Updated footer comment
[metaproxy-moved-to-github.git] / src / sru_util.hpp
1 /* This file is part of Metaproxy.
2    Copyright (C) 2005-2008 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 "util.hpp"
23 #include "package.hpp"
24
25 //#include <yaz/zgdu.h>
26 //#include <yaz/z-core.h>
27 #include <yaz/srw.h>
28
29 #include <iosfwd>
30 #include <string>
31
32 namespace std 
33 {
34     std::ostream& operator<<(std::ostream& os, Z_SRW_PDU& srw_pdu); 
35
36 }
37
38
39 namespace metaproxy_1 {
40     namespace util  {
41
42         class SRUServerInfo;
43
44         // std::string sru_protocol(const Z_HTTP_Request &http_req);
45         // std::string debug_http(const Z_HTTP_Request &http_req);
46         // void http_response(mp::Package &package, 
47         //                   const std::string &content, 
48         //                   int http_code = 200);
49
50         bool build_sru_debug_package(metaproxy_1::Package &package);
51
52         SRUServerInfo get_sru_server_info(metaproxy_1::Package &package);
53                                           // Z_SRW_explainRequest 
54                                           //const *er_req);
55         
56 //         bool build_simple_explain(metaproxy_1::Package &package, 
57 //                                   metaproxy_1::odr &odr_en,
58 //                                   Z_SRW_PDU *sru_pdu_res,
59 //                                   SRUServerInfo sruinfo,
60 //                                   Z_SRW_explainRequest const *er_req = 0);
61         
62         bool build_sru_explain(metaproxy_1::Package &package, 
63                                metaproxy_1::odr &odr_en,
64                                Z_SRW_PDU *sru_pdu_res,
65                                SRUServerInfo sruinfo,
66                                const xmlNode *explain = 0,
67                                Z_SRW_explainRequest const *er_req = 0);
68         
69         bool build_sru_response(metaproxy_1::Package &package, 
70                                 metaproxy_1::odr &odr_en,
71                                 Z_SOAP *soap,
72                                 const Z_SRW_PDU *sru_pdu_res,
73                                 char *charset,
74                                 const char *stylesheet);        
75         
76         Z_SRW_PDU * decode_sru_request(metaproxy_1::Package &package,   
77                                        metaproxy_1::odr &odr_de,
78                                        metaproxy_1::odr &odr_en,
79                                        Z_SRW_PDU *sru_pdu_res,
80                                        Z_SOAP **soap,
81                                        char *charset,
82                                        char *stylesheet);
83
84         bool check_sru_query_exists(metaproxy_1::Package &package,
85                                     metaproxy_1::odr &odr_en,
86                                     Z_SRW_PDU *sru_pdu_res,
87                                     Z_SRW_searchRetrieveRequest
88                                     const *sr_req);
89         
90         Z_ElementSetNames * build_esn_from_schema(metaproxy_1::odr &odr_en, 
91                                                   const char *schema);
92
93         class SRUServerInfo
94         {
95         public:
96             SRUServerInfo ()
97                 : database("Default")
98                 {}
99         public:
100             std::string database;
101             std::string host;
102             std::string port;
103         };
104         
105         
106         
107
108 //         class SRU 
109 //         {
110 //         public:
111 //             enum SRU_protocol_type { SRU_NONE, SRU_GET, SRU_POST, SRU_SOAP};
112 //             typedef const int SRU_query_type;
113 //             union SRW_query {char * cql; char * xcql; char * pqf;};
114 //         private:
115 //             //bool decode(const Z_HTTP_Request &http_req);
116 //             SRU_protocol_type protocol(const Z_HTTP_Request &http_req) const;
117 //         private:
118 //             SRU_protocol_type m_protocol;
119 //             std::string m_charset;
120 //             std::string m_stylesheet;            
121 //         };
122     }    
123 }
124
125 #endif
126 /*
127  * Local variables:
128  * c-basic-offset: 4
129  * c-file-style: "Stroustrup"
130  * indent-tabs-mode: nil
131  * End:
132  * vim: shiftwidth=4 tabstop=8 expandtab
133  */
134