38eabb9b7c0a442d069db70c85eb34c04fee0097
[metaproxy-moved-to-github.git] / src / sru_util.hpp
1 /* This file is part of Metaproxy.
2    Copyright (C) Index Data
3
4 Metaproxy is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17 */
18
19 #ifndef YP2_SDU_UTIL_HPP
20 #define YP2_SDU_UTIL_HPP
21
22 #include <metaproxy/util.hpp>
23 #include <metaproxy/package.hpp>
24
25 #include <yaz/srw.h>
26
27 #include <iosfwd>
28 #include <string>
29
30 namespace std
31 {
32     std::ostream& operator<<(std::ostream& os, Z_SRW_PDU& srw_pdu);
33
34 }
35
36
37 namespace metaproxy_1 {
38     namespace util  {
39
40         class SRUServerInfo;
41
42         // std::string sru_protocol(const Z_HTTP_Request &http_req);
43         // std::string debug_http(const Z_HTTP_Request &http_req);
44         // void http_response(mp::Package &package,
45         //                   const std::string &content,
46         //                   int http_code = 200);
47
48         bool build_sru_debug_package(metaproxy_1::Package &package);
49
50         SRUServerInfo get_sru_server_info(metaproxy_1::Package &package);
51                                           // Z_SRW_explainRequest
52                                           //const *er_req);
53
54 //         bool build_simple_explain(metaproxy_1::Package &package,
55 //                                   metaproxy_1::odr &odr_en,
56 //                                   Z_SRW_PDU *sru_pdu_res,
57 //                                   SRUServerInfo sruinfo,
58 //                                   Z_SRW_explainRequest const *er_req = 0);
59
60         bool build_sru_explain(metaproxy_1::Package &package,
61                                metaproxy_1::odr &odr_en,
62                                Z_SRW_PDU *sru_pdu_res,
63                                SRUServerInfo sruinfo,
64                                const xmlNode *explain = 0,
65                                Z_SRW_explainRequest const *er_req = 0);
66
67         bool build_sru_response(metaproxy_1::Package &package,
68                                 metaproxy_1::odr &odr_en,
69                                 Z_SOAP *soap,
70                                 const Z_SRW_PDU *sru_pdu_res,
71                                 char *charset,
72                                 const char *stylesheet);
73
74         Z_SRW_PDU * decode_sru_request(metaproxy_1::Package &package,
75                                        metaproxy_1::odr &odr_de,
76                                        metaproxy_1::odr &odr_en,
77                                        Z_SRW_PDU *sru_pdu_res,
78                                        Z_SOAP **soap,
79                                        char *charset);
80
81         bool check_sru_query_exists(metaproxy_1::Package &package,
82                                     metaproxy_1::odr &odr_en,
83                                     Z_SRW_PDU *sru_pdu_res,
84                                     Z_SRW_searchRetrieveRequest
85                                     const *sr_req);
86
87         Z_ElementSetNames * build_esn_from_schema(metaproxy_1::odr &odr_en,
88                                                   const char *schema);
89
90         class SRUServerInfo
91         {
92         public:
93             SRUServerInfo ()
94                 : database("Default")
95                 {}
96         public:
97             std::string database;
98             std::string host;
99             std::string port;
100         };
101
102
103
104
105 //         class SRU
106 //         {
107 //         public:
108 //             enum SRU_protocol_type { SRU_NONE, SRU_GET, SRU_POST, SRU_SOAP};
109 //             typedef const int SRU_query_type;
110 //             union SRW_query {char * cql; char * xcql; char * pqf;};
111 //         private:
112 //             //bool decode(const Z_HTTP_Request &http_req);
113 //             SRU_protocol_type protocol(const Z_HTTP_Request &http_req) const;
114 //         private:
115 //             SRU_protocol_type m_protocol;
116 //             std::string m_charset;
117 //             std::string m_stylesheet;
118 //         };
119     }
120 }
121
122 #endif
123 /*
124  * Local variables:
125  * c-basic-offset: 4
126  * c-file-style: "Stroustrup"
127  * indent-tabs-mode: nil
128  * End:
129  * vim: shiftwidth=4 tabstop=8 expandtab
130  */
131