X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=util%2Foid.c;h=7545112b1d83ded5672ab374a221f70ce373c3f7;hb=4b3d1e197d75fcb2607be8d86d244f20c4180000;hp=3b71395a2ba0997e861f2d1fd17daf05a3dfe441;hpb=c34d71d35aceed27cf7e30e6b329a235b48b9ccd;p=yaz-moved-to-github.git diff --git a/util/oid.c b/util/oid.c index 3b71395..7545112 100644 --- a/util/oid.c +++ b/util/oid.c @@ -1,8 +1,8 @@ /* - * Copyright (c) 1995-2002, Index Data + * Copyright (c) 1995-2003, Index Data * See the file LICENSE for details. * - * $Id: oid.c,v 1.53 2002-02-11 23:25:26 adam Exp $ + * $Id: oid.c,v 1.67 2003-09-02 12:12:13 adam Exp $ */ /* @@ -45,7 +45,7 @@ static oident standard_oids[] = "BER" }, {PROTO_GENERAL, CLASS_TRANSYN, VAL_ISO2709, {1,0,2709,1,1,-1}, "ISO2709"}, - {PROTO_GENERAL, CLASS_GENERAL, VAL_ISO_ILL_1, {1,2,10161,2,1,-1}, + {PROTO_GENERAL, CLASS_GENERAL, VAL_ISO_ILL_1, {1,0,10161,2,1,-1}, "ISOILL-1"}, /* Z39.50v3 definitions */ {PROTO_Z3950, CLASS_ABSYN, VAL_APDU, {2,1,-1}, @@ -87,9 +87,18 @@ static oident standard_oids[] = "Dan-1"}, {PROTO_Z3950, CLASS_ATTSET, VAL_HOLDINGS, {3,16,-1}, "Holdings"}, - - {PROTO_Z3950, CLASS_ATTSET, VAL_THESAURUS, {3,1000,81,1,-1}, + {PROTO_Z3950, CLASS_ATTSET, VAL_USMARC, {3,17,-1}, + "MARC"}, + {PROTO_Z3950, CLASS_ATTSET, VAL_BIB2, {3,18,-1}, + "Bib-2"}, + {PROTO_Z3950, CLASS_ATTSET, VAL_ZEEREX, {3,19,-1}, + "ZeeRex"}, +#if 0 /* This is the spawn of Satan. Use Zthes-1 instead */ + {PROTO_Z3950, CLASS_ATTSET, VAL_THESAURUS, {3,1000,81,1,-1}, "Thesaurus-attset"}, +#endif /*0*/ + {PROTO_Z3950, CLASS_ATTSET, VAL_IDXPATH, {3,1000,81,2,-1}, + "IDXPATH"}, {PROTO_Z3950, CLASS_DIAGSET, VAL_BIB1, {4,1,-1}, "Bib-1"}, {PROTO_Z3950, CLASS_DIAGSET, VAL_DIAG1, {4,2,-1}, @@ -215,15 +224,17 @@ 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}, "exp. spec."}, {PROTO_Z3950, CLASS_EXTSERV, VAL_EXPORTINV, {9,7,-1}, "exp. inv."}, - {PROTO_Z3950, CLASS_EXTSERV, VAL_ADMINSERVICE, {9,81,1,-1}, + {PROTO_Z3950, CLASS_EXTSERV, VAL_ADMINSERVICE, {9,1000,81,1,-1}, "Admin"}, {PROTO_Z3950, CLASS_USERINFO,VAL_SEARCHRES1, {10,1,-1}, "searchResult-1"}, @@ -280,11 +291,17 @@ static oident standard_oids[] = {PROTO_Z3950, CLASS_TAGSET, VAL_CIMI1, {14,6,-1}, "CIMI-tagset"}, {PROTO_Z3950, CLASS_TAGSET, VAL_THESAURUS, {14,1000,81,1,-1}, - "thesaurus-tagset"}, + "thesaurus-tagset"}, /* What is this Satan-spawn doing here? */ {PROTO_Z3950, CLASS_TAGSET, VAL_EXPLAIN, {14,1000,81,2,-1}, "Explain-tagset"}, + {PROTO_Z3950, CLASS_TAGSET, VAL_ZTHES, {14,8,-1}, + "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}, "UCS-2"}, {PROTO_GENERAL, CLASS_GENERAL, VAL_UCS4, {1,0,10646,1,0,4,-1}, @@ -293,6 +310,8 @@ static oident standard_oids[] = "UTF-16"}, {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}, + "OCLC-userInfo"}, {PROTO_NOP, CLASS_NOP, VAL_NOP, {-1}, 0 } }; @@ -345,14 +364,14 @@ static int match_prefix(int *look, int *prefix) return 0; } -void oid_transfer (struct oident *oident) +void oid_transfer (struct oident *oidentp) { - while (*oident->oidsuffix >= 0) + while (*oidentp->oidsuffix >= 0) { - oid_addent (oident->oidsuffix, oident->proto, - oident->oclass, - oident->desc, oident->value); - oident++; + oid_addent (oidentp->oidsuffix, oidentp->proto, + oidentp->oclass, + oidentp->desc, oidentp->value); + oidentp++; } } @@ -472,7 +491,7 @@ struct oident *oid_addent (int *oid, enum oid_proto proto, int i; sprintf (desc_str, "%d", *oid); - for (i = 1; oid[i] >= 0; i++) + for (i = 1; i < 12 && oid[i] >= 0; i++) sprintf (desc_str+strlen(desc_str), ".%d", oid[i]); desc = desc_str; } @@ -557,3 +576,40 @@ void oid_trav (void (*func)(struct oident *oidinfo, void *vp), void *vp) for (ol = oident_table; ol; ol = ol->next) (*func)(&ol->oident, vp); } + +int *oid_name_to_oid(oid_class oclass, const char *name, int *oid) { + struct oident ent; + + /* Translate syntax to oid_val */ + oid_value value = oid_getvalbyname(name); + + /* Build it into an oident */ + ent.proto = PROTO_Z3950; + ent.oclass = oclass; + ent.value = value; + + /* Translate to an array of int */ + return oid_ent_to_oid(&ent, oid); +} + +char *oid_to_dotstring(const int *oid, char *oidbuf) { + char tmpbuf[20]; + int i; + + oidbuf[0] = '\0'; + for (i = 0; oid[i] != -1; i++) { + sprintf(tmpbuf, "%d", oid[i]); + if (i > 0) strcat(oidbuf, "."); + strcat(oidbuf, tmpbuf); + } + + return oidbuf; +} + +char *oid_name_to_dotstring(oid_class oclass, const char *name, char *oidbuf) { + int oid[OID_SIZE]; + + (void) oid_name_to_oid(oclass, name, oid); + return oid_to_dotstring(oid, oidbuf); +} +