X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Foid_util.c;h=ed60edcdb66286c18948abbe9849d701de04db61;hp=752315871ff61ad214e63361f82e4fa34d0a238c;hb=68bbd857190c6e29727ca1f5070fe6d8e5102bbb;hpb=be821514c869d68186361b5aab6bbfd1aa60e087 diff --git a/src/oid_util.c b/src/oid_util.c index 7523158..ed60edc 100644 --- a/src/oid_util.c +++ b/src/oid_util.c @@ -1,8 +1,6 @@ -/* - * Copyright (C) 1995-2007, Index Data ApS +/* This file is part of the YAZ toolkit. + * Copyright (C) Index Data * See the file LICENSE for details. - * - * $Id: oid_util.c,v 1.2 2007-04-12 20:47:28 adam Exp $ */ /** @@ -16,24 +14,24 @@ #include #include -#include +#include #include #include -void oid_oidcpy(int *t, const int *s) +void oid_oidcpy(Odr_oid *t, const Odr_oid *s) { while ((*(t++) = *(s++)) > -1); } -void oid_oidcat(int *t, const int *s) +void oid_oidcat(Odr_oid *t, const Odr_oid *s) { while (*t > -1) t++; while ((*(t++) = *(s++)) > -1); } -int oid_oidcmp(const int *o1, const int *o2) +int oid_oidcmp(const Odr_oid *o1, const Odr_oid *o2) { while (*o1 == *o2 && *o1 > -1) { @@ -48,7 +46,7 @@ int oid_oidcmp(const int *o1, const int *o2) return -1; } -int oid_oidlen(const int *o) +int oid_oidlen(const Odr_oid *o) { int len = 0; @@ -58,13 +56,13 @@ int oid_oidlen(const int *o) } -char *oid_oid_to_dotstring(const int *oid, char *oidbuf) +char *oid_oid_to_dotstring(const Odr_oid *oid, char *oidbuf) { char tmpbuf[20]; int i; oidbuf[0] = '\0'; - for (i = 0; oid[i] != -1 && i < OID_SIZE; i++) + for (i = 0; oid[i] != -1 && i < OID_SIZE; i++) { yaz_snprintf(tmpbuf, sizeof(tmpbuf)-1, "%d", oid[i]); if (i > 0) @@ -74,11 +72,11 @@ char *oid_oid_to_dotstring(const int *oid, char *oidbuf) return oidbuf; } -int oid_dotstring_to_oid(const char *name, int *oid) +int oid_dotstring_to_oid(const char *name, Odr_oid *oid) { int i = 0; int val = 0; - while (isdigit (*(unsigned char *) name)) + while (yaz_isdigit (*name)) { val = val*10 + (*name - '0'); name++; @@ -90,6 +88,8 @@ int oid_dotstring_to_oid(const char *name, int *oid) name++; } } + if (i == 0) + return -1; oid[i] = val; oid[i+1] = -1; return 0; @@ -98,6 +98,7 @@ int oid_dotstring_to_oid(const char *name, int *oid) /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab