1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2008 Index Data.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
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.
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.
27 /* $Id: srw.h,v 1.37 2008-01-28 09:51:02 adam Exp $ */
31 * \brief Header for SRW/SRU
39 #include <yaz/diagsrw.h>
40 #include <yaz/diagsru_update.h>
45 char *extraRecordData_buf;
46 int extraRecordData_len;
47 char *recordIdentifier;
53 #define Z_SRW_recordPacking_string 0
54 #define Z_SRW_recordPacking_XML 1
55 #define Z_SRW_recordPacking_URL 2
69 #define Z_SRW_query_type_cql 1
70 #define Z_SRW_query_type_xcql 2
71 #define Z_SRW_query_type_pqf 3
79 #define Z_SRW_sort_type_none 1
80 #define Z_SRW_sort_type_sort 2
81 #define Z_SRW_sort_type_xSort 3
96 } Z_SRW_searchRetrieveRequest;
99 int * numberOfRecords;
101 int * resultSetIdleTime;
103 Z_SRW_record *records;
106 Z_SRW_diagnostic *diagnostics;
108 int *nextRecordPosition;
110 Z_SRW_extra_record **extra_records; /* of size num_records */
111 } Z_SRW_searchRetrieveResponse;
117 } Z_SRW_explainRequest;
121 Z_SRW_diagnostic *diagnostics;
123 Z_SRW_extra_record *extra_record;
124 } Z_SRW_explainResponse;
133 int *responsePosition;
141 int *numberOfRecords;
147 Z_SRW_scanTerm *terms;
149 Z_SRW_diagnostic *diagnostics;
151 } Z_SRW_scanResponse;
157 } Z_SRW_recordVersion;
163 Z_SRW_recordVersion *recordVersions;
164 int num_recordVersions;
165 Z_SRW_record *record;
166 Z_SRW_extra_record *extra_record;
167 char *extraRequestData_buf;
168 int extraRequestData_len;
170 } Z_SRW_updateRequest;
172 typedef struct Z_SRW_extra_arg Z_SRW_extra_arg;
173 struct Z_SRW_extra_arg {
176 Z_SRW_extra_arg *next;
180 char *operationStatus;
182 Z_SRW_recordVersion *recordVersions;
183 int num_recordVersions;
184 Z_SRW_record *record;
185 Z_SRW_extra_record *extra_record;
186 char *extraResponseData_buf;
187 int extraResponseData_len;
188 Z_SRW_diagnostic *diagnostics;
190 } Z_SRW_updateResponse;
192 #define Z_SRW_searchRetrieve_request 1
193 #define Z_SRW_searchRetrieve_response 2
194 #define Z_SRW_explain_request 3
195 #define Z_SRW_explain_response 4
196 #define Z_SRW_scan_request 5
197 #define Z_SRW_scan_response 6
198 #define Z_SRW_update_request 7
199 #define Z_SRW_update_response 8
204 Z_SRW_searchRetrieveRequest *request;
205 Z_SRW_searchRetrieveResponse *response;
206 Z_SRW_explainRequest *explain_request;
207 Z_SRW_explainResponse *explain_response;
208 Z_SRW_scanRequest *scan_request;
209 Z_SRW_scanResponse *scan_response;
210 Z_SRW_updateRequest *update_request;
211 Z_SRW_updateResponse *update_response;
214 char *username; /* From HTTP header or request */
215 char *password; /* From HTTP header or request */
216 Z_SRW_extra_arg *extra_args; /* only used for SRU GET/POST */
219 YAZ_EXPORT int yaz_srw_codec(ODR o, void * pptr,
220 Z_SRW_PDU **handler_data,
221 void *client_data, const char *ns);
222 YAZ_EXPORT int yaz_ucp_codec(ODR o, void * pptr,
223 Z_SRW_PDU **handler_data,
224 void *client_data, const char *ns);
225 YAZ_EXPORT Z_SRW_PDU *yaz_srw_get_core_v_1_1(ODR o);
226 YAZ_EXPORT Z_SRW_PDU *yaz_srw_get_pdu(ODR o, int which, const char *version);
227 YAZ_EXPORT Z_SRW_PDU *yaz_srw_get(ODR o, int which);
228 YAZ_EXPORT Z_SRW_recordVersion *yaz_srw_get_record_versions(ODR o, int num);
229 YAZ_EXPORT Z_SRW_extra_record *yaz_srw_get_extra_record(ODR o);
230 YAZ_EXPORT Z_SRW_record *yaz_srw_get_record(ODR o);
231 YAZ_EXPORT Z_SRW_record *yaz_srw_get_records(ODR o, int num);
233 YAZ_EXPORT int yaz_diag_bib1_to_srw (int bib1_code);
235 YAZ_EXPORT int yaz_diag_srw_to_bib1(int srw_code);
237 YAZ_EXPORT const char *yaz_srw_pack_to_str(int pack);
238 YAZ_EXPORT int yaz_srw_str_to_pack(const char *str);
240 YAZ_EXPORT char *yaz_uri_val(const char *path, const char *name, ODR o);
241 YAZ_EXPORT void yaz_uri_val_int(const char *path, const char *name,
243 YAZ_EXPORT int yaz_srw_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
244 Z_SOAP **soap_package, ODR decode, char **charset);
245 YAZ_EXPORT int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
246 Z_SOAP **soap_package, ODR decode,
248 Z_SRW_diagnostic **, int *num_diagnostic);
250 YAZ_EXPORT void yaz_add_srw_diagnostic(ODR o, Z_SRW_diagnostic **d,
252 const char *addinfo);
254 YAZ_EXPORT void yaz_add_sru_update_diagnostic(ODR o, Z_SRW_diagnostic **d,
256 const char *addinfo);
258 YAZ_EXPORT void yaz_mk_std_diagnostic(ODR o, Z_SRW_diagnostic *d,
259 int code, const char *details);
261 YAZ_EXPORT void yaz_add_srw_diagnostic_uri(ODR o, Z_SRW_diagnostic **d,
262 int *num, const char *uri,
264 const char *details);
266 YAZ_EXPORT void yaz_mk_srw_diagnostic(ODR o, Z_SRW_diagnostic *d,
267 const char *uri, const char *message,
268 const char *details);
270 YAZ_EXPORT int yaz_sru_get_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu,
271 ODR encode, const char *charset);
272 YAZ_EXPORT int yaz_sru_post_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu,
273 ODR encode, const char *charset);
274 YAZ_EXPORT int yaz_sru_soap_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu,
275 ODR odr, const char *charset);
277 YAZ_EXPORT char *yaz_negotiate_sru_version(char *input_ver);
280 void yaz_encode_sru_extra(Z_SRW_PDU *sr, ODR odr, const char *extra_args);
283 #define YAZ_XMLNS_SRU_v1_0 "http://www.loc.gov/zing/srw/v1.0/"
284 #define YAZ_XMLNS_SRU_v1_1 "http://www.loc.gov/zing/srw/"
285 #define YAZ_XMLNS_DIAG_v1_1 "http://www.loc.gov/zing/srw/diagnostic/"
286 #define YAZ_XMLNS_UPDATE_v0_9 "http://www.loc.gov/zing/srw/update/"
289 int yaz_srw_check_content_type(Z_HTTP_Response *hres);
292 int sru_decode_surrogate_diagnostics(const char *buf, size_t len,
293 Z_SRW_diagnostic **diag,
304 * indent-tabs-mode: nil
306 * vim: shiftwidth=4 tabstop=8 expandtab