X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fyaz-my-server.cpp;h=38a3bc780d7f94591f8347cac7ce993ba52d326f;hb=b79576d9970810e60bc7b34cc9af56f3139fa5d8;hp=c7c92f488d225f5bbe80258b353cbbc5883542e1;hpb=5238ea544d4a2b414592f1d503f5ed83f305b21b;p=yazpp-moved-to-github.git diff --git a/src/yaz-my-server.cpp b/src/yaz-my-server.cpp index c7c92f4..38a3bc7 100644 --- a/src/yaz-my-server.cpp +++ b/src/yaz-my-server.cpp @@ -2,59 +2,7 @@ * Copyright (c) 1998-2001, Index Data. * See the file LICENSE for details. * - * $Log: yaz-my-server.cpp,v $ - * Revision 1.1 2001-03-27 14:47:45 adam - * New server facility scheme. - * - * Revision 1.15 2001/03/26 14:43:49 adam - * New threaded PDU association. - * - * Revision 1.14 2000/11/01 14:22:59 adam - * Added fd parameter for method IYaz_PDU_Observer::clone. - * - * Revision 1.13 2000/10/11 11:58:16 adam - * Moved header files to include/yaz++. Switched to libtool and automake. - * Configure script creates yaz++-config script. - * - * Revision 1.12 2000/09/21 21:43:20 adam - * Better high-level server API. - * - * Revision 1.11 2000/09/12 16:23:49 adam - * Updated server example. - * - * Revision 1.10 2000/09/12 16:04:17 adam - * Added comstack method for Yaz_PDU_Assoc.. - * - * Revision 1.9 2000/09/12 12:09:53 adam - * More work on high-level server. - * - * Revision 1.8 2000/09/08 10:23:42 adam - * Added skeleton of yaz-z-server. - * - * Revision 1.7 1999/12/06 13:52:45 adam - * Modified for new location of YAZ header files. Experimental threaded - * operation. - * - * Revision 1.6 1999/04/21 12:09:01 adam - * Many improvements. Modified to proxy server to work with "sessions" - * based on cookies. - * - * Revision 1.5 1999/04/09 11:46:57 adam - * Added object Yaz_Z_Assoc. Much more functional client. - * - * Revision 1.4 1999/03/23 14:17:57 adam - * More work on timeout handling. Work on yaz-client. - * - * Revision 1.3 1999/02/02 14:01:22 adam - * First WIN32 port of YAZ++. - * - * Revision 1.2 1999/01/28 13:08:47 adam - * Yaz_PDU_Assoc better encapsulated. Memory leak fix in - * yaz-socket-manager.cc. - * - * Revision 1.1.1.1 1999/01/28 09:41:07 adam - * First implementation of YAZ++. - * + * $Id: yaz-my-server.cpp,v 1.9 2001-11-06 17:08:05 adam Exp $ */ #include @@ -65,10 +13,22 @@ class MyILL : public Yaz_Facility_ILL { public: - int ill_init (Z_InitRequest *initRequest, - Z_InitResponse *initResponse); + void ill_service (Z_ExtendedServicesRequest *req, + Z_ItemOrder *io, + Z_ExtendedServicesResponse *res); }; +class MyUpdate : public Yaz_Facility_Update { +public: + void update_service (Z_ExtendedServicesRequest *req, + Z_IUUpdate *io, + Z_ExtendedServicesResponse *res); + void update_service0 (Z_ExtendedServicesRequest *req, + Z_IU0Update *io, + Z_ExtendedServicesResponse *res); +}; + + class MyRetrieval : public Yaz_Facility_Retrieval, Yaz_USMARC { public: int sr_init (Z_InitRequest *initRequest, @@ -85,8 +45,18 @@ 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(); MyServer(IYaz_PDU_Observable *the_PDU_Observable); IYaz_PDU_Observer* sessionNotify(IYaz_PDU_Observable *the_PDU_Observable, int fd); @@ -95,16 +65,65 @@ public: void connectNotify(); private: + MyRetrieval m_retrieval; + MyILL m_ill; + MyUpdate m_update; +#if HAVE_YAZ_URSULA_H + MyUrsula m_ursula; +#endif int m_no; }; -int MyILL::ill_init (Z_InitRequest *initRequest, - Z_InitResponse *initResponse) +void MyILL::ill_service (Z_ExtendedServicesRequest *req, + Z_ItemOrder *io, + Z_ExtendedServicesResponse *res) { - yaz_log (LOG_LOG, "MyILL::ill_init"); - return 1; + yaz_log (LOG_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)"); } +void MyUpdate::update_service0 (Z_ExtendedServicesRequest *req, + Z_IU0Update *io, + Z_ExtendedServicesResponse *res) +{ + yaz_log (LOG_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) { @@ -148,21 +167,27 @@ void MyRetrieval::sr_record (const char *resultSetName, { yaz_log (LOG_LOG, "MyServer::recv_Z_record"); const char *rec = get_record(position); - create_databaseRecord (namePlusRecord, 0, VAL_USMARC, rec, + create_databaseRecord (odr_encode(), namePlusRecord, 0, VAL_USMARC, rec, strlen(rec)); } +MyServer::~MyServer() +{ +} + IYaz_PDU_Observer *MyServer::sessionNotify( IYaz_PDU_Observable *the_PDU_Observable, int fd) { MyServer *new_server; - MyRetrieval *new_ret = new MyRetrieval; - MyILL *new_ill = new MyILL; m_no++; new_server = new MyServer(the_PDU_Observable); new_server->timeout(900); - new_server->facility_add(new_ret, "my sr"); - new_server->facility_add(new_ill, "my ill"); + 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()); @@ -191,7 +216,6 @@ void MyServer::connectNotify() { } - void usage(char *prog) { fprintf (stderr, "%s: [-a log] [-v level] [-T] @:port\n", prog); @@ -234,10 +258,14 @@ int main(int argc, char **argv) return 1; } } +#if YAZ_POSIX_THREADS if (thread_flag) my_PDU_Assoc = new Yaz_PDU_AssocThread(&mySocketManager); else my_PDU_Assoc = new Yaz_PDU_Assoc(&mySocketManager); +#else + my_PDU_Assoc = new Yaz_PDU_Assoc(&mySocketManager); +#endif z = new MyServer(my_PDU_Assoc); z->server(addr);