From b416df50f7dec326e96cd809220ea66a66044e88 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 2 Nov 2001 13:06:29 +0000 Subject: [PATCH 01/16] Fixed bug in result_set_optimize where LSLB == resultCount. --- src/yaz-proxy.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index d501230..d351988 100644 --- a/src/yaz-proxy.cpp +++ b/src/yaz-proxy.cpp @@ -3,7 +3,10 @@ * See the file LICENSE for details. * * $Log: yaz-proxy.cpp,v $ - * Revision 1.26 2001-08-13 16:39:12 adam + * Revision 1.27 2001-11-02 13:06:29 adam + * Fixed bug in result_set_optimize where LSLB == resultCount. + * + * Revision 1.26 2001/08/13 16:39:12 adam * PDU_Assoc keeps track of children. Using yaz_log instead of logf. * * Revision 1.25 2001/04/25 18:59:30 adam @@ -360,7 +363,7 @@ Z_APDU *Yaz_Proxy::result_set_optimize(Z_APDU *apdu) m_client->m_sr_transform = 1; return new_apdu; } - else if (m_client->m_last_resultCount > *sr->largeSetLowerBound || + else if (m_client->m_last_resultCount >= *sr->largeSetLowerBound || m_client->m_last_resultCount == 0) { // large set @@ -460,6 +463,8 @@ void Yaz_Proxy::shutdown() // only keep if keep_alive flag and cookie is set... if (m_keepalive && m_client && m_client->m_cookie[0]) { + yaz_log (LOG_LOG, "shutdown - keepalive this=%p, m_server=%p", + this, m_client->m_server); if (m_client->m_waiting == 2) abort(); // Tell client (if any) that no server connection is there.. @@ -474,7 +479,8 @@ void Yaz_Proxy::shutdown() } else if (!m_parent) { - abort(); + yaz_log (LOG_LOG, "abort %p", this); + abort(); } delete this; } -- 1.7.10.4 From 966d1a0443071c2b75426d0214bfb9960c5c3fba Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Sun, 4 Nov 2001 22:36:21 +0000 Subject: [PATCH 02/16] Fixed problem processEvent which in rare cases return 0. --- configure.in | 2 +- include/yaz++/yaz-socket-manager.h | 3 +- src/Makefile.am | 4 +- src/yaz-ir-assoc.cpp | 45 +----------------- src/yaz-marc-sample.cpp | 5 +- src/yaz-my-client.cpp | 88 +--------------------------------- src/yaz-my-server.cpp | 74 +---------------------------- src/yaz-pdu-assoc-thread.cpp | 11 +---- src/yaz-pdu-assoc.cpp | 81 +------------------------------ src/yaz-proxy-main.cpp | 45 +----------------- src/yaz-proxy.cpp | 92 +----------------------------------- src/yaz-socket-manager.cpp | 72 +++++----------------------- src/yaz-z-assoc.cpp | 75 +---------------------------- src/yaz-z-query.cpp | 38 +-------------- src/yaz-z-server-ill.cpp | 20 +------- src/yaz-z-server-sr.cpp | 10 +--- src/yaz-z-server-update.cpp | 10 +--- src/yaz-z-server-ursula.cpp | 17 +------ src/yaz-z-server.cpp | 42 +--------------- yaz.m4 | 2 +- 20 files changed, 36 insertions(+), 700 deletions(-) diff --git a/configure.in b/configure.in index cbb90bf..5e07d83 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ AC_INIT(configure.in) -AM_INIT_AUTOMAKE("yaz++", 0.1) +AM_INIT_AUTOMAKE("yaz++", 0.2) AC_PROG_CC AC_PROG_CPP diff --git a/include/yaz++/yaz-socket-manager.h b/include/yaz++/yaz-socket-manager.h index 0cb57c8..73b00d2 100644 --- a/include/yaz++/yaz-socket-manager.h +++ b/include/yaz++/yaz-socket-manager.h @@ -2,7 +2,7 @@ * Copyright (c) 1998-2000, Index Data. * See the file LICENSE for details. * - * $Id: yaz-socket-manager.h,v 1.1 2000-10-11 11:58:16 adam Exp $ + * $Id: yaz-socket-manager.h,v 1.2 2001-11-04 22:36:21 adam Exp $ */ #ifndef YAZ_SOCKET_MANAGER_INCLUDED @@ -22,6 +22,7 @@ class YAZ_EXPORT Yaz_SocketManager : public IYazSocketObservable { int fd; unsigned mask; unsigned timeout; + unsigned timeout_this; time_t last_activity; YazSocketEntry *next; }; diff --git a/src/Makefile.am b/src/Makefile.am index 22f29ce..07bc103 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ -## $Id: Makefile.am,v 1.7 2001-08-09 09:01:03 adam Exp $ +## $Id: Makefile.am,v 1.8 2001-11-04 22:36:21 adam Exp $ -INCLUDES=$(YAZINC) -I$(srcdir)/../include +CXXFLAGS = $(YAZINC) -I$(srcdir)/../include lib_LTLIBRARIES = libyaz++.la diff --git a/src/yaz-ir-assoc.cpp b/src/yaz-ir-assoc.cpp index d30eab3..68f7012 100644 --- a/src/yaz-ir-assoc.cpp +++ b/src/yaz-ir-assoc.cpp @@ -2,50 +2,7 @@ * Copyright (c) 1998-2000, Index Data. * See the file LICENSE for details. * - * $Log: yaz-ir-assoc.cpp,v $ - * Revision 1.16 2001-08-13 16:39:12 adam - * PDU_Assoc keeps track of children. Using yaz_log instead of logf. - * - * Revision 1.15 2001/04/26 12:17:49 heikki - * Ursula stuff, mostly in the test client - * - * Revision 1.14 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.13 2000/09/06 14:23:45 adam - * WIN32 updates. - * - * Revision 1.12 2000/05/10 11:36:58 ian - * Added default parameters for refid to request functions. - * Added default parameter for result set name to search and present request. - * Commented out forced logging of PDU contents. - * Added send_deleteResultSetRequest - * - * Revision 1.11 1999/12/06 13:52:45 adam - * Modified for new location of YAZ header files. Experimental threaded - * operation. - * - * Revision 1.10 1999/04/29 07:33:28 adam - * Changed setting of host in connect/proxy setting. YAZ' strtoaddr now - * ignores database part of host. - * - * Revision 1.9 1999/04/28 13:29:14 adam - * Yet another fix regarding database settings. - * - * Revision 1.8 1999/04/28 13:04:03 adam - * Fixed setting of proxy otherInfo so that database(s) are removed. - * - * Revision 1.7 1999/04/21 12:09:01 adam - * Many improvements. Modified to proxy server to work with "sessions" - * based on cookies. - * - * Revision 1.6 1999/04/20 10:30:05 adam - * Implemented various stuff for client and proxy. Updated calls - * to ODR to reflect new name parameter. - * - * Revision 1.5 1999/04/09 11:46:57 adam - * Added object Yaz_Z_Assoc. Much more functional client. + * $Id: yaz-ir-assoc.cpp,v 1.17 2001-11-04 22:36:21 adam Exp $ */ #include diff --git a/src/yaz-marc-sample.cpp b/src/yaz-marc-sample.cpp index a276242..5ad5bd6 100644 --- a/src/yaz-marc-sample.cpp +++ b/src/yaz-marc-sample.cpp @@ -2,10 +2,7 @@ * Copyright (c) 2000-2001, Index Data. * See the file LICENSE for details. * - * $Log: yaz-marc-sample.cpp,v $ - * Revision 1.1 2001-03-27 14:47:45 adam - * New server facility scheme. - * + * $Id: yaz-marc-sample.cpp,v 1.2 2001-11-04 22:36:21 adam Exp $ */ #include diff --git a/src/yaz-my-client.cpp b/src/yaz-my-client.cpp index c655184..6bb36eb 100644 --- a/src/yaz-my-client.cpp +++ b/src/yaz-my-client.cpp @@ -1,92 +1,8 @@ /* - * Copyright (c) 1998-2000, Index Data. + * Copyright (c) 1998-2001, Index Data. * See the file LICENSE for details. * - * $Log: yaz-my-client.cpp,v $ - * Revision 1.9 2001-04-26 17:51:56 heikki - * better ursula request (doesn't crash) - * - * Revision 1.8 2001/04/26 17:30:07 heikki - * Ursularequest got more default data - * - * Revision 1.7 2001/04/26 12:17:49 heikki - * Ursula stuff, mostly in the test client - * - * Revision 1.6 2001/04/17 16:21:21 heikki - * Working on UrsulaRenewal, Request, and Update - * - * Revision 1.5 2001/04/10 10:48:08 adam - * Fixed problem where proxy could cash bad result sets. - * - * Revision 1.4 2001/04/05 15:12:24 adam - * WIN32 updates. - * - * Revision 1.3 2001/04/05 13:09:44 adam - * Removed ursula dependancy. - * - * Revision 1.2 2001/04/04 14:02:49 adam - * URSULA / Z-ruth service. - * - * Revision 1.1 2001/03/27 14:47:45 adam - * New server facility scheme. - * - * Revision 1.17 2001/03/26 14:43:49 adam - * New threaded PDU association. - * - * Revision 1.16 2000/11/01 14:22:59 adam - * Added fd parameter for method IYaz_PDU_Observer::clone. - * - * Revision 1.15 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.14 2000/09/08 10:23:42 adam - * Added skeleton of yaz-z-server. - * - * Revision 1.13 2000/09/06 14:23:45 adam - * WIN32 updates. - * - * Revision 1.12 2000/09/04 08:59:16 adam - * Changed call to logging functions (yaz_ added). - * - * Revision 1.11 2000/07/04 13:48:49 adam - * Implemented upper-limit on proxy-to-target sessions. - * - * Revision 1.10 2000/05/30 03:12:27 ian - * minor change to stop g++ 2.95.2 complaining about taking the address - * of a member function. - * - * Revision 1.9 1999/12/06 13:52:45 adam - * Modified for new location of YAZ header files. Experimental threaded - * operation. - * - * Revision 1.8 1999/11/10 10:02:34 adam - * Work on proxy. - * - * Revision 1.7 1999/04/21 12:09:01 adam - * Many improvements. Modified to proxy server to work with "sessions" - * based on cookies. - * - * Revision 1.6 1999/04/20 10:30:05 adam - * Implemented various stuff for client and proxy. Updated calls - * to ODR to reflect new name parameter. - * - * 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:18 adam - * First WIN32 port of YAZ++. - * - * Revision 1.2 1999/01/28 13:08:42 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-client.cpp,v 1.10 2001-11-04 22:36:21 adam Exp $ */ #include diff --git a/src/yaz-my-server.cpp b/src/yaz-my-server.cpp index 0ec90bd..6f6a490 100644 --- a/src/yaz-my-server.cpp +++ b/src/yaz-my-server.cpp @@ -2,79 +2,7 @@ * Copyright (c) 1998-2001, Index Data. * See the file LICENSE for details. * - * $Log: yaz-my-server.cpp,v $ - * Revision 1.7 2001-08-13 16:39:12 adam - * PDU_Assoc keeps track of children. Using yaz_log instead of logf. - * - * Revision 1.6 2001/05/17 14:18:03 adam - * New handler for old version item update for server: - * void update_service0 (Z_ExtendedServicesRequest *req, - * Z_IU0Update *io, Z_ExtendedServicesResponse *res) - * - * Revision 1.5 2001/05/03 12:39:39 adam - * Added Update server service. - * - * Revision 1.4 2001/04/05 13:09:44 adam - * Removed ursula dependancy. - * - * Revision 1.3 2001/04/04 14:02:49 adam - * URSULA / Z-ruth service. - * - * Revision 1.2 2001/03/29 15:14:26 adam - * Minor updates. - * - * 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.8 2001-11-04 22:36:21 adam Exp $ */ #include diff --git a/src/yaz-pdu-assoc-thread.cpp b/src/yaz-pdu-assoc-thread.cpp index d59846c..4a445fd 100644 --- a/src/yaz-pdu-assoc-thread.cpp +++ b/src/yaz-pdu-assoc-thread.cpp @@ -2,16 +2,7 @@ * Copyright (c) 1998-2001, Index Data. * See the file LICENSE for details. * - * $Log: yaz-pdu-assoc-thread.cpp,v $ - * Revision 1.3 2001-08-13 16:39:12 adam - * PDU_Assoc keeps track of children. Using yaz_log instead of logf. - * - * Revision 1.2 2001/03/27 14:47:45 adam - * New server facility scheme. - * - * Revision 1.1 2001/03/26 14:43:49 adam - * New threaded PDU association. - * + * $Id: yaz-pdu-assoc-thread.cpp,v 1.4 2001-11-04 22:36:21 adam Exp $ */ #ifdef WIN32 diff --git a/src/yaz-pdu-assoc.cpp b/src/yaz-pdu-assoc.cpp index 17dc1b0..0ed6f29 100644 --- a/src/yaz-pdu-assoc.cpp +++ b/src/yaz-pdu-assoc.cpp @@ -2,86 +2,7 @@ * Copyright (c) 1998-2001, Index Data. * See the file LICENSE for details. * - * $Log: yaz-pdu-assoc.cpp,v $ - * Revision 1.24 2001-08-13 16:39:12 adam - * PDU_Assoc keeps track of children. Using yaz_log instead of logf. - * - * Revision 1.23 2001/03/26 14:43:49 adam - * New threaded PDU association. - * - * Revision 1.22 2001/01/29 11:18:24 adam - * Server sets OPTIONS search and present. - * - * Revision 1.21 2000/11/20 14:17:36 adam - * Yet another WIN32 fix for connect notify. - * - * Revision 1.20 2000/11/20 11:27:33 adam - * Fixes for connect operation (timeout and notify fix). - * - * Revision 1.19 2000/11/01 14:22:59 adam - * Added fd parameter for method IYaz_PDU_Observer::clone. - * - * Revision 1.18 2000/10/24 12:29:57 adam - * Fixed bug in proxy where a Yaz_ProxyClient could be owned by - * two Yaz_Proxy's (fatal). - * - * Revision 1.17 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.16 2000/09/22 09:54:11 heikki - * minor - * - * Revision 1.15 2000/09/21 21:43:20 adam - * Better high-level server API. - * - * Revision 1.14 2000/09/12 12:09:53 adam - * More work on high-level server. - * - * Revision 1.13 2000/09/08 10:23:42 adam - * Added skeleton of yaz-z-server. - * - * Revision 1.12 2000/09/06 14:23:45 adam - * WIN32 updates. - * - * Revision 1.11 2000/09/04 08:29:22 adam - * Fixed memory leak(s). Added re-use of associations, rather than - * re-init, when maximum number of targets are in use. - * - * Revision 1.10 2000/08/10 08:42:42 adam - * Fixes for {set,get}_APDU_log. - * - * Revision 1.9 1999/12/06 13:52:45 adam - * Modified for new location of YAZ header files. Experimental threaded - * operation. - * - * Revision 1.8 1999/04/28 13:04:03 adam - * Fixed setting of proxy otherInfo so that database(s) are removed. - * - * Revision 1.7 1999/04/21 12:09:01 adam - * Many improvements. Modified to proxy server to work with "sessions" - * based on cookies. - * - * Revision 1.6 1999/04/20 10:30:05 adam - * Implemented various stuff for client and proxy. Updated calls - * to ODR to reflect new name parameter. - *g - * 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:20 adam - * First WIN32 port of YAZ++. - * - * Revision 1.2 1999/01/28 13:08:44 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-pdu-assoc.cpp,v 1.25 2001-11-04 22:36:21 adam Exp $ */ #include diff --git a/src/yaz-proxy-main.cpp b/src/yaz-proxy-main.cpp index f6abc77..0487363 100644 --- a/src/yaz-proxy-main.cpp +++ b/src/yaz-proxy-main.cpp @@ -2,50 +2,7 @@ * Copyright (c) 1998-2001, Index Data. * See the file LICENSE for details. * - * $Log: yaz-proxy-main.cpp,v $ - * Revision 1.13 2001-04-10 10:48:08 adam - * Fixed problem where proxy could cash bad result sets. - * - * Revision 1.12 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.11 2000/09/08 10:23:42 adam - * Added skeleton of yaz-z-server. - * - * Revision 1.10 2000/09/04 08:59:16 adam - * Changed call to logging functions (yaz_ added). - * - * Revision 1.9 2000/08/07 14:19:59 adam - * Fixed serious bug regarding timeouts. Improved logging for proxy. - * - * Revision 1.8 2000/07/04 13:48:49 adam - * Implemented upper-limit on proxy-to-target sessions. - * - * 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/11/10 10:02:34 adam - * Work on proxy. - * - * Revision 1.5 1999/04/21 12:09:01 adam - * Many improvements. Modified to proxy server to work with "sessions" - * based on cookies. - * - * Revision 1.4 1999/04/09 11:46:57 adam - * Added object Yaz_Z_Assoc. Much more functional client. - * - * Revision 1.3 1999/02/02 14:01:21 adam - * First WIN32 port of YAZ++. - * - * Revision 1.2 1999/01/28 13:08:45 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-proxy-main.cpp,v 1.14 2001-11-04 22:36:21 adam Exp $ */ #include diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index d351988..a73c95a 100644 --- a/src/yaz-proxy.cpp +++ b/src/yaz-proxy.cpp @@ -2,97 +2,7 @@ * Copyright (c) 1998-2001, Index Data. * See the file LICENSE for details. * - * $Log: yaz-proxy.cpp,v $ - * Revision 1.27 2001-11-02 13:06:29 adam - * Fixed bug in result_set_optimize where LSLB == resultCount. - * - * Revision 1.26 2001/08/13 16:39:12 adam - * PDU_Assoc keeps track of children. Using yaz_log instead of logf. - * - * Revision 1.25 2001/04/25 18:59:30 adam - * Added referenceId handling for server. - * - * Revision 1.24 2001/04/10 10:48:08 adam - * Fixed problem where proxy could cash bad result sets. - * - * Revision 1.23 2001/03/26 14:43:49 adam - * New threaded PDU association. - * - * Revision 1.22 2000/11/20 11:27:33 adam - * Fixes for connect operation (timeout and notify fix). - * - * Revision 1.21 2000/11/01 14:22:59 adam - * Added fd parameter for method IYaz_PDU_Observer::clone. - * - * Revision 1.20 2000/10/24 12:29:57 adam - * Fixed bug in proxy where a Yaz_ProxyClient could be owned by - * two Yaz_Proxy's (fatal). - * - * Revision 1.19 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.18 2000/09/08 10:23:42 adam - * Added skeleton of yaz-z-server. - * - * Revision 1.17 2000/09/05 13:57:28 adam - * Fixed get_otherInfoAPDU to return otherInfo for extended services. - * - * Revision 1.16 2000/09/04 08:29:22 adam - * Fixed memory leak(s). Added re-use of associations, rather than - * re-init, when maximum number of targets are in use. - * - * Revision 1.15 2000/08/31 14:41:55 adam - * Proxy no longer generates cookies (it's up to the client). Proxy - * re-opens if target new op is started before previous operation finishes. - * - * Revision 1.14 2000/08/10 08:42:42 adam - * Fixes for {set,get}_APDU_log. - * - * Revision 1.13 2000/08/07 14:19:59 adam - * Fixed serious bug regarding timeouts. Improved logging for proxy. - * - * Revision 1.12 2000/07/04 13:48:49 adam - * Implemented upper-limit on proxy-to-target sessions. - * - * Revision 1.11 1999/12/06 13:52:45 adam - * Modified for new location of YAZ header files. Experimental threaded - * operation. - * - * Revision 1.10 1999/11/10 10:02:34 adam - * Work on proxy. - * - * Revision 1.9 1999/09/13 12:53:44 adam - * Proxy removes OtherInfo Proxy Address and Session ID. Other - * Otherinfo remains untouched. - * - * Revision 1.8 1999/05/04 10:53:00 adam - * Changed the way the PROXY behaves when lost cookie is received. - * - * Revision 1.7 1999/04/28 13:31:17 adam - * Better result set optimisation for proxy. - * - * Revision 1.6 1999/04/27 07:52:13 adam - * Improved proxy; added query match for result set re-use. - * - * Revision 1.5 1999/04/21 12:09:01 adam - * Many improvements. Modified to proxy server to work with "sessions" - * based on cookies. - * - * Revision 1.4 1999/04/20 10:30:05 adam - * Implemented various stuff for client and proxy. Updated calls - * to ODR to reflect new name parameter. - * - * Revision 1.3 1999/04/09 11:46:57 adam - * Added object Yaz_Z_Assoc. Much more functional client. - * - * Revision 1.2 1999/01/28 13:08:46 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-proxy.cpp,v 1.28 2001-11-04 22:36:21 adam Exp $ */ #include diff --git a/src/yaz-socket-manager.cpp b/src/yaz-socket-manager.cpp index d951926..5f0f7df 100644 --- a/src/yaz-socket-manager.cpp +++ b/src/yaz-socket-manager.cpp @@ -1,61 +1,8 @@ /* - * Copyright (c) 1998-2000, Index Data. + * Copyright (c) 1998-2001, Index Data. * See the file LICENSE for details. * - * $Log: yaz-socket-manager.cpp,v $ - * Revision 1.16 2001-08-13 16:39:12 adam - * PDU_Assoc keeps track of children. Using yaz_log instead of logf. - * - * Revision 1.15 2001/03/26 14:43:49 adam - * New threaded PDU association. - * - * Revision 1.14 2000/11/20 14:17:36 adam - * Yet another WIN32 fix for connect notify. - * - * Revision 1.13 2000/11/20 11:27:33 adam - * Fixes for connect operation (timeout and notify fix). - * - * Revision 1.12 2000/10/24 12:29:57 adam - * Fixed bug in proxy where a Yaz_ProxyClient could be owned by - * two Yaz_Proxy's (fatal). - * - * Revision 1.11 2000/10/11 11:58:17 adam - * Moved header files to include/yaz++. Switched to libtool and automake. - * Configure script creates yaz++-config script. - * - * Revision 1.10 2000/09/08 10:23:42 adam - * Added skeleton of yaz-z-server. - * - * Revision 1.9 2000/08/07 14:19:59 adam - * Fixed serious bug regarding timeouts. Improved logging for proxy. - * - * Revision 1.8 1999/12/06 13:52:45 adam - * Modified for new location of YAZ header files. Experimental threaded - * operation. - * - * Revision 1.7 1999/04/28 13:02:08 adam - * Added include of string.h. - * - * 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:23 adam - * First WIN32 port of YAZ++. - * - * Revision 1.2 1999/01/28 13:08:48 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-socket-manager.cpp,v 1.17 2001-11-04 22:36:21 adam Exp $ */ #include #ifdef WIN32 @@ -201,6 +148,9 @@ int Yaz_SocketManager::processEvent() timeout_this = 1; if (!timeout || timeout_this < timeout) timeout = timeout_this; + p->timeout_this = timeout_this; + yaz_log (m_log, "Yaz_SocketManager::select timeout_this=%d", + p->timeout_this); } } if (!no) @@ -215,7 +165,8 @@ int Yaz_SocketManager::processEvent() to.tv_sec = timeout; to.tv_usec = 0; - yaz_log (m_log, "Yaz_SocketManager::select no=%d timeout=%d", no, timeout); + yaz_log (m_log, "Yaz_SocketManager::select begin no=%d timeout=%d", + no, timeout); while ((res = select(max + 1, &in, &out, &except, timeout ? &to : 0)) < 0) if (errno != EINTR) return -1; @@ -241,12 +192,12 @@ int Yaz_SocketManager::processEvent() event->event = mask; putEvent (event); } - else if (p->timeout && p->last_activity && - now >= p->last_activity + (int) (p->timeout)) + else if (res == 0 && p->timeout && p->timeout_this == timeout) { YazSocketEvent *event = new YazSocketEvent; + assert (p->last_activity); yaz_log (m_log, "timeout, now = %ld last_activity=%ld timeout=%d", - now, p->last_activity, p->timeout); + now, p->last_activity, p->timeout); p->last_activity = now; event->observer = p->observer; event->event = YAZ_SOCKET_OBSERVE_TIMEOUT; @@ -259,7 +210,8 @@ int Yaz_SocketManager::processEvent() delete event; return 1; } - return 0; + yaz_log (LOG_WARN, "unhandled event in processEvent"); + return 1; } diff --git a/src/yaz-z-assoc.cpp b/src/yaz-z-assoc.cpp index e9f4b19..052c059 100644 --- a/src/yaz-z-assoc.cpp +++ b/src/yaz-z-assoc.cpp @@ -2,79 +2,7 @@ * Copyright (c) 1998-2001, Index Data. * See the file LICENSE for details. * - * $Log: yaz-z-assoc.cpp,v $ - * Revision 1.21 2001-08-13 16:39:12 adam - * PDU_Assoc keeps track of children. Using yaz_log instead of logf. - * - * Revision 1.20 2001/04/25 18:59:30 adam - * Added referenceId handling for server. - * - * Revision 1.19 2001/03/27 14:47:45 adam - * New server facility scheme. - * - * Revision 1.18 2001/03/26 14:43:49 adam - * New threaded PDU association. - * - * Revision 1.17 2001/01/04 14:25:25 heikki - * No SIGPIPES in windows... - * - * Revision 1.16 2000/12/14 16:00:39 adam - * Ignoring signal SIGPIPE. - * - * Revision 1.15 2000/10/11 11:58:17 adam - * Moved header files to include/yaz++. Switched to libtool and automake. - * Configure script creates yaz++-config script. - * - * Revision 1.14 2000/09/12 16:40:33 heikki - * minor - * - * Revision 1.13 2000/09/08 10:23:42 adam - * Added skeleton of yaz-z-server. - * - * Revision 1.12 2000/09/05 13:57:28 adam - * Fixed get_otherInfoAPDU to return otherInfo for extended services. - * - * Revision 1.11 2000/09/04 08:59:16 adam - * Changed call to logging functions (yaz_ added). - * - * Revision 1.10 2000/09/04 08:29:22 adam - * Fixed memory leak(s). Added re-use of associations, rather than - * re-init, when maximum number of targets are in use. - * - * Revision 1.9 2000/08/10 08:42:42 adam - * Fixes for {set,get}_APDU_log. - * - * Revision 1.8 2000/08/07 14:19:59 adam - * Fixed serious bug regarding timeouts. Improved logging for proxy. - * - * Revision 1.7 2000/05/10 11:36:58 ian - * Added default parameters for refid to request functions. - * Added default parameter for result set name to search and present request. - * Commented out forced logging of PDU contents. - * Added send_deleteResultSetRequest - * - * Revision 1.6 1999/12/06 13:52:45 adam - * Modified for new location of YAZ header files. Experimental threaded - * operation. - * - * Revision 1.5 1999/11/10 10:02:34 adam - * Work on proxy. - * - * Revision 1.4 1999/09/13 12:53:44 adam - * Proxy removes OtherInfo Proxy Address and Session ID. Other - * Otherinfo remains untouched. - * - * Revision 1.3 1999/04/21 12:09:01 adam - * Many improvements. Modified to proxy server to work with "sessions" - * based on cookies. - * - * Revision 1.2 1999/04/20 10:30:05 adam - * Implemented various stuff for client and proxy. Updated calls - * to ODR to reflect new name parameter. - * - * Revision 1.1 1999/04/09 11:46:57 adam - * Added object Yaz_Z_Assoc. Much more functional client. - * + * $Id: yaz-z-assoc.cpp,v 1.22 2001-11-04 22:36:21 adam Exp $ */ #include @@ -89,7 +17,6 @@ int Yaz_Z_Assoc::yaz_init_func() #ifndef WIN32 signal (SIGPIPE, SIG_IGN); #endif - nmem_init(); return 1; } diff --git a/src/yaz-z-query.cpp b/src/yaz-z-query.cpp index 9846d84..c94bd11 100644 --- a/src/yaz-z-query.cpp +++ b/src/yaz-z-query.cpp @@ -1,42 +1,8 @@ /* - * Copyright (c) 1998-2000, Index Data. + * Copyright (c) 1998-2001, Index Data. * See the file LICENSE for details. * - * $Log: yaz-z-query.cpp,v $ - * Revision 1.9 2000-10-11 11:58:17 adam - * Moved header files to include/yaz++. Switched to libtool and automake. - * Configure script creates yaz++-config script. - * - * Revision 1.8 2000/09/08 10:23:42 adam - * Added skeleton of yaz-z-server. - * - * Revision 1.7 2000/05/10 11:36:58 ian - * Added default parameters for refid to request functions. - * Added default parameter for result set name to search and present request. - * Commented out forced logging of PDU contents. - * Added send_deleteResultSetRequest - * - * Revision 1.6 1999/12/06 13:52:45 adam - * Modified for new location of YAZ header files. Experimental threaded - * operation. - * - * Revision 1.5 1999/04/27 07:52:13 adam - * Improved proxy; added query match for result set re-use. - * - * Revision 1.4 1999/04/21 12:09:01 adam - * Many improvements. Modified to proxy server to work with "sessions" - * based on cookies. - * - * Revision 1.3 1999/04/20 10:30:05 adam - * Implemented various stuff for client and proxy. Updated calls - * to ODR to reflect new name parameter. - * - * Revision 1.2 1999/04/09 11:46:57 adam - * Added object Yaz_Z_Assoc. Much more functional client. - * - * Revision 1.1 1999/03/23 14:17:57 adam - * More work on timeout handling. Work on yaz-client. - * + * $Id: yaz-z-query.cpp,v 1.10 2001-11-04 22:36:21 adam Exp $ */ #include diff --git a/src/yaz-z-server-ill.cpp b/src/yaz-z-server-ill.cpp index f7797e4..1751933 100644 --- a/src/yaz-z-server-ill.cpp +++ b/src/yaz-z-server-ill.cpp @@ -2,25 +2,7 @@ * Copyright (c) 2000-2001, Index Data. * See the file LICENSE for details. * - * $Log: yaz-z-server-ill.cpp,v $ - * Revision 1.6 2001-05-03 12:39:39 adam - * Added Update server service. - * - * Revision 1.5 2001/04/25 19:40:18 adam - * Added refernceId handling for other services. - * - * Revision 1.4 2001/04/04 14:02:49 adam - * URSULA / Z-ruth service. - * - * Revision 1.3 2001/04/03 14:37:19 adam - * More work ILL-service. - * - * Revision 1.2 2001/03/29 15:14:26 adam - * Minor updates. - * - * Revision 1.1 2001/03/27 14:47:45 adam - * New server facility scheme. - * + * $Id: yaz-z-server-ill.cpp,v 1.7 2001-11-04 22:36:21 adam Exp $ */ #include diff --git a/src/yaz-z-server-sr.cpp b/src/yaz-z-server-sr.cpp index 9750e16..105f777 100644 --- a/src/yaz-z-server-sr.cpp +++ b/src/yaz-z-server-sr.cpp @@ -2,15 +2,7 @@ * Copyright (c) 2000-2001, Index Data. * See the file LICENSE for details. * - * $Log: yaz-z-server-sr.cpp,v $ - * Revision 1.3 2001-04-25 18:59:30 adam - * Added referenceId handling for server. - * - * Revision 1.2 2001/04/04 14:02:49 adam - * URSULA / Z-ruth service. - * - * Revision 1.1 2001/03/27 15:02:14 adam - * New server facility scheme. + * $Id: yaz-z-server-sr.cpp,v 1.4 2001-11-04 22:36:21 adam Exp $ * */ diff --git a/src/yaz-z-server-update.cpp b/src/yaz-z-server-update.cpp index 8e82e5b..fa7101d 100644 --- a/src/yaz-z-server-update.cpp +++ b/src/yaz-z-server-update.cpp @@ -2,15 +2,7 @@ * Copyright (c) 2000-2001, Index Data. * See the file LICENSE for details. * - * $Log: yaz-z-server-update.cpp,v $ - * Revision 1.2 2001-05-17 14:18:03 adam - * New handler for old version item update for server: - * void update_service0 (Z_ExtendedServicesRequest *req, - * Z_IU0Update *io, Z_ExtendedServicesResponse *res) - * - * Revision 1.1 2001/05/03 12:42:57 adam - * Added update server service. - * + * $Id: yaz-z-server-update.cpp,v 1.3 2001-11-04 22:36:21 adam Exp $ */ #include diff --git a/src/yaz-z-server-ursula.cpp b/src/yaz-z-server-ursula.cpp index 5476c85..882f9fc 100644 --- a/src/yaz-z-server-ursula.cpp +++ b/src/yaz-z-server-ursula.cpp @@ -2,22 +2,7 @@ * Copyright (c) 2001, Index Data. * See the file LICENSE for details. * - * $Log: yaz-z-server-ursula.cpp,v $ - * Revision 1.5 2001-08-13 16:39:12 adam - * PDU_Assoc keeps track of children. Using yaz_log instead of logf. - * - * Revision 1.4 2001/04/25 19:40:18 adam - * Added refernceId handling for other services. - * - * Revision 1.3 2001/04/11 12:33:42 heikki - * Working on ursula things - * - * Revision 1.2 2001/04/05 15:12:24 adam - * WIN32 updates. - * - * Revision 1.1 2001/04/04 14:02:49 adam - * URSULA / Z-ruth service. - * + * $Id: yaz-z-server-ursula.cpp,v 1.6 2001-11-04 22:36:21 adam Exp $ */ #include diff --git a/src/yaz-z-server.cpp b/src/yaz-z-server.cpp index ae7e94a..98e5929 100644 --- a/src/yaz-z-server.cpp +++ b/src/yaz-z-server.cpp @@ -2,45 +2,7 @@ * Copyright (c) 2000-2001, Index Data. * See the file LICENSE for details. * - * $Log: yaz-z-server.cpp,v $ - * Revision 1.12 2001-04-25 19:40:18 adam - * Added refernceId handling for other services. - * - * Revision 1.11 2001/04/12 15:12:10 heikki - * minor ursula stuff - * - * Revision 1.10 2001/04/04 14:02:49 adam - * URSULA / Z-ruth service. - * - * Revision 1.9 2001/03/29 15:14:26 adam - * Minor updates. - * - * Revision 1.8 2001/03/27 14:47:45 adam - * New server facility scheme. - * - * Revision 1.7 2001/03/26 14:43:49 adam - * New threaded PDU association. - * - * Revision 1.6 2001/01/29 11:18:24 adam - * Server sets OPTIONS search and present. - * - * Revision 1.5 2000/10/24 12:29:57 adam - * Fixed bug in proxy where a Yaz_ProxyClient could be owned by - * two Yaz_Proxy's (fatal). - * - * Revision 1.4 2000/10/11 11:58:17 adam - * Moved header files to include/yaz++. Switched to libtool and automake. - * Configure script creates yaz++-config script. - * - * Revision 1.3 2000/09/21 21:43:20 adam - * Better high-level server API. - * - * Revision 1.2 2000/09/12 12:09:53 adam - * More work on high-level server. - * - * Revision 1.1 2000/09/08 10:23:42 adam - * Added skeleton of yaz-z-server. - * + * $Id: yaz-z-server.cpp,v 1.13 2001-11-04 22:36:21 adam Exp $ */ #include @@ -130,7 +92,7 @@ void Yaz_Z_Server::recv_Z_PDU (Z_APDU *apdu_request) } if (!taken) { - yaz_log (LOG_LOG, "unhandled request = %d", apdu_request->which); + yaz_log (LOG_WARN, "unhandled request = %d", apdu_request->which); delete this; } } diff --git a/yaz.m4 b/yaz.m4 index f4e8e6c..a245efc 100644 --- a/yaz.m4 +++ b/yaz.m4 @@ -1,4 +1,4 @@ -## $Id: yaz.m4,v 1.2 2001-03-26 14:43:49 adam Exp $ +## $Id: yaz.m4,v 1.3 2001-11-04 22:36:21 adam Exp $ ## # Use this m4 funciton for autoconf if you use YAZ in your own # configure script. -- 1.7.10.4 From 19db153df3124f15689496768049bb73c3011a69 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 6 Nov 2001 17:08:05 +0000 Subject: [PATCH 03/16] New option -o that optimization level (0 = no optimization). Database names mutch match too before doing result set optimization. --- README.txt | 4 +-- include/yaz++/yaz-proxy.h | 6 +++- include/yaz++/yaz-z-databases.h | 26 ++++++++++++++++ src/Makefile.am | 4 +-- src/yaz-my-server.cpp | 6 +++- src/yaz-pdu-assoc-thread.cpp | 16 +++++++--- src/yaz-pdu-assoc.cpp | 10 +++--- src/yaz-proxy-main.cpp | 9 ++++-- src/yaz-proxy.cpp | 58 ++++++++++++++++++++++------------ src/yaz-z-databases.cpp | 65 +++++++++++++++++++++++++++++++++++++++ 10 files changed, 165 insertions(+), 39 deletions(-) create mode 100644 include/yaz++/yaz-z-databases.h create mode 100644 src/yaz-z-databases.cpp diff --git a/README.txt b/README.txt index e43628c..27fd545 100644 --- a/README.txt +++ b/README.txt @@ -1,6 +1,6 @@ YAZ++ - A C++ library for YAZ -$Id: README.txt,v 1.9 2001-04-25 19:40:18 adam Exp $ +$Id: README.txt,v 1.10 2001-11-06 17:08:05 adam Exp $ o Introduction @@ -18,7 +18,7 @@ example applications: yaz-my-server basic server yaz-proxy not-so-basic proxy server -Directory structure of the YAZ++ package. +Directory structure of the YAZ++ package: -- src (C++ source) -- include/yaz++ (C++ headers) diff --git a/include/yaz++/yaz-proxy.h b/include/yaz++/yaz-proxy.h index e4f3e5e..b0ad495 100644 --- a/include/yaz++/yaz-proxy.h +++ b/include/yaz++/yaz-proxy.h @@ -2,11 +2,12 @@ * Copyright (c) 1998-2000, Index Data. * See the file LICENSE for details. * - * $Id: yaz-proxy.h,v 1.3 2001-03-26 14:43:49 adam Exp $ + * $Id: yaz-proxy.h,v 1.4 2001-11-06 17:08:05 adam Exp $ */ #include #include +#include class Yaz_Proxy; @@ -28,6 +29,7 @@ class YAZ_EXPORT Yaz_ProxyClient : public Yaz_Z_Assoc { Yaz_ProxyClient **m_prev; int m_init_flag; Yaz_Z_Query *m_last_query; + Yaz_Z_Databases m_last_databases; int m_last_resultCount; int m_sr_transform; int m_seqno; @@ -52,6 +54,7 @@ class YAZ_EXPORT Yaz_Proxy : public Yaz_Z_Assoc { int m_keepalive; char *m_proxyTarget; long m_seed; + char *m_optimize; public: Yaz_Proxy(IYaz_PDU_Observable *the_PDU_Observable); ~Yaz_Proxy(); @@ -61,6 +64,7 @@ class YAZ_EXPORT Yaz_Proxy : public Yaz_Z_Assoc { void failNotify(); void timeoutNotify(); void connectNotify(); + const char *option(const char *name, const char *value); void set_proxyTarget(const char *target); char *get_proxyTarget() { return m_proxyTarget; }; void set_max_clients(int m) { m_max_clients = m; }; diff --git a/include/yaz++/yaz-z-databases.h b/include/yaz++/yaz-z-databases.h new file mode 100644 index 0000000..f750c4d --- /dev/null +++ b/include/yaz++/yaz-z-databases.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2001, Index Data. + * See the file LICENSE for details. + * + * $Id: yaz-z-databases.h,v 1.1 2001-11-06 17:08:05 adam Exp $ + */ + +#include + +/** Z39.50 Databases list + */ +class YAZ_EXPORT Yaz_Z_Databases { +public: +/// Make Query from rpn string + Yaz_Z_Databases(); + ~Yaz_Z_Databases(); + void set (int num, const char **db); + void get (NMEM n, int *num, char ***db); + void get (ODR o, int *num, char ***db); + int match (Yaz_Z_Databases &db); + int match (int num, const char **db); + private: + char **m_list; + int m_num; + NMEM nmem; +}; diff --git a/src/Makefile.am b/src/Makefile.am index 07bc103..bccdfab 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,4 @@ -## $Id: Makefile.am,v 1.8 2001-11-04 22:36:21 adam Exp $ +## $Id: Makefile.am,v 1.9 2001-11-06 17:08:05 adam Exp $ CXXFLAGS = $(YAZINC) -I$(srcdir)/../include @@ -7,7 +7,7 @@ lib_LTLIBRARIES = libyaz++.la libyaz___la_SOURCES=yaz-socket-manager.cpp yaz-pdu-assoc.cpp \ yaz-z-assoc.cpp yaz-proxy.cpp yaz-z-query.cpp yaz-ir-assoc.cpp \ yaz-z-server.cpp yaz-pdu-assoc-thread.cpp yaz-z-server-sr.cpp \ - yaz-z-server-ill.cpp yaz-z-server-update.cpp + yaz-z-server-ill.cpp yaz-z-server-update.cpp yaz-z-databases.cpp EXTRA_DIST=yaz-z-server-ursula.cpp diff --git a/src/yaz-my-server.cpp b/src/yaz-my-server.cpp index 6f6a490..38a3bc7 100644 --- a/src/yaz-my-server.cpp +++ b/src/yaz-my-server.cpp @@ -2,7 +2,7 @@ * Copyright (c) 1998-2001, Index Data. * See the file LICENSE for details. * - * $Id: yaz-my-server.cpp,v 1.8 2001-11-04 22:36:21 adam Exp $ + * $Id: yaz-my-server.cpp,v 1.9 2001-11-06 17:08:05 adam Exp $ */ #include @@ -258,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); diff --git a/src/yaz-pdu-assoc-thread.cpp b/src/yaz-pdu-assoc-thread.cpp index 4a445fd..aadcca1 100644 --- a/src/yaz-pdu-assoc-thread.cpp +++ b/src/yaz-pdu-assoc-thread.cpp @@ -2,17 +2,26 @@ * Copyright (c) 1998-2001, Index Data. * See the file LICENSE for details. * - * $Id: yaz-pdu-assoc-thread.cpp,v 1.4 2001-11-04 22:36:21 adam Exp $ + * $Id: yaz-pdu-assoc-thread.cpp,v 1.5 2001-11-06 17:08:05 adam Exp $ */ #ifdef WIN32 +#define USE_THREADS 1 +#endif + +#if YAZ_POSIX_THREADS +#define USE_THREADS 1 +#endif + +#if USE_THREADS + +#ifdef WIN32 #include #else #include #include #endif - #include #include #include @@ -20,8 +29,6 @@ #include #include - - Yaz_PDU_AssocThread::Yaz_PDU_AssocThread( IYazSocketObservable *socketObservable) : Yaz_PDU_Assoc(socketObservable) @@ -78,3 +85,4 @@ void Yaz_PDU_AssocThread::childNotify(COMSTACK cs) pthread_detach (tid); #endif } +#endif diff --git a/src/yaz-pdu-assoc.cpp b/src/yaz-pdu-assoc.cpp index 0ed6f29..0238d0c 100644 --- a/src/yaz-pdu-assoc.cpp +++ b/src/yaz-pdu-assoc.cpp @@ -2,7 +2,7 @@ * Copyright (c) 1998-2001, Index Data. * See the file LICENSE for details. * - * $Id: yaz-pdu-assoc.cpp,v 1.25 2001-11-04 22:36:21 adam Exp $ + * $Id: yaz-pdu-assoc.cpp,v 1.26 2001-11-06 17:08:05 adam Exp $ */ #include @@ -286,7 +286,7 @@ void Yaz_PDU_Assoc::destroy() Yaz_PDU_Assoc::PDU_Queue::PDU_Queue(const char *buf, int len) { - m_buf = (char *) malloc (len); + m_buf = (char *) xmalloc (len); memcpy (m_buf, buf, len); m_len = len; m_next = 0; @@ -294,7 +294,7 @@ Yaz_PDU_Assoc::PDU_Queue::PDU_Queue(const char *buf, int len) Yaz_PDU_Assoc::PDU_Queue::~PDU_Queue() { - free (m_buf); + xfree (m_buf); } int Yaz_PDU_Assoc::flush_PDU() @@ -420,7 +420,7 @@ void Yaz_PDU_Assoc::connect(IYaz_PDU_Observer *observer, m_socketObservable->addObserver(cs_fileno(m_cs), this); if (res >= 0) - { // Connect pending or complet + { // Connect pending or complete m_state = Connecting; unsigned mask = YAZ_SOCKET_OBSERVE_EXCEPT; if (m_cs->io_pending & CS_WANT_WRITE) @@ -441,8 +441,6 @@ void Yaz_PDU_Assoc::connect(IYaz_PDU_Observer *observer, // Single-threaded... Only useful for non-blocking handlers void Yaz_PDU_Assoc::childNotify(COMSTACK cs) { - - Yaz_PDU_Assoc *new_observable = new Yaz_PDU_Assoc (m_socketObservable, cs); diff --git a/src/yaz-proxy-main.cpp b/src/yaz-proxy-main.cpp index 0487363..ef8214e 100644 --- a/src/yaz-proxy-main.cpp +++ b/src/yaz-proxy-main.cpp @@ -2,7 +2,7 @@ * Copyright (c) 1998-2001, Index Data. * See the file LICENSE for details. * - * $Id: yaz-proxy-main.cpp,v 1.14 2001-11-04 22:36:21 adam Exp $ + * $Id: yaz-proxy-main.cpp,v 1.15 2001-11-06 17:08:05 adam Exp $ */ #include @@ -14,7 +14,7 @@ void usage(char *prog) { - fprintf (stderr, "%s: [-a log] [-c num] [-v level] [-t target] @:port\n", prog); + fprintf (stderr, "%s: [-a log] [-c num] [-v level] [-t target] [-o optlevel] @:port\n", prog); exit (1); } @@ -26,7 +26,7 @@ int args(Yaz_Proxy *proxy, int argc, char **argv) char *prog = argv[0]; int ret; - while ((ret = options("a:t:v:c:", argv, argc, &arg)) != -2) + while ((ret = options("o:a:t:v:c:", argv, argc, &arg)) != -2) { switch (ret) { @@ -44,6 +44,9 @@ int args(Yaz_Proxy *proxy, int argc, char **argv) case 't': proxy->set_proxyTarget(arg); break; + case 'o': + proxy->option("optimize", arg); + break; case 'v': yaz_log_init_level (yaz_log_mask_str(arg)); break; diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index a73c95a..384fde6 100644 --- a/src/yaz-proxy.cpp +++ b/src/yaz-proxy.cpp @@ -2,7 +2,7 @@ * Copyright (c) 1998-2001, Index Data. * See the file LICENSE for details. * - * $Id: yaz-proxy.cpp,v 1.28 2001-11-04 22:36:21 adam Exp $ + * $Id: yaz-proxy.cpp,v 1.29 2001-11-06 17:08:05 adam Exp $ */ #include @@ -23,11 +23,13 @@ Yaz_Proxy::Yaz_Proxy(IYaz_PDU_Observable *the_PDU_Observable) : m_proxyTarget = 0; m_max_clients = 50; m_seed = time(0); + m_optimize = xstrdup ("1"); } Yaz_Proxy::~Yaz_Proxy() { xfree (m_proxyTarget); + xfree (m_optimize); } void Yaz_Proxy::set_proxyTarget(const char *target) @@ -90,34 +92,28 @@ Yaz_ProxyClient *Yaz_Proxy::get_client(Z_APDU *apdu) get_otherInfoAPDU(apdu, &oi); char *cookie = get_cookie(oi); - yaz_log (LOG_LOG, "Yaz_Proxy::get_client cookie=%s", cookie ? cookie : - "null"); const char *proxy_host = get_proxy(oi); if (proxy_host) set_proxyTarget(proxy_host); - yaz_log (LOG_LOG, "proxy_host = %s", m_proxyTarget ? m_proxyTarget:"none"); // no target specified at all? if (!m_proxyTarget) return 0; + if (!strcmp(m_proxyTarget, "stop")) + exit (0); if (cookie && *cookie) { - yaz_log (LOG_LOG, "lookup of clients cookie=%s target=%s", - cookie, m_proxyTarget); Yaz_ProxyClient *cc = 0; for (c = parent->m_clientPool; c; c = c->m_next) { - yaz_log (LOG_LOG, " found client cookie = %s target=%s seqno=%d", - c->m_cookie, c->get_hostname(), c->m_seqno); assert (c->m_prev); assert (*c->m_prev == c); if (!strcmp(cookie,c->m_cookie) && !strcmp(m_proxyTarget, c->get_hostname())) { - yaz_log (LOG_LOG, "found!"); cc = c; } } @@ -148,7 +144,7 @@ Yaz_ProxyClient *Yaz_Proxy::get_client(Z_APDU *apdu) c->m_server = this; c->m_seqno = parent->m_seqno; (parent->m_seqno)++; - yaz_log (LOG_LOG, "get_client 1 %p %p", this, c); + yaz_log (LOG_DEBUG, "get_client 1 %p %p", this, c); return c; } } @@ -201,7 +197,7 @@ Yaz_ProxyClient *Yaz_Proxy::get_client(Z_APDU *apdu) delete c->m_server; } (parent->m_seqno)++; - yaz_log (LOG_LOG, "get_client 2 %p %p", this, c); + yaz_log (LOG_DEBUG, "get_client 2 %p %p", this, c); return c; } } @@ -235,7 +231,7 @@ Yaz_ProxyClient *Yaz_Proxy::get_client(Z_APDU *apdu) (parent->m_seqno)++; } - yaz_log (LOG_LOG, "get_client 3 %p %p", this, c); + yaz_log (LOG_DEBUG, "get_client 3 %p %p", this, c); return c; } @@ -243,13 +239,20 @@ Z_APDU *Yaz_Proxy::result_set_optimize(Z_APDU *apdu) { if (apdu->which != Z_APDU_searchRequest) return apdu; + if (*m_parent->m_optimize != '1') + return apdu; Z_SearchRequest *sr = apdu->u.searchRequest; Yaz_Z_Query *this_query = new Yaz_Z_Query; + Yaz_Z_Databases this_databases; + + this_databases.set(sr->num_databaseNames, (const char **) + sr->databaseNames); this_query->set_Z_Query(sr->query); if (m_client->m_last_query && - m_client->m_last_query->match(this_query)) + m_client->m_last_query->match(this_query) && + m_client->m_last_databases.match(this_databases)) { delete this_query; if (m_client->m_last_resultCount > *sr->smallSetUpperBound && @@ -311,6 +314,8 @@ Z_APDU *Yaz_Proxy::result_set_optimize(Z_APDU *apdu) yaz_log (LOG_LOG, "Yaz_Proxy::result_set_optimize new set"); delete m_client->m_last_query; m_client->m_last_query = this_query; + m_client->m_last_databases.set(sr->num_databaseNames, + (const char **) sr->databaseNames); } return apdu; } @@ -369,29 +374,31 @@ void Yaz_Proxy::connectNotify() void Yaz_Proxy::shutdown() { - yaz_log (LOG_LOG, "shutdown (client to proxy)"); // only keep if keep_alive flag and cookie is set... if (m_keepalive && m_client && m_client->m_cookie[0]) { - yaz_log (LOG_LOG, "shutdown - keepalive this=%p, m_server=%p", - this, m_client->m_server); if (m_client->m_waiting == 2) abort(); // Tell client (if any) that no server connection is there.. m_client->m_server = 0; + yaz_log (LOG_LOG, "shutdown (client to proxy) keepalive %s", m_client->get_hostname()); } else if (m_client) { - yaz_log (LOG_LOG, "deleting %p %p", this, m_client); if (m_client->m_waiting == 2) abort(); + yaz_log (LOG_LOG, "shutdown (client to proxy) close %s", m_client->get_hostname()); delete m_client; } else if (!m_parent) { - yaz_log (LOG_LOG, "abort %p", this); + yaz_log (LOG_LOG, "shutdown (client to proxy) bad state"); abort(); } + else + { + yaz_log (LOG_LOG, "shutdown (client to proxy)"); + } delete this; } @@ -404,7 +411,7 @@ void Yaz_ProxyClient::shutdown() void Yaz_Proxy::failNotify() { - yaz_log (LOG_LOG, "connection closed by client"); + yaz_log (LOG_LOG, "Yaz_Proxy connection closed by client"); shutdown(); } @@ -462,6 +469,17 @@ Yaz_ProxyClient::Yaz_ProxyClient(IYaz_PDU_Observable *the_PDU_Observable) : m_waiting = 0; } +const char *Yaz_Proxy::option(const char *name, const char *value) +{ + if (!strcmp (name, "optimize")) { + if (value) { + xfree (m_optimize); + m_optimize = xstrdup (value); + } + return m_optimize; + } +} + void Yaz_ProxyClient::recv_Z_PDU(Z_APDU *apdu) { m_waiting = 0; @@ -491,7 +509,7 @@ void Yaz_ProxyClient::recv_Z_PDU(Z_APDU *apdu) sr->numberOfRecordsReturned = pr->numberOfRecordsReturned; apdu = new_apdu; } - if (m_cookie) + if (m_cookie && *m_cookie) set_otherInformationString (apdu, VAL_COOKIE, 1, m_cookie); if (m_server) { diff --git a/src/yaz-z-databases.cpp b/src/yaz-z-databases.cpp new file mode 100644 index 0000000..362bd5a --- /dev/null +++ b/src/yaz-z-databases.cpp @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2001, Index Data. + * See the file LICENSE for details. + * + * $Id: yaz-z-databases.cpp,v 1.1 2001-11-06 17:08:05 adam Exp $ + */ + +#include + +#include + +Yaz_Z_Databases::Yaz_Z_Databases() +{ + nmem = nmem_create (); + m_num = 0; + m_list = 0; +} + +Yaz_Z_Databases::~Yaz_Z_Databases() +{ + nmem_destroy (nmem); +} + +void Yaz_Z_Databases::set (int num, const char **db) +{ + nmem_reset (nmem); + + m_list = (char **) nmem_malloc (nmem, num * sizeof(char*)); + m_num = num; + for (int i = 0; imem, num, db); +} + +int Yaz_Z_Databases::match (Yaz_Z_Databases &db) +{ + if (db.m_num != m_num) + return 0; + for (int i = 0; i Date: Tue, 6 Nov 2001 20:33:32 +0000 Subject: [PATCH 04/16] WIN32 update. --- src/yaz-proxy.cpp | 3 ++- src/yaz-z-databases.cpp | 4 ++-- win/yazxx/yazxx.dsp | 8 ++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index 384fde6..f7a8353 100644 --- a/src/yaz-proxy.cpp +++ b/src/yaz-proxy.cpp @@ -2,7 +2,7 @@ * Copyright (c) 1998-2001, Index Data. * See the file LICENSE for details. * - * $Id: yaz-proxy.cpp,v 1.29 2001-11-06 17:08:05 adam Exp $ + * $Id: yaz-proxy.cpp,v 1.30 2001-11-06 20:33:32 adam Exp $ */ #include @@ -478,6 +478,7 @@ const char *Yaz_Proxy::option(const char *name, const char *value) } return m_optimize; } + return 0; } void Yaz_ProxyClient::recv_Z_PDU(Z_APDU *apdu) diff --git a/src/yaz-z-databases.cpp b/src/yaz-z-databases.cpp index 362bd5a..a16bc4d 100644 --- a/src/yaz-z-databases.cpp +++ b/src/yaz-z-databases.cpp @@ -2,7 +2,7 @@ * Copyright (c) 2001, Index Data. * See the file LICENSE for details. * - * $Id: yaz-z-databases.cpp,v 1.1 2001-11-06 17:08:05 adam Exp $ + * $Id: yaz-z-databases.cpp,v 1.2 2001-11-06 20:33:32 adam Exp $ */ #include @@ -41,7 +41,7 @@ void Yaz_Z_Databases::get (NMEM n, int *num, char ***db) void Yaz_Z_Databases::get (ODR o, int *num, char ***db) { - return get (o->mem, num, db); + get (o->mem, num, db); } int Yaz_Z_Databases::match (Yaz_Z_Databases &db) diff --git a/win/yazxx/yazxx.dsp b/win/yazxx/yazxx.dsp index 0755d89..89e1ae6 100644 --- a/win/yazxx/yazxx.dsp +++ b/win/yazxx/yazxx.dsp @@ -225,6 +225,14 @@ SOURCE="..\..\include\yaz++\yaz-z-assoc.h" # End Source File # Begin Source File +SOURCE="..\..\src\yaz-z-databases.cpp" +# End Source File +# Begin Source File + +SOURCE="..\..\include\yaz++\yaz-z-databases.h" +# End Source File +# Begin Source File + SOURCE="..\..\src\yaz-z-query.cpp" # End Source File # Begin Source File -- 1.7.10.4 From 413fa20e2396875645fa715539bb13b5efa6217b Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 12 Nov 2001 14:33:09 +0000 Subject: [PATCH 05/16] Added yaz-z-databases.h to include. --- include/yaz++/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/yaz++/Makefile.am b/include/yaz++/Makefile.am index 897794b..01d4cb4 100644 --- a/include/yaz++/Makefile.am +++ b/include/yaz++/Makefile.am @@ -2,4 +2,4 @@ pkginclude_HEADERS = yaz-ir-assoc.h yaz-pdu-assoc.h \ yaz-pdu-observer.h yaz-proxy.h yaz-query.h \ yaz-socket-manager.h yaz-socket-observer.h yaz-z-assoc.h \ - yaz-z-query.h yaz-z-server.h + yaz-z-query.h yaz-z-server.h yaz-z-databases.h -- 1.7.10.4 From 94881bc56aff2b24ead75ac5f9e14128570cf311 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 21 Dec 2001 10:50:22 +0000 Subject: [PATCH 06/16] Fixed bug where timeout could be set to a negative value. --- src/yaz-socket-manager.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/yaz-socket-manager.cpp b/src/yaz-socket-manager.cpp index 5f0f7df..1eb8c5c 100644 --- a/src/yaz-socket-manager.cpp +++ b/src/yaz-socket-manager.cpp @@ -2,7 +2,7 @@ * Copyright (c) 1998-2001, Index Data. * See the file LICENSE for details. * - * $Id: yaz-socket-manager.cpp,v 1.17 2001-11-04 22:36:21 adam Exp $ + * $Id: yaz-socket-manager.cpp,v 1.18 2001-12-21 10:50:22 adam Exp $ */ #include #ifdef WIN32 @@ -144,7 +144,7 @@ int Yaz_SocketManager::processEvent() timeout_this -= now - p->last_activity; else p->last_activity = now; - if (timeout_this < 1) + if (timeout_this < 1 || timeout_this > 2147483646) timeout_this = 1; if (!timeout || timeout_this < timeout) timeout = timeout_this; @@ -169,7 +169,10 @@ int Yaz_SocketManager::processEvent() no, timeout); while ((res = select(max + 1, &in, &out, &except, timeout ? &to : 0)) < 0) if (errno != EINTR) + { + yaz_log (LOG_LOG|LOG_WARN, "select"); return -1; + } now = time(0); for (p = m_observers; p; p = p->next) { -- 1.7.10.4 From f45771ec3032b3ef67ec4c275da242e3c647b53e Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 14 Jan 2002 12:01:27 +0000 Subject: [PATCH 07/16] Fix: proxy doesn't cache searches/result sets when errors occur. New option -u that sets authentication info. --- include/yaz++/yaz-proxy.h | 9 ++++--- src/yaz-proxy-main.cpp | 12 ++++++--- src/yaz-proxy.cpp | 65 +++++++++++++++++++++++++++++++-------------- 3 files changed, 59 insertions(+), 27 deletions(-) diff --git a/include/yaz++/yaz-proxy.h b/include/yaz++/yaz-proxy.h index b0ad495..f05f2fe 100644 --- a/include/yaz++/yaz-proxy.h +++ b/include/yaz++/yaz-proxy.h @@ -2,7 +2,7 @@ * Copyright (c) 1998-2000, Index Data. * See the file LICENSE for details. * - * $Id: yaz-proxy.h,v 1.4 2001-11-06 17:08:05 adam Exp $ + * $Id: yaz-proxy.h,v 1.5 2002-01-14 12:01:27 adam Exp $ */ #include @@ -30,6 +30,7 @@ class YAZ_EXPORT Yaz_ProxyClient : public Yaz_Z_Assoc { int m_init_flag; Yaz_Z_Query *m_last_query; Yaz_Z_Databases m_last_databases; + int m_last_ok; int m_last_resultCount; int m_sr_transform; int m_seqno; @@ -53,6 +54,7 @@ class YAZ_EXPORT Yaz_Proxy : public Yaz_Z_Assoc { int m_max_clients; int m_keepalive; char *m_proxyTarget; + char *m_proxy_authentication; long m_seed; char *m_optimize; public: @@ -65,8 +67,9 @@ class YAZ_EXPORT Yaz_Proxy : public Yaz_Z_Assoc { void timeoutNotify(); void connectNotify(); const char *option(const char *name, const char *value); - void set_proxyTarget(const char *target); - char *get_proxyTarget() { return m_proxyTarget; }; + void set_proxy_target(const char *target); + void set_proxy_authentication (const char *auth); + char *get_proxy_target() { return m_proxyTarget; }; void set_max_clients(int m) { m_max_clients = m; }; }; diff --git a/src/yaz-proxy-main.cpp b/src/yaz-proxy-main.cpp index ef8214e..1a23020 100644 --- a/src/yaz-proxy-main.cpp +++ b/src/yaz-proxy-main.cpp @@ -2,7 +2,7 @@ * Copyright (c) 1998-2001, Index Data. * See the file LICENSE for details. * - * $Id: yaz-proxy-main.cpp,v 1.15 2001-11-06 17:08:05 adam Exp $ + * $Id: yaz-proxy-main.cpp,v 1.16 2002-01-14 12:01:28 adam Exp $ */ #include @@ -14,7 +14,8 @@ void usage(char *prog) { - fprintf (stderr, "%s: [-a log] [-c num] [-v level] [-t target] [-o optlevel] @:port\n", prog); + fprintf (stderr, "%s: [-a log] [-c num] [-v level] [-t target] " + "[-u auth] [-o optlevel] @:port\n", prog); exit (1); } @@ -26,7 +27,7 @@ int args(Yaz_Proxy *proxy, int argc, char **argv) char *prog = argv[0]; int ret; - while ((ret = options("o:a:t:v:c:", argv, argc, &arg)) != -2) + while ((ret = options("o:a:t:v:c:u:", argv, argc, &arg)) != -2) { switch (ret) { @@ -42,8 +43,11 @@ int args(Yaz_Proxy *proxy, int argc, char **argv) proxy->set_APDU_log(arg); break; case 't': - proxy->set_proxyTarget(arg); + proxy->set_proxy_target(arg); break; + case 'u': + proxy->set_proxy_authentication(arg); + break; case 'o': proxy->option("optimize", arg); break; diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index f7a8353..3a6bb9e 100644 --- a/src/yaz-proxy.cpp +++ b/src/yaz-proxy.cpp @@ -2,7 +2,7 @@ * Copyright (c) 1998-2001, Index Data. * See the file LICENSE for details. * - * $Id: yaz-proxy.cpp,v 1.30 2001-11-06 20:33:32 adam Exp $ + * $Id: yaz-proxy.cpp,v 1.31 2002-01-14 12:01:28 adam Exp $ */ #include @@ -21,6 +21,7 @@ Yaz_Proxy::Yaz_Proxy(IYaz_PDU_Observable *the_PDU_Observable) : m_seqno = 1; m_keepalive = 1; m_proxyTarget = 0; + m_proxy_authentication = 0; m_max_clients = 50; m_seed = time(0); m_optimize = xstrdup ("1"); @@ -29,10 +30,11 @@ Yaz_Proxy::Yaz_Proxy(IYaz_PDU_Observable *the_PDU_Observable) : Yaz_Proxy::~Yaz_Proxy() { xfree (m_proxyTarget); + xfree (m_proxy_authentication); xfree (m_optimize); } -void Yaz_Proxy::set_proxyTarget(const char *target) +void Yaz_Proxy::set_proxy_target(const char *target) { xfree (m_proxyTarget); m_proxyTarget = 0; @@ -40,14 +42,23 @@ void Yaz_Proxy::set_proxyTarget(const char *target) m_proxyTarget = (char *) xstrdup (target); } +void Yaz_Proxy::set_proxy_authentication (const char *auth) +{ + xfree (m_proxy_authentication); + m_proxy_authentication = 0; + if (auth) + m_proxy_authentication = (char *) xstrdup (auth); +} + IYaz_PDU_Observer *Yaz_Proxy::sessionNotify(IYaz_PDU_Observable *the_PDU_Observable, int fd) { Yaz_Proxy *new_proxy = new Yaz_Proxy(the_PDU_Observable); new_proxy->m_parent = this; new_proxy->timeout(500); - new_proxy->set_proxyTarget(m_proxyTarget); + new_proxy->set_proxy_target(m_proxyTarget); new_proxy->set_APDU_log(get_APDU_log()); + new_proxy->set_proxy_authentication(m_proxy_authentication); return new_proxy; } @@ -95,7 +106,7 @@ Yaz_ProxyClient *Yaz_Proxy::get_client(Z_APDU *apdu) const char *proxy_host = get_proxy(oi); if (proxy_host) - set_proxyTarget(proxy_host); + set_proxy_target(proxy_host); // no target specified at all? if (!m_proxyTarget) @@ -130,9 +141,8 @@ Yaz_ProxyClient *Yaz_Proxy::get_client(Z_APDU *apdu) c->close(); c->client(m_proxyTarget); c->m_init_flag = 0; - - delete c->m_last_query; - c->m_last_query = 0; + + c->m_last_ok = 0; c->m_last_resultCount = 0; c->m_sr_transform = 0; c->m_waiting = 0; @@ -156,7 +166,23 @@ Yaz_ProxyClient *Yaz_Proxy::get_client(Z_APDU *apdu) return 0; } yaz_log (LOG_LOG, "got InitRequest"); - + Z_InitRequest *initRequest = apdu->u.initRequest; + + if (!initRequest->idAuthentication) + { + if (m_proxy_authentication) + { + initRequest->idAuthentication = + (Z_IdAuthentication *) + odr_malloc (odr_encode(), + sizeof(*initRequest->idAuthentication)); + initRequest->idAuthentication->which = + Z_IdAuthentication_open; + initRequest->idAuthentication->u.open = + odr_strdup (odr_encode(), m_proxy_authentication); + } + } + // go through list of clients - and find the lowest/oldest one. Yaz_ProxyClient *c_min = 0; int min_seq = -1; @@ -221,10 +247,8 @@ Yaz_ProxyClient *Yaz_Proxy::get_client(Z_APDU *apdu) c->m_seqno = parent->m_seqno; c->client(m_proxyTarget); c->m_init_flag = 0; - - delete c->m_last_query; - c->m_last_query = 0; c->m_last_resultCount = 0; + c->m_last_ok = 0; c->m_sr_transform = 0; c->m_waiting = 0; c->timeout(10); @@ -250,7 +274,7 @@ Z_APDU *Yaz_Proxy::result_set_optimize(Z_APDU *apdu) this_query->set_Z_Query(sr->query); - if (m_client->m_last_query && + if (m_client->m_last_ok && m_client->m_last_query && m_client->m_last_query->match(this_query) && m_client->m_last_databases.match(this_databases)) { @@ -259,6 +283,7 @@ Z_APDU *Yaz_Proxy::result_set_optimize(Z_APDU *apdu) m_client->m_last_resultCount < *sr->largeSetLowerBound) { // medium Set + // send present request (medium size) yaz_log (LOG_LOG, "Yaz_Proxy::result_set_optimize medium set"); Z_APDU *new_apdu = create_Z_PDU(Z_APDU_presentRequest); Z_PresentRequest *pr = new_apdu->u.presentRequest; @@ -279,7 +304,7 @@ Z_APDU *Yaz_Proxy::result_set_optimize(Z_APDU *apdu) else if (m_client->m_last_resultCount >= *sr->largeSetLowerBound || m_client->m_last_resultCount == 0) { - // large set + // large set. Return pseudo-search response immediately yaz_log (LOG_LOG, "Yaz_Proxy::result_set_optimize large set"); Z_APDU *new_apdu = create_Z_PDU(Z_APDU_searchResponse); new_apdu->u.searchResponse->referenceId = sr->referenceId; @@ -291,6 +316,7 @@ Z_APDU *Yaz_Proxy::result_set_optimize(Z_APDU *apdu) else { // small set + // send a present request (small set) yaz_log (LOG_LOG, "Yaz_Proxy::result_set_optimize small set"); Z_APDU *new_apdu = create_Z_PDU(Z_APDU_presentRequest); Z_PresentRequest *pr = new_apdu->u.presentRequest; @@ -314,6 +340,7 @@ Z_APDU *Yaz_Proxy::result_set_optimize(Z_APDU *apdu) yaz_log (LOG_LOG, "Yaz_Proxy::result_set_optimize new set"); delete m_client->m_last_query; m_client->m_last_query = this_query; + m_client->m_last_ok = 0; m_client->m_last_databases.set(sr->num_databaseNames, (const char **) sr->databaseNames); } @@ -465,6 +492,7 @@ Yaz_ProxyClient::Yaz_ProxyClient(IYaz_PDU_Observable *the_PDU_Observable) : m_init_flag = 0; m_last_query = 0; m_last_resultCount = 0; + m_last_ok = 0; m_sr_transform = 0; m_waiting = 0; } @@ -489,13 +517,10 @@ void Yaz_ProxyClient::recv_Z_PDU(Z_APDU *apdu) { m_last_resultCount = *apdu->u.searchResponse->resultCount; int status = *apdu->u.searchResponse->searchStatus; - if (! status || ( - apdu->u.searchResponse->records && - apdu->u.searchResponse->records->which != Z_Records_DBOSD)) - { - delete m_last_query; - m_last_query = 0; - } + if (status && + (!apdu->u.searchResponse->records || + apdu->u.searchResponse->records->which == Z_Records_DBOSD)) + m_last_ok = 1; } if (apdu->which == Z_APDU_presentResponse && m_sr_transform) { -- 1.7.10.4 From 9ced9af24735149c7d67ec79044428ba3adec7a9 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 21 Jan 2002 21:51:06 +0000 Subject: [PATCH 08/16] Using cs_rcvconnect instead of cs_connect to complete connect. --- src/yaz-pdu-assoc.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/yaz-pdu-assoc.cpp b/src/yaz-pdu-assoc.cpp index 0238d0c..d571844 100644 --- a/src/yaz-pdu-assoc.cpp +++ b/src/yaz-pdu-assoc.cpp @@ -2,7 +2,7 @@ * Copyright (c) 1998-2001, Index Data. * See the file LICENSE for details. * - * $Id: yaz-pdu-assoc.cpp,v 1.26 2001-11-06 17:08:05 adam Exp $ + * $Id: yaz-pdu-assoc.cpp,v 1.27 2002-01-21 21:51:06 adam Exp $ */ #include @@ -124,8 +124,8 @@ void Yaz_PDU_Assoc::socketNotify(int event) } else { - yaz_log (m_log, "cs_connect again"); - int res = cs_connect (m_cs, 0); + yaz_log (m_log, "cs_rcvconnect"); + int res = cs_rcvconnect (m_cs); if (res == 1) { unsigned mask = YAZ_SOCKET_OBSERVE_EXCEPT; -- 1.7.10.4 From 8a1224da4d5c0d6bde27b39d1ec0f9b6ffa6aea0 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 15 Apr 2002 09:43:30 +0000 Subject: [PATCH 09/16] Using AM_CXXFLAGS instead of CXXFLAGS --- buildconf.sh | 10 +++++----- src/Makefile.am | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/buildconf.sh b/buildconf.sh index 071751e..02252f6 100755 --- a/buildconf.sh +++ b/buildconf.sh @@ -1,13 +1,13 @@ #!/bin/sh -# $Id: buildconf.sh,v 1.6 2001-03-26 14:43:49 adam Exp $ +# $Id: buildconf.sh,v 1.7 2002-04-15 09:43:30 adam Exp $ dir=`aclocal --print-ac-dir` if [ -f $dir/yaz.m4 ]; then - aclocal || exit 1 + aclocal else - aclocal -I . || exit 1 + aclocal -I . fi -libtoolize --force >/dev/null 2>&1 || exit 2 -automake -a >/dev/null 2>&1 || exit 3 +libtoolize --force +automake -a autoconf || exit 4 if [ -f config.cache ]; then rm config.cache diff --git a/src/Makefile.am b/src/Makefile.am index bccdfab..459e973 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ -## $Id: Makefile.am,v 1.9 2001-11-06 17:08:05 adam Exp $ +## $Id: Makefile.am,v 1.10 2002-04-15 09:43:30 adam Exp $ -CXXFLAGS = $(YAZINC) -I$(srcdir)/../include +AM_CXXFLAGS = $(YAZINC) -I$(srcdir)/../include lib_LTLIBRARIES = libyaz++.la -- 1.7.10.4 From 18e58bebefe391a91ffac537ad589deb2baea89c Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 22 Apr 2002 12:08:07 +0000 Subject: [PATCH 10/16] Encoding failed print in APDU log --- src/yaz-z-assoc.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/yaz-z-assoc.cpp b/src/yaz-z-assoc.cpp index 052c059..e3389d3 100644 --- a/src/yaz-z-assoc.cpp +++ b/src/yaz-z-assoc.cpp @@ -2,7 +2,7 @@ * Copyright (c) 1998-2001, Index Data. * See the file LICENSE for details. * - * $Id: yaz-z-assoc.cpp,v 1.22 2001-11-04 22:36:21 adam Exp $ + * $Id: yaz-z-assoc.cpp,v 1.23 2002-04-22 12:08:07 adam Exp $ */ #include @@ -208,6 +208,8 @@ int Yaz_Z_Assoc::encode_Z_PDU(Z_APDU *apdu, char **buf, int *len) z_APDU(m_odr_print, &apdu, 0, "encode"); if (!z_APDU(m_odr_out, &apdu, 0, 0)) { + if (m_APDU_file) + fprintf (m_APDU_file, "PDU encode failed (above)"); yaz_log (LOG_LOG, "yaz_Z_Assoc::encode_Z_PDU failed"); return -1; } -- 1.7.10.4 From b93c75bec555a4b1bd2428a3af826d154b7a47f7 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 24 Apr 2002 12:21:03 +0000 Subject: [PATCH 11/16] New utility create_diagnostics --- include/yaz++/yaz-z-server.h | 6 +++++- src/yaz-z-server.cpp | 43 ++++++++++++++++++++++++++---------------- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/include/yaz++/yaz-z-server.h b/include/yaz++/yaz-z-server.h index 4d4fb99..f91970c 100644 --- a/include/yaz++/yaz-z-server.h +++ b/include/yaz++/yaz-z-server.h @@ -2,7 +2,7 @@ * Copyright (c) 2000-2001, Index Data. * See the file LICENSE for details. * - * $Id: yaz-z-server.h,v 1.10 2001-05-17 14:18:03 adam Exp $ + * $Id: yaz-z-server.h,v 1.11 2002-04-24 12:21:03 adam Exp $ */ #include @@ -23,6 +23,10 @@ class YAZ_EXPORT Yaz_Z_ServerUtility { Z_Records *create_nonSurrogateDiagnostics (ODR odr, int error, const char *addinfo); + + void Yaz_Z_ServerUtility::create_diagnostics ( + ODR odr, int error, const char *addinfo, + Z_DiagRec ***dreca, int *num); }; class YAZ_EXPORT IYaz_Server_Facility { diff --git a/src/yaz-z-server.cpp b/src/yaz-z-server.cpp index 98e5929..0af5836 100644 --- a/src/yaz-z-server.cpp +++ b/src/yaz-z-server.cpp @@ -2,7 +2,7 @@ * Copyright (c) 2000-2001, Index Data. * See the file LICENSE for details. * - * $Id: yaz-z-server.cpp,v 1.13 2001-11-04 22:36:21 adam Exp $ + * $Id: yaz-z-server.cpp,v 1.14 2002-04-24 12:21:03 adam Exp $ */ #include @@ -118,17 +118,11 @@ void Yaz_Z_ServerUtility::create_surrogateDiagnostics( ODR odr, Z_NamePlusRecord *rec, const char *dbname, int error, char *const addinfo) { - int oid[OID_SIZE]; int *err = (int *)odr_malloc (odr, sizeof(*err)); - oident bib1; Z_DiagRec *drec = (Z_DiagRec *)odr_malloc (odr, sizeof(*drec)); Z_DefaultDiagFormat *dr = (Z_DefaultDiagFormat *) odr_malloc (odr, sizeof(*dr)); - bib1.proto = PROTO_Z3950; - bib1.oclass = CLASS_DIAGSET; - bib1.value = VAL_BIB1; - yaz_log(LOG_DEBUG, "SurrogateDiagnotic: %d -- %s", error, addinfo); *err = error; rec->databaseName = dbname ? odr_strdup (odr, dbname) : 0; @@ -136,8 +130,9 @@ void Yaz_Z_ServerUtility::create_surrogateDiagnostics( rec->u.surrogateDiagnostic = drec; drec->which = Z_DiagRec_defaultFormat; drec->u.defaultFormat = dr; - dr->diagnosticSetId = odr_oiddup (odr, - oid_ent_to_oid(&bib1, oid)); + dr->diagnosticSetId = + yaz_oidval_to_z3950oid (odr, CLASS_DIAGSET, VAL_BIB1); + dr->condition = err; dr->which = Z_DefaultDiagFormat_v2Addinfo; dr->u.v2Addinfo = odr_strdup (odr, addinfo ? addinfo : ""); @@ -146,10 +141,8 @@ void Yaz_Z_ServerUtility::create_surrogateDiagnostics( Z_Records *Yaz_Z_ServerUtility::create_nonSurrogateDiagnostics ( ODR odr, int error, const char *addinfo) { - int oid[OID_SIZE]; Z_Records *rec = (Z_Records *) odr_malloc (odr, sizeof(*rec)); - oident bib1; int *err = (int *) odr_malloc (odr, sizeof(*err)); Z_DiagRec *drec = (Z_DiagRec *) @@ -157,17 +150,35 @@ Z_Records *Yaz_Z_ServerUtility::create_nonSurrogateDiagnostics ( Z_DefaultDiagFormat *dr = (Z_DefaultDiagFormat *) odr_malloc (odr, sizeof(*dr)); - bib1.proto = PROTO_Z3950; - bib1.oclass = CLASS_DIAGSET; - bib1.value = VAL_BIB1; - *err = error; rec->which = Z_Records_NSD; rec->u.nonSurrogateDiagnostic = dr; dr->diagnosticSetId = - odr_oiddup (odr, oid_ent_to_oid(&bib1, oid)); + yaz_oidval_to_z3950oid (odr, CLASS_DIAGSET, VAL_BIB1); + dr->condition = err; dr->which = Z_DefaultDiagFormat_v2Addinfo; dr->u.v2Addinfo = odr_strdup (odr, addinfo ? addinfo : ""); return rec; } + +void Yaz_Z_ServerUtility::create_diagnostics ( + ODR odr, int error, const char *addinfo, + Z_DiagRec ***dreca, int *num) +{ + Z_DiagRec *drec = (Z_DiagRec *) odr_malloc (odr, sizeof(*drec)); + Z_DefaultDiagFormat *dr = (Z_DefaultDiagFormat *) + odr_malloc (odr, sizeof(*dr)); + + *num = 1; + *dreca = (Z_DiagRec **) odr_malloc (odr, sizeof(*dreca)); + (*dreca)[0] = drec; + + drec->which = Z_DiagRec_defaultFormat; + drec->u.defaultFormat = dr; + dr->diagnosticSetId = + yaz_oidval_to_z3950oid (odr, CLASS_DIAGSET, VAL_BIB1); + dr->condition = odr_intdup (odr, error); + dr->which = Z_DefaultDiagFormat_v2Addinfo; + dr->u.v2Addinfo = odr_strdup (odr, addinfo ? addinfo : ""); +} -- 1.7.10.4 From a1c32cb5086cc24b6ba776379016bf6adad47821 Mon Sep 17 00:00:00 2001 From: Heikki Levanto Date: Wed, 24 Apr 2002 13:16:47 +0000 Subject: [PATCH 12/16] Minor project file details --- include/yaz++/yaz-z-databases.h | 4 ++-- src/yaz-z-databases.cpp | 4 ++-- win/yazclient/yazclient.dsp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/yaz++/yaz-z-databases.h b/include/yaz++/yaz-z-databases.h index f750c4d..de6bc59 100644 --- a/include/yaz++/yaz-z-databases.h +++ b/include/yaz++/yaz-z-databases.h @@ -2,12 +2,12 @@ * Copyright (c) 2001, Index Data. * See the file LICENSE for details. * - * $Id: yaz-z-databases.h,v 1.1 2001-11-06 17:08:05 adam Exp $ + * $Id: yaz-z-databases.h,v 1.2 2002-04-24 13:16:47 heikki Exp $ */ #include -/** Z39.50 Databases list +/** Z39.50 Databases list */ class YAZ_EXPORT Yaz_Z_Databases { public: diff --git a/src/yaz-z-databases.cpp b/src/yaz-z-databases.cpp index a16bc4d..1f12bb4 100644 --- a/src/yaz-z-databases.cpp +++ b/src/yaz-z-databases.cpp @@ -2,7 +2,7 @@ * Copyright (c) 2001, Index Data. * See the file LICENSE for details. * - * $Id: yaz-z-databases.cpp,v 1.2 2001-11-06 20:33:32 adam Exp $ + * $Id: yaz-z-databases.cpp,v 1.3 2002-04-24 13:16:47 heikki Exp $ */ #include @@ -24,7 +24,7 @@ Yaz_Z_Databases::~Yaz_Z_Databases() void Yaz_Z_Databases::set (int num, const char **db) { nmem_reset (nmem); - + m_list = (char **) nmem_malloc (nmem, num * sizeof(char*)); m_num = num; for (int i = 0; i Date: Thu, 8 Aug 2002 13:31:54 +0000 Subject: [PATCH 13/16] Added ZOOM. --- zoom/Changes | 38 +++++++++++++++ zoom/Makefile | 36 +++++++++++++++ zoom/README | 28 +++++++++++ zoom/master-header | 131 ++++++++++++++++++++++++++++++++++++++++++++++++++++ zoom/zclient.cpp | 54 ++++++++++++++++++++++ zoom/zconn.cpp | 34 ++++++++++++++ zoom/zerr.cpp | 93 +++++++++++++++++++++++++++++++++++++ zoom/zquery.cpp | 54 ++++++++++++++++++++++ zoom/zrec.cpp | 69 +++++++++++++++++++++++++++ zoom/zrs.cpp | 59 +++++++++++++++++++++++ 10 files changed, 596 insertions(+) create mode 100644 zoom/Changes create mode 100644 zoom/Makefile create mode 100644 zoom/README create mode 100644 zoom/master-header create mode 100644 zoom/zclient.cpp create mode 100644 zoom/zconn.cpp create mode 100644 zoom/zerr.cpp create mode 100644 zoom/zquery.cpp create mode 100644 zoom/zrec.cpp create mode 100644 zoom/zrs.cpp diff --git a/zoom/Changes b/zoom/Changes new file mode 100644 index 0000000..266869a --- /dev/null +++ b/zoom/Changes @@ -0,0 +1,38 @@ +Changes between the current version of the C++ binding specification +(http://zoom.z3950.org/bind/cplusplus/zoom-1.0g.hh) and the +specification generated in "interface.h" in this directory (which I +expect to become version 1.3a of the official specification.) + +-- + +Add #include for size_t + +Add comment about G++'s rejection of throw(ZOOM:error) clause + +Add destructor declaration to connection class. + +Remove errcode(), errmsg() and addinfo() methods from the connection +and resultSet classes, since exceptions should be used in these +enlightened days. + +Rename the record::recordSyntax enumeration to record::syntax, and add +an UNKNOWN element. + +Remove "virtual" from all the record class's methods, including its +destructor, since we no longer expect to derive record subclasses +representing records expressed in specific record-syntaxes -- see +version 1.3 of the ZOOM AAPI. + +Remove the nfields() and field() methods from the record class -- +again, see v1.3 of the AAPI. + +Add some substance to the error base class: it can now be created +(with an error-code specified), and the error-code may be both fetched +and rendered as a human-readable string. This is necessary so that +it's possible to meaningfully catch(error e). + +Add the missing char *errmsg() method to the systemError and bib1Error +classes. + +Add a new error subclass, queryError, for reporting malformed query +strings etc. diff --git a/zoom/Makefile b/zoom/Makefile new file mode 100644 index 0000000..bdcc128 --- /dev/null +++ b/zoom/Makefile @@ -0,0 +1,36 @@ +# $Header: /home/cvsroot/yaz++/zoom/Attic/Makefile,v 1.1 2002-08-08 13:31:54 mike Exp $ + +CCC = g++ # ... until I figure out what the standard + # Make macro name is for the C++ compiler. +CPPFLAGS := -Wall -g +L = libzoom.a +OBJ = $L(zerr.o) $L(zconn.o) $L(zquery.o) $L(zrs.o) $L(zrec.o) + +all: interface.h zclient + +zclient: zclient.o $L + @echo CCC = $(CCC) + $(CCC) $(CPPFLAGS) -o zclient zclient.o $L -lyaz + +test: zclient + ./zclient bagel.indexdata.dk 210 gils '@and mineral epicenter' + +$L: $(OBJ) + ranlib $L + +$(OBJ): zoom++.h + +zclient.o: zoom++.h + +zoom++.h: master-header + rm -f $@ + sed 's/^* / /; s/^*/ /' $< > $@ + chmod -w $@ + +interface.h: master-header + rm -f $@ + grep -v '^*' $< > $@ + chmod -w $@ + +clean: + rm -f zoom++.h interface.h zclient *.[ao] core diff --git a/zoom/README b/zoom/README new file mode 100644 index 0000000..729a4d6 --- /dev/null +++ b/zoom/README @@ -0,0 +1,28 @@ +This is an initial implementation of the ZOOM C++ binding +(http://zoom.z3950.org/bind/cplusplus/) for the Yaz toolkit. +It's a rather obvious thin layer on top of Yaz's ZOOM-C +implementation. + +The build environment will no doubt need to be tweaked to fit +in with the way that the rest of Yaz++ is built. + +Only one wrinkle, really: we want the ZOOM C++ header file for two +different purposes: one is to function as an interface specification +that can go on the ZOOM web-site, and one is to actually build +against. The requirements of these two manifestations of the header +file are rather different in that the latter needs to include +implementation details that the former very explicitly does _not_ +want. Accordingly, we automatically generate both versions from a +master copy in which the implementation-dependent lines are preceded +by asterisks(*). So we have: + + master-header The master copy, which may be edited. + interface.h The read-only, automatically-generated file + that can be considered a formal specification + of the ZOOM C++ interface. + zoom++.h The read-only, automatically-generated file + that is actually used in the build process, + and ought quite possibly to be moved into + ../include/yaz++/zoom.h + +Good luck! diff --git a/zoom/master-header b/zoom/master-header new file mode 100644 index 0000000..c573e33 --- /dev/null +++ b/zoom/master-header @@ -0,0 +1,131 @@ +// $Header: /home/cvsroot/yaz++/zoom/master-header,v 1.1 2002-08-08 13:31:54 mike Exp $ +// +// ZOOM C++ Binding. +// The ZOOM homepage is at http://zoom.z3950.org/ +// +// Derived from version 1.0g at +// http://zoom.z3950.org/bind/cplusplus/zoom-1.0g.hh + +#include // for size_t + +*/* +* * This is a bit stupid. The fact that our ZOOM-C++ implementation is +* * based on the ZOOM-C implementation is our Dirty Little Secret, and +* * there is in principle no reason why client code need be bothered +* * with it. Except of course that the public class declarations in +* * C++ have to lay their private parts out for the world to see +* * (oo-er). Hence the inclusion of +* */ +*#include +* +namespace ZOOM { + // Forward declarations for type names. + class query; + class resultSet; + class record; + + const char *option (const char *key); + const char *option (const char *key, const char *val); + int errcode (); + char *errmsg (); + char *addinfo (); + + class connection { +* ZOOM_connection c; + public: + connection (const char *hostname, int portnum); + // ### I would like to add a ``throw (ZOOM::error)'' clause + // here, but it looks like G++ 2.95.2 doesn't recognise it. + ~connection (); + const char *option (const char *key) const; + const char *option (const char *key, const char *val); +* ZOOM_connection _getYazConnection() const { return c; } // package-private + }; + + class query { + // pure virtual class: derive concrete subclasses from it. +* protected: +* ZOOM_query q; + public: + virtual ~query (); +* ZOOM_query _getYazQuery() const { return q; } // package-private + }; + + class prefixQuery : public query { + public: + prefixQuery (const char *pqn); + ~prefixQuery(); + }; + + class CCLQuery : public query { + public: + CCLQuery (const char *ccl, void *qualset); + ~CCLQuery(); + }; + + class resultSet { +* connection &owner; +* ZOOM_resultset rs; + public: + resultSet (connection &c, const query &q); + ~resultSet (); + const char *option (const char *key) const; + const char *option (const char *key, const char *val); + size_t size () const; + const record *getRecord (size_t i) const; + }; + + class record { +* const resultSet *owner; +* ZOOM_record r; + public: +* record::record(const resultSet *rs, ZOOM_record rec): +* owner(rs), r(rec) {} + ~record (); + enum syntax { + UNKNOWN, GRS1, SUTRS, USMARC, UKMARC, XML + }; + record *clone () const; + syntax recsyn () const; + const char *render () const; + const char *rawdata () const; + }; + + class error { +* protected: +* int code; + public: + error (int code); + int errcode () const; + const char *errmsg () const; + }; + + class systemError: public error { + public: + systemError (); + int errcode () const; + const char *errmsg () const; + }; + + class bib1Error: public error { +* const char *info; + public: +* ~bib1Error(); + bib1Error (int errcode, const char *addinfo); + int errcode () const; + const char *errmsg () const; + const char *addinfo () const; + }; + + class queryError: public error { +* const char *q; + public: +* ~queryError(); + static const int PREFIX = 1; + static const int CCL = 2; + queryError (int qtype, const char *source); + int errcode () const; + const char *errmsg () const; + const char *addinfo () const; + }; +} diff --git a/zoom/zclient.cpp b/zoom/zclient.cpp new file mode 100644 index 0000000..8a1bb95 --- /dev/null +++ b/zoom/zclient.cpp @@ -0,0 +1,54 @@ +// $Header: /home/cvsroot/yaz++/zoom/zclient.cpp,v 1.1 2002-08-08 13:31:54 mike Exp $ + +// Trivial sample client + +#include // for atoi() +#include +#include "zoom++.h" + +int main(int argc, char **argv) +{ + if (argc != 5) { + cerr << "Usage: " << argv[0] << + " <@prefix-search>\n"; + return 1; + } + + const char *hostname = argv[1]; + const int port = atoi(argv[2]); + const char *dbname = argv[3]; + const char *searchSpec = argv[4]; + + ZOOM::connection *conn; + try { + conn = new ZOOM::connection(hostname, port); + } catch(ZOOM::bib1Error err) { + cerr << argv[0] << ": connect: " << + err.errmsg() << " (" << err.addinfo() << ")\n"; + return 2; + } catch(ZOOM::error err) { + cerr << argv[0] << ": connect: " << err.errmsg() << "\n"; + return 2; + } + + conn->option("databaseName", dbname); + ZOOM::prefixQuery pq(searchSpec); + ZOOM::resultSet *rs; + try { + rs = new ZOOM::resultSet(*conn, pq); + } catch(ZOOM::bib1Error err) { + cerr << argv[0] << ": searchSpec: " << + err.errmsg() << " (" << err.addinfo() << ")\n"; + return 3; + } + + size_t n = rs->size(); + cout << "found " << n << " records:\n"; + for (size_t i = 0; i < n; i++) { + const ZOOM::record *rec = rs->getRecord(i); + cout << "=== record " << i+1 << " (recsyn " << rec->recsyn() + << ") ===\n" << rec->render(); + } + + return 0; +} diff --git a/zoom/zconn.cpp b/zoom/zconn.cpp new file mode 100644 index 0000000..e6f9dc9 --- /dev/null +++ b/zoom/zconn.cpp @@ -0,0 +1,34 @@ +// $Header: /home/cvsroot/yaz++/zoom/zconn.cpp,v 1.1 2002-08-08 13:31:54 mike Exp $ + +// Z39.50 Connection class + +#include "zoom++.h" + + +namespace ZOOM { + connection::connection(const char *hostname, int portnum) { + c = ZOOM_connection_new(hostname, portnum); + + int errcode; + const char *errmsg; // unused: carries same info as `errcode' + const char *addinfo; + if ((errcode = ZOOM_connection_error(c, &errmsg, &addinfo)) != 0) { + throw bib1Error(errcode, addinfo); + } + } + + const char *connection::option(const char *key) const { + return ZOOM_connection_option_get(c, key); + } + + const char *connection::option(const char *key, const char *val) { + // ### There may be memory-management issues here. + const char *old = ZOOM_connection_option_get(c, key); + ZOOM_connection_option_set(c, key, val); + return old; + } + + connection::~connection() { + ZOOM_connection_destroy(c); + } +} diff --git a/zoom/zerr.cpp b/zoom/zerr.cpp new file mode 100644 index 0000000..e418003 --- /dev/null +++ b/zoom/zerr.cpp @@ -0,0 +1,93 @@ +// $Header: /home/cvsroot/yaz++/zoom/Attic/zerr.cpp,v 1.1 2002-08-08 13:31:54 mike Exp $ + +// Z39.50 Error classes + +#include +#include // for strerror(), strlen(), strcpy() +#include // for sprintf() +#include +#include "zoom++.h" + + +namespace ZOOM { + error::error(int errcode) { + code = errcode; + } + + int error::errcode() const { + return code; + } + + const char *error::errmsg() const { + static char buf[40]; + sprintf(buf, "error #%d", code); + return buf; + } + + + + systemError::systemError() : error::error(errno){ + code = errno; + } + + int systemError::errcode() const { + return code; + } + + const char *systemError::errmsg() const { + return strerror(code); + } + + + + bib1Error::bib1Error(int errcode, const char *addinfo) : + error::error(errcode) { + info = new char[strlen(addinfo)+1]; + strcpy((char*) info, addinfo); + } + + bib1Error::~bib1Error() { + delete info; + } + + int bib1Error::errcode() const { + return code; + } + + const char *bib1Error::errmsg() const { + return diagbib1_str(code); + } + + const char *bib1Error::addinfo() const { + return info; + } + + + + queryError::queryError(int qtype, const char *source) : + error::error(qtype) { + q = new char[strlen(source)+1]; + strcpy((char*) q, source); + } + + queryError::~queryError() { + delete q; + } + + int queryError::errcode() const { + return code; + } + + const char *queryError::errmsg() const { + switch (code) { + case PREFIX: return "bad prefix search"; + case CCL: return "bad CCL search"; + default: break; + } + return "bad search (unknown type)"; + } + + const char *queryError::addinfo() const { + return q; + } +} diff --git a/zoom/zquery.cpp b/zoom/zquery.cpp new file mode 100644 index 0000000..77c0d93 --- /dev/null +++ b/zoom/zquery.cpp @@ -0,0 +1,54 @@ +// $Header: /home/cvsroot/yaz++/zoom/zquery.cpp,v 1.1 2002-08-08 13:31:54 mike Exp $ + +// Z39.50 Query classes + +#include "zoom++.h" + + +namespace ZOOM { + query::~query() { + ZOOM_query_destroy(q); + q = 0; + } + + + + prefixQuery::prefixQuery(const char *pqn) { + q = ZOOM_query_create(); + if (ZOOM_query_prefix(q, pqn) == -1) { + ZOOM_query_destroy(q); + throw queryError(queryError::PREFIX, pqn); + } + } + + // The binding specification says we have to have destructors for + // the query subclasses, so in they go -- even though they don't + // actually _do_ anything that inheriting the base query type's + // destructor wouldn't do. It's an irritant of C++ that the + // declaration of a subclass has to express explicitly the + // implementation detail of whether destruction is implemented + // by a specific destructor or by inheritance. Oh well. + // + // ### Not sure whether I need to do nothing at all, and the + // superclass destructor gets called anyway (I think that only + // works when you _don't_ define a destructor so that the default + // one pertains) or whether I need to duplicate the functionality + // of that destructor. Let's play safe by assuming the latter and + // zeroing what we free so that we get bitten if we're wrong. + // + prefixQuery::~prefixQuery() { + ZOOM_query_destroy(q); + q = 0; + } + + + + CCLQuery::CCLQuery(const char *ccl, void *qualset) { + throw "Oops. No CCL support in ZOOM-C yet. Sorry."; + } + + CCLQuery::~CCLQuery() { + ZOOM_query_destroy(q); + q = 0; + } +} diff --git a/zoom/zrec.cpp b/zoom/zrec.cpp new file mode 100644 index 0000000..18e34be --- /dev/null +++ b/zoom/zrec.cpp @@ -0,0 +1,69 @@ +// $Header: /home/cvsroot/yaz++/zoom/zrec.cpp,v 1.1 2002-08-08 13:31:54 mike Exp $ + +// Z39.50 Record class + +#include "zoom++.h" +#include // for strcasecmp() + + +namespace ZOOM { + record::~record() { + if (owner == 0) { + // Must have been clone()d + ZOOM_record_destroy(r); + } + } + + // ### Would this operation be better expressed as a copy constructor? + record *record::clone() const { + // It's tempting just to replace `r' with a clone, and return + // `this', but probably more honest to allocate a new C++ + // record object. + + record *rec = new record(0, 0); + if ((rec->r = ZOOM_record_clone(r)) == 0) { + // Presumably an out-of-memory error + throw systemError(); + } + + return rec; + } + + // It's tempting to modify this method just to return either the + // string that ZOOM_record_get("syntax") gives us, or the VAL_* + // value from Yaz's OID database, but we'd break the nominal + // plug-compatibility of competing C++ binding implementations + // if we did that. + // + record::syntax record::recsyn() const { + const char *syn = ZOOM_record_get(r, "syntax", 0); + + // These string constants are from yaz/util/oid.c + if (!strcasecmp(syn, "xml")) + return XML; + else if (!strcasecmp(syn, "GRS-1")) + return GRS1; + else if (!strcasecmp(syn, "SUTRS")) + return SUTRS; + else if (!strcasecmp(syn, "USmarc")) + return USMARC; + else if (!strcasecmp(syn, "UKmarc")) + return UKMARC; + else if (!strcasecmp(syn, "XML") || + !strcasecmp(syn, "text-XML") || + !strcasecmp(syn, "application-XML")) + return XML; + + return UNKNOWN; + } + + const char *record::render() const { + int len; + return ZOOM_record_get(r, "render", &len); + } + + const char *record::rawdata() const { + int len; + return ZOOM_record_get(r, "raw", &len); + } +} diff --git a/zoom/zrs.cpp b/zoom/zrs.cpp new file mode 100644 index 0000000..39d0422 --- /dev/null +++ b/zoom/zrs.cpp @@ -0,0 +1,59 @@ +// $Header: /home/cvsroot/yaz++/zoom/zrs.cpp,v 1.1 2002-08-08 13:31:54 mike Exp $ + +// Z39.50 Result Set class + +#include "zoom++.h" + + +namespace ZOOM { + resultSet::resultSet(connection &c, const query &q) : owner(c) { + ZOOM_connection yazc = c._getYazConnection(); + rs = ZOOM_connection_search(yazc, q._getYazQuery()); + int errcode; + const char *errmsg; // unused: carries same info as `errcode' + const char *addinfo; + + if ((errcode = ZOOM_connection_error(yazc, &errmsg, &addinfo)) != 0) { + throw bib1Error(errcode, addinfo); + } + } + + resultSet::~resultSet() { + ZOOM_resultset_destroy(rs); + } + + const char *resultSet::option(const char *key) const { + return ZOOM_resultset_option_get(rs, key); + } + + const char *resultSet::option(const char *key, const char *val) { + // ### There may be memory-management issues here. + const char *old = ZOOM_resultset_option_get(rs, key); + ZOOM_resultset_option_set(rs, key, val); + return old; + } + + size_t resultSet::size() const { + return ZOOM_resultset_size(rs); + } + + const record *resultSet::getRecord(size_t i) const { + ZOOM_record rec; + if ((rec = ZOOM_resultset_record(rs, i)) == 0) { + const char *errmsg; // unused: carries same info as `errcode' + const char *addinfo; + int errcode = ZOOM_connection_error(owner._getYazConnection(), + &errmsg, &addinfo); + throw bib1Error(errcode, addinfo); + } + + // Memory management is odd here. The ZOOM-C record we've + // just fetched (`rec') is owned by the ZOOM-C result-set we + // fetched it from (`rs'), so all we need to allocate is a + // ZOOM-C++ wrapper for it, which is destroyed at the + // appropriate time -- but the underlying (ZOOM-C) record is + // _not_ destroyed at that time, because it's done when the + // underlying result-set is deleted. + return new record(this, rec); + } +} -- 1.7.10.4 From 7c6295779d21f882f9d53186c5a751cbf86b6c86 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Thu, 8 Aug 2002 16:06:08 +0000 Subject: [PATCH 14/16] Rename error classes to exception. Rename zerr.cpp --- zoom/Changes | 18 ++++++---- zoom/master-header | 36 ++++++++++---------- zoom/zclient.cpp | 13 ++++---- zoom/zconn.cpp | 4 +-- zoom/zerr.cpp | 93 ---------------------------------------------------- zoom/zexcept.cpp | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++ zoom/zquery.cpp | 4 +-- zoom/zrec.cpp | 4 +-- zoom/zrs.cpp | 6 ++-- 9 files changed, 138 insertions(+), 133 deletions(-) delete mode 100644 zoom/zerr.cpp create mode 100644 zoom/zexcept.cpp diff --git a/zoom/Changes b/zoom/Changes index 266869a..e8e0549 100644 --- a/zoom/Changes +++ b/zoom/Changes @@ -7,7 +7,7 @@ expect to become version 1.3a of the official specification.) Add #include for size_t -Add comment about G++'s rejection of throw(ZOOM:error) clause +Add comment about G++'s rejection of throw(ZOOM:exception) clause Add destructor declaration to connection class. @@ -26,13 +26,17 @@ version 1.3 of the ZOOM AAPI. Remove the nfields() and field() methods from the record class -- again, see v1.3 of the AAPI. -Add some substance to the error base class: it can now be created +Rename the error class to exception, and its subclasses likewise. I +think that's Telling It Like It Is, and it's certainly more in tune +with the was v1.3 of the AAPI is going. + +Add some substance to the exception base class: it can now be created (with an error-code specified), and the error-code may be both fetched and rendered as a human-readable string. This is necessary so that -it's possible to meaningfully catch(error e). +it's possible to meaningfully catch(exception e). -Add the missing char *errmsg() method to the systemError and bib1Error -classes. +Add the missing char *errmsg() method to the systemException and +bib1Exception classes. -Add a new error subclass, queryError, for reporting malformed query -strings etc. +Add a new exception subclass, queryException, for reporting malformed +query strings etc. diff --git a/zoom/master-header b/zoom/master-header index c573e33..a66b089 100644 --- a/zoom/master-header +++ b/zoom/master-header @@ -1,4 +1,4 @@ -// $Header: /home/cvsroot/yaz++/zoom/master-header,v 1.1 2002-08-08 13:31:54 mike Exp $ +// $Header: /home/cvsroot/yaz++/zoom/master-header,v 1.2 2002-08-08 16:06:08 mike Exp $ // // ZOOM C++ Binding. // The ZOOM homepage is at http://zoom.z3950.org/ @@ -34,12 +34,12 @@ namespace ZOOM { * ZOOM_connection c; public: connection (const char *hostname, int portnum); - // ### I would like to add a ``throw (ZOOM::error)'' clause + // ### I would like to add a ``throw (ZOOM::exception)'' clause // here, but it looks like G++ 2.95.2 doesn't recognise it. ~connection (); const char *option (const char *key) const; const char *option (const char *key, const char *val); -* ZOOM_connection _getYazConnection() const { return c; } // package-private +* ZOOM_connection _getYazConnection () const { return c; } // package-private }; class query { @@ -48,19 +48,19 @@ namespace ZOOM { * ZOOM_query q; public: virtual ~query (); -* ZOOM_query _getYazQuery() const { return q; } // package-private +* ZOOM_query _getYazQuery () const { return q; } // package-private }; class prefixQuery : public query { public: prefixQuery (const char *pqn); - ~prefixQuery(); + ~prefixQuery (); }; class CCLQuery : public query { public: CCLQuery (const char *ccl, void *qualset); - ~CCLQuery(); + ~CCLQuery (); }; class resultSet { @@ -79,8 +79,8 @@ namespace ZOOM { * const resultSet *owner; * ZOOM_record r; public: -* record::record(const resultSet *rs, ZOOM_record rec): -* owner(rs), r(rec) {} +* record::record (const resultSet *rs, ZOOM_record rec): +* owner (rs), r (rec) {} ~record (); enum syntax { UNKNOWN, GRS1, SUTRS, USMARC, UKMARC, XML @@ -91,39 +91,39 @@ namespace ZOOM { const char *rawdata () const; }; - class error { + class exception { * protected: * int code; public: - error (int code); + exception (int code); int errcode () const; const char *errmsg () const; }; - class systemError: public error { + class systemException: public exception { public: - systemError (); + systemException (); int errcode () const; const char *errmsg () const; }; - class bib1Error: public error { + class bib1Exception: public exception { * const char *info; public: -* ~bib1Error(); - bib1Error (int errcode, const char *addinfo); +* ~bib1Exception (); + bib1Exception (int errcode, const char *addinfo); int errcode () const; const char *errmsg () const; const char *addinfo () const; }; - class queryError: public error { + class queryException: public exception { * const char *q; public: -* ~queryError(); +* ~queryException (); static const int PREFIX = 1; static const int CCL = 2; - queryError (int qtype, const char *source); + queryException (int qtype, const char *source); int errcode () const; const char *errmsg () const; const char *addinfo () const; diff --git a/zoom/zclient.cpp b/zoom/zclient.cpp index 8a1bb95..863968d 100644 --- a/zoom/zclient.cpp +++ b/zoom/zclient.cpp @@ -1,4 +1,4 @@ -// $Header: /home/cvsroot/yaz++/zoom/zclient.cpp,v 1.1 2002-08-08 13:31:54 mike Exp $ +// $Header: /home/cvsroot/yaz++/zoom/zclient.cpp,v 1.2 2002-08-08 16:06:08 mike Exp $ // Trivial sample client @@ -22,12 +22,13 @@ int main(int argc, char **argv) ZOOM::connection *conn; try { conn = new ZOOM::connection(hostname, port); - } catch(ZOOM::bib1Error err) { - cerr << argv[0] << ": connect: " << + } catch(ZOOM::bib1Exception err) { + cerr << argv[0] << ": connect: bib1Exception " << err.errmsg() << " (" << err.addinfo() << ")\n"; return 2; - } catch(ZOOM::error err) { - cerr << argv[0] << ": connect: " << err.errmsg() << "\n"; + } catch(ZOOM::exception err) { + cerr << argv[0] << ": connect: exception " << + err.errmsg() << "\n"; return 2; } @@ -36,7 +37,7 @@ int main(int argc, char **argv) ZOOM::resultSet *rs; try { rs = new ZOOM::resultSet(*conn, pq); - } catch(ZOOM::bib1Error err) { + } catch(ZOOM::bib1Exception err) { cerr << argv[0] << ": searchSpec: " << err.errmsg() << " (" << err.addinfo() << ")\n"; return 3; diff --git a/zoom/zconn.cpp b/zoom/zconn.cpp index e6f9dc9..8aad4ab 100644 --- a/zoom/zconn.cpp +++ b/zoom/zconn.cpp @@ -1,4 +1,4 @@ -// $Header: /home/cvsroot/yaz++/zoom/zconn.cpp,v 1.1 2002-08-08 13:31:54 mike Exp $ +// $Header: /home/cvsroot/yaz++/zoom/zconn.cpp,v 1.2 2002-08-08 16:06:08 mike Exp $ // Z39.50 Connection class @@ -13,7 +13,7 @@ namespace ZOOM { const char *errmsg; // unused: carries same info as `errcode' const char *addinfo; if ((errcode = ZOOM_connection_error(c, &errmsg, &addinfo)) != 0) { - throw bib1Error(errcode, addinfo); + throw bib1Exception(errcode, addinfo); } } diff --git a/zoom/zerr.cpp b/zoom/zerr.cpp deleted file mode 100644 index e418003..0000000 --- a/zoom/zerr.cpp +++ /dev/null @@ -1,93 +0,0 @@ -// $Header: /home/cvsroot/yaz++/zoom/Attic/zerr.cpp,v 1.1 2002-08-08 13:31:54 mike Exp $ - -// Z39.50 Error classes - -#include -#include // for strerror(), strlen(), strcpy() -#include // for sprintf() -#include -#include "zoom++.h" - - -namespace ZOOM { - error::error(int errcode) { - code = errcode; - } - - int error::errcode() const { - return code; - } - - const char *error::errmsg() const { - static char buf[40]; - sprintf(buf, "error #%d", code); - return buf; - } - - - - systemError::systemError() : error::error(errno){ - code = errno; - } - - int systemError::errcode() const { - return code; - } - - const char *systemError::errmsg() const { - return strerror(code); - } - - - - bib1Error::bib1Error(int errcode, const char *addinfo) : - error::error(errcode) { - info = new char[strlen(addinfo)+1]; - strcpy((char*) info, addinfo); - } - - bib1Error::~bib1Error() { - delete info; - } - - int bib1Error::errcode() const { - return code; - } - - const char *bib1Error::errmsg() const { - return diagbib1_str(code); - } - - const char *bib1Error::addinfo() const { - return info; - } - - - - queryError::queryError(int qtype, const char *source) : - error::error(qtype) { - q = new char[strlen(source)+1]; - strcpy((char*) q, source); - } - - queryError::~queryError() { - delete q; - } - - int queryError::errcode() const { - return code; - } - - const char *queryError::errmsg() const { - switch (code) { - case PREFIX: return "bad prefix search"; - case CCL: return "bad CCL search"; - default: break; - } - return "bad search (unknown type)"; - } - - const char *queryError::addinfo() const { - return q; - } -} diff --git a/zoom/zexcept.cpp b/zoom/zexcept.cpp new file mode 100644 index 0000000..7113a4d --- /dev/null +++ b/zoom/zexcept.cpp @@ -0,0 +1,93 @@ +// $Header: /home/cvsroot/yaz++/zoom/zexcept.cpp,v 1.1 2002-08-08 16:06:08 mike Exp $ + +// Z39.50 Exception classes + +#include +#include // for strerror(), strlen(), strcpy() +#include // for sprintf() +#include +#include "zoom++.h" + + +namespace ZOOM { + exception::exception(int errcode) { + code = errcode; + } + + int exception::errcode() const { + return code; + } + + const char *exception::errmsg() const { + static char buf[40]; + sprintf(buf, "error #%d", code); + return buf; + } + + + + systemException::systemException() : exception::exception(errno){ + code = errno; + } + + int systemException::errcode() const { + return code; + } + + const char *systemException::errmsg() const { + return strerror(code); + } + + + + bib1Exception::bib1Exception(int errcode, const char *addinfo) : + exception::exception(errcode) { + info = new char[strlen(addinfo)+1]; + strcpy((char*) info, addinfo); + } + + bib1Exception::~bib1Exception() { + delete info; + } + + int bib1Exception::errcode() const { + return code; + } + + const char *bib1Exception::errmsg() const { + return diagbib1_str(code); + } + + const char *bib1Exception::addinfo() const { + return info; + } + + + + queryException::queryException(int qtype, const char *source) : + exception::exception(qtype) { + q = new char[strlen(source)+1]; + strcpy((char*) q, source); + } + + queryException::~queryException() { + delete q; + } + + int queryException::errcode() const { + return code; + } + + const char *queryException::errmsg() const { + switch (code) { + case PREFIX: return "bad prefix search"; + case CCL: return "bad CCL search"; + default: break; + } + return "bad search (unknown type)"; + } + + const char *queryException::addinfo() const { + return q; + } +} diff --git a/zoom/zquery.cpp b/zoom/zquery.cpp index 77c0d93..602663f 100644 --- a/zoom/zquery.cpp +++ b/zoom/zquery.cpp @@ -1,4 +1,4 @@ -// $Header: /home/cvsroot/yaz++/zoom/zquery.cpp,v 1.1 2002-08-08 13:31:54 mike Exp $ +// $Header: /home/cvsroot/yaz++/zoom/zquery.cpp,v 1.2 2002-08-08 16:06:08 mike Exp $ // Z39.50 Query classes @@ -17,7 +17,7 @@ namespace ZOOM { q = ZOOM_query_create(); if (ZOOM_query_prefix(q, pqn) == -1) { ZOOM_query_destroy(q); - throw queryError(queryError::PREFIX, pqn); + throw queryException(queryException::PREFIX, pqn); } } diff --git a/zoom/zrec.cpp b/zoom/zrec.cpp index 18e34be..2a0bd6f 100644 --- a/zoom/zrec.cpp +++ b/zoom/zrec.cpp @@ -1,4 +1,4 @@ -// $Header: /home/cvsroot/yaz++/zoom/zrec.cpp,v 1.1 2002-08-08 13:31:54 mike Exp $ +// $Header: /home/cvsroot/yaz++/zoom/zrec.cpp,v 1.2 2002-08-08 16:06:08 mike Exp $ // Z39.50 Record class @@ -23,7 +23,7 @@ namespace ZOOM { record *rec = new record(0, 0); if ((rec->r = ZOOM_record_clone(r)) == 0) { // Presumably an out-of-memory error - throw systemError(); + throw systemException(); } return rec; diff --git a/zoom/zrs.cpp b/zoom/zrs.cpp index 39d0422..48e212c 100644 --- a/zoom/zrs.cpp +++ b/zoom/zrs.cpp @@ -1,4 +1,4 @@ -// $Header: /home/cvsroot/yaz++/zoom/zrs.cpp,v 1.1 2002-08-08 13:31:54 mike Exp $ +// $Header: /home/cvsroot/yaz++/zoom/zrs.cpp,v 1.2 2002-08-08 16:06:08 mike Exp $ // Z39.50 Result Set class @@ -14,7 +14,7 @@ namespace ZOOM { const char *addinfo; if ((errcode = ZOOM_connection_error(yazc, &errmsg, &addinfo)) != 0) { - throw bib1Error(errcode, addinfo); + throw bib1Exception(errcode, addinfo); } } @@ -44,7 +44,7 @@ namespace ZOOM { const char *addinfo; int errcode = ZOOM_connection_error(owner._getYazConnection(), &errmsg, &addinfo); - throw bib1Error(errcode, addinfo); + throw bib1Exception(errcode, addinfo); } // Memory management is odd here. The ZOOM-C record we've -- 1.7.10.4 From 38cf7818581012c3a0f95e870ad8fdf625e7e7a4 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Thu, 8 Aug 2002 16:06:50 +0000 Subject: [PATCH 15/16] Oops. Forgot to change zerr.cpp to zexcept.cpp in Makefile. --- zoom/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zoom/Makefile b/zoom/Makefile index bdcc128..b901e05 100644 --- a/zoom/Makefile +++ b/zoom/Makefile @@ -1,10 +1,10 @@ -# $Header: /home/cvsroot/yaz++/zoom/Attic/Makefile,v 1.1 2002-08-08 13:31:54 mike Exp $ +# $Header: /home/cvsroot/yaz++/zoom/Attic/Makefile,v 1.2 2002-08-08 16:06:50 mike Exp $ CCC = g++ # ... until I figure out what the standard # Make macro name is for the C++ compiler. CPPFLAGS := -Wall -g L = libzoom.a -OBJ = $L(zerr.o) $L(zconn.o) $L(zquery.o) $L(zrs.o) $L(zrec.o) +OBJ = $L(zexcept.o) $L(zconn.o) $L(zquery.o) $L(zrs.o) $L(zrec.o) all: interface.h zclient -- 1.7.10.4 From fb113bcbf8398f8faa896529405909c7f8092b20 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Thu, 8 Aug 2002 16:14:26 +0000 Subject: [PATCH 16/16] Add -ansi option to default G++ flags. That detects that on my Linux system (Red Hat 7.1) wrongly fails to declare strcasecmp(), so I am using yaz_matchstr() instead. --- zoom/Makefile | 4 ++-- zoom/zrec.cpp | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/zoom/Makefile b/zoom/Makefile index b901e05..2b3201d 100644 --- a/zoom/Makefile +++ b/zoom/Makefile @@ -1,8 +1,8 @@ -# $Header: /home/cvsroot/yaz++/zoom/Attic/Makefile,v 1.2 2002-08-08 16:06:50 mike Exp $ +# $Header: /home/cvsroot/yaz++/zoom/Attic/Makefile,v 1.3 2002-08-08 16:14:26 mike Exp $ CCC = g++ # ... until I figure out what the standard # Make macro name is for the C++ compiler. -CPPFLAGS := -Wall -g +CPPFLAGS := -Wall -g -ansi L = libzoom.a OBJ = $L(zexcept.o) $L(zconn.o) $L(zquery.o) $L(zrs.o) $L(zrec.o) diff --git a/zoom/zrec.cpp b/zoom/zrec.cpp index 2a0bd6f..09dee2f 100644 --- a/zoom/zrec.cpp +++ b/zoom/zrec.cpp @@ -1,9 +1,9 @@ -// $Header: /home/cvsroot/yaz++/zoom/zrec.cpp,v 1.2 2002-08-08 16:06:08 mike Exp $ +// $Header: /home/cvsroot/yaz++/zoom/zrec.cpp,v 1.3 2002-08-08 16:14:26 mike Exp $ // Z39.50 Record class #include "zoom++.h" -#include // for strcasecmp() +#include // for yaz_matchstr() namespace ZOOM { @@ -39,19 +39,19 @@ namespace ZOOM { const char *syn = ZOOM_record_get(r, "syntax", 0); // These string constants are from yaz/util/oid.c - if (!strcasecmp(syn, "xml")) + if (!yaz_matchstr(syn, "xml")) return XML; - else if (!strcasecmp(syn, "GRS-1")) + else if (!yaz_matchstr(syn, "GRS-1")) return GRS1; - else if (!strcasecmp(syn, "SUTRS")) + else if (!yaz_matchstr(syn, "SUTRS")) return SUTRS; - else if (!strcasecmp(syn, "USmarc")) + else if (!yaz_matchstr(syn, "USmarc")) return USMARC; - else if (!strcasecmp(syn, "UKmarc")) + else if (!yaz_matchstr(syn, "UKmarc")) return UKMARC; - else if (!strcasecmp(syn, "XML") || - !strcasecmp(syn, "text-XML") || - !strcasecmp(syn, "application-XML")) + else if (!yaz_matchstr(syn, "XML") || + !yaz_matchstr(syn, "text-XML") || + !yaz_matchstr(syn, "application-XML")) return XML; return UNKNOWN; -- 1.7.10.4