YAZ  5.23.1
srw.h
Go to the documentation of this file.
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) 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 <yaz/facet.h>
41 
43 
44 typedef struct {
49 
50 typedef struct {
51  char *recordSchema;
52 
53  int recordPacking; /* recordXMLEscaping in SRU 2.0 */
54 #define Z_SRW_recordPacking_string 0
55 #define Z_SRW_recordPacking_XML 1
56 #define Z_SRW_recordPacking_URL 2
57 
61 } Z_SRW_record;
62 
63 typedef struct {
64  char *uri;
65  char *details;
66  char *message;
68 
69 typedef struct {
70 
71  char *queryType;
72  char *query;
73 
74 #define Z_SRW_sort_type_none 1
75 #define Z_SRW_sort_type_sort 2
76 #define Z_SRW_sort_type_xSort 3
77  int sort_type;
78  union {
79  char *none;
80  char *sortKeys;
81  char *xSortKeys;
82  } sort;
85  char *recordSchema;
86 
87  char *recordPacking; /* recordXMLEscaping in SRU 2.0 */
88  char *packing; /* recordPacking in SRU 2.0 */
89 
90  char *recordXPath;
91  char *database;
92  char *stylesheet;
96 
97 typedef struct {
100  char * resultSetId;
102 
105 
109 
110  Z_SRW_extra_record **extra_records; /* of size num_records */
112  char *suggestions;
114 
115 typedef struct {
117  char *packing;
118  char *database;
119  char *stylesheet;
121 
122 typedef struct {
128 
129 typedef struct {
130  char *queryType;
131  char *scanClause;
134  char *stylesheet;
135  char *database;
137 
138 typedef struct {
139  char *value;
141  char *displayTerm;
142  char *whereInList;
144 
145 typedef struct {
151 
152 
153 typedef struct {
154  char *versionType;
157 
158 typedef struct {
159  char *database;
160  char *operation;
161  char *recordId;
168  char *stylesheet;
170 
173  char *name;
174  char *value;
176 };
177 
178 typedef struct {
180  char *recordId;
190 
191 #define Z_SRW_searchRetrieve_request 1
192 #define Z_SRW_searchRetrieve_response 2
193 #define Z_SRW_explain_request 3
194 #define Z_SRW_explain_response 4
195 #define Z_SRW_scan_request 5
196 #define Z_SRW_scan_response 6
197 #define Z_SRW_update_request 7
198 #define Z_SRW_update_response 8
199 
200 typedef struct {
201  int which;
202  union {
211  } u;
212  char *srw_version;
213  char *username; /* From HTTP header or request */
214  char *password; /* From HTTP header or request */
215 
216  /* 1. SRU extraRequestData x-name=value for requests encoding */
217  /* 2. SRU extraRequestData x-name=value for requests decoding */
218  /* 3. SRU echoed data for response encoding */
220 
223 } Z_SRW_PDU;
224 
225 YAZ_EXPORT int yaz_srw_codec(ODR o, void * pptr,
226  Z_SRW_PDU **handler_data,
227  void *client_data, const char *ns);
228 YAZ_EXPORT int yaz_ucp_codec(ODR o, void * pptr,
229  Z_SRW_PDU **handler_data,
230  void *client_data, const char *ns);
231 YAZ_EXPORT Z_SRW_PDU *yaz_srw_get_core_v_2_0(ODR o);
232 YAZ_EXPORT Z_SRW_PDU *yaz_srw_get_pdu(ODR o, int which, const char *version);
233 YAZ_EXPORT Z_SRW_PDU *yaz_srw_get_pdu_e(ODR o, int which, Z_SRW_PDU *req);
234 YAZ_EXPORT Z_SRW_PDU *yaz_srw_get(ODR o, int which);
235 YAZ_EXPORT Z_SRW_recordVersion *yaz_srw_get_record_versions(ODR o, int num);
237 YAZ_EXPORT Z_SRW_record *yaz_srw_get_record(ODR o);
238 YAZ_EXPORT Z_SRW_record *yaz_srw_get_records(ODR o, int num);
239 
240 YAZ_EXPORT int yaz_diag_bib1_to_srw (int bib1_code);
241 
242 YAZ_EXPORT int yaz_diag_srw_to_bib1(int srw_code);
243 
244 YAZ_EXPORT const char *yaz_srw_pack_to_str(int pack);
245 YAZ_EXPORT int yaz_srw_str_to_pack(const char *str);
246 
247 YAZ_EXPORT int yaz_uri_to_array(const char *path, ODR o,
248  char ***name, char ***val);
249 YAZ_EXPORT void yaz_array_to_uri(char **path, ODR o,
250  char **name, char **value);
251 
256 YAZ_EXPORT void yaz_encode_uri_component(char *dst, const char *uri);
257 
263 YAZ_EXPORT void yaz_decode_uri_component(char *dst, const char *uri,
264  size_t len);
265 
266 YAZ_EXPORT int yaz_srw_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
267  Z_SOAP **soap_package, ODR decode, char **charset);
268 
269 YAZ_EXPORT int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
270  Z_SOAP **soap_package, ODR decode,
271  char **charset,
272  Z_SRW_diagnostic **, int *num_diagnostic);
273 
281 YAZ_EXPORT int yaz_solr_decode_response(ODR o, Z_HTTP_Response *hres,
282  Z_SRW_PDU **pdup);
283 
284 
285 YAZ_EXPORT void yaz_add_srw_diagnostic(ODR o, Z_SRW_diagnostic **d,
286  int *num, int code,
287  const char *addinfo);
288 
289 YAZ_EXPORT void yaz_add_sru_update_diagnostic(ODR o, Z_SRW_diagnostic **d,
290  int *num, int code,
291  const char *addinfo);
292 
293 YAZ_EXPORT void yaz_mk_std_diagnostic(ODR o, Z_SRW_diagnostic *d,
294  int code, const char *details);
295 
296 YAZ_EXPORT void yaz_add_srw_diagnostic_uri(ODR o, Z_SRW_diagnostic **d,
297  int *num, const char *uri,
298  const char *message,
299  const char *details);
300 
301 YAZ_EXPORT void yaz_mk_srw_diagnostic(ODR o, Z_SRW_diagnostic *d,
302  const char *uri, const char *message,
303  const char *details);
304 
305 YAZ_EXPORT int yaz_sru_get_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu,
306  ODR encode, const char *charset);
307 YAZ_EXPORT int yaz_sru_post_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu,
308  ODR encode, const char *charset);
309 YAZ_EXPORT int yaz_sru_soap_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu,
310  ODR odr, const char *charset);
311 
320 YAZ_EXPORT int yaz_solr_encode_request(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu,
321  ODR encode, const char *charset);
322 
323 YAZ_EXPORT
324 void yaz_encode_sru_extra(Z_SRW_PDU *sr, ODR odr, const char *extra_args);
325 
326 
327 #define YAZ_XMLNS_SRU_v1_0 "http://www.loc.gov/zing/srw/v1.0/"
328 #define YAZ_XMLNS_SRU_v1_1 "http://www.loc.gov/zing/srw/"
329 #define YAZ_XMLNS_DIAG_v1_1 "http://www.loc.gov/zing/srw/diagnostic/"
330 #define YAZ_XMLNS_DIAG_v2 "http://docs.oasis-open.org/ns/search-ws/diagnostic"
331 #define YAZ_XMLNS_UPDATE_v0_9 "http://www.loc.gov/zing/srw/update/"
332 #define YAZ_XMLNS_SRU_v2_mask "http://docs.oasis-open.org/ns/search-ws/*"
333 #define YAZ_XMLNS_SRU_v1_response "http://www.loc.gov/*"
334 
335 YAZ_EXPORT
336 int yaz_srw_check_content_type(Z_HTTP_Response *hres);
337 
338 YAZ_EXPORT
339 int sru_decode_surrogate_diagnostics(const char *buf, size_t len,
340  Z_SRW_diagnostic **diag,
341  int *num, ODR odr);
342 
343 YAZ_EXPORT
344 void yaz_mk_sru_surrogate(ODR o, Z_SRW_record *record, int pos,
345  int code, const char *details);
346 
352 YAZ_EXPORT
353 char *yaz_encode_sru_dbpath_odr(ODR out, const char *db);
354 
361 YAZ_EXPORT
362 void yaz_encode_sru_dbpath_buf(char *dst, const char *db);
363 
364 YAZ_END_CDECL
365 
366 #endif
367 /*
368  * Local variables:
369  * c-basic-offset: 4
370  * c-file-style: "Stroustrup"
371  * indent-tabs-mode: nil
372  * End:
373  * vim: shiftwidth=4 tabstop=8 expandtab
374  */
375 
Z_SRW_scanRequest * scan_request
Definition: srw.h:207
Z_SRW_extra_record * extra_record
Definition: srw.h:165
int yaz_srw_str_to_pack(const char *str)
Definition: srwutil.c:1226
Odr_int * startRecord
Definition: srw.h:83
int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu, Z_SOAP **soap_package, ODR decode, char **charset, Z_SRW_diagnostic **, int *num_diagnostic)
Definition: srwutil.c:358
Z_SRW_record record
Definition: srw.h:123
char * versionValue
Definition: srw.h:155
int yaz_solr_decode_response(ODR o, Z_HTTP_Response *hres, Z_SRW_PDU **pdup)
decode SOLR response (HTTP)
Definition: solr.c:328
Odr_int * numberOfRecords
Definition: srw.h:140
char * recordData_buf
Definition: srw.h:58
Odr_int * nextRecordPosition
Definition: srw.h:108
char * srw_version
Definition: srw.h:212
char * recordIdentifier
Definition: srw.h:47
char * recordId
Definition: srw.h:180
char * versionType
Definition: srw.h:154
int yaz_ucp_codec(ODR o, void *pptr, Z_SRW_PDU **handler_data, void *client_data, const char *ns)
Definition: srw.c:1150
Z_SRW_diagnostic * diagnostics
Definition: srw.h:148
Z_SRW_record * yaz_srw_get_records(ODR o, int num)
Definition: srwutil.c:719
Z_SRW_record * yaz_srw_get_record(ODR o)
Definition: srwutil.c:735
Z_SRW_scanTerm * terms
Definition: srw.h:146
Z_SRW_diagnostic * diagnostics
Definition: srw.h:187
Odr_int * resultSetTTL
Definition: srw.h:93
Z_SRW_extra_record ** extra_records
Definition: srw.h:110
char * name
Definition: initopt.c:18
char * password
Definition: srw.h:214
char * extraResponseData_buf
Definition: srw.h:185
Z_SRW_record * record
Definition: srw.h:183
char * scanClause
Definition: srw.h:131
Z_SRW_recordVersion * yaz_srw_get_record_versions(ODR o, int num)
Definition: srwutil.c:1199
const char * yaz_srw_pack_to_str(int pack)
Definition: srwutil.c:1212
char * database
Definition: srw.h:159
Z_SRW_searchRetrieveResponse * response
Definition: srw.h:204
Odr_int * numberOfRecords
Definition: srw.h:98
Z_FacetList * facetList
Definition: srw.h:94
nmem_int_t Odr_int
Definition: odr.h:47
int extraRequestData_len
Definition: srw.h:167
Z_SRW_PDU * yaz_srw_get_pdu_e(ODR o, int which, Z_SRW_PDU *req)
Definition: srwutil.c:763
Z_SRW_scanResponse * scan_response
Definition: srw.h:208
int yaz_diag_srw_to_bib1(int srw_code)
Definition: diag_map.c:215
int yaz_sru_get_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu, ODR encode, const char *charset)
Definition: srwutil.c:1105
char * recordPacking
Definition: srw.h:116
int yaz_diag_bib1_to_srw(int bib1_code)
Definition: diag_map.c:203
char * operation
Definition: srw.h:160
Odr_int * maximumTerms
Definition: srw.h:133
char * queryType
Definition: srw.h:130
void yaz_add_sru_update_diagnostic(ODR o, Z_SRW_diagnostic **d, int *num, int code, const char *addinfo)
Definition: srwutil.c:195
Header for the Z_GDU (HTTP or Z39.50 package)
char * extraRecordData_buf
Definition: srw.h:45
char * uri
Definition: srw.h:64
Z_SRW_updateRequest * update_request
Definition: srw.h:209
Odr_int * maximumRecords
Definition: srw.h:84
char * extraResponseData_buf
Definition: srw.h:221
Z_SRW_PDU * yaz_srw_get(ODR o, int which)
Definition: srwutil.c:757
Header for SOAP.
char * extraRequestData_buf
Definition: srw.h:166
int yaz_uri_to_array(const char *path, ODR o, char ***name, char ***val)
Definition: uri.c:121
Z_SRW_extra_record * extra_record
Definition: srw.h:184
int extraResponseData_len
Definition: srw.h:222
Odr_int * resultSetIdleTime
Definition: srw.h:101
Z_SRW_diagnostic * diagnostics
Definition: srw.h:106
void yaz_mk_srw_diagnostic(ODR o, Z_SRW_diagnostic *d, const char *uri, const char *message, const char *details)
Definition: srwutil.c:147
Z_SRW_PDU * yaz_srw_get_core_v_2_0(ODR o)
Definition: srwutil.c:752
char * packing
Definition: srw.h:117
char * database
Definition: srw.h:118
Z_SRW_explainRequest * explain_request
Definition: srw.h:205
Definition: soap.h:55
char * stylesheet
Definition: srw.h:119
int recordPacking
Definition: srw.h:53
int extraResponseData_len
Definition: srw.h:186
Z_SRW_extra_record * extra_record
Definition: srw.h:126
char * recordSchema
Definition: srw.h:51
Header for the facet utilities.
void yaz_encode_uri_component(char *dst, const char *uri)
encodes URI component
Definition: uri.c:45
Z_SRW_extra_arg * extra_args
Definition: srw.h:219
Z_SRW_explainResponse * explain_response
Definition: srw.h:206
Z_SRW_extra_arg * next
Definition: srw.h:175
char * username
Definition: srw.h:213
char * value
Definition: srw.h:139
Z_SRW_PDU * yaz_srw_get_pdu(ODR o, int which, const char *version)
Definition: srwutil.c:818
Diagnostics: Generated by csvtodiag.tcl from ./sru_update.csv.
int yaz_srw_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu, Z_SOAP **soap_package, ODR decode, char **charset)
Definition: srwutil.c:259
char * whereInList
Definition: srw.h:142
char * details
Definition: srw.h:65
Z_SRW_extra_record * yaz_srw_get_extra_record(ODR o)
Definition: srwutil.c:707
int which
Definition: srw.h:201
char * resultCountPrecision
Definition: srw.h:99
Z_SRW_diagnostic * diagnostics
Definition: srw.h:124
Z_SRW_record * record
Definition: srw.h:164
Definition: odr.h:124
int extraRecordData_len
Definition: srw.h:46
char * message
Definition: srw.h:66
void yaz_add_srw_diagnostic_uri(ODR o, Z_SRW_diagnostic **d, int *num, const char *uri, const char *message, const char *details)
Definition: srwutil.c:171
Odr_int * recordPosition
Definition: srw.h:60
Diagnostics: Generated by csvtodiag.tcl from ./srw.csv.
void yaz_array_to_uri(char **path, ODR o, char **name, char **value)
Definition: uri.c:98
Z_SRW_record * records
Definition: srw.h:103
Z_FacetList * facetList
Definition: srw.h:111
int yaz_sru_post_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu, ODR encode, const char *charset)
Definition: srwutil.c:1137
int yaz_sru_soap_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu, ODR odr, const char *charset)
Definition: srwutil.c:1161
char * operationStatus
Definition: srw.h:179
void yaz_mk_std_diagnostic(ODR o, Z_SRW_diagnostic *d, int code, const char *details)
Definition: srwutil.c:162
char * name
Definition: srw.h:173
char * recordId
Definition: srw.h:161
void yaz_decode_uri_component(char *dst, const char *uri, size_t len)
decodes URI component
Definition: uri.c:86
void yaz_add_srw_diagnostic(ODR o, Z_SRW_diagnostic **d, int *num, int code, const char *addinfo)
Definition: srwutil.c:185
Z_SRW_recordVersion * recordVersions
Definition: srw.h:181
void yaz_encode_sru_extra(Z_SRW_PDU *sr, ODR odr, const char *extra_args)
Definition: srwutil.c:1237
char * stylesheet
Definition: srw.h:168
char * stylesheet
Definition: srw.h:134
int yaz_solr_encode_request(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu, ODR encode, const char *charset)
encode SOLR request (HTTP)
Definition: solr.c:467
int recordData_len
Definition: srw.h:59
char * database
Definition: srw.h:135
int num_recordVersions
Definition: srw.h:163
char * displayTerm
Definition: srw.h:141
int num_diagnostics
Definition: srw.h:149
int num_diagnostics
Definition: srw.h:188
int yaz_srw_codec(ODR o, void *pptr, Z_SRW_PDU **handler_data, void *client_data, const char *ns)
Definition: srw.c:581
Z_SRW_searchRetrieveRequest * request
Definition: srw.h:203
Definition: srw.h:200
char * value
Definition: srw.h:174
Z_SRW_recordVersion * recordVersions
Definition: srw.h:162
Odr_int * responsePosition
Definition: srw.h:132
Z_SRW_updateResponse * update_response
Definition: srw.h:210
int num_recordVersions
Definition: srw.h:182
#define YAZ_BEGIN_CDECL
Definition: yconfig.h:56