X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;ds=sidebyside;f=client%2Fclient.c;h=8feb388b8065eb5bcba5ead236a1c0d39dd02b3f;hb=088c938eb8a4c6e4db96603e30b3558fd3d67580;hp=7fe8df2a6e77e2b29f745786a64358e33de5b638;hpb=7057699040b614f56be178f3672b4a2b95301d5f;p=yaz-moved-to-github.git diff --git a/client/client.c b/client/client.c index 7fe8df2..8feb388 100644 --- a/client/client.c +++ b/client/client.c @@ -3,7 +3,31 @@ * See the file LICENSE for details. * * $Log: client.c,v $ - * Revision 1.120 2001-04-06 12:26:46 adam + * Revision 1.125 2001-07-19 19:51:41 adam + * Added typecasts to make C++ happy. + * + * Revision 1.124 2001/07/04 20:13:51 ja7 + * Added new commend "proxy" for ysing a yaz-proxy to connect to the target + * Added new command line option -p for setting the proxy host + * + * Revision 1.123 2001/06/11 12:54:47 heikki + * Displayng diags in EsResponse, even if they should not be there... + * + * Revision 1.122 2001/05/16 07:27:29 adam + * Reference id set for InitRequest. + * + * Revision 1.121 2001/04/22 12:26:17 ja7 + * if Compiled with Command line history a open command is pushed into + * the command history if yaz-client is startet with a server on the + * command line. eg + * yaz-clinet tcp:server:port/database + * hash the commend + * open tcp:server:port/database + * in the command history on startup + * + * Added the refid set with setrefid to the update APDU + * + * Revision 1.120 2001/04/06 12:26:46 adam * Optional CCL module. Moved atoi_n to marcdisp.h from yaz-util.h. * * Revision 1.119 2001/04/05 13:08:48 adam @@ -404,6 +428,7 @@ #include #include #include +#include #include @@ -449,8 +474,9 @@ static char last_scan_line[512] = "0"; static char last_scan_query[512] = "0"; static char ccl_fields[512] = "default.bib"; static char* esPackageName = 0; +static char* yazProxy = 0; -static char last_cmd[100] = "?"; +static char last_cmd[32] = "?"; static FILE *marcdump = 0; static char *refid = NULL; @@ -518,7 +544,7 @@ static Z_ReferenceId *set_refid (ODR out) /* INIT SERVICE ------------------------------- */ -static void send_initRequest() +static void send_initRequest(const char* type_and_host) { Z_APDU *apdu = zget_APDU(out, Z_APDU_initRequest); Z_InitRequest *req = apdu->u.initRequest; @@ -541,6 +567,12 @@ static void send_initRequest() req->idAuthentication = auth; + req->referenceId = set_refid (out); + + + yaz_oi_set_string_oidval(&req->otherInfo, out, VAL_PROXY, 1, type_and_host); + + send_apdu(apdu); printf("Sent initrequest.\n"); } @@ -662,7 +694,15 @@ int cmd_open(char *arg) if (sscanf (arg, "%100[^/]/%100s", type_and_host, base) < 1) return 0; - conn = cs_create_host(type_and_host, 1, &add); + if(yazProxy) + { + conn = cs_create_host(yazProxy, 1, &add); + } + else + { + conn = cs_create_host(type_and_host, 1, &add); + }; + if (!conn) { printf ("Couldn't create comstack\n"); @@ -680,7 +720,8 @@ int cmd_open(char *arg) return 0; } printf("Ok.\n"); - send_initRequest(); + + send_initRequest(type_and_host); if (*base) cmd_base (base); return 2; @@ -1318,6 +1359,11 @@ void process_ESResponse(Z_ExtendedServicesResponse *res) display_diagrecs(res->diagnostics, res->num_diagnostics); break; } + if ( (*res->operationStatus != Z_ExtendedServicesResponse_failure) && + (res->num_diagnostics != 0) ) { + display_diagrecs(res->diagnostics, res->num_diagnostics); + } + } #if YAZ_MODULE_ill @@ -1563,6 +1609,8 @@ static int cmd_update(char *arg) oid_ent_to_oid (&update_oid, oid); req->packageType = odr_oiddup(out,oid); req->packageName = esPackageName; + + req->referenceId = set_refid (out); r = req->taskSpecificParameters = (Z_External *) odr_malloc (out, sizeof(*r)); @@ -2358,6 +2406,17 @@ int cmd_packagename(char* arg) { return 1; }; +int cmd_proxy(char* arg) { + xfree (yazProxy); + yazProxy = NULL; + if (*arg) + { + yazProxy = (char *) xmalloc (strlen(arg)+1); + strcpy (yazProxy, arg); + } + return 1; +}; + static void initialize(void) { #if YAZ_MODULE_ccl @@ -2420,6 +2479,7 @@ static int client(int wait) {"itemorder", cmd_itemorder, "ill|item "}, {"update", cmd_update, ""}, {"packagename", cmd_packagename, ""}, + {"proxy", cmd_proxy, "('tcp'|'osi')':'['/'][':']"}, #ifdef ASN_COMPILED /* Server Admin Functions */ {"adm-reindex", cmd_adm_reindex, ""}, @@ -2449,7 +2509,7 @@ static int client(int wait) #ifdef USE_SELECT fd_set input; #endif - char line[1024], word[1024], arg[1024]; + char line[1024], word[32], arg[1024]; #ifdef USE_SELECT FD_ZERO(&input); @@ -2492,7 +2552,7 @@ static int client(int wait) gettimeofday (&tv_start, 0); #endif - if ((res = sscanf(line, "%s %[^;]", word, arg)) <= 0) + if ((res = sscanf(line, "%31s %1023[^;]", word, arg)) <= 0) { strcpy(word, last_cmd); *arg = '\0'; @@ -2627,7 +2687,7 @@ int main(int argc, char **argv) int ret; int opened = 0; - while ((ret = options("c:a:m:v:", argv, argc, &arg)) != -2) + while ((ret = options("c:a:m:v:p:", argv, argc, &arg)) != -2) { switch (ret) { @@ -2635,8 +2695,17 @@ int main(int argc, char **argv) if (!opened) { initialize (); - if (cmd_open (arg) == 2) - opened = 1; + if (cmd_open (arg) == 2) { +#if HAVE_READLINE_HISTORY_H + char* tmp=(char*)malloc(strlen(arg)+6); + *tmp=0; + strcat(tmp,"open "); + strcat(tmp,arg); + add_history(tmp); + free(tmp); +#endif + opened = 1; + }; } break; case 'm': @@ -2656,12 +2725,15 @@ int main(int argc, char **argv) else apdu_file=fopen(arg, "a"); break; + case 'p': + yazProxy=strdup(arg); + break; case 'v': yaz_log_init (yaz_log_mask_str(arg), "", NULL); break; default: fprintf (stderr, "Usage: %s [-m ] [ -a ] " - "[-c cclfields] []\n", + "[-c cclfields] [-p ] []\n", prog); exit (1); }