X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fyaz-client.cpp;fp=src%2Fyaz-client.cpp;h=e7f66e838bf51f121103c56c8d5318aa6abe3010;hb=26b3f7f15abcb69aaf00fb6bdaf410ff3e7de14c;hp=565652e906a061d7094da3c8c62deaa8289db6aa;hpb=2e14b1af67a2044e73d024bc29445035910a2dd4;p=yazpp-moved-to-github.git 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 (); }