Implemented first bits of http_file filter which serves plain
[metaproxy-moved-to-github.git] / src / util.hpp
1 /* $Id: util.hpp,v 1.10 2006-01-19 21:43:51 adam 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         Z_ReferenceId **get_referenceId(Z_APDU *apdu);
22         Z_APDU *create_APDU(ODR odr, int type, Z_APDU *in_apdu);
23         bool set_databases_from_zurl(ODR odr, std::string zurl,
24                                      int *db_num, char ***db_strings);
25         void split_zurl(std::string zurl, std::string &host,
26                         std::list<std::string> &db);
27
28         int get_vhost_otherinfo(Z_OtherInformation **otherInformation,
29                                 bool remove_flag,
30                                 std::list<std::string> &vhosts);
31         void set_vhost_otherinfo(Z_OtherInformation **otherInformation,
32                                  ODR odr,
33                                  const std::list<std::string> &vhosts);
34         void get_init_diagnostics(Z_InitResponse *res,
35                                   int &error_code, std::string &addinfo);
36         void get_default_diag(Z_DefaultDiagFormat *r,
37                               int &error_code, std::string &addinfo);
38
39         void piggyback(int smallSetUpperBound,
40                        int largeSetLowerBound,
41                        int mediumSetPresentNumber,
42                        int result_set_size,
43                        int &number_to_present);
44     };
45
46     class odr : public boost::noncopyable {
47     public:
48         odr(int type);
49         odr();
50         ~odr();
51         operator ODR() const;
52         Z_APDU *create_close(Z_APDU *in_apdu, 
53                              int reason, const char *addinfo);
54         Z_APDU *create_initResponse(Z_APDU *in_apdu, 
55                                     int error, const char *addinfo);
56         Z_APDU *create_searchResponse(Z_APDU *in_apdu,
57                                       int error, const char *addinfo);
58         Z_APDU *create_presentResponse(Z_APDU *in_apdu,
59                                        int error, const char *addinfo);
60         Z_APDU *create_scanResponse(Z_APDU *in_apdu,
61                                     int error, const char *addinfo);
62         Z_APDU *create_APDU(int type, Z_APDU *in_apdu);
63         Z_GDU *create_HTTP_Response(yp2::Session &session,
64                                     Z_HTTP_Request *req, int code);
65     private:
66         ODR m_odr;
67     };
68         
69 }
70 #endif
71 /*
72  * Local variables:
73  * c-basic-offset: 4
74  * indent-tabs-mode: nil
75  * c-file-style: "stroustrup"
76  * End:
77  * vim: shiftwidth=4 tabstop=8 expandtab
78  */