1 /* $Id: util.hpp,v 1.22 2006-10-04 14:04:00 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)
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::list<std::string> &vhosts);
79 int get_or_remove_vhost_otherinfo(
80 Z_OtherInformation **otherInformation,
82 std::list<std::string> &vhosts);
84 void get_init_diagnostics(Z_InitResponse *res,
85 int &error_code, std::string &addinfo);
87 void get_default_diag(Z_DefaultDiagFormat *r,
88 int &error_code, std::string &addinfo);
90 void piggyback(int smallSetUpperBound,
91 int largeSetLowerBound,
92 int mediumSetPresentNumber,
94 int &number_to_present);
97 class odr : public boost::noncopyable {
102 operator ODR() const;
103 Z_APDU *create_close(const Z_APDU *in_apdu,
104 int reason, const char *addinfo);
105 Z_APDU *create_initResponse(const Z_APDU *in_apdu,
106 int error, const char *addinfo);
107 Z_APDU *create_searchResponse(const Z_APDU *in_apdu,
108 int error, const char *addinfo);
109 Z_APDU *create_presentResponse(const Z_APDU *in_apdu,
110 int error, const char *addinfo);
111 Z_APDU *create_scanResponse(const Z_APDU *in_apdu,
112 int error, const char *addinfo);
113 Z_APDU *create_APDU(int type, const Z_APDU *in_apdu);
115 Z_GDU *create_HTTP_Response(metaproxy_1::Session &session,
116 Z_HTTP_Request *req, int code);
123 boost::scoped_ptr<Rep> m_p;
127 bool open(const std::string &fname);
128 bool getline(std::vector<std::string> &args);
135 * indent-tabs-mode: nil
136 * c-file-style: "stroustrup"
138 * vim: shiftwidth=4 tabstop=8 expandtab