1 /* This file is part of Metaproxy.
2 Copyright (C) 2005-2008 Index Data
4 Metaproxy is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
9 Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "package.hpp"
24 #include <yaz/z-core.h>
26 #include <boost/utility.hpp>
27 #include <boost/scoped_ptr.hpp>
35 namespace metaproxy_1 {
40 std::string to_string(const T& t)
49 record_composition_to_esn(Z_RecordComposition *comp);
51 std::string http_header_value(const Z_HTTP_Header* header,
52 const std::string name);
54 std::string http_headers_debug(const Z_HTTP_Request &http_req);
56 void http_response(metaproxy_1::Package &package,
57 const std::string &content,
61 int memcmp2(const void *buf1, int len1, const void *buf2, int len2);
63 std::string database_name_normalize(const std::string &s);
65 bool pqf(ODR odr, Z_APDU *apdu, const std::string &q);
67 std::string zQueryToString(Z_Query *query);
69 Z_ReferenceId **get_referenceId(const Z_APDU *apdu);
71 void transfer_referenceId(ODR odr, const Z_APDU *src, Z_APDU *dst);
73 Z_APDU *create_APDU(ODR odr, int type, const Z_APDU *in_apdu);
75 bool set_databases_from_zurl(ODR odr, std::string zurl,
76 int *db_num, char ***db_strings);
78 void split_zurl(std::string zurl, std::string &host,
79 std::list<std::string> &db);
81 void get_vhost_otherinfo(Z_OtherInformation *otherInformation,
82 std::list<std::string> &vhosts);
84 int remove_vhost_otherinfo(Z_OtherInformation **otherInformation,
85 std::list<std::string> &vhosts);
87 void set_vhost_otherinfo(Z_OtherInformation **otherInformation,
89 const std::string vhost,
92 void set_vhost_otherinfo(Z_OtherInformation **otherInformation,
94 const std::list<std::string> &vhosts);
96 int get_or_remove_vhost_otherinfo(
97 Z_OtherInformation **otherInformation,
99 std::list<std::string> &vhosts);
101 void get_init_diagnostics(Z_InitResponse *res,
102 int &error_code, std::string &addinfo);
104 void get_default_diag(Z_DefaultDiagFormat *r,
105 int &error_code, std::string &addinfo);
107 void piggyback(int smallSetUpperBound,
108 int largeSetLowerBound,
109 int mediumSetPresentNumber,
111 int &number_to_present);
114 class odr : public boost::noncopyable {
119 operator ODR() const;
120 Z_APDU *create_close(const Z_APDU *in_apdu,
121 int reason, const char *addinfo);
122 Z_APDU *create_initResponse(const Z_APDU *in_apdu,
123 int error, const char *addinfo);
124 Z_APDU *create_searchResponse(const Z_APDU *in_apdu,
125 int error, const char *addinfo);
126 Z_APDU *create_presentResponse(const Z_APDU *in_apdu,
127 int error, const char *addinfo);
128 Z_APDU *create_scanResponse(const Z_APDU *in_apdu,
129 int error, const char *addinfo);
130 Z_APDU *create_APDU(int type, const Z_APDU *in_apdu);
132 Z_GDU *create_HTTP_Response(metaproxy_1::Session &session,
133 Z_HTTP_Request *req, int code);
140 boost::scoped_ptr<Rep> m_p;
144 bool open(const std::string &fname);
145 bool getline(std::vector<std::string> &args);
152 * c-file-style: "Stroustrup"
153 * indent-tabs-mode: nil
155 * vim: shiftwidth=4 tabstop=8 expandtab