X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Foid.c;h=bd4067446c32ec5425a7ba671255cd2d98b7bcf3;hb=b853eb3de1a249859eef71c9a285172a199656ce;hp=ed33f0246a9bafdecfb56f28cd3569aec6060c40;hpb=81c23570ac55dbb3faa04a6625a45d9c617c5c02;p=yaz-moved-to-github.git diff --git a/src/oid.c b/src/oid.c index ed33f02..bd40674 100644 --- a/src/oid.c +++ b/src/oid.c @@ -1,11 +1,14 @@ /* - * Copyright (c) 1995-2003, Index Data + * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: oid.c,v 1.3 2003-11-19 22:24:57 adam Exp $ + * $Id: oid.c,v 1.9 2005-06-06 10:29:33 adam Exp $ */ -/* +/** + * \file oid.c + * \brief Implements OID database + * * More or less protocol-transparent OID database. * We could (and should?) extend this so that the user app can add new * entries to the list at initialization. @@ -308,21 +311,25 @@ static oident standard_oids[] = "Zthes-tagset"}, {PROTO_Z3950, CLASS_NEGOT, VAL_CHARNEG3, {15,3,-1}, "CharSetandLanguageNegotiation-3"}, + {PROTO_Z3950, CLASS_NEGOT, VAL_CHARNEG4, {15,4,-1}, + "CharSetandLanguageNegotiation-4"}, {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}, + {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 */ @@ -488,7 +495,6 @@ struct oident *oid_addent (int *oid, enum oid_proto proto, nmem_mutex_enter (oid_mutex); if (!oident) { - char desc_str[200]; struct oident_list *oident_list; oident_list = (struct oident_list *) nmem_malloc (oid_nmem, sizeof(*oident_list)); @@ -498,14 +504,20 @@ struct oident *oid_addent (int *oid, enum oid_proto proto, if (!desc) { + char desc_str[OID_SIZE*10]; int i; - sprintf (desc_str, "%d", *oid); - for (i = 1; i < 12 && oid[i] >= 0; i++) - sprintf (desc_str+strlen(desc_str), ".%d", oid[i]); - desc = desc_str; + *desc_str = '\0'; + if (*oid >= 0) + { + sprintf (desc_str, "%d", *oid); + for (i = 1; i < OID_SIZE && oid[i] >= 0; i++) + sprintf (desc_str+strlen(desc_str), ".%d", oid[i]); + } + oident->desc = nmem_strdup(oid_nmem, desc_str); } - oident->desc = nmem_strdup (oid_nmem, desc); + else + oident->desc = nmem_strdup(oid_nmem, desc); if (value == VAL_DYNAMIC) oident->value = (enum oid_value) (++oid_value_dynamic); else @@ -537,7 +549,7 @@ static oid_value oid_getval_raw(const char *name) int val = 0, i = 0, oid[OID_SIZE]; struct oident *oident; - while (isdigit (*name)) + while (isdigit (*(const unsigned char *) name)) { val = val*10 + (*name - '0'); name++; @@ -563,7 +575,7 @@ oid_value oid_getvalbyname(const char *name) struct oident_list *ol; oid_init (); - if (isdigit (*name)) + if (isdigit (*(const unsigned char *) name)) return oid_getval_raw (name); for (ol = oident_table; ol; ol = ol->next) if (!yaz_matchstr(ol->oident.desc, name))