Implemented command update0 in YAZ client which is equivalent to
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 2 Sep 2003 12:12:12 +0000 (12:12 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 2 Sep 2003 12:12:12 +0000 (12:12 +0000)
update but uses old of Ext Update ASN.1.
Use OID 1.2.840.10003.15.1000.81.1 for privately defined charsets
in charset negotiation. Added VAL_ID_CHARSET in oid.h.
Previously no OID was used for this info.

CHANGELOG
client/client.c
include/yaz/oid.h
util/oid.c
ztest/ztest.c
zutil/charneg.c

index a928173..9983e6f 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,13 @@ Possible compatibility problems with earlier versions marked with '*'.
 
 --- (IN PROGRESS)
 
+Implemented command update0 in YAZ client which is equivalent to
+update but uses old of Ext Update ASN.1.
+
+Use OID 1.2.840.10003.15.1000.81.1 for privately defined charsets
+in charset negotiation. Added VAL_ID_CHARSET in oid.h.
+Previously no OID was used for this info.
+
 ZOOM uses smallSetUpperBound=1 instead of 0 for piggyback searches.
 It apparantely upsets EBSCO Publishing IR Z39.50 Server which
 returns 'malformed search term' otherwise.
index 15dcd4d..c285452 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 1995-2003, Index Data
  * See the file LICENSE for details.
  *
- * $Id: client.c,v 1.206 2003-07-30 22:33:12 adam Exp $
+ * $Id: client.c,v 1.207 2003-09-02 12:12:12 adam Exp $
  */
 
 #include <stdio.h>
@@ -1849,14 +1849,24 @@ static int only_z3950()
     return 0;
 }
 
+static int cmd_update_common(const char *arg, int version);
+
 static int cmd_update(const char *arg)
 {
+    cmd_update_common(arg, 1);
+}
+
+static int cmd_update0(const char *arg)
+{
+    cmd_update_common(arg, 0);
+}
+
+static int cmd_update_common(const char *arg, int version)
+{
     Z_APDU *apdu = zget_APDU(out, Z_APDU_extendedServicesRequest );
     Z_ExtendedServicesRequest *req = apdu->u.extendedServicesRequest;
     Z_External *r;
     int oid[OID_SIZE];
-    Z_IUOriginPartToKeep *toKeep;
-    Z_IUSuppliedRecords *notToKeep;
     oident update_oid;
     char action[20], recid[20], fname[80];
     int action_no;
@@ -1920,7 +1930,10 @@ static int cmd_update(const char *arg)
 
     update_oid.proto = PROTO_Z3950;
     update_oid.oclass = CLASS_EXTSERV;
-    update_oid.value = VAL_DBUPDATE;
+    if (version == 0)
+       update_oid.value = VAL_DBUPDATE0;
+    else
+       update_oid.value = VAL_DBUPDATE;
     oid_ent_to_oid (&update_oid, oid);
     req->packageType = odr_oiddup(out,oid);
     req->packageName = esPackageName;
@@ -1932,41 +1945,90 @@ static int cmd_update(const char *arg)
     r->direct_reference = odr_oiddup(out,oid);
     r->indirect_reference = 0;
     r->descriptor = 0;
-    r->which = Z_External_update;
-    r->u.update = (Z_IUUpdate *) odr_malloc(out, sizeof(*r->u.update));
-    r->u.update->which = Z_IUUpdate_esRequest;
-    r->u.update->u.esRequest = (Z_IUUpdateEsRequest *)
-        odr_malloc(out, sizeof(*r->u.update->u.esRequest));
-    toKeep = r->u.update->u.esRequest->toKeep = (Z_IUOriginPartToKeep *)
-        odr_malloc(out, sizeof(*r->u.update->u.esRequest->toKeep));
-    toKeep->databaseName = databaseNames[0];
-    toKeep->schema = 0;
-    toKeep->elementSetName = 0;
-    toKeep->actionQualifier = 0;
-    toKeep->action = (int *) odr_malloc(out, sizeof(*toKeep->action));
-    *toKeep->action = action_no;
-
-    notToKeep = r->u.update->u.esRequest->notToKeep = (Z_IUSuppliedRecords *)
-        odr_malloc(out, sizeof(*r->u.update->u.esRequest->notToKeep));
-    notToKeep->num = 1;
-    notToKeep->elements = (Z_IUSuppliedRecords_elem **)
-        odr_malloc(out, sizeof(*notToKeep->elements));
-    notToKeep->elements[0] = (Z_IUSuppliedRecords_elem *)
-        odr_malloc(out, sizeof(**notToKeep->elements));
-    notToKeep->elements[0]->which = Z_IUSuppliedRecords_elem_opaque;
-    if (*recid)
-    {
-        notToKeep->elements[0]->u.opaque = (Odr_oct *)
-            odr_malloc (out, sizeof(Odr_oct));
-        notToKeep->elements[0]->u.opaque->buf = (unsigned char *) recid;
-        notToKeep->elements[0]->u.opaque->size = strlen(recid);
-        notToKeep->elements[0]->u.opaque->len = strlen(recid);
+    if (version == 0)
+    {
+       Z_IU0OriginPartToKeep *toKeep;
+       Z_IU0SuppliedRecords *notToKeep;
+
+       r->which = Z_External_update0;
+       r->u.update0 = (Z_IU0Update *) odr_malloc(out, sizeof(*r->u.update0));
+       r->u.update0->which = Z_IUUpdate_esRequest;
+       r->u.update0->u.esRequest = (Z_IU0UpdateEsRequest *)
+           odr_malloc(out, sizeof(*r->u.update0->u.esRequest));
+       toKeep = r->u.update0->u.esRequest->toKeep = (Z_IU0OriginPartToKeep *)
+           odr_malloc(out, sizeof(*r->u.update0->u.esRequest->toKeep));
+       
+       toKeep->databaseName = databaseNames[0];
+       toKeep->schema = 0;
+       toKeep->elementSetName = 0;
+
+       toKeep->action = (int *) odr_malloc(out, sizeof(*toKeep->action));
+       *toKeep->action = action_no;
+       
+       notToKeep = r->u.update0->u.esRequest->notToKeep = (Z_IU0SuppliedRecords *)
+           odr_malloc(out, sizeof(*r->u.update0->u.esRequest->notToKeep));
+       notToKeep->num = 1;
+       notToKeep->elements = (Z_IU0SuppliedRecords_elem **)
+           odr_malloc(out, sizeof(*notToKeep->elements));
+       notToKeep->elements[0] = (Z_IU0SuppliedRecords_elem *)
+           odr_malloc(out, sizeof(**notToKeep->elements));
+       notToKeep->elements[0]->which = Z_IUSuppliedRecords_elem_opaque;
+       if (*recid)
+       {
+           notToKeep->elements[0]->u.opaque = (Odr_oct *)
+               odr_malloc (out, sizeof(Odr_oct));
+           notToKeep->elements[0]->u.opaque->buf = (unsigned char *) recid;
+           notToKeep->elements[0]->u.opaque->size = strlen(recid);
+           notToKeep->elements[0]->u.opaque->len = strlen(recid);
+       }
+       else
+           notToKeep->elements[0]->u.opaque = 0;
+       notToKeep->elements[0]->supplementalId = 0;
+       notToKeep->elements[0]->correlationInfo = 0;
+       notToKeep->elements[0]->record = record_this;
     }
     else
-        notToKeep->elements[0]->u.opaque = 0;
-    notToKeep->elements[0]->supplementalId = 0;
-    notToKeep->elements[0]->correlationInfo = 0;
-    notToKeep->elements[0]->record = record_this;
+    {
+       Z_IUOriginPartToKeep *toKeep;
+       Z_IUSuppliedRecords *notToKeep;
+
+       r->which = Z_External_update;
+       r->u.update = (Z_IUUpdate *) odr_malloc(out, sizeof(*r->u.update));
+       r->u.update->which = Z_IUUpdate_esRequest;
+       r->u.update->u.esRequest = (Z_IUUpdateEsRequest *)
+           odr_malloc(out, sizeof(*r->u.update->u.esRequest));
+       toKeep = r->u.update->u.esRequest->toKeep = (Z_IUOriginPartToKeep *)
+           odr_malloc(out, sizeof(*r->u.update->u.esRequest->toKeep));
+       
+       toKeep->databaseName = databaseNames[0];
+       toKeep->schema = 0;
+       toKeep->elementSetName = 0;
+       toKeep->actionQualifier = 0;
+       toKeep->action = (int *) odr_malloc(out, sizeof(*toKeep->action));
+       *toKeep->action = action_no;
+
+       notToKeep = r->u.update->u.esRequest->notToKeep = (Z_IUSuppliedRecords *)
+           odr_malloc(out, sizeof(*r->u.update->u.esRequest->notToKeep));
+       notToKeep->num = 1;
+       notToKeep->elements = (Z_IUSuppliedRecords_elem **)
+           odr_malloc(out, sizeof(*notToKeep->elements));
+       notToKeep->elements[0] = (Z_IUSuppliedRecords_elem *)
+           odr_malloc(out, sizeof(**notToKeep->elements));
+       notToKeep->elements[0]->which = Z_IUSuppliedRecords_elem_opaque;
+       if (*recid)
+       {
+           notToKeep->elements[0]->u.opaque = (Odr_oct *)
+               odr_malloc (out, sizeof(Odr_oct));
+           notToKeep->elements[0]->u.opaque->buf = (unsigned char *) recid;
+           notToKeep->elements[0]->u.opaque->size = strlen(recid);
+           notToKeep->elements[0]->u.opaque->len = strlen(recid);
+       }
+       else
+           notToKeep->elements[0]->u.opaque = 0;
+       notToKeep->elements[0]->supplementalId = 0;
+       notToKeep->elements[0]->correlationInfo = 0;
+       notToKeep->elements[0]->record = record_this;
+    }
     
     send_apdu(apdu);
 
@@ -3586,6 +3648,7 @@ static struct {
     {"refid", cmd_refid, "<id>",NULL,0,NULL},
     {"itemorder", cmd_itemorder, "ill|item <itemno>",NULL,0,NULL},
     {"update", cmd_update, "<action> <recid> [<file>]",NULL,0,NULL},
+    {"update0", cmd_update0, "<action> <recid> [<file>]",NULL,0,NULL},
     {"packagename", cmd_packagename, "<packagename>",NULL,0,NULL},
     {"proxy", cmd_proxy, "[('tcp'|'ssl')]<host>[':'<port>]",NULL,0,NULL},
     {"charset", cmd_charset, "<nego_charset> <output_charset>",NULL,0,NULL},
index c0beb28..510cc17 100644 (file)
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: oid.h,v 1.18 2003-07-18 19:54:30 mike Exp $
+ * $Id: oid.h,v 1.19 2003-09-02 12:12:13 adam Exp $
  */
 
 #ifndef OID_H
@@ -212,7 +212,9 @@ typedef enum oid_value
     VAL_ZEEREX,
     VAL_CQL,
     VAL_DBUPDATE1,
+
     VAL_OCLCUI,
+    VAL_ID_CHARSET,
 
 /* VAL_DYNAMIC must have highest value */
     VAL_DYNAMIC,
index 22a8373..7545112 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 1995-2003, Index Data
  * See the file LICENSE for details.
  *
- * $Id: oid.c,v 1.66 2003-07-24 09:44:52 mike Exp $
+ * $Id: oid.c,v 1.67 2003-09-02 12:12:13 adam Exp $
  */
 
 /*
@@ -298,6 +298,8 @@ static oident standard_oids[] =
      "Zthes-tagset"},
     {PROTO_Z3950,   CLASS_NEGOT,   VAL_CHARNEG3,     {15,3,-1},
      "CharSetandLanguageNegotiation-3"},
+    {PROTO_Z3950,   CLASS_NEGOT,   VAL_ID_CHARSET,   {15,1000,81,1,-1},
+     "ID-Charset" },
     {PROTO_Z3950,   CLASS_USERINFO,VAL_CQL,          {16, 2, -1},
      "CQL"},
     {PROTO_GENERAL, CLASS_GENERAL, VAL_UCS2,    {1,0,10646,1,0,2,-1},
index c7e0679..2574a8c 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 1995-2003, Index Data.
  * See the file LICENSE for details.
  *
- * $Id: ztest.c,v 1.57 2003-03-24 22:26:51 adam Exp $
+ * $Id: ztest.c,v 1.58 2003-09-02 12:12:13 adam Exp $
  */
 
 /*
@@ -386,6 +386,10 @@ int ztest_esrequest (void *handle, bend_esrequest_rr *rr)
            }
        }
     }
+    else if (rr->esr->taskSpecificParameters->which == Z_External_update0)
+    {
+       yaz_log(LOG_LOG, "Received DB Update (version 0)");
+    }
     else
     {
         yaz_log (LOG_WARN, "Unknown Extended Service(%d)",
index 726d4f1..dbcedd4 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- $ $Id: charneg.c,v 1.7 2002-10-04 19:06:25 adam Exp $
+ $ $Id: charneg.c,v 1.8 2003-09-02 12:12:13 adam Exp $
  * Helper functions for Character Set and Language Negotiation - 3
  */
 
 #include <yaz/yaz-util.h>
 
 static Z_External* z_ext_record2(ODR o, int oid_class, int oid_value,
-                                 const char *buf, int len)
+                                 const char *buf)
 {
     Z_External *p;
     oident oid;
+    int len = strlen(buf);
     
     if (!(p = (Z_External *)odr_malloc(o, sizeof(*p)))) return 0;
     
@@ -95,7 +96,6 @@ static Z_OriginProposal_0 *z_get_OriginProposal_0(ODR o, const char *charset)
         Z_PrivateCharacterSet *pc =
             (Z_PrivateCharacterSet *)odr_malloc(o, sizeof(*pc));
 
-        
         memset(pc, 0, sizeof(*pc));
         
         p0->which = Z_OriginProposal_0_private;
@@ -103,7 +103,7 @@ static Z_OriginProposal_0 *z_get_OriginProposal_0(ODR o, const char *charset)
        
         pc->which = Z_PrivateCharacterSet_externallySpecified;
         pc->u.externallySpecified =
-            z_ext_record2(o, CLASS_RECSYN, VAL_NOP, charset, strlen(charset));
+            z_ext_record2(o, CLASS_NEGOT, VAL_ID_CHARSET, charset);
     }
     return p0;
 }
@@ -158,6 +158,7 @@ static Z_CharSetandLanguageNegotiation *z_get_CharSetandLanguageNegotiation(
     return p;
 }
 
+/* Create EXTERNAL for negotation proposal. Client side */
 Z_External *yaz_set_proposal_charneg(ODR o,
                                      const char **charsets, int num_charsets,
                                      const char **langs, int num_langs,
@@ -184,6 +185,7 @@ Z_External *yaz_set_proposal_charneg(ODR o,
     return p;
 }
 
+/* used by yaz_set_response_charneg */
 static Z_TargetResponse *z_get_TargetResponse(ODR o, const char *charset,
                                               const char *lang, int selected)
 {      
@@ -215,7 +217,7 @@ static Z_TargetResponse *z_get_TargetResponse(ODR o, const char *charset,
        
         pc->which = Z_PrivateCharacterSet_externallySpecified;
         pc->u.externallySpecified =
-        z_ext_record2(o, CLASS_RECSYN, VAL_NOP, charset, strlen(charset));
+           z_ext_record2(o, CLASS_NEGOT, VAL_ID_CHARSET, charset);
     }
     p->recordsInSelectedCharSets = (bool_t *)odr_malloc(o, sizeof(bool_t));
     *p->recordsInSelectedCharSets = (selected) ? 1:0;
@@ -224,6 +226,7 @@ static Z_TargetResponse *z_get_TargetResponse(ODR o, const char *charset,
     return p;
 }
 
+/* Create charset response. Server side */
 Z_External *yaz_set_response_charneg(ODR o, const char *charset,
                                      const char *lang, int selected)
 {
@@ -246,6 +249,7 @@ Z_External *yaz_set_response_charneg(ODR o, const char *charset,
     return p;
 }
 
+/* Get negotiation from OtherInformation. Client&Server side */
 Z_CharSetandLanguageNegotiation *yaz_get_charneg_record(Z_OtherInformation *p)
 {
     Z_External *pext;
@@ -268,10 +272,10 @@ Z_CharSetandLanguageNegotiation *yaz_get_charneg_record(Z_OtherInformation *p)
             }
         }
     }
-       
     return 0;
 }
 
+/* Get charsets, langs, selected from negotiation.. Server side */
 void yaz_get_proposal_charneg(NMEM mem, Z_CharSetandLanguageNegotiation *p,
                               char ***charsets, int *num_charsets,
                               char ***langs, int *num_langs, int *selected)
@@ -342,6 +346,7 @@ void yaz_get_proposal_charneg(NMEM mem, Z_CharSetandLanguageNegotiation *p,
         *selected = *pro->recordsInSelectedCharSets;
 }
 
+/* Return charset, lang, selected from negotiation.. Client side */
 void yaz_get_response_charneg(NMEM mem, Z_CharSetandLanguageNegotiation *p,
                               char **charset, char **lang, int *selected)
 {