2 * Copyright (c) 2000-2001, Index Data.
3 * See the file LICENSE for details.
5 * $Log: yaz-z-server.cpp,v $
6 * Revision 1.9 2001-03-29 15:14:26 adam
9 * Revision 1.8 2001/03/27 14:47:45 adam
10 * New server facility scheme.
12 * Revision 1.7 2001/03/26 14:43:49 adam
13 * New threaded PDU association.
15 * Revision 1.6 2001/01/29 11:18:24 adam
16 * Server sets OPTIONS search and present.
18 * Revision 1.5 2000/10/24 12:29:57 adam
19 * Fixed bug in proxy where a Yaz_ProxyClient could be owned by
20 * two Yaz_Proxy's (fatal).
22 * Revision 1.4 2000/10/11 11:58:17 adam
23 * Moved header files to include/yaz++. Switched to libtool and automake.
24 * Configure script creates yaz++-config script.
26 * Revision 1.3 2000/09/21 21:43:20 adam
27 * Better high-level server API.
29 * Revision 1.2 2000/09/12 12:09:53 adam
30 * More work on high-level server.
32 * Revision 1.1 2000/09/08 10:23:42 adam
33 * Added skeleton of yaz-z-server.
38 #include <yaz++/yaz-z-server.h>
40 Yaz_Z_Server::Yaz_Z_Server(IYaz_PDU_Observable *the_PDU_Observable)
41 : Yaz_Z_Assoc(the_PDU_Observable)
46 Yaz_Z_Server::~Yaz_Z_Server()
51 void Yaz_Z_Server::facility_reset ()
53 Yaz_Z_Server_Facility_Info *p = m_facilities;
56 Yaz_Z_Server_Facility_Info *p_next = p->m_next;
65 void Yaz_Z_Server::facility_add(IYaz_Server_Facility *facility,
68 Yaz_Z_Server_Facility_Info **p = &m_facilities;
72 *p = new Yaz_Z_Server_Facility_Info;
75 (*p)->m_name = new char [strlen(name)+1];
76 strcpy ((*p)->m_name, name);
77 (*p)->m_facility = facility;
80 void Yaz_Z_Server::recv_Z_PDU (Z_APDU *apdu_request)
82 Yaz_Z_Server_Facility_Info *f = m_facilities;
84 if (apdu_request->which == Z_APDU_initRequest)
86 Z_APDU *apdu_response = create_Z_PDU(Z_APDU_initResponse);
88 Z_InitRequest *req = apdu_request->u.initRequest;
89 Z_InitResponse *resp = apdu_response->u.initResponse;
91 if (ODR_MASK_GET(req->protocolVersion, Z_ProtocolVersion_1))
93 ODR_MASK_SET(resp->protocolVersion, Z_ProtocolVersion_1);
95 if (ODR_MASK_GET(req->protocolVersion, Z_ProtocolVersion_2))
97 ODR_MASK_SET(resp->protocolVersion, Z_ProtocolVersion_2);
99 if (ODR_MASK_GET(req->protocolVersion, Z_ProtocolVersion_3))
101 ODR_MASK_SET(resp->protocolVersion, Z_ProtocolVersion_3);
105 f->m_facility->init(this, req, resp);
108 send_Z_PDU(apdu_response);
116 taken = f->m_facility->recv(this, apdu_request);
123 yaz_log (LOG_LOG, "got request = %d", apdu_request->which);