X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fyaz-my-server.cpp;h=adb63deddd7cfd49e52fbc415a939b79cea08cc3;hb=5e3f7e1a720a08d30c407049c94c6ca825a5ed27;hp=94492892368213201976f44e4e5fde2e084d2df2;hpb=ceb226cb18d96a6b3aa2dd6cff94aa27850362cf;p=yazpp-moved-to-github.git diff --git a/src/yaz-my-server.cpp b/src/yaz-my-server.cpp index 9449289..adb63de 100644 --- a/src/yaz-my-server.cpp +++ b/src/yaz-my-server.cpp @@ -2,10 +2,12 @@ * Copyright (c) 1998-2001, Index Data. * See the file LICENSE for details. * - * $Id: yaz-my-server.cpp,v 1.10 2002-10-09 12:50:26 adam Exp $ + * $Id: yaz-my-server.cpp,v 1.16 2005-05-17 13:00:56 adam Exp $ */ +#include #include +#include #include #include #include @@ -45,15 +47,6 @@ public: Z_Records *records); }; -#if HAVE_YAZ_URSULA_H -class MyUrsula : public Yaz_Facility_Ursula { -public: - void ursula_service (Z_ExtendedServicesRequest *req, - Z_UrsPDU *u, - Z_ExtendedServicesResponse *res); -}; -#endif - class MyServer : public Yaz_Z_Server { public: ~MyServer(); @@ -68,9 +61,6 @@ private: MyRetrieval m_retrieval; MyILL m_ill; MyUpdate m_update; -#if HAVE_YAZ_URSULA_H - MyUrsula m_ursula; -#endif int m_no; }; @@ -78,63 +68,34 @@ void MyILL::ill_service (Z_ExtendedServicesRequest *req, Z_ItemOrder *io, Z_ExtendedServicesResponse *res) { - yaz_log (LOG_LOG, "MyServer::ill_service"); + yaz_log (YLOG_LOG, "MyServer::ill_service"); } void MyUpdate::update_service (Z_ExtendedServicesRequest *req, Z_IUUpdate *io, Z_ExtendedServicesResponse *res) { - yaz_log (LOG_LOG, "MyServer::update_service (v1.1)"); + yaz_log (YLOG_LOG, "MyServer::update_service (v1.1)"); } void MyUpdate::update_service0 (Z_ExtendedServicesRequest *req, Z_IU0Update *io, Z_ExtendedServicesResponse *res) { - yaz_log (LOG_LOG, "MyServer::update_service (v1.0)"); + yaz_log (YLOG_LOG, "MyServer::update_service (v1.0)"); } -#if HAVE_YAZ_URSULA_H -void MyUrsula::ursula_service (Z_ExtendedServicesRequest *req, - Z_UrsPDU *u, - Z_ExtendedServicesResponse *res) -{ - yaz_log (LOG_LOG, "MyServer::ursula_service"); - switch (u->which) - { - case Z_UrsPDU_request: - yaz_log(LOG_LOG, "request"); - if (u->u.request->libraryNo) - yaz_log (LOG_LOG, "libraryNo: %s", u->u.request->libraryNo); - break; - case Z_UrsPDU_update: - yaz_log(LOG_LOG, "request"); - break; - case Z_UrsPDU_reservation: - yaz_log(LOG_LOG, "request"); - break; - case Z_UrsPDU_renewal: - yaz_log(LOG_LOG, "request"); - break; - default: - yaz_log(LOG_LOG, "unknown"); - break; - } -} -#endif - int MyRetrieval::sr_init (Z_InitRequest *initRequest, Z_InitResponse *initResponse) { - yaz_log (LOG_LOG, "MyServer::sr_init"); + yaz_log (YLOG_LOG, "MyServer::sr_init"); return 1; } void MyRetrieval::sr_search (Z_SearchRequest *searchRequest, Z_SearchResponse *searchResponse) { - yaz_log (LOG_LOG, "MyServer::recv_Z_search"); + yaz_log (YLOG_LOG, "MyServer::recv_Z_search"); if (searchRequest->query->which == Z_Query_type_1) { Z_RPNStructure *s = searchRequest->query->u.type_1->RPNStructure; @@ -155,7 +116,7 @@ void MyRetrieval::sr_search (Z_SearchRequest *searchRequest, void MyRetrieval::sr_present (Z_PresentRequest *presentRequest, Z_PresentResponse *presentResponse) { - yaz_log (LOG_LOG, "MyServer::recv_Z_present"); + yaz_log (YLOG_LOG, "MyServer::recv_Z_present"); } void MyRetrieval::sr_record (const char *resultSetName, @@ -165,10 +126,14 @@ void MyRetrieval::sr_record (const char *resultSetName, Z_NamePlusRecord *namePlusRecord, Z_Records *records) { - yaz_log (LOG_LOG, "MyServer::recv_Z_record"); + yaz_log (YLOG_LOG, "MyServer::recv_Z_record"); const char *rec = get_record(position); - create_databaseRecord (odr_encode(), namePlusRecord, 0, VAL_USMARC, rec, - strlen(rec)); + if (rec) + create_databaseRecord (odr_encode(), namePlusRecord, 0, + VAL_USMARC, rec, strlen(rec)); + else + create_surrogateDiagnostics(odr_encode(), namePlusRecord, 0, + YAZ_BIB1_PRESENT_REQUEST_OUT_OF_RANGE, 0); } MyServer::~MyServer() @@ -185,10 +150,6 @@ IYaz_PDU_Observer *MyServer::sessionNotify( new_server->facility_add(&new_server->m_retrieval, "my sr"); new_server->facility_add(&new_server->m_ill, "my ill"); new_server->facility_add(&new_server->m_update, "my update"); -#if HAVE_YAZ_URSULA_H - new_server->facility_add(&new_server->m_ursula, "my ursula"); -#endif - new_server->set_APDU_log(get_APDU_log()); return new_server; @@ -202,13 +163,13 @@ MyServer::MyServer(IYaz_PDU_Observable *the_PDU_Observable) : void MyServer::timeoutNotify() { - yaz_log (LOG_LOG, "connection timed out"); + yaz_log (YLOG_LOG, "connection timed out"); delete this; } void MyServer::failNotify() { - yaz_log (LOG_LOG, "connection closed by client"); + yaz_log (YLOG_LOG, "connection closed by client"); delete this; } @@ -216,7 +177,7 @@ void MyServer::connectNotify() { } -void usage(char *prog) +void usage(const char *prog) { fprintf (stderr, "%s: [-a log] [-v level] [-T] @:port\n", prog); exit (1); @@ -227,7 +188,7 @@ int main(int argc, char **argv) int thread_flag = 0; char *arg; char *prog = *argv; - char *addr = "tcp:@:9999"; + const char *addr = "tcp:@:9999"; char *apdu_log = 0; Yaz_SocketManager mySocketManager; @@ -271,7 +232,7 @@ int main(int argc, char **argv) z->server(addr); if (apdu_log) { - yaz_log (LOG_LOG, "set_APDU_log %s", apdu_log); + yaz_log (YLOG_LOG, "set_APDU_log %s", apdu_log); z->set_APDU_log(apdu_log); }