1 /* $Id: util.hpp,v 1.25 2007-05-09 21:23:09 adam Exp $
2 Copyright (c) 2005-2007, Index Data.
4 This file is part of Metaproxy.
6 Metaproxy is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
11 Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with Metaproxy; see the file LICENSE. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
25 #include "package.hpp"
27 #include <yaz/z-core.h>
29 #include <boost/utility.hpp>
30 #include <boost/scoped_ptr.hpp>
38 namespace metaproxy_1 {
43 std::string to_string(const T& t)
52 record_composition_to_esn(Z_RecordComposition *comp);
54 std::string http_header_value(const Z_HTTP_Header* header,
55 const std::string name);
57 std::string http_headers_debug(const Z_HTTP_Request &http_req);
59 void http_response(metaproxy_1::Package &package,
60 const std::string &content,
64 int memcmp2(const void *buf1, int len1, const void *buf2, int len2);
66 std::string database_name_normalize(const std::string &s);
68 bool pqf(ODR odr, Z_APDU *apdu, const std::string &q);
70 std::string zQueryToString(Z_Query *query);
72 Z_ReferenceId **get_referenceId(const Z_APDU *apdu);
74 void transfer_referenceId(ODR odr, const Z_APDU *src, Z_APDU *dst);
76 Z_APDU *create_APDU(ODR odr, int type, const Z_APDU *in_apdu);
78 bool set_databases_from_zurl(ODR odr, std::string zurl,
79 int *db_num, char ***db_strings);
81 void split_zurl(std::string zurl, std::string &host,
82 std::list<std::string> &db);
84 void get_vhost_otherinfo(Z_OtherInformation *otherInformation,
85 std::list<std::string> &vhosts);
87 int remove_vhost_otherinfo(Z_OtherInformation **otherInformation,
88 std::list<std::string> &vhosts);
90 void set_vhost_otherinfo(Z_OtherInformation **otherInformation,
92 const std::string vhost,
95 void set_vhost_otherinfo(Z_OtherInformation **otherInformation,
97 const std::list<std::string> &vhosts);
99 int get_or_remove_vhost_otherinfo(
100 Z_OtherInformation **otherInformation,
102 std::list<std::string> &vhosts);
104 void get_init_diagnostics(Z_InitResponse *res,
105 int &error_code, std::string &addinfo);
107 void get_default_diag(Z_DefaultDiagFormat *r,
108 int &error_code, std::string &addinfo);
110 void piggyback(int smallSetUpperBound,
111 int largeSetLowerBound,
112 int mediumSetPresentNumber,
114 int &number_to_present);
117 class odr : public boost::noncopyable {
122 operator ODR() const;
123 Z_APDU *create_close(const Z_APDU *in_apdu,
124 int reason, const char *addinfo);
125 Z_APDU *create_initResponse(const Z_APDU *in_apdu,
126 int error, const char *addinfo);
127 Z_APDU *create_searchResponse(const Z_APDU *in_apdu,
128 int error, const char *addinfo);
129 Z_APDU *create_presentResponse(const Z_APDU *in_apdu,
130 int error, const char *addinfo);
131 Z_APDU *create_scanResponse(const Z_APDU *in_apdu,
132 int error, const char *addinfo);
133 Z_APDU *create_APDU(int type, const Z_APDU *in_apdu);
135 Z_GDU *create_HTTP_Response(metaproxy_1::Session &session,
136 Z_HTTP_Request *req, int code);
143 boost::scoped_ptr<Rep> m_p;
147 bool open(const std::string &fname);
148 bool getline(std::vector<std::string> &args);
155 * indent-tabs-mode: nil
156 * c-file-style: "stroustrup"
158 * vim: shiftwidth=4 tabstop=8 expandtab