From 8d08fd5b79e49e14ca014de8e6bed12a2cc0468d Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Sun, 25 Mar 2001 21:55:12 +0000 Subject: [PATCH] Added odr_intdup. Ztest server returns TaskPackage for ItemUpdate. --- client/client.c | 6 ++- ill/ill-get.c | 9 ++-- include/yaz/backend.h | 6 ++- include/yaz/nmem.h | 8 +++- include/yaz/odr.h | 5 ++- odr/odr_mem.c | 12 +++++- server/seshigh.c | 87 ++++++++++++++++----------------------- server/statserv.c | 16 +++++++- util/nmemsdup.c | 15 +++++-- ztest/read-grs.c | 14 +++---- ztest/ztest.c | 59 +++++++++++++++++++++++++- zutil/prt-ext.c | 11 +++-- zutil/zget.c | 109 ++++++++++++++++++------------------------------- 13 files changed, 208 insertions(+), 149 deletions(-) diff --git a/client/client.c b/client/client.c index 89e8039..25a299c 100644 --- a/client/client.c +++ b/client/client.c @@ -3,7 +3,10 @@ * See the file LICENSE for details. * * $Log: client.c,v $ - * Revision 1.116 2001-03-21 12:43:36 adam + * Revision 1.117 2001-03-25 21:55:12 adam + * Added odr_intdup. Ztest server returns TaskPackage for ItemUpdate. + * + * Revision 1.116 2001/03/21 12:43:36 adam * Implemented cs_create_host. Better error reporting for SSL comstack. * * Revision 1.115 2001/03/13 18:10:58 adam @@ -631,7 +634,6 @@ int cmd_open(char *arg) { void *add; char type_and_host[101], base[101]; - char *host = 0; CS_TYPE t; if (conn) diff --git a/ill/ill-get.c b/ill/ill-get.c index 8fe5257..f953752 100644 --- a/ill/ill-get.c +++ b/ill/ill-get.c @@ -3,7 +3,10 @@ * See the file LICENSE for details. * * $Log: ill-get.c,v $ - * Revision 1.8 2001-02-21 13:46:53 adam + * Revision 1.9 2001-03-25 21:55:12 adam + * Added odr_intdup. Ztest server returns TaskPackage for ItemUpdate. + * + * Revision 1.8 2001/02/21 13:46:53 adam * C++ fixes. * * Revision 1.7 2001/02/20 11:25:32 adam @@ -63,7 +66,6 @@ int *ill_get_int (struct ill_get_ctl *gc, const char *name, ODR o = gc->odr; char element[128]; const char *v; - int *r = (int *) odr_malloc (o, sizeof(*r)); strcpy(element, name); if (sub) @@ -74,8 +76,7 @@ int *ill_get_int (struct ill_get_ctl *gc, const char *name, v = (gc->f)(gc->clientData, element); if (v) val = atoi(v); - *r = val; - return r; + return odr_intdup(o, val); } int *ill_get_enumerated (struct ill_get_ctl *gc, const char *name, diff --git a/include/yaz/backend.h b/include/yaz/backend.h index 72abdc5..a02e1fa 100644 --- a/include/yaz/backend.h +++ b/include/yaz/backend.h @@ -24,7 +24,10 @@ * OF THIS SOFTWARE. * * $Log: backend.h,v $ - * Revision 1.11 2001-01-30 21:34:17 adam + * Revision 1.12 2001-03-25 21:55:12 adam + * Added odr_intdup. Ztest server returns TaskPackage for ItemUpdate. + * + * Revision 1.11 2001/01/30 21:34:17 adam * Added step-size for Scan backend interface. * * Revision 1.10 2000/10/02 11:07:44 adam @@ -244,6 +247,7 @@ typedef struct bend_esrequest_rr bend_association association; int errcode; /* 0==success, -1==accepted, >0 = failure */ char *errstring; /* system error string or NULL */ + Z_TaskPackage *taskPackage; } bend_esrequest_rr; typedef struct bend_segment_rr { diff --git a/include/yaz/nmem.h b/include/yaz/nmem.h index 24faba2..44d1cf8 100644 --- a/include/yaz/nmem.h +++ b/include/yaz/nmem.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995-2000, Index Data. + * Copyright (c) 1995-2001, Index Data. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation, in whole or in part, for any purpose, is hereby granted, @@ -24,7 +24,10 @@ * OF THIS SOFTWARE. * * $Log: nmem.h,v $ - * Revision 1.4 2000-05-09 11:48:58 adam + * Revision 1.5 2001-03-25 21:55:12 adam + * Added odr_intdup. Ztest server returns TaskPackage for ItemUpdate. + * + * Revision 1.4 2000/05/09 11:48:58 adam * Fix (bug introduced by previous commit). * * Revision 1.3 2000/05/09 10:55:05 adam @@ -85,6 +88,7 @@ typedef struct nmem_control *NMEM; YAZ_EXPORT void nmem_reset(NMEM n); YAZ_EXPORT int nmem_total(NMEM n); YAZ_EXPORT char *nmem_strdup (NMEM mem, const char *src); +YAZ_EXPORT int *nmem_intdup (NMEM mem, int v); YAZ_EXPORT void nmem_transfer (NMEM dst, NMEM src); YAZ_EXPORT void nmem_critical_enter (void); diff --git a/include/yaz/odr.h b/include/yaz/odr.h index cb9e571..ccff72e 100644 --- a/include/yaz/odr.h +++ b/include/yaz/odr.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995-2000, Index Data. + * Copyright (c) 1995-2001, Index Data. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation, in whole or in part, for any purpose, is hereby granted, @@ -23,7 +23,7 @@ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. * - * $Id: odr.h,v 1.3 2000-02-28 11:20:06 adam Exp $ + * $Id: odr.h,v 1.4 2001-03-25 21:55:12 adam Exp $ */ #ifndef ODR_H @@ -203,6 +203,7 @@ YAZ_EXPORT void odr_setbuf(ODR o, char *buf, int len, int can_grow); YAZ_EXPORT char *odr_getbuf(ODR o, int *len, int *size); YAZ_EXPORT void *odr_malloc(ODR o, int size); YAZ_EXPORT char *odr_strdup(ODR o, const char *str); +YAZ_EXPORT int *odr_intdup(ODR o, int v); YAZ_EXPORT NMEM odr_extract_mem(ODR o); YAZ_EXPORT Odr_null *odr_nullval(void); #define odr_release_mem(m) nmem_destroy(m) diff --git a/odr/odr_mem.c b/odr/odr_mem.c index d5d3193..f938a68 100644 --- a/odr/odr_mem.c +++ b/odr/odr_mem.c @@ -1,9 +1,12 @@ /* - * Copyright (c) 1995-2000, Index Data + * Copyright (c) 1995-2001, Index Data * See the file LICENSE for details. * * $Log: odr_mem.c,v $ - * Revision 1.18 2000-02-29 13:44:55 adam + * Revision 1.19 2001-03-25 21:55:12 adam + * Added odr_intdup. Ztest server returns TaskPackage for ItemUpdate. + * + * Revision 1.18 2000/02/29 13:44:55 adam * Check for config.h (currently not generated). * * Revision 1.17 2000/01/31 13:15:21 adam @@ -95,6 +98,11 @@ char *odr_strdup(ODR o, const char *str) return nmem_strdup(o->mem, str); } +int *odr_intdup(ODR o, int v) +{ + return nmem_intdup(o->mem, v); +} + int odr_total(ODR o) { return o->mem ? nmem_total(o->mem) : 0; diff --git a/server/seshigh.c b/server/seshigh.c index 3a4b6b0..568b2bc 100644 --- a/server/seshigh.c +++ b/server/seshigh.c @@ -3,7 +3,10 @@ * See the file LICENSE for details. * * $Log: seshigh.c,v $ - * Revision 1.114 2001-02-21 13:46:53 adam + * Revision 1.115 2001-03-25 21:55:12 adam + * Added odr_intdup. Ztest server returns TaskPackage for ItemUpdate. + * + * Revision 1.114 2001/02/21 13:46:53 adam * C++ fixes. * * Revision 1.113 2001/01/30 21:34:17 adam @@ -662,8 +665,8 @@ void ir_session(IOCHAN h, int event) if (!z_APDU(assoc->decode, &req->request, 0, 0)) { yaz_log(LOG_LOG, "ODR error on incoming PDU: %s [near byte %d] ", - odr_errmsg(odr_geterror(assoc->decode)), - odr_offset(assoc->decode)); + odr_errmsg(odr_geterror(assoc->decode)), + odr_offset(assoc->decode)); yaz_log(LOG_LOG, "PDU dump:"); odr_dumpBER(yaz_log_file(), assoc->input_buffer, res); do_close(assoc, Z_Close_protocolError, "Malformed package"); @@ -883,22 +886,22 @@ void backend_response(IOCHAN i, int event) static int process_response(association *assoc, request *req, Z_APDU *res) { odr_setbuf(assoc->encode, req->response, req->size_response, 1); + + if (assoc->print && !z_APDU(assoc->print, &res, 0, 0)) + { + yaz_log(LOG_WARN, "ODR print error: %s", + odr_errmsg(odr_geterror(assoc->print))); + odr_reset(assoc->print); + } if (!z_APDU(assoc->encode, &res, 0, 0)) { yaz_log(LOG_WARN, "ODR error when encoding response: %s", odr_errmsg(odr_geterror(assoc->decode))); - odr_reset(assoc->encode); return -1; } req->response = odr_getbuf(assoc->encode, &req->len_response, &req->size_response); odr_setbuf(assoc->encode, 0, 0, 0); /* don'txfree if we abort later */ - if (assoc->print && !z_APDU(assoc->print, &res, 0, 0)) - { - yaz_log(LOG_WARN, "ODR print error: %s", - odr_errmsg(odr_geterror(assoc->print))); - odr_reset(assoc->print); - } odr_reset(assoc->encode); req->state = REQUEST_IDLE; request_enq(&assoc->outgoing, req); @@ -1117,8 +1120,7 @@ static Z_Records *diagrec(association *assoc, int error, char *addinfo) Z_Records *rec = (Z_Records *) odr_malloc (assoc->encode, sizeof(*rec)); oident bib1; - int *err = (int *) - odr_malloc (assoc->encode, sizeof(*err)); + int *err = odr_intdup(assoc->encode, error); Z_DiagRec *drec = (Z_DiagRec *) odr_malloc (assoc->encode, sizeof(*drec)); Z_DefaultDiagFormat *dr = (Z_DefaultDiagFormat *) @@ -1130,7 +1132,6 @@ static Z_Records *diagrec(association *assoc, int error, char *addinfo) yaz_log(LOG_DEBUG, "Diagnostic: %d -- %s", error, addinfo ? addinfo : "NULL"); - *err = error; rec->which = Z_Records_NSD; #if ASN_COMPILED rec->u.nonSurrogateDiagnostic = dr; @@ -1155,7 +1156,7 @@ static Z_NamePlusRecord *surrogatediagrec(association *assoc, char *dbname, int oid[OID_SIZE]; Z_NamePlusRecord *rec = (Z_NamePlusRecord *) odr_malloc (assoc->encode, sizeof(*rec)); - int *err = (int *)odr_malloc (assoc->encode, sizeof(*err)); + int *err = odr_intdup(assoc->encode, error); oident bib1; Z_DiagRec *drec = (Z_DiagRec *)odr_malloc (assoc->encode, sizeof(*drec)); Z_DefaultDiagFormat *dr = (Z_DefaultDiagFormat *) @@ -1166,7 +1167,6 @@ static Z_NamePlusRecord *surrogatediagrec(association *assoc, char *dbname, bib1.value = VAL_BIB1; yaz_log(LOG_DEBUG, "SurrogateDiagnotic: %d -- %s", error, addinfo); - *err = error; rec->databaseName = dbname; rec->which = Z_NamePlusRecord_surrogateDiagnostic; rec->u.surrogateDiagnostic = drec; @@ -1187,7 +1187,7 @@ static Z_DiagRecs *diagrecs(association *assoc, int error, char *addinfo) { int oid[OID_SIZE]; Z_DiagRecs *recs = (Z_DiagRecs *)odr_malloc (assoc->encode, sizeof(*recs)); - int *err = (int *)odr_malloc (assoc->encode, sizeof(*err)); + int *err = odr_intdup(assoc->encode, error); oident bib1; Z_DiagRec **recp = (Z_DiagRec **)odr_malloc (assoc->encode, sizeof(*recp)); Z_DiagRec *drec = (Z_DiagRec *)odr_malloc (assoc->encode, sizeof(*drec)); @@ -1198,7 +1198,6 @@ static Z_DiagRecs *diagrecs(association *assoc, int error, char *addinfo) bib1.oclass = CLASS_DIAGSET; bib1.value = VAL_BIB1; - *err = error; recs->num_diagRecs = 1; recs->diagRecs = recp; recp[0] = drec; @@ -1442,15 +1441,10 @@ 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 = (int *)odr_malloc (assoc->encode, sizeof(*nulint)); - bool_t *sr = (bool_t *)odr_malloc (assoc->encode, sizeof(*sr)); - int *next = (int *)odr_malloc (assoc->encode, sizeof(*next)); - int *none = (int *)odr_malloc (assoc->encode, sizeof(*none)); - - *nulint = 0; - *sr = 1; - *next = 0; - *none = Z_RES_NONE; + int *nulint = odr_intdup (assoc->encode, 0); + bool_t *sr = odr_intdup(assoc->encode, 1); + int *next = odr_intdup(assoc->encode, 0); + int *none = odr_intdup(assoc->encode, Z_RES_NONE); apdu->which = Z_APDU_searchResponse; apdu->u.searchResponse = resp; @@ -1475,12 +1469,10 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb, } else { - int *toget = (int *)odr_malloc (assoc->encode, sizeof(*toget)); - int *presst = (int *)odr_malloc (assoc->encode, sizeof(*presst)); + int *toget = odr_intdup(assoc->encode, 0); + int *presst = odr_intdup(assoc->encode, 0); Z_RecordComposition comp, *compp = 0; - *toget = 0; - *presst = 0; resp->records = 0; resp->resultCount = &bsrt->hits; @@ -1595,12 +1587,9 @@ static Z_APDU *process_presentRequest(association *assoc, request *reqb, } apdu = (Z_APDU *)odr_malloc (assoc->encode, sizeof(*apdu)); resp = (Z_PresentResponse *)odr_malloc (assoc->encode, sizeof(*resp)); - presst = (int *)odr_malloc (assoc->encode, sizeof(*presst)); - next = (int *)odr_malloc (assoc->encode, sizeof(*next)); - num = (int *)odr_malloc (assoc->encode, sizeof(*num)); - *presst = 0; - *next = 0; - *num = *req->numberOfRecordsRequested; + presst = odr_intdup(assoc->encode, 0); + next = odr_intdup(assoc->encode, 0); + num = odr_intdup(assoc->encode, *req->numberOfRecordsRequested); apdu->which = Z_APDU_presentResponse; apdu->u.presentResponse = resp; @@ -1630,10 +1619,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 = (int *) - odr_malloc (assoc->encode, sizeof(*scanStatus)); - int *numberOfEntriesReturned = (int *) - odr_malloc (assoc->encode, sizeof(*numberOfEntriesReturned)); + int *scanStatus = odr_intdup(assoc->encode, Z_Scan_failure); + int *numberOfEntriesReturned = odr_intdup(assoc->encode, 0); Z_ListEntries *ents = (Z_ListEntries *) odr_malloc (assoc->encode, sizeof(*ents)); Z_DiagRecs *diagrecs_p = NULL; @@ -1641,14 +1628,12 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb, int *fd) oident *attset; yaz_log(LOG_LOG, "Got ScanRequest"); - *scanStatus = Z_Scan_failure; - *numberOfEntriesReturned = 0; apdu->which = Z_APDU_scanResponse; apdu->u.scanResponse = res; res->referenceId = req->referenceId; - res->stepSize = (int*) odr_malloc (assoc->encode, sizeof(*res->stepSize)); - *res->stepSize = 0; + res->stepSize = odr_intdup(assoc->encode, 0); + if (req->stepSize) *res->stepSize = *req->stepSize; res->scanStatus = scanStatus; @@ -1796,9 +1781,7 @@ static Z_APDU *process_sortRequest(association *assoc, request *reqb, (*assoc->init->bend_sort)(assoc->backend, bsrr); res->referenceId = bsrr->referenceId; - res->sortStatus = (int *) - odr_malloc (assoc->encode, sizeof(*res->sortStatus)); - *res->sortStatus = bsrr->sort_status; + res->sortStatus = odr_intdup(assoc->encode, bsrr->sort_status); res->resultSetStatus = 0; if (bsrr->errcode) { @@ -1856,9 +1839,7 @@ static Z_APDU *process_deleteRequest(association *assoc, request *reqb, res->referenceId = req->referenceId; - res->deleteOperationStatus = (int *) - odr_malloc (assoc->encode, sizeof(*res->deleteOperationStatus)); - *res->deleteOperationStatus = bdrr->delete_status; + res->deleteOperationStatus = odr_intdup(assoc->encode,bdrr->delete_status); res->deleteListStatuses = 0; if (bdrr->num_setnames > 0) @@ -2020,6 +2001,7 @@ static Z_APDU *process_ESRequest(association *assoc, request *reqb, int *fd) esrequest.errstring = NULL; esrequest.request = reqb; esrequest.association = assoc; + esrequest.taskPackage = 0; esrequest.referenceId = req->referenceId; (*assoc->init->bend_esrequest)(assoc->backend, &esrequest); @@ -2054,7 +2036,10 @@ static Z_APDU *process_ESRequest(association *assoc, request *reqb, int *fd) resp->diagnostics = diagRecs->diagRecs; } /* Do something with the members of bend_extendedservice */ - + if (esrequest.taskPackage) + resp->taskPackage = z_ext_record (assoc->encode, VAL_EXTENDED, + (const char *) esrequest.taskPackage, + -1); yaz_log(LOG_DEBUG,"Send the result apdu"); return apdu; } diff --git a/server/statserv.c b/server/statserv.c index 18382ed..e4297bc 100644 --- a/server/statserv.c +++ b/server/statserv.c @@ -7,7 +7,10 @@ * Chas Woodfield, Fretwell Downing Informatics. * * $Log: statserv.c,v $ - * Revision 1.71 2001-03-21 12:43:36 adam + * Revision 1.72 2001-03-25 21:55:13 adam + * Added odr_intdup. Ztest server returns TaskPackage for ItemUpdate. + * + * Revision 1.71 2001/03/21 12:43:36 adam * Implemented cs_create_host. Better error reporting for SSL comstack. * * Revision 1.70 2001/02/01 08:52:26 adam @@ -816,6 +819,17 @@ static void add_listener(char *where, int what) COMSTACK l; void *ap; IOCHAN lst = NULL; + const char *mode; + + if (control_block.dynamic) + mode = "dynamic"; + else if (control_block.threads) + mode = "threaded"; + else + mode = "static"; + + yaz_log(LOG_LOG, "Adding %s %s listener on %s", mode, + what == PROTO_SR ? "SR" : "Z3950", where); l = cs_create_host(where, 0, &ap); if (!l) diff --git a/util/nmemsdup.c b/util/nmemsdup.c index 77ae6d7..0c32d71 100644 --- a/util/nmemsdup.c +++ b/util/nmemsdup.c @@ -1,10 +1,12 @@ /* - * Copyright (c) 1997-2000, Index Data. + * Copyright (c) 1997-2001, Index Data. * See the file LICENSE for details. - * Sebastian Hammer, Adam Dickmeiss * * $Log: nmemsdup.c,v $ - * Revision 1.4 2000-02-29 13:44:55 adam + * Revision 1.5 2001-03-25 21:55:13 adam + * Added odr_intdup. Ztest server returns TaskPackage for ItemUpdate. + * + * Revision 1.4 2000/02/29 13:44:55 adam * Check for config.h (currently not generated). * * Revision 1.3 1999/11/30 13:47:12 adam @@ -30,3 +32,10 @@ char *nmem_strdup (NMEM mem, const char *src) strcpy (dst, src); return dst; } + +int *nmem_intdup(NMEM mem, int v) +{ + int *dst = (int*) nmem_malloc (mem, sizeof(int)); + *dst = v; + return dst; +} diff --git a/ztest/read-grs.c b/ztest/read-grs.c index 2751046..97123e3 100644 --- a/ztest/read-grs.c +++ b/ztest/read-grs.c @@ -1,10 +1,12 @@ /* - * Copyright (c) 1995-1999, Index Data. + * Copyright (c) 1995-2001, Index Data. * See the file LICENSE for details. - * Sebastian Hammer, Adam Dickmeiss * * $Log: read-grs.c,v $ - * Revision 1.5 1999-11-30 13:47:12 adam + * Revision 1.6 2001-03-25 21:55:13 adam + * Added odr_intdup. Ztest server returns TaskPackage for ItemUpdate. + * + * Revision 1.5 1999/11/30 13:47:12 adam * Improved installation. Moved header files to include/yaz. * * Revision 1.4 1999/08/27 09:40:32 adam @@ -86,15 +88,13 @@ Z_GenericRecord *read_grs1(FILE *f, ODR o) } r->elements[r->num_elements] = t = (Z_TaggedElement *) odr_malloc(o, sizeof(Z_TaggedElement)); - t->tagType = (int *)odr_malloc(o, sizeof(int)); - *t->tagType = type; + t->tagType = odr_intdup(o, type); t->tagValue = (Z_StringOrNumeric *) odr_malloc(o, sizeof(Z_StringOrNumeric)); if ((ivalue = atoi(value))) { t->tagValue->which = Z_StringOrNumeric_numeric; - t->tagValue->u.numeric = (int *)odr_malloc(o, sizeof(int)); - *t->tagValue->u.numeric = ivalue; + t->tagValue->u.numeric = odr_intdup(o, ivalue); } else { diff --git a/ztest/ztest.c b/ztest/ztest.c index 32595fe..e6e724d 100644 --- a/ztest/ztest.c +++ b/ztest/ztest.c @@ -6,7 +6,10 @@ * Chas Woodfield, Fretwell Downing Datasystems. * * $Log: ztest.c,v $ - * Revision 1.39 2001-03-12 14:40:57 adam + * Revision 1.40 2001-03-25 21:55:13 adam + * Added odr_intdup. Ztest server returns TaskPackage for ItemUpdate. + * + * Revision 1.39 2001/03/12 14:40:57 adam * Minor change of print of item update info. * * Revision 1.38 2001/02/21 13:46:54 adam @@ -336,6 +339,60 @@ int ztest_esrequest (void *handle, bend_esrequest_rr *rr) if (!strcmp(toKeep->databaseName, "accept")) rr->errcode = -1; } + if (toKeep) + { + Z_External *ext = odr_malloc (rr->stream, sizeof(*ext)); + Z_IUOriginPartToKeep *keep = + odr_malloc (rr->stream, sizeof(*keep)); + Z_IUTargetPart *targetPart = + odr_malloc (rr->stream, sizeof(*targetPart)); + rr->taskPackage = odr_malloc (rr->stream, sizeof(*rr->taskPackage)); + rr->taskPackage->packageType = + odr_oiddup (rr->stream, rr->esr->packageType); + rr->taskPackage->packageName = 0; + rr->taskPackage->userId = 0; + rr->taskPackage->retentionTime = 0; + rr->taskPackage->permissions = 0; + rr->taskPackage->description = 0; + rr->taskPackage->targetReference = (Odr_oct *) + odr_malloc (rr->stream, sizeof(Odr_oct)); + rr->taskPackage->targetReference->buf = + odr_strdup (rr->stream, "123"); + rr->taskPackage->targetReference->len = + rr->taskPackage->targetReference->size = + strlen(rr->taskPackage->targetReference->buf); + rr->taskPackage->creationDateTime = 0; + rr->taskPackage->taskStatus = odr_intdup(rr->stream, 0); + rr->taskPackage->packageDiagnostics = 0; + rr->taskPackage->taskSpecificParameters = ext; + + ext->direct_reference = + odr_oiddup (rr->stream, rr->esr->packageType); + ext->indirect_reference = 0; + ext->descriptor = 0; + ext->which = Z_External_update; + ext->u.update = (Z_IUUpdate *) + odr_malloc (rr->stream, sizeof(*ext->u.update)); + ext->u.update->which = Z_IUUpdate_taskPackage; + ext->u.update->u.taskPackage = (Z_IUUpdateTaskPackage *) + odr_malloc (rr->stream, sizeof(Z_IUUpdateTaskPackage)); + ext->u.update->u.taskPackage->originPart = keep; + ext->u.update->u.taskPackage->targetPart = targetPart; + + keep->action = odr_malloc (rr->stream, sizeof(int)); + *keep->action = *toKeep->action; + keep->databaseName = + odr_strdup (rr->stream, toKeep->databaseName); + keep->schema = 0; + keep->elementSetName = 0; + keep->actionQualifier = 0; + + targetPart->updateStatus = odr_intdup (rr->stream, 1); + targetPart->num_globalDiagnostics = 0; + targetPart->globalDiagnostics = odr_nullval(); + targetPart->num_taskPackageRecords = 0; + targetPart->taskPackageRecords = odr_nullval(); + } if (notToKeep) { int i; diff --git a/zutil/prt-ext.c b/zutil/prt-ext.c index 2349fbc..14ff4a0 100644 --- a/zutil/prt-ext.c +++ b/zutil/prt-ext.c @@ -1,10 +1,12 @@ /* - * Copyright (c) 1995-1999, Index Data. + * Copyright (c) 1995-2001, Index Data. * See the file LICENSE for details. - * Sebastian Hammer, Adam Dickmeiss * * $Log: prt-ext.c,v $ - * Revision 1.4 2000-03-14 15:22:04 ian + * Revision 1.5 2001-03-25 21:55:13 adam + * Added odr_intdup. Ztest server returns TaskPackage for ItemUpdate. + * + * Revision 1.4 2000/03/14 15:22:04 ian * Added Admin external to choice table. * * Revision 1.3 2000/03/14 13:52:32 ian @@ -255,6 +257,9 @@ Z_External *z_ext_record(ODR o, int format, const char *buf, int len) case VAL_OPAC: thisext->which = Z_External_OPAC; break; + case VAL_EXTENDED: + thisext->which = Z_External_extendedService; + break; default: return 0; } diff --git a/zutil/zget.c b/zutil/zget.c index d1723b4..d8a970c 100644 --- a/zutil/zget.c +++ b/zutil/zget.c @@ -1,10 +1,13 @@ /* - * 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.5 2001-03-13 18:11:38 adam + * 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 @@ -87,10 +90,8 @@ Z_InitRequest *zget_InitRequest(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->preferredMessageSize = odr_intdup(o, 30*1024); + r->maximumRecordSize = odr_intdup(o, 30*1024); r->idAuthentication = 0; r->implementationId = "YAZ (id=81)"; r->implementationName = "Index Data/YAZ"; @@ -109,12 +110,9 @@ 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->preferredMessageSize = odr_intdup(o, 30*1024); + r->maximumRecordSize = odr_intdup(o, 30*1024); + r->result = odr_intdup(o, 1); r->implementationId = "YAZ (id=81)"; r->implementationName = "Index Data/YAZ"; r->implementationVersion = YAZ_VERSION; @@ -128,14 +126,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; @@ -153,14 +147,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; @@ -175,10 +165,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; @@ -195,12 +183,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; @@ -212,8 +197,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; @@ -226,8 +210,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; @@ -246,8 +229,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; @@ -259,10 +241,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; @@ -276,8 +256,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; @@ -293,8 +272,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; @@ -306,8 +284,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; @@ -343,8 +320,7 @@ 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 = (Z_NamePlusRecord **) odr_nullval(); r->otherInfo = 0; @@ -356,8 +332,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; @@ -383,8 +358,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; @@ -407,10 +381,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; @@ -422,8 +394,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; @@ -431,8 +402,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_waitIfPossible; + r->waitAction = odr_intdup(o, Z_ExtendedServicesRequest_waitIfPossible); r->elements = 0; r->otherInfo = 0; return r; @@ -444,8 +414,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; -- 1.7.10.4