SRW, CQL, 2003
[yaz-moved-to-github.git] / srw / srw-server.c
1
2 #include <yaz/srw-util.h>
3 #include <yaz/xmalloc.h>
4
5 struct srw_info {
6     int (*sr_h)(void *userinfo,
7                 struct soap * soap,
8                 xsd__string  *query,
9                 struct xcql__operandType *xQuery,       
10                 xsd__string *sortKeys,
11                 struct xsort__xSortKeysType *xSortKeys,
12                 xsd__integer *startRecord,
13                 xsd__integer *maximumRecords,
14                 xsd__string *recordSchema,
15                 xsd__string *recordPacking,
16                 struct zs__searchRetrieveResponse *res);
17     int (*e_h)(void *userinfo,
18               struct soap *soap,
19               struct zs__explainResponse *explainResponse);
20     void *userinfo;
21 };
22
23 int zs__explainRequest (struct soap *soap,
24                         struct zs__explainResponse *explainResponse)
25 {
26     struct srw_info *info = (struct srw_info *) soap->user;
27     return (*info->e_h)(info->userinfo, soap, explainResponse);
28 }
29
30 int zs__searchRetrieveRequest(struct soap * soap,
31                               xsd__string  *query,
32                               struct xcql__operandType *xQuery, 
33                               xsd__string *sortKeys,
34                               struct xsort__xSortKeysType *xSortKeys,
35                               xsd__integer *startRecord,
36                               xsd__integer *maximumRecords,
37                               xsd__string *recordSchema,
38                               xsd__string *recordPacking,
39                               struct zs__searchRetrieveResponse *res)
40 {
41     struct srw_info *info = (struct srw_info *) soap->user;
42     return (*info->sr_h)(info->userinfo, soap,
43                          query, xQuery, sortKeys, xSortKeys,
44                          startRecord, maximumRecords,
45                          recordSchema, recordPacking,
46                          res);
47 }
48
49 void yaz_srw_serve (struct soap *soap,
50                     void *userinfo,
51                     int (*sr_h)(void *userinfo,
52                                 struct soap * soap,
53                                 xsd__string  *query,
54                                 struct xcql__operandType *xQuery,       
55                                 xsd__string *sortKeys,
56                                 struct xsort__xSortKeysType *xSortKeys,
57                                 xsd__integer *startRecord,
58                                 xsd__integer *maximumRecords,
59                                 xsd__string *recordSchema,
60                                 xsd__string *recordPacking,
61                                 struct zs__searchRetrieveResponse *res),
62                     int (*e_h)(void *userinfo,
63                                 struct soap *soap,
64                                struct zs__explainResponse *explainResponse))
65 {
66     struct srw_info info;
67
68     info.sr_h = sr_h;
69     info.e_h = e_h;
70     info.userinfo = userinfo;
71     soap->user = &info;
72     soap->namespaces = srw_namespaces;
73     soap_serve(soap);
74 }