Change forms of get_vhost functions.. get_vhost_otherinfo returns
[metaproxy-moved-to-github.git] / src / util.hpp
1 /* $Id: util.hpp,v 1.18 2006-08-30 12:27:34 adam Exp $
2    Copyright (c) 2005-2006, Index Data.
3
4    See the LICENSE file for details
5  */
6
7 #ifndef YP2_UTIL_HPP
8 #define YP2_UTIL_HPP
9
10 #include <yaz/z-core.h>
11 #include <string>
12 #include <list>
13 #include <vector>
14
15 #include <boost/utility.hpp>
16 #include <boost/scoped_ptr.hpp>
17 #include "package.hpp"
18
19 namespace metaproxy_1 {
20     namespace util  {
21         int memcmp2(const void *buf1, int len1, const void *buf2, int len2);
22
23         std::string database_name_normalize(const std::string &s);
24
25         bool pqf(ODR odr, Z_APDU *apdu, const std::string &q);
26
27         std::string zQueryToString(Z_Query *query);
28
29         Z_ReferenceId **get_referenceId(const Z_APDU *apdu);
30
31         void transfer_referenceId(ODR odr, const Z_APDU *src, Z_APDU *dst);
32
33         Z_APDU *create_APDU(ODR odr, int type, const Z_APDU *in_apdu);
34
35         bool set_databases_from_zurl(ODR odr, std::string zurl,
36                                      int *db_num, char ***db_strings);
37
38         void split_zurl(std::string zurl, std::string &host,
39                         std::list<std::string> &db);
40         
41         void get_vhost_otherinfo(Z_OtherInformation *otherInformation,
42                                  std::list<std::string> &vhosts);
43         
44         int remove_vhost_otherinfo(Z_OtherInformation **otherInformation,
45                                    std::list<std::string> &vhosts);
46
47         void set_vhost_otherinfo(Z_OtherInformation **otherInformation,
48                                  ODR odr,
49                                  const std::list<std::string> &vhosts);
50
51         int get_or_remove_vhost_otherinfo(
52             Z_OtherInformation **otherInformation,
53             bool remove_flag,
54             std::list<std::string> &vhosts);
55
56         void get_init_diagnostics(Z_InitResponse *res,
57                                   int &error_code, std::string &addinfo);
58
59         void get_default_diag(Z_DefaultDiagFormat *r,
60                               int &error_code, std::string &addinfo);
61
62         void piggyback(int smallSetUpperBound,
63                        int largeSetLowerBound,
64                        int mediumSetPresentNumber,
65                        int result_set_size,
66                        int &number_to_present);
67     };
68
69     class odr : public boost::noncopyable {
70     public:
71         odr(int type);
72         odr();
73         ~odr();
74         operator ODR() const;
75         Z_APDU *create_close(const Z_APDU *in_apdu, 
76                              int reason, const char *addinfo);
77         Z_APDU *create_initResponse(const Z_APDU *in_apdu, 
78                                     int error, const char *addinfo);
79         Z_APDU *create_searchResponse(const Z_APDU *in_apdu,
80                                       int error, const char *addinfo);
81         Z_APDU *create_presentResponse(const Z_APDU *in_apdu,
82                                        int error, const char *addinfo);
83         Z_APDU *create_scanResponse(const Z_APDU *in_apdu,
84                                     int error, const char *addinfo);
85         Z_APDU *create_APDU(int type, const Z_APDU *in_apdu);
86
87         Z_GDU *create_HTTP_Response(metaproxy_1::Session &session,
88                                     Z_HTTP_Request *req, int code);
89     private:
90         ODR m_odr;
91     };
92
93     class PlainFile {
94         class Rep;
95         boost::scoped_ptr<Rep> m_p;
96     public:
97         PlainFile();
98         ~PlainFile();
99         bool open(const std::string &fname);
100         bool getline(std::vector<std::string> &args);
101     };
102 }
103 #endif
104 /*
105  * Local variables:
106  * c-basic-offset: 4
107  * indent-tabs-mode: nil
108  * c-file-style: "stroustrup"
109  * End:
110  * vim: shiftwidth=4 tabstop=8 expandtab
111  */