New sub directory zutil. Moved YAZ Compiler to be part of YAZ tree.
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 8 Jun 1999 10:10:15 +0000 (10:10 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 8 Jun 1999 10:10:15 +0000 (10:10 +0000)
32 files changed:
Makefile.in
asn/Makefile.in
asn/diagbib1.c [deleted file]
asn/prt-ext.c [deleted file]
asn/zget.c [deleted file]
client/Makefile.in
configure
configure.in
lib/Makefile.in
util/Makefile.in
util/logrpn.c [deleted file]
util/matchstr.c [new file with mode: 0644]
util/otherinfo.c [deleted file]
util/pquery.c [deleted file]
util/query.c [deleted file]
util/yaz-ccl.c [deleted file]
util/yaz-util.c [deleted file]
util/yc.tcl [new file with mode: 0755]
z39.50/Makefile.in [new file with mode: 0644]
z39.50/datetime.asn [new file with mode: 0644]
z39.50/esupdate.asn [new file with mode: 0644]
z39.50/univres.asn [new file with mode: 0644]
z39.50/z.tcl [new file with mode: 0644]
z39.50/z3950v3.asn [new file with mode: 0644]
ztest/Makefile.in
zutil/diagbib1.c [new file with mode: 0644]
zutil/logrpn.c [new file with mode: 0644]
zutil/otherinfo.c [new file with mode: 0644]
zutil/pquery.c [new file with mode: 0644]
zutil/prt-ext.c [new file with mode: 0644]
zutil/query.c [new file with mode: 0644]
zutil/zget.c [new file with mode: 0644]

index c1074e3..bd2c11b 100644 (file)
@@ -1,7 +1,7 @@
 # Copyright (C) 1995-1999, Index Data 
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
 # Copyright (C) 1995-1999, Index Data 
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile.in,v 1.7 1999-04-28 15:17:01 adam Exp $
+# $Id: Makefile.in,v 1.8 1999-06-08 10:10:15 adam Exp $
 
 # Uncomment the lines below to enable mOSI communcation.
 #CDEFS=-DUSE_XTIMOSI
 
 # Uncomment the lines below to enable mOSI communcation.
 #CDEFS=-DUSE_XTIMOSI
@@ -22,7 +22,7 @@ CC=@CC@
 CPP=@CPP@
 SHELL=/bin/sh
 MAKE=make
 CPP=@CPP@
 SHELL=/bin/sh
 MAKE=make
-SUBDIR=$(MOD) util odr $(RFC1006) ccl comstack retrieval client server ztest lib
+SUBDIR=$(MOD) util odr zutil $(RFC1006) ccl comstack retrieval client server ztest lib
 # Add external libraries to the LIBS macro
 LIBS=@LIBS@
 
 # Add external libraries to the LIBS macro
 LIBS=@LIBS@
 
index ca9e822..61baa3e 100644 (file)
@@ -1,7 +1,7 @@
-# Copyright (C) 1995-1998, Index Data I/S 
+# Copyright (C) 1995-1999, Index Data 
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile.in,v 1.3 1998-10-28 15:10:02 adam Exp $
+# $Id: Makefile.in,v 1.4 1999-06-08 10:10:16 adam Exp $
 
 SHELL=/bin/sh
 
 
 SHELL=/bin/sh
 
@@ -17,9 +17,8 @@ LIBINCLUDE=-L$(LIBDIR)
 
 DEFS=$(INCLUDE) $(CDEFS)
 LIB=$(LIBDIR)/libasn.a
 
 DEFS=$(INCLUDE) $(CDEFS)
 LIB=$(LIBDIR)/libasn.a
-PO = proto.o diagbib1.o zget.o prt-rsc.o prt-acc.o prt-exp.o prt-ext.o \
-       prt-grs.o prt-exd.o prt-dia.o prt-esp.o prt-arc.o prt-add.o \
-       prt-dat.o prt-univ.o
+PO = proto.o prt-rsc.o prt-acc.o prt-exp.o prt-grs.o prt-exd.o \
+       prt-dia.o prt-esp.o prt-arc.o prt-add.o prt-dat.o prt-univ.o
 all: $(LIB)
 
 alll:
 all: $(LIB)
 
 alll:
diff --git a/asn/diagbib1.c b/asn/diagbib1.c
deleted file mode 100644 (file)
index 1d0e5b8..0000000
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright (c) 1995-1997, Index Data
- * See the file LICENSE for details.
- * Sebastian Hammer, Adam Dickmeiss
- *
- * $Log: diagbib1.c,v $
- * Revision 1.7  1997-09-29 07:22:26  adam
- * Added static modifier to msg_tab.
- *
- * Revision 1.6  1997/07/01 14:15:10  adam
- * Added new BIB-1 diagnostic messages.
- *
- * Revision 1.5  1996/01/02 13:57:30  adam
- * Added error messages.
- *
- * Revision 1.4  1995/09/29  17:11:52  quinn
- * Smallish
- *
- * Revision 1.3  1995/09/27  15:02:39  quinn
- * Modified function heads & prototypes.
- *
- * Revision 1.2  1995/05/16  08:50:21  quinn
- * License, documentation, and memory fixes
- *
- * Revision 1.1  1995/03/15  13:46:09  adam
- * New function diagbib1_str.
- *
- */
-
-#include <stdio.h>
-
-#include "diagbib1.h"
-
-static struct {
-    int code;
-    char *msg;
-} msg_tab[] = {
-{ 1, "Permanent system error" },
-{ 2, "Temporary system error" },
-{ 3, "Unsupported search" },
-{ 4, "Terms only exclusion (stop) words" },
-{ 5, "Too many argument words" },
-{ 6, "Too many boolean operators" },
-{ 7, "Too many truncated words" },
-{ 8, "Too many incomplete subfields" },
-{ 9, "Truncated words too short" },
-{ 10, "Invalid format for record number (search term)" },
-{ 11, "Too many characters in search statement" },
-{ 12, "Too many records retrieved" },
-{ 13, "Present request out of range" },
-{ 14, "System error in presenting records" },
-{ 15, "Record no authorized to be sent intersystem" },
-{ 16, "Record exceeds Preferred-message-size" },
-{ 17, "Record exceeds Maximum-record-size" },
-{ 18, "Result set not supported as a search term" },
-{ 19, "Only single result set as search term supported" },
-{ 20, "Only ANDing of a single result set as search term supported" },
-{ 21, "Result set exists and replace indicator off" },
-{ 22, "Result set naming not supported" },
-{ 23, "Combination of specified databases not supported" },
-{ 24, "Element set names not supported" },
-{ 25, "Specified element set name not valid for specified database" },
-{ 26, "Only a single element set name supported" },
-{ 27, "Result set no longer exists - unilaterally deleted by target" },
-{ 28, "Result set is in use" },
-{ 29, "One of the specified databases is locked" },
-{ 30, "Specified result set does not exist" },
-{ 31, "Resources exhausted - no results available" },
-{ 32, "Resources exhausted - unpredictable partial results available" },
-{ 33, "Resources exhausted - valid subset of results available" },
-{ 100, "Unspecified error" },
-{ 101, "Access-control failure" },
-{ 102, "Security challenge required but could not be issued -"
-" request terminated" },
-{ 103, "Security challenge required but could not be issued -"
-" record not included" },
-{ 104, "Security challenge failed - record not included" },
-{ 105, "Terminated by negative continue response" },
-{ 106, "No abstract syntaxes agreed to for this record" },
-{ 107, "Query type not supported" },
-{ 108, "Malformed query" },
-{ 109, "Database unavailable" },
-{ 110, "Operator unsupported" },
-{ 111, "Too many databases specified" },
-{ 112, "Too many result sets created" },
-{ 113, "Unsupported attribute type" },
-{ 114, "Unsupported Use attribute" },
-{ 115, "Unsupported value for Use attribute" },
-{ 116, "Use attribute required but not supplied" },
-{ 117, "Unsupported Relation attribute" },
-{ 118, "Unsupported Structure attribute" },
-{ 119, "Unsupported Position attribute" },
-{ 120, "Unsupported Truncation attribute" },
-{ 121, "Unsupported Attribute Set" },
-{ 122, "Unsupported Completeness attribute" },
-{ 123, "Unsupported attribute combination" },
-{ 124, "Unsupported coded value for term" },
-{ 125, "Malformed search term" },
-{ 126, "Illegal term value for attribute" },
-{ 127, "Unparsable format for un-normalized value" },
-{ 128, "Illegal result set name" },
-{ 129, "Proximity search of sets not supported" },
-{ 130, "Illegal result set in proximity search" },
-{ 131, "Unsupported proximity relation" },
-{ 132, "Unsupported proximity unit code" },
-{ 201, "Proximity not supported with this attribute combination" },
-{ 202, "Unsupported distance for proximity" },
-{ 203, "Ordered flag not supported for proximity" },
-{ 205, "Only zero step size supported for Scan" },
-{ 206, "Specified step size not supported for Scan" },
-{ 207, "Cannot sort according to sequence" },
-{ 208, "No result set name supplied on Sort" },
-{ 209, "Generic sort not supported (database-specific sort only supported)" },
-{ 210, "Database specific sort not supported" },
-{ 211, "Too many sort keys" },
-{ 212, "Duplicate sort keys" },
-{ 213, "Unsupported missing data action" },
-{ 214, "Illegal sort relation" },
-{ 215, "Illegal case value" },
-{ 216, "Illegal missing data action" },
-{ 217, "Segmentation: Cannot guarantee records will fit in specified segments"
-},
-{ 218, "ES: Package name already in use" },
-{ 219, "ES: no such package, on modify/delete" },
-{ 220, "ES: quota exceeded" },
-{ 221, "ES: extended service type not supported" },
-{ 222, "ES: permission denied on ES - id not authorized" },
-{ 223, "ES: permission denied on ES - cannot modify or delete" },
-{ 224, "ES: immediate execution failed" },
-{ 225, "ES: immediate execution not supported for this service" },
-{ 226, "ES: immediate execution not supported for these parameters" },
-{ 227, "No data available in requested record syntax" },
-{ 228, "Scan: malformed scan" },
-{ 229, "Term type not supported" },
-{ 230, "Sort: too many input results" },
-{ 231, "Sort: incompatible record formats" },
-{ 232, "Scan: term list not supported" },
-{ 233, "Scan: unsupported value of position-in-response" },
-{ 234, "Too many index terms processed" },
-{ 235, "Database does not exist" },
-{ 236, "Access to specified database denied" },
-{ 237, "Sort: illegal sort" },
-{ 238, "Record not available in requested syntax" },
-{ 239, "Record syntax not supported" },
-{ 240, "Scan: Resources exhausted looking for satisfying terms" },
-{ 241, "Scan: Beginning or end of term list" },
-{ 242, "Segmentation: max-segment-size too small to segment record" },
-{ 243, "Present:  additional-ranges parameter not supported" },
-{ 244, "Present:  comp-spec parameter not supported" },
-{ 245, "Type-1 query: restriction ('resultAttr') operand not supported" },
-{ 246, "Type-1 query: 'complex' attributeValue not supported" },
-{ 247, "Type-1 query: 'attributeSet' as part of AttributeElement not supported" },
-{ 1001, "Malformed APDU"}, 
-{ 1002, "ES: EXTERNAL form of Item Order request not supported" },
-{ 1003, "ES: Result set item form of Item Order request not supported" },
-{ 1004, "ES: Extended services not supported unless access control is in effect" },
-{ 1005, "Response records in Search response not supported" },
-{ 1006, "Response records in Search response not possible for specified database (or database combination)" },
-{ 1007, "No Explain server. Addinfo: pointers to servers that have a surrogate Explain database for this server" },
-{ 1008, "ES: missing mandatory parameter for specified function. Addinfo: parameter" },
-{ 1009, "ES: Item Order, unsupported OID in itemRequest. Addinfo: OID" },
-{ 1010, "Init/AC: Bad Userid" },
-{ 1011, "Init/AC: Bad Userid and/or Password" },
-{ 1012, "Init/AC: No searches remaining (pre-purchased searches exhausted)" },
-{ 1013, "Init/AC: Incorrect interface type (specified id valid only when used with a particular access method or client)" },
-{ 1014, "Init/AC: Authentication System error" },
-{ 1015, "Init/AC: Maximum number of simultaneous sessions for Userid" },
-{ 1016, "Init/AC: Blocked network address"},
-{ 1017, "Init/AC: No databases available for specified userId"},
-{ 1018, "Init/AC: System temporarily out of resources"},
-{ 1019, "Init/AC: System not available due to maintenance (Addinfo: when it's expected back up)" },
-{ 1020, "Init/AC: System temporarily unavailable (Addinfo: when it's expected back up)"},
-{ 1021, "Init/AC: Account has expired"},
-{ 1022, "Init/AC: Password has expired so a new one must be supplied"},
-{ 1023, "Init/AC: Password has been changed by an administrator so a new one must be supplied"},
-{ 0, NULL} 
-};
-
-const char *diagbib1_str (int code)
-{
-    int i;
-    for (i=0; msg_tab[i].msg; i++)
-        if (msg_tab[i].code == code)
-            return msg_tab[i].msg;
-    return "Unknown error";
-}
diff --git a/asn/prt-ext.c b/asn/prt-ext.c
deleted file mode 100644 (file)
index 33095a4..0000000
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * Copyright (c) 1995-1999, Index Data.
- * See the file LICENSE for details.
- * Sebastian Hammer, Adam Dickmeiss
- *
- * $Log: prt-ext.c,v $
- * Revision 1.22  1999-05-26 15:24:26  adam
- * Fixed minor bugs regarding DB Update (introduced by previous commit).
- *
- * Revision 1.21  1999/05/26 14:47:12  adam
- * Implemented z_ext_record.
- *
- * Revision 1.20  1999/04/20 09:56:48  adam
- * Added 'name' paramter to encoder/decoder routines (typedef Odr_fun).
- * Modified all encoders/decoders to reflect this change.
- *
- * 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.
- *
- * Revision 1.17  1998/03/20 14:46:06  adam
- * Added UNIverse Resource Reports.
- *
- * Revision 1.16  1998/02/11 11:53:32  adam
- * Changed code so that it compiles as C++.
- *
- * Revision 1.15  1998/02/10 15:31:46  adam
- * Implemented date and time structure. Changed the Update Extended
- * Service.
- *
- * Revision 1.14  1998/01/05 09:04:57  adam
- * Fixed bugs in encoders/decoders - Not operator (!) missing.
- *
- * Revision 1.13  1997/05/14 06:53:22  adam
- * C++ support.
- *
- * Revision 1.12  1997/04/30 08:52:02  quinn
- * Null
- *
- * Revision 1.11  1996/10/10  12:35:13  quinn
- * Added Update extended service.
- *
- * Revision 1.10  1996/10/09  15:54:55  quinn
- * Added SearchInfoReport
- *
- * Revision 1.9  1996/06/10  08:53:36  quinn
- * Added Summary,OPAC,ResourceReport
- *
- * Revision 1.8  1996/02/20  12:51:44  quinn
- * Completed SCAN. Fixed problems with EXTERNAL.
- *
- * Revision 1.7  1995/10/12  10:34:38  quinn
- * Added Espec-1.
- *
- * Revision 1.6  1995/09/29  17:11:55  quinn
- * Smallish
- *
- * Revision 1.5  1995/09/27  15:02:42  quinn
- * Modified function heads & prototypes.
- *
- * Revision 1.4  1995/08/29  11:17:16  quinn
- * *** empty log message ***
- *
- * Revision 1.3  1995/08/21  09:10:18  quinn
- * Smallish fixes to suppport new formats.
- *
- * Revision 1.2  1995/08/17  12:45:00  quinn
- * Fixed minor problems with GRS-1. Added support in c&s.
- *
- * Revision 1.1  1995/08/15  13:37:41  quinn
- * Improved EXTERNAL
- *
- *
- */
-
-#include <proto.h>
-
-/*
- * The table below should be moved to the ODR structure itself and
- * be an image of the association context: To help
- * map indirect references when they show up. 
- */
-static Z_ext_typeent type_table[] =
-{
-    {VAL_SUTRS, Z_External_sutrs, (Odr_fun) z_SUTRS},
-    {VAL_EXPLAIN, Z_External_explainRecord, (Odr_fun)z_ExplainRecord},
-    {VAL_RESOURCE1, Z_External_resourceReport1, (Odr_fun)z_ResourceReport1},
-    {VAL_RESOURCE2, Z_External_resourceReport2, (Odr_fun)z_ResourceReport2},
-    {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},
-    {VAL_OPAC, Z_External_OPAC, (Odr_fun)z_OPACRecord},
-    {VAL_SEARCHRES1, Z_External_searchResult1, (Odr_fun)z_SearchInfoReport},
-    {VAL_DBUPDATE, Z_External_update, (Odr_fun)z_IUUpdate},
-    {VAL_DATETIME, Z_External_dateTime, (Odr_fun)z_DateTime},
-    {VAL_UNIVERSE_REPORT, Z_External_universeReport, (Odr_fun)z_UniverseReport},
-    {VAL_NONE, 0, 0}
-};
-
-Z_ext_typeent *z_ext_getentbyref(oid_value val)
-{
-    Z_ext_typeent *i;
-
-    for (i = type_table; i->dref != VAL_NONE; i++)
-       if (i->dref == val)
-           return i;
-    return 0;
-}
-
-int z_External(ODR o, Z_External **p, int opt, const char *name)
-{
-    oident *oid;
-    Z_ext_typeent *type;
-
-    static Odr_arm arm[] =
-    {
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_single,
-        (Odr_fun)odr_any, 0},
-       {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_External_octet,
-        (Odr_fun)odr_octetstring, 0},
-       {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_External_arbitrary,
-        (Odr_fun)odr_bitstring, 0},
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_sutrs,
-        (Odr_fun)z_SUTRS, 0},
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_explainRecord,
-        (Odr_fun)z_ExplainRecord, 0},
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_resourceReport1,
-        (Odr_fun)z_ResourceReport1, 0},
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_resourceReport2,
-        (Odr_fun)z_ResourceReport2, 0},
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_promptObject1,
-        (Odr_fun)z_PromptObject1, 0},
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_grs1,
-        (Odr_fun)z_GenericRecord, 0},
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_extendedService,
-        (Odr_fun)z_TaskPackage, 0},
-#ifdef ASN_COMPILED
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_itemOrder,
-        (Odr_fun)z_IOItemOrder, 0},
-#else
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_itemOrder,
-        (Odr_fun)z_ItemOrder, 0},
-#endif
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_diag1,
-        (Odr_fun)z_DiagnosticFormat, 0},
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_espec1,
-        (Odr_fun)z_Espec1, 0},
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_summary,
-        (Odr_fun)z_BriefBib, 0},
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_OPAC,
-        (Odr_fun)z_OPACRecord, 0},
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_searchResult1,
-        (Odr_fun)z_SearchInfoReport, 0},
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_update,
-        (Odr_fun)z_IUUpdate, 0},
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_dateTime,
-        (Odr_fun)z_DateTime, 0},
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_universeReport,
-        (Odr_fun)z_UniverseReport, 0},
-       {-1, -1, -1, -1, 0, 0}
-    };
-    
-    odr_implicit_settag(o, ODR_UNIVERSAL, ODR_EXTERNAL);
-    if (!odr_sequence_begin(o, p, sizeof(**p), name))
-       return opt && odr_ok(o);
-    if (!(odr_oid(o, &(*p)->direct_reference, 1, 0) &&
-         odr_integer(o, &(*p)->indirect_reference, 1, 0) &&
-         odr_graphicstring(o, &(*p)->descriptor, 1, 0)))
-       return 0;
-    /*
-     * Do we know this beast?
-     */
-    if (o->direction == ODR_DECODE && (*p)->direct_reference &&
-       (oid = oid_getentbyoid((*p)->direct_reference)) &&
-       (type = z_ext_getentbyref(oid->value)))
-    {
-       int zclass, tag, cons;
-       
-       /*
-        * We know it. If it's represented as an ASN.1 type, bias the CHOICE.
-        */
-       if (!odr_peektag(o, &zclass, &tag, &cons))
-           return opt && odr_ok(o);
-       if (zclass == ODR_CONTEXT && tag == 0 && cons == 1)
-           odr_choice_bias(o, type->what);
-    }
-    return
-       odr_choice(o, arm, &(*p)->u, &(*p)->which, name) &&
-       odr_sequence_end(o);
-}
-
-Z_External *z_ext_record(ODR o, int format, const char *buf, int len)
-{
-    Z_External *thisext;
-    oident recform;
-    int oid[OID_SIZE];
-
-    thisext = (Z_External *) odr_malloc(o, sizeof(*thisext));
-    thisext->descriptor = 0;
-    thisext->indirect_reference = 0;
-
-    recform.proto = PROTO_Z3950;
-    recform.oclass = CLASS_RECSYN;
-    recform.value = (enum oid_value) format;
-    if (!oid_ent_to_oid(&recform, oid))
-       return 0;
-    thisext->direct_reference = odr_oiddup(o, oid);
-    
-    if (len < 0) /* Structured data */
-    {
-       switch (format)
-       {
-       case VAL_SUTRS:
-           thisext->which = Z_External_sutrs;
-           break;
-       case VAL_GRS1:
-           thisext->which = Z_External_grs1;
-           break;
-       case VAL_EXPLAIN:
-           thisext->which = Z_External_explainRecord;
-           break;
-       case VAL_SUMMARY:
-           thisext->which = Z_External_summary;
-           break;
-       case VAL_OPAC:
-           thisext->which = Z_External_OPAC;
-           break;
-       default:
-           return 0;
-       }
-       
-       /*
-        * We cheat on the pointers here. Obviously, the record field
-        * of the backend-fetch structure should have been a union for
-        * correctness, but we're stuck with this for backwards
-        * compatibility.
-        */
-       thisext->u.grs1 = (Z_GenericRecord*) buf;
-    }
-    else if (format == VAL_SUTRS) /* SUTRS is a single-ASN.1-type */
-    {
-       Odr_oct *sutrs = (Odr_oct *)odr_malloc(o, sizeof(*sutrs));
-       
-       thisext->which = Z_External_sutrs;
-       thisext->u.sutrs = sutrs;
-       sutrs->buf = (unsigned char *)odr_malloc(o, len);
-       sutrs->len = sutrs->size = len;
-       memcpy(sutrs->buf, buf, len);
-    }
-    else
-    {
-       thisext->which = Z_External_octet;
-       if (!(thisext->u.octet_aligned = (Odr_oct *)
-             odr_malloc(o, sizeof(Odr_oct))))
-           return 0;
-       if (!(thisext->u.octet_aligned->buf = (unsigned char *)
-             odr_malloc(o, len)))
-           return 0;
-       memcpy(thisext->u.octet_aligned->buf, buf, len);
-       thisext->u.octet_aligned->len = thisext->u.octet_aligned->size = len;
-    }
-    return thisext;
-}
-
diff --git a/asn/zget.c b/asn/zget.c
deleted file mode 100644 (file)
index f4d27a4..0000000
+++ /dev/null
@@ -1,522 +0,0 @@
-/*
- * Copyright (c) 1995-1999, Index Data.
- * See the file LICENSE for details.
- * Sebastian Hammer, Adam Dickmeiss
- *
- * $Log: zget.c,v $
- * Revision 1.17  1999-04-20 09:56:48  adam
- * Added 'name' paramter to encoder/decoder routines (typedef Odr_fun).
- * Modified all encoders/decoders to reflect this change.
- *
- * Revision 1.16  1998/08/19 16:10:05  adam
- * Changed som member names of DeleteResultSetRequest/Response.
- *
- * 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
- * Function zget_presentRequest fills resultSetId with "default" instead
- * of "Default".
- *
- * Revision 1.12  1997/10/29 12:00:37  adam
- * Routine zget_SearchRequest fills resultSetName member with "default"
- * instead of "Default".
- *
- * Revision 1.11  1997/05/02 08:39:10  quinn
- * New PDUs added, thanks to Ronald van der Meer
- *
- * Revision 1.10  1996/01/02 08:57:23  quinn
- * Changed enums in the ASN.1 .h files to #defines. Changed oident.class to oclass
- *
- * Revision 1.9  1995/09/29  17:11:55  quinn
- * Smallish
- *
- * Revision 1.8  1995/09/27  15:02:43  quinn
- * Modified function heads & prototypes.
- *
- * Revision 1.7  1995/06/15  07:44:52  quinn
- * Moving to v3.
- *
- * Revision 1.6  1995/06/14  15:26:37  quinn
- * *** empty log message ***
- *
- * Revision 1.5  1995/06/07  14:42:30  quinn
- * Fixed CLOSE
- *
- * Revision 1.4  1995/06/07  14:36:25  quinn
- * Added CLOSE
- *
- * Revision 1.3  1995/06/05  10:52:06  quinn
- * Fixed some negligences.
- *
- * Revision 1.2  1995/05/30  10:15:49  quinn
- * Added our implementor's ID
- *
- * Revision 1.1  1995/05/22  11:30:20  quinn
- * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
- *
- *
- */
-
-#include <proto.h>
-
-Z_InitRequest *zget_InitRequest(ODR o)
-{
-    Z_InitRequest *r = (Z_InitRequest *)odr_malloc(o, sizeof(*r));
-
-    r->referenceId = 0;
-    r->options = (Odr_bitmask *)odr_malloc(o, sizeof(*r->options));
-    ODR_MASK_ZERO(r->options);
-    r->protocolVersion = (Odr_bitmask *)odr_malloc(o, sizeof(*r->protocolVersion));
-    ODR_MASK_ZERO(r->protocolVersion);
-    r->preferredMessageSize = (int *)odr_malloc(o, sizeof(int));
-    *r->preferredMessageSize = 30*1024;
-    r->maximumRecordSize = (int *)odr_malloc(o, sizeof(int));
-    *r->maximumRecordSize = 30*1024;
-    r->idAuthentication = 0;
-    r->implementationId = "YAZ (id=81)";
-    r->implementationName = "Index Data/YAZ";
-    r->implementationVersion = YAZ_VERSION;
-    r->userInformationField = 0;
-    r->otherInfo = 0;
-    return r;
-}
-
-Z_InitResponse *zget_InitResponse(ODR o)
-{
-    Z_InitResponse *r = (Z_InitResponse *)odr_malloc(o, sizeof(*r));
-
-    r->referenceId = 0;
-    r->options = (Odr_bitmask *)odr_malloc(o, sizeof(*r->options));
-    ODR_MASK_ZERO(r->options);
-    r->protocolVersion = (Odr_bitmask *)odr_malloc(o, sizeof(*r->protocolVersion));
-    ODR_MASK_ZERO(r->protocolVersion);
-    r->preferredMessageSize = (int *)odr_malloc(o, sizeof(int));
-    *r->preferredMessageSize = 30*1024;
-    r->maximumRecordSize = (int *)odr_malloc(o, sizeof(int));
-    *r->maximumRecordSize = 30*1024;
-    r->result = (int *)odr_malloc(o, sizeof(bool_t));
-    *r->result = 1;
-    r->implementationId = "YAZ (id=81)";
-    r->implementationName = "Index Data/YAZ";
-    r->implementationVersion = YAZ_VERSION;
-    r->userInformationField = 0;
-    r->otherInfo = 0;
-    return r;
-}
-
-Z_SearchRequest *zget_SearchRequest(ODR o)
-{
-    Z_SearchRequest *r = (Z_SearchRequest *)odr_malloc(o, sizeof(*r));
-
-    r->referenceId = 0;
-    r->smallSetUpperBound = (int *)odr_malloc(o, sizeof(int));
-    *r->smallSetUpperBound = 0;
-    r->largeSetLowerBound = (int *)odr_malloc(o, sizeof(int));
-    *r->largeSetLowerBound = 1;
-    r->mediumSetPresentNumber = (int *)odr_malloc(o, sizeof(int));
-    *r->mediumSetPresentNumber = 0;
-    r->replaceIndicator = (int *)odr_malloc(o, sizeof(bool_t));
-    *r->replaceIndicator = 1;
-    r->resultSetName = "default";
-    r->num_databaseNames = 0;
-    r->databaseNames = 0;
-    r->smallSetElementSetNames = 0;
-    r->mediumSetElementSetNames = 0;
-    r->preferredRecordSyntax = 0;
-    r->query = 0;
-    r->additionalSearchInfo = 0;
-    r->otherInfo = 0;
-    return r;
-}
-
-Z_SearchResponse *zget_SearchResponse(ODR o)
-{
-    Z_SearchResponse *r = (Z_SearchResponse *)odr_malloc(o, sizeof(*r));
-
-    r->referenceId = 0;
-    r->resultCount = (int *)odr_malloc(o, sizeof(int));
-    *r->resultCount = 0;
-    r->numberOfRecordsReturned = (int *)odr_malloc(o, sizeof(int));
-    *r->numberOfRecordsReturned = 0;
-    r->nextResultSetPosition = (int *)odr_malloc(o, sizeof(int));
-    *r->nextResultSetPosition = 0;
-    r->searchStatus = (int *)odr_malloc(o, sizeof(bool_t));
-    *r->searchStatus = 1;
-    r->resultSetStatus = 0;
-    r->presentStatus = 0;
-    r->records = 0;
-    r->additionalSearchInfo = 0;
-    r->otherInfo = 0;
-    return r;
-}
-
-Z_PresentRequest *zget_PresentRequest(ODR o)
-{
-    Z_PresentRequest *r = (Z_PresentRequest *)odr_malloc(o, sizeof(*r));
-
-    r->referenceId = 0;
-    r->resultSetId = "default";
-    r->resultSetStartPoint = (int *)odr_malloc(o, sizeof(int));
-    *r->resultSetStartPoint = 1;
-    r->numberOfRecordsRequested = (int *)odr_malloc(o, sizeof(int));
-    *r->numberOfRecordsRequested = 10;
-    r->num_ranges = 0;
-    r->additionalRanges = 0;
-    r->recordComposition = 0;
-    r->preferredRecordSyntax = 0;
-    r->maxSegmentCount = 0;
-    r->maxRecordSize = 0;
-    r->maxSegmentSize = 0;
-    r->otherInfo = 0;
-    return r;
-}
-
-Z_PresentResponse *zget_PresentResponse(ODR o)
-{
-    Z_PresentResponse *r = (Z_PresentResponse *)odr_malloc(o, sizeof(*r));
-
-    r->referenceId = 0;
-    r->numberOfRecordsReturned = (int *)odr_malloc(o, sizeof(int));
-    *r->numberOfRecordsReturned = 0;
-    r->nextResultSetPosition = (int *)odr_malloc(o, sizeof(int));
-    *r->nextResultSetPosition = 0;
-    r->presentStatus = (int *)odr_malloc(o, sizeof(int));
-    *r->presentStatus = Z_PRES_SUCCESS;
-    r->records = 0;
-    r->otherInfo = 0;
-    return r;
-}
-
-Z_DeleteResultSetRequest *zget_DeleteResultSetRequest(ODR o)
-{
-    Z_DeleteResultSetRequest *r = (Z_DeleteResultSetRequest *)
-       odr_malloc(o, sizeof(*r));
-
-    r->referenceId = 0;
-    r->deleteFunction = (int *)odr_malloc(o, sizeof(int));
-    *r->deleteFunction = Z_DeleteRequest_list;
-    r->num_resultSetList = 0;
-    r->resultSetList = 0;
-    r->otherInfo = 0;
-    return r;
-}
-
-Z_DeleteResultSetResponse *zget_DeleteResultSetResponse(ODR o)
-{
-    Z_DeleteResultSetResponse *r = (Z_DeleteResultSetResponse *)
-       odr_malloc(o, sizeof(*r));
-    
-    r->referenceId = 0;
-    r->deleteOperationStatus = (int *)odr_malloc(o, sizeof(int));
-    *r->deleteOperationStatus = Z_DeleteStatus_success;
-    r->deleteListStatuses = 0;
-    r->numberNotDeleted = 0;
-    r->bulkStatuses = 0;
-    r->deleteMessage = 0;
-    r->otherInfo = 0;
-    return r;
-}
-
-Z_ScanRequest *zget_ScanRequest(ODR o)
-{
-    Z_ScanRequest *r = (Z_ScanRequest *)odr_malloc(o, sizeof(*r));
-    
-    r->referenceId = 0;
-    r->num_databaseNames = 0;
-    r->databaseNames = 0;
-    r->attributeSet = 0;
-    r->termListAndStartPoint = 0;
-    r->stepSize = 0;
-    r->numberOfTermsRequested = (int *)odr_malloc(o, sizeof(int));
-    *r->numberOfTermsRequested = 20;
-    r->preferredPositionInResponse = 0;
-    r->otherInfo = 0;
-    return r;
-}
-
-Z_ScanResponse *zget_ScanResponse(ODR o)
-{
-    Z_ScanResponse *r = (Z_ScanResponse *)odr_malloc(o, sizeof(*r));
-    
-    r->referenceId = 0;
-    r->stepSize = 0;
-    r->scanStatus = (int *)odr_malloc(o, sizeof(int));
-    *r->scanStatus = Z_Scan_success;
-    r->numberOfEntriesReturned = (int *)odr_malloc(o, sizeof(int));
-    *r->numberOfEntriesReturned = 0;
-    r->positionOfTerm =0;
-    r->entries = 0;
-    r->attributeSet = 0;
-    r->otherInfo = 0;
-    return r;
-}
-
-Z_TriggerResourceControlRequest *zget_TriggerResourceControlRequest(ODR o)
-{
-    Z_TriggerResourceControlRequest *r = (Z_TriggerResourceControlRequest *)
-       odr_malloc(o, sizeof(*r));
-    
-    r->referenceId = 0;
-    r->requestedAction = (int *)odr_malloc(o, sizeof(int));
-    *r->requestedAction = Z_TriggerResourceCtrl_resourceReport;
-    r->prefResourceReportFormat = 0;
-    r->resultSetWanted = 0;
-    r->otherInfo = 0;
-    return r;
-}
-
-Z_ResourceControlRequest *zget_ResourceControlRequest(ODR o)
-{
-    Z_ResourceControlRequest *r = (Z_ResourceControlRequest *)
-       odr_malloc(o, sizeof(*r));
-
-    r->referenceId = 0;
-    r->suspendedFlag = 0;
-    r->resourceReport = 0;
-    r->partialResultsAvailable = 0;
-    r->responseRequired = (int *)odr_malloc(o, sizeof(bool_t));
-    *r->responseRequired = 0;
-    r->triggeredRequestFlag = 0;
-    r->otherInfo = 0;
-    return r;
-}
-
-Z_ResourceControlResponse *zget_ResourceControlResponse(ODR o)
-{
-    Z_ResourceControlResponse *r = (Z_ResourceControlResponse *)
-       odr_malloc(o, sizeof(*r));
-
-    r->referenceId = 0;
-    r->continueFlag = (int *)odr_malloc(o, sizeof(bool_t));
-    *r->continueFlag = 1;
-    r->resultSetWanted = 0;
-    r->otherInfo = 0;
-    return r;
-}
-
-Z_AccessControlRequest *zget_AccessControlRequest(ODR o)
-{
-    Z_AccessControlRequest *r = (Z_AccessControlRequest *)
-       odr_malloc(o, sizeof(*r));
-
-    r->referenceId = 0;
-    r->which = Z_AccessRequest_simpleForm;
-    r->u.simpleForm = 0;
-    r->otherInfo = 0;
-    return r;
-}
-
-Z_AccessControlResponse *zget_AccessControlResponse(ODR o)
-{
-    Z_AccessControlResponse *r = (Z_AccessControlResponse *)
-       odr_malloc(o, sizeof(*r));
-
-    r->referenceId = 0;
-    r->which = Z_AccessResponse_simpleForm;
-    r->u.simpleForm = 0;
-    r->diagnostic = 0;
-    r->otherInfo = 0;
-    return r;
-}
-
-Z_Segment *zget_Segment(ODR o)
-{
-    Z_Segment *r = (Z_Segment *)odr_malloc(o, sizeof(*r));
-
-    r->referenceId = 0;
-    r->numberOfRecordsReturned = (int *)odr_malloc(o, sizeof(int));
-    *r->numberOfRecordsReturned = 0;
-    r->num_segmentRecords = 0;
-    r->segmentRecords = 0;
-    r->otherInfo = 0;
-    return r;
-}
-
-Z_Close *zget_Close(ODR o)
-{
-    Z_Close *r = (Z_Close *)odr_malloc(o, sizeof(*r));
-
-    r->referenceId = 0;
-    r->closeReason = (int *)odr_malloc(o, sizeof(int));
-    *r->closeReason = Z_Close_finished;
-    r->diagnosticInformation = 0;
-    r->resourceReportFormat = 0;
-    r->resourceReport = 0;
-    r->otherInfo = 0;
-    return r;
-}
-
-Z_ResourceReportRequest *zget_ResourceReportRequest(ODR o)
-{
-    Z_ResourceReportRequest *r = (Z_ResourceReportRequest *)
-       odr_malloc(o, sizeof(*r));
-
-    r->referenceId = 0;
-    r->opId = 0;
-    r->prefResourceReportFormat = 0;
-    r->otherInfo = 0;
-    return r;
-}
-
-Z_ResourceReportResponse *zget_ResourceReportResponse(ODR o)
-{
-    Z_ResourceReportResponse *r = (Z_ResourceReportResponse *)
-       odr_malloc(o, sizeof(*r));
-
-    r->referenceId = 0;
-    r->resourceReportStatus = (int *)odr_malloc(o, sizeof(int));
-    *r->resourceReportStatus = Z_ResourceReportStatus_success;
-    r->resourceReport = 0;
-    r->otherInfo = 0;
-    return r;
-}
-
-Z_SortRequest *zget_SortRequest(ODR o)
-{
-    Z_SortRequest *r = (Z_SortRequest *)odr_malloc(o, sizeof(*r));
-
-    r->referenceId = 0;
-    r->inputResultSetNames = 0;
-    r->sortedResultSetName = 0;
-    r->sortSequence = 0;
-    r->otherInfo = 0;
-    return r;
-}
-
-Z_SortResponse *zget_SortResponse(ODR o)
-{
-    Z_SortResponse *r = (Z_SortResponse *)odr_malloc(o, sizeof(*r));
-
-    r->referenceId = 0;
-    r->sortStatus = (int *)odr_malloc(o, sizeof(int));
-    *r->sortStatus = Z_SortStatus_success;
-    r->resultSetStatus = (int *)odr_malloc(o, sizeof(int));
-    *r->resultSetStatus = Z_SortResultSetStatus_empty;
-    r->diagnostics = 0;
-    r->otherInfo = 0;
-    return r;
-}
-
-Z_ExtendedServicesRequest *zget_ExtendedServicesRequest(ODR o)
-{
-    Z_ExtendedServicesRequest *r = (Z_ExtendedServicesRequest *)
-       odr_malloc(o, sizeof(*r));
-
-    r->referenceId = 0;
-    r->function = (int *)odr_malloc(o, sizeof(int));
-    *r->function = Z_ExtendedServicesRequest_create;
-    r->packageType = 0;
-    r->packageName = 0;
-    r->userId = 0;
-    r->retentionTime = 0;
-    r->permissions = 0;
-    r->description = 0;
-    r->taskSpecificParameters = 0;
-    r->waitAction = (int *)odr_malloc(o, sizeof(int));
-    *r->waitAction = Z_ExtendedServicesRequest_wait;
-    r->elements = 0;
-    r->otherInfo = 0;
-    return r;
-}
-
-Z_ExtendedServicesResponse *zget_ExtendedServicesResponse(ODR o)
-{
-    Z_ExtendedServicesResponse *r = (Z_ExtendedServicesResponse *)
-       odr_malloc(o, sizeof(*r));
-
-    r->referenceId = 0;
-    r->operationStatus = (int *)odr_malloc(o, sizeof(int));
-    *r->operationStatus = Z_ExtendedServicesResponse_done;
-    r->num_diagnostics = 0;
-    r->diagnostics = 0;
-    r->taskPackage = 0;
-    r->otherInfo = 0;
-    return r;
-}
-
-Z_APDU *zget_APDU(ODR o, int which)
-{
-    Z_APDU *r = (Z_APDU *)odr_malloc(o, sizeof(*r));
-
-    switch (r->which = which)
-    {
-       case Z_APDU_initRequest:
-           r->u.initRequest = zget_InitRequest(o);
-            break;
-       case Z_APDU_initResponse:
-           r->u.initResponse = zget_InitResponse(o);
-            break;
-       case Z_APDU_searchRequest:
-           r->u.searchRequest = zget_SearchRequest(o);
-            break;
-       case Z_APDU_searchResponse:
-           r->u.searchResponse = zget_SearchResponse(o);
-            break;
-       case Z_APDU_presentRequest:
-           r->u.presentRequest = zget_PresentRequest(o);
-            break;
-       case Z_APDU_presentResponse:
-           r->u.presentResponse = zget_PresentResponse(o);
-            break;
-       case Z_APDU_deleteResultSetRequest:
-           r->u.deleteResultSetRequest = zget_DeleteResultSetRequest(o);
-            break;
-       case Z_APDU_deleteResultSetResponse:
-           r->u.deleteResultSetResponse = zget_DeleteResultSetResponse(o);
-           break;
-       case Z_APDU_scanRequest:
-           r->u.scanRequest = zget_ScanRequest(o);
-            break;
-       case Z_APDU_scanResponse:
-           r->u.scanResponse = zget_ScanResponse(o);
-            break;
-       case Z_APDU_triggerResourceControlRequest:
-           r->u.triggerResourceControlRequest =
-                zget_TriggerResourceControlRequest(o);
-            break;
-       case Z_APDU_resourceControlRequest:
-           r->u.resourceControlRequest = zget_ResourceControlRequest(o);
-           break;
-       case Z_APDU_resourceControlResponse:
-           r->u.resourceControlResponse = zget_ResourceControlResponse(o);
-           break;
-       case Z_APDU_segmentRequest:
-           r->u.segmentRequest = zget_Segment(o);
-           break;
-       case Z_APDU_close:
-           r->u.close = zget_Close(o);
-           break;
-       case Z_APDU_accessControlRequest:
-           r->u.accessControlRequest = zget_AccessControlRequest(o);
-           break;
-       case Z_APDU_accessControlResponse:
-           r->u.accessControlResponse = zget_AccessControlResponse(o);
-           break;
-       case Z_APDU_resourceReportRequest:
-           r->u.resourceReportRequest = zget_ResourceReportRequest(o);
-           break;
-       case Z_APDU_resourceReportResponse:
-           r->u.resourceReportResponse = zget_ResourceReportResponse(o);
-           break;
-       case Z_APDU_sortRequest:
-           r->u.sortRequest = zget_SortRequest(o);
-           break;
-       case Z_APDU_sortResponse:
-           r->u.sortResponse = zget_SortResponse(o);
-           break;
-       case Z_APDU_extendedServicesRequest:
-           r->u.extendedServicesRequest = zget_ExtendedServicesRequest(o);
-           break;
-       case Z_APDU_extendedServicesResponse:
-           r->u.extendedServicesResponse = zget_ExtendedServicesResponse(o);
-           break;
-       default:
-           fprintf(stderr, "Bad APDU-type to zget_APDU");
-           exit(1);
-    }
-    return r;
-}
index d25248b..be24467 100644 (file)
@@ -1,7 +1,7 @@
 # Copyright (C) 1995-1999, Index Data
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
 # Copyright (C) 1995-1999, Index Data
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile.in,v 1.6 1999-04-16 14:45:55 adam Exp $
+# $Id: Makefile.in,v 1.7 1999-06-08 10:10:16 adam Exp $
 
 SHELL=/bin/sh
 
 
 SHELL=/bin/sh
 
@@ -17,7 +17,7 @@ LIBDIR=../lib
 
 INCLUDE=-I../z39.50 -I../include -I. -I../../xtimosi/src
 DEFS=$(INCLUDE) $(CDEFS) -DCCL2RPN=1
 
 INCLUDE=-I../z39.50 -I../include -I. -I../../xtimosi/src
 DEFS=$(INCLUDE) $(CDEFS) -DCCL2RPN=1
-YAZLIBS=$(LIBDIR)/libasn.a $(LIBDIR)/libcomstack.a \
+YAZLIBS=$(LIBDIR)/libzutil.a $(LIBDIR)/libasn.a $(LIBDIR)/libcomstack.a \
   ../lib/libccl.a $(LIBMOSI) $(LIBDIR)/libodr.a $(LIBDIR)/libutil.a 
 PROG=client
 PROGO=client.o
   ../lib/libccl.a $(LIBMOSI) $(LIBDIR)/libodr.a $(LIBDIR)/libutil.a 
 PROG=client
 PROGO=client.o
index 8c6689c..1b0bc14 100755 (executable)
--- a/configure
+++ b/configure
@@ -951,28 +951,18 @@ fi
 
 
 if test "$YCDIR" = "yes"; then
 
 
 if test "$YCDIR" = "yes"; then
-       YCDIR="../yc"
-fi
-if test -d z39.50; then
-       rm z39.50
-fi
-if test "$YCDIR" = ""; then
-       ASNMODULE=asn
-else
-       if test ! -d "$YCDIR"; then
-               echo "configure: warning: YC directory ${YCDIR} doesn't exist" 1>&2
-       fi
-       ln -s ${YCDIR}/z39.50 z39.50
        ASNMODULE=z39.50
        ASNMODULE=z39.50
+else
+       ASNMODULE=asn
 fi
 checkBoth=0
 echo $ac_n "checking for connect""... $ac_c" 1>&6
 fi
 checkBoth=0
 echo $ac_n "checking for connect""... $ac_c" 1>&6
-echo "configure:971: checking for connect" >&5
+echo "configure:961: checking for connect" >&5
 if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
 if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 976 "configure"
+#line 966 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char connect(); below.  */
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char connect(); below.  */
@@ -995,7 +985,7 @@ connect();
 
 ; return 0; }
 EOF
 
 ; return 0; }
 EOF
-if { (eval echo configure:999: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:989: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_connect=yes"
 else
   rm -rf conftest*
   eval "ac_cv_func_connect=yes"
 else
@@ -1016,7 +1006,7 @@ fi
 
 if test "$ac_cv_func_connect" = "no"; then
        echo $ac_n "checking for main in -lsocket""... $ac_c" 1>&6
 
 if test "$ac_cv_func_connect" = "no"; then
        echo $ac_n "checking for main in -lsocket""... $ac_c" 1>&6
-echo "configure:1020: checking for main in -lsocket" >&5
+echo "configure:1010: checking for main in -lsocket" >&5
 ac_lib_var=`echo socket'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 ac_lib_var=`echo socket'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1024,14 +1014,14 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1028 "configure"
+#line 1018 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:1035: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1025: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1057,12 +1047,12 @@ if test "$checkBoth" = "1"; then
        oldLibs=$LIBS
        LIBS="$LIBS -lsocket -lnsl"
        echo $ac_n "checking for accept""... $ac_c" 1>&6
        oldLibs=$LIBS
        LIBS="$LIBS -lsocket -lnsl"
        echo $ac_n "checking for accept""... $ac_c" 1>&6
-echo "configure:1061: checking for accept" >&5
+echo "configure:1051: checking for accept" >&5
 if eval "test \"`echo '$''{'ac_cv_func_accept'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
 if eval "test \"`echo '$''{'ac_cv_func_accept'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1066 "configure"
+#line 1056 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char accept(); below.  */
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char accept(); below.  */
@@ -1085,7 +1075,7 @@ accept();
 
 ; return 0; }
 EOF
 
 ; return 0; }
 EOF
-if { (eval echo configure:1089: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1079: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_accept=yes"
 else
   rm -rf conftest*
   eval "ac_cv_func_accept=yes"
 else
@@ -1107,12 +1097,12 @@ fi
 
 fi
 echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6
 
 fi
 echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6
-echo "configure:1111: checking for gethostbyname" >&5
+echo "configure:1101: checking for gethostbyname" >&5
 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1116 "configure"
+#line 1106 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char gethostbyname(); below.  */
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char gethostbyname(); below.  */
@@ -1135,7 +1125,7 @@ gethostbyname();
 
 ; return 0; }
 EOF
 
 ; return 0; }
 EOF
-if { (eval echo configure:1139: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1129: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_gethostbyname=yes"
 else
   rm -rf conftest*
   eval "ac_cv_func_gethostbyname=yes"
 else
@@ -1153,7 +1143,7 @@ if eval "test \"`echo '$ac_cv_func_'gethostbyname`\" = yes"; then
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for main in -lnsl""... $ac_c" 1>&6
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for main in -lnsl""... $ac_c" 1>&6
-echo "configure:1157: checking for main in -lnsl" >&5
+echo "configure:1147: checking for main in -lnsl" >&5
 ac_lib_var=`echo nsl'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 ac_lib_var=`echo nsl'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1161,14 +1151,14 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1165 "configure"
+#line 1155 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:1172: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1162: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1191,7 +1181,7 @@ fi
 fi
 
 echo $ac_n "checking for readline in -lreadline""... $ac_c" 1>&6
 fi
 
 echo $ac_n "checking for readline in -lreadline""... $ac_c" 1>&6
-echo "configure:1195: checking for readline in -lreadline" >&5
+echo "configure:1185: checking for readline in -lreadline" >&5
 ac_lib_var=`echo readline'_'readline | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 ac_lib_var=`echo readline'_'readline | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1199,7 +1189,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lreadline  $LIBS"
 cat > conftest.$ac_ext <<EOF
   ac_save_LIBS="$LIBS"
 LIBS="-lreadline  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1203 "configure"
+#line 1193 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1210,7 +1200,7 @@ int main() {
 readline()
 ; return 0; }
 EOF
 readline()
 ; return 0; }
 EOF
-if { (eval echo configure:1214: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1204: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1231,7 +1221,7 @@ else
 fi
 
 echo $ac_n "checking for add_history in -lhistory""... $ac_c" 1>&6
 fi
 
 echo $ac_n "checking for add_history in -lhistory""... $ac_c" 1>&6
-echo "configure:1235: checking for add_history in -lhistory" >&5
+echo "configure:1225: checking for add_history in -lhistory" >&5
 ac_lib_var=`echo history'_'add_history | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 ac_lib_var=`echo history'_'add_history | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1239,7 +1229,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lhistory  $LIBS"
 cat > conftest.$ac_ext <<EOF
   ac_save_LIBS="$LIBS"
 LIBS="-lhistory  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1243 "configure"
+#line 1233 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1250,7 +1240,7 @@ int main() {
 add_history()
 ; return 0; }
 EOF
 add_history()
 ; return 0; }
 EOF
-if { (eval echo configure:1254: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1244: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1275,17 +1265,17 @@ if test "$ac_cv_lib_readline_readline" = "yes"; then
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1279: checking for $ac_hdr" >&5
+echo "configure:1269: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1284 "configure"
+#line 1274 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1289: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1279: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1313,11 +1303,11 @@ done
 
 fi
 echo $ac_n "checking for working tcpd.h""... $ac_c" 1>&6
 
 fi
 echo $ac_n "checking for working tcpd.h""... $ac_c" 1>&6
-echo "configure:1317: checking for working tcpd.h" >&5
+echo "configure:1307: checking for working tcpd.h" >&5
 oldLibs=$LIBS
 LIBS="$LIBS -lwrap"
 cat > conftest.$ac_ext <<EOF
 oldLibs=$LIBS
 LIBS="$LIBS -lwrap"
 cat > conftest.$ac_ext <<EOF
-#line 1321 "configure"
+#line 1311 "configure"
 #include "confdefs.h"
 #include <syslog.h>
 #include <tcpd.h>
 #include "confdefs.h"
 #include <syslog.h>
 #include <tcpd.h>
@@ -1328,7 +1318,7 @@ struct request_info request_info; int i;
 i = hosts_access(&request_info);
 ; return 0; }
 EOF
 i = hosts_access(&request_info);
 ; return 0; }
 EOF
-if { (eval echo configure:1332: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1322: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   tcpd_ok=1
 else
   rm -rf conftest*
   tcpd_ok=1
 else
@@ -1349,12 +1339,12 @@ EOF
 
 fi
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
 
 fi
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:1353: checking for ANSI C header files" >&5
+echo "configure:1343: checking for ANSI C header files" >&5
 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1358 "configure"
+#line 1348 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -1362,7 +1352,7 @@ else
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1366: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1356: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1379,7 +1369,7 @@ rm -f conftest*
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 1383 "configure"
+#line 1373 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -1397,7 +1387,7 @@ fi
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 1401 "configure"
+#line 1391 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -1418,7 +1408,7 @@ if test "$cross_compiling" = yes; then
   :
 else
   cat > conftest.$ac_ext <<EOF
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 1422 "configure"
+#line 1412 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -1429,7 +1419,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
 exit (0); }
 
 EOF
 exit (0); }
 
 EOF
-if { (eval echo configure:1433: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1423: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
 then
   :
 else
@@ -1468,17 +1458,17 @@ if test "$threads_ok" = "yes"; then
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1472: checking for $ac_hdr" >&5
+echo "configure:1462: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1477 "configure"
+#line 1467 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1482: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1472: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1505,12 +1495,12 @@ fi
 done
 
        echo $ac_n "checking for pthread_mutex_lock""... $ac_c" 1>&6
 done
 
        echo $ac_n "checking for pthread_mutex_lock""... $ac_c" 1>&6
-echo "configure:1509: checking for pthread_mutex_lock" >&5
+echo "configure:1499: checking for pthread_mutex_lock" >&5
 if eval "test \"`echo '$''{'ac_cv_func_pthread_mutex_lock'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
 if eval "test \"`echo '$''{'ac_cv_func_pthread_mutex_lock'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1514 "configure"
+#line 1504 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char pthread_mutex_lock(); below.  */
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char pthread_mutex_lock(); below.  */
@@ -1533,7 +1523,7 @@ pthread_mutex_lock();
 
 ; return 0; }
 EOF
 
 ; return 0; }
 EOF
-if { (eval echo configure:1537: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1527: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_pthread_mutex_lock=yes"
 else
   rm -rf conftest*
   eval "ac_cv_func_pthread_mutex_lock=yes"
 else
@@ -1554,7 +1544,7 @@ fi
 
        if test "$ac_cv_func_pthread_mutex_lock" = "no"; then
                echo $ac_n "checking for main in -lpthread""... $ac_c" 1>&6
 
        if test "$ac_cv_func_pthread_mutex_lock" = "no"; then
                echo $ac_n "checking for main in -lpthread""... $ac_c" 1>&6
-echo "configure:1558: checking for main in -lpthread" >&5
+echo "configure:1548: checking for main in -lpthread" >&5
 ac_lib_var=`echo pthread'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 ac_lib_var=`echo pthread'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1562,14 +1552,14 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpthread  $LIBS"
 cat > conftest.$ac_ext <<EOF
   ac_save_LIBS="$LIBS"
 LIBS="-lpthread  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1566 "configure"
+#line 1556 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:1573: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1563: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1715,7 +1705,7 @@ done
 ac_given_srcdir=$srcdir
 ac_given_INSTALL="$INSTALL"
 
 ac_given_srcdir=$srcdir
 ac_given_INSTALL="$INSTALL"
 
-trap 'rm -fr `echo "Makefile util/Makefile asn/Makefile odr/Makefile comstack/Makefile client/Makefile server/Makefile ztest/Makefile retrieval/Makefile ccl/Makefile lib/Makefile rfc1006/Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+trap 'rm -fr `echo "Makefile util/Makefile asn/Makefile odr/Makefile zutil/Makefile comstack/Makefile client/Makefile server/Makefile ztest/Makefile retrieval/Makefile ccl/Makefile lib/Makefile rfc1006/Makefile z39.50/Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
 EOF
 cat >> $CONFIG_STATUS <<EOF
 
 EOF
 cat >> $CONFIG_STATUS <<EOF
 
@@ -1795,7 +1785,7 @@ EOF
 
 cat >> $CONFIG_STATUS <<EOF
 
 
 cat >> $CONFIG_STATUS <<EOF
 
-CONFIG_FILES=\${CONFIG_FILES-"Makefile util/Makefile asn/Makefile odr/Makefile comstack/Makefile client/Makefile server/Makefile ztest/Makefile retrieval/Makefile ccl/Makefile lib/Makefile rfc1006/Makefile"}
+CONFIG_FILES=\${CONFIG_FILES-"Makefile util/Makefile asn/Makefile odr/Makefile zutil/Makefile comstack/Makefile client/Makefile server/Makefile ztest/Makefile retrieval/Makefile ccl/Makefile lib/Makefile rfc1006/Makefile z39.50/Makefile"}
 EOF
 cat >> $CONFIG_STATUS <<\EOF
 for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
 EOF
 cat >> $CONFIG_STATUS <<\EOF
 for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
index 7af1cea..f1cfa19 100644 (file)
@@ -1,7 +1,7 @@
 dnl YAZ Toolkit
 dnl (c) Index Data 1994-1999
 dnl See the file LICENSE for details.
 dnl YAZ Toolkit
 dnl (c) Index Data 1994-1999
 dnl See the file LICENSE for details.
-dnl $Id: configure.in,v 1.8 1999-05-26 07:49:35 adam Exp $
+dnl $Id: configure.in,v 1.9 1999-06-08 10:10:16 adam Exp $
 AC_INIT(include/yaz-version.h)
 dnl
 dnl ------ Checking programs
 AC_INIT(include/yaz-version.h)
 dnl
 dnl ------ Checking programs
@@ -15,19 +15,9 @@ AC_SUBST(ASNMODULE)
 AC_ARG_WITH(yc,[  --with-yc               compile using YC: The Yaz Compiler], [YCDIR=$withval],[YCDIR=""])
 
 if test "$YCDIR" = "yes"; then
 AC_ARG_WITH(yc,[  --with-yc               compile using YC: The Yaz Compiler], [YCDIR=$withval],[YCDIR=""])
 
 if test "$YCDIR" = "yes"; then
-       YCDIR="../yc"
-fi
-if test -d z39.50; then
-       rm z39.50
-fi
-if test "$YCDIR" = ""; then
-       ASNMODULE=asn
-else
-       if test ! -d "$YCDIR"; then
-               AC_MSG_WARN(YC directory ${YCDIR} doesn't exist)
-       fi
-       ln -s ${YCDIR}/z39.50 z39.50
        ASNMODULE=z39.50
        ASNMODULE=z39.50
+else
+       ASNMODULE=asn
 fi
 dnl
 dnl ----- Sockets
 fi
 dnl
 dnl ----- Sockets
@@ -87,4 +77,4 @@ if test "$threads_ok" = "yes"; then
 fi
 dnl
 dnl ------ Makefiles
 fi
 dnl
 dnl ------ Makefiles
-AC_OUTPUT(Makefile util/Makefile asn/Makefile odr/Makefile comstack/Makefile client/Makefile server/Makefile ztest/Makefile retrieval/Makefile ccl/Makefile lib/Makefile rfc1006/Makefile)
+AC_OUTPUT(Makefile util/Makefile asn/Makefile odr/Makefile zutil/Makefile comstack/Makefile client/Makefile server/Makefile ztest/Makefile retrieval/Makefile ccl/Makefile lib/Makefile rfc1006/Makefile z39.50/Makefile)
index e18f529..ae65af1 100644 (file)
@@ -1,7 +1,7 @@
 # Copyright (C) 1994-1998, Index Data 
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
 # Copyright (C) 1994-1998, Index Data 
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile.in,v 1.2 1998-09-22 09:40:54 adam Exp $
+# $Id: Makefile.in,v 1.3 1999-06-08 10:10:16 adam Exp $
 
 SHELL=/bin/sh
 
 
 SHELL=/bin/sh
 
@@ -9,7 +9,7 @@ RANLIB=@RANLIB@
 
 MAKE=make
 YAZLIBS=libodr.a libasn.a libcomstack.a \
 
 MAKE=make
 YAZLIBS=libodr.a libasn.a libcomstack.a \
-       libserver.a libutil.a libret.a
+       libserver.a libzutil.a libutil.a libret.a
 LIB=libyaz.a
 
 all: $(LIB)
 LIB=libyaz.a
 
 all: $(LIB)
index 2e9d30a..9206397 100644 (file)
@@ -1,7 +1,7 @@
 # Copyright (C) 1994-1998, Index Data
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
 # Copyright (C) 1994-1998, Index Data
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile.in,v 1.5 1999-04-26 07:25:25 adam Exp $
+# $Id: Makefile.in,v 1.6 1999-06-08 10:10:16 adam Exp $
 
 SHELL=/bin/sh
 
 
 SHELL=/bin/sh
 
@@ -16,9 +16,9 @@ LIBDIR=../lib
 
 DEFS=$(INCLUDE) $(CDEFS)
 LIB=$(LIBDIR)/libutil.a
 
 DEFS=$(INCLUDE) $(CDEFS)
 LIB=$(LIBDIR)/libutil.a
-PO = options.o log.o marcdisp.o yaz-ccl.o pquery.o oid.o wrbuf.o nmemsdup.o \
-   xmalloc.o readconf.o tpath.o nmem.o yaz-util.o atoin.o otherinfo.o \
-   logrpn.o # dmalloc.o 
+PO = options.o log.o marcdisp.o oid.o wrbuf.o nmemsdup.o \
+   xmalloc.o readconf.o tpath.o nmem.o matchstr.o \
+   atoin.o # dmalloc.o 
 
 all: $(LIB) marcdump
 
 
 all: $(LIB) marcdump
 
diff --git a/util/logrpn.c b/util/logrpn.c
deleted file mode 100644 (file)
index 16af8ba..0000000
+++ /dev/null
@@ -1,366 +0,0 @@
-/*
- * Copyright (C) 1995-1998, Index Data
- * All rights reserved.
- * Sebastian Hammer, Adam Dickmeiss
- *
- * $Log: logrpn.c,v $
- * Revision 1.1  1998-11-16 16:02:35  adam
- * Added loggin utilies, log_rpn_query and log_scan_term. These used
- * to be part of Zebra.
- *
- *
- *
- * Old logs from zlogs.c:
- *
- * Revision 1.9  1998/10/13 20:36:02  adam
- * Changed "indent" format string in log messages.
- *
- * Revision 1.8  1998/04/02 14:35:29  adam
- * First version of Zebra that works with compiled ASN.1.
- *
- * Revision 1.7  1998/01/29 13:40:11  adam
- * Better logging for scan service.
- *
- * Revision 1.6  1997/09/29 09:06:41  adam
- * Removed static var to make this module thread safe.
- *
- * Revision 1.5  1997/04/30 08:56:07  quinn
- * null
- *
- * Revision 1.4  1996/10/08  09:41:25  quinn
- * Fixed diagnostic.
- *
- * Revision 1.3  1996/03/20  09:36:40  adam
- * Function dict_lookup_grep got extra parameter, init_pos, which marks
- * from which position in pattern approximate pattern matching should occur.
- * Approximate pattern matching is used in relevance=re-2.
- *
- * Revision 1.2  1996/01/03  16:22:11  quinn
- * operator->roperator
- *
- * Revision 1.1  1995/11/16  17:00:55  adam
- * Better logging of rpn query.
- *
- */
-#include <stdio.h>
-#include <assert.h>
-
-#include <log.h>
-#include <logrpn.h>
-
-static void attrStr (int type, int value, enum oid_value ast, char *str)
-{
-    *str = '\0';
-    switch (ast)
-    {
-    case VAL_BIB1:
-    case VAL_EXP1:
-    case VAL_GILS:
-        switch (type)
-        {
-        case 1:
-            sprintf (str, "use");
-            break;
-        case 2:
-            switch (value)
-            {
-            case 1:
-                sprintf (str, "relation=Less than");
-                break;
-            case 2:
-                sprintf (str, "relation=Less than or equal");
-                break;
-            case 3:
-                sprintf (str, "relation=Equal");
-                break;
-            case 4:
-                sprintf (str, "relation=Greater or equal");
-                break;
-            case 5:
-                sprintf (str, "relation=Greater than");
-                break;
-            case 6:
-                sprintf (str, "relation=Not equal");
-                break;
-            case 100:
-                sprintf (str, "relation=Phonetic");
-                break;
-            case 101:
-                sprintf (str, "relation=Stem");
-                break;
-            case 102:
-                sprintf (str, "relation=Relevance");
-                break;
-            case 103:
-                sprintf (str, "relation=AlwaysMatches");
-                break;
-            default:
-                sprintf (str, "relation");
-            }
-            break;
-        case 3:
-            switch (value)
-            {
-            case 1:
-                sprintf (str, "position=First in field");
-                break;
-            case 2:
-                sprintf (str, "position=First in any subfield");
-                break;
-            case 3:
-                sprintf (str, "position=Any position in field");
-                break;
-            default:
-                sprintf (str, "position");
-            }
-            break;
-        case 4:
-            switch (value)
-            {
-            case 1:
-                sprintf (str, "structure=Phrase");
-                break;
-            case 2:
-                sprintf (str, "structure=Word");
-                break;
-            case 3:
-                sprintf (str, "structure=Key");
-                break;
-            case 4:
-                sprintf (str, "structure=Year");
-                break;
-            case 5:
-                sprintf (str, "structure=Date");
-                break;
-            case 6:
-                sprintf (str, "structure=Word list");
-                break;
-            case 100:
-                sprintf (str, "structure=Date (un)");
-                break;
-            case 101:
-                sprintf (str, "structure=Name (norm)");
-                break;
-            case 102:
-                sprintf (str, "structure=Name (un)");
-                break;
-            case 103:
-                sprintf (str, "structure=Structure");
-                break;
-            case 104:
-                sprintf (str, "structure=urx");
-                break;
-            case 105:
-                sprintf (str, "structure=free-form-text");
-                break;
-            case 106:
-                sprintf (str, "structure=document-text");
-                break;
-            case 107:
-                sprintf (str, "structure=local-number");
-                break;
-            case 108:
-                sprintf (str, "structure=string");
-                break;
-            case 109:
-                sprintf (str, "structure=numeric string");
-                break;
-            default:
-                sprintf (str, "structure");
-            }
-            break;
-        case 5:
-            switch (value)
-            {
-            case 1:
-                sprintf (str, "truncation=Right");
-                break;
-            case 2:
-                sprintf (str, "truncation=Left");
-                break;
-            case 3:
-                sprintf (str, "truncation=Left&right");
-                break;
-            case 100:
-                sprintf (str, "truncation=Do not truncate");
-                break;
-            case 101:
-                sprintf (str, "truncation=Process #");
-                break;
-            case 102:
-                sprintf (str, "truncation=re-1");
-                break;
-            case 103:
-                sprintf (str, "truncation=re-2");
-                break;
-            default:
-                sprintf (str, "truncation");
-            }
-            break;
-        case 6:
-            switch (value)
-            {
-            case 1:
-                sprintf (str, "completeness=Incomplete subfield");
-                break;
-            case 2:
-                sprintf (str, "completeness=Complete subfield");
-                break;
-            case 3:
-                sprintf (str, "completeness=Complete field");
-                break;
-            default:
-                sprintf (str, "completeness");
-            }
-            break;
-        }
-        break;
-    default:
-        break;
-    }
-    if (*str)
-        sprintf (str + strlen(str), " (%d=%d)", type, value);
-    else
-        sprintf (str, "%d=%d", type, value);
-}
-
-/*
- * zlog_attributes: print attributes of term
- */
-static void zlog_attributes (Z_AttributesPlusTerm *t, int level,
-                             enum oid_value ast)
-{
-    int of, i;
-    char str[80];
-#ifdef ASN_COMPILED
-    int num_attributes = t->attributes->num_attributes;
-#else
-    int num_attributes = t->num_attributes;
-#endif
-    
-    for (of = 0; of < num_attributes; of++)
-    {
-       const char *attset_name = "";
-        Z_AttributeElement *element;
-#ifdef ASN_COMPILED
-       element = t->attributes->attributes[of];
-#else
-        element = t->attributeList[of];
-#endif
-       if (element->attributeSet)
-       {
-           oident *attrset;
-           attrset = oid_getentbyoid (element->attributeSet);
-           attset_name = attrset->desc;
-       }
-        switch (element->which) 
-        {
-        case Z_AttributeValue_numeric:
-           attrStr (*element->attributeType,
-                    *element->value.numeric, ast, str);
-            logf (LOG_LOG, "%*.0s%s %s", level, "", attset_name, str);
-            break;
-        case Z_AttributeValue_complex:
-            logf (LOG_LOG, "%*.0s%s attributeType=%d complex",
-                 level, "", attset_name, *element->attributeType);
-            for (i = 0; i<element->value.complex->num_list; i++)
-            {
-                if (element->value.complex->list[i]->which ==
-                    Z_StringOrNumeric_string)
-                    logf (LOG_LOG, "%*.0s  string: '%s'", level, "",
-                          element->value.complex->list[i]->u.string);
-                else if (element->value.complex->list[i]->which ==
-                         Z_StringOrNumeric_numeric)
-                    logf (LOG_LOG, "%*.0s  numeric: '%d'", level, "",
-                          *element->value.complex->list[i]->u.numeric);
-            }
-            break;
-        default:
-            logf (LOG_LOG, "%.*s%s attribute unknown",
-                 level, "", attset_name);
-        }
-    }
-}
-
-static void zlog_structure (Z_RPNStructure *zs, int level, enum oid_value ast)
-{
-    if (zs->which == Z_RPNStructure_complex)
-    {
-        switch (zs->u.complex->roperator->which)
-        {
-        case Z_Operator_and:
-            logf (LOG_LOG, "%*.0s and", level, "");
-            break;
-        case Z_Operator_or:
-            logf (LOG_LOG, "%*.0s or", level, "");
-            break;
-        case Z_Operator_and_not:
-            logf (LOG_LOG, "%*.0s and-not", level, "");
-            break;
-        default:
-            logf (LOG_LOG, "%*.0s unknown complex", level, "");
-            return;
-        }
-        zlog_structure (zs->u.complex->s1, level+2, ast);
-        zlog_structure (zs->u.complex->s2, level+2, ast);
-    }
-    else if (zs->which == Z_RPNStructure_simple)
-    {
-        if (zs->u.simple->which == Z_Operand_APT)
-        {
-            Z_AttributesPlusTerm *zapt = zs->u.simple->u.attributesPlusTerm;
-
-            if (zapt->term->which == Z_Term_general) 
-            {
-                logf (LOG_LOG, "%*.0s term '%.*s' (general)", level, "",
-                      zapt->term->u.general->len, zapt->term->u.general->buf);
-            }
-            else
-            {
-                logf (LOG_LOG, "%*.0s term (not general)", level, "");
-            }
-            zlog_attributes (zapt, level+2, ast);
-        }
-        else if (zs->u.simple->which == Z_Operand_resultSetId)
-        {
-            logf (LOG_LOG, "%*.0s set '%s'", level, "",
-                  zs->u.simple->u.resultSetId);
-        }
-        else
-            logf (LOG_LOG, "%*.0s unknown simple structure", level, "");
-    }
-    else
-        logf (LOG_LOG, "%*.0s unknown structure", level, "");
-}
-
-void log_rpn_query (Z_RPNQuery *rpn)
-{
-    oident *attrset;
-    enum oid_value ast;
-    
-    attrset = oid_getentbyoid (rpn->attributeSetId);
-    if (attrset)
-    {
-        ast = attrset->value;
-       logf (LOG_LOG, "RPN query. Type: %s", attrset->desc);
-    } 
-    else
-    {
-       ast = VAL_NONE;
-       logf (LOG_LOG, "RPN query. Unknown type");
-    }
-    zlog_structure (rpn->RPNStructure, 0, ast);
-}
-
-void log_scan_term (Z_AttributesPlusTerm *zapt, oid_value ast)
-{
-    int level = 0;
-    if (zapt->term->which == Z_Term_general) 
-    {
-       logf (LOG_LOG, "%*.0s term '%.*s' (general)", level, "",
-             zapt->term->u.general->len, zapt->term->u.general->buf);
-    }
-    else
-       logf (LOG_LOG, "%*.0s term (not general)", level, "");
-    zlog_attributes (zapt, level+2, ast);
-}
diff --git a/util/matchstr.c b/util/matchstr.c
new file mode 100644 (file)
index 0000000..e30a47d
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 1995-1997, Index Data.
+ * See the file LICENSE for details.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * $Log: matchstr.c,v $
+ * Revision 1.1  1999-06-08 10:10:16  adam
+ * New sub directory zutil. Moved YAZ Compiler to be part of YAZ tree.
+ *
+ * Revision 1.7  1997/09/30 11:47:47  adam
+ * Added function 'cause checkergcc doesn't include assert handler.
+ *
+ * Revision 1.6  1997/09/04 07:54:34  adam
+ * Right hande side operand of yaz_matchstr may include a ? in
+ * which case it returns "match ok".
+ *
+ * Revision 1.5  1997/07/21 12:48:11  adam
+ * Removed windows DLL stubs.
+ *
+ * Revision 1.4  1997/05/01 15:07:55  adam
+ * Added DLL entry point routines.
+ *
+ * Revision 1.3  1996/10/29 13:36:28  adam
+ * Added header.
+ *
+ * Revision 1.2  1996/02/20 17:58:42  adam
+ * Added const to yaz_matchstr.
+ *
+ * Revision 1.1  1996/02/20  16:33:06  quinn
+ * Moved matchstr to global util
+ *
+ * Revision 1.1  1995/11/01  11:56:08  quinn
+ * Added Retrieval (data management) functions en masse.
+ *
+ *
+ */
+#include <stdio.h>
+#include <assert.h>
+#include <ctype.h>
+#include <yaz-util.h>
+
+/*
+ * Match strings, independently of case and occurences of '-'.
+ * fairly inefficient - will be replaced with an indexing scheme for
+ * the various subsystems if we get a bottleneck here.
+ */
+
+int yaz_matchstr(const char *s1, const char *s2)
+{
+    while (*s1 && *s2)
+    {
+       char c1, c2;
+
+        if (*s2 == '?')
+            return 0;
+       if (*s1 == '-')
+           s1++;
+       if (*s2 == '-')
+           s2++;
+       if (!*s1 || !*s2)
+           break;
+       c1 = *s1;
+       c2 = *s2;
+       if (isupper(c1))
+           c1 = tolower(c1);
+       if (isupper(c2))
+           c2 = tolower(c2);
+       if (c1 != c2)
+           break;
+       s1++;
+       s2++;
+    }
+    return *s1 || *s2;
+}
+
+#ifdef __GNUC__
+#ifdef __CHECKER__
+void __assert_fail (const char *assertion, const char *file, 
+                    unsigned int line, const char *function)
+{
+    fprintf (stderr, "%s in file %s line %d func %s\n",
+             assertion, file, line, function);
+    abort ();
+}
+#endif
+#endif
diff --git a/util/otherinfo.c b/util/otherinfo.c
deleted file mode 100644 (file)
index ced403e..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (c) 1999, Index Data
- * See the file LICENSE for details.
- * Sebastian Hammer, Adam Dickmeiss
- *
- * $Log: otherinfo.c,v $
- * Revision 1.1  1999-04-26 07:25:25  adam
- * Implemented OtherInfo utility.
- *
- */
-
-#include <stdio.h>
-#include <string.h>
-
-#include <otherinfo.h>
-
-void yaz_oi_APDU(Z_APDU *apdu, Z_OtherInformation ***oip)
-{
-    switch (apdu->which)
-    {
-    case Z_APDU_initRequest:
-       *oip = &apdu->u.initRequest->otherInfo;
-       break;
-    case Z_APDU_searchRequest:
-       *oip = &apdu->u.searchRequest->otherInfo;
-       break;
-    case Z_APDU_presentRequest:
-       *oip = &apdu->u.presentRequest->otherInfo;
-       break;
-    case Z_APDU_sortRequest:
-       *oip = &apdu->u.sortRequest->otherInfo;
-       break;
-    case Z_APDU_scanRequest:
-       *oip = &apdu->u.scanRequest->otherInfo;
-       break;
-    case Z_APDU_initResponse:
-       *oip = &apdu->u.initResponse->otherInfo;
-       break;
-    case Z_APDU_searchResponse:
-       *oip = &apdu->u.searchResponse->otherInfo;
-       break;
-    case Z_APDU_presentResponse:
-       *oip = &apdu->u.presentResponse->otherInfo;
-       break;
-    case Z_APDU_sortResponse:
-       *oip = &apdu->u.sortResponse->otherInfo;
-       break;
-    case Z_APDU_scanResponse:
-       *oip = &apdu->u.scanResponse->otherInfo;
-       break;
-    default:
-       *oip = 0;
-       break;
-    }
-}
-
-Z_OtherInformationUnit *yaz_oi_update (
-    Z_OtherInformation **otherInformationP, ODR odr,
-    int *oid, int categoryValue)
-{
-    int i;
-    Z_OtherInformation *otherInformation = *otherInformationP;
-    if (!otherInformation)
-    {
-       if (!odr)
-           return 0;
-       otherInformation = *otherInformationP = (Z_OtherInformation *)
-           odr_malloc (odr, sizeof(*otherInformation));
-       otherInformation->num_elements = 0;
-       otherInformation->list = 0;
-    }
-    for (i = 0; i<otherInformation->num_elements; i++)
-    {
-       if (!oid)
-       {
-           if (!otherInformation->list[i]->category)
-               return otherInformation->list[i];
-       }
-       else
-       {
-           if (otherInformation->list[i]->category &&
-               categoryValue ==
-               *otherInformation->list[i]->category->categoryValue &&
-               !oid_oidcmp (oid, otherInformation->list[i]->category->
-                            categoryTypeId))
-               return otherInformation->list[i];
-       }
-    }
-    if (!odr)
-       return 0;
-    else
-    {
-       Z_OtherInformationUnit **newlist = (Z_OtherInformationUnit**)
-           odr_malloc(odr, otherInformation->num_elements+1 *
-                      sizeof(*newlist));
-       for (i = 0; i<otherInformation->num_elements; i++)
-           newlist[i] = otherInformation->list[i];
-       otherInformation->list = newlist;
-       
-       otherInformation->list[i] = (Z_OtherInformationUnit*)
-           odr_malloc (odr, sizeof(Z_OtherInformationUnit));
-       if (oid)
-       {
-           otherInformation->list[i]->category = (Z_InfoCategory*)
-               odr_malloc (odr, sizeof(Z_InfoCategory));
-           otherInformation->list[i]->category->categoryTypeId = (int*)
-               odr_oiddup (odr, oid);
-           otherInformation->list[i]->category->categoryValue = (int*)
-               odr_malloc (odr, sizeof(int));
-           *otherInformation->list[i]->category->categoryValue =
-               categoryValue;
-       }
-       else
-           otherInformation->list[i]->category = 0;
-       otherInformation->list[i]->which = Z_OtherInfo_characterInfo;
-       otherInformation->list[i]->information.characterInfo = 0;
-       
-       otherInformation->num_elements = i+1;
-       return otherInformation->list[i];
-    }
-}
-
-void yaz_oi_set_string_oid (
-    Z_OtherInformation **otherInformation, ODR odr,
-    int *oid, int categoryValue,
-    const char *str)
-{
-    Z_OtherInformationUnit *oi =
-       yaz_oi_update(otherInformation, odr, oid, categoryValue);
-    if (!oi)
-       return;
-    oi->which = Z_OtherInfo_characterInfo;
-    oi->information.characterInfo = odr_strdup (odr, str);
-}
-
-void yaz_oi_set_string_oidval (
-    Z_OtherInformation **otherInformation, ODR odr,
-    int oidval, int categoryValue,
-    const char *str)
-{
-    int oid[OID_SIZE];
-    struct oident ent;
-    ent.proto = PROTO_Z3950;
-    ent.oclass = CLASS_USERINFO;
-    ent.value = (oid_value) oidval;
-    if (!oid_ent_to_oid (&ent, oid))
-       return ;
-    yaz_oi_set_string_oid(otherInformation,
-                         odr, oid, categoryValue, str);
-}
-
-char *yaz_oi_get_string_oid (
-    Z_OtherInformation **otherInformation,
-    int *oid, int categoryValue)
-{
-    Z_OtherInformationUnit *oi;
-    
-    if ((oi = yaz_oi_update(otherInformation, 0, oid, 1)) &&
-       oi->which == Z_OtherInfo_characterInfo)
-       return oi->information.characterInfo;
-    return 0;
-}
-
-char *yaz_oi_get_string_oidval(Z_OtherInformation **otherInformation,
-                               int oidval, int categoryValue)    
-{
-    int oid[OID_SIZE];
-    struct oident ent;
-    ent.proto = PROTO_Z3950;
-    ent.oclass = CLASS_USERINFO;
-    ent.value = (oid_value) oidval;
-
-    if (!oid_ent_to_oid (&ent, oid))
-       return 0;
-    return yaz_oi_get_string_oid (otherInformation, oid, categoryValue);
-}
-
diff --git a/util/pquery.c b/util/pquery.c
deleted file mode 100644 (file)
index 0225178..0000000
+++ /dev/null
@@ -1,614 +0,0 @@
-/*
- * Copyright (c) 1995-1998, Index Data.
- * See the file LICENSE for details.
- * Sebastian Hammer, Adam Dickmeiss
- *
- * $Log: pquery.c,v $
- * Revision 1.22  1999-04-20 09:56:49  adam
- * Added 'name' paramter to encoder/decoder routines (typedef Odr_fun).
- * Modified all encoders/decoders to reflect this change.
- *
- * Revision 1.21  1998/10/13 16:03:37  adam
- * Better checking for invalid OID's in p_query_rpn.
- *
- * 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
- * Changed code so that it compiles as C++.
- *
- * Revision 1.17  1997/11/24 11:33:57  adam
- * Using function odr_nullval() instead of global ODR_NULLVAL when
- * appropriate.
- *
- * Revision 1.16  1997/09/29 13:19:00  adam
- * Added function, oid_ent_to_oid, to replace the function
- * oid_getoidbyent, which is not thread safe.
- *
- * Revision 1.15  1997/09/29 07:13:43  adam
- * Changed type of a few variables to avoid warnings.
- *
- * Revision 1.14  1997/09/22 12:33:41  adam
- * Fixed bug introduced by previous commit.
- *
- * Revision 1.13  1997/09/17 12:10:42  adam
- * YAZ version 1.4.
- *
- * Revision 1.12  1997/09/01 08:54:13  adam
- * New windows NT/95 port using MSV5.0. Made prefix query handling
- * thread safe. The function options ignores empty arguments when met.
- *
- * Revision 1.11  1996/11/11 13:15:29  adam
- * Added proximity operator.
- *
- * Revision 1.10  1996/08/12 14:10:35  adam
- * New function p_query_attset to define default attribute set.
- *
- * Revision 1.9  1996/03/15  11:03:46  adam
- * Attribute set can be set globally for a query with the @attrset
- * operator. The @attr operator has an optional attribute-set specifier
- * that sets the attribute set locally.
- *
- * Revision 1.8  1996/01/02  11:46:56  quinn
- * Changed 'operator' to 'roperator' to avoid C++ conflict.
- *
- * Revision 1.7  1995/09/29  17:12:36  quinn
- * Smallish
- *
- * Revision 1.6  1995/09/27  15:03:03  quinn
- * Modified function heads & prototypes.
- *
- * Revision 1.5  1995/06/15  12:31:02  quinn
- * *** empty log message ***
- *
- * Revision 1.4  1995/06/15  07:45:19  quinn
- * Moving to v3.
- *
- * Revision 1.3  1995/06/14  11:06:35  adam
- * Bug fix: Attributes wasn't interpreted correctly!
- *
- * Revision 1.2  1995/05/26  08:56:11  adam
- * New function: p_query_scan.
- *
- * Revision 1.1  1995/05/22  15:31:49  adam
- * New function, p_query_rpn, to convert from prefix (ascii) to rpn (asn).
- *
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include <proto.h>
-#include <oid.h>
-
-#include <pquery.h>
-
-static oid_value p_query_dfset = VAL_NONE;
-
-struct lex_info {
-    const char *query_buf;
-    const char *lex_buf;
-    size_t lex_len;
-    int query_look;
-    char *left_sep;
-    char *right_sep;
-    int escape_char;
-    int term_type;
-};
-
-static Z_RPNStructure *rpn_structure (struct lex_info *li, ODR o, oid_proto, 
-                                      int num_attr, int max_attr, 
-                                      int *attr_list, oid_value *attr_set);
-
-static enum oid_value query_oid_getvalbyname (struct lex_info *li)
-{
-    enum oid_value value;
-    char buf[32];
-
-    if (li->lex_len > 31)
-        return VAL_NONE;
-    memcpy (buf, li->lex_buf, li->lex_len);
-    buf[li->lex_len] = '\0';
-    value = oid_getvalbyname (buf);
-    return value;
-}
-
-static int compare_term (struct lex_info *li, const char *src, size_t off)
-{
-    size_t len=strlen(src);
-
-    if (li->lex_len == len+off && !memcmp (li->lex_buf+off, src, len-off))
-       return 1;
-    return 0;
-}
-
-static int query_token (struct lex_info *li)
-{
-    const char *sep_match;
-    const char **qptr = &li->query_buf;
-
-    while (**qptr == ' ')
-        (*qptr)++;
-    if (**qptr == '\0')
-        return 0;
-    li->lex_len = 0;
-    if ((sep_match = strchr (li->left_sep, **qptr)))
-    {
-        int sep_index = sep_match - li->left_sep;
-        
-        ++(*qptr);
-        li->lex_buf = *qptr;
-        while (**qptr && **qptr != li->right_sep[sep_index])
-        {
-            ++(li->lex_len);
-            ++(*qptr);
-        }
-        if (**qptr)
-            ++(*qptr);
-    }
-    else
-    {
-        li->lex_buf = *qptr;
-        while (**qptr && **qptr != ' ')
-        {
-            ++(li->lex_len);
-            ++(*qptr);
-        }
-    }
-    if (li->lex_len >= 1 && li->lex_buf[0] == li->escape_char)
-    {
-       if (compare_term (li, "and", 1))
-           return 'a';
-        if (compare_term (li, "or", 1))
-            return 'o';
-        if (compare_term (li, "not", 1))
-            return 'n';
-        if (compare_term (li, "attr", 1))
-            return 'l';
-        if (compare_term (li, "set", 1))
-            return 's';
-        if (compare_term (li, "attrset", 1))
-            return 'r';
-        if (compare_term (li, "prox", 1))
-            return 'p';
-        if (compare_term (li, "term", 1))
-            return 'y';
-    }
-    return 't';
-}
-
-static int lex (struct lex_info *li)
-{
-    return li->query_look = query_token (li);
-}
-
-static Z_AttributesPlusTerm *rpn_term (struct lex_info *li, ODR o,
-                                       oid_proto proto, 
-                                       int num_attr, int *attr_list,
-                                       oid_value *attr_set)
-{
-    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));
-
-    if (!num_attr)
-        elements = (Z_AttributeElement**)odr_nullval();
-    else
-    {
-        int i;
-        int *attr_tmp;
-
-        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++)
-        {
-            elements[i] =
-                (Z_AttributeElement*)odr_malloc (o,sizeof(**elements));
-            elements[i]->attributeType = &attr_tmp[2*i];
-            if (attr_set[i] == VAL_NONE)
-                elements[i]->attributeSet = 0;
-            else
-            {
-                oident attrid;
-                int oid[OID_SIZE];
-               
-                attrid.proto = PROTO_Z3950;
-                attrid.oclass = CLASS_ATTSET;
-                attrid.value = attr_set[i];
-                   
-                elements[i]->attributeSet =
-                   odr_oiddup (o, oid_ent_to_oid (&attrid, oid));
-            }
-           elements[i]->which = Z_AttributeValue_numeric;
-           elements[i]->value.numeric = &attr_tmp[2*i+1];
-        }
-    }
-#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;
-    term_octet->buf = (unsigned char *)odr_malloc (o, li->lex_len);
-    term_octet->size = term_octet->len = li->lex_len;
-    memcpy (term_octet->buf, li->lex_buf, li->lex_len);
-    return zapt;
-}
-
-static Z_Operand *rpn_simple (struct lex_info *li, ODR o, oid_proto proto,
-                              int num_attr, int *attr_list,
-                              oid_value *attr_set)
-{
-    Z_Operand *zo;
-
-    zo = (Z_Operand *)odr_malloc (o, sizeof(*zo));
-    switch (li->query_look)
-    {
-    case 't':
-        zo->which = Z_Operand_APT;
-        if (!(zo->u.attributesPlusTerm =
-              rpn_term (li, o, proto, num_attr, attr_list, attr_set)))
-            return NULL;
-        lex (li);
-        break;
-    case 's':
-        lex (li);
-        if (!li->query_look)
-            return NULL;
-        zo->which = Z_Operand_resultSetId;
-        zo->u.resultSetId = (char *)odr_malloc (o, li->lex_len+1);
-        memcpy (zo->u.resultSetId, li->lex_buf, li->lex_len);
-        zo->u.resultSetId[li->lex_len] = '\0';
-        lex (li);
-        break;
-    default:
-        return NULL;
-    }
-    return zo;
-}
-
-static Z_ProximityOperator *rpn_proximity (struct lex_info *li, ODR o)
-{
-    Z_ProximityOperator *p = (Z_ProximityOperator *)odr_malloc (o, sizeof(*p));
-
-    if (!lex (li))
-        return NULL;
-    if (*li->lex_buf == '1')
-    {
-        p->exclusion = (int *)odr_malloc (o, sizeof(*p->exclusion));
-        *p->exclusion = 1;
-    } 
-    else if (*li->lex_buf == '0')
-    {
-        p->exclusion = (int *)odr_malloc (o, sizeof(*p->exclusion));
-        *p->exclusion = 0;
-    }
-    else
-        p->exclusion = NULL;
-
-    if (!lex (li))
-        return NULL;
-    p->distance = (int *)odr_malloc (o, sizeof(*p->distance));
-    *p->distance = atoi (li->lex_buf);
-
-    if (!lex (li))
-        return NULL;
-    p->ordered = (int *)odr_malloc (o, sizeof(*p->ordered));
-    *p->ordered = atoi (li->lex_buf);
-    
-    if (!lex (li))
-        return NULL;
-    p->relationType = (int *)odr_malloc (o, sizeof(*p->relationType));
-    *p->relationType = atoi (li->lex_buf);
-
-    if (!lex (li))
-        return NULL;
-    if (*li->lex_buf == 'k')
-        p->which = 0;
-    else if (*li->lex_buf == 'p')
-        p->which = 1;
-    else
-        p->which = atoi (li->lex_buf);
-
-    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;
-}
-
-static Z_Complex *rpn_complex (struct lex_info *li, ODR o, oid_proto proto,
-                               int num_attr, int max_attr, 
-                               int *attr_list, oid_value *attr_set)
-{
-    Z_Complex *zc;
-    Z_Operator *zo;
-
-    zc = (Z_Complex *)odr_malloc (o, sizeof(*zc));
-    zo = (Z_Operator *)odr_malloc (o, sizeof(*zo));
-    zc->roperator = zo;
-    switch (li->query_look)
-    {
-    case 'a':
-        zo->which = Z_Operator_and;
-        zo->u.and = odr_nullval();
-        break;
-    case 'o':
-        zo->which = Z_Operator_or;
-        zo->u.and = odr_nullval();
-        break;
-    case 'n':
-        zo->which = Z_Operator_and_not;
-        zo->u.and = odr_nullval();
-        break;
-    case 'p':
-        zo->which = Z_Operator_prox;
-        zo->u.prox = rpn_proximity (li, o);
-        if (!zo->u.prox)
-            return NULL;
-        break;
-    default:
-        return NULL;
-    }
-    lex (li);
-    if (!(zc->s1 =
-          rpn_structure (li, o, proto, num_attr, max_attr, attr_list,
-                         attr_set)))
-        return NULL;
-    if (!(zc->s2 =
-          rpn_structure (li, o, proto, num_attr, max_attr, attr_list,
-                         attr_set)))
-        return NULL;
-    return zc;
-}
-
-static Z_RPNStructure *rpn_structure (struct lex_info *li, ODR o,
-                                      oid_proto proto, 
-                                      int num_attr, int max_attr, 
-                                      int *attr_list, oid_value *attr_set)
-{
-    Z_RPNStructure *sz;
-    const char *cp;
-
-    sz = (Z_RPNStructure *)odr_malloc (o, sizeof(*sz));
-    switch (li->query_look)
-    {
-    case 'a':
-    case 'o':
-    case 'n':
-    case 'p':
-        sz->which = Z_RPNStructure_complex;
-        if (!(sz->u.complex =
-              rpn_complex (li, o, proto, num_attr, max_attr, attr_list,
-                           attr_set)))
-            return NULL;
-        break;
-    case 't':
-    case 's':
-        sz->which = Z_RPNStructure_simple;
-        if (!(sz->u.simple =
-              rpn_simple (li, o, proto, num_attr, attr_list,
-                          attr_set)))
-            return NULL;
-        break;
-    case 'l':
-        lex (li);
-        if (!li->query_look)
-            return NULL;
-        if (num_attr >= max_attr)
-            return NULL;
-        if (!(cp = strchr (li->lex_buf, '=')) ||
-            (size_t) (cp-li->lex_buf) > li->lex_len)
-        {
-            attr_set[num_attr] = query_oid_getvalbyname (li);
-           if (attr_set[num_attr] == VAL_NONE)
-               return NULL;
-            lex (li);
-
-            if (!(cp = strchr (li->lex_buf, '=')))
-                return NULL;
-        }
-        else 
-        {
-            if (num_attr > 0)
-                attr_set[num_attr] = attr_set[num_attr-1];
-            else
-                attr_set[num_attr] = VAL_NONE;
-        }
-        attr_list[2*num_attr] = atoi (li->lex_buf);
-        attr_list[2*num_attr+1] = atoi (cp+1);
-        num_attr++;
-        lex (li);
-        return
-            rpn_structure (li, o, proto, num_attr, max_attr, attr_list,
-                           attr_set);
-    case 'y':
-       lex (li);
-       if (!li->query_look)
-           return NULL;
-       if (compare_term (li, "general", 0))
-           li->term_type = Z_Term_general;
-       else if (compare_term (li, "numeric", 0))
-           li->term_type = Z_Term_numeric;
-       else if (compare_term (li, "string", 0))
-           li->term_type = Z_Term_characterString;
-       else if (compare_term (li, "oid", 0))
-           li->term_type = Z_Term_oid;
-       else if (compare_term (li, "datetime", 0))
-           li->term_type = Z_Term_dateTime;
-       else if (compare_term (li, "null", 0))
-           li->term_type = Z_Term_null;
-       lex (li);
-        return
-            rpn_structure (li, o, proto, num_attr, max_attr, attr_list,
-                           attr_set);
-    case 0:                /* operator/operand expected! */
-        return NULL;
-    }
-    return sz;
-}
-
-Z_RPNQuery *p_query_rpn_mk (ODR o, struct lex_info *li, oid_proto proto,
-                            const char *qbuf)
-{
-    Z_RPNQuery *zq;
-    int attr_array[1024];
-    oid_value attr_set[512];
-    oid_value topSet = VAL_NONE;
-    oident oset;
-    int oid[OID_SIZE];
-
-    zq = (Z_RPNQuery *)odr_malloc (o, sizeof(*zq));
-    lex (li);
-    if (li->query_look == 'r')
-    {
-        lex (li);
-        topSet = query_oid_getvalbyname (li);
-        if (topSet == VAL_NONE)
-            return NULL;
-
-        lex (li);
-    }
-    if (topSet == VAL_NONE)
-        topSet = p_query_dfset;
-    if (topSet == VAL_NONE)
-        topSet = VAL_BIB1;
-    oset.proto = proto;
-    oset.oclass = CLASS_ATTSET;
-    oset.value = topSet;
-
-    if (!oid_ent_to_oid (&oset, oid))
-       return NULL;
-    zq->attributeSetId = odr_oiddup (o, oid);
-
-    if (!(zq->RPNStructure = rpn_structure (li, o, proto, 0, 512,
-                                            attr_array, attr_set)))
-        return NULL;
-    return zq;
-}
-
-Z_RPNQuery *p_query_rpn (ODR o, oid_proto proto,
-                         const char *qbuf)
-{
-    struct lex_info li;
-    
-    li.left_sep = "{\"";
-    li.right_sep = "}\"";
-    li.escape_char = '@';
-    li.term_type = Z_Term_general;
-    li.query_buf = qbuf;
-    return p_query_rpn_mk (o, &li, proto, qbuf);
-}
-
-Z_AttributesPlusTerm *p_query_scan_mk (struct lex_info *li,
-                                       ODR o, oid_proto proto,
-                                       Odr_oid **attributeSetP,
-                                       const char *qbuf)
-{
-    int attr_list[1024];
-    oid_value attr_set[512];
-    int num_attr = 0;
-    int max_attr = 512;
-    const char *cp;
-    oid_value topSet = VAL_NONE;
-    oident oset;
-    int oid[OID_SIZE];
-
-    lex (li);
-    if (li->query_look == 'r')
-    {
-        lex (li);
-        topSet = query_oid_getvalbyname (li);
-
-        lex (li);
-    }
-    if (topSet == VAL_NONE)
-        topSet = p_query_dfset;
-    if (topSet == VAL_NONE)
-        topSet = VAL_BIB1;
-    oset.proto = proto;
-    oset.oclass = CLASS_ATTSET;
-    oset.value = topSet;
-
-    *attributeSetP = odr_oiddup (o, oid_ent_to_oid (&oset, oid));
-
-    while (li->query_look == 'l')
-    {
-        lex (li);
-        if (!li->query_look)
-            return NULL;
-        if (num_attr >= max_attr)
-            return NULL;
-
-        if (!(cp = strchr (li->lex_buf, '=')) ||
-            (size_t) (cp-li->lex_buf) > li->lex_len)
-        {
-            attr_set[num_attr] = query_oid_getvalbyname (li);
-            lex (li);
-
-            if (!(cp = strchr (li->lex_buf, '=')))
-                return NULL;
-        }
-        else
-        {
-            if (num_attr > 0)
-                attr_set[num_attr] = attr_set[num_attr-1];
-            else
-                attr_set[num_attr] = VAL_NONE;
-        }
-        attr_list[2*num_attr] = atoi (li->lex_buf);
-        attr_list[2*num_attr+1] = atoi (cp+1);
-        num_attr++;
-        lex (li);
-    }
-    if (!li->query_look)
-        return NULL;
-    return rpn_term (li, o, proto, num_attr, attr_list, attr_set);
-}
-
-Z_AttributesPlusTerm *p_query_scan (ODR o, oid_proto proto,
-                                    Odr_oid **attributeSetP,
-                                    const char *qbuf)
-{
-    struct lex_info li;
-
-    li.left_sep = "{\"";
-    li.right_sep = "}\"";
-    li.escape_char = '@';
-    li.term_type = Z_Term_general;
-    li.query_buf = qbuf;
-
-    return p_query_scan_mk (&li, o, proto, attributeSetP, qbuf);
-}
-
-int p_query_attset (const char *arg)
-{
-    p_query_dfset = oid_getvalbyname (arg);
-    return (p_query_dfset == VAL_NONE) ? -1 : 0;
-}
-
diff --git a/util/query.c b/util/query.c
deleted file mode 100644 (file)
index 6b3236b..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (c) 1995, Index Data
- * See the file LICENSE for details.
- * Sebastian Hammer, Adam Dickmeiss
- *
- * $Log: query.c,v $
- * Revision 1.3  1996-01-02 11:46:56  quinn
- * Changed 'operator' to 'roperator' to avoid C++ conflict.
- *
- * Revision 1.2  1995/05/16  08:51:14  quinn
- * License, documentation, and memory fixes
- *
- * Revision 1.1  1995/04/10  10:28:47  quinn
- * Added copy of CCL and MARC display
- *
- *
- */
-
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-
-#include <odr.h>
-#include <proto.h>
-
-static Z_Complex *makecomplex(ODR o, char **buf);
-static Z_Operand *makesimple(ODR o, char **buf);
-Z_RPNStructure *makerpn(ODR o, char **buf);
-
-void skip_spaces(char**p)
-{
-    while (**p && isspace(**p))
-       (*p)++;
-}
-
-static Z_Operand *makesimple(ODR o, char **buf)
-{
-    Z_Operand *r;
-    Z_AttributesPlusTerm *t;
-    char *b;
-
-    r = odr_malloc(o, sizeof(*r));
-    if (**buf == 's' && *((*buf) + 1) == '=')
-    {
-       char *b = odr_malloc(o, 100);
-
-       r->which = Z_Operand_resultSetId;
-       r->u.resultSetId = b;
-       (*buf)++;
-       (*buf)++;
-       while (**buf && !isspace(**buf))
-           *(b++) = *((*buf)++);
-       *b = 0;
-       return r;
-    }
-    else if (**buf != '"')
-       return 0;
-    (*buf)++;
-    r->which = Z_Operand_APT;
-    r->u.attributesPlusTerm = t = odr_malloc(o, sizeof(*t));
-    t->num_attributes = 0;
-    t->attributeList = 0;
-    t->term = odr_malloc(o, sizeof(*t->term));
-    t->term->which = Z_Term_general;
-    t->term->u.general = odr_malloc(o, sizeof(Odr_oct));
-    t->term->u.general->buf = odr_malloc(o, 100);
-    t->term->u.general->size = 100;
-    t->term->u.general->len = 0;
-    b = (char*) t->term->u.general->buf;
-    while (**buf && **buf != '"')
-    {
-       *(b++) = *((*buf)++);
-       t->term->u.general->len++;
-    }
-    if (**buf != '"')
-       return 0;
-    (*buf)++;
-    return r;
-}
-
-static Z_Complex *makecomplex(ODR o, char **buf)
-{
-    Z_Complex *r;
-    char op[100], *b;
-
-    r = odr_malloc(o, sizeof(*r));
-    r->roperator = odr_malloc(o, sizeof(*r->roperator));
-
-    b = op;
-    while (**buf && !isspace(**buf))
-       *(b++) = *((*buf)++);
-    *b = 0;
-    if (!strcmp(op, "and"))
-       r->roperator->which = Z_Operator_and;
-    else if (!strcmp(op, "or"))
-       r->roperator->which = Z_Operator_or;
-    else if (!strcmp(op, "not"))
-       r->roperator->which = Z_Operator_and_not;
-    r->roperator->u.and = "";
-    while (**buf && !isspace(**buf))
-       (*buf)++;
-    if (!(r->s1 = makerpn(o, buf)))
-       return 0;
-    if (!(r->s2 = makerpn(o, buf)))
-       return 0;
-    return r;
-}
-    
-Z_RPNStructure *makerpn(ODR o, char **buf)
-{
-    Z_RPNStructure *r;
-
-    r = odr_malloc(o, sizeof(*r));
-    skip_spaces(buf);
-    if (**buf == '"' || **buf == 's')
-    {
-       r->which = Z_RPNStructure_simple;
-       if (!(r->u.simple = makesimple(o, buf)))
-           return 0;
-       return r;
-    }
-    r->which = Z_RPNStructure_complex;
-    if (!(r->u.complex = makecomplex(o, buf)))
-       return 0;
-    return r;
-}
diff --git a/util/yaz-ccl.c b/util/yaz-ccl.c
deleted file mode 100644 (file)
index 436d048..0000000
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright (c) 1996-1998, Index Data.
- * See the file LICENSE for details.
- * Sebastian Hammer, Adam Dickmeiss
- *
- * $Log: yaz-ccl.c,v $
- * 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
- * Using function odr_nullval() instead of global ODR_NULLVAL when
- * appropriate.
- *
- * Revision 1.10  1997/09/29 08:58:25  adam
- * Fixed conversion of trees so that true copy is made.
- *
- * Revision 1.9  1997/06/23 10:31:25  adam
- * Added ODR argument to ccl_rpn_query and ccl_scan_query.
- *
- * Revision 1.8  1996/10/29 13:36:27  adam
- * Added header.
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-
-#include <yaz-ccl.h>
-
-static Z_RPNStructure *ccl_rpn_structure (ODR o, struct ccl_rpn_node *p);
-
-static Z_AttributesPlusTerm *ccl_rpn_term (ODR o, struct ccl_rpn_node *p)
-{
-    struct ccl_rpn_attr *attr;
-    int num = 0;
-    Z_AttributesPlusTerm *zapt;
-    Odr_oct *term_octet;
-    Z_Term *term;
-    Z_AttributeElement **elements;
-
-    zapt = (Z_AttributesPlusTerm *)odr_malloc (o, sizeof(*zapt));
-    assert (zapt);
-
-    term_octet = (Odr_oct *)odr_malloc (o, sizeof(*term_octet));
-    assert (term_octet);
-
-    term = (Z_Term *)odr_malloc (o, sizeof(*term));
-    assert(term);
-
-    for (attr = p->u.t.attr_list; attr; attr = attr->next)
-        num++;
-    if (!num)
-        elements = (Z_AttributeElement**)odr_nullval();
-    else
-    {
-        int i = 0;
-       elements = (Z_AttributeElement **)
-           odr_malloc (o, num*sizeof(*elements));
-        for (attr = p->u.t.attr_list; attr; attr = attr->next, i++)
-        {
-            elements[i] = (Z_AttributeElement *)
-               odr_malloc (o, sizeof(**elements));
-            assert (elements[i]);
-            elements[i]->attributeType =
-               (int *)odr_malloc(o, sizeof(int));
-            *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));
-           *elements[i]->value.numeric = attr->value;
-        }
-    }
-#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;
-    term_octet->len = term_octet->size = strlen (p->u.t.term);
-    term_octet->buf = (unsigned char *)odr_malloc (o, term_octet->len+1);
-    strcpy ((char*) term_octet->buf, p->u.t.term);
-    return zapt;
-}
-
-static Z_Operand *ccl_rpn_simple (ODR o, struct ccl_rpn_node *p)
-{
-    Z_Operand *zo;
-
-    zo = (Z_Operand *)odr_malloc (o, sizeof(*zo));
-    assert (zo);
-
-    switch (p->kind)
-    {
-    case CCL_RPN_TERM:
-        zo->which = Z_Operand_APT;
-        zo->u.attributesPlusTerm = ccl_rpn_term (o, p);
-        break;
-    case CCL_RPN_SET:
-        zo->which = Z_Operand_resultSetId;
-        zo->u.resultSetId = p->u.setname;
-        break;
-    default:
-        assert (0);
-    }
-    return zo;
-}
-
-static Z_Complex *ccl_rpn_complex (ODR o, struct ccl_rpn_node *p)
-{
-    Z_Complex *zc;
-    Z_Operator *zo;
-
-    zc = (Z_Complex *)odr_malloc (o, sizeof(*zc));
-    assert (zc);
-    zo = (Z_Operator *)odr_malloc (o, sizeof(*zo));
-    assert (zo);
-
-    zc->roperator = zo;
-    switch (p->kind)
-    {
-    case CCL_RPN_AND:
-        zo->which = Z_Operator_and;
-        zo->u.and = odr_nullval();
-        break;
-    case CCL_RPN_OR:
-        zo->which = Z_Operator_or;
-        zo->u.and = odr_nullval();
-        break;
-    case CCL_RPN_NOT:
-        zo->which = Z_Operator_and_not;
-        zo->u.and = odr_nullval();
-        break;
-    default:
-        assert (0);
-    }
-    zc->s1 = ccl_rpn_structure (o, p->u.p[0]);
-    zc->s2 = ccl_rpn_structure (o, p->u.p[1]);
-    return zc;
-}
-
-static Z_RPNStructure *ccl_rpn_structure (ODR o, struct ccl_rpn_node *p)
-{
-    Z_RPNStructure *zs;
-
-    zs = (Z_RPNStructure *)odr_malloc (o, sizeof(*zs));
-    assert (zs);
-    switch (p->kind)
-    {
-    case CCL_RPN_AND:
-    case CCL_RPN_OR:
-    case CCL_RPN_NOT:
-    case CCL_RPN_PROX:
-        zs->which = Z_RPNStructure_complex;
-        zs->u.complex = ccl_rpn_complex (o, p);
-        break;
-    case CCL_RPN_TERM:
-    case CCL_RPN_SET:
-        zs->which = Z_RPNStructure_simple;
-        zs->u.simple = ccl_rpn_simple (o, p);
-        break;
-    default:
-        assert (0);
-    }
-    return zs;
-}
-
-Z_RPNQuery *ccl_rpn_query (ODR o, struct ccl_rpn_node *p)
-{
-    Z_RPNQuery *zq;
-
-    zq = (Z_RPNQuery *)odr_malloc (o, sizeof(*zq));
-    assert (zq);
-    zq->attributeSetId = NULL;
-    zq->RPNStructure = ccl_rpn_structure (o, p);
-    return zq;
-}
-
-Z_AttributesPlusTerm *ccl_scan_query (ODR o, struct ccl_rpn_node *p)
-{
-    if (p->kind != CCL_RPN_TERM)
-        return NULL;
-    return ccl_rpn_term (o, p);
-}
diff --git a/util/yaz-util.c b/util/yaz-util.c
deleted file mode 100644 (file)
index 40f22c8..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 1995-1997, Index Data.
- * See the file LICENSE for details.
- * Sebastian Hammer, Adam Dickmeiss
- *
- * $Log: yaz-util.c,v $
- * Revision 1.7  1997-09-30 11:47:47  adam
- * Added function 'cause checkergcc doesn't include assert handler.
- *
- * Revision 1.6  1997/09/04 07:54:34  adam
- * Right hande side operand of yaz_matchstr may include a ? in
- * which case it returns "match ok".
- *
- * Revision 1.5  1997/07/21 12:48:11  adam
- * Removed windows DLL stubs.
- *
- * Revision 1.4  1997/05/01 15:07:55  adam
- * Added DLL entry point routines.
- *
- * Revision 1.3  1996/10/29 13:36:28  adam
- * Added header.
- *
- * Revision 1.2  1996/02/20 17:58:42  adam
- * Added const to yaz_matchstr.
- *
- * Revision 1.1  1996/02/20  16:33:06  quinn
- * Moved matchstr to global util
- *
- * Revision 1.1  1995/11/01  11:56:08  quinn
- * Added Retrieval (data management) functions en masse.
- *
- *
- */
-#include <stdio.h>
-#include <assert.h>
-#include <ctype.h>
-#include <yaz-util.h>
-
-/*
- * Match strings, independently of case and occurences of '-'.
- * fairly inefficient - will be replaced with an indexing scheme for
- * the various subsystems if we get a bottleneck here.
- */
-
-int yaz_matchstr(const char *s1, const char *s2)
-{
-    while (*s1 && *s2)
-    {
-       char c1, c2;
-
-        if (*s2 == '?')
-            return 0;
-       if (*s1 == '-')
-           s1++;
-       if (*s2 == '-')
-           s2++;
-       if (!*s1 || !*s2)
-           break;
-       c1 = *s1;
-       c2 = *s2;
-       if (isupper(c1))
-           c1 = tolower(c1);
-       if (isupper(c2))
-           c2 = tolower(c2);
-       if (c1 != c2)
-           break;
-       s1++;
-       s2++;
-    }
-    return *s1 || *s2;
-}
-
-#ifdef __GNUC__
-#ifdef __CHECKER__
-void __assert_fail (const char *assertion, const char *file, 
-                    unsigned int line, const char *function)
-{
-    fprintf (stderr, "%s in file %s line %d func %s\n",
-             assertion, file, line, function);
-    abort ();
-}
-#endif
-#endif
diff --git a/util/yc.tcl b/util/yc.tcl
new file mode 100755 (executable)
index 0000000..76785d3
--- /dev/null
@@ -0,0 +1,1375 @@
+#!/bin/sh
+# the next line restarts using tclsh \
+exec tclsh "$0" "$@"
+#
+# YC: YAZ ODR Compiler
+# (c) Index Data 1996-1998
+# See the file LICENSE for details.
+# Sebastian Hammer, Adam Dickmeiss
+#
+# $Log: yc.tcl,v $
+# Revision 1.1  1999-06-08 10:10:16  adam
+# New sub directory zutil. Moved YAZ Compiler to be part of YAZ tree.
+#
+# Revision 1.8  1999/04/20 10:37:04  adam
+# Updated for ODR - added name parameter.
+#
+# Revision 1.7  1998/04/03 14:44:20  adam
+# Small fix.
+#
+# Revision 1.6  1998/04/03 13:21:17  adam
+# Yet another fix.
+#
+# Revision 1.5  1998/04/03 12:48:17  adam
+# Fixed bug: missed handling of constructed tags for CHOICE.
+#
+# Revision 1.4  1998/03/31 15:47:45  adam
+# First compiled ASN.1 code for YAZ.
+#
+# Revision 1.3  1998/03/23 17:13:20  adam
+# Implemented SET OF and ENUM. The Compiler now eats ILL (ISO10161) and
+# LDAP (RFC1777).
+#
+# Revision 1.2  1997/10/07 10:31:01  adam
+# Added facility to specify tag type (CONTEXT, APPLICATION, ...).
+#
+# Revision 1.1.1.1  1996/10/31 14:04:40  adam
+# First version of the compiler for YAZ.
+#
+#
+
+set yc_version 0.2
+
+# Syntax for the ASN.1 supported:
+# file   -> file module
+#         | module
+# module -> name skip DEFINITIONS ::= mbody END
+# mbody  -> EXPORTS { nlist }
+#         | IMPORTS { imlist }
+#         | name ::= tmt
+#         | skip
+# tmt    -> tag mod type
+# type   -> SEQUENCE { sqlist }
+#         | SEQUENCE OF type
+#         | CHOICE { chlist }
+#         | basic enlist
+#
+# basic  -> INTEGER
+#         | BOOLEAN
+#         | OCTET STRING
+#         | BIT STRING
+#         | EXTERNAL
+#         | name
+# sqlist -> sqlist , name tmt opt
+#         | name tmt opt
+# chlist -> chlist , name tmt 
+#         | name tmt 
+# enlist -> enlist , name (n)
+#         | name (n)
+# imlist -> nlist FROM name
+#           imlist nlist FROM name
+# nlist  -> name
+#         | nlist , name
+# mod   -> IMPLICIT | EXPLICIT | e
+# tag   -> [tagtype n] | [n] | e
+# opt   -> OPTIONAL | e
+#
+# name    identifier/token 
+# e       epsilon/empty 
+# skip    one token skipped
+# n       number
+# tagtype APPLICATION, CONTEXT, etc.
+
+# lex: moves input file pointer and returns type of token.
+# The globals $type and $val are set. $val holds name if token
+# is normal identifier name.
+# sets global var type to one of:
+#     {}     eof-of-file
+#     \{     left curly brace 
+#     \}     right curly brace
+#     ,      comma
+#     ;      semicolon
+#     (      (n)
+#     [      [n]
+#     :      ::=
+#     n      other token n
+proc lex {} {
+    global inf val type
+    while {![string length $inf(str)]} {
+        incr inf(lineno)
+        set inf(cnt) [gets $inf(inf) inf(str)]
+        if {$inf(cnt) < 0} {
+            set type {}
+            return {}
+        }
+       lappend inf(asn,$inf(asndef)) $inf(str)
+        set l [string first -- $inf(str)]
+        if {$l >= 0} {
+            incr l -1
+            set inf(str) [string range $inf(str) 0 $l]
+        }
+        set inf(str) [string trim $inf(str)]
+    }
+    set s [string index $inf(str) 0]
+    set type $s
+    set val {}
+    switch -- $s {
+        \{ { }
+        \} { }
+        ,  { }
+        ;  { }
+       \(  { }
+       \)  { }
+        \[ { regexp {^\[[ ]*(.+)[ ]*\]} $inf(str) s val }
+        :  { regexp {^::=} $inf(str) s }
+        default {
+             regexp "^\[^,\t :\{\}();\]+" $inf(str) s
+             set type n
+             set val $s
+           }
+    }
+    set off [string length $s]
+    set inf(str) [string trim [string range $inf(str) $off end]]
+    return $type
+}
+
+# lex-expect: move pointer and expect token $t
+proc lex-expect {t} {
+    global type val
+    lex
+    if {[string compare $t $type]} {
+        asnError "Got $type '$val', expected $t"
+    }
+}
+
+# lex-name-move: see if token is $name; moves pointer and returns
+# 1 if it is; returns 0 otherwise.
+proc lex-name-move {name} {
+    global type val
+    if {![string compare $type n] && ![string compare $val $name]} {
+        lex
+        return 1
+    }
+    return 0
+}
+
+# asnError: Report error and die
+proc asnError {msg} {
+    global inf
+   
+    puts "Error in line $inf(lineno) in module $inf(module)"
+    puts " $msg"
+    error
+    exit 1
+}
+
+# asnWarning: Report warning and return
+proc asnWarning {msg} {
+    global inf
+   
+    puts "Warning in line $inf(lineno) in module $inf(module)"
+    puts " $msg"
+}
+
+# asnEnum: parses enumerated list - { name1 (n), name2 (n), ... }
+# Uses $name as prefix. If there really is a list, $lx holds the C
+# preprocessor definitions on return; otherwise lx isn't set.
+proc asnEnum {name lx} {
+    global type val inf
+
+    if {[string compare $type \{]} return
+    upvar $lx l
+    while {1} {
+       set pq [asnName $name]
+        set id [lindex $pq 0]
+       set id ${name}_$id
+       lex-expect n
+        lappend l "#define $inf(dprefix)$id $val"
+       lex-expect ")"
+        lex
+        if {[string compare $type ,]} break
+    }
+    if {[string compare $type \}]} {
+        asnError "Missing \} in enum list got $type '$val'"
+    }
+    lex
+}
+
+# asnMod: parses tag and modifier.
+# $xtag and $ximplicit holds tag and implicit-indication on return.
+# $xtag is empty if no tag was specified. $ximplicit is 1 on implicit
+# tagging; 0 otherwise.
+proc asnMod {xtag ximplicit xtagtype} {
+    global type val inf
+
+    upvar $xtag tag
+    upvar $ximplicit implicit
+    upvar $xtagtype tagtype
+
+    set tag {} 
+    set tagtype {}
+    if {![string compare $type \[]} {
+        if {[regexp {^([a-zA-Z]+)[ ]+([0-9]+)$} $val x tagtype tag]} {
+            set tagtype ODR_$tagtype 
+        } elseif {[regexp {^([0-9]+)$} $val x tag]} {
+            set tagtype ODR_CONTEXT
+        } else {
+            asnError "bad tag specification: $val"
+        }
+       lex
+    }
+    set implicit $inf(implicit-tags)
+    if {![string compare $type n]} {
+        if {![string compare $val EXPLICIT]} {
+            lex
+            set implicit 0
+        } elseif {![string compare $val IMPLICIT]} {
+            lex
+            set implicit 1
+        }
+    }
+}
+
+# asnName: moves pointer and expects name. Returns C-validated name.
+proc asnName {name} {
+    global val inf
+    lex-expect n
+    if {[info exists inf(membermap,$inf(module),$name,$val)]} {
+           set nval $inf(membermap,$inf(module),$name,$val)
+       if {$inf(verbose)} {
+           puts " mapping member $name,$val to $nval"
+       }
+       lex
+    } else {
+       set nval $val
+       if {![string match {[A-Z]*} $val]} {
+           lex
+       }
+    }
+    return [join [split $nval -] _]
+}
+
+# asnOptional: parses optional modifier. Returns 1 if OPTIONAL was 
+# specified; 0 otherwise.
+proc asnOptional {} {
+    global type val
+    if {[lex-name-move OPTIONAL]} {
+        return 1
+    } elseif {[lex-name-move DEFAULT]} {
+       lex
+       return 1
+    }
+    return 0
+}
+
+# asnSizeConstraint: parses the optional SizeConstraint.
+# Currently not used for anything.
+proc asnSizeConstraint {} {
+    global type val
+    if {[lex-name-move SIZE]} {
+       asnSubtypeSpec
+    }
+}
+
+# asnSubtypeSpec: parses the SubtypeSpec ...
+# Currently not used for anything. We now it's balanced however, i.e.
+# (... ( ... ) .. )
+proc asnSubtypeSpec {} {
+    global type val
+
+    if {[string compare $type "("]} {
+       return 
+    }
+    lex
+    set level 1
+    while {$level > 0} {
+       if {![string compare $type "("]} {
+           incr level
+       } elseif {![string compare $type ")"]} {
+           incr level -1
+       }
+       lex
+    }
+}
+
+# asnType: parses ASN.1 type.
+# On entry $name should hold the name we are currently defining.
+# Returns type indicator:
+#   SequenceOf     SEQUENCE OF
+#   Sequence       SEQUENCE 
+#   SetOf          SET OF
+#   Set            SET
+#   Choice         CHOICE
+#   Simple         Basic types.
+#   In this casecalling procedure's $tname variable is a list holding:
+#        {C-Function C-Type} if the type is IMPORTed or ODR defined.
+#      or
+#        {C-Function C-Type 1} if the type should be defined in this module
+proc asnType {name} {
+    global type val inf
+    upvar tname tname
+
+    set tname {}
+    if {[string compare $type n]} {
+        asnError "Expects type specifier, but got $type"
+    }
+    set v $val
+    lex
+    switch -- $v {
+        SEQUENCE {
+           asnSizeConstraint
+           if {[lex-name-move OF]} {
+               asnSubtypeSpec
+               return SequenceOf
+           } else {
+               asnSubtypeSpec
+               return Sequence
+           }
+       }
+       SET {
+           asnSizeConstraint
+           if {[lex-name-move OF]} {
+               asnSubtypeSpec
+               return SetOf
+           } else {
+               asnSubtypeSpec
+               return Set
+           }
+        }
+        CHOICE {
+           asnSubtypeSpec
+            return Choice
+        }
+    }
+    if {[string length [info commands asnBasic$v]]} {
+        set tname [asnBasic$v]
+    } else {
+        if {[info exists inf(map,$inf(module),$v)]} {
+            set v $inf(map,$inf(module),$v)
+        }
+        if {[info exists inf(imports,$v)]} {
+            set tname $inf(imports,$v)
+        } else {
+            set w [join [split $v -] _]
+            set tname [list $inf(fprefix)$w $inf(vprefix)$w 1]
+        }
+    }
+    if {[lex-name-move DEFINED]} {
+       if {[lex-name-move BY]} {
+           lex
+       }
+    }
+    asnSubtypeSpec
+    return Simple
+}
+
+proc mapName {name} {
+    global inf
+    if {[info exists inf(map,$inf(module),$name)]} {
+        set name $inf(map,$inf(module),$name)
+       if {$inf(verbose)} {
+           puts -nonewline " $name ($inf(lineno))"
+           puts " mapping to $name"
+       }
+    } else {
+       if {$inf(verbose)} {
+           puts " $name ($inf(lineno))"
+       }
+    }
+    return $name
+}
+
+# asnDef: parses type definition (top-level) and generates C code
+# On entry $name holds the type we are defining.
+proc asnDef {name} {
+    global inf file
+
+    set name [mapName $name]
+    if {[info exist inf(defined,$inf(fprefix)$name)]} {
+        incr inf(definedl,$name)
+        if {$inf(verbose) > 1} {
+            puts "set map($inf(module),$name) $name$inf(definedl,$name)"
+        }
+    } else {
+        set inf(definedl,$name) 0
+    }
+    set mname [join [split $name -] _]
+    asnMod tag implicit tagtype
+    set t [asnType $mname]
+    asnSub $mname $t $tname $tag $implicit $tagtype
+}
+
+
+# asnSub: parses type and generates C-code
+# On entry,
+#   $name holds the type we are defining.
+#   $t is the type returned by the asnType procedure.
+#   $tname is the $tname set by the asnType procedure.
+#   $tag is the tag as returned by asnMod
+#   $implicit is the implicit indicator as returned by asnMod
+proc asnSub {name t tname tag implicit tagtype} {
+    global file inf
+   
+    set ignore 0
+    set defname defined,$inf(fprefix)$name
+    if {[info exist inf($defname)]} {
+        asnWarning "$name already defined in line $inf($defname)"
+        set ignore 1
+    }
+    set inf($defname) $inf(lineno)
+    switch -- $t {
+        Sequence   { set l [asnSequence $name $tag $implicit $tagtype] }
+        SequenceOf { set l [asnOf $name $tag $implicit $tagtype 0] }
+       SetOf      { set l [asnOf $name $tag $implicit $tagtype 1] }
+        Choice     { set l [asnChoice $name $tag $implicit $tagtype] }
+        Simple     { set l [asnSimple $name $tname $tag $implicit $tagtype] }
+        default    { asnError "switch asnType case not handled" }
+    }
+    if {$ignore} return
+
+    puts $file(outc) {}
+    puts $file(outc) "int $inf(fprefix)$name (ODR o, $inf(vprefix)$name **p, int opt, const char *name)"
+    puts $file(outc) \{
+    puts $file(outc) [lindex $l 0]
+    puts $file(outc) \}
+    set ok 1
+    set fdef "$inf(cprefix)int $inf(fprefix)$name (ODR o, $inf(vprefix)$name **p, int opt, const char *name);"
+    switch -- $t {
+        Simple {
+            set decl "typedef [lindex $l 1] $inf(vprefix)$name;"
+            if {![string compare [lindex $tname 2] 1]} {
+                if {![info exist inf(defined,[lindex $tname 0])]} {
+                    set ok 0
+                }
+            }
+           set inf(var,$inf(nodef)) [join [lindex $l 2] \n]
+           incr inf(nodef)
+        }
+        default {
+            set decl "typedef struct $inf(vprefix)$name $inf(vprefix)$name;"
+           set inf(var,$inf(nodef)) "[lindex $l 1];"
+           incr inf(nodef)
+        }
+    }
+    if {$ok} {
+        puts $file(outh) {}
+        puts $file(outh) $decl
+        puts $file(outh) $fdef
+       asnForwardTypes $name
+    } else {
+        lappend inf(forward,code,[lindex $tname 0]) {} $decl $fdef
+        lappend inf(forward,ref,[lindex $tname 0]) $name
+    }
+}
+
+proc asnForwardTypes {name} {
+    global inf file
+
+    if {![info exists inf(forward,code,$inf(fprefix)$name)]} {
+       return 0
+    }
+    foreach r $inf(forward,code,$inf(fprefix)$name) {
+       puts $file(outh) $r
+    }
+    unset inf(forward,code,$inf(fprefix)$name)
+
+    while {[info exists inf(forward,ref,$inf(fprefix)$name)]} {
+       set n $inf(forward,ref,$inf(fprefix)$name)
+       set m [lrange $n 1 end]
+       if {[llength $m]} {
+           set inf(forward,ref,$inf(fprefix)$name) $m
+       } else {
+           unset inf(forward,ref,$inf(fprefix)$name)
+       }
+       asnForwardTypes [lindex $n 0]
+    }
+}
+
+# asnSimple: parses simple type definition and generates C code
+# On entry,
+#   $name is the name we are defining
+#   $tname is the tname as returned by asnType
+#   $tag is the tag as returned by asnMod
+#   $implicit is the implicit indicator as returned by asnMod
+# Returns,
+#   {c-code, h-code}
+# Note: Doesn't take care of enum lists yet.
+proc asnSimple {name tname tag implicit tagtype} {
+    global inf
+
+    set j "[lindex $tname 1] "
+
+    if {[info exists inf(unionmap,$inf(module),$name)]} {
+       set uName $inf(unionmap,$inf(module),$name)
+    } else {
+       set uName $name
+    }
+
+    asnEnum $uName jj
+    if {![string length $tag]} {
+        set l "\treturn [lindex $tname 0] (o, p, opt, name);" 
+    } elseif {$implicit} {
+        set l \
+  "\treturn odr_implicit_tag (o, [lindex $tname 0], p, $tagtype, $tag, opt, name);" 
+    } else {
+        set l \
+  "\treturn odr_explicit_tag (o, [lindex $tname 0], p, $tagtype, $tag, opt, name);" \
+    }
+    if {[info exists jj]} {
+       return [list $l $j $jj]
+    } else {
+       return [list $l $j]
+    }
+}
+
+# asnSequence: parses "SEQUENCE { s-list }" and generates C code.
+# On entry,
+#   $name is the type we are defining
+#   $tag tag 
+#   $implicit
+# Returns,
+#   {c-code, h-code}
+proc asnSequence {name tag implicit tagtype} {
+    global val type inf
+
+    lappend j "struct $inf(vprefix)$name \{"
+    set level 0
+    set nchoice 0
+    if {![string length $tag]} {
+        lappend l "\tif (!odr_sequence_begin (o, p, sizeof(**p), name))"
+        lappend l "\t\treturn opt && odr_ok (o);"
+    } elseif {$implicit} {
+        lappend l "\tif (!odr_implicit_settag (o, $tagtype, $tag) ||"
+        lappend l "\t\t!odr_sequence_begin (o, p, sizeof(**p), name))"
+        lappend l "\t\treturn opt && odr_ok(o);"
+    } else {
+        lappend l "\tif (!odr_constructed_begin (o, p, $tagtype, $tag, name)"
+        lappend l "\t\treturn opt && odr_ok(o);"
+        lappend l "\tif (o->direction == ODR_DECODE)"
+        lappend l "\t\t*p = odr_malloc (o, sizeof(**p));"
+
+        lappend l "\tif (!odr_sequence_begin (o, p, sizeof(**p), 0))"
+        lappend l "\t\{"
+        lappend l "\t\t*p = 0;"
+        lappend l "\t\treturn 0;"
+        lappend l "\t\}"
+    }
+    lappend l "\treturn"
+    while {1} {
+        set p [lindex [asnName $name] 0]
+        asnMod ltag limplicit ltagtype
+        set t [asnType $p]
+
+       set uName { }
+       if {[info exists inf(unionmap,$inf(module),$name,$p)]} {
+           set uName $inf(unionmap,$inf(module),$name,$p)
+       }
+
+        if {![string compare $t Simple]} {
+           if {[string compare $uName { }]} {
+               set enumName $uName
+           } else {
+               set enumName $name
+           }
+            asnEnum $enumName j
+            set opt [asnOptional]
+            if {![string length $ltag]} {
+                lappend l "\t\t[lindex $tname 0](o, &(*p)->$p, $opt, \"$p\") &&"
+            } elseif {$limplicit} {
+                lappend l "\t\todr_implicit_tag (o, [lindex $tname 0],"
+                lappend l "\t\t\t&(*p)->$p, $ltagtype, $ltag, $opt, \"$p\") &&"
+            } else {
+                lappend l "\t\todr_explicit_tag (o, [lindex $tname 0],"
+                lappend l "\t\t\t&(*p)->$p, $ltagtype, $ltag, $opt, \"$p\") &&"
+            }
+            set dec "\t[lindex $tname 1] *$p;"
+        } elseif {![string compare $t SequenceOf] && [string length $uName] &&\
+                     (![string length $ltag] || $limplicit)} {
+            set u [asnType $p]
+           
+           if {[llength $uName] < 2} {
+               set uName [list num_$p $p]
+           }
+            if {[string length $ltag]} {
+                if {!$limplicit} {
+                    asnError explicittag
+                }
+                lappend l "\t\todr_implicit_settag (o, $ltagtype, $ltag) &&"
+            }
+            switch -- $u {
+                Simple {
+                    asnEnum $name j
+                    set tmpa "odr_sequence_of(o, (Odr_fun) [lindex $tname 0], &(*p)->$p,"
+                    set tmpb "&(*p)->[lindex $uName 0], \"$p\")"
+                    lappend j "\tint [lindex $uName 0];"
+                    set dec "\t[lindex $tname 1] **[lindex $uName 1];"
+                }
+                default {
+                    set subName [mapName ${name}_$level]
+                    asnSub $subName $u {} {} 0 {}
+                    
+                    set tmpa "odr_sequence_of(o, (Odr_fun) $inf(fprefix)$subName, &(*p)->$p,"
+                    set tmpb "&(*p)->[lindex $uName 0], \"$p\")"
+                    lappend j "\tint [lindex $uName 0];"
+                    set dec "\t$inf(vprefix)$subName **[lindex $uName 1];"
+                    incr level
+                }
+            }
+            set opt [asnOptional]
+            if {$opt} {
+                lappend l "\t\t($tmpa"
+                lappend l "\t\t  $tmpb || odr_ok(o)) &&"
+            } else {
+                lappend l "\t\t$tmpa"
+                lappend l "\t\t  $tmpb &&"
+            }
+        } elseif {!$nchoice && ![string compare $t Choice] && \
+                     [string length $uName]} {
+           if {[llength $uName] < 3} {
+               set uName [list which u $name]
+               incr nchoice
+           }
+            lappend j "\tint [lindex $uName 0];"
+            lappend j "\tunion \{"
+            lappend v "\tstatic Odr_arm arm\[\] = \{"
+            asnArm $name [lindex $uName 2] v j
+            lappend v "\t\};"
+            set dec "\t\} [lindex $uName 1];"
+            set opt [asnOptional]
+            set oa {}
+            set ob {}
+            if {[string length $ltag]} {
+                if {$limplicit} {
+                    lappend l "\t\todr_implicit_settag (o, $ltagtype, $ltag) &&"
+                    if {$opt} {
+                        asnWarning "optional handling missing in CHOICE in SEQUENCE"
+                       asnWarning " set unionmap($inf(module),$name,$p) to {}"
+                    }
+                } else {
+                    if {$opt} {
+                        set la "(("
+                    } else {
+                        set la ""
+                    }
+                    lappend l "\t\t${la}odr_constructed_begin (o, &(*p)->[lindex $uName 1], $ltagtype, $ltag, \"$p\") &&"
+                }
+            } else {
+                if {$opt} {
+                    set oa "("
+                    set ob " || odr_ok(o))" 
+                }
+            }
+            lappend l "\t\t${oa}odr_choice (o, arm, &(*p)->[lindex $uName 1], &(*p)->[lindex $uName 0], 0)${ob} &&"
+            if {[string length $ltag]} {
+                if {!$limplicit} {
+                    if {$opt} {
+                        set lb ") || odr_ok(o))"
+                    } else {
+                        set lb ""
+                    }
+                    lappend l "\t\todr_constructed_end (o)${lb} &&"
+                } 
+            }
+        } else {
+           set subName [mapName ${name}_$level]
+            asnSub $subName $t {} {} 0 {}
+            set opt [asnOptional]
+            if {![string length $ltag]} {
+                lappend l "\t\t$inf(fprefix)${subName} (o, &(*p)->$p, $opt, \"$p\") &&"
+            } elseif {$limplicit} {
+                lappend l "\t\todr_implicit_tag (o, $inf(fprefix)${subName},"
+                lappend l "\t\t\t&(*p)->$p, $ltagtype, $ltag, $opt, \"$p\") &&"
+            } else {
+                lappend l "\t\todr_explicit_tag (o, $inf(fprefix)${subName},"
+                lappend l "\t\t\t&(*p)->$p, $ltagtype, $ltag, $opt, \"$p\") &&"
+            }
+            set dec "\t$inf(vprefix)${subName} *$p;"
+            incr level
+        }
+        if {$opt} {
+            lappend j "$dec /* OPT */"
+        } else {
+            lappend j $dec
+        }
+        if {[string compare $type ,]} break
+    }
+    lappend j "\}"
+    if {[string length $tag] && !$implicit} {
+        lappend l "\t\todr_sequence_end (o) &&"
+        lappend l "\t\todr_constructed_end (o);"
+    } else {
+        lappend l "\t\todr_sequence_end (o);"
+    }
+    if {[string compare $type \}]} {
+        asnError "Missing \} got $type '$val'"
+    }
+    lex
+    if {[info exists v]} {
+        set l [concat $v $l]
+    }
+    return [list [join $l \n] [join $j \n]]
+}
+
+# asnOf: parses "SEQUENCE/SET OF type" and generates C code.
+# On entry,
+#   $name is the type we are defining
+#   $tag tag 
+#   $implicit
+# Returns,
+#   {c-code, h-code}
+proc asnOf {name tag implicit tagtype isset} { 
+    global inf
+
+    if {$isset} {
+       set func odr_set_of
+    } else {
+       set func odr_sequence_of
+    }
+
+    if {[info exists inf(unionmap,$inf(module),$name)]} {
+       set numName $inf(unionmap,$inf(module),$name)
+    } else {
+       set numName {num elements}
+    }
+
+    lappend j "struct $inf(vprefix)$name \{"
+    lappend j "\tint [lindex $numName 0];"
+
+    lappend l "\tif (!odr_initmember (o, p, sizeof(**p)))"
+    lappend l "\t\treturn opt && odr_ok(o);"
+    if {[string length $tag]} {
+        if {$implicit} {
+            lappend l "\todr_implicit_settag (o, $tagtype, $tag);"
+        } else {
+            asnWarning "Constructed SEQUENCE/SET OF not handled"
+        }
+    }
+    set t [asnType $name]
+    switch -- $t {
+        Simple {
+            asnEnum $name j
+            lappend l "\tif ($func (o, (Odr_fun) [lindex $tname 0], &(*p)->[lindex $numName 1],"
+            lappend l "\t\t&(*p)->[lindex $numName 0], name))"
+            lappend j "\t[lindex $tname 1] **[lindex $numName 1];"
+        }
+        default {
+            set subName [mapName ${name}_s]
+            lappend l "\tif ($func (o, (Odr_fun) $inf(fprefix)$subName, &(*p)->[lindex $numName 1],"
+            lappend l "\t\t&(*p)->[lindex $numName 0], name))"
+            lappend j "\t$inf(vprefix)$subName **[lindex $numName 1];"
+            asnSub $subName $t {} {} 0 {}
+        }
+    }
+    lappend j "\}"
+    lappend l "\t\treturn 1;"
+    lappend l "\t*p = 0;"
+    lappend l "\treturn opt && odr_ok(o);"
+    return [list [join $l \n] [join $j \n]]
+}
+
+# asnArm: parses c-list in choice
+proc asnArm {name defname lx jx} {
+    global type val inf
+
+    upvar $lx l
+    upvar $jx j
+    while {1} {
+        set pq [asnName $name]
+        set p [lindex $pq 0]
+        set q [lindex $pq 1]
+        if {![string length $q]} {
+            set q $p
+           set p ${defname}_$p
+        }
+        asnMod ltag limplicit ltagtype
+        set t [asnType $q]
+
+        lappend enums "$inf(dprefix)$p"
+        if {![string compare $t Simple]} {
+            asnEnum $name j
+            if {![string length $ltag]} {
+                lappend l "\t\t\{-1, -1, -1, $inf(dprefix)$p,"
+               lappend l "\t\t (Odr_fun) [lindex $tname 0], \"$q\"\},"
+            } elseif {$limplicit} {
+                lappend l "\t\t\{ODR_IMPLICIT, $ltagtype, $ltag, $inf(dprefix)$p,"
+                lappend l "\t\t(Odr_fun) [lindex $tname 0], \"$q\"\},"
+            } else {
+                lappend l "\t\t\{ODR_EXPLICIT, $ltagtype, $ltag, $inf(dprefix)$p,"
+                lappend l "\t\t(Odr_fun) [lindex $tname 0], \"$q\"\},"
+            }
+            lappend j "\t\t[lindex $tname 1] *$q;"
+        } else {
+            set subName [mapName ${name}_$q]
+            if {![string compare $inf(dprefix)${name}_$q \
+                                 $inf(vprefix)$subName]} {
+                set po [string toupper [string index $q 0]][string \
+                                                            range $q 1 end]
+                set subName [mapName ${name}${po}]
+            }
+            asnSub $subName $t $tname {} 0 {}
+            if {![string length $ltag]} {
+                lappend l "\t\t\{-1, -1, -1, $inf(dprefix)$p,"
+               lappend l "\t\t (Odr_fun) $inf(fprefix)$subName, \"$q\"\},"
+            } elseif {$limplicit} {
+                lappend l "\t\t\{ODR_IMPLICIT, $ltagtype, $ltag, $inf(dprefix)$p,"
+                lappend l "\t\t(Odr_fun) $inf(fprefix)$subName, \"$q\"\},"
+            } else {
+                lappend l "\t\t\{ODR_EXPLICIT, $ltagtype, $ltag, $inf(dprefix)$p,"
+                lappend l "\t\t(Odr_fun) $inf(fprefix)$subName, \"$q\"\},"
+            }
+            lappend j "\t\t$inf(vprefix)$subName *$q;"
+        }
+        if {[string compare $type ,]} break
+    }
+    if {[string compare $type \}]} {
+        asnError "Missing \} got $type '$val'"
+    }
+    lex
+    set level 1
+    foreach e $enums {
+        lappend j "#define $e $level"
+        incr level
+    }
+    lappend l "\t\t\{-1, -1, -1, -1, (Odr_fun) 0, 0\}"
+}
+
+# asnChoice: parses "CHOICE {c-list}" and generates C code.
+# On entry,
+#   $name is the type we are defining
+#   $tag tag 
+#   $implicit
+# Returns,
+#   {c-code, h-code}
+proc asnChoice {name tag implicit tagtype} {
+    global type val inf
+
+    if {[info exists inf(unionmap,$inf(module),$name)]} {
+       set uName $inf(unionmap,$inf(module),$name)
+    } else {
+       set uName [list which u $name]
+    }
+
+    lappend j "struct $inf(vprefix)$name \{"
+    lappend j "\tint [lindex $uName 0];"
+    lappend j "\tunion \{"
+    lappend l "\tstatic Odr_arm arm\[\] = \{"
+    asnArm $name [lindex $uName 2] l j
+    lappend j "\t\} [lindex $uName 1];"
+    lappend j "\}"
+    lappend l "\t\};"
+    if {![string length $tag]} {
+       lappend l "\tif (!odr_initmember(o, p, sizeof(**p)))"
+       lappend l "\t\treturn opt && odr_ok(o);"
+       lappend l "\tif (odr_choice(o, arm, &(*p)->[lindex $uName 1], &(*p)->[lindex $uName 0], name))"
+    } elseif {$implicit} {
+       lappend l "\tif (!odr_initmember(o, p, sizeof(**p)))"
+       lappend l "\t\treturn opt && odr_ok(o);"
+       lappend l "\todr_implicit_settag(o, $tagtype, $tag);"
+       lappend l "\tif (odr_choice(o, arm, &(*p)->[lindex $uName 1], &(*p)->[lindex $uName 0], name))"
+    } else {
+       lappend l "\tif (!*p && o->direction != ODR_DECODE)"
+       lappend l "\t\treturn opt;"
+       lappend l "\tif (!odr_constructed_begin(o, p, $tagtype, $tag, 0))"
+       lappend l "\t\treturn opt && odr_ok(o);"
+       lappend l "\tif (!odr_initmember(o, p, sizeof(**p)))"
+       lappend l "\t\treturn opt && odr_ok(o);"
+       lappend l "\tif (odr_choice(o, arm, &(*p)->[lindex $uName 1], &(*p)->[lindex $uName 0], name) &&"
+       lappend l "\t\todr_constructed_end(o))"
+    }
+    lappend l "\t\treturn 1;"
+    lappend l "\t*p = 0;"
+    lappend l "\treturn opt && odr_ok(o);"
+    return [list [join $l \n] [join $j \n]]
+}
+
+# asnImports: parses i-list in "IMPORTS {i-list}" 
+# On return inf(import,..)-array is updated.
+# inf(import,"module") is a list of {C-handler, C-type} elements.
+# The {C-handler, C-type} is compatible with the $tname as is used by the
+# asnType procedure to solve external references.
+proc asnImports {} {
+    global type val inf file
+
+    while {1} {
+        if {[string compare $type n]} {
+            asnError "Missing name in IMPORTS list"
+        }
+        lappend nam $val
+        lex
+        if {![string compare $type n] && ![string compare $val FROM]} {
+            lex
+           
+           if {[info exists inf(filename,$val)]} {
+               set fname $inf(filename,$val)
+           } else {
+               set fname $val
+           }
+           puts $file(outh) "\#include \"${fname}.h\""
+
+            if {[info exists inf(prefix,$val)]} {
+                set prefix $inf(prefix,$val)
+            } else {
+                set prefix $inf(prefix)
+            }
+            foreach n $nam {
+                set m [join [split $n -] _]
+                set inf(imports,$n) [list [lindex $prefix 0]$m \
+                                          [lindex $prefix 1]$m]
+            }
+            unset nam
+            lex
+            if {[string compare $type n]} break
+        } elseif {![string compare $type ,]} {
+            lex
+        } else break
+    }
+    if {[string compare $type \;]} {
+        asnError "Missing ; after IMPORTS list - got $type '$val'"
+    }
+    lex
+}
+
+# asnExports: parses e-list in "EXPORTS {e-list}" 
+# This function does nothing with elements in the list.
+proc asnExports {} {
+    global type val inf
+
+    while {1} {
+        if {[string compare $type n]} {
+            asnError "Missing name in EXPORTS list"
+        }
+        set inf(exports,$val) 1
+        lex
+        if {[string compare $type ,]} break
+        lex
+    }
+    if {[string compare $type \;]} {
+        asnError "Missing ; after EXPORTS list - got $type ($val)"
+    }
+    lex
+}
+
+# asnModuleBody: parses a module specification and generates C code.
+# Exports lists, imports lists, and type definitions are handled;
+# other things are silently ignored.
+proc asnModuleBody {} {
+    global type val file inf
+
+    if {[info exists inf(prefix,$inf(module))]} {
+        set prefix $inf(prefix,$inf(module))
+    } else {
+        set prefix $inf(prefix)
+    }
+    set inf(fprefix) [lindex $prefix 0]
+    set inf(vprefix) [lindex $prefix 1]
+    set inf(dprefix) [lindex $prefix 2]
+    if {[llength $prefix] > 3} {
+       set inf(cprefix) [lindex $prefix 3]
+    } else {
+       set inf(cprefix) {YAZ_EXPORT }
+    }
+
+    if {$inf(verbose)} {
+        puts "Module $inf(module), $inf(lineno)"
+    }
+
+    set defblock 0
+    if {[info exists inf(init,$inf(module),c)]} {
+       puts $file(outc) $inf(init,$inf(module),c)
+    }
+    if {[info exists inf(init,$inf(module),h)]} {
+       puts $file(outh) "\#ifdef __cplusplus"
+       puts $file(outh) "extern \"C\" \{"
+       puts $file(outh) "\#endif"
+       set defblock 1
+       puts $file(outh) $inf(init,$inf(module),h)
+    }
+    if {[info exists inf(init,$inf(module),p)]} {
+       puts $file(outp) $inf(init,$inf(module),p)
+    }
+
+    while {[string length $type]} {
+       if {[string compare $type n]} {
+           lex
+           continue
+       }
+       if {![string compare $val END]} {
+           break
+       } elseif {![string compare $val EXPORTS]} {
+           lex
+           asnExports
+       } elseif {![string compare $val IMPORTS]} {
+           if {$defblock} {
+               puts $file(outh) "\#ifdef __cplusplus"
+               puts $file(outh) "\}"
+               puts $file(outh) "\#endif"
+               set defblock 0
+           }
+           lex
+           asnImports
+       } else {
+           if {!$defblock} {
+               puts $file(outh) "\#ifdef __cplusplus"
+               puts $file(outh) "extern \"C\" \{"
+               puts $file(outh) "\#endif"
+               set defblock 1
+           }
+           set inf(asndef) $inf(nodef)
+           set oval $val
+           lex
+           if {![string compare $type :]} {
+               lex
+               asnDef $oval
+               set inf(asndef) 0
+           } elseif {![string compare $type n]} {
+               lex
+               if {[string length $type]} {
+                   lex
+               }
+           }
+       }
+    }
+    if {$defblock} {
+       puts $file(outh) "\#ifdef __cplusplus"
+       puts $file(outh) "\}"
+       puts $file(outh) "\#endif"
+       set defblock 0
+    }
+    foreach x [array names inf imports,*] {
+        unset inf($x)
+    }
+}
+
+# asnTagDefault: parses TagDefault section
+proc asnTagDefault {} {
+    global type val inf file
+    
+    set inf(implicit-tags) 0
+    while {[string length $type]} {
+       if {[lex-name-move EXPLICIT]} {
+           lex
+           set inf(implicit-tags) 0
+       } elseif {[lex-name-move  IMPLICIT]} {
+           lex
+           set inf(implicit-tags) 1
+       } else {
+           break
+       }
+    }
+}
+
+# asnModules: parses a collection of module specifications.
+# Depending on the module pattern, $inf(moduleP), a module is either
+# skipped or processed.
+proc asnModules {} {
+    global type val inf file yc_version
+
+    set inf(nodef) 0
+    set inf(asndef) 0
+    lex
+    while {![string compare $type n]} {
+       set inf(module) $val
+        if {[info exists inf(moduleP)] && ![string match $inf(moduleP) $val]} {
+            if {$inf(verbose)} {
+                puts "Skipping $id"
+            }
+            while {![lex-name-move END]} {
+               lex
+           }
+        } else {
+           set inf(nodef) 1
+           set inf(asndef) 1
+
+           while {![lex-name-move DEFINITIONS]} {
+               lex
+               if {![string length $type]} return
+           }
+
+
+           if {[info exists inf(filename,$inf(module))]} {
+               set fname $inf(filename,$inf(module))
+           } else {
+               set fname $inf(module)
+           }
+            set ppname [join [split $fname -] _]
+
+           if {![info exists inf(c-file)]} {
+               set inf(c-file) ${fname}.c
+           }
+           set file(outc) [open $inf(c-file) w]
+
+           if {![info exists inf(h-file)]} {
+               set inf(h-file) ${fname}.h
+           }
+           set file(outh) [open $inf(h-file) w]
+
+           if {![info exists inf(p-file)]} {
+               set inf(p-file) ${fname}-p.h
+           }
+           set file(outp) [open $inf(p-file) w]
+
+           set md [clock format [clock seconds]]
+           
+           puts $file(outc) "/* YC ${yc_version} $md */"
+           puts $file(outc) "/* Module-C: $inf(module) */"
+           puts $file(outc) {}
+
+           puts $file(outh) "/* YC ${yc_version}: $md */"
+           puts $file(outh) "/* Module-H $inf(module) */"
+           puts $file(outh) {}
+
+           puts $file(outp) "/* YC ${yc_version}: $md */"
+           puts $file(outp) "/* Module-P: $inf(module) */"
+           puts $file(outp) {}
+
+           puts $file(outc) "\#include \"$inf(p-file)\""
+
+           puts $file(outh) "\#ifndef ${ppname}_H"
+           puts $file(outh) "\#define ${ppname}_H"
+           puts $file(outh) {}
+           puts $file(outh) "\#include <odr.h>"
+           
+           puts $file(outp) "\#ifndef ${ppname}_P_H"
+           puts $file(outp) "\#define ${ppname}_P_H"
+           puts $file(outp) {}
+           puts $file(outp) "\#include \"$inf(h-file)\""
+
+
+           puts $file(outp) "\#ifdef __cplusplus"
+           puts $file(outp) "extern \"C\" \{"
+           puts $file(outp) "\#endif"
+           
+           asnTagDefault
+           if {[string compare $type :]} {
+               asnError "::= expected got $type '$val'"
+           } 
+           lex
+           if {![lex-name-move BEGIN]} {
+               asnError "BEGIN expected"
+           }
+           asnModuleBody
+           lex
+
+           if {[info exists file(outp)]} {
+               set f $file(outp)
+           } else {
+               set f $file(outh)
+           }
+           for {set i 1} {$i < $inf(nodef)} {incr i} {
+               puts $f $inf(var,$i)
+               if {[info exists inf(asn,$i)]} {
+                   if {0} {
+                       puts $f "/*"
+                       foreach comment $inf(asn,$i) {
+                           puts $f $comment
+                       }
+                       puts $f " */"
+                   }
+                   unset inf(asn,$i)
+               }
+               unset inf(var,$i)
+               puts $f {}
+           }
+           puts $file(outp) "\#ifdef __cplusplus"
+           puts $file(outp) "\}"
+           puts $file(outp) "\#endif"
+
+           if {[info exists inf(body,$inf(module),h)]} {
+               puts $file(outh) $inf(body,$inf(module),h)
+           }
+           if {[info exists inf(body,$inf(module),c)]} {
+               puts $file(outc) $inf(body,$inf(module),c)
+           }
+           if {[info exists inf(body,$inf(module),p)]} {
+               puts $file(outp) $inf(body,$inf(module),p)
+           }
+           puts $file(outh) "\#endif"
+           puts $file(outp) "\#endif"
+           foreach f [array names file] {
+               close $file($f)
+           }
+           unset inf(c-file)
+           unset inf(h-file)
+           unset inf(p-file)
+       }
+    }
+}
+
+# asnFile: parses an ASN.1 specification file as specified in $inf(iname).
+proc asnFile {} {
+    global inf file
+
+    if {$inf(verbose) > 1} {
+        puts "Reading ASN.1 file $inf(iname)"
+    }
+    set inf(str) {}
+    set inf(lineno) 0
+    set inf(inf) [open $inf(iname) r]
+    
+    asnModules
+    
+}
+
+# The following procedures are invoked by the asnType function. 
+# Each procedure takes the form: asnBasic<TYPE> and they must return
+# two elements: the C function handler and the C type.
+# On entry upvar $name is the type we are defining and global, $inf(module), is
+# the current module name.
+
+proc asnBasicEXTERNAL {} {
+    return {odr_external {Odr_external}}
+}
+
+proc asnBasicINTEGER {} {
+    return {odr_integer {int}}
+}
+
+proc asnBasicENUMERATED {} {
+    return {odr_enum {int}}
+}
+
+proc asnBasicNULL {} {
+    return {odr_null {Odr_null}}
+}
+
+proc asnBasicBOOLEAN {} {
+    return {odr_bool {bool_t}}
+}
+
+proc asnBasicOCTET {} {
+    global type val
+    lex-name-move STRING
+    return {odr_octetstring {Odr_oct}}
+}
+
+proc asnBasicBIT {} {
+    global type val
+    lex-name-move STRING
+    return {odr_bitstring {Odr_bitmask}}
+}
+
+proc asnBasicOBJECT {} {
+    global type val
+    lex-name-move IDENTIFIER
+    return {odr_oid {Odr_oid}}
+}
+
+proc asnBasicANY {} {
+    upvar name name
+    global inf
+    return [list $inf(fprefix)ANY_$name void]
+}
+
+# userDef: reads user definitions file $name
+proc userDef {name} {
+    global inf
+
+    if {$inf(verbose) > 1} {
+        puts "Reading definitions file $name"
+    }
+    source $name
+
+    if {[info exists default-prefix]} {
+        set inf(prefix) ${default-prefix}
+    }
+    foreach m [array names prefix] {
+        set inf(prefix,$m) $prefix($m)
+    }
+    foreach m [array names body] {
+       set inf(body,$m) $body($m)
+    }
+    foreach m [array names init] {
+       set inf(init,$m) $init($m)
+    }
+    foreach m [array names filename] {
+       set inf(filename,$m) $filename($m)
+    }
+    foreach m [array names map] {
+        set inf(map,$m) $map($m)
+    }
+    foreach m [array names membermap] {
+        set inf(membermap,$m) $membermap($m)
+    }
+    foreach m [array names unionmap] {
+        set inf(unionmap,$m) $unionmap($m)
+    }
+}
+
+set inf(verbose) 0
+set inf(prefix) {yc_ Yc_ YC_}
+
+# Parse command line
+set l [llength $argv]
+set i 0
+while {$i < $l} {
+    set arg [lindex $argv $i]
+    switch -glob -- $arg {
+        -v {
+           incr inf(verbose) 
+        }
+        -c {
+           set p [string range $arg 2 end]
+           if {![string length $p]} {
+                 set p [lindex $argv [incr i]]
+             }
+           set inf(c-file) $p
+        }
+        -h* {
+           set p [string range $arg 2 end]
+           if {![string length $p]} {
+                 set p [lindex $argv [incr i]]
+             }
+           set inf(h-file) $p
+        }
+        -p* {
+           set p [string range $arg 2 end]
+           if {![string length $p]} {
+               set p [lindex $argv [incr i]]
+           }
+           set inf(p-file) $p
+        }
+        -d* {
+           set p [string range $arg 2 end]
+           if {![string length $p]} {
+               set p [lindex $argv [incr i]]
+           }
+           userDef $p
+        }
+        -m* {
+           set p [string range $arg 2 end]
+           if {![string length $p]} {
+               set p [lindex $argv [incr i]]
+           }
+           set inf(moduleP) $p
+        }
+       -x* {
+           set p [string range $arg 2 end]
+           if {![string length $p]} {
+               set p [lindex $argv [incr i]]
+           }
+           if {[llength $p] == 1} {
+               set inf(prefix) [list [string tolower $p] \
+                                    [string toupper $p] [string toupper $p]]
+           } elseif {[llength $p] == 3} {
+               set inf(prefix) $p
+           } else {
+               puts [llength $p]
+               exit 1
+           }
+       }           
+        default {
+           set inf(iname) $arg
+        }
+    }
+    incr i
+}
+
+if {![info exists inf(iname)]} {
+    puts "YAZ ODR Compiler ${yc_version}"
+    puts -nonewline "Usage: ${argv0}"
+    puts { [-v] [-c cfile] [-h hfile] [-p hfile] [-d dfile] }
+    puts {    [-x prefix] [-m module] file}
+    exit 1
+}
+
+asnFile
diff --git a/z39.50/Makefile.in b/z39.50/Makefile.in
new file mode 100644 (file)
index 0000000..b8a0cf8
--- /dev/null
@@ -0,0 +1,71 @@
+# $Id: Makefile.in,v 1.1 1999-06-08 10:10:16 adam Exp $
+
+SHELL=/bin/sh
+
+CC=@CC@
+CPP=@CPP@
+RANLIB=@RANLIB@
+CDEFS=@DEFS@
+LIBS=@LIBS@
+
+INCLUDE=-I. -I../include
+DEFS=$(INCLUDE) $(CDEFS)
+LIBDIR=../lib
+LIBS=$(LIBDIR)/libodr.a $(LIBDIR)/libutil.a
+YCFLAGS=
+
+LIB=$(LIBDIR)/libasn.a
+
+O=yc-tst.o yc-assoc.o yc-set.o yc-get.o yc-query.o 
+
+PO=z-accdes1.o z-accform1.o z-acckrb1.o z-core.o \
+ z-diag1.o z-espec1.o z-estask.o z-exp.o z-grs.o z-opac.o z-uifr1.o \
+ z-rrf1.o z-rrf2.o z-sum.o z-sutrs.o \
+ zes-expi.o zes-exps.o zes-order.o zes-pquery.o zes-psched.o \
+ zes-pset.o zes-update0.o z-date.o z-univ.o \
+ zes-update.o
+
+CF=z-accdes1.c z-accform1.c z-acckrb1.c z-core.c \
+ z-diag1.c z-espec1.c z-estask.c z-exp.c z-grs.c z-opac.c z-uifr1.c \
+ z-rrf1.c z-rrf2.c z-sum.c z-sutrs.c \
+ zes-expi.c zes-exps.c zes-order.c zes-pquery.c zes-psched.c \
+ zes-pset.c zes-update0.c 
+
+all: $(LIB) 
+
+yc-tst: $(O) $(LIB)
+       $(CC) $(CFLAGS) $(O) -o yc-tst $(LIB) $(LIBS)
+
+
+$(LIB): $(PO)
+       rm -f $(LIB)
+       ar qc $(LIB) $(PO)
+       $(RANLIB) $(LIB)
+
+z-accdes1.h z-core.h: z.tcl z3950v3.asn ../util/yc.tcl
+       ../util/yc.tcl -d z.tcl $(YCFLAGS) z3950v3.asn 
+
+z-date.h z-date.c: z.tcl datetime.asn ../util/yc.tcl
+       ../util/yc.tcl -d z.tcl $(YCFLAGS) datetime.asn
+
+z-univ.h z-univ.c: z.tcl univres.asn
+       ../util/yc.tcl -d z.tcl $(YCFLAGS) univres.asn
+
+zes-update.h zes-update.c: z.tcl esupdate.asn
+       ../util/yc.tcl -d z.tcl $(YCFLAGS) esupdate.asn
+
+.c.o:
+       $(CC) -c $(CFLAGS) $(DEFS) $<
+
+clean:
+       -rm -f *.o yc-tst core *.out
+
+realclean: clean
+       -rm -f z-*.[cho] zes-*.[cho]
+
+depend: z-core.h z-date.h z-univ.h zes-update.c
+       sed '/^#Depend/q' <Makefile >Makefile.tmp
+       $(CPP) $(DEFS) -M *.c >>Makefile.tmp
+       mv -f Makefile.tmp Makefile
+
+#Depend --- DOT NOT DELETE THIS LINE
diff --git a/z39.50/datetime.asn b/z39.50/datetime.asn
new file mode 100644 (file)
index 0000000..2baad10
--- /dev/null
@@ -0,0 +1,82 @@
+UserInfoFormat-dateTime
+{Z39-50-userInfoFormat dateTime (6)} DEFINITIONS ::=
+BEGIN
+IMPORTS IntUnit FROM Z39-50-APDU-1995;
+
+DateTime ::= SEQUENCE{
+     date [1]  Z3950Date OPTIONAL,
+     time [2]  Z3950Time OPTIONAL
+                    -- one or the other, or both
+          }
+
+Z3950Date ::= SEQUENCE{
+ year         [1] IMPLICIT INTEGER,
+                    -- For "positive" years, i.e. 1 AD or later, supply
+                    -- the absolute year, e.g. If the year is 1995, supply
+                    -- the integer 1995; the value 95 would indicate the
+                    -- year 0095.
+                    -- For "negative" years, e.g. 1 BC or earlier, -1
+                    -- represents 1 BC, -2 represents 2 BC, etc. Zero is
+                    -- invalid, because there was no year zero.
+ partOfYear   [2] CHOICE{ -- may be omitted if only year is significant
+        monthAndDay [1]   IMPLICIT SEQUENCE{
+                       month [2]  IMPLICIT INTEGER, 
+                                   -- value 1-12
+                       day   [3]  IMPLICIT INTEGER OPTIONAL
+                                   -- may be omitted if only year and month
+                                   -- are significant. Value 1-31.
+                                           },
+        julianDay   [2]   IMPLICIT INTEGER, -- Value 1 - 366.
+        weekNumber  [3]   IMPLICIT INTEGER, -- Value 1 - 53. 
+        quarter     [4] CHOICE{
+                       first    [1] IMPLICIT NULL,
+                       second   [2] IMPLICIT NULL,
+                       third    [3] IMPLICIT NULL,
+                       fourth   [4] IMPLICIT NULL},
+        season      [5] CHOICE{
+                       winter   [1] IMPLICIT NULL,
+                       spring   [2] IMPLICIT NULL,
+                       summer   [3] IMPLICIT NULL,
+                       autumn   [4] IMPLICIT NULL}
+                                              } OPTIONAL, 
+ flags        [3] IMPLICIT SEQUENCE{
+     circa          [1]   IMPLICIT NULL OPTIONAL,
+                          -- if this flag is set then the date is "approximate".
+     era            [2]   IMPLICIT CHOICE{
+                          -- If era occurs, partOfYear should not occur.
+                          decade         [1] IMPLICIT NULL,
+                                              -- year must be multiple of 10.
+                                              -- For example, 1900 refers to
+                                              -- the decade covering the years
+                                              -- 1900 through 1909.
+                          century        [2] IMPLICIT NULL,
+                                              -- year must be multiple of 100.
+                          millennium     [3] IMPLICIT NULL
+                                              -- year must be multiple of 1000.
+                                                    } OPTIONAL
+                                              } OPTIONAL
+                                }
+
+
+Z3950Time ::= SEQUENCE{
+     hour           [1] IMPLICIT INTEGER,
+                             -- Value 0-23. 
+     minute         [2]  IMPLICIT INTEGER OPTIONAL,
+                             -- value 0-59. May be omitted when hour only is
+                             -- significant (in which case second and
+                             -- partOfSecond must also be omitted). 
+     second         [3]  IMPLICIT INTEGER OPTIONAL,
+                             -- value 0-59. May be omitted when only hour, or
+                             -- hour and minute, is significant (in which case
+                             -- partOfSecond must also be omitted).
+     partOfSecond   [4]  IMPLICIT IntUnit OPTIONAL,
+                             -- Use Unit System = 'si', Unit type = 'time'; 
+                             -- Unit = 'second', with appropriate value and
+                             -- scale factor.
+     zone           [5]  CHOICE{
+                              local      [1]  IMPLICIT NULL,
+                              utc        [2]  IMPLICIT NULL,
+
+                              utcOffset  [3]  IMPLICIT INTEGER  -- in minutes
+                                                    }}             
+END                              
diff --git a/z39.50/esupdate.asn b/z39.50/esupdate.asn
new file mode 100644 (file)
index 0000000..e6628a1
--- /dev/null
@@ -0,0 +1,103 @@
+ESFormat-Update
+{Z39-50-extendedService Update (5) revisions (1)  revision-1 (1)} DEFINITIONS ::=
+  -- oid is 1.2.840.10003.9.5.1.1
+BEGIN
+IMPORTS DiagRec, InternationalString
+FROM Z39-50-APDU-1995;
+Update ::= CHOICE{
+    esRequest      [1] IMPLICIT SEQUENCE{
+       toKeep         [1] OriginPartToKeep,
+       notToKeep      [2] OriginPartNotToKeep},
+    taskPackage    [2] IMPLICIT SEQUENCE{
+                       originPart     [1]
+                                   OriginPartToKeep,
+                       targetPart     [2] TargetPart}}
+
+OriginPartToKeep ::= SEQUENCE{
+action                  [1] IMPLICIT INTEGER{
+                                recordInsert    (1),
+                                recordReplace   (2),
+                                recordDelete    (3),
+                                elementUpdate   (4),
+                                specialUpdate   (5)},
+ databaseName           [2] IMPLICIT InternationalString,
+ schema                 [3] IMPLICIT OBJECT IDENTIFIER OPTIONAL,
+ elementSetName         [4] IMPLICIT InternationalString OPTIONAL,
+ actionQualifier        [5] IMPLICIT EXTERNAL OPTIONAL}
+
+OriginPartNotToKeep ::= SuppliedRecords
+
+TargetPart ::= SEQUENCE{
+  updateStatus        [1] IMPLICIT INTEGER{
+                          success (1),
+                          partial (2),
+                          failure (3)},
+  globalDiagnostics   [2] IMPLICIT SEQUENCE OF
+                              DiagRec OPTIONAL,
+                    -- These are non-surrogate
+                    -- diagnosticsrelating to the task,
+                    -- not to individual records.
+  taskPackageRecords  [3] IMPLICIT SEQUENCE OF
+TaskPackageRecordStructure
+                    -- There should be a
+                    -- TaskPackageRecordStructure
+                    -- for every record supplied.
+                    -- The target should create
+                    -- such a structure for every
+                    -- record immediately upon
+                    -- creating the task package
+                    -- to include correlation
+                    -- information and status.
+                    -- The record itself would not
+                    -- be included until processing
+                    -- for that record is complete.
+               }
+
+-- Auxiliary definitions for Update
+SuppliedRecords ::= SEQUENCE OF SEQUENCE{
+  recordId     [1] CHOICE{
+                number  [1] IMPLICIT INTEGER,
+                string  [2] IMPLICIT  InternationalString,
+                opaque  [3] IMPLICIT OCTET STRING} OPTIONAL,
+  supplementalId [2] CHOICE{
+                 timeStamp       [1] IMPLICIT  GeneralizedTime,
+                 versionNumber   [2] IMPLICIT InternationalString,
+                 previousVersion [3] IMPLICIT EXTERNAL} OPTIONAL,
+  correlationInfo   [3] IMPLICIT CorrelationInfo OPTIONAL,
+  record            [4] IMPLICIT EXTERNAL}
+
+CorrelationInfo ::= SEQUENCE{
+            -- origin may supply one or both for any record:
+  note [1] IMPLICIT InternationalString OPTIONAL,
+  id   [2] IMPLICIT INTEGER OPTIONAL}
+
+TaskPackageRecordStructure ::= SEQUENCE{
+     recordOrSurDiag  [1] CHOICE {
+                    record     [1] IMPLICIT EXTERNAL,
+                      -- Choose 'record' if
+                      -- recordStatus is 'success', and
+                      -- elementSetName was supplied.
+
+                  surrogateDiagnostics   [2] IMPLICIT
+                              SEQUENCE OF DiagRec
+                         -- Choose 'SurrogateDiagnostics', if
+                         -- RecordStatus is failure.
+                                } OPTIONAL,
+                -- The parameter recordOrSurDiag
+                    -- will thus be omitted only if
+                    -- 'elementSetName' was omitted and
+                    -- recordStatus is 'success'; or
+                    --if record status is 'queued'
+                    -- or in 'process'.
+     correlationInfo [2] IMPLICIT
+                         CorrelationInfo OPTIONAL,
+                    -- This should be included
+                    -- if it was supplied by the origin.
+     recordStatus    [3] IMPLICIT INTEGER{
+                                        success   (1),
+                                        queued    (2),
+                                        inProcess (3),
+                                        failure   (4)},
+      supplementalDiagnostics   [4] IMPLICIT
+                SEQUENCE OF DiagRec OPTIONAL}
+END
diff --git a/z39.50/univres.asn b/z39.50/univres.asn
new file mode 100644 (file)
index 0000000..f83320d
--- /dev/null
@@ -0,0 +1,23 @@
+ResourceReport-Format-Universe-1
+{Z39-50-resourceReport universe-1 (1000)} DEFINITIONS ::=
+BEGIN
+IMPORTS StringOrNumeric FROM Z39-50-APDU-1995;
+--
+
+UniverseReportHits ::= SEQUENCE {
+       database        StringOrNumeric,
+       hits    StringOrNumeric
+}
+
+UniverseReportDuplicate ::= SEQUENCE {
+       hitno StringOrNumeric
+}
+
+UniverseReport ::= SEQUENCE {
+       totalHits INTEGER,
+       report CHOICE {
+               databaseHits    [0] IMPLICIT UniverseReportHits,
+               duplicate               [1] IMPLICIT UniverseReportDuplicate
+       }
+}
+END
diff --git a/z39.50/z.tcl b/z39.50/z.tcl
new file mode 100644 (file)
index 0000000..065d000
--- /dev/null
@@ -0,0 +1,341 @@
+# YC Sample Config File for Z39.50
+# $Id: z.tcl,v 1.1 1999-06-08 10:10:16 adam Exp $
+# ----------------------------------------------------------
+# Prefix Specifications
+#  
+#    1: C function prefix
+#    2: C type prefix
+#    3: C preprocessor prefix
+
+# Default prefix
+set default-prefix {z_ Z_ Z_}
+
+# Name clash in extended services (TargetPart, OriginPartToKeep, etc)
+# You can possibly think of better names :)
+set prefix(ESFormat-PersistentResultSet) {z_PR Z_PR Z_PR}
+set prefix(ESFormat-PersistentQuery) {z_PQuery Z_PQuery Z_PQuery}
+set prefix(ESFormat-PeriodicQuerySchedule) {z_PQS Z_PQS Z_PQS}
+set prefix(ESFormat-ItemOrder) {z_IO Z_IO Z_IO}
+set prefix(ESFormat-Update0) {z_IU0 Z_IU0 Z_IU0}
+set prefix(ESFormat-Update) {z_IU Z_IU Z_IU}
+set prefix(ESFormat-ExportSpecification) {z_ES Z_ES Z_ES}
+set prefix(ESFormat-ExportInvocation) {z_EI Z_EI Z_EI}
+
+# ----------------------------------------------------------
+# Settings for core of the protocol
+set m Z39-50-APDU-1995
+
+# Filename
+set filename($m) z-core
+
+# Public header initialization code
+set init($m,h) {
+typedef struct Z_External Z_External;
+YAZ_EXPORT int z_External(ODR o, Z_External **p, int opt, const char *name);
+}
+
+set body($m,h) "
+#ifdef __cplusplus
+extern \"C\" \{
+#endif
+
+int z_ANY_type_0 (ODR o, void **p, int opt);
+
+#ifdef __cplusplus
+\}
+#endif
+"
+set body($m,c) {
+
+/* the type-0 query ... */
+int z_ANY_type_0 (ODR o, void **p, int opt)
+{
+    return 0;
+}
+
+}
+
+# Type Name overrides
+set map($m,PDU) APDU
+set map($m,AttributeElement_complex) ComplexAttribute
+set map($m,DeleteSetStatus) DeleteStatus
+set membermap($m,ProximityOperator,private) {ProximityOperator_private zprivate}
+set unionmap($m,AttributeElement,attributeValue) {which value AttributeValue}
+set membermap($m,ElementSpec,externalEspec) externalSpec
+set membermap($m,RPNStructure,op) simple
+set membermap($m,RPNStructure,rpnRpnOp) complex
+set map($m,RPNStructure_complex) Complex
+set membermap($m,Operand,attrTerm) {Operand_APT attributesPlusTerm}
+set membermap($m,Operand,resultSet) {Operand_resultSetId resultSetId}
+set membermap($m,Operand,resultAttr) {Operand_resultAttr resultAttr}
+set membermap($m,Complex,rpn1) s1
+set membermap($m,Complex,rpn2) s2
+set membermap($m,Complex,op) roperator
+set membermap($m,RPNQuery,attributeSet) attributeSetId
+set membermap($m,RPNQuery,rpn) RPNStructure
+set map($m,KnownProximityUnit) ProxUnit
+set membermap($m,ProximityOperator,lessThan) {Prox_lessThan 1}
+set membermap($m,ProximityOperator,lessThanOrEqual) {Prox_lessThanOrEqual 1}
+set membermap($m,ProximityOperator,equal) {Prox_equal 1}
+set membermap($m,ProximityOperator,greaterThanOrEqual) {Prox_greaterThanOrEqual 1}
+set membermap($m,ProximityOperator,greaterThan) {Prox_greaterThan 1}
+set membermap($m,ProximityOperator,notEqual) {Prox_notEqual 1}
+#
+set membermap($m,Records,responseRecords) {Records_DBOSD databaseOrSurDiagnostics}
+set membermap($m,Records,nonSurrogateDiagnostic) {Records_NSD nonSurrogateDiagnostic}
+set membermap($m,Records,multipleNonSurDiagnostics) {Records_multipleNSD multipleNonSurDiagnostics}
+set map($m,Records_DBOSD) NamePlusRecordList
+set map($m,Records_NSD) DiagRec
+set map($m,Records_multipleNSD) DiagRecs
+set membermap($m,NamePlusRecord,name) databaseName
+set unionmap($m,DiagRecs) {num_diagRecs diagRecs}
+set unionmap($m,NamePlusRecordList) {num_records records}
+#
+set membermap($m,ElementSetNames,genericElementSetName) generic
+set map($m,ElementSetNames_databaseSpecific) DatabaseSpecific
+#
+set map($m,OccurrenceByAttributes_s) OccurrenceByAttributesElem
+set map($m,OccurrenceByAttributesElem_byDatabase) byDatabaseList
+#
+set membermap($m,SortElement,datbaseSpecific) databaseSpecific
+set map($m,SortElement_databaseSpecific) SortDbSpecificList
+#
+set map($m,SortKey_sortAttributes) SortAttributes
+set unionmap($m,PresentRequest,recordComposition) {}
+set map($m,PresentRequest_0) RecordComposition
+set unionmap($m,PresentRequest,additionalRanges) {num_ranges additionalRanges}
+set unionmap($m,SortRequest,sortSequence) {}
+set map($m,SortRequest_0) SortKeySpecList
+set unionmap($m,SortKeySpecList) {num_specs specs}
+set map($m,InitializeRequest) InitRequest
+set map($m,InitializeResponse) InitResponse
+set unionmap($m,CloseReason) Close
+set membermap($m,ProtocolVersion,version-1) 1
+set membermap($m,ProtocolVersion,version-2) 2
+set membermap($m,ProtocolVersion,version-3) 3
+set membermap($m,InitRequest,exceptionalRecordSize) maximumRecordSize
+set membermap($m,InitResponse,exceptionalRecordSize) maximumRecordSize
+set map($m,RecordsMultipleNonSurDiagnostics) DiagRecs
+set map($m,RecordsDatabaseOrSurDiagnostics) NamePlusRecordList
+set membermap($m,NamePlusRecord,retrievalRecord) databaseRecord
+set unionmap($m,RecordComposition) {which u RecordComp}
+set unionmap($m,ScanResponse,scanStatus) Scan
+set unionmap($m,AttributeList) {num_attributes attributes}
+set membermap($m,SortKey,sortfield) sortField
+set map($m,CompSpec_0) DbSpecific
+set map($m,DatabaseSpecific_s) DatabaseSpecificUnit
+set map($m,ListStatuses_s) ListStatus
+set map($m,IdAuthenticationIdPass) IdPass
+set map($m,OtherInformation_s) OtherInformationUnit
+set unionmap($m,OtherInformationUnit,information) {which information OtherInfo}
+set unionmap($m,OtherInformation) {num_elements list}
+set unionmap($m,Specification,elementSpec) {}
+set map($m,Specification_0) ElementSpec
+
+# ----
+set m DiagnosticFormatDiag1
+set filename($m) z-diag1
+set map($m,DiagFormat_tooMany) TooMany
+set map($m,DiagFormat_badSpec) BadSpec
+set map($m,DiagFormat_dbUnavail) DbUnavail
+set map($m,DiagFormat_attribute) Attribute
+set map($m,DiagFormat_attCombo) AttCombo
+set map($m,DiagFormat_term) DiagTerm
+set map($m,DiagFormat_proximity) Proximity
+set map($m,DiagFormat_scan) Scan
+set map($m,DiagFormat_sort) Sort
+set unionmap($m,Sort) {which u SortD}
+set map($m,DiagFormat_segmentation) Segmentation
+set map($m,DiagFormat_extServices) ExtServices
+set map($m,DiagFormat_accessCtrl) AccessCtrl
+set map($m,DiagFormat_recordSyntax) RecordSyntax
+#
+set map($m,Scan_termList2) AttrListList
+set map($m,Sort_inputTooLarge) StringList
+#
+set map($m,AccessCtrl_oid) OidList
+set map($m,AccessCtrl_alternative) AltOidList
+# ----
+set m RecordSyntax-explain
+set filename($m) z-exp
+set map($m,Explain-Record) ExplainRecord
+set map($m,ElementDataType_structured) ElementInfoList
+set map($m,HumanString_s) HumanStringUnit
+set unionmap($m,HumanString) {num_strings strings}
+set membermap($m,CommonInfo,humanString-Language) humanStringLanguage
+set unionmap($m,AttributeOccurrence,attributeValues) {which attributeValues AttributeOcc}
+set unionmap($m,AttributeCombination) {num_occurrences occurrences}
+#
+set membermap($m,NetworkAddress,internetAddress) {NetworkAddress_iA internetAddress}
+set map($m,NetworkAddress_iA) NetworkAddressIA
+set membermap($m,NetworkAddress,osiPresentationAddress) {NetworkAddress_oPA osiPresentationAddress}
+set map($m,NetworkAddress_oPA) NetworkAddressOPA
+set map($m,NetworkAddress_other) NetworkAddressOther
+set unionmap($m,DatabaseList) {num_databases databases}
+set membermap($m,TargetInfo,recent-news) recentNews
+set membermap($m,TargetInfo,usage-restrictions) usageRest
+set membermap($m,DatabaseInfo,user-fee) userFee
+#
+set map($m,ProximitySupport_0) ProxSupportUnit
+set map($m,ProxSupportUnitZprivate) ProxSupportPrivate
+set membermap($m,ProxSupportUnit,private) {ProxSupportUnit_private zprivate}
+#
+set map($m,AttributeOccurrence_specific) AttributeValueList
+set unionmap($m,AttributeValueList) {num_attributes attributes}
+
+set unionmap($m,ExplainRecord) {which u Explain}
+set map($m,SchemaInfo_0) TagTypeMapping
+set map($m,TagSetInfo_0) TagSetElements
+set map($m,TermListInfo_0) TermListElement
+set map($m,TermListDetails_0) EScanInfo
+set map($m,PrivateCapabilities_0) PrivateCapOperator
+set map($m,Costs_0) CostsOtherCharge
+set map($m,Path_s) PathUnit
+set map($m,IconObject_s) IconObjectUnit
+set map($m,NetworkAddressInternetAddress) NetworkAddressIA
+set map($m,NetworkAddressOsiPresentationAddress) NetworkAddressOPA
+set membermap($m,QueryTypeDetails,private) {QueryTypeDetails_private zprivate}
+set membermap($m,PrivateCapOperator,operator) roperator
+set map($m,AccessRestrictions_s) AccessRestrictionsUnit
+# ----
+set m RecordSyntax-SUTRS
+set filename($m) z-sutrs
+#set map($m,SutrsRecord) SUTRS
+set body($m,c) {
+int z_SUTRS (ODR o, Odr_oct **p, int opt)
+{
+    return odr_implicit(o, odr_octetstring, p, ODR_UNIVERSAL,
+        ODR_GENERALSTRING, opt);
+}
+}
+
+set init($m,h) {
+typedef Odr_oct Z_SUTRS;
+YAZ_EXPORT int z_SUTRS (ODR o, Odr_oct **p, int opt);
+}
+# ----
+set m RecordSyntax-opac
+set filename($m) z-opac
+# ----
+set m RecordSyntax-summary
+set filename($m) z-sum
+# ----
+set m RecordSyntax-generic
+set filename($m) z-grs
+set map($m,ElementData_subtree) GenericRecord
+set map($m,Variant_0) Triple
+set membermap($m,Triple,class) zclass
+set unionmap($m,Triple,value) {which value Triple}
+set unionmap($m,GenericRecord) {num_elements elements}
+# ----
+set m RecordSyntax-ESTaskPackage
+set filename($m) z-estask
+# ----
+set m ResourceReport-Format-Resource-1
+set filename($m) z-rrf1
+set map($m,ResourceReport) ResourceReport1
+set map($m,Estimate) Estimate1
+# ----
+set m ResourceReport-Format-Resource-2
+set filename($m) z-rrf2
+set map($m,ResourceReport) ResourceReport2
+set map($m,Estimate) Estimate2
+# ----
+set m AccessControlFormat-prompt-1
+set filename($m) z-accform1
+set membermap($m,PromptId,enummeratedPrompt) enumeratedPrompt 
+set map($m,PromptObject) PromptObject1
+set map($m,Challenge) Challenge1
+set map($m,Challenge1_s) ChallengeUnit1
+set map($m,Response) Response1
+set map($m,Response1_s) ResponseUnit1
+set map($m,PromptObject) PromptObject1
+# ----
+set m AccessControlFormat-des-1
+set filename($m) z-accdes1
+# ----
+set m AccessControlFormat-krb-1
+set filename($m) z-acckrb1
+# ----
+set m ESFormat-PersistentResultSet
+set filename($m) zes-pset
+# ----
+set m ESFormat-PersistentQuery
+set filename($m) zes-pquery
+# ----
+set m ESFormat-PeriodicQuerySchedule 
+set filename($m) zes-psched
+# ----
+set m ESFormat-ItemOrder
+set filename($m) zes-order
+set map($m,ItemOrderEsRequest) Request
+set map($m,ItemOrderTaskPackage) TaskPackage
+set map($m,OriginPartToKeep_0) Contact
+set map($m,OriginPartToKeep_1) Billing
+set map($m,OriginPartNotToKeep_0) ResultSetItem
+#
+# ---- (old version)
+set m ESFormat-Update0
+set filename($m) zes-update0
+set map($m,SuppliedRecords_s) SuppliedRecords_elem
+set map($m,SuppliedRecords_elem_0) SuppliedRecordsId
+#
+# ---- (new, current version)
+set m ESFormat-Update
+set filename($m) zes-update
+set map($m,SuppliedRecords_s) SuppliedRecords_elem
+set map($m,SuppliedRecords_elem_0) SuppliedRecordsId
+# ----
+set m ESFormat-ExportSpecification
+set filename($m) zes-exps
+# ----
+set m ESFormat-ExportInvocation
+set filename($m) zes-expi
+# ----
+set m UserInfoFormat-searchResult-1
+set filename($m) z-uifr1
+# ----
+set m ElementSpecificationFormat-eSpec-1
+set filename($m) z-espec1
+set map($m,Espec-1) Espec1
+set map($m,TagPath) ETagPath
+set map($m,ETagPath_s) ETagUnit
+set map($m,ETagUnitSpecificTag) SpecificTag
+set membermap($m,SpecificTag,occurrence) occurrences
+set unionmap($m,ElementRequest) {which u ERequest}
+set unionmap($m,ETagPath) {num_tags tags}
+set map($m,OccurrencesValues) OccurValues
+# ----
+set m UserInfoFormat-dateTime
+set filename($m) z-date
+set map($m,Z3950Date) Date
+set map($m,Z3950Time) Time
+set unionmap($m,Z3950Date,era) {}
+set map($m,DateFlags_0) Era
+set map($m,Z3950DateMonthAndDay) MonthAndDay
+set map($m,Z3950DateQuarter) DateQuater
+set map($m,Z3950DateSeason) DateSeason
+set map($m,Date_0) DateFlags
+set unionmap($m,DateFlags,era) {}
+# ----
+set m ResourceReport-Format-Universe-1 
+set filename($m) z-univ
+
+# ----------------------------------------------------------
+# "Constructed" types defined by means of C-types are declared here.
+# Each function returns the C-handler and the C-type.
+proc asnBasicGeneralString {} {
+    return {odr_generalstring char}
+}
+
+proc asnBasicVisibleString {} {
+    return {odr_visiblestring char}
+}
+
+proc asnBasicGeneralizedTime {} {
+    return {odr_generalizedtime char}
+}
+
+proc asnBasicEXTERNAL {} {
+    return {z_External Z_External}
+}
diff --git a/z39.50/z3950v3.asn b/z39.50/z3950v3.asn
new file mode 100644 (file)
index 0000000..5974370
--- /dev/null
@@ -0,0 +1,2590 @@
+Z39-50-APDU-1995 -- OID for this definition, assigned in OID.3.1, is {Z39-50 2 1} 
+DEFINITIONS ::=  
+BEGIN   -- Z39.50 Maintenance Agency Official Text for ANSI/NISO Z39.50-1995 - July 1995
+--
+EXPORTS OtherInformation, Term, AttributeSetId, AttributeList, AttributeElement, ElementSetName, SortElement, DatabaseName,
+CompSpec, Specification, Permissions, InternationalString, IntUnit, Unit, StringOrNumeric, Query, Records, ResultSetId,
+DefaultDiagFormat, DiagRec;
+--
+
+PDU ::= CHOICE{
+ initRequest        [20] IMPLICIT InitializeRequest,
+ initResponse      [21] IMPLICIT InitializeResponse,
+ searchRequest      [22] IMPLICIT SearchRequest,
+ searchResponse      [23] IMPLICIT SearchResponse,
+ presentRequest      [24] IMPLICIT PresentRequest,
+ presentResponse      [25] IMPLICIT PresentResponse,
+ deleteResultSetRequest    [26] IMPLICIT DeleteResultSetRequest,
+ deleteResultSetResponse    [27] IMPLICIT DeleteResultSetResponse,
+ accessControlRequest    [28] IMPLICIT AccessControlRequest,
+ accessControlResponse    [29] IMPLICIT AccessControlResponse,
+ resourceControlRequest         [30] IMPLICIT ResourceControlRequest,
+ resourceControlResponse    [31] IMPLICIT ResourceControlResponse,
+ triggerResourceControlRequest  [32] IMPLICIT TriggerResourceControlRequest,
+ resourceReportRequest          [33] IMPLICIT ResourceReportRequest,
+ resourceReportResponse    [34] IMPLICIT ResourceReportResponse,
+ scanRequest         [35] IMPLICIT ScanRequest,
+ scanResponse      [36] IMPLICIT ScanResponse,
+              -- [37] through [42] reserved
+ sortRequest        [43] IMPLICIT SortRequest,
+ sortResponse      [44] IMPLICIT SortResponse,
+ segmentRequest      [45] IMPLICIT Segment,
+ extendedServicesRequest    [46] IMPLICIT ExtendedServicesRequest,
+ extendedServicesResponse    [47] IMPLICIT ExtendedServicesResponse,
+ close          [48] IMPLICIT Close}
+
+
+-- Initialize APDUs
+--
+  InitializeRequest ::= SEQUENCE{
+  referenceId        ReferenceId OPTIONAL,
+  protocolVersion      ProtocolVersion,
+  options        Options,
+  preferredMessageSize  [5]  IMPLICIT INTEGER,
+   exceptionalRecordSize  [6]  IMPLICIT INTEGER,
+   idAuthentication    [7]    IdAuthentication OPTIONAL, -- see note below
+  implementationId    [110]  IMPLICIT InternationalString OPTIONAL,
+  implementationName  [111]  IMPLICIT InternationalString OPTIONAL,
+   implementationVersion  [112]  IMPLICIT InternationalString OPTIONAL,   
+  userInformationField  [11]  EXTERNAL OPTIONAL,
+  otherInfo        OtherInformation OPTIONAL}
+--Note:
+-- For idAuthentication, the type ANY is retained for compatibility with earlier versions. 
+-- For interoperability, the following is recommended:
+IdAuthentication ::=
+   CHOICE{
+      open   VisibleString,
+      idPass  SEQUENCE {
+      groupId  [0]  IMPLICIT InternationalString OPTIONAL,
+      userId   [1]  IMPLICIT InternationalString OPTIONAL,
+      password  [2]  IMPLICIT InternationalString OPTIONAL },
+      anonymous  NULL,
+      other    EXTERNAL
+   }
+-- May use access control formats for 'other'.  See Appendix 7 ACC.
+--
+  InitializeResponse ::= SEQUENCE{
+  referenceId        ReferenceId OPTIONAL,
+   protocolVersion                ProtocolVersion,
+  options              Options,
+  preferredMessageSize  [5]  IMPLICIT INTEGER,
+   exceptionalRecordSize  [6]  IMPLICIT INTEGER,
+  result        [12]  IMPLICIT BOOLEAN,    -- reject = FALSE; Accept = TRUE
+  implementationId    [110]  IMPLICIT InternationalString OPTIONAL,
+  implementationName  [111]  IMPLICIT InternationalString OPTIONAL,
+   implementationVersion  [112]  IMPLICIT InternationalString OPTIONAL,   
+  userInformationField  [11]  EXTERNAL OPTIONAL,
+  otherInfo        OtherInformation OPTIONAL}
+-- Begin auxiliary definitions for Init PDUs
+  ProtocolVersion  ::=  [3]   IMPLICIT BIT STRING{
+    version-1      (0),       -- This bit should always be set, but does not
+              -- correspond to any Z39.50 version.
+    version-2      (1),              -- "Version 2 supported."
+              -- This bit should always be set.
+    version-3      (2)        -- "Version 3 supported."
+-- Values higher than 'version-3' should be ignored. Both the Initialize request and Initialize Response APDUs
+-- include a value string corresponding to the supported versions. The highest common version is selected
+-- for use. If there are no versions in common, "Result" in the Init Response should indicate "reject."
+-- Note: Versions 1 and 2 are identical. Systems supporting version 2 should indicate support for version
+-- 1 as well, for interoperability with systems that indicate support for version 1 only (e.g. ISO 10163-1991
+-- implementations).  
+  }
+  Options  ::= [4] IMPLICIT BIT STRING{ 
+      search        (0), 
+      present       (1), 
+      delSet        (2),
+       resourceReport    (3),
+      triggerResourceCtrl    (4),
+      resourceCtrl       (5), 
+      accessCtrl       (6),
+      scan         (7),
+      sort        (8), 
+      --        (9) (reserved)
+      extendedServices    (10),
+      level-1Segmentation    (11),
+      level-2Segmentation    (12),
+      concurrentOperations  (13),
+      namedResultSets    (14)}
+-- end auxiliary definitions for Init PDUs
+
+
+--Search APDUs
+  SearchRequest ::= SEQUENCE{
+  referenceId          ReferenceId OPTIONAL,
+      smallSetUpperBound    [13]  IMPLICIT INTEGER,
+  largeSetLowerBound    [14]  IMPLICIT INTEGER,
+  mediumSetPresentNumber    [15]  IMPLICIT INTEGER,
+  replaceIndicator      [16]  IMPLICIT BOOLEAN,
+  resultSetName      [17]  IMPLICIT InternationalString,
+   databaseNames      [18]   IMPLICIT SEQUENCE OF DatabaseName,
+   smallSetElementSetNames    [100]  ElementSetNames OPTIONAL,
+    mediumSetElementSetNames  [101]  ElementSetNames OPTIONAL,
+  preferredRecordSyntax    [104]  IMPLICIT OBJECT IDENTIFIER OPTIONAL,
+  query          [21]  Query,
+    -- Following two parameters may be used only if version 3 is in force.
+   additionalSearchInfo    [203]  IMPLICIT OtherInformation OPTIONAL,
+  otherInfo          OtherInformation OPTIONAL}
+
+
+-- Query Definitions
+  Query  ::=  CHOICE{
+      type-0  [0]  ANY,  
+        type-1    [1]  IMPLICIT RPNQuery,
+        type-2      [2]  OCTET STRING,
+        type-100  [100]  OCTET STRING,
+        type-101  [101]  IMPLICIT RPNQuery,
+       type-102  [102]  OCTET STRING}
+--
+-- Definitions for RPN query
+     RPNQuery ::= SEQUENCE{
+      attributeSet    AttributeSetId,
+      rpn      RPNStructure}
+--
+  RPNStructure ::= CHOICE{
+    op    [0] Operand, 
+     rpnRpnOp  [1] IMPLICIT SEQUENCE{
+          rpn1    RPNStructure,
+                rpn2    RPNStructure,
+                op    Operator }} 
+  Operand ::= CHOICE{
+    attrTerm  AttributesPlusTerm, 
+    resultSet  ResultSetId, 
+          -- If version 2 is in force: 
+          --   - If query type is 1, one of the above two must be chosen; 
+          --   - resultAttr (below) may be used only if query type is 101. 
+    resultAttr  ResultSetPlusAttributes}
+
+  AttributesPlusTerm ::= [102] IMPLICIT SEQUENCE{
+         attributes  AttributeList, 
+        term    Term}
+  ResultSetPlusAttributes ::= [214] IMPLICIT SEQUENCE{
+        resultSet  ResultSetId,
+        attributes  AttributeList}
+  AttributeList ::=    [44]  IMPLICIT SEQUENCE OF AttributeElement
+--
+  Term ::= CHOICE{
+    general      [45]  IMPLICIT OCTET STRING,
+              -- values below may be used only if version 3 is in force
+    numeric      [215]  IMPLICIT INTEGER,
+    characterString    [216]  IMPLICIT InternationalString,
+    oid        [217]  IMPLICIT OBJECT IDENTIFIER,
+    dateTime      [218]  IMPLICIT GeneralizedTime,
+    external      [219]  IMPLICIT EXTERNAL,
+    integerAndUnit    [220] IMPLICIT IntUnit,
+    null        [221] IMPLICIT NULL}   
+
+  Operator ::= [46] CHOICE{
+         and    [0] IMPLICIT NULL,
+            or    [1] IMPLICIT NULL,
+                and-not  [2] IMPLICIT NULL,
+              -- If version 2 is in force: 
+              --  - For query type 1, one of the above three must be chosen;
+              --  - prox (below) may be used only if query type is 101. 
+        prox    [3] IMPLICIT ProximityOperator}
+  AttributeElement  ::=  SEQUENCE{
+    attributeSet    [1]    IMPLICIT AttributeSetId OPTIONAL,
+                -- Must be omitted if version 2 is in force.
+                -- If included, overrides value of attributeSet
+                -- in RPNQuery above, but only for this attribute.
+    attributeType  [120]  IMPLICIT INTEGER,
+    attributeValue    CHOICE{
+              numeric  [121]   IMPLICIT INTEGER,
+                  -- If version 2 is in force, 
+                  -- Must select 'numeric' for attributeValue.
+
+      complex  [224] IMPLICIT SEQUENCE{ 
+               list      [1] IMPLICIT SEQUENCE OF StringOrNumeric,
+                    semanticAction  [2] IMPLICIT SEQUENCE OF INTEGER OPTIONAL}}}
+                       
+
+  ProximityOperator ::= SEQUENCE{
+    exclusion      [1] IMPLICIT BOOLEAN OPTIONAL,
+    distance      [2] IMPLICIT INTEGER,
+    ordered      [3] IMPLICIT BOOLEAN,
+    relationType      [4] IMPLICIT INTEGER{
+              lessThan      (1),
+              lessThanOrEqual    (2),
+              equal        (3),
+              greaterThanOrEqual    (4),
+              greaterThan      (5),
+              notEqual      (6)},
+    proximityUnitCode    [5] CHOICE{
+              known  [1] IMPLICIT KnownProximityUnit,
+              private  [2] IMPLICIT INTEGER}}
+--
+    KnownProximityUnit ::= INTEGER{
+          character  (1),
+          word     (2),
+          sentence   (3),
+          paragraph   (4),
+          section   (5),
+          chapter   (6),
+          document   (7),
+          element  (8),
+          subelement  (9),
+          elementType  (10),
+           byte    (11) -- Version 3 only
+          }
+-- End definitions for RPN Query
+
+
+SearchResponse ::= SEQUENCE{
+  referenceId        ReferenceId OPTIONAL,
+  resultCount       [23]  IMPLICIT INTEGER,
+  numberOfRecordsReturned  [24]  IMPLICIT INTEGER,
+  nextResultSetPosition  [25]  IMPLICIT INTEGER,
+  searchStatus      [22]  IMPLICIT BOOLEAN,
+  resultSetStatus    [26]  IMPLICIT INTEGER{
+              subset    (1),
+                 interim  (2), 
+               none    (3)} OPTIONAL,
+  presentStatus        PresentStatus  OPTIONAL,
+    records        Records OPTIONAL,
+    -- Following two parameters may be used only if version 3 is in force.
+  additionalSearchInfo  [203]  IMPLICIT OtherInformation OPTIONAL,
+  otherInfo        OtherInformation OPTIONAL}
+--Retrieval APDUs 
+  PresentRequest ::= SEQUENCE{
+  referenceId          ReferenceId OPTIONAL,
+      resultSetId          ResultSetId,
+  resultSetStartPoint      [30]  IMPLICIT INTEGER,
+  numberOfRecordsRequested  [29]  IMPLICIT INTEGER,
+  additionalRanges      [212]  IMPLICIT SEQUENCE OF Range OPTIONAL,
+      -- additionalRanges may be included only if version 3 is in force.
+  recordComposition      CHOICE{
+                simple  [19]         ElementSetNames,
+                -- must choose 'simple' if version 2 is in force
+                complex  [209]               IMPLICIT CompSpec} OPTIONAL,
+  preferredRecordSyntax    [104]  IMPLICIT OBJECT IDENTIFIER OPTIONAL,
+  maxSegmentCount      [204]  IMPLICIT INTEGER OPTIONAL, -- level 1 or 2
+  maxRecordSize      [206]  IMPLICIT INTEGER OPTIONAL, -- level 2 only
+  maxSegmentSize      [207]  IMPLICIT INTEGER OPTIONAL, -- level 2 only
+  otherInfo          OtherInformation OPTIONAL}
+--
+  Segment ::= SEQUENCE{
+      -- Segment PDU may only be used when version 3 is in force, 
+      -- and only when segmentation is in effect.
+   referenceId          ReferenceId OPTIONAL,
+     numberOfRecordsReturned    [24]  IMPLICIT INTEGER,
+  segmentRecords      [0]  IMPLICIT SEQUENCE OF NamePlusRecord,
+  otherInfo          OtherInformation OPTIONAL}
+--
+  PresentResponse ::= SEQUENCE{
+  referenceId          ReferenceId OPTIONAL,
+  numberOfRecordsReturned    [24]  IMPLICIT INTEGER,
+   nextResultSetPosition    [25]  IMPLICIT INTEGER,
+    presentStatus          PresentStatus,
+  records          Records OPTIONAL,
+  otherInfo          OtherInformation OPTIONAL} 
+-- begin auxiliary definitions for Search and Present APDUs
+
+-- begin definition of records
+  Records ::= CHOICE{
+  responseRecords      [28]  IMPLICIT SEQUENCE OF NamePlusRecord,
+  nonSurrogateDiagnostic     [130]  IMPLICIT DefaultDiagFormat,
+  multipleNonSurDiagnostics   [205]  IMPLICIT SEQUENCE OF DiagRec} 
+--
+  NamePlusRecord  ::=  SEQUENCE{
+  name    [0] IMPLICIT DatabaseName OPTIONAL,
+  record  [1] CHOICE{
+        retrievalRecord        [1] EXTERNAL,
+        surrogateDiagnostic    [2] DiagRec, 
+          -- Must select one of the above two, retrievalRecord or
+          -- surrogateDiagnostic, unless 'level 2 segmentation' is in effect.
+        startingFragment    [3] FragmentSyntax,
+        intermediateFragment  [4] FragmentSyntax,
+        finalFragment    [5] FragmentSyntax}}
+  FragmentSyntax ::= CHOICE{
+    externallyTagged    EXTERNAL,
+    notExternallyTagged  OCTET STRING}
+
+  DiagRec ::= CHOICE{
+      defaultFormat    DefaultDiagFormat,
+                -- Must choose defaultFormat if version 2 is in effect.
+      externallyDefined    EXTERNAL}
+
+  DefaultDiagFormat::= SEQUENCE{ 
+  diagnosticSetId  OBJECT IDENTIFIER,
+  condition    INTEGER,
+  addinfo      CHOICE{
+           v2Addinfo  VisibleString,  -- version 2
+           v3Addinfo  InternationalString  -- version 3
+            }}
+  -- end definition of records
+  Range  ::= SEQUENCE{
+    startingPosition    [1] IMPLICIT INTEGER,
+    numberOfRecords    [2] IMPLICIT INTEGER} 
+--
+  ElementSetNames ::= CHOICE {
+    genericElementSetName  [0] IMPLICIT InternationalString,
+    databaseSpecific    [1] IMPLICIT SEQUENCE OF SEQUENCE{
+              dbName  DatabaseName,
+              esn    ElementSetName}}
+
+  PresentStatus   ::=    [27]  IMPLICIT INTEGER{
+                            success  (0),
+                             partial-1   (1),
+                              partial-2   (2),
+              partial-3   (3),
+                                      partial-4   (4),
+                               failure    (5)}
+
+-- begin definition of composition specification
+  CompSpec ::= SEQUENCE{
+  selectAlternativeSyntax  [1] IMPLICIT BOOLEAN,
+            -- See comment for recordSyntax, below.
+  generic             [2] IMPLICIT Specification OPTIONAL,
+  dbSpecific      [3] IMPLICIT SEQUENCE OF SEQUENCE{
+                db  [1] DatabaseName,
+                spec  [2] IMPLICIT Specification} OPTIONAL,
+    -- At least one of generic and dbSpecific must occur, and both may occur. If both, then for
+     -- any record not in the list of databases within dbSpecific, generic applies.
+   recordSyntax               [4] IMPLICIT SEQUENCE OF OBJECT IDENTIFIER OPTIONAL
+               -- For each record, the target selects the first record syntax
+               -- in this list that it can support.  If the list is exhausted, the
+               -- target may select an alternative syntax if
+               -- selectAlternativeSyntax is 'true'.
+        }
+  Specification ::= SEQUENCE{
+  schema    [1] IMPLICIT OBJECT IDENTIFIER OPTIONAL,
+  elementSpec    [2] CHOICE{
+              elementSetName   [1] IMPLICIT InternationalString,
+          externalEspec  [2] IMPLICIT EXTERNAL} OPTIONAL}
+-- end definition of composition specification
+-- end auxiliary definitions for search and response APDUs
+
+-- Delete APDUs
+  DeleteResultSetRequest ::= SEQUENCE{
+  referenceId          ReferenceId OPTIONAL,
+      deleteFunction      [32]  IMPLICIT INTEGER{
+                    list   (0),
+                    all   (1)},
+   resultSetList          SEQUENCE OF ResultSetId OPTIONAL,
+  otherInfo          OtherInformation OPTIONAL} 
+--
+  DeleteResultSetResponse ::= SEQUENCE{
+  referenceId          ReferenceId OPTIONAL,
+    deleteOperationStatus    [0]  IMPLICIT DeleteSetStatus,
+  deleteListStatuses      [1]  IMPLICIT ListStatuses OPTIONAL,
+  numberNotDeleted       [34]  IMPLICIT INTEGER OPTIONAL,
+     bulkStatuses        [35]   IMPLICIT ListStatuses OPTIONAL,
+   deleteMessage      [36]  IMPLICIT InternationalString OPTIONAL,
+  otherInfo          OtherInformation OPTIONAL}
+  ListStatuses ::= SEQUENCE OF SEQUENCE{ 
+        id  ResultSetId, 
+        status  DeleteSetStatus}
+
+  DeleteSetStatus ::= [33] IMPLICIT INTEGER{
+                  success          (0),
+                   resultSetDidNotExist      (1),
+                    previouslyDeletedByTarget      (2),
+                     systemProblemAtTarget      (3),
+                   accessNotAllowed        (4),
+      resourceControlAtOrigin      (5),
+                   resourceControlAtTarget      (6),
+                    bulkDeleteNotSupported      (7),
+                   notAllRsltSetsDeletedOnBulkDlte    (8),
+      notAllRequestedResultSetsDeleted    (9),
+      resultSetInUse        (10)}
+--
+
+--Access- and Resource-control APDUs
+--
+  AccessControlRequest ::= SEQUENCE{
+  referenceId        ReferenceId OPTIONAL,
+  securityChallenge      CHOICE{
+              simpleForm      [37] IMPLICIT OCTET STRING,
+               externallyDefined    [0]  EXTERNAL},
+  otherInfo        OtherInformation OPTIONAL}
+
+  AccessControlResponse ::= SEQUENCE{
+  referenceId        ReferenceId OPTIONAL,
+  securityChallengeResponse  CHOICE{
+              simpleForm      [38]   IMPLICIT OCTET STRING,
+               externallyDefined    [0]  EXTERNAL} OPTIONAL,
+              -- Optional only in version 3; mandatory in version 2. If
+              -- omitted (in version 3) then diagnostic must occur.
+  diagnostic    [223]    DiagRec OPTIONAL, -- Version 3 only.
+  otherInfo        OtherInformation OPTIONAL}
+
+
+
+  ResourceControlRequest ::= SEQUENCE{
+  referenceId          ReferenceId OPTIONAL,
+  suspendedFlag      [39]  IMPLICIT BOOLEAN OPTIONAL,
+  resourceReport      [40]  ResourceReport OPTIONAL,
+  partialResultsAvailable    [41]  IMPLICIT INTEGER{
+                subset    (1),
+                interim  (2),
+                none    (3)} OPTIONAL,
+  responseRequired      [42]   IMPLICIT BOOLEAN, 
+  triggeredRequestFlag    [43]   IMPLICIT BOOLEAN OPTIONAL,
+  otherInfo          OtherInformation OPTIONAL}
+
+
+  ResourceControlResponse ::= SEQUENCE{
+     referenceId          ReferenceId OPTIONAL,
+    continueFlag       [44]   IMPLICIT BOOLEAN, 
+  resultSetWanted      [45]  IMPLICIT BOOLEAN OPTIONAL,
+  otherInfo          OtherInformation OPTIONAL}
+
+
+
+  TriggerResourceControlRequest ::= SEQUENCE{
+     referenceId          ReferenceId OPTIONAL,
+  requestedAction      [46]  IMPLICIT INTEGER{
+                resourceReport  (1),
+                resourceControl  (2),
+                cancel      (3)}, 
+  prefResourceReportFormat    [47]   IMPLICIT ResourceReportId OPTIONAL,
+  resultSetWanted      [48]   IMPLICIT BOOLEAN OPTIONAL,
+  otherInfo          OtherInformation OPTIONAL}
+
+
+
+  ResourceReportRequest ::= SEQUENCE{
+     referenceId          ReferenceId OPTIONAL,
+  opId          [210]  IMPLICIT ReferenceId OPTIONAL,
+  prefResourceReportFormat    [49]   IMPLICIT ResourceReportId OPTIONAL,
+  otherInfo          OtherInformation OPTIONAL}
+--
+  ResourceReportResponse ::= SEQUENCE{
+     referenceId          ReferenceId OPTIONAL,
+  resourceReportStatus    [50]   IMPLICIT INTEGER{
+                success    (0),
+                partial    (1),
+                failure-1    (2),
+                failure-2    (3),
+                failure-3    (4),
+                failure-4    (5),
+                failure-5    (6),
+                failure-6    (7)},
+  resourceReport               [51]   ResourceReport OPTIONAL,
+  otherInfo          OtherInformation OPTIONAL}
+--
+   ResourceReport     ::=   EXTERNAL
+  ResourceReportId    ::=    OBJECT IDENTIFIER
+
+--Scan APDUs
+  ScanRequest ::= SEQUENCE{
+  referenceId              ReferenceId OPTIONAL,
+    databaseNames        [3]  IMPLICIT SEQUENCE OF DatabaseName,
+    attributeSet            AttributeSetId OPTIONAL,
+    termListAndStartPoint        AttributesPlusTerm,
+    stepSize           [5]   IMPLICIT INTEGER OPTIONAL,
+    numberOfTermsRequested         [6]   IMPLICIT INTEGER,
+    preferredPositionInResponse      [7]   IMPLICIT INTEGER OPTIONAL,
+    otherInfo            OtherInformation OPTIONAL}
+
+  ScanResponse ::= SEQUENCE{
+   referenceId              ReferenceId OPTIONAL,
+   stepSize           [3]  IMPLICIT INTEGER OPTIONAL,
+   scanStatus           [4]  IMPLICIT INTEGER {
+                                success   (0),
+                                partial-1   (1),
+                                partial-2   (2),
+                                partial-3   (3),
+                                partial-4   (4),
+                                partial-5   (5),
+                                failure  (6) },
+   numberOfEntriesReturned       [5]  IMPLICIT INTEGER,
+   positionOfTerm         [6]  IMPLICIT INTEGER OPTIONAL,
+   entries           [7]  IMPLICIT ListEntries  OPTIONAL,  
+   attributeSet          [8]  IMPLICIT AttributeSetId OPTIONAL,
+   otherInfo            OtherInformation OPTIONAL}
+
+-- begin auxiliary definitions for Scan
+  ListEntries ::= SEQUENCE{
+  entries        [1]   IMPLICIT SEQUENCE OF Entry OPTIONAL,
+    nonsurrogateDiagnostics    [2]  IMPLICIT SEQUENCE OF DiagRec OPTIONAL
+    -- At least one of entries and nonsurrogateDiagnostics must occur
+          }
+
+  Entry  ::= CHOICE {
+     termInfo               [1]   IMPLICIT TermInfo,
+     surrogateDiagnostic    [2]   DiagRec}
+--
+  TermInfo ::= SEQUENCE {
+   term                    Term,
+     displayTerm      [0]   IMPLICIT InternationalString OPTIONAL,
+                                     -- Presence of displayTerm means that term is not considered by
+              -- the target to be suitable for display, and displayTerm should
+              -- instead be displayed. 'term' is the actual term in the term list;
+               -- 'displayTerm' is for display purposes only, and is not an actual
+              -- term in the term list.
+  suggestedAttributes            AttributeList OPTIONAL,
+     alternativeTerm    [4]  IMPLICIT SEQUENCE OF AttributesPlusTerm OPTIONAL, 
+     globalOccurrences    [2]  IMPLICIT INTEGER OPTIONAL,
+     byAttributes      [3]  IMPLICIT OccurrenceByAttributes OPTIONAL,
+     otherTermInfo      OtherInformation OPTIONAL} 
+
+  OccurrenceByAttributes ::= SEQUENCE OF SEQUENCE{
+     attributes    [1]  AttributeList, 
+     occurrences       CHOICE{
+               global    [2] INTEGER,
+            byDatabase  [3] IMPLICIT SEQUENCE OF SEQUENCE{ 
+              db      DatabaseName,
+              num     [1]  IMPLICIT INTEGER OPTIONAL,
+              otherDbInfo    OtherInformation OPTIONAL}} OPTIONAL,
+     otherOccurInfo    OtherInformation OPTIONAL} 
+-- end auxiliary definitions for Scan
+
+-- Sort APDUs
+SortRequest  ::= SEQUENCE{
+  referenceId              ReferenceId OPTIONAL,
+  inputResultSetNames  [3]  IMPLICIT SEQUENCE OF InternationalString,
+  sortedResultSetName  [4]    IMPLICIT InternationalString,
+  sortSequence     [5]  IMPLICIT SEQUENCE OF SortKeySpec,
+              -- order of occurrence is from major to minor
+  otherInfo        OtherInformation OPTIONAL}
+
+SortResponse  ::= SEQUENCE{
+  referenceId          ReferenceId OPTIONAL,
+  sortStatus         [3]  IMPLICIT INTEGER{
+                            success  (0), 
+              partial-1  (1),
+              failure  (2)},
+  resultSetStatus    [4]  IMPLICIT INTEGER{
+              empty    (1), 
+                  interim  (2), 
+                  unchanged  (3),
+              none    (4)} OPTIONAL,
+  diagnostics        [5]             IMPLICIT SEQUENCE OF DiagRec OPTIONAL,
+  otherInfo        OtherInformation OPTIONAL}
+
+-- begin auxiliary definitions for Sort
+  SortKeySpec ::= SEQUENCE{
+    sortElement      SortElement, 
+       sortRelation    [1]  IMPLICIT INTEGER{
+                                ascending      (0),
+              descending      (1),
+              ascendingByFrequency    (3),
+              descendingByfrequency  (4)},
+      caseSensitivity    [2]   IMPLICIT INTEGER{
+                                 caseSensitive      (0), 
+              caseInsensitive    (1)},
+      missingValueAction    [3]   CHOICE{
+                                     abort    [1] IMPLICIT NULL,
+                                     null      [2] IMPLICIT NULL,
+                    --supply a null value for missing value
+          missingValueData  [3] IMPLICIT OCTET STRING} OPTIONAL}
+
+  SortElement ::=   CHOICE{
+    generic        [1] SortKey,
+       datbaseSpecific    [2] IMPLICIT SEQUENCE OF SEQUENCE{
+                       databaseName  DatabaseName,
+                       dbSort    SortKey}} 
+
+  SortKey ::= CHOICE{
+    sortfield       [0]  IMPLICIT InternationalString,
+                  -- An element, element-group-tag, or alias supported by the target
+               -- and denoting a set of elements associated with each record.
+     elementSpec    [1]  IMPLICIT Specification,
+        sortAttributes    [2]  IMPLICIT SEQUENCE{
+              id  AttributeSetId,
+              list  AttributeList}}
+-- end auxiliary definitions for sort
+
+
+
+-- Extended Service APDUs
+  ExtendedServicesRequest  ::= SEQUENCE{
+  referenceId              ReferenceId OPTIONAL,
+  function      [3]  IMPLICIT INTEGER {
+              create    (1),
+              delete    (2),
+              modify  (3)},
+  packageType      [4]  IMPLICIT OBJECT IDENTIFIER,
+  packageName    [5]  IMPLICIT InternationalString OPTIONAL,
+              -- PackageName mandatory for 'modify' or 'delete'; optional for
+              -- 'create'. Following four parameters mandatory for 'create'; should
+              -- be included on 'modify' if being modified; not needed on 'delete'.
+  userId        [6]   IMPLICIT InternationalString OPTIONAL,
+  retentionTime    [7]   IMPLICIT IntUnit OPTIONAL,
+  permissions      [8]   IMPLICIT Permissions OPTIONAL,
+  description      [9]   IMPLICIT InternationalString OPTIONAL,
+
+-- (ExtendedServiceRequest APDU continued)
+  taskSpecificParameters  [10]  IMPLICIT EXTERNAL OPTIONAL, 
+              -- Mandatory for 'create'; included on 'modify' if specific
+              -- parameters being modified; not necessary on 'delete'. For the
+              -- 'EXTERNAL,' use OID of specific ES definition and select
+              --  CHOICE [1]: 'esRequest'.
+  waitAction      [11]  IMPLICIT INTEGER{
+              wait      (1),
+              waitIfPossible  (2),
+              dontWait    (3),
+              dontReturnPackage  (4)},
+  elements          ElementSetName OPTIONAL,
+  otherInfo          OtherInformation OPTIONAL}
+--
+
+ExtendedServicesResponse ::= SEQUENCE{
+  referenceId                ReferenceId OPTIONAL,
+  operationStatus    [3]    IMPLICIT INTEGER{
+                done      (1),
+                accepted    (2),  
+                failure    (3)},
+  diagnostics      [4]    IMPLICIT SEQUENCE OF DiagRec OPTIONAL,
+  taskPackage      [5]    IMPLICIT EXTERNAL OPTIONAL,
+                -- Use OID: {Z39-50-recordSyntax (106)} and corresponding
+                -- syntax. For the EXTERNAL, 'taskSpecific,' within that
+                -- definition, use OID of the specific es, and choose [2],
+                -- 'taskPackage'.
+  otherInfo          OtherInformation OPTIONAL}
+
+ Permissions ::= SEQUENCE OF SEQUENCE{
+  userId      [1] IMPLICIT InternationalString,
+  allowableFunctions  [2] IMPLICIT SEQUENCE OF INTEGER{
+              delete      (1),
+              modifyContents  (2),
+              modifyPermissions  (3),
+              present    (4),
+                 invoke    (5)}} 
+
+Close ::= SEQUENCE{
+  referenceId          ReferenceId OPTIONAL,  -- See 3.2.11.1.5.
+  closeReason          CloseReason,
+  diagnosticInformation    [3]  IMPLICIT InternationalString OPTIONAL,
+  resourceReportFormat    [4]  IMPLICIT ResourceReportId OPTIONAL, 
+                -- For use by origin only, and only on Close request;
+                -- origin requests target to include report in response.
+   resourceReport      [5]  ResourceReport OPTIONAL,
+                -- For use by target only, unilaterally on Close request;
+                -- on Close response may be unilateral or in response
+                -- to origin request.
+  otherInfo          OtherInformation OPTIONAL}
+
+  CloseReason ::=  [211]  IMPLICIT INTEGER{
+            finished      (0),
+            shutdown      (1),
+            systemProblem    (2),
+            costLimit      (3),
+            resources      (4),
+            securityViolation    (5),
+            protocolError    (6),
+            lackOfActivity    (7),
+            peerAbort      (8),
+            unspecified      (9)}
+
+
+-- Global auxiliary definitions
+  ReferenceId       ::=      [2]  IMPLICIT OCTET STRING
+  ResultSetId        ::=      [31]    IMPLICIT InternationalString
+  ElementSetName     ::=     [103]   IMPLICIT InternationalString
+  DatabaseName     ::=    [105]   IMPLICIT InternationalString
+  AttributeSetId     ::=       OBJECT IDENTIFIER
+
+
+-- OtherInformation
+  OtherInformation   ::= [201] IMPLICIT SEQUENCE OF SEQUENCE{
+    category            [1]   IMPLICIT InfoCategory OPTIONAL, 
+    information        CHOICE{
+      characterInfo        [2]  IMPLICIT InternationalString,
+      binaryInfo        [3]  IMPLICIT OCTET STRING,
+      externallyDefinedInfo    [4]  IMPLICIT EXTERNAL,
+      oid          [5]  IMPLICIT OBJECT IDENTIFIER}}
+--
+  InfoCategory ::= SEQUENCE{
+      categoryTypeId  [1]   IMPLICIT OBJECT IDENTIFIER OPTIONAL,
+      categoryValue  [2]   IMPLICIT INTEGER}
+
+
+-- Units
+  -- IntUnit is used when value and unit are supplied together. Unit, alone, is used when just
+  -- specifying a unit (without a value).  For example, IntUnit is used in Term, in an RPNQuery, or
+  -- it can be the datatype of an element within a retrieval record. Unit (alone) would be used in an
+  -- element request, when requesting data be returned according to a particular unit.
+
+  IntUnit ::= SEQUENCE{
+    value    [1] IMPLICIT INTEGER,
+    unitUsed  [2] IMPLICIT Unit}
+--
+  Unit ::= SEQUENCE{
+    unitSystem    [1] InternationalString OPTIONAL,    -- e.g. 'SI'
+    unitType    [2] StringOrNumeric OPTIONAL,    -- e.g. 'mass'
+    unit      [3] StringOrNumeric OPTIONAL,    -- e.g. 'kilograms'
+    scaleFactor    [4] IMPLICIT INTEGER OPTIONAL    -- e.g. 9 means 10**9
+        }
+
+--CharacterString
+  InternationalString ::= GeneralString
+    -- When version 2 is in force, this collapses to VisibleString. That is, only characters in the
+    -- visibleString repertoire may be used. (Datatype compatibility with version 2 is not affected,
+     -- because references are IMPLICIT.)  When version 3 is in force, the semantics of the
+    -- GeneralString content may be altered by negotiation during initialization. If no such
+    -- negotiation is in effect, then GeneralString semantics are in force.
+
+StringOrNumeric ::= CHOICE{
+  string    [1] IMPLICIT InternationalString,
+  numeric  [2] IMPLICIT INTEGER}
+
+END -- IR DEFINITIONS
+
+
+
+DiagnosticFormatDiag1 
+{Z39-50-diagnosticFormat diag-1 (2)} DEFINITIONS ::=
+BEGIN
+IMPORTS Term, Specification, AttributeList, SortElement, DatabaseName, 
+DefaultDiagFormat, InternationalString FROM Z39-50-APDU-1995;
+
+
+DiagnosticFormat ::=  SEQUENCE OF SEQUENCE{ 
+  diagnostic  [1] CHOICE{
+              defaultDiagRec    [1]  IMPLICIT DefaultDiagFormat,
+              explicitDiagnostic    [2]  DiagFormat} OPTIONAL, 
+  message  [2] IMPLICIT InternationalString OPTIONAL} 
+
+
+DiagFormat ::= CHOICE{
+
+tooMany  [1000]   IMPLICIT SEQUENCE{
+                tooManyWhat   [1]  IMPLICIT INTEGER{
+                                  argumentWords        (1), 
+                                  truncatedWords        (2), 
+                                  booleanOperators      (3),
+                                  incompleteSubfields    (4), 
+                                  characters          (5),
+                                  recordsRetrieved      (6), 
+                                  dataBasesSpecified      (7),
+                                  resultSetsCreated      (8), 
+                                  indexTermsProcessed    (9)},
+                max        [2]  IMPLICIT INTEGER OPTIONAL},
+
+
+
+
+
+
+
+badSpec    [1001]  IMPLICIT SEQUENCE{  -- element set name or specification
+                spec        [1] IMPLICIT Specification, -- esn or element spec not supported
+                db        [2] IMPLICIT DatabaseName OPTIONAL,
+                            -- if db specified, above spec not supported for db; otherwise,
+                            -- spec not supported period.
+                goodOnes    [3] IMPLICIT SEQUENCE OF Specification OPTIONAL  
+                            -- target supplies ones that are supported
+                            },
+
+
+dbUnavail  [1002]  IMPLICIT SEQUENCE{ -- database unavailable
+                db  [1] IMPLICIT DatabaseName,
+                why  [2] IMPLICIT SEQUENCE{
+                        reasonCode  [1] IMPLICIT INTEGER{
+                                      doesNotExist    (0),
+                                      existsButUnavail  (1),
+                                      locked      (2),
+                                      accessDenied    (3)} OPTIONAL,
+                        message    [2] IMPLICIT InternationalString OPTIONAL}},
+
+
+unSupOp  [1003]  IMPLICIT INTEGER{  -- unsupported operator
+                and     (0),
+                or      (1),
+                and-not  (2),
+                prox    (3)},
+
+
+attribute    [1004]  IMPLICIT SEQUENCE{
+                    -- Applies for unsupported attribute set, attribute type, 
+                    -- attribute value, or term (for a given attribute type or value).
+
+                id      [1]  IMPLICIT OBJECT IDENTIFIER,
+                   -- if only "id" occurs, then attribute set is not supported
+                type    [2]  IMPLICIT INTEGER OPTIONAL,
+                   -- must occur if value occurs.
+                value    [3]   IMPLICIT INTEGER OPTIONAL,
+                    -- if omitted, and Type occurs, then Type is what is unsupported
+                term    [4]  Term OPTIONAL
+                    -- If occurs, term is illegal or not supported, for attribute value,
+                    -- if value occurs; otherwise, for type.
+                                },
+
+
+attCombo  [1005]  IMPLICIT SEQUENCE{ -- attribute combination not supported
+              unsupportedCombination  [1] IMPLICIT AttributeList, 
+              recommendedAlternatives  [2] IMPLICIT SEQUENCE OF AttributeList OPTIONAL}, 
+
+
+
+
+term      [1006]  IMPLICIT SEQUENCE{
+                problem    [1] IMPLICIT INTEGER{
+                            codedValue  (1),
+                            unparsable  (2),
+                            tooShort    (3),
+                            type      (4)} OPTIONAL,
+                term      [2] Term},
+
+
+proximity  [1007] CHOICE{        -- proximity diagnostics:
+               resultSets  [1]    IMPLICIT NULL,         -- proximity between sets not supported
+              badSet    [2]    IMPLICIT InternationalString,  -- bad result set specified
+                 relation    [3]   IMPLICIT INTEGER,      -- 1 to 6 ; relation not supported
+              unit      [4]  IMPLICIT INTEGER,      -- unsupported unit code
+              distance    [5]  IMPLICIT INTEGER,      -- unsupported distance
+              attributes  [6]  AttributeList,             --  proximity not supported with specified
+                                                   -- attribute combination
+              ordered    [7]  IMPLICIT NULL,        -- ordered flag not supported
+              exclusion  [8]  IMPLICIT NULL          -- exclusion flag not supported
+                    },
+
+
+
+
+
+scan     [1008] CHOICE{      -- scan diagnostics:
+              nonZeroStepSize  [0] IMPLICIT NULL,  -- only zero step size supported
+              specifiedStepSize  [1] IMPLICIT NULL,  -- specified step size not supported
+              termList1      [3] IMPLICIT NULL,  -- term list not supported (no alternative supplied)
+              termList2      [4] IMPLICIT SEQUENCE OF AttributeList,
+                                          -- term list not supported (alternatives supplied)
+              posInResponse    [5] IMPLICIT INTEGER{  --value of positionInResponse not supported
+                              mustBeOne        (1),
+                              mustBePositive    (2),
+                              mustBeNonNegative  (3),
+                              other            (4)},
+              resources      [6] IMPLICIT NULL,   -- resources exhausted looking for satisfying terms
+              endOfList      [7] IMPLICIT NULL  -- beginning or end of term list
+                },
+
+
+sort       [1009] CHOICE{
+              sequence    [0]  IMPLICIT NULL,        -- cannot sort according to sequence
+              noRsName    [1]  IMPLICIT NULL,        -- no result set name supplied
+              tooMany    [2]  IMPLICIT INTEGER,      --  Too many input result sets,
+                                                --  maximum supplied.
+              incompatible  [3]  IMPLICIT NULL,        -- records with different formats
+                                                 -- not compatible for sorting
+              generic      [4]  IMPLICIT NULL,        -- generic sort not supported 
+                                                -- (db specific only)
+              dbSpecific    [5]  IMPLICIT NULL,        -- db specific sort not supported
+              sortElement    [6]  SortElement,
+              key        [7]  IMPLICIT INTEGER{
+                              tooMany  (1),    -- too many sort keys
+                              duplicate  (2)},    -- duplicate sort keys
+              action      [8]  IMPLICIT NULL,  -- unsupported missing data action
+              illegal      [9]  IMPLICIT INTEGER{
+                              relation  (1),  -- illegal sort relation
+                              case    (2),  -- illegal case value
+                              action  (3),   -- illegal missing data action
+                              sort    (4)},  -- illegal sort
+            inputTooLarge    [10]  IMPLICIT SEQUENCE OF InternationalString,
+                                      --   one or more of the input result sets too large to sort
+          aggregateTooLarge  [11]  IMPLICIT NULL  --  aggregate result set too large
+                          },
+
+segmentation  [1010]  CHOICE{
+                segmentCount  [0]    IMPLICIT NULL,
+                                  -- Cannot guarantee record will fit within max segments. Target
+                                  -- suggests that origin try again to retrieve record, without
+                                  -- including max-segment-count.
+                segmentSize  [1]    IMPLICIT INTEGER
+                                -- record cannot be segmented into fragments such that the largest
+                                -- will fit within max segment size specified. Target supplies (in
+                                -- bytes) the smallest acceptable value of Max-segment-size to
+                                -- retrieve the record.
+                          },
+
+
+extServices  [1011] CHOICE{
+                req        [1] IMPLICIT INTEGER{   -- bad request
+                            nameInUse    (1),  -- package name already in use
+                            noSuchName  (2),  -- no such package, on modify/delete
+                            quota        (3),  -- quota exceeded
+                            type        (4)},  -- extended service type not supported
+                permission  [2] IMPLICIT INTEGER{ -- permission denied on ES, because: 
+                            id         (1),    --   id not authorized, or
+                            modifyDelete  (2)},    -- cannot modify or delete
+                immediate  [3] IMPLICIT INTEGER{ -- immediate execution:
+                            failed      (1),    -- failed, 
+                            service      (2),    -- not supported for this service, or
+                            parameters    (3)    -- for these parameters.
+                                }},
+
+
+accessCtrl    [1012] CHOICE{
+                noUser    [1] IMPLICIT NULL,    -- no user to display challenge to
+                refused    [2] IMPLICIT NULL,    -- access control information refused by user
+                simple    [3] IMPLICIT NULL,    -- only simple form supported (target used
+                                          -- externally defined)
+                oid      [4] IMPLICIT SEQUENCE OF OBJECT IDENTIFIER,
+                                          -- oid not supported (origin supplies alternative
+                                          -- suggested oids)
+                alternative  [5] IMPLICIT SEQUENCE OF OBJECT IDENTIFIER,
+                                          -- origin insists that target use an alternative
+                                          -- challenge for this data (e.g. stronger                                     
+   
+                                          -- authentication or stronger Access control). The                            
+              -- origin supplies suggested alternative oids.
+                pwdInv    [6] IMPLICIT NULL,    -- password invalid
+                pwdExp    [7] IMPLICIT NULL      -- password expired
+                    },
+
+
+recordSyntax  [1013] IMPLICIT SEQUENCE{ -- record cannot be transferred in requested syntax
+              unsupportedSyntax    [1] IMPLICIT OBJECT IDENTIFIER, 
+              suggestedAlternatives  [2] IMPLICIT SEQUENCE OF OBJECT IDENTIFIER OPTIONAL}
+}
+
+END
+
+
+
+
+
+RecordSyntax-explain 
+{Z39-50-recordSyntax explain (100)} DEFINITIONS ::=
+
+BEGIN 
+IMPORTS AttributeSetId, Term, OtherInformation, DatabaseName, ElementSetName, IntUnit, Unit,
+ StringOrNumeric, Specification, InternationalString, AttributeList, AttributeElement FROM Z39-50-APDU-1995;
+
+Explain-Record ::= CHOICE{
+  -- Each of these may be used as search term  when Use attribute is 'explain-category'.
+  targetInfo         [0]    IMPLICIT TargetInfo,
+  databaseInfo      [1]    IMPLICIT DatabaseInfo,
+  schemaInfo        [2]    IMPLICIT SchemaInfo,
+  tagSetInfo         [3]    IMPLICIT TagSetInfo,
+  recordSyntaxInfo    [4]    IMPLICIT RecordSyntaxInfo,
+  attributeSetInfo    [5]    IMPLICIT AttributeSetInfo,
+  termListInfo      [6]    IMPLICIT TermListInfo,
+  extendedServicesInfo  [7]    IMPLICIT ExtendedServicesInfo,
+  attributeDetails      [8]    IMPLICIT AttributeDetails,
+  termListDetails    [9]    IMPLICIT TermListDetails,
+  elementSetDetails    [10]  IMPLICIT ElementSetDetails,
+  retrievalRecordDetails  [11]   IMPLICIT RetrievalRecordDetails,
+  sortDetails             [12]   IMPLICIT SortDetails,
+  processing           [13]  IMPLICIT ProcessingInformation,
+  variants          [14]  IMPLICIT VariantSetInfo,
+  units          [15]    IMPLICIT UnitInfo,
+  categoryList            [100]  IMPLICIT CategoryList}
+
+-- Element set name 'B' (brief)  retrieves:
+--  -  'commonInfo' (except for otherInfo within commonInfo)
+--  -  key elements
+--  -  other elements designated as 'non-key brief elements'
+-- Esn 'description' retrieves brief elements as well as 'description', and specific additional descriptive
+-- elements if designated.  
+-- Element set name 'F' (full) retrieves all of the above, as well as those designated as "non-brief elements". Some
+-- elements designated as OPTIONAL may be mandatory in full records, and are so identified. (Note that all elements
+-- that are not part of the brief element set must be designated as OPTIONAL in the ASN.1, otherwise it would be
+-- illegal to omit them.)
+-- Other esns are defined (below) as needed.
+
+-- - - - - - - - - - - - -   Info Records
+  -- Info records are mainly for software consumption
+  -- They describe individual entities within the target system:
+  --   The target itself
+  --   Individual databases
+  --   Schemas
+  --   Tag sets
+  --   Record syntaxes
+  --   Attribute sets
+  --   Term lists
+  --   Extended services
+ --     The information about each Schema, Tag Set, Record Syntax and Attribute Set should
+  -- match the universal definitions of these items. The only exception is that a target may omit any
+  -- items it doesn't support, for example the description of the bib-1 attribute set may omit attributes
+  -- that the target does not support under any circumstances.
+  --      Databases that may be searched together can be listed in the dbCominations element of the TargetInfo record.  
+TargetInfo ::= SEQUENCE {
+  commonInfo      [0]    IMPLICIT CommonInfo OPTIONAL,
+    -- Key elements follow:
+  name          [1]    IMPLICIT InternationalString,
+    -- Non-key brief elements follow:
+  recent-news      [2]    IMPLICIT HumanString OPTIONAL,
+  icon          [3]    IMPLICIT IconObject OPTIONAL,
+  namedResultSets    [4]    IMPLICIT BOOLEAN,
+  multipleDBsearch    [5]    IMPLICIT BOOLEAN,
+  maxResultSets      [6]    IMPLICIT INTEGER OPTIONAL,
+  maxResultSize      [7]    IMPLICIT INTEGER OPTIONAL,
+  maxTerms        [8]    IMPLICIT INTEGER OPTIONAL,
+  timeoutInterval      [9]    IMPLICIT IntUnit OPTIONAL,
+  welcomeMessage    [10]  IMPLICIT HumanString OPTIONAL,
+    -- non-brief elements follow:
+  -- 'description' esn retrieves the following two (as well as brief):
+  contactInfo      [11]  IMPLICIT ContactInfo OPTIONAL,
+  description      [12]  IMPLICIT HumanString OPTIONAL,
+  nicknames        [13]  IMPLICIT SEQUENCE OF InternationalString OPTIONAL,
+  usage-restrictions    [14]  IMPLICIT HumanString OPTIONAL,
+  paymentAddr      [15]  IMPLICIT HumanString OPTIONAL,
+  hours          [16]  IMPLICIT HumanString OPTIONAL,
+  dbCombinations    [17]  IMPLICIT SEQUENCE OF DatabaseList OPTIONAL,
+  addresses        [18]  IMPLICIT SEQUENCE OF NetworkAddress OPTIONAL,
+  languages        [101]  IMPLICIT SEQUENCE OF InternationalString OPTIONAL,
+                  -- Languages supported for message strings.  Each is a three-character
+                  -- language code from Z39.53-1994.
+-- characterSets      [102]  this tag reserved for "character sets supported for name and message strings".
+  -- commonAccessInfo elements list objects the target supports. All objects listed in
+  -- AccessInfo for any individual database should also be listed here.
+  commonAccessInfo  [19]  IMPLICIT AccessInfo OPTIONAL}
+
+
+DatabaseInfo ::= SEQUENCE {
+      -- A target may provide "virtual databases" that are combinations of individual database. These
+      -- databases are indicated by the presence of subDbs in the combination database's DatabaseDescription.
+  commonInfo        [0]    IMPLICIT CommonInfo OPTIONAL,
+    -- Key elements follow:
+  name            [1]    IMPLICIT DatabaseName,
+    -- Non-key brief elements follow:
+  explainDatabase      [2]             IMPLICIT NULL OPTIONAL,
+                       -- If present, this database is the Explain database, or an Explain database
+                    -- for a different server, possibly on a different host. The means by which
+                    -- that server may be accessed is not addressed by this standard. One
+                    -- suggested possibility is an implementor agreement whereby the
+                    -- database name is a url which may be used to connect to the server.
+  nicknames          [3]    IMPLICIT SEQUENCE OF DatabaseName OPTIONAL,
+  icon            [4]    IMPLICIT IconObject OPTIONAL,
+  user-fee          [5]    IMPLICIT BOOLEAN,
+  available          [6]    IMPLICIT BOOLEAN,
+  titleString          [7]    IMPLICIT HumanString OPTIONAL,
+    -- Non-brief elements follow:
+  keywords          [8]    IMPLICIT SEQUENCE OF HumanString OPTIONAL,
+  description        [9]    IMPLICIT HumanString OPTIONAL,
+  associatedDbs        [10]  IMPLICIT DatabaseList OPTIONAL,
+                    -- databases that may be searched in combination with this one 
+
+  subDbs          [11]  IMPLICIT DatabaseList OPTIONAL,
+                        -- When present, this database is a composite representing the combined
+                     -- databases 'subDbs'. The individual subDbs are also available.
+  disclaimers        [12]  IMPLICIT HumanString OPTIONAL,
+  news            [13]  IMPLICIT HumanString OPTIONAL,
+  recordCount           [14]    CHOICE {
+                                   actualNumber  [0] IMPLICIT INTEGER,
+                                    approxNumber  [1] IMPLICIT INTEGER} OPTIONAL,
+  defaultOrder        [15]  IMPLICIT HumanString OPTIONAL,
+  avRecordSize        [16]  IMPLICIT INTEGER OPTIONAL,
+  maxRecordSize      [17]  IMPLICIT INTEGER OPTIONAL,
+  hours            [18]  IMPLICIT HumanString OPTIONAL,
+  bestTime          [19]  IMPLICIT HumanString OPTIONAL,
+  lastUpdate          [20]  IMPLICIT GeneralizedTime OPTIONAL,
+  updateInterval        [21]  IMPLICIT IntUnit OPTIONAL,
+  coverage          [22]  IMPLICIT HumanString OPTIONAL,
+  proprietary        [23]  IMPLICIT BOOLEAN OPTIONAL, -- mandatory in full record
+  copyrightText        [24]  IMPLICIT HumanString OPTIONAL,
+  copyrightNotice      [25]  IMPLICIT HumanString OPTIONAL,
+  producerContactInfo    [26]  IMPLICIT ContactInfo OPTIONAL,
+  supplierContactInfo      [27]  IMPLICIT ContactInfo OPTIONAL,
+  submissionContactInfo    [28]  IMPLICIT ContactInfo OPTIONAL,
+    -- accessInfo lists items connected with the database. All listed items should be in the target's AccessInfo.
+  accessInfo                [29]  IMPLICIT AccessInfo OPTIONAL}
+
+
+SchemaInfo ::= SEQUENCE {
+  commonInfo    [0]  IMPLICIT CommonInfo OPTIONAL,
+    -- Key elements follow:
+  schema      [1]  IMPLICIT OBJECT IDENTIFIER,
+    -- Non-key brief elements follow:
+  name        [2]  IMPLICIT InternationalString,
+    -- Non-brief elements follow:
+  description    [3]  IMPLICIT HumanString OPTIONAL,
+  tagTypeMapping  [4]  IMPLICIT SEQUENCE OF SEQUENCE {
+              tagType    [0] IMPLICIT INTEGER,
+              tagSet       [1] IMPLICIT OBJECT IDENTIFIER OPTIONAL,
+                -- If tagSet is omitted, then this tagType is for a tagSet locally defined
+                -- within the schema that cannot be referenced by another schema.
+              defaultTagType  [2] IMPLICIT NULL OPTIONAL
+                        } OPTIONAL,
+  recordStructure  [5]  IMPLICIT SEQUENCE OF ElementInfo OPTIONAL}
+
+
+  --  ElementInfo referenced in SchemaInfo and RecordSyntaxInfo
+    ElementInfo ::= SEQUENCE {
+      elementName  [1] IMPLICIT InternationalString,
+      elementTagPath  [2] IMPLICIT Path,
+      dataType      [3] ElementDataType OPTIONAL, -- If omitted, not specified. 
+       required         [4] IMPLICIT BOOLEAN,
+      repeatable     [5] IMPLICIT BOOLEAN,
+       description    [6] IMPLICIT HumanString OPTIONAL}
+
+
+  -- Path is referenced by ElementInfo as well as PerElementDetails
+             Path ::= SEQUENCE OF SEQUENCE{
+              tagType  [1] IMPLICIT INTEGER,
+              tagValue     [2] StringOrNumeric}
+      ElementDataType ::= CHOICE{
+            primitive  [0] IMPLICIT PrimitiveDataType,
+           structured  [1] IMPLICIT SEQUENCE OF ElementInfo}
+      PrimitiveDataType ::= INTEGER{
+            octetString        (0),
+            numeric           (1),
+            date            (2),
+            external        (3),
+            string          (4),
+            trueOrFalse       (5),
+            oid         (6),
+            intUnit        (7),
+        empty        (8),
+            noneOfTheAbove  (100) -- see 'description'
+            }
+
+
+TagSetInfo ::= SEQUENCE {
+  commonInfo  [0]  IMPLICIT CommonInfo OPTIONAL,
+    -- Key elements follow:
+  tagSet      [1]  IMPLICIT OBJECT IDENTIFIER,
+    -- non-key brief elements follow:
+  name      [2]  IMPLICIT InternationalString,
+    -- non-brief elements follow:
+  description  [3]  IMPLICIT HumanString OPTIONAL,
+  elements    [4]  IMPLICIT SEQUENCE OF SEQUENCE {
+              elementname  [1]  IMPLICIT InternationalString,
+               nicknames    [2]  IMPLICIT SEQUENCE OF InternationalString OPTIONAL,
+              elementTag     [3]  StringOrNumeric, 
+              description    [4]  IMPLICIT HumanString OPTIONAL, 
+            dataType       [5]  PrimitiveDataType OPTIONAL,
+              -- If the data type is expected to be structured, that is described in the schema info,
+              -- and datatype is omitted here.
+             otherTagInfo       OtherInformation OPTIONAL} OPTIONAL}
+
+RecordSyntaxInfo ::= SEQUENCE {
+  commonInfo    [0]  IMPLICIT CommonInfo OPTIONAL,
+    -- Key elements follow:
+  recordSyntax    [1]  IMPLICIT OBJECT IDENTIFIER,
+    -- Non-key brief elements follow:
+  name        [2]  IMPLICIT InternationalString,
+    -- non-brief elements follow:
+  transferSyntaxes  [3]  IMPLICIT SEQUENCE OF OBJECT IDENTIFIER OPTIONAL,
+  description    [4]  IMPLICIT HumanString OPTIONAL,
+  asn1Module    [5]  IMPLICIT InternationalString OPTIONAL,
+  abstractStructure  [6]  IMPLICIT SEQUENCE OF ElementInfo OPTIONAL
+               -- Omitting abstractStructure only means target isn't using
+                 -- Explain to describe the structure, not that there is no structure.
+              }
+
+AttributeSetInfo ::= SEQUENCE {
+  commonInfo  [0]  IMPLICIT CommonInfo OPTIONAL,
+    -- Key elements follow:
+  attributeSet  [1]  IMPLICIT AttributeSetId,
+    -- non-key brief elements follow:
+  name      [2]  IMPLICIT InternationalString,
+    -- non-brief elements follow:
+  attributes    [3]  IMPLICIT SEQUENCE OF AttributeType OPTIONAL,
+            -- mandatory in full record
+  description   [4] IMPLICIT HumanString OPTIONAL}
+-- AttributeType referenced in AttributeSetInfo
+  AttributeType ::= SEQUENCE {
+      name             [0] IMPLICIT InternationalString OPTIONAL,
+      description      [1] IMPLICIT HumanString OPTIONAL,
+       attributeType    [2] IMPLICIT INTEGER,
+      attributeValues  [3] IMPLICIT SEQUENCE OF AttributeDescription}
+    AttributeDescription ::= SEQUENCE {
+        name                 [0] IMPLICIT InternationalString OPTIONAL,
+        description          [1] IMPLICIT HumanString OPTIONAL,
+        attributeValue       [2] StringOrNumeric,
+        equivalentAttributes  [3]  IMPLICIT SEQUENCE OF StringOrNumeric OPTIONAL
+                  -- each is an occurrence of 'attributeValue' from AttributeDescription for a
+                  -- different attribute. Equivalences listed here should be derived from the 
+                  -- attribute set definition, not from a particular server's behavior.  
+                    }
+
+
+TermListInfo ::= SEQUENCE{
+  commonInfo    [0]  IMPLICIT CommonInfo OPTIONAL,
+    -- Key elements follow:
+  databaseName  [1]  IMPLICIT DatabaseName,
+    -- Non-key brief elements follow:
+  termLists      [2] IMPLICIT SEQUENCE OF SEQUENCE{
+            name    [1] IMPLICIT InternationalString,
+            title    [2] IMPLICIT HumanString OPTIONAL,
+                                            -- Title is for users to see and can differ by language. Name, on the
+                      -- other hand is typically a short string not necessarily meant to be
+                       -- human-readable, and not variable by language.
+            searchCost   [3]   IMPLICIT INTEGER {
+                  optimized  (0),    -- The attribute (or combination) associated
+                            -- with this   list will do fast searches. 
+                      normal      (1),    -- The attribute (combination) will work as
+                            -- expected. So there's probably an index for the
+                            -- attribute (combination) or some similar
+                             -- mechanism.
+                      expensive   (2),    -- Can use the attribute (combination), but it
+                            -- might not provide satisfactory results.
+                            -- Probably there is no index, or post-
+                            -- processing of records is required.
+                      filter      (3)    -- can't search with this attribute (combination) alone.
+                         } OPTIONAL,
+              scanable  [4]  IMPLICIT BOOLEAN, -- 'true' means this list can be scanned.
+               broader    [5] IMPLICIT SEQUENCE OF InternationalString OPTIONAL,
+               narrower  [6] IMPLICIT SEQUENCE OF InternationalString OPTIONAL
+                       -- broader and narrower list alternative term lists related to this one.
+                       -- The term lists so listed should also be in this termLists structure.
+                          }
+  -- no non-brief elements
+            }
+
+
+ExtendedServicesInfo ::= SEQUENCE {
+  commonInfo          [0]  IMPLICIT CommonInfo OPTIONAL,
+    -- Key elements follow:
+  type          [1]  IMPLICIT OBJECT IDENTIFIER,
+    -- Non-key brief elements follow:
+  name                [2]  IMPLICIT InternationalString OPTIONAL,
+                -- should be supplied if privateType is 'true'
+  privateType      [3]  IMPLICIT BOOLEAN,
+  restrictionsApply    [5]  IMPLICIT BOOLEAN,  -- if 'true' see 'description'
+  feeApply              [6]  IMPLICIT BOOLEAN,  -- if 'true' see 'description'
+  available             [7]  IMPLICIT BOOLEAN,
+  retentionSupported    [8]  IMPLICIT BOOLEAN,
+  waitAction      [9]  IMPLICIT INTEGER{
+                waitSupported    (1),
+                waitAlways      (2),
+                waitNotSupported  (3),
+                depends      (4),
+                notSaying      (5)},
+  -- non-brief elements follow:
+    -- To get brief plus 'description' use esn 'description'
+  description           [10]  IMPLICIT HumanString OPTIONAL,
+      -- to get above elements and 'specificExplain' use esn 'specificExplain'
+  specificExplain    [11]  IMPLICIT EXTERNAL OPTIONAL,
+                  -- Use oid of specific ES, and select choice [3] 'explain'. Format
+                  -- to be developed in conjunction with the specific ES definition.
+    -- to get all elements except 'specificExplain', use esn 'asn'
+  esASN          [12]  IMPLICIT InternationalString OPTIONAL -- the ASN.1 for this ES
+                }
+
+-- - - - - - - - - - - - - Detail records
+ -- The detail records describe relationships among entities supported by the target. RetrievalRecordDetails describes
+ -- the way that schema elements are mapped into record elements. This mapping may be different for each
+ -- combination of database, schema, record syntax. The per-element details describe the default mapping.
+ -- Origin-request re-tagging can change that mapping. When multiple databases are listed in a databaseNames
+ -- element, the record applies equally to all of the listed databases.  This is unrelated to searching the databases
+ -- together. AttributeDetails describes how databases can be searched. Each supported attribute is listed, and the
+ -- allowable combinations can be described.
+
+
+AttributeDetails ::= SEQUENCE {
+  commonInfo        [0]  IMPLICIT CommonInfo OPTIONAL,
+    -- Key elements follow:
+  databaseName        [1]  IMPLICIT DatabaseName,
+    -- Non-brief elements follow:
+  attributesBySet        [2]  IMPLICIT SEQUENCE OF AttributeSetDetails OPTIONAL, 
+                  -- mandatory in full record
+  attributeCombinations    [3]  IMPLICIT AttributeCombinations OPTIONAL}
+
+
+
+
+-- AttributeSetDetails referenced by AttributeDetails
+  AttributeSetDetails ::= SEQUENCE {
+        attributeSet      [0] IMPLICIT AttributeSetId,
+          attributesByType  [1] IMPLICIT SEQUENCE OF AttributeTypeDetails }
+    AttributeTypeDetails ::= SEQUENCE {
+         attributeType     [0] IMPLICIT INTEGER,
+          defaultIfOmitted    [1] IMPLICIT OmittedAttributeInterpretation OPTIONAL,
+          attributeValues    [2] IMPLICIT SEQUENCE OF AttributeValue OPTIONAL }
+                          -- If no attributeValues are supplied, all values of this type are fully
+                    -- supported, and the descriptions in AttributeSetInfo are adequate.
+
+    OmittedAttributeInterpretation ::= SEQUENCE {
+        defaultValue           [0] StringOrNumeric OPTIONAL,
+                                -- A default value is listed if that's how the server works
+        defaultDescription  [1] IMPLICIT HumanString OPTIONAL }
+                          -- The human-readable description should generally be provided.
+                    -- It is legal for both default elements to be missing, which
+                    -- means that the target will allow the attribute type to be
+                    -- omitted, but isn't saying what it will do.
+
+    AttributeValue ::= SEQUENCE {
+        value              [0]  StringOrNumeric,
+        description        [1]  IMPLICIT HumanString OPTIONAL,
+        subAttributes     [2]  IMPLICIT SEQUENCE OF StringOrNumeric OPTIONAL,
+        superAttributes    [3]  IMPLICIT SEQUENCE OF StringOrNumeric OPTIONAL,
+        partialSupport    [4]  IMPLICIT NULL OPTIONAL }
+        -- partialSupport indicates that an attributeValue is accepted, but may not be processed in the
+        -- "expected" way. One important reason for this is composite databases: in this case partialSupport
+        -- may indicate that only some of the subDbs support the attribute, and others ignore it.
+
+
+
+TermListDetails ::= SEQUENCE{  -- one for each termList in TermListInfo
+  commonInfo    [0]  IMPLICIT CommonInfo OPTIONAL,
+    -- Key elements follow:
+  termListName    [1]  IMPLICIT InternationalString,
+    -- Non-key elements (all non-brief) follow:
+  description    [2]  IMPLICIT HumanString OPTIONAL,
+  attributes      [3]  IMPLICIT AttributeCombinations OPTIONAL,
+                          -- Pattern for attributes that hit this list. Mandatory in full record
+  scanInfo      [4]  IMPLICIT SEQUENCE {
+                maxStepSize         [0] IMPLICIT INTEGER OPTIONAL,
+                collatingSequence  [1] IMPLICIT HumanString OPTIONAL,
+                increasing            [2] IMPLICIT BOOLEAN OPTIONAL} OPTIONAL,
+            -- Occurs only if list is scanable. If list is scanable and if scanInfo is omitted, 
+            -- target doesn't consider these important.
+  estNumberTerms  [5]  IMPLICIT INTEGER OPTIONAL,
+  sampleTerms    [6]  IMPLICIT SEQUENCE OF Term OPTIONAL}
+
+
+
+ElementSetDetails ::= SEQUENCE {
+  -- ElementSetDetails describes the way that database records are mapped to record elements. This
+  -- mapping may be different for each combination of database name and element set. The database record
+   -- description is a schema, which may be private to the target. The schema's abstract record structure
+  -- and tag sets provide the vocabulary for discussing record content; their presence in the Explain
+  -- database does not imply support for complex retrieval specification.
+  commonInfo      [0]  IMPLICIT CommonInfo OPTIONAL,
+    -- Key elements follow:
+  databaseName      [1]  IMPLICIT DatabaseName,
+  elementSetName    [2]  IMPLICIT ElementSetName,
+  recordSyntax      [3]  IMPLICIT OBJECT IDENTIFIER,
+    -- Non-key Brief elements follow:
+  schema        [4]  IMPLICIT OBJECT IDENTIFIER,
+    -- Non-brief elements follow:
+  description      [5]  IMPLICIT HumanString OPTIONAL,
+  detailsPerElement    [6]  IMPLICIT SEQUENCE OF PerElementDetails OPTIONAL -- mandatory in full record
+              }
+
+
+RetrievalRecordDetails ::= SEQUENCE {
+  commonInfo      [0]  IMPLICIT CommonInfo OPTIONAL,
+    -- Key elements follow:
+  databaseName      [1]  IMPLICIT DatabaseName,
+  schema        [2]  IMPLICIT OBJECT IDENTIFIER,
+  recordSyntax      [3]  IMPLICIT OBJECT IDENTIFIER,
+    -- Non-brief elements follow:
+  description      [4]  IMPLICIT HumanString OPTIONAL,
+  detailsPerElement    [5]  IMPLICIT SEQUENCE OF PerElementDetails OPTIONAL
+                -- mandatory in full record
+            }
+
+-- PerElementDetails is referenced in RetrievalRecordDetails and ElementSetDetails.
+  PerElementDetails ::= SEQUENCE {
+      name      [0]    IMPLICIT InternationalString OPTIONAL,
+                   -- If the name is omitted, the record syntax's name for this element
+                  -- is appropriate.
+      recordTag    [1]    IMPLICIT RecordTag OPTIONAL,
+                   -- The record tag may be omitted if tags are inappropriate for the record
+                  -- syntax, or if the origin can be expected to know it for some other reason.
+      schemaTags    [2]    IMPLICIT SEQUENCE OF Path OPTIONAL,
+                      -- The information from the listed schema elements is combined
+                  -- in some way to produce the data sent in the listed record tag. The
+                  -- 'contents' element below may describe the logic used.
+      maxSize    [3]    IMPLICIT INTEGER OPTIONAL,
+      minSize    [4]    IMPLICIT INTEGER OPTIONAL,
+      avgSize      [5]    IMPLICIT INTEGER OPTIONAL,
+      fixedSize    [6]    IMPLICIT INTEGER OPTIONAL,
+      repeatable    [8]    IMPLICIT BOOLEAN,
+      required    [9]    IMPLICIT BOOLEAN, 
+                  -- 'required' really means that target will always supply the element.
+      description    [12]  IMPLICIT HumanString OPTIONAL,
+      contents    [13]  IMPLICIT HumanString OPTIONAL,
+      billingInfo    [14]  IMPLICIT HumanString OPTIONAL,
+      restrictions    [15]  IMPLICIT HumanString OPTIONAL,
+      alternateNames  [16]  IMPLICIT SEQUENCE OF InternationalString OPTIONAL,
+      genericNames  [17]  IMPLICIT SEQUENCE OF InternationalString OPTIONAL,
+      searchAccess  [18]  IMPLICIT AttributeCombinations OPTIONAL }
+      -- RecordTag referenced in PerElementDetails above
+        RecordTag ::= SEQUENCE {
+              qualifier  [0] StringOrNumeric OPTIONAL,
+                    -- E.g. tag set for GRS-1
+              tagValue  [1] StringOrNumeric}
+
+SortDetails ::= SEQUENCE {
+  commonInfo    [0]  IMPLICIT CommonInfo OPTIONAL,
+  -- Key elements follow:
+  databaseName    [1]  IMPLICIT DatabaseName,
+    -- No non-key brief elements
+    -- Non-brief elements follow:
+  sortKeys      [2]  IMPLICIT SEQUENCE OF SortKeyDetails OPTIONAL
+              -- mandatory in full record
+          }
+  SortKeyDetails ::= SEQUENCE {
+      description        [0]  IMPLICIT HumanString OPTIONAL,
+      elementSpecifications  [1]  IMPLICIT SEQUENCE OF Specification OPTIONAL,
+                      -- each specification is a way of specifying this same sort key
+      attributeSpecifications  [2]  IMPLICIT AttributeCombinations OPTIONAL,
+                      -- each combination is a way of specifying this same sort key
+      sortType                   [3]  CHOICE {
+                    character    [0]  IMPLICIT NULL,
+                    numeric    [1]  IMPLICIT NULL,
+                    structured    [2]  IMPLICIT HumanString} OPTIONAL,
+      caseSensitivity      [4]  IMPLICIT INTEGER {
+                      always    (0),  -- always case-sensitive
+                    never    (1),            -- never case-sensitive
+                    default-yes  (2),               -- case-sensitivity is as specified on request, and if not
+                            -- specified, case-sensitive.
+                    default-no  (3)} -- case-sensitivity is as specified on request, and if not
+                            -- specified, not case-sensitive.
+                          OPTIONAL}
+
+ProcessingInformation ::= SEQUENCE{
+  commonInfo      [0]  IMPLICIT CommonInfo OPTIONAL,
+    -- Key elements follow:
+  databaseName      [1]  IMPLICIT DatabaseName,
+  processingContext    [2]  IMPLICIT INTEGER {
+                  access        (0),   -- e.g. choosing databases
+                  search        (1),   -- e.g. "search strategies" or search forms 
+                  retrieval      (2),   -- e.g. recommended element combinations 
+                  record-presentation  (3),    -- display of retrieved records
+                  record-handling    (4)    -- handling (e.g. saving) of retrieved records
+        },
+  name          [3]  IMPLICIT InternationalString,
+  oid          [4]  IMPLICIT OBJECT IDENTIFIER,
+    -- No non-key brief elements
+    -- Non-brief elements follow:
+  description      [5]  IMPLICIT HumanString OPTIONAL,
+                -- use element set name 'description' to retrieve all except instructions.
+  instructions      [6]  IMPLICIT EXTERNAL OPTIONAL -- mandatory in full record
+              }
+
+
+VariantSetInfo ::= SEQUENCE {
+    -- A record in this category describes a variant set definition, i.e., classes, types, and values, for a specific
+    -- variant set definition supported by the target. Support by the target of a particular variant set definition
+    -- does not imply that the definition is supported for any specific database or element. 
+  commonInfo    [0] IMPLICIT CommonInfo OPTIONAL,
+  -- Key elements follow:
+  variantSet    [1] IMPLICIT OBJECT IDENTIFIER,
+  -- Non-key brief elements follow:
+  name      [2] IMPLICIT InternationalString,
+  -- Non-brief elements follow:
+  variants    [3] IMPLICIT SEQUENCE OF VariantClass OPTIONAL
+                   -- mandatory in full record
+           }
+
+  -- Subsidiary structures for VariantSetInfo
+    VariantClass ::= SEQUENCE {
+          name        [0] IMPLICIT InternationalString OPTIONAL,
+          description    [1] IMPLICIT HumanString OPTIONAL,
+          variantClass    [2] IMPLICIT INTEGER,
+          variantTypes  [3] IMPLICIT SEQUENCE OF VariantType}
+    VariantType ::= SEQUENCE {
+          name            [0] IMPLICIT InternationalString OPTIONAL,
+          description     [1] IMPLICIT HumanString OPTIONAL,
+          variantType    [2] IMPLICIT INTEGER,
+          variantValue  [3] IMPLICIT VariantValue OPTIONAL}
+    VariantValue ::= SEQUENCE {
+          dataType     [0] PrimitiveDataType,
+          values        [1] ValueSet OPTIONAL }
+    ValueSet ::= CHOICE {
+          range       [0] IMPLICIT ValueRange,
+          enumerated  [1] IMPLICIT SEQUENCE OF ValueDescription }
+    ValueRange ::= SEQUENCE {
+            -- At last one the following must be supplied, both may be supplied.
+          lower      [0] ValueDescription OPTIONAL,
+          upper     [1] ValueDescription OPTIONAL }
+    ValueDescription ::= CHOICE{
+      integer             INTEGER,
+          string              InternationalString,
+          octets              OCTET STRING,
+          oid                 OBJECT IDENTIFIER,
+          unit               [1]  IMPLICIT Unit,
+          valueAndUnit   [2]  IMPLICIT IntUnit 
+            -- oid and unit can't be used in a ValueRange
+            }
+
+
+
+UnitInfo ::= SEQUENCE {
+  commonInfo  [0] IMPLICIT CommonInfo OPTIONAL,
+  -- Key elements follow:
+  unitSystem   [1] IMPLICIT InternationalString,
+   -- No non-key brief elements
+   -- Non-brief elements follow:
+  description   [2] IMPLICIT HumanString OPTIONAL,
+  units      [3] IMPLICIT SEQUENCE OF UnitType OPTIONAL
+                         -- mandatory in full record
+           }
+
+  -- Subsidiary structures for UnitInfo
+    UnitType ::= SEQUENCE {
+      name    [0] IMPLICIT InternationalString OPTIONAL,
+      description  [1] IMPLICIT HumanString OPTIONAL,
+      unitType  [2] StringOrNumeric,
+      units     [3] IMPLICIT SEQUENCE OF Units}
+
+    Units ::= SEQUENCE {
+      name     [0] IMPLICIT InternationalString OPTIONAL,
+      description  [1] IMPLICIT HumanString OPTIONAL,
+      unit      [2] StringOrNumeric}
+
+CategoryList ::= SEQUENCE {
+  commonInfo      [0] IMPLICIT CommonInfo OPTIONAL,
+    -- Only one record expected per Explain database. All elements appear in brief presentation.
+  categories      [1] IMPLICIT SEQUENCE OF CategoryInfo }
+    CategoryInfo ::= SEQUENCE {
+           category          [1] IMPLICIT InternationalString,
+            originalCategory    [2] IMPLICIT InternationalString OPTIONAL,
+          description         [3] IMPLICIT HumanString OPTIONAL,
+         asn1Module      [4] IMPLICIT InternationalString OPTIONAL}
+
+
+-- - - - - - - - - - - - - - Subsidiary definitions
+
+CommonInfo ::= SEQUENCE {
+  dateAdded         [0] IMPLICIT GeneralizedTime OPTIONAL,
+  dateChanged       [1] IMPLICIT GeneralizedTime OPTIONAL,
+  expiry                [2] IMPLICIT GeneralizedTime OPTIONAL,
+  humanString-Language  [3] IMPLICIT LanguageCode OPTIONAL,
+  -- following not to occur for brief:
+  otherInfo          OtherInformation OPTIONAL}
+
+
+HumanString ::= SEQUENCE OF SEQUENCE {
+          language  [0] IMPLICIT LanguageCode OPTIONAL,
+        text        [1] IMPLICIT InternationalString}
+
+IconObject ::= SEQUENCE OF SEQUENCE{
+      -- Note that the "SEQUENCE OF" is to allow alternative representations of the same Icon; it is not
+      -- intended to allow multiple icons.
+  bodyType [1] CHOICE{
+           ianaType  [1] IMPLICIT InternationalString,
+          z3950type  [2] IMPLICIT InternationalString,
+           otherType  [3] IMPLICIT InternationalString},
+  content  [2] IMPLICIT OCTET STRING}
+
+
+LanguageCode ::= InternationalString  -- from ANSI/NISO Z39.53-1994 
+
+ContactInfo ::= SEQUENCE {
+  name           [0] IMPLICIT InternationalString OPTIONAL,
+  description  [1] IMPLICIT HumanString OPTIONAL,
+  address        [2] IMPLICIT HumanString OPTIONAL,
+  email         [3] IMPLICIT InternationalString OPTIONAL,
+  phone         [4] IMPLICIT InternationalString OPTIONAL}
+
+NetworkAddress ::= CHOICE {
+  internetAddress      [0] IMPLICIT SEQUENCE {
+                  hostAddress    [0]  IMPLICIT InternationalString,
+                  port       [1]  IMPLICIT INTEGER},
+  osiPresentationAddress    [1] IMPLICIT SEQUENCE { 
+                    pSel         [0] IMPLICIT InternationalString,  
+                    sSel         [1] IMPLICIT InternationalString OPTIONAL,  
+                    tSel        [2] IMPLICIT InternationalString OPTIONAL,  
+                    nSap      [3] IMPLICIT InternationalString},
+  other            [2] IMPLICIT SEQUENCE {  
+                      type        [0] IMPLICIT InternationalString,
+                address    [1] IMPLICIT InternationalString}}
+
+AccessInfo ::= SEQUENCE {
+    -- AccessInfo contains the fundamental information about what facilities are required to use this target
+    -- or server. For example, if an origin can handle none of the record syntaxes a database can provide, 
+    -- it might choose not to access the database.
+  queryTypesSupported  [0]    IMPLICIT SEQUENCE OF QueryTypeDetails OPTIONAL,
+  diagnosticsSets        [1]    IMPLICIT SEQUENCE OF OBJECT IDENTIFIER OPTIONAL,
+  attributeSetIds          [2]    IMPLICIT SEQUENCE OF AttributeSetId OPTIONAL,
+  schemas                [3]    IMPLICIT SEQUENCE OF OBJECT IDENTIFIER OPTIONAL,
+  recordSyntaxes         [4]    IMPLICIT SEQUENCE OF OBJECT IDENTIFIER OPTIONAL,
+  resourceChallenges    [5]    IMPLICIT SEQUENCE OF OBJECT IDENTIFIER OPTIONAL,
+  restrictedAccess       [6]    IMPLICIT AccessRestrictions OPTIONAL,
+  costInfo                 [8]    IMPLICIT Costs OPTIONAL,
+  variantSets       [9]    IMPLICIT SEQUENCE OF OBJECT IDENTIFIER OPTIONAL,
+  elementSetNames    [10]  IMPLICIT SEQUENCE OF ElementSetName OPTIONAL,
+  unitSystems      [11]  IMPLICIT SEQUENCE OF InternationalString}
+
+-- begin auxiliary definitions for AccessInfo
+-- Begin Query Details
+QueryTypeDetails ::= CHOICE {
+  private       [0]    IMPLICIT PrivateCapabilities,
+  rpn            [1]    IMPLICIT RpnCapabilities,
+  iso8777          [2]    IMPLICIT Iso8777Capabilities,
+  z39-58      [100]  IMPLICIT HumanString,
+  erpn        [101]  IMPLICIT RpnCapabilities,
+  rankedList      [102]  IMPLICIT HumanString}
+
+PrivateCapabilities ::= SEQUENCE {
+  operators       [0]  IMPLICIT SEQUENCE OF SEQUENCE {
+              operator  [0] IMPLICIT InternationalString,
+              description  [1] IMPLICIT HumanString OPTIONAL } OPTIONAL,
+  searchKeys    [1]  IMPLICIT SEQUENCE OF SearchKey OPTIONAL,  -- field names that can be searched
+  description    [2]  IMPLICIT SEQUENCE OF HumanString OPTIONAL }
+
+RpnCapabilities ::= SEQUENCE {
+  operators                    [0] IMPLICIT SEQUENCE OF INTEGER OPTIONAL,
+                                        -- Omitted means all operators are supported.
+  resultSetAsOperandSupported  [1] IMPLICIT BOOLEAN,
+  restrictionOperandSupported    [2] IMPLICIT BOOLEAN,
+  proximity                    [3] IMPLICIT ProximitySupport OPTIONAL}
+
+Iso8777Capabilities ::= SEQUENCE {
+  searchKeys  [0]  IMPLICIT SEQUENCE OF SearchKey,  -- field names that may be searched
+  restrictions   [1]  IMPLICIT HumanString OPTIONAL 
+            -- Omitted means supported, not specifying units.
+              }
+
+ProximitySupport ::= SEQUENCE {
+  anySupport      [0]   IMPLICIT BOOLEAN,
+          -- 'false' means no proximity support, in which case unitsSupported not supplied.
+  unitsSupported  [1]   IMPLICIT SEQUENCE OF CHOICE{  
+             known  [1] IMPLICIT INTEGER, -- values from KnownProximityUnit
+          private  [2] IMPLICIT SEQUENCE{  
+                      unit    [0] IMPLICIT INTEGER,  
+                description  [1] HumanString OPTIONAL}} OPTIONAL}
+
+SearchKey ::= SEQUENCE {
+  searchKey     [0]  IMPLICIT InternationalString,
+  description     [1]  IMPLICIT HumanString OPTIONAL }
+-- End Query details
+AccessRestrictions ::= SEQUENCE OF SEQUENCE {
+  accessType      [0] INTEGER {
+                  any         (0),
+                  search         (1),
+                  present         (2),
+                  specific-elements  (3),
+                  extended-services  (4),
+            by-database      (5)},
+  accessText         [1]  IMPLICIT HumanString OPTIONAL,
+  accessChallenges  [2]  IMPLICIT SEQUENCE OF OBJECT IDENTIFIER OPTIONAL}
+
+Costs ::= SEQUENCE {
+  connectCharge    [0] IMPLICIT Charge OPTIONAL,    -- Per-connection charge
+  connectTime    [1] IMPLICIT Charge OPTIONAL,    -- Time-based charge
+  displayCharge     [2] IMPLICIT Charge OPTIONAL,    -- Per-record charge
+  searchCharge     [3] IMPLICIT Charge OPTIONAL,    -- Per-search charge
+  subscriptCharge  [4]  IMPLICIT Charge OPTIONAL,  -- Subscription charges
+  otherCharges    [5] IMPLICIT SEQUENCE OF SEQUENCE{   -- Other charges
+            forWhat  [1]  IMPLICIT HumanString,
+            charge    [2]  IMPLICIT Charge} OPTIONAL} 
+    Charge ::= SEQUENCE{
+        cost          [1] IMPLICIT IntUnit,
+        perWhat  [2] IMPLICIT Unit OPTIONAL,
+                      -- e.g. "second," "minute," "line," "record"...
+        text          [3] IMPLICIT HumanString OPTIONAL} 
+-- End Auxiliary definitions for AccessInfo
+
+DatabaseList ::= SEQUENCE OF DatabaseName
+
+AttributeCombinations ::= SEQUENCE {
+  defaultAttributeSet  [0] IMPLICIT AttributeSetId,
+                 -- Default for the combinations. Also probably a good choice for the default
+              -- in searches, but that isn't required.
+  legalCombinations  [1] IMPLICIT SEQUENCE OF AttributeCombination }
+
+
+AttributeCombination ::= SEQUENCE OF AttributeOccurrence
+            -- An AttributeCombination is a pattern for legal combination of attributes
+
+
+AttributeOccurrence ::= SEQUENCE {   
+      -- An AttributeOccurrence lists the legal values for a specific attribute type in a combination.
+       attributeSet       [0]  IMPLICIT AttributeSetId OPTIONAL,
+       attributeType      [1]  IMPLICIT INTEGER,
+       mustBeSupplied  [2]  IMPLICIT NULL OPTIONAL,
+       attributeValues    CHOICE {
+                      any-or-none  [3] IMPLICIT NULL, -- All supported values are OK 
+                      specific    [4] IMPLICIT SEQUENCE OF StringOrNumeric}}
+                                                  -- Only these values allowed
+END
+
+
+
+
+
+
+
+
+
+RecordSyntax-SUTRS
+{Z39-50-recordSyntax SUTRS (101)} DEFINITIONS ::=
+BEGIN 
+IMPORTS InternationalString  FROM Z39-50-APDU-1995;
+        SutrsRecord ::=  InternationalString
+-- Line terminator is ASCII LF (X'0A').
+-- Recommended maximum line length is 72 characters.
+END
+
+
+
+
+
+RecordSyntax-opac
+{Z39-50-recordSyntax opac (102)} DEFINITIONS ::=
+BEGIN 
+IMPORTS InternationalString  FROM Z39-50-APDU-1995;
+OPACRecord ::= SEQUENCE {
+  bibliographicRecord   [1]   IMPLICIT EXTERNAL OPTIONAL,
+  holdingsData     [2]   IMPLICIT SEQUENCE OF HoldingsRecord OPTIONAL}
+HoldingsRecord ::=  CHOICE {
+  marcHoldingsRecord  [1]   IMPLICIT EXTERNAL,
+  holdingsAndCirc  [2]  IMPLICIT HoldingsAndCircData}
+HoldingsAndCircData ::=  SEQUENCE {
+-- the following elements are required to display holdings in conformance with NISO standards.
+  typeOfRecord    [1]   IMPLICIT InternationalString OPTIONAL, -- LDR 06
+  encodingLevel    [2]   IMPLICIT InternationalString OPTIONAL, -- LDR 017
+  format      [3]   IMPLICIT InternationalString OPTIONAL, -- 007 00-01
+  receiptAcqStatus    [4]   IMPLICIT InternationalString OPTIONAL, -- 008 06
+  generalRetention    [5]   IMPLICIT InternationalString OPTIONAL, -- 008 12
+  completeness    [6]   IMPLICIT InternationalString OPTIONAL, -- 008 16
+       dateOfReport     [7]   IMPLICIT InternationalString OPTIONAL, -- 008 26-31
+  nucCode    [8]   IMPLICIT InternationalString OPTIONAL, -- 852 $a
+  localLocation    [9]   IMPLICIT InternationalString OPTIONAL, -- 852 $b
+  shelvingLocation  [10]   IMPLICIT InternationalString OPTIONAL, -- 852 $c
+  callNumber    [11]   IMPLICIT InternationalString OPTIONAL, -- 852 $h and $i
+  shelvingData     [12]   IMPLICIT InternationalString OPTIONAL, -- 852 $j thru $m
+  copyNumber    [13]   IMPLICIT InternationalString OPTIONAL, -- 852 $t
+  publicNote    [14]   IMPLICIT InternationalString OPTIONAL, -- 852 $z
+  reproductionNote  [15]   IMPLICIT InternationalString OPTIONAL, -- 843
+  termsUseRepro     [16]   IMPLICIT InternationalString OPTIONAL, -- 845
+  enumAndChron    [17]   IMPLICIT InternationalString OPTIONAL, -- all 85x, 86x
+  volumes     [18]   IMPLICIT SEQUENCE OF Volume OPTIONAL, 
+            -- repeats for each volume held
+  circulationData    [19]   IMPLICIT SEQUENCE OF CircRecord OPTIONAL 
+            -- repeats for each circulating item.
+            }
+Volume ::=  SEQUENCE {
+  enumeration    [1]   IMPLICIT InternationalString OPTIONAL,
+  chronology     [2]   IMPLICIT InternationalString OPTIONAL,
+  enumAndChron    [3]   IMPLICIT InternationalString OPTIONAL }
+CircRecord ::=  SEQUENCE {
+  availableNow    [1]   IMPLICIT BOOLEAN,
+  availablityDate    [2]   IMPLICIT InternationalString OPTIONAL,
+  availableThru      [3]   IMPLICIT InternationalString OPTIONAL,
+  restrictions     [4]   IMPLICIT InternationalString OPTIONAL,
+  itemId        [5]   IMPLICIT InternationalString OPTIONAL,
+  renewable        [6]   IMPLICIT BOOLEAN,
+  onHold        [7]   IMPLICIT BOOLEAN,
+  enumAndChron     [8]   IMPLICIT InternationalString OPTIONAL,
+  midspine    [9]   IMPLICIT InternationalString OPTIONAL,
+  temporaryLocation  [10]   IMPLICIT InternationalString OPTIONAL}
+END
+
+
+
+RecordSyntax-summary
+
+{Z39-50-recordSyntax summary (103)} DEFINITIONS ::=
+BEGIN 
+IMPORTS OtherInformation, InternationalString  FROM Z39-50-APDU-1995;
+BriefBib ::= SEQUENCE {
+  title           [1]   IMPLICIT InternationalString,
+  author            [2]   IMPLICIT InternationalString OPTIONAL,
+  callNumber         [3]   IMPLICIT InternationalString OPTIONAL,
+  recordType      [4]   IMPLICIT InternationalString OPTIONAL,
+  bibliographicLevel  [5]   IMPLICIT InternationalString OPTIONAL,
+  format        [6]   IMPLICIT SEQUENCE OF FormatSpec OPTIONAL,
+  publicationPlace    [7]   IMPLICIT InternationalString OPTIONAL,
+  publicationDate     [8]   IMPLICIT InternationalString OPTIONAL,
+  targetSystemKey   [9]   IMPLICIT InternationalString OPTIONAL,
+  satisfyingElement  [10]   IMPLICIT InternationalString OPTIONAL,
+  rank         [11]   IMPLICIT INTEGER OPTIONAL,
+  documentId     [12]   IMPLICIT InternationalString OPTIONAL,
+  abstract       [13]   IMPLICIT InternationalString OPTIONAL,
+  otherInfo        OtherInformation OPTIONAL}
+
+FormatSpec     ::=  SEQUENCE {
+  type         [1]   IMPLICIT InternationalString,
+  size      [2]   IMPLICIT INTEGER OPTIONAL,
+  bestPosn     [3]   IMPLICIT INTEGER OPTIONAL}
+END
+
+
+
+
+
+
+
+
+
+
+RecordSyntax-generic  -- For detailed semantics, see Appendix RET.
+{Z39-50-recordSyntax GRS-1 (105)} DEFINITIONS ::=
+BEGIN 
+EXPORTS Variant;
+IMPORTS IntUnit, Unit, InternationalString, StringOrNumeric, Term FROM Z39-50-APDU-1995;
+
+GenericRecord ::= SEQUENCE OF TaggedElement  
+TaggedElement ::= SEQUENCE {
+  tagType    [1] IMPLICIT INTEGER OPTIONAL,
+              -- If omitted, default should be supplied dynamically by tagSet-M; 
+              -- otherwise it should be statically specified by the schema.
+  tagValue    [2] StringOrNumeric,
+  tagOccurrence  [3] IMPLICIT INTEGER OPTIONAL,
+                             -- Occurrence within the database record, and relative to the parent. No
+              -- default; if omitted, target not telling or it is irrelevant.
+  content      [4] ElementData,
+  metaData    [5] IMPLICIT ElementMetaData OPTIONAL,
+  appliedVariant  [6] IMPLICIT Variant OPTIONAL}
+
+ElementData ::= CHOICE{
+  octets      OCTET STRING,
+  numeric    INTEGER,
+  date      GeneralizedTime,
+  ext        EXTERNAL,
+  string      InternationalString,
+  trueOrFalse    BOOLEAN,
+  oid        OBJECT IDENTIFIER,
+  intUnit          [1]  IMPLICIT IntUnit,
+   elementNotThere    [2] IMPLICIT NULL,  -- element requested but not there
+  elementEmpty      [3] IMPLICIT NULL,  -- element there, but empty
+  noDataRequested    [4] IMPLICIT NULL,  -- variant request said 'no data'
+  diagnostic        [5] IMPLICIT EXTERNAL,
+  subtree          [6] SEQUENCE OF TaggedElement -- recursive, for nested tags
+              }
+
+
+ElementMetaData ::= SEQUENCE{
+  seriesOrder        [1]   IMPLICIT Order OPTIONAL, -- only for a non-leaf node
+  usageRight        [2]   IMPLICIT Usage OPTIONAL,
+  hits            [3]    IMPLICIT SEQUENCE OF HitVector OPTIONAL,
+  displayName      [4]    IMPLICIT InternationalString OPTIONAL, 
+                    -- name for element that origin can use for display
+  supportedVariants    [5]   IMPLICIT SEQUENCE OF Variant OPTIONAL,
+  message        [6]    IMPLICIT InternationalString OPTIONAL,
+  elementDescriptor    [7]   IMPLICIT OCTET STRING OPTIONAL,
+  surrogateFor      [8]   IMPLICIT TagPath OPTIONAL,  
+                    -- the retrieved element is a surrogate for the element given by this path  
+  surrogateElement    [9]   IMPLICIT TagPath OPTIONAL,
+                    -- the element given by this path is a surrogate for the retrieved element
+    other          [99]  IMPLICIT EXTERNAL OPTIONAL}
+
+        TagPath ::= SEQUENCE  OF SEQUENCE{
+          tagType      [1]  IMPLICIT INTEGER OPTIONAL,
+            tagValue      [2]  StringOrNumeric,
+            tagOccurrence    [3]  IMPLICIT INTEGER OPTIONAL}
+
+
+
+Order ::= SEQUENCE{
+  ascending    [1] IMPLICIT BOOLEAN,
+              -- "true" means monotonically increasing (i.e. non-decreasing); 
+              -- "false" means monotonically decreasing (i.e. non-increasing).
+  order      [2] IMPLICIT INTEGER
+              -- Same as defined by 'elementOrdering' in tagSet-M, though this may be
+              -- overridden by schema.
+          }
+
+
+
+Usage ::= SEQUENCE  {
+  type        [1] IMPLICIT INTEGER{
+              redistributable    (1),   -- Element is freely redistributable.
+              restricted      (2),   -- Restriction contains statement.
+              licensePointer    (3)   -- Restriction contains license pointer.
+              },
+  restriction    [2] IMPLICIT InternationalString OPTIONAL}
+
+
+
+HitVector ::= SEQUENCE{ 
+    -- Each hit vector points to a fragment within the element, via location and/or token.
+  satisfier            Term OPTIONAL, -- sourceword, etc.
+  offsetIntoElement    [1] IMPLICIT IntUnit OPTIONAL,
+  length          [2] IMPLICIT IntUnit OPTIONAL,
+  hitRank          [3] IMPLICIT INTEGER OPTIONAL,
+  targetToken        [4] IMPLICIT OCTET STRING OPTIONAL
+                  -- Origin may use token subsequently within a variantRequest (in
+                  --  an elementRequest) to retrieve (or to refer to) the fragment.  
+              }
+
+
+
+
+Variant ::= SEQUENCE{
+    globalVariantSetId    [1] IMPLICIT OBJECT IDENTIFIER OPTIONAL,
+                  -- Applies to the triples below, when variantSetId omitted. If
+                  -- globalVariantSetId omitted, default applies. Default may be provided by
+                  -- the tagSet-M element defaultVariantSetId.
+
+
+
+
+  triples          [2]  IMPLICIT SEQUENCE OF SEQUENCE{
+                  variantSetId  [0]  IMPLICIT OBJECT IDENTIFIER OPTIONAL,
+                              -- If omitted, globalVariantSetId (above)
+                              -- applies, unless that too is omitted, in
+                               -- which case, default used.
+                  class      [1]  IMPLICIT INTEGER,
+                  type      [2]  IMPLICIT INTEGER,
+                  value      [3]  CHOICE{
+                               integer INTEGER,
+                               internationalString InternationalString,
+                               octetString OCTET STRING,
+                               objectIdentifier OBJECT IDENTIFIER,
+                               boolean BOOLEAN,
+                              null NULL,
+                          -- Following need context tags:
+                            unit      [1] IMPLICIT Unit, 
+                            valueAndUnit  [2] IMPLICIT IntUnit}}}
+END
+
+
+
+RecordSyntax-ESTaskPackage
+{Z39-50-recordSyntax ESTaskPackage (106)} DEFINITIONS ::=
+BEGIN 
+IMPORTS Permissions, InternationalString, IntUnit, DiagRec FROM Z39-50-APDU-1995;
+
+TaskPackage ::= SEQUENCE{
+  packageType      [1]   IMPLICIT OBJECT IDENTIFIER,
+                    -- oid of specific ES definition
+  packageName      [2]   IMPLICIT InternationalString OPTIONAL,
+  userId          [3]   IMPLICIT InternationalString OPTIONAL,
+  retentionTime      [4]   IMPLICIT IntUnit OPTIONAL,
+  permissions        [5]   IMPLICIT Permissions OPTIONAL,
+  description        [6]   IMPLICIT InternationalString OPTIONAL,
+  targetReference      [7]   IMPLICIT OCTET STRING OPTIONAL,
+  creationDateTime    [8]   IMPLICIT GeneralizedTime OPTIONAL,
+  taskStatus        [9]   IMPLICIT INTEGER{
+                      pending    (0),
+                      active    (1),
+                      complete  (2),
+                      aborted    (3)},
+  packageDiagnostics    [10]  IMPLICIT SEQUENCE OF DiagRec OPTIONAL,
+  taskSpecificParameters  [11]  IMPLICIT EXTERNAL
+                    -- Use oid for specific ES definition
+                    -- (same oid as packageType above)
+                    -- and select [2] "taskPackage."
+    } 
+END
+
+
+
+
+ResourceReport-Format-Resource-1
+{Z39-50-resourceReport resource-1 (1)} DEFINITIONS ::=
+BEGIN 
+IMPORTS InternationalString FROM Z39-50-APDU-1995;  
+--
+ResourceReport ::= SEQUENCE{
+estimates    [1]   IMPLICIT SEQUENCE OF Estimate,
+message      [2]   IMPLICIT InternationalString}
+--
+Estimate ::= SEQUENCE{
+type        [1]   IMPLICIT EstimateType,
+value        [2]   IMPLICIT INTEGER,  -- the actual estimate
+currency-code  [3]   IMPLICIT INTEGER OPTIONAL
+                -- code for representation of currencies defined in ISO 4217-1990.  
+                -- Applicable only to monetary estimates.
+                              }
+EstimateType ::= INTEGER{
+currentSearchRecords    (1),         -- estimated no. records in current (incomplete) result set for search
+finalSearchRecords       (2),        -- estimated no. records that will be in result set if search completes
+currentPresentRecords    (3),        -- estimated number of records in current (incomplete) set of
+                      -- records to be returned on Present
+finalPresentRecords      (4),  -- estimated number of records that will be in the set of records
+                      -- to be returned by Present if Present completes
+currentOpTimeProcessing  (5),  -- processing time (in .001 CPU seconds) used by operation so far
+finalOpTimeProcessing    (6),                -- estimated total processing time (in .001 CPU seconds) that will
+                              -- be used by this operation if it completes
+currentAssocTime      (7),  -- estimated processing time used by association (in .001 CPU sec.)
+currentOperationCost      (8),  -- estimated cost for this operation so far
+finalOperationCost      (9),  -- estimated cost for this operation if it completes
+currentAssocCost        (10),  -- estimated cost for this association so far
+finalOpTimeElapsed            (11),  -- estimated elapsed time for operation if it completes (in .001 sec.) 
+percentComplete         (12), -- estimated percent complete
+currentSearchAssocCost    (13),  -- estimated search cost for association so far
+currentPresentAssocCost  (14),  -- estimated present cost for this association so far
+currentConnectAssocCost    (15),  -- estimated connect time cost for association so far
+currentOtherAssocCost    (16)  -- estimated other cost (not included in 13-15) for association so far
+                  }
+END
+
+
+
+
+
+
+
+
+
+
+
+
+
+ResourceReport-Format-Resource-2
+{Z39-50-resourceReport resource-2 (2)} DEFINITIONS ::=
+BEGIN 
+IMPORTS InternationalString, StringOrNumeric, IntUnit FROM Z39-50-APDU-1995;  
+--
+ResourceReport ::= SEQUENCE{
+estimates    [1]   IMPLICIT SEQUENCE OF Estimate OPTIONAL,
+message      [2]   IMPLICIT InternationalString OPTIONAL}
+--
+Estimate ::= SEQUENCE{
+type      [1]   StringOrNumeric,
+              -- Numeric values of 1-16 are the same as used in Resource-1.
+value      [2]   IMPLICIT IntUnit
+              -- When expressing currency:
+              --    unitSystem (of Unit) is 'z3950'  (case insensitive)
+              --    unitType is 'iso4217-1990'       (case insensitive)
+              --    unit is currency code from ISO 4217-1990.
+}
+END
+
+
+
+
+
+AccessControlFormat-prompt-1
+{Z39-50-accessControl prompt-1 (1)} DEFINITIONS ::=
+BEGIN
+IMPORTS InternationalString, DiagRec FROM Z39-50-APDU-1995;
+--
+PromptObject ::= CHOICE{
+  challenge      [1] IMPLICIT Challenge,
+   response        [2] IMPLICIT Response}
+
+  Challenge ::= SEQUENCE OF SEQUENCE {
+    promptId      [1] PromptId,
+                    -- Target supplies a number (for an enumerated prompt) or string (for a non
+                    -- -enumerated prompt), for each prompt, and the origin returns it in response, for
+                    -- this prompt, so target may correlate the prompt response with the prompt.
+    defaultResponse  [2] IMPLICIT InternationalString OPTIONAL,
+     promptInfo      [3] CHOICE{ 
+                    character  [1] IMPLICIT InternationalString,
+                    encrypted  [2] IMPLICIT Encryption} OPTIONAL,
+                    -- Information corresponding to an enumerated prompt. For example if 'type', within
+                    -- PromptId, is 'copyright', then promptInfo may contain a copyright statement.  
+    regExpr        [4] IMPLICIT InternationalString OPTIONAL,
+                              -- A regular expression that promptResponse should match. See IEEE 1003.2
+                    -- Volume 1, Section 2.8 "Regular Expression Notation." For example if promptId
+                    -- is "Year of publication," regExpr might be "19[89][0-9]|20[0-9][0-9]".
+    responseRequired  [5] IMPLICIT NULL OPTIONAL,
+     allowedValues    [6] IMPLICIT SEQUENCE OF InternationalString OPTIONAL,
+                        -- e.g. promptId="Desired color"; allowed = 'red', 'blue','Green'.
+    shouldSave      [7] IMPLICIT NULL OPTIONAL,
+                        -- Target recommends that origin save the data that it prompts from the
+                     -- user corresponding to this prompt, because it is likely to be requested again (so
+                    -- origin might not have to prompt the user next time).
+        dataType        [8] IMPLICIT INTEGER{
+                             integer        (1),
+                          date            (2),
+                        float           (3),
+                        alphaNumeric  (4),
+                        url-urn       (5),
+                        boolean       (6)} OPTIONAL,
+                        -- Target telling origin type of data it wants. E.g., if "date" is specified,
+                        -- presumably the origin will try to prompt something "date-like" from the user.
+        diagnostic       [9] IMPLICIT EXTERNAL OPTIONAL
+                          -- Intended for repeat requests when there is an error the origin 
+                        -- should report to the user from previous attempt.
+                }
+
+
+  Response ::= SEQUENCE OF SEQUENCE {
+      promptId    [1] PromptId,
+                  -- Corresponds to a prompt in the challenge, or may be unprompted, for
+                  -- example "newPassword." If unprompted, should be "enumerated." 
+                  -- If this responds to a non-enumerated prompt, then nonEnumeratedPrompt
+                   -- should contain the prompt string from the challenge.
+    promptResponse  [2] CHOICE{
+                    string      [1] IMPLICIT InternationalString,
+                    accept      [2] IMPLICIT BOOLEAN,
+                    acknowledge  [3] IMPLICIT NULL,
+                    diagnostic    [4] DiagRec,
+                     encrypted    [5] IMPLICIT Encryption}}
+
+
+ PromptId ::= CHOICE{
+  enummeratedPrompt    [1] IMPLICIT SEQUENCE{
+                      type            [1] IMPLICIT INTEGER{
+                                      groupId    (0),
+                                      userId     (1),
+                                      password   (2),
+                                      newPassword  (3),
+                                      copyright    (4),
+                            -- When type on Challenge is 'copyright', promptInfo has text of
+                            -- copyright message to be displayed verbatim to the user. If
+                            -- promptResponse indicates 'acceptance', this indicates the user has been
+                            -- shown, and accepted, the terms of the copyright. This is not intended
+                            -- to be legally binding, but provides a good-faith attempt on
+                            -- the part of the target to inform the user of the copyright.
+                                      sessionId      (5)},
+                      suggestedString    [2] IMPLICIT InternationalString OPTIONAL},
+   nonEnumeratedPrompt  [2] IMPLICIT InternationalString}
+
+
+ Encryption ::= SEQUENCE{
+  cryptType    [1] IMPLICIT OCTET STRING OPTIONAL, 
+  credential    [2] IMPLICIT OCTET STRING OPTIONAL,
+                    --random number, SALT, or other factor
+  data        [3] IMPLICIT OCTET STRING}
+
+END
+
+
+
+
+AccessControlFormat-des-1
+{Z39-50-accessControlFormat  des-1 (2)} DEFINITIONS ::=
+BEGIN
+    DES-RN-Object ::= CHOICE {
+      challenge    [1]    IMPLICIT DRNType,
+      response      [2]    IMPLICIT DRNType}
+    DRNType ::= SEQUENCE{
+          userId        [1]    IMPLICIT OCTET STRING OPTIONAL,
+          salt          [2]    IMPLICIT OCTET STRING OPTIONAL,
+          randomNumber  [3]    IMPLICIT OCTET STRING}
+END
+
+
+AccessControlFormat-krb-1
+{Z39-50-accessControlFormat  krb-1 (3)} DEFINITIONS ::=
+BEGIN
+IMPORTS InternationalString FROM Z39-50-APDU-1995;
+
+     KRBObject ::= CHOICE {
+       challenge   [1]    IMPLICIT KRBRequest,
+       response    [2]    IMPLICIT KRBResponse}
+     KRBRequest ::= SEQUENCE{
+           service         [1]   IMPLICIT InternationalString,
+           instance        [2]   IMPLICIT InternationalString OPTIONAL,
+           realm          [3]   IMPLICIT InternationalString OPTIONAL}
+        -- target requests a ticket for the given service, instance, and realm
+     KRBResponse ::= SEQUENCE{
+           userid            [1]   IMPLICIT InternationalString OPTIONAL,
+           ticket           [2]  IMPLICIT OCTET STRING}
+        -- origin responds with a ticket for the requested service
+END
+
+
+
+
+
+
+
+
+
+ESFormat-PersistentResultSet
+{Z39-50-extendedService PersistentResultSet (1)} DEFINITIONS ::=
+BEGIN
+IMPORTS InternationalString FROM Z39-50-APDU-1995;
+PersistentResultSet ::= CHOICE{
+    esRequest    [1] IMPLICIT SEQUENCE{
+        toKeep    [1] IMPLICIT NULL,
+        notToKeep  [2] OriginPartNotToKeep OPTIONAL},
+    taskPackage  [2] IMPLICIT SEQUENCE{
+        originPart  [1] IMPLICIT NULL,
+        targetPart  [2] TargetPart OPTIONAL}}
+OriginPartNotToKeep ::= SEQUENCE{
+  originSuppliedResultSet  [1] IMPLICIT InternationalString OPTIONAL,
+          -- name of transient result set, supplied on request, mandatory unless function is 'delete'
+  replaceOrAppend    [2] IMPLICIT INTEGER{  -- only if function is "modify"
+          replace    (1),
+          append    (2)} OPTIONAL}
+TargetPart ::= SEQUENCE{
+  targetSuppliedResultSet  [1] IMPLICIT InternationalString OPTIONAL, 
+          -- Name of transient result set, supplied by target, representing the persistent result set to which
+          -- package pertains. Meaningful only when package  is presented. (i.e. not on ES response).
+  numberOfRecords  [2] IMPLICIT INTEGER OPTIONAL}
+END
+
+
+ESFormat-PersistentQuery
+{Z39-50-extendedService PersistentQuery (2)} DEFINITIONS ::=
+BEGIN
+IMPORTS Query, InternationalString, OtherInformation FROM Z39-50-APDU-1995;
+PersistentQuery ::= CHOICE{
+    esRequest      [1] IMPLICIT SEQUENCE{
+        toKeep    [1] OriginPartToKeep OPTIONAL,
+        notToKeep  [2] OriginPartNotToKeep},
+    taskPackage    [2] IMPLICIT SEQUENCE{
+        originPart  [1] OriginPartToKeep OPTIONAL,
+        targetPart  [2] TargetPart}}
+OriginPartToKeep ::= SEQUENCE{
+  dbNames        [2] IMPLICIT SEQUENCE OF InternationalString OPTIONAL,
+  additionalSearchInfo  [3] OtherInformation OPTIONAL}
+OriginPartNotToKeep ::= CHOICE{
+  package    [1] IMPLICIT InternationalString,
+  query    [2] Query}
+TargetPart ::= Query          
+END
+
+ESFormat-PeriodicQuerySchedule
+{Z39-50-extendedService PeriodicQuerySchedule (3)} DEFINITIONS ::=
+BEGIN
+IMPORTS Query, InternationalString, IntUnit FROM Z39-50-APDU-1995 
+ExportSpecification, Destination FROM ESFormat-ExportSpecification;
+
+PeriodicQuerySchedule ::= CHOICE{
+    esRequest    [1] IMPLICIT SEQUENCE{
+              toKeep    [1] OriginPartToKeep,
+              notToKeep  [2] OriginPartNotToKeep},
+    taskPackage    [2] IMPLICIT SEQUENCE{
+              originPart  [1] OriginPartToKeep,
+              targetPart  [2] TargetPart}}
+
+OriginPartToKeep ::=SEQUENCE{
+  activeFlag          [1] IMPLICIT BOOLEAN,
+  databaseNames        [2] IMPLICIT SEQUENCE OF InternationalString OPTIONAL,
+  resultSetDisposition      [3] IMPLICIT INTEGER{
+                    replace    (1),
+                    append    (2),
+                    createNew  (3)  -- Only if origin and target have agreement about
+                            -- naming convention for the resulting package,
+                             -- and only if no result set is specified.
+                } OPTIONAL,   -- Mandatory on 'create' if result set is specified, in
+                        -- which case it must be 'replace' or 'append.
+  alertDestination        [4] Destination OPTIONAL,
+  exportParameters      [5] CHOICE{
+                    packageName  [1]   IMPLICIT InternationalString,
+                    exportPackage  [2] ExportSpecification} OPTIONAL}
+
+OriginPartNotToKeep ::= SEQUENCE{
+  querySpec           [1] CHOICE{
+                    actualQuery    [1] Query,
+                    packageName  [2] IMPLICIT InternationalString} OPTIONAL,
+                  -- mandatory for 'create'
+  originSuggestedPeriod    [2] Period OPTIONAL,  -- mandatory for 'create'
+  expiration          [3] IMPLICIT GeneralizedTime OPTIONAL,
+  resultSetPackage        [4] IMPLICIT InternationalString OPTIONAL}
+
+TargetPart ::= SEQUENCE{
+  actualQuery        [1] Query,
+  targetStatedPeriod    [2] Period,
+                  -- Target supplies the period, which may be same as origin proposed.
+  expiration        [3] IMPLICIT GeneralizedTime OPTIONAL,
+                  -- Target supplies value for task package. It may be the same as origin
+                  -- proposed or different from (and overrides) origin proposal, but if
+                  -- omitted, there is no expiration.
+  resultSetPackage      [4] IMPLICIT InternationalString OPTIONAL,
+                  -- May be omitted only if exportParameters was supplied. Target
+                  -- supplies same name as origin supplied, if origin did supply a name.
+  lastQueryTime      [5] IMPLICIT GeneralizedTime,
+  lastResultNumber    [6] IMPLICIT INTEGER,
+  numberSinceModify    [7] IMPLICIT INTEGER OPTIONAL}
+
+
+
+
+  Period ::= CHOICE{
+                unit             [1] IMPLICIT IntUnit,
+                 businessDaily     [2] IMPLICIT NULL,
+              continuous       [3] IMPLICIT NULL,
+              other         [4] IMPLICIT InternationalString}
+END
+
+
+ESFormat-ItemOrder
+{Z39-50-extendedService ItemOrder (4)} DEFINITIONS ::=
+BEGIN
+IMPORTS InternationalString FROM Z39-50-APDU-1995;
+ItemOrder ::= CHOICE{
+    esRequest  [1] IMPLICIT SEQUENCE{
+              toKeep    [1] OriginPartToKeep OPTIONAL,
+              notToKeep  [2] OriginPartNotToKeep},
+    taskPackage  [2] IMPLICIT SEQUENCE{
+              originPart  [1] OriginPartToKeep OPTIONAL,
+              targetPart  [2] TargetPart}}
+OriginPartToKeep ::= SEQUENCE{
+  supplDescription    [1] IMPLICIT EXTERNAL OPTIONAL,
+  contact        [2] IMPLICIT SEQUENCE{
+                       name  [1]   IMPLICIT InternationalString OPTIONAL,
+                         phone  [2]   IMPLICIT InternationalString OPTIONAL,
+                       email  [3]   IMPLICIT InternationalString OPTIONAL} OPTIONAL,
+  addlBilling      [3] IMPLICIT SEQUENCE{
+                paymentMethod    [1]   CHOICE{
+                                  billInvoice              [0] IMPLICIT NULL,
+                                    prepay                [1] IMPLICIT NULL,
+                                    depositAccount        [2] IMPLICIT NULL,
+                                    creditCard          [3] IMPLICIT CreditCardInfo,
+                    cardInfoPreviouslySupplied  [4] IMPLICIT NULL,
+                    privateKnown        [5] IMPLICIT NULL,
+                    privateNotKnown      [6] IMPLICIT EXTERNAL},
+                customerReference  [2] IMPLICIT InternationalString OPTIONAL,
+                     customerPONumber  [3] IMPLICIT InternationalString OPTIONAL}
+                                 OPTIONAL}
+CreditCardInfo   ::= SEQUENCE{
+       nameOnCard    [1] IMPLICIT InternationalString,
+      expirationDate    [2] IMPLICIT InternationalString,
+    cardNumber      [3] IMPLICIT InternationalString} 
+
+OriginPartNotToKeep ::= SEQUENCE{ -- Corresponds to 'requestedItem' in service definition.
+      --  Must supply at least one, and may supply both.
+  resultSetItem    [1]   IMPLICIT SEQUENCE{  
+                resultSetId    [1]   IMPLICIT InternationalString,
+                    item      [2]   IMPLICIT INTEGER} OPTIONAL,
+  itemRequest      [2] IMPLICIT EXTERNAL OPTIONAL
+                -- When itemRequest is an ILL-Request APDU, 
+                -- use OID {iso standard 10161 abstract-syntax (2) ill-apdus (1)}
+              }
+
+TargetPart ::= SEQUENCE{
+  itemRequest      [1]  IMPLICIT EXTERNAL OPTIONAL,
+    -- When itemRequest is an ILL-Request APDU, use OID 1.0.10161.2.1 (as above)
+  statusOrErrorReport  [2] IMPLICIT EXTERNAL OPTIONAL,
+    -- When statusOrErrorReport is an ILL Status-Or-Error-Report APDU, use OID  1.0.10161.2.1 (as above)
+  auxiliaryStatus    [3]  IMPLICIT INTEGER{
+                notReceived      (1),
+                loanQueue      (2),
+                forwarded      (3),
+                unfilledCopyright  (4),
+                filledCopyright    (5)} OPTIONAL}
+END
+
+
+
+
+ESFormat-Update0
+{Z39-50-extendedService Update (5)} DEFINITIONS ::=
+BEGIN
+IMPORTS DiagRec, InternationalString FROM Z39-50-APDU-1995; 
+Update ::= CHOICE{
+    esRequest  [1] IMPLICIT SEQUENCE{
+              toKeep    [1] OriginPartToKeep,
+              notToKeep  [2] OriginPartNotToKeep},
+    taskPackage  [2] IMPLICIT SEQUENCE{
+              originPart  [1] OriginPartToKeep,
+              targetPart  [2] TargetPart}}
+
+
+OriginPartToKeep ::= SEQUENCE{
+  action          [1] IMPLICIT INTEGER{
+                   recordInsert    (1),
+                   recordReplace  (2),
+                  recordDelete  (3),
+                  elementUpdate  (4)},
+  databaseName      [2] IMPLICIT InternationalString,
+  schema          [3] IMPLICIT OBJECT IDENTIFIER OPTIONAL,
+  elementSetName      [4] IMPLICIT InternationalString OPTIONAL}
+
+
+OriginPartNotToKeep ::= SuppliedRecords
+
+
+TargetPart ::= SEQUENCE{
+  updateStatus    [1] IMPLICIT INTEGER{
+                  success  (1),
+                  partial  (2),
+                  failure  (3)},
+  globalDiagnostics  [2] IMPLICIT SEQUENCE OF DiagRec OPTIONAL,
+                -- These are non-surrogate diagnostics relating to the task, 
+                -- not to individual records.
+  taskPackageRecords  [3] IMPLICIT SEQUENCE OF TaskPackageRecordStructure
+                -- There should be a TaskPackageRecordStructure for every record
+                -- supplied. The target should create such a structure for every
+                      -- record immediately upon creating the task package to include
+                -- correlation information and status. The record itself would not
+                -- be included until processing for that record is complete.
+            }
+
+-- Auxiliary definitions for Update
+SuppliedRecords ::= SEQUENCE OF SEQUENCE{
+  recordId    [1] CHOICE{
+              number  [1] IMPLICIT INTEGER,
+              string  [2] IMPLICIT InternationalString,
+              opaque  [3]  IMPLICIT OCTET STRING} OPTIONAL,
+  supplementalId  [2] CHOICE{
+              timeStamp    [1] IMPLICIT GeneralizedTime,
+              versionNumber  [2] IMPLICIT InternationalString,
+              previousVersion  [3] IMPLICIT EXTERNAL} OPTIONAL,
+  correlationInfo  [3] IMPLICIT CorrelationInfo OPTIONAL,
+  record      [4] IMPLICIT EXTERNAL}
+
+CorrelationInfo ::= SEQUENCE{
+          -- origin may supply one or both for any record:
+  note  [1] IMPLICIT InternationalString OPTIONAL,
+  id    [2] IMPLICIT INTEGER OPTIONAL}
+
+TaskPackageRecordStructure ::= SEQUENCE{
+    recordOrSurDiag  [1] CHOICE {
+                record    [1] IMPLICIT EXTERNAL,
+                        -- Choose 'record' if recordStatus is 'success', and
+                        -- elementSetName was supplied.
+                diagnostic  [2] DiagRec
+                        -- Choose 'diagnostic', if RecordStatus is failure.
+                                } OPTIONAL,
+                -- The parameter recordOrSurDiag will thus be omitted only if
+                -- 'elementSetName' was omitted and recordStatus is
+                -- 'success'; or if record status is 'queued' or in 'process'.
+    correlationInfo    [2] IMPLICIT CorrelationInfo OPTIONAL,
+                -- This should be included if it was supplied by the origin.
+    recordStatus      [3] IMPLICIT INTEGER{
+                  success    (1),
+                  queued    (2),
+                  inProcess  (3),
+                  failure    (4)}}
+END
+
+
+ESFormat-ExportSpecification
+{Z39-50-extendedService ExportSpecification (6)} DEFINITIONS ::=
+BEGIN
+EXPORTS ExportSpecification, Destination; IMPORTS CompSpec, InternationalString FROM Z39-50-APDU-1995;
+ExportSpecification ::= CHOICE{
+    esRequest    [1] IMPLICIT SEQUENCE{
+        toKeep    [1] OriginPartToKeep,
+        notToKeep  [2] IMPLICIT NULL},
+    taskPackage    [2] IMPLICIT SEQUENCE{
+        originPart  [1] OriginPartToKeep,
+        targetPart  [2] IMPLICIT NULL}}
+OriginPartToKeep ::= SEQUENCE{
+  composition        [1] IMPLICIT CompSpec,
+  exportDestination    [2] Destination}
+
+  Destination ::= CHOICE{
+  phoneNumber    [1]    IMPLICIT InternationalString,
+  faxNumber      [2]   IMPLICIT InternationalString,
+  x400address      [3]   IMPLICIT InternationalString,
+  emailAddress    [4]   IMPLICIT InternationalString,
+  pagerNumber    [5]   IMPLICIT InternationalString,
+  ftpAddress      [6]   IMPLICIT InternationalString,
+  ftamAddress    [7]   IMPLICIT InternationalString,
+  printerAddress    [8]   IMPLICIT InternationalString,
+  other        [100]  IMPLICIT SEQUENCE{
+                  vehicle      [1]  IMPLICIT InternationalString  OPTIONAL,
+                  destination    [2] IMPLICIT InternationalString}}
+END
+
+
+
+
+ESFormat-ExportInvocation
+{Z39-50-extendedService ExportInvocation (7)} DEFINITIONS ::=
+BEGIN
+IMPORTS InternationalString, IntUnit FROM Z39-50-APDU-1995 
+ExportSpecification FROM ESFormat-ExportSpecification;
+ExportInvocation ::= CHOICE{
+    esRequest    [1] IMPLICIT SEQUENCE{
+        toKeep    [1] OriginPartToKeep,
+        notToKeep  [2] OriginPartNotToKeep},
+    taskPackage    [2] IMPLICIT SEQUENCE{
+        originPart  [1] OriginPartToKeep,
+        targetPart  [2] TargetPart OPTIONAL}}
+
+OriginPartToKeep ::= SEQUENCE{
+  exportSpec    [1] CHOICE{
+              packageName    [1] IMPLICIT InternationalString,
+              packageSpec    [2] ExportSpecification},
+  numberOfCopies  [2] IMPLICIT INTEGER}
+
+
+
+
+
+OriginPartNotToKeep  ::= SEQUENCE{
+  resultSetId      [1] IMPLICIT InternationalString,
+  records        [2] CHOICE{
+                all    [1] IMPLICIT NULL,
+                ranges  [2]   IMPLICIT SEQUENCE OF SEQUENCE{
+                        start  [1] IMPLICIT INTEGER,
+                        count  [2] IMPLICIT INTEGER OPTIONAL
+                          -- Count may be omitted only on last range, to indicate
+                          -- "all remaining records beginning with 'start'."
+                    }}}
+
+TargetPart   ::= SEQUENCE{
+    estimatedQuantity    [1] IMPLICIT IntUnit OPTIONAL,
+    quantitySoFar      [2] IMPLICIT IntUnit OPTIONAL,
+    estimatedCost      [3] IMPLICIT IntUnit OPTIONAL,
+    costSoFar        [4] IMPLICIT IntUnit OPTIONAL}
+END
+
+
+
+UserInfoFormat-searchResult-1
+{Z39-50-userInfoFormat searchResult-1 (1)} DEFINITIONS ::=
+BEGIN
+IMPORTS DatabaseName, Term, Query, IntUnit, InternationalString FROM Z39-50-APDU-1995;
+SearchInfoReport ::= SEQUENCE OF SEQUENCE{
+  subqueryId      [1] IMPLICIT InternationalString OPTIONAL, 
+                           -- shorthand identifier of subquery
+  fullQuery        [2] IMPLICIT BOOLEAN,     -- 'true' means this is the full query; 'false',
+                          -- a sub-query 
+  subqueryExpression    [3] QueryExpression OPTIONAL,  -- A subquery of the query as
+                          -- submitted. May be whole query;
+                          -- if so, "fullQuery" should be 'true'.
+  subqueryInterpretation  [4] QueryExpression OPTIONAL,  -- how target interpreted subquery
+  subqueryRecommendation  [5] QueryExpression OPTIONAL,  -- target-recommended alternative
+  subqueryCount      [6] IMPLICIT INTEGER OPTIONAL,  -- Number of records for this
+                          -- subQuery, across all of the specified
+                          -- databases. (If during search, via resource
+                           -- control, number of records so far).
+  subqueryWeight     [7] IMPLICIT IntUnit OPTIONAL,  -- relative weight of this subquery
+  resultsByDB          [8] IMPLICIT ResultsByDB OPTIONAL}
+
+ResultsByDB ::= SEQUENCE OF SEQUENCE{
+  databases      [1] CHOICE{
+            all     [1] IMPLICIT NULL,
+                  -- applies across all of the databases in Search PDU
+            list    [2]  IMPLICIT SEQUENCE OF DatabaseName
+                  -- applies across all databases in this list
+              },
+  count        [2] IMPLICIT INTEGER OPTIONAL,
+            -- Number of records for query component (and, as above, if during search,
+             -- via resource control, number of records so far).
+  resultSetName    [3] IMPLICIT InternationalString OPTIONAL
+                        -- Target-assigned result set by which subQuery is available. Should not
+             -- be provided unless processing for this query component is concluded (i.e.,
+            -- when this report comes during search, via resource control, as opposed
+            -- to after search, via additionalSearchInfo).
+              }
+
+QueryExpression ::=  CHOICE {
+                term   [1] IMPLICIT SEQUENCE{
+              queryTerm  [1]  Term,
+              termComment            [2] IMPLICIT InternationalString OPTIONAL},
+           query  [2] Query}
+END
+
+
+
+ElementSpecificationFormat-eSpec-1
+{Z39-50-elementSpec eSpec-1 (1)} DEFINITIONS ::=
+BEGIN
+IMPORTS Variant FROM RecordSyntax-generic
+StringOrNumeric, InternationalString FROM Z39-50-APDU-1995;
+--
+Espec-1 ::= SEQUENCE{
+  elementSetNames    [1] IMPLICIT SEQUENCE OF InternationalString OPTIONAL,
+                  -- Origin may include one or more element set names, each
+                  -- specifying a set of elements. Each of the elements is to be
+                  -- treated as an elementRequest in the form of simpleElement,
+                  -- where occurrence is 1. 
+  defaultVariantSetId    [2] IMPLICIT OBJECT IDENTIFIER OPTIONAL,
+                  -- If supplied, applies whenever variantRequest 
+                  -- does not include variantSetId. 
+  defaultVariantRequest  [3] IMPLICIT Variant OPTIONAL,
+                  -- If supplied, then for each simple elementRequest that does not
+                   -- include a variantRequest, the defaultVariantRequest applies.
+                  -- (defaultVariantRequest does not apply to a compositeRequest.)
+  defaultTagType      [4] IMPLICIT INTEGER OPTIONAL,
+                  -- If supplied, applies whenever 'tagType' (within 'tag' within TagPath) 
+                  -- is omitted.
+  elements        [5] IMPLICIT SEQUENCE OF ElementRequest OPTIONAL}
+--
+
+ElementRequest::= CHOICE{
+  simpleElement    [1]   IMPLICIT SimpleElement,
+  compositeElement  [2] IMPLICIT SEQUENCE{
+            elementList    [1] CHOICE{
+                  primitives    [1]   IMPLICIT SEQUENCE OF InternationalString,
+                              -- Origin may specify one or more element
+                              -- set names, each identifying a set of elements,
+                              -- and the composite element is the union.
+                  specs      [2] IMPLICIT SEQUENCE OF SimpleElement},
+
+            deliveryTag    [2] IMPLICIT TagPath,
+                          -- DeliveryTag tagPath for compositeElement may not
+                          -- include wildThing or wildPath.
+            variantRequest  [3] IMPLICIT Variant OPTIONAL}}
+
+SimpleElement ::= SEQUENCE{
+      path        [1] IMPLICIT TagPath,
+      variantRequest  [2] IMPLICIT Variant OPTIONAL}
+  
+
+TagPath ::= SEQUENCE OF CHOICE{  
+  specificTag  [1] IMPLICIT SEQUENCE{
+            tagType  [1] IMPLICIT INTEGER OPTIONAL,
+                      -- If omitted, then 'defaultTagType' (above) applies, if supplied, and
+                      -- if not supplied, then default listed in schema applies.
+            tagValue  [2] StringOrNumeric,
+             occurrence  [3] Occurrences OPTIONAL 
+                      -- default is "first occurrence"
+                  },
+  wildThing  [2] Occurrences,
+              -- Get Nth "thing" at this level, regardless of tag, for each N specified by
+            -- "Occurrences" (which may be 'all' meaning match every element at this level).
+            -- E.g., if "Occurrences" is 3, get third element regardless of its tag or the tag of
+            -- the first two elements.
+  wildPath  [3] IMPLICIT NULL
+              -- Match any tag, at this level or below, that is on a path for which next tag in this 
+              -- TagPath sequence occurs. WildPath may not be last member of the TagPath
+            -- sequence.
+                      }
+--
+
+Occurrences ::= CHOICE{
+  all    [1] IMPLICIT NULL,
+  last    [2] IMPLICIT NULL,
+  values  [3] IMPLICIT SEQUENCE{
+          start    [1] IMPLICIT INTEGER,
+                  -- if 'start' alone is included, then single occurrence is requested
+          howMany  [2] IMPLICIT INTEGER OPTIONAL
+                  -- For example, if 'start' is 5 and 'howMany' is 6, then request is for
+                  -- "occurrences 5 through 10."
+                  }}
+END
+
index b7854ca..96ac4d9 100644 (file)
@@ -1,7 +1,7 @@
 # Copyright (C) 1995-1999, Index Data
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
 # Copyright (C) 1995-1999, Index Data
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile.in,v 1.5 1999-04-16 14:45:55 adam Exp $
+# $Id: Makefile.in,v 1.6 1999-06-08 10:10:16 adam Exp $
 
 SHELL=/bin/sh
 
 
 SHELL=/bin/sh
 
@@ -19,8 +19,8 @@ SHELL=/bin/sh
 INCLUDE=-I../z39.50 -I../include -I. -I../../xtimosi/src
 DEFS=$(INCLUDE) $(CDEFS)
 LIB=$(LIBDIR)/libserver.a 
 INCLUDE=-I../z39.50 -I../include -I. -I../../xtimosi/src
 DEFS=$(INCLUDE) $(CDEFS)
 LIB=$(LIBDIR)/libserver.a 
-YAZLIBS=$(LIBDIR)/libserver.a $(LIBDIR)/libasn.a $(LIBDIR)/libodr.a \
-$(LIBDIR)/libcomstack.a $(LIBMOSI) $(LIBDIR)/libutil.a
+YAZLIBS=$(LIBDIR)/libserver.a $(LIBDIR)/libzutil.a $(LIBDIR)/libasn.a \
+  $(LIBDIR)/libodr.a $(LIBDIR)/libcomstack.a $(LIBMOSI) $(LIBDIR)/libutil.a
 PROG=ztest
 PROGO=ztest.o read-grs.o
 RANLIB=ranlib
 PROG=ztest
 PROGO=ztest.o read-grs.o
 RANLIB=ranlib
diff --git a/zutil/diagbib1.c b/zutil/diagbib1.c
new file mode 100644 (file)
index 0000000..ce0b831
--- /dev/null
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) 1995-1997, Index Data
+ * See the file LICENSE for details.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * $Log: diagbib1.c,v $
+ * Revision 1.1  1999-06-08 10:10:16  adam
+ * New sub directory zutil. Moved YAZ Compiler to be part of YAZ tree.
+ *
+ * Revision 1.7  1997/09/29 07:22:26  adam
+ * Added static modifier to msg_tab.
+ *
+ * Revision 1.6  1997/07/01 14:15:10  adam
+ * Added new BIB-1 diagnostic messages.
+ *
+ * Revision 1.5  1996/01/02 13:57:30  adam
+ * Added error messages.
+ *
+ * Revision 1.4  1995/09/29  17:11:52  quinn
+ * Smallish
+ *
+ * Revision 1.3  1995/09/27  15:02:39  quinn
+ * Modified function heads & prototypes.
+ *
+ * Revision 1.2  1995/05/16  08:50:21  quinn
+ * License, documentation, and memory fixes
+ *
+ * Revision 1.1  1995/03/15  13:46:09  adam
+ * New function diagbib1_str.
+ *
+ */
+
+#include <stdio.h>
+
+#include "diagbib1.h"
+
+static struct {
+    int code;
+    char *msg;
+} msg_tab[] = {
+{ 1, "Permanent system error" },
+{ 2, "Temporary system error" },
+{ 3, "Unsupported search" },
+{ 4, "Terms only exclusion (stop) words" },
+{ 5, "Too many argument words" },
+{ 6, "Too many boolean operators" },
+{ 7, "Too many truncated words" },
+{ 8, "Too many incomplete subfields" },
+{ 9, "Truncated words too short" },
+{ 10, "Invalid format for record number (search term)" },
+{ 11, "Too many characters in search statement" },
+{ 12, "Too many records retrieved" },
+{ 13, "Present request out of range" },
+{ 14, "System error in presenting records" },
+{ 15, "Record no authorized to be sent intersystem" },
+{ 16, "Record exceeds Preferred-message-size" },
+{ 17, "Record exceeds Maximum-record-size" },
+{ 18, "Result set not supported as a search term" },
+{ 19, "Only single result set as search term supported" },
+{ 20, "Only ANDing of a single result set as search term supported" },
+{ 21, "Result set exists and replace indicator off" },
+{ 22, "Result set naming not supported" },
+{ 23, "Combination of specified databases not supported" },
+{ 24, "Element set names not supported" },
+{ 25, "Specified element set name not valid for specified database" },
+{ 26, "Only a single element set name supported" },
+{ 27, "Result set no longer exists - unilaterally deleted by target" },
+{ 28, "Result set is in use" },
+{ 29, "One of the specified databases is locked" },
+{ 30, "Specified result set does not exist" },
+{ 31, "Resources exhausted - no results available" },
+{ 32, "Resources exhausted - unpredictable partial results available" },
+{ 33, "Resources exhausted - valid subset of results available" },
+{ 100, "Unspecified error" },
+{ 101, "Access-control failure" },
+{ 102, "Security challenge required but could not be issued -"
+" request terminated" },
+{ 103, "Security challenge required but could not be issued -"
+" record not included" },
+{ 104, "Security challenge failed - record not included" },
+{ 105, "Terminated by negative continue response" },
+{ 106, "No abstract syntaxes agreed to for this record" },
+{ 107, "Query type not supported" },
+{ 108, "Malformed query" },
+{ 109, "Database unavailable" },
+{ 110, "Operator unsupported" },
+{ 111, "Too many databases specified" },
+{ 112, "Too many result sets created" },
+{ 113, "Unsupported attribute type" },
+{ 114, "Unsupported Use attribute" },
+{ 115, "Unsupported value for Use attribute" },
+{ 116, "Use attribute required but not supplied" },
+{ 117, "Unsupported Relation attribute" },
+{ 118, "Unsupported Structure attribute" },
+{ 119, "Unsupported Position attribute" },
+{ 120, "Unsupported Truncation attribute" },
+{ 121, "Unsupported Attribute Set" },
+{ 122, "Unsupported Completeness attribute" },
+{ 123, "Unsupported attribute combination" },
+{ 124, "Unsupported coded value for term" },
+{ 125, "Malformed search term" },
+{ 126, "Illegal term value for attribute" },
+{ 127, "Unparsable format for un-normalized value" },
+{ 128, "Illegal result set name" },
+{ 129, "Proximity search of sets not supported" },
+{ 130, "Illegal result set in proximity search" },
+{ 131, "Unsupported proximity relation" },
+{ 132, "Unsupported proximity unit code" },
+{ 201, "Proximity not supported with this attribute combination" },
+{ 202, "Unsupported distance for proximity" },
+{ 203, "Ordered flag not supported for proximity" },
+{ 205, "Only zero step size supported for Scan" },
+{ 206, "Specified step size not supported for Scan" },
+{ 207, "Cannot sort according to sequence" },
+{ 208, "No result set name supplied on Sort" },
+{ 209, "Generic sort not supported (database-specific sort only supported)" },
+{ 210, "Database specific sort not supported" },
+{ 211, "Too many sort keys" },
+{ 212, "Duplicate sort keys" },
+{ 213, "Unsupported missing data action" },
+{ 214, "Illegal sort relation" },
+{ 215, "Illegal case value" },
+{ 216, "Illegal missing data action" },
+{ 217, "Segmentation: Cannot guarantee records will fit in specified segments"
+},
+{ 218, "ES: Package name already in use" },
+{ 219, "ES: no such package, on modify/delete" },
+{ 220, "ES: quota exceeded" },
+{ 221, "ES: extended service type not supported" },
+{ 222, "ES: permission denied on ES - id not authorized" },
+{ 223, "ES: permission denied on ES - cannot modify or delete" },
+{ 224, "ES: immediate execution failed" },
+{ 225, "ES: immediate execution not supported for this service" },
+{ 226, "ES: immediate execution not supported for these parameters" },
+{ 227, "No data available in requested record syntax" },
+{ 228, "Scan: malformed scan" },
+{ 229, "Term type not supported" },
+{ 230, "Sort: too many input results" },
+{ 231, "Sort: incompatible record formats" },
+{ 232, "Scan: term list not supported" },
+{ 233, "Scan: unsupported value of position-in-response" },
+{ 234, "Too many index terms processed" },
+{ 235, "Database does not exist" },
+{ 236, "Access to specified database denied" },
+{ 237, "Sort: illegal sort" },
+{ 238, "Record not available in requested syntax" },
+{ 239, "Record syntax not supported" },
+{ 240, "Scan: Resources exhausted looking for satisfying terms" },
+{ 241, "Scan: Beginning or end of term list" },
+{ 242, "Segmentation: max-segment-size too small to segment record" },
+{ 243, "Present:  additional-ranges parameter not supported" },
+{ 244, "Present:  comp-spec parameter not supported" },
+{ 245, "Type-1 query: restriction ('resultAttr') operand not supported" },
+{ 246, "Type-1 query: 'complex' attributeValue not supported" },
+{ 247, "Type-1 query: 'attributeSet' as part of AttributeElement not supported" },
+{ 1001, "Malformed APDU"}, 
+{ 1002, "ES: EXTERNAL form of Item Order request not supported" },
+{ 1003, "ES: Result set item form of Item Order request not supported" },
+{ 1004, "ES: Extended services not supported unless access control is in effect" },
+{ 1005, "Response records in Search response not supported" },
+{ 1006, "Response records in Search response not possible for specified database (or database combination)" },
+{ 1007, "No Explain server. Addinfo: pointers to servers that have a surrogate Explain database for this server" },
+{ 1008, "ES: missing mandatory parameter for specified function. Addinfo: parameter" },
+{ 1009, "ES: Item Order, unsupported OID in itemRequest. Addinfo: OID" },
+{ 1010, "Init/AC: Bad Userid" },
+{ 1011, "Init/AC: Bad Userid and/or Password" },
+{ 1012, "Init/AC: No searches remaining (pre-purchased searches exhausted)" },
+{ 1013, "Init/AC: Incorrect interface type (specified id valid only when used with a particular access method or client)" },
+{ 1014, "Init/AC: Authentication System error" },
+{ 1015, "Init/AC: Maximum number of simultaneous sessions for Userid" },
+{ 1016, "Init/AC: Blocked network address"},
+{ 1017, "Init/AC: No databases available for specified userId"},
+{ 1018, "Init/AC: System temporarily out of resources"},
+{ 1019, "Init/AC: System not available due to maintenance (Addinfo: when it's expected back up)" },
+{ 1020, "Init/AC: System temporarily unavailable (Addinfo: when it's expected back up)"},
+{ 1021, "Init/AC: Account has expired"},
+{ 1022, "Init/AC: Password has expired so a new one must be supplied"},
+{ 1023, "Init/AC: Password has been changed by an administrator so a new one must be supplied"},
+{ 0, NULL} 
+};
+
+const char *diagbib1_str (int code)
+{
+    int i;
+    for (i=0; msg_tab[i].msg; i++)
+        if (msg_tab[i].code == code)
+            return msg_tab[i].msg;
+    return "Unknown error";
+}
diff --git a/zutil/logrpn.c b/zutil/logrpn.c
new file mode 100644 (file)
index 0000000..a263cdf
--- /dev/null
@@ -0,0 +1,369 @@
+/*
+ * Copyright (C) 1995-1998, Index Data
+ * All rights reserved.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * $Log: logrpn.c,v $
+ * Revision 1.1  1999-06-08 10:10:16  adam
+ * New sub directory zutil. Moved YAZ Compiler to be part of YAZ tree.
+ *
+ * Revision 1.1  1998/11/16 16:02:35  adam
+ * Added loggin utilies, log_rpn_query and log_scan_term. These used
+ * to be part of Zebra.
+ *
+ *
+ *
+ * Old logs from zlogs.c:
+ *
+ * Revision 1.9  1998/10/13 20:36:02  adam
+ * Changed "indent" format string in log messages.
+ *
+ * Revision 1.8  1998/04/02 14:35:29  adam
+ * First version of Zebra that works with compiled ASN.1.
+ *
+ * Revision 1.7  1998/01/29 13:40:11  adam
+ * Better logging for scan service.
+ *
+ * Revision 1.6  1997/09/29 09:06:41  adam
+ * Removed static var to make this module thread safe.
+ *
+ * Revision 1.5  1997/04/30 08:56:07  quinn
+ * null
+ *
+ * Revision 1.4  1996/10/08  09:41:25  quinn
+ * Fixed diagnostic.
+ *
+ * Revision 1.3  1996/03/20  09:36:40  adam
+ * Function dict_lookup_grep got extra parameter, init_pos, which marks
+ * from which position in pattern approximate pattern matching should occur.
+ * Approximate pattern matching is used in relevance=re-2.
+ *
+ * Revision 1.2  1996/01/03  16:22:11  quinn
+ * operator->roperator
+ *
+ * Revision 1.1  1995/11/16  17:00:55  adam
+ * Better logging of rpn query.
+ *
+ */
+#include <stdio.h>
+#include <assert.h>
+
+#include <log.h>
+#include <logrpn.h>
+
+static void attrStr (int type, int value, enum oid_value ast, char *str)
+{
+    *str = '\0';
+    switch (ast)
+    {
+    case VAL_BIB1:
+    case VAL_EXP1:
+    case VAL_GILS:
+        switch (type)
+        {
+        case 1:
+            sprintf (str, "use");
+            break;
+        case 2:
+            switch (value)
+            {
+            case 1:
+                sprintf (str, "relation=Less than");
+                break;
+            case 2:
+                sprintf (str, "relation=Less than or equal");
+                break;
+            case 3:
+                sprintf (str, "relation=Equal");
+                break;
+            case 4:
+                sprintf (str, "relation=Greater or equal");
+                break;
+            case 5:
+                sprintf (str, "relation=Greater than");
+                break;
+            case 6:
+                sprintf (str, "relation=Not equal");
+                break;
+            case 100:
+                sprintf (str, "relation=Phonetic");
+                break;
+            case 101:
+                sprintf (str, "relation=Stem");
+                break;
+            case 102:
+                sprintf (str, "relation=Relevance");
+                break;
+            case 103:
+                sprintf (str, "relation=AlwaysMatches");
+                break;
+            default:
+                sprintf (str, "relation");
+            }
+            break;
+        case 3:
+            switch (value)
+            {
+            case 1:
+                sprintf (str, "position=First in field");
+                break;
+            case 2:
+                sprintf (str, "position=First in any subfield");
+                break;
+            case 3:
+                sprintf (str, "position=Any position in field");
+                break;
+            default:
+                sprintf (str, "position");
+            }
+            break;
+        case 4:
+            switch (value)
+            {
+            case 1:
+                sprintf (str, "structure=Phrase");
+                break;
+            case 2:
+                sprintf (str, "structure=Word");
+                break;
+            case 3:
+                sprintf (str, "structure=Key");
+                break;
+            case 4:
+                sprintf (str, "structure=Year");
+                break;
+            case 5:
+                sprintf (str, "structure=Date");
+                break;
+            case 6:
+                sprintf (str, "structure=Word list");
+                break;
+            case 100:
+                sprintf (str, "structure=Date (un)");
+                break;
+            case 101:
+                sprintf (str, "structure=Name (norm)");
+                break;
+            case 102:
+                sprintf (str, "structure=Name (un)");
+                break;
+            case 103:
+                sprintf (str, "structure=Structure");
+                break;
+            case 104:
+                sprintf (str, "structure=urx");
+                break;
+            case 105:
+                sprintf (str, "structure=free-form-text");
+                break;
+            case 106:
+                sprintf (str, "structure=document-text");
+                break;
+            case 107:
+                sprintf (str, "structure=local-number");
+                break;
+            case 108:
+                sprintf (str, "structure=string");
+                break;
+            case 109:
+                sprintf (str, "structure=numeric string");
+                break;
+            default:
+                sprintf (str, "structure");
+            }
+            break;
+        case 5:
+            switch (value)
+            {
+            case 1:
+                sprintf (str, "truncation=Right");
+                break;
+            case 2:
+                sprintf (str, "truncation=Left");
+                break;
+            case 3:
+                sprintf (str, "truncation=Left&right");
+                break;
+            case 100:
+                sprintf (str, "truncation=Do not truncate");
+                break;
+            case 101:
+                sprintf (str, "truncation=Process #");
+                break;
+            case 102:
+                sprintf (str, "truncation=re-1");
+                break;
+            case 103:
+                sprintf (str, "truncation=re-2");
+                break;
+            default:
+                sprintf (str, "truncation");
+            }
+            break;
+        case 6:
+            switch (value)
+            {
+            case 1:
+                sprintf (str, "completeness=Incomplete subfield");
+                break;
+            case 2:
+                sprintf (str, "completeness=Complete subfield");
+                break;
+            case 3:
+                sprintf (str, "completeness=Complete field");
+                break;
+            default:
+                sprintf (str, "completeness");
+            }
+            break;
+        }
+        break;
+    default:
+        break;
+    }
+    if (*str)
+        sprintf (str + strlen(str), " (%d=%d)", type, value);
+    else
+        sprintf (str, "%d=%d", type, value);
+}
+
+/*
+ * zlog_attributes: print attributes of term
+ */
+static void zlog_attributes (Z_AttributesPlusTerm *t, int level,
+                             enum oid_value ast)
+{
+    int of, i;
+    char str[80];
+#ifdef ASN_COMPILED
+    int num_attributes = t->attributes->num_attributes;
+#else
+    int num_attributes = t->num_attributes;
+#endif
+    
+    for (of = 0; of < num_attributes; of++)
+    {
+       const char *attset_name = "";
+        Z_AttributeElement *element;
+#ifdef ASN_COMPILED
+       element = t->attributes->attributes[of];
+#else
+        element = t->attributeList[of];
+#endif
+       if (element->attributeSet)
+       {
+           oident *attrset;
+           attrset = oid_getentbyoid (element->attributeSet);
+           attset_name = attrset->desc;
+       }
+        switch (element->which) 
+        {
+        case Z_AttributeValue_numeric:
+           attrStr (*element->attributeType,
+                    *element->value.numeric, ast, str);
+            logf (LOG_LOG, "%*.0s%s %s", level, "", attset_name, str);
+            break;
+        case Z_AttributeValue_complex:
+            logf (LOG_LOG, "%*.0s%s attributeType=%d complex",
+                 level, "", attset_name, *element->attributeType);
+            for (i = 0; i<element->value.complex->num_list; i++)
+            {
+                if (element->value.complex->list[i]->which ==
+                    Z_StringOrNumeric_string)
+                    logf (LOG_LOG, "%*.0s  string: '%s'", level, "",
+                          element->value.complex->list[i]->u.string);
+                else if (element->value.complex->list[i]->which ==
+                         Z_StringOrNumeric_numeric)
+                    logf (LOG_LOG, "%*.0s  numeric: '%d'", level, "",
+                          *element->value.complex->list[i]->u.numeric);
+            }
+            break;
+        default:
+            logf (LOG_LOG, "%.*s%s attribute unknown",
+                 level, "", attset_name);
+        }
+    }
+}
+
+static void zlog_structure (Z_RPNStructure *zs, int level, enum oid_value ast)
+{
+    if (zs->which == Z_RPNStructure_complex)
+    {
+        switch (zs->u.complex->roperator->which)
+        {
+        case Z_Operator_and:
+            logf (LOG_LOG, "%*.0s and", level, "");
+            break;
+        case Z_Operator_or:
+            logf (LOG_LOG, "%*.0s or", level, "");
+            break;
+        case Z_Operator_and_not:
+            logf (LOG_LOG, "%*.0s and-not", level, "");
+            break;
+        default:
+            logf (LOG_LOG, "%*.0s unknown complex", level, "");
+            return;
+        }
+        zlog_structure (zs->u.complex->s1, level+2, ast);
+        zlog_structure (zs->u.complex->s2, level+2, ast);
+    }
+    else if (zs->which == Z_RPNStructure_simple)
+    {
+        if (zs->u.simple->which == Z_Operand_APT)
+        {
+            Z_AttributesPlusTerm *zapt = zs->u.simple->u.attributesPlusTerm;
+
+            if (zapt->term->which == Z_Term_general) 
+            {
+                logf (LOG_LOG, "%*.0s term '%.*s' (general)", level, "",
+                      zapt->term->u.general->len, zapt->term->u.general->buf);
+            }
+            else
+            {
+                logf (LOG_LOG, "%*.0s term (not general)", level, "");
+            }
+            zlog_attributes (zapt, level+2, ast);
+        }
+        else if (zs->u.simple->which == Z_Operand_resultSetId)
+        {
+            logf (LOG_LOG, "%*.0s set '%s'", level, "",
+                  zs->u.simple->u.resultSetId);
+        }
+        else
+            logf (LOG_LOG, "%*.0s unknown simple structure", level, "");
+    }
+    else
+        logf (LOG_LOG, "%*.0s unknown structure", level, "");
+}
+
+void log_rpn_query (Z_RPNQuery *rpn)
+{
+    oident *attrset;
+    enum oid_value ast;
+    
+    attrset = oid_getentbyoid (rpn->attributeSetId);
+    if (attrset)
+    {
+        ast = attrset->value;
+       logf (LOG_LOG, "RPN query. Type: %s", attrset->desc);
+    } 
+    else
+    {
+       ast = VAL_NONE;
+       logf (LOG_LOG, "RPN query. Unknown type");
+    }
+    zlog_structure (rpn->RPNStructure, 0, ast);
+}
+
+void log_scan_term (Z_AttributesPlusTerm *zapt, oid_value ast)
+{
+    int level = 0;
+    if (zapt->term->which == Z_Term_general) 
+    {
+       logf (LOG_LOG, "%*.0s term '%.*s' (general)", level, "",
+             zapt->term->u.general->len, zapt->term->u.general->buf);
+    }
+    else
+       logf (LOG_LOG, "%*.0s term (not general)", level, "");
+    zlog_attributes (zapt, level+2, ast);
+}
diff --git a/zutil/otherinfo.c b/zutil/otherinfo.c
new file mode 100644 (file)
index 0000000..29aa036
--- /dev/null
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 1999, Index Data
+ * See the file LICENSE for details.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * $Log: otherinfo.c,v $
+ * Revision 1.1  1999-06-08 10:10:16  adam
+ * New sub directory zutil. Moved YAZ Compiler to be part of YAZ tree.
+ *
+ * Revision 1.1  1999/04/26 07:25:25  adam
+ * Implemented OtherInfo utility.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include <otherinfo.h>
+
+void yaz_oi_APDU(Z_APDU *apdu, Z_OtherInformation ***oip)
+{
+    switch (apdu->which)
+    {
+    case Z_APDU_initRequest:
+       *oip = &apdu->u.initRequest->otherInfo;
+       break;
+    case Z_APDU_searchRequest:
+       *oip = &apdu->u.searchRequest->otherInfo;
+       break;
+    case Z_APDU_presentRequest:
+       *oip = &apdu->u.presentRequest->otherInfo;
+       break;
+    case Z_APDU_sortRequest:
+       *oip = &apdu->u.sortRequest->otherInfo;
+       break;
+    case Z_APDU_scanRequest:
+       *oip = &apdu->u.scanRequest->otherInfo;
+       break;
+    case Z_APDU_initResponse:
+       *oip = &apdu->u.initResponse->otherInfo;
+       break;
+    case Z_APDU_searchResponse:
+       *oip = &apdu->u.searchResponse->otherInfo;
+       break;
+    case Z_APDU_presentResponse:
+       *oip = &apdu->u.presentResponse->otherInfo;
+       break;
+    case Z_APDU_sortResponse:
+       *oip = &apdu->u.sortResponse->otherInfo;
+       break;
+    case Z_APDU_scanResponse:
+       *oip = &apdu->u.scanResponse->otherInfo;
+       break;
+    default:
+       *oip = 0;
+       break;
+    }
+}
+
+Z_OtherInformationUnit *yaz_oi_update (
+    Z_OtherInformation **otherInformationP, ODR odr,
+    int *oid, int categoryValue)
+{
+    int i;
+    Z_OtherInformation *otherInformation = *otherInformationP;
+    if (!otherInformation)
+    {
+       if (!odr)
+           return 0;
+       otherInformation = *otherInformationP = (Z_OtherInformation *)
+           odr_malloc (odr, sizeof(*otherInformation));
+       otherInformation->num_elements = 0;
+       otherInformation->list = 0;
+    }
+    for (i = 0; i<otherInformation->num_elements; i++)
+    {
+       if (!oid)
+       {
+           if (!otherInformation->list[i]->category)
+               return otherInformation->list[i];
+       }
+       else
+       {
+           if (otherInformation->list[i]->category &&
+               categoryValue ==
+               *otherInformation->list[i]->category->categoryValue &&
+               !oid_oidcmp (oid, otherInformation->list[i]->category->
+                            categoryTypeId))
+               return otherInformation->list[i];
+       }
+    }
+    if (!odr)
+       return 0;
+    else
+    {
+       Z_OtherInformationUnit **newlist = (Z_OtherInformationUnit**)
+           odr_malloc(odr, otherInformation->num_elements+1 *
+                      sizeof(*newlist));
+       for (i = 0; i<otherInformation->num_elements; i++)
+           newlist[i] = otherInformation->list[i];
+       otherInformation->list = newlist;
+       
+       otherInformation->list[i] = (Z_OtherInformationUnit*)
+           odr_malloc (odr, sizeof(Z_OtherInformationUnit));
+       if (oid)
+       {
+           otherInformation->list[i]->category = (Z_InfoCategory*)
+               odr_malloc (odr, sizeof(Z_InfoCategory));
+           otherInformation->list[i]->category->categoryTypeId = (int*)
+               odr_oiddup (odr, oid);
+           otherInformation->list[i]->category->categoryValue = (int*)
+               odr_malloc (odr, sizeof(int));
+           *otherInformation->list[i]->category->categoryValue =
+               categoryValue;
+       }
+       else
+           otherInformation->list[i]->category = 0;
+       otherInformation->list[i]->which = Z_OtherInfo_characterInfo;
+       otherInformation->list[i]->information.characterInfo = 0;
+       
+       otherInformation->num_elements = i+1;
+       return otherInformation->list[i];
+    }
+}
+
+void yaz_oi_set_string_oid (
+    Z_OtherInformation **otherInformation, ODR odr,
+    int *oid, int categoryValue,
+    const char *str)
+{
+    Z_OtherInformationUnit *oi =
+       yaz_oi_update(otherInformation, odr, oid, categoryValue);
+    if (!oi)
+       return;
+    oi->which = Z_OtherInfo_characterInfo;
+    oi->information.characterInfo = odr_strdup (odr, str);
+}
+
+void yaz_oi_set_string_oidval (
+    Z_OtherInformation **otherInformation, ODR odr,
+    int oidval, int categoryValue,
+    const char *str)
+{
+    int oid[OID_SIZE];
+    struct oident ent;
+    ent.proto = PROTO_Z3950;
+    ent.oclass = CLASS_USERINFO;
+    ent.value = (oid_value) oidval;
+    if (!oid_ent_to_oid (&ent, oid))
+       return ;
+    yaz_oi_set_string_oid(otherInformation,
+                         odr, oid, categoryValue, str);
+}
+
+char *yaz_oi_get_string_oid (
+    Z_OtherInformation **otherInformation,
+    int *oid, int categoryValue)
+{
+    Z_OtherInformationUnit *oi;
+    
+    if ((oi = yaz_oi_update(otherInformation, 0, oid, 1)) &&
+       oi->which == Z_OtherInfo_characterInfo)
+       return oi->information.characterInfo;
+    return 0;
+}
+
+char *yaz_oi_get_string_oidval(Z_OtherInformation **otherInformation,
+                               int oidval, int categoryValue)    
+{
+    int oid[OID_SIZE];
+    struct oident ent;
+    ent.proto = PROTO_Z3950;
+    ent.oclass = CLASS_USERINFO;
+    ent.value = (oid_value) oidval;
+
+    if (!oid_ent_to_oid (&ent, oid))
+       return 0;
+    return yaz_oi_get_string_oid (otherInformation, oid, categoryValue);
+}
+
diff --git a/zutil/pquery.c b/zutil/pquery.c
new file mode 100644 (file)
index 0000000..a302244
--- /dev/null
@@ -0,0 +1,617 @@
+/*
+ * Copyright (c) 1995-1998, Index Data.
+ * See the file LICENSE for details.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * $Log: pquery.c,v $
+ * Revision 1.1  1999-06-08 10:10:16  adam
+ * New sub directory zutil. Moved YAZ Compiler to be part of YAZ tree.
+ *
+ * Revision 1.22  1999/04/20 09:56:49  adam
+ * Added 'name' paramter to encoder/decoder routines (typedef Odr_fun).
+ * Modified all encoders/decoders to reflect this change.
+ *
+ * Revision 1.21  1998/10/13 16:03:37  adam
+ * Better checking for invalid OID's in p_query_rpn.
+ *
+ * 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
+ * Changed code so that it compiles as C++.
+ *
+ * Revision 1.17  1997/11/24 11:33:57  adam
+ * Using function odr_nullval() instead of global ODR_NULLVAL when
+ * appropriate.
+ *
+ * Revision 1.16  1997/09/29 13:19:00  adam
+ * Added function, oid_ent_to_oid, to replace the function
+ * oid_getoidbyent, which is not thread safe.
+ *
+ * Revision 1.15  1997/09/29 07:13:43  adam
+ * Changed type of a few variables to avoid warnings.
+ *
+ * Revision 1.14  1997/09/22 12:33:41  adam
+ * Fixed bug introduced by previous commit.
+ *
+ * Revision 1.13  1997/09/17 12:10:42  adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.12  1997/09/01 08:54:13  adam
+ * New windows NT/95 port using MSV5.0. Made prefix query handling
+ * thread safe. The function options ignores empty arguments when met.
+ *
+ * Revision 1.11  1996/11/11 13:15:29  adam
+ * Added proximity operator.
+ *
+ * Revision 1.10  1996/08/12 14:10:35  adam
+ * New function p_query_attset to define default attribute set.
+ *
+ * Revision 1.9  1996/03/15  11:03:46  adam
+ * Attribute set can be set globally for a query with the @attrset
+ * operator. The @attr operator has an optional attribute-set specifier
+ * that sets the attribute set locally.
+ *
+ * Revision 1.8  1996/01/02  11:46:56  quinn
+ * Changed 'operator' to 'roperator' to avoid C++ conflict.
+ *
+ * Revision 1.7  1995/09/29  17:12:36  quinn
+ * Smallish
+ *
+ * Revision 1.6  1995/09/27  15:03:03  quinn
+ * Modified function heads & prototypes.
+ *
+ * Revision 1.5  1995/06/15  12:31:02  quinn
+ * *** empty log message ***
+ *
+ * Revision 1.4  1995/06/15  07:45:19  quinn
+ * Moving to v3.
+ *
+ * Revision 1.3  1995/06/14  11:06:35  adam
+ * Bug fix: Attributes wasn't interpreted correctly!
+ *
+ * Revision 1.2  1995/05/26  08:56:11  adam
+ * New function: p_query_scan.
+ *
+ * Revision 1.1  1995/05/22  15:31:49  adam
+ * New function, p_query_rpn, to convert from prefix (ascii) to rpn (asn).
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <proto.h>
+#include <oid.h>
+
+#include <pquery.h>
+
+static oid_value p_query_dfset = VAL_NONE;
+
+struct lex_info {
+    const char *query_buf;
+    const char *lex_buf;
+    size_t lex_len;
+    int query_look;
+    char *left_sep;
+    char *right_sep;
+    int escape_char;
+    int term_type;
+};
+
+static Z_RPNStructure *rpn_structure (struct lex_info *li, ODR o, oid_proto, 
+                                      int num_attr, int max_attr, 
+                                      int *attr_list, oid_value *attr_set);
+
+static enum oid_value query_oid_getvalbyname (struct lex_info *li)
+{
+    enum oid_value value;
+    char buf[32];
+
+    if (li->lex_len > 31)
+        return VAL_NONE;
+    memcpy (buf, li->lex_buf, li->lex_len);
+    buf[li->lex_len] = '\0';
+    value = oid_getvalbyname (buf);
+    return value;
+}
+
+static int compare_term (struct lex_info *li, const char *src, size_t off)
+{
+    size_t len=strlen(src);
+
+    if (li->lex_len == len+off && !memcmp (li->lex_buf+off, src, len-off))
+       return 1;
+    return 0;
+}
+
+static int query_token (struct lex_info *li)
+{
+    const char *sep_match;
+    const char **qptr = &li->query_buf;
+
+    while (**qptr == ' ')
+        (*qptr)++;
+    if (**qptr == '\0')
+        return 0;
+    li->lex_len = 0;
+    if ((sep_match = strchr (li->left_sep, **qptr)))
+    {
+        int sep_index = sep_match - li->left_sep;
+        
+        ++(*qptr);
+        li->lex_buf = *qptr;
+        while (**qptr && **qptr != li->right_sep[sep_index])
+        {
+            ++(li->lex_len);
+            ++(*qptr);
+        }
+        if (**qptr)
+            ++(*qptr);
+    }
+    else
+    {
+        li->lex_buf = *qptr;
+        while (**qptr && **qptr != ' ')
+        {
+            ++(li->lex_len);
+            ++(*qptr);
+        }
+    }
+    if (li->lex_len >= 1 && li->lex_buf[0] == li->escape_char)
+    {
+       if (compare_term (li, "and", 1))
+           return 'a';
+        if (compare_term (li, "or", 1))
+            return 'o';
+        if (compare_term (li, "not", 1))
+            return 'n';
+        if (compare_term (li, "attr", 1))
+            return 'l';
+        if (compare_term (li, "set", 1))
+            return 's';
+        if (compare_term (li, "attrset", 1))
+            return 'r';
+        if (compare_term (li, "prox", 1))
+            return 'p';
+        if (compare_term (li, "term", 1))
+            return 'y';
+    }
+    return 't';
+}
+
+static int lex (struct lex_info *li)
+{
+    return li->query_look = query_token (li);
+}
+
+static Z_AttributesPlusTerm *rpn_term (struct lex_info *li, ODR o,
+                                       oid_proto proto, 
+                                       int num_attr, int *attr_list,
+                                       oid_value *attr_set)
+{
+    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));
+
+    if (!num_attr)
+        elements = (Z_AttributeElement**)odr_nullval();
+    else
+    {
+        int i;
+        int *attr_tmp;
+
+        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++)
+        {
+            elements[i] =
+                (Z_AttributeElement*)odr_malloc (o,sizeof(**elements));
+            elements[i]->attributeType = &attr_tmp[2*i];
+            if (attr_set[i] == VAL_NONE)
+                elements[i]->attributeSet = 0;
+            else
+            {
+                oident attrid;
+                int oid[OID_SIZE];
+               
+                attrid.proto = PROTO_Z3950;
+                attrid.oclass = CLASS_ATTSET;
+                attrid.value = attr_set[i];
+                   
+                elements[i]->attributeSet =
+                   odr_oiddup (o, oid_ent_to_oid (&attrid, oid));
+            }
+           elements[i]->which = Z_AttributeValue_numeric;
+           elements[i]->value.numeric = &attr_tmp[2*i+1];
+        }
+    }
+#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;
+    term_octet->buf = (unsigned char *)odr_malloc (o, li->lex_len);
+    term_octet->size = term_octet->len = li->lex_len;
+    memcpy (term_octet->buf, li->lex_buf, li->lex_len);
+    return zapt;
+}
+
+static Z_Operand *rpn_simple (struct lex_info *li, ODR o, oid_proto proto,
+                              int num_attr, int *attr_list,
+                              oid_value *attr_set)
+{
+    Z_Operand *zo;
+
+    zo = (Z_Operand *)odr_malloc (o, sizeof(*zo));
+    switch (li->query_look)
+    {
+    case 't':
+        zo->which = Z_Operand_APT;
+        if (!(zo->u.attributesPlusTerm =
+              rpn_term (li, o, proto, num_attr, attr_list, attr_set)))
+            return NULL;
+        lex (li);
+        break;
+    case 's':
+        lex (li);
+        if (!li->query_look)
+            return NULL;
+        zo->which = Z_Operand_resultSetId;
+        zo->u.resultSetId = (char *)odr_malloc (o, li->lex_len+1);
+        memcpy (zo->u.resultSetId, li->lex_buf, li->lex_len);
+        zo->u.resultSetId[li->lex_len] = '\0';
+        lex (li);
+        break;
+    default:
+        return NULL;
+    }
+    return zo;
+}
+
+static Z_ProximityOperator *rpn_proximity (struct lex_info *li, ODR o)
+{
+    Z_ProximityOperator *p = (Z_ProximityOperator *)odr_malloc (o, sizeof(*p));
+
+    if (!lex (li))
+        return NULL;
+    if (*li->lex_buf == '1')
+    {
+        p->exclusion = (int *)odr_malloc (o, sizeof(*p->exclusion));
+        *p->exclusion = 1;
+    } 
+    else if (*li->lex_buf == '0')
+    {
+        p->exclusion = (int *)odr_malloc (o, sizeof(*p->exclusion));
+        *p->exclusion = 0;
+    }
+    else
+        p->exclusion = NULL;
+
+    if (!lex (li))
+        return NULL;
+    p->distance = (int *)odr_malloc (o, sizeof(*p->distance));
+    *p->distance = atoi (li->lex_buf);
+
+    if (!lex (li))
+        return NULL;
+    p->ordered = (int *)odr_malloc (o, sizeof(*p->ordered));
+    *p->ordered = atoi (li->lex_buf);
+    
+    if (!lex (li))
+        return NULL;
+    p->relationType = (int *)odr_malloc (o, sizeof(*p->relationType));
+    *p->relationType = atoi (li->lex_buf);
+
+    if (!lex (li))
+        return NULL;
+    if (*li->lex_buf == 'k')
+        p->which = 0;
+    else if (*li->lex_buf == 'p')
+        p->which = 1;
+    else
+        p->which = atoi (li->lex_buf);
+
+    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;
+}
+
+static Z_Complex *rpn_complex (struct lex_info *li, ODR o, oid_proto proto,
+                               int num_attr, int max_attr, 
+                               int *attr_list, oid_value *attr_set)
+{
+    Z_Complex *zc;
+    Z_Operator *zo;
+
+    zc = (Z_Complex *)odr_malloc (o, sizeof(*zc));
+    zo = (Z_Operator *)odr_malloc (o, sizeof(*zo));
+    zc->roperator = zo;
+    switch (li->query_look)
+    {
+    case 'a':
+        zo->which = Z_Operator_and;
+        zo->u.and = odr_nullval();
+        break;
+    case 'o':
+        zo->which = Z_Operator_or;
+        zo->u.and = odr_nullval();
+        break;
+    case 'n':
+        zo->which = Z_Operator_and_not;
+        zo->u.and = odr_nullval();
+        break;
+    case 'p':
+        zo->which = Z_Operator_prox;
+        zo->u.prox = rpn_proximity (li, o);
+        if (!zo->u.prox)
+            return NULL;
+        break;
+    default:
+        return NULL;
+    }
+    lex (li);
+    if (!(zc->s1 =
+          rpn_structure (li, o, proto, num_attr, max_attr, attr_list,
+                         attr_set)))
+        return NULL;
+    if (!(zc->s2 =
+          rpn_structure (li, o, proto, num_attr, max_attr, attr_list,
+                         attr_set)))
+        return NULL;
+    return zc;
+}
+
+static Z_RPNStructure *rpn_structure (struct lex_info *li, ODR o,
+                                      oid_proto proto, 
+                                      int num_attr, int max_attr, 
+                                      int *attr_list, oid_value *attr_set)
+{
+    Z_RPNStructure *sz;
+    const char *cp;
+
+    sz = (Z_RPNStructure *)odr_malloc (o, sizeof(*sz));
+    switch (li->query_look)
+    {
+    case 'a':
+    case 'o':
+    case 'n':
+    case 'p':
+        sz->which = Z_RPNStructure_complex;
+        if (!(sz->u.complex =
+              rpn_complex (li, o, proto, num_attr, max_attr, attr_list,
+                           attr_set)))
+            return NULL;
+        break;
+    case 't':
+    case 's':
+        sz->which = Z_RPNStructure_simple;
+        if (!(sz->u.simple =
+              rpn_simple (li, o, proto, num_attr, attr_list,
+                          attr_set)))
+            return NULL;
+        break;
+    case 'l':
+        lex (li);
+        if (!li->query_look)
+            return NULL;
+        if (num_attr >= max_attr)
+            return NULL;
+        if (!(cp = strchr (li->lex_buf, '=')) ||
+            (size_t) (cp-li->lex_buf) > li->lex_len)
+        {
+            attr_set[num_attr] = query_oid_getvalbyname (li);
+           if (attr_set[num_attr] == VAL_NONE)
+               return NULL;
+            lex (li);
+
+            if (!(cp = strchr (li->lex_buf, '=')))
+                return NULL;
+        }
+        else 
+        {
+            if (num_attr > 0)
+                attr_set[num_attr] = attr_set[num_attr-1];
+            else
+                attr_set[num_attr] = VAL_NONE;
+        }
+        attr_list[2*num_attr] = atoi (li->lex_buf);
+        attr_list[2*num_attr+1] = atoi (cp+1);
+        num_attr++;
+        lex (li);
+        return
+            rpn_structure (li, o, proto, num_attr, max_attr, attr_list,
+                           attr_set);
+    case 'y':
+       lex (li);
+       if (!li->query_look)
+           return NULL;
+       if (compare_term (li, "general", 0))
+           li->term_type = Z_Term_general;
+       else if (compare_term (li, "numeric", 0))
+           li->term_type = Z_Term_numeric;
+       else if (compare_term (li, "string", 0))
+           li->term_type = Z_Term_characterString;
+       else if (compare_term (li, "oid", 0))
+           li->term_type = Z_Term_oid;
+       else if (compare_term (li, "datetime", 0))
+           li->term_type = Z_Term_dateTime;
+       else if (compare_term (li, "null", 0))
+           li->term_type = Z_Term_null;
+       lex (li);
+        return
+            rpn_structure (li, o, proto, num_attr, max_attr, attr_list,
+                           attr_set);
+    case 0:                /* operator/operand expected! */
+        return NULL;
+    }
+    return sz;
+}
+
+Z_RPNQuery *p_query_rpn_mk (ODR o, struct lex_info *li, oid_proto proto,
+                            const char *qbuf)
+{
+    Z_RPNQuery *zq;
+    int attr_array[1024];
+    oid_value attr_set[512];
+    oid_value topSet = VAL_NONE;
+    oident oset;
+    int oid[OID_SIZE];
+
+    zq = (Z_RPNQuery *)odr_malloc (o, sizeof(*zq));
+    lex (li);
+    if (li->query_look == 'r')
+    {
+        lex (li);
+        topSet = query_oid_getvalbyname (li);
+        if (topSet == VAL_NONE)
+            return NULL;
+
+        lex (li);
+    }
+    if (topSet == VAL_NONE)
+        topSet = p_query_dfset;
+    if (topSet == VAL_NONE)
+        topSet = VAL_BIB1;
+    oset.proto = proto;
+    oset.oclass = CLASS_ATTSET;
+    oset.value = topSet;
+
+    if (!oid_ent_to_oid (&oset, oid))
+       return NULL;
+    zq->attributeSetId = odr_oiddup (o, oid);
+
+    if (!(zq->RPNStructure = rpn_structure (li, o, proto, 0, 512,
+                                            attr_array, attr_set)))
+        return NULL;
+    return zq;
+}
+
+Z_RPNQuery *p_query_rpn (ODR o, oid_proto proto,
+                         const char *qbuf)
+{
+    struct lex_info li;
+    
+    li.left_sep = "{\"";
+    li.right_sep = "}\"";
+    li.escape_char = '@';
+    li.term_type = Z_Term_general;
+    li.query_buf = qbuf;
+    return p_query_rpn_mk (o, &li, proto, qbuf);
+}
+
+Z_AttributesPlusTerm *p_query_scan_mk (struct lex_info *li,
+                                       ODR o, oid_proto proto,
+                                       Odr_oid **attributeSetP,
+                                       const char *qbuf)
+{
+    int attr_list[1024];
+    oid_value attr_set[512];
+    int num_attr = 0;
+    int max_attr = 512;
+    const char *cp;
+    oid_value topSet = VAL_NONE;
+    oident oset;
+    int oid[OID_SIZE];
+
+    lex (li);
+    if (li->query_look == 'r')
+    {
+        lex (li);
+        topSet = query_oid_getvalbyname (li);
+
+        lex (li);
+    }
+    if (topSet == VAL_NONE)
+        topSet = p_query_dfset;
+    if (topSet == VAL_NONE)
+        topSet = VAL_BIB1;
+    oset.proto = proto;
+    oset.oclass = CLASS_ATTSET;
+    oset.value = topSet;
+
+    *attributeSetP = odr_oiddup (o, oid_ent_to_oid (&oset, oid));
+
+    while (li->query_look == 'l')
+    {
+        lex (li);
+        if (!li->query_look)
+            return NULL;
+        if (num_attr >= max_attr)
+            return NULL;
+
+        if (!(cp = strchr (li->lex_buf, '=')) ||
+            (size_t) (cp-li->lex_buf) > li->lex_len)
+        {
+            attr_set[num_attr] = query_oid_getvalbyname (li);
+            lex (li);
+
+            if (!(cp = strchr (li->lex_buf, '=')))
+                return NULL;
+        }
+        else
+        {
+            if (num_attr > 0)
+                attr_set[num_attr] = attr_set[num_attr-1];
+            else
+                attr_set[num_attr] = VAL_NONE;
+        }
+        attr_list[2*num_attr] = atoi (li->lex_buf);
+        attr_list[2*num_attr+1] = atoi (cp+1);
+        num_attr++;
+        lex (li);
+    }
+    if (!li->query_look)
+        return NULL;
+    return rpn_term (li, o, proto, num_attr, attr_list, attr_set);
+}
+
+Z_AttributesPlusTerm *p_query_scan (ODR o, oid_proto proto,
+                                    Odr_oid **attributeSetP,
+                                    const char *qbuf)
+{
+    struct lex_info li;
+
+    li.left_sep = "{\"";
+    li.right_sep = "}\"";
+    li.escape_char = '@';
+    li.term_type = Z_Term_general;
+    li.query_buf = qbuf;
+
+    return p_query_scan_mk (&li, o, proto, attributeSetP, qbuf);
+}
+
+int p_query_attset (const char *arg)
+{
+    p_query_dfset = oid_getvalbyname (arg);
+    return (p_query_dfset == VAL_NONE) ? -1 : 0;
+}
+
diff --git a/zutil/prt-ext.c b/zutil/prt-ext.c
new file mode 100644 (file)
index 0000000..0c30124
--- /dev/null
@@ -0,0 +1,278 @@
+/*
+ * Copyright (c) 1995-1999, Index Data.
+ * See the file LICENSE for details.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * $Log: prt-ext.c,v $
+ * Revision 1.1  1999-06-08 10:10:16  adam
+ * New sub directory zutil. Moved YAZ Compiler to be part of YAZ tree.
+ *
+ * Revision 1.22  1999/05/26 15:24:26  adam
+ * Fixed minor bugs regarding DB Update (introduced by previous commit).
+ *
+ * Revision 1.21  1999/05/26 14:47:12  adam
+ * Implemented z_ext_record.
+ *
+ * Revision 1.20  1999/04/20 09:56:48  adam
+ * Added 'name' paramter to encoder/decoder routines (typedef Odr_fun).
+ * Modified all encoders/decoders to reflect this change.
+ *
+ * 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.
+ *
+ * Revision 1.17  1998/03/20 14:46:06  adam
+ * Added UNIverse Resource Reports.
+ *
+ * Revision 1.16  1998/02/11 11:53:32  adam
+ * Changed code so that it compiles as C++.
+ *
+ * Revision 1.15  1998/02/10 15:31:46  adam
+ * Implemented date and time structure. Changed the Update Extended
+ * Service.
+ *
+ * Revision 1.14  1998/01/05 09:04:57  adam
+ * Fixed bugs in encoders/decoders - Not operator (!) missing.
+ *
+ * Revision 1.13  1997/05/14 06:53:22  adam
+ * C++ support.
+ *
+ * Revision 1.12  1997/04/30 08:52:02  quinn
+ * Null
+ *
+ * Revision 1.11  1996/10/10  12:35:13  quinn
+ * Added Update extended service.
+ *
+ * Revision 1.10  1996/10/09  15:54:55  quinn
+ * Added SearchInfoReport
+ *
+ * Revision 1.9  1996/06/10  08:53:36  quinn
+ * Added Summary,OPAC,ResourceReport
+ *
+ * Revision 1.8  1996/02/20  12:51:44  quinn
+ * Completed SCAN. Fixed problems with EXTERNAL.
+ *
+ * Revision 1.7  1995/10/12  10:34:38  quinn
+ * Added Espec-1.
+ *
+ * Revision 1.6  1995/09/29  17:11:55  quinn
+ * Smallish
+ *
+ * Revision 1.5  1995/09/27  15:02:42  quinn
+ * Modified function heads & prototypes.
+ *
+ * Revision 1.4  1995/08/29  11:17:16  quinn
+ * *** empty log message ***
+ *
+ * Revision 1.3  1995/08/21  09:10:18  quinn
+ * Smallish fixes to suppport new formats.
+ *
+ * Revision 1.2  1995/08/17  12:45:00  quinn
+ * Fixed minor problems with GRS-1. Added support in c&s.
+ *
+ * Revision 1.1  1995/08/15  13:37:41  quinn
+ * Improved EXTERNAL
+ *
+ *
+ */
+
+#include <proto.h>
+
+/*
+ * The table below should be moved to the ODR structure itself and
+ * be an image of the association context: To help
+ * map indirect references when they show up. 
+ */
+static Z_ext_typeent type_table[] =
+{
+    {VAL_SUTRS, Z_External_sutrs, (Odr_fun) z_SUTRS},
+    {VAL_EXPLAIN, Z_External_explainRecord, (Odr_fun)z_ExplainRecord},
+    {VAL_RESOURCE1, Z_External_resourceReport1, (Odr_fun)z_ResourceReport1},
+    {VAL_RESOURCE2, Z_External_resourceReport2, (Odr_fun)z_ResourceReport2},
+    {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},
+    {VAL_OPAC, Z_External_OPAC, (Odr_fun)z_OPACRecord},
+    {VAL_SEARCHRES1, Z_External_searchResult1, (Odr_fun)z_SearchInfoReport},
+    {VAL_DBUPDATE, Z_External_update, (Odr_fun)z_IUUpdate},
+    {VAL_DATETIME, Z_External_dateTime, (Odr_fun)z_DateTime},
+    {VAL_UNIVERSE_REPORT, Z_External_universeReport, (Odr_fun)z_UniverseReport},
+    {VAL_NONE, 0, 0}
+};
+
+Z_ext_typeent *z_ext_getentbyref(oid_value val)
+{
+    Z_ext_typeent *i;
+
+    for (i = type_table; i->dref != VAL_NONE; i++)
+       if (i->dref == val)
+           return i;
+    return 0;
+}
+
+int z_External(ODR o, Z_External **p, int opt, const char *name)
+{
+    oident *oid;
+    Z_ext_typeent *type;
+
+    static Odr_arm arm[] =
+    {
+       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_single,
+        (Odr_fun)odr_any, 0},
+       {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_External_octet,
+        (Odr_fun)odr_octetstring, 0},
+       {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_External_arbitrary,
+        (Odr_fun)odr_bitstring, 0},
+       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_sutrs,
+        (Odr_fun)z_SUTRS, 0},
+       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_explainRecord,
+        (Odr_fun)z_ExplainRecord, 0},
+       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_resourceReport1,
+        (Odr_fun)z_ResourceReport1, 0},
+       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_resourceReport2,
+        (Odr_fun)z_ResourceReport2, 0},
+       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_promptObject1,
+        (Odr_fun)z_PromptObject1, 0},
+       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_grs1,
+        (Odr_fun)z_GenericRecord, 0},
+       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_extendedService,
+        (Odr_fun)z_TaskPackage, 0},
+#ifdef ASN_COMPILED
+       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_itemOrder,
+        (Odr_fun)z_IOItemOrder, 0},
+#else
+       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_itemOrder,
+        (Odr_fun)z_ItemOrder, 0},
+#endif
+       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_diag1,
+        (Odr_fun)z_DiagnosticFormat, 0},
+       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_espec1,
+        (Odr_fun)z_Espec1, 0},
+       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_summary,
+        (Odr_fun)z_BriefBib, 0},
+       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_OPAC,
+        (Odr_fun)z_OPACRecord, 0},
+       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_searchResult1,
+        (Odr_fun)z_SearchInfoReport, 0},
+       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_update,
+        (Odr_fun)z_IUUpdate, 0},
+       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_dateTime,
+        (Odr_fun)z_DateTime, 0},
+       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_universeReport,
+        (Odr_fun)z_UniverseReport, 0},
+       {-1, -1, -1, -1, 0, 0}
+    };
+    
+    odr_implicit_settag(o, ODR_UNIVERSAL, ODR_EXTERNAL);
+    if (!odr_sequence_begin(o, p, sizeof(**p), name))
+       return opt && odr_ok(o);
+    if (!(odr_oid(o, &(*p)->direct_reference, 1, 0) &&
+         odr_integer(o, &(*p)->indirect_reference, 1, 0) &&
+         odr_graphicstring(o, &(*p)->descriptor, 1, 0)))
+       return 0;
+    /*
+     * Do we know this beast?
+     */
+    if (o->direction == ODR_DECODE && (*p)->direct_reference &&
+       (oid = oid_getentbyoid((*p)->direct_reference)) &&
+       (type = z_ext_getentbyref(oid->value)))
+    {
+       int zclass, tag, cons;
+       
+       /*
+        * We know it. If it's represented as an ASN.1 type, bias the CHOICE.
+        */
+       if (!odr_peektag(o, &zclass, &tag, &cons))
+           return opt && odr_ok(o);
+       if (zclass == ODR_CONTEXT && tag == 0 && cons == 1)
+           odr_choice_bias(o, type->what);
+    }
+    return
+       odr_choice(o, arm, &(*p)->u, &(*p)->which, name) &&
+       odr_sequence_end(o);
+}
+
+Z_External *z_ext_record(ODR o, int format, const char *buf, int len)
+{
+    Z_External *thisext;
+    oident recform;
+    int oid[OID_SIZE];
+
+    thisext = (Z_External *) odr_malloc(o, sizeof(*thisext));
+    thisext->descriptor = 0;
+    thisext->indirect_reference = 0;
+
+    recform.proto = PROTO_Z3950;
+    recform.oclass = CLASS_RECSYN;
+    recform.value = (enum oid_value) format;
+    if (!oid_ent_to_oid(&recform, oid))
+       return 0;
+    thisext->direct_reference = odr_oiddup(o, oid);
+    
+    if (len < 0) /* Structured data */
+    {
+       switch (format)
+       {
+       case VAL_SUTRS:
+           thisext->which = Z_External_sutrs;
+           break;
+       case VAL_GRS1:
+           thisext->which = Z_External_grs1;
+           break;
+       case VAL_EXPLAIN:
+           thisext->which = Z_External_explainRecord;
+           break;
+       case VAL_SUMMARY:
+           thisext->which = Z_External_summary;
+           break;
+       case VAL_OPAC:
+           thisext->which = Z_External_OPAC;
+           break;
+       default:
+           return 0;
+       }
+       
+       /*
+        * We cheat on the pointers here. Obviously, the record field
+        * of the backend-fetch structure should have been a union for
+        * correctness, but we're stuck with this for backwards
+        * compatibility.
+        */
+       thisext->u.grs1 = (Z_GenericRecord*) buf;
+    }
+    else if (format == VAL_SUTRS) /* SUTRS is a single-ASN.1-type */
+    {
+       Odr_oct *sutrs = (Odr_oct *)odr_malloc(o, sizeof(*sutrs));
+       
+       thisext->which = Z_External_sutrs;
+       thisext->u.sutrs = sutrs;
+       sutrs->buf = (unsigned char *)odr_malloc(o, len);
+       sutrs->len = sutrs->size = len;
+       memcpy(sutrs->buf, buf, len);
+    }
+    else
+    {
+       thisext->which = Z_External_octet;
+       if (!(thisext->u.octet_aligned = (Odr_oct *)
+             odr_malloc(o, sizeof(Odr_oct))))
+           return 0;
+       if (!(thisext->u.octet_aligned->buf = (unsigned char *)
+             odr_malloc(o, len)))
+           return 0;
+       memcpy(thisext->u.octet_aligned->buf, buf, len);
+       thisext->u.octet_aligned->len = thisext->u.octet_aligned->size = len;
+    }
+    return thisext;
+}
+
diff --git a/zutil/query.c b/zutil/query.c
new file mode 100644 (file)
index 0000000..eb5e5e6
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 1995, Index Data
+ * See the file LICENSE for details.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * $Log: query.c,v $
+ * Revision 1.1  1999-06-08 10:10:16  adam
+ * New sub directory zutil. Moved YAZ Compiler to be part of YAZ tree.
+ *
+ * Revision 1.3  1996/01/02 11:46:56  quinn
+ * Changed 'operator' to 'roperator' to avoid C++ conflict.
+ *
+ * Revision 1.2  1995/05/16  08:51:14  quinn
+ * License, documentation, and memory fixes
+ *
+ * Revision 1.1  1995/04/10  10:28:47  quinn
+ * Added copy of CCL and MARC display
+ *
+ *
+ */
+
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+
+#include <odr.h>
+#include <proto.h>
+
+static Z_Complex *makecomplex(ODR o, char **buf);
+static Z_Operand *makesimple(ODR o, char **buf);
+Z_RPNStructure *makerpn(ODR o, char **buf);
+
+void skip_spaces(char**p)
+{
+    while (**p && isspace(**p))
+       (*p)++;
+}
+
+static Z_Operand *makesimple(ODR o, char **buf)
+{
+    Z_Operand *r;
+    Z_AttributesPlusTerm *t;
+    char *b;
+
+    r = odr_malloc(o, sizeof(*r));
+    if (**buf == 's' && *((*buf) + 1) == '=')
+    {
+       char *b = odr_malloc(o, 100);
+
+       r->which = Z_Operand_resultSetId;
+       r->u.resultSetId = b;
+       (*buf)++;
+       (*buf)++;
+       while (**buf && !isspace(**buf))
+           *(b++) = *((*buf)++);
+       *b = 0;
+       return r;
+    }
+    else if (**buf != '"')
+       return 0;
+    (*buf)++;
+    r->which = Z_Operand_APT;
+    r->u.attributesPlusTerm = t = odr_malloc(o, sizeof(*t));
+    t->num_attributes = 0;
+    t->attributeList = 0;
+    t->term = odr_malloc(o, sizeof(*t->term));
+    t->term->which = Z_Term_general;
+    t->term->u.general = odr_malloc(o, sizeof(Odr_oct));
+    t->term->u.general->buf = odr_malloc(o, 100);
+    t->term->u.general->size = 100;
+    t->term->u.general->len = 0;
+    b = (char*) t->term->u.general->buf;
+    while (**buf && **buf != '"')
+    {
+       *(b++) = *((*buf)++);
+       t->term->u.general->len++;
+    }
+    if (**buf != '"')
+       return 0;
+    (*buf)++;
+    return r;
+}
+
+static Z_Complex *makecomplex(ODR o, char **buf)
+{
+    Z_Complex *r;
+    char op[100], *b;
+
+    r = odr_malloc(o, sizeof(*r));
+    r->roperator = odr_malloc(o, sizeof(*r->roperator));
+
+    b = op;
+    while (**buf && !isspace(**buf))
+       *(b++) = *((*buf)++);
+    *b = 0;
+    if (!strcmp(op, "and"))
+       r->roperator->which = Z_Operator_and;
+    else if (!strcmp(op, "or"))
+       r->roperator->which = Z_Operator_or;
+    else if (!strcmp(op, "not"))
+       r->roperator->which = Z_Operator_and_not;
+    r->roperator->u.and = "";
+    while (**buf && !isspace(**buf))
+       (*buf)++;
+    if (!(r->s1 = makerpn(o, buf)))
+       return 0;
+    if (!(r->s2 = makerpn(o, buf)))
+       return 0;
+    return r;
+}
+    
+Z_RPNStructure *makerpn(ODR o, char **buf)
+{
+    Z_RPNStructure *r;
+
+    r = odr_malloc(o, sizeof(*r));
+    skip_spaces(buf);
+    if (**buf == '"' || **buf == 's')
+    {
+       r->which = Z_RPNStructure_simple;
+       if (!(r->u.simple = makesimple(o, buf)))
+           return 0;
+       return r;
+    }
+    r->which = Z_RPNStructure_complex;
+    if (!(r->u.complex = makecomplex(o, buf)))
+       return 0;
+    return r;
+}
diff --git a/zutil/zget.c b/zutil/zget.c
new file mode 100644 (file)
index 0000000..ddcd8d9
--- /dev/null
@@ -0,0 +1,525 @@
+/*
+ * Copyright (c) 1995-1999, Index Data.
+ * See the file LICENSE for details.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * $Log: zget.c,v $
+ * Revision 1.1  1999-06-08 10:10:16  adam
+ * New sub directory zutil. Moved YAZ Compiler to be part of YAZ tree.
+ *
+ * Revision 1.17  1999/04/20 09:56:48  adam
+ * Added 'name' paramter to encoder/decoder routines (typedef Odr_fun).
+ * Modified all encoders/decoders to reflect this change.
+ *
+ * Revision 1.16  1998/08/19 16:10:05  adam
+ * Changed som member names of DeleteResultSetRequest/Response.
+ *
+ * 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
+ * Function zget_presentRequest fills resultSetId with "default" instead
+ * of "Default".
+ *
+ * Revision 1.12  1997/10/29 12:00:37  adam
+ * Routine zget_SearchRequest fills resultSetName member with "default"
+ * instead of "Default".
+ *
+ * Revision 1.11  1997/05/02 08:39:10  quinn
+ * New PDUs added, thanks to Ronald van der Meer
+ *
+ * Revision 1.10  1996/01/02 08:57:23  quinn
+ * Changed enums in the ASN.1 .h files to #defines. Changed oident.class to oclass
+ *
+ * Revision 1.9  1995/09/29  17:11:55  quinn
+ * Smallish
+ *
+ * Revision 1.8  1995/09/27  15:02:43  quinn
+ * Modified function heads & prototypes.
+ *
+ * Revision 1.7  1995/06/15  07:44:52  quinn
+ * Moving to v3.
+ *
+ * Revision 1.6  1995/06/14  15:26:37  quinn
+ * *** empty log message ***
+ *
+ * Revision 1.5  1995/06/07  14:42:30  quinn
+ * Fixed CLOSE
+ *
+ * Revision 1.4  1995/06/07  14:36:25  quinn
+ * Added CLOSE
+ *
+ * Revision 1.3  1995/06/05  10:52:06  quinn
+ * Fixed some negligences.
+ *
+ * Revision 1.2  1995/05/30  10:15:49  quinn
+ * Added our implementor's ID
+ *
+ * Revision 1.1  1995/05/22  11:30:20  quinn
+ * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
+ *
+ *
+ */
+
+#include <proto.h>
+
+Z_InitRequest *zget_InitRequest(ODR o)
+{
+    Z_InitRequest *r = (Z_InitRequest *)odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->options = (Odr_bitmask *)odr_malloc(o, sizeof(*r->options));
+    ODR_MASK_ZERO(r->options);
+    r->protocolVersion = (Odr_bitmask *)odr_malloc(o, sizeof(*r->protocolVersion));
+    ODR_MASK_ZERO(r->protocolVersion);
+    r->preferredMessageSize = (int *)odr_malloc(o, sizeof(int));
+    *r->preferredMessageSize = 30*1024;
+    r->maximumRecordSize = (int *)odr_malloc(o, sizeof(int));
+    *r->maximumRecordSize = 30*1024;
+    r->idAuthentication = 0;
+    r->implementationId = "YAZ (id=81)";
+    r->implementationName = "Index Data/YAZ";
+    r->implementationVersion = YAZ_VERSION;
+    r->userInformationField = 0;
+    r->otherInfo = 0;
+    return r;
+}
+
+Z_InitResponse *zget_InitResponse(ODR o)
+{
+    Z_InitResponse *r = (Z_InitResponse *)odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->options = (Odr_bitmask *)odr_malloc(o, sizeof(*r->options));
+    ODR_MASK_ZERO(r->options);
+    r->protocolVersion = (Odr_bitmask *)odr_malloc(o, sizeof(*r->protocolVersion));
+    ODR_MASK_ZERO(r->protocolVersion);
+    r->preferredMessageSize = (int *)odr_malloc(o, sizeof(int));
+    *r->preferredMessageSize = 30*1024;
+    r->maximumRecordSize = (int *)odr_malloc(o, sizeof(int));
+    *r->maximumRecordSize = 30*1024;
+    r->result = (int *)odr_malloc(o, sizeof(bool_t));
+    *r->result = 1;
+    r->implementationId = "YAZ (id=81)";
+    r->implementationName = "Index Data/YAZ";
+    r->implementationVersion = YAZ_VERSION;
+    r->userInformationField = 0;
+    r->otherInfo = 0;
+    return r;
+}
+
+Z_SearchRequest *zget_SearchRequest(ODR o)
+{
+    Z_SearchRequest *r = (Z_SearchRequest *)odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->smallSetUpperBound = (int *)odr_malloc(o, sizeof(int));
+    *r->smallSetUpperBound = 0;
+    r->largeSetLowerBound = (int *)odr_malloc(o, sizeof(int));
+    *r->largeSetLowerBound = 1;
+    r->mediumSetPresentNumber = (int *)odr_malloc(o, sizeof(int));
+    *r->mediumSetPresentNumber = 0;
+    r->replaceIndicator = (int *)odr_malloc(o, sizeof(bool_t));
+    *r->replaceIndicator = 1;
+    r->resultSetName = "default";
+    r->num_databaseNames = 0;
+    r->databaseNames = 0;
+    r->smallSetElementSetNames = 0;
+    r->mediumSetElementSetNames = 0;
+    r->preferredRecordSyntax = 0;
+    r->query = 0;
+    r->additionalSearchInfo = 0;
+    r->otherInfo = 0;
+    return r;
+}
+
+Z_SearchResponse *zget_SearchResponse(ODR o)
+{
+    Z_SearchResponse *r = (Z_SearchResponse *)odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->resultCount = (int *)odr_malloc(o, sizeof(int));
+    *r->resultCount = 0;
+    r->numberOfRecordsReturned = (int *)odr_malloc(o, sizeof(int));
+    *r->numberOfRecordsReturned = 0;
+    r->nextResultSetPosition = (int *)odr_malloc(o, sizeof(int));
+    *r->nextResultSetPosition = 0;
+    r->searchStatus = (int *)odr_malloc(o, sizeof(bool_t));
+    *r->searchStatus = 1;
+    r->resultSetStatus = 0;
+    r->presentStatus = 0;
+    r->records = 0;
+    r->additionalSearchInfo = 0;
+    r->otherInfo = 0;
+    return r;
+}
+
+Z_PresentRequest *zget_PresentRequest(ODR o)
+{
+    Z_PresentRequest *r = (Z_PresentRequest *)odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->resultSetId = "default";
+    r->resultSetStartPoint = (int *)odr_malloc(o, sizeof(int));
+    *r->resultSetStartPoint = 1;
+    r->numberOfRecordsRequested = (int *)odr_malloc(o, sizeof(int));
+    *r->numberOfRecordsRequested = 10;
+    r->num_ranges = 0;
+    r->additionalRanges = 0;
+    r->recordComposition = 0;
+    r->preferredRecordSyntax = 0;
+    r->maxSegmentCount = 0;
+    r->maxRecordSize = 0;
+    r->maxSegmentSize = 0;
+    r->otherInfo = 0;
+    return r;
+}
+
+Z_PresentResponse *zget_PresentResponse(ODR o)
+{
+    Z_PresentResponse *r = (Z_PresentResponse *)odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->numberOfRecordsReturned = (int *)odr_malloc(o, sizeof(int));
+    *r->numberOfRecordsReturned = 0;
+    r->nextResultSetPosition = (int *)odr_malloc(o, sizeof(int));
+    *r->nextResultSetPosition = 0;
+    r->presentStatus = (int *)odr_malloc(o, sizeof(int));
+    *r->presentStatus = Z_PRES_SUCCESS;
+    r->records = 0;
+    r->otherInfo = 0;
+    return r;
+}
+
+Z_DeleteResultSetRequest *zget_DeleteResultSetRequest(ODR o)
+{
+    Z_DeleteResultSetRequest *r = (Z_DeleteResultSetRequest *)
+       odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->deleteFunction = (int *)odr_malloc(o, sizeof(int));
+    *r->deleteFunction = Z_DeleteRequest_list;
+    r->num_resultSetList = 0;
+    r->resultSetList = 0;
+    r->otherInfo = 0;
+    return r;
+}
+
+Z_DeleteResultSetResponse *zget_DeleteResultSetResponse(ODR o)
+{
+    Z_DeleteResultSetResponse *r = (Z_DeleteResultSetResponse *)
+       odr_malloc(o, sizeof(*r));
+    
+    r->referenceId = 0;
+    r->deleteOperationStatus = (int *)odr_malloc(o, sizeof(int));
+    *r->deleteOperationStatus = Z_DeleteStatus_success;
+    r->deleteListStatuses = 0;
+    r->numberNotDeleted = 0;
+    r->bulkStatuses = 0;
+    r->deleteMessage = 0;
+    r->otherInfo = 0;
+    return r;
+}
+
+Z_ScanRequest *zget_ScanRequest(ODR o)
+{
+    Z_ScanRequest *r = (Z_ScanRequest *)odr_malloc(o, sizeof(*r));
+    
+    r->referenceId = 0;
+    r->num_databaseNames = 0;
+    r->databaseNames = 0;
+    r->attributeSet = 0;
+    r->termListAndStartPoint = 0;
+    r->stepSize = 0;
+    r->numberOfTermsRequested = (int *)odr_malloc(o, sizeof(int));
+    *r->numberOfTermsRequested = 20;
+    r->preferredPositionInResponse = 0;
+    r->otherInfo = 0;
+    return r;
+}
+
+Z_ScanResponse *zget_ScanResponse(ODR o)
+{
+    Z_ScanResponse *r = (Z_ScanResponse *)odr_malloc(o, sizeof(*r));
+    
+    r->referenceId = 0;
+    r->stepSize = 0;
+    r->scanStatus = (int *)odr_malloc(o, sizeof(int));
+    *r->scanStatus = Z_Scan_success;
+    r->numberOfEntriesReturned = (int *)odr_malloc(o, sizeof(int));
+    *r->numberOfEntriesReturned = 0;
+    r->positionOfTerm =0;
+    r->entries = 0;
+    r->attributeSet = 0;
+    r->otherInfo = 0;
+    return r;
+}
+
+Z_TriggerResourceControlRequest *zget_TriggerResourceControlRequest(ODR o)
+{
+    Z_TriggerResourceControlRequest *r = (Z_TriggerResourceControlRequest *)
+       odr_malloc(o, sizeof(*r));
+    
+    r->referenceId = 0;
+    r->requestedAction = (int *)odr_malloc(o, sizeof(int));
+    *r->requestedAction = Z_TriggerResourceCtrl_resourceReport;
+    r->prefResourceReportFormat = 0;
+    r->resultSetWanted = 0;
+    r->otherInfo = 0;
+    return r;
+}
+
+Z_ResourceControlRequest *zget_ResourceControlRequest(ODR o)
+{
+    Z_ResourceControlRequest *r = (Z_ResourceControlRequest *)
+       odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->suspendedFlag = 0;
+    r->resourceReport = 0;
+    r->partialResultsAvailable = 0;
+    r->responseRequired = (int *)odr_malloc(o, sizeof(bool_t));
+    *r->responseRequired = 0;
+    r->triggeredRequestFlag = 0;
+    r->otherInfo = 0;
+    return r;
+}
+
+Z_ResourceControlResponse *zget_ResourceControlResponse(ODR o)
+{
+    Z_ResourceControlResponse *r = (Z_ResourceControlResponse *)
+       odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->continueFlag = (int *)odr_malloc(o, sizeof(bool_t));
+    *r->continueFlag = 1;
+    r->resultSetWanted = 0;
+    r->otherInfo = 0;
+    return r;
+}
+
+Z_AccessControlRequest *zget_AccessControlRequest(ODR o)
+{
+    Z_AccessControlRequest *r = (Z_AccessControlRequest *)
+       odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->which = Z_AccessRequest_simpleForm;
+    r->u.simpleForm = 0;
+    r->otherInfo = 0;
+    return r;
+}
+
+Z_AccessControlResponse *zget_AccessControlResponse(ODR o)
+{
+    Z_AccessControlResponse *r = (Z_AccessControlResponse *)
+       odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->which = Z_AccessResponse_simpleForm;
+    r->u.simpleForm = 0;
+    r->diagnostic = 0;
+    r->otherInfo = 0;
+    return r;
+}
+
+Z_Segment *zget_Segment(ODR o)
+{
+    Z_Segment *r = (Z_Segment *)odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->numberOfRecordsReturned = (int *)odr_malloc(o, sizeof(int));
+    *r->numberOfRecordsReturned = 0;
+    r->num_segmentRecords = 0;
+    r->segmentRecords = 0;
+    r->otherInfo = 0;
+    return r;
+}
+
+Z_Close *zget_Close(ODR o)
+{
+    Z_Close *r = (Z_Close *)odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->closeReason = (int *)odr_malloc(o, sizeof(int));
+    *r->closeReason = Z_Close_finished;
+    r->diagnosticInformation = 0;
+    r->resourceReportFormat = 0;
+    r->resourceReport = 0;
+    r->otherInfo = 0;
+    return r;
+}
+
+Z_ResourceReportRequest *zget_ResourceReportRequest(ODR o)
+{
+    Z_ResourceReportRequest *r = (Z_ResourceReportRequest *)
+       odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->opId = 0;
+    r->prefResourceReportFormat = 0;
+    r->otherInfo = 0;
+    return r;
+}
+
+Z_ResourceReportResponse *zget_ResourceReportResponse(ODR o)
+{
+    Z_ResourceReportResponse *r = (Z_ResourceReportResponse *)
+       odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->resourceReportStatus = (int *)odr_malloc(o, sizeof(int));
+    *r->resourceReportStatus = Z_ResourceReportStatus_success;
+    r->resourceReport = 0;
+    r->otherInfo = 0;
+    return r;
+}
+
+Z_SortRequest *zget_SortRequest(ODR o)
+{
+    Z_SortRequest *r = (Z_SortRequest *)odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->inputResultSetNames = 0;
+    r->sortedResultSetName = 0;
+    r->sortSequence = 0;
+    r->otherInfo = 0;
+    return r;
+}
+
+Z_SortResponse *zget_SortResponse(ODR o)
+{
+    Z_SortResponse *r = (Z_SortResponse *)odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->sortStatus = (int *)odr_malloc(o, sizeof(int));
+    *r->sortStatus = Z_SortStatus_success;
+    r->resultSetStatus = (int *)odr_malloc(o, sizeof(int));
+    *r->resultSetStatus = Z_SortResultSetStatus_empty;
+    r->diagnostics = 0;
+    r->otherInfo = 0;
+    return r;
+}
+
+Z_ExtendedServicesRequest *zget_ExtendedServicesRequest(ODR o)
+{
+    Z_ExtendedServicesRequest *r = (Z_ExtendedServicesRequest *)
+       odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->function = (int *)odr_malloc(o, sizeof(int));
+    *r->function = Z_ExtendedServicesRequest_create;
+    r->packageType = 0;
+    r->packageName = 0;
+    r->userId = 0;
+    r->retentionTime = 0;
+    r->permissions = 0;
+    r->description = 0;
+    r->taskSpecificParameters = 0;
+    r->waitAction = (int *)odr_malloc(o, sizeof(int));
+    *r->waitAction = Z_ExtendedServicesRequest_wait;
+    r->elements = 0;
+    r->otherInfo = 0;
+    return r;
+}
+
+Z_ExtendedServicesResponse *zget_ExtendedServicesResponse(ODR o)
+{
+    Z_ExtendedServicesResponse *r = (Z_ExtendedServicesResponse *)
+       odr_malloc(o, sizeof(*r));
+
+    r->referenceId = 0;
+    r->operationStatus = (int *)odr_malloc(o, sizeof(int));
+    *r->operationStatus = Z_ExtendedServicesResponse_done;
+    r->num_diagnostics = 0;
+    r->diagnostics = 0;
+    r->taskPackage = 0;
+    r->otherInfo = 0;
+    return r;
+}
+
+Z_APDU *zget_APDU(ODR o, int which)
+{
+    Z_APDU *r = (Z_APDU *)odr_malloc(o, sizeof(*r));
+
+    switch (r->which = which)
+    {
+       case Z_APDU_initRequest:
+           r->u.initRequest = zget_InitRequest(o);
+            break;
+       case Z_APDU_initResponse:
+           r->u.initResponse = zget_InitResponse(o);
+            break;
+       case Z_APDU_searchRequest:
+           r->u.searchRequest = zget_SearchRequest(o);
+            break;
+       case Z_APDU_searchResponse:
+           r->u.searchResponse = zget_SearchResponse(o);
+            break;
+       case Z_APDU_presentRequest:
+           r->u.presentRequest = zget_PresentRequest(o);
+            break;
+       case Z_APDU_presentResponse:
+           r->u.presentResponse = zget_PresentResponse(o);
+            break;
+       case Z_APDU_deleteResultSetRequest:
+           r->u.deleteResultSetRequest = zget_DeleteResultSetRequest(o);
+            break;
+       case Z_APDU_deleteResultSetResponse:
+           r->u.deleteResultSetResponse = zget_DeleteResultSetResponse(o);
+           break;
+       case Z_APDU_scanRequest:
+           r->u.scanRequest = zget_ScanRequest(o);
+            break;
+       case Z_APDU_scanResponse:
+           r->u.scanResponse = zget_ScanResponse(o);
+            break;
+       case Z_APDU_triggerResourceControlRequest:
+           r->u.triggerResourceControlRequest =
+                zget_TriggerResourceControlRequest(o);
+            break;
+       case Z_APDU_resourceControlRequest:
+           r->u.resourceControlRequest = zget_ResourceControlRequest(o);
+           break;
+       case Z_APDU_resourceControlResponse:
+           r->u.resourceControlResponse = zget_ResourceControlResponse(o);
+           break;
+       case Z_APDU_segmentRequest:
+           r->u.segmentRequest = zget_Segment(o);
+           break;
+       case Z_APDU_close:
+           r->u.close = zget_Close(o);
+           break;
+       case Z_APDU_accessControlRequest:
+           r->u.accessControlRequest = zget_AccessControlRequest(o);
+           break;
+       case Z_APDU_accessControlResponse:
+           r->u.accessControlResponse = zget_AccessControlResponse(o);
+           break;
+       case Z_APDU_resourceReportRequest:
+           r->u.resourceReportRequest = zget_ResourceReportRequest(o);
+           break;
+       case Z_APDU_resourceReportResponse:
+           r->u.resourceReportResponse = zget_ResourceReportResponse(o);
+           break;
+       case Z_APDU_sortRequest:
+           r->u.sortRequest = zget_SortRequest(o);
+           break;
+       case Z_APDU_sortResponse:
+           r->u.sortResponse = zget_SortResponse(o);
+           break;
+       case Z_APDU_extendedServicesRequest:
+           r->u.extendedServicesRequest = zget_ExtendedServicesRequest(o);
+           break;
+       case Z_APDU_extendedServicesResponse:
+           r->u.extendedServicesResponse = zget_ExtendedServicesResponse(o);
+           break;
+       default:
+           fprintf(stderr, "Bad APDU-type to zget_APDU");
+           exit(1);
+    }
+    return r;
+}