2d751f7bad300e940b85d285afd9e4c425685944
[yazpp-moved-to-github.git] / src / yaz-z-server-ursula.cpp
1 /*
2  * Copyright (c) 2001, Index Data.
3  * See the file LICENSE for details.
4  * 
5  * $Log: yaz-z-server-ursula.cpp,v $
6  * Revision 1.3  2001-04-11 12:33:42  heikki
7  * Working on ursula things
8  *
9  * Revision 1.2  2001/04/05 15:12:24  adam
10  * WIN32 updates.
11  *
12  * Revision 1.1  2001/04/04 14:02:49  adam
13  * URSULA / Z-ruth service.
14  *
15  */
16
17 #include <yaz/log.h>
18 #include <yaz++/yaz-z-server.h>
19
20 #if HAVE_YAZ_URSULA_H
21 int Yaz_Facility_Ursula::init(Yaz_Z_Server *s, Z_InitRequest *initRequest,
22                               Z_InitResponse *initResponse)
23 {
24     Z_Options *req = initRequest->options;
25     Z_Options *res = initResponse->options;
26     
27     if (ODR_MASK_GET(req, Z_Options_extendedServices))
28         ODR_MASK_SET(res, Z_Options_extendedServices);
29     return 1;
30 }
31
32 int Yaz_Facility_Ursula::recv(Yaz_Z_Server *s, Z_APDU *apdu_request)
33 {   
34     Z_APDU *apdu_response;
35
36     if (apdu_request->which != Z_APDU_extendedServicesRequest)
37         return 0;
38     Z_ExtendedServicesRequest *req = apdu_request->u.extendedServicesRequest;
39
40     Z_External *r = req->taskSpecificParameters;
41
42     if (!r)
43         return 0;
44
45     if (r->which != ODR_EXTERNAL_octet)
46     {
47         logf (LOG_LOG, "ursula::recv not octet alighed");
48         return 0;
49     }
50     odr_setbuf (s->odr_decode(), (char*) r->u.octet_aligned->buf,
51                 r->u.octet_aligned->len, 0);
52     Z_UrsPDU *pdu = 0;
53     if (!z_UrsPDU (s->odr_decode(), &pdu, 0, ""))
54     {
55         logf (LOG_LOG, "ursula::decode failed");
56         return 0;
57     }
58     yaz_log (LOG_LOG, "got ursula packet");
59     apdu_response = s->create_Z_PDU(Z_APDU_extendedServicesResponse);
60     ursula_service(req, pdu, apdu_response->u.extendedServicesResponse, NULL);
61       // FIXME: Initialize the response pdu...   ADAM!!!
62     s->send_Z_PDU(apdu_response);
63     return 1;
64 }
65 #endif