added regex core functionality for filter_query_rewrite
[metaproxy-moved-to-github.git] / src / util.hpp
1 /* $Id: util.hpp,v 1.11 2006-01-20 22:38:12 marc Exp $
2    Copyright (c) 2005, 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
14 #include <boost/utility.hpp>
15
16 #include "package.hpp"
17
18 namespace yp2 {
19     namespace util  {
20         bool pqf(ODR odr, Z_APDU *apdu, const std::string &q);
21
22         std::string zQueryToString(Z_Query *query);
23
24         Z_ReferenceId **get_referenceId(Z_APDU *apdu);
25
26         Z_APDU *create_APDU(ODR odr, int type, Z_APDU *in_apdu);
27
28         bool set_databases_from_zurl(ODR odr, std::string zurl,
29                                      int *db_num, char ***db_strings);
30
31         void split_zurl(std::string zurl, std::string &host,
32                         std::list<std::string> &db);
33
34         int get_vhost_otherinfo(Z_OtherInformation **otherInformation,
35                                 bool remove_flag,
36                                 std::list<std::string> &vhosts);
37
38         void set_vhost_otherinfo(Z_OtherInformation **otherInformation,
39                                  ODR odr,
40                                  const std::list<std::string> &vhosts);
41
42         void get_init_diagnostics(Z_InitResponse *res,
43                                   int &error_code, std::string &addinfo);
44
45         void get_default_diag(Z_DefaultDiagFormat *r,
46                               int &error_code, std::string &addinfo);
47
48         void piggyback(int smallSetUpperBound,
49                        int largeSetLowerBound,
50                        int mediumSetPresentNumber,
51                        int result_set_size,
52                        int &number_to_present);
53     };
54
55     class odr : public boost::noncopyable {
56     public:
57         odr(int type);
58         odr();
59         ~odr();
60         operator ODR() const;
61         Z_APDU *create_close(Z_APDU *in_apdu, 
62                              int reason, const char *addinfo);
63         Z_APDU *create_initResponse(Z_APDU *in_apdu, 
64                                     int error, const char *addinfo);
65         Z_APDU *create_searchResponse(Z_APDU *in_apdu,
66                                       int error, const char *addinfo);
67         Z_APDU *create_presentResponse(Z_APDU *in_apdu,
68                                        int error, const char *addinfo);
69         Z_APDU *create_scanResponse(Z_APDU *in_apdu,
70                                     int error, const char *addinfo);
71         Z_APDU *create_APDU(int type, Z_APDU *in_apdu);
72         Z_GDU *create_HTTP_Response(yp2::Session &session,
73                                     Z_HTTP_Request *req, int code);
74     private:
75         ODR m_odr;
76     };
77         
78 }
79 #endif
80 /*
81  * Local variables:
82  * c-basic-offset: 4
83  * indent-tabs-mode: nil
84  * c-file-style: "stroustrup"
85  * End:
86  * vim: shiftwidth=4 tabstop=8 expandtab
87  */