summaryrefslogtreecommitdiffstats
path: root/src/isode/pepsy
diff options
context:
space:
mode:
authorMark Eichin <eichin@mit.edu>1994-06-10 03:36:08 +0000
committerMark Eichin <eichin@mit.edu>1994-06-10 03:36:08 +0000
commit90864cc89d4323e379b5cc2270865627cd7fc665 (patch)
tree5a5458b3967c32bb7ef50b968f240a63744e966a /src/isode/pepsy
parent9f848ddada00ab926f70bd892b199f875404e26a (diff)
downloadkrb5-90864cc89d4323e379b5cc2270865627cd7fc665.tar.gz
krb5-90864cc89d4323e379b5cc2270865627cd7fc665.tar.xz
krb5-90864cc89d4323e379b5cc2270865627cd7fc665.zip
autoconfed isode for kerberos work
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@3697 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/isode/pepsy')
-rw-r--r--src/isode/pepsy/Makefile.in357
-rw-r--r--src/isode/pepsy/UNIV.py140
-rw-r--r--src/isode/pepsy/configure.in2
-rw-r--r--src/isode/pepsy/dec.c2154
-rw-r--r--src/isode/pepsy/dfns.c248
-rw-r--r--src/isode/pepsy/doc/DESCRIPTION1056
-rw-r--r--src/isode/pepsy/doc/Makefile10
-rw-r--r--src/isode/pepsy/doc/overview.ms271
-rw-r--r--src/isode/pepsy/doc/tables.ms353
-rw-r--r--src/isode/pepsy/doc/wt-pep.ms201
-rw-r--r--src/isode/pepsy/dtabs.c812
-rw-r--r--src/isode/pepsy/enc.c1573
-rw-r--r--src/isode/pepsy/etabs.c2284
-rw-r--r--src/isode/pepsy/fre.c702
-rw-r--r--src/isode/pepsy/lex.l.gnrc630
-rw-r--r--src/isode/pepsy/libpepsy.342
-rw-r--r--src/isode/pepsy/macdefs.h57
-rw-r--r--src/isode/pepsy/main.c4244
-rw-r--r--src/isode/pepsy/mine.h53
-rw-r--r--src/isode/pepsy/mod.c173
-rw-r--r--src/isode/pepsy/pass2.c1524
-rw-r--r--src/isode/pepsy/pass2.h140
-rw-r--r--src/isode/pepsy/pep.output7842
-rw-r--r--src/isode/pepsy/pepsy-driver.h53
-rw-r--r--src/isode/pepsy/pepsy.175
-rw-r--r--src/isode/pepsy/pepsy.c3731
-rw-r--r--src/isode/pepsy/pepsy.h.gnrc342
-rw-r--r--src/isode/pepsy/pepsy_misc.c381
-rw-r--r--src/isode/pepsy/pepsy_str.c61
-rw-r--r--src/isode/pepsy/pepsydefs.h.gnrc422
-rw-r--r--src/isode/pepsy/pepy-refs.h146
-rw-r--r--src/isode/pepsy/prnt.c1740
-rw-r--r--src/isode/pepsy/ptabs.c1144
-rw-r--r--src/isode/pepsy/py_advise.c66
-rw-r--r--src/isode/pepsy/sym.h43
-rw-r--r--src/isode/pepsy/t1.py391
-rw-r--r--src/isode/pepsy/t2.py69
-rw-r--r--src/isode/pepsy/t3.py513
-rw-r--r--src/isode/pepsy/test_table.h209
-rw-r--r--src/isode/pepsy/tt.py82
-rw-r--r--src/isode/pepsy/util.c780
-rw-r--r--src/isode/pepsy/version.major1
-rw-r--r--src/isode/pepsy/version.minor1
-rw-r--r--src/isode/pepsy/vprint.c766
-rw-r--r--src/isode/pepsy/yacc.y.gnrc1643
45 files changed, 37527 insertions, 0 deletions
diff --git a/src/isode/pepsy/Makefile.in b/src/isode/pepsy/Makefile.in
new file mode 100644
index 000000000..b26daa0d3
--- /dev/null
+++ b/src/isode/pepsy/Makefile.in
@@ -0,0 +1,357 @@
+###############################################################################
+# Instructions to Make, for compilation of ISODE PEPSY process
+###############################################################################
+
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+BUILDTOP = ../../
+TOPDIR = $(BUILDTOP)
+
+OPTIONS = -I. -I$(HDIR) $(PEPYPATH) $(KRBOPT)
+CFLAGS = $(OPTIONS) $(LOPTIONS)
+
+HDIR = $(TOPDIR)isode/h/
+UTILDIR = $(TOPDIR)isode/util/
+INCDIRM = $(HDIR)
+INCDIR = $(INCDIRM)/
+PEPSYDIRM= $(INCDIR)pepsy
+PEPSYDIR= $(PEPSYDIRM)/
+PSAPDIRM= $(TOPDIR)isode/psap
+PSAPDIR= $(PSAPDIRM)/
+LIBISODE= $(TOPDIR)libisode.a
+LIBDSAP = $(TOPDIR)libdsap.a
+
+KRBINC = $(TOPDIR)include/
+ISODEINCM= $(KRBINC)isode
+ISODEINC= $(KRBINC)isode/
+PEPSYINCM= $(ISODEINC)pepsy
+PEPSYINC= $(ISODEINC)pepsy/
+
+LIBES = libcompat.a
+LLIBS =
+LN = ln
+LDCC = $(CC)
+###############################################################################
+#
+# NOTICE
+#
+# Acquisition, use, and distribution of this module and related
+# materials are subject to the restrictions of a license agreement.
+# Consult the Preface in the User's Manual for the full terms of
+# this agreement.
+#
+###############################################################################
+
+
+PEPYPATH= -DPEPYPATH -DPEPSYPATH=\".:$(PEPSYDIRM)\"
+
+# to prevent a lot of unnecessary re-loading
+PEPSYLIBES= $(PSAPDIR)/sprintoid.o $(PSAPDIR)/pl_tables.o \
+ $(PSAPDIR)/oid_cmp.o $(PSAPDIR)/oid_cpy.o \
+ $(PSAPDIR)/oid_free.o ../compat/libcompat.a
+LIBES = $(TOPDIR)libpsap.a $(TOPDIR)libcompat.a
+LLIBS = $(TOPDIR)llib-lpsap $(TOPDIR)llib-lcompat
+HFILES = $(HDIR)psap.h \
+ $(HDIR)manifest.h $(HDIR)general.h $(HDIR)config.h
+
+DRFILES = enc.o dec.o fre.o prnt.o util.o
+SUPFILES= vprint.o UNIV_tables.o pepsy_str.o py_advise.o
+LIBFILES= $(DRFILES) $(SUPFILES)
+
+CFILES = enc.c dec.c fre.c prnt.c main.c util.c \
+ vprint.c pepsy_str.c py_advise.c
+
+HFILES = $(HDIR)/pepsy.h test_table.h
+HEADERS = UNIV.ph UNIV-types.h
+
+OFILES = $(LIBFILES) main.o
+
+T_FILES = T1_tables.c T2_tables.c T3_tables.c
+
+
+##################################################################
+# Here it is...
+##################################################################
+all: pepsy libpepsy # peptest
+ -mkdir $(ISODEINCM)
+ -mkdir $(PEPSYINCM)
+ @for h in $(HEADERS); do cp $$h $(PEPSYINC)/$$h; done
+ -@echo copied $(HEADERS)
+
+inst-all: inst-pepsy inst-headers manuals # inst-libpepsy
+install: inst-all clean
+lint: l-pepsy l-libpepsy
+
+
+##################################################################
+# pepsy
+##################################################################
+
+PEPSY-C = pepsy.c pepsy-yacc.c pepsy_misc.c pass2.c etabs.c dtabs.c ptabs.c \
+ dfns.c mod.c
+PEPSY-O = pepsy.o pepsy-yacc.o pepsy_misc.o pass2.o etabs.o dtabs.o ptabs.o \
+ dfns.o mod.o
+
+inst-pepsy: $(BINDIR)pepsy
+
+$(BINDIR)pepsy: xpepsy
+ -cp $@ zxpepsy
+ -rm -f $@
+ cp xpepsy $@
+ -@ls -gls $@
+ -@echo ""
+
+pepsy: xpepsy
+ -@echo ""
+
+xpepsy: pepsyvrsn.o $(PEPSYLIBES)
+ $(LDCC) $(LDFLAGS) -o $@ $(PEPSY-O) \
+ pepsyvrsn.o $(PEPSYLIBES) -lm
+
+pepsy.o: pepsy.c pepsydefs.h $(HFILES)
+ $(CC) $(CFLAGS) -c pepsy.c
+
+
+pepsyvrsn.c: $(PEPSY-O)
+ $(UTILDIR)version.sh pepsy > $@
+
+pepsy-yacc.o: pepsy-yacc.c lex.c
+ $(CC) $(CFLAGS) -c pepsy-yacc.c
+
+pepsy-yacc.c: pepsy-yacc.y
+ -@echo "expect 40 shift/reduce and 11 reduce/reduce conflicts"
+ yacc $(YACCFLAGS) pepsy-yacc.y
+ mv y.tab.c $@
+
+pepsy-yacc.y: yacc.y.gnrc
+ $(UTILDIR)extract.sh PEPSY SCTRL < $? > $@
+
+pepsy_misc.o: pepsy_misc.c pepsydefs.h
+ $(CC) $(CFLAGS) -c pepsy_misc.c
+
+lex.c: lex.l
+ $(LEX) $(LEXFLAGS) lex.l
+ mv lex.yy.c $@
+
+lex.l: lex.l.gnrc
+ $(UTILDIR)extract.sh PEPSY < $? > $@
+
+pepsydefs.h: pepsydefs.h.gnrc
+ $(UTILDIR)extract.sh PEPSY < $? > $@
+
+pepsy.h: pepsy.h.gnrc
+ $(UTILDIR)extract.sh PEPSY < $? > $@
+
+pass2.o: pass2.c
+ $(CC) $(CFLAGS) -c pass2.c
+etabs.o: etabs.c
+ $(CC) $(CFLAGS) -c etabs.c
+dtabs.o: dtabs.c
+ $(CC) $(CFLAGS) -c dtabs.c
+ptabs.o: ptabs.c
+ $(CC) $(CFLAGS) -c ptabs.c
+dfns.o: dfns.c
+ $(CC) $(CFLAGS) -c dfns.c
+mod.o: mod.c
+ $(CC) $(CFLAGS) -c mod.c
+
+
+l-pepsy: $(PEPSY-C) pepsydefs.h pepsyvrsn.c true
+ $(LINT) $(LFLAGS) -DPEPSYPATH=\".:$(PEPSYDIRM)\" $(PEPSY-C) \
+ pepsyvrsn.c $(LLIBS) \
+ | grep -v "warning: possible pointer alignment problem"
+
+
+################################################################
+# libpepsy
+################################################################
+
+inst-libpepsy: $(LIBDIR)libpepsy.a inst-headers
+
+libpepsy: libpepsy.a true
+ -@rm -f $(HDIR)/UNIV*.h
+ -@$(LN) UNIV-types.h $(HDIR)/UNIV-types.h || cp UNIV-types.h $(HDIR)/UNIV-types.h
+
+libpepsy.a: $(LIBFILES)
+ -rm -f $@
+ @$(UTILDIR)make-lib.sh $(SYSTEM) $@ $(LIBFILES)
+ -@rm -f $(TOPDIR)libpepsy.a
+ -@$(LN) libpepsy.a $(TOPDIR)libpepsy.a || cp libpepsy.a $(TOPDIR)libpepsy.a
+ -@ls -l $@
+ -@echo "PEPSY library built normally"
+
+inst-headers:; -mkdir $(PEPSYDIRM)
+ @for h in $(HEADERS); do $(MAKE) TARGET=$$h inst-target; done
+
+inst-target: $(PEPSYDIR)$(TARGET)
+
+$(PEPSYDIR)$(TARGET): $(TARGET)
+ -cp $@ z$(TARGET)
+ cp $(TARGET) $@
+ -@ls -gls $@
+ -@echo ""
+
+UNIV_tables.o: UNIV_tables.c UNIV-types.h
+
+UNIV-types.h UNIV_tables.c: UNIV.py xpepsy
+ ./xpepsy -A -f -h -m UNIV.py
+
+l-libpepsy: $(CFILES) $(T_FILES) true
+ $(LINT) $(LFLAGS) $(CFILES) $(T_FILES) \
+ $(LLIBS) \
+ | grep -v "warning: possible pointer alignment problem"
+
+vprint.o: UNIV-types.h $(HDIR)psap.h $(HDIR)general.h $(HDIR)manifest.h \
+ $(HDIR)logger.h
+
+
+##################################################################
+# pep
+##################################################################
+alltests: tabletest peptest
+
+peptest: pep.results pep.output
+ -diff pep.output pep.results
+ touch peptest
+
+pep.results: pep
+ ./pep > pep.results
+
+tabletest: xpepsy t1test t2test t3test psap2test acsaptest ftamtest
+
+psap2test: ../psap2/PS_tables.c ../psap2/PS-types.h
+ ./xpepsy -A -f -h -m ../psap2/ps.py
+ -diff ../psap2/PS_tables.c . | grep -v "^[><] # line" \
+ | grep -v "do not edit"
+ -diff ../psap2/PS-types.h . | grep -v "^[><] # line" \
+ | grep -v "do not edit"
+ -rm -f PS_tables.c PS-types.h
+
+acsaptest: ../acsap/ACS_tables.c ../acsap/ACS-types.h
+ ./xpepsy -A -f -h -m ../acsap/acs.py
+ -diff ../acsap/ACS_tables.c . | grep -v "^[><] # line" \
+ | grep -v "do not edit"
+ -diff ../acsap/ACS-types.h . | grep -v "^[><] # line" \
+ | grep -v "do not edit"
+ -rm -f ACS_tables.c ACS-types.h
+
+ftamtest: ../ftam/FTAM_tables.c ../ftam/FTAM-types.h
+ ./xpepsy -A -f -h -m ../ftam/ftam.py
+ -diff ../ftam/FTAM_tables.c . | grep -v "^[><] # line" \
+ | grep -v "do not edit"
+ -diff ../ftam/FTAM-types.h . | grep -v "^[><] # line" \
+ | grep -v "do not edit"
+ -rm -f FTAM_tables.c FTAM-types.h
+
+fadutest: ../ftam/FADU_tables.c ../ftam/FADU-types.h
+ ./xpepsy -A -f -h -m ../ftam/fadu.py
+ -diff ../ftam/FADU_tables.c . | grep -v "^[><] # line" \
+ | grep -v "do not edit"
+ -diff ../ftam/FADU-types.h . | grep -v "^[><] # line" \
+ | grep -v "do not edit"
+ -rm -f FADU_tables.c FADU-types.h
+
+t1test: T1_tables.c T1-types.h
+ mv T1_tables.c T1_tables.c_orig
+ mv T1-types.h T1-types.h_orig
+ ./xpepsy -A -f -m t1.py
+ -diff T1_tables.c_orig T1_tables.c | grep -v "^[><] # line" \
+ | grep -v "do not edit"
+ -diff T1-types.h_orig T1-types.h | grep -v "^[><] # line" \
+ | grep -v "do not edit"
+
+t2test: T2_tables.c T2-types.h
+ mv T2_tables.c T2_tables.c_orig
+ mv T2-types.h T2-types.h_orig
+ ./xpepsy -A -f -m t2.py
+ -diff T2_tables.c_orig T2_tables.c | grep -v "^[><] # line" \
+ | grep -v "do not edit"
+ -diff T2-types.h_orig T2-types.h | grep -v "^[><] # line" \
+ | grep -v "do not edit"
+
+t3test: T3_tables.c T3-types.h
+ mv T3_tables.c T3_tables.c_orig
+ mv T3-types.h T3-types.h_orig
+ ./xpepsy -A -f -m -i pepsy-refs.h t3.py
+ -diff T3_tables.c_orig T3_tables.c | grep -v "^[><] # line" \
+ | grep -v "do not edit"
+ -diff T3-types.h_orig T3-types.h | grep -v "^[><] # line" \
+ | grep -v "do not edit"
+
+PEPLIBS = ../libpsap.a ../libcompat.a
+PEPFILES= T1_tables.o T2_tables.o T3_tables.o $(OFILES) $(PEPLIBS) # malloctrace.a
+
+pep: $(PEPFILES)
+ #$(LDCC) $(LDFLAGS) -o pep $(PEPFILES) malloctrace.a $(LSOCKET)
+ $(LDCC) $(LDFLAGS) -o pep $(PEPFILES) $(LSOCKET) -lm
+
+pep-saber: $(PEPFILES)
+ #load $(CFLAGS) (PEPFILES)
+
+main.o: T1-types.h test_table.h main.c
+ $(CC) $(CFLAGS) -DPRNT=1 -c main.c
+
+enc.o: enc.c pepsy-driver.h
+ $(CC) $(CFLAGS) -c enc.c
+
+dec.o: dec.c pepsy-driver.h
+ $(CC) $(CFLAGS) -c dec.c
+
+prnt.o: prnt.c pepsy-driver.h
+ $(CC) $(CFLAGS) -c prnt.c
+
+util.o: util.c pepsy-driver.h
+ $(CC) $(CFLAGS) -c util.c
+
+T1_tables.o: T1_tables.c T1-types.h UNIV-types.h
+
+T1_tables.c T1-types.h: t1.py xpepsy
+ ./xpepsy -A -f -m t1.py
+
+T1_tables.c: T2-types.h T3-types.h
+
+T2_tables.o: T2_tables.c T2-types.h UNIV-types.h
+
+T2_tables.c T2-types.h: t2.py xpepsy
+ ./xpepsy -A -f -m t2.py
+
+T3_tables.o: T3_tables.c T3-types.h UNIV-types.h
+
+T3_tables.c T3-types.h: t3.py xpepsy
+ ./xpepsy -A -f -m -i pepy-refs.h t3.py
+
+prt.o: prnt.c $(HDIR)/pepsy.h
+ $(CC) $(CFLAGS) -Dprintf=vprint -o $@ prnt.c
+
+
+################################################################
+# manual pages
+################################################################
+
+MANUALS = pepsy.1 # libpepsy.3
+
+manuals:; @$(UTILDIR)inst-man.sh $(MANOPTS) $(MANUALS)
+ -@echo ""
+
+
+################################################################
+# clean
+################################################################
+
+clean:; rm -f *.o *.a x* z* _* core pepsydefs.h *yacc.y *yacc.c lex.l \
+ lex.c *.ph UNIV_* UNIV-* _* core $(HDIR)/UNIV*.h \
+ pp.c pp pep libpepsy.a pepsy-yacc.y T1* T2* T3* t? \
+ peptest pep.results pepsyvrsn.c
+
+grind:; iprint Makefile
+ tgrind -lc pepsydefs.h pepsy.c pepsy.c pepsyvrsn.c
+ tgrind -ly yacc.y lex.l
+ tgrind -lpepsy -d $(TOPDIR)pepy/grindefs UNIV.py
+ tgrind -lc $(CFILES)
+ @echo $(MANUALS) | \
+ tr " " "\012" | \
+ sed -e "s%.*%itroff -man &%" | \
+ sh -ve
+
+true:;
diff --git a/src/isode/pepsy/UNIV.py b/src/isode/pepsy/UNIV.py
new file mode 100644
index 000000000..ef5b9293d
--- /dev/null
+++ b/src/isode/pepsy/UNIV.py
@@ -0,0 +1,140 @@
+-- ASN.1 UNIVERSAL defined types
+
+--
+--
+--
+
+--
+-- NOTICE
+--
+-- Acquisition, use, and distribution of this module and related
+-- materials are subject to the restrictions of a license agreement.
+-- Consult the Preface in the User's Manual for the full terms of
+-- this agreement.
+--
+--
+
+
+UNIV DEFINITIONS ::=
+
+%{
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+%}
+
+BEGIN
+
+
+ -- ISO 646-1983
+IA5String ::=
+ [UNIVERSAL 22]
+ IMPLICIT OCTET STRING
+
+NumericString ::=
+ [UNIVERSAL 18]
+ IMPLICIT IA5String
+
+PrintableString ::=
+ [UNIVERSAL 19]
+ IMPLICIT IA5String
+
+
+ -- ISO 6937/2-1983
+T61String ::=
+ [UNIVERSAL 20]
+ IMPLICIT OCTET STRING
+
+TeletexString ::=
+ T61String
+
+ -- ISO 6937/2-1983
+VideotexString ::=
+ [UNIVERSAL 21]
+ IMPLICIT OCTET STRING
+
+
+ -- ISO 2014, 3307, 4031
+ -- date, time, zone
+GeneralizedTime ::=
+ [UNIVERSAL 24]
+ IMPLICIT VisibleString
+
+GeneralisedTime ::=
+ GeneralizedTime
+
+
+UTCTime ::=
+ [UNIVERSAL 23]
+ IMPLICIT VisibleString
+
+UniversalTime ::=
+ UTCTime
+
+ -- ISO 2375
+GraphicString ::=
+ [UNIVERSAL 25]
+ IMPLICIT OCTET STRING
+
+VisibleString ::=
+ [UNIVERSAL 26]
+ IMPLICIT OCTET STRING
+
+ISO646String ::=
+ VisibleString
+
+GeneralString ::=
+ [UNIVERSAL 27]
+ IMPLICIT OCTET STRING
+
+CharacterString ::=
+ [UNIVERSAL 28]
+ IMPLICIT OCTET STRING
+
+
+ -- ISO 8824
+EXTERNAL ::=
+ [UNIVERSAL 8]
+ IMPLICIT SEQUENCE {
+ direct-reference
+ OBJECT IDENTIFIER
+ OPTIONAL,
+
+ indirect-reference
+ INTEGER
+ --* OPTIONAL *-- DEFAULT 0,
+
+ data-value-descriptor
+ ObjectDescriptor
+ OPTIONAL,
+
+ encoding
+ CHOICE {
+ single-ASN1-type[0]
+ ANY,
+
+ octet-aligned[1]
+ IMPLICIT OCTET STRING,
+
+ arbitrary[2]
+ IMPLICIT BIT STRING
+ }
+ }
+
+
+ -- ISO 8824
+ObjectDescriptor ::=
+ [UNIVERSAL 7]
+ IMPLICIT GraphicString
+
+END
+
+%{
+
+#ifndef PEPSY_VERSION
+
+PEPYPARM NullParm = (PEPYPARM) 0;
+
+#endif
+
+%}
diff --git a/src/isode/pepsy/configure.in b/src/isode/pepsy/configure.in
new file mode 100644
index 000000000..cdff2db09
--- /dev/null
+++ b/src/isode/pepsy/configure.in
@@ -0,0 +1,2 @@
+AC_INIT(configure.in)
+AC_OUTPUT(Makefile)
diff --git a/src/isode/pepsy/dec.c b/src/isode/pepsy/dec.c
new file mode 100644
index 000000000..85845ce7a
--- /dev/null
+++ b/src/isode/pepsy/dec.c
@@ -0,0 +1,2154 @@
+/* dec.c */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:30:23 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:18:50 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:39:04 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:42:52 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "pepsy-driver.h"
+#include "psap.h"
+#include "pepsy.h"
+#include "tailor.h"
+
+extern int pepsylose ();
+
+extern tpe *next_tpe(), *fdflt_b();
+
+#define NEXT_TPE(p) (p = next_tpe(p))
+#define CHKTAG(mod, p, pe) ismatch(p, mod, pe->pe_class, pe->pe_id)
+
+
+static char oomsg[] = "Out of memory";
+#define oom(a,b) pepsylose ((a), (b), NULLPE, oomsg)
+
+static char inpmsg[] = "Illegal Null Pointer";
+#define inpm(a,b) pepsylose ((a), (b), NULLPE, inpmsg)
+
+static PE setpresent();
+
+#define F_CI 0x100 /* called internally */
+
+/* Have we got an optional object which we have allocated space for */
+#define ALLOC_MEM(p, parm) (p->pe_type == SOBJECT \
+ && p[-1].pe_type == MEMALLOC)
+
+static int pr_obj();
+static int pr_type();
+static int pr_seq();
+static int pr_set();
+static int pr_seqof();
+static int pr_setof();
+static int pr_choice();
+static int pr_etype();
+static int setdval();
+static int fix_mem();
+
+/*
+ * decode the specified type of the specified module into the given
+ * pe
+ */
+dec_f(typ, mod, pe, explicit, len, buf, parm)
+/* ARGSUSED */
+int typ; /* which type it is */
+modtyp *mod; /* Module it is from */
+PE pe;
+int explicit;
+int *len;
+char **buf;
+char **parm;
+{
+ tpe *p;
+ int iflag; /* are we called internally ? */
+
+ if (typ < 0 || typ >= mod->md_nentries) {
+ return (pepsylose (mod, NULLTPE, NULLPE, "dec_f: Illegal typ %d", typ));
+ }
+
+ p = mod->md_dtab[typ];
+ if (p->pe_type != PE_START) {
+ return (pepsylose (mod, NULLTPE, NULLPE, "dec_f: missing PE_START"));
+ }
+ p++;
+ iflag = explicit & F_CI;
+ explicit &= ~F_CI;
+ if (!iflag)
+ *parm = NULLCP; /* initialise this for the MALLOCs that follow */
+
+ if (pr_obj(explicit, pe, parm, p, mod) == NOTOK)
+ goto bad;
+
+ return (OK);
+bad:
+ return (NOTOK);
+}
+
+/*
+ * Parse an object. The top level of an object does not have any
+ * offset field which makes it different to pr_type routine which
+ * must assume that it has an offset.
+ */
+static int
+pr_obj(expl, pe, parm, p, mod)
+int expl; /* do we look at the tag */
+PE pe;
+char **parm;
+tpe *p;
+modtyp *mod; /* Module it is from */
+{
+ int cnt = 0;
+
+
+ DLOG (psap_log, LLOG_DEBUG, ("1st Decoding the type %d", p->pe_type));
+
+ while (p->pe_type != PE_END) {
+
+ if (ISDTYPE(p) && expl && CHKTAG(mod, p, pe) == 0) {
+ if (DEFAULT(p))
+ return pepsylose (mod, p, pe,
+ "pr_obj:Default not implemented");
+ else if (OPTIONAL(p)) {
+ if (ALLOC_MEM(p, parm))
+ fix_mem(parm, p);
+ goto next;
+ } else
+ return pepsylose (mod, p, pe, "pr_obj:missing mandatory parameter");
+ }
+ DLOG (psap_log, LLOG_DEBUG, ("2nd Decoding the type %d", p->pe_type));
+
+ switch (p->pe_type) {
+ case PE_END:
+ case PE_START:
+ return pepsylose (mod, p, pe, "pr_obj:illegal END/START");
+
+ /*
+ * This allows Functions to be called at the very end of the
+ * decoding -- With the decoded data - I hope - very messy
+ */
+ case UCODE:
+ if (mod->md_ducode == NULLIFP
+ || (*mod->md_ducode) (parm, pe, p, 0) == NOTOK)
+ goto bad;
+ break;
+
+
+ default:
+ if (pr_type(expl, pe, parm, p, mod) == NOTOK)
+ goto bad;
+ break;
+ }
+ if (ISDTYPE(p) && cnt > 0)
+ return pepsylose (mod, p, NULLPE, "pr_obj:compound type found");
+next:
+ if (NEXT_TPE(p) == NULLTPE)
+ goto bad;
+ }
+
+ return (OK);
+
+bad:
+ return (NOTOK);
+}
+
+/*
+ * Parse a single type. If a basic type parse it, if a compound type
+ * call the appropriate parsing routine
+ */
+static int
+pr_type(expl, pe, parm, p, mod)
+int expl; /* do we look at the tag */
+PE pe;
+char **parm;
+tpe *p;
+modtyp *mod; /* Module it is from */
+{
+ int cnt = 0;
+ int len;
+ OID oid;
+ char *nparm;
+ /* there is no such pointer as &(*parm + p->pe_ucode) (ucode non zero) so
+ * we fudge it by making a temporary one. As no memory needs to be
+ * allocated through it this should work
+ */
+
+
+ DLOG (psap_log, LLOG_DEBUG, ("pr_type:type %d", p->pe_type));
+
+ while (p->pe_type != PE_END) {
+
+ if (ISDTYPE(p) && expl && CHKTAG(mod, p, pe) == 0) {
+ if (DEFAULT(p)) {
+ if (setdval(p, FDFLT_B(p), parm, mod) == NOTOK)
+ goto bad;
+ return (NO_DATA_USED);
+ } else if (OPTIONAL(p)) {
+ if (ALLOC_MEM(p, parm))
+ fix_mem(parm, p);
+ return (NO_DATA_USED);
+ } else
+ return pepsylose (mod, p, pe,
+ "pr_type:missing mandatory parameter");
+ }
+ DLOG (psap_log, LLOG_DEBUG, ("pr_type: type %d", p->pe_type));
+
+ switch (p->pe_type) {
+ case PE_END:
+ case PE_START:
+ return pepsylose (mod, p, pe, "pr_type:illegal END/START");
+
+ case BOPTIONAL:
+ if (CHKTAG(mod, p + 1, pe) == 0) {
+ if (ALLOC_MEM(p, parm))
+ fix_mem(parm, p);
+ if (IF_USELECT(p)) {
+ if (p -> pe_ucode >= 0 &&
+ (mod -> md_ducode == NULLIFP ||
+ (*mod->md_ducode)(parm, pe, p, 0) == NOTOK))
+ goto bad;
+ }
+ else CLR_OPT_PRESENT(p, parm);
+ return (NO_DATA_USED);
+ }
+ if (IF_USELECT(p)) {
+ if (p -> pe_ucode >= 0 &&
+ (mod -> md_ducode == NULLIFP ||
+ (*mod->md_ducode)(parm, pe, p, 1) == NOTOK))
+ goto bad;
+ }
+ else
+ SET_OPT_PRESENT(p, parm);
+ p++;
+ continue;
+
+ case FREE_ONLY: /* the next entry(s) only for freeing routines
+ * so skip this and next entry
+ */
+ break;
+
+ case FFN_CALL: /* call function to free - skip this here */
+ break;
+
+ case UCODE:
+ if (mod->md_ducode == NULLIFP
+ || (*mod->md_ducode) (parm, pe, p, 0) == NOTOK)
+ goto bad;
+ break;
+
+ case ETAG:
+ switch (p->pe_ucode) {
+ default:
+ p++;
+ if (pr_etype(pe->pe_cons, parm, p, mod) == NOTOK)
+ return (NOTOK);
+ }
+ break;
+
+ case MEMALLOC:
+ if (*parm)
+ break; /* already allocated */
+ if ((*(parm) = (char *) calloc(1, (unsigned ) p->pe_tag)) == NULL)
+ return oom(mod, p);
+ break;
+
+ /* The difference between here and the en_type makes me think
+ * that this is never called for SEQ_START ????
+ */
+ case SSEQ_START:
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (pr_seq(pe, &nparm, p, mod) == NOTOK)
+ goto bad;
+ } else if (pr_seq(pe, parm, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SEQ_START:
+ if (pr_seq(pe, (char **) (*parm + p->pe_ucode), p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SSEQOF_START:
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (pr_seqof(pe, &nparm, p, mod) == NOTOK)
+ goto bad;
+ } else if (pr_seqof(pe, parm, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SEQOF_START:
+ if (pr_seqof(pe, (char **) (*parm + p->pe_ucode), p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SSET_START:
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (pr_set(pe, &nparm, p, mod) == NOTOK)
+ goto bad;
+ } else if (pr_set(pe, parm, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SET_START:
+ if (pr_set(pe, (char **) (*parm + p->pe_ucode), p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SSETOF_START:
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (pr_setof(pe, &nparm, p, mod) == NOTOK)
+ goto bad;
+ } else if (pr_setof(pe, parm, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SETOF_START:
+ if (pr_setof(pe, (char **) (*parm + p->pe_ucode), p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case IMP_OBJ:
+ p++;
+ if (p->pe_type == EXTOBJ) {
+ if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0|F_CI, (int *)0,
+ (char **) 0, (char **) (*parm + p->pe_ucode)) == NOTOK)
+ goto bad;
+ } else if (p->pe_type == SEXTOBJ) {
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0|F_CI, (int *)0,
+ (char **) 0, (char **) &nparm) == NOTOK)
+ goto bad;
+ } else if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0|F_CI, (int *)0,
+ (char **) 0, (char **) parm) == NOTOK)
+ goto bad;
+ } else {
+ if (p->pe_type == SOBJECT) {
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (pr_obj(0, pe, &nparm, mod->md_dtab[p->pe_tag] + 1, mod)
+ == NOTOK)
+ goto bad;
+ } else if (pr_obj(0, pe, parm, mod->md_dtab[p->pe_tag] + 1, mod)
+ == NOTOK)
+ goto bad;
+ } else if (pr_obj(0, pe, (char **) (*parm + p->pe_ucode),
+ mod->md_dtab[p->pe_tag] + 1, mod) == NOTOK)
+ goto bad;
+ }
+ break;
+
+ case SOBJECT:
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (pr_obj(expl, pe, &nparm, mod->md_dtab[p->pe_tag] + 1, mod)==NOTOK)
+ goto bad;
+ } else if (pr_obj(expl, pe, parm, mod->md_dtab[p->pe_tag] + 1, mod)==NOTOK)
+ goto bad;
+ break;
+
+ case OBJECT:
+
+ if (pr_obj(expl, pe, (char **) (*parm + p->pe_ucode),
+ mod->md_dtab[p->pe_tag] + 1, mod)==NOTOK)
+ goto bad;
+ break;
+
+ case SCHOICE_START:
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (pr_choice(pe, &nparm, p, mod) == NOTOK)
+ goto bad;
+ } else if (pr_choice(pe, parm, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case CHOICE_START:
+ if (pr_choice(pe, parm, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SEXTOBJ:
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ if (p[1].pe_type != EXTMOD)
+ return pepsylose (mod, p, pe, "pr_type: missing EXTMOD");
+ nparm = *parm + p->pe_ucode;
+ if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 1|F_CI, (int *)0,
+ (char **) 0, &nparm) == NOTOK)
+ goto bad;
+ } else if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 1|F_CI, (int *)0,
+ (char **) 0, parm) == NOTOK)
+ goto bad;
+ break;
+
+ case EXTOBJ:
+ if (p[1].pe_type != EXTMOD)
+ return pepsylose (mod, p, pe, "pr_type: missing EXTMOD");
+ if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 1|F_CI, (int *)0,
+ (char **) 0, (char **) (*parm + p->pe_ucode)) == NOTOK)
+ goto bad;
+ break;
+
+ case INTEGER:
+ if (pe != NULLPE) {
+ DLOG (psap_log, LLOG_DEBUG, ("pr_type:integer %d",
+ prim2num(pe)));
+ if (((*(integer *) (*parm + p->pe_ucode)) = prim2num(pe))
+ == NOTOK && pe->pe_errno != PE_ERR_NONE)
+ return pepsylose (mod, p, pe, "pr_type:bad integer %s",
+ pe_error(pe->pe_errno));
+ }
+ break;
+
+#ifdef PEPSY_REALS
+ case REALTYPE:
+ if (pe != NULLPE) {
+ DLOG (psap_log, LLOG_DEBUG, ("pr_type:Real %g",
+ prim2real(pe)));
+
+ if (((*(double *) (*parm + p->pe_ucode)) = prim2real(pe))
+ == NOTOK && pe->pe_errno != PE_ERR_NONE)
+ return pepsylose (mod, p, pe, "pr_type:bad real %s",
+ pe_error(pe->pe_errno));
+ }
+ break;
+
+#endif
+
+ case BOOLEAN:
+ if (pe != NULLPE) {
+ int i;
+
+ DLOG (psap_log, LLOG_DEBUG, ("boolean %d",
+ prim2flag(pe)));
+ if ((i = prim2flag (pe)) == NOTOK)
+ return pepsylose (mod, p, pe, "pr_type:bad integer %s",
+ pe_error(pe->pe_errno));
+ *(char *) (*parm + p->pe_ucode) = i & 0xff;
+ }
+ break;
+
+ case T_NULL:
+ break;
+
+ case SANY:
+ if (pe != NULLPE) {
+ ((*(PE *) (parm + p->pe_ucode)) = pe)->pe_refcnt++;
+ if (pe->pe_errno != PE_ERR_NONE)
+ return pepsylose (mod, p, pe, "pr_type:bad ANY %s",
+ pe_error(pe->pe_errno));
+ }
+ break;
+
+ case ANY:
+ if (pe != NULLPE) {
+ (*(PE *) (*parm + p->pe_ucode) = pe)->pe_refcnt++;
+ if (pe->pe_errno != PE_ERR_NONE)
+ return pepsylose(mod, p, pe, "pr_type:bad ANY %s",
+ pe_error(pe->pe_errno));
+ }
+ break;
+
+ case SOCTETSTRING:
+ if (pe != NULLPE) {
+ if ((*((struct qbuf **) (parm + p->pe_ucode)) = prim2qb(pe)) ==
+ (struct qbuf *) NULL && pe->pe_errno != PE_ERR_NONE)
+ return pepsylose(mod, p, pe, "pr_type:bad octet string %s",
+ pe_error(pe->pe_errno));
+ }
+ break;
+
+ case OCTETSTRING:
+ if (pe != NULLPE) {
+ if ((*((struct qbuf **) (*parm + p->pe_ucode))
+ = prim2qb(pe)) == (struct qbuf *) NULL
+ && pe->pe_errno != PE_ERR_NONE)
+ return pepsylose (mod, p, pe,
+ "pr_type:bad octet string %s",
+ pe_error(pe->pe_errno));
+ }
+ break;
+
+ case T_STRING:
+ if ((*((char **) (*parm + p->pe_ucode)) = prim2str(pe, &len))
+ == NULLCP && pe->pe_errno != PE_ERR_NONE)
+ return pepsylose (mod, p, pe, "pr_type:bad octet string %s",
+ pe_error(pe->pe_errno));
+ /* undocumented feature of prim2str that it adds a NULL char
+ * to the end of the string
+ */
+ break;
+
+ case BITSTR_PTR:
+ if (p[1].pe_type != BITSTR_LEN)
+ return pepsylose (mod, &p[1], NULLPE,
+ "pr_type: missing BITSTR_PTR");
+
+ pe = prim2bit(pe);
+ if ((*((char **) (*parm + p->pe_ucode)) =
+ bitstr2strb(pe, (int *)(*parm + (p + 1)->pe_ucode)))
+ == NULLCP && pe->pe_errno != PE_ERR_NONE)
+ return pepsylose (mod, p, pe, "pr_type:bad bit string %s",
+ pe_error(pe->pe_errno));
+ break;
+
+
+ case OCTET_PTR:
+ if (p[1].pe_type != OCTET_LEN)
+ return pepsylose (mod, &p[1], NULLPE,
+ "pr_type: missing OCTET_PTR");
+ if ((*((char **) (*parm + p->pe_ucode)) =
+ prim2str(pe, (int *)(*parm + (p + 1)->pe_ucode)))
+ == NULLCP && pe->pe_errno != PE_ERR_NONE)
+ return pepsylose (mod, p, pe, "pr_type:bad octet string %s",
+ pe_error(pe->pe_errno));
+ break;
+
+
+ case SBITSTRING:
+ if (pe != NULLPE) {
+ if ((*((PE *) (parm + p->pe_ucode)) = prim2bit(pe_cpy(pe))) == NULLPE)
+ return pepsylose (mod, p, pe, "pr_type:out of memory");
+ }
+ break;
+
+ case BITSTRING:
+ if (pe != NULLPE) {
+ if ((*((PE *) (*parm + p->pe_ucode)) =
+ prim2bit(pe_cpy(pe))) == NULLPE)
+ return pepsylose(mod, p, pe, "pr_type:out of memory");
+ }
+ break;
+
+ case SOBJID:
+ /*
+ * This is messy because ISODE's library routine uses a
+ * static. Don't know why they do
+ */
+ if ((oid = prim2oid(pe + p->pe_ucode)) == NULLOID
+ || (*(OID *) parm = oid_cpy(oid)) == NULLOID) {
+ if (oid && oid->oid_elements) {
+ free((char *) oid->oid_elements);
+ oid->oid_elements = NULL;
+ }
+ return pepsylose (mod, p, pe,
+ "pr_type:Object Identifier: out of memory");
+ }
+ if (oid && oid->oid_elements) {
+ free((char *) oid->oid_elements);
+ oid->oid_elements = NULL;
+ }
+ break;
+
+ case OBJID:
+ if ((oid = prim2oid(pe)) == NULLOID
+ || (*(OID *) (*parm + p->pe_ucode) = oid_cpy(oid)) == NULLOID) {
+ if (oid && oid->oid_elements) {
+ free((char *) oid->oid_elements);
+ oid->oid_elements = NULL;
+ }
+ return pepsylose (mod, p, pe,
+ "pr_type:Object Identifier: out of memory");
+ }
+ if (oid && oid->oid_elements) {
+ free((char *) oid->oid_elements);
+ oid->oid_elements = NULL;
+ }
+ break;
+
+ case FN_CALL:
+ if ((FN_PTR(mod, p))(parm, pe) == NOTOK)
+ return pepsylose (mod, p, NULLPE,
+ "pr_type:FN_CALL:call failed");
+ break;
+
+ default:
+ return pepsylose (mod, p, pe, "pr_type: type not implemented");
+ }
+ if (ISDTYPE(p) && cnt > 0)
+ return pepsylose (mod, p, pe, "pr_type:compound type found");
+
+ if (ISDTYPE(p) && pe != NULLPE)
+ return (OK);
+ if (NEXT_TPE(p) == NULLTPE)
+ goto bad;
+ }
+
+ return (OK);
+
+bad:
+ return (NOTOK);
+}
+
+/*
+ * Parse a sequence, calling appropriate routines to parse each sub
+ * type
+ */
+static int
+pr_seq(head, parm, p, mod)
+PE head;
+char **parm;
+tpe *p;
+modtyp *mod; /* Module it is from */
+{
+ PE pe;
+ int *popt = NULL; /* Pointer to optional field */
+ int optcnt = 0; /* Number of optionals bits so far */
+ char *nparm;
+
+ if (p->pe_type != SEQ_START && p->pe_type != SSEQ_START)
+ return pepsylose (mod, p, head, "pr_seq: missing SEQ_START");
+ p++;
+
+ if (p->pe_type == DFLT_B)
+ p++;
+
+ pe = first_member(head);
+ while (p->pe_type != PE_END) {
+ DLOG (psap_log, LLOG_DEBUG, ("pr_seq:type %d", p->pe_type));
+
+ if (ISDTYPE(p) && OPTIONAL(p)) {
+ switch (p->pe_type) {
+ case INTEGER:
+ case REALTYPE:
+ case BOOLEAN:
+ case T_NULL:
+ basictype:
+ if (pe == NULLPE || CHKTAG(mod, p, pe) == 0) {
+ optcnt++;
+ goto next;
+ }
+ SETBIT(*popt, optcnt++);
+ break;
+
+ case ETAG: /* XXX ? optional things in seq's? */
+ switch (p[1].pe_type) {
+ case INTEGER:
+ case REALTYPE:
+ case BOOLEAN:
+ case T_NULL:
+ goto basictype;
+ }
+ /* else fall through... */
+
+ default:
+ if (pe == NULLPE || CHKTAG(mod, p, pe) == 0) {
+ if (ALLOC_MEM(p, parm))
+ fix_mem(parm, p);
+ goto next;
+ }
+ break;
+ }
+ } else if (ISDTYPE(p) && (pe == NULLPE || CHKTAG(mod, p, pe) == 0)) {
+ if (DEFAULT(p)) {
+ if(setdval(p, FDFLT_B(p), parm, mod) == NOTOK)
+ goto bad;
+ goto next;
+ } else
+ return pepsylose (mod, p, pe,
+ "pr_seq:missing mandatory parameter");
+ }
+ switch (p->pe_type) {
+ case OPTL:
+ popt = (int *) (*parm + p->pe_ucode);
+ break;
+
+ case FREE_ONLY: /* the next entry(s) only for freeing routines
+ * so skip this and next entry
+ */
+ break;
+
+ case FFN_CALL: /* call function to free - skip this here */
+ break;
+
+ case UCODE:
+ if (mod->md_ducode == NULLIFP
+ || (*mod->md_ducode) (parm, pe, p, 0) == NOTOK)
+ goto bad;
+ break;
+
+ case BOPTIONAL:
+ if (pe == NULLPE || CHKTAG(mod, p + 1, pe) == 0) {
+ if (ALLOC_MEM(p, parm))
+ fix_mem(parm, p);
+ if (IF_USELECT(p)) {
+ if (p -> pe_ucode >= 0 &&
+ (mod -> md_ducode == NULLIFP ||
+ (*mod->md_ducode)(parm, pe, p, 0) == NOTOK))
+ goto bad;
+ }
+ else CLR_OPT_PRESENT(p, parm);
+ goto next;
+ }
+ if (IF_USELECT(p)) {
+ if (p -> pe_ucode >= 0 &&
+ (mod -> md_ducode == NULLIFP ||
+ (*mod->md_ducode)(parm, pe, p, 1) == NOTOK))
+ goto bad;
+ }
+ else SET_OPT_PRESENT(p, parm);
+ p++;
+ continue;
+
+ case ETAG:
+ if (pr_type(1, pe, parm, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case MEMALLOC:
+ if (*parm)
+ break; /* already allocated */
+ if ((*(parm) = (char *) calloc(1, (unsigned ) p->pe_tag))==NULLCP)
+ return oom(mod, p);
+ break;
+
+ case SEQ_START:
+ if (pr_seq(pe, (char **) (*parm + p->pe_ucode), p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SEQOF_START:
+ if (pr_seqof(pe, (char **) (*parm + p->pe_ucode), p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SET_START:
+ if (pr_set(pe, (char **) (*parm + p->pe_ucode), p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SETOF_START:
+ if (pr_setof(pe, (char **) (*parm + p->pe_ucode), p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case IMP_OBJ:
+ p++;
+ if (p->pe_type == EXTOBJ) {
+ if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0|F_CI, (int *)0,
+ (char **) 0, (char **) (*parm + p->pe_ucode)) == NOTOK)
+ goto bad;
+ } else if (p->pe_type == SEXTOBJ) {
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0|F_CI, (int *)0,
+ (char **) 0, (char **) &nparm) == NOTOK)
+ goto bad;
+ } else if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0|F_CI, (int *)0,
+ (char **) 0, (char **) parm) == NOTOK)
+ goto bad;
+ } else {
+ if (p->pe_type == SOBJECT) {
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (pr_obj(0, pe, &nparm, mod->md_dtab[p->pe_tag] + 1, mod)
+ == NOTOK)
+ goto bad;
+ } else
+ if (pr_obj(0, pe, parm, mod->md_dtab[p->pe_tag] + 1, mod)
+ == NOTOK)
+ goto bad;
+ } else if (pr_obj(0, pe, (char **) (*parm + p->pe_ucode),
+ mod->md_dtab[p->pe_tag] + 1, mod) == NOTOK)
+ goto bad;
+ }
+ break;
+
+ case SOBJECT:
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (pr_obj(1, pe, &nparm, mod->md_dtab[p->pe_tag] + 1, mod) == NOTOK)
+ goto bad;
+ } else if (pr_obj(1, pe, parm, mod->md_dtab[p->pe_tag] + 1, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case OBJECT:
+ if (pr_obj(1, pe, (char **) (*parm + p->pe_ucode),
+ mod->md_dtab[p->pe_tag] + 1, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SCHOICE_START:
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (pr_choice(pe, &nparm, p, mod) == NOTOK)
+ goto bad;
+ } else if (pr_choice(pe, parm, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case CHOICE_START:
+ if (pr_choice(pe, (char **) (*parm + p->pe_ucode), p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SEXTOBJ:
+ if (p[1].pe_type != EXTMOD)
+ return pepsylose (mod, p, pe, "pr_seq: missing EXTMOD");
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 1|F_CI, (int *) 0,
+ (char **) 0, &nparm) == NOTOK)
+ goto bad;
+ } else if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 1|F_CI, (int *) 0,
+ (char **) 0, parm) == NOTOK)
+ goto bad;
+ break;
+
+ case EXTOBJ:
+ if (p[1].pe_type != EXTMOD)
+ return pepsylose (mod, p, pe, "pr_seq: missing EXTMOD");
+
+ if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 1|F_CI, (int *) 0,
+ (char **) 0, (char **) (*parm + p->pe_ucode)) == NOTOK)
+ goto bad;
+ break;
+
+ default:
+ /* only called if we have a match */
+ if (pr_type(1, pe, parm, p, mod) == NOTOK)
+ goto bad;
+ break;
+ }
+
+ if (ISDTYPE(p) && pe != NULLPE)
+ pe = next_member(head, pe);
+next:
+ if (NEXT_TPE(p) == NULLTPE)
+ goto bad;
+ }
+
+ return (OK);
+
+bad:
+ return (NOTOK);
+}
+
+
+/*
+ * Parse a set, calling appropriate routines to parse each sub type
+ */
+static int
+pr_set(head, parm, p, mod)
+PE head;
+char **parm;
+tpe *p;
+modtyp *mod; /* Module it is from */
+{
+ PE pe;
+ int *popt = NULL; /* Pointer to optional field */
+ int optcnt = 0; /* Number of optionals bits so far */
+ char *nparm;
+
+ if (p->pe_type != SET_START && p->pe_type != SSET_START)
+ return pepsylose (mod, p, NULLPE, "pr_seq: missing SET_START");
+ p++;
+
+ if (p->pe_type == DFLT_B)
+ p++;
+
+ while (p->pe_type != PE_END) {
+ DLOG (psap_log, LLOG_DEBUG, ("pr_set type %d", p->pe_type));
+
+ if (ISDTYPE(p) && OPTIONAL(p)) {
+ switch (p->pe_type) {
+ case INTEGER:
+ case REALTYPE:
+ case BOOLEAN:
+ case T_NULL:
+ if ((pe = setpresent(head, p, mod)) == NULLPE) {
+ optcnt++;
+ goto next;
+ }
+ SETBIT(*popt, optcnt++);
+ break;
+
+
+ default:
+ if ((pe = setpresent(head, p, mod)) == NULLPE) {
+ if (ALLOC_MEM(p, parm))
+ fix_mem(parm, p);
+ goto next;
+ }
+ break;
+ }
+ } else if (ISDTYPE(p) && (pe = setpresent(head, p, mod)) == NULLPE) {
+ if (DEFAULT(p)) {
+ if (setdval(p, FDFLT_B(p), parm, mod) == NOTOK)
+ goto bad;
+ goto next;
+ } else
+ return pepsylose (mod, p, pe,
+ "pr_set:missing mandatory parameter");
+ }
+ switch (p->pe_type) {
+ case OPTL:
+ popt = (int *) (*parm + p->pe_ucode);
+ break;
+
+ case FREE_ONLY: /* the next entry(s) only for freeing routines
+ * so skip this and next entry
+ */
+ break;
+
+ case FFN_CALL: /* call function to free - skip this here */
+ break;
+
+ case UCODE:
+ if (mod->md_ducode == NULLIFP
+ || (*mod->md_ducode) (parm, pe, p, 0) == NOTOK)
+ goto bad;
+ break;
+
+ case BOPTIONAL:
+ if ((pe = setpresent(head, p + 1, mod)) == NULLPE) {
+ if (ALLOC_MEM(p, parm))
+ fix_mem(parm, p);
+ if (IF_USELECT(p)) {
+ if (p -> pe_ucode >= 0 &&
+ (mod -> md_ducode == NULLIFP ||
+ (*mod->md_ducode)(parm, pe, p, 0) == NOTOK))
+ goto bad;
+ }
+ else CLR_OPT_PRESENT(p, parm);
+ goto next;
+ }
+ if (IF_USELECT(p)) {
+ if (p -> pe_ucode >= 0 &&
+ (mod -> md_ducode == NULLIFP ||
+ (*mod->md_ducode)(parm, pe, p, 1) == NOTOK))
+ goto bad;
+ }
+ else SET_OPT_PRESENT(p, parm);
+ p++;
+ continue;
+
+ case ETAG:
+ if (pr_type(1, pe, parm, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case MEMALLOC:
+ if (*parm)
+ break; /* already allocated */
+ if ((*(parm) = (char *) calloc(1, (unsigned ) p->pe_tag))==NULLCP)
+ return oom(mod, p);
+ break;
+
+ case SEQ_START:
+ if (pr_seq(pe, (char **) (*parm + p->pe_ucode), p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SEQOF_START:
+ if (pr_seqof(pe, (char **) (*parm + p->pe_ucode), p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SET_START:
+ if (pr_set(pe, (char **) (*parm + p->pe_ucode), p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SETOF_START:
+ if (pr_setof(pe, (char **) (*parm + p->pe_ucode), p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case IMP_OBJ:
+ p++;
+ if (p->pe_type == EXTOBJ) {
+ if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0|F_CI, (int *) 0,
+ (char **) 0, (char **) (*parm + p->pe_ucode)) == NOTOK)
+ goto bad;
+ } else if (p->pe_type == SEXTOBJ) {
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0|F_CI, (int *) 0,
+ (char **) 0, (char **) &nparm) == NOTOK)
+ goto bad;
+ } else if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0|F_CI, (int *) 0,
+ (char **) 0, (char **) parm) == NOTOK)
+ goto bad;
+ } else {
+ if (p->pe_type == SOBJECT) {
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (pr_obj(0, pe, &nparm, mod->md_dtab[p->pe_tag] + 1, mod)
+ == NOTOK)
+ goto bad;
+ } else if (pr_obj(0, pe, parm, mod->md_dtab[p->pe_tag] + 1, mod)
+ == NOTOK)
+ goto bad;
+ } else if (pr_obj(0, pe, (char **) (*parm + p->pe_ucode),
+ mod->md_dtab[p->pe_tag] + 1, mod) == NOTOK)
+ goto bad;
+ }
+ break;
+
+ case SOBJECT:
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (pr_obj(1, pe, &nparm, mod->md_dtab[p->pe_tag] + 1, mod)== NOTOK)
+ goto bad;
+ } else if (pr_obj(1, pe, parm, mod->md_dtab[p->pe_tag] + 1, mod)== NOTOK)
+ goto bad;
+ break;
+
+ case OBJECT:
+ if (pr_obj(1, pe, (char **) (*parm + p->pe_ucode),
+ mod->md_dtab[p->pe_tag] + 1, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SCHOICE_START:
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (pr_choice(pe, &nparm, p, mod) == NOTOK)
+ goto bad;
+ } else if (pr_choice(pe, parm, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case CHOICE_START:
+ if (pr_choice(pe, (char **) (*parm + p->pe_ucode), p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SEXTOBJ:
+ if (p[1].pe_type != EXTMOD)
+ return pepsylose (mod, p, pe, "pr_set: missing EXTMOD");
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 1|F_CI, (int *) 0,
+ (char **) 0, &nparm) == NOTOK)
+ goto bad;
+ } else if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 1|F_CI, (int *) 0,
+ (char **) 0, parm) == NOTOK)
+ goto bad;
+ break;
+
+ case EXTOBJ:
+ if (p[1].pe_type != EXTMOD)
+ return pepsylose (mod, p, pe, "pr_set: missing EXTMOD");
+
+ if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 1|F_CI, (int *) 0,
+ (char **) 0, (char **) (*parm + p->pe_ucode)) == NOTOK)
+ goto bad;
+ break;
+
+ default:
+ if (pr_type(1, pe, parm, p, mod) == NOTOK)
+ goto bad;
+ break;
+ }
+
+next:
+ if (NEXT_TPE(p) == NULLTPE)
+ goto bad;
+ }
+
+ return (OK);
+
+bad:
+ return (NOTOK);
+
+}
+
+
+/*
+ * Parse a sequence of calling appropriate routines to parse each sub
+ * type
+ */
+static int
+pr_seqof(head, parm, p, mod)
+PE head;
+char **parm;
+tpe *p;
+modtyp *mod; /* Module it is from */
+{
+ PE pe;
+ tpe *start; /* first entry in list */
+ int dflt = 0;
+ char *nparm;
+
+ if (p->pe_type != SEQOF_START && p->pe_type != SSEQOF_START)
+ return pepsylose (mod, p, head, "pr_seqof:missing SEQOF_START");
+
+ p++;
+
+ if (p->pe_type == DFLT_B)
+ p++;
+
+ start = p;
+
+ pe = first_member(head);
+ while (pe != NULLPE) {
+ while (p->pe_type != PE_END) {
+
+ DLOG (psap_log, LLOG_DEBUG, ("pr_seqof type %d", p->pe_type));
+
+ if (ISDTYPE(p) && CHKTAG(mod, p, pe) == 0) {
+ if (DEFAULT(p)) {
+ if (setdval(p, FDFLT_B(p), parm, mod) == NOTOK)
+ goto bad;
+ goto next;
+ } else if (OPTIONAL(p)) {
+ if (ALLOC_MEM(p, parm))
+ fix_mem(parm, p);
+ goto next;
+ } else
+ return pepsylose (mod, p, pe,
+ "pr_seqof:missing mandatory parameter");
+ }
+ switch (p->pe_type) {
+ case FREE_ONLY: /* the next entry(s) only for freeing routines
+ * so skip this and next entry
+ */
+ break;
+
+ case FFN_CALL: /* call function to free - skip this here */
+ break;
+
+ case UCODE:
+ if (mod->md_ducode == NULLIFP
+ || (*mod->md_ducode) (parm, pe, p, 0) == NOTOK)
+ goto bad;
+ break;
+
+ case BOPTIONAL:
+ if (pe == NULLPE || CHKTAG(mod, p + 1, pe) == 0) {
+ if (ALLOC_MEM(p, parm))
+ fix_mem(parm, p);
+ if (IF_USELECT(p)) {
+ if (p -> pe_ucode >= 0 &&
+ (mod -> md_ducode == NULLIFP ||
+ (*mod->md_ducode)(parm, pe, p, 0) == NOTOK))
+ goto bad;
+ }
+ else CLR_OPT_PRESENT(p, parm);
+ goto next;
+ }
+ if (IF_USELECT(p)) {
+ if (p -> pe_ucode >= 0 &&
+ (mod -> md_ducode == NULLIFP ||
+ (*mod->md_ducode)(parm, pe, p, 1) == NOTOK))
+ goto bad;
+ }
+ else SET_OPT_PRESENT(p, parm);
+ p++;
+ continue;
+
+ case ETAG:
+ if (pr_type(1, pe, parm, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case MEMALLOC:
+ if (*parm)
+ break; /* already allocated */
+ if ((*(parm) = (char *) calloc(1, (unsigned ) p->pe_tag))
+ == NULLCP)
+ return oom(mod, p);
+ break;
+
+ case SCTRL:
+ parm = (char **) ((char *) *parm + p->pe_ucode);
+ break;
+
+ case SEQ_START:
+ if (pr_seq(pe, (char **) (*parm + p->pe_ucode), p, mod) ==NOTOK)
+ goto bad;
+ break;
+
+ case SEQOF_START:
+ if (pr_seqof(pe, (char **) (*parm + p->pe_ucode), p,mod)==NOTOK)
+ goto bad;
+ break;
+
+ case SET_START:
+ if (pr_set(pe, (char **) (*parm + p->pe_ucode), p, mod) ==NOTOK)
+ goto bad;
+ break;
+
+ case SETOF_START:
+ if (pr_setof(pe, (char **)(*parm + p->pe_ucode), p, mod)==NOTOK)
+ goto bad;
+ break;
+
+ case SOBJECT:
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (pr_obj(1,pe, &nparm, mod->md_dtab[p->pe_tag]+1, mod)==NOTOK)
+ goto bad;
+ } else if (pr_obj(1,pe, parm, mod->md_dtab[p->pe_tag]+1, mod)==NOTOK)
+ goto bad;
+ break;
+
+ case OBJECT:
+ if (pr_obj(1, pe, (char **) (*parm + p->pe_ucode),
+ mod->md_dtab[p->pe_tag] + 1, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SCHOICE_START:
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (pr_choice(pe, &nparm, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case CHOICE_START:
+ if (pr_choice(pe, (char **)(*parm + p->pe_ucode), p,mod)==NOTOK)
+ goto bad;
+ break;
+
+ case SEXTOBJ:
+ if (p[1].pe_type != EXTMOD)
+ return pepsylose (mod, p, pe, "pr_seqof: missing EXTMOD");
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 1|F_CI, (int *) 0,
+ (char **) 0, &nparm) == NOTOK)
+ goto bad;
+ } else if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 1|F_CI, (int *) 0,
+ (char **) 0, parm) == NOTOK)
+ goto bad;
+ break;
+
+ case EXTOBJ:
+ if (p[1].pe_type != EXTMOD)
+ return pepsylose (mod, p, pe, "pr_seqof: missing EXTMOD");
+
+ if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 1|F_CI, (int *) 0,
+ (char **) 0, (char **) (*parm + p->pe_ucode)) == NOTOK)
+ goto bad;
+ break;
+
+ default:
+ if (pr_type(1, pe, parm, p, mod) == NOTOK)
+ goto bad;
+ break;
+ }
+
+ if (ISDTYPE(p) && dflt == 0)
+ pe = next_member(head, pe);
+ next:
+ if (NEXT_TPE(p) == NULLTPE)
+ goto bad;
+ }
+ parm = (char **) (*parm + p->pe_ucode);
+ p = start;
+ }
+
+ return (OK);
+
+bad:
+ return (NOTOK);
+}
+
+/*
+ * Parse a setof, calling appropriate routines to parse each sub type
+ */
+static int
+pr_setof(head, parm, p, mod)
+PE head;
+char **parm;
+tpe *p;
+modtyp *mod; /* Module it is from */
+{
+ PE pe;
+ tpe *start;
+ char *nparm;
+
+ if (p->pe_type != SETOF_START && p->pe_type != SSETOF_START)
+ return pepsylose(mod, p, head, "pr_setof: missing SETOF_START");
+ p++;
+
+ if (p->pe_type == DFLT_B)
+ p++;
+
+ start = p;
+ pe = first_member(head);
+
+ for (pe = first_member(head); pe; pe = next_member(head, pe)) {
+ while (p->pe_type != PE_END) {
+ DLOG (psap_log, LLOG_DEBUG, ("pr_setof type %d", p->pe_type));
+
+ if (pe == NULLPE || CHKTAG(mod, p, pe) == 0) {
+ if (DEFAULT(p)) {
+ if (setdval(p, FDFLT_B(p), parm, mod) == NOTOK)
+ goto bad;
+ goto next;
+ } else
+ return pepsylose (mod, p, pe,
+ "pr_setof:missing mandatory parameter");
+ }
+
+ switch (p->pe_type) {
+ case FREE_ONLY: /* the next entry(s) only for freeing routines
+ * so skip this and next entry
+ */
+ break;
+
+ case FFN_CALL: /* call function to free - skip this here */
+ break;
+
+ case UCODE:
+ if (mod->md_ducode == NULLIFP
+ || (*mod->md_ducode) (parm, pe, p, 0) == NOTOK)
+ goto bad;
+ break;
+
+ case BOPTIONAL:
+ if ((pe = setpresent(head, p + 1, mod)) == NULLPE) {
+ if (ALLOC_MEM(p, parm))
+ fix_mem(parm, p);
+ if (IF_USELECT(p)) {
+ if (p -> pe_ucode >= 0 &&
+ (mod -> md_ducode == NULLIFP ||
+ (*mod->md_ducode)(parm, pe, p, 0) == NOTOK))
+ goto bad;
+ }
+ else CLR_OPT_PRESENT(p, parm);
+ goto next;
+ }
+ if (IF_USELECT(p)) {
+ if (p -> pe_ucode >= 0 &&
+ (mod -> md_ducode == NULLIFP ||
+ (*mod->md_ducode)(parm, pe, p, 1) == NOTOK))
+ goto bad;
+ }
+ else SET_OPT_PRESENT(p, parm);
+ p++;
+ continue;
+
+ case ETAG:
+ if (pr_type(1, pe->pe_cons, parm, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case MEMALLOC:
+ if (*parm)
+ break; /* already allocated */
+ if ((*(parm) = (char *) calloc(1, (unsigned )p->pe_tag))
+ == NULLCP)
+ return oom(mod, p);
+ break;
+
+ case SCTRL:
+ parm = (char **) (*parm + p->pe_ucode);
+ break;
+
+ case SEQ_START:
+ if (pr_seq(pe, (char **) (*parm + p->pe_ucode), p, mod) ==NOTOK)
+ goto bad;
+ break;
+
+ case SEQOF_START:
+ if (pr_seqof(pe, (char **)(*parm + p->pe_ucode), p, mod)==NOTOK)
+ goto bad;
+ break;
+
+ case SET_START:
+ if (pr_set(pe, (char **) (*parm + p->pe_ucode), p, mod) ==NOTOK)
+ goto bad;
+ break;
+
+ case SETOF_START:
+ if (pr_setof(pe, (char **)(*parm + p->pe_ucode), p, mod)==NOTOK)
+ goto bad;
+ break;
+
+ case SOBJECT:
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (pr_obj(1, pe, &nparm, mod->md_dtab[p->pe_tag]+1, mod)==NOTOK)
+ goto bad;
+ } else if (pr_obj(1, pe, parm, mod->md_dtab[p->pe_tag]+1, mod)==NOTOK)
+ goto bad;
+ break;
+
+ case OBJECT:
+ if (pr_obj(1, pe, (char **) (*parm + p->pe_ucode),
+ mod->md_dtab[p->pe_tag] + 1, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SCHOICE_START:
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (pr_choice(pe, &nparm, p, mod) == NOTOK)
+ goto bad;
+ } else if (pr_choice(pe, parm, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case CHOICE_START:
+ if (pr_choice(pe, (char **)(*parm + p->pe_ucode), p,mod)==NOTOK)
+ goto bad;
+ break;
+
+ case SEXTOBJ:
+ if (p[1].pe_type != EXTMOD)
+ return pepsylose (mod, p, pe, "pr_setof: missing EXTMOD");
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 1|F_CI,
+ (int *) 0, (char **) 0, &nparm) == NOTOK)
+ goto bad;
+ } else if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 1|F_CI,
+ (int *) 0, (char **) 0, parm) == NOTOK)
+ goto bad;
+ break;
+
+ case EXTOBJ:
+ if (p[1].pe_type != EXTMOD)
+ return pepsylose (mod, p, pe, "pr_setof: missing EXTMOD");
+ if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 1|F_CI,
+ (int *) 0, (char **) 0, (char **) (*parm + p->pe_ucode)) == NOTOK)
+ goto bad;
+ break;
+
+ default:
+ if (pr_type(1, pe, parm, p, mod) == NOTOK)
+ goto bad;
+ break;
+ }
+
+ next:
+ if (NEXT_TPE(p) == NULLTPE)
+ goto bad;
+ }
+ parm = (char **) (*parm + p->pe_ucode);
+ p = start;
+ }
+
+ return (OK);
+
+bad:
+ return (NOTOK);
+}
+
+/*
+ * parse a choice field. This means find which choice is taken
+ */
+static int
+pr_choice(head, parm, p, mod)
+PE head;
+char **parm;
+tpe *p;
+modtyp *mod; /* Module it is from */
+{
+ int *poffset;
+ int cnt;
+ tpe *savep = NULLTPE;
+
+ if (p->pe_type != CHOICE_START && p->pe_type != SCHOICE_START)
+ return pepsylose (mod, p, head, "pr_choice:missing CHOICE_START");
+
+ p++;
+
+ if (p->pe_type == DFLT_B)
+ p++;
+
+ if (p->pe_type == MEMALLOC) {
+ if (*parm == NULLCP) {
+ /* not already allocated */
+ if ((*(parm) = (char *) calloc(1,(unsigned )p->pe_tag))==NULLCP)
+ return oom(mod, p);
+ }
+ p++;
+ }
+ if (p->pe_type == SCTRL) {
+ if (IF_USELECT(p)) {
+ savep = p;
+ } else if ((poffset = (int *) (*parm + p->pe_ucode)) == NULL)
+ goto bad;
+ p++;
+ }
+ for (cnt = 1; p->pe_type != PE_END; NEXT_TPE(p)) {
+ if (ISDTYPE(p)) {
+ if (ismatch(p, mod, head->pe_class, head->pe_id)) {
+ if (!savep && poffset)
+ *poffset = cnt;
+ if (pr_etype(head, parm, p, mod) == NOTOK)
+ goto bad;
+ if (savep) {
+ if (savep -> pe_ucode >= 0 &&
+ (mod -> md_ducode == NULLIFP ||
+ (*mod -> md_ducode)(parm, head, savep, cnt) == NOTOK))
+ goto bad;
+ }
+ NEXT_TPE(p);
+ if (p->pe_type == UCODE) {
+ if (mod->md_ducode == NULLIFP
+ || (*mod->md_ducode) (parm, head, p, 0) == NOTOK)
+ return (NOTOK);
+ }
+ return (OK);
+ }
+ cnt++;
+ }
+ }
+ (void) pepsylose(mod, p, head, "pr_choice: no choice taken");
+bad:
+ return (NOTOK);
+}
+
+/*
+ * Parse a single type for explicit tag If a basic type parse it, if
+ * a compound type call the appropriate parsing routine
+ */
+static int
+pr_etype(pe, parm, p, mod)
+PE pe;
+char **parm;
+tpe *p;
+modtyp *mod; /* Module it is from */
+{
+ int cnt;
+ char *nparm;
+
+ switch (p->pe_type) {
+ case PE_END:
+ case PE_START:
+ return pepsylose (mod, p, pe, "pr_etype:illegal END/START");
+
+ case FREE_ONLY: /* the next entry(s) only for freeing routines
+ * so skip this and next entry
+ */
+ break;
+
+ case FFN_CALL: /* call function to free - skip this here */
+ break;
+
+ case UCODE:
+ if (mod->md_ducode == NULLIFP
+ || (*mod->md_ducode) (parm, pe, p, 0) == NOTOK)
+ goto bad;
+ break;
+
+ case BOPTIONAL:
+ return pepsylose (mod, p, pe, "pr_etype:illegal BOPTIONAL");
+
+ case ETAG:
+ switch (p->pe_ucode) {
+
+ default:
+ p++;
+ if (pr_etype(pe->pe_cons, parm, p, mod) == NOTOK)
+ goto bad;
+ }
+ break;
+
+ case MEMALLOC:
+ if (*parm)
+ break; /* already allocated */
+ if ((*(parm) = (char *) calloc(1, (unsigned ) p->pe_tag)) == NULLCP)
+ return oom(mod, p);
+ break;
+
+ case SEQ_START:
+ if (pr_seq(pe, (char **) (*parm + p->pe_ucode), p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SSEQOF_START:
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (pr_seqof(pe, &nparm, p, mod) == NOTOK)
+ goto bad;
+ } else if (pr_seqof(pe, parm, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SEQOF_START:
+ if (pr_seqof(pe, (char **) (*parm + p->pe_ucode), p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SSEQ_START:
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (pr_seq(pe, &nparm, p, mod) == NOTOK)
+ goto bad;
+ } else if (pr_seq(pe, parm, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SET_START:
+ if (pr_set(pe, (char **) (*parm + p->pe_ucode), p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SSET_START:
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (pr_set(pe, &nparm, p, mod) == NOTOK)
+ goto bad;
+ } else if (pr_set(pe, parm, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SETOF_START:
+ if (pr_setof(pe, (char **) (*parm + p->pe_ucode), p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SSETOF_START:
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (pr_setof(pe, &nparm, p, mod) == NOTOK)
+ goto bad;
+ } else if (pr_setof(pe, parm, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case IMP_OBJ:
+ p++;
+ if (p->pe_type == EXTOBJ) {
+ if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0|F_CI, (int *) 0,
+ (char **) 0, (char **) (*parm + p->pe_ucode)) == NOTOK)
+ goto bad;
+ } else if (p->pe_type == SEXTOBJ) {
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0|F_CI, (int *) 0,
+ (char **) 0, (char **) &nparm) == NOTOK)
+ goto bad;
+ } else if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0|F_CI, (int *) 0,
+ (char **) 0, (char **) parm) == NOTOK)
+ goto bad;
+ } else {
+ if (p->pe_type == SOBJECT) {
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (pr_obj(0, pe, (char **)&nparm, mod->md_dtab[p->pe_tag]+1, mod)==NOTOK)
+ goto bad;
+ } else if (pr_obj(0, pe, (char **)parm, mod->md_dtab[p->pe_tag]+1, mod)==NOTOK)
+ goto bad;
+ } else if (pr_obj(0, pe, (char **) (*parm + p->pe_ucode),
+ mod->md_dtab[p->pe_tag] + 1, mod) == NOTOK)
+ goto bad;
+ }
+ break;
+
+ case SOBJECT:
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (pr_obj(1, pe, &nparm, mod->md_dtab[p->pe_tag] + 1, mod) == NOTOK)
+ goto bad;
+ } else if (pr_obj(1, pe, parm, mod->md_dtab[p->pe_tag] + 1, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case OBJECT:
+ if (pr_obj(1, pe, (char **) (*parm + p->pe_ucode),
+ mod->md_dtab[p->pe_tag] + 1, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SCHOICE_START:
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (pr_choice(pe, &nparm, p, mod) == NOTOK)
+ goto bad;
+ } else if (pr_choice(pe, parm, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case CHOICE_START:
+ if (pr_choice(pe, (char **) (*parm + p->pe_ucode), p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SEXTOBJ:
+ if (p[1].pe_type != EXTMOD)
+ return pepsylose (mod, p, pe, "pr_etype: missing EXTMOD");
+ if (p->pe_ucode > 0) {
+ if (*parm == NULLCP)
+ return inpm(mod, p);
+ nparm = *parm + p->pe_ucode;
+ if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 1|F_CI, (int *) 0,
+ (char **) 0, &nparm) == NOTOK)
+ goto bad;
+ } else if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 1|F_CI, (int *) 0,
+ (char **) 0, parm) == NOTOK)
+ goto bad;
+ break;
+
+ case EXTOBJ:
+ if (p[1].pe_type != EXTMOD)
+ return pepsylose (mod, p, pe, "pr_etype: missing EXTMOD");
+
+ if (dec_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 1|F_CI, (int *) 0,
+ (char **) 0, (char **) (*parm + p->pe_ucode)) == NOTOK)
+ goto bad;
+ break;
+
+ case INTEGER:
+ if (pe != NULLPE) {
+ DLOG (psap_log, LLOG_DEBUG, ("pr_etype:integer %d", prim2num(pe)));
+
+ if (((*(integer *)(*parm + p->pe_ucode)) = prim2num(pe)) == NOTOK &&
+ pe->pe_errno != PE_ERR_NONE)
+ return pepsylose (mod, p, pe, "pr_etype:bad integer %s",
+ pe_error(pe->pe_errno));
+ }
+ break;
+
+#ifdef PEPSY_REALS
+ case REALTYPE:
+ if (pe != NULLPE) {
+ DLOG (psap_log, LLOG_DEBUG, ("pr_etype:Real %g", prim2real(pe)));
+
+ if (((*(double *) (*parm + p->pe_ucode)) = prim2real(pe))
+ == NOTOK && pe->pe_errno != PE_ERR_NONE)
+ return pepsylose (mod, p, pe, "pr_etype:bad real %s",
+ pe_error(pe->pe_errno));
+ }
+ break;
+
+#endif
+
+ case BOOLEAN:
+ if (pe != NULLPE) {
+ int i;
+
+ DLOG(psap_log, LLOG_DEBUG, ("pr_etype:boolean %d", prim2flag(pe)));
+
+ if ((i = prim2flag (pe)) == NOTOK)
+ return pepsylose (mod, p, pe, "pr_etype:bad integer %s",
+ pe_error(pe->pe_errno));
+ (*(char *) (*parm + p->pe_ucode)) = i & 0xff;
+ }
+ break;
+
+ case T_NULL:
+ break;
+
+ case ANY:
+ if (pe != NULLPE) {
+ (*(PE *) (*parm + p->pe_ucode) = pe)->pe_refcnt++;
+ if (pe->pe_errno != PE_ERR_NONE)
+ return pepsylose (mod, p, pe, "pr_etype:bad ANY %s",
+ pe_error(pe->pe_errno));
+ }
+ break;
+
+ case SANY:
+ if (pe != NULLPE) {
+ (*(PE *) (parm + p->pe_ucode) = pe) -> pe_refcnt++;
+ if (pe->pe_errno != PE_ERR_NONE)
+ return pepsylose (mod, p, pe, "pr_etype:bad ANY %s",
+ pe_error(pe->pe_errno));
+ }
+ break;
+
+ case SOCTETSTRING:
+ if (pe != NULLPE) {
+ if ((*((struct qbuf **) (parm + p->pe_ucode))
+ = prim2qb(pe)) == (struct qbuf *) NULL
+ && pe->pe_errno != PE_ERR_NONE)
+ return pepsylose (mod, p, pe, "pr_etype:bad octet string %s",
+ pe_error(pe->pe_errno));
+ }
+ break;
+
+ case OCTETSTRING:
+ if (pe != NULLPE) {
+ if ((*((struct qbuf **) (*parm + p->pe_ucode))
+ = prim2qb(pe)) == (struct qbuf *) NULL
+ && pe->pe_errno != PE_ERR_NONE)
+ return pepsylose (mod, p, pe, "pr_etype:bad octet string %s",
+ pe_error(pe->pe_errno));
+ }
+ break;
+
+ case T_STRING:
+ if ((*((char **) (*parm + p->pe_ucode)) = prim2str(pe, &cnt))
+ == NULLCP && pe->pe_errno != PE_ERR_NONE)
+ return pepsylose (mod, p, pe, "pr_type:bad octet string %s",
+ pe_error(pe->pe_errno));
+ /* undocumented feature of prim2str that it adds a NULL char
+ * to the end of the string
+ */
+ break;
+
+ case OCTET_PTR:
+ if (p[1].pe_type != OCTET_LEN)
+ return pepsylose (mod, &p[1], NULLPE,"pr_etype: missing OCTET_PTR");
+ if ((*((char **) (*parm + p->pe_ucode)) =
+ prim2str(pe, (int *)(*parm + (p + 1)->pe_ucode)))
+ == NULLCP && pe->pe_errno != PE_ERR_NONE)
+ return pepsylose (mod, p, pe, "pr_etype:bad octet string %s",
+ pe_error(pe->pe_errno));
+ break;
+
+ case BITSTR_PTR:
+ if (p[1].pe_type != BITSTR_LEN)
+ return pepsylose (mod, &p[1], NULLPE,
+ "pr_etype: missing BITSTR_PTR");
+ pe = prim2bit(pe);
+ if ((*((char **) (*parm + p->pe_ucode)) =
+ bitstr2strb(pe, (int *)(*parm + (p + 1)->pe_ucode)))
+ == NULLCP && pe->pe_errno != PE_ERR_NONE)
+ return pepsylose (mod, p, pe, "pr_etype:bad bit string %s",
+ pe_error(pe->pe_errno));
+ break;
+
+ case SBITSTRING:
+ if (pe != NULLPE) {
+ if (((*(PE *) (parm + p->pe_ucode)) = prim2bit(pe_cpy(pe))) == NULLPE)
+ return pepsylose (mod, p, pe, "pr_etype:out of memory");
+ }
+ break;
+
+ case BITSTRING:
+ if (pe != NULLPE) {
+ if ((*((PE *) (*parm + p->pe_ucode)) = prim2bit(pe_cpy(pe))) == NULLPE)
+ return pepsylose (mod, p, pe, "pr_etype:out of memory");
+ }
+ break;
+
+ case SOBJID:
+ if ((*(OID *) (parm + p->pe_ucode) = oid_cpy(prim2oid(pe))) == NULLOID)
+ return pepsylose (mod, p, pe, "pr_etype:OID: out of memory");
+ break;
+
+ case OBJID:
+ if ((*(OID *) (*parm + p->pe_ucode) = oid_cpy(prim2oid(pe))) == NULLOID)
+ return pepsylose (mod, p, pe, "en_etype:OID: out of memory");
+ break;
+
+ case FN_CALL:
+ if ((FN_PTR(mod, p))(parm, pe) == NOTOK)
+ return pepsylose (mod, p, NULLPE, "pr_etype:FN_CALL:call failed");
+ break;
+
+ default:
+ return pepsylose(mod, p, pe,
+ "pr_etype: %d not implemented", p->pe_type);
+ }
+
+ return (OK);
+bad:
+ return (NOTOK);
+}
+
+
+/*
+ * determine if the given field is present in the data This is simple
+ * if the field is a simple type with an obvious tag but in the case
+ * of an object or a CHOICE type the tag is not obvious. If the
+ * object is a CHOICE there are more than one possible tag that could
+ * match and in this case we must try to match each one of them.
+ */
+static PE
+setpresent(head, p, mod)
+PE head;
+tpe *p;
+modtyp *mod;
+{
+ PE pe;
+ modtyp *nmod;
+
+ while (!ISDTYPE(p) && p->pe_type != PE_END) {
+ p++;
+ }
+ if (!ISDTYPE(p) || p->pe_type == PE_END)
+ return (NULLPE);
+
+ switch (p->pe_type) {
+ case EXTOBJ:
+ case SEXTOBJ:
+ /* Needs to be changed for optional and default */
+ nmod = EXT2MOD(mod, (p + 1));
+ return (setpresent(head, p = nmod->md_dtab[p->pe_tag] + 1, nmod));
+
+ case OBJECT:
+ case SOBJECT:
+ /* Needs to be changed for optional and default */
+ return (setpresent(head, p = mod->md_dtab[p->pe_tag] + 1, mod));
+
+ case SCHOICE_START:
+ case CHOICE_START:
+ for (p++; p && p->pe_type != PE_END; p = NEXT_TPE(p)) {
+ if (!ISDTYPE(p))
+ continue;
+ if ((pe = setpresent(head, p, mod)))
+ return (pe);
+ }
+ return (NULLPE);
+
+ default:
+ return (set_find(head, CLASS(p), TAG(p)));
+ }
+}
+
+/*
+ * set the default value to that value in the structure
+ */
+static int
+setdval(typ, dflt, parm, mod)
+tpe *typ, *dflt;
+char **parm;
+modtyp *mod;
+{
+ char *p;
+ integer i;
+ int no; /* number of octets */
+ char *nparm;
+
+again:
+ switch (typ->pe_type) {
+ case MEMALLOC:
+ if (*parm)
+ break; /* already allocated */
+
+ if ((*(parm) = (char *) calloc(1, (unsigned ) typ->pe_tag)) == NULL) {
+ (void) pepsylose (mod, typ, NULLPE,
+ "setdval:calloc failed on %d", typ->pe_tag);
+ return NOTOK;
+ }
+ /* fall through and do the same stuff as for ETAG */
+
+ case ETAG:
+ typ++;
+ goto again;
+
+ case INTEGER:
+ *(integer *) (*parm + typ->pe_ucode) = IVAL(mod, dflt);
+ break;
+
+#ifdef PEPSY_REALS
+ case REALTYPE:
+ *(double *) (*parm + typ->pe_ucode) = RVAL(mod, dflt);
+ break;
+#endif
+
+ case BOOLEAN:
+ *(char *) (*parm + typ->pe_ucode) = IVAL(mod, dflt);
+ break;
+
+ case T_NULL:
+ /* Only one value */
+ break;
+
+ case SBITSTRING:
+ *(PE *) (parm + typ->pe_ucode) = strb2bitstr(PVAL(mod, dflt), (int )IVAL(mod, dflt), 0, 0);
+ break;
+
+ case BITSTRING:
+ *(PE *) (*parm + typ->pe_ucode) =
+ strb2bitstr(PVAL(mod, dflt), (int )IVAL(mod, dflt), 0, 0);
+ break;
+
+ case SOCTETSTRING:
+ *(struct qbuf **) (parm + typ->pe_ucode) = str2qb(PVAL(mod, dflt),
+ (int )IVAL(mod, dflt), 1);
+ break;
+
+ case OCTETSTRING:
+ *(struct qbuf **) (*parm + typ->pe_ucode) =
+ str2qb(PVAL(mod, dflt), (int )IVAL(mod, dflt), 1);
+ break;
+
+ case T_STRING:
+ *(char **) (*parm + typ->pe_ucode) = strdup(PVAL(mod, dflt));
+ break;
+
+ case OCTET_PTR:
+ if (typ[1].pe_type != OCTET_LEN)
+ return pepsylose (mod, typ, NULLPE, "setdval:missing OCTET_LEN");
+ i = IVAL(mod, dflt);
+ p = smalloc((int )i + 1);
+ bcopy(PVAL(mod, dflt), p, (int )i);
+ p[i] = '\0';
+ *(char **) (*parm + typ->pe_ucode) = p;
+ *(int *) (*parm + (typ + 1)->pe_ucode) = i;
+ break;
+
+ case BITSTR_PTR:
+ if (typ[1].pe_type != BITSTR_LEN)
+ return pepsylose (mod, typ, NULLPE, "setdval:missing BITSTR_LEN");
+ i = IVAL(mod, dflt);
+ no = (i + 7)/8; /* round up */
+ p = smalloc(no + 1);
+ bcopy(PVAL(mod, dflt), p, no);
+ p[no] = '\0';
+ *(char **) (*parm + typ->pe_ucode) = p;
+ *(int *) (*parm + (typ + 1)->pe_ucode) = i;
+ break;
+
+ case OBJECT:
+ if (setdval(mod->md_dtab[typ->pe_tag] + 1, dflt,
+ (char **) (*parm + typ->pe_ucode), mod) == NOTOK)
+ return NOTOK;
+ break;
+
+ case SOBJECT:
+ if (typ->pe_ucode > 0) {
+ nparm = *parm + typ->pe_ucode;
+ if (setdval(mod->md_dtab[typ->pe_tag] + 1, dflt, &nparm, mod) == NOTOK)
+ return NOTOK;
+ } else if (setdval(mod->md_dtab[typ->pe_tag] + 1, dflt, parm, mod) == NOTOK)
+ return NOTOK;
+ break;
+
+ case IMP_OBJ:
+ typ++;
+
+ case ANY:
+ case SANY:
+ case SEXTOBJ:
+ case EXTOBJ:
+ case OBJID:
+ case SOBJID:
+ case SEQ_START:
+ case SET_START:
+ case -1: /* Just use the pepy method of null
+ * pointers */
+ /*
+ * This is the posy/pepy hack way of doing things at the
+ * moment
+ */
+ *(char **) (*parm + typ->pe_ucode) = NULL;
+ break;
+
+ case FN_CALL:
+ if ((FN_PTR(mod, typ))(parm, NULLPE) == NOTOK)
+ return pepsylose (mod, typ, NULLPE,
+ "setdval:FN_CALL:call failed");
+ break;
+
+ default:
+ /*
+ * dmp_tpe("setdval: type not implemented", typ, mod); - need
+ * mod
+ */
+ (void) pepsylose(mod, typ, NULLPE,
+ "setdval: %d not implemented", typ->pe_type);
+ return NOTOK;
+ }
+ return OK;
+}
+/*
+ * fix up the allocation of memory. We have allocated memory for an
+ * optional object that is not present. ISODE routines get upset if
+ * this is present because it then believes the object is present and
+ * tries to process it ...
+ */
+static int
+fix_mem(parm, p)
+char **parm;
+tpe *p;
+{
+ if (p->pe_type != SOBJECT || p[-1].pe_type != MEMALLOC
+ || p[1].pe_type != PE_END)
+ SLOG (psap_log, LLOG_EXCEPTIONS, NULLCP, ("fix_mem:inconsistency"));
+ if (*parm)
+ free(*parm);
+ *parm = NULL;
+}
diff --git a/src/isode/pepsy/dfns.c b/src/isode/pepsy/dfns.c
new file mode 100644
index 000000000..cf72afc87
--- /dev/null
+++ b/src/isode/pepsy/dfns.c
@@ -0,0 +1,248 @@
+/* dfns.c */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:30:26 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:18:53 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:39:07 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:42:53 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+#include <stdio.h>
+#include "general.h"
+#include "mine.h"
+#include "pepsydefs.h"
+#include "pass2.h"
+
+id_entry *id_table[TABLESIZE];
+
+#define my_error(mesg) (fprintf(stderr, "%s\n",mesg),exit(1))
+
+extern char *notidtoid(), *my_new_str(), *my_strcat();
+extern char *
+proc_name(), *mymodule;
+
+/*
+ * Lookup the hash table (id_table) for the string t and insert it at
+ * the start of the appropriate chain if it is not already there.
+ * The argument flag indicates whether t is being defined (1) or used
+ * (0).
+ */
+char *
+proc_name(t, flag)
+char *t;
+int flag;
+{
+ int i;
+ static int curr = 0;
+ id_entry *ptr;
+
+ i = hash_val(t);
+ for (ptr = id_table[i]; ptr != NULL && strcmp(t, ptr->h_value); ptr = ptr->next);
+
+ if (ptr == NULL) {
+ if ((ptr = (id_entry *) malloc(sizeof(id_entry))) == NULL)
+ my_error("proc_name: Out of memory");
+ ptr->h_value = t;
+ ptr->r_value = my_strcat(notidtoid(t), notidtoid(mymodule));
+ ptr->count = 1;
+ if (flag) {
+ ptr->def_bit = flag;
+ ptr->def_value = curr++;
+ }
+ ptr->next = id_table[i];
+ id_table[i] = ptr;
+ } else if (!ptr->def_bit)
+ ptr->def_bit = flag;
+
+ return ptr->r_value;
+}
+
+/*
+ * output a sequence of #define statements (one for each value stored
+ * in the hash table) to the file specified by fp
+ */
+out_final_defs(fp)
+FILE *fp;
+{
+ int j;
+ id_entry *ptr;
+
+ for (j = 0; j < TABLESIZE; j++)
+ for (ptr = id_table[j]; ptr != NULL; ptr = ptr->next) {
+ if (ptr->def_bit)
+ (void) fprintf(fp, "#define %s%s\t%d\n", PREFIX, ptr->r_value, ptr->def_value);
+ else
+ ferrs(0, "the identifier %s is used but not defined\n", ptr->h_value);
+ if (ptr->count > 1) /* not used */
+ (void) printf("The id %s has a count of %d\n", ptr->r_value, ptr->count);
+ }
+}
+
+/*
+ * return a copy of the string s with '-' replaced by '_'
+ */
+char *
+notidtoid(s)
+char *s;
+{
+
+ char *t, *r;
+
+ t = my_new_str(s);
+ for (r = t; *r != '\0'; r++)
+ if (*r == '-')
+ *r = '_';
+ return t;
+}
+
+/*
+ * return a copy of the string s
+ */
+char *
+my_new_str(s)
+char *s;
+{
+
+ char *t;
+
+ if ((t = (char *) malloc((unsigned)strlen(s) + 1)) == NULL)
+ my_error("my_new_str: Out of memory");
+
+ (void) strcpy(t, s);
+ return t;
+}
+
+/*
+ * return the concatenation of the strings s1 and s2
+ */
+char *
+my_strcat(s1, s2)
+char *s1, *s2;
+{
+ char *s3, *s, *t;
+
+ if (s1 == NULL || *s1 == '\0')
+ return my_new_str(s2);
+
+ if ((s3 = (char *) malloc((unsigned)(strlen(s1) + strlen(s2) + 1))) == NULL)
+ my_error("my_strcat: Out of memory");
+
+ for (s = s1, t = s3; *s != '\0'; s++, t++)
+ *t = *s;
+ (void) strcpy(t, s2);
+ return s3;
+}
+
+/*
+ * a simple hash function
+ */
+hash_val(s)
+char *s;
+{
+ int i, sum;
+ char *t;
+
+ sum = 0;
+ for (i = 1, t = s; *t != '\0'; i++, t++)
+ sum = sum + *t * i;
+ return (sum % TABLESIZE);
+}
+
+/*
+ * initialize the table id_table
+ */
+init()
+{
+ int i;
+
+ for (i = 0; i <= TABLESIZE; i++)
+ id_table[i] = NULL;
+}
+#define BUFSIZE 128
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+
+static char *buf = NULL;
+static unsigned int len = 0;
+
+/*
+ * Return in a static buffer the two strings concatenated
+ */
+char *
+concat(s1, s2)
+char *s1, *s2;
+{
+ int tot;
+
+ tot = strlen(s1) + strlen(s2) + 1;
+
+ if (tot > len) {
+ len = MAX(BUFSIZE, tot);
+ if (buf == NULL) {
+ if ((buf = malloc(len)) == NULL)
+ ferr(1, "concat:malloc failed\n");
+ } else if ((buf = realloc(buf, len)) == NULL)
+ ferr(1, "concat:realloc failed\n");
+ }
+ (void) strcpy(buf, s1);
+ (void) strcat(buf, s2);
+
+ return (buf);
+}
+
+/*
+ * Generate a free call given the name of the parameter, the module
+ * name, and the name of the type
+ */
+char *
+gfree(module, id, parm)
+char *module; /* name of module we are in (usually
+ * mymodule) */
+char *id; /* name of type we want to free */
+char *parm; /* name of the pointer to the data */
+{
+ char *p1 = notidtoid(module);
+ char *p2 = notidtoid(id);
+
+ if (buf == NULL) {
+ if ((buf = malloc(BUFSIZE)) == NULL)
+ ferr(1, "gfree:malloc failed\n");
+ len = BUFSIZ;
+ }
+ (void) sprintf(buf, "(void) fre_obj((char *) %s, %s%s%s.md_dtab[%s%s%s], &%s%s%s, 1)",
+ parm,
+ PREFIX, p1, MODTYP_SUFFIX,
+ PREFIX, p2, p1,
+ PREFIX, p1, MODTYP_SUFFIX);
+ free(p1);
+ free(p2);
+
+ return (buf);
+}
diff --git a/src/isode/pepsy/doc/DESCRIPTION b/src/isode/pepsy/doc/DESCRIPTION
new file mode 100644
index 000000000..2f861f526
--- /dev/null
+++ b/src/isode/pepsy/doc/DESCRIPTION
@@ -0,0 +1,1056 @@
+
+
+
+
+
+
+_1. _O_v_e_r_v_i_e_w _o_f _p_e_p_s_y _s_y_s_t_e_m
+
+ This section describes how the various parts fit
+together to make the system work. The principle behind
+pepsy is fairly simple. The ASN.1 is summarised as tables
+of integers. These tables are read by driver routines which
+encode or decode data to or from the internal format that
+ISODE OSI implementation uses. In ISODE specific functions
+are generated for each ASN.1 type defined in contrast the
+pepsy merely generates a new table of data which is far far
+smaller.
+
+ As there is a great deal of effort invested in the
+ISODE interface to the encoding/decoding routines pepsy
+automatically provides macros which map the original func-
+tions into the appropriate function call of a driver. This
+allows existing posy using code to switch to the pepsy sys-
+tem with no changes to the code provided no function
+pointers are used to the original ISODE functions. Even
+when there are function pointers used the changes are very
+simple and take only a few hours to implement.
+
+_1._1. _B_r_i_e_f _d_e_s_c_r_i_p_t_i_o_n _o_f _t_h_e _u_s_e _o_f _t_h_e _p_e_p_s_y _s_y_s_t_e_m.
+
+_1._1._1. _O_u_t_l_i_n_e _o_f _t_h_e _f_i_l_e_s _p_r_o_d_u_c_e_d _u_n_d_e_r _t_h_e _p_e_p_s_y _s_y_s_-
+_t_e_m.
+
+ The pepsy system consists of a program called _p_o_s_y
+which translates ASN.1 modules into a set of tables, called
+_p_o_s_y at the moment, and library of driver routines, called
+_l_i_b_p_e_p_s_y._a. Running this _p_o_s_y program on the ASN.1 file
+will produce several files. If the name of the ASN.1 module
+is MODULE the following files are generated:
+
+MODULE-types.h
+ which contains C structure definitions. The user of
+ the library provides data as a linked list of these C
+ data structures and expects to receive data back as a
+ similar linked list. These data structures are exactly
+ the same as those produced by the original ISODE _p_o_s_y
+ so that existing software written for the old _p_o_s_y pro-
+ gram needs no change. For details on the C data struc-
+ tures types generated see the documentation of the ori-
+ ginal _p_o_s_y program in volume 4 Chapter 5 of the ISODE
+ manuals.
+
+MODULE_tables.c
+ This file contains the tables generated by the new _p_o_s_y
+ program. These tables consist of three parts, the
+ first which contains the summary of ASN.1 types. Each
+ type is summarised as an array of a primitive type,
+ struct pte, for encoding and decoding, and struct ptpe
+ for printing. As implied there is one array for each
+ type for each of encoding, decoding and printing as
+
+
+
+ January 23, 1990
+
+
+
+
+
+ - 2 -
+
+
+ specified when _p_o_s_y is run. The next part contains up
+ to three tables of pointers to these arrays. Each of
+ the three different types of arrays, encoding, decoding
+ and printing, has its own table of pointers. Finally
+ there is the module type definition which contains con-
+ tains pointers to these tables and some other useful
+ information about the module such as its name. This
+ module type structure, which is typedefed to modtyp, is
+ the only piece of data which is global, all the rest of
+ the data is static and is only addressable via the mod-
+ typ data structure. This provides a kind of object
+ oriented approach to handling the tables. Once you are
+ passed a pointer to an ASN.1's modtyp structure you can
+ encode, decode and print any of its types by calling
+ the appropriate libpepsy.a routine with its type
+ number.
+
+MODULE_pre_defs.h
+ This file contains #defines symbol of each of the ASN.1
+ types to its type number, which is used when calling a
+ libpepsy.a routine. Each symbol is _Ztype-nameMODULE
+ where _t_y_p_e-_n_a_m_e is the name of the type with dashes (-)
+ turned into underscores (_) and _M_O_D_U_L_E is the name of
+ the module. For example of the ASN.1 universal type
+ _G_r_a_p_h_i_c_S_t_r_i_n_g would have the #define symbol _ZGra-
+ phicStringUNIV. The __Z is prepended to try to make the
+ symbols unique. This file also contains and extern
+ declaration for the modtyp data for its module.
+
+MODULE_defs.h
+ This file contains macros for all the encoding, decod-
+ ing and printing functions that the _p_e_p_y program would
+ have for these ASN.1 types. This allows much of the
+ code that uses the routines generated by running the
+ old _p_o_s_y program and taking its output and running _p_e_p_y
+ on augmented ASN.1 output can be recompiled unchanged.
+ If the code used pointers to these functions it is
+ necessary to change it to pass around the type numbers
+ instead and to call appropriately call a libpepsy.a
+ library routine with the type number. As pointers to
+ the printing routines in ISODE are passed as arguments
+ a #define is provided to turn the argument into the
+ pair of arguments, type number and pointer to modtyp
+ structure, which are needed to allow the diagnostic
+ printing code to work with no change for the current
+ ISODE stack. This file also contains a #include of the
+ _M_O_D_U_L_E__p_r_e__d_e_f_s._h file.
+
+ As the _M_O_D_U_L_E-_t_y_p_e_s._h file #include's the _M_O_D_U_L_E__d_e_f_s._h
+file no further #includes need to be added to the files
+using the encoding/decoding/printing functions. This means
+that code written to use posy/pepy system may need no change
+at all and the only effort required is to change the
+Makefile to use the pepsy system. If there is code changes
+
+
+
+ January 23, 1990
+
+
+
+
+
+ - 3 -
+
+
+required it would most likely be because function pointers
+are used to reference the functions generated by posy. If
+only the _p_e_p_y system was used, not posy then pepy, with code
+placed inside action statements then quite a large amount of
+work may be needed to change over to the new system, depend-
+ing on how large and complex the _p_e_p_y module is.
+
+_1._1._2. _O_u_t_l_i_n_e _o_f _t_h_e _p_e_p_s_y _l_i_b_r_a_r_y.
+
+enc.cThis contains the routines that encode data from the C
+ data structures into ISODE's PElement linked list data
+ structure which it uses for all presentation data. The
+ most important function to pepsy users is enc_f which
+ called to encode a particular type. It is passed the
+ type number and a pointer to modtyp structure for that
+ module and then the rest of the arguments which are
+ passed to an encode function generated by _p_o_s_y/_p_e_p_y
+ system. See the documentation in Volume 4, "The Appli-
+ cations Cookbook", Section 6.4 called "Pepy Environ-
+ ment". Most of these latter arguments are ignored,
+ only parm and pe, are used.
+
+ Contrary to what the ISODE documentation says these
+ignored parameters are hardly ever used by existing code.
+We have not found a single case where used for encoding a
+named type, which is all that the user can reference anyway,
+so we don't see any problems with ignoring these other
+parameters. Hopefully one day they can be thrown away
+entirely, until then they are actually passed the the encod-
+ing function.
+
+ The rest of the functions are mostly recursive routines
+which encode a particular type of table entry. For example
+SEQUENCE is encoded by en_seq which may call itself or oth-
+ers to encode the types from which it is built up. The
+function en_type builds up a simple type and en_obj encodes
+a new type (object) and so on with other functions. There
+are a few utility routines in the file such as same which
+determines whether the value is the same as the default
+value also.
+
+dec.cThis file contains the decoding routines that translate
+ presentation data into C data structures defined in the
+ MODULE-types.h is like _e_n_c._c. It is very much like the
+ file _e_n_c._c except the routines do the reverse tasks The
+ routines are structured in a very similar way. We have
+ dec_f which is called by the user to decode a type and
+ like enc_f takes the same arguments as the decoding
+ functions generated by _p_o_s_y with two additions, the
+ type number and a pointer to the modtyp structure for
+ that module. Likewise the other functions are very
+ much like those of enc.c
+
+prnt.cThis file contains the routines that print the
+
+
+
+ January 23, 1990
+
+
+
+
+
+ - 4 -
+
+
+ presentation data in a format similar to that generated
+ by _p_e_p_y's printing functions. It's main function
+ prnt_f is takes the same arguments as the printing
+ function generated by _p_e_p_y as well as the now familiar
+ type number and modtyp pointer. The functions are
+ modeled on the decoding routines as it has similar job
+ to. The only difference is that instead of storing the
+ decoded data into a C data structure it is nicely
+ printed out.
+
+fr.c This file contains code to free the data structures
+ defined in MODULE-types.h. Likewise if the -f flag is
+ given when generating the types file it also includes
+ macros in the types file which replace the freeing
+ functions generated by ISODE's _p_o_s_y. The function that
+ the user calls us fre_obj which takes a pointer to the
+ data structure, its decoding table entry and a pointer
+ to the modtyp structure for the module. The freeing is
+ based on the decoding routines except instead of decod-
+ ing all it does is free each part of the data struc-
+ ture, which might involve recursive calls, then it
+ frees the data structure at the end.
+
+util.cThis contains the utility routines used by more than
+ one of the above files. This is mostly diagnostic rou-
+ tines at the moment, more general routines could be
+ included in here. If there is an error at the moment
+ which it can't recover from it just prints out a mes-
+ sage on standard error and calls exit. Not perfect and
+ this is something that will need work.
+
+main.cThis contains code to perform a series of tests on the
+ _p_e_p_s_y library which is a useful check to see whether
+ any of the routines has been broken by any changes
+ made. It basically loops through a whole series of
+ test cases. Each test case is encoded from some built
+ in test data and then decoded and checked to see if the
+ data has changed in the transfer. If it is compiled
+ with -_D_P_R_N_T=_1 the encoded data is also printed out to
+ check the printing routines which generates a vast
+ amount of output. Finally the free routines are used
+ to free the allocated data, although it can not
+ directly check the free routines to see if they work,
+ it can be used with a malloc tracing package to check
+ that the routines work.
+
+test_table.h
+ This contains the test cases that _m_a_i_n._c program runs.
+ Each entry in the table corresponds to a type. One of
+ the fields is count of how many times that type is to
+ be tested to try out the different possibly data values
+ it might have.
+
+pep.h and pepdefs.h
+
+
+
+ January 23, 1990
+
+
+
+
+
+ - 5 -
+
+
+ These files contain the definition of types used for
+ the tables that drive the encoding/decoding/printing
+ routines. All the constants used in that table are
+ defined here via #defines. The modtyp structure is
+ defined in _p_e_p_d_e_f_s._h.
+
+t1.py and t2.py
+ These are test ASN.1 modules that are used by _m_a_i_n._c
+ routines to check the _p_e_p_s_y library. The file _t_1._p_y
+ contains the majority of different types with a few of
+ a different module provided in _t_2._p_y. This allows the
+ testing of the code for handling ASN.1 external refer-
+ ences, i.e. references to types defined in other,
+ external, modules.
+
+_1._1._3. _N_e_w _f_i_l_e_s _i_n _t_h_e _p_e_p_y _d_i_r_e_c_t_o_r_y
+
+etabs.c, dtabs.c and ptabs.c
+ These files contain the code to generate the
+ encoding/decoding/printing tables. The main routine in
+ _e_t_a_b_s._c is tenc_typ which is called on each ASN.1 type
+ to generate an array of entries which describe how to
+ encode that type. See the details section for more
+ information about how the table entries function.
+ Similarly _d_t_a_b_s._c contains the routine tdec_typ which
+ is called on each type to generate its decoding table
+ entries. Likewise tprnt_typ routine generates the
+ arrays of table entries for the printing tables. This
+ function is in _p_t_a_b_s._c.
+
+dfns.cThis file contains miscellaneous string handling rou-
+ tines and hash table routines that don't really belong
+ anywhere else. Some of the routines could be cleaned
+ up in that they tend not to free memory they use.
+
+mine.hThis file contains the definitions for the hash
+ table(s) that are used to keep track of the ASN.1
+ types. This could probably be done with out a hash
+ table, should anyone want to clean this up, feel wel-
+ come. The lookup function is in _d_f_n_s._c.
+
+pass2.h
+ This file has most of the #defines for the table gen-
+ erating program. Most of the prefixes and suffixes of
+ function names and files names are defined here so,
+ hopefully, the names can be changed by merely changing
+ the definition. This contains most of the important
+ definitions needed by the changes to the _p_o_s_y program
+ needed to generate tables.
+
+posy.hThis contains the definition of a symbol which is now
+ needed outside of the the main routine and the yacc
+ file. By putting it here we can include it any file
+ that needs to know it with out putting in any that
+
+
+
+ January 23, 1990
+
+
+
+
+
+ - 6 -
+
+
+ doesn't need it and with out including all the other
+ definitions that occur in _p_e_p_y._h. The structure and
+ meaning of the tables generated from the ASN.1 grammar
+
+ Each collection of ASN.1 grammar is called a module.
+(See ASN.1 ) Each ASN.1 module is completely specified in
+the program by a single C structure of type modtyp and the
+data which it references. See the _p_e_p_d_e_f_s._h file in the
+_p_e_p_s_y directory. For each ASN.1 module there are three
+tables that are generated fromASN.1 grammar. These initial-
+ised arrays which we call tables are called the encoding,
+decoding and printing tables. Each of these tables is
+referenced through a different pointer of the modtyp struc-
+ture.
+
+ Each of these pointers references an array of pointers,
+one pointer for each ASN.1 type defined in the module. The
+position of one of these pointers is the unique type number
+we give to its corresponding type. The pointer references
+an array of type tpe or ptpe, depending whether it is an
+entry in the decoding/encoding tables or printing tables
+respectively. See _p_e_p._h in the _p_e_p_s_y directory. This array
+actually contains the necessary information to
+encode/decode/print that ASN.1 type. So given the modtyp
+structure of an ASN.1 module and its type number you can
+call a routine to encode, decode or print that type.
+
+ The rest of this document assumes a good knowledge of
+ASN.1 notation so go read a copy if you haven't already.
+From here on I shall mention only tpe and this means tpe in
+the case of encoding or decoding and ptpe in the case of
+printing, unless otherwise stated. Each type is represented
+by an array of tpe (or ptpe for printing). The basic ele-
+ment consists of four integer fields, the printing table is
+the same with an addition char pointer field which contains
+the name corresponding to that entry in the ASN.1 grammar.
+The first specifies the type of the entry and determines how
+the rest are interpreted. The possible types are listed in
+_p_e_p_s_y/_p_e_p._h. Each type is an array which starts with an
+entry of type PE_START and ends with one of type PE_END.
+Each primitive type requires one entry to specify it, apart
+from possible PE_START and PE_END used to specify the start
+and end of the type. Constructed types are represented by a
+list of entries terminated by an entry of type PE_END. As
+ASN.1 types can be nested inside so will the representation
+in tpe entries be nested. For example the ASN.1 type defin-
+ition:
+ Example1 ::=
+ SEQUENCE {
+ seq1 SEQUENCE {
+ an-i INTEGER,
+ an-ostring OCTET STRING
+ },
+ a-bool IMPLICIT [0] BOOLEAN
+
+
+
+ January 23, 1990
+
+
+
+
+
+ - 7 -
+
+
+ }
+ Will generate an encoding array:
+static tpe et_Example1Test[] = {
+ { PE_START, 0, 0, 0 },
+ { SEQ_START, 0, 16, FL_UNIVERSAL },
+ { SEQ_START, OFFSET(struct type_Test_Example1, seq1), 16, FL_UNIVERSAL },
+ { INTEGER, OFFSET(struct element_Test_0, an__i), 2, FL_UNIVERSAL },
+ { OCTETSTRING, OFFSET(struct element_Test_0, an__ostring), 4, FL_UNIVERSAL },
+ { PE_END, 0, 0, 0 },
+ { BOOLEAN, OFFSET(struct type_Test_Example1, a__bool), 0, FL_CONTEXT },
+ { PE_END, 0, 0, 0 },
+ { PE_END, 0, 0, 0 }
+ };
+
+
+ Here the second last PE_END matches and closes off the
+first SEQ_START. The entries which correspond to the other
+primative types are pretty obvious, with the INTEGER entry
+corresponding to the primative INTEGER. For fields that
+generate data the general interpretation of the other three
+fields is offset, tag and flags/class fields respectively.
+
+offsetThe second field gives the offset in a C data struc-
+ ture needed to reference the data that corresponds to
+ this table entry. Each ASN.1 type has C structure
+ types generated as described in the ISODE manuals,
+ volume 4 "The applications Cookbook" Section 5.2, "POSY
+ Environment". As this offset may have to be determined
+ in a compiler dependent manner a C preprocessor macro
+ is used hide the actual details.
+
+tag This is the tag associated with the ASN.1 type for that
+ entry. Notice that in the example the [0] IMPLICIT
+ which changes the tag associated with the BOOLEAN entry
+ actually has the correct tag of 0 in the table. Like-
+ wise SEQUENCE has the correct tag of 16 in its
+ SEQ_START entry and so on for the others.
+
+flags/class
+ This contains the ASN.1 class associated with the
+ entry's type. That is UNIVERSAL for all except the
+ BOOLEAN type which is CONTEXT class. This fourth can
+ also contain flags that specify if the type is OPTIONAL
+ or DEFAULT. There is plenty of room here as there is
+ only four possibly classes.
+
+ Now that you have some idea of how these arrays are
+arranged for a type definition I will proceed to go through
+the possible type of entries and describe what they do and
+how they work. These values are defined in _p_e_p_s_y/_p_e_p._h.
+Those entries with a value below TYPE_DATA are entries that
+don't correspond to data to be encoded/decoded and are for
+other book keeping type purposes.
+
+
+
+
+ January 23, 1990
+
+
+
+
+
+ - 8 -
+
+
+PE_START and PE_END
+ As explained above PE_START starts the beginning of a
+ ASN.1 type's array. It probably isn't necessary but
+ the size of the tables is so small it isn't much of an
+ over head to keep around for cosmetic reasons. The
+ entry type PE_END is necessary to mark the end of some
+ compound type as well as the end of ASN.1 data type.
+
+XOBJECT and UCODE
+ These are obsolete types and probably should be
+ removed. They were to allow C code written directly by
+ the user to be incorporated into the encoding/decoding
+ but it was found unnecessary. Prehaps some brave soul
+ would like to use them in an attempt to implement a
+ similar system based on _p_e_p_y which is what we first
+ attempted to do until we found this to be much easier.
+
+MALLOCThis field only occurs in the decoding tables. It
+ specifies how much space to malloc out for the current
+ C structure it is just inside of. For instance in the
+ example above the decoding table has the following
+ entry:
+
+ { MALLOC, 0, sizeof (struct type_Test_Example1), 0 },
+
+ just after the first SEQ_START entry. It tells it to
+ malloc out a struct type_Test_Example1 structure to
+ hold the data from the sequence when it is decoded.
+
+SCTRLThis entry is used in handling the ASN.1 CHOICE type.
+ The C type generated for ASN.1 CHOICE type is a struc-
+ ture with an offset field in it and a union of all the
+ C types present in the CHOICE. Each ASN.1 type in the
+ CHOICE of types has a C type definition generated for
+ it. The union is of all these types, which is quite a
+ logical way to implement a CHOICE type. The offset
+ field specifies which possibility of interpreting the
+ union should be used (which _m_e_m_b_e_r should selected).
+ As such it needs to be read by the encoding routines
+ when encoding the data from the C data structures and
+ to be set by the decoding routines when it is decoding
+ the data into the C data structures. There is one such
+ entry for each CHOICE type to specify where the offset
+ field is.
+
+CH_ACTAnother redundant entry type. I think this was also
+ used in code to handle C statements or actions speci-
+ fied by the user. It probably should be removed.
+
+OPTL This is used to handle the optionals field that is gen-
+ erated by posy when optional types that are _n_o_t imple-
+ mented by pointers are present in the ASN.1 type. For
+ example if an ASN.1 type has an optional integer field
+ how does the encoding routine determine if the integer
+
+
+
+ January 23, 1990
+
+
+
+
+
+ - 9 -
+
+
+ is to be present or not? If it was implemented as a
+ pointer it could use a NULL (zero) pointer to mean that
+ the type was not present because NULL is guaranteed to
+ never occur as a legal pointer to a real object. But
+ all the possible values for integer could be legally
+ passed so instead for these types which are not
+ pointers and are optional a bit map is allocated in the
+ structure. Each non pointer optional type a bit from
+ the bit map is allocated.
+
+ If that bit is set the corresponding type is present
+and it is not present if the bit is not set. Each bit has a
+#define generated for it. The bit map is merely an integer
+field called "optionals" limiting maximum number of such
+optionals to 32 on Sun machines, 16 on some others. (An
+array of char as BSD fd_sets would have avoid all such lim-
+its, not that this limit is expected to be exceeded very
+often !) Like the SCTRL entry this entry merely serves to
+specify where this field is so it can be test and set by the
+encoding and decoding routines respectively.
+
+ANY and CONS_ANY
+ The C type corresponding to the entry is a PE pointer.
+ To conform with _p_e_p_y the tag and class of this entry
+ are ignored, which may or may not be the most sensible
+ thing. The CONS_ANY is a redundant symbol which means
+ the same thing but is not used. This should be clean
+ up and removed.
+
+INTEGER, BOOLEAN, BITSTRING, OCTETSTRING and OBJID
+ These are just as described in the first article. See
+ the ISODE manual to find out what they are allocated as
+ a C data type to implement them. The offset fields
+ says where to find this data type with in the current
+ structure.
+
+SET_START, SETOF_START, SEQ_START and SEQOF_START
+ These compound entries differ from the above in that
+ they group all the following entries together up to the
+ matching PE_END. The entries with OF in them
+ correspond to the ASN.1 types which have OF in them
+ e.g. SET OF. Allowing the OF items to have an arbi-
+ trary number of entries is excessive flexibility, they
+ can only have one type by the ASN.1 grammar rules. The
+ C data type corresponding to them is either a structure
+ if it is the first such type in the array or a pointer
+ to a structure is isn't. This complicates the process-
+ ing of these structures a little but not greatly. The
+ OF types differ one other important way, they may occur
+ zero, one or more times, with no upper bound. To cope
+ with this the C data type is a linked list structure.
+ The pointer to the data structure determines whether or
+ not there is another occurrence of the type, if it is
+ NULL there isn't. Thus each data structure has this
+
+
+
+ January 23, 1990
+
+
+
+
+
+ - 10 -
+
+
+ pointer to the next occurrence, the offset of this
+ pointer is placed in the PE_END field where it can con-
+ veniently be used to determine whether or not to make
+ another pass through the table entry.
+
+OBJECTWhen one type references another it generates an
+ OBJECT entry. This specifies the type number of the
+ type which is present in the 3rd field of the tpe
+ structure, pe_tag. The 2nd field still gives the
+ offset in the C data structure which specifies where
+ the user's data for that type is to be found. Usually
+ this a pointer to the C data structure for that type.
+
+T_NULLThis entry means the ASN.1 primative type NULL. It
+ doesn't have any body and consequently has no offset as
+ it cannot carry data directly. Only its absence or
+ presence can mean anything so if it is optional it sets
+ or clears a bit in the bit map as described earlier for
+ OPTL entry.
+
+T_OIDThis use to be used for Object Identifiers and now is
+ unused, it should be got rid.
+
+OBJIDThis corresponds to the Object Identifier ASN.1 type
+ primitive. It is implemented the same as other prima-
+ tive types like INTEGER and OCTET STRING.
+
+ETAG This entry gives the explicit tag of the following
+ entry. The usual fields which define class and tag are
+ the only ones which have meaning in this entry. By
+ concatenating successive ETAG entries it is possibly to
+ build up an limited number explicit tags, although this
+ hasn't been tested yet.
+
+IMP_OBJ
+ If a type has an implicit tag usually all we have to do
+ is set its tag and class appropriately in its entry.
+ This works for all but one important case, the refer-
+ ence of another type. This is messy because we can't
+ alter the definition of the type with out wrecking it
+ for the other uses. So what we do for encoding is
+ build the type normally and then afterward it is built
+ change its tag and class to be the values we want.
+ Similarly for decoding we match the tag and class up
+ and then decode the body of the type. We can't use a
+ OBJECT entry for this because among other reasons there
+ 3rd field is already to store the type number. (The
+ forth needs to be free to contain flags such as DEFAULT
+ and OPTIONAL) So a new entry type is used, IMP_OBJ, to
+ hold the tag and class. It must be followed by an
+ OBJECT entry which is used to handle the type as nor-
+ mal, the IMP_OBJ entry gives the tag and class to be
+ used. Like the ETAG entry the IMP_OBJ affects the
+ entry that follows it.
+
+
+
+ January 23, 1990
+
+
+
+
+
+ - 11 -
+
+
+EXTOBJ and EXTMOD
+ These handle external type references. This is just
+ like a normal (internal?) type reference except we must
+ now specify which module as well as the type. Simi-
+ larly because there are no more free fields in the
+ OBJECT type we need two entries to hold all the infor-
+ mation we need. The EXTMOD occurs first and holds the
+ type number and the offset into the C data structure
+ and the flags, exactly as for an OBJECT entry. The
+ next entry, which must be an EXTMOD, contains a pointer
+ to the modtyp structure for its module. Like a normal
+ OBJECT entry to handle the case of an implicit tag an
+ IMP_OBJ entry would occur before these two entries
+ which gives the class and tag. Likewise it could have
+ an explicit tag in which the two entries would be pro-
+ ceeded by an ETAG entry.
+
+DFLT_F and DFLT_B
+ When a type has a default value, to handle decoding and
+ encoding properly you need to know its value. As there
+ is no space to store the value in most entries we allo-
+ cate a whole entry to specify the value. When encoding
+ it is convenient to have the default occur before the
+ entry it refers to. This allows a single check to han-
+ dle all the default encoding. All it has to do is
+ check whether it is the same as the default value and
+ if so not bother encoding the next type. On the other
+ hand when decoding it is more convenient to have the
+ entry after the one it refers to. In this case we need
+ to determine that it is missing before we use the
+ default value to determine the value to pass to the
+ user. To handle this we have entries of both types.
+ _D_F_L_T__F contains the default value for the following
+ entry (F = Front) and DFLT_B contains that for the
+ entry before it (B = Back). Consequently DFLT_F are
+ only used in the decoding tables and DFLT_B entries are
+ only used in the decoding (and printing tables).
+
+S-Types
+ These types are entries for the same ASN.1 type as the
+ entry type formed by removing the starting `S'. The
+ above forms would do to handle ASN.1 but we also have
+ to be compatible with the C data structures generated
+ by _p_o_s_y. The implementors decided to optimise the C
+ data structures generated a little means we have to
+ have all these S type entries. If a type was a single
+ field in most cases they produced a #define which elim-
+ inates the need to have a whole structure just for that
+ type. In all the places where this type is used the
+ field of the C structure is changed from a pointer to
+ field which holds the value directly in the structure.
+ See the ISODE reference given above for more details.
+
+ We handle this by generating the same tables that would
+
+
+
+ January 23, 1990
+
+
+
+
+
+ - 12 -
+
+
+be generated with out the optimisation, except the optimised
+types the S-type of entries instead of the normal ones. For
+example an optimised OCTET STRING would have the type field
+of its entry as SOCTETSTRING instead of OCTETSTRING. The
+only difference in how S type and its corresponding normal
+are handle is how they find the C data structure for that
+entry. That difference is that there is no indirection
+through pointers.
+
+Flags field
+ Besides the encoding the class the pe_flags field also
+ contains a few possible flags. Mainly FL_OPTIONAL
+ which means the ASN.1 type corresponding to this flag
+ is OPTIONAL. Consequently when encoding it has to
+ determine if the type is present in the user data pos-
+ sibly using the bit map as described under the OPTL
+ entry. Likewise when decoding it may have to set a bit
+ in the bit map appropriately. The other flag at the
+ moment is FL_DEFAULT which means the entry corresponds
+ to an ASN.1 DEFAULT type. This bit is still needed as
+ not all types have DFLT_* entries implmented for them
+ at the moment. In particular compound value things
+ like SEQUENCE and SET can't have thier default value
+ specified. This is consistent with ISODE, if fact
+ implementing that may even break existing ISODE code.
+ This last flag FL_IMPLICIT is obsolete and not not used
+ any where.
+
+
+_1._2. _W_a_l_k _t_h_r_o_u_g_h _o_f _p_e_p_s_y _l_i_b_r_a_r_y _r_o_u_t_i_n_e_s.
+
+ Here we walk through all the pepsy library routines at
+least briefly. If any new routines are added or a routine
+changed this documentation is the most likely part that will
+need changing. First we give some theory as to how the task
+have have been brocken into routines then describe each
+function in detail. We assume you are familiar with ISODE's
+PE data structure manipulation routines. if not they are
+documented in the ISODE manuals, Volume one, chapter 5,
+"Encoding of Data-Structures" (It actually covers decoding
+as well).
+
+_1._2._1. _O_v_e_r_v_i_e_w _o_f _p_e_p_s_y _l_i_b_r_a_r_y
+
+ Each seperate task is put into a different file. So
+all the encoding stuff is in _e_n_c._c, all the decoding stuff
+is in _d_e_c._c, printing stuff in _p_r_n_t._c and freeing stuff in
+_f_r_e._c. Actually it breaks down a little in practice, some
+of the routines for moving around the tables are used in
+both _e_n_c._c and _d_e_c._c for example. Probably they should
+defined in _u_t_i_l._c so that linking one of the files from the
+library doesn't force linking any other except _u_t_i_l._o.
+
+ There is a common structure to each of the major files
+
+
+
+ January 23, 1990
+
+
+
+
+
+ - 13 -
+
+
+as well. There is a main routine which the user calls to
+obtain the services provided by that file's routines. As
+all the files revolve about processing the table entries
+their structure is based on running through the table
+entries.
+
+ We shall call each array of entries a table or an
+object. There is a routine, usually with a name ending in
+_obj, which is designed to process an object. For example
+en_obj is the routine called to generated an encoded object.
+Then there are routines to call on each compound type such
+as en_seq for encode a SEQUENCE. Finally all the primitives
+are handled by a one function that ends in _type. This lets
+each routine concentrate on handling the features particular
+to its type and call the appropriate routine to handle each
+type it finds with in its compound type.
+
+ Most of these table processing routines have just three
+arguements: which are called parm, p, mod. The parm is char
+* or char ** in the encoding and decoding routines respec-
+tively. This points to the user's C structure that data to
+be encoded is taken from when encoding. When decoding it is
+the address of a pointer which is made to point the C struc-
+ture filled with the decode data. The freeing, which is
+based on the decoding routines, has a char ** while the
+printing routines don't look at the user's data and so don't
+have such a pointer. The p points to the current table
+entry we are up to processing and the mod arguement points
+to the modtyp structure for the current module we are pro-
+cessing.
+
+ All these processing routines return a PE type, which
+is defined in ISODE's file _h/_p_s_a_p._h, and to return zero if
+they have an error, but not always. In fact the error han-
+dling is needs some work and has not been tested very well.
+Generally it tries to print out the table entry where some-
+thing went wrong and the name of the function it was in. It
+then sometimes does an exit which may not be very pleasent
+for the user.
+
+_1._2._2. _T_h_e _e_n_c_o_d_i_n_g _r_o_u_t_i_n_e_s - _e_n_c._c
+
+enc_fThis is the the routine made available to the user for
+ the encoding routines. It is fairly simple as it
+ leaves all the hard things up to other routines. All
+ it does is use the type number and modtyp pointer to
+ get a pointer to the table for encoding that type.
+ Then it calls the table or object encoding routine,
+ en_obj, on that object. It first does a consistency
+ check of making sure the first entry in the table is a
+ PE_start. Note that it returns an integer (OK or
+ NOTOK) instead of a PE pointer. This is to be consi-
+ tent with ISODE functions.
+
+
+
+
+ January 23, 1990
+
+
+
+
+
+ - 14 -
+
+
+en_objWe loop through the entries until we come to the end
+ of the table and then we return the PE we have built up
+ from the user's data which is pointed to by parm. In
+ looping through each entry we call the appropriate rou-
+ tine to encode its data. The default case is handled
+ by calling en_type which takes care of all the primi-
+ tive types.
+
+ The macro NEXT_TPE sets its arguement to point to the
+next type in the table, counting compound types as one type.
+Thus if NEXT_TPE is called on a SET_START it will skip all
+the entries up to and including the matching PE_END. As
+many objects consist of one compound type and its components
+the main loop will only be run through once. Even when the
+object is not based on a compound type it will then consist
+of one simple type which is processed by en_type, again
+probably going through the loop only once. In fact the only
+way it can go through the loop more than once is to process
+entries that subsidary to the main type, e.g. ETAG entries
+and things like that. To double check this is the case
+there is some code that looks for the processing of more
+than one data generating entry.
+
+ Much of that testing could probably be eliminated with
+no loss. Similarly prehaps the IMP_OBJ and ETAG could be
+handled by the default action of calling en_type. As these
+routines have evolved after many changes there are things
+like that which really need to be looked at closely before
+trying. The comment /*SUPRESS 288*/ means suppress warning
+288 to saber C debugging tool that we use.
+
+en_type
+ This is one of the longest functions as it has so many
+ cases to handle. It again is structure as a loop over
+ the types until PE_END but it actually returns as soon
+ as it has encoded the next type. We can now look at
+ the encoding of the primative ASN.1 types in detail.
+
+DFLT_FBecause we have arranged that for encoding tables,
+ that we precede the entry with a DFLT_F entry we can
+ neatly handle all the default cases. All we do is
+ check if the parameter passed in the user data, in
+ parm, is the same as the default value specified in the
+ DFLT_F entry. The function same performs this check.
+ If it is the same don't encode anything just return,
+ otherwise continue on and encode it.
+
+ETAG To handle explicit tags we merely allocate a PE with
+ the right tag and call en_etype to encode its contents,
+ which are in the following entries. The switch on the
+ pe_ucode field use to make a difference but now it is
+ meaningless and should be cleaned up.
+
+SEQ_START, SEQOF_START, SET_START, SETOF_START
+
+
+
+ January 23, 1990
+
+
+
+
+
+ - 15 -
+
+
+ We merely call the appropriate function handle them.
+ Note one _i_m_p_o_r_t_a_n_t difference in the way they are
+ called here from that in enc_obj, the parm arguement is
+ used as a base to index off and fetch a new pointer to
+ pass the next function. This seemly bizarre action is
+ quite straight forward when seen written as it is nor-
+ mally in C, "parm->offset". Where the field offset is
+ a pointer which has an offset from the start of the
+ structure of p->pe_ucode bytes.
+
+ This is the magic of how we access all the different
+fields of the C data structures with the one piece of code.
+It is also prehaps the most critical dependency of the whole
+system on the implementation of the C language. As the BGNU
+C compiler supports this feature then it is compilerable on
+most machines. But any porters should pay attention to this
+to ensure that thier compiler is happy generating these
+offsets and compiling these casts properly.
+
+ The reason why this is different from the calls in
+en_obj is that this is not the first compound type in the
+table. The first and only the first does not have an offset
+and does not need to be indirected through any pointers.
+All the compound types inside this type will have as their
+field a pointer which points to a structure. From here on
+we shall say _i_n_d_i_r_e_c_t_i_o_n to mean this adding the pe_ucode
+field to the pointer to the structure and using it to refer-
+ence a pointer. Whether to use _i_n_d_i_r_e_c_t_i_o_n or not is very
+important matter that really needs to be understood to
+understand how the routines are structured.
+
+IMP_OBJ
+ Here we have to handle the case where we can encode the
+ object then have to change its tag and class after
+ encoding. At the end of this entry this is done very
+ simply by assigning the right values to the appropriate
+ fields after the object has been built. This means
+ that if the intermeadiate form is altered this piece of
+ code may have to be altered as well. There seems to be
+ no better way of handling this.
+
+ The complication in handling this field is the handling
+of all the possible types of object. If it is an external
+object we have to perform a call to enc_f with all the right
+arguements where a normal OBJECT, the last else branch,
+requires a normal call to en_obj. Note the case of SOBJECT
+is the same as OBJECT _e_x_c_e_p_t _t_h_e_r_e _i_s _n_o _i_n_d_i_r_e_c_t_i_o_n.
+
+SOBJECT and OBJECT
+ Here is the code that handles the two cases sperately.
+ It is exactly as in the IMP_OBJ case except seperated
+ out. Note the only difference between the two cases is
+ lack of indirection in the SOBJECT case.
+
+
+
+
+ January 23, 1990
+
+
+
+
+
+ - 16 -
+
+
+CHOICE_START
+ This is exactly as all other compound types, like
+ SEQ_START and OBJECT, we call the appropriate routine
+ with indirection. From reading the ISODE manuals that
+ the ASN.1 CHOICE type is handled by a structure of its
+ own like the other compund types.
+
+EXTOBJ and SEXTOBJ
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ January 23, 1990
+
+
diff --git a/src/isode/pepsy/doc/Makefile b/src/isode/pepsy/doc/Makefile
new file mode 100644
index 000000000..33e7b0121
--- /dev/null
+++ b/src/isode/pepsy/doc/Makefile
@@ -0,0 +1,10 @@
+
+FILES = overview.ms tables.ms wt-pep.ms
+
+pepsy.info: $(FILES)
+ ditroff -ms $(FILES)
+
+DESCRIPTION: $(FILES)
+ -rm -f ../DESCRIPTION
+ nroff -ms $(FILES) > DESCRIPTION
+ ln DESCRIPTION ..
diff --git a/src/isode/pepsy/doc/overview.ms b/src/isode/pepsy/doc/overview.ms
new file mode 100644
index 000000000..ad0528fc8
--- /dev/null
+++ b/src/isode/pepsy/doc/overview.ms
@@ -0,0 +1,271 @@
+.NH 1
+Overview of pepsy system
+.XS
+Overview of pepsy system
+.XE
+.PP
+This section describes how the various parts fit together to make
+the system work.
+The principle behind pepsy is fairly simple.
+The \fBASN.1\fR is summarised as tables of integers.
+These tables are read by driver routines which encode or decode
+data to or from the internal format that \fBISODE\fR \fBOSI\fR implementation uses.
+In \fBISODE\fR specific functions are generated for each \fBASN.1\fR type
+defined in contrast the pepsy merely generates a new table of data which
+is far far smaller.
+.PP
+As there is a great deal of effort invested in the \fBISODE\fR interface to the
+encoding/decoding routines pepsy automatically provides macros which map
+the original functions into the appropriate function call of a driver.
+This allows existing posy using code to switch to the
+pepsy system with \fBno changes\fR
+to the code \fBprovided\fR no function pointers are used to the original
+\fBISODE\fR functions.
+Even when there are function pointers used the changes are very simple and
+take only a few hours to implement.
+.NH 2
+Brief description of the use of the pepsy system.
+.XS
+A Brief description of the use of the pepsy system.
+.XE
+.NH 3
+Outline of the files produced under the pepsy system.
+.XS
+Outline of the files produced under the pepsy system.
+.XE
+.PP
+The pepsy system consists of a program called \fIposy\fR
+which translates \fBASN.1\fR modules into a set of tables, called \fIposy\fR at the moment,
+and library of driver routines, called \fIlibpepsy.a\fR.
+Running this \fIposy\fR program on the \fBASN.1\fR file will produce several
+files.
+If the name of the \fBASN.1\fR module is \fBMODULE\fR the following files
+are generated:
+.I
+.IP MODULE-types.h
+.R
+which contains \fBC\fR structure definitions.
+The user of the library provides data as a linked list of
+these \fBC\fR data structures and expects to receive data back as a similar
+linked list.
+These data structures are exactly the same as those produced by the original
+\fBISODE\fR \fIposy\fR so that existing software written for the old \fIposy\fR
+program needs no change.
+For details on the \fBC\fR data structures types generated
+see the documentation of the original \fIposy\fR program in
+volume 4 Chapter 5 of the \fBISODE\fR manuals.
+.I
+.IP MODULE_tables.c
+.R
+This file contains the tables generated by the new \fIposy\fR program.
+These tables consist of three parts, the first which contains the summary of
+\fBASN.1\fR types.
+Each type is summarised as an array of a primitive type, \fBstruct pte\fR,
+for encoding and decoding, and \fBstruct ptpe\fR for printing.
+As implied there is one array for each type for each of encoding, decoding and
+printing as specified when \fIposy\fR is run.
+The next part contains up to three tables of pointers to these arrays.
+Each of the three different types of arrays, encoding, decoding and printing,
+has its own table of pointers.
+Finally there is the module type definition which contains contains pointers
+to these tables and some other useful information about the module such as its
+name.
+This module type structure, which is \fBtypedef\fRed to \fBmodtyp\fR,
+is the only piece of data which is global, all the
+rest of the data is static and is only addressable via the \fBmodtyp\fR
+data structure.
+This provides a kind of object oriented approach to handling the tables.
+Once you are passed a pointer to an \fBASN.1\fR's \fBmodtyp\fR structure
+you can encode, decode and print any of its types by calling the appropriate
+\fBlibpepsy.a\fR routine with its type number.
+.I
+.IP MODULE_pre_defs.h
+.R
+This file contains \fB#define\fRs symbol of each of the \fBASN.1\fR types
+to its type number, which is used when calling a \fBlibpepsy.a\fR routine.
+Each symbol is \fB_Ztype-nameMODULE\fR where \fItype-name\fR is the name of
+the type with dashes (\fB-\fR) turned into underscores (\fB_\fR) and
+\fIMODULE\fR is the name of the module.
+For example of the \fBASN.1\fR universal type \fIGraphicString\fR would
+have the \fB#define\fR symbol \fB_ZGraphicStringUNIV\fR.
+The \fI_Z\fR is prepended to try to make the symbols unique.
+This file also contains and extern declaration for the \fBmodtyp\fR data
+for its module.
+.I
+.IP MODULE_defs.h
+.R
+This file contains macros for all the encoding, decoding and printing
+functions that the \fIpepy\fR program would have for these \fBASN.1\fR
+types.
+This allows much of the code that uses the routines generated by running
+the old \fIposy\fR program and taking its output and running \fIpepy\fR on
+augmented \fBASN.1\fR output can be recompiled unchanged.
+If the code used pointers to these functions it is necessary to change it
+to pass around the type numbers instead and to call appropriately call
+a \fBlibpepsy.a\fR library routine with the type number.
+As pointers to the printing routines in ISODE are passed as arguments
+a \fB#define\fR is provided to turn the argument into the pair of arguments,
+type number and pointer to \fBmodtyp\fR structure, which are needed to allow
+the diagnostic printing code to work with no change for
+the current \fBISODE\fR stack.
+This file also contains a \fB#include\fR of the \fIMODULE_pre_defs.h\fR file.
+.PP
+As the \fIMODULE-types.h\fR file \fB#include\fR's the \fIMODULE_defs.h\fR
+file no further \fB#include\fRs need to be added to the files using the
+encoding/decoding/printing functions.
+This means that code written to use posy/pepy system may need no change at all
+and the only effort required is to change the Makefile to use the pepsy
+system.
+If there is code changes required it would most likely be because function
+pointers are used to reference the functions generated by posy.
+If only the \fIpepy\fR system was used,
+not posy then pepy,
+with code placed inside action statements then quite a large amount of work
+may be needed to change over to the new system, depending on how large and
+complex the \fIpepy\fR module is.
+.NH 3
+Outline of the pepsy library.
+.XS
+Outline of the pepsy library.
+.XE
+.IP enc.c
+This contains the routines that encode data from the \fBC\fR data structures
+into \fBISODE\fR's \fBPElement\fR linked list data structure which it
+uses for all presentation data.
+The most important function to pepsy users is \fBenc_f\fR which called to
+encode a particular type.
+It is passed the type number and a pointer to \fBmodtyp\fR structure for that
+module and then the rest of the arguments which are passed to an encode
+function generated by \fIposy\fR/\fIpepy\fR system.
+See the documentation in Volume 4, "The Applications Cookbook",
+Section 6.4 called "Pepy Environment".
+Most of these latter arguments are ignored, only \fBparm\fR and \fBpe\fR,
+are used.
+.PP
+Contrary to what the \fBISODE\fR documentation says these ignored parameters
+are hardly ever used by existing code.
+We have not found a single case where used for encoding a named type,
+which is all that the user can reference anyway,
+so we don't see any problems with ignoring these other parameters.
+Hopefully one day they can be thrown away entirely, until then they are
+actually passed the the encoding function.
+.PP
+The rest of the functions are mostly recursive routines which encode a
+particular type of table entry.
+For example \fBSEQUENCE\fR is encoded by \fBen_seq\fR which may call itself
+or others to encode the types from which it is built up.
+The function \fBen_type\fR builds up a simple type and \fBen_obj\fR encodes
+a new type (object) and so on with other functions.
+There are a few utility routines in the file such as \fBsame\fR which
+determines whether the value is the same as the default value also.
+.IP dec.c
+This file contains the decoding routines that translate
+presentation data into \fBC\fR data structures defined in
+the \fBMODULE-types.h\fR
+is like \fIenc.c\fR.
+It is very much like the file \fIenc.c\fR except the routines do the
+reverse tasks
+The routines are structured in a very similar way.
+We have \fBdec_f\fR which is called by the user to decode a type
+and like \fBenc_f\fR takes the same arguments as the decoding functions
+generated by \fIposy\fR with two additions, the type number and a pointer
+to the \fBmodtyp\fR structure for that module.
+Likewise the other functions are very much like those of enc.c
+.IP prnt.c
+This file contains the routines that print the presentation data in a format
+similar to that generated by \fIpepy\fR's printing functions.
+It's main function \fBprnt_f\fR is takes the same arguments as the printing
+function generated by \fIpepy\fR as well as the now familiar type number
+and \fBmodtyp\fR pointer.
+The functions are modeled on the decoding routines as it has similar job to.
+The only difference is that instead of storing the decoded data
+into a \fBC\fR data structure it is nicely printed out.
+.IP fr.c
+This file contains code to free the data structures
+defined in \fBMODULE-types.h\fR.
+Likewise if the \fB-f\fR flag is given when generating the types file it also
+includes macros in the types file which replace the freeing functions generated
+by ISODE's \fIposy\fR.
+The function that the user calls us \fBfre_obj\fR which takes a pointer to
+the data structure, its decoding table entry and a pointer
+to the \fBmodtyp\fR structure for the module.
+The freeing is based on the decoding routines except instead of decoding all
+it does is free each part of the data structure, which might involve recursive
+calls, then it frees the data structure at the end.
+.IP util.c
+This contains the utility routines used by more than one of the above files.
+This is mostly diagnostic routines at the moment, more general routines could
+be included in here.
+If there is an error at the moment which it can't recover from it just prints
+out a message on standard error and calls \fBexit\fR.
+Not perfect and this is something that will need work.
+.IP main.c
+This contains code to perform a series of tests on the \fIpepsy\fR library
+which is a useful check to see whether any of the routines has been broken
+by any changes made.
+It basically loops through a whole series of test cases.
+Each test case is encoded from some built in test data and then decoded
+and checked to see if the data has changed in the transfer.
+If it is compiled with \fI-DPRNT=1\fR the encoded data is also printed
+out to check the printing routines which generates a vast amount of output.
+Finally the free routines are used to free the allocated data, although it
+can not directly check the free routines to see if they work, it can be used
+with a malloc tracing package to check that the routines work.
+.IP test_table.h
+This contains the test cases that \fImain.c\fR program runs.
+Each entry in the table corresponds to a type.
+One of the fields is count of how many times that type is to be tested
+to try out the different possibly data values it might have.
+.IP "pep.h and pepdefs.h"
+These files contain the definition of types used for the tables that drive the
+encoding/decoding/printing routines.
+All the constants used in that table are defined here via \fB#define\fRs.
+The \fBmodtyp\fR structure is defined in \fIpepdefs.h\fR.
+.IP "t1.py and t2.py"
+These are test \fBASN.1\fR modules that are used by \fImain.c\fR routines
+to check the \fIpepsy\fR library.
+The file \fIt1.py\fR contains the majority of different types with
+a few of a different module provided in \fIt2.py\fR.
+This allows the testing of the code for handling \fBASN.1\fR
+external references, i.e. references to types defined in other, external,
+modules.
+.NH 3
+New files in the pepy directory
+.XS
+New files in the pepy directory
+.XE
+.IP "etabs.c, dtabs.c and ptabs.c"
+These files contain the code to generate the encoding/decoding/printing tables.
+The main routine in \fIetabs.c\fR is \fBtenc_typ\fR which is called
+on each \fBASN.1\fR type
+to generate an array of entries which describe how to encode that type.
+See the details section for more information about how the
+table entries function.
+Similarly \fIdtabs.c\fR contains the routine \fBtdec_typ\fR which is
+called on each type to generate its decoding table entries.
+Likewise \fBtprnt_typ\fR routine generates the arrays of table entries for
+the printing tables.
+This function is in \fIptabs.c\fR.
+.IP "dfns.c"
+This file contains miscellaneous string handling routines and hash table
+routines that don't really belong anywhere else.
+Some of the routines could be cleaned up in that they tend not to free memory
+they use.
+.IP mine.h
+This file contains the definitions for the hash table(s) that are used to keep
+track of the \fBASN.1\fR types.
+This could probably be done with out a hash table, should anyone want to
+clean this up, feel welcome.
+The lookup function is in \fIdfns.c\fR.
+.IP pass2.h
+This file has most of the \fB#define\fRs for the table generating program.
+Most of the prefixes and suffixes of function names and files names are defined
+here so, hopefully, the names can be changed by merely changing the definition.
+This contains most of the important definitions needed by the changes
+to the \fIposy\fR program needed to generate tables.
+.IP posy.h
+This contains the definition of a symbol which is now needed outside of the
+the main routine and the yacc file.
+By putting it here we can include it any file that needs to know it with out
+putting in any that doesn't need it and with out including all the other
+definitions that occur in \fIpepy.h\fR.
diff --git a/src/isode/pepsy/doc/tables.ms b/src/isode/pepsy/doc/tables.ms
new file mode 100644
index 000000000..8f5b3f62f
--- /dev/null
+++ b/src/isode/pepsy/doc/tables.ms
@@ -0,0 +1,353 @@
+.NS 2
+The structure and meaning of the tables generated from the ASN.1 grammar
+.XS
+The structure and meaning of the tables generated from the ASN.1 grammar
+.XE
+.PP
+Each collection of \fBASN.1\fR grammar is called a module.
+(See
+.[
+ASN.1
+.]
+)
+Each \fBASN.1\fR module is completely specified in the program by a
+single \fBC\fR structure of type \fBmodtyp\fR and the data which it references.
+See the \fIpepdefs.h\fR file in the \fIpepsy\fR directory.
+For each \fBASN.1\fR module
+there are three tables that are generated from\fBASN.1\fR grammar.
+These initialised arrays which we call tables are
+called the encoding, decoding and printing tables.
+Each of these tables is referenced through a different pointer
+of the \fBmodtyp\fR structure.
+.PP
+Each of these pointers references an array of pointers,
+one pointer for each \fBASN.1\fR type defined in the module.
+The position of one of these pointers is the unique type number we give to
+its corresponding type.
+The pointer references an array of type \fBtpe\fR or \fBptpe\fR, depending
+whether it is an entry in the decoding/encoding tables or printing tables
+respectively.
+See \fIpep.h\fR in the \fIpepsy\fR directory.
+This array actually contains the necessary information to encode/decode/print
+that \fBASN.1\fR type.
+So given the \fBmodtyp\fR structure of an \fBASN.1\fR module and its
+type number you can call a routine to encode, decode or print that type.
+.PP
+The rest of this document assumes a good knowledge of \fBASN.1\fR notation
+so go read a copy if you haven't already.
+From here on I shall mention only \fBtpe\fR and this means \fBtpe\fR in the
+case of encoding or decoding and \fBptpe\fR in the case of printing, unless
+otherwise stated.
+Each type is represented by an array of \fBtpe\fR (or \fBptpe\fR for printing).
+The basic element consists of four integer fields,
+the printing table is the same with an addition \fBchar\fR pointer field which
+contains the name corresponding to that entry in the \fBASN.1\fR grammar.
+The first specifies the type of the entry and determines how the
+rest are interpreted.
+The possible types are listed in \fIpepsy/pep.h\fR.
+Each type is an array which starts with an entry of type \fBPE_START\fR
+and ends with one of type \fBPE_END\fR.
+Each primitive type requires one entry to specify it,
+apart from possible \fBPE_START\fR and \fBPE_END\fR used to specify the start
+and end of the type.
+Constructed types are represented by a list of entries terminated by an
+entry of type \fBPE_END\fR.
+As \fBASN.1\fR types can be nested inside so will the
+representation in \fBtpe\fR entries be nested.
+For example the \fBASN.1\fR type definition:
+.nf
+ Example1 ::=
+ SEQUENCE {
+ seq1 SEQUENCE {
+ an-i INTEGER,
+ an-ostring OCTET STRING
+ },
+ a-bool IMPLICIT [0] BOOLEAN
+ }
+.fi
+.ce 1
+Will generate an encoding array:
+.nf
+static tpe et_Example1Test[] = {
+ { PE_START, 0, 0, 0 },
+ { SEQ_START, 0, 16, FL_UNIVERSAL },
+ { SEQ_START, OFFSET(struct type_Test_Example1, seq1), 16, FL_UNIVERSAL },
+ { INTEGER, OFFSET(struct element_Test_0, an__i), 2, FL_UNIVERSAL },
+ { OCTETSTRING, OFFSET(struct element_Test_0, an__ostring), 4, FL_UNIVERSAL },
+ { PE_END, 0, 0, 0 },
+ { BOOLEAN, OFFSET(struct type_Test_Example1, a__bool), 0, FL_CONTEXT },
+ { PE_END, 0, 0, 0 },
+ { PE_END, 0, 0, 0 }
+ };
+
+.fi
+.PP
+Here the second last \fBPE_END\fR matches and closes off the
+first \fBSEQ_START\fR.
+The entries which correspond to the other primative types are pretty
+obvious, with the INTEGER entry corresponding to the primative INTEGER.
+For fields that generate data the general interpretation of the other three
+fields is offset, tag and flags/class fields respectively.
+.IP offset
+The second field gives the offset in a \fBC\fR data structure
+needed to reference the data that corresponds to this table entry.
+Each \fBASN.1\fR type has \fBC\fR structure types generated as described in
+the
+.[
+ISODE
+.]
+manuals, volume 4 "The applications Cookbook" Section 5.2,
+"POSY Environment".
+As this offset may have to be determined in a compiler dependent manner
+a \fBC\fR preprocessor macro is used hide the actual details.
+.IP tag
+This is the tag associated with the \fBASN.1\fR type for that entry.
+Notice that in the example the [0] IMPLICIT which changes the tag
+associated with the BOOLEAN entry actually has the correct tag of 0 in the
+table.
+Likewise SEQUENCE has the correct tag of 16 in its \fBSEQ_START\fR entry
+and so on for the others.
+.IP flags/class
+This contains the \fBASN.1\fR class associated with the entry's type.
+That is UNIVERSAL for all except the BOOLEAN type which is CONTEXT class.
+This fourth can also contain flags that specify if the type is OPTIONAL
+or DEFAULT.
+There is plenty of room here as there is only four possibly classes.
+.PP
+Now that you have some idea of how these arrays are arranged for a type
+definition I will proceed to go through the possible type of
+entries and describe what they do and how they work.
+These values are defined in \fIpepsy/pep.h\fR.
+Those entries with a value below \fBTYPE_DATA\fR are entries that
+don't correspond to data to be encoded/decoded and are for other book keeping
+type purposes.
+.IP "PE_START and PE_END"
+As explained above \fBPE_START\fR starts the beginning of a \fBASN.1\fR type's
+array.
+It probably isn't necessary but the size of the tables is so small it isn't
+much of an over head to keep around for cosmetic reasons.
+The entry type \fBPE_END\fR is necessary to mark the end of some
+compound type as well as the end of \fBASN.1\fR data type.
+.IP "XOBJECT and UCODE"
+These are obsolete types and probably should be removed.
+They were to allow \fBC\fR code written directly by the user to be incorporated
+into the encoding/decoding but it was found unnecessary.
+Prehaps some brave soul would like to use them in an attempt to implement
+a similar system based on \fIpepy\fR which is what we first attempted to
+do until we found this to be much easier.
+.IP MALLOC
+This field only occurs in the decoding tables.
+It specifies how much space to malloc out for the current \fBC\fR structure
+it is just inside of.
+For instance in the example above the decoding table has the following entry:
+.DS C
+{ MALLOC, 0, sizeof (struct type_Test_Example1), 0 },
+.DE
+just after the first \fBSEQ_START\fR entry.
+It tells it to \fBmalloc\fR out a \fBstruct type_Test_Example1\fR structure
+to hold the data from the sequence when it is decoded.
+.IP SCTRL
+This entry is used in handling the \fBASN.1\fR CHOICE type.
+The \fBC\fR type generated for \fBASN.1\fR CHOICE type is a structure with
+an offset field in it and a
+union of all the \fBC\fR types present in the CHOICE.
+Each \fBASN.1\fR type in the CHOICE of types has a \fBC\fR type definition
+generated for it.
+The union is of all these types, which is quite a logical way to implement
+a CHOICE type.
+The offset field specifies which possibility of interpreting the union
+should be used (which \fImember\fR should selected).
+As such it needs to be read by the encoding routines
+when encoding the data from the \fBC\fR data structures
+and to be set by the decoding routines when it is decoding the data into
+the \fBC\fR data structures.
+There is one such entry for each \fBCHOICE\fR type to specify where the
+offset field is.
+.IP CH_ACT
+Another redundant entry type.
+I think this was also used in code to handle \fBC\fR statements or
+actions specified by the user.
+It probably should be removed.
+.IP OPTL
+This is used to handle the optionals field that is generated by
+\fBposy\fR when optional types that are \fInot\fR implemented by pointers
+are present in the \fBASN.1\fR type.
+For example if an \fBASN.1\fR type has an optional integer field how
+does the encoding routine determine if the integer is to be
+present or not?
+If it was implemented as a pointer it could use a \fBNULL\fR (zero) pointer
+to mean that the type was not present because
+NULL is guaranteed to never occur as a legal pointer to a real object.
+But all the possible values for integer could be legally passed so
+instead for these types which are not pointers and are optional
+a bit map is allocated in the structure.
+Each non pointer optional type a bit from the bit map is
+allocated.
+.PP
+If that bit is set the corresponding type is present and it is not
+present if the bit is not set.
+Each bit has a \fB#define\fR generated for it.
+The bit map is merely an integer field called "\fBoptionals\fR" limiting
+maximum number of such optionals to 32 on Sun machines, 16 on some others.
+(An array of \fBchar\fR as BSD fd_sets would have avoid all such limits,
+not that this limit is expected to be exceeded very often !)
+Like the \fBSCTRL\fR entry this entry merely serves to specify where
+this field is so it can be test and set by the encoding and decoding routines
+respectively.
+.IP "ANY and CONS_ANY"
+The \fBC\fR type corresponding to the entry is a \fBPE\fR pointer.
+To conform with \fIpepy\fR the tag and class of this entry are ignored,
+which may or may not be the most sensible thing.
+The \fBCONS_ANY\fR is a redundant symbol which means the same thing but
+is not used.
+This should be clean up and removed.
+.IP "INTEGER, BOOLEAN, BITSTRING, OCTETSTRING and OBJID"
+These are just as described in the first article.
+See the ISODE manual to find out what they are allocated as a \fBC\fR data
+type to implement them.
+The offset fields says where to find this data type with in the current
+structure.
+.IP "SET_START, SETOF_START, SEQ_START and SEQOF_START"
+These compound entries differ from the above in that they group all
+the following entries together up to the matching \fBPE_END\fR.
+The entries with \fBOF\fR in them correspond to the \fBASN.1\fR types
+which have \fBOF\fR in them
+e.g. \fBSET OF\fR.
+Allowing the \fBOF\fR items to have an arbitrary number of entries is
+excessive flexibility, they can only have one type by the \fBASN.1\fR grammar
+rules.
+The \fBC\fR data type corresponding to them is either a structure if
+it is the first such type in the array or a pointer to a structure
+is isn't.
+This complicates the processing of these structures a little but not greatly.
+The \fBOF\fR types differ one other important way,
+they may occur zero, one or more times, with no upper bound.
+To cope with this the \fBC\fR data type is a linked list structure.
+The pointer to the data structure determines whether or not there is another
+occurrence of the type, if it is NULL there isn't.
+Thus each data structure has this pointer to the next occurrence, the offset of
+this pointer is placed in the \fBPE_END\fR field where it can conveniently
+be used to determine whether or not to make another pass through the
+table entry.
+.IP OBJECT
+When one type references another it generates an \fBOBJECT\fR entry.
+This specifies the type number of the type
+which is present in the 3rd field of the \fBtpe\fR structure,
+\fBpe_tag\fR.
+The 2nd field still gives the offset in the \fBC\fR data structure
+which specifies where the user's data for that type is to be found.
+Usually this a pointer to the \fBC\fR data structure for that type.
+.IP T_NULL
+This entry means the \fBASN.1\fR primative type \fBNULL\fR.
+It doesn't have any body and consequently has no offset as it cannot
+carry data directly.
+Only its absence or presence can mean anything so if it is optional it sets or
+clears a bit in the bit map as described earlier for \fBOPTL\fR entry.
+.IP T_OID
+This use to be used for Object Identifiers and now is unused,
+it should be got rid.
+.IP OBJID
+This corresponds to the Object Identifier \fBASN.1\fR type primitive.
+It is implemented the same as other primative types like \fBINTEGER\fR
+and \fBOCTET STRING\fR.
+.IP ETAG
+This entry gives the explicit tag of the following entry.
+The usual fields which define class and tag are the only ones which have
+meaning in this entry.
+By concatenating successive \fBETAG\fR entries it is possibly to build up
+an limited number explicit tags, although this hasn't been tested yet.
+.IP IMP_OBJ
+If a type has an implicit tag usually all we have to do is set its tag
+and class appropriately in its entry.
+This works for all but one important case, the reference of another type.
+This is messy because we can't alter the definition of the type with out
+wrecking it for the other uses.
+So what we do for encoding is build the type normally
+and then afterward it is built
+change its tag and class to be the values we want.
+Similarly for decoding we match the tag and class up and then decode the body
+of the type.
+We can't use a \fBOBJECT\fR entry for this because among other
+reasons there 3rd field is already to store the type number.
+(The forth needs to be free to contain flags such as \fBDEFAULT\fR
+and \fBOPTIONAL\fR)
+So a new entry type is used, \fBIMP_OBJ\fR, to hold the tag and class.
+It must be followed by an \fBOBJECT\fR entry which is used to handle the type
+as normal, the \fBIMP_OBJ\fR entry gives the tag and class to be used.
+Like the \fBETAG\fR entry the \fBIMP_OBJ\fR affects the entry that follows it.
+.IP "EXTOBJ and EXTMOD"
+These handle external type references.
+This is just like a normal (internal?) type reference except we must now
+specify which module as well as the type.
+Similarly because there are no more free fields in the \fBOBJECT\fR type
+we need two entries to hold all the information we need.
+The \fBEXTMOD\fR occurs first and holds the type number and the offset
+into the \fBC\fR data structure and the flags, exactly as for an \fBOBJECT\fR
+entry.
+The next entry, which must be an \fBEXTMOD\fR, contains a pointer to
+the \fBmodtyp\fR structure for its module.
+Like a normal \fBOBJECT\fR entry to handle the case of an implicit tag
+an \fBIMP_OBJ\fR entry would occur before these two entries which gives
+the class and tag.
+Likewise it could have an explicit tag in which the two entries
+would be proceeded by an \fBETAG\fR entry.
+.IP "DFLT_F and DFLT_B"
+When a type has a default value, to handle decoding and encoding properly you
+need to know its value.
+As there is no space to store the value in most entries we allocate a whole
+entry to specify the value.
+When encoding it is convenient to have the default occur before the entry it
+refers to.
+This allows a single check to handle all the default encoding.
+All it has to do is check whether it is the same as the default value and if so
+not bother encoding the next type.
+On the other hand when decoding it is more convenient to have
+the entry after the
+one it refers to.
+In this case we need to determine that it is missing before we use the default
+value to determine the value to pass to the user.
+To handle this we have entries of both types.
+.B DFLT_F
+contains the default value for the following entry (F = Front)
+and \fBDFLT_B\fR contains that for the entry before it (B = Back).
+Consequently \fBDFLT_F\fR are only used in the decoding tables
+and \fBDFLT_B\fR entries are only used in the decoding (and printing tables).
+.IP S-Types
+These types are entries for the same \fBASN.1\fR type as the entry type
+formed by removing the starting `S'.
+The above forms would do to handle \fBASN.1\fR but we also have to be
+compatible with the \fBC\fR data structures generated by \fIposy\fR.
+The implementors decided to optimise the \fBC\fR data structures generated
+a little means we have to have all these \fBS\fR type entries.
+If a type was a single field in most cases they produced a \fB#define\fR
+which eliminates the need to have a whole structure just for that type.
+In all the places where this type is used the field of the \fBC\fR structure
+is changed from a pointer to field which holds the value directly in the
+structure.
+See the \fBISODE\fR reference given above for more details.
+.PP
+We handle this by generating the same tables that would be generated
+with out the optimisation, except the optimised types the S-type of entries
+instead of the normal ones.
+For example an optimised \fBOCTET STRING\fR would have
+the type field of its entry as \fBSOCTETSTRING\fR instead of \fBOCTETSTRING\fR.
+The only difference in how \fBS\fR type and its corresponding normal are handle
+is how they find the \fBC\fR data structure for that entry.
+That difference is that there is no indirection through pointers.
+.IP "Flags field"
+Besides the encoding the class the \fBpe_flags\fR field
+also contains a few possible flags.
+Mainly \fBFL_OPTIONAL\fR which means the \fBASN.1\fR type
+corresponding to this flag is OPTIONAL.
+Consequently when encoding it has to determine if the type is present in the
+user data possibly using the bit map as described under the \fBOPTL\fR entry.
+Likewise when decoding it may have to set a bit in the bit map appropriately.
+The other flag at the moment is \fBFL_DEFAULT\fR which means the entry
+corresponds to an \fBASN.1\fR DEFAULT type.
+This bit is still needed as not all types have \fBDFLT_*\fR entries implmented
+for them at the moment.
+In particular compound value things like SEQUENCE and SET can't have thier
+default value specified.
+This is consistent with \fBISODE\fR, if fact implementing that may even
+break existing \fBISODE\fR code.
+This last flag \fBFL_IMPLICIT\fR is obsolete and not not used any where.
diff --git a/src/isode/pepsy/doc/wt-pep.ms b/src/isode/pepsy/doc/wt-pep.ms
new file mode 100644
index 000000000..8045bd9e6
--- /dev/null
+++ b/src/isode/pepsy/doc/wt-pep.ms
@@ -0,0 +1,201 @@
+\" Walk through of the pepsy library routines
+.NH 2
+Walk through of pepsy library routines.
+.XS
+Walk through of pepsy library routines.
+.XE
+.PP
+Here we walk through all the pepsy library routines at least briefly.
+If any new routines are added or a routine changed this documentation
+is the most likely part that will need changing.
+First we give some theory as to how the task have have been brocken
+into routines then describe each function in detail.
+We assume you are familiar with \fBISODE\fR's \fBPE\fR data
+structure manipulation routines.
+if not they are documented in the \fBISODE\fR manuals, Volume one, chapter 5,
+"Encoding of Data-Structures" (It actually covers decoding as well).
+.NH 3
+Overview of pepsy library
+.XS
+Overview of pepsy library
+.XE
+.PP
+Each seperate task is put into a different file.
+So all the encoding stuff is in \fIenc.c\fR, all the decoding stuff is
+in \fIdec.c\fR, printing stuff in \fIprnt.c\fR and freeing stuff in \fIfre.c\fR.
+Actually it breaks down a little in practice, some of the routines for
+moving around the tables are used in both \fIenc.c\fR and \fIdec.c\fR
+for example.
+Probably they should defined in \fIutil.c\fR so that linking one of the files
+from the library doesn't force linking any other except \fIutil.o\fR.
+.PP
+There is a common structure to each of the major files as well.
+There is a main routine which the user calls to obtain the services
+provided by that file's routines.
+As all the files revolve about processing the table entries their
+structure is based on running through the table entries.
+.PP
+We shall call each array of entries a table or an object.
+There is a routine, usually with a name ending in _obj, which is designed
+to process an object.
+For example \fBen_obj\fR is the routine called to generated an encoded
+object.
+Then there are routines to call on each compound type
+such as \fBen_seq\fR for encode a SEQUENCE.
+Finally all the primitives are handled by a one function that ends in _type.
+This lets each routine concentrate on handling the features particular to
+its type and call the appropriate routine to handle each type it finds
+with in its compound type.
+.PP
+Most of these table processing routines have just three arguements:
+which are called \fBparm\fR, \fBp\fR, \fBmod\fR.
+The \fBparm\fR is char * or char ** in the encoding and decoding routines
+respectively.
+This points to the user's \fBC\fR structure that data to be encoded
+is taken from when encoding.
+When decoding it is the address of a pointer which is made to point
+the \fBC\fR structure filled with the decode data.
+The freeing, which is based on the decoding routines, has a char **
+while the printing routines don't look at the user's data and so don't
+have such a pointer.
+The \fBp\fR points to the current table entry we are up to processing and
+the \fBmod\fR arguement points to the \fBmodtyp\fR structure for the current
+module we are processing.
+.PP
+All these processing routines return a \fBPE\fR type,
+which is defined in \fBISODE\fR's file \fIh/psap.h\fR, and to return zero
+if they have an error, but not always.
+In fact the error handling is needs some work and has not
+been tested very well.
+Generally it tries to print out the table entry where something went wrong and
+the name of the function it was in.
+It then sometimes does an exit which may not be very pleasent for the
+user.
+.NH 3
+The encoding routines - enc.c
+.XS
+The encoding routines - enc.c
+.XE
+.IP enc_f
+This is the the routine made available to the user for the encoding routines.
+It is fairly simple as it leaves all the hard things up to other routines.
+All it does is use the type number and \fBmodtyp\fR pointer to get
+a pointer to the table for encoding that type.
+Then it calls the table or object encoding routine, \fBen_obj\fR,
+on that object.
+It first does a consistency check of making sure the first entry in the table
+is a \fBPE_start\fR.
+Note that it returns an integer (OK or NOTOK) instead of a \fBPE\fR pointer.
+This is to be consitent with \fBISODE\fR functions.
+.IP en_obj
+We loop through the entries until we come to the end of the table and then we
+return the \fBPE\fR we have built up from the user's data which is pointed
+to by \fBparm\fR.
+In looping through each entry we call the appropriate routine to encode its
+data.
+The default case is handled by calling \fBen_type\fR which takes care of
+all the primitive types.
+.PP
+The macro \fBNEXT_TPE\fR sets its arguement to point to the next type
+in the table, counting compound types as one type.
+Thus if \fBNEXT_TPE\fR is called on a \fBSET_START\fR it will skip all the
+entries up to and including the matching \fBPE_END\fR.
+As many objects consist of one compound type and its components the main
+loop will only be run through once.
+Even when the object is not based on a compound type it will then consist of
+one simple type which is processed by \fBen_type\fR, again probably
+going through the loop only once.
+In fact the only way it can go through the loop more than once
+is to process entries that subsidary to the main type, e.g. \fBETAG\fB entries
+and things like that.
+To double check this is the case there is some code that looks for
+the processing of more than one data generating entry.
+.PP
+Much of that testing could probably be eliminated with no loss.
+Similarly prehaps the \fBIMP_OBJ\fR and \fBETAG\fR could be handled by the
+default action of calling \fBen_type\fR.
+As these routines have evolved after many changes there are things like
+that which really need to be looked at closely before trying.
+The comment /*SUPRESS 288*/ means suppress warning 288 to saber C debugging
+tool that we use.
+.IP en_type
+This is one of the longest functions as it has so many cases to handle.
+It again is structure as a loop over the types until \fBPE_END\fR but it
+actually returns as soon as it has encoded the next type.
+We can now look at the encoding of the primative \fBASN.1\fR types in detail.
+.IP DFLT_F
+Because we have arranged that for encoding tables, that we precede
+the entry with a \fBDFLT_F\fR entry we can neatly handle all the default
+cases.
+All we do is check if the parameter passed in the user data, in \fBparm\fR,
+is the same as the default value specified in the \fBDFLT_F\fR entry.
+The function \fBsame\fR performs this check.
+If it is the same don't encode anything just return, otherwise continue on
+and encode it.
+.IP ETAG
+To handle explicit tags we merely allocate a \fBPE\fR with the right tag
+and call \fBen_etype\fR to encode its contents, which are in the following
+entries.
+The switch on the \fBpe_ucode\fR field use to make a difference
+but now it is meaningless and should be cleaned up.
+.IP "SEQ_START, SEQOF_START, SET_START, SETOF_START"
+We merely call the appropriate function handle them.
+Note one \fIimportant\fR difference in the way they are called here from that
+in \fBenc_obj\fR, the parm arguement is used as a base to index off and
+fetch a new pointer to pass the next function.
+This seemly bizarre action is quite straight forward when seen written as
+it is normally in \fBC\fR, "\fBparm->offset\fR".
+Where the field \fBoffset\fR is a pointer which has an offset from the start
+of the structure of \fBp->pe_ucode\fR bytes.
+.PP
+This is the magic of how we access all the different fields
+of the \fBC\fR data structures with the one piece of code.
+It is also prehaps the most critical dependency of the whole system
+on the implementation of the \fBC\fR language.
+As the \BGNU\fR \fBC\fR compiler supports this feature then it is
+compilerable on most machines.
+But any porters should pay attention to this to ensure that thier compiler
+is happy generating these offsets and compiling these casts properly.
+.PP
+The reason why this is different from the calls in \fBen_obj\fR is that
+this is not the first compound type in the table.
+The first and only the first does not have an offset and does not need to be
+indirected through any pointers.
+All the compound types inside this type will have
+as their field a pointer which points to a structure.
+From here on we shall say \fIindirection\fR to mean this
+adding the \fBpe_ucode\fR field
+to the pointer to the structure and using it to reference a pointer.
+Whether to use \fIindirection\fR or not is very important matter
+that really needs to be understood to understand how the routines are
+structured.
+.IP IMP_OBJ
+Here we have to handle the case where we can encode the object then have to
+change its tag and class after encoding.
+At the end of this entry this is done very simply by assigning the
+right values to the appropriate fields after the object has been built.
+This means that if the intermeadiate form is altered this piece of code
+may have to be altered as well.
+There seems to be no better way of handling this.
+.PP
+The complication in handling this field is the handling of all the possible
+types of object.
+If it is an external object we have to perform a call to \fBenc_f\fR with
+all the right arguements
+where a normal OBJECT, the last else branch, requires a normal call
+to \fBen_obj\fR.
+Note the case of \fBSOBJECT\fR is the same
+as \fBOBJECT\fR \fIexcept there is no indirection\fR.
+.IP "SOBJECT and OBJECT"
+Here is the code that handles the two cases sperately.
+It is exactly as in the \fBIMP_OBJ\fR case except seperated out.
+Note the only difference between the two cases is lack of indirection in
+the \fBSOBJECT\fR case.
+.IP CHOICE_START
+This is exactly as all other compound types,
+like \fBSEQ_START\fR and \fBOBJECT\fR, we call the appropriate routine with
+indirection.
+From reading the \fBISODE\fR manuals that the \fBASN.1\fR CHOICE type
+is handled by a structure of its own like the other compund types.
+.IP "EXTOBJ and SEXTOBJ"
+
diff --git a/src/isode/pepsy/dtabs.c b/src/isode/pepsy/dtabs.c
new file mode 100644
index 000000000..2f738f956
--- /dev/null
+++ b/src/isode/pepsy/dtabs.c
@@ -0,0 +1,812 @@
+/* dtabs.c */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:30:28 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:18:55 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:39:09 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:42:54 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+#include <stdio.h>
+#include "pepsydefs.h"
+#include "pass2.h"
+#include "mine.h"
+#include <ctype.h>
+
+
+extern char *c_tag(), *c_class();
+extern char *ec_tag(), *ec_class();
+extern char *strip_last();
+extern char *str_yp_code[];
+extern char *get_val(), *get_comp(), *strp2name();
+extern s_table *lookup_list(), *get_offset();
+extern YP tdec_loop();
+
+extern char *concat();
+extern char *my_strcat();
+extern char *rm_indirect();
+extern char *getfield();
+extern char *setfield();
+extern char *modsym ();
+extern int gen_sentry();
+
+/* extern int explicit; */
+
+#define WORDSIZE 20
+
+/*
+ * table encode a type. generate tables for the encoding of a type
+ */
+tdec_typ(fp, yp, id, type)
+FILE *fp;
+YP yp;
+char *id;
+char *type;
+{
+ char *t, *f;
+ char *p1;
+ YP y;
+ YAL yal;
+
+ if (yp->yp_code < 0 || yp->yp_code > YP_REAL)
+ ferrd(1, "tdec_typ: unimplemented type %d\n", yp->yp_code);
+
+ if (yp == NULL) {
+ ferr(0, "tdec_typ:NULL arguement\n");
+ return;
+ }
+
+ if (type)
+ t = type;
+ else if (yp->yp_param_type) {
+ char *t1;
+ /* we have a [[ P type ]] specification */
+ if ((t1 = rm_indirect(yp->yp_param_type)) == NULLCP) {
+ fprintf(stderr,
+ "\ntdec_typ:SETLIST can't extract direct type from %s\n",
+ yp->yp_param_type);
+ exit(1);
+ }
+ t = strdup(t1);
+ } else
+ t = my_strcat("struct ", modsym(mymodule, id, "type"));
+
+ if (yal = yp->yp_bef_alist) {
+ yal->yal_type = t;
+ if (yal->yal_dec)
+ gen_act(fp, yp->yp_bef_alist->yal_dec);
+ }
+ if (yal = yp->yp_aft_alist) {
+ yal->yal_type = t;
+ }
+ if (yal = yp->yp_control_act)
+ yal -> yal_type = t;
+
+ if (yal = yp->yp_optional_act)
+ yal -> yal_type = t;
+
+ if (type == NULLCP) {
+ switch (yp->yp_code) {
+ /*
+ * These generate MEMALLOC entries inside *_START ..
+ * PE_END fields for historical reasons. One day we might
+ * fix this to be all done the same way.
+ */
+ case YP_SEQLIST:
+ case YP_SEQTYPE:
+ case YP_SETLIST:
+ case YP_SETTYPE:
+ case YP_CHOICE:
+ break;
+
+ default:
+ if (yp->yp_varexp == NULL)
+ break; /* S* type entry - doesn't need a
+ * malloc */
+
+ (void) fprintf(fp, "\t{ MEMALLOC, 0, sizeof (%s), 0 },\n", t);
+ break;
+ }
+ }
+
+
+ if ((yp->yp_flags & YP_PARMVAL) && yp->yp_parm) {
+ if ((f = getfield(yp->yp_parm)) == NULLCP) {
+ fprintf(stderr, "\ntdec_typ: can't extract field from %s\n",
+ yp->yp_parm);
+ exit(1);
+ }
+ f = strdup(f);
+ } else
+ f = yp->yp_varexp;
+
+ if ((yp->yp_flags & (YP_OPTIONAL|YP_OPTCONTROL|YP_DEFAULT))
+ == (YP_OPTIONAL|YP_OPTCONTROL)) {
+ char *f1;
+ char *bitno;
+
+ if (yp -> yp_optional_act && yp -> yp_optional_act -> yal_dec) {
+ (void) fprintf (fp, "\t{ BOPTIONAL, %d, 0, FL_USELECT},\n",
+ control_act(yp -> yp_optional_act -> yal_dec));
+ }
+ else {
+ if ((f1 = getfldbit(yp->yp_optcontrol, &bitno)) == NULLCP) {
+ fprintf(stderr,
+ "\ntdec_typ:BOPTIONAL: can't extract field from %s\n",
+ yp->yp_optcontrol);
+ exit(1);
+ }
+ (void) fprintf(fp, "\t{ BOPTIONAL, AOFFSET(%s, %s), %s, 0},\n", t,
+ f1, bitno);
+ }
+ }
+
+ if (yp->yp_flags & YP_TAG && !(yp->yp_flags & YP_IMPLICIT)) {
+ (void) fprintf(fp, "\t{ ETAG, 0, ");
+ (void) fprintf(fp, "%s, %s },\n", ec_tag(yp), ec_class(yp));
+ }
+
+ if (yp->yp_yfn && yp->yp_yfn->yfn_dec) {
+
+ gen_fn(fp, yp, yp->yp_yfn->yfn_dec);
+
+ if (yp->yp_flags & YP_DEFAULT)
+ gdflt(fp, yp, G_DEC);
+
+ if (gen_freefn(fp, yp)) {
+ if (yp->yp_aft_alist && yp->yp_aft_alist->yal_dec)
+ gen_act(fp, yp->yp_aft_alist->yal_dec);
+ return;
+ }
+ }
+
+ switch (yp->yp_code) {
+
+ case YP_UNDF:
+ ferr(1, "tdec_typ:Undefined type\n");
+
+ case YP_BOOL:
+ if (yp->yp_intexp)
+ f = setfield(yp->yp_intexp);
+ if (noindirect(f))
+ ferr(1, "tdec_typ:BOOL: must specify a field for boolean\n");
+ p1 = "BOOLEAN";
+ if (yp->yp_varexp || (yp->yp_intexp && !noindirect(f)))
+ break;
+ ferr(1, "tdec_typ:BOOL: couldn't determine type\n");
+
+ /* This needs to be fixed up in the action generating area */
+ case YP_INTLIST:
+
+ case YP_INT:
+
+ case YP_ENUMLIST:
+ if (yp->yp_intexp)
+ f = setfield(yp->yp_intexp);
+ if (noindirect(f))
+ ferr(1, "tdec_typ:INT: must specify a field for an integer\n");
+ if (yp->yp_varexp || (yp->yp_intexp && !noindirect(f))) {
+ p1 = "INTEGER";
+ break;
+ }
+ ferr(1, "tdec_typ:INT: couldn't determine type\n");
+ break;
+
+ case YP_REAL:
+ if (yp->yp_strexp)
+ f = setfield(yp->yp_strexp);
+ if (noindirect(f))
+ ferr(1, "tdec_typ:REAL: must specify a field for a REAL\n");
+ if (yp->yp_varexp || (yp->yp_strexp && !noindirect(f))) {
+ p1 = "REALTYPE";
+ break;
+ }
+ ferr(1, "tdec_typ:REAL: couldn't determine type\n");
+ break;
+
+
+ case YP_BIT:
+ case YP_BITLIST:
+ if (yp->yp_strexp && yp->yp_intexp) {
+ if (yp->yp_strexp)
+ f = setfield(yp->yp_strexp);
+ if (noindirect(f))
+ ferr(1, "tdec_typ:BIT: must specify a [[ x ... ]] value\n");
+ p1 = "BITSTR_PTR";
+ prnte(fp, t, f, yp, p1);
+ if (yp->yp_intexp)
+ f = setfield(yp->yp_intexp);
+ if (noindirect(f))
+ ferr(1, "tdec_typ:BIT: must specify a [[ x ... ]] value\n");
+ p1 = "BITSTR_LEN";
+ break;
+ }
+ if (yp->yp_strexp == NULLCP && yp->yp_intexp)
+ f = setfield(yp->yp_intexp);
+ if (yp->yp_varexp || (yp->yp_intexp && !noindirect(f))) {
+ p1 = "BITSTRING";
+ break;
+ }
+ t = NULL;
+ p1 = NULL;
+ (void) fprintf(fp, "\t{ SBITSTRING, 0, %s, %s },\n",
+ c_tag(yp), c_class(yp));
+ break;
+
+ case YP_OCT:
+ if (yp->yp_strexp) {
+ switch (yp->yp_prfexp) {
+ case 'q': /* [[ q parm->qbufptr ]] */
+ if (yp->yp_strexp)
+ f = setfield(yp->yp_strexp);
+ if (noindirect(f))
+ p1 = "SOCTETSTRING";
+ else
+ p1 = "OCTETSTRING";
+ break;
+
+ case 's': /* [[ s ptr ]] */
+ if (yp->yp_strexp)
+ f = setfield(yp->yp_strexp);
+ if (noindirect(f))
+ ferr(1, "tdec_typ:OCTET: must specify a field [[ s .. ]]\n");
+ p1 = "T_STRING";
+ break;
+
+ case 'o': /* [[ o ptr $ length ]] */
+ if (yp->yp_strexp)
+ f = setfield(yp->yp_strexp);
+ if (noindirect(f))
+ ferr(1, "tdec_typ:OCTET: must specify a field [[ o .. ]]\n");
+ p1 = "OCTET_PTR";
+ prnte(fp, t, f, yp, p1);
+ if (yp->yp_intexp)
+ f = setfield(yp->yp_intexp);
+ if (noindirect(f))
+ ferr(1, "tdec_typ:OCTET: must specify a field [[ o .. $ .. ]]\n");
+ p1 = "OCTET_LEN";
+ break;
+
+ default:
+ fprintf(stderr,"\ntdec_typ: Unknown Octet string specifier %c\n",
+ yp->yp_prfexp);
+ exit(1);
+ }
+ break;
+ }
+ if (f) {
+ p1 = "OCTETSTRING";
+ break;
+ }
+ t = NULL;
+ p1 = NULL;
+ (void) fprintf(fp, "\t{ SOCTETSTRING, 0, %s, %s },\n",
+ c_tag(yp), c_class(yp));
+ break;
+
+ case YP_OID:
+ if (yp->yp_strexp)
+ f = setfield(yp->yp_strexp);
+ if (yp->yp_varexp || (yp->yp_strexp && !noindirect(f))) {
+ p1 = "OBJID";
+ break;
+ }
+ t = NULL;
+ p1 = NULL;
+ (void) fprintf(fp, "\t{ SOBJID, 0, %s, %s },\n",
+ c_tag(yp), c_class(yp));
+ break;
+
+ case YP_SEQ:
+ case YP_SET:
+ case YP_ANY:
+ if (yp->yp_strexp)
+ f = setfield(yp->yp_strexp);
+ if (yp->yp_varexp || (yp->yp_strexp && !noindirect(f))) {
+ p1 = "ANY";
+ break;
+ }
+ t = NULL;
+ p1 = NULL;
+ (void) fprintf(fp, "\t{ SANY, 0, %s, %s },\n",
+ c_tag(yp), c_class(yp));
+ break;
+
+ case YP_NULL:
+ p1 = "T_NULL";
+ t = NULL;
+ break;
+
+ case YP_IDEFINED:
+ p1 = NULL;
+
+ if ((yp->yp_flags & YP_PARMVAL) && yp->yp_prfexp)
+ ferr(1,
+ "\n[[ ? reference ]] [[ p reference ]] is illegal\n\t only one allowed\n");
+
+ if (yp->yp_prfexp) { /* [[ ? parm->field ]] - complex to process */
+ gen_identry(fp, t, f, yp, gen_ventry);
+
+ if (yp->yp_flags & YP_DEFAULT)
+ gdflt(fp, yp, G_DEC);
+
+ break;
+ }
+
+ {
+ /* Predefined Universal Type */
+ struct univ_typ *p, *univtyp();
+
+ if ((p = univtyp(yp->yp_identifier))) {
+ if (p->univ_flags & UNF_EXTMOD) {
+ yp->yp_module = p->univ_mod;
+ goto do_obj;
+ }
+ if (f == NULL || noindirect(f)) {/* No offset type */
+ if (yp->yp_flags & YP_TAG
+ && yp->yp_flags & YP_IMPLICIT)
+ prstfield(fp, p->univ_tab, t, f,
+ int2tstr(yp->yp_tag->yt_value->yv_number),
+ c_flags(yp, yp->yp_tag->yt_class));
+ else
+ prstfield(fp, p->univ_tab, t, f,
+ int2tstr((int)p->univ_id),
+ c_flags(yp, p->univ_class));
+ goto out;
+ }
+ if (yp->yp_flags & YP_TAG && yp->yp_flags & YP_IMPLICIT)
+ prtfield(fp, p->univ_tab, t, f,
+ int2tstr(yp->yp_tag->yt_value->yv_number),
+ c_flags(yp, yp->yp_tag->yt_class));
+ else
+ prtfield(fp, p->univ_tab, t, f,
+ int2tstr((int)p->univ_id),
+ c_flags(yp, p->univ_class));
+ goto out;
+ }
+ }
+do_obj:
+ if (yp->yp_flags & YP_TAG && yp->yp_flags & YP_IMPLICIT)
+ (void) fprintf(fp, "\t{ IMP_OBJ, 0, %s, %s },\n", c_tag(yp), c_class(yp));
+ if (yp->yp_module == NULL
+ || strcmp(yp->yp_module, mymodule) == 0) {
+ if (f == NULL || noindirect(f))
+ prstfield(fp, "OBJECT", t, f,
+ concat("_Z", proc_name(yp->yp_identifier, 0)),
+ c_class(yp));
+ else
+ prtfield(fp, "OBJECT", t, f,
+ concat("_Z", proc_name(yp->yp_identifier, 0)),
+ c_class(yp));
+
+ } else {
+ if (f == NULL || noindirect(f))
+ prstfield(fp, "EXTOBJ", t, f,
+ concat("_Z", strp2name(yp->yp_identifier, yp->yp_module)),
+ c_class(yp));
+ else
+ prtfield(fp, "EXTOBJ", t, f,
+ concat("_Z", strp2name(yp->yp_identifier, yp->yp_module)),
+ c_class(yp));
+ (void) fprintf(fp, "\t{ EXTMOD, %d, 0, 0 },\n",
+ gen_modref(yp->yp_module));
+ }
+ out:
+ if (yp->yp_flags & YP_DEFAULT)
+ gdflt(fp, yp, G_DEC);
+ break;
+
+ case YP_SEQLIST:
+ p1 = NULL;
+ /* support for -h flag */
+ if (yp->yp_varexp == NULL && type != NULL)
+ ferr(1, "tdec_typ:YP_SEQLIST:NULL varexp pointer\n");
+ prcte(fp, type, t, f, yp, "SEQ_START");
+
+ if (yp->yp_flags & YP_DEFAULT)
+ gdflt(fp, yp, G_DEC);
+ if (y = yp->yp_type) {
+ char *t1;
+
+ if (yp->yp_param_type) {
+ /* we have a [[ P type ]] specification */
+ if ((t1 = rm_indirect(yp->yp_param_type)) == NULLCP) {
+ fprintf(stderr,
+ "\ntdec_typ:SEQLIST can't extract direct type from %s\n",
+ yp->yp_param_type);
+ exit(1);
+ }
+ yp->yp_structname = strdup(t1);
+ } else if (type) {
+ if (yp->yp_declexp == NULL)
+ ferr(1, "tdec_typ:YP_SEQLIST:no declexp\n");
+ yp->yp_structname = my_strcat("struct ", yp->yp_declexp);
+ } else
+ yp->yp_structname = t;
+
+ if (!type || !noindirect(f))
+ genmalloc(fp, yp);
+
+ if (optfield(y)) {
+ (void) fprintf(fp,
+ "\t{ OPTL, OFFSET(%s, optionals), 0, 0 },\n",
+ yp->yp_structname);
+ }
+ tdec_loop(fp, y, id, yp->yp_structname);
+ }
+ (void) fprintf(fp, "\t{ PE_END, 0, 0, 0 },\n");
+ break;
+
+ case YP_SETLIST:
+ p1 = NULL;
+ /* support for -h flag */
+ p1 = NULL;
+ if (yp->yp_varexp == NULL && type != NULL)
+ ferr(1, "tdec_typ:YP_SETLIST:NULL varexp pointer\n");
+ prcte(fp, type, t, f, yp, "SET_START");
+
+ if (yp->yp_flags & YP_DEFAULT)
+ gdflt(fp, yp, G_DEC);
+ if (y = yp->yp_type) {
+ char *t1;
+
+ if (yp->yp_param_type) {
+ /* we have a [[ P type ]] specification */
+ if ((t1 = rm_indirect(yp->yp_param_type)) == NULLCP) {
+ fprintf(stderr,
+ "\ntdec_typ:SETLIST can't extract direct type from %s\n",
+ yp->yp_param_type);
+ exit(1);
+ }
+ yp->yp_structname = strdup(t1);
+ } else if (type) {
+ if (yp->yp_declexp == NULL)
+ ferr(1, "tdec_typ:YP_SETLIST:no declexp\n");
+ yp->yp_structname = my_strcat("struct ", yp->yp_declexp);
+ } else
+ yp->yp_structname = t;
+
+ if (!type || !noindirect(f))
+ genmalloc(fp, yp);
+
+ if (optfield(y)) {
+ (void) fprintf(fp,
+ "\t{ OPTL, OFFSET(%s, optionals), 0, 0 },\n",
+ yp->yp_structname);
+ }
+ tdec_loop(fp, y, id, yp->yp_structname);
+ }
+ (void) fprintf(fp, "\t{ PE_END, 0, 0, 0 },\n");
+ break;
+
+ case YP_SEQTYPE: /* What is the difference ?? */
+ p1 = NULL;
+ prcte(fp, type, t, f, yp, "SEQOF_START");
+
+ if (yp->yp_flags & YP_DEFAULT)
+ gdflt(fp, yp, G_DEC);
+
+ if (y = yp->yp_type) {
+ char *t1;
+
+ if (yp->yp_param_type) {
+ /* we have a [[ P type ]] specification */
+ if ((t1 = rm_indirect(yp->yp_param_type)) == NULLCP) {
+ fprintf(stderr,
+ "\ntdec_typ:SEQTYPE can't extract direct type from %s\n",
+ yp->yp_param_type);
+ exit(1);
+ }
+ yp->yp_structname = strdup(t1);
+ } else if (type) {
+ if (yp->yp_declexp == NULL)
+ ferr(1, "tdec_typ:YP_SEQTYPE:no declexp\n");
+ yp->yp_structname = my_strcat("struct ", yp->yp_declexp);
+ } else
+ yp->yp_structname = t;
+
+ if (!type || !noindirect(f))
+ genmalloc(fp, yp);
+
+ tdec_loop(fp, y, id, yp->yp_structname);
+ }
+ if (yp->yp_flags & YP_CONTROLLED) {
+ char *f1;
+
+ if ((f1 = getfield(yp->yp_control)) == NULLCP) {
+ fprintf(stderr, "\ntdec_typ:SEQ OF: can't extract field from %s\n",
+ yp->yp_control);
+ exit(1);
+ }
+ (void) fprintf(fp, "\t{ PE_END, OFFSET(%s, %s), 0, 0 },\n",
+ yp->yp_structname, f1);
+ } else if (yp->yp_structname != NULL)
+ (void) fprintf(fp, "\t{ PE_END, OFFSET(%s, next), 0, 0 },\n",
+ yp->yp_structname);
+ else
+ (void) fprintf(fp, "\t{ PE_END, 0, 0, 0 },\n");
+ break;
+
+ case YP_SETTYPE:
+ p1 = NULL;
+ prcte(fp, type, t, f, yp, "SETOF_START");
+
+ if (yp->yp_flags & YP_DEFAULT)
+ gdflt(fp, yp, G_DEC);
+
+ if (y = yp->yp_type) {
+ char *t1;
+
+
+ if (yp->yp_param_type) {
+ /* we have a [[ P type ]] specification */
+ if ((t1 = rm_indirect(yp->yp_param_type)) == NULLCP) {
+ fprintf(stderr,
+ "\ntdec_typ:SETTYPE can't extract direct type from %s\n",
+ yp->yp_param_type);
+ exit(1);
+ }
+ yp->yp_structname = strdup(t1);
+ } else if (type) {
+ if (yp->yp_declexp == NULL)
+ ferr(1, "tdec_typ:YP_SETTYPE:no declexp\n");
+ yp->yp_structname = my_strcat("struct ", yp->yp_declexp);
+ } else
+ yp->yp_structname = t;
+
+ if (!type || !noindirect(f))
+ genmalloc(fp, yp);
+
+ tdec_loop(fp, y, id, yp->yp_structname);
+ }
+ if (yp->yp_flags & YP_CONTROLLED) {
+ char *f1;
+
+ if ((f1 = getfield(yp->yp_control)) == NULLCP) {
+ fprintf(stderr, "\ntdec_typ:SET OF: can't extract field from %s\n",
+ yp->yp_control);
+ exit(1);
+ }
+ (void) fprintf(fp, "\t{ PE_END, OFFSET(%s, %s), 0, 0 },\n",
+ yp->yp_structname, f1);
+ } else if (yp->yp_structname != NULL)
+ (void) fprintf(fp, "\t{ PE_END, OFFSET(%s, next), 0, 0 },\n",
+ yp->yp_structname);
+ else
+ (void) fprintf(fp, "\t{ PE_END, 0, 0, 0 },\n");
+ break;
+
+ case YP_CHOICE:
+ p1 = NULL;
+ /* support for -h flag */
+ if (hflag && (y = yp->yp_type) && !y->yp_next) {
+ tdec_typ(fp, y, id, yp->yp_structname);
+ break;
+ }
+ if (type == NULL || type && noindirect(f))
+ prstfield(fp, "CHOICE_START", t, f, NULLCP, c_class(yp));
+ else
+ prtfield(fp, "CHOICE_START", t, type ? f : NULLCP,
+ NULLCP, c_class(yp));
+
+ if (yp->yp_flags & YP_DEFAULT)
+ gdflt(fp, yp, G_DEC);
+ if (y = yp->yp_type) {
+ char *t1;
+
+ if (yp->yp_param_type) {
+ /* we have a [[ P type ]] specification */
+ if ((t1 = rm_indirect(yp->yp_param_type)) == NULLCP) {
+ fprintf(stderr,
+ "\ntdec_typ:CHOICE can't extract direct type from %s\n",
+ yp->yp_param_type);
+ exit(1);
+ }
+ yp->yp_structname = strdup(t1);
+ } else if (type) {
+ if (yp->yp_declexp == NULL)
+ ferr(1, "tdec_typ:YP_CHOICE:no declexp\n");
+ yp->yp_structname = my_strcat("struct ", yp->yp_declexp);
+ } else
+ yp->yp_structname = t;
+
+ if (!type || !noindirect(f))
+ genmalloc(fp, yp);
+
+
+ if (yp -> yp_control_act && yp->yp_control_act->yal_dec) {
+ (void) fprintf (fp, "\t{ SCTRL, %d, 0, FL_USELECT },\n",
+ control_act(yp->yp_control_act -> yal_dec));
+ }
+ else if (yp->yp_flags & YP_CONTROLLED) {
+ char *f1;
+
+ if ((f1 = getfield(yp->yp_control)) == NULLCP) {
+ fprintf(stderr, "\ntdec_typ:CHOICE: can't extract field from %s\n",
+ yp->yp_control);
+ exit(1);
+ }
+ (void) fprintf(fp, "\t{ SCTRL, OFFSET(%s, %s), 0, 0 },\n",
+ yp->yp_structname, f1);
+ } else if (yp->yp_structname != NULL)
+ (void) fprintf(fp,"\t{ SCTRL, OFFSET(%s, offset), 0, 0 },\n",
+ yp->yp_structname);
+ else
+ ferr(1, "\nCHOICE missing SCTRL\n");
+
+ if (yp->yp_param_type) {
+ /* we have a [[ P type ]] specification */
+ if ((t1 = rm_indirect(yp->yp_param_type)) == NULLCP) {
+ fprintf(stderr,
+ "\ntdec_typ:CHOICE can't extract direct type from %s\n",
+ yp->yp_param_type);
+ exit(1);
+ }
+ yp->yp_structname = strdup(t1);
+ } else if (type) {
+ if (yp->yp_declexp == NULL)
+ ferr(1, "tdec_typ:YP_CHOICE:no declexp\n");
+ yp->yp_structname = my_strcat("struct ", yp->yp_declexp);
+ } else
+ yp->yp_structname = t;
+ tdec_loop(fp, y, id, yp->yp_structname);
+ }
+ (void) fprintf(fp, "\t{ PE_END, 0, 0, 0 },\n");
+ break;
+
+ default:
+ ferrd(1, "tdec_typ: yp_code = %d not implemented\n", yp->yp_code);
+ }
+
+ if (p1 != NULL) {
+ prnte(fp, t, f, yp, p1);
+
+ if (yp->yp_flags & YP_DEFAULT)
+ gdflt(fp, yp, G_DEC);
+ }
+
+ if (yp->yp_aft_alist && yp->yp_aft_alist->yal_dec)
+ gen_act(fp, yp->yp_aft_alist->yal_dec);
+
+}
+
+/*
+ * generate tables for encoding a contructed type
+ */
+YP
+tdec_loop(fp, yp, id, type)
+FILE *fp;
+YP yp;
+char *id;
+char *type;
+{
+ for (; yp != NULL; yp = yp->yp_next) {
+ tdec_typ(fp, yp, id, type);
+ }
+}
+/*
+ * Generate a malloc of for the given object
+ */
+genmalloc(fp, yp)
+FILE *fp;
+YP yp;
+{
+ if (hasdatstr(yp))
+ (void) fprintf(fp, "\t{ MEMALLOC, 0, sizeof (%s), 0 },\n",
+ yp->yp_structname);
+}
+/*
+ * Has Data Structure,
+ * determine if this type needs a data structure allocated to it - calls
+ * itself recursively to handle the cases of pulled up types
+ * returns non zero if it does need a type allocated for it
+ */
+hasdatstr(yp)
+YP yp;
+{
+ YP y;
+ YP yp1;
+ struct univ_typ *p;
+
+ switch (yp -> yp_code) {
+ case YP_BIT:
+ case YP_BITLIST:
+ case YP_SEQ:
+ case YP_SET:
+ case YP_ANY:
+ case YP_OCT:
+ case YP_OID:
+ break;
+
+ case YP_IDEFINED:
+
+ yp1 = lkup(yp);
+
+ if (yp1->yp_code == YP_IDEFINED) {
+ if ((p = univtyp(yp1->yp_identifier)) == NULL
+ || p->univ_type <= YP_UNDF) {
+ return (1); /* we can't tell unless we know what this is */
+ /* ferr(0, "\tcomptag:treated as implicit\n"); */
+ }
+ if (p->univ_flags & UNF_HASDATA)
+ return (1);
+ return (0);
+ } else
+ return (hasdatstr(yp1));
+
+ case YP_SEQLIST:
+ case YP_SETLIST:
+ case YP_CHOICE:
+ if (hflag && (y = yp -> yp_type) && !y -> yp_next) {
+ return (hasdatstr(y));
+ }
+ /* else fall */
+
+ default:
+ return (1);
+ }
+ return (0);
+}
+
+int control_act (act)
+Action act;
+{
+ register char *p;
+
+ for (p = act -> a_data; *p; p++)
+ if (!isspace (*p) && *p == '0')
+ return -1;
+ return act -> a_num;
+}
+
+/*
+ * generate an entry for the freeing routines
+ * if there is a freeing function just call that
+ * if not specify the type and offset so the free routines know how to free it
+ * return non zero if we don't want the normal decoding entry to be
+ * generated after us for freeing purposes.
+ */
+gen_freefn(fp, yp)
+FILE *fp;
+YP yp;
+{
+ char *fn;
+
+ if (yp->yp_yfn && (fn = yp->yp_yfn->yfn_fre)) {
+ (void) fprintf(fp, "\t{ FFN_CALL, %d, 0, 0, },\n", addptr(fn));
+ return (1); /* don't free as per normal */
+ }
+
+ (void) fprintf(fp, "\t{ FREE_ONLY, 0, 0, 0, },\n");
+ return (0);
+
+}
+
diff --git a/src/isode/pepsy/enc.c b/src/isode/pepsy/enc.c
new file mode 100644
index 000000000..0a93af700
--- /dev/null
+++ b/src/isode/pepsy/enc.c
@@ -0,0 +1,1573 @@
+/* enc.c */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:30:30 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:18:57 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:39:11 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:42:54 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include <ctype.h>
+#include "pepsy-driver.h"
+#include "psap.h"
+#include "pepsy.h"
+#include "tailor.h"
+
+#ifndef PEPYPARM
+#define PEPYPARM char *
+#endif
+
+
+extern tpe *next_tpe(), *fdflt_f();
+char *idname(), *clname();
+
+#define NEXT_TPE(p) (p = next_tpe(p))
+#define CHKTAG(mod, p, pe) ismatch(p, mod, pe->pe_class, pe->pe_id)
+
+static char oomsg[] = "Out of memory";
+#define oom(a,b) pepsylose ((a), (b), NULLPE, oomsg);
+#define RET_OK(rpe, pe) *(rpe) = (pe), (OK)
+
+static int en_obj ();
+static int en_type();
+static int en_seq();
+static int en_set();
+static int en_seqof();
+static int en_setof();
+static int en_choice();
+static int en_etype();
+
+/*
+ * encode the specified type of the specified module into the given
+ * pe
+ */
+enc_f(typ, mod, pe, explicit, len, buf, parm)
+/* ARGSUSED */
+int typ; /* which type it is */
+modtyp *mod; /* Module it is from */
+register PE *pe;
+int explicit;
+int len;
+char *buf;
+char *parm;
+{
+ register tpe *p;
+
+ if (typ < 0 || typ >= mod->md_nentries) {
+ (void) pepsylose (mod, NULLTPE, NULLPE, "enc_f:Illegal typ %d", typ);
+ return NOTOK;
+ }
+
+ p = mod->md_etab[typ];
+ if (p->pe_type != PE_START) {
+ return (pepsylose (mod, NULLTPE, NULLPE, "enc_f: missing PE_START"));
+ }
+ p++;
+
+ return (en_obj(parm, p, mod, pe));
+}
+
+/*
+ * Encode an object. If the object is a simple type it may have a
+ * compressed type reference. If it is a compound type it will not
+ * have an offset. This is very important as it means we cannot just
+ * use en_type to handle this which must always assume the field can
+ * have an offset.
+ */
+static int
+en_obj(parm, p, mod, rpe)
+PEPYPARM parm;
+tpe *p;
+modtyp *mod; /* Module it is from */
+PE *rpe; /* Return value PE */
+{
+ PE pe = NULLPE; /* for pepsylose calls */
+ int cnt = 0;
+ tpe *tmp;
+
+ DLOG (psap_log, LLOG_DEBUG, ("en_obj: type %d", p->pe_type));
+
+ *rpe = NULLPE; /* default case */
+
+ while (p->pe_type != PE_END) {
+
+ switch (p->pe_type) {
+ case PE_END:
+ case PE_START:
+ return (pepsylose (mod, p, pe, "en_obj:END/START type"));
+
+ /*
+ * This allows Functions to be called at the very end of the
+ * encoding -- With the encoded data - very messy
+ */
+ case UCODE:
+ if (mod->md_eucode == NULLIFP
+ || (*mod->md_eucode) (parm, &pe, p) == NOTOK)
+ goto bad;
+ break;
+
+ default:
+ if (en_type(parm, p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+ }
+ if (ISDTYPE(p) && cnt++ > 0)
+ return pepsylose (mod, p, NULLPE, "en_obj:compound type found");
+
+ if (ISDTYPE(p)) {
+ if (pe == NULLPE)
+ return pepsylose (mod, p, NULLPE,
+ "en_obj: missing mandatory value");
+ }
+ /* make sure any final UCODEs get run
+ if (ISDTYPE(p) && pe != NULLPE)
+ return (RET_OK(rpe, pe));
+ */
+
+ if (NEXT_TPE(p) == NULLTPE)
+ goto bad;
+ }
+
+ return (RET_OK(rpe, pe));
+
+bad:
+ return (NOTOK);
+}
+
+/*
+ * Encode a single type. If a basic type encode it, if a compound
+ * type call the appropriate encoding routine
+ */
+static int
+en_type(parm, p, mod, rpe)
+register PEPYPARM parm;
+register tpe *p;
+register modtyp *mod; /* Module it is from */
+PE *rpe; /* Return value PE */
+{
+ PE pe = NULLPE;
+ int cnt = 0;
+ int i; /* Integer for encoding type */
+ tpe *tmp;
+ char *cp;
+
+ DLOG (psap_log, LLOG_DEBUG, ("Encoding the type %d", p->pe_type));
+
+ *rpe = NULLPE;
+ while (p->pe_type != PE_END) {
+
+ switch (p->pe_type) {
+ case PE_END:
+ case PE_START:
+ return (pepsylose (mod, p, pe, "en_type:END/START type"));
+
+ case DFLT_F:
+ tmp = p;
+ p = FDFLT_F(p);
+ if ((i = same(p, tmp, parm, mod)) == NOTOK)
+ return (NOTOK); /* Error */
+ if (i)
+ return (RET_OK(rpe, NULLPE));/* don't encode it */
+ p = tmp + 1;
+ continue;
+
+ case BOPTIONAL:
+ if (IF_USELECT(p)) {
+ if (mod -> md_eucode == NULLIFP)
+ goto bad;
+ if ((*mod->md_eucode) (parm, &pe, p) == 0)
+ return (RET_OK(rpe,NULLPE)); /* don't encode it */
+ } else if (!OPT_PRESENT(p, parm))
+ return (RET_OK(rpe, NULLPE));/* don't encode it */
+ p++; /* encode it */
+ continue;
+
+ case UCODE:
+ if (mod->md_eucode == NULLIFP
+ || (*mod->md_eucode) (parm, &pe, p) == NOTOK)
+ goto bad;
+ break;
+
+ case ETAG:
+ if ((pe = pe_alloc(CLASS(p), PE_FORM_CONS, TAG(p))) == NULLPE)
+ return oom (mod, p);
+
+ switch (p->pe_ucode) {
+
+ default:
+ p++;
+ if (en_etype(parm, p, mod, &pe->pe_cons) == NOTOK)
+ goto bad;
+ }
+ break;
+
+ case SEQ_START:
+ if (en_seq(*(char **) (parm + p->pe_ucode), p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SEQOF_START:
+ if (en_seqof(*(char **) (parm + p->pe_ucode), p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SET_START:
+ if (en_set(*(char **) (parm + p->pe_ucode), p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SETOF_START:
+ if (en_setof(*(char **) (parm + p->pe_ucode), p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SSEQ_START:
+ if (en_seq(parm + p->pe_ucode, p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SSEQOF_START:
+ if (en_seqof(parm + p->pe_ucode, p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SSET_START:
+ if (en_set(parm + p->pe_ucode, p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SSETOF_START:
+ if (en_setof(parm + p->pe_ucode, p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case IMP_OBJ:
+ tmp = p++;
+ if (p->pe_type == EXTOBJ) {
+ if (enc_f(p->pe_tag, EXT2MOD(mod, (p + 1)), &pe, 1,
+ 0, (char *)0, *(char **) (parm + p->pe_ucode)) == NOTOK)
+ return (NOTOK);
+ } else if (p->pe_type == SEXTOBJ) {
+ if (enc_f(p->pe_tag, EXT2MOD(mod, (p + 1)), &pe, 1,
+ 0, (char *)0, (parm + p->pe_ucode)) == NOTOK)
+ return (NOTOK);
+ } else if (p->pe_type == SOBJECT) {
+ if (en_obj((char *) (parm + p->pe_ucode), mod->md_etab[p->pe_tag] + 1, mod, &pe)
+ == NOTOK)
+ goto bad;;
+ } else
+ if (en_obj(*(char **) (parm + p->pe_ucode),
+ mod->md_etab[p->pe_tag] + 1, mod, &pe) == NOTOK)
+ goto bad;
+
+ pe->pe_class = CLASS(tmp);
+ pe->pe_id = TAG(tmp);
+ break;
+
+ case SOBJECT:
+ if (en_obj((char *) (parm + p->pe_ucode), mod->md_etab[p->pe_tag] + 1, mod, &pe)
+ == NOTOK)
+ goto bad;
+ break;
+
+ case OBJECT:
+ if (en_obj(*(char **) (parm + p->pe_ucode),
+ mod->md_etab[p->pe_tag] + 1, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case CHOICE_START:
+ if (en_choice(*(char **) (parm + p->pe_ucode), p, mod, &pe) ==NOTOK)
+ goto bad;
+ break;
+
+ case SCHOICE_START:
+ if (en_choice(parm + p->pe_ucode, p, mod, &pe) ==NOTOK)
+ goto bad;
+ break;
+
+ case SEXTOBJ:
+ if (p[1].pe_type != EXTMOD)
+ return pepsylose (mod, &p[1], NULLPE,
+ "en_seq: missing EXTMOD");
+ if (enc_f(p->pe_tag, EXT2MOD(mod, (p + 1)), &pe, 1, 0, (char *)0,
+ (char *) (parm + p->pe_ucode)) == NOTOK)
+ return (NOTOK);
+ break;
+
+ case EXTOBJ:
+ if (p[1].pe_type != EXTMOD)
+ return pepsylose (mod, &p[1], NULLPE,
+ "en_seq: missing EXTMOD");
+ if (enc_f(p->pe_tag, EXT2MOD(mod, (p + 1)), &pe, 1, 0, (char *)0,
+ *(char **) (parm + p->pe_ucode)) == NOTOK)
+ return (NOTOK);
+ break;
+
+ case INTEGER:
+ DLOG (psap_log, LLOG_DEBUG,
+ ("en_type:INTEGER offset is %d, value is %d",
+ p->pe_ucode, *(integer *)(parm + p->pe_ucode)));
+
+ if ((pe = num2prim(*(integer *) (parm + p->pe_ucode),
+ CLASS(p), TAG(p))) == NULLPE)
+ return oom(mod, p);
+ break;
+
+#ifdef PEPSY_REALS
+ case REALTYPE:
+ DLOG (psap_log, LLOG_DEBUG, ("en_type:REAL: offset %d value %g",
+ p->pe_ucode,
+ *(double *) (parm + p->pe_ucode)));
+
+ if ((pe = real2prim(*(double *) (parm + p->pe_ucode),
+ CLASS(p), TAG(p))) == NULLPE)
+ return oom(mod, p);
+ break;
+
+#endif
+ case BOOLEAN:
+ DLOG (psap_log, LLOG_DEBUG, ("en_type:BOOLEAN:offset %d value %d",
+ p->pe_ucode,
+ *(char *) (parm + p->pe_ucode)));
+ if ((pe = flag2prim(*(char *) (parm + p->pe_ucode),
+ CLASS(p), TAG(p))) == NULLPE)
+ return oom(mod, p);
+ break;
+
+ case T_NULL:
+ DLOG (psap_log, LLOG_DEBUG, ("en_type:NULL:offset %d",p->pe_ucode));
+
+ if ((pe = pe_alloc(CLASS(p), PE_FORM_PRIM,
+ TAG(p))) == NULLPE)
+ return oom(mod,p);
+
+ break;
+
+ case SANY:
+ (pe = (PE) (parm + p->pe_ucode))->pe_refcnt++;
+ break;
+
+ case ANY:
+ if ((parm + p->pe_ucode) == 0 || *(PE *) (parm + p->pe_ucode) == 0)
+#if ROSAP_HACK
+ /* hack for ROSAP. expects this strangeness */
+ pe = pe_alloc(PE_CLASS_UNIV, PE_FORM_PRIM, PE_PRIM_NULL);
+#else
+ pe = NULLPE;
+#endif
+ else
+ (pe = *(PE *) (parm + p->pe_ucode))->pe_refcnt++;
+ break;
+
+ case SOCTETSTRING:
+ if ((pe = qb2prim((struct qbuf *) (parm + p->pe_ucode), CLASS(p), TAG(p)))
+ == NULLPE)
+ return oom(mod, p)
+ break;
+
+ case OCTETSTRING:
+ if ((pe = qb2prim(*(struct qbuf **) (parm + p->pe_ucode),
+ CLASS(p), TAG(p))) == NULLPE)
+ return oom(mod, p);
+ break;
+
+ case T_STRING:
+ if (*(char **) (parm + p->pe_ucode) == NULLCP)
+ return pepsylose (mod, &p[1], NULLPE,
+ "en_type:T_STRING missing pointer");
+ if ((pe = str2prim(*(char **) (parm + p->pe_ucode),
+ strlen(*(char **) (parm + p->pe_ucode)),
+ CLASS(p), TAG(p))) == NULLPE)
+ return oom(mod, p);
+ break;
+
+ case OCTET_PTR:
+ if (p[1].pe_type != OCTET_LEN)
+ return pepsylose (mod, &p[1], NULLPE,
+ "en_type:missing OCTET_LEN");
+
+ if (*(char **) (parm + p->pe_ucode) == NULLCP)
+ return pepsylose (mod, &p[1], NULLPE,
+ "en_type:OCTET_PTR missing pointer");
+
+ if (*(int *) (parm + (p + 1)->pe_ucode) < 0)
+ return pepsylose (mod, &p[1], NULLPE,
+ "en_type:OCTET_LEN negative length");
+
+ if ((pe = str2prim(*(char **) (parm + p->pe_ucode),
+ *(int *) (parm + (p + 1)->pe_ucode),
+ CLASS(p), TAG(p))) == NULLPE)
+ return oom(mod, p);
+ break;
+
+ case BITSTR_PTR:
+ if (p[1].pe_type != BITSTR_LEN)
+ return pepsylose (mod, &p[1], NULLPE,
+ "en_type:missing BITSTR_LEN");
+
+ if (*(char **) (parm + p->pe_ucode) == NULLCP)
+ return pepsylose (mod, &p[1], NULLPE,
+ "en_type:BITSTR_PTR missing pointer");
+
+ if (*(int *) (parm + (p + 1)->pe_ucode) < 0)
+ return pepsylose (mod, &p[1], NULLPE,
+ "en_type:BITSTR_LEN negative length");
+
+ if ((pe = strb2bitstr(*(char **) (parm + p->pe_ucode),
+ *(int *) (parm + (p + 1)->pe_ucode),
+ CLASS(p), TAG(p))) == NULLPE
+ || (pe = bit2prim(pe)) == NULLPE)
+ return oom(mod, p);
+ break;
+
+ case SBITSTRING:
+ if ((cp = bitstr2strb((PE) (parm + p->pe_ucode), &i)) == NULL)
+ return oom(mod, p);
+ if ((pe = strb2bitstr(cp, i, CLASS(p), TAG(p))) == NULLPE)
+ return oom(mod, p);
+ free(cp);
+ if ((pe = bit2prim(pe)) == NULLPE)
+ return oom(mod, p);
+ break;
+
+ case BITSTRING:
+ if ((cp = bitstr2strb(*(PE *) (parm + p->pe_ucode), &i))
+ == NULL)
+ return oom(mod, p);
+
+ if ((pe = strb2bitstr(cp, i, CLASS(p), TAG(p))) == NULLPE)
+ return oom(mod, p);
+
+ free(cp);
+ if ((pe = bit2prim(pe)) == NULLPE)
+ return oom(mod, p);
+ break;
+
+ case SOBJID:
+ if ((pe = obj2prim((OID) (parm + p->pe_ucode), CLASS(p), TAG(p))) == NULLPE)
+ return oom(mod, p);
+ break;
+
+ case OBJID:
+ if ((pe = obj2prim(*(OID *) (parm + p->pe_ucode), CLASS(p), TAG(p)))
+ == NULLPE)
+ return oom(mod, p);
+ break;
+
+ case FN_CALL:
+ if ((FN_PTR(mod, p))(parm, &pe) == NOTOK)
+ return pepsylose (mod, p, NULLPE,
+ "en_type:FN_CALL:call failed");
+ if (STAG(p) >= 0) {
+ pe->pe_class = CLASS(p);
+ pe->pe_id = TAG(p);
+ }
+ break;
+
+ default:
+ return pepsylose (mod, p, NULLPE, "en_type: type not implemented");
+ }
+ if (ISDTYPE(p) && cnt++ > 0)
+ return pepsylose (mod, p, NULLPE, "en_type:compound type found");
+
+ if (ISDTYPE(p)) {
+ if (pe == NULLPE)
+ return pepsylose (mod, p, NULLPE,
+ "en_type: missing mandatory value");
+ }
+ if (ISDTYPE(p) && pe != NULLPE)
+ return (RET_OK(rpe, pe));
+ if (NEXT_TPE(p) == NULLTPE)
+ goto bad;
+ }
+
+ return (RET_OK(rpe, pe));
+
+bad:
+ return (NOTOK);
+}
+
+/*
+ * Build a sequence, calling appropriate routines to build each sub
+ * type
+ */
+static int
+en_seq(parm, p, mod, rpe)
+PEPYPARM parm;
+tpe *p;
+modtyp *mod; /* Module it is from */
+PE *rpe; /* Return value PE */
+{
+ PE head;
+ PE pe = NULLPE;
+ tpe *tmp; /* first entry in list */
+ int *popt = NULL; /* Pointer to optional field */
+ int optcnt = 0; /* Number of optionals bits so far */
+ int val;
+
+ if (p->pe_type != SEQ_START && p->pe_type != SSEQ_START)
+ return (pepsylose (mod, p, pe, "en_seq: missing SEQ_START\n"));
+
+ if ((head = pe_alloc(CLASS(p), PE_FORM_CONS, TAG(p))) == NULLPE)
+ return oom (mod, p);
+ p++;
+
+ while (p->pe_type != PE_END) {
+
+ DLOG (psap_log, LLOG_DEBUG, ("en_seq type%d", p->pe_type));
+
+ if (ISDTYPE(p) && OPTIONAL(p)) {
+ switch (p->pe_type) {
+ case INTEGER:
+ case REALTYPE:
+ case BOOLEAN:
+ case T_NULL:
+ if (!TESTBIT(*popt, optcnt++))
+ goto next; /* Missing so skip */
+ break;
+
+ case FN_CALL:
+ if ((val = hasdata(parm, p, mod, popt, &optcnt)) == NOTOK)
+ goto bad;
+ if (val == 0)
+ goto next;
+ break;
+
+ case ETAG:
+ if ((val = hasdata(parm, p + 1, mod, popt, &optcnt)) == NOTOK)
+ goto bad;
+ if (val == 0)
+ goto next;
+ break;
+
+ case IMP_OBJ:
+ if (p[1].pe_type == SOBJECT && parm == NULL
+ || *((char **) (parm + p[1].pe_ucode)) == NULL)
+ goto next;
+ break;
+
+ case SOBJECT:
+ if (((char *) parm) == NULL)
+ goto next;
+ break;
+
+ default:
+ if (*((char **) (parm + p->pe_ucode)) == NULL)
+ goto next;
+ break;
+ }
+ }
+ switch (p->pe_type) {
+ case OPTL:
+ popt = (int *) (parm + p->pe_ucode);
+ break;
+
+ case UCODE:
+ if (mod->md_eucode == NULLIFP
+ || (*mod->md_eucode) (parm, &pe, p) == NOTOK)
+ goto bad;
+ break;
+
+ case ETAG:
+ if (en_type(parm, p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SEQ_START:
+ if (en_seq(*(char **) (parm + p->pe_ucode), p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SEQOF_START:
+ if (en_seqof(*(char **) (parm + p->pe_ucode), p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SET_START:
+ if (en_set(*(char **) (parm + p->pe_ucode), p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SETOF_START:
+ if (en_setof(*(char **) (parm + p->pe_ucode), p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case IMP_OBJ:
+ tmp = p++;
+ if (p->pe_type == EXTOBJ || p->pe_type == SEXTOBJ) {
+ if (enc_f(p->pe_tag, EXT2MOD(mod, (p + 1)), &pe, 1,
+ 0, (char *)0, *(char **) (parm + p->pe_ucode)) == NOTOK)
+ return (NOTOK);
+ } else if (p->pe_type == SOBJECT) {
+ if (en_obj((char *) (parm + p->pe_ucode), mod->md_etab[p->pe_tag] + 1, mod,
+ &pe) == NOTOK)
+ goto bad;
+ } else
+ if (en_obj(*(char **) (parm + p->pe_ucode),
+ mod->md_etab[p->pe_tag] + 1, mod, &pe) == NOTOK)
+ goto bad;
+ pe->pe_class = CLASS(tmp);
+ pe->pe_id = TAG(tmp);
+ break;
+
+ case SOBJECT:
+ if (en_obj((char *) (parm + p->pe_ucode), mod->md_etab[p->pe_tag] + 1, mod, &pe)
+ == NOTOK)
+ goto bad;
+ break;
+
+ case OBJECT:
+ if (en_obj(*(char **) (parm + p->pe_ucode),
+ mod->md_etab[p->pe_tag] + 1, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case CHOICE_START:
+ if (en_choice(*(char **) (parm + p->pe_ucode), p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SCHOICE_START:
+ if (en_choice((char *) (parm + p->pe_ucode), p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SEXTOBJ:
+ if (p[1].pe_type != EXTMOD)
+ return pepsylose (mod, &p[1], NULLPE, "en_seq: missing EXTMOD");
+ if (enc_f(p->pe_tag, EXT2MOD(mod, (p + 1)), &pe, 1, 0, (char *)0,
+ (char *) (parm + p->pe_ucode)) == NOTOK)
+ return (NOTOK);
+ break;
+
+ case EXTOBJ:
+ if (p[1].pe_type != EXTMOD)
+ return pepsylose (mod, &p[1], NULLPE, "en_seq: missing EXTMOD");
+
+ if (enc_f(p->pe_tag, EXT2MOD(mod, (p + 1)), &pe, 1, 0, (char *)0,
+ *(char **) (parm + p->pe_ucode)) == NOTOK)
+ return (NOTOK);
+ break;
+
+ default:
+ if (en_type(parm, p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+ }
+
+ if ((ISDTYPE(p) || p->pe_type == BOPTIONAL) && pe != NULLPE) {
+ if (seq_add(head, pe, -1) == NOTOK)
+ return pepsylose (mod, p, NULLPE, "en_seq bad sequence: %s",
+ pe_error(pe->pe_errno));
+ }
+next:
+ if (NEXT_TPE(p) == NULLTPE)
+ return (NOTOK);
+ }
+
+ return (RET_OK(rpe, head));
+
+bad:
+ return (NOTOK);
+}
+
+
+/*
+ * Parse a set, calling appropriate routines to parse each sub type
+ */
+static int
+en_set(parm, p, mod, rpe)
+PEPYPARM parm;
+tpe *p;
+modtyp *mod; /* Module it is from */
+PE *rpe; /* Return value PE */
+{
+ PE head;
+ PE pe = NULLPE;
+ tpe *tmp;
+ int *popt = NULL; /* Pointer to optional field */
+ int optcnt = 0; /* Number of optionals bits so far */
+ int val;
+
+ if (p->pe_type != SET_START && p->pe_type != SSET_START)
+ return pepsylose (mod, p, pe, "en_set: missing SET_START");
+
+ if ((head = pe_alloc(CLASS(p), PE_FORM_CONS, TAG(p))) == NULLPE)
+ return oom(mod, p);
+
+ p++;
+ while (p->pe_type != PE_END) {
+
+ DLOG (psap_log, LLOG_DEBUG, ("en_set type %d", p->pe_type));
+
+ if (ISDTYPE(p) && OPTIONAL(p)) {
+ switch (p->pe_type) {
+ case INTEGER:
+ case REALTYPE:
+ case BOOLEAN:
+ case T_NULL:
+ if (!TESTBIT(*popt, optcnt++))
+ goto next; /* Missing so skip */
+ break;
+
+ case FN_CALL:
+ if ((val = hasdata(parm, p, mod, popt, &optcnt)) == NOTOK)
+ goto bad;
+ if (val == 0)
+ goto next;
+ break;
+
+ case ETAG:
+ if ((val = hasdata(parm, p + 1, mod, popt, &optcnt)) == NOTOK)
+ goto bad;
+ if (val == 0)
+ goto next;
+ break;
+
+ case IMP_OBJ:
+ if (p[1].pe_type == SOBJECT && parm == NULL
+ || *((char **) (parm + p[1].pe_ucode)) == NULL)
+ goto next;
+ break;
+
+ case SOBJECT:
+ if (((char *) (parm + p->pe_ucode)) == NULL)
+ goto next;
+ break;
+
+ default:
+ if (*((char **) (parm + p->pe_ucode)) == NULL)
+ goto next;
+ break;
+ }
+ }
+ switch (p->pe_type) {
+ case OPTL:
+ popt = (int *) (parm + p->pe_ucode);
+ break;
+
+ case UCODE:
+ if (mod->md_eucode == NULLIFP
+ || (*mod->md_eucode) (parm, &pe, p) == NOTOK)
+ goto bad;
+ break;
+
+ case ETAG:
+ if (en_type(parm, p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SEQ_START:
+ if (en_seq(*(char **) (parm + p->pe_ucode), p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SEQOF_START:
+ if (en_seqof(*(char **) (parm + p->pe_ucode), p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SET_START:
+ if (en_set(*(char **) (parm + p->pe_ucode), p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SETOF_START:
+ if (en_setof(*(char **) (parm + p->pe_ucode), p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case IMP_OBJ:
+ tmp = p++;
+ if (p->pe_type == EXTOBJ || p->pe_type == SEXTOBJ) {
+ if (enc_f(p->pe_tag, EXT2MOD(mod, (p + 1)), &pe, 1,
+ 0, (char *)0, *(char **) (parm + p->pe_ucode)) == NOTOK)
+ return (NOTOK);
+ } else if (p->pe_type == SOBJECT) {
+ if (en_obj((char *) parm + p->pe_ucode, mod->md_etab[p->pe_tag] + 1, mod,
+ &pe) == NOTOK)
+ goto bad;
+ } else
+ if (en_obj(*(char **) (parm + p->pe_ucode),
+ mod->md_etab[p->pe_tag] + 1, mod, &pe) == NOTOK)
+ goto bad;
+ pe->pe_class = CLASS(tmp);
+ pe->pe_id = TAG(tmp);
+ break;
+
+ case SOBJECT:
+ if (en_obj(parm + p->pe_ucode, mod->md_etab[p->pe_tag] + 1, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case OBJECT:
+ if (en_obj(*(char **) (parm + p->pe_ucode),
+ mod->md_etab[p->pe_tag] + 1, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case CHOICE_START:
+ if (en_choice(*(char **) (parm + p->pe_ucode), p, mod, &pe) ==NOTOK)
+ goto bad;
+ break;
+
+
+ case SCHOICE_START:
+ if (en_choice((char *) (parm + p->pe_ucode), p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SEXTOBJ:
+ if (p[1].pe_type != EXTMOD)
+ return pepsylose (mod, p, NULLPE, "en_set: missing EXTMOD");
+
+ if (enc_f(p->pe_tag, EXT2MOD(mod, (p + 1)), &pe, 1, 0, (char *)0,
+ parm + p->pe_ucode) == NOTOK)
+ return (NOTOK);
+ break;
+
+ case EXTOBJ:
+ if (p[1].pe_type != EXTMOD)
+ return pepsylose (mod, p, NULLPE, "en_set: missing EXTMOD");
+
+ if (enc_f(p->pe_tag, EXT2MOD(mod, (p + 1)), &pe, 1, 0, (char *)0,
+ *(char **) (parm + p->pe_ucode)) == NOTOK)
+ return (NOTOK);
+ break;
+
+ default:
+ if (en_type(parm, p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+ }
+
+ if ((ISDTYPE(p) || p->pe_type == BOPTIONAL) && pe != NULLPE) {
+ if (set_add(head, pe) == NOTOK)
+ return pepsylose (mod, p, NULLPE, "en_set bad set: %s",
+ pe_error(pe->pe_errno));
+ }
+next:
+ NEXT_TPE(p);
+ }
+
+ return (RET_OK(rpe, head));
+
+bad:
+ return (NOTOK);
+}
+
+
+/*
+ * Parse a sequence of calling appropriate routines to parse each sub
+ * type
+ */
+static int
+en_seqof(parm, p, mod, rpe)
+PEPYPARM parm;
+tpe *p;
+modtyp *mod; /* Module it is from */
+PE *rpe; /* Return value PE */
+{
+ PE head;
+ PE pe = NULLPE;
+ tpe *start; /* first entry in list */
+ tpe *tmp;
+
+ if (p->pe_type != SEQOF_START && p->pe_type != SSEQOF_START)
+ return pepsylose (mod, p, NULLPE, "en_seqof: missing SEQOF_START");
+
+ if ((head = pe_alloc(CLASS(p), PE_FORM_CONS, TAG(p))) == NULLPE)
+ return oom(mod, p);
+
+ start = p;
+ while ((char *) parm != NULL) {
+ p++;
+ while (p->pe_type != PE_END) {
+
+ DLOG (psap_log, LLOG_DEBUG, ("en_seqof type%d", p->pe_type));
+
+ switch (p->pe_type) {
+ case UCODE:
+ if (mod->md_eucode == NULLIFP
+ || (*mod->md_eucode) (parm, &pe, p) == NOTOK)
+ goto bad;
+ break;
+
+ case ETAG:
+ if (en_type(parm, p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SEQ_START:
+ if (en_seq(*(char **) (parm + p->pe_ucode), p, mod, &pe)==NOTOK)
+ goto bad;
+ break;
+
+ case SEQOF_START:
+ if (en_seqof(*(char **) (parm + p->pe_ucode), p, mod, &pe)
+ == NOTOK)
+ goto bad;
+ break;
+
+ case SET_START:
+ if (en_set(*(char **) (parm + p->pe_ucode), p, mod, &pe)==NOTOK)
+ goto bad;
+ break;
+
+ case SETOF_START:
+ if (en_setof(*(char **) (parm + p->pe_ucode), p, mod, &pe)
+ == NOTOK)
+ goto bad;
+ break;
+
+ case IMP_OBJ:
+ tmp = p++;
+ if (p->pe_type == EXTOBJ || p->pe_type == SEXTOBJ) {
+ if (enc_f(p->pe_tag, EXT2MOD(mod, (p + 1)), &pe, 1,
+ 0, (char *)0, *(char **) (parm + p->pe_ucode)) == NOTOK)
+ return (NOTOK);
+ } else if (p->pe_type == SOBJECT) {
+ if (en_obj((char *) (parm + p->pe_ucode), mod->md_etab[p->pe_tag] + 1,
+ mod, &pe) == NOTOK)
+ goto bad;
+ } else if (en_obj(*(char **) (parm + p->pe_ucode),
+ mod->md_etab[p->pe_tag] + 1, mod, &pe) == NOTOK)
+ goto bad;
+ pe->pe_class = CLASS(tmp);
+ pe->pe_id = TAG(tmp);
+ break;
+
+ case SOBJECT:
+ if (en_obj(parm + p->pe_ucode, mod->md_etab[p->pe_tag] + 1, mod, &pe) ==NOTOK)
+ goto bad;
+ break;
+
+ case OBJECT:
+ if (en_obj(*(char **) (parm + p->pe_ucode),
+ mod->md_etab[p->pe_tag] + 1, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case CHOICE_START:
+ if (en_choice(*(char **) (parm + p->pe_ucode), p, mod, &pe)
+ == NOTOK)
+ goto bad;
+ break;
+
+
+ case SCHOICE_START:
+ if (en_choice((char *) (parm + p->pe_ucode), p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SEXTOBJ:
+ if (p[1].pe_type != EXTMOD)
+ return pepsylose (mod, p+1, NULLPE,
+ "en_seqof: missing EXTMOD");
+ if (enc_f(p->pe_tag, EXT2MOD(mod, (p + 1)), &pe, 1, 0, (char *)0,
+ parm + p->pe_ucode) == NOTOK)
+ return (NOTOK);
+ break;
+
+ case EXTOBJ:
+ if (p[1].pe_type != EXTMOD)
+ return pepsylose (mod, p+1, NULLPE,
+ "en_seqof: missing EXTMOD");
+
+ if (enc_f(p->pe_tag, EXT2MOD(mod, (p + 1)), &pe, 1, 0, (char *)0,
+ *(char **) (parm + p->pe_ucode)) == NOTOK)
+ return (NOTOK);
+ break;
+
+ default:
+ if (en_type(parm, p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+ }
+ if (ISDTYPE(p) && pe != NULLPE) {
+ if (seq_add(head, pe, -1) == NOTOK)
+ return pepsylose (mod, p, NULLPE,
+ "en_seqof bad sequence: %s",
+ pe_error(pe->pe_errno));
+ }
+ if (NEXT_TPE(p) == NULLTPE)
+ goto bad;
+ }
+ parm = *(char **) (parm + p->pe_ucode); /* Any more ? */
+ p = start;
+ }
+
+ return (RET_OK(rpe, head));
+
+bad:
+ return (NOTOK);
+}
+
+/*
+ * Parse a setof, calling appropriate routines to parse each sub type
+ */
+static int
+en_setof(parm, p, mod, rpe)
+PEPYPARM parm;
+tpe *p;
+modtyp *mod; /* Module it is from */
+PE *rpe; /* Return value PE */
+{
+ PE head;
+ PE pe = NULLPE, last = NULLPE;
+ tpe *start;
+ tpe *tmp;
+
+ if (p->pe_type != SETOF_START && p->pe_type != SSETOF_START)
+ return pepsylose (mod, p, NULLPE, "en_setof: missing SETOF_START");
+
+ if ((head = pe_alloc(CLASS(p), PE_FORM_CONS, TAG(p))) == NULLPE)
+ return oom(mod,p);
+
+ start = p;
+ while ((char *) parm != NULL) {
+ p++;
+ while (p->pe_type != PE_END) {
+ DLOG (psap_log, LLOG_DEBUG, ("en_setof type%d",
+ p->pe_type));
+
+ switch (p->pe_type) {
+ case UCODE:
+ if (mod->md_eucode == NULLIFP
+ || (*mod->md_eucode) (parm, &pe, p) == NOTOK)
+ goto bad;
+ break;
+
+ case ETAG:
+ if (en_type(parm, p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SEQ_START:
+ if (en_seq(*(char **) (parm + p->pe_ucode), p, mod, &pe)==NOTOK)
+ goto bad;
+ break;
+
+ case SEQOF_START:
+ if (en_seqof(*(char **) (parm + p->pe_ucode), p, mod, &pe)
+ == NOTOK)
+ goto bad;
+ break;
+
+ case SET_START:
+ if (en_set(*(char **) (parm + p->pe_ucode), p, mod, &pe)==NOTOK)
+ goto bad;
+ break;
+
+ case SETOF_START:
+ if (en_setof(*(char **) (parm + p->pe_ucode), p, mod, &pe)
+ == NOTOK)
+ goto bad;
+ break;
+
+ case IMP_OBJ:
+ tmp = p++;
+ if (p->pe_type == EXTOBJ || p->pe_type == SEXTOBJ) {
+ if (enc_f(p->pe_tag, EXT2MOD(mod, (p + 1)), &pe, 1,
+ 0, (char *)0, *(char **) (parm + p->pe_ucode)) == NOTOK)
+ return (NOTOK);
+ } else if (p->pe_type == SOBJECT) {
+ if (en_obj((char *) parm + p->pe_ucode, mod->md_etab[p->pe_tag] + 1,
+ mod, &pe) == NOTOK)
+ goto bad;
+ } else
+ if (en_obj(*(char **) (parm + p->pe_ucode),
+ mod->md_etab[p->pe_tag] + 1, mod, &pe) == NOTOK)
+ goto bad;
+ pe->pe_class = CLASS(tmp);
+ pe->pe_id = TAG(tmp);
+ break;
+
+ case SOBJECT:
+ if (en_obj(parm + p->pe_ucode, mod->md_etab[p->pe_tag] + 1, mod, &pe) ==NOTOK)
+ goto bad;
+ break;
+
+ case OBJECT:
+ if (en_obj(*(char **) (parm + p->pe_ucode),
+ mod->md_etab[p->pe_tag] + 1, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case CHOICE_START:
+ if (en_choice(*(char **) (parm + p->pe_ucode), p, mod, &pe)
+ == NOTOK)
+ goto bad;
+ break;
+
+
+ case SCHOICE_START:
+ if (en_choice((char *) (parm + p->pe_ucode), p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SEXTOBJ:
+ if (p[1].pe_type != EXTMOD)
+ return pepsylose (mod, p + 1, NULLPE,
+ "en_setof: missing EXTMOD");
+ if (enc_f(p->pe_tag, EXT2MOD(mod, (p + 1)), &pe, 1, 0, (char *)0,
+ parm + p->pe_ucode) == NOTOK)
+ return (NOTOK);
+ break;
+
+ case EXTOBJ:
+ if (p[1].pe_type != EXTMOD)
+ return pepsylose (mod, p + 1, NULLPE,
+ "en_setof: missing EXTMOD");
+
+ if (enc_f(p->pe_tag, EXT2MOD(mod, (p + 1)), &pe, 1, 0, (char *)0,
+ *(char **) (parm + p->pe_ucode)) == NOTOK)
+ return (NOTOK);
+ break;
+
+ default:
+ if (en_type(parm, p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+ }
+
+ if (ISDTYPE(p) && pe != NULLPE) {
+ if (set_addon(head, last, pe) == NOTOK)
+ return pepsylose (mod, p, NULLPE, "en_setof bad set: %s",
+ pe_error(pe->pe_errno));
+ else
+ last = pe;
+ }
+
+ if (NEXT_TPE(p) == NULLTPE)
+ goto bad;;
+ }
+ parm = *(char **) (parm + p->pe_ucode); /* Any more ? */
+ p = start;
+ }
+
+ return (RET_OK(rpe, head));
+
+
+bad:
+ return (NOTOK);
+}
+
+/*
+ * encode a choice field. This means find which choice is taken and
+ * call en_type to encode it
+ */
+static int
+en_choice(parm, p, mod, rpe)
+PEPYPARM parm;
+tpe *p;
+modtyp *mod; /* Module it is from */
+PE *rpe; /* Return value PE */
+{
+ int cnt;
+
+ if (p->pe_type != CHOICE_START && p->pe_type != SCHOICE_START)
+ return pepsylose (mod, p, NULLPE, "en_choice:missing CHOICE_START");
+ p++;
+ if (p->pe_type != SCTRL)
+ return pepsylose (mod, p, NULLPE, "en_choice:missing SCTRL");
+
+ if (IF_USELECT(p)) {
+ if (mod->md_eucode == NULLIFP ||
+ (cnt = (*mod -> md_eucode) (parm, &rpe, p)) == NOTOK)
+ return pepsylose (mod, p, NULLPE, "choice selection failed");
+ }
+ else
+ cnt = *(int *) (parm + p->pe_ucode);
+
+ DLOG (psap_log, LLOG_DEBUG, ("cnt %d", cnt));
+
+ if (cnt != 0)
+ cnt--;
+ if (cnt < 0)
+ return pepsylose (mod, p, NULLPE, "en_choice:offset %d negative", cnt);
+
+ for (p++; p->pe_type != PE_END; NEXT_TPE(p)) {
+ if (cnt == 0 && p->pe_type == UCODE) {
+ if (mod->md_eucode == NULLIFP
+ || (*mod->md_eucode) (parm, &rpe, p) == NOTOK)
+ return (NOTOK);
+ }
+ if (ISDTYPE(p)) {
+ if (cnt == 0) {
+ if (en_etype(parm, p, mod, rpe) == NOTOK)
+ return (NOTOK);
+ return (OK);
+ }
+ cnt--;
+ }
+ }
+
+ return pepsylose (mod, p, NULLPE, "en_choice: no choice taken");
+}
+
+
+/*
+ * check to see if the object is present or not
+ */
+static int
+chkobj(mod, p, head)
+modtyp *mod;
+tpe *p;
+PE head;
+{
+
+ for (; p->pe_type != PE_END; NEXT_TPE(p)) {
+ if (!ISDTYPE(p))
+ continue;
+
+ if (p->pe_type == OBJECT) {
+ if (chkobj(mod, p, head))
+ return (1);
+ } else if (CHKTAG(mod, p, head))
+ return (1);
+
+ if (OPTIONAL(p) || DEFAULT(p))
+ continue;
+
+ return (0);
+ }
+ return (0);
+}
+
+/*
+ * Encode a single type for an explicit tag field If a basic type
+ * encode it, if a compound type call the appropriate encoding
+ * routine. Similar to en_type except we do the indirection on the
+ * ucode field
+ */
+static int
+en_etype(parm, p, mod, rpe)
+PEPYPARM parm;
+tpe *p;
+modtyp *mod; /* Module it is from */
+PE *rpe; /* Return value PE */
+{
+ tpe *tmp;
+ PE pe = NULLPE;
+
+ switch (p->pe_type) {
+ case PE_END:
+ case PE_START:
+ return (pepsylose (mod, p, pe, "en_etype:END/START type"));
+
+ case UCODE:
+ if (mod->md_eucode == NULLIFP
+ || (*mod->md_eucode) (parm, &pe, p) == NOTOK)
+ goto bad;
+ break;
+
+ case ETAG:
+ if ((pe = pe_alloc(CLASS(p), PE_FORM_CONS, TAG(p))) == NULLPE)
+ return oom(mod, p);
+ switch (p->pe_ucode) {
+ default:
+ p++;
+ if (en_etype(parm, p, mod, &pe->pe_cons) == NOTOK)
+ goto bad;
+ }
+ break;
+
+ case SEQ_START:
+ if (en_seq(*(char **) (parm + p->pe_ucode), p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SEQOF_START:
+ if (en_seqof(*(char **) (parm + p->pe_ucode), p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SET_START:
+ if (en_set(*(char **) (parm + p->pe_ucode), p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SETOF_START:
+ if (en_setof(*(char **) (parm + p->pe_ucode), p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SSEQ_START:
+ if (en_seq(parm + p->pe_ucode, p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SSEQOF_START:
+ if (en_seqof(parm + p->pe_ucode, p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SSET_START:
+ if (en_set(parm + p->pe_ucode, p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SSETOF_START:
+ if (en_setof(parm + p->pe_ucode, p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case IMP_OBJ:
+ tmp = p++;
+ if (p->pe_type == EXTOBJ || p->pe_type == SEXTOBJ) {
+ if (enc_f(p->pe_tag, EXT2MOD(mod, (p + 1)), &pe, 1,
+ 0, (char *)0, *(char **) (parm + p->pe_ucode)) == NOTOK)
+ return (NOTOK);
+ } else if (p->pe_type == SOBJECT) {
+ if (en_obj((char *) parm + p->pe_ucode, mod->md_etab[p->pe_tag] + 1, mod, &pe)
+ == NOTOK)
+ goto bad;
+ } else
+ if (en_obj(*(char **) (parm + p->pe_ucode),
+ mod->md_etab[p->pe_tag] + 1, mod, &pe) == NOTOK)
+ goto bad;
+ pe->pe_class = CLASS(tmp);
+ pe->pe_id = TAG(tmp);
+ break;
+
+ case SOBJECT:
+ if (en_obj(parm + p->pe_ucode, mod->md_etab[p->pe_tag] + 1, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case OBJECT:
+ if (en_obj(*(char **) (parm + p->pe_ucode),
+ mod->md_etab[p->pe_tag] + 1, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case CHOICE_START:
+ if (en_choice(*(char **) (parm + p->pe_ucode), p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case SCHOICE_START:
+ if (en_choice((char *) (parm + p->pe_ucode), p, mod, &pe) == NOTOK)
+ goto bad;
+ break;
+
+ case INTEGER:
+ DLOG (psap_log, LLOG_DEBUG, ("offset %d value %d",
+ p->pe_ucode,
+ *(integer *) (parm + p->pe_ucode)));
+ if ((pe = num2prim(*(integer *) (parm + p->pe_ucode), CLASS(p), TAG(p))) == NULLPE)
+ return oom (mod, p);
+
+ break;
+
+#ifdef PEPSY_REALS
+ case REALTYPE:
+ DLOG (psap_log, LLOG_DEBUG, ("offset %d value %g",
+ p->pe_ucode,
+ *(double *) (parm + p->pe_ucode)));
+ if ((pe = real2prim(*(double *) (parm + p->pe_ucode),
+ CLASS(p), TAG(p))) == NULLPE)
+ return oom(mod, p);
+ break;
+
+#endif
+ case BOOLEAN:
+ DLOG (psap_log, LLOG_DEBUG, ("offset %d value %d",
+ p->pe_ucode,
+ *(char *) (parm + p->pe_ucode)));
+
+ if ((pe = flag2prim(*(char *) (parm + p->pe_ucode), CLASS(p), TAG(p))) == NULLPE)
+ return oom(mod, p);
+ break;
+
+ case T_NULL:
+ DLOG (psap_log, LLOG_DEBUG, ("offset %d", p->pe_ucode));
+ if ((pe = pe_alloc(CLASS(p), PE_FORM_PRIM, TAG(p))) == NULLPE)
+ return oom(mod, p);
+ break;
+
+ case SANY:
+ (pe = (PE) (parm + p->pe_ucode))->pe_refcnt++;
+ break;
+
+ case ANY:
+ if ((parm + p->pe_ucode) == 0 || *(PE *) (parm + p->pe_ucode) == 0)
+#if ROSAP_HACK
+ /* hack for ROSAP. expects this strangeness */
+ pe = pe_alloc(PE_CLASS_UNIV, PE_FORM_PRIM, PE_PRIM_NULL);
+#else
+ pe = NULLPE;
+#endif
+ else
+ (pe = *(PE *) (parm + p->pe_ucode))->pe_refcnt++;
+ break;
+
+ case SEXTOBJ:
+ if (p[1].pe_type != EXTMOD)
+ return pepsylose (mod, p+1, NULLPE, "en_etype: missing EXTMOD");
+ if (enc_f(p->pe_tag, EXT2MOD(mod, (p + 1)), &pe, 1, 0, (char *)0,
+ parm + p->pe_ucode) == NOTOK)
+ return (NOTOK);
+ break;
+
+ case EXTOBJ:
+ if (p[1].pe_type != EXTMOD)
+ return pepsylose (mod, p+1, NULLPE, "en_etype: missing EXTMOD");
+ if (enc_f(p->pe_tag, EXT2MOD(mod, (p + 1)), &pe, 1, 0, (char *)0,
+ *(char **) (parm + p->pe_ucode)) == NOTOK)
+ return (NOTOK);
+ break;
+
+ case SOCTETSTRING:
+ if ((pe = qb2prim((struct qbuf *) (parm + p->pe_ucode), CLASS(p), TAG(p))) == NULLPE)
+ return oom(mod, p);
+ break;
+
+ case SBITSTRING:
+ {
+ char *cp;
+ int i;
+
+ if ((cp = bitstr2strb((PE) (parm + p->pe_ucode), &i)) == NULL)
+ return oom(mod, p);
+ if ((pe = strb2bitstr(cp, i, CLASS(p), TAG(p))) == NULLPE)
+ return oom(mod, p);
+ free(cp);
+ if ((pe = bit2prim (pe)) == NULLPE)
+ return oom(mod, p);
+ }
+ break;
+
+ case OCTETSTRING:
+ if ((pe = qb2prim(*(struct qbuf **) (parm + p->pe_ucode), CLASS(p), TAG(p))) == NULLPE)
+ return oom(mod, p);
+ break;
+
+ case T_STRING:
+ if (*(char **) (parm + p->pe_ucode) == NULLCP)
+ return pepsylose (mod, &p[1], NULLPE,
+ "en_etype:T_STRING missing pointer");
+
+ if ((pe = str2prim(*(char **) (parm + p->pe_ucode),
+ strlen(*(char **) (parm + p->pe_ucode)),
+ CLASS(p), TAG(p))) == NULLPE)
+ return oom(mod, p);
+ break;
+
+ case OCTET_PTR:
+ if (p[1].pe_type != OCTET_LEN)
+ return pepsylose (mod, &p[1], NULLPE,
+ "en_etype: missing OCTET_LEN");
+
+ if (*(char **) (parm + p->pe_ucode) == NULLCP)
+ return pepsylose (mod, &p[1], NULLPE,
+ "en_etype:OCTET_PTR missing pointer");
+
+ if (*(int *) (parm + (p + 1)->pe_ucode) < 0)
+ return pepsylose (mod, &p[1], NULLPE,
+ "en_etype:OCTET_LEN negative length");
+
+ if ((pe = str2prim(*(char **) (parm + p->pe_ucode),
+ *(int *) (parm + (p + 1)->pe_ucode),
+ CLASS(p), TAG(p))) == NULLPE)
+ return oom(mod, p);
+ break;
+
+ case BITSTR_PTR:
+ if (p[1].pe_type != BITSTR_LEN)
+ return pepsylose (mod, &p[1], NULLPE,
+ "en_etype:missing BITSTR_LEN");
+
+ if (*(char **) (parm + p->pe_ucode) == NULLCP)
+ return pepsylose (mod, &p[1], NULLPE,
+ "en_etype:BITSTR_PTR missing pointer");
+
+ if (*(int *) (parm + (p + 1)->pe_ucode) < 0)
+ return pepsylose (mod, &p[1], NULLPE,
+ "en_etype:BITSTR_LEN negative length");
+
+ if ((pe = strb2bitstr(*(char **) (parm + p->pe_ucode),
+ *(int *) (parm + (p + 1)->pe_ucode),
+ CLASS(p), TAG(p))) == NULLPE
+ || (pe = bit2prim(pe)) == NULLPE)
+ return oom(mod, p);
+ break;
+
+ case BITSTRING:
+ {
+ char *cp;
+ int i;
+
+ if ((cp = bitstr2strb(*(PE *) (parm + p->pe_ucode), &i)) == NULL)
+ return oom(mod, p);
+ if ((pe = strb2bitstr(cp, i, CLASS(p), TAG(p))) == NULLPE)
+ return oom(mod, p);
+ free(cp);
+ if ((pe = bit2prim(pe)) == NULLPE)
+ return oom(mod, p);
+ }
+ break;
+
+ case SOBJID:
+ if ((pe = obj2prim((OID) (parm + p->pe_ucode), CLASS(p), TAG(p))) == NULLPE)
+ return oom(mod, p);
+ break;
+
+ case OBJID:
+ if ((pe = obj2prim(*(OID *) (parm + p->pe_ucode), CLASS(p), TAG(p)))
+ == NULLPE)
+ return oom(mod, p);
+ break;
+
+ case FN_CALL:
+ if ((FN_PTR(mod, p))(parm, &pe) == NOTOK)
+ return pepsylose (mod, p, NULLPE,
+ "en_etype:FN_CALL:call failed");
+ if (STAG(p) >= 0) {
+ pe->pe_class = CLASS(p);
+ pe->pe_id = TAG(p);
+ }
+ break;
+
+ default:
+ return pepsylose (mod, p, NULLPE, "en_etype: type not implemented");
+ }
+ return (RET_OK(rpe, pe));
+
+bad:
+ return (NOTOK);
+}
diff --git a/src/isode/pepsy/etabs.c b/src/isode/pepsy/etabs.c
new file mode 100644
index 000000000..806e5ac49
--- /dev/null
+++ b/src/isode/pepsy/etabs.c
@@ -0,0 +1,2284 @@
+/* etabs.c */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:30:33 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:19:00 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:39:14 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:42:55 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+#include <stdio.h>
+#include <ctype.h>
+#include "pepsydefs.h"
+#include "sym.h"
+#include "pass2.h"
+#include "mine.h"
+
+s_table *head;
+
+extern s_table *lookup_list(), *proc_def();
+
+extern char *c_tag(), *c_class();
+extern char *ec_tag(), *ec_class();
+extern char *strip_last();
+extern char *get_val(), *get_comp(), *get_string();
+extern s_table *get_offset();
+extern char *my_strcat(), *strp2name();
+extern char *my_new_str();
+extern char *mymodule;
+extern char *modsym();
+extern char *concat();
+extern char *genlabel();
+extern char *notidtoid();
+extern char *code2name();
+extern char *yp2name();
+extern YV calc_yv();
+extern SY syfind();
+static s_table *en_ptr;
+extern s_table *ptr;
+extern char *rm_indirect();
+extern char *getfield();
+extern char *setfield();
+
+static int cons_type = 0;
+/* int explicit; */
+
+s_table *save_ptr;
+
+extern YT gen_etag();
+
+#define WORDSIZE 20
+#define MAXNAME 256 /* maximum size of a identifier */
+
+#ifdef DEBUG
+char *str_yp_code[] = {
+ "Undefined", "Boolean", "Integer", "Named number list", "Bitstring",
+ "Named Bitstring list", "Octet String", "Null", "Sequence",
+ "Sequence of", "Sequence list", "Set", "Set of", "Set list",
+ "Choice", "Any", "Object Identifier",
+ "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "Identifier",
+
+};
+
+#endif
+
+/*
+ * table encode a type. generate tables for the encoding of a type
+ */
+tenc_typ(fp, yp, id, type)
+FILE *fp;
+YP yp;
+char *id;
+char *type;
+{
+
+ char *t, *f;
+ char *p1;
+ YP y;
+ YAL yal;
+
+
+ if (yp->yp_code < 0 || yp->yp_code > YP_REAL)
+ ferrd(1, "tenc_typ: unimplemented type %d\n", yp->yp_code);
+
+ if (yp == NULL) {
+ ferr(0, "tenc_typ:NULL argument\n");
+ return;
+ }
+
+ /* Preserve the type of the containing object */
+ if (type)
+ t = type;
+ else if (yp->yp_param_type) {
+ char *t1;
+ /* we have a [[ P type ]] specification */
+ if ((t1 = rm_indirect(yp->yp_param_type)) == NULLCP) {
+ fprintf(stderr,
+ "\ntenc_typ:SETLIST can't extract direct type from %s\n",
+ yp->yp_param_type);
+ exit(1);
+ }
+ t = strdup(t1);
+ } else
+ t = my_strcat("struct ", modsym(mymodule, id, "type"));
+
+ if (yal = yp->yp_bef_alist) {
+ yal->yal_type = t;
+ if (yal->yal_enc)
+ gen_act(fp, yp->yp_bef_alist->yal_enc);
+ }
+ if (yal = yp->yp_aft_alist) {
+ yal->yal_type = t;
+ }
+ if (yal = yp->yp_control_act)
+ yal -> yal_type = t;
+
+ if (yal = yp->yp_optional_act)
+ yal -> yal_type = t;
+
+ if (yp->yp_flags & YP_DEFAULT)
+ gdflt(fp, yp, G_ENC);
+
+ if ((yp->yp_flags & YP_PARMVAL) && yp->yp_parm) {
+ if ((f = getfield(yp->yp_parm)) == NULLCP) {
+ fprintf(stderr, "\ntenc_typ: can't extract field from %s\n",
+ yp->yp_parm);
+ exit(1);
+ }
+ f = strdup(f);
+ } else
+ f = yp->yp_varexp;
+
+ if ((yp->yp_flags & (YP_OPTIONAL|YP_OPTCONTROL|YP_DEFAULT))
+ == (YP_OPTIONAL|YP_OPTCONTROL)) {
+ char *f1;
+ char *bitno;
+
+ if (yp -> yp_optional_act && yp -> yp_optional_act -> yal_enc) {
+ fprintf (fp, "\t{ BOPTIONAL, %d, 0, FL_USELECT},\n",
+ yp -> yp_optional_act -> yal_enc -> a_num);
+ }
+ else {
+ if ((f1 = getfldbit(yp->yp_optcontrol, &bitno)) == NULLCP) {
+ fprintf(stderr,
+ "\ntenc_typ:BOPTIONAL: can't extract field from %s\n",
+ yp->yp_optcontrol);
+ exit(1);
+ }
+ (void) fprintf(fp, "\t{ BOPTIONAL, AOFFSET(%s, %s), %s, 0},\n",
+ t, f1, bitno);
+ }
+ }
+
+ /* handle explicit tags - one day may have to change this if anyone
+ * ever defines a type with more than one explicit tag
+ */
+ if (yp->yp_flags & YP_TAG && !(yp->yp_flags & YP_IMPLICIT)) {
+ (void) fprintf(fp, "\t{ ETAG, 0, ");
+ (void) fprintf(fp, "%s, %s },\n", ec_tag(yp), ec_class(yp));
+ }
+
+ if (yp->yp_yfn && yp->yp_yfn->yfn_enc) {
+ gen_fn(fp, yp, yp->yp_yfn->yfn_enc);
+
+ if (yp->yp_aft_alist && yp->yp_aft_alist->yal_enc)
+ gen_act(fp, yp->yp_aft_alist->yal_enc);
+
+ return;
+ }
+
+ switch (yp->yp_code) {
+
+ case YP_UNDF:
+ ferr(1, "tenc_typ:Undefined type\n");
+
+ case YP_BOOL:
+ p1 = "BOOLEAN";
+ if (yp->yp_intexp)
+ f = setfield(yp->yp_intexp);
+ if (noindirect(f))
+ ferr(1, "tenc_typ:BOOL: must specify a field [[ b .. ]]\n");
+ if (yp->yp_varexp || (yp->yp_intexp && !noindirect(f)))
+ break;
+ ferr(1, "tenc_typ:BOOL: couldn't determine type\n");
+
+ case YP_INTLIST:
+
+ case YP_INT:
+
+ case YP_ENUMLIST:
+ if (yp->yp_intexp)
+ f = setfield(yp->yp_intexp);
+ if (noindirect(f))
+ ferr(1, "tenc_typ:INT: must specify a field [[ i .. ]]\n");
+ if (yp->yp_varexp || (yp->yp_intexp && !noindirect(f))) {
+ p1 = "INTEGER";
+ break;
+ }
+ ferr(1, "tenc_typ:INT: couldn't determine type\n");
+ break;
+
+ case YP_REAL:
+ if (yp->yp_strexp)
+ f = setfield(yp->yp_strexp);
+ if (noindirect(f))
+ ferr(1, "tenc_typ:REAL: must specify a field [[ r .. ]]\n");
+ if (yp->yp_varexp || (yp->yp_strexp && !noindirect(f))) {
+ p1 = "REALTYPE";
+ break;
+ }
+ ferr(1, "tenc_typ:REAL: couldn't determine type\n");
+ break;
+
+ case YP_BIT:
+ case YP_BITLIST:
+ if (yp->yp_strexp && yp->yp_intexp) {
+ if (yp->yp_strexp)
+ f = setfield(yp->yp_strexp);
+ if (noindirect(f))
+ ferr(1, "tenc_typ:BIT: must specify a field [[ x .. ]]\n");
+ p1 = "BITSTR_PTR";
+ prnte(fp, t, f, yp, p1);
+ if (yp->yp_intexp)
+ f = setfield(yp->yp_intexp);
+ if (noindirect(f))
+ ferr(1, "tenc_typ:BIT: must specify a field [[ x .. ]]\n");
+ p1 = "BITSTR_LEN";
+ break;
+ }
+ if (yp->yp_strexp == NULLCP && yp->yp_intexp)
+ f = setfield(yp->yp_intexp);
+ if (yp->yp_varexp || (yp->yp_intexp && !noindirect(f))) {
+ p1 = "BITSTRING";
+ break;
+ }
+ t = NULL;
+ p1 = NULL;
+ (void) fprintf(fp, "\t{ SBITSTRING, 0, %s, %s },\n",
+ c_tag(yp), c_class(yp));
+ break;
+
+ case YP_OCT:
+ if (yp->yp_strexp) {
+ switch (yp->yp_prfexp) {
+ case 'q': /* [[ q parm->qbufptr ]] */
+ if (yp->yp_strexp)
+ f = setfield(yp->yp_strexp);
+ if (noindirect(f))
+ p1 = "SOCTETSTRING";
+ else
+ p1 = "OCTETSTRING";
+ break;
+
+ case 's': /* [[ s ptr ]] */
+ if (yp->yp_strexp)
+ f = setfield(yp->yp_strexp);
+ if (noindirect(f))
+ ferr(1, "tenc_typ:OCT: must specify a field [[ s .. ]]\n");
+ p1 = "T_STRING";
+ break;
+
+ case 'o': /* [[ o ptr $ length ]] */
+ if (yp->yp_strexp)
+ f = setfield(yp->yp_strexp);
+ if (noindirect(f))
+ ferr(1, "tenc_typ:OCT: must specify a field [[ s .. ]]\n");
+ p1 = "OCTET_PTR";
+ prnte(fp, t, f, yp, p1);
+ if (yp->yp_intexp)
+ f = setfield(yp->yp_intexp);
+ if (noindirect(f))
+ ferr(1, "tenc_typ:OCT: must specify a field [[ s .. ]]\n");
+ p1 = "OCTET_LEN";
+ break;
+
+ default:
+ fprintf(stderr,"\ntenc_typ: Unknown Octet string specifier %c\n",
+ yp->yp_prfexp);
+ exit(1);
+ }
+ break;
+ }
+
+ if (f && !noindirect(f)) {
+ p1 = "OCTETSTRING";
+ break;
+ }
+ t = NULL;
+ p1 = NULL;
+ (void) fprintf(fp, "\t{ SOCTETSTRING, 0, %s, %s },\n",
+ c_tag(yp), c_class(yp));
+ break;
+
+ case YP_OID:
+ if (yp->yp_strexp)
+ f = setfield(yp->yp_strexp);
+ if (yp->yp_varexp || (yp->yp_strexp && !noindirect(f))) {
+ p1 = "OBJID";
+ break;
+ }
+ t = NULL;
+ p1 = NULL;
+ (void) fprintf(fp, "\t{ SOBJID, 0, %s, %s },\n",
+ c_tag(yp), c_class(yp));
+ break;
+
+
+ case YP_SEQ:
+ case YP_SET:
+ case YP_ANY:
+ if (yp->yp_strexp)
+ f = setfield(yp->yp_strexp);
+ if (yp->yp_varexp || (yp->yp_strexp && !noindirect(f))) {
+ p1 = "ANY";
+ break;
+ }
+ t = NULL;
+ p1 = NULL;
+ (void) fprintf(fp, "\t{ SANY, 0, %s, %s },\n",
+ c_tag(yp), c_class(yp));
+ break;
+
+ case YP_NULL:
+ p1 = "T_NULL";
+ t = NULL;
+ break;
+
+ case YP_IDEFINED:
+ p1 = NULL;
+ if ((yp->yp_flags & YP_PARMVAL) && yp->yp_prfexp)
+ ferr(1,
+ "\n[[ ? reference ]] [[ p reference ]] is illegal\n\t only one allowed\n");
+
+ if (yp->yp_prfexp) { /* [[ ? parm->field ]] - complex to process */
+ gen_identry(fp, t, f, yp, gen_ventry);
+ break;
+ }
+
+ {
+ /* Predefined Universal Type */
+ struct univ_typ *p, *univtyp();
+
+ if ((p = univtyp(yp->yp_identifier))) {
+ if (p->univ_flags & UNF_EXTMOD) {
+ yp->yp_module = p->univ_mod;
+ goto do_obj;
+ }
+ if (f == NULL || noindirect(f)) {/* No offset type */
+ if (yp->yp_flags & YP_TAG
+ && yp->yp_flags & YP_IMPLICIT)
+ prstfield(fp, p->univ_tab, t, f,
+ int2tstr(yp->yp_tag->yt_value->yv_number),
+ c_flags(yp, yp->yp_tag->yt_class));
+ /*
+ (void) fprintf(fp, "\t{ S%s, 0, %d, %s },\n",
+ p->univ_tab,
+ yp->yp_tag->yt_value->yv_number,
+ c_flags(yp, yp->yp_tag->yt_class));
+ */
+ else
+ prstfield(fp, p->univ_tab, t, f,
+ int2tstr((int)p->univ_id),
+ c_flags(yp, p->univ_class));
+ /*
+ (void) fprintf(fp, "\t{ S%s, 0, %d, %s },\n",
+ p->univ_tab, p->univ_id,
+ c_flags(yp, p->univ_class));
+ */
+ break;
+ }
+ if (yp->yp_flags & YP_TAG && yp->yp_flags & YP_IMPLICIT)
+ prtfield(fp, p->univ_tab, t, f,
+ int2tstr(yp->yp_tag->yt_value->yv_number),
+ c_flags(yp, yp->yp_tag->yt_class));
+ /*
+ (void) fprintf(fp, "\t{ %s, OFFSET(%s, %s), %d, %s },\n",
+ p->univ_tab, t, f,
+ yp->yp_tag->yt_value->yv_number,
+ c_flags(yp, yp->yp_tag->yt_class));
+ */
+ else
+ prtfield(fp, p->univ_tab, t, f, int2tstr((int)p->univ_id),
+ c_flags(yp, p->univ_class));
+ /*
+ (void) fprintf(fp, "\t{ %s, OFFSET(%s, %s), %d, %s },\n",
+ p->univ_tab, t, f, p->univ_id,
+ c_flags(yp, p->univ_class));
+ */
+ break;
+ }
+ }
+do_obj:
+ if (yp->yp_flags & YP_TAG && yp->yp_flags & YP_IMPLICIT)
+ (void) fprintf(fp, "\t{ IMP_OBJ, 0, %s, %s },\n", c_tag(yp), c_class(yp));
+ if (yp->yp_module == NULL
+ || strcmp(yp->yp_module, mymodule) == 0) {
+ if (f == NULL || noindirect(f)) { /* No offset type */
+ prstfield(fp, "OBJECT", t, f,
+ concat("_Z", proc_name(yp->yp_identifier, 0)),
+ c_class(yp));
+ /*
+ (void) fprintf(fp, "\t{ SOBJECT, 0, _Z%s, %s },\n",
+ proc_name(yp->yp_identifier, 0), c_class(yp));
+ */
+ } else
+ prtfield(fp, "OBJECT", t, f,
+ concat("_Z", proc_name(yp->yp_identifier, 0)),
+ c_class(yp));
+ /*
+ (void) fprintf(fp,
+ "\t{ OBJECT, OFFSET(%s, %s), _Z%s, %s },\n",
+ t, f, proc_name(yp->yp_identifier, 0), c_class(yp));
+ */
+ } else {
+ if (f == NULL || noindirect(f)) { /* No offset type */
+ prstfield(fp, "EXTOBJ", t, f,
+ concat("_Z", strp2name(yp->yp_identifier, yp->yp_module)),
+ c_class(yp));
+ /*
+ (void) fprintf(fp, "\t{ SEXTOBJ, 0, _Z%s, %s },\n",
+ strp2name(yp->yp_identifier, yp->yp_module),
+ c_class(yp));
+ */
+ } else
+ prtfield(fp, "EXTOBJ", t, f,
+ concat("_Z", strp2name(yp->yp_identifier, yp->yp_module)),
+ c_class(yp));
+ /*
+ (void) fprintf(fp,
+ "\t{ EXTOBJ, OFFSET(%s, %s), _Z%s, %s },\n",
+ t, f, strp2name(yp->yp_identifier, yp->yp_module),
+ c_class(yp));
+ */
+
+ (void) fprintf(fp, "\t{ EXTMOD, %d, 0, 0 },\n",
+ gen_modref(yp->yp_module));
+ }
+ break;
+
+ case YP_SEQLIST:
+ p1 = NULL;
+ /* support for -h flag */
+ cons_type++;
+ save_ptr = en_ptr;
+ if (yp->yp_varexp == NULL && type != NULL)
+ ferr(1, "tenc_typ:YP_SEQLIST:NULL varexp pointer\n");
+ prcte(fp, type, t, f, yp, "SEQ_START");
+ if (y = yp->yp_type) {
+ char *t1;
+
+ /* compute the type of data */
+ if (yp->yp_param_type) {
+ /* we have a [[ P type ]] specification */
+ if ((t1 = rm_indirect(yp->yp_param_type)) == NULLCP) {
+ fprintf(stderr,
+ "\ntenc_typ:SEQLIST: can't extract direct type from %s\n",
+ yp->yp_param_type);
+ exit(1);
+ }
+ yp->yp_structname = strdup(t1);
+ } else if (type) {
+ if (yp->yp_declexp == NULL)
+ ferr(1, "tenc_typ:YP_SEQLIST:no declexp\n");
+ yp->yp_structname = my_strcat("struct ", yp->yp_declexp);
+ } else
+ yp->yp_structname = t;
+
+ if (optfield(y)) {
+ (void) fprintf(fp,
+ "\t{ OPTL, OFFSET(%s, optionals), 0, 0 },\n",
+ yp->yp_structname);
+ }
+ tenc_loop(fp, y, id, yp->yp_structname);
+ }
+ (void) fprintf(fp, "\t{ PE_END, 0, 0, 0 },\n");
+ en_ptr = save_ptr;
+ cons_type--;
+ break;
+
+ case YP_SETLIST:
+ p1 = NULL;
+ /* support for -h flag */
+ cons_type++;
+ if (yp->yp_varexp == NULL && type != NULL)
+ ferr(1, "tenc_typ:YP_SETLIST:NULL varexp pointer\n");
+ prcte(fp, type, t, f, yp, "SET_START");
+ if (y = yp->yp_type) {
+ char *t1;
+
+ if (yp->yp_param_type) {
+ /* we have a [[ P type ]] specification */
+ if ((t1 = rm_indirect(yp->yp_param_type)) == NULLCP) {
+ fprintf(stderr,
+ "\ntenc_typ:SETLIST can't extract direct type from %s\n",
+ yp->yp_param_type);
+ exit(1);
+ }
+ yp->yp_structname = strdup(t1);
+ } else if (type) {
+ if (yp->yp_declexp == NULL)
+ ferr(1, "tenc_typ:YP_SETLIST:no declexp\n");
+ yp->yp_structname = my_strcat("struct ", yp->yp_declexp);
+ } else
+ yp->yp_structname = t;
+ if (optfield(y)) {
+ (void) fprintf(fp,
+ "\t{ OPTL, OFFSET(%s, optionals), 0, 0 },\n",
+ yp->yp_structname);
+ }
+ tenc_loop(fp, y, id, yp->yp_structname);
+ }
+ (void) fprintf(fp, "\t{ PE_END, 0, 0, 0 },\n");
+ en_ptr = save_ptr;
+ cons_type--;
+ break;
+
+ case YP_SEQTYPE:
+ p1 = NULL;
+ cons_type++;
+ save_ptr = en_ptr;
+ prcte(fp, type, t, f, yp, "SEQOF_START");
+ if (y = yp->yp_type) {
+ char *t1;
+
+ if (yp->yp_param_type) {
+ /* we have a [[ P type ]] specification */
+ if ((t1 = rm_indirect(yp->yp_param_type)) == NULLCP) {
+ fprintf(stderr,
+ "\ntenc_typ:SETLIST can't extract direct type from %s\n",
+ yp->yp_param_type);
+ exit(1);
+ }
+ yp->yp_structname = strdup(t1);
+ } else if (type) {
+ if (yp->yp_declexp == NULL)
+ ferr(1, "tenc_typ:YP_SEQTYPE:no declexp\n");
+ yp->yp_structname = my_strcat("struct ", yp->yp_declexp);
+ } else
+ yp->yp_structname = t;
+ tenc_loop(fp, y, id, yp->yp_structname);
+ }
+ if (yp->yp_flags & YP_CONTROLLED) {
+ char *f1;
+
+ if ((f1 = getfield(yp->yp_control)) == NULLCP) {
+ fprintf(stderr, "\ntenc_typ:SEQ OF: can't extract field from %s\n",
+ yp->yp_control);
+ exit(1);
+ }
+ (void) fprintf(fp, "\t{ PE_END, OFFSET(%s, %s), 0, 0 },\n",
+ yp->yp_structname, f1);
+ } else if (yp->yp_structname != NULL)
+ (void) fprintf(fp, "\t{ PE_END, OFFSET(%s, next), 0, 0 },\n",
+ yp->yp_structname);
+ else
+ (void) fprintf(fp, "\t{ PE_END, 0, 0, 0 },\n");
+ en_ptr = save_ptr;
+ cons_type--;
+ break;
+
+ case YP_SETTYPE:
+ p1 = NULL;
+ cons_type++;
+ save_ptr = en_ptr;
+ prcte(fp, type, t, f, yp, "SETOF_START");
+
+ if (y = yp->yp_type) {
+ char *t1;
+
+ if (yp->yp_param_type) {
+ /* we have a [[ P type ]] specification */
+ if ((t1 = rm_indirect(yp->yp_param_type)) == NULLCP) {
+ fprintf(stderr,
+ "\ntenc_typ:SETTYPE can't extract direct type from %s\n",
+ yp->yp_param_type);
+ exit(1);
+ }
+ yp->yp_structname = strdup(t1);
+ } else if (type) {
+ if (yp->yp_declexp == NULL)
+ ferr(1, "tenc_typ:YP_SETTYPE:no declexp\n");
+ yp->yp_structname = my_strcat("struct ", yp->yp_declexp);
+ } else
+ yp->yp_structname = t;
+ tenc_loop(fp, y, id, yp->yp_structname);
+ }
+ if (yp->yp_flags & YP_CONTROLLED) {
+ char *f1;
+
+ if ((f1 = getfield(yp->yp_control)) == NULLCP) {
+ fprintf(stderr, "\ntenc_typ:SET OF: can't extract field from %s\n",
+ yp->yp_control);
+ exit(1);
+ }
+ (void) fprintf(fp, "\t{ PE_END, OFFSET(%s, %s), 0, 0 },\n",
+ yp->yp_structname, f1);
+ } else if (yp->yp_structname != NULL)
+ (void) fprintf(fp, "\t{ PE_END, OFFSET(%s, next), 0, 0 },\n",
+ yp->yp_structname);
+ else
+ (void) fprintf(fp, "\t{ PE_END, 0, 0, 0 },\n");
+ en_ptr = save_ptr;
+ cons_type--;
+ break;
+
+ case YP_CHOICE:
+ p1 = NULL;
+ /* support for -h flag */
+ if (hflag && (y = yp->yp_type) && !y->yp_next) {
+ tenc_typ(fp, y, id, yp->yp_structname);
+ break;
+ }
+ cons_type++;
+ save_ptr = en_ptr;
+ if (type == NULL || type && noindirect(f))
+ prstfield(fp, "CHOICE_START", t, f, NULLCP, c_class(yp));
+ else
+ prtfield(fp, "CHOICE_START", t, type ? f : NULLCP, NULLCP, c_class(yp));
+ if (y = yp->yp_type) {
+ char *t1;
+
+ if (yp->yp_param_type) {
+ /* we have a [[ P type ]] specification */
+ if ((t1 = rm_indirect(yp->yp_param_type)) == NULLCP) {
+ fprintf(stderr,
+ "\ntenc_typ:CHOICE can't extract direct type from %s\n",
+ yp->yp_param_type);
+ exit(1);
+ }
+ yp->yp_structname = strdup(t1);
+ } else if (type) {
+ if (yp->yp_declexp == NULL)
+ ferr(1, "tenc_typ:YP_CHOICE:no declexp\n");
+ yp->yp_structname = my_strcat("struct ", yp->yp_declexp);
+ } else
+ yp->yp_structname = t;
+
+ if (yp -> yp_control_act && yp->yp_control_act->yal_enc) {
+ (void) fprintf (fp, "\t{ SCTRL, %d, 0, FL_USELECT },\n",
+ yp -> yp_control_act -> yal_enc -> a_num);
+ }
+ else if (yp->yp_flags & YP_CONTROLLED) {
+ char *f1;
+
+ if ((f1 = getfield(yp->yp_control)) == NULLCP) {
+ fprintf(stderr, "\ntenc_typ:CHOICE: can't extract field from %s\n",
+ yp->yp_control);
+ exit(1);
+ }
+ (void) fprintf(fp, "\t{ SCTRL, OFFSET(%s, %s), 0, 0 },\n",
+ yp->yp_structname, f1);
+ } else if (yp->yp_structname != NULL)
+ (void) fprintf(fp, "\t{ SCTRL, OFFSET(%s, offset), 0, 0 },\n",
+ yp->yp_structname);
+ else
+ ferr(1, "\nCHOICE missing SCTRL\n");
+ tenc_loop(fp, y, id, yp->yp_structname);
+ }
+ (void) fprintf(fp, "\t{ PE_END, 0, 0, 0 },\n");
+ en_ptr = save_ptr;
+ cons_type--;
+ break;
+
+ default:
+ ferrd(1, "tenc_typ: yp_code = %d not implemented\n", yp->yp_code);
+ }
+
+ if (p1 != NULL)
+ prnte(fp, t, f, yp, p1);
+
+ if (yp->yp_aft_alist && yp->yp_aft_alist->yal_enc)
+ gen_act(fp, yp->yp_aft_alist->yal_enc);
+
+}
+
+static int fflags[] = {
+ 0, 1, 2, 2, 3, 3, 4, 5, 16, 16, 16, 17, 17, 17,
+0, -1, 6, 0, 10, 9};
+
+/*
+ * calculate the tag string of the given type and return it
+ */
+char *
+c_tag(yp)
+YP yp;
+{
+ static char buf[WORDSIZE];
+ int i;
+
+ if (yp->yp_flags & YP_TAG && yp->yp_flags & YP_IMPLICIT) {
+ i = yp->yp_tag->yt_value->yv_number;
+ } else {
+ if (yp->yp_code < 0 || yp->yp_code > YP_REAL
+ || yp->yp_code == YP_CHOICE)
+ i = 0;
+ else
+ i = fflags[yp->yp_code];
+ /* Choice now legal argument - to allow prte_* routines to work */
+ if (i == 0 && yp->yp_code != YP_CHOICE)
+ ferrd (1, "c_tag:Unknown Tag %d", yp->yp_code);
+ }
+
+ (void) sprintf(buf, "%d", i);
+
+ return (buf);
+}
+
+/*
+ * calculate the tag string of the explicit tag and return it
+ */
+char *
+ec_tag(yp)
+YP yp;
+{
+ static char buf[WORDSIZE];
+ int i;
+
+ if (!(yp->yp_flags & YP_TAG) || yp->yp_flags & YP_IMPLICIT)
+ ferr(1, "ec_tag:internal error:called with out explicit tag\n");
+
+ i = yp->yp_tag->yt_value->yv_number;
+
+ (void) sprintf(buf, "%d", i);
+
+ return (buf);
+}
+
+/*
+ * produce a string that represents the class/flags field for a given
+ * yp entry taking the class to be that given in cl
+ */
+char *
+c_flags(yp, cl)
+YP yp;
+PElementClass cl;
+{
+ char *p1;
+ static char buf[STRSIZE];
+
+ switch (yp->yp_code) {
+ case YP_IDEFINED:
+ case YP_CHOICE:
+ if (yp->yp_flags & YP_TAG)
+ break;
+ if (yp->yp_flags & YP_OPTIONAL
+ && ((yp->yp_flags & (YP_OPTIONAL|YP_OPTCONTROL|YP_DEFAULT))
+ != (YP_OPTIONAL|YP_OPTCONTROL))) {
+ p1 = "FL_OPTIONAL";
+ } else if (yp->yp_flags & YP_DEFAULT) {
+ p1 = "FL_DEFAULT";
+ } else
+ p1 = "0";
+ return (p1);
+
+ default:
+ break;
+ }
+ p1 = class2str(cl);
+ if (yp->yp_flags & YP_OPTIONAL
+ && ((yp->yp_flags & (YP_OPTIONAL|YP_OPTCONTROL|YP_DEFAULT))
+ != (YP_OPTIONAL|YP_OPTCONTROL))) {
+ (void) strncpy(buf, p1, STRSIZE);
+ p1 = strncat(buf, "|FL_OPTIONAL", STRSIZE);
+ } else if (yp->yp_flags & YP_DEFAULT) {
+ (void) strncpy(buf, p1, STRSIZE);
+ p1 = strncat(buf, "|FL_DEFAULT", STRSIZE);
+ }
+ return (p1);
+}
+/*
+ * turn the class number into its corresponding string
+ */
+char *
+class2str(cl)
+PElementClass cl;
+{
+ register char *p1;
+
+ switch (cl) {
+ case PE_CLASS_UNIV:
+ p1 = "FL_UNIVERSAL";
+ break;
+
+ case PE_CLASS_APPL:
+ p1 = "FL_APPLICATION";
+ break;
+
+ case PE_CLASS_PRIV:
+ p1 = "FL_PRIVATE";
+ break;
+
+ case PE_CLASS_CONT:
+ p1 = "FL_CONTEXT";
+ break;
+
+ default:
+ ferrd(1, "class2str: illegal class found %d\n", (int)cl);
+
+ }
+ return (p1);
+}
+
+/*
+ * calculate a string specifying the class for the given type and
+ * return it
+ */
+char *
+c_class(yp)
+YP yp;
+{
+ int i;
+
+ if (yp->yp_flags & YP_TAG && yp->yp_flags & YP_IMPLICIT) {
+ i = yp->yp_tag->yt_class;
+ } else {
+ i = PE_CLASS_UNIV;
+ }
+ return (c_flags(yp, (PElementClass)i));
+
+}
+/*
+ * calculate a string specifying the class for the explicit tag and
+ * return it
+ */
+char *
+ec_class(yp)
+YP yp;
+{
+ int i;
+ char *p1;
+ static char buf[STRSIZE];
+
+ if (!(yp->yp_flags & YP_TAG) || yp->yp_flags & YP_IMPLICIT)
+ ferr(1, "ec_class:internal error:called with out explicit tag\n");
+ switch (yp->yp_code) {
+ case YP_IDEFINED:
+ case YP_CHOICE:
+ if (yp->yp_flags & YP_TAG)
+ break;
+ if (yp->yp_flags & YP_OPTIONAL
+ && ((yp->yp_flags & (YP_OPTIONAL|YP_OPTCONTROL|YP_DEFAULT))
+ != (YP_OPTIONAL|YP_OPTCONTROL))) {
+ p1 = "FL_OPTIONAL";
+ } else if (yp->yp_flags & YP_DEFAULT) {
+ p1 = "FL_DEFAULT";
+ } else
+ p1 = "0";
+ return (p1);
+
+ default:
+ break;
+ }
+
+ i = yp->yp_tag->yt_class;
+
+ switch (i) {
+ case PE_CLASS_UNIV:
+ p1 = "FL_UNIVERSAL";
+ break;
+
+ case PE_CLASS_APPL:
+ p1 = "FL_APPLICATION";
+ break;
+
+ case PE_CLASS_PRIV:
+ p1 = "FL_PRIVATE";
+ break;
+
+ case PE_CLASS_CONT:
+ p1 = "FL_CONTEXT";
+ break;
+
+ default:
+ ferrd(1, "c_class: illegal class found %d\n", i);
+
+ }
+ if ((yp->yp_flags & YP_OPTIONAL)
+ && ((yp->yp_flags & (YP_OPTIONAL|YP_OPTCONTROL|YP_DEFAULT))
+ != (YP_OPTIONAL|YP_OPTCONTROL))) {
+ (void) strncpy(buf, p1, STRSIZE);
+ p1 = strncat(buf, "|FL_OPTIONAL", STRSIZE);
+ } else if (yp->yp_flags & YP_DEFAULT) {
+ (void) strncpy(buf, p1, STRSIZE);
+ p1 = strncat(buf, "|FL_DEFAULT", STRSIZE);
+ }
+ return (p1);
+}
+
+/*
+ * generate tables for encoding a contructed type
+ */
+tenc_loop(fp, yp, id, type)
+FILE *fp;
+YP yp;
+char *id;
+char *type;
+{
+ for (; yp != NULL; yp = yp->yp_next) {
+ tenc_typ(fp, yp, id, type);
+ }
+}
+
+/*
+ * Print the string and exit if argument greater than zero
+ */
+ferr(i, s)
+int i;
+char *s;
+{
+ (void) fprintf(stderr, "%s", s);
+ if (i > 0)
+ exit(i);
+}
+
+/*
+ * Print the integer and exit if argument greater than zero
+ */
+ferrd(i, s, d)
+int i;
+char *s;
+int d;
+{
+ (void) fprintf(stderr, s, d);
+ if (i > 0)
+ exit(i);
+}
+
+/*
+ * Print the string and exit if argument greater than zero
+ */
+ferrs(i, s, d)
+int i;
+char *s;
+char *d;
+{
+ (void) fprintf(stderr, s, d);
+ if (i > 0)
+ exit(i);
+}
+
+/*
+ * return a copy of the string s minus its last character
+ */
+char *
+strip_last(s)
+char *s;
+{
+ char *t, *r;
+
+ if (s) {
+ t = new_string(s);
+ for (r = t; *r != '\0'; r++);
+ ;
+ *--r = '\0';
+ return t;
+ } else
+ return NULL;
+}
+
+/*
+ * add the declaration specified by the strings type and id to the
+ * start of the declaration list
+ */
+add_list(type, id)
+char *type, *id;
+{
+
+ s_table *prev;
+
+ if ((prev = (s_table *) malloc(sizeof(s_table))) == NULL)
+ ferr(1, "add_list: Out of memory\n");
+ prev->type = type;
+ prev->name = id;
+ prev->parent = NULL;
+ prev->defined = 0;
+ prev->next = head;
+ head = prev;
+}
+
+/*
+ * print the declaration list
+ */
+print_list()
+{
+ s_table *prev;
+
+ for (prev = head; prev != NULL; prev = prev->next) {
+ (void) printf("type is %s\n", prev->type);
+ (void) printf("name is %s\n", prev->name);
+ (void) printf("\n");
+ }
+}
+
+/*
+ * parse the declaration in the string s returning the type in v1 and
+ * the name in v2
+ */
+parse_decl(s, v1, v2)
+char **s, **v1, **v2;
+{
+ char *t;
+
+ for (t = *s; *t != '\0' && !(isalnum(*t) || *t == '_'); t++);
+
+ *s = t;
+ if (*t != '\0') {
+ for (; *t != '*'; t++);
+ *t = '\0';
+ *v1 = my_strcat(*s, "*");
+ Printf(3, ("the type is %s\n", *v1));
+ if (*++t == '*')
+ t++;
+ for (*s = t; isalnum(*t) || *t == '_'; t++);
+ if (*t != '\0') {
+ *t = '\0';
+ t++;
+ }
+ *v2 = new_string(*s); /* don't really need new_string */
+ Printf(2, ("the name is %s\n", *v2));
+ *s = t;
+ }
+}
+
+/*
+ * return the next identifier in the string s
+ */
+char *
+get_val(s)
+char **s;
+{
+ char *t, *r;
+
+ for (t = *s; *t != '\0' && !(isalnum(*t) || *t == '_' || *t == '.'); t++);
+
+ if (*t != '\0') {
+ for (*s = t; isalnum(*t) || *t == '_' || *t == '.'; t++);
+ *t = '\0';
+ r = *s;
+ Printf(3, ("arg is |%s|\n", r));
+ *s = ++t;
+ return r;
+ } else
+ return NULL;
+}
+
+/*
+ * return the next component (sequence of characters up to the next
+ * ';' or '\0') of the string s
+ */
+char *
+get_comp(s)
+char **s;
+{
+ char *t, *r;
+
+ for (t = *s; *t != '\0' && !(isalnum(*t) || *t == '_' || *t == ';'); t++);
+
+ if (*t != '\0') {
+ for (*s = t; *t != '\0' && *t != ';'; t++);
+ *t = '\0';
+ r = *s;
+ Printf(3, ("component is |%s|\n", r));
+ *s = ++t;
+ return r;
+ } else
+ return NULL;
+}
+
+/*
+ * return a copy of that part of the string s which may contain
+ * definitions for the variables generated by posy
+ */
+char *
+get_string(s, direction)
+char *s;
+int direction;
+{
+ char *t, *t1;
+
+ if (direction & YP_ENCODER)
+ return new_string(s);
+ if (direction & YP_DECODER) {
+ t = new_string(s);
+ for (t1 = t; !(isalnum(*t1) || *t1 == '_'); t1++);
+ if (*t1 == 'i' && *++t1 == 'f' && *++t1 == ' ') { /* MEMALLOC code */
+ for (; *t1 != '}'; t1++) /* skip MEMALLOC code */
+ ;
+ t1++;
+ Printf(4, ("returning the string %s\n", t1));
+ return t1;
+ } else
+ return t;
+ }
+ return NULL;
+}
+
+/*
+ * Determine wether this list contains any items that will generate
+ * an optional field. If so return non zero
+ */
+optfield(yp)
+YP yp;
+{
+ for (; yp; yp = yp->yp_next) {
+ if (yp->yp_flags & YP_OPTIONAL) {
+
+ if ((yp->yp_flags & (YP_OPTIONAL|YP_OPTCONTROL|YP_DEFAULT))
+ == (YP_OPTIONAL|YP_OPTCONTROL))
+ return (0);
+
+ switch (yp->yp_code) {
+ case YP_BOOL:
+ case YP_INT:
+ case YP_INTLIST:
+ case YP_ENUMLIST:
+ case YP_NULL:
+ return (1);
+ }
+ }
+ }
+ return (0);
+}
+
+gen_dflts(fp, yp, type)
+FILE *fp;
+YP yp;
+char *type;
+{
+ YP y;
+
+ if (yp == NULL)
+ return;
+ switch (yp->yp_code) {
+ case YP_IDEFINED:
+ break;
+
+ case YP_CHOICE:
+ case YP_SEQTYPE:
+ case YP_SETTYPE:
+ case YP_SEQLIST:
+ case YP_SETLIST:
+ for (y = yp->yp_type; y != NULL; y = y->yp_next) {
+ gen_dflts(fp, y, type);
+ }
+ break;
+
+ default:
+ break;
+ }
+ /* Output definitions for default entries */
+ if (yp->yp_flags & YP_DEFAULT)
+ defdflt(fp, yp, type);
+
+ if (yp->yp_yfn)
+ declfns(fp, yp->yp_yfn);
+}
+/*
+ * Compute the concatenation into a temporary buffer of two strings
+ * after having run notid on them first
+ */
+char *
+strp2name(s1, s2)
+char *s1, *s2;
+{
+ char *p;
+ static char buf[STRSIZE * 2 + 5];
+
+ if ((int)strlen(s1) > STRSIZE || (int)strlen(s2) > STRSIZE)
+ ferr(1, "strp2name:string to big\n");
+ (void) strcpy(buf, p = notidtoid(s1));
+ free(p);
+ (void) strcat(buf, p = notidtoid(s2));
+ free(p);
+
+ return (buf);
+}
+
+/*
+ * Output the definitions for default entries and initialise the yp's
+ * to have pointers which reference these definitions for use by
+ * gdflt routine.
+ */
+defdflt(fp, yp, name)
+FILE *fp;
+YP yp;
+char *name;
+{
+ YV yv;
+ YV yv1;
+ SY sy;
+ YP yp1;
+ int size, i;
+ char *str;
+ char *label;
+ struct univ_typ *p;
+ int code;
+
+ if ((yp->yp_flags & YP_DEFAULT) == 0)
+ ferrd(1, "defdflt:called with out a default code = %d\n", yp->yp_code);
+ yv = yp->yp_default;
+
+ yp1 = yp;
+
+ /* Find the bottom definition */
+ code = yp1->yp_code;
+ while (code == YP_IDEFINED) {
+ if ((sy = syfind(yp1->yp_identifier)) == NULL) {
+ if ((p = univtyp(yp1->yp_identifier)) == NULL
+ || p->univ_type <= YP_UNDF)
+ ferrs(1,
+ "defdflt:IDEFINED:cannot find definition of symbol %s\n",
+ yp1->yp_identifier);
+ code = p->univ_type;
+ break;
+
+ }
+ yp1 = sy->sy_type;
+ code = yp1->yp_code;
+ }
+
+ switch (code) {
+ case YP_BOOL:
+ case YP_INT:
+ case YP_INTLIST:
+ case YP_ENUMLIST:
+ switch (yv->yv_code) {
+ case YV_NUMBER:
+ case YV_BOOL:
+ /* None needed */
+ break;
+
+ case YV_IDEFINED:
+ if ((yv1 = calc_yv(yp1, yv->yv_identifier)) == NULL) {
+ ferrs(1, "defdflt:BOOL/INT:cannot find definition of %s\n",
+ yv->yv_identifier);
+ }
+ /* None Needed */
+ break;
+
+ default:
+ ferrd(1, "defdflt:INT/BOOL:unimplemented value code = %d\n",
+ yv->yv_code);
+ }
+ break;
+
+ case YP_REAL:
+ switch (yv->yv_code) {
+ case YV_REAL:
+ yv1 = yv;
+ goto dumpdef3;
+
+ case YV_IDEFINED:
+ if ((yv1 = calc_yv(yp1, yv->yv_identifier)) == NULL) {
+ ferrs(1, "defdflt:REAL:cannot find definition of %s\n",
+ yv->yv_identifier);
+ }
+ goto dumpdef3;
+
+ default:
+ ferrd(1, "defdflt:REAL:unimplemented value code = %d\n",
+ yv->yv_code);
+ }
+ break;
+
+ case YP_BIT:
+ case YP_BITLIST:
+ switch (yv->yv_code) {
+ /*
+ * This is an illegal value for a bit string ! - BUT ACSE
+ * uses it !
+ */
+ /* gdflt also patched to support it */
+ case YV_IDEFINED:
+ ferrs(0,
+ "warning:bitstring default specified illegally with identifier %s\n",
+ yv->yv_identifier);
+ if ((yv1 = calc_yv(yp1, yv->yv_identifier)) == NULL) {
+ ferrs(1, "defdflt:BIT:cannot find definition of %s\n",
+ yv->yv_identifier);
+ }
+ /* doesn't work fix posy-yacc.y */
+ size = numtobstr(yv1, &str);
+ goto dumpdef1;
+
+ case YV_NUMBER:
+ size = numtobstr(yv, &str);
+ goto dumpdef1;
+
+ case YV_VALIST:
+ if ((size = valisttobs(yp1, yv, &str)) < 0) {
+ ferrs(1, "defdflt:bad default value for bit string %s\n",
+ yp->yp_flags & YP_ID ? yp->yp_identifier : "");
+ }
+ goto dumpdef1;
+
+ case YV_HSTRING:
+ str = yv->yv_xstring;
+ size = yv->yv_xlength*4;
+ goto dumpdef1;
+
+ case YV_BSTRING:
+ str = yv->yv_xstring;
+ size = yv->yv_xlength;
+ goto dumpdef1;
+
+ default:
+ /* Could be a syntax error */
+ ferrd(1, "defdflt:BIT:illegal value code = %d\n", yv->yv_code);
+ }
+ break;
+
+ case YP_IDEFINED:
+ ferrs(1, "defdflt:IDEFINED:internal error on symbol %s\n",
+ yp1->yp_identifier);
+ break;
+
+ case YP_OCT:
+ switch (yv->yv_code) {
+ case YV_NUMBER:
+ size = numtobstr(yv, &str);
+ goto dumpdef2;
+
+ case YV_STRING:
+ str = yv->yv_string;
+ size = strlen(str);
+ goto dumpdef2;
+
+ case YV_HSTRING:
+ str = yv->yv_xstring;
+ size = (yv->yv_xlength + 1)/2;
+ goto dumpdef2;
+
+ case YV_BSTRING:
+ str = yv->yv_xstring;
+ size = (yv->yv_xlength + 7)/8; /* round up */
+ goto dumpdef2;
+
+ default:
+ /* Could be a syntax error */
+ ferrd(1, "defdflt:OCT:illegal value code = %d\n", yv->yv_code);
+ }
+ break;
+
+ case YP_NULL:
+ case YP_SEQ:
+ case YP_SEQTYPE:
+ case YP_SEQLIST:
+ case YP_SET:
+ case YP_SETTYPE:
+ case YP_SETLIST:
+ case YP_CHOICE:
+ case YP_ANY:
+ case YP_OID:
+ /* None yet */
+ break;
+
+ default:
+ ferrd(1, "defdflt:unknown type %d\n", code);
+ }
+
+ return;
+
+dumpdef1: /* Bitstrings */
+ label = genlabel(name, yp);
+ yp->yp_action0 = label;
+ yp->yp_act0_lineno = size;
+ i = (size + NBPC - 1) / NBPC;
+ (void) fprintf(fp, "\nstatic unsigned char %s[] = ", label);
+ if (printable(str, i))
+ prstr(fp, str, i);
+ else
+ prhstr(fp, str, i);
+ (void) fprintf(fp, ";\n");
+ return;
+
+dumpdef2: /* Octet strings (and aliases) */
+ label = genlabel(name, yp);
+ yp->yp_action0 = label;
+ yp->yp_act0_lineno = size;
+ (void) fprintf(fp, "\nstatic unsigned char %s[] = ", label);
+ if (printable(str, size))
+ prstr(fp, str, size);
+ else
+ prhstr(fp, str, size);
+ (void) fprintf(fp, ";\n");
+ return;
+
+dumpdef3: /* Reals */
+ label = genlabel(name, yp);
+ yp->yp_action0 = label;
+ (void) fprintf(fp, "\nstatic double %s = %f;\n", label, yv1->yv_real);
+ return;
+
+}
+/*
+ * generate the default entry for encoding/decoding fields. This
+ * should contain the default value which the encoder will know means
+ * default encoding
+ */
+gdflt(fp, yp, which)
+FILE *fp;
+YP yp;
+int which; /* Which type of entries to generate
+ * G_ENC encode G_DEC decode */
+{
+ YV yv;
+ YV yv1;
+ SY sy;
+ YP yp1;
+ char *ndflt;
+ struct univ_typ *p;
+ int code;
+
+
+ if (which == G_ENC)
+ ndflt = "DFLT_F";
+ else
+ ndflt = "DFLT_B";
+
+ if ((yp->yp_flags & YP_DEFAULT) == 0)
+ ferrd(1, "gdflt:called with out a default code = %d\n", yp->yp_code);
+ yv = yp->yp_default;
+
+ yp1 = yp;
+
+ /* Find the bottom definition */
+ code = yp1->yp_code;
+ while (code == YP_IDEFINED) {
+ if ((sy = syfind(yp1->yp_identifier)) == NULL) {
+ if ((p = univtyp(yp1->yp_identifier)) == NULL
+ || p->univ_type <= YP_UNDF)
+ ferrs(1,
+ "gdflt:IDEFINED:cannot find definition of symbol %s\n",
+ yp1->yp_identifier);
+ code = p->univ_type;
+ break;
+
+ }
+ yp1 = sy->sy_type;
+ code = yp1->yp_code;
+ }
+
+ switch (code) {
+ case YP_BOOL:
+ case YP_INT:
+ case YP_INTLIST:
+ case YP_ENUMLIST:
+ switch (yv->yv_code) {
+ case YV_NUMBER:
+ case YV_BOOL:
+ (void) fprintf(fp, "\t{ %s, %d, 0, 0 },\n", ndflt,
+ yp->yp_default->yv_number);
+ break;
+
+ case YV_IDEFINED:
+ if ((yv1 = calc_yv(yp1, yv->yv_identifier)) == NULL) {
+ ferrs(1, "gdflt:BOOL/INT:cannot find definition of %s\n",
+ yv->yv_identifier);
+ }
+ (void) fprintf(fp, "\t{ %s, %d, 0, 0 },\n", ndflt,
+ yv1->yv_number);
+ break;
+
+ default:
+ ferrd(1, "gdflt:INT/BOOL:unimplemented value code = %d\n",
+ yv->yv_code);
+ }
+ break;
+
+ case YP_BIT:
+ case YP_BITLIST:
+ switch (yv->yv_code) {
+#ifdef ILLEGAL_DEFAULTS
+ case YV_IDEFINED: /* supporting illegal default
+ * specification */
+#endif
+ case YV_NUMBER:
+ case YV_HSTRING:
+ case YV_BSTRING:
+ case YV_VALIST:
+ (void) fprintf(fp, "\t{ %s, %d, %d, 0 },\n", ndflt,
+ yp->yp_act0_lineno, addptr(yp->yp_action0));
+ break;
+
+ default:
+ /* Could be a syntax error */
+ ferrd(1, "gdflt:BIT:illegal value code = %d\n", yv->yv_code);
+ }
+ break;
+
+ case YP_IDEFINED:
+ ferrs(1, "gdflt:IDEFINED:internal error on symbol %s\n",
+ yp1->yp_identifier);
+ break;
+
+ case YP_REAL:
+ switch (yv->yv_code) {
+#ifdef ILLEGAL_DEFAULTS
+ case YV_IDEFINED: /* Illegal according to ASN.1 but we can do it
+ * so why not support it
+ */
+#endif
+ case YV_REAL:
+ (void) fprintf(fp, "\t{ %s, 0, %d, 0 },\n", ndflt,
+ addptr(concat("&", yp->yp_action0)));
+ break;
+
+ default:
+ /* Could be a syntax error */
+ ferrd(1, "gdflt:REAL:illegal value code = %d\n", yv->yv_code);
+ }
+ break;
+
+ case YP_OCT:
+ switch (yv->yv_code) {
+ case YV_NUMBER:
+ case YV_STRING:
+ case YV_HSTRING:
+ case YV_BSTRING:
+ (void) fprintf(fp, "\t{ %s, %d, %d, 0 },\n", ndflt,
+ yp->yp_act0_lineno, addptr(yp->yp_action0));
+ break;
+
+ default:
+ /* Could be a syntax error */
+ ferrd(1, "gdflt:OCT:illegal value code = %d\n", yv->yv_code);
+ }
+ break;
+
+ case YP_NULL:
+ case YP_SEQ:
+ case YP_SEQTYPE:
+ case YP_SEQLIST:
+ case YP_SET:
+ case YP_SETTYPE:
+ case YP_SETLIST:
+ case YP_CHOICE:
+ case YP_ANY:
+ case YP_OID:
+ (void) fprintf(fp, "\t{ %s, 0, 0, 0 },\n", ndflt);
+ break;
+
+ default:
+ ferrd(1, "gdflt:unknown type %d\n", yp->yp_code);
+ }
+
+}
+/*
+ * Calculate the value associated with the given identifier id by
+ * looking at the value definitions associated with type definition
+ * yp. Returns the value definition if found or NULL if not.
+ */
+YV
+calc_yv(yp, id)
+YP yp;
+char *id;
+{
+ YV yv;
+
+ for (yv = yp->yp_value; yv != NULL; yv = yv->yv_next) {
+ if (yv->yv_flags & YV_NAMED && strcmp(yv->yv_named, id) == 0)
+ return (yv);
+ }
+
+ return (NULL);
+}
+
+/*
+ * ******* This does not work. posy needs to be fixed for case of
+ * '01'b ***** Turn a Literal number value in yv into a bistring
+ * initialisation. Return the length of the bit string or less than
+ * zero on error. Set the (char *) pointer, whose address is in
+ * ppstr, to point to a string containing the a reference to a
+ * character array which contains the bits.
+ */
+
+numtobstr(yv, ppstr)
+YV yv;
+char **ppstr;
+{
+
+ int ibits, lastb, i;
+ char *buf;
+
+ buf = malloc(NBPI / NBPC + 1);
+ bzero(buf, NBPI / NBPC + 1);
+ lastb = -1;
+ ibits = yv->yv_number;
+ for (i = 0; i < NBPI; i++) {
+ if ((1 << i) & ibits) {
+ buf[i / NBPC] |= 1 << (NBPC - 1 - (i % NBPC));
+ lastb = i;
+ }
+ }
+
+ *ppstr = buf;
+ return (lastb + 1);
+}
+#define ROUNDUP 10
+/*
+ * Take a list of Values (YV_VALIST) which should contain a list of
+ * bits and convert them into a bitstring initialisation. As in
+ * numtobstr return the size of the bit string or a negative number
+ * if there is an error. Put a reference to a character array which
+ * contains the definition of the bits in the character pointer whose
+ * address is in ppstr. yp is the definition of the type which
+ * contains the names of all the defined bits.
+ */
+valisttobs(yp, yv, ppstr)
+YP yp;
+YV yv;
+char **ppstr;
+{
+
+ YV yv1, yv2;
+ int lastb, val, nsize, size;
+ char *buf;
+
+ lastb = -1;
+ size = ROUNDUP;
+ if ((buf = malloc((unsigned)size)) == NULL) {
+ ferrd(1, "valisttobs:malloc:failed on %d\n", size);
+ }
+ bzero(buf, size);
+ for (yv1 = yv->yv_idlist; yv1 != NULL; yv1 = yv1->yv_next) {
+ if ((yv2 = calc_yv(yp, yv1->yv_identifier)) == NULL) {
+ return (-1);
+ }
+ val = yv2->yv_number;
+ /* Bug here probably */
+ if (size < val / NBPC) {
+ nsize = val / NBPC + ROUNDUP;
+ if ((buf = realloc(buf, (unsigned)nsize)) == NULL) {
+ ferrd(1, "valisttobs:realloc:failed on %d\n", nsize);
+ }
+ bzero(buf + size, nsize - size);
+ size = nsize;
+ }
+ buf[val / NBPC] |= 1 << (NBPC - 1 - (val % NBPC));
+ if (val > lastb)
+ lastb = val;
+ }
+ *ppstr = buf;
+ return (lastb + 1);
+}
+/*
+ * Print the string out in a format acceptable as a quoted string in
+ * a C program including the quotes. Using \ escapes for unprintable
+ * characters
+ */
+prstr(fp, str, len)
+FILE *fp;
+char *str;
+int len;
+{
+ (void) fputc('"', fp);
+ while (len-- > 0) {
+ if (isprint(*str & 0xff)) {
+ (void) fputc(*str & 0xff, fp);
+ str++;
+ continue;
+ }
+ (void) fprintf(fp, "\\%0o", *str & 0xff);
+ }
+ (void) fputc('"', fp);
+#define MAXPLINE 16
+}
+/*
+ * output a initialisation for a character array as unsigned hex
+ * numbers
+ */
+prhstr(fp, str, len)
+FILE *fp;
+char *str;
+int len;
+{
+ int npline; /* number on this line */
+
+ (void) fprintf(fp, "{\n");
+ npline = 0;
+ while (len > 0) {
+ if (npline >= MAXPLINE) {
+ (void) fputc('\n', fp);
+ npline = 0;
+ }
+ npline++;
+ (void) fprintf(fp, " 0x%02x,", *str++ & 0xff);
+ len--;
+ }
+ (void) fprintf(fp, "}");
+}
+/*
+ * determine if the string is printable i.e. only sensible to be read
+ * as a character string. 1 (true) if it is 0, if it isn't
+ */
+printable(str, i)
+char *str;
+int i;
+{
+ while (i-- > 0) {
+ if (!isprint(*str & 0xff))
+ return (0); /* look for the first non printable
+ * character */
+ str++;
+ }
+ return (1);
+}
+/*
+ * generate a unique identifier using the name given and the name if
+ * present in yp. Return a pointer to it in a space malloc'ed out
+ */
+char *
+genlabel(name, yp)
+char *name;
+YP yp;
+{
+ char buf[MAXNAME];
+ static int cnt;
+ char *p1, *p2;
+
+ p1 = notidtoid(name);
+ if (yp->yp_flags & YP_ID) {
+ p2 = notidtoid(yp->yp_id);
+ (void) sprintf(buf, "L%s_%s_%d", p1, p2, cnt++);
+ free(p2);
+ } else
+ (void) sprintf(buf, "L%s_X_%d", p1, cnt++);
+ free(p1);
+
+ return (my_new_str(buf));
+}
+/*
+ * generate a ptr table reference for the given module table entry
+ */
+gen_modref(mod)
+char *mod;
+{
+ char buf[BUFSIZ];
+ char *p1;
+ int ind;
+
+ p1 = notidtoid(mod);
+ (void) sprintf(buf, "&%s%s%s", PREFIX, p1, MODTYP_SUFFIX);
+ ind = addptr(buf);
+ free(p1);
+
+ return (ind);
+}
+
+char *
+setfield(p)
+char *p;
+{
+ char *f;
+
+ if ((f = getfield(p)) == NULLCP) {
+ fprintf(stderr, "\nsetfield: can't extract field from %s\n", p);
+ exit(1);
+ }
+ return (strdup(f));
+}
+
+/*
+ * print a normal table entry
+ */
+prnte(fp, t, f, yp, p1)
+FILE *fp;
+char *t; /* parent type */
+char *f; /* field name */
+YP yp; /* object */
+char *p1; /* table entry name */
+{
+ if (p1 == NULL)
+ ferr(1, "prnte: called with a NULL p1\n");
+
+ if (t && noindirect(f))
+ prstfield(fp, p1, t, f, c_tag(yp), c_class(yp));
+ else
+ prtfield(fp, p1, t, f, c_tag(yp), c_class(yp));
+}
+
+/*
+ * generate the entry allowing for defined types and then call the given
+ * function to generate the base entry
+ * Algorithm:
+ * If we can find the base type
+ * i) generate any ETAG that subsequent definitions might have
+ * ii) call the function to generate the base entry
+ * iii) and the function checks that it matches the type of the value pass
+ * else - can't find the base type - probably because it is external
+ * i) generate a warning and exit
+ */
+gen_identry(fp, t, f, yp, fn)
+FILE *fp;
+char *t, *f;
+YP yp;
+int (*fn)();
+{
+ YP yp1;
+ int code;
+ SY sy;
+ YT pd_yt = NULLYT; /* Passed down tag if any */
+ YT yt;
+ struct univ_typ *p = NULL;
+ char *flags; /* the flags if any which each subtype must have */
+ int save_flags;
+
+ yp1 = yp;
+ code = yp1->yp_code;
+
+ if (yp->yp_flags & YP_OPTIONAL)
+ flags = "|FL_OPTIONAL";
+ else if (yp->yp_flags & YP_DEFAULT)
+ flags = "|FL_DEFAULT";
+ else
+ flags = "";
+
+ /* any explicit tag for original yp type is handled before this
+ * routine is called so don't call gen_etag for it here
+ * but we do need to initialise pd_yt for the case of an IMPLICIT TAG.
+ */
+ if ((yp->yp_flags & (YP_TAG|YP_IMPLICIT))== (YP_TAG|YP_IMPLICIT))
+ pd_yt = yp->yp_tag;
+
+ while (code == YP_IDEFINED) {
+ if ((sy = syfind(yp1->yp_identifier)) == NULL) {
+ if ((p = univtyp(yp1->yp_identifier)) == NULL
+ || p->univ_type <= YP_UNDF)
+ ferrs(1,
+ "\ngen_identry:symbol %s is not defined in this file:\npepsy cannot support value passing for this type, sorry\n",
+ yp1->yp_identifier);
+ code = p->univ_type;
+ break;
+
+ }
+ yp1 = sy->sy_type;
+ /* check for Explicit tags & generate ETAG entries */
+ pd_yt = gen_etag(fp, pd_yt, yp1, flags);
+ code = yp1->yp_code;
+ }
+
+ if (p) {
+ /* how do we check type is consistent with value passed ? */
+ yp1 = new_type(code, -1);
+
+ yp1->yp_flags |= yp->yp_flags & (YP_OPTIONAL|YP_DEFAULT);
+
+ if (pd_yt == NULLYT) {
+ yp1->yp_tag = new_tag(p->univ_class);
+ yp1->yp_tag->yt_value = new_value(YV_NUMBER);
+ yp1->yp_tag->yt_value->yv_number = p->univ_id;
+ } else
+ yp1->yp_tag = pd_yt;
+ yp1->yp_flags |= YP_TAG|YP_IMPLICIT;
+
+ (*fn)(fp, yp, yp1, t, f);
+
+ /* lets free the yp1 allocated above */
+ if (pd_yt == NULLYT) {
+ free((char *)yp1->yp_tag->yt_value);
+ free((char *)yp1->yp_tag);
+ }
+ free((char *)yp1);
+
+ return;
+ }
+ /* check type is consistent with value passed some where??*/
+
+ save_flags = yp1->yp_flags;
+ yp1->yp_flags |= yp->yp_flags & (YP_OPTIONAL|YP_DEFAULT);
+
+ if (pd_yt) {
+ yt = yp1->yp_tag;
+ yp1->yp_tag = pd_yt;
+ yp1->yp_flags |= YP_TAG|YP_IMPLICIT;
+ }
+
+ (*fn)(fp, yp, yp1, t, f);
+
+ if (pd_yt) { /* restore the tag for later */
+ yp1->yp_tag = yt;
+ }
+ yp1->yp_flags = save_flags;
+
+}
+
+/*
+ * generate the ETAG entry if needed for following the given defined type
+ * down to what it is. Given that its use above has an IMPLICIT tag pd_yt
+ * if it is non Null
+ */
+YT
+gen_etag(fp, pd_yt, yp, flags)
+FILE *fp;
+YT pd_yt;
+YP yp;
+char *flags;
+{
+ YT yt;
+
+ yt = yp->yp_tag;
+ if (yt && yt->yt_value) {
+ if ((yp->yp_flags & (YP_TAG|YP_IMPLICIT)) == YP_TAG) {
+ /* EXPLICIT TAG so generate an ETAG */
+ if (pd_yt)
+ yt = pd_yt; /* if we have a value passed down use that */
+ (void) fprintf(fp, "\t{ ETAG, 0, %d, %s%s },\n",
+ yt->yt_value->yv_number,
+ class2str(yt->yt_class), flags);
+ pd_yt = NULLYT; /* non't pass on any value */
+
+ } else if ((yp->yp_flags & (YP_TAG|YP_IMPLICIT))== (YP_TAG|YP_IMPLICIT)) {
+ /* otherwise it is implicit and so pass its tag down
+ * unless we already have a tag being passed in which case
+ * the passed down tag overrides this current tag
+ */
+ if (pd_yt == NULLYT)
+ pd_yt = yt;
+ }
+ }
+
+ return (pd_yt);
+}
+
+/*
+ * generate the table entry for a value passing defined type which
+ * is equivalent to the given primative type
+ */
+gen_ventry(fp, oyp, yp, t, f)
+FILE *fp;
+YP oyp, yp;
+char *t, *f;
+{
+ char *p1;
+ register char s = oyp->yp_prfexp; /* type of value passing */
+
+
+ if (noindirect(f) && s != 'q' && s != 'a')
+ ferrs(1,
+ "gen_ventry: must specify a field for primative value- not %s\n", f);
+
+ switch (s) {
+ case 'q': /* [[ q parm->qbufptr ]] */
+ if (yp->yp_code != YP_OCT)
+ warning("qbuf pointer passed for a %s by type %s",
+ code2name(yp->yp_code), yp2name(oyp));
+
+ f = setfield(oyp->yp_strexp);
+ if (noindirect(f))
+ p1 = "SOCTETSTRING";
+ else
+ p1 = "OCTETSTRING";
+ break;
+
+ case 's': /* [[ s ptr ]] */
+ if (yp->yp_code != YP_OCT)
+ warning("string pointer passed for a %s by type %s",
+ code2name(yp->yp_code), yp2name(oyp));
+
+ f = setfield(oyp->yp_strexp);
+ p1 = "T_STRING";
+ break;
+
+ case 'o': /* [[ o ptr $ length ]] */
+ if (yp->yp_code != YP_OCT)
+ warning("octet/length pair passed for a %s by type %s",
+ code2name(yp->yp_code), yp2name(oyp));
+ f = setfield(oyp->yp_strexp);
+ p1 = "OCTET_PTR";
+ prnte(fp, t, f, yp, p1);
+ if (oyp->yp_intexp)
+ f = setfield(oyp->yp_intexp);
+ if (noindirect(f))
+ ferr(1, "gen_ventry:OCT: must specify a field [[ s .. ]]\n");
+ p1 = "OCTET_LEN";
+ break;
+
+ case 'x': /* [[ x ptr $ length ]] */
+ if (yp->yp_code != YP_BIT && yp->yp_code != YP_BITLIST)
+ warning("bit string/length pair passed for a %s by type %s",
+ code2name(yp->yp_code), yp2name(oyp));
+
+ f = setfield(oyp->yp_strexp);
+ p1 = "BITSTR_PTR";
+ prnte(fp, t, f, yp, p1);
+ f = setfield(oyp->yp_intexp);
+ if (noindirect(f))
+ ferr(1, "tenc_typ:BIT: must specify a field [[ x .. ]]\n");
+ p1 = "BITSTR_LEN";
+ break;
+
+ case 'r': /* [[ r REAL ]] */
+ if (yp->yp_code != YP_REAL)
+ warning("Real passed for a %s by type %s",
+ code2name(yp->yp_code), yp2name(oyp));
+
+ f = setfield(oyp->yp_strexp);
+ p1 = "REALTYPE";
+ break;
+
+ case 'i': /* [[ i INTEGER ]] */
+ if (yp->yp_code != YP_INT && yp->yp_code != YP_INTLIST
+ && yp->yp_code != YP_ENUMLIST)
+ warning("integer passed for a %s by type %s",
+ code2name(yp->yp_code), yp2name(oyp));
+
+ if (oyp->yp_intexp)
+ f = setfield(oyp->yp_intexp);
+ p1 = "INTEGER";
+ break;
+
+ case 't': /* [[ t Bitvector ]] */
+ if (yp->yp_code != YP_BIT && yp->yp_code != YP_BITLIST)
+ warning("Bitvector (PE) passed for a %s by type %s",
+ code2name(yp->yp_code), yp2name(oyp));
+
+ f = setfield(oyp->yp_intexp);
+ if (oyp->yp_varexp && !noindirect(f))
+ p1 = "BITSTRING";
+ else
+ p1 = "SBITSTRING";
+ break;
+
+ case 'b': /* [[ b BOOLEAN ]] */
+ if (yp->yp_code != YP_BOOL)
+ warning("Boolean passed for a %s by type %s",
+ code2name(yp->yp_code), yp2name(oyp));
+
+ if (oyp->yp_intexp)
+ f = setfield(oyp->yp_intexp);
+ p1 = "BOOLEAN";
+ break;
+
+ case 'O': /* [[ O Object Identifier ]] */
+ if (yp->yp_code != YP_OID)
+ warning("Object Identifier pointer passed for a %s by type %s",
+ code2name(yp->yp_code), yp2name(oyp));
+ f = setfield(oyp->yp_strexp);
+ p1 = "OBJID";
+ break;
+
+ case 'a': /* [[ a ANY ]] */
+ if (yp->yp_code != YP_ANY)
+ warning("PE pointer passed for a %s by type %s",
+ code2name(yp->yp_code), yp2name(oyp));
+ f = setfield(oyp->yp_strexp);
+ if (noindirect(f))
+ p1 = "SANY";
+ else
+ p1 = "ANY";
+ break;
+ default:
+ ferrd(1, "gen_vident:unknown Value passed %d\n", (int )s);
+ }
+
+ prnte(fp, t, f, yp, p1);
+}
+
+/*
+ * generate a table entry for a function call that handles this type
+ */
+gen_fn(fp, yp, fn)
+FILE *fp;
+YP yp;
+char *fn; /* name of routine to generate */
+{
+
+ gen_identry(fp, fn, NULLCP, yp, gen_fnentry);
+}
+
+/*
+ * generate a table entry for a function call that handles this type
+ */
+/* ARGSUSED */
+gen_fnentry(fp, oyp, yp, fn, dummy)
+FILE *fp;
+YP oyp;
+YP yp;
+char *fn; /* name of routine to generate */
+char *dummy;
+{
+
+ (void) fprintf(fp, "\t{ FN_CALL, %d, %s, %s },\n",
+ addptr(fn), c_tag(yp), c_class(yp));
+}
+/*
+ * declare the functions that are used
+ * One day generate ANSII C definitions as well
+ */
+declfns(fp, fn)
+FILE *fp;
+YFN fn;
+{
+ if (fn->yfn_enc) {
+ (void) fprintf(fp, "extern int %s();\n", fn->yfn_enc);
+ }
+ if (fn->yfn_dec) {
+ (void) fprintf(fp, "extern int %s();\n", fn->yfn_dec);
+ }
+ if (fn->yfn_prt) {
+ (void) fprintf(fp, "extern int %s();\n", fn->yfn_prt);
+ }
+ if (fn->yfn_fre) {
+ (void) fprintf(fp, "extern int %s();\n", fn->yfn_fre);
+ }
+}
+/*
+ * generate the table entry to handle an action - UCODE
+ */
+gen_act(fp, act)
+FILE *fp;
+Action act;
+{
+ (void) fprintf(fp, "\t{ UCODE, %d, 0, 0 }, /* line %d */\n", act->a_num,
+ act->a_line);
+}
+
+/*
+ * print out the field entry for a type where all the parameters are given
+ */
+prtfield(fp, typ, t, f, cl, fl)
+FILE *fp;
+char *typ, *t, *f, *cl, *fl;
+{
+ if (cl == NULLCP)
+ cl = "0";
+
+ if (f && t) {
+ if (*f == '&')
+ f++;
+ (void) fprintf(fp, "\t{ %s, OFFSET(%s, %s), %s, %s },\n", typ, t, f,
+ cl, fl);
+ } else
+ (void) fprintf(fp, "\t{ %s, 0, %s, %s },\n", typ, cl, fl);
+}
+
+/*
+ * print out the field entry for a Simple type where all the parameters
+ * are given
+ */
+prstfield(fp, typ, t, f, cl, fl)
+FILE *fp;
+char *typ, *t, *f, *cl, *fl;
+{
+ if (cl == NULLCP)
+ cl = "0";
+
+ if (f && t && *f == '&') {
+ f++;
+ (void) fprintf(fp, "\t{ S%s, OFFSET(%s, %s), %s, %s },\n", typ, t, f,
+ cl, fl);
+ } else
+ (void) fprintf(fp, "\t{ S%s, 0, %s, %s },\n", typ, cl, fl);
+}
+
+/*
+ * convert an integer into a temporary string. Useful for calling
+ * the printing routines with
+ */
+char *
+int2tstr(i)
+int i;
+{
+ static char buf[STRSIZE];
+
+ (void) sprintf(buf, "%d", i);
+
+ return (buf);
+}
+
+static char *codetab[] = {
+ "Undefined", "BOOLEAN", "INTEGER", "INTEGER (named numbers)", "BIT STRING",
+ "BIT STRING (named bits)", "OCTET STRING", "NULL", "SEQUENCE",
+ "SEQUENCE OF", "SEQUENCE", "SET", "SET OF", "SET", "CHOICE",
+ "ANY", "OBJECT IDENTIFIER", "Defined type", "ENUMERATED",
+ "REAL", "Imported type",
+
+ NULL
+};
+/*
+ * produce a user readable name for a yp_code value
+ */
+char *
+code2name(code)
+int code;
+{
+ static char buf[STRSIZE];
+
+ if (code < 0 || code > YP_IMPTYPE) {
+ (void) sprintf(buf, "Unknown code (%d)", code);
+ return (buf);
+ }
+
+ return (codetab[code]);
+}
+/*
+ * print out a description of the yp type for the user that is good enough
+ * for them to identifier the entry if possible
+ */
+char *
+yp2name(yp)
+YP yp;
+{
+ static char buf[STRSIZE*4];
+ char *p;
+
+ p = buf;
+ if (yp->yp_code == YP_IDEFINED) {
+ if (yp->yp_module) {
+ (void) sprintf(p, "%s.", yp->yp_module);
+ p += strlen(p);
+ }
+ if (yp->yp_identifier)
+ (void) sprintf(p, "%s", yp->yp_identifier);
+ else
+ (void) strcpy(p, "(no identifier)");
+ p += strlen(p);
+ if (yp->yp_modid) {
+ (void) sprintf(p, " (%s)", sprintoid(yp->yp_modid));
+ p += strlen(p);
+ }
+ } else {
+ (void) sprintf(p, "%s", code2name(yp->yp_code));
+ p += strlen(p);
+ }
+
+ if (yp->yp_flags & YP_ID) {
+ (void) sprintf(p, " %s", yp->yp_id);
+ p += strlen(p);
+ }
+
+ if (yp->yp_lineno > 0) {
+ (void) sprintf(p, " on line %d", yp->yp_lineno);
+ p += strlen(p);
+ }
+
+ return (buf);
+
+}
+/*
+ * generate a table entry for the given compound type. It determines wether to
+ * generate a simple type (prstfield) or not.
+ */
+prcte(fp, type, t, f, yp, p1)
+FILE *fp;
+char *type; /* zero if we are foundation type of the table */
+char *t; /* parent type */
+char *f; /* field name */
+YP yp; /* object */
+char *p1; /* table entry name */
+{
+ if (type == NULL || type && noindirect(f))
+ prstfield(fp, p1, t, f, c_tag(yp), c_class(yp));
+ else
+ prtfield(fp, p1, t, type ? f : NULLCP, c_tag(yp), c_class(yp));
+}
diff --git a/src/isode/pepsy/fre.c b/src/isode/pepsy/fre.c
new file mode 100644
index 000000000..5e71fd81e
--- /dev/null
+++ b/src/isode/pepsy/fre.c
@@ -0,0 +1,702 @@
+/* fre.c */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:30:36 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:19:03 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:39:16 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:42:57 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+/* LINTLIBRARY */
+
+
+/* LINTLIBRARY */
+
+/*
+ * These routines are the driving routines for freeing of the data
+ */
+#include <stdio.h>
+#include "pepsy-driver.h" /* for PEPSY_VERSION defn */
+#include "psap.h"
+#include "pepsy.h"
+
+
+extern tpe *next_tpe();
+extern int pepsylose ();
+#define NEXT_TPE(p) p = next_tpe(p)
+#define CHKTAG(mod, p, pe) ismatch(p, mod, pe->pe_class, pe->pe_id)
+
+static fre_seq();
+static fre_seqof();
+static fre_choice();
+
+/*
+ * free an objects data. Basic algorithm is to walk through it twice
+ * first time freeing all the "children" of the data structure - then
+ * the second time free the structure itself
+ */
+fre_obj(parm, p, mod, dofree)
+modtyp *mod;
+tpe *p;
+char *parm;
+int dofree;
+{
+ char *malptr = NULL; /* Have we seen a malloc */
+ int ndofree = dofree; /* Does the function below deallocate space */
+
+ if (parm == 0)
+ return (OK);
+
+ if (p->pe_type != PE_START) {
+ (void) pepsylose (mod, p, NULLPE, "fre_obj: missing PE_START\n");
+ return (NOTOK);
+ }
+
+ for (p++; p->pe_type != PE_END; NEXT_TPE(p)) {
+
+ /*
+ * we have to have all these cases here because it is different to the
+ * situation when the entry is not the main entry of the typereference.
+ */
+ switch (p->pe_type) {
+ case MEMALLOC:
+ if (dofree) {
+ malptr = parm;
+ ndofree = 0; /* we are deallocating space on this level */
+ }
+ break;
+
+ default:
+ if (fre_type(parm, p, mod, ndofree) != OK)
+ return (NOTOK);
+ break;
+ }
+ }
+
+ if (malptr && dofree) { /* If we saw a malloc free item */
+ free(malptr);
+ malptr = NULLCP;
+ }
+
+ return (OK);
+}
+
+/*
+ * Handle freeing of single type field. All the more general routines
+ * fall back to this so we can put the code to free something just
+ * here once and it will handle all the cases else where
+ */
+fre_type(parm, p, mod, dofree)
+char *parm;
+tpe *p;
+modtyp *mod; /* Module it is from */
+int dofree;
+{
+
+ if (parm == 0)
+ return OK;
+
+again:
+ switch (p->pe_type) {
+ case MEMALLOC:
+ break;
+
+ case PE_END:
+ case PE_START:
+ case UCODE:
+ break;
+
+ case BOPTIONAL:
+ case FREE_ONLY: /* this next entry is for us */
+ case DFLT_F:
+ p++;
+ goto again;
+
+ case ETAG:
+ switch (p->pe_ucode) {
+
+ default:
+ p++;
+ if (fre_type(parm, p, mod, dofree) != OK)
+ return (NOTOK);
+ }
+ break;
+
+ case SEQ_START:
+ case SET_START:
+ if (fre_seq(*(char **) (parm + p->pe_ucode), p, mod, 1) != OK)
+ return (NOTOK);
+ break;
+
+ case SEQOF_START:
+ case SETOF_START:
+ if (fre_seqof(*(char **) (parm + p->pe_ucode), p, mod, 1) != OK)
+ return (NOTOK);
+ break;
+
+ case SSEQ_START:
+ case SSET_START:
+ if (fre_seq((char *) parm + p->pe_ucode, p, mod, dofree) != OK)
+ return (NOTOK);
+ break;
+
+ case SSEQOF_START:
+ case SSETOF_START:
+ if (fre_seqof((char *) parm + p->pe_ucode, p, mod, dofree) != OK)
+ return (NOTOK);
+ break;
+
+ case IMP_OBJ:
+ p++;
+ if (p->pe_type == EXTOBJ) {
+ if (fre_obj(*(char **) (parm + p->pe_ucode),
+ (EXT2MOD(mod, (p + 1)))->md_dtab[p->pe_tag],
+ EXT2MOD(mod, (p + 1)), 1) != OK)
+ return (NOTOK);
+ } else if (p->pe_type == SEXTOBJ) {
+ if (fre_obj((parm + p->pe_ucode),
+ (EXT2MOD(mod, (p + 1)))->md_dtab[p->pe_tag],
+ EXT2MOD(mod, (p + 1)), dofree) != OK)
+ return (NOTOK);
+ } else if (p->pe_type == SOBJECT) {
+ if (fre_obj((char *) parm + p->pe_ucode, mod->md_dtab[p->pe_tag], mod, dofree) != OK)
+ return (NOTOK);
+ } else
+ if (fre_obj(*(char **) (parm + p->pe_ucode),
+ mod->md_dtab[p->pe_tag], mod, 1) != OK)
+ return (NOTOK);
+ break;
+
+ case SOBJECT:
+ if (fre_obj((char *) parm + p->pe_ucode, mod->md_dtab[p->pe_tag], mod, dofree) != OK)
+ return (NOTOK);
+ break;
+
+ case OBJECT:
+ if (fre_obj(*(char **) (parm + p->pe_ucode), mod->md_dtab[p->pe_tag],
+ mod, 1) != OK)
+ return (NOTOK);
+ break;
+
+ case SCHOICE_START:
+ if (fre_choice((char *) parm + p->pe_ucode, p, mod, dofree) != OK)
+ return (NOTOK);
+ break;
+
+ case CHOICE_START:
+ if (fre_choice(*(char **) (parm + p->pe_ucode), p, mod, 1) != OK)
+ return (NOTOK);
+ break;
+
+ case SEXTOBJ:
+ if (p[1].pe_type != EXTMOD) {
+ (void) pepsylose (mod, p, NULLPE, "fre_type:missing EXTMOD");
+ return (NOTOK);
+ }
+ if (fre_obj(parm + p->pe_ucode, (EXT2MOD(mod, (p + 1)))->md_dtab[p->pe_tag],
+ EXT2MOD(mod, (p + 1)), dofree) != OK)
+ return (NOTOK);
+ break;
+
+ case EXTOBJ:
+ if (p[1].pe_type != EXTMOD) {
+ (void) pepsylose (mod, p, NULLPE, "fre_type:missing EXTMOD");
+ return (NOTOK);
+ }
+ if (fre_obj(*(char **) (parm + p->pe_ucode),
+ (EXT2MOD(mod, (p + 1)))->md_dtab[p->pe_tag],
+ EXT2MOD(mod, (p + 1)), 1) != OK)
+ return (NOTOK);
+ break;
+
+ case INTEGER:
+ case BOOLEAN:
+ case T_NULL:
+ case REALTYPE:
+ break;
+
+ case SANY:
+ /*
+ * These tests of the pointer don't appear necessary from the
+ * definition of encoding and decoding but ISODE generates
+ * freeing code that does these checks and ISODE's ps layer
+ * definitely requires it
+ */
+ if (parm != NULL) {
+ pe_free((PE) parm);
+ parm = NULL;
+ }
+ break;
+
+ case ANY:
+ if (*(char **) (parm + p->pe_ucode) != NULL) {
+ pe_free(*(PE *) (parm + p->pe_ucode));
+ *((PE *) (parm + p->pe_ucode)) = NULLPE;
+ }
+ break;
+
+ case SOCTETSTRING:
+ if (parm != NULL) {
+ qb_free((struct qbuf *) parm);
+ parm = NULL;
+ }
+ break;
+
+ case T_STRING:
+ case OCTET_PTR:
+ case BITSTR_PTR:
+ if (*(char **) (parm + p->pe_ucode) != NULL) {
+ free(*(char **) (parm + p->pe_ucode));
+ *(char **) (parm + p->pe_ucode) = NULLCP;
+ }
+ break;
+
+ case OCTETSTRING:
+ if (*(char **) (parm + p->pe_ucode) != NULL) {
+ qb_free(*(struct qbuf **) (parm + p->pe_ucode));
+ *(struct qbuf **) (parm + p->pe_ucode) = (struct qbuf *)0;
+ }
+ break;
+
+ case SBITSTRING:
+ if (parm != NULL) {
+ pe_free((PE) parm);
+ parm = NULL;
+ }
+ break;
+
+ case BITSTRING:
+ if (*(char **) (parm + p->pe_ucode) != NULL) {
+ pe_free(*(PE *) (parm + p->pe_ucode));
+ *(PE *) (parm + p->pe_ucode) = NULLPE;
+ }
+ break;
+
+ case SOBJID:
+ if (parm != NULL) {
+ oid_free((OID) parm);
+ parm = NULL;
+ }
+ break;
+
+ case OBJID:
+ if (*(char **) (parm + p->pe_ucode) != NULL) {
+ oid_free(*(OID *) (parm + p->pe_ucode));
+ *(OID *) (parm + p->pe_ucode) = NULLOID;
+ }
+ break;
+
+ case FN_CALL:
+ break; /* can't do anything with this */
+
+ case FFN_CALL:
+ if ((FN_PTR(mod, p))(parm) == NOTOK)
+ return pepsylose (mod, p, NULLPE,
+ "fre_type:FN_CALL:call failed");
+ break;
+
+ default:
+ (void) pepsylose (mod, p, NULLPE, "fre_type: %d not implemented\n",
+ p->pe_type);
+ return (NOTOK);
+ }
+
+ return (OK);
+}
+
+/*
+ * free elements of a sequential type. e.g. sequence or set
+ */
+static fre_seq(parm, p, mod, dofree)
+char *parm;
+tpe *p;
+modtyp *mod; /* Module it is from */
+int dofree;
+{
+/* int *popt = NULL; Pointer to optional field */
+ char *malptr = NULL; /* Have we seen a malloc */
+ int ndofree = dofree; /* Does the function below deallocate space */
+
+
+ if (parm == 0)
+ return OK;
+
+ if (p->pe_type != SEQ_START && p->pe_type != SET_START
+ && p->pe_type != SSEQ_START && p->pe_type != SSET_START) {
+ (void) pepsylose (mod, p, NULLPE, "fre_seq: bad starting item %d\n",
+ p->pe_type);
+ return (NOTOK);
+ }
+ p++;
+
+ if (p->pe_type == DFLT_B)
+ p++;
+
+ while (p->pe_type != PE_END) {
+
+ switch (p->pe_type) {
+ case MEMALLOC:
+ if (dofree) {
+ malptr = parm;
+ ndofree = 0; /* we are deallocating space on this level */
+ }
+ break;
+
+ case OPTL:
+/* popt = (int *) (parm + p->pe_ucode); */
+ break;
+
+ case ETAG:
+ p++;
+ continue;
+
+ case UCODE:
+ break;
+
+ case SET_START:
+ case SEQ_START:
+ if (fre_seq(*(char **) (parm + p->pe_ucode), p, mod, 1) != OK)
+ return (NOTOK);
+ break;
+
+ case SETOF_START:
+ case SEQOF_START:
+ if (fre_seqof(*(char **) (parm + p->pe_ucode), p, mod, 1) != OK)
+ return (NOTOK);
+ break;
+
+ case SSEQ_START:
+ case SSET_START:
+ if (fre_seq((char *) parm + p->pe_ucode, p, mod, ndofree) != OK)
+ return (NOTOK);
+ break;
+
+ case SSEQOF_START:
+ case SSETOF_START:
+ if (fre_seqof((char *) parm + p->pe_ucode, p, mod, ndofree) != OK)
+ return (NOTOK);
+ break;
+
+ case IMP_OBJ:
+ p++;
+ continue;
+
+ case SOBJECT:
+ if (fre_obj((char *) parm + p->pe_ucode,
+ mod->md_dtab[p->pe_tag], mod, ndofree) != OK)
+ return (NOTOK);
+ break;
+
+ case OBJECT:
+ if (fre_obj(*(char **) (parm + p->pe_ucode),
+ mod->md_dtab[p->pe_tag], mod, 1) != OK)
+ return (NOTOK);
+ break;
+
+ case SCHOICE_START:
+ if (fre_choice((char *) parm + p->pe_ucode, p, mod, ndofree) != OK)
+ return (NOTOK);
+ break;
+
+ case CHOICE_START:
+ if (fre_choice(*(char **) (parm + p->pe_ucode), p, mod, 1) != OK)
+ return (NOTOK);
+ break;
+
+ case SEXTOBJ:
+ if (p[1].pe_type != EXTMOD) {
+ (void) pepsylose (mod, p, NULLPE, "fre_seq:missing EXTMOD");
+ return (NOTOK);
+ }
+ if (fre_obj(parm + p->pe_ucode, (EXT2MOD(mod, (p + 1)))->md_dtab[p->pe_tag],
+ EXT2MOD(mod, (p + 1)), ndofree) != OK)
+ return (NOTOK);
+ break;
+
+ case EXTOBJ:
+ if (p[1].pe_type != EXTMOD) {
+ (void) pepsylose (mod, p, NULLPE, "fre_seq:missing EXTMOD");
+ return (NOTOK);
+ }
+ if (fre_obj(*(char **) (parm + p->pe_ucode),
+ (EXT2MOD(mod, (p + 1)))->md_dtab[p->pe_tag],
+ EXT2MOD(mod, (p + 1)), 1) != OK)
+ return (NOTOK);
+ break;
+
+ default:
+ if (fre_type(parm, p, mod, ndofree) != OK)
+ return (NOTOK);
+ break;
+ }
+
+ NEXT_TPE(p);
+ }
+ if (malptr && dofree) { /* If we saw a malloc free item */
+ free(malptr);
+ malptr = NULLCP;
+ }
+
+ return (OK);
+
+}
+
+/*
+ * free all the fields in a SET OF/SEQUENCE OF type structure. We
+ * must follow the linked list until the end
+ */
+static fre_seqof(parm, p, mod, dofree)
+char *parm;
+tpe *p;
+modtyp *mod; /* Module it is from */
+int dofree;
+{
+ tpe *start; /* first entry in list */
+ char *oparm;
+
+ if (parm == 0)
+ return OK;
+
+ if (p->pe_type != SEQOF_START && p->pe_type != SETOF_START
+ && p->pe_type != SSEQOF_START && p->pe_type != SSETOF_START) {
+ (void) pepsylose (mod, p, NULLPE, "fre_seqof: illegal field");
+ return (NOTOK);
+ }
+ for (start = p; (char *) parm != NULL; p = start) {
+ p++;
+
+ if (p->pe_type == DFLT_B)
+ p++;
+
+ while (p->pe_type != PE_END) {
+
+ switch (p->pe_type) {
+ case MEMALLOC:
+ break;
+
+ case ETAG:
+ p++;
+ continue;
+
+ case UCODE:
+ break;
+
+ case SEQ_START:
+ case SET_START:
+ if (fre_seq(*(char **) (parm + p->pe_ucode), p, mod, 1) != OK)
+ return (NOTOK);
+ break;
+
+ case SEQOF_START:
+ case SETOF_START:
+ if (fre_seqof(*(char **) (parm + p->pe_ucode), p, mod, 1) != OK)
+ return (NOTOK);
+ break;
+
+ case SSEQ_START:
+ case SSET_START:
+ if (fre_seq((char *) parm + p->pe_ucode, p, mod, dofree) != OK)
+ return (NOTOK);
+ break;
+
+ case SSEQOF_START:
+ case SSETOF_START:
+ if (fre_seqof((char *) parm + p->pe_ucode, p, mod, dofree) != OK)
+ return (NOTOK);
+ break;
+
+ case IMP_OBJ:
+ p++;
+ continue;
+
+ case SOBJECT:
+ if (fre_obj(parm + p->pe_ucode, mod->md_dtab[p->pe_tag], mod, 0) != OK)
+ return (NOTOK);
+ break;
+
+ case OBJECT:
+ if (fre_obj(*(char **) (parm + p->pe_ucode),
+ mod->md_dtab[p->pe_tag], mod, 1) != OK)
+ return (NOTOK);
+ break;
+
+ case SCHOICE_START:
+ if (fre_choice((char *) parm + p->pe_ucode, p, mod, 0) != OK)
+ return (NOTOK);
+ break;
+
+ case CHOICE_START:
+ if (fre_choice(*(char **)(parm + p->pe_ucode), p, mod, 1) != OK)
+ return (NOTOK);
+ break;
+
+ case SEXTOBJ:
+ if (p[1].pe_type != EXTMOD) {
+ (void) pepsylose (mod, p, NULLPE,
+ "fre_seqof: missing EXTMOD");
+ return (NOTOK);
+ }
+ if (fre_obj(parm + p->pe_ucode, (EXT2MOD(mod, (p + 1)))->md_dtab[p->pe_tag],
+ EXT2MOD(mod, (p + 1)), 0) != OK)
+ return (NOTOK);
+ break;
+
+ case EXTOBJ:
+ if (p[1].pe_type != EXTMOD) {
+ (void) pepsylose (mod, p, NULLPE,
+ "fre_seqof: missing EXTMOD");
+ return (NOTOK);
+ }
+ if (fre_obj(*(char **) (parm + p->pe_ucode),
+ (EXT2MOD(mod, (p + 1)))->md_dtab[p->pe_tag],
+ EXT2MOD(mod, (p + 1)), 1) != OK)
+ return (NOTOK);
+ break;
+
+ default:
+ if (fre_type(parm, p, mod, 1) != OK)
+ return (NOTOK);
+ break;
+ }
+
+ NEXT_TPE(p);
+ }
+ oparm = parm;
+ parm = *(char **) (parm + p->pe_ucode); /* Any more ? */
+ if (dofree) {
+ free(oparm);
+ oparm = NULLCP;
+ }
+ }
+
+ return (OK);
+
+}
+
+/*
+ * free the item of the choice. Use the SCTRL field to determine
+ * which item is present and then call the appropriate routine to
+ * free it
+ */
+static fre_choice(parm, p, mod, dofree)
+char *parm;
+tpe *p;
+modtyp *mod; /* Module it is from */
+int dofree;
+{
+ int cnt;
+ char *malptr = NULL; /* Have we seen a malloc */
+ int ndofree = dofree; /* Does the function below deallocate space */
+
+ if (parm == 0)
+ return OK;
+
+ if (p->pe_type != CHOICE_START && p->pe_type != SCHOICE_START) {
+ (void) pepsylose (mod, p, NULLPE,
+ "fre_choice:CHOICE_START missing found %d\n", p->pe_type);
+ }
+ p++;
+
+ if (p->pe_type == DFLT_B)
+ p++;
+
+ if (p->pe_type == MEMALLOC) {
+ if (dofree) {
+ malptr = parm;
+ ndofree = 0; /* we are deallocating space on this level */
+ }
+ p++;
+ }
+ if (p->pe_type != SCTRL) {
+ (void) pepsylose (mod, p, NULLPE,
+ "fre_choice: missing SCTRL information\n");
+ return (NOTOK);
+ }
+ cnt = *(int *) (parm + p->pe_ucode);
+ if (cnt != 0)
+ cnt--;
+ if (cnt < 0) {
+ (void) pepsylose (mod, p, NULLPE,"fre_choice:offset negative %d", cnt);
+ return (NOTOK);
+ }
+ for (p++; p->pe_type != PE_END; NEXT_TPE(p)) {
+ if (ISDTYPE(p)) {
+ if (cnt == 0) {
+ if (fre_type(parm, p, mod, ndofree) != OK)
+ return (NOTOK);
+ if (malptr && dofree) { /* If we saw a malloc free item */
+ free(malptr);
+ malptr = NULLCP;
+ }
+ return (OK);
+ }
+ cnt--;
+ }
+ }
+
+ (void) pepsylose (mod, p, NULLPE, "fre_choice: no choice taken");
+ return (NOTOK);
+}
+/*
+ * look out for FN_CALL - if this entry is really a FN_CALL return non zero
+ * else return 0
+ * Basically we have to stop FN_CALL being tested by hasdata which will call
+ * the decoding function which is illegal and gives rubbish.
+ */
+callsfn(p, mod)
+tpe *p;
+modtyp *mod;
+{
+
+ while (p->pe_type != PE_END) {
+ switch (p->pe_type) {
+ case ETAG:
+ p++;
+ continue;
+
+ case FN_CALL:
+ return (1);
+
+ default:
+ case INTEGER:
+ case REALTYPE:
+ case BOOLEAN:
+ case T_NULL:
+ case IMP_OBJ:
+ case OBJECT:
+ return (0);
+ }
+ }
+
+ (void) pepsylose (mod, p, NULLPE,"callsfn:Corrupted tables:PE_END found\n");
+ ferr(1, "callsfn:Mangled tables\n");
+ /*NOTREACHED*/
+
+}
diff --git a/src/isode/pepsy/lex.l.gnrc b/src/isode/pepsy/lex.l.gnrc
new file mode 100644
index 000000000..5676e3884
--- /dev/null
+++ b/src/isode/pepsy/lex.l.gnrc
@@ -0,0 +1,630 @@
+/* lex.l - lex ASN.1 analyzer */
+/* %WARNING% */
+
+%{
+#ifndef lint
+static char *RCSid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:30:38 eichin
+ * autoconfed isode for kerberos work
+ *
+Revision 1.1 94/06/10 03:19:06 eichin
+autoconfed isode for kerberos work
+
+# Revision 1.1 1994/05/31 20:39:22 eichin
+# reduced-isode release from /mit/isode/isode-subset/src
+#
+ * Revision 8.0 91/07/17 12:42:58 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ *
+ */
+
+
+struct table {
+ char *t_keyword;
+ int t_value;
+ int t_porting;
+};
+
+static struct table reserved[] = {
+ "ABSENT", ABSENT, 0,
+ "ANY", ANY, 0,
+ "APPLICATION", APPLICATION, 0,
+ "BEGIN", BGIN, 0,
+ "BIT", BIT, 0,
+ "BITSTRING", BITSTRING, 0,
+ "BOOLEAN", BOOLEAN, 0,
+ "BY", BY, 0,
+ "CHOICE", CHOICE, 0,
+ "COMPONENT", COMPONENT, 0,
+ "COMPONENTS", COMPONENTS, 0,
+ "COMPONENTSOF", COMPONENTSOF, 0,
+ "DECODER", DECODER, 0,
+ "DEFAULT", DEFAULT, 0,
+ "DEFINED", DEFINED, 0,
+ "DEFINITIONS", DEFINITIONS, 0,
+ "ENCODER", ENCODER, 0,
+ "ENCRYPTED", ENCRYPTED, 0,
+ "END", END, 0,
+ "ENUMERATED", ENUMERATED, 0,
+ "EXPLICIT", EXPLICIT, 0,
+ "EXPORTS", EXPORTS, 0,
+ "FALSE", FALSE, 0,
+ "FROM", FROM, 0,
+ "IDENTIFIER", IDENTIFIER, 0,
+ "IMPLICIT", IMPLICIT, 0,
+ "IMPORTS", IMPORTS, 0,
+ "INCLUDE", INCLUDES, 0,
+ "INTEGER", INTEGER, 0,
+ "MIN", MIN, 0,
+ "MAX", MAX, 0,
+ "NULL", NIL, 0,
+ "OBJECT", OBJECT, 0,
+ "OCTET", OCTET, 0,
+ "OCTETSTRING", OCTETSTRING, 0,
+ "OF", OF, 0,
+ "OPTIONAL", OPTIONAL, 0,
+ "PREFIXES", PREFIXES, 0,
+ "PRESENT", PRESENT, 0,
+ "PRINTER", PRINTER, 0,
+ "PRIVATE", PRIVATE, 0,
+ "REAL", REAL, 0,
+ "SECTIONS", SECTIONS, 0,
+ "SEQUENCE", SEQUENCE, 0,
+ "SEQUENCEOF", SEQUENCEOF, 0,
+ "SET", SET, 0,
+ "SETOF", SETOF, 0,
+ "SIZE", SIZE, 0,
+ "STRING", STRING, 0,
+ "TAGS", TAGS, 0,
+ "TRUE", TRUE, 0,
+ "UNIVERSAL", UNIVERSAL, 0,
+ "WITH", WITH, 0,
+ "PLUS-INFINITY", PLUSINFINITY, 0,
+ "MINUS-INFINITY", MINUSINFINITY, 0,
+%BEGIN(ROSY)%
+ "OPERATION", OPERATION, 1,
+ "ARGUMENT", ARGUMENT, 0,
+ "RESULT", RESULT, 0,
+ "ERRORS", ERRORS, 0,
+ "LINKED", LINKED, 0,
+ "ERROR", ERROR, 1,
+ "PARAMETER", PARAMETER, 0,
+/* start new stuff */
+ "ABSTRACT-OPERATION", OPERATION, 0,
+ "ABSTRACT-ERROR", ERROR, 0,
+ "ABSTRACT", ABSTRACT, 0,
+ "OPERATIONS", OPERATIONS, 0,
+ "CONSUMER", CONSUMER, 0,
+ "SUPPLIER", SUPPLIER, 0,
+ "INVOKES", INVOKES, 0,
+ "PORT", PORT, 0,
+ "PORTS", PORTS, 0,
+/* refine is beyond me! (JPO)
+ "REFINE", REFINE, 0,
+ "AS", AS, 0,
+ "RECURRING", RECURRING, 0,
+ "VISIBLE", VISIBLE, 0,
+ "PAIRED", PAIRED, 0,
+*/
+/* end new stuff */
+%END(ROSY)%
+%BEGIN(MOSY)%
+ "OBJECT-TYPE", OBJECTYPE, 1,
+ "SYNTAX", SYNTAX, 0,
+ "ACCESS", ACCESS, 0,
+ "STATUS", STATUS, 0,
+%END(MOSY)%
+ NULL, 0
+};
+
+%}
+
+%%
+
+"--" { register int c, d;
+
+ for (d = 0; c = input (); d = c == '-')
+ if (c == '\n' || (d && c == '-'))
+ break;
+ }
+[ \t]* {
+ if (yydebug)
+ fprintf (stderr, "WT\n");
+ }
+\n {
+ if (yydebug)
+ fprintf (stderr, "NL\n");
+ }
+"::=" {
+ if (yydebug)
+ fprintf (stderr, "SY: CCE\n");
+ return CCE;
+ }
+"..." {
+ if (yydebug)
+ fprintf (stderr, "SY: DOTDOTDOT\n");
+ return DOTDOTDOT;
+ }
+".." {
+ if (yydebug)
+ fprintf (stderr, "SY: DOTDOT\n");
+ return DOTDOT;
+ }
+"." {
+ if (yydebug)
+ fprintf (stderr, "SY: DOT\n");
+ return DOT;
+ }
+";" {
+ if (yydebug)
+ fprintf (stderr, "SY: SEMICOLON");
+ return SEMICOLON;
+ }
+"," {
+ if (yydebug)
+ fprintf (stderr, "SY: COMMA\n");
+ return COMMA;
+ }
+"{" {
+ if (yydebug)
+ fprintf (stderr, "SY: LBRACE\n");
+ return LBRACE;
+ }
+"}" {
+ if (yydebug)
+ fprintf (stderr, "SY: RBRACE\n");
+ return RBRACE;
+ }
+"|" {
+ if (yydebug)
+ fprintf (stderr, "SY: BAR\n");
+ return BAR;
+ }
+"-" {
+ if (yydebug)
+ fprintf (stderr, "SY: MINUS\n");
+ return MINUS;
+ }
+"+" {
+ if (yydebug)
+ fprintf (stderr, "SY: PLUS\n");
+ return PLUS;
+ }
+%BEGIN(ROSY)%
+"[S]" {
+ if (yydebug)
+ fprintf (stderr, "SY: OBJECTSUPPLIER\n");
+ return OBJECTSUPPLIER;
+ }
+"[C]" {
+ if (yydebug)
+ fprintf (stderr, "SY: OBJECTCONSUMER\n");
+ return OBJECTCONSUMER;
+ }
+%END(ROSY)%
+"[["|"$"|"<<" { register int tok, c, d, len;
+ register char *cp, *ep, *pp;
+
+ if (*yytext == '$')
+ tok = VLENGTH;
+ else
+ if (*yytext == '<')
+ tok = CONTROL;
+ else {
+ while((c = input()) == ' ' || c =='\t')
+ continue;
+ switch (c) {
+ case 'a': tok = VALA;
+ break;
+ case 'b': tok = VALB;
+ break;
+ case 'i': tok = VALI;
+ break;
+ case 's': tok = VALS;
+ break;
+ case 'o': tok = VALO;
+ break;
+ case 'x': tok = VALX;
+ break;
+ case 'p': tok = VALP;
+ break;
+ case 'q': tok = VALQ;
+ break;
+ case 'r': tok = VALR;
+ break;
+ case 't': tok = VALT;
+ break;
+ case 'O': tok = VALOID;
+ break;
+ case 'P': tok = PARAMETERTYPE;
+ break;
+ case 'T': tok = VALTYPE;
+ break;
+ case 'E': tok = ENC_FN;
+ break;
+ case 'D': tok = DEC_FN;
+ break;
+ case 'F': tok = FRE_FN;
+ break;
+ default : myyerror ("unknown token: \"%s\"", yytext);
+ break;
+ }
+ if ((c = input()) != ' ' && c != '\t'
+ && c != '\n')
+ yyerror ("syntax error in [[ ... ]]");
+ }
+
+ if ((pp = malloc ((unsigned) (len = BUFSIZ)))
+ == NULL)
+ yyerror ("out of memory");
+
+ for (ep = (cp = pp) + len - 1, d = NULL;; d = c) {
+ if ((c = input ()) == NULL)
+ yyerror ("end-of-file while reading value");
+ if ((d == ']' && c == ']' && tok !=CONTROL) ||
+ (c == '$' && (tok ==VALX || tok ==VALO)) ||
+ (d == '>' && c == '>' && tok ==CONTROL)) {
+ if ((tok == VALX || tok == VALO) &&
+ (c != '$'))
+ yyerror("Missing '$' in [[ - ]]");
+ if (c == '$') {unput(c); *cp = NULL;}
+ else *--cp = NULL;
+ yylval.yy_string = pp;
+ if (yydebug)
+ fprintf (stderr, "VAL: \"%s\"\n",
+ yylval.yy_string);
+ return tok;
+ }
+ if (cp >= ep) {
+ register int curlen = cp - pp;
+ register char *dp;
+
+ if ((dp = realloc (pp,
+ (unsigned) (len += BUFSIZ)))
+ == NULL)
+ yyerror ("out of memory");
+ cp = dp + curlen;
+ ep = (pp = dp) + len - 1;
+ }
+ *cp++ = c;
+ }
+ }
+"[" {
+ if (yydebug)
+ fprintf (stderr, "SY: LBRACKET\n");
+ return LBRACKET;
+ }
+"]" {
+ if (yydebug)
+ fprintf (stderr, "SY: RBRACKET\n");
+ return RBRACKET;
+ }
+"<" {
+ if (yydebug)
+ fprintf (stderr, "SY: LANGLE\n");
+ return LANGLE;
+ }
+"(" {
+ if (yydebug)
+ fprintf (stderr, "SY: LPAREN\n");
+ return LPAREN;
+ }
+")" {
+ if (yydebug)
+ fprintf (stderr, "SY: RPAREN\n");
+ return RPAREN;
+ }
+"\*" {
+ if (yydebug)
+ fprintf (stderr, "SY: STAR\n");
+ return STAR;
+ }
+[0-9]+ {
+ (void) sscanf (yytext, "%d", &yylval.yy_number);
+ if (yydebug)
+ fprintf (stderr, "LIT: 0x%x\n", yylval.yy_number);
+ return LITNUMBER;
+ }
+-[0-9]+ {
+ (void) sscanf (yytext, "%d", &yylval.yy_number);
+ if (yydebug)
+ fprintf (stderr, "LIT: 0x%x\n", yylval.yy_number);
+ return LITNUMBER;
+ }
+'[^'$]*'[BbHh] { register char *cp; register int i;
+
+ switch (*(cp = yytext + strlen (yytext) - 1)) {
+ case 'H':
+ case 'h':
+ *--cp = NULL;
+ for (cp = yytext + 1; *cp; cp++)
+ if (!isxdigit(*cp))
+ yyerror ("bad hex string");
+ yylval.yy_string = new_string(yytext + 1);
+ if (yydebug)
+ fprintf (stderr,
+ "HSTRING: %s\n", yylval.yy_string);
+ return HSTRING;
+
+ case 'B':
+ case 'b':
+ *--cp = NULL;
+ for (cp = yytext + 1; *cp; cp++)
+ if (*cp != '0' && *cp != '1')
+ yyerror ("bad bit string");
+ yylval.yy_string = new_string(yytext + 1);
+ if (yydebug)
+ fprintf (stderr,
+ "BSTRING: %s\n", yylval.yy_string);
+ return BSTRING;
+ }
+ yyerror ("illegal string");
+ }
+\"[^\"$]*\" {
+ yytext[strlen (yytext) - 1] = NULL;
+ yylval.yy_string = new_string (yytext + 1);
+ if (yydebug)
+ fprintf (stderr, "LIT: \"%s\"\n", yylval.yy_string);
+ return LITSTRING;
+ }
+[A-Z][A-Za-z0-9-]* { register struct table *t;
+
+ for (t = reserved; t -> t_keyword; t++)
+ if (strcmp (t -> t_keyword, yytext) == 0) {
+ if (yyporting && t -> t_porting)
+ break;
+ if (yydebug)
+ fprintf (stderr,
+ "KE: \"%s\"\n", yytext);
+ yylval.yy_number = yylineno;
+ return t -> t_value;
+ }
+ yylval.yy_string = new_string (yytext);
+ if (yydebug)
+ fprintf (stderr, "ID: \"%s\"\n", yylval.yy_string);
+ return ID;
+ }
+[a-z][A-Za-z0-9-]* { yylval.yy_string = new_string (yytext);
+ if (yydebug)
+ fprintf (stderr, "NAME: \"%s\"\n", yylval.yy_string);
+ return NAME;
+ }
+"%[" { register int c, d, len;
+ register char *cp, *ep, *pp;
+
+ if ((pp = malloc ((unsigned) (len = BUFSIZ)))
+ == NULL)
+ yyerror ("out of memory");
+
+ for (ep = (cp = pp) + len - 1, d = NULL;; d = c) {
+ if ((c = input ()) == NULL)
+ yyerror ("end-of-file while reading value");
+ if (d == '%' && c == ']' ) {
+ *--cp = NULL;
+ yylval.yy_string = pp;
+ if (yydebug)
+ fprintf (stderr, "VAL: \"%s\"\n",
+ yylval.yy_string);
+ return SCTRL;
+ }
+ if (d == '\n')
+ yyerror ("newline in %[ %] construct");
+ if (cp >= ep) {
+ register int curlen = cp - pp;
+ register char *dp;
+
+ if ((dp = realloc (pp,
+ (unsigned) (len += BUFSIZ)))
+ == NULL)
+ yyerror ("out of memory");
+ cp = dp + curlen;
+ ep = (pp = dp) + len - 1;
+ }
+ *cp++ = c;
+ }
+ }
+"%{" { register int c, d, len;
+ int mylineno;
+ register char *cp, *ep, *pp;
+
+ mylineno = yylineno;
+ if ((pp = malloc ((unsigned) (len = BUFSIZ)))
+ == NULL)
+ yyerror ("out of memory");
+
+ for (ep = (cp = pp) + len - 1, d = NULL;; d = c) {
+ if ((c = input ()) == NULL)
+ yyerror ("end-of-file while reading action");
+ if (d == '%' && c == '}') {
+ *--cp = NULL;
+ yylval.yy_action = new_action (pp, mylineno);;
+ if (yydebug)
+ fprintf (stderr, "ACTION: \"%s\", %d\n",
+ yylval.yy_action -> ya_text,
+ yylval.yy_action -> ya_lineno);
+ return ACTION;
+ }
+ if (cp >= ep) {
+ register int curlen = cp - pp;
+ register char *dp;
+
+ if ((dp = realloc (pp,
+ (unsigned) (len += BUFSIZ)))
+ == NULL)
+ yyerror ("out of memory");
+ cp = dp + curlen;
+ ep = (pp = dp) + len - 1;
+ }
+ *cp++ = c;
+ }
+ }
+%BEGIN(PEPSY)%
+"<[DEP]<" { register int c, d, len;
+ int mylineno;
+ register char *cp, *ep, *pp;
+ int c_typ = (yytext[1] == 'D' ? DCHOICE :
+ (yytext[1] == 'E' ? ECHOICE : PCHOICE));
+
+ mylineno = yylineno;
+ if ((pp = malloc ((unsigned) (len = BUFSIZ)))
+ == NULL)
+ yyerror ("out of memory");
+
+ for (ep = (cp = pp) + len - 1, d = NULL;; d = c) {
+ if ((c = input ()) == NULL)
+ yyerror ("end-of-file while reading action");
+ if (d == '>' && c == '>') {
+ *--cp = NULL;
+ yylval.yy_action = new_action (pp, mylineno);;
+ if (yydebug)
+ fprintf (stderr,"%cCHOICE: \"%s\", %d\n",
+ yytext[1],
+ yylval.yy_action -> ya_text,
+ yylval.yy_action -> ya_lineno);
+ return c_typ;
+ }
+ if (cp >= ep) {
+ register int curlen = cp - pp;
+ register char *dp;
+
+ if ((dp = realloc (pp,
+ (unsigned) (len += BUFSIZ)))
+ == NULL)
+ yyerror ("out of memory");
+ cp = dp + curlen;
+ ep = (pp = dp) + len - 1;
+ }
+ *cp++ = c;
+ }
+ }
+
+"%E{" { register int c, d, len;
+ int mylineno;
+ register char *cp, *ep, *pp;
+
+ mylineno = yylineno;
+ if ((pp = malloc ((unsigned) (len = BUFSIZ)))
+ == NULL)
+ yyerror ("out of memory");
+
+ for (ep = (cp = pp) + len - 1, d = NULL;; d = c) {
+ if ((c = input ()) == NULL)
+ yyerror ("end-of-file while reading action");
+ if (d == '%' && c == '}') {
+ *--cp = NULL;
+ yylval.yy_action = new_action (pp, mylineno);;
+ if (yydebug)
+ fprintf (stderr,"EACTION: \"%s\", %d\n",
+ yylval.yy_action -> ya_text,
+ yylval.yy_action -> ya_lineno);
+ return EACTION;
+ }
+ if (cp >= ep) {
+ register int curlen = cp - pp;
+ register char *dp;
+
+ if ((dp = realloc (pp,
+ (unsigned) (len += BUFSIZ)))
+ == NULL)
+ yyerror ("out of memory");
+ cp = dp + curlen;
+ ep = (pp = dp) + len - 1;
+ }
+ *cp++ = c;
+ }
+ }
+"%D{" { register int c, d, len;
+ int mylineno;
+ register char *cp, *ep, *pp;
+
+ mylineno = yylineno;
+ if ((pp = malloc ((unsigned) (len = BUFSIZ)))
+ == NULL)
+ yyerror ("out of memory");
+
+ for (ep = (cp = pp) + len - 1, d = NULL;; d = c) {
+ if ((c = input ()) == NULL)
+ yyerror ("end-of-file while reading action");
+ if (d == '%' && c == '}') {
+ *--cp = NULL;
+ yylval.yy_action = new_action (pp, mylineno);;
+ if (yydebug)
+ fprintf (stderr,"DACTION: \"%s\", %d\n",
+ yylval.yy_action -> ya_text,
+ yylval.yy_action -> ya_lineno);
+ return DACTION;
+ }
+ if (cp >= ep) {
+ register int curlen = cp - pp;
+ register char *dp;
+
+ if ((dp = realloc (pp,
+ (unsigned) (len += BUFSIZ)))
+ == NULL)
+ yyerror ("out of memory");
+ cp = dp + curlen;
+ ep = (pp = dp) + len - 1;
+ }
+ *cp++ = c;
+ }
+ }
+"%P{" { register int c, d, len;
+ int mylineno;
+ register char *cp, *ep, *pp;
+
+ mylineno = yylineno;
+ if ((pp = malloc ((unsigned) (len = BUFSIZ)))
+ == NULL)
+ yyerror ("out of memory");
+
+ for (ep = (cp = pp) + len - 1, d = NULL;; d = c) {
+ if ((c = input ()) == NULL)
+ yyerror ("end-of-file while reading action");
+ if (d == '%' && c == '}') {
+ *--cp = NULL;
+ yylval.yy_action = new_action (pp, mylineno);;
+ if (yydebug)
+ fprintf (stderr,"PACTION: \"%s\", %d\n",
+ yylval.yy_action -> ya_text,
+ yylval.yy_action -> ya_lineno);
+ return PACTION;
+ }
+ if (cp >= ep) {
+ register int curlen = cp - pp;
+ register char *dp;
+
+ if ((dp = realloc (pp,
+ (unsigned) (len += BUFSIZ)))
+ == NULL)
+ yyerror ("out of memory");
+ cp = dp + curlen;
+ ep = (pp = dp) + len - 1;
+ }
+ *cp++ = c;
+ }
+ }
+%END(PEPSY)%
+. {
+ myyerror ("unknown token: \"%s\"", yytext);
+ }
+
+%%
diff --git a/src/isode/pepsy/libpepsy.3 b/src/isode/pepsy/libpepsy.3
new file mode 100644
index 000000000..a4f99a86f
--- /dev/null
+++ b/src/isode/pepsy/libpepsy.3
@@ -0,0 +1,42 @@
+.TH LIBPEPSY 3 "16 Oct 1987"
+.\" $Header$
+.\"
+.\"
+.\" $Log$
+.\" Revision 1.1 1994/06/10 03:30:42 eichin
+.\" autoconfed isode for kerberos work
+.\"
+Revision 1.1 94/06/10 03:19:08 eichin
+autoconfed isode for kerberos work
+
+# Revision 1.1 1994/05/31 20:39:24 eichin
+# reduced-isode release from /mit/isode/isode-subset/src
+#
+.\" Revision 8.0 91/07/17 12:42:58 isode
+.\" Release 7.0
+.\"
+.\"
+.SH NAME
+libpepsy \- PEPSY support library
+.SH SYNOPSIS
+\fIpepsy\fR\0...\0\fImodule.py\fR
+.sp
+\fIcc\fR\0...\0\fImodule_tables.c\fR\0\fB\-lisode\fR
+.SH DESCRIPTION
+The \fIlibpepsy\fR library contains driver routines for processing
+the tables produced by \fIpepsy\fR.
+Also contains the tables for the ASN.1 defined types
+generated by \fIpepsy\fR and some miscellanous printing routines in
+\fIvprint.c\fR.
+This library is unspectacular but necessary.
+.SH FILES
+None
+.SH "SEE ALSO"
+pepsy(1)
+.SH DIAGNOSTICS
+Routines for users use routines return
+the manifest constant \fBNOTOK\fR (\-1) on error.
+Others return \fBNULLPE\fR on error.
+.SH AUTHOR
+Andrew Worsley,
+CSIRO and UCL
diff --git a/src/isode/pepsy/macdefs.h b/src/isode/pepsy/macdefs.h
new file mode 100644
index 000000000..b39a9d2c3
--- /dev/null
+++ b/src/isode/pepsy/macdefs.h
@@ -0,0 +1,57 @@
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:30:44 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:19:10 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:39:31 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:42:59 isode
+ * Release 7.0
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+/*
+ * common encoding macro definitions
+ */
+
+#define DO_OFFSET(parm, p) ((parm) + (p)->pe_ucode)
+#define NO_OFFSET(parm, p) (parm)
+
+/* various things From Pointer And Offset- *_FPAO */
+
+#define INT_FPAO(parm, p) (*(integer *)DO_OFFSET(parm, p))
+
+#define REAL_FPAO(parm, p) (*(double *)DO_OFFSET(parm, p))
+
+#define CHAR_FPAO(parm, p) (*(char *)DO_OFFSET(parm, p))
+
+#define OID_FPAO(parm, p) (*(OID *)DO_OFFSET(parm, p))
+#define SOID_FPAO(parm, p) ((OID)NO_OFFSET(parm, p))
+
+#define PTR_FPAO(parm, p) (*(char **)DO_OFFSET(parm, p))
+#define SPTR_FPAO(parm, p) ((char *)NO_OFFSET(parm, p))
+
+#define QB_FPAO(parm, p) (*(struct qbuf **)DO_OFFSET(parm, p))
+#define SQB_FPAO(parm, p) ((struct qbuf *)NO_OFFSET(parm, p))
+
+#define PE_FPAO(parm, p) (*(PE *)DO_OFFSET(parm, p))
+#define SPE_FPAO(parm, p) ((PE)NO_OFFSET(parm, p)
+
+#define TYPE2MOD(mod, p) ((mod)->md_etab[p->pe_tag])
diff --git a/src/isode/pepsy/main.c b/src/isode/pepsy/main.c
new file mode 100644
index 000000000..1b5360e6a
--- /dev/null
+++ b/src/isode/pepsy/main.c
@@ -0,0 +1,4244 @@
+/* main.c */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:30:46 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:19:12 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:39:33 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:42:59 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+#include <stdio.h>
+#include <ctype.h>
+#include "config.h"
+#ifdef PEPSY_REALS
+#include <math.h>
+#define F_SMALL (1.0e-10) /* How accurate should reals agree */
+#endif
+#include "psap.h"
+#include "T1-types.h"
+#include "T2-types.h"
+#include "T3-types.h"
+
+
+
+#include "test_table.h"
+ /* compactly generate the new item of data */
+#define new(x) ((x *)calloc(1, sizeof (x)))
+
+#define NULLQB (struct qbuf *)0
+char *fill();
+static char *idname();
+static char *clname();
+static int prntbits();
+static int pclen();
+static int prntos();
+static int prntstr();
+
+extern int print_pe();
+extern modtyp _ZBIT_1;
+extern char *bitstr2strb();
+extern PE mkpelist(), mkpe();
+extern OID mkoid();
+extern struct type_UNIV_EXTERNAL *mkext();
+
+extern struct rep_elem *mkrep_elem();
+extern struct rep_int *mkrep_int();
+
+extern void exit();
+
+static int t_test = 1; /* Iteration of the test */
+
+#define NullParm ((char *) 0)
+/*ARGSUSED*/
+main(argc, argv)
+int argc;
+char **argv;
+{
+ int i;
+ int succ, fail;
+
+ succ = fail = 0;
+ if (argc <= 1) {
+ for (i = MAXTCASE - 1; i >= 0; i--) {
+ if (t_case[i].tst_entry < 0)
+ continue;
+ for (t_test = t_case[i].tst_tests; t_test > 0; t_test--) {
+ if (ed_tst(i) != OK) {
+ (void) printf("Failed\n");
+ fail++;
+ } else
+ succ++;
+ }
+ }
+ if (fail > 0)
+ (void) printf("Failed\n");
+ (void) printf("Total %d = %d successes %d failures\n", fail + succ, succ, fail);
+#ifdef PEP_TEST
+ tailorfree();
+#endif
+ } else {
+ i = atoi(argv[1]);
+ if (argc > 2)
+ t_test = atoi(argv[2]);
+ (void) printf("Test %d\n", i);
+ if (ed_tst(i) != OK)
+ (void) printf("Failed\n");
+#ifdef PEP_TEST
+ tailorfree();
+#endif
+ }
+ return (fail);
+
+}
+
+/*
+ * Perform a test of encoding/decoding on type number tynum
+ */
+ed_tst(tynum)
+int tynum;
+{
+ PE pe;
+ char *parm1, *parm2;
+
+ if (tynum < 0 || tynum >= MAXTCASE)
+ ferrd(1, "ed_tst illegal type %d\n", tynum);
+
+
+ if ((parm1 = fill(tynum)) == NULL) {
+ ferr(1, "calloc did not work\n");
+ }
+
+#define encode(tynum, x, parm) \
+ enc_f(t_case[tynum].tst_entry, &_ZT1_mod, (x), 1, 0, NULLCP, (parm))
+
+ if (encode(tynum, &pe, parm1) == NOTOK) {
+ (void) printf("encode:failed on %s: %s\n", t_case[tynum].tst_name,
+ PY_pepy);
+ return(NOTOK);
+ }
+
+
+#define decode(tynum, x, parm) \
+ dec_f(t_case[tynum].tst_entry, &_ZT1_mod, (x), 1, (int *) 0, (char **)NULL, (parm))
+
+ if (decode(tynum, pe, &parm2) == NOTOK) {
+ (void) printf("decode:failed on %s: %s\n", t_case[tynum].tst_name,
+ PY_pepy);
+ return (NOTOK);
+ }
+
+ if (tcmp(tynum, parm1, parm2)) {
+ (void) printf("%s: not transfered properly\n", t_case[tynum].tst_name);
+ return (NOTOK);
+ }
+
+#if PRNT
+#define print(tynum, x) \
+ prnt_f(t_case[tynum].tst_entry, &_ZT1_mod, (x), 1, (int *) 0, (char **)0)
+
+ (void) printf("\n\"%s\" t_test = %d\n", t_case[tynum].tst_name, t_test);
+ if (print(tynum, pe) == NOTOK) {
+ (void) printf("Print:failed on %s: %s\n", t_case[tynum].tst_name,
+ PY_pepy);
+ exit(2);
+ }
+#endif
+
+
+
+#define fre_space(tynum, parm) \
+ fre_obj(parm, _ZT1_mod.md_dtab[t_case[tynum].tst_entry], &_ZT1_mod, 1)
+
+ if (fre_space(tynum, parm1) != OK)
+ return (NOTOK);
+ if (fre_space(tynum, parm2) != OK)
+ return (NOTOK);
+
+ if (pe)
+ pe_free(pe);
+
+ return (OK);
+}
+
+ /*SUPPRESS 218*/
+/*
+ * fill in some test data for the given type
+ */
+char *
+fill(tynum)
+int tynum;
+{
+ char *parm;
+ static int count;
+ int i;
+ char *p;
+
+ if ((parm = calloc(1, t_case[tynum].tst_size)) == NULL) {
+ ferr(1, "calloc did not work\n");
+ }
+
+ switch (tynum) {
+ case TY_MPDU:
+#define Xparm ((struct type_T1_MPDU *)parm)
+ if ((Xparm->a__seq = new(struct element_T1_1)) == NULL) {
+ (void) printf("calloc did not work\n");
+ return NULL;
+ }
+ Xparm->a__seq->fred = 10;
+ Xparm->a__seq->george = 1;
+ break;
+#undef Xparm
+
+ case TY_EMBEDDED:
+#define Xparm ((struct type_T1_Embedded *)parm)
+ Xparm->anMPDU = (struct type_T1_MPDU *)fill(TY_MPDU);
+ Xparm->ei = 6966;
+ break;
+#undef Xparm
+
+ case TY_STRINGS:
+#define Xparm ((struct type_T1_Strings *)parm)
+ Xparm->ostring = str2qb("12\376\0\377a6", 7, 1);
+ Xparm->bstring = strb2bitstr("\270\017\010\020\040\100", 50, 0, 0);
+ Xparm->nstring = str2qb("123456", 6, 1);
+ Xparm->pstring = str2qb("hello, world", 12, 1);
+ Xparm->tstring = str2qb("teletex", 7, 1);
+ Xparm->t61string = str2qb("T.61", 4, 1);
+ Xparm->vstring = str2qb("visible", 7, 1);
+ Xparm->vis__string = str2qb("visible again", 13, 1);
+ Xparm->i646string = str2qb("who knows what this is", 22, 1);
+ Xparm->ia5string = str2qb("This is ASCII\n\r", 15, 1);
+ Xparm->graphstring = str2qb("This is a graphic string", 24, 1);
+ Xparm->genstring = str2qb("This is a general string", 24, 1);
+ break;
+#undef Xparm
+
+ case TY_EMB_STRINGS:
+#define Xparm ((struct type_T1_Emb__Strings *)parm)
+ Xparm->atest = 2001;
+ Xparm->ctest = strb2bitstr("\03\010\252\125", 24, 0, 0);
+ Xparm->btest = str2qb("Good bye", 8, 1);
+ Xparm->big__test = (struct type_T1_Strings *)fill(TY_STRINGS);
+ if ((Xparm->emb__test = new(struct element_T1_0)) == NULL) {
+ (void) printf("calloc did not work\n");
+ return NULL;
+ }
+ Xparm->emb__test->em__int = -101;
+ Xparm->emb__test->em__oct = str2qb("Embedded octet string", 21, 1);
+ Xparm->emb__test->em__bit = strb2bitstr("\377\252\125\370\01", 40, 0,0);
+ break;
+#undef Xparm
+
+ case TY_IMPLICIT:
+#define Xparm ((struct type_T1_Impl__Tags *)parm)
+ Xparm->i__impl = -1;
+ Xparm->o__impl = str2qb("I'm an implicit tagged octet string", 36, 1);
+ Xparm->b__impl = strb2bitstr("\0\0\01\230\01", 40, 0, 0);
+ Xparm->f__impl = 0xff; /* True */
+ Xparm->obj__impl = (struct type_T1_Emb__Strings *)fill(TY_EMB_STRINGS);
+ if ((Xparm->i__emb__test = new(struct element_T1_2)) == NULL) {
+ (void) printf("calloc did not work\n");
+ return NULL;
+ }
+ Xparm->i__emb__test->i__em__int = -101;
+ Xparm->i__emb__test->i__em__oct = str2qb("Implicit Embedded", 18, 1);
+ Xparm->i__emb__test->i__em__bit = strb2bitstr("\200\200\200\200", 32, 0, 0);
+#undef Xparm
+ break;
+
+ case TY_EXPLICIT:
+#define Xparm ((struct type_T1_Expl__Tags *)parm)
+ Xparm->i__expl = 35051;
+ Xparm->o__expl = str2qb("explicit tagged octet string", 28, 1);
+ Xparm->b__expl = strb2bitstr("\070\070\070\077", 32, 0, 0);
+ Xparm->f__expl = 0xf0; /* True */
+ Xparm->obj__expl = (struct type_T1_Emb__Strings *)fill(TY_EMB_STRINGS);
+ if ((Xparm->i__exp__test = new(struct element_T1_3)) == NULL) {
+ (void) printf("calloc did not work\n");
+ return NULL;
+ }
+ Xparm->i__exp__test->i__ex__int = -9;
+ Xparm->i__exp__test->i__ex__oct = str2qb("Explicit Embedded", 18, 1);
+ Xparm->i__exp__test->i__ex__bit = strb2bitstr("\03\03\03\03\277", 40, 0, 0);
+#undef Xparm
+ break;
+
+ case TY_SEQOF:
+#define Xparm ((struct type_T1_Seqof__Test *)parm)
+ count = 2;
+ Xparm->sqof__test1 = (struct element_T1_4 *) fill(TY_ELEMENT4);
+ count = 2;
+ Xparm->stof__test1 = (struct member_T1_2 *) fill(TY_MEMBER2);
+ Xparm->i__test1 = 33;
+ count = 2;
+ Xparm->sqof__test2 = (struct element_T1_6 *) fill(TY_ELEMENT6);
+ count = 2;
+ Xparm->stof__test2 = (struct member_T1_4 *) fill(TY_MEMBER4);
+ Xparm->i__test2 = 99;
+ break;
+#undef Xparm
+
+ case TY_ELEMENT4:
+#define Xparm ((struct element_T1_4 *)parm)
+ Xparm->element_T1_5 = (struct type_T1_Expl__Tags *)fill(TY_EXPLICIT);
+ if (count-- > 0)
+ Xparm->next = (struct element_T1_4 *) fill(TY_ELEMENT4);
+ else
+ Xparm->next = NULL;
+ break;
+#undef Xparm
+
+ case TY_MEMBER2:
+#define Xparm ((struct member_T1_2 *)parm)
+ Xparm->member_T1_3 = (struct type_T1_Expl__Tags *)fill(TY_EXPLICIT);
+ if (count-- > 0)
+ Xparm->next = (struct member_T1_2 *) fill(TY_MEMBER2);
+ else
+ Xparm->next = NULL;
+ break;
+#undef Xparm
+
+ case TY_ELEMENT6:
+#define Xparm ((struct element_T1_6 *)parm)
+ Xparm->element_T1_7 = (struct element_T1_8 *)fill(TY_ELEMENT8);
+ if (count-- > 0)
+ Xparm->next = (struct element_T1_6 *) fill(TY_ELEMENT6);
+ else
+ Xparm->next = NULL;
+ break;
+#undef Xparm
+
+ case TY_ELEMENT8:
+#define Xparm ((struct element_T1_8 *)parm)
+ Xparm->sqof__in = (struct type_T1_Expl__Tags *)fill(TY_EXPLICIT);
+ Xparm->sqof__i = 212121;
+ Xparm->sqof__o = str2qb("Element8 Embedded", 18, 1);
+ break;
+#undef Xparm
+
+ case TY_MEMBER4:
+#define Xparm ((struct member_T1_4 *)parm)
+ Xparm->member_T1_5 = (struct element_T1_9 *)fill(TY_ELEMENT9);
+ if (count-- > 0)
+ Xparm->next = (struct member_T1_4 *) fill(TY_MEMBER4);
+ else
+ Xparm->next = NULL;
+ break;
+#undef Xparm
+
+ case TY_ELEMENT9:
+#define Xparm ((struct element_T1_9 *)parm)
+ Xparm->stof__in = (struct type_T1_Expl__Tags *)fill(TY_EXPLICIT);
+ Xparm->stof__i = -12345;
+ Xparm->stof__o = str2qb("XYZabcde Embedded", 18, 1);
+ break;
+#undef Xparm
+
+ case TY_CHOICE:
+#define Xparm ((struct type_T1_Choice__Test *)parm)
+ Xparm->c1 = (struct choice_T1_0 *) fill(TY_CHOICE0);
+ Xparm->c2 = (struct choice_T1_1 *) fill(TY_CHOICE1);
+ Xparm->c3 = (struct choice_T1_2 *) fill(TY_CHOICE2);
+ Xparm->c4 = (struct element_T1_11 *) fill(TY_ELEMENT11);
+ break;
+#undef Xparm
+
+ case TY_CHOICE0:
+#define Xparm ((struct choice_T1_0 *)parm)
+
+ switch (Xparm->offset = (t_test + 10)%choice_T1_0_obj__c1 + 1) {
+ case choice_T1_0_i__c1:
+ Xparm->un.i__c1 = 10101;
+ break;
+
+ case choice_T1_0_o__c1:
+ Xparm->un.o__c1 = str2qb("Andrew Worsley!!!", 18, 1);
+ break;
+
+ case choice_T1_0_b__c1:
+ Xparm->un.b__c1 = strb2bitstr("\02\02\02\07\077", 40, 0, 0);
+ break;
+
+ case choice_T1_0_f__c1:
+ Xparm->un.f__c1 = 0x11;
+ break;
+
+ case choice_T1_0_obj__c1:
+ Xparm->un.obj__c1 = (struct type_T1_Emb__Strings *) fill(TY_EMB_STRINGS);
+ break;
+
+ default:
+ ferrd(1, "TY_CHOICE0:illegal offset %d\n", Xparm->offset);
+ }
+ break;
+#undef Xparm
+
+ case TY_CHOICE1:
+#define Xparm ((struct choice_T1_1 *)parm)
+
+ switch (Xparm->offset = (t_test + 11)%choice_T1_1_obj__c2 + 1) {
+ case choice_T1_1_i__c2:
+ Xparm->un.i__c2 = 1212;
+ break;
+
+ case choice_T1_1_o__c2:
+ Xparm->un.o__c2 = str2qb("Richard Worsley!!", 18, 1);
+ break;
+
+ case choice_T1_1_b__c2:
+ Xparm->un.b__c2 = strb2bitstr("\02\01\01\07\077", 40, 0, 0);
+ break;
+
+ case choice_T1_1_f__c2:
+ Xparm->un.f__c2 = 0x12;
+ break;
+
+ case choice_T1_1_obj__c2:
+ Xparm->un.obj__c2 = (struct type_T1_Emb__Strings *) fill(TY_EMB_STRINGS);
+ break;
+
+ default:
+ ferrd(1, "TY_CHOICE1:illegal offset %d\n", Xparm->offset);
+ }
+ break;
+#undef Xparm
+
+ case TY_CHOICE2:
+#define Xparm ((struct choice_T1_2 *)parm)
+
+ switch (Xparm->offset = (t_test + 12)%choice_T1_2_i__c3 + 1) {
+ case choice_T1_2_i__c3:
+ Xparm->un.i__c3 = 689364;
+ break;
+
+ case choice_T1_2_seq__c3:
+ Xparm->un.seq__c3 = (struct element_T1_10 *) fill(TY_ELEMENT10);
+ break;
+
+ case choice_T1_2_set__c3:
+ Xparm->un.set__c3 = (struct member_T1_6 *) fill(TY_MEMBER6);
+ break;
+
+ default:
+ ferrd(1, "TY_CHOICE2:illegal offset %d\n", Xparm->offset);
+ }
+ break;
+#undef Xparm
+
+ case TY_CHOICE3:
+#define Xparm ((struct choice_T1_3 *)parm)
+
+ switch (Xparm->offset = (t_test + 13)%choice_T1_3_sc__b__i + 1) {
+ case choice_T1_3_sc__a__i:
+ Xparm->un.sc__a__i = 16891;
+ break;
+
+ case choice_T1_3_sc__b__i:
+ Xparm->un.sc__b__i = 13151;
+ break;
+
+ case choice_T1_3_c4__i:
+ Xparm->un.c4__i = 10938;
+ break;
+
+ case choice_T1_3_c4__obj:
+ Xparm->un.c4__obj = (struct type_T1_Expl__Tags *) fill(TY_EXPLICIT);
+ break;
+
+ default:
+ ferrd(1, "TY_CHOICE3:illegal offset %d\n", Xparm->offset);
+ }
+ break;
+#undef Xparm
+
+ case TY_ELEMENT10:
+#define Xparm ((struct element_T1_10 *)parm)
+ Xparm->seq__c3__in = (struct type_T1_Expl__Tags *) fill(TY_EXPLICIT);
+ Xparm->seq__c3__i = 40938;
+ Xparm->seq__c3__o = str2qb("James Worsley!!!!", 18, 1);
+ break;
+#undef Xparm
+
+ case TY_MEMBER6:
+#define Xparm ((struct member_T1_6 *)parm)
+ Xparm->set__c3__in = (struct type_T1_Expl__Tags *) fill(TY_EXPLICIT);
+ Xparm->set__c3__i = 0x40938;
+ Xparm->set__c3__o = str2qb("Patrick Worsley!!", 18, 1);
+ break;
+#undef Xparm
+
+ case TY_ELEMENT11:
+#define Xparm ((struct element_T1_11 *)parm)
+ Xparm->c4__choice = (struct choice_T1_3 *) fill(TY_CHOICE3);
+ break;
+#undef Xparm
+
+ case TY_OPTIONAL:
+#define Xparm ((struct type_T1_Opt__Strings *)parm)
+ if (t_test & opt_T1_Opt__Strings_a__opt) {
+ Xparm->optionals |= opt_T1_Opt__Strings_a__opt;
+ Xparm->a__opt = 192837;
+ }
+ if (t_test & opt_T1_Opt__Strings_d__opt) {
+ Xparm->optionals |= opt_T1_Opt__Strings_d__opt;
+ Xparm->d__opt = 1;
+ }
+ Xparm->b__opt = str2qb("Susan Hannah Sibel", 19, 1);
+ if (t_test*(t_test + 1) & opt_T1_Opt__Strings_d__opt) {
+ Xparm->c__opt = strb2bitstr("\012\017\02\07\077", 40, 0, 0);
+ }
+ if (t_test & opt_T1_Opt__Strings_e__opt) {
+ Xparm->optionals |= opt_T1_Opt__Strings_e__opt;
+ Xparm->e__opt = 0;
+ }
+ if ((t_test + 12)*t_test & opt_T1_Opt__Strings_a__opt) {
+ Xparm->big__opt = (struct type_T1_Strings *) fill(TY_STRINGS);
+ }
+ if ((t_test + 2)*t_test & opt_T1_Opt__Strings_a__opt) {
+ Xparm->emb__opt = (struct element_T1_12 *) fill(TY_ELEMENT12);
+ }
+ if ((t_test + 4)*t_test & opt_T1_Opt__Strings_a__opt) {
+ Xparm->st__opt = (struct member_T1_7 *) fill(TY_MEMBER7);
+ }
+ if ((t_test + 8)*t_test & opt_T1_Opt__Strings_a__opt) {
+ Xparm->obj__opt = (struct type_T1_MPDU *) fill(TY_MPDU);
+ }
+ if (t_test & opt_T1_Opt__Strings_etag__opt) {
+ Xparm->optionals |= opt_T1_Opt__Strings_etag__opt;
+ Xparm->etag__opt = 2983461;
+ }
+ if ((t_test + 6)*t_test & opt_T1_Opt__Strings_a__opt) {
+ Xparm->ch__opt = (struct choice_T1_4 *) fill(TY_CHOICE4);
+ }
+ break;
+#undef Xparm
+
+ case TY_ELEMENT12:
+#define Xparm ((struct element_T1_12 *)parm)
+ if ((t_test + 10)*t_test & opt_T1_element_T1_12_oem__int) {
+ Xparm->optionals |= opt_T1_element_T1_12_oem__int;
+ Xparm->oem__int = 197336;
+ }
+ if (t_test*(t_test + 22) & opt_T1_Opt__Strings_a__opt) {
+ Xparm->oem__oct = str2qb("Ling Worsley", 13, 1);
+ }
+ if (t_test*(t_test + 16) & opt_T1_Opt__Strings_d__opt) {
+ Xparm->oem__bit = strb2bitstr("\0142\0117\02\017\07", 40, 0, 0);
+ }
+ break;
+#undef Xparm
+
+ case TY_MEMBER7:
+#define Xparm ((struct member_T1_7 *)parm)
+ if ((t_test + 12)*t_test & opt_T1_member_T1_7_st__int0) {
+ Xparm->optionals |= opt_T1_member_T1_7_st__int0;
+ Xparm->st__int0 = 85659;
+ }
+ if ((t_test + 12)*t_test & opt_T1_member_T1_7_st__int1) {
+ Xparm->optionals |= opt_T1_member_T1_7_st__int1;
+ Xparm->st__int1 = 664388;
+ }
+ if ((t_test + 12)*t_test & opt_T1_member_T1_7_st__int2) {
+ Xparm->optionals |= opt_T1_member_T1_7_st__int2;
+ Xparm->st__int2 = 967768;
+ }
+ break;
+#undef Xparm
+
+ case TY_CHOICE4:
+#define Xparm ((struct choice_T1_4 *)parm)
+
+ switch (Xparm->offset = (t_test + 14)%choice_T1_4_ch__2 + 1) {
+ case choice_T1_4_ch__1:
+ Xparm->un.ch__1 = 74576;
+ break;
+
+ case choice_T1_4_ch__2:
+ Xparm->un.ch__2 = 28828;
+ break;
+
+ default:
+ ferrd(1, "TY_CHOICE4:illegal offset %d\n", Xparm->offset);
+ }
+ break;
+#undef Xparm
+
+ case TY_EXTREF:
+#define Xparm ((struct type_T1_E__ref *)parm)
+ Xparm->a__ref = (struct type_T2_Info *) fill(TY_T2_INFO);
+ Xparm->b__ref = (struct type_T2_Info *) fill(TY_T2_INFO);
+ Xparm->c__ref = (struct type_T1_Choice__Test *) fill(TY_CHOICE);
+ if ((t_test + 20)*t_test & 0x2) {
+ Xparm->d__ref = (struct type_T2_Info *) fill(TY_T2_INFO);
+ }
+ if ((t_test + 20)*t_test & 0x1) {
+ Xparm->e__ref = (struct type_T2_Info *) fill(TY_T2_INFO);
+ }
+ break;
+#undef Xparm
+
+ case TY_T2_INFO:
+#define Xparm ((struct type_T2_Info *)parm)
+ Xparm->a1 = 101910;
+ Xparm->a2 = -304985;
+ Xparm->a3 = 13;
+ Xparm->a4 = (struct type_T2_MPDU *) fill(TY_T2_MPDU);
+ break;
+#undef Xparm
+
+ case TY_T2_MPDU:
+#define Xparm ((struct type_T2_MPDU *)parm)
+ Xparm->a__seq = (struct element_T2_0 *) fill(TY_T2_ELEM0);
+ break;
+#undef Xparm
+
+ case TY_T2_ELEM0:
+#define Xparm ((struct element_T2_0 *)parm)
+ Xparm->fred = 998877;
+ break;
+#undef Xparm
+
+ case TY_OPTIMISED:
+#define Xparm ((struct type_T1_Optimised *)parm)
+ Xparm->o1 = strb2bitstr("\0241\0227\032\011\0237", 40, 0, 0);
+ Xparm->o2 = str2qb("Peckling Worsley!!!!", 20, 1);
+ Xparm->o3 = (struct type_T1_MPDU *) fill(TY_MPDU);
+ Xparm->o4 = (PE ) mkpelist(t_test);
+ Xparm->element_T1_14 = (struct member_T1_9 *) fill(TY_MEMBER9);
+ break;
+#undef Xparm
+
+ case TY_MEMBER9:
+#define Xparm ((struct member_T1_9 *)parm)
+ Xparm->o5 = mkpelist(t_test);
+ Xparm->o6 = mkpelist(t_test);
+ Xparm->o7 = mkoid(t_test);
+ break;
+#undef Xparm
+
+ case TY_EXTERNAL:
+#define Xparm ((struct type_T1_Ext__typ *)parm)
+ Xparm->ext = mkext(t_test*8 + 1);
+ Xparm->a__ny = mkpe(t_test*8 + 1);
+ Xparm->ext__impl = mkext(t_test*6 + 1);
+ Xparm->any__impl = mkpe(t_test*8 + 3);
+ Xparm->ext__expl = mkext(t_test*4 + 1);
+ Xparm->any__expl = mkpe(t_test*8 + 5);
+ break;
+#undef Xparm
+
+ case TY_SEXTERNAL:
+#define Xparm ((struct type_T1_SExt *)parm)
+ free(parm); /* don't need it */
+ Xparm = mkext(21);
+ break;
+#undef Xparm
+
+ case TY_ETAGOBJ:
+#define Xparm ((struct type_T1_Etags *)parm)
+ switch (Xparm->offset = (t_test + 4)%type_T1_Etags_bE + 1) {
+ case type_T1_Etags_aE:
+ Xparm->un.aE = 10283;
+ break;
+
+ case type_T1_Etags_bE:
+ Xparm->un.bE = 40986;
+ break;
+
+ default:
+ ferrd(1, "TY_ETAGOBJ:illegal offset %d\n", Xparm->offset);
+ }
+ break;
+#undef Xparm
+
+/* This has to be changed when posy is upgraded to handle DEFAULTS properly */
+ case TY_DEFAULT:
+#define Xparm ((struct type_T1_Def__Strings *)parm)
+ if (t_test*t_test & 2)
+ Xparm->a__def = int_T1_a__def_a__def__0;
+ else
+ Xparm->a__def = int_T1_a__def_a__def__1;
+ if (t_test*t_test & 4)
+ Xparm->b__def = str2qb("Susan Sibel !!!!", 17, 1);
+ else if (t_test*t_test & 8)
+ Xparm->b__def = str2qb("hello, world", 12, 1);
+ else
+ Xparm->b__def = NULLQB;
+ if (t_test*t_test & 8)
+ Xparm->c__def = strb2bitstr(int2strb(bit_T1_c__def_c__def__two, 9),
+ 9, 0, 0);
+ else
+ Xparm->c__def = NULLPE;
+ if (t_test*t_test & 0x10)
+ Xparm->okay = 0;
+ else
+ Xparm->okay = 1;
+ if (t_test*t_test & 0x20)
+ Xparm->e__def = 0;
+ else
+ Xparm->e__def = 1;
+ Xparm->big__def = (struct type_T1_Strings *) fill(TY_STRINGS);
+ if (t_test*t_test*t_test & 0x10)
+ Xparm->emb__def = NULL;
+ else
+ Xparm->emb__def = (struct element_T1_13 *) fill(TY_ELEMENT13);
+ if (t_test*t_test*t_test & 0x20)
+ Xparm->st__def = NULL;
+ else
+ Xparm->st__def = (struct member_T1_8 *) fill(TY_MEMBER8);
+ break;
+#undef Xparm
+
+ case TY_ELEMENT13:
+#define Xparm ((struct element_T1_13 *)parm)
+ if (t_test*t_test*t_test & 1)
+ Xparm->colour = int_T1_colour_green;
+ else
+ Xparm->colour = int_T1_colour_red;
+ if (t_test*t_test & 040)
+ Xparm->oem__oct = str2qb("Julia Dzuikas !!!!", 19, 1);
+ else
+ Xparm->oem__oct = NULLQB;
+ if (t_test*t_test*t_test & 2)
+ Xparm->version = strb2bitstr(int2strb((1 << bit_T1_version_basic)
+ |(1 << bit_T1_version_patch1), 3),
+ 3, 0, 0);
+ else
+ Xparm->version = strb2bitstr(int2strb((1 << bit_T1_version_basic),
+ 3), 3, 0, 0);
+ break;
+#undef Xparm
+
+ case TY_MEMBER8:
+#define Xparm ((struct member_T1_8 *)parm)
+ if (t_test*t_test*t_test & 4)
+ Xparm->wine = int_T1_wine_burgundy;
+ else
+ Xparm->wine = int_T1_wine_claret;
+ if (t_test*t_test*t_test & 010)
+ Xparm->beer = int_T1_beer_vb;
+ else
+ Xparm->beer = int_T1_beer_hieneken;
+ if (t_test*t_test*t_test & 020)
+ Xparm->spirit = int_T1_spirit_vodka;
+ else
+ Xparm->spirit = int_T1_spirit_brandy;
+ break;
+#undef Xparm
+
+ case TY_STEST:
+#define Xparm ((struct type_T1_Stest *)parm)
+ if (t_test*(t_test + 2)*t_test & 4)
+ Xparm->st1 = (struct type_T1_Sint *)fill(TY_SINT);
+ else
+ Xparm->st1 = (struct type_T1_Sint *)NULL;
+ if (t_test*(t_test + 2)*t_test & 010)
+ Xparm->st2 = str2qb("goodbye, world", 14, 1);
+ else
+ Xparm->st2 = str2qb("xxxxxxx, world", 14, 1);
+ break;
+#undef Xparm
+
+ case TY_SINT:
+#define Xparm ((struct type_T1_Sint *)parm)
+ if (t_test*(t_test + 4)*t_test & 4)
+ Xparm->parm = 33;
+ else
+ Xparm->parm = 44;
+ break;
+#undef Xparm
+
+ case TY_ETYPE:
+#define Xparm ((struct type_T1_Enum__type *)parm)
+ switch (t_test & 3) {
+ case 0:
+ Xparm->parm = int_T1_Enum__type_pork;
+ break;
+
+ case 1:
+ Xparm->parm = int_T1_Enum__type_beef;
+ break;
+
+
+ case 2:
+ Xparm->parm = int_T1_Enum__type_chicken;
+ break;
+
+
+ case 3:
+ Xparm->parm = int_T1_Enum__type_lamb;
+ break;
+
+ default:
+ ferrd(1, "fill:ETYPE: Self consistency failure\n", t_test);
+ }
+ break;
+#undef Xparm
+
+ case TY_ENUM_TEST:
+#define Xparm ((struct type_T1_T__enum *)parm)
+ i = t_test;
+ Xparm->ae1 = (struct type_T1_Enum__type *)fill(TY_ETYPE);
+ t_test++;
+ Xparm->ae2 = (struct type_T1_Enum__type *)fill(TY_ETYPE);
+ t_test++;
+ Xparm->ae3 = (struct type_T1_Enum__type *)fill(TY_ETYPE);
+ t_test++;
+ if (t_test & 1)
+ Xparm->ae5 = (struct type_T1_Enum__type *)fill(TY_ETYPE);
+ Xparm->ae4 = (struct type_T1_Enum__type *)fill(TY_ETYPE);
+ t_test++;
+ if (t_test & 2)
+ Xparm->ae4->parm = int_T1_Enum__type_chicken; /* Default */
+ t_test = i;
+ break;
+#undef Xparm
+
+#ifdef PEPSY_REALS
+ case TY_REAL:
+#define Xparm ((struct type_T1_Real *)parm)
+ switch (t_test % 3) {
+ case 0:
+ Xparm->parm = -2.28789;
+ break;
+
+ case 1:
+ Xparm->parm = 927639.98009;
+ break;
+
+ case 2:
+ Xparm->parm = 0.0;
+ break;
+
+ default:
+ ferrd(1, "fill:TY_REAL:Internal error %d\n", t_test);
+ }
+ break;
+#undef Xparm
+
+ case TY_REAL_TEST:
+#define Xparm ((struct type_T1_T__real *)parm)
+ i = t_test;
+ Xparm->r1 = (struct type_T1_Real *) fill(TY_REAL);
+ t_test++;
+ Xparm->r2 = (struct type_T1_Real *) fill(TY_REAL);
+ t_test++;
+ Xparm->r3 = (struct type_T1_Real *) fill(TY_REAL);
+ t_test++;
+
+ Xparm->r4 = (struct type_T1_Real *) fill(TY_REAL);
+ t_test++;
+ if (i & 1) /* Default */
+ Xparm->r4->parm = 3.1415962;
+
+ if (i & 2) { /* Optional */
+ Xparm->r5 = (struct type_T1_Real *) fill(TY_REAL);
+ }
+ t_test = i;
+ break;
+#undef Xparm
+
+/* all strings have to be malloc'ed out ! */
+ case TY_OPTPEPY:
+ case TY_DEFPEPY:
+#define Xparm ((struct pepy_refs1 *)parm)
+ Xparm->t_int = 12354 + t_test;
+ Xparm->t_int1 = 12354 + t_test;
+ Xparm->t_enum = t_test + 1;
+ Xparm->t_enum1 = t_test + 1;
+ Xparm->t_qbuf = str2qb("Some is out there!", 18, 1);
+ Xparm->t_qbuf1 = str2qb("Some is out there!", 18, 1);
+ Xparm->t_string = strdup("hello, world\n");
+ Xparm->t_string1 = strdup("hello, world\n");
+ p = malloc(30);
+ bcopy("\0001234567890", p, 30);
+ Xparm->t_ostring = p;
+ Xparm->t_olen = t_test + 4;
+ p = malloc(30);
+ bcopy("\0001234567890", p, 30);
+ Xparm->t_ostring1 = p;
+ Xparm->t_olen1 = t_test + 4;
+ Xparm->t_bool = t_test % 2;
+ Xparm->t_bool1 = t_test % 2;
+ Xparm->t_real = sqrt(t_test * 3.1415962);
+ Xparm->t_real1 = sqrt(t_test * 3.1415962);
+ Xparm->t_oid = mkoid(t_test);
+ if (tynum != TY_OPTPEPY)
+ Xparm->t_oid1 = mkoid(t_test);
+ Xparm->t_pe = strb2bitstr("\0221\0327\052\211\0237\200", 41, 0, 0);
+ Xparm->t_pe1 = strb2bitstr("\0221\0327\052\211\0237\200", 41, 0, 0);
+ Xparm->t_any = mkpe(t_test*8 + 3);
+ p = malloc(30);
+ bcopy("\0001234567890", p, 30);
+ Xparm->t_bstring = p;
+ Xparm->t_blen = t_test*8 + 8;
+ break;
+#undef Xparm
+
+ case TY_PEPY:
+#define Xparm ((struct pepy_refs *)parm)
+ Xparm->t_int = 12354 + t_test;
+ Xparm->t_enum = t_test + 1;
+ Xparm->t_qbuf = str2qb("Some is out there!", 18, 1);
+ Xparm->t_string = strdup("hello, world\n");
+ p = malloc(30);
+ bcopy("\0001234567890", p, 30);
+ Xparm->t_ostring = p;
+ Xparm->t_olen = t_test + 4;
+ p = malloc(30);
+ bcopy("\0001234567890", p, 30);
+ Xparm->t_bstring = p;
+ Xparm->t_blen = t_test*8 + 4;
+ Xparm->t_bool = t_test % 2;
+ Xparm->t_real = sqrt(t_test * 3.1415962);
+ Xparm->t_oid = mkoid(t_test);
+ Xparm->t_pe = strb2bitstr("\0221\0327\052\011\0237\200", 41, 0, 0);
+ Xparm->t_any = mkpe(t_test*8 + 3);
+ Xparm->t_def = (struct pepy_refs1 *)fill(TY_DEFPEPY);
+ Xparm->t_opt = (struct pepy_refs1 *)fill(TY_OPTPEPY);
+ for (i = NUMOPT - 1; i >= 0; i--)
+ if ((t_test + i) % 2 == 1)
+ BITSET(Xparm->t_opt->opt_set, i);
+ else
+ BITCLR(Xparm->t_opt->opt_set, i);
+ break;
+#undef Xparm
+
+ case TY_S_COMPD:
+#define Xparm ((struct pepy_refs1 *)parm)
+ Xparm->t_int = 12354 + t_test;
+ Xparm->t_enum = t_test + 1;
+ Xparm->t_int1 = 12354 + t_test;
+ Xparm->t_enum1 = t_test + 1;
+ for (i = NUMOPT - 1; i >= 0; i--) {
+ if (i != OPT_INT1 && i != OPT_INT2
+ && i != OPT_ENUM1 && i != OPT_ENUM2)
+ continue;
+
+ if ((t_test + i) % 2 == 1)
+ BITSET(Xparm->opt_set, i);
+ else
+ BITCLR(Xparm->opt_set, i);
+ }
+ break;
+#undef Xparm
+
+#endif
+
+ case TY_ACTION:
+ case TY_REPEAT:
+#define Xparm ((struct repeats *)parm)
+ Xparm->rp_sq1 = mkrep_int(t_test - 1);
+ Xparm->rp_sq2 = mkrep_elem(t_test - 1);
+ Xparm->rp_st1 = mkrep_int(t_test - 1);
+ Xparm->rp_st2 = mkrep_elem(2*t_test - 1);
+ switch (t_test % 3) {
+ case 0:
+ Xparm->rp_choice = RP_INT;
+ Xparm->rp_int = t_test*t_test - 10;
+ break;
+
+ case 1:
+ Xparm->rp_choice = RP_BOOL;
+ Xparm->rp_bool = (t_test + 1) % 2;
+ break;
+
+ case 2:
+ Xparm->rp_choice = RP_OSTRING;
+ Xparm->rp_ostring = strdup("lets go home");
+ Xparm->rp_int = strlen(Xparm->rp_ostring);
+ break;
+
+ default:
+ ferrd(1, "fill:TY_REPEAT:Internal error %d\n", t_test);
+ }
+ break;
+#undef Xparm
+
+ case TY_VPDEFINED:
+#define Xparm ((struct pepy_refs *)parm)
+ Xparm->t_int = 9354 + t_test;
+ Xparm->t_enum = t_test + 1;
+ Xparm->t_qbuf = str2qb("Some one is out there!", 22, 1);
+ Xparm->t_string = strdup("hello there, world\n");
+ p = malloc(30);
+ bcopy("\0001234567890", p, 30);
+ Xparm->t_ostring = p;
+ Xparm->t_olen = t_test + 4;
+ p = malloc(30);
+ bcopy("\0001234567890", p, 30);
+ Xparm->t_bstring = p;
+ Xparm->t_blen = t_test*8 + 4;
+ Xparm->t_pe = strb2bitstr("\0221\0327\052\211\0237\200", t_test + 33, 0, 0);
+ Xparm->t_bool = t_test % 2;
+ Xparm->t_real = sqrt((float )t_test);
+ Xparm->t_oid = mkoid(t_test);
+ Xparm->t_any = mkpe(t_test*7 + 3);
+ break;
+#undef Xparm
+
+ case TY_FUNC:
+#define Xparm ((struct codedata *)parm)
+ Xparm->cd_a = mkpe(t_test + 2);
+ Xparm->cd_b = mkpe(t_test + 3);
+ Xparm->cd_c = mkpe(t_test + 5);
+ Xparm->cd_d = mkpe(t_test + 7);
+ Xparm->cd_int = t_test - 1;
+ if (t_test % 2)
+ Xparm->cd_string = strdup("hello there, world\n");
+ else
+ Xparm->cd_string = strdup("hello world\n");
+ for (i = NCD_OPT - 1; i >= 0; i--) {
+ if ((t_test + i) % 2 == 1)
+ BITSET(Xparm->cd_opt_set, i);
+ else
+ BITCLR(Xparm->cd_opt_set, i);
+ }
+ Xparm->cd_left = (struct codedata *)fill(TY_OPTFUNC);
+ Xparm->cd_right = (struct codedata *)fill(TY_DFTFUNC);
+ break;
+#undef Xparm
+
+ case TY_OPTFUNC:
+#define Xparm ((struct codedata *)parm)
+ if ((t_test + 2) % 3)
+ Xparm->cd_a = mkpe(t_test + 2);
+ if ((t_test + 1) % 3)
+ Xparm->cd_b = mkpe(t_test + 3);
+ Xparm->cd_c = mkpe(t_test + 5);
+ Xparm->cd_d = mkpe(t_test + 7);
+ Xparm->cd_int = t_test - 1;
+ if (t_test % 2)
+ Xparm->cd_string = strdup("hello there, world\n");
+ else
+ Xparm->cd_string = NULLCP;
+ for (i = NCD_OPT - 1; i >= 0; i--) {
+ if ((t_test + i) % 2 == 1)
+ BITSET(Xparm->cd_opt_set, i);
+ else
+ BITCLR(Xparm->cd_opt_set, i);
+ }
+ break;
+#undef Xparm
+
+ case TY_DFTFUNC:
+#define Xparm ((struct codedata *)parm)
+ if ((t_test + 2) % 3)
+ Xparm->cd_a = mkpe(t_test*2 + 1);
+ if ((t_test + 1) % 3)
+ Xparm->cd_b = mkpe(t_test*2 + 2);
+ Xparm->cd_c = mkpe(t_test*2 + 3);
+ Xparm->cd_d = mkpe(t_test*2 + 4);
+ Xparm->cd_int = t_test - 2;
+ if (t_test % 2)
+ Xparm->cd_string = strdup("hello there, world\n");
+ else
+ Xparm->cd_string = strdup("Some is out");
+ for (i = NCD_OPT - 1; i >= 0; i--) {
+ if ((t_test + i) % 2 == 1)
+ BITSET(Xparm->cd_opt_set, i);
+ else
+ BITCLR(Xparm->cd_opt_set, i);
+ }
+ break;
+#undef Xparm
+
+#ifdef PEPSY_REALS
+ case TY_ASIMPLE:
+#define Xparm ((struct codedata *)parm)
+ Xparm->cd_a = mkpe(t_test + 2);
+ Xparm->cd_int = 2*t_test - 1;
+ Xparm->cd_int1 = 2*t_test - 1;
+ Xparm->cd_int2 = 2*t_test - 1;
+ if (t_test % 2)
+ Xparm->cd_string = strdup("hello there, world\n");
+ else
+ Xparm->cd_string = strdup("hello world\n");
+ Xparm->cd_string1 = strdup("hello world\n");
+ Xparm->cd_string2 = strdup("hello world\n");
+ Xparm->cd_bool = t_test % 2;
+ Xparm->cd_real = t_test * 3.1415962;
+ Xparm->cd_oid = mkoid(t_test*2);
+ Xparm->cd_oid1 = mkoid(t_test*2);
+ Xparm->cd_oid2 = mkoid(t_test*2);
+ Xparm->cd_bit = strb2bitstr("\0221\0327\052\211\0237\200", t_test + 30,
+ 0, 0);
+ Xparm->cd_right = (struct codedata *)fill(TY_DFTFUNC);
+ break;
+#undef Xparm
+#endif
+
+ default:
+ ferrd(1, "fill:unknown type %d\n", tynum);
+ }
+
+ return (parm);
+}
+
+/*
+ * compare two structures for differences of fields indicating an
+ * error
+ */
+tcmp(tynum, parm1, parm2)
+int tynum;
+char *parm1, *parm2;
+{
+ int d;
+ int i;
+
+ d = 0;
+
+ switch (tynum) {
+ case TY_MPDU:
+#define Xparm1 ((struct type_T1_MPDU *)parm1)
+#define Xparm2 ((struct type_T1_MPDU *)parm2)
+ if (Xparm1->a__seq && !Xparm2->a__seq
+ || !Xparm1->a__seq && Xparm2->a__seq) {
+ (void) printf("a__seq missing/present\n");
+ d++;
+ }
+ if (Xparm1->a__seq && Xparm2->a__seq) {
+ if (Xparm1->a__seq->fred != Xparm2->a__seq->fred) {
+ (void) printf("%s->a__seq->fred %d != %d\n",
+ Xparm1->a__seq->fred, Xparm2->a__seq->fred);
+ d++;
+ }
+ if (Xparm1->a__seq->george != Xparm2->a__seq->george) {
+ (void) printf("%s a__seq->george %d != %d\n", t_case[tynum].tst_name,
+ Xparm1->a__seq->george, Xparm2->a__seq->george);
+ d++;
+ }
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_EMBEDDED:
+#define Xparm1 ((struct type_T1_Embedded *)parm1)
+#define Xparm2 ((struct type_T1_Embedded *)parm2)
+ if (Xparm1->anMPDU && !Xparm2->anMPDU ||!Xparm1->anMPDU && Xparm2->anMPDU) {
+ (void) printf("anMPDU missing/present\n");
+ d++;
+ }
+ if (Xparm1->anMPDU && Xparm2->anMPDU) {
+ d += tcmp(TY_MPDU, (char *)Xparm1->anMPDU, (char *)Xparm2->anMPDU);
+ }
+ if (Xparm1->ei != Xparm2->ei) {
+ (void) printf("%s ei %d != %d\n",
+ t_case[tynum].tst_name, Xparm1->ei, Xparm2->ei);
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_STRINGS:
+#define Xparm1 ((struct type_T1_Strings *)parm1)
+#define Xparm2 ((struct type_T1_Strings *)parm2)
+ if (qb_cmp(Xparm1->ostring, Xparm2->ostring)) {
+ (void) printf("ostring octet string different\n");
+ d++;
+ }
+ if (bit_cmp(Xparm1->bstring, Xparm2->bstring)) {
+ (void) printf("bstring bitstring different\n");
+ d++;
+ }
+ if (qb_cmp(Xparm1->nstring, Xparm2->nstring)) {
+ (void) printf("nstring octet string different\n");
+ d++;
+ }
+ if (qb_cmp(Xparm1->pstring, Xparm2->pstring)) {
+ (void) printf("pstring octet string different\n");
+ d++;
+ }
+ if (qb_cmp(Xparm1->tstring, Xparm2->tstring)) {
+ (void) printf("tstring octet string different\n");
+ d++;
+ }
+ if (qb_cmp(Xparm1->t61string, Xparm2->t61string)) {
+ (void) printf("t61string octet string different\n");
+ d++;
+ }
+ if (qb_cmp(Xparm1->vstring, Xparm2->vstring)) {
+ (void) printf("vstring octet string different\n");
+ d++;
+ }
+ if (qb_cmp(Xparm1->vis__string, Xparm2->vis__string)) {
+ (void) printf("vis__string octet string different\n");
+ d++;
+ }
+ if (qb_cmp(Xparm1->i646string, Xparm2->i646string)) {
+ (void) printf("i646string octet string different\n");
+ d++;
+ }
+ if (qb_cmp(Xparm1->ia5string, Xparm2->ia5string)) {
+ (void) printf("ia5string octet string different\n");
+ d++;
+ }
+ if (qb_cmp(Xparm1->graphstring, Xparm2->graphstring)) {
+ (void) printf("graphstring octet string different\n");
+ d++;
+ }
+ if (qb_cmp(Xparm1->genstring, Xparm2->genstring)) {
+ (void) printf("genstring octet string different\n");
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_EMB_STRINGS:
+#define Xparm1 ((struct type_T1_Emb__Strings *)parm1)
+#define Xparm2 ((struct type_T1_Emb__Strings *)parm2)
+ if (qb_cmp(Xparm1->btest, Xparm2->btest)) {
+ (void) printf("btest octet string different\n");
+ d++;
+ }
+ if (bit_cmp(Xparm1->ctest, Xparm2->ctest)) {
+ (void) printf("ctest bitstring different\n");
+ d++;
+ }
+ if (Xparm1->atest != Xparm2->atest) {
+ (void) printf("atest integers different\n");
+ d++;
+ }
+ if (Xparm1->big__test && Xparm2->big__test) {
+ d += tcmp(TY_STRINGS, (char *)Xparm1->big__test, (char *)Xparm2->big__test);
+ } else if (Xparm1->big__test || Xparm2->big__test) {
+ (void) printf("big__test one Strings missing!\n");
+ d++;
+ }
+ if (qb_cmp(Xparm1->emb__test->em__oct, Xparm2->emb__test->em__oct)) {
+ (void) printf("emb__test->em__oct octet string different\n");
+ d++;
+ }
+ if (bit_cmp(Xparm1->emb__test->em__bit, Xparm2->emb__test->em__bit)) {
+ (void) printf("emb__test->em__bit bitstring different\n");
+ d++;
+ }
+ if (Xparm1->emb__test->em__int != Xparm2->emb__test->em__int) {
+ (void) printf("emb__test->em__int integers different\n");
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_IMPLICIT:
+#define Xparm1 ((struct type_T1_Impl__Tags *)parm1)
+#define Xparm2 ((struct type_T1_Impl__Tags *)parm2)
+ if (qb_cmp(Xparm1->o__impl, Xparm2->o__impl)) {
+ (void) printf("o__impl octet string different\n");
+ d++;
+ }
+ if (bit_cmp(Xparm1->b__impl, Xparm2->b__impl)) {
+ (void) printf("b__impl bitstring different\n");
+ d++;
+ }
+ if (Xparm1->i__impl != Xparm2->i__impl) {
+ (void) printf("i__impl integers different\n");
+ d++;
+ }
+ if (Xparm1->obj__impl && Xparm2->obj__impl) {
+ d += tcmp(TY_EMB_STRINGS, (char *)Xparm1->obj__impl, (char *)Xparm2->obj__impl);
+ } else if (Xparm1->obj__impl || Xparm2->obj__impl) {
+ (void) printf("obj__impl one Embedded Strings missing!\n");
+ d++;
+ }
+ if (qb_cmp(Xparm1->i__emb__test->i__em__oct, Xparm2->i__emb__test->i__em__oct)) {
+ (void) printf("i__emb__test->i__em__oct octet string different\n");
+ d++;
+ }
+ if (bit_cmp(Xparm1->i__emb__test->i__em__bit, Xparm2->i__emb__test->i__em__bit)) {
+ (void) printf("i__emb__test->i__em__bit bitstring different\n");
+ d++;
+ }
+ if (Xparm1->i__emb__test->i__em__int != Xparm2->i__emb__test->i__em__int) {
+ (void) printf("i__emb__test->i__em__int integers different\n");
+ d++;
+ }
+#undef Xparm1
+#undef Xparm2
+ break;
+
+ case TY_EXPLICIT:
+#define Xparm1 ((struct type_T1_Expl__Tags *)parm1)
+#define Xparm2 ((struct type_T1_Expl__Tags *)parm2)
+ if (qb_cmp(Xparm1->o__expl, Xparm2->o__expl)) {
+ (void) printf("o__expl octet string different\n");
+ d++;
+ }
+ if (bit_cmp(Xparm1->b__expl, Xparm2->b__expl)) {
+ (void) printf("b__expl bitstring different\n");
+ d++;
+ }
+ if (Xparm1->i__expl != Xparm2->i__expl) {
+ (void) printf("i__expl integers different\n");
+ d++;
+ }
+ if (Xparm1->obj__expl && Xparm2->obj__expl) {
+ d += tcmp(TY_EMB_STRINGS, (char *)Xparm1->obj__expl, (char *)Xparm2->obj__expl);
+ } else if (Xparm1->obj__expl || Xparm2->obj__expl) {
+ (void) printf("obj__expl one Embedded Strings missing!\n");
+ d++;
+ }
+ if (qb_cmp(Xparm1->i__exp__test->i__ex__oct, Xparm2->i__exp__test->i__ex__oct)) {
+ (void) printf("i__exp__test->i__ex__oct octet string different\n");
+ d++;
+ }
+ if (bit_cmp(Xparm1->i__exp__test->i__ex__bit, Xparm2->i__exp__test->i__ex__bit)) {
+ (void) printf("i__exp__test->i__ex__bit bitstring different\n");
+ d++;
+ }
+ if (Xparm1->i__exp__test->i__ex__int != Xparm2->i__exp__test->i__ex__int) {
+ (void) printf("i__exp__test->i__ex__int integers different\n");
+ d++;
+ }
+#undef Xparm1
+#undef Xparm2
+ break;
+
+
+ case TY_SEQOF:
+#define Xparm1 ((struct type_T1_Seqof__Test *)parm1)
+#define Xparm2 ((struct type_T1_Seqof__Test *)parm2)
+ if (Xparm1->sqof__test1 && Xparm2->sqof__test1) {
+ d += tcmp(TY_ELEMENT4, (char *)Xparm1->sqof__test1, (char *)Xparm2->sqof__test1);
+ } else if (Xparm1->sqof__test1 || Xparm2->sqof__test1) {
+ (void) printf("sqof__test1 one missing");
+ d++;
+ }
+ if (Xparm1->stof__test1 && Xparm2->stof__test1) {
+ d += tcmp(TY_MEMBER2, (char *)Xparm1->stof__test1, (char *)Xparm2->stof__test1);
+ } else if (Xparm1->stof__test1 || Xparm2->stof__test1) {
+ (void) printf("stof__test1 one missing");
+ d++;
+ }
+ if (Xparm1->i__test1 != Xparm2->i__test1) {
+ (void) printf("i__test1 integers different\n");
+ d++;
+ }
+ if (Xparm1->sqof__test2 && Xparm2->sqof__test2) {
+ d += tcmp(TY_ELEMENT6, (char *)Xparm1->sqof__test2, (char *)Xparm2->sqof__test2);
+ } else if (Xparm1->sqof__test2 || Xparm2->sqof__test2) {
+ (void) printf("sqof__test2 one missing");
+ d++;
+ }
+ if (Xparm1->stof__test2 && Xparm2->stof__test2) {
+ d += tcmp(TY_MEMBER4, (char *)Xparm1->stof__test2, (char *)Xparm2->stof__test2);
+ } else if (Xparm1->stof__test2 || Xparm2->stof__test2) {
+ (void) printf("stof__test2 one missing");
+ d++;
+ }
+ if (Xparm1->i__test2 != Xparm2->i__test2) {
+ (void) printf("i__test2 integers different\n");
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_ELEMENT4:
+#define Xparm1 ((struct element_T1_4 *)parm1)
+#define Xparm2 ((struct element_T1_4 *)parm2)
+ if (Xparm1->element_T1_5 && Xparm2->element_T1_5) {
+ d += tcmp(TY_EXPLICIT, (char *)Xparm1->element_T1_5, (char *)Xparm2->element_T1_5);
+ } else if (Xparm1->element_T1_5 || Xparm2->element_T1_5) {
+ (void) printf("element_T1_5 one missing");
+ d++;
+ }
+ if (Xparm1->next && Xparm2->next) {
+ d += tcmp(TY_ELEMENT4, (char *)Xparm1->next, (char *)Xparm2->next);
+ } else if (Xparm1->next || Xparm2->next) {
+ (void) printf("%s: next one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_MEMBER2:
+#define Xparm1 ((struct member_T1_2 *)parm1)
+#define Xparm2 ((struct member_T1_2 *)parm2)
+ if (Xparm1->member_T1_3 && Xparm2->member_T1_3) {
+ d += tcmp(TY_EXPLICIT, (char *)Xparm1->member_T1_3, (char *)Xparm2->member_T1_3);
+ } else if (Xparm1->member_T1_3 || Xparm2->member_T1_3) {
+ (void) printf("%s: member_T1_3 one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->next && Xparm2->next) {
+ d += tcmp(TY_MEMBER2, (char *)Xparm1->next, (char *)Xparm2->next);
+ } else if (Xparm1->next || Xparm2->next) {
+ (void) printf("%s: next one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_ELEMENT6:
+#define Xparm1 ((struct element_T1_6 *)parm1)
+#define Xparm2 ((struct element_T1_6 *)parm2)
+ if (Xparm1->element_T1_7 && Xparm2->element_T1_7) {
+ d += tcmp(TY_ELEMENT8, (char *)Xparm1->element_T1_7, (char *)Xparm2->element_T1_7);
+ } else if (Xparm1->element_T1_7 || Xparm2->element_T1_7) {
+ (void) printf("%s: element_T1_7 one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->next && Xparm2->next) {
+ d += tcmp(TY_ELEMENT6, (char *)Xparm1->next, (char *)Xparm2->next);
+ } else if (Xparm1->next || Xparm2->next) {
+ (void) printf("%s: next one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_ELEMENT8:
+#define Xparm1 ((struct element_T1_8 *)parm1)
+#define Xparm2 ((struct element_T1_8 *)parm2)
+ if (Xparm1->sqof__in && Xparm2->sqof__in) {
+ d += tcmp(TY_EXPLICIT, (char *)Xparm1->sqof__in, (char *)Xparm2->sqof__in);
+ } else if (Xparm1->sqof__in || Xparm2->sqof__in) {
+ (void) printf("%s: sqof__in one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->sqof__i != Xparm2->sqof__i) {
+ (void) printf("sqof__i integers different\n");
+ d++;
+ }
+ if (qb_cmp(Xparm1->sqof__o, Xparm2->sqof__o)) {
+ (void) printf("sqof__o octet string different\n");
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_MEMBER4:
+#define Xparm1 ((struct member_T1_4 *)parm1)
+#define Xparm2 ((struct member_T1_4 *)parm2)
+ if (Xparm1->member_T1_5 && Xparm2->member_T1_5) {
+ d += tcmp(TY_ELEMENT9, (char *)Xparm1->member_T1_5, (char *)Xparm2->member_T1_5);
+ } else if (Xparm1->member_T1_5 || Xparm2->member_T1_5) {
+ (void) printf("%s: member_T1_5 one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->next && Xparm2->next) {
+ d += tcmp(TY_MEMBER4, (char *)Xparm1->next, (char *)Xparm2->next);
+ } else if (Xparm1->next || Xparm2->next) {
+ (void) printf("%s: next one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_ELEMENT9:
+#define Xparm1 ((struct element_T1_9 *)parm1)
+#define Xparm2 ((struct element_T1_9 *)parm2)
+ if (Xparm1->stof__in && Xparm2->stof__in) {
+ d += tcmp(TY_EXPLICIT, (char *)Xparm1->stof__in, (char *)Xparm2->stof__in);
+ } else if (Xparm1->stof__in || Xparm2->stof__in) {
+ (void) printf("%s: stof__in one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->stof__i != Xparm2->stof__i) {
+ (void) printf("stof__i integers different\n");
+ d++;
+ }
+ if (qb_cmp(Xparm1->stof__o, Xparm2->stof__o)) {
+ (void) printf("stof__o octet string different\n");
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_CHOICE:
+#define Xparm1 ((struct type_T1_Choice__Test *)parm1)
+#define Xparm2 ((struct type_T1_Choice__Test *)parm2)
+ if (Xparm1->c1 && Xparm2->c1) {
+ d += tcmp(TY_CHOICE0, (char *)Xparm1->c1, (char *)Xparm2->c1);
+ } else if (Xparm1->c1 || Xparm2->c1) {
+ (void) printf("%s: c1 one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->c2 && Xparm2->c2) {
+ d += tcmp(TY_CHOICE1, (char *)Xparm1->c2, (char *)Xparm2->c2);
+ } else if (Xparm1->c2 || Xparm2->c2) {
+ (void) printf("%s: c2 one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->c3 && Xparm2->c3) {
+ d += tcmp(TY_CHOICE2, (char *)Xparm1->c3, (char *)Xparm2->c3);
+ } else if (Xparm1->c3 || Xparm2->c3) {
+ (void) printf("%s: c3 one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->c4 && Xparm2->c4) {
+ d += tcmp(TY_ELEMENT11, (char *)Xparm1->c4, (char *)Xparm2->c4);
+ } else if (Xparm1->c4 || Xparm2->c4) {
+ (void) printf("%s: c4 one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_CHOICE0:
+#define Xparm1 ((struct choice_T1_0 *)parm1)
+#define Xparm2 ((struct choice_T1_0 *)parm2)
+ if (Xparm1->offset != Xparm2->offset) {
+ d++;
+ (void) printf("%s: offset mismatch %d != %d\n", t_case[tynum].tst_name,
+ Xparm1->offset, Xparm2->offset);
+ break;
+ }
+ switch (Xparm1->offset) {
+ case choice_T1_0_i__c1:
+ if (Xparm1->un.i__c1 != Xparm2->un.i__c1) {
+ d++;
+ (void) printf("%s: i__c1 mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->un.i__c1, Xparm2->un.i__c1);
+ }
+ break;
+
+ case choice_T1_0_o__c1:
+ if (qb_cmp(Xparm1->un.o__c1, Xparm2->un.o__c1)) {
+ (void) printf("o__c1 octet string different\n");
+ d++;
+ }
+ break;
+
+ case choice_T1_0_b__c1:
+ if (bit_cmp(Xparm1->un.b__c1, Xparm2->un.b__c1)) {
+ (void) printf("un.b__c1 bitstring different\n");
+ d++;
+ }
+ break;
+
+ case choice_T1_0_f__c1:
+ if (Xparm1->un.f__c1 && !Xparm2->un.f__c1
+ || !Xparm1->un.f__c1 && Xparm2->un.f__c1) {
+ (void) printf("f__c1 Boolean different\n");
+ d++;
+ }
+ break;
+
+ case choice_T1_0_obj__c1:
+ if (Xparm1->un.obj__c1 && Xparm2->un.obj__c1) {
+ d += tcmp(TY_EMB_STRINGS, (char *)Xparm1->un.obj__c1,
+ (char *)Xparm2->un.obj__c1);
+ } else if (Xparm1->un.obj__c1 || Xparm2->un.obj__c1) {
+ (void) printf("%s: un.obj__c1 one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ break;
+
+ default:
+ ferrd(1, "TY_CHOICE0:illegal offset %d\n", Xparm1->offset);
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_CHOICE1:
+#define Xparm1 ((struct choice_T1_1 *)parm1)
+#define Xparm2 ((struct choice_T1_1 *)parm2)
+
+ if (Xparm1->offset != Xparm2->offset) {
+ d++;
+ (void) printf("%s: offset mismatch %d != %d\n", t_case[tynum].tst_name,
+ Xparm1->offset, Xparm2->offset);
+ break;
+ }
+ switch (Xparm1->offset) {
+ case choice_T1_1_i__c2:
+ if (Xparm1->un.i__c2 != Xparm2->un.i__c2) {
+ d++;
+ (void) printf("%s: i__c2 mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->un.i__c2, Xparm2->un.i__c2);
+ }
+ break;
+
+ case choice_T1_1_o__c2:
+ if (qb_cmp(Xparm1->un.o__c2, Xparm2->un.o__c2)) {
+ (void) printf("o__c2 octet string different\n");
+ d++;
+ }
+ break;
+
+ case choice_T1_1_b__c2:
+ if (bit_cmp(Xparm1->un.b__c2, Xparm2->un.b__c2)) {
+ (void) printf("un.b__c2 bitstring different\n");
+ d++;
+ }
+ break;
+
+ case choice_T1_1_f__c2:
+ if (Xparm1->un.f__c2 && !Xparm2->un.f__c2
+ || !Xparm1->un.f__c2 && Xparm2->un.f__c2) {
+ d++;
+ (void) printf("%s: f__c2 mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->un.f__c2, Xparm2->un.f__c2);
+ }
+ break;
+
+ case choice_T1_1_obj__c2:
+ if (Xparm1->un.obj__c2 && Xparm2->un.obj__c2) {
+ d += tcmp(TY_EMB_STRINGS, (char *)Xparm1->un.obj__c2,
+ (char *)Xparm2->un.obj__c2);
+ } else if (Xparm1->un.obj__c2 || Xparm2->un.obj__c2) {
+ (void) printf("%s: un.obj__c2 one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ break;
+
+ default:
+ ferrd(1, "TY_CHOICE1:illegal offset %d\n", Xparm1->offset);
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_CHOICE2:
+#define Xparm1 ((struct choice_T1_2 *)parm1)
+#define Xparm2 ((struct choice_T1_2 *)parm2)
+
+ switch (Xparm1->offset) {
+ case choice_T1_2_i__c3:
+ if (Xparm1->un.i__c3 != Xparm2->un.i__c3) {
+ d++;
+ (void) printf("%s: i__c3 mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->un.i__c3, Xparm2->un.i__c3);
+ }
+ break;
+
+ case choice_T1_2_seq__c3:
+ if (Xparm1->un.seq__c3 && Xparm2->un.seq__c3) {
+ d += tcmp(TY_ELEMENT10, (char *)Xparm1->un.seq__c3, (char *)Xparm2->un.seq__c3);
+ } else if (Xparm1->un.seq__c3 || Xparm2->un.seq__c3) {
+ (void) printf("%s: un.seq__c3 one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ break;
+
+ case choice_T1_2_set__c3:
+ if (Xparm1->un.set__c3 && Xparm2->un.set__c3) {
+ d += tcmp(TY_MEMBER6, (char *)Xparm1->un.set__c3, (char *)Xparm2->un.set__c3);
+ } else if (Xparm1->un.set__c3 || Xparm2->un.set__c3) {
+ (void) printf("%s: un.set__c3 one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ break;
+
+ default:
+ ferrd(1, "TY_CHOICE2:illegal offset %d\n", Xparm1->offset);
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_CHOICE3:
+#define Xparm1 ((struct choice_T1_3 *)parm1)
+#define Xparm2 ((struct choice_T1_3 *)parm2)
+
+ switch (Xparm1->offset) {
+ case choice_T1_3_sc__a__i:
+ if (Xparm1->un.sc__a__i != Xparm2->un.sc__a__i) {
+ d++;
+ (void) printf("%s: sc__a__i mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->un.sc__a__i, Xparm2->un.sc__a__i);
+ }
+ break;
+
+ case choice_T1_3_sc__b__i:
+ if (Xparm1->un.sc__b__i != Xparm2->un.sc__b__i) {
+ d++;
+ (void) printf("%s: sc__b__i mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->un.sc__b__i, Xparm2->un.sc__b__i);
+ }
+ break;
+
+ case choice_T1_3_c4__i:
+ if (Xparm1->un.c4__i != Xparm2->un.c4__i) {
+ d++;
+ (void) printf("%s: c4__i mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->un.c4__i, Xparm2->un.c4__i);
+ }
+ break;
+
+ case choice_T1_3_c4__obj:
+ if (Xparm1->un.c4__obj && Xparm2->un.c4__obj) {
+ d += tcmp(TY_EXPLICIT, (char *)Xparm1->un.c4__obj, (char *)Xparm2->un.c4__obj);
+ } else if (Xparm1->un.c4__obj || Xparm2->un.c4__obj) {
+ (void) printf("%s: un.c4__obj one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ break;
+
+ default:
+ ferrd(1, "TY_CHOICE3:illegal offset %d\n", Xparm1->offset);
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_ELEMENT10:
+#define Xparm1 ((struct element_T1_10 *)parm1)
+#define Xparm2 ((struct element_T1_10 *)parm2)
+ if (Xparm1->seq__c3__in && Xparm2->seq__c3__in) {
+ d += tcmp(TY_EXPLICIT, (char *)Xparm1->seq__c3__in, (char *)Xparm2->seq__c3__in);
+ } else if (Xparm1->seq__c3__in || Xparm2->seq__c3__in) {
+ (void) printf("%s: seq__c3__in one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->seq__c3__i != Xparm2->seq__c3__i) {
+ d++;
+ (void) printf("%s: seq__c3__i mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->seq__c3__i, Xparm2->seq__c3__i);
+ }
+ if (qb_cmp(Xparm1->seq__c3__o, Xparm2->seq__c3__o)) {
+ (void) printf("seq__c3__o octet string different\n");
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_MEMBER6:
+#define Xparm1 ((struct member_T1_6 *)parm1)
+#define Xparm2 ((struct member_T1_6 *)parm2)
+ if (Xparm1->set__c3__in && Xparm2->set__c3__in) {
+ d += tcmp(TY_EXPLICIT, (char *)Xparm1->set__c3__in, (char *)Xparm2->set__c3__in);
+ } else if (Xparm1->set__c3__in || Xparm2->set__c3__in) {
+ (void) printf("%s: set__c3__in one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->set__c3__i != Xparm2->set__c3__i) {
+ d++;
+ (void) printf("%s: set__c3__i mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->set__c3__i, Xparm2->set__c3__i);
+ }
+ if (qb_cmp(Xparm1->set__c3__o, Xparm2->set__c3__o)) {
+ (void) printf("set__c3__o octet string different\n");
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_ELEMENT11:
+#define Xparm1 ((struct element_T1_11 *)parm1)
+#define Xparm2 ((struct element_T1_11 *)parm2)
+ if (Xparm1->c4__choice && Xparm2->c4__choice) {
+ d += tcmp(TY_CHOICE3, (char *)Xparm1->c4__choice, (char *)Xparm2->c4__choice);
+ } else if (Xparm1->c4__choice || Xparm2->c4__choice) {
+ (void) printf("%s: c4__choice one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_OPTIONAL:
+#define Xparm1 ((struct type_T1_Opt__Strings *)parm1)
+#define Xparm2 ((struct type_T1_Opt__Strings *)parm2)
+ if (Xparm1->optionals & opt_T1_Opt__Strings_a__opt) {
+ if (Xparm1->a__opt != Xparm2->a__opt) {
+ d++;
+ (void) printf("%s: a__opt mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->a__opt, Xparm2->a__opt);
+ }
+ }
+ if (Xparm1->optionals & opt_T1_Opt__Strings_d__opt) {
+ if (Xparm1->d__opt && !Xparm2->d__opt
+ || !Xparm1->d__opt && Xparm2->d__opt) {
+ d++;
+ (void) printf("%s: d__opt mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->d__opt, Xparm2->d__opt);
+ }
+ }
+ if (Xparm1->b__opt != NULLQB && Xparm2->b__opt != NULLQB) {
+ if (qb_cmp(Xparm1->b__opt, Xparm2->b__opt)) {
+ (void) printf("b__opt octet string different\n");
+ d++;
+ }
+ }
+ if (Xparm1->b__opt != NULLQB && Xparm2->b__opt == NULLQB
+ || Xparm1->b__opt == NULLQB && Xparm2->b__opt != NULLQB) {
+ (void) printf("%s: b__opt one missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->c__opt != NULLPE && Xparm2->c__opt != NULLPE) {
+ if (bit_cmp(Xparm1->c__opt, Xparm2->c__opt)) {
+ (void) printf("%s:c__opt bitstring different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ }
+ if (Xparm1->optionals & opt_T1_Opt__Strings_e__opt) {
+ if (Xparm1->e__opt && !Xparm2->e__opt
+ || !Xparm1->e__opt && Xparm2->e__opt) {
+ d++;
+ (void) printf("%s: e__opt mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->e__opt, Xparm2->e__opt);
+ }
+ }
+ if (Xparm1->big__opt && Xparm2->big__opt) {
+ d += tcmp(TY_STRINGS, (char *)Xparm1->big__opt,
+ (char *)Xparm2->big__opt);
+ } else if (Xparm1->big__opt && !Xparm2->big__opt
+ || !Xparm1->big__opt && Xparm2->big__opt) {
+ (void) printf("%s: big__opt one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->emb__opt && Xparm2->emb__opt) {
+ d += tcmp(TY_ELEMENT12, (char *)Xparm1->emb__opt,
+ (char *)Xparm2->emb__opt);
+ } else if (Xparm1->emb__opt && !Xparm2->emb__opt
+ || !Xparm1->emb__opt && Xparm2->emb__opt) {
+ (void) printf("%s: emb__opt one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->st__opt && Xparm2->st__opt) {
+ d += tcmp(TY_MEMBER7, (char *)Xparm1->st__opt,
+ (char *)Xparm2->st__opt);
+ } else if (Xparm1->st__opt && !Xparm2->st__opt
+ || !Xparm1->st__opt && Xparm2->st__opt) {
+ (void) printf("%s: st__opt one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->obj__opt && Xparm2->obj__opt) {
+ d += tcmp(TY_MPDU, (char *)Xparm1->obj__opt,
+ (char *)Xparm2->obj__opt);
+ } else if (Xparm1->obj__opt && !Xparm2->obj__opt
+ || !Xparm1->obj__opt && Xparm2->obj__opt) {
+ (void) printf("%s: obj__opt one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->optionals & opt_T1_Opt__Strings_etag__opt) {
+ if (Xparm1->etag__opt != Xparm2->etag__opt) {
+ d++;
+ (void) printf("%s: etag__opt mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->etag__opt, Xparm2->etag__opt);
+ }
+ }
+ if (Xparm1->ch__opt && Xparm2->ch__opt) {
+ d += tcmp(TY_CHOICE4, (char *)Xparm1->ch__opt,
+ (char *)Xparm2->ch__opt);
+ } else if (Xparm1->ch__opt && !Xparm2->ch__opt
+ || !Xparm1->ch__opt && Xparm2->ch__opt) {
+ (void) printf("%s: ch__opt one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_ELEMENT12:
+#define Xparm1 ((struct element_T1_12 *)parm1)
+#define Xparm2 ((struct element_T1_12 *)parm2)
+ if (Xparm1->optionals & opt_T1_element_T1_12_oem__int) {
+ if (Xparm1->oem__int != Xparm2->oem__int) {
+ d++;
+ (void) printf("%s: oem__int mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->oem__int, Xparm2->oem__int);
+ }
+ }
+ if (Xparm1->oem__oct != NULLQB && Xparm2->oem__oct != NULLQB) {
+ if (qb_cmp(Xparm1->oem__oct, Xparm2->oem__oct)) {
+ (void) printf("oem__oct octet string different\n");
+ d++;
+ }
+ }
+ if (Xparm1->oem__oct != NULLQB && Xparm2->oem__oct == NULLQB
+ || Xparm1->oem__oct == NULLQB && Xparm2->oem__oct != NULLQB) {
+ (void) printf("%s: oem__oct one missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->oem__bit != NULLPE && Xparm2->oem__bit != NULLPE) {
+ if (bit_cmp(Xparm1->oem__bit, Xparm2->oem__bit)) {
+ (void) printf("%s:oem__bit bitstring different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_MEMBER7:
+#define Xparm1 ((struct member_T1_7 *)parm1)
+#define Xparm2 ((struct member_T1_7 *)parm2)
+ if (Xparm1->optionals & opt_T1_member_T1_7_st__int0) {
+ if (Xparm1->st__int0 != Xparm2->st__int0) {
+ d++;
+ (void) printf("%s: st__int0 mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->st__int0, Xparm2->st__int0);
+ }
+ }
+ if (Xparm1->optionals & opt_T1_member_T1_7_st__int1) {
+ if (Xparm1->st__int1 != Xparm2->st__int1) {
+ d++;
+ (void) printf("%s: st__int1 mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->st__int1, Xparm2->st__int1);
+ }
+ }
+ if (Xparm1->optionals & opt_T1_member_T1_7_st__int2) {
+ if (Xparm1->st__int2 != Xparm2->st__int2) {
+ d++;
+ (void) printf("%s: st__int2 mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->st__int2, Xparm2->st__int2);
+ }
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_CHOICE4:
+#define Xparm1 ((struct choice_T1_4 *)parm1)
+#define Xparm2 ((struct choice_T1_4 *)parm2)
+ if (Xparm1->offset != Xparm2->offset) {
+ d++;
+ (void) printf("%s: offset mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->offset, Xparm2->offset);
+ break;
+ }
+ switch (Xparm1->offset) {
+ case choice_T1_4_ch__1:
+ if (Xparm1->un.ch__1 != Xparm2->un.ch__1) {
+ d++;
+ (void) printf("%s: ch__1 mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->un.ch__1, Xparm2->un.ch__1);
+ }
+ break;
+
+ case choice_T1_4_ch__2:
+ if (Xparm1->un.ch__2 != Xparm2->un.ch__2) {
+ d++;
+ (void) printf("%s: ch__2 mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->un.ch__2, Xparm2->un.ch__2);
+ }
+ break;
+
+ default:
+ ferrd(1, "tcmp:TY_CHOICE4:illegal offset %d\n", Xparm1->offset);
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_EXTREF:
+#define Xparm1 ((struct type_T1_E__ref *)parm1)
+#define Xparm2 ((struct type_T1_E__ref *)parm2)
+ if (Xparm1->a__ref && Xparm2->a__ref) {
+ d += tcmp(TY_T2_INFO, (char *)Xparm1->a__ref,
+ (char *)Xparm2->a__ref);
+ } else if (Xparm1->a__ref == NULL || Xparm2->a__ref == NULL) {
+ (void) printf("%s: a__ref one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->b__ref && Xparm2->b__ref) {
+ d += tcmp(TY_T2_INFO, (char *)Xparm1->b__ref,
+ (char *)Xparm2->b__ref);
+ } else if (Xparm1->b__ref == NULL || Xparm2->b__ref == NULL) {
+ (void) printf("%s: b__ref one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->c__ref && Xparm2->c__ref) {
+ d += tcmp(TY_CHOICE, (char *)Xparm1->c__ref,
+ (char *)Xparm2->c__ref);
+ } else if (Xparm1->c__ref == NULL || Xparm2->c__ref == NULL) {
+ (void) printf("%s: c__ref one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->d__ref && Xparm2->d__ref) {
+ d += tcmp(TY_T2_INFO, (char *)Xparm1->d__ref,
+ (char *)Xparm2->d__ref);
+ } else if (Xparm1->d__ref && !Xparm2->d__ref
+ || !Xparm1->d__ref && Xparm2->d__ref) {
+ (void) printf("%s: d__ref one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->e__ref && Xparm2->e__ref) {
+ d += tcmp(TY_T2_INFO, (char *)Xparm1->e__ref,
+ (char *)Xparm2->e__ref);
+ } else if (Xparm1->e__ref && !Xparm2->e__ref
+ || !Xparm1->e__ref && Xparm2->e__ref) {
+ (void) printf("%s: e__ref one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_T2_INFO:
+#define Xparm1 ((struct type_T2_Info *)parm1)
+#define Xparm2 ((struct type_T2_Info *)parm2)
+ if (Xparm1->a1 != Xparm2->a1) {
+ d++;
+ (void) printf("%s: a1 mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->a1, Xparm2->a1);
+ }
+ if (Xparm1->a2 != Xparm2->a2) {
+ d++;
+ (void) printf("%s: a2 mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->a2, Xparm2->a2);
+ }
+ if (Xparm1->a3 != Xparm2->a3) {
+ d++;
+ (void) printf("%s: a3 mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->a3, Xparm2->a3);
+ }
+ if (Xparm1->a4 && Xparm2->a4) {
+ d += tcmp(TY_T2_MPDU, (char *)Xparm1->a4, (char *)Xparm2->a4);
+ } else if (Xparm1->a4 == NULL || Xparm2->a4 == NULL) {
+ (void) printf("%s: a4 one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_T2_MPDU:
+#define Xparm1 ((struct type_T2_MPDU *)parm1)
+#define Xparm2 ((struct type_T2_MPDU *)parm2)
+ if (Xparm1->a__seq && Xparm2->a__seq) {
+ d += tcmp(TY_T2_ELEM0, (char *)Xparm1->a__seq,
+ (char *)Xparm2->a__seq);
+ } else if (Xparm1->a__seq == NULL || Xparm2->a__seq == NULL) {
+ (void) printf("%s: a__seq one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_T2_ELEM0:
+#define Xparm1 ((struct element_T2_0 *)parm1)
+#define Xparm2 ((struct element_T2_0 *)parm2)
+ if (Xparm1->fred != Xparm2->fred) {
+ d++;
+ (void) printf("%s: fred mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->fred, Xparm2->fred);
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_OPTIMISED:
+#define Xparm1 ((struct type_T1_Optimised *)parm1)
+#define Xparm2 ((struct type_T1_Optimised *)parm2)
+ if (Xparm1->o1 == NULLPE || Xparm2->o1 == NULLPE) {
+ (void) printf("%s: o1 one missing\n", t_case[tynum].tst_name);
+ d++;
+ } else if (bit_cmp(Xparm1->o1, Xparm2->o1)) {
+ (void) printf("%s:o1 bitstring different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->o2 != NULLQB && Xparm2->o2 != NULLQB) {
+ if (qb_cmp(Xparm1->o2, Xparm2->o2)) {
+ (void) printf("o2 octet string different\n");
+ d++;
+ }
+ } else {
+ (void) printf("%s: o2 one missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->o3 && Xparm2->o3) {
+ d += tcmp(TY_MPDU, (char *)Xparm1->o3, (char *)Xparm2->o3);
+ } else if (Xparm1->o3 == NULL || Xparm2->o3 == NULL) {
+ (void) printf("%s: o3 one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->o4 != NULLPE && Xparm2->o4 == NULLPE
+ || Xparm1->o4 == NULLPE && Xparm2->o4 != NULLPE) {
+ (void) printf("%s: o4 one missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->o4 != NULLPE && Xparm2->o4 != NULLPE) {
+ if (pe_cmp(Xparm1->o4, Xparm2->o4)) {
+ (void) printf("%s:o4 SET of ANY different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ }
+ if (Xparm1->element_T1_14 && Xparm2->element_T1_14) {
+ d += tcmp(TY_MEMBER9, (char *)Xparm1->element_T1_14,
+ (char *)Xparm2->element_T1_14);
+ } else if (Xparm1->element_T1_14 == NULL
+ || Xparm2->element_T1_14 == NULL) {
+ (void) printf("%s: element_T1_14 one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_MEMBER9:
+#define Xparm1 ((struct member_T1_9 *)parm1)
+#define Xparm2 ((struct member_T1_9 *)parm2)
+ if (Xparm1->o5 != NULLPE && Xparm2->o5 != NULLPE) {
+ if (pe_cmp(Xparm1->o5, Xparm2->o5)) {
+ (void) printf("%s:o5 SET of ANY different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else {
+ (void) printf("%s: o5 one missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->o6 != NULLPE && Xparm2->o6 != NULLPE) {
+ if (pe_cmp(Xparm1->o6, Xparm2->o6)) {
+ (void) printf("%s:o6 SET of ANY different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else {
+ (void) printf("%s: o6 one missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->o7 != NULLOID && Xparm2->o7 != NULLOID) {
+ if (oid_cmp(Xparm1->o7, Xparm2->o7)) {
+ (void) printf("%s:o7 OID different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else {
+ (void) printf("%s: o7 one missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_EXTERNAL:
+#define Xparm1 ((struct type_T1_Ext__typ *)parm1)
+#define Xparm2 ((struct type_T1_Ext__typ *)parm2)
+ if (Xparm1->ext != NULL && Xparm2->ext != NULL) {
+ if (ext_cmp(Xparm1->ext, Xparm2->ext)) {
+ (void) printf("%s:ext EXTERNAL different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else {
+ (void) printf("%s: ext one missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->a__ny != NULLPE && Xparm2->a__ny != NULLPE) {
+ if (pe_cmp(Xparm1->a__ny, Xparm2->a__ny)) {
+ (void) printf("%s:a__ny ANY different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else {
+ (void) printf("%s: a__ny one missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->ext__impl != NULL && Xparm2->ext__impl != NULL) {
+ if (ext_cmp(Xparm1->ext__impl, Xparm2->ext__impl)) {
+ (void) printf("%s:ext__impl EXTERNAL different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else {
+ (void) printf("%s: ext__impl one missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->any__impl != NULLPE && Xparm2->any__impl != NULLPE) {
+ if (pe_cmp(Xparm1->any__impl, Xparm2->any__impl)) {
+ (void) printf("%s:any__impl ANY different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else {
+ (void) printf("%s: any__impl one missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->ext__expl != NULL && Xparm2->ext__expl != NULL) {
+ if (ext_cmp(Xparm1->ext__expl, Xparm2->ext__expl)) {
+ (void) printf("%s:ext__expl EXTERNAL different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else {
+ (void) printf("%s: ext__expl one missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->any__expl != NULLPE && Xparm2->any__expl != NULLPE) {
+ if (pe_cmp(Xparm1->any__expl, Xparm2->any__expl)) {
+ (void) printf("%s:any__expl ANY different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else {
+ (void) printf("%s: any__expl one missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_SEXTERNAL:
+#define Xparm1 ((struct type_T1_SExt *)parm1)
+#define Xparm2 ((struct type_T1_SExt *)parm2)
+ if (Xparm1 != NULL && Xparm2 != NULL) {
+ if (ext_cmp(Xparm1, Xparm2)) {
+ (void) printf("%s:ext EXTERNAL different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else {
+ (void) printf("%s: ext one missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+
+ case TY_ETAGOBJ:
+#define Xparm1 ((struct type_T1_Etags *)parm1)
+#define Xparm2 ((struct type_T1_Etags *)parm2)
+ if (Xparm1->offset != Xparm2->offset) {
+ d++;
+ (void) printf("%s: offset mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->offset, Xparm2->offset);
+ break;
+ }
+ switch (Xparm1->offset) {
+ case type_T1_Etags_aE:
+ if (Xparm1->un.aE != Xparm2->un.aE) {
+ d++;
+ (void) printf("%s: un.aE mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->un.aE, Xparm2->un.aE);
+ }
+ break;
+
+ case type_T1_Etags_bE:
+ if (Xparm1->un.bE != Xparm2->un.bE) {
+ d++;
+ (void) printf("%s: un.bE mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->un.bE, Xparm2->un.bE);
+ }
+ break;
+
+ default:
+ ferrd(1, "TY_ETAGOBJ:illegal offset %d\n", Xparm1->offset);
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+/* This has to be changed when posy is upgraded to handle DEFAULTS properly */
+ case TY_DEFAULT:
+#define Xparm1 ((struct type_T1_Def__Strings *)parm1)
+#define Xparm2 ((struct type_T1_Def__Strings *)parm2)
+ if (Xparm1->a__def != Xparm2->a__def) {
+ d++;
+ (void) printf("%s: a__def mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->a__def, Xparm2->a__def);
+ }
+ if (Xparm1->b__def != NULLQB && Xparm2->b__def != NULLQB) {
+ if (qb_cmp(Xparm1->b__def, Xparm2->b__def)) {
+ (void) printf("b__def octet string different\n");
+ d++;
+ }
+ } else if (Xparm2->b__def == NULLQB) {
+ (void) printf("%s: b__def one missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->c__def != NULLPE && Xparm2->c__def != NULLPE) {
+ if (bit_cmp(Xparm1->c__def, Xparm2->c__def)) {
+ (void) printf("%s:c__def bitstring different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else if (Xparm2->c__def == NULLPE) {
+ (void) printf("%s: c__def restored version missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->okay != Xparm2->okay) {
+ d++;
+ (void) printf("%s: okay mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->okay, Xparm2->okay);
+ }
+ /* Can't test NULL ....
+ if (Xparm1->e__opt != Xparm2->e__opt) {
+ d++;
+ (void) printf("%s: e__opt mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->e__opt, Xparm2->e__opt);
+ }
+ */
+ if (Xparm1->big__def && Xparm2->big__def) {
+ d += tcmp(TY_STRINGS, (char *)Xparm1->big__def,
+ (char *)Xparm2->big__def);
+ } else {
+ (void) printf("%s: big__def one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->emb__def && Xparm2->emb__def) {
+ d += tcmp(TY_ELEMENT13, (char *)Xparm1->emb__def,
+ (char *)Xparm2->emb__def);
+ } else if (Xparm1->emb__def != NULL || Xparm2->emb__def != NULL) {
+ (void) printf("%s: emb__def one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->st__def && Xparm2->st__def) {
+ d += tcmp(TY_MEMBER8, (char *)Xparm1->st__def,
+ (char *)Xparm2->st__def);
+ } else if (Xparm1->st__def != NULL || Xparm2->st__def != NULL) {
+ (void) printf("%s: st__def one missing", t_case[tynum].tst_name);
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_ELEMENT13:
+#define Xparm1 ((struct element_T1_13 *)parm1)
+#define Xparm2 ((struct element_T1_13 *)parm2)
+ if (Xparm1->colour != Xparm2->colour) {
+ d++;
+ (void) printf("%s: colour mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->colour, Xparm2->colour);
+ }
+ if (Xparm1->oem__oct != NULLQB && Xparm2->oem__oct != NULLQB) {
+ if (qb_cmp(Xparm1->oem__oct, Xparm2->oem__oct)) {
+ (void) printf("oem__oct octet string different\n");
+ d++;
+ }
+ } else if (Xparm1->oem__oct != NULLQB || Xparm2->oem__oct != NULLQB) {
+ (void) printf("oem__oct: one missing 0x%x, 0x%x\n", Xparm1->oem__oct,
+ Xparm1->oem__oct);
+ d++;
+ }
+ if (Xparm1->version != NULLPE && Xparm2->version != NULLPE) {
+ if (bit_cmp(Xparm1->version, Xparm2->version)) {
+ (void) printf("%s:version bitstring different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else if (Xparm2->version == NULLPE) {
+ (void) printf("%s: version decoded version missing\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_MEMBER8:
+#define Xparm1 ((struct member_T1_8 *)parm1)
+#define Xparm2 ((struct member_T1_8 *)parm2)
+ if (Xparm1->wine != Xparm2->wine) {
+ d++;
+ (void) printf("%s: wine mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->wine, Xparm2->wine);
+ }
+ if (Xparm1->beer != Xparm2->beer) {
+ d++;
+ (void) printf("%s: beer mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->beer, Xparm2->beer);
+ }
+ if (Xparm1->spirit != Xparm2->spirit) {
+ d++;
+ (void) printf("%s: spirit mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->spirit, Xparm2->spirit);
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_STEST:
+#define Xparm1 ((struct type_T1_Stest *)parm1)
+#define Xparm2 ((struct type_T1_Stest *)parm2)
+ if (Xparm1->st1 != NULL && Xparm2->st1 != NULL) {
+ d += tcmp(TY_SINT, (char *)Xparm1->st1, (char *)Xparm2->st1);
+ } else if (Xparm2->st1 == NULL) {
+ d++;
+ (void) printf("%s: missing", t_case[tynum].tst_name);
+ }
+ if (Xparm1->st2 != NULL && Xparm2->st2 != NULL) {
+ if (qb_cmp(Xparm1->st2, Xparm2->st2)) {
+ (void) printf("%s:st2 octet string different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else if (Xparm2->st2 == NULL) {
+ d++;
+ (void) printf("%s: missing", t_case[tynum].tst_name);
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_SINT:
+#define Xparm1 ((struct type_T1_Sint *)parm1)
+#define Xparm2 ((struct type_T1_Sint *)parm2)
+ if (Xparm1->parm != Xparm2->parm) {
+ (void) printf("%s:parm %d != %d\n", t_case[tynum].tst_name, Xparm1->parm,
+ Xparm2->parm);
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_ETYPE:
+#define Xparm1 ((struct type_T1_Enum__type *)parm1)
+#define Xparm2 ((struct type_T1_Enum__type *)parm2)
+ if (Xparm1->parm != Xparm2->parm) {
+ (void) printf("%s:parm %d != %d\n", t_case[tynum].tst_name, Xparm1->parm,
+ Xparm2->parm);
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_ENUM_TEST:
+#define Xparm1 ((struct type_T1_T__enum *)parm1)
+#define Xparm2 ((struct type_T1_T__enum *)parm2)
+ if (Xparm1->ae1 && Xparm2->ae1 ) {
+ d += tcmp(TY_ETYPE, (char *)Xparm1->ae1, (char *)Xparm2->ae1);
+ } else {
+ d++;
+ (void) printf("%s:ae1 missing\n", t_case[tynum].tst_name);
+ }
+ if (Xparm1->ae2 && Xparm2->ae2 ) {
+ d += tcmp(TY_ETYPE, (char *)Xparm1->ae2, (char *)Xparm2->ae2);
+ } else {
+ d++;
+ (void) printf("%s:ae2 missing\n", t_case[tynum].tst_name);
+ }
+ if (Xparm1->ae3 && Xparm2->ae3 ) {
+ d += tcmp(TY_ETYPE, (char *)Xparm1->ae3, (char *)Xparm2->ae3);
+ } else {
+ d++;
+ (void) printf("%s:ae3 missing\n", t_case[tynum].tst_name);
+ }
+ /* Default */
+ if (Xparm1->ae4 && Xparm2->ae4 ) {
+ d += tcmp(TY_ETYPE, (char *)Xparm1->ae4, (char *)Xparm2->ae4);
+ } else {
+ d++;
+ (void) printf("%s:ae4 missing\n", t_case[tynum].tst_name);
+ }
+ /* Optional */
+ if (Xparm1->ae5 && Xparm2->ae5 ) {
+ d += tcmp(TY_ETYPE, (char *)Xparm1->ae5, (char *)Xparm2->ae5);
+ } else if (Xparm1->ae5 || Xparm2->ae5) {
+ d++;
+ (void) printf("%s:ae5 missing\n", t_case[tynum].tst_name);
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+#ifdef PEPSY_REALS
+ case TY_REAL:
+#define Xparm1 ((struct type_T1_Real *)parm1)
+#define Xparm2 ((struct type_T1_Real *)parm2)
+ /* Horrible floating point test for roughly equal */
+ if (fabs(Xparm1->parm) < F_SMALL/2) {
+ if (fabs(Xparm1->parm - Xparm2->parm) > F_SMALL) {
+ (void) printf("%s:parm %f != %f\n", t_case[tynum].tst_name,
+ Xparm1->parm, Xparm2->parm);
+ d++;
+ }
+ } else if (fabs((Xparm1->parm - Xparm2->parm)/Xparm1->parm) > F_SMALL) {
+ (void) printf("%s:parm %f != %f\n", t_case[tynum].tst_name, Xparm1->parm,
+ Xparm2->parm);
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_REAL_TEST:
+#define Xparm1 ((struct type_T1_T__real *)parm1)
+#define Xparm2 ((struct type_T1_T__real *)parm2)
+ if (Xparm1->r1 && Xparm2->r1 ) {
+ d += tcmp(TY_REAL, (char *)Xparm1->r1, (char *)Xparm2->r1);
+ } else {
+ d++;
+ (void) printf("%s:r1 missing\n", t_case[tynum].tst_name);
+ }
+ if (Xparm1->r2 && Xparm2->r2 ) {
+ d += tcmp(TY_REAL, (char *)Xparm1->r2, (char *)Xparm2->r2);
+ } else {
+ d++;
+ (void) printf("%s:r2 missing\n", t_case[tynum].tst_name);
+ }
+ if (Xparm1->r3 && Xparm2->r3 ) {
+ d += tcmp(TY_REAL, (char *)Xparm1->r3, (char *)Xparm2->r3);
+ } else {
+ d++;
+ (void) printf("%s:r3 missing\n", t_case[tynum].tst_name);
+ }
+ /* Default */
+ if (Xparm1->r4 && Xparm2->r4 ) {
+ d += tcmp(TY_REAL, (char *)Xparm1->r4, (char *)Xparm2->r4);
+ } else {
+ d++;
+ (void) printf("%s:r4 missing\n", t_case[tynum].tst_name);
+ }
+ /* Optional */
+ if (Xparm1->r5 && Xparm2->r5 ) {
+ d += tcmp(TY_REAL, (char *)Xparm1->r5, (char *)Xparm2->r5);
+ } else if (Xparm1->r5 || Xparm2->r5) {
+ d++;
+ (void) printf("%s:r5 missing\n", t_case[tynum].tst_name);
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_PEPY:
+#define Xparm1 ((struct pepy_refs *)parm1)
+#define Xparm2 ((struct pepy_refs *)parm2)
+ if (Xparm1->t_int != Xparm2->t_int) {
+ d++;
+ (void) printf("%s: t_int mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->t_int, Xparm2->t_int);
+ }
+
+ if (Xparm1->t_enum != Xparm2->t_enum) {
+ d++;
+ (void) printf("%s:t_enum mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->t_enum, Xparm2->t_enum);
+ }
+
+ if (qb_cmp(Xparm1->t_qbuf, Xparm2->t_qbuf)) {
+ (void) printf("t_qbuf octet string different\n");
+ d++;
+ }
+
+ if (Xparm1->t_bool != Xparm2->t_bool) {
+ d++;
+ (void) printf("%s:t_bool mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->t_bool, Xparm2->t_bool);
+ }
+
+#ifdef PEPSY_REALS
+ /* Horrible floating point test for roughly equal */
+ if (fabs(Xparm1->t_real) < F_SMALL/2) {
+ if (fabs(Xparm1->t_real - Xparm2->t_real) > F_SMALL) {
+ (void) printf("%s:t_real %f != %f\n", t_case[tynum].tst_name,
+ Xparm1->t_real, Xparm2->t_real);
+ d++;
+ }
+ } else if (fabs((Xparm1->t_real - Xparm2->t_real)/Xparm1->t_real) > F_SMALL) {
+ (void) printf("%s:t_real %f != %f\n", t_case[tynum].tst_name,
+ Xparm1->t_real, Xparm2->t_real);
+ d++;
+ }
+#endif
+ if (Xparm1->t_any != NULLPE && Xparm2->t_any != NULLPE) {
+ if (pe_cmp(Xparm1->t_any, Xparm2->t_any)) {
+ (void) printf("%s:t_any different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ }
+ if (Xparm1->t_oid != NULLOID && Xparm2->t_oid != NULLOID) {
+ if (oid_cmp(Xparm1->t_oid, Xparm2->t_oid)) {
+ (void) printf("%s:t_oid OID different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else {
+ (void) printf("%s: t_oid one missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->t_bstring != NULLCP && Xparm2->t_bstring != NULLCP) {
+ if (bitstr_cmp(Xparm1->t_bstring, Xparm1->t_blen,
+ Xparm2->t_bstring, Xparm2->t_blen)) {
+ (void) printf("%s:t_blen string different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else if (Xparm2->t_bstring == NULLCP) {
+ (void) printf("%s: t_bstring decoded version missing\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->t_ostring != NULLCP && Xparm2->t_ostring != NULLCP) {
+ if (Xparm1->t_olen != Xparm2->t_olen) {
+ (void) printf("%s:t_olen string different\n",
+ t_case[tynum].tst_name);
+ d++;
+ } else if (bcmp(Xparm1->t_ostring, Xparm2->t_ostring,
+ Xparm1->t_olen)) {
+ (void) printf("%s:t_ostring string different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else if (Xparm2->t_ostring == NULLCP) {
+ (void) printf("%s: t_ostring decoded version missing\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->t_string != NULLCP && Xparm2->t_string != NULLCP) {
+ if (strcmp(Xparm1->t_string, Xparm2->t_string)) {
+ (void) printf("%s:t_string string different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else if (Xparm2->t_string == NULLCP) {
+ (void) printf("%s: t_string decoded version missing\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->t_pe != NULLPE && Xparm2->t_pe != NULLPE) {
+ if (bit_cmp(Xparm1->t_pe, Xparm2->t_pe)) {
+ (void) printf("%s:t_pe bitstring different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else if (Xparm2->t_pe == NULLPE) {
+ (void) printf("%s: t_pe decoded version missing\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->t_def && Xparm2->t_def ) {
+ d += tcmp(TY_DEFPEPY, (char *)Xparm1->t_def, (char *)Xparm2->t_def);
+ } else if (Xparm1->t_def || Xparm2->t_def) {
+ d++;
+ (void) printf("%s:t_def missing\n", t_case[tynum].tst_name);
+ }
+ if (Xparm1->t_opt && Xparm2->t_opt ) {
+ d += tcmp(TY_OPTPEPY, (char *)Xparm1->t_opt, (char *)Xparm2->t_opt);
+ for (i = NUMOPT - 1; i >= 0; i--)
+ if (BITTEST(Xparm1->t_opt->opt_set, i)
+ != BITTEST(Xparm2->t_opt->opt_set, i)) {
+ d++;
+ (void) printf("%s:t_opt missing optional %d\n",
+ t_case[tynum].tst_name, i);
+ }
+ } else if (Xparm1->t_opt || Xparm2->t_opt) {
+ d++;
+ (void) printf("%s:t_opt missing\n", t_case[tynum].tst_name);
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_DEFPEPY:
+ case TY_OPTPEPY:
+#define Xparm1 ((struct pepy_refs1 *)parm1)
+#define Xparm2 ((struct pepy_refs1 *)parm2)
+ if (tynum == TY_DEFPEPY || (BITTEST(Xparm1->opt_set, OPT_INT1) != 0
+ && BITTEST(Xparm2->opt_set, OPT_INT1) != 0)) {
+ if (Xparm1->t_int != Xparm2->t_int) {
+ d++;
+ (void) printf("%s: t_int mismatch %d != %d\n", t_case[tynum].tst_name,
+ Xparm1->t_int, Xparm2->t_int);
+ }
+ }
+ if (tynum == TY_DEFPEPY || (BITTEST(Xparm1->opt_set, OPT_INT2) != 0
+ && BITTEST(Xparm2->opt_set, OPT_INT2) != 0)) {
+ if (Xparm1->t_int1 != Xparm2->t_int1) {
+ d++;
+ (void) printf("%s: t_int1 mismatch %d != %d\n", t_case[tynum].tst_name,
+ Xparm1->t_int1, Xparm2->t_int1);
+ }
+ }
+
+ if (tynum == TY_DEFPEPY || (BITTEST(Xparm1->opt_set, OPT_ENUM1) != 0
+ && BITTEST(Xparm2->opt_set, OPT_ENUM1) != 0)) {
+ if (Xparm1->t_enum != Xparm2->t_enum) {
+ d++;
+ (void) printf("%s:t_enum mismatch %d != %d\n", t_case[tynum].tst_name,
+ Xparm1->t_enum, Xparm2->t_enum);
+ }
+ }
+ if (tynum == TY_DEFPEPY || (BITTEST(Xparm1->opt_set, OPT_ENUM2) != 0
+ && BITTEST(Xparm2->opt_set, OPT_ENUM2) != 0)) {
+ if (Xparm1->t_enum1 != Xparm2->t_enum1) {
+ d++;
+ (void) printf("%s:t_enum1 mismatch %d != %d\n", t_case[tynum].tst_name,
+ Xparm1->t_enum1, Xparm2->t_enum1);
+ }
+ }
+
+ if (qb_cmp(Xparm1->t_qbuf, Xparm2->t_qbuf)) {
+ (void) printf("t_qbuf octet string different\n");
+ d++;
+ }
+ if (qb_cmp(Xparm1->t_qbuf1, Xparm2->t_qbuf1)) {
+ (void) printf("t_qbuf1 octet string different\n");
+ d++;
+ }
+
+ if (tynum == TY_DEFPEPY || (BITTEST(Xparm1->opt_set, OPT_BOOL1) != 0
+ && BITTEST(Xparm2->opt_set, OPT_BOOL1) != 0)) {
+ if (Xparm1->t_bool != Xparm2->t_bool) {
+ d++;
+ (void) printf("%s:t_bool mismatch %d != %d\n", t_case[tynum].tst_name,
+ Xparm1->t_bool, Xparm2->t_bool);
+ }
+ }
+ if (tynum == TY_OPTPEPY) {
+ if (BITTEST(Xparm1->opt_set, OPT_BOOL2) != 0
+ && BITTEST(Xparm2->opt_set, OPT_BOOL2) != 0) {
+ if (Xparm1->t_bool1 != Xparm2->t_bool1) {
+ d++;
+ (void) printf("%s:t_bool1 mismatch %d != %d\n", t_case[tynum].tst_name,
+ Xparm1->t_bool1, Xparm2->t_bool1);
+ }
+ } else if (BITTEST(Xparm1->opt_set, OPT_BOOL2) != 0
+ || BITTEST(Xparm2->opt_set, OPT_BOOL2) != 0) {
+ d++;
+ (void) printf("%s: t_bool1 missing %d != %d\n", t_case[tynum].tst_name,
+ Xparm1->opt_set, Xparm2->opt_set);
+ }
+ }
+
+#ifdef PEPSY_REALS
+ /* Horrible floating point test for roughly equal */
+ if (fabs(Xparm1->t_real) < F_SMALL/2) {
+ if (fabs(Xparm1->t_real - Xparm2->t_real) > F_SMALL) {
+ (void) printf("%s:t_real %f != %f\n", t_case[tynum].tst_name,
+ Xparm1->t_real, Xparm2->t_real);
+ d++;
+ }
+ } else if (tynum == TY_DEFPEPY
+ && fabs((Xparm1->t_real - Xparm2->t_real)/Xparm1->t_real) > F_SMALL) {
+ (void) printf("%s:t_real %f != %f\n", t_case[tynum].tst_name,
+ Xparm1->t_real, Xparm2->t_real);
+ d++;
+ }
+ if (fabs(Xparm1->t_real1) < F_SMALL/2) {
+ if (fabs(Xparm1->t_real1 - Xparm2->t_real1) > F_SMALL) {
+ (void) printf("%s:t_real1 %f != %f\n", t_case[tynum].tst_name,
+ Xparm1->t_real1, Xparm2->t_real1);
+ d++;
+ }
+ } else if (tynum == TY_DEFPEPY
+ && fabs((Xparm1->t_real1 - Xparm2->t_real1)/Xparm1->t_real1) > F_SMALL) {
+ (void) printf("%s:t_real1 %f != %f\n", t_case[tynum].tst_name,
+ Xparm1->t_real1, Xparm2->t_real1);
+ d++;
+ }
+#endif
+ if (Xparm1->t_any != NULLPE && Xparm2->t_any != NULLPE) {
+ if (pe_cmp(Xparm1->t_any, Xparm2->t_any)) {
+ (void) printf("%s:t_any different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ }
+
+ if (Xparm1->t_oid != NULLOID && Xparm2->t_oid != NULLOID) {
+ if (oid_cmp(Xparm1->t_oid, Xparm2->t_oid)) {
+ (void) printf("%s:t_oid OID different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else {
+ (void) printf("%s: t_oid one missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->t_oid1 != NULLOID && Xparm2->t_oid1 != NULLOID) {
+ if (oid_cmp(Xparm1->t_oid1, Xparm2->t_oid1)) {
+ (void) printf("%s:t_oid1 OID different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ }
+
+ if (Xparm1->t_bstring != NULLCP && Xparm2->t_bstring != NULLCP) {
+ if (bitstr_cmp(Xparm1->t_bstring, Xparm1->t_blen,
+ Xparm2->t_bstring, Xparm2->t_blen)) {
+ (void) printf("%s:t_blen string different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else if (Xparm2->t_bstring == NULLCP) {
+ (void) printf("%s: t_bstring decoded version missing\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->t_bstring1 != NULLCP && Xparm2->t_bstring1 != NULLCP) {
+ if (bitstr_cmp(Xparm1->t_bstring1, Xparm1->t_blen1,
+ Xparm2->t_bstring1, Xparm2->t_blen1)) {
+ (void) printf("%s:t_blen1 string different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else if (tynum == TY_DEFPEPY && Xparm2->t_bstring1 == NULLCP) {
+ (void) printf("%s: t_bstring1 decoded version missing\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+
+ if (Xparm1->t_ostring != NULLCP && Xparm2->t_ostring != NULLCP) {
+ if (Xparm1->t_olen != Xparm2->t_olen) {
+ (void) printf("%s:t_olen string different\n",
+ t_case[tynum].tst_name);
+ d++;
+ } else if (bcmp(Xparm1->t_ostring, Xparm2->t_ostring,
+ Xparm1->t_olen)) {
+ (void) printf("%s:t_ostring string different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else if (Xparm2->t_ostring == NULLCP) {
+ (void) printf("%s: t_ostring decoded version missing\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->t_ostring1 != NULLCP && Xparm2->t_ostring1 != NULLCP) {
+ if (Xparm1->t_olen1 != Xparm2->t_olen1) {
+ (void) printf("%s:t_olen1 string different\n",
+ t_case[tynum].tst_name);
+ d++;
+ } else if (bcmp(Xparm1->t_ostring1, Xparm2->t_ostring1,
+ Xparm1->t_olen1)) {
+ (void) printf("%s:t_ostring string different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else if (Xparm2->t_ostring1 == NULLCP) {
+ (void) printf("%s: t_ostring1 decoded version missing\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+
+ if (Xparm1->t_string != NULLCP && Xparm2->t_string != NULLCP) {
+ if (strcmp(Xparm1->t_string, Xparm2->t_string)) {
+ (void) printf("%s:t_string string different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else if (Xparm2->t_string == NULLCP) {
+ (void) printf("%s: t_string decoded version missing\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->t_string1 != NULLCP && Xparm2->t_string1 != NULLCP) {
+ if (strcmp(Xparm1->t_string1, Xparm2->t_string1)) {
+ (void) printf("%s:t_string1 string different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else if (Xparm2->t_string1 == NULLCP) {
+ (void) printf("%s: t_string1 decoded version missing\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+
+ if (Xparm1->t_pe != NULLPE && Xparm2->t_pe != NULLPE) {
+ if (bit_cmp(Xparm1->t_pe, Xparm2->t_pe)) {
+ (void) printf("%s:t_pe bitstring different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else if (Xparm2->t_pe == NULLPE) {
+ (void) printf("%s: t_pe decoded version missing\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->t_pe1 != NULLPE && Xparm2->t_pe1 != NULLPE) {
+ if (bit_cmp(Xparm1->t_pe1, Xparm2->t_pe1)) {
+ (void) printf("%s:t_pe1 bitstring different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else if (Xparm2->t_pe1 == NULLPE) {
+ (void) printf("%s: t_pe1 decoded version missing\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_S_COMPD:
+#define Xparm1 ((struct pepy_refs1 *)parm1)
+#define Xparm2 ((struct pepy_refs1 *)parm2)
+ if (BITTEST(Xparm1->opt_set, OPT_INT1) != 0
+ && BITTEST(Xparm2->opt_set, OPT_INT1) != 0) {
+ if (Xparm1->t_int != Xparm2->t_int) {
+ d++;
+ (void) printf("%s: t_int mismatch %d != %d\n", t_case[tynum].tst_name,
+ Xparm1->t_int, Xparm2->t_int);
+ }
+ } else if (BITTEST(Xparm1->opt_set, OPT_INT1) != 0
+ || BITTEST(Xparm2->opt_set, OPT_INT1) != 0) {
+ d++;
+ (void) printf("%s: t_int missing %d != %d\n", t_case[tynum].tst_name,
+ Xparm1->opt_set, Xparm2->opt_set);
+ }
+
+ if (BITTEST(Xparm1->opt_set, OPT_INT2) != 0
+ && BITTEST(Xparm2->opt_set, OPT_INT2) != 0) {
+ if (Xparm1->t_int1 != Xparm2->t_int1) {
+ d++;
+ (void) printf("%s: t_int1 mismatch %d != %d\n", t_case[tynum].tst_name,
+ Xparm1->t_int1, Xparm2->t_int1);
+ }
+ } else if (BITTEST(Xparm1->opt_set, OPT_INT2) != 0
+ || BITTEST(Xparm2->opt_set, OPT_INT2) != 0) {
+ d++;
+ (void) printf("%s: t_int1 missing %d != %d\n", t_case[tynum].tst_name,
+ Xparm1->opt_set, Xparm2->opt_set);
+ }
+
+ if (BITTEST(Xparm1->opt_set, OPT_ENUM1) != 0
+ && BITTEST(Xparm2->opt_set, OPT_ENUM1) != 0) {
+ if (Xparm1->t_enum != Xparm2->t_enum) {
+ d++;
+ (void) printf("%s:t_enum mismatch %d != %d\n", t_case[tynum].tst_name,
+ Xparm1->t_enum, Xparm2->t_enum);
+ }
+ } else if (BITTEST(Xparm1->opt_set, OPT_ENUM1) != 0
+ || BITTEST(Xparm2->opt_set, OPT_ENUM1) != 0) {
+ d++;
+ (void) printf("%s: t_int missing %d != %d\n", t_case[tynum].tst_name,
+ Xparm1->opt_set, Xparm2->opt_set);
+ }
+
+ if (BITTEST(Xparm1->opt_set, OPT_ENUM2) != 0
+ && BITTEST(Xparm2->opt_set, OPT_ENUM2) != 0) {
+ if (Xparm1->t_enum1 != Xparm2->t_enum1) {
+ d++;
+ (void) printf("%s:t_enum1 mismatch %d != %d\n", t_case[tynum].tst_name,
+ Xparm1->t_enum1, Xparm2->t_enum1);
+ }
+ } else if (BITTEST(Xparm1->opt_set, OPT_ENUM2) != 0
+ || BITTEST(Xparm2->opt_set, OPT_ENUM2) != 0) {
+ d++;
+ (void) printf("%s: t_int missing %d != %d\n", t_case[tynum].tst_name,
+ Xparm1->opt_set, Xparm2->opt_set);
+ }
+
+ for (i = NUMOPT - 1; i >= 0; i--) {
+ if (i != OPT_INT1 && i != OPT_INT2
+ && i != OPT_ENUM1 && i != OPT_ENUM2)
+ continue;
+
+ if (BITTEST(Xparm1->opt_set, i) != BITTEST(Xparm2->opt_set, i)) {
+ d++;
+ (void) printf("%s:t_opt missing optional %d\n",
+ t_case[tynum].tst_name, i);
+ }
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+#endif
+
+ case TY_ACTION:
+ case TY_REPEAT:
+#define Xparm1 ((struct repeats *)parm1)
+#define Xparm2 ((struct repeats *)parm2)
+ if (ri_cmp(Xparm1->rp_sq1, Xparm2->rp_sq1)) {
+ d++;
+ (void) printf("%s:rp_sq1 mangled\n", t_case[tynum].tst_name);
+ }
+ if (re_cmp(Xparm1->rp_sq2, Xparm2->rp_sq2)) {
+ d++;
+ (void) printf("%s:rp_sq2 mangled\n", t_case[tynum].tst_name);
+ }
+ if (ri_cmp(Xparm1->rp_st1, Xparm2->rp_st1)) {
+ d++;
+ (void) printf("%s:rp_st1 mangled\n", t_case[tynum].tst_name);
+ }
+ if (re_cmp(Xparm1->rp_st2, Xparm2->rp_st2)) {
+ d++;
+ (void) printf("%s:rp_st2 mangled\n", t_case[tynum].tst_name);
+ }
+ if (Xparm1->rp_choice != Xparm2->rp_choice) {
+ d++;
+ (void) printf("%s:rp_choice wrong %d != %d\n",
+ t_case[tynum].tst_name, Xparm1->rp_choice, Xparm2->rp_choice);
+ }
+ switch (Xparm1->rp_choice) {
+ case RP_INT:
+ if (Xparm1->rp_int != Xparm2->rp_int) {
+ d++;
+ (void) printf("%s:rp_int wrong %d != %d\n",
+ t_case[tynum].tst_name, Xparm1->rp_int, Xparm2->rp_int);
+ }
+ break;
+
+ case RP_BOOL:
+ if (Xparm1->rp_bool && !Xparm2->rp_bool
+ || !Xparm1->rp_bool && Xparm2->rp_bool) {
+ d++;
+ (void) printf("%s:RP_BOOL wrong %d != %d\n",
+ t_case[tynum].tst_name, Xparm1->rp_bool, Xparm2->rp_bool);
+ }
+ break;
+
+ case RP_OSTRING:
+ if (!Xparm1->rp_ostring) {
+ d++;
+ (void) printf("%s:initial rp_ostring missing\n",
+ t_case[tynum].tst_name);
+ }
+ if (!Xparm2->rp_ostring) {
+ d++;
+ (void) printf("%s:final rp_ostring missing\n",
+ t_case[tynum].tst_name);
+ }
+ if (strcmp(Xparm1->rp_ostring, Xparm2->rp_ostring)) {
+ d++;
+ (void) printf("%s:rp_ostring not equal %s != %s\n",
+ t_case[tynum].tst_name, Xparm1->rp_ostring, Xparm2->rp_ostring);
+ }
+ break;
+
+ default:
+ d++;
+ (void) printf("%s:bad choice found\n", t_case[tynum].tst_name);
+ break;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_VPDEFINED:
+#define Xparm1 ((struct pepy_refs *)parm1)
+#define Xparm2 ((struct pepy_refs *)parm2)
+ if (Xparm1->t_int != Xparm2->t_int) {
+ d++;
+ (void) printf("%s: t_int mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->t_int, Xparm2->t_int);
+ }
+
+ if (Xparm1->t_enum != Xparm2->t_enum) {
+ d++;
+ (void) printf("%s:t_enum mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->t_enum, Xparm2->t_enum);
+ }
+
+ if (qb_cmp(Xparm1->t_qbuf, Xparm2->t_qbuf)) {
+ (void) printf("t_qbuf octet string different\n");
+ d++;
+ }
+
+ if (Xparm1->t_bool != Xparm2->t_bool) {
+ d++;
+ (void) printf("%s:t_bool mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->t_bool, Xparm2->t_bool);
+ }
+
+#ifdef PEPSY_REALS
+ /* Horrible floating point test for roughly equal */
+ if (fabs(Xparm1->t_real) < F_SMALL/2) {
+ if (fabs(Xparm1->t_real - Xparm2->t_real) > F_SMALL) {
+ (void) printf("%s:t_real %f != %f\n", t_case[tynum].tst_name,
+ Xparm1->t_real, Xparm2->t_real);
+ d++;
+ }
+ } else if (fabs((Xparm1->t_real - Xparm2->t_real)/Xparm1->t_real) > F_SMALL) {
+ (void) printf("%s:t_real %f != %f\n", t_case[tynum].tst_name,
+ Xparm1->t_real, Xparm2->t_real);
+ d++;
+ }
+#endif
+ if (Xparm1->t_any != NULLPE && Xparm2->t_any != NULLPE) {
+ if (pe_cmp(Xparm1->t_any, Xparm2->t_any)) {
+ (void) printf("%s:t_any different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ }
+ if (Xparm1->t_oid != NULLOID && Xparm2->t_oid != NULLOID) {
+ if (oid_cmp(Xparm1->t_oid, Xparm2->t_oid)) {
+ (void) printf("%s:t_oid OID different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else {
+ (void) printf("%s: t_oid one missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->t_bstring != NULLCP && Xparm2->t_bstring != NULLCP) {
+ if (bitstr_cmp(Xparm1->t_bstring, Xparm1->t_blen,
+ Xparm2->t_bstring, Xparm2->t_blen)) {
+ (void) printf("%s:t_blen string different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else if (Xparm2->t_bstring == NULLCP) {
+ (void) printf("%s: t_bstring decoded version missing\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->t_pe != NULLPE && Xparm2->t_pe != NULLPE) {
+ if (bit_cmp(Xparm1->t_pe, Xparm2->t_pe)) {
+ (void) printf("%s:t_pe bitstring different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else if (Xparm2->t_pe == NULLPE) {
+ (void) printf("%s: t_pe decoded version missing\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->t_ostring != NULLCP && Xparm2->t_ostring != NULLCP) {
+ if (Xparm1->t_olen != Xparm2->t_olen) {
+ (void) printf("%s:t_olen string different\n",
+ t_case[tynum].tst_name);
+ d++;
+ } else if (bcmp(Xparm1->t_ostring, Xparm2->t_ostring,
+ Xparm1->t_olen)) {
+ (void) printf("%s:t_ostring string different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else {
+ (void) printf("%s: t_ostring missing\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->t_string != NULLCP && Xparm2->t_string != NULLCP) {
+ if (strcmp(Xparm1->t_string, Xparm2->t_string)) {
+ (void) printf("%s:t_string string different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else {
+ (void) printf("%s: t_string decoded version missing\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_FUNC:
+#define Xparm1 ((struct codedata *)parm1)
+#define Xparm2 ((struct codedata *)parm2)
+ if (Xparm1->cd_a != NULLPE && Xparm2->cd_a != NULLPE) {
+ if (pe_cmp(Xparm1->cd_a, Xparm2->cd_a)) {
+ (void) printf("%s:cd_a different\n", t_case[tynum].tst_name);
+ d++;
+ }
+ } else {
+ (void) printf("%s: cd_a missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->cd_b != NULLPE && Xparm2->cd_b != NULLPE) {
+ if (pe_cmp(Xparm1->cd_b, Xparm2->cd_b)) {
+ (void) printf("%s:cd_b different\n", t_case[tynum].tst_name);
+ d++;
+ }
+ } else {
+ (void) printf("%s: cd_b missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->cd_c != NULLPE && Xparm2->cd_c != NULLPE) {
+ if (pe_cmp(Xparm1->cd_c, Xparm2->cd_c)) {
+ (void) printf("%s:cd_c different\n", t_case[tynum].tst_name);
+ d++;
+ }
+ } else {
+ (void) printf("%s: cd_c missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->cd_d != NULLPE && Xparm2->cd_d != NULLPE) {
+ if (pe_cmp(Xparm1->cd_d, Xparm2->cd_d)) {
+ (void) printf("%s:cd_d different\n", t_case[tynum].tst_name);
+ d++;
+ }
+ } else {
+ (void) printf("%s: cd_d missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->cd_int != Xparm2->cd_int) {
+ d++;
+ (void) printf("%s:cd_int mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->cd_int, Xparm2->cd_int);
+ }
+
+ if (Xparm1->cd_string != NULLCP && Xparm2->cd_string != NULLCP) {
+ if (strcmp(Xparm1->cd_string, Xparm2->cd_string)) {
+ (void) printf("%s:cd_string string different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else {
+ (void) printf("%s: cd_string missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->cd_left && Xparm2->cd_left ) {
+ d += tcmp(TY_OPTFUNC, (char *)Xparm1->cd_left,
+ (char *)Xparm2->cd_left);
+ } else if (Xparm1->cd_left || Xparm2->cd_left) {
+ d++;
+ (void) printf("%s:cd_left missing\n", t_case[tynum].tst_name);
+ }
+ if (Xparm1->cd_right && Xparm2->cd_right ) {
+ d += tcmp(TY_DFTFUNC, (char *)Xparm1->cd_right,
+ (char *)Xparm2->cd_right);
+ } else if (Xparm1->cd_right || Xparm2->cd_right) {
+ d++;
+ (void) printf("%s:cd_right missing\n", t_case[tynum].tst_name);
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_OPTFUNC:
+#define Xparm1 ((struct codedata *)parm1)
+#define Xparm2 ((struct codedata *)parm2)
+ if (Xparm1->cd_a != NULLPE && Xparm2->cd_a != NULLPE) {
+ if (pe_cmp(Xparm1->cd_a, Xparm2->cd_a)) {
+ (void) printf("%s:cd_a different\n", t_case[tynum].tst_name);
+ d++;
+ }
+ } else if (Xparm1->cd_a != NULLPE || Xparm2->cd_a != NULLPE) {
+ (void) printf("%s: cd_a missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->cd_b != NULLPE && Xparm2->cd_b != NULLPE) {
+ if (pe_cmp(Xparm1->cd_b, Xparm2->cd_b)) {
+ (void) printf("%s:cd_b different\n", t_case[tynum].tst_name);
+ d++;
+ }
+ } else if (Xparm1->cd_b != NULLPE || Xparm2->cd_b != NULLPE) {
+ (void) printf("%s: cd_b missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ for (i = NCD_OPT - 1; i >= 0; i--) {
+ if (BITTEST(Xparm1->cd_opt_set, i)
+ != BITTEST(Xparm2->cd_opt_set, i)) {
+ d++;
+ (void) printf("%s: flag bit %d differs\n",
+ t_case[tynum].tst_name, i);
+ }
+ }
+ if (BITTEST(Xparm1->cd_opt_set, CD_C)) {
+ if (Xparm1->cd_c != NULLPE && Xparm2->cd_c != NULLPE) {
+ if (pe_cmp(Xparm1->cd_c, Xparm2->cd_c)) {
+ (void) printf("%s:cd_c different\n",t_case[tynum].tst_name);
+ d++;
+ }
+ } else {
+ (void) printf("%s: cd_c missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ }
+ if (BITTEST(Xparm1->cd_opt_set, CD_D)) {
+ if (Xparm1->cd_d != NULLPE && Xparm2->cd_d != NULLPE) {
+ if (pe_cmp(Xparm1->cd_d, Xparm2->cd_d)) {
+ (void) printf("%s:cd_d different\n",t_case[tynum].tst_name);
+ d++;
+ }
+ } else {
+ (void) printf("%s: cd_d missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ }
+
+ if (BITTEST(Xparm1->cd_opt_set, CD_INT)) {
+ if (Xparm1->cd_int != Xparm2->cd_int) {
+ d++;
+ (void) printf("%s:cd_int mismatch %d != %d",
+ t_case[tynum].tst_name, Xparm1->cd_int, Xparm2->cd_int);
+ }
+ }
+
+ if (Xparm1->cd_string != NULLCP && Xparm2->cd_string != NULLCP) {
+ if (strcmp(Xparm1->cd_string, Xparm2->cd_string)) {
+ (void) printf("%s:cd_string string different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else if (Xparm1->cd_string != NULLCP || Xparm2->cd_string != NULLCP) {
+ (void) printf("%s: cd_string missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+ case TY_DFTFUNC:
+#define Xparm1 ((struct codedata *)parm1)
+#define Xparm2 ((struct codedata *)parm2)
+ if (Xparm1->cd_a != NULLPE && Xparm2->cd_a != NULLPE) {
+ if (pe_cmp(Xparm1->cd_a, Xparm2->cd_a)) {
+ (void) printf("%s:cd_a different\n", t_case[tynum].tst_name);
+ d++;
+ }
+ } else if (Xparm1->cd_a != NULLPE || Xparm2->cd_a != NULLPE) {
+ (void) printf("%s: cd_a missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->cd_b != NULLPE && Xparm2->cd_b != NULLPE) {
+ if (pe_cmp(Xparm1->cd_b, Xparm2->cd_b)) {
+ (void) printf("%s:cd_b different\n", t_case[tynum].tst_name);
+ d++;
+ }
+ } else if (Xparm1->cd_b != NULLPE || Xparm2->cd_b != NULLPE) {
+ (void) printf("%s: cd_b missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ for (i = NCD_OPT - 1; i >= 0; i--) {
+ if (i == CD_INT)
+ continue;
+
+ if (BITTEST(Xparm1->cd_opt_set,i) !=BITTEST(Xparm2->cd_opt_set,i)) {
+ d++;
+ (void) printf("%s: flag bit %d differs\n",
+ t_case[tynum].tst_name,i);
+ }
+ }
+ if (BITTEST(Xparm1->cd_opt_set, CD_C)) {
+ if (Xparm1->cd_c != NULLPE && Xparm2->cd_c != NULLPE) {
+ if (pe_cmp(Xparm1->cd_c, Xparm2->cd_c)) {
+ (void) printf("%s:cd_c different\n",t_case[tynum].tst_name);
+ d++;
+ }
+ } else {
+ (void) printf("%s: cd_c missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ }
+ if (BITTEST(Xparm1->cd_opt_set, CD_D)) {
+ if (Xparm1->cd_d != NULLPE && Xparm2->cd_d != NULLPE) {
+ if (pe_cmp(Xparm1->cd_d, Xparm2->cd_d)) {
+ (void) printf("%s:cd_d different\n",t_case[tynum].tst_name);
+ d++;
+ }
+ } else {
+ (void) printf("%s: cd_d missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ }
+
+ if (Xparm1->cd_int != Xparm2->cd_int) {
+ d++;
+ (void) printf("%s:cd_int mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->cd_int, Xparm2->cd_int);
+ }
+
+ if (Xparm1->cd_string != NULLCP && Xparm2->cd_string != NULLCP) {
+ if (strcmp(Xparm1->cd_string, Xparm2->cd_string)) {
+ (void) printf("%s:cd_string string different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else {
+ (void) printf("%s: cd_string missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+
+#ifdef PEPSY_REALS
+ case TY_ASIMPLE:
+#define Xparm1 ((struct codedata *)parm1)
+#define Xparm2 ((struct codedata *)parm2)
+ if (Xparm1->cd_a != NULLPE && Xparm2->cd_a != NULLPE) {
+ if (pe_cmp(Xparm1->cd_a, Xparm2->cd_a)) {
+ (void) printf("%s:cd_a different\n", t_case[tynum].tst_name);
+ d++;
+ }
+ } else {
+ (void) printf("%s: cd_a missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->cd_int != Xparm2->cd_int) {
+ d++;
+ (void) printf("%s:cd_int mismatch %d != %d", t_case[tynum].tst_name,
+ Xparm1->cd_int, Xparm2->cd_int);
+ }
+
+ if (Xparm1->cd_string != NULLCP && Xparm2->cd_string != NULLCP) {
+ if (strcmp(Xparm1->cd_string, Xparm2->cd_string)) {
+ (void) printf("%s:cd_string string different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else {
+ (void) printf("%s: cd_string missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->cd_bool && !Xparm2->cd_bool
+ || !Xparm1->cd_bool && Xparm2->cd_bool) {
+ d++;
+ (void) printf("%s:cd_bool wrong %d != %d\n",
+ t_case[tynum].tst_name, Xparm1->cd_bool, Xparm2->cd_bool);
+ }
+ /* Horrible floating point test for roughly equal */
+ if (fabs(Xparm1->cd_real) < F_SMALL/2) {
+ if (fabs(Xparm1->cd_real - Xparm2->cd_real) > F_SMALL) {
+ (void) printf("%s:cd_real %f != %f\n", t_case[tynum].tst_name,
+ Xparm1->cd_real, Xparm2->cd_real);
+ d++;
+ }
+ } else if (fabs((Xparm1->cd_real - Xparm2->cd_real)/Xparm1->cd_real)
+ > F_SMALL) {
+ (void) printf("%s:cd_real %f != %f\n", t_case[tynum].tst_name,
+ Xparm1->cd_real, Xparm2->cd_real);
+ d++;
+ }
+ if (Xparm1->cd_oid != NULLOID && Xparm2->cd_oid != NULLOID) {
+ if (oid_cmp(Xparm1->cd_oid, Xparm2->cd_oid)) {
+ (void) printf("%s:cd_oid OID different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else {
+ (void) printf("%s: cd_oid one missing\n", t_case[tynum].tst_name);
+ d++;
+ }
+ if (Xparm1->cd_bit != NULLPE && Xparm2->cd_bit != NULLPE) {
+ if (bit_cmp(Xparm1->cd_bit, Xparm2->cd_bit)) {
+ (void) printf("%s:cd_bit bitstring different\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ } else if (Xparm2->cd_bit == NULLPE) {
+ (void) printf("%s: cd_bit decoded version missing\n",
+ t_case[tynum].tst_name);
+ d++;
+ }
+ break;
+#undef Xparm1
+#undef Xparm2
+#endif
+
+ default:
+ ferrd(1, "tcmp:unknown type %d\n", tynum);
+ }
+ if (d) {
+ (void) printf("tcmp:failed on %s\n", t_case[tynum].tst_name);
+ }
+ return (d);
+}
+
+/*
+ * Compare two possible null qbuf lists and return non zero if they are
+ * different
+ * Pretty complex to allow for all sorts of weird cases
+ * Doesn't work for a qbuf which doesn't have a head ! Don't really know what
+ * is the proper form of a queue buf. MArshall's doco doesn't say
+ */
+qb_cmp(qb1, qb2)
+struct qbuf *qb1, *qb2;
+{
+ struct qbuf *qp1, *qp2;
+ char *po1, *po2;
+ int len1, len2;
+
+ if (qb1 == NULL && qb2 == NULL)
+ return (0);
+
+ if (qb1 == NULL || qb2 == NULL)
+ return (1);
+
+ qp1 = qb1->qb_forw;
+ qp2 = qb2->qb_forw;
+ po1 = qp1->qb_data;
+ po2 = qp2->qb_data;
+ len1 = qp1->qb_len;
+ len2 = qp2->qb_len;
+
+ while (qp1 != qb1 && qp2 != qb2) {
+ if (len1 < len2) {
+ if (bcmp(po1, po2, len1))
+ return (1);
+ len2 -= len1;
+ po2 += len1;
+ qp1 = qp1->qb_forw;
+ po1 = qp1->qb_data;
+ len1 = qp1->qb_len;
+ } else {
+ if (bcmp(po1, po2, len1))
+ return (1);
+ len1 -= len2;
+ po1 += len2;
+ qp2 = qp2->qb_forw;
+ po2 = qp2->qb_data;
+ len2 = qp2->qb_len;
+ }
+ }
+
+ if (len1 == 0)
+ qp1 = qp1->qb_forw;
+ if (len2 == 0)
+ qp2 = qp2->qb_forw;
+ while (qp1 != qb1 && qp1->qb_len == 0)
+ qp1 = qp1->qb_forw;
+ while (qp2 != qb2 && qp2->qb_len == 0)
+ qp2 = qp2->qb_forw;
+ if (qp1 == qb1 && qp2 == qb2)
+ return (0); /* perfect match */
+
+ return (1);
+}
+
+/*
+ * compare two bitstrings. Including the little bits left at the end but
+ * not the bits not in the strings
+ */
+bit_cmp(b1, b2)
+PE b1, b2;
+{
+ int len1, len2;
+ register char *cp1, *cp2;
+
+ if (b1 == NULLPE && b2 == NULLPE)
+ return (0);
+ if (b1 == NULLPE || b2 == NULLPE)
+ goto fail;
+
+ if ((cp1 = bitstr2strb(b1, &len1)) == NULL)
+ goto fail;
+ if ((cp2 = bitstr2strb(b2, &len2)) == NULL) {
+ free(cp1);
+ goto fail;
+ }
+
+ if (len1 != len2 || bcmp(cp1, cp2, len1/8)) {
+ free(cp1);
+ free(cp2);
+ goto fail;
+ }
+
+ if (len1 % 8) {
+ int i;
+ int mask;
+
+ /* Check those last few bits */
+ i = len1/8;
+ mask = (0xff00 >> len1 % 8) & 0xff;
+ if ((cp1[i] & mask) != (cp2[i] & mask)) {
+ free(cp1);
+ free(cp2);
+ goto fail;
+ }
+ }
+
+ free(cp1);
+ free(cp2);
+ return (0);
+
+ fail:
+ return (1);
+}
+
+/*
+ * compare to strings of given number of bits for equality
+ */
+bitstr_cmp(cp1, len1, cp2, len2)
+char *cp1, *cp2;
+int len1, len2;
+{
+ int i;
+ int mask;
+
+ if (len1 != len2 || bcmp(cp1, cp2, len1/8))
+ return (1);
+
+ if (len1 % 8) {
+
+ /* Check those last few bits */
+ i = len1/8;
+ mask = (0xff00 >> len1 % 8) & 0xff;
+ if ((cp1[i] & mask) != (cp2[i] & mask)) {
+ return (1);
+ }
+ }
+ return (0);
+}
+
+#define MKMASK 0x7
+#define MKSHIFT 6
+/*
+ * Generate a randomish list of PElement s for use as ANY or SET OF ANY ....
+ */
+PE
+mkpelist(i)
+{
+ PE pe, fpe = NULL;
+
+ fpe = pe_alloc(PE_CLASS_PRIV, PE_FORM_CONS, (PElementID ) i);
+ while (i > 0) {
+ pe = mkpe(i);
+ pe->pe_next = fpe->pe_cons;
+ fpe->pe_cons = pe;
+ i--;
+ }
+ return (fpe);
+}
+
+/*
+ * generate a randomish PElement
+ */
+PE
+mkpe(i)
+int i;
+{
+ int id, class;
+ PE pe;
+
+ id = i * i + 1;
+ class = PE_CLASS_PRIV;
+ switch ((i*i >> MKSHIFT) & MKMASK) {
+ case 5:
+ case 0:
+ pe = flag2prim(i & 0x1, (PElementClass ) class, (PElementID ) id);
+ break;
+
+ case 6:
+ case 1:
+ pe = num2prim((integer )i, (PElementClass ) class, (PElementID ) id);
+ break;
+
+ case 7:
+ case 2:
+ pe = str2prim("mkpelist:testdata", 17, (PElementClass ) class,
+ (PElementID ) id);
+ break;
+
+ case 3:
+ pe = strb2bitstr("\021\0245\375\0124", 4,
+ (PElementClass ) class, (PElementID ) id);
+ break;
+
+ case 4:
+ pe = mkpelist(i - 1);
+ break;
+
+ default:
+ ferrd(1, "mkpelist:internal error %d case not handled\n",
+ (i*i >> MKSHIFT) & MKMASK);
+ }
+
+ return (pe);
+}
+
+#define OID_SIZE 6
+/*
+ * make an OID for testing
+ */
+OID
+mkoid(i)
+int i;
+{
+ OID oid;
+ int oid_cnt = i % OID_SIZE;
+
+ if ((oid = new(struct OIDentifier)) == NULL) {
+ (void) printf("mkoid:calloc did not work\n");
+ return NULL;
+ }
+ if (oid_cnt < 2)
+ oid_cnt = 2; /* At least two integers long */
+ oid->oid_nelem = oid_cnt;
+ if ((oid->oid_elements =
+ (unsigned int *)calloc((unsigned ) oid_cnt, sizeof (int))) == NULL) {
+ (void) printf("mkoid:calloc 2 did not work\n");
+ return NULL;
+ }
+ while (oid_cnt > 2) {
+ oid->oid_elements[oid_cnt - 1] = oid_cnt*i + 33;
+ oid_cnt--;
+ }
+
+ oid->oid_elements[0] = 1;
+ oid->oid_elements[1] = 17;
+
+
+ return (oid);
+}
+
+/*
+ * Produce an External structure initialised to test values
+ * for testing EXTERNAL encoding routines
+ */
+struct type_UNIV_EXTERNAL *
+mkext(i)
+int i;
+{
+ int k;
+ struct type_UNIV_EXTERNAL *p;
+
+ k = i + 2;
+ k *= k; /* generate a more random looking number */
+ k %= 51; /* Keep it in a reasonable bounds to avoid overflow */
+ if ((p = new(struct type_UNIV_EXTERNAL)) == NULL
+ || (p->encoding = new(struct choice_UNIV_0)) == NULL)
+ ferr(1, "mkext:malloc:out of memory\n");
+
+ if (i & 0x1)
+ p->direct__reference = mkoid(i*3);
+
+ p->indirect__reference = k & 0x7c;
+
+ p->data__value__descriptor = str2qb("A very wild type of data", 25, 1);
+
+ switch (p->encoding->offset = (k % choice_UNIV_0_arbitrary) + 1) {
+
+ case choice_UNIV_0_arbitrary:
+ p->encoding->un.single__ASN1__type = mkpe(k % 7);
+ break;
+
+ case choice_UNIV_0_single__ASN1__type:
+ p->encoding->un.single__ASN1__type = mkpe(k % 5);
+ break;
+
+ case choice_UNIV_0_octet__aligned:
+ p->encoding->un.octet__aligned = str2qb("Some test data", 15, 1);
+ break;
+
+ default:
+ ferrd(1, "mkext:internal error: bad offset %d\n", p->encoding->offset);
+
+ }
+
+ return (p);
+}
+
+/*
+ * compare two external types to see if they are identical - return zero if
+ * they are and non zero if they are different
+ */
+ext_cmp(e1, e2)
+register struct type_UNIV_EXTERNAL *e1, *e2;
+{
+ if (e1->direct__reference != NULLOID && e2->direct__reference != NULLOID) {
+ if (oid_cmp(e1->direct__reference, e2->direct__reference))
+ return (1);
+ } else {
+ if (e1->direct__reference != NULLOID || e2->direct__reference != NULLOID)
+ return (1);
+ if (e1->indirect__reference != e2->indirect__reference)
+ return (1);
+ }
+ if (e1->data__value__descriptor != NULLQB
+ && e2->data__value__descriptor != NULLQB) {
+ if (qb_cmp(e1->data__value__descriptor, e2->data__value__descriptor))
+ return (1);
+ } else if (e1->data__value__descriptor != NULLQB
+ || e2->data__value__descriptor != NULLQB)
+ return (1);
+ if (e1->encoding == NULL || e2->encoding == NULL)
+ return (1);
+ if (e1->encoding->offset != e2->encoding->offset)
+ return (1);
+ switch (e1->encoding->offset) {
+ case choice_UNIV_0_single__ASN1__type:
+ if (e1->encoding->un.single__ASN1__type == NULLPE
+ || e2->encoding->un.single__ASN1__type == NULLPE)
+ return (1);
+ if (pe_cmp(e1->encoding->un.single__ASN1__type,
+ e2->encoding->un.single__ASN1__type))
+ return (1);
+ break;
+
+ case choice_UNIV_0_octet__aligned:
+ if (e1->encoding->un.octet__aligned == NULLQB
+ || e2->encoding->un.octet__aligned == NULLQB)
+ return (1);
+ if (qb_cmp(e1->encoding->un.octet__aligned,
+ e2->encoding->un.octet__aligned))
+ return (1);
+ break;
+
+ case choice_UNIV_0_arbitrary:
+ if (e1->encoding->un.arbitrary == NULLPE
+ || e2->encoding->un.arbitrary == NULLPE)
+ return (1);
+ if (pe_cmp(e1->encoding->un.arbitrary,
+ e2->encoding->un.arbitrary))
+ return (1);
+ break;
+
+ default:
+ ferrd(1, "ext_cmp:illegal offset value %d\n", e1->encoding->offset);
+ }
+
+ return (0);
+}
+/*
+ * print the PE structure pointed to by pe
+ */
+print_pe(pe, n)
+PE pe;
+int n;
+{
+
+ if (pe == NULL)
+ return;
+ (void) printf("%*s", 4 * n, "");
+ if (pe->pe_errno)
+ (void) printf(" errno = %d", pe->pe_errno);
+ if (pe->pe_class == PE_CLASS_UNIV)
+ (void) printf(" %s", idname( (int )pe->pe_id));
+ else if (pe->pe_class == PE_CLASS_CONT)
+ (void) printf("[%d]", pe->pe_id);
+ else
+ (void) printf("[%s %d]", clname( (int )pe->pe_class), pe->pe_id);
+
+ (void) printf("\n");
+
+ if (pe->pe_form != 0x0) {
+ if (pe->pe_cons != NULLPE)
+ print_pe(pe->pe_cons, n + 1);
+ } else {
+ (void) printf("%*s", 4 * n, "");
+ switch (pe->pe_id) {
+ case PE_PRIM_BOOL:
+ (void) printf("%d", prim2flag(pe));
+ break;
+
+ case PE_PRIM_INT:
+ (void) printf(" %d", prim2num(pe));
+ break;
+ case PE_PRIM_BITS:
+ prntbits(pe);
+ break;
+
+ case PE_PRIM_OCTS:
+ (void) prntos(pe);
+ break;
+
+ case PE_PRIM_NULL:
+ break;
+
+
+ case PE_DEFN_NUMS:
+ case PE_DEFN_PRTS:
+ case PE_DEFN_T61S:
+ case PE_DEFN_VTXS:
+ case PE_DEFN_IA5S:
+ case PE_DEFN_GFXS:
+ case PE_DEFN_VISS:
+ case PE_DEFN_GENS:
+ case PE_DEFN_CHRS:
+ (void) prntstr(pe);
+ break;
+
+
+ case PE_PRIM_OID:
+ case PE_CONS_EXTN:
+ case PE_PRIM_REAL:
+ case PE_PRIM_ENUM:
+ case PE_PRIM_ENCR:
+
+ case PE_CONS_SEQ:
+ case PE_CONS_SET:
+
+ case PE_DEFN_UTCT:
+ case PE_DEFN_GENT:
+ default:
+ (void) printf("Unimplemented %d ", pe->pe_id);
+ break;
+ }
+ (void) printf("\n");
+ }
+ if (pe->pe_next != NULLPE) {
+ (void) printf("%*s", 4 * n, "pe_next:\n");
+ print_pe(pe->pe_next, n);
+ }
+}
+
+/*
+ * return the string describing that class
+ */
+static char *
+clname(cl)
+int cl;
+{
+ char *p;
+ static char buf[30];
+
+ switch (cl) {
+ case PE_CLASS_UNIV:
+ p = "Universal";
+ break;
+
+ case PE_CLASS_APPL:
+ p = "Application";
+ break;
+
+ case PE_CLASS_CONT:
+ p = "Context";
+ break;
+
+ case PE_CLASS_PRIV:
+ p = "Private";
+ break;
+
+ default:
+ (void) sprintf(buf, "Unknown Class %d", cl);
+ p = buf;
+ break;
+ }
+ return (p);
+}
+
+
+/*
+ * return the string describing that identity or the number itself
+ * Assuming a Universal class
+ */
+static char *
+idname(id)
+int id;
+{
+ char *p;
+ static char buf[40];
+
+ switch (id) {
+ case PE_PRIM_BOOL:
+ p = "Boolean";
+ break;
+
+ case PE_PRIM_INT:
+ p = "Integer";
+ break;
+
+ case PE_PRIM_BITS:
+ p = "Bit String";
+ break;
+
+ case PE_PRIM_OCTS:
+ p = "Octet String";
+ break;
+
+ case PE_PRIM_NULL:
+ p = "Null";
+ break;
+
+ case PE_PRIM_OID:
+ p = "Object Descriptor";
+ break;
+
+ case PE_CONS_EXTN:
+ p = "External";
+ break;
+
+ case PE_PRIM_REAL:
+ p = "Real";
+ break;
+
+ case PE_PRIM_ENUM:
+ p = "Enumerated Type";
+ break;
+
+ case PE_PRIM_ENCR:
+ p = "Encrypted Type";
+ break;
+
+ case PE_CONS_SEQ:
+ p = "Sequence";
+ break;
+
+ case PE_CONS_SET:
+ p = "Set";
+ break;
+
+ case PE_DEFN_NUMS:
+ p = "Numeric String";
+ break;
+
+ case PE_DEFN_PRTS:
+ p = "Printable String";
+ break;
+
+ case PE_DEFN_T61S:
+ p = "T.61 String";
+ break;
+
+ case PE_DEFN_VTXS:
+ p = "Videotex String";
+ break;
+
+ case PE_DEFN_IA5S:
+ p = "IA5 String";
+ break;
+
+ case PE_DEFN_UTCT:
+ p = "UTC Time";
+ break;
+
+ case PE_DEFN_GENT:
+ p = "Generalised Time";
+ break;
+
+ case PE_DEFN_GFXS:
+ p = "Graphics String";
+ break;
+
+ case PE_DEFN_VISS:
+ p = "Visable String";
+ break;
+
+ case PE_DEFN_GENS:
+ p = "General String";
+ break;
+
+ case PE_DEFN_CHRS:
+ p = "Character String";
+ break;
+
+ default:
+ (void) sprintf(buf, "Unknown Universal %d", id);
+ p = buf;
+ break;
+ }
+ return (p);
+}
+/*
+ * Print out the value of a bits string
+ */
+static prntbits(pe)
+PE pe;
+{
+ int len, i;
+
+ if ((len = pe->pe_nbits) < 0) {
+ (void) printf("prntbits:Bad bistring\n");
+ return;
+ }
+ (void) printf("Bits:");
+ for (i = 0; i < len; i++)
+ if (bit_test(pe, i))
+ (void) printf(" %d", i);
+
+ (void) putchar('\n');
+}
+
+/*
+ * Dump a bunch of hex digits printing out those that are printable
+ * Print out a given length of octets as hex (with the ASCII
+ * characters given if they have any
+ */
+static pclen(s, len)
+register char *s;
+register int len;
+{
+ register int cnt = 0;
+
+ while (len-- > 0) {
+ if (cnt % 8 == 0)
+ (void) printf("\n%d:", cnt / 8 + 1);
+ if (isprint(*s & 0x7f))
+ (void) printf("\t%02x(%c)", *s & 0xff, *s & 0x7f);
+ else
+ (void) printf("\t%02x", *s & 0xff);
+ s++;
+ cnt++;
+ }
+ (void) putchar('\n');
+}
+
+/*
+ * print out an octet string
+ */
+static prntos(pe)
+PE pe;
+{
+ struct qbuf *qb;
+
+ if ((qb = prim2qb(pe)) == NULL) {
+bad:
+ (void) printf("prntos:bad octet string\n");
+ return (NOTOK);
+ }
+ if (qb_pullup(qb) == NOTOK)
+ goto bad;
+
+ if (qb->qb_forw->qb_data == NULL || qb->qb_forw->qb_len < 0)
+ goto bad;
+
+ pclen(qb->qb_forw->qb_data, qb->qb_forw->qb_len);
+ return (OK);
+}
+
+/*
+ * print out a string which should be printable
+ */
+static prntstr(pe)
+PE pe;
+{
+ struct qbuf *qb;
+
+ if ((qb = prim2qb(pe)) == NULL) {
+bad:
+ (void) printf("prntstr:bad string\n");
+ return (NOTOK);
+ }
+ if (qb_pullup(qb) == NOTOK)
+ goto bad;
+
+ if (qb->qb_forw->qb_data == NULL || qb->qb_forw->qb_len < 0)
+ goto bad;
+
+ (void) printf("\"%s\"", qb->qb_forw->qb_data);
+ return (OK);
+}
+
+/*
+ * build a link list of struct rep_int containing the speicified number of
+ * elements
+ */
+struct rep_int *
+mkrep_int(cnt)
+int cnt;
+{
+ struct rep_int *hd, *tl, *p;
+
+ for (hd = NULLREP_INT, tl = NULL; cnt-- > 0; ) {
+ if ((p = new(struct rep_int)) == NULLREP_INT)
+ ferr(1, "mkrep_int:malloc failed\n");
+
+ p->i = t_test*cnt + 3;
+ if (tl) {
+ tl->r = p;
+ tl = p;
+ } else
+ hd = tl = p;
+ }
+
+ return (hd);
+}
+
+static char *test_str[] = { "The quick", "brown", "fox jumps over",
+ "The Lazy", "dog", 0 };
+
+/*
+ * build a link list of struct rep_elem containing the speicified number of
+ * elements
+ */
+struct rep_elem *
+mkrep_elem(cnt)
+int cnt;
+{
+ struct rep_elem *hd, *tl, *p;
+ char **str;
+
+ for (str = test_str, hd = NULLREP_ELEM, tl = NULL; cnt-- > 0; ) {
+ if ((p = new(struct rep_elem)) == NULLREP_ELEM)
+ ferr(1, "mkrep_elem:malloc failed\n");
+
+ if (*str == NULLCP)
+ str = test_str;
+
+ p->r_int = t_test + cnt + 3;
+ p->r_ostring = strdup(*str++);
+ p->r_bstring = strdup("1234567890abcdefghijklmnopqrstuvwxyz");
+ if (tl) {
+ tl->r_next = p;
+ tl = p;
+ } else
+ hd = tl = p;
+ }
+
+ return (hd);
+}
+
+/*
+ * return non zero if the to lists are different - also
+ * prints a message about the difference found
+ */
+ri_cmp(p1, p2)
+struct rep_int *p1, *p2;
+{
+ int cnt;
+
+
+ for (cnt = 1; p1 && p2; cnt++) {
+ if (p1->i != p2->i) {
+ (void) printf("ri_cmp: Integers differ in %d item (%d != %d)\n",
+ cnt, p1->i, p2->i);
+ return (1);
+ }
+ p1 = p1->r;
+ p2 = p2->r;
+ }
+ if (p1) {
+ (void) printf("ri_cmp: 1st list has more items (> %d)\n", cnt);
+ return(1);
+ }
+ if (p2) {
+ (void) printf("ri_cmp: 2nd list has more items (> %d)\n", cnt);
+ return(1);
+ }
+
+ return (0);
+}
+
+/*
+ * return non zero if the to lists are different - also
+ * prints a message about the difference found
+ */
+re_cmp(p1, p2)
+struct rep_elem *p1, *p2;
+{
+ int cnt;
+
+
+ for (cnt = 1; p1 && p2; cnt++) {
+ if (p1->r_int != p2->r_int) {
+ (void) printf("re_cmp: Integers differ in %d item (%d != %d)\n",
+ cnt, p1->r_int, p2->r_int);
+ return (1);
+ }
+ if (strcmp(p1->r_ostring, p2->r_ostring)) {
+ (void) printf("re_cmp: strings differ in %d item (%s != %s)\n",
+ cnt, p1->r_ostring, p2->r_ostring);
+ return (1);
+ }
+ if (bitscmp(p1->r_bstring, p2->r_bstring, p1->r_int)) {
+ (void) printf("re_cmp: bit strings differ in %d item\n", cnt);
+ return (1);
+ }
+ p1 = p1->r_next;
+ p2 = p2->r_next;
+ }
+ if (p1) {
+ (void) printf("re_cmp: 1st list has more items (> %d)\n", cnt);
+ return(1);
+ }
+ if (p2) {
+ (void) printf("re_cmp: 2nd list has more items (> %d)\n", cnt);
+ return(1);
+ }
+
+ return (0);
+}
diff --git a/src/isode/pepsy/mine.h b/src/isode/pepsy/mine.h
new file mode 100644
index 000000000..83bb8e7d5
--- /dev/null
+++ b/src/isode/pepsy/mine.h
@@ -0,0 +1,53 @@
+/* mine.h */
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:30:50 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:39:42 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:43:02 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+#define TABLESIZE 29
+
+typedef struct ID_TABLE {
+ char *h_value;
+ char *r_value;
+ int def_bit;
+ int def_value;
+ int count;
+ struct ID_TABLE *next;
+ } id_entry;
+
+typedef struct S_TABLE {
+ char *name;
+ char *type;
+ struct S_TABLE *parent;
+ char *field;
+ int defined;
+ struct S_TABLE *next;
+ } s_table;
+
+extern id_entry *id_table[];
+
+extern char *c_flags();
diff --git a/src/isode/pepsy/mod.c b/src/isode/pepsy/mod.c
new file mode 100644
index 000000000..69d361bb5
--- /dev/null
+++ b/src/isode/pepsy/mod.c
@@ -0,0 +1,173 @@
+/* mod.c */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:30:52 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:39:44 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:43:02 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+#include <stdio.h>
+#include <ctype.h>
+#include "pepsydefs.h"
+#include "pass2.h"
+
+extern char *sysin;
+extern char *proc_name();
+extern char *my_strcat();
+
+char *calc_arg();
+
+#define MAXLENGTH 30
+
+#ifdef notdef
+/*
+ * output each of the actions associated with yp
+ */
+do_sw_type(name, yp, fp, fpa)
+char *name;
+YP yp;
+FILE *fp;
+FILE *fpa;
+{
+ char *s;
+ char *arg;
+
+ s = proc_name(name, 0);
+ if (yp->yp_action1) {
+ (void) fprintf(fp, "\t\tcase %s%s:\n", s, ACT1);
+ arg = calc_arg(yp, 1);
+ my_do_action(fp, yp->yp_action1, 0, arg, yp->yp_act1_lineno, yp->yp_param_type);
+ (void) fprintf(fp, "\t\t\tbreak;\n");
+ }
+ if (yp->yp_action2) {
+ (void) fprintf(fp, "\t\tcase %s%s:\n", s, ACT2);
+ arg = calc_arg(yp, 2);
+ my_do_action(fp, yp->yp_action2, 0, arg, yp->yp_act2_lineno, yp->yp_param_type);
+ (void) fprintf(fp, "\t\t\tbreak;\n");
+ }
+ if (yp->yp_action05) {
+ (void) fprintf(fp, "\t\tcase %s%s:\n", s, ACT05);
+ arg = calc_arg(yp, 5);
+ my_do_action(fp, yp->yp_action05, 0, arg, yp->yp_act05_lineno, yp->yp_param_type);
+ (void) fprintf(fp, "\t\t\tbreak;\n");
+ }
+}
+#endif
+
+my_do_action(fp, action, level, arg, lineno, new)
+FILE *fp;
+char *action;
+int level;
+char *arg;
+int lineno;
+char *new;
+{
+ int i;
+ char t[MAXLENGTH];
+ char c, d;
+
+ (void) fprintf(fp, "%*s{\n", level * 4, "");
+ Printf(4, ("\n"));
+
+ if (*sysin)
+ (void) fprintf(fp, "# line %d \"%s\"\n", lineno, sysin);
+
+ for (d = NULL; c = *action; d = c, action++) {
+ Printf(4, ("open char is %c\n", *action));
+ for (i = 0; i < MAXLENGTH - 1 && (isalpha(*action) || *action == '_'); action++, i++)
+ t[i] = *action;
+ t[i] = '\0';
+ Printf(4, ("WORD IS %s, %c, %d\n", t, *action, i));
+ if (strcmp(t, "")) {
+ if (!strcmp(t, "parm"))
+ (void) fprintf(fp, "(%s)%s", new, "parm");
+ else
+ (void) fprintf(fp, "%s", t);
+ c = *(action - 1);
+ action--;
+ continue;
+ /*
+ * OR d = *(action - 1); c = *action;
+ */
+ }
+ switch (d) {
+ case '$':
+ if (c == '$') {
+ (void) fprintf(fp, "%s", arg);
+ c = NULL;
+ break;
+ }
+ (void) fputc('$', fp); /* fall */
+
+ default:
+ if (c != '$')
+ (void) fputc(c, fp);
+ break;
+ }
+ }
+
+ switch (d) {
+ case '\n':
+ break;
+
+ case '$':
+ (void) fputc('$', fp); /* fall */
+ default:
+ (void) fputc('\n', fp);
+ break;
+ }
+
+ (void) fprintf(fp, "%*s}\n", level * 4, "");
+}
+
+char *
+calc_arg(yp, actno)
+YP yp;
+int actno;
+{
+
+ switch (actno) {
+ case 1:
+ return "";
+
+ case 2:
+ if (yp->yp_direction & YP_ENCODER)
+ return "(pe)";
+ else
+ return "(pe)";
+
+ case 5:
+ if (yp->yp_direction & YP_ENCODER)
+ return "";
+ else
+ return "(pe)";
+ default:
+ return "";
+ }
+}
diff --git a/src/isode/pepsy/pass2.c b/src/isode/pepsy/pass2.c
new file mode 100644
index 000000000..84b7a57d2
--- /dev/null
+++ b/src/isode/pepsy/pass2.c
@@ -0,0 +1,1524 @@
+/* pass2.c */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:30:54 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.2 1994/06/07 23:10:07 eichin
+ * KLUDGE XXX static forward decl for AIX
+ *
+ * Revision 1.1 1994/05/31 20:39:46 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:43:03 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+#include <stdio.h>
+#include <ctype.h>
+#include "pepsydefs.h"
+#include "pass2.h"
+#include "mine.h"
+#include "sym.h"
+
+extern int doexternals;
+extern int sflag, mflag, fflag, Cflag;
+
+extern char *eval;
+
+extern int Aflag;
+extern SY mysymbols;
+extern char *modsym(), *gfree();
+extern char *my_strcat();
+extern char *notidtoid();
+extern char *rm_indirect();
+extern char *getid();
+extern char *getidordot();
+extern char *getfield();
+extern char *sym2type();
+extern YP lookup_type();
+extern MD lookup_module ();
+
+char *tab; /* mymodule - with - changed to _ */
+
+Action start_action, final_action;
+int e_actions, d_actions, p_actions; /* number of actions of each type */
+
+FILE *ffopen();
+
+peri_pass2()
+{
+ char *inc; /* *_pre_defs.h file */
+
+ if (!sflag)
+ (void) fflush(stderr);
+
+ tab = notidtoid(mymodule);
+
+ if (strcmp(mymodule, "UNIV"))
+ (void) lookup_module("UNIV", NULLOID);
+
+ inc = my_strcat (mymodule, HFILE2);
+
+ gen_typesfile(inc);
+
+ gen_tablefile(inc);
+
+}
+static int ptr_cnt = 0;
+/*
+ * generate the table file which contains:
+ * #include types file
+ * #include - types files for other (external) modules referenced
+ * definitions of data structures used: strings and stuff for defaults
+ * declaractions of functions referenced.
+ * tpe tables - one per type assignment for each of
+ * encoding, decoding and printing
+ * tables of pointers to all the above tpe tables - one for
+ * type of tpe table
+ * pointer table - used to hold pointers as tpe table cannot
+ * hold pointers but only integers which index into this table
+ * module definition - the key to all the data structures os this
+ * module. contains references to all the tables.
+ * lint declaractions for the "pepy" functions
+ */
+gen_tablefile(inc)
+char *inc;
+{
+
+ int nentries;
+ int encflag = 1, decflag = 1, prntflag = 1;
+ SY sy;
+ YP yp;
+ FILE *fphh, *fptab;
+
+ fptab = ffopen(my_strcat(mymodule, TBLNAME)); /* thing_tables.c */
+
+ /* Only need two files <stdio.h> and our types file which includes
+ * everything else we need
+ * Assumption. types file in the same directory as the _tables
+ */
+ (void) fprintf(fptab, "#include <stdio.h>\n");
+ (void) fprintf(fptab, "#include \"%s%s\"\n\n", mymodule, GENTYPES);
+
+ if (start_action) {
+ (void) fprintf (fptab, "\n# line %d \"%s\"\n",
+ start_action->a_line ? start_action->a_line : 1,
+ sysin);
+ fputs (start_action->a_data, fptab);
+ }
+#ifdef _AIX
+ (void) fprintf (fptab, "\nstatic caddr_t %s%s%s[%d];\t/* aix forward decl*/\n",
+ PREFIX, PTR_TABNAME, tab, 100+ptr_cnt);
+#else
+ (void) fprintf (fptab, "\nextern caddr_t %s%s%s[];\t/* forward decl */\n",
+ PREFIX, PTR_TABNAME, tab);
+#endif
+ /*
+ * loop through and generate all the default values definitions
+ * and what ever else needs to be processed for all the entries
+ * e.g. external module references and coding function declarations
+ */
+ for (sy = mysymbols; sy; sy = sy->sy_next) {
+ yp = sy->sy_type;
+ if (yp->yp_flags & YP_IMPORTED)
+ continue;
+ if (yp->yp_direction & (YP_ENCODER | YP_DECODER | YP_PRINTER)
+ || Aflag) {
+ gen_dflts(fptab, sy->sy_type, sy->sy_name);
+ }
+ }
+
+ (void) fprintf(fptab, "\n#define OFFSET(t,f)\t((int ) &(((t *)0)->f))\n\n");
+#ifndef hpux
+ (void) fprintf(fptab, "\n#define AOFFSET(t,f)\t((int ) (((t *)0)->f))\n\n");
+#else
+ (void) fprintf(fptab, "\n#define AOFFSET(t,f)\t((int ) &(((t *)0)->f[0]))\n\n");
+#endif
+ nentries = 0;
+ /*
+ * generate tpe tables
+ */
+ for (sy = mysymbols; sy; sy = sy->sy_next) {
+ yp = sy->sy_type;
+ if (yp->yp_flags & YP_IMPORTED)
+ continue;
+ if (yp->yp_direction & YP_ENCODER || Aflag) {
+ nentries++;
+ gen_enctbl(fptab, sy);
+ }
+ }
+ for (sy = mysymbols; sy; sy = sy->sy_next) {
+ yp = sy->sy_type;
+ if (yp->yp_flags & YP_IMPORTED)
+ continue;
+ if (yp->yp_direction & YP_DECODER || Aflag)
+ gen_dectbl(fptab, sy);
+ }
+
+ for (sy = mysymbols; sy; sy = sy->sy_next) {
+ yp = sy->sy_type;
+ if (yp->yp_flags & YP_IMPORTED)
+ continue;
+ if (yp->yp_direction & YP_PRINTER || Aflag)
+ gen_prnttbl(fptab, sy);
+ }
+
+ fphh = ffopen(inc); /* thing_pre_defs.h */
+ (void) fprintf(fphh, "\nextern modtyp %s%s%s;\n",
+ PREFIX, tab, MODTYP_SUFFIX);
+ out_final_defs(fphh);
+ if (fclose(fphh) == EOF) {
+ fprintf (stderr, "Write error to file");
+ perror (inc);
+ exit (1);
+ }
+
+ gen_actfunct(fptab);
+
+ gen_tpe(fptab); /* generate table of pointers to tpe tables */
+
+ gen_modtype(fptab, nentries, encflag, decflag, prntflag);
+
+ if (final_action) {
+ (void) fprintf (fptab, "\n# line %d \"%s\"\n",
+ final_action->a_line ? final_action->a_line : 1,
+ sysin);
+ fputs (final_action->a_data, fptab);
+ }
+
+ gen_lint(fptab);
+
+ if(fclose(fptab) == EOF) {
+ fprintf (stderr, "Write error to file");
+ perror ("");
+ exit (1);
+ }
+}
+
+/*
+ * generate the *-types.h file
+ */
+gen_typesfile(inc)
+char *inc;
+{
+ char *buf;
+#ifdef ACT_CODE
+ int encflag = 1, decflag = 1, prntflag = 1;
+ char *act;
+ FILE *fpe, *fpd, *fpp, *fpa;
+#endif
+ SY sy;
+ YP yp;
+ FILE *fph;
+
+ fph = ffopen(my_strcat(mymodule, HFILE1)); /* thing_defs.h */
+ if (!Cflag) {
+ if (mflag) {
+ (void) fprintf (fph, "#ifndef\tPEPYPATH\n");
+ (void) fprintf (fph, "#include <isode/pepsy/%s>\n", inc);
+ (void) fprintf (fph, "#else\n");
+ (void) fprintf (fph, "#include \"%s\"\n", inc);
+ (void) fprintf (fph, "#endif\n\n\n");
+ }
+ else {
+ if (is_stand (inc))
+ (void) fprintf (fph, "#include <isode/pepsy/%s>\n", inc);
+ else
+ (void) fprintf (fph, "#include \"%s\"\n", inc);
+ }
+ }
+
+#ifdef ACT_CODE
+ act = my_strcat(mymodule, ACTIONDEFS);
+
+ fpe = ffopen(my_strcat(mymodule, ENCFILENAME));
+ file_header(fpe, act);
+ fpd = ffopen(my_strcat(mymodule, DECFILENAME));
+ file_header(fpd, act);
+ fpp = ffopen(my_strcat(mymodule, PRNTFILENAME));
+ file_header(fpp, act);
+ fpa = ffopen(act);
+#endif
+
+ /* define the macros to support posy functions */
+
+ fprintf(fph, "\n#ifndef\tlint\n");
+ for (sy = mysymbols; sy; sy = sy->sy_next) {
+ eval = sy->sy_name;
+ yp = sy->sy_type;
+
+ if (sy->sy_module == NULLCP)
+ yyerror("no module name associated with symbol");
+ if (yp->yp_flags & YP_IMPORTED)
+ continue;
+ if (strcmp(sy->sy_module, mymodule)) {
+ fprintf(stderr, "mymodule unsuitable for module name e.g %s and %s(mymodule)\n", sy->sy_module, mymodule);
+ exit(1);
+ }
+ if (yp->yp_direction & YP_ENCODER || Aflag) {
+ buf = modsym (sy -> sy_module, sy -> sy_name, yyencdflt);
+ fprintf(fph, "#define %s", buf);
+ fprintf(fph, "(pe, top, len, buffer, parm) \\\n");
+ fprintf(fph, " %s(%s%s, ", ENCFNCNAME, PREFIX, proc_name(sy->sy_name, 1));
+ fprintf(fph, "&%s%s%s, ", PREFIX, tab, MODTYP_SUFFIX);
+ fprintf(fph, "pe, top, len, buffer, (char *) parm)\n\n");
+#ifdef ACT_CODE
+ if (encflag) {
+ fprintf(fpe, "%s%s", ENC_FNCNAME, tab);
+ open_func(fpe);
+ encflag--;
+ }
+#endif
+ if (bflag)
+ init_new_file();
+ if (bflag)
+ end_file();
+ }
+ if (yp->yp_direction & YP_DECODER || Aflag) {
+ buf = modsym (sy -> sy_module, sy -> sy_name, yydecdflt);
+ if (bflag)
+ init_new_file();
+ fprintf(fph, "#define %s", buf);
+ fprintf(fph, "(pe, top, len, buffer, parm) \\\n");
+ fprintf(fph, " %s(%s%s, ", DECFNCNAME, PREFIX, proc_name(sy->sy_name, 1));
+ fprintf(fph, "&%s%s%s, ", PREFIX, tab, MODTYP_SUFFIX);
+ fprintf(fph, "pe, top, len, buffer, (char **) parm)\n\n");
+#if ACT_CODE
+ if (decflag) {
+ fprintf(fpd, "%s%s", DEC_FNCNAME, tab);
+ open_func(fpd);
+ decflag--;
+ }
+#endif
+ if (bflag)
+ end_file();
+ }
+ if (yp->yp_direction & YP_PRINTER || Aflag) {
+ buf = modsym (sy -> sy_module, sy -> sy_name, yyprfdflt);
+ if (bflag)
+ init_new_file();
+ fprintf(fph, "#define %s", buf);
+ fprintf(fph, "(pe, top, len, buffer, parm) \\\n");
+ fprintf(fph, " %s(%s%s, ", PRNTFNCNAME, PREFIX, proc_name(sy->sy_name, 1));
+ fprintf(fph, "&%s%s%s, ", PREFIX, tab, MODTYP_SUFFIX);
+ fprintf(fph, "pe, top, len, buffer)\n");
+ fprintf(fph, "#define %s_P", buf);
+ fprintf(fph, " %s%s, ", PREFIX,
+ proc_name(sy->sy_name, 1));
+ fprintf(fph, "&%s%s%s\n\n", PREFIX, tab, MODTYP_SUFFIX);
+#ifdef ACT_CODE
+ if (prntflag) {
+ fprintf(fpp, "%s%s", PRNT_FNCNAME, tab);
+ open_func(fpp);
+ prntflag--;
+ }
+#endif
+ if (bflag)
+ end_file();
+ }
+ if (!bflag && ferror(stdout))
+ myyerror("write error - %s", sys_errname(errno));
+ }
+ fprintf(fph, "\n#endif /* lint */\n");
+
+#ifdef ACT_CODE
+ if (!encflag) {
+ close_func(fpe);
+ }
+ if (!decflag) {
+ close_func(fpd);
+ }
+ if (!prntflag) {
+ close_func(fpp);
+ }
+#endif
+
+ if (fclose(fph) == EOF) {
+ fprintf (stderr, "Write error to file");
+ perror ("");
+ exit (1);
+ }
+#ifdef ACT_CODE
+ fclose(fpe);
+ fclose(fpd);
+ fclose(fpp);
+ fclose(fpa);
+#endif
+}
+
+
+gen_enctbl(fp, sy)
+FILE *fp;
+SY sy;
+{
+ YP yp;
+
+ yp = sy->sy_type;
+ fprintf(fp,"static tpe %s%s[] = {\n", ETABLE, proc_name(sy->sy_name, 0));
+ fprintf(fp, "\t{ PE_START, 0, 0, 0 },\n");
+
+ tenc_typ(fp, yp, sy->sy_name, NULLCP);
+
+ fprintf(fp, "\t{ PE_END, 0, 0, 0 }\n");
+ fprintf(fp, "\t};\n");
+ fprintf(fp, "\n");
+}
+
+gen_dectbl(fp, sy)
+FILE *fp;
+SY sy;
+{
+ fprintf(fp,"static tpe %s%s[] = {\n", DTABLE, proc_name(sy->sy_name, 0));
+ fprintf(fp, "\t{ PE_START, 0, 0, 0 },\n");
+
+ tdec_typ(fp, sy->sy_type, sy->sy_name, NULLCP);
+
+ fprintf(fp, "\t{ PE_END, 0, 0, 0 }\n");
+ fprintf(fp, "\t};\n");
+ fprintf(fp, "\n");
+}
+
+
+gen_prnttbl(fp, sy)
+FILE *fp;
+SY sy;
+{
+ fprintf(fp,"static ptpe %s%s[] = {\n",PTABLE, proc_name(sy->sy_name, 0));
+ fprintf(fp, "\t{ PE_START, 0, 0, 0, (char **)&%s%s%s[%d] },\n",
+ PREFIX, PTR_TABNAME, tab, addsptr(sy->sy_name));
+
+ tprnt_typ(fp, sy->sy_type, sy->sy_name, NULLCP);
+
+ fprintf(fp, "\t{ PE_END, 0, 0, 0, NULLVP }\n");
+ fprintf(fp, "\t};\n");
+ fprintf(fp, "\n");
+}
+
+
+/*
+ * define the tpe index tables and the pointer table
+ */
+gen_tpe(fp)
+FILE *fp;
+{
+ SY sy;
+ int empty = 1;
+
+ fprintf(fp, "static tpe *etabl[] = {\n");
+ for (sy = mysymbols; sy; sy = sy->sy_next) {
+ if (sy->sy_type->yp_flags & YP_IMPORTED)
+ continue;
+ if (sy->sy_type->yp_direction & YP_ENCODER || Aflag) {
+ fprintf(fp, "\t%s%s,\n", ETABLE, proc_name(sy->sy_name, 0));
+ empty = 0;
+ }
+ }
+ if (empty)
+ fprintf(fp, "\t0,\n");
+ fprintf(fp, "\t};\n\n");
+ empty = 1;
+
+ fprintf(fp, "static tpe *dtabl[] = {\n");
+ for (sy = mysymbols; sy; sy = sy->sy_next) {
+ if (sy->sy_type->yp_flags & YP_IMPORTED)
+ continue;
+ if (sy->sy_type->yp_direction & YP_DECODER || Aflag) {
+ fprintf(fp, "\t%s%s,\n", DTABLE, proc_name(sy->sy_name, 0));
+ empty = 0;
+ }
+ }
+ if (empty)
+ fprintf(fp, "\t0,\n");
+ fprintf(fp, "\t};\n\n");
+ empty = 1;
+
+ fprintf(fp, "static ptpe *ptabl[] = {\n");
+ for (sy = mysymbols; sy; sy = sy->sy_next) {
+ if (sy->sy_type->yp_flags & YP_IMPORTED)
+ continue;
+ if (sy->sy_type->yp_direction & YP_PRINTER || Aflag) {
+ fprintf(fp, "\t%s%s,\n", PTABLE, proc_name(sy->sy_name, 0));
+ empty = 0;
+ }
+ }
+ if (empty)
+ fprintf(fp, "\t0,\n");
+ fprintf(fp, "\t};\n\n");
+
+ /* produce pointer table */
+ dump_ptrtab(fp);
+}
+
+/*
+ * output the module structure for this module
+ */
+gen_modtype(fp, no, f1, f2, f3)
+FILE *fp;
+int no;
+int f1, f2, f3;
+{
+ if (!f1)
+ fprintf(fp, "extern PE\t%s%s();\n", ENC_FNCNAME, tab);
+ if (!f2)
+ fprintf(fp, "extern PE\t%s%s();\n", DEC_FNCNAME, tab);
+ if (!f3)
+ fprintf(fp, "extern PE\t%s%s();\n", PRNT_FNCNAME, tab);
+ fprintf(fp, "\n");
+ fprintf(fp, "modtyp %s%s%s = {\n", PREFIX, tab, MODTYP_SUFFIX);
+ fprintf(fp, "\t\"%s\",\n", mymodule); /* name */
+ fprintf(fp, "\t%d,\n", no); /* number of entries */
+ /* coding tables */
+ fprintf(fp, "\tetabl,\n");
+ fprintf(fp, "\tdtabl,\n");
+ fprintf(fp, "\tptabl,\n");
+ /* action tables */
+ if (e_actions > 0)
+ fprintf(fp, "\tefn_%s,\n", tab);
+ else
+ fprintf(fp, "\t0,\n"); /* no action code */
+
+ if (d_actions > 0)
+ fprintf(fp, "\tdfn_%s,\n", tab);
+ else
+ fprintf(fp, "\t0,\n"); /* no action code */
+
+ if (p_actions > 0)
+ fprintf(fp, "\tpfn_%s,\n", tab);
+ else
+ fprintf(fp, "\t0,\n"); /* no action code */
+
+ fprintf(fp, "\t%s%s%s,\n", PREFIX, PTR_TABNAME, tab);
+ fprintf(fp, "\t};\n\n");
+}
+
+/*
+ * open a file called name
+ */
+FILE *
+ffopen(name)
+char *name;
+{
+ FILE *fp;
+
+ if ((fp = fopen(name, "w")) == NULL) {
+ fprintf(stderr, "Can't create the file %s", name);
+ exit(1);
+ }
+ return fp;
+}
+
+#ifdef ACT_CODE
+/*
+ * output the file prologue to the file specified by fp
+ */
+file_header(fp, act)
+FILE *fp;
+char *act;
+{
+ fprintf(fp, "#include %s\n", PSAP_DOT_H);
+ fprintf(fp, "#include \"%s\"\n", INCFILE1);
+ fprintf(fp, "#include \"%s\"\n", act);
+ fprintf(fp, "#include \"%s%s\"\n\n", mymodule, GENTYPES);
+ fprintf(fp, "#ifndef PEPYPARM\n");
+ fprintf(fp, "#define PEPYPARM char *\n");
+ fprintf(fp, "#endif\n");
+ fprintf(fp, "extern PEPYPARM NullParm;\n\n");
+}
+
+#endif
+
+/*
+ * output the function prologue to the file specified by fp
+ */
+open_func(fp)
+FILE *fp;
+{
+
+ fprintf(fp, "(pe, parm, p, mod)\n");
+ fprintf(fp, "PE\tpe;\n");
+ fprintf(fp, "PEPYPARM\tparm;\n");
+ fprintf(fp, "tpe\t*p;\n");
+ fprintf(fp, "modtyp\t*mod;\n");
+ fprintf(fp, "{\n");
+ /* action 0 ???? */
+ fprintf(fp, "\tswitch (p->pe_ucode) {\n");
+}
+
+/*
+ * output the function epilogue to the file specified by fp
+ */
+close_func(fp)
+FILE *fp;
+{
+ fprintf(fp, "\t\tdefault:\n");
+ fprintf(fp, "\t\t\tbreak;\n");
+ fprintf(fp, "\t}\n");
+ fprintf(fp, "\treturn OK;\n}\n\n");
+}
+
+/*
+ * print the table id_table
+ */
+print_table()
+{
+ int i;
+ id_entry *t;
+
+ for (i = 0; i < TABLESIZE; i++) {
+ for (t = id_table[i]; t != NULL; t = t->next)
+ (void) printf("%s(%d) --> ", t->r_value, t->def_value);
+ if (id_table[i] != NULL)
+ (void) printf("NULL -- %d\n", i);
+ }
+}
+static struct univ_typ univ_tab[] = {
+ {"EXTERNAL", "struct type_UNIV_EXTERNAL *", "EXTERNAL", 8, 0,
+ "UNIV", UNF_EXTMOD|UNF_HASDATA, YP_SEQLIST, },
+ {"GeneralString", "struct qbuf *", "OCTETSTRING", 27, 0,
+ "UNIV", 0, YP_OCT, },
+ {"GeneralisedTime", "struct qbuf *", "OCTETSTRING", 24, 0,
+ "UNIV", 0, YP_OCT, },
+ {"GeneralizedTime", "struct qbuf *", "OCTETSTRING", 24, 0,
+ "UNIV", 0, YP_OCT, },
+ {"GraphicString", "struct qbuf *", "OCTETSTRING", 25, 0,
+ "UNIV", 0, YP_OCT, },
+ {"IA5String", "struct qbuf *", "OCTETSTRING", 22, 0,
+ "UNIV", 0, YP_OCT, },
+ {"ISO646String", "struct qbuf *", "OCTETSTRING", 26, 0,
+ "UNIV", 0, YP_OCT, },
+ {"NumericString", "struct qbuf *", "OCTETSTRING", 18, 0,
+ "UNIV", 0, YP_OCT, },
+ {"PrintableString", "struct qbuf *", "OCTETSTRING", 19, 0,
+ "UNIV", 0, YP_OCT, },
+ {"TeletexString", "struct qbuf *", "OCTETSTRING", 20, 0,
+ "UNIV", 0, YP_OCT, },
+ {"T61String", "struct qbuf *", "OCTETSTRING", 20, 0,
+ "UNIV", 0, YP_OCT, },
+ {"UTCTime", "struct qbuf *", "OCTETSTRING", 23, 0,
+ "UNIV", 0, YP_OCT, },
+ {"UniversalTime", "struct qbuf *", "OCTETSTRING", 23, 0,
+ "UNIV", 0, YP_OCT, },
+ {"VideotexString", "struct qbuf *", "OCTETSTRING", 21, 0,
+ "UNIV", 0, YP_OCT, },
+ {"VisibleString", "struct qbuf *", "OCTETSTRING", 26, 0,
+ "UNIV", 0, YP_OCT, },
+};
+
+extern struct univ_typ *simptyp();
+
+/*
+ * Determine wether the type name matches one of the Universal types
+ * which are to be treated specially. If so return a pointer to the
+ * data structure which contains the parameters describing how it
+ * should be processed
+ */
+struct univ_typ *
+univtyp(name)
+char *name;
+{
+ int low, high, i;
+ struct univ_typ *p;
+
+ low = 0;
+ high = NENTRIES(univ_tab) - 1;
+ while (low <= high) {
+ p = univ_tab + (low + high) / 2;
+ if ((i = scmp(name, p->univ_name)) == 0)
+ return (p);
+ if (low == high)
+ return (NULL);
+ if (i < 0)
+ high = p - univ_tab - 1;
+ else
+ low = p - univ_tab + 1;
+ }
+
+#if OPTIMISED
+ if ((p = simptyp(name)) == NULL)
+ return (p);
+#endif
+
+ return (NULL);
+}
+
+/*
+ * Compare two strings returning a number representing the character
+ * where they differ or 0 if are the same - I wrote this because I
+ * couldn't trust strcmp to work the same way between numbers and
+ * letters everywhere. longer strings are greater shorter strings
+ * numbers are greater then all letters lower case are greater then
+ * upper case There must be a better way !
+ */
+scmp(s1, s2)
+char *s1, *s2;
+{
+ while (*s1 == *s2 && *s2)
+ s1++, s2++;
+ if (*s1 == '\0' && *s2 == '\0')
+ return (0);
+ if (*s1 == '\0')
+ return (-1);
+ if (*s2 == '\0')
+ return (1);
+ if (isalpha(*s1) && isalpha(*s2)) {
+ if (isupper(*s1) && isupper(*s2))
+ return (*s1 - *s2);
+ if (islower(*s1) && islower(*s1))
+ return (*s1 - *s2);
+ if (isupper(*s1))
+ return (-1);
+ if (islower(*s1))
+ return (1);
+ }
+ if (isdigit(*s1) && isdigit(*s2))
+ return (*s1 - *s2);
+ if (isdigit(*s1))
+ return (1);
+ if (isdigit(*s2))
+ return (-1);
+ return (*s1 - *s2);
+}
+
+/*
+ * lookup a symbol and return a pointer to it
+ */
+SY
+syfind(name)
+char *name;
+{
+ SY sy;
+
+ for (sy = mysymbols; sy; sy = sy->sy_next) {
+ if (sy->sy_type->yp_flags & YP_IMPORTED)
+ continue;
+ if (strcmp(name, sy->sy_name) == 0)
+ return (sy);
+ }
+ return (NULL);
+}
+#if OPTIMISED
+/*
+ * determine if the symbol is a simple type that is optimised
+ */
+struct univ_typ *
+simptyp(yp)
+YP yp;
+{
+ struct univ_typ *p;
+
+ static struct univ_typ bitstring =
+ {"Bitstring", "struct PElement *", "BITSTRING", 3, 0},
+ octetstring =
+ {"GeneralString", "struct qbuf *", "OCTETSTRING", 4, 0},
+ oid =
+ {"Object Identifier", "struct OIDentifier *", "OBJIDENT", 6, 0},
+ obj =
+ {"Module", "struct OIDentifier *",
+ "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 27, 0};
+
+#define MSTRING 30 /* number of Xs in the above string */
+
+ switch (yp->yp_code) {
+ case YP_BIT:
+ case YP_BITLIST:
+ return (&bitstring);
+
+ case YP_SEQ:
+ case YP_SET:
+ case YP_ANY:
+ return (&bitstring);
+
+ case YP_OCT:
+ return (&octetstring);
+
+ case YP_OID:
+ return (&oid);
+
+ case YP_IDEFINED:
+ (void) strncpy(p->univ_tab, yp->yp_identifier, MSTRING);
+ return (&obj);
+
+
+ case YP_SEQLIST:
+ case YP_SETLIST:
+ case YP_CHOICE:
+
+ default:
+ return (NULL);
+ }
+}
+#endif
+
+/*
+ * lookup a type name until you get something that is not a name
+ */
+YP
+lkup(yp)
+YP yp;
+{
+ YP yp1;
+
+ if (yp == NULLYP)
+ return (yp);
+
+ while (yp->yp_code == YP_IDEFINED) {
+ if ((yp1 = lookup_type(yp->yp_module, yp->yp_identifier)) == NULLYP)
+ return (yp);
+ yp = yp1;
+ }
+
+ return (yp);
+}
+/*
+ * compute the type of tag it should be given the tag and the type it is
+ * being applied to
+ */
+comptag(tag, yp)
+int tag;
+YP yp;
+{
+ static int warned = 0;
+ YP yp1;
+ struct univ_typ *p;
+ int code;
+
+ if (tag == 0)
+ return (0);
+
+ yp1 = lkup(yp);
+
+ if (yp1->yp_code == YP_IDEFINED) {
+ if ((p = univtyp(yp1->yp_identifier)) == NULL
+ || p->univ_type <= YP_UNDF) {
+ switch (chkil(yp1->yp_identifier)) {
+ case ER_NORMAL:
+ return (tag);
+
+ case ER_EXPLICIT:
+ return (0);
+
+ default:
+ break;
+ }
+
+ if (warned++ <= 3) {
+ ferrs(0, "\ncomptag:warning implicit tag of unknown type %s\n",
+ yp1->yp_identifier);
+ ferr(0, "\tcomptag:treated as implicit\n");
+ }
+ return (tag);
+ }
+ code = p->univ_type;
+ } else {
+ code = yp1->yp_code;
+ if (code == YP_ANY && yp1->yp_flags & YP_WANTIMPLICIT)
+ return (tag);
+ }
+
+ if (code == YP_CHOICE || code == YP_ANY)
+ return (0);
+
+ return (tag);
+}
+
+/*
+ * Generate function definitions for all the macros so that lint
+ * can type check all their uses
+ */
+gen_lint(fp)
+FILE *fp;
+{
+ char *buf;
+ SY sy;
+ YP yp;
+
+ fprintf(fp, "\n#if\tdefined(lint) || defined(PEPSY_LINKABLE_FUNCS)\n");
+ for (sy = mysymbols; sy; sy = sy->sy_next) {
+ eval = sy->sy_name;
+ yp = sy->sy_type;
+
+ if (sy->sy_module == NULLCP)
+ yyerror("no module name associated with symbol");
+ if (yp->yp_flags & YP_IMPORTED)
+ continue;
+ if (strcmp(sy->sy_module, mymodule)) {
+ fprintf(stderr,
+ "mymodule unsuitable for module name e.g %s and %s(mymodule)\n",
+ sy->sy_module, mymodule);
+ exit(1);
+ }
+ if (yysection & YP_ENCODER) {
+ /* Encoding routine */
+ buf = modsym (sy -> sy_module, sy -> sy_name, yyencdflt);
+ fprintf(fp, "\n#undef %s\n", buf);
+ fprintf(fp, "int %s", buf);
+ fprintf(fp, "(pe, top, len, buffer, parm)\n");
+ fprintf(fp, "PE *pe;\n");
+ fprintf(fp, "int\ttop,\n\tlen;\n");
+ fprintf(fp, "char *buffer;\n");
+ fprintf(fp, "%s *parm;\n", sym2type(sy));
+ fprintf(fp, "{\n return (%s(%s%s, ",
+ ENCFNCNAME, PREFIX, proc_name(sy->sy_name, 1));
+ fprintf(fp, "&%s%s%s, ", PREFIX, tab, MODTYP_SUFFIX);
+ fprintf(fp, "pe, top, len, buffer,\n\t\t(char *) parm));\n}\n");
+ }
+
+ if (yysection & YP_DECODER) {
+ /* Decoding routine */
+ buf = modsym (sy -> sy_module, sy -> sy_name, yydecdflt);
+ fprintf(fp, "\n#undef %s\n", buf);
+ fprintf(fp, "int %s", buf);
+ fprintf(fp, "(pe, top, len, buffer, parm)\n");
+ fprintf(fp, "PE\tpe;\n");
+ fprintf(fp, "int\ttop,\n *len;\n");
+ fprintf(fp, "char **buffer;\n");
+ fprintf(fp, "%s **parm;\n", sym2type(sy));
+ fprintf(fp, "{\n return (%s(%s%s, ",
+ DECFNCNAME, PREFIX, proc_name(sy->sy_name, 1));
+ fprintf(fp, "&%s%s%s, ", PREFIX, tab, MODTYP_SUFFIX);
+ fprintf(fp, "pe, top, len, buffer,\n\t\t(char **) parm));\n}\n");
+ }
+
+ if (yysection & YP_PRINTER) {
+ /* Printing routine */
+ buf = modsym (sy -> sy_module, sy -> sy_name, yyprfdflt);
+ fprintf(fp, "\n#undef %s\n/* ARGSUSED */\n", buf);
+ fprintf(fp, "int %s", buf);
+ fprintf(fp, "(pe, top, len, buffer, parm)\n");
+ fprintf(fp, "PE\tpe;\n");
+ fprintf(fp, "int\ttop,\n *len;\n");
+ fprintf(fp, "char **buffer;\n");
+ fprintf(fp, "%s *parm;\n", sym2type(sy));
+ fprintf(fp, "{\n return (%s(%s%s, ",
+ PRNTFNCNAME, PREFIX, proc_name(sy->sy_name, 1));
+ fprintf(fp, "&%s%s%s, ", PREFIX, tab, MODTYP_SUFFIX);
+ fprintf(fp, "pe, top, len, buffer));\n}\n");
+ }
+
+ if (!fflag)
+ continue;
+
+ switch(yp->yp_code) {
+ /* see do_struct1 in pepsy.c for this list */
+ case YP_BIT:
+ case YP_BITLIST:
+ case YP_SEQ:
+ case YP_SET:
+ case YP_ANY:
+
+ case YP_OCT:
+ case YP_OID:
+ continue; /* these are all #defined... */
+ }
+
+ /* Free routine */
+ buf = modsym (sy -> sy_module, sy -> sy_name, "free");
+ fprintf(fp, "\n#undef %s\n", buf);
+ fprintf(fp, "void %s(val)\n", buf);
+ fprintf(fp, "%s *val;\n", sym2type(sy));
+ fprintf(fp, "{\n");
+ fprintf(fp, "%s;\n", gfree(sy->sy_module, sy->sy_name, "val"));
+ fprintf(fp, "}\n");
+
+ }
+
+ fprintf(fp, "\n#endif\t/* lint||PEPSY_LINKABLE_FUNCS */\n");
+
+ if (ferror(fp))
+ myyerror("write error - %s", sys_errname(errno));
+}
+
+/*
+ * pointer table support routines
+ */
+static char **ptr_tab; /* reference of the pointer */
+/* static int ptr_cnt = 0; */
+static int ptr_max = 0;
+/*
+ * add the given pointer to the pointer table and return its index
+ */
+addptr(p)
+char *p;
+{
+ int ind;
+ register int i;
+ register char *s;
+
+ /*
+ * try to eliminate common pointers by returning a ponter if it matches
+ * previously
+ */
+ for (i = 0; i < ptr_cnt; i++)
+ if (strcmp(p, ptr_tab[i]) == 0)
+ return (i);
+
+ if (ptr_max <= ptr_cnt) {
+ if (ptr_max == 0)
+ ptr_tab = (char **) malloc ((unsigned)sizeof(char **) * (ptr_max = 100));
+ else
+ ptr_tab = (char **) realloc ((char *)ptr_tab, (unsigned)sizeof(char **) * (ptr_max *= 2));
+ }
+ if (ptr_tab == NULL) {
+ fprintf(stderr, "\npointer table out of memeory (%d needed)\n",
+ ptr_cnt);
+ exit(1);
+ }
+
+ if ((s = malloc ((unsigned) (strlen (p) + 1))) == NULLCP) {
+ fprintf(stderr, "\naddptr:out of memory\n");
+ exit(1);
+ }
+ (void) strcpy (s, p);
+
+ ptr_tab[ind = ptr_cnt++] = s;
+
+ return (ind);
+}
+
+
+dump_ptrtab(fp)
+FILE *fp;
+{
+ int i;
+
+
+ fprintf(fp, "\n/* Pointer table %d entries */\n", ptr_cnt);
+ fprintf(fp, "static caddr_t %s%s%s[] = {\n", PREFIX, PTR_TABNAME, tab);
+
+ for (i = 0; i < ptr_cnt; i++)
+ fprintf(fp, " (caddr_t ) %s,\n", ptr_tab[i]);
+
+ if (ptr_cnt <= 0)
+ fprintf(fp, " (caddr_t ) 0,\n"); /* for fussy C compilers */
+
+ fprintf(fp, "};\n");
+}
+
+/*
+ * routines to parse and analyse C types to support the pepy-like extensions
+ * of pepsy
+ */
+
+/*
+ * remove a level of indirection from the given type. If possible. if not
+ * return NULLCP, otherwise return the new type in a temporary buffer
+ */
+char *
+rm_indirect(p)
+char *p;
+{
+ static char buf[STRSIZE];
+ int i;
+
+ if (p == NULLCP || *p == '\0' || (i = strlen(p)) >= STRSIZE)
+ return (NULLCP);
+
+ (void) strncpy(buf, p, STRSIZE);
+
+ for (; i >= 0; i--) {
+ if (buf[i] == '*') {
+ buf[i] = '\0';
+ return (buf);
+ }
+ }
+
+ return (NULLCP);
+
+}
+
+/*
+ * extract the field from the C arguement and the following constant
+ * expression for the bit number.
+ * if it fails return NULLCP
+ */
+char *
+getfldbit(p, pstr)
+register char *p;
+char **pstr;
+{
+ static char buf[STRSIZE];
+
+ if (p == NULLCP || pstr == (char **)0)
+ return (NULLCP);
+
+ if ((p = getidordot(p, buf, STRSIZE)) == NULLCP)
+ return (NULLCP);
+
+ while (*p && isspace(*p))
+ p++;
+
+ if (*p != '$') { /* must be a -> */
+
+ if (strncmp(p, "->", 2) != 0)
+ return (NULLCP);
+
+ p += 2;
+
+ if ((p = getidordot(p, buf, STRSIZE)) == NULLCP)
+ return (NULLCP);
+
+ while (*p && isspace(*p))
+ p++;
+
+ if (*p != '$')
+ return (NULLCP);
+ }
+
+ *pstr = p + 1; /* have to leave it up to the compiler to verify the
+ * constant expression for the bit number
+ */
+ return (buf);
+}
+
+/* return a pointer after the current batch of white space if any */
+char *
+skipspace(p)
+char *p;
+{
+ if (p == NULLCP)
+ return (NULLCP);
+
+ while (*p && isspace(*p))
+ p++;
+
+ return (p);
+}
+
+/*
+ * extract the field from the C arguement and return it in a static buffer
+ * else return NULLCP
+ */
+char *
+getfield(p)
+register char *p;
+{
+ static char buf[STRSIZE];
+ char *buf1;
+
+ if (p == NULLCP)
+ return (NULLCP);
+
+ while (*p && isspace(*p))
+ p++;
+
+ if (*p == '*') /* to support *parm field */
+ return (p);
+
+ if ((p = getidordot(p, buf, STRSIZE)) == NULLCP)
+ return (NULLCP);
+
+ while (*p && isspace(*p))
+ p++;
+
+ if (*p == '\0')
+ return (buf);
+
+ if (strncmp(p, "->", 2) != 0)
+ return (NULLCP);
+
+ p += 2;
+
+ /* if we have an & keep it on the field */
+ if (*buf == '&')
+ buf1 = buf + 1;
+ else
+ buf1 = buf;
+
+ if ((p = getidordot(p, buf1, STRSIZE)) == NULLCP)
+ return (NULLCP);
+
+ while (*p && isspace(*p))
+ p++;
+
+ if (*p == '\0')
+ return (buf);
+
+ return (NULLCP);
+}
+
+/*
+ * get an identifier into the given buffer [A-Za-z_] are legal chars
+ */
+char *
+getid(p, buf, len)
+register char *p;
+register char *buf;
+register int len;
+{
+ char *fbuf;
+
+ fbuf = buf;
+
+ while (*p && isspace(*p))
+ p++;
+
+ while (*p && (isalnum(*p) || *p == '_')) {
+ if (len-- >= 0)
+ *buf++ = *p;
+ p++;
+ }
+
+ if (fbuf == buf)
+ return (NULLCP);
+
+ *buf = '\0';
+
+ return (p);
+
+}
+
+/*
+ * get an identifier into the given buffer - '.' are considered part of an
+ * identifier - should really be called get field reference
+ */
+char *
+getidordot(p, buf, len)
+register char *p;
+register char *buf;
+register int len;
+{
+ char *fbuf;
+
+ fbuf = buf;
+
+ while (*p && isspace(*p))
+ p++;
+
+ if (*p == '&') {
+ len--;
+ *buf++ = *p++;
+
+ while (*p && isspace(*p))
+ p++;
+ }
+
+ while (*p && (isalnum(*p) || *p == '_' || *p == '.')) {
+ if (len-- >= 0)
+ *buf++ = *p;
+ p++;
+ }
+
+ if (fbuf == buf)
+ return (NULLCP);
+
+ *buf = '\0';
+
+ return (p);
+
+}
+static char *noindstr[] = {
+ "*", "*parm", "&", "&parm",
+ NULLCP
+ };
+
+/*
+ * determine if the given field means no indirection wanted and so return 1
+ * else return 0
+ */
+noindirect(f)
+char *f;
+{
+ char *p, **ps;
+ int l;
+
+ if (f == NULLCP)
+ return (1);
+
+ f = skipspace(f);
+
+ if (f == NULLCP)
+ return (1);
+
+ if (*f == '&')
+ return (1);
+
+ for (p = f; *p && !isspace(*p); p++)
+ ;
+ l = p - f;
+
+ for (ps = noindstr; *ps; ps++)
+ if (l == strlen(*ps) && strncmp(f, *ps, l) == 0)
+ return (1);
+
+ return (0);
+}
+
+/*
+ * process the T - the Type and field specifier
+ * the given YP to the appropriate values for VALTYPE string
+ * Namely the yp_parm_type to contain the (Parameter) type string.
+ * then if there is a $ the yp_parm to the part after the $, the field
+ */
+setvaltype(yp, str)
+YP yp;
+char *str;
+{
+ char *p;
+
+ if (str == NULLCP || *(str = skipspace(str)) == '\0')
+ return (0);
+
+ if (p = index(str, '$')) {
+ *p++ = '\0';
+ p = skipspace(p);
+ yp->yp_parm = strdup(p);
+ yp->yp_flags |= YP_PARMVAL;
+ }
+
+ yp->yp_param_type = strdup(str);
+
+ return (1);
+
+}
+
+
+/*
+ * generate the functions that carry out the action statements
+ */
+gen_actfunct(fp)
+FILE *fp;
+{
+ SY sy;
+ YP yp;
+
+ if (e_actions > 0) {
+ (void) fprintf(fp, "\n/*VARARGS*/");
+ (void) fprintf(fp, "\nstatic\tint\nefn_%s(__p, ppe, _Zp)\ncaddr_t __p;\n", tab);
+ (void) fprintf(fp, "PE *ppe;\ntpe *_Zp;\n{\n");
+ (void) fprintf(fp, "\t\t\n\t/* %d cases */\n switch(_Zp->pe_ucode) {\n",
+ e_actions);
+ for (sy = mysymbols; sy; sy = sy->sy_next) {
+ yp = sy->sy_type;
+ if (yp->yp_flags & YP_IMPORTED)
+ continue;
+
+ if (yp->yp_direction & YP_ENCODER || Aflag)
+ gen_actions(fp, yp, G_ENC);
+
+ }
+ (void) fprintf(fp,
+" default:\n return (pepsylose(NULLMODTYP, _Zp, *ppe, \"enf_%s:Bad table entry: %%d\",\n _Zp->pe_ucode));\n",
+ tab);
+ (void) fprintf(fp, "\t\t}\t/* switch */\n return (OK);\n}\n");
+ }
+ if (d_actions > 0) {
+ (void) fprintf(fp, "\n/*VARARGS*/");
+ (void) fprintf(fp, "\nstatic\tint\ndfn_%s(__p, pe, _Zp, _val)\ncaddr_t __p;\n", tab);
+ (void) fprintf(fp, "PE pe;\ntpe *_Zp;\nint _val;\n{\n");
+ (void) fprintf(fp, "\t\t\n\t/* %d cases */\n switch(_Zp->pe_ucode) {\n",
+ d_actions);
+ for (sy = mysymbols; sy; sy = sy->sy_next) {
+ yp = sy->sy_type;
+ if (yp->yp_flags & YP_IMPORTED)
+ continue;
+
+ if (yp->yp_direction & YP_DECODER || Aflag)
+ gen_actions(fp, yp, G_DEC);
+
+ }
+ (void) fprintf(fp,
+" default:\n return (pepsylose(NULLMODTYP, _Zp, pe, \"dnf_%s:Bad table entry: %%d\",\n _Zp->pe_ucode));\n",
+ tab);
+ (void) fprintf(fp, "\t\t}\t/* switch */\n return (OK);\n}\n");
+ }
+ if (p_actions > 0) {
+ (void) fprintf(fp, "\n/*VARARGS*/");
+ (void) fprintf(fp, "\nstatic\tint\npfn_%s(pe, _Zp)\n", tab);
+ (void) fprintf(fp, "PE pe;\ntpe *_Zp;\n{\n");
+ (void) fprintf(fp, "\t\t\n\t/* %d cases */\n switch(_Zp->pe_ucode) {\n",
+ p_actions);
+ for (sy = mysymbols; sy; sy = sy->sy_next) {
+ yp = sy->sy_type;
+
+ if (yp->yp_flags & YP_IMPORTED)
+ continue;
+
+ if (yp->yp_direction & YP_PRINTER || Aflag)
+ gen_actions(fp, yp, G_PNT);
+
+ }
+ (void) fprintf(fp,
+" default:\n return (pepsylose(NULLMODTYP, _Zp, NULLPE, \"pnf_%s:Bad table entry: %%d\",\n _Zp->pe_ucode));\n",
+ tab);
+ (void) fprintf(fp, "\t\t}\t/* switch */\n return (OK);\n}\n");
+ }
+}
+
+#define GEN_RETURN 1
+#define GEN_ASSIGN 2
+/*
+ * generate the actions for this YP unit and all its children
+ */
+gen_actions(fp, oyp, form)
+FILE *fp;
+YP oyp;
+int form; /* what type of action is it */
+{
+ register YP yp;
+ register YAL yal;
+
+ for (yp = oyp; yp; yp = yp->yp_next) {
+
+ /* do its actions first then any of its children */
+ if (yal = yp->yp_bef_alist)
+ dumpact(fp, yal, form, 0);
+ if (yal = yp->yp_aft_alist)
+ dumpact(fp, yal, form, 0);
+ if (yal = yp -> yp_control_act) {
+ if (form == G_ENC)
+ dumpact (fp, yal,form, GEN_RETURN);
+ else if (form == G_DEC)
+ dumpact (fp, yal, form, GEN_ASSIGN);
+ }
+ if (yal = yp -> yp_optional_act) {
+ if (form == G_ENC)
+ dumpact (fp, yal,form, GEN_RETURN);
+ else if (form == G_DEC)
+ dumpact (fp, yal, form, 0);
+ }
+
+ switch (yp->yp_code) {
+ case YP_SEQTYPE:
+ case YP_SEQLIST:
+ case YP_SETTYPE:
+ case YP_SETLIST:
+ case YP_CHOICE:
+ gen_actions(fp, yp->yp_type, form);
+ break;
+
+ default:
+ break;
+ }
+ }
+}
+/*
+ * dump out a single action
+ */
+dumpact(fp, yal, form, ret)
+FILE *fp;
+YAL yal;
+int form;
+int ret;
+{
+ char *comm = yal->yal_comment;
+ char *type = yal->yal_type;
+ Action act;
+ char buf[STRSIZE];
+
+ if ((int)strlen(type) > STRSIZE)
+ ferr(1, "dumpact:type too big");
+ (void) strncpy(buf, type, STRSIZE);
+ if (form != G_DEC)
+ (void) strncat(buf, "*", STRSIZE);
+ else
+ (void) strncat(buf, "**", STRSIZE);
+ type = buf;
+ switch (form) {
+ case G_ENC:
+ act = yal->yal_enc;
+ break;
+ case G_DEC:
+ act = yal->yal_dec;
+ break;
+ case G_PNT:
+ act = yal->yal_prn;
+ break;
+ }
+
+ /* can't tell wether this table has the UCODE till here */
+ if (act == NULLAction || act -> a_line == -1)
+ return;
+
+ if (form != G_PNT)
+ (void) fprintf(fp, "\n#define parm ((%s )__p)\n\tcase %d: /* %s */\n",
+ type, act->a_num, comm ? comm : "");
+ else
+ (void) fprintf(fp, "\n\tcase %d: /* %s */\n", act->a_num, comm ? comm : "");
+
+ (void) fprintf(fp, "\t\t{\n# line %d \"%s\"\n",
+ act->a_line ? act->a_line : 1, sysin);
+
+ switch (ret) {
+ case GEN_ASSIGN:
+ if (control_act (act) == -1)
+ fprintf (fp, "\t\t/* ignored - empty expression */\n");
+ else fprintf (fp, "\t\t(%s) = _val;\n", act -> a_data);
+ break;
+ case GEN_RETURN:
+ fprintf (fp, "\t\treturn (%s);\n",act -> a_data);
+ break;
+ default:
+ fputs (act -> a_data, fp);
+ putc (';', fp);
+ break;
+ }
+
+ (void) fprintf(fp, "\n\t\t}\n\t break;\n");
+
+ if (form != G_PNT)
+ (void) fprintf(fp, "\n#undef parm\n");
+ act -> a_line = -1; /* mark as done */
+}
+
+/*
+ * produce a temporary copy of the type specified in the ParameterType
+ * specification
+ * i.e. a [[ P type ]] specification
+ */
+char *
+partyp2str(yp)
+YP yp;
+{
+ char *p;
+
+ if (yp->yp_param_type == NULLCP) {
+ fprintf(stderr, "\npartyp2str no param_type field\n");
+ exit(1);
+ }
+
+ if ((p = rm_indirect(yp->yp_param_type)) == NULLCP) {
+ fprintf(stderr, "\npartyp2str can't extract direct type from %s\n",
+ yp->yp_param_type);
+ exit(1);
+ }
+
+ return (p);
+}
+/*
+ * produce a string giving the type of a symbol, in a static buffer
+ */
+char *
+sym2type(sy)
+SY sy;
+{
+ static char buffer[STRSIZE];
+
+ if (sy->sy_type && sy->sy_type->yp_param_type)
+ return (partyp2str(sy->sy_type));
+
+ (void) sprintf(buffer, "struct %s", modsym(sy->sy_module, sy->sy_name, "type"));
+
+ return (buffer);
+}
diff --git a/src/isode/pepsy/pass2.h b/src/isode/pepsy/pass2.h
new file mode 100644
index 000000000..e0eeda94a
--- /dev/null
+++ b/src/isode/pepsy/pass2.h
@@ -0,0 +1,140 @@
+/* pass2.h */
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:30:57 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:39:49 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:43:04 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* Change the version number only important features change - so people can
+ * #ifdef on the version number. Also used to provide backwards compatible
+ * macro definitions for posy/pepy.
+ */
+#define PEPSY_VERSION_NUMBER 2
+#define NBPC 8 /* Number of Bits per character - machine dependant */
+#define NBPI sizeof (int)*NBPC /* Number of bits per integer */
+
+#define PSAP_DOT_H "\"psap.h\""
+#define I_PSAP_DOT_H "<isode/psap.h>"
+#define UNIV_TYPES_DOT_H "\"UNIV-types.h\""
+#define I_UNIV_TYPES_DOT_H "<isode/pepsy/UNIV-types.h>"
+#define HFILE1 "_defs.h"
+#define HFILE2 "_pre_defs.h"
+#define ACTIONDEFS "_action.h"
+
+#define GENTYPES "-types.h"
+#define INCFILE1 "pepsy.h"
+/* #define INCFILE2 "pepdefs.h" - not used any more */
+
+#define ACT1 "_act1"
+#define ACT2 "_act2"
+#define ACT3 "_act3"
+#define ACT4 "_act4"
+#define ACT05 "_act05"
+
+#define PREFIX "_Z"
+
+#define ETABLE "et_"
+#define DTABLE "dt_"
+#define PTABLE "pt_"
+
+#define ENCFNCNAME "enc_f"
+#define DECFNCNAME "dec_f"
+#define PRNTFNCNAME "prnt_f"
+
+#define ENC_FNCNAME "enc_f_"
+#define DEC_FNCNAME "dec_f_"
+#define PRNT_FNCNAME "prnt_f_"
+
+#define ENCFILENAME "_enc.c"
+#define DECFILENAME "_dec.c"
+#define PRNTFILENAME "_prnt.c"
+
+#define TBLNAME "_tables.c"
+#define MODTYP_SUFFIX "_mod"
+
+#define MAXPTRS 200 /* maximum number of pointers in pointer table */
+
+#define PTR_TABNAME "ptrtab"
+extern int p_debug;
+
+#define DEB 1
+
+#ifdef DEB
+#define Printf(x, y) if (x <= p_debug) printf y
+#else
+#define Printf(x, y)
+#endif
+
+/*
+ * info for handling a Universal type
+ */
+struct univ_typ {
+ char *univ_name; /* Name of this Universal type */
+ char *univ_data; /* type to generate for it */
+ char *univ_tab; /* type of table entry it needs */
+ PElementID univ_id; /* tag of the type */
+ PElementClass univ_class; /* class - probably Universal primative */
+ char *univ_mod; /* Name of its module if it has one */
+ int univ_flags; /* Information about entry */
+ int univ_type; /* Type we can use for its contents */
+#define UNF_EXTMOD 1 /* Use an external module reference */
+#define UNF_HASDATA 2 /* Has data structure - allocate data for it */
+ };
+
+extern struct univ_typ *univtyp();
+
+/* How many entries in an array */
+#define NENTRIES(x) (sizeof (x)/sizeof ((x)[0]))
+
+/* used to specify which tables a routine is to generate */
+#define G_ENC 0 /* encoding */
+#define G_DEC 1 /* decoding */
+#define G_PNT 2 /* printing */
+
+#define hflag (options[0])
+#define Hflag (options[1])
+#define h2flag (options[2])
+#define NOPTIONS 3
+extern int options[];
+
+#define STRSIZE 128 /* general buffer size */
+
+extern char *proc_name();
+
+extern char *getfield(), *getfldbit();
+extern char *class2str();
+
+extern int gen_ventry(); /* generate a Value Passing Entry */
+extern int gen_fnentry(); /* generate a function calling entry */
+/* extern Action start_action, final_action; */
+extern char *int2tstr(); /* integer to temporary string */
+
+extern char *getfield(), *getfldbit();
+extern char *class2str();
+
+extern int gen_ventry(); /* generate a Value Passing Entry */
+extern int gen_fnentry(); /* generate a function calling entry */
+/* extern Action start_action, final_action; */
diff --git a/src/isode/pepsy/pep.output b/src/isode/pepsy/pep.output
new file mode 100644
index 000000000..f0f8f9ff1
--- /dev/null
+++ b/src/isode/pepsy/pep.output
@@ -0,0 +1,7842 @@
+before encoding INTEGER 7
+before encoding OCTET STRING "The quick"
+before encoding BIT STRING: 0011000
+After Bitstring encoding:'0011000'B
+After Sequence encoding:
+{
+ 7,
+ "The quick",
+ '0011000'B
+}
+before encoding INTEGER 6
+before encoding OCTET STRING "brown"
+before encoding BIT STRING: 001100
+After Bitstring encoding:'001100'B
+After Sequence encoding:
+{
+ 6,
+ "brown",
+ '001100'B
+}
+encoding SET OF Rep-action
+before encoding INTEGER 10
+before encoding OCTET STRING "The quick"
+before encoding BIT STRING: 0011000100
+After Bitstring encoding:'0011000100'B
+After Sequence encoding:
+{
+ 10,
+ "The quick",
+ '0011000100'B
+}
+encoding SET OF Rep-action
+before encoding INTEGER 9
+before encoding OCTET STRING "brown"
+before encoding BIT STRING: 001100010
+After Bitstring encoding:'001100010'B
+After Sequence encoding:
+{
+ 9,
+ "brown",
+ '001100010'B
+}
+encoding SET OF Rep-action
+before encoding INTEGER 8
+before encoding OCTET STRING "fox jumps over"
+before encoding BIT STRING: 00110001
+After Bitstring encoding:'00110001'B
+After Sequence encoding:
+{
+ 8,
+ "fox jumps over",
+ '00110001'B
+}
+encoding SET OF Rep-action
+before encoding INTEGER 7
+before encoding OCTET STRING "The Lazy"
+before encoding BIT STRING: 0011000
+After Bitstring encoding:'0011000'B
+After Sequence encoding:
+{
+ 7,
+ "The Lazy",
+ '0011000'B
+}
+encoding SET OF Rep-action
+before encoding INTEGER 6
+before encoding OCTET STRING "dog"
+before encoding BIT STRING: 001100
+After Bitstring encoding:'001100'B
+After Sequence encoding:
+{
+ 6,
+ "dog",
+ '001100'B
+}
+Before Decoding Rep-action
+After Decoding Rep-action:
+rp_int 7
+r_ostring "The quick"
+r_bstring: 0011000
+Before Decoding Rep-action
+After Decoding Rep-action:
+rp_int 6
+r_ostring "brown"
+r_bstring: 001100
+Before Decoding Rep-action
+After Decoding Rep-action:
+rp_int 10
+r_ostring "The quick"
+r_bstring: 0011000100
+Before Decoding Rep-action
+After Decoding Rep-action:
+rp_int 9
+r_ostring "brown"
+r_bstring: 001100010
+Before Decoding Rep-action
+After Decoding Rep-action:
+rp_int 8
+r_ostring "fox jumps over"
+r_bstring: 00110001
+Before Decoding Rep-action
+After Decoding Rep-action:
+rp_int 7
+r_ostring "The Lazy"
+r_bstring: 0011000
+Before Decoding Rep-action
+After Decoding Rep-action:
+rp_int 6
+r_ostring "dog"
+r_bstring: 001100
+After Decoding CHOICE: chosen 1
+After Decoding UAction
+
+"Action Statements" t_test = 3
+{
+ a {
+ 6,
+ 3
+ },
+ b {
+ {
+ a 7,
+ b "The quick",
+ c '0011000'B
+ },
+ {
+ a 6,
+ b "brown",
+ c '001100'B
+ }
+ },
+ c {
+ 6,
+ 3
+ },
+ d {
+ {
+ a 10,
+ b "The quick",
+ c '0011000100'B
+ },
+ {
+ a 9,
+ b "brown",
+ c '001100010'B
+ },
+ {
+ a 8,
+ b "fox jumps over",
+ c '00110001'B
+ },
+ {
+ a 7,
+ b "The Lazy",
+ c '0011000'B
+ },
+ {
+ a 6,
+ b "dog",
+ c '001100'B
+ }
+ },
+ e {
+ -1
+ }
+}
+before encoding INTEGER 5
+before encoding OCTET STRING "The quick"
+before encoding BIT STRING: 00110
+After Bitstring encoding:'00110'B
+After Sequence encoding:
+{
+ 5,
+ "The quick",
+ '00110'B
+}
+encoding SET OF Rep-action
+before encoding INTEGER 7
+before encoding OCTET STRING "The quick"
+before encoding BIT STRING: 0011000
+After Bitstring encoding:'0011000'B
+After Sequence encoding:
+{
+ 7,
+ "The quick",
+ '0011000'B
+}
+encoding SET OF Rep-action
+before encoding INTEGER 6
+before encoding OCTET STRING "brown"
+before encoding BIT STRING: 001100
+After Bitstring encoding:'001100'B
+After Sequence encoding:
+{
+ 6,
+ "brown",
+ '001100'B
+}
+encoding SET OF Rep-action
+before encoding INTEGER 5
+before encoding OCTET STRING "fox jumps over"
+before encoding BIT STRING: 00110
+After Bitstring encoding:'00110'B
+After Sequence encoding:
+{
+ 5,
+ "fox jumps over",
+ '00110'B
+}
+Before Decoding Rep-action
+After Decoding Rep-action:
+rp_int 5
+r_ostring "The quick"
+r_bstring: 00110
+Before Decoding Rep-action
+After Decoding Rep-action:
+rp_int 7
+r_ostring "The quick"
+r_bstring: 0011000
+Before Decoding Rep-action
+After Decoding Rep-action:
+rp_int 6
+r_ostring "brown"
+r_bstring: 001100
+Before Decoding Rep-action
+After Decoding Rep-action:
+rp_int 5
+r_ostring "fox jumps over"
+r_bstring: 00110
+After Decoding CHOICE: chosen 3
+After Decoding UAction
+
+"Action Statements" t_test = 2
+{
+ a {
+ 3
+ },
+ b {
+ {
+ a 5,
+ b "The quick",
+ c '00110'B
+ }
+ },
+ c {
+ 3
+ },
+ d {
+ {
+ a 7,
+ b "The quick",
+ c '0011000'B
+ },
+ {
+ a 6,
+ b "brown",
+ c '001100'B
+ },
+ {
+ a 5,
+ b "fox jumps over",
+ c '00110'B
+ }
+ },
+ e {
+ "lets go home"
+ }
+}
+encoding SET OF Rep-action
+before encoding INTEGER 4
+before encoding OCTET STRING "The quick"
+before encoding BIT STRING: 0011
+After Bitstring encoding:'0011'B
+After Sequence encoding:
+{
+ 4,
+ "The quick",
+ '0011'B
+}
+encoding Boolean 0
+Before Decoding Rep-action
+After Decoding Rep-action:
+rp_int 4
+r_ostring "The quick"
+r_bstring: 0011
+Decoding Boolean
+After Decoding CHOICE: chosen 2
+After Decoding UAction
+
+"Action Statements" t_test = 1
+{
+ a {},
+ b {},
+ c {},
+ d {
+ {
+ a 4,
+ b "The quick",
+ c '0011'B
+ }
+ },
+ e {
+ FALSE
+ }
+}
+
+"All Simple Types" t_test = 3
+{
+ a {
+ a 'ff'H,
+ b "\b",
+ d "\n",
+ "hello there, world\n"
+ },
+ b 5,
+ c 5,
+ d 5,
+ e "hello there, world\n",
+ f "hello world\n",
+ g "hello world\n",
+ h 1.17,
+ i 1.17,
+ j 1.17,
+ k 'ff'H,
+ l '000100100011000100011010001101110'B,
+ m 9.42479,
+ n TRUE
+}
+
+"All Simple Types" t_test = 2
+{
+ a {
+ a 'ff'H,
+ c 'ff'H,
+ e 0
+ },
+ b 3,
+ c 3,
+ d 3,
+ e "hello world\n",
+ f "hello world\n",
+ g "hello world\n",
+ h 1.17.45.49,
+ i 1.17.45.49,
+ j 1.17.45.49,
+ k '00'H,
+ l '00010010001100010001101000110111'B,
+ m 6.28319,
+ n FALSE
+}
+
+"All Simple Types" t_test = 1
+{
+ a {
+ b '00'H,
+ d '00'H,
+ e -1,
+ "hello there, world\n"
+ },
+ b 1,
+ c 1,
+ d 1,
+ e "hello there, world\n",
+ f "hello world\n",
+ g "hello world\n",
+ h 1.17,
+ i 1.17,
+ j 1.17,
+ k 'ff'H,
+ l '0001001000110001000110100011011'B,
+ m 3.1416,
+ n TRUE
+}
+
+"function calling code" t_test = 3
+{
+ a 'ff'H,
+ b '00'H,
+ c "\b",
+ d "\n",
+ e 2,
+ f "hello there, world\n",
+ left {
+ a 'ff'H,
+ b '00'H,
+ d "\n",
+ e 2,
+ "hello there, world\n"
+ },
+ right {
+ a 'ff'H,
+ b "\b",
+ d "\n",
+ "hello there, world\n"
+ }
+}
+
+"function calling code" t_test = 2
+{
+ a '00'H,
+ b 'ff'H,
+ c 'ff'H,
+ d "\t",
+ f "hello world\n",
+ left {
+ a '00'H,
+ c 'ff'H
+ },
+ right {
+ a 'ff'H,
+ c 'ff'H,
+ e 0
+ }
+}
+
+"function calling code" t_test = 1
+{
+ a 'ff'H,
+ b '00'H,
+ c '00'H,
+ d "\b",
+ e 0,
+ f "hello there, world\n",
+ left {
+ b '00'H,
+ d "\b",
+ e 0,
+ "hello there, world\n"
+ },
+ right {
+ b '00'H,
+ d '00'H,
+ e -1,
+ "hello there, world\n"
+ }
+}
+
+"Value Passing Defined types" t_test = 3
+{
+ "hello there, world\n",
+ b "Some one is out there!",
+ '00313233343536'H,
+ '0000000000110001001100100011'B,
+ [PRIVATE 577] '18'H,
+ '000100100011000100011010001101110010'B,
+ 9357,
+ 1.73205,
+ 1.17.42,
+ TRUE,
+ 4
+}
+
+"Value Passing Defined types" t_test = 2
+{
+ "hello there, world\n",
+ b "Some one is out there!",
+ '003132333435'H,
+ '00000000001100010011'B,
+ [PRIVATE 16] {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H,
+ [PRIVATE 37] '00'H,
+ [PRIVATE 50] 'ff'H,
+ [PRIVATE 65] "\b",
+ [PRIVATE 82] "\t",
+ [PRIVATE 101] "\n",
+ [PRIVATE 122] '0b'H,
+ [PRIVATE 145] "mkpelist:testdata",
+ [PRIVATE 170] "mkpelist:testdata",
+ [PRIVATE 197] '0010'H,
+ [PRIVATE 226] '0010'H,
+ [PRIVATE 15] {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H,
+ [PRIVATE 37] '00'H,
+ [PRIVATE 50] 'ff'H,
+ [PRIVATE 65] "\b",
+ [PRIVATE 82] "\t",
+ [PRIVATE 101] "\n",
+ [PRIVATE 122] '0b'H,
+ [PRIVATE 145] "mkpelist:testdata",
+ [PRIVATE 170] "mkpelist:testdata",
+ [PRIVATE 197] '0010'H,
+ [PRIVATE 226] '0010'H
+ }
+ },
+ '00010010001100010001101000110111001'B,
+ 9356,
+ 1.41421,
+ 1.17,
+ FALSE,
+ 3
+}
+
+"Value Passing Defined types" t_test = 1
+{
+ "hello there, world\n",
+ b "Some one is out there!",
+ '0031323334'H,
+ '000000000011'B,
+ [PRIVATE 101] "\n",
+ '0001001000110001000110100011011100'B,
+ 9355,
+ 1,
+ 1.17,
+ TRUE,
+ 2
+}
+
+"Repeating pepy elements" t_test = 3
+{
+ a {
+ 6,
+ 3
+ },
+ b {
+ {
+ a 7,
+ b "The quick",
+ c '0011000'B
+ },
+ {
+ a 6,
+ b "brown",
+ c '001100'B
+ }
+ },
+ c {
+ 6,
+ 3
+ },
+ d {
+ {
+ a 10,
+ b "The quick",
+ c '0011000100'B
+ },
+ {
+ a 9,
+ b "brown",
+ c '001100010'B
+ },
+ {
+ a 8,
+ b "fox jumps over",
+ c '00110001'B
+ },
+ {
+ a 7,
+ b "The Lazy",
+ c '0011000'B
+ },
+ {
+ a 6,
+ b "dog",
+ c '001100'B
+ }
+ },
+ e {
+ -1
+ }
+}
+
+"Repeating pepy elements" t_test = 2
+{
+ a {
+ 3
+ },
+ b {
+ {
+ a 5,
+ b "The quick",
+ c '00110'B
+ }
+ },
+ c {
+ 3
+ },
+ d {
+ {
+ a 7,
+ b "The quick",
+ c '0011000'B
+ },
+ {
+ a 6,
+ b "brown",
+ c '001100'B
+ },
+ {
+ a 5,
+ b "fox jumps over",
+ c '00110'B
+ }
+ },
+ e {
+ "lets go home"
+ }
+}
+
+"Repeating pepy elements" t_test = 1
+{
+ a {},
+ b {},
+ c {},
+ d {
+ {
+ a 4,
+ b "The quick",
+ c '0011'B
+ }
+ },
+ e {
+ FALSE
+ }
+}
+
+"Compound S-types" t_test = 3
+{
+ a {},
+ b {
+ [2] 12357
+ },
+ c {},
+ d {
+ [4] 4
+ }
+}
+
+"Compound S-types" t_test = 2
+{
+ a {
+ 12356
+ },
+ b {},
+ c {
+ 3
+ },
+ d {}
+}
+
+"Compound S-types" t_test = 1
+{
+ a {},
+ b {
+ [2] 12355
+ },
+ c {},
+ d {
+ [4] 2
+ }
+}
+
+"Pepy Stuff" t_test = 3
+{
+ 12357,
+ 4,
+ "Some is out there!",
+ "hello, world\n",
+ '00313233343536'H,
+ '00010010001100010001101000110111001010100'B,
+ '0000000000110001001100100011'B,
+ TRUE,
+ 1.17.42,
+ 3.06998,
+ [PRIVATE 730] '0010'H,
+ {
+ [1] 12357,
+ 12357,
+ 4,
+ [4] 4,
+ "hello, world\n",
+ [8] "hello, world\n",
+ '00313233343536'H,
+ [10] '00313233343536'H,
+ 1.17.42,
+ [18] 1.17.42,
+ 3.06998,
+ [20] 3.06998,
+ [21] '0010'H
+ },
+ [13] {
+ [2] 12357,
+ [4] 4,
+ "Some is out there!",
+ [6] "Some is out there!",
+ "hello, world\n",
+ [8] "hello, world\n",
+ '00313233343536'H,
+ [10] '00313233343536'H,
+ '00010010001100010001101000110111001010101'B,
+ [12] '00010010001100010001101000110111001010101'B,
+ '00000000001100010011001000110011'B,
+ [16] TRUE,
+ 1.17.42,
+ 3.06998,
+ [PRIVATE 730] '0010'H
+ }
+}
+
+"Pepy Stuff" t_test = 2
+{
+ 12356,
+ 3,
+ "Some is out there!",
+ "hello, world\n",
+ '003132333435'H,
+ '00010010001100010001101000110111001010100'B,
+ '00000000001100010011'B,
+ FALSE,
+ 1.17,
+ 2.50663,
+ [PRIVATE 362] 'ff'H,
+ {
+ [1] 12356,
+ 12356,
+ "hello, world\n",
+ [8] "hello, world\n",
+ '003132333435'H,
+ [10] '003132333435'H,
+ '000000000011000100110010'B,
+ FALSE,
+ [16] FALSE,
+ 1.17,
+ [18] 1.17,
+ 2.50663,
+ [20] 2.50663,
+ [21] 'ff'H
+ },
+ [13] {
+ 12356,
+ 3,
+ "Some is out there!",
+ [6] "Some is out there!",
+ "hello, world\n",
+ [8] "hello, world\n",
+ '003132333435'H,
+ [10] '003132333435'H,
+ '00010010001100010001101000110111001010101'B,
+ [12] '00010010001100010001101000110111001010101'B,
+ '000000000011000100110010'B,
+ FALSE,
+ 1.17,
+ [19] 2.50663,
+ [PRIVATE 362] 'ff'H
+ }
+}
+
+"Pepy Stuff" t_test = 1
+{
+ 12355,
+ 2,
+ "Some is out there!",
+ "hello, world\n",
+ '0031323334'H,
+ '00010010001100010001101000110111001010100'B,
+ '000000000011'B,
+ TRUE,
+ 1.17,
+ 1.77245,
+ [PRIVATE 122] '0b'H,
+ {
+ [1] 12355,
+ 12355,
+ 2,
+ [4] 2,
+ "hello, world\n",
+ [8] "hello, world\n",
+ '0031323334'H,
+ [10] '0031323334'H,
+ '0000000000110001'B,
+ 1.17,
+ [18] 1.17,
+ 1.77245,
+ [20] 1.77245,
+ [21] '0b'H
+ },
+ [13] {
+ [2] 12355,
+ [4] 2,
+ "Some is out there!",
+ [6] "Some is out there!",
+ "hello, world\n",
+ [8] "hello, world\n",
+ '0031323334'H,
+ [10] '0031323334'H,
+ '00010010001100010001101000110111001010101'B,
+ [12] '00010010001100010001101000110111001010101'B,
+ '0000000000110001'B,
+ [16] TRUE,
+ 1.17,
+ 1.77245,
+ [PRIVATE 122] '0b'H
+ }
+}
+
+"Tests of Real type" t_test = 4
+{
+ r1 927640,
+ r2 0,
+ r3 -2.28789,
+ r4 927640
+}
+
+"Tests of Real type" t_test = 3
+{
+ r1 -2.28789,
+ r2 927640,
+ r3 0,
+ r4 3.1416,
+ r5 927640
+}
+
+"Tests of Real type" t_test = 2
+{
+ r1 0,
+ r2 -2.28789,
+ r3 927640,
+ r4 0,
+ r5 -2.28789
+}
+
+"Tests of Real type" t_test = 1
+{
+ r1 927640,
+ r2 0,
+ r3 -2.28789,
+ r4 3.1416
+}
+
+"Real" t_test = 3
+-2.28789
+
+"Real" t_test = 2
+0
+
+"Real" t_test = 1
+927640
+
+"Tests of Enumerated type" t_test = 4
+{
+ ae1 0,
+ ae2 1,
+ ae3 3,
+ ae4 -1,
+ ae5 -1
+}
+
+"Tests of Enumerated type" t_test = 3
+{
+ ae1 -1,
+ ae2 0,
+ ae3 1,
+ ae4 3
+}
+
+"Tests of Enumerated type" t_test = 2
+{
+ ae1 3,
+ ae2 -1,
+ ae3 0,
+ ae4 3,
+ ae5 1
+}
+
+"Tests of Enumerated type" t_test = 1
+{
+ ae1 1,
+ ae2 3,
+ ae3 -1,
+ ae4 0
+}
+
+"Enumerated Type" t_test = 4
+0
+
+"Enumerated Type" t_test = 3
+-1
+
+"Enumerated Type" t_test = 2
+3
+
+"Enumerated Type" t_test = 1
+1
+
+"Single Objects" t_test = 4
+{
+ st2 "xxxxxxx, world"
+}
+
+"Single Objects" t_test = 3
+{}
+
+"Single Objects" t_test = 2
+{
+ st2 "xxxxxxx, world"
+}
+
+"Single Objects" t_test = 1
+{
+ st2 "xxxxxxx, world"
+}
+
+"Explicit Tagged Objects" t_test = 3
+{
+ bE 40986
+}
+
+"Explicit Tagged Objects" t_test = 2
+{
+ aE 10283
+}
+
+"Explicit Tagged Objects" t_test = 1
+{
+ bE 40986
+}
+
+"Single EXTERNAL" t_test = 1
+{
+ direct-reference 1.17.222,
+ indirect-reference 16,
+ data-value-descriptor '4120766572792077696c642074797065206f66206461746100'H,
+ encoding {
+ octet-aligned '536f6d652074657374206461746100'H
+ }
+}
+
+"EXTERNAL" t_test = 6
+{
+ ext {
+ direct-reference 1.17.474,
+ data-value-descriptor '4120766572792077696c642074797065206f66206461746100'H,
+ encoding {
+ single-ASN1-type '00'H
+ }
+ },
+ a-ny 'ff'H,
+ ext-impl {
+ direct-reference 1.17.366,
+ indirect-reference 40,
+ data-value-descriptor '4120766572792077696c642074797065206f66206461746100'H,
+ encoding {
+ single-ASN1-type '00'H
+ }
+ },
+ any-impl 'ff'H,
+ ext-expl {
+ direct-reference 1.17.258,
+ indirect-reference 12,
+ data-value-descriptor '4120766572792077696c642074797065206f66206461746100'H,
+ encoding {
+ single-ASN1-type '00'H
+ }
+ },
+ any-expl '0010'H
+}
+
+"EXTERNAL" t_test = 5
+{
+ ext {
+ direct-reference 1.17.402,
+ indirect-reference 12,
+ data-value-descriptor '4120766572792077696c642074797065206f66206461746100'H,
+ encoding {
+ octet-aligned '536f6d652074657374206461746100'H
+ }
+ },
+ a-ny "mkpelist:testdata",
+ ext-impl {
+ direct-reference 1.17.312,
+ indirect-reference 16,
+ data-value-descriptor '4120766572792077696c642074797065206f66206461746100'H,
+ encoding {
+ single-ASN1-type 'ff'H
+ }
+ },
+ any-impl {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H,
+ [PRIVATE 37] '00'H,
+ [PRIVATE 50] 'ff'H,
+ [PRIVATE 65] "\b",
+ [PRIVATE 82] "\t",
+ [PRIVATE 101] "\n",
+ [PRIVATE 122] '0b'H,
+ [PRIVATE 145] "mkpelist:testdata",
+ [PRIVATE 170] "mkpelist:testdata",
+ [PRIVATE 197] '0010'H,
+ [PRIVATE 226] '0010'H,
+ [PRIVATE 15] {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H,
+ [PRIVATE 37] '00'H,
+ [PRIVATE 50] 'ff'H,
+ [PRIVATE 65] "\b",
+ [PRIVATE 82] "\t",
+ [PRIVATE 101] "\n",
+ [PRIVATE 122] '0b'H,
+ [PRIVATE 145] "mkpelist:testdata",
+ [PRIVATE 170] "mkpelist:testdata",
+ [PRIVATE 197] '0010'H,
+ [PRIVATE 226] '0010'H
+ },
+ [PRIVATE 16] {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H,
+ [PRIVATE 37] '00'H,
+ [PRIVATE 50] 'ff'H,
+ [PRIVATE 65] "\b",
+ [PRIVATE 82] "\t",
+ [PRIVATE 101] "\n",
+ [PRIVATE 122] '0b'H,
+ [PRIVATE 145] "mkpelist:testdata",
+ [PRIVATE 170] "mkpelist:testdata",
+ [PRIVATE 197] '0010'H,
+ [PRIVATE 226] '0010'H,
+ [PRIVATE 15] {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H,
+ [PRIVATE 37] '00'H,
+ [PRIVATE 50] 'ff'H,
+ [PRIVATE 65] "\b",
+ [PRIVATE 82] "\t",
+ [PRIVATE 101] "\n",
+ [PRIVATE 122] '0b'H,
+ [PRIVATE 145] "mkpelist:testdata",
+ [PRIVATE 170] "mkpelist:testdata",
+ [PRIVATE 197] '0010'H,
+ [PRIVATE 226] '0010'H
+ }
+ },
+ [PRIVATE 325] '00'H,
+ [PRIVATE 362] 'ff'H,
+ [PRIVATE 401] '14'H,
+ [PRIVATE 442] '15'H,
+ [PRIVATE 485] "mkpelist:testdata",
+ [PRIVATE 530] 'ff'H,
+ [PRIVATE 577] '18'H,
+ [PRIVATE 626] '19'H,
+ [PRIVATE 677] "mkpelist:testdata",
+ [PRIVATE 730] '0010'H,
+ [PRIVATE 27] {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H,
+ [PRIVATE 37] '00'H,
+ [PRIVATE 50] 'ff'H,
+ [PRIVATE 65] "\b",
+ [PRIVATE 82] "\t",
+ [PRIVATE 101] "\n",
+ [PRIVATE 122] '0b'H,
+ [PRIVATE 145] "mkpelist:testdata",
+ [PRIVATE 170] "mkpelist:testdata",
+ [PRIVATE 197] '0010'H,
+ [PRIVATE 226] '0010'H,
+ [PRIVATE 15] {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H,
+ [PRIVATE 37] '00'H,
+ [PRIVATE 50] 'ff'H,
+ [PRIVATE 65] "\b",
+ [PRIVATE 82] "\t",
+ [PRIVATE 101] "\n",
+ [PRIVATE 122] '0b'H,
+ [PRIVATE 145] "mkpelist:testdata",
+ [PRIVATE 170] "mkpelist:testdata",
+ [PRIVATE 197] '0010'H,
+ [PRIVATE 226] '0010'H
+ },
+ [PRIVATE 16] {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H,
+ [PRIVATE 37] '00'H,
+ [PRIVATE 50] 'ff'H,
+ [PRIVATE 65] "\b",
+ [PRIVATE 82] "\t",
+ [PRIVATE 101] "\n",
+ [PRIVATE 122] '0b'H,
+ [PRIVATE 145] "mkpelist:testdata",
+ [PRIVATE 170] "mkpelist:testdata",
+ [PRIVATE 197] '0010'H,
+ [PRIVATE 226] '0010'H,
+ [PRIVATE 15] {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H,
+ [PRIVATE 37] '00'H,
+ [PRIVATE 50] 'ff'H,
+ [PRIVATE 65] "\b",
+ [PRIVATE 82] "\t",
+ [PRIVATE 101] "\n",
+ [PRIVATE 122] '0b'H,
+ [PRIVATE 145] "mkpelist:testdata",
+ [PRIVATE 170] "mkpelist:testdata",
+ [PRIVATE 197] '0010'H,
+ [PRIVATE 226] '0010'H
+ }
+ },
+ [PRIVATE 325] '00'H,
+ [PRIVATE 362] 'ff'H,
+ [PRIVATE 401] '14'H,
+ [PRIVATE 442] '15'H,
+ [PRIVATE 485] "mkpelist:testdata",
+ [PRIVATE 530] 'ff'H,
+ [PRIVATE 577] '18'H,
+ [PRIVATE 626] '19'H,
+ [PRIVATE 677] "mkpelist:testdata",
+ [PRIVATE 730] '0010'H
+ },
+ [PRIVATE 842] 'ff'H,
+ [PRIVATE 901] '1e'H,
+ [PRIVATE 962] "mkpelist:testdata",
+ [PRIVATE 1025] '00'H,
+ [PRIVATE 1090] "!",
+ [PRIVATE 1157] "mkpelist:testdata",
+ [PRIVATE 1226] '0010'H,
+ [PRIVATE 35] {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H,
+ [PRIVATE 37] '00'H,
+ [PRIVATE 50] 'ff'H,
+ [PRIVATE 65] "\b",
+ [PRIVATE 82] "\t",
+ [PRIVATE 101] "\n",
+ [PRIVATE 122] '0b'H,
+ [PRIVATE 145] "mkpelist:testdata",
+ [PRIVATE 170] "mkpelist:testdata",
+ [PRIVATE 197] '0010'H,
+ [PRIVATE 226] '0010'H,
+ [PRIVATE 15] {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H,
+ [PRIVATE 37] '00'H,
+ [PRIVATE 50] 'ff'H,
+ [PRIVATE 65] "\b",
+ [PRIVATE 82] "\t",
+ [PRIVATE 101] "\n",
+ [PRIVATE 122] '0b'H,
+ [PRIVATE 145] "mkpelist:testdata",
+ [PRIVATE 170] "mkpelist:testdata",
+ [PRIVATE 197] '0010'H,
+ [PRIVATE 226] '0010'H
+ },
+ [PRIVATE 16] {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H,
+ [PRIVATE 37] '00'H,
+ [PRIVATE 50] 'ff'H,
+ [PRIVATE 65] "\b",
+ [PRIVATE 82] "\t",
+ [PRIVATE 101] "\n",
+ [PRIVATE 122] '0b'H,
+ [PRIVATE 145] "mkpelist:testdata",
+ [PRIVATE 170] "mkpelist:testdata",
+ [PRIVATE 197] '0010'H,
+ [PRIVATE 226] '0010'H,
+ [PRIVATE 15] {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H,
+ [PRIVATE 37] '00'H,
+ [PRIVATE 50] 'ff'H,
+ [PRIVATE 65] "\b",
+ [PRIVATE 82] "\t",
+ [PRIVATE 101] "\n",
+ [PRIVATE 122] '0b'H,
+ [PRIVATE 145] "mkpelist:testdata",
+ [PRIVATE 170] "mkpelist:testdata",
+ [PRIVATE 197] '0010'H,
+ [PRIVATE 226] '0010'H
+ }
+ },
+ [PRIVATE 325] '00'H,
+ [PRIVATE 362] 'ff'H,
+ [PRIVATE 401] '14'H,
+ [PRIVATE 442] '15'H,
+ [PRIVATE 485] "mkpelist:testdata",
+ [PRIVATE 530] 'ff'H,
+ [PRIVATE 577] '18'H,
+ [PRIVATE 626] '19'H,
+ [PRIVATE 677] "mkpelist:testdata",
+ [PRIVATE 730] '0010'H,
+ [PRIVATE 27] {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H,
+ [PRIVATE 37] '00'H,
+ [PRIVATE 50] 'ff'H,
+ [PRIVATE 65] "\b",
+ [PRIVATE 82] "\t",
+ [PRIVATE 101] "\n",
+ [PRIVATE 122] '0b'H,
+ [PRIVATE 145] "mkpelist:testdata",
+ [PRIVATE 170] "mkpelist:testdata",
+ [PRIVATE 197] '0010'H,
+ [PRIVATE 226] '0010'H,
+ [PRIVATE 15] {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H,
+ [PRIVATE 37] '00'H,
+ [PRIVATE 50] 'ff'H,
+ [PRIVATE 65] "\b",
+ [PRIVATE 82] "\t",
+ [PRIVATE 101] "\n",
+ [PRIVATE 122] '0b'H,
+ [PRIVATE 145] "mkpelist:testdata",
+ [PRIVATE 170] "mkpelist:testdata",
+ [PRIVATE 197] '0010'H,
+ [PRIVATE 226] '0010'H
+ },
+ [PRIVATE 16] {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H,
+ [PRIVATE 37] '00'H,
+ [PRIVATE 50] 'ff'H,
+ [PRIVATE 65] "\b",
+ [PRIVATE 82] "\t",
+ [PRIVATE 101] "\n",
+ [PRIVATE 122] '0b'H,
+ [PRIVATE 145] "mkpelist:testdata",
+ [PRIVATE 170] "mkpelist:testdata",
+ [PRIVATE 197] '0010'H,
+ [PRIVATE 226] '0010'H,
+ [PRIVATE 15] {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H,
+ [PRIVATE 37] '00'H,
+ [PRIVATE 50] 'ff'H,
+ [PRIVATE 65] "\b",
+ [PRIVATE 82] "\t",
+ [PRIVATE 101] "\n",
+ [PRIVATE 122] '0b'H,
+ [PRIVATE 145] "mkpelist:testdata",
+ [PRIVATE 170] "mkpelist:testdata",
+ [PRIVATE 197] '0010'H,
+ [PRIVATE 226] '0010'H
+ }
+ },
+ [PRIVATE 325] '00'H,
+ [PRIVATE 362] 'ff'H,
+ [PRIVATE 401] '14'H,
+ [PRIVATE 442] '15'H,
+ [PRIVATE 485] "mkpelist:testdata",
+ [PRIVATE 530] 'ff'H,
+ [PRIVATE 577] '18'H,
+ [PRIVATE 626] '19'H,
+ [PRIVATE 677] "mkpelist:testdata",
+ [PRIVATE 730] '0010'H
+ },
+ [PRIVATE 842] 'ff'H,
+ [PRIVATE 901] '1e'H,
+ [PRIVATE 962] "mkpelist:testdata",
+ [PRIVATE 1025] '00'H,
+ [PRIVATE 1090] "!",
+ [PRIVATE 1157] "mkpelist:testdata",
+ [PRIVATE 1226] '0010'H
+ },
+ [PRIVATE 1370] 'ff'H,
+ [PRIVATE 1445] "&",
+ [PRIVATE 1522] "mkpelist:testdata",
+ [PRIVATE 1601] "(",
+ [PRIVATE 1682] "mkpelist:testdata",
+ [PRIVATE 1765] '0010'H
+ },
+ ext-expl {
+ direct-reference 1.17.222,
+ indirect-reference 16,
+ data-value-descriptor '4120766572792077696c642074797065206f66206461746100'H,
+ encoding {
+ octet-aligned '536f6d652074657374206461746100'H
+ }
+ },
+ any-expl "mkpelist:testdata"
+}
+
+"EXTERNAL" t_test = 4
+{
+ ext {
+ direct-reference 1.17.330,
+ data-value-descriptor '4120766572792077696c642074797065206f66206461746100'H,
+ encoding {
+ octet-aligned '536f6d652074657374206461746100'H
+ }
+ },
+ a-ny "!",
+ ext-impl {
+ direct-reference 1.17.258,
+ indirect-reference 12,
+ data-value-descriptor '4120766572792077696c642074797065206f66206461746100'H,
+ encoding {
+ single-ASN1-type '00'H
+ }
+ },
+ any-impl '0010'H,
+ ext-expl {
+ direct-reference 1.17.186,
+ indirect-reference 4,
+ data-value-descriptor '4120766572792077696c642074797065206f66206461746100'H,
+ encoding {
+ octet-aligned '536f6d652074657374206461746100'H
+ }
+ },
+ any-expl 'ff'H
+}
+
+"EXTERNAL" t_test = 3
+{
+ ext {
+ direct-reference 1.17.258,
+ indirect-reference 12,
+ data-value-descriptor '4120766572792077696c642074797065206f66206461746100'H,
+ encoding {
+ single-ASN1-type '00'H
+ }
+ },
+ a-ny '19'H,
+ ext-impl {
+ direct-reference 1.17.204,
+ indirect-reference 32,
+ data-value-descriptor '4120766572792077696c642074797065206f66206461746100'H,
+ encoding {
+ single-ASN1-type 'ff'H
+ }
+ },
+ any-impl '0010'H,
+ ext-expl {
+ direct-reference 1.17.150,
+ indirect-reference 20,
+ data-value-descriptor '4120766572792077696c642074797065206f66206461746100'H,
+ encoding {
+ single-ASN1-type 'ff'H
+ }
+ },
+ any-expl 'ff'H
+}
+
+"EXTERNAL" t_test = 2
+{
+ ext {
+ direct-reference 1.17.186,
+ indirect-reference 4,
+ data-value-descriptor '4120766572792077696c642074797065206f66206461746100'H,
+ encoding {
+ octet-aligned '536f6d652074657374206461746100'H
+ }
+ },
+ a-ny {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H,
+ [PRIVATE 37] '00'H,
+ [PRIVATE 50] 'ff'H,
+ [PRIVATE 65] "\b",
+ [PRIVATE 82] "\t",
+ [PRIVATE 101] "\n",
+ [PRIVATE 122] '0b'H,
+ [PRIVATE 145] "mkpelist:testdata",
+ [PRIVATE 170] "mkpelist:testdata",
+ [PRIVATE 197] '0010'H,
+ [PRIVATE 226] '0010'H,
+ [PRIVATE 15] {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H,
+ [PRIVATE 37] '00'H,
+ [PRIVATE 50] 'ff'H,
+ [PRIVATE 65] "\b",
+ [PRIVATE 82] "\t",
+ [PRIVATE 101] "\n",
+ [PRIVATE 122] '0b'H,
+ [PRIVATE 145] "mkpelist:testdata",
+ [PRIVATE 170] "mkpelist:testdata",
+ [PRIVATE 197] '0010'H,
+ [PRIVATE 226] '0010'H
+ }
+ },
+ ext-impl {
+ direct-reference 1.17.150,
+ indirect-reference 20,
+ data-value-descriptor '4120766572792077696c642074797065206f66206461746100'H,
+ encoding {
+ single-ASN1-type 'ff'H
+ }
+ },
+ any-impl 'ff'H,
+ ext-expl {
+ direct-reference 1.17.114,
+ indirect-reference 16,
+ data-value-descriptor '4120766572792077696c642074797065206f66206461746100'H,
+ encoding {
+ octet-aligned '536f6d652074657374206461746100'H
+ }
+ },
+ any-expl '15'H
+}
+
+"EXTERNAL" t_test = 1
+{
+ ext {
+ direct-reference 1.17.114,
+ indirect-reference 16,
+ data-value-descriptor '4120766572792077696c642074797065206f66206461746100'H,
+ encoding {
+ octet-aligned '536f6d652074657374206461746100'H
+ }
+ },
+ a-ny "\t",
+ ext-impl {
+ direct-reference 1.17.96,
+ indirect-reference 28,
+ data-value-descriptor '4120766572792077696c642074797065206f66206461746100'H,
+ encoding {
+ single-ASN1-type '00'H
+ }
+ },
+ any-impl '0b'H,
+ ext-expl {
+ direct-reference 1.17.78,
+ indirect-reference 48,
+ data-value-descriptor '4120766572792077696c642074797065206f66206461746100'H,
+ encoding {
+ octet-aligned '536f6d652074657374206461746100'H
+ }
+ },
+ any-expl "mkpelist:testdata"
+}
+
+"Optimised" t_test = 8
+{
+ o1 '0001010000110001000100100011011100011010'B,
+ o2 "Peckling Worsley!!!!",
+ o3 {
+ a-seq {
+ fred 10,
+ george TRUE
+ }
+ },
+ o4 {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H,
+ [PRIVATE 37] '00'H,
+ [PRIVATE 50] 'ff'H,
+ [PRIVATE 65] "\b"
+ },
+ {
+ o5 {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H,
+ [PRIVATE 37] '00'H,
+ [PRIVATE 50] 'ff'H,
+ [PRIVATE 65] "\b"
+ },
+ o6 {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H,
+ [PRIVATE 37] '00'H,
+ [PRIVATE 50] 'ff'H,
+ [PRIVATE 65] "\b"
+ },
+ o7 1.17
+ }
+}
+
+"Optimised" t_test = 7
+{
+ o1 '0001010000110001000100100011011100011010'B,
+ o2 "Peckling Worsley!!!!",
+ o3 {
+ a-seq {
+ fred 10,
+ george TRUE
+ }
+ },
+ o4 {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H,
+ [PRIVATE 37] '00'H,
+ [PRIVATE 50] 'ff'H
+ },
+ {
+ o5 {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H,
+ [PRIVATE 37] '00'H,
+ [PRIVATE 50] 'ff'H
+ },
+ o6 {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H,
+ [PRIVATE 37] '00'H,
+ [PRIVATE 50] 'ff'H
+ },
+ o7 1.17
+ }
+}
+
+"Optimised" t_test = 6
+{
+ o1 '0001010000110001000100100011011100011010'B,
+ o2 "Peckling Worsley!!!!",
+ o3 {
+ a-seq {
+ fred 10,
+ george TRUE
+ }
+ },
+ o4 {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H,
+ [PRIVATE 37] '00'H
+ },
+ {
+ o5 {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H,
+ [PRIVATE 37] '00'H
+ },
+ o6 {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H,
+ [PRIVATE 37] '00'H
+ },
+ o7 1.17
+ }
+}
+
+"Optimised" t_test = 5
+{
+ o1 '0001010000110001000100100011011100011010'B,
+ o2 "Peckling Worsley!!!!",
+ o3 {
+ a-seq {
+ fred 10,
+ george TRUE
+ }
+ },
+ o4 {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H
+ },
+ {
+ o5 {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H
+ },
+ o6 {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H,
+ [PRIVATE 26] 'ff'H
+ },
+ o7 1.17.48.53.58
+ }
+}
+
+"Optimised" t_test = 4
+{
+ o1 '0001010000110001000100100011011100011010'B,
+ o2 "Peckling Worsley!!!!",
+ o3 {
+ a-seq {
+ fred 10,
+ george TRUE
+ }
+ },
+ o4 {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H
+ },
+ {
+ o5 {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H
+ },
+ o6 {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H,
+ [PRIVATE 17] '00'H
+ },
+ o7 1.17.45.49
+ }
+}
+
+"Optimised" t_test = 3
+{
+ o1 '0001010000110001000100100011011100011010'B,
+ o2 "Peckling Worsley!!!!",
+ o3 {
+ a-seq {
+ fred 10,
+ george TRUE
+ }
+ },
+ o4 {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H
+ },
+ {
+ o5 {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H
+ },
+ o6 {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H,
+ [PRIVATE 10] 'ff'H
+ },
+ o7 1.17.42
+ }
+}
+
+"Optimised" t_test = 2
+{
+ o1 '0001010000110001000100100011011100011010'B,
+ o2 "Peckling Worsley!!!!",
+ o3 {
+ a-seq {
+ fred 10,
+ george TRUE
+ }
+ },
+ o4 {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H
+ },
+ {
+ o5 {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H
+ },
+ o6 {
+ [PRIVATE 2] 'ff'H,
+ [PRIVATE 5] '00'H
+ },
+ o7 1.17
+ }
+}
+
+"Optimised" t_test = 1
+{
+ o1 '0001010000110001000100100011011100011010'B,
+ o2 "Peckling Worsley!!!!",
+ o3 {
+ a-seq {
+ fred 10,
+ george TRUE
+ }
+ },
+ o4 {
+ [PRIVATE 2] 'ff'H
+ },
+ {
+ o5 {
+ [PRIVATE 2] 'ff'H
+ },
+ o6 {
+ [PRIVATE 2] 'ff'H
+ },
+ o7 1.17
+ }
+}
+
+"External References" t_test = 6
+{
+ a-ref {
+ a1 101910,
+ a2 -304985,
+ a3 13,
+ a4 {
+ a-seq {
+ fred 998877
+ }
+ }
+ },
+ b-ref {
+ a1 101910,
+ a2 -304985,
+ a3 13,
+ a4 {
+ a-seq {
+ fred 998877
+ }
+ }
+ },
+ c-ref {
+ c1 {
+ o-c1 '416e6472657720576f72736c657921212100'H
+ },
+ c2 {
+ b-c2 '0000001000000001000000010000011100111111'B
+ },
+ c3 {
+ seq-c3 {
+ seq-c3-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ seq-c3-i 40938,
+ seq-c3-o '4a616d657320576f72736c65792121212100'H
+ }
+ },
+ c4 {
+ c4-choice {
+ sc-b-i 13151
+ }
+ }
+ }
+}
+
+"External References" t_test = 5
+{
+ a-ref {
+ a1 101910,
+ a2 -304985,
+ a3 13,
+ a4 {
+ a-seq {
+ fred 998877
+ }
+ }
+ },
+ b-ref {
+ a1 101910,
+ a2 -304985,
+ a3 13,
+ a4 {
+ a-seq {
+ fred 998877
+ }
+ }
+ },
+ c-ref {
+ c1 {
+ i-c1 10101
+ },
+ c2 {
+ o-c2 '5269636861726420576f72736c6579212100'H
+ },
+ c3 {
+ i-c3 689364
+ },
+ c4 {
+ c4-choice {
+ sc-a-i 16891
+ }
+ }
+ },
+ e-ref {
+ a1 101910,
+ a2 -304985,
+ a3 13,
+ a4 {
+ a-seq {
+ fred 998877
+ }
+ }
+ }
+}
+
+"External References" t_test = 4
+{
+ a-ref {
+ a1 101910,
+ a2 -304985,
+ a3 13,
+ a4 {
+ a-seq {
+ fred 998877
+ }
+ }
+ },
+ b-ref {
+ a1 101910,
+ a2 -304985,
+ a3 13,
+ a4 {
+ a-seq {
+ fred 998877
+ }
+ }
+ },
+ c-ref {
+ c1 {
+ obj-c1 {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ }
+ },
+ c2 {
+ i-c2 1212
+ },
+ c3 {
+ set-c3 {
+ set-c3-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ set-c3-i 264504,
+ set-c3-o '5061747269636b20576f72736c6579212100'H
+ }
+ },
+ c4 {
+ c4-choice {
+ c4-obj {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ }
+ }
+ }
+ }
+}
+
+"External References" t_test = 3
+{
+ a-ref {
+ a1 101910,
+ a2 -304985,
+ a3 13,
+ a4 {
+ a-seq {
+ fred 998877
+ }
+ }
+ },
+ b-ref {
+ a1 101910,
+ a2 -304985,
+ a3 13,
+ a4 {
+ a-seq {
+ fred 998877
+ }
+ }
+ },
+ c-ref {
+ c1 {
+ f-c1 TRUE
+ },
+ c2 {
+ obj-c2 {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ }
+ },
+ c3 {
+ seq-c3 {
+ seq-c3-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ seq-c3-i 40938,
+ seq-c3-o '4a616d657320576f72736c65792121212100'H
+ }
+ },
+ c4 {
+ c4-choice {
+ c4-i 10938
+ }
+ }
+ },
+ e-ref {
+ a1 101910,
+ a2 -304985,
+ a3 13,
+ a4 {
+ a-seq {
+ fred 998877
+ }
+ }
+ }
+}
+
+"External References" t_test = 2
+{
+ a-ref {
+ a1 101910,
+ a2 -304985,
+ a3 13,
+ a4 {
+ a-seq {
+ fred 998877
+ }
+ }
+ },
+ b-ref {
+ a1 101910,
+ a2 -304985,
+ a3 13,
+ a4 {
+ a-seq {
+ fred 998877
+ }
+ }
+ },
+ c-ref {
+ c1 {
+ b-c1 '0000001000000010000000100000011100111111'B
+ },
+ c2 {
+ f-c2 TRUE
+ },
+ c3 {
+ i-c3 689364
+ },
+ c4 {
+ c4-choice {
+ sc-b-i 13151
+ }
+ }
+ }
+}
+
+"External References" t_test = 1
+{
+ a-ref {
+ a1 101910,
+ a2 -304985,
+ a3 13,
+ a4 {
+ a-seq {
+ fred 998877
+ }
+ }
+ },
+ b-ref {
+ a1 101910,
+ a2 -304985,
+ a3 13,
+ a4 {
+ a-seq {
+ fred 998877
+ }
+ }
+ },
+ c-ref {
+ c1 {
+ o-c1 '416e6472657720576f72736c657921212100'H
+ },
+ c2 {
+ b-c2 '0000001000000001000000010000011100111111'B
+ },
+ c3 {
+ set-c3 {
+ set-c3-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ set-c3-i 264504,
+ set-c3-o '5061747269636b20576f72736c6579212100'H
+ }
+ },
+ c4 {
+ c4-choice {
+ sc-a-i 16891
+ }
+ }
+ },
+ e-ref {
+ a1 101910,
+ a2 -304985,
+ a3 13,
+ a4 {
+ a-seq {
+ fred 998877
+ }
+ }
+ }
+}
+
+"Default test" t_test = 12
+{
+ a-def 1,
+ okay FALSE,
+ big-def {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-def {
+ colour 1,
+ version { basic }
+ },
+ st-def {
+ beer 2,
+ spirit 0
+ }
+}
+
+"Default test" t_test = 11
+{
+ a-def 1,
+ c-def '100000000'B,
+ okay FALSE,
+ big-def {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ }
+}
+
+"Default test" t_test = 10
+{
+ a-def 1,
+ b-def '537573616e20536962656c202121212100'H,
+ big-def {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-def {
+ colour 1,
+ oem-oct '4a756c696120447a75696b6173202121212100'H,
+ version { basic }
+ }
+}
+
+"Default test" t_test = 9
+{
+ a-def 1,
+ okay FALSE,
+ big-def {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ st-def {}
+}
+
+"Default test" t_test = 8
+{
+ a-def 1,
+ big-def {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-def {
+ colour 1,
+ version { basic }
+ },
+ st-def {
+ beer 2,
+ spirit 0
+ }
+}
+
+"Default test" t_test = 7
+{
+ a-def 1,
+ okay FALSE,
+ big-def {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ st-def {
+ wine 2,
+ beer 2
+ }
+}
+
+"Default test" t_test = 6
+{
+ a-def 1,
+ b-def '537573616e20536962656c202121212100'H,
+ big-def {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ st-def {}
+}
+
+"Default test" t_test = 5
+{
+ a-def 1,
+ c-def '100000000'B,
+ okay FALSE,
+ big-def {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ }
+}
+
+"Default test" t_test = 4
+{
+ a-def 1,
+ okay FALSE,
+ big-def {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-def {
+ colour 1,
+ version { basic }
+ },
+ st-def {
+ beer 2,
+ spirit 0
+ }
+}
+
+"Default test" t_test = 3
+{
+ a-def 1,
+ c-def '100000000'B,
+ big-def {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ st-def {}
+}
+
+"Default test" t_test = 2
+{
+ a-def 1,
+ b-def '537573616e20536962656c202121212100'H,
+ big-def {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-def {
+ colour 1,
+ version { basic }
+ },
+ st-def {
+ spirit 0
+ }
+}
+
+"Default test" t_test = 1
+{
+ a-def 1,
+ big-def {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-def {
+ version { basic }
+ },
+ st-def {
+ beer 2,
+ spirit 0
+ }
+}
+
+"Optional test" t_test = 8
+{
+ b-opt '537573616e2048616e6e616820536962656c00'H,
+ etag-opt 2983461
+}
+
+"Optional test" t_test = 7
+{
+ a-opt 192837,
+ b-opt '537573616e2048616e6e616820536962656c00'H,
+ d-opt TRUE,
+ e-opt NULL,
+ big-opt {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-opt {
+ oem-int 197336,
+ oem-oct '4c696e6720576f72736c657900'H
+ },
+ st-opt {
+ st-int0 85659,
+ st-int2 967768
+ },
+ obj-opt {
+ a-seq {
+ fred 10,
+ george TRUE
+ }
+ },
+ ch-opt {
+ ch-2 28828
+ }
+}
+
+"Optional test" t_test = 6
+{
+ b-opt '537573616e2048616e6e616820536962656c00'H,
+ c-opt '0000101000001111000000100000011100111111'B,
+ d-opt TRUE,
+ e-opt NULL
+}
+
+"Optional test" t_test = 5
+{
+ a-opt 192837,
+ b-opt '537573616e2048616e6e616820536962656c00'H,
+ c-opt '0000101000001111000000100000011100111111'B,
+ e-opt NULL,
+ big-opt {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-opt {
+ oem-int 197336,
+ oem-oct '4c696e6720576f72736c657900'H
+ },
+ st-opt {
+ st-int0 85659,
+ st-int2 967768
+ },
+ obj-opt {
+ a-seq {
+ fred 10,
+ george TRUE
+ }
+ },
+ ch-opt {
+ ch-2 28828
+ }
+}
+
+"Optional test" t_test = 4
+{
+ b-opt '537573616e2048616e6e616820536962656c00'H,
+ e-opt NULL
+}
+
+"Optional test" t_test = 3
+{
+ a-opt 192837,
+ b-opt '537573616e2048616e6e616820536962656c00'H,
+ d-opt TRUE,
+ big-opt {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-opt {
+ oem-int 197336,
+ oem-oct '4c696e6720576f72736c657900'H
+ },
+ st-opt {
+ st-int0 85659,
+ st-int2 967768
+ },
+ obj-opt {
+ a-seq {
+ fred 10,
+ george TRUE
+ }
+ },
+ ch-opt {
+ ch-2 28828
+ }
+}
+
+"Optional test" t_test = 2
+{
+ b-opt '537573616e2048616e6e616820536962656c00'H,
+ c-opt '0000101000001111000000100000011100111111'B,
+ d-opt TRUE
+}
+
+"Optional test" t_test = 1
+{
+ a-opt 192837,
+ b-opt '537573616e2048616e6e616820536962656c00'H,
+ c-opt '0000101000001111000000100000011100111111'B,
+ big-opt {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-opt {
+ oem-int 197336,
+ oem-oct '4c696e6720576f72736c657900'H
+ },
+ st-opt {
+ st-int0 85659,
+ st-int2 967768
+ },
+ obj-opt {
+ a-seq {
+ fred 10,
+ george TRUE
+ }
+ },
+ ch-opt {
+ ch-2 28828
+ }
+}
+
+"Choice" t_test = 7
+{
+ c1 {
+ b-c1 '0000001000000010000000100000011100111111'B
+ },
+ c2 {
+ f-c2 TRUE
+ },
+ c3 {
+ set-c3 {
+ set-c3-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ set-c3-i 264504,
+ set-c3-o '5061747269636b20576f72736c6579212100'H
+ }
+ },
+ c4 {
+ c4-choice {
+ c4-i 10938
+ }
+ }
+}
+
+"Choice" t_test = 6
+{
+ c1 {
+ o-c1 '416e6472657720576f72736c657921212100'H
+ },
+ c2 {
+ b-c2 '0000001000000001000000010000011100111111'B
+ },
+ c3 {
+ seq-c3 {
+ seq-c3-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ seq-c3-i 40938,
+ seq-c3-o '4a616d657320576f72736c65792121212100'H
+ }
+ },
+ c4 {
+ c4-choice {
+ sc-b-i 13151
+ }
+ }
+}
+
+"Choice" t_test = 5
+{
+ c1 {
+ i-c1 10101
+ },
+ c2 {
+ o-c2 '5269636861726420576f72736c6579212100'H
+ },
+ c3 {
+ i-c3 689364
+ },
+ c4 {
+ c4-choice {
+ sc-a-i 16891
+ }
+ }
+}
+
+"Choice" t_test = 4
+{
+ c1 {
+ obj-c1 {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ }
+ },
+ c2 {
+ i-c2 1212
+ },
+ c3 {
+ set-c3 {
+ set-c3-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ set-c3-i 264504,
+ set-c3-o '5061747269636b20576f72736c6579212100'H
+ }
+ },
+ c4 {
+ c4-choice {
+ c4-obj {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ }
+ }
+ }
+}
+
+"Choice" t_test = 3
+{
+ c1 {
+ f-c1 TRUE
+ },
+ c2 {
+ obj-c2 {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ }
+ },
+ c3 {
+ seq-c3 {
+ seq-c3-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ seq-c3-i 40938,
+ seq-c3-o '4a616d657320576f72736c65792121212100'H
+ }
+ },
+ c4 {
+ c4-choice {
+ c4-i 10938
+ }
+ }
+}
+
+"Choice" t_test = 2
+{
+ c1 {
+ b-c1 '0000001000000010000000100000011100111111'B
+ },
+ c2 {
+ f-c2 TRUE
+ },
+ c3 {
+ i-c3 689364
+ },
+ c4 {
+ c4-choice {
+ sc-b-i 13151
+ }
+ }
+}
+
+"Choice" t_test = 1
+{
+ c1 {
+ o-c1 '416e6472657720576f72736c657921212100'H
+ },
+ c2 {
+ b-c2 '0000001000000001000000010000011100111111'B
+ },
+ c3 {
+ set-c3 {
+ set-c3-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ set-c3-i 264504,
+ set-c3-o '5061747269636b20576f72736c6579212100'H
+ }
+ },
+ c4 {
+ c4-choice {
+ sc-a-i 16891
+ }
+ }
+}
+
+"SEQ OF and SET OF" t_test = 10
+{
+ sqof-test1 {
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ }
+ },
+ stof-test1 {
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ }
+ },
+ i-test1 33,
+ sqof-test2 {
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ },
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ },
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ }
+ },
+ stof-test2 {
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ },
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ },
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ }
+ },
+ i-test2 99
+}
+
+"SEQ OF and SET OF" t_test = 9
+{
+ sqof-test1 {
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ }
+ },
+ stof-test1 {
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ }
+ },
+ i-test1 33,
+ sqof-test2 {
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ },
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ },
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ }
+ },
+ stof-test2 {
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ },
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ },
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ }
+ },
+ i-test2 99
+}
+
+"SEQ OF and SET OF" t_test = 8
+{
+ sqof-test1 {
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ }
+ },
+ stof-test1 {
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ }
+ },
+ i-test1 33,
+ sqof-test2 {
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ },
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ },
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ }
+ },
+ stof-test2 {
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ },
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ },
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ }
+ },
+ i-test2 99
+}
+
+"SEQ OF and SET OF" t_test = 7
+{
+ sqof-test1 {
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ }
+ },
+ stof-test1 {
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ }
+ },
+ i-test1 33,
+ sqof-test2 {
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ },
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ },
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ }
+ },
+ stof-test2 {
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ },
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ },
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ }
+ },
+ i-test2 99
+}
+
+"SEQ OF and SET OF" t_test = 6
+{
+ sqof-test1 {
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ }
+ },
+ stof-test1 {
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ }
+ },
+ i-test1 33,
+ sqof-test2 {
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ },
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ },
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ }
+ },
+ stof-test2 {
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ },
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ },
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ }
+ },
+ i-test2 99
+}
+
+"SEQ OF and SET OF" t_test = 5
+{
+ sqof-test1 {
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ }
+ },
+ stof-test1 {
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ }
+ },
+ i-test1 33,
+ sqof-test2 {
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ },
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ },
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ }
+ },
+ stof-test2 {
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ },
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ },
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ }
+ },
+ i-test2 99
+}
+
+"SEQ OF and SET OF" t_test = 4
+{
+ sqof-test1 {
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ }
+ },
+ stof-test1 {
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ }
+ },
+ i-test1 33,
+ sqof-test2 {
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ },
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ },
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ }
+ },
+ stof-test2 {
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ },
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ },
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ }
+ },
+ i-test2 99
+}
+
+"SEQ OF and SET OF" t_test = 3
+{
+ sqof-test1 {
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ }
+ },
+ stof-test1 {
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ }
+ },
+ i-test1 33,
+ sqof-test2 {
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ },
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ },
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ }
+ },
+ stof-test2 {
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ },
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ },
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ }
+ },
+ i-test2 99
+}
+
+"SEQ OF and SET OF" t_test = 2
+{
+ sqof-test1 {
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ }
+ },
+ stof-test1 {
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ }
+ },
+ i-test1 33,
+ sqof-test2 {
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ },
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ },
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ }
+ },
+ stof-test2 {
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ },
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ },
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ }
+ },
+ i-test2 99
+}
+
+"SEQ OF and SET OF" t_test = 1
+{
+ sqof-test1 {
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ }
+ },
+ stof-test1 {
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ }
+ },
+ i-test1 33,
+ sqof-test2 {
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ },
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ },
+ {
+ sqof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ sqof-i 212121,
+ sqof-o '456c656d656e743820456d62656464656400'H
+ }
+ },
+ stof-test2 {
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ },
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ },
+ {
+ stof-in {
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+ },
+ stof-i -12345,
+ stof-o '58595a616263646520456d62656464656400'H
+ }
+ },
+ i-test2 99
+}
+
+"Explicit tags" t_test = 1
+{
+ i-expl 35051,
+ o-expl "explicit tagged octet string",
+ b-expl '00111000001110000011100000111111'B,
+ f-expl TRUE,
+ obj-expl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-exp-test {
+ i-ex-int -9,
+ i-ex-oct '4578706c6963697420456d62656464656400'H,
+ i-ex-bit '0000001100000011000000110000001110111111'B
+ }
+}
+
+"Implicit tags" t_test = 1
+{
+ i-impl -1,
+ o-impl '49276d20616e20696d706c6963697420746167676564206f6374657420737472696e6700'H,
+ b-impl '0000000000000000000000011001100000000001'B,
+ f-impl TRUE,
+ obj-impl {
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+ },
+ i-emb-test {
+ i-em-int -101,
+ i-em-oct '496d706c6963697420456d62656464656400'H,
+ i-em-bit '10000000100000001000000010000000'B
+ }
+}
+
+"Embedded Strings" t_test = 1
+{
+ atest 2001,
+ btest "Good bye",
+ ctest '000000110000100010101010'B,
+ big-test {
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+ },
+ emb-test {
+ em-int -101,
+ em-oct "Embedded octet string",
+ em-bit '1111111110101010010101011111100000000001'B
+ }
+}
+
+"Strings" t_test = 1
+{
+ ostring '3132fe00ff6136'H,
+ bstring '10111000000011110000100000010000001000000100000000'B,
+ nstring "123456",
+ pstring "hello, world",
+ tstring "teletex",
+ t61string "T.61",
+ vstring "visible",
+ vis-string "visible again",
+ i646string "who knows what this is",
+ ia5string "This is ASCII\n\r",
+ graphstring "This is a graphic string",
+ genstring "This is a general string"
+}
+
+"Embedded" t_test = 1
+{
+ anMPDU {
+ a-seq {
+ fred 10,
+ george TRUE
+ }
+ },
+ ei 6966
+}
+
+"MPDU" t_test = 1
+{
+ a-seq {
+ fred 10,
+ george TRUE
+ }
+}
+Total 107 = 107 successes 0 failures
diff --git a/src/isode/pepsy/pepsy-driver.h b/src/isode/pepsy/pepsy-driver.h
new file mode 100644
index 000000000..aeffc8e6d
--- /dev/null
+++ b/src/isode/pepsy/pepsy-driver.h
@@ -0,0 +1,53 @@
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:31:08 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:39:58 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:43:07 isode
+ * Release 7.0
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+/*
+ * common definitions for the pepsy driver routines
+ */
+#define PEPSY_VERSION 2
+
+/* find the default entry for this entry - for decoding
+ * - assumes its the next or the one after or the one after that.
+ * old version
+#define FDFLT_B(p) ((((p) + 1)->pe_type == DFLT_B) ? ((p) + 1) : \
+ ((((p) + 2)->pe_type == DFLT_B) ? ((p) + 2): ((p) + 3)))
+ */
+#define FDFLT_B(p) fdflt_b(p) /* try a function */
+
+/* find the entry for this default entry - for encoding
+ * call a function - to keep looking till it finds it, this is the
+ * alternative to the above scheme.
+ */
+#define FDFLT_F(p) fdflt_f(p) /* have to use a function */
+
+/* assumes encoding tables */
+#define OPT_PRESENT(p, parm) (BITTEST(parm + p->pe_ucode, p->pe_tag))
+
+/* assumes decoding tables */
+#define SET_OPT_PRESENT(p, parm) (BITSET(*parm + p->pe_ucode, p->pe_tag))
+#define CLR_OPT_PRESENT(p, parm) (BITCLR(*parm + p->pe_ucode, p->pe_tag))
+
+#define NO_DATA_USED (OK + 1)
diff --git a/src/isode/pepsy/pepsy.1 b/src/isode/pepsy/pepsy.1
new file mode 100644
index 000000000..d0560693b
--- /dev/null
+++ b/src/isode/pepsy/pepsy.1
@@ -0,0 +1,75 @@
+.TH PEPSY 1 "24 Jun 1990"
+.\" $Header$
+.\"
+.\"
+.\" $Log$
+.\" Revision 1.1 1994/06/10 03:31:11 eichin
+.\" autoconfed isode for kerberos work
+.\"
+# Revision 1.1 1994/05/31 20:40:03 eichin
+# reduced-isode release from /mit/isode/isode-subset/src
+#
+.\" Revision 8.0 91/07/17 12:43:07 isode
+.\" Release 7.0
+.\"
+.\"
+.SH NAME
+pepsy \- table driven replacement for posy/pepy
+.SH SYNOPSIS
+.in +.5i
+.ti -.5i
+.B pepsy
+\%[\-A]
+\%[\-a]
+\%[\-C]
+\%[\-f]
+\%[\-h\fIoption\fP]
+\%[\-s]
+\fImodule.py\fR
+.in -.5i
+.SH DESCRIPTION
+The \fIpepsy\fR program reads a description of a \fIpresentation\fR module and
+produces definitions and tables for use with the \fIC\fR programming language.
+It is meant to be backwards-compatible with the \fIposy\fR system.
+(So, \fIpepsy\fR will ignore any \fIpepy\fR-style augmentations in the
+input file.)
+.PP
+The `\-A' (All) switch directs \fIpepsy\fR to generate tables for encoders,
+decoders, and printers.
+.PP
+The `\-a' switch directs \fIpepsy\fR to augment the #include file with
+commentary text.
+.PP
+The '\-C' switch directs \fIpepsy\fR to produce backwards compatible
+code which generates three .h files rather than one.
+.PP
+The `\-f' switch directs \fIpepsy\fR to generate \fIC\fR macros to deallocate
+the structures it defines.
+.PP
+The `\-h' switch enables additional heuristics when \fIpepsy\fR generates a
+\fIC\fR language structure definition.
+Option `0' enables the default heuristics.
+Enabling any other option also results in enabling option `0'.
+Option `1' enables \*(lqclever\*(rq but non\-unique structure naming.
+Option `2' enables the generation of arrays rather than linked-lists
+whenever possible.
+.PP
+Normally, \fIpepsy\fR prints the name of each type as it works.
+The `\-s' switch disables this behavior.
+.SH FILES
+.nf
+.ta \w'\fImodule\fR_pre_defs.h 'u
+\fImodule\fR.ph extern type definitions from \fImodule\fR
+\fImodule\fR_tables.c initialised tables for processing \fImodule\fR
+\fImodule\fR-types.h \fIC\fR structure definitions from \fImodule\fR
+\fImodule\fR_pre_defs.h Preprocessor constants for each type in \fImodule\fR
+\fImodule\fR_defs.h macros to support pepy routines for \fImodule\fR's types
+.re
+.fi
+.SH "SEE ALSO"
+pepy(1), posy(1),
+.br
+\fIThe ISO Development Environment: User's Manual\fR
+.SH AUTHOR
+Andrew Worsley,
+CSIRO and UCL
diff --git a/src/isode/pepsy/pepsy.c b/src/isode/pepsy/pepsy.c
new file mode 100644
index 000000000..4bae33e4c
--- /dev/null
+++ b/src/isode/pepsy/pepsy.c
@@ -0,0 +1,3731 @@
+/* pepsy.c - table driven posy/pepy replacement system */
+
+/* OPEN QUESTIONS:
+
+ How to do smarter DEFAULT determination for the other types and NULLs
+
+ Perhaps pull-up primitive IDentifiers
+
+ Abort a CHOICE encoding if the structure is empty
+
+
+ HEURISTICS
+
+ 1. LANGUAGE SIMPLIFICATIONS:
+
+
+ Pull-up uni-member SEQUENCEs/SETs/CHOICEs
+
+
+ 2. LANGUAGE ASSUMPTIONS:
+
+ Unique tags to avoid conflicts for internal structures (-h1 option)
+
+
+ 3. STYLE ISSUES:
+
+ SEQUENCE/SET OF Type should have Type be an ID for nicer naming
+ */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:31:15 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.2 1994/06/07 03:45:37 eichin
+ * mips doesn't have yylineno either
+ *
+ * Revision 1.1 1994/05/31 20:40:05 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:43:08 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+#include <ctype.h>
+#include <stdio.h>
+#include <varargs.h>
+#include "pepsydefs.h"
+#include "pass2.h"
+
+#if defined(USING_BISON) || defined(mips)
+int yylineno = 0; /* Bison doesn't have yylineno, sigh */
+ /* ultrix doesn't either */
+#endif
+
+
+#define SVAL(s) ((s) ? (s) : "")
+#define PARVAL(s) ((s) ? (s) : "parm")
+
+/* DATA */
+
+static int aflag = 0;
+int Aflag = 0; /* Don't so all modes by default */
+int Cflag = 1; /* combine H files */
+int dflag = 0;
+int Pflag = 0; /* pepy compat ... */
+char *bflag = NULL; /* .. */
+char *iflag = NULL; /* -i file => #include users file */
+char *module_actions = NULL;
+int pepydebug = 0;
+int doexternals = 1;
+int fflag = 0;
+static int linepos = 0;
+int mflag = 0;
+int sflag = 0;
+
+int p_debug = 3;
+int options[NOPTIONS];
+
+char *eval = NULLCP;
+
+char *mymodule = "";
+OID mymoduleid = NULLOID;
+static char modulename[BUFSIZ];
+
+int yysection = YP_DECODER;
+char *yyencpref = "encode";
+char *yydecpref = "decode";
+char *yyprfpref = "print";
+char *yyencdflt = "encode";
+char *yydecdflt = "decode";
+char *yyprfdflt = "print";
+
+static char *classes[] = {
+ "UNIVERSAL ",
+ "APPLICATION ",
+ "",
+ "PRIVATE "
+};
+
+static char *tags[] = {
+ "", "BOOLEAN", "INTEGER", "INTEGER", "BIT STRING", "BIT STRING",
+ "OCTET STRING", "NULL", "SEQUENCE", "SEQUENCE OF", "SEQUENCE", "SET",
+ "SET OF", "SET", "CHOICE", "ANY", "OBJECT IDENTIFIER", "", "ENUMERATED",
+ "REAL", "",
+
+ NULL
+};
+
+struct tuple tuples[] = {
+ YP_BOOL, "PE_CLASS_UNIV", "PE_FORM_PRIM", "PE_PRIM_BOOL",
+ PE_CLASS_UNIV, PE_PRIM_BOOL,
+ YP_INT, "PE_CLASS_UNIV", "PE_FORM_PRIM", "PE_PRIM_INT",
+ PE_CLASS_UNIV, PE_PRIM_INT,
+ YP_INTLIST, "PE_CLASS_UNIV", "PE_FORM_PRIM", "PE_PRIM_INT",
+ PE_CLASS_UNIV, PE_PRIM_INT,
+ YP_BIT, "PE_CLASS_UNIV", NULLCP, "PE_PRIM_BITS",
+ PE_CLASS_UNIV, PE_PRIM_BITS,
+ YP_BITLIST, "PE_CLASS_UNIV", NULLCP, "PE_PRIM_BITS",
+ PE_CLASS_UNIV, PE_PRIM_BITS,
+ YP_OCT, "PE_CLASS_UNIV", NULLCP, "PE_PRIM_OCTS",
+ PE_CLASS_UNIV, PE_PRIM_OCTS,
+ YP_NULL, "PE_CLASS_UNIV", NULLCP, "PE_PRIM_NULL",
+ PE_CLASS_UNIV, PE_PRIM_NULL,
+ YP_OID, "PE_CLASS_UNIV", "PE_FORM_PRIM", "PE_PRIM_OID",
+ PE_CLASS_UNIV, PE_PRIM_OID,
+ YP_SEQ, "PE_CLASS_UNIV", "PE_FORM_CONS", "PE_CONS_SEQ",
+ PE_CLASS_UNIV, PE_CONS_SEQ,
+ YP_SEQTYPE, "PE_CLASS_UNIV", "PE_FORM_CONS", "PE_CONS_SEQ",
+ PE_CLASS_UNIV, PE_CONS_SEQ,
+ YP_SEQLIST, "PE_CLASS_UNIV", "PE_FORM_CONS", "PE_CONS_SEQ",
+ PE_CLASS_UNIV, PE_CONS_SEQ,
+ YP_SET, "PE_CLASS_UNIV", "PE_FORM_CONS", "PE_CONS_SET",
+ PE_CLASS_UNIV, PE_CONS_SET,
+ YP_SETTYPE, "PE_CLASS_UNIV", "PE_FORM_CONS", "PE_CONS_SET",
+ PE_CLASS_UNIV, PE_CONS_SET,
+ YP_SETLIST, "PE_CLASS_UNIV", "PE_FORM_CONS", "PE_CONS_SET",
+ PE_CLASS_UNIV, PE_CONS_SET,
+ YP_ENUMLIST, "PE_CLASS_UNIV", "PE_FORM_PRIM", "PE_PRIM_ENUM",
+ PE_CLASS_UNIV, PE_PRIM_ENUM,
+ YP_REAL, "PE_CLASS_UNIV", "PE_FORM_PRIM", "PE_PRIM_REAL",
+ PE_CLASS_UNIV, PE_PRIM_REAL,
+
+ YP_UNDF
+};
+
+
+static char autogen[BUFSIZ];
+
+char *sysin = NULLCP;
+static char sysout[BUFSIZ];
+static char sysdef[BUFSIZ];
+static char sysact[BUFSIZ];
+
+static FILE *fdef;
+
+
+static MD mymodules = NULLMD;
+
+typedef struct symlist {
+ char *sy_encpref;
+ char *sy_decpref;
+ char *sy_prfpref;
+ char *sy_module;
+ char *sy_name;
+
+ YP sy_type;
+
+ struct symlist *sy_next;
+} symlist, *SY;
+#define NULLSY ((SY) 0)
+
+SY mysymbols = NULLSY;
+
+
+char *gensym (), *modsym (), *array ();
+extern char *my_strcat(), *gfree(), *concat(), *my_new_str();
+extern char *getid();
+MD lookup_module ();
+SY new_symbol (), add_symbol ();
+static double val2real ();
+static void prime_default ();
+static void merge_files ();
+
+static yyerror_aux ();
+static do_struct0 ();
+static do_struct1 ();
+static do_struct2 ();
+static printag ();
+static xalloc ();
+static balloc ();
+static choice_pullup ();
+static components_pullup ();
+static int val2int ();
+static val2prf ();
+static dump_real ();
+static int dfl2int ();
+static print_value ();
+static modsym_aux ();
+static read_ph_file ();
+static write_ph_file ();
+
+extern void exit(); /* to keep lint happy */
+
+FILE *open_ph_file ();
+
+YP lookup_type ();
+
+YT lookup_tag ();
+
+/* MAIN */
+
+/* ARGSUSED */
+
+main (argc, argv, envp)
+int argc;
+char **argv,
+ **envp;
+{
+ int i;
+ register char *cp,
+ *dp;
+
+ dp = pepsyversion + strlen ("pepsy ");
+ (void) fprintf (stderr, "pepsy %s\n", dp);
+
+ sysout[0] = sysdef[0] = sysact[0] = NULL;
+ for (argc--, argv++; argc > 0; argc--, argv++) {
+ cp = *argv;
+
+ if (strcmp (cp, "-A") == 0) {
+ Aflag++;
+ continue;
+ }
+ if (strcmp (cp, "-a") == 0) {
+ aflag++;
+ continue;
+ }
+ if (strcmp (cp, "-C") == 0) {
+ Cflag = 0;
+ continue;
+ }
+ if (strcmp (cp, "-d") == 0) {
+ dflag++;
+ continue;
+ }
+ if (strcmp (cp, "-f") == 0) {
+ dflag++, fflag++;
+ continue;
+ }
+ if (strncmp (cp, "-h", 2) == 0) {
+ if (cp[2] == NULL) {
+ hflag++;
+ continue;
+ }
+ if (sscanf (cp + 2, "%d", &i) != 1 || i >= NOPTIONS)
+ goto usage;
+ hflag++, options[i]++;
+ continue;
+ }
+ if (strcmp (cp, "-m") == 0) {
+ mflag++;
+ continue;
+ }
+ if (strcmp (cp, "-s") == 0) {
+ sflag++;
+ continue;
+ }
+ if (strcmp (cp, "-i") == 0) {
+ argv++;
+ if (argc-- > 0)
+ iflag = *argv;
+ continue;
+ }
+
+ if (sysin) {
+ usage: ;
+ (void) fprintf (stderr,
+ "usage: pepsy [-A] [-a] [-C] [-d] [-f] [-h] [-s] module.py\n");
+ exit (1);
+ }
+
+ if (*cp == '-') {
+ if (*++cp != NULL)
+ goto usage;
+ sysin = "";
+ }
+ sysin = cp;
+ }
+
+ switch (pepydebug = (cp = getenv ("PEPSYTEST")) && *cp ? atoi (cp) : 0) {
+ case 2:
+ yydebug++; /* fall */
+ case 1:
+ sflag++; /* .. */
+ case 0:
+ break;
+ }
+
+ if (sysin == NULLCP)
+ sysin = "";
+
+ if (*sysin && freopen (sysin, "r", stdin) == NULL) {
+ (void) fprintf (stderr, "unable to read "), perror (sysin);
+ exit (1);
+ }
+
+ if (strcmp (sysout, "-") == 0)
+ sysout[0] = NULL;
+ if (*sysout && freopen (sysout, "w", stdout) == NULL) {
+ (void) fprintf (stderr, "unable to write "), perror (sysout);
+ exit (1);
+ }
+
+ if (cp = index (dp, ')')) {
+ for (cp++; *cp != ' '; cp++)
+ if (*cp == NULL)
+ break;
+ if (*cp == NULL)
+ cp = NULL;
+ }
+ if (cp == NULL)
+ cp = dp + strlen (dp);
+ (void) sprintf (autogen, "pepsy %*.*s", cp - dp, cp - dp, dp);
+
+ initoidtbl ();
+
+ exit (yyparse ()); /* NOTREACHED */
+}
+
+/* ERRORS */
+
+yyerror (s)
+register char *s;
+{
+ yyerror_aux (s);
+
+ if (*sysout)
+ (void) unlink (sysout);
+ if (*sysdef)
+ (void) unlink (sysdef);
+ if (*sysact)
+ (void) unlink (sysact);
+
+ exit (1);
+}
+
+#ifndef lint
+warning (va_alist)
+va_dcl
+{
+ char buffer[BUFSIZ];
+ char buffer2[BUFSIZ];
+ va_list ap;
+
+ va_start (ap);
+
+ _asprintf (buffer, NULLCP, ap);
+
+ va_end (ap);
+
+ (void) sprintf (buffer2, "Warning: %s", buffer);
+ yyerror_aux (buffer2);
+}
+
+#else
+
+/* VARARGS1 */
+warning (fmt)
+char *fmt;
+{
+ warning (fmt);
+}
+#endif
+
+static yyerror_aux (s)
+register char *s;
+{
+ if (linepos)
+ (void) fprintf (stderr, "\n"), linepos = 0;
+
+ if (eval)
+ (void) fprintf (stderr, "type %s: ", eval);
+ else
+ (void) fprintf (stderr, "line %d: ", yylineno);
+ (void) fprintf (stderr, "%s\n", s);
+ if (!eval)
+ (void) fprintf (stderr, "last token read was \"%s\"\n", yytext);
+}
+
+/* */
+
+#ifndef lint
+myyerror (va_alist)
+va_dcl
+{
+ char buffer[BUFSIZ];
+ va_list ap;
+
+ va_start (ap);
+
+ _asprintf (buffer, NULLCP, ap);
+
+ va_end (ap);
+
+ yyerror (buffer);
+}
+#else
+/* VARARGS */
+
+myyerror (fmt)
+char *fmt;
+{
+ myyerror (fmt);
+}
+#endif
+
+
+#ifndef lint
+static pyyerror (va_alist)
+va_dcl
+{
+ char buffer[BUFSIZ];
+ register YP yp;
+ va_list ap;
+
+ va_start (ap);
+
+ yp = va_arg (ap, YP);
+
+ _asprintf (buffer, NULLCP, ap);
+
+ va_end (ap);
+
+ yyerror_aux (buffer);
+ print_type (yp, 0);
+
+
+ if (*sysout)
+ (void) unlink (sysout);
+ if (*sysdef)
+ (void) unlink (sysdef);
+ if (*sysact)
+ (void) unlink (sysact);
+
+ exit (1);
+}
+#else
+/* VARARGS */
+
+static pyyerror (yp, fmt)
+YP yp;
+char *fmt;
+{
+ pyyerror (yp, fmt);
+}
+#endif
+
+/* */
+
+yywrap () {
+ if (linepos)
+ (void) fprintf (stderr, "\n"), linepos = 0;
+
+ return 1;
+}
+
+/* */
+
+/* ARGSUSED */
+
+yyprint (s, f, top)
+char *s;
+int f;
+int top;
+{
+ int len;
+ static int nameoutput = 0;
+ static int outputlinelen = 79;
+ static int didf = 0;
+
+ if (sflag || !s)
+ return;
+
+ if (f && didf == 0) {
+ if (linepos)
+ fprintf (stderr, "\n\n");
+ else fprintf (stderr, "\n");
+
+ fprintf (stderr, "%s includes:", mymodule);
+ linepos = (nameoutput = strlen (mymodule) + 10) + 1;
+
+ didf = 1;
+ }
+
+ if (!nameoutput || top) {
+ if (linepos)
+ (void) fprintf (stderr, "\n\n");
+
+ (void) fprintf (stderr, "%s", mymodule);
+ nameoutput = (linepos = strlen (mymodule)) + 1;
+
+#define section(flag,prefix) \
+ if (yysection & (flag)) { \
+ fprintf (stderr, " %s", (prefix)); \
+ linepos += strlen (prefix) + 1; \
+ } \
+ else \
+ fprintf (stderr, " none"), linepos += 5
+ section (YP_ENCODER, yyencpref);
+ section (YP_DECODER, yydecpref);
+ section (YP_PRINTER, yyprfpref);
+
+
+ (void) fprintf (stderr, ":");
+ linepos += 2;
+
+ if (top)
+ return;
+ }
+
+ len = strlen (s) + (f ? 2 : 0);
+ if (linepos != nameoutput)
+ if (len + linepos + 1 > outputlinelen)
+ (void) fprintf (stderr, "\n%*s", linepos = nameoutput, "");
+ else
+ (void) fprintf (stderr, " "), linepos++;
+ (void) fprintf (stderr, f ? "(%s)" : "%s", s);
+ linepos += len;
+}
+
+/* PASS1 */
+
+pass1 ()
+{
+}
+
+/* */
+
+pass1_type (encpref, decpref, prfpref, mod, id, yp)
+register char *encpref,
+ *decpref,
+ *prfpref,
+ *mod,
+ *id;
+register YP yp;
+{
+ register SY sy;
+
+ if (lookup_type (mod, id)) /* no duplicate entries, please... */
+ return;
+
+ if (pepydebug) {
+ if (linepos)
+ (void) fprintf (stderr, "\n"), linepos = 0;
+
+ (void) fprintf (stderr, "%s.%s\n", mod ? mod : mymodule, id);
+ print_type (yp, 0);
+ (void) fprintf (stderr, "--------\n");
+ }
+ else
+ if (!(yp -> yp_flags & YP_IMPORTED))
+ yyprint (id, 0, 0);
+
+ sy = new_symbol (encpref, decpref, prfpref, mod, id, yp);
+ mysymbols = add_symbol (mysymbols, sy);
+}
+
+static void hprologue (fp)
+FILE *fp;
+{
+#define NFILES 5
+ char *files[NFILES];
+ /* { "psap.h", "pepsy.h", "UNIV-types.h", (char *)0 }; */
+
+ int last = 0; /* last slot available in files */
+ (void) fprintf (fp, "/* automatically generated by %s, do not edit! */\n\n",
+ autogen);
+ (void) fprintf (fp, "#ifndef\t_module_%s_defined_\n", modulename);
+ (void) fprintf (fp, "#define\t_module_%s_defined_\n\n", modulename);
+
+ (void) fprintf (fp, "#ifndef\tPEPSY_VERSION\n");
+ (void) fprintf (fp, "#define\tPEPSY_VERSION\t\t%d\n", PEPSY_VERSION_NUMBER);
+ (void) fprintf (fp, "#endif\n\n");
+
+ files[last++] = "psap.h";
+ files[last++] = "pepsy.h";
+
+ if (strcmp (mymodule, "UNIV")) {
+ files[last++] = "pepsy/UNIV-types.h";
+ }
+
+ files[last++] = (char *)0;
+
+ doincl(fp, files);
+
+#undef NFILES
+}
+
+/* PASS2 */
+
+pass2 () {
+ register SY sy;
+ register YP yp;
+
+
+ modsym_aux (mymodule, modulename);
+
+ (void) sprintf (sysdef, "%s%s", mymodule, Cflag ? "-t.tmp" : "-types.h");
+ if ((fdef = fopen (sysdef, "w")) == NULL)
+ myyerror ("unable to write %s", sysdef);
+ if (!Cflag)
+ hprologue (fdef);
+
+
+ if (!Cflag) {
+ if (mflag) {
+ (void) fprintf (fdef, "#ifndef\tPEPYPATH\n");
+ (void) fprintf (fdef, "#include <isode/pepsy/%s%s>\n", mymodule, HFILE1);
+ (void) fprintf (fdef, "#else\n");
+ (void) fprintf (fdef, "#include \"%s%s\"\n", mymodule, HFILE1);
+ (void) fprintf (fdef, "#endif\n");
+ }
+ else
+ (void) fprintf (fdef, "#include \"%s%s\"\n", mymodule, HFILE1);
+ }
+ /* User's #include file */
+ if (iflag) {
+ (void) fprintf (fdef, "#include \"%s\"\n", iflag);
+ }
+
+ /*
+ * pull up some symbols
+ */
+ for (sy = mysymbols; sy; sy = sy -> sy_next) {
+ eval = sy -> sy_name;
+ yp = sy -> sy_type;
+ if (sy -> sy_module == NULLCP)
+ yyerror ("no module name associated with symbol");
+ if (yp -> yp_flags & YP_IMPORTED)
+ continue;
+
+ do_struct0 (yp, eval);
+ if (ferror (stdout) || ferror (fdef))
+ myyerror ("write error - %s", sys_errname (errno));
+ }
+ /* dump out the references to the external types */
+ proc_extmod(fdef);
+
+ /*
+ * generate the #define's for simple type definitions
+ */
+ for (sy = mysymbols; sy; sy = sy -> sy_next) {
+ eval = sy -> sy_name;
+ yp = sy -> sy_type;
+ if (yp -> yp_flags & YP_IMPORTED)
+ continue;
+
+ do_struct1 (yp, eval, NULLCP);
+ if (ferror (stdout) || ferror (fdef))
+ myyerror ("write error - %s", sys_errname (errno));
+ }
+
+ /*
+ * generate the C structure definitions
+ */
+ for (sy = mysymbols; sy; sy = sy -> sy_next) {
+ eval = sy -> sy_name;
+ yp = sy -> sy_type;
+ if (yp -> yp_flags & YP_IMPORTED)
+ continue;
+
+ do_struct2 (yp, eval, NULLCP);
+ if (ferror (stdout) || ferror (fdef))
+ myyerror ("write error - %s", sys_errname (errno));
+ }
+
+ peri_pass2();
+
+ (void) fprintf (fdef, "#endif\n");
+ (void) fflush (fdef);
+ (void) fflush (stdout);
+ if (ferror (stdout) || ferror (fdef))
+ myyerror ("write error - %s", sys_errname (errno));
+ (void) fclose (fdef);
+
+ if (Cflag)
+ merge_files (mymodule);
+
+ write_ph_file();
+ if (!sflag) {
+ if (linepos) fprintf (stderr, "\n"), linepos = 0;
+ (void) fflush (stderr);
+ }
+}
+
+static void copy_file (fp1, fp2)
+FILE *fp1, *fp2;
+{
+ char buf[BUFSIZ];
+ int n;
+
+ while ((n = fread (buf, 1, BUFSIZ, fp1)) > 0) {
+ if (fwrite (buf, 1, n, fp2) != n) {
+ fprintf (stderr, "Write error\n");
+ exit (1);
+ }
+ }
+}
+
+static void merge_files (stem)
+char *stem;
+{
+ FILE *fpin, *fpout;
+ char fname[BUFSIZ];
+ char buf[BUFSIZ];
+
+ (void) sprintf (fname, "%s-types.h", stem);
+ if ((fpout = fopen (fname, "w")) == NULL)
+ myyerror ("unable to write %s", fname);
+
+ hprologue (fpout);
+ (void) sprintf (buf, "%s%s", stem, HFILE2);
+ if ((fpin = fopen (buf, "r")) == NULL)
+ myyerror ("unable to read file %s", buf);
+ copy_file (fpin, fpout);
+ (void) fclose (fpin);
+ (void) unlink (buf);
+
+ (void) sprintf (buf, "%s%s", stem, HFILE1);
+ if ((fpin = fopen (buf, "r")) == NULL)
+ myyerror ("unable to read file %s", buf);
+ copy_file (fpin, fpout);
+ (void) fclose (fpin);
+ (void) unlink (buf);
+
+ (void) sprintf (buf, "%s-t.tmp", stem);
+ if ((fpin = fopen (buf, "r")) == NULL)
+ myyerror ("unable to read file %s", buf);
+ copy_file (fpin, fpout);
+ (void) fclose (fpin);
+ (void) unlink (buf);
+
+ if (fclose (fpout) == EOF) {
+ fprintf (stderr, "Write error to file");
+ perror ("");
+ exit (1);
+ }
+}
+
+/* */
+
+/* ARGSUSED */
+
+static do_struct0 (yp, id)
+register YP yp;
+char *id;
+{
+ register YP y;
+ MD md;
+
+ switch (yp -> yp_code) {
+ case YP_SEQLIST:
+ case YP_SETLIST:
+ components_pullup (yp);
+ break;
+
+ default:
+ break;
+ }
+
+ switch (yp -> yp_code) {
+ case YP_SEQTYPE:
+ case YP_SETTYPE:
+ do_struct0 (yp -> yp_type, id);
+ break;
+
+ case YP_CHOICE:
+ case YP_SETLIST:
+ choice_pullup (yp, yp -> yp_code == YP_CHOICE ? CH_FULLY
+ : CH_PARTIAL);
+ /* and fall */
+ case YP_SEQLIST:
+ for (y = yp -> yp_type; y; y = y -> yp_next)
+ do_struct0 (y, id);
+ break;
+
+ case YP_IDEFINED:
+ if (yp -> yp_module && strcmp (yp -> yp_module, mymodule)) {
+ if ((md = lookup_module (yp -> yp_module, yp -> yp_modid))
+ == NULLMD || (md->md_flags & MDF_SEEN) == 0) {
+ addextmod(yp -> yp_module);
+ if (md)
+ md->md_flags |= MDF_SEEN;
+ }
+ }
+ /* correct for IMPLICIT Tag of a CHOICE or ANY if possible */
+ if ((yp->yp_flags & (YP_IMPLICIT|YP_TAG)) == (YP_IMPLICIT|YP_TAG)) {
+ yp->yp_flags &= ~YP_IMPLICIT; /* clear it */
+ yp->yp_flags |= comptag(YP_IMPLICIT, yp);
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+/* */
+
+static do_struct1 (yp, id, pullup)
+register YP yp;
+char *id,
+ *pullup;
+{
+ register int i,
+ j;
+ char buf1[BUFSIZ];
+ register YP y;
+ register YV yv;
+
+ switch (yp -> yp_code) {
+ case YP_BIT:
+ case YP_BITLIST:
+ case YP_SEQ:
+ case YP_SET:
+ case YP_ANY:
+ (void) fprintf (fdef, "\n");
+ if (aflag)
+ printag (yp, 4, pullup);
+ (void) fprintf (fdef, "#define\t%s\tPElement\n",
+ modsym (mymodule, id, "type"));
+ if (yp -> yp_code == YP_BITLIST) {
+ i = -1;
+ for (yv = yp -> yp_value; yv; yv = yv -> yv_next)
+ if ((j = val2int (yv)) < 0)
+ pyyerror (yp, "invalid bit number in BIT STRING");
+ else
+ if (j > i)
+ i = j;
+ if (i < sizeof (int) * 8) { /* NBBY */
+ (void) fprintf (fdef, "#define\t%s\t\"\\020",
+ modsym (mymodule, eval, "bits"));
+ for (yv = yp -> yp_value; yv; yv = yv -> yv_next)
+ if (yv -> yv_flags & YV_NAMED)
+ (void) fprintf (fdef, "\\0%o%s",
+ val2int (yv) + 1, yv -> yv_named);
+ else
+ (void) fprintf (fdef, "\\0%oBIT%d",
+ val2int (yv) + 1, val2int (yv));
+ (void) fprintf (fdef, "\"\n");
+ }
+ for (yv = yp -> yp_value; yv; yv = yv -> yv_next) {
+ modsym_aux (yv -> yv_named, buf1);
+ (void) fprintf (fdef, "#define\t%s_%s\t%d\n",
+ modsym (mymodule, eval, "bit"),
+ buf1, val2int (yv));
+ }
+ }
+ if (fflag)
+ (void) fprintf (fdef, "#define\t%s\tpe_free\n",
+ modsym (mymodule, id, "free"));
+ break;
+
+ case YP_OCT:
+ (void) fprintf (fdef, "\n");
+ if (aflag)
+ printag (yp, 4, pullup);
+ (void) fprintf (fdef, "#define\t%s\tqbuf\n",
+ modsym (mymodule, id, "type"));
+ if (fflag)
+ (void) fprintf (fdef, "#define\t%s\tqb_free\n",
+ modsym (mymodule, id, "free"));
+ break;
+
+ case YP_OID:
+ (void) fprintf (fdef, "\n");
+ if (aflag)
+ printag (yp, 4, pullup);
+ (void) fprintf (fdef, "#define\t%s\tOIDentifier\n",
+ modsym (mymodule, id, "type"));
+ if (fflag)
+ (void) fprintf (fdef, "#define\t%s\toid_free\n",
+ modsym (mymodule, id, "free"));
+ break;
+
+ case YP_IDEFINED:
+ (void) fprintf (fdef, "\n");
+ if (aflag)
+ printag (yp, 4, pullup);
+ (void) fprintf (fdef, "#define\t%s\t",
+ modsym (mymodule, id, "type"));
+ (void) fprintf (fdef, "%s\n",
+ modsym (yp -> yp_module, yp -> yp_identifier, "type"));
+ if (fflag) {
+ (void) fprintf (fdef, "#define\t%s\t",
+ modsym (mymodule, id, "free"));
+ (void) fprintf (fdef, "%s\n",
+ modsym (yp -> yp_module, yp -> yp_identifier, "free"));
+ }
+ break;
+
+ case YP_SEQLIST:
+ case YP_SETLIST:
+ case YP_CHOICE:
+ if (hflag && (y = yp -> yp_type) && !y -> yp_next) {
+ do_struct1 (y, id, tags[yp -> yp_code]);
+ break;
+ }
+ /* else fall */
+
+ default:
+ break;
+ }
+}
+
+/* */
+
+static do_struct2 (yp, id, pullup)
+register YP yp;
+char *id,
+ *pullup;
+{
+ register YP y;
+ int flg = (yp -> yp_code == YP_SEQTYPE || yp -> yp_code == YP_SETTYPE);
+
+ switch (yp -> yp_code) {
+ case YP_BIT:
+ case YP_BITLIST:
+ case YP_SEQ:
+ case YP_SET:
+ case YP_ANY:
+ case YP_OCT:
+ case YP_OID:
+ case YP_IDEFINED:
+ break;
+
+ case YP_SEQLIST:
+ case YP_SETLIST:
+ case YP_CHOICE:
+ if (hflag && (y = yp -> yp_type) && !y -> yp_next) {
+ do_struct2 (y, id, tags[yp -> yp_code]);
+ break;
+ }
+ /* else fall */
+
+ default:
+ (void) fprintf (fdef, "\n");
+ if (aflag)
+ printag (yp, 4, pullup);
+ (void) fprintf (fdef, "struct %s {\n", modsym (mymodule, id, "type"));
+ pepsy (yp, 1, 1, "parm", id, "parm", flg && h2flag);
+ (void) fprintf (fdef, "};\n");
+ (void) fprintf (fdef, "#define\t%s(parm)\\\n\t%s\n", modsym (mymodule, id, "free"), gfree(mymodule, id, "parm"));
+
+ break;
+ }
+}
+
+/* */
+
+/* ARGSUSED */
+
+static do_type1 (yp, top, level, id, var, action2, direction)
+register YP yp;
+int top,
+ level;
+char *id,
+ *var,
+ *action2;
+int direction;
+{
+ int i;
+ char *cp,
+ *ep,
+ buffer[BUFSIZ],
+ varbuf[BUFSIZ];
+ register YP y;
+ register YV yv;
+ register YT yt;
+
+ (void) printf ("%*s", level * 4, "");
+
+ if (yp -> yp_flags & YP_ID) {
+ (void) printf ("%s", yp -> yp_id);
+ if (!(yp -> yp_flags & YP_TAG))
+ (void) printf ("\n%*s", ++level * 4, "");
+ }
+
+ if (yp -> yp_flags & YP_TAG) {
+ yt = yp -> yp_tag;
+ (void) printf ("[%s%d]\n", classes[yt -> yt_class], val2int (yt -> yt_value));
+ level++;
+ (void) printf ("%*s", level * 4, "");
+ }
+ if (yp -> yp_flags & YP_OPTIONAL && yp -> yp_varexp) {
+ if ((ep = index (yp -> yp_varexp, ' ')) == NULL)
+ yyerror ("Bug in varexp!");
+
+ (void) sprintf (varbuf, "%*.*s", ep - yp -> yp_varexp,
+ ep - yp -> yp_varexp, yp -> yp_varexp);
+ }
+
+ switch (yp -> yp_code) {
+ case YP_BOOL:
+ if ((yp -> yp_flags & (YP_OPTIONAL|YP_DEFAULT)) &&
+ direction == YP_DECODER) {
+ if (!top && !(yp -> yp_flags & (YP_ID | YP_TAG)))
+ (void) printf ("dummy-for-default\n%*s", ++level * 4, "");
+ if (yp -> yp_flags & YP_OPTIONAL)
+ (void) printf ("%%{ %s -> optionals |= %s; %%}\n%*s",
+ varbuf, yp -> yp_optcontrol, level * 4, "");
+ else
+ (void) printf ("%%{ %s%s = %d; %%}\n%*s",
+ var, SVAL (yp -> yp_varexp),
+ val2int (yp -> yp_default) ? 1 : 0, level * 4, "");
+ }
+ break;
+
+ case YP_INT:
+ if ((yp -> yp_flags & (YP_OPTIONAL|YP_DEFAULT)) &&
+ direction == YP_DECODER) {
+ if (!top && !(yp -> yp_flags & (YP_ID | YP_TAG)))
+ (void) printf ("dummy-for-default\n%*s", ++level * 4, "");
+ if (yp -> yp_flags & YP_OPTIONAL)
+ (void) printf ("%%{ %s -> optionals |= %s; %%}\n%*s",
+ varbuf, yp -> yp_optcontrol, level * 4, "");
+ else
+ (void) printf ("%%{ %s%s = %d; %%}\n%*s",
+ var, SVAL (yp -> yp_varexp),
+ val2int (yp -> yp_default), level * 4, "");
+ }
+ break;
+
+ case YP_INTLIST:
+ case YP_ENUMLIST:
+ if ((yp -> yp_flags & (YP_OPTIONAL|YP_DEFAULT)) &&
+ direction == YP_DECODER) {
+ if (!top && !(yp -> yp_flags & (YP_ID | YP_TAG)))
+ (void) printf ("dummy-for-default\n%*s", ++level * 4, "");
+ if (yp -> yp_flags & YP_OPTIONAL)
+ (void) printf ("%%{ %s -> optionals |= %s; %%}\n%*s",
+ varbuf, yp -> yp_optcontrol, level * 4, "");
+ else
+ (void) printf ("%%{ %s%s = %d; %%}\n%*s",
+ var, SVAL (yp -> yp_varexp), dfl2int (yp),
+ level * 4, "");
+ }
+ break;
+
+ case YP_REAL:
+ if ((yp -> yp_flags & (YP_OPTIONAL|YP_DEFAULT)) &&
+ direction == YP_DECODER) {
+ if (!top && !(yp -> yp_flags & (YP_ID | YP_TAG)))
+ (void) printf ("dummy-for-default\n%*s", ++level * 4, "");
+ if (yp -> yp_flags & YP_OPTIONAL)
+ (void) printf ("%%{ %s -> optionals |= %s; %%}\n%*s",
+ varbuf, yp -> yp_optcontrol, level * 4, "");
+ else
+ (void) printf ("%%{ %s%s = %g; %%}\n%*s",
+ var, SVAL (yp -> yp_varexp),
+ val2real (yp -> yp_default), level * 4, "");
+ }
+ break;
+
+ case YP_NULL:
+ if ((yp -> yp_flags & YP_OPTIONAL) && direction == YP_DECODER) {
+ if (!top && !(yp -> yp_flags & (YP_ID | YP_TAG)))
+ (void) printf ("dummy-for-default\n%*s", ++level * 4, "");
+ (void) printf ("%%{ %s -> optionals |= %s; %%}\n%*s",
+ varbuf, yp -> yp_optcontrol, level * 4, "");
+ }
+ break;
+ }
+
+ if ((yp -> yp_flags & (YP_TAG | YP_IMPLICIT)) == (YP_TAG | YP_IMPLICIT))
+ (void) printf ("IMPLICIT ");
+ if (yp -> yp_flags & YP_BOUND)
+ (void) printf ("%s < ", yp -> yp_bound);
+ if (yp -> yp_flags & YP_COMPONENTS)
+ (void) printf ("COMPONENTS OF ");
+ if (yp -> yp_flags & YP_ENCRYPTED)
+ (void) printf ("ENCRYPTED ");
+
+ switch (yp -> yp_code) {
+ case YP_BOOL:
+ (void) printf ("BOOLEAN");
+ switch (direction) {
+ case YP_ENCODER:
+ case YP_DECODER:
+ (void) printf (top ? "\n%*s[[b %s -> %s ]]" : "\n%*s[[b %s%s ]]",
+ level * 4, "", var, SVAL (yp -> yp_varexp));
+ break;
+ }
+ break;
+
+ case YP_INT:
+ (void) printf ("INTEGER");
+ switch (direction) {
+ case YP_ENCODER:
+ case YP_DECODER:
+ (void) printf (top ? "\n%*s[[i %s -> %s ]]" : "\n%*s[[i %s%s ]]",
+ level * 4, "", var, SVAL (yp -> yp_varexp));
+ break;
+ }
+ break;
+
+ case YP_INTLIST:
+ case YP_ENUMLIST:
+ if (yp -> yp_code == YP_ENUMLIST)
+ (void) printf ("ENUMERATED");
+ else
+ (void) printf ("INTEGER");
+ switch (direction) {
+ case YP_ENCODER:
+ case YP_DECODER:
+ (void) printf (top ? "\n%*s[[i %s -> %s ]]\n%*s{\n"
+ : "\n%*s[[i %s%s ]]\n%*s{\n",
+ level * 4, "", var, SVAL (yp -> yp_varexp),
+ level * 4, "");
+ break;
+
+ default:
+ (void) printf (" {\n");
+ break;
+ }
+ level++;
+ for (yv = yp -> yp_value; yv; yv = yv -> yv_next)
+ (void) printf ("%*s%s(%d)%s\n", level * 4, "", yv -> yv_named,
+ val2int (yv), yv -> yv_next ? "," : "");
+ level--;
+ (void) printf ("%*s}", level * 4, "");
+ break;
+
+ case YP_BIT:
+ (void) printf ("BIT STRING");
+ switch (direction) {
+ case YP_ENCODER:
+ (void) printf ("\n%*s[[x bit_parm = bitstr2strb (%s%s, &len) $ len]]",
+ level * 4, "", var, SVAL (yp -> yp_varexp));
+ (void) printf ("\n%*s%%{\n%*sfree (bit_parm);\n", level * 4, "",
+ (level + 1) * 4, "");
+ if (action2)
+ (void) printf ("%*s%s\n", (level + 1) * 4, "", action2);
+ (void) printf ("%*s%%}\n", level * 4, "");
+ break;
+
+ case YP_DECODER:
+ balloc (yp, var, action2, level);
+ break;
+ }
+ break;
+
+ case YP_BITLIST:
+ (void) printf ("BIT STRING");
+ switch (direction) {
+ case YP_ENCODER:
+ (void) printf ("\n%*s[[x bit_parm = bitstr2strb (%s%s, &len) $ len]]\n%*s{\n",
+ level * 4, "", var, SVAL (yp -> yp_varexp),
+ level * 4, "");
+ break;
+
+ case YP_DECODER:
+ default:
+ (void) printf (" {\n");
+ break;
+ }
+ level++;
+ for (yv = yp -> yp_value; yv; yv = yv -> yv_next)
+ (void) printf ("%*s%s(%d)%s\n", level * 4, "", yv -> yv_named,
+ val2int (yv), yv -> yv_next ? "," : "");
+ level--;
+ (void) printf ("%*s}", level * 4, "");
+ switch (direction) {
+ case YP_DECODER:
+ balloc (yp, var, action2, level);
+ break;
+
+ case YP_ENCODER:
+ (void) printf ("\n%*s%%{\n%*sfree (bit_parm);\n", level * 4, "",
+ (level + 1) * 4, "");
+ if (action2)
+ (void) printf ("%*s%s\n", (level + 1) * 4, "", action2);
+ (void) printf ("%*s%%}\n", level * 4, "");
+ break;
+ }
+ break;
+
+ case YP_OCT:
+ (void) printf ("OCTET STRING");
+ switch (direction) {
+ case YP_ENCODER:
+ (void) printf ("\n%*s[[q %s%s ]]", level * 4, "",
+ var, SVAL (yp -> yp_varexp));
+ break;
+
+ case YP_DECODER:
+ (void) printf ("\n%*s[[q %s%s ]]", level * 4, "",
+ var, SVAL (yp -> yp_varexp));
+ break;
+ }
+ break;
+
+ case YP_REAL:
+ (void) printf ("REAL");
+ (void) printf (top ? "\n%*s[[r %s -> %s ]]" : "\n%*s[[r %s%s ]]",
+ level * 4, "", var, SVAL (yp -> yp_varexp));
+ break;
+
+ case YP_NULL:
+ (void) printf ("NULL");
+ break;
+
+ case YP_SEQ:
+ case YP_SET:
+ case YP_ANY:
+ (void) printf ("%s", tags[yp -> yp_code]);
+ switch (direction) {
+ case YP_ENCODER:
+ case YP_DECODER:
+ (void) printf ("\n%*s[[a %s%s ]]",
+ level * 4, "", var, SVAL (yp -> yp_varexp));
+ break;
+ }
+ break;
+
+ case YP_SEQTYPE:
+ case YP_SETTYPE:
+ ep = yp -> yp_code != YP_SETTYPE ? "element" : "member";
+ (void) printf ("%s\n", tags [yp -> yp_code]);
+ switch (direction) {
+ case YP_ENCODER:
+ if ((y = yp -> yp_type) -> yp_declexp) {
+ (void) printf ("%*s%%{ %s = %s; %%}\n",
+ (level + 1) * 4, "", y -> yp_declexp,
+ SVAL (y -> yp_varexp));
+ }
+ if (h2flag) {
+ if (top) {
+ (void) printf ("%*s<<n_parm = 0; ", (level + 1) * 4, "");
+ (void) printf ("n_parm < parm -> nelem; n_parm++>>\n");
+ }
+ else {
+ (void) printf ("%*s<<n_%s = 0;\n%*sn_%s < %s -> nelem;\n",
+ (level + 1) * 4, "", yp -> yp_declexp,
+ (level + 3) * 4, "", yp -> yp_declexp,
+ yp -> yp_declexp);
+ (void) printf ("%*sn_%s++>>\n",
+ (level + 3) * 4, "", yp -> yp_declexp);
+ }
+ }
+ else {
+ if (top)
+ (void) printf ("%*s<<; parm; parm = parm -> next>>\n",
+ (level + 1) * 4, "");
+ else
+ (void) printf ("%*s<<%s = %s%s;\n%*s%s;\n%*s%s = %s -> next>>\n",
+ (level + 1) * 4, "", yp -> yp_declexp,
+ var, SVAL (yp -> yp_varexp),
+ (level + 3) * 4, "", yp -> yp_declexp,
+ (level + 3) * 4, "", yp -> yp_declexp,
+ yp -> yp_declexp);
+ }
+ break;
+
+ case YP_DECODER:
+ if (h2flag) {
+ y = yp -> yp_type;
+ xalloc (y, 0, level + 2, y -> yp_declexp,
+ y -> yp_declexp, 1);
+ }
+ else
+ xalloc (yp, 0, level + 1,
+ top ? "parm" : yp -> yp_declexp,
+ top ? modsym (mymodule, eval, "type")
+ : yp -> yp_declexp, 1);
+ break;
+ }
+ do_type1 (yp -> yp_type, 0, level + 1, ep, "", NULLCP, direction);
+ switch (direction) {
+ case YP_DECODER:
+ (void) printf ("\n%*s%%{ ", (level + 1) * 4, "");
+ if (h2flag)
+ (void) printf ("n_%s++;", top ? "parm" : yp -> yp_declexp);
+ else
+ if (top)
+ (void) printf ("parm = &((*parm) -> next);");
+ else
+ (void) printf ("%s = &((*%s) -> next);",
+ yp -> yp_declexp, yp -> yp_declexp);
+ if (action2)
+ (void) printf (" %s", action2);
+ (void) printf (" %%}");
+ break;
+ }
+ break;
+
+ case YP_SEQLIST:
+ case YP_SETLIST:
+ ep = yp -> yp_code != YP_SETLIST ? "element" : "member";
+ (void) printf ("%s", tags [yp -> yp_code]);
+ (void) printf ("\n%*s%%{\n", (level + 1) * 4, "");
+ if (direction == YP_DECODER)
+ xalloc (yp, 1, level + 2, yp -> yp_declexp,
+ yp -> yp_declexp, 0);
+ for (y = yp -> yp_type; y; y = y -> yp_next) {
+ if (y -> yp_declexp)
+ switch (direction) {
+ case YP_ENCODER:
+ (void) printf ("%*s%s = %s;\n",
+ (level + 2) * 4, "",
+ y -> yp_declexp, y -> yp_varexp);
+ break;
+
+ case YP_DECODER:
+ (void) printf ("%*s%s = &(%s);\n",
+ (level + 2) * 4, "",
+ y -> yp_declexp, y -> yp_varexp);
+ break;
+ }
+ if (direction == YP_DECODER &&
+ y -> yp_flags & YP_DEFAULT) {
+ prime_default (y, level + 2);
+ }
+ }
+ (void) printf ("%*s%%}\n%*s{\n", (level + 1) * 4, "",
+ level * 4, "");
+
+ if (!hflag || !(y = yp -> yp_type) || y -> yp_next) {
+ var = "";
+ top = 0;
+ }
+ for (y = yp -> yp_type; y; y = y -> yp_next) {
+ do_type1 (y, top,
+ level + ((y -> yp_flags & (YP_ID | YP_TAG)) ? 1 : 2),
+ ep, var, NULLCP, direction);
+ (void) printf ("%s\n", y -> yp_next ? ",\n" : "");
+ }
+ (void) printf ("%*s}", level * 4, "");
+ break;
+
+ case YP_CHOICE:
+ (void) printf ("CHOICE");
+ if (!hflag || !(y = yp -> yp_type) || y -> yp_next)
+ var = "";
+ i = 0;
+ for (y = yp -> yp_type; y; y = y -> yp_next)
+ if (y -> yp_declexp)
+ i++;
+ switch (direction) {
+ case YP_ENCODER:
+ if (i) {
+ (void) printf ("\n%*s%%{\n", (level + 1) * 4, "");
+ for (y = yp -> yp_type; y; y = y -> yp_next)
+ if (y -> yp_declexp)
+ (void) printf ("%*s%s = %s;\n", (level + 2) * 4, "",
+ y -> yp_declexp, y -> yp_varexp);
+ (void) printf ("%*s%%}\n%*s", (level + 1) * 4, "",
+ (level + 1) * 4 - 1, "" );
+ }
+ if (*var)
+ (void) printf (" <<1>>");
+ else
+ if (top)
+ (void) printf (" <<parm -> offset>>");
+ else
+ (void) printf (" <<%s -> offset>>",
+ yp -> yp_declexp);
+ (void) printf (i ? "\n%*s{\n" : " {\n", level * 4, "");
+ break;
+
+ case YP_DECODER:
+ (void) printf ("\n");
+ xalloc (yp, 0, level + 1, yp -> yp_declexp,
+ yp -> yp_declexp, 1);
+ (void) printf ("%*s{\n", level * 4, "");
+ break;
+
+ default:
+ (void) printf (" {\n");
+ break;
+ }
+ if (direction == YP_DECODER) {
+ (void) sprintf (cp = buffer, "(*(%s)) -> offset = ",
+ top ? "parm" : yp -> yp_declexp);
+ cp += strlen (cp);
+ }
+ else
+ cp = NULL;
+ if (!hflag || !(y = yp -> yp_type) || y -> yp_next)
+ top = 0;
+ else
+ if (top)
+ cp = NULL;
+ for (y = yp -> yp_type; y; y = y -> yp_next) {
+ if (cp)
+ (void) sprintf (cp, "%s;", y -> yp_offset);
+ do_type1 (y, top, level + 1, "choice", var,
+ cp ? buffer : NULLCP, direction);
+ (void) printf ("%s\n", y -> yp_next ? ",\n" : "");
+ }
+ (void) printf ("%*s}", level * 4, "");
+ break;
+
+ case YP_OID:
+ (void) printf ("OBJECT IDENTIFIER");
+ switch (direction) {
+ case YP_ENCODER:
+ case YP_DECODER:
+ (void) printf ("\n%*s[[O %s%s ]]",
+ level * 4, "", var, SVAL (yp -> yp_varexp));
+ break;
+ }
+ break;
+
+ case YP_IDEFINED:
+ if (yp -> yp_module && strcmp (yp -> yp_module, mymodule))
+ (void) printf ("%s.", yp -> yp_module);
+ (void) printf ("%s", yp -> yp_identifier);
+ switch (direction) {
+ case YP_ENCODER:
+ (void) printf ("\n%*s[[p %s%s ]]",
+ level * 4, "", var, SVAL (yp -> yp_varexp));
+ break;
+
+ case YP_DECODER:
+ (void) printf ("\n%*s[[p &(%s%s)]]",
+ level * 4, "", var, SVAL (yp -> yp_varexp));
+ break;
+ }
+ break;
+
+ default:
+ myyerror ("unknown type: %d", yp -> yp_code);
+ }
+
+ if (action2)
+ switch (yp -> yp_code) {
+ case YP_BIT:
+ case YP_BITLIST:
+ if (direction == YP_ENCODER)
+ break;
+ case YP_SEQTYPE:
+ case YP_SETTYPE:
+ if (direction == YP_DECODER)
+ break;
+ /* else fall */
+
+ default:
+ (void) printf ("\n%*s%%{ %s %%}", level * 4, "", action2);
+ break;
+ }
+
+ if (yp -> yp_flags & YP_OPTIONAL) {
+ (void) printf ("\n%*sOPTIONAL", level * 4, "");
+
+ if (direction == YP_ENCODER)
+ switch (yp -> yp_code) {
+ case YP_BOOL:
+ case YP_INT:
+ case YP_INTLIST:
+ case YP_ENUMLIST:
+ case YP_NULL:
+ case YP_REAL:
+ (void) printf (" <<%s -> optionals & %s >>",
+ varbuf, yp -> yp_optcontrol);
+ default:
+ break;
+
+ case YP_BIT:
+ case YP_BITLIST:
+ case YP_OCT:
+ case YP_SEQ:
+ case YP_SEQTYPE:
+ case YP_SEQLIST:
+ case YP_SET:
+ case YP_SETTYPE:
+ case YP_SETLIST:
+ case YP_CHOICE:
+ case YP_ANY:
+ case YP_OID:
+ case YP_IDEFINED:
+ (void) printf (" <<%s%s>>", var, SVAL (yp -> yp_varexp));
+ break;
+ }
+ }
+ else
+ if (yp -> yp_flags & YP_DEFAULT) {
+ (void) printf ("\n%*sDEFAULT ", level * 4, "");
+ val2prf (yp -> yp_default, level + 2);
+
+ if (direction == YP_ENCODER)
+ switch (yp -> yp_code) {
+ case YP_BOOL:
+ (void) printf (" <<%s%s%s>>",
+ val2int (yp -> yp_default) ? "!" : "",
+ var, SVAL (yp -> yp_varexp));
+ break;
+
+ case YP_INT:
+ case YP_INTLIST:
+ case YP_ENUMLIST:
+ (void) printf (" <<%s%s != %d>>", var, SVAL (yp -> yp_varexp),
+ dfl2int (yp));
+ break;
+
+ case YP_REAL:
+ (void) printf (" << %s%s != %g >>",
+ var, SVAL (yp -> yp_varexp),
+ val2real (yp -> yp_default));
+ break;
+
+ case YP_NULL:
+ default:
+ break;
+
+ case YP_BIT:
+ case YP_BITLIST:
+ case YP_OCT:
+ case YP_SEQ:
+ case YP_SEQTYPE:
+ case YP_SEQLIST:
+ case YP_SET:
+ case YP_SETTYPE:
+ case YP_SETLIST:
+ case YP_CHOICE:
+ case YP_ANY:
+ case YP_OID:
+ case YP_IDEFINED:
+ (void) printf (" <<%s%s>>", var, SVAL (yp -> yp_varexp));
+ break;
+ }
+ }
+
+ if (direction == YP_ENCODER
+ && yp -> yp_varexp
+ && (cp = index (yp -> yp_varexp, ' '))
+ && strncmp (cp + 1, "-> ", 3) == 0) {
+ *cp = NULL;
+ (void) sprintf (buffer, "(*%s) -> %s", yp -> yp_varexp, cp + 4);
+ yp -> yp_varexp = new_string (buffer);
+ }
+}
+
+/* TYPE HANDLING */
+
+YP lookup_type (mod, id)
+register char *mod,
+ *id;
+{
+ register SY sy;
+
+ for (sy = mysymbols; sy; sy = sy -> sy_next) {
+ if (mod) {
+ if (strcmp (sy -> sy_module, mod))
+ continue;
+ }
+ else
+ if (strcmp (sy -> sy_module, mymodule)
+ && strcmp (sy -> sy_module, "UNIV"))
+ continue;
+
+ if (strcmp (sy -> sy_name, id) == 0)
+ return sy -> sy_type;
+ }
+
+ return NULLYP;
+}
+
+/* */
+
+pepsy (yp, top, level, id, val, var, arrayflg)
+register YP yp;
+int top,
+ level,
+ arrayflg;
+char *id,
+ *val,
+ *var;
+{
+ register int i,
+ j;
+ register char *bp;
+ char *cp,
+ *dp,
+ *ep,
+ *newid,
+ buf1[BUFSIZ],
+ buf2[BUFSIZ],
+ buf3[BUFSIZ];
+ register YP y;
+ register YV yv;
+
+ (void) strcpy (bp = buf2, var);
+ bp += strlen (bp);
+ /* Preserve the name of the field */
+ yp->yp_varexp = new_string(yp -> yp_ptrname ? yp -> yp_ptrname : id);
+
+ switch (yp -> yp_code) {
+ case YP_BOOL:
+ if (aflag)
+ printag (yp, level + 4, NULLCP);
+ (void) fprintf (fdef, "%*schar %s;\n", level * 4, "",
+ array(id, arrayflg));
+ break;
+
+ case YP_INT:
+ case YP_INTLIST:
+ case YP_ENUMLIST:
+ if (aflag)
+ printag (yp, level + 4, NULLCP);
+ (void) fprintf (fdef, "%*sinteger %s;\n", level * 4, "",
+ array(id, arrayflg));
+ if (yp -> yp_code == YP_INT)
+ break;
+ for (yv = yp -> yp_value; yv; yv = yv -> yv_next) {
+ modsym_aux (yv -> yv_named, buf1);
+ (void) fprintf (fdef, "#define\t%s_%s\t%d\n",
+ modsym (mymodule, top ? eval : id, "int"),
+ buf1, val2int (yv));
+ }
+ break;
+
+ case YP_BIT:
+ case YP_BITLIST:
+ if (!top) {
+ if (aflag)
+ printag (yp, level + 4, NULLCP);
+ (void) fprintf (fdef, "%*sPE %s;\n", level * 4, "",
+ array(id, arrayflg));
+ }
+ if (yp -> yp_code != YP_BITLIST)
+ break;
+ i = -1;
+ for (yv = yp -> yp_value; yv; yv = yv -> yv_next)
+ if ((j = val2int (yv)) < 0)
+ pyyerror (yp, "invalid bit number in BIT STRING");
+ else
+ if (j > i)
+ i = j;
+ if (i < sizeof (int) * 8) { /* NBBY */
+ (void) fprintf (fdef, "#define\t%s\t\"\\020",
+ modsym (mymodule, top ? eval : id, "bits"));
+ for (yv = yp -> yp_value; yv; yv = yv -> yv_next)
+ if (yv -> yv_flags & YV_NAMED)
+ (void) fprintf (fdef, "\\0%o%s",
+ val2int (yv) + 1, yv -> yv_named);
+ else
+ (void) fprintf (fdef, "\\0%oBIT%d",
+ val2int (yv) + 1, val2int (yv));
+ (void) fprintf (fdef, "\"\n");
+ }
+ for (yv = yp -> yp_value; yv; yv = yv -> yv_next) {
+ modsym_aux (yv -> yv_named, buf1);
+ (void) fprintf (fdef, "#define\t%s_%s\t%d\n",
+ modsym (mymodule, top ? eval : id, "bit"),
+ buf1, val2int (yv));
+ }
+ break;
+
+ case YP_REAL:
+ if (aflag)
+ printag (yp, level + 4, NULLCP);
+ (void) fprintf (fdef, "%*sdouble %s;\n", level * 4, "",
+ array(id, arrayflg));
+ yp -> yp_varexp = new_string (buf2);
+ break;
+
+ case YP_OCT:
+ if (!top) {
+ if (aflag)
+ printag (yp, level + 4, NULLCP);
+ (void) fprintf (fdef, "%*sstruct qbuf *%s;\n", level * 4, "",
+ array(id, arrayflg));
+ }
+ break;
+
+ case YP_NULL:
+ if (aflag)
+ printag (yp, level + 4, NULLCP);
+ (void) fprintf (fdef, "%*schar %s;\n", level * 4, "",
+ array(id, arrayflg));
+ break;
+
+ case YP_SEQ:
+ case YP_SET:
+ case YP_ANY:
+ if (!top) {
+ if (aflag)
+ printag (yp, level + 4, NULLCP);
+ (void) fprintf (fdef, "%*sPE %s;\n", level * 4, "",
+ array(id, arrayflg));
+ }
+ break;
+
+ case YP_SEQTYPE:
+ case YP_SETTYPE:
+ ep = yp -> yp_code != YP_SETTYPE ? "element" : "member";
+ if ((cp = rindex (buf2, ' ')) && *++cp) {
+ if ((dp = rindex (cp, '.')) && *++dp)
+ cp = dp;
+ (void) sprintf (dp = buf1, "%*.*s",
+ cp - buf2, cp - buf2, buf2);
+ dp += strlen (dp);
+ }
+ else {
+ (void) strcpy (buf1, buf2);
+ dp = NULL;
+ }
+ newid = yp -> yp_ptrname ? yp -> yp_ptrname : id;
+ if (h2flag && top)
+ (void) fprintf (fdef, "%*sinteger\tnelem;\n", level * 4, "");
+ if (!top) {
+ if (yp -> yp_structname)
+ id = yp -> yp_structname;
+ else if (!Hflag)
+ id = gensym (ep, NULLCP);
+ if (aflag)
+ printag (yp, level + 4, NULLCP);
+ (void) fprintf (fdef, "%*sstruct %s {\n", level * 4, "", id);
+ if (h2flag)
+ (void) fprintf (fdef, "%*sinteger\tnelem;\n", (level + 1) * 4, "");
+ }
+ if (dp)
+ (void) strcpy (dp, newid);
+ (void) strcpy (bp = buf2, id);
+ bp += strlen (bp);
+
+ if (!top)
+ yp -> yp_declexp = new_string (id);
+
+ if (dp)
+ (void) strcpy (dp, newid);
+ if ((y = yp -> yp_type) -> yp_code == YP_IDEFINED && hflag) {
+ modsym_aux (y -> yp_identifier, cp = buf3);
+ if (h2flag) {
+ cp += strlen(cp);
+ (void) sprintf (cp, "[n_%s]", PARVAL (yp->yp_declexp));
+ cp = buf3;
+ }
+ }
+ else {
+ switch (y -> yp_code) {
+ case YP_SEQLIST:
+ case YP_SETLIST:
+ case YP_SETTYPE:
+ case YP_SEQTYPE:
+ case YP_CHOICE:
+ case YP_IDEFINED:
+ cp = gensym (ep, h2flag ? PARVAL(yp->yp_declexp) : NULLCP);
+ break;
+ default:
+ cp = gensym (ep, NULLCP);
+ break;
+ }
+ }
+ (void) sprintf (bp, " -> %s", cp);
+ level++;
+ pepsy (y, 0, level, cp, ep, buf2, h2flag);
+ *bp = NULL;
+ if (y -> yp_code != YP_IDEFINED)
+ free (cp);
+ if (!h2flag)
+ (void) fprintf (fdef, "\n%*sstruct %s *next;\n", level * 4, "",
+ top ? modsym (mymodule, val, "type") : id);
+
+ level--;
+
+ (void) strcpy (bp = buf2, var);
+ bp += strlen (bp);
+
+ if (!top) {
+ (void) fprintf (fdef, "%*s} *%s;\n", level * 4, "",
+ array(newid, arrayflg));
+ if (!Hflag)
+ free (id);
+ }
+ break;
+
+ case YP_SEQLIST:
+ case YP_SETLIST:
+ ep = yp -> yp_code != YP_SETLIST ? "element" : "member";
+ if ((cp = rindex (buf2, ' ')) && *++cp) {
+ if ((dp = rindex (cp, '.')) && *++dp)
+ cp = dp;
+ (void) sprintf (dp = buf1, "%*.*s",
+ cp - buf2, cp - buf2, buf2);
+ dp += strlen (dp);
+ }
+ else {
+ (void) strcpy (buf1, buf2);
+ dp = NULL;
+ }
+ newid = yp -> yp_ptrname ? yp -> yp_ptrname : id;
+ if (!top) {
+ if (yp -> yp_structname)
+ id = yp -> yp_structname;
+ else if (!Hflag)
+ id = gensym (ep, NULLCP);
+ if (aflag)
+ printag (yp, level + 4, NULLCP);
+ (void) fprintf (fdef, "%*sstruct %s {\n", level * 4, "", id);
+
+ if (dp)
+ (void) strcpy (dp, newid);
+
+ (void) strcpy (bp = buf2, id);
+ bp += strlen (bp);
+ yp -> yp_declexp = new_string (id);
+
+ level++;
+ }
+ if (dp)
+ (void) strcpy (dp, newid);
+ for (y = yp -> yp_type, i = 0; y; y = y -> yp_next) {
+ if (y -> yp_flags & YP_OPTIONAL)
+ switch (y -> yp_code) {
+ case YP_BOOL:
+ case YP_INT:
+ case YP_INTLIST:
+ case YP_ENUMLIST:
+ case YP_REAL:
+ case YP_NULL:
+ {
+ char obuf[BUFSIZ];
+
+ if (i == 0)
+ (void) fprintf (fdef, "%*sinteger optionals;\n",
+ level * 4, "");
+ if (y -> yp_flags & YP_ID)
+ modsym_aux (y -> yp_id, cp = buf1);
+ else {
+ cp = gensym (ep, NULLCP);
+ (void) strcpy (buf1, cp);
+ free (cp);
+ cp = buf1;
+ }
+ (void) sprintf (obuf, "%s_%s",
+ modsym (mymodule,
+ top ? eval : id,
+ "opt"), cp);
+ (void) fprintf (fdef, "#define\t%s (0%08o)\n", obuf,
+ 1 << i);
+#ifdef ASN1_OUTPUT
+ y -> yp_optcontrol = new_string (obuf);
+ y -> yp_flags |= YP_OPTCONTROL;
+#endif
+
+ i ++;
+ if (i >= 8 * sizeof (int))
+ yyerror ("too many optionals in structure");
+ }
+ break;
+ }
+ }
+ if (i > 0) (void) fprintf (fdef, "\n");
+
+ for (y = yp -> yp_type, i = 1; y; y = y -> yp_next, i++) {
+ if (y -> yp_flags & YP_ID)
+ modsym_aux (y -> yp_id, cp = buf1);
+ else
+ cp = gensym (ep, NULLCP);
+ (void) sprintf (bp, " -> %s", cp);
+ pepsy (y, 0, level, cp, ep, buf2, 0);
+ *bp = NULL;
+ if (!(y -> yp_flags & YP_ID))
+ free (cp);
+ if (y -> yp_next)
+ (void) fprintf (fdef, "\n");
+ }
+ if (i == 1)
+ (void) fprintf (fdef, "%*schar dummy;\n", level * 4, "");
+ if (!top) {
+ level--;
+
+ (void) strcpy (bp = buf2, var);
+ bp += strlen (bp);
+
+ (void) fprintf (fdef, "%*s} *%s;\n", level * 4, "",
+ array(newid, arrayflg));
+ if (!Hflag)
+ free (id);
+ }
+ break;
+
+ case YP_CHOICE:
+ if ((cp = rindex (buf2, ' ')) && *++cp) {
+ if ((dp = rindex (cp, '.')) && *++dp)
+ cp = dp;
+ (void) sprintf (dp = buf1, "%*.*s",
+ cp - buf2, cp - buf2, buf2);
+ dp += strlen (dp);
+ }
+ else {
+ (void) strcpy (buf1, buf2);
+ dp = NULL;
+ }
+ newid = yp -> yp_ptrname ? yp -> yp_ptrname : id;
+ if (!top) {
+ if (yp -> yp_structname)
+ id = yp -> yp_structname;
+ else if (!Hflag)
+ id = gensym ("choice", NULLCP);
+ if (aflag)
+ printag (yp, level + 4, NULLCP);
+ (void) fprintf (fdef, "%*sstruct %s {\n", level * 4, "", id);
+
+ if (dp)
+ (void) strcpy (dp, newid);
+ (void) strcpy (bp = buf2, id);
+ bp += strlen (bp);
+ yp -> yp_declexp = new_string (id);
+
+ level++;
+ }
+ if (dp)
+ (void) strcpy (dp, newid);
+ (void) fprintf (fdef, "%*sint offset;\n", level * 4, "");
+ if (top)
+ cp = modsym (mymodule, val, "type");
+ else
+ cp = id;
+ (void) sprintf (ep = buf1, "%s_", cp);
+ ep += strlen (ep);
+ for (y = yp -> yp_type, i = 1; y; y = y -> yp_next, i++) {
+ if (y -> yp_flags & YP_ID)
+ modsym_aux (y -> yp_id, ep);
+ else
+ (void) sprintf (ep, "%d", i);
+ y -> yp_offset = new_string (buf1);
+ (void) fprintf (fdef, "#define\t%s\t%d\n", y -> yp_offset, i);
+ }
+ (void) fprintf (fdef, "\n%*sunion {\n", level * 4, "");
+ level++;
+ for (y = yp -> yp_type; y; y = y -> yp_next) {
+ char *t;
+
+ if (y -> yp_flags & YP_ID)
+ modsym_aux (y -> yp_id, cp = buf1);
+ else
+ cp = gensym ("choice", NULLCP);
+ (void) sprintf (bp, " -> un.%s", cp);
+ pepsy (y, 0, level, cp, "choice", buf2, 0);
+ /* prefix yp_varexp (field name) with un. so we will generate offsets that
+ * allow for the union all the CHOICE fields are imbedded in
+ */
+ t = y->yp_varexp;
+ y->yp_varexp = my_strcat("un.", t);
+ free(t);
+
+ *bp = NULL;
+ if (!(y -> yp_flags & YP_ID))
+ free (cp);
+ if (y -> yp_next)
+ (void) fprintf (fdef, "\n");
+ }
+ level--;
+ (void) fprintf (fdef, "%*s} un;\n", level * 4, "");
+ if (!top) {
+ level--;
+
+ (void) strcpy (bp = buf2, var);
+ bp += strlen (bp);
+
+ (void) fprintf (fdef, "%*s} *%s;\n", level * 4, "",
+ array(newid, arrayflg));
+ if (!Hflag)
+ free (id);
+ }
+ break;
+
+ case YP_OID:
+ if (!top) {
+ if (aflag)
+ printag (yp, level + 4, NULLCP);
+ (void) fprintf (fdef, "%*sOID %s;\n", level * 4, "",
+ array(id, arrayflg));
+ }
+ break;
+
+ case YP_IDEFINED:
+ if (aflag)
+ printag (yp, level + 4, NULLCP);
+ {
+ /* Predefined Universal Type */
+ struct univ_typ *p;
+ if ((p = univtyp(yp->yp_identifier))) {
+ (void) fprintf (fdef, "%*s%s%s;\n", level * 4, "",
+ p->univ_data, array(id, arrayflg));
+ /*
+ if (fflag)
+ ferr(1, "pepsy:YP_IDEFINED:fflag not implemented\n");
+ */
+ break;
+ }
+ }
+ (void) fprintf (fdef, "%*sstruct %s *%s;\n", level * 4, "",
+ modsym (yp -> yp_module, yp -> yp_identifier, "type"),
+ array(id, arrayflg));
+ break;
+
+ default:
+ myyerror ("unknown type: %d", yp -> yp_code);
+ }
+}
+
+/* */
+
+static printag (yp, level, pullup)
+register YP yp;
+int level;
+char *pullup;
+{
+ (void) fprintf (fdef, "%*s/* ", level * 4, "");
+ switch (yp -> yp_code) {
+ case YP_IDEFINED:
+ if (yp -> yp_module && strcmp (yp -> yp_module, mymodule))
+ (void) fprintf (fdef, "%s.", yp -> yp_module);
+ (void) fprintf (fdef, "%s", yp -> yp_identifier);
+ break;
+
+ default:
+ (void) fprintf (fdef, "%s", tags[yp -> yp_code]);
+ break;
+ }
+ if (pullup)
+ (void) fprintf (fdef, " pulled up from %s", pullup);
+ (void) fprintf (fdef, " */\n");
+}
+
+/* */
+
+static xalloc (yp, top, level, arg, type, brackets)
+register YP yp;
+int top,
+ level,
+ brackets;
+char *arg,
+ *type;
+{
+ int didone;
+ register YP y;
+
+ if (hflag && !arg && !type)
+ return;
+
+ didone = 0;
+
+ if (arg && type) {
+ if (brackets && !didone) {
+ (void) printf ("%*s%%{\n", level * 4, "");
+ level++, didone++;
+ }
+
+ if (h2flag && (yp -> yp_code == YP_SEQTYPE ||
+ yp -> yp_code == YP_SETTYPE)) {
+ (void) printf ("%*s{\n%*sPE xx_pe = prim2%s ($$);\n\n",
+ level * 4, "", (level +1) * 4, "",
+ yp -> yp_code == YP_SEQTYPE ? "seq" : "set");
+ (void) printf ("%*sn_%s = xx_pe -> pe_cardinal > 0 ",
+ (level + 1) * 4, "", arg);
+ (void) printf ("? xx_pe -> pe_cardinal : 0;\n%*s}\n", level * 4, "");
+ (void) printf ("%*sif ((*(%s) = (struct %s *)\n",
+ level * 4, "", arg, type);
+ (void) printf ("%*scalloc (1 + (unsigned) n_%s, sizeof **(%s)",
+ (level + 2) * 4, "", arg, arg);
+ (void) printf (")) == ((struct %s *) 0)) {\n", type);
+ (void) printf ("%*sadvise (NULLCP, \"%%s\", PEPY_ERR_NOMEM);\n",
+ (level + 1) * 4, "");
+ (void) printf ("%*sreturn NOTOK;\n%*s}\n", (level + 1) * 4, "",
+ level * 4, "");
+ (void) printf ("%*s(*%s) -> nelem = n_%s;\n", level * 4, "", arg, arg);
+ (void) printf ("%*sn_%s = 0;\n", level * 4, "", arg);
+ } else {
+ (void) printf ("%*sif ((*(%s) = (struct %s *)\n",
+ level * 4, "", arg, type);
+ (void) printf ("%*scalloc (1, sizeof **(%s))) == ((struct %s *) 0)) {\n",
+ (level + 2) * 4, "", arg, type);
+ (void) printf ("%*sadvise (NULLCP, \"%%s\", PEPY_ERR_NOMEM);\n",
+ (level + 1) * 4, "");
+ (void) printf ("%*sreturn NOTOK;\n%*s}\n", (level + 1) * 4, "",
+ level * 4, "");
+ }
+ }
+ switch (yp -> yp_code) {
+ case YP_SEQTYPE:
+ case YP_SETTYPE:
+ if (top) break;
+ case YP_CHOICE:
+ case YP_SEQLIST:
+ case YP_SETLIST:
+ for (y = yp -> yp_type; y; y = y -> yp_next)
+ switch (y -> yp_code) {
+ case YP_SEQTYPE:
+ case YP_SETTYPE:
+ if (h2flag && (yp -> yp_code == YP_SETLIST ||
+ yp -> yp_code == YP_SEQLIST)) {
+ /* include allocation here - no chance later */
+ if (brackets && !didone) {
+ (void) printf ("%*s%%{\n", level * 4, "");
+ level++, didone++;
+ }
+ if (y -> yp_declexp)
+ (void) printf ("%*s%s = &(%s);\n", level * 4, "",
+ y -> yp_declexp,
+ y -> yp_varexp);
+ xalloc (y, top, level, y -> yp_declexp,
+ y -> yp_declexp, 0);
+ }
+ /* and continue ... */
+ case YP_SEQLIST:
+ case YP_SETLIST:
+ case YP_CHOICE:
+ if (brackets && !didone) {
+ (void) printf ("%*s%%{\n", level * 4, "");
+ level++, didone++;
+ }
+ (void) printf ("%*s%s = &(%s);\n",
+ level * 4, "", y -> yp_declexp,
+ y -> yp_varexp);
+ break;
+ }
+ break;
+ }
+
+ if (brackets && didone) {
+ level--;
+ (void) printf ("%*s%%}\n", level * 4, "");
+ }
+}
+
+
+static balloc (yp, var, action2, level)
+register YP yp;
+char *var, *action2;
+int level;
+{
+ (void) printf ("\n%*s%%{\n", level * 4, "");
+ level++;
+
+ (void) printf ("%*sif ((%s%s = prim2bit (pe_cpy ($$))) == NULLPE) {\n",
+ level * 4, "", var, SVAL (yp -> yp_varexp));
+ (void) printf ("%*sadvise (NULLCP, \"%%s\", PEPY_ERR_NOMEM);\n", (level + 1) * 4, "");
+ (void) printf ("%*sreturn NOTOK;\n%*s}\n", (level + 1) * 4, "", level * 4, "");
+
+ if (action2)
+ (void) printf ("\n%*s%s\n", level * 4, "", action2);
+
+ level--;
+ (void) printf ("%*s%%}", level * 4, "");
+}
+
+#ifdef notdef
+static qalloc (yp, var, action2, level)
+register YP yp;
+char *var,
+ *action2;
+int level;
+{
+ (void) printf ("\n%*s%%{\n", level * 4, "");
+ level++;
+
+ (void) printf ("%*sif ((%s%s = str2qb ($$, $$_len, 1)) == ((struct qbuf *) 0)) {\n",
+ level * 4, "", var, SVAL (yp -> yp_varexp));
+ (void) printf ("%*sadvise (NULLCP, \"%%s\", PEPY_ERR_NOMEM);\n", (level + 1) * 4, "");
+ (void) printf ("%*sreturn NOTOK;\n%*s}\n", (level + 1) * 4, "", level * 4, "");
+
+ if (action2)
+ (void) printf ("\n%*s%s\n", level * 4, "", action2);
+
+ level--;
+ (void) printf ("%*s%%}", level * 4, "");
+}
+#endif
+
+/* */
+
+/*
+ * now we don't pull up things if they have actions associated with them
+ * this should be okay for those who want exact posy equivalence and
+ * yet keep those who want the pepy support able to have multiple
+ * actions in CHOICE { CHOICE {} } and such like
+ */
+static choice_pullup (yp, partial)
+register YP yp;
+int partial;
+{
+ register YP *x,
+ y,
+ z,
+ *z1,
+ z2,
+ z3;
+
+ for (x = &yp -> yp_type; y = *x; x = &y -> yp_next) {
+ if (y -> yp_flags & (YP_TAG | YP_BOUND))
+ continue;
+
+ switch (y -> yp_code) {
+ case YP_IDEFINED:
+ if ((z = lookup_type (y -> yp_module, y -> yp_identifier))
+ == NULLYP
+ || z -> yp_code != YP_CHOICE)
+ continue;
+ if (z -> yp_control_act || z ->yp_bef_alist || z-> yp_aft_alist)
+ continue;
+
+ choice_pullup (z2 = copy_type (z), CH_FULLY);
+ if (y -> yp_flags & YP_OPTIONAL) {
+ z2 -> yp_flags |= YP_OPTIONAL;
+ partial = 1;
+ }
+ if (y -> yp_flags & YP_DEFAULT) {
+ z2 -> yp_flags |= YP_DEFAULT;
+ z2 -> yp_default = copy_value (y -> yp_default);
+ partial = 1;
+ }
+ goto patch;
+
+ case YP_CHOICE:
+ if (y -> yp_control_act || y ->yp_bef_alist || y-> yp_aft_alist)
+ continue;
+
+ choice_pullup (z2 = copy_type (y), CH_FULLY);
+patch: ;
+ if (partial) {
+ *x = z2;
+ z2 -> yp_next = y -> yp_next;
+ continue;
+ }
+ break;
+
+ default:
+ continue;
+ }
+ z = z3 = z2 -> yp_type;
+ for (z1 = &z -> yp_next; z2 = *z1; z1 = &z2 -> yp_next)
+ z3 = z2;
+ *z1 = y -> yp_next;
+ *x = z;
+ y = z3;
+ }
+}
+
+/* */
+
+static components_pullup (yp)
+register YP yp;
+{
+ register YP *x,
+ y,
+ z,
+ z1,
+ z2;
+
+ for (x = &yp -> yp_type; y = *x; x = &y -> yp_next) {
+ if (!(y -> yp_flags & YP_COMPONENTS))
+ continue;
+
+ switch (y -> yp_code) {
+ case YP_SEQLIST:
+ case YP_SETLIST:
+ z = y;
+ break;
+
+ case YP_IDEFINED:
+ if ((z = lookup_type (y -> yp_module, y -> yp_identifier))
+ == NULLYP) {
+ warning ("COMPONENTS OF target \"%s\" is undefined",
+ y -> yp_identifier);
+ continue;
+ }
+ break;
+ }
+ if (yp -> yp_code != z -> yp_code) {
+ warning ("COMPONENTS OF target \"%s\" is wrong type, should be %s",
+ y -> yp_code == YP_IDEFINED ? y -> yp_identifier
+ : y -> yp_id ? y -> yp_id
+ : "",
+ yp -> yp_code == YP_SEQLIST ? "SEQUENCE" : "SET");
+ continue;
+ }
+ if (z -> yp_type == NULLYP)
+ continue;
+ components_pullup (z = copy_type (z));
+ *x = z2 = z -> yp_type;
+ for (x = &z -> yp_type; z1 = *x; x = &z1 -> yp_next)
+ z2 = z1;
+ *x = y -> yp_next;
+ y = z2;
+ }
+}
+
+/* VALUE HANDLING */
+
+static int val2int (yv)
+register YV yv;
+{
+ switch (yv -> yv_code) {
+ case YV_BOOL:
+ case YV_NUMBER:
+ return yv -> yv_number;
+
+ case YV_STRING:
+ yyerror ("need an integer, not a string");
+
+ case YV_IDEFINED:
+ case YV_IDLIST:
+ yyerror ("haven't written symbol table for values yet");
+
+ case YV_NULL:
+ yyerror ("need an integer, not NULL");
+
+ default:
+ myyerror ("unknown value: %d", yv -> yv_code);
+ }
+/* NOTREACHED */
+}
+
+static double val2real (yv)
+register YV yv;
+{
+ switch (yv -> yv_code) {
+ case YV_NUMBER:
+ return yv -> yv_number;
+
+ case YV_REAL:
+ return yv -> yv_real;
+
+ case YV_STRING:
+ yyerror ("need an integer, not a string");
+
+ case YV_IDEFINED:
+ case YV_IDLIST:
+ yyerror ("haven't written symbol table for values yet");
+
+ case YV_NULL:
+ yyerror ("need an integer, not NULL");
+
+ default:
+ myyerror ("unknown value: %d", yv -> yv_code);
+ }
+/* NOTREACHED */
+}
+
+/* */
+
+static val2prf (yv, level)
+register YV yv;
+int level;
+{
+ register YV y;
+
+ if (yv -> yv_flags & YV_ID)
+ (void) printf ("%s ", yv -> yv_id);
+
+ if (yv -> yv_flags & YV_TYPE) /* will this REALLY work??? */
+ do_type1 (yv -> yv_type, 0, level, NULLCP, NULLCP, NULLCP, NULL);
+
+ switch (yv -> yv_code) {
+ case YV_BOOL:
+ (void) printf (yv -> yv_number ? "TRUE" : "FALSE");
+ break;
+
+ case YV_NUMBER:
+ if (yv -> yv_named)
+ (void) printf ("%s", yv -> yv_named);
+ else
+ (void) printf ("%d", yv -> yv_number);
+ break;
+
+ case YV_REAL:
+ dump_real (yv -> yv_real);
+ break;
+
+ case YV_STRING:
+ (void) printf ("\"%s\"", yv -> yv_string);
+ break;
+
+ case YV_IDEFINED:
+ if (yv -> yv_module)
+ (void) printf ("%s.", yv -> yv_module);
+ (void) printf ("%s", yv -> yv_identifier);
+ break;
+
+ case YV_IDLIST:
+ case YV_VALIST:
+ (void) printf ("{");
+ for (y = yv -> yv_idlist; y; y = y -> yv_next) {
+ (void) printf (" ");
+ val2prf (y, level + 1);
+ (void) printf (y -> yv_next ? ", " : " ");
+ }
+ (void) printf ("}");
+ break;
+
+ case YV_NULL:
+ (void) printf ("NULL");
+ break;
+
+ default:
+ myyerror ("unknown value: %d", yv -> yv_code);
+ /* NOTREACHED */
+ }
+}
+static dump_real (r)
+double r;
+{
+#ifndef BSD44
+ extern char *ecvt ();
+ char *cp;
+ char sbuf[128];
+ int decpt, sign;
+
+ cp = ecvt (r, 20, &decpt, &sign);
+ (void) strcpy (sbuf, cp); /* cp gets overwritten by printf */
+ (void) printf ("{ %s%s, 10, %d }", sign ? "-" : "", sbuf,
+ decpt - strlen (sbuf));
+#else
+ register char *cp,
+ *dp,
+ *sp;
+ char sbuf[128];
+
+ (void) sprintf (sbuf, "%.19e", r);
+ if (*(dp = sbuf) == '-')
+ sp = "-", dp++;
+ else
+ sp = "";
+
+ if (dp[1] != '.' || (cp = index (dp, 'e')) == NULL) {
+ (void) printf ("{ 0, 10, 0 } -- %s --", sbuf);
+ return;
+ }
+ *cp++ = NULL;
+ (void) printf ("{ %s%c%s, 10, %d }",
+ sp, *dp, dp + 2, atoi (cp) - strlen (dp + 2));
+#endif
+}
+
+/* */
+
+static int dfl2int (yp)
+register YP yp;
+{
+ register YV yv,
+ y;
+
+ yv = yp -> yp_default;
+ switch (yv -> yv_code) {
+ case YV_BOOL:
+ case YV_NUMBER:
+ return yv -> yv_number;
+
+ case YV_STRING:
+ yyerror ("need an integer, not a string");
+
+ case YV_REAL:
+ yyerror ("need an integer, not a real");
+
+ case YV_IDEFINED:
+ for (y = yp -> yp_value; y; y = y -> yv_next)
+ if (y -> yv_code == YV_NUMBER
+ && (y -> yv_flags & YV_NAMED)
+ && strcmp (yv -> yv_identifier, y -> yv_named) == 0)
+ return y -> yv_number;
+ /* and fall */
+
+ case YV_IDLIST:
+ yyerror ("haven't written symbol table for values yet");
+
+ case YV_NULL:
+ yyerror ("need an integer, not NULL");
+
+ default:
+ myyerror ("unknown value: %d", yv -> yv_code);
+ }
+/* NOTREACHED */
+}
+
+/* DEBUG */
+
+print_type (yp, level)
+register YP yp;
+register int level;
+{
+ register YP y;
+ register YV yv;
+
+ if (yp == NULLYP)
+ return;
+
+ (void) fprintf (stderr, "%*scode=0x%x flags=%s direction=0x%x\n", level * 4, "",
+ yp -> yp_code, sprintb (yp -> yp_flags, YPBITS),
+ yp -> yp_direction);
+ (void) fprintf (stderr,
+ "%*sintexp=\"%s\" strexp=\"%s\" prfexp=0%o declexp=\"%s\" varexp=\"%s\"\n",
+ level * 4, "", yp -> yp_intexp, yp -> yp_strexp, yp -> yp_prfexp,
+ yp -> yp_declexp, yp -> yp_varexp);
+ if (yp -> yp_param_type)
+ (void) fprintf (stderr, "%*sparameter type=\"%s\"\n", level * 4, "",
+ yp -> yp_param_type);
+ if (yp -> yp_action0)
+ (void) fprintf (stderr, "%*saction0 at line %d=\"%s\"\n", level * 4, "",
+ yp -> yp_act0_lineno, yp -> yp_action0);
+ if (yp -> yp_action05)
+ (void) fprintf (stderr, "%*saction05 at line %d=\"%s\"\n", level * 4, "",
+ yp -> yp_act05_lineno, yp -> yp_action05);
+ if (yp -> yp_action1)
+ (void) fprintf (stderr, "%*saction1 at line %d=\"%s\"\n", level * 4, "",
+ yp -> yp_act1_lineno, yp -> yp_action1);
+ if (yp -> yp_action2)
+ (void) fprintf (stderr, "%*saction2 at line %d=\"%s\"\n", level * 4, "",
+ yp -> yp_act2_lineno, yp -> yp_action2);
+ if (yp -> yp_action3)
+ (void) fprintf (stderr, "%*saction3 at line %d=\"%s\"\n", level * 4, "",
+ yp -> yp_act3_lineno, yp -> yp_action3);
+
+ if (yp -> yp_flags & YP_TAG) {
+ (void) fprintf (stderr, "%*stag class=0x%x value=0x%x\n", level * 4, "",
+ yp -> yp_tag -> yt_class, yp -> yp_tag -> yt_value);
+ print_value (yp -> yp_tag -> yt_value, level + 1);
+ }
+
+ if (yp -> yp_flags & YP_DEFAULT) {
+ (void) fprintf (stderr, "%*sdefault=0x%x\n", level * 4, "", yp -> yp_default);
+ print_value (yp -> yp_default, level + 1);
+ }
+
+ if (yp -> yp_flags & YP_ID)
+ (void) fprintf (stderr, "%*sid=\"%s\"\n", level * 4, "", yp -> yp_id);
+
+ if (yp -> yp_flags & YP_BOUND)
+ (void) fprintf (stderr, "%*sbound=\"%s\"\n", level * 4, "", yp -> yp_bound);
+
+ if (yp -> yp_offset)
+ (void) fprintf (stderr, "%*soffset=\"%s\"\n", level * 4, "", yp -> yp_offset);
+
+ switch (yp -> yp_code) {
+ case YP_INTLIST:
+ case YP_ENUMLIST:
+ case YP_BITLIST:
+ (void) fprintf (stderr, "%*svalue=0x%x\n", level * 4, "", yp -> yp_value);
+ for (yv = yp -> yp_value; yv; yv = yv -> yv_next) {
+ print_value (yv, level + 1);
+ (void) fprintf (stderr, "%*s----\n", (level + 1) * 4, "");
+ }
+ break;
+
+ case YP_SEQTYPE:
+ case YP_SEQLIST:
+ case YP_SETTYPE:
+ case YP_SETLIST:
+ case YP_CHOICE:
+ (void) fprintf (stderr, "%*stype=0x%x\n", level * 4, "", yp -> yp_type);
+ for (y = yp -> yp_type; y; y = y -> yp_next) {
+ print_type (y, level + 1);
+ (void) fprintf (stderr, "%*s----\n", (level + 1) * 4, "");
+ }
+ break;
+
+ case YP_IDEFINED:
+ (void) fprintf (stderr, "%*smodule=\"%s\" identifier=\"%s\"\n",
+ level * 4, "", yp -> yp_module ? yp -> yp_module : "",
+ yp -> yp_identifier);
+ break;
+
+ default:
+ break;
+ }
+}
+
+/* */
+
+static print_value (yv, level)
+register YV yv;
+register int level;
+{
+ register YV y;
+
+ if (yv == NULLYV)
+ return;
+
+ (void) fprintf (stderr, "%*scode=0x%x flags=%s\n", level * 4, "",
+ yv -> yv_code, sprintb (yv -> yv_flags, YVBITS));
+
+ if (yv -> yv_action)
+ (void) fprintf (stderr, "%*saction at line %d=\"%s\"\n", level * 4, "",
+ yv -> yv_act_lineno, yv -> yv_action);
+
+ if (yv -> yv_flags & YV_ID)
+ (void) fprintf (stderr, "%*sid=\"%s\"\n", level * 4, "", yv -> yv_id);
+
+ if (yv -> yv_flags & YV_NAMED)
+ (void) fprintf (stderr, "%*snamed=\"%s\"\n", level * 4, "", yv -> yv_named);
+
+ if (yv -> yv_flags & YV_TYPE) {
+ (void) fprintf (stderr, "%*stype=0x%x\n", level * 4, "", yv -> yv_type);
+ print_type (yv -> yv_type, level + 1);
+ }
+
+ switch (yv -> yv_code) {
+ case YV_NUMBER:
+ case YV_BOOL:
+ (void) fprintf (stderr, "%*snumber=0x%x\n", level * 4, "",
+ yv -> yv_number);
+ break;
+
+ case YV_STRING:
+ (void) fprintf (stderr, "%*sstring=\"%s\"\n", level * 4, "",
+ yv -> yv_string);
+ break;
+
+ case YV_IDEFINED:
+ if (yv -> yv_flags & YV_BOUND)
+ (void) fprintf (stderr, "%*smodule=\"%s\" identifier=\"%s\"\n",
+ level * 4, "", yv -> yv_module, yv -> yv_identifier);
+ else
+ (void) fprintf (stderr, "%*sbound identifier=\"%s\"\n",
+ level * 4, "", yv -> yv_identifier);
+ break;
+
+ case YV_IDLIST:
+ case YV_VALIST:
+ for (y = yv -> yv_idlist; y; y = y -> yv_next) {
+ print_value (y, level + 1);
+ (void) fprintf (stderr, "%*s----\n", (level + 1) * 4, "");
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+/* SYMBOLS */
+
+static SY new_symbol (encpref, decpref, prfpref, mod, id, type)
+register char *encpref,
+ *decpref,
+ *prfpref,
+ *mod,
+ *id;
+register YP type;
+{
+ register SY sy;
+
+ if ((sy = (SY) calloc (1, sizeof *sy)) == NULLSY)
+ yyerror ("out of memory");
+ sy -> sy_encpref = encpref;
+ sy -> sy_decpref = decpref;
+ sy -> sy_prfpref = prfpref;
+ sy -> sy_module = mod;
+ sy -> sy_name = id;
+ sy -> sy_type = type;
+
+ return sy;
+}
+
+
+static SY add_symbol (s1, s2)
+register SY s1,
+ s2;
+{
+ register SY sy;
+
+ if (s1 == NULLSY)
+ return s2;
+
+ for (sy = s1; sy -> sy_next; sy = sy -> sy_next)
+ continue;
+ sy -> sy_next = s2;
+
+ return s1;
+}
+
+/* MODULES */
+
+MD lookup_module (module, oid)
+char *module;
+OID oid;
+{
+ register MD md;
+
+ for (md = mymodules; md; md = md -> md_next) {
+ if (module && md -> md_module && strcmp (md -> md_module, module) == 0)
+ return md;
+ if (oid && md -> md_oid && oid_cmp(oid, md->md_oid) == 0)
+ return md;
+ }
+
+ read_ph_file (module, oid);
+
+ if ((md = (MD) calloc (1, sizeof *md)) == NULLMD)
+ yyerror ("out of memory");
+ md -> md_module = new_string (module);
+ if (oid)
+ md -> md_oid = oid_cpy(oid);
+ else
+ md -> md_oid = NULLOID;
+
+ if (mymodules != NULLMD)
+ md -> md_next = mymodules;
+
+ return (mymodules = md);
+}
+
+/* TYPES */
+
+YP new_type (code, lineno)
+int code;
+int lineno;
+{
+ register YP yp;
+
+ if ((yp = (YP) calloc (1, sizeof *yp)) == NULLYP)
+ yyerror ("out of memory");
+ yp -> yp_code = code;
+ yp -> yp_lineno = lineno;
+
+ return yp;
+}
+
+
+YP add_type (y, z)
+register YP y,
+ z;
+{
+ register YP yp;
+
+ for (yp = y; yp -> yp_next; yp = yp -> yp_next)
+ continue;
+ yp -> yp_next = z;
+
+ return y;
+}
+
+/* */
+
+YP copy_type (yp)
+register YP yp;
+{
+ register YP y;
+
+ if (yp == NULLYP)
+ return NULLYP;
+
+ y = new_type (yp -> yp_code, yp -> yp_lineno);
+ y -> yp_direction = yp -> yp_direction;
+
+ switch (yp -> yp_code) {
+ case YP_IDEFINED:
+ if (yp -> yp_module)
+ y -> yp_module = new_string (yp -> yp_module);
+ y -> yp_identifier = new_string (yp -> yp_identifier);
+ y -> yp_modid = oid_cpy (yp -> yp_modid);
+ break;
+
+ case YP_SEQTYPE:
+ case YP_SEQLIST:
+ case YP_SETTYPE:
+ case YP_SETLIST:
+ case YP_CHOICE:
+ y -> yp_type = copy_type (yp -> yp_type);
+ break;
+
+ case YP_INTLIST:
+ case YP_ENUMLIST:
+ case YP_BITLIST:
+ y -> yp_value = copy_value (yp -> yp_value);
+ break;
+
+ default:
+ break;
+ }
+
+ y -> yp_intexp = yp -> yp_intexp;
+ y -> yp_strexp = yp -> yp_strexp;
+ y -> yp_prfexp = yp -> yp_prfexp;
+
+ y -> yp_declexp = yp -> yp_declexp;
+ y -> yp_varexp = yp -> yp_varexp;
+
+ if (yp -> yp_structname)
+ y -> yp_structname = new_string (yp -> yp_structname);
+ if (yp -> yp_ptrname)
+ y -> yp_ptrname = new_string (yp -> yp_ptrname);
+
+ if (yp -> yp_param_type)
+ y -> yp_param_type = new_string (yp -> yp_param_type);
+
+ if (yp -> yp_action0) {
+ y -> yp_action0 = new_string (yp -> yp_action0);
+ y -> yp_act0_lineno = yp -> yp_act0_lineno;
+ }
+
+ if (yp -> yp_action05) {
+ y -> yp_action05 = new_string (yp -> yp_action05);
+ y -> yp_act05_lineno = yp -> yp_act05_lineno;
+ }
+
+ if (yp -> yp_action1) {
+ y -> yp_action1 = new_string (yp -> yp_action1);
+ y -> yp_act1_lineno = yp -> yp_act1_lineno;
+ }
+
+ if (yp -> yp_action2) {
+ y -> yp_action2 = new_string (yp -> yp_action2);
+ y -> yp_act2_lineno = yp -> yp_act2_lineno;
+ }
+
+ if (yp -> yp_action3) {
+ y -> yp_action3 = new_string (yp -> yp_action3);
+ y -> yp_act3_lineno = yp -> yp_act3_lineno;
+ }
+
+ y -> yp_flags = yp -> yp_flags;
+
+ if (yp -> yp_flags & YP_DEFAULT)
+ y -> yp_default = copy_value (yp -> yp_default);
+
+ if (yp -> yp_flags & YP_ID)
+ y -> yp_id = new_string (yp -> yp_id);
+
+ if (yp -> yp_flags & YP_TAG)
+ y -> yp_tag = copy_tag (yp -> yp_tag);
+
+ if (yp -> yp_flags & YP_BOUND)
+ y -> yp_bound = new_string (yp -> yp_bound);
+
+ if (yp -> yp_flags & YP_PARMVAL)
+ y -> yp_parm = new_string (yp -> yp_parm);
+
+ if (yp -> yp_flags & YP_CONTROLLED)
+ y -> yp_control = new_string (yp -> yp_control);
+
+ if (yp -> yp_flags & YP_OPTCONTROL)
+ y -> yp_optcontrol = new_string (yp -> yp_optcontrol);
+
+ if (yp -> yp_offset)
+ y -> yp_offset = new_string (yp -> yp_offset);
+
+ if (yp -> yp_control_act) {
+ y -> yp_control_act = yp -> yp_control_act;
+ }
+ if (yp -> yp_optional_act) {
+ y -> yp_optional_act = yp -> yp_optional_act;
+ }
+ if (yp -> yp_bef_alist) {
+ y -> yp_bef_alist = yp -> yp_bef_alist;
+ }
+ if (yp -> yp_aft_alist) {
+ y -> yp_aft_alist = yp -> yp_aft_alist;
+ }
+
+
+ if (yp -> yp_next)
+ y -> yp_next = copy_type (yp -> yp_next);
+
+ return y;
+}
+
+/* VALUES */
+
+YV new_value (code)
+int code;
+{
+ register YV yv;
+
+ if ((yv = (YV) calloc (1, sizeof *yv)) == NULLYV)
+ yyerror ("out of memory");
+ yv -> yv_code = code;
+
+ return yv;
+}
+
+
+YV add_value (y, z)
+register YV y,
+ z;
+{
+ register YV yv;
+
+ for (yv = y; yv -> yv_next; yv = yv -> yv_next)
+ continue;
+ yv -> yv_next = z;
+
+ return y;
+}
+
+/* */
+
+YV copy_value (yv)
+register YV yv;
+{
+ register YV y;
+
+ if (yv == NULLYV)
+ return NULLYV;
+
+ y = new_value (yv -> yv_code);
+ y -> yv_flags = yv -> yv_flags;
+
+ if (yv -> yv_action) {
+ y -> yv_action = new_string (yv -> yv_action);
+ y -> yv_act_lineno = yv -> yv_act_lineno;
+ }
+
+ if (yv -> yv_flags & YV_ID)
+ y -> yv_id = new_string (yv -> yv_id);
+
+ if (yv -> yv_flags & YV_NAMED)
+ y -> yv_named = new_string (yv -> yv_named);
+
+ if (yv -> yv_flags & YV_TYPE)
+ y -> yv_type = copy_type (yv -> yv_type);
+
+ switch (yv -> yv_code) {
+ case YV_NUMBER:
+ case YV_BOOL:
+ y -> yv_number = yv -> yv_number;
+ break;
+
+ case YV_STRING:
+ y -> yv_string = new_string (yv -> yv_string);
+ break;
+
+ case YV_IDEFINED:
+ if (yv -> yv_module)
+ y -> yv_module = new_string (yv -> yv_module);
+ y -> yv_identifier = new_string (yv -> yv_identifier);
+ break;
+
+ case YV_IDLIST:
+ case YV_VALIST:
+ y -> yv_idlist = copy_value (yv -> yv_idlist);
+ break;
+
+ default:
+ break;
+ }
+
+ if (yv -> yv_next)
+ y -> yv_next = copy_value (yv -> yv_next);
+
+ return y;
+}
+
+/* TAGS */
+
+YT new_tag (class)
+PElementClass class;
+{
+ register YT yt;
+
+ if ((yt = (YT) calloc (1, sizeof *yt)) == NULLYT)
+ yyerror ("out of memory");
+ yt -> yt_class = class;
+
+ return yt;
+}
+
+/* */
+
+YT copy_tag (yt)
+register YT yt;
+{
+ register YT y;
+
+ if (yt == NULLYT)
+ return NULLYT;
+
+ y = new_tag (yt -> yt_class);
+
+ y -> yt_value = copy_value (yt -> yt_value);
+
+ return y;
+}
+
+/* STRINGS */
+
+char *new_string (s)
+register char *s;
+{
+ register char *p;
+
+ if (s == NULLCP)
+ return NULLCP;
+
+ if ((p = malloc ((unsigned) (strlen (s) + 1))) == NULLCP)
+ yyerror ("out of memory");
+
+ (void) strcpy (p, s);
+ return p;
+}
+
+/* SYMBOLS */
+
+static struct triple {
+ char *t_name;
+ PElementClass t_class;
+ PElementID t_id;
+} triples[] = {
+ "IA5String", PE_CLASS_UNIV, PE_DEFN_IA5S,
+ "ISO646String", PE_CLASS_UNIV, PE_DEFN_IA5S,
+ "NumericString", PE_CLASS_UNIV, PE_DEFN_NUMS,
+ "PrintableString", PE_CLASS_UNIV, PE_DEFN_PRTS,
+ "T61String", PE_CLASS_UNIV, PE_DEFN_T61S,
+ "TeletexString", PE_CLASS_UNIV, PE_DEFN_T61S,
+ "VideotexString", PE_CLASS_UNIV, PE_DEFN_VTXS,
+ "GeneralizedTime", PE_CLASS_UNIV, PE_DEFN_GENT,
+ "GeneralisedTime", PE_CLASS_UNIV, PE_DEFN_GENT,
+ "UTCTime", PE_CLASS_UNIV, PE_DEFN_UTCT,
+ "UniversalTime", PE_CLASS_UNIV, PE_DEFN_UTCT,
+ "GraphicString", PE_CLASS_UNIV, PE_DEFN_GFXS,
+ "VisibleString", PE_CLASS_UNIV, PE_DEFN_VISS,
+ "GeneralString", PE_CLASS_UNIV, PE_DEFN_GENS,
+ "EXTERNAL", PE_CLASS_UNIV, PE_CONS_EXTN,
+ "ObjectDescriptor", PE_CLASS_UNIV, PE_PRIM_ODE,
+
+ NULL
+};
+
+/* */
+
+char *modsym (module, id, prefix)
+register char *module,
+ *id;
+char *prefix;
+{
+ char buf1[BUFSIZ],
+ buf2[BUFSIZ],
+ buf3[BUFSIZ];
+ register struct triple *t;
+ static char buffer[BUFSIZ];
+
+ if (module == NULLCP)
+ for (t = triples; t -> t_name; t++)
+ if (strcmp (t -> t_name, id) == 0) {
+ module = "UNIV";
+ break;
+ }
+
+ if (prefix)
+ modsym_aux (prefix, buf1);
+ modsym_aux (module ? module : mymodule, buf2);
+ modsym_aux (id, buf3);
+ if (prefix)
+ (void) sprintf (buffer, "%s_%s_%s", buf1, buf2, buf3);
+ else
+ (void) sprintf (buffer, "%s_%s", buf2, buf3);
+
+ return buffer;
+}
+
+
+static modsym_aux (name, bp)
+register char *name,
+ *bp;
+{
+ register char c;
+
+ while (c = *name++)
+ switch (c) {
+ case '-':
+ *bp++ = '_';
+ *bp++ = '_';
+ break;
+
+ default:
+ *bp++ = c;
+ break;
+ }
+
+ *bp = NULL;
+}
+
+/* */
+
+static char *gensym (s, a)
+char *s, *a;
+{
+ int i;
+ register char *p;
+ char buffer[BUFSIZ];
+ static int cP = 0;
+ static int eP = 0;
+ static int mP = 0;
+
+ switch (*s) {
+ case 'c':
+ i = cP++;
+ break;
+ case 'e':
+ i = eP++;
+ break;
+ case 'm':
+ i = mP++;
+ break;
+
+ default:
+ myyerror ("unknown gensym argument \"%s\"", s);
+ /* NOTREACHED */
+ }
+ if (a)
+ (void) sprintf (buffer, "%s_%s_%d[n_%s]", s, modulename, i, a);
+ else
+ (void) sprintf (buffer, "%s_%s_%d", s, modulename, i);
+
+ if ((p = malloc ((unsigned) (strlen (buffer) + 11))) == NULLCP)
+ yyerror ("out of memory");
+
+ (void) strcpy (p, buffer);
+ return p;
+}
+
+/* pepy compatible routines - you know how it is ... */
+init_new_file ()
+{
+ ;
+}
+
+end_file ()
+{
+ ;
+}
+
+static char *array (s, flg)
+char *s;
+int flg;
+{
+ static char buf[BUFSIZ];
+ char *p;
+
+ if (!flg) return s;
+
+ if (p = index (s, '[')) {
+ (void) sprintf (buf, "%*.*s[1]", p - s, p - s, s);
+ return buf;
+ }
+ return s;
+}
+
+static void prime_default (yp, level)
+YP yp;
+int level;
+{
+ switch (yp -> yp_code) {
+ case YP_BOOL:
+ (void) printf ("%*s%s = %d;\n", level * 4, "",
+ SVAL (yp->yp_varexp),
+ val2int (yp -> yp_default) ? 1 : 0);
+ break;
+
+ case YP_INT:
+ (void) printf ("%*s%s = %d;\n", level * 4, "",
+ SVAL (yp -> yp_varexp), val2int (yp -> yp_default));
+ break;
+
+ case YP_INTLIST:
+ case YP_ENUMLIST:
+ (void) printf ("%*s%s = %d;\n", level * 4, "",
+ SVAL (yp -> yp_varexp), dfl2int (yp));
+ break;
+
+ case YP_REAL:
+ (void) printf ("%*s%s = %g;\n", level * 4, "",
+ SVAL (yp -> yp_varexp),
+ val2real (yp -> yp_default));
+
+ default:
+ break;
+ }
+}
+/* PH FILES */
+
+/* really need much more information in the .ph file... */
+
+static read_ph_file (module, oid)
+register char *module;
+OID oid;
+{
+ int class,
+ value,
+ direction;
+ char buffer[BUFSIZ],
+ file[BUFSIZ],
+ id[BUFSIZ],
+ encpref[BUFSIZ],
+ decpref[BUFSIZ],
+ printpref[BUFSIZ];
+ char *p, *ep, *dp, *ppp;
+ register FILE *fp;
+ register YP yp;
+ register YT yt;
+ register YV yv;
+
+ (void) sprintf (file, "%s.ph", module);
+ if (oid)
+ (void) sprintf (p = buffer, "%s.ph", sprintoid(oid));
+ else
+ p = NULLCP;
+ if ((fp = open_ph_file (file, p, "r")) == NULL)
+ {
+ warning ("Can't find file %s%s%s failed\n",
+ file, p ? "/" : "", p ? p : "");
+ return;
+ }
+
+ if (strcmp (module, "UNIV"))
+ yyprint (module, 1, 0);
+
+ while (fgets (buffer, sizeof buffer, fp)) {
+ if (sscanf (buffer, "%d/%d/%d: %s",
+ &class, &value, &direction, id) !=4) {
+ myyerror ("bad external definition in %s: %s",
+ file, buffer);
+ continue;
+ }
+ ppp = dp = ep = NULLCP;
+ if (p = index(buffer, '|')) {
+ if( sscanf (p+1, "%s %s %s\n", encpref, decpref, printpref) == 3) {
+ ppp = new_string (printpref);
+ dp = new_string (decpref);
+ ep = new_string (encpref);
+ }
+ }
+
+ yp = new_type (class == -1 ? YP_ANY : YP_IMPTYPE, -1);
+ yp -> yp_flags = YP_IMPORTED;
+ if (class >= 0) {
+ yp -> yp_flags |= YP_TAG;
+ yp -> yp_tag = yt = new_tag ((PElementClass) class);
+ yt -> yt_value = yv = new_value (YV_NUMBER);
+ yv -> yv_number = value;
+ }
+ yp -> yp_direction = direction;
+ pass1_type (ep, dp, ppp, new_string (module),
+ new_string (id), yp);
+ }
+
+ (void) fclose (fp);
+}
+
+/* */
+
+static write_ph_file () {
+ int msave;
+ char file[BUFSIZ];
+ char fileoid[BUFSIZ];
+ char *cp;
+ register FILE *fp;
+ register SY sy;
+ register YT yt;
+ register YP yp;
+
+ (void) sprintf (file, "%s.ph", mymodule);
+ if (mymoduleid)
+ (void) sprintf (cp = fileoid, "%s.ph", sprintoid(mymoduleid));
+ else
+ cp = NULLCP;
+ msave = mflag, mflag = 0;
+ if ((fp = open_ph_file (file, cp, "w")) == NULL)
+ myyerror ("unable to write %s", file);
+ mflag = msave;
+
+ for (sy = mysymbols; sy; sy = sy -> sy_next) {
+ yp = sy -> sy_type;
+ if (yp -> yp_flags & YP_IMPORTED)
+ continue;
+ if (doexternals == 0 && (yp->yp_flags & YP_EXPORTED) == 0)
+ continue;
+
+ if (is_any_type (yp)) {
+ (void) fprintf (fp, "-1/0/%d: %s", yp -> yp_direction, sy -> sy_name);
+ (void) fprintf (fp, " |%s %s %s\n", yyencpref, yydecpref, yyprfpref);
+ }
+ else
+ if ((yt = lookup_tag (yp)) && yt -> yt_class != PE_CLASS_CONT) {
+ (void) fprintf (fp, "%d/%d/%d: %s", yt -> yt_class,
+ val2int (yt -> yt_value), yp -> yp_direction,
+ sy -> sy_name);
+ (void) fprintf (fp, " |%s %s %s\n", yyencpref, yydecpref, yyprfpref);
+ }
+ }
+
+ (void) fclose (fp);
+}
+
+/* */
+
+#ifndef PEPSYPATH
+#define PEPSYPATH ""
+#endif
+
+
+static FILE *open_ph_file (fn, fnoid, mode)
+char *fn,
+ *fnoid,
+ *mode;
+{
+ register char *dst,
+ *path;
+ char fnb[BUFSIZ];
+ register FILE *fp;
+ static char *pepypath = NULL;
+
+ if (*fn == '/')
+ return fopen (fn, mode);
+
+ if (mflag) { /* MOBY HACK */
+ if ((fp = fopen (fn, mode)) != NULL)
+ return fp;
+ if (fnoid && (fp = fopen (fnoid, mode)) != NULL)
+ return fp;
+
+ (void) sprintf (fnb, "../pepy/%s", fn);
+ if ((fp = fopen (fnb, mode)) != NULL)
+ return fp;
+ if (fnoid) {
+ (void) sprintf (fnb, "../pepy/%s", fnoid);
+ if ((fp = fopen (fnb, mode)) != NULL)
+ return fp;
+ }
+
+ (void) sprintf (fnb, "../../pepy/%s", fn);
+ if((fp = fopen (fnb, mode)) != NULL)
+ return fp;
+ if (fnoid) {
+ (void) sprintf (fnb, "../../pepy/%s", fnoid);
+ if ((fp = fopen (fnb, mode)) != NULL)
+ return fp;
+ }
+ return NULL;
+ }
+
+ if (pepypath == NULL && (pepypath = getenv ("PEPSYPATH")) == NULL)
+ pepypath = PEPSYPATH;
+ path = pepypath;
+
+ do {
+ dst = fnb;
+ while (*path && *path != ':')
+ *dst++ = *path++;
+ if (dst != fnb)
+ *dst++ = '/';
+ (void) strcpy (dst, fn);
+ if ((fp = fopen (fnb, mode)) != NULL)
+ break;
+ if (fnoid) {
+ (void) strcpy (dst, fnoid);
+ if ((fp = fopen (fnb, mode)) != NULL)
+ break;
+ }
+ } while (*path++);
+
+ return fp;
+}
+
+YT lookup_tag (yp)
+register YP yp;
+{
+ register struct tuple *t;
+ static struct ypt ypts;
+ register YT yt = &ypts;
+ static struct ypv ypvs;
+ register YV yv = &ypvs;
+ register YP z;
+
+ if (yp -> yp_flags & YP_TAG)
+ return yp -> yp_tag;
+
+ while (yp -> yp_code == YP_IDEFINED) {
+ if (yp -> yp_module && strcmp (yp -> yp_module, mymodule))
+ (void) lookup_module (yp -> yp_module, yp -> yp_modid);
+
+ if (z = lookup_type (yp -> yp_module, yp -> yp_identifier)) {
+ yp = z;
+
+ if (yp -> yp_flags & YP_TAG)
+ return yp -> yp_tag;
+
+ continue;
+ }
+
+ break;
+ }
+
+ for (t = tuples; t -> t_type != YP_UNDF; t++)
+ if (t -> t_type == yp -> yp_code) {
+ yt -> yt_class = t -> t_classnum;
+ yt -> yt_value = yv;
+ yv -> yv_code = YV_NUMBER;
+ yv -> yv_number = t -> t_idnum;
+
+ return yt;
+ }
+
+ return NULLYT;
+}
+
+int is_any_type (yp)
+register YP yp;
+{
+ register YP z;
+
+ while (yp -> yp_code == YP_IDEFINED) {
+ if (yp -> yp_flags & YP_TAG)
+ return 0;
+
+ if (yp -> yp_module && strcmp (yp -> yp_module, mymodule))
+ (void) lookup_module (yp -> yp_module, yp -> yp_modid);
+
+ if (z = lookup_type (yp -> yp_module, yp -> yp_identifier)) {
+ yp = z;
+
+ continue;
+ }
+
+ break;
+ }
+
+ return (yp -> yp_code == YP_ANY && !(yp -> yp_flags & YP_TAG));
+}
+
+/*
+ * return a string with the leading pathname stripped off
+ */
+char *
+pstrip(p)
+char *p;
+{
+ char *p1;
+
+ if (p1 = rindex(p, '/'))
+ return (p1 + 1);
+ return (p);
+}
+
+
+/*
+ * produce a #include on the given file descriptor according to what ever
+ * rules are in fashion today. Unfortunately these keep changing so to
+ * minimise the effort involved in keeping up we put all the code to change
+ * in the one place, here. -- amrw
+ *
+ * actually, the rules have never changed, andrew just can't figure them out.
+ * -- mtr
+ */
+doincl(fp, file)
+FILE *fp; /* where #include is to be written to */
+char *file[]; /* files to be included */
+{
+ char **p;
+
+ if (mflag) {
+ /* PEPYPATH version */
+
+ (void) fprintf (fp, "#ifndef PEPYPATH\n");
+ for (p = file; *p; p++) {
+ if (is_stand(*p))
+ (void) fprintf (fp, "#include <isode/%s>\n", *p);
+ else
+ (void) fprintf (fp, "#include \"%s\"\n", pstrip(*p));
+ }
+ (void) fprintf (fp, "#else\n");
+ for (p = file; *p; p++) {
+ (void) fprintf (fp, "#include \"%s\"\n", pstrip(*p));
+ }
+ (void) fprintf (fp, "#endif\n\n");
+
+ }
+ else {
+ for (p = file; *p; p++) {
+ if (is_stand(*p))
+ (void) fprintf (fp, "#include <isode/%s>\n", *p);
+ else
+ (void) fprintf (fp, "#include \"%s\"\n", pstrip(*p));
+ }
+ }
+ (void) fprintf (fp, "\n");
+}
+
+/* standard files - that should be found in the <isode> directory */
+static char *stand_f[] = {
+ "psap.h",
+ "pepsy.h",
+ "UNIV-types.h",
+ "UNIV_defs.h",
+ "UNIV_pre_defs.h",
+
+ (char *)0 /* terminating NULL pointer */
+ };
+
+
+/*
+ * determine if the given (after stripping any path) file is a standard
+ * include file which should be in the include/isode directory.
+ * return nonzero (true) if it is.
+ */
+is_stand(file)
+char *file;
+{
+ char **p;
+ char *f = pstrip (file);
+ for (p = stand_f; *p; p++) {
+ if (strcmp(f, pstrip(*p)) == 0)
+ return (1);
+ }
+
+ return (0);
+}
+
+/* Number of different external modules that can referenced */
+#define EXTMODSIZE 50
+
+/* table of external modules we reference */
+static char *extmodtab[EXTMODSIZE];
+static int nextmod = 0; /* next free slot in external module table */
+
+/*
+ * build up a list of external modules we have referenced
+ */
+addextmod(p)
+char *p; /* name of external module */
+{
+
+ if (nextmod >= EXTMODSIZE)
+ ferr(1, "Too many external modules reference, table overflow\n");
+
+ extmodtab[nextmod++] = p;
+}
+
+/*
+ * process all the external modules collected to produce the includes
+ * required
+ */
+proc_extmod(fp)
+FILE *fp;
+{
+ char **p;
+ char *files[EXTMODSIZE + 1];
+ char *buf;
+ char *tail = "-types.h";
+ char *prefix = "pepsy/";
+ int last = 0;
+
+ if (nextmod <= 0)
+ return; /* no external definitions */
+
+ for (p = extmodtab; p < extmodtab + nextmod; p++) {
+ if (last >= EXTMODSIZE)
+ ferr(1, "proc_extmod: too many external modules\n");
+
+ buf = concat(*p, tail);
+ if (mflag || is_stand(buf)) /* need to prepend a "pepsy/" */
+ files[last++] = my_strcat(prefix, buf);
+ else
+ files[last++] = my_new_str(buf);
+ }
+ files[last++] = (char *)0;
+
+ doincl(fp, files);
+
+ /* free up this memory */
+ --last; /* don't free the NULL pointer - can core dump */
+ while (last > 0)
+ free(files[--last]);
+
+}
+
+/*
+ * allocate a yfn structure and intialise it
+ */
+YFN
+new_yfn(efn, dfn, pfn, ffn)
+char *efn, *dfn, *pfn, *ffn;
+{
+
+ register YFN fn;
+ char buf[STRSIZE];
+
+ if ((fn = (YFN) calloc (1, sizeof *fn)) == NULLYFN)
+ yyerror ("out of memory");
+
+ if (efn) {
+ if (getid(efn, buf, STRSIZE) == NULLCP)
+ yyerror("Bad Encoding function\n");
+ fn -> yfn_enc = strdup(buf);
+ free(efn);
+ }
+
+ if (dfn) {
+ if (getid(dfn, buf, STRSIZE) == NULLCP)
+ yyerror("Bad Decoding function\n");
+ fn -> yfn_dec = strdup(buf);
+ free(dfn);
+ }
+
+ if (pfn) {
+ if (getid(pfn, buf, STRSIZE) == NULLCP)
+ yyerror("Bad Printing function\n");
+ fn -> yfn_prt = strdup(buf);
+ free(pfn);
+ }
+
+ if (ffn) {
+ if (getid(ffn, buf, STRSIZE) == NULLCP)
+ yyerror("Bad Printing function\n");
+ fn -> yfn_fre = strdup(buf);
+ free(ffn);
+ }
+
+ return fn;
+}
+
+/*
+ * support routine for action_t = allocate space for it and fill it in with
+ * the given yy_action field
+ */
+Action
+new_action_t(text, lineno, num)
+char *text;
+int lineno;
+{
+ Action act;
+
+ if ((act = (Action) malloc(sizeof (action_t))) == NULLAction)
+ yyerror("out of memory\n");
+
+ act->a_data = text;
+ act->a_line = lineno;
+ act->a_num = num;
+
+ return (act);
+}
+
+/*
+ * support routine for YAL = allocate space for it and make sure it is
+ * zero'd
+ */
+YAL
+new_yal()
+{
+ YAL yal;
+
+ if ((yal = (YAL) calloc(1, sizeof (*yal))) == NULLYAL)
+ yyerror("out of memory\n");
+
+ return (yal);
+}
+YAL
+yal_join(yal1, yal2)
+YAL yal1, yal2;
+{
+ if (yal2 == NULLYAL)
+ return (yal1);
+ if (yal1 == NULLYAL)
+ return (yal2);
+
+ if (yal1->yal_enc == NULLAction && yal2->yal_enc != NULLAction)
+ yal1->yal_enc = yal2->yal_enc;
+ else if (yal1->yal_enc != NULLAction && yal2->yal_enc != NULLAction)
+ yyerror("two encoding actions in the same place\n merge into one\n");
+
+ if (yal1->yal_dec == NULLAction && yal2->yal_dec != NULLAction)
+ yal1->yal_dec = yal2->yal_dec;
+ else if (yal1->yal_dec != NULLAction && yal2->yal_dec != NULLAction)
+ yyerror("two decoding actions in the same place\n merge into one\n");
+
+ if (yal1->yal_prn == NULLAction && yal2->yal_prn != NULLAction)
+ yal1->yal_prn = yal2->yal_prn;
+ else if (yal1->yal_prn != NULLAction && yal2->yal_prn != NULLAction)
+ yyerror("two printing actions in the same place\n merge into one\n");
+
+ free((char *)yal2);
+ return (yal1);
+}
+/*
+ * join two yfn structures
+ */
+YFN
+join_yfn(fn1, fn2)
+register YFN fn1, fn2;
+{
+
+ if (fn2 == NULLYFN)
+ return (fn1);
+ if (fn1 == NULLYFN)
+ return (fn2);
+
+ if (fn1->yfn_enc == NULLCP && fn2->yfn_enc != NULLCP)
+ fn1->yfn_enc = fn2->yfn_enc;
+ else if (fn1->yfn_enc != NULLCP && fn2->yfn_enc != NULLCP)
+ yyerror("Illegal: two encoding functions for the same type\n");
+
+ if (fn1->yfn_dec == NULLCP && fn2->yfn_dec != NULLCP)
+ fn1->yfn_dec = fn2->yfn_dec;
+ else if (fn1->yfn_dec != NULLCP && fn2->yfn_dec != NULLCP)
+ yyerror("Illegal: two decoding functions for the same type\n");
+
+ if (fn1->yfn_prt == NULLCP && fn2->yfn_prt != NULLCP)
+ fn1->yfn_prt = fn2->yfn_prt;
+ else if (fn1->yfn_prt != NULLCP && fn2->yfn_prt != NULLCP)
+ yyerror("Illegal: two printing functions for the same type\n");
+
+ free((char *)fn2);
+
+ return (fn1);
+}
+
diff --git a/src/isode/pepsy/pepsy.h.gnrc b/src/isode/pepsy/pepsy.h.gnrc
new file mode 100644
index 000000000..9e0c8c430
--- /dev/null
+++ b/src/isode/pepsy/pepsy.h.gnrc
@@ -0,0 +1,342 @@
+%BEGIN(PEPSY)%
+/* pepsy.h - definitions for pepsy */
+%END(PEPSY)%
+%BEGIN(PEPY)%
+/* pepy.h - definitions for pepy */
+%END(PEPY)%
+%BEGIN(ROSY)%
+/* rosy-defs.h - definitions for rosy */
+%END(ROSY)%
+%BEGIN(MOSY)%
+/* mosy-defs.h - definitions for mosy */
+%END(MOSY)%
+/* %WARNING% */
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:31:20 eichin
+ * autoconfed isode for kerberos work
+ *
+# Revision 1.1 1994/05/31 20:40:08 eichin
+# reduced-isode release from /mit/isode/isode-subset/src
+#
+ * Revision 8.0 91/07/17 12:43:09 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+#include "psap.h"
+
+struct tuple {
+ int t_type;
+ char *t_class;
+ char *t_form;
+ char *t_id;
+ PElementClass t_classnum;
+ int t_idnum;
+};
+
+typedef struct ypv {
+ int yv_code;
+#define YV_UNDF 0x00 /* ??? */
+#define YV_NUMBER 0x01 /* LITNUMBER */
+#define YV_BOOL 0x02 /* TRUE | FALSE */
+#define YV_STRING 0x03 /* LITSTRING */
+#define YV_IDEFINED 0x04 /* ID */
+#define YV_IDLIST 0x05 /* IdentifierList */
+#define YV_VALIST 0x06 /* { Values } */
+#define YV_NULL 0x07 /* NULL */
+#define YV_ABSENT 0x08 /* WITH COMPONENTS .. ABSENT */
+#define YV_PRESENT 0x09 /* " " .. PRESENT */
+#define YV_INCLUDES 0x0a /* INCLUDES ... */
+#define YV_WITHCOMPS 0x0b /* WITH COMPONENTS */
+#define YV_OIDLIST 0x0c /* { object identifier } */
+#define YV_REAL 0x0d /* real value */
+
+ union {
+ int yv_un_number; /* code = YV_NUMBER
+ code = YV_BOOL */
+
+ double yv_un_real; /* code = YV_REAL */
+
+ char *yv_un_string; /* code = YV_STRING */
+
+ struct { /* code = YV_IDEFINED */
+ char *yv_st_module;
+ char *yv_st_modid;
+ char *yv_st_identifier;
+ } yv_st;
+
+ struct ypv *yv_un_idlist; /* code = YV_IDLIST
+ code = YV_VALIST
+ code = YV_OIDLIST */
+ } yv_un;
+#define yv_number yv_un.yv_un_number
+#define yv_string yv_un.yv_un_string
+#define yv_identifier yv_un.yv_st.yv_st_identifier
+#define yv_module yv_un.yv_st.yv_st_module
+#define yv_modid yv_un.yv_st.yv_st_modid
+#define yv_idlist yv_un.yv_un_idlist
+#define yv_real yv_un.yv_un_real
+
+ char *yv_action;
+ int yv_act_lineno;
+
+ int yv_flags;
+#define YV_NOFLAGS 0x00 /* no flags */
+#define YV_ID 0x01 /* ID Value */
+#define YV_NAMED 0x02 /* NamedNumber */
+#define YV_TYPE 0x04 /* TYPE Value */
+#define YV_BOUND 0x08 /* named value */
+#define YVBITS "\020\01ID\02NAMED\03TYPE\04BOUND"
+
+ char *yv_id; /* flags & YV_ID */
+
+ char *yv_named; /* flags & YV_NAMED */
+
+ struct ype *yv_type; /* flags & YV_TYPE */
+
+ struct ypv *yv_next;
+} ypv, *YV;
+#define NULLYV ((YV) 0)
+
+YV new_value (), add_value (), copy_value ();
+
+/* */
+
+typedef struct ypt {
+ PElementClass yt_class;
+
+ YV yt_value;
+} ypt, *YT;
+#define NULLYT ((YT) 0)
+
+YT new_tag (), copy_tag ();
+
+/* */
+
+typedef struct ype {
+ int yp_code;
+#define YP_UNDF 0x00 /* type not yet known */
+#define YP_BOOL 0x01 /* BOOLEAN */
+#define YP_INT 0x02 /* INTEGER */
+#define YP_INTLIST 0x03 /* INTEGER [ NamedNumberList ] */
+#define YP_BIT 0x04 /* BITSTRING */
+#define YP_BITLIST 0x05 /* BITSTRING [ NamedNumberList ] */
+#define YP_OCT 0x06 /* OCTETSTRING */
+#define YP_NULL 0x07 /* NULL */
+#define YP_SEQ 0x08 /* SEQUENCE */
+#define YP_SEQTYPE 0x09 /* SEQUENCE OF Type */
+#define YP_SEQLIST 0x0a /* SEQUENCE [ ElementTypes ] */
+#define YP_SET 0x0b /* SET */
+#define YP_SETTYPE 0x0c /* SET OF Type */
+#define YP_SETLIST 0x0d /* SET [ MemberTypes ] */
+#define YP_CHOICE 0x0e /* CHOICE [ AlternativeTypeList ] */
+#define YP_ANY 0x0f /* ANY */
+#define YP_OID 0x10 /* OBJECT IDENTIFIER */
+#define YP_IDEFINED 0x11 /* identifier */
+#define YP_ENUMLIST 0x12 /* ENUMERATED */
+#define YP_REAL 0x13 /* Real (floating-point) */
+
+ int yp_direction;
+#define YP_DECODER 0x01
+#define YP_ENCODER 0x02
+#define YP_PRINTER 0x04
+
+ union {
+ struct { /* code = YP_IDEFINED */
+ char *yp_st_module; /* module name */
+ OID yp_st_modid; /* module id */
+ char *yp_st_identifier; /* definition name */
+ } yp_st;
+
+ struct ype *yp_un_type; /* code = YP_SEQTYPE
+ code = YP_SEQLIST
+ code = YP_SETTYPE
+ code = YP_SETLIST
+ code = YP_CHOICE */
+
+ YV yp_un_value; /* code = YP_INTLIST
+ code = YP_BITLIST */
+ } yp_un;
+#define yp_identifier yp_un.yp_st.yp_st_identifier
+#define yp_module yp_un.yp_st.yp_st_module
+#define yp_modid yp_un.yp_st.yp_st_modid
+#define yp_type yp_un.yp_un_type
+#define yp_value yp_un.yp_un_value
+
+ char *yp_intexp; /* expressions to pass (use) as extra */
+ char *yp_strexp; /* parameters (primitive values) */
+ char yp_prfexp;
+
+ char *yp_declexp;
+ char *yp_varexp;
+
+ char *yp_structname;
+ char *yp_ptrname;
+
+ char *yp_param_type;
+
+ char *yp_action0;
+ int yp_act0_lineno;
+
+ char *yp_action05;
+ int yp_act05_lineno;
+
+ char *yp_action1;
+ int yp_act1_lineno;
+
+ char *yp_action2;
+ int yp_act2_lineno;
+
+ char *yp_action3;
+ int yp_act3_lineno;
+
+ int yp_flags;
+#define YP_NOFLAGS 0x0000 /* no flags */
+#define YP_OPTIONAL 0x0001 /* OPTIONAL */
+#define YP_COMPONENTS 0x0002 /* COMPONENTS OF */
+#define YP_IMPLICIT 0x0004 /* IMPLICIT */
+#define YP_DEFAULT 0x0008 /* DEFAULT */
+#define YP_ID 0x0010 /* ID */
+#define YP_TAG 0x0020 /* Tag */
+#define YP_BOUND 0x0040 /* ID LANGLE */
+#define YP_PULLEDUP 0x0080 /* member is a choice */
+#define YP_PARMVAL 0x0100 /* value to be passed to parm is present */
+#define YP_CONTROLLED 0x0200 /* encoding item has a controller */
+#define YP_OPTCONTROL 0x0400 /* .. */
+#define YP_ACTION1 0x0800 /* action1 acted upon */
+#define YP_PARMISOID 0x1000 /* value to be passed to parm is OID */
+#define YP_ENCRYPTED 0x2000 /* encypted - which is a bit hazy */
+#define YP_IMPORTED 0x4000 /* value imported from another module */
+#define YP_EXPORTED 0x8000 /* value exported to another module */
+#define YPBITS "\020\01OPTIONAL\02COMPONENTS\03IMPLICIT\04DEFAULT\05ID\06TAG\
+\07BOUND\010PULLEDUP\011PARMVAL\012CONTROLLED\013OPTCONTROL\
+\014ACTION1\015PARMISOID\016ENCRYPTED\017IMPORTED\020EXPORTED"
+
+ YV yp_default; /* flags & YP_DEFAULT */
+
+ char *yp_id; /* flags & YP_ID */
+
+ YT yp_tag; /* flags & YP_TAG */
+
+ char *yp_bound; /* flags & YP_BOUND */
+
+ char *yp_parm; /* flags & YP_PARMVAL */
+
+ char *yp_control; /* flags & YP_CONTROLLED */
+
+ char *yp_optcontrol; /* flags & YP_OPTCONTROL */
+
+ char *yp_offset;
+
+ struct ype *yp_next;
+} ype, *YP;
+#define NULLYP ((YP) 0)
+
+YP new_type (), add_type (), copy_type ();
+
+char *new_string ();
+
+#define TBL_EXPORT 0
+#define TBL_IMPORT 1
+#define MAX_TBLS 2
+
+extern int tagcontrol;
+#define TAG_UNKNOWN 0
+#define TAG_IMPLICIT 1
+#define TAG_EXPLICIT 2
+
+#define CH_FULLY 0
+#define CH_PARTIAL 1
+
+typedef struct yop {
+ char *yo_name;
+
+ YP yo_arg;
+ YP yo_result;
+ YV yo_errors;
+ YV yo_linked;
+
+ int yo_opcode;
+} yop, *YO;
+#define NULLYO ((YO) 0)
+
+
+typedef struct yerr {
+ char *ye_name;
+
+ YP ye_param;
+
+ int ye_errcode;
+
+ int ye_offset;
+} yerr, *YE;
+#define NULLYE ((YE) 0)
+
+/* */
+
+%BEGIN(PEPSY)%
+extern char *pepsyversion;
+%END(PEPSY)%
+%BEGIN(PEPY)%
+extern char *pepyversion;
+%END(PEPY)%
+%BEGIN(ROSY)%
+extern char *rosyversion;
+%END(ROSY)%
+%BEGIN(MOSY)%
+extern char *mosyversion;
+%END(MOSY)%
+
+extern int yysection;
+extern char *yyencpref;
+extern char *yydecpref;
+extern char *yyprfpref;
+extern char *yyencdflt;
+extern char *yydecdflt;
+extern char *yyprfdflt;
+
+extern int yydebug;
+extern int yylineno;
+
+#ifndef HPUX
+extern char yytext[];
+#else
+extern unsigned char yytext[];
+#endif
+
+extern char *mymodule;
+
+extern OID mymoduleid;
+
+extern char *bflag;
+extern int Cflag;
+extern int dflag;
+extern int Pflag;
+extern char *sysin;
+
+extern char *module_actions;
+
+OID addoid ();
+OID int2oid ();
+OID oidlookup ();
+char *oidname ();
+char *oidprint ();
+
+extern int errno;
diff --git a/src/isode/pepsy/pepsy_misc.c b/src/isode/pepsy/pepsy_misc.c
new file mode 100644
index 000000000..98edbdc61
--- /dev/null
+++ b/src/isode/pepsy/pepsy_misc.c
@@ -0,0 +1,381 @@
+/* pepy_misc.c - PE parser (yacc-based) misc routines */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:31:22 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:40:10 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:43:10 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+#include <ctype.h>
+#include <stdio.h>
+#include "pepsydefs.h"
+
+/* Oid manipulation */
+
+typedef struct oidlist {
+ OID op_oid;
+ char *op_name;
+ struct oidlist *op_next;
+} oidlist, *OP;
+#define NULLOP ((OP) 0)
+
+typedef struct symtable {
+ char *sym_name;
+ char *sym_module;
+ OID sym_oid;
+ int sym_type;
+ struct symtable *sym_next;
+} symtable, *SYM;
+#define NULLSYM ((SYM)0)
+
+
+static OP myoids;
+static SYM symtab[MAX_TBLS];
+
+
+OID addoid (o1, o2)
+OID o1, o2;
+{
+ OID noid;
+
+ if (o1 == NULLOID || o2 == NULLOID)
+ return NULLOID;
+
+ noid = (OID) calloc (1, sizeof(*noid));
+ if (noid == NULLOID)
+ myyerror ("out of memory (%d needed)", sizeof(*noid));
+
+ noid -> oid_nelem = o1->oid_nelem + o2->oid_nelem;
+ noid -> oid_elements = (unsigned int *) calloc ((unsigned)noid->oid_nelem,
+ sizeof(unsigned int));
+ if (noid -> oid_elements == NULL)
+ myyerror ("out of memory (%d needed)", noid->oid_nelem);
+
+ bcopy ((char *)o1->oid_elements, (char *)noid->oid_elements,
+ o1->oid_nelem * sizeof(unsigned int));
+ bcopy ((char *)o2 -> oid_elements,
+ (char *) &noid -> oid_elements[o1->oid_nelem],
+ o2 -> oid_nelem * sizeof(unsigned int));
+ return noid;
+}
+
+defineoid (name, oid)
+char *name;
+OID oid;
+{
+ register char *p;
+ register OP op;
+
+ if (oid == NULLOID) {
+ myyerror ("Warning Null oid in defineoid");
+ return;
+ }
+ for (op = myoids; op; op = op -> op_next)
+ if (strcmp (op -> op_name, name) == 0) {
+ if (oid_cmp(op->op_oid, oid) != 0) {
+ p = new_string(sprintoid (oid));
+ warning ("OID name clash %s => %s & %s",
+ name, p, sprintoid(op->op_oid));
+ free (p);
+ }
+ else
+ return;
+ }
+ op = (OP) calloc (1, sizeof *op);
+ if (op == NULLOP)
+ myyerror ("out of memory (%d needed)", sizeof(*op));
+ op -> op_oid = oid_cpy(oid);
+ op -> op_name = new_string (name);
+ op -> op_next = myoids;
+ myoids = op;
+}
+
+OID oidlookup (name)
+char *name;
+{
+ OP op;
+
+ for (op = myoids; op; op = op -> op_next)
+ if (strcmp ( name, op->op_name) == 0)
+ return oid_cpy(op -> op_oid);
+
+ warning ("unknown Object Identifier '%s'", name);
+ return NULLOID;
+}
+
+char *oidname (oid)
+OID oid;
+{
+ OP op;
+
+ for (op = myoids; op; op = op -> op_next)
+ if (oid_cmp (op->op_oid, oid) == 0)
+ return op -> op_name;
+
+ return NULLCP;
+}
+
+OID int2oid (n)
+int n;
+{
+ OID noid;
+
+ noid = (OID) calloc(1, sizeof(*noid));
+ if (noid == NULLOID)
+ myyerror ("out of memory (%d needed)", sizeof *noid);
+
+ noid -> oid_elements = (unsigned int *) calloc (1, sizeof(unsigned int));
+ if (noid -> oid_elements == NULL)
+ myyerror ("out of memory (%d needed)", sizeof(unsigned int));
+ noid -> oid_nelem = 1;
+ noid -> oid_elements[0] = n;
+ return noid;
+}
+
+/* */
+
+addtable (name, lt, typ)
+char *name;
+int lt;
+int typ; /* Does it allow implicit's to work or not */
+{
+ SYM sp;
+
+ sp = (SYM)calloc (1, sizeof *sp);
+ sp -> sym_name = new_string (name);
+ sp -> sym_next = symtab[lt];
+ sp -> sym_type = typ;
+ symtab[lt] = sp;
+}
+
+addtableref (name, id, lt)
+char *name;
+OID id;
+int lt;
+{
+ SYM sp;
+ char *nm;
+ OID oid;
+
+ nm = name ? new_string (name) : NULLCP;
+ oid = id ? oid_cpy (id) : NULLOID;
+
+ for (sp = symtab[lt]; sp; sp = sp -> sym_next)
+ if (sp -> sym_module == NULLCP && sp -> sym_oid == NULLOID)
+ {
+ sp -> sym_module = nm;
+ sp -> sym_oid = oid;
+ }
+}
+
+print_expimp ()
+{
+ SYM sp;
+ int ind;
+ OID oid;
+ char *p;
+
+ if (sp = symtab[TBL_EXPORT])
+ (void) printf ("\nEXPORTS\n");
+
+ for (ind = 0; sp; sp = sp->sym_next) {
+ if (ind == 0) {
+ (void) putchar('\t');
+ ind = 8;
+ }
+ (void) printf("%s", sp -> sym_name);
+ ind += strlen (sp -> sym_name);
+ if (sp -> sym_next){
+ (void) putchar (',');
+ ind ++;
+ }
+ else
+ (void) putchar (';');
+ if (ind > 72) {
+ (void) putchar ('\n');
+ ind = 0;
+ }
+ else {
+ (void) putchar (' ');
+ ind ++;
+ }
+ }
+ (void) putchar ('\n');
+
+ if (sp = symtab[TBL_IMPORT]) {
+ (void) printf ("\nIMPORTS\n");
+ p = sp -> sym_module;
+ oid = sp -> sym_oid;
+ }
+ for (ind = 0; sp; sp = sp -> sym_next) {
+ if (ind == 0) {
+ (void) putchar ('\t');
+ ind = 8;
+ }
+ (void) printf ("%s", sp -> sym_name);
+ ind += strlen (sp -> sym_name);
+ if (sp -> sym_next) {
+ if (strcmp (p, sp -> sym_next -> sym_module) == 0) {
+ (void) putchar (',');
+ ind ++;
+ if ( ind > 72) {
+ (void) putchar ('\n');
+ ind = 0;
+ }
+ else {
+ (void) putchar (' ');
+ ind ++;
+ }
+ }
+ else {
+ if (ind != 8)
+ (void) printf ("\n\t\t");
+ else
+ (void) putchar ('\t');
+ (void) printf ("FROM %s", p);
+ if (oid)
+ (void) printf (" %s", oidprint (oid));
+ (void) printf ("\n\t");
+ ind = 8;
+ p = sp -> sym_next -> sym_module;
+ oid = sp -> sym_next -> sym_oid;
+ }
+ }
+ else {
+ if (ind != 8)
+ (void) printf ("\n\t\t");
+ else
+ (void) putchar ('\t');
+ (void) printf ("FROM %s", p);
+ if (oid)
+ (void) printf (" %s", oidprint (oid));
+ (void) printf (";\n");
+ }
+ }
+}
+
+check_impexp (yp)
+YP yp;
+{
+ SYM sp;
+
+ for (sp = symtab[TBL_EXPORT]; sp; sp = sp->sym_next)
+ if (strcmp (sp -> sym_name, yp -> yp_identifier) == 0)
+ {
+ yp -> yp_flags |= YP_EXPORTED;
+ break;
+ }
+
+ for (sp = symtab[TBL_IMPORT]; sp; sp = sp -> sym_next)
+ if (strcmp (sp -> sym_name, yp -> yp_identifier) == 0) {
+ if (yp->yp_flags & YP_EXPORTED)
+ myyerror ("Warning: %s imported & exported!", yp->yp_identifier);
+ yp -> yp_module = sp -> sym_module;
+ yp -> yp_modid = sp -> sym_oid;
+/* yp -> yp_flags |= YP_IMPORTED; */
+ }
+}
+static struct oidtbl {
+ char *oid_name;
+ int oid_value;
+} oidtable[] = {
+ /* Top level OIDS */
+ "ccitt", 0,
+ "iso", 1,
+ "joint-iso-ccitt", 2,
+
+ NULL,
+};
+
+initoidtbl ()
+{
+ struct oidtbl *op;
+ OID oid;
+
+ for (op = oidtable; op -> oid_name; op++) {
+ defineoid (op->oid_name, oid = int2oid(op->oid_value));
+ oid_free (oid);
+ }
+}
+
+char *oidprint (oid)
+OID oid;
+{
+ static char buf[BUFSIZ];
+ char *cp;
+ char *p;
+ OID o2;
+ unsigned int *ip;
+ int i;
+
+ if (oid == NULLOID)
+ return "";
+
+ (void) strcpy (buf, "{ ");
+ cp = buf + strlen(buf);
+
+ i = oid->oid_nelem;
+ ip = oid->oid_elements;
+
+ p = oidname (o2 = int2oid((int)*ip));
+ oid_free (o2);
+ if (p) {
+ i --;
+ ip ++;
+ (void) sprintf (cp, "%s ", p);
+ cp += strlen(cp);
+ }
+
+ for (; i > 0; i--) {
+ (void) sprintf (cp, "%d ", *ip++);
+ cp += strlen (cp);
+ }
+
+ (void) strcat (cp, " }");
+ return buf;
+}
+
+/*
+ * look at import list and return any clue found as to handling implicit tags
+ * on that type
+ */
+chkil(id)
+char *id;
+{
+ SYM sy;
+
+ for (sy = symtab[TBL_IMPORT]; sy; sy = sy->sym_next)
+ if (strcmp(sy->sym_name, id) == 0)
+ break;
+ if (sy)
+ return (sy->sym_type);
+
+ return (ER_UNKNOWN);
+
+}
diff --git a/src/isode/pepsy/pepsy_str.c b/src/isode/pepsy/pepsy_str.c
new file mode 100644
index 000000000..58bd5b85d
--- /dev/null
+++ b/src/isode/pepsy/pepsy_str.c
@@ -0,0 +1,61 @@
+/* pepy_strings.c - constant strings used in pepy */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:31:23 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:40:12 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:43:12 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+char *pepy_strings[] = {
+ "bad ", /* PEPY_ERR_BAD */
+ "bad bitstring: ", /* PEPY_ERR_BAD_BITS */
+ "bad boolean: ", /* PEPY_ERR_BAD_BOOLEAN */
+ "bad class/id: ", /* PEPY_ERR_BAD_CLASS */
+ "bad class/form/id: ", /* PEPY_ERR_BAD_CLASS_FORM_ID */
+ "bad form ", /* PEPY_ERR_BAD_FORM */
+ "bad integer: ", /* PEPY_ERR_BAD_INTEGER */
+ "bad object identifier: ", /* PEPY_ERR_BAD_OID */
+ "bad octetstring: ", /* PEPY_ERR_BAD_OCTET */
+ "bad real: ", /* PEPY_ERR_BAD_REAL */
+ "bad sequence: ", /* PEPY_ERR_BAD_SEQ */
+ "bad set: ", /* PEPY_ERR_BAD_SET */
+ "has too many bits", /* PEPY_ERR_TOO_MANY_BITS */
+ "has too many elements", /* PEPY_ERR_TOO_MANY_ELEMENTS */
+ "has unknown choice: ", /* PEPY_ERR_UNKNOWN_CHOICE */
+ "has unknown component: ", /* PEPY_ERR_UNK_COMP */
+ "initialization fails", /* PEPY_ERR_INIT_FAILED */
+ "invalid choice selected: ", /* PEPY_ERR_INVALID_CHOICE */
+ "missing ", /* PEPY_ERR_MISSING */
+ "out of memory", /* PEPY_ERR_NOMEM */
+ "too many elements for tagged ", /* PEPY_ERR_TOO_MANY_TAGGED */
+ "warning: extra or duplicate members present in SET",
+ /* PEPY_ERR_EXTRA_MEMBERS */
+ (char *)0
+};
+
+
diff --git a/src/isode/pepsy/pepsydefs.h.gnrc b/src/isode/pepsy/pepsydefs.h.gnrc
new file mode 100644
index 000000000..119bdd8d7
--- /dev/null
+++ b/src/isode/pepsy/pepsydefs.h.gnrc
@@ -0,0 +1,422 @@
+%BEGIN(PEPSY)%
+/* pepsydefs.h - definitions for pepsy */
+%END(PEPSY)%
+%BEGIN(PEPY)%
+/* pepy.h - definitions for pepy */
+%END(PEPY)%
+%BEGIN(ROSY)%
+/* rosy-defs.h - definitions for rosy */
+%END(ROSY)%
+%BEGIN(MOSY)%
+/* mosy-defs.h - definitions for mosy */
+%END(MOSY)%
+/* %WARNING% */
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:31:25 eichin
+ * autoconfed isode for kerberos work
+ *
+# Revision 1.2 1994/06/07 04:06:25 eichin
+# yytext is char* under mips too
+#
+# Revision 1.1 1994/05/31 20:40:17 eichin
+# reduced-isode release from /mit/isode/isode-subset/src
+#
+ * Revision 8.0 91/07/17 12:43:12 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+#include "psap.h"
+
+struct tuple {
+ int t_type;
+ char *t_class;
+ char *t_form;
+ char *t_id;
+ PElementClass t_classnum;
+ int t_idnum;
+};
+
+typedef struct ypv {
+ int yv_code;
+#define YV_UNDF 0x00 /* ??? */
+#define YV_NUMBER 0x01 /* LITNUMBER */
+#define YV_BOOL 0x02 /* TRUE | FALSE */
+#define YV_STRING 0x03 /* LITSTRING */
+#define YV_IDEFINED 0x04 /* ID */
+#define YV_IDLIST 0x05 /* IdentifierList */
+#define YV_VALIST 0x06 /* { Values } */
+#define YV_NULL 0x07 /* NULL */
+#define YV_ABSENT 0x08 /* WITH COMPONENTS .. ABSENT */
+#define YV_PRESENT 0x09 /* " " .. PRESENT */
+#define YV_INCLUDES 0x0a /* INCLUDES ... */
+#define YV_WITHCOMPS 0x0b /* WITH COMPONENTS */
+#define YV_OIDLIST 0x0c /* { object identifier } */
+#define YV_REAL 0x0d /* real value */
+#define YV_HSTRING 0x0e /* Hex String */
+#define YV_BSTRING 0x0f /* Bit String */
+
+ union {
+ int yv_un_number; /* code = YV_NUMBER
+ code = YV_BOOL */
+
+ double yv_un_real; /* code = YV_REAL */
+
+ char *yv_un_string; /* code = YV_STRING */
+
+ struct { /* code = YV_IDEFINED */
+ char *yv_st_module;
+ char *yv_st_modid;
+ char *yv_st_identifier;
+ } yv_st;
+
+ struct ypv *yv_un_idlist; /* code = YV_IDLIST
+ code = YV_VALIST
+ code = YV_OIDLIST */
+
+ struct {
+ char *yv_sl_xstring;
+ int yv_sl_xlength;
+ } yv_sl; /* code = YV_HSTRING
+ code = YV_BSTRING */
+ } yv_un;
+#define yv_number yv_un.yv_un_number
+#define yv_string yv_un.yv_un_string
+#define yv_identifier yv_un.yv_st.yv_st_identifier
+#define yv_module yv_un.yv_st.yv_st_module
+#define yv_modid yv_un.yv_st.yv_st_modid
+#define yv_idlist yv_un.yv_un_idlist
+#define yv_real yv_un.yv_un_real
+#define yv_xstring yv_un.yv_sl.yv_sl_xstring
+#define yv_xlength yv_un.yv_sl.yv_sl_xlength
+
+ char *yv_action;
+ int yv_act_lineno;
+
+ int yv_flags;
+#define YV_NOFLAGS 0x00 /* no flags */
+#define YV_ID 0x01 /* ID Value */
+#define YV_NAMED 0x02 /* NamedNumber */
+#define YV_TYPE 0x04 /* TYPE Value */
+#define YV_BOUND 0x08 /* named value */
+#define YVBITS "\020\01ID\02NAMED\03TYPE\04BOUND"
+
+ char *yv_id; /* flags & YV_ID */
+
+ char *yv_named; /* flags & YV_NAMED */
+
+ struct ype *yv_type; /* flags & YV_TYPE */
+
+ struct ypv *yv_next;
+} ypv, *YV;
+#define NULLYV ((YV) 0)
+
+YV new_value (), add_value (), copy_value ();
+
+/* */
+
+typedef struct ypt {
+ PElementClass yt_class;
+
+ YV yt_value;
+} ypt, *YT;
+#define NULLYT ((YT) 0)
+
+YT new_tag (), copy_tag ();
+
+%BEGIN(PEPSY)%
+/* Encoding functions definitions */
+typedef struct yfn {
+ char *yfn_enc; /* Encoding function name */
+ char *yfn_dec; /* Decoding function name */
+ char *yfn_prt; /* Printing function name */
+ char *yfn_fre; /* Freeing function name */
+} yfn, *YFN;
+
+#define NULLYFN ((YFN) 0)
+
+extern YFN new_yfn(), join_yfn();
+
+typedef struct action_t {
+ char *a_data; /* actual C text of action statement */
+ int a_line; /* line number of input we came from */
+ int a_num; /* number for case statement */
+} action_t, *Action;
+#define NULLAction ((Action)0)
+
+extern Action new_action_t();
+
+typedef struct yactlist {
+ Action yal_enc;
+ Action yal_dec;
+ Action yal_prn;
+ char *yal_comment; /* A comment as to where the line comes from */
+ char *yal_type; /* the C type of the parm used in this action */
+} yactlist_t, *YAL;
+#define NULLYAL ((YAL)0)
+
+extern YAL new_yal(), yal_join();
+
+extern Action start_action, final_action;
+
+extern int e_actions, d_actions, p_actions;
+
+#define ER_UNKNOWN 0 /* Unknown what the type is - warn if used */
+#define ER_NORMAL 1 /* Implicit works normally */
+#define ER_EXPLICIT 2 /* Implicit should be translated to explicit */
+
+
+%END(PEPSY)%
+
+/* */
+
+typedef struct ype {
+ int yp_code;
+#define YP_UNDF 0x00 /* type not yet known */
+#define YP_BOOL 0x01 /* BOOLEAN */
+#define YP_INT 0x02 /* INTEGER */
+#define YP_INTLIST 0x03 /* INTEGER [ NamedNumberList ] */
+#define YP_BIT 0x04 /* BITSTRING */
+#define YP_BITLIST 0x05 /* BITSTRING [ NamedNumberList ] */
+#define YP_OCT 0x06 /* OCTETSTRING */
+#define YP_NULL 0x07 /* NULL */
+#define YP_SEQ 0x08 /* SEQUENCE */
+#define YP_SEQTYPE 0x09 /* SEQUENCE OF Type */
+#define YP_SEQLIST 0x0a /* SEQUENCE [ ElementTypes ] */
+#define YP_SET 0x0b /* SET */
+#define YP_SETTYPE 0x0c /* SET OF Type */
+#define YP_SETLIST 0x0d /* SET [ MemberTypes ] */
+#define YP_CHOICE 0x0e /* CHOICE [ AlternativeTypeList ] */
+#define YP_ANY 0x0f /* ANY */
+#define YP_OID 0x10 /* OBJECT IDENTIFIER */
+#define YP_IDEFINED 0x11 /* identifier */
+#define YP_ENUMLIST 0x12 /* ENUMERATED */
+#define YP_REAL 0x13 /* Real (floating-point) */
+#define YP_IMPTYPE 0x14 /* Imported - real type unknown */
+
+ int yp_direction;
+#define YP_DECODER 0x01
+#define YP_ENCODER 0x02
+#define YP_PRINTER 0x04
+
+ union {
+ struct { /* code = YP_IDEFINED */
+ char *yp_st_module; /* module name */
+ OID yp_st_modid; /* module id */
+ char *yp_st_identifier; /* definition name */
+ } yp_st;
+
+ struct ype *yp_un_type; /* code = YP_SEQTYPE
+ code = YP_SEQLIST
+ code = YP_SETTYPE
+ code = YP_SETLIST
+ code = YP_CHOICE */
+
+ YV yp_un_value; /* code = YP_INTLIST
+ code = YP_BITLIST */
+ } yp_un;
+#define yp_identifier yp_un.yp_st.yp_st_identifier
+#define yp_module yp_un.yp_st.yp_st_module
+#define yp_modid yp_un.yp_st.yp_st_modid
+#define yp_type yp_un.yp_un_type
+#define yp_value yp_un.yp_un_value
+
+ char *yp_intexp; /* expressions to pass (use) as extra */
+ char *yp_strexp; /* parameters (primitive values) */
+ char yp_prfexp;
+
+ char *yp_declexp;
+ char *yp_varexp;
+
+ char *yp_structname;
+ char *yp_ptrname;
+
+ char *yp_param_type;
+
+ char *yp_action0;
+ int yp_act0_lineno;
+
+ char *yp_action05;
+ int yp_act05_lineno;
+
+ char *yp_action1;
+ int yp_act1_lineno;
+
+ char *yp_action2;
+ int yp_act2_lineno;
+
+ char *yp_action3;
+ int yp_act3_lineno;
+
+ int yp_flags;
+#define YP_NOFLAGS 0x0000 /* no flags */
+#define YP_OPTIONAL 0x0001 /* OPTIONAL */
+#define YP_COMPONENTS 0x0002 /* COMPONENTS OF */
+#define YP_IMPLICIT 0x0004 /* IMPLICIT */
+#define YP_DEFAULT 0x0008 /* DEFAULT */
+#define YP_ID 0x0010 /* ID */
+#define YP_TAG 0x0020 /* Tag */
+#define YP_BOUND 0x0040 /* ID LANGLE */
+#define YP_PULLEDUP 0x0080 /* member is a choice */
+#define YP_PARMVAL 0x0100 /* value to be passed to parm is present */
+#define YP_CONTROLLED 0x0200 /* encoding item has a controller */
+#define YP_OPTCONTROL 0x0400 /* .. */
+#define YP_ACTION1 0x0800 /* action1 acted upon */
+#define YP_PARMISOID 0x1000 /* value to be passed to parm is OID */
+#define YP_ENCRYPTED 0x2000 /* encypted - which is a bit hazy */
+#define YP_IMPORTED 0x4000 /* value imported from another module */
+#define YP_EXPORTED 0x8000 /* value exported to another module */
+#define YP_WANTIMPLICIT 0x10000 /* Keep the implicit tag */
+#define YPBITS "\020\01OPTIONAL\02COMPONENTS\03IMPLICIT\04DEFAULT\05ID\06TAG\
+\07BOUND\010PULLEDUP\011PARMVAL\012CONTROLLED\013OPTCONTROL\
+\014ACTION1\015PARMISOID\016ENCRYPTED\017IMPORTED\020EXPORTED"
+
+ YV yp_default; /* flags & YP_DEFAULT */
+
+ char *yp_id; /* flags & YP_ID */
+
+ YT yp_tag; /* flags & YP_TAG */
+
+ char *yp_bound; /* flags & YP_BOUND */
+
+ char *yp_parm; /* flags & YP_PARMVAL */
+
+ char *yp_control; /* flags & YP_CONTROLLED */
+
+ char *yp_optcontrol; /* flags & YP_OPTCONTROL */
+
+ char *yp_offset;
+
+ struct ype *yp_next;
+
+%BEGIN(PEPSY)%
+ YFN yp_yfn; /* encoding/decoding functions */
+
+ YAL yp_bef_alist; /* list of before this */
+ YAL yp_aft_alist; /* list of after this */
+
+ YAL yp_control_act; /* controlled actions */
+ YAL yp_optional_act; /* optional actions */
+%END(PEPSY)%
+
+ int yp_lineno; /* line number for diagnostics */
+
+} ype, *YP;
+#define NULLYP ((YP) 0)
+
+YP new_type (), add_type (), copy_type (), lkup();
+
+char *new_string ();
+
+#define TBL_EXPORT 0
+#define TBL_IMPORT 1
+#define MAX_TBLS 2
+
+extern int tagcontrol;
+#define TAG_UNKNOWN 0
+#define TAG_IMPLICIT 1
+#define TAG_EXPLICIT 2
+
+#define CH_FULLY 0
+#define CH_PARTIAL 1
+
+typedef struct yop {
+ char *yo_name;
+
+ YP yo_arg;
+ YP yo_result;
+ YV yo_errors;
+ YV yo_linked;
+
+ int yo_opcode;
+} yop, *YO;
+#define NULLYO ((YO) 0)
+
+
+typedef struct yerr {
+ char *ye_name;
+
+ YP ye_param;
+
+ int ye_errcode;
+
+ int ye_offset;
+} yerr, *YE;
+#define NULLYE ((YE) 0)
+
+typedef struct modlist {
+ char *md_module;
+ OID md_oid;
+ int md_flags;
+#define MDF_SEEN 1 /* Seen this module */
+
+ struct modlist *md_next;
+} modlist, *MD;
+#define NULLMD ((MD) 0)
+
+/* */
+
+%BEGIN(PEPSY)%
+extern char *pepsyversion;
+%END(PEPSY)%
+%BEGIN(PEPY)%
+extern char *pepyversion;
+%END(PEPY)%
+
+extern int yysection;
+extern char *yyencpref;
+extern char *yydecpref;
+extern char *yyprfpref;
+extern char *yyencdflt;
+extern char *yydecdflt;
+extern char *yyprfdflt;
+
+extern int yydebug;
+extern int yylineno;
+
+#if defined(linux) || defined(mips)
+extern char *yytext;
+#else
+#ifndef HPUX
+extern char yytext[];
+#else
+extern unsigned char yytext[];
+#endif
+#endif
+
+extern char *mymodule;
+
+extern OID mymoduleid;
+
+extern char *bflag;
+extern int Cflag;
+extern int dflag;
+extern int Pflag;
+extern char *sysin;
+
+extern char *module_actions;
+
+OID addoid ();
+OID int2oid ();
+OID oidlookup ();
+char *oidname ();
+char *oidprint ();
+
+extern int errno;
diff --git a/src/isode/pepsy/pepy-refs.h b/src/isode/pepsy/pepy-refs.h
new file mode 100644
index 000000000..d4b78eb5a
--- /dev/null
+++ b/src/isode/pepsy/pepy-refs.h
@@ -0,0 +1,146 @@
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:31:27 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:40:22 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:43:13 isode
+ * Release 7.0
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+/*
+ * data structure(s) for module T3 (t3.py)
+ */
+
+/* bits to use for optional fields */
+#define OPT_REAL1 0
+#define OPT_INT1 1
+#define OPT_INT2 2
+#define OPT_ENUM1 3
+#define OPT_ENUM2 4
+#define OPT_BOOL1 5
+#define OPT_BOOL2 6
+#define OPT_REAL2 7
+#define NUMOPT 8
+
+struct pepy_refs {
+ integer t_int;
+ integer t_enum;
+ struct qbuf *t_qbuf;
+ char *t_string;
+ char *t_ostring;
+ char *t_bstring;
+ int t_blen;
+ int t_olen;
+ char t_bool;
+ double t_real;
+ OID t_oid;
+ PE t_pe;
+ PE t_any;
+ struct pepy_refs1 *t_def;
+ struct pepy_refs1 *t_opt;
+ char opt_set[NBITS2NCHARS(NUMOPT)]
+ };
+
+struct pepy_refs1 {
+ integer t_int;
+ integer t_int1;
+ integer t_enum;
+ integer t_enum1;
+ struct qbuf *t_qbuf;
+ struct qbuf *t_qbuf1;
+ char *t_string;
+ char *t_string1;
+ char *t_ostring;
+ char *t_ostring1;
+ char *t_bstring;
+ int t_blen;
+ char *t_bstring1;
+ int t_blen1;
+ int t_olen;
+ int t_olen1;
+ char t_bool;
+ char t_bool1;
+ double t_real;
+ double t_real1;
+ OID t_oid;
+ OID t_oid1;
+ PE t_pe;
+ PE t_pe1;
+ PE t_any;
+ char opt_set[NBITS2NCHARS(NUMOPT)]
+ };
+
+struct rep_elem {
+ int r_int;
+ char *r_ostring;
+ char *r_bstring;
+ struct rep_elem *r_next;
+ };
+#define NULLREP_ELEM (struct rep_elem *)0
+
+struct rep_int {
+ int i;
+ struct rep_int *r;
+ };
+#define NULLREP_INT (struct rep_int *)0
+
+
+struct repeats {
+ struct rep_int *rp_sq1; /* SEQUECE of INTEGER */
+ struct rep_elem *rp_sq2; /* SEQUENCE OF Rep-elem */
+ struct rep_int *rp_st1; /* SET OF INTEGER */
+ struct rep_elem *rp_st2; /* SET OF Rep-elem */
+
+ int rp_choice;
+#define RP_INT 1 /* INTEGER */
+#define RP_BOOL 2 /* BOOLEAN */
+#define RP_OSTRING 3 /* OCTET STRING */
+ int rp_int; /* integer or boolean */
+ char rp_bool; /* integer or boolean */
+ char *rp_ostring;
+};
+
+#define CD_INT 0
+#define CD_C 1
+#define CD_D 2
+#define NCD_OPT 3
+
+struct codedata {
+ PE cd_a;
+ PE cd_b;
+ PE cd_c;
+ PE cd_d;
+ integer cd_int;
+ integer cd_int1;
+ integer cd_int2;
+ char *cd_string;
+ char *cd_string1;
+ char *cd_string2;
+ struct codedata *cd_left;
+ struct codedata *cd_right;
+ char cd_opt_set[NBITS2NCHARS(NCD_OPT)];
+ char cd_bool;
+ double cd_real;
+ OID cd_oid;
+ OID cd_oid1;
+ OID cd_oid2;
+ PE cd_bit;
+};
+
diff --git a/src/isode/pepsy/prnt.c b/src/isode/pepsy/prnt.c
new file mode 100644
index 000000000..9c23b6c46
--- /dev/null
+++ b/src/isode/pepsy/prnt.c
@@ -0,0 +1,1740 @@
+/* prnt.c */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:31:29 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:40:23 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:43:13 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include <ctype.h>
+#include <varargs.h>
+#include "pepsy-driver.h"
+#include "psap.h"
+#include "pepsy.h"
+#include "tailor.h"
+
+#define PRINT_TYPES 0
+#define CHOICE_PUSH
+
+
+extern PE p_setpresent();
+extern IFP vfnx;
+extern FILE *vfp;
+
+extern ptpe *next_ptpe();
+extern int pepsylose ();
+
+int xlevel = 0;
+int tabed = 0;
+int xpushed = 0;
+
+#define NEXT_PTPE(p) (p = next_ptpe(p))
+#define CHKTAG(mod, p, pe) p_ismatch(p, mod, pe->pe_class, pe->pe_id)
+
+static int p_pr_obj();
+static int p_pr_type();
+static int p_pr_seq();
+static int p_pr_set();
+static int p_pr_seqof();
+static int p_pr_setof();
+static int p_pr_choice();
+static int p_pr_etype();
+
+/* SUPPRESS 36 *//* for Saber C */
+
+/*
+ * to guarentee the rules that vname and a vprint-type routine are called
+ * alternatively. Basically can't have two vname's in a row
+ */
+static vnamelock = 0;
+ /* if vnamelock > 0 don't call vname */
+#define VNAME(x) if (vnamelock++ <= 0) vname(x); else
+#define VTAG(class, tag) if (vnamelock++ <= 0) \
+ vtag((int )class, (int )tag); else
+
+/* as vprint takes a variable number of arguements we have to put all of
+ * the arguements inside () and remove them when we expand to vprint
+ */
+#define VPRINT(x) vnamelock = 0, vprint x
+#define VSTRING(x) vnamelock = 0, vstring(x)
+#define VUNKNOWN(x) vnamelock = 0, vunknown(x)
+#define VPUSH vnamelock = 0, vpush
+#define VPOP vnamelock = 0, vpop
+
+
+/*
+ * Print out ASN data given in pe using the information given in the tables
+ */
+prnt_f(typ, mod, pe, explicit, len, buf)
+/* ARGSUSED */
+int typ; /* which type it is */
+modtyp *mod; /* ASN Module it is from */
+PE pe;
+int explicit; /* nonzero means we are call top level
+ * print final \n
+ */
+int *len;
+char **buf;
+{
+ ptpe *p;
+
+ if (typ < 0 || typ >= mod->md_nentries) {
+ return (ppepsylose (mod, NULLPTPE, pe, "prnt_f:Illegal type %d\n",typ));
+ }
+
+ p = mod->md_ptab[typ];
+
+ if (p->pe_type != PE_START) {
+ return (ppepsylose (mod, p, pe, "prnt_f: missing PE_START\n"));
+ }
+
+#if EXTRA_BRACKETS
+ if (explicit) {
+ if (p->pe_typename)
+ VNAME(*p->pe_typename);
+ }
+ VPUSH();
+#endif
+
+
+ if (p_pr_obj(explicit, pe, p, mod) == NOTOK) {
+#if EXTRA_BRACKETS
+ VPOP();
+#endif
+ return (NOTOK);
+ }
+#if EXTRA_BRACKETS
+ VPOP();
+#endif
+ return (OK);
+}
+
+/*
+ * Parse an object. The top level of an object does not have any
+ * offset field which makes it different to pr_type routine which
+ * must assume that it has an offset.
+ */
+static int
+p_pr_obj(expl, pe, p, mod)
+int expl; /* do we look at the tag */
+PE pe;
+ptpe *p;
+modtyp *mod; /* Module it is from */
+{
+ int cnt = 0;
+
+#if PRINT_TYPES
+ if (p->pe_typename)
+ VNAME(*p->pe_typename);
+#endif
+
+ p++;
+ while (p->pe_type != PE_END) {
+
+ if (ISDTYPE(p) && expl && CHKTAG(mod, p, pe) == 0) {
+ if (DEFAULT(p)) {
+ return (ppepsylose (mod, p, pe,
+ "p_pr_obj:Default not implemented\n"));
+ }
+ else if (OPTIONAL(p))
+ return (NO_DATA_USED);
+ else {
+ return (ppepsylose (mod, p, pe,
+ "p_pr_obj:missing mandatory parameter", p, mod));
+ }
+ }
+ if (p->pe_typename)
+ VNAME(*p->pe_typename);
+ switch (p->pe_type) {
+ case PE_END:
+ case PE_START:
+ goto bad;
+
+ case UCODE:
+ if (mod->md_pucode == NULLIFP
+ || (*mod->md_pucode) (pe, p) == NOTOK)
+ goto bad;
+ break;
+
+
+ default:
+ if (p_pr_type(expl, pe, p, mod) == NOTOK)
+ goto bad;
+ break;
+ }
+ if (ISDTYPE(p) && cnt > 0)
+ return (ppepsylose (mod, p, pe, "p_pr_obj:compound type found\n"));
+ if (ISDTYPE(p) && pe != NULLPE) {
+ return (OK);
+ }
+ if (NEXT_PTPE(p) == NULLPTPE)
+ goto bad;
+ }
+
+ return (OK);
+
+bad:
+ return (NOTOK);
+}
+
+
+/*
+ * Parse a single type. If a basic type parse it, if a compound type
+ * call the appropriate parsing routine
+ */
+static int
+p_pr_type(expl, pe, p, mod)
+int expl; /* do we look at the tag */
+PE pe;
+ptpe *p;
+modtyp *mod; /* Module it is from */
+{
+ int cnt = 0;
+ integer i;
+ OID oid;
+
+
+ while (p->pe_type != PE_END) {
+
+ if (ISDTYPE(p) && expl && CHKTAG(mod, p, pe) == 0) {
+ if (DEFAULT(p)) {
+#ifdef PRINT_DEFAULTS
+ setpval(p, p + 1, mod);
+#endif
+ return (OK);
+ } else if (OPTIONAL(p))
+ return (OK);
+ else {
+ dmp_ptpe("p_pr_type:missing mandatory parameter", p, mod);
+ goto bad;
+ }
+ }
+ switch (p->pe_type) {
+ case PE_END:
+ case PE_START:
+ goto bad;
+
+ case BOPTIONAL:
+ if (CHKTAG(mod, p + 1, pe) == 0) {
+ return (OK);
+ }
+ p++;
+ continue;
+
+ case UCODE:
+ if (mod->md_pucode == NULLIFP
+ || (*mod->md_pucode) (pe, p) == NOTOK)
+ goto bad;
+ break;
+
+ case ETAG:
+ switch (p->pe_ucode) {
+ default:
+ if (p_pr_etype(pe->pe_cons, p, mod) == NOTOK)
+ goto bad;
+ }
+ break;
+
+ case SSEQ_START:
+ case SEQ_START:
+ if (p_pr_seq(pe, p, mod) == NOTOK) {
+ goto bad;
+ }
+ break;
+
+ case SSEQOF_START:
+ case SEQOF_START:
+ if (p_pr_seqof(pe, p, mod) == NOTOK) {
+ goto bad;
+ }
+ break;
+
+ case SSET_START:
+ case SET_START:
+ if (p_pr_set(pe, p, mod) == NOTOK) {
+ goto bad;
+ }
+ break;
+
+ case SSETOF_START:
+ case SETOF_START:
+ if (p_pr_setof(pe, p, mod) == NOTOK) {
+ goto bad;
+ }
+ break;
+
+ case IMP_OBJ:
+ p++;
+ if (p->pe_type == EXTOBJ || p->pe_type == SEXTOBJ) {
+ if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP,
+ (char **) 0) == NOTOK)
+ goto bad;
+ } else {
+ if (p_pr_obj(0, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK) {
+ goto bad;
+ }
+ }
+ break;
+
+ case SOBJECT:
+ case OBJECT:
+ if (p_pr_obj(expl, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK) {
+ goto bad;
+ }
+ break;
+
+ case SCHOICE_START:
+ case CHOICE_START:
+ if (p_pr_choice(pe, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SEXTOBJ:
+ case EXTOBJ:
+ if (p[1].pe_type != EXTMOD) {
+ return (ppepsylose (mod, p, pe, "p_pr_type: missing EXTMOD"));
+ }
+ if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP,
+ (char **) 0) == NOTOK)
+ goto bad;
+ break;
+
+ case INTEGER:
+ if (pe != NULLPE) {
+ if ((i = prim2num(pe)) == NOTOK && pe->pe_errno != PE_ERR_NONE)
+ goto bad;
+ VPRINT(("%d", i));
+ }
+ break;
+
+#ifdef PEPSY_REALS
+ case REALTYPE:
+ if (pe != NULLPE) {
+ double r;
+
+ if ((r = prim2real(pe)) == NOTOK
+ && pe->pe_errno != PE_ERR_NONE)
+ goto bad;
+ VPRINT(("%g", r));
+ }
+ break;
+#endif
+
+ case BOOLEAN:
+ if (pe != NULLPE) {
+ if ((i = prim2flag(pe)) == NOTOK)
+ goto bad;
+ VPRINT((i ? "TRUE" : "FALSE"));
+ }
+ break;
+
+ case T_NULL:
+ VPRINT(("NULL"));
+ break;
+
+ case SANY:
+ if (pe != NULLPE) {
+ if (pe->pe_errno != PE_ERR_NONE) {
+ goto bad;
+ } else
+ VUNKNOWN(pe);
+ }
+ break;
+
+
+ case ANY:
+ if (pe != NULLPE) {
+ if (pe->pe_errno != PE_ERR_NONE) {
+ goto bad;
+ } else
+ VUNKNOWN(pe);
+ }
+ break;
+
+ case SOCTETSTRING:
+ if (pe != NULLPE) {
+ VSTRING(pe);
+ }
+ break;
+
+ case OCTETSTRING:
+ case T_STRING:
+ case OCTET_PTR:
+ if (pe != NULLPE) {
+ VSTRING(pe);
+ }
+ break;
+
+ case SBITSTRING:
+ if (pe != NULLPE) {
+ PE bstr;
+
+ if ((bstr = prim2bit(pe)) == NULLPE)
+ goto bad;
+ if (p -> pe_ucode >= 0 && mod->md_ptrtab &&
+ mod -> md_ptrtab[p -> pe_ucode] &&
+ bstr -> pe_nbits < LOTSOFBITS)
+ VPRINT (("%s", bit2str(bstr,
+ mod -> md_ptrtab[p -> pe_ucode])));
+ else if (bstr->pe_nbits < LOTSOFBITS)
+ VPRINT(("%s", bit2str(bstr, "\020")));
+ else
+ VUNKNOWN(pe);
+ }
+ break;
+
+ case BITSTR_PTR:
+ case BITSTRING:
+ if (pe != NULLPE) {
+ PE bstr;
+
+ if ((bstr = prim2bit(pe)) == NULLPE)
+ goto bad;
+ if (p -> pe_ucode >= 0 && mod->md_ptrtab &&
+ mod -> md_ptrtab[p -> pe_ucode] &&
+ bstr -> pe_nbits < LOTSOFBITS)
+ VPRINT (("%s", bit2str(bstr,
+ mod -> md_ptrtab[p -> pe_ucode])));
+ else if (bstr->pe_nbits < LOTSOFBITS)
+ VPRINT(("%s", bit2str(bstr, "\020")));
+ else
+ VUNKNOWN(pe);
+ }
+ break;
+
+ case SOBJID:
+ if ((oid = (OID) prim2oid(pe)) == NULLOID) {
+ goto bad;
+ } else {
+ VPRINT(("%s", oid2ode(oid)));
+ }
+ break;
+
+ case OBJID:
+ if ((oid = (OID) prim2oid(pe)) == NULLOID) {
+ goto bad;
+ } else {
+ VPRINT(("%s", oid2ode(oid)));
+ }
+ break;
+
+ case FN_CALL:
+ if ((FN_PTR(mod, p))(pe) == NOTOK)
+ return ppepsylose (mod, &p[1], NULLPE,
+ "p_pr_type:FN_CALL:call failed");
+ break;
+
+ default:
+ return (ppepsylose (mod, p, pe, "p_pr_type: %d not implemented\n",
+ p->pe_type));
+ }
+ if (ISDTYPE(p) && cnt > 0)
+ return (ppepsylose (mod, p, pe, "p_pr_type:compound type found\n"));
+ if (ISDTYPE(p) && pe != NULLPE)
+ return (OK);
+ if (NEXT_PTPE(p) == NULLPTPE)
+ goto bad;
+ }
+
+ return (OK);
+
+bad:
+ return (NOTOK);
+}
+
+/*
+ * Parse a sequence, calling appropriate routines to parse each sub
+ * type
+ */
+static int
+p_pr_seq(head, p, mod)
+PE head;
+ptpe *p;
+modtyp *mod; /* Module it is from */
+{
+ PE pe;
+
+ if (p->pe_type != SEQ_START && p->pe_type != SSEQ_START)
+ return (ppepsylose (mod, p, head, "p_pr_seq: missing SEQ_START\n"));
+#if PRINT_TYPES
+ if (p->pe_typename)
+ VNAME(*p->pe_typename);
+#endif
+ VPUSH();
+
+ p++;
+ if (p->pe_type == DFLT_B)
+ p++;
+
+
+ pe = first_member(head);
+ while (p->pe_type != PE_END) {
+ if (ISDTYPE(p) && OPTIONAL(p)) {
+ if (pe == NULLPE || CHKTAG(mod, p, pe) == 0)
+ goto next;
+ } else if (ISDTYPE(p) && (pe == NULLPE || CHKTAG(mod, p, pe) == 0)) {
+ if (DEFAULT(p)) {
+#ifdef PRINT_DEFAULTS
+ setpval(p, p + 1, mod);
+#endif
+ goto next;
+ } else {
+ dmp_ptpe("p_pr_seq:missing mandatory parameter", p, mod);
+ goto bad;
+ }
+ }
+ if (p->pe_typename)
+ VNAME(*p->pe_typename);
+ switch (p->pe_type) {
+ case OPTL:
+ break;
+
+ case UCODE:
+ if (mod->md_pucode == NULLIFP
+ || (*mod->md_pucode) (pe, p) == NOTOK)
+ goto bad;
+ break;
+
+ case BOPTIONAL:
+ if (CHKTAG(mod, p + 1, pe) == 0)
+ goto next;
+ p++;
+ continue;
+
+ case ETAG:
+ if (p_pr_type(1, pe, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SEQ_START:
+ if (p_pr_seq(pe, p, mod) == NOTOK) {
+ goto bad;
+ }
+ break;
+
+ case SEQOF_START:
+ if (p_pr_seqof(pe, p, mod) == NOTOK) {
+ goto bad;
+ }
+ break;
+
+ case SET_START:
+ if (p_pr_set(pe, p, mod) == NOTOK) {
+ goto bad;
+ }
+ break;
+
+ case SETOF_START:
+ if (p_pr_setof(pe, p, mod) == NOTOK) {
+ goto bad;
+ }
+ break;
+
+ case IMP_OBJ:
+ p++;
+ if (p->pe_type == EXTOBJ) {
+ if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP,
+ (char **) 0) == NOTOK)
+ goto bad;
+ } else {
+ if (p_pr_obj(0, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK) {
+ goto bad;
+ }
+ }
+ break;
+
+ case SOBJECT:
+ if (p_pr_obj(1, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK) {
+ goto bad;
+ }
+ break;
+
+ case OBJECT:
+#if PRINT_TYPES
+ if (p->pe_typename)
+ VNAME(*p->pe_typename);
+#endif
+ if (p_pr_obj(1, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK) {
+ goto bad;
+ }
+ break;
+
+ case SCHOICE_START:
+ case CHOICE_START:
+ if (p_pr_choice(pe, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SEXTOBJ:
+ if (p[1].pe_type != EXTMOD) {
+ return (ppepsylose (mod, p, pe, "p_pr_seq: missing EXTMOD"));
+ }
+ if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0,NULLIP,
+ (char **)0) == NOTOK)
+ goto bad;
+ break;
+
+ case EXTOBJ:
+ if (p[1].pe_type != EXTMOD) {
+ return (ppepsylose (mod, p, pe, "p_pr_seq: missing EXTMOD"));
+ }
+ if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP,
+ (char **)0) == NOTOK)
+ goto bad;
+ break;
+
+ default:
+ if (p_pr_type(1, pe, p, mod) == NOTOK)
+ goto bad;
+ break;
+ }
+
+ if (ISDTYPE(p) && pe != NULLPE)
+ pe = next_member(head, pe);
+next:
+ if (NEXT_PTPE(p) == NULLPTPE)
+ goto bad;
+ }
+
+ VPOP();
+ return (OK);
+
+bad:
+ VPOP();
+ return (NOTOK);
+}
+
+
+/*
+ * Parse a set, calling appropriate routines to parse each sub type
+ */
+static int
+p_pr_set(head, p, mod)
+PE head;
+ptpe *p;
+modtyp *mod; /* Module it is from */
+{
+ PE pe;
+
+ if (p->pe_type != SET_START && p->pe_type != SSET_START)
+ return (ppepsylose (mod, p, head, "p_pr_seq: missing SET_START\n"));
+#if PRINT_TYPES
+ if (p->pe_typename)
+ VNAME(*p->pe_typename);
+#endif
+ VPUSH();
+
+ p++;
+ if (p->pe_type == DFLT_B)
+ p++;
+
+ while (p->pe_type != PE_END) {
+
+ if (ISDTYPE(p) && OPTIONAL(p)) {
+ if ((pe = (PE) p_setpresent(head, p, mod)) == NULLPE)
+ goto next;
+ } else if (ISDTYPE(p)
+ && (pe = (PE) p_setpresent(head, p, mod)) == NULLPE) {
+ if (DEFAULT(p)) {
+#ifdef PRINT_DEFAULTS
+ setpval(p, p + 1, mod);
+#endif
+ goto next;
+ } else {
+ dmp_ptpe("p_pr_set:missing mandatory parameter", p, mod);
+ goto bad;
+ }
+ }
+ if (p->pe_typename)
+ VNAME(*p->pe_typename);
+ switch (p->pe_type) {
+ case OPTL:
+ break;
+
+ case UCODE:
+ if (mod->md_pucode == NULLIFP
+ || (*mod->md_pucode) (pe, p) == NOTOK)
+ goto bad;
+ break;
+
+ case BOPTIONAL:
+ if ((pe = (PE) p_setpresent(head, p + 1, mod)) == NULLPE)
+ goto next;
+ p++;
+ continue;
+
+ case ETAG:
+ if (p_pr_type(1, pe, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SEQ_START:
+ if (p_pr_seq(pe, p, mod) == NOTOK) {
+ goto bad;
+ }
+ break;
+
+ case SEQOF_START:
+ if (p_pr_seqof(pe, p, mod) == NOTOK) {
+ goto bad;
+ }
+ break;
+
+ case SET_START:
+ if (p_pr_set(pe, p, mod) == NOTOK) {
+ goto bad;
+ }
+ break;
+
+ case SETOF_START:
+ if (p_pr_setof(pe, p, mod) == NOTOK) {
+ goto bad;
+ }
+ break;
+
+ case IMP_OBJ:
+ p++;
+ if (p->pe_type == EXTOBJ) {
+ if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP,
+ (char **) 0) == NOTOK)
+ goto bad;
+ } else {
+ if (p_pr_obj(0, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK) {
+ goto bad;
+ }
+ }
+ break;
+
+ case SOBJECT:
+ if (p_pr_obj(1, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK) {
+ goto bad;
+ }
+ break;
+
+ case OBJECT:
+ if (p_pr_obj(1, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK) {
+ goto bad;
+ }
+ break;
+
+ case SCHOICE_START:
+ case CHOICE_START:
+ if (p_pr_choice(pe, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SEXTOBJ:
+ if (p[1].pe_type != EXTMOD) {
+ return (ppepsylose (mod, p, pe, "p_pr_set: missing EXTMOD"));
+ }
+ if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP, (char **)0) == NOTOK)
+ return (NOTOK);
+ break;
+
+ case EXTOBJ:
+ if (p[1].pe_type != EXTMOD) {
+ return (ppepsylose (mod, p, pe, "p_pr_set: missing EXTMOD"));
+ }
+ if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP,
+ (char **)0) == NOTOK)
+ goto bad;
+ break;
+
+ default:
+ if (p_pr_type(1, pe, p, mod) == NOTOK)
+ goto bad;
+ break;
+ }
+
+next:
+ if (NEXT_PTPE(p) == NULLPTPE)
+ goto bad;
+ }
+
+ VPOP();
+ return (OK);
+
+bad:
+ VPOP();
+ return (NOTOK);
+}
+
+
+/*
+ * Parse a sequence of calling appropriate routines to parse each sub
+ * type
+ */
+
+static int
+p_pr_seqof(head, p, mod)
+PE head;
+ptpe *p;
+modtyp *mod; /* Module it is from */
+{
+ PE pe;
+ ptpe *start; /* first entry in list */
+ int dflt = 0;
+
+ if (p->pe_type != SEQOF_START && p->pe_type != SSEQOF_START) {
+ return (ppepsylose (mod, p, head, "p_pr_seqof: missing SEQOF_START\n"));
+ }
+#if PRINT_TYPES
+ if (p->pe_typename)
+ VNAME(*p->pe_typename);
+#endif
+ VPUSH();
+
+ p++;
+
+ if (p->pe_type == DFLT_B)
+ p++;
+
+ start = p;
+
+
+ pe = first_member(head);
+ while (pe != NULLPE) {
+ while (p->pe_type != PE_END) {
+
+ if (ISDTYPE(p) && CHKTAG(mod, p, pe) == 0) {
+ if (DEFAULT(p))
+ return (ppepsylose (mod, p, pe,
+ "p_pr_seqof:Default not implemented\n"));
+ else if (OPTIONAL(p))
+ goto next;
+ else {
+ return (ppepsylose (mod, p, pe,
+ "p_pr_seqof:missing mandatory parameter"));
+ }
+ }
+ if (p->pe_typename)
+ VNAME(*p->pe_typename);
+ switch (p->pe_type) {
+ case UCODE:
+ if (mod->md_pucode == NULLIFP
+ || (*mod->md_pucode) (pe, p) == NOTOK)
+ goto bad;
+ break;
+
+ case BOPTIONAL:
+ if (CHKTAG(mod, p + 1, pe) == 0)
+ goto next;
+ p++;
+ continue;
+
+ case ETAG:
+ if (p_pr_type(1, pe, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ /*
+ * case SCTRL: parm = (char *) ((char *) parm);
+ * break;
+ */
+
+ case SEQ_START:
+ if (p_pr_seq(pe, p, mod) == NOTOK) {
+ goto bad;
+ }
+ break;
+
+ case SEQOF_START:
+ if (p_pr_seqof(pe, p, mod) == NOTOK) {
+ goto bad;
+ }
+ break;
+
+ case SET_START:
+ if (p_pr_set(pe, p, mod) == NOTOK) {
+ goto bad;
+ }
+ break;
+
+ case SETOF_START:
+ if (p_pr_setof(pe, p, mod) == NOTOK) {
+ goto bad;
+ }
+ break;
+
+ case SOBJECT:
+ if (p_pr_obj(1, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK) {
+ goto bad;
+ }
+ break;
+
+ case OBJECT:
+ if (p_pr_obj(1, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK) {
+ goto bad;
+ }
+ break;
+
+ case SCHOICE_START:
+ case CHOICE_START:
+ if (p_pr_choice(pe, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SEXTOBJ:
+ if (p[1].pe_type != EXTMOD) {
+ return (ppepsylose (mod, p, pe,"p_pr_seqof:missing EXTMOD"));
+ }
+ if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP,
+ (char **)0) == NOTOK)
+ goto bad;
+ break;
+
+ case EXTOBJ:
+ if (p[1].pe_type != EXTMOD) {
+ return (ppepsylose (mod, p, pe,"p_pr_seqof:missing EXTMOD"));
+ }
+ if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP,
+ (char **) 0) == NOTOK)
+ goto bad;
+ break;
+
+ default:
+ if (p_pr_type(1, pe, p, mod) == NOTOK)
+ goto bad;
+ break;
+ }
+
+ if (ISDTYPE(p) && dflt == 0)
+ pe = next_member(head, pe);
+ next:
+ if (NEXT_PTPE(p) == NULLPTPE)
+ goto bad;
+ }
+ /* parm = (char *) (parm); */
+ p = start;
+ }
+
+ VPOP();
+ return (OK);
+
+bad:
+ VPOP();
+ return (NOTOK);
+}
+
+/*
+ * Parse a setof, calling appropriate routines to parse each sub type
+ */
+static int
+p_pr_setof(head, p, mod)
+PE head;
+ptpe *p;
+modtyp *mod; /* Module it is from */
+{
+ PE pe;
+ ptpe *start;
+
+ if (p->pe_type != SETOF_START && p->pe_type != SSETOF_START)
+ return (ppepsylose (mod, p, head, "p_pr_setof: missing SETOF_START\n"));
+#if PRINT_TYPES
+ if (p->pe_typename)
+ VNAME(*p->pe_typename);
+#endif
+ VPUSH();
+
+ p++;
+ if (p->pe_type == DFLT_B)
+ p++;
+
+ start = p;
+
+ for (pe = first_member(head); pe; pe = next_member(head, pe)) {
+ while (p->pe_type != PE_END) {
+ if (pe == NULLPE || CHKTAG(mod, p, pe) == 0) {
+ if (DEFAULT(p)) {
+#ifdef PRINT_DEFAULTS
+ setpval(p, p + 1, mod);
+#endif
+ goto next;
+ } else {
+ dmp_ptpe("p_pr_setof:missing mandatory parameter", p, mod);
+ goto bad;
+ }
+ }
+
+ if (p->pe_typename)
+ VNAME(*p->pe_typename);
+ switch (p->pe_type) {
+ case UCODE:
+ if (mod->md_pucode == NULLIFP
+ || (*mod->md_pucode) (pe, p) == NOTOK)
+ goto bad;
+ break;
+
+ case BOPTIONAL:
+ if ((pe = (PE) p_setpresent(head, p + 1, mod)) == NULLPE)
+ goto next;
+ p++;
+ continue;
+
+ case ETAG:
+ if (p_pr_type(1, pe->pe_cons, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ /*
+ * case SCTRL: parm = (char *) (parm); break;
+ */
+
+ case SEQ_START:
+ if (p_pr_seq(pe, p, mod) == NOTOK) {
+ goto bad;
+ }
+ break;
+
+ case SEQOF_START:
+ if (p_pr_seqof(pe, p, mod) == NOTOK) {
+ goto bad;
+ }
+ break;
+
+ case SET_START:
+ if (p_pr_set(pe, p, mod) == NOTOK) {
+ goto bad;
+ }
+ break;
+
+ case SETOF_START:
+ if (p_pr_setof(pe, p, mod) == NOTOK) {
+ goto bad;
+ }
+ break;
+
+ case SOBJECT:
+ if (p_pr_obj(1, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK) {
+ goto bad;
+ }
+ break;
+
+ case OBJECT:
+ if (p_pr_obj(1, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK) {
+ goto bad;
+ }
+ break;
+
+ case SCHOICE_START:
+ case CHOICE_START:
+ if (p_pr_choice(pe, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SEXTOBJ:
+ if (p[1].pe_type != EXTMOD) {
+ return (ppepsylose (mod, p, pe,"p_pr_setof:missing EXTMOD"));
+ }
+ if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP,
+ (char **) 0) == NOTOK)
+ goto bad;
+ break;
+
+ case EXTOBJ:
+ if (p[1].pe_type != EXTMOD) {
+ return (ppepsylose (mod, p, pe,"p_pr_setof:missing EXTMOD"));
+ }
+ if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP,
+ (char **) 0) == NOTOK)
+ goto bad;
+ break;
+
+ default:
+ if (p_pr_type(1, pe, p, mod) == NOTOK)
+ goto bad;
+ break;
+ }
+
+ next:
+ if (NEXT_PTPE(p) == NULLPTPE)
+ goto bad;
+ }
+ /* parm = (char *)(parm); */
+ p = start;
+ }
+
+ VPOP();
+ return (OK);
+
+bad:
+ VPOP();
+ return (NOTOK);
+
+}
+
+/*
+ * parse a choice field. This means find which choice is taken
+ */
+static int
+p_pr_choice(head, p, mod)
+PE head;
+ptpe *p;
+modtyp *mod; /* Module it is from */
+{
+ if (p->pe_type != CHOICE_START && p->pe_type != SCHOICE_START) {
+ return (ppepsylose (mod, p, head, "p_pr_choice:missing CHOICE_START"));
+ }
+#if PRINT_TYPES
+ if (p->pe_typename)
+ VNAME(*p->pe_typename);
+#endif
+#ifdef CHOICE_PUSH
+ VPUSH();
+#endif
+
+ p++;
+ if (p->pe_type == DFLT_B)
+ p++;
+
+ if (p->pe_type == SCTRL) {
+ p++;
+ }
+
+ for (; p->pe_type != PE_END; NEXT_PTPE(p)) {
+ if (ISDTYPE(p) && p_ismatch(p, mod, head->pe_class, head->pe_id)) {
+ if (p->pe_typename)
+ VNAME(*p->pe_typename);
+ if (p_pr_type(0, head, p, mod) == NOTOK)
+ return (NOTOK);
+#ifdef CHOICE_PUSH
+ VPOP();
+#endif
+ NEXT_PTPE(p);
+ if (p->pe_type == UCODE) {
+ if (mod->md_pucode == NULLIFP
+ || (*mod->md_pucode) (head, p) == NOTOK)
+ return (NOTOK);
+ }
+ return (OK);
+ }
+ }
+
+ dmp_ptpe("p_pr_choice: no choice taken", p, mod);
+#ifdef CHOICE_PUSH
+ VPOP();
+#endif
+ return (NOTOK);
+}
+
+/*
+ * Calculate the next ptpe entry in the sequence. Count a sequence as
+ * one element
+ */
+ptpe *
+next_ptpe(p)
+ptpe *p;
+{
+ int level;
+
+ level = 0;
+ if (p->pe_type == PE_END) {
+ (void) ppepsylose (NULLMODTYP, p, NULLPE,
+ "next_ptpe: unexpected PE_END");
+ return (NULLPTPE);
+ }
+ do {
+again:
+ switch (p->pe_type) {
+ case SSEQ_START:
+ case SSEQOF_START:
+ case SSET_START:
+ case SSETOF_START:
+ case SCHOICE_START:
+ case SEQ_START:
+ case SEQOF_START:
+ case SET_START:
+ case SETOF_START:
+ case CHOICE_START:
+ level++;
+ break;
+
+ case UCODE:
+ case SCTRL:
+ case CH_ACT:
+ case INTEGER:
+ case REALTYPE:
+ case BOOLEAN:
+ case SANY:
+ case ANY:
+ case T_NULL:
+ case OBJECT:
+ case SOBJECT:
+ case BITSTRING:
+ case SBITSTRING:
+ case BITSTR_LEN:
+ case OCTETSTRING:
+ case T_STRING:
+ case OCTET_LEN:
+ case SOCTETSTRING:
+ case OBJID:
+ case SOBJID:
+ case OPTL:
+ case EXTMOD:
+ case DFLT_B:
+ case FN_CALL:
+ case FFN_CALL:
+ break;
+
+ case OCTET_PTR:
+ case BITSTR_PTR:
+ case IMP_OBJ:
+ case ETAG:
+ case EXTOBJ:
+ case SEXTOBJ:
+ case DFLT_F:
+ case BOPTIONAL:
+ p++;
+ goto again;
+
+ case PE_END:
+ level--;
+ break;
+
+ default:
+ (void) ppepsylose (NULLMODTYP, p, NULLPE,
+ "next_ptpe: unknown type %d\n", p->pe_type);
+ return (NULLPTPE);
+ }
+ p++;
+ } while (level > 0 || p->pe_type == DFLT_B);
+
+ return (p);
+}
+
+/*
+ * Parse a single type for explicit tag If a basic type parse it, if
+ * a compound type call the appropriate parsing routine
+ */
+static int
+p_pr_etype(pe, p, mod)
+PE pe;
+ptpe *p;
+modtyp *mod; /* Module it is from */
+{
+ integer i;
+ OID oid;
+
+ if (p->pe_type != ETAG)
+ return (ppepsylose (mod, p, pe, "p_pr_etype: missing ETAG\n"));
+
+
+ if (PRINT_TAG(p))
+ VTAG (CLASS (p), TAG (p));
+ p++;
+
+ switch (p->pe_type) {
+ case PE_END:
+ case PE_START:
+ goto bad;
+
+ case UCODE:
+ if (mod->md_pucode == NULLIFP
+ || (*mod->md_pucode) (pe, p) == NOTOK)
+ goto bad;
+ break;
+
+ case BOPTIONAL:
+ return (ppepsylose (mod, p, pe, "p_pr_etype:illegal BOPTIONAL\n"));
+
+ case ETAG:
+ switch (p->pe_ucode) {
+
+ default:
+ if (p_pr_etype(pe->pe_cons, p, mod) == NOTOK)
+ goto bad;
+ }
+ break;
+
+ case SSEQ_START:
+ case SEQ_START:
+ if (p_pr_seq(pe, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SSEQOF_START:
+ case SEQOF_START:
+ if (p_pr_seqof(pe, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SSET_START:
+ case SET_START:
+ if (p_pr_set(pe, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SSETOF_START:
+ case SETOF_START:
+ if (p_pr_setof(pe, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case IMP_OBJ:
+ p++;
+ if (p->pe_type == EXTOBJ) {
+ if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP,
+ (char **) 0) == NOTOK)
+ goto bad;
+ } else {
+#if PRINT_TYPES
+ if (p->pe_typename)
+ VNAME(*p->pe_typename);
+#endif
+ if (p_pr_obj(0, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK)
+ goto bad;
+ }
+ break;
+
+ case SOBJECT:
+#if PRINT_TYPES
+ if (p->pe_typename)
+ VNAME(*p->pe_typename);
+#endif
+ if (p_pr_obj(1, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK)
+ goto bad;
+ break;
+
+ case OBJECT:
+#if PRINT_TYPES
+ if (p->pe_typename)
+ VNAME(*p->pe_typename);
+#endif
+ if (p_pr_obj(1, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SCHOICE_START:
+ case CHOICE_START:
+ if (p_pr_choice(pe, p, mod) == NOTOK)
+ goto bad;
+ break;
+
+ case SEXTOBJ:
+ if (p[1].pe_type != EXTMOD) {
+ return (ppepsylose (mod, p, pe, "p_pr_etype: missing EXTMOD"));
+ }
+ if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP,
+ (char **) 0) == NOTOK)
+ goto bad;
+ break;
+
+ case EXTOBJ:
+ if (p[1].pe_type != EXTMOD) {
+ return (ppepsylose (mod, p, pe, "p_pr_etype: missing EXTMOD"));
+ }
+ if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP,
+ (char **) 0) == NOTOK)
+ goto bad;
+ break;
+
+ case INTEGER:
+ if (pe != NULLPE) {
+ if ((i = prim2num(pe)) == NOTOK && pe->pe_errno != PE_ERR_NONE)
+ goto bad;
+ VPRINT(("%d", i));
+ }
+ break;
+
+#ifdef PEPSY_REALS
+ case REALTYPE:
+ if (pe != NULLPE) {
+ double r;
+
+ if ((r = prim2real(pe)) == NOTOK
+ && pe->pe_errno != PE_ERR_NONE)
+ goto bad;
+ VPRINT(("%g", r));
+ }
+ break;
+#endif
+
+
+ case BOOLEAN:
+ if (pe != NULLPE) {
+ if ((i= prim2flag(pe)) == NOTOK)
+ goto bad;
+ VPRINT((i ? "TRUE" : "FALSE"));
+ }
+ break;
+
+ case T_NULL:
+ VPRINT(("NULL"));
+ break;
+
+ case ANY:
+ if (pe != NULLPE) {
+ if (pe->pe_errno != PE_ERR_NONE) {
+ goto bad;
+ } else
+ VUNKNOWN(pe);
+ }
+ break;
+
+ case SANY:
+ if (pe != NULLPE) {
+ if (pe->pe_errno != PE_ERR_NONE) {
+ goto bad;
+ } else
+ VUNKNOWN(pe);
+ }
+ break;
+
+ case SOCTETSTRING:
+ case OCTETSTRING:
+ case T_STRING:
+ case OCTET_PTR:
+ if (pe != NULLPE) {
+ VSTRING(pe);
+ }
+ break;
+
+ case BITSTRING:
+ case BITSTR_PTR:
+ case SBITSTRING:
+ if (pe != NULLPE) {
+ PE bstr;
+
+ if ((bstr = prim2bit(pe)) == NULLPE)
+ goto bad;
+ if (p -> pe_ucode >= 0 && mod->md_ptrtab &&
+ mod -> md_ptrtab[p -> pe_ucode] &&
+ bstr -> pe_nbits < LOTSOFBITS)
+ VPRINT (("%s", bit2str(bstr,
+ mod -> md_ptrtab[p -> pe_ucode])));
+ else if (bstr->pe_nbits < LOTSOFBITS)
+ VPRINT(("%s", bit2str(bstr, "\020")));
+ else
+ VUNKNOWN(pe);
+ }
+ break;
+
+ case SOBJID:
+ if ((oid = prim2oid(pe)) == NULLOID) {
+ goto bad;
+ } else {
+ VPRINT(("%s", oid2ode(oid)));
+ }
+ break;
+
+ case OBJID:
+ if ((oid = prim2oid(pe)) == NULLOID) {
+ goto bad;
+ } else {
+ VPRINT(("%s", oid2ode(oid)));
+ }
+ break;
+
+ default:
+ return (ppepsylose (mod, p, pe, "p_pr_etype: %d not implemented\n",
+ p->pe_type));
+ }
+
+ return (OK);
+
+bad:
+ return (NOTOK);
+}
+
+/*
+ * Is there a match at for this tag and class pair. Return 1 if yes 0
+ * if no We will search through contained objects and through choices
+ */
+p_ismatch(p, mod, cl, tag)
+ptpe *p;
+modtyp *mod; /* Module it is from */
+unsigned int cl, tag;
+{
+ if (!ISDTYPE(p))
+ return (0);
+ switch (p->pe_type) {
+ case SOBJECT:
+ case OBJECT:
+ /* Needs to be changed for optional and default */
+ return (p_ismatch(p = mod->md_ptab[p->pe_tag] + 1, mod, cl, tag));
+
+ case SEXTOBJ:
+ case EXTOBJ:
+ if (p[1].pe_type != EXTMOD) {
+ (void) ppepsylose (mod, p, NULLPE, "p_ismatch: missing EXTMOD");
+ return (0); /* fixup ismatch return -1 */
+ }
+ return (p_ismatch(EXT2MOD(mod, (p + 1))->md_ptab[p->pe_tag] + 1,
+ EXT2MOD(mod, (p + 1)), cl, tag));
+
+ case SCHOICE_START:
+ case CHOICE_START:
+ for (p++; p->pe_type != PE_END; p = NEXT_PTPE(p)) {
+ if (!ISDTYPE(p))
+ continue;
+ if (p_ismatch(p, mod, cl, tag))
+ return (1);
+ }
+ return (0);
+
+
+ case SANY:
+ return (1);
+
+ case ANY:
+ if (STAG(p) == -1)
+ return (1);
+ /* else fall through - not sure if this is needed */
+
+ default:
+ return (tag == TAG(p) && cl == CLASS(p));
+ }
+ /* NOTREACHED */
+ /* return (0); */
+}
+
+/*
+ * determine if the given field is present in the data This is simple
+ * if the field is a simple type with an obvious tag but in the case
+ * of an object or a CHOICE type the tag is not obvious. If the
+ * object is a CHOICE there are more than one possible tag that could
+ * match and in this case we must try to match each one of them.
+ */
+PE
+p_setpresent(head, p, mod)
+PE head;
+ptpe *p;
+modtyp *mod;
+{
+ PE pe;
+ modtyp *nmod;
+
+ while (!ISDTYPE(p) && p->pe_type != PE_END) {
+ p++;
+ }
+ if (!ISDTYPE(p) || p->pe_type == PE_END)
+ return (NULLPE);
+
+ switch (p->pe_type) {
+ case EXTOBJ:
+ case SEXTOBJ:
+ /* Needs to be changed for optional and default */
+ nmod = EXT2MOD(mod, (p + 1));
+ return (p_setpresent(head, p = nmod->md_ptab[p->pe_tag] + 1, nmod));
+
+ case OBJECT:
+ case SOBJECT:
+ {
+ /* Needs to be changed for optional and default */
+ return (p_setpresent(head, p = mod->md_ptab[p->pe_tag] + 1, mod));
+ }
+
+ case SCHOICE_START:
+ case CHOICE_START:
+ for (p++; p->pe_type != PE_END; p = NEXT_PTPE(p)) {
+ if (!ISDTYPE(p))
+ continue;
+ if ((pe = (PE) p_setpresent(head, p, mod)))
+ return (pe);
+ }
+ return (NULLPE);
+
+ default:
+ return (set_find(head, CLASS(p), TAG(p)));
+ }
+}
+
+#ifdef PRINT_DEFAULTS
+/*
+ * set the default value to that value in the structure
+ */
+setpval(typ, dflt, mod)
+ptpe *typ, *dflt;
+modtyp *mod;
+{
+ int len, i;
+ integer intval;
+ char *ptr, *optr;
+ PE pe_ptr;
+
+ switch (typ->pe_type) {
+
+ case INTEGER:
+ intval = IVAL(mod, dflt);
+ (*vfnx) (vfp, "%d (DEFAULT INTEGER)\n", intval);
+ break;
+
+
+#ifdef PEPSY_REALS
+ case REALTYPE:
+ (*vfnx) (vfp, "%f (DEFAULT Real)\n", RVAL(mod, dflt));
+ break;
+#endif
+
+ case BOOLEAN:
+ intval = IVAL(mod, dflt);
+ /*
+ * (*vfnx) (vfp, "%s %d (DEFAULT BOOLEAN)\n",
+ * (typ->pe_typename) ? typ->pe_typename : "", charval);
+ */
+ (*vfnx) (vfp, "%d (DEFAULT BOOLEAN)\n", intval);
+ break;
+
+ case T_NULL:
+ /* Only one value */
+ break;
+
+ case SBITSTRING:
+ case BITSTRING:
+ (PE) pe_ptr = strb2bitstr(PVAL(mod, dflt), IVAL(mod, dflt), 0, 0);
+ (*vfnx) (vfp, " '");
+ optr = ptr = bitstr2strb((PE) pe_ptr, &len);
+ for (i = 0; i < len; i += 8)
+ (*vfnx) (vfp, "%.2x", *ptr++);
+ (*vfnx) (vfp, "'H (DEFAULT BITSTRING)\n");
+ pe_free (pe_ptr);
+ free (optr);
+ break;
+
+ case SOCTETSTRING:
+ case OCTETSTRING:
+ ptr = PVAL(mod, dflt); /* array of octets */
+ intval = IVAL(mod, dflt); /* length of array */
+ if (printable(ptr, intval)) {
+ (*vfnx) (vfp, "\"");
+ for (; *ptr && intval-- > 0; ptr++)
+ (void) fputc(*ptr, vfp);
+ (*vfnx) (vfp, "\"\n");
+ } else {
+ (*vfnx) (vfp, "'");
+ if (ptr) {
+ for (; intval-- > 0; ptr++)
+ (*vfnx) (vfp, "%.2x", *ptr & 0xff);
+ }
+ (*vfnx) (vfp, "'H \n");
+ }
+ break;
+
+ case OBJECT:
+ setpval(mod->md_ptab[typ->pe_tag] + 1, dflt, mod);
+ break;
+
+ case SOBJECT:
+ setpval(mod->md_ptab[typ->pe_tag] + 1, dflt, mod);
+ break;
+
+ case IMP_OBJ:
+ typ++;
+
+ case ANY:
+ case SANY:
+ case SEXTOBJ:
+ case EXTOBJ:
+ case OBJID:
+ case SOBJID:
+ case SEQ_START:
+ case SET_START:
+ case -1: /* Just use the pepy method of null
+ * pointers */
+ /*
+ * This is the posy/pepy hack way of doing things at the
+ * moment
+ */
+ (char *) ptr = NULL;
+ break;
+
+ default:
+ return (ppepsylose (mod, p, pe, "setpval: type %d not implemented\n",
+ typ->pe_type));
+ break;
+ }
+
+}
+#endif
+/*
+ * return non zero if we can print out the string
+ */
+printable(strptr, len)
+char *strptr;
+int len;
+{
+ if (strptr == NULL || *strptr == '\0') {
+ return (0);
+ }
+
+ while (len-- > 0) {
+ if (!isprint(*strptr++))
+ return (0);
+ }
+
+ return (1);
+}
+
+/*
+ * (Dump) Print out a printable entry in a human recognisable form
+ */
+dmp_ptpe(s, p, mod)
+char *s;
+modtyp *mod; /* Module it is from */
+ptpe *p;
+{
+ int i, j;
+ ptpe **par, **prev;
+ char *name;
+
+ (void) fprintf(vfp, "%s:(%s)", s, mod->md_name);
+ /*
+ * Calculate what table it is in - we assume they are in order of
+ * increasing address
+ */
+
+ par = NULL;
+ if (mod->md_ptab != NULL && mod->md_ptab[0] < p) {
+ par = mod->md_ptab;
+ name = "Printing:";
+ }
+ if (par == NULL) {
+ (void) fprintf(vfp, "can't find entry 0x%x\n", p);
+ return;
+ }
+ prev = par;
+ for (i = mod->md_nentries; i > 0; i--) {
+ if (*par > p)
+ break;
+ par++;
+ }
+ if (par == prev) {
+ (void) ppepsylose (mod, p, NULLPE,
+ "dmp_ptpe:par == prev == 0x%x internal error\n", (int) par);
+ return;
+ }
+ par--;
+ j = p - *par;
+
+ (void) fprintf(vfp, "%s type %d + %d ", name, par - prev, j);
+ p_pr_entry(p);
+}
diff --git a/src/isode/pepsy/ptabs.c b/src/isode/pepsy/ptabs.c
new file mode 100644
index 000000000..81dad23ea
--- /dev/null
+++ b/src/isode/pepsy/ptabs.c
@@ -0,0 +1,1144 @@
+/* ptabs.c */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:31:32 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:40:26 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:43:14 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+#include <stdio.h>
+#include "pepsydefs.h"
+#include "pass2.h"
+#include "mine.h"
+
+extern char *c_tag(), *c_class();
+extern char *ec_tag(), *ec_class(), *pec_class();
+extern char *strip_last();
+extern char *str_yp_code[];
+extern char *get_val(), *get_comp(), *strp2name();
+extern s_table *lookup_list(), *get_offset();
+extern YP tprnt_loop();
+extern int gen_pentry();
+
+extern char *concat();
+extern char *my_strcat();
+extern char *rm_indirect();
+extern char *getfield();
+extern char *setfield();
+extern char *yp2name ();
+extern char *code2name ();
+extern char *modsym ();
+
+/*
+extern int explicit;
+*/
+
+extern char *tab;
+static int cons_type = 0;
+
+s_table *ptr;
+s_table *save_ptr;
+
+#define WORDSIZE 20
+
+/*
+ * Marshall's three extra conditions for changing the printing output
+ */
+static int mrose1; /* if NamedType */
+static int mrose2; /* !mrose1 && -h && DefinedType */
+static int mrose3; /* (mrose1 || !mrose2) && TAG && (OPTIONAL|DEFAULT) */
+
+/*
+ * table printe a type. generate tables for the printing of a type
+ */
+tprnt_typ(fp, yp, id, type)
+FILE *fp;
+YP yp;
+char *id;
+char *type;
+{
+ char *t, *f;
+ char *p1;
+ YP y;
+ int flag;
+ int ptr_tblidx = -1;
+
+ if (yp->yp_code < 0 || yp->yp_code > YP_REAL)
+ ferrd(1, "tdec_typ: unimplemented type %d\n", yp->yp_code);
+
+ if (yp == NULL) {
+ ferr(0, "tprnt_typ:NULL arguement\n");
+ return;
+ }
+
+ if (yp->yp_bef_alist && yp->yp_bef_alist->yal_prn)
+ gen_act(fp, yp->yp_bef_alist->yal_prn);
+
+ if (yp->yp_flags & YP_ID)
+ mrose1 = 1;
+ else
+ mrose1 = 0;
+
+ if (!mrose1 && hflag && yp->yp_code == YP_IDEFINED)
+ mrose2 = 1;
+ else
+ mrose2 = 0;
+
+ if ((mrose1 || !mrose2) && yp->yp_flags & YP_TAG
+ && yp->yp_flags & (YP_OPTIONAL|YP_DEFAULT))
+ mrose3 = 1;
+ else
+ mrose3 = 0;
+
+ if (type)
+ t = type;
+ else if (yp->yp_param_type) {
+ char *t1;
+ /* we have a [[ P type ]] specification */
+ if ((t1 = rm_indirect(yp->yp_param_type)) == NULLCP) {
+ fprintf(stderr,
+ "\ntenc_typ:SETLIST can't extract direct type from %s\n",
+ yp->yp_param_type);
+ exit(1);
+ }
+ t = strdup(t1);
+ } else
+ t = my_strcat("struct ", modsym(mymodule, id, "type"));
+
+ if ((yp->yp_flags & YP_PARMVAL) && yp->yp_parm) {
+ if ((f = getfield(yp->yp_parm)) == NULLCP) {
+ fprintf(stderr, "\ntprnt_typ:can't extract field from %s\n",
+ yp->yp_parm);
+ exit(1);
+ }
+ f = strdup(f);
+ } else
+ f = yp->yp_varexp;
+
+ if ((yp->yp_flags & (YP_OPTIONAL|YP_OPTCONTROL|YP_DEFAULT))
+ == (YP_OPTIONAL|YP_OPTCONTROL)) {
+ yp->yp_flags &= ~YP_OPTCONTROL;
+ flag = 1;
+ } else
+ flag = 0;
+
+ if (yp->yp_flags & YP_TAG && !(yp->yp_flags & YP_IMPLICIT)) {
+ prte_enoff(fp, "ETAG", yp, ptr_tblidx);
+ }
+
+ if (yp->yp_yfn && yp->yp_yfn->yfn_prt) {
+ gen_fn(fp, yp, yp->yp_yfn->yfn_prt);
+ if (yp->yp_flags & YP_DEFAULT)
+ gdflt(fp, yp, G_DEC);
+
+ if (yp->yp_aft_alist && yp->yp_aft_alist->yal_prn)
+ gen_act(fp, yp->yp_aft_alist->yal_prn);
+
+ return;
+ }
+
+ switch (yp->yp_code) {
+
+ case YP_UNDF:
+ ferr(1, "tprnt_typ:Undefined type\n");
+
+ case YP_BOOL:
+ if (yp->yp_intexp)
+ f = setfield(yp->yp_intexp);
+ if (noindirect(f))
+ ferr(1, "tdec_typ:BOOL: must specify a field [[ b .. ]]\n");
+ p1 = "BOOLEAN";
+ if (yp->yp_varexp || (yp->yp_intexp && !noindirect(f)))
+ break;
+ ferr(1, "tdec_typ:BOOL: can't find a type for boolean\n");
+
+ /* This needs to be fixed up in the action generating area */
+ case YP_INTLIST:
+
+ case YP_INT:
+
+ case YP_ENUMLIST:
+ if (yp->yp_intexp)
+ f = setfield(yp->yp_intexp);
+ if (noindirect(f))
+ ferr(1, "tdec_typ:INT: must specify a field [[ i .. ]]\n");
+ p1 = "INTEGER";
+ if (yp->yp_varexp || (yp->yp_intexp && !noindirect(f)))
+ break;
+ ferr(1, "tdec_typ:INT: couldn't determine type\n");
+
+ case YP_REAL:
+ if (yp->yp_strexp)
+ f = setfield(yp->yp_strexp);
+ if (noindirect(f))
+ ferr(1, "tdec_typ:REAL: must specify a field [[ r .. ]]\n");
+ p1 = "REALTYPE";
+ if (yp->yp_varexp || (yp->yp_strexp && !noindirect(f)))
+ break;
+ ferr(1, "tdec_typ:INT: couldn't determine type\n");
+
+
+ case YP_BITLIST:
+ ptr_tblidx = addptr (modsym(mymodule,
+ yp->yp_varexp ? yp -> yp_varexp : id,
+ "bits"));
+ /* fall */
+ case YP_BIT:
+ if (yp->yp_strexp && yp->yp_intexp) {
+ if (yp->yp_strexp)
+ f = setfield(yp->yp_strexp);
+ if (noindirect(f))
+ ferr(1, "tdec_typ:BIT: must specify a field [[ x .. ]]\n");
+ p1 = "BITSTR_PTR";
+ prte_off(fp, p1, yp, t, f, ptr_tblidx);
+ if (yp->yp_intexp)
+ f = setfield(yp->yp_intexp);
+ if (noindirect(f))
+ ferr(1, "tdec_typ:BIT: must specify a field [[ x .. ]]\n");
+ p1 = "BITSTR_LEN";
+ break;
+ }
+ if (yp->yp_strexp == NULLCP && yp->yp_intexp)
+ f = setfield(yp->yp_intexp);
+ if (yp->yp_varexp || (yp->yp_strexp && !noindirect(f))) {
+ p1 = "BITSTRING";
+ break;
+ }
+ t = NULL;
+ p1 = NULL;
+ (void) fprintf(fp, "\t{ SBITSTRING, %d, %s, %s, NULLVP },\n",
+ ptr_tblidx, c_tag(yp), c_class(yp));
+ break;
+
+ case YP_OCT:
+ if (yp->yp_strexp) {
+ switch (yp->yp_prfexp) {
+ case 'q': /* [[ q parm->qbufptr ]] */
+ if (yp->yp_strexp)
+ f = setfield(yp->yp_strexp);
+ if (noindirect(f))
+ p1 = "SOCTETSTRING";
+ else
+ p1 = "OCTETSTRING";
+ break;
+
+ case 's': /* [[ s ptr ]] */
+ if (yp->yp_strexp)
+ f = setfield(yp->yp_strexp);
+ if (noindirect(f))
+ ferr(1, "tdec_typ:OCT: must specify a field [[ s .. ]]\n");
+ p1 = "T_STRING";
+ break;
+
+ case 'o': /* [[ o ptr $ length ]] */
+ if (yp->yp_strexp)
+ f = setfield(yp->yp_strexp);
+ if (noindirect(f))
+ ferr(1, "tdec_typ:OCT: must specify a field [[ o .. ]]\n");
+ p1 = "OCTET_PTR";
+ prte_off(fp, p1, yp, t, f, ptr_tblidx);
+ if (yp->yp_intexp)
+ f = setfield(yp->yp_intexp);
+ if (noindirect(f))
+ ferr(1, "tdec_typ:OCT: must specify a field [[ o .. ]]\n");
+ p1 = "OCTET_LEN";
+ break;
+
+ default:
+ fprintf(stderr,"\ntprnt_typ:Unknown Octet string specifier %c\n",
+ yp->yp_prfexp);
+ exit(1);
+ }
+ break;
+ }
+
+ if (f && !noindirect(f)) {
+ p1 = "OCTETSTRING";
+ break;
+ }
+ t = NULL;
+ p1 = NULL;
+ prte_noff(fp, "SOCTETSTRING", yp, ptr_tblidx);
+ break;
+
+ case YP_OID:
+ if (yp->yp_strexp)
+ f = setfield(yp->yp_strexp);
+ if (yp->yp_varexp || (yp->yp_strexp && !noindirect(f))) {
+ p1 = "OBJID";
+ break;
+ }
+ t = NULL;
+ p1 = NULL;
+ prte_noff(fp, "SOBJID", yp, ptr_tblidx);
+ break;
+
+ case YP_SEQ:
+ case YP_SET:
+ case YP_ANY:
+ if (yp->yp_strexp)
+ f = setfield(yp->yp_strexp);
+ if (yp->yp_varexp || (yp->yp_strexp && !noindirect(f))) {
+ p1 = "ANY";
+ break;
+ }
+ t = NULL;
+ p1 = NULL;
+ prte_noff(fp, "SANY", yp, ptr_tblidx);
+ break;
+
+ case YP_NULL:
+ p1 = "T_NULL";
+ t = NULL;
+ break;
+
+ case YP_IDEFINED:
+ p1 = NULL;
+
+ if ((yp->yp_flags & YP_PARMVAL) && yp->yp_prfexp)
+ ferr(1,
+ "\n[[ ? reference ]] [[ p reference ]] is illegal\n\t only one allowed\n");
+
+ if (yp->yp_prfexp) { /* [[ ? parm->field ]] - complex to process */
+ gen_identry(fp, t, f, yp, gen_pentry);
+
+ if (yp->yp_flags & YP_DEFAULT)
+ gdflt(fp, yp, G_DEC);
+
+ break;
+ }
+
+ pr_deftyp(fp, yp, t, f);
+ if (yp->yp_flags & YP_DEFAULT)
+ gdflt(fp, yp, G_DEC);
+ break;
+
+ case YP_SEQLIST:
+ p1 = NULL;
+ /* support for -h flag */
+ cons_type++;
+ save_ptr = ptr;
+ if (yp->yp_varexp == NULL && type != NULL)
+ ferr(1, "tprnt_typ:YP_SEQLIST:NULL varexp pointer\n");
+ if (type == NULL)
+ prte_noff(fp, "SSEQ_START", yp, ptr_tblidx);
+ else if (noindirect(f))
+ prte_noff(fp, "SSEQ_START", yp, ptr_tblidx);
+ else
+ prte_off(fp, "SEQ_START", yp, t, f, ptr_tblidx);
+
+ if (yp->yp_flags & YP_DEFAULT)
+ gdflt(fp, yp, G_DEC);
+ if (y = yp->yp_type) {
+ char *t1;
+
+ if (yp->yp_param_type) {
+ /* we have a [[ P type ]] specification */
+ if ((t1 = rm_indirect(yp->yp_param_type)) == NULLCP) {
+ fprintf(stderr,
+ "\ntprnt_typ:SEQLIST can't extract direct type from %s\n",
+ yp->yp_param_type);
+ exit(1);
+ }
+ yp->yp_structname = strdup(t1);
+ } else if (type) {
+ if (yp->yp_declexp == NULL)
+ ferr(1, "tprnt_typ:YP_SEQLIST:no declexp\n");
+ yp->yp_structname = my_strcat("struct ", yp->yp_declexp);
+ } else
+ yp->yp_structname = t;
+#ifdef DO_OFFSETS
+ if (optfield(y)) {
+ (void) fprintf(fp,
+ "\t{ OPTL, OFFSET(%s, optionals), 0, 0, NULLVP },\n",
+ yp->yp_structname);
+ }
+#endif
+ tprnt_loop(fp, y, id, yp->yp_structname);
+ }
+ (void) fprintf(fp, "\t{ PE_END, 0, 0, 0, NULLVP },\n");
+ ptr = save_ptr;
+ cons_type--;
+ break;
+
+ case YP_SETLIST:
+ p1 = NULL;
+ /* support for -h flag */
+ cons_type++;
+ if (yp->yp_varexp == NULL && type != NULL)
+ ferr(1, "tprnt_typ:YP_SETLIST:NULL varexp pointer\n");
+ if (type == NULL)
+ prte_noff(fp, "SSET_START", yp, ptr_tblidx);
+ else if (noindirect(f))
+ prte_noff(fp, "SSET_START", yp, ptr_tblidx);
+ else
+ prte_off(fp, "SET_START", yp, t, f, ptr_tblidx);
+
+ if (yp->yp_flags & YP_DEFAULT)
+ ddflt(fp, yp);
+ if (y = yp->yp_type) {
+ char *t1;
+
+ if (yp->yp_param_type) {
+ /* we have a [[ P type ]] specification */
+ if ((t1 = rm_indirect(yp->yp_param_type)) == NULLCP) {
+ fprintf(stderr,
+ "\ntprnt_typ:SETLIST can't extract direct type from %s\n",
+ yp->yp_param_type);
+ exit(1);
+ }
+ yp->yp_structname = strdup(t1);
+ } else if (type) {
+ if (yp->yp_declexp == NULL)
+ ferr(1, "tprnt_typ:YP_SETLIST:no declexp\n");
+ yp->yp_structname = my_strcat("struct ", yp->yp_declexp);
+ } else
+ yp->yp_structname = t;
+#ifdef DO_OFFSETS
+ if (optfield(y)) {
+ (void) fprintf(fp,
+ "\t{ OPTL, OFFSET(%s, optionals), 0, 0, NULLVP },\n",
+ yp->yp_structname);
+ }
+#endif
+ tprnt_loop(fp, y, id, yp->yp_structname);
+ }
+ (void) fprintf(fp, "\t{ PE_END, 0, 0, 0, NULLVP },\n");
+ ptr = save_ptr;
+ cons_type--;
+ break;
+
+ case YP_SEQTYPE: /* What is the difference ?? */
+ p1 = NULL;
+ cons_type++;
+ save_ptr = ptr;
+ if (type == NULL)
+ prte_noff(fp, "SSEQOF_START", yp, ptr_tblidx);
+ else if (noindirect(f))
+ prte_noff(fp, "SSEQOF_START", yp, ptr_tblidx);
+ else
+ prte_off(fp, "SEQOF_START", yp, t, f, ptr_tblidx);
+ if (yp->yp_flags & YP_DEFAULT)
+ gdflt(fp, yp, G_DEC);
+
+ if (y = yp->yp_type) {
+ char *t1;
+
+ if (yp->yp_param_type) {
+ /* we have a [[ P type ]] specification */
+ if ((t1 = rm_indirect(yp->yp_param_type)) == NULLCP) {
+ fprintf(stderr,
+ "\ntprnt_typ:SEQTYPE can't extract direct type from %s\n",
+ yp->yp_param_type);
+ exit(1);
+ }
+ yp->yp_structname = strdup(t1);
+ } else if (type) {
+ if (yp->yp_declexp == NULL)
+ ferr(1, "tprnt_typ:YP_SEQTYPE:no declexp\n");
+ yp->yp_structname = my_strcat("struct ", yp->yp_declexp);
+ } else
+ yp->yp_structname = t;
+ tprnt_loop(fp, y, id, yp->yp_structname);
+ }
+#ifdef DO_OFFSETS
+ if (yp->yp_flags & YP_CONTROLLED) {
+ char *f1;
+
+ if ((f1 = getfield(yp->yp_control)) == NULLCP) {
+ fprintf(stderr, "\ntprnt_typ:SEQ OF: can't extract field from %s\n",
+ yp->yp_control);
+ exit(1);
+ }
+ (void) fprintf(fp, "\t{ PE_END, OFFSET(%s, %s), 0, 0 },\n",
+ yp->yp_structname, f1);
+ } else if (yp->yp_structname != NULL)
+ (void) fprintf(fp,
+ "\t{ PE_END, OFFSET(%s, next), 0, 0, NULLVP },\n",
+ yp->yp_structname);
+ else
+#endif
+ (void) fprintf(fp, "\t{ PE_END, 0, 0, 0, NULLVP },\n");
+ ptr = save_ptr;
+ cons_type--;
+ break;
+
+ case YP_SETTYPE:
+ p1 = NULL;
+ cons_type++;
+ save_ptr = ptr;
+ if (type == NULL)
+ prte_noff(fp, "SSETOF_START", yp, ptr_tblidx);
+ else if (noindirect(f))
+ prte_noff(fp, "SSETOF_START", yp, ptr_tblidx);
+ else
+ prte_off(fp, "SETOF_START", yp, t, f, ptr_tblidx);
+
+ if (yp->yp_flags & YP_DEFAULT)
+ gdflt(fp, yp, G_DEC);
+
+ if (y = yp->yp_type) {
+ char *t1;
+
+ if (yp->yp_param_type) {
+ /* we have a [[ P type ]] specification */
+ if ((t1 = rm_indirect(yp->yp_param_type)) == NULLCP) {
+ fprintf(stderr,
+ "\ntprnt_typ:SETTYPE can't extract direct type from %s\n",
+ yp->yp_param_type);
+ exit(1);
+ }
+ yp->yp_structname = strdup(t1);
+ } else if (type) {
+ if (yp->yp_declexp == NULL)
+ ferr(1, "tprnt_typ:YP_SETTYPE:no declexp\n");
+ yp->yp_structname = my_strcat("struct ", yp->yp_declexp);
+ } else
+ yp->yp_structname = t;
+ tprnt_loop(fp, y, id, yp->yp_structname);
+ }
+ if (yp->yp_flags & YP_CONTROLLED) {
+ char *f1;
+
+ if ((f1 = getfield(yp->yp_control)) == NULLCP) {
+ fprintf(stderr, "\ntprnt_typ:SET OF: can't extract field from %s\n",
+ yp->yp_control);
+ exit(1);
+ }
+ (void) fprintf(fp, "\t{ PE_END, OFFSET(%s, %s), 0, 0 },\n",
+ yp->yp_structname, f1);
+ } else if (yp->yp_structname != NULL)
+ (void) fprintf(fp,
+ "\t{ PE_END, OFFSET(%s, next), 0, 0, NULLVP },\n",
+ yp->yp_structname);
+ else
+ (void) fprintf(fp, "\t{ PE_END, 0, 0, 0, NULLVP },\n");
+ ptr = save_ptr;
+ cons_type--;
+ break;
+
+ case YP_CHOICE:
+ p1 = NULL;
+ /* support for -h flag */
+ if (hflag && (y = yp->yp_type) && !y->yp_next) {
+ tprnt_typ(fp, y, id, yp->yp_structname);
+ break;
+ }
+ cons_type++;
+ save_ptr = ptr;
+ /* Generates an unused tags field - so beware */
+ if (type == NULL)
+ prte_noff(fp, "SCHOICE_START", yp, ptr_tblidx);
+ else if (noindirect(f))
+ prte_noff(fp, "SCHOICE_START", yp, ptr_tblidx);
+ else
+ prte_off(fp, "CHOICE_START", yp, t, f, ptr_tblidx);
+
+ if (yp->yp_flags & YP_DEFAULT)
+ gdflt(fp, yp, G_DEC);
+ if (y = yp->yp_type) {
+ char *t1;
+#ifdef DO_OFFSETS
+ char *f1;
+
+ if (yp->yp_flags & YP_CONTROLLED) {
+
+ if ((f1 = getfield(yp->yp_control)) == NULLCP) {
+ fprintf(stderr,
+ "\ntprnt_typ:CHOICE: can't extract field from %s\n",
+ yp->yp_control);
+ exit(1);
+ }
+
+ } else
+ f1 = "offset";
+
+ if ((yp->yp_flags & YP_ID) && yp->yp_id)
+ (void) fprintf(fp,
+ "\t{ SCTRL, OFFSET(%s, %s), 0, 0, (char **)&%s%s%s[%d] },\n",
+ yp->yp_structname, f1, PREFIX, PTR_TABNAME, tab,
+ addsptr(yp->yp_id));
+ else
+ (void) fprintf(fp,
+ "\t{ SCTRL, OFFSET(%s, %s), 0, 0, NULLVP },\n",
+ yp->yp_structname, f1);
+#else
+ if ((yp->yp_flags & YP_ID) && yp->yp_id)
+ (void) fprintf(fp,"\t{ SCTRL, 0, 0, 0, (char **)&%s%s%s[%d] },\n",
+ PREFIX, PTR_TABNAME, tab, addsptr(yp->yp_id));
+ else
+ (void) fprintf(fp, "\t{ SCTRL, 0, 0, 0, NULLVP },\n");
+
+#endif
+ if (yp->yp_param_type) {
+ /* we have a [[ P type ]] specification */
+ if ((t1 = rm_indirect(yp->yp_param_type)) == NULLCP) {
+ fprintf(stderr,
+ "\ntprnt_typ:CHOICE can't extract direct type from %s\n",
+ yp->yp_param_type);
+ exit(1);
+ }
+ yp->yp_structname = strdup(t1);
+ } else if (type) {
+ if (yp->yp_declexp == NULL)
+ ferr(1, "tprnt_typ:YP_CHOICE:no declexp\n");
+ yp->yp_structname = my_strcat("struct ", yp->yp_declexp);
+ } else
+ yp->yp_structname = t;
+ tprnt_loop(fp, y, id, yp->yp_structname);
+ }
+ (void) fprintf(fp, "\t{ PE_END, 0, 0, 0, NULLVP },\n");
+ ptr = save_ptr;
+ cons_type--;
+ break;
+
+ default:
+ ferrd(1, "tprnt_typ: yp_code = %d not implemented\n", yp->yp_code);
+ }
+
+ if (p1 != NULL) {
+ if (t != NULL)
+ prte_off(fp, p1, yp, t, f, ptr_tblidx);
+ else
+ prte_noff(fp, p1, yp, ptr_tblidx);
+
+ if (yp->yp_flags & YP_DEFAULT)
+ gdflt(fp, yp, G_DEC);
+ }
+
+ if (flag)
+ yp->yp_flags |= YP_OPTCONTROL;
+
+ if (yp->yp_aft_alist && yp->yp_aft_alist->yal_prn)
+ gen_act(fp, yp->yp_aft_alist->yal_prn);
+
+}
+
+/*
+ * generate tables for printing a contructed type
+ */
+YP
+tprnt_loop(fp, yp, id, type)
+FILE *fp;
+YP yp;
+char *id;
+char *type;
+{
+ for (; yp != NULL; yp = yp->yp_next) {
+ tprnt_typ(fp, yp, id, type);
+ }
+}
+
+
+ddflt(fp, yp)
+FILE *fp;
+YP yp;
+{
+ switch (yp->yp_code) {
+ case YP_BOOL:
+ case YP_INT:
+ case YP_INTLIST:
+ (void) fprintf(fp, "\t{DFLT_B, %d, 0, 0 },\n",
+ yp->yp_default->yv_number);
+ break;
+ case YP_BIT:
+ case YP_BITLIST:
+ case YP_OCT:
+ case YP_NULL:
+ case YP_SEQ:
+ case YP_SEQTYPE:
+ case YP_SEQLIST:
+ case YP_SET:
+ case YP_SETTYPE:
+ case YP_SETLIST:
+ case YP_CHOICE:
+ case YP_ANY:
+ case YP_OID:
+ case YP_IDEFINED:
+ case YP_ENUMLIST:
+ case YP_REAL:
+ (void) fprintf(fp, "\t{DFLT_B, 0, 0, 0 },\n");
+ break;
+
+ default:
+ ferrd(1, "ddflt:unknown type %d\n", yp->yp_code);
+ }
+
+}
+
+/*
+ * print a Non offset table entry
+ */
+prte_noff(fp, type, yp, idx)
+FILE *fp;
+char *type;
+YP yp;
+int idx;
+{
+ char *tag;
+ char *flags;
+ char *typename;
+ char buf1[BUFSIZ];
+
+ tag = c_tag(yp);
+ flags = c_class(yp);
+ if (mrose3) { /* need to append FL_PRTAG flag */
+ (void) strncpy(buf1, flags, BUFSIZ);
+ (void) strncat(buf1, "|FL_PRTAG", BUFSIZ);
+ flags = buf1;
+ }
+ if (mrose1)
+ typename = yp->yp_id;
+ else if (mrose2)
+ typename = yp->yp_identifier;
+ else
+ typename = (char *)0;
+ if (typename) {
+ int pindex = addsptr (typename);
+ (void) fprintf(fp, "\t{ %s, %d, %s, %s, (char **)&%s%s%s[%d] },\n",
+ type, idx, tag, flags,
+ PREFIX, PTR_TABNAME, tab, pindex);
+ }
+ else
+ (void) fprintf(fp, "\t{ %s, %d, %s, %s, NULLVP },\n",
+ type,idx, tag, flags);
+}
+
+/*
+ * print a Non offset table entry for an ETAG - special case
+ */
+prte_enoff(fp, type, yp, idx)
+FILE *fp;
+char *type;
+YP yp;
+int idx;
+{
+ char *tag;
+ char *flags;
+ char *typename;
+ char buf1[BUFSIZ];
+
+ tag = ec_tag(yp);
+ flags = ec_class(yp);
+ if (mrose3) { /* need to append FL_PRTAG flag */
+ (void) strncpy(buf1, flags, BUFSIZ);
+ (void) strncat(buf1, "|FL_PRTAG", BUFSIZ);
+ flags = buf1;
+ mrose3 = 0; /* don't want the next tag */
+ }
+ if (mrose1) {
+ typename = yp->yp_id;
+ mrose1 = 0;
+ } else if (mrose2) {
+ typename = yp->yp_identifier;
+ mrose2 = 0;
+ } else
+ typename = NULL;
+ if (typename){
+ int pindex = addsptr (typename);
+ (void) fprintf(fp, "\t{ %s, %d, %s, %s, (char **)&%s%s%s[%d] },\n",
+ type, idx, tag, flags,
+ PREFIX, PTR_TABNAME, tab, pindex);
+ }
+ else
+ (void) fprintf(fp, "\t{ %s, %d, %s, %s, NULLVP },\n",
+ type, idx, tag, flags);
+}
+
+/*
+ * print an offset table entry
+ */
+/* ARGSUSED */
+prte_off(fp, type, yp, t, f, idx)
+FILE *fp;
+char *type;
+YP yp;
+char *t, *f;
+int idx;
+{
+ char *tag;
+ char *flags;
+ char *typename;
+ char buf1[BUFSIZ];
+
+ tag = c_tag(yp);
+ flags = c_class(yp);
+ if (mrose3) { /* need to append FL_PRTAG flag */
+ (void) strncpy(buf1, flags, BUFSIZ);
+ (void) strncat(buf1, "|FL_PRTAG", BUFSIZ);
+ flags = buf1;
+ }
+ if (mrose1)
+ typename = yp->yp_id;
+ else if (mrose2)
+ typename = yp->yp_identifier;
+ else
+ typename = (char *)0;
+#ifdef DO_OFFSETS
+ if (typename) {
+ int pindex = addsptr (typename);
+ (void) fprintf(fp, "\t{ %s, OFFSET(%s, %s), %s, %s, (char **)&%s%s%s[%d] },\n",
+ type, t, f, tag, flags,
+ PREFIX, PTR_TABNAME, tab, pindex);
+ }
+ else
+ (void) fprintf(fp, "\t{ %s, OFFSET(%s, %s), %s, %s, NULLVP },\n",
+ type, t, f, tag, flags);
+#else
+ if (typename){
+ int pindex = addsptr (typename);
+ (void) fprintf(fp, "\t{ %s, %d, %s, %s, (char **)&%s%s%s[%d] },\n",
+ type, idx, tag, flags,
+ PREFIX, PTR_TABNAME, tab, pindex);
+ }
+ else
+ (void) fprintf(fp, "\t{ %s, %d, %s, %s, NULLVP },\n",
+ type, idx, tag, flags);
+#endif
+}
+
+/*
+ * handle the very complex task of defined types.
+ * Basically generating object calls
+ */
+pr_deftyp(fp, yp, t, f)
+FILE *fp;
+YP yp;
+char *t;
+char *f;
+{
+ /* Predefined Universal Type */
+ struct univ_typ *p, *univtyp();
+
+ if ((p = univtyp(yp->yp_identifier))) {
+ if (p->univ_flags & UNF_EXTMOD) {
+ yp->yp_module = p->univ_mod;
+ goto do_obj;
+ }
+ prte_univt(fp, p, yp, t, f);
+ return;
+ }
+
+do_obj:
+ if (yp->yp_flags & YP_TAG && yp->yp_flags & YP_IMPLICIT)
+ prte_noff(fp, "IMP_OBJ", yp, -1);
+ prte_obj(fp, yp, t, f);
+}
+
+/*
+ * print an offset table entry for an OBJECT type entry
+ */
+/* ARGSUSED */
+prte_obj(fp, yp, t, f)
+FILE *fp;
+YP yp;
+char *t, *f;
+{
+ char *type;
+ char *obj;
+ char *flags;
+ char *typename;
+ char *off;
+ char buf1[BUFSIZ];
+#ifdef DO_OFFSETS
+ char buf2[BUFSIZ];
+#endif
+ int extflag;
+
+ if (yp->yp_module == NULL || strcmp(yp->yp_module, mymodule) == 0) {
+ if (f && !noindirect(f))
+ type = "OBJECT";
+ else
+ type = "SOBJECT";
+ obj = proc_name(yp->yp_identifier, 0);
+ extflag = 0;
+ } else {
+ if (f && !noindirect(f))
+ type = "EXTOBJ";
+ else
+ type = "SEXTOBJ";
+ obj = strp2name(yp->yp_identifier, yp->yp_module);
+ extflag = 1;
+ }
+ flags = c_class(yp);
+ if (mrose3) { /* need to append FL_PRTAG flag */
+ (void) strncpy(buf1, flags, BUFSIZ);
+ (void) strncat(buf1, "|FL_PRTAG", BUFSIZ);
+ flags = buf1;
+ }
+ if (mrose1)
+ typename = yp->yp_id;
+ else if (mrose2)
+ typename = yp->yp_identifier;
+ else
+ typename = (char *)0;
+#ifdef DO_OFFSETS
+ if (f && !noindirect(f)) {
+ (void) sprintf(buf2, "OFFSET(%s, %s)", t, f);
+ off = buf2;
+ } else if (f && *f == '&') {
+ (void) sprintf(buf2, "OFFSET(%s, %s)", t, f + 1);
+ off = buf2;
+ } else
+#endif
+ off = "0";
+ if (typename){
+ int pindex = addsptr (typename);
+ (void) fprintf(fp, "\t{ %s, %s, _Z%s, %s, (char **)&%s%s%s[%d] },\n",
+ type, off, obj, flags,
+ PREFIX, PTR_TABNAME, tab, pindex);
+ }
+ else
+ (void) fprintf(fp, "\t{ %s, %s, _Z%s, %s, NULLVP },\n",
+ type, off, obj, flags);
+ if (extflag)
+ (void) fprintf(fp, "\t{ EXTMOD, %d, 0, 0, NULLVP },\n",
+ gen_modref(yp->yp_module));
+}
+
+/*
+ * print an table entry for Universal type with the given entry
+ */
+/* ARGSUSED */
+prte_univt(fp, p, yp, t, f)
+FILE *fp;
+struct univ_typ *p;
+YP yp;
+char *t, *f;
+{
+ char *type;
+ int tag;
+ PElementClass class;
+ char *flags;
+ char *typename;
+ char *off;
+ char buf1[BUFSIZ];
+#ifdef DO_OFFSETS
+ char buf2[BUFSIZ];
+#endif
+ char buf3[BUFSIZ];
+
+ if (f == NULL || noindirect(f)) {
+ (void) sprintf(buf3, "S%s", p->univ_tab);
+ type = buf3;
+ } else
+ type = p->univ_tab;
+
+ if (yp->yp_flags & YP_TAG && yp->yp_flags & YP_IMPLICIT) {
+ tag = yp->yp_tag->yt_value->yv_number;
+ class = yp->yp_tag->yt_class;
+ } else {
+ tag = p->univ_id;
+ class = p->univ_class;
+ }
+
+ (void) strncpy(buf1, c_flags(yp, class), BUFSIZ);
+ flags = buf1;
+ if (mrose3) { /* need to append FL_PRTAG flag */
+ (void) strncat(buf1, "|FL_PRTAG", BUFSIZ);
+ }
+ if (mrose1)
+ typename = yp->yp_id;
+ else if (mrose2)
+ typename = yp->yp_identifier;
+ else
+ typename = (char *)0;
+#ifdef DO_OFFSETS
+ if (f && !noindirect(f)) {
+ (void) sprintf(buf2, "OFFSET(%s, %s)", t, f);
+ off = buf2;
+ } else if (f && *f == '&') {
+ (void) sprintf(buf2, "OFFSET(%s, %s)", t, f + 1);
+ off = buf2;
+ } else
+#endif
+ off = "0";
+ if (typename) {
+ int pindex = addsptr (typename);
+ (void) fprintf(fp, "\t{ %s, %s, %d, %s, (char **)&%s%s%s[%d] },\n",
+ type, off, tag, flags,
+ PREFIX, PTR_TABNAME, tab, pindex);
+ }
+ else
+ (void) fprintf(fp, "\t{ %s, %s, %d, %s, NULLVP },\n",
+ type, off, tag, flags);
+}
+
+/*
+ * generate the table entry for a value passing defined type which
+ * is equivalent to the given primative type
+ */
+gen_pentry(fp, oyp, yp, t, f)
+FILE *fp;
+YP oyp, yp;
+char *t, *f;
+{
+ char *p1;
+ register char s = oyp->yp_prfexp; /* type of value passing */
+ int idx;
+
+
+ if (noindirect(f) && s != 'q' && s != 'a')
+ ferrs(1,
+ "gen_ventry: must specify a field for primative value- not %s\n", f);
+
+#if 0
+/* can't get id from in here - yet */
+ if (yp->yp_code == YP_BITLIST) {
+ idx = addptr (modsym(mymodule, yp->yp_varexp ? yp -> yp_varexp : id,
+ "bits"));
+ } else
+#endif
+ idx = -1;
+
+ switch (s) {
+ case 'q': /* [[ q parm->qbufptr ]] */
+ if (yp->yp_code != YP_OCT)
+ warning("qbuf pointer passed for a %s by type %s",
+ code2name(yp->yp_code), yp2name(oyp));
+
+ f = setfield(oyp->yp_strexp);
+ if (noindirect(f))
+ p1 = "SOCTETSTRING";
+ else
+ p1 = "OCTETSTRING";
+ break;
+
+ case 's': /* [[ s ptr ]] */
+ if (yp->yp_code != YP_OCT)
+ warning("string pointer passed for a %s by type %s",
+ code2name(yp->yp_code), yp2name(oyp));
+
+ f = setfield(oyp->yp_strexp);
+ p1 = "T_STRING";
+ break;
+
+ case 'o': /* [[ o ptr $ length ]] */
+ if (yp->yp_code != YP_OCT)
+ warning("octet/length pair passed for a %s by type %s",
+ code2name(yp->yp_code), yp2name(oyp));
+ f = setfield(oyp->yp_strexp);
+ p1 = "OCTET_PTR";
+ prte_off(fp, p1, yp, t, f, idx);
+ if (oyp->yp_intexp)
+ f = setfield(oyp->yp_intexp);
+ if (noindirect(f))
+ ferr(1, "gen_ventry:OCT: must specify a field [[ s .. ]]\n");
+ p1 = "OCTET_LEN";
+ break;
+
+ case 'x': /* [[ x ptr $ length ]] */
+ if (yp->yp_code != YP_BIT && yp->yp_code != YP_BITLIST)
+ warning("bit string/length pair passed for a %s by type %s",
+ code2name(yp->yp_code), yp2name(oyp));
+
+ f = setfield(oyp->yp_strexp);
+ p1 = "BITSTR_PTR";
+ prte_off(fp, p1, yp, t, f, idx);
+ f = setfield(oyp->yp_intexp);
+ if (noindirect(f))
+ ferr(1, "tenc_typ:BIT: must specify a field [[ x .. ]]\n");
+ p1 = "BITSTR_LEN";
+ break;
+
+ case 'r': /* [[ r REAL ]] */
+ if (yp->yp_code != YP_REAL)
+ warning("Real passed for a %s by type %s",
+ code2name(yp->yp_code), yp2name(oyp));
+
+ f = setfield(oyp->yp_strexp);
+ p1 = "REALTYPE";
+ break;
+
+ case 'i': /* [[ i INTEGER ]] */
+ if (yp->yp_code != YP_INT && yp->yp_code != YP_INTLIST
+ && yp->yp_code != YP_ENUMLIST)
+ warning("integer passed for a %s by type %s",
+ code2name(yp->yp_code), yp2name(oyp));
+
+ if (oyp->yp_intexp)
+ f = setfield(oyp->yp_intexp);
+ p1 = "INTEGER";
+ break;
+
+ case 't': /* [[ t Bitvector ]] */
+ if (yp->yp_code != YP_BIT && yp->yp_code != YP_BITLIST)
+ warning("Bitvector (PE) passed for a %s by type %s",
+ code2name(yp->yp_code), yp2name(oyp));
+
+ f = setfield(oyp->yp_intexp);
+ if (oyp->yp_varexp && !noindirect(f))
+ p1 = "BITSTRING";
+ else
+ p1 = "SBITSTRING";
+ break;
+
+ case 'b': /* [[ b BOOLEAN ]] */
+ if (yp->yp_code != YP_BOOL)
+ warning("Boolean passed for a %s by type %s",
+ code2name(yp->yp_code), yp2name(oyp));
+
+ if (oyp->yp_intexp)
+ f = setfield(oyp->yp_intexp);
+ p1 = "BOOLEAN";
+ break;
+
+ case 'O': /* [[ O Object Identifier ]] */
+ if (yp->yp_code != YP_OID)
+ warning("Object Identifier pointer passed for a %s by type %s",
+ code2name(yp->yp_code), yp2name(oyp));
+ f = setfield(oyp->yp_strexp);
+ p1 = "OBJID";
+ break;
+
+ case 'a': /* [[ a ANY ]] */
+ if (yp->yp_code != YP_ANY)
+ warning("PE pointer passed for a %s by type %s",
+ code2name(yp->yp_code), yp2name(oyp));
+ f = setfield(oyp->yp_strexp);
+ if (noindirect(f))
+ p1 = "SANY";
+ else
+ p1 = "ANY";
+ break;
+ default:
+ ferrd(1, "gen_vident:unknown Value passed %d\n", (int )s);
+ }
+
+ prte_off(fp, p1, yp, t, f, idx);
+}
+
+int addsptr (s)
+char *s;
+{
+ char buf[BUFSIZ];
+
+ (void) sprintf (buf, "\"%s\"", s);
+ return addptr (buf);
+}
diff --git a/src/isode/pepsy/py_advise.c b/src/isode/pepsy/py_advise.c
new file mode 100644
index 000000000..f588ea579
--- /dev/null
+++ b/src/isode/pepsy/py_advise.c
@@ -0,0 +1,66 @@
+/* py_advise.c - standard "advise" routine for pepsy/pepy */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:31:34 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:40:28 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:43:15 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include <varargs.h>
+
+/* */
+
+#ifndef lint
+char PY_pepy[BUFSIZ];
+
+
+void PY_advise (va_alist)
+va_dcl
+{
+ va_list ap;
+
+ va_start (ap);
+
+ asprintf (PY_pepy, ap);
+
+ va_end (ap);
+}
+#else
+/* VARARGS */
+
+void PY_advise (what, fmt)
+char *what,
+ *fmt;
+{
+ PY_advise (what, fmt);
+}
+#endif
diff --git a/src/isode/pepsy/sym.h b/src/isode/pepsy/sym.h
new file mode 100644
index 000000000..232b6ba40
--- /dev/null
+++ b/src/isode/pepsy/sym.h
@@ -0,0 +1,43 @@
+/* sym.h */
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:31:36 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:40:30 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:43:16 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+typedef struct symlist {
+ char *sy_encpref;
+ char *sy_decpref;
+ char *sy_prfpref;
+ char *sy_module;
+ char *sy_name;
+
+ YP sy_type;
+
+ struct symlist *sy_next;
+} symlist, *SY;
+#define NULLSY ((SY) 0)
+
diff --git a/src/isode/pepsy/t1.py b/src/isode/pepsy/t1.py
new file mode 100644
index 000000000..0380e5e66
--- /dev/null
+++ b/src/isode/pepsy/t1.py
@@ -0,0 +1,391 @@
+-- $Header$
+--
+--
+-- $Log$
+-- Revision 1.1 1994/06/10 03:31:38 eichin
+-- autoconfed isode for kerberos work
+--
+# Revision 1.1 1994/05/31 20:40:32 eichin
+# reduced-isode release from /mit/isode/isode-subset/src
+#
+-- Revision 8.0 91/07/17 12:43:16 isode
+-- Release 7.0
+--
+--
+
+--
+-- NOTICE
+--
+-- Acquisition, use, and distribution of this module and related
+-- materials are subject to the restrictions of a license agreement.
+-- Consult the Preface in the User's Manual for the full terms of
+-- this agreement.
+--
+--
+
+
+T1 { joint-iso-ccitt rubbish(999) modid(1) } DEFINITIONS ::=
+
+
+BEGIN
+
+IMPORTS
+ + Info,
+ + Sset,
+ + Sseq,
+ - Sany,
+ + Soid
+ FROM T2
+ Pepy-refs,
+ Single-type,
+ Repeated,
+ Defined,
+ CodeTest,
+ AllSimples,
+ UAction
+ FROM T3;
+
+-- Embedded Sequences test
+
+
+ -- Test of Embedded Strings
+Emb-Strings ::= SEQUENCE {
+ atest INTEGER,
+ btest OCTET STRING,
+ ctest BIT STRING,
+ big-test Strings,
+ emb-test SEQUENCE {
+ em-int INTEGER,
+ em-oct OCTET STRING,
+ em-bit BIT STRING
+ }
+ }
+
+
+Strings ::= SEQUENCE { -- Test Octet strings, bit strings and character
+ -- Strings in general
+ ostring OCTET STRING,
+ bstring BIT STRING,
+ nstring NumericString,
+ pstring PrintableString,
+ tstring TeletexString,
+ t61string T61String,
+ vstring VideotexString,
+ vis-string VisibleString,
+ i646string ISO646String,
+ ia5string IA5String,
+ graphstring GraphicString,
+ genstring GeneralString
+ }
+
+Embedded ::= SEQUENCE {
+ anMPDU MPDU,
+ ei INTEGER
+ }
+
+MPDU ::=
+ SEQUENCE {
+ a-seq SEQUENCE {
+ fred [0] IMPLICIT INTEGER,
+
+ george BOOLEAN
+ }
+ }
+
+ServiceMPDU ::=
+ SET {
+ a-set SET {
+ a-data [1] IMPLICIT BIT STRING,
+
+ a-more-data [2] IMPLICIT INTEGER
+ },
+ b-set SET {
+ b-data [1] IMPLICIT BIT STRING,
+
+ b-more-data [2] IMPLICIT INTEGER
+ }
+ }
+-- Implicit tags
+
+Impl-Tags ::= SEQUENCE {
+ i-impl [1] IMPLICIT INTEGER,
+ o-impl [2] IMPLICIT OCTET STRING,
+ b-impl [3] IMPLICIT BIT STRING,
+ f-impl [4] IMPLICIT BOOLEAN,
+ obj-impl [5] IMPLICIT Emb-Strings,
+
+ -- Test of Embedded Strings
+ i-emb-test [APPLICATION 88] IMPLICIT SEQUENCE {
+ i-em-int INTEGER,
+ i-em-oct OCTET STRING,
+ i-em-bit BIT STRING
+ }
+ }
+
+-- Explicit tags
+
+Expl-Tags ::= SEQUENCE {
+ i-expl [1] INTEGER,
+ o-expl [2] OCTET STRING,
+ b-expl [3] BIT STRING,
+ f-expl [4] BOOLEAN,
+ obj-expl [5] Emb-Strings,
+
+ -- Test of Embedded Strings
+ i-exp-test [APPLICATION 88] SEQUENCE {
+ i-ex-int INTEGER,
+ i-ex-oct OCTET STRING,
+ i-ex-bit BIT STRING
+ }
+ }
+
+ -- Test of Sequence of
+Seqof-Test ::= SEQUENCE {
+ sqof-test1 SEQUENCE OF Expl-Tags,
+ stof-test1 SET OF Expl-Tags,
+ i-test1 INTEGER,
+ sqof-test2 SEQUENCE OF SEQUENCE {
+ sqof-in Expl-Tags,
+ sqof-i INTEGER,
+ sqof-o OCTET STRING
+ },
+ stof-test2 SET OF SEQUENCE {
+ stof-in Expl-Tags,
+ stof-i INTEGER,
+ stof-o OCTET STRING
+ },
+ i-test2 INTEGER
+ }
+
+
+ -- Test data for the Choice type
+Choice-Test ::= SET {
+ c1 CHOICE {
+ i-c1 [1] IMPLICIT INTEGER,
+ o-c1 [2] IMPLICIT OCTET STRING,
+ b-c1 [3] IMPLICIT BIT STRING,
+ f-c1 [4] IMPLICIT BOOLEAN,
+ obj-c1 [5] IMPLICIT Emb-Strings
+ },
+ c2 CHOICE {
+ i-c2 [6] INTEGER,
+ o-c2 [7] OCTET STRING,
+ b-c2 [8] BIT STRING,
+ f-c2 [9] BOOLEAN,
+ obj-c2 [10] Emb-Strings
+ },
+ c3 CHOICE {
+ seq-c3 SEQUENCE {
+ seq-c3-in Expl-Tags,
+ seq-c3-i INTEGER,
+ seq-c3-o OCTET STRING
+ },
+ set-c3 SET {
+ set-c3-in Expl-Tags,
+ set-c3-i INTEGER,
+ set-c3-o OCTET STRING
+ },
+ i-c3 INTEGER
+ },
+ c4 [12] IMPLICIT SEQUENCE {
+ c4-choice CHOICE {
+ c4-i INTEGER,
+ c4-obj [2] IMPLICIT Expl-Tags,
+ c4-subch CHOICE {
+ sc-a-i [0] IMPLICIT INTEGER,
+ sc-b-i [1] IMPLICIT INTEGER
+ }
+ }
+ }
+
+
+ }
+
+ -- Test of Optional fields
+
+Opt-Strings ::= SEQUENCE {
+ a-opt INTEGER OPTIONAL,
+ b-opt OCTET STRING,
+ c-opt BIT STRING OPTIONAL,
+ d-opt BOOLEAN OPTIONAL,
+ e-opt NULL OPTIONAL,
+ big-opt Strings OPTIONAL,
+ emb-opt SEQUENCE {
+ oem-int INTEGER OPTIONAL,
+ oem-oct OCTET STRING OPTIONAL,
+ oem-bit BIT STRING OPTIONAL
+ } OPTIONAL,
+ st-opt SET {
+ st-int0 [0] IMPLICIT INTEGER OPTIONAL,
+ st-int1 [1] IMPLICIT INTEGER OPTIONAL,
+ st-int2 [2] IMPLICIT INTEGER OPTIONAL
+ } OPTIONAL,
+ obj-opt [APPLICATION 1] IMPLICIT MPDU OPTIONAL,
+ etag-opt [APPLICATION 2] INTEGER OPTIONAL,
+ ch-opt CHOICE {
+ ch-1 [10] IMPLICIT INTEGER,
+ ch-2 [20] IMPLICIT INTEGER
+ } OPTIONAL
+ }
+
+ -- Test of Default fields
+
+Def-Strings ::= SEQUENCE {
+ a-def INTEGER { a-def-0 (0), a-def-1(1) } DEFAULT a-def-0,
+ -- posy bug does not allow handling of 'xxx'b or 'xx'h notation
+ -- so we don't use proper posy notation
+ -- b-def OCTET STRING DEFAULT 'ff01ab20'h,
+ b-def PrintableString DEFAULT "hello, world",
+ c-def BIT STRING { c-def-one(3), c-def-two (1)}
+ DEFAULT { c-def-one },
+ okay BOOLEAN DEFAULT TRUE,
+ e-def NULL DEFAULT NULL,
+ big-def Strings,
+ emb-def SEQUENCE {
+ colour INTEGER { red(1), green(2), yellow(3) } DEFAULT green,
+ oem-oct OCTET STRING OPTIONAL,
+ version BIT STRING { basic(0), patch1(1), patch2(2) }
+ DEFAULT { basic }
+ } DEFAULT { red, { basic } },
+ st-def SET {
+ wine [0] IMPLICIT INTEGER { claret(1), burgundy(2), moselle(3) }
+ DEFAULT claret,
+ beer [1] IMPLICIT INTEGER { vb(0), fosters(1), hieneken(2) }
+ DEFAULT vb,
+ spirit [2] IMPLICIT INTEGER { brandy(0), vodka(1), wisky(2) }
+ DEFAULT vodka
+ } DEFAULT { vb, vodka }
+ }
+
+-- External References
+--
+E-ref ::= SEQUENCE {
+ a-ref T2.Info,
+ b-ref [APPLICATION 33] IMPLICIT T2.Info,
+ c-ref [1] T1.Choice-Test,
+ d-ref [2] T2.Info OPTIONAL,
+ e-ref [APPLICATION 33] IMPLICIT T2.Info OPTIONAL
+ }
+
+
+-- Simple type optimisations of POSY/PEPY
+
+ Bstring ::= [APPLICATION 8] BIT STRING
+
+ Ostring ::= [31] IMPLICIT OCTET STRING
+
+ Obj ::= [101] IMPLICIT MPDU
+
+ Sset ::= SET
+
+ Sseq ::= SEQUENCE
+
+ Sany ::= ANY
+
+ Soid ::= OBJECT IDENTIFIER
+
+
+Optimised ::= SEQUENCE {
+ o1 Bstring,
+ o2 Ostring,
+ o3 Obj,
+ o4 [APPLICATION 3] IMPLICIT Sset OPTIONAL,
+ [APPLICATION 21] SET {
+ o5 [PRIVATE 9] IMPLICIT Sseq,
+ o6 [PRIVATE 33] IMPLICIT Sany,
+ o7 [PRIVATE 8] IMPLICIT Soid
+ }
+}
+
+-- Use of External Simple types
+Ext-Opt ::= SEQUENCE {
+ o1 T2.Bstring,
+ o2 T2.Ostring,
+ o3 T2.Obj,
+ o4 [PRIVATE 38] IMPLICIT T2.Sset OPTIONAL,
+ [APPLICATION 21] SET {
+ o5 [PRIVATE 1] IMPLICIT T2.Sseq,
+ o6 [PRIVATE 2] IMPLICIT T2.Sany,
+ o7 [PRIVATE 3] IMPLICIT T2.Soid
+ }
+}
+
+-- External type and ANY usage
+
+Ext-typ ::= SEQUENCE {
+ ext EXTERNAL,
+ a-ny [APPLICATION 32] ANY,
+ ext-impl [PRIVATE 6] IMPLICIT EXTERNAL,
+ any-impl [APPLICATION 7] ANY,
+ ext-expl [PRIVATE 9] EXTERNAL,
+ any-expl [APPLICATION 10] ANY
+ }
+
+SExt ::= [PRIVATE 99] IMPLICIT EXTERNAL
+
+-- check of posy's %[ name $ head %] stuff
+Names ::=
+ SEQUENCE {
+ SEQUENCE %[ seq_str $ ptr %] {
+ fred [0] IMPLICIT INTEGER
+ }
+ }
+
+-- Test explicit tags as the first field of an object
+Etags ::=
+ [APPLICATION 3]
+ CHOICE {
+ aE [0] IMPLICIT INTEGER,
+ bE [1] IMPLICIT INTEGER
+ }
+
+Stest ::=
+ [APPLICATION 4] SET {
+ st1 Sint DEFAULT 33,
+ st2 Soctet DEFAULT "goodbye, world"
+ }
+
+Sint ::= INTEGER
+
+Soctet ::= OCTET STRING
+
+Simpl-test ::= SEQUENCE { si-t [23] IMPLICIT Sbstring }
+
+Sbstring ::= BIT STRING { bit0(0), bit1(1), bit2(2) }
+
+SStest ::= [101] IMPLICIT Simpl-test
+
+Enum-type ::= ENUMERATED { pork(0), beef(1), chicken(3), lamb(-1) }
+
+T-enum ::= SEQUENCE {
+ ae1 Enum-type,
+ ae2 [12] Enum-type,
+ ae3 [13] IMPLICIT Enum-type,
+ ae4 [15] IMPLICIT Enum-type DEFAULT chicken,
+ ae5 Enum-type OPTIONAL
+ }
+Real ::= REAL
+
+T-real ::= SEQUENCE {
+ r1 Real,
+ r2 [99] Real,
+ r3 [101] IMPLICIT Real,
+ r4 [501] IMPLICIT Real DEFAULT { 31415962, 10, -7 },
+ r5 Real OPTIONAL
+ }
+
+T-pepy ::= T3.Pepy-refs
+
+T3-Single ::= T3.Single-type
+
+T3-Repeat ::= T3.Repeated
+
+T3-Defined ::= T3.Defined
+
+T3-CodeTest ::= T3.CodeTest
+
+T3-AllSimples ::= T3.AllSimples
+
+T3-UAction ::= T3.UAction
+
+END
diff --git a/src/isode/pepsy/t2.py b/src/isode/pepsy/t2.py
new file mode 100644
index 000000000..0e5393884
--- /dev/null
+++ b/src/isode/pepsy/t2.py
@@ -0,0 +1,69 @@
+-- $Header$
+--
+--
+-- $Log$
+-- Revision 1.1 1994/06/10 03:31:40 eichin
+-- autoconfed isode for kerberos work
+--
+# Revision 1.1 1994/05/31 20:40:34 eichin
+# reduced-isode release from /mit/isode/isode-subset/src
+#
+-- Revision 8.0 91/07/17 12:43:17 isode
+-- Release 7.0
+--
+--
+
+--
+-- NOTICE
+--
+-- Acquisition, use, and distribution of this module and related
+-- materials are subject to the restrictions of a license agreement.
+-- Consult the Preface in the User's Manual for the full terms of
+-- this agreement.
+--
+--
+
+
+
+T2 DEFINITIONS ::=
+
+
+BEGIN
+
+-- Embedded Sequences test
+
+
+SECTIONS enc dec prnt
+
+Info ::= SEQUENCE {
+ a1 [0] IMPLICIT INTEGER,
+ a2 [1] IMPLICIT INTEGER,
+ a3 [2] IMPLICIT INTEGER,
+ a4 MPDU
+ }
+
+MPDU ::=
+ SEQUENCE {
+ a-seq SEQUENCE {
+ fred [0] IMPLICIT INTEGER
+
+ }
+ }
+
+-- Simple type optimisations of POSY/PEPY
+
+ Bstring ::= [APPLICATION 8] BIT STRING
+
+ Ostring ::= [31] IMPLICIT OCTET STRING
+
+ Obj ::= [101] IMPLICIT MPDU
+
+ Sset ::= SET
+
+ Sseq ::= SEQUENCE
+
+ Sany ::= ANY
+
+ Soid ::= OBJECT IDENTIFIER
+
+END
diff --git a/src/isode/pepsy/t3.py b/src/isode/pepsy/t3.py
new file mode 100644
index 000000000..9b7759e2d
--- /dev/null
+++ b/src/isode/pepsy/t3.py
@@ -0,0 +1,513 @@
+-- $Header$
+--
+--
+-- $Log$
+-- Revision 1.1 1994/06/10 03:31:42 eichin
+-- autoconfed isode for kerberos work
+--
+# Revision 1.1 1994/05/31 20:40:36 eichin
+# reduced-isode release from /mit/isode/isode-subset/src
+#
+-- Revision 8.0 91/07/17 12:43:17 isode
+-- Release 7.0
+--
+--
+
+--
+-- NOTICE
+--
+-- Acquisition, use, and distribution of this module and related
+-- materials are subject to the restrictions of a license agreement.
+-- Consult the Preface in the User's Manual for the full terms of
+-- this agreement.
+--
+--
+
+
+
+T3 DEFINITIONS ::=
+
+%{
+/*
+ * this stuff is to test the verbatim actions at the start of the
+ * type definitions
+ */
+%}
+
+BEGIN
+
+
+
+Pepy-refs [[ P struct pepy_refs * ]] ::= SEQUENCE {
+ [1] IMPLICIT INTEGER [[ i parm->t_int ]],
+ [2] IMPLICIT ENUMERATED [[ i parm->t_enum ]] {
+ orange(1), apple(2), pear(3), bannana(4) },
+
+ [3] IMPLICIT OCTET STRING [[ q parm->t_qbuf ]],
+ [4] IMPLICIT OCTET STRING [[ s parm->t_string ]],
+ [5] IMPLICIT OCTET STRING [[ o parm->t_ostring $ parm->t_olen ]],
+ [6] IMPLICIT BIT STRING [[ t parm->t_pe ]],
+ [7] IMPLICIT BIT STRING [[ x parm->t_bstring $ t_blen ]],
+ [8] IMPLICIT BOOLEAN [[ b parm->t_bool ]],
+ [9] IMPLICIT OBJECT IDENTIFIER [[ O parm->t_oid ]],
+ [10] IMPLICIT REAL [[ r parm->t_real ]],
+ [11] ANY [[ a parm->t_any ]],
+ [12] Def-types [[ p parm->t_def ]],
+ [13] Opt-types [[ p parm->t_opt ]] OPTIONAL
+
+ }
+
+-- Optional and Default test cases
+
+Def-types [[ P struct pepy_refs1 * ]] ::= SEQUENCE {
+ [1] INTEGER [[ i parm->t_int ]] DEFAULT 2,
+ [2] IMPLICIT INTEGER [[ i parm->t_int1 ]] DEFAULT 2,
+ [3] IMPLICIT ENUMERATED [[ i parm->t_enum ]]
+ { orange(1), apple(2), pear(3), bannana(4) } DEFAULT pear,
+
+ [4] ENUMERATED [[ i parm->t_enum1 ]] {
+ orange(1), apple(2), pear(3), bannana(4) } DEFAULT pear,
+ [5] IMPLICIT OCTET STRING [[ q parm->t_qbuf ]]
+ DEFAULT '536f6d65206973206f757420746865726521'H,
+ [6] OCTET STRING [[ q parm->t_qbuf1 ]]
+ DEFAULT '536f6d65206973206f757420746865726521'H,
+ [7] IMPLICIT OCTET STRING [[ s parm->t_string ]] DEFAULT '003132'h,
+ [8] OCTET STRING [[ s parm->t_string1 ]] DEFAULT '003132'h,
+ [9] IMPLICIT OCTET STRING [[ o parm->t_ostring $ parm->t_olen ]]
+ DEFAULT 'ff01ab20'h,
+ [10] OCTET STRING [[ o parm->t_ostring1 $ parm->t_olen1 ]]
+ DEFAULT 'ff01ab20'h,
+ [11] IMPLICIT BIT STRING [[ t parm->t_pe ]]
+ DEFAULT '00010010001100010001101000110111001010101'B,
+ [12] BIT STRING [[ t parm->t_pe1 ]]
+ DEFAULT '00010010001100010001101000110111001010101'B,
+ [13] IMPLICIT BIT STRING [[ x parm->t_bstring $ t_blen ]]
+ DEFAULT '00000000001100010011001000110011'B,
+ [14] BIT STRING [[ x parm->t_bstring1 $ t_blen1 ]]
+ DEFAULT '00000000001100010011001000110011'B,
+ [15] IMPLICIT BOOLEAN [[ b parm->t_bool ]] DEFAULT TRUE,
+ [16] BOOLEAN [[ b parm->t_bool ]] DEFAULT TRUE,
+ [17] IMPLICIT OBJECT IDENTIFIER [[ O parm->t_oid ]], -- one day DEFAULT 1.17.42,
+ [18] OBJECT IDENTIFIER [[ O parm->t_oid1 ]] OPTIONAL, -- one day DEFAULT 1.17.42,
+ [19] IMPLICIT REAL [[ r parm->t_real ]] DEFAULT { 306998, 10, -5 },
+ [20] REAL [[ r parm->t_real1 ]] DEFAULT { 306998, 10, -5 },
+ [21] ANY [[ a parm->t_any ]] OPTIONAL
+
+ }
+
+Opt-types [[ P struct pepy_refs1 * ]] ::= SEQUENCE {
+ [1] IMPLICIT INTEGER [[ i parm->t_int ]] OPTIONAL << opt_set $ OPT_INT1 >>,
+ [2] INTEGER [[ i parm->t_int1 ]] OPTIONAL << opt_set $ OPT_INT2 >>,
+ [3] IMPLICIT ENUMERATED [[ i parm->t_enum ]] {
+ orange(1), apple(2), pear(3), bannana(4) } OPTIONAL << opt_set $ OPT_ENUM1 >>,
+ [4] ENUMERATED [[ i parm->t_enum1 ]] {
+ orange(1), apple(2), pear(3), bannana(4) } OPTIONAL << opt_set $ OPT_ENUM2 >>,
+
+ [5] IMPLICIT OCTET STRING [[ q parm->t_qbuf ]] OPTIONAL,
+ [6] OCTET STRING [[ q parm->t_qbuf1 ]] OPTIONAL,
+ [7] IMPLICIT OCTET STRING [[ s parm->t_string ]] OPTIONAL,
+ [8] OCTET STRING [[ s parm->t_string1 ]] OPTIONAL,
+ [9] IMPLICIT OCTET STRING [[ o parm->t_ostring $ parm->t_olen ]]
+ OPTIONAL,
+ [10] OCTET STRING [[ o parm->t_ostring1 $ parm->t_olen1 ]]
+ OPTIONAL,
+ [11] IMPLICIT BIT STRING [[ t parm->t_pe ]] OPTIONAL,
+ [12] BIT STRING [[ t parm->t_pe1 ]] OPTIONAL,
+ [13] IMPLICIT BIT STRING [[ x parm->t_bstring $ t_blen ]] OPTIONAL,
+ [14] BIT STRING [[ x parm->t_bstring1 $ t_blen1 ]] OPTIONAL,
+ [15] IMPLICIT BOOLEAN [[ b parm->t_bool ]] OPTIONAL << opt_set $ OPT_BOOL1>>,
+ [16] BOOLEAN [[ b parm->t_bool1 ]] OPTIONAL << opt_set $ OPT_BOOL2>>,
+ [17] IMPLICIT OBJECT IDENTIFIER [[ O parm->t_oid ]], -- one day OPTIONAL,
+ [18] IMPLICIT REAL [[ r parm->t_real ]] OPTIONAL << opt_set $ OPT_REAL1 >>,
+ [19] REAL [[ r parm->t_real1 ]] OPTIONAL << opt_set $ OPT_REAL2 >>,
+ [20] ANY [[ a parm->t_any ]]
+
+ }
+
+ Single-type [[ P struct pepy_refs1 * ]] ::= SEQUENCE {
+ a SEQUENCE [[ T struct pepy_refs1 * $ * ]] {
+ [1] IMPLICIT INTEGER [[ i parm->t_int ]] OPTIONAL << opt_set $ OPT_INT1 >>
+ },
+ b SEQUENCE [[ T struct pepy_refs1 * $ * ]] {
+ [2] INTEGER [[ i parm->t_int1 ]] OPTIONAL << opt_set $ OPT_INT2 >>
+ },
+
+ c SET [[ T struct pepy_refs1 * $ *parm ]] {
+ [3] IMPLICIT ENUMERATED [[ i parm->t_enum ]] {
+orange(1), apple(2), pear(3), bannana(4) } OPTIONAL << opt_set $ OPT_ENUM1 >>
+ },
+ d SET [[ T struct pepy_refs1 * $ *parm ]] {
+ [4] ENUMERATED [[ i parm->t_enum1 ]] {
+orange(1), apple(2), pear(3), bannana(4) } OPTIONAL << opt_set $ OPT_ENUM2 >>
+ }
+ }
+
+ Repeated [[ P struct repeats * ]]::= SEQUENCE {
+ a SEQUENCE OF [[ T struct rep_int * $ rp_sq1 ]]
+ <<r>> [1] INTEGER [[ i i ]],
+
+ b SEQUENCE OF [[ T struct rep_elem * $ rp_sq2 ]] <<r_next>>
+ Rep-elem [[ p * ]],
+
+ c SET OF [[ T struct rep_int * $ rp_st1 ]] <<r>> INTEGER [[ i i ]],
+
+ d SET OF [[ T struct rep_elem * $ rp_st2 ]] <<r_next>>
+ [3] IMPLICIT Rep-elem [[ p * ]],
+
+ e CHOICE [[ T struct repeats * $ * ]] <<rp_choice>> {
+ [1] INTEGER [[ i rp_int ]],
+ [2] BOOLEAN [[ b rp_bool ]],
+ [3] OCTET STRING [[ o rp_ostring $ rp_int ]]
+ }
+ }
+
+ Rep-elem [[ P struct rep_elem * ]]
+ ::= SEQUENCE {
+ a INTEGER [[ i r_int ]],
+ b OCTET STRING [[ s r_ostring ]],
+ c BIT STRING [[ x r_bstring $ r_int ]]
+ }
+
+ Defined [[ P struct pepy_refs * ]] ::=
+ SEQUENCE {
+ a PrintableString [[ s t_string ]],
+ b [ APPLICATION 3 ] AString [[ q t_qbuf ]],
+ c [ APPLICATION 3 ] IMPLICIT AnOctetString [[ o t_ostring $ t_olen ]],
+ d BitsAndPieces [[ x t_bstring $ t_blen ]],
+ e AnAny [[ a t_any ]],
+ ABitString [[ t t_pe ]],
+ AnotherType [[ i t_int ]],
+ [12] AReal [[ r t_real ]],
+ [99] IMPLICIT AnOID [[ O t_oid ]],
+ [13] IMPLICIT Boodles [[ b t_bool ]],
+ AnEnumerated [[ i t_enum ]]
+ }
+
+ AString ::= GraphicString
+
+ AnOctetString ::= OCTET STRING
+
+ BitsAndPieces ::= [31] SomeBits
+
+ SomeBits ::= [APPLICATION 10] IMPLICIT ABitString
+
+ ABitString ::= BIT STRING
+
+ AnAny ::= ANY
+
+ AnotherType ::= [21] AnInteger
+
+ AnInteger ::= INTEGER
+
+ AReal ::= REAL
+
+ AnOID ::= OBJECT IDENTIFIER
+
+ Boodles ::= [PRIVATE 9] ABoolean
+
+ ABoolean ::= [APPLICATION 12] BOOLEAN
+
+ AnEnumerated ::= [4] ENUMERATED { orange(1), apple(2), pear(3), bannana(4) }
+ -- Coding functions tests
+
+ CodeTest [[ P struct codedata * ]] ::= SEQUENCE {
+ a BasicANY [[ p cd_a ]],
+ b [42] E-ANY [[ p cd_b ]],
+ c [36] D-ANY [[ p cd_c ]],
+ d DE-ANY [[ p cd_d ]],
+ e [APPLICATION 44] IMPLICIT INTEGER [[ i cd_int ]]
+ [[ E get_int ]] [[ D put_int ]] DEFAULT 1,
+ f [17] GraphicString [[ s cd_string ]]
+ [[ E get_string ]][[ D put_string ]] [[ F fr_string ]] OPTIONAL,
+ left CodeOpt [[ p cd_left ]] OPTIONAL,
+ right CodeDflt [[ p cd_right ]] OPTIONAL
+ }
+
+ BasicANY ::= ANY [[ a * ]]
+
+ E-ANY ::= ANY [[ a * ]] [[ E get_pe ]]
+
+ D-ANY ::= ANY [[ a * ]] [[ D put_pe ]] [[ F fr_pe ]]
+
+ DE-ANY ::= ANY [[ a * ]] [[ D put_pe ]] [[ E get_pe ]]
+
+ CodeOpt [[ P struct codedata * ]] ::= SEQUENCE {
+ a [PRIVATE 5] BasicANY [[ p cd_a ]] OPTIONAL,
+ b [35] E-ANY [[ p cd_b ]] OPTIONAL,
+ c [45] EXPLICIT D-ANY [[ p cd_c ]] OPTIONAL <<cd_opt_set $ CD_C>>,
+ d [1] DE-ANY [[ p cd_d ]] OPTIONAL <<cd_opt_set $ CD_D>>,
+ e [15] IMPLICIT INTEGER [[ i cd_int ]] [[ E get_int ]] [[ D put_int ]]
+ OPTIONAL << cd_opt_set $ CD_INT >>,
+ f GraphicString [[ s cd_string ]] [[ E get_string ]][[ D put_string ]]
+ OPTIONAL
+ }
+
+ -- It would be nice to do DEFAULTs for ANY but how do we specify
+ -- DEFAULT ANY in the ASN.1 ?? Let alone parse it
+
+ CodeDflt [[ P struct codedata * ]] ::= SEQUENCE {
+ a [1] BasicANY [[ p cd_a ]] OPTIONAL,
+ b [2] E-ANY [[ p cd_b ]] OPTIONAL,
+ c [3] D-ANY [[ p cd_c ]] OPTIONAL <<cd_opt_set $ CD_C>>,
+ d [4] DE-ANY [[ p cd_d ]] OPTIONAL <<cd_opt_set $ CD_D>>,
+ e [APPLICATION 4] INTEGER [[ i cd_int ]] [[ E get_int ]] [[ D put_int ]]
+ DEFAULT 3,
+ f [90] IMPLICIT GraphicString [[ s cd_string ]] [[ E get_string2 ]]
+ [[ D put_string2 ]] DEFAULT '536f6d65206973206f7574'H
+ }
+
+ Simple1 [[ P struct codedata * ]] ::= CodeDflt [[ p cd_right ]]
+
+ Simple2 [[ P struct codedata * ]] ::= INTEGER [[ i cd_int ]]
+
+ Simple3 [[ P struct codedata * ]] ::= [1] INTEGER [[ i cd_int1 ]]
+
+ Simple4 [[ P struct codedata * ]] ::= [1] IMPLICIT INTEGER [[ i cd_int2 ]]
+
+ Simple5 [[ P struct codedata * ]] ::= OCTET STRING [[ s cd_string ]]
+
+ Simple6 [[ P struct codedata * ]] ::= [1] OCTET STRING [[ s cd_string1 ]]
+
+ Simple7 [[ P struct codedata * ]] ::= [1] IMPLICIT OCTET STRING
+ [[ s cd_string2 ]]
+
+ Simple8 [[ P struct codedata * ]] ::= OBJECT IDENTIFIER [[ O cd_oid ]]
+
+ Simple9 [[ P struct codedata * ]] ::= [1] OBJECT IDENTIFIER [[ O cd_oid1 ]]
+
+ Simple10 [[ P struct codedata * ]] ::= [1] IMPLICIT OBJECT IDENTIFIER
+ [[ O cd_oid2 ]]
+
+ Simple11 [[ P struct codedata * ]] ::= ANY [[ a cd_a ]]
+
+ Simple12 [[ P struct codedata * ]] ::= BIT STRING [[ t cd_bit ]]
+
+ Simple13 [[ P struct codedata * ]] ::= REAL [[ r cd_real ]]
+
+ Simple14 [[ P struct codedata * ]] ::= BOOLEAN [[ b cd_bool ]]
+
+ AllSimples [[ P struct codedata * ]] ::= SEQUENCE {
+
+ a Simple1 [[ p * ]],
+ b Simple2 [[ p * ]],
+ c Simple3 [[ p * ]],
+ d Simple4 [[ p * ]],
+ e Simple5 [[ p * ]],
+ f Simple6 [[ p * ]],
+ g Simple7 [[ p * ]],
+ h Simple8 [[ p * ]],
+ i Simple9 [[ p * ]],
+ j Simple10 [[ p * ]],
+ k Simple11 [[ p * ]],
+ l Simple12 [[ p * ]],
+ m Simple13 [[ p * ]],
+ n Simple14 [[ p * ]]
+
+ }
+
+ UAction [[ P struct repeats * ]]::= SEQUENCE {
+ a SEQUENCE OF [[ T struct rep_int * $ rp_sq1 ]]
+ <<r>> [1] INTEGER [[ i i ]],
+
+ b SEQUENCE OF [[ T struct rep_elem * $ rp_sq2 ]] <<r_next>>
+ Rep-action [[ p * ]],
+
+ c SET OF [[ T struct rep_int * $ rp_st1 ]] <<r>> INTEGER [[ i i ]],
+
+ d SET OF [[ T struct rep_elem * $ rp_st2 ]] <<r_next>>
+ %E{ (void) printf("encoding SET OF Rep-action\n");%}
+ [3] IMPLICIT Rep-action [[ p * ]],
+
+ e CHOICE [[ T struct repeats * $ * ]] <<rp_choice>> {
+ %D{ (void) printf("Before Encoding CHOICE\n"); %}
+ [1] INTEGER [[ i rp_int ]],
+ [2]
+ %E{ (void) printf("encoding Boolean %d\n", parm->rp_bool);%}
+ BOOLEAN [[ b rp_bool ]]
+ %D{ (void) printf("Decoding Boolean\n"); %},
+ [3] OCTET STRING [[ o rp_ostring $ rp_int ]]
+ }
+ %D{ (void) printf("After Decoding CHOICE: chosen %d\n", (*parm)->rp_choice); %}
+ } %D{ (void) printf("After Decoding UAction\n"); %}
+
+ Rep-action [[ P struct rep_elem * ]]
+ ::=
+ %D{ (void) printf("Before Decoding Rep-action\n"); %}
+ SEQUENCE {
+ %E{ (void) printf("before encoding INTEGER %d\n", parm->r_int);%}
+ a INTEGER [[ i r_int ]],
+ %E{ (void) printf("before encoding OCTET STRING \"%s\"\n",
+ parm->r_ostring);
+ %}
+ b OCTET STRING [[ s r_ostring ]],
+ %E{
+ int i;
+
+ (void) printf("before encoding BIT STRING: ");
+ for (i = 0; i < parm->r_int; i++) {
+ if (BITTEST(parm->r_bstring, i))
+ (void) putchar('1');
+ else
+ (void) putchar('0');
+ }
+ (void) putchar('\n');
+
+ %}
+ c BIT STRING [[ x r_bstring $ r_int ]]
+ %E{
+ (void) printf("After Bitstring encoding:");
+ vunknown(*ppe);
+ %}
+ }
+ %E{
+ (void) printf("After Sequence encoding:\n");
+ vunknown(*ppe);
+ %}
+ %D{
+ int i;
+
+ (void) printf("After Decoding Rep-action:\n");
+ (void) printf("rp_int %d\n", (*parm)->r_int);
+ (void) printf("r_ostring \"%s\"\n", (*parm)->r_ostring);
+ (void) printf("r_bstring: ");
+
+ for (i = 0; i < (*parm)->r_int; i++) {
+ if (BITTEST((*parm)->r_bstring, i))
+ (void) putchar('1');
+ else
+ (void) putchar('0');
+ }
+ (void) putchar('\n');
+
+ %}
+
+END
+%{
+
+/*
+ * Encoding function for test examples of the Coding functions in t3.py
+ */
+
+get_pe(parm, ppe)
+PE parm;
+PE *ppe;
+{
+ if (ppe == (PE *)0) {
+ if (parm == NULLPE) /* Optional */
+ return (OK + 1);
+ return (OK);
+ }
+
+ *ppe = pe_cpy(parm);
+ return (OK);
+}
+
+put_pe(parm, pe)
+PE *parm;
+PE pe;
+{
+ *parm = pe_cpy(pe);
+ return (OK);
+}
+
+get_int(parm, ppe)
+struct codedata *parm;
+PE *ppe;
+{
+ if (ppe == (PE *)0) {
+ if (parm->cd_int == 1) /* Default case */
+ return (OK + 1);
+ return (OK);
+ }
+
+ *ppe = int2prim(parm->cd_int);
+ return (OK);
+}
+
+put_int(parm, pe)
+struct codedata **parm;
+PE pe;
+{
+ if (pe)
+ (*parm)->cd_int = prim2num(pe);
+ else
+ (*parm)->cd_int = 1; /* Default */
+ return (OK);
+}
+
+get_string(parm, ppe)
+struct codedata *parm;
+PE *ppe;
+{
+ if (ppe == (PE *)0) {
+ if (parm->cd_string == NULLCP) /* Not present */
+ return (OK + 1);
+ return (OK);
+ }
+
+ *ppe = str2prim(parm->cd_string, strlen(parm->cd_string), 0, 0);
+ return (OK);
+}
+
+put_string(parm, pe)
+struct codedata **parm;
+PE pe;
+{
+ int len;
+
+ if (pe)
+ (*parm)->cd_string = prim2str(pe, &len);
+ else
+ (*parm)->cd_string = NULLCP; /* Default */
+
+ return (OK);
+}
+get_string2(parm, ppe)
+struct codedata *parm;
+PE *ppe;
+{
+ if (ppe == (PE *)0) {
+ if (parm->cd_string == NULLCP
+ || strcmp(parm->cd_string, "Some is out") == 0)/* Not present */
+ return (OK + 1);
+ return (OK);
+ }
+
+ *ppe = str2prim(parm->cd_string, strlen(parm->cd_string), 0, 0);
+ return (OK);
+}
+
+put_string2(parm, pe)
+struct codedata **parm;
+PE pe;
+{
+ int len;
+
+ if (pe)
+ (*parm)->cd_string = prim2str(pe, &len);
+ else
+ (*parm)->cd_string = strdup("Some is out"); /* Default */
+
+ return (OK);
+}
+
+fr_string(parm)
+struct codedata *parm;
+{
+ if (parm->cd_string)
+ free(parm->cd_string);
+
+ return (OK);
+}
+
+fr_pe(parm)
+PE parm;
+{
+ if (parm)
+ pe_free(parm);
+
+ return (OK);
+}
+
+%}
+
diff --git a/src/isode/pepsy/test_table.h b/src/isode/pepsy/test_table.h
new file mode 100644
index 000000000..d55f58812
--- /dev/null
+++ b/src/isode/pepsy/test_table.h
@@ -0,0 +1,209 @@
+/* test_table.h */
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:31:45 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:40:38 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:43:18 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/*
+ * This contains the information about each test case necessary to test it
+ * e.g. size, name
+ */
+
+ struct tst_typ {
+ char *tst_name; /* Name for error messages */
+ unsigned int tst_size; /* Size of its data structure in bytes */
+ int tst_entry; /* entry for decoding/encoding */
+ int tst_tests; /* How many values of the t_test variable
+ * to try it with
+ */
+#define NOENTRY -1
+ } t_case[] = {
+ /* MPDU */
+ { "MPDU", sizeof (struct type_T1_MPDU), _ZMPDUT1, 1, },
+#define TY_MPDU 0
+ { "Embedded", sizeof (struct type_T1_Embedded), _ZEmbeddedT1, 1, },
+#define TY_EMBEDDED 1
+ { "Strings", sizeof (struct type_T1_Strings), _ZStringsT1, 1, },
+#define TY_STRINGS 2
+ { "Embedded Strings", sizeof (struct type_T1_Emb__Strings),
+ _ZEmb_StringsT1, 1, },
+#define TY_EMB_STRINGS 3
+ { "Implicit tags", sizeof (struct type_T1_Impl__Tags),
+ _ZImpl_TagsT1, 1, },
+#define TY_IMPLICIT 4
+ { "Explicit tags", sizeof (struct type_T1_Expl__Tags),
+ _ZExpl_TagsT1, 1, },
+#define TY_EXPLICIT 5
+ { "SEQ OF and SET OF", sizeof (struct type_T1_Seqof__Test),
+ _ZSeqof_TestT1, 10, },
+#define TY_SEQOF 6
+ { "Seqof Test 1", sizeof (struct element_T1_4), NOENTRY, 0, },
+#define TY_ELEMENT4 7
+ { "Set of Test 1", sizeof (struct member_T1_2), NOENTRY, 0, },
+#define TY_MEMBER2 8
+ { "Seq of Test 2", sizeof (struct element_T1_6), NOENTRY, 0, },
+#define TY_ELEMENT6 9
+ { "Seq of Sequence test", sizeof (struct element_T1_8), NOENTRY, 0, },
+#define TY_ELEMENT8 10
+ { "Set of Test 2", sizeof (struct member_T1_4), NOENTRY, 0, },
+#define TY_MEMBER4 11
+ { "Set of Sequence", sizeof (struct element_T1_9), NOENTRY, 0, },
+#define TY_ELEMENT9 12
+ { "Choice", sizeof (struct type_T1_Choice__Test), _ZChoice_TestT1, 7, },
+#define TY_CHOICE 13
+ { "Choice test 0", sizeof (struct choice_T1_0), NOENTRY, 0, },
+#define TY_CHOICE0 14
+ { "Choice test 1", sizeof (struct choice_T1_1), NOENTRY, 0, },
+#define TY_CHOICE1 15
+ { "Choice test 2", sizeof (struct choice_T1_2), NOENTRY, 0, },
+#define TY_CHOICE2 16
+ { "Element 10", sizeof (struct element_T1_10), NOENTRY, 0, },
+#define TY_ELEMENT10 17
+ { "Member 6", sizeof (struct member_T1_6), NOENTRY, 0, },
+#define TY_MEMBER6 18
+ { "Element 11", sizeof (struct element_T1_11), NOENTRY, 0, },
+#define TY_ELEMENT11 19
+ { "Choice test 3", sizeof (struct choice_T1_3), NOENTRY, 0, },
+#define TY_CHOICE3 20
+ { "Optional test", sizeof (struct type_T1_Opt__Strings), _ZOpt_StringsT1,
+ 8, },
+#define TY_OPTIONAL 21
+ { "Element 12", sizeof (struct element_T1_12), NOENTRY, 0, },
+#define TY_ELEMENT12 22
+ { "Member 7", sizeof (struct member_T1_7), NOENTRY, 0, },
+#define TY_MEMBER7 23
+ { "Choice test 4", sizeof (struct choice_T1_4), NOENTRY, 0, },
+#define TY_CHOICE4 24
+ { "Default test", sizeof (struct type_T1_Def__Strings), _ZDef_StringsT1,
+ 12, },
+#define TY_DEFAULT 25
+ { "Element 13", sizeof (struct element_T1_13), NOENTRY, 0, },
+#define TY_ELEMENT13 26
+ { "Member 8", sizeof (struct member_T1_8), NOENTRY, 0, },
+#define TY_MEMBER8 27
+ { "External References", sizeof (struct type_T1_E__ref), _ZE_refT1, 6,},
+#define TY_EXTREF 28
+ { "T2 Info", sizeof (struct type_T2_Info), NOENTRY, 0, },
+#define TY_T2_INFO 29
+ { "T2 MPDU", sizeof (struct type_T2_MPDU), NOENTRY, 0, },
+#define TY_T2_MPDU 30
+ { "T2 ELEMENT 0", sizeof (struct element_T2_0), NOENTRY, 0, },
+#define TY_T2_ELEM0 31
+ { "Optimised", sizeof (struct type_T1_Optimised), _ZOptimisedT1, 8, },
+#define TY_OPTIMISED 32
+ { "MEMBER 9", sizeof (struct member_T1_9), NOENTRY, 0, },
+#define TY_MEMBER9 33
+ { "EXTERNAL", sizeof (struct type_T1_Ext__typ), _ZExt_typT1, 6, },
+#define TY_EXTERNAL 34
+ { "Single EXTERNAL", sizeof (struct type_T1_SExt), _ZSExtT1, 1, },
+#define TY_SEXTERNAL 35
+ { "Explicit Tagged Objects", sizeof (struct type_T1_Etags), _ZEtagsT1, 3, },
+#define TY_ETAGOBJ 36
+ { "Single Objects", sizeof (struct type_T1_Stest), _ZStestT1, 4, },
+#define TY_STEST 37
+ { "Single Integer", sizeof (struct type_T1_Sint), NOENTRY, 0, },
+#define TY_SINT 38
+ { "Enumerated Type", sizeof (struct type_T1_Enum__type), _ZEnum_typeT1,
+ 4, },
+#define TY_ETYPE 39
+ { "Tests of Enumerated type", sizeof (struct type_T1_T__enum),
+ _ZT_enumT1, 4, },
+#define TY_ENUM_TEST 40
+#define TY_REAL 41
+#ifdef PEPSY_REALS
+ { "Real", sizeof (struct type_T1_Real), _ZRealT1, 3, },
+
+ { "Tests of Real type", sizeof (struct type_T1_T__real),
+ _ZT_realT1, 4, },
+
+ { "Pepy Stuff", sizeof (struct pepy_refs), _ZT_pepyT1, 3, },
+
+ { "Default Pepy", sizeof (struct pepy_refs1), NOENTRY, 0, },
+
+ { "Optional Pepy", sizeof (struct pepy_refs1), NOENTRY, 0, },
+
+ { "Compound S-types", sizeof (struct pepy_refs1), _ZT3_SingleT1, 3, },
+
+#else
+ { NULLCP, 0, NOENTRY, 3, },
+
+ { NULLCP, 0, NOENTRY, 4, },
+
+ { NULLCP, 0, NOENTRY, 3, },
+
+ { NULLCP, 0, NOENTRY, 3, },
+
+ { NULLCP, 0, NOENTRY, 0, },
+
+ { NULLCP, 0, NOENTRY, 3, },
+#endif
+#define TY_REAL_TEST 42
+#define TY_PEPY 43
+#define TY_DEFPEPY 44
+#define TY_OPTPEPY 45
+#define TY_S_COMPD 46
+
+ {"Repeating pepy elements",sizeof (struct repeats), _ZT3_RepeatT1, 3, },
+#define TY_REPEAT 47
+
+#ifdef PEPSY_REALS
+
+ {"Value Passing Defined types",sizeof (struct pepy_refs),
+ _ZT3_DefinedT1, 3, },
+
+#else
+ { NULLCP, 0, NOENTRY, 3, },
+
+#endif
+
+#define TY_VPDEFINED 48
+
+ {"function calling code",sizeof (struct codedata), _ZT3_CodeTestT1, 3,},
+#define TY_FUNC 49
+
+ {"optional function calling",sizeof (struct codedata), NOENTRY, 3,},
+#define TY_OPTFUNC 50
+
+ {"default function calling",sizeof (struct codedata), NOENTRY, 3,},
+#define TY_DFTFUNC 51
+
+#ifdef PEPSY_REALS
+
+ {"All Simple Types",sizeof (struct codedata), _ZT3_AllSimplesT1, 3,},
+
+#else
+ { NULLCP, 0, NOENTRY, 3, },
+
+#endif
+
+#define TY_ASIMPLE 52
+
+ {"Action Statements",sizeof (struct repeats), _ZT3_UActionT1, 3, },
+#define TY_ACTION 53
+ };
+
+#define MAXTCASE (sizeof (t_case)/sizeof (t_case[0]))
diff --git a/src/isode/pepsy/tt.py b/src/isode/pepsy/tt.py
new file mode 100644
index 000000000..3ca22928b
--- /dev/null
+++ b/src/isode/pepsy/tt.py
@@ -0,0 +1,82 @@
+-- $Header$
+--
+--
+-- $Log$
+-- Revision 1.1 1994/06/10 03:31:48 eichin
+-- autoconfed isode for kerberos work
+--
+# Revision 1.1 1994/05/31 20:40:40 eichin
+# reduced-isode release from /mit/isode/isode-subset/src
+#
+-- Revision 8.0 91/07/17 12:43:18 isode
+-- Release 7.0
+--
+--
+
+--
+-- NOTICE
+--
+-- Acquisition, use, and distribution of this module and related
+-- materials are subject to the restrictions of a license agreement.
+-- Consult the Preface in the User's Manual for the full terms of
+-- this agreement.
+--
+--
+
+
+
+TT DEFINITIONS ::=
+
+%{
+int foo;
+%}
+
+BEGIN
+
+EntryInformationSelection [[P struct entryinfoselection *]]
+ ::=
+ SET
+ {
+ attributeTypes
+ CHOICE [[ T struct entryinfoselection * $ *]]
+ <D< (*parm)->eis_allattributes>>
+ <E< parm->eis_allattributes ? 1 : 2>>
+ {
+ allAttributes
+ [0] NULL,
+ select
+ [1] SET OF [[ T struct attrcomp * $ eis_select ]] <<attr_link>>
+ AttributeType [[p attr_type]]
+ }
+ %D{
+ if ((*parm)->eis_allattributes == 1)
+ (*parm)->eis_allattributes = TRUE;
+ else
+ (*parm)->eis_allattributes = FALSE;
+ %}
+ -- DEFAULT allAttributes NULL,
+ OPTIONAL <E<parm->eis_allattributes != FALSE>><D<0>>,
+ infoTypes
+ [2] INTEGER [[i eis_infotypes]]
+ {
+ attributeTypesOnly(0) ,
+ attributeTypesAndValues(1)
+ }
+ DEFAULT attributeTypesAndValues
+ }
+
+
+TestChoice ::= CHOICE <E< 1 >> <D< foo >> {
+ one OCTET STRING,
+ two SEQUENCE {
+ one2 IA5String OPTIONAL <E< 1 >> <D< 0 >>,
+ two2 CHOICE {
+ one3 NULL,
+ two3 INTEGER
+ } OPTIONAL <E<1>> <D<foo = 1>>
+ },
+ three INTEGER {eine(1), zwei(2), drie(3) },
+ four BIT STRING { un(1), deux(2), trois(3), quatre(4) }
+}
+END
+
diff --git a/src/isode/pepsy/util.c b/src/isode/pepsy/util.c
new file mode 100644
index 000000000..5682985af
--- /dev/null
+++ b/src/isode/pepsy/util.c
@@ -0,0 +1,780 @@
+/* util.c */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:31:50 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:40:44 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:43:19 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "pepsy-driver.h"
+#include "psap.h"
+#include "pepsy.h"
+#include <varargs.h>
+#include "tailor.h"
+
+#ifndef PEPYPARM
+#define PEPYPARM char *
+#endif
+
+static char *pr_petype ();
+
+extern void exit();
+
+#ifdef lint
+/* VARARGS4 */
+
+int pepsylose (module, p, pe, str)
+modtyp *module;
+tpe *p;
+char *str;
+PE pe;
+{
+ return pepsylose (module, p, pe, str);
+}
+
+#else
+int pepsylose (va_alist)
+va_dcl
+{
+ va_list ap;
+ int type;
+ modtyp *module;
+ tpe *p;
+ char *cp;
+ PE pe;
+ char buffer[BUFSIZ];
+
+ va_start (ap);
+
+ module = va_arg (ap, modtyp *);
+ p = va_arg (ap, tpe *);
+ pe = va_arg (ap, PE);
+
+ _asprintf (buffer, NULLCP, ap);
+ (void) sprintf (PY_pepy, "%s: module %s",
+ buffer, module ? module -> md_name : "<none>");
+ if (p) {
+ cp = PY_pepy + strlen (PY_pepy);
+ (void) sprintf (cp, " %s/class=%s/id=%d",
+ pr_petype (p -> pe_type),
+ pe_classlist[p -> pe_flags & FL_CLASS],
+ p -> pe_tag);
+ }
+ if (pe && pe -> pe_class >= 0 && ((int)pe -> pe_class) < pe_maxclass) {
+ cp = PY_pepy + strlen (PY_pepy);
+ (void) sprintf (cp, " got %s/%d", pe_classlist[pe -> pe_class],
+ pe -> pe_id);
+ }
+
+ SLOG (psap_log, LLOG_EXCEPTIONS, NULLCP, ("%s", PY_pepy));
+
+ va_end (ap);
+ return NOTOK;
+}
+#endif
+
+#ifdef lint
+/* VARARGS4 */
+
+int ppepsylose (module, p, pe, str)
+modtyp *module;
+ptpe *p;
+char *str;
+PE pe;
+{
+ return ppepsylose (module, p, pe, str);
+}
+
+#else
+int ppepsylose (va_alist)
+va_dcl
+{
+ va_list ap;
+ int type;
+ modtyp *module;
+ ptpe *p;
+ char *cp;
+ PE pe;
+ char buffer[BUFSIZ];
+
+ va_start (ap);
+
+ module = va_arg (ap, modtyp *);
+ p = va_arg (ap, ptpe *);
+ pe = va_arg (ap, PE);
+
+ _asprintf (buffer, NULLCP, ap);
+ (void) sprintf (PY_pepy, "%s: module %s",
+ buffer, module ? module -> md_name : "<none>");
+ if (p) {
+ cp = PY_pepy + strlen (PY_pepy);
+ (void) sprintf (cp, " %s/class=%s/id=%d",
+ pr_petype (p -> pe_type),
+ pe_classlist[p -> pe_flags & FL_CLASS],
+ p -> pe_tag);
+ if (p->pe_typename)
+ (void) sprintf (cp, "(%s)", *p -> pe_typename);
+ }
+ if (pe && pe -> pe_class >= 0 && ((int)pe -> pe_class) < pe_maxclass) {
+ cp = PY_pepy + strlen (PY_pepy);
+ (void) sprintf (cp, " got %s/%d", pe_classlist[pe -> pe_class],
+ pe -> pe_id);
+ }
+
+ SLOG (psap_log, LLOG_EXCEPTIONS, NULLCP, ("%s", PY_pepy));
+
+ va_end (ap);
+ return NOTOK;
+}
+#endif
+
+/*
+ * Useful little routines
+ */
+/*
+ * print out the message and if the arguement is greater than 0
+ * terminate
+ */
+ferr(n, mesg)
+char *mesg;
+{
+ (void) printf(mesg);
+ if (n > 0)
+ exit(n);
+}
+/*
+ * print out the message and number and if the arguement is greater
+ * than 0 terminate
+ */
+ferrd(n, mesg, d)
+char *mesg;
+int d;
+{
+ (void) printf(mesg, d);
+ if (n > 0)
+ exit(n);
+}
+
+/*
+ * 0 = Encoding table, 1 = Decoding table, 2 = Printing table
+ */
+#define TYP_ENC 0
+#define TYP_DEC 1
+#define TYP_PRINT 2
+#define TYP_LAST 2
+
+dmp_tpe(s, p, mod)
+char *s;
+modtyp *mod; /* Module it is from */
+tpe *p;
+{
+ int typ, i, j;
+ tpe **par, **prev;
+ char *name;
+
+ (void) printf("%s: (%s)", s, mod->md_name);
+ /*
+ * Calculate what table it is in - we assume they are in order of
+ * increasing address
+ */
+
+ par = NULL;
+ for (typ = 0; typ <= TYP_LAST; typ++) {
+ switch (typ) {
+ case TYP_ENC:
+ if (mod->md_etab != NULL && mod->md_etab[0] < p) {
+ par = mod->md_etab;
+ name = "Encoding:";
+ }
+ break;
+
+ case TYP_DEC:
+ if (mod->md_dtab != NULL && mod->md_dtab[0] < p) {
+ par = mod->md_dtab;
+ name = "Decoding:";
+ }
+ break;
+
+ case TYP_PRINT:
+ if (mod->md_ptab != NULL && mod->md_ptab[0] < (ptpe *) p) {
+ par = (tpe **) mod->md_ptab;
+ name = "Printing:";
+ }
+ break;
+
+ default:
+ (void) pepsylose (mod, p, NULLPE, "dmp_tpe:typ = %d internal error\n",
+ typ);
+ return;
+ }
+ }
+ if (par == NULL) {
+ (void) printf("can't find entry 0x%x\n", p);
+ return;
+ }
+ prev = par;
+ for (i = mod->md_nentries; i > 0; i--) {
+ if (*par > p)
+ break;
+ par++;
+ }
+ if (par == prev)
+ (void) pepsylose (mod, p, NULLPE,
+ "dmp_tpe:par == prev == 0x%x internal error\n", (int) par);
+ par--;
+ j = p - *par;
+
+ (void) printf("%s type %d + %d ", name, par - prev, j);
+ pr_entry(p);
+}
+#define NENTRY(x) ((sizeof (x)/sizeof (x[0])))
+/*
+ * Print out a tpe entry
+ */
+static char *ntypes[] = { "PE_START", "PE_END", "illegal 1", "illegal 2",
+ "XOBJECT", "illegal 4", "illegal 5", "UCODE", "MALLOC", "SCTRL", "CH_ACT",
+ "OPTL", "BOPTIONAL", "FFN_CALL",},
+
+ *otypes[] = { "ANY", "INTEGER", "BOOLEAN", "OBJECT",
+ "BITSTRING", "OCTETSTRING", "SET_START", "SEQ_START", "SEQOF_START",
+ "SETOF_START", "CHOICE_START", "UNKNOWN", "T_NULL", "T_OID",
+ "ETAG", "IMP_OBJ", "EXTOBJ", "EXTMOD", "OBJID", "DFLT_F", "DFLT_B",
+ "T_STRING", "OCTET_PTR", "OCTET_LEN", "BITSTR_PTR", "BITSTR_LEN",
+ "FN_CALL" };
+
+static char *
+pr_petype (type)
+int type;
+{
+ static char nbuf[30];
+
+ if (type >= PE_START && type < NENTRY(ntypes) - 1)
+ return ntypes[type + 1];
+ else if (type >= TYPE_DATA && type < NENTRY(otypes) + TYPE_DATA)
+ return otypes[type - TYPE_DATA];
+ (void) sprintf (nbuf, "%d", type);
+ return nbuf;
+}
+
+pr_entry(p)
+tpe *p;
+{
+ (void) printf ("%s, ", pr_petype (p -> pe_type));
+ (void) printf("%d, %d, %d}\n", p->pe_ucode, p->pe_tag, p->pe_flags);
+}
+
+p_pr_entry(p)
+ptpe *p;
+{
+ if (p->pe_type >= PE_START && p->pe_type < NENTRY(ntypes) - 1)
+ (void) printf("{%s, ", ntypes[p->pe_type + 1]);
+ else if (p->pe_type >= TYPE_DATA && p->pe_type < NENTRY(otypes) + TYPE_DATA)
+ (void) printf("{%s, ", otypes[p->pe_type - TYPE_DATA]);
+ else
+ (void) printf("{%d, ", p->pe_type);
+
+ (void) printf("%d, %d, %d}\n", p->pe_ucode, p->pe_tag, p->pe_flags);
+}
+
+
+/*
+ * null function for what evr purposes
+ */
+f_null()
+{
+}
+
+/*
+ * compare a given number of bits pointed to by the two character
+ * pointers return 0 if they are the same non zero otherwise
+ */
+bitscmp(p1, p2, len)
+register char *p1, *p2;
+int len;
+{
+ register int i;
+ register unsigned int mask;
+
+ if (len >= 8 && bcmp(p1, p2, len / 8))
+ return (1);
+
+ if (len % 8 == 0)
+ return (0);
+ /* Check those last few bits */
+ i = len / 8;
+ mask = (0xff00 >> len % 8) & 0xff;
+ if ((p1[i] & mask) != (p2[i] & mask))
+ return (1);
+
+ return (0);
+}
+
+#define MIN(a, b) (a < b ? a : b)
+/*
+ * compare an octet string and a qb and return 0 if they are the same
+ * and non zero otherwise
+ */
+ostrcmp(p, len, qb)
+register char *p;
+register int len;
+register struct qbuf *qb;
+{
+ register struct qbuf *qp;
+
+ if (len < 0 || qb == NULL || p == NULL)
+ return (1);
+ qp = qb;
+ do {
+ if (qp->qb_data != NULL) {
+ if (qp->qb_len < 0)
+ ferrd(1, "ostrcmp:qb_len %d < 0", qp->qb_len);
+ if (qp->qb_len > len)
+ return (1);
+ if (bcmp(qp->qb_data, p, qp->qb_len))
+ return (1);
+ if ((len -= qp->qb_len) == 0)
+ return (0);
+ p += qp->qb_len;
+ }
+ qp = qp->qb_forw;
+ } while (qp != qb);
+
+ return (len);
+}
+
+/*
+ * Is data present for the optional item? 1 for yes 0 for no
+ */
+hasdata(parm, p, mod, popt, optcnt)
+PEPYPARM parm;
+tpe *p;
+modtyp *mod; /* Module it is from */
+int *popt, *optcnt;
+{
+ int val;
+
+ switch (p->pe_type) {
+ case INTEGER:
+ case REALTYPE:
+ case BOOLEAN:
+ case T_NULL:
+ if (DEFAULT(p)) {
+ /* Default's don't have bit map */
+ if (p[1].pe_type == DFLT_B && same(p, p + 1, parm, mod)
+ || p[-1].pe_type == DFLT_F && same(p, p - 1, parm, mod))
+ goto next;
+ break;
+ }
+ if (!TESTBIT(*popt, (*optcnt)++))
+ goto next; /* Missing so skip */
+ break;
+
+ case ETAG:
+ if (!hasdata(parm, p + 1, mod, popt, optcnt))
+ goto next;
+ break;
+
+ case IMP_OBJ:
+ if (p[1].pe_type == SOBJECT && parm == NULL
+ || *((char **) (parm + p[1].pe_ucode)) == NULL)
+ goto next;
+ break;
+
+ case FN_CALL: /* function call */
+ if ((val = (FN_PTR(mod, p))(parm, (PE *)0)) == NOTOK)
+ return pepsylose (mod, p, NULLPE,
+ "hasdata:FN_CALL:call failed");
+ if (val != OK)
+ goto next;
+ break;
+
+ default:
+ if (*((char **) (parm + p->pe_ucode)) == NULL)
+ goto next;
+ break;
+ }
+ return (1);
+
+next:
+ return (0);
+}
+
+/*
+ * determine if the default value is the same as the value in the
+ * structure and if so return greater than zero (meaning don't encode this
+ * item). On error return NOTOK
+ */
+same(typ, dflt, parm, mod)
+tpe *typ, *dflt;
+char *parm;
+modtyp *mod; /* Module it is from */
+{
+ int val;
+ int len;
+ char *p1;
+ PE pe;
+ struct qbuf *qb;
+
+ switch (typ->pe_type) {
+ case INTEGER:
+ val = IVAL(mod, dflt) == *(integer *) (parm + typ->pe_ucode);
+ break;
+
+#ifdef PEPSY_REALS
+ case REALTYPE:
+ val = RVAL(mod, dflt) == *(double *) (parm + typ->pe_ucode);
+ break;
+#endif
+
+ case BOOLEAN:
+ val = IVAL(mod, dflt) == *(char *) (parm + typ->pe_ucode);
+ break;
+
+ case T_NULL:
+ val = 1; /* Only one value */
+ break;
+
+ case SBITSTRING:
+ if ((pe = (PE) parm) == NULL) {
+ val = 1;
+ break;
+ }
+ goto bstring;
+
+ case BITSTRING:
+ if ((pe = *(PE *) (parm + typ->pe_ucode)) == NULL) {
+ val = 1;
+ break;
+ }
+bstring:
+ if ((p1 = bitstr2strb(pe, &val)) == NULL) {
+ (void) pepsylose (mod, typ, pe, "same:bad bitstring\n");
+ return (NOTOK);
+ /* Should really abort encoding here but how can we comunicate this
+ * to the routine that calls us?
+ */
+ }
+bstring2:
+ if (val != IVAL(mod, dflt) || bitscmp(PVAL(mod, dflt), p1, val))
+ val = 0;
+ else
+ val = 1;
+ if (typ->pe_type != BITSTR_PTR)
+ free(p1);
+ break;
+
+ case BITSTR_PTR:
+ if (typ[1].pe_type != BITSTR_LEN)
+ return pepsylose (mod, typ, pe, "same:missing BITSTR_LEN\n");
+ if ((p1 = *(char **) (parm + typ->pe_ucode)) == NULL) {
+ val = 1;
+ break;
+ }
+ val = *(int *) (parm + (typ + 1)->pe_ucode);
+ goto bstring2;
+
+ case SOCTETSTRING:
+ if ((qb = (struct qbuf *) parm) == NULL) {
+ val = 1;
+ break;
+ }
+ goto ostring;
+
+ case OCTETSTRING:
+ if ((qb = *(struct qbuf **) (parm + typ->pe_ucode)) == NULL) {
+ val = 1;
+ break;
+ }
+ostring:
+ if (ostrcmp(PVAL(mod, dflt), (int ) IVAL(mod, dflt), qb))
+ val = 0;
+ else
+ val = 1;
+ break;
+
+ case OCTET_PTR:
+ if (typ[1].pe_type != OCTET_LEN)
+ return pepsylose (mod, typ, pe, "same:missing OCTET_LEN\n");
+ if ((p1 = *(char **) (parm + typ->pe_ucode)) == NULL) {
+ val = 1;
+ break;
+ }
+ len = *(int *) (parm + (typ + 1)->pe_ucode);
+ goto o1string;
+
+ case T_STRING:
+ if ((p1 = *(char **) (parm + typ->pe_ucode)) == NULL) {
+ val = 1;
+ break;
+ }
+ len = strlen(p1);
+o1string:
+ if (len != IVAL(mod, dflt)) {
+ val = 0;
+ break;
+ }
+ if (bcmp(PVAL(mod, dflt), p1, len))
+ val = 0;
+ else
+ val = 1;
+ break;
+
+ case OBJECT:
+ if (*(char **) (parm + typ->pe_ucode) == NULL) {
+ val = 1; /* to conform with pepy's way of
+ * doing default */
+ break;
+ }
+ val = same(mod->md_etab[typ->pe_tag] + 1, dflt,
+ *(char **) (parm + typ->pe_ucode), mod);
+ break;
+
+ case SOBJECT:
+ if ((char *) parm == NULL) {
+ val = 1; /* to conform with pepy's way of
+ * doing default */
+ break;
+ }
+ val = same(mod->md_etab[typ->pe_tag] + 1, dflt, parm, mod);
+ break;
+
+ case IMP_OBJ:
+ typ++; /* fall through */
+
+ case ANY:
+ case SANY:
+ case SEXTOBJ:
+ case EXTOBJ:
+ case OBJID:
+ case SOBJID:
+ case SEQ_START:
+ case SET_START:
+ case -1: /* Just use the pepy method of null
+ * pointers */
+ /*
+ * This is the posy/pepy hack way of doing things at the
+ * moment
+ */
+ val = *(char **) (parm + typ->pe_ucode) == NULL;
+ break;
+
+ case FN_CALL: /* function call */
+ if ((val = (FN_PTR(mod, typ))(parm, (PE *)0)) == NOTOK)
+ return pepsylose (mod, typ, NULLPE,
+ "same:FN_CALL:call failed");
+ if (val != OK)
+ val = 1;
+ else
+ val = 0;
+ break;
+
+
+ default:
+ (void) pepsylose (mod, typ, NULLPE, "same: %d not implemented\n",
+ typ->pe_type);
+ return (NOTOK);
+ }
+
+ return (val);
+}
+
+/*
+ * Calculate the next tpe entry in the sequence. Count a sequence as
+ * one element
+ */
+tpe *
+next_tpe(p)
+tpe *p;
+{
+ int level;
+
+
+
+ level = 0;
+ if (p->pe_type == PE_END) {
+ (void) pepsylose (NULLMODTYP, p, NULLPE,
+ "next_tpe:internal error: unexpected PE_END found");
+ return (p);
+ }
+ do {
+again:
+ switch (p->pe_type) {
+ case SSEQ_START:
+ case SSEQOF_START:
+ case SSET_START:
+ case SSETOF_START:
+ case SCHOICE_START:
+ case SEQ_START:
+ case SEQOF_START:
+ case SET_START:
+ case SETOF_START:
+ case CHOICE_START:
+ level++;
+ break;
+
+ case UCODE:
+ case MEMALLOC:
+ case SCTRL:
+ case CH_ACT:
+ case INTEGER:
+ case REALTYPE:
+ case BOOLEAN:
+ case SANY:
+ case ANY:
+ case T_NULL:
+ case OBJECT:
+ case SOBJECT:
+ case BITSTRING:
+ case BITSTR_LEN:
+ case SBITSTRING:
+ case OCTETSTRING:
+ case T_STRING:
+ case OCTET_LEN:
+ case SOCTETSTRING:
+ case OBJID:
+ case SOBJID:
+ case OPTL:
+ case EXTMOD:
+ case DFLT_B:
+ case FN_CALL:
+ case FFN_CALL:
+ break;
+
+ case IMP_OBJ:
+ case ETAG:
+ case EXTOBJ:
+ case SEXTOBJ:
+ case DFLT_F:
+ case OCTET_PTR:
+ case BITSTR_PTR:
+ case BOPTIONAL:
+ case FREE_ONLY:
+ p++;
+ goto again;
+
+ case PE_END:
+ level--;
+ break;
+
+ default:
+ ferrd(1, "next_tpe: unknown type %d\n", p->pe_type);
+ }
+ p++;
+ } while (level > 0 || p->pe_type == DFLT_B);
+
+ return (p);
+}
+
+/*
+ * Is there a match at for this tag and class pair. Return 1 if yes 0
+ * if no We will search through contained objects and through choices
+ */
+ismatch(p, mod, cl, tag)
+tpe *p;
+modtyp *mod; /* Module it is from */
+unsigned int cl, tag;
+{
+ while (!ISDTYPE(p))
+ p++;
+
+ switch (p->pe_type) {
+ case SOBJECT:
+ case OBJECT:
+ /* Needs to be changed for optional and default */
+ return (ismatch(p = mod->md_dtab[p->pe_tag] + 1, mod, cl, tag));
+
+ case SEXTOBJ:
+ case EXTOBJ:
+ if (p[1].pe_type != EXTMOD) {
+ dmp_tpe("ismatch: missing EXTMOD", p, mod);
+ ferr(1, "ismatch:internal error\n");
+ }
+ return (ismatch(EXT2MOD(mod, (p + 1))->md_dtab[p->pe_tag] + 1,
+ EXT2MOD(mod, (p + 1)), cl, tag));
+
+ case CHOICE_START:
+ case SCHOICE_START:
+ for (p++; p->pe_type != PE_END; p = next_tpe (p)) {
+ if (!ISDTYPE(p))
+ continue;
+ if (ismatch(p, mod, cl, tag))
+ return (1);
+ }
+ return (0);
+
+ case SANY:
+ return (1);
+
+ case FN_CALL:
+ case ANY:
+ if (STAG(p) == -1)
+ return (1);
+ /* else fall through - not sure if this is needed */
+
+ default:
+ return (tag == TAG(p) && cl == CLASS(p));
+ }
+}
+
+/*
+ * find the data entry that goes with this DFLT_F entry
+ * bascially skip over any ETAGS that (an arbitary number but almost always 1)
+ */
+tpe *
+fdflt_f(p)
+register tpe *p;
+{
+ if (p->pe_type != DFLT_F)
+ ferr(1, "fdlt_f:Internal Error missing DFLT_F\n");
+
+ for (p++; p->pe_type != PE_END; p++) {
+ if (p->pe_type != ETAG)
+ return (p);
+ }
+ ferr(1, "fdlt_f:Internal Error PE_END found\n");
+ /*NOTREACHED*/
+}
+
+/*
+ * find the DFLT_B entry
+ */
+tpe *
+fdflt_b(p)
+register tpe *p;
+{
+ for (p++; p->pe_type != PE_END; p++) {
+ if (p->pe_type == DFLT_B)
+ return (p);
+ }
+ ferr(1, "fdflt_b:Internal Error PE_END found\n");
+ /*NOTREACHED*/
+}
diff --git a/src/isode/pepsy/version.major b/src/isode/pepsy/version.major
new file mode 100644
index 000000000..7f8f011eb
--- /dev/null
+++ b/src/isode/pepsy/version.major
@@ -0,0 +1 @@
+7
diff --git a/src/isode/pepsy/version.minor b/src/isode/pepsy/version.minor
new file mode 100644
index 000000000..573541ac9
--- /dev/null
+++ b/src/isode/pepsy/version.minor
@@ -0,0 +1 @@
+0
diff --git a/src/isode/pepsy/vprint.c b/src/isode/pepsy/vprint.c
new file mode 100644
index 000000000..abad66ecf
--- /dev/null
+++ b/src/isode/pepsy/vprint.c
@@ -0,0 +1,766 @@
+/* vprint.c - pepy printer support */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:31:55 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.2 1994/06/03 18:43:58 eichin
+ * don't declare fprintf on aix
+ *
+ * Revision 1.1 1994/05/31 20:40:53 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:43:20 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <ctype.h>
+#include <stdio.h>
+#include <varargs.h>
+#include "UNIV-types.h"
+#include "psap.h"
+#include "pepsy.h"
+#include "logger.h"
+
+
+#ifndef __STDC__
+#ifndef _AIX
+int fprintf ();
+#endif
+#else
+#ifdef __GNUC__
+#ifdef SUNOS4 /* And probaby a few more - what a mess! */
+int fprintf ();
+#endif
+#endif
+#endif
+
+static vprint1 ();
+static vprint2 ();
+static vwrite ();
+
+/* DATA */
+
+#define VPRINT(s) vprint1 (), vwrite ((s)), vprint2 ()
+
+static int vlevel = 0;
+
+static int didname = 0;
+static int didvpop = 0;
+static int didvpush = 0;
+static int docomma = 0;
+
+static char *py_classlist[] = {
+ "UNIVERSAL", "APPLICATION", "", "PRIVATE"
+};
+
+static char *vbp = NULL;
+static char *vsp;
+
+IFP vfnx = (IFP) fprintf;
+FILE *vfp = stdout;
+static PS vps = NULLPS;
+
+char *oct2str (), *newbuf ();
+
+/* VPUSH/VPOP */
+
+vpush () {
+ if (didvpush)
+ vwrite ("\n"), didvpush = 0;
+ else
+ if (!didname && docomma)
+ vwrite (",\n");
+
+ if (didname)
+ vwrite (" ");
+ else
+ if (vfp && vlevel > 0)
+ (*vfnx) (vfp, "%*s", vlevel * 3, "");
+ vwrite ("{");
+ vlevel++;
+
+ didname = didvpop = docomma = 0, didvpush = 1;
+}
+
+
+vpop () {
+ if (didname || docomma)
+ vwrite ("\n");
+
+ vlevel--;
+ if (!didvpush && vfp && vlevel > 0)
+ (*vfnx) (vfp, "%*s", vlevel * 3, "");
+ vwrite ("}");
+ if (vlevel == 0)
+ vwrite ("\n");
+
+ didname = didvpush = 0, didvpop = docomma = vlevel ? 1 : 0;
+}
+
+/* VNAME/VTAG */
+
+vname (name)
+char *name;
+{
+ if (didvpush)
+ vwrite ("\n"), didvpush = 0;
+ else
+ if (docomma)
+ vwrite (",\n");
+
+ if (vfp && vlevel > 0)
+ (*vfnx) (vfp, "%*s", vlevel * 3, "");
+ vwrite (name);
+
+ didname = 1;
+}
+
+
+vtag (class, id)
+int class,
+ id;
+{
+ register char *bp;
+ static char buffer[BUFSIZ];
+
+ if (didname)
+ return;
+
+ bp = buffer;
+ *bp++ = '[';
+ switch (class) {
+ case PE_CLASS_UNIV:
+ case PE_CLASS_APPL:
+ case PE_CLASS_PRIV:
+ (void) sprintf (bp, "%s ", py_classlist[class]);
+ bp += strlen (bp);
+ break;
+
+ case PE_CLASS_CONT:
+ default:
+ break;
+ }
+ (void) sprintf (bp, "%d]", id);
+
+ vname (buffer);
+}
+
+/* VPRINT */
+
+#ifndef lint
+vprint (va_alist)
+va_dcl
+{
+ char buffer[BUFSIZ];
+ va_list ap;
+
+ vprint1 ();
+
+ va_start (ap);
+
+ _asprintf (buffer, NULLCP, ap);
+
+ va_end (ap);
+
+ vwrite (buffer);
+
+ vprint2 ();
+}
+#else
+/* VARARGS */
+
+vprint (fmt)
+char *fmt;
+{
+ vprint (fmt);
+}
+#endif
+
+
+static vprint1 ()
+{
+ if (didvpush) {
+ vwrite ("\n"), didvpush = 0;
+ goto indent;
+ }
+ else
+ if (didname)
+ vwrite (" ");
+ else {
+ if (docomma)
+ vwrite (",\n");
+indent: ;
+ if (vfp && vlevel > 0)
+ (*vfnx) (vfp, "%*s", vlevel * 3, "");
+ }
+}
+
+
+static vprint2 ()
+{
+ if (vlevel == 0)
+ vwrite ("\n");
+
+ didname = didvpop = 0, docomma = vlevel ? 1 : 0;
+}
+
+/* */
+
+static vwrite (s)
+char *s;
+{
+ if (vfp)
+ (*vfnx) (vfp, "%s", s);
+ else {
+ register char c,
+ *cp;
+
+ if (vps)
+ for (cp = s; *cp; cp++) {
+ if (*cp == '\n' )
+ (void) ps_write (vps, (PElementData) " ", 1);
+ else
+ (void) ps_write (vps, (PElementData) cp, 1);
+ }
+ else
+ for (cp = s; *cp; )
+ *vbp++ = (c = *cp++) != '\n' ? c : ' ';
+ }
+}
+
+/* VSTRING */
+
+vstring (pe)
+register PE pe;
+{
+ register PE p;
+
+ switch (pe -> pe_form) {
+ case PE_FORM_PRIM:
+ case PE_FORM_ICONS:
+ VPRINT (oct2str ((char *) pe -> pe_prim, (int) pe -> pe_len));
+ break;
+
+ case PE_FORM_CONS:
+ vpush ();
+ for (p = pe -> pe_cons; p; p = p -> pe_next)
+ vstring (p);
+ vpop ();
+ break;
+ }
+}
+
+/* */
+
+static char *oct2str (s, len)
+register char *s;
+register int len;
+{
+ int ia5ok;
+ register int k;
+ register char *bp,
+ *cp,
+ *dp,
+ *zp;
+
+ ia5ok = 1, k = 0;
+ for (dp = (cp = s) + len; cp < dp; cp++) {
+ switch (*cp) {
+ case ' ':
+ continue;
+
+ case '"':
+ break;
+
+ case '\b':
+ case '\f':
+ case '\n':
+ case '\r':
+ case '\t':
+ case '\\':
+ ia5ok = -1, k++;
+ continue;
+
+ case '-':
+ if (cp > s && *(cp + 1) == '-')
+ break;
+ continue;
+
+ default:
+ if (iscntrl (*cp) || isspace (*cp) || (*cp & 0x80))
+ break;
+ continue;
+ }
+ ia5ok = 0;
+ break;
+ }
+
+ switch (ia5ok) {
+ case 1:
+ zp = newbuf (len + 2);
+ (void) sprintf (zp, "\"%*.*s\"", len, len, s);
+ break;
+
+ case -1:
+ bp = zp = newbuf (len + k + 2);
+ *bp++ = '"';
+ for (cp = s; cp < dp; cp++)
+ if (*cp >= ' ' && *cp != '\\')
+ *bp++ = *cp;
+ else {
+ *bp++ = '\\';
+ switch (*cp) {
+ case '\b':
+ *bp++ = 'b';
+ break;
+ case '\f':
+ *bp++ = 'f';
+ break;
+ case '\n':
+ *bp++ = 'n';
+ break;
+ case '\r':
+ *bp++ = 'r';
+ break;
+ case '\t':
+ *bp++ = 't';
+ break;
+
+ case '\\':
+ *bp++ = '\\';
+ break;
+ }
+ }
+ (void) sprintf (bp, "\"");
+ break;
+
+ case 0:
+ default:
+ bp = zp = newbuf (len * 2 + 3);
+ *bp++ = '\'';
+ for (cp = s; cp < dp; cp++) {
+ (void) sprintf (bp, "%02x", *cp & 0xff);
+ bp += strlen (bp);
+ }
+ (void) sprintf (bp, "'H");
+ break;
+ }
+
+ return zp;
+}
+
+/* */
+
+char *bit2str (pe, s)
+PE pe;
+char *s;
+{
+ int ia5ok;
+ register int hit,
+ i,
+ j,
+ k;
+ register char *bp,
+ *cp,
+ *zp;
+
+ j = pe -> pe_nbits;
+ if ((cp = s) && *++cp) {
+ ia5ok = 1, hit = 0;
+ for (i = 0; i < j;)
+ if (bit_test (pe, i++) == 1) {
+ do {
+ if (!(k = *cp++ & 0xff))
+ break;
+ if (k == i) {
+ hit += hit ? 2 : 1;
+ for (; *cp > ' '; cp++)
+ hit++;
+ }
+ else
+ for (; *cp > ' '; cp++)
+ continue;
+ } while (k != 0 && k < i);
+ if (k == 0 || k > i) {
+ ia5ok = 0;
+ break;
+ }
+ }
+ }
+ else
+ ia5ok = 0;
+
+ if (ia5ok) {
+ bp = zp = newbuf (hit + 3);
+ *bp++ = '{';
+
+ cp = s, cp++;
+ for (i = hit = 0; i < j;)
+ if (bit_test (pe, i++) == 1) {
+ do {
+ if (!(k = *cp++ & 0xff))
+ break;
+ if (k == i) {
+ if (hit)
+ *bp++ = ',';
+ *bp++ = ' ';
+ for (; *cp > ' '; cp++)
+ *bp++ = *cp;
+ }
+ else
+ for (; *cp > ' '; cp++)
+ continue;
+ } while (k != 0 && k < i);
+ if (k == 0 || k > i)
+ break;
+ hit++;
+ }
+
+ (void) sprintf (bp, "%s}", hit ? " " : "");
+ }
+ else {
+ bp = zp = newbuf (j + 3);
+ *bp++ = '\'';
+ for (i = 0; i < j; i++)
+ *bp++ = bit_test (pe, i) ? '1' : '0';
+ (void) sprintf (bp, "'B");
+ }
+
+ return zp;
+}
+
+/* */
+
+#ifdef vunknown
+#undef vunknown
+#endif
+
+vunknown (pe)
+register PE pe;
+{
+ int i;
+#ifdef notyet /* could comment this in, but then all programs need -lm */
+ double j;
+#endif
+ OID oid;
+ register PE p;
+
+ switch (pe -> pe_form) {
+ case PE_FORM_PRIM:
+ switch (PE_ID (pe -> pe_class, pe -> pe_id)) {
+ case PE_ID (PE_CLASS_UNIV, PE_PRIM_BOOL):
+ if ((i = prim2flag (pe)) == NOTOK)
+ goto bad_pe;
+ VPRINT (i ? "TRUE" : "FALSE");
+ break;
+
+ case PE_ID (PE_CLASS_UNIV, PE_PRIM_INT):
+ case PE_ID (PE_CLASS_UNIV, PE_PRIM_ENUM):
+ if ((i = prim2num (pe)) == NOTOK
+ && pe -> pe_errno != PE_ERR_NONE)
+ goto bad_pe;
+ vprint ("%d", i);
+ break;
+
+#ifdef notyet
+ case PE_ID (PE_CLASS_UNIV, PE_PRIM_REAL):
+ if ((j = prim2real (pe)) == NOTOK
+ && pe -> pe_errno != PE_ERR_NONE)
+ goto bad_pe;
+ vprint ("%g", j);
+ break;
+#endif
+
+ case PE_ID (PE_CLASS_UNIV, PE_PRIM_BITS):
+ if ((p = prim2bit (pe)) == NULLPE)
+ goto bad_pe;
+ if (p -> pe_nbits < LOTSOFBITS) {
+ VPRINT (bit2str (p, "\020"));
+ break;
+ }
+ /* else fall... */
+
+ default:
+ bad_pe: ;
+ vtag ((int) pe -> pe_class, (int) pe -> pe_id);
+ /* fall */
+
+ case PE_ID (PE_CLASS_UNIV, PE_PRIM_OCTS):
+ case PE_ID (PE_CLASS_UNIV, PE_DEFN_IA5S):
+ case PE_ID (PE_CLASS_UNIV, PE_DEFN_NUMS):
+ case PE_ID (PE_CLASS_UNIV, PE_DEFN_PRTS):
+ case PE_ID (PE_CLASS_UNIV, PE_DEFN_T61S):
+ case PE_ID (PE_CLASS_UNIV, PE_DEFN_VTXS):
+ case PE_ID (PE_CLASS_UNIV, PE_DEFN_GENT):
+ case PE_ID (PE_CLASS_UNIV, PE_DEFN_UTCT):
+ case PE_ID (PE_CLASS_UNIV, PE_DEFN_GFXS):
+ case PE_ID (PE_CLASS_UNIV, PE_DEFN_VISS):
+ case PE_ID (PE_CLASS_UNIV, PE_DEFN_GENS):
+ case PE_ID (PE_CLASS_UNIV, PE_DEFN_CHRS):
+ case PE_ID (PE_CLASS_UNIV, PE_PRIM_ODE):
+ vstring (pe);
+ break;
+
+ case PE_ID (PE_CLASS_UNIV, PE_PRIM_NULL):
+ VPRINT ("NULL");
+ break;
+
+ case PE_ID (PE_CLASS_UNIV, PE_PRIM_OID):
+ if ((oid = prim2oid (pe)) == NULLOID)
+ goto bad_pe;
+ VPRINT (oid2ode (oid));
+ break;
+ }
+ break;
+
+ case PE_FORM_CONS:
+ switch (PE_ID (pe -> pe_class, pe -> pe_id)) {
+ case PE_ID (PE_CLASS_UNIV, PE_CONS_SEQ):
+ case PE_ID (PE_CLASS_UNIV, PE_CONS_SET):
+ break;
+
+ case PE_ID (PE_CLASS_UNIV, PE_CONS_EXTN):
+ (void) print_UNIV_EXTERNAL (pe, 1, NULLIP, NULLVP,
+ NULLCP);
+ return;
+
+ default:
+ vtag ((int) pe -> pe_class, (int) pe -> pe_id);
+ break;
+ }
+ vpush ();
+ for (p = pe -> pe_cons; p; p = p -> pe_next)
+ vunknown (p);
+ vpop ();
+ break;
+
+ case PE_FORM_ICONS:
+ vtag ((int) pe -> pe_class, (int) pe -> pe_id);
+ vstring (pe);
+ break;
+ }
+}
+
+/* VPUSHFP/VPOPFP */
+
+vpushfp (fp, pe, s, rw)
+FILE *fp;
+PE pe;
+char *s;
+int rw;
+{
+ vpushpp ((caddr_t) fp, fprintf, pe, s, rw);
+}
+
+vsetfp (fp, s)
+FILE * fp;
+char * s;
+{
+ vfp = fp;
+ vfnx = (IFP) fprintf;
+
+ if(s != NULLCP)
+ (*vfnx) (vfp, "%s\n", s);
+
+ vlevel = didname = didvpush = didvpop = docomma = 0;
+}
+
+vpopfp ()
+{
+ (*vfnx) (vfp, "-------\n");
+ (void) fflush (vfp);
+
+ vpopp ();
+}
+
+/* VPUSHSTR/VPOPSTR */
+
+vpushstr (cp)
+char *cp;
+{
+ vfp = NULL;
+ vbp = vsp = cp;
+
+ vlevel = didname = didvpush = didvpop = docomma = 0;
+}
+
+
+vpopstr ()
+{
+ while (--vbp >= vsp)
+ if (*vbp != ' ')
+ break;
+ *++vbp = NULL;
+
+ vfp = stdout;
+}
+
+/* VPUSHPP */
+
+vpushpp (pv, pfnx, pe, text, rw)
+caddr_t pv;
+IFP pfnx;
+register PE pe;
+char *text;
+int rw;
+{
+ vfp = (FILE *) pv, vfnx = pfnx;
+
+ (*vfnx) (vfp, "%s %s", rw ? "read" : "wrote", text ? text : "pdu");
+ if (pe -> pe_context != PE_DFLT_CTX)
+ (*vfnx) (vfp, ", context %d", pe -> pe_context);
+ (*vfnx) (vfp, "\n");
+
+ vlevel = didname = didvpush = didvpop = docomma = 0;
+}
+
+vpopp ()
+{
+ vfp = stdout, vfnx = (IFP) fprintf;
+}
+
+
+vpushquipu (ps)
+PS ps;
+{
+ vps = ps;
+ vfp = NULL;
+
+ vlevel = didname = didvpush = didvpop = docomma = 0;
+}
+
+
+vpopquipu ()
+{
+ vpopp();
+ vps = NULLPS;
+}
+
+/* PVPDU - for pepsy */
+
+#undef pvpdu
+
+pvpdu (lp, ind, mod, pe, text, rw)
+register LLog *lp;
+int ind; /* index into tables */
+modtyp *mod; /* pointer to tables */
+register PE pe;
+char *text;
+int rw;
+{
+ register char *bp;
+ char buffer[BUFSIZ];
+
+ vfp = (FILE *) lp, vfnx = ll_printf;
+
+ bp = buffer;
+ (void) sprintf (bp, "%s %s", rw ? "read" : "wrote",
+ text ? text : "pdu");
+ bp += strlen (bp);
+ if (pe -> pe_context != PE_DFLT_CTX) {
+ (void) sprintf (bp, ", context %d", pe -> pe_context);
+ bp += strlen (bp);
+ }
+ LLOG (lp, LLOG_ALL, ("%s", buffer));
+
+ vlevel = didname = didvpush = didvpop = docomma = 0;
+
+ if (mod == NULL)
+ (void) vunknown (pe);
+ else
+ (void) prnt_f (ind, mod, pe, 1, NULLIP, NULLVP);
+
+ (void) ll_printf (lp, "-------\n");
+
+ (void) ll_sync (lp);
+
+ vfp = stdout, vfnx = (IFP) fprintf;
+}
+
+/* MISC */
+
+static char *bufp = NULL;
+
+static char *newbuf (i)
+int i;
+{
+ static unsigned int len = 0;
+
+ if (i++ < len)
+ return bufp;
+
+ if (bufp)
+ free (bufp);
+ if ((bufp = malloc ((unsigned int) i)))
+ len = i;
+ else
+ len = 0;
+
+ return bufp;
+}
+/* VPDU - support for backwards compatibility */
+
+_vpdu (lp, fnx, pe, text, rw)
+register LLog *lp;
+IFP fnx;
+register PE pe;
+char *text;
+int rw;
+{
+ register char *bp;
+ char buffer[BUFSIZ];
+
+ vfp = (FILE *) lp, vfnx = ll_printf;
+
+ bp = buffer;
+ (void) sprintf (bp, "%s %s", rw ? "read" : "wrote",
+ text ? text : "pdu");
+ bp += strlen (bp);
+ if (pe -> pe_context != PE_DFLT_CTX) {
+ (void) sprintf (bp, ", context %d", pe -> pe_context);
+ bp += strlen (bp);
+ }
+ LLOG (lp, LLOG_ALL, ("%s", buffer));
+
+ vlevel = didname = didvpush = didvpop = docomma = 0;
+
+ (void) (*fnx) (pe, 1, NULLIP, NULLVP, NULLCP);
+
+ (void) ll_printf (lp, "-------\n");
+
+ (void) ll_sync (lp);
+
+ vfp = stdout, vfnx = (IFP) fprintf;
+}
+
+#ifdef PEP_TEST
+free_bp()
+{
+ if (bufp)
+ free(bufp);
+}
+#endif
diff --git a/src/isode/pepsy/yacc.y.gnrc b/src/isode/pepsy/yacc.y.gnrc
new file mode 100644
index 000000000..21e14f960
--- /dev/null
+++ b/src/isode/pepsy/yacc.y.gnrc
@@ -0,0 +1,1643 @@
+/* yacc.y - yacc ASN.1 parser */
+/* %WARNING% */
+
+%{
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:31:58 eichin
+ * autoconfed isode for kerberos work
+ *
+# Revision 1.1 1994/05/31 20:40:55 eichin
+# reduced-isode release from /mit/isode/isode-subset/src
+#
+ * Revision 8.0 91/07/17 12:43:20 isode
+ * Release 7.0
+ *
+ * Revision 7.9 91/05/17 12:28:39 isode
+ * lint and include fixes
+ *
+ * Revision 7.8 91/05/12 09:34:50 mrose
+ * svr4
+ *
+ * Revision 7.7 91/02/22 09:50:19 mrose
+ * Interim 6.8
+ *
+ * Revision 7.6 91/01/09 11:17:59 mrose
+ * pow
+ *
+ * Revision 7.5 91/01/08 12:51:06 mrose
+ * update
+ *
+ * Revision 7.4 90/12/23 18:42:15 mrose
+ * update
+ *
+ * Revision 7.3 90/12/11 10:41:16 mrose
+ * sync
+ *
+ * Revision 7.2 90/11/11 10:54:24 mrose
+ * update
+ *
+ * Revision 7.1 90/11/04 19:17:31 mrose
+ * update
+ *
+ * Revision 7.0 90/11/03 21:18:17 mrose
+ * *** empty log message ***
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+#include <stdio.h>
+#include <ctype.h>
+%BEGIN(PEPSY)%
+#include "pepsydefs.h"
+%END(PEPSY)%
+%BEGIN(PEPY)%
+#include "pepy.h"
+%END(PEPY)%
+%BEGIN(ROSY)%
+#include "rosy-defs.h"
+%END(ROSY)%
+%BEGIN(MOSY)%
+#include "mosy-defs.h"
+%END(MOSY)%
+
+#define YYSTYPE YYSTKTYPE
+
+
+#define YYDEBUG 1
+
+extern int pepydebug;
+extern int doexternals;
+
+int tagcontrol = TAG_UNKNOWN;
+static int tagdefault;
+static int listtype;
+static OID modid;
+
+static int yyporting = 0;
+
+typedef struct ypa {
+ char *ya_text;
+ int ya_lineno;
+} ypa, *YA;
+#define NULLYA ((YA) 0)
+extern double pow ();
+
+%BEGIN(PEPSY)%
+/* encoding/decoding/printing/freeing functions */
+static char *efn, *dfn, *pfn, *ffn;
+
+/*
+ * clear the ?fn variables for the next coding functions
+ */
+clrfn()
+{
+ if (efn) {
+ efn = NULLCP;
+ }
+ if (dfn) {
+ dfn = NULLCP;
+ }
+ if (pfn) {
+ pfn = NULLCP;
+ }
+ if (ffn) {
+ ffn = NULLCP;
+ }
+}
+
+%END(PEPSY)%
+
+static YA new_action (text, lineno)
+char *text;
+int lineno;
+{
+ register YA ya;
+
+ if ((ya = (YA) calloc (1, sizeof *ya)) == NULLYA)
+ yyerror ("out of memory");
+
+ ya -> ya_text = text;
+ ya -> ya_lineno = lineno;
+
+ return ya;
+}
+#define free_action(ya) (void) free ((char *) (ya))
+
+typedef struct {
+ char *ys_structname;
+ char *ys_ptrname;
+} ysa, *YS;
+#define NULLYS ((YS) 0)
+
+static YS new_ys (str)
+char *str;
+{
+ register YS ys;
+ register char *p, *q;
+ char c;
+
+ if((ys = (YS) malloc (sizeof *ys)) == NULLYS)
+ yyerror ("out of memory");
+ q = str;
+ while (isspace (*q)) q++;
+ for (p = q; isalnum(*p) || *p == '_'; p++)
+ continue;
+ if (*p != '\0') {
+ c = *p;
+ *p = '\0';
+ ys -> ys_structname = new_string (q);
+ *p = c;
+ }
+ else {
+ ys -> ys_structname = new_string (q);
+ ys -> ys_ptrname = NULLCP;
+ free (str);
+ return ys;
+ }
+ for (q = p; *q != '$'; q++)
+ if (! *q) {
+ free (str);
+ ys -> ys_ptrname = NULLCP;
+ return ys;
+ }
+ q++;
+ while (isspace (*q)) q++;
+ for (p = q; isalnum(*p) || *p == '_'; p++)
+ continue;
+ *p = '\0';
+ ys -> ys_ptrname = new_string (q);
+ free (str);
+ return ys;
+}
+#define free_ys(ys) (void) free ((char *) (ys))
+
+static int final_actions = 0;
+static int start_actions = 0;
+
+char *
+hex2bin (s, pi)
+register char *s;
+int *pi;
+{
+ register char *d;
+ char *start;
+ register int c,
+ i;
+
+
+ if ((d = malloc((unsigned)strlen(s)/2 + 2)) == NULLCP)
+ yyerror ("out of memory");
+ start = d;
+ for (i = 0; *s; i++) {
+ if ((c = *s++) >= 'a' && c <= 'f')
+ c -= 'a' - 0x0a;
+ else
+ if (c >= 'A' && c <= 'F')
+ c -= 'A' - 0x0a;
+ else
+ if (c >= '0' && c <= '9')
+ c -= '0';
+ else
+ c = 0;
+
+ if (i & 1)
+ *d++ |= c & 0xf;
+ else
+ *d = (c & 0xf) << 4;
+ }
+
+ *pi = i; /* We use number semi-octets ! */
+ return start;
+}
+
+char *
+bit2bin (s, pi)
+register char *s;
+int *pi;
+{
+ register char *d;
+ char *start;
+ register int c,
+ shft,
+ i;
+
+
+ if ((d = malloc((unsigned)strlen(s)/8 + 2)) == NULLCP)
+ yyerror ("out of memory");
+ start = d;
+ *d = 0;
+ for (i = 0; *s; i++) {
+ if ((c = *s++) == '1')
+ c = 1;
+ else if (c == '0')
+ c = 0;
+ else
+ break; /* ?? */
+
+ shft = 7 - i % 8; /* shift to get to its bit */
+ *d |= c << shft;
+ if (shft == 0) /* last bit in this octet so goto next octet */
+ *++d = 0; /* initialise it to zero */
+ }
+
+ *pi = i;
+ return start;
+}
+
+bin2hex (s, d, len)
+register u_char *s;
+register char *d;
+int len;
+{
+ register int i,
+ g;
+
+ for (i = 0; i < len; i++) {
+ g = s[i >> 1];
+ if ((i & 1) == 0)
+ g >>= 4;
+ g &= 0xf;
+
+ if (g < 0x0a)
+ *d++ = g + '0';
+ else
+ *d++ = g + 'a' - 0x0a;
+ }
+
+ *d = NULL;
+
+ return len;
+}
+
+int
+hex2int(s)
+register char *s;
+{
+ register int sum = 0;
+ register int i;
+
+ while (*s) {
+ if (!isxdigit(*s))
+ break;
+ if (isdigit(*s))
+ i = *s - '0';
+ else
+ i = tolower(*s) - 'a' + 10;
+ sum = sum << 4 + i;
+ s++;
+ }
+
+ return (sum);
+}
+
+int
+bit2int(s)
+register char *s;
+{
+ register int sum = 0;
+
+ while (*s) {
+ if (*s != '0' && *s != '1')
+ break;
+ if (*s == '1')
+ sum <<= 1;
+ else
+ sum = sum << 1 + 1;
+ s++;
+ }
+ return (sum);
+}
+
+%}
+
+%start ModuleDefinition
+
+
+%union {
+ int yy_number;
+ char *yy_string;
+ YP yy_type;
+ YV yy_value;
+ YT yy_tag;
+ YA yy_action;
+ OID yy_oid;
+ YS yy_sctrl;
+ double yy_real;
+%BEGIN(PEPSY)%
+ YFN yy_yfn;
+ YAL yy_yal;
+%END(PEPSY)%
+}
+
+
+%token ABSENT ACTION ANY APPLICATION BAR BGIN BIT BITSTRING BOOLEAN
+ BSTRING BY CCE CHOICE COMMA COMPONENT COMPONENTS COMPONENTSOF
+ CONTROL DEC_FN DECODER DEFAULT DEFINED DEFINITIONS DOT DOTDOT
+ DOTDOTDOT ENC_FN ENCODER ENCRYPTED END ENUMERATED EXPORTS
+ EXPLICIT FALSE FRE_FN FROM HSTRING ID IDENTIFIER IMPLICIT
+ IMPORTS INCLUDES INTEGER LANGLE LBRACE LBRACKET LITNUMBER
+ LITSTRING LPAREN MIN MINUS MAX NAME NIL OBJECT OCTET
+ OCTETSTRING OF OPTIONAL PARAMETERTYPE PLUS PREFIXES PRESENT
+ PRINTER PRIVATE PRT_FN RBRACE RBRACKET REAL RPAREN STAR
+ SECTIONS SEMICOLON SEQUENCE SEQUENCEOF SET SETOF SIZE STRING
+ TAGS TRUE UNIVERSAL VALA VALB VALI VALS VALP VALO VALOID VALR
+ VALT VALTYPE VALQ VALX VLENGTH WITH SCTRL PLUSINFINITY
+ MINUSINFINITY
+%BEGIN(ROSY)%
+ OPERATION ARGUMENT RESULT ERRORS LINKED ERROR PARAMETER
+/* new stuff */
+ ABSTRACT OPERATIONS CONSUMER SUPPLIER INVOKES PORT PORTS
+ OBJECTCONSUMER OBJECTSUPPLIER REFINE AS RECURRING VISIBLE
+ PAIRED BIND UNBIND
+/* end new stuff */
+%END(ROSY)%
+%BEGIN(MOSY)%
+ OBJECTYPE SYNTAX ACCESS STATUS
+%END(MOSY)%
+%BEGIN(PEPSY)%
+ EACTION DACTION PACTION ECHOICE DCHOICE PCHOICE
+%END(PEPSY)%
+
+%type <yy_number> LITNUMBER
+%type <yy_number> ABSENT ANY BGIN APPLICATION BIT BITSTRING
+ BOOLEAN CHOICE COMPONENT COMPONENTS COMPONENTSOF
+ DECODER DEFAULT DEFINED DEFINITIONS ENCODER
+ ENCRYPTED END ENUMERATED EXPLICIT EXPORTS
+ FALSE FROM IDENTIFIER IMPLICIT IMPORTS INCLUDES
+ INTEGER MIN MAX NIL OBJECT OCTET OCTETSTRING
+ OF OPTIONAL PREFIXES PRESENT PRINTER PRIVATE REAL
+ SECTIONS SEQUENCE SEQUENCEOF SET STRING TAGS
+ TRUE UNIVERSAL WITH PLUSINFINITY MINUSINFINITY
+ AnyType
+%type <yy_real> RealValue NumericRealValue SpecialRealValue
+%type <yy_string> DEC_FN ENC_FN PRT_FN FRE_FN ID NAME LITSTRING
+ BSTRING HSTRING VALA VALB VALI VALS VALP VALQ
+ VALR VALT VALTYPE VALO VALX VLENGTH VALOID
+ CONTROL PARAMETERTYPE ParameterType Control
+ ValParameter String PassInt PassBool PassOid
+ PassAny PassReal ModuleIdentifier Symbol
+ SymbolList SCTRL
+%type <yy_type> Type BuiltinType DefinedType PassValue PassBit
+ PassString NullPass ElementTypes
+ OptionalTypeList OptionalType NamedType
+ ComponentsOf AlternativeTypeList MemberTypes
+ SubType Valtype
+%BEGIN(ROSY)%
+ Argument Result Parameter
+%END(ROSY)%
+%type <yy_value> NamedNumberList NamedNumber
+NumericValue
+ Value BuiltinValue DefinedValue IdentifierList
+ Values NamedValueList NamedValue NNlist
+%BEGIN(ROSY)%
+ Errors ErrorNames LinkedOperations
+ LinkedOperationNames
+%END(ROSY)%
+%BEGIN(MOSY)%
+ ObjectID ObjectIDComponentList ObjectSubID
+%END(MOSY)%
+%BEGIN(PEPSY)%
+%type <yy_yfn> CodingFn
+%type <yy_yal> UAction CAction
+%type <yy_action> EACTION DACTION PACTION ECHOICE DCHOICE PCHOICE
+%END(PEPSY)%
+%type <yy_tag> Tag Class
+%type <yy_action> ACTION
+%type <yy_oid> ObjIdComponentList ObjectIdentifierValue
+ ObjIdComponent NumberForm NameAndNumberForm
+%type <yy_sctrl> Sctrl
+%%
+
+ModuleDefinition: ModuleIdentifier DEFINITIONS TagDefault CCE
+ {
+ mymodule = $1;
+ mymoduleid = modid;
+ pass1 ();
+ }
+ ModuleActions ModulePrefixes { start_actions++; }
+ BGIN ModuleBody END
+ ModuleActions { pass2 (); final_actions++; }
+ ;
+
+TagDefault: EXPLICIT TAGS {
+ tagdefault = 0;
+ tagcontrol = TAG_EXPLICIT;
+ }
+ | IMPLICIT TAGS {
+ tagdefault = YP_IMPLICIT;
+ tagcontrol = TAG_IMPLICIT;
+ }
+ | empty {
+ tagdefault = 0;
+ tagcontrol = TAG_UNKNOWN;
+ }
+ ;
+
+ModuleIdentifier: ID AssignedIdentifier { $$ = $1; }
+ ;
+
+AssignedIdentifier: ObjectIdentifierValue { modid = $1; }
+ | empty
+ ;
+
+ModuleActions: ACTION {
+%BEGIN(PEPSY)%
+ { Action a;
+
+ a = new_action_t($1 -> ya_text,
+ $1 -> ya_lineno,
+ 0);
+ if (start_actions)
+ final_action = a;
+ else
+ start_action = a;
+ free_action ($1);
+ break;
+ /*NOTREACHED*/
+ }
+%END(PEPSY)%
+ /*
+%BEGIN(PEPY)%
+ if (bflag) {
+ if (final_actions)
+ init_new_file ();
+ else {
+ module_actions = $1 -> ya_text;
+ free_action ($1);
+ break;
+ }
+ }
+%END(PEPY)%
+ if (!dflag) {
+ if (Cflag > 0) {
+ if (!Pflag && *sysin)
+ (void) printf ("# line %d \"%s\"\n",
+ $1 -> ya_lineno, sysin);
+ fputs ($1 -> ya_text, stdout);
+ }
+ else {
+ (void) printf ("%%{\n#include \"%s-types.h\"\n",
+ mymodule);
+ (void) printf ("%s%%}\n", $1 -> ya_text);
+ Cflag = -1;
+ }
+ }
+ free_action ($1);
+%BEGIN(PEPY)%
+ if (bflag)
+ end_file ();
+%END(PEPY)%
+ */
+ }
+ | empty
+ ;
+ModulePrefixes:
+ PREFIXES String String String
+ {
+ yyencdflt = $2;
+ yydecdflt = $3;
+ yyprfdflt = $4;
+ }
+ | empty
+ ;
+ModuleBody: Exports Imports AssignmentList
+ ;
+
+Exports: EXPORTS { listtype = TBL_EXPORT; doexternals = 0;
+ yyporting = 1; }
+ SymbolsExported SEMICOLON {
+ yyporting = 0;
+ if (mymoduleid == NULLOID)
+ warning ("EXPORTS but no ModuleIdentifier");
+
+ }
+ | empty
+ ;
+
+SymbolsExported: SymbolList
+ | empty
+ ;
+
+Imports: IMPORTS { listtype = TBL_IMPORT; yyporting = 1; }
+ SymbolsImported SEMICOLON {
+ yyporting = 0;
+ if (mymoduleid == NULLOID)
+ warning ("IMPORTS but no ModuleIdentifier");
+ }
+
+ | empty
+ ;
+
+SymbolsImported: SymbolsFromModuleList
+ | empty
+ ;
+
+SymbolsFromModuleList: SymbolsFromModuleList SymbolsFromModule
+ | SymbolsFromModule
+ ;
+
+SymbolsFromModule: SymbolList FROM ModuleIdentifier
+ {
+ addtableref ($3, modid, listtype);
+ }
+ ;
+
+SymbolList: SymbolList COMMA Symbol {
+ addtable($3, listtype, ER_UNKNOWN);
+ }
+ | Symbol { addtable ($1, listtype, ER_UNKNOWN); }
+
+ | SymbolList COMMA MINUS Symbol {
+ addtable($4, listtype, ER_NORMAL);
+ }
+ | MINUS Symbol { addtable ($2, listtype, ER_NORMAL); }
+
+ | SymbolList COMMA PLUS Symbol {
+ addtable($4, listtype, ER_EXPLICIT);
+ }
+ | PLUS Symbol { addtable ($2, listtype, ER_EXPLICIT); }
+ ;
+
+Symbol: ID
+ | NAME
+ ;
+
+AssignmentList: AssignmentList Section Assignment
+ | empty
+ ;
+
+Section: ENCODER String
+ { yysection = YP_ENCODER; yyencpref = $2;
+ yyprint (NULLCP, 0, 1); }
+ | DECODER String
+ { yysection = YP_DECODER; yydecpref = $2;
+ yyprint (NULLCP, 0, 1); }
+ | PRINTER String
+ { yysection = YP_PRINTER; yyprfpref = $2;
+ yyprint (NULLCP, 0, 1); }
+ | SECTIONS String String String
+ {
+ yysection = NULL;
+ if (strcmp (yyencpref = $2, "none"))
+ yysection |= YP_ENCODER;
+ if (strcmp (yydecpref = $3, "none"))
+ yysection |= YP_DECODER;
+ if (strcmp (yyprfpref = $4, "none"))
+ yysection |= YP_PRINTER;
+ yyprint (NULLCP, 0, 1);
+ }
+ | empty
+ ;
+
+String: ID { $$ = $1; }
+ | NAME { $$ = $1; }
+ ;
+
+Assignment: Typeassignment
+%BEGIN(ROSY)%
+ | OperationDefinition
+ | ErrorDefinition
+/* new stuff */
+ | PortDefinition
+ | ObjectDefinition
+/* | RefineDefinition -- impossible!!!! (JPO) */
+/* | BindDefinition -- lacking defs... */
+/* | UnBindDefinition -- ditto */
+/* end new stuff */
+%END(ROSY)%
+%BEGIN(MOSY)%
+ | ObjectTypeDefinition
+ | ObjectIDefinition
+%END(MOSY)%
+ | Valueassignment
+ ;
+
+%BEGIN(ROSY)%
+OperationDefinition: NAME OPERATION Argument Result Errors LinkedOperations
+ CCE LITNUMBER {
+ pass1_op (mymodule, $1, $3, $4, $5, $6, $8);
+ }
+ ;
+
+Argument: ARGUMENT NamedType { $$ = $2; }
+ | empty { $$ = NULLYP; }
+ ;
+
+Result: RESULT NamedType { $$ = $2; }
+ | empty { $$ = NULLYP; }
+ ;
+
+Errors: ERRORS LBRACE ErrorNames RBRACE { $$ = $3; }
+ | empty { $$ = NULLYV; }
+
+LinkedOperations: LINKED LBRACE LinkedOperationNames RBRACE { $$ = $3; }
+ | empty { $$ = NULLYV; }
+
+
+ErrorNames: NamedValueList {
+ $$ = new_value (YV_VALIST);
+ $$ -> yv_idlist = $1;
+ }
+ | empty { $$ = NULLYV; }
+
+
+LinkedOperationNames: NamedValueList {
+ $$ = new_value (YV_VALIST);
+ $$ -> yv_idlist = $1;
+ }
+ | empty { $$ = NULLYV; }
+
+
+ErrorDefinition: NAME ERROR Parameter CCE LITNUMBER {
+ pass1_err (mymodule, $1, $3, $5);
+ }
+ ;
+
+Parameter: PARAMETER NamedType { $$ = $2; }
+ | empty { $$ = NULLYP; }
+ ;
+
+/* new stuff start */
+PortDefinition: NAME PORT PortOperations CCE PortValue
+ ;
+
+PortValue: ObjectIdentifierValue
+ | NAME
+ ;
+
+PortOperations: PortSymmetrical
+ | PortAsymetrical
+ | empty
+
+PortSymmetrical: ABSTRACT OPERATIONS LBRACE PortOperationList RBRACE
+ ;
+
+PortAsymetrical: PortOneSided
+ | PortTwoSided
+ ;
+
+PortOneSided: PortConsumer
+ | PortSupplier
+ ;
+
+PortTwoSided: PortConsumer PortSupplier
+ | PortSupplier PortConsumer
+ ;
+
+PortConsumer: CONSUMER INVOKES LBRACE PortOperationList RBRACE
+ ;
+
+PortSupplier: SUPPLIER INVOKES LBRACE PortOperationList RBRACE
+ ;
+
+PortOperationList: OperationValue
+ | OperationValue COMMA PortOperationList
+ ;
+
+OperationValue: NAME
+ | ID
+ | LITNUMBER
+ | ObjectIdentifierValue
+ ;
+
+ObjectDefinition: NAME OBJECT ObjectType CCE PortValue
+ ;
+
+ObjectType: PORTS LBRACE ObjectPortList RBRACE
+ | empty
+ ;
+
+ObjectPortList: ObjectPort COMMA ObjectPortList
+ | ObjectPort
+ ;
+
+ObjectPort: PortValue ObjectPortType
+ ;
+
+ObjectPortType: ObjectSymetric
+ | ObjectAsymetric
+ ;
+
+ObjectSymetric: empty
+ ;
+
+ObjectAsymetric: OBJECTCONSUMER
+ | OBJECTSUPPLIER
+ ;
+
+/* New stuff end */
+%END(ROSY)%
+
+%BEGIN(MOSY)%
+ObjectTypeDefinition: NAME OBJECTYPE SYNTAX NamedType ACCESS NAME
+ STATUS NAME CCE ObjectID {
+ pass1_obj (mymodule, $1, $4, $10, $6, $8);
+ }
+ ;
+
+ObjectIDefinition: NAME OBJECT IDENTIFIER CCE ObjectID {
+ pass1_oid (mymodule, $1, $5);
+ }
+ ;
+
+ObjectID: NAME {
+ $$ = new_value (YV_OIDLIST);
+ $$ -> yv_idlist = new_value (YV_IDEFINED);
+ $$ -> yv_idlist -> yv_identifier = $1;
+ $$ -> yv_idlist -> yv_flags |= YV_BOUND;
+ }
+ | LBRACE ObjectIDComponentList RBRACE {
+ $$ = new_value (YV_OIDLIST);
+ $$ -> yv_idlist = $2;
+ }
+ ;
+ObjectIDComponentList: ObjectSubID { $$ = $1; }
+ | ObjectIDComponentList ObjectSubID {
+ $$ = add_value ($1, $2);
+ }
+ ;
+ObjectSubID: LITNUMBER {
+ $$ = new_value (YV_NUMBER);
+ $$ -> yv_number = $1;
+ }
+ | NAME {
+ $$ = new_value (YV_IDEFINED);
+ $$ -> yv_identifier = $1;
+ $$ -> yv_flags |= YV_BOUND;
+ }
+ | NAME LPAREN LITNUMBER RPAREN {
+ $$ = new_value (YV_NUMBER);
+ $$ -> yv_number = $3;
+ $$ -> yv_named = $1;
+ $$ -> yv_flags |= YV_NAMED;
+ }
+ ;
+%END(MOSY)%
+%BEGIN(PEPSY)%
+UAction: UAction EACTION {
+ if ($1 == NULLYAL)
+ $$ = new_yal();
+ else
+ $$ = $1;
+ if ($$->yal_enc)
+ yyerror("multiple encoding actions at the one place\n");
+ $$->yal_enc = new_action_t($2->ya_text,
+ $2->ya_lineno, e_actions++);
+ }
+ | UAction DACTION {
+ if ($1 == NULLYAL)
+ $$ = new_yal();
+ else
+ $$ = $1;
+ if ($$->yal_dec)
+ yyerror("multiple decoding actions at the one place\n");
+ $$->yal_dec = new_action_t($2->ya_text, $2->ya_lineno, d_actions++);
+ }
+ | UAction PACTION {
+ if ($1 == NULLYAL)
+ $$ = new_yal();
+ else
+ $$ = $1;
+ if ($$->yal_prn)
+ yyerror("multiple printing actions at the one place\n");
+ $$->yal_prn = new_action_t($2->ya_text, $2->ya_lineno, p_actions++);
+ }
+ | empty
+ { $$ = NULLYAL; }
+ ;
+
+CAction: CAction ECHOICE {
+ if ($1 == NULLYAL)
+ $$ = new_yal();
+ else
+ $$ = $1;
+ if ($$->yal_enc)
+ yyerror("multiple choice encoding actions at the one place\n");
+ $$->yal_enc = new_action_t($2->ya_text,
+ $2->ya_lineno, e_actions++);
+ }
+ | CAction DCHOICE {
+ if ($1 == NULLYAL)
+ $$ = new_yal();
+ else
+ $$ = $1;
+ if ($$->yal_dec)
+ yyerror("multiple choice decoding actions at the one place\n");
+ $$->yal_dec = new_action_t($2->ya_text, $2->ya_lineno, d_actions ++);
+ }
+ | CAction PCHOICE {
+ if ($1 == NULLYAL)
+ $$ = new_yal();
+ else
+ $$ = $1;
+ if ($$->yal_prn)
+ yyerror("multiple choice printing actions at the one place\n");
+ $$->yal_prn = new_action_t($2->ya_text, $2->ya_lineno, 0);
+ }
+ | empty
+ { $$ = NULLYAL; }
+ ;
+
+%END(PEPSY)%
+
+Typeassignment: ID ParameterType CCE UAction Type {
+ if ($2)
+ $5 -> yp_param_type = $2;
+ if ($4)
+ $5->yp_bef_alist=yal_join($4, $5->yp_bef_alist);
+ pass1_type (yyencpref, yydecpref, yyprfpref,
+ mymodule, $1, $5);
+ } ;
+
+Type: BuiltinType CodingFn UAction {
+ $$ = $1;
+ $$ -> yp_direction = yysection;
+ if ($2)
+ $$->yp_yfn = join_yfn($$->yp_yfn, $2);
+ if ($3)
+ $$->yp_aft_alist=yal_join($3, $$->yp_aft_alist);
+ }
+ | DefinedType CodingFn UAction {
+ $$ = $1;
+ $$ -> yp_direction = yysection;
+ if ($2)
+ $$->yp_yfn = join_yfn($$->yp_yfn, $2);
+ if ($3)
+ $$->yp_aft_alist=yal_join($3, $$->yp_aft_alist);
+ }
+ | SubType CodingFn UAction {
+ $$ = $1;
+ $$ -> yp_direction = yysection;
+ if ($2)
+ $$->yp_yfn = join_yfn($$->yp_yfn, $2);
+ if ($3)
+ $$->yp_aft_alist=yal_join($3, $$->yp_aft_alist);
+ }
+ ;
+
+
+Control: CONTROL
+ | empty { $$ = NULLCP; }
+ ;
+
+ParameterType: PARAMETERTYPE
+ | empty { $$ = NULLCP; }
+ ;
+
+Valtype: VALTYPE {
+ $$ = new_type(YP_UNDF, -1);
+ if (setvaltype($$, $1) == 0)
+ yyerror("syntax error in [[ T ... ]]");
+ free($1);
+ }
+ | empty { $$ = new_type(YP_UNDF, -1); }
+ ;
+
+BuiltinType: BOOLEAN PassBool {
+ $$ = new_type (YP_BOOL, $1);
+ $$ -> yp_intexp = $2;
+ }
+ | INTEGER PassInt NNlist {
+ $$ = new_type ($3 ? YP_INTLIST : YP_INT, $1);
+ $$ -> yp_intexp = $2;
+ if ($3)
+ $$ -> yp_value = $3;
+ }
+ | ENUMERATED PassInt LBRACE NamedNumberList
+ RBRACE {
+ $$ = new_type (YP_ENUMLIST, $1);
+ $$ -> yp_intexp = $2;
+ $$ -> yp_value = $4;
+ }
+
+ | Bitstring PassBit NNlist {
+ $$ = $2;
+ $$ -> yp_code = $3 ? YP_BITLIST: YP_BIT;
+ if ($3)
+ $$ -> yp_value = $3;
+ }
+ | Octetstring PassString {
+ $$ = $2;
+ $$ -> yp_code = YP_OCT;
+ }
+ | NIL {
+ $$ = new_type (YP_NULL, $1);
+ }
+ | SEQUENCE Sctrl PassAny {
+ $$ = new_type (YP_SEQ, $1);
+ $$ -> yp_strexp = $3;
+ }
+ | SequenceOf Sctrl Valtype Control UAction Type {
+ $$ = $3;
+ $$->yp_code = YP_SEQTYPE;
+ $$ -> yp_type = $6;
+ if ($2) {
+ $$ -> yp_structname = $2 -> ys_structname;
+ $$ -> yp_ptrname = $2 -> ys_ptrname;
+ free_ys ($2);
+ }
+ if ($4) {
+ $$ -> yp_control = $4;
+ $$ -> yp_flags |= YP_CONTROLLED;
+ }
+ if ($5)
+ $6->yp_bef_alist=yal_join($5, $6->yp_bef_alist);
+ }
+ | SEQUENCE Sctrl Valtype LBRACE UAction ElementTypes RBRACE {
+ $$ = $3;
+ $$->yp_code = YP_SEQLIST;
+ $$ -> yp_type = $6;
+ if ($2) {
+ $$ -> yp_structname = $2 -> ys_structname;
+ $$ -> yp_ptrname = $2 -> ys_ptrname;
+ free_ys ($2);
+ }
+ if ($6 && $5)
+ $6->yp_bef_alist=yal_join($5, $6->yp_bef_alist);
+ }
+ | SET Sctrl PassAny {
+ $$ = new_type (YP_SET, $1);
+ $$ -> yp_strexp = $3;
+ }
+ | SetOf Sctrl Valtype Control UAction Type {
+ $$ = $3;
+ $$->yp_code = YP_SETTYPE;
+ $$ -> yp_type = $6;
+ if ($2) {
+ $$ -> yp_structname = $2 -> ys_structname;
+ $$ -> yp_ptrname = $2 -> ys_ptrname;
+ free_ys ($2);
+ }
+ if ($4) {
+ $$ -> yp_control = $4;
+ $$ -> yp_flags |= YP_CONTROLLED;
+ }
+ if ($5)
+ $6->yp_bef_alist=yal_join($5, $6->yp_bef_alist);
+ }
+
+ | SET Sctrl Valtype LBRACE UAction MemberTypes RBRACE {
+ $$ = $3;
+ $$->yp_code = YP_SETLIST;
+ $$ -> yp_type = $6;
+ if ($2) {
+ $$ -> yp_structname = $2 -> ys_structname;
+ $$ -> yp_ptrname = $2 -> ys_ptrname;
+ free_ys ($2);
+ }
+ if ($6 && $5)
+ $6->yp_bef_alist=yal_join($5, $6->yp_bef_alist);
+ }
+ | Tag UAction IMPLICIT Type {
+ $$ = $4;
+ $$ -> yp_tag = $1;
+ $$ -> yp_flags |= (YP_IMPLICIT | YP_TAG);
+ if ($2)
+ $$->yp_bef_alist=yal_join($2, $$->yp_bef_alist);
+ }
+ | Tag UAction EXPLICIT Type {
+ $$ = $4;
+ $$ -> yp_tag = $1;
+ $$ -> yp_flags |= YP_TAG;
+ if ($2)
+ $$->yp_bef_alist=yal_join($2, $$->yp_bef_alist);
+ }
+ | Tag UAction Type {
+ $$ = $3;
+ $$ -> yp_tag = $1;
+ $$ -> yp_flags |= (YP_TAG| tagdefault);
+ if ($2)
+ $$->yp_bef_alist=yal_join($2, $$->yp_bef_alist);
+ }
+ | CHOICE Sctrl Valtype Control CAction LBRACE UAction
+ AlternativeTypeList RBRACE {
+ $$ = $3;
+ $$->yp_code = YP_CHOICE;
+ $$ -> yp_type = $8;
+ if ($2) {
+ $$ -> yp_structname = $2 -> ys_structname;
+ $$ -> yp_ptrname = $2 -> ys_ptrname;
+ free_ys ($2);
+ }
+ if ($4) {
+ $$ -> yp_control = $4;
+ $$ -> yp_flags |= YP_CONTROLLED;
+ }
+ if ($5)
+ $$ -> yp_control_act = $5;
+ if ($8 && $7)
+ $8->yp_bef_alist=yal_join($7, $8->yp_bef_alist);
+ }
+ | NAME LANGLE Type {
+ $$ = $3;
+ $$ -> yp_bound = $1;
+ $$ -> yp_flags |= YP_BOUND;
+ }
+ | AnyType PassAny {
+ $$ = new_type (YP_ANY, $1);
+ $$ -> yp_strexp = $2;
+ }
+ | STAR AnyType PassAny {
+ $$ = new_type (YP_ANY, $2);
+ $$ -> yp_strexp = $3;
+ $$ -> yp_flags |= YP_WANTIMPLICIT;
+ }
+ | OBJECT IDENTIFIER PassOid {
+ $$ = new_type (YP_OID, $1);
+ $$ -> yp_strexp = $3;
+ }
+ | ENCRYPTED Type {
+ $$ = $2;
+ $$ -> yp_tag = new_tag (PE_CLASS_UNIV);
+ $$ -> yp_tag -> yt_value = new_value(YV_NUMBER);
+ $$ -> yp_tag -> yt_value -> yv_number = PE_PRIM_ENCR;
+ $$ -> yp_flags |=
+ (YP_ENCRYPTED | YP_TAG | YP_IMPLICIT);
+ }
+ | REAL PassReal {
+ $$ = new_type(YP_REAL, $1);
+ $$ -> yp_strexp = $2;
+ }
+ ;
+
+NNlist: LBRACE NamedNumberList RBRACE { $$ = $2; }
+ | empty { $$ = NULL; }
+ ;
+DefinedType: ID PassValue ValParameter {
+ $$ = $2;
+ $$ -> yp_code = YP_IDEFINED;
+ $$ -> yp_identifier = $1;
+ if ($3) {
+ $$ -> yp_parm = $3;
+ $$ -> yp_flags |= YP_PARMVAL;
+ }
+%BEGIN(ROSY)%
+#ifndef lint
+%END(ROSY)%
+ check_impexp ($$);
+%BEGIN(ROSY)%
+#endif
+%END(ROSY)%
+ }
+ | ID DOT ID PassValue ValParameter {
+ $$ = $4;
+ $$ -> yp_code = YP_IDEFINED;
+ $$ -> yp_identifier = $3;
+ $$ -> yp_module = $1;
+ if ($5) {
+ $$ -> yp_parm = $5;
+ $$ -> yp_flags |= YP_PARMVAL;
+ }
+ }
+ ;
+
+PassValue: VALA {
+ $$ = new_type (YP_UNDF, -1);
+ $$ -> yp_intexp = NULLCP;
+ $$ -> yp_strexp = $1;
+ $$ -> yp_prfexp = 'a';
+ }
+ | VALB {
+ $$ = new_type (YP_UNDF, -1);
+ $$ -> yp_intexp = $1;
+ $$ -> yp_strexp = NULLCP;
+ $$ -> yp_prfexp = 'b';
+ }
+ | VALI {
+ $$ = new_type (YP_UNDF, -1);
+ $$ -> yp_intexp = $1;
+ $$ -> yp_strexp = NULLCP;
+ $$ -> yp_prfexp = 'i';
+ }
+ | VALX VLENGTH {
+ $$ = new_type (YP_UNDF, -1);
+ $$ -> yp_intexp = $2;
+ $$ -> yp_strexp = $1;
+ $$ -> yp_prfexp = 'x';
+ }
+ | VALOID {
+ $$ = new_type (YP_UNDF, -1);
+ $$ -> yp_intexp = NULLCP;
+ $$ -> yp_strexp = $1;
+ $$ -> yp_prfexp = 'O';
+ }
+ | VALR {
+ $$ = new_type (YP_UNDF, -1);
+ $$ -> yp_intexp = NULLCP;
+ $$ -> yp_strexp = $1;
+ $$ -> yp_prfexp = 'r';
+ }
+ | VALT {
+ $$ = new_type (YP_UNDF, -1);
+ $$ -> yp_intexp = $1;
+ $$ -> yp_prfexp = 't';
+ }
+ | PassString
+ ;
+
+AnyType: ANY
+ | ANY DEFINED BY NAME
+ ;
+
+PassOid: VALOID
+ | empty { $$ = NULLCP; }
+ ;
+
+PassAny: VALA
+ | empty { $$ = NULLCP; }
+ ;
+
+PassBool: VALB
+ | empty { $$ = NULLCP; }
+ ;
+
+PassInt: VALI
+ | empty { $$ = NULLCP; }
+ ;
+
+PassBit: VALX VLENGTH {
+ $$ = new_type (YP_UNDF, -1);
+ $$ -> yp_intexp = $2;
+ $$ -> yp_strexp = $1;
+ }
+ | VALT {
+ $$ = new_type (YP_UNDF, -1);
+ $$ -> yp_intexp = $1;
+ $$ -> yp_strexp = NULLCP;
+ }
+ | NullPass
+ ;
+
+PassString: VALS {
+ $$ = new_type (YP_UNDF, -1);
+ $$ -> yp_intexp = NULLCP;
+ $$ -> yp_strexp = $1;
+ $$ -> yp_prfexp = 's';
+ }
+ | VALO VLENGTH {
+ $$ = new_type (YP_UNDF, -1);
+ $$ -> yp_intexp = $2;
+ $$ -> yp_strexp = $1;
+ $$ -> yp_prfexp = 'o';
+ }
+ | VALQ {
+ $$ = new_type (YP_UNDF, -1);
+ $$ -> yp_intexp = NULLCP;
+ $$ -> yp_strexp = $1;
+ $$ -> yp_prfexp = 'q';
+ }
+ | NullPass
+ ;
+
+PassReal: VALR
+ | empty { $$ = NULLCP; }
+ ;
+
+NullPass: empty {
+ $$ = new_type (YP_UNDF, -1);
+ $$ -> yp_intexp = NULLCP;
+ $$ -> yp_strexp = NULLCP;
+ }
+ ;
+
+CodingFn: fnlist {
+ $$ = new_yfn(efn, dfn, pfn, ffn);
+ clrfn();
+ }
+ | { $$ = NULLYFN; }
+ ;
+
+fn: ENC_FN {
+ if (efn)
+ myyerror("extra encoding function %s ignored\n", $1);
+ else
+ efn = $1;
+ }
+ | DEC_FN {
+ if (dfn)
+ myyerror("extra decoding function %s ignored\n", $1);
+ else
+ dfn = $1;
+ }
+ | PRT_FN {
+ if (pfn)
+ myyerror("extra printing function %s ignored\n", $1);
+ else
+ pfn = $1;
+ }
+ | FRE_FN {
+ if (ffn)
+ myyerror("extra freeing function %s ignored\n", $1);
+ else
+ ffn = $1;
+ }
+ ;
+
+fnlist: fn
+ | fnlist fn
+
+ValParameter: VALP
+ | empty { $$ = NULLCP; }
+ ;
+
+NamedNumberList: NamedNumber { $$ = $1; }
+ | NamedNumberList COMMA NamedNumber {
+ $$ = add_value ($1, $3);
+ }
+ ;
+NamedNumber: NAME LPAREN NumericValue RPAREN {
+ $$ = $3;
+ $$ -> yv_named = $1;
+ $$ -> yv_flags |= YV_NAMED;
+ }
+ ;
+NumericValue: LITNUMBER {
+ $$ = new_value (YV_NUMBER);
+ $$ -> yv_number = $1;
+ }
+ | DefinedValue
+ ;
+
+ElementTypes: OptionalTypeList { $$ = $1; }
+ | empty { $$ = NULLYP; }
+ ;
+MemberTypes: OptionalTypeList { $$ = $1; }
+
+ | empty { $$ = NULLYP; }
+ ;
+OptionalTypeList: OptionalType { $$ = $1; }
+ | OptionalTypeList COMMA UAction OptionalType {
+ if ($3)
+ $4->yp_bef_alist=yal_join($3, $4->yp_bef_alist);
+ $$ = add_type ($1, $4);
+ }
+ ;
+OptionalType: NamedType { $$ = $1; }
+ | NamedType OPTIONAL Control {
+ $$ = $1;
+ $$ -> yp_flags |= YP_OPTIONAL;
+ if ($3) {
+ $$ -> yp_optcontrol = $3;
+ $$ -> yp_flags |= YP_OPTCONTROL;
+ }
+ }
+ | NamedType OPTIONAL CAction {
+ $$ = $1;
+ $$ -> yp_flags |= YP_OPTIONAL;
+ if ($3) {
+ $$ -> yp_flags |= YP_OPTCONTROL;
+ $$ -> yp_optional_act = $3;
+ }
+ }
+ | NamedType DEFAULT Value Control {
+ $$ = $1;
+ $$ -> yp_default = $3;
+ $$ -> yp_flags |= YP_DEFAULT;
+ if ($4) {
+ $$ -> yp_optcontrol = $4;
+ $$ -> yp_flags |= YP_OPTCONTROL;
+ }
+ }
+ | ComponentsOf { $$ = $1; }
+ | NAME ComponentsOf { $$ = $2; $$->yp_id = $1; }
+ ;
+NamedType: NAME Type {
+ $$ = $2;
+ $$ -> yp_id = $1;
+ $$ -> yp_flags |= YP_ID;
+ }
+ | Type { $$ = $1; }
+ ;
+ComponentsOf: Components Type {
+ $$ = $2;
+ $$ -> yp_flags |= YP_COMPONENTS;
+ }
+ ;
+AlternativeTypeList: NamedType { $$ = $1; }
+ | AlternativeTypeList COMMA UAction NamedType {
+ if ($3)
+ $4->yp_bef_alist=yal_join($3, $4->yp_bef_alist);
+ $$ = add_type ($1, $4);
+ }
+ ;
+
+Tag: LBRACKET Class NumericValue RBRACKET {
+ $$ = $2;
+ $$ -> yt_value = $3;
+ }
+ ;
+Class: UNIVERSAL { $$ = new_tag (PE_CLASS_UNIV); }
+ | APPLICATION { $$ = new_tag (PE_CLASS_APPL); }
+ | PRIVATE { $$ = new_tag (PE_CLASS_PRIV); }
+ | empty { $$ = new_tag (PE_CLASS_CONT); }
+ ;
+
+
+Valueassignment: NAME Type CCE Value
+ ;
+
+Value: BuiltinValue
+ | DefinedValue
+ ;
+BuiltinValue: TRUE {
+ $$ = new_value (YV_BOOL);
+ $$ -> yv_number = 1;
+ }
+ | FALSE {
+ $$ = new_value (YV_BOOL);
+ $$ -> yv_number = 0;
+ }
+ | LITNUMBER {
+ $$ = new_value (YV_NUMBER);
+ $$ -> yv_number = $1;
+ }
+ | BSTRING {
+ $$ = new_value (YV_BSTRING);
+ $$ -> yv_xstring = bit2bin($1, &$$->yv_xlength);
+ free($1);
+ }
+ | HSTRING {
+ $$ = new_value (YV_HSTRING);
+ $$ -> yv_xstring = hex2bin($1, &$$->yv_xlength);
+ free($1);
+ }
+ | LBRACE ID IdentifierList RBRACE {
+ $$ = new_value (YV_IDLIST);
+ $$ -> yv_idlist = new_value (YV_IDEFINED);
+ $$ -> yv_idlist -> yv_identifier = $2;
+ if ($3)
+ $$ = add_value ($$, $3);
+ }
+ | LITSTRING {
+ $$ = new_value (YV_STRING);
+ $$ -> yv_string = $1;
+ }
+ | NIL { $$ = new_value (YV_NULL); }
+ | LBRACE Values RBRACE {
+ $$ = new_value (YV_VALIST);
+ $$ -> yv_idlist = $2;
+ }
+ | NAME Value {
+ $$ = $2;
+ $$ -> yv_id = $1;
+ $$ -> yv_flags |= YV_ID;
+ }
+ | Type Value {
+ $$ = $2;
+ $$ -> yv_type = $1;
+ $$ -> yv_flags |= YV_TYPE;
+ }
+ | RealValue {
+ $$ = new_value (YV_REAL);
+ $$ -> yv_real = $1;
+ }
+ ;
+
+RealValue: NumericRealValue
+ | SpecialRealValue
+ ;
+
+SpecialRealValue: PLUSINFINITY { $$ = PE_REAL_INFINITY;}
+ | MINUSINFINITY { $$ = - PE_REAL_INFINITY; }
+ ;
+
+NumericRealValue: LBRACE LITNUMBER COMMA LITNUMBER COMMA
+ LITNUMBER RBRACE {
+ if ($4 != 2 && $4 != 10)
+ myyerror ("Illegal base value %d", $4);
+ $$ = $2 * pow ((double)$4, (double)$6);
+ }
+ ;
+
+DefinedValue: ID {
+ $$ = new_value (YV_IDEFINED);
+ $$ -> yv_identifier = $1;
+ }
+ | NAME { /* XXX */
+ $$ = new_value (YV_IDEFINED);
+ $$ -> yv_identifier = $1;
+ $$ -> yv_flags |= YV_BOUND;
+ }
+ | ID DOT ID {
+ $$ = new_value (YV_IDEFINED);
+ $$ -> yv_identifier = $3;
+ $$ -> yv_module = $1;
+ }
+ ;
+
+IdentifierList: IdentifierList COMMA ID {
+ $$ = new_value (YV_IDEFINED);
+ $$ -> yv_identifier = $3;
+ if ($1)
+ $$ = add_value ($1, $$);
+ }
+ | empty { $$ = NULLYV; }
+ ;
+
+Values: NamedValueList { $$ = $1; }
+ | empty { $$ = NULLYV; }
+ ;
+NamedValueList: NamedValue { $$ = $1; }
+ | NamedValueList COMMA NamedValue {
+ $$ = add_value ($1, $3);
+ }
+ ;
+NamedValue: Value { $$ = $1; }
+ ;
+
+empty: ;
+
+Octetstring: OCTET STRING
+ | OCTETSTRING
+ ;
+
+Bitstring: BITSTRING
+ | BIT STRING
+ ;
+
+SequenceOf: SEQUENCEOF
+ | SEQUENCE OF
+ ;
+SetOf: SETOF
+ | SET OF
+ ;
+Components: COMPONENTSOF
+ | COMPONENTS OF
+ ;
+
+ObjectIdentifierValue: LBRACE ObjIdComponentList RBRACE
+ { $$ = $2; }
+ ;
+
+ObjIdComponentList: ObjIdComponent
+ | ObjIdComponentList ObjIdComponent
+ {
+ $$ = addoid($1, $2);
+ oid_free ($1);
+ oid_free ($2);
+ }
+ ;
+
+ObjIdComponent: NumberForm
+ | NameAndNumberForm
+ ;
+
+NumberForm: LITNUMBER { $$ = int2oid ($1); }
+ | DefinedValue {
+ $$ = oidlookup($1->yv_identifier);
+ free((char *)$1);
+ }
+ ;
+
+NameAndNumberForm: NAME LPAREN NumberForm RPAREN {
+ free ($1);
+ $$ = $3;
+ }
+ ;
+
+SubType: Type SubtypeSpec
+ | SET SizeConstraint OF Sctrl UAction Control Type {
+ $$ = new_type (YP_SETTYPE, $1);
+ $$ -> yp_type = $7;
+ if ($4) {
+ $$ -> yp_structname = $4 -> ys_structname;
+ $$ -> yp_ptrname = $4 -> ys_ptrname;
+ free_ys ($4);
+ }
+ if ($6) {
+ $$ -> yp_control = $6;
+ $$ -> yp_flags |= YP_CONTROLLED;
+ }
+ if ($5)
+ $7->yp_bef_alist=yal_join($5, $7->yp_bef_alist);
+ }
+
+ | SEQUENCE SizeConstraint OF Sctrl UAction Control Type {
+ $$ = new_type (YP_SEQTYPE, $1);
+ $$ -> yp_type = $7;
+ if ($4) {
+ $$ -> yp_structname = $4 -> ys_structname;
+ $$ -> yp_ptrname = $4 -> ys_ptrname;
+ free_ys ($4);
+ }
+ if ($6) {
+ $$ -> yp_control = $6;
+ $$ -> yp_flags |= YP_CONTROLLED;
+ }
+ if ($5)
+ $7->yp_bef_alist=yal_join($5, $7->yp_bef_alist);
+ }
+ ;
+
+SubtypeSpec: LPAREN SubtypeAlternative SubtypeAlternativeList RPAREN
+ ;
+
+SubtypeAlternative: SubtypeValueSet
+ | SubtypeConstraint
+ ;
+
+SubtypeAlternativeList: BAR SubtypeAlternative SubtypeAlternativeList
+ | empty
+ ;
+
+SubtypeValueSet: Value
+ | ContainedSubType
+ | ValueRange
+ | PermittedAlphabet
+ ;
+
+SubtypeConstraint: SizeConstraint
+ | InnerTypeConstraint
+ ;
+
+ContainedSubType: INCLUDES Type ;
+
+ValueRange: LowerEndPoint DOTDOT UpperEndpoint
+ ;
+
+LowerEndPoint: LowerEndValue
+ | LowerEndValue LANGLE
+ ;
+
+UpperEndpoint: UpperEndValue
+ | LANGLE UpperEndValue
+ ;
+
+LowerEndValue: Value
+ | MIN
+ ;
+
+UpperEndValue: Value
+ | MAX
+ ;
+
+SizeConstraint: SIZE SubtypeSpec
+ ;
+
+PermittedAlphabet: FROM SubtypeSpec
+ ;
+
+InnerTypeConstraint: WITH COMPONENT SingleTypeConstraint
+ | WITH COMPONENTS MultipleTypeConstraints
+ ;
+
+SingleTypeConstraint: SubtypeSpec
+ ;
+
+MultipleTypeConstraints:FullSpecification
+ | PartialSpecification
+ ;
+
+FullSpecification: LBRACE TypeConstraints RBRACE
+ ;
+
+PartialSpecification: LBRACE DOTDOTDOT COMMA TypeConstraints RBRACE
+ ;
+
+TypeConstraints: NamedConstraint
+ | NamedConstraint COMMA TypeConstraints
+ ;
+
+NamedConstraint: NAME Constraint
+ | Constraint
+ ;
+
+Constraint: ValueConstraint
+ | PresenceConstraint
+ | empty
+ ;
+
+ValueConstraint: SubtypeSpec
+ ;
+
+PresenceConstraint: PRESENT
+ | ABSENT
+ ;
+
+Sctrl: SCTRL { $$ = new_ys ($1); }
+ | empty { $$ = NULLYS; }
+ ;
+%%
+
+#ifdef HPUX
+#define uchar Uchar
+#endif
+#include "lex.c"