X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=util%2Foid.c;h=4aeddfe3e6093ee6ddf8dc46f96a465e3fefe022;hb=3d47aeca3756dc7d1c2ea91f74fef2b0886f76e8;hp=6ad4477fe283c4a81de46a71ae42a2ca1876dbdb;hpb=c7eb63e9060187fbba904c3da9697ff85f919af4;p=yaz-moved-to-github.git diff --git a/util/oid.c b/util/oid.c index 6ad4477..4aeddfe 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.60 2003-04-03 21:01:28 mike Exp $ + * $Id: oid.c,v 1.63 2003-07-10 11:52:37 mike 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}, @@ -358,14 +360,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++; } } @@ -570,3 +572,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); +} +