X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=client%2Fclient.c;h=665773b66561739eba1a7b9200c271e03cdf08cd;hb=e65dd6fdeb899a631867cc4f17aac2d04d3cecbb;hp=ac57c74b9f648fcc6b2c4a9f9e3f37126526858d;hpb=11594352845d8e70c9d668c20fde891a1d45f3d6;p=yaz-moved-to-github.git diff --git a/client/client.c b/client/client.c index ac57c74..665773b 100644 --- a/client/client.c +++ b/client/client.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: client.c,v 1.326 2007-01-24 15:14:57 adam Exp $ + * $Id: client.c,v 1.328 2007-03-14 11:46:37 adam Exp $ */ /** \file client.c * \brief yaz-client program @@ -13,6 +13,9 @@ #include #include #include +#ifndef WIN32 +#include +#endif #if HAVE_SYS_TYPES_H #include #endif @@ -2131,20 +2134,22 @@ static int cmd_update_SRW(int action_no, const char *recid, static int cmd_update_common(const char *arg, int version) { - char action[20], recid[20]; + char action[20], recid_buf[20]; + const char *recid = 0; char *rec_buf; int rec_len; int action_no; int noread = 0; *action = 0; - *recid = 0; - sscanf (arg, "%19s %19s%n", action, recid, &noread); + *recid_buf = 0; + sscanf (arg, "%19s %19s%n", action, recid_buf, &noread); if (noread == 0) { - printf("Update must be followed by action and recid\n"); + printf("Use: update action recid [fname]\n"); printf(" where action is one of insert,replace,delete.update\n"); - printf(" recid is some record ID (any string)\n"); + printf(" recid is some record ID. Use none for no ID\n"); + printf(" fname is file of record to be updated\n"); return 0; } @@ -2163,6 +2168,9 @@ static int cmd_update_common(const char *arg, int version) return 0; } + if (strcmp(recid_buf, "none")) /* none means no record ID */ + recid = recid_buf; + arg += noread; if (parse_cmd_doc(&arg, out, &rec_buf, &rec_len, 1) == 0) return 0; @@ -2274,7 +2282,7 @@ static int cmd_update_Z3950(int version, int action_no, const char *recid, notToKeep->elements[0] = (Z_IU0SuppliedRecords_elem *) odr_malloc(out, sizeof(**notToKeep->elements)); notToKeep->elements[0]->which = Z_IUSuppliedRecords_elem_opaque; - if (*recid && strcmp(recid, "none")) + if (recid) { notToKeep->elements[0]->u.opaque = (Odr_oct *) odr_malloc (out, sizeof(Odr_oct)); @@ -2316,7 +2324,7 @@ static int cmd_update_Z3950(int version, int action_no, const char *recid, notToKeep->elements[0] = (Z_IUSuppliedRecords_elem *) odr_malloc(out, sizeof(**notToKeep->elements)); notToKeep->elements[0]->which = Z_IUSuppliedRecords_elem_opaque; - if (*recid) + if (recid) { notToKeep->elements[0]->u.opaque = (Odr_oct *) odr_malloc (out, sizeof(Odr_oct)); @@ -4679,12 +4687,23 @@ char **readline_completer(char *text, int start, int end) } #endif +#ifndef WIN32 +void ctrl_c_handler(int x) +{ + exit_client(0); +} +#endif + static void client(void) { char line[10240]; line[10239] = '\0'; +#ifndef WIN32 + signal(SIGINT, ctrl_c_handler); +#endif + #if HAVE_GETTIMEOFDAY gettimeofday (&tv_start, 0); #endif