From 26b3f7f15abcb69aaf00fb6bdaf410ff3e7de14c Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 6 Dec 1999 13:52:45 +0000 Subject: [PATCH] Modified for new location of YAZ header files. Experimental threaded operation. --- include/yaz-ir-assoc.h | 3 +- include/yaz-pdu-assoc.h | 13 +- include/yaz-pdu-observer.h | 6 +- include/yaz-proxy.h | 23 +- include/yaz-socket-manager.h | 3 +- include/yaz-z-assoc.h | 13 +- include/yaz-z-query.h | 4 +- src/Makefile.in | 22 +- src/yaz-client.cpp | 81 ++++- src/yaz-ir-assoc.cpp | 27 +- src/yaz-pdu-assoc.cpp | 185 ++++++---- src/yaz-proxy-main.cpp | 20 +- src/yaz-proxy.cpp | 80 +++-- src/yaz-server.cpp | 15 +- src/yaz-socket-manager.cpp | 17 +- src/yaz-z-assoc.cpp | 32 +- src/yaz-z-query.cpp | 8 +- unix/configure | 764 +++++++++++++----------------------------- unix/configure.in | 58 ++-- 19 files changed, 622 insertions(+), 752 deletions(-) diff --git a/include/yaz-ir-assoc.h b/include/yaz-ir-assoc.h index b60f415..c1fd26d 100644 --- a/include/yaz-ir-assoc.h +++ b/include/yaz-ir-assoc.h @@ -3,7 +3,7 @@ * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * - * $Id: yaz-ir-assoc.h,v 1.7 1999-04-21 12:09:01 adam Exp $ + * $Id: yaz-ir-assoc.h,v 1.8 1999-12-06 13:52:45 adam Exp $ */ #include @@ -73,4 +73,5 @@ class YAZ_EXPORT Yaz_IR_Assoc: public Yaz_Z_Assoc { int m_preferredRecordSyntax; Z_ElementSetNames *m_elementSetNames; int m_lastReceived; + int m_log; }; diff --git a/include/yaz-pdu-assoc.h b/include/yaz-pdu-assoc.h index ff286c0..205c7ed 100644 --- a/include/yaz-pdu-assoc.h +++ b/include/yaz-pdu-assoc.h @@ -3,10 +3,10 @@ * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * - * $Id: yaz-pdu-assoc.h,v 1.6 1999-11-10 10:02:34 adam Exp $ + * $Id: yaz-pdu-assoc.h,v 1.7 1999-12-06 13:52:45 adam Exp $ */ -#include +#include #include #include @@ -18,7 +18,7 @@ */ class YAZ_EXPORT Yaz_PDU_Assoc : public IYaz_PDU_Observable, IYazSocketObserver { private: - enum { Connecting, Connected, Listen, Ready, Closed } m_state; + enum { Connecting, Listen, Ready, Closed } m_state; class PDU_Queue { public: PDU_Queue(const char *buf, int len); @@ -40,9 +40,10 @@ class YAZ_EXPORT Yaz_PDU_Assoc : public IYaz_PDU_Observable, IYazSocketObserver int Yaz_PDU_Assoc::flush_PDU(); int *m_destroyed; int m_idleTime; + int m_log; public: /// Create object using specified socketObservable - Yaz_PDU_Assoc(IYazSocketObservable *socketObservable, COMSTACK cs = 0); + Yaz_PDU_Assoc(IYazSocketObservable *socketObservable); /// Close socket and destroy object. virtual ~Yaz_PDU_Assoc(); /// Clone the object @@ -53,6 +54,8 @@ class YAZ_EXPORT Yaz_PDU_Assoc : public IYaz_PDU_Observable, IYazSocketObserver void connect(IYaz_PDU_Observer *observer, const char *addr); /// listen for clients (server role) void listen(IYaz_PDU_Observer *observer, const char *addr); + /// open with existing socket + void socket(IYaz_PDU_Observer *observer, int fd); /// Socket notification void socketNotify(int event); /// Close socket @@ -61,4 +64,6 @@ class YAZ_EXPORT Yaz_PDU_Assoc : public IYaz_PDU_Observable, IYazSocketObserver void destroy(); /// Set Idle Time void idleTime (int timeout); + /// Child start... + virtual void childNotify(int fd); }; diff --git a/include/yaz-pdu-observer.h b/include/yaz-pdu-observer.h index 292bb95..fdedc51 100644 --- a/include/yaz-pdu-observer.h +++ b/include/yaz-pdu-observer.h @@ -3,7 +3,7 @@ * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * - * $Id: yaz-pdu-observer.h,v 1.6 1999-04-20 10:30:05 adam Exp $ + * $Id: yaz-pdu-observer.h,v 1.7 1999-12-06 13:52:45 adam Exp $ */ #ifndef YAZ_PDU_OBSERVER_H @@ -33,6 +33,8 @@ class YAZ_EXPORT IYaz_PDU_Observable { virtual void destroy() = 0; /// Set Idle Time virtual void idleTime (int timeout) = 0; + /// open with existing socket + virtual void socket(IYaz_PDU_Observer *observer, int fd) = 0; }; /** Protocol Data Unit Observer. @@ -43,7 +45,7 @@ class YAZ_EXPORT IYaz_PDU_Observer { public: /// A PDU has been received virtual void recv_PDU(const char *buf, int len) = 0; - /// Called when Iyaz_PDU_Observabvle::connect was successful. + /// Called when Iyaz_PDU_Observable::connect was successful. virtual void connectNotify() = 0; /// Called whenever the connection was closed virtual void failNotify() = 0; diff --git a/include/yaz-proxy.h b/include/yaz-proxy.h index 3d051c9..cdd8cc3 100644 --- a/include/yaz-proxy.h +++ b/include/yaz-proxy.h @@ -3,7 +3,7 @@ * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * - * $Id: yaz-proxy.h,v 1.8 1999-11-10 10:02:34 adam Exp $ + * $Id: yaz-proxy.h,v 1.9 1999-12-06 13:52:45 adam Exp $ */ #include @@ -18,9 +18,11 @@ class YAZ_EXPORT Yaz_ProxyClient : public Yaz_Z_Assoc { ~Yaz_ProxyClient(); void recv_Z_PDU(Z_APDU *apdu); IYaz_PDU_Observer* clone(IYaz_PDU_Observable *the_PDU_Observable); + void shutdown(); Yaz_Proxy *m_server; void failNotify(); void timeoutNotify(); + void connectNotify(); char m_cookie[32]; Yaz_ProxyClient *m_next; Yaz_ProxyClient **m_prev; @@ -32,19 +34,12 @@ class YAZ_EXPORT Yaz_ProxyClient : public Yaz_Z_Assoc { /// Information Retrieval Proxy Server. class YAZ_EXPORT Yaz_Proxy : public Yaz_Z_Assoc { - public: - Yaz_Proxy(IYaz_PDU_Observable *the_PDU_Observable); - ~Yaz_Proxy(); - void recv_Z_PDU(Z_APDU *apdu); - IYaz_PDU_Observer* clone(IYaz_PDU_Observable *the_PDU_Observable); - void failNotify(); - void timeoutNotify(); - void proxyTarget(const char *target); private: char *get_cookie(Z_OtherInformation **otherInfo); char *get_proxy(Z_OtherInformation **otherInfo); Yaz_ProxyClient *get_client(Z_APDU *apdu); Z_APDU *result_set_optimize(Z_APDU *apdu); + void shutdown(); Yaz_ProxyClient *m_client; IYaz_PDU_Observable *m_PDU_Observable; @@ -53,5 +48,15 @@ class YAZ_EXPORT Yaz_Proxy : public Yaz_Z_Assoc { int m_seqno; int m_keepalive; char *m_proxyTarget; + public: + Yaz_Proxy(IYaz_PDU_Observable *the_PDU_Observable); + ~Yaz_Proxy(); + void recv_Z_PDU(Z_APDU *apdu); + IYaz_PDU_Observer* clone(IYaz_PDU_Observable *the_PDU_Observable); + void failNotify(); + void timeoutNotify(); + void connectNotify(); + void set_proxyTarget(const char *target); + char *get_proxyTarget() { return m_proxyTarget; }; }; diff --git a/include/yaz-socket-manager.h b/include/yaz-socket-manager.h index 2f57cf2..a43daec 100644 --- a/include/yaz-socket-manager.h +++ b/include/yaz-socket-manager.h @@ -3,7 +3,7 @@ * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * - * $Id: yaz-socket-manager.h,v 1.4 1999-04-20 10:30:05 adam Exp $ + * $Id: yaz-socket-manager.h,v 1.5 1999-12-06 13:52:45 adam Exp $ */ #include @@ -38,6 +38,7 @@ class YAZ_EXPORT Yaz_SocketManager : public IYazSocketObservable { YazSocketEvent *Yaz_SocketManager::getEvent(); void putEvent(YazSocketEvent *event); void removeEvent(IYazSocketObserver *observer); + int m_log; public: /// Add an observer virtual void addObserver(int fd, IYazSocketObserver *observer); diff --git a/include/yaz-z-assoc.h b/include/yaz-z-assoc.h index f02468d..d4d67eb 100644 --- a/include/yaz-z-assoc.h +++ b/include/yaz-z-assoc.h @@ -3,11 +3,11 @@ * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * - * $Id: yaz-z-assoc.h,v 1.4 1999-09-13 12:53:44 adam Exp $ + * $Id: yaz-z-assoc.h,v 1.5 1999-12-06 13:52:45 adam Exp $ */ -#include -#include +#include +#include #include /** Z39.50 Assocation. @@ -23,11 +23,11 @@ class YAZ_EXPORT Yaz_Z_Assoc : public IYaz_PDU_Observer { /// Receive PDU void recv_PDU(const char *buf, int len); /// Connect notification - void connectNotify(); + virtual void connectNotify() = 0; /// Failure notification - void failNotify(); + virtual void failNotify() = 0; /// Timeout notification - void timeoutNotify(); + virtual void timeoutNotify() = 0; /// Timeout specify void timeout(int timeout); /// Begin Z39.50 client role @@ -76,4 +76,5 @@ class YAZ_EXPORT Yaz_Z_Assoc : public IYaz_PDU_Observer { ODR m_odr_in; ODR m_odr_out; ODR m_odr_print; + int m_log; }; diff --git a/include/yaz-z-query.h b/include/yaz-z-query.h index 9af3fff..f9c428d 100644 --- a/include/yaz-z-query.h +++ b/include/yaz-z-query.h @@ -3,10 +3,10 @@ * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * - * $Id: yaz-z-query.h,v 1.5 1999-04-27 07:52:13 adam Exp $ + * $Id: yaz-z-query.h,v 1.6 1999-12-06 13:52:45 adam Exp $ */ -#include +#include #include /** Z39.50 Query diff --git a/src/Makefile.in b/src/Makefile.in index bf9ae4b..8e18d44 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,7 +1,7 @@ # Copyright (C) 1999, Index Data ApS # All rights reserved. # Sebastian Hammer, Adam Dickmeiss -# $Id: Makefile.in,v 1.5 1999-07-12 07:57:27 adam Exp $ +# $Id: Makefile.in,v 1.6 1999-12-06 13:52:45 adam Exp $ SHELL=/bin/sh @@ -13,12 +13,10 @@ RANLIB=@RANLIB@ CDEFS=@DEFS@ LIBS=@LIBS@ -LIBDIR=../../yaz/lib - -INCLUDE=-I../../yaz/include -I../include +YAZLIB=@YAZLIB@ +INCLUDE=-I../include @YAZINC@ DEFS=$(INCLUDE) $(CDEFS) -YAZLIBS=$(LIBDIR)/libyaz.a -PROG1=yaz-client +PROG1=yaz-clientx PROGO1=yaz-client.o PROG2=yaz-server PROGO2=yaz-server.o @@ -37,14 +35,14 @@ $(LIB): $(PO) ar qc $(LIB) $(PO) $(RANLIB) $(LIB) -$(PROG1): $(PROGO1) $(YAZLIBS) $(LIB) - $(CXX) $(CXXFLAGS) -o $(PROG1) $(PROGO1) $(LIB) $(YAZLIBS) $(LIBS) +$(PROG1): $(PROGO1) $(LIB) + $(CXX) $(CXXFLAGS) -o $(PROG1) $(PROGO1) $(LIB) $(YAZLIB) $(LIBS) -$(PROG2): $(PROGO2) $(YAZLIBS) $(LIB) - $(CXX) $(CXXFLAGS) -o $(PROG2) $(PROGO2) $(LIB) $(YAZLIBS) $(LIBS) +$(PROG2): $(PROGO2) $(LIB) + $(CXX) $(CXXFLAGS) -o $(PROG2) $(PROGO2) $(LIB) $(YAZLIB) $(LIBS) -$(PROG3): $(PROGO3) $(YAZLIBS) $(LIB) - $(CXX) $(CXXFLAGS) -o $(PROG3) $(PROGO3) $(LIB) $(YAZLIBS) $(LIBS) +$(PROG3): $(PROGO3) $(LIB) + $(CXX) $(CXXFLAGS) -o $(PROG3) $(PROGO3) $(LIB) $(YAZLIB) $(LIBS) alll: diff --git a/src/yaz-client.cpp b/src/yaz-client.cpp index 565652e..e7f66e8 100644 --- a/src/yaz-client.cpp +++ b/src/yaz-client.cpp @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: yaz-client.cpp,v $ - * Revision 1.8 1999-11-10 10:02:34 adam + * 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 @@ -33,9 +37,9 @@ * */ -#include -#include -#include +#include +#include +#include #include #include #include @@ -75,17 +79,42 @@ public: void recv_genericRecord(Z_GenericRecord *r); void display_genericRecord(Z_GenericRecord *r, int level); void display_variant(Z_Variant *v, int level); + void connectNotify(); + void failNotify(); + void timeoutNotify(); int processCommand(const char *cmd); const char *MyClient::getCommand(); int cmd_open(char *host); + int cmd_connect(char *host); int cmd_quit(char *args); int cmd_close(char *args); int cmd_find(char *args); int cmd_show(char *args); int cmd_cookie(char *args); int cmd_init(char *args); + int cmd_format(char *args); + int cmd_proxy(char *args); }; + +void MyClient::connectNotify() +{ + printf ("Connection accepted by target\n"); + set_lastReceived(-1); +} + +void MyClient::timeoutNotify() +{ + printf ("Connection timeout\n"); + close(); +} + +void MyClient::failNotify() +{ + printf ("Connection closed by target\n"); + set_lastReceived(-1); +} + IYaz_PDU_Observer *MyClient::clone(IYaz_PDU_Observable *the_PDU_Observable) { return new MyClient(the_PDU_Observable, m_socketManager); @@ -392,10 +421,23 @@ int MyClient::wait() #define C_PROMPT "Z>" +int MyClient::cmd_connect(char *host) +{ + client (host); + timeout (10); + wait (); + timeout (0); + return 1; +} + int MyClient::cmd_open(char *host) { client (host); - m_socketManager->processEvent(); + timeout (10); + wait (); + timeout (0); + send_initRequest(); + wait (); return 1; } @@ -430,6 +472,8 @@ int MyClient::cmd_find(char *args) } if (send_searchRequest(&query) >= 0) wait(); + else + printf ("Not connected\n"); return 1; } @@ -441,6 +485,8 @@ int MyClient::cmd_show(char *args) m_setOffset = start; if (send_presentRequest(start, number) >= 0) wait(); + else + printf ("Not connected\n"); return 1; } @@ -450,6 +496,18 @@ int MyClient::cmd_cookie(char *args) return 1; } +int MyClient::cmd_format(char *args) +{ + set_preferredRecordSyntax(args); + return 1; +} + +int MyClient::cmd_proxy(char *args) +{ + set_proxy(args); + return 1; +} + int MyClient::processCommand(const char *commandLine) { char cmdStr[1024], cmdArgs[1024]; @@ -461,12 +519,15 @@ int MyClient::processCommand(const char *commandLine) char *ad; } cmd[] = { {"open", &cmd_open, "[':'][/]"}, - {"quit", &cmd_quit, ""}, + {"connect", &cmd_connect, "[':'][/]"}, + {"quit", &cmd_quit, ""}, {"close", &cmd_close, ""}, {"find", &cmd_find, ""}, {"show", &cmd_show, "[ []]"}, {"cookie", &cmd_cookie, ""}, {"init", &cmd_init, ""}, + {"format", &cmd_format, ""}, + {"proxy", &cmd_proxy, ":[':']"}, {0,0,0} }; @@ -548,7 +609,7 @@ int MyClient::args(Yaz_SocketManager *socketManager, int argc, char **argv) char *prog = argv[0]; int ret; - while ((ret = options("p:v:q", argv, argc, &arg)) != -2) + while ((ret = options("c:p:v:q", argv, argc, &arg)) != -2) { switch (ret) { @@ -568,6 +629,9 @@ int MyClient::args(Yaz_SocketManager *socketManager, int argc, char **argv) } set_proxy(arg); break; + case 'c': + set_cookie(arg); + break; case 'v': log_init_level (log_mask_str(arg)); break; @@ -582,6 +646,9 @@ int MyClient::args(Yaz_SocketManager *socketManager, int argc, char **argv) if (host) { client (host); + timeout (10); + wait (); + timeout (0); send_initRequest(); wait (); } diff --git a/src/yaz-ir-assoc.cpp b/src/yaz-ir-assoc.cpp index a6eac26..358a616 100644 --- a/src/yaz-ir-assoc.cpp +++ b/src/yaz-ir-assoc.cpp @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: yaz-ir-assoc.cpp,v $ - * Revision 1.10 1999-04-29 07:33:28 adam + * 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. * @@ -28,7 +32,7 @@ #include -#include +#include #include Yaz_IR_Assoc::Yaz_IR_Assoc(IYaz_PDU_Observable *the_PDU_Observable) @@ -42,6 +46,7 @@ Yaz_IR_Assoc::Yaz_IR_Assoc(IYaz_PDU_Observable *the_PDU_Observable) m_host = 0; m_proxy = 0; m_cookie = 0; + m_log = LOG_DEBUG; const char *db = "Default"; set_databaseNames(1, &db); } @@ -65,7 +70,7 @@ void Yaz_IR_Assoc::get_databaseNames (int *num, char ***list) void Yaz_IR_Assoc::set_databaseNames (int num, const char **list) { int i; - logf (LOG_LOG, "Yaz_IR_Assoc::set_databaseNames num=%d", num); + logf (m_log, "Yaz_IR_Assoc::set_databaseNames num=%d", num); for (i = 0; iwhich; switch (apdu->which) { case Z_APDU_initResponse: - logf (LOG_LOG, "recv InitResponse"); + logf (m_log, "recv InitResponse"); recv_initResponse(apdu->u.initResponse); break; case Z_APDU_initRequest: - logf (LOG_LOG, "recv InitRequest"); + logf (m_log, "recv InitRequest"); recv_initRequest(apdu->u.initRequest); break; case Z_APDU_searchRequest: - logf (LOG_LOG, "recv searchRequest"); + logf (m_log, "recv searchRequest"); recv_searchRequest(apdu->u.searchRequest); break; case Z_APDU_searchResponse: - logf (LOG_LOG, "recv searchResponse"); + logf (m_log, "recv searchResponse"); recv_searchResponse(apdu->u.searchResponse); break; case Z_APDU_presentRequest: - logf (LOG_LOG, "recv presentRequest"); + logf (m_log, "recv presentRequest"); recv_presentRequest(apdu->u.presentRequest); break; case Z_APDU_presentResponse: - logf (LOG_LOG, "recv presentResponse"); + logf (m_log, "recv presentResponse"); recv_presentResponse(apdu->u.presentResponse); break; } @@ -221,7 +226,7 @@ int Yaz_IR_Assoc::send_searchRequest(Yaz_Z_Query *query) oid_ent_to_oid(&prefsyn, oid_syntax); req->preferredRecordSyntax = oid_syntax; } - logf (LOG_LOG, "send_searchRequest"); + logf (m_log, "send_searchRequest"); assert (req->otherInfo == 0); if (m_cookie) { diff --git a/src/yaz-pdu-assoc.cpp b/src/yaz-pdu-assoc.cpp index c7475fc..c0b70c3 100644 --- a/src/yaz-pdu-assoc.cpp +++ b/src/yaz-pdu-assoc.cpp @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: yaz-pdu-assoc.cpp,v $ - * Revision 1.8 1999-04-28 13:04:03 adam + * 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 @@ -37,14 +41,13 @@ #include -#include -#include +#include +#include -Yaz_PDU_Assoc::Yaz_PDU_Assoc(IYazSocketObservable *socketObservable, - COMSTACK cs) +Yaz_PDU_Assoc::Yaz_PDU_Assoc(IYazSocketObservable *socketObservable) { m_state = Closed; - m_cs = cs; + m_cs = 0; m_socketObservable = socketObservable; m_PDU_Observer = 0; m_queue_out = 0; @@ -54,11 +57,13 @@ Yaz_PDU_Assoc::Yaz_PDU_Assoc(IYazSocketObservable *socketObservable, m_parent = 0; m_next = 0; m_destroyed = 0; + m_idleTime = 0; + m_log = LOG_DEBUG; } IYaz_PDU_Observable *Yaz_PDU_Assoc::clone() { - Yaz_PDU_Assoc *copy = new Yaz_PDU_Assoc(m_socketObservable, 0); + Yaz_PDU_Assoc *copy = new Yaz_PDU_Assoc(m_socketObservable); return copy; } @@ -69,8 +74,8 @@ Yaz_PDU_Assoc::~Yaz_PDU_Assoc() void Yaz_PDU_Assoc::socketNotify(int event) { - logf (LOG_LOG, "Yaz_PDU_Assoc::socketNotify p=%p event = %d", this, event); - if (m_state == Connected) + logf (m_log, "Yaz_PDU_Assoc::socketNotify p=%p event = %d", this, event); + if (0 /* m_state == Connected */) { m_state = Ready; m_socketObservable->maskObserver(this, YAZ_SOCKET_OBSERVE_READ| @@ -85,7 +90,11 @@ void Yaz_PDU_Assoc::socketNotify(int event) close(); m_PDU_Observer->failNotify(); } - else + else if (event & YAZ_SOCKET_OBSERVE_TIMEOUT) + { + m_PDU_Observer->timeoutNotify(); + } + else { m_state = Ready; m_socketObservable->maskObserver(this, YAZ_SOCKET_OBSERVE_READ| @@ -111,20 +120,26 @@ void Yaz_PDU_Assoc::socketNotify(int event) if (!(new_line = cs_accept(m_cs))) return; - Yaz_PDU_Assoc *assoc = new Yaz_PDU_Assoc (m_socketObservable, - new_line); + /* 1. create socket-manager + 2. create pdu-assoc + 3. create top-level object + setup observer for child fileid in pdu-assoc + 4. start thread + */ + int fd = cs_fileno(new_line); + cs_fileno(new_line) = -1; + cs_close (new_line); +#if 1 + childNotify(fd); +#else + Yaz_PDU_Assoc *assoc = new Yaz_PDU_Assoc (m_socketObservable); assoc->m_parent = this; assoc->m_next = m_children; m_children = assoc; - + assoc->m_PDU_Observer = m_PDU_Observer->clone(assoc); - assoc->m_state = Ready; - assoc->m_socketObservable->addObserver(cs_fileno(new_line), assoc); - assoc->m_socketObservable->maskObserver(assoc, - YAZ_SOCKET_OBSERVE_READ| - YAZ_SOCKET_OBSERVE_EXCEPT); - assoc->m_socketObservable->timeoutObserver(assoc, - assoc->m_idleTime); + socket(fd); +#endif } } else if (m_state == Ready) @@ -142,7 +157,7 @@ void Yaz_PDU_Assoc::socketNotify(int event) return; else if (res <= 0) { - logf (LOG_LOG, "Connection closed by client"); + logf (m_log, "Connection closed by peer"); close(); m_PDU_Observer->failNotify(); return; @@ -169,7 +184,7 @@ void Yaz_PDU_Assoc::close() m_state = Closed; if (m_cs) { - logf (LOG_LOG, "Yaz_PDU_Assoc::close fd=%d", cs_fileno(m_cs)); + logf (m_log, "Yaz_PDU_Assoc::close fd=%d", cs_fileno(m_cs)); cs_close (m_cs); } m_cs = 0; @@ -230,9 +245,10 @@ int Yaz_PDU_Assoc::flush_PDU() { int r; - logf (LOG_LOG, "Yaz_PDU_Assoc::flush_PDU"); + logf (m_log, "Yaz_PDU_Assoc::flush_PDU"); if (m_state != Ready) { + logf (m_log, "YAZ_PDU_Assoc::flush_PDU, not ready"); return 1; } PDU_Queue *q = m_queue_out; @@ -254,11 +270,11 @@ int Yaz_PDU_Assoc::flush_PDU() m_socketObservable->maskObserver(this, YAZ_SOCKET_OBSERVE_READ| YAZ_SOCKET_OBSERVE_EXCEPT| YAZ_SOCKET_OBSERVE_WRITE); - logf (LOG_LOG, "Yaz_PDU_Assoc::flush_PDU put %d bytes (incomplete)", + logf (m_log, "Yaz_PDU_Assoc::flush_PDU put %d bytes (incomplete)", q->m_len); return r; } - logf (LOG_LOG, "Yaz_PDU_Assoc::flush_PDU put %d bytes", q->m_len); + logf (m_log, "Yaz_PDU_Assoc::flush_PDU put %d bytes", q->m_len); // whole packet sent... delete this and proceed to next ... m_queue_out = q->m_next; delete q; @@ -271,13 +287,13 @@ int Yaz_PDU_Assoc::flush_PDU() int Yaz_PDU_Assoc::send_PDU(const char *buf, int len) { - logf (LOG_LOG, "Yaz_PDU_Assoc::send_PDU"); + logf (m_log, "Yaz_PDU_Assoc::send_PDU"); PDU_Queue **pq = &m_queue_out; int is_idle = (*pq ? 0 : 1); if (!m_cs) { - logf (LOG_LOG, "Yaz_PDU_Assoc::send_PDU failed, m_cs == 0"); + logf (m_log, "Yaz_PDU_Assoc::send_PDU failed, m_cs == 0"); return -1; } while (*pq) @@ -286,7 +302,7 @@ int Yaz_PDU_Assoc::send_PDU(const char *buf, int len) if (is_idle) return flush_PDU (); else - logf (LOG_LOG, "Yaz_PDU_Assoc::cannot send_PDU fd=%d", + logf (m_log, "Yaz_PDU_Assoc::cannot send_PDU fd=%d", cs_fileno(m_cs)); return 0; } @@ -296,8 +312,7 @@ COMSTACK Yaz_PDU_Assoc::comstack() if (!m_cs) { CS_TYPE cs_type = tcpip_type; - int protocol = PROTO_Z3950; - m_cs = cs_create (cs_type, 0, protocol); + m_cs = cs_create (cs_type, 0, PROTO_Z3950); } return m_cs; } @@ -309,7 +324,7 @@ void Yaz_PDU_Assoc::listen(IYaz_PDU_Observer *observer, void *ap; COMSTACK cs = comstack(); - logf (LOG_LOG, "Yaz_PDU_Assoc::listen %s", addr); + logf (m_log, "Yaz_PDU_Assoc::listen %s", addr); m_PDU_Observer = observer; if (!cs) return; @@ -327,54 +342,98 @@ void Yaz_PDU_Assoc::listen(IYaz_PDU_Observer *observer, void Yaz_PDU_Assoc::idleTime(int idleTime) { m_idleTime = idleTime; - logf (LOG_LOG, "Yaz_PDU_Assoc::idleTime(%d)", idleTime); + logf (m_log, "Yaz_PDU_Assoc::idleTime(%d)", idleTime); m_socketObservable->timeoutObserver(this, m_idleTime); } void Yaz_PDU_Assoc::connect(IYaz_PDU_Observer *observer, const char *addr) { - logf (LOG_LOG, "Yaz_PDU_Assoc::connect %s", addr); + logf (m_log, "Yaz_PDU_Assoc::connect %s", addr); close(); m_PDU_Observer = observer; COMSTACK cs = comstack(); void *ap = cs_straddr (cs, addr); if (!ap) { - logf (LOG_LOG, "cs_straddr failed"); + logf (m_log, "cs_straddr failed"); return; } int res = cs_connect (cs, ap); - if (res < 0) + logf (m_log, "Yaz_PDU_Assoc::connect fd=%d res=%d", cs_fileno(cs), res); + m_socketObservable->addObserver(cs_fileno(cs), this); + m_socketObservable->maskObserver(this, YAZ_SOCKET_OBSERVE_READ| + YAZ_SOCKET_OBSERVE_EXCEPT| + YAZ_SOCKET_OBSERVE_WRITE); + m_state = Connecting; +} + +void Yaz_PDU_Assoc::socket(IYaz_PDU_Observer *observer, int fd) +{ + close(); + m_PDU_Observer = observer; + if (fd >= 0) { - logf (LOG_LOG|LOG_ERRNO, "Yaz_PDU_Assoc::connect failed"); + CS_TYPE cs_type = tcpip_type; + m_cs = cs_createbysocket(fd, cs_type, 0, PROTO_Z3950); + m_state = Ready; + m_socketObservable->addObserver(fd, this); + m_socketObservable->maskObserver(this, + YAZ_SOCKET_OBSERVE_READ| + YAZ_SOCKET_OBSERVE_EXCEPT); + m_socketObservable->timeoutObserver(this, m_idleTime); + } +} + #if 1 - logf (LOG_LOG, "Yaz_PDU_Assoc::connect fd=%d", cs_fileno(cs)); - m_socketObservable->addObserver(cs_fileno(cs), this); - m_socketObservable->maskObserver(this, YAZ_SOCKET_OBSERVE_READ| - YAZ_SOCKET_OBSERVE_EXCEPT| - YAZ_SOCKET_OBSERVE_WRITE); - m_state = Connecting; +void Yaz_PDU_Assoc::childNotify(int fd) +{ + /// Clone PDU Observable (keep socket manager) + IYaz_PDU_Observable *new_observable = clone(); + + /// Clone PDU Observer + IYaz_PDU_Observer *observer = m_PDU_Observer->clone(new_observable); + + /// Attach new socket to it + new_observable->socket(observer, fd); +} #else - close (); -#endif - } - else - { - logf (LOG_LOG, "Yaz_PDU_Assoc::connect fd=%d", cs_fileno(cs)); - m_socketObservable->addObserver(cs_fileno(cs), this); - m_socketObservable->maskObserver(this, YAZ_SOCKET_OBSERVE_READ| - YAZ_SOCKET_OBSERVE_EXCEPT| - YAZ_SOCKET_OBSERVE_WRITE); - if (res == 1) - { - logf (LOG_LOG, "Yaz_PDU_Assoc::connect pending"); - m_state = Connecting; - } - else - { - logf (LOG_LOG, "Yaz_PDU_Assoc::Connect complete"); - m_state = Connected; - } - } + +#include +#include + +class thread_info { + Yaz_SocketManager *socketManager; + IYaz_PDU_Observable * + +}; + +static void *events(void *p) +{ + Yaz_SocketManager *s = (Yaz_SocketManager *) p; + + while (s->processEvent() > 0) + ; + return 0; } + +void Yaz_PDU_Assoc::childNotify(int fd) +{ + Yaz_SocketManager *socket_observable = new Yaz_SocketManager; + IYaz_PDU_Observable *new_observable = clone(); + + m_socketObservable = socket_observable; + + /// Clone PDU Observer + IYaz_PDU_Observer *observer = m_PDU_Observer->clone(new_observable); + + /// Attach new socket to it + new_observable->socket(observer, fd); + + pthread_t type; + + int id = pthread_create (&type, 0, events, socket_observable); + logf (LOG_LOG, "pthread_create returned id=%d", id); +} +#endif + diff --git a/src/yaz-proxy-main.cpp b/src/yaz-proxy-main.cpp index 2f41054..126b5bb 100644 --- a/src/yaz-proxy-main.cpp +++ b/src/yaz-proxy-main.cpp @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: yaz-proxy-main.cpp,v $ - * Revision 1.6 1999-11-10 10:02:34 adam + * 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 @@ -26,8 +30,8 @@ * */ -#include -#include +#include +#include #include #include @@ -47,7 +51,7 @@ int args(Yaz_Proxy *proxy, int argc, char **argv) char *prog = argv[0]; int ret; - while ((ret = options("p:v:q", argv, argc, &arg)) != -2) + while ((ret = options("t:v:", argv, argc, &arg)) != -2) { switch (ret) { @@ -60,7 +64,7 @@ int args(Yaz_Proxy *proxy, int argc, char **argv) addr = arg; break; case 't': - proxy->proxyTarget(arg); + proxy->set_proxyTarget(arg); break; case 'v': log_init_level (log_mask_str(arg)); @@ -74,10 +78,14 @@ int args(Yaz_Proxy *proxy, int argc, char **argv) { proxy->server(addr); } + else + { + usage(prog); + return 1; + } return 0; } - int main(int argc, char **argv) { Yaz_SocketManager mySocketManager; diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index 9d2e555..b985cd1 100644 --- a/src/yaz-proxy.cpp +++ b/src/yaz-proxy.cpp @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: yaz-proxy.cpp,v $ - * Revision 1.10 1999-11-10 10:02:34 adam + * 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 @@ -42,8 +46,7 @@ #include -#include - +#include #include Yaz_Proxy::Yaz_Proxy(IYaz_PDU_Observable *the_PDU_Observable) : @@ -64,7 +67,7 @@ Yaz_Proxy::~Yaz_Proxy() } -void Yaz_Proxy::proxyTarget(const char *target) +void Yaz_Proxy::set_proxyTarget(const char *target) { xfree (m_proxyTarget); m_proxyTarget = 0; @@ -77,7 +80,8 @@ IYaz_PDU_Observer *Yaz_Proxy::clone(IYaz_PDU_Observable { Yaz_Proxy *new_proxy = new Yaz_Proxy(the_PDU_Observable); new_proxy->m_parent = this; - new_proxy->timeout(120); + new_proxy->timeout(20); + new_proxy->set_proxyTarget(m_proxyTarget); return new_proxy; } @@ -132,25 +136,31 @@ Yaz_ProxyClient *Yaz_Proxy::get_client(Z_APDU *apdu) assert (*c->m_prev == c); if (!strcmp(cookie,c->m_cookie)) { - logf (LOG_LOG, "Yaz_Proxy::get_client cached"); + logf (LOG_LOG, "Yaz_Proxy::get_client found cached target"); return c; } - } - + } } if (!m_client) { - const char *proxy_host = 0; if (apdu->which == Z_APDU_initRequest) { logf (LOG_LOG, "got InitRequest"); - char *proxy_host = get_proxy(&apdu->u.initRequest->otherInfo); - if (!proxy_host) - proxy_host = m_proxyTarget; - if (!proxy_host) - return 0; + const char *proxy_host = + get_proxy(&apdu->u.initRequest->otherInfo); + if (proxy_host) + set_proxyTarget(proxy_host); + logf (LOG_LOG, "proxy_host = %s", m_proxyTarget ? + m_proxyTarget:"none"); + } + else + { + logf (LOG_LOG, "no first INIT!"); + return 0; } + if (!m_proxyTarget) + return 0; logf (LOG_LOG, "Yaz_Proxy::get_client creating new"); c = new Yaz_ProxyClient(m_PDU_Observable->clone()); c->m_next = parent->m_clientPool; @@ -162,12 +172,7 @@ Yaz_ProxyClient *Yaz_Proxy::get_client(Z_APDU *apdu) sprintf (c->m_cookie, "%d", parent->m_seqno); (parent->m_seqno)++; - if (apdu->which == Z_APDU_initRequest) - { - logf (LOG_LOG, "got InitRequest"); - - c->client(proxy_host); - } + c->client(m_proxyTarget); c->timeout(600); } return c; @@ -289,9 +294,13 @@ void Yaz_Proxy::recv_Z_PDU(Z_APDU *apdu) } } -void Yaz_Proxy::failNotify() +void Yaz_Proxy::connectNotify() { - logf (LOG_LOG, "failNotity server"); +} + +void Yaz_Proxy::shutdown() +{ + logf (LOG_LOG, "shutdown (client to proxy)"); if (m_keepalive) { // Tell client (if any) that no server connection is there.. @@ -305,13 +314,30 @@ void Yaz_Proxy::failNotify() delete this; } -void Yaz_ProxyClient::failNotify() +void Yaz_ProxyClient::shutdown() { - logf (LOG_LOG, "failNotity client"); + logf (LOG_LOG, "shutdown (proxy to server)"); delete m_server; delete this; } +void Yaz_Proxy::failNotify() +{ + logf (LOG_LOG, "connection closed by client"); + shutdown(); +} + +void Yaz_ProxyClient::failNotify() +{ + logf (LOG_LOG, "connection closed by server"); + shutdown(); +} + +void Yaz_ProxyClient::connectNotify() +{ + logf (LOG_LOG, "connection accepted by target"); +} + IYaz_PDU_Observer *Yaz_ProxyClient::clone(IYaz_PDU_Observable *the_PDU_Observable) { @@ -331,12 +357,14 @@ Yaz_ProxyClient::~Yaz_ProxyClient() void Yaz_Proxy::timeoutNotify() { - failNotify(); + logf (LOG_LOG, "timeout (client to proxy)"); + shutdown(); } void Yaz_ProxyClient::timeoutNotify() { - failNotify(); + logf (LOG_LOG, "timeout (proxy to target)"); + shutdown(); } Yaz_ProxyClient::Yaz_ProxyClient(IYaz_PDU_Observable *the_PDU_Observable) : diff --git a/src/yaz-server.cpp b/src/yaz-server.cpp index ec6133d..0cbf801 100644 --- a/src/yaz-server.cpp +++ b/src/yaz-server.cpp @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: yaz-server.cpp,v $ - * Revision 1.6 1999-04-21 12:09:01 adam + * 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. * @@ -26,7 +30,7 @@ * */ -#include +#include #include #include #include @@ -38,6 +42,7 @@ public: IYaz_PDU_Observer* clone(IYaz_PDU_Observable *the_PDU_Observable); void failNotify(); void timeoutNotify(); + void connectNotify(); private: int m_no; }; @@ -96,10 +101,14 @@ void MyServer::failNotify() delete this; } +void MyServer::connectNotify() +{ +} + int main(int argc, char **argv) { Yaz_SocketManager mySocketManager; - Yaz_PDU_Assoc *my_PDU_Assoc = new Yaz_PDU_Assoc(&mySocketManager, 0); + Yaz_PDU_Assoc *my_PDU_Assoc = new Yaz_PDU_Assoc(&mySocketManager); MyServer z(my_PDU_Assoc); diff --git a/src/yaz-socket-manager.cpp b/src/yaz-socket-manager.cpp index 3f5178b..099ec76 100644 --- a/src/yaz-socket-manager.cpp +++ b/src/yaz-socket-manager.cpp @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: yaz-socket-manager.cpp,v $ - * Revision 1.7 1999-04-28 13:02:08 adam + * 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 @@ -39,7 +43,7 @@ #include #include -#include +#include #include @@ -121,7 +125,7 @@ int Yaz_SocketManager::processEvent() YazSocketEntry *p; YazSocketEvent *event = getEvent(); unsigned timeout = 0; - logf (LOG_LOG, "processEvent"); + logf (m_log, "processEvent"); if (event) { event->observer->socketNotify(event->event); @@ -166,9 +170,9 @@ int Yaz_SocketManager::processEvent() } if (!no) { - logf (LOG_LOG, "no pending events return 0"); + logf (m_log, "no pending events return 0"); if (!m_observers) - logf (LOG_LOG, "no observers"); + logf (m_log, "no observers"); return 0; } @@ -176,7 +180,7 @@ int Yaz_SocketManager::processEvent() to.tv_sec = timeout; to.tv_usec = 0; - logf (LOG_LOG, "timeout=%d", timeout); + logf (m_log, "select pending=%d timeout=%d", no, timeout); while ((res = select(max + 1, &in, &out, &except, timeout ? &to : 0)) < 0) if (errno != EINTR) return -1; @@ -283,6 +287,7 @@ Yaz_SocketManager::Yaz_SocketManager() m_observers = 0; m_queue_front = 0; m_queue_back = 0; + m_log = LOG_DEBUG; } Yaz_SocketManager::~Yaz_SocketManager() diff --git a/src/yaz-z-assoc.cpp b/src/yaz-z-assoc.cpp index f9a9596..8d46e5a 100644 --- a/src/yaz-z-assoc.cpp +++ b/src/yaz-z-assoc.cpp @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: yaz-z-assoc.cpp,v $ - * Revision 1.5 1999-11-10 10:02:34 adam + * 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 @@ -26,15 +30,13 @@ #include -#include +#include #include -#include +#include int Yaz_Z_Assoc::yaz_init_func() { - logf (LOG_LOG, "nmem_init"); nmem_init(); - logf (LOG_LOG, "done"); return 1; } @@ -46,6 +48,7 @@ Yaz_Z_Assoc::Yaz_Z_Assoc(IYaz_PDU_Observable *the_PDU_Observable) m_odr_in = odr_createmem (ODR_DECODE); m_odr_out = odr_createmem (ODR_ENCODE); m_odr_print = odr_createmem (ODR_PRINT); + m_log = LOG_DEBUG; } Yaz_Z_Assoc::~Yaz_Z_Assoc() @@ -59,7 +62,7 @@ Yaz_Z_Assoc::~Yaz_Z_Assoc() void Yaz_Z_Assoc::recv_PDU(const char *buf, int len) { - logf (LOG_LOG, "recv_PDU len=%d", len); + logf (m_log, "recv_PDU len=%d", len); Z_APDU *apdu = decode_Z_PDU (buf, len); if (apdu) { @@ -85,7 +88,6 @@ int Yaz_Z_Assoc::send_Z_PDU(Z_APDU *apdu) { char *buf; int len; - logf (LOG_LOG, "Yaz_Z_Assoc:send_Z_PDU"); if (encode_Z_PDU(apdu, &buf, &len) > 0) return m_PDU_Observable->send_PDU(buf, len); return -1; @@ -127,21 +129,6 @@ int Yaz_Z_Assoc::encode_Z_PDU(Z_APDU *apdu, char **buf, int *len) return *len; } -void Yaz_Z_Assoc::connectNotify() -{ - logf (LOG_LOG, "connectNotify"); -} - -void Yaz_Z_Assoc::failNotify() -{ - logf (LOG_LOG, "failNotify"); -} - -void Yaz_Z_Assoc::timeoutNotify() -{ - logf (LOG_LOG, "timeoutNotify"); -} - void Yaz_Z_Assoc::client(const char *addr) { m_PDU_Observable->connect (this, addr); @@ -176,6 +163,7 @@ void Yaz_Z_Assoc::timeout(int timeout) m_PDU_Observable->idleTime(timeout); } + void Yaz_Z_Assoc::get_otherInfoAPDU(Z_APDU *apdu, Z_OtherInformation ***oip) { switch (apdu->which) diff --git a/src/yaz-z-query.cpp b/src/yaz-z-query.cpp index c375ea6..c06246f 100644 --- a/src/yaz-z-query.cpp +++ b/src/yaz-z-query.cpp @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: yaz-z-query.cpp,v $ - * Revision 1.5 1999-04-27 07:52:13 adam + * 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 @@ -24,7 +28,7 @@ */ #include -#include +#include Yaz_Z_Query::Yaz_Z_Query() { diff --git a/unix/configure b/unix/configure index f9fa7e4..af8736b 100755 --- a/unix/configure +++ b/unix/configure @@ -1,7 +1,7 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.12 +# Generated automatically using autoconf version 2.13 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation @@ -12,7 +12,7 @@ ac_help= ac_default_prefix=/usr/local # Any additions from configure.in: ac_help="$ac_help - --enable-threads enable threads if available" + --with-yazconfig Path for yaz-config" # Initialize some variables set by options. # The variables have the same names as the options, with @@ -51,6 +51,7 @@ mandir='${prefix}/man' # Initialize some other variables. subdirs= MFLAGS= MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. ac_max_here_lines=12 @@ -334,7 +335,7 @@ EOF verbose=yes ;; -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.12" + echo "configure generated by autoconf version 2.13" exit 0 ;; -with-* | --with-*) @@ -504,9 +505,11 @@ ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross +ac_exeext= +ac_objext=o if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then @@ -523,15 +526,16 @@ fi # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:527: checking for $ac_word" >&5 +echo "configure:530: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="gcc" @@ -552,16 +556,17 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:556: checking for $ac_word" >&5 +echo "configure:560: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_prog_rejected=no - for ac_dir in $PATH; do + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then @@ -596,25 +601,61 @@ else echo "$ac_t""no" 1>&6 fi + if test -z "$CC"; then + case "`uname -s`" in + *win32* | *WIN32*) + # Extract the first word of "cl", so it can be a program name with args. +set dummy cl; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:611: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="cl" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + ;; + esac + fi test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:604: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:643: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross -cat > conftest.$ac_ext < conftest.$ac_ext << EOF + +#line 654 "configure" #include "confdefs.h" + main(){return(0);} EOF -if { (eval echo configure:618: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:659: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -628,18 +669,24 @@ else ac_cv_prog_cc_works=no fi rm -fr conftest* +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:638: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:685: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:643: checking whether we are using GNU C" >&5 +echo "configure:690: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -648,7 +695,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:652: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:699: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -659,11 +706,15 @@ echo "$ac_t""$ac_cv_prog_gcc" 1>&6 if test $ac_cv_prog_gcc = yes; then GCC=yes - ac_test_CFLAGS="${CFLAGS+set}" - ac_save_CFLAGS="$CFLAGS" - CFLAGS= - echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:667: checking whether ${CC-cc} accepts -g" >&5 +else + GCC= +fi + +ac_test_CFLAGS="${CFLAGS+set}" +ac_save_CFLAGS="$CFLAGS" +CFLAGS= +echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +echo "configure:718: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -678,32 +729,37 @@ rm -f conftest* fi echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 - if test "$ac_test_CFLAGS" = set; then - CFLAGS="$ac_save_CFLAGS" - elif test $ac_cv_prog_cc_g = yes; then +if test "$ac_test_CFLAGS" = set; then + CFLAGS="$ac_save_CFLAGS" +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then CFLAGS="-g -O2" else - CFLAGS="-O2" + CFLAGS="-g" fi else - GCC= - test "${CFLAGS+set}" = set || CFLAGS="-g" + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi fi -for ac_prog in $CCC c++ g++ gcc CC cxx cc++ +for ac_prog in $CCC c++ g++ gcc CC cxx cc++ cl do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:699: checking for $ac_word" >&5 +echo "configure:754: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CXX="$ac_prog" @@ -726,21 +782,23 @@ test -n "$CXX" || CXX="gcc" echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:730: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5 +echo "configure:786: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5 ac_ext=C # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CXX-g++} -o conftest $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cxx_cross -cat > conftest.$ac_ext < conftest.$ac_ext << EOF + +#line 797 "configure" #include "confdefs.h" -main(){return(0);} + +int main(){return(0);} EOF -if { (eval echo configure:744: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:802: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cxx_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -758,7 +816,7 @@ ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross echo "$ac_t""$ac_cv_prog_cxx_works" 1>&6 @@ -766,12 +824,12 @@ if test $ac_cv_prog_cxx_works = no; then { echo "configure: error: installation or configuration problem: C++ compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:770: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:828: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cxx_cross" 1>&6 cross_compiling=$ac_cv_prog_cxx_cross echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6 -echo "configure:775: checking whether we are using GNU C++" >&5 +echo "configure:833: checking whether we are using GNU C++" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -780,7 +838,7 @@ else yes; #endif EOF -if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:784: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:842: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gxx=yes else ac_cv_prog_gxx=no @@ -791,11 +849,15 @@ echo "$ac_t""$ac_cv_prog_gxx" 1>&6 if test $ac_cv_prog_gxx = yes; then GXX=yes - ac_test_CXXFLAGS="${CXXFLAGS+set}" - ac_save_CXXFLAGS="$CXXFLAGS" - CXXFLAGS= - echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6 -echo "configure:799: checking whether ${CXX-g++} accepts -g" >&5 +else + GXX= +fi + +ac_test_CXXFLAGS="${CXXFLAGS+set}" +ac_save_CXXFLAGS="$CXXFLAGS" +CXXFLAGS= +echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6 +echo "configure:861: checking whether ${CXX-g++} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -810,20 +872,24 @@ rm -f conftest* fi echo "$ac_t""$ac_cv_prog_cxx_g" 1>&6 - if test "$ac_test_CXXFLAGS" = set; then - CXXFLAGS="$ac_save_CXXFLAGS" - elif test $ac_cv_prog_cxx_g = yes; then +if test "$ac_test_CXXFLAGS" = set; then + CXXFLAGS="$ac_save_CXXFLAGS" +elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then CXXFLAGS="-g -O2" else - CXXFLAGS="-O2" + CXXFLAGS="-g" fi else - GXX= - test "${CXXFLAGS+set}" = set || CXXFLAGS="-g" + if test "$GXX" = yes; then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi fi echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:827: checking how to run the C preprocessor" >&5 +echo "configure:893: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -838,14 +904,14 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:848: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` +{ (eval echo configure:914: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else @@ -855,14 +921,31 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:931: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -nologo -E" + cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:865: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` +{ (eval echo configure:948: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else @@ -875,6 +958,8 @@ fi rm -f conftest* fi rm -f conftest* +fi +rm -f conftest* ac_cv_prog_CPP="$CPP" fi CPP="$ac_cv_prog_CPP" @@ -884,7 +969,7 @@ fi echo "$ac_t""$CPP" 1>&6 echo $ac_n "checking how to run the C++ preprocessor""... $ac_c" 1>&6 -echo "configure:888: checking how to run the C++ preprocessor" >&5 +echo "configure:973: checking how to run the C++ preprocessor" >&5 if test -z "$CXXCPP"; then if eval "test \"`echo '$''{'ac_cv_prog_CXXCPP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -893,17 +978,17 @@ else # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CXX-g++} -o conftest $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cxx_cross CXXCPP="${CXX-g++} -E" cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:906: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` +{ (eval echo configure:991: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else @@ -919,7 +1004,7 @@ ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross fi fi @@ -952,28 +1037,30 @@ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:960: checking for a BSD compatible install" >&5 +echo "configure:1046: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else - IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:" + IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" for ac_dir in $PATH; do # Account for people who put trailing slashes in PATH elements. case "$ac_dir/" in /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. - for ac_prog in ginstall installbsd scoinst install; do + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do if test -f $ac_dir/$ac_prog; then if test $ac_prog = install && grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. - # OSF/1 installbsd also uses dspmsg, but is usable. : else ac_cv_path_install="$ac_dir/$ac_prog -c" @@ -1003,20 +1090,23 @@ echo "$ac_t""$INSTALL" 1>&6 # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' + test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1012: checking for $ac_word" >&5 +echo "configure:1101: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_RANLIB="ranlib" @@ -1034,484 +1124,72 @@ else echo "$ac_t""no" 1>&6 fi -checkBoth=0 -echo $ac_n "checking for connect""... $ac_c" 1>&6 -echo "configure:1040: checking for connect" >&5 -if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char connect(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_connect) || defined (__stub___connect) -choke me -#else -connect(); -#endif - -; return 0; } -EOF -if { (eval echo configure:1068: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - eval "ac_cv_func_connect=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_connect=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'connect`\" = yes"; then - echo "$ac_t""yes" 1>&6 - : -else - echo "$ac_t""no" 1>&6 -fi - -if test "$ac_cv_func_connect" = "no"; then - echo $ac_n "checking for main in -lsocket""... $ac_c" 1>&6 -echo "configure:1089: checking for main in -lsocket" >&5 -ac_lib_var=`echo socket'_'main | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lsocket $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - LIBS="$LIBS -lsocket" -else - echo "$ac_t""no" 1>&6 -checkBoth=1 +yazconfig=NONE +yazpath=NONE +# Check whether --with-yazconfig or --without-yazconfig was given. +if test "${with_yazconfig+set}" = set; then + withval="$with_yazconfig" + yazpath=$withval fi -fi -if test "$checkBoth" = "1"; then - oldLibs=$LIBS - LIBS="$LIBS -lsocket -lnsl" - echo $ac_n "checking for accept""... $ac_c" 1>&6 -echo "configure:1130: checking for accept" >&5 -if eval "test \"`echo '$''{'ac_cv_func_accept'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +if test "x$yazpath" != "xNONE"; then + yazconfig=$yazpath/yaz-config else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char accept(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_accept) || defined (__stub___accept) -choke me -#else -accept(); -#endif - -; return 0; } -EOF -if { (eval echo configure:1158: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - eval "ac_cv_func_accept=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_accept=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'accept`\" = yes"; then - echo "$ac_t""yes" 1>&6 - : -else - echo "$ac_t""no" 1>&6 -LIBS=$oldLibs -fi - -fi -echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6 -echo "configure:1180: checking for gethostbyname" >&5 -if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char gethostbyname(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_gethostbyname) || defined (__stub___gethostbyname) -choke me -#else -gethostbyname(); -#endif - -; return 0; } -EOF -if { (eval echo configure:1208: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - eval "ac_cv_func_gethostbyname=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_gethostbyname=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'gethostbyname`\" = yes"; then - echo "$ac_t""yes" 1>&6 - : -else - echo "$ac_t""no" 1>&6 -echo $ac_n "checking for main in -lnsl""... $ac_c" 1>&6 -echo "configure:1226: checking for main in -lnsl" >&5 -ac_lib_var=`echo nsl'_'main | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lnsl $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - LIBS="$LIBS -lnsl" -else - echo "$ac_t""no" 1>&6 -fi - -fi - -echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:1264: checking for ANSI C header files" >&5 -if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -#include -#include -#include -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1277: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - rm -rf conftest* - ac_cv_header_stdc=yes -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_header_stdc=no -fi -rm -f conftest* - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. -cat > conftest.$ac_ext < -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "memchr" >/dev/null 2>&1; then - : -else - rm -rf conftest* - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. -cat > conftest.$ac_ext < -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "free" >/dev/null 2>&1; then - : -else - rm -rf conftest* - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. -if test "$cross_compiling" = yes; then - : -else - cat > conftest.$ac_ext < -#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int main () { int i; for (i = 0; i < 256; i++) -if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); -exit (0); } - -EOF -if { (eval echo configure:1344: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null -then - : -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - ac_cv_header_stdc=no -fi -rm -fr conftest* -fi - -fi -fi - -echo "$ac_t""$ac_cv_header_stdc" 1>&6 -if test $ac_cv_header_stdc = yes; then - cat >> confdefs.h <<\EOF -#define STDC_HEADERS 1 -EOF - -fi - -if test "$ac_cv_header_stdc" = "no"; then - echo "configure: warning: Your system doesn't seem to support ANSI C" 1>&2 -fi -# Check whether --enable-threads or --disable-threads was given. -if test "${enable_threads+set}" = set; then - enableval="$enable_threads" - threads_ok=$enableval -else - threads_ok=no -fi - -if test "$threads_ok" = "yes"; then - for ac_hdr in pthread.h threads.h -do -ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1383: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1393: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` - cat >> confdefs.h <&6 -fi -done - - echo $ac_n "checking for pthread_mutex_lock""... $ac_c" 1>&6 -echo "configure:1420: checking for pthread_mutex_lock" >&5 -if eval "test \"`echo '$''{'ac_cv_func_pthread_mutex_lock'+set}'`\" = set"; then + for i in ../../yaz* ../../yaz; do + if test -d $i; then + if test -r $i/include/yaz/yaz-version.h; then + yazconfig=$i/yaz-config + fi + fi + done + if test "x$yazconfig" = "xNONE"; then + # Extract the first word of "yaz-config", so it can be a program name with args. +set dummy yaz-config; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1152: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_yazconfig'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char pthread_mutex_lock(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_pthread_mutex_lock) || defined (__stub___pthread_mutex_lock) -choke me -#else -pthread_mutex_lock(); -#endif - -; return 0; } -EOF -if { (eval echo configure:1448: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - eval "ac_cv_func_pthread_mutex_lock=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_pthread_mutex_lock=no" -fi -rm -f conftest* + case "$yazconfig" in + /*) + ac_cv_path_yazconfig="$yazconfig" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_yazconfig="$yazconfig" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_yazconfig="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_yazconfig" && ac_cv_path_yazconfig="NONE" + ;; +esac fi - -if eval "test \"`echo '$ac_cv_func_'pthread_mutex_lock`\" = yes"; then - echo "$ac_t""yes" 1>&6 - : +yazconfig="$ac_cv_path_yazconfig" +if test -n "$yazconfig"; then + echo "$ac_t""$yazconfig" 1>&6 else echo "$ac_t""no" 1>&6 fi - if test "$ac_cv_func_pthread_mutex_lock" = "no"; then - echo $ac_n "checking for main in -lpthread""... $ac_c" 1>&6 -echo "configure:1469: checking for main in -lpthread" >&5 -ac_lib_var=`echo pthread'_'main | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lpthread $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - + fi fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_lib=HAVE_LIB`echo pthread | sed -e 's/[^a-zA-Z0-9_]/_/g' \ - -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` - cat >> confdefs.h <&6 +echo "configure:1188: checking for YAZ" >&5 +if test -r $yazconfig; then + . $yazconfig + echo "$ac_t""$yazconfig" 1>&6 else - echo "$ac_t""no" 1>&6 -fi - - fi - cat >> confdefs.h <<\EOF -#define _REENTRANT 1 -EOF - + echo "$ac_t""Not found" 1>&6 fi trap '' 1 2 15 cat > confcache <<\EOF @@ -1536,7 +1214,7 @@ EOF # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. (set) 2>&1 | - case `(ac_space=' '; set) 2>&1` in + case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote substitution # turns \\\\ into \\, and sed turns \\ into \). @@ -1615,7 +1293,7 @@ do echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.12" + echo "$CONFIG_STATUS generated by autoconf version 2.13" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; @@ -1635,9 +1313,11 @@ sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g; s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF $ac_vpsub $extrasub +s%@SHELL@%$SHELL%g s%@CFLAGS@%$CFLAGS%g s%@CPPFLAGS@%$CPPFLAGS%g s%@CXXFLAGS@%$CXXFLAGS%g +s%@FFLAGS@%$FFLAGS%g s%@DEFS@%$DEFS%g s%@LDFLAGS@%$LDFLAGS%g s%@LIBS@%$LIBS%g @@ -1661,8 +1341,12 @@ s%@CXX@%$CXX%g s%@CPP@%$CPP%g s%@CXXCPP@%$CXXCPP%g s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g s%@INSTALL_DATA@%$INSTALL_DATA%g s%@RANLIB@%$RANLIB%g +s%@YAZINC@%$YAZINC%g +s%@YAZLIB@%$YAZLIB%g +s%@yazconfig@%$yazconfig%g CEOF EOF diff --git a/unix/configure.in b/unix/configure.in index 1591362..87fb89e 100644 --- a/unix/configure.in +++ b/unix/configure.in @@ -1,7 +1,7 @@ dnl YAZ++ Toolkit configure script. dnl (c) Index Data ApS 1999 dnl See the file LICENSE for details. -dnl $Id: configure.in,v 1.2 1999-03-23 14:17:57 adam Exp $ +dnl $Id: configure.in,v 1.3 1999-12-06 13:52:45 adam Exp $ AC_INIT(../include/yaz-socket-manager.h) dnl dnl ------ Checking programs @@ -12,35 +12,35 @@ AC_PROG_CXXCPP AC_PROG_INSTALL AC_PROG_RANLIB dnl -dnl ----- Sockets -checkBoth=0 -AC_CHECK_FUNC(connect) -if test "$ac_cv_func_connect" = "no"; then - AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", checkBoth=1) +dnl ------ Look for Yaz +dnl See if user specified location of yaz-config; otherwise +dnl use ../yaz if is a directory (internal development); otherwise +dnl use yaz-config found in PATH. +AC_SUBST(YAZINC) +AC_SUBST(YAZLIB) +yazconfig=NONE +yazpath=NONE +AC_ARG_WITH(yazconfig, [ --with-yazconfig Path for yaz-config], [yazpath=$withval]) +if test "x$yazpath" != "xNONE"; then + yazconfig=$yazpath/yaz-config +else + for i in ../../yaz* ../../yaz; do + if test -d $i; then + if test -r $i/include/yaz/yaz-version.h; then + yazconfig=$i/yaz-config + fi + fi + done + if test "x$yazconfig" = "xNONE"; then + AC_PATH_PROG(yazconfig, yaz-config, NONE) + fi fi -if test "$checkBoth" = "1"; then - oldLibs=$LIBS - LIBS="$LIBS -lsocket -lnsl" - AC_CHECK_FUNC(accept, , [LIBS=$oldLibs]) -fi -AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"])) -dnl -dnl ------ Headers -AC_STDC_HEADERS -if test "$ac_cv_header_stdc" = "no"; then - AC_MSG_WARN(Your system doesn't seem to support ANSI C) -fi -dnl -dnl ------ Threads -AC_ARG_ENABLE(threads, [ --enable-threads enable threads if available], - [threads_ok=$enableval], [threads_ok=no]) -if test "$threads_ok" = "yes"; then - AC_CHECK_HEADERS(pthread.h threads.h) - AC_CHECK_FUNC(pthread_mutex_lock) - if test "$ac_cv_func_pthread_mutex_lock" = "no"; then - AC_CHECK_LIB(pthread, main) - fi - AC_DEFINE(_REENTRANT) +AC_MSG_CHECKING(for YAZ) +if test -r $yazconfig; then + . $yazconfig + AC_MSG_RESULT($yazconfig) +else + AC_MSG_RESULT(Not found) fi dnl dnl ------ Makefiles -- 1.7.10.4