From b853eb3de1a249859eef71c9a285172a199656ce Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 6 Jun 2005 10:29:33 +0000 Subject: [PATCH] Add support for privately defined extended service, xml update, with OID 1.2.840.10003.9.1000.105.4. --- client/client.c | 31 ++++++++++++++++++++++++++++++- include/yaz/oid.h | 3 ++- src/oid.c | 16 +++++++++------- src/zoom-c.c | 39 +++++++++++++++++++++++++++++++++++++-- zoom/zoomsh.c | 9 ++++++++- 5 files changed, 86 insertions(+), 12 deletions(-) diff --git a/client/client.c b/client/client.c index b5a11eb..bfeeb4c 100644 --- a/client/client.c +++ b/client/client.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: client.c,v 1.283 2005-06-06 07:25:47 adam Exp $ + * $Id: client.c,v 1.284 2005-06-06 10:29:33 adam Exp $ */ #include @@ -1841,6 +1841,11 @@ void process_ESResponse(Z_ExtendedServicesResponse *res) } } } + if (res->taskPackage && res->taskPackage->which == Z_External_octet) + { + Odr_oct *doc = res->taskPackage->u.octet_aligned; + printf("%.*s\n", doc->len, doc->buf); + } } const char *get_ill_element (void *clientData, const char *element) @@ -2246,6 +2251,29 @@ static int cmd_update_common(const char *arg, int version) return 2; } +static int cmd_xmlupdate(const char *arg) +{ + Z_APDU *apdu = zget_APDU(out, Z_APDU_extendedServicesRequest); + Z_ExtendedServicesRequest *req = apdu->u.extendedServicesRequest; + + req->packageType = yaz_oidval_to_z3950oid(out, CLASS_EXTSERV, + VAL_XMLUPDATE); + Z_External *ext = (Z_External *) odr_malloc(out, sizeof(*ext)); + req->taskSpecificParameters = ext; + ext->direct_reference = req->packageType; + ext->descriptor = 0; + ext->indirect_reference = 0; + + ext->which = Z_External_octet; + ext->u.single_ASN1_type = (Odr_oct *) odr_malloc (out, sizeof(Odr_oct)); + + ext->u.single_ASN1_type->buf = (unsigned char*) odr_strdup(out, arg); + ext->u.single_ASN1_type->size = ext->u.single_ASN1_type->len = strlen(arg); + send_apdu(apdu); + + return 2; +} + static int cmd_itemorder(const char *arg) { char type[12]; @@ -4166,6 +4194,7 @@ static struct { {"itemorder", cmd_itemorder, "ill|item ",NULL,0,NULL}, {"update", cmd_update, " []",NULL,0,NULL}, {"update0", cmd_update0, " []",NULL,0,NULL}, + {"xmlupdate", cmd_xmlupdate, " ",NULL,0,NULL}, {"packagename", cmd_packagename, "",NULL,0,NULL}, {"proxy", cmd_proxy, "[('tcp'|'ssl')][':']",NULL,0,NULL}, {"charset", cmd_charset, " ",NULL,0,NULL}, diff --git a/include/yaz/oid.h b/include/yaz/oid.h index fb38708..ffc2b73 100644 --- a/include/yaz/oid.h +++ b/include/yaz/oid.h @@ -23,7 +23,7 @@ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. * - * $Id: oid.h,v 1.24 2005-01-15 19:47:09 adam Exp $ + * $Id: oid.h,v 1.25 2005-06-06 10:29:33 adam Exp $ */ /** @@ -230,6 +230,7 @@ typedef enum oid_value VAL_MARC21FIN, VAL_CHARNEG4, + VAL_XMLUPDATE, /* VAL_DYNAMIC must have highest value */ VAL_DYNAMIC, diff --git a/src/oid.c b/src/oid.c index 8ae7508..bd40674 100644 --- a/src/oid.c +++ b/src/oid.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: oid.c,v 1.8 2005-05-26 21:46:41 adam Exp $ + * $Id: oid.c,v 1.9 2005-06-06 10:29:33 adam Exp $ */ /** @@ -317,17 +317,19 @@ static oident standard_oids[] = "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}, + {PROTO_GENERAL, CLASS_GENERAL, VAL_UCS2, {1,0,10646,1,0,2,-1}, "UCS-2"}, - {PROTO_GENERAL, CLASS_GENERAL, VAL_UCS4, {1,0,10646,1,0,4,-1}, + {PROTO_GENERAL, CLASS_GENERAL, VAL_UCS4, {1,0,10646,1,0,4,-1}, "UCS-4"}, - {PROTO_GENERAL, CLASS_GENERAL, VAL_UTF16, {1,0,10646,1,0,5,-1}, + {PROTO_GENERAL, CLASS_GENERAL, VAL_UTF16, {1,0,10646,1,0,5,-1}, "UTF-16"}, - {PROTO_GENERAL, CLASS_GENERAL, VAL_UTF8, {1,0,10646,1,0,8,-1}, + {PROTO_GENERAL, CLASS_GENERAL, VAL_UTF8, {1,0,10646,1,0,8,-1}, "UTF-8"}, - {PROTO_Z3950, CLASS_USERINFO,VAL_OCLCUI, {10, 1000, 17, 1, -1}, + {PROTO_Z3950, CLASS_USERINFO,VAL_OCLCUI, {10, 1000, 17, 1, -1}, "OCLC-userInfo"}, - {PROTO_NOP, CLASS_NOP, VAL_NOP, {-1}, 0 } + {PROTO_Z3950, CLASS_EXTSERV, VAL_XMLUPDATE, {9,1000,105,4,-1}, + "XMLUpdate-ES"}, + {PROTO_NOP, CLASS_NOP, VAL_NOP, {-1}, 0 } }; /* OID utilities */ diff --git a/src/zoom-c.c b/src/zoom-c.c index 05aff9c..d63ebe3 100644 --- a/src/zoom-c.c +++ b/src/zoom-c.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: zoom-c.c,v 1.41 2005-05-17 11:48:36 adam Exp $ + * $Id: zoom-c.c,v 1.42 2005-06-06 10:29:33 adam Exp $ */ /** * \file zoom-c.c @@ -1015,7 +1015,7 @@ static zoom_ret ZOOM_connection_send_init (ZOOM_connection c) ZOOM_options_get(c->options, "implementationName"), odr_prepend(c->odr_out, "ZOOM-C", ireq->implementationName)); - version = odr_strdup(c->odr_out, "$Revision: 1.41 $"); + version = odr_strdup(c->odr_out, "$Revision: 1.42 $"); if (strlen(version) > 10) /* check for unexpanded CVS strings */ version[strlen(version)-2] = '\0'; ireq->implementationVersion = odr_prepend(c->odr_out, @@ -2549,6 +2549,30 @@ Z_APDU *create_admin_package(ZOOM_package p, int type, return apdu; } +static Z_APDU *create_xmlupdate_package(ZOOM_package p) +{ + Z_APDU *apdu = create_es_package(p, VAL_XMLUPDATE); + Z_ExtendedServicesRequest *req = apdu->u.extendedServicesRequest; + Z_External *ext = (Z_External *) odr_malloc(p->odr_out, sizeof(*ext)); + const char *doc = ZOOM_options_get(p->options, "doc"); + + req->taskSpecificParameters = ext; + ext->direct_reference = req->packageType; + ext->descriptor = 0; + ext->indirect_reference = 0; + + ext->which = Z_External_octet; + ext->u.single_ASN1_type = (Odr_oct *) + odr_malloc (p->odr_out, sizeof(Odr_oct)); + + if (!doc) + doc = ""; + ext->u.single_ASN1_type->buf = (unsigned char*) + odr_strdup(p->odr_out, doc); + ext->u.single_ASN1_type->size = ext->u.single_ASN1_type->len = strlen(doc); + return apdu; +} + static Z_APDU *create_update_package(ZOOM_package p) { Z_APDU *apdu = 0; @@ -2715,6 +2739,10 @@ ZOOM_API(void) { apdu = create_update_package(p); } + else if (!strcmp(type, "xmlupdate")) + { + apdu = create_xmlupdate_package(p); + } if (apdu) { if (encode_APDU(p->connection, apdu, p->odr_out) == 0) @@ -2881,6 +2909,13 @@ static int es_response (ZOOM_connection c, ZOOM_options_setl (c->tasks->u.package->options, "targetReference", (char*) id->buf, id->len); } + if (res->taskPackage && + res->taskPackage->which == Z_External_octet) + { + Odr_oct *doc = res->taskPackage->u.octet_aligned; + ZOOM_options_setl (c->tasks->u.package->options, + "xmlUpdateDoc", (char*) doc->buf, doc->len); + } return 1; } diff --git a/zoom/zoomsh.c b/zoom/zoomsh.c index 7276d63..2f27942 100644 --- a/zoom/zoomsh.c +++ b/zoom/zoomsh.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: zoomsh.c,v 1.32 2005-01-15 19:47:15 adam Exp $ + * $Id: zoomsh.c,v 1.33 2005-06-06 10:29:35 adam Exp $ */ /* ZOOM-C Shell */ @@ -259,7 +259,14 @@ static void cmd_ext (ZOOM_connection *c, ZOOM_resultset *r, dset, error, addinfo); else if (p[i]) { + const char *v; printf ("ok\n"); + v = ZOOM_package_option_get (p[i], "targetReference"); + if (v) + printf("targetReference: %s\n", v); + v = ZOOM_package_option_get (p[i], "xmlUpdateDoc"); + if (v) + printf("xmlUpdateDoc: %s\n", v); } ZOOM_package_destroy (p[i]); } -- 1.7.10.4