X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Fyaz-client.cpp;h=a6558dc84e04196ffadd199f76d7ea0d60bb38de;hb=79cc3b2b8486f2dec0eb51a932e92ac22d8c0eb2;hp=e7f66e838bf51f121103c56c8d5318aa6abe3010;hpb=26b3f7f15abcb69aaf00fb6bdaf410ff3e7de14c;p=yazpp-moved-to-github.git diff --git a/src/yaz-client.cpp b/src/yaz-client.cpp index e7f66e8..a6558dc 100644 --- a/src/yaz-client.cpp +++ b/src/yaz-client.cpp @@ -1,10 +1,17 @@ /* - * 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.9 1999-12-06 13:52:45 adam + * Revision 1.11 2000-07-04 13:48:49 adam + * Implemented upper-limit on proxy-to-target sessions. + * + * Revision 1.10 2000/05/30 03:12:27 ian + * minor change to stop g++ 2.95.2 complaining about taking the address + * of a member function. + * + * Revision 1.9 1999/12/06 13:52:45 adam * Modified for new location of YAZ header files. Experimental threaded * operation. * @@ -82,6 +89,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); @@ -133,15 +141,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"); } @@ -518,16 +551,16 @@ int MyClient::processCommand(const char *commandLine) int (MyClient::*fun)(char *arg); char *ad; } cmd[] = { - {"open", &cmd_open, "[':'][/]"}, - {"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, ":[':']"}, + {"open", &MyClient::cmd_open, "[':'][/]"}, + {"connect", &MyClient::cmd_connect, "[':'][/]"}, + {"quit", &MyClient::cmd_quit, ""}, + {"close", &MyClient::cmd_close, ""}, + {"find", &MyClient::cmd_find, ""}, + {"show", &MyClient::cmd_show, "[ []]"}, + {"cookie", &MyClient::cmd_cookie, ""}, + {"init", &MyClient::cmd_init, ""}, + {"format", &MyClient::cmd_format, ""}, + {"proxy", &MyClient::cmd_proxy, ":[':']"}, {0,0,0} };