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