SRW, CQL, 2003
[yaz-moved-to-github.git] / util / oid.c
index c4202dc..a8c485b 100644 (file)
@@ -1,8 +1,8 @@
 /*
- * Copyright (c) 1995-2002, Index Data
+ * Copyright (c) 1995-2003, Index Data
  * See the file LICENSE for details.
  *
- * $Id: oid.c,v 1.50 2002-01-23 20:22:49 adam Exp $
+ * $Id: oid.c,v 1.59 2003-01-06 08:20:28 adam Exp $
  */
 
 /*
@@ -45,7 +45,7 @@ static oident standard_oids[] =
      "BER" },
     {PROTO_GENERAL, CLASS_TRANSYN, VAL_ISO2709,      {1,0,2709,1,1,-1},
      "ISO2709"},
-    {PROTO_GENERAL, CLASS_GENERAL, VAL_ISO_ILL_1,    {1,2,10161,2,1,-1},
+    {PROTO_GENERAL, CLASS_GENERAL, VAL_ISO_ILL_1,    {1,0,10161,2,1,-1},
      "ISOILL-1"},
     /* Z39.50v3 definitions */
     {PROTO_Z3950,   CLASS_ABSYN,   VAL_APDU,         {2,1,-1},
@@ -87,9 +87,17 @@ static oident standard_oids[] =
      "Dan-1"},
     {PROTO_Z3950,   CLASS_ATTSET,  VAL_HOLDINGS,     {3,16,-1},
      "Holdings"},
-
-    {PROTO_Z3950,   CLASS_ATTSET,  VAL_THESAURUS,    {3,1000,81,1,-1},
+    {PROTO_Z3950,   CLASS_ATTSET,  VAL_USMARC,       {3,17,-1},
+     "MARC"},
+    {PROTO_Z3950,   CLASS_ATTSET,  VAL_BIB2,         {3,18,-1},
+     "Bib-2"},
+    {PROTO_Z3950,   CLASS_ATTSET,  VAL_ZEEREX,       {3,19,-1},
+     "ZeeRex"},
+
+    {PROTO_Z3950,   CLASS_ATTSET,  VAL_THESAURUS,    {3,1000,81,1,-1},     
      "Thesaurus-attset"},
+    {PROTO_Z3950,   CLASS_ATTSET,  VAL_IDXPATH,      {3,1000,81,2,-1},
+     "IDXPATH"},
     {PROTO_Z3950,   CLASS_DIAGSET, VAL_BIB1,         {4,1,-1},
      "Bib-1"},
     {PROTO_Z3950,   CLASS_DIAGSET, VAL_DIAG1,        {4,2,-1},
@@ -280,9 +288,23 @@ static oident standard_oids[] =
     {PROTO_Z3950,   CLASS_TAGSET,  VAL_CIMI1,        {14,6,-1},
      "CIMI-tagset"},
     {PROTO_Z3950,   CLASS_TAGSET,  VAL_THESAURUS,    {14,1000,81,1,-1},
-     "thesaurus-tagset"},
+     "thesaurus-tagset"},      /* What is this Satan-spawn doing here? */
     {PROTO_Z3950,   CLASS_TAGSET,  VAL_EXPLAIN,      {14,1000,81,2,-1},
      "Explain-tagset"},
+    {PROTO_Z3950,   CLASS_TAGSET,  VAL_ZTHES,        {14,8,-1},
+     "Zthes-tagset"},
+    {PROTO_Z3950,   CLASS_NEGOT,   VAL_CHARNEG3,     {15,3,-1},
+     "CharSetandLanguageNegotiation-3"},
+    {PROTO_Z3950,   CLASS_USERINFO,VAL_CQL,          {16, 2, -1},
+     "CQL"},
+    {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},
+     "UCS-4"},
+    {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},
+     "UTF-8"},
     {PROTO_NOP,     CLASS_NOP,     VAL_NOP,       {-1},        0          }
 };
 
@@ -447,8 +469,6 @@ struct oident *oid_addent (int *oid, enum oid_proto proto,
     struct oident *oident = 0;
 
     nmem_mutex_enter (oid_mutex);
-    if (desc)
-        oident = oid_getentbyoid_x (oid);
     if (!oident)
     {
        char desc_str[200];
@@ -464,7 +484,7 @@ struct oident *oid_addent (int *oid, enum oid_proto proto,
            int i;
 
            sprintf (desc_str, "%d", *oid);
-           for (i = 1; oid[i] >= 0; i++)
+           for (i = 1; i < 12 && oid[i] >= 0; i++)
                sprintf (desc_str+strlen(desc_str), ".%d", oid[i]);
            desc = desc_str;
        }
@@ -514,7 +534,9 @@ static oid_value oid_getval_raw(const char *name)
     }
     oid[i] = val;
     oid[i+1] = -1;
-    oident = oid_addent (oid, PROTO_GENERAL, CLASS_GENERAL, NULL,
+    oident = oid_getentbyoid_x (oid);
+    if (!oident)
+        oident = oid_addent (oid, PROTO_GENERAL, CLASS_GENERAL, NULL,
                         VAL_DYNAMIC);
     return oident->value;
 }
@@ -538,3 +560,12 @@ void oid_setprivateoids(oident *list)
 {
     oid_transfer (list);
 }
+
+void oid_trav (void (*func)(struct oident *oidinfo, void *vp), void *vp)
+{
+    struct oident_list *ol;
+
+    oid_init ();
+    for (ol = oident_table; ol; ol = ol->next)
+        (*func)(&ol->oident, vp);
+}