From: Adam Dickmeiss Date: Thu, 18 Jun 2009 13:47:48 +0000 (+0200) Subject: Merge branch 'master' into longint X-Git-Tag: v3.0.47~2 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=e709ab8b395212d2d3d12ad215a3aa2272654c62;hp=82b56be0c22f75d8d40f295e09ca8b7c628fa530 Merge branch 'master' into longint --- diff --git a/client/client.c b/client/client.c index a58a7b3..732acfc 100644 --- a/client/client.c +++ b/client/client.c @@ -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 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) @@ -1123,7 +1123,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: @@ -1184,8 +1185,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; @@ -1544,7 +1544,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"); @@ -1584,7 +1584,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); } @@ -1602,7 +1603,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); @@ -1621,12 +1622,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) @@ -1641,7 +1642,16 @@ 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 *pInt) +{ + if (pInt != NULL) + { + print_level(iLevel); + printf("%s: " ODR_INT_PRINTF "\n", pTag, *pInt); + } +} + +static void print_bool(int iLevel, const char *pTag, Odr_bool *pInt) { if (pInt != NULL) { @@ -1794,10 +1804,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; } @@ -2046,9 +2056,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"); @@ -2285,8 +2293,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)); @@ -2333,8 +2340,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)); @@ -2655,7 +2661,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 *start, Odr_int *number) { char arg[40]; char *p; @@ -2691,7 +2697,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 nos = 1; char setstring[100]; req->referenceId = set_refid(out); @@ -2773,7 +2779,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; } @@ -2781,7 +2788,7 @@ static int send_presentRequest(const char *arg) static int send_SRW_presentRequest(const char *arg) { char setstring[100]; - int nos = 1; + Odr_int nos = 1; Z_SRW_PDU *sr = srw_sr; if (!sr) @@ -2927,7 +2934,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 pp, Odr_int num, const char *term) { Z_APDU *apdu = zget_APDU(out, Z_APDU_scanRequest); Z_ScanRequest *req = apdu->u.scanRequest; @@ -3063,7 +3070,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"); } @@ -3076,12 +3083,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)) @@ -3114,7 +3121,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); @@ -3125,15 +3132,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); } } } @@ -3908,7 +3916,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) @@ -3948,7 +3956,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; inum_records; i++) handle_srw_record(res->records + i); } @@ -3962,7 +3970,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) @@ -4178,7 +4186,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: diff --git a/doc/asn.xml b/doc/asn.xml index bb84b52..c787d4f 100644 --- a/doc/asn.xml +++ b/doc/asn.xml @@ -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 int. For ASN.1 constructs that have no direct + such as Odr_int 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 The ODR Module) provides auxiliary definitions. @@ -308,10 +309,10 @@ typedef struct Z_ext_typeent optionsOdr_bitmaskEmpty bitmask - preferredMessageSizeint30*1024 + preferredMessageSizeOdr_int30*1024 - maximumRecordSizeint30*1024 + maximumRecordSizeOdr_int30*1024 idAuthenticationZ_IdAuthenticationNULL @@ -360,13 +361,13 @@ typedef struct Z_ext_typeent optionsOdr_bitmaskEmpty bitmask - preferredMessageSizeint30*1024 + preferredMessageSizeOdr_int30*1024 - maximumRecordSizeint30*1024 + maximumRecordSizeOdr_int30*1024 - resultbool_tTRUE + resultOdr_boolTRUE implementationIdchar*"id)" @@ -405,22 +406,22 @@ typedef struct Z_ext_typeent referenceIdZ_ReferenceIdNULL - smallSetUpperBoundint0 + smallSetUpperBoundOdr_int0 - largeSetLowerBoundint1 + largeSetLowerBoundOdr_int1 - mediumSetPresentNumberint0 + mediumSetPresentNumberOdr_int0 - replaceIndicatorbool_tTRUE + replaceIndicatorOdr_boolTRUE resultSetNamechar *"default" - num_databaseNamesint0 + num_databaseNamesOdr_int0 databaseNameschar **NULL @@ -469,22 +470,22 @@ typedef struct Z_ext_typeent referenceIdZ_ReferenceIdNULL - resultCountint0 + resultCountOdr_int0 - numberOfRecordsReturnedint0 + numberOfRecordsReturnedOdr_int0 - nextResultSetPositionint0 + nextResultSetPositionOdr_int0 - searchStatusbool_tTRUE + searchStatusOdr_boolTRUE - resultSetStatusintNULL + resultSetStatusOdr_intNULL - presentStatusintNULL + presentStatusOdr_intNULL recordsZ_RecordsNULL @@ -521,13 +522,13 @@ typedef struct Z_ext_typeent resultSetIdchar*"default" - resultSetStartPointint1 + resultSetStartPointOdr_int1 - numberOfRecordsRequestedint10 + numberOfRecordsRequestedOdr_int10 - num_rangesint0 + num_rangesOdr_int0 additionalRangesZ_RangeNULL @@ -539,13 +540,13 @@ typedef struct Z_ext_typeent preferredRecordSyntaxOdr_oidNULL - maxSegmentCountintNULL + maxSegmentCountOdr_intNULL - maxRecordSizeintNULL + maxRecordSizeOdr_intNULL - maxSegmentSizeintNULL + maxSegmentSizeOdr_intNULL otherInfoZ_OtherInformationNULL @@ -572,13 +573,13 @@ typedef struct Z_ext_typeent referenceIdZ_ReferenceIdNULL - numberOfRecordsReturnedint0 + numberOfRecordsReturnedOdr_int0 - nextResultSetPositionint0 + nextResultSetPositionOdr_int0 - presentStatusintZ_PresentStatus_success + presentStatusOdr_intZ_PresentStatus_success recordsZ_RecordsNULL @@ -609,10 +610,10 @@ typedef struct Z_ext_typeent Z_ReferenceIdNULL - deleteFunctionintZ_DeleteResultSetRequest_list + deleteFunctionOdr_intZ_DeleteResultSetRequest_list - num_idsint0 + num_idsOdr_int0 resultSetListchar**NULL @@ -643,19 +644,19 @@ typedef struct Z_ext_typeent referenceIdZ_ReferenceIdNULL - deleteOperationStatusint + deleteOperationStatusOdr_int Z_DeleteStatus_success - num_statusesint0 + num_statusesOdr_int0 deleteListStatusesZ_ListStatus**NULL - numberNotDeletedintNULL + numberNotDeletedOdr_intNULL - num_bulkStatusesint0 + num_bulkStatusesOdr_int0 bulkStatusesZ_ListStatusNUL @@ -689,7 +690,7 @@ typedef struct Z_ext_typeent referenceIdZ_ReferenceIdNULL - num_databaseNamesint0 + num_databaseNamesOdr_int0 databaseNameschar**NULL @@ -701,13 +702,13 @@ typedef struct Z_ext_typeent termListAndStartPointZ_AttributesPlus... NULL - stepSizeintNULL + stepSizeOdr_intNULL - numberOfTermsRequestedint20 + numberOfTermsRequestedOdr_int20 - preferredPositionInResponseintNULL + preferredPositionInResponseOdr_intNULL otherInfoZ_OtherInformationNULL @@ -736,16 +737,16 @@ typedef struct Z_ext_typeent referenceIdZ_ReferenceIdNULL - stepSizeintNULL + stepSizeOdr_intNULL - scanStatusintZ_Scan_success + scanStatusOdr_intZ_Scan_success - numberOfEntriesReturnedint0 + numberOfEntriesReturnedOdr_int0 - positionOfTermintNULL + positionOfTermOdr_intNULL entriesZ_ListEntrisNULL @@ -779,14 +780,14 @@ typedef struct Z_ext_typeent referenceIdZ_ReferenceIdNULL - requestedActionint + requestedActionOdr_int Z_TriggerResourceCtrl_resou.. prefResourceReportFormatOdr_oidNULL - resultSetWantedbool_tNULL + resultSetWantedOdr_boolNULL otherInfoZ_OtherInformationNULL @@ -815,19 +816,19 @@ typedef struct Z_ext_typeent referenceIdZ_ReferenceIdNULL - suspendedFlagbool_tNULL + suspendedFlagOdr_boolNULL resourceReportZ_ExternalNULL - partialResultsAvailableintNULL + partialResultsAvailableOdr_intNULL - responseRequiredbool_tFALSE + responseRequiredOdr_boolFALSE - triggeredRequestFlagbool_tNULL + triggeredRequestFlagOdr_boolNULL otherInfoZ_OtherInformationNULL @@ -951,10 +952,10 @@ typedef struct Z_ext_typeent referenceIdZ_ReferenceIdNULL - numberOfRecordsReturnedintvalue=0 + numberOfRecordsReturnedOdr_intvalue=0 - num_segmentRecordsint0 + num_segmentRecordsOdr_int0 segmentRecordsZ_NamePlusRecordNULL @@ -984,7 +985,7 @@ typedef struct Z_ext_typeent referenceIdZ_ReferenceIdNULL - closeReasonintZ_Close_finished + closeReasonOdr_intZ_Close_finished diagnosticInformationchar*NULL diff --git a/doc/odr.xml b/doc/odr.xml index 627f5c9..0f6ac6f 100644 --- a/doc/odr.xml +++ b/doc/odr.xml @@ -262,7 +262,7 @@ Encoding and decoding functions - 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); @@ -311,7 +311,7 @@ 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) - 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); - (we don't allow values that can't be contained in a C integer.) + The Odr_int is just a simple integer. @@ -638,7 +639,7 @@ void do_nothing_useful(int value) BOOLEAN -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); @@ -652,7 +653,7 @@ int odr_bool(ODR o, bool_t **p, int optional, const char *name); NULL -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); @@ -794,7 +795,7 @@ int odr_explicit_tag(ODR o, Odr_fun fun, int class, int tag, -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 { 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; @@ -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; }; diff --git a/include/yaz/backend.h b/include/yaz/backend.h index 2cf6fa2..a7a4874 100644 --- a/include/yaz/backend.h +++ b/include/yaz/backend.h @@ -61,7 +61,7 @@ typedef struct { bend_request request; bend_association association; int *fd; - int 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 */ - int 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 */ - int *step_size; /* step size */ - int 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 */ - int *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; diff --git a/include/yaz/nmem.h b/include/yaz/nmem.h index 8e9add0..9364323 100644 --- a/include/yaz/nmem.h +++ b/include/yaz/nmem.h @@ -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,12 +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); + +/** \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 diff --git a/include/yaz/odr.h b/include/yaz/odr.h index d687d14..b6abe59 100644 --- a/include/yaz/odr.h +++ b/include/yaz/odr.h @@ -44,6 +44,10 @@ YAZ_BEGIN_CDECL +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 #endif @@ -184,7 +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 int *odr_intdup(ODR o, int 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); @@ -228,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, 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_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, int *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); @@ -298,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 */ - int *indirect_reference; /* OPTIONAL */ + Odr_int *indirect_reference; /* OPTIONAL */ char *descriptor; /* OPTIONAL */ int which; #define ODR_EXTERNAL_single 0 diff --git a/include/yaz/prt-ext.h b/include/yaz/prt-ext.h index 8a8c42c..e4b2f3f 100644 --- a/include/yaz/prt-ext.h +++ b/include/yaz/prt-ext.h @@ -58,7 +58,7 @@ typedef struct Z_ext_typeent struct Z_External { Odr_oid *direct_reference; - int *indirect_reference; + Odr_int *indirect_reference; char *descriptor; int which; /* Generic types */ diff --git a/include/yaz/srw.h b/include/yaz/srw.h index 572ce8b..1a07418 100644 --- a/include/yaz/srw.h +++ b/include/yaz/srw.h @@ -54,7 +54,7 @@ typedef struct { #define Z_SRW_recordPacking_URL 2 char *recordData_buf; int recordData_len; - int *recordPosition; + Odr_int *recordPosition; } Z_SRW_record; typedef struct { @@ -84,27 +84,27 @@ typedef struct { char *sortKeys; char *xSortKeys; } sort; - int *startRecord; - int *maximumRecords; + Odr_int *startRecord; + Odr_int *maximumRecords; char *recordSchema; char *recordPacking; char *recordXPath; char *database; char *stylesheet; - int *resultSetTTL; + Odr_int *resultSetTTL; } Z_SRW_searchRetrieveRequest; typedef struct { - int * numberOfRecords; + Odr_int *numberOfRecords; char * resultSetId; - int * resultSetIdleTime; + Odr_int *resultSetIdleTime; Z_SRW_record *records; int num_records; Z_SRW_diagnostic *diagnostics; int num_diagnostics; - int *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; - int *responsePosition; - int *maximumTerms; + Odr_int *responsePosition; + Odr_int *maximumTerms; char *stylesheet; char *database; } Z_SRW_scanRequest; typedef struct { char *value; - int *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, int **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, diff --git a/src/ber_int.c b/src/ber_int.c index 13e07cb..ef185aa 100644 --- a/src/ber_int.c +++ b/src/ber_int.c @@ -30,10 +30,10 @@ #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 val); +static int ber_decinteger(const unsigned char *buf, Odr_int *val, int max); -int ber_integer(ODR o, int *val) +int ber_integer(ODR o, Odr_int *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 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 *val, int max) { const unsigned char *b = buf; unsigned char fill; diff --git a/src/cqltransform.c b/src/cqltransform.c index ea6c20a..4036f60 100644 --- a/src/cqltransform.c +++ b/src/cqltransform.c @@ -107,7 +107,7 @@ static int cql_transform_parse_tok_line(cql_transform_t ct, t = yaz_tok_move(tp); } elem->attributeType = nmem_intdup(ct->nmem, 0); - if (sscanf(wrbuf_cstr(type_str), "%d", elem->attributeType) + if (sscanf(wrbuf_cstr(type_str), ODR_INT_PRINTF, elem->attributeType) != 1) { wrbuf_destroy(type_str); diff --git a/src/grs1disp.c b/src/grs1disp.c index f6a64ce..892fdf5 100644 --- a/src/grs1disp.c +++ b/src/grs1disp.c @@ -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) { diff --git a/src/ill-get.c b/src/ill-get.c index d0d107b..a0efcfa 100644 --- a/src/ill-get.c +++ b/src/ill-get.c @@ -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 *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 @@ 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 *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); } diff --git a/src/logrpn.c b/src/logrpn.c index e34b6b2..58468d5 100644 --- a/src/logrpn.c +++ b/src/logrpn.c @@ -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; ivalue.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: diff --git a/src/nmemsdup.c b/src/nmemsdup.c index d30dbaf..1f9d415 100644 --- a/src/nmemsdup.c +++ b/src/nmemsdup.c @@ -38,9 +38,16 @@ char *nmem_strdupn (NMEM mem, const char *src, size_t n) return dst; } -int *nmem_intdup(NMEM mem, int v) +nmem_int_t *nmem_intdup(NMEM mem, nmem_int_t v) { - int *dst = (int*) nmem_malloc (mem, sizeof(int)); + nmem_int_t *dst = (nmem_int_t*) nmem_malloc (mem, sizeof(*dst)); + *dst = v; + return dst; +} + +nmem_bool_t *nmem_booldup(NMEM mem, nmem_bool_t v) +{ + nmem_bool_t *dst = (nmem_bool_t*) nmem_malloc (mem, sizeof(*dst)); *dst = v; return dst; } diff --git a/src/odr_bool.c b/src/odr_bool.c index 114799f..0434183 100644 --- a/src/odr_bool.c +++ b/src/odr_bool.c @@ -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; diff --git a/src/odr_enum.c b/src/odr_enum.c index 40189b1..d658ca8 100644 --- a/src/odr_enum.c +++ b/src/odr_enum.c @@ -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 **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 *)odr_malloc(o, sizeof(**p)); return ber_integer(o, *p); } /* diff --git a/src/odr_int.c b/src/odr_int.c index a039f43..606f59b 100644 --- a/src/odr_int.c +++ b/src/odr_int.c @@ -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 **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 *)odr_malloc(o, sizeof(**p)); return ber_integer(o, *p); } /* diff --git a/src/odr_mem.c b/src/odr_mem.c index 55478c0..028d06d 100644 --- a/src/odr_mem.c +++ b/src/odr_mem.c @@ -47,11 +47,16 @@ 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 *odr_intdup(ODR o, Odr_int v) { return nmem_intdup(o->mem, v); } +Odr_bool *odr_booldup(ODR o, Odr_bool v) +{ + return nmem_booldup(o->mem, v); +} + int odr_total(ODR o) { return nmem_total(o->mem); diff --git a/src/pquery.c b/src/pquery.c index 16d826a..9a150a4 100644 --- a/src/pquery.c +++ b/src/pquery.c @@ -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 *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 *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 *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 *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 *)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 *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 *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 *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 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 attr_list[1024]; char *attr_clist[512]; Odr_oid *attr_set[512]; int num_attr = 0; diff --git a/src/querytowrbuf.c b/src/querytowrbuf.c index 088b307..ee975f4 100644 --- a/src/querytowrbuf.c +++ b/src/querytowrbuf.c @@ -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; ivalue.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)) diff --git a/src/rpn2cql.c b/src/rpn2cql.c index de06fab..692c55a 100644 --- a/src/rpn2cql.c +++ b/src/rpn2cql.c @@ -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; diff --git a/src/seshigh.c b/src/seshigh.c index 8c0c3fa..19c771d 100644 --- a/src/seshigh.c +++ b/src/seshigh.c @@ -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 start, + Odr_int *num, Z_RecordComposition *comp, + Odr_int *next, Odr_int *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 *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; @@ -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 *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 *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 *next; + Odr_int *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 *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; @@ -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*) odr_malloc(assoc->encode, sizeof(*bdrr->statuses) * bdrr->num_setnames); for (i = 0; i < bdrr->num_setnames; i++) diff --git a/src/session.h b/src/session.h index d96432c..f7c81ce 100644 --- a/src/session.h +++ b/src/session.h @@ -122,8 +122,8 @@ typedef struct association association_state state; /* session parameters */ - int preferredMessageSize; - int maximumRecordSize; + Odr_int preferredMessageSize; + Odr_int maximumRecordSize; int version; /* highest version-bit set (2 or 3) */ unsigned cs_get_mask; diff --git a/src/srw.c b/src/srw.c index c962922..869f4d5 100644 --- 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 *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 **val) { #if CHECK_TYPE struct _xmlAttr *attr; diff --git a/src/srwutil.c b/src/srwutil.c index 7b62217..6284831 100644 --- a/src/srwutil.c +++ b/src/srwutil.c @@ -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 **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 **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 *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)++; } } diff --git a/src/xmlquery.c b/src/xmlquery.c index f2c5338..cb433ad 100644 --- a/src/xmlquery.c +++ b/src/xmlquery.c @@ -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 *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"); diff --git a/src/zget.c b/src/zget.c index 0308373..d0c23d6 100644 --- a/src/zget.c +++ b/src/zget.c @@ -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; diff --git a/src/zoom-c.c b/src/zoom-c.c index a7dced4..fbade55 100644 --- a/src/zoom-c.c +++ b/src/zoom-c.c @@ -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 = diff --git a/test/tstodr.c b/test/tstodr.c index 8aa0154..f2b8b3a 100644 --- a/test/tstodr.c +++ b/test/tstodr.c @@ -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); @@ -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); diff --git a/util/yaz-asncomp b/util/yaz-asncomp index e0a86b1..fb454a6 100755 --- a/util/yaz-asncomp +++ b/util/yaz-asncomp @@ -1217,11 +1217,11 @@ proc asnBasicEXTERNAL {} { } proc asnBasicINTEGER {} { - return {odr_integer {int}} + return {odr_integer {Odr_int}} } proc asnBasicENUMERATED {} { - return {odr_enum {int}} + 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 {} { diff --git a/util/yaz-illclient.c b/util/yaz-illclient.c index cdaf416..ef71659 100644 --- a/util/yaz-illclient.c +++ b/util/yaz-illclient.c @@ -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: diff --git a/ztest/dummy-opac.c b/ztest/dummy-opac.c index f44d042..47d9f56 100644 --- a/ztest/dummy-opac.c +++ b/ztest/dummy-opac.c @@ -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; diff --git a/ztest/ztest.c b/ztest/ztest.c index 974d2da..f426eb9 100644 --- a/ztest/ztest.c +++ b/ztest/ztest.c @@ -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;