New OID database - with public definitions in oid_db.h. Removed old OID
authorAdam Dickmeiss <adam@indexdata.dk>
Thu, 12 Apr 2007 13:52:56 +0000 (13:52 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Thu, 12 Apr 2007 13:52:56 +0000 (13:52 +0000)
database including the head oid.h and definitions such as enum oid_value
and struct oident. The new OID database uses the same string names as
before but the 'protocol' is gone. There are now only two representations
raw OID (int *) and string. Functions with prefix yaz_string_to_oid
converts from string to OID; functions with prefix yaz_oid_to_string
converts the other way.

47 files changed:
NEWS
client/admin.c
client/client.c
client/tabcomplete.c
client/tabcomplete.h
include/yaz/Makefile.am
include/yaz/backend.h
include/yaz/comstack.h
include/yaz/logrpn.h
include/yaz/odr.h
include/yaz/oid.h [deleted file]
include/yaz/oid_db.h [new file with mode: 0644]
include/yaz/oid_util.h [new file with mode: 0644]
include/yaz/otherinfo.h
include/yaz/pquery.h
include/yaz/proto.h
include/yaz/prt-ext.h
include/yaz/query-charset.h
include/yaz/querytowrbuf.h
include/yaz/tcpip.h
include/yaz/unix.h
src/Makefile.am
src/charneg.c
src/grs1disp.c
src/logrpn.c
src/nmem.c
src/odr_mem.c
src/odr_oid.c
src/odr_util.c
src/oid.c [deleted file]
src/oid_db.c [new file with mode: 0644]
src/oid_util.c [new file with mode: 0644]
src/otherinfo.c
src/pquery.c
src/prt-ext.c
src/querytowrbuf.c
src/retrieval.c
src/seshigh.c
src/session.h
src/sortspec.c
src/xmlquery.c
src/z3950oid.c [deleted file]
src/zget.c
src/zoom-c.c
src/zoom-p.h
zoom/zoomsh.c
ztest/ztest.c

diff --git a/NEWS b/NEWS
index 216e038..a3163d5 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,11 @@
+New OID database - with public definitions in oid_db.h. Removed old OID
+database including the head oid.h and definitions such as enum oid_value
+and struct oident. The new OID database uses the same string names as
+before but the 'protocol' is gone. There are now only two representations
+raw OID (int *) and string. Functions with prefix yaz_string_to_oid
+converts from string to OID; functions with prefix yaz_oid_to_string
+converts the other way.
+
 Change to emit_term() in CQL-to-PQF query translation: when a term has
 the /regexp relation modifier, do not process it for leading and
 trailing "^" and "*", which have quite different meanings in regular
index 30afef2..eaca6ec 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: admin.c,v 1.23 2007-01-03 08:42:13 adam Exp $
+ * $Id: admin.c,v 1.24 2007-04-12 13:52:57 adam Exp $
  */
 
 #include <stdio.h>
@@ -27,7 +27,7 @@
 #include <yaz/proto.h>
 #include <yaz/marcdisp.h>
 #include <yaz/diagbib1.h>
-
+#include <yaz/oid_db.h>
 #include <yaz/pquery.h>
 
 #include "admin.h"
@@ -47,20 +47,19 @@ int sendAdminES(int type, char* param1)
     Z_APDU *apdu = zget_APDU(out, Z_APDU_extendedServicesRequest );
     Z_ExtendedServicesRequest *req = apdu->u.extendedServicesRequest;
     Z_External *r;
-    int oid[OID_SIZE];
+    int *oid;
     Z_ESAdminOriginPartToKeep  *toKeep;
     Z_ESAdminOriginPartNotToKeep  *notToKeep;
-    oident update_oid;
     printf ("Admin request\n");
     fflush(stdout);
 
-    /* Set up the OID for the external */
-    update_oid.proto = PROTO_Z3950;
-    update_oid.oclass = CLASS_EXTSERV;
-    update_oid.value = VAL_ADMINSERVICE;
+    oid = yaz_string_to_oid_odr(yaz_oid_std(),
+                                CLASS_EXTSERV,
+                                OID_STR_ADMIN,
+                                out);
+
 
-    oid_ent_to_oid (&update_oid, oid);
-    req->packageType = odr_oiddup(out,oid);
+    req->packageType = oid;
     req->packageName = "1.Extendedserveq";
 
     /* Allocate the external */
index ab6f759..59a70c2 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: client.c,v 1.331 2007-03-28 16:35:47 mike Exp $
+ * $Id: client.c,v 1.332 2007-04-12 13:52:57 adam Exp $
  */
 /** \file client.c
  *  \brief yaz-client program
@@ -56,6 +56,8 @@
 
 #include <yaz/comstack.h>
 
+#include <yaz/oid_db.h>
+#define NO_OID 1
 #include <yaz/proto.h>
 #include <yaz/marcdisp.h>
 #include <yaz/diagbib1.h>
@@ -111,8 +113,8 @@ static Z_ElementSetNames *elementSetNames = 0;
 static int setno = 1;                   /* current set offset */
 static enum oid_proto protocol = PROTO_Z3950;      /* current app protocol */
 #define RECORDSYNTAX_MAX 20
-static enum oid_value recordsyntax_list[RECORDSYNTAX_MAX]  = { VAL_USMARC };
-static int recordsyntax_size = 1;
+static char *recordsyntax_list[RECORDSYNTAX_MAX];
+static int recordsyntax_size = 0;
 
 static char *record_schema = 0;
 static int sent_close = 0;
@@ -172,10 +174,9 @@ int rl_attempted_completion_over = 0;
 
 #define maxOtherInfosSupported 10
 struct {
-    int oidval;
+    int oid[OID_SIZE];
     char* value;
 } extraOtherInfos[maxOtherInfosSupported];
-        
 
 void process_cmd_line(char* line);
 #if HAVE_READLINE_READLINE_H
@@ -244,8 +245,8 @@ void add_otherInfos(Z_APDU *a)
     yaz_oi_APDU(a, &oi);
     for(i=0; i<maxOtherInfosSupported; ++i) 
     {
-        if(extraOtherInfos[i].oidval != -1) 
-            yaz_oi_set_string_oidval(oi, out, extraOtherInfos[i].oidval,
+        if (oid_oidlen(extraOtherInfos[i].oid) > 0)
+            yaz_oi_set_string_oid(oi, out, extraOtherInfos[i].oid,
                                      1, extraOtherInfos[i].value);
     }   
 }
@@ -336,9 +337,13 @@ static void send_initRequest(const char* type_and_host)
 
     req->referenceId = set_refid (out);
 
-    if (yazProxy && type_and_host) 
-        yaz_oi_set_string_oidval(&req->otherInfo, out, VAL_PROXY,
-        1, type_and_host);
+    if (yazProxy && type_and_host)
+    {
+        const int *oid_proxy = yaz_string_to_oid(yaz_oid_std(),
+                                                 CLASS_USERINFO, OID_STR_PROXY);
+        yaz_oi_set_string_oid(&req->otherInfo, out, oid_proxy,
+                              1, type_and_host);
+    }
     
     if (negotiationCharset || yazLang) {
         Z_OtherInformation **p;
@@ -412,9 +417,12 @@ static int process_initResponse(Z_InitResponse *res)
             }
             else if (uif->which == Z_External_single) 
             {
+                const int *oclc_oid = yaz_string_to_oid(yaz_oid_std(),
+                                                        CLASS_GENERAL,
+                                                        "OCLC-userInfo");
                 Odr_any *sat = uif->u.single_ASN1_type;
-                oident *oid = oid_getentbyoid(uif->direct_reference);
-                if (oid->value == VAL_OCLCUI) {
+                if (!oid_oidcmp(uif->direct_reference, oclc_oid))
+                {
                     Z_OCLC_UserInformation *oclc_ui;
                     ODR decode = odr_createmem(ODR_DECODE);
                     odr_setbuf(decode, (char *) sat->buf, sat->len, 0);
@@ -851,27 +859,26 @@ static void print_record(const unsigned char *buf, size_t len)
 
 static void display_record(Z_External *r)
 {
-    oident *ent = oid_getentbyoid(r->direct_reference);
-
+    char oid_name_buf[OID_STR_MAX];
+    int oclass;
+    const int *oid = r->direct_reference;
+    const char *oid_name = 0;
+    
     record_last = r;
     /*
      * Tell the user what we got.
      */
-    if (r->direct_reference)
+    if (oid)
     {
+        oid_name = yaz_oid_to_string_buf(oid, &oclass, oid_name_buf);
         printf("Record type: ");
-        if (ent)
-            printf("%s\n", ent->desc);
-        else if (!odr_oid(print, &r->direct_reference, 0, 0))
-        {
-            odr_perror(print, "print oid");
-            odr_reset(print);
-        }
+        if (oid_name)
+            printf("%s\n", oid_name);
     }
     /* Check if this is a known, ASN.1 type tucked away in an octet string */
-    if (ent && r->which == Z_External_octet)
+    if (r->which == Z_External_octet)
     {
-        Z_ext_typeent *type = z_ext_getentbyref(ent->value);
+        Z_ext_typeent *type = z_ext_getentbyref(r->direct_reference);
         char *rr;
 
         if (type)
@@ -901,25 +908,24 @@ static void display_record(Z_External *r)
             }
         }
     }
-    if (ent && ent->value == VAL_SOIF)
+    if (oid_name && !yaz_matchstr(oid_name, OID_STR_SOIF))
     {
         print_record((const unsigned char *) r->u.octet_aligned->buf,
                      r->u.octet_aligned->len);
         if (marc_file)
             fwrite (r->u.octet_aligned->buf, 1, r->u.octet_aligned->len, marc_file);
     }
-    else if (r->which == Z_External_octet)
+    else if (oid && r->which == Z_External_octet)
     {
         const char *octet_buf = (char*)r->u.octet_aligned->buf;
-        if (ent->oclass == CLASS_RECSYN && 
-                (ent->value == VAL_TEXT_XML || 
-                 ent->value == VAL_APPLICATION_XML ||
-                 ent->value == VAL_HTML))
+        if (oid_name && (!yaz_matchstr(oid_name, OID_STR_XML)
+                         || !yaz_matchstr(oid_name, OID_STR_APPLICATION_XML)
+                         || !yaz_matchstr(oid_name, OID_STR_HTML)))
         {
             print_record((const unsigned char *) octet_buf,
                          r->u.octet_aligned->len);
         }
-        else if (ent->value == VAL_POSTSCRIPT)
+        else if (oid_name && !yaz_matchstr(oid_name, OID_STR_POSTSCRIPT))
         {
             int size = r->u.octet_aligned->len;
             if (size > 100)
@@ -928,11 +934,12 @@ static void display_record(Z_External *r)
         }
         else
         {
+            const int *oidsuffix = oid_oidlen(oid) > 1 
+                ? oid + oid_oidlen(oid)-2 : 0;
             if ( 
 #if AVOID_MARC_DECODE
                 /* primitive check for a marc OID 5.1-29 except 16 */
-                ent->oidsuffix[0] == 5 && ent->oidsuffix[1] < 30 &&
-                ent->oidsuffix[1] != 16
+                oidsuffix[0] == 5 && oidsuffix[1] < 30 && oidsuffix[1] != 16
 #else
                 1
 #endif
@@ -946,7 +953,7 @@ static void display_record(Z_External *r)
 
                 if (marcCharset && !strcmp(marcCharset, "auto"))
                 {
-                    if (ent->value == VAL_USMARC)
+                    if (!yaz_matchstr(oid_name, OID_STR_USMARC))
                     {
                         if (octet_buf[9] == 'a')
                             from = "UTF-8";
@@ -996,7 +1003,7 @@ static void display_record(Z_External *r)
         if (marc_file)
             fwrite (octet_buf, 1, r->u.octet_aligned->len, marc_file);
     }
-    else if (ent && ent->value == VAL_SUTRS)
+    else if (oid_name && !yaz_matchstr(oid_name, OID_STR_SUTRS))
     {
         if (r->which != Z_External_sutrs)
         {
@@ -1007,7 +1014,7 @@ static void display_record(Z_External *r)
         if (marc_file)
             fwrite (r->u.sutrs->buf, 1, r->u.sutrs->len, marc_file);
     }
-    else if (ent && ent->value == VAL_GRS1)
+    else if (oid_name && !yaz_matchstr(oid_name, OID_STR_GRS1))
     {
         WRBUF w;
         if (r->which != Z_External_grs1)
@@ -1020,7 +1027,7 @@ static void display_record(Z_External *r)
         puts (wrbuf_cstr(w));
         wrbuf_destroy(w);
     }
-    else if (ent && ent->value == VAL_OPAC)
+    else if (oid_name && !yaz_matchstr(oid_name, OID_STR_OPAC))
     {
         int i;
         if (r->u.opac->bibliographicRecord)
@@ -1136,7 +1143,6 @@ static void display_record(Z_External *r)
 static void display_diagrecs(Z_DiagRec **pp, int num)
 {
     int i;
-    oident *ent;
     Z_DefaultDiagFormat *r;
 
     printf("Diagnostic message(s) from database:\n");
@@ -1150,9 +1156,19 @@ static void display_diagrecs(Z_DiagRec **pp, int num)
         }
         else
             r = p->u.defaultFormat;
-        if (!(ent = oid_getentbyoid(r->diagnosticSetId)) ||
-            ent->oclass != CLASS_DIAGSET || ent->value != VAL_BIB1)
-            printf("Missing or unknown diagset\n");
+
+        if (!r->diagnosticSetId)
+            printf("Missing diagset\n");
+        else
+        {
+            int oclass;
+            char diag_name_buf[OID_STR_MAX];
+            const char *diag_name = 0;
+            diag_name = yaz_oid_to_string_buf
+                (r->diagnosticSetId, &oclass, diag_name_buf);
+            if (yaz_matchstr(diag_name, OID_STR_BIB1))
+                printf("Unknown diagset: %s\n", diag_name);
+        }
         printf("    [%d] %s", *r->condition, diagbib1_str(*r->condition));
         switch (r->which)
         {
@@ -1385,7 +1401,7 @@ static int send_SRW_searchRequest(const char *arg)
 
     if (record_schema)
         sr->u.request->recordSchema = record_schema;
-    if (recordsyntax_size == 1 && recordsyntax_list[0] == VAL_TEXT_XML)
+    if (recordsyntax_size == 1 && !yaz_matchstr(recordsyntax_list[0], "xml"))
         sr->u.request->recordPacking = "xml";
     return send_srw(sr);
 }
@@ -1464,9 +1480,11 @@ static int send_searchRequest(const char *arg)
     if (smallSetUpperBound > 0 || (largeSetLowerBound > 1 &&
         mediumSetPresentNumber > 0))
     {
-        if (recordsyntax_size > 0)
+        if (recordsyntax_size)
             req->preferredRecordSyntax =
-                yaz_oidval_to_z3950oid(out, CLASS_RECSYN, recordsyntax_list[0]);
+                yaz_string_to_oid_odr(yaz_oid_std(), 
+                                      CLASS_RECSYN, recordsyntax_list[0], out);
+
         req->smallSetElementSetNames =
             req->mediumSetElementSetNames = elementSetNames;
     }
@@ -1916,15 +1934,10 @@ static Z_External *create_external_itemRequest(void)
     }
     else
     {
-        oident oid;
-        
-        item_request_buf = odr_getbuf (out, &item_request_size, 0);
-        oid.proto = PROTO_GENERAL;
-        oid.oclass = CLASS_GENERAL;
-        oid.value = VAL_ISO_ILL_1;
-        
+        const int *ill_oid = yaz_string_to_oid(yaz_oid_std(),
+                                               CLASS_GENERAL, "ISOILL-1");
         r = (Z_External *) odr_malloc (out, sizeof(*r));
-        r->direct_reference = odr_oiddup(out,oid_getoidbyent(&oid)); 
+        r->direct_reference = odr_oiddup(out, ill_oid);
         r->indirect_reference = 0;
         r->descriptor = 0;
         r->which = Z_External_single;
@@ -1974,15 +1987,13 @@ static Z_External *create_external_ILL_APDU(int which)
     }
     else
     {
-        oident oid;
+        const int *ill_oid = yaz_string_to_oid(yaz_oid_std(),
+                                               CLASS_GENERAL, "ISOILL-1");
+
         ill_request_buf = odr_getbuf (out, &ill_request_size, 0);
         
-        oid.proto = PROTO_GENERAL;
-        oid.oclass = CLASS_GENERAL;
-        oid.value = VAL_ISO_ILL_1;
-        
         r = (Z_External *) odr_malloc (out, sizeof(*r));
-        r->direct_reference = odr_oiddup(out,oid_getoidbyent(&oid)); 
+        r->direct_reference = odr_oiddup(out, ill_oid);
         r->indirect_reference = 0;
         r->descriptor = 0;
         r->which = Z_External_single;
@@ -2006,13 +2017,10 @@ static Z_External *create_external_ILL_APDU(int which)
 static Z_External *create_ItemOrderExternal(const char *type, int itemno)
 {
     Z_External *r = (Z_External *) odr_malloc(out, sizeof(Z_External));
-    oident ItemOrderRequest;
-  
-    ItemOrderRequest.proto = PROTO_Z3950;
-    ItemOrderRequest.oclass = CLASS_EXTSERV;
-    ItemOrderRequest.value = VAL_ITEMORDER;
-    r->direct_reference = odr_oiddup(out,oid_getoidbyent(&ItemOrderRequest)); 
+    const int *itemorder_oid = yaz_string_to_oid(yaz_oid_std(),
+                                                 CLASS_EXTSERV,
+                                                 "Item order");
+    r->direct_reference = odr_oiddup(out, itemorder_oid);
     r->indirect_reference = 0;
     r->descriptor = 0;
 
@@ -2060,14 +2068,16 @@ static Z_External *create_ItemOrderExternal(const char *type, int itemno)
     }
     else if (!strcmp(type, "xml") || !strcmp(type, "3"))
     {
-    const char *xml_buf =
-        "<itemorder>\n"
-        "  <type>request</type>\n"
-        "  <libraryNo>000200</libraryNo>\n"
-        "  <borrowerTicketNo> 1212 </borrowerTicketNo>\n"
-        "</itemorder>";
+        const int *oid_xml = yaz_string_to_oid(yaz_oid_std(),
+                                               CLASS_RECSYN, "xml");
+        const char *xml_buf =
+            "<itemorder>\n"
+            "  <type>request</type>\n"
+            "  <libraryNo>000200</libraryNo>\n"
+            "  <borrowerTicketNo> 1212 </borrowerTicketNo>\n"
+            "</itemorder>";
         r->u.itemOrder->u.esRequest->notToKeep->itemRequest =
-            z_ext_record (out, VAL_TEXT_XML, xml_buf, strlen(xml_buf));
+            z_ext_record_oid(out, oid_xml, xml_buf, strlen(xml_buf));
     }
     else
         r->u.itemOrder->u.esRequest->notToKeep->itemRequest = 0;
@@ -2079,15 +2089,13 @@ static int send_itemorder(const char *type, int itemno)
 {
     Z_APDU *apdu = zget_APDU(out, Z_APDU_extendedServicesRequest);
     Z_ExtendedServicesRequest *req = apdu->u.extendedServicesRequest;
-    oident ItemOrderRequest;
-
 
+    const int *itemorder_oid = yaz_string_to_oid(yaz_oid_std(),
+                                                 CLASS_EXTSERV,
+                                                 "Item order");
     req->referenceId = set_refid (out);
 
-    ItemOrderRequest.proto = PROTO_Z3950;
-    ItemOrderRequest.oclass = CLASS_EXTSERV;
-    ItemOrderRequest.value = VAL_ITEMORDER;
-    req->packageType = odr_oiddup(out,oid_getoidbyent(&ItemOrderRequest));
+    req->packageType = odr_oiddup(out, itemorder_oid);
     req->packageName = esPackageName;
 
     req->taskSpecificParameters = create_ItemOrderExternal(type, itemno);
@@ -2225,9 +2233,11 @@ static int cmd_update_Z3950(int version, int action_no, const char *recid,
     Z_ExtendedServicesRequest *req = apdu->u.extendedServicesRequest;
     Z_External *r;
     Z_External *record_this = 0;
+    const int *oid_xml = yaz_string_to_oid(yaz_oid_std(),
+                                           CLASS_RECSYN, "xml");
 
     if (rec_buf)
-        record_this = z_ext_record (out, VAL_TEXT_XML, rec_buf, rec_len);
+        record_this = z_ext_record_oid(out, oid_xml, rec_buf, rec_len);
     else
     {
         if (!record_last)
@@ -2239,9 +2249,10 @@ static int cmd_update_Z3950(int version, int action_no, const char *recid,
     }
 
     req->packageType =
-        yaz_oidval_to_z3950oid(out, CLASS_EXTSERV,
-                               version == 0 ? VAL_DBUPDATE0 : VAL_DBUPDATE);
-
+        yaz_string_to_oid_odr(yaz_oid_std(),
+                              CLASS_EXTSERV, 
+                              version == 0 ? "DB. Update (first version)" :
+                              "DB. Update", out);
     req->packageName = esPackageName;
     
     req->referenceId = set_refid (out);
@@ -2349,8 +2360,8 @@ static int cmd_xmles(const char *arg)
     {
         char *asn_buf = 0;
         int noread = 0;
+        int *oid;
         char oid_str[51];
-        int oid_value_xmles = VAL_XMLES;
         Z_APDU *apdu = zget_APDU(out, Z_APDU_extendedServicesRequest);
         Z_ExtendedServicesRequest *req = apdu->u.extendedServicesRequest;
         
@@ -2370,24 +2381,24 @@ static int cmd_xmles(const char *arg)
             return 0;
         }
         arg += noread;
-        oid_value_xmles  = oid_getvalbyname(oid_str);
-        if (oid_value_xmles == VAL_NONE)
-        {
-            printf("Bad OID: %s\n", oid_str);
-            return 0;
-        }
-
         if (parse_cmd_doc(&arg, out, &asn_buf,
                           &ext->u.single_ASN1_type->len, 0) == 0)
             return 0;
 
         ext->u.single_ASN1_type->buf = (unsigned char *) asn_buf;
 
-        req->packageType = yaz_oidval_to_z3950oid(out, CLASS_EXTSERV,
-                                                  oid_value_xmles);
+        oid = yaz_string_to_oid_odr(yaz_oid_std(),
+                                    CLASS_EXTSERV, oid_str, out);
+        if (!oid)
+        {
+            printf("Bad OID: %s\n", oid_str);
+            return 0;
+        }
+
+        req->packageType = oid;
         
-        ext->direct_reference = yaz_oidval_to_z3950oid(out, CLASS_EXTSERV,
-                                                       oid_value_xmles);
+        ext->direct_reference = oid;
+
         send_apdu(apdu);
         
         return 2;
@@ -2457,7 +2468,8 @@ static int cmd_explain(const char *arg)
         
         /* save this for later .. when fetching individual records */
         sr = yaz_srw_get(out, Z_SRW_explain_request);
-        if (recordsyntax_size > 0 && recordsyntax_list[0] == VAL_TEXT_XML)
+        if (recordsyntax_size == 1 
+            && !yaz_matchstr(recordsyntax_list[0], "xml"))
             sr->u.explain_request->recordPacking = "xml";
         send_srw(sr);
         return 2;
@@ -2646,9 +2658,10 @@ static int send_presentRequest(const char *arg)
     req->resultSetStartPoint = &setno;
     req->numberOfRecordsRequested = &nos;
 
-    if (recordsyntax_size == 1)
+    if (recordsyntax_size)
         req->preferredRecordSyntax =
-            yaz_oidval_to_z3950oid(out, CLASS_RECSYN, recordsyntax_list[0]);
+            yaz_string_to_oid_odr(yaz_oid_std(),
+                                  CLASS_RECSYN, recordsyntax_list[0], out);
 
     if (record_schema || recordsyntax_size >= 2)
     {
@@ -2669,13 +2682,15 @@ static int send_presentRequest(const char *arg)
         else 
         {
             compo.u.complex->generic->schema.oid =
-                yaz_str_to_z3950oid(out, CLASS_SCHEMA, record_schema);
+                yaz_string_to_oid_odr(yaz_oid_std(),
+                                      CLASS_SCHEMA, record_schema, out);
             
             if (!compo.u.complex->generic->schema.oid)
             {
                 /* OID wasn't a schema! Try record syntax instead. */
                 compo.u.complex->generic->schema.oid = (Odr_oid *)
-                    yaz_str_to_z3950oid(out, CLASS_RECSYN, record_schema);
+                    yaz_string_to_oid_odr(yaz_oid_std(),
+                                          CLASS_RECSYN, record_schema, out);
             }
         }
         if (!elementSetNames)
@@ -2691,6 +2706,9 @@ static int send_presentRequest(const char *arg)
         }
         compo.u.complex->num_dbSpecific = 0;
         compo.u.complex->dbSpecific = 0;
+
+        compo.u.complex->num_recordSyntax = 0;
+        compo.u.complex->recordSyntax = 0;
         if (recordsyntax_size >= 2)
         {
             int i;
@@ -2699,13 +2717,8 @@ static int send_presentRequest(const char *arg)
                 odr_malloc(out, recordsyntax_size * sizeof(Odr_oid*));
             for (i = 0; i < recordsyntax_size; i++)
             compo.u.complex->recordSyntax[i] =                 
-                yaz_oidval_to_z3950oid(out, CLASS_RECSYN,
-                                       recordsyntax_list[i]);
-        }
-        else
-        {
-            compo.u.complex->num_recordSyntax = 0;
-            compo.u.complex->recordSyntax = 0;
+                yaz_string_to_oid_odr(yaz_oid_std(), 
+                                      CLASS_RECSYN, recordsyntax_list[i], out);
         }
     }
     else if (elementSetNames)
@@ -2733,7 +2746,7 @@ static int send_SRW_presentRequest(const char *arg)
     sr->u.request->maximumRecords = odr_intdup(out, nos);
     if (record_schema)
         sr->u.request->recordSchema = record_schema;
-    if (recordsyntax_size == 1 && recordsyntax_list[0] == VAL_TEXT_XML)
+    if (recordsyntax_size == 1 && !yaz_matchstr(recordsyntax_list[0], "xml"))
         sr->u.request->recordPacking = "xml";
     return send_srw(sr);
 }
@@ -2886,7 +2899,8 @@ int send_scanrequest(const char *query, int pp, int num, const char *term)
             return -1;
         }
         req->attributeSet =
-            yaz_oidval_to_z3950oid(out, CLASS_ATTSET, VAL_BIB1);
+            yaz_string_to_oid_odr(yaz_oid_std(),
+                                  CLASS_ATTSET, "Bib-1", out);
         if (!(req->termListAndStartPoint = ccl_scan_query (out, rpn)))
         {
             printf("Couldn't convert CCL to Scan term\n");
@@ -3181,29 +3195,29 @@ int cmd_format(const char *arg)
     const char *cp = arg;
     int nor;
     int idx = 0;
-    oid_value nsyntax[RECORDSYNTAX_MAX];
+    int i;
     char form_str[41];
     if (!arg || !*arg)
     {
         printf("Usage: format <recordsyntax>\n");
         return 0;
     }
+    for (i = 0; i < recordsyntax_size; i++)
+    {
+        xfree(recordsyntax_list[i]);
+        recordsyntax_list[i] = 0;
+    }
+
     while (sscanf(cp, "%40s%n", form_str, &nor) >= 1 && nor > 0 
            && idx < RECORDSYNTAX_MAX)
     {
-        nsyntax[idx] = oid_getvalbyname(form_str);
         if (!strcmp(form_str, "none"))
             break;
-        if (nsyntax[idx] == VAL_NONE)
-        {
-            printf ("unknown record syntax: %s\n", form_str);
-            return 0;
-        }
+        recordsyntax_list[idx] = xstrdup(form_str);
         cp += nor;
         idx++;
     }
     recordsyntax_size = idx;
-    memcpy(recordsyntax_list, nsyntax, idx * sizeof(*nsyntax));
     return 1;
 }
 
@@ -3224,24 +3238,6 @@ int cmd_elements(const char *arg)
     return 1;
 }
 
-int cmd_attributeset(const char *arg)
-{
-    char what[100];
-
-    if (!arg || !*arg)
-    {
-        printf("Usage: attributeset <setname>\n");
-        return 0;
-    }
-    sscanf(arg, "%s", what);
-    if (p_query_attset (what))
-    {
-        printf("Unknown attribute set name\n");
-        return 0;
-    }
-    return 1;
-}
-
 int cmd_querytype (const char *arg)
 {
     if (!strcmp (arg, "ccl"))
@@ -3611,6 +3607,7 @@ int cmd_set_marcdump(const char* arg)
     return 1;
 }
 
+#if 0
 /* 
    this command takes 3 arge {name class oid} 
 */
@@ -3690,6 +3687,7 @@ int cmd_register_oid(const char* args) {
     }
     return 1;  
 }
+#endif
 
 int cmd_push_command(const char* arg) 
 {
@@ -3737,7 +3735,6 @@ static void initialize(void)
         fprintf(stderr, "failed to allocate ODR streams\n");
         exit(1);
     }
-    oid_init();
     
     setvbuf(stdout, 0, _IONBF, 0);
     if (apdu_file)
@@ -3758,8 +3755,11 @@ static void initialize(void)
     rl_attempted_completion_function = (CPPFunction*)readline_completer;
 #endif
     for(i = 0; i < maxOtherInfosSupported; ++i) {
-        extraOtherInfos[i].oidval = -1;
+        extraOtherInfos[i].oid[0] = -1;
+        extraOtherInfos[i].value = 0;
     }
+
+    cmd_format("usmarc");
     
     source_rcfile();
 
@@ -4141,42 +4141,42 @@ int cmd_set_otherinfo(const char* args)
     char oidstr[101], otherinfoString[101];
     int otherinfoNo;
     int sscan_res;
-    int oidval;
     
     sscan_res = sscanf (args, "%d %100[^ ] %100s", 
                         &otherinfoNo, oidstr, otherinfoString);
-    if (sscan_res==1) {
+
+    if (sscan_res > 0 && otherinfoNo >= maxOtherInfosSupported) {
+        printf("Error otherinfo index too large (%d>=%d)\n",
+               otherinfoNo,maxOtherInfosSupported);
+        return 0;
+    }
+    
+
+    if (sscan_res==1) 
+    {
         /* reset this otherinfo */
-        if(otherinfoNo>=maxOtherInfosSupported) {
-            printf("Error otherinfo index to large (%d>%d)\n",
-                   otherinfoNo,maxOtherInfosSupported);
-        }
-        extraOtherInfos[otherinfoNo].oidval = -1;
-        if (extraOtherInfos[otherinfoNo].value)
-            xfree(extraOtherInfos[otherinfoNo].value);                   
+        extraOtherInfos[otherinfoNo].oid[0] = -1;
+        xfree(extraOtherInfos[otherinfoNo].value);                   
         extraOtherInfos[otherinfoNo].value = 0;
         return 0;
     }
-    if (sscan_res<3) {
+    if (sscan_res != 3) {
         printf("Error in set_otherinfo command \n");
         return 0;
     }
-    
-    if (otherinfoNo>=maxOtherInfosSupported) {
-        printf("Error otherinfo index too large (%d>=%d)\n",
-               otherinfoNo,maxOtherInfosSupported);
-    }
-    
-    oidval = oid_getvalbyname (oidstr);
-    if (oidval == VAL_NONE)
+    else
     {
-        printf("Error in set_otherinfo command unknown oid %s \n",oidstr);
-        return 0;
-    }
-    extraOtherInfos[otherinfoNo].oidval = oidval;
-    if (extraOtherInfos[otherinfoNo].value)
+        NMEM oid_tmp = nmem_create();
+        const int *oid =
+            yaz_string_to_oid_nmem(yaz_oid_std(),
+                                   CLASS_GENERAL, oidstr, oid_tmp);
+        oid_oidcpy(extraOtherInfos[otherinfoNo].oid, oid);
+            
         xfree(extraOtherInfos[otherinfoNo].value);
-    extraOtherInfos[otherinfoNo].value = xstrdup(otherinfoString);
+        extraOtherInfos[otherinfoNo].value = xstrdup(otherinfoString);
+
+        nmem_destroy(oid_tmp);
+    }
     
     return 0;
 }
@@ -4199,32 +4199,44 @@ int cmd_list_otherinfo(const char* args)
 {
     int i;         
     
-    if(strlen(args)>0) {
+    if (strlen(args)>0)
+    {
         i = atoi(args);
-        if( i >= maxOtherInfosSupported ) {
+        if (i >= maxOtherInfosSupported)
+        {
             printf("Error otherinfo index to large (%d>%d)\n",i,maxOtherInfosSupported);
             return 0;
         }
-
-        if(extraOtherInfos[i].oidval != -1) 
+        if (extraOtherInfos[i].value)
+        {
+            char name_oid[OID_STR_MAX];
+            int oclass;
+            const char *name =
+                yaz_oid_to_string_buf(extraOtherInfos[i].oid, &oclass,
+                                      name_oid);
             printf("  otherinfo %d %s %s\n",
-                   i,
-                   yaz_z3950_oid_value_to_str(
-                       (enum oid_value) extraOtherInfos[i].oidval,
-                       CLASS_RECSYN),
+                   i, name ? name : "null",
                    extraOtherInfos[i].value);
+        }
         
-    } else {            
-        for(i=0; i<maxOtherInfosSupported; ++i) {
-            if(extraOtherInfos[i].oidval != -1) 
+    } 
+    else 
+    {            
+        for(i = 0; i < maxOtherInfosSupported; ++i)
+        {
+            if (extraOtherInfos[i].value)
+            {
+                char name_oid[OID_STR_MAX];
+                int oclass;
+                const char *name =
+                    yaz_oid_to_string_buf(extraOtherInfos[i].oid, &oclass,
+                                          name_oid);
                 printf("  otherinfo %d %s %s\n",
-                       i,
-                       yaz_z3950_oid_value_to_str(
-                           (enum oid_value) extraOtherInfos[i].oidval,
-                           CLASS_RECSYN),
+                       i, name ? name : "null",
                        extraOtherInfos[i].value);
+            }
+            
         }
-        
     }
     return 0;
 }
@@ -4285,10 +4297,10 @@ int cmd_list_all(const char* args) {
     printf("ssub/lslb/mspn       : %d/%d/%d\n",smallSetUpperBound,largeSetLowerBound,mediumSetPresentNumber);
     
     /* print present related options */
-    printf("Format               : %s\n",
-           (recordsyntax_size > 0) ? 
-           yaz_z3950_oid_value_to_str(recordsyntax_list[0], CLASS_RECSYN) :
-           "none");
+    if (recordsyntax_size > 0)
+    {
+        printf("Format               : %s\n", recordsyntax_list[0]);
+    }
     printf("Schema               : %s\n",record_schema ? record_schema : "not set");
     printf("Elements             : %s\n",elementSetNames?elementSetNames->u.generic:"");
     
@@ -4312,20 +4324,22 @@ int cmd_clear_otherinfo(const char* args)
                    otherinfoNo, maxOtherInfosSupported);
             return 0;
         }
-        if (extraOtherInfos[otherinfoNo].oidval != -1)
+        if (extraOtherInfos[otherinfoNo].value)
         {                 
             /* only clear if set. */
-            extraOtherInfos[otherinfoNo].oidval = -1;
+            extraOtherInfos[otherinfoNo].oid[0] = -1;
             xfree(extraOtherInfos[otherinfoNo].value);
+            extraOtherInfos[otherinfoNo].value = 0;
         }
     } else {
         int i;
         for(i = 0; i < maxOtherInfosSupported; ++i) 
         {
-            if (extraOtherInfos[i].oidval != -1)
+            if (extraOtherInfos[i].value)
             {                               
-                extraOtherInfos[i].oidval = -1;
+                extraOtherInfos[i].oid[0] = -1;
                 xfree(extraOtherInfos[i].value);
+                extraOtherInfos[i].value = 0;
             }
         }
     }
@@ -4356,7 +4370,7 @@ static struct {
     char *ad;
         completerFunctionType rl_completerfunction;
     int complete_filenames;
-    char **local_tabcompletes;
+    const char **local_tabcompletes;
 } cmd_array[] = {
     {"open", cmd_open, "('tcp'|'ssl')':<host>[':'<port>][/<db>]",NULL,0,NULL},
     {"quit", cmd_quit, "",NULL,0,NULL},
@@ -4382,7 +4396,6 @@ static struct {
     {"schema", cmd_schema, "<schema>",complete_schema,0,NULL},
     {"elements", cmd_elements, "<elementSetName>",NULL,0,NULL},
     {"close", cmd_close, "",NULL,0,NULL},
-    {"attributeset", cmd_attributeset, "<attrset>",complete_attributeset,0,NULL},
     {"querytype", cmd_querytype, "<type>",complete_querytype,0,NULL},
     {"refid", cmd_refid, "<id>",NULL,0,NULL},
     {"itemorder", cmd_itemorder, "ill|item|xml <itemno>",NULL,0,NULL},
@@ -4408,7 +4421,9 @@ static struct {
     {"set_auto_wait", cmd_set_auto_wait," on|off",complete_auto_reconnect,1,NULL},
     {"set_otherinfo", cmd_set_otherinfo,"<otherinfoinddex> <oid> <string>",NULL,0,NULL},
     {"sleep", cmd_sleep,"<seconds>",NULL,0,NULL},
+#if 0
     {"register_oid", cmd_register_oid,"<name> <class> <oid>",NULL,0,NULL},
+#endif
     {"push_command", cmd_push_command,"<command>",command_generator,0,NULL},
     {"register_tab", cmd_register_tab,"<commandname> <tab>",command_generator,0,NULL},
     {"cclparse", cmd_cclparse,"<ccl find command>",NULL,0,NULL},
@@ -4501,7 +4516,7 @@ int cmd_register_tab(const char* arg)
     char command[101], tabargument[101];
     int i;
     int num_of_tabs;
-    char** tabslist;
+    const char** tabslist;
     
     if (sscanf (arg, "%100s %100s", command, tabargument) < 1) {
         return 0;
@@ -4521,7 +4536,7 @@ int cmd_register_tab(const char* arg)
     
         
     if (!cmd_array[i].local_tabcompletes)
-        cmd_array[i].local_tabcompletes = (char **) calloc(1,sizeof(char**));
+        cmd_array[i].local_tabcompletes = (const char **) calloc(1,sizeof(char**));
     
     num_of_tabs=0;              
     
@@ -4530,7 +4545,7 @@ int cmd_register_tab(const char* arg)
         num_of_tabs++;
     }
     
-    cmd_array[i].local_tabcompletes = (char **)
+    cmd_array[i].local_tabcompletes = (const char **)
         realloc(cmd_array[i].local_tabcompletes,
                 (num_of_tabs+2)*sizeof(char**));
     tabslist = cmd_array[i].local_tabcompletes;
@@ -4616,7 +4631,7 @@ static char *command_generator(const char *text, int state)
 }
 
 #if HAVE_READLINE_READLINE_H
-static char** default_completer_list = NULL;
+static const char** default_completer_list = NULL;
 
 static char* default_completer(const char* text, int state)
 {
index 4d2032d..3bbb156 100644 (file)
@@ -2,15 +2,15 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: tabcomplete.c,v 1.17 2007-01-03 08:42:13 adam Exp $
+ * $Id: tabcomplete.c,v 1.18 2007-04-12 13:52:57 adam Exp $
  */
 
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <yaz/oid.h>
 #include "tabcomplete.h"
+#include <yaz/oid_db.h>
 
 /* ***************************************************************************
  *
  * 
  * ***************************************************************************/
 
-char *complete_from_list(char* completions[], const char *text, int state)
+char *complete_from_list(const char** completions,
+                         const char *text, int state)
 {       
 #if HAVE_READLINE_READLINE_H
     static int idx;
     
-    if(!completions) return NULL;
-    if(state==0) {
+    if (!completions) 
+        return NULL;
+    if (state==0) 
         idx = 0;
-    }
     for(; completions[idx]; ++ idx) {
         if(!
 #ifdef WIN32
@@ -52,8 +53,8 @@ char *complete_from_list(char* completions[], const char *text, int state)
    
 
 typedef struct {
-    oid_class oclass;
-    char** values;
+    int oclass;
+    const char** values;
     size_t index;
     size_t max;
 } oid_callback_t;
@@ -63,31 +64,34 @@ typedef struct {
   of pointers into the oid owned data 
 */
 
-void oid_loader(struct oident* oid, void* data_)
+void oid_loader(const int *oid,
+                int oclass, const char *name, void* data_)
 {
     oid_callback_t* data=(oid_callback_t*) data_;
     
-    
-    if((oid->oclass == CLASS_GENERAL) || (oid->oclass == data->oclass)) {
-        if(data->index==data->max) {
-                        data->values=(char**)realloc(data->values,((data->max+1)*2)*sizeof(char*));
-                        data->max=(data->max+1)*2 - 1;
-        };
-        data->values[data->index]=oid->desc;
+    if ((oclass == CLASS_GENERAL) || (oclass == data->oclass))
+    {
+        if (data->index==data->max) 
+        {
+            data->values=(const char**)
+                realloc(data->values,((data->max+1)*2)*sizeof(char*));
+            data->max=(data->max+1)*2 - 1;
+        }
+        data->values[data->index] = name;
         ++data->index;          
     }
 }
 
-char** build_list_for_oclass(oid_class oclass)
+const char** build_list_for_oclass(oid_class oclass)
 { 
     oid_callback_t data;        
-    data.values = (char **) calloc(10,sizeof(char*));
+    data.values = (const char **) calloc(10,sizeof(char*));
     data.index = 0;
     data.max = 9;
     data.oclass = oclass;
-    
-    oid_trav(oid_loader, &data);
-    
+
+    yaz_oid_trav(yaz_oid_std(), oid_loader, &data);
+
     data.values[data.index]=0;
     return data.values;    
 }
@@ -100,20 +104,20 @@ char** build_list_for_oclass(oid_class oclass)
 
 char* complete_querytype(const char *text, int state)
 {
-    char* querytypes[] = {"ccl2rpn","prefix","cclrpn","ccl","cql", 0};
+    static const char* querytypes[] = {"ccl2rpn","prefix","cclrpn","ccl","cql", 0};
     return complete_from_list(querytypes,text,state);  
 }
 
 char* complete_auto_reconnect(const char *text, int state)
 {
-    char* querytypes[] = {"on","off",0};
+    static const char* querytypes[] = {"on","off",0};
     return complete_from_list(querytypes,text,state);  
 }
 
 
 char* complete_format(const char* text, int state)
 {
-    char** list=build_list_for_oclass(CLASS_RECSYN);
+    const char** list = build_list_for_oclass(CLASS_RECSYN);
     char* res=complete_from_list(list,text,state);  
     
     free(list); 
@@ -122,7 +126,7 @@ char* complete_format(const char* text, int state)
 
 char* complete_schema(const char* text, int state)
 {
-    char** list = build_list_for_oclass(CLASS_SCHEMA);
+    const char** list = build_list_for_oclass(CLASS_SCHEMA);
     char* res = complete_from_list(list,text,state);  
     
     free(list); 
@@ -132,7 +136,7 @@ char* complete_schema(const char* text, int state)
 
 char* complete_attributeset(const char* text, int state)
 {
-    char** list = build_list_for_oclass(CLASS_ATTSET);
+    const char** list = build_list_for_oclass(CLASS_ATTSET);
     char* res = complete_from_list(list,text,state);  
     
     free(list); 
index f7e0707..8abb9a7 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: tabcomplete.h,v 1.8 2007-01-03 08:42:13 adam Exp $
+ * $Id: tabcomplete.h,v 1.9 2007-04-12 13:52:57 adam Exp $
  */
 
 /* 
@@ -14,7 +14,8 @@ char* complete_format(const char* text, int state);
 char* complete_schema(const char* text, int state);
 char* complete_attributeset(const char* text, int state);
 char* complete_auto_reconnect(const char *text, int state);
-char *complete_from_list(char* completions[], const char *text, int state);
+char *complete_from_list(const char** completions,
+                         const char *text, int state);
 /*
  * Local variables:
  * c-basic-offset: 4
index 85ca9c0..89621e2 100644 (file)
@@ -1,13 +1,14 @@
-## $Id: Makefile.am,v 1.40 2007-04-10 14:42:31 adam Exp $
+## $Id: Makefile.am,v 1.41 2007-04-12 13:52:57 adam Exp $
 
 pkginclude_HEADERS= backend.h ccl.h ccl_xml.h cql.h comstack.h \
  diagbib1.h diagsrw.h diagsru_update.h sortspec.h log.h logrpn.h marcdisp.h \
  nmem.h nmem_xml.h odr.h \
- oid.h options.h otherinfo.h pquery.h prt-ext.h querytowrbuf.h \
+ options.h otherinfo.h pquery.h prt-ext.h querytowrbuf.h \
  readconf.h record_conv.h retrieval.h statserv.h \
  tcpip.h test.h timing.h unix.h tpath.h wrbuf.h xmalloc.h \
  yaz-ccl.h yaz-iconv.h yaz-util.h yaz-version.h yconfig.h proto.h \
  xmlquery.h libxml2_error.h xmltypes.h snprintf.h query-charset.h \
+ oid_db.h oid_util.h \
  \
  ill.h ill-core.h item-req.h z-accdes1.h z-accform1.h \
  z-acckrb1.h z-core.h z-date.h z-diag1.h z-espec1.h z-estask.h z-exp.h \
index 7d1d2c6..c7df87a 100644 (file)
@@ -24,7 +24,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-/* $Id: backend.h,v 1.42 2007-01-16 14:12:37 adam Exp $ */
+/* $Id: backend.h,v 1.43 2007-04-12 13:52:57 adam Exp $ */
 
 /** 
  * \file backend.h
@@ -40,6 +40,7 @@
 #include <yaz/yconfig.h>
 #include <yaz/proto.h>
 #include <yaz/srw.h>
+#include <yaz/oid_db.h>
 
 YAZ_BEGIN_CDECL
     
@@ -77,7 +78,7 @@ typedef struct {
     char *setname;             /* set name */
     int start;
     int number;                /* record number */
-    oid_value format;          /* One of the CLASS_RECSYN members */
+    int *format;               /* format, transfer syntax (OID) */
     Z_ReferenceId *referenceId;/* reference ID */
     Z_RecordComposition *comp; /* Formatting instructions */
     ODR stream;                /* encoding stream - memory source if required */
@@ -94,8 +95,7 @@ typedef struct bend_fetch_rr {
     char *setname;             /* set name */
     int number;                /* record number */
     Z_ReferenceId *referenceId;/* reference ID */
-    oid_value request_format;  /* One of the CLASS_RECSYN members */
-    int *request_format_raw;   /* same as above (raw OID) */
+    int *request_format;        /* format, transfer syntax (OID) */
     Z_RecordComposition *comp; /* Formatting instructions */
     ODR stream;                /* encoding stream - memory source if req */
     ODR print;                 /* printing stream */
@@ -104,8 +104,7 @@ typedef struct bend_fetch_rr {
     int len;                   /* length of record or -1 if structured */
     char *record;              /* record */
     int last_in_set;           /* is it?  */
-    oid_value output_format;   /* format */
-    int *output_format_raw;    /* used instead of above if not-null */
+    int *output_format;        /* response format/syntax (OID) */
     int errcode;               /* 0==success */
     char *errstring;           /* system error string or NULL */
     int surrogate_flag;        /* surrogate diagnostic */
@@ -128,7 +127,7 @@ typedef enum {
 typedef struct bend_scan_rr {
     int num_bases;      /* number of elements in databaselist */
     char **basenames;   /* databases to search */
-    oid_value attributeset;
+    int *attributeset;
     Z_ReferenceId *referenceId; /* reference ID */
     Z_AttributesPlusTerm *term;
     ODR stream;         /* encoding stream - memory source if required */
index 216d28d..f19d54d 100644 (file)
@@ -24,7 +24,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-/* $Id: comstack.h,v 1.26 2007-01-11 10:30:40 adam Exp $ */
+/* $Id: comstack.h,v 1.27 2007-04-12 13:52:57 adam Exp $ */
 
 /** 
  * \file comstack.h
@@ -35,7 +35,7 @@
 #define COMSTACK_H
 
 #include <yaz/yconfig.h>
-#include <yaz/oid.h>
+#include <yaz/oid_util.h>
 #include <yaz/xmalloc.h>
 
 YAZ_BEGIN_CDECL
index bad4498..a6d352f 100644 (file)
@@ -24,7 +24,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-/* $Id: logrpn.h,v 1.14 2007-03-19 21:07:35 adam Exp $ */
+/* $Id: logrpn.h,v 1.15 2007-04-12 13:52:57 adam Exp $ */
 
 /**
  * \file logrpn.h
@@ -42,10 +42,10 @@ YAZ_BEGIN_CDECL
 YAZ_EXPORT void log_rpn_query(Z_RPNQuery *rpn);
 YAZ_EXPORT void log_rpn_query_level(int loglevel, Z_RPNQuery *rpn);
 
-YAZ_EXPORT void log_scan_term(Z_AttributesPlusTerm *zapt, oid_value ast);
+YAZ_EXPORT void log_scan_term(Z_AttributesPlusTerm *zapt, const int *ast);
 YAZ_EXPORT void log_scan_term_level(int loglevel, 
-                                    Z_AttributesPlusTerm *zapt, oid_value ast);
-
+                                    Z_AttributesPlusTerm *zapt,
+                                    const int *ast);
 YAZ_EXPORT void yaz_log_zquery(Z_Query *q);
 YAZ_EXPORT void yaz_log_zquery_level(int loglevel, Z_Query *q);
 
index 78cc834..407d38c 100644 (file)
@@ -24,7 +24,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-/* $Id: odr.h,v 1.26 2007-03-19 21:08:13 adam Exp $ */
+/* $Id: odr.h,v 1.27 2007-04-12 13:52:57 adam Exp $ */
 
 /**
  * \file odr.h
@@ -218,7 +218,6 @@ YAZ_EXPORT Odr_null *odr_nullval(void);
 #define odr_offset(o) ((o)->bp - (o)->buf)
 #define odr_ok(o) (!(o)->error)
 #define odr_getmem(o) ((o)->mem)
-#define odr_setmem(o, v) ((o)->mem = (v))
 
 #define ODR_MAXNAME 256
 
@@ -276,8 +275,8 @@ YAZ_EXPORT int completeBER(const unsigned char *buf, int len);
 
 YAZ_EXPORT void odr_begin(ODR o);
 YAZ_EXPORT void odr_end(ODR o);
-YAZ_EXPORT Odr_oid *odr_oiddup(ODR odr, Odr_oid *o);
-YAZ_EXPORT Odr_oid *odr_oiddup_nmem(NMEM nmem, Odr_oid *o);
+YAZ_EXPORT Odr_oid *odr_oiddup(ODR odr, const Odr_oid *o);
+YAZ_EXPORT Odr_oid *odr_oiddup_nmem(NMEM nmem, const Odr_oid *o);
 YAZ_EXPORT int odr_grow_block(ODR b, int min_bytes);
 YAZ_EXPORT int odr_write(ODR o, unsigned char *buf, int bytes);
 YAZ_EXPORT int odr_seek(ODR o, int whence, int offset);
diff --git a/include/yaz/oid.h b/include/yaz/oid.h
deleted file mode 100644 (file)
index 69d999f..0000000
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * Copyright (c) 1995-2007, Index Data
- * All rights reserved.
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in the
- *       documentation and/or other materials provided with the distribution.
- *     * Neither the name of Index Data nor the names of its contributors
- *       may be used to endorse or promote products derived from this
- *       software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/* $Id: oid.h,v 1.30 2007-01-03 08:42:14 adam Exp $ */
-
-/**
- * \file oid.h
- * \brief Header for OID database
- *
- * More or less protocol-transparent OID database.
- * We could (and should?) extend this so that the user app can add new
- * entries to the list at initialization.
- */
-#ifndef OID_H
-#define OID_H
-
-#include <yaz/yconfig.h>
-
-YAZ_BEGIN_CDECL
-
-#define OID_SIZE 20
-#define OID_STR_MAX 256
-    
-typedef enum oid_proto
-{
-    PROTO_NOP=0,
-    PROTO_Z3950,
-    PROTO_SR,
-    PROTO_GENERAL,
-    PROTO_WAIS,
-    PROTO_HTTP
-} oid_proto;
-
-typedef enum oid_class
-{
-    CLASS_NOP=0,
-    CLASS_APPCTX,
-    CLASS_ABSYN,
-    CLASS_ATTSET,
-    CLASS_TRANSYN,
-    CLASS_DIAGSET,
-    CLASS_RECSYN,
-    CLASS_RESFORM,
-    CLASS_ACCFORM,
-    CLASS_EXTSERV,
-    CLASS_USERINFO,
-    CLASS_ELEMSPEC,
-    CLASS_VARSET,
-    CLASS_SCHEMA,
-    CLASS_TAGSET,
-    CLASS_GENERAL,
-    CLASS_NEGOT
-} oid_class;
-
-typedef enum oid_value
-{
-    VAL_NOP=0,
-    VAL_APDU,
-    VAL_BER,
-    VAL_BASIC_CTX,
-    VAL_BIB1,
-
-    VAL_EXP1,
-    VAL_EXT1,
-    VAL_CCL1,
-    VAL_GILS,
-    VAL_WAIS, 
-/* 10 */
-    VAL_STAS,
-    VAL_COLLECT1,
-    VAL_CIMI1,
-    VAL_GEO,
-    VAL_DIAG1,
-
-    VAL_ISO2709,
-    VAL_UNIMARC,
-    VAL_INTERMARC,
-    VAL_CCF,
-    VAL_USMARC,
-/* 20 */
-    VAL_UKMARC,
-    VAL_NORMARC,
-    VAL_LIBRISMARC,
-    VAL_DANMARC,
-    VAL_FINMARC,
-
-    VAL_MAB,
-    VAL_CANMARC,
-    VAL_SBN,
-    VAL_PICAMARC,
-    VAL_AUSMARC,
-/* 30 */
-    VAL_IBERMARC,
-    VAL_CATMARC,
-    VAL_MALMARC,
-    VAL_EXPLAIN,
-    VAL_SUTRS,
-
-    VAL_OPAC,
-    VAL_SUMMARY,
-    VAL_GRS0,
-    VAL_GRS1,
-    VAL_EXTENDED,
-/* 40 */
-    VAL_FRAGMENT,
-    VAL_RESOURCE1,
-    VAL_RESOURCE2,
-    VAL_PROMPT1,
-    VAL_DES1,
-
-    VAL_KRB1,
-    VAL_PRESSET,
-    VAL_PQUERY,
-    VAL_PCQUERY,
-    VAL_ITEMORDER,
-
-/* 50 */
-    VAL_DBUPDATE0,
-    VAL_DBUPDATE,
-    VAL_EXPORTSPEC,
-    VAL_EXPORTINV,
-    VAL_NONE,
-
-    VAL_SETM,
-    VAL_SETG,
-    VAL_VAR1,
-    VAL_ESPEC1,
-    VAL_SOIF,
-
-/* 60 */
-    VAL_SEARCHRES1,
-    VAL_THESAURUS,
-    VAL_CHARLANG,
-    VAL_USERINFO1,
-    VAL_MULTISRCH1,
-
-    VAL_MULTISRCH2,
-    VAL_DATETIME,
-    VAL_SQLRS,
-    VAL_PDF,
-    VAL_POSTSCRIPT,
-
-/* 70 */
-    VAL_HTML,
-    VAL_TIFF,
-    VAL_GIF,
-    VAL_JPEG,
-    VAL_PNG,
-
-    VAL_MPEG,
-    VAL_SGML,
-    VAL_TIFFB,
-    VAL_WAV,
-    VAL_UPDATEES,
-
-/* 80 */
-    VAL_TEXT_XML,
-    VAL_APPLICATION_XML,
-    VAL_UNIVERSE_REPORT,
-    VAL_PROXY,
-    VAL_COOKIE,
-
-    VAL_CLIENT_IP,
-    VAL_ISO_ILL_1,
-    VAL_ZBIG,
-    VAL_UTIL,
-    VAL_XD1,
-
-/* 90 */
-    VAL_ZTHES,
-    VAL_FIN1,
-    VAL_DAN1,
-    VAL_DIAG_ES,
-    VAL_DIAG_GENERAL,
-
-    VAL_JPMARC,
-    VAL_SWEMARC,
-    VAL_SIGLEMARC,
-    VAL_ISDSMARC,
-    VAL_RUSMARC,
-
-/* 100 */
-    VAL_ADMINSERVICE,
-    VAL_HOLDINGS,
-    VAL_HUNMARC,
-    VAL_CHARNEG3,
-    VAL_LIB1,
-
-    VAL_VIRT,
-    VAL_UCS2,
-    VAL_UCS4,
-    VAL_UTF16,
-    VAL_UTF8,
-/* 110 */
-
-    VAL_IDXPATH,
-    VAL_BIB2,
-    VAL_ZEEREX,
-    VAL_CQL,
-    VAL_DBUPDATE1,
-
-    VAL_OCLCUI,
-    VAL_ID_CHARSET,
-    VAL_EXTLITE,
-    VAL_NACSISCATP,
-    VAL_FINMARC2000,
-/* 120 */
-
-    VAL_MARC21FIN,
-    VAL_CHARNEG4,
-    VAL_XMLES,
-
-/* VAL_DYNAMIC must have highest value */
-    VAL_DYNAMIC,
-    VAL_MAX = VAL_DYNAMIC+30
-} oid_value;
-
-typedef struct oident
-{
-    oid_proto proto;
-    oid_class oclass;
-    oid_value value;
-    int oidsuffix[OID_SIZE];
-    char *desc;
-} oident;
-
-YAZ_EXPORT int *oid_getoidbyent(struct oident *ent);
-YAZ_EXPORT int *oid_ent_to_oid(struct oident *ent, int *dst);
-YAZ_EXPORT struct oident *oid_getentbyoid(int *o);
-YAZ_EXPORT void oid_oidcpy(int *t, int *s);
-YAZ_EXPORT void oid_oidcat(int *t, int *s);
-YAZ_EXPORT int oid_oidcmp(int *o1, int *o2);
-YAZ_EXPORT int oid_oidlen(int *o);
-YAZ_EXPORT oid_value oid_getvalbyname(const char *name);
-YAZ_EXPORT void oid_setprivateoids(oident *list);
-YAZ_EXPORT struct oident *oid_addent (int *oid, enum oid_proto proto,
-                                      enum oid_class oclass,
-                                      const char *desc, int value);
-
-YAZ_EXPORT void oid_trav (void (*func)(struct oident *oidinfo, void *vp),
-                          void *vp);
-
-YAZ_EXPORT void oid_init(void);
-YAZ_EXPORT void oid_exit(void);
-YAZ_EXPORT int *oid_name_to_oid(oid_class oclass, const char *name, int *oid);
-YAZ_EXPORT char *oid_to_dotstring(const int *oid, char *oidbuf);
-YAZ_EXPORT char *oid_name_to_dotstring(oid_class oclass, const char *name,
-                                       char *oidbuf);
-
-YAZ_END_CDECL
-
-#endif
-/*
- * Local variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- * vim: shiftwidth=4 tabstop=8 expandtab
- */
-
diff --git a/include/yaz/oid_db.h b/include/yaz/oid_db.h
new file mode 100644 (file)
index 0000000..094a1f4
--- /dev/null
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 1995-2007, Index Data
+ * All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of Index Data nor the names of its contributors
+ *       may be used to endorse or promote products derived from this
+ *       software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/* $Id: oid_db.h,v 1.1 2007-04-12 13:52:57 adam Exp $ */
+
+/**
+ * \file oid_db.h
+ * \brief Header for OID database
+ */
+#ifndef OID_DB_H
+#define OID_DB_H
+
+#include <yaz/yconfig.h>
+#include <yaz/oid_util.h>
+#include <yaz/odr.h>
+
+YAZ_BEGIN_CDECL
+
+/** \brief OID database */
+typedef struct yaz_oid_entry *yaz_oid_db_t;
+
+/** \brief returns standard OID database 
+    \retval OID database handle
+*/
+YAZ_EXPORT
+yaz_oid_db_t yaz_oid_std(void);
+
+/** \brief maps named OID string to raw OID by database lookup
+    \param oid_db OID database
+    \param oclass class of string (enum oid_class) 
+    \param name OID name
+    \returns raw OID or NULL if name is unknown (bad)
+
+    This function only maps known names in the database provided.
+    Use yaz_string_to_oid_nmem or yaz_string_to_oid_odr to map
+    any named OID in dot-notation (1.2.8).
+*/
+YAZ_EXPORT
+const int *yaz_string_to_oid(yaz_oid_db_t oid_db,
+                             int oclass, const char *name);
+
+
+/** \brief creates NMEM malloc'ed OID from string
+    \param oid_db OID database
+    \param oclass class of string (enum oid_class) 
+    \param name OID name
+    \param nmem memory for returned OID
+    \returns raw OID or NULL if name is unknown (bad)
+*/
+YAZ_EXPORT
+int *yaz_string_to_oid_nmem(yaz_oid_db_t oid_db,
+                            int oclass, const char *name, NMEM nmem);
+
+/** \brief creates ODR malloc'ed OID from string
+    \param oid_db OID database
+    \param oclass class of string (enum oid_class) 
+    \param name OID name
+    \param odr memory for returned OID
+    \returns raw OID or NULL if name is unknown (bad)
+*/
+YAZ_EXPORT
+int *yaz_string_to_oid_odr(yaz_oid_db_t oid_db,
+                           int oclass, const char *name, ODR odr);
+
+/** \brief maps raw OID to string
+    \param oid_db OID database
+    \param oid raw OID
+    \param oclass holds OID class if found (output parameter)
+    \returns OID name or NULL if not found in database
+*/
+YAZ_EXPORT
+const char *yaz_oid_to_string(yaz_oid_db_t oid_db,
+                              const int *oid, int *oclass);
+
+
+/** \brief maps any OID to string (named or dot-notation)
+    \param oid raw OID
+    \param oclass holds OID class if found (output parameter)
+    \param buf string buffer for result (must be of size OID_STR_MAX)
+    \returns OID string (named or dot notatition) 
+*/
+YAZ_EXPORT
+const char *yaz_oid_to_string_buf(const int *oid, int *oclass, char *buf);
+
+/** \brief traverses OIDs in a database
+    \param oid_db OID database
+    \param func function to be called for each OID
+    \param client_data data to be passed to func (custom defined)
+*/
+YAZ_EXPORT void yaz_oid_trav(yaz_oid_db_t oid_db,
+                             void (*func)(const int *oid,
+                                          int oclass, const char *name,
+                                          void *client_data),
+                             void *client_data);
+
+/** \brief checks if OID refers to MARC transfer syntax
+    \param oid raw OID
+    \retval 1 OID is a MARC type
+    \retval 0 OID is not a MARC type
+*/
+YAZ_EXPORT
+int yaz_oid_is_iso2709(const int *oid);
+
+#define OID_STR_BIB1 "Bib-1"
+#define OID_STR_DIAG1 "Diag-1"
+#define OID_STR_USMARC "USmarc"
+#define OID_STR_XML "XML"
+#define OID_STR_SOIF "SOIF"
+#define OID_STR_APPLICATION_XML "application-XML"
+#define OID_STR_HTML "html"
+#define OID_STR_GRS1 "GRS-1"
+#define OID_STR_POSTSCRIPT "postscript"
+#define OID_STR_SUTRS "SUTRS"
+#define OID_STR_OPAC "OPAC"
+#define OID_STR_EXPLAIN "Explain"
+#define OID_STR_SUMMARY "Summary"
+#define OID_STR_EXTENDED "Extended"
+#define OID_STR_COOKIE "Cookie" 
+#define OID_STR_PROXY "Proxy" 
+#define OID_STR_CLIENT_IP "Client-IP"
+#define OID_STR_ILL_1 "ISOILL-1"
+#define OID_STR_ADMIN "Admin"
+#define OID_STR_XMLES "XML-ES"
+#define OID_STR_EXT_UPDATE "DB. Update"
+#define OID_STR_ITEMORDER "Item order"
+#define OID_STR_USERINFO_1 "UserInfo-1"
+#define OID_STR_ID_CHARSET "ID-Charset"
+#define OID_STR_CHARNEG_3 "CharSetandLanguageNegotiation-3"
+#define OID_STR_CHARNEG_4 "CharSetandLanguageNegotiation-4"
+
+YAZ_END_CDECL
+
+#endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
diff --git a/include/yaz/oid_util.h b/include/yaz/oid_util.h
new file mode 100644 (file)
index 0000000..d0b85b6
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 1995-2007, Index Data
+ * All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of Index Data nor the names of its contributors
+ *       may be used to endorse or promote products derived from this
+ *       software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/* $Id: oid_util.h,v 1.1 2007-04-12 13:52:57 adam Exp $ */
+
+/**
+ * \file oid_util.h
+ * \brief Header for OID database
+ *
+ * More or less protocol-transparent OID database.
+ * We could (and should?) extend this so that the user app can add new
+ * entries to the list at initialization.
+ */
+#ifndef OID_UTIL_H
+#define OID_UTIL_H
+
+#include <yaz/yconfig.h>
+
+YAZ_BEGIN_CDECL
+
+#define OID_SIZE 20
+#define OID_STR_MAX 256
+
+typedef enum oid_proto
+{
+    PROTO_NOP=0,
+    PROTO_Z3950,
+    PROTO_SR,
+    PROTO_GENERAL,
+    PROTO_WAIS,
+    PROTO_HTTP
+} oid_proto;
+
+typedef enum oid_class
+{
+    CLASS_NOP=0,
+    CLASS_APPCTX,
+    CLASS_ABSYN,
+    CLASS_ATTSET,
+    CLASS_TRANSYN,
+    CLASS_DIAGSET,
+    CLASS_RECSYN,
+    CLASS_RESFORM,
+    CLASS_ACCFORM,
+    CLASS_EXTSERV,
+    CLASS_USERINFO,
+    CLASS_ELEMSPEC,
+    CLASS_VARSET,
+    CLASS_SCHEMA,
+    CLASS_TAGSET,
+    CLASS_GENERAL,
+    CLASS_NEGOT
+} oid_class;
+    
+YAZ_EXPORT void oid_oidcpy(int *t, const int *s);
+YAZ_EXPORT void oid_oidcat(int *t, const int *s);
+YAZ_EXPORT int oid_oidcmp(const int *o1, const int *o2);
+YAZ_EXPORT int oid_oidlen(const int *o);
+YAZ_EXPORT char *oid_to_dotstring(const int *oid, char *oidbuf);
+YAZ_END_CDECL
+
+#endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 045ff6c..7a4c1ab 100644 (file)
@@ -24,7 +24,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-/* $Id: otherinfo.h,v 1.8 2007-01-03 08:42:14 adam Exp $ */
+/* $Id: otherinfo.h,v 1.9 2007-04-12 13:52:57 adam Exp $ */
 
 /**
  * \file otherinfo.h
@@ -40,21 +40,26 @@ YAZ_BEGIN_CDECL
 YAZ_EXPORT void yaz_oi_APDU(Z_APDU *apdu, Z_OtherInformation ***oip);
 YAZ_EXPORT    Z_OtherInformationUnit *yaz_oi_update (
     Z_OtherInformation **otherInformationP, ODR odr,
-    int *oid, int categoryValue, int delete_flag);
+    const int *oid, int categoryValue, int delete_flag);
 YAZ_EXPORT void yaz_oi_set_string_oid (
     Z_OtherInformation **otherInformation, ODR odr,
-    int *oid, int categoryValue,
+    const int *oid, int categoryValue,
     const char *str);
+#ifndef NO_OID
 YAZ_EXPORT void yaz_oi_set_string_oidval (
     Z_OtherInformation **otherInformation, ODR odr,
     int oidval, int categoryValue,
     const char *str);
+#endif
+
 YAZ_EXPORT char *yaz_oi_get_string_oid (
     Z_OtherInformation **otherInformation,
-    int *oid, int categoryValue, int delete_flag);
+    const int *oid, int categoryValue, int delete_flag);
+#ifndef NO_OID
 YAZ_EXPORT char *yaz_oi_get_string_oidval(
     Z_OtherInformation **otherInformation,
     int oidval, int categoryValue, int delete_flag);
+#endif
 
 YAZ_END_CDECL
 
index bc480c7..066b560 100644 (file)
@@ -24,7 +24,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-/* $Id: pquery.h,v 1.10 2007-01-03 08:42:14 adam Exp $ */
+/* $Id: pquery.h,v 1.11 2007-04-12 13:52:57 adam Exp $ */
 
 /**
  * \file pquery.h
@@ -41,21 +41,19 @@ YAZ_BEGIN_CDECL
 
 typedef struct yaz_pqf_parser *YAZ_PQF_Parser;
 
-YAZ_EXPORT Z_RPNQuery *p_query_rpn (ODR o, oid_proto proto, const char *qbuf);
+YAZ_EXPORT Z_RPNQuery *p_query_rpn(ODR o, const char *qbuf);
 
-YAZ_EXPORT Z_AttributesPlusTerm *p_query_scan (ODR o, oid_proto proto,
-           Odr_oid **attributeSetP, const char *qbuf);
-YAZ_EXPORT int p_query_attset (const char *arg);
+YAZ_EXPORT Z_AttributesPlusTerm *p_query_scan(ODR o, oid_proto proto,
+                                              Odr_oid **attributeSetP, const char *qbuf);
+YAZ_EXPORT YAZ_PQF_Parser yaz_pqf_create(void);
+YAZ_EXPORT Z_RPNQuery *yaz_pqf_parse(YAZ_PQF_Parser p, ODR o,
+                                     const char *qbuf);
+YAZ_EXPORT Z_AttributesPlusTerm *yaz_pqf_scan(YAZ_PQF_Parser p, ODR o,
+                                              Odr_oid **attributeSetId,
+                                              const char *qbuf);
+YAZ_EXPORT void yaz_pqf_destroy(YAZ_PQF_Parser p);
 
-YAZ_EXPORT YAZ_PQF_Parser yaz_pqf_create (void);
-YAZ_EXPORT Z_RPNQuery *yaz_pqf_parse (YAZ_PQF_Parser p, ODR o,
-                                      const char *qbuf);
-YAZ_EXPORT Z_AttributesPlusTerm *yaz_pqf_scan (YAZ_PQF_Parser p, ODR o,
-                                               Odr_oid **attributeSetId,
-                                               const char *qbuf);
-YAZ_EXPORT void yaz_pqf_destroy (YAZ_PQF_Parser p);
-
-YAZ_EXPORT int yaz_pqf_error (YAZ_PQF_Parser p, const char **msg, size_t *off);
+YAZ_EXPORT int yaz_pqf_error(YAZ_PQF_Parser p, const char **msg, size_t *off);
 
 
 /* no error */
index f10dd6c..f928e79 100644 (file)
@@ -24,7 +24,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-/* $Id: proto.h,v 1.26 2007-01-03 08:42:14 adam Exp $ */
+/* $Id: proto.h,v 1.27 2007-04-12 13:52:57 adam Exp $ */
 
 /**
  * \file proto.h
@@ -65,7 +65,6 @@
 #include <yaz/zes-update0.h>
 #include <yaz/z-charneg.h>
 #include <yaz/z-mterm2.h>
-#include <yaz/oid.h>
 #include <yaz/wrbuf.h>
 #include <yaz/zgdu.h>
 #include <yaz/z-oclcui.h>
@@ -130,13 +129,6 @@ typedef struct Z_IOItemOrder Z_ItemOrder;
 
 YAZ_EXPORT Z_APDU *zget_APDU(ODR o, int which);
 YAZ_EXPORT Z_Close *zget_Close (ODR o);
-YAZ_EXPORT Odr_oid *yaz_oidval_to_z3950oid (ODR o, int oid_class,
-                                            int oid_value);
-YAZ_EXPORT Odr_oid *yaz_str_to_z3950oid (ODR o, int oid_class,
-                                         const char *str);
-YAZ_EXPORT const char *yaz_z3950oid_to_str (Odr_oid *oid, int *oid_class);
-
-YAZ_EXPORT const char* yaz_z3950_oid_value_to_str(oid_value ov, oid_class oc);
 
 /** \brief Performs "pretty" display of GRS-1 record to WRBUF */
 YAZ_EXPORT void yaz_display_grs1(WRBUF wrbuf, Z_GenericRecord *r, int flags);
index 526b4af..daa5820 100644 (file)
@@ -24,7 +24,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-/* $Id: prt-ext.h,v 1.15 2007-01-03 08:42:14 adam Exp $ */
+/* $Id: prt-ext.h,v 1.16 2007-04-12 13:52:57 adam Exp $ */
 
 /**
  * \file prt-ext.h
@@ -39,7 +39,7 @@
 #define PRT_EXT_H
 
 #include <yaz/yconfig.h>
-#include <yaz/oid.h>
+#include <yaz/oid_util.h>
 
 
 YAZ_BEGIN_CDECL
@@ -50,7 +50,11 @@ YAZ_BEGIN_CDECL
  */
 typedef struct Z_ext_typeent
 {
+#if 0
     oid_value dref;    /* the direct-reference OID value. */
+#else
+    int oid[OID_SIZE]; /* the direct-reference OID */
+#endif
     int what;          /* discriminator value for the external CHOICE */
     Odr_fun fun;       /* decoder function */
 } Z_ext_typeent;
@@ -139,11 +143,10 @@ struct Z_External
 /** \brief codec for BER EXTERNAL */
 YAZ_EXPORT int z_External(ODR o, Z_External **p, int opt, const char *name);
 /** \brief returns type information for OID (NULL if not known) */
-YAZ_EXPORT Z_ext_typeent *z_ext_getentbyref(oid_value val);
+YAZ_EXPORT Z_ext_typeent *z_ext_getentbyref(const int *oid);
 /** \brief encodes EXTERNAL record based on OID (NULL if knot known) */
-YAZ_EXPORT Z_External *z_ext_record(ODR o, int format, const char *buf,
-                                    int len);
-
+YAZ_EXPORT Z_External *z_ext_record_oid(ODR o, const int *oid,
+                                        const char *buf, int len);
 YAZ_END_CDECL
 
 #endif
index 758d0ea..572ba09 100644 (file)
@@ -24,9 +24,9 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-/* $Id: query-charset.h,v 1.1 2007-04-10 14:42:31 adam Exp $ */
+/* $Id: query-charset.h,v 1.2 2007-04-12 13:52:57 adam Exp $ */
 /**
- * \file querytowrbuf.h
+ * \file query-charset.h
  * \brief Query to WRBUF (to strings)
  */
 
index bca4c4e..4d80c61 100644 (file)
@@ -24,7 +24,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-/* $Id: querytowrbuf.h,v 1.5 2007-03-19 21:07:35 adam Exp $ */
+/* $Id: querytowrbuf.h,v 1.6 2007-04-12 13:52:57 adam Exp $ */
 /**
  * \file querytowrbuf.h
  * \brief Query to WRBUF (to strings)
@@ -41,7 +41,7 @@ YAZ_BEGIN_CDECL
 
 YAZ_EXPORT void yaz_query_to_wrbuf(WRBUF b, const Z_Query *q);
 YAZ_EXPORT void yaz_scan_to_wrbuf(WRBUF b, const Z_AttributesPlusTerm *zapt,
-                                  oid_value ast);
+                                  const int *attribute_set);
 YAZ_EXPORT void yaz_rpnquery_to_wrbuf(WRBUF b, const Z_RPNQuery *rpn);
 YAZ_EXPORT void wrbuf_diags(WRBUF b, int num_diagnostics,Z_DiagRec **diags);
 
index 224ef82..0208450 100644 (file)
@@ -24,7 +24,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-/* $Id: tcpip.h,v 1.11 2007-01-03 08:42:14 adam Exp $ */
+/* $Id: tcpip.h,v 1.12 2007-04-12 13:52:57 adam Exp $ */
 
 /**
  * \file tcpip.h
@@ -35,7 +35,6 @@
 #define TCPIP_H
 
 #include <yaz/comstack.h>
-#include <yaz/oid.h>
 
 YAZ_BEGIN_CDECL
 
index ac420ec..8c60ac8 100644 (file)
@@ -24,7 +24,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-/* $Id: unix.h,v 1.8 2007-01-03 08:42:14 adam Exp $ */
+/* $Id: unix.h,v 1.9 2007-04-12 13:52:57 adam Exp $ */
 
 /**
  * \file unix.h
@@ -37,7 +37,6 @@
 #ifndef WIN32
 
 #include <yaz/comstack.h>
-#include <yaz/oid.h>
 
 YAZ_BEGIN_CDECL
 
index 48ed65f..58f7aac 100644 (file)
@@ -1,6 +1,6 @@
 ## This file is part of the YAZ toolkit.
 ## Copyright (C) 1995-2007, Index Data, All rights reserved.
-## $Id: Makefile.am,v 1.55 2007-03-21 19:47:28 adam Exp $
+## $Id: Makefile.am,v 1.56 2007-04-12 13:52:57 adam Exp $
 
 YAZ_VERSION_INFO=3:0:0
 
@@ -50,7 +50,7 @@ diagsru_update.c $(top_srcdir)/include/yaz/diagsru_update.h: csvtosru_update.tcl
 
 libyaz_la_SOURCES=version.c options.c log.c \
   marcdisp.c marc_read_xml.c marc_read_iso2709.c marc_read_line.c \
-  oid.c wrbuf.c \
+  wrbuf.c oid_db.c \
   nmemsdup.c xmalloc.c readconf.c tpath.c nmem.c matchstr.c atoin.c \
   siconv.c marc8.c marc8r.c \
   odr_bool.c ber_bool.c ber_len.c ber_tag.c odr_util.c \
@@ -69,7 +69,7 @@ libyaz_la_SOURCES=version.c options.c log.c \
   ill-core.c item-req.c ill-get.c \
   zget.c yaz-ccl.c diag-entry.c diag-entry.h diagbib1.c diagsrw.c \
   diagsru_update.c logrpn.c \
-  otherinfo.c pquery.c sortspec.c z3950oid.c charneg.c initopt.c \
+  otherinfo.c pquery.c sortspec.c charneg.c initopt.c \
   zoom-c.c zoom-socket.c zoom-opt.c zoom-p.h \
   grs1disp.c zgdu.c soap.c srw.c srwutil.c \
   opacdisp.c cclfind.c ccltoken.c cclerrms.c cclqual.c cclptree.c \
@@ -79,7 +79,7 @@ libyaz_la_SOURCES=version.c options.c log.c \
   eventl.c seshigh.c statserv.c requestq.c tcpdchk.c \
   eventl.h service.c service.h session.h test.c timing.c \
   xmlquery.c http.c \
-  mime.c mime.h \
+  mime.c mime.h oid_util.c \
   record_conv.c retrieval.c elementset.c snprintf.c query-charset.c
 
 libyaz_la_LDFLAGS=-version-info $(YAZ_VERSION_INFO)
index 51a4b25..d6a2398 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: charneg.c,v 1.7 2007-01-03 08:42:15 adam Exp $
+ * $Id: charneg.c,v 1.8 2007-04-12 13:52:57 adam Exp $
  */
 
 /** 
 #include <yaz/z-charneg.h>
 #include <yaz/charneg.h>
 #include <yaz/yaz-util.h>
+#include <yaz/oid_db.h>
 
-static Z_External* z_ext_record2(ODR o, int oid_class, int oid_value,
-                                 const char *buf)
+static Z_External* z_ext_record2(ODR o, const char *buf)
 {
     Z_External *p;
-    oident oid;
     int len = strlen(buf);
     
     if (!(p = (Z_External *)odr_malloc(o, sizeof(*p)))) return 0;
@@ -29,10 +28,10 @@ static Z_External* z_ext_record2(ODR o, int oid_class, int oid_value,
     p->descriptor = 0;
     p->indirect_reference = 0;
     
-    oid.proto = PROTO_Z3950;
-    oid.oclass = (enum oid_class) oid_class;
-    oid.value = (enum oid_value) oid_value;
-    p->direct_reference = odr_oiddup(o, oid_getoidbyent(&oid));
+    p->direct_reference = yaz_string_to_oid_odr(yaz_oid_std(),
+                                                CLASS_NEGOT,
+                                                OID_STR_ID_CHARSET,
+                                                o);
     
     p->which = Z_External_octet;
     if (!(p->u.octet_aligned = (Odr_oct *)odr_malloc(o, sizeof(Odr_oct)))) {
@@ -110,8 +109,7 @@ static Z_OriginProposal_0 *z_get_OriginProposal_0(ODR o, const char *charset)
         p0->u.zprivate = pc;
         
         pc->which = Z_PrivateCharacterSet_externallySpecified;
-        pc->u.externallySpecified =
-            z_ext_record2(o, CLASS_NEGOT, VAL_ID_CHARSET, charset);
+        pc->u.externallySpecified = z_ext_record2(o, charset);
     }
     return p0;
 }
@@ -173,15 +171,14 @@ Z_External *yaz_set_proposal_charneg(ODR o,
                                      int selected)
 {
     Z_External *p = (Z_External *)odr_malloc(o, sizeof(*p));
-    oident oid;
         
     p->descriptor = 0;
     p->indirect_reference = 0;  
 
-    oid.proto = PROTO_Z3950;
-    oid.oclass = CLASS_NEGOT;
-    oid.value = VAL_CHARNEG3;
-    p->direct_reference = odr_oiddup(o, oid_getoidbyent(&oid));
+    p->direct_reference = yaz_string_to_oid_odr(yaz_oid_std(),
+                                                CLASS_NEGOT,
+                                                OID_STR_CHARNEG_3,
+                                                o);
 
     p->which = Z_External_charSetandLanguageNegotiation;
     p->u.charNeg3 = z_get_CharSetandLanguageNegotiation(o);
@@ -205,10 +202,10 @@ Z_External *yaz_set_proposal_charneg_list(ODR o,
     int langs_count = 0;
     
     if (charset_list)
-        nmem_strsplit(o->mem, delim, charset_list,
+        nmem_strsplit(odr_getmem(o), delim, charset_list,
                       &charsets_addresses, &charsets_count);
     if (lang_list)
-        nmem_strsplit(o->mem, delim, lang_list,
+        nmem_strsplit(odr_getmem(o), delim, lang_list,
                       &langs_addresses, &langs_count);    
     return yaz_set_proposal_charneg(o,
                                     (const char **) charsets_addresses,
@@ -251,7 +248,7 @@ static Z_TargetResponse *z_get_TargetResponse(ODR o, const char *charset,
         
         pc->which = Z_PrivateCharacterSet_externallySpecified;
         pc->u.externallySpecified =
-            z_ext_record2(o, CLASS_NEGOT, VAL_ID_CHARSET, charset);
+            z_ext_record2(o, charset);
     }
     p->recordsInSelectedCharSets = (bool_t *)odr_malloc(o, sizeof(bool_t));
     *p->recordsInSelectedCharSets = (selected) ? 1:0;
@@ -265,15 +262,14 @@ Z_External *yaz_set_response_charneg(ODR o, const char *charset,
                                      const char *lang, int selected)
 {
     Z_External *p = (Z_External *)odr_malloc(o, sizeof(*p));
-    oident oid;
         
     p->descriptor = 0;
     p->indirect_reference = 0;  
 
-    oid.proto = PROTO_Z3950;
-    oid.oclass = CLASS_NEGOT;
-    oid.value = VAL_CHARNEG3;
-    p->direct_reference = odr_oiddup(o, oid_getoidbyent(&oid));
+    p->direct_reference = yaz_string_to_oid_odr(yaz_oid_std(),
+                                                CLASS_NEGOT,
+                                                OID_STR_CHARNEG_3,
+                                                o);
 
     p->which = Z_External_charSetandLanguageNegotiation;
     p->u.charNeg3 = z_get_CharSetandLanguageNegotiation(o);
@@ -295,12 +291,15 @@ Z_CharSetandLanguageNegotiation *yaz_get_charneg_record(Z_OtherInformation *p)
         Z_External *pext;
         if ((p->list[i]->which == Z_OtherInfo_externallyDefinedInfo) &&
             (pext = p->list[i]->information.externallyDefinedInfo)) {
-            
-            oident *ent = oid_getentbyoid(pext->direct_reference);
-            
-            if (ent && ent->value == VAL_CHARNEG3 
-                && ent->oclass == CLASS_NEGOT
-                &&  pext->which == Z_External_charSetandLanguageNegotiation)
+
+            int oclass;
+            const char *name = yaz_oid_to_string(yaz_oid_std(),
+                                                 pext->direct_reference,
+                                                 &oclass);
+
+            if (oclass == CLASS_NEGOT 
+                && name && !strcmp(name, OID_STR_CHARNEG_3) 
+                && pext->which == Z_External_charSetandLanguageNegotiation)
             {
                 return pext->u.charNeg3;
             }
@@ -320,19 +319,22 @@ int yaz_del_charneg_record(Z_OtherInformation **p)
     for (i = 0; i < (*p)->num_elements; i++) {
         Z_External *pext;
         if (((*p)->list[i]->which == Z_OtherInfo_externallyDefinedInfo) &&
-            (pext = (*p)->list[i]->information.externallyDefinedInfo)) {
-            
-            oident *ent = oid_getentbyoid(pext->direct_reference);
-            
-            if (ent && ent->value == VAL_CHARNEG3 
-                && ent->oclass == CLASS_NEGOT
+            (pext = (*p)->list[i]->information.externallyDefinedInfo))
+        {
+            int oclass;
+            const char *name = yaz_oid_to_string(yaz_oid_std(),
+                                                 pext->direct_reference,
+                                                 &oclass);
+
+            if (oclass == CLASS_NEGOT 
+                && name && !strcmp(name, OID_STR_CHARNEG_3) 
                 && pext->which == Z_External_charSetandLanguageNegotiation)
             {
-                --((*p)->num_elements);
-                if ((*p)->num_elements == 0)
+                if ((*p)->num_elements <= 1)
                     *p = 0;
                 else
                 {
+                    --((*p)->num_elements);
                     for(; i < (*p)->num_elements; i++)
                         (*p)->list[i] = (*p)->list[i+1];
                 }
index ddf2928..43a5fa5 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: grs1disp.c,v 1.6 2007-03-12 16:16:49 adam Exp $
+ * $Id: grs1disp.c,v 1.7 2007-04-12 13:52:57 adam Exp $
  */
 
 /**
@@ -16,6 +16,7 @@
 #include <ctype.h>
 
 #include <yaz/proto.h>
+#include <yaz/oid_db.h>
 
 static void display_variant(WRBUF w, Z_Variant *v, int level)
 {
@@ -77,16 +78,16 @@ static void display_grs1(WRBUF w, Z_GenericRecord *r, int level)
         else if (t->content->which == Z_ElementData_oid)
         {
             int *ip = t->content->u.oid;
-            oident *oent;
-            
-            if ((oent = oid_getentbyoid(t->content->u.oid)))
-                wrbuf_printf(w, "OID: %s\n", oent->desc);
-            else
+
+            if (ip)
             {
-                wrbuf_printf(w, "{");
-                while (ip && *ip >= 0)
-                    wrbuf_printf(w, " %d", *(ip++));
-                wrbuf_printf(w, " }\n");
+                char oid_name_str[OID_STR_MAX];
+                int oclass;
+                const char *oid_name 
+                    = yaz_oid_to_string_buf(ip, &oclass, oid_name_str);
+            
+                if (oid_name)
+                    wrbuf_printf(w, "OID: %s\n", oid_name);
             }
         }
         else if (t->content->which == Z_ElementData_noDataRequested)
index 14bca6d..fa9a2ea 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * All rights reserved.
  *
- * $Id: logrpn.c,v 1.15 2007-01-03 08:42:15 adam Exp $
+ * $Id: logrpn.c,v 1.16 2007-04-12 13:52:57 adam Exp $
  */
 
 /**
@@ -15,6 +15,7 @@
 
 #include <yaz/log.h>
 #include <yaz/logrpn.h>
+#include <yaz/oid_db.h>
 
 static const char *relToStr(int v)
 {
@@ -35,148 +36,139 @@ static const char *relToStr(int v)
     return str;
 }
 
-static void attrStr (int type, int value, enum oid_value ast, char *str)
+static void attrStr (int type, int value, char *str)
 {
     const char *rstr;
     *str = '\0';
-    switch (ast)
+    switch (type)
     {
-    case VAL_BIB1:
-    case VAL_EXP1:
-    case VAL_GILS:
-        switch (type)
+    case 1:
+        sprintf (str, "use");
+        break;
+    case 2:
+        rstr = relToStr(value);
+        if (rstr)
+            sprintf(str, "relation=%s", rstr);
+        else
+            sprintf(str, "relation=%d", value);
+        break;
+    case 3:
+        switch (value)
         {
         case 1:
-            sprintf (str, "use");
+            sprintf(str, "position=First in field");
             break;
         case 2:
-            rstr = relToStr(value);
-            if (rstr)
-                sprintf(str, "relation=%s", rstr);
-            else
-                sprintf(str, "relation=%d", value);
+            sprintf(str, "position=First in any subfield");
             break;
         case 3:
-            switch (value)
-            {
-            case 1:
-                sprintf(str, "position=First in field");
-                break;
-            case 2:
-                sprintf(str, "position=First in any subfield");
-                break;
-            case 3:
-                sprintf(str, "position=Any position in field");
-                break;
-            default:
-                sprintf(str, "position");
-            }
+            sprintf(str, "position=Any position in field");
+            break;
+        default:
+            sprintf(str, "position");
+        }
+        break;
+    case 4:
+        switch (value)
+        {
+        case 1:
+            sprintf(str, "structure=Phrase");
+            break;
+        case 2:
+            sprintf(str, "structure=Word");
+            break;
+        case 3:
+            sprintf(str, "structure=Key");
             break;
         case 4:
-            switch (value)
-            {
-            case 1:
-                sprintf(str, "structure=Phrase");
-                break;
-            case 2:
-                sprintf(str, "structure=Word");
-                break;
-            case 3:
-                sprintf(str, "structure=Key");
-                break;
-            case 4:
-                sprintf(str, "structure=Year");
-                break;
-            case 5:
-                sprintf(str, "structure=Date");
-                break;
-            case 6:
-                sprintf(str, "structure=Word list");
-                break;
-            case 100:
-                sprintf(str, "structure=Date (un)");
-                break;
-            case 101:
-                sprintf(str, "structure=Name (norm)");
-                break;
-            case 102:
-                sprintf(str, "structure=Name (un)");
-                break;
-            case 103:
-                sprintf(str, "structure=Structure");
-                break;
-            case 104:
-                sprintf(str, "structure=urx");
-                break;
-            case 105:
-                sprintf(str, "structure=free-form-text");
-                break;
-            case 106:
-                sprintf(str, "structure=document-text");
-                break;
-            case 107:
-                sprintf(str, "structure=local-number");
-                break;
-            case 108:
-                sprintf(str, "structure=string");
-                break;
-            case 109:
-                sprintf(str, "structure=numeric string");
-                break;
-            default:
-                sprintf(str, "structure");
-            }
+            sprintf(str, "structure=Year");
             break;
         case 5:
-            switch (value)
-            {
-            case 1:
-                sprintf(str, "truncation=Right");
-                break;
-            case 2:
-                sprintf(str, "truncation=Left");
-                break;
-            case 3:
-                sprintf(str, "truncation=Left&right");
-                break;
-            case 100:
-                sprintf(str, "truncation=Do not truncate");
-                break;
-            case 101:
-                sprintf(str, "truncation=Process #");
-                break;
-            case 102:
-                sprintf(str, "truncation=re-1");
-                break;
-            case 103:
-                sprintf(str, "truncation=re-2");
-                break;
-            case 104:
-                sprintf(str, "truncation=CCL");
-                break;
-            default:
-                sprintf(str, "truncation");
-            }
+            sprintf(str, "structure=Date");
             break;
         case 6:
-            switch(value)
-            {
-            case 1:
-                sprintf(str, "completeness=Incomplete subfield");
-                break;
-            case 2:
-                sprintf(str, "completeness=Complete subfield");
-                break;
-            case 3:
-                sprintf(str, "completeness=Complete field");
-                break;
-            default:
-                sprintf(str, "completeness");
-            }
+            sprintf(str, "structure=Word list");
+            break;
+        case 100:
+            sprintf(str, "structure=Date (un)");
+            break;
+        case 101:
+            sprintf(str, "structure=Name (norm)");
+            break;
+        case 102:
+            sprintf(str, "structure=Name (un)");
+            break;
+        case 103:
+            sprintf(str, "structure=Structure");
+            break;
+        case 104:
+            sprintf(str, "structure=urx");
+            break;
+        case 105:
+            sprintf(str, "structure=free-form-text");
             break;
+        case 106:
+            sprintf(str, "structure=document-text");
+            break;
+        case 107:
+            sprintf(str, "structure=local-number");
+            break;
+        case 108:
+            sprintf(str, "structure=string");
+            break;
+        case 109:
+            sprintf(str, "structure=numeric string");
+            break;
+        default:
+            sprintf(str, "structure");
         }
         break;
-    default:
+    case 5:
+        switch (value)
+        {
+        case 1:
+            sprintf(str, "truncation=Right");
+            break;
+        case 2:
+            sprintf(str, "truncation=Left");
+            break;
+        case 3:
+            sprintf(str, "truncation=Left&right");
+            break;
+        case 100:
+            sprintf(str, "truncation=Do not truncate");
+            break;
+        case 101:
+            sprintf(str, "truncation=Process #");
+            break;
+        case 102:
+            sprintf(str, "truncation=re-1");
+            break;
+        case 103:
+            sprintf(str, "truncation=re-2");
+            break;
+        case 104:
+            sprintf(str, "truncation=CCL");
+            break;
+        default:
+            sprintf(str, "truncation");
+        }
+        break;
+    case 6:
+        switch(value)
+        {
+        case 1:
+            sprintf(str, "completeness=Incomplete subfield");
+            break;
+        case 2:
+            sprintf(str, "completeness=Complete subfield");
+            break;
+        case 3:
+            sprintf(str, "completeness=Complete field");
+            break;
+        default:
+            sprintf(str, "completeness");
+        }
         break;
     }
     if (*str)
@@ -188,8 +180,8 @@ static void attrStr (int type, int value, enum oid_value ast, char *str)
 /*
  * zlog_attributes: print attributes of term
  */
-static void zlog_attributes (Z_AttributesPlusTerm *t, int depth,
-                             enum oid_value ast, int loglevel)
+static void zlog_attributes(Z_AttributesPlusTerm *t, int depth,
+                            const int *ast, int loglevel)
 {
     int of, i;
     char str[80];
@@ -197,20 +189,22 @@ static void zlog_attributes (Z_AttributesPlusTerm *t, int depth,
     
     for (of = 0; of < num_attributes; of++)
     {
-        const char *attset_name = "";
+        char attset_name_buf[OID_STR_MAX];
+        const char *attset_name = 0;
         Z_AttributeElement *element;
         element = t->attributes->attributes[of];
         if (element->attributeSet)
         {
-            oident *attrset;
-            attrset = oid_getentbyoid (element->attributeSet);
-            attset_name = attrset->desc;
+            attset_name = yaz_oid_to_string_buf(element->attributeSet,
+                                                0, attset_name_buf);
         }
+        if (!attset_name)
+            attset_name = "";
         switch (element->which) 
         {
         case Z_AttributeValue_numeric:
             attrStr (*element->attributeType,
-                     *element->value.numeric, ast, str);
+                     *element->value.numeric, str);
             yaz_log (loglevel, "%*.0s%s %s", depth, "", attset_name, str);
             break;
         case Z_AttributeValue_complex:
@@ -273,8 +267,8 @@ static char *prox_unit_name(Z_ProximityOperator *op)
     }
 }
 
-static void zlog_structure (Z_RPNStructure *zs, int depth, 
-        enum oid_value ast, int loglevel)
+static void zlog_structure(Z_RPNStructure *zs, int depth, 
+                           const int *ast, int loglevel)
 {
     if (zs->which == Z_RPNStructure_complex)
     {
@@ -330,7 +324,7 @@ static void zlog_structure (Z_RPNStructure *zs, int depth,
             default:
                 yaz_log (loglevel, "%*.0s term (not general)", depth, "");
             }
-            zlog_attributes (zapt, depth+2, ast, loglevel);
+            zlog_attributes(zapt, depth+2, ast, loglevel);
         }
         else if (zs->u.simple->which == Z_Operand_resultSetId)
         {
@@ -346,21 +340,7 @@ static void zlog_structure (Z_RPNStructure *zs, int depth,
 
 void log_rpn_query_level (int loglevel, Z_RPNQuery *rpn)
 {
-    oident *attrset;
-    enum oid_value ast;
-    
-    attrset = oid_getentbyoid (rpn->attributeSetId);
-    if (attrset)
-    {
-        ast = attrset->value;
-        yaz_log (loglevel, "RPN query. Type: %s", attrset->desc);
-    } 
-    else
-    {
-        ast = VAL_NONE;
-        yaz_log (loglevel, "RPN query. Unknown type");
-    }
-    zlog_structure (rpn->RPNStructure, 0, ast, loglevel);
+    zlog_structure(rpn->RPNStructure, 0, rpn->attributeSetId, loglevel);
 }
 
 void log_rpn_query(Z_RPNQuery *rpn)
@@ -369,7 +349,7 @@ void log_rpn_query(Z_RPNQuery *rpn)
 }
 
 void log_scan_term_level(int loglevel, 
-                         Z_AttributesPlusTerm *zapt, oid_value ast)
+                         Z_AttributesPlusTerm *zapt, const int *ast)
 {
     int depth = 0;
     if (!loglevel)
@@ -381,10 +361,10 @@ void log_scan_term_level(int loglevel,
     }
     else
         yaz_log (loglevel, "%*.0s term (not general)", depth, "");
-    zlog_attributes (zapt, depth+2, ast, loglevel);
+    zlog_attributes(zapt, depth+2, ast, loglevel);
 }
 
-void log_scan_term(Z_AttributesPlusTerm *zapt, oid_value ast)
+void log_scan_term(Z_AttributesPlusTerm *zapt, const int *ast)
 {
     log_scan_term_level (YLOG_LOG, zapt, ast);
 }
index 82ce672..ce08d99 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: nmem.c,v 1.28 2007-01-03 08:42:15 adam Exp $
+ * $Id: nmem.c,v 1.29 2007-04-12 13:52:57 adam Exp $
  */
 
 /**
@@ -27,7 +27,6 @@
 #include <yaz/xmalloc.h>
 #include <yaz/nmem.h>
 #include <yaz/log.h>
-#include <yaz/oid.h>
 
 #ifdef WIN32
 #include <windows.h>
@@ -499,7 +498,6 @@ void nmem_exit (void)
 {
     if (--nmem_init_flag == 0)
     {
-        oid_exit();
         while (freelist)
         {
             struct nmem_block *fl = freelist;
index d9e4025..efbda89 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_mem.c,v 1.9 2007-03-19 21:08:13 adam Exp $
+ * $Id: odr_mem.c,v 1.10 2007-04-12 13:52:57 adam Exp $
  */
 /**
  * \file odr_mem.c
@@ -25,21 +25,17 @@ NMEM odr_extract_mem(ODR o)
 {
     NMEM r = o->mem;
 
-    o->mem = 0;
+    o->mem = nmem_create();
     return r;
 }
 
 void *odr_malloc(ODR o, int size)
 {
-    if (o && !o->mem)
-        o->mem = nmem_create();
-    return nmem_malloc(o ? o->mem : 0, size);
+    return nmem_malloc(o->mem, size);
 }
 
 char *odr_strdup(ODR o, const char *str)
 {
-    if (o && !o->mem)
-        o->mem = nmem_create();
     return nmem_strdup(o->mem, str);
 }
 
@@ -50,14 +46,12 @@ char *odr_strdupn(ODR o, const char *str, size_t n)
 
 int *odr_intdup(ODR o, int v)
 {
-    if (o && !o->mem)
-        o->mem = nmem_create();
     return nmem_intdup(o->mem, v);
 }
 
 int odr_total(ODR o)
 {
-    return o->mem ? nmem_total(o->mem) : 0;
+    return nmem_total(o->mem);
 }
 
 Odr_oct *odr_create_Odr_oct(ODR o, const unsigned char *buf, int sz)
index be45098..361fa2b 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_oid.c,v 1.9 2007-03-19 21:08:13 adam Exp $
+ * $Id: odr_oid.c,v 1.10 2007-04-12 13:52:57 adam Exp $
  */
 /**
  * \file odr_oid.c
@@ -12,8 +12,8 @@
 #include <config.h>
 #endif
 
+#include <yaz/oid_util.h>
 #include "odr-priv.h"
-#include <yaz/oid.h>
 
 /*
  * Top level oid en/decoder.
index 9a9f445..c50ac55 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_util.c,v 1.10 2007-03-19 21:08:13 adam Exp $
+ * $Id: odr_util.c,v 1.11 2007-04-12 13:52:57 adam Exp $
  */
 /**
  * \file odr_util.c
@@ -16,7 +16,7 @@
 #include <string.h>
 #include <ctype.h>
 #include "odr-priv.h"
-#include <yaz/oid.h>
+#include <yaz/oid_util.h>
 
 void odr_prname(ODR o, const char *name)
 {
@@ -44,7 +44,7 @@ int odp_more_chunks(ODR o, const unsigned char *base, int len)
         return o->bp - base < len;
 }
 
-Odr_oid *odr_oiddup_nmem(NMEM nmem, Odr_oid *o)
+Odr_oid *odr_oiddup_nmem(NMEM nmem, const Odr_oid *o)
 {
     Odr_oid *r;
 
@@ -56,11 +56,9 @@ Odr_oid *odr_oiddup_nmem(NMEM nmem, Odr_oid *o)
     return r;
 }
 
-Odr_oid *odr_oiddup(ODR odr, Odr_oid *o)
+Odr_oid *odr_oiddup(ODR odr, const Odr_oid *o)
 {
-    if (!odr->mem)
-        odr->mem = nmem_create();
-    return odr_oiddup_nmem (odr->mem, o);
+    return odr_oiddup_nmem(odr_getmem(odr), o);
 }
 
 Odr_oid *odr_getoidbystr_nmem(NMEM nmem, const char *str)
@@ -84,9 +82,7 @@ Odr_oid *odr_getoidbystr_nmem(NMEM nmem, const char *str)
 
 Odr_oid *odr_getoidbystr(ODR o, const char *str)
 {
-    if (!o->mem)
-        o->mem = nmem_create();
-    return odr_getoidbystr_nmem (o->mem, str);
+    return odr_getoidbystr_nmem(odr_getmem(o), str);
 }
 
 int odr_missing(ODR o, int opt, const char *name)
diff --git a/src/oid.c b/src/oid.c
deleted file mode 100644 (file)
index 8fef519..0000000
--- a/src/oid.c
+++ /dev/null
@@ -1,649 +0,0 @@
-/*
- * Copyright (C) 1995-2007, Index Data ApS
- * See the file LICENSE for details.
- *
- * $Id: oid.c,v 1.13 2007-01-03 08:42:15 adam Exp $
- */
-
-/**
- * \file oid.c
- * \brief Implements OID database
- *
- * More or less protocol-transparent OID database.
- * We could (and should?) extend this so that the user app can add new
- * entries to the list at initialization.
- */
-#if HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-#include <yaz/oid.h>
-#include <yaz/yaz-util.h>
-
-static int z3950_prefix[] = { 1, 2, 840, 10003, -1 };
-static int sr_prefix[]    = { 1, 0, 10163, -1 };
-
-struct oident_list {
-    struct oident oident;
-    struct oident_list *next;
-};
-
-static struct oident_list *oident_table = NULL;
-static int oid_value_dynamic = VAL_DYNAMIC;
-static int oid_init_flag = 0;
-static NMEM_MUTEX oid_mutex = 0;
-static NMEM oid_nmem = 0;
-
-/*
- * OID database
- */
-static oident standard_oids[] =
-{
-    /* General definitions */
-    {PROTO_GENERAL, CLASS_TRANSYN, VAL_BER,          {2,1,1,-1},
-     "BER" },
-    {PROTO_GENERAL, CLASS_TRANSYN, VAL_ISO2709,      {1,0,2709,1,1,-1},
-     "ISO2709"},
-    {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},
-     "Z-APDU"},    
-    {PROTO_Z3950,   CLASS_APPCTX,  VAL_BASIC_CTX,    {1,1,-1},
-     "Z-BASIC"},
-    {PROTO_Z3950,   CLASS_ATTSET,  VAL_BIB1,         {3,1,-1},
-     "Bib-1"},
-    {PROTO_Z3950,   CLASS_ATTSET,  VAL_EXP1,         {3,2,-1},
-     "Exp-1"},
-    {PROTO_Z3950,   CLASS_ATTSET,  VAL_EXT1,         {3,3,-1},
-     "Ext-1"},
-    {PROTO_Z3950,   CLASS_ATTSET,  VAL_CCL1,         {3,4,-1},
-     "CCL-1"},
-    {PROTO_Z3950,   CLASS_ATTSET,  VAL_GILS,         {3,5,-1},
-     "GILS-attset"},
-    {PROTO_Z3950,   CLASS_ATTSET,  VAL_GILS,         {3,5,-1},
-     "GILS"},
-    {PROTO_Z3950,   CLASS_ATTSET,  VAL_STAS,         {3,6,-1},
-     "STAS-attset"},
-    {PROTO_Z3950,   CLASS_ATTSET,  VAL_COLLECT1,     {3,7,-1},
-     "Collections-attset"},
-    {PROTO_Z3950,   CLASS_ATTSET,  VAL_CIMI1,        {3,8,-1},
-     "CIMI-attset"},
-    {PROTO_Z3950,   CLASS_ATTSET,  VAL_GEO,          {3,9,-1},
-     "Geo-attset"},
-
-    {PROTO_Z3950,   CLASS_ATTSET,  VAL_ZBIG,         {3,10,-1},
-     "ZBIG"},
-    {PROTO_Z3950,   CLASS_ATTSET,  VAL_UTIL,         {3,11,-1},
-     "Util"},
-    {PROTO_Z3950,   CLASS_ATTSET,  VAL_XD1,          {3,12,-1},
-     "XD-1"},
-    {PROTO_Z3950,   CLASS_ATTSET,  VAL_ZTHES,        {3,13,-1},
-     "Zthes"},
-    {PROTO_Z3950,   CLASS_ATTSET,  VAL_FIN1,         {3,14,-1},
-     "Fin-1"},
-    {PROTO_Z3950,   CLASS_ATTSET,  VAL_DAN1,         {3,15,-1},
-     "Dan-1"},
-    {PROTO_Z3950,   CLASS_ATTSET,  VAL_HOLDINGS,     {3,16,-1},
-     "Holdings"},
-    {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"},
-    /* New applications should use Zthes-1 instead of this Satan-spawn */
-    {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_ATTSET,  VAL_EXTLITE,      {3,1000,81,3,-1},
-     "EXTLITE"},
-    {PROTO_Z3950,   CLASS_DIAGSET, VAL_BIB1,         {4,1,-1},
-     "Bib-1"},
-    {PROTO_Z3950,   CLASS_DIAGSET, VAL_DIAG1,        {4,2,-1},
-     "Diag-1"},
-    {PROTO_Z3950,   CLASS_DIAGSET, VAL_DIAG_ES,      {4,3,-1},
-     "Diag-ES"},
-    {PROTO_Z3950,   CLASS_DIAGSET, VAL_DIAG_GENERAL, {4,3,-1},
-     "Diag-General"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_UNIMARC,      {5,1,-1},
-     "Unimarc"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_INTERMARC,    {5,2,-1},
-     "Intermarc"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_CCF,          {5,3,-1},
-     "CCF"},
-    /* MARC21 is just an alias for the original USmarc */
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_USMARC,       {5,10,-1},
-     "MARC21"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_USMARC,       {5,10,-1},
-     "USmarc"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_UKMARC,       {5,11,-1},
-     "UKmarc"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_NORMARC,      {5,12,-1},
-     "Normarc"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_LIBRISMARC,   {5,13,-1},
-     "Librismarc"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_DANMARC,      {5,14,-1},
-     "Danmarc"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_FINMARC,      {5,15,-1},
-     "Finmarc"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_MAB,          {5,16,-1},
-     "MAB"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_CANMARC,      {5,17,-1},
-     "Canmarc"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_SBN,          {5,18,-1},
-     "SBN"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_PICAMARC,     {5,19,-1},
-     "Picamarc"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_AUSMARC,      {5,20,-1},
-     "Ausmarc"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_IBERMARC,     {5,21,-1},
-     "Ibermarc"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_CATMARC,      {5,22,-1},
-     "Carmarc"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_MALMARC,      {5,23,-1},
-     "Malmarc"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_JPMARC,       {5,24,-1},
-     "JPmarc"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_SWEMARC,      {5,25,-1},
-     "SWEmarc"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_SIGLEMARC,    {5,26,-1},
-     "SIGLEmarc"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_ISDSMARC,     {5,27,-1},
-     "ISDSmarc"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_RUSMARC,      {5,28,-1},
-     "RUSmarc"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_HUNMARC,      {5,29,-1},
-     "Hunmarc"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_NACSISCATP,   {5,30,-1},
-     "NACSIS-CATP"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_FINMARC2000,  {5,31,-1},
-     "FINMARC2000"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_MARC21FIN,    {5,32,-1},
-     "MARC21-fin"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_EXPLAIN,      {5,100,-1},
-     "Explain"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_SUTRS,        {5,101,-1},
-     "SUTRS"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_OPAC,         {5,102,-1},
-     "OPAC"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_SUMMARY,      {5,103,-1},
-     "Summary"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_GRS0,         {5,104,-1},
-     "GRS-0"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_GRS1,         {5,105,-1},
-     "GRS-1"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_EXTENDED,     {5,106,-1},
-     "Extended"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_FRAGMENT,     {5,107,-1},
-     "Fragment"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_PDF,          {5,109,1,-1},
-     "pdf"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_POSTSCRIPT,   {5,109,2,-1},
-     "postscript"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_HTML,         {5,109,3,-1},
-     "html"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_TIFF,         {5,109,4,-1},
-     "tiff"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_GIF,          {5,109,5,-1},
-     "gif"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_JPEG,         {5,109,6,-1},
-     "jpeg"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_PNG,          {5,109,7,-1},
-     "png"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_MPEG,         {5,109,8,-1},
-     "mpeg"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_SGML,         {5,109,9,-1},
-     "sgml"},
-
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_TIFFB,        {5,110,1,-1},
-     "tiff-b"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_WAV,          {5,110,2,-1},
-     "wav"},
-
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_SQLRS,        {5,111,-1},
-     "SQL-RS"},
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_SOIF,         {5,1000,81,2,-1},
-     "SOIF" },
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_TEXT_XML,     {5,109,10,-1},
-     "text-XML" },
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_TEXT_XML,     {5,109,10,-1},
-     "XML" },
-    {PROTO_Z3950,   CLASS_RECSYN,  VAL_APPLICATION_XML, {5,109,11,-1},
-     "application-XML" },
-    {PROTO_Z3950,   CLASS_RESFORM, VAL_RESOURCE1,    {7,1,-1},
-     "Resource-1"},
-    {PROTO_Z3950,   CLASS_RESFORM, VAL_RESOURCE2,    {7,2,-1},
-     "Resource-2"},
-    {PROTO_Z3950,   CLASS_RESFORM, VAL_UNIVERSE_REPORT, {7,1000,81,1,-1},
-     "UNIverse-Resource-Report"},
-
-    {PROTO_Z3950,   CLASS_ACCFORM, VAL_PROMPT1,      {8,1,-1},
-     "Prompt-1"},
-    {PROTO_Z3950,   CLASS_ACCFORM, VAL_DES1,         {8,2,-1},
-     "Des-1"},
-    {PROTO_Z3950,   CLASS_ACCFORM, VAL_KRB1,         {8,3,-1},
-     "Krb-1"},
-    {PROTO_Z3950,   CLASS_EXTSERV, VAL_PRESSET,      {9,1,-1},
-     "Pers. set"},
-    {PROTO_Z3950,   CLASS_EXTSERV, VAL_PQUERY,       {9,2,-1},
-     "Pers. query"},
-    {PROTO_Z3950,   CLASS_EXTSERV, VAL_PCQUERY,      {9,3,-1},
-     "Per'd query"},
-    {PROTO_Z3950,   CLASS_EXTSERV, VAL_ITEMORDER,    {9,4,-1},
-     "Item order"},
-    {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},
-     "exp. spec."},
-    {PROTO_Z3950,   CLASS_EXTSERV, VAL_EXPORTINV,    {9,7,-1},
-     "exp. inv."},
-    {PROTO_Z3950,   CLASS_EXTSERV, VAL_ADMINSERVICE, {9,1000,81,1,-1},
-     "Admin"},
-    {PROTO_Z3950,   CLASS_USERINFO,VAL_SEARCHRES1,   {10,1,-1},
-     "searchResult-1"},
-    {PROTO_Z3950,   CLASS_USERINFO,VAL_CHARLANG,     {10,2,-1},
-     "CharSetandLanguageNegotiation"},
-    {PROTO_Z3950,   CLASS_USERINFO,VAL_USERINFO1,    {10,3,-1},
-     "UserInfo-1"},
-    {PROTO_Z3950,   CLASS_USERINFO,VAL_MULTISRCH1,   {10,4,-1},
-     "MultipleSearchTerms-1"},
-    {PROTO_Z3950,   CLASS_USERINFO,VAL_MULTISRCH2,   {10,5,-1},
-     "MultipleSearchTerms-2"},
-    {PROTO_Z3950,   CLASS_USERINFO,VAL_DATETIME,     {10,6,-1},
-     "DateTime"},
-    {PROTO_Z3950,   CLASS_USERINFO,VAL_PROXY,        {10,1000,81,1,-1},
-     "Proxy" },
-    {PROTO_Z3950,   CLASS_USERINFO,VAL_COOKIE,       {10,1000,81,2,-1},
-     "Cookie" },
-    {PROTO_Z3950,   CLASS_USERINFO,VAL_CLIENT_IP,    {10,1000,81,3,-1},
-     "Client-IP" },
-    {PROTO_Z3950,   CLASS_ELEMSPEC,VAL_ESPEC1,       {11,1,-1},
-     "Espec-1"},
-    {PROTO_Z3950,   CLASS_VARSET,  VAL_VAR1,         {12,1,-1},
-     "Variant-1"},
-    {PROTO_Z3950,   CLASS_SCHEMA,  VAL_WAIS,         {13,1,-1},
-     "WAIS-schema"},
-    {PROTO_Z3950,   CLASS_SCHEMA,  VAL_GILS,         {13,2,-1},
-     "GILS-schema"},
-    {PROTO_Z3950,   CLASS_SCHEMA,  VAL_COLLECT1,     {13,3,-1},
-     "Collections-schema"},
-    {PROTO_Z3950,   CLASS_SCHEMA,  VAL_GEO,          {13,4,-1},
-     "Geo-schema"},
-    {PROTO_Z3950,   CLASS_SCHEMA,  VAL_CIMI1,        {13,5,-1},
-     "CIMI-schema"},
-    {PROTO_Z3950,   CLASS_SCHEMA,  VAL_UPDATEES,     {13,6,-1},
-     "Update ES"},
-    {PROTO_Z3950,   CLASS_SCHEMA,  VAL_HOLDINGS,     {13,7,-1},
-     "Holdings"},
-    {PROTO_Z3950,   CLASS_SCHEMA,  VAL_ZTHES,        {13,8,-1},
-     "Zthes"},
-    {PROTO_Z3950,   CLASS_SCHEMA,  VAL_THESAURUS,    {13,1000,81,1,-1},
-     "thesaurus-schema"},
-    {PROTO_Z3950,   CLASS_SCHEMA,  VAL_EXPLAIN,      {13,1000,81,2,-1},
-     "Explain-schema"},
-    {PROTO_Z3950,   CLASS_TAGSET,  VAL_SETM,         {14,1,-1},
-     "TagsetM"},
-    {PROTO_Z3950,   CLASS_TAGSET,  VAL_SETG,         {14,2,-1},
-     "TagsetG"},
-    {PROTO_Z3950,   CLASS_TAGSET,  VAL_STAS,         {14,3,-1},
-     "STAS-tagset"},
-    {PROTO_Z3950,   CLASS_TAGSET,  VAL_GILS,         {14,4,-1},
-     "GILS-tagset"},
-    {PROTO_Z3950,   CLASS_TAGSET,  VAL_COLLECT1,     {14,5,-1},
-     "Collections-tagset"},
-    {PROTO_Z3950,   CLASS_TAGSET,  VAL_CIMI1,        {14,6,-1},
-     "CIMI-tagset"},
-    {PROTO_Z3950,   CLASS_TAGSET,  VAL_THESAURUS,    {14,1000,81,1,-1},
-     "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_NEGOT,   VAL_CHARNEG4,     {15,4,-1},
-     "CharSetandLanguageNegotiation-4"},
-    {PROTO_Z3950,   CLASS_NEGOT,   VAL_ID_CHARSET,   {15,1000,81,1,-1},
-     "ID-Charset" },
-    {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_Z3950,   CLASS_USERINFO,VAL_OCLCUI,       {10, 1000, 17, 1, -1},
-     "OCLC-userInfo"},
-    {PROTO_Z3950,   CLASS_EXTSERV, VAL_XMLES,        {9,1000,105,4,-1},
-     "XML-ES"},
-    {PROTO_NOP,     CLASS_NOP,     VAL_NOP,          {-1},      0     }
-};
-
-/* OID utilities */
-
-void oid_oidcpy(int *t, int *s)
-{
-    while ((*(t++) = *(s++)) > -1);
-}
-
-void oid_oidcat(int *t, int *s)
-{
-    while (*t > -1)
-        t++;
-    while ((*(t++) = *(s++)) > -1);
-}
-
-int oid_oidcmp(int *o1, int *o2)
-{
-    while (*o1 == *o2 && *o1 > -1)
-    {
-        o1++;
-        o2++;
-    }
-    if (*o1 == *o2)
-        return 0;
-    else if (*o1 > *o2)
-        return 1;
-    else
-        return -1;
-}
-
-int oid_oidlen(int *o)
-{
-    int len = 0;
-
-    while (*(o++) >= 0)
-        len++;
-    return len;
-}
-
-
-static int match_prefix(int *look, int *prefix)
-{
-    int len;
-
-    for (len = 0; *look == *prefix; look++, prefix++, len++);
-    if (*prefix < 0) /* did we reach the end of the prefix? */
-        return len;
-    return 0;
-}
-
-void oid_transfer (struct oident *oidentp)
-{
-    while (*oidentp->oidsuffix >= 0)
-    {
-        oid_addent (oidentp->oidsuffix, oidentp->proto,
-                    oidentp->oclass,
-                    oidentp->desc, oidentp->value);
-        oidentp++;
-    }
-}
-
-void oid_init (void)
-{
-    if (oid_init_flag == 0)
-    {
-        /* oid_transfer is thread safe, so there's nothing wrong in having
-           two threads calling it simultaniously. On the other hand
-           no thread may exit oid_init before all OID's bave been
-           transferred - which is why checked is set after oid_transfer... 
-        */
-        nmem_mutex_create (&oid_mutex);
-        nmem_mutex_enter (oid_mutex);
-        if (!oid_nmem)
-            oid_nmem = nmem_create ();
-        nmem_mutex_leave (oid_mutex);
-        oid_transfer (standard_oids);
-        oid_init_flag = 1;
-    }
-}
-
-void oid_exit (void)
-{
-    if (oid_init_flag)
-    {
-        oid_init_flag = 0;
-        nmem_mutex_destroy (&oid_mutex);
-        nmem_destroy (oid_nmem);
-        oid_nmem = 0;
-    }
-}
-
-static struct oident *oid_getentbyoid_x(int *o)
-{
-    enum oid_proto proto;
-    int prelen;
-    struct oident_list *ol;
-    
-    /* determine protocol type */
-    if ((prelen = match_prefix(o, z3950_prefix)) != 0)
-        proto = PROTO_Z3950;
-    else if ((prelen = match_prefix(o, sr_prefix)) != 0)
-        proto = PROTO_SR;
-    else
-        proto = PROTO_GENERAL;
-    for (ol = oident_table; ol; ol = ol->next)
-    {
-        struct oident *p = &ol->oident;
-        if (p->proto == proto && !oid_oidcmp(o + prelen, p->oidsuffix))
-            return p;
-        if (p->proto == PROTO_GENERAL && !oid_oidcmp (o, p->oidsuffix))
-            return p;
-    }
-    return 0;
-}
-
-/*
- * To query, fill out proto, class, and value of the ent parameter.
- */
-int *oid_ent_to_oid(struct oident *ent, int *ret)
-{
-    struct oident_list *ol;
-    
-    oid_init ();
-    for (ol = oident_table; ol; ol = ol->next)
-    {
-        struct oident *p = &ol->oident;
-        if (ent->value == p->value &&
-            (p->proto == PROTO_GENERAL || (ent->proto == p->proto &&  
-            (ent->oclass == p->oclass || ent->oclass == CLASS_GENERAL))))
-        {
-            if (p->proto == PROTO_Z3950)
-                oid_oidcpy(ret, z3950_prefix);
-            else if (p->proto == PROTO_SR)
-                oid_oidcpy(ret, sr_prefix);
-            else
-                ret[0] = -1;
-            oid_oidcat(ret, p->oidsuffix);
-            ent->desc = p->desc;
-            return ret;
-        }
-    }
-    ret[0] = -1;
-    return 0;
-}
-
-/*
- * To query, fill out proto, class, and value of the ent parameter.
- */
-int *oid_getoidbyent(struct oident *ent)
-{
-    static int ret[OID_SIZE];
-
-    return oid_ent_to_oid (ent, ret);
-}
-
-struct oident *oid_addent (int *oid, enum oid_proto proto,
-                           enum oid_class oclass,
-                           const char *desc, int value)
-{
-    struct oident *oident = 0;
-
-    nmem_mutex_enter (oid_mutex);
-    if (!oident)
-    {
-        struct oident_list *oident_list;
-        oident_list = (struct oident_list *)
-            nmem_malloc (oid_nmem, sizeof(*oident_list));
-        oident = &oident_list->oident;
-        oident->proto = proto;
-        oident->oclass = oclass;
-
-        if (!desc)
-        {
-            char desc_str[OID_STR_MAX];
-            int i;
-
-            *desc_str = '\0';
-            if (*oid >= 0)
-            {
-                sprintf (desc_str, "%d", *oid);
-                for (i = 1; i < OID_SIZE && oid[i] >= 0; i++)
-                    sprintf (desc_str+strlen(desc_str), ".%d", oid[i]);
-            }
-            oident->desc = nmem_strdup(oid_nmem, desc_str);
-        }
-        else
-            oident->desc = nmem_strdup(oid_nmem, desc);
-        if (value == VAL_DYNAMIC)
-            oident->value = (enum oid_value) (++oid_value_dynamic);
-        else
-            oident->value = (enum oid_value) value;
-        oid_oidcpy (oident->oidsuffix, oid);
-        oident_list->next = oident_table;
-        oident_table = oident_list;
-    }
-    nmem_mutex_leave (oid_mutex);
-    return oident;
-}
-
-struct oident *oid_getentbyoid(int *oid)
-{
-    struct oident *oident;
-
-    if (!oid)
-        return 0;
-    oid_init ();
-    oident = oid_getentbyoid_x (oid);
-    if (!oident)
-        oident = oid_addent (oid, PROTO_GENERAL, CLASS_GENERAL,
-                             NULL, VAL_DYNAMIC);
-    return oident;
-}
-
-static oid_value oid_getval_raw(const char *name)
-{
-    int val = 0, i = 0, oid[OID_SIZE];
-    struct oident *oident;
-    
-    while (isdigit (*(const 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;
-    oident = oid_getentbyoid_x (oid);
-    if (!oident)
-        oident = oid_addent (oid, PROTO_GENERAL, CLASS_GENERAL, NULL,
-                         VAL_DYNAMIC);
-    return oident->value;
-}
-
-oid_value oid_getvalbyname(const char *name)
-{
-    struct oident_list *ol;
-
-    oid_init ();
-    if (isdigit (*(const unsigned char *) name))
-        return oid_getval_raw (name);
-    for (ol = oident_table; ol; ol = ol->next)
-        if (!yaz_matchstr(ol->oident.desc, name))
-        {
-            return ol->oident.value;
-        }
-    return VAL_NONE;
-}
-
-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);
-}
-
-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 < OID_SIZE; 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);
-}
-
-/*
- * Local variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- * vim: shiftwidth=4 tabstop=8 expandtab
- */
-
diff --git a/src/oid_db.c b/src/oid_db.c
new file mode 100644 (file)
index 0000000..1c5448b
--- /dev/null
@@ -0,0 +1,373 @@
+/*
+ * Copyright (C) 1995-2007, Index Data ApS
+ * See the file LICENSE for details.
+ *
+ * $Id: oid_db.c,v 1.1 2007-04-12 13:52:57 adam Exp $
+ */
+
+/**
+ * \brief OID Database
+ */
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include <yaz/yaz-util.h>
+#include <yaz/odr.h>
+#include <yaz/oid_util.h>
+#include <yaz/oid_db.h>
+
+struct yaz_oid_entry {
+    int oclass;
+    int oid[10];
+    char *name;
+};
+
+#define Z3950_PREFIX 1, 2, 840, 10003
+
+static struct yaz_oid_entry standard_oids[] =
+{
+    /* General definitions */
+    {CLASS_TRANSYN, {2, 1, 1,-1}, "BER" },
+    {CLASS_TRANSYN, {1, 0, 2709, 1, 1,-1},  "ISO2709"},
+    {CLASS_GENERAL, {1, 0, 10161, 2, 1,-1},  OID_STR_ILL_1 },
+    {CLASS_ABSYN, {2, 1,-1}, "Z-APDU"}, 
+    {CLASS_APPCTX, {1, 1,-1}, "Z-BASIC"},
+    {CLASS_ATTSET, {Z3950_PREFIX, 3, 1,-1}, "Bib-1"},
+    {CLASS_ATTSET, {Z3950_PREFIX, 3, 2,-1}, "Exp-1"},
+    {CLASS_ATTSET, {Z3950_PREFIX, 3, 3,-1}, "Ext-1"},
+    {CLASS_ATTSET, {Z3950_PREFIX, 3, 4,-1}, "CCL-1"},
+    {CLASS_ATTSET, {Z3950_PREFIX, 3, 5,-1}, "GILS"},
+    {CLASS_ATTSET, {Z3950_PREFIX, 3, 5,-1}, "GILS-attset"},
+    {CLASS_ATTSET, {Z3950_PREFIX, 3, 6,-1}, "STAS-attset"},
+    {CLASS_ATTSET, {Z3950_PREFIX, 3, 7,-1}, "Collections-attset"},
+    {CLASS_ATTSET, {Z3950_PREFIX, 3, 8,-1}, "CIMI-attset"},
+    {CLASS_ATTSET, {Z3950_PREFIX, 3, 9,-1}, "Geo-attset"},
+    {CLASS_ATTSET, {Z3950_PREFIX, 3, 10,-1}, "ZBIG"},
+    {CLASS_ATTSET, {Z3950_PREFIX, 3, 11,-1}, "Util"},
+    {CLASS_ATTSET, {Z3950_PREFIX, 3, 12,-1}, "XD-1"},
+    {CLASS_ATTSET, {Z3950_PREFIX, 3, 13,-1}, "Zthes"},
+    {CLASS_ATTSET, {Z3950_PREFIX, 3, 14,-1}, "Fin-1"},
+    {CLASS_ATTSET, {Z3950_PREFIX, 3, 15,-1}, "Dan-1"},
+    {CLASS_ATTSET, {Z3950_PREFIX, 3, 16,-1}, "Holdings"},
+    {CLASS_ATTSET, {Z3950_PREFIX, 3, 17,-1}, "MARC"},
+    {CLASS_ATTSET, {Z3950_PREFIX, 3, 18,-1}, "Bib-2"},
+    {CLASS_ATTSET, {Z3950_PREFIX, 3, 19,-1}, "ZeeRex"},
+    /* New applications should use Zthes-1 instead of this Satan-spawn */
+    {CLASS_ATTSET, {Z3950_PREFIX, 3,1000, 81,1,-1},
+     "Thesaurus-attset"},
+    {CLASS_ATTSET, {Z3950_PREFIX, 3,1000, 81,2,-1},
+     "IDXPATH"},
+    {CLASS_ATTSET, {Z3950_PREFIX, 3,1000, 81,3,-1},
+     "EXTLITE"},
+    {CLASS_DIAGSET, {Z3950_PREFIX, 4, 1,-1},
+     OID_STR_BIB1},
+    {CLASS_DIAGSET, {Z3950_PREFIX, 4, 2,-1},
+     OID_STR_DIAG1},
+    {CLASS_DIAGSET, {Z3950_PREFIX, 4, 3,-1},
+     "Diag-ES"},
+    {CLASS_DIAGSET,  {Z3950_PREFIX, 4, 3,-1},
+     "Diag-General"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 1,-1},
+     "Unimarc"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 2,-1},
+     "Intermarc"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 3,-1},
+     "CCF"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 10,-1},
+     OID_STR_USMARC},
+    /* MARC21 is just an alias for the original USmarc */
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 10,-1},
+     "MARC21"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 11,-1},
+     "UKmarc"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 12,-1},
+     "Normarc"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 13,-1},
+     "Librismarc"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 14,-1},
+     "Danmarc"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 15,-1},
+     "Finmarc"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 16,-1},
+     "MAB"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 17,-1},
+     "Canmarc"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 18,-1},
+     "SBN"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 19,-1},
+     "Picamarc"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 20,-1},
+     "Ausmarc"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 21,-1},
+     "Ibermarc"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 22,-1},
+     "Carmarc"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 23,-1},
+     "Malmarc"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 24,-1},
+     "JPmarc"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 25,-1},
+     "SWEmarc"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 26,-1},
+     "SIGLEmarc"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 27,-1},
+     "ISDSmarc"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 28,-1},
+     "RUSmarc"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 29,-1},
+     "Hunmarc"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 30,-1},
+     "NACSIS-CATP"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 31,-1},
+     "FINMARC2000"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 32,-1},
+     "MARC21-fin"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 100,-1},
+     OID_STR_EXPLAIN},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 101,-1},
+     OID_STR_SUTRS},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 102,-1},
+     OID_STR_OPAC},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 103,-1},
+     OID_STR_SUMMARY},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 104,-1},
+     "GRS-0"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 105,-1},
+     OID_STR_GRS1 },
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 106,-1},
+     OID_STR_EXTENDED},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 107,-1},
+     "Fragment"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 109,1,-1},
+     "pdf"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 109,2,-1},
+     OID_STR_POSTSCRIPT},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 109,3,-1},
+     OID_STR_HTML},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 109,4,-1},
+     "tiff"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 109,5,-1},
+     "gif"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 109,6,-1},
+     "jpeg"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 109,7,-1},
+     "png"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 109,8,-1},
+     "mpeg"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 109,9,-1},
+     "sgml"},
+
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 110,1,-1},
+     "tiff-b"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 110,2,-1},
+     "wav"},
+
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 111,-1},
+     "SQL-RS"},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 1000, 81, 2,-1},
+     OID_STR_SOIF},
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 109, 10,-1},
+     OID_STR_XML },
+    {CLASS_RECSYN, {Z3950_PREFIX, 5, 109, 10,-1},
+     "application-XML"},
+    {CLASS_RECSYN,   {Z3950_PREFIX, 5, 109, 11,-1},
+     OID_STR_APPLICATION_XML },
+    {CLASS_RESFORM, {Z3950_PREFIX, 7, 1,-1},
+     "Resource-1"},
+    {CLASS_RESFORM, {Z3950_PREFIX, 7, 2,-1},
+     "Resource-2"},
+    {CLASS_RESFORM,  {Z3950_PREFIX, 7, 1000, 81, 1,-1},
+     "UNIverse-Resource-Report"},
+
+    {CLASS_ACCFORM, {Z3950_PREFIX, 8, 1,-1},
+     "Prompt-1"},
+    {CLASS_ACCFORM, {Z3950_PREFIX, 8, 2,-1},
+     "Des-1"},
+    {CLASS_ACCFORM, {Z3950_PREFIX, 8, 3,-1},
+     "Krb-1"},
+    {CLASS_EXTSERV, {Z3950_PREFIX, 9, 1,-1},
+     "Pers. set"},
+    {CLASS_EXTSERV, {Z3950_PREFIX, 9, 2,-1},
+     "Pers. query"},
+    {CLASS_EXTSERV, {Z3950_PREFIX, 9, 3,-1},
+     "Per'd query"},
+    {CLASS_EXTSERV, {Z3950_PREFIX, 9, 4,-1},
+     OID_STR_ITEMORDER },
+    {CLASS_EXTSERV, {Z3950_PREFIX, 9, 5,-1},
+     "DB. Update (first version)"},
+    {CLASS_EXTSERV, {Z3950_PREFIX, 9, 5,1,-1},
+     "DB. Update (second version)"},
+    {CLASS_EXTSERV, {Z3950_PREFIX, 9, 5, 1, 1,-1},
+     OID_STR_EXT_UPDATE},
+    {CLASS_EXTSERV, {Z3950_PREFIX, 9, 6,-1},
+     "exp. spec."},
+    {CLASS_EXTSERV, {Z3950_PREFIX, 9, 7,-1},
+     "exp. inv."},
+    {CLASS_EXTSERV,  {Z3950_PREFIX, 9, 1000, 81, 1,-1},
+     OID_STR_ADMIN},
+    {CLASS_USERINFO, {Z3950_PREFIX, 10, 1,-1},
+     "searchResult-1"},
+    {CLASS_USERINFO, {Z3950_PREFIX, 10, 2,-1},
+     "CharSetandLanguageNegotiation"},
+    {CLASS_USERINFO, {Z3950_PREFIX, 10, 3,-1},
+     OID_STR_USERINFO_1},
+    {CLASS_USERINFO,   {Z3950_PREFIX, 10, 4,-1},
+     "MultipleSearchTerms-1"},
+    {CLASS_USERINFO,   {Z3950_PREFIX, 10, 5,-1},
+     "MultipleSearchTerms-2"},
+    {CLASS_USERINFO, {Z3950_PREFIX, 10, 6,-1},
+     "DateTime"},
+    {CLASS_USERINFO, {Z3950_PREFIX, 10, 1000, 81, 1,-1},
+     OID_STR_PROXY},
+    {CLASS_USERINFO, {Z3950_PREFIX, 10, 1000, 81, 2,-1},
+     OID_STR_COOKIE},
+    {CLASS_USERINFO, {Z3950_PREFIX, 10, 1000, 81, 3,-1},
+     OID_STR_CLIENT_IP },
+    {CLASS_ELEMSPEC, {1, 2, 840, 1003, 11, 1,-1},
+     "Espec-1"},
+    {CLASS_VARSET, {Z3950_PREFIX, 12, 1,-1},
+     "Variant-1"},
+    {CLASS_SCHEMA, {Z3950_PREFIX, 13, 1,-1},
+     "WAIS-schema"},
+    {CLASS_SCHEMA, {Z3950_PREFIX, 13, 2,-1},
+     "GILS-schema"},
+    {CLASS_SCHEMA, {Z3950_PREFIX, 13, 3,-1},
+     "Collections-schema"},
+    {CLASS_SCHEMA, {Z3950_PREFIX, 13, 4,-1},
+     "Geo-schema"},
+    {CLASS_SCHEMA, {Z3950_PREFIX, 13, 5,-1},
+     "CIMI-schema"},
+    {CLASS_SCHEMA, {Z3950_PREFIX, 13, 6,-1},
+     "Update ES"},
+    {CLASS_SCHEMA, {Z3950_PREFIX, 13, 7,-1},
+     "Holdings"},
+    {CLASS_SCHEMA, {Z3950_PREFIX, 13, 8,-1},
+     "Zthes"},
+    {CLASS_SCHEMA, {Z3950_PREFIX, 13, 1000, 81, 1,-1},
+     "thesaurus-schema"},
+    {CLASS_SCHEMA, {Z3950_PREFIX, 13, 1000, 81, 2,-1},
+     "Explain-schema"},
+    {CLASS_TAGSET, {Z3950_PREFIX, 14, 1,-1},
+     "TagsetM"},
+    {CLASS_TAGSET, {Z3950_PREFIX, 14, 2,-1},
+     "TagsetG"},
+    {CLASS_TAGSET, {Z3950_PREFIX, 14, 3,-1},
+     "STAS-tagset"},
+    {CLASS_TAGSET, {Z3950_PREFIX, 14, 4,-1},
+     "GILS-tagset"},
+    {CLASS_TAGSET, {Z3950_PREFIX, 14, 5,-1},
+     "Collections-tagset"},
+    {CLASS_TAGSET, {Z3950_PREFIX, 14, 6,-1},
+     "CIMI-tagset"},
+    {CLASS_TAGSET, {Z3950_PREFIX, 14, 1000, 81, 1,-1},
+     "thesaurus-tagset"}, 
+    {CLASS_TAGSET, {Z3950_PREFIX, 14, 1000, 81, 2,-1},
+     "Explain-tagset"},
+    {CLASS_TAGSET, {Z3950_PREFIX, 14, 8,-1},
+     "Zthes-tagset"},
+    {CLASS_NEGOT, {Z3950_PREFIX, 15, 3,-1},
+     OID_STR_CHARNEG_3 },
+    {CLASS_NEGOT, {Z3950_PREFIX, 15, 4,-1},
+     OID_STR_CHARNEG_4 },
+    {CLASS_NEGOT, {Z3950_PREFIX, 15, 1000, 81,1,-1},
+     OID_STR_ID_CHARSET },
+    {CLASS_USERINFO, {1, 2, 840, 1003, 16,  2, -1},
+     "CQL"},
+    {CLASS_GENERAL, {1,0,10646,1,0,2,-1},
+     "UCS-2"},
+    {CLASS_GENERAL, {1,0,10646,1,0,4,-1},
+     "UCS-4"},
+    {CLASS_GENERAL, {1,0,10646,1,0,5,-1},
+     "UTF-16"},
+    {CLASS_GENERAL, {1,0,10646,1,0,8,-1},
+     "UTF-8"},
+    {CLASS_USERINFO, {Z3950_PREFIX, 10, 1000, 17, 1, -1},
+     "OCLC-userInfo"},
+    {CLASS_EXTSERV, {Z3950_PREFIX, 9, 1000,105,4,-1},
+     OID_STR_XMLES },
+    {CLASS_NOP, {-1}, 0}
+};
+
+yaz_oid_db_t yaz_oid_std(void)
+{
+    return standard_oids;
+}
+
+const int *yaz_string_to_oid(yaz_oid_db_t oid_list,
+                            int oclass, const char *name)
+{
+    for (; oid_list->name; oid_list++)
+    {
+       if (!yaz_matchstr(oid_list->name, name)
+           && (oclass == CLASS_GENERAL || oclass == oid_list->oclass))
+           return oid_list->oid;
+    }
+    return 0;
+}
+
+int *yaz_string_to_oid_nmem(yaz_oid_db_t oid_list,
+                           int oclass, const char *name, NMEM nmem)
+{
+    const int *oid = yaz_string_to_oid(oid_list, oclass, name);
+    if (oid)
+       return odr_oiddup_nmem(nmem, oid);
+    return odr_getoidbystr_nmem(nmem, name);
+}
+
+int *yaz_string_to_oid_odr(yaz_oid_db_t oid_list,
+                          int oclass, const char *name, ODR o)
+{
+    return yaz_string_to_oid_nmem(oid_list, oclass, name, odr_getmem(o));
+}
+
+const char *yaz_oid_to_string(yaz_oid_db_t oid_list,
+                             const int *oid, int *oclass)
+{
+    if (!oid)
+       return 0;
+    for (; oid_list->name; oid_list++)
+    {
+       if (!oid_oidcmp(oid_list->oid, oid))
+       {
+           if (oclass)
+               *oclass = oid_list->oclass;
+           return oid_list->name;
+       }
+    }
+    return 0;
+}
+
+const char *yaz_oid_to_string_buf(const int *oid, int *oclass, char *buf)
+{
+    const char *p = yaz_oid_to_string(standard_oids, oid, oclass);
+    if (p)
+       return p;
+    if (oclass)
+       *oclass = CLASS_GENERAL;
+    return oid_to_dotstring(oid, buf);
+}
+
+int yaz_oid_is_iso2709(const int *oid)
+{
+    if (oid_oidlen(oid) == 6 && oid[0] == 1 && oid[1] == 2
+       && oid[2] == 840 && oid[3] == 10003 && oid[4] == 5 
+       && oid[5] <= 29 && oid[5] != 16)
+       return 1;
+    return 0;
+}
+
+void yaz_oid_trav(yaz_oid_db_t oid_list,
+                 void (*func)(const int *oid,
+                              int oclass, const char *name,
+                              void *client_data),
+                 void *client_data)
+{
+    for (; oid_list->name; oid_list++)
+       func(oid_list->oid, oid_list->oclass, oid_list->name, client_data);
+}
+
diff --git a/src/oid_util.c b/src/oid_util.c
new file mode 100644 (file)
index 0000000..fc62f51
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * 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 $
+ */
+
+/**
+ * \file oid_util.c
+ * \brief Implements OID base utilities
+ *
+ */
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include <yaz/snprintf.h>
+#include <yaz/oid_util.h>
+
+void oid_oidcpy(int *t, const int *s)
+{
+    while ((*(t++) = *(s++)) > -1);
+}
+
+void oid_oidcat(int *t, const int *s)
+{
+    while (*t > -1)
+        t++;
+    while ((*(t++) = *(s++)) > -1);
+}
+
+int oid_oidcmp(const int *o1, const int *o2)
+{
+    while (*o1 == *o2 && *o1 > -1)
+    {
+        o1++;
+        o2++;
+    }
+    if (*o1 == *o2)
+        return 0;
+    else if (*o1 > *o2)
+        return 1;
+    else
+        return -1;
+}
+
+int oid_oidlen(const int *o)
+{
+    int len = 0;
+
+    while (*(o++) >= 0)
+        len++;
+    return len;
+}
+
+
+char *oid_to_dotstring(const int *oid, char *oidbuf)
+{
+    char tmpbuf[20];
+    int i;
+
+    oidbuf[0] = '\0';
+    for (i = 0; oid[i] != -1 && i < OID_SIZE; i++) 
+    {
+        yaz_snprintf(tmpbuf, sizeof(tmpbuf)-1, "%d", oid[i]);
+        if (i > 0)
+            strcat(oidbuf, ".");
+        strcat(oidbuf, tmpbuf);
+    }
+    return oidbuf;
+}
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index fe2b637..7aac192 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: otherinfo.c,v 1.6 2007-01-03 08:42:15 adam Exp $
+ * $Id: otherinfo.c,v 1.7 2007-04-12 13:52:57 adam Exp $
  */
 /**
  * \file otherinfo.c
@@ -73,7 +73,7 @@ void yaz_oi_APDU(Z_APDU *apdu, Z_OtherInformation ***oip)
 
 Z_OtherInformationUnit *yaz_oi_update (
     Z_OtherInformation **otherInformationP, ODR odr,
-    int *oid, int categoryValue, int delete_flag)
+    const int *oid, int categoryValue, int delete_flag)
 {
     int i;
     Z_OtherInformation *otherInformation;
@@ -157,7 +157,7 @@ Z_OtherInformationUnit *yaz_oi_update (
 
 void yaz_oi_set_string_oid (
     Z_OtherInformation **otherInformation, ODR odr,
-    int *oid, int categoryValue,
+    const int *oid, int categoryValue,
     const char *str)
 {
     Z_OtherInformationUnit *oi =
@@ -168,25 +168,9 @@ void yaz_oi_set_string_oid (
     oi->information.characterInfo = odr_strdup (odr, str);
 }
 
-void yaz_oi_set_string_oidval (
-    Z_OtherInformation **otherInformation, ODR odr,
-    int oidval, int categoryValue,
-    const char *str)
-{
-    int oid[OID_SIZE];
-    struct oident ent;
-    ent.proto = PROTO_Z3950;
-    ent.oclass = CLASS_USERINFO;
-    ent.value = (oid_value) oidval;
-    if (!oid_ent_to_oid (&ent, oid))
-        return ;
-    yaz_oi_set_string_oid(otherInformation,
-                          odr, oid, categoryValue, str);
-}
-
 char *yaz_oi_get_string_oid (
     Z_OtherInformation **otherInformation,
-    int *oid, int categoryValue, int delete_flag)
+    const int *oid, int categoryValue, int delete_flag)
 {
     Z_OtherInformationUnit *oi;
     
@@ -197,21 +181,6 @@ char *yaz_oi_get_string_oid (
     return 0;
 }
 
-char *yaz_oi_get_string_oidval(Z_OtherInformation **otherInformation,
-                               int oidval, int categoryValue, int delete_flag)
-{
-    int oid[OID_SIZE];
-    struct oident ent;
-    ent.proto = PROTO_Z3950;
-    ent.oclass = CLASS_USERINFO;
-    ent.value = (oid_value) oidval;
-
-    if (!oid_ent_to_oid (&ent, oid))
-        return 0;
-    return yaz_oi_get_string_oid (otherInformation, oid, categoryValue,
-                                  delete_flag);
-}
-
 /*
  * Local variables:
  * c-basic-offset: 4
index da12e21..a9dbcc3 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: pquery.c,v 1.9 2007-01-03 08:42:15 adam Exp $
+ * $Id: pquery.c,v 1.10 2007-04-12 13:52:57 adam Exp $
  */
 /**
  * \file pquery.c
 #include <ctype.h>
 
 #include <yaz/proto.h>
-#include <yaz/oid.h>
+#include <yaz/oid_db.h>
 #include <yaz/pquery.h>
 
-static oid_value p_query_dfset = VAL_NONE;
-
 struct yaz_pqf_parser {
     const char *query_buf;
     const char *query_ptr;
@@ -33,27 +31,24 @@ struct yaz_pqf_parser {
     int error;
 };
 
-static Z_RPNStructure *rpn_structure (struct yaz_pqf_parser *li, ODR o,
-                                      oid_proto, 
-                                      int num_attr, int max_attr, 
-                                      int *attr_list, char **attr_clist,
-                                      oid_value *attr_set);
+static Z_RPNStructure *rpn_structure(struct yaz_pqf_parser *li, ODR o,
+                                     int num_attr, int max_attr, 
+                                     int *attr_list, char **attr_clist,
+                                     int **attr_set);
 
-static enum oid_value query_oid_getvalbyname (struct yaz_pqf_parser *li)
+static int *query_oid_getvalbyname(struct yaz_pqf_parser *li, ODR o)
 {
-    enum oid_value value;
     char buf[32];
 
     if (li->lex_len > 31)
-        return VAL_NONE;
+        return 0;
     memcpy (buf, li->lex_buf, li->lex_len);
     buf[li->lex_len] = '\0';
-    value = oid_getvalbyname (buf);
-    return value;
+    return yaz_string_to_oid_odr(yaz_oid_std(), CLASS_ATTSET, buf, o);
 }
 
-static int compare_term (struct yaz_pqf_parser *li, const char *src,
-                         size_t off)
+static int compare_term(struct yaz_pqf_parser *li, const char *src,
+                        size_t off)
 {
     size_t len=strlen(src);
     
@@ -62,7 +57,7 @@ static int compare_term (struct yaz_pqf_parser *li, const char *src,
     return 0;
 }
 
-static int query_token (struct yaz_pqf_parser *li)
+static int query_token(struct yaz_pqf_parser *li)
 {
     int sep_char = ' ';
     const char *sep_match;
@@ -121,9 +116,9 @@ static int query_token (struct yaz_pqf_parser *li)
     return 't';
 }
 
-static int lex (struct yaz_pqf_parser *li)
+static int lex(struct yaz_pqf_parser *li)
 {
-    return li->query_look = query_token (li);
+    return li->query_look = query_token(li);
 }
 
 static int escape_string(char *out_buf, const char *in, int len)
@@ -191,15 +186,15 @@ static int escape_string(char *out_buf, const char *in, int len)
 
 static int p_query_parse_attr(struct yaz_pqf_parser *li, ODR o,
                               int num_attr, int *attr_list,
-                              char **attr_clist, oid_value *attr_set)
+                              char **attr_clist, int **attr_set)
 {
     const char *cp;
 
     if (!(cp = strchr (li->lex_buf, '=')) ||
         (size_t) (cp-li->lex_buf) > li->lex_len)
     {
-        attr_set[num_attr] = query_oid_getvalbyname (li);
-        if (attr_set[num_attr] == VAL_NONE)
+        attr_set[num_attr] = query_oid_getvalbyname (li, o);
+        if (attr_set[num_attr] == 0)
         {
             li->error = YAZ_PQF_ERROR_ATTSET;
             return 0;
@@ -220,7 +215,7 @@ static int p_query_parse_attr(struct yaz_pqf_parser *li, ODR o,
         if (num_attr > 0)
             attr_set[num_attr] = attr_set[num_attr-1];
         else
-            attr_set[num_attr] = VAL_NONE;
+            attr_set[num_attr] = 0;
     }
     if (*li->lex_buf < '0' || *li->lex_buf > '9')
     {
@@ -245,10 +240,9 @@ static int p_query_parse_attr(struct yaz_pqf_parser *li, ODR o,
     return 1;
 }
 
-static Z_AttributesPlusTerm *rpn_term (struct yaz_pqf_parser *li, ODR o,
-                                       oid_proto proto, 
-                                       int num_attr, int *attr_list,
-                                       char **attr_clist, oid_value *attr_set)
+static Z_AttributesPlusTerm *rpn_term(struct yaz_pqf_parser *li, ODR o,
+                                      int num_attr, int *attr_list,
+                                      char **attr_clist, int **attr_set)
 {
     Z_AttributesPlusTerm *zapt;
     Odr_oct *term_octet;
@@ -282,8 +276,7 @@ static Z_AttributesPlusTerm *rpn_term (struct yaz_pqf_parser *li, ODR o,
             elements[k] =
                 (Z_AttributeElement*)odr_malloc (o,sizeof(**elements));
             elements[k]->attributeType = &attr_tmp[2*i];
-            elements[k]->attributeSet =
-                yaz_oidval_to_z3950oid(o, CLASS_ATTSET, attr_set[i]);
+            elements[k]->attributeSet = attr_set[i];
 
             if (attr_clist[i])
             {
@@ -357,9 +350,9 @@ static Z_AttributesPlusTerm *rpn_term (struct yaz_pqf_parser *li, ODR o,
     return zapt;
 }
 
-static Z_Operand *rpn_simple (struct yaz_pqf_parser *li, ODR o, oid_proto proto,
-                              int num_attr, int *attr_list, char **attr_clist,
-                              oid_value *attr_set)
+static Z_Operand *rpn_simple(struct yaz_pqf_parser *li, ODR o,
+                             int num_attr, int *attr_list, char **attr_clist,
+                             int **attr_set)
 {
     Z_Operand *zo;
 
@@ -369,8 +362,7 @@ static Z_Operand *rpn_simple (struct yaz_pqf_parser *li, ODR o, oid_proto proto,
     case 't':
         zo->which = Z_Operand_APT;
         if (!(zo->u.attributesPlusTerm =
-              rpn_term (li, o, proto, num_attr, attr_list, attr_clist,
-                        attr_set)))
+              rpn_term (li, o, num_attr, attr_list, attr_clist, attr_set)))
             return 0;
         lex (li);
         break;
@@ -492,10 +484,10 @@ static Z_ProximityOperator *rpn_proximity (struct yaz_pqf_parser *li, ODR o)
     return p;
 }
 
-static Z_Complex *rpn_complex (struct yaz_pqf_parser *li, ODR o, oid_proto proto,
-                               int num_attr, int max_attr, 
-                               int *attr_list, char **attr_clist,
-                               oid_value *attr_set)
+static Z_Complex *rpn_complex(struct yaz_pqf_parser *li, ODR o,
+                              int num_attr, int max_attr, 
+                              int *attr_list, char **attr_clist,
+                              int **attr_set)
 {
     Z_Complex *zc;
     Z_Operator *zo;
@@ -531,17 +523,17 @@ static Z_Complex *rpn_complex (struct yaz_pqf_parser *li, ODR o, oid_proto proto
     }
     lex (li);
     if (!(zc->s1 =
-          rpn_structure (li, o, proto, num_attr, max_attr, attr_list,
-                         attr_clist, attr_set)))
+          rpn_structure(li, o, num_attr, max_attr, attr_list,
+                        attr_clist, attr_set)))
         return NULL;
     if (!(zc->s2 =
-          rpn_structure (li, o, proto, num_attr, max_attr, attr_list,
-                         attr_clist, attr_set)))
+          rpn_structure(li, o, num_attr, max_attr, attr_list,
+                        attr_clist, attr_set)))
         return NULL;
     return zc;
 }
 
-static void rpn_term_type (struct yaz_pqf_parser *li, ODR o)
+static void rpn_term_type(struct yaz_pqf_parser *li, ODR o)
 {
     if (!li->query_look)
         return ;
@@ -557,21 +549,22 @@ static void rpn_term_type (struct yaz_pqf_parser *li, ODR o)
         li->term_type = Z_Term_dateTime;
     else if (compare_term (li, "null", 0))
         li->term_type = Z_Term_null;
+#if 0
     else if (compare_term(li, "range", 0))
     {
         /* prepare for external: range search .. */
         li->term_type = Z_Term_external;
         li->external_type = VAL_MULTISRCH2;
     }
+#endif
     lex (li);
 }
                            
-static Z_RPNStructure *rpn_structure (struct yaz_pqf_parser *li, ODR o,
-                                      oid_proto proto, 
-                                      int num_attr, int max_attr, 
-                                      int *attr_list,
-                                      char **attr_clist,
-                                      oid_value *attr_set)
+static Z_RPNStructure *rpn_structure(struct yaz_pqf_parser *li, ODR o,
+                                     int num_attr, int max_attr, 
+                                     int *attr_list,
+                                     char **attr_clist,
+                                     int **attr_set)
 {
     Z_RPNStructure *sz;
 
@@ -584,7 +577,7 @@ static Z_RPNStructure *rpn_structure (struct yaz_pqf_parser *li, ODR o,
     case 'p':
         sz->which = Z_RPNStructure_complex;
         if (!(sz->u.complex =
-              rpn_complex (li, o, proto, num_attr, max_attr, attr_list,
+              rpn_complex (li, o, num_attr, max_attr, attr_list,
                            attr_clist, attr_set)))
             return NULL;
         break;
@@ -592,7 +585,7 @@ static Z_RPNStructure *rpn_structure (struct yaz_pqf_parser *li, ODR o,
     case 's':
         sz->which = Z_RPNStructure_simple;
         if (!(sz->u.simple =
-              rpn_simple (li, o, proto, num_attr, attr_list,
+              rpn_simple (li, o, num_attr, attr_list,
                           attr_clist, attr_set)))
             return NULL;
         break;
@@ -614,13 +607,13 @@ static Z_RPNStructure *rpn_structure (struct yaz_pqf_parser *li, ODR o,
         num_attr++;
         lex (li);
         return
-            rpn_structure (li, o, proto, num_attr, max_attr, attr_list,
+            rpn_structure (li, o, num_attr, max_attr, attr_list,
                            attr_clist,  attr_set);
     case 'y':
         lex (li);
         rpn_term_type (li, o);
         return
-            rpn_structure (li, o, proto, num_attr, max_attr, attr_list,
+            rpn_structure (li, o, num_attr, max_attr, attr_list,
                            attr_clist, attr_set);
     case 0:                /* operator/operand expected! */
         li->error = YAZ_PQF_ERROR_MISSING;
@@ -629,35 +622,34 @@ static Z_RPNStructure *rpn_structure (struct yaz_pqf_parser *li, ODR o,
     return sz;
 }
 
-Z_RPNQuery *p_query_rpn_mk (ODR o, struct yaz_pqf_parser *li, oid_proto proto,
-                            const char *qbuf)
+Z_RPNQuery *p_query_rpn_mk(ODR o, struct yaz_pqf_parser *li, const char *qbuf)
 {
     Z_RPNQuery *zq;
     int attr_array[1024];
     char *attr_clist[512];
-    oid_value attr_set[512];
-    oid_value topSet = VAL_NONE;
+    int *attr_set[512];
+    int *top_set = 0;
 
     zq = (Z_RPNQuery *)odr_malloc (o, sizeof(*zq));
     lex (li);
     if (li->query_look == 'r')
     {
         lex (li);
-        topSet = query_oid_getvalbyname (li);
-        if (topSet == VAL_NONE)
+        top_set = query_oid_getvalbyname(li, o);
+        if (!top_set)
         {
             li->error = YAZ_PQF_ERROR_ATTSET;
             return NULL;
         }
-
         lex (li);
     }
-    if (topSet == VAL_NONE)
-        topSet = p_query_dfset;
-    if (topSet == VAL_NONE)
-        topSet = VAL_BIB1;
+    if (!top_set)
+    {
+        top_set = yaz_string_to_oid_odr(yaz_oid_std(),
+                                        CLASS_ATTSET, OID_STR_BIB1, o);
+    }
 
-    zq->attributeSetId = yaz_oidval_to_z3950oid(o, CLASS_ATTSET, topSet);
+    zq->attributeSetId = top_set;
 
     if (!zq->attributeSetId)
     {
@@ -665,8 +657,8 @@ Z_RPNQuery *p_query_rpn_mk (ODR o, struct yaz_pqf_parser *li, oid_proto proto,
         return 0;
     }
 
-    if (!(zq->RPNStructure = rpn_structure (li, o, proto, 0, 512,
-                                            attr_array, attr_clist, attr_set)))
+    if (!(zq->RPNStructure = rpn_structure(li, o, 0, 512,
+                                           attr_array, attr_clist, attr_set)))
         return 0;
     if (li->query_look)
     {
@@ -676,7 +668,7 @@ Z_RPNQuery *p_query_rpn_mk (ODR o, struct yaz_pqf_parser *li, oid_proto proto,
     return zq;
 }
 
-Z_RPNQuery *p_query_rpn (ODR o, oid_proto proto, const char *qbuf)
+Z_RPNQuery *p_query_rpn(ODR o, const char *qbuf)
 {
     struct yaz_pqf_parser li;
 
@@ -687,37 +679,41 @@ Z_RPNQuery *p_query_rpn (ODR o, oid_proto proto, const char *qbuf)
     li.term_type = Z_Term_general;
     li.query_buf = li.query_ptr = qbuf;
     li.lex_buf = 0;
-    return p_query_rpn_mk (o, &li, proto, qbuf);
+    return p_query_rpn_mk(o, &li, qbuf);
 }
 
 
-Z_AttributesPlusTerm *p_query_scan_mk (struct yaz_pqf_parser *li,
-                                       ODR o, oid_proto proto,
-                                       Odr_oid **attributeSetP,
-                                       const char *qbuf)
+Z_AttributesPlusTerm *p_query_scan_mk(struct yaz_pqf_parser *li,
+                                      ODR o, oid_proto proto,
+                                      Odr_oid **attributeSetP,
+                                      const char *qbuf)
 {
     int attr_list[1024];
     char *attr_clist[512];
-    oid_value attr_set[512];
+    int *attr_set[512];
     int num_attr = 0;
     int max_attr = 512;
-    oid_value topSet = VAL_NONE;
+    int *top_set = 0;
     Z_AttributesPlusTerm *apt;
 
     lex (li);
     if (li->query_look == 'r')
     {
         lex (li);
-        topSet = query_oid_getvalbyname (li);
-
+        top_set = query_oid_getvalbyname(li, o);
+        if (!top_set)
+        {
+            li->error = YAZ_PQF_ERROR_ATTSET;
+            return NULL;
+        }
         lex (li);
     }
-    if (topSet == VAL_NONE)
-        topSet = p_query_dfset;
-    if (topSet == VAL_NONE)
-        topSet = VAL_BIB1;
-
-    *attributeSetP = yaz_oidval_to_z3950oid (o, CLASS_ATTSET, topSet);
+    if (!top_set)
+    {
+        top_set = yaz_string_to_oid_odr(yaz_oid_std(),
+                                        CLASS_ATTSET, OID_STR_BIB1, o);
+    }
+    *attributeSetP = top_set;
 
     while (1)
     {
@@ -753,7 +749,7 @@ Z_AttributesPlusTerm *p_query_scan_mk (struct yaz_pqf_parser *li,
         li->error = YAZ_PQF_ERROR_MISSING;
         return 0;
     }
-    apt = rpn_term (li, o, proto, num_attr, attr_list, attr_clist, attr_set);
+    apt = rpn_term(li, o, num_attr, attr_list, attr_clist, attr_set);
 
     lex (li);
 
@@ -782,12 +778,6 @@ Z_AttributesPlusTerm *p_query_scan (ODR o, oid_proto proto,
     return p_query_scan_mk (&li, o, proto, attributeSetP, qbuf);
 }
 
-int p_query_attset (const char *arg)
-{
-    p_query_dfset = oid_getvalbyname (arg);
-    return (p_query_dfset == VAL_NONE) ? -1 : 0;
-}
-
 YAZ_PQF_Parser yaz_pqf_create (void)
 {
     YAZ_PQF_Parser p = (YAZ_PQF_Parser) xmalloc (sizeof(*p));
@@ -801,23 +791,23 @@ YAZ_PQF_Parser yaz_pqf_create (void)
     return p;
 }
 
-void yaz_pqf_destroy (YAZ_PQF_Parser p)
+void yaz_pqf_destroy(YAZ_PQF_Parser p)
 {
     xfree (p);
 }
 
-Z_RPNQuery *yaz_pqf_parse (YAZ_PQF_Parser p, ODR o, const char *qbuf)
+Z_RPNQuery *yaz_pqf_parse(YAZ_PQF_Parser p, ODR o, const char *qbuf)
 {
     if (!p)
         return 0;
     p->query_buf = p->query_ptr = qbuf;
     p->lex_buf = 0;
-    return p_query_rpn_mk (o, p, PROTO_Z3950, qbuf);
+    return p_query_rpn_mk (o, p, qbuf);
 }
 
-Z_AttributesPlusTerm *yaz_pqf_scan (YAZ_PQF_Parser p, ODR o,
-                                    Odr_oid **attributeSetP,
-                                    const char *qbuf)
+Z_AttributesPlusTerm *yaz_pqf_scan(YAZ_PQF_Parser p, ODR o,
+                                   Odr_oid **attributeSetP,
+                                   const char *qbuf)
 {
     if (!p)
         return 0;
index 746bcb7..ba73b6e 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: prt-ext.c,v 1.7 2007-01-03 08:42:15 adam Exp $
+ * $Id: prt-ext.c,v 1.8 2007-04-12 13:52:57 adam Exp $
  */
 
 /**
@@ -12,6 +12,7 @@
 
 #include <yaz/proto.h>
 
+#include <yaz/oid_db.h>
 #define PRT_EXT_DEBUG 0
 
 #if PRT_EXT_DEBUG
  */
 static Z_ext_typeent type_table[] =
 {
-    {VAL_SUTRS, Z_External_sutrs, (Odr_fun) z_SUTRS},
-    {VAL_EXPLAIN, Z_External_explainRecord, (Odr_fun)z_ExplainRecord},
-    {VAL_RESOURCE1, Z_External_resourceReport1, (Odr_fun)z_ResourceReport1},
-    {VAL_RESOURCE2, Z_External_resourceReport2, (Odr_fun)z_ResourceReport2},
-    {VAL_PROMPT1, Z_External_promptObject1, (Odr_fun)z_PromptObject1 },
-    {VAL_GRS1, Z_External_grs1, (Odr_fun)z_GenericRecord},
-    {VAL_EXTENDED, Z_External_extendedService, (Odr_fun)z_TaskPackage},
-    {VAL_ITEMORDER, Z_External_itemOrder, (Odr_fun)z_IOItemOrder},
-    {VAL_DIAG1, Z_External_diag1, (Odr_fun)z_DiagnosticFormat},
-    {VAL_ESPEC1, Z_External_espec1, (Odr_fun)z_Espec1},
-    {VAL_SUMMARY, Z_External_summary, (Odr_fun)z_BriefBib},
-    {VAL_OPAC, Z_External_OPAC, (Odr_fun)z_OPACRecord},
-    {VAL_SEARCHRES1, Z_External_searchResult1, (Odr_fun)z_SearchInfoReport},
-    {VAL_DBUPDATE, Z_External_update, (Odr_fun)z_IUUpdate},
-    {VAL_DBUPDATE0, Z_External_update0, (Odr_fun)z_IU0Update},
-    {VAL_DBUPDATE1, Z_External_update0, (Odr_fun)z_IU0Update},
-    {VAL_DATETIME, Z_External_dateTime, (Odr_fun)z_DateTime},
-    {VAL_UNIVERSE_REPORT, Z_External_universeReport,(Odr_fun)z_UniverseReport},
-    {VAL_ADMINSERVICE, Z_External_ESAdmin, (Odr_fun)z_Admin},
-    {VAL_USERINFO1, Z_External_userInfo1, (Odr_fun) z_OtherInformation},
-    {VAL_CHARNEG3, Z_External_charSetandLanguageNegotiation, (Odr_fun)
+    {{1, 2, 830, 10003, 5, 101,-1}, Z_External_sutrs, (Odr_fun) z_SUTRS},
+    {{1, 2, 830, 10003, 5, 100,-1}, Z_External_explainRecord, (Odr_fun)z_ExplainRecord},
+    {{1, 2, 840, 10003, 7, 1,-1}, Z_External_resourceReport1, (Odr_fun)z_ResourceReport1},
+    {{1, 2, 840, 10003, 7, 2,-1}, Z_External_resourceReport2, (Odr_fun)z_ResourceReport2},
+    {{1, 2, 840, 10003, 8, 1,-1}, Z_External_promptObject1, (Odr_fun)z_PromptObject1 },
+    {{1, 2, 840, 10003, 5, 105,-1}, Z_External_grs1, (Odr_fun)z_GenericRecord},
+    {{1, 2, 840, 10003, 5, 106,-1}, Z_External_extendedService, (Odr_fun)z_TaskPackage},
+    {{1, 2, 840, 10003, 9, 4,-1}, Z_External_itemOrder, (Odr_fun)z_IOItemOrder},
+    {{1, 2, 840, 10003, 4, 2,-1}, Z_External_diag1, (Odr_fun)z_DiagnosticFormat},
+    {{1, 2, 840, 10003, 11, 1,-1}, Z_External_espec1, (Odr_fun)z_Espec1},
+    {{1, 2, 840, 10003, 5, 103,-1}, Z_External_summary, (Odr_fun)z_BriefBib},
+    {{1, 2, 840, 10003, 5, 102,-1}, Z_External_OPAC, (Odr_fun)z_OPACRecord},
+    {{1, 2, 840, 10003, 10, 1,-1}, Z_External_searchResult1, (Odr_fun)z_SearchInfoReport},
+    {{1, 2, 840, 10003, 9, 5,-1}, Z_External_update, (Odr_fun)z_IUUpdate},
+    {{1, 2, 840, 10003, 9, 5,1,-1}, Z_External_update0, (Odr_fun)z_IU0Update},
+    {{1, 2, 840, 10003, 9, 5, 1, 1,-1}, Z_External_update0, (Odr_fun)z_IU0Update},
+    {{1, 2, 840, 10003, 10, 6,-1}, Z_External_dateTime, (Odr_fun)z_DateTime},
+    {{1, 2, 840, 10003, 7, 1000, 81, 1,-1}, Z_External_universeReport,(Odr_fun)z_UniverseReport},
+    {{1, 2, 840, 10003, 9, 1000, 81, 1,-1}, Z_External_ESAdmin, (Odr_fun)z_Admin},
+    {{1, 2, 840, 10003, 10, 3,-1}, Z_External_userInfo1, (Odr_fun) z_OtherInformation},
+    {{1, 2, 840, 10003, 15, 3,-1}, Z_External_charSetandLanguageNegotiation, (Odr_fun)
                   z_CharSetandLanguageNegotiation},
-    {VAL_PROMPT1, Z_External_acfPrompt1, (Odr_fun) z_PromptObject1},
-    {VAL_DES1, Z_External_acfDes1, (Odr_fun) z_DES_RN_Object},
-    {VAL_KRB1, Z_External_acfKrb1, (Odr_fun) z_KRBObject},
-    {VAL_MULTISRCH2, Z_External_multisrch2, (Odr_fun) z_MultipleSearchTerms_2},
-    {VAL_CQL, Z_External_CQL, (Odr_fun) z_InternationalString},
-    {VAL_NONE, 0, 0}
+    {{1, 2, 840, 10003, 8, 1,-1}, Z_External_acfPrompt1, (Odr_fun) z_PromptObject1},
+    {{1, 2, 840, 10003, 8, 2,-1}, Z_External_acfDes1, (Odr_fun) z_DES_RN_Object},
+    {{1, 2, 840, 10003, 8, 3,-1}, Z_External_acfKrb1, (Odr_fun) z_KRBObject},
+    {{1, 2, 840, 10003, 10, 5,-1}, Z_External_multisrch2, (Odr_fun) z_MultipleSearchTerms_2},
+    {{1, 2, 840, 10003, 16,  2, -1}, Z_External_CQL, (Odr_fun) z_InternationalString},
+    {{-1}, 0, 0}
 };
 
-Z_ext_typeent *z_ext_getentbyref(oid_value val)
+Z_ext_typeent *z_ext_getentbyref(const int *oid)
 {
-    Z_ext_typeent *i;
+    Z_ext_typeent *p;
 
-    for (i = type_table; i->dref != VAL_NONE; i++)
-        if (i->dref == val)
-            return i;
+    for (p = type_table; p->oid[0] != -1; p++)
+        if (!oid_oidcmp(oid, p->oid))
+            return p;
     return 0;
 }
 
@@ -86,7 +87,6 @@ Z_ext_typeent *z_ext_getentbyref(oid_value val)
 */
 int z_External(ODR o, Z_External **p, int opt, const char *name)
 {
-    oident *oid;
     Z_ext_typeent *type;
 
     static Odr_arm arm[] =
@@ -183,8 +183,7 @@ int z_External(ODR o, Z_External **p, int opt, const char *name)
 #endif
     /* Do we know this beast? */
     if (o->direction == ODR_DECODE && (*p)->direct_reference &&
-        (oid = oid_getentbyoid((*p)->direct_reference)) &&
-        (type = z_ext_getentbyref(oid->value)))
+        (type = z_ext_getentbyref((*p)->direct_reference)))
     {
         int zclass, tag, cons;
         /* OID is present and we know it */
@@ -240,18 +239,22 @@ int z_External(ODR o, Z_External **p, int opt, const char *name)
         odr_sequence_end(o);
 }
 
-Z_External *z_ext_record(ODR o, int format, const char *buf, int len)
+Z_External *z_ext_record_oid(ODR o, const int *oid, const char *buf, int len)
 {
     Z_External *thisext;
+    char oid_str_buf[OID_STR_MAX];
+    const char *oid_str;
+    int oclass;
 
+    if (!oid)
+        return 0;
     thisext = (Z_External *) odr_malloc(o, sizeof(*thisext));
     thisext->descriptor = 0;
     thisext->indirect_reference = 0;
 
-    thisext->direct_reference = 
-        yaz_oidval_to_z3950oid (o, CLASS_RECSYN, format);    
-    if (!thisext->direct_reference)
-        return 0;
+    oid_str = yaz_oid_to_string_buf(oid, &oclass, oid_str_buf);
+
+    thisext->direct_reference = odr_oiddup(o, oid);
 
     if (len < 0) /* Structured data */
     {
@@ -263,31 +266,36 @@ Z_External *z_ext_record(ODR o, int format, const char *buf, int len)
          */
         thisext->u.grs1 = (Z_GenericRecord*) buf;
 
-        switch (format)
+        if (!strcmp(oid_str, OID_STR_SUTRS))
         {
-        case VAL_SUTRS:
             thisext->which = Z_External_sutrs;
-            break;
-        case VAL_GRS1:
+        }
+        else if (!strcmp(oid_str, OID_STR_GRS1))
+        {
             thisext->which = Z_External_grs1;
-            break;
-        case VAL_EXPLAIN:
+        }
+        else if (!strcmp(oid_str, OID_STR_EXPLAIN))
+        {
             thisext->which = Z_External_explainRecord;
-            break;
-        case VAL_SUMMARY:
+        }
+        else if (!strcmp(oid_str, OID_STR_SUMMARY))
+        {
             thisext->which = Z_External_summary;
-            break;
-        case VAL_OPAC:
+        }
+        else if (!strcmp(oid_str, OID_STR_OPAC))
+        {
             thisext->which = Z_External_OPAC;
-            break;
-        case VAL_EXTENDED:
+        }
+        else if (!strcmp(oid_str, OID_STR_EXTENDED))
+        {
             thisext->which = Z_External_extendedService;
-            break;
-        default:
+        }
+        else
+        {
             return 0;
         }
     }
-    else if (format == VAL_SUTRS) /* SUTRS is a single-ASN.1-type */
+    else if (!strcmp(oid_str, OID_STR_SUTRS)) /* SUTRS is a single-ASN.1-type */
     {
         Odr_oct *sutrs = (Odr_oct *)odr_malloc(o, sizeof(*sutrs));
         
index 51f01ad..64b2ddc 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * All rights reserved.
  *
- * $Id: querytowrbuf.c,v 1.8 2007-03-19 21:07:35 adam Exp $
+ * $Id: querytowrbuf.c,v 1.9 2007-04-12 13:52:57 adam Exp $
  */
 
 /** \file querytowrbuf.c
@@ -14,6 +14,7 @@
 
 #include <yaz/logrpn.h>
 #include <yaz/querytowrbuf.h>
+#include <yaz/oid_db.h>
 
 static void yaz_term_to_wrbuf(WRBUF b, const char *term, int len)
 {
@@ -40,14 +41,18 @@ static void yaz_attribute_element_to_wrbuf(WRBUF b,
                                            const Z_AttributeElement *element)
 {
     int i;
-    char *setname="";
-    char *sep = ""; /* optional space after attrset name */
+    char oid_name_str[OID_STR_MAX];
+    const char *setname = 0;
+    char *sep = " "; /* optional space after attrset name */
     if (element->attributeSet)
     {
-        oident *attrset;
-        attrset = oid_getentbyoid (element->attributeSet);
-        setname = attrset->desc;
-        sep = " ";
+        setname = yaz_oid_to_string_buf(element->attributeSet, 
+                                        0, oid_name_str);
+    }
+    if (!setname)
+    {
+        setname = "";
+        sep = "";
     }
     switch (element->which) 
     {
@@ -181,14 +186,13 @@ static void yaz_rpnstructure_to_wrbuf(WRBUF b, const Z_RPNStructure *zs)
 
 void yaz_rpnquery_to_wrbuf(WRBUF b, const Z_RPNQuery *rpn)
 {
-    oident *attrset;
-    enum oid_value ast;
-    
-    attrset = oid_getentbyoid (rpn->attributeSetId);
-    if (attrset)
+    if (rpn->attributeSetId)
     {
-        ast = attrset->value;
-        wrbuf_printf(b, "@attrset %s ", attrset->desc);
+        char oid_name_str[OID_STR_MAX];
+        const char *oid_name = yaz_oid_to_string_buf(rpn->attributeSetId,
+                                                     0, oid_name_str);
+        if (oid_name)
+            wrbuf_printf(b, "@attrset %s ", oid_name);
     } 
     yaz_rpnstructure_to_wrbuf(b, rpn->RPNStructure);
     wrbuf_chop_right(b);
@@ -221,7 +225,7 @@ void yaz_query_to_wrbuf(WRBUF b, const Z_Query *q)
 }
 
 void yaz_scan_to_wrbuf(WRBUF b, const Z_AttributesPlusTerm *zapt,
-                       oid_value ast)
+                       const int *attrbute_set)
 {
     /* should print attr set here */
     wrbuf_printf(b, "RPN ");
index e041a2f..7f0b17d 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 2005-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: retrieval.c,v 1.17 2007-03-19 14:40:07 adam Exp $
+ * $Id: retrieval.c,v 1.18 2007-04-12 13:52:57 adam Exp $
  */
 /**
  * \file retrieval.c
@@ -20,6 +20,7 @@
 #include <yaz/nmem.h>
 #include <yaz/tpath.h>
 #include <yaz/proto.h>
+#include <yaz/oid_db.h>
 
 #if YAZ_HAVE_XML2
 #include <libxml/parser.h>
@@ -74,7 +75,7 @@ yaz_retrieval_t yaz_retrieval_create()
 {
     yaz_retrieval_t p = xmalloc(sizeof(*p));
     p->odr = odr_createmem(ODR_ENCODE);
-    p->nmem = p->odr->mem;
+    p->nmem = odr_getmem(p->odr);
     p->wr_error = wrbuf_alloc();
     p->list = 0;
     p->path = 0;
@@ -127,9 +128,11 @@ static int conf_retrieval(yaz_retrieval_t p, const xmlNode *ptr)
         if (!xmlStrcmp(attr->name, BAD_CAST "syntax") &&
             attr->children && attr->children->type == XML_TEXT_NODE)
         {
-            el->syntax = yaz_str_to_z3950oid(
-                p->odr, CLASS_RECSYN,
-                (const char *) attr->children->content);
+            el->syntax = yaz_string_to_oid_odr(
+                yaz_oid_std(),
+                CLASS_RECSYN,
+                (const char *) attr->children->content,
+                p->odr);
             if (!el->syntax)
             {
                 wrbuf_printf(p->wr_error, "Element <retrieval>: "
@@ -192,9 +195,11 @@ static int conf_retrieval(yaz_retrieval_t p, const xmlNode *ptr)
                          && attr->children 
                          && attr->children->type == XML_TEXT_NODE){
                     el->backend_syntax 
-                    = yaz_str_to_z3950oid(p->odr, CLASS_RECSYN,
-                       (const char *) attr->children->content);
-                    
+                        = yaz_string_to_oid_odr(
+                            yaz_oid_std(),
+                            CLASS_RECSYN,
+                            (const char *) attr->children->content,
+                            p->odr);
                     if (!el->backend_syntax){
                         wrbuf_printf(p->wr_error, 
                                      "Element <backend syntax='%s'>: "
index 68ff2fa..5b2ecf6 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: seshigh.c,v 1.112 2007-03-19 14:40:07 adam Exp $
+ * $Id: seshigh.c,v 1.113 2007-04-12 13:52:57 adam Exp $
  */
 /**
  * \file seshigh.c
@@ -62,7 +62,7 @@
 #include "session.h"
 #include "mime.h"
 #include <yaz/proto.h>
-#include <yaz/oid.h>
+#include <yaz/oid_db.h>
 #include <yaz/log.h>
 #include <yaz/logrpn.h>
 #include <yaz/querytowrbuf.h>
@@ -72,6 +72,7 @@
 #include <yaz/otherinfo.h>
 #include <yaz/yaz-util.h>
 #include <yaz/pquery.h>
+#include <yaz/oid_db.h>
 
 #include <yaz/srw.h>
 #include <yaz/backend.h>
@@ -586,7 +587,7 @@ static int retrieve_fetch(association *assoc, bend_fetch_rr *rr)
     {
         int r;
         const char *input_schema = yaz_get_esn(rr->comp);
-        Odr_oid *input_syntax_raw = rr->request_format_raw;
+        Odr_oid *input_syntax_raw = rr->request_format;
         
         const char *backend_schema = 0;
         Odr_oid *backend_syntax = 0;
@@ -631,19 +632,10 @@ static int retrieve_fetch(association *assoc, bend_fetch_rr *rr)
         }
         if (backend_schema)
         {
-            yaz_set_esn(&rr->comp, backend_schema, rr->stream->mem);
+            yaz_set_esn(&rr->comp, backend_schema, odr_getmem(rr->stream));
         }
         if (backend_syntax)
-        {
-            oident *oident_syntax = oid_getentbyoid(backend_syntax);
-
-            rr->request_format_raw = backend_syntax;
-            
-            if (oident_syntax)
-                rr->request_format = oident_syntax->value;
-            else
-                rr->request_format = VAL_NONE;
-        }
+            rr->request_format = backend_syntax;
     }
     (*assoc->init->bend_fetch)(assoc->backend, rr);
     if (rc && rr->record && rr->errcode == 0 && rr->len > 0)
@@ -666,11 +658,7 @@ static int retrieve_fetch(association *assoc, bend_fetch_rr *rr)
         wrbuf_destroy(output_record);
     }
     if (match_syntax)
-    {
-        struct oident *oi = oid_getentbyoid(match_syntax);
-        rr->output_format = oi ? oi->value : VAL_NONE;
-        rr->output_format_raw = match_syntax;
-    }
+        rr->output_format = match_syntax;
     if (match_schema)
         rr->schema = odr_strdup(rr->stream, match_schema);
     return 0;
@@ -691,10 +679,10 @@ static int srw_bend_fetch(association *assoc, int pos,
     rr.setname = "default";
     rr.number = pos;
     rr.referenceId = 0;
-    rr.request_format = VAL_TEXT_XML;
-    rr.request_format_raw = yaz_oidval_to_z3950oid(assoc->decode,
-                                                   CLASS_RECSYN,
-                                                   VAL_TEXT_XML);
+    rr.request_format = yaz_string_to_oid_odr(yaz_oid_std(),
+                                              CLASS_RECSYN,
+                                              OID_STR_XML,
+                                              assoc->decode);
     rr.comp = (Z_RecordComposition *)
             odr_malloc(assoc->decode, sizeof(*rr.comp));
     rr.comp->which = Z_RecordComp_complex;
@@ -1023,7 +1011,6 @@ static void srw_bend_search(association *assoc, request *req,
                         bprr->setname = "default";
                         bprr->start = start;
                         bprr->number = number;
-                        bprr->format = VAL_TEXT_XML;
                         if (srw_req->recordSchema)
                         {
                             bprr->comp = (Z_RecordComposition *) odr_malloc(assoc->decode,
@@ -1296,20 +1283,11 @@ static void srw_bend_scan(association *assoc, request *req,
         if (srw_req->query_type == Z_SRW_query_type_pqf &&
             assoc->init->bend_scan)
         {
-            Odr_oid *scan_attributeSet = 0;
-            oident *attset;
             YAZ_PQF_Parser pqf_parser = yaz_pqf_create();
             
             bsrr->term = yaz_pqf_scan(pqf_parser, assoc->decode,
-                                      &scan_attributeSet, 
+                                      &bsrr->attributeset, 
                                       srw_req->scanClause.pqf); 
-            if (scan_attributeSet &&
-                (attset = oid_getentbyoid(scan_attributeSet)) &&
-                (attset->oclass == CLASS_ATTSET ||
-                 attset->oclass == CLASS_GENERAL))
-                bsrr->attributeset = attset->value;
-            else
-                bsrr->attributeset = VAL_NONE;
             yaz_pqf_destroy(pqf_parser);
             bsrr->scanClause = 0;
             ((int (*)(void *, bend_scan_rr *))
@@ -1321,7 +1299,7 @@ static void srw_bend_scan(association *assoc, request *req,
         {
             int srw_error;
             bsrr->scanClause = 0;
-            bsrr->attributeset = VAL_NONE;
+            bsrr->attributeset = 0;
             bsrr->term = odr_malloc(assoc->decode, sizeof(*bsrr->term));
             srw_error = cql2pqf_scan(assoc->encode,
                                      srw_req->scanClause.cql,
@@ -1341,7 +1319,7 @@ static void srw_bend_scan(association *assoc, request *req,
                  && assoc->init->bend_srw_scan)
         {
             bsrr->term = 0;
-            bsrr->attributeset = VAL_NONE;
+            bsrr->attributeset = 0;
             bsrr->scanClause = srw_req->scanClause.cql;
             ((int (*)(void *, bend_scan_rr *))
              (*assoc->init->bend_srw_scan))(assoc->backend, bsrr);
@@ -2170,7 +2148,9 @@ static int process_z_response(association *assoc, request *req, Z_APDU *res)
 
 static char *get_vhost(Z_OtherInformation *otherInfo)
 {
-    return yaz_oi_get_string_oidval(&otherInfo, VAL_PROXY, 1, 0);
+    const int *oid = yaz_string_to_oid(yaz_oid_std(),
+                                       CLASS_USERINFO, OID_STR_PROXY);
+    return yaz_oi_get_string_oid(&otherInfo, oid, 1, 0);
 }
 
 /*
@@ -2364,7 +2344,7 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb)
                 assoc->init->implementation_name,
                 odr_prepend(assoc->encode, "GFS", resp->implementationName));
 
-    version = odr_strdup(assoc->encode, "$Revision: 1.112 $");
+    version = odr_strdup(assoc->encode, "$Revision: 1.113 $");
     if (strlen(version) > 10)   /* check for unexpanded CVS strings */
         version[strlen(version)-2] = '\0';
     resp->implementationVersion = odr_prepend(assoc->encode,
@@ -2476,7 +2456,7 @@ static Z_NamePlusRecord *surrogatediagrec(association *assoc,
 
 static Z_Records *pack_records(association *a, char *setname, int start,
                                int *num, Z_RecordComposition *comp,
-                               int *next, int *pres, oid_value format,
+                               int *next, int *pres,
                                Z_ReferenceId *referenceId,
                                int *oid, int *errcode)
 {
@@ -2520,10 +2500,8 @@ static Z_Records *pack_records(association *a, char *setname, int start,
         freq.surrogate_flag = 0;
         freq.number = recno;
         freq.comp = comp;
-        freq.request_format = format;
-        freq.request_format_raw = oid;
-        freq.output_format = format;
-        freq.output_format_raw = 0;
+        freq.request_format = oid;
+        freq.output_format = 0;
         freq.stream = a->encode;
         freq.print = a->print;
         freq.referenceId = referenceId;
@@ -2615,13 +2593,10 @@ static Z_Records *pack_records(association *a, char *setname, int start,
             thisrec->databaseName = 0;
         thisrec->which = Z_NamePlusRecord_databaseRecord;
 
-        if (freq.output_format_raw)
-        {
-            struct oident *ident = oid_getentbyoid(freq.output_format_raw);
-            freq.output_format = ident->value;
-        }
-        thisrec->u.databaseRecord = z_ext_record(a->encode, freq.output_format,
-                                                 freq.record, freq.len);
+        if (!freq.output_format)
+            freq.output_format = freq.request_format;
+        thisrec->u.databaseRecord = z_ext_record_oid(
+            a->encode, freq.output_format, freq.record, freq.len);
         if (!thisrec->u.databaseRecord)
             return 0;
         reclist->records[reclist->num_records] = thisrec;
@@ -2668,7 +2643,7 @@ static Z_APDU *process_searchRequest(association *assoc, request *reqb,
         bsrr->basenames = req->databaseNames;
         bsrr->query = req->query;
         bsrr->stream = assoc->encode;
-        nmem_transfer(bsrr->stream->mem, reqb->request_mem);
+        nmem_transfer(odr_getmem(bsrr->stream), reqb->request_mem);
         bsrr->decode = assoc->decode;
         bsrr->print = assoc->print;
         bsrr->hits = 0;
@@ -2774,15 +2749,7 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb,
 
         if (*toget && !resp->records)
         {
-            oident *prefformat;
-            oid_value form;
             int *presst = odr_intdup(assoc->encode, 0);
-
-            if (!(prefformat = oid_getentbyoid(req->preferredRecordSyntax)))
-                form = VAL_NONE;
-            else
-                form = prefformat->value;
-
             /* Call bend_present if defined */
             if (assoc->init->bend_present)
             {
@@ -2791,7 +2758,7 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb,
                 bprr->setname = req->resultSetName;
                 bprr->start = 1;
                 bprr->number = *toget;
-                bprr->format = form;
+                bprr->format = req->preferredRecordSyntax;
                 bprr->comp = compp;
                 bprr->referenceId = req->referenceId;
                 bprr->stream = assoc->encode;
@@ -2812,9 +2779,10 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb,
             }
 
             if (!resp->records)
-                resp->records = pack_records(assoc, req->resultSetName, 1,
-                                             toget, compp, next, presst, form, req->referenceId,
-                                             req->preferredRecordSyntax, NULL);
+                resp->records = pack_records(
+                    assoc, req->resultSetName, 1,
+                    toget, compp, next, presst, req->referenceId,
+                    req->preferredRecordSyntax, NULL);
             if (!resp->records)
                 return 0;
             resp->numberOfRecordsReturned = toget;
@@ -2889,8 +2857,6 @@ static Z_APDU *process_presentRequest(association *assoc, request *reqb,
                                       int *fd)
 {
     Z_PresentRequest *req = reqb->apdu_request->u.presentRequest;
-    oident *prefformat;
-    oid_value form;
     Z_APDU *apdu;
     Z_PresentResponse *resp;
     int *next;
@@ -2900,10 +2866,6 @@ static Z_APDU *process_presentRequest(association *assoc, request *reqb,
 
     yaz_log(log_requestdetail, "Got PresentRequest.");
 
-    if (!(prefformat = oid_getentbyoid(req->preferredRecordSyntax)))
-        form = VAL_NONE;
-    else
-        form = prefformat->value;
     resp = (Z_PresentResponse *)odr_malloc (assoc->encode, sizeof(*resp));
     resp->records = 0;
     resp->presentStatus = odr_intdup(assoc->encode, 0);
@@ -2914,7 +2876,7 @@ static Z_APDU *process_presentRequest(association *assoc, request *reqb,
         bprr->setname = req->resultSetId;
         bprr->start = *req->resultSetStartPoint;
         bprr->number = *req->numberOfRecordsRequested;
-        bprr->format = form;
+        bprr->format = req->preferredRecordSyntax;
         bprr->comp = req->recordComposition;
         bprr->referenceId = req->referenceId;
         bprr->stream = assoc->encode;
@@ -2951,7 +2913,7 @@ static Z_APDU *process_presentRequest(association *assoc, request *reqb,
             pack_records(assoc, req->resultSetId, *req->resultSetStartPoint,
                          num, req->recordComposition, next,
                          resp->presentStatus,
-                         form, req->referenceId, req->preferredRecordSyntax, 
+                         req->referenceId, req->preferredRecordSyntax, 
                          &errcode);
     }
     if (log_request)
@@ -2995,7 +2957,6 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb, int *fd)
     Z_ListEntries *ents = (Z_ListEntries *)
         odr_malloc (assoc->encode, sizeof(*ents));
     Z_DiagRecs *diagrecs_p = NULL;
-    oident *attset;
     bend_scan_rr *bsrr = (bend_scan_rr *)
         odr_malloc (assoc->encode, sizeof(*bsrr));
     struct scan_entry *save_entries;
@@ -3063,12 +3024,7 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb, int *fd)
     }
     save_entries = bsrr->entries;  /* save it so we can compare later */
 
-    if (req->attributeSet &&
-        (attset = oid_getentbyoid(req->attributeSet)) &&
-        (attset->oclass == CLASS_ATTSET || attset->oclass == CLASS_GENERAL))
-        bsrr->attributeset = attset->value;
-    else
-        bsrr->attributeset = VAL_NONE;
+    bsrr->attributeset = req->attributeSet;
     log_scan_term_level (log_requestdetail, req->termListAndStartPoint, 
             bsrr->attributeset);
     bsrr->term_position = req->preferredPositionInResponse ?
@@ -3542,9 +3498,13 @@ static Z_APDU *process_ESRequest(association *assoc, request *reqb, int *fd)
     }
     /* Do something with the members of bend_extendedservice */
     if (esrequest.taskPackage)
-        resp->taskPackage = z_ext_record (assoc->encode, VAL_EXTENDED,
-                                         (const char *)  esrequest.taskPackage,
-                                          -1);
+    {
+        const int *oid = yaz_string_to_oid(yaz_oid_std(),
+                                           CLASS_EXTSERV, OID_STR_EXTENDED);
+        resp->taskPackage = z_ext_record_oid(assoc->encode, oid,
+                                             (const char *)  esrequest.taskPackage,
+                                             -1);
+    }
     yaz_log(YLOG_DEBUG,"Send the result apdu");
     return apdu;
 }
index e0cba4c..42573ba 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: session.h,v 1.13 2007-01-03 08:42:15 adam Exp $
+ * $Id: session.h,v 1.14 2007-04-12 13:52:57 adam Exp $
  */
 /**
  * \file session.h
@@ -14,7 +14,6 @@
 #include <yaz/comstack.h>
 #include <yaz/cql.h>
 #include <yaz/odr.h>
-#include <yaz/oid.h>
 #include <yaz/proto.h>
 #include <yaz/backend.h>
 #include <yaz/retrieval.h>
index 3ca7e03..b76a253 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: sortspec.c,v 1.8 2007-01-03 08:42:15 adam Exp $
+ * $Id: sortspec.c,v 1.9 2007-04-12 13:52:57 adam Exp $
  */
 /**
  * \file sortspec.c
@@ -14,8 +14,8 @@
 #include <stdlib.h>
 
 #include <yaz/proto.h>
-#include <yaz/oid.h>
 #include <yaz/sortspec.h>
+#include <yaz/oid_db.h>
 
 Z_SortKeySpecList *yaz_sort_spec (ODR out, const char *arg)
 {
@@ -50,7 +50,8 @@ Z_SortKeySpecList *yaz_sort_spec (ODR out, const char *arg)
             sk->u.sortAttributes = (Z_SortAttributes *)
                 odr_malloc (out, sizeof(*sk->u.sortAttributes));
             sk->u.sortAttributes->id = 
-                yaz_oidval_to_z3950oid(out, CLASS_ATTSET, VAL_BIB1);
+                yaz_string_to_oid_odr(yaz_oid_std(),
+                                      CLASS_ATTSET, OID_STR_BIB1, out);
             sk->u.sortAttributes->list = (Z_AttributeList *)
                 odr_malloc (out, sizeof(*sk->u.sortAttributes->list));
             sk->u.sortAttributes->list->attributes = (Z_AttributeElement **)
index a66560b..994a90e 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * All rights reserved.
  *
- * $Id: xmlquery.c,v 1.12 2007-01-03 08:42:15 adam Exp $
+ * $Id: xmlquery.c,v 1.13 2007-04-12 13:52:57 adam Exp $
  */
 
 /** \file xmlquery.c
@@ -26,12 +26,12 @@ void yaz_query2xml_attribute_element(const Z_AttributeElement *element,
 {
     char formstr[30];
     const char *setname = 0;
+    char oid_name_str[OID_STR_MAX];
     
     if (element->attributeSet)
     {
-        oident *attrset;
-        attrset = oid_getentbyoid (element->attributeSet);
-        setname = attrset->desc;
+        setname = yaz_oid_to_string_buf(element->attributeSet,
+                                        0, oid_name_str);
     }
 
     if (element->which == Z_AttributeValue_numeric)
@@ -228,9 +228,14 @@ xmlNodePtr yaz_query2xml_rpnstructure(const Z_RPNStructure *zs,
 
 xmlNodePtr yaz_query2xml_rpn(const Z_RPNQuery *rpn, xmlNodePtr parent)
 {
-    oident *attrset = oid_getentbyoid (rpn->attributeSetId);
-    if (attrset && attrset->value)
-        xmlNewProp(parent, BAD_CAST "set", BAD_CAST attrset->desc);
+    if (rpn->attributeSetId)
+    {
+        char oid_name_str[OID_STR_MAX];
+        const char *setname = yaz_oid_to_string_buf(rpn->attributeSetId,
+                                                    0, oid_name_str);
+        if (setname)
+            xmlNewProp(parent, BAD_CAST "set", BAD_CAST setname);
+    }
     return yaz_query2xml_rpnstructure(rpn->RPNStructure, parent);
 }
 
@@ -452,8 +457,10 @@ void yaz_xml2query_attribute_element(const xmlNode *ptr,
         
     *elem = (Z_AttributeElement *) odr_malloc(odr, sizeof(**elem));
     if (set)
-        (*elem)->attributeSet = yaz_str_to_z3950oid(odr, CLASS_ATTSET,
-                                                    (const char *)set);
+        (*elem)->attributeSet = yaz_string_to_oid_odr(yaz_oid_std(),
+                                                      CLASS_ATTSET,
+                                                      (const char *) set,
+                                                      odr);
     else
         (*elem)->attributeSet = 0;
     (*elem)->attributeType = intVal(odr, (const char *) type);
@@ -500,7 +507,7 @@ void yaz_xml2query_attribute_element(const xmlNode *ptr,
 
 char *strVal(const xmlNode *ptr_cdata, ODR odr)
 {
-    return nmem_text_node_cdata(ptr_cdata, odr->mem);
+    return nmem_text_node_cdata(ptr_cdata, odr_getmem(odr));
 }
 
 void yaz_xml2query_term(const xmlNode *ptr,
@@ -711,7 +718,8 @@ void yaz_xml2query_rpn(const xmlNode *ptr, Z_RPNQuery **query, ODR odr,
 
     *query = (Z_RPNQuery*) odr_malloc(odr, sizeof(Z_RPNQuery));
     if (set)
-        (*query)->attributeSetId = yaz_str_to_z3950oid(odr, CLASS_ATTSET, set);
+        (*query)->attributeSetId = yaz_string_to_oid_odr(yaz_oid_std(),
+                                                         CLASS_ATTSET, set, odr);
     else
         (*query)->attributeSetId = 0;
     yaz_xml2query_rpnstructure(ptr->children, &(*query)->RPNStructure,
diff --git a/src/z3950oid.c b/src/z3950oid.c
deleted file mode 100644 (file)
index b2cdb9e..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 1995-2007, Index Data ApS
- * See the file LICENSE for details.
- *
- * $Id: z3950oid.c,v 1.6 2007-01-03 08:42:15 adam Exp $
- */
-
-/** \file z3950oid.c
-    \brief Z3950 OID conversion utilities
-*/
-
-#if HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <yaz/proto.h>
-
-Odr_oid *yaz_oidval_to_z3950oid (ODR o, int oid_class, int oid_value)
-{
-    oident ident;
-    int oid[OID_SIZE];
-
-    ident.proto = PROTO_Z3950;
-    ident.oclass = (enum oid_class) oid_class;
-    ident.value = (enum oid_value) oid_value;
-
-    if (ident.value == VAL_NONE)
-        return 0;
-
-    return odr_oiddup(o, oid_ent_to_oid(&ident, oid));
-}
-
-Odr_oid *yaz_str_to_z3950oid (ODR o, int oid_class, const char *str)
-{
-    struct oident ident;
-    int oid[OID_SIZE];
-
-    ident.proto = PROTO_Z3950;
-    ident.oclass = (enum oid_class) oid_class;
-    ident.value = oid_getvalbyname(str);
-
-    if (ident.value == VAL_NONE)
-        return 0;
-
-    return odr_oiddup(o, oid_ent_to_oid(&ident, oid));
-}
-
-const char *yaz_z3950oid_to_str (Odr_oid *oid, int *oid_class)
-{
-    struct oident *ident = oid_getentbyoid(oid);
-
-    if (!ident || ident->value == VAL_NONE)
-        return 0;
-    *oid_class = ident->oclass;
-    return ident->desc;
-}
-
-
-const char* yaz_z3950_oid_value_to_str(oid_value ov, oid_class oc)
-{
-    struct oident tmpentry;
-    int tmp_oid[OID_SIZE];
-     
-    tmpentry.proto = PROTO_Z3950;
-    tmpentry.oclass = oc;
-    tmpentry.value = ov; 
-    
-    if( oid_ent_to_oid(&tmpentry,tmp_oid) ) 
-    {
-        return tmpentry.desc;
-    } 
-    else 
-    {
-        return "";
-    }
-}
-/*
- * Local variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- * vim: shiftwidth=4 tabstop=8 expandtab
- */
-
index 8537a89..e8785ef 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: zget.c,v 1.12 2007-01-03 08:42:15 adam Exp $
+ * $Id: zget.c,v 1.13 2007-04-12 13:52:57 adam Exp $
  */
 /**
  * \file zget.c
@@ -10,6 +10,7 @@
  */
 
 #include <yaz/proto.h>
+#include <yaz/oid_db.h>
 
 Z_InitRequest *zget_InitRequest(ODR o)
 {
@@ -505,7 +506,8 @@ Z_DefaultDiagFormat *zget_DefaultDiagFormat(ODR o, int error,
     Z_DefaultDiagFormat *dr = (Z_DefaultDiagFormat *) 
         odr_malloc (o, sizeof(*dr));
     
-    dr->diagnosticSetId = yaz_oidval_to_z3950oid (o, CLASS_DIAGSET, VAL_BIB1);
+    dr->diagnosticSetId = yaz_string_to_oid_odr(
+        yaz_oid_std(), CLASS_DIAGSET, OID_STR_BIB1, o);
     dr->condition = odr_intdup(o, error);
     dr->which = Z_DefaultDiagFormat_v2Addinfo;
     dr->u.v2Addinfo = odr_strdup (o, addinfo ? addinfo : "");
@@ -550,7 +552,6 @@ Z_NamePlusRecord *zget_surrogateDiagRec(ODR o, const char *dbname,
 Z_External *zget_init_diagnostics(ODR odr, int error, const char *addinfo)
 {
     Z_External *x, *x2;
-    oident oid;
     Z_OtherInformation *u;
     Z_OtherInformationUnit *l;
     Z_DiagnosticFormat *d;
@@ -559,10 +560,10 @@ Z_External *zget_init_diagnostics(ODR odr, int error, const char *addinfo)
     x = (Z_External*) odr_malloc(odr, sizeof *x);
     x->descriptor = 0;
     x->indirect_reference = 0;  
-    oid.proto = PROTO_Z3950;
-    oid.oclass = CLASS_USERINFO;
-    oid.value = VAL_USERINFO1;
-    x->direct_reference = odr_oiddup(odr, oid_getoidbyent(&oid));
+    x->direct_reference = yaz_string_to_oid_odr(yaz_oid_std(),
+                                                CLASS_USERINFO,
+                                                OID_STR_USERINFO_1,
+                                                odr);
     x->which = Z_External_userInfo1;
 
     u = odr_malloc(odr, sizeof *u);
@@ -578,9 +579,10 @@ Z_External *zget_init_diagnostics(ODR odr, int error, const char *addinfo)
     l->information.externallyDefinedInfo = x2;
     x2->descriptor = 0;
     x2->indirect_reference = 0;
-    oid.oclass = CLASS_DIAGSET;
-    oid.value = VAL_DIAG1;
-    x2->direct_reference = odr_oiddup(odr, oid_getoidbyent(&oid));
+    x2->direct_reference = yaz_string_to_oid_odr(yaz_oid_std(),
+                                                 CLASS_DIAGSET,
+                                                 OID_STR_DIAG1,
+                                                 odr);
     x2->which = Z_External_diag1;
 
     d = (Z_DiagnosticFormat*) odr_malloc(odr, sizeof *d);
@@ -600,7 +602,6 @@ Z_External *zget_init_diagnostics_octet(ODR odr, int error,
                                         const char *addinfo)
 {
     Z_External *x, *x2;
-    oident oid;
     Z_OtherInformation *u;
     Z_OtherInformationUnit *l;
     Z_DiagnosticFormat *d;
@@ -621,10 +622,11 @@ Z_External *zget_init_diagnostics_octet(ODR odr, int error,
     l->information.externallyDefinedInfo = x2;
     x2->descriptor = 0;
     x2->indirect_reference = 0;
-    oid.oclass = CLASS_DIAGSET;
-    oid.proto = PROTO_Z3950;
-    oid.value = VAL_DIAG1;
-    x2->direct_reference = odr_oiddup(odr, oid_getoidbyent(&oid));
+
+    x2->direct_reference = yaz_string_to_oid_odr(yaz_oid_std(),
+                                                 CLASS_DIAGSET,
+                                                 OID_STR_DIAG1,
+                                                 odr);
     x2->which = Z_External_diag1;
 
     d = (Z_DiagnosticFormat*) odr_malloc(odr, sizeof *d);
@@ -647,10 +649,10 @@ Z_External *zget_init_diagnostics_octet(ODR odr, int error,
     x = (Z_External*) odr_malloc(odr, sizeof *x);
     x->descriptor = 0;
     x->indirect_reference = 0;  
-    oid.proto = PROTO_Z3950;
-    oid.oclass = CLASS_USERINFO;
-    oid.value = VAL_USERINFO1;
-    x->direct_reference = odr_oiddup(odr, oid_getoidbyent(&oid));
+    x->direct_reference = yaz_string_to_oid_odr(yaz_oid_std(),
+                                                CLASS_USERINFO,
+                                                OID_STR_USERINFO_1,
+                                                odr);
 
     x->which = Z_External_octet;
     x->u.octet_aligned = (Odr_oct *) odr_malloc(odr, sizeof(Odr_oct));
index bf4beb0..a67405a 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: zoom-c.c,v 1.122 2007-03-21 11:27:46 adam Exp $
+ * $Id: zoom-c.c,v 1.123 2007-04-12 13:52:57 adam Exp $
  */
 /**
  * \file zoom-c.c
@@ -45,9 +45,10 @@ static char *cql2pqf(ZOOM_connection c, const char *cql);
  * This wrapper is just for logging failed lookups.  It would be nicer
  * if it could cause failure when a lookup fails, but that's hard.
  */
-static Odr_oid *zoom_yaz_str_to_z3950oid(ZOOM_connection c,
-                                         int oid_class, const char *str) {
-    Odr_oid *res = yaz_str_to_z3950oid(c->odr_out, oid_class, str);
+static int *zoom_yaz_str_to_z3950oid(ZOOM_connection c,
+                                     int oid_class, const char *str) {
+    int *res = yaz_string_to_oid_odr(yaz_oid_std(), oid_class, str,
+                                     c->odr_out);
     if (res == 0)
         yaz_log(YLOG_WARN, "%p OID lookup (%d, '%s') failed",
                 c, (int) oid_class, str);
@@ -393,7 +394,7 @@ static char **set_DatabaseNames(ZOOM_connection con, ZOOM_options options,
     }
     if (!cp)
         cp = "Default";
-    nmem_strsplit(odr->mem, "+", cp,  &databaseNames, num);
+    nmem_strsplit(odr_getmem(odr), "+", cp,  &databaseNames, num);
     return databaseNames;
 }
 
@@ -583,7 +584,7 @@ ZOOM_API(int)
     s->query_string = odr_strdup(s->odr, str);
     s->z_query = (Z_Query *) odr_malloc(s->odr, sizeof(*s->z_query));
     s->z_query->which = Z_Query_type_1;
-    s->z_query->u.type_1 =  p_query_rpn(s->odr, PROTO_Z3950, str);
+    s->z_query->u.type_1 =  p_query_rpn(s->odr, str);
     if (!s->z_query->u.type_1)
     {
         yaz_log(log_details, "%p ZOOM_query_prefix str=%s failed", s, str);
@@ -1172,11 +1173,11 @@ static void otherInfo_attach(ZOOM_connection c, Z_APDU *a, ODR out)
     for (i = 0; i<200; i++)
     {
         size_t len;
+        int *oid;
         Z_OtherInformation **oi;
         char buf[80];
         const char *val;
         const char *cp;
-        int oidval;
 
         sprintf(buf, "otherInfo%d", i);
         val = ZOOM_options_get(c->options, buf);
@@ -1190,12 +1191,14 @@ static void otherInfo_attach(ZOOM_connection c, Z_APDU *a, ODR out)
             len = sizeof(buf)-1;
         memcpy(buf, val, len);
         buf[len] = '\0';
-        oidval = oid_getvalbyname(buf);
-        if (oidval == VAL_NONE)
+        
+        oid = yaz_string_to_oid_odr(yaz_oid_std(), CLASS_USERINFO,
+                                    buf, out);
+        if (!oid)
             continue;
         
         yaz_oi_APDU(a, &oi);
-        yaz_oi_set_string_oidval(oi, out, oidval, 1, cp+1);
+        yaz_oi_set_string_oid(oi, out, oid, 1, cp+1);
     }
 }
 
@@ -1204,15 +1207,19 @@ static int encode_APDU(ZOOM_connection c, Z_APDU *a, ODR out)
     assert(a);
     if (c->cookie_out)
     {
+        const int *oid = yaz_string_to_oid(
+            yaz_oid_std(), CLASS_USERINFO, OID_STR_COOKIE);
         Z_OtherInformation **oi;
         yaz_oi_APDU(a, &oi);
-        yaz_oi_set_string_oidval(oi, out, VAL_COOKIE, 1, c->cookie_out);
+        yaz_oi_set_string_oid(oi, out, oid, 1, c->cookie_out);
     }
     if (c->client_IP)
     {
+        const int *oid = yaz_string_to_oid(
+            yaz_oid_std(), CLASS_USERINFO, OID_STR_CLIENT_IP);
         Z_OtherInformation **oi;
         yaz_oi_APDU(a, &oi);
-        yaz_oi_set_string_oidval(oi, out, VAL_CLIENT_IP, 1, c->client_IP);
+        yaz_oi_set_string_oid(oi, out, oid, 1, c->client_IP);
     }
     otherInfo_attach(c, a, out);
     if (!z_APDU(out, &a, 0, 0))
@@ -1291,7 +1298,7 @@ static zoom_ret ZOOM_connection_send_init(ZOOM_connection c)
                     odr_prepend(c->odr_out, "ZOOM-C",
                                 ireq->implementationName));
     
-    version = odr_strdup(c->odr_out, "$Revision: 1.122 $");
+    version = odr_strdup(c->odr_out, "$Revision: 1.123 $");
     if (strlen(version) > 10)   /* check for unexpanded CVS strings */
         version[strlen(version)-2] = '\0';
     ireq->implementationVersion = 
@@ -1349,8 +1356,12 @@ static zoom_ret ZOOM_connection_send_init(ZOOM_connection c)
         ireq->idAuthentication = auth;
     }
     if (c->proxy)
-        yaz_oi_set_string_oidval(&ireq->otherInfo, c->odr_out,
-                                 VAL_PROXY, 1, c->host_port);
+    {
+        const int *oid = yaz_string_to_oid(
+            yaz_oid_std(), CLASS_USERINFO, OID_STR_CLIENT_IP);
+        yaz_oi_set_string_oid(&ireq->otherInfo, c->odr_out,
+                              oid, 1, c->host_port);
+    }
     if (c->charset || c->lang)
     {
         Z_OtherInformation **oi;
@@ -1646,7 +1657,8 @@ static void response_default_diag(ZOOM_connection c, Z_DefaultDiagFormat *r)
     xfree(c->addinfo);
     c->addinfo = 0;
     set_dset_error(c, *r->condition,
-                   yaz_z3950oid_to_str(r->diagnosticSetId, &oclass),
+                   yaz_oid_to_string(yaz_oid_std(), 
+                                     r->diagnosticSetId, &oclass),
                    addinfo, 0);
 }
 
@@ -1866,7 +1878,9 @@ ZOOM_API(int)
                 break;
             }
             if (diagset)
-                *diagset = yaz_z3950oid_to_str(ddf->diagnosticSetId, &oclass);
+                *diagset =
+                    yaz_oid_to_string(yaz_oid_std(),
+                                      ddf->diagnosticSetId, &oclass);
         }
         else
         {
@@ -1950,9 +1964,7 @@ ZOOM_API(const char *)
         if (npr->which == Z_NamePlusRecord_databaseRecord)
         {
             Z_External *r = (Z_External *) npr->u.databaseRecord;
-            oident *ent = oid_getentbyoid(r->direct_reference);
-            if (ent)
-                desc = ent->desc;
+            desc = yaz_oid_to_string(yaz_oid_std(), r->direct_reference, 0);
         }
         if (!desc)
             desc = "none";
@@ -1967,7 +1979,7 @@ ZOOM_API(const char *)
     if (!strcmp(type, "render"))
     {
         Z_External *r = (Z_External *) npr->u.databaseRecord;
-        oident *ent = oid_getentbyoid(r->direct_reference);
+        const int *oid = r->direct_reference;
 
         /* render bibliographic record .. */
         if (r->which == Z_External_OPAC)
@@ -1975,7 +1987,7 @@ ZOOM_API(const char *)
             r = r->u.opac->bibliographicRecord;
             if (!r)
                 return 0;
-            ent = oid_getentbyoid(r->direct_reference);
+            oid = r->direct_reference;
         }
         if (r->which == Z_External_sutrs)
             return record_iconv_return(rec, len,
@@ -1984,18 +1996,9 @@ ZOOM_API(const char *)
                                        charset);
         else if (r->which == Z_External_octet)
         {
-            const char *ret_buf;
-            switch (ent->value)
+            if (yaz_oid_is_iso2709(oid))
             {
-            case VAL_SOIF:
-            case VAL_HTML:
-            case VAL_SUTRS:
-                break;
-            case VAL_TEXT_XML:
-            case VAL_APPLICATION_XML:
-                break;
-            default:
-                ret_buf = marc_iconv_return(
+                const char *ret_buf = marc_iconv_return(
                     rec, YAZ_MARC_LINE, len,
                     (const char *) r->u.octet_aligned->buf,
                     r->u.octet_aligned->len,
@@ -2024,7 +2027,7 @@ ZOOM_API(const char *)
     else if (!strcmp(type, "xml"))
     {
         Z_External *r = (Z_External *) npr->u.databaseRecord;
-        oident *ent = oid_getentbyoid(r->direct_reference);
+        const int *oid = r->direct_reference;
 
         /* render bibliographic record .. */
         if (r->which == Z_External_OPAC)
@@ -2032,7 +2035,7 @@ ZOOM_API(const char *)
             r = r->u.opac->bibliographicRecord;
             if (!r)
                 return 0;
-            ent = oid_getentbyoid(r->direct_reference);
+            oid = r->direct_reference;
         }
         
         if (r->which == Z_External_sutrs)
@@ -2042,20 +2045,10 @@ ZOOM_API(const char *)
                                        charset);
         else if (r->which == Z_External_octet)
         {
-            const char *ret_buf;
             int marc_decode_type = YAZ_MARC_MARCXML;
-
-            switch (ent->value)
+            if (yaz_oid_is_iso2709(oid))
             {
-            case VAL_SOIF:
-            case VAL_HTML:
-            case VAL_SUTRS:
-                break;
-            case VAL_TEXT_XML:
-            case VAL_APPLICATION_XML:
-                break;
-            default:
-                ret_buf = marc_iconv_return(
+                const char *ret_buf = marc_iconv_return(
                     rec, marc_decode_type, len,
                     (const char *) r->u.octet_aligned->buf,
                     r->u.octet_aligned->len,
@@ -2272,7 +2265,7 @@ static void handle_records(ZOOM_connection c, Z_Records *sr,
                     resultset, *start, *count);
 
             /* transfer our response to search_nmem .. we need it later */
-            nmem_transfer(resultset->odr->mem, nmem);
+            nmem_transfer(odr_getmem(resultset->odr), nmem);
             nmem_destroy(nmem);
             if (present_phase && p->num_records == 0)
             {
@@ -2451,7 +2444,7 @@ static int scan_response(ZOOM_connection c, Z_ScanResponse *res)
     if (res->entries && res->entries->nonsurrogateDiagnostics)
         response_diag(c, res->entries->nonsurrogateDiagnostics[0]);
     scan->scan_response = res;
-    nmem_transfer(scan->odr->mem, nmem);
+    nmem_transfer(odr_getmem(scan->odr), nmem);
     if (res->stepSize)
         ZOOM_options_set_int(scan->options, "stepSize", *res->stepSize);
     if (res->positionOfTerm)
@@ -2856,7 +2849,7 @@ ZOOM_API(void)
     ZOOM_options_set(scan->options, key, val);
 }
 
-static Z_APDU *create_es_package(ZOOM_package p, int type)
+static Z_APDU *create_es_package(ZOOM_package p, const char *type)
 {
     const char *str;
     Z_APDU *apdu = zget_APDU(p->odr_out, Z_APDU_extendedServicesRequest);
@@ -2866,14 +2859,14 @@ static Z_APDU *create_es_package(ZOOM_package p, int type)
     
     str = ZOOM_options_get(p->options, "package-name");
     if (str && *str)
-        req->packageName = nmem_strdup(p->odr_out->mem, str);
+        req->packageName = odr_strdup(p->odr_out, str);
     
     str = ZOOM_options_get(p->options, "user-id");
     if (str)
-        req->userId = nmem_strdup(p->odr_out->mem, str);
+        req->userId = odr_strdup(p->odr_out, str);
     
-    req->packageType = yaz_oidval_to_z3950oid(p->odr_out, CLASS_EXTSERV,
-                                              type);
+    req->packageType = yaz_string_to_oid_odr(yaz_oid_std(), CLASS_EXTSERV,
+                                             type, p->odr_out);
 
     str = ZOOM_options_get(p->options, "function");
     if (str)
@@ -2917,16 +2910,14 @@ static Z_External *encode_ill_request(ZOOM_package p)
     }
     else
     {
-        oident oid;
         int illRequest_size = 0;
         char *illRequest_buf = odr_getbuf(out, &illRequest_size, 0);
                 
-        oid.proto = PROTO_GENERAL;
-        oid.oclass = CLASS_GENERAL;
-        oid.value = VAL_ISO_ILL_1;
-                
         r = (Z_External *) odr_malloc(out, sizeof(*r));
-        r->direct_reference = odr_oiddup(out,oid_getoidbyent(&oid)); 
+        r->direct_reference = yaz_string_to_oid_odr(yaz_oid_std(),
+                                                    CLASS_GENERAL,
+                                                    OID_STR_ILL_1,
+                                                    out);
         r->indirect_reference = 0;
         r->descriptor = 0;
         r->which = Z_External_single;
@@ -2957,15 +2948,15 @@ static Z_ItemOrder *encode_item_order(ZOOM_package p)
         
     str = ZOOM_options_get(p->options, "contact-name");
     req->u.esRequest->toKeep->contact->name = str ?
-        nmem_strdup(p->odr_out->mem, str) : 0;
+        odr_strdup(p->odr_out, str) : 0;
         
     str = ZOOM_options_get(p->options, "contact-phone");
     req->u.esRequest->toKeep->contact->phone = str ?
-        nmem_strdup(p->odr_out->mem, str) : 0;
+        odr_strdup(p->odr_out, str) : 0;
         
     str = ZOOM_options_get(p->options, "contact-email");
     req->u.esRequest->toKeep->contact->email = str ?
-        nmem_strdup(p->odr_out->mem, str) : 0;
+        odr_strdup(p->odr_out, str) : 0;
         
     req->u.esRequest->toKeep->addlBilling = 0;
         
@@ -2985,7 +2976,7 @@ static Z_ItemOrder *encode_item_order(ZOOM_package p)
             odr_malloc(p->odr_out, sizeof(Z_IOResultSetItem));
 
         req->u.esRequest->notToKeep->resultSetItem->resultSetId =
-            nmem_strdup(p->odr_out->mem, str);
+            odr_strdup(p->odr_out, str);
         req->u.esRequest->notToKeep->resultSetItem->item =
             (int *) odr_malloc(p->odr_out, sizeof(int));
         
@@ -2996,8 +2987,12 @@ static Z_ItemOrder *encode_item_order(ZOOM_package p)
 
     str = ZOOM_options_get(p->options, "doc");
     if (str)
+    {
+        const int *oid = yaz_string_to_oid(yaz_oid_std(),
+                                           CLASS_RECSYN, OID_STR_XML);
         req->u.esRequest->notToKeep->itemRequest =
-            z_ext_record(p->odr_out, VAL_TEXT_XML, str, strlen(str));
+            z_ext_record_oid(p->odr_out, oid, str, strlen(str));
+    }
     else
         req->u.esRequest->notToKeep->itemRequest = encode_ill_request(p);
     
@@ -3008,7 +3003,7 @@ Z_APDU *create_admin_package(ZOOM_package p, int type,
                              Z_ESAdminOriginPartToKeep **toKeepP,
                              Z_ESAdminOriginPartNotToKeep **notToKeepP)
 {
-    Z_APDU *apdu = create_es_package(p, VAL_ADMINSERVICE);
+    Z_APDU *apdu = create_es_package(p, OID_STR_ADMIN);
     if (apdu)
     {
         Z_ESAdminOriginPartToKeep  *toKeep;
@@ -3022,8 +3017,8 @@ Z_APDU *create_admin_package(ZOOM_package p, int type,
             first_db = db[0];
             
         r->direct_reference =
-            yaz_oidval_to_z3950oid(p->odr_out, CLASS_EXTSERV,
-                                   VAL_ADMINSERVICE);
+            yaz_string_to_oid_odr(yaz_oid_std(),
+                                  CLASS_EXTSERV, OID_STR_ADMIN, p->odr_out);
         r->descriptor = 0;
         r->indirect_reference = 0;
         r->which = Z_External_ESAdmin;
@@ -3058,7 +3053,7 @@ Z_APDU *create_admin_package(ZOOM_package p, int type,
 
 static Z_APDU *create_xmlupdate_package(ZOOM_package p)
 {
-    Z_APDU *apdu = create_es_package(p, VAL_XMLES);
+    Z_APDU *apdu = create_es_package(p, OID_STR_XMLES);
     Z_ExtendedServicesRequest *req = apdu->u.extendedServicesRequest;
     Z_External *ext = (Z_External *) odr_malloc(p->odr_out, sizeof(*ext));
     const char *doc = ZOOM_options_get(p->options, "doc");
@@ -3089,19 +3084,26 @@ static Z_APDU *create_update_package(ZOOM_package p)
     const char *recordIdNumber = ZOOM_options_get(p->options, "recordIdNumber");
     const char *record_buf = ZOOM_options_get(p->options, "record");
     const char *syntax_str = ZOOM_options_get(p->options, "syntax");
-    int syntax_oid = VAL_NONE;
     int action_no = -1;
-    
-    if (syntax_str)
-        syntax_oid = oid_getvalbyname(syntax_str);
+    int *syntax_oid = 0;
+
+    if (!syntax_str)
+        syntax_str = "xml";
     if (!record_buf)
     {
         record_buf = "void";
-        syntax_oid = VAL_SUTRS;
+        syntax_str = "SUTRS";
     }
-    if (syntax_oid == VAL_NONE)
-        syntax_oid = VAL_TEXT_XML;
-    
+
+    if (syntax_str)
+    {
+        syntax_oid = yaz_string_to_oid_odr(yaz_oid_std(),
+                                           CLASS_RECSYN, syntax_str,
+                                           p->odr_out);
+    }
+    if (!syntax_oid)
+        return 0;
+
     if (num_db > 0)
         first_db = db[0];
     
@@ -3121,7 +3123,7 @@ static Z_APDU *create_update_package(ZOOM_package p)
     else
         return 0;
 
-    apdu = create_es_package(p, VAL_DBUPDATE);
+    apdu = create_es_package(p, OID_STR_EXT_UPDATE);
     if (apdu)
     {
         Z_IUOriginPartToKeep *toKeep;
@@ -3130,10 +3132,11 @@ static Z_APDU *create_update_package(ZOOM_package p)
             odr_malloc(p->odr_out, sizeof(*r));
         
         apdu->u.extendedServicesRequest->taskSpecificParameters = r;
+
         
         r->direct_reference =
-            yaz_oidval_to_z3950oid(p->odr_out, CLASS_EXTSERV,
-                                   VAL_DBUPDATE);
+            yaz_string_to_oid_odr(yaz_oid_std(), CLASS_EXTSERV,
+                                  OID_STR_EXT_UPDATE, p->odr_out);
         r->descriptor = 0;
         r->which = Z_External_update;
         r->indirect_reference = 0;
@@ -3181,8 +3184,8 @@ static Z_APDU *create_update_package(ZOOM_package p)
         notToKeep->elements[0]->supplementalId = 0;
         notToKeep->elements[0]->correlationInfo = 0;
         notToKeep->elements[0]->record =
-            z_ext_record(p->odr_out, syntax_oid,
-                         record_buf, strlen(record_buf));
+            z_ext_record_oid(p->odr_out, syntax_oid,
+                             record_buf, strlen(record_buf));
     }
     if (0 && apdu)
     {
@@ -3207,14 +3210,14 @@ ZOOM_API(void)
     p->buf_out = 0;
     if (!strcmp(type, "itemorder"))
     {
-        apdu = create_es_package(p, VAL_ITEMORDER);
+        apdu = create_es_package(p, OID_STR_ITEMORDER);
         if (apdu)
         {
             Z_External *r = (Z_External *) odr_malloc(p->odr_out, sizeof(*r));
             
             r->direct_reference =
-                yaz_oidval_to_z3950oid(p->odr_out, CLASS_EXTSERV,
-                                       VAL_ITEMORDER);
+                yaz_string_to_oid_odr(yaz_oid_std(), CLASS_EXTSERV,
+                                      OID_STR_ITEMORDER, p->odr_out);
             r->descriptor = 0;
             r->which = Z_External_itemOrder;
             r->indirect_reference = 0;
@@ -3508,9 +3511,12 @@ static void recv_apdu(ZOOM_connection c, Z_APDU *apdu)
         }
         else
         {
+            const int *oid = yaz_string_to_oid(yaz_oid_std(),
+                                               CLASS_USERINFO,
+                                               OID_STR_COOKIE);
             char *cookie =
-                yaz_oi_get_string_oidval(&apdu->u.initResponse->otherInfo,
-                                         VAL_COOKIE, 1, 0);
+                yaz_oi_get_string_oid(&apdu->u.initResponse->otherInfo,
+                                      oid, 1, 0);
             xfree(c->cookie_in);
             c->cookie_in = 0;
             if (cookie)
@@ -3658,7 +3664,8 @@ static void handle_srw_response(ZOOM_connection c,
             odr_malloc(c->odr_in, sizeof(Z_External));
         npr->u.databaseRecord->descriptor = 0;
         npr->u.databaseRecord->direct_reference =
-            yaz_oidval_to_z3950oid(c->odr_in, CLASS_RECSYN, VAL_TEXT_XML);
+            yaz_string_to_oid_odr(yaz_oid_std(), CLASS_RECSYN, OID_STR_XML,
+                                  c->odr_in);
         npr->u.databaseRecord->which = Z_External_octet;
 
         npr->u.databaseRecord->u.octet_aligned = (Odr_oct *)
@@ -3684,7 +3691,7 @@ static void handle_srw_response(ZOOM_connection c,
         }
     }
     nmem = odr_extract_mem(c->odr_in);
-    nmem_transfer(resultset->odr->mem, nmem);
+    nmem_transfer(odr_getmem(resultset->odr), nmem);
     nmem_destroy(nmem);
 }
 #endif
index 68f1880..90c7142 100644 (file)
@@ -2,14 +2,14 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: zoom-p.h,v 1.17 2007-01-09 13:56:48 adam Exp $
+ * $Id: zoom-p.h,v 1.18 2007-04-12 13:52:57 adam Exp $
  */
 /**
  * \file zoom-p.h
  * \brief Internal header for ZOOM implementation
  */
-
 #include <yaz/proto.h>
+#include <yaz/oid_db.h>
 #include <yaz/comstack.h>
 #include <yaz/wrbuf.h>
 #include <yaz/zoom.h>
index 25b220e..0bbd70b 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: zoomsh.c,v 1.45 2007-03-21 11:27:47 adam Exp $
+ * $Id: zoomsh.c,v 1.46 2007-04-12 13:52:58 adam Exp $
  */
 
 /** \file zoomsh.c
@@ -28,7 +28,6 @@
 #include <yaz/log.h>
 #include <yaz/nmem.h>
 #include <yaz/zoom.h>
-#include <yaz/oid.h>
 
 #define MAX_CON 100
 
@@ -204,10 +203,8 @@ static void display_records (ZOOM_connection c,
             /* if rec is non-null, we got a record for display */
             if (rec)
             {
-                char oidbuf[100];
-                (void) oid_name_to_dotstring(CLASS_RECSYN, syntax, oidbuf);
-                printf ("%d %s %s (%s)\n",
-                        pos, (db ? db : "unknown"), syntax, oidbuf);
+                printf ("%d %s %s\n",
+                        pos, (db ? db : "unknown"), syntax);
                 if (render)
                     fwrite (render, 1, len, stdout);
                 printf ("\n");
index dacf640..75034af 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: ztest.c,v 1.85 2007-01-16 14:12:38 adam Exp $
+ * $Id: ztest.c,v 1.86 2007-04-12 13:52:58 adam Exp $
  */
 
 /*
@@ -16,7 +16,7 @@
 #include <unistd.h>
 #endif
 
-#include <yaz/yaz-util.h>
+#include <yaz/log.h>
 #include <yaz/backend.h>
 #include <yaz/ill.h>
 
@@ -137,17 +137,21 @@ int ztest_esrequest (void *handle, bend_esrequest_rr *rr)
                 ILL_APDU *ill_apdu = 0;
                 if (r->direct_reference)
                 {
-                    oident *ent = oid_getentbyoid(r->direct_reference);
-                    if (ent)
-                        yaz_log(log_level, "OID %s", ent->desc);
-                    if (ent && ent->value == VAL_TEXT_XML)
+                    char oid_name_str[OID_STR_MAX];
+                    int oclass;
+                    const char *oid_name = 
+                        yaz_oid_to_string_buf(r->direct_reference,
+                                          &oclass, oid_name_str);
+                    if (oid_name)
+                        yaz_log(log_level, "OID %s", oid_name);
+                    if (oid_name && !strcmp(oid_name, OID_STR_XML))
                     {
                         yaz_log (log_level, "ILL XML request");
                         if (r->which == Z_External_octet)
                             yaz_log (log_level, "%.*s", r->u.octet_aligned->len,
                                      r->u.octet_aligned->buf); 
                     }
-                    if (ent && ent->value == VAL_ISO_ILL_1)
+                    if (oid_name && !strcmp(oid_name, OID_STR_ILL_1))
                     {
                         yaz_log (log_level, "Decode ItemRequest begin");
                         if (r->which == ODR_EXTERNAL_single)
@@ -369,7 +373,13 @@ int ztest_esrequest (void *handle, bend_esrequest_rr *rr)
                 targetPart->taskPackageRecords[0]->which =
                     Z_IUTaskPackageRecordStructure_record;
                 targetPart->taskPackageRecords[0]->u.record = 
-                    z_ext_record (rr->stream, VAL_SUTRS, "test", 4);
+                    z_ext_record_oid(rr->stream,
+                                     yaz_string_to_oid_odr(
+                                         yaz_oid_std(),
+                                         CLASS_RECSYN,
+                                         OID_STR_SUTRS,
+                                         rr->stream),
+                                     "test", 4);
                 targetPart->taskPackageRecords[0]->correlationInfo = 0; 
                 targetPart->taskPackageRecords[0]->recordStatus =
                     odr_intdup (rr->stream,
@@ -388,11 +398,14 @@ int ztest_esrequest (void *handle, bend_esrequest_rr *rr)
 
                     if (rec->direct_reference)
                     {
-                        struct oident *oident;
-                        oident = oid_getentbyoid(rec->direct_reference);
-                        if (oident)
+                        char oid_name_str[OID_STR_MAX];
+                        const char *oid_name 
+                            = oid_name = yaz_oid_to_string_buf(
+                                rec->direct_reference, 0,
+                                oid_name_str);
+                        if (oid_name)
                             yaz_log (log_level, "record %d type %s", i,
-                                     oident->desc);
+                                     oid_name);
                     }
                     switch (rec->which)
                     {
@@ -452,11 +465,18 @@ int ztest_present (void *handle, bend_present_rr *rr)
 int ztest_fetch(void *handle, bend_fetch_rr *r)
 {
     char *cp;
+    int oclass;
+    char oid_str_buf[OID_STR_MAX];
+    const char *oid_str = 0;
 
     r->last_in_set = 0;
     r->basename = "Default";
-    r->output_format = r->request_format;  
-    if (r->request_format == VAL_SUTRS)
+    r->output_format = r->request_format;
+
+    oid_str = yaz_oid_to_string_buf(r->request_format, &oclass,
+                                    oid_str_buf);
+
+    if (oid_str && !strcmp(oid_str, OID_STR_SUTRS))
     {
         /* this section returns a small record */
         char buf[100];
@@ -467,7 +487,7 @@ int ztest_fetch(void *handle, bend_fetch_rr *r)
         r->record = (char *) odr_malloc (r->stream, r->len+1);
         strcpy(r->record, buf);
     }
-    else if (r->request_format == VAL_GRS1)
+    else if (oid_str && !strcmp(oid_str, OID_STR_GRS1))
     {
         r->len = -1;
         r->record = (char*) dummy_grs_record(r->number, r->stream);
@@ -477,7 +497,7 @@ int ztest_fetch(void *handle, bend_fetch_rr *r)
             return 0;
         }
     }
-    else if (r->request_format == VAL_POSTSCRIPT)
+    else if (oid_str && !strcmp(oid_str, OID_STR_POSTSCRIPT))
     {
         char fname[20];
         FILE *f;
@@ -500,17 +520,15 @@ int ztest_fetch(void *handle, bend_fetch_rr *r)
         fseek (f, 0L, SEEK_SET);
         r->record = (char*) odr_malloc (r->stream, size);
         r->len = size;
-        r->output_format = VAL_POSTSCRIPT;
         fread (r->record, size, 1, f);
         fclose (f);
     }
-    else if (r->request_format == VAL_TEXT_XML)
+    else if (oid_str && !strcmp(oid_str, OID_STR_XML))
     {
         if ((cp = dummy_xml_record (r->number, r->stream)))
         {
             r->len = strlen(cp);
             r->record = cp;
-            r->output_format = VAL_TEXT_XML;
         }
         else 
         {
@@ -523,7 +541,8 @@ int ztest_fetch(void *handle, bend_fetch_rr *r)
     {
         r->len = strlen(cp);
         r->record = cp;
-        r->output_format = VAL_USMARC;
+        r->output_format = yaz_string_to_oid_odr(
+            yaz_oid_std(), CLASS_RECSYN, OID_STR_USMARC, r->stream);
     }
     else
     {