X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Foid_util.c;h=93d724b404be98c1a8009a903baa85e8f0488683;hb=a766a381d38e67255fea3a9e9c4b818d49b73936;hp=fc62f5192c66e09384dcc78d83b7213e08ecc6e0;hpb=7a4064cd15f6c6b34c1180e1bc51f0d0e90da320;p=yaz-moved-to-github.git diff --git a/src/oid_util.c b/src/oid_util.c index fc62f51..93d724b 100644 --- a/src/oid_util.c +++ b/src/oid_util.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: oid_util.c,v 1.1 2007-04-12 13:52:57 adam Exp $ + * $Id: oid_util.c,v 1.3 2007-04-13 07:04:42 adam Exp $ */ /** @@ -58,7 +58,7 @@ int oid_oidlen(const int *o) } -char *oid_to_dotstring(const int *oid, char *oidbuf) +char *oid_oid_to_dotstring(const int *oid, char *oidbuf) { char tmpbuf[20]; int i; @@ -74,6 +74,29 @@ char *oid_to_dotstring(const int *oid, char *oidbuf) return oidbuf; } +int oid_dotstring_to_oid(const char *name, int *oid) +{ + int i = 0; + int val = 0; + while (isdigit (*(unsigned char *) name)) + { + val = val*10 + (*name - '0'); + name++; + if (*name == '.') + { + if (i < OID_SIZE-1) + oid[i++] = val; + val = 0; + name++; + } + } + if (i == 0) + return -1; + oid[i] = val; + oid[i+1] = -1; + return 0; +} + /* * Local variables: * c-basic-offset: 4