X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=src%2Fyaz-z-server.cpp;h=06992b7326a847b554680c9b18f9293647867929;hb=6196cb9e06a6cc83892e1ad16daa1fb921111e28;hp=dff28151d662d54372962dc3b254feb9213af5e5;hpb=28588b9224eb5189af32b10f440ef2a917a05ea2;p=yazpp-moved-to-github.git diff --git a/src/yaz-z-server.cpp b/src/yaz-z-server.cpp index dff2815..06992b7 100644 --- a/src/yaz-z-server.cpp +++ b/src/yaz-z-server.cpp @@ -1,30 +1,32 @@ /* - * Copyright (c) 2000-2003, Index Data. + * Copyright (c) 2000-2004, Index Data. * See the file LICENSE for details. * - * $Id: yaz-z-server.cpp,v 1.16 2003-10-01 13:13:51 adam Exp $ + * $Id: yaz-z-server.cpp,v 1.22 2005-06-08 13:28:06 adam Exp $ */ #include #include -Yaz_Z_Server::Yaz_Z_Server(IYaz_PDU_Observable *the_PDU_Observable) - : Yaz_Z_Assoc(the_PDU_Observable) +using namespace yazpp_1; + +Z_Server::Z_Server(IPDU_Observable *the_PDU_Observable) + : Z_Assoc(the_PDU_Observable) { m_facilities = 0; } -Yaz_Z_Server::~Yaz_Z_Server() +Z_Server::~Z_Server() { facility_reset(); } -void Yaz_Z_Server::facility_reset () +void Z_Server::facility_reset () { - Yaz_Z_Server_Facility_Info *p = m_facilities; + Z_Server_Facility_Info *p = m_facilities; while (p) { - Yaz_Z_Server_Facility_Info *p_next = p->m_next; + Z_Server_Facility_Info *p_next = p->m_next; delete [] p->m_name; delete p; @@ -33,14 +35,14 @@ void Yaz_Z_Server::facility_reset () m_facilities = 0; } -void Yaz_Z_Server::facility_add(IYaz_Server_Facility *facility, - const char *name) +void Z_Server::facility_add(IServer_Facility *facility, + const char *name) { - Yaz_Z_Server_Facility_Info **p = &m_facilities; + Z_Server_Facility_Info **p = &m_facilities; while (*p) p = &(*p)->m_next; - *p = new Yaz_Z_Server_Facility_Info; + *p = new Z_Server_Facility_Info; (*p)->m_next = 0; (*p)->m_name = new char [strlen(name)+1]; @@ -48,9 +50,17 @@ void Yaz_Z_Server::facility_add(IYaz_Server_Facility *facility, (*p)->m_facility = facility; } -void Yaz_Z_Server::recv_Z_PDU (Z_APDU *apdu_request, int len) +void Z_Server::recv_GDU (Z_GDU *apdu, int len) +{ + if (apdu->which == Z_GDU_Z3950) + recv_Z_PDU(apdu->u.z3950, len); + else + delete this; +} + +void Z_Server::recv_Z_PDU (Z_APDU *apdu_request, int len) { - Yaz_Z_Server_Facility_Info *f = m_facilities; + Z_Server_Facility_Info *f = m_facilities; if (apdu_request->which == Z_APDU_initRequest) { @@ -92,7 +102,7 @@ void Yaz_Z_Server::recv_Z_PDU (Z_APDU *apdu_request, int len) } if (!taken) { - yaz_log (LOG_WARN, "unhandled request = %d", apdu_request->which); + yaz_log (YLOG_WARN, "unhandled request = %d", apdu_request->which); delete this; } } @@ -101,7 +111,7 @@ void Yaz_Z_Server::recv_Z_PDU (Z_APDU *apdu_request, int len) /* * database record. */ -void Yaz_Z_ServerUtility::create_databaseRecord ( +void Z_ServerUtility::create_databaseRecord ( ODR odr, Z_NamePlusRecord *rec, const char *dbname, int format, const void *buf, int len) { @@ -114,7 +124,7 @@ void Yaz_Z_ServerUtility::create_databaseRecord ( /* * surrogate diagnostic. */ -void Yaz_Z_ServerUtility::create_surrogateDiagnostics( +void Z_ServerUtility::create_surrogateDiagnostics( ODR odr, Z_NamePlusRecord *rec, const char *dbname, int error, char *const addinfo) { @@ -123,7 +133,7 @@ void Yaz_Z_ServerUtility::create_surrogateDiagnostics( Z_DefaultDiagFormat *dr = (Z_DefaultDiagFormat *) odr_malloc (odr, sizeof(*dr)); - yaz_log(LOG_DEBUG, "SurrogateDiagnotic: %d -- %s", error, addinfo); + yaz_log(YLOG_DEBUG, "SurrogateDiagnotic: %d -- %s", error, addinfo); *err = error; rec->databaseName = dbname ? odr_strdup (odr, dbname) : 0; rec->which = Z_NamePlusRecord_surrogateDiagnostic; @@ -138,7 +148,7 @@ void Yaz_Z_ServerUtility::create_surrogateDiagnostics( dr->u.v2Addinfo = odr_strdup (odr, addinfo ? addinfo : ""); } -Z_Records *Yaz_Z_ServerUtility::create_nonSurrogateDiagnostics ( +Z_Records *Z_ServerUtility::create_nonSurrogateDiagnostics ( ODR odr, int error, const char *addinfo) { Z_Records *rec = (Z_Records *) @@ -162,7 +172,7 @@ Z_Records *Yaz_Z_ServerUtility::create_nonSurrogateDiagnostics ( return rec; } -void Yaz_Z_ServerUtility::create_diagnostics ( +void Z_ServerUtility::create_diagnostics ( ODR odr, int error, const char *addinfo, Z_DiagRec ***dreca, int *num) {