From a8063bff74c6d48f7a0aec23c266894777e3134b Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 23 Mar 1999 14:17:57 +0000 Subject: [PATCH] More work on timeout handling. Work on yaz-client. --- include/yaz-ir-assoc.h | 15 ++++-- include/yaz-pdu-assoc.h | 8 ++- include/yaz-pdu-observer.h | 9 +++- include/yaz-query.h | 21 ++++++++ include/yaz-socket-manager.h | 7 ++- include/yaz-socket-observer.h | 7 ++- include/yaz-z-query.h | 37 ++++++++++++++ src/Makefile.in | 15 +++--- src/yaz-client.cpp | 110 ++++++++++++++++++++++++++++++++++++++++- src/yaz-ir-assoc.cpp | 14 +++++- src/yaz-pdu-assoc.cpp | 16 +++++- src/yaz-server.cpp | 19 +++++-- src/yaz-socket-manager.cpp | 45 +++++++++++++---- src/yaz-z-query.cpp | 64 ++++++++++++++++++++++++ unix/Makefile.in | 6 ++- unix/configure.in | 6 +-- 16 files changed, 362 insertions(+), 37 deletions(-) create mode 100644 include/yaz-query.h create mode 100644 include/yaz-z-query.h create mode 100644 src/yaz-z-query.cpp diff --git a/include/yaz-ir-assoc.h b/include/yaz-ir-assoc.h index 3a04149..a5f998d 100644 --- a/include/yaz-ir-assoc.h +++ b/include/yaz-ir-assoc.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: yaz-ir-assoc.h,v $ - * Revision 1.3 1999-02-02 14:01:12 adam + * 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:12 adam * First WIN32 port of YAZ++. * * Revision 1.2 1999/01/28 13:08:39 adam @@ -37,6 +40,8 @@ class YAZ_EXPORT Yaz_IR_Assoc : public IYaz_PDU_Observer { void connectNotify(); /// Failure notification void failNotify(); + /// Timeout notification + void timeoutNotify(); /// Begin Z39.50 client role void client(const char *addr); /// Begin Z39.50 server role @@ -48,12 +53,14 @@ class YAZ_EXPORT Yaz_IR_Assoc : public IYaz_PDU_Observer { /// Send Z39.50 PDU int send_Z_PDU(Z_APDU *apdu); /// Receive Z39.50 PDU - virtual void recv_Z_PDU (Z_APDU *apdu) = 0; - /// Create Z39.50 with reasonable defaults + virtual void recv_Z_PDU(Z_APDU *apdu) = 0; + /// Create Z39.50 PDU with reasonable defaults Z_APDU *create_Z_PDU(int type); + /// Request Alloc + ODR odr_encode (); + private: static int yaz_init_flag; static int yaz_init_func(); - private: IYaz_PDU_Observable *m_PDU_Observable; ODR m_odr_in; ODR m_odr_out; diff --git a/include/yaz-pdu-assoc.h b/include/yaz-pdu-assoc.h index 2309798..c5930c4 100644 --- a/include/yaz-pdu-assoc.h +++ b/include/yaz-pdu-assoc.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: yaz-pdu-assoc.h,v $ - * Revision 1.3 1999-02-02 14:01:13 adam + * 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:13 adam * First WIN32 port of YAZ++. * * Revision 1.2 1999/01/28 13:08:40 adam @@ -49,6 +52,7 @@ class YAZ_EXPORT Yaz_PDU_Assoc : public IYaz_PDU_Observable, IYazSocketObserver PDU_Queue *m_queue_out; int Yaz_PDU_Assoc::flush_PDU(); int *m_destroyed; + int m_idleTime; public: /// Create object using specified socketObservable Yaz_PDU_Assoc(IYazSocketObservable *socketObservable, COMSTACK cs); @@ -68,4 +72,6 @@ class YAZ_EXPORT Yaz_PDU_Assoc : public IYaz_PDU_Observable, IYazSocketObserver void close(); /// Close and destroy void destroy(); + /// Set Idle Time + void idleTime (int timeout); }; diff --git a/include/yaz-pdu-observer.h b/include/yaz-pdu-observer.h index cd4d246..78618bf 100644 --- a/include/yaz-pdu-observer.h +++ b/include/yaz-pdu-observer.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: yaz-pdu-observer.h,v $ - * Revision 1.3 1999-02-02 14:01:14 adam + * 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:14 adam * First WIN32 port of YAZ++. * * Revision 1.2 1999/01/28 13:08:41 adam @@ -41,6 +44,8 @@ class YAZ_EXPORT IYaz_PDU_Observable { virtual IYaz_PDU_Observable *clone() = 0; /// Destroy completely virtual void destroy() = 0; + /// Set Idle Time + virtual void idleTime (int timeout) = 0; }; /** Protocol Data Unit Observer. @@ -55,6 +60,8 @@ class YAZ_EXPORT IYaz_PDU_Observer { virtual void connectNotify() = 0; /// Called whenever the connection was closed virtual void failNotify() = 0; + /// Called whenever the connection was closed + virtual void timeoutNotify() = 0; /// Make clone of observer using IYaz_PDU_Observable interface virtual IYaz_PDU_Observer *clone(IYaz_PDU_Observable *the_PDU_Observable) = 0; }; diff --git a/include/yaz-query.h b/include/yaz-query.h new file mode 100644 index 0000000..f484d05 --- /dev/null +++ b/include/yaz-query.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 1998-1999, Index Data. + * See the file LICENSE for details. + * Sebastian Hammer, Adam Dickmeiss + * + * $Log: yaz-query.h,v $ + * Revision 1.1 1999-03-23 14:17:57 adam + * More work on timeout handling. Work on yaz-client. + * + */ + + +/** Query + Generic Query. +*/ +class YAZ_EXPORT Yaz_Query { + public: + /// Print query in buffer described by str and len + virtual void print (char *str, int len) = 0; +}; + diff --git a/include/yaz-socket-manager.h b/include/yaz-socket-manager.h index 5f5dbce..9404b39 100644 --- a/include/yaz-socket-manager.h +++ b/include/yaz-socket-manager.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: yaz-socket-manager.h,v $ - * Revision 1.2 1999-02-02 14:01:16 adam + * Revision 1.3 1999-03-23 14:17:57 adam + * More work on timeout handling. Work on yaz-client. + * + * Revision 1.2 1999/02/02 14:01:16 adam * First WIN32 port of YAZ++. * * Revision 1.1.1.1 1999/01/28 09:41:07 adam @@ -13,6 +16,7 @@ */ #include +#include /** Simple Socket Manager. Implements a stand-alone simple model that uses select(2) to @@ -25,6 +29,7 @@ class YAZ_EXPORT Yaz_SocketManager : public IYazSocketObservable { int fd; unsigned mask; unsigned timeout; + time_t last_activity; YazSocketEntry *next; }; YazSocketEntry *m_observers; // all registered observers diff --git a/include/yaz-socket-observer.h b/include/yaz-socket-observer.h index 11980da..2732eed 100644 --- a/include/yaz-socket-observer.h +++ b/include/yaz-socket-observer.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: yaz-socket-observer.h,v $ - * Revision 1.2 1999-02-02 14:01:17 adam + * Revision 1.3 1999-03-23 14:17:57 adam + * More work on timeout handling. Work on yaz-client. + * + * Revision 1.2 1999/02/02 14:01:17 adam * First WIN32 port of YAZ++. * * Revision 1.1.1.1 1999/01/28 09:41:07 adam @@ -18,7 +21,7 @@ #define YAZ_SOCKET_OBSERVE_READ 1 #define YAZ_SOCKET_OBSERVE_WRITE 2 #define YAZ_SOCKET_OBSERVE_EXCEPT 4 -#define YAZ_SOCKET_OBSERVE_TIME 8 +#define YAZ_SOCKET_OBSERVE_TIMEOUT 8 /** Forward reference diff --git a/include/yaz-z-query.h b/include/yaz-z-query.h new file mode 100644 index 0000000..b35bb8b --- /dev/null +++ b/include/yaz-z-query.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 1998-1999, Index Data. + * See the file LICENSE for details. + * Sebastian Hammer, Adam Dickmeiss + * + * $Log: yaz-z-query.h,v $ + * Revision 1.1 1999-03-23 14:17:57 adam + * More work on timeout handling. Work on yaz-client. + * + */ + +#include +#include + +/** Z39.50 Query + RPN, etc. +*/ +class YAZ_EXPORT Yaz_Z_Query : public Yaz_Query { + public: + /// Make Query from rpn string + Yaz_Z_Query(); + /// Delete Query + virtual ~Yaz_Z_Query(); + /// Set RPN + void set_rpn (const char *rpn); + /// Set Z Query + void set_Z_Query (Z_Query *z_query); + /// Get Z Query + Z_Query *get_Z_Query (); + /// print query + void print(char *str, int len); + private: + char *buf; + int len; + ODR odr_decode; + ODR odr_encode; +}; diff --git a/src/Makefile.in b/src/Makefile.in index 88687b3..b14caa9 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,7 +1,7 @@ -# Copyright (C) 1999, Index Data +# Copyright (C) 1999, Index Data ApS # All rights reserved. # Sebastian Hammer, Adam Dickmeiss -# $Id: Makefile.in,v 1.2 1999-01-28 10:04:47 adam Exp $ +# $Id: Makefile.in,v 1.3 1999-03-23 14:17:57 adam Exp $ SHELL=/bin/sh @@ -27,9 +27,10 @@ PROGO2=yaz-server.o PROG3=yaz-proxy PROGO3=yaz-proxy-main.o LIB=libyaz++.lib -PO=yaz-socket-manager.o yaz-pdu-assoc.o yaz-ir-assoc.o yaz-proxy.o +PO=yaz-socket-manager.o yaz-pdu-assoc.o yaz-ir-assoc.o yaz-proxy.o \ + yaz-z-query.o -.SUFFIXES: .cc +.SUFFIXES: .cpp all: $(PROG1) $(PROG2) $(PROG3) @@ -49,7 +50,7 @@ $(PROG3): $(PROGO3) $(YAZLIBS) $(LIB) alll: -.cc.o: +.cpp.o: $(CXX) -c $(DEFS) $(CXXFLAGS) $< .c.o: @@ -57,11 +58,11 @@ alll: clean: rm -f *.[oa] test core mon.out gmon.out errlist - rm -f $(PROG1) $(PROG2) $(PROG3) + rm -f $(PROG1) $(PROG2) $(PROG3) $(LIB) depend: sed '/^#Depend/q' Makefile.tmp - $(CXXCPP) $(DEFS) -M *.cc >>Makefile.tmp + $(CXXCPP) $(DEFS) -M *.cpp >>Makefile.tmp mv -f Makefile.tmp Makefile #Depend --- DOT NOT DELETE THIS LINE diff --git a/src/yaz-client.cpp b/src/yaz-client.cpp index 7d799f0..7f67f35 100644 --- a/src/yaz-client.cpp +++ b/src/yaz-client.cpp @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: yaz-client.cpp,v $ - * Revision 1.3 1999-02-02 14:01:18 adam + * 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 @@ -20,6 +23,7 @@ #include #include #include +#include class YAZ_EXPORT MyClient : public Yaz_IR_Assoc { public: @@ -27,6 +31,16 @@ public: void recv_Z_PDU(Z_APDU *apdu); IYaz_PDU_Observer *clone(IYaz_PDU_Observable *the_PDU_Observable); void init(); + void search(Yaz_Z_Query *query); + void present(int start, int number); + void set_databaseNames (int num, char **list); + void set_syntax (const char *syntax); + void set_elementSetName (const char *elementSetName); +private: + int m_num_databaseNames; + char **m_databaseNames; + int m_recordSyntax; + Z_ElementSetNames *m_elementSetNames; }; void MyClient::recv_Z_PDU(Z_APDU *apdu) @@ -40,6 +54,9 @@ void MyClient::recv_Z_PDU(Z_APDU *apdu) case Z_APDU_searchResponse: logf (LOG_LOG, "got searchResponse"); break; + case Z_APDU_presentResponse: + logf (LOG_LOG, "got presentResponse"); + break; } } @@ -51,6 +68,97 @@ IYaz_PDU_Observer *MyClient::clone(IYaz_PDU_Observable *the_PDU_Observable) MyClient::MyClient(IYaz_PDU_Observable *the_PDU_Observable) : Yaz_IR_Assoc (the_PDU_Observable) { + m_num_databaseNames = 0; + m_databaseNames = 0; + m_recordSyntax = VAL_NONE; +} + +void MyClient::set_databaseNames (int num, char **list) +{ + int i; + for (i = 0; iu.generic; + delete m_elementSetNames; + m_elementSetNames = 0; + if (elementSetName && *elementSetName) + { + m_elementSetNames = new Z_ElementSetNames; + m_elementSetNames->which = Z_ElementSetNames_generic; + m_elementSetNames->u.generic = new char[strlen(elementSetName)+1]; + strcpy (m_elementSetNames->u.generic, elementSetName); + } +} + +void MyClient::search(Yaz_Z_Query *query) +{ + Z_APDU *apdu = create_Z_PDU(Z_APDU_searchRequest); + Z_SearchRequest *req = apdu->u.searchRequest; + + req->num_databaseNames = m_num_databaseNames; + req->databaseNames = m_databaseNames; + req->query = query->get_Z_Query(); + + int oid_syntax[OID_SIZE]; + oident prefsyn; + if (m_recordSyntax != VAL_NONE) + { + prefsyn.proto = PROTO_Z3950; + prefsyn.oclass = CLASS_RECSYN; + prefsyn.value = (enum oid_value) m_recordSyntax; + oid_ent_to_oid(&prefsyn, oid_syntax); + req->preferredRecordSyntax = oid_syntax; + } + send_Z_PDU(apdu); +} + +void MyClient::present(int start, int number) +{ + Z_APDU *apdu = create_Z_PDU(Z_APDU_presentRequest); + Z_PresentRequest *req = apdu->u.presentRequest; + + req->resultSetStartPoint = &start; + req->numberOfRecordsRequested = &number; + + int oid_syntax[OID_SIZE]; + oident prefsyn; + if (m_recordSyntax != VAL_NONE) + { + prefsyn.proto = PROTO_Z3950; + prefsyn.oclass = CLASS_RECSYN; + prefsyn.value = (enum oid_value) m_recordSyntax; + oid_ent_to_oid(&prefsyn, oid_syntax); + req->preferredRecordSyntax = oid_syntax; + } + Z_RecordComposition compo; + if (m_elementSetNames) + { + req->recordComposition = &compo; + compo.which = Z_RecordComp_simple; + compo.u.simple = m_elementSetNames; + } + send_Z_PDU(apdu); } void MyClient::init() diff --git a/src/yaz-ir-assoc.cpp b/src/yaz-ir-assoc.cpp index f5dcb50..f941e6c 100644 --- a/src/yaz-ir-assoc.cpp +++ b/src/yaz-ir-assoc.cpp @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: yaz-ir-assoc.cpp,v $ - * Revision 1.3 1999-02-02 14:01:19 adam + * 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:19 adam * First WIN32 port of YAZ++. * * Revision 1.2 1999/01/28 13:08:43 adam @@ -110,6 +113,11 @@ void Yaz_IR_Assoc::failNotify() logf (LOG_LOG, "failNotify"); } +void Yaz_IR_Assoc::timeoutNotify() +{ + logf (LOG_LOG, "timeoutNotify"); +} + void Yaz_IR_Assoc::client(const char *addr) { m_PDU_Observable->connect (this, addr); @@ -120,3 +128,7 @@ void Yaz_IR_Assoc::server(const char *addr) m_PDU_Observable->listen (this, addr); } +ODR Yaz_IR_Assoc::odr_encode() +{ + return m_odr_out; +} diff --git a/src/yaz-pdu-assoc.cpp b/src/yaz-pdu-assoc.cpp index 334490f..e0c0c9d 100644 --- a/src/yaz-pdu-assoc.cpp +++ b/src/yaz-pdu-assoc.cpp @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: yaz-pdu-assoc.cpp,v $ - * Revision 1.3 1999-02-02 14:01:20 adam + * 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 @@ -106,6 +109,8 @@ void Yaz_PDU_Assoc::socketNotify(int event) assoc->m_socketObservable->maskObserver(assoc, YAZ_SOCKET_OBSERVE_READ| YAZ_SOCKET_OBSERVE_EXCEPT); + if (m_idleTime) + assoc->m_socketObservable->timeoutObserver(assoc, m_idleTime); } } else if (m_state == Ready) @@ -137,6 +142,10 @@ void Yaz_PDU_Assoc::socketNotify(int event) return; } while (m_cs && cs_more (m_cs)); } + if (event & YAZ_SOCKET_OBSERVE_TIMEOUT) + { + m_PDU_Observer->timeoutNotify(); + } } } @@ -301,6 +310,11 @@ void Yaz_PDU_Assoc::listen(IYaz_PDU_Observer *observer, m_state = Listen; } +void Yaz_PDU_Assoc::idleTime(int idleTime) +{ + m_idleTime = idleTime; +} + void Yaz_PDU_Assoc::connect(IYaz_PDU_Observer *observer, const char *addr) { diff --git a/src/yaz-server.cpp b/src/yaz-server.cpp index c0dd47a..932910c 100644 --- a/src/yaz-server.cpp +++ b/src/yaz-server.cpp @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: yaz-server.cpp,v $ - * Revision 1.3 1999-02-02 14:01:22 adam + * 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 @@ -27,6 +30,7 @@ public: void recv_Z_PDU(Z_APDU *apdu); IYaz_PDU_Observer* clone(IYaz_PDU_Observable *the_PDU_Observable); void failNotify(); + void timeoutNotify(); private: int m_no; }; @@ -59,7 +63,7 @@ void MyServer::recv_Z_PDU(Z_APDU *apdu) IYaz_PDU_Observer *MyServer::clone(IYaz_PDU_Observable *the_PDU_Observable) { - logf (LOG_LOG, "clone %d", m_no); + logf (LOG_LOG, "child no %d", m_no); m_no++; return new MyServer(the_PDU_Observable); } @@ -70,16 +74,25 @@ MyServer::MyServer(IYaz_PDU_Observable *the_PDU_Observable) : m_no = 0; } +void MyServer::timeoutNotify() +{ + logf (LOG_LOG, "connection timed out"); + delete this; +} + void MyServer::failNotify() { + logf (LOG_LOG, "connection closed by client"); delete this; } int main(int argc, char **argv) { Yaz_SocketManager mySocketManager; + Yaz_PDU_Assoc *my_PDU_Assoc = new Yaz_PDU_Assoc(&mySocketManager, 0); - MyServer z(new Yaz_PDU_Assoc(&mySocketManager, 0)); + my_PDU_Assoc->idleTime(20); + MyServer z(my_PDU_Assoc); if (argc <= 1) z.server("@:9999"); diff --git a/src/yaz-socket-manager.cpp b/src/yaz-socket-manager.cpp index 95bcc80..eeb06e2 100644 --- a/src/yaz-socket-manager.cpp +++ b/src/yaz-socket-manager.cpp @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: yaz-socket-manager.cpp,v $ - * Revision 1.3 1999-02-02 14:01:23 adam + * 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 @@ -54,6 +57,8 @@ void Yaz_SocketManager::addObserver(int fd, IYazSocketObserver *observer) } se->fd = fd; se->mask = 0; + se->last_activity = 0; + se->timeout = 0; } void Yaz_SocketManager::deleteObserver(IYazSocketObserver *observer) @@ -104,6 +109,7 @@ int Yaz_SocketManager::processEvent() { YazSocketEntry *p; YazSocketEvent *event = getEvent(); + unsigned timeout = 0; if (event) { event->observer->socketNotify(event->event); @@ -115,21 +121,15 @@ int Yaz_SocketManager::processEvent() int res; int max = 0; int no = 0; - struct timeval to; - struct timeval *timeout = &to; FD_ZERO(&in); FD_ZERO(&out); FD_ZERO(&except); - timeout = &to; /* hang on select */ - to.tv_sec = 60; - to.tv_usec = 0; - + time_t now = time(0); for (p = m_observers; p; p = p->next) { int fd = p->fd; - logf (LOG_LOG, "fd = %d mask=%d", fd, p->mask); if (p->mask) no++; if (p->mask & YAZ_SOCKET_OBSERVE_READ) @@ -140,13 +140,29 @@ int Yaz_SocketManager::processEvent() FD_SET(fd, &except); if (fd > max) max = fd; + if (p->timeout) + { + unsigned timeout_this; + timeout_this = p->timeout; + if (p->last_activity) + timeout_this -= now - p->last_activity; + if (timeout_this < 1) + timeout_this = 1; + if (!timeout || timeout_this < timeout) + timeout = timeout_this; + } } if (!no) return 0; - while ((res = select(max + 1, &in, &out, &except, timeout)) < 0) + + struct timeval to; + to.tv_sec = timeout; + to.tv_usec = 0; + + while ((res = select(max + 1, &in, &out, &except, timeout ? &to : 0)) < 0) if (errno != EINTR) return -1; - + now = time(0); for (p = m_observers; p; p = p->next) { int fd = p->fd; @@ -163,10 +179,19 @@ int Yaz_SocketManager::processEvent() if (mask) { YazSocketEvent *event = new YazSocketEvent; + p->last_activity = now; event->observer = p->observer; event->event = mask; putEvent (event); } + else if (p->timeout && now >= p->last_activity + (int) (p->timeout)) + { + YazSocketEvent *event = new YazSocketEvent; + p->last_activity = now; + event->observer = p->observer; + event->event = YAZ_SOCKET_OBSERVE_TIMEOUT; + putEvent (event); + } } if ((event = getEvent())) { diff --git a/src/yaz-z-query.cpp b/src/yaz-z-query.cpp new file mode 100644 index 0000000..e7d9b48 --- /dev/null +++ b/src/yaz-z-query.cpp @@ -0,0 +1,64 @@ +/* + * Copyright (c) 1998-1999, Index Data. + * See the file LICENSE for details. + * Sebastian Hammer, Adam Dickmeiss + * + * $Log: yaz-z-query.cpp,v $ + * Revision 1.1 1999-03-23 14:17:57 adam + * More work on timeout handling. Work on yaz-client. + * + */ + +#include +#include + +Yaz_Z_Query::Yaz_Z_Query() +{ + odr_encode = odr_createmem (ODR_ENCODE); + odr_decode = odr_createmem (ODR_DECODE); +} + +void Yaz_Z_Query::set_rpn (const char *rpn) +{ + buf = 0; + odr_reset (odr_encode); + Z_Query *query = (Z_Query*) odr_malloc (odr_encode, sizeof(*query)); + query->which = Z_Query_type_1; + query->u.type_1 = p_query_rpn (odr_encode, PROTO_Z3950, rpn); + if (!query->u.type_1) + return; + if (!z_Query (odr_encode, &query, 0)) + return; + buf = odr_getbuf (odr_encode, &len, 0); +} + +void Yaz_Z_Query::set_Z_Query(Z_Query *z_query) +{ + buf = 0; + odr_reset (odr_encode); + if (!z_Query (odr_encode, &z_query, 0)) + return; + buf = odr_getbuf (odr_encode, &len, 0); +} + +Yaz_Z_Query::~Yaz_Z_Query() +{ + odr_destroy (odr_encode); + odr_destroy (odr_decode); +} + +Z_Query *Yaz_Z_Query::get_Z_Query () +{ + Z_Query *query; + if (!buf) + return 0; + odr_setbuf (odr_decode, buf, len, 0); + if (!z_Query(odr_decode, &query, 0)) + return 0; + return query; +} + +void Yaz_Z_Query::print(char *str, int len) +{ + +} diff --git a/unix/Makefile.in b/unix/Makefile.in index 55a6de6..b2043b9 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -1,15 +1,17 @@ # Copyright (C) 1999, Index Data # All rights reserved. # Sebastian Hammer, Adam Dickmeiss -# $Id: Makefile.in,v 1.1 1999-01-28 09:41:07 adam Exp $ +# $Id: Makefile.in,v 1.2 1999-03-23 14:17:57 adam Exp $ SHELL=/bin/sh MAKE=make -.PHONY: all doc clean distclean +.PHONY: all doc clean distclean depend all: cd ../src; $(MAKE) +depend: + cd ../src; $(MAKE) depend doc: cd ../include; doc++ -H -d ../doc *.h diff --git a/unix/configure.in b/unix/configure.in index 4a0d7e3..1591362 100644 --- a/unix/configure.in +++ b/unix/configure.in @@ -1,7 +1,7 @@ -dnl YAZ Toolkit -dnl (c) Index Data 1994-1999 +dnl YAZ++ Toolkit configure script. +dnl (c) Index Data ApS 1999 dnl See the file LICENSE for details. -dnl $Id: configure.in,v 1.1 1999-01-28 09:41:07 adam Exp $ +dnl $Id: configure.in,v 1.2 1999-03-23 14:17:57 adam Exp $ AC_INIT(../include/yaz-socket-manager.h) dnl dnl ------ Checking programs -- 1.7.10.4