Ignore new "metaproxy" binary rather than old "yp2"
[metaproxy-moved-to-github.git] / src / util.hpp
1 /* $Id: util.hpp,v 1.13 2006-03-16 10:40:59 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         bool pqf(ODR odr, Z_APDU *apdu, const std::string &q);
22
23         std::string zQueryToString(Z_Query *query);
24
25         Z_ReferenceId **get_referenceId(Z_APDU *apdu);
26
27         Z_APDU *create_APDU(ODR odr, int type, Z_APDU *in_apdu);
28
29         bool set_databases_from_zurl(ODR odr, std::string zurl,
30                                      int *db_num, char ***db_strings);
31
32         void split_zurl(std::string zurl, std::string &host,
33                         std::list<std::string> &db);
34
35         int get_vhost_otherinfo(Z_OtherInformation **otherInformation,
36                                 bool remove_flag,
37                                 std::list<std::string> &vhosts);
38
39         void set_vhost_otherinfo(Z_OtherInformation **otherInformation,
40                                  ODR odr,
41                                  const std::list<std::string> &vhosts);
42
43         void get_init_diagnostics(Z_InitResponse *res,
44                                   int &error_code, std::string &addinfo);
45
46         void get_default_diag(Z_DefaultDiagFormat *r,
47                               int &error_code, std::string &addinfo);
48
49         void piggyback(int smallSetUpperBound,
50                        int largeSetLowerBound,
51                        int mediumSetPresentNumber,
52                        int result_set_size,
53                        int &number_to_present);
54     };
55
56     class odr : public boost::noncopyable {
57     public:
58         odr(int type);
59         odr();
60         ~odr();
61         operator ODR() const;
62         Z_APDU *create_close(Z_APDU *in_apdu, 
63                              int reason, const char *addinfo);
64         Z_APDU *create_initResponse(Z_APDU *in_apdu, 
65                                     int error, const char *addinfo);
66         Z_APDU *create_searchResponse(Z_APDU *in_apdu,
67                                       int error, const char *addinfo);
68         Z_APDU *create_presentResponse(Z_APDU *in_apdu,
69                                        int error, const char *addinfo);
70         Z_APDU *create_scanResponse(Z_APDU *in_apdu,
71                                     int error, const char *addinfo);
72         Z_APDU *create_APDU(int type, Z_APDU *in_apdu);
73         Z_GDU *create_HTTP_Response(metaproxy_1::Session &session,
74                                     Z_HTTP_Request *req, int code);
75     private:
76         ODR m_odr;
77     };
78
79     class PlainFile {
80         class Rep;
81         boost::scoped_ptr<Rep> m_p;
82     public:
83         PlainFile();
84         ~PlainFile();
85         bool open(const std::string &fname);
86         bool getline(std::vector<std::string> &args);
87     };
88 }
89 #endif
90 /*
91  * Local variables:
92  * c-basic-offset: 4
93  * indent-tabs-mode: nil
94  * c-file-style: "stroustrup"
95  * End:
96  * vim: shiftwidth=4 tabstop=8 expandtab
97  */