X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=zutil%2Fzget.c;h=8e09ca7c3fff4f16530f8070ade1e773c665e5e4;hp=04f4f18b153d985bc460a9613559b444a556c447;hb=c5f9b67c889e65446bcbf727bef3705229c3fd7f;hpb=a6eef2e7073a7295d1a7bf09f538946135a5ebbb diff --git a/zutil/zget.c b/zutil/zget.c index 04f4f18..8e09ca7 100644 --- a/zutil/zget.c +++ b/zutil/zget.c @@ -1,10 +1,31 @@ /* - * Copyright (c) 1995-1999, Index Data. + * Copyright (c) 1995-2001, Index Data. * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * * $Log: zget.c,v $ - * Revision 1.3 2000-03-20 19:06:25 adam + * Revision 1.10 2001-09-24 21:48:46 adam + * Setting v1,v2,search and present options for init request. + * + * Revision 1.9 2001/05/18 11:42:03 adam + * YAZ Build date for WIN32. + * + * Revision 1.8 2001/05/17 14:16:15 adam + * Added EXTERNAL handling for item update0 (1.0). + * + * Revision 1.7 2001/05/16 07:22:56 adam + * YAZ CVS Date part of implementationVersion in init{request,Response}. + * + * Revision 1.6 2001/03/25 21:55:13 adam + * Added odr_intdup. Ztest server returns TaskPackage for ItemUpdate. + * + * Revision 1.5 2001/03/13 18:11:38 adam + * Altered zget_ExtendedServicesRequest - sets waitAction to waitIfPossible. + * + * Revision 1.4 2001/02/21 13:46:54 adam + * C++ fixes. + * + * Revision 1.3 2000/03/20 19:06:25 adam * Added Segment request for fronend server. Work on admin for client. * * Revision 1.2 1999/11/30 13:47:12 adam @@ -79,16 +100,30 @@ Z_InitRequest *zget_InitRequest(ODR o) r->referenceId = 0; r->options = (Odr_bitmask *)odr_malloc(o, sizeof(*r->options)); ODR_MASK_ZERO(r->options); - r->protocolVersion = (Odr_bitmask *)odr_malloc(o, sizeof(*r->protocolVersion)); + r->protocolVersion = (Odr_bitmask *) + odr_malloc(o, sizeof(*r->protocolVersion)); + + ODR_MASK_SET(r->options, Z_Options_search); + ODR_MASK_SET(r->options, Z_Options_present); + ODR_MASK_ZERO(r->protocolVersion); - r->preferredMessageSize = (int *)odr_malloc(o, sizeof(int)); - *r->preferredMessageSize = 30*1024; - r->maximumRecordSize = (int *)odr_malloc(o, sizeof(int)); - *r->maximumRecordSize = 30*1024; + + ODR_MASK_SET(r->protocolVersion, Z_ProtocolVersion_1); + ODR_MASK_SET(r->protocolVersion, Z_ProtocolVersion_2); + + r->preferredMessageSize = odr_intdup(o, 30*1024); + r->maximumRecordSize = odr_intdup(o, 30*1024); r->idAuthentication = 0; - r->implementationId = "YAZ (id=81)"; + r->implementationId = "81"; r->implementationName = "Index Data/YAZ"; - r->implementationVersion = YAZ_VERSION; + r->implementationVersion = YAZ_VERSION +#ifdef YAZ_DATE_STR + " (" YAZ_DATE_STR ")" +#endif +#ifdef YAZ_OS + " " YAZ_OS +#endif + ; r->userInformationField = 0; r->otherInfo = 0; return r; @@ -103,15 +138,19 @@ Z_InitResponse *zget_InitResponse(ODR o) ODR_MASK_ZERO(r->options); r->protocolVersion = (Odr_bitmask *)odr_malloc(o, sizeof(*r->protocolVersion)); ODR_MASK_ZERO(r->protocolVersion); - r->preferredMessageSize = (int *)odr_malloc(o, sizeof(int)); - *r->preferredMessageSize = 30*1024; - r->maximumRecordSize = (int *)odr_malloc(o, sizeof(int)); - *r->maximumRecordSize = 30*1024; - r->result = (int *)odr_malloc(o, sizeof(bool_t)); - *r->result = 1; - r->implementationId = "YAZ (id=81)"; + r->preferredMessageSize = odr_intdup(o, 30*1024); + r->maximumRecordSize = odr_intdup(o, 30*1024); + r->result = odr_intdup(o, 1); + r->implementationId = "81"; r->implementationName = "Index Data/YAZ"; - r->implementationVersion = YAZ_VERSION; + r->implementationVersion = YAZ_VERSION +#ifdef YAZ_DATE_STR + " (" YAZ_DATE_STR ")" +#endif +#ifdef YAZ_OS + " " YAZ_OS +#endif + ; r->userInformationField = 0; r->otherInfo = 0; return r; @@ -122,14 +161,10 @@ Z_SearchRequest *zget_SearchRequest(ODR o) Z_SearchRequest *r = (Z_SearchRequest *)odr_malloc(o, sizeof(*r)); r->referenceId = 0; - r->smallSetUpperBound = (int *)odr_malloc(o, sizeof(int)); - *r->smallSetUpperBound = 0; - r->largeSetLowerBound = (int *)odr_malloc(o, sizeof(int)); - *r->largeSetLowerBound = 1; - r->mediumSetPresentNumber = (int *)odr_malloc(o, sizeof(int)); - *r->mediumSetPresentNumber = 0; - r->replaceIndicator = (int *)odr_malloc(o, sizeof(bool_t)); - *r->replaceIndicator = 1; + 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->resultSetName = "default"; r->num_databaseNames = 0; r->databaseNames = 0; @@ -147,14 +182,10 @@ Z_SearchResponse *zget_SearchResponse(ODR o) Z_SearchResponse *r = (Z_SearchResponse *)odr_malloc(o, sizeof(*r)); r->referenceId = 0; - r->resultCount = (int *)odr_malloc(o, sizeof(int)); - *r->resultCount = 0; - r->numberOfRecordsReturned = (int *)odr_malloc(o, sizeof(int)); - *r->numberOfRecordsReturned = 0; - r->nextResultSetPosition = (int *)odr_malloc(o, sizeof(int)); - *r->nextResultSetPosition = 0; - r->searchStatus = (int *)odr_malloc(o, sizeof(bool_t)); - *r->searchStatus = 1; + 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->resultSetStatus = 0; r->presentStatus = 0; r->records = 0; @@ -169,10 +200,8 @@ Z_PresentRequest *zget_PresentRequest(ODR o) r->referenceId = 0; r->resultSetId = "default"; - r->resultSetStartPoint = (int *)odr_malloc(o, sizeof(int)); - *r->resultSetStartPoint = 1; - r->numberOfRecordsRequested = (int *)odr_malloc(o, sizeof(int)); - *r->numberOfRecordsRequested = 10; + r->resultSetStartPoint = odr_intdup(o, 1); + r->numberOfRecordsRequested = odr_intdup(o, 10); r->num_ranges = 0; r->additionalRanges = 0; r->recordComposition = 0; @@ -189,12 +218,9 @@ Z_PresentResponse *zget_PresentResponse(ODR o) Z_PresentResponse *r = (Z_PresentResponse *)odr_malloc(o, sizeof(*r)); r->referenceId = 0; - r->numberOfRecordsReturned = (int *)odr_malloc(o, sizeof(int)); - *r->numberOfRecordsReturned = 0; - r->nextResultSetPosition = (int *)odr_malloc(o, sizeof(int)); - *r->nextResultSetPosition = 0; - r->presentStatus = (int *)odr_malloc(o, sizeof(int)); - *r->presentStatus = Z_PRES_SUCCESS; + r->numberOfRecordsReturned = odr_intdup(o, 0); + r->nextResultSetPosition = odr_intdup(o, 0); + r->presentStatus = odr_intdup(o, Z_PRES_SUCCESS); r->records = 0; r->otherInfo = 0; return r; @@ -206,8 +232,7 @@ Z_DeleteResultSetRequest *zget_DeleteResultSetRequest(ODR o) odr_malloc(o, sizeof(*r)); r->referenceId = 0; - r->deleteFunction = (int *)odr_malloc(o, sizeof(int)); - *r->deleteFunction = Z_DeleteRequest_list; + r->deleteFunction = odr_intdup(o, Z_DeleteRequest_list); r->num_resultSetList = 0; r->resultSetList = 0; r->otherInfo = 0; @@ -220,8 +245,7 @@ Z_DeleteResultSetResponse *zget_DeleteResultSetResponse(ODR o) odr_malloc(o, sizeof(*r)); r->referenceId = 0; - r->deleteOperationStatus = (int *)odr_malloc(o, sizeof(int)); - *r->deleteOperationStatus = Z_DeleteStatus_success; + r->deleteOperationStatus = odr_intdup(o, Z_DeleteStatus_success); r->deleteListStatuses = 0; r->numberNotDeleted = 0; r->bulkStatuses = 0; @@ -240,8 +264,7 @@ Z_ScanRequest *zget_ScanRequest(ODR o) r->attributeSet = 0; r->termListAndStartPoint = 0; r->stepSize = 0; - r->numberOfTermsRequested = (int *)odr_malloc(o, sizeof(int)); - *r->numberOfTermsRequested = 20; + r->numberOfTermsRequested = odr_intdup(o, 20); r->preferredPositionInResponse = 0; r->otherInfo = 0; return r; @@ -253,10 +276,8 @@ Z_ScanResponse *zget_ScanResponse(ODR o) r->referenceId = 0; r->stepSize = 0; - r->scanStatus = (int *)odr_malloc(o, sizeof(int)); - *r->scanStatus = Z_Scan_success; - r->numberOfEntriesReturned = (int *)odr_malloc(o, sizeof(int)); - *r->numberOfEntriesReturned = 0; + r->scanStatus = odr_intdup(o, Z_Scan_success); + r->numberOfEntriesReturned = odr_intdup(o, 0); r->positionOfTerm =0; r->entries = 0; r->attributeSet = 0; @@ -270,8 +291,7 @@ Z_TriggerResourceControlRequest *zget_TriggerResourceControlRequest(ODR o) odr_malloc(o, sizeof(*r)); r->referenceId = 0; - r->requestedAction = (int *)odr_malloc(o, sizeof(int)); - *r->requestedAction = Z_TriggerResourceCtrl_resourceReport; + r->requestedAction = odr_intdup(o, Z_TriggerResourceCtrl_resourceReport); r->prefResourceReportFormat = 0; r->resultSetWanted = 0; r->otherInfo = 0; @@ -287,8 +307,7 @@ Z_ResourceControlRequest *zget_ResourceControlRequest(ODR o) r->suspendedFlag = 0; r->resourceReport = 0; r->partialResultsAvailable = 0; - r->responseRequired = (int *)odr_malloc(o, sizeof(bool_t)); - *r->responseRequired = 0; + r->responseRequired = odr_intdup(o, 0); r->triggeredRequestFlag = 0; r->otherInfo = 0; return r; @@ -300,8 +319,7 @@ Z_ResourceControlResponse *zget_ResourceControlResponse(ODR o) odr_malloc(o, sizeof(*r)); r->referenceId = 0; - r->continueFlag = (int *)odr_malloc(o, sizeof(bool_t)); - *r->continueFlag = 1; + r->continueFlag = odr_intdup(o, 1); r->resultSetWanted = 0; r->otherInfo = 0; return r; @@ -337,10 +355,9 @@ Z_Segment *zget_Segment(ODR o) Z_Segment *r = (Z_Segment *)odr_malloc(o, sizeof(*r)); r->referenceId = 0; - r->numberOfRecordsReturned = (int *)odr_malloc(o, sizeof(int)); - *r->numberOfRecordsReturned = 0; + r->numberOfRecordsReturned = odr_intdup(o, 0); r->num_segmentRecords = 0; - r->segmentRecords = odr_nullval(); + r->segmentRecords = (Z_NamePlusRecord **) odr_nullval(); r->otherInfo = 0; return r; } @@ -350,8 +367,7 @@ Z_Close *zget_Close(ODR o) Z_Close *r = (Z_Close *)odr_malloc(o, sizeof(*r)); r->referenceId = 0; - r->closeReason = (int *)odr_malloc(o, sizeof(int)); - *r->closeReason = Z_Close_finished; + r->closeReason = odr_intdup(o, Z_Close_finished); r->diagnosticInformation = 0; r->resourceReportFormat = 0; r->resourceReport = 0; @@ -377,8 +393,7 @@ Z_ResourceReportResponse *zget_ResourceReportResponse(ODR o) odr_malloc(o, sizeof(*r)); r->referenceId = 0; - r->resourceReportStatus = (int *)odr_malloc(o, sizeof(int)); - *r->resourceReportStatus = Z_ResourceReportStatus_success; + r->resourceReportStatus = odr_intdup(o, Z_ResourceReportStatus_success); r->resourceReport = 0; r->otherInfo = 0; return r; @@ -401,10 +416,8 @@ Z_SortResponse *zget_SortResponse(ODR o) Z_SortResponse *r = (Z_SortResponse *)odr_malloc(o, sizeof(*r)); r->referenceId = 0; - r->sortStatus = (int *)odr_malloc(o, sizeof(int)); - *r->sortStatus = Z_SortStatus_success; - r->resultSetStatus = (int *)odr_malloc(o, sizeof(int)); - *r->resultSetStatus = Z_SortResultSetStatus_empty; + r->sortStatus = odr_intdup(o, Z_SortStatus_success); + r->resultSetStatus = odr_intdup(o, Z_SortResultSetStatus_empty); r->diagnostics = 0; r->otherInfo = 0; return r; @@ -416,8 +429,7 @@ Z_ExtendedServicesRequest *zget_ExtendedServicesRequest(ODR o) odr_malloc(o, sizeof(*r)); r->referenceId = 0; - r->function = (int *)odr_malloc(o, sizeof(int)); - *r->function = Z_ExtendedServicesRequest_create; + r->function = odr_intdup(o, Z_ExtendedServicesRequest_create); r->packageType = 0; r->packageName = 0; r->userId = 0; @@ -425,8 +437,7 @@ Z_ExtendedServicesRequest *zget_ExtendedServicesRequest(ODR o) r->permissions = 0; r->description = 0; r->taskSpecificParameters = 0; - r->waitAction = (int *)odr_malloc(o, sizeof(int)); - *r->waitAction = Z_ExtendedServicesRequest_wait; + r->waitAction = odr_intdup(o, Z_ExtendedServicesRequest_waitIfPossible); r->elements = 0; r->otherInfo = 0; return r; @@ -438,8 +449,7 @@ Z_ExtendedServicesResponse *zget_ExtendedServicesResponse(ODR o) odr_malloc(o, sizeof(*r)); r->referenceId = 0; - r->operationStatus = (int *)odr_malloc(o, sizeof(int)); - *r->operationStatus = Z_ExtendedServicesResponse_done; + r->operationStatus = odr_intdup(o, Z_ExtendedServicesResponse_done); r->num_diagnostics = 0; r->diagnostics = 0; r->taskPackage = 0;