Change wording ot YAZ license the 'Revised BSD License'. YAZ has used a
[yaz-moved-to-github.git] / include / yaz / srw.h
1 /*
2  * Copyright (c) 1995-2006, 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 /* $Id: srw.h,v 1.29 2006-10-09 21:02:41 adam Exp $ */
28
29 /*
30  * Copyright (C) 1995-2005, Index Data ApS
31  * See the file LICENSE for details.
32  *
33  * $Id: srw.h,v 1.29 2006-10-09 21:02:41 adam Exp $
34  */
35 /**
36  * \file srw.h
37  * \brief Header for SRW/SRU
38  */
39
40 #ifndef YAZ_SRW_H
41 #define YAZ_SRW_H
42
43 #include <yaz/soap.h>
44 #include <yaz/zgdu.h>
45 #include <yaz/diagsrw.h>
46
47 YAZ_BEGIN_CDECL
48
49 typedef struct {
50     int type;
51     char *recordReviewCode;
52     char *recordReviewNote;
53     char *recordId;
54     char *nonDupRecordId;
55     char *recordLockStatus;
56     char *recordOldVersion;
57 } Z_SRW_extra_record;
58
59 typedef struct {
60     char *recordSchema;
61     int recordPacking;
62 #define Z_SRW_recordPacking_string 0
63 #define Z_SRW_recordPacking_XML 1
64 #define Z_SRW_recordPacking_URL 2
65     char *recordData_buf;
66     int recordData_len;
67     int *recordPosition;
68 } Z_SRW_record;
69
70 typedef struct {
71     char *uri;
72     char *details;
73     char *message;
74 } Z_SRW_diagnostic;
75     
76 typedef struct {
77
78 #define Z_SRW_query_type_cql  1
79 #define Z_SRW_query_type_xcql 2
80 #define Z_SRW_query_type_pqf  3
81     int query_type;
82     union {
83         char *cql;
84         char *xcql;
85         char *pqf;
86     } query;
87
88 #define Z_SRW_sort_type_none 1
89 #define Z_SRW_sort_type_sort 2
90 #define Z_SRW_sort_type_xSort 3
91     int sort_type;
92     union {
93         char *none;
94         char *sortKeys;
95         char *xSortKeys;
96     } sort;
97     int *startRecord;
98     int *maximumRecords;
99     char *recordSchema;
100     char *recordPacking;
101     char *recordXPath;
102     char *database;
103     char *stylesheet;
104     int *resultSetTTL;
105 } Z_SRW_searchRetrieveRequest;
106
107 typedef struct {
108     int * numberOfRecords;
109     char * resultSetId;
110     int * resultSetIdleTime;
111     
112     Z_SRW_record *records;
113     int num_records;
114
115     Z_SRW_diagnostic *diagnostics;
116     int num_diagnostics;
117     int *nextRecordPosition;
118
119     Z_SRW_extra_record **extra_records;  /* of size num_records */
120 } Z_SRW_searchRetrieveResponse;
121
122 typedef struct {
123     char *recordPacking;
124     char *database;
125     char *stylesheet;
126 } Z_SRW_explainRequest;
127
128 typedef struct {
129     Z_SRW_record record;
130     Z_SRW_diagnostic *diagnostics;
131     int num_diagnostics;
132     Z_SRW_extra_record *extra_record;
133 } Z_SRW_explainResponse;
134     
135 typedef struct {
136     int query_type;
137     union {
138         char *cql;
139         char *xcql;
140         char *pqf;
141     } scanClause;
142     int *responsePosition;
143     int *maximumTerms;
144     char *stylesheet;
145     char *database;
146 } Z_SRW_scanRequest;
147
148 typedef struct {
149     char *value;
150     int *numberOfRecords;
151     char *displayTerm;
152     char *whereInList;
153 } Z_SRW_scanTerm;
154
155 typedef struct {
156     Z_SRW_scanTerm *terms;
157     int num_terms;
158     Z_SRW_diagnostic *diagnostics;
159     int num_diagnostics;
160 } Z_SRW_scanResponse;
161
162
163 typedef struct {
164     char *database;
165     char *operation;
166     char *recordId;
167     char *recordVersion;
168     char *recordOldVersion;
169     Z_SRW_record record;
170     Z_SRW_extra_record *extra_record;
171     char *extraRequestData;
172     char *stylesheet;
173 } Z_SRW_updateRequest;
174
175 typedef struct {
176     char *operationStatus;
177     char *recordId;
178     char *recordVersion;
179     char *recordChecksum;
180     char *extraResponseData;
181     Z_SRW_record record;
182     Z_SRW_extra_record *extra_record;
183     Z_SRW_diagnostic *diagnostics;
184     int num_diagnostics;
185 } Z_SRW_updateResponse;
186
187 #define Z_SRW_searchRetrieve_request  1
188 #define Z_SRW_searchRetrieve_response 2
189 #define Z_SRW_explain_request 3
190 #define Z_SRW_explain_response 4
191 #define Z_SRW_scan_request 5
192 #define Z_SRW_scan_response 6
193 #define Z_SRW_update_request 7
194 #define Z_SRW_update_response 8
195
196 typedef struct {
197     int which;
198     union {
199         Z_SRW_searchRetrieveRequest *request;
200         Z_SRW_searchRetrieveResponse *response;
201         Z_SRW_explainRequest *explain_request;
202         Z_SRW_explainResponse *explain_response;
203         Z_SRW_scanRequest *scan_request;
204         Z_SRW_scanResponse *scan_response;
205         Z_SRW_updateRequest *update_request;
206         Z_SRW_updateResponse *update_response;
207     } u;
208     char *srw_version;
209     char *username; /* From HTTP header or request */
210     char *password; /* From HTTP header or request  */
211     char *extra_args; /* For SRU GET/POST only */
212 } Z_SRW_PDU;
213
214 YAZ_EXPORT int yaz_srw_codec(ODR o, void * pptr,
215                              Z_SRW_PDU **handler_data,
216                              void *client_data, const char *ns);
217 YAZ_EXPORT int yaz_ucp_codec(ODR o, void * pptr,
218                              Z_SRW_PDU **handler_data,
219                              void *client_data, const char *ns);
220 YAZ_EXPORT Z_SRW_PDU *yaz_srw_get_core_v_1_1(ODR o);
221 YAZ_EXPORT Z_SRW_PDU *yaz_srw_get(ODR o, int which);
222 YAZ_EXPORT Z_SRW_extra_record *yaz_srw_get_extra_record(ODR o);
223
224 YAZ_EXPORT int yaz_diag_bib1_to_srw (int bib1_code);
225
226 YAZ_EXPORT int yaz_diag_srw_to_bib1(int srw_code);
227
228 YAZ_EXPORT char *yaz_uri_val(const char *path, const char *name, ODR o);
229 YAZ_EXPORT void yaz_uri_val_int(const char *path, const char *name,
230                                 ODR o, int **intp);
231 YAZ_EXPORT int yaz_srw_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
232                               Z_SOAP **soap_package, ODR decode, char **charset);
233 YAZ_EXPORT int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
234                               Z_SOAP **soap_package, ODR decode, 
235                               char **charset,
236                               Z_SRW_diagnostic **, int *num_diagnostic);
237
238 YAZ_EXPORT void yaz_add_srw_diagnostic(ODR o, Z_SRW_diagnostic **d,
239                                        int *num, int code,
240                                        const char *addinfo);
241     
242
243 YAZ_EXPORT void yaz_mk_std_diagnostic(ODR o, Z_SRW_diagnostic *d, 
244                                       int code, const char *details);
245
246 YAZ_EXPORT void yaz_add_srw_diagnostic_uri(ODR o, Z_SRW_diagnostic **d,
247                                            int *num, const char *uri,
248                                            const char *message,
249                                            const char *details);
250
251 YAZ_EXPORT void yaz_mk_srw_diagnostic(ODR o, Z_SRW_diagnostic *d, 
252                                       const char *uri, const char *message,
253                                       const char *details);
254
255 YAZ_EXPORT int yaz_sru_get_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu,
256                                   ODR encode, const char *charset);
257 YAZ_EXPORT int yaz_sru_post_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu,
258                                    ODR encode, const char *charset);
259 YAZ_EXPORT int yaz_sru_soap_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu,
260                                    ODR odr, const char *charset);
261
262 YAZ_END_CDECL
263
264 #endif
265 /*
266  * Local variables:
267  * c-basic-offset: 4
268  * indent-tabs-mode: nil
269  * End:
270  * vim: shiftwidth=4 tabstop=8 expandtab
271  */
272