Support for the UserInformation DPU OCLC-UserInformation:
[yaz-moved-to-github.git] / util / oid.c
index e6236e4..1a0ecbb 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 1995-2003, Index Data
  * See the file LICENSE for details.
  *
- * $Id: oid.c,v 1.61 2003-05-26 13:36:48 adam Exp $
+ * $Id: oid.c,v 1.64 2003-07-18 19:54:30 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},
@@ -297,7 +299,7 @@ static oident standard_oids[] =
     {PROTO_Z3950,   CLASS_NEGOT,   VAL_CHARNEG3,     {15,3,-1},
      "CharSetandLanguageNegotiation-3"},
     {PROTO_Z3950,   CLASS_USERINFO,VAL_CQL,          {16, 2, -1},
-     "CQL"},
+     "OCLC-userInfo"},
     {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},
@@ -306,6 +308,8 @@ static oident standard_oids[] =
      "UTF-16"},
     {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},
+     "CQL"},
     {PROTO_NOP,     CLASS_NOP,     VAL_NOP,       {-1},        0          }
 };
 
@@ -570,3 +574,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);
+}
+