YAZ  4.2.57
srw.h
Go to the documentation of this file.
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) 1995-2013 Index Data.
3  * All rights reserved.
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of Index Data nor the names of its contributors
13  * may be used to endorse or promote products derived from this
14  * software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
33 #ifndef YAZ_SRW_H
34 #define YAZ_SRW_H
35 
36 #include <yaz/soap.h>
37 #include <yaz/zgdu.h>
38 #include <yaz/diagsrw.h>
39 #include <yaz/diagsru_update.h>
40 #include "facet.h"
41 
43 
44 typedef struct {
49 
50 typedef struct {
51  char *recordSchema;
53 #define Z_SRW_recordPacking_string 0
54 #define Z_SRW_recordPacking_XML 1
55 #define Z_SRW_recordPacking_URL 2
59 } Z_SRW_record;
60 
61 typedef struct {
62  char *uri;
63  char *details;
64  char *message;
66 
67 typedef struct {
68 
69 #define Z_SRW_query_type_cql 1
70 #define Z_SRW_query_type_xcql 2
71 #define Z_SRW_query_type_pqf 3
73  union {
74  char *cql;
75  char *xcql;
76  char *pqf;
77  } query;
78 
79 #define Z_SRW_sort_type_none 1
80 #define Z_SRW_sort_type_sort 2
81 #define Z_SRW_sort_type_xSort 3
82  int sort_type;
83  union {
84  char *none;
85  char *sortKeys;
86  char *xSortKeys;
87  } sort;
90  char *recordSchema;
92  char *recordXPath;
93  char *database;
94  char *stylesheet;
98 
99 typedef struct {
101  char * resultSetId;
103 
106 
110 
111  Z_SRW_extra_record **extra_records; /* of size num_records */
113  char *suggestions;
115 
116 typedef struct {
118  char *database;
119  char *stylesheet;
121 
122 typedef struct {
128 
129 typedef struct {
131  union {
132  char *cql;
133  char *xcql;
134  char *pqf;
135  } scanClause;
138  char *stylesheet;
139  char *database;
141 
142 typedef struct {
143  char *value;
145  char *displayTerm;
146  char *whereInList;
148 
149 typedef struct {
155 
156 
157 typedef struct {
158  char *versionType;
161 
162 typedef struct {
163  char *database;
164  char *operation;
165  char *recordId;
172  char *stylesheet;
174 
177  char *name;
178  char *value;
180 };
181 
182 typedef struct {
184  char *recordId;
194 
195 #define Z_SRW_searchRetrieve_request 1
196 #define Z_SRW_searchRetrieve_response 2
197 #define Z_SRW_explain_request 3
198 #define Z_SRW_explain_response 4
199 #define Z_SRW_scan_request 5
200 #define Z_SRW_scan_response 6
201 #define Z_SRW_update_request 7
202 #define Z_SRW_update_response 8
203 
204 typedef struct {
205  int which;
206  union {
215  } u;
216  char *srw_version;
217  char *username; /* From HTTP header or request */
218  char *password; /* From HTTP header or request */
219  Z_SRW_extra_arg *extra_args; /* extraRequestData SRU GET/POST */
222 } Z_SRW_PDU;
223 
224 YAZ_EXPORT int yaz_srw_codec(ODR o, void * pptr,
225  Z_SRW_PDU **handler_data,
226  void *client_data, const char *ns);
227 YAZ_EXPORT int yaz_ucp_codec(ODR o, void * pptr,
228  Z_SRW_PDU **handler_data,
229  void *client_data, const char *ns);
230 YAZ_EXPORT Z_SRW_PDU *yaz_srw_get_core_v_1_1(ODR o);
231 YAZ_EXPORT Z_SRW_PDU *yaz_srw_get_pdu(ODR o, int which, const char *version);
232 YAZ_EXPORT Z_SRW_PDU *yaz_srw_get(ODR o, int which);
233 YAZ_EXPORT Z_SRW_recordVersion *yaz_srw_get_record_versions(ODR o, int num);
235 YAZ_EXPORT Z_SRW_record *yaz_srw_get_record(ODR o);
236 YAZ_EXPORT Z_SRW_record *yaz_srw_get_records(ODR o, int num);
237 
238 YAZ_EXPORT int yaz_diag_bib1_to_srw (int bib1_code);
239 
240 YAZ_EXPORT int yaz_diag_srw_to_bib1(int srw_code);
241 
242 YAZ_EXPORT const char *yaz_srw_pack_to_str(int pack);
243 YAZ_EXPORT int yaz_srw_str_to_pack(const char *str);
244 
246 YAZ_EXPORT char *yaz_uri_val(const char *path, const char *name, ODR o);
247 
249 YAZ_EXPORT void yaz_uri_val_int(const char *path, const char *name,
250  ODR o, Odr_int **intp);
251 
252 YAZ_EXPORT int yaz_uri_to_array(const char *path, ODR o,
253  char ***name, char ***val);
254 YAZ_EXPORT void yaz_array_to_uri(char **path, ODR o,
255  char **name, char **value);
256 
261 YAZ_EXPORT void yaz_encode_uri_component(char *dst, const char *uri);
262 
268 YAZ_EXPORT void yaz_decode_uri_component(char *dst, const char *uri,
269  size_t len);
270 
271 YAZ_EXPORT int yaz_srw_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
272  Z_SOAP **soap_package, ODR decode, char **charset);
273 
274 YAZ_EXPORT int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
275  Z_SOAP **soap_package, ODR decode,
276  char **charset,
277  Z_SRW_diagnostic **, int *num_diagnostic);
278 
286 YAZ_EXPORT int yaz_solr_decode_response(ODR o, Z_HTTP_Response *hres,
287  Z_SRW_PDU **pdup);
288 
289 
290 YAZ_EXPORT void yaz_add_srw_diagnostic(ODR o, Z_SRW_diagnostic **d,
291  int *num, int code,
292  const char *addinfo);
293 
294 YAZ_EXPORT void yaz_add_sru_update_diagnostic(ODR o, Z_SRW_diagnostic **d,
295  int *num, int code,
296  const char *addinfo);
297 
298 YAZ_EXPORT void yaz_mk_std_diagnostic(ODR o, Z_SRW_diagnostic *d,
299  int code, const char *details);
300 
301 YAZ_EXPORT void yaz_add_srw_diagnostic_uri(ODR o, Z_SRW_diagnostic **d,
302  int *num, const char *uri,
303  const char *message,
304  const char *details);
305 
306 YAZ_EXPORT void yaz_mk_srw_diagnostic(ODR o, Z_SRW_diagnostic *d,
307  const char *uri, const char *message,
308  const char *details);
309 
310 YAZ_EXPORT int yaz_sru_get_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu,
311  ODR encode, const char *charset);
312 YAZ_EXPORT int yaz_sru_post_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu,
313  ODR encode, const char *charset);
314 YAZ_EXPORT int yaz_sru_soap_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu,
315  ODR odr, const char *charset);
316 
325 YAZ_EXPORT int yaz_solr_encode_request(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu,
326  ODR encode, const char *charset);
327 
328 YAZ_EXPORT char *yaz_negotiate_sru_version(char *input_ver);
329 
330 YAZ_EXPORT
331 void yaz_encode_sru_extra(Z_SRW_PDU *sr, ODR odr, const char *extra_args);
332 
333 
334 #define YAZ_XMLNS_SRU_v1_0 "http://www.loc.gov/zing/srw/v1.0/"
335 #define YAZ_XMLNS_SRU_v1_1 "http://www.loc.gov/zing/srw/"
336 #define YAZ_XMLNS_DIAG_v1_1 "http://www.loc.gov/zing/srw/diagnostic/"
337 #define YAZ_XMLNS_UPDATE_v0_9 "http://www.loc.gov/zing/srw/update/"
338 #define YAZ_XMLNS_SRU_v2_response "http://docs.oasis-open.org/ns/search-ws/sru*esponse"
339 #define YAZ_XMLNS_SRU_v1_response "http://www.loc.gov/*"
340 
341 YAZ_EXPORT
342 int yaz_srw_check_content_type(Z_HTTP_Response *hres);
343 
344 YAZ_EXPORT
345 int sru_decode_surrogate_diagnostics(const char *buf, size_t len,
346  Z_SRW_diagnostic **diag,
347  int *num, ODR odr);
348 
349 YAZ_EXPORT
350 void yaz_mk_sru_surrogate(ODR o, Z_SRW_record *record, int pos,
351  int code, const char *details);
352 
358 YAZ_EXPORT
359 char *yaz_encode_sru_dbpath_odr(ODR out, const char *db);
360 
367 YAZ_EXPORT
368 void yaz_encode_sru_dbpath_buf(char *dst, const char *db);
369 
370 YAZ_END_CDECL
371 
372 #endif
373 /*
374  * Local variables:
375  * c-basic-offset: 4
376  * c-file-style: "Stroustrup"
377  * indent-tabs-mode: nil
378  * End:
379  * vim: shiftwidth=4 tabstop=8 expandtab
380  */
381