1 /* $Id: util.hpp,v 1.21 2006-10-03 07:57:40 marc Exp $
2 Copyright (c) 2005-2006, 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)
36 std::string http_header_value(const Z_HTTP_Header* header,
37 const std::string name);
39 std::string http_headers_debug(const Z_HTTP_Request &http_req);
41 void http_response(metaproxy_1::Package &package,
42 const std::string &content,
46 int memcmp2(const void *buf1, int len1, const void *buf2, int len2);
48 std::string database_name_normalize(const std::string &s);
50 bool pqf(ODR odr, Z_APDU *apdu, const std::string &q);
52 std::string zQueryToString(Z_Query *query);
54 Z_ReferenceId **get_referenceId(const Z_APDU *apdu);
56 void transfer_referenceId(ODR odr, const Z_APDU *src, Z_APDU *dst);
58 Z_APDU *create_APDU(ODR odr, int type, const Z_APDU *in_apdu);
60 bool set_databases_from_zurl(ODR odr, std::string zurl,
61 int *db_num, char ***db_strings);
63 void split_zurl(std::string zurl, std::string &host,
64 std::list<std::string> &db);
66 void get_vhost_otherinfo(Z_OtherInformation *otherInformation,
67 std::list<std::string> &vhosts);
69 int remove_vhost_otherinfo(Z_OtherInformation **otherInformation,
70 std::list<std::string> &vhosts);
72 void set_vhost_otherinfo(Z_OtherInformation **otherInformation,
74 const std::list<std::string> &vhosts);
76 int get_or_remove_vhost_otherinfo(
77 Z_OtherInformation **otherInformation,
79 std::list<std::string> &vhosts);
81 void get_init_diagnostics(Z_InitResponse *res,
82 int &error_code, std::string &addinfo);
84 void get_default_diag(Z_DefaultDiagFormat *r,
85 int &error_code, std::string &addinfo);
87 void piggyback(int smallSetUpperBound,
88 int largeSetLowerBound,
89 int mediumSetPresentNumber,
91 int &number_to_present);
94 class odr : public boost::noncopyable {
100 Z_APDU *create_close(const Z_APDU *in_apdu,
101 int reason, const char *addinfo);
102 Z_APDU *create_initResponse(const Z_APDU *in_apdu,
103 int error, const char *addinfo);
104 Z_APDU *create_searchResponse(const Z_APDU *in_apdu,
105 int error, const char *addinfo);
106 Z_APDU *create_presentResponse(const Z_APDU *in_apdu,
107 int error, const char *addinfo);
108 Z_APDU *create_scanResponse(const Z_APDU *in_apdu,
109 int error, const char *addinfo);
110 Z_APDU *create_APDU(int type, const Z_APDU *in_apdu);
112 Z_GDU *create_HTTP_Response(metaproxy_1::Session &session,
113 Z_HTTP_Request *req, int code);
120 boost::scoped_ptr<Rep> m_p;
124 bool open(const std::string &fname);
125 bool getline(std::vector<std::string> &args);
132 * indent-tabs-mode: nil
133 * c-file-style: "stroustrup"
135 * vim: shiftwidth=4 tabstop=8 expandtab