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