X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=src%2Fyaz-client.cpp;h=a14956e943eeb0e236035582ce8a924705f176ac;hb=bd71f8812ca0f38438733efc89ecce1f49dae9e7;hp=2bd47b1d13f856f757985de02a09b97817bd2a75;hpb=848aaf80bff6102e377c9cbd2a52679b74102699;p=yazpp-moved-to-github.git diff --git a/src/yaz-client.cpp b/src/yaz-client.cpp index 2bd47b1..a14956e 100644 --- a/src/yaz-client.cpp +++ b/src/yaz-client.cpp @@ -1,10 +1,31 @@ /* - * Copyright (c) 1998-1999, Index Data. + * Copyright (c) 1998-2000, Index Data. * See the file LICENSE for details. - * Sebastian Hammer, Adam Dickmeiss * * $Log: yaz-client.cpp,v $ - * Revision 1.10 2000-05-30 03:12:27 ian + * 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. * @@ -44,9 +65,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include extern "C" { #if HAVE_READLINE_READLINE_H @@ -67,7 +88,8 @@ private: public: MyClient(IYaz_PDU_Observable *the_PDU_Observable, Yaz_SocketManager *the_SocketManager); - IYaz_PDU_Observer *clone(IYaz_PDU_Observable *the_PDU_Observable); + IYaz_PDU_Observer *sessionNotify( + IYaz_PDU_Observable *the_PDU_Observable, int fd); int args(Yaz_SocketManager *socketManager, int argc, char **argv); int interactive(Yaz_SocketManager *socketManager); int wait(); @@ -86,6 +108,7 @@ public: void connectNotify(); void failNotify(); void timeoutNotify(); + char *get_cookie (Z_OtherInformation **oi); int processCommand(const char *cmd); const char *MyClient::getCommand(); int cmd_open(char *host); @@ -119,7 +142,8 @@ void MyClient::failNotify() set_lastReceived(-1); } -IYaz_PDU_Observer *MyClient::clone(IYaz_PDU_Observable *the_PDU_Observable) +IYaz_PDU_Observer *MyClient::sessionNotify( + IYaz_PDU_Observable *the_PDU_Observable, int fd) { return new MyClient(the_PDU_Observable, m_socketManager); } @@ -137,15 +161,40 @@ MyClient::MyClient(IYaz_PDU_Observable *the_PDU_Observable, void usage(char *prog) { - fprintf (stderr, "%s: [-v log] [-p proxy] [zurl]\n", prog); + fprintf (stderr, "%s: [-v log] [-c cookie] [-p proxy] [zurl]\n", prog); exit (1); } +char *MyClient::get_cookie(Z_OtherInformation **otherInfo) +{ + int oid[OID_SIZE]; + Z_OtherInformationUnit *oi; + struct oident ent; + ent.proto = PROTO_Z3950; + ent.oclass = CLASS_USERINFO; + ent.value = (oid_value) VAL_COOKIE; + + if (oid_ent_to_oid (&ent, oid) && + (oi = update_otherInformation(otherInfo, 0, oid, 1, 1)) && + oi->which == Z_OtherInfo_characterInfo) + return oi->information.characterInfo; + return 0; +} + void MyClient::recv_initResponse(Z_InitResponse *initResponse) { printf ("Got InitResponse. Status "); if (*initResponse->result) + { printf ("Ok\n"); + + const char *p = get_cookie (&initResponse->otherInfo); + if (p) + { + printf ("cookie = %s\n", p); + set_cookie(p); + } + } else printf ("Fail\n"); } @@ -637,7 +686,7 @@ int MyClient::args(Yaz_SocketManager *socketManager, int argc, char **argv) set_cookie(arg); break; case 'v': - log_init_level (log_mask_str(arg)); + yaz_log_init_level (yaz_log_mask_str(arg)); break; case 'q': m_interactive_flag = 0; @@ -670,4 +719,5 @@ int main(int argc, char **argv) exit (1); if (z.interactive(&mySocketManager)) exit (1); + return 0; }