From: Adam Dickmeiss Date: Tue, 31 Mar 1998 15:13:19 +0000 (+0000) Subject: Development towards compiled ASN.1. X-Git-Tag: YAZ.1.8~496 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=f94999cca65bd3464c1c6db8b5046e0a010b0c7f Development towards compiled ASN.1. --- diff --git a/Makefile b/Makefile index 93d9fdb..db6b788 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # Copyright (C) 1995-1998, Index Data I/S # All rights reserved. # Sebastian Hammer, Adam Dickmeiss -# $Id: Makefile,v 1.36 1998-01-29 13:43:03 adam Exp $ +# $Id: Makefile,v 1.37 1998-03-31 15:13:19 adam Exp $ # Uncomment the lines below to enable mOSI communcation. #ODEFS=-DUSE_XTIMOSI @@ -9,11 +9,18 @@ #LIBMOSI=../../xtimosi/src/libmosi.a ../lib/librfc.a #XMOSI=xmosi.o -CDEFS=$(ODEFS) +CDEFS=$(ODEFS) + +#INCLUDE=-I../z39.50 -I. -I../include +#MOD=z39.50 + +INCLUDE=-I. -I../include +MOD=asn + #CC= SHELL=/bin/sh MAKE=make -SUBDIR=util odr asn $(RFC1006) ccl comstack retrieval client server ztest makelib +SUBDIR=$(MOD) util odr $(RFC1006) ccl comstack retrieval client server ztest makelib # Add external libraries to the ELIBS macro ELIBS= CONTROL=RANLIB="ranlib" ELIBS="$(ELIBS)" @@ -29,11 +36,11 @@ YAZDIR=/usr/local/lib/yaz all: for i in $(SUBDIR); do cd $$i; if $(MAKE) $(CONTROL) \ - CFLAGS="$(CFLAGS)" CDEFS="$(CDEFS)" LIBMOSI="$(LIBMOSI)" XMOSI="$(XMOSI)";\ + INCLUDE="$(INCLUDE)" CFLAGS="$(CFLAGS)" CDEFS="$(CDEFS)" LIBMOSI="$(LIBMOSI)" XMOSI="$(XMOSI)";\ then cd ..; else exit 1; fi; done dep depend: - for i in $(SUBDIR); do cd $$i; if $(MAKE) CDEFS="$(CDEFS)" depend;\ + for i in $(SUBDIR); do cd $$i; if $(MAKE) INCLUDE="$(INCLUDE)" CDEFS="$(CDEFS)" depend;\ then cd ..; else exit 1; fi; done clean: diff --git a/asn/prt-ext.c b/asn/prt-ext.c index edfead6..670021b 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.18 1998-03-31 11:07:44 adam + * Revision 1.19 1998-03-31 15:13:19 adam + * Development towards compiled ASN.1. + * + * Revision 1.18 1998/03/31 11:07:44 adam * Furhter work on UNIverse resource report. * Added Extended Services handling in frontend server. * @@ -79,7 +82,11 @@ static Z_ext_typeent type_table[] = {VAL_PROMPT1, Z_External_promptObject1, (Odr_fun)z_PromptObject1 }, {VAL_GRS1, Z_External_grs1, (Odr_fun)z_GenericRecord}, {VAL_EXTENDED, Z_External_extendedService, (Odr_fun)z_TaskPackage}, +#ifdef ASN_COMPILED + {VAL_ITEMORDER, Z_External_itemOrder, (Odr_fun)z_IOItemOrder}, +#else {VAL_ITEMORDER, Z_External_itemOrder, (Odr_fun)z_ItemOrder}, +#endif {VAL_DIAG1, Z_External_diag1, (Odr_fun)z_DiagnosticFormat}, {VAL_ESPEC1, Z_External_espec1, (Odr_fun)z_Espec1}, {VAL_SUMMARY, Z_External_summary, (Odr_fun)z_BriefBib}, @@ -124,7 +131,11 @@ int z_External(ODR o, Z_External **p, int opt) {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_grs1, (Odr_fun)z_GenericRecord}, {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_extendedService, (Odr_fun)z_TaskPackage}, +#ifdef ASN_COMPILED + {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_itemOrder, (Odr_fun)z_IOItemOrder}, +#else {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_itemOrder, (Odr_fun)z_ItemOrder}, +#endif {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_diag1, (Odr_fun)z_DiagnosticFormat}, {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_espec1, (Odr_fun)z_Espec1}, {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_summary, (Odr_fun)z_BriefBib}, diff --git a/asn/zget.c b/asn/zget.c index e59bea1..1163246 100644 --- a/asn/zget.c +++ b/asn/zget.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zget.c,v $ - * Revision 1.14 1998-02-11 11:53:32 adam + * Revision 1.15 1998-03-31 15:13:19 adam + * Development towards compiled ASN.1. + * + * Revision 1.14 1998/02/11 11:53:32 adam * Changed code so that it compiles as C++. * * Revision 1.13 1998/01/29 13:13:39 adam @@ -204,7 +207,11 @@ Z_DeleteResultSetRequest *zget_DeleteResultSetRequest(ODR o) r->referenceId = 0; r->deleteFunction = (int *)odr_malloc(o, sizeof(int)); *r->deleteFunction = Z_DeleteRequest_list; +#ifdef ASN_COMPILED + r->num_resultSetList = 0; +#else r->num_ids = 0; +#endif r->resultSetList = 0; #ifdef Z_95 r->otherInfo = 0; @@ -219,11 +226,19 @@ Z_DeleteResultSetResponse *zget_DeleteResultSetResponse(ODR o) r->referenceId = 0; r->deleteOperationStatus = (int *)odr_malloc(o, sizeof(int)); *r->deleteOperationStatus = Z_DeleteStatus_success; +#ifdef ASN_COMPILED + r->deleteListStatuses = 0; +#else r->num_statuses = 0; r->deleteListStatuses = 0; +#endif r->numberNotDeleted = 0; +#ifdef ASN_COMPILED + r->bulkStatuses = 0; +#else r->num_bulkStatuses = 0; r->bulkStatuses = 0; +#endif r->deleteMessage = 0; #ifdef Z_95 r->otherInfo = 0; diff --git a/client/client.c b/client/client.c index 25c719c..7375649 100644 --- a/client/client.c +++ b/client/client.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: client.c,v $ - * Revision 1.64 1998-03-31 11:07:44 adam + * Revision 1.65 1998-03-31 15:13:19 adam + * Development towards compiled ASN.1. + * + * Revision 1.64 1998/03/31 11:07:44 adam * Furhter work on UNIverse resource report. * Added Extended Services handling in frontend server. * @@ -579,7 +582,7 @@ static void display_record(Z_DatabaseRecord *p) * Note: we throw away the original, BER-encoded record here. * Do something else with it if you want to keep it. */ - r->u.sutrs = (Odr_oct *)rr; /* we don't actually check the type here. */ + r->u.sutrs = (Z_SUTRS *) rr; /* we don't actually check the type here. */ r->which = type->what; } } @@ -643,10 +646,22 @@ static void display_diagrecs(Z_DiagRec **pp, int num) ent->oclass != CLASS_DIAGSET || ent->value != VAL_BIB1) printf("Missing or unknown diagset\n"); printf(" [%d] %s", *r->condition, diagbib1_str(*r->condition)); +#ifdef ASN_COMPILED + switch (r->which) + { + case Z_DefaultDiagFormat_v2Addinfo: + printf (" -- v2 addinfo '%s'\n", r->u.v2Addinfo); + break; + case Z_DefaultDiagFormat_v3Addinfo: + printf (" -- v3 addinfo '%s'\n", r->u.v3Addinfo); + break; + } +#else if (r->addinfo && *r->addinfo) printf(" -- '%s'\n", r->addinfo); else printf("\n"); +#endif } } @@ -666,7 +681,16 @@ static void display_records(Z_Records *p) int i; if (p->which == Z_Records_NSD) + { +#ifdef ASN_COMPILED + Z_DiagRec dr, *dr_p = &dr; + dr.which = Z_DiagRec_defaultFormat; + dr.u.defaultFormat = p->u.nonSurrogateDiagnostic; + display_diagrecs (&dr_p, 1); +#else display_diagrecs (&p->u.nonSurrogateDiagnostic, 1); +#endif + } else if (p->which == Z_Records_multipleNSD) display_diagrecs (p->u.multipleNonSurDiagnostics->diagRecs, p->u.multipleNonSurDiagnostics->num_diagRecs); @@ -985,7 +1009,11 @@ static Z_External *CreateItemOrderExternal(int itemno) r->u.itemOrder = odr_malloc(out,sizeof(Z_ItemOrder)); memset(r->u.itemOrder, 0, sizeof(Z_ItemOrder)); +#ifdef ASN_COMPILED + r->u.itemOrder->which=Z_IOItemOrder_esRequest; +#else r->u.itemOrder->which=Z_ItemOrder_esRequest; +#endif r->u.itemOrder->u.esRequest = odr_malloc(out,sizeof(Z_IORequest)); memset(r->u.itemOrder->u.esRequest, 0, sizeof(Z_IORequest)); @@ -1306,6 +1334,14 @@ int send_sortrequest(char *arg, int newset) req->referenceId = set_refid (out); +#ifdef ASN_COMPILED + req->num_inputResultSetNames = 1; + req->inputResultSetNames = (Z_InternationalString **) + odr_malloc (out, sizeof(*req->inputResultSetNames)); + req->inputResultSetNames[0] = (char *) + odr_malloc (out, strlen(setstring)+1); + strcpy (req->inputResultSetNames[0], setstring); +#else req->inputResultSetNames = (Z_StringList *)odr_malloc (out, sizeof(*req->inputResultSetNames)); req->inputResultSetNames->num_strings = 1; @@ -1314,6 +1350,7 @@ int send_sortrequest(char *arg, int newset) req->inputResultSetNames->strings[0] = (char *)odr_malloc (out, strlen(setstring)+1); strcpy (req->inputResultSetNames->strings[0], setstring); +#endif if (newset && setnumber >= 0) sprintf (setstring, "%d", ++setnumber); @@ -1374,7 +1411,12 @@ int send_sortrequest(char *arg, int newset) sks->caseSensitivity = (int *)odr_malloc (out, sizeof(*sks->caseSensitivity)); *sks->caseSensitivity = Z_SortCase_caseSensitive; +#ifdef ASN_COMPILED + sks->which = Z_SortKeySpec_null; + sks->u.null = odr_nullval (); +#else sks->missingValueAction = NULL; +#endif for (i = 0; sort_flags[i]; i++) { @@ -1426,6 +1468,8 @@ void display_term(Z_TermInfo *t) void process_scanResponse(Z_ScanResponse *res) { int i; + Z_Entry **entries = NULL; + int num_entries = 0; printf("Received ScanResponse\n"); print_refid (res->referenceId); @@ -1437,22 +1481,33 @@ void process_scanResponse(Z_ScanResponse *res) printf("Scan returned code %d\n", *res->scanStatus); if (!res->entries) return; +#ifdef ASN_COMPILED + if ((entries = res->entries->entries)) + num_entries = res->entries->num_entries; +#else if (res->entries->which == Z_ListEntries_entries) { - Z_Entries *ent = res->entries->u.entries; - - for (i = 0; i < ent->num_entries; i++) - if (ent->entries[i]->which == Z_Entry_termInfo) - { - printf("%c ", i + 1 == *res->positionOfTerm ? '*' : ' '); - display_term(ent->entries[i]->u.termInfo); - } - else - display_diagrecs(&ent->entries[i]->u.surrogateDiagnostic, 1); + entries = res->entries->u.entries->entries; + num_entries = res->entries->u.entries->num_entries; } - else +#endif + for (i = 0; i < num_entries; i++) + if (entries[i]->which == Z_Entry_termInfo) + { + printf("%c ", i + 1 == *res->positionOfTerm ? '*' : ' '); + display_term(entries[i]->u.termInfo); + } + else + display_diagrecs(&entries[i]->u.surrogateDiagnostic, 1); +#ifdef ASN_COMPILED + if (res->entries->nonsurrogateDiagnostics) + display_diagrecs (res->entries->nonsurrogateDiagnostics, + res->entries->num_nonsurrogateDiagnostics); +#else + if (res->entries->which == Z_ListEntries_nonSurrogateDiagnostics) display_diagrecs(&res->entries-> u.nonSurrogateDiagnostics->diagRecs[0], 1); +#endif } void process_sortResponse(Z_SortResponse *res) @@ -1471,9 +1526,15 @@ void process_sortResponse(Z_SortResponse *res) } printf ("\n"); print_refid (res->referenceId); +#ifdef ASN_COMPILED + if (res->diagnostics) + display_diagrecs(res->diagnostics, + res->num_diagnostics); +#else if (res->diagnostics) display_diagrecs(res->diagnostics->diagRecs, res->diagnostics->num_diagRecs); +#endif } int cmd_sort_generic(char *arg, int newset) diff --git a/include/prt-ext.h b/include/prt-ext.h index 63c38f2..4939fe6 100644 --- a/include/prt-ext.h +++ b/include/prt-ext.h @@ -33,6 +33,7 @@ #define PRT_EXT_H #include +#include #ifdef __cplusplus extern "C" { diff --git a/retrieval/d1_expout.c b/retrieval/d1_expout.c index 39fb011..e572708 100644 --- a/retrieval/d1_expout.c +++ b/retrieval/d1_expout.c @@ -1,10 +1,13 @@ /* - * Copyright (c) 1995-1997, Index Data. + * Copyright (c) 1995-1998, Index Data. * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * * $Log: d1_expout.c,v $ - * Revision 1.9 1998-03-05 08:07:58 adam + * Revision 1.10 1998-03-31 15:13:20 adam + * Development towards compiled ASN.1. + * + * Revision 1.9 1998/03/05 08:07:58 adam * Make data1 to EXPLAIN ignore local tags in root. * * Revision 1.8 1998/02/11 11:53:35 adam @@ -390,12 +393,21 @@ static int *f_recordCount(ExpHandle *eh, data1_node *c, int *which) c = c->child; if (!is_numeric_tag (eh, c)) return 0; +#ifdef ASN_COMPILED + if (c->u.tag.element->tag->value.numeric == 210) + *wp = Z_DatabaseInfo_actualNumber; + else if (c->u.tag.element->tag->value.numeric == 211) + *wp = Z_DatabaseInfo_approxNumber; + else + return 0; +#else if (c->u.tag.element->tag->value.numeric == 210) *wp = Z_Exp_RecordCount_actualNumber; else if (c->u.tag.element->tag->value.numeric == 211) *wp = Z_Exp_RecordCount_approxNumber; else return 0; +#endif if (!c->child || c->child->which != DATA1N_data) return 0; sprintf(intbuf, "%.*s", 63, c->child->u.data.data); @@ -561,7 +573,11 @@ static Z_DatabaseInfo *f_databaseInfo(ExpHandle *eh, data1_node *n) res->subDbs = 0; res->disclaimers = 0; res->news = 0; +#ifdef ASN_COMPILED + res->u.actualNumber = 0; +#else res->recordCount = 0; +#endif res->defaultOrder = 0; res->avRecordSize = 0; res->maxRecordSize = 0; @@ -640,8 +656,13 @@ static Z_DatabaseInfo *f_databaseInfo(ExpHandle *eh, data1_node *n) break; case 207: res->disclaimers = f_humstring(eh, c); break; case 103: res->news = f_humstring(eh, c); break; +#ifdef ASN_COMPILED + case 209: res->u.actualNumber = + f_recordCount(eh, c, &res->which); break; +#else case 209: res->recordCount = f_recordCount(eh, c, &res->recordCount_which); break; +#endif case 212: res->defaultOrder = f_humstring(eh, c); break; case 213: res->avRecordSize = f_integer(eh, c); break; case 214: res->maxRecordSize = f_integer(eh, c); break; diff --git a/server/seshigh.c b/server/seshigh.c index fd86e0f..24a835d 100644 --- a/server/seshigh.c +++ b/server/seshigh.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: seshigh.c,v $ - * Revision 1.73 1998-03-31 11:07:45 adam + * Revision 1.74 1998-03-31 15:13:20 adam + * Development towards compiled ASN.1. + * + * Revision 1.73 1998/03/31 11:07:45 adam * Furhter work on UNIverse resource report. * Added Extended Services handling in frontend server. * @@ -829,6 +832,17 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb) * These functions should be merged. */ +static void set_addinfo (Z_DefaultDiagFormat *dr, char *addinfo) +{ +#if ASN_COMPILED + dr->which = Z_DefaultDiagFormat_v2Addinfo; + dr->u.v2Addinfo = addinfo ? addinfo : ""; +#else + dr->which = Z_DiagForm_v2AddInfo; + dr->addinfo = addinfo ? addinfo : ""; +#endif +} + /* * nonsurrogate diagnostic record. */ @@ -849,6 +863,9 @@ static Z_Records *diagrec(association *assoc, int error, char *addinfo) "NULL"); *err = error; rec->which = Z_Records_NSD; +#if ASN_COMPILED + rec->u.nonSurrogateDiagnostic = dr; +#else #ifdef Z_95 rec->u.nonSurrogateDiagnostic = drec; drec->which = Z_DiagRec_defaultFormat; @@ -856,11 +873,11 @@ static Z_Records *diagrec(association *assoc, int error, char *addinfo) #else rec->u.nonSurrogateDiagnostic = dr; #endif +#endif dr->diagnosticSetId = odr_oiddup (assoc->encode, oid_ent_to_oid(&bib1, oid)); dr->condition = err; - dr->which = Z_DiagForm_v2AddInfo; - dr->addinfo = addinfo ? addinfo : ""; + set_addinfo (dr, addinfo); return rec; } @@ -891,8 +908,8 @@ static Z_NamePlusRecord *surrogatediagrec(association *assoc, char *dbname, dr->diagnosticSetId = odr_oiddup (assoc->encode, oid_ent_to_oid(&bib1, oid)); dr->condition = err; - dr->which = Z_DiagForm_v2AddInfo; - dr->addinfo = addinfo ? addinfo : ""; + set_addinfo (dr, addinfo); + return rec; } @@ -924,8 +941,14 @@ static Z_DiagRecs *diagrecs(association *assoc, int error, char *addinfo) rec->diagnosticSetId = odr_oiddup (assoc->encode, oid_ent_to_oid(&bib1, oid)); rec->condition = err; + +#ifdef ASN_COMPILED + rec->which = Z_DefaultDiagFormat_v2Addinfo; + rec->u.v2Addinfo = addinfo ? addinfo : ""; +#else rec->which = Z_DiagForm_v2AddInfo; rec->addinfo = addinfo ? addinfo : ""; +#endif return recs; } @@ -1066,6 +1089,12 @@ static Z_Records *pack_records(association *a, char *setname, int start, } else if (fres->format == VAL_SUTRS) /* SUTRS is a single-ASN.1-type */ { +#if 0 + Z_SUTRS *sutrs = (Z_SUTRS *)odr_malloc(a->encode, 1+fres->len); + + memcpy(sutrs, fres->record, fres->len); + sutrs[fres->len] = '\0'; +#else Odr_oct *sutrs = (Odr_oct *)odr_malloc(a->encode, sizeof(*sutrs)); thisext->which = Z_External_sutrs; @@ -1073,6 +1102,7 @@ static Z_Records *pack_records(association *a, char *setname, int start, sutrs->buf = (unsigned char *)odr_malloc(a->encode, fres->len); sutrs->len = sutrs->size = fres->len; memcpy(sutrs->buf, fres->record, fres->len); +#endif } else /* octet-aligned record. */ { @@ -1343,6 +1373,7 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb, int *fd) int *numberOfEntriesReturned = (int *)odr_malloc (assoc->encode, sizeof(*numberOfEntriesReturned)); Z_ListEntries *ents = (Z_ListEntries *)odr_malloc (assoc->encode, sizeof(*ents)); + Z_DiagRecs *diagrecs_p = NULL; oident *attent; bend_scanrequest srq; bend_scanresult *srs; @@ -1360,21 +1391,29 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb, int *fd) res->numberOfEntriesReturned = numberOfEntriesReturned; res->positionOfTerm = 0; res->entries = ents; - ents->which = Z_ListEntries_nonSurrogateDiagnostics; +#if ASN_COMPILED + ents->num_entries = 0; + ents->entries = NULL; + ents->num_nonsurrogateDiagnostics = 0; + ents->nonsurrogateDiagnostics = NULL; +#else + ents->which = Z_ListEntries_entries; +#endif res->attributeSet = 0; res->otherInfo = 0; if (req->attributeSet && (!(attent = oid_getentbyoid(req->attributeSet)) || - attent->oclass != CLASS_ATTSET || attent->value != VAL_BIB1)) - ents->u.nonSurrogateDiagnostics = diagrecs(assoc, 121, 0); + attent->oclass != CLASS_ATTSET + || attent->value != VAL_BIB1)) + diagrecs_p = diagrecs(assoc, 121, 0); else if (req->stepSize && *req->stepSize > 0) - ents->u.nonSurrogateDiagnostics = diagrecs(assoc, 205, 0); + diagrecs_p = diagrecs(assoc, 205, 0); else { if (req->termListAndStartPoint->term->which == Z_Term_general) logf(LOG_DEBUG, " term: '%.*s'", - req->termListAndStartPoint->term->u.general->len, - req->termListAndStartPoint->term->u.general->buf); + req->termListAndStartPoint->term->u.general->len, + req->termListAndStartPoint->term->u.general->buf); srq.num_bases = req->num_databaseNames; srq.basenames = req->databaseNames; srq.num_entries = *req->numberOfTermsRequested; @@ -1388,31 +1427,42 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb, int *fd) srq.term_position = req->preferredPositionInResponse ? *req->preferredPositionInResponse : 1; if (!(srs = bend_scan(assoc->backend, &srq, 0))) - ents->u.nonSurrogateDiagnostics = diagrecs(assoc, 2, 0); + diagrecs_p = diagrecs(assoc, 2, 0); else if (srs->errcode) - ents->u.nonSurrogateDiagnostics = diagrecs(assoc, - srs->errcode, srs->errstring); + diagrecs_p = diagrecs(assoc, srs->errcode, srs->errstring); else { int i; - Z_Entries *list = (Z_Entries *)odr_malloc (assoc->encode, sizeof(*list)); - Z_Entry **tab = (Z_Entry **)odr_malloc (assoc->encode, - sizeof(*tab) * srs->num_entries); - +#ifdef ASN_COMPILED +#else + Z_Entries *list = (Z_Entries *) + odr_malloc (assoc->encode, sizeof(*list)); +#endif + Z_Entry **tab = (Z_Entry **) + odr_malloc (assoc->encode, sizeof(*tab) * srs->num_entries); + if (srs->status == BEND_SCAN_PARTIAL) *scanStatus = Z_Scan_partial_5; else *scanStatus = Z_Scan_success; - ents->which = Z_ListEntries_entries; +#ifdef ASN_COMPILED + ents->entries = tab; + ents->num_entries = srs->num_entries; + res->numberOfEntriesReturned = &ents->num_entries; +#else ents->u.entries = list; list->entries = tab; + list->num_entries = srs->num_entries; + res->numberOfEntriesReturned = &list->num_entries; +#endif + res->positionOfTerm = &srs->term_position; for (i = 0; i < srs->num_entries; i++) { Z_Entry *e; Z_TermInfo *t; Odr_oct *o; - - list->entries[i] = e = (Z_Entry *)odr_malloc(assoc->encode, sizeof(*e)); + + tab[i] = e = (Z_Entry *)odr_malloc(assoc->encode, sizeof(*e)); e->which = Z_Entry_termInfo; e->u.termInfo = t = (Z_TermInfo *)odr_malloc(assoc->encode, sizeof(*t)); t->suggestedAttributes = 0; @@ -1431,12 +1481,18 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb, int *fd) logf(LOG_DEBUG, " term #%d: '%s' (%d)", i, srs->entries[i].term, srs->entries[i].occurrences); } - list->num_entries = i; - res->numberOfEntriesReturned = &list->num_entries; - res->positionOfTerm = &srs->term_position; } } - + if (diagrecs_p) + { +#ifdef ASN_COMPILED + ents->num_nonsurrogateDiagnostics = diagrecs_p->num_diagRecs; + ents->nonsurrogateDiagnostics = diagrecs_p->diagRecs; +#else + ents->u.nonSurrogateDiagnostics = diagrecs_p; + ents->which = Z_ListEntries_nonSurrogateDiagnostics; +#endif + } return apdu; } @@ -1451,8 +1507,13 @@ static Z_APDU *process_sortRequest(association *assoc, request *reqb, logf(LOG_LOG, "Got SortRequest."); +#ifdef ASN_COMPILED + bsrr->num_input_setnames = req->num_inputResultSetNames; + bsrr->input_setnames = req->inputResultSetNames; +#else bsrr->num_input_setnames = req->inputResultSetNames->num_strings; bsrr->input_setnames = req->inputResultSetNames->strings; +#endif bsrr->output_setname = req->sortedResultSetName; bsrr->sort_sequence = req->sortSequence; bsrr->stream = assoc->encode; @@ -1468,9 +1529,22 @@ static Z_APDU *process_sortRequest(association *assoc, request *reqb, *res->sortStatus = bsrr->sort_status; res->resultSetStatus = 0; if (bsrr->errcode) - res->diagnostics = diagrecs(assoc, bsrr->errcode, bsrr->errstring); + { + Z_DiagRecs *dr = diagrecs (assoc, bsrr->errcode, bsrr->errstring); +#ifdef ASN_COMPILED + res->diagnostics = dr->diagRecs; + res->num_diagnostics = dr->num_diagRecs; +#else + res->diagnostics = dr; +#endif + } else + { +#ifdef ASN_COMPILED + res->num_diagnostics = 0; +#endif res->diagnostics = 0; + } res->otherInfo = 0; apdu->which = Z_APDU_sortResponse; diff --git a/util/pquery.c b/util/pquery.c index 47ff25b..b57b9a5 100644 --- a/util/pquery.c +++ b/util/pquery.c @@ -1,10 +1,13 @@ /* - * Copyright (c) 1995-1997, Index Data. + * Copyright (c) 1995-1998, Index Data. * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * * $Log: pquery.c,v $ - * Revision 1.19 1998-03-05 08:09:03 adam + * Revision 1.20 1998-03-31 15:13:20 adam + * Development towards compiled ASN.1. + * + * Revision 1.19 1998/03/05 08:09:03 adam * Minor change to make C++ happy. * * Revision 1.18 1998/02/11 11:53:36 adam @@ -182,51 +185,61 @@ static Z_AttributesPlusTerm *rpn_term (struct lex_info *li, ODR o, Z_AttributesPlusTerm *zapt; Odr_oct *term_octet; Z_Term *term; + Z_AttributeElement **elements; zapt = (Z_AttributesPlusTerm *)odr_malloc (o, sizeof(*zapt)); term_octet = (Odr_oct *)odr_malloc (o, sizeof(*term_octet)); term = (Z_Term *)odr_malloc (o, sizeof(*term)); - zapt->num_attributes = num_attr; - if (num_attr) + if (!num_attr) + elements = (Z_AttributeElement**)odr_nullval(); + else { int i; int *attr_tmp; - zapt->attributeList = (Z_AttributeElement**)odr_malloc (o, num_attr * - sizeof(*zapt->attributeList)); + 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)); for (i = 0; i < num_attr; i++) { - zapt->attributeList[i] = - (Z_AttributeElement*)odr_malloc (o,sizeof(**zapt->attributeList)); - zapt->attributeList[i]->attributeType = &attr_tmp[2*i]; + elements[i] = + (Z_AttributeElement*)odr_malloc (o,sizeof(**elements)); + elements[i]->attributeType = &attr_tmp[2*i]; #ifdef Z_95 if (attr_set[i] == VAL_NONE) - zapt->attributeList[i]->attributeSet = 0; + elements[i]->attributeSet = 0; else { oident attrid; int oid[OID_SIZE]; - + attrid.proto = PROTO_Z3950; attrid.oclass = CLASS_ATTSET; attrid.value = attr_set[i]; - zapt->attributeList[i]->attributeSet = - odr_oiddup (o, oid_ent_to_oid (&attrid, oid)); + elements[i]->attributeSet = + odr_oiddup (o, oid_ent_to_oid (&attrid, oid)); } - zapt->attributeList[i]->which = Z_AttributeValue_numeric; - zapt->attributeList[i]->value.numeric = &attr_tmp[2*i+1]; + elements[i]->which = Z_AttributeValue_numeric; + elements[i]->value.numeric = &attr_tmp[2*i+1]; #else - zapt->attributeList[i]->attributeValue = &attr_tmp[2*i+1]; + elements[i]->attributeValue = &attr_tmp[2*i+1]; #endif } } - else - zapt->attributeList = (Z_AttributeElement**)odr_nullval(); +#ifdef ASN_COMPILED + zapt->attributes = (Z_AttributeList *) + odr_malloc (o, sizeof(*zapt->attributes)); + zapt->attributes->num_attributes = num_attr; + zapt->attributes->attributes = elements; +#else + zapt->num_attributes = num_attr; + zapt->attributeList = elements; +#endif + zapt->term = term; term->which = Z_Term_general; term->u.general = term_octet; @@ -313,9 +326,14 @@ static Z_ProximityOperator *rpn_proximity (struct lex_info *li, ODR o) if (!lex (li)) return NULL; +#ifdef ASN_COMPILED + p->which = Z_ProximityOperator_known; + p->u.known = (int *)odr_malloc (o, sizeof(*p->u.known)); + *p->u.known = atoi (li->lex_buf); +#else p->proximityUnitCode = (int *)odr_malloc (o, sizeof(*p->proximityUnitCode)); *p->proximityUnitCode = atoi (li->lex_buf); - +#endif return p; } diff --git a/util/yaz-ccl.c b/util/yaz-ccl.c index d9de5ba..436d048 100644 --- a/util/yaz-ccl.c +++ b/util/yaz-ccl.c @@ -1,10 +1,13 @@ /* - * Copyright (c) 1996-1997, Index Data. + * Copyright (c) 1996-1998, Index Data. * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * * $Log: yaz-ccl.c,v $ - * Revision 1.12 1998-02-11 11:53:36 adam + * Revision 1.13 1998-03-31 15:13:20 adam + * Development towards compiled ASN.1. + * + * Revision 1.12 1998/02/11 11:53:36 adam * Changed code so that it compiles as C++. * * Revision 1.11 1997/11/24 11:33:57 adam @@ -38,6 +41,7 @@ static Z_AttributesPlusTerm *ccl_rpn_term (ODR o, struct ccl_rpn_node *p) Z_AttributesPlusTerm *zapt; Odr_oct *term_octet; Z_Term *term; + Z_AttributeElement **elements; zapt = (Z_AttributesPlusTerm *)odr_malloc (o, sizeof(*zapt)); assert (zapt); @@ -50,30 +54,37 @@ static Z_AttributesPlusTerm *ccl_rpn_term (ODR o, struct ccl_rpn_node *p) for (attr = p->u.t.attr_list; attr; attr = attr->next) num++; - zapt->num_attributes = num; - if (num) + if (!num) + elements = (Z_AttributeElement**)odr_nullval(); + else { int i = 0; - zapt->attributeList = (Z_AttributeElement **)odr_malloc (o, num*sizeof(*zapt->attributeList)); - assert (zapt->attributeList); + elements = (Z_AttributeElement **) + odr_malloc (o, num*sizeof(*elements)); for (attr = p->u.t.attr_list; attr; attr = attr->next, i++) { - zapt->attributeList[i] = - (Z_AttributeElement *)odr_malloc (o, sizeof(**zapt->attributeList)); - assert (zapt->attributeList[i]); - zapt->attributeList[i]->attributeType = + elements[i] = (Z_AttributeElement *) + odr_malloc (o, sizeof(**elements)); + assert (elements[i]); + elements[i]->attributeType = (int *)odr_malloc(o, sizeof(int)); - *zapt->attributeList[i]->attributeType = attr->type; - zapt->attributeList[i]->attributeSet = 0; - zapt->attributeList[i]->which = Z_AttributeValue_numeric; - zapt->attributeList[i]->value.numeric = + *elements[i]->attributeType = attr->type; + elements[i]->attributeSet = 0; + elements[i]->which = Z_AttributeValue_numeric; + elements[i]->value.numeric = (int *)odr_malloc (o, sizeof(int)); - *zapt->attributeList[i]->value.numeric = attr->value; + *elements[i]->value.numeric = attr->value; } } - else - zapt->attributeList = (Z_AttributeElement**)odr_nullval(); - +#ifdef ASN_COMPILED + zapt->attributes = (Z_AttributeList *) + odr_malloc (o, sizeof(*zapt->attributes)); + zapt->attributes->num_attributes = num; + zapt->attributes->attributes = elements; +#else + zapt->num_attributes = num; + zapt->attributeList = elements; +#endif zapt->term = term; term->which = Z_Term_general; term->u.general = term_octet;