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