1 /* $Id: util.hpp,v 1.24 2007-01-25 14:05:54 adam Exp $
2 Copyright (c) 2005-2007, Index Data.
4 See the LICENSE file for details
10 #include "package.hpp"
12 #include <yaz/z-core.h>
14 #include <boost/utility.hpp>
15 #include <boost/scoped_ptr.hpp>
23 namespace metaproxy_1 {
28 std::string to_string(const T& t)
37 record_composition_to_esn(Z_RecordComposition *comp);
39 std::string http_header_value(const Z_HTTP_Header* header,
40 const std::string name);
42 std::string http_headers_debug(const Z_HTTP_Request &http_req);
44 void http_response(metaproxy_1::Package &package,
45 const std::string &content,
49 int memcmp2(const void *buf1, int len1, const void *buf2, int len2);
51 std::string database_name_normalize(const std::string &s);
53 bool pqf(ODR odr, Z_APDU *apdu, const std::string &q);
55 std::string zQueryToString(Z_Query *query);
57 Z_ReferenceId **get_referenceId(const Z_APDU *apdu);
59 void transfer_referenceId(ODR odr, const Z_APDU *src, Z_APDU *dst);
61 Z_APDU *create_APDU(ODR odr, int type, const Z_APDU *in_apdu);
63 bool set_databases_from_zurl(ODR odr, std::string zurl,
64 int *db_num, char ***db_strings);
66 void split_zurl(std::string zurl, std::string &host,
67 std::list<std::string> &db);
69 void get_vhost_otherinfo(Z_OtherInformation *otherInformation,
70 std::list<std::string> &vhosts);
72 int remove_vhost_otherinfo(Z_OtherInformation **otherInformation,
73 std::list<std::string> &vhosts);
75 void set_vhost_otherinfo(Z_OtherInformation **otherInformation,
77 const std::string vhost,
80 void set_vhost_otherinfo(Z_OtherInformation **otherInformation,
82 const std::list<std::string> &vhosts);
84 int get_or_remove_vhost_otherinfo(
85 Z_OtherInformation **otherInformation,
87 std::list<std::string> &vhosts);
89 void get_init_diagnostics(Z_InitResponse *res,
90 int &error_code, std::string &addinfo);
92 void get_default_diag(Z_DefaultDiagFormat *r,
93 int &error_code, std::string &addinfo);
95 void piggyback(int smallSetUpperBound,
96 int largeSetLowerBound,
97 int mediumSetPresentNumber,
99 int &number_to_present);
102 class odr : public boost::noncopyable {
107 operator ODR() const;
108 Z_APDU *create_close(const Z_APDU *in_apdu,
109 int reason, const char *addinfo);
110 Z_APDU *create_initResponse(const Z_APDU *in_apdu,
111 int error, const char *addinfo);
112 Z_APDU *create_searchResponse(const Z_APDU *in_apdu,
113 int error, const char *addinfo);
114 Z_APDU *create_presentResponse(const Z_APDU *in_apdu,
115 int error, const char *addinfo);
116 Z_APDU *create_scanResponse(const Z_APDU *in_apdu,
117 int error, const char *addinfo);
118 Z_APDU *create_APDU(int type, const Z_APDU *in_apdu);
120 Z_GDU *create_HTTP_Response(metaproxy_1::Session &session,
121 Z_HTTP_Request *req, int code);
128 boost::scoped_ptr<Rep> m_p;
132 bool open(const std::string &fname);
133 bool getline(std::vector<std::string> &args);
140 * indent-tabs-mode: nil
141 * c-file-style: "stroustrup"
143 * vim: shiftwidth=4 tabstop=8 expandtab