Move memcmp2 to util. Change use of namespaces a little because Doxygen
[metaproxy-moved-to-github.git] / src / util.hpp
1 /* $Id: util.hpp,v 1.15 2006-06-09 14:12:13 adam Exp $
2    Copyright (c) 2005-2006, Index Data.
3
4 %LICENSE%
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(Z_APDU *apdu);
30
31         Z_APDU *create_APDU(ODR odr, int type, Z_APDU *in_apdu);
32
33         bool set_databases_from_zurl(ODR odr, std::string zurl,
34                                      int *db_num, char ***db_strings);
35
36         void split_zurl(std::string zurl, std::string &host,
37                         std::list<std::string> &db);
38
39         int get_vhost_otherinfo(Z_OtherInformation **otherInformation,
40                                 bool remove_flag,
41                                 std::list<std::string> &vhosts);
42
43         void set_vhost_otherinfo(Z_OtherInformation **otherInformation,
44                                  ODR odr,
45                                  const std::list<std::string> &vhosts);
46
47         void get_init_diagnostics(Z_InitResponse *res,
48                                   int &error_code, std::string &addinfo);
49
50         void get_default_diag(Z_DefaultDiagFormat *r,
51                               int &error_code, std::string &addinfo);
52
53         void piggyback(int smallSetUpperBound,
54                        int largeSetLowerBound,
55                        int mediumSetPresentNumber,
56                        int result_set_size,
57                        int &number_to_present);
58     };
59
60     class odr : public boost::noncopyable {
61     public:
62         odr(int type);
63         odr();
64         ~odr();
65         operator ODR() const;
66         Z_APDU *create_close(Z_APDU *in_apdu, 
67                              int reason, const char *addinfo);
68         Z_APDU *create_initResponse(Z_APDU *in_apdu, 
69                                     int error, const char *addinfo);
70         Z_APDU *create_searchResponse(Z_APDU *in_apdu,
71                                       int error, const char *addinfo);
72         Z_APDU *create_presentResponse(Z_APDU *in_apdu,
73                                        int error, const char *addinfo);
74         Z_APDU *create_scanResponse(Z_APDU *in_apdu,
75                                     int error, const char *addinfo);
76         Z_APDU *create_APDU(int type, Z_APDU *in_apdu);
77         Z_GDU *create_HTTP_Response(metaproxy_1::Session &session,
78                                     Z_HTTP_Request *req, int code);
79     private:
80         ODR m_odr;
81     };
82
83     class PlainFile {
84         class Rep;
85         boost::scoped_ptr<Rep> m_p;
86     public:
87         PlainFile();
88         ~PlainFile();
89         bool open(const std::string &fname);
90         bool getline(std::vector<std::string> &args);
91     };
92 }
93 #endif
94 /*
95  * Local variables:
96  * c-basic-offset: 4
97  * indent-tabs-mode: nil
98  * c-file-style: "stroustrup"
99  * End:
100  * vim: shiftwidth=4 tabstop=8 expandtab
101  */