From: Adam Dickmeiss Date: Mon, 16 Apr 2007 21:53:08 +0000 (+0000) Subject: Generate built-in OIDs from oid.csv. X-Git-Tag: YAZ.3.0.0~50 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=3cdfbd27dfc8dd15619f127ae78bf0f71b27dd6d Generate built-in OIDs from oid.csv. --- diff --git a/client/admin.c b/client/admin.c index eaca6ec..9b2d870 100644 --- a/client/admin.c +++ b/client/admin.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: admin.c,v 1.24 2007-04-12 13:52:57 adam Exp $ + * $Id: admin.c,v 1.25 2007-04-16 21:53:08 adam Exp $ */ #include @@ -53,11 +53,7 @@ int sendAdminES(int type, char* param1) printf ("Admin request\n"); fflush(stdout); - oid = yaz_string_to_oid_odr(yaz_oid_std(), - CLASS_EXTSERV, - OID_STR_ADMIN, - out); - + oid = odr_oiddup(out, yaz_oid_extserv_admin); req->packageType = oid; req->packageName = "1.Extendedserveq"; diff --git a/client/client.c b/client/client.c index b091b31..d8edfe1 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.333 2007-04-12 20:47:27 adam Exp $ + * $Id: client.c,v 1.334 2007-04-16 21:53:08 adam Exp $ */ /** \file client.c * \brief yaz-client program @@ -339,9 +339,7 @@ static void send_initRequest(const char* type_and_host) if (yazProxy && type_and_host) { - const int *oid_proxy = yaz_string_to_oid(yaz_oid_std(), - CLASS_USERINFO, OID_STR_PROXY); - yaz_oi_set_string_oid(&req->otherInfo, out, oid_proxy, + yaz_oi_set_string_oid(&req->otherInfo, out, yaz_oid_userinfo_proxy, 1, type_and_host); } @@ -859,10 +857,7 @@ static void print_record(const unsigned char *buf, size_t len) static void display_record(Z_External *r) { - char oid_name_buf[OID_STR_MAX]; - int oclass; const int *oid = r->direct_reference; - const char *oid_name = 0; record_last = r; /* @@ -870,7 +865,10 @@ static void display_record(Z_External *r) */ if (oid) { - oid_name = yaz_oid_to_string_buf(oid, &oclass, oid_name_buf); + int oclass; + char oid_name_buf[OID_STR_MAX]; + const char *oid_name + = yaz_oid_to_string_buf(oid, &oclass, oid_name_buf); printf("Record type: "); if (oid_name) printf("%s\n", oid_name); @@ -908,7 +906,7 @@ static void display_record(Z_External *r) } } } - if (oid_name && !yaz_matchstr(oid_name, OID_STR_SOIF)) + if (oid && !oid_oidcmp(oid, yaz_oid_recsyn_soif)) { print_record((const unsigned char *) r->u.octet_aligned->buf, r->u.octet_aligned->len); @@ -918,14 +916,14 @@ static void display_record(Z_External *r) else if (oid && r->which == Z_External_octet) { const char *octet_buf = (char*)r->u.octet_aligned->buf; - if (oid_name && (!yaz_matchstr(oid_name, OID_STR_XML) - || !yaz_matchstr(oid_name, OID_STR_APPLICATION_XML) - || !yaz_matchstr(oid_name, OID_STR_HTML))) + if (oid && (!oid_oidcmp(oid, yaz_oid_recsyn_xml) + || !oid_oidcmp(oid, yaz_oid_recsyn_xml) + || !oid_oidcmp(oid, yaz_oid_recsyn_html))) { print_record((const unsigned char *) octet_buf, r->u.octet_aligned->len); } - else if (oid_name && !yaz_matchstr(oid_name, OID_STR_POSTSCRIPT)) + else if (oid && !oid_oidcmp(oid, yaz_oid_recsyn_postscript)) { int size = r->u.octet_aligned->len; if (size > 100) @@ -953,7 +951,7 @@ static void display_record(Z_External *r) if (marcCharset && !strcmp(marcCharset, "auto")) { - if (!yaz_matchstr(oid_name, OID_STR_USMARC)) + if (!oid_oidcmp(oid, yaz_oid_recsyn_usmarc)) { if (octet_buf[9] == 'a') from = "UTF-8"; @@ -1003,7 +1001,7 @@ static void display_record(Z_External *r) if (marc_file) fwrite (octet_buf, 1, r->u.octet_aligned->len, marc_file); } - else if (oid_name && !yaz_matchstr(oid_name, OID_STR_SUTRS)) + else if (oid && !oid_oidcmp(oid, yaz_oid_recsyn_sutrs)) { if (r->which != Z_External_sutrs) { @@ -1014,7 +1012,7 @@ static void display_record(Z_External *r) if (marc_file) fwrite (r->u.sutrs->buf, 1, r->u.sutrs->len, marc_file); } - else if (oid_name && !yaz_matchstr(oid_name, OID_STR_GRS1)) + else if (oid && !oid_oidcmp(oid, yaz_oid_recsyn_grs_1)) { WRBUF w; if (r->which != Z_External_grs1) @@ -1027,7 +1025,7 @@ static void display_record(Z_External *r) puts (wrbuf_cstr(w)); wrbuf_destroy(w); } - else if (oid_name && !yaz_matchstr(oid_name, OID_STR_OPAC)) + else if (oid && !oid_oidcmp(oid, yaz_oid_recsyn_opac)) { int i; if (r->u.opac->bibliographicRecord) @@ -1166,7 +1164,7 @@ static void display_diagrecs(Z_DiagRec **pp, int num) const char *diag_name = 0; diag_name = yaz_oid_to_string_buf (r->diagnosticSetId, &oclass, diag_name_buf); - if (yaz_matchstr(diag_name, OID_STR_BIB1)) + if (oid_oidcmp(r->diagnosticSetId, yaz_oid_diagset_bib_1)) printf("Unknown diagset: %s\n", diag_name); } printf(" [%d] %s", *r->condition, diagbib1_str(*r->condition)); diff --git a/configure.ac b/configure.ac index 5592298..e889524 100644 --- a/configure.ac +++ b/configure.ac @@ -1,8 +1,8 @@ dnl YAZ Toolkit, Index Data 1995-2007 dnl See the file LICENSE for details. -dnl $Id: configure.ac,v 1.73 2007-04-12 13:53:33 adam Exp $ +dnl $Id: configure.ac,v 1.74 2007-04-16 21:53:08 adam Exp $ AC_PREREQ(2.59) -AC_INIT([yaz],[2.1.99.2],[yaz-help@indexdata.dk]) +AC_INIT([yaz],[2.1.99.3],[yaz-help@indexdata.dk]) AC_CONFIG_SRCDIR(configure.ac) AC_CONFIG_AUX_DIR([config]) AM_INIT_AUTOMAKE([1.8]) diff --git a/include/yaz/Makefile.am b/include/yaz/Makefile.am index 89621e2..acf1c52 100644 --- a/include/yaz/Makefile.am +++ b/include/yaz/Makefile.am @@ -1,4 +1,4 @@ -## $Id: Makefile.am,v 1.41 2007-04-12 13:52:57 adam Exp $ +## $Id: Makefile.am,v 1.42 2007-04-16 21:53:08 adam Exp $ pkginclude_HEADERS= backend.h ccl.h ccl_xml.h cql.h comstack.h \ diagbib1.h diagsrw.h diagsru_update.h sortspec.h log.h logrpn.h marcdisp.h \ @@ -8,7 +8,7 @@ pkginclude_HEADERS= backend.h ccl.h ccl_xml.h cql.h comstack.h \ tcpip.h test.h timing.h unix.h tpath.h wrbuf.h xmalloc.h \ yaz-ccl.h yaz-iconv.h yaz-util.h yaz-version.h yconfig.h proto.h \ xmlquery.h libxml2_error.h xmltypes.h snprintf.h query-charset.h \ - oid_db.h oid_util.h \ + oid_db.h oid_util.h oid_std.h \ \ ill.h ill-core.h item-req.h z-accdes1.h z-accform1.h \ z-acckrb1.h z-core.h z-date.h z-diag1.h z-espec1.h z-estask.h z-exp.h \ diff --git a/include/yaz/oid_db.h b/include/yaz/oid_db.h index 4e208e9..ca75db7 100644 --- a/include/yaz/oid_db.h +++ b/include/yaz/oid_db.h @@ -24,7 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* $Id: oid_db.h,v 1.4 2007-04-16 08:43:08 adam Exp $ */ +/* $Id: oid_db.h,v 1.5 2007-04-16 21:53:08 adam Exp $ */ /** * \file oid_db.h @@ -136,53 +136,16 @@ YAZ_EXPORT int yaz_oid_add(yaz_oid_db_t oid_db, int oclass, const char *name, const int *new_oid); -#define OID_STR_BIB1 "Bib-1" -#define OID_STR_DIAG1 "Diag-1" -#define OID_STR_USMARC "USmarc" -#define OID_STR_XML "XML" -#define OID_STR_SOIF "SOIF" -#define OID_STR_APPLICATION_XML "application-XML" -#define OID_STR_HTML "html" -#define OID_STR_GRS1 "GRS-1" -#define OID_STR_POSTSCRIPT "postscript" -#define OID_STR_SUTRS "SUTRS" -#define OID_STR_OPAC "OPAC" -#define OID_STR_EXPLAIN "Explain" -#define OID_STR_SUMMARY "Summary" -#define OID_STR_EXTENDED "Extended" -#define OID_STR_COOKIE "Cookie" -#define OID_STR_PROXY "Proxy" -#define OID_STR_CLIENT_IP "Client-IP" -#define OID_STR_ILL_1 "ISOILL-1" -#define OID_STR_ADMIN "Admin" -#define OID_STR_XMLES "XML-ES" -#define OID_STR_EXT_UPDATE "DB. Update" -#define OID_STR_ITEMORDER "Item order" -#define OID_STR_USERINFO_1 "UserInfo-1" -#define OID_STR_ID_CHARSET "ID-Charset" -#define OID_STR_CHARNEG_3 "CharSetandLanguageNegotiation-3" -#define OID_STR_CHARNEG_4 "CharSetandLanguageNegotiation-4" -#define OID_STR_VARIANT_1 "Variant-1" -#define OID_STR_SEARCH_RESULT_1 "searchResult-1" - -YAZ_EXPORT const int *yaz_oid_xml(void); -YAZ_EXPORT const int *yaz_oid_application_xml(void); -YAZ_EXPORT const int *yaz_oid_html(void); -YAZ_EXPORT const int *yaz_oid_sutrs(void); -YAZ_EXPORT const int *yaz_oid_opac(void); -YAZ_EXPORT const int *yaz_oid_grs1(void); -YAZ_EXPORT const int *yaz_oid_postscript(void); -YAZ_EXPORT const int *yaz_oid_explain(void); -YAZ_EXPORT const int *yaz_oid_extended(void); -YAZ_EXPORT const int *yaz_oid_summary(void); -YAZ_EXPORT const int *yaz_oid_get_usmarc(void); -YAZ_EXPORT const int *yaz_oid_soif(void); -YAZ_EXPORT const int *yaz_oid_attset_bib1(void); -YAZ_EXPORT const int *yaz_oid_diag1(void); -YAZ_EXPORT const int *yaz_oid_proxy(void); -YAZ_EXPORT const int *yaz_oid_cookie(void); -YAZ_EXPORT const int *yaz_oid_search_result_1(void); -YAZ_EXPORT const int *yaz_oid_variant1(void); +struct yaz_oid_entry { + int oclass; + const int *oid; + char *name; +}; + +#define Z3950_PREFIX 1, 2, 840, 10003 + +#include + YAZ_END_CDECL #endif diff --git a/src/Makefile.am b/src/Makefile.am index 7499876..0ee0d30 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ ## This file is part of the YAZ toolkit. ## Copyright (C) 1995-2007, Index Data, All rights reserved. -## $Id: Makefile.am,v 1.57 2007-04-16 11:15:51 adam Exp $ +## $Id: Makefile.am,v 1.58 2007-04-16 21:53:09 adam Exp $ YAZ_VERSION_INFO=3:0:0 @@ -21,7 +21,7 @@ EXTRA_DIST=$(tabdata_DATA) $(illdata_DATA) \ charconv.tcl codetables.xml \ csvtodiag.tcl csvtobib1.tcl csvtosrw.tcl bib1.csv srw.csv \ csvtosru_update.tcl sru_update.csv \ - oid.csv + oidtoc.tcl oid.csv YAZCOMP=$(top_srcdir)/util/yaz-asncomp YAZCOMP_Z = $(YAZCOMP) -d $(srcdir)/z.tcl -i yaz -I$(top_srcdir)/include @@ -39,6 +39,10 @@ marc8.c: charconv.tcl codetables.xml marc8r.c: charconv.tcl codetables.xml $(TCLSH) $(srcdir)/charconv.tcl -r -p marc8r $(srcdir)/codetables.xml -o marc8r.c +# Generate OID database from CSV +oid_std.c $(top_srcdir)/include/yaz/oid_std.h: oidtoc.tcl oid.csv + $(TCLSH) $(srcdir)/oidtoc.tcl $(srcdir)/oid.csv $(srcdir)/oid_std.c $(top_srcdir)/include/yaz/oid_std.h + # Generate diagnostics from CSVs diagbib1.c $(top_srcdir)/include/yaz/diagbib1.h: csvtobib1.tcl bib1.csv $(TCLSH) $(srcdir)/csvtobib1.tcl $(srcdir) @@ -80,7 +84,7 @@ libyaz_la_SOURCES=version.c options.c log.c \ eventl.c seshigh.c statserv.c requestq.c tcpdchk.c \ eventl.h service.c service.h session.h test.c timing.c \ xmlquery.c http.c \ - mime.c mime.h oid_util.c \ + mime.c mime.h oid_util.c oid_std.c \ record_conv.c retrieval.c elementset.c snprintf.c query-charset.c libyaz_la_LDFLAGS=-version-info $(YAZ_VERSION_INFO) diff --git a/src/charneg.c b/src/charneg.c index d6a2398..9f88490 100644 --- a/src/charneg.c +++ b/src/charneg.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: charneg.c,v 1.8 2007-04-12 13:52:57 adam Exp $ + * $Id: charneg.c,v 1.9 2007-04-16 21:53:09 adam Exp $ */ /** @@ -28,10 +28,7 @@ static Z_External* z_ext_record2(ODR o, const char *buf) p->descriptor = 0; p->indirect_reference = 0; - p->direct_reference = yaz_string_to_oid_odr(yaz_oid_std(), - CLASS_NEGOT, - OID_STR_ID_CHARSET, - o); + p->direct_reference = odr_oiddup(o, yaz_oid_negot_charset_id); p->which = Z_External_octet; if (!(p->u.octet_aligned = (Odr_oct *)odr_malloc(o, sizeof(Odr_oct)))) { @@ -175,10 +172,7 @@ Z_External *yaz_set_proposal_charneg(ODR o, p->descriptor = 0; p->indirect_reference = 0; - p->direct_reference = yaz_string_to_oid_odr(yaz_oid_std(), - CLASS_NEGOT, - OID_STR_CHARNEG_3, - o); + p->direct_reference = odr_oiddup(o, yaz_oid_negot_charset_3); p->which = Z_External_charSetandLanguageNegotiation; p->u.charNeg3 = z_get_CharSetandLanguageNegotiation(o); @@ -266,10 +260,7 @@ Z_External *yaz_set_response_charneg(ODR o, const char *charset, p->descriptor = 0; p->indirect_reference = 0; - p->direct_reference = yaz_string_to_oid_odr(yaz_oid_std(), - CLASS_NEGOT, - OID_STR_CHARNEG_3, - o); + p->direct_reference = odr_oiddup(o, yaz_oid_negot_charset_3); p->which = Z_External_charSetandLanguageNegotiation; p->u.charNeg3 = z_get_CharSetandLanguageNegotiation(o); @@ -291,14 +282,8 @@ Z_CharSetandLanguageNegotiation *yaz_get_charneg_record(Z_OtherInformation *p) Z_External *pext; if ((p->list[i]->which == Z_OtherInfo_externallyDefinedInfo) && (pext = p->list[i]->information.externallyDefinedInfo)) { - - int oclass; - const char *name = yaz_oid_to_string(yaz_oid_std(), - pext->direct_reference, - &oclass); - - if (oclass == CLASS_NEGOT - && name && !strcmp(name, OID_STR_CHARNEG_3) + + if (!oid_oidcmp(pext->direct_reference, yaz_oid_negot_charset_3) && pext->which == Z_External_charSetandLanguageNegotiation) { return pext->u.charNeg3; @@ -321,13 +306,7 @@ int yaz_del_charneg_record(Z_OtherInformation **p) if (((*p)->list[i]->which == Z_OtherInfo_externallyDefinedInfo) && (pext = (*p)->list[i]->information.externallyDefinedInfo)) { - int oclass; - const char *name = yaz_oid_to_string(yaz_oid_std(), - pext->direct_reference, - &oclass); - - if (oclass == CLASS_NEGOT - && name && !strcmp(name, OID_STR_CHARNEG_3) + if (!oid_oidcmp(pext->direct_reference, yaz_oid_negot_charset_3) && pext->which == Z_External_charSetandLanguageNegotiation) { if ((*p)->num_elements <= 1) diff --git a/src/oid.csv b/src/oid.csv index b375043..1aeb30c 100644 --- a/src/oid.csv +++ b/src/oid.csv @@ -1,4 +1,4 @@ -"$Id: oid.csv,v 1.1 2007-04-16 11:15:51 adam Exp $" +"$Id: oid.csv,v 1.2 2007-04-16 21:53:09 adam Exp $" TRANSYN, 2.1.1, "BER" TRANSYN, 1.0.2709.1.1, "ISO2709" GENERAL, 1.0.10161.2.1, "ISOILL-1" @@ -88,13 +88,13 @@ RESFORM, Z3950_PREFIX.7.1000.81.1, "UNIverse-Resource-Report" ACCFORM, Z3950_PREFIX.8.1, "Prompt-1" ACCFORM, Z3950_PREFIX.8.2, "Des-1" ACCFORM, Z3950_PREFIX.8.3, "Krb-1" -EXTSERV, Z3950_PREFIX.9.1, "Pers. set" -EXTSERV, Z3950_PREFIX.9.2, "Pers. query" -EXTSERV, Z3950_PREFIX.9.3, "Per'd query" +EXTSERV, Z3950_PREFIX.9.1, "Persistent set" +EXTSERV, Z3950_PREFIX.9.2, "Persistent query" +EXTSERV, Z3950_PREFIX.9.3, "Periodic query" EXTSERV, Z3950_PREFIX.9.4, "Item order" -EXTSERV, Z3950_PREFIX.9.5, "DB. Update (first version)" -EXTSERV, Z3950_PREFIX.9.5.1, "DB. Update (second version)" -EXTSERV, Z3950_PREFIX.9.5.1.1, "DB. Update" +EXTSERV, Z3950_PREFIX.9.5, "Database Update (first version)" +EXTSERV, Z3950_PREFIX.9.5.1, "Database Update (second version)" +EXTSERV, Z3950_PREFIX.9.5.1.1, "Database Update" EXTSERV, Z3950_PREFIX.9.6, "exp. spec." EXTSERV, Z3950_PREFIX.9.7, "exp. inv." EXTSERV, Z3950_PREFIX.9.1000.81.1, "Admin" @@ -128,9 +128,9 @@ TAGSET, Z3950_PREFIX.14.6, "CIMI-tagset" TAGSET, Z3950_PREFIX.14.1000.81.1, "thesaurus-tagset" TAGSET, Z3950_PREFIX.14.1000.81.2, "Explain-tagset" TAGSET, Z3950_PREFIX.14.8, "Zthes-tagset" -NEGOT, Z3950_PREFIX.15.3, "CharSetandLanguageNegotiation-3" -NEGOT, Z3950_PREFIX.15.4, "CharSetandLanguageNegotiation-4" -NEGOT, Z3950_PREFIX.15.1000.81.1, "ID-Charset" +NEGOT, Z3950_PREFIX.15.3, "Charset-3" +NEGOT, Z3950_PREFIX.15.4, "Charset-4" +NEGOT, Z3950_PREFIX.15.1000.81.1, "Charset-ID" USERINFO, Z3950_PREFIX.16.2, "CQL" GENERAL, 1.0.10646.1.0.2, "UCS-2" GENERAL, 1.0.10646.1.0.4, "UCS-4" diff --git a/src/oid_db.c b/src/oid_db.c index 2b1d79e..3795bba 100644 --- a/src/oid_db.c +++ b/src/oid_db.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: oid_db.c,v 1.4 2007-04-16 08:43:08 adam Exp $ + * $Id: oid_db.c,v 1.5 2007-04-16 21:53:09 adam Exp $ */ /** @@ -21,171 +21,15 @@ #include #include -struct yaz_oid_entry { - int oclass; - int oid[OID_SIZE]; - char *name; -}; - -#define Z3950_PREFIX 1, 2, 840, 10003 - -static struct yaz_oid_entry standard_list[] = -{ - /* General definitions */ - {CLASS_TRANSYN, {2, 1, 1,-1}, "BER" }, - {CLASS_TRANSYN, {1, 0, 2709, 1, 1,-1}, "ISO2709"}, - {CLASS_GENERAL, {1, 0, 10161, 2, 1,-1}, OID_STR_ILL_1 }, - {CLASS_ABSYN, {2, 1,-1}, "Z-APDU"}, - {CLASS_APPCTX, {1, 1,-1}, "Z-BASIC"}, - {CLASS_ATTSET, {Z3950_PREFIX, 3, 1,-1}, "Bib-1"}, - {CLASS_ATTSET, {Z3950_PREFIX, 3, 2,-1}, "Exp-1"}, - {CLASS_ATTSET, {Z3950_PREFIX, 3, 3,-1}, "Ext-1"}, - {CLASS_ATTSET, {Z3950_PREFIX, 3, 4,-1}, "CCL-1"}, - {CLASS_ATTSET, {Z3950_PREFIX, 3, 5,-1}, "GILS"}, - {CLASS_ATTSET, {Z3950_PREFIX, 3, 5,-1}, "GILS-attset"}, - {CLASS_ATTSET, {Z3950_PREFIX, 3, 6,-1}, "STAS-attset"}, - {CLASS_ATTSET, {Z3950_PREFIX, 3, 7,-1}, "Collections-attset"}, - {CLASS_ATTSET, {Z3950_PREFIX, 3, 8,-1}, "CIMI-attset"}, - {CLASS_ATTSET, {Z3950_PREFIX, 3, 9,-1}, "Geo-attset"}, - {CLASS_ATTSET, {Z3950_PREFIX, 3, 10,-1}, "ZBIG"}, - {CLASS_ATTSET, {Z3950_PREFIX, 3, 11,-1}, "Util"}, - {CLASS_ATTSET, {Z3950_PREFIX, 3, 12,-1}, "XD-1"}, - {CLASS_ATTSET, {Z3950_PREFIX, 3, 13,-1}, "Zthes"}, - {CLASS_ATTSET, {Z3950_PREFIX, 3, 14,-1}, "Fin-1"}, - {CLASS_ATTSET, {Z3950_PREFIX, 3, 15,-1}, "Dan-1"}, - {CLASS_ATTSET, {Z3950_PREFIX, 3, 16,-1}, "Holdings"}, - {CLASS_ATTSET, {Z3950_PREFIX, 3, 17,-1}, "MARC"}, - {CLASS_ATTSET, {Z3950_PREFIX, 3, 18,-1}, "Bib-2"}, - {CLASS_ATTSET, {Z3950_PREFIX, 3, 19,-1}, "ZeeRex"}, - /* New applications should use Zthes-1 instead of this Satan-spawn */ - {CLASS_ATTSET, {Z3950_PREFIX, 3,1000, 81,1,-1}, "Thesaurus-attset"}, - {CLASS_ATTSET, {Z3950_PREFIX, 3,1000, 81,2,-1}, "IDXPATH"}, - {CLASS_ATTSET, {Z3950_PREFIX, 3,1000, 81,3,-1}, "EXTLITE"}, - {CLASS_DIAGSET, {Z3950_PREFIX, 4, 1,-1}, OID_STR_BIB1}, - {CLASS_DIAGSET, {Z3950_PREFIX, 4, 2,-1}, OID_STR_DIAG1}, - {CLASS_DIAGSET, {Z3950_PREFIX, 4, 3,-1}, "Diag-ES"}, - {CLASS_DIAGSET, {Z3950_PREFIX, 4, 3,-1}, "Diag-General"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 1,-1}, "Unimarc"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 2,-1}, "Intermarc"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 3,-1}, "CCF"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 10,-1}, OID_STR_USMARC}, - /* MARC21 is just an alias for the original USmarc */ - {CLASS_RECSYN, {Z3950_PREFIX, 5, 10,-1}, "MARC21"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 11,-1}, "UKmarc"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 12,-1}, "Normarc"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 13,-1}, "Librismarc"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 14,-1}, "Danmarc"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 15,-1}, "Finmarc"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 16,-1}, "MAB"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 17,-1}, "Canmarc"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 18,-1}, "SBN"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 19,-1}, "Picamarc"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 20,-1}, "Ausmarc"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 21,-1}, "Ibermarc"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 22,-1}, "Carmarc"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 23,-1}, "Malmarc"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 24,-1}, "JPmarc"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 25,-1}, "SWEmarc"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 26,-1}, "SIGLEmarc"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 27,-1}, "ISDSmarc"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 28,-1}, "RUSmarc"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 29,-1}, "Hunmarc"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 30,-1}, "NACSIS-CATP"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 31,-1}, "FINMARC2000"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 32,-1}, "MARC21-fin"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 100,-1}, OID_STR_EXPLAIN}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 101,-1}, OID_STR_SUTRS}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 102,-1}, OID_STR_OPAC}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 103,-1}, OID_STR_SUMMARY}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 104,-1}, "GRS-0"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 105,-1}, OID_STR_GRS1 }, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 106,-1}, OID_STR_EXTENDED}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 107,-1}, "Fragment"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 109,1,-1}, "pdf"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 109,2,-1}, OID_STR_POSTSCRIPT}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 109,3,-1}, OID_STR_HTML}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 109,4,-1}, "tiff"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 109,5,-1}, "gif"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 109,6,-1}, "jpeg"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 109,7,-1}, "png"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 109,8,-1}, "mpeg"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 109,9,-1}, "sgml"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 110,1,-1}, "tiff-b"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 110,2,-1}, "wav"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 111,-1}, "SQL-RS"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 1000, 81, 2,-1}, OID_STR_SOIF}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 109, 10,-1}, OID_STR_XML }, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 109, 10,-1}, "application-XML"}, - {CLASS_RECSYN, {Z3950_PREFIX, 5, 109, 11,-1}, OID_STR_APPLICATION_XML }, - {CLASS_RESFORM, {Z3950_PREFIX, 7, 1,-1}, "Resource-1"}, - {CLASS_RESFORM, {Z3950_PREFIX, 7, 2,-1}, "Resource-2"}, - {CLASS_RESFORM, {Z3950_PREFIX, 7, 1000, 81, 1,-1}, "UNIverse-Resource-Report"}, - {CLASS_ACCFORM, {Z3950_PREFIX, 8, 1,-1}, "Prompt-1"}, - {CLASS_ACCFORM, {Z3950_PREFIX, 8, 2,-1}, "Des-1"}, - {CLASS_ACCFORM, {Z3950_PREFIX, 8, 3,-1}, "Krb-1"}, - {CLASS_EXTSERV, {Z3950_PREFIX, 9, 1,-1}, "Pers. set"}, - {CLASS_EXTSERV, {Z3950_PREFIX, 9, 2,-1}, "Pers. query"}, - {CLASS_EXTSERV, {Z3950_PREFIX, 9, 3,-1}, "Per'd query"}, - {CLASS_EXTSERV, {Z3950_PREFIX, 9, 4,-1}, OID_STR_ITEMORDER }, - {CLASS_EXTSERV, {Z3950_PREFIX, 9, 5,-1}, "DB. Update (first version)"}, - {CLASS_EXTSERV, {Z3950_PREFIX, 9, 5,1,-1}, "DB. Update (second version)"}, - {CLASS_EXTSERV, {Z3950_PREFIX, 9, 5, 1, 1,-1}, OID_STR_EXT_UPDATE}, - {CLASS_EXTSERV, {Z3950_PREFIX, 9, 6,-1}, "exp. spec."}, - {CLASS_EXTSERV, {Z3950_PREFIX, 9, 7,-1}, "exp. inv."}, - {CLASS_EXTSERV, {Z3950_PREFIX, 9, 1000, 81, 1,-1}, OID_STR_ADMIN}, - {CLASS_USERINFO, {Z3950_PREFIX, 10, 1,-1}, OID_STR_SEARCH_RESULT_1}, - {CLASS_USERINFO, {Z3950_PREFIX, 10, 2,-1}, "CharSetandLanguageNegotiation"}, - {CLASS_USERINFO, {Z3950_PREFIX, 10, 3,-1}, OID_STR_USERINFO_1}, - {CLASS_USERINFO, {Z3950_PREFIX, 10, 4,-1}, "MultipleSearchTerms-1"}, - {CLASS_USERINFO, {Z3950_PREFIX, 10, 5,-1}, "MultipleSearchTerms-2"}, - {CLASS_USERINFO, {Z3950_PREFIX, 10, 6,-1}, "DateTime"}, - {CLASS_USERINFO, {Z3950_PREFIX, 10, 1000, 81, 1,-1}, OID_STR_PROXY}, - {CLASS_USERINFO, {Z3950_PREFIX, 10, 1000, 81, 2,-1}, OID_STR_COOKIE}, - {CLASS_USERINFO, {Z3950_PREFIX, 10, 1000, 81, 3,-1}, OID_STR_CLIENT_IP }, - {CLASS_ELEMSPEC, {Z3950_PREFIX, 11, 1,-1}, "Espec-1"}, - {CLASS_VARSET, {Z3950_PREFIX, 12, 1,-1}, OID_STR_VARIANT_1}, - {CLASS_SCHEMA, {Z3950_PREFIX, 13, 1,-1}, "WAIS-schema"}, - {CLASS_SCHEMA, {Z3950_PREFIX, 13, 2,-1}, "GILS-schema"}, - {CLASS_SCHEMA, {Z3950_PREFIX, 13, 3,-1}, "Collections-schema"}, - {CLASS_SCHEMA, {Z3950_PREFIX, 13, 4,-1}, "Geo-schema"}, - {CLASS_SCHEMA, {Z3950_PREFIX, 13, 5,-1}, "CIMI-schema"}, - {CLASS_SCHEMA, {Z3950_PREFIX, 13, 6,-1}, "Update ES"}, - {CLASS_SCHEMA, {Z3950_PREFIX, 13, 7,-1}, "Holdings"}, - {CLASS_SCHEMA, {Z3950_PREFIX, 13, 8,-1}, "Zthes"}, - {CLASS_SCHEMA, {Z3950_PREFIX, 13, 1000, 81, 1,-1}, "thesaurus-schema"}, - {CLASS_SCHEMA, {Z3950_PREFIX, 13, 1000, 81, 2,-1}, "Explain-schema"}, - {CLASS_TAGSET, {Z3950_PREFIX, 14, 1,-1}, "TagsetM"}, - {CLASS_TAGSET, {Z3950_PREFIX, 14, 2,-1}, "TagsetG"}, - {CLASS_TAGSET, {Z3950_PREFIX, 14, 3,-1}, "STAS-tagset"}, - {CLASS_TAGSET, {Z3950_PREFIX, 14, 4,-1}, "GILS-tagset"}, - {CLASS_TAGSET, {Z3950_PREFIX, 14, 5,-1}, "Collections-tagset"}, - {CLASS_TAGSET, {Z3950_PREFIX, 14, 6,-1}, "CIMI-tagset"}, - {CLASS_TAGSET, {Z3950_PREFIX, 14, 1000, 81, 1,-1}, "thesaurus-tagset"}, - {CLASS_TAGSET, {Z3950_PREFIX, 14, 1000, 81, 2,-1}, "Explain-tagset"}, - {CLASS_TAGSET, {Z3950_PREFIX, 14, 8,-1}, "Zthes-tagset"}, - {CLASS_NEGOT, {Z3950_PREFIX, 15, 3,-1}, OID_STR_CHARNEG_3 }, - {CLASS_NEGOT, {Z3950_PREFIX, 15, 4,-1}, OID_STR_CHARNEG_4 }, - {CLASS_NEGOT, {Z3950_PREFIX, 15, 1000, 81, 1, -1}, OID_STR_ID_CHARSET }, - {CLASS_USERINFO, {1, 2, 840, 1003, 16, 2, -1}, "CQL"}, - {CLASS_GENERAL, {1,0,10646,1,0,2,-1}, "UCS-2"}, - {CLASS_GENERAL, {1,0,10646,1,0,4,-1}, "UCS-4"}, - {CLASS_GENERAL, {1,0,10646,1,0,5,-1}, "UTF-16"}, - {CLASS_GENERAL, {1,0,10646,1,0,8,-1}, "UTF-8"}, - {CLASS_USERINFO, {Z3950_PREFIX, 10, 1000, 17, 1, -1}, "OCLC-userInfo"}, - {CLASS_EXTSERV, {Z3950_PREFIX, 9, 1000,105,4,-1}, OID_STR_XMLES }, - {CLASS_NOP, {-1}, 0} -}; - struct yaz_oid_db { - struct yaz_oid_entry *entries; - struct yaz_oid_db *next; - int xmalloced; + struct yaz_oid_entry *entries; + struct yaz_oid_db *next; + int xmalloced; }; struct yaz_oid_db standard_db_l = { - standard_list, 0, 0 + yaz_oid_standard_entries, 0, 0 }; - yaz_oid_db_t standard_db = &standard_db_l; yaz_oid_db_t yaz_oid_std(void) @@ -278,6 +122,7 @@ int yaz_oid_add(yaz_oid_db_t oid_db, int oclass, const char *name, if (!oid) { struct yaz_oid_entry *ent; + int *alloc_oid; while (oid_db->next) oid_db = oid_db->next; @@ -287,12 +132,16 @@ int yaz_oid_add(yaz_oid_db_t oid_db, int oclass, const char *name, oid_db->next = 0; oid_db->xmalloced = 1; oid_db->entries = ent = xmalloc(2 * sizeof(*ent)); - ent[0].oclass = oclass; - oid_oidcpy(ent[0].oid, new_oid); + + alloc_oid = xmalloc(sizeof(*alloc_oid) * (oid_oidlen(new_oid)+1)); + oid_oidcpy(alloc_oid, new_oid); + ent[0].oid = alloc_oid; ent[0].name = xstrdup(name); - ent[1].oclass = CLASS_NOP; - ent[1].oid[0] = -1; + ent[0].oclass = oclass; + + ent[1].oid = 0; ent[1].name = 0; + ent[1].oclass = CLASS_NOP; return 0; } return -1; @@ -340,97 +189,6 @@ void yaz_oid_trav(yaz_oid_db_t oid_db, } } -const int *yaz_oid_xml(void) -{ - return yaz_string_to_oid(yaz_oid_std(), CLASS_RECSYN, OID_STR_XML); -} - -const int *yaz_oid_application_xml(void) -{ - return yaz_string_to_oid(yaz_oid_std(), CLASS_RECSYN, - OID_STR_APPLICATION_XML); -} -const int *yaz_oid_html(void) -{ - return yaz_string_to_oid(yaz_oid_std(), CLASS_RECSYN, OID_STR_HTML); -} - -const int *yaz_oid_sutrs(void) -{ - return yaz_string_to_oid(yaz_oid_std(), CLASS_RECSYN, OID_STR_SUTRS); -} - -const int *yaz_oid_opac(void) -{ - return yaz_string_to_oid(yaz_oid_std(), CLASS_RECSYN, OID_STR_OPAC); -} - -const int *yaz_oid_grs1(void) -{ - return yaz_string_to_oid(yaz_oid_std(), CLASS_RECSYN, OID_STR_GRS1); -} - -const int *yaz_oid_postscript(void) -{ - return yaz_string_to_oid(yaz_oid_std(), CLASS_RECSYN, OID_STR_POSTSCRIPT); -} - -const int *yaz_oid_explain(void) -{ - return yaz_string_to_oid(yaz_oid_std(), CLASS_RECSYN, OID_STR_EXPLAIN); -} - -const int *yaz_oid_extended(void) -{ - return yaz_string_to_oid(yaz_oid_std(), CLASS_RECSYN, OID_STR_EXTENDED); -} - -const int *yaz_oid_summary(void) -{ - return yaz_string_to_oid(yaz_oid_std(), CLASS_RECSYN, OID_STR_SUMMARY); -} - -const int *yaz_oid_get_usmarc(void) -{ - return yaz_string_to_oid(yaz_oid_std(), CLASS_RECSYN, OID_STR_USMARC); -} - -const int *yaz_oid_soif(void) -{ - return yaz_string_to_oid(yaz_oid_std(), CLASS_RECSYN, OID_STR_SOIF); -} - -const int *yaz_oid_attset_bib1(void) -{ - return yaz_string_to_oid(yaz_oid_std(), CLASS_ATTSET, OID_STR_BIB1); -} - -const int *yaz_oid_diag1(void) -{ - return yaz_string_to_oid(yaz_oid_std(), CLASS_DIAGSET, OID_STR_DIAG1); -} - -const int *yaz_oid_proxy(void) -{ - return yaz_string_to_oid(yaz_oid_std(), CLASS_USERINFO, OID_STR_PROXY); -} - -const int *yaz_oid_cookie(void) -{ - return yaz_string_to_oid(yaz_oid_std(), CLASS_USERINFO, OID_STR_COOKIE); -} - -const int *yaz_oid_search_result_1(void) -{ - return yaz_string_to_oid(yaz_oid_std(), CLASS_USERINFO, - OID_STR_SEARCH_RESULT_1); -} - -const int *yaz_oid_variant1(void) -{ - return yaz_string_to_oid(yaz_oid_std(), CLASS_VARSET, OID_STR_VARIANT_1); -} - /* * Local variables: * c-basic-offset: 4 diff --git a/src/oidtoc.tcl b/src/oidtoc.tcl new file mode 100644 index 0000000..7809f3f --- /dev/null +++ b/src/oidtoc.tcl @@ -0,0 +1,82 @@ +# This file is part of the YAZ toolkit +# Copyright (c) Index Data 2006-2007 +# See the file LICENSE for details. +# +# $Id: oidtoc.tcl,v 1.1 2007-04-16 21:53:09 adam Exp $ +# +# Converts a CSV file with Object identifiers to C + +proc readoids {input} { + set csv [open $input r] + set lineno 0 + + while {1} { + incr lineno + set cnt [gets $csv line] + if {$cnt < 0} { + break + } + if {![string compare [string index $line 0] \"]} { + continue + } + set tokens [string map {, { }} $line] + if {[llength $tokens] != 3} { + puts "$input:$lineno: Bad line '$line'" + exit 1 + } + lappend oids $tokens + } + close $csv + if {![info exists oids]} { + puts "$input:0 No OIDS" + exit 1 + } + return $oids +} + +proc oid_to_c {input cfile hfile} { + set oids [readoids $input] + + set cfile [open $cfile w] + set hfile [open $hfile w] + + puts $cfile "\#include " + puts $cfile "" + foreach oid $oids { + set lname [string tolower [lindex $oid 2]] + set lname [string map {- _ . _ { } _ ( {} ) {}} $lname] + set prefix [string tolower [lindex $oid 0]] + + puts -nonewline $cfile "const int yaz_oid_${prefix}_${lname}\[\] = \{" + puts -nonewline $cfile [string map {. ,} [lindex $oid 1]] + puts $cfile ",-1\};" + + puts $hfile "extern const int yaz_oid_${prefix}_${lname}\[\];" + } + + puts $cfile "struct yaz_oid_entry yaz_oid_standard_entries\[\] =" + puts $cfile "\{" + foreach oid $oids { + set lname [string tolower [lindex $oid 2]] + set lname [string map {- _ . _ { } _ ( {} ) {}} $lname] + set prefix [string tolower [lindex $oid 0]] + + puts -nonewline $cfile "\t\{CLASS_[lindex $oid 0], " + puts -nonewline $cfile "yaz_oid_${prefix}_${lname}, " + puts -nonewline $cfile \"[lindex $oid 2]\" + puts $cfile "\}," + } + + puts $cfile "\t\{CLASS_NOP, 0, 0\}" + puts $cfile "\};" + + puts $hfile "extern struct yaz_oid_entry yaz_oid_standard_entries\[\];" + close $cfile + close $hfile +} + +if {[llength $argv] != 3} { + puts "oidtoc.tcl csv cfile hfile" + exit 1 +} +oid_to_c [lindex $argv 0] [lindex $argv 1] [lindex $argv 2] \ No newline at end of file diff --git a/src/pquery.c b/src/pquery.c index a9dbcc3..de99f0c 100644 --- a/src/pquery.c +++ b/src/pquery.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: pquery.c,v 1.10 2007-04-12 13:52:57 adam Exp $ + * $Id: pquery.c,v 1.11 2007-04-16 21:53:09 adam Exp $ */ /** * \file pquery.c @@ -645,8 +645,7 @@ Z_RPNQuery *p_query_rpn_mk(ODR o, struct yaz_pqf_parser *li, const char *qbuf) } if (!top_set) { - top_set = yaz_string_to_oid_odr(yaz_oid_std(), - CLASS_ATTSET, OID_STR_BIB1, o); + top_set = odr_oiddup(o, yaz_oid_attset_bib_1); } zq->attributeSetId = top_set; @@ -710,8 +709,7 @@ Z_AttributesPlusTerm *p_query_scan_mk(struct yaz_pqf_parser *li, } if (!top_set) { - top_set = yaz_string_to_oid_odr(yaz_oid_std(), - CLASS_ATTSET, OID_STR_BIB1, o); + top_set = odr_oiddup(o, yaz_oid_attset_bib_1); } *attributeSetP = top_set; diff --git a/src/prt-ext.c b/src/prt-ext.c index 80d3418..1e1070e 100644 --- a/src/prt-ext.c +++ b/src/prt-ext.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: prt-ext.c,v 1.9 2007-04-13 09:55:41 adam Exp $ + * $Id: prt-ext.c,v 1.10 2007-04-16 21:53:09 adam Exp $ */ /** @@ -266,27 +266,27 @@ Z_External *z_ext_record_oid(ODR o, const int *oid, const char *buf, int len) */ thisext->u.grs1 = (Z_GenericRecord*) buf; - if (!strcmp(oid_str, OID_STR_SUTRS)) + if (!oid_oidcmp(oid, yaz_oid_recsyn_sutrs)) { thisext->which = Z_External_sutrs; } - else if (!strcmp(oid_str, OID_STR_GRS1)) + else if (!oid_oidcmp(oid, yaz_oid_recsyn_grs_1)) { thisext->which = Z_External_grs1; } - else if (!strcmp(oid_str, OID_STR_EXPLAIN)) + else if (!oid_oidcmp(oid, yaz_oid_recsyn_explain)) { thisext->which = Z_External_explainRecord; } - else if (!strcmp(oid_str, OID_STR_SUMMARY)) + else if (!oid_oidcmp(oid, yaz_oid_recsyn_summary)) { thisext->which = Z_External_summary; } - else if (!strcmp(oid_str, OID_STR_OPAC)) + else if (!oid_oidcmp(oid, yaz_oid_recsyn_opac)) { thisext->which = Z_External_OPAC; } - else if (!strcmp(oid_str, OID_STR_EXTENDED)) + else if (!oid_oidcmp(oid, yaz_oid_recsyn_extended)) { thisext->which = Z_External_extendedService; } @@ -295,7 +295,7 @@ Z_External *z_ext_record_oid(ODR o, const int *oid, const char *buf, int len) return 0; } } - else if (!strcmp(oid_str, OID_STR_SUTRS)) /* SUTRS is a single-ASN.1-type */ + else if (!oid_oidcmp(oid, yaz_oid_recsyn_sutrs)) /* SUTRS is a single-ASN.1-type */ { Odr_oct *sutrs = (Odr_oct *)odr_malloc(o, sizeof(*sutrs)); @@ -322,23 +322,17 @@ Z_External *z_ext_record_oid(ODR o, const int *oid, const char *buf, int len) Z_External *z_ext_record_xml(ODR o, const char *buf, int len) { - const int *oid = yaz_string_to_oid(yaz_oid_std(), - CLASS_RECSYN, OID_STR_XML); - return z_ext_record_oid(o, oid, buf, len); + return z_ext_record_oid(o, yaz_oid_recsyn_xml, buf, len); } Z_External *z_ext_record_sutrs(ODR o, const char *buf, int len) { - const int *oid = yaz_string_to_oid(yaz_oid_std(), - CLASS_RECSYN, OID_STR_SUTRS); - return z_ext_record_oid(o, oid, buf, len); + return z_ext_record_oid(o, yaz_oid_recsyn_sutrs, buf, len); } Z_External *z_ext_record_usmarc(ODR o, const char *buf, int len) { - const int *oid = yaz_string_to_oid(yaz_oid_std(), - CLASS_RECSYN, OID_STR_USMARC); - return z_ext_record_oid(o, oid, buf, len); + return z_ext_record_oid(o, yaz_oid_recsyn_usmarc, buf, len); } /* diff --git a/src/seshigh.c b/src/seshigh.c index 8ac8a69..690e872 100644 --- a/src/seshigh.c +++ b/src/seshigh.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: seshigh.c,v 1.114 2007-04-12 20:47:28 adam Exp $ + * $Id: seshigh.c,v 1.115 2007-04-16 21:53:09 adam Exp $ */ /** * \file seshigh.c @@ -679,10 +679,8 @@ static int srw_bend_fetch(association *assoc, int pos, rr.setname = "default"; rr.number = pos; rr.referenceId = 0; - rr.request_format = yaz_string_to_oid_odr(yaz_oid_std(), - CLASS_RECSYN, - OID_STR_XML, - assoc->decode); + rr.request_format = odr_oiddup(assoc->decode, yaz_oid_recsyn_xml); + rr.comp = (Z_RecordComposition *) odr_malloc(assoc->decode, sizeof(*rr.comp)); rr.comp->which = Z_RecordComp_complex; @@ -2148,9 +2146,7 @@ static int process_z_response(association *assoc, request *req, Z_APDU *res) static char *get_vhost(Z_OtherInformation *otherInfo) { - const int *oid = yaz_string_to_oid(yaz_oid_std(), - CLASS_USERINFO, OID_STR_PROXY); - return yaz_oi_get_string_oid(&otherInfo, oid, 1, 0); + return yaz_oi_get_string_oid(&otherInfo, yaz_oid_userinfo_proxy, 1, 0); } /* @@ -2344,7 +2340,7 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb) assoc->init->implementation_name, odr_prepend(assoc->encode, "GFS", resp->implementationName)); - version = odr_strdup(assoc->encode, "$Revision: 1.114 $"); + version = odr_strdup(assoc->encode, "$Revision: 1.115 $"); if (strlen(version) > 10) /* check for unexpanded CVS strings */ version[strlen(version)-2] = '\0'; resp->implementationVersion = odr_prepend(assoc->encode, @@ -3499,11 +3495,10 @@ static Z_APDU *process_ESRequest(association *assoc, request *reqb, int *fd) /* Do something with the members of bend_extendedservice */ if (esrequest.taskPackage) { - const int *oid = yaz_string_to_oid(yaz_oid_std(), - CLASS_EXTSERV, OID_STR_EXTENDED); - resp->taskPackage = z_ext_record_oid(assoc->encode, oid, - (const char *) esrequest.taskPackage, - -1); + resp->taskPackage = z_ext_record_oid( + assoc->encode, yaz_oid_recsyn_extended, + (const char *) esrequest.taskPackage, -1 + ); } yaz_log(YLOG_DEBUG,"Send the result apdu"); return apdu; diff --git a/src/sortspec.c b/src/sortspec.c index b76a253..8d9272e 100644 --- a/src/sortspec.c +++ b/src/sortspec.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: sortspec.c,v 1.9 2007-04-12 13:52:57 adam Exp $ + * $Id: sortspec.c,v 1.10 2007-04-16 21:53:09 adam Exp $ */ /** * \file sortspec.c @@ -49,9 +49,7 @@ Z_SortKeySpecList *yaz_sort_spec (ODR out, const char *arg) sk->which = Z_SortKey_sortAttributes; sk->u.sortAttributes = (Z_SortAttributes *) odr_malloc (out, sizeof(*sk->u.sortAttributes)); - sk->u.sortAttributes->id = - yaz_string_to_oid_odr(yaz_oid_std(), - CLASS_ATTSET, OID_STR_BIB1, out); + sk->u.sortAttributes->id = odr_oiddup(out, yaz_oid_attset_bib_1); sk->u.sortAttributes->list = (Z_AttributeList *) odr_malloc (out, sizeof(*sk->u.sortAttributes->list)); sk->u.sortAttributes->list->attributes = (Z_AttributeElement **) diff --git a/src/zget.c b/src/zget.c index e8785ef..b88e70a 100644 --- a/src/zget.c +++ b/src/zget.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: zget.c,v 1.13 2007-04-12 13:52:57 adam Exp $ + * $Id: zget.c,v 1.14 2007-04-16 21:53:09 adam Exp $ */ /** * \file zget.c @@ -506,8 +506,7 @@ Z_DefaultDiagFormat *zget_DefaultDiagFormat(ODR o, int error, Z_DefaultDiagFormat *dr = (Z_DefaultDiagFormat *) odr_malloc (o, sizeof(*dr)); - dr->diagnosticSetId = yaz_string_to_oid_odr( - yaz_oid_std(), CLASS_DIAGSET, OID_STR_BIB1, o); + dr->diagnosticSetId = odr_oiddup(o, yaz_oid_diagset_bib_1); dr->condition = odr_intdup(o, error); dr->which = Z_DefaultDiagFormat_v2Addinfo; dr->u.v2Addinfo = odr_strdup (o, addinfo ? addinfo : ""); @@ -560,10 +559,7 @@ Z_External *zget_init_diagnostics(ODR odr, int error, const char *addinfo) x = (Z_External*) odr_malloc(odr, sizeof *x); x->descriptor = 0; x->indirect_reference = 0; - x->direct_reference = yaz_string_to_oid_odr(yaz_oid_std(), - CLASS_USERINFO, - OID_STR_USERINFO_1, - odr); + x->direct_reference = odr_oiddup(odr, yaz_oid_userinfo_userinfo_1); x->which = Z_External_userInfo1; u = odr_malloc(odr, sizeof *u); @@ -579,10 +575,7 @@ Z_External *zget_init_diagnostics(ODR odr, int error, const char *addinfo) l->information.externallyDefinedInfo = x2; x2->descriptor = 0; x2->indirect_reference = 0; - x2->direct_reference = yaz_string_to_oid_odr(yaz_oid_std(), - CLASS_DIAGSET, - OID_STR_DIAG1, - odr); + x2->direct_reference = odr_oiddup(odr, yaz_oid_diagset_diag_1); x2->which = Z_External_diag1; d = (Z_DiagnosticFormat*) odr_malloc(odr, sizeof *d); @@ -623,10 +616,7 @@ Z_External *zget_init_diagnostics_octet(ODR odr, int error, x2->descriptor = 0; x2->indirect_reference = 0; - x2->direct_reference = yaz_string_to_oid_odr(yaz_oid_std(), - CLASS_DIAGSET, - OID_STR_DIAG1, - odr); + x2->direct_reference = odr_oiddup(odr, yaz_oid_diagset_diag_1); x2->which = Z_External_diag1; d = (Z_DiagnosticFormat*) odr_malloc(odr, sizeof *d); @@ -649,11 +639,7 @@ Z_External *zget_init_diagnostics_octet(ODR odr, int error, x = (Z_External*) odr_malloc(odr, sizeof *x); x->descriptor = 0; x->indirect_reference = 0; - x->direct_reference = yaz_string_to_oid_odr(yaz_oid_std(), - CLASS_USERINFO, - OID_STR_USERINFO_1, - odr); - + x->direct_reference = odr_oiddup(odr, yaz_oid_userinfo_userinfo_1); x->which = Z_External_octet; x->u.octet_aligned = (Odr_oct *) odr_malloc(odr, sizeof(Odr_oct)); x->u.octet_aligned->buf = odr_malloc(odr, octet_len); diff --git a/src/zoom-c.c b/src/zoom-c.c index fb30049..27ebfa8 100644 --- a/src/zoom-c.c +++ b/src/zoom-c.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: zoom-c.c,v 1.124 2007-04-13 09:55:41 adam Exp $ + * $Id: zoom-c.c,v 1.125 2007-04-16 21:53:09 adam Exp $ */ /** * \file zoom-c.c @@ -1207,19 +1207,17 @@ static int encode_APDU(ZOOM_connection c, Z_APDU *a, ODR out) assert(a); if (c->cookie_out) { - const int *oid = yaz_string_to_oid( - yaz_oid_std(), CLASS_USERINFO, OID_STR_COOKIE); Z_OtherInformation **oi; yaz_oi_APDU(a, &oi); - yaz_oi_set_string_oid(oi, out, oid, 1, c->cookie_out); + yaz_oi_set_string_oid(oi, out, yaz_oid_userinfo_cookie, + 1, c->cookie_out); } if (c->client_IP) { - const int *oid = yaz_string_to_oid( - yaz_oid_std(), CLASS_USERINFO, OID_STR_CLIENT_IP); Z_OtherInformation **oi; yaz_oi_APDU(a, &oi); - yaz_oi_set_string_oid(oi, out, oid, 1, c->client_IP); + yaz_oi_set_string_oid(oi, out, yaz_oid_userinfo_client_ip, + 1, c->client_IP); } otherInfo_attach(c, a, out); if (!z_APDU(out, &a, 0, 0)) @@ -1298,7 +1296,7 @@ static zoom_ret ZOOM_connection_send_init(ZOOM_connection c) odr_prepend(c->odr_out, "ZOOM-C", ireq->implementationName)); - version = odr_strdup(c->odr_out, "$Revision: 1.124 $"); + version = odr_strdup(c->odr_out, "$Revision: 1.125 $"); if (strlen(version) > 10) /* check for unexpanded CVS strings */ version[strlen(version)-2] = '\0'; ireq->implementationVersion = @@ -1357,10 +1355,8 @@ static zoom_ret ZOOM_connection_send_init(ZOOM_connection c) } if (c->proxy) { - const int *oid = yaz_string_to_oid( - yaz_oid_std(), CLASS_USERINFO, OID_STR_CLIENT_IP); yaz_oi_set_string_oid(&ireq->otherInfo, c->odr_out, - oid, 1, c->host_port); + yaz_oid_userinfo_proxy, 1, c->host_port); } if (c->charset || c->lang) { @@ -2849,7 +2845,7 @@ ZOOM_API(void) ZOOM_options_set(scan->options, key, val); } -static Z_APDU *create_es_package(ZOOM_package p, const char *type) +static Z_APDU *create_es_package(ZOOM_package p, const int *oid) { const char *str; Z_APDU *apdu = zget_APDU(p->odr_out, Z_APDU_extendedServicesRequest); @@ -2865,8 +2861,7 @@ static Z_APDU *create_es_package(ZOOM_package p, const char *type) if (str) req->userId = odr_strdup(p->odr_out, str); - req->packageType = yaz_string_to_oid_odr(yaz_oid_std(), CLASS_EXTSERV, - type, p->odr_out); + req->packageType = odr_oiddup(p->odr_out, oid); str = ZOOM_options_get(p->options, "function"); if (str) @@ -2914,10 +2909,7 @@ static Z_External *encode_ill_request(ZOOM_package p) char *illRequest_buf = odr_getbuf(out, &illRequest_size, 0); r = (Z_External *) odr_malloc(out, sizeof(*r)); - r->direct_reference = yaz_string_to_oid_odr(yaz_oid_std(), - CLASS_GENERAL, - OID_STR_ILL_1, - out); + r->direct_reference = odr_oiddup(out, yaz_oid_general_isoill_1); r->indirect_reference = 0; r->descriptor = 0; r->which = Z_External_single; @@ -3001,7 +2993,7 @@ Z_APDU *create_admin_package(ZOOM_package p, int type, Z_ESAdminOriginPartToKeep **toKeepP, Z_ESAdminOriginPartNotToKeep **notToKeepP) { - Z_APDU *apdu = create_es_package(p, OID_STR_ADMIN); + Z_APDU *apdu = create_es_package(p, yaz_oid_extserv_admin); if (apdu) { Z_ESAdminOriginPartToKeep *toKeep; @@ -3014,9 +3006,7 @@ Z_APDU *create_admin_package(ZOOM_package p, int type, if (num_db > 0) first_db = db[0]; - r->direct_reference = - yaz_string_to_oid_odr(yaz_oid_std(), - CLASS_EXTSERV, OID_STR_ADMIN, p->odr_out); + r->direct_reference = odr_oiddup(p->odr_out, yaz_oid_extserv_admin); r->descriptor = 0; r->indirect_reference = 0; r->which = Z_External_ESAdmin; @@ -3051,7 +3041,7 @@ Z_APDU *create_admin_package(ZOOM_package p, int type, static Z_APDU *create_xmlupdate_package(ZOOM_package p) { - Z_APDU *apdu = create_es_package(p, OID_STR_XMLES); + Z_APDU *apdu = create_es_package(p, yaz_oid_extserv_xml_es); 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"); @@ -3121,7 +3111,7 @@ static Z_APDU *create_update_package(ZOOM_package p) else return 0; - apdu = create_es_package(p, OID_STR_EXT_UPDATE); + apdu = create_es_package(p, yaz_oid_extserv_database_update); if (apdu) { Z_IUOriginPartToKeep *toKeep; @@ -3132,9 +3122,8 @@ static Z_APDU *create_update_package(ZOOM_package p) apdu->u.extendedServicesRequest->taskSpecificParameters = r; - r->direct_reference = - yaz_string_to_oid_odr(yaz_oid_std(), CLASS_EXTSERV, - OID_STR_EXT_UPDATE, p->odr_out); + r->direct_reference = odr_oiddup(p->odr_out, + yaz_oid_extserv_database_update); r->descriptor = 0; r->which = Z_External_update; r->indirect_reference = 0; @@ -3208,14 +3197,13 @@ ZOOM_API(void) p->buf_out = 0; if (!strcmp(type, "itemorder")) { - apdu = create_es_package(p, OID_STR_ITEMORDER); + apdu = create_es_package(p, yaz_oid_extserv_item_order); if (apdu) { Z_External *r = (Z_External *) odr_malloc(p->odr_out, sizeof(*r)); - r->direct_reference = - yaz_string_to_oid_odr(yaz_oid_std(), CLASS_EXTSERV, - OID_STR_ITEMORDER, p->odr_out); + r->direct_reference = + odr_oiddup(p->odr_out, yaz_oid_extserv_item_order); r->descriptor = 0; r->which = Z_External_itemOrder; r->indirect_reference = 0; @@ -3509,12 +3497,9 @@ static void recv_apdu(ZOOM_connection c, Z_APDU *apdu) } else { - const int *oid = yaz_string_to_oid(yaz_oid_std(), - CLASS_USERINFO, - OID_STR_COOKIE); char *cookie = yaz_oi_get_string_oid(&apdu->u.initResponse->otherInfo, - oid, 1, 0); + yaz_oid_userinfo_cookie, 1, 0); xfree(c->cookie_in); c->cookie_in = 0; if (cookie) @@ -3662,8 +3647,7 @@ static void handle_srw_response(ZOOM_connection c, odr_malloc(c->odr_in, sizeof(Z_External)); npr->u.databaseRecord->descriptor = 0; npr->u.databaseRecord->direct_reference = - yaz_string_to_oid_odr(yaz_oid_std(), CLASS_RECSYN, OID_STR_XML, - c->odr_in); + odr_oiddup(c->odr_in, yaz_oid_recsyn_xml); npr->u.databaseRecord->which = Z_External_octet; npr->u.databaseRecord->u.octet_aligned = (Odr_oct *) diff --git a/ztest/ztest.c b/ztest/ztest.c index d45c8b1..5769d52 100644 --- a/ztest/ztest.c +++ b/ztest/ztest.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: ztest.c,v 1.87 2007-04-13 09:55:41 adam Exp $ + * $Id: ztest.c,v 1.88 2007-04-16 21:53:09 adam Exp $ */ /* @@ -144,14 +144,15 @@ int ztest_esrequest (void *handle, bend_esrequest_rr *rr) &oclass, oid_name_str); if (oid_name) yaz_log(log_level, "OID %s", oid_name); - if (oid_name && !strcmp(oid_name, OID_STR_XML)) + if (!oid_oidcmp(r->direct_reference, yaz_oid_recsyn_xml)) { yaz_log (log_level, "ILL XML request"); if (r->which == Z_External_octet) yaz_log (log_level, "%.*s", r->u.octet_aligned->len, r->u.octet_aligned->buf); } - if (oid_name && !strcmp(oid_name, OID_STR_ILL_1)) + if (!oid_oidcmp(r->direct_reference, + yaz_oid_general_isoill_1)) { yaz_log (log_level, "Decode ItemRequest begin"); if (r->which == ODR_EXTERNAL_single) @@ -462,15 +463,15 @@ int ztest_fetch(void *handle, bend_fetch_rr *r) int oclass; char oid_str_buf[OID_STR_MAX]; const char *oid_str = 0; + const int *oid = r->request_format; r->last_in_set = 0; r->basename = "Default"; r->output_format = r->request_format; - oid_str = yaz_oid_to_string_buf(r->request_format, &oclass, - oid_str_buf); - - if (oid_str && !strcmp(oid_str, OID_STR_SUTRS)) + oid_str = yaz_oid_to_string_buf(oid, &oclass, oid_str_buf); + + if (oid && !oid_oidcmp(oid, yaz_oid_recsyn_sutrs)) { /* this section returns a small record */ char buf[100]; @@ -481,7 +482,7 @@ int ztest_fetch(void *handle, bend_fetch_rr *r) r->record = (char *) odr_malloc (r->stream, r->len+1); strcpy(r->record, buf); } - else if (oid_str && !strcmp(oid_str, OID_STR_GRS1)) + else if (oid && !oid_oidcmp(oid, yaz_oid_recsyn_grs_1)) { r->len = -1; r->record = (char*) dummy_grs_record(r->number, r->stream); @@ -491,7 +492,7 @@ int ztest_fetch(void *handle, bend_fetch_rr *r) return 0; } } - else if (oid_str && !strcmp(oid_str, OID_STR_POSTSCRIPT)) + else if (oid && !oid_oidcmp(oid, yaz_oid_recsyn_postscript)) { char fname[20]; FILE *f; @@ -517,7 +518,7 @@ int ztest_fetch(void *handle, bend_fetch_rr *r) fread (r->record, size, 1, f); fclose (f); } - else if (oid_str && !strcmp(oid_str, OID_STR_XML)) + else if (oid && !oid_oidcmp(oid, yaz_oid_recsyn_xml)) { if ((cp = dummy_xml_record (r->number, r->stream))) { @@ -535,8 +536,7 @@ int ztest_fetch(void *handle, bend_fetch_rr *r) { r->len = strlen(cp); r->record = cp; - r->output_format = yaz_string_to_oid_odr( - yaz_oid_std(), CLASS_RECSYN, OID_STR_USMARC, r->stream); + r->output_format = odr_oiddup(r->stream, yaz_oid_recsyn_usmarc); } else {