Introduce type for BER BOOLEAN/INTEGER .
authorAdam Dickmeiss <adam@indexdata.dk>
Thu, 18 Jun 2009 12:09:21 +0000 (14:09 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Thu, 18 Jun 2009 12:09:21 +0000 (14:09 +0200)
The BER BOOLEAN is now the integral type Odr_bool which still happens
to be an 'int'. The BER INTEGER which used to be a plain 'int' is now
typedef'd to Odr_int. This is still an integral 'int', but it may be
changed to 64-bit via a one-liner in nmem.h (NMEM_64=1). The documentation,
ASN-1 compiler as well as programs has been updated to use the new types.

24 files changed:
client/client.c
doc/asn.xml
doc/odr.xml
include/yaz/backend.h
include/yaz/nmem.h
include/yaz/odr.h
include/yaz/prt-ext.h
include/yaz/srw.h
src/ber_int.c
src/cqltransform.c
src/ill-get.c
src/nmemsdup.c
src/odr_bool.c
src/odr_enum.c
src/odr_int.c
src/odr_mem.c
src/pquery.c
src/seshigh.c
src/session.h
src/srw.c
src/srwutil.c
src/xmlquery.c
test/tstodr.c
util/yaz-asncomp

index d6ec0c3..0cf0cad 100644 (file)
@@ -104,7 +104,7 @@ static int smallSetUpperBound = 0;
 static int largeSetLowerBound = 1;
 static int mediumSetPresentNumber = 0;
 static Z_ElementSetNames *elementSetNames = 0;
-static odr_int_t setno = 1;                   /* current set offset */
+static Odr_int setno = 1;                   /* current set offset */
 static enum oid_proto protocol = PROTO_Z3950;      /* current app protocol */
 #define RECORDSYNTAX_MAX 20
 static char *recordsyntax_list[RECORDSYNTAX_MAX];
@@ -1640,7 +1640,7 @@ static void print_level(int iLevel)
         printf(" ");
 }
 
-static void print_int(int iLevel, const char *pTag, odr_int_t *pInt)
+static void print_int(int iLevel, const char *pTag, Odr_int *pInt)
 {
     if (pInt != NULL)
     {
@@ -1649,6 +1649,15 @@ static void print_int(int iLevel, const char *pTag, odr_int_t *pInt)
     }
 }
 
+static void print_bool(int iLevel, const char *pTag, Odr_bool *pInt)
+{
+    if (pInt != NULL)
+    {
+        print_level(iLevel);
+        printf("%s: %d\n", pTag, *pInt);
+    }
+}
+
 static void print_string(int iLevel, const char *pTag, const char *pString)
 {
     if (pString != NULL)
@@ -1793,10 +1802,10 @@ static int process_resourceControlRequest(Z_ResourceControlRequest *req)
 {
     printf("Received ResourceControlRequest.\n");
     print_referenceId(1, req->referenceId);
-    print_int(1, "Suspended Flag", req->suspendedFlag);
+    print_bool(1, "Suspended Flag", req->suspendedFlag);
     print_int(1, "Partial Results Available", req->partialResultsAvailable);
-    print_int(1, "Response Required", req->responseRequired);
-    print_int(1, "Triggered Request Flag", req->triggeredRequestFlag);
+    print_bool(1, "Response Required", req->responseRequired);
+    print_bool(1, "Triggered Request Flag", req->triggeredRequestFlag);
     print_external(1, req->resourceReport);
     return 0;
 }
@@ -2650,7 +2659,7 @@ static int cmd_setnames(const char *arg)
 /* PRESENT SERVICE ----------------------------- */
 
 static void parse_show_args(const char *arg_c, char *setstring,
-                            odr_int_t *start, odr_int_t *number)
+                            Odr_int *start, Odr_int *number)
 {
     char arg[40];
     char *p;
@@ -2686,7 +2695,7 @@ static int send_presentRequest(const char *arg)
     Z_APDU *apdu = zget_APDU(out, Z_APDU_presentRequest);
     Z_PresentRequest *req = apdu->u.presentRequest;
     Z_RecordComposition compo;
-    odr_int_t nos = 1;
+    Odr_int nos = 1;
     char setstring[100];
 
     req->referenceId = set_refid(out);
@@ -2777,7 +2786,7 @@ static int send_presentRequest(const char *arg)
 static int send_SRW_presentRequest(const char *arg)
 {
     char setstring[100];
-    odr_int_t nos = 1;
+    Odr_int nos = 1;
     Z_SRW_PDU *sr = srw_sr;
 
     if (!sr)
@@ -2923,7 +2932,7 @@ int cmd_cancel_find(const char *arg) {
 }
 
 int send_scanrequest(const char *set,  const char *query,
-                     odr_int_t pp, odr_int_t num, const char *term)
+                     Odr_int pp, Odr_int num, const char *term)
 {
     Z_APDU *apdu = zget_APDU(out, Z_APDU_scanRequest);
     Z_ScanRequest *req = apdu->u.scanRequest;
index bb84b52..c787d4f 100644 (file)
@@ -5,7 +5,8 @@
     various PDUs of the Z39.50 protocol, as well as for the complex types
     appearing within the PDUs. For the primitive data types, the C
     representation often takes the form of an ordinary C language type,
-    such as <literal>int</literal>. For ASN.1 constructs that have no direct
+    such as <literal>Odr_int</literal> which is equivalent to an integral
+    C integer. For ASN.1 constructs that have no direct
     representation in C, such as general octet strings and bit strings,
     the &odr; module (see section <link linkend="odr">The ODR Module</link>)
     provides auxiliary definitions.
@@ -308,10 +309,10 @@ typedef struct Z_ext_typeent
        options</entry><entry>Odr_bitmask</entry><entry>Empty bitmask
       </entry></row>
      <row><entry>
-       preferredMessageSize</entry><entry>int</entry><entry>30*1024
+       preferredMessageSize</entry><entry>Odr_int</entry><entry>30*1024
       </entry></row>
      <row><entry>
-       maximumRecordSize</entry><entry>int</entry><entry>30*1024
+       maximumRecordSize</entry><entry>Odr_int</entry><entry>30*1024
       </entry></row>
      <row><entry>
        idAuthentication</entry><entry>Z_IdAuthentication</entry><entry>NULL
@@ -360,13 +361,13 @@ typedef struct Z_ext_typeent
        options</entry><entry>Odr_bitmask</entry><entry>Empty bitmask
        </entry></row>
       <row><entry>
-       preferredMessageSize</entry><entry>int</entry><entry>30*1024
+       preferredMessageSize</entry><entry>Odr_int</entry><entry>30*1024
        </entry></row>
       <row><entry>
-       maximumRecordSize</entry><entry>int</entry><entry>30*1024
+       maximumRecordSize</entry><entry>Odr_int</entry><entry>30*1024
        </entry></row>
       <row><entry>
-       result</entry><entry>bool_t</entry><entry>TRUE
+       result</entry><entry>Odr_bool</entry><entry>TRUE
        </entry></row>
       <row><entry>
        implementationId</entry><entry>char*</entry><entry>"id)"
@@ -405,22 +406,22 @@ typedef struct Z_ext_typeent
        referenceId</entry><entry>Z_ReferenceId</entry><entry>NULL
        </entry></row>
       <row><entry>
-       smallSetUpperBound</entry><entry>int</entry><entry>0
+       smallSetUpperBound</entry><entry>Odr_int</entry><entry>0
        </entry></row>
       <row><entry>
-       largeSetLowerBound</entry><entry>int</entry><entry>1
+       largeSetLowerBound</entry><entry>Odr_int</entry><entry>1
        </entry></row>
       <row><entry>
-       mediumSetPresentNumber</entry><entry>int</entry><entry>0
+       mediumSetPresentNumber</entry><entry>Odr_int</entry><entry>0
        </entry></row>
       <row><entry>
-       replaceIndicator</entry><entry>bool_t</entry><entry>TRUE
+       replaceIndicator</entry><entry>Odr_bool</entry><entry>TRUE
        </entry></row>
       <row><entry>
        resultSetName</entry><entry>char *</entry><entry>"default"
        </entry></row>
       <row><entry>
-       num_databaseNames</entry><entry>int</entry><entry>0
+       num_databaseNames</entry><entry>Odr_int</entry><entry>0
        </entry></row>
       <row><entry>
        databaseNames</entry><entry>char **</entry><entry>NULL
@@ -469,22 +470,22 @@ typedef struct Z_ext_typeent
        referenceId</entry><entry>Z_ReferenceId</entry><entry>NULL
        </entry></row>
       <row><entry>
-       resultCount</entry><entry>int</entry><entry>0
+       resultCount</entry><entry>Odr_int</entry><entry>0
        </entry></row>
       <row><entry>
-       numberOfRecordsReturned</entry><entry>int</entry><entry>0
+       numberOfRecordsReturned</entry><entry>Odr_int</entry><entry>0
        </entry></row>
       <row><entry>
-       nextResultSetPosition</entry><entry>int</entry><entry>0
+       nextResultSetPosition</entry><entry>Odr_int</entry><entry>0
        </entry></row>
       <row><entry>
-       searchStatus</entry><entry>bool_t</entry><entry>TRUE
+       searchStatus</entry><entry>Odr_bool</entry><entry>TRUE
        </entry></row>
       <row><entry>
-       resultSetStatus</entry><entry>int</entry><entry>NULL
+       resultSetStatus</entry><entry>Odr_int</entry><entry>NULL
        </entry></row>
       <row><entry>
-       presentStatus</entry><entry>int</entry><entry>NULL
+       presentStatus</entry><entry>Odr_int</entry><entry>NULL
        </entry></row>
       <row><entry>
        records</entry><entry>Z_Records</entry><entry>NULL
@@ -521,13 +522,13 @@ typedef struct Z_ext_typeent
        resultSetId</entry><entry>char*</entry><entry>"default"
        </entry></row>
       <row><entry>
-       resultSetStartPoint</entry><entry>int</entry><entry>1
+       resultSetStartPoint</entry><entry>Odr_int</entry><entry>1
        </entry></row>
       <row><entry>
-       numberOfRecordsRequested</entry><entry>int</entry><entry>10
+       numberOfRecordsRequested</entry><entry>Odr_int</entry><entry>10
        </entry></row>
       <row><entry>
-       num_ranges</entry><entry>int</entry><entry>0
+       num_ranges</entry><entry>Odr_int</entry><entry>0
        </entry></row>
       <row><entry>
        additionalRanges</entry><entry>Z_Range</entry><entry>NULL
@@ -539,13 +540,13 @@ typedef struct Z_ext_typeent
        preferredRecordSyntax</entry><entry>Odr_oid</entry><entry>NULL
        </entry></row>
       <row><entry>
-       maxSegmentCount</entry><entry>int</entry><entry>NULL
+       maxSegmentCount</entry><entry>Odr_int</entry><entry>NULL
        </entry></row>
       <row><entry>
-       maxRecordSize</entry><entry>int</entry><entry>NULL
+       maxRecordSize</entry><entry>Odr_int</entry><entry>NULL
        </entry></row>
       <row><entry>
-       maxSegmentSize</entry><entry>int</entry><entry>NULL
+       maxSegmentSize</entry><entry>Odr_int</entry><entry>NULL
        </entry></row>
       <row><entry>
        otherInfo</entry><entry>Z_OtherInformation</entry><entry>NULL
@@ -572,13 +573,13 @@ typedef struct Z_ext_typeent
        referenceId</entry><entry>Z_ReferenceId</entry><entry>NULL
        </entry></row>
       <row><entry>
-       numberOfRecordsReturned</entry><entry>int</entry><entry>0
+       numberOfRecordsReturned</entry><entry>Odr_int</entry><entry>0
        </entry></row>
       <row><entry>
-       nextResultSetPosition</entry><entry>int</entry><entry>0
+       nextResultSetPosition</entry><entry>Odr_int</entry><entry>0
        </entry></row>
       <row><entry>
-       presentStatus</entry><entry>int</entry><entry>Z_PresentStatus_success
+       presentStatus</entry><entry>Odr_int</entry><entry>Z_PresentStatus_success
        </entry></row>
       <row><entry>
        records</entry><entry>Z_Records</entry><entry>NULL
@@ -609,10 +610,10 @@ typedef struct Z_ext_typeent
        </entry><entry>Z_ReferenceId</entry><entry>NULL
        </entry></row>
       <row><entry>
-       deleteFunction</entry><entry>int</entry><entry>Z_DeleteResultSetRequest_list
+       deleteFunction</entry><entry>Odr_int</entry><entry>Z_DeleteResultSetRequest_list
        </entry></row>
       <row><entry>
-       num_ids</entry><entry>int</entry><entry>0
+       num_ids</entry><entry>Odr_int</entry><entry>0
        </entry></row>
       <row><entry>
        resultSetList</entry><entry>char**</entry><entry>NULL
@@ -643,19 +644,19 @@ typedef struct Z_ext_typeent
        referenceId</entry><entry>Z_ReferenceId</entry><entry>NULL
        </entry></row>
       <row><entry>
-       deleteOperationStatus</entry><entry>int</entry>
+       deleteOperationStatus</entry><entry>Odr_int</entry>
        <entry>Z_DeleteStatus_success</entry></row>
       <row><entry>
-       num_statuses</entry><entry>int</entry><entry>0
+       num_statuses</entry><entry>Odr_int</entry><entry>0
        </entry></row>
       <row><entry>
        deleteListStatuses</entry><entry>Z_ListStatus**</entry><entry>NULL
        </entry></row>
       <row><entry>
-       numberNotDeleted</entry><entry>int</entry><entry>NULL
+       numberNotDeleted</entry><entry>Odr_int</entry><entry>NULL
        </entry></row>
       <row><entry>
-       num_bulkStatuses</entry><entry>int</entry><entry>0
+       num_bulkStatuses</entry><entry>Odr_int</entry><entry>0
        </entry></row>
       <row><entry>
        bulkStatuses</entry><entry>Z_ListStatus</entry><entry>NUL
@@ -689,7 +690,7 @@ typedef struct Z_ext_typeent
        referenceId</entry><entry>Z_ReferenceId</entry><entry>NULL
        </entry></row>
       <row><entry>
-       num_databaseNames</entry><entry>int</entry><entry>0
+       num_databaseNames</entry><entry>Odr_int</entry><entry>0
        </entry></row>
       <row><entry>
        databaseNames</entry><entry>char**</entry><entry>NULL
@@ -701,13 +702,13 @@ typedef struct Z_ext_typeent
        termListAndStartPoint</entry><entry>Z_AttributesPlus...
        </entry><entry>NULL</entry></row>
       <row><entry>
-       stepSize</entry><entry>int</entry><entry>NULL
+       stepSize</entry><entry>Odr_int</entry><entry>NULL
        </entry></row>
       <row><entry>
-       numberOfTermsRequested</entry><entry>int</entry><entry>20
+       numberOfTermsRequested</entry><entry>Odr_int</entry><entry>20
        </entry></row>
       <row><entry>
-       preferredPositionInResponse</entry><entry>int</entry><entry>NULL
+       preferredPositionInResponse</entry><entry>Odr_int</entry><entry>NULL
        </entry></row>
       <row><entry>
        otherInfo</entry><entry>Z_OtherInformation</entry><entry>NULL
@@ -736,16 +737,16 @@ typedef struct Z_ext_typeent
        referenceId</entry><entry>Z_ReferenceId</entry><entry>NULL
        </entry></row>
       <row><entry>
-       stepSize</entry><entry>int</entry><entry>NULL
+       stepSize</entry><entry>Odr_int</entry><entry>NULL
        </entry></row>
       <row><entry>
-       scanStatus</entry><entry>int</entry><entry>Z_Scan_success
+       scanStatus</entry><entry>Odr_int</entry><entry>Z_Scan_success
        </entry></row>
       <row><entry>
-       numberOfEntriesReturned</entry><entry>int</entry><entry>0
+       numberOfEntriesReturned</entry><entry>Odr_int</entry><entry>0
        </entry></row>
       <row><entry>
-       positionOfTerm</entry><entry>int</entry><entry>NULL
+       positionOfTerm</entry><entry>Odr_int</entry><entry>NULL
        </entry></row>
       <row><entry>
        entries</entry><entry>Z_ListEntris</entry><entry>NULL
@@ -779,14 +780,14 @@ typedef struct Z_ext_typeent
        referenceId</entry><entry>Z_ReferenceId</entry><entry>NULL
        </entry></row>
       <row><entry>
-       requestedAction</entry><entry>int</entry><entry>
+       requestedAction</entry><entry>Odr_int</entry><entry>
        Z_TriggerResourceCtrl_resou..
        </entry></row>
       <row><entry>
        prefResourceReportFormat</entry><entry>Odr_oid</entry><entry>NULL
        </entry></row>
       <row><entry>
-       resultSetWanted</entry><entry>bool_t</entry><entry>NULL
+       resultSetWanted</entry><entry>Odr_bool</entry><entry>NULL
        </entry></row>
       <row><entry>
        otherInfo</entry><entry>Z_OtherInformation</entry><entry>NULL
@@ -815,19 +816,19 @@ typedef struct Z_ext_typeent
        referenceId</entry><entry>Z_ReferenceId</entry><entry>NULL
        </entry></row>
       <row><entry>
-       suspendedFlag</entry><entry>bool_t</entry><entry>NULL
+       suspendedFlag</entry><entry>Odr_bool</entry><entry>NULL
        </entry></row>
       <row><entry>
        resourceReport</entry><entry>Z_External</entry><entry>NULL
        </entry></row>
       <row><entry>
-       partialResultsAvailable</entry><entry>int</entry><entry>NULL
+       partialResultsAvailable</entry><entry>Odr_int</entry><entry>NULL
        </entry></row>
       <row><entry>
-       responseRequired</entry><entry>bool_t</entry><entry>FALSE
+       responseRequired</entry><entry>Odr_bool</entry><entry>FALSE
        </entry></row>
       <row><entry>
-       triggeredRequestFlag</entry><entry>bool_t</entry><entry>NULL
+       triggeredRequestFlag</entry><entry>Odr_bool</entry><entry>NULL
        </entry></row>
       <row><entry>
        otherInfo</entry><entry>Z_OtherInformation</entry><entry>NULL
@@ -951,10 +952,10 @@ typedef struct Z_ext_typeent
        referenceId</entry><entry>Z_ReferenceId</entry><entry>NULL
        </entry></row>
       <row><entry>
-       numberOfRecordsReturned</entry><entry>int</entry><entry>value=0
+       numberOfRecordsReturned</entry><entry>Odr_int</entry><entry>value=0
        </entry></row>
       <row><entry>
-       num_segmentRecords</entry><entry>int</entry><entry>0
+       num_segmentRecords</entry><entry>Odr_int</entry><entry>0
        </entry></row>
       <row><entry>
        segmentRecords</entry><entry>Z_NamePlusRecord</entry><entry>NULL
@@ -984,7 +985,7 @@ typedef struct Z_ext_typeent
        referenceId</entry><entry>Z_ReferenceId</entry><entry>NULL
        </entry></row>
       <row><entry>
-       closeReason</entry><entry>int</entry><entry>Z_Close_finished
+       closeReason</entry><entry>Odr_int</entry><entry>Z_Close_finished
        </entry></row>
       <row><entry>
        diagnosticInformation</entry><entry>char*</entry><entry>NULL
index 627f5c9..0f6ac6f 100644 (file)
     <example id="example.odr.encoding.and.decoding.functions">
      <title>Encoding and decoding functions</title>
      <synopsis>
-      int odr_integer(ODR o, int **p, int optional, const char *name);
+      int odr_integer(ODR o, Odr_int **p, int optional, const char *name);
       
       int z_APDU(ODR o, Z_APDU **p, int optional, const char *name);
      </synopsis>
 void do_nothing_useful(int value)
 {
     ODR encode, decode;
-    int *valp, *resvalp;
+    Odr_int *valp, *resvalp;
     char *bufferp;
     int len;
      
@@ -337,7 +337,8 @@ void do_nothing_useful(int value)
         printf("decoding went bad\n");
         return;
     }
-    printf("the value is %d\n", *resvalp);
+    /* ODR_INT_PRINTF format for printf (such as %d) */
+    printf("the value is " ODR_INT_PRINTF "\n", *resvalp);
 
     /* clean up */
     odr_destroy(encode);
@@ -585,11 +586,11 @@ void do_nothing_useful(int value)
      </para>
 
      <synopsis>
-      int odr_integer(ODR o, int **p, int optional, const char *name);
+      int odr_integer(ODR o, Odr_int **p, int optional, const char *name);
      </synopsis>
 
      <para>
-      (we don't allow values that can't be contained in a C integer.)
+      The <literal>Odr_int</literal> is just a simple integer.
      </para>
      
      <para>
@@ -638,7 +639,7 @@ void do_nothing_useful(int value)
     <sect3 id="odr.boolean"><title>BOOLEAN</title>
 
      <synopsis>
-int odr_bool(ODR o, bool_t **p, int optional, const char *name);
+int odr_bool(ODR o, Odr_bool **p, int optional, const char *name);
      </synopsis>
 
     </sect3>
@@ -652,7 +653,7 @@ int odr_bool(ODR o, bool_t **p, int optional, const char *name);
     <sect3 id="odr.null"><title>NULL</title>
 
      <synopsis>
-int odr_null(ODR o, bool_t **p, int optional, const char *name);
+int odr_null(ODR o, Odr_null **p, int optional, const char *name);
      </synopsis>
 
      <para>
@@ -794,7 +795,7 @@ int odr_explicit_tag(ODR o, Odr_fun fun, int class, int tag,
     </para>
 
     <screen>
-int myInt(ODR o, int **p, int optional, const char *name)
+int myInt(ODR o, Odr_int **p, int optional, const char *name)
 {
     return odr_implicit_tag(o, odr_integer, p,
                            ODR_CONTEXT, 210, optional, name);
@@ -866,8 +867,8 @@ MySequence ::= SEQUENCE {
     <screen>
 typedef struct MySequence
 {
-    int *intval;
-    bool_t *boolval;
+    Odr_int *intval;
+    Odr_bool *boolval;
 } MySequence;
      
 int mySequence(ODR o, MySequence **p, int optional, const char *name)
@@ -1070,7 +1071,7 @@ MyArray ::= SEQUENCE OF INTEGER
 typedef struct MyArray
 {
     int num_elements;
-    int **elements;
+    Odr_int **elements;
 } MyArray;
     </screen>
 
@@ -1194,9 +1195,9 @@ typedef struct MyChoice
     } which;
     union
     {
-        int *untagged;
-        int *tagged;
-        bool_t *other;
+        Odr_int *untagged;
+        Odr_int *tagged;
+        Odr_bool *other;
     } u;
 };
     </screen>
index aa6a9ea..a7a4874 100644 (file)
@@ -61,7 +61,7 @@ typedef struct {
     bend_request request;
     bend_association association;
     int *fd;
-    odr_int_t hits;                  /* number of hits */
+    Odr_int hits;                  /* number of hits */
     int errcode;               /* 0==OK */
     char *errstring;           /* system error string or NULL */
     Z_OtherInformation *search_info; /* additional search info */
@@ -114,7 +114,7 @@ typedef struct bend_fetch_rr {
 /** \brief Information for scan entry */
 struct scan_entry {
     char *term;         /* the returned scan term */
-    odr_int_t occurrences;/* no of occurrences or -1 if error (see below) */
+    Odr_int occurrences;/* no of occurrences or -1 if error (see below) */
     int errcode;        /* Bib-1 diagnostic code; only used when occur.= -1 */
     char *errstring;    /* Additional string */
     char *display_term;
@@ -135,8 +135,8 @@ typedef struct bend_scan_rr {
     ODR stream;         /* encoding stream - memory source if required */
     ODR print;          /* printing stream */
 
-    odr_int_t *step_size;     /* step size */
-    odr_int_t term_position;  /* desired index of term in result list/returned */
+    Odr_int *step_size;     /* step size */
+    Odr_int term_position;  /* desired index of term in result list/returned */
     int num_entries;    /* number of entries requested/returned */
 
     /* scan term entries. The called handler does not have
@@ -178,8 +178,8 @@ typedef struct bend_delete_rr {
     int num_setnames;
     char **setnames;
     Z_ReferenceId *referenceId;
-    int delete_status;      /* status for the whole operation */
-    odr_int_t *statuses;    /* status each set - indexed as setnames */
+    int delete_status;    /* status for the whole operation */
+    Odr_int *statuses;    /* status each set - indexed as setnames */
     ODR stream;
     ODR print; 
 } bend_delete_rr;
index 4157e0f..9364323 100644 (file)
@@ -43,6 +43,24 @@ YAZ_BEGIN_CDECL
 /** \brief NMEM handle (an opaque pointer to memory) */
 typedef struct nmem_control *NMEM;
 
+/** \brief Set to 1 if YAZ BER integer is 64-bit ; 0 otherwise */
+#define NMEM_64 0
+
+#if NMEM_64
+/** \brief BER/utility integer (64-bit or more) */
+typedef long long int nmem_int_t;
+/** \brief printf format for nmem_int_t type */
+#define NMEM_INT_PRINTF "%lld"
+#else
+/** \brief BER/utility integer (32-bit on most platforms) */
+typedef int nmem_int_t;
+/** \brief printf format for nmem_int_t type */
+#define NMEM_INT_PRINTF "%d"
+#endif
+
+/** \brief BER/utility boolean */
+typedef int nmem_bool_t;
+
 /** \brief releases memory associaged with an NMEM handle 
     \param n NMEM handle
 */
@@ -94,14 +112,19 @@ YAZ_EXPORT void nmem_strsplit(NMEM nmem, const char *delim,
 YAZ_EXPORT void nmem_strsplit_blank(NMEM nmem, const char *dstr,
                                     char ***darray, int *num);
 
-/** \brief allocates integer for NMEM
+/** \brief allocates and sets integer for NMEM
     \param nmem NMEM handle
     \param v integer value
     \returns pointer to created integer
 */
-YAZ_EXPORT int *nmem_intdup(NMEM nmem, int v);
+YAZ_EXPORT nmem_int_t *nmem_intdup(NMEM nmem, nmem_int_t v);
 
-YAZ_EXPORT long long int *nmem_longintdup(NMEM nmem, long long int v);
+/** \brief allocates and sets boolean for NMEM
+    \param nmem NMEM handle
+    \param v value (0=false, != 0 true)
+    \returns pointer to created boolean
+*/
+YAZ_EXPORT nmem_bool_t *nmem_booldup(NMEM nmem, nmem_bool_t v);
 
 /** \brief transfers memory from one NMEM handle to another
     \param src source NMEM handle
index c0dc755..b6abe59 100644 (file)
 
 YAZ_BEGIN_CDECL
 
-#define ODR_INT_PRINTF "%lld"
-
-typedef long long int odr_int_t;
-typedef int odr_bool_t;
+typedef nmem_int_t Odr_int;
+typedef nmem_bool_t Odr_bool;
+#define ODR_INT_PRINTF NMEM_INT_PRINTF
 
 #ifndef bool_t
 #define bool_t int
@@ -189,8 +188,8 @@ YAZ_EXPORT void *odr_malloc(ODR o, int size);
 YAZ_EXPORT char *odr_strdup(ODR o, const char *str);
 YAZ_EXPORT char *odr_strdupn(ODR o, const char *str, size_t n);
 YAZ_EXPORT char *odr_strdup_null(ODR o, const char *str);
-YAZ_EXPORT odr_int_t *odr_intdup(ODR o, odr_int_t v);
-YAZ_EXPORT odr_bool_t *odr_booldup(ODR o, odr_bool_t v);
+YAZ_EXPORT Odr_int *odr_intdup(ODR o, Odr_int v);
+YAZ_EXPORT Odr_bool *odr_booldup(ODR o, Odr_bool v);
 YAZ_EXPORT Odr_oct *odr_create_Odr_oct(ODR o, const unsigned char *buf,
                                        int sz);
 YAZ_EXPORT NMEM odr_extract_mem(ODR o);
@@ -234,16 +233,16 @@ YAZ_EXPORT int ber_tag(ODR o, void *p, int zclass, int tag,
 YAZ_EXPORT int ber_enctag(ODR o, int zclass, int tag, int constructed);
 YAZ_EXPORT int ber_dectag(const unsigned char *buf, int *zclass,
                           int *tag, int *constructed, int max);
-YAZ_EXPORT int odr_bool(ODR o, int **p, int opt, const char *name);
-YAZ_EXPORT int odr_integer(ODR o, odr_int_t **p, int opt, const char *name);
-YAZ_EXPORT int odr_enum(ODR o, odr_int_t **p, int opt, const char *name);
+YAZ_EXPORT int odr_bool(ODR o, Odr_bool **p, int opt, const char *name);
+YAZ_EXPORT int odr_integer(ODR o, Odr_int **p, int opt, const char *name);
+YAZ_EXPORT int odr_enum(ODR o, Odr_int **p, int opt, const char *name);
 YAZ_EXPORT int odr_implicit_settag(ODR o, int zclass, int tag);
 YAZ_EXPORT int ber_enclen(ODR o, int len, int lenlen, int exact);
 YAZ_EXPORT int ber_declen(const unsigned char *buf, int *len, int max);
 YAZ_EXPORT void odr_prname(ODR o, const char *name);
 YAZ_EXPORT int ber_null(ODR o);
 YAZ_EXPORT int odr_null(ODR o, Odr_null **p, int opt, const char *name);
-YAZ_EXPORT int ber_integer(ODR o, odr_int_t *val);
+YAZ_EXPORT int ber_integer(ODR o, Odr_int *val);
 YAZ_EXPORT int odr_constructed_begin(ODR o, void *p, int zclass, int tag,
                                      const char *name);
 YAZ_EXPORT int odr_constructed_end(ODR o);
@@ -304,7 +303,7 @@ YAZ_EXPORT char *odr_prepend(ODR o, const char *prefix, const char *old);
 typedef struct Odr_external
 {
     Odr_oid *direct_reference;       /* OPTIONAL */
-    odr_int_t *indirect_reference;   /* OPTIONAL */
+    Odr_int *indirect_reference;     /* OPTIONAL */
     char    *descriptor;             /* OPTIONAL */
     int which;
 #define ODR_EXTERNAL_single 0
index aaa8c2d..e4b2f3f 100644 (file)
@@ -58,7 +58,7 @@ typedef struct Z_ext_typeent
 struct Z_External
 {
     Odr_oid *direct_reference;
-    odr_int_t *indirect_reference;
+    Odr_int *indirect_reference;
     char *descriptor;
     int which;
 /* Generic types */
index f8caeab..1a07418 100644 (file)
@@ -54,7 +54,7 @@ typedef struct {
 #define Z_SRW_recordPacking_URL 2
     char *recordData_buf;
     int recordData_len;
-    odr_int_t *recordPosition;
+    Odr_int *recordPosition;
 } Z_SRW_record;
 
 typedef struct {
@@ -84,27 +84,27 @@ typedef struct {
         char *sortKeys;
         char *xSortKeys;
     } sort;
-    odr_int_t *startRecord;
-    odr_int_t *maximumRecords;
+    Odr_int *startRecord;
+    Odr_int *maximumRecords;
     char *recordSchema;
     char *recordPacking;
     char *recordXPath;
     char *database;
     char *stylesheet;
-    odr_int_t *resultSetTTL;
+    Odr_int *resultSetTTL;
 } Z_SRW_searchRetrieveRequest;
 
 typedef struct {
-    odr_int_t *numberOfRecords;
+    Odr_int *numberOfRecords;
     char * resultSetId;
-    odr_int_t *resultSetIdleTime;
+    Odr_int *resultSetIdleTime;
     
     Z_SRW_record *records;
     int num_records;
 
     Z_SRW_diagnostic *diagnostics;
     int num_diagnostics;
-    odr_int_t *nextRecordPosition;
+    Odr_int *nextRecordPosition;
 
     Z_SRW_extra_record **extra_records;  /* of size num_records */
 } Z_SRW_searchRetrieveResponse;
@@ -129,15 +129,15 @@ typedef struct {
         char *xcql;
         char *pqf;
     } scanClause;
-    odr_int_t *responsePosition;
-    odr_int_t *maximumTerms;
+    Odr_int *responsePosition;
+    Odr_int *maximumTerms;
     char *stylesheet;
     char *database;
 } Z_SRW_scanRequest;
 
 typedef struct {
     char *value;
-    odr_int_t *numberOfRecords;
+    Odr_int *numberOfRecords;
     char *displayTerm;
     char *whereInList;
 } Z_SRW_scanTerm;
@@ -238,7 +238,7 @@ YAZ_EXPORT int yaz_srw_str_to_pack(const char *str);
 
 YAZ_EXPORT char *yaz_uri_val(const char *path, const char *name, ODR o);
 YAZ_EXPORT void yaz_uri_val_int(const char *path, const char *name,
-                                ODR o, odr_int_t **intp);
+                                ODR o, Odr_int **intp);
 YAZ_EXPORT int yaz_srw_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
                               Z_SOAP **soap_package, ODR decode, char **charset);
 YAZ_EXPORT int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
index a134ae2..ef185aa 100644 (file)
 
 #include "odr-priv.h"
 
-static int ber_encinteger(ODR o, odr_int_t val);
-static int ber_decinteger(const unsigned char *buf, odr_int_t *val, int max);
+static int ber_encinteger(ODR o, Odr_int val);
+static int ber_decinteger(const unsigned char *buf, Odr_int *val, int max);
 
-int ber_integer(ODR o, odr_int_t *val)
+int ber_integer(ODR o, Odr_int *val)
 {
     int res;
 
@@ -61,7 +61,7 @@ int ber_integer(ODR o, odr_int_t *val)
 /*
  * Returns: number of bytes written or -1 for error (out of bounds).
  */
-int ber_encinteger(ODR o, odr_int_t val)
+int ber_encinteger(ODR o, Odr_int val)
 {
     int a, len;
     union { int i; unsigned char c[sizeof(int)]; } tmp;
@@ -82,7 +82,7 @@ int ber_encinteger(ODR o, odr_int_t val)
 /*
  * Returns: Number of bytes read or 0 if no match, -1 if error.
  */
-int ber_decinteger(const unsigned char *buf, odr_int_t *val, int max)
+int ber_decinteger(const unsigned char *buf, Odr_int *val, int max)
 {
     const unsigned char *b = buf;
     unsigned char fill;
index 3846685..4036f60 100644 (file)
@@ -106,7 +106,7 @@ static int cql_transform_parse_tok_line(cql_transform_t ct,
             wrbuf_puts(type_str, yaz_tok_parse_string(tp));
             t = yaz_tok_move(tp);
         }
-        elem->attributeType = nmem_longintdup(ct->nmem, 0);
+        elem->attributeType = nmem_intdup(ct->nmem, 0);
         if (sscanf(wrbuf_cstr(type_str), ODR_INT_PRINTF, elem->attributeType)
             != 1)
         {
@@ -140,7 +140,7 @@ static int cql_transform_parse_tok_line(cql_transform_t ct,
         {
             elem->which = Z_AttributeValue_numeric;
             elem->value.numeric =
-                nmem_longintdup(ct->nmem, atoi(value_str));
+                nmem_intdup(ct->nmem, atoi(value_str));
         }
         else
         {
index a1e31c8..a0efcfa 100644 (file)
@@ -35,8 +35,8 @@ bool_t *ill_get_bool (struct ill_get_ctl *gc, const char *name,
     return r;
 }
 
-odr_int_t *ill_get_int(struct ill_get_ctl *gc, const char *name,
-                       const char *sub, odr_int_t val)
+Odr_int *ill_get_int(struct ill_get_ctl *gc, const char *name,
+                       const char *sub, Odr_int val)
 {
     ODR o = gc->odr;
     char element[128];
@@ -54,8 +54,8 @@ odr_int_t *ill_get_int(struct ill_get_ctl *gc, const char *name,
     return odr_intdup(o, val);
 }
 
-odr_int_t *ill_get_enumerated (struct ill_get_ctl *gc, const char *name,
-                         const char *sub, odr_int_t val)
+Odr_int *ill_get_enumerated (struct ill_get_ctl *gc, const char *name,
+                         const char *sub, Odr_int val)
 {
     return ill_get_int(gc, name, sub, val);
 }
index 36dc823..1f9d415 100644 (file)
@@ -38,16 +38,16 @@ char *nmem_strdupn (NMEM mem, const char *src, size_t n)
     return dst;
 }
 
-long long int *nmem_longintdup(NMEM mem, long long int v)
+nmem_int_t *nmem_intdup(NMEM mem, nmem_int_t v)
 {
-    long long int *dst = (long long int*) nmem_malloc (mem, sizeof(*dst));
+    nmem_int_t *dst = (nmem_int_t*) nmem_malloc (mem, sizeof(*dst));
     *dst = v;
     return dst;
 }
 
-int *nmem_intdup(NMEM mem, int v)
+nmem_bool_t *nmem_booldup(NMEM mem, nmem_bool_t v)
 {
-    int *dst = (int*) nmem_malloc (mem, sizeof(*dst));
+    nmem_bool_t *dst = (nmem_bool_t*) nmem_malloc (mem, sizeof(*dst));
     *dst = v;
     return dst;
 }
index 114799f..0434183 100644 (file)
@@ -18,7 +18,7 @@
  * Top level boolean en/decoder.
  * Returns 1 on success, 0 on error.
  */
-int odr_bool(ODR o, int **p, int opt, const char *name)
+int odr_bool(ODR o, Odr_int **p, int opt, const char *name)
 {
     int res, cons = 0;
 
index 88b39de..d658ca8 100644 (file)
@@ -16,7 +16,7 @@
  * Top level enum en/decoder.
  * Returns 1 on success, 0 on error.
  */
-int odr_enum(ODR o, odr_int_t **p, int opt, const char *name)
+int odr_enum(ODR o, Odr_int **p, int opt, const char *name)
 {
     int res, cons = 0;
 
@@ -44,7 +44,7 @@ int odr_enum(ODR o, odr_int_t **p, int opt, const char *name)
         return 0;
     }
     if (o->direction == ODR_DECODE)
-        *p = (odr_int_t *)odr_malloc(o, sizeof(**p));
+        *p = (Odr_int *)odr_malloc(o, sizeof(**p));
     return ber_integer(o, *p);
 }
 /*
index 27cc35d..606f59b 100644 (file)
@@ -16,7 +16,7 @@
  * Top level integer en/decoder.
  * Returns 1 on success, 0 on error.
  */
-int odr_integer(ODR o, odr_int_t **p, int opt, const char *name)
+int odr_integer(ODR o, Odr_int **p, int opt, const char *name)
 {
     int res, cons = 0;
 
@@ -44,7 +44,7 @@ int odr_integer(ODR o, odr_int_t **p, int opt, const char *name)
         return 0;
     }
     if (o->direction == ODR_DECODE)
-        *p = (odr_int_t *)odr_malloc(o, sizeof(**p));
+        *p = (Odr_int *)odr_malloc(o, sizeof(**p));
     return ber_integer(o, *p);
 }
 /*
index 3f2b02b..028d06d 100644 (file)
@@ -47,14 +47,14 @@ char *odr_strdupn(ODR o, const char *str, size_t n)
     return nmem_strdupn(o->mem, str, n);
 }
 
-odr_int_t *odr_intdup(ODR o, odr_int_t v)
+Odr_int *odr_intdup(ODR o, Odr_int v)
 {
-    return nmem_longintdup(o->mem, v);
+    return nmem_intdup(o->mem, v);
 }
 
-odr_bool_t *odr_booldup(ODR o, odr_bool_t v)
+Odr_bool *odr_booldup(ODR o, Odr_bool v)
 {
-    return nmem_intdup(o->mem, v);
+    return nmem_booldup(o->mem, v);
 }
 
 int odr_total(ODR o)
index c25a795..9a150a4 100644 (file)
@@ -31,7 +31,7 @@ struct yaz_pqf_parser {
 
 static Z_RPNStructure *rpn_structure(struct yaz_pqf_parser *li, ODR o,
                                      int num_attr, int max_attr, 
-                                     odr_int_t *attr_list, char **attr_clist,
+                                     Odr_int *attr_list, char **attr_clist,
                                      Odr_oid **attr_set);
 
 static Odr_oid *query_oid_getvalbyname(struct yaz_pqf_parser *li, ODR o)
@@ -183,7 +183,7 @@ 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, odr_int_t *attr_list,
+                              int num_attr, Odr_int *attr_list,
                               char **attr_clist, Odr_oid **attr_set)
 {
     const char *cp;
@@ -239,7 +239,7 @@ static int p_query_parse_attr(struct yaz_pqf_parser *li, ODR o,
 }
 
 static Z_AttributesPlusTerm *rpn_term(struct yaz_pqf_parser *li, ODR o,
-                                      int num_attr, odr_int_t *attr_list,
+                                      int num_attr, Odr_int *attr_list,
                                       char **attr_clist, Odr_oid **attr_set)
 {
     Z_AttributesPlusTerm *zapt;
@@ -256,12 +256,12 @@ static Z_AttributesPlusTerm *rpn_term(struct yaz_pqf_parser *li, ODR o,
     else
     {
         int i, k = 0;
-        odr_int_t *attr_tmp;
+        Odr_int *attr_tmp;
 
         elements = (Z_AttributeElement**)
             odr_malloc (o, num_attr * sizeof(*elements));
 
-        attr_tmp = (odr_int_t *)odr_malloc(o, num_attr * 2 * sizeof(*attr_tmp));
+        attr_tmp = (Odr_int *)odr_malloc(o, num_attr * 2 * sizeof(*attr_tmp));
         memcpy(attr_tmp, attr_list, num_attr * 2 * sizeof(*attr_tmp));
         for (i = num_attr; --i >= 0; )
         {
@@ -348,7 +348,7 @@ static Z_AttributesPlusTerm *rpn_term(struct yaz_pqf_parser *li, ODR o,
 }
 
 static Z_Operand *rpn_simple(struct yaz_pqf_parser *li, ODR o,
-                             int num_attr, odr_int_t *attr_list,
+                             int num_attr, Odr_int *attr_list,
                              char **attr_clist,
                              Odr_oid **attr_set)
 {
@@ -484,7 +484,7 @@ static Z_ProximityOperator *rpn_proximity (struct yaz_pqf_parser *li, ODR o)
 
 static Z_Complex *rpn_complex(struct yaz_pqf_parser *li, ODR o,
                               int num_attr, int max_attr, 
-                              odr_int_t *attr_list, char **attr_clist,
+                              Odr_int *attr_list, char **attr_clist,
                               Odr_oid **attr_set)
 {
     Z_Complex *zc;
@@ -560,7 +560,7 @@ static void rpn_term_type(struct yaz_pqf_parser *li, ODR o)
                            
 static Z_RPNStructure *rpn_structure(struct yaz_pqf_parser *li, ODR o,
                                      int num_attr, int max_attr, 
-                                     odr_int_t *attr_list,
+                                     Odr_int *attr_list,
                                      char **attr_clist,
                                      Odr_oid **attr_set)
 {
@@ -623,7 +623,7 @@ static Z_RPNStructure *rpn_structure(struct yaz_pqf_parser *li, ODR o,
 Z_RPNQuery *p_query_rpn_mk(ODR o, struct yaz_pqf_parser *li, const char *qbuf)
 {
     Z_RPNQuery *zq;
-    odr_int_t attr_array[1024];
+    Odr_int attr_array[1024];
     char *attr_clist[512];
     Odr_oid *attr_set[512];
     Odr_oid *top_set = 0;
@@ -685,7 +685,7 @@ Z_AttributesPlusTerm *p_query_scan_mk(struct yaz_pqf_parser *li,
                                       Odr_oid **attributeSetP,
                                       const char *qbuf)
 {
-    odr_int_t attr_list[1024];
+    Odr_int attr_list[1024];
     char *attr_clist[512];
     Odr_oid *attr_set[512];
     int num_attr = 0;
index aebcdc0..19c771d 100644 (file)
@@ -2458,9 +2458,9 @@ static Z_NamePlusRecord *surrogatediagrec(association *assoc,
     return zget_surrogateDiagRec(assoc->encode, dbname, error, addinfo);
 }
 
-static Z_Records *pack_records(association *a, char *setname, odr_int_t start,
-                               odr_int_t *num, Z_RecordComposition *comp,
-                               odr_int_t *next, odr_int_t *pres,
+static Z_Records *pack_records(association *a, char *setname, Odr_int start,
+                               Odr_int *num, Z_RecordComposition *comp,
+                               Odr_int *next, Odr_int *pres,
                                Z_ReferenceId *referenceId,
                                Odr_oid *oid, int *errcode)
 {
@@ -2704,9 +2704,9 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb,
     Z_APDU *apdu = (Z_APDU *)odr_malloc(assoc->encode, sizeof(*apdu));
     Z_SearchResponse *resp = (Z_SearchResponse *)
         odr_malloc(assoc->encode, sizeof(*resp));
-    odr_int_t *nulint = odr_intdup(assoc->encode, 0);
-    odr_int_t *next = odr_intdup(assoc->encode, 0);
-    odr_int_t *none = odr_intdup(assoc->encode, Z_SearchResponse_none);
+    Odr_int *nulint = odr_intdup(assoc->encode, 0);
+    Odr_int *next = odr_intdup(assoc->encode, 0);
+    Odr_int *none = odr_intdup(assoc->encode, Z_SearchResponse_none);
     int returnedrecs = 0;
 
     apdu->which = Z_APDU_searchResponse;
@@ -2733,7 +2733,7 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb,
     else
     {
         bool_t *sr = odr_booldup(assoc->encode, 1);
-        odr_int_t *toget = odr_intdup(assoc->encode, 0);
+        Odr_int *toget = odr_intdup(assoc->encode, 0);
         Z_RecordComposition comp, *compp = 0;
 
         yaz_log(log_requestdetail, "resultCount: " ODR_INT_PRINTF, bsrt->hits);
@@ -2762,7 +2762,7 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb,
 
         if (*toget && !resp->records)
         {
-            odr_int_t *presst = odr_intdup(assoc->encode, 0);
+            Odr_int *presst = odr_intdup(assoc->encode, 0);
             /* Call bend_present if defined */
             if (assoc->init->bend_present)
             {
@@ -2872,8 +2872,8 @@ static Z_APDU *process_presentRequest(association *assoc, request *reqb,
     Z_PresentRequest *req = reqb->apdu_request->u.presentRequest;
     Z_APDU *apdu;
     Z_PresentResponse *resp;
-    odr_int_t *next;
-    odr_int_t *num;
+    Odr_int *next;
+    Odr_int *num;
     int errcode = 0;
     const char *errstring = 0;
 
@@ -2966,8 +2966,8 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb, int *fd)
     Z_APDU *apdu = (Z_APDU *)odr_malloc(assoc->encode, sizeof(*apdu));
     Z_ScanResponse *res = (Z_ScanResponse *)
         odr_malloc(assoc->encode, sizeof(*res));
-    odr_int_t *scanStatus = odr_intdup(assoc->encode, Z_Scan_failure);
-    odr_int_t *numberOfEntriesReturned = odr_intdup(assoc->encode, 0);
+    Odr_int *scanStatus = odr_intdup(assoc->encode, Z_Scan_failure);
+    Odr_int *numberOfEntriesReturned = odr_intdup(assoc->encode, 0);
     Z_ListEntries *ents = (Z_ListEntries *)
         odr_malloc(assoc->encode, sizeof(*ents));
     Z_DiagRecs *diagrecs_p = NULL;
@@ -3268,7 +3268,7 @@ static Z_APDU *process_deleteRequest(association *assoc, request *reqb,
     bdrr->statuses = 0;
     if (bdrr->num_setnames > 0)
     {
-        bdrr->statuses = (odr_int_t*) 
+        bdrr->statuses = (Odr_int*) 
             odr_malloc(assoc->encode, sizeof(*bdrr->statuses) *
                        bdrr->num_setnames);
         for (i = 0; i < bdrr->num_setnames; i++)
index 13e06db..f7c81ce 100644 (file)
@@ -122,8 +122,8 @@ typedef struct association
     association_state state;
 
     /* session parameters */
-    odr_int_t preferredMessageSize;
-    odr_int_t maximumRecordSize;
+    Odr_int preferredMessageSize;
+    Odr_int maximumRecordSize;
     int version;                  /* highest version-bit set (2 or 3) */
 
     unsigned cs_get_mask;
index a8a9f3e..869f4d5 100644 (file)
--- a/src/srw.c
+++ b/src/srw.c
@@ -61,7 +61,7 @@ xmlNodePtr add_xsd_string(xmlNodePtr ptr, const char *elem, const char *val)
 }
 
 static void add_xsd_integer(xmlNodePtr ptr, const char *elem,
-                            const odr_int_t *val)
+                            const Odr_int *val)
 {
     if (val)
     {
@@ -166,7 +166,7 @@ static int match_xsd_XML_n(xmlNodePtr ptr, const char *elem, ODR o,
 }
                      
 static int match_xsd_integer(xmlNodePtr ptr, const char *elem, ODR o,
-                             odr_int_t **val)
+                             Odr_int **val)
 {
 #if CHECK_TYPE
     struct _xmlAttr *attr;
index 99e417c..6284831 100644 (file)
@@ -279,7 +279,7 @@ static void yaz_srw_decodeauth(Z_SRW_PDU *sr, Z_HTTP_Request *hreq,
 }
 #endif
 
-void yaz_uri_val_int(const char *path, const char *name, ODR o, odr_int_t **intp)
+void yaz_uri_val_int(const char *path, const char *name, ODR o, Odr_int **intp)
 {
     const char *v = yaz_uri_val(path, name, o);
     if (v)
@@ -463,7 +463,7 @@ int yaz_srw_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
 
 #if YAZ_HAVE_XML2
 static int yaz_sru_decode_integer(ODR odr, const char *pname, 
-                                  const char *valstr, odr_int_t **valp,
+                                  const char *valstr, Odr_int **valp,
                                   Z_SRW_diagnostic **diag, int *num_diag,
                                   int min_value)
 {
@@ -1197,7 +1197,7 @@ int yaz_diag_srw_to_bib1(int code)
 }
 
 static void add_val_int(ODR o, char **name, char **value,  int *i,
-                        char *a_name, odr_int_t *val)
+                        char *a_name, Odr_int *val)
 {
     if (val)
     {
index 21849c6..cb433ad 100644 (file)
@@ -313,7 +313,7 @@ bool_t *boolVal(ODR odr, const char *str)
     return odr_booldup(odr, 1);
 }
 
-odr_int_t *intVal(ODR odr, const char *str)
+Odr_int *intVal(ODR odr, const char *str)
 {
     return odr_intdup(odr, atoi(str));
 }
index 4c2ae05..f2b8b3a 100644 (file)
@@ -136,6 +136,44 @@ static void tst(void)
     odr_destroy(odr_decode);
 }
 
+/* example from documentation.. 'Using Odr' */
+void do_nothing_useful(int value)
+{
+    ODR encode, decode;
+    Odr_int *valp, *resvalp;
+    char *bufferp;
+    int len;
+     
+    /* allocate streams */
+    if (!(encode = odr_createmem(ODR_ENCODE)))
+        return;
+    if (!(decode = odr_createmem(ODR_DECODE)))
+        return;
+
+    valp = &value;
+    if (odr_integer(encode, &valp, 0, 0) == 0)
+    {
+        printf("encoding went bad\n");
+        return;
+    }
+    bufferp = odr_getbuf(encode, &len, 0);
+    printf("length of encoded data is %d\n", len);
+
+    /* now let's decode the thing again */
+    odr_setbuf(decode, bufferp, len, 0);
+    if (odr_integer(decode, &resvalp, 0, 0) == 0)
+    {
+        printf("decoding went bad\n");
+        return;
+    }
+    /* ODR_INT_PRINTF format for printf (such as %d) */
+    printf("the value is " ODR_INT_PRINTF "\n", *resvalp);
+
+    /* clean up */
+    odr_destroy(encode);
+    odr_destroy(decode);
+}
+
 int main(int argc, char **argv)
 {
     YAZ_CHECK_INIT(argc, argv);
index bd757fb..fb454a6 100755 (executable)
@@ -1217,11 +1217,11 @@ proc asnBasicEXTERNAL {} {
 }
 
 proc asnBasicINTEGER {} {
-    return {odr_integer {odr_int_t}}
+    return {odr_integer {Odr_int}}
 }
 
 proc asnBasicENUMERATED {} {
-    return {odr_enum {odr_int_t}}
+    return {odr_enum {Odr_int}}
 }
 
 proc asnBasicNULL {} {
@@ -1229,7 +1229,7 @@ proc asnBasicNULL {} {
 }
 
 proc asnBasicBOOLEAN {} {
-    return {odr_bool {bool_t}}
+    return {odr_bool {Odr_bool}}
 }
 
 proc asnBasicOCTET {} {