Improved memory debugging for xmalloc/nmem.c. References to NMEM
[yaz-moved-to-github.git] / client / client.c
index a627386..16a6175 100644 (file)
@@ -4,7 +4,19 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: client.c,v $
- * Revision 1.52  1997-09-29 07:20:31  adam
+ * Revision 1.55  1997-10-31 12:20:08  adam
+ * Improved memory debugging for xmalloc/nmem.c. References to NMEM
+ * instead of ODR in n ESPEC-1 handling in source d1_espec.c.
+ * Bug fix: missing fclose in data1_read_espec1.
+ *
+ * Revision 1.54  1997/10/27 13:52:46  adam
+ * Header yaz-util includes all YAZ utility header files.
+ *
+ * Revision 1.53  1997/09/29 13:18:59  adam
+ * Added function, oid_ent_to_oid, to replace the function
+ * oid_getoidbyent, which is not thread safe.
+ *
+ * Revision 1.52  1997/09/29 07:20:31  adam
  * Client code uses nmem_init.
  *
  * Revision 1.51  1997/09/26 09:41:55  adam
  * to illustrate the use of the YAZ service-level API.
  */
 
-#include <yconfig.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
 #include <assert.h>
 
+#include <yaz-util.h>
+
 #include <comstack.h>
 #include <tcpip.h>
 #ifdef USE_XTIMOSI
 #include <proto.h>
 #include <marcdisp.h>
 #include <diagbib1.h>
-#include <options.h>
 
 #include <pquery.h>
 
@@ -488,7 +500,6 @@ static void display_record(Z_DatabaseRecord *p)
             odr_reset(print);
         }
     }
-
     /* Check if this is a known, ASN.1 type tucked away in an octet string */
     if (ent && r->which == Z_External_octet)
     {
@@ -620,6 +631,7 @@ static int send_searchRequest(char *arg)
     Z_APDU *apdu = zget_APDU(out, Z_APDU_searchRequest);
     Z_SearchRequest *req = apdu->u.searchRequest;
     Z_Query query;
+    int oid[OID_SIZE];
 #if CCL2RPN
     struct ccl_rpn_node *rpn;
     int error, pos;
@@ -670,7 +682,7 @@ static int send_searchRequest(char *arg)
         prefsyn.oclass = CLASS_RECSYN;
         prefsyn.value = recordsyntax;
         req->preferredRecordSyntax =
-            odr_oiddup(out, oid_getoidbyent(&prefsyn));
+            odr_oiddup(out, oid_ent_to_oid(&prefsyn, oid));
         req->smallSetElementSetNames =
             req->mediumSetElementSetNames = elementSetNames;
     }
@@ -704,7 +716,7 @@ static int send_searchRequest(char *arg)
         bib1.proto = protocol;
         bib1.oclass = CLASS_ATTSET;
         bib1.value = VAL_BIB1;
-        RPNquery->attributeSetId = oid_getoidbyent(&bib1);
+        RPNquery->attributeSetId = oid_ent_to_oid(&bib1, oid);
         query.u.type_1 = RPNquery;
         ccl_rpn_delete (rpn);
         break;
@@ -834,6 +846,7 @@ static int send_presentRequest(char *arg)
     Z_RecordComposition compo;
     oident prefsyn;
     int nos = 1;
+    int oid[OID_SIZE];
     char *p;
     char setstring[100];
 
@@ -864,7 +877,8 @@ static int send_presentRequest(char *arg)
     prefsyn.proto = protocol;
     prefsyn.oclass = CLASS_RECSYN;
     prefsyn.value = recordsyntax;
-    req->preferredRecordSyntax = oid_getoidbyent(&prefsyn);
+    req->preferredRecordSyntax = oid_ent_to_oid(&prefsyn, oid);
+
     if (elementSetNames)
     {
         req->recordComposition = &compo;
@@ -1033,65 +1047,13 @@ int cmd_format(char *arg)
         printf("Usage: format <recordsyntax>\n");
         return 0;
     }
-    if (!strcmp(arg, "sutrs"))
-    {
-        printf("Preferred format is SUTRS.\n");
-        recordsyntax = VAL_SUTRS;
-        return 1;
-    }
-    else if (!strcmp(arg, "usmarc"))
-    {
-        printf("Preferred format is USMARC\n");
-        recordsyntax = VAL_USMARC;
-        return 1;
-    }
-    else if (!strcmp(arg, "danmarc"))
-    {
-        printf("Preferred format is DANMARC\n");
-        recordsyntax = VAL_DANMARC;
-        return 1;
-    }
-    else if (!strcmp(arg, "ukmarc"))
-    {
-        printf("Preferred format is UKMARC\n");
-        recordsyntax = VAL_UKMARC;
-        return 1;
-    }
-    else if (!strcmp(arg, "unimarc"))
+    recordsyntax = oid_getvalbyname (arg);
+    if (recordsyntax == VAL_NONE)
     {
-        printf("Preferred format is UNIMARC\n");
-        recordsyntax = VAL_UNIMARC;
-        return 1;
-    }
-    else if (!strcmp(arg, "grs1"))
-    {
-        printf("Preferred format is GRS1\n");
-        recordsyntax = VAL_GRS1;
-        return 1;
-    }
-    else if (!strcmp(arg, "soif"))
-    {
-        printf("Preferred format is SOIF\n");
-        recordsyntax = VAL_SOIF;
-        return 1;
-    }
-    else if (!strcmp(arg, "summary"))
-    {
-        printf("Preferred format is Summary\n");
-        recordsyntax = VAL_SUMMARY;
-        return 1;
-    }
-    else if (!strcmp(arg, "explain"))
-    {
-        printf("Preferred format is Explain\n");
-        recordsyntax = VAL_EXPLAIN;
-        return 1;
-    }
-    else
-    {
-        printf("Specify one of {sutrs,usmarc,danmarc,ukmarc,unimarc,grs1,summary,explain}.\n");
+        printf ("unknown record syntax\n");
         return 0;
     }
+    return 1;
 }
 
 int cmd_elements(char *arg)