From 7f4183f05884c781eb395a17e4282485c618ded6 Mon Sep 17 00:00:00 2001 From: Sebastian Hammer Date: Mon, 21 Aug 1995 09:10:10 +0000 Subject: [PATCH] Smallish fixes to suppport new formats. --- CHANGELOG | 13 +++++++++--- asn/Makefile | 5 +++-- asn/proto.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++- asn/prt-ext.c | 8 ++++++- include/proto.h | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++- include/prt-ext.h | 6 +++++- include/prt.h | 1 + odr/odr_mem.c | 15 ++++++++++++- server/seshigh.c | 29 +++++++++++++++++-------- util/oid.c | 26 ++++++++++++++++++++++- 10 files changed, 203 insertions(+), 20 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6c4f9de..8b02996 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,8 +9,12 @@ will only affect you if you use the frontend-server. Added Explain encoders/decoders to the service-level API. Untested. Added GRS-1 encoders/decoders to the service-level API. Lightly tested. -Test-client will ask for and ODR pretty-print GRS1. Ztest will return -dummy records. +Test-client will ask for and print GRS1. Ztest will return dummy records +on request. + +Added Extended Services: Item Order encoders and decoders to the Service- +level API. Untested. Would anyone be willing to fax or mail the pertinent +bits of the ILL protocol to us? Moved pretty-printing of structure-wrappers ({..}) from odr_seq.c to odr_cons.c, which causes a more correct output. @@ -19,11 +23,14 @@ Fixed handling of searchRequest in frontend server. NextResultSetPosition was always set to 0 when no records were requested in the searchRequest. * Added better external-handling. This shouldn't harm old code that *encodes* -externals. It will break code that looks for a 'single-ASN1-type' +externals. It can break code that looks for a 'single-ASN1-type' representation, since those types that are known are now decoded immediately. Look at the SUTRS sample code in seshigh.c and client.c. Documentation updated. +Better, but backwards-compatible handling of records in bend_fetchresponse. +Length -1 marks structured record, type is deduced from format field. + --- 1.0b2 1995/06/27 Fairly quick maintenance release to add SUTRS support. diff --git a/asn/Makefile b/asn/Makefile index 0ef61da..a1bc5d8 100644 --- a/asn/Makefile +++ b/asn/Makefile @@ -1,7 +1,7 @@ # Copyright (C) 1994, Index Data I/S # All rights reserved. # Sebastian Hammer, Adam Dickmeiss -# $Id: Makefile,v 1.18 1995-08-17 12:44:59 quinn Exp $ +# $Id: Makefile,v 1.19 1995-08-21 09:10:13 quinn Exp $ SHELL=/bin/sh INCLUDE=-I../include -I. @@ -11,7 +11,8 @@ LIBINCLUDE=-L$(LIBDIR) DEFS=$(INCLUDE) LIB=$(LIBDIR)/libasn.a LIBS=-lodr -lasn -PO = proto.o diagbib1.o zget.o prt-rsc.o prt-acc.o prt-exp.o prt-ext.o prt-grs.o +PO = proto.o diagbib1.o zget.o prt-rsc.o prt-acc.o prt-exp.o prt-ext.o \ + prt-grs.o prt-exd.o CPP=$(CC) -E RANLIB=ranlib diff --git a/asn/proto.c b/asn/proto.c index 913644a..b50e132 100644 --- a/asn/proto.c +++ b/asn/proto.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: proto.c,v $ - * Revision 1.36 1995-08-15 11:59:39 quinn + * Revision 1.37 1995-08-21 09:10:15 quinn + * Smallish fixes to suppport new formats. + * + * Revision 1.36 1995/08/15 11:59:39 quinn * Updated External * * Revision 1.35 1995/08/10 08:53:59 quinn @@ -1417,6 +1420,56 @@ int z_Close(ODR o, Z_Close **p, int opt) /* ------------------------ APDU ------------------------- */ +int z_Permissions(ODR o, Z_Permissions **p, int opt) +{ + if (!odr_sequence_begin(o, p, sizeof(**p))) + return opt && odr_ok(o); + return + odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT, + 1, 0) && + odr_implicit_settag(o, ODR_CONTEXT, 2) && + odr_sequence_of(o, odr_integer, &(*p)->allowableFunctions, + &(*p)->num_allowableFunctions) && + odr_sequence_end(o); +} + +int z_ExtendedServicesRequest(ODR o, Z_ExtendedServicesRequest **p, int opt) +{ + if (!odr_sequence_begin(o, p, sizeof(**p))) + return opt && odr_ok(o); + return + z_ReferenceId(o, &(*p)->referenceId, 1) && + odr_implicit(o, odr_integer, &(*p)->function, ODR_CONTEXT, 3, 0) && + odr_implicit(o, odr_oid, &(*p)->packageType, ODR_CONTEXT, 4, 0) && + odr_implicit(o, z_InternationalString, &(*p)->packageName, ODR_CONTEXT, 5, 1) && + odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT, 6, 1) && + odr_implicit(o, z_IntUnit, &(*p)->retentionTime, ODR_CONTEXT, 7, 1) && + odr_implicit(o, z_Permissions, &(*p)->permissions, ODR_CONTEXT, 8, 1) && + odr_implicit(o, z_InternationalString, &(*p)->description, ODR_CONTEXT, 9, 1) && + odr_implicit(o, z_External, &(*p)->taskSpecificParameters, ODR_CONTEXT, 10, 1) && + odr_implicit(o, odr_integer, &(*p)->waitAction, ODR_CONTEXT, 11, 0) && + z_ElementSetName(o, &(*p)->elements, 1) && + z_OtherInformation(o, &(*p)->otherInfo, 1) && + odr_sequence_end(o); +} + +int z_ExtendedServicesResponse(ODR o, Z_ExtendedServicesResponse **p, int opt) +{ + if (!odr_sequence_begin(o, p, sizeof(**p))) + return opt && odr_ok(o); + return + z_ReferenceId(o, &(*p)->referenceId, 1) && + odr_implicit(o, odr_integer, &(*p)->operationStatus, ODR_CONTEXT, 3, 0) && + odr_implicit_settag(o, ODR_CONTEXT, 4) && + (odr_sequence_of(o, z_DiagRec, &(*p)->diagnostics, + &(*p)->num_diagnostics) || odr_ok(o)) && + odr_implicit(o, z_External, &(*p)->taskPackage, ODR_CONTEXT, 5, 1) && + z_OtherInformation(o, &(*p)->otherInfo, 1) && + odr_sequence_end(o); +} + +/* ------------------------ APDU ------------------------- */ + int z_APDU(ODR o, Z_APDU **p, int opt) { static Odr_arm arm[] = @@ -1443,6 +1496,10 @@ int z_APDU(ODR o, Z_APDU **p, int opt) {ODR_IMPLICIT, ODR_CONTEXT, 35, Z_APDU_scanRequest, z_ScanRequest}, {ODR_IMPLICIT, ODR_CONTEXT, 36, Z_APDU_scanResponse, z_ScanResponse}, {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_APDU_segmentRequest, z_Segment}, + {ODR_IMPLICIT, ODR_CONTEXT, 46, Z_APDU_extendedServicesRequest, + z_ExtendedServicesRequest}, + {ODR_IMPLICIT, ODR_CONTEXT, 47, Z_APDU_extendedServicesResponse, + z_ExtendedServicesResponse}, {ODR_IMPLICIT, ODR_CONTEXT, 48, Z_APDU_close, z_Close}, {-1, -1, -1, -1, 0} diff --git a/asn/prt-ext.c b/asn/prt-ext.c index 3b5b49f..f075073 100644 --- a/asn/prt-ext.c +++ b/asn/prt-ext.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: prt-ext.c,v $ - * Revision 1.2 1995-08-17 12:45:00 quinn + * Revision 1.3 1995-08-21 09:10:18 quinn + * Smallish fixes to suppport new formats. + * + * Revision 1.2 1995/08/17 12:45:00 quinn * Fixed minor problems with GRS-1. Added support in c&s. * * Revision 1.1 1995/08/15 13:37:41 quinn @@ -35,6 +38,9 @@ int z_External(ODR o, Z_External **p, int opt) {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_promptObject1, z_PromptObject1}, {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_grs1, z_GenericRecord}, + {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_extendedService, + z_TaskPackage}, + {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_itemOrder, z_ItemOrder}, {-1, -1, -1, -1, 0} }; /* diff --git a/include/proto.h b/include/proto.h index 4d6b8e5..19ef1d0 100644 --- a/include/proto.h +++ b/include/proto.h @@ -24,7 +24,10 @@ * OF THIS SOFTWARE. * * $Log: proto.h,v $ - * Revision 1.22 1995-08-17 12:45:14 quinn + * Revision 1.23 1995-08-21 09:10:36 quinn + * Smallish fixes to suppport new formats. + * + * Revision 1.22 1995/08/17 12:45:14 quinn * Fixed minor problems with GRS-1. Added support in c&s. * * Revision 1.21 1995/08/15 12:00:11 quinn @@ -1020,6 +1023,55 @@ typedef struct Z_Segment Z_OtherInformation *otherInfo; /* OPTIONAL */ } Z_Segment; +/* ----------------------- Extended Services ---------------- */ + +typedef struct Z_Permissions +{ + char *userId; + int num_allowableFunctions; + int **allowableFunctions; +#define Z_Permissions_delete 1 +#define Z_Permissions_modifyContents 2 +#define Z_Permissions_modifyPermissions 3 +#define Z_Permissions_present 4 +#define Z_Permissions_invoke 5 +} Z_Permissions; + +typedef struct Z_ExtendedServicesRequest +{ + Z_ReferenceId *referenceId; /* OPTIONAL */ + int *function; +#define Z_ExtendedServicesRequest_create 1 +#define Z_ExtendedServicesRequest_delete 2 +#define Z_ExtendedServicesRequest_modify 3 + Odr_oid *packageType; + char *packageName; /* OPTIONAL */ + char *userId; /* OPTIONAL */ + Z_IntUnit *retentionTime; /* OPTIONAL */ + Z_Permissions *permissions; /* OPTIONAL */ + char *description; /* OPTIONAL */ + Z_External *taskSpecificParameters; /* OPTIONAL */ + int *waitAction; +#define Z_ExtendedServicesRequest_wait 1 +#define Z_ExtendedServicesRequest_waitIfPossible 2 +#define Z_ExtendedServicesRequest_dontWait 3 +#define Z_ExtendedServicesRequest_dontReturnPackage 4 + char *elements; /* OPTIONAL */ + Z_OtherInformation *otherInfo; /* OPTIONAL */ +} Z_ExtendedServicesRequest; + +typedef struct Z_ExtendedServicesResponse +{ + Z_ReferenceId *referenceId; /* OPTIONAL */ + int *operationStatus; +#define Z_ExtendedServicesResponse_done 1 +#define Z_ExtendedServicesResponse_accepted 2 +#define Z_ExtendedServicesResponse_failure 3 + int num_diagnostics; + Z_DiagRec **diagnostics; /* OPTIONAL */ + Z_External *taskPackage; /* OPTIONAL */ + Z_OtherInformation *otherInfo; /* OPTIONAL */ +} Z_ExtendedServicesResponse; /* ------------------------ APDU ---------------------------- */ @@ -1041,6 +1093,8 @@ typedef struct Z_APDU Z_APDU_scanRequest, Z_APDU_scanResponse, Z_APDU_segmentRequest, + Z_APDU_extendedServicesRequest, + Z_APDU_extendedServicesResponse, Z_APDU_close } which; union @@ -1059,6 +1113,8 @@ typedef struct Z_APDU Z_ScanRequest *scanRequest; Z_ScanResponse *scanResponse; Z_Segment *segmentRequest; + Z_ExtendedServicesRequest *extendedServicesRequest; + Z_ExtendedServicesResponse *extendedServicesResponse; Z_Close *close; } u; } Z_APDU; @@ -1090,12 +1146,15 @@ int z_StringOrNumeric(ODR o, Z_StringOrNumeric **p, int opt); int z_OtherInformationUnit(ODR o, Z_OtherInformationUnit **p, int opt); int z_Term(ODR o, Z_Term **p, int opt); int z_Specification(ODR o, Z_Specification **p, int opt); +int z_Permissions(ODR o, Z_Permissions **p, int opt); +int z_DiagRec(ODR o, Z_DiagRec **p, int opt); Z_APDU *zget_APDU(ODR o, enum Z_APDU_which which); #include #include #include #include +#include #include diff --git a/include/prt-ext.h b/include/prt-ext.h index 7c5a06f..a714403 100644 --- a/include/prt-ext.h +++ b/include/prt-ext.h @@ -47,7 +47,9 @@ struct Z_External Z_External_resourceReport1, Z_External_resourceReport2, Z_External_promptObject1, - Z_External_grs1 + Z_External_grs1, + Z_External_extendedService, + Z_External_itemOrder } which; union { @@ -63,6 +65,8 @@ struct Z_External Z_ResourceReport2 *resourceReport2; Z_PromptObject1 *promptObject1; Z_GenericRecord *grs1; + Z_TaskPackage *extendedService; + Z_ItemOrder *itemOrder; } u; }; diff --git a/include/prt.h b/include/prt.h index 977bec9..0b45d2b 100644 --- a/include/prt.h +++ b/include/prt.h @@ -43,3 +43,4 @@ int odr_write(ODR o, unsigned char *buf, int bytes); int odr_seek(ODR o, int whence, int offset); int odr_dumpBER(FILE *f, char *buf, int len); void odr_choice_bias(ODR o, int what); +int odr_total(ODR o); diff --git a/odr/odr_mem.c b/odr/odr_mem.c index bc48fcd..044b306 100644 --- a/odr/odr_mem.c +++ b/odr/odr_mem.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: odr_mem.c,v $ - * Revision 1.5 1995-05-16 08:50:55 quinn + * Revision 1.6 1995-08-21 09:10:41 quinn + * Smallish fixes to suppport new formats. + * + * Revision 1.5 1995/05/16 08:50:55 quinn * License, documentation, and memory fixes * * Revision 1.4 1995/05/15 11:56:09 quinn @@ -36,6 +39,7 @@ typedef struct odr_memblock char *buf; int size; int top; + int total; struct odr_memblock *next; } odr_memblock; @@ -74,6 +78,7 @@ static odr_memblock *get_block(int size) abort(); } r->top = 0; + r->total = 0; return r; } @@ -113,15 +118,23 @@ void *odr_malloc(ODR o, int size) abort(); else { + if (o->mem) + p->total = o->mem->total; p->next = o->mem; o->mem = p; } r = p->buf + p->top; /* align size */ p->top += (size + (sizeof(long) - 1)) & ~(sizeof(long) - 1); + p->total += size; return r; } +int odr_total(ODR o) +{ + return o->mem ? o->mem->total : 0; +} + /* ---------- memory management for data encoding ----------*/ diff --git a/server/seshigh.c b/server/seshigh.c index a9dfd99..0fd64e9 100644 --- a/server/seshigh.c +++ b/server/seshigh.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: seshigh.c,v $ - * Revision 1.44 1995-08-17 12:45:25 quinn + * Revision 1.45 1995-08-21 09:11:00 quinn + * Smallish fixes to suppport new formats. + * + * Revision 1.44 1995/08/17 12:45:25 quinn * Fixed minor problems with GRS-1. Added support in c&s. * * Revision 1.43 1995/08/15 12:00:31 quinn @@ -756,7 +759,14 @@ static Z_Records *pack_records(association *a, char *setname, int start, bend_fetchresult *fres; Z_NamePlusRecord *thisrec; Z_DatabaseRecord *thisext; - + int this_length; + + /* + * we get the number of bytes allocated on the stream before any + * allocation done by the backend - this should give us a reasonable + * idea of the total size of the data so far. + */ + total_length = odr_total(a->encode); if (reclist.num_records == MAX_RECORDS - 1) { *pres = Z_PRES_PARTIAL_2; @@ -778,19 +788,23 @@ static Z_Records *pack_records(association *a, char *setname, int start, *pres = Z_PRES_FAILURE; return diagrec(a->proto, fres->errcode, fres->errstring); } + if (fres->len >= 0) + this_length = fres->len; + else + this_length = odr_total(a->encode) - total_length; logf(LOG_DEBUG, " fetched record, len=%d, total=%d", - fres->len, total_length); - if (fres->len + total_length > a->preferredMessageSize) + this_length, total_length); + if (this_length + total_length > a->preferredMessageSize) { /* record is small enough, really */ - if (fres->len <= a->preferredMessageSize) + if (this_length <= a->preferredMessageSize) { logf(LOG_DEBUG, " Dropped last normal-sized record"); *pres = Z_PRES_PARTIAL_2; break; } /* record can only be fetched by itself */ - if (fres->len < a->maximumRecordSize) + if (this_length < a->maximumRecordSize) { logf(LOG_DEBUG, " Record > prefmsgsz"); if (toget > 1) @@ -799,7 +813,6 @@ static Z_Records *pack_records(association *a, char *setname, int start, reclist.records[reclist.num_records] = surrogatediagrec(a->proto, fres->basename, 16, 0); reclist.num_records++; - total_length += 10; /* totally arbitrary */ continue; } } @@ -809,7 +822,6 @@ static Z_Records *pack_records(association *a, char *setname, int start, reclist.records[reclist.num_records] = surrogatediagrec(a->proto, fres->basename, 17, 0); reclist.num_records++; - total_length += 10; /* totally arbitrary */ continue; } } @@ -877,7 +889,6 @@ static Z_Records *pack_records(association *a, char *setname, int start, } reclist.records[reclist.num_records] = thisrec; reclist.num_records++; - total_length += fres->len; *next = fres->last_in_set ? 0 : recno + 1; } *num = reclist.num_records; diff --git a/util/oid.c b/util/oid.c index 44b91b6..bc36e70 100644 --- a/util/oid.c +++ b/util/oid.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: oid.c,v $ - * Revision 1.1 1995-05-29 08:17:13 quinn + * Revision 1.2 1995-08-21 09:11:16 quinn + * Smallish fixes to suppport new formats. + * + * Revision 1.1 1995/05/29 08:17:13 quinn * iMoved oid to util to support comstack. * * Revision 1.5 1995/05/22 11:30:16 quinn @@ -118,6 +121,27 @@ static oident oids[] = {PROTO_SR, CLASS_RECSYN, VAL_CANMARC, {5,17,-1}, "Canmarc" }, {PROTO_SR, CLASS_RECSYN, VAL_SBN, {5,18,-1}, "SBN" }, {PROTO_SR, CLASS_RECSYN, VAL_PICAMARC, {5,19,-1}, "Picamarc" }, + {PROTO_SR, CLASS_RECSYN, VAL_AUSMARC, {5,20,-1}, "Ausmarc" }, + {PROTO_SR, CLASS_RECSYN, VAL_IBERMARC, {5,21,-1}, "Ibermarc" }, + {PROTO_SR, CLASS_RECSYN, VAL_EXPLAIN, {5,100,-1}, "Explain" }, + {PROTO_SR, CLASS_RECSYN, VAL_SUTRS, {5,101,-1}, "SUTRS" }, + {PROTO_SR, CLASS_RECSYN, VAL_OPAC, {5,102,-1}, "OPAC" }, + {PROTO_SR, CLASS_RECSYN, VAL_SUMMARY, {5,103,-1}, "Summary" }, + {PROTO_SR, CLASS_RECSYN, VAL_GRS0, {5,104,-1}, "GRS-0" }, + {PROTO_SR, CLASS_RECSYN, VAL_GRS1, {5,105,-1}, "GRS-1" }, + {PROTO_SR, CLASS_RECSYN, VAL_EXTENDED, {5,106,-1}, "Extended" }, + {PROTO_SR, CLASS_RESFORM, VAL_RESOURCE1, {7,1,-1}, "Resource-1" }, + {PROTO_SR, CLASS_RESFORM, VAL_RESOURCE2, {7,2,-1}, "Resource-2" }, + {PROTO_SR, CLASS_ACCFORM, VAL_PROMPT1, {8,1,-1}, "Prompt-1" }, + {PROTO_SR, CLASS_ACCFORM, VAL_DES1, {8,2,-1}, "Des-1" }, + {PROTO_SR, CLASS_ACCFORM, VAL_KRB1, {8,3,-1}, "Krb-1" }, + {PROTO_SR, CLASS_EXTSERV, VAL_PRESSET, {9,1,-1}, "Pers. set" }, + {PROTO_SR, CLASS_EXTSERV, VAL_PQUERY, {9,2,-1}, "Pers. query" }, + {PROTO_SR, CLASS_EXTSERV, VAL_PCQUERY, {9,3,-1}, "Per'd query" }, + {PROTO_SR, CLASS_EXTSERV, VAL_ITEMORDER, {9,4,-1}, "Item order" }, + {PROTO_SR, CLASS_EXTSERV, VAL_DBUPDATE, {9,5,-1}, "DB. Update" }, + {PROTO_SR, CLASS_EXTSERV, VAL_EXPORTSPEC,{9,6,-1}, "exp. spec." }, + {PROTO_SR, CLASS_EXTSERV, VAL_EXPORTINV, {9,7,-1}, "exp. inv." }, {0, 0, 0, {-1}, 0 } }; -- 1.7.10.4