From 0e96e3780fe77ed9f8bd78245b9e9a8a42c0892d Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 2 Jun 2003 12:53:27 +0000 Subject: [PATCH] ESFormat-Update updates. Character set conversion for ZOOM_record_get. --- CHANGELOG | 16 ++++++---- doc/zoom.xml | 13 +------- include/yaz/oid.h | 3 +- util/oid.c | 8 +++-- z39.50/prt-ext.c | 4 ++- z39.50/z3950v3.asn | 33 +++++++++++---------- zutil/zoom-c.c | 83 +++++++++++++++++++++++++++++++++++----------------- zutil/zoom-p.h | 4 +-- 8 files changed, 96 insertions(+), 68 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 9a6520a..7ef29a4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,10 +1,16 @@ Possible compatibility problems with earlier versions marked with '*'. -New ZOOM setting, recordCharset, with value "from[,to]" -where from is the character set of a record as received -by the target. The character set "to" is desired charset -of output record as returned by ZOOM_record_get. If -"to" is omitted, UTF-8 is assumed. +* ESFormat-Update updates. Packages with OID 1.2.840.10003.9.5.1 and +1.2.840.10003.9.5 are now handled by the same decoder z_IU0Update . +Decoder has been updated with ASN.1 changes as listed in +http://lcweb.loc.gov/z3950/agency/defns/updateES.html +Note that the "latest" DB Update, OID 1.2.840.10003.9.5.1.1 , handler +z_IUUpdate, remains unchanged. + +ZOOM_record_get may now return a record in a specific character set. +For type use "form; charset=from[,to]" where form (render, xml, ..) , +"from" is the character set of record as returned by target. "to" is +the character set to be returned. If omitted, "to" is UTF-8. YAZ ASN.1 compiler renamed from yaz-comp to yaz-asncomp diff --git a/doc/zoom.xml b/doc/zoom.xml index 575628a..66cffa4 100644 --- a/doc/zoom.xml +++ b/doc/zoom.xml @@ -1,4 +1,4 @@ - + ZOOM &zoom; is an acronym for 'Z39.50 Object-Orientation Model' and is @@ -403,17 +403,6 @@ If this option isn't set, the ZOOM module will automatically allocate a result set name. default - - recordCharsetSpecification of character set - conversion of records. This is a pure client side operation - - unrelated to Z39.50 character set negotiation. The value - is a string of the form - "from[,to]" - where from is character set encoding - of record as returned by the target. The to - is encoding of the output record (as returned by ZOOM_record_get). - If from is omitted, UTF-8 is assumed. - default diff --git a/include/yaz/oid.h b/include/yaz/oid.h index 048918b..f5eaa23 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.15 2003-02-21 12:08:58 adam Exp $ + * $Id: oid.h,v 1.16 2003-06-02 12:53:27 adam Exp $ */ #ifndef OID_H @@ -211,6 +211,7 @@ typedef enum oid_value VAL_BIB2, VAL_ZEEREX, VAL_CQL, + VAL_DBUPDATE1, /* VAL_DYNAMIC must have highest value */ VAL_DYNAMIC, diff --git a/util/oid.c b/util/oid.c index e6236e4..a7f6914 100644 --- a/util/oid.c +++ b/util/oid.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2003, Index Data * See the file LICENSE for details. * - * $Id: oid.c,v 1.61 2003-05-26 13:36:48 adam Exp $ + * $Id: oid.c,v 1.62 2003-06-02 12:53:28 adam Exp $ */ /* @@ -224,8 +224,10 @@ static oident standard_oids[] = "Per'd query"}, {PROTO_Z3950, CLASS_EXTSERV, VAL_ITEMORDER, {9,4,-1}, "Item order"}, - {PROTO_Z3950, CLASS_EXTSERV, VAL_DBUPDATE0, {9,5,1,-1}, - "DB. Update (old version)"}, + {PROTO_Z3950, CLASS_EXTSERV, VAL_DBUPDATE0, {9,5,-1}, + "DB. Update (first version)"}, + {PROTO_Z3950, CLASS_EXTSERV, VAL_DBUPDATE1, {9,5,1,-1}, + "DB. Update (second version)"}, {PROTO_Z3950, CLASS_EXTSERV, VAL_DBUPDATE, {9,5,1,1,-1}, "DB. Update"}, {PROTO_Z3950, CLASS_EXTSERV, VAL_EXPORTSPEC, {9,6,-1}, diff --git a/z39.50/prt-ext.c b/z39.50/prt-ext.c index 7e9bc41..32de772 100644 --- a/z39.50/prt-ext.c +++ b/z39.50/prt-ext.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2003, Index Data. * See the file LICENSE for details. * - * $Id: prt-ext.c,v 1.5 2003-01-06 08:20:28 adam Exp $ + * $Id: prt-ext.c,v 1.6 2003-06-02 12:53:28 adam Exp $ */ #include @@ -28,6 +28,8 @@ static Z_ext_typeent type_table[] = {VAL_OPAC, Z_External_OPAC, (Odr_fun)z_OPACRecord}, {VAL_SEARCHRES1, Z_External_searchResult1, (Odr_fun)z_SearchInfoReport}, {VAL_DBUPDATE, Z_External_update, (Odr_fun)z_IUUpdate}, + {VAL_DBUPDATE0, Z_External_update0, (Odr_fun)z_IU0Update}, + {VAL_DBUPDATE1, Z_External_update0, (Odr_fun)z_IU0Update}, {VAL_DATETIME, Z_External_dateTime, (Odr_fun)z_DateTime}, {VAL_UNIVERSE_REPORT, Z_External_universeReport,(Odr_fun)z_UniverseReport}, {VAL_ADMINSERVICE, Z_External_ESAdmin, (Odr_fun)z_Admin}, diff --git a/z39.50/z3950v3.asn b/z39.50/z3950v3.asn index 98cf885..d841961 100644 --- a/z39.50/z3950v3.asn +++ b/z39.50/z3950v3.asn @@ -2401,11 +2401,12 @@ OriginPartToKeep ::= SEQUENCE{ recordInsert (1), recordReplace (2), recordDelete (3), - elementUpdate (4)}, + elementUpdate (4), + specialUpdate (5)}, databaseName [2] IMPLICIT InternationalString, schema [3] IMPLICIT OBJECT IDENTIFIER OPTIONAL, - elementSetName [4] IMPLICIT InternationalString OPTIONAL} - + elementSetName [4] IMPLICIT InternationalString OPTIONAL, + actionQualifier [5] IMPLICIT EXTERNAL OPTIONAL} OriginPartNotToKeep ::= SuppliedRecords @@ -2445,23 +2446,23 @@ CorrelationInfo ::= SEQUENCE{ id [2] IMPLICIT INTEGER OPTIONAL} TaskPackageRecordStructure ::= SEQUENCE{ - recordOrSurDiag [1] CHOICE { - record [1] IMPLICIT EXTERNAL, - -- Choose 'record' if recordStatus is 'success', and - -- elementSetName was supplied. - diagnostic [2] DiagRec - -- Choose 'diagnostic', if RecordStatus is failure. - } OPTIONAL, - -- The parameter recordOrSurDiag will thus be omitted only if - -- 'elementSetName' was omitted and recordStatus is - -- 'success'; or if record status is 'queued' or in 'process'. - correlationInfo [2] IMPLICIT CorrelationInfo OPTIONAL, + recordOrSurDiag [1] CHOICE { + record [1] IMPLICIT EXTERNAL, + -- ........ + surrogateDiagnostics [2] IMPLICIT + SEQUENCE OF DiagRec + -- Choose 'SurrogateDiagnostics', if + -- RecordStatus is failure. + } OPTIONAL, + correlationInfo [2] IMPLICIT CorrelationInfo OPTIONAL, -- This should be included if it was supplied by the origin. - recordStatus [3] IMPLICIT INTEGER{ + recordStatus [3] IMPLICIT INTEGER{ success (1), queued (2), inProcess (3), - failure (4)}} + failure (4)}, + supplementalDiagnostics [4] IMPLICIT + SEQUENCE OF DiagRec OPTIONAL} END diff --git a/zutil/zoom-c.c b/zutil/zoom-c.c index 1d6a2f2..7d6d55c 100644 --- a/zutil/zoom-c.c +++ b/zutil/zoom-c.c @@ -2,7 +2,7 @@ * Copyright (c) 2000-2003, Index Data * See the file LICENSE for details. * - * $Id: zoom-c.c,v 1.36 2003-05-30 10:24:58 adam Exp $ + * $Id: zoom-c.c,v 1.37 2003-06-02 12:53:28 adam Exp $ * * ZOOM layer for C, connections, result sets, queries. */ @@ -1305,9 +1305,6 @@ ZOOM_record_clone (ZOOM_record srec) nrec->odr = odr_createmem(ODR_DECODE); nrec->wrbuf_marc = 0; nrec->wrbuf_iconv = 0; - nrec->record_charset = 0; - if (srec->record_charset) - nrec->record_charset = odr_strdup(nrec->odr, srec->record_charset); odr_setbuf (nrec->odr, buf, size, 0); z_NamePlusRecord (nrec->odr, &nrec->npr, 0, 0); @@ -1346,7 +1343,8 @@ ZOOM_record_destroy (ZOOM_record rec) } static const char *record_iconv_return(ZOOM_record rec, int *len, - const char *buf, int sz) + const char *buf, int sz, + const char *record_charset) { char to[40]; char from[40]; @@ -1354,26 +1352,26 @@ static const char *record_iconv_return(ZOOM_record rec, int *len, *from = '\0'; strcpy(to, "UTF-8"); - if (rec->record_charset) + if (record_charset && *record_charset) { /* Use "from,to" or just "from" */ - const char *cp =strchr(rec->record_charset, ','); - int clen = strlen(rec->record_charset); + const char *cp =strchr(record_charset, ','); + int clen = strlen(record_charset); if (cp && cp[1]) { strncpy( to, cp+1, sizeof(to)-1); to[sizeof(to)-1] = '\0'; - clen = cp - rec->record_charset; + clen = cp - record_charset; } if (clen > sizeof(from)-1) clen = sizeof(from)-1; if (clen) - strncpy(from, rec->record_charset, clen); + strncpy(from, record_charset, clen); from[clen] = '\0'; } - if (*from && *to && (cd = yaz_iconv_open("UTF-8", rec->record_charset))) + if (*from && *to && (cd = yaz_iconv_open(to, from))) { char outbuf[12]; size_t inbytesleft = sz; @@ -1410,8 +1408,12 @@ static const char *record_iconv_return(ZOOM_record rec, int *len, } ZOOM_API(const char *) -ZOOM_record_get (ZOOM_record rec, const char *type, int *len) +ZOOM_record_get (ZOOM_record rec, const char *type_spec, int *len) { + char type[40]; + char charset[40]; + const char *cp; + int i; Z_NamePlusRecord *npr; if (len) @@ -1422,6 +1424,34 @@ ZOOM_record_get (ZOOM_record rec, const char *type, int *len) npr = rec->npr; if (!npr) return 0; + + cp = type_spec; + for (i = 0; cp[i] && i < sizeof(type)-1; i++) + { + if (cp[i] == ';' || cp[i] == ' ') + break; + type[i] = cp[i]; + } + type[i] = '\0'; + charset[0] = '\0'; + if (type_spec[i] == ';') + { + i++; + while (type_spec[i] == ' ') + i++; + if (!strncmp(type_spec+i, "charset=", 8)) + { + cp = type_spec+i+8; + for (i = 0; cp[i] && i < sizeof(charset)-1; i++) + { + if (cp[i] == ';' || cp[i] == ' ') + break; + charset[i] = cp[i]; + } + charset[i] = '\0'; + } + } + if (!strcmp (type, "database")) { if (len) @@ -1452,7 +1482,8 @@ ZOOM_record_get (ZOOM_record rec, const char *type, int *len) if (r->which == Z_External_sutrs) return record_iconv_return(rec, len, - r->u.sutrs->buf, r->u.sutrs->len); + r->u.sutrs->buf, r->u.sutrs->len, + charset); else if (r->which == Z_External_octet) { yaz_marc_t mt; @@ -1479,13 +1510,15 @@ ZOOM_record_get (ZOOM_record rec, const char *type, int *len) yaz_marc_destroy(mt); return record_iconv_return(rec, len, wrbuf_buf(rec->wrbuf_marc), - wrbuf_len(rec->wrbuf_marc)); + wrbuf_len(rec->wrbuf_marc), + charset); } yaz_marc_destroy(mt); } return record_iconv_return(rec, len, (const char *) r->u.octet_aligned->buf, - r->u.octet_aligned->len); + r->u.octet_aligned->len, + charset); } else if (r->which == Z_External_grs1) { @@ -1495,7 +1528,8 @@ ZOOM_record_get (ZOOM_record rec, const char *type, int *len) yaz_display_grs1(rec->wrbuf_marc, r->u.grs1, 0); return record_iconv_return(rec, len, wrbuf_buf(rec->wrbuf_marc), - wrbuf_len(rec->wrbuf_marc)); + wrbuf_len(rec->wrbuf_marc), + charset); } return 0; } @@ -1508,7 +1542,8 @@ ZOOM_record_get (ZOOM_record rec, const char *type, int *len) if (r->which == Z_External_sutrs) return record_iconv_return(rec, len, (const char *) r->u.sutrs->buf, - r->u.sutrs->len); + r->u.sutrs->len, + charset); else if (r->which == Z_External_octet) { yaz_marc_t mt; @@ -1540,13 +1575,15 @@ ZOOM_record_get (ZOOM_record rec, const char *type, int *len) yaz_marc_destroy(mt); return record_iconv_return(rec, len, wrbuf_buf(rec->wrbuf_marc), - wrbuf_len(rec->wrbuf_marc)); + wrbuf_len(rec->wrbuf_marc), + charset); } yaz_marc_destroy(mt); } return record_iconv_return(rec, len, (const char *) r->u.octet_aligned->buf, - r->u.octet_aligned->len); + r->u.octet_aligned->len, + charset); } else if (r->which == Z_External_grs1) { @@ -1610,8 +1647,6 @@ static void record_cache_add (ZOOM_resultset r, Z_NamePlusRecord *npr, ZOOM_resultset_option_get (r, "elementSetName"); const char *syntax = ZOOM_resultset_option_get (r, "preferredRecordSyntax"); - const char *recordCharset = - ZOOM_resultset_option_get (r, "recordCharset"); ZOOM_Event event = ZOOM_Event_create(ZOOM_EVENT_RECV_RECORD); ZOOM_connection_put_event(r->connection, event); @@ -1626,8 +1661,6 @@ static void record_cache_add (ZOOM_resultset r, Z_NamePlusRecord *npr, continue; if (strcmp_null(syntax, rc->syntax)) continue; - if (strcmp_null(recordCharset, rc->rec.record_charset)) - continue; /* not destroying rc->npr (it's handled by nmem )*/ rc->rec.npr = npr; /* keeping wrbuf_marc too */ @@ -1654,10 +1687,6 @@ static void record_cache_add (ZOOM_resultset r, Z_NamePlusRecord *npr, else rc->schema = 0; - rc->rec.record_charset = 0; - if (recordCharset) - rc->rec.record_charset = odr_strdup(r->odr, recordCharset); - rc->pos = pos; rc->next = r->record_cache; r->record_cache = rc; diff --git a/zutil/zoom-p.h b/zutil/zoom-p.h index 82f1371..1871801 100644 --- a/zutil/zoom-p.h +++ b/zutil/zoom-p.h @@ -1,6 +1,6 @@ /* * Private C header for ZOOM C. - * $Id: zoom-p.h,v 1.8 2003-05-30 10:24:58 adam Exp $ + * $Id: zoom-p.h,v 1.9 2003-06-02 12:53:28 adam Exp $ */ #if HAVE_XSLT @@ -63,7 +63,6 @@ struct ZOOM_connection_p { ZOOM_Event m_queue_back; }; - struct ZOOM_options_entry { char *name; char *value; @@ -104,7 +103,6 @@ struct ZOOM_record_p { WRBUF wrbuf_marc; WRBUF wrbuf_iconv; Z_NamePlusRecord *npr; - char *record_charset; }; struct ZOOM_record_cache_p { -- 1.7.10.4