For update, record ID "none" makes update omit record ID.
[yaz-moved-to-github.git] / client / client.c
index 5492b84..bb0f250 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2006, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: client.c,v 1.312 2006-08-15 13:30:00 adam Exp $
+ * $Id: client.c,v 1.319 2006-11-14 08:37:16 adam Exp $
  */
 /** \file client.c
  *  \brief yaz-client program
@@ -180,7 +180,7 @@ int cmd_register_tab(const char* arg);
 
 static void close_session (void);
 
-ODR getODROutputStream()
+ODR getODROutputStream(void)
 {
     return out;
 }
@@ -686,7 +686,7 @@ int session_connect(const char *arg)
         conn = cs_create_host(arg, 1, &add);
     if (!conn)
     {
-        printf ("Couldn't create comstack\n");
+        printf ("Could not resolve address %s\n", arg);
         return 0;
     }
 #if YAZ_HAVE_XML2
@@ -711,12 +711,6 @@ int session_connect(const char *arg)
     if (cs_connect(conn, add) < 0)
     {
         printf ("error = %s\n", cs_strerror(conn));
-        if (conn->cerrno == CSYSERR)
-        {
-            char msg[256];
-            yaz_strerror(msg, sizeof(msg));
-            printf ("%s\n", msg);
-        }
         cs_close(conn);
         conn = 0;
         return 0;
@@ -766,7 +760,7 @@ int cmd_open(const char *arg)
     return session_connect(cur_host);
 }
 
-void try_reconnect() 
+void try_reconnect(void)
 {
     char* open_command;
         
@@ -1410,7 +1404,7 @@ static int send_SRW_searchRequest(const char *arg)
     if (record_schema)
         sr->u.request->recordSchema = record_schema;
     if (recordsyntax_size == 1 && recordsyntax_list[0] == VAL_TEXT_XML)
-        sr->u.explain_request->recordPacking = "xml";
+        sr->u.request->recordPacking = "xml";
     return send_srw(sr);
 }
 #endif
@@ -1891,7 +1885,7 @@ const char *get_ill_element (void *clientData, const char *element)
     return 0;
 }
 
-static Z_External *create_external_itemRequest()
+static Z_External *create_external_itemRequest(void)
 {
     struct ill_get_ctl ctl;
     ILL_ItemRequest *req;
@@ -2087,6 +2081,9 @@ static int send_itemorder(const char *type, int itemno)
     Z_ExtendedServicesRequest *req = apdu->u.extendedServicesRequest;
     oident ItemOrderRequest;
 
+
+    req->referenceId = set_refid (out);
+
     ItemOrderRequest.proto = PROTO_Z3950;
     ItemOrderRequest.oclass = CLASS_EXTSERV;
     ItemOrderRequest.value = VAL_ITEMORDER;
@@ -2099,7 +2096,7 @@ static int send_itemorder(const char *type, int itemno)
     return 0;
 }
 
-static int only_z3950()
+static int only_z3950(void)
 {
     if (!conn)
     {
@@ -2223,7 +2220,7 @@ static int cmd_update_common(const char *arg, int version)
         notToKeep->elements[0] = (Z_IU0SuppliedRecords_elem *)
             odr_malloc(out, sizeof(**notToKeep->elements));
         notToKeep->elements[0]->which = Z_IUSuppliedRecords_elem_opaque;
-        if (*recid)
+        if (*recid && strcmp(recid, "none"))
         {
             notToKeep->elements[0]->u.opaque = (Odr_oct *)
                 odr_malloc (out, sizeof(Odr_oct));
@@ -2291,14 +2288,17 @@ static int cmd_xmles(const char *arg)
         return 1;
     else
     {
+        char *asn_buf = 0;
         int noread = 0;
         char oid_str[51];
         int oid_value_xmles = VAL_XMLES;
         Z_APDU *apdu = zget_APDU(out, Z_APDU_extendedServicesRequest);
         Z_ExtendedServicesRequest *req = apdu->u.extendedServicesRequest;
         
+
         Z_External *ext = (Z_External *) odr_malloc(out, sizeof(*ext));
         
+        req->referenceId = set_refid (out);
         req->taskSpecificParameters = ext;
         ext->indirect_reference = 0;
         ext->descriptor = 0;
@@ -2317,10 +2317,13 @@ static int cmd_xmles(const char *arg)
             printf("Bad OID: %s\n", oid_str);
             return 0;
         }
-        
-        if (parse_cmd_doc(&arg, out, (char **) &ext->u.single_ASN1_type->buf,
+
+        if (parse_cmd_doc(&arg, out, &asn_buf,
                           &ext->u.single_ASN1_type->len, 0) == 0)
             return 0;
+
+        ext->u.single_ASN1_type->buf = (unsigned char *) asn_buf;
+
         req->packageType = yaz_oidval_to_z3950oid(out, CLASS_EXTSERV,
                                                   oid_value_xmles);
         
@@ -3633,7 +3636,7 @@ int cmd_push_command(const char* arg)
     return 1;
 }
 
-void source_rcfile() 
+void source_rcfile(void)
 {
     /*  Look for a $HOME/.yazclientrc and source it if it exists */
     struct stat statbuf;
@@ -4307,7 +4310,7 @@ static struct {
     {"attributeset", cmd_attributeset, "<attrset>",complete_attributeset,0,NULL},
     {"querytype", cmd_querytype, "<type>",complete_querytype,0,NULL},
     {"refid", cmd_refid, "<id>",NULL,0,NULL},
-    {"itemorder", cmd_itemorder, "ill|item <itemno>",NULL,0,NULL},
+    {"itemorder", cmd_itemorder, "ill|item|xml <itemno>",NULL,0,NULL},
     {"update", cmd_update, "<action> <recid> [<doc>]",NULL,0,NULL},
     {"update0", cmd_update0, "<action> <recid> [<doc>]",NULL,0,NULL},
     {"xmles", cmd_xmles, "<OID> <doc>",NULL,0,NULL},