From e461bc647761fc0284d4556f526c93c8a00a22fa Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 16 Aug 1996 15:07:42 +0000 Subject: [PATCH] First work on Explain. --- Makefile.in | 4 +- explain.c | 1619 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ grs.c | 7 +- ir-tcl.c | 205 +++++--- ir-tclp.h | 8 +- 5 files changed, 1780 insertions(+), 63 deletions(-) create mode 100644 explain.c diff --git a/Makefile.in b/Makefile.in index 342e3fd..28c0a7b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -2,7 +2,7 @@ # (c) Index Data 1995-1996 # See the file LICENSE for details. # Sebastian Hammer, Adam Dickmeiss -# $Id: Makefile.in,v 1.38 1996-07-26 09:15:06 adam Exp $ +# $Id: Makefile.in,v 1.39 1996-08-16 15:07:42 adam Exp $ SHELL=/bin/sh # IrTcl Version @@ -53,7 +53,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ RANLIB = @RANLIB@ -O=ir-tcl.o marc.o queue.o mem.o grs.o +O=ir-tcl.o marc.o queue.o mem.o grs.o explain.o all: ir-tcl ir-tk diff --git a/explain.c b/explain.c new file mode 100644 index 0000000..ad33770 --- /dev/null +++ b/explain.c @@ -0,0 +1,1619 @@ +/* + * IR toolkit for tcl/tk + * (c) Index Data 1996 + * See the file LICENSE for details. + * Sebastian Hammer, Adam Dickmeiss + * + * $Log: explain.c,v $ + * Revision 1.1 1996-08-16 15:07:43 adam + * First work on Explain. + * + */ + +#include +#include +#include +#include + +#include "ir-tclp.h" + +typedef struct { + int argc; + char **argv; + Tcl_Interp *interp; +} IrExpArg; + +typedef struct { + char *name; + int id; + int (*handle)(); +} IrExpChoice; + +typedef char *Z_ElementSetName; +typedef Odr_oid *Z_AttributeSetId; +typedef int Z_integer; +typedef char *Z_InternationalString; +typedef char *Z_LanguageCode; + +static int ir_UnitType (IrExpArg *iea, + Z_UnitType *p, const char *name, int argi); +static int ir_Unit (IrExpArg *iea, + Z_Unit *p, const char *name, int argi); +static int ir_VariantType (IrExpArg *iea, + Z_VariantType *p, const char *name, int argi); +static int ir_OmittedAttributeInterpretation (IrExpArg *iea, + Z_OmittedAttributeInterpretation *p, const char *name, int argi); +static int ir_AttributeTypeDetails (IrExpArg *iea, + Z_AttributeTypeDetails *p, const char *name, int argi); +static int ir_Specification (IrExpArg *iea, + Z_Specification *p, const char *name, int argi); +static int ir_RetrievalRecordDetails (IrExpArg *iea, + Z_RetrievalRecordDetails *p, const char *name, int argi); +static int ir_ElementInfo (IrExpArg *iea, + Z_ElementInfo *p, const char *name, int argi); +static int ir_integer (IrExpArg *iea, + Z_integer *p, const char *name, int argi); +static int ir_InternationalString (IrExpArg *iea, + char *p, const char *name, int argi); +static int ir_TagSetInfo (IrExpArg *iea, + Z_TagSetInfo *p, const char *name, int argi); +static int ir_DatabaseName (IrExpArg *iea, + char *p, const char *name, int argi); +static int ir_AccessInfo (IrExpArg *iea, + Z_AccessInfo *p, const char *name, int argi); +static int ir_bool (IrExpArg *iea, + bool_t *p, const char *name, int argi); +static int ir_LanguageCode (IrExpArg *iea, + char *p, const char *name, int argi); +static int ir_Units (IrExpArg *iea, + Z_Units *p, const char *name, int argi); +static int ir_SortDetails (IrExpArg *iea, + Z_SortDetails *p, const char *name, int argi); +static int ir_ElementSetDetails (IrExpArg *iea, + Z_ElementSetDetails *p, const char *name, int argi); +static int ir_TermListDetails (IrExpArg *iea, + Z_TermListDetails *p, const char *name, int argi); +static int ir_AttributeValue (IrExpArg *iea, + Z_AttributeValue *p, const char *name, int argi); +static int ir_ElementDataType (IrExpArg *iea, + Z_ElementDataType *p, const char *name, int argi); +static int ir_ProximitySupport (IrExpArg *iea, + Z_ProximitySupport *p, const char *name, int argi); +static int ir_ProcessingInformation (IrExpArg *iea, + Z_ProcessingInformation *p, const char *name, int argi); +static int ir_AttributeCombinations (IrExpArg *iea, + Z_AttributeCombinations *p, const char *name, int argi); +static int ir_AttributeSetDetails (IrExpArg *iea, + Z_AttributeSetDetails *p, const char *name, int argi); +static int ir_DatabaseInfo (IrExpArg *iea, + Z_DatabaseInfo *p, const char *name, int argi); +static int ir_IconObject (IrExpArg *iea, + Z_IconObject *p, const char *name, int argi); +static int ir_RpnCapabilities (IrExpArg *iea, + Z_RpnCapabilities *p, const char *name, int argi); +static int ir_QueryTypeDetails (IrExpArg *iea, + Z_QueryTypeDetails *p, const char *name, int argi); +static int ir_ValueDescription (IrExpArg *iea, + Z_ValueDescription *p, const char *name, int argi); +static int ir_AttributeSetInfo (IrExpArg *iea, + Z_AttributeSetInfo *p, const char *name, int argi); +static int ir_SchemaInfo (IrExpArg *iea, + Z_SchemaInfo *p, const char *name, int argi); +static int ir_AttributeOccurrence (IrExpArg *iea, + Z_AttributeOccurrence *p, const char *name, int argi); +static int ir_AttributeCombination (IrExpArg *iea, + Z_AttributeCombination *p, const char *name, int argi); +static int ir_UnitInfo (IrExpArg *iea, + Z_UnitInfo *p, const char *name, int argi); +static int ir_VariantClass (IrExpArg *iea, + Z_VariantClass *p, const char *name, int argi); +static int ir_VariantSetInfo (IrExpArg *iea, + Z_VariantSetInfo *p, const char *name, int argi); +static int ir_RecordTag (IrExpArg *iea, + Z_RecordTag *p, const char *name, int argi); +static int ir_TermListInfo (IrExpArg *iea, + Z_TermListInfo *p, const char *name, int argi); +static int ir_StringOrNumeric (IrExpArg *iea, + Z_StringOrNumeric *p, const char *name, int argi); +static int ir_CategoryInfo (IrExpArg *iea, + Z_CategoryInfo *p, const char *name, int argi); +static int ir_ValueRange (IrExpArg *iea, + Z_ValueRange *p, const char *name, int argi); +static int ir_Term (IrExpArg *iea, + Z_Term *p, const char *name, int argi); +static int ir_DatabaseList (IrExpArg *iea, + Z_DatabaseList *p, const char *name, int argi); +static int ir_HumanString (IrExpArg *iea, + Z_HumanString *p, const char *name, int argi); +static int ir_CommonInfo (IrExpArg *iea, + Z_CommonInfo *p, const char *name, int argi); +static int ir_NetworkAddress (IrExpArg *iea, + Z_NetworkAddress *p, const char *name, int argi); +static int ir_Costs (IrExpArg *iea, + Z_Costs *p, const char *name, int argi); +static int ir_RecordSyntaxInfo (IrExpArg *iea, + Z_RecordSyntaxInfo *p, const char *name, int argi); +static int ir_OtherInformation (IrExpArg *iea, + Z_OtherInformation *p, const char *name, int argi); +static int ir_CategoryList (IrExpArg *iea, + Z_CategoryList *p, const char *name, int argi); +static int ir_VariantValue (IrExpArg *iea, + Z_VariantValue *p, const char *name, int argi); +static int ir_PerElementDetails (IrExpArg *iea, + Z_PerElementDetails *p, const char *name, int argi); +static int ir_AttributeDetails (IrExpArg *iea, + Z_AttributeDetails *p, const char *name, int argi); +static int ir_ExtendedServicesInfo (IrExpArg *iea, + Z_ExtendedServicesInfo *p, const char *name, int argi); +static int ir_AttributeType (IrExpArg *iea, + Z_AttributeType *p, const char *name, int argi); +static int ir_IntUnit (IrExpArg *iea, + Z_IntUnit *p, const char *name, int argi); +static int ir_Charge (IrExpArg *iea, + Z_Charge *p, const char *name, int argi); +static int ir_PrivateCapabilities (IrExpArg *iea, + Z_PrivateCapabilities *p, const char *name, int argi); +static int ir_ValueSet (IrExpArg *iea, + Z_ValueSet *p, const char *name, int argi); +static int ir_AttributeDescription (IrExpArg *iea, + Z_AttributeDescription *p, const char *name, int argi); +static int ir_Path (IrExpArg *iea, + Z_Path *p, const char *name, int argi); +static int ir_ContactInfo (IrExpArg *iea, + Z_ContactInfo *p, const char *name, int argi); +static int ir_SearchKey (IrExpArg *iea, + Z_SearchKey *p, const char *name, int argi); +static int ir_Iso8777Capabilities (IrExpArg *iea, + Z_Iso8777Capabilities *p, const char *name, int argi); +static int ir_AccessRestrictions (IrExpArg *iea, + Z_AccessRestrictions *p, const char *name, int argi); +static int ir_SortKeyDetails (IrExpArg *iea, + Z_SortKeyDetails *p, const char *name, int argi); + + +static int +ir_match_start (const char *name, void *p, IrExpArg *iea, int argi) +{ + if (!p) + return 0; + Tcl_AppendResult (iea->interp, name, " {", NULL); + return 1; +} + +static int +ir_match_end (const char *name, IrExpArg *iea, int argi) +{ + Tcl_AppendResult (iea->interp, "} ", NULL); + return TCL_OK; +} + +static int +ir_choice (IrExpArg *iea, IrExpChoice *clist, int what, void *p, int argi) +{ + while (clist->name) + { + if (clist->id == what) + return (*clist->handle)(iea, p, clist->name, argi); + clist++; + } + return TCL_OK; +} + +static int ir_null (IrExpArg *iea, + Odr_null *p, const char *name, int argi) +{ + if (p) + Tcl_AppendResult (iea->interp, name, " ", NULL); + return TCL_OK; +} + +static int ir_CString (IrExpArg *iea, + char *p, const char *name, int argi) +{ + Tcl_AppendResult (iea->interp, "{", name, " ", NULL); + if (p) + Tcl_AppendElement (iea->interp, p); + Tcl_AppendResult (iea->interp, "} ", NULL); + return TCL_OK; +} + + + +static int ir_ElementSetName (IrExpArg *iea, + char *p, const char *name, int argi) +{ + return ir_CString (iea, p, name, argi); +} + +static int ir_DatabaseName (IrExpArg *iea, + char *p, const char *name, int argi) +{ + return ir_CString (iea, p, name, argi); +} + +static int ir_InternationalString (IrExpArg *iea, + char *p, const char *name, int argi) +{ + return ir_CString (iea, p, name, argi); +} + +static int ir_GeneralizedTime (IrExpArg *iea, + char *p, const char *name, int argi) +{ + return ir_CString (iea, p, name, argi); +} + +static int ir_oid (IrExpArg *iea, + Odr_oid *p, const char *name, int argi) +{ + return TCL_OK; +} + +static int ir_TagTypeMapping (IrExpArg *iea, + Z_TagTypeMapping **p, const char *name, int argi) +{ + return TCL_OK; +} + +static int ir_PrimitiveDataType (IrExpArg *iea, + int *p, const char *name, int argi) +{ + return TCL_OK; +} + +static int ir_octet (IrExpArg *iea, + Odr_oct *p, const char *name, int argi) +{ + return TCL_OK; +} + +static int ir_choice_nop (IrExpArg *iea, + void *p, const char *name, int argi) +{ + Tcl_AppendResult (iea->interp, name, " ", NULL); + return TCL_OK; +} + +static int ir_Term (IrExpArg *iea, + Z_Term *p, const char *name, int argi) +{ + return TCL_OK; +} + +static int ir_bool (IrExpArg *iea, + bool_t *p, const char *name, int argi) +{ + Tcl_AppendResult (iea->interp, "{", name, " ", NULL); + if (p) + Tcl_AppendResult (iea->interp, *p ? "1" : "0", NULL); + Tcl_AppendResult (iea->interp, "} ", NULL); + return TCL_OK; +} + +static int ir_integer (IrExpArg *iea, + int *p, const char *name, int argi) +{ + Tcl_AppendResult (iea->interp, "{", name, NULL); + if (p) + { + char buf[64]; + sprintf (buf, " %d", *p); + Tcl_AppendResult (iea->interp, buf, NULL); + } + Tcl_AppendResult (iea->interp, "} ", NULL); + return TCL_OK; +} + +static int ir_LanguageCode (IrExpArg *iea, + char *p, const char *name, int argi) +{ + if (p) + Tcl_AppendResult (iea->interp, name, " ", p, " ", NULL); + return TCL_OK; +} + +static int ir_External (IrExpArg *iea, + Z_External *p, const char *name, int argi) +{ + return TCL_OK; +} + +static int ir_sequence (int (*fh)(), IrExpArg *iea, void *p, int num, + const char *name, int argi) +{ + void **pp = (void **) p; + if (num > 0 && ir_match_start (name, p, iea, argi)) + { + int i; + for (i = 0; icommonInfo, "commonInfo", argi); + ir_InternationalString (iea, p->name, "name", argi); + ir_HumanString (iea, p->recentNews, "recent-news", argi); + ir_IconObject (iea, p->icon, "icon", argi); + ir_bool (iea, p->namedResultSets, "namedResultSets", argi); + ir_bool (iea, p->multipleDBsearch, "multipleDBsearch", argi); + ir_integer (iea, p->maxResultSets, "maxResultSets", argi); + ir_integer (iea, p->maxResultSize, "maxResultSize", argi); + ir_integer (iea, p->maxTerms, "maxTerms", argi); + ir_IntUnit (iea, p->timeoutInterval, "timeoutInterval", argi); + ir_HumanString (iea, p->welcomeMessage, "welcomeMessage", argi); + ir_ContactInfo (iea, p->contactInfo, "contactInfo", argi); + ir_HumanString (iea, p->description, "description", argi); + ir_sequence (ir_InternationalString, iea, p->nicknames, + p->num_nicknames, "nicknames", argi); + ir_HumanString (iea, p->usageRest, "usage-rest", argi); + ir_HumanString (iea, p->paymentAddr, "paymentAddr", argi); + ir_HumanString (iea, p->hours, "hours", argi); + ir_sequence (ir_DatabaseList, iea, p->dbCombinations, + p->num_dbCombinations, "dbCombinations", argi); + ir_sequence (ir_NetworkAddress, iea, p->addresses, + p->num_addresses, "addresses", argi); + ir_AccessInfo (iea, p->commonAccessInfo, "commonAccessInfo", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_DatabaseInfo (IrExpArg *iea, + Z_DatabaseInfo *p, const char *name, int argi) +{ + static IrExpChoice arm_recordCount [] = { + { "actualNumber", Z_Exp_RecordCount_actualNumber, + ir_integer }, + { "approxNumber", Z_Exp_RecordCount_approxNumber, + ir_integer }, + { NULL, 0, NULL }}; + + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_CommonInfo (iea, p->commonInfo, "commonInfo", argi); + ir_DatabaseName (iea, p->name, "name", argi); + ir_null (iea, p->explainDatabase, "explainDatabase", argi); + ir_sequence (ir_DatabaseName, iea, p->nicknames, + p->num_nicknames, "nicknames", argi); + ir_IconObject (iea, p->icon, "icon", argi); + ir_bool (iea, p->userFee, "user-fee", argi); + ir_bool (iea, p->available, "available", argi); + ir_HumanString (iea, p->titleString, "titleString", argi); + ir_sequence (ir_HumanString, iea, p->keywords, + p->num_keywords, "keywords", argi); + ir_HumanString (iea, p->description, "description", argi); + ir_DatabaseList (iea, p->associatedDbs, "associatedDbs", argi); + ir_DatabaseList (iea, p->subDbs, "subDbs", argi); + ir_HumanString (iea, p->disclaimers, "disclaimers", argi); + ir_HumanString (iea, p->news, "news", argi); + + ir_choice (iea, arm_recordCount, p->recordCount_which, + p->recordCount, argi); + + ir_HumanString (iea, p->defaultOrder, "defaultOrder", argi); + ir_integer (iea, p->avRecordSize, "avRecordSize", argi); + ir_integer (iea, p->maxRecordSize, "maxRecordSize", argi); + ir_HumanString (iea, p->hours, "hours", argi); + ir_HumanString (iea, p->bestTime, "bestTime", argi); + ir_GeneralizedTime (iea, p->lastUpdate, "lastUpdate", argi); + ir_IntUnit (iea, p->updateInterval, "updateInterval", argi); + ir_HumanString (iea, p->coverage, "coverage", argi); + ir_bool (iea, p->proprietary, "proprietary", argi); + ir_HumanString (iea, p->copyrightText, "copyrightText", argi); + ir_HumanString (iea, p->copyrightNotice, "copyrightNotice", argi); + ir_ContactInfo (iea, p->producerContactInfo, "producerContactInfo", argi); + ir_ContactInfo (iea, p->supplierContactInfo, "supplierContactInfo", argi); + ir_ContactInfo (iea, p->submissionContactInfo, "submissionContactInfo", argi); + ir_AccessInfo (iea, p->accessInfo, "accessInfo", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_SchemaInfo (IrExpArg *iea, + Z_SchemaInfo *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_CommonInfo (iea, p->commonInfo, "commonInfo", argi); + ir_oid (iea, p->schema, "schema", argi); + ir_InternationalString (iea, p->name, "name", argi); + ir_HumanString (iea, p->description, "description", argi); + + ir_sequence (ir_TagTypeMapping, iea, p->tagTypeMapping, + p->num_tagTypeMapping, "tagTypeMapping", argi); + ir_sequence (ir_ElementInfo, iea, p->recordStructure, + p->num_recordStructure, "recordStructure", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_ElementDataTypePrimitive (IrExpArg *iea, + int *p, const char *name, int argi) +{ + static IrExpChoice arm[] = { + {"octetString", Z_PrimitiveElement_octetString, ir_choice_nop }, + {"numeric", Z_PrimitiveElement_numeric, ir_choice_nop }, + {NULL, 0, NULL}}; + + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_choice (iea, arm, *p, NULL, argi); + return ir_match_end (name, iea, argi); +} + +static int ir_ElementInfo (IrExpArg *iea, + Z_ElementInfo *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_InternationalString (iea, p->elementName, "elementName", argi); + ir_Path (iea, p->elementTagPath, "elementTagPath", argi); + ir_ElementDataType (iea, p->dataType, "dataType", argi); + ir_bool (iea, p->required, "required", argi); + ir_bool (iea, p->repeatable, "repeatable", argi); + ir_HumanString (iea, p->description, "description", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_ElementInfoList (IrExpArg *iea, + Z_ElementInfoList *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_sequence (ir_ElementInfo, iea, p->list, + p->num, "list", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_ElementDataType (IrExpArg *iea, + Z_ElementDataType *p, const char *name, int argi) +{ + static IrExpChoice arm[] = { + { "primitive", Z_ElementDataType_primitive, + ir_ElementDataTypePrimitive }, + { "structured", Z_ElementDataType_structured, + ir_ElementInfoList }, + { NULL, 0, NULL }}; + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_choice (iea, arm, p->which, p->u.primitive, argi); + return ir_match_end (name, iea, argi); +} + +static int ir_PathUnit (IrExpArg *iea, + Z_PathUnit *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_integer (iea, p->tagType, "tagType", argi); + ir_StringOrNumeric (iea, p->tagValue, "tagValue", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_Path (IrExpArg *iea, + Z_Path *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_sequence (ir_PathUnit, iea, p->list, + p->num, "list", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_TagSetInfoElements (IrExpArg *iea, + Z_TagSetInfoElements *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_InternationalString (iea, p->elementName, "elementname", argi); + ir_sequence (ir_InternationalString, iea, p->nicknames, + p->num_nicknames, "nicknames", argi); + ir_StringOrNumeric (iea, p->elementTag, "elementTag", argi); + ir_HumanString (iea, p->description, "description", argi); + ir_PrimitiveDataType (iea, p->dataType, "dataType", argi); + ir_OtherInformation (iea, p->otherTagInfo, "otherTagInfo", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_TagSetInfo (IrExpArg *iea, + Z_TagSetInfo *p, const char *name, int argi) +{ + int i; + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_CommonInfo (iea, p->commonInfo, "commonInfo", argi); + ir_oid (iea, p->tagSet, "tagSet", argi); + ir_InternationalString (iea, p->name, "name", argi); + ir_HumanString (iea, p->description, "description", argi); + for (i = 0; inum_elements; i++) + ir_TagSetInfoElements (iea, p->elements[i], "elements", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_RecordSyntaxInfo (IrExpArg *iea, + Z_RecordSyntaxInfo *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_CommonInfo (iea, p->commonInfo, "commonInfo", argi); + ir_oid (iea, p->recordSyntax, "recordSyntax", argi); + ir_InternationalString (iea, p->name, "name", argi); + ir_sequence (ir_oid, iea, p->transferSyntaxes, + p->num_transferSyntaxes, "transferSyntaxes", argi); + ir_HumanString (iea, p->description, "description", argi); + ir_InternationalString (iea, p->asn1Module, "asn1Module", argi); + ir_sequence (ir_ElementInfo, iea, p->abstractStructure, + p->num_abstractStructure, "abstractStructure", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_AttributeType (IrExpArg *iea, + Z_AttributeType *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_InternationalString (iea, p->name, "name", argi); + ir_HumanString (iea, p->description, "description", argi); + ir_integer (iea, p->attributeType, "attributeType", argi); + ir_sequence (ir_AttributeDescription, iea, p->attributeValues, + p->num_attributeValues, "attributeValues", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_AttributeSetInfo (IrExpArg *iea, + Z_AttributeSetInfo *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_CommonInfo (iea, p->commonInfo, "commonInfo", argi); + ir_oid (iea, p->attributeSet, "attributeSet", argi); + ir_InternationalString (iea, p->name, "name", argi); + ir_sequence (ir_AttributeType, iea, p->attributes, + p->num_attributes, "attributes", argi); + ir_HumanString (iea, p->description, "description", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_AttributeDescription (IrExpArg *iea, + Z_AttributeDescription *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_InternationalString (iea, p->name, "name", argi); + ir_HumanString (iea, p->description, "description", argi); + ir_StringOrNumeric (iea, p->attributeValue, "attributeValue", argi); + ir_sequence (ir_StringOrNumeric,iea, p->equivalentAttributes, + p->num_equivalentAttributes, "equivalentAttributes", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_TermListElement (IrExpArg *iea, + Z_TermListElement *p, const char *name, int argi) +{ + static IrExpChoice searchCostArm [] = { + { "optimized", Z_TermListInfo_optimized, ir_choice_nop }, + { "normal", Z_TermListInfo_normal, ir_choice_nop }, + { "expensive", Z_TermListInfo_expensive, ir_choice_nop }, + { "filter", Z_TermListInfo_filter, ir_choice_nop }, + { NULL, 0, NULL }}; + ir_InternationalString (iea, p->name, "name", argi); + ir_HumanString (iea, p->title, "title", argi); + if (p->searchCost) + ir_choice (iea, searchCostArm, *p->searchCost, NULL, argi); + + ir_bool (iea, p->scanable, "scanable", argi); + ir_sequence (ir_InternationalString, iea, p->broader, + p->num_broader, "broader", argi); + ir_sequence (ir_InternationalString, iea, p->narrower, + p->num_narrower, "narrower", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_TermListInfo (IrExpArg *iea, + Z_TermListInfo *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_CommonInfo (iea, p->commonInfo, "commonInfo", argi); + ir_DatabaseName (iea, p->databaseName, "databaseName", argi); + ir_sequence (ir_TermListElement, iea, p->termLists, + p->num_termLists, "termLists", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_ExtendedServicesInfo (IrExpArg *iea, + Z_ExtendedServicesInfo *p, const char *name, int argi) +{ + static IrExpChoice waitActionArm [] = { + { "waitSupported", Z_ExtendedServicesInfo_waitSupported, + ir_choice_nop }, + { "waitAlways", Z_ExtendedServicesInfo_waitAlways, + ir_choice_nop }, + { "waitNotSupported", Z_ExtendedServicesInfo_waitNotSupported, + ir_choice_nop }, + { "depends", Z_ExtendedServicesInfo_depends, + ir_choice_nop }, + { "notSaying", Z_ExtendedServicesInfo_notSaying, + ir_choice_nop }, + { NULL, 0, NULL }}; + + ir_InternationalString (iea, p->name, "name", argi); + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_CommonInfo (iea, p->commonInfo, "commonInfo", argi); + ir_oid (iea, p->type, "type", argi); + ir_InternationalString (iea, p->name, "name", argi); + ir_bool (iea, p->privateType, "privateType", argi); + ir_bool (iea, p->restrictionsApply, "restrictionsApply", argi); + ir_bool (iea, p->feeApply, "feeApply", argi); + ir_bool (iea, p->available, "available", argi); + ir_bool (iea, p->retentionSupported, "retentionSupported", argi); + + ir_choice (iea, waitActionArm, *p->waitAction, NULL, argi); + + ir_HumanString (iea, p->description, "description", argi); + ir_External (iea, p->specificExplain, "specificExplain", argi); + ir_InternationalString (iea, p->esASN, "esASN", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_AttributeDetails (IrExpArg *iea, + Z_AttributeDetails *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_CommonInfo (iea, p->commonInfo, "commonInfo", argi); + ir_DatabaseName (iea, p->databaseName, "databaseName", argi); + ir_sequence (ir_AttributeSetDetails, iea, p->attributesBySet, + p->num_attributesBySet, "attributesBySet", argi); + ir_AttributeCombinations (iea, p->attributeCombinations, + "attributeCombinations", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_AttributeSetDetails (IrExpArg *iea, + Z_AttributeSetDetails *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_oid (iea, p->attributeSet, "attributeSet", argi); + ir_sequence (ir_AttributeTypeDetails, iea, p->attributesByType, + p->num_attributesByType, "attributesByType", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_AttributeTypeDetails (IrExpArg *iea, + Z_AttributeTypeDetails *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_integer (iea, p->attributeType, "attributeType", argi); + ir_OmittedAttributeInterpretation (iea, p->optionalType, + "optionalType", argi); + ir_sequence (ir_AttributeValue, iea, p->attributeValues, + p->num_attributeValues, "attributeValues", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_OmittedAttributeInterpretation (IrExpArg *iea, + Z_OmittedAttributeInterpretation *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_StringOrNumeric (iea, p->defaultValue, "defaultValue", argi); + ir_HumanString (iea, p->defaultDescription, "defaultDescription", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_EScanInfo (IrExpArg *iea, + Z_EScanInfo *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_integer (iea, p->maxStepSize, "maxStepSize", argi); + ir_HumanString (iea, p->collatingSequence, "collatingSequence", argi); + ir_bool (iea, p->increasing, "increasing", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_TermListDetails (IrExpArg *iea, + Z_TermListDetails *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_CommonInfo (iea, p->commonInfo, "commonInfo", argi); + ir_InternationalString (iea, p->termListName, "termListName", argi); + ir_HumanString (iea, p->description, "description", argi); + ir_AttributeCombinations (iea, p->attributes, "attributes", argi); + + ir_EScanInfo (iea, p->scanInfo, "scanInfo", argi); + + ir_integer (iea, p->estNumberTerms, "estNumberTerms", argi); + ir_sequence (ir_Term, iea, p->sampleTerms, + p->num_sampleTerms, "sampleTerms", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_ElementSetDetails (IrExpArg *iea, + Z_ElementSetDetails *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_CommonInfo (iea, p->commonInfo, "commonInfo", argi); + ir_DatabaseName (iea, p->databaseName, "databaseName", argi); + ir_ElementSetName (iea, p->elementSetName, "elementSetName", argi); + ir_oid (iea, p->recordSyntax, "recordSyntax", argi); + ir_oid (iea, p->schema, "schema", argi); + ir_HumanString (iea, p->description, "description", argi); + ir_sequence (ir_PerElementDetails, iea, p->detailsPerElement, + p->num_detailsPerElement, "detailsPerElement", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_RetrievalRecordDetails (IrExpArg *iea, + Z_RetrievalRecordDetails *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_CommonInfo (iea, p->commonInfo, "commonInfo", argi); + ir_DatabaseName (iea, p->databaseName, "databaseName", argi); + ir_oid (iea, p->schema, "schema", argi); + ir_oid (iea, p->recordSyntax, "recordSyntax", argi); + ir_HumanString (iea, p->description, "description", argi); + ir_sequence (ir_PerElementDetails, iea, p->detailsPerElement, + p->num_detailsPerElement, "detailsPerElement", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_PerElementDetails (IrExpArg *iea, + Z_PerElementDetails *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_InternationalString (iea, p->name, "name", argi); + ir_RecordTag (iea, p->recordTag, "recordTag", argi); + ir_sequence (ir_Path, iea, p->schemaTags, + p->num_schemaTags, "schemaTags", argi); + ir_integer (iea, p->maxSize, "maxSize", argi); + ir_integer (iea, p->minSize, "minSize", argi); + ir_integer (iea, p->avgSize, "avgSize", argi); + ir_integer (iea, p->fixedSize, "fixedSize", argi); + ir_bool (iea, p->repeatable, "repeatable", argi); + ir_bool (iea, p->required, "required", argi); + ir_HumanString (iea, p->description, "description", argi); + ir_HumanString (iea, p->contents, "contents", argi); + ir_HumanString (iea, p->billingInfo, "billingInfo", argi); + ir_HumanString (iea, p->restrictions, "restrictions", argi); + ir_sequence (ir_InternationalString, iea, p->alternateNames, + p->num_alternateNames, "alternateNames", argi); + ir_sequence (ir_InternationalString, iea, p->genericNames, + p->num_genericNames, "genericNames", argi); + ir_AttributeCombinations (iea, p->searchAccess, "searchAccess", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_RecordTag (IrExpArg *iea, + Z_RecordTag *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_StringOrNumeric (iea, p->qualifier, "qualifier", argi); + ir_StringOrNumeric (iea, p->tagValue, "tagValue", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_SortDetails (IrExpArg *iea, + Z_SortDetails *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_CommonInfo (iea, p->commonInfo, "commonInfo", argi); + ir_DatabaseName (iea, p->databaseName, "databaseName", argi); + ir_sequence (ir_SortKeyDetails, iea, p->sortKeys, + p->num_sortKeys, "sortKeys", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_SortKeyDetailsSortType (IrExpArg *iea, + Z_SortKeyDetailsSortType *p, const char *name, int argi) +{ + static IrExpChoice sortArm [] = { + { "character", Z_SortKeyDetailsSortType_character, + ir_null }, + { "numeric", Z_SortKeyDetailsSortType_numeric, + ir_null }, + { "structured", Z_SortKeyDetailsSortType_structured, + ir_HumanString }, + { NULL, 0, NULL }}; + return ir_choice (iea, sortArm, p->which, p->u.character, argi); +} + +static int ir_SortKeyDetails (IrExpArg *iea, + Z_SortKeyDetails *p, const char *name, int argi) +{ + static IrExpChoice sortArm [] = { + { "always", Z_SortKeyDetails_always, + ir_choice_nop }, + { "never", Z_SortKeyDetails_never, + ir_choice_nop }, + { "defaultYes", Z_SortKeyDetails_defaultYes, + ir_choice_nop }, + { "defaultNo", Z_SortKeyDetails_defaultNo, + ir_choice_nop }, + { NULL, 0, NULL }}; + + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_HumanString (iea, p->description, "description", argi); + ir_sequence (ir_Specification, iea, p->elementSpecifications, + p->num_elementSpecifications, "elementSpecifications", argi); + ir_AttributeCombinations (iea, p->attributeSpecifications, + "attributeSpecifications", argi); + ir_SortKeyDetailsSortType (iea, p->sortType, "sortType", argi); + + if (p->caseSensitivity) + ir_choice (iea, sortArm, *p->caseSensitivity, NULL, argi); + + return ir_match_end (name, iea, argi); +} + +static int ir_ProcessingInformation (IrExpArg *iea, + Z_ProcessingInformation *p, const char *name, int argi) +{ + IrExpChoice arm[] = { + { "access", Z_ProcessingInformation_access, + ir_choice_nop }, + { "search", Z_ProcessingInformation_search, + ir_choice_nop }, + { "retrieval", Z_ProcessingInformation_retrieval, + ir_choice_nop }, + { "recordPresentation", Z_ProcessingInformation_recordPresentation, + ir_choice_nop }, + { "recordHandling", Z_ProcessingInformation_recordHandling, + ir_choice_nop }, + { NULL, 0, NULL }}; + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_CommonInfo (iea, p->commonInfo, "commonInfo", argi); + ir_DatabaseName (iea, p->databaseName, "databaseName", argi); + + ir_choice (iea, arm, *p->processingContext, NULL, argi); + ir_InternationalString (iea, p->name, "name", argi); + ir_oid (iea, p->oid, "oid", argi); + ir_HumanString (iea, p->description, "description", argi); + ir_External (iea, p->instructions, "instructions", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_VariantSetInfo (IrExpArg *iea, + Z_VariantSetInfo *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_CommonInfo (iea, p->commonInfo, "commonInfo", argi); + ir_oid (iea, p->variantSet, "variantSet", argi); + ir_InternationalString (iea, p->name, "name", argi); + ir_sequence (ir_VariantClass, iea, p->variants, + p->num_variants, "variants", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_VariantClass (IrExpArg *iea, + Z_VariantClass *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_InternationalString (iea, p->name, "name", argi); + ir_HumanString (iea, p->description, "description", argi); + ir_integer (iea, p->variantClass, "variantClass", argi); + ir_sequence (ir_VariantType, iea, p->variantTypes, + p->num_variantTypes, "variantTypes", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_VariantType (IrExpArg *iea, + Z_VariantType *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_InternationalString (iea, p->name, "name", argi); + ir_HumanString (iea, p->description, "description", argi); + ir_integer (iea, p->variantType, "variantType", argi); + ir_VariantValue (iea, p->variantValue, "variantValue", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_ValueSetEnumerated (IrExpArg *iea, + Z_ValueSetEnumerated *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_sequence (ir_ValueDescription, iea, p->enumerated, + p->num_enumerated, "enumerated", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_ValueSet (IrExpArg *iea, + Z_ValueSet *p, const char *name, int argi) +{ + IrExpChoice arm [] = { + { "range", Z_ValueSet_range, ir_ValueRange }, + { "enumerated", Z_ValueSet_enumerated, ir_ValueSetEnumerated }, + { NULL, 0, NULL }}; + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_choice (iea, arm, p->which, p->u.range, argi); + return ir_match_end (name, iea, argi); +} + +static int ir_VariantValue (IrExpArg *iea, + Z_VariantValue *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_PrimitiveDataType (iea, p->dataType, "dataType", argi); + if (p->values) + ir_ValueSet (iea, p->values, "values", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_ValueRange (IrExpArg *iea, + Z_ValueRange *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_ValueDescription (iea, p->lower, "lower", argi); + ir_ValueDescription (iea, p->upper, "upper", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_ValueDescription (IrExpArg *iea, + Z_ValueDescription *p, const char *name, int argi) +{ + static IrExpChoice arm [] = { + { "integer", Z_ValueDescription_integer, ir_integer }, + { "string", Z_ValueDescription_string, ir_InternationalString}, + { "octets", Z_ValueDescription_octets, ir_octet}, + { "oid", Z_ValueDescription_oid, ir_oid}, + { "unit", Z_ValueDescription_unit, ir_Unit}, + { "valueAndUnit", Z_ValueDescription_valueAndUnit, ir_IntUnit}, + { NULL, 0, NULL }}; + + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_choice (iea, arm, p->which, p->u.integer, argi); + return ir_match_end (name, iea, argi); +} + +static int ir_UnitInfo (IrExpArg *iea, + Z_UnitInfo *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_CommonInfo (iea, p->commonInfo, "commonInfo", argi); + ir_InternationalString (iea, p->unitSystem, "unitSystem", argi); + ir_HumanString (iea, p->description, "description", argi); + ir_sequence (ir_UnitType, iea, p->units, + p->num_units, "units", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_UnitType (IrExpArg *iea, + Z_UnitType *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_InternationalString (iea, p->name, "name", argi); + ir_HumanString (iea, p->description, "description", argi); + ir_StringOrNumeric (iea, p->unitType, "unitType", argi); + ir_sequence (ir_Units, iea, p->units, p->num_units, "units", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_Units (IrExpArg *iea, + Z_Units *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_InternationalString (iea, p->name, "name", argi); + ir_HumanString (iea, p->description, "description", argi); + ir_StringOrNumeric (iea, p->unit, "unit", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_CategoryList (IrExpArg *iea, + Z_CategoryList *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_CommonInfo (iea, p->commonInfo, "commonInfo", argi); + ir_sequence (ir_CategoryInfo, iea, p->categories, + p->num_categories, "categories", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_CategoryInfo (IrExpArg *iea, + Z_CategoryInfo *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_InternationalString (iea, p->category, "category", argi); + ir_InternationalString (iea, p->originalCategory, "originalCategory", argi); + ir_HumanString (iea, p->description, "description", argi); + ir_InternationalString (iea, p->asn1Module, "asn1Module", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_CommonInfo (IrExpArg *iea, + Z_CommonInfo *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_GeneralizedTime (iea, p->dateAdded, "dateAdded", argi); + ir_GeneralizedTime (iea, p->dateChanged, "dateChanged", argi); + ir_GeneralizedTime (iea, p->expiry, "expiry", argi); + ir_LanguageCode (iea, p->humanStringLanguage, "humanString-Language", + argi); + ir_OtherInformation (iea, p->otherInfo, "otherInfo", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_HumanStringUnit (IrExpArg *iea, + Z_HumanStringUnit *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_LanguageCode (iea, p->language, "language", argi); + ir_InternationalString (iea, p->text, "text", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_HumanString (IrExpArg *iea, + Z_HumanString *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_sequence (ir_HumanStringUnit, iea, p->strings, + p->num_strings, "strings", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_IconObjectUnit (IrExpArg *iea, + Z_IconObjectUnit *p, const char *name, int argi) +{ + static IrExpChoice arm [] = { + { "ianaType", Z_IconObject_ianaType, ir_choice_nop }, + { "z3950type", Z_IconObject_z3950type, ir_choice_nop }, + { "otherType", Z_IconObject_otherType, ir_choice_nop }, + { NULL, 0, NULL }}; + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_choice (iea, arm, p->which, NULL, argi); + ir_InternationalString (iea, p->bodyType, "bodyType", argi); + ir_octet (iea, p->content, "content", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_IconObject (IrExpArg *iea, + Z_IconObject *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_sequence (ir_IconObjectUnit, iea, p->iconUnits, + p->num_iconUnits, "iconUnits", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_ContactInfo (IrExpArg *iea, + Z_ContactInfo *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_InternationalString (iea, p->name, "name", argi); + ir_HumanString (iea, p->description, "description", argi); + ir_HumanString (iea, p->address, "address", argi); + ir_InternationalString (iea, p->email, "email", argi); + ir_InternationalString (iea, p->phone, "phone", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_NetworkAddressIA (IrExpArg *iea, + Z_NetworkAddressIA *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_InternationalString (iea, p->hostAddress, "hostAddress", argi); + ir_integer (iea, p->port, "port", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_NetworkAddressOPA (IrExpArg *iea, + Z_NetworkAddressOPA *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_InternationalString (iea, p->pSel, "pSel", argi); + ir_InternationalString (iea, p->sSel, "sSel", argi); + ir_InternationalString (iea, p->tSel, "tSel", argi); + ir_InternationalString (iea, p->nSap, "nSap", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_NetworkAddressOther (IrExpArg *iea, + Z_NetworkAddressOther *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_InternationalString (iea, p->type, "type", argi); + ir_InternationalString (iea, p->address, "address", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_NetworkAddress (IrExpArg *iea, + Z_NetworkAddress *p, const char *name, int argi) +{ + IrExpChoice arm [] = { + { "iA", Z_NetworkAddress_iA, ir_NetworkAddressIA }, + { "oPA", Z_NetworkAddress_oPA, ir_NetworkAddressOPA }, + { "other", Z_NetworkAddress_other, ir_NetworkAddressOther }, + { NULL, 0, NULL }}; + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_choice (iea, arm, p->which, p->u.internetAddress, argi); + return ir_match_end (name, iea, argi); +} + +static int ir_AccessInfo (IrExpArg *iea, + Z_AccessInfo *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_sequence (ir_QueryTypeDetails, iea, p->queryTypesSupported, + p->num_queryTypesSupported, "queryTypesSupported", argi); + ir_sequence (ir_oid, iea, p->diagnosticsSets, + p->num_diagnosticsSets, "diagnosticsSets", argi); + ir_sequence (ir_oid, iea, p->attributeSetIds, + p->num_attributeSetIds, "attributeSetIds", argi); + ir_sequence (ir_oid, iea, p->schemas, + p->num_schemas, "schemas", argi); + ir_sequence (ir_oid, iea, p->recordSyntaxes, + p->num_recordSyntaxes, "recordSyntaxes", argi); + ir_sequence (ir_oid, iea, p->resourceChallenges, + p->num_resourceChallenges, "resourceChallenges", argi); + ir_AccessRestrictions (iea, p->restrictedAccess, "restrictedAccess", argi); + ir_Costs (iea, p->costInfo, "costInfo", argi); + ir_sequence (ir_oid, iea, p->variantSets, + p->num_variantSets, "variantSets", argi); + ir_sequence (ir_ElementSetName, iea, p->elementSetNames, + p->num_elementSetNames, "elementSetNames", argi); + ir_sequence (ir_InternationalString, iea, p->unitSystems, + p->num_unitSystems, "unitSystems", argi); + return ir_match_end (name, iea, argi); +} + + +static int ir_QueryTypeDetails (IrExpArg *iea, + Z_QueryTypeDetails *p, const char *name, int argi) +{ + static IrExpChoice arm[] = { + { "private", Z_QueryTypeDetails_private, + ir_PrivateCapabilities }, + { "rpn", Z_QueryTypeDetails_rpn, + ir_RpnCapabilities }, + { "iso8777", Z_QueryTypeDetails_iso8777, + ir_Iso8777Capabilities }, + { "z3958", Z_QueryTypeDetails_z3958, + ir_HumanString }, + { "erpn", Z_QueryTypeDetails_erpn, + ir_RpnCapabilities }, + { "rankedList", Z_QueryTypeDetails_rankedList, + ir_HumanString }, + { NULL, 0, NULL }}; + + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_choice (iea, arm, p->which, p->u.private, argi); + return ir_match_end (name, iea, argi); +} + +static int ir_PrivateCapOperator (IrExpArg *iea, + Z_PrivateCapOperator *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_InternationalString (iea, p->roperator, "operator", argi); + ir_HumanString (iea, p->description, "description", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_PrivateCapabilities (IrExpArg *iea, + Z_PrivateCapabilities *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + + ir_sequence (ir_PrivateCapOperator, iea, p->operators, + p->num_operators, "operators", argi); + ir_sequence (ir_SearchKey, iea, p->searchKeys, + p->num_searchKeys, "searchKeys", argi); + ir_sequence (ir_HumanString, iea, p->description, + p->num_description, "description", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_RpnCapabilities (IrExpArg *iea, + Z_RpnCapabilities *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_sequence (ir_integer, iea, p->operators, + p->num_operators, "operators", argi); + ir_bool (iea, p->resultSetAsOperandSupported, + "resultSetAsOperandSupported", argi); + ir_bool (iea, p->restrictionOperandSupported, + "restrictionOperandSupported", argi); + ir_ProximitySupport (iea, p->proximity, "proximity", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_Iso8777Capabilities (IrExpArg *iea, + Z_Iso8777Capabilities *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_sequence (ir_SearchKey, iea, p->searchKeys, + p->num_searchKeys, "searchKeys", argi); + ir_HumanString (iea, p->restrictions, "restrictions", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_ProxSupportPrivate (IrExpArg *iea, + Z_ProxSupportPrivate *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_integer (iea, p->unit, "unit", argi); + ir_HumanString (iea, p->description, "description", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_ProxSupportUnit (IrExpArg *iea, + Z_ProxSupportUnit *p, const char *name, int argi) +{ + static IrExpChoice arm [] = { + { "known", Z_ProxSupportUnit_known, ir_integer }, + { "private", Z_ProxSupportUnit_private, ir_ProxSupportPrivate }, + { NULL, 0, NULL }}; + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_choice (iea, arm, p->which, p->u.private, argi); + return ir_match_end (name, iea, argi); +} + +static int ir_ProximitySupport (IrExpArg *iea, + Z_ProximitySupport *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_bool (iea, p->anySupport, "anySupport", argi); + ir_sequence (ir_ProxSupportUnit, iea, p->unitsSupported, + p->num_unitsSupported, "unitsSupported", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_SearchKey (IrExpArg *iea, + Z_SearchKey *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_InternationalString (iea, p->searchKey, "searchKey", argi); + ir_HumanString (iea, p->description, "description", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_AccessRestrictionsUnit (IrExpArg *iea, + Z_AccessRestrictionsUnit *p, const char *name, int argi) +{ + static IrExpChoice arm[] = { + { "any", Z_AccessRestrictions_any, + ir_choice_nop }, + { "search", Z_AccessRestrictions_search, + ir_choice_nop }, + { "present", Z_AccessRestrictions_present, + ir_choice_nop }, + { "specific-elements", Z_AccessRestrictions_specific_elements, + ir_choice_nop }, + { "extended-services", Z_AccessRestrictions_extended_services, + ir_choice_nop }, + { "by-database", Z_AccessRestrictions_by_database, + ir_choice_nop }, + { NULL, 0, NULL }}; + + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_choice (iea, arm, *p->accessType, NULL, argi); + ir_HumanString (iea, p->accessText, "accessText", argi); + ir_sequence (ir_oid, iea, p->accessChallenges, + p->num_accessChallenges, "accessChallenges", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_AccessRestrictions (IrExpArg *iea, + Z_AccessRestrictions *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_sequence (ir_AccessRestrictionsUnit, iea, p->restrictions, + p->num_restrictions, "restrictions", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_CostsOtherCharge (IrExpArg *iea, + Z_CostsOtherCharge *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_HumanString (iea, p->forWhat, "forWhat", argi); + ir_Charge (iea, p->charge, "charge", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_Costs (IrExpArg *iea, + Z_Costs *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_Charge (iea, p->connectCharge, "connectCharge", argi); + ir_Charge (iea, p->connectTime, "connectTime", argi); + ir_Charge (iea, p->displayCharge, "displayCharge", argi); + ir_Charge (iea, p->searchCharge, "searchCharge", argi); + ir_Charge (iea, p->subscriptCharge, "subscriptCharge", argi); + + ir_sequence (ir_CostsOtherCharge, iea, p->otherCharges, + p->num_otherCharges, "otherCharges", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_Charge (IrExpArg *iea, + Z_Charge *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_IntUnit (iea, p->cost, "cost", argi); + ir_Unit (iea, p->perWhat, "perWhat", argi); + ir_HumanString (iea, p->text, "text", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_DatabaseList (IrExpArg *iea, + Z_DatabaseList *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_sequence (ir_DatabaseName, iea, p->databases, + p->num_databases, "databases", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_AttributeCombinations (IrExpArg *iea, + Z_AttributeCombinations *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_oid (iea, p->defaultAttributeSet, "defaultAttributeSet", argi); + ir_sequence (ir_AttributeCombination, iea, p->legalCombinations, + p->num_legalCombinations, "legalCombinations", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_AttributeCombination (IrExpArg *iea, + Z_AttributeCombination *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_sequence (ir_AttributeOccurrence, iea, p->occurrences, + p->num_occurrences, "occurrences", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_AttributeValueList (IrExpArg *iea, + Z_AttributeValueList *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_sequence (ir_StringOrNumeric, iea, p->attributes, + p->num_attributes, "attributes", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_AttributeOccurrence (IrExpArg *iea, + Z_AttributeOccurrence *p, const char *name, int argi) +{ + static IrExpChoice arm [] = { + { "any-or-none", Z_AttributeOcc_anyOrNone, ir_null }, + { "specific", Z_AttributeOcc_specific, ir_AttributeValueList }, + { NULL, 0, NULL } }; + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_oid (iea, p->attributeSet, "attributeSet", argi); + ir_integer (iea, p->attributeType, "attributeType", argi); + ir_null (iea, p->mustBeSupplied, "mustBeSupplied", argi); + ir_choice (iea, arm, p->which, p->attributeValues->anyOrNone, argi); + return ir_match_end (name, iea, argi); +} + +static int ir_AttributeValue (IrExpArg *iea, + Z_AttributeValue *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_StringOrNumeric (iea, p->value, "value", argi); + ir_HumanString (iea, p->description, "description", argi); + ir_sequence (ir_StringOrNumeric, iea, p->subAttributes, + p->num_subAttributes, "subAttributes", argi); + ir_sequence (ir_StringOrNumeric, iea, p->superAttributes, + p->num_superAttributes, "superAttributes", argi); + ir_null (iea, p->partialSupport, "partialSupport", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_StringOrNumeric (IrExpArg *iea, + Z_StringOrNumeric *p, const char *name, int argi) +{ + IrExpChoice arm[] = { + { "string", Z_StringOrNumeric_string, ir_InternationalString }, + { "numeric", Z_StringOrNumeric_numeric, ir_integer }, + { NULL, 0, NULL }}; + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_choice (iea, arm, p->which, p->u.string, argi); + return ir_match_end (name, iea, argi); +} + +static int ir_ElementSpec (IrExpArg *iea, + Z_ElementSpec *p, const char *name, int argi) +{ + static IrExpChoice arm[] = { + { "elementSetName", Z_ElementSpec_elementSetName, + ir_InternationalString }, + { "externalSpec", Z_ElementSpec_externalSpec, + ir_External }, + { NULL, 0, NULL }}; + + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_choice (iea, arm, p->which, p->u.elementSetName, argi); + return ir_match_end (name, iea, argi); +} + +static int ir_Specification (IrExpArg *iea, + Z_Specification *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_oid (iea, p->schema, "schema", argi); + ir_ElementSpec (iea, p->elementSpec, "elementSpec", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_InfoCategory (IrExpArg *iea, + Z_InfoCategory *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_oid (iea, p->categoryTypeId, "categoryTypeId", argi); + ir_integer (iea, p->categoryValue, "categoryValue", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_OtherInformationUnit (IrExpArg *iea, + Z_OtherInformationUnit *p, const char *name, int argi) +{ + static IrExpChoice arm[] = { + { "characterInfo", Z_OtherInfo_characterInfo, + ir_InternationalString }, + { "binaryInfo", Z_OtherInfo_binaryInfo, + ir_octet}, + { "externallyDefinedInfo", Z_OtherInfo_externallyDefinedInfo, + ir_External}, + { "oid", Z_OtherInfo_oid, + ir_oid}, + { NULL, 0, NULL }}; + + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_InfoCategory (iea, p->category, "category", argi); + ir_choice (iea, arm, p->which, p->information.characterInfo, argi); + return ir_match_end (name, iea, argi); +} + +static int ir_OtherInformation (IrExpArg *iea, + Z_OtherInformation *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_sequence (ir_OtherInformationUnit, iea, p->list, + p->num_elements, "list", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_IntUnit (IrExpArg *iea, + Z_IntUnit *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_integer (iea, p->value, "value", argi); + ir_Unit (iea, p->unitUsed, "unitUsed", argi); + return ir_match_end (name, iea, argi); +} + +static int ir_Unit (IrExpArg *iea, + Z_Unit *p, const char *name, int argi) +{ + if (!ir_match_start (name, p, iea, ++argi)) + return TCL_OK; + ir_InternationalString (iea, p->unitSystem, "unitSystem", argi); + ir_StringOrNumeric (iea, p->unitType, "unitType", argi); + ir_StringOrNumeric (iea, p->unit, "unit", argi); + ir_integer (iea, p->scaleFactor, "scaleFactor", argi); + return ir_match_end (name, iea, argi); +} + +int ir_ExplainRecord (IrExpArg *iea, Z_ExplainRecord *p, int argi) +{ + static IrExpChoice arm[] = { + {"targetInfo", Z_Explain_targetInfo, + ir_TargetInfo}, + {"databaseInfo", Z_Explain_databaseInfo, + ir_DatabaseInfo}, + {"schemaInfo", Z_Explain_schemaInfo, + ir_SchemaInfo}, + {"tagSetInfo", Z_Explain_tagSetInfo, + ir_TagSetInfo}, + {"recordSyntaxInfo", Z_Explain_recordSyntaxInfo, + ir_RecordSyntaxInfo}, + {"attributeSetInfo", Z_Explain_attributeSetInfo, + ir_AttributeSetInfo}, + {"termListInfo", Z_Explain_termListInfo, + ir_TermListInfo}, + {"extendedServicesInfo", Z_Explain_extendedServicesInfo, + ir_ExtendedServicesInfo}, + {"attributeDetails", Z_Explain_attributeDetails, + ir_AttributeDetails}, + {"termListDetails", Z_Explain_termListDetails, + ir_TermListDetails}, + {"elementSetDetails", Z_Explain_elementSetDetails, + ir_ElementSetDetails}, + {"retrievalRecordDetails", Z_Explain_retrievalRecordDetails, + ir_RetrievalRecordDetails}, + {"sortDetails", Z_Explain_sortDetails, + ir_SortDetails}, + {"processing", Z_Explain_processing, + ir_ProcessingInformation}, + {"variants", Z_Explain_variants, + ir_VariantSetInfo}, + {"units", Z_Explain_units, + ir_UnitInfo}, + {"categoryList", Z_Explain_categoryList, + ir_CategoryList}, + {NULL, 0, NULL }}; + + + return ir_choice (iea, arm, p->which, p->u.targetInfo, argi); +} + +int ir_tcl_get_explain (Tcl_Interp *interp, Z_ExplainRecord *rec, + int argc, char **argv) +{ + IrExpArg iea; + + iea.argv = argv; + iea.argc = argc; + iea.interp = interp; + + return ir_ExplainRecord (&iea, rec, 2); +} diff --git a/grs.c b/grs.c index fc62ff9..f5e4d22 100644 --- a/grs.c +++ b/grs.c @@ -1,11 +1,14 @@ /* * IR toolkit for tcl/tk - * (c) Index Data 1995 + * (c) Index Data 1995-1996 * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * * $Log: grs.c,v $ - * Revision 1.8 1996-07-03 13:31:10 adam + * Revision 1.9 1996-08-16 15:07:44 adam + * First work on Explain. + * + * Revision 1.8 1996/07/03 13:31:10 adam * The xmalloc/xfree functions from YAZ are used to manage memory. * * Revision 1.7 1996/06/05 09:26:20 adam diff --git a/ir-tcl.c b/ir-tcl.c index 1271e6f..2db9f28 100644 --- a/ir-tcl.c +++ b/ir-tcl.c @@ -1,11 +1,14 @@ /* * IR toolkit for tcl/tk - * (c) Index Data 1995 + * (c) Index Data 1995-1996 * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * * $Log: ir-tcl.c,v $ - * Revision 1.92 1996-08-09 15:33:07 adam + * Revision 1.93 1996-08-16 15:07:45 adam + * First work on Explain. + * + * Revision 1.92 1996/08/09 15:33:07 adam * Modified the code to use tk4.1/tcl7.5 patch level 1. The time-driven * polling is no longer activated on Windows since asynchrounous I/O works * better. @@ -382,6 +385,7 @@ static void delete_IR_record (IrTcl_RecordList *rl) break; } xfree (rl->u.dbrec.buf); + rl->u.dbrec.buf = NULL; break; case Z_NamePlusRecord_surrogateDiagnostic: ir_deleteDiags (&rl->u.surrogateDiagnostics.list, @@ -2427,7 +2431,7 @@ static int do_getSutrs (void *o, Tcl_Interp *interp, int argc, char **argv) /* - * do_getGrs: Get a GRS1 Record + * do_getGrs: Get a GRS-1 Record */ static int do_getGrs (void *o, Tcl_Interp *interp, int argc, char **argv) { @@ -2462,6 +2466,54 @@ static int do_getGrs (void *o, Tcl_Interp *interp, int argc, char **argv) /* + * do_getExplain: Get an Explain Record + */ +static int do_getExplain (void *o, Tcl_Interp *interp, int argc, char **argv) +{ + IrTcl_SetObj *obj = o; + IrTcl_Obj *p = obj->parent; + void *rr; + Z_ext_typeent *etype; + int offset; + IrTcl_RecordList *rl; + + if (argc <= 0) + return TCL_OK; + if (argc < 3) + { + sprintf (interp->result, "wrong # args"); + return TCL_ERROR; + } + if (Tcl_GetInt (interp, argv[2], &offset)==TCL_ERROR) + return TCL_ERROR; + rl = find_IR_record (obj, offset); + if (!rl) + { + Tcl_AppendResult (interp, "No record at #", argv[2], NULL); + return TCL_ERROR; + } + if (rl->which != Z_NamePlusRecord_databaseRecord) + { + Tcl_AppendResult (interp, "No DB record at #", argv[2], NULL); + return TCL_ERROR; + } + if (rl->u.dbrec.type != VAL_EXPLAIN) + return TCL_OK; + + if (!(etype = z_ext_getentbyref (VAL_EXPLAIN))) + return TCL_OK; + + odr_setbuf (p->odr_in, rl->u.dbrec.buf, rl->u.dbrec.size, 0); + if (!(*etype->fun)(p->odr_in, &rr, 0)) + return TCL_OK; + + if (etype->what != Z_External_explainRecord) + return TCL_OK; + + return ir_tcl_get_explain (interp, rr, argc, argv); +} + +/* * do_responseStatus: Return response status (present or search) */ static int do_responseStatus (void *o, Tcl_Interp *interp, @@ -2637,6 +2689,7 @@ static IrTcl_Method ir_set_method_tab[] = { { "getMarc", do_getMarc, NULL}, { "getSutrs", do_getSutrs, NULL}, { "getGrs", do_getGrs, NULL}, + { "getExplain", do_getExplain, NULL}, { "recordType", do_recordType, NULL}, { "recordElements", do_recordElements, NULL}, { "diag", do_diag, NULL}, @@ -3215,7 +3268,7 @@ static void ir_deleteDiags (IrTcl_Diagnostic **dst_list, int *dst_num) } static void ir_handleDiags (IrTcl_Diagnostic **dst_list, int *dst_num, - Z_DiagRec **list, int num) + Z_DiagRec **list, int num) { int i; char *addinfo; @@ -3244,7 +3297,86 @@ static void ir_handleDiags (IrTcl_Diagnostic **dst_list, int *dst_num, } } -static void ir_handleRecords (void *o, Z_Records *zrs, IrTcl_SetObj *setobj, +static void ir_handleDBRecord (IrTcl_Obj *p, IrTcl_RecordList *rl, + Z_External *oe) +{ + struct oident *ident; + Z_ext_typeent *etype; + + rl->u.dbrec.size = oe->u.octet_aligned->len; + rl->u.dbrec.buf = NULL; + + if ((ident = oid_getentbyoid (oe->direct_reference))) + rl->u.dbrec.type = ident->value; + else + rl->u.dbrec.type = VAL_USMARC; + + if (ident && (oe->which == Z_External_single || + oe->which == Z_External_octet) + && (etype = z_ext_getentbyref (ident->value))) + { + void *rr; + + odr_setbuf (p->odr_in, (char*) oe->u.octet_aligned->buf, + oe->u.octet_aligned->len, 0); + if (!(*etype->fun)(p->odr_in, &rr, 0)) + return; + switch (etype->what) + { + case Z_External_sutrs: + logf (LOG_LOG, "Z_External_sutrs"); + oe->u.sutrs = rr; + if ((rl->u.dbrec.buf = ir_tcl_malloc (oe->u.sutrs->len+1))) + { + memcpy (rl->u.dbrec.buf, oe->u.sutrs->buf, + oe->u.sutrs->len); + rl->u.dbrec.buf[oe->u.sutrs->len] = '\0'; + } + rl->u.dbrec.size = oe->u.sutrs->len; + break; + case Z_External_grs1: + logf (LOG_LOG, "Z_External_grs1"); + oe->u.grs1 = rr; + ir_tcl_grs_mk (oe->u.grs1, &rl->u.dbrec.u.grs1); + break; + case Z_External_explainRecord: + logf (LOG_LOG, "Z_External_explainRecord"); + if ((rl->u.dbrec.buf = ir_tcl_malloc (rl->u.dbrec.size))) + { + memcpy (rl->u.dbrec.buf, oe->u.octet_aligned->buf, + rl->u.dbrec.size); + } + break; + } + } + else + { + if (oe->which == Z_External_octet && rl->u.dbrec.size > 0) + { + char *buf = (char*) oe->u.octet_aligned->buf; + if ((rl->u.dbrec.buf = ir_tcl_malloc (rl->u.dbrec.size))) + memcpy (rl->u.dbrec.buf, buf, rl->u.dbrec.size); + } + else if (rl->u.dbrec.type == VAL_SUTRS && + oe->which == Z_External_sutrs) + { + if ((rl->u.dbrec.buf = ir_tcl_malloc (oe->u.sutrs->len+1))) + { + memcpy (rl->u.dbrec.buf, oe->u.sutrs->buf, + oe->u.sutrs->len); + rl->u.dbrec.buf[oe->u.sutrs->len] = '\0'; + } + rl->u.dbrec.size = oe->u.sutrs->len; + } + else if (rl->u.dbrec.type == VAL_GRS1 && + oe->which == Z_External_grs1) + { + ir_tcl_grs_mk (oe->u.grs1, &rl->u.dbrec.u.grs1); + } + } +} + +static void ir_handleZRecords (void *o, Z_Records *zrs, IrTcl_SetObj *setobj, const char *elements) { IrTcl_Obj *p = o; @@ -3262,64 +3394,21 @@ static void ir_handleRecords (void *o, Z_Records *zrs, IrTcl_SetObj *setobj, setobj->numberOfRecordsReturned = zrs->u.databaseOrSurDiagnostics->num_records; logf (LOG_DEBUG, "Got %d records", setobj->numberOfRecordsReturned); - for (offset = 0; offsetnumberOfRecordsReturned; offset++) + for (offset = 0; offset < setobj->numberOfRecordsReturned; offset++) { - rl = new_IR_record (setobj, setobj->start + offset, - zrs->u.databaseOrSurDiagnostics-> - records[offset]->which, + Z_NamePlusRecord *znpr = zrs->u.databaseOrSurDiagnostics-> + records[offset]; + + rl = new_IR_record (setobj, setobj->start + offset, znpr->which, elements); if (rl->which == Z_NamePlusRecord_surrogateDiagnostic) - { ir_handleDiags (&rl->u.surrogateDiagnostics.list, &rl->u.surrogateDiagnostics.num, - &zrs->u.databaseOrSurDiagnostics-> - records[offset]->u.surrogateDiagnostic, + &znpr->u.surrogateDiagnostic, 1); - } else - { - Z_DatabaseRecord *zr; - Z_External *oe; - struct oident *ident; - - zr = zrs->u.databaseOrSurDiagnostics->records[offset] - ->u.databaseRecord; - oe = (Z_External*) zr; - rl->u.dbrec.size = zr->u.octet_aligned->len; - - if ((ident = oid_getentbyoid (oe->direct_reference))) - rl->u.dbrec.type = ident->value; - else - rl->u.dbrec.type = VAL_USMARC; - - if (oe->which == ODR_EXTERNAL_octet && rl->u.dbrec.size > 0) - { - char *buf = (char*) zr->u.octet_aligned->buf; - if ((rl->u.dbrec.buf = ir_tcl_malloc (rl->u.dbrec.size))) - memcpy (rl->u.dbrec.buf, buf, rl->u.dbrec.size); - } - else if (rl->u.dbrec.type == VAL_SUTRS && - oe->which == Z_External_sutrs) - { - odr_setbuf (p->odr_in, (char*) oe->u.single_ASN1_type->buf, - oe->u.single_ASN1_type->len, 0); - if ((rl->u.dbrec.buf = ir_tcl_malloc (oe->u.sutrs->len+1))) - { - memcpy (rl->u.dbrec.buf, oe->u.sutrs->buf, - oe->u.sutrs->len); - rl->u.dbrec.buf[oe->u.sutrs->len] = '\0'; - } - rl->u.dbrec.size = oe->u.sutrs->len; - } - else if (rl->u.dbrec.type == VAL_GRS1 && - oe->which == Z_External_grs1) - { - ir_tcl_grs_mk (oe->u.grs1, &rl->u.dbrec.u.grs1); - rl->u.dbrec.buf = NULL; - } - else - rl->u.dbrec.buf = NULL; - } + ir_handleDBRecord (p, rl, + (Z_External*) (znpr->u.databaseRecord)); } } else if (zrs->which == Z_Records_multipleNSD) @@ -3371,7 +3460,7 @@ static void ir_searchResponse (void *o, Z_SearchResponse *searchrs, es = setobj->set_inher.smallSetElementSetNames; else es = setobj->set_inher.mediumSetElementSetNames; - ir_handleRecords (o, zrs, setobj, es); + ir_handleZRecords (o, zrs, setobj, es); } else setobj->recordFlag = 0; @@ -3393,7 +3482,7 @@ static void ir_presentResponse (void *o, Z_PresentResponse *presrs, get_referenceId (&setobj->set_inher.referenceId, presrs->referenceId); setobj->nextResultSetPosition = *presrs->nextResultSetPosition; if (zrs) - ir_handleRecords (o, zrs, setobj, setobj->set_inher.elementSetNames); + ir_handleZRecords (o, zrs, setobj, setobj->set_inher.elementSetNames); else { setobj->recordFlag = 0; diff --git a/ir-tclp.h b/ir-tclp.h index be0d39a..06c9150 100644 --- a/ir-tclp.h +++ b/ir-tclp.h @@ -5,7 +5,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: ir-tclp.h,v $ - * Revision 1.33 1996-07-03 13:31:13 adam + * Revision 1.34 1996-08-16 15:07:47 adam + * First work on Explain. + * + * Revision 1.33 1996/07/03 13:31:13 adam * The xmalloc/xfree functions from YAZ are used to manage memory. * * Revision 1.32 1996/03/20 13:54:05 adam @@ -380,6 +383,9 @@ void ir_tcl_grs_del (IrTcl_GRS_Record **grs_record); int ir_tcl_get_grs (Tcl_Interp *interp, IrTcl_GRS_Record *grs_record, int argc, char **argv); +int ir_tcl_get_explain (Tcl_Interp *interp, Z_ExplainRecord *rec, + int argc, char **argv); + int ir_tcl_method (Tcl_Interp *interp, int argc, char **argv, IrTcl_Methods *tab, int *ret); int ir_tcl_get_set_int (int *val, Tcl_Interp *interp, int argc, char **argv); -- 1.7.10.4