5a2ab0a22f218456a66fcc9a33de609e9b80e323
[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                     int (*sr_h)(void *userinfo,
51                                 struct soap * soap,
52                                 xsd__string  *query,
53                                 struct xcql__operandType *xQuery,       
54                                 xsd__string *sortKeys,
55                                 struct xsort__xSortKeysType *xSortKeys,
56                                 xsd__integer *startRecord,
57                                 xsd__integer *maximumRecords,
58                                 xsd__string *recordSchema,
59                                 xsd__string *recordPacking,
60                                 struct zs__searchRetrieveResponse *res),
61                     int (*e_h)(void *userinfo,
62                                 struct soap *soap,
63                                struct zs__explainResponse *explainResponse))
64 {
65     struct srw_info info;
66
67     info.sr_h = sr_h;
68     info.e_h = e_h;
69     info.userinfo = soap->user;
70     soap->user = &info;
71     soap->namespaces = srw_namespaces;
72     soap_serve(soap);
73 }
74