Include stdlib.h for zoom.h
[yaz-moved-to-github.git] / include / yaz / srw.h
1 /*
2  * Copyright (c) 2002-2004, Index Data.
3  * See the file LICENSE for details.
4  *
5  * $Id: srw.h,v 1.16 2004-02-14 15:58:42 adam Exp $
6  */
7
8 #ifndef YAZ_SRW_H
9 #define YAZ_SRW_H
10
11 #include <yaz/soap.h>
12 #include <yaz/zgdu.h>
13
14 YAZ_BEGIN_CDECL
15
16 typedef struct {
17     char *recordSchema;
18     int recordPacking;
19 #define Z_SRW_recordPacking_string 0
20 #define Z_SRW_recordPacking_XML 1
21     char *recordData_buf;
22     int recordData_len;
23     int *recordPosition;
24 } Z_SRW_record;
25
26 typedef struct {
27     char *uri;
28     char *details;
29     char *message;
30 } Z_SRW_diagnostic;
31     
32 typedef struct {
33
34 #define Z_SRW_query_type_cql  1
35 #define Z_SRW_query_type_xcql 2
36 #define Z_SRW_query_type_pqf  3
37     int query_type;
38     union {
39         char *cql;
40         char *xcql;
41         char *pqf;
42     } query;
43
44 #define Z_SRW_sort_type_none 1
45 #define Z_SRW_sort_type_sort 2
46 #define Z_SRW_sort_type_xSort 3
47     int sort_type;
48     union {
49         char *none;
50         char *sortKeys;
51         char *xSortKeys;
52     } sort;
53     int *startRecord;
54     int *maximumRecords;
55     char *recordSchema;
56     char *recordPacking;
57     char *recordXPath;
58     char *database;
59     char *stylesheet;
60     int *resultSetTTL;
61 } Z_SRW_searchRetrieveRequest;
62
63 typedef struct {
64     int * numberOfRecords;
65     char * resultSetId;
66     int * resultSetIdleTime;
67     
68     Z_SRW_record *records;
69     int num_records;
70
71     Z_SRW_diagnostic *diagnostics;
72     int num_diagnostics;
73     int *nextRecordPosition;
74 } Z_SRW_searchRetrieveResponse;
75
76 typedef struct {
77     char *recordPacking;
78     char *database;
79     char *stylesheet;
80 } Z_SRW_explainRequest;
81
82 typedef struct {
83     Z_SRW_record record;
84     Z_SRW_diagnostic *diagnostics;
85     int num_diagnostics;
86 } Z_SRW_explainResponse;
87     
88 typedef struct {
89     char *scanClause;
90     int *responsePosition;
91     int *maximumTerms;
92     char *stylesheet;
93     char *database;
94 } Z_SRW_scanRequest;
95
96 typedef struct {
97     char *value;
98     int *numberOfRecords;
99     char *displayTerm;
100 } Z_SRW_scanTerm;
101
102 typedef struct {
103     Z_SRW_scanTerm *terms;
104     int num_terms;
105     Z_SRW_diagnostic *diagnostics;
106     int num_diagnostics;
107 } Z_SRW_scanResponse;
108
109 #define Z_SRW_searchRetrieve_request  1
110 #define Z_SRW_searchRetrieve_response 2
111 #define Z_SRW_explain_request 3
112 #define Z_SRW_explain_response 4
113 #define Z_SRW_scan_request 5
114 #define Z_SRW_scan_response 6
115
116 typedef struct {
117     int which;
118     union {
119         Z_SRW_searchRetrieveRequest *request;
120         Z_SRW_searchRetrieveResponse *response;
121         Z_SRW_explainRequest *explain_request;
122         Z_SRW_explainResponse *explain_response;
123         Z_SRW_scanRequest *scan_request;
124         Z_SRW_scanResponse *scan_response;
125     } u;
126     char *srw_version;
127 } Z_SRW_PDU;
128
129 YAZ_EXPORT int yaz_srw_codec(ODR o, void * pptr,
130                              Z_SRW_PDU **handler_data,
131                              void *client_data, const char *ns);
132 YAZ_EXPORT Z_SRW_PDU *yaz_srw_get(ODR o, int which);
133
134 YAZ_EXPORT const char *yaz_diag_srw_str (int code);
135
136 YAZ_EXPORT int yaz_diag_bib1_to_srw (int bib1_code);
137
138 YAZ_EXPORT int yaz_diag_srw_to_bib1(int srw_code);
139
140 YAZ_EXPORT char *yaz_uri_val(const char *path, const char *name, ODR o);
141 YAZ_EXPORT void yaz_uri_val_int(const char *path, const char *name,
142                                 ODR o, int **intp);
143 YAZ_EXPORT int yaz_srw_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
144                               Z_SOAP **soap_package, ODR decode, char **charset);
145 YAZ_EXPORT int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
146                               Z_SOAP **soap_package, ODR decode, 
147                               char **charset,
148                               Z_SRW_diagnostic **, int *num_diagnostic);
149
150 YAZ_EXPORT void yaz_add_srw_diagnostic(ODR o, Z_SRW_diagnostic **d,
151                                        int *num, int code,
152                                        const char *addinfo);
153     
154 YAZ_EXPORT void yaz_mk_std_diagnostic(ODR o, Z_SRW_diagnostic *d, 
155                                       int code, const char *details);
156 YAZ_END_CDECL
157
158 #endif