Fix leak for odr_print of ZOOM connection.
[yaz-moved-to-github.git] / src / zget.c
index e8785ef..d0c23d6 100644 (file)
@@ -1,8 +1,6 @@
-/*
- * Copyright (C) 1995-2007, Index Data ApS
+/* This file is part of the YAZ toolkit.
+ * Copyright (C) 1995-2009 Index Data
  * See the file LICENSE for details.
- *
- * $Id: zget.c,v 1.13 2007-04-12 13:52:57 adam Exp $
  */
 /**
  * \file zget.c
@@ -36,11 +34,8 @@ Z_InitRequest *zget_InitRequest(ODR o)
     r->implementationId = "81";
     r->implementationName = "YAZ";
     r->implementationVersion = YAZ_VERSION
-#ifdef YAZ_DATE_STR
-    " (" YAZ_DATE_STR ")"
-#endif
-#ifdef YAZ_OS
-    " " YAZ_OS
+#ifdef YAZ_VERSION_SHA1
+    " " YAZ_VERSION_SHA1
 #endif
         ;
     r->userInformationField = 0;
@@ -59,15 +54,12 @@ Z_InitResponse *zget_InitResponse(ODR o)
     ODR_MASK_ZERO(r->protocolVersion);
     r->preferredMessageSize = odr_intdup(o, 30*1024);
     r->maximumRecordSize = odr_intdup(o, 30*1024);
-    r->result = odr_intdup(o, 1);
+    r->result = odr_booldup(o, 1);
     r->implementationId = "81";
     r->implementationName = "YAZ";
     r->implementationVersion = YAZ_VERSION
-#ifdef YAZ_DATE_STR
-    " (" YAZ_DATE_STR ")"
-#endif
-#ifdef YAZ_OS
-    " " YAZ_OS
+#ifdef YAZ_VERSION_SHA1
+    " " YAZ_VERSION_SHA1
 #endif
         ;
     r->userInformationField = 0;
@@ -83,7 +75,7 @@ Z_SearchRequest *zget_SearchRequest(ODR o)
     r->smallSetUpperBound = odr_intdup(o, 0);
     r->largeSetLowerBound = odr_intdup(o, 1);
     r->mediumSetPresentNumber = odr_intdup(o, 0);
-    r->replaceIndicator = odr_intdup(o, 1);
+    r->replaceIndicator = odr_booldup(o, 1);
     r->resultSetName = "default";
     r->num_databaseNames = 0;
     r->databaseNames = 0;
@@ -104,7 +96,7 @@ Z_SearchResponse *zget_SearchResponse(ODR o)
     r->resultCount = odr_intdup(o, 0);
     r->numberOfRecordsReturned = odr_intdup(o, 0);
     r->nextResultSetPosition = odr_intdup(o, 0);
-    r->searchStatus = odr_intdup(o, 1);
+    r->searchStatus = odr_booldup(o, 1);
     r->resultSetStatus = 0;
     r->presentStatus = 0;
     r->records = 0;
@@ -226,7 +218,7 @@ Z_ResourceControlRequest *zget_ResourceControlRequest(ODR o)
     r->suspendedFlag = 0;
     r->resourceReport = 0;
     r->partialResultsAvailable = 0;
-    r->responseRequired = odr_intdup(o, 0);
+    r->responseRequired = odr_booldup(o, 0);
     r->triggeredRequestFlag = 0;
     r->otherInfo = 0;
     return r;
@@ -238,7 +230,7 @@ Z_ResourceControlResponse *zget_ResourceControlResponse(ODR o)
         odr_malloc(o, sizeof(*r));
 
     r->referenceId = 0;
-    r->continueFlag = odr_intdup(o, 1);
+    r->continueFlag = odr_booldup(o, 1);
     r->resultSetWanted = 0;
     r->otherInfo = 0;
     return r;
@@ -506,8 +498,7 @@ Z_DefaultDiagFormat *zget_DefaultDiagFormat(ODR o, int error,
     Z_DefaultDiagFormat *dr = (Z_DefaultDiagFormat *) 
         odr_malloc (o, sizeof(*dr));
     
-    dr->diagnosticSetId = yaz_string_to_oid_odr(
-        yaz_oid_std(), CLASS_DIAGSET, OID_STR_BIB1, o);
+    dr->diagnosticSetId = odr_oiddup(o, yaz_oid_diagset_bib_1);
     dr->condition = odr_intdup(o, error);
     dr->which = Z_DefaultDiagFormat_v2Addinfo;
     dr->u.v2Addinfo = odr_strdup (o, addinfo ? addinfo : "");
@@ -560,13 +551,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;  
-    x->direct_reference = yaz_string_to_oid_odr(yaz_oid_std(),
-                                                CLASS_USERINFO,
-                                                OID_STR_USERINFO_1,
-                                                odr);
+    x->direct_reference = odr_oiddup(odr, yaz_oid_userinfo_userinfo_1);
     x->which = Z_External_userInfo1;
 
-    u = odr_malloc(odr, sizeof *u);
+    u = (Z_OtherInformation *) odr_malloc(odr, sizeof *u);
     x->u.userInfo1 = u;
     u->num_elements = 1;
     u->list = (Z_OtherInformationUnit**) odr_malloc(odr, sizeof *u->list);
@@ -579,10 +567,7 @@ Z_External *zget_init_diagnostics(ODR odr, int error, const char *addinfo)
     l->information.externallyDefinedInfo = x2;
     x2->descriptor = 0;
     x2->indirect_reference = 0;
-    x2->direct_reference = yaz_string_to_oid_odr(yaz_oid_std(),
-                                                 CLASS_DIAGSET,
-                                                 OID_STR_DIAG1,
-                                                 odr);
+    x2->direct_reference = odr_oiddup(odr, yaz_oid_diagset_diag_1);
     x2->which = Z_External_diag1;
 
     d = (Z_DiagnosticFormat*) odr_malloc(odr, sizeof *d);
@@ -610,7 +595,7 @@ Z_External *zget_init_diagnostics_octet(ODR odr, int error,
     int octet_len;
     ODR encode;
 
-    u = odr_malloc(odr, sizeof *u);
+    u = (Z_OtherInformation *) odr_malloc(odr, sizeof *u);
     u->num_elements = 1;
     u->list = (Z_OtherInformationUnit**) odr_malloc(odr, sizeof *u->list);
     u->list[0] = (Z_OtherInformationUnit*) odr_malloc(odr, sizeof *u->list[0]);
@@ -623,10 +608,7 @@ Z_External *zget_init_diagnostics_octet(ODR odr, int error,
     x2->descriptor = 0;
     x2->indirect_reference = 0;
 
-    x2->direct_reference = yaz_string_to_oid_odr(yaz_oid_std(),
-                                                 CLASS_DIAGSET,
-                                                 OID_STR_DIAG1,
-                                                 odr);
+    x2->direct_reference = odr_oiddup(odr, yaz_oid_diagset_diag_1);
     x2->which = Z_External_diag1;
 
     d = (Z_DiagnosticFormat*) odr_malloc(odr, sizeof *d);
@@ -649,14 +631,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;  
-    x->direct_reference = yaz_string_to_oid_odr(yaz_oid_std(),
-                                                CLASS_USERINFO,
-                                                OID_STR_USERINFO_1,
-                                                odr);
-
+    x->direct_reference = odr_oiddup(odr, yaz_oid_userinfo_userinfo_1);
     x->which = Z_External_octet;
     x->u.octet_aligned = (Odr_oct *) odr_malloc(odr, sizeof(Odr_oct));
-    x->u.octet_aligned->buf = odr_malloc(odr, octet_len);
+    x->u.octet_aligned->buf = (unsigned char *) odr_malloc(odr, octet_len);
     memcpy(x->u.octet_aligned->buf, octet_buf, octet_len);
     x->u.octet_aligned->len = octet_len;
 
@@ -668,6 +646,7 @@ Z_External *zget_init_diagnostics_octet(ODR odr, int error,
 /*
  * Local variables:
  * c-basic-offset: 4
+ * c-file-style: "Stroustrup"
  * indent-tabs-mode: nil
  * End:
  * vim: shiftwidth=4 tabstop=8 expandtab