X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Foid_util.c;fp=src%2Foid_util.c;h=752315871ff61ad214e63361f82e4fa34d0a238c;hp=fc62f5192c66e09384dcc78d83b7213e08ecc6e0;hb=be821514c869d68186361b5aab6bbfd1aa60e087;hpb=aa29dbf34d5bb3cbf5b26ee3adfbaf9f9b4f3c67 diff --git a/src/oid_util.c b/src/oid_util.c index fc62f51..7523158 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.2 2007-04-12 20:47:28 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,27 @@ 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++; + } + } + oid[i] = val; + oid[i+1] = -1; + return 0; +} + /* * Local variables: * c-basic-offset: 4