Added yp2::util split_zurl and get_vhost_otherinfo.
[metaproxy-moved-to-github.git] / src / util.hpp
1 /* $Id: util.hpp,v 1.6 2006-01-17 13:34: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 namespace yp2 {
17     namespace util  {
18         bool pqf(ODR odr, Z_APDU *apdu, const std::string &q);
19         Z_ReferenceId **get_referenceId(Z_APDU *apdu);
20         Z_APDU *create_APDU(ODR odr, int type, Z_APDU *in_apdu);
21         bool set_databases_from_zurl(ODR odr, std::string zurl,
22                                      int *db_num, char ***db_strings);
23         void split_zurl(std::string zurl, std::string &host,
24                         std::list<std::string> &db);
25
26         int get_vhost_otherinfo(Z_OtherInformation **otherInformation,
27                                 bool remove_flag,
28                                 std::list<std::string> &vhosts);
29     };
30
31     class odr : public boost::noncopyable {
32     public:
33         odr(int type);
34         odr();
35         ~odr();
36         operator ODR() const;
37         Z_APDU *create_close(Z_APDU *in_apdu, 
38                              int reason, const char *addinfo);
39         Z_APDU *create_initResponse(Z_APDU *in_apdu, 
40                                     int error, const char *addinfo);
41         Z_APDU *create_searchResponse(Z_APDU *in_apdu,
42                                       int error, const char *addinfo);
43         Z_APDU *create_presentResponse(Z_APDU *in_apdu,
44                                        int error, const char *addinfo);
45         Z_APDU *create_scanResponse(Z_APDU *in_apdu,
46                                     int error, const char *addinfo);
47         Z_APDU *create_APDU(int type, Z_APDU *in_apdu);
48     private:
49         ODR m_odr;
50     };
51         
52 }
53 #endif
54 /*
55  * Local variables:
56  * c-basic-offset: 4
57  * indent-tabs-mode: nil
58  * c-file-style: "stroustrup"
59  * End:
60  * vim: shiftwidth=4 tabstop=8 expandtab
61  */