1 /* $Id: util.hpp,v 1.19 2006-09-29 08:42:47 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>
24 namespace metaproxy_1 {
29 std::string to_string(const T& t)
37 std::string http_header_value(const Z_HTTP_Header* header,
38 const std::string name);
40 int memcmp2(const void *buf1, int len1, const void *buf2, int len2);
42 std::string database_name_normalize(const std::string &s);
44 bool pqf(ODR odr, Z_APDU *apdu, const std::string &q);
46 std::string zQueryToString(Z_Query *query);
48 Z_ReferenceId **get_referenceId(const Z_APDU *apdu);
50 void transfer_referenceId(ODR odr, const Z_APDU *src, Z_APDU *dst);
52 Z_APDU *create_APDU(ODR odr, int type, const Z_APDU *in_apdu);
54 bool set_databases_from_zurl(ODR odr, std::string zurl,
55 int *db_num, char ***db_strings);
57 void split_zurl(std::string zurl, std::string &host,
58 std::list<std::string> &db);
60 void get_vhost_otherinfo(Z_OtherInformation *otherInformation,
61 std::list<std::string> &vhosts);
63 int remove_vhost_otherinfo(Z_OtherInformation **otherInformation,
64 std::list<std::string> &vhosts);
66 void set_vhost_otherinfo(Z_OtherInformation **otherInformation,
68 const std::list<std::string> &vhosts);
70 int get_or_remove_vhost_otherinfo(
71 Z_OtherInformation **otherInformation,
73 std::list<std::string> &vhosts);
75 void get_init_diagnostics(Z_InitResponse *res,
76 int &error_code, std::string &addinfo);
78 void get_default_diag(Z_DefaultDiagFormat *r,
79 int &error_code, std::string &addinfo);
81 void piggyback(int smallSetUpperBound,
82 int largeSetLowerBound,
83 int mediumSetPresentNumber,
85 int &number_to_present);
88 class odr : public boost::noncopyable {
94 Z_APDU *create_close(const Z_APDU *in_apdu,
95 int reason, const char *addinfo);
96 Z_APDU *create_initResponse(const Z_APDU *in_apdu,
97 int error, const char *addinfo);
98 Z_APDU *create_searchResponse(const Z_APDU *in_apdu,
99 int error, const char *addinfo);
100 Z_APDU *create_presentResponse(const Z_APDU *in_apdu,
101 int error, const char *addinfo);
102 Z_APDU *create_scanResponse(const Z_APDU *in_apdu,
103 int error, const char *addinfo);
104 Z_APDU *create_APDU(int type, const Z_APDU *in_apdu);
106 Z_GDU *create_HTTP_Response(metaproxy_1::Session &session,
107 Z_HTTP_Request *req, int code);
114 boost::scoped_ptr<Rep> m_p;
118 bool open(const std::string &fname);
119 bool getline(std::vector<std::string> &args);
126 * indent-tabs-mode: nil
127 * c-file-style: "stroustrup"
129 * vim: shiftwidth=4 tabstop=8 expandtab