64-bit BER integers. Fixes bug #114.
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 16 Jun 2009 08:43:48 +0000 (10:43 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 16 Jun 2009 08:43:48 +0000 (10:43 +0200)
Introduce a new type, odr_int_t, which is equivalent to 'long lont int'
This type is pretty much available everywhere..  was introduced in C99.
This change makes YAZ non-backwards compatible .. both source-wise
and binary wise. However, it is expected to be fairly trivial to update
applications.

31 files changed:
client/client.c
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/grs1disp.c
src/ill-get.c
src/logrpn.c
src/nmemsdup.c
src/odr_enum.c
src/odr_int.c
src/odr_mem.c
src/pquery.c
src/querytowrbuf.c
src/rpn2cql.c
src/seshigh.c
src/session.h
src/srw.c
src/srwutil.c
src/xmlquery.c
src/zget.c
src/zoom-c.c
test/tst_record_conv.c
test/tstodr.c
util/yaz-asncomp
util/yaz-illclient.c
ztest/dummy-opac.c
ztest/ztest.c

index f528d96..d6ec0c3 100644 (file)
@@ -104,7 +104,7 @@ static int smallSetUpperBound = 0;
 static int largeSetLowerBound = 1;
 static int mediumSetPresentNumber = 0;
 static Z_ElementSetNames *elementSetNames = 0;
-static int setno = 1;                   /* current set offset */
+static odr_int_t 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];
@@ -526,7 +526,7 @@ static void render_diag(Z_DiagnosticFormat *diag) {
         case Z_DiagnosticFormat_s_defaultDiagRec: {
             Z_DefaultDiagFormat *dd = ds->u.defaultDiagRec;
             /* ### should check `dd->diagnosticSetId' */
-            printf("code=%d (%s)", *dd->condition,
+            printf("code=" ODR_INT_PRINTF " (%s)", *dd->condition,
                    diagbib1_str(*dd->condition));
             /* Both types of addinfo are the same, so use type-pun */
             if (dd->u.v2Addinfo != 0)
@@ -1121,7 +1121,8 @@ static void display_diagrecs(Z_DiagRec **pp, int num)
             if (oid_oidcmp(r->diagnosticSetId, yaz_oid_diagset_bib_1))
                 printf("Unknown diagset: %s\n", diag_name);
         }
-        printf("    [%d] %s", *r->condition, diagbib1_str(*r->condition));
+        printf("    [" ODR_INT_PRINTF "] %s",
+               *r->condition, diagbib1_str(*r->condition));
         switch (r->which)
         {
         case Z_DefaultDiagFormat_v2Addinfo:
@@ -1182,8 +1183,7 @@ static int send_deleteResultSetRequest(const char *arg)
                names[0], names[1], names[2], names[3],
                names[4], names[5], names[6], names[7]);
 
-    req->deleteFunction = (int *)
-        odr_malloc(out, sizeof(*req->deleteFunction));
+    req->deleteFunction = odr_intdup(out, 0);
     if (req->num_resultSetList > 0)
     {
         *req->deleteFunction = Z_DeleteResultSetRequest_list;
@@ -1542,7 +1542,7 @@ static void display_queryExpression(const char *lead, Z_QueryExpression *qe)
                 printf("%s", term->u.characterString);
                 break;
             case Z_Term_numeric:
-                printf("%d", *term->u.numeric);
+                printf(ODR_INT_PRINTF, *term->u.numeric);
                 break;
             case Z_Term_null:
                 printf("null");
@@ -1582,7 +1582,8 @@ static void display_searchResult(Z_OtherInformation *o)
                     display_queryExpression("recommendation",
                         sr->elements[j]->subqueryRecommendation);
                     if (sr->elements[j]->subqueryCount)
-                        printf(" cnt=%d", *sr->elements[j]->subqueryCount);
+                        printf(" cnt=" ODR_INT_PRINTF,
+                               *sr->elements[j]->subqueryCount);
                     if (sr->elements[j]->subqueryId)
                         printf(" id=%s ", sr->elements[j]->subqueryId);
                 }
@@ -1600,7 +1601,7 @@ static int process_searchResponse(Z_SearchResponse *res)
         printf("Search was a success.\n");
     else
         printf("Search was a bloomin' failure.\n");
-    printf("Number of hits: %d", *res->resultCount);
+    printf("Number of hits: " ODR_INT_PRINTF, *res->resultCount);
     last_hit_count = *res->resultCount;
     if (setnumber >= 0)
         printf(", setno %d", setnumber);
@@ -1619,12 +1620,12 @@ static int process_searchResponse(Z_SearchResponse *res)
         case Z_SearchResponse_estimate:
             printf("estimate"); break;
         default:
-            printf("%d", *res->resultSetStatus);
+            printf(ODR_INT_PRINTF, *res->resultSetStatus);
         }
         putchar('\n');
     }
     display_searchResult(res->additionalSearchInfo);
-    printf("records returned: %d\n",
+    printf("records returned: " ODR_INT_PRINTF "\n",
            *res->numberOfRecordsReturned);
     setno += *res->numberOfRecordsReturned;
     if (res->records)
@@ -1639,12 +1640,12 @@ static void print_level(int iLevel)
         printf(" ");
 }
 
-static void print_int(int iLevel, const char *pTag, int *pInt)
+static void print_int(int iLevel, const char *pTag, odr_int_t *pInt)
 {
     if (pInt != NULL)
     {
         print_level(iLevel);
-        printf("%s: %d\n", pTag, *pInt);
+        printf("%s: " ODR_INT_PRINTF "\n", pTag, *pInt);
     }
 }
 
@@ -2044,9 +2045,7 @@ static Z_External *create_ItemOrderExternal(const char *type, int itemno,
     r->u.itemOrder->u.esRequest->notToKeep->resultSetItem->resultSetId = "1";
 
     r->u.itemOrder->u.esRequest->notToKeep->resultSetItem->item =
-        (int *) odr_malloc(out, sizeof(int));
-    *r->u.itemOrder->u.esRequest->notToKeep->resultSetItem->item = itemno;
-
+        odr_intdup(out, itemno);
     if (!strcmp (type, "item") || !strcmp(type, "2"))
     {
         printf("using item-request\n");
@@ -2283,8 +2282,7 @@ static int cmd_update_Z3950(int version, int action_no, const char *recid,
         }
         toKeep->elementSetName = 0;
 
-        toKeep->action = (int *) odr_malloc(out, sizeof(*toKeep->action));
-        *toKeep->action = action_no;
+        toKeep->action = odr_intdup(out, action_no);
 
         notToKeep = r->u.update0->u.esRequest->notToKeep = (Z_IU0SuppliedRecords *)
             odr_malloc(out, sizeof(*r->u.update0->u.esRequest->notToKeep));
@@ -2331,8 +2329,7 @@ static int cmd_update_Z3950(int version, int action_no, const char *recid,
         }
         toKeep->elementSetName = 0;
         toKeep->actionQualifier = 0;
-        toKeep->action = (int *) odr_malloc(out, sizeof(*toKeep->action));
-        *toKeep->action = action_no;
+        toKeep->action = odr_intdup(out, action_no);
 
         notToKeep = r->u.update->u.esRequest->notToKeep = (Z_IUSuppliedRecords *)
             odr_malloc(out, sizeof(*r->u.update->u.esRequest->notToKeep));
@@ -2653,7 +2650,7 @@ static int cmd_setnames(const char *arg)
 /* PRESENT SERVICE ----------------------------- */
 
 static void parse_show_args(const char *arg_c, char *setstring,
-                            int *start, int *number)
+                            odr_int_t *start, odr_int_t *number)
 {
     char arg[40];
     char *p;
@@ -2689,7 +2686,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;
-    int nos = 1;
+    odr_int_t nos = 1;
     char setstring[100];
 
     req->referenceId = set_refid(out);
@@ -2771,7 +2768,8 @@ static int send_presentRequest(const char *arg)
         compo.u.simple = elementSetNames;
     }
     send_apdu(apdu);
-    printf("Sent presentRequest (%d+%d).\n", setno, nos);
+    printf("Sent presentRequest (" ODR_INT_PRINTF "+" ODR_INT_PRINTF ").\n",
+           setno, nos);
     return 2;
 }
 
@@ -2779,7 +2777,7 @@ static int send_presentRequest(const char *arg)
 static int send_SRW_presentRequest(const char *arg)
 {
     char setstring[100];
-    int nos = 1;
+    odr_int_t nos = 1;
     Z_SRW_PDU *sr = srw_sr;
 
     if (!sr)
@@ -2925,7 +2923,7 @@ int cmd_cancel_find(const char *arg) {
 }
 
 int send_scanrequest(const char *set,  const char *query,
-                     int pp, int num, const char *term)
+                     odr_int_t pp, odr_int_t num, const char *term)
 {
     Z_APDU *apdu = zget_APDU(out, Z_APDU_scanRequest);
     Z_ScanRequest *req = apdu->u.scanRequest;
@@ -3061,7 +3059,7 @@ void display_term(Z_TermInfo *t)
             t->term->u.general->buf);
 
     if (t->globalOccurrences)
-        printf(" (%d)\n", *t->globalOccurrences);
+        printf(" (" ODR_INT_PRINTF ")\n", *t->globalOccurrences);
     else
         printf("\n");
 }
@@ -3074,12 +3072,12 @@ void process_scanResponse(Z_ScanResponse *res)
 
     printf("Received ScanResponse\n");
     print_refid(res->referenceId);
-    printf("%d entries", *res->numberOfEntriesReturned);
+    printf(ODR_INT_PRINTF " entries", *res->numberOfEntriesReturned);
     if (res->positionOfTerm)
-        printf(", position=%d", *res->positionOfTerm);
+        printf(", position=" ODR_INT_PRINTF, *res->positionOfTerm);
     printf("\n");
     if (*res->scanStatus != Z_Scan_success)
-        printf("Scan returned code %d\n", *res->scanStatus);
+        printf("Scan returned code " ODR_INT_PRINTF "\n", *res->scanStatus);
     if (!res->entries)
         return;
     if ((entries = res->entries->entries))
@@ -3112,7 +3110,7 @@ void process_sortResponse(Z_SortResponse *res)
     case Z_SortResponse_failure:
         printf("failure"); break;
     default:
-        printf("unknown (%d)", *res->sortStatus);
+        printf("unknown (" ODR_INT_PRINTF ")", *res->sortStatus);
     }
     printf("\n");
     print_refid (res->referenceId);
@@ -3123,15 +3121,16 @@ void process_sortResponse(Z_SortResponse *res)
 
 void process_deleteResultSetResponse(Z_DeleteResultSetResponse *res)
 {
-    printf("Got deleteResultSetResponse status=%d\n",
+    printf("Got deleteResultSetResponse status=" ODR_INT_PRINTF "\n",
            *res->deleteOperationStatus);
     if (res->deleteListStatuses)
     {
         int i;
         for (i = 0; i < res->deleteListStatuses->num; i++)
         {
-            printf("%s status=%d\n", res->deleteListStatuses->elements[i]->id,
-                    *res->deleteListStatuses->elements[i]->status);
+            printf("%s status=" ODR_INT_PRINTF "\n",
+                   res->deleteListStatuses->elements[i]->id,
+                   *res->deleteListStatuses->elements[i]->status);
         }
     }
 }
@@ -3906,7 +3905,7 @@ static void handle_srw_record(Z_SRW_record *rec)
 {
     if (rec->recordPosition)
     {
-        printf("pos=%d", *rec->recordPosition);
+        printf("pos=" ODR_INT_PRINTF, *rec->recordPosition);
         setno = *rec->recordPosition + 1;
     }
     if (rec->recordSchema)
@@ -3946,7 +3945,7 @@ static void handle_srw_response(Z_SRW_searchRetrieveResponse *res)
             printf("Details: %s\n", res->diagnostics[i].details);
     }
     if (res->numberOfRecords)
-        printf("Number of hits: %d\n", *res->numberOfRecords);
+        printf("Number of hits: " ODR_INT_PRINTF "\n", *res->numberOfRecords);
     for (i = 0; i<res->num_records; i++)
         handle_srw_record(res->records + i);
 }
@@ -3960,7 +3959,7 @@ static void handle_srw_scan_term(Z_SRW_scanTerm *term)
     else
         printf("No value:");
     if (term->numberOfRecords)
-        printf(" %d", *term->numberOfRecords);
+        printf(" " ODR_INT_PRINTF, *term->numberOfRecords);
     if (term->whereInList)
         printf(" %s", term->whereInList);
     if (term->value && term->displayTerm)
@@ -4176,7 +4175,7 @@ static void wait_and_handle_response(int one_response_only)
                     display_records(apdu->u.presentResponse->records);
                 else
                     printf("No records.\n");
-                printf("nextResultSetPosition = %d\n",
+                printf("nextResultSetPosition = " ODR_INT_PRINTF "\n",
                         *apdu->u.presentResponse->nextResultSetPosition);
                 break;
             case Z_APDU_sortResponse:
index 2cf6fa2..aa6a9ea 100644 (file)
@@ -61,7 +61,7 @@ typedef struct {
     bend_request request;
     bend_association association;
     int *fd;
-    int hits;                  /* number of hits */
+    odr_int_t 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 */
-    int occurrences;    /* no of occurrences or -1 if error (see below) */
+    odr_int_t 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 */
 
-    int *step_size;     /* step size */
-    int term_position;  /* desired index of term in result list/returned */
+    odr_int_t *step_size;     /* step size */
+    odr_int_t 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
@@ -179,7 +179,7 @@ typedef struct bend_delete_rr {
     char **setnames;
     Z_ReferenceId *referenceId;
     int delete_status;      /* status for the whole operation */
-    int *statuses;          /* status each set - indexed as setnames */
+    odr_int_t *statuses;    /* status each set - indexed as setnames */
     ODR stream;
     ODR print; 
 } bend_delete_rr;
index 8e9add0..4157e0f 100644 (file)
@@ -101,6 +101,8 @@ YAZ_EXPORT void nmem_strsplit_blank(NMEM nmem, const char *dstr,
 */
 YAZ_EXPORT int *nmem_intdup(NMEM nmem, int v);
 
+YAZ_EXPORT long long int *nmem_longintdup(NMEM nmem, long long int v);
+
 /** \brief transfers memory from one NMEM handle to another
     \param src source NMEM handle
     \param dst destination NMEM handle
index d687d14..c0dc755 100644 (file)
 
 YAZ_BEGIN_CDECL
 
+#define ODR_INT_PRINTF "%lld"
+
+typedef long long int odr_int_t;
+typedef int odr_bool_t;
+
 #ifndef bool_t
 #define bool_t int
 #endif
@@ -184,7 +189,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 int *odr_intdup(ODR o, int v);
+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_oct *odr_create_Odr_oct(ODR o, const unsigned char *buf,
                                        int sz);
 YAZ_EXPORT NMEM odr_extract_mem(ODR o);
@@ -229,15 +235,15 @@ 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, int **p, int opt, const char *name);
-YAZ_EXPORT int odr_enum(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_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, int *val);
+YAZ_EXPORT int ber_integer(ODR o, odr_int_t *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);
@@ -298,7 +304,7 @@ YAZ_EXPORT char *odr_prepend(ODR o, const char *prefix, const char *old);
 typedef struct Odr_external
 {
     Odr_oid *direct_reference;       /* OPTIONAL */
-    int     *indirect_reference;     /* OPTIONAL */
+    odr_int_t *indirect_reference;   /* OPTIONAL */
     char    *descriptor;             /* OPTIONAL */
     int which;
 #define ODR_EXTERNAL_single 0
index 8a8c42c..aaa8c2d 100644 (file)
@@ -58,7 +58,7 @@ typedef struct Z_ext_typeent
 struct Z_External
 {
     Odr_oid *direct_reference;
-    int *indirect_reference;
+    odr_int_t *indirect_reference;
     char *descriptor;
     int which;
 /* Generic types */
index 572ce8b..f8caeab 100644 (file)
@@ -54,7 +54,7 @@ typedef struct {
 #define Z_SRW_recordPacking_URL 2
     char *recordData_buf;
     int recordData_len;
-    int *recordPosition;
+    odr_int_t *recordPosition;
 } Z_SRW_record;
 
 typedef struct {
@@ -84,27 +84,27 @@ typedef struct {
         char *sortKeys;
         char *xSortKeys;
     } sort;
-    int *startRecord;
-    int *maximumRecords;
+    odr_int_t *startRecord;
+    odr_int_t *maximumRecords;
     char *recordSchema;
     char *recordPacking;
     char *recordXPath;
     char *database;
     char *stylesheet;
-    int *resultSetTTL;
+    odr_int_t *resultSetTTL;
 } Z_SRW_searchRetrieveRequest;
 
 typedef struct {
-    int * numberOfRecords;
+    odr_int_t *numberOfRecords;
     char * resultSetId;
-    int * resultSetIdleTime;
+    odr_int_t *resultSetIdleTime;
     
     Z_SRW_record *records;
     int num_records;
 
     Z_SRW_diagnostic *diagnostics;
     int num_diagnostics;
-    int *nextRecordPosition;
+    odr_int_t *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;
-    int *responsePosition;
-    int *maximumTerms;
+    odr_int_t *responsePosition;
+    odr_int_t *maximumTerms;
     char *stylesheet;
     char *database;
 } Z_SRW_scanRequest;
 
 typedef struct {
     char *value;
-    int *numberOfRecords;
+    odr_int_t *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, int **intp);
+                                ODR o, odr_int_t **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 13e07cb..a134ae2 100644 (file)
 
 #include "odr-priv.h"
 
-static int ber_encinteger(ODR o, int val);
-static int ber_decinteger(const unsigned char *buf, int *val, int max);
+static int ber_encinteger(ODR o, odr_int_t val);
+static int ber_decinteger(const unsigned char *buf, odr_int_t *val, int max);
 
-int ber_integer(ODR o, int *val)
+int ber_integer(ODR o, odr_int_t *val)
 {
     int res;
 
@@ -61,7 +61,7 @@ int ber_integer(ODR o, int *val)
 /*
  * Returns: number of bytes written or -1 for error (out of bounds).
  */
-int ber_encinteger(ODR o, int val)
+int ber_encinteger(ODR o, odr_int_t val)
 {
     int a, len;
     union { int i; unsigned char c[sizeof(int)]; } tmp;
@@ -82,7 +82,7 @@ int ber_encinteger(ODR o, int val)
 /*
  * Returns: Number of bytes read or 0 if no match, -1 if error.
  */
-int ber_decinteger(const unsigned char *buf, int *val, int max)
+int ber_decinteger(const unsigned char *buf, odr_int_t *val, int max)
 {
     const unsigned char *b = buf;
     unsigned char fill;
index ea6c20a..3846685 100644 (file)
@@ -106,8 +106,8 @@ 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_intdup(ct->nmem, 0);
-        if (sscanf(wrbuf_cstr(type_str), "%d", elem->attributeType)
+        elem->attributeType = nmem_longintdup(ct->nmem, 0);
+        if (sscanf(wrbuf_cstr(type_str), ODR_INT_PRINTF, elem->attributeType)
             != 1)
         {
             wrbuf_destroy(type_str);
@@ -140,7 +140,7 @@ static int cql_transform_parse_tok_line(cql_transform_t ct,
         {
             elem->which = Z_AttributeValue_numeric;
             elem->value.numeric =
-                nmem_intdup(ct->nmem, atoi(value_str));
+                nmem_longintdup(ct->nmem, atoi(value_str));
         }
         else
         {
index f6a64ce..892fdf5 100644 (file)
@@ -22,8 +22,9 @@ static void display_variant(WRBUF w, Z_Variant *v, int level)
 
     for (i = 0; i < v->num_triples; i++)
     {
-        printf("%*sclass=%d,type=%d", level * 4, "", *v->triples[i]->zclass,
-            *v->triples[i]->type);
+        printf("%*sclass=" ODR_INT_PRINTF ",type=" ODR_INT_PRINTF,
+               level * 4, "", *v->triples[i]->zclass,
+               *v->triples[i]->type);
         if (v->triples[i]->which == Z_Triple_internationalString)
             printf(",value=%s\n", v->triples[i]->value.internationalString);
         else
@@ -47,11 +48,11 @@ static void display_grs1(WRBUF w, Z_GenericRecord *r, int level)
         t = r->elements[i];
         wrbuf_printf(w, "(");
         if (t->tagType)
-            wrbuf_printf(w, "%d,", *t->tagType);
+            wrbuf_printf(w, ODR_INT_PRINTF, *t->tagType);
         else
             wrbuf_printf(w, "?,");
         if (t->tagValue->which == Z_StringOrNumeric_numeric)
-            wrbuf_printf(w, "%d) ", *t->tagValue->u.numeric);
+            wrbuf_printf(w, ODR_INT_PRINTF ") ", *t->tagValue->u.numeric);
         else
             wrbuf_printf(w, "%s) ", t->tagValue->u.string);
         if (t->content->which == Z_ElementData_subtree)
@@ -71,7 +72,7 @@ static void display_grs1(WRBUF w, Z_GenericRecord *r, int level)
         }
         else if (t->content->which == Z_ElementData_numeric)
         {
-            wrbuf_printf(w, "%d\n", *t->content->u.numeric);
+            wrbuf_printf(w, ODR_INT_PRINTF "\n", *t->content->u.numeric);
         }
         else if (t->content->which == Z_ElementData_oid)
         {
index d0d107b..a1e31c8 100644 (file)
@@ -35,8 +35,8 @@ bool_t *ill_get_bool (struct ill_get_ctl *gc, const char *name,
     return r;
 }
 
-int *ill_get_int (struct ill_get_ctl *gc, const char *name,
-                  const char *sub, int val)
+odr_int_t *ill_get_int(struct ill_get_ctl *gc, const char *name,
+                       const char *sub, odr_int_t val)
 {
     ODR o = gc->odr;
     char element[128];
@@ -54,8 +54,8 @@ int *ill_get_int (struct ill_get_ctl *gc, const char *name,
     return odr_intdup(o, val);
 }
 
-int *ill_get_enumerated (struct ill_get_ctl *gc, const char *name,
-                         const char *sub, int val)
+odr_int_t *ill_get_enumerated (struct ill_get_ctl *gc, const char *name,
+                         const char *sub, odr_int_t val)
 {
     return ill_get_int(gc, name, sub, val);
 }
index e34b6b2..58468d5 100644 (file)
@@ -206,7 +206,8 @@ static void zlog_attributes(Z_AttributesPlusTerm *t, int depth,
             yaz_log (loglevel, "%*.0s%s %s", depth, "", attset_name, str);
             break;
         case Z_AttributeValue_complex:
-            yaz_log (loglevel, "%*.0s%s attributeType=%d complex",
+            yaz_log (loglevel, "%*.0s%s attributeType=" ODR_INT_PRINTF
+                     " complex",
                   depth, "", attset_name, *element->attributeType);
             for (i = 0; i<element->value.complex->num_list; i++)
             {
@@ -216,7 +217,8 @@ static void zlog_attributes(Z_AttributesPlusTerm *t, int depth,
                              element->value.complex->list[i]->u.string);
                 else if (element->value.complex->list[i]->which ==
                          Z_StringOrNumeric_numeric)
-                    yaz_log (loglevel, "%*.0s  numeric: '%d'", depth, "",
+                    yaz_log (loglevel, "%*.0s  numeric: '" ODR_INT_PRINTF
+                             " '", depth, "",
                              *element->value.complex->list[i]->u.numeric);
             }
             break;
@@ -279,7 +281,8 @@ static void zlog_structure(Z_RPNStructure *zs, int depth,
             yaz_log (loglevel, "%*.0s %s", depth, "", complex_op_name(op) );
             break;
         case Z_Operator_prox:
-            yaz_log (loglevel, "%*.0s prox excl=%s dist=%d order=%s "
+            yaz_log (loglevel, "%*.0s prox excl=%s dist=" ODR_INT_PRINTF
+                     " order=%s "
                      "rel=%s unit=%s",
                      depth, "", op->u.prox->exclusion ?
                      (*op->u.prox->exclusion ? "T" : "F") : "N", 
@@ -313,7 +316,8 @@ static void zlog_structure(Z_RPNStructure *zs, int depth,
                          zapt->term->u.characterString);
                 break;
             case Z_Term_numeric:
-                yaz_log (loglevel, "%*.0s term '%d' (numeric)", depth, "",
+                yaz_log (loglevel, "%*.0s term '" ODR_INT_PRINTF
+                         "' (numeric)", depth, "",
                          *zapt->term->u.numeric);
                 break;
             case Z_Term_null:
index d30dbaf..36dc823 100644 (file)
@@ -38,9 +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)
+{
+    long long int *dst = (long long int*) nmem_malloc (mem, sizeof(*dst));
+    *dst = v;
+    return dst;
+}
+
 int *nmem_intdup(NMEM mem, int v)
 {
-    int *dst = (int*) nmem_malloc (mem, sizeof(int));
+    int *dst = (int*) nmem_malloc (mem, sizeof(*dst));
     *dst = v;
     return dst;
 }
index 40189b1..88b39de 100644 (file)
@@ -16,7 +16,7 @@
  * Top level enum en/decoder.
  * Returns 1 on success, 0 on error.
  */
-int odr_enum(ODR o, int **p, int opt, const char *name)
+int odr_enum(ODR o, odr_int_t **p, int opt, const char *name)
 {
     int res, cons = 0;
 
@@ -44,7 +44,7 @@ int odr_enum(ODR o, int **p, int opt, const char *name)
         return 0;
     }
     if (o->direction == ODR_DECODE)
-        *p = (int *)odr_malloc(o, sizeof(int));
+        *p = (odr_int_t *)odr_malloc(o, sizeof(**p));
     return ber_integer(o, *p);
 }
 /*
index a039f43..27cc35d 100644 (file)
@@ -16,7 +16,7 @@
  * Top level integer en/decoder.
  * Returns 1 on success, 0 on error.
  */
-int odr_integer(ODR o, int **p, int opt, const char *name)
+int odr_integer(ODR o, odr_int_t **p, int opt, const char *name)
 {
     int res, cons = 0;
 
@@ -44,7 +44,7 @@ int odr_integer(ODR o, int **p, int opt, const char *name)
         return 0;
     }
     if (o->direction == ODR_DECODE)
-        *p = (int *)odr_malloc(o, sizeof(int));
+        *p = (odr_int_t *)odr_malloc(o, sizeof(**p));
     return ber_integer(o, *p);
 }
 /*
index 55478c0..3f2b02b 100644 (file)
@@ -47,7 +47,12 @@ char *odr_strdupn(ODR o, const char *str, size_t n)
     return nmem_strdupn(o->mem, str, n);
 }
 
-int *odr_intdup(ODR o, int v)
+odr_int_t *odr_intdup(ODR o, odr_int_t v)
+{
+    return nmem_longintdup(o->mem, v);
+}
+
+odr_bool_t *odr_booldup(ODR o, odr_bool_t v)
 {
     return nmem_intdup(o->mem, v);
 }
index 16d826a..c25a795 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, 
-                                     int *attr_list, char **attr_clist,
+                                     odr_int_t *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, int *attr_list,
+                              int num_attr, odr_int_t *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, int *attr_list,
+                                      int num_attr, odr_int_t *attr_list,
                                       char **attr_clist, Odr_oid **attr_set)
 {
     Z_AttributesPlusTerm *zapt;
@@ -256,13 +256,13 @@ static Z_AttributesPlusTerm *rpn_term(struct yaz_pqf_parser *li, ODR o,
     else
     {
         int i, k = 0;
-        int *attr_tmp;
+        odr_int_t *attr_tmp;
 
         elements = (Z_AttributeElement**)
             odr_malloc (o, num_attr * sizeof(*elements));
 
-        attr_tmp = (int *)odr_malloc (o, num_attr * 2 * sizeof(int));
-        memcpy (attr_tmp, attr_list, num_attr * 2 * sizeof(int));
+        attr_tmp = (odr_int_t *)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; )
         {
             int j;
@@ -348,7 +348,8 @@ 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, int *attr_list, char **attr_clist,
+                             int num_attr, odr_int_t *attr_list,
+                             char **attr_clist,
                              Odr_oid **attr_set)
 {
     Z_Operand *zo;
@@ -395,9 +396,9 @@ static Z_ProximityOperator *rpn_proximity (struct yaz_pqf_parser *li, ODR o)
         return NULL;
     }
     if (*li->lex_buf == '1')
-        p->exclusion = odr_intdup (o, 1);
+        p->exclusion = odr_booldup(o, 1);
     else if (*li->lex_buf == '0')
-        p->exclusion = odr_intdup (o, 0);
+        p->exclusion = odr_booldup(o, 0);
     else if (*li->lex_buf == 'v' || *li->lex_buf == 'n')
         p->exclusion = NULL;
     else
@@ -425,9 +426,9 @@ static Z_ProximityOperator *rpn_proximity (struct yaz_pqf_parser *li, ODR o)
         return NULL;
     }
     if (*li->lex_buf == '1')
-        p->ordered = odr_intdup (o, 1);
+        p->ordered = odr_booldup(o, 1);
     else if (*li->lex_buf == '0')
-        p->ordered = odr_intdup (o, 0);
+        p->ordered = odr_booldup(o, 0);
     else
     {
         li->error = YAZ_PQF_ERROR_PROXIMITY;
@@ -483,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, 
-                              int *attr_list, char **attr_clist,
+                              odr_int_t *attr_list, char **attr_clist,
                               Odr_oid **attr_set)
 {
     Z_Complex *zc;
@@ -559,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, 
-                                     int *attr_list,
+                                     odr_int_t *attr_list,
                                      char **attr_clist,
                                      Odr_oid **attr_set)
 {
@@ -622,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;
-    int attr_array[1024];
+    odr_int_t attr_array[1024];
     char *attr_clist[512];
     Odr_oid *attr_set[512];
     Odr_oid *top_set = 0;
@@ -684,7 +685,7 @@ Z_AttributesPlusTerm *p_query_scan_mk(struct yaz_pqf_parser *li,
                                       Odr_oid **attributeSetP,
                                       const char *qbuf)
 {
-    int attr_list[1024];
+    odr_int_t attr_list[1024];
     char *attr_clist[512];
     Odr_oid *attr_set[512];
     int num_attr = 0;
index 088b307..ee975f4 100644 (file)
@@ -55,11 +55,12 @@ static void yaz_attribute_element_to_wrbuf(WRBUF b,
     switch (element->which) 
     {
     case Z_AttributeValue_numeric:
-        wrbuf_printf(b,"@attr %s%s%d=%d ", setname, sep,
+        wrbuf_printf(b,"@attr %s%s" ODR_INT_PRINTF "=" ODR_INT_PRINTF " ",
+                     setname, sep,
                      *element->attributeType, *element->value.numeric);
         break;
     case Z_AttributeValue_complex:
-        wrbuf_printf(b,"@attr %s%s\"%d=", setname, sep,
+        wrbuf_printf(b,"@attr %s%s\""ODR_INT_PRINTF "=", setname, sep,
                      *element->attributeType);
         for (i = 0; i<element->value.complex->num_list; i++)
         {
@@ -71,7 +72,7 @@ static void yaz_attribute_element_to_wrbuf(WRBUF b,
                               element->value.complex->list[i]->u.string);
             else if (element->value.complex->list[i]->which ==
                      Z_StringOrNumeric_numeric)
-                wrbuf_printf (b, "%d", 
+                wrbuf_printf (b, ODR_INT_PRINTF, 
                               *element->value.complex->list[i]->u.numeric);
         }
         wrbuf_printf(b, "\" ");
@@ -117,7 +118,8 @@ static void yaz_apt_to_wrbuf(WRBUF b, const Z_AttributesPlusTerm *zapt)
                             strlen(zapt->term->u.characterString));
         break;
     case Z_Term_numeric:
-        wrbuf_printf(b, "@term numeric %d ", *zapt->term->u.numeric);
+        wrbuf_printf(b, "@term numeric " ODR_INT_PRINTF " ",
+                     *zapt->term->u.numeric);
         break;
     case Z_Term_null:
         wrbuf_printf(b, "@term null x");
@@ -142,7 +144,8 @@ static void yaz_rpnstructure_to_wrbuf(WRBUF b, const Z_RPNStructure *zs)
             else
                 wrbuf_putc(b, '0');
 
-            wrbuf_printf(b, " %d %d %d ", *op->u.prox->distance,
+            wrbuf_printf(b, " " ODR_INT_PRINTF " %d " 
+                         ODR_INT_PRINTF " ", *op->u.prox->distance,
                          *op->u.prox->ordered,
                          *op->u.prox->relationType);
 
@@ -158,7 +161,7 @@ static void yaz_rpnstructure_to_wrbuf(WRBUF b, const Z_RPNStructure *zs)
                 wrbuf_printf(b, "%d", op->u.prox->which);
             }
             if (op->u.prox->u.known)
-                wrbuf_printf(b, " %d ", *op->u.prox->u.known);
+                wrbuf_printf(b, " " ODR_INT_PRINTF " ", *op->u.prox->u.known);
             else
                 wrbuf_printf(b, " 0 ");
         }
@@ -240,7 +243,7 @@ void wrbuf_diags(WRBUF b, int num_diagnostics,Z_DiagRec **diags)
     {
         Z_DefaultDiagFormat *e=diags[0]->u.defaultFormat;
         if (e->condition)
-            wrbuf_printf(b, "%d ",*e->condition);
+            wrbuf_printf(b, ODR_INT_PRINTF " ",*e->condition);
         else
             wrbuf_printf(b, "?? ");
         if ((e->which==Z_DefaultDiagFormat_v2Addinfo) && (e->u.v2Addinfo))
index de06fab..692c55a 100644 (file)
@@ -86,7 +86,7 @@ static int rpn2cql_simple(cql_transform_t ct,
             sterm = (const char *) term->u.general->buf;
             break;
         case Z_Term_numeric:
-            wrbuf_printf(w, "%d", *term->u.numeric);
+            wrbuf_printf(w, ODR_INT_PRINTF, *term->u.numeric);
             break;
         case Z_Term_characterString:
             sterm = term->u.characterString;
index 8c0c3fa..aebcdc0 100644 (file)
@@ -972,7 +972,8 @@ static void srw_bend_search(association *assoc, request *req,
                 int number = srw_req->maximumRecords ? *srw_req->maximumRecords : 0;
                 int start = srw_req->startRecord ? *srw_req->startRecord : 1;
                 
-                yaz_log(log_requestdetail, "Request to pack %d+%d out of %d",
+                yaz_log(log_requestdetail, "Request to pack %d+%d out of "
+                        ODR_INT_PRINTF,
                         start, number, rr.hits);
                 
                 srw_res->numberOfRecords = odr_intdup(assoc->encode, rr.hits);
@@ -1129,11 +1130,11 @@ static void srw_bend_search(association *assoc, request *req,
             wrbuf_printf(wr, "ERROR info:http/%d", *http_code);
         else if (srw_res->numberOfRecords)
         {
-            wrbuf_printf(wr, "OK %d",
+            wrbuf_printf(wr, "OK " ODR_INT_PRINTF,
                          (srw_res->numberOfRecords ?
                           *srw_res->numberOfRecords : 0));
         }
-        wrbuf_printf(wr, " %s %d+%d", 
+        wrbuf_printf(wr, " %s " ODR_INT_PRINTF " +%d", 
                      (srw_res->resultSetId ?
                       srw_res->resultSetId : "-"),
                      (srw_req->startRecord ? *srw_req->startRecord : 1), 
@@ -1401,7 +1402,7 @@ static void srw_bend_scan(association *assoc, request *req,
         else
             wrbuf_printf(wr, "OK - - ");
 
-        wrbuf_printf(wr, "%d+%d+0 ",
+        wrbuf_printf(wr, ODR_INT_PRINTF "+" ODR_INT_PRINTF " ",
                      (srw_req->responsePosition ? 
                       *srw_req->responsePosition : 1),
                      (srw_req->maximumTerms ?
@@ -2457,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, int start,
-                               int *num, Z_RecordComposition *comp,
-                               int *next, int *pres,
+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,
                                Z_ReferenceId *referenceId,
                                Odr_oid *oid, int *errcode)
 {
@@ -2479,8 +2480,9 @@ static Z_Records *pack_records(association *a, char *setname, int start,
     *num = 0;
     *next = 0;
 
-    yaz_log(log_requestdetail, "Request to pack %d+%d %s", start, toget, setname);
-    yaz_log(log_requestdetail, "pms=%d, mrs=%d", a->preferredMessageSize,
+    yaz_log(log_requestdetail, "Request to pack " ODR_INT_PRINTF "+%d %s", start, toget, setname);
+    yaz_log(log_requestdetail, "pms=" ODR_INT_PRINTF
+            ", mrs=" ODR_INT_PRINTF, a->preferredMessageSize,
         a->maximumRecordSize);
     for (recno = start; reclist->num_records < toget; recno++)
     {
@@ -2575,7 +2577,8 @@ static Z_Records *pack_records(association *a, char *setname, int start,
             }
             else /* too big entirely */
             {
-                yaz_log(log_requestdetail, "Record > maxrcdsz this=%d max=%d",
+                yaz_log(log_requestdetail, "Record > maxrcdsz "
+                        "this=%d max=" ODR_INT_PRINTF,
                         this_length, a->maximumRecordSize);
                 reclist->records[reclist->num_records] =
                     surrogatediagrec(a, freq.basename, 17, 0);
@@ -2701,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));
-    int *nulint = odr_intdup(assoc->encode, 0);
-    int *next = odr_intdup(assoc->encode, 0);
-    int *none = odr_intdup(assoc->encode, Z_SearchResponse_none);
+    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);
     int returnedrecs = 0;
 
     apdu->which = Z_APDU_searchResponse;
@@ -2723,17 +2726,17 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb,
         resp->resultCount = nulint;
         resp->numberOfRecordsReturned = nulint;
         resp->nextResultSetPosition = nulint;
-        resp->searchStatus = nulint;
+        resp->searchStatus = odr_booldup(assoc->encode, 0);
         resp->resultSetStatus = none;
         resp->presentStatus = 0;
     }
     else
     {
-        bool_t *sr = odr_intdup(assoc->encode, 1);
-        int *toget = odr_intdup(assoc->encode, 0);
+        bool_t *sr = odr_booldup(assoc->encode, 1);
+        odr_int_t *toget = odr_intdup(assoc->encode, 0);
         Z_RecordComposition comp, *compp = 0;
 
-        yaz_log(log_requestdetail, "resultCount: %d", bsrt->hits);
+        yaz_log(log_requestdetail, "resultCount: " ODR_INT_PRINTF, bsrt->hits);
 
         resp->records = 0;
         resp->resultCount = &bsrt->hits;
@@ -2759,7 +2762,7 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb,
 
         if (*toget && !resp->records)
         {
-            int *presst = odr_intdup(assoc->encode, 0);
+            odr_int_t *presst = odr_intdup(assoc->encode, 0);
             /* Call bend_present if defined */
             if (assoc->init->bend_present)
             {
@@ -2837,7 +2840,7 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb,
         if (bsrt->errcode)
             wrbuf_printf(wr, "ERROR %d", bsrt->errcode);
         else
-            wrbuf_printf(wr, "OK %d", bsrt->hits);
+            wrbuf_printf(wr, "OK " ODR_INT_PRINTF, bsrt->hits);
         wrbuf_printf(wr, " %s 1+%d ",
                      req->resultSetName, returnedrecs);
         yaz_query_to_wrbuf(wr, req->query);
@@ -2869,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;
-    int *next;
-    int *num;
+    odr_int_t *next;
+    odr_int_t *num;
     int errcode = 0;
     const char *errstring = 0;
 
@@ -2936,9 +2939,10 @@ static Z_APDU *process_presentRequest(association *assoc, request *reqb,
         else if (*resp->presentStatus == Z_PresentStatus_success)
             wrbuf_printf(wr, "OK -  ");
         else
-            wrbuf_printf(wr, "Partial %d - ", *resp->presentStatus);
+            wrbuf_printf(wr, "Partial " ODR_INT_PRINTF " - ",
+                         *resp->presentStatus);
 
-        wrbuf_printf(wr, " %s %d+%d ",
+        wrbuf_printf(wr, " %s " ODR_INT_PRINTF "+" ODR_INT_PRINTF " ",
                 req->resultSetId, *req->resultSetStartPoint,
                 *req->numberOfRecordsRequested);
         yaz_log(log_request, "%s", wrbuf_cstr(wr) );
@@ -2962,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));
-    int *scanStatus = odr_intdup(assoc->encode, Z_Scan_failure);
-    int *numberOfEntriesReturned = odr_intdup(assoc->encode, 0);
+    odr_int_t *scanStatus = odr_intdup(assoc->encode, Z_Scan_failure);
+    odr_int_t *numberOfEntriesReturned = odr_intdup(assoc->encode, 0);
     Z_ListEntries *ents = (Z_ListEntries *)
         odr_malloc(assoc->encode, sizeof(*ents));
     Z_DiagRecs *diagrecs_p = NULL;
@@ -3061,7 +3065,8 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb, int *fd)
             *scanStatus = Z_Scan_success;
         ents->entries = tab;
         ents->num_entries = bsrr->num_entries;
-        res->numberOfEntriesReturned = &ents->num_entries;          
+        res->numberOfEntriesReturned = odr_intdup(assoc->encode, 
+                                                   ents->num_entries);
         res->positionOfTerm = &bsrr->term_position;
         for (i = 0; i < bsrr->num_entries; i++)
         {
@@ -3100,7 +3105,7 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb, int *fd)
                     odr_malloc(assoc->encode, o->len = o->size =
                                strlen(bsrr->entries[i].term));
                 memcpy(o->buf, bsrr->entries[i].term, o->len);
-                yaz_log(YLOG_DEBUG, "  term #%d: '%s' (%d)", i,
+                yaz_log(YLOG_DEBUG, "  term #%d: '%s' (" ODR_INT_PRINTF ")", i,
                          bsrr->entries[i].term, bsrr->entries[i].occurrences);
             }
             else
@@ -3139,7 +3144,8 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb, int *fd)
         else
             wrbuf_printf(wr, "OK"); 
 
-        wrbuf_printf(wr, " %d - %d+%d+%d",
+        wrbuf_printf(wr, " " ODR_INT_PRINTF " - " ODR_INT_PRINTF "+" 
+                     ODR_INT_PRINTF "+" ODR_INT_PRINTF,
                      res->numberOfEntriesReturned ?
                      *res->numberOfEntriesReturned : 0,
                      (req->preferredPositionInResponse ?
@@ -3262,7 +3268,7 @@ static Z_APDU *process_deleteRequest(association *assoc, request *reqb,
     bdrr->statuses = 0;
     if (bdrr->num_setnames > 0)
     {
-        bdrr->statuses = (int*) 
+        bdrr->statuses = (odr_int_t*) 
             odr_malloc(assoc->encode, sizeof(*bdrr->statuses) *
                        bdrr->num_setnames);
         for (i = 0; i < bdrr->num_setnames; i++)
index d96432c..13e06db 100644 (file)
@@ -122,8 +122,8 @@ typedef struct association
     association_state state;
 
     /* session parameters */
-    int preferredMessageSize;
-    int maximumRecordSize;
+    odr_int_t preferredMessageSize;
+    odr_int_t maximumRecordSize;
     int version;                  /* highest version-bit set (2 or 3) */
 
     unsigned cs_get_mask;
index c962922..a8a9f3e 100644 (file)
--- a/src/srw.c
+++ b/src/srw.c
@@ -60,12 +60,13 @@ xmlNodePtr add_xsd_string(xmlNodePtr ptr, const char *elem, const char *val)
     return add_xsd_string_ns(ptr, elem, val, 0);
 }
 
-static void add_xsd_integer(xmlNodePtr ptr, const char *elem, const int *val)
+static void add_xsd_integer(xmlNodePtr ptr, const char *elem,
+                            const odr_int_t *val)
 {
     if (val)
     {
-        char str[30];
-        sprintf(str, "%d", *val);
+        char str[40];
+        sprintf(str, ODR_INT_PRINTF, *val);
         xmlNewTextChild(ptr, 0, BAD_CAST elem, BAD_CAST str);
     }
 }
@@ -164,7 +165,8 @@ static int match_xsd_XML_n(xmlNodePtr ptr, const char *elem, ODR o,
     return 1;
 }
                      
-static int match_xsd_integer(xmlNodePtr ptr, const char *elem, ODR o, int **val)
+static int match_xsd_integer(xmlNodePtr ptr, const char *elem, ODR o,
+                             odr_int_t **val)
 {
 #if CHECK_TYPE
     struct _xmlAttr *attr;
index 7b62217..99e417c 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, int **intp)
+void yaz_uri_val_int(const char *path, const char *name, ODR o, odr_int_t **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, int **valp,
+                                  const char *valstr, odr_int_t **valp,
                                   Z_SRW_diagnostic **diag, int *num_diag,
                                   int min_value)
 {
@@ -1197,13 +1197,13 @@ int yaz_diag_srw_to_bib1(int code)
 }
 
 static void add_val_int(ODR o, char **name, char **value,  int *i,
-                        char *a_name, int *val)
+                        char *a_name, odr_int_t *val)
 {
     if (val)
     {
         name[*i] = a_name;
-        value[*i] = (char *) odr_malloc(o, 30);
-        sprintf(value[*i], "%d", *val);
+        value[*i] = (char *) odr_malloc(o, 40);
+        sprintf(value[*i], ODR_INT_PRINTF, *val);
         (*i)++;
     }
 }
index f2c5338..21849c6 100644 (file)
@@ -40,10 +40,11 @@ void yaz_query2xml_attribute_element(const Z_AttributeElement *element,
         if (setname)
             xmlNewProp(node, BAD_CAST "set", BAD_CAST setname);
 
-        sprintf(formstr, "%d", *element->attributeType);
+        assert(*element->attributeType > 0 && *element->attributeType < 20);
+        sprintf(formstr, ODR_INT_PRINTF, *element->attributeType);
         xmlNewProp(node, BAD_CAST "type", BAD_CAST formstr);
 
-        sprintf(formstr, "%d", *element->value.numeric);
+        sprintf(formstr, ODR_INT_PRINTF, *element->value.numeric);
         xmlNewProp(node, BAD_CAST "value", BAD_CAST formstr);
     }
     else if (element->which == Z_AttributeValue_complex)
@@ -56,7 +57,7 @@ void yaz_query2xml_attribute_element(const Z_AttributeElement *element,
             if (setname)
                 xmlNewProp(node, BAD_CAST "set", BAD_CAST setname);
             
-            sprintf(formstr, "%d", *element->attributeType);
+            sprintf(formstr, ODR_INT_PRINTF, *element->attributeType);
             xmlNewProp(node, BAD_CAST "type", BAD_CAST formstr);
             
             if (element->value.complex->list[i]->which ==
@@ -68,7 +69,7 @@ void yaz_query2xml_attribute_element(const Z_AttributeElement *element,
             else if (element->value.complex->list[i]->which ==
                      Z_StringOrNumeric_numeric)
             {
-                sprintf(formstr, "%d",
+                sprintf(formstr, ODR_INT_PRINTF,
                         *element->value.complex->list[i]->u.numeric);
                 xmlNewProp(node, BAD_CAST "value", BAD_CAST formstr);
             }
@@ -93,7 +94,7 @@ xmlNodePtr yaz_query2xml_term(const Z_Term *term,
         break;
     case Z_Term_numeric:
         type = "numeric";
-       sprintf(formstr, "%d", *term->u.numeric);
+       sprintf(formstr, ODR_INT_PRINTF, *term->u.numeric);
        t = xmlNewText(BAD_CAST formstr);       
         break;
     case Z_Term_characterString:
@@ -172,7 +173,7 @@ void yaz_query2xml_operator(Z_Operator *op, xmlNodePtr node)
             else
                 xmlNewProp(node, BAD_CAST "exclusion", BAD_CAST "false");
         }
-        sprintf(formstr, "%d", *op->u.prox->distance);
+        sprintf(formstr, ODR_INT_PRINTF, *op->u.prox->distance);
         xmlNewProp(node, BAD_CAST "distance", BAD_CAST formstr);
 
         if (*op->u.prox->ordered)
@@ -180,13 +181,13 @@ void yaz_query2xml_operator(Z_Operator *op, xmlNodePtr node)
         else 
             xmlNewProp(node, BAD_CAST "ordered", BAD_CAST "false");
        
-        sprintf(formstr, "%d", *op->u.prox->relationType);
+        sprintf(formstr, ODR_INT_PRINTF, *op->u.prox->relationType);
         xmlNewProp(node, BAD_CAST "relationType", BAD_CAST formstr);
         
         switch(op->u.prox->which)
         {
         case Z_ProximityOperator_known:
-            sprintf(formstr, "%d", *op->u.prox->u.known);
+            sprintf(formstr, ODR_INT_PRINTF, *op->u.prox->u.known);
             xmlNewProp(node, BAD_CAST "knownProximityUnit",
                        BAD_CAST formstr);
             break;
@@ -308,11 +309,11 @@ void yaz_query2xml(const Z_Query *q, xmlDocPtr *docp)
 bool_t *boolVal(ODR odr, const char *str)
 {
     if (*str == '\0' || strchr("0fF", *str))
-        return odr_intdup(odr, 0);
-    return odr_intdup(odr, 1);
+        return odr_booldup(odr, 0);
+    return odr_booldup(odr, 1);
 }
 
-int *intVal(ODR odr, const char *str)
+odr_int_t *intVal(ODR odr, const char *str)
 {
     return odr_intdup(odr, atoi(str));
 }
@@ -372,7 +373,7 @@ void yaz_xml2query_operator(const xmlNode *ptr, Z_Operator **op,
         if (atval)
             pop->ordered = boolVal(odr, atval);
         else
-            pop->ordered = odr_intdup(odr, 1);
+            pop->ordered = odr_booldup(odr, 1);
 
         atval = (const char *) xmlGetProp((xmlNodePtr) ptr,
                                           BAD_CAST "relationType");
index 0308373..d0c23d6 100644 (file)
@@ -54,7 +54,7 @@ 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
@@ -75,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;
@@ -96,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;
@@ -218,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;
@@ -230,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;
index a7dced4..fbade55 100644 (file)
@@ -3137,7 +3137,7 @@ static Z_ItemOrder *encode_item_order(ZOOM_package p)
         req->u.esRequest->notToKeep->resultSetItem->resultSetId =
             odr_strdup(p->odr_out, str);
         req->u.esRequest->notToKeep->resultSetItem->item =
-            (int *) odr_malloc(p->odr_out, sizeof(int));
+            odr_intdup(p->odr_out, 0);
         
         str = ZOOM_options_get(p->options, "itemorder-item");
         *req->u.esRequest->notToKeep->resultSetItem->item =
index 2ca35d0..ffe3c4f 100644 (file)
@@ -182,10 +182,12 @@ static int conv_convert_test(yaz_record_conv_t p,
             else if (strcmp(output_expect_record, wrbuf_cstr(output_record)))
             {
                 ret = 0;
-                printf("got-output_record len=%d: %s\n", 
-                       wrbuf_len(output_record),wrbuf_cstr(output_record));
-                printf("output_expect_record len=%d %s\n",
-                       strlen(output_expect_record), output_expect_record);
+                printf("got-output_record len=%ld: %s\n", 
+                       (long) wrbuf_len(output_record),
+                       wrbuf_cstr(output_record));
+                printf("output_expect_record len=%ld %s\n",
+                       (long) strlen(output_expect_record),
+                       output_expect_record);
             }
             else
             {
index 8aa0154..4c2ae05 100644 (file)
@@ -25,7 +25,7 @@ void tst_MySequence1(ODR encode, ODR decode)
     s->second->buf = (unsigned char *) "hello";
     s->second->len = 5;
     s->second->size = 0;
-    s->third = odr_intdup(encode, 1);
+    s->third = odr_booldup(encode, 1);
     s->fourth = odr_nullval();
     s->fifth = odr_intdup(encode, YC_MySequence_enum1);
     
@@ -80,7 +80,7 @@ void tst_MySequence2(ODR encode, ODR decode)
     s->second->buf = (unsigned char *) "hello";
     s->second->len = 5;
     s->second->size = 0;
-    s->third = odr_intdup(encode, 1);
+    s->third = odr_booldup(encode, 1);
     s->fourth = odr_nullval();
     s->fifth = odr_intdup(encode, YC_MySequence_enum1);
     s->myoid = odr_getoidbystr(encode, MYOID);
index e0a86b1..bd757fb 100755 (executable)
@@ -1217,11 +1217,11 @@ proc asnBasicEXTERNAL {} {
 }
 
 proc asnBasicINTEGER {} {
-    return {odr_integer {int}}
+    return {odr_integer {odr_int_t}}
 }
 
 proc asnBasicENUMERATED {} {
-    return {odr_enum {int}}
+    return {odr_enum {odr_int_t}}
 }
 
 proc asnBasicNULL {} {
index cdaf416..ef71659 100644 (file)
@@ -368,7 +368,7 @@ ILL_Extension *makepromptextension(struct prog_args *args, ODR odr) {
     odr_reset(odr_prt); /*!*/
 
     e->identifier = odr_intdup(odr,1);
-    e->critical = odr_intdup(odr,0);
+    e->critical = odr_booldup(odr,0);
     e->item = (Odr_any *) odr_malloc(odr,sizeof(*e->item));
     if ( ! z_External(odr_ext, &ext,0,0) ) {
         yaz_log(YLOG_FATAL,"Encoding of z_External failed ");
@@ -427,7 +427,7 @@ ILL_Extension *makeoclcextension(struct prog_args *args, ODR odr) {
     odr_reset(odr_prt); /*!*/
 
     e->identifier = odr_intdup(odr,1);
-    e->critical = odr_intdup(odr,0);
+    e->critical = odr_booldup(odr,0);
     e->item = (Odr_any *) odr_malloc(odr,sizeof(*e->item));
     if ( ! z_External(odr_ext, &ext,0,0) ) {
         yaz_log(YLOG_FATAL,"Encoding of z_External failed ");
@@ -608,7 +608,7 @@ void checkerr( ILL_Status_Or_Error_Report *staterr ) {
                     printf("Already forwarded: \n");
                     break;
                 case ILL_User_Error_Report_intermediary_problem:
-                    printf("Intermediary problem: %d\n", 
+                    printf("Intermediary problem: " ODR_INT_PRINTF "\n", 
                         *uerr->u.intermediary_problem);
                     break;
                 case ILL_User_Error_Report_security_problem:
@@ -616,7 +616,7 @@ void checkerr( ILL_Status_Or_Error_Report *staterr ) {
                         getillstring(uerr->u.security_problem));
                     break;
                 case ILL_User_Error_Report_unable_to_perform:
-                    printf("Unable to perform: %d\n", 
+                    printf("Unable to perform: " ODR_INT_PRINTF "\n", 
                           *uerr->u.unable_to_perform);
                     break;
                 default:
@@ -628,11 +628,11 @@ void checkerr( ILL_Status_Or_Error_Report *staterr ) {
             ILL_Provider_Error_Report *perr= err->provider_error_report;
             switch( perr->which ) {
                 case ILL_Provider_Error_Report_general_problem:
-                    printf("General Problem: %d:", 
+                    printf("General Problem: " ODR_INT_PRINTF ":", 
                           *perr->u.general_problem);
                     break;
                 case ILL_Provider_Error_Report_transaction_id_problem:
-                    printf("Transaction Id Problem: %d:", 
+                    printf("Transaction Id Problem: " ODR_INT_PRINTF ":", 
                           *perr->u.general_problem);
                     break;
                 case ILL_Provider_Error_Report_state_transition_prohibited:
index f44d042..47d9f56 100644 (file)
@@ -65,13 +65,13 @@ Z_OPACRecord *dummy_opac(int num, ODR odr, const char *marc_input)
         hc->circulationData[0] = (Z_CircRecord *)
              odr_malloc(odr, sizeof(**hc->circulationData));
 
-        hc->circulationData[0]->availableNow = odr_intdup(odr, 1);
+        hc->circulationData[0]->availableNow = odr_booldup(odr, 1);
         hc->circulationData[0]->availablityDate = 0;
         hc->circulationData[0]->availableThru = 0;
         hc->circulationData[0]->restrictions = 0;
         hc->circulationData[0]->itemId = "1226176";
-        hc->circulationData[0]->renewable = odr_intdup(odr, 0);
-        hc->circulationData[0]->onHold = odr_intdup(odr, 0);
+        hc->circulationData[0]->renewable = odr_booldup(odr, 0);
+        hc->circulationData[0]->onHold = odr_booldup(odr, 0);
         hc->circulationData[0]->enumAndChron = 0;
         hc->circulationData[0]->midspine = 0;
         hc->circulationData[0]->temporaryLocation = 0;
index 974d2da..f426eb9 100644 (file)
@@ -134,10 +134,10 @@ int ztest_esrequest(void *handle, bend_esrequest_rr *rr)
 
     if (rr->esr->packageName)
         yaz_log(log_level, "packagename: %s", rr->esr->packageName);
-    yaz_log(log_level, "Waitaction: %d", *rr->esr->waitAction);
+    yaz_log(log_level, "Waitaction: " ODR_INT_PRINTF, *rr->esr->waitAction);
 
 
-    yaz_log(log_level, "function: %d", *rr->esr->function);
+    yaz_log(log_level, "function: " ODR_INT_PRINTF, *rr->esr->function);
 
     if (!rr->esr->taskSpecificParameters)
     {
@@ -172,7 +172,7 @@ int ztest_esrequest(void *handle, bend_esrequest_rr *rr)
             {
                 yaz_log(log_level, "resultsetItem");
                 yaz_log(log_level, "setId: %s", n->resultSetItem->resultSetId);
-                yaz_log(log_level, "item: %d", *n->resultSetItem->item);
+                yaz_log(log_level, "item: " ODR_INT_PRINTF, *n->resultSetItem->item);
             }
             if (n->itemRequest)
             {
@@ -254,7 +254,8 @@ int ztest_esrequest(void *handle, bend_esrequest_rr *rr)
                 }
                 if (item_req)
                 {
-                    yaz_log(log_level, "ILL protocol version = %d",
+                    yaz_log(log_level, "ILL protocol version = "
+                            ODR_INT_PRINTF,
                             *item_req->protocol_version_num);
                 }
             }
@@ -345,7 +346,8 @@ int ztest_esrequest(void *handle, bend_esrequest_rr *rr)
                     yaz_log(log_level, " specialUpdate");
                     break;
                 default:
-                    yaz_log(log_level, " unknown (%d)", *toKeep->action);
+                    yaz_log(log_level, " unknown (" ODR_INT_PRINTF ")",
+                            *toKeep->action);
                 }
             }
             if (toKeep->databaseName)
@@ -402,8 +404,7 @@ int ztest_esrequest(void *handle, bend_esrequest_rr *rr)
                 ext->u.update->u.taskPackage->originPart = keep;
                 ext->u.update->u.taskPackage->targetPart = targetPart;
 
-                keep->action = (int *) odr_malloc(rr->stream, sizeof(int));
-                *keep->action = *toKeep->action;
+                keep->action = odr_intdup(rr->stream, *toKeep->action);
                 keep->databaseName =
                     odr_strdup(rr->stream, toKeep->databaseName);
                 keep->schema = 0;