├── stamp-h.in ├── c-lib ├── tbl │ └── Makefile.am ├── Cebuf │ └── Makefile.am ├── ebuf │ └── Makefile.am ├── mbuf │ └── Makefile.am ├── sbuf │ └── Makefile.am ├── inc │ ├── asn-config.h │ ├── tbl-dbg.h │ ├── Makefile.am │ ├── tbl-gen.h │ ├── tbl-gen-c-hdr.h │ ├── tbl-free.h │ ├── tbl-print.h │ ├── tbl-enc.h │ ├── tbl-dec.h │ ├── print.h │ ├── asn-incl.h │ ├── asn-bool.h │ ├── asn-enum.h │ ├── asn-null.h │ ├── tbl-incl.h │ ├── asn-real.h │ ├── nibble-alloc.h │ ├── tbl-util.h │ ├── hash.h │ ├── asn-octs.h │ ├── asn-bits.h │ ├── asn-oid.h │ ├── min-buf.h │ └── asn-int.h ├── Makefile.am ├── tbl.h.patch ├── README └── src │ ├── str-stk.c │ ├── Makefile.am │ ├── print.c │ └── asn-enum.c ├── c++-lib ├── c++ │ └── Makefile.am ├── tcl │ └── Makefile.am ├── src │ ├── asn-real.C │ ├── Makefile.am │ ├── print.C │ └── str-stk.C ├── Makefile.am ├── inc │ ├── Makefile.am │ ├── init.h │ ├── print.h │ ├── asn-incl.h │ ├── tcl-if.h │ ├── str-stk.h │ ├── hash.h │ ├── asn-null.h │ ├── asn-enum.h │ ├── asn-real.h │ └── asn-int.h └── README ├── doc ├── version.tex ├── ttab.tex ├── tumble.sed ├── misc-hyph.tex ├── idl-gen.tex ├── tcl.bib ├── corba.bib ├── modifying.tex ├── ptbl.1 ├── pval.1 └── mkchdr.1 ├── ChangeLog ├── compiler ├── core │ ├── meta.c │ ├── meta.h │ ├── dependency.h │ ├── mem.h │ ├── recursive.h │ ├── normalize.h │ ├── do-macros.h │ ├── link-types.h │ ├── link-values.h │ ├── err-chk.h │ ├── oid.h │ ├── val-parser.h │ ├── parser.h │ ├── gen-tbls.h │ ├── lib-types.h │ ├── exports.h │ ├── lex-stuff.h │ ├── define.h │ ├── Makefile.am │ ├── mem.c │ └── lib-types.c ├── back-ends │ ├── idl-gen │ │ ├── gen-code.c │ │ ├── types.h │ │ ├── gen-any.h │ │ ├── gen-code.h │ │ ├── Makefile.am │ │ ├── gen-vals.h │ │ └── rules.h │ ├── c++-gen │ │ ├── Makefile.am │ │ ├── gen-any.h │ │ ├── types.h │ │ ├── kwd.h │ │ ├── gen-vals.h │ │ ├── rules.h │ │ ├── gen-code.h │ │ └── kwd.c │ ├── c-gen │ │ ├── Makefile.am │ │ ├── kwd.h │ │ ├── gen-print.h │ │ ├── gen-any.h │ │ ├── gen-free.h │ │ ├── gen-type.h │ │ ├── gen-vals.h │ │ ├── gen-enc.h │ │ ├── gen-dec.h │ │ ├── gen-code.h │ │ ├── rules.h │ │ ├── util.h │ │ ├── type-info.h │ │ └── kwd.c │ ├── cond.h │ ├── Makefile.am │ ├── tag-util.h │ ├── cond.c │ └── str-util.h └── Makefile.am ├── version.h ├── tbl-tools ├── Makefile.am ├── berdecode │ ├── Makefile.am │ └── README ├── pval │ ├── Makefile.am │ └── README ├── ptbl │ ├── Makefile.am │ ├── pasn1.h │ ├── README │ └── ptbl.c └── mkchdr │ ├── Makefile.am │ ├── README │ └── mkchdr.c ├── tbl-example ├── p-rec.ber.uu ├── makefile └── README ├── c-examples ├── simple │ └── good-pr.ber.uu ├── makefile ├── test-lib │ ├── README │ └── makefile └── snmp │ └── makefile ├── c++-examples ├── simple │ └── good-pr.ber.uu ├── makefile └── test-lib │ ├── README │ └── makefile ├── snacc-c-ebuf.pc.in ├── snacc-c-ebuf-uninstalled.pc.in ├── asn1specs ├── Makefile.am ├── ex1.asn1 ├── p-rec.asn1 ├── any.asn1 └── asn-useful.asn1 ├── policy.h ├── Makefile.am ├── .gitignore └── acconfig.h /stamp-h.in: -------------------------------------------------------------------------------- 1 | timestamp 2 | -------------------------------------------------------------------------------- /c-lib/tbl/Makefile.am: -------------------------------------------------------------------------------- 1 | # empty 2 | -------------------------------------------------------------------------------- /c++-lib/c++/Makefile.am: -------------------------------------------------------------------------------- 1 | # empty 2 | -------------------------------------------------------------------------------- /c++-lib/tcl/Makefile.am: -------------------------------------------------------------------------------- 1 | # empty 2 | -------------------------------------------------------------------------------- /c-lib/Cebuf/Makefile.am: -------------------------------------------------------------------------------- 1 | # empty 2 | -------------------------------------------------------------------------------- /c-lib/ebuf/Makefile.am: -------------------------------------------------------------------------------- 1 | # empty 2 | -------------------------------------------------------------------------------- /c-lib/mbuf/Makefile.am: -------------------------------------------------------------------------------- 1 | # empty 2 | -------------------------------------------------------------------------------- /c-lib/sbuf/Makefile.am: -------------------------------------------------------------------------------- 1 | # empty 2 | -------------------------------------------------------------------------------- /doc/version.tex: -------------------------------------------------------------------------------- 1 | \def\snaccversion{1.3b3} 2 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nevali/snacc/HEAD/ChangeLog -------------------------------------------------------------------------------- /doc/ttab.tex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nevali/snacc/HEAD/doc/ttab.tex -------------------------------------------------------------------------------- /compiler/core/meta.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nevali/snacc/HEAD/compiler/core/meta.c -------------------------------------------------------------------------------- /compiler/core/meta.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nevali/snacc/HEAD/compiler/core/meta.h -------------------------------------------------------------------------------- /doc/tumble.sed: -------------------------------------------------------------------------------- 1 | /^%%EndSetup$/i\ 2 | statusdict begin\ 3 | \ true settumble\ 4 | end 5 | -------------------------------------------------------------------------------- /c++-lib/src/asn-real.C: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nevali/snacc/HEAD/c++-lib/src/asn-real.C -------------------------------------------------------------------------------- /c-lib/inc/asn-config.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nevali/snacc/HEAD/c-lib/inc/asn-config.h -------------------------------------------------------------------------------- /version.h: -------------------------------------------------------------------------------- 1 | #define VERSION "1.3.1" 2 | #define RELDATE "2012-03-10" 3 | #define BUGREPADDR "mo@nevali.net" 4 | -------------------------------------------------------------------------------- /compiler/back-ends/idl-gen/gen-code.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nevali/snacc/HEAD/compiler/back-ends/idl-gen/gen-code.c -------------------------------------------------------------------------------- /tbl-tools/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | AUTOMAKE_OPTIONS = 1.3 foreign 4 | 5 | SUBDIRS = mkchdr pval ptbl berdecode 6 | -------------------------------------------------------------------------------- /compiler/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | AUTOMAKE_OPTIONS = 1.3 foreign 4 | 5 | SUBDIRS = core back-ends 6 | EXTRA_DIST = README -------------------------------------------------------------------------------- /tbl-example/p-rec.ber.uu: -------------------------------------------------------------------------------- 1 | begin 644 p-rec.ber 2 | M8(&.81`6!$IO:&X6`446!5-M:71HH!`6#E1H92!":6<@0VAE97-E7X$``P&& 3 | MGZ$*0P@Q.3@R,#$P-*(281`6!$UA] [-d|-debug] 2 | [-T|-table |-} 3 | 4 | This is berdecode, revision 1.10 as of 1997/06/24. 5 | This program reads a binary ASN.1 grammar file generated by snacc -T 6 | and uses it to decode ASN.1 BER encoded data from files or stdin. 7 | 8 | From every message the first bytes (default 2) 9 | are skipped. 10 | 11 | Flag -d gives additional information during decoding. 12 | -------------------------------------------------------------------------------- /tbl-tools/ptbl/pasn1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * file: .../tbl-tools/ptbl/pasn1.h 3 | * 4 | * $Header: /usr/app/odstb/CVS/snacc/tbl-tools/ptbl/pasn1.h,v 1.1 1997/02/15 19:26:22 rj Exp $ 5 | * $Log: pasn1.h,v $ 6 | * Revision 1.1 1997/02/15 19:26:22 rj 7 | * first check-in 8 | * 9 | */ 10 | 11 | 12 | void PrintTblTypeDefInAsn1 PROTO ((FILE *f, TBL *tbl, TBLTypeDef *td)); 13 | 14 | void PrintTblTypeInAsn1 PROTO ((FILE *f, TBL *tbl, TBLTypeDef *td, TBLType *t)); 15 | 16 | void PrintTblInAsn1 PROTO ((FILE *f, TBL *tbl)); 17 | -------------------------------------------------------------------------------- /c-lib/inc/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | AUTOMAKE_OPTIONS = 1.3 foreign 4 | 5 | cpkgincludedir = $(pkgincludedir)/c 6 | cpkginclude_HEADERS = asn-any.h asn-bits.h asn-bool.h asn-config.h asn-enum.h \ 7 | asn-incl.h asn-int.h asn-len.h asn-list.h asn-null.h asn-octs.h asn-oid.h \ 8 | asn-real.h asn-tag.h exp-buf.h gen-buf.h hash.h min-buf.h nibble-alloc.h \ 9 | print.h sbuf.h str-stk.h tbl-dbg.h tbl-dec.h tbl-enc.h tbl-free.h \ 10 | tbl-gen-c-hdr.h tbl-gen.h tbl-incl.h tbl-print.h tbl-util.h 11 | 12 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | AUTOMAKE_OPTIONS = 1.3 foreign 4 | 5 | SUBDIRS = compiler c-lib c++-lib tbl-tools asn1specs @TCLDIRS@ doc 6 | EXTRA_DIST = version.h policy.h snacc.h snacc.m4 7 | bin_SCRIPTS = snacc-config 8 | cpkgincludedir = $(pkgincludedir)/c 9 | cpkginclude_HEADERS = policy.h snacc.h snaccconfig.h 10 | cxxpkgincludedir = $(pkgincludedir)/c++ 11 | cxxpkginclude_HEADERS = $(cpkginclude_HEADERS) 12 | m4datadir = $(datadir)/aclocal 13 | m4data_DATA = snacc.m4 14 | 15 | pkgconfigdir = $(libdir)/pkgconfig 16 | 17 | pkgconfig_DATA = snacc-c-ebuf.pc 18 | 19 | noinst_DATA = snacc-c-ebuf-uninstalled.pc 20 | -------------------------------------------------------------------------------- /compiler/back-ends/idl-gen/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/back_ends/idl_gen/types.h - fills in c++ type information 3 | * 4 | * Copyright (C) 1991, 1992 Michael Sample 5 | * and the University of British Columbia 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * $Header: /usr/app/odstb/CVS/snacc/compiler/back-ends/idl-gen/types.h,v 1.1 1997/01/01 20:25:42 rj Exp $ 13 | * $Log: types.h,v $ 14 | * Revision 1.1 1997/01/01 20:25:42 rj 15 | * first draft 16 | * 17 | */ 18 | 19 | 20 | void FillIDLTypeInfo PROTO ((IDLRules *r, ModuleList *m)); 21 | -------------------------------------------------------------------------------- /compiler/back-ends/idl-gen/gen-any.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/back_ends/idl_gen/gen_any.h 3 | * 4 | * MS 92 5 | * Copyright (C) 1991, 1992 Michael Sample 6 | * and the University of British Columbia 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * $Header: /usr/app/odstb/CVS/snacc/compiler/back-ends/idl-gen/gen-any.h,v 1.1 1997/01/01 20:25:33 rj Exp $ 14 | * $Log: gen-any.h,v $ 15 | * Revision 1.1 1997/01/01 20:25:33 rj 16 | * first draft 17 | * 18 | */ 19 | 20 | void PrintIDLAnyCode PROTO ((FILE *src, IDLRules *r, ModuleList *mods, Module *m)); 21 | -------------------------------------------------------------------------------- /doc/corba.bib: -------------------------------------------------------------------------------- 1 | % file: .../doc/corba.bib 2 | 3 | % $Header: /usr/app/odstb/CVS/snacc/doc/corba.bib,v 1.1 1997/01/01 22:47:51 rj Exp $ 4 | % $Log: corba.bib,v $ 5 | % Revision 1.1 1997/01/01 22:47:51 rj 6 | % first check-in 7 | % 8 | 9 | @techreport{corba, 10 | institution = "OMG", 11 | author = "OMG", 12 | title = "The Common Object Request Broker: Architecture and Specification", 13 | year = "1993", 14 | version = "1.2", 15 | } 16 | 17 | @techreport{idl-c++, 18 | institution = "OMG", 19 | author = "OMG", 20 | title = "OMG RFP Submission--IDL C++ Language Mapping Specification", 21 | year = "1994", 22 | } 23 | 24 | @techreport{gdmo-idl, 25 | institution = "X/Open", 26 | author = "X/Open", 27 | title = "GDMO to OMG IDL Specification Translation Algorithm", 28 | year = "1994", 29 | } 30 | -------------------------------------------------------------------------------- /c-lib/tbl.h.patch: -------------------------------------------------------------------------------- 1 | *** tbl.h Wed Feb 5 17:37:16 1997 2 | --- boot/tbl.h Wed Jul 19 16:58:58 1995 3 | *************** 4 | *** 82,87 **** 5 | --- 82,88 ---- 6 | { 7 | TBLTypeDefId typeDef; /* TBLTypeDefId */ 8 | AsnBool implicit; /* BOOLEAN */ 9 | + struct TBLTypeDef *typeDefPtr; /* Added by MS to hold resolved index */ 10 | } TBLTypeRef; 11 | 12 | AsnLen BEncTBLTypeRefContent PROTO ((BUF_TYPE b, TBLTypeRef *v)); 13 | *************** 14 | *** 100,105 **** 15 | --- 101,108 ---- 16 | { 17 | TBLTagClass tclass; /* TBLTagClass */ 18 | AsnInt code; /* INTEGER (0..MAX) */ 19 | + BER_FORM form; /* added by MS to simplify enc/dec */ 20 | + AsnTag encTag; /* added by MS to simplify enc/dec */ 21 | } TBLTag; 22 | 23 | AsnLen BEncTBLTagContent PROTO ((BUF_TYPE b, TBLTag *v)); 24 | -------------------------------------------------------------------------------- /compiler/back-ends/idl-gen/gen-code.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/back_ends/idl_gen/gen_code.h 3 | * 4 | * Copyright (C) 1991, 1992 Michael Sample 5 | * and the University of British Columbia 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * $Header: /usr/app/odstb/CVS/snacc/compiler/back-ends/idl-gen/gen-code.h,v 1.1 1997/01/01 20:25:35 rj Exp $ 13 | * $Log: gen-code.h,v $ 14 | * Revision 1.1 1997/01/01 20:25:35 rj 15 | * first draft 16 | * 17 | */ 18 | 19 | void PrintIDLCode PROTO ((FILE *idl, ModuleList *mods, Module *m, IDLRules *r, long int longJmpVal, int printValues)); 20 | -------------------------------------------------------------------------------- /compiler/back-ends/idl-gen/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | AUTOMAKE_OPTIONS = 1.4 foreign 4 | 5 | noinst_LIBRARIES = libjunk.a 6 | libjunk_a_SOURCES = rules.h types.h gen-any.h gen-code.h gen-vals.h \ 7 | rules.c types.c gen-any.c gen-code.c gen-vals.c 8 | CORE_DIR = $(top_srcdir)/compiler/core 9 | BACKEND_DIR = $(top_srcdir)/compiler/back-ends 10 | ASN1_LIB_DIR = $(top_srcdir)/c-lib 11 | ASN1_INC_DIR = $(ASN1_LIB_DIR)/inc 12 | ASN1_BOOT_DIR = $(ASN1_LIB_DIR)/boot 13 | AM_CPPFLAGS = -DCOMPILER -DUSE_NIBBLE_MEMORY=0 -DUSE_EXP_BUF \ 14 | -I$(ASN1_INC_DIR) -I$(ASN1_BOOT_DIR) -I$(BACKEND_DIR) -I$(CORE_DIR) 15 | CLEANFILES = LIBOBJ 16 | 17 | # target to make LIBOBJ: 18 | LIBOBJ: $(libjunk_a_OBJECTS) 19 | rm -f $@ && d=`pwd` && for obj in $(libjunk_a_OBJECTS); do echo "$$d/$$obj" >> $@; done 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Makefile.in 2 | Makefile 3 | .deps 4 | .libs 5 | *.o 6 | *.lo 7 | *.la 8 | *.a 9 | *.pc 10 | *~ 11 | LIBOBJ 12 | /compiler/core/snacc 13 | /compiler/core/snaccC 14 | /compiler/core/tbl.c 15 | /compiler/core/tbl.h 16 | /compiler/core/lex-asn1.c 17 | /compiler/core/parse-asn1.c 18 | /compiler/core/parse-asn1.h 19 | /tbl-tools/berdecode/berdecode 20 | /tbl-tools/mkchdr/mkchdr 21 | /tbl-tools/ptbl/ptbl 22 | /tbl-tools/pval/pval 23 | /autom4te.cache 24 | /aclocal.m4 25 | /config.log 26 | /config.status 27 | /config.sub 28 | /config.guess 29 | /configure 30 | /config.h.in 31 | /config.h 32 | /install-sh 33 | /missing 34 | /snaccconfig.h 35 | /ltmain.sh 36 | /libtool 37 | /depcomp 38 | /stamp-h* 39 | /snacc-config 40 | /ylwrap 41 | /c++-lib/c++ 42 | /c++-lib/tcl 43 | /c-lib/Cebuf 44 | /c-lib/ebuf 45 | /c-lib/mbuf 46 | /c-lib/sbuf 47 | /c-lib/tbl 48 | -------------------------------------------------------------------------------- /compiler/back-ends/c++-gen/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | AUTOMAKE_OPTIONS = 1.4 foreign 4 | 5 | noinst_LIBRARIES = libjunk.a 6 | libjunk_a_SOURCES = kwd.h rules.h types.h gen-any.h gen-code.h gen-vals.h \ 7 | kwd.c types.c rules.c gen-code.c gen-vals.c gen-any.c 8 | CORE_DIR = $(top_srcdir)/compiler/core 9 | BACKEND_DIR = $(top_srcdir)/compiler/back-ends 10 | ASN1_LIB_DIR = $(top_srcdir)/c-lib 11 | ASN1_INC_DIR = $(ASN1_LIB_DIR)/inc 12 | ASN1_BOOT_DIR = $(ASN1_LIB_DIR)/boot 13 | AM_CPPFLAGS = -DCOMPILER -DUSE_NIBBLE_MEMORY=0 -DUSE_EXP_BUF \ 14 | -I$(ASN1_INC_DIR) -I$(ASN1_BOOT_DIR) -I$(BACKEND_DIR) -I$(CORE_DIR) 15 | CLEANFILES = LIBOBJ 16 | 17 | # target to make LIBOBJ: 18 | LIBOBJ: $(libjunk_a_OBJECTS) 19 | rm -f $@ && d=`pwd` && for obj in $(libjunk_a_OBJECTS); do echo "$$d/$$obj" >> $@; done 20 | -------------------------------------------------------------------------------- /c++-examples/makefile: -------------------------------------------------------------------------------- 1 | # file: .../c++-examples/makefile 2 | 3 | SUBDIRS = test-lib simple any snmp 4 | 5 | #------------------------------------------------------------------------------- 6 | 7 | .PHONY: implicit_default 8 | implicit_default:: 9 | $(MAKE) subdirs 10 | 11 | subdirs:: $(SUBDIRS) 12 | $(SUBDIRS):: 13 | ifeq ($(subtarget)",check) 14 | echo "Doing "$@" :"; 15 | endif 16 | cd $@ && $(MAKE) $(subtarget) 17 | 18 | # the following hack is needed for older make versions (gmake doesn't need it): 19 | init-depend:: 20 | @for dir in $(SUBDIRS); do\ 21 | test -f $$dir/dependencies || touch $$dir/dependencies;\ 22 | done 23 | 24 | .DEFAULT:: 25 | $(MAKE) subdirs subtarget=$@ 26 | 27 | distfiles:: 28 | echo makefile 29 | for dir in $(SUBDIRS); do\ 30 | subfiles=`cd $$dir && $(MAKE) -s $@`;\ 31 | for file in $$subfiles; do\ 32 | echo "$$dir/$$file";\ 33 | done;\ 34 | done 35 | 36 | # dummy: 37 | install:: 38 | -------------------------------------------------------------------------------- /c-lib/inc/tbl-gen.h: -------------------------------------------------------------------------------- 1 | #ifndef TBL_GEN_H 2 | #define TBL_GEN_H 3 | 4 | #define USE_GEN_BUF 1 5 | #include "tbl-incl.h" 6 | 7 | typedef enum {TDEINFO, TDEEOC=TDEINFO, TDEPEEKTAG, TDEPUSHTAG, 8 | TDEWARNING, TDEUNEXPECTED=TDEWARNING, TDENONOPTIONAL, TDEMANDATORY, 9 | TDECONSTRAINT, TDENOMATCH, 10 | TDEERROR} TdeExceptionCode; 11 | 12 | typedef int (*TdeTypeProc) PROTO ((TBLType* type, AVal* val, int begin)); 13 | typedef int (*TdeSimpleProc) PROTO ((AsnTag tag, AsnOcts* val, int begin)); 14 | typedef int (*TdeExcProc) PROTO ((TdeExceptionCode code, void* p1, void* p2, void* p3)); 15 | 16 | int 17 | TdeDecode PROTO ((TBL* tbl, BUF_TYPE b, unsigned long int* bytesDecoded, 18 | TdeTypeProc typeproc, TdeSimpleProc simpleproc, TdeExcProc excproc)); 19 | 20 | int 21 | TdeDecodeSpecific PROTO ((TBL* tbl, BUF_TYPE b, TBLType* type, 22 | unsigned long int* bytesDecoded, 23 | TdeTypeProc typeproc, TdeSimpleProc simpleproc, TdeExcProc excproc)); 24 | #endif 25 | -------------------------------------------------------------------------------- /asn1specs/ex1.asn1: -------------------------------------------------------------------------------- 1 | -- file: .../asn1specs/ex1.asn1 2 | -- 3 | -- This is an example ASN.1 module used in the documentation 4 | -- 5 | -- MS 92 6 | -- 7 | -- $Header: /usr/app/odstb/CVS/snacc/asn1specs/ex1.asn1,v 1.2 1997/02/16 20:25:22 rj Exp $ 8 | -- $Log: ex1.asn1,v $ 9 | -- Revision 1.2 1997/02/16 20:25:22 rj 10 | -- check-in of a few cosmetic changes 11 | -- 12 | -- Revision 1.1 1994/10/08 05:41:32 rj 13 | -- initial check-in. 14 | -- 15 | 16 | EX1 DEFINITIONS ::= 17 | BEGIN 18 | 19 | anOidVal OBJECT IDENTIFIER ::= { joint-iso-ccitt 40 foobar(29) } 20 | theSameOidVal OBJECT IDENTIFIER ::= { 2 40 29 } 21 | anIntVal INTEGER ::= 1 22 | aBoolVal BOOLEAN ::= TRUE 23 | 24 | T1 ::= SEQUENCE 25 | { 26 | INTEGER OPTIONAL, 27 | OCTET STRING OPTIONAL, 28 | ENUMERATED { a(0), b(1), c(2) }, 29 | SEQUENCE OF INTEGER, 30 | SEQUENCE { id OBJECT IDENTIFIER, value OCTET STRING }, 31 | CHOICE { INTEGER, OBJECT IDENTIFIER } 32 | } 33 | 34 | END 35 | -------------------------------------------------------------------------------- /compiler/back-ends/c-gen/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | AUTOMAKE_OPTIONS = 1.4 foreign 4 | 5 | noinst_LIBRARIES = libjunk.a 6 | libjunk_a_SOURCES = kwd.h gen-any.h gen-code.h gen-dec.h gen-enc.h \ 7 | gen-free.h gen-print.h gen-type.h gen-vals.h rules.h type-info.h \ 8 | util.h type-info.c util.c rules.c gen-code.c gen-type.c gen-enc.c \ 9 | gen-dec.c gen-vals.c gen-free.c gen-print.c gen-any.c kwd.c 10 | CORE_DIR = $(top_srcdir)/compiler/core 11 | BACKEND_DIR = $(top_srcdir)/compiler/back-ends 12 | ASN1_LIB_DIR = $(top_srcdir)/c-lib 13 | ASN1_INC_DIR = $(ASN1_LIB_DIR)/inc 14 | ASN1_BOOT_DIR = $(ASN1_LIB_DIR)/boot 15 | AM_CPPFLAGS = -DCOMPILER -DUSE_NIBBLE_MEMORY=0 -DUSE_EXP_BUF \ 16 | -I$(ASN1_INC_DIR) -I$(ASN1_BOOT_DIR) -I$(BACKEND_DIR) -I$(CORE_DIR) 17 | CLEANFILES = LIBOBJ 18 | 19 | # target to make LIBOBJ: 20 | LIBOBJ: $(libjunk_a_OBJECTS) 21 | rm -f $@ && d=`pwd` && for obj in $(libjunk_a_OBJECTS); do echo "$$d/$$obj" >> $@; done 22 | -------------------------------------------------------------------------------- /compiler/back-ends/cond.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/back_ends/cond.h - generate conditional include for C(++) hdr files 3 | * 4 | * Copyright (C) 1991, 1992 Michael Sample 5 | * and the University of British Columbia 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * $Header: /usr/app/odstb/CVS/snacc/compiler/back-ends/cond.h,v 1.1 1995/07/25 19:13:50 rj Exp $ 13 | * $Log: cond.h,v $ 14 | * Revision 1.1 1995/07/25 19:13:50 rj 15 | * PrintConditionalIncludeOpen() and PrintConditionalIncludeClose() moved from back-ends/c-gen/gen-code.[ch]. 16 | * 17 | * Revision 1.2 1994/10/08 03:48:09 rj 18 | */ 19 | 20 | 21 | void PrintConditionalIncludeOpen PROTO ((FILE *f, char *fileName)); 22 | void PrintConditionalIncludeClose PROTO ((FILE *f, char *fileName)); 23 | -------------------------------------------------------------------------------- /tbl-tools/pval/README: -------------------------------------------------------------------------------- 1 | (RCS control information is at the end of this file.) 2 | 3 | 4 | Value printing README - MS 93 5 | ----------------------------- 6 | 7 | pval is a program that prints BER values in their value notation. Its 8 | arguments are a type table file, a module and type name and a list of 9 | BER files of that type. 10 | 11 | Look at the code in pval.c - quite simple & very generic. This is the 12 | advantage of type tables. 13 | 14 | Type "make" to build pval. 15 | Type ./pval to see the arguments it expects. 16 | 17 | try: 18 | 19 | ./pval -T ../demo-tbls/p-rec.tt -n PersonnelRecord ../demo-tbls/p-rec.ber 20 | 21 | cool, eh? 22 | 23 | #------------------------------------------------------------------------------- 24 | # $Header: /usr/app/odstb/CVS/snacc/tbl-tools/pval/README,v 1.2 1997/02/15 19:21:15 rj Exp $ 25 | # $Log: README,v $ 26 | # Revision 1.2 1997/02/15 19:21:15 rj 27 | # make without args just builds, doesn't install 28 | # 29 | # Revision 1.1 1997/02/15 19:15:07 rj 30 | # first check-in 31 | # 32 | -------------------------------------------------------------------------------- /tbl-tools/mkchdr/README: -------------------------------------------------------------------------------- 1 | (RCS control information is at the end of this file.) 2 | 3 | 4 | mkchdr - Making C header files from a Type Table 5 | ------------------------------------------------ 6 | 7 | synopsis: 8 | mkchdr [output-file] 9 | 10 | mkchdr reads the type table from tbl-file and writes the equivalent C 11 | typedefs to output-file. If no output-file is given, stdout is used. 12 | 13 | The table files are generated with the snacc -T option. 14 | 15 | Look in .../tbl-example/ to see how these header files are used. 16 | The table decoder/encoder does not use them---they are simply a 17 | mechanism to allow your program to deal with the values returned from 18 | the table driven decoder (or given to the encoder) in a nice fashion. 19 | 20 | #------------------------------------------------------------------------------- 21 | # $Header: /usr/app/odstb/CVS/snacc/tbl-tools/mkchdr/README,v 1.1 1997/02/15 19:08:49 rj Exp $ 22 | # $Log: README,v $ 23 | # Revision 1.1 1997/02/15 19:08:49 rj 24 | # first check-in 25 | # 26 | -------------------------------------------------------------------------------- /c-lib/inc/tbl-gen-c-hdr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * tbl-gen-c-hdr.h - prints C type defs for vals 3 | * tbl decoder will return for the given type table. 4 | * 5 | * 6 | * Mike Sample 7 | * 8 | * Copyright (C) 1993 Michael Sample 9 | * and the University of British Columbia 10 | * 11 | * This library is free software; you can redistribute it and/or 12 | * modify it provided that this copyright/license information is retained 13 | * in original form. 14 | * 15 | * If you modify this file, you must clearly indicate your changes. 16 | * 17 | * This source code is distributed in the hope that it will be 18 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 19 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 | * 21 | * $Header: /usr/app/odstb/CVS/snacc/c-lib/inc/tbl-gen-c-hdr.h,v 1.1 1995/07/27 08:55:56 rj Exp $ 22 | * $Log: tbl-gen-c-hdr.h,v $ 23 | * Revision 1.1 1995/07/27 08:55:56 rj 24 | * first check-in after being merged into .../c-lib/. 25 | * 26 | */ 27 | 28 | void TblPrintCHdr PROTO ((TBL *tbl, FILE *f)); 29 | -------------------------------------------------------------------------------- /compiler/back-ends/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | AUTOMAKE_OPTIONS = 1.4 foreign 4 | SUBDIRS = c-gen c++-gen idl-gen 5 | 6 | noinst_LIBRARIES = libjunk.a 7 | libjunk_a_SOURCES = cond.c cond.h str-util.c str-util.h tag-util.c tag-util.h 8 | CORE_DIR = $(top_srcdir)/compiler/core 9 | BACKEND_DIR = $(top_srcdir)/compiler/back-ends 10 | ASN1_LIB_DIR = $(top_srcdir)/c-lib 11 | ASN1_INC_DIR = $(ASN1_LIB_DIR)/inc 12 | ASN1_BOOT_DIR = $(ASN1_LIB_DIR)/boot 13 | AM_CPPFLAGS = -DCOMPILER -DUSE_NIBBLE_MEMORY=0 -DUSE_EXP_BUF \ 14 | -I$(ASN1_INC_DIR) -I$(ASN1_BOOT_DIR) -I$(BACKEND_DIR) -I$(CORE_DIR) 15 | CLEANFILES = LIBOBJ 16 | 17 | # target to make LIBOBJ: 18 | GEN_LIBOBJ = c-gen/LIBOBJ c++-gen/LIBOBJ idl-gen/LIBOBJ 19 | LIBOBJ: $(libjunk_a_OBJECTS) $(GEN_LIBOBJ) 20 | rm -f $@ && d=`pwd` && for obj in $(libjunk_a_OBJECTS); do echo "$$d/$$obj" >> $@; done 21 | for obj in $(GEN_LIBOBJ); do cat $$obj >> $@; done 22 | 23 | # target to make remote things: 24 | $(GEN_LIBOBJ): force 25 | cd `dirname $@` && $(MAKE) `basename $@` 26 | force: ; 27 | 28 | -------------------------------------------------------------------------------- /c++-lib/README: -------------------------------------------------------------------------------- 1 | (RCS control information is at the end of this file.) 2 | 3 | 4 | C++ ASN.1 library README 5 | ------------------------ 6 | 7 | This directory contains the class definitions and the encode, decode, 8 | free and print methods for all of the built-in ASN.1 types. It also 9 | contains buffer routines. 10 | 11 | The makefile will produce one or two libraries, libasn1c++.a and 12 | libasn1tcl.a. 13 | Whether the tcl library is to be generated or not is determined at 14 | configuration time. 15 | 16 | In addition to the normal C++ libraries contents, the Tcl library 17 | contains the meta code and the Tcl interface described in the 18 | documentation. 19 | 20 | #------------------------------------------------------------------------------- 21 | # $Header: /usr/app/odstb/CVS/snacc/c++-lib/README,v 1.3 1995/07/24 15:45:53 rj Exp $ 22 | # $Log: README,v $ 23 | # Revision 1.3 1995/07/24 15:45:53 rj 24 | # mention meta code and tcl interface and their additional libary. 25 | # 26 | # Revision 1.2 1994/09/01 00:55:55 rj 27 | # textual change to adapt to change of directory tree. 28 | # 29 | -------------------------------------------------------------------------------- /c-lib/inc/tbl-free.h: -------------------------------------------------------------------------------- 1 | /* 2 | * tbl-free.h - frees data structs returned by type table driven decoder. 3 | * 4 | * 5 | * Mike Sample 6 | * 7 | * Copyright (C) 1993 Michael Sample 8 | * and the University of British Columbia 9 | * 10 | * This library is free software; you can redistribute it and/or 11 | * modify it provided that this copyright/license information is retained 12 | * in original form. 13 | * 14 | * If you modify this file, you must clearly indicate your changes. 15 | * 16 | * This source code is distributed in the hope that it will be 17 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 18 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 19 | * 20 | * $Header: /usr/app/odstb/CVS/snacc/c-lib/inc/tbl-free.h,v 1.1 1995/07/27 08:55:55 rj Exp $ 21 | * $Log: tbl-free.h,v $ 22 | * Revision 1.1 1995/07/27 08:55:55 rj 23 | * first check-in after being merged into .../c-lib/. 24 | * 25 | */ 26 | 27 | 28 | void TblFree PROTO ((TBL *tbl, char *modName, char *typeName, AVal *v)); 29 | 30 | void TblFreeType PROTO ((TBLType *tblT, AVal *v)); 31 | -------------------------------------------------------------------------------- /c-lib/inc/tbl-print.h: -------------------------------------------------------------------------------- 1 | /* 2 | * tbl-print.h - type table value printer 3 | * 4 | * 5 | * Mike Sample 6 | * 7 | * Copyright (C) 1993 Michael Sample 8 | * and the University of British Columbia 9 | * 10 | * This library is free software; you can redistribute it and/or 11 | * modify it provided that this copyright/license information is retained 12 | * in original form. 13 | * 14 | * If you modify this file, you must clearly indicate your changes. 15 | * 16 | * This source code is distributed in the hope that it will be 17 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 18 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 19 | * 20 | * $Header: /usr/app/odstb/CVS/snacc/c-lib/inc/tbl-print.h,v 1.1 1995/07/27 08:55:58 rj Exp $ 21 | * $Log: tbl-print.h,v $ 22 | * Revision 1.1 1995/07/27 08:55:58 rj 23 | * first check-in after being merged into .../c-lib/. 24 | * 25 | */ 26 | 27 | 28 | void TblPrintValue PROTO ((TBL *tbl, char *modName, char *typeName, FILE *f, AVal *v)); 29 | 30 | void TblPrintTypeValue PROTO ((TBLType *tblT, FILE *f, AVal *v, unsigned short int indent)); 31 | -------------------------------------------------------------------------------- /compiler/core/dependency.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/core/depedency.h 3 | * 4 | * Copyright (C) 1991, 1992 Michael Sample 5 | * and the University of British Columbia 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * $Header: /usr/app/odstb/CVS/snacc/compiler/core/dependency.h,v 1.2 1994/10/08 03:48:38 rj Exp $ 13 | * $Log: dependency.h,v $ 14 | * Revision 1.2 1994/10/08 03:48:38 rj 15 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 16 | * 17 | * Revision 1.1 1994/08/28 09:49:01 rj 18 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 19 | * 20 | */ 21 | 22 | 23 | void SortAllDependencies PROTO ((ModuleList *m)); 24 | -------------------------------------------------------------------------------- /compiler/core/mem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/core/mem.h 3 | * 4 | * MS 91/08/03 5 | * 6 | * Copyright (C) 1991, 1992 Michael Sample 7 | * and the University of British Columbia 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * $Header: /usr/app/odstb/CVS/snacc/compiler/core/mem.h,v 1.2 1994/09/01 00:40:32 rj Exp $ 15 | * $Log: mem.h,v $ 16 | * Revision 1.2 1994/09/01 00:40:32 rj 17 | * snacc_config.h's last macro, MT ( ) got here. 18 | * 19 | * Revision 1.1 1994/08/28 09:49:22 rj 20 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 21 | * 22 | */ 23 | 24 | #ifndef _snacc_mem_h_ 25 | #define _snacc_mem_h_ 26 | 27 | void *Malloc PROTO ((int size)); 28 | void *Realloc PROTO ((void *ptr, int newsize)); 29 | void Free PROTO ((void *ptr)); 30 | 31 | /* malloc type */ 32 | #define MT( type) (type *)Malloc (sizeof (type)) 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /c-lib/inc/tbl-enc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * tbl-enc.h - type table encoder 3 | * 4 | * 5 | * Mike Sample 6 | * 7 | * Copyright (C) 1993 Michael Sample 8 | * and the University of British Columbia 9 | * This library is free software; you can redistribute it and/or 10 | * modify it provided that this copyright/license information is retained 11 | * in original form. 12 | * 13 | * If you modify this file, you must clearly indicate your changes. 14 | * 15 | * This source code is distributed in the hope that it will be 16 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 17 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 18 | * 19 | * $Header: /usr/app/odstb/CVS/snacc/c-lib/inc/tbl-enc.h,v 1.1 1995/07/27 08:55:54 rj Exp $ 20 | * $Log: tbl-enc.h,v $ 21 | * Revision 1.1 1995/07/27 08:55:54 rj 22 | * first check-in after being merged into .../c-lib/. 23 | * 24 | */ 25 | 26 | 27 | int TblEncode PROTO ((TBL *tbl, char *modName, char *typeName, BUF_TYPE b, AVal *v, unsigned long int *bytesEncoded)); 28 | 29 | int TblEncodeType PROTO ((TBLType *tblT, BUF_TYPE b, AVal *v, int implicit, unsigned long int *bytesEncoded)); 30 | -------------------------------------------------------------------------------- /c-lib/inc/tbl-dec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * tbl-util.h - type table utilities. 3 | * 4 | * 5 | * Mike Sample 6 | * 7 | * Copyright (C) 1993 Michael Sample 8 | * and the University of British Columbia 9 | * 10 | * This library is free software; you can redistribute it and/or 11 | * modify it provided that this copyright/license information is retained 12 | * in original form. 13 | * 14 | * If you modify this file, you must clearly indicate your changes. 15 | * 16 | * This source code is distributed in the hope that it will be 17 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 18 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 19 | * 20 | * $Header: /usr/app/odstb/CVS/snacc/c-lib/inc/tbl-dec.h,v 1.1 1995/07/27 08:55:52 rj Exp $ 21 | * $Log: tbl-dec.h,v $ 22 | * Revision 1.1 1995/07/27 08:55:52 rj 23 | * first check-in after being merged into .../c-lib/. 24 | * 25 | */ 26 | 27 | 28 | AVal *TblDecode PROTO ((TBL *tbl, char *modName, char *typeName, BUF_TYPE b, unsigned long int *bytesDecoded)); 29 | 30 | AVal *TblDecodeType PROTO ((TBLType *tblT, BUF_TYPE b, int implicit, unsigned long int *bytesDecoded, ENV_TYPE env)); 31 | -------------------------------------------------------------------------------- /compiler/core/recursive.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/core/recursive.h - find and mark the recursive types in a module 3 | * 4 | * MS 92 5 | * 6 | * Copyright (C) 1992 Michael Sample and the University of British Columbia 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * $Header: /usr/app/odstb/CVS/snacc/compiler/core/recursive.h,v 1.2 1994/10/08 03:48:57 rj Exp $ 14 | * $Log: recursive.h,v $ 15 | * Revision 1.2 1994/10/08 03:48:57 rj 16 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 17 | * 18 | * Revision 1.1 1994/08/28 09:49:36 rj 19 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 20 | * 21 | */ 22 | 23 | void MarkRecursiveTypes PROTO ((Module *m)); 24 | -------------------------------------------------------------------------------- /compiler/back-ends/idl-gen/gen-vals.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/back_ends/idl_gen/gen_vals.h 3 | * 4 | * MS 92 5 | * 6 | * Copyright (C) 1991, 1992 Michael Sample 7 | * and the University of British Columbia 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * $Header: /usr/app/odstb/CVS/snacc/compiler/back-ends/idl-gen/gen-vals.h,v 1.1 1997/01/01 20:25:37 rj Exp $ 15 | * $Log: gen-vals.h,v $ 16 | * Revision 1.1 1997/01/01 20:25:37 rj 17 | * first draft 18 | * 19 | */ 20 | 21 | 22 | void PrintIDLValueDef PROTO ((FILE *src, IDLRules *r, ValueDef *v)); 23 | 24 | void PrintIDLValueExtern PROTO ((FILE *hdr, IDLRules *r, ValueDef *v)); 25 | 26 | void PrintIDLValuesClass PROTO ((FILE *f, IDLRules *r, Value *v)); 27 | 28 | void PrintIDLValueInstatiation PROTO ((FILE *f, IDLRules *r, Value *v)); 29 | 30 | void PrintIDLOidValue PROTO ((FILE *f, IDLRules *r, AsnOid *oid)); 31 | 32 | void PrintIDLIntValue PROTO ((FILE *f, IDLRules *r, AsnInt oid)); 33 | -------------------------------------------------------------------------------- /c-examples/makefile: -------------------------------------------------------------------------------- 1 | # c-examples/makefile 2 | # 3 | # $Header: /usr/app/odstb/CVS/snacc/c-examples/makefile,v 1.2 1995/07/24 20:38:56 rj Exp $ 4 | # $Log: makefile,v $ 5 | # Revision 1.2 1995/07/24 20:38:56 rj 6 | # `cd && make' instead of `cd; make'. 7 | # 8 | # changed `_' to `-' in file names. 9 | # 10 | 11 | SUBDIRS = test-lib simple any snmp 12 | 13 | #------------------------------------------------------------------------------- 14 | 15 | .PHONY: implicit_default 16 | implicit_default:: 17 | $(MAKE) subdirs 18 | 19 | subdirs:: $(SUBDIRS) 20 | $(SUBDIRS):: 21 | ifeq ($(subtarget)",check) 22 | echo "Doing "$@" :"; 23 | endif 24 | cd $@ && $(MAKE) $(subtarget) 25 | 26 | # the following hack is needed for older make versions (gmake doesn't need it): 27 | init-depend:: 28 | @for dir in $(SUBDIRS); do\ 29 | test -f $$dir/dependencies || touch $$dir/dependencies;\ 30 | done 31 | 32 | .DEFAULT:: 33 | $(MAKE) subdirs subtarget=$@ 34 | 35 | distfiles:: 36 | echo makefile 37 | for dir in $(SUBDIRS); do\ 38 | subfiles=`cd $$dir && $(MAKE) -s $@`;\ 39 | for file in $$subfiles; do\ 40 | echo "$$dir/$$file";\ 41 | done;\ 42 | done 43 | 44 | # dummy: 45 | install:: 46 | -------------------------------------------------------------------------------- /c-lib/inc/print.h: -------------------------------------------------------------------------------- 1 | /* 2 | * print.h 3 | * 4 | * MS 92 5 | * Copyright (C) 1992 Michael Sample and the University of British Columbia 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it provided that this copyright/license information is retained 9 | * in original form. 10 | * 11 | * If you modify this file, you must clearly indicate your changes. 12 | * 13 | * This source code is distributed in the hope that it will be 14 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 15 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * 17 | * $Header: /usr/app/odstb/CVS/snacc/c-lib/inc/print.h,v 1.2 1995/07/24 21:01:23 rj Exp $ 18 | * $Log: print.h,v $ 19 | * Revision 1.2 1995/07/24 21:01:23 rj 20 | * changed `_' to `-' in file names. 21 | * 22 | * Revision 1.1 1994/08/28 09:45:38 rj 23 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 24 | * 25 | */ 26 | 27 | #ifndef _snaccc_print_h_ 28 | #define _snaccc_print_h_ 29 | 30 | extern unsigned short int stdIndentG; 31 | 32 | void Indent PROTO ((FILE *f, unsigned short int i)); 33 | 34 | 35 | #endif /* conditional include */ 36 | -------------------------------------------------------------------------------- /compiler/core/normalize.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/core/normalize.h 3 | * 4 | * 5 | * Copyright (C) 1991, 1992 Michael Sample 6 | * and the University of British Columbia 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * $Header: /usr/app/odstb/CVS/snacc/compiler/core/normalize.h,v 1.2 1994/10/08 03:48:50 rj Exp $ 14 | * $Log: normalize.h,v $ 15 | * Revision 1.2 1994/10/08 03:48:50 rj 16 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 17 | * 18 | * Revision 1.1 1994/08/28 09:49:25 rj 19 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 20 | * 21 | */ 22 | 23 | void NormalizeModule PROTO ((Module *m)); 24 | void NormalizeValue PROTO ((Module *m, ValueDef *vd, Value *v, int quiet)); 25 | -------------------------------------------------------------------------------- /compiler/core/do-macros.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/core/do_macros.h 3 | * 4 | * MS 92 5 | * 6 | * Copyright (C) 1991, 1992 Michael Sample 7 | * and the University of British Columbia 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * $Header: /usr/app/odstb/CVS/snacc/compiler/core/do-macros.h,v 1.3 1995/07/25 19:41:24 rj Exp $ 15 | * $Log: do-macros.h,v $ 16 | * Revision 1.3 1995/07/25 19:41:24 rj 17 | * changed `_' to `-' in file names. 18 | * 19 | * Revision 1.2 1994/10/08 03:48:40 rj 20 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 21 | * 22 | * Revision 1.1 1994/08/28 09:49:04 rj 23 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 24 | * 25 | */ 26 | 27 | void ProcessMacros PROTO ((Module *m)); 28 | -------------------------------------------------------------------------------- /c-lib/README: -------------------------------------------------------------------------------- 1 | (RCS control information is at the end of this file.) 2 | 3 | 4 | C ASN.1 library README 5 | ---------------------- 6 | 7 | This directory contains the type definitions and the encode, decode, 8 | free and print routines for all of the built-in ASN.1 types. It also 9 | contains the code for three different buffer types. 10 | 11 | The makefile will produce 3 different libraries, one for each buffer 12 | type. Each buffer types requires a different library because many of 13 | the buffer routine calls made from the encode and decode library 14 | routines are macros (for performance reasons). 15 | 16 | The 3 libararies are: 17 | libasn1cebuf.a - uses the ExpBufs 18 | libasn1cmbuf.a - uses the MinBufs 19 | libasn1csbuf.a - uses the SBufs 20 | 21 | See the documentation for a full descriptions of the buffer types. 22 | You must link your code with proper library (i.e. if you use SBufs, 23 | link with libasn1csbuf.a). 24 | 25 | #------------------------------------------------------------------------------- 26 | # $Header: /usr/app/odstb/CVS/snacc/c-lib/README,v 1.2 1994/08/31 23:50:07 rj Exp $ 27 | # $Log: README,v $ 28 | # Revision 1.2 1994/08/31 23:50:07 rj 29 | # textual change to adapt to change of directory tree. 30 | # 31 | -------------------------------------------------------------------------------- /compiler/back-ends/idl-gen/rules.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/back_ends/idl_gen/rules.h 3 | * 4 | * Copyright (C) 1991, 1992 Michael Sample 5 | * and the University of British Columbia 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * $Header: /usr/app/odstb/CVS/snacc/compiler/back-ends/idl-gen/rules.h,v 1.1 1997/01/01 20:25:39 rj Exp $ 13 | * $Log: rules.h,v $ 14 | * Revision 1.1 1997/01/01 20:25:39 rj 15 | * first draft 16 | * 17 | * Revision 1.2 1994/10/08 03:47:50 rj 18 | */ 19 | 20 | /* see ../../core/asn1module.h for IDLTDI (C++ type def info) */ 21 | 22 | typedef struct IDLRules 23 | { 24 | int maxDigitsToAppend; 25 | 26 | char *typePrefix, 27 | *typeSuffix; 28 | 29 | char *choiceEnumSuffix; 30 | char *choiceUnionFieldName; /* what the name of the choice's union is */ 31 | char *choiceUnionName; /* name (tag) for choice union def name */ 32 | 33 | int capitalizeNamedElmts; 34 | 35 | IDLTDI typeConvTbl[BASICTYPE_MACRODEF + 1]; 36 | } IDLRules; 37 | 38 | extern IDLRules idlRulesG; 39 | -------------------------------------------------------------------------------- /compiler/core/link-types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/core/link.h 3 | * 4 | * links type references 5 | * 6 | * Copyright (C) 1991, 1992 Michael Sample 7 | * and the University of British Columbia 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * $Header: /usr/app/odstb/CVS/snacc/compiler/core/link-types.h,v 1.3 1995/07/25 19:41:37 rj Exp $ 15 | * $Log: link-types.h,v $ 16 | * Revision 1.3 1995/07/25 19:41:37 rj 17 | * changed `_' to `-' in file names. 18 | * 19 | * Revision 1.2 1994/10/08 03:48:47 rj 20 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 21 | * 22 | * Revision 1.1 1994/08/28 09:49:18 rj 23 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 24 | * 25 | */ 26 | 27 | 28 | int LinkTypeRefs PROTO ((ModuleList *m)); 29 | -------------------------------------------------------------------------------- /c-lib/src/str-stk.c: -------------------------------------------------------------------------------- 1 | /* 2 | * str_stk.c - maintains a stack of the components of a bit string 3 | * or octet string so they can be copied into a single chunk 4 | * 5 | * Copyright (C) 1992 Michael Sample and the University of British Columbia 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it provided that this copyright/license information is retained 9 | * in original form. 10 | * 11 | * If you modify this file, you must clearly indicate your changes. 12 | * 13 | * This source code is distributed in the hope that it will be 14 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 15 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * 17 | * $Header: /usr/app/odstb/CVS/snacc/c-lib/src/str-stk.c,v 1.2 1995/07/24 21:04:57 rj Exp $ 18 | * $Log: str-stk.c,v $ 19 | * Revision 1.2 1995/07/24 21:04:57 rj 20 | * changed `_' to `-' in file names. 21 | * 22 | * Revision 1.1 1994/08/28 09:46:09 rj 23 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 24 | * 25 | */ 26 | 27 | #include "asn-config.h" 28 | #include "str-stk.h" 29 | 30 | /* global for use by AsnBits and AsnOcts */ 31 | 32 | StrStk strStkG = { NULL, 128, 0, 64, 0, 0 }; 33 | -------------------------------------------------------------------------------- /compiler/core/link-values.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/core/link_values.h 3 | * 4 | * links value references 5 | * 6 | * Copyright (C) 1991, 1992 Michael Sample 7 | * and the University of British Columbia 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * $Header: /usr/app/odstb/CVS/snacc/compiler/core/link-values.h,v 1.3 1995/07/25 19:41:39 rj Exp $ 15 | * $Log: link-values.h,v $ 16 | * Revision 1.3 1995/07/25 19:41:39 rj 17 | * changed `_' to `-' in file names. 18 | * 19 | * Revision 1.2 1994/10/08 03:48:48 rj 20 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 21 | * 22 | * Revision 1.1 1994/08/28 09:49:20 rj 23 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 24 | * 25 | */ 26 | 27 | 28 | int LinkValueRefs PROTO ((ModuleList *m)); 29 | -------------------------------------------------------------------------------- /compiler/core/err-chk.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/core/err_chk.h - check parsed, linked & normalized module for semantic errors 3 | * 4 | * MS 92 5 | * 6 | * Copyright (C) 1991, 1992 Michael Sample 7 | * and the University of British Columbia 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * $Header: /usr/app/odstb/CVS/snacc/compiler/core/err-chk.h,v 1.3 1995/07/25 19:41:26 rj Exp $ 15 | * $Log: err-chk.h,v $ 16 | * Revision 1.3 1995/07/25 19:41:26 rj 17 | * changed `_' to `-' in file names. 18 | * 19 | * Revision 1.2 1994/10/08 03:48:42 rj 20 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 21 | * 22 | * Revision 1.1 1994/08/28 09:49:07 rj 23 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 24 | * 25 | */ 26 | 27 | 28 | void ErrChkModule PROTO ((Module *m)); 29 | -------------------------------------------------------------------------------- /compiler/back-ends/c++-gen/gen-any.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/back_ends/c++_gen/gen_any.h 3 | * 4 | * MS 92 5 | * Copyright (C) 1991, 1992 Michael Sample 6 | * and the University of British Columbia 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * $Header: /usr/app/odstb/CVS/snacc/compiler/back-ends/c++-gen/gen-any.h,v 1.3 1995/07/25 18:19:12 rj Exp $ 14 | * $Log: gen-any.h,v $ 15 | * Revision 1.3 1995/07/25 18:19:12 rj 16 | * changed `_' to `-' in file names. 17 | * 18 | * Revision 1.2 1994/10/08 03:47:54 rj 19 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 20 | * 21 | * Revision 1.1 1994/08/28 09:47:59 rj 22 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 23 | * 24 | */ 25 | 26 | void PrintCxxAnyCode PROTO ((FILE *src, FILE *hdr, CxxRules *r, ModuleList *mods, Module *m)); 27 | -------------------------------------------------------------------------------- /compiler/back-ends/c-gen/kwd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/back-ends/c-gen/kwd.h - for determining whether a string is a C keyword 3 | * 4 | * Copyright (C) 1991, 1992 Michael Sample 5 | * and the University of British Columbia 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * $Header: /usr/app/odstb/CVS/snacc/compiler/back-ends/c-gen/kwd.h,v 1.3 1995/07/25 18:45:39 rj Exp $ 13 | * $Log: kwd.h,v $ 14 | * Revision 1.3 1995/07/25 18:45:39 rj 15 | * file name has been shortened for redundant part: c-gen/c-kwd -> c-gen/kwd. 16 | * 17 | * Revision 1.2 1994/10/08 03:48:07 rj 18 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 19 | * 20 | * Revision 1.1 1994/08/28 09:48:14 rj 21 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 22 | * 23 | */ 24 | 25 | int IsCKeyWord PROTO ((char *str)); 26 | -------------------------------------------------------------------------------- /c-examples/test-lib/README: -------------------------------------------------------------------------------- 1 | (RCS control information is at the end of this file.) 2 | 3 | 4 | C test_lib README 5 | ----------------- 6 | 7 | This directory should have 3 files: 8 | README - this file 9 | makefile 10 | test_lib.c 11 | 12 | Type "make" to compile test_lib. 13 | 14 | test_lib tests each encode and decode routine in the C ASN.1 15 | runtime library. Errors will be reported. 16 | 17 | test_lib should be run for each machine architecture you install snacc on. 18 | If you modify the library routines you should run test_lib again. 19 | 20 | The general testing methodology is: 21 | 1. test the buffer routines 22 | 2. test tags 23 | 3. test lengths 24 | 4. test each libarary type. 25 | 26 | For each type, a range of values is encoded and then decoded 27 | and and compared with the original value. 28 | 29 | #------------------------------------------------------------------------------- 30 | # $Header: /usr/app/odstb/CVS/snacc/c-examples/test-lib/README,v 1.2 1997/02/16 20:26:19 rj Exp $ 31 | # $Log: README,v $ 32 | # Revision 1.2 1997/02/16 20:26:19 rj 33 | # check-in of a few cosmetic changes 34 | # 35 | # Revision 1.1 1994/08/31 08:46:36 rj 36 | # first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 37 | # 38 | -------------------------------------------------------------------------------- /asn1specs/p-rec.asn1: -------------------------------------------------------------------------------- 1 | -- file: .../asn1specs/p_rec.asn1 2 | -- 3 | -- this file is used in ../c{,++}-examples/simple/ 4 | -- 5 | -- $Header: /usr/app/odstb/CVS/snacc/asn1specs/p-rec.asn1,v 1.3 1997/09/16 14:55:30 wan Exp $ 6 | -- $Log: p-rec.asn1,v $ 7 | -- Revision 1.3 1997/09/16 14:55:30 wan 8 | -- Added test for "tag dividable by 128" case. 9 | -- 10 | -- Revision 1.2 1995/07/25 19:53:17 rj 11 | -- changed `_' to `-' in file names. 12 | -- 13 | -- Revision 1.1 1994/08/31 23:05:47 rj 14 | -- first check-in. 15 | -- 16 | 17 | P-REC DEFINITIONS ::= 18 | BEGIN 19 | 20 | 21 | PersonnelRecord ::= --snacc isPdu:"TRUE" -- [APPLICATION 0] IMPLICIT SET 22 | { 23 | Name, 24 | title [0] IA5String, 25 | EmployeeNumber, 26 | dateOfHire [1] Date, 27 | nameOfSpouse [2] Name, 28 | children [3] IMPLICIT SEQUENCE OF ChildInformation DEFAULT {} 29 | } 30 | 31 | ChildInformation ::= SET 32 | { 33 | Name, 34 | dateOfBirth [0] Date 35 | } 36 | 37 | Name ::= [APPLICATION 1] IMPLICIT SEQUENCE 38 | { 39 | givenName IA5String, 40 | initial IA5String, 41 | familyName IA5String 42 | } 43 | 44 | EmployeeNumber ::= [APPLICATION 128] IMPLICIT INTEGER 45 | 46 | Date ::= [APPLICATION 3] IMPLICIT IA5String -- YYYYMMDD 47 | 48 | 49 | 50 | END 51 | -------------------------------------------------------------------------------- /c++-examples/test-lib/README: -------------------------------------------------------------------------------- 1 | (RCS control information is at the end of this file.) 2 | 3 | 4 | C++ test_lib README 5 | ------------------- 6 | 7 | This directory should have 3 files: 8 | README - this file 9 | makefile 10 | test_lib.C 11 | 12 | Type "make" to compile test_lib. 13 | 14 | test_lib tests each encode and decode routine in the C++ ASN.1 15 | runtime library. Errors will be reported. 16 | 17 | test_lib should be run for each machine architecture you install snacc on. 18 | If you modify the library routines you should run test_lib again. 19 | 20 | The general testing methodology is: 21 | 1. test the buffer routines 22 | 2. test tags 23 | 3. test lengths 24 | 4. test each libarary type. 25 | 26 | For each type, a range of values is encoded and then decoded 27 | and and compared with the original value. 28 | 29 | #------------------------------------------------------------------------------- 30 | # $Header: /usr/app/odstb/CVS/snacc/c++-examples/test-lib/README,v 1.2 1997/02/16 20:25:29 rj Exp $ 31 | # $Log: README,v $ 32 | # Revision 1.2 1997/02/16 20:25:29 rj 33 | # check-in of a few cosmetic changes 34 | # 35 | # Revision 1.1 1994/08/31 08:48:16 rj 36 | # first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 37 | # 38 | -------------------------------------------------------------------------------- /c-examples/test-lib/makefile: -------------------------------------------------------------------------------- 1 | # c-examples/test-lib/makefile 2 | # 3 | # $Header: /usr/app/odstb/CVS/snacc/c-examples/test-lib/makefile,v 1.4 1995/07/24 20:50:11 rj Exp $ 4 | # $Log: makefile,v $ 5 | # Revision 1.4 1995/07/24 20:50:11 rj 6 | # changed `_' to `-' in file names. 7 | # 8 | # Revision 1.3 1995/02/13 15:05:59 rj 9 | # augment CPPFLAGS, not overwrite. 10 | # 11 | # Revision 1.2 1994/08/31 21:43:20 rj 12 | # rebuild the executables when the c-lib is newer. 13 | # 14 | # Revision 1.1 1994/08/31 08:46:37 rj 15 | # first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 16 | # 17 | 18 | #include ../../makehead 19 | 20 | TOP = /usr 21 | 22 | ASN1_C_LIB_DIR = $(TOP)/lib 23 | ASN1_C_INC_DIR = $(TOP)/include/snacc/c 24 | ASN1_C_LIB = $(ASN1_C_LIB_DIR)/libasn1csbuf.a 25 | 26 | CPPFLAGS += -g -I$(TOP) -I$(ASN1_C_INC_DIR) -DUSE_SBUF 27 | LIBS += -lm 28 | 29 | LDLIBS = $(ASN1_C_LIB) $(LIBS) 30 | 31 | CFILES = \ 32 | test-lib.c 33 | 34 | DISTFILES = \ 35 | README \ 36 | makefile \ 37 | $(CFILES) 38 | 39 | #------------------------------------------------------------------------------- 40 | 41 | default:: check 42 | 43 | check:: test-lib 44 | ./test-lib 45 | 46 | test-lib: $(ASN1_C_LIB) 47 | 48 | clean:: 49 | $(RM) *.o *~ .emacs* test-lib core 50 | 51 | #include ../../maketail 52 | -------------------------------------------------------------------------------- /compiler/back-ends/c++-gen/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/back_ends/c++_gen/types.h - fills in c++ type information 3 | * 4 | * Copyright (C) 1991, 1992 Michael Sample 5 | * and the University of British Columbia 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * $Header: /usr/app/odstb/CVS/snacc/compiler/back-ends/c++-gen/types.h,v 1.3 1995/07/25 18:25:19 rj Exp $ 13 | * $Log: types.h,v $ 14 | * Revision 1.3 1995/07/25 18:25:19 rj 15 | * file name has been shortened for redundant part: c++-gen/c++-types -> c++-gen/types. 16 | * 17 | * Revision 1.2 1994/10/08 03:47:52 rj 18 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 19 | * 20 | * Revision 1.1 1994/08/28 09:47:57 rj 21 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 22 | * 23 | */ 24 | 25 | 26 | void FillCxxTypeInfo PROTO ((CxxRules *r, ModuleList *m)); 27 | -------------------------------------------------------------------------------- /compiler/back-ends/c++-gen/kwd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/back_ends/c++_gen/kwd.h - routines for determining whether a given str is a C++ keyword 3 | * 4 | * MS 92 5 | * Copyright (C) 1991, 1992 Michael Sample 6 | * and the University of British Columbia 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * $Header: /usr/app/odstb/CVS/snacc/compiler/back-ends/c++-gen/kwd.h,v 1.3 1995/07/25 18:22:41 rj Exp $ 14 | * $Log: kwd.h,v $ 15 | * Revision 1.3 1995/07/25 18:22:41 rj 16 | * file name has been shortened for redundant part: c++-gen/c++-kwd -> c++-gen/kwd. 17 | * 18 | * Revision 1.2 1994/10/08 03:48:05 rj 19 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 20 | * 21 | * Revision 1.1 1994/08/28 09:48:12 rj 22 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 23 | * 24 | */ 25 | 26 | int IsCxxKeyWord PROTO ((char *str)); 27 | -------------------------------------------------------------------------------- /compiler/core/oid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/core/oid.h - routine for building an ENC_OID from an arc number list 3 | * 4 | * Copyright (C) 1991, 1992 Michael Sample 5 | * and the University of British Columbia 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * $Header: /usr/app/odstb/CVS/snacc/compiler/core/oid.h,v 1.2 1994/10/08 03:48:51 rj Exp $ 13 | * $Log: oid.h,v $ 14 | * Revision 1.2 1994/10/08 03:48:51 rj 15 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 16 | * 17 | * Revision 1.1 1994/08/28 09:49:27 rj 18 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 19 | * 20 | */ 21 | 22 | 23 | int OidArcNameToNum PROTO ((char *name)); 24 | unsigned long EncodedOidLen PROTO ((OID *oid)); 25 | void BuildEncodedOid PROTO ((OID *oid, AsnOid *result)); 26 | void UnbuildEncodedOid PROTO ((AsnOid *eoid, OID **result)); 27 | -------------------------------------------------------------------------------- /compiler/core/val-parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/core/val_parser.h 3 | * 4 | * Value *ParseValue (Type *t, char *valueNotation, int vnlen); 5 | * given a string with txt ASN.1 value notation, the length of 6 | * the string and the ASN.1 type the value notion defines a value 7 | * for, return a Value that contains the internal version 8 | * 9 | * 10 | * Copyright (C) 1992 Michael Sample and the University of British Columbia 11 | * 12 | * This program is free software; you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation; either version 2 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * $Header: /usr/app/odstb/CVS/snacc/compiler/core/val-parser.h,v 1.3 1995/07/25 19:41:48 rj Exp $ 18 | * $Log: val-parser.h,v $ 19 | * Revision 1.3 1995/07/25 19:41:48 rj 20 | * changed `_' to `-' in file names. 21 | * 22 | * Revision 1.2 1994/08/31 21:47:26 rj 23 | * adjust the function declaration to the function definition. this went undetected because the .c file didn't include its .h file. 24 | * 25 | * Revision 1.1 1994/08/28 09:49:45 rj 26 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 27 | * 28 | */ 29 | 30 | 31 | int ParseValues PROTO ((ModuleList *mods, Module *m)); 32 | -------------------------------------------------------------------------------- /tbl-tools/ptbl/README: -------------------------------------------------------------------------------- 1 | (RCS control information is at the end of this file.) 2 | 3 | 4 | Table printing README - MS 93 5 | ----------------------------- 6 | 7 | This program is good for snooping through table file to see what 8 | they contain. You will almost always want to use the "-a" option. 9 | 10 | The ptbl program will print a type table in 2 forms: 11 | 12 | 1. By default tables are printed in ASN.1 value notation for the 13 | TBL ASN.1 data structure (See the tbl.asn1 file in snacc/asn1specs). 14 | 15 | 2. Using the "-a" option makes ptbl print the type in the type table in 16 | ASN.1 form. Some parts are not printed - IMPORT/EXPORT info 17 | (although you could figure it out). The ASN.1 printing code 18 | (in pasn1.c) is very simple and is a good way to become familiar 19 | with the TBL data structure (type tables). 20 | 21 | 22 | Type "make" to build ptbl. 23 | Type ./ptbl to see the arguments it expects. 24 | 25 | try: 26 | 27 | ./ptbl -a ../demo-tbls/p-rec.tt 28 | 29 | also try: 30 | 31 | ./ptbl ../demo-tbls/p-rec.tt 32 | 33 | ptbl without the -a option is only really useful for debugging. 34 | 35 | #------------------------------------------------------------------------------- 36 | # $Header: /usr/app/odstb/CVS/snacc/tbl-tools/ptbl/README,v 1.1 1997/02/15 19:26:19 rj Exp $ 37 | # $Log: README,v $ 38 | # Revision 1.1 1997/02/15 19:26:19 rj 39 | # first check-in 40 | # 41 | -------------------------------------------------------------------------------- /compiler/core/parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/core/parser.h 3 | * 4 | * Copyright (C) 1991, 1992 Michael Sample 5 | * and the University of British Columbia 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * $Header: /usr/app/odstb/CVS/snacc/compiler/core/parser.h,v 1.3 1995/07/24 13:33:19 rj Exp $ 13 | * $Log: parser.h,v $ 14 | * Revision 1.3 1995/07/24 13:33:19 rj 15 | * typo fixed: Pasrser -> Parser 16 | * 17 | * Revision 1.2 1994/10/08 03:48:52 rj 18 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 19 | * 20 | * Revision 1.1 1994/08/28 09:49:31 rj 21 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 22 | * 23 | */ 24 | 25 | extern int smallErrG; /* can continue processing but don't produce code - see more errs */ 26 | extern int yydebug; /* set to 1 to enable debugging */ 27 | 28 | int InitAsn1Parser PROTO ((Module *mod, char *fileName, FILE *fPtr)); 29 | 30 | int yyparse(); 31 | -------------------------------------------------------------------------------- /compiler/back-ends/c-gen/gen-print.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/back-ends/c-gen/gen-print.h 3 | * 4 | * MS 92 5 | * Copyright (C) 1991, 1992 Michael Sample 6 | * and the University of British Columbia 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * $Header: /usr/app/odstb/CVS/snacc/compiler/back-ends/c-gen/gen-print.h,v 1.3 1995/07/25 18:43:19 rj Exp $ 14 | * $Log: gen-print.h,v $ 15 | * Revision 1.3 1995/07/25 18:43:19 rj 16 | * file name has been shortened for redundant part: c-gen/gen-c-print -> c-gen/gen-print. 17 | * 18 | * changed `_' to `-' in file names. 19 | * 20 | * Revision 1.2 1994/10/08 03:48:13 rj 21 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 22 | * 23 | * Revision 1.1 1994/08/28 09:48:29 rj 24 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 25 | * 26 | */ 27 | 28 | void PrintCPrinter PROTO ((FILE *src, FILE *hdr, CRules *r, ModuleList *mods, Module *m, TypeDef *td)); 29 | -------------------------------------------------------------------------------- /compiler/back-ends/c-gen/gen-any.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/back-ends/c-gen/gen-any.h 3 | * 4 | * MS 92 5 | * Copyright (C) 1991, 1992 Michael Sample 6 | * and the University of British Columbia 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * $Header: /usr/app/odstb/CVS/snacc/compiler/back-ends/c-gen/gen-any.h,v 1.3 1995/07/25 18:33:59 rj Exp $ 14 | * $Log: gen-any.h,v $ 15 | * Revision 1.3 1995/07/25 18:33:59 rj 16 | * file name has been shortened for redundant part: c-gen/gen-c-any -> c-gen/gen-any. 17 | * 18 | * changed `_' to `-' in file names. 19 | * 20 | * Revision 1.2 1994/10/08 03:48:08 rj 21 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 22 | * 23 | * Revision 1.1 1994/08/28 09:48:16 rj 24 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 25 | * 26 | */ 27 | 28 | extern int anyEnumValG; 29 | 30 | 31 | void PrintCAnyCode PROTO ((FILE *src, FILE *hdr, CRules *r, ModuleList *mods, Module *m)); 32 | -------------------------------------------------------------------------------- /compiler/back-ends/c-gen/gen-free.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/back-ends/c-gen/gen-free.h 3 | * 4 | * Mike Sample 5 | * 92/04 6 | * Copyright (C) 1991, 1992 Michael Sample 7 | * and the University of British Columbia 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * $Header: /usr/app/odstb/CVS/snacc/compiler/back-ends/c-gen/gen-free.h,v 1.3 1995/07/25 18:42:48 rj Exp $ 15 | * $Log: gen-free.h,v $ 16 | * Revision 1.3 1995/07/25 18:42:48 rj 17 | * file name has been shortened for redundant part: c-gen/gen-c-free -> c-gen/gen-free. 18 | * 19 | * changed `_' to `-' in file names. 20 | * 21 | * Revision 1.2 1994/10/08 03:48:12 rj 22 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 23 | * 24 | * Revision 1.1 1994/08/28 09:48:27 rj 25 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 26 | * 27 | */ 28 | 29 | 30 | void PrintCFree PROTO ((FILE *src, FILE *hdr, CRules *r, ModuleList *mods, Module *m, TypeDef *td)); 31 | -------------------------------------------------------------------------------- /c-lib/inc/asn-incl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * asn_incl.h 3 | * includes hdr files nec for a user prg that calls the generated 4 | * encoding/decoding routines. 5 | * 6 | * Copyright (C) 1992 Michael Sample and the University of British Columbia 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it provided that this copyright/license information is retained 10 | * in original form. 11 | * 12 | * If you modify this file, you must clearly indicate your changes. 13 | * 14 | * This source code is distributed in the hope that it will be 15 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 16 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | * 18 | * $Header: /usr/app/odstb/CVS/snacc/c-lib/inc/asn-incl.h,v 1.2 1995/07/24 21:01:13 rj Exp $ 19 | * $Log: asn-incl.h,v $ 20 | * Revision 1.2 1995/07/24 21:01:13 rj 21 | * changed `_' to `-' in file names. 22 | * 23 | * Revision 1.1 1994/08/28 09:21:27 rj 24 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 25 | * 26 | */ 27 | 28 | 29 | #include "asn-config.h" 30 | #include "asn-len.h" 31 | #include "asn-tag.h" 32 | #include "asn-bool.h" 33 | #include "asn-int.h" 34 | #include "asn-enum.h" 35 | #include "asn-real.h" 36 | #include "asn-octs.h" 37 | #include "asn-bits.h" 38 | #include "asn-oid.h" 39 | #include "asn-null.h" 40 | #include "asn-any.h" 41 | #include "asn-list.h" 42 | #include "asn-useful.h" 43 | -------------------------------------------------------------------------------- /compiler/back-ends/c-gen/gen-type.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/back-ends/c-gen/gen-type.h - routines for printing c types ASN.1 from type trees 3 | * 4 | * Mike Sample 5 | * 91/09/26 6 | * Copyright (C) 1991, 1992 Michael Sample 7 | * and the University of British Columbia 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * $Header: /usr/app/odstb/CVS/snacc/compiler/back-ends/c-gen/gen-type.h,v 1.3 1995/07/25 18:43:45 rj Exp $ 15 | * $Log: gen-type.h,v $ 16 | * Revision 1.3 1995/07/25 18:43:45 rj 17 | * file name has been shortened for redundant part: c-gen/gen-c-type -> c-gen/gen-type. 18 | * 19 | * changed `_' to `-' in file names. 20 | * 21 | * Revision 1.2 1994/10/08 03:48:14 rj 22 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 23 | * 24 | * Revision 1.1 1994/08/28 09:48:32 rj 25 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 26 | * 27 | */ 28 | 29 | 30 | void PrintCTypeDef PROTO ((FILE *f, CRules *r, Module *m, TypeDef *td)); 31 | -------------------------------------------------------------------------------- /compiler/core/gen-tbls.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/core/gen_tbls.h 3 | * 4 | * generates type tables and writes them to a file. 5 | * 6 | * MS 7 | * 93/02/07 8 | * 9 | * Copyright (C) 1993 Michael Sample 10 | * and the University of British Columbia 11 | * 12 | * This program is free software; you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation; either version 2 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * $Header: /usr/app/odstb/CVS/snacc/compiler/core/gen-tbls.h,v 1.4 1997/05/07 15:18:35 wan Exp $ 18 | * $Log: gen-tbls.h,v $ 19 | * Revision 1.4 1997/05/07 15:18:35 wan 20 | * Added (limited) size constraints, bitstring and enumeration names to tables 21 | * 22 | * Revision 1.3 1995/07/25 19:41:29 rj 23 | * changed `_' to `-' in file names. 24 | * 25 | * Revision 1.2 1994/10/08 03:48:44 rj 26 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 27 | * 28 | * Revision 1.1 1994/08/28 09:49:11 rj 29 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 30 | * 31 | */ 32 | 33 | 34 | void GenTypeTbls PROTO ((ModuleList *mods, char *fileName, int tableFileVersion)); 35 | -------------------------------------------------------------------------------- /compiler/back-ends/c-gen/gen-vals.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/back-ends/c-gen/gen-vals.h 3 | * 4 | * MS 92 5 | * Copyright (C) 1991, 1992 Michael Sample 6 | * and the University of British Columbia 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * $Header: /usr/app/odstb/CVS/snacc/compiler/back-ends/c-gen/gen-vals.h,v 1.3 1995/07/25 18:44:13 rj Exp $ 14 | * $Log: gen-vals.h,v $ 15 | * Revision 1.3 1995/07/25 18:44:13 rj 16 | * file name has been shortened for redundant part: c-gen/gen-c-vals -> c-gen/gen-vals. 17 | * 18 | * changed `_' to `-' in file names. 19 | * 20 | * Revision 1.2 1994/10/08 03:48:15 rj 21 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 22 | * 23 | * Revision 1.1 1994/08/28 09:48:34 rj 24 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 25 | * 26 | */ 27 | 28 | void PrintCValueDef PROTO ((FILE *src, CRules *r, ValueDef *v)); 29 | 30 | void PrintCValueExtern PROTO ((FILE *hdr, CRules *r, ValueDef *v)); 31 | 32 | void PrintCOidValue PROTO ((FILE *f, CRules *r, AsnOid *oid)); 33 | -------------------------------------------------------------------------------- /compiler/back-ends/c-gen/gen-enc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/back-ends/c-gen/gen-enc.h - routines for printing C encoders from type trees 3 | * 4 | * Mike Sample 5 | * 91/09/26 6 | * Copyright (C) 1991, 1992 Michael Sample 7 | * and the University of British Columbia 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * $Header: /usr/app/odstb/CVS/snacc/compiler/back-ends/c-gen/gen-enc.h,v 1.3 1995/07/25 18:42:25 rj Exp $ 15 | * $Log: gen-enc.h,v $ 16 | * Revision 1.3 1995/07/25 18:42:25 rj 17 | * file name has been shortened for redundant part: c-gen/gen-c-enc -> c-gen/gen-enc. 18 | * 19 | * changed `_' to `-' in file names. 20 | * 21 | * Revision 1.2 1994/10/08 03:48:11 rj 22 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 23 | * 24 | * Revision 1.1 1994/08/28 09:48:25 rj 25 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 26 | * 27 | */ 28 | 29 | 30 | 31 | void PrintCBerEncoder PROTO ((FILE *src, FILE *hdr, CRules *r, Module *m, TypeDef *td)); 32 | 33 | void PrintCBerContentEncoder PROTO ((FILE *src, FILE *hdr, CRules *r, Module *m, TypeDef *td)); 34 | -------------------------------------------------------------------------------- /c-lib/inc/asn-bool.h: -------------------------------------------------------------------------------- 1 | /* 2 | * asn_bool.h 3 | * 4 | * MS 92 5 | * Copyright (C) 1992 Michael Sample and the University of British Columbia 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it provided that this copyright/license information is retained 9 | * in original form. 10 | * 11 | * If you modify this file, you must clearly indicate your changes. 12 | * 13 | * This source code is distributed in the hope that it will be 14 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 15 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * 17 | * $Header: /usr/app/odstb/CVS/snacc/c-lib/inc/asn-bool.h,v 1.2 1995/07/24 21:01:10 rj Exp $ 18 | * $Log: asn-bool.h,v $ 19 | * Revision 1.2 1995/07/24 21:01:10 rj 20 | * changed `_' to `-' in file names. 21 | * 22 | * Revision 1.1 1994/08/28 09:21:24 rj 23 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 24 | * 25 | */ 26 | 27 | #ifndef _asn_bool_h_ 28 | #define _asn_bool_h_ 29 | 30 | typedef unsigned char AsnBool; 31 | 32 | 33 | AsnLen BEncAsnBool PROTO ((BUF_TYPE b, AsnBool *data)); 34 | 35 | void BDecAsnBool PROTO ((BUF_TYPE b, AsnBool *result, AsnLen *bytesDecoded, ENV_TYPE env)); 36 | 37 | AsnLen BEncAsnBoolContent PROTO ((BUF_TYPE b, AsnBool *data)); 38 | 39 | void BDecAsnBoolContent PROTO ((BUF_TYPE b, AsnTag tag, AsnLen len, AsnBool *result, AsnLen *bytesDecoded, ENV_TYPE env)); 40 | 41 | /* do nothing */ 42 | #define FreeAsnBool( v) 43 | 44 | void PrintAsnBool PROTO ((FILE *f, AsnBool *b, unsigned short int indent)); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /compiler/back-ends/c-gen/gen-dec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/back-ends/c-gen/gen-dec.h - routines for printing C decoders from type trees 3 | * 4 | * Mike Sample 5 | * 91/09/26 6 | * Copyright (C) 1991, 1992 Michael Sample 7 | * and the University of British Columbia 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * $Header: /usr/app/odstb/CVS/snacc/compiler/back-ends/c-gen/gen-dec.h,v 1.3 1995/07/25 18:41:03 rj Exp $ 15 | * $Log: gen-dec.h,v $ 16 | * Revision 1.3 1995/07/25 18:41:03 rj 17 | * file name has been shortened for redundant part: c-gen/gen-c-dec -> c-gen/gen-dec. 18 | * 19 | * changed `_' to `-' in file names. 20 | * 21 | * Revision 1.2 1994/10/08 03:48:10 rj 22 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 23 | * 24 | * Revision 1.1 1994/08/28 09:48:22 rj 25 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 26 | * 27 | */ 28 | 29 | 30 | void PrintCBerDecoder PROTO ((FILE *src, FILE *hdr, CRules *r, Module *m, TypeDef *td, long int *longJmpVal)); 31 | 32 | 33 | void PrintCBerContentDecoder PROTO ((FILE *src, FILE *hdr, CRules *r, Module *m, TypeDef *td, long int *longJmpVal)); 34 | -------------------------------------------------------------------------------- /c-lib/inc/asn-enum.h: -------------------------------------------------------------------------------- 1 | /* 2 | * asn_enum.h 3 | * 4 | * MS 92 5 | * Copyright (C) 1992 Michael Sample and the University of British Columbia 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it provided that this copyright/license information is retained 9 | * in original form. 10 | * 11 | * If you modify this file, you must clearly indicate your changes. 12 | * 13 | * This source code is distributed in the hope that it will be 14 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 15 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * 17 | * $Header: /usr/app/odstb/CVS/snacc/c-lib/inc/asn-enum.h,v 1.2 1995/07/24 21:01:12 rj Exp $ 18 | * $Log: asn-enum.h,v $ 19 | * Revision 1.2 1995/07/24 21:01:12 rj 20 | * changed `_' to `-' in file names. 21 | * 22 | * Revision 1.1 1994/08/28 09:21:26 rj 23 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 24 | * 25 | */ 26 | 27 | #ifndef _asn_enum_h_ 28 | #define _asn_enum_h_ 29 | 30 | typedef AsnInt AsnEnum; 31 | 32 | /* 33 | * ENUMERATED have a UNIVERSAL tag that is diff from INTEGERS 34 | * so need diff encoding routine tho content stuff is the same 35 | */ 36 | AsnLen BEncAsnEnum PROTO ((BUF_TYPE b, AsnEnum *data)); 37 | 38 | void BDecAsnEnum PROTO ((BUF_TYPE b, AsnEnum *result, AsnLen *bytesDecoded, ENV_TYPE env)); 39 | 40 | #define BEncAsnEnumContent BEncAsnIntContent 41 | 42 | #define BDecAsnEnumContent BDecAsnIntContent 43 | 44 | #define FreeAsnEnum FreeAsnInt 45 | 46 | #define PrintAsnEnum PrintAsnInt 47 | 48 | 49 | #endif /* conditional include */ 50 | -------------------------------------------------------------------------------- /compiler/back-ends/tag-util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/back_ends/c_gen/tag_util.h - utilities for dealing with tags 3 | * 4 | * MS 92 5 | * Copyright (C) 1991, 1992 Michael Sample 6 | * and the University of British Columbia 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * $Header: /usr/app/odstb/CVS/snacc/compiler/back-ends/tag-util.h,v 1.3 1995/07/25 18:15:29 rj Exp $ 14 | * $Log: tag-util.h,v $ 15 | * Revision 1.3 1995/07/25 18:15:29 rj 16 | * changed `_' to `-' in file names. 17 | * 18 | * Revision 1.2 1994/10/08 03:48:19 rj 19 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 20 | * 21 | * Revision 1.1 1994/08/28 09:48:40 rj 22 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 23 | * 24 | */ 25 | 26 | 27 | TagList *GetTags PROTO ((Type *t, int *stoleChoiceTags)); 28 | void FreeTags PROTO ((TagList *tl)); 29 | int CountTags PROTO ((Type *t)); 30 | unsigned long int TagByteLen PROTO ((unsigned long int tagCode)); 31 | char *Class2ClassStr PROTO ((int class)); /* class defined in asn1module.h */ 32 | char *Form2FormStr PROTO ((BER_FORM form)); 33 | char *Code2UnivCodeStr PROTO ((BER_UNIV_CODE code)); 34 | -------------------------------------------------------------------------------- /compiler/back-ends/c-gen/gen-code.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/back-ends/c-gen/gen-code.h - generates C hdr and source files 3 | * 4 | * Copyright (C) 1991, 1992 Michael Sample 5 | * and the University of British Columbia 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * $Header: /usr/app/odstb/CVS/snacc/compiler/back-ends/c-gen/gen-code.h,v 1.3 1995/07/25 18:38:30 rj Exp $ 13 | * $Log: gen-code.h,v $ 14 | * Revision 1.3 1995/07/25 18:38:30 rj 15 | * file name has been shortened for redundant part: c-gen/gen-c-code -> c-gen/gen-code. 16 | * 17 | * PrintConditionalIncludeOpen() and PrintConditionalIncludeClose() moved to back-ends/cond.h 18 | * 19 | * changed `_' to `-' in file names. 20 | * 21 | * Revision 1.2 1994/10/08 03:48:09 rj 22 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 23 | * 24 | * Revision 1.1 1994/08/28 09:48:19 rj 25 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 26 | * 27 | */ 28 | 29 | 30 | void PrintCCode PROTO ((FILE *src, FILE *hdr, ModuleList *mods, Module *m, CRules *r, long int longJmpVal, int printTypes, int printValues, int printEncoders, int printDecoders, int printPrinters, int printFree)); 31 | -------------------------------------------------------------------------------- /c-lib/inc/asn-null.h: -------------------------------------------------------------------------------- 1 | /* 2 | * asn_null.h 3 | * 4 | * MS 92 5 | * Copyright (C) 1992 Michael Sample and the University of British Columbia 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it provided that this copyright/license information is retained 9 | * in original form. 10 | * 11 | * If you modify this file, you must clearly indicate your changes. 12 | * 13 | * This source code is distributed in the hope that it will be 14 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 15 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * 17 | * $Header: /usr/app/odstb/CVS/snacc/c-lib/inc/asn-null.h,v 1.2 1995/07/24 21:01:16 rj Exp $ 18 | * $Log: asn-null.h,v $ 19 | * Revision 1.2 1995/07/24 21:01:16 rj 20 | * changed `_' to `-' in file names. 21 | * 22 | * Revision 1.1 1994/08/28 09:21:31 rj 23 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 24 | * 25 | */ 26 | 27 | #ifndef _asn_null_h_ 28 | #define _asn_null_h_ 29 | 30 | typedef char AsnNull; 31 | 32 | 33 | AsnLen BEncAsnNull PROTO ((BUF_TYPE b, AsnNull *data)); 34 | 35 | void BDecAsnNull PROTO ((BUF_TYPE b, AsnNull *result, AsnLen *bytesDecoded, ENV_TYPE env)); 36 | 37 | 38 | /* 'return' length of encoded NULL value, 0 */ 39 | #define BEncAsnNullContent(b, data) 0 40 | 41 | void BDecAsnNullContent PROTO ((BUF_TYPE b, AsnTag tag, AsnLen len, AsnNull *result, AsnLen *bytesDecoded, ENV_TYPE env)); 42 | 43 | /* do nothing */ 44 | #define FreeAsnNull( v) 45 | 46 | void PrintAsnNull PROTO ((FILE *f, AsnNull * b, unsigned short int indent)); 47 | 48 | #endif /* conditional include */ 49 | -------------------------------------------------------------------------------- /c-lib/inc/tbl-incl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * tbl-incl.h - wraps all nec tbl stuff in one file 3 | * 4 | * Copyright (C) 1993 Michael Sample 5 | * and the University of British Columbia 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it provided that this copyright/license information is retained 9 | * in original form. 10 | * 11 | * If you modify this file, you must clearly indicate your changes. 12 | * 13 | * This source code is distributed in the hope that it will be 14 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 15 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * 17 | * $Header: /usr/app/odstb/CVS/snacc/c-lib/inc/tbl-incl.h,v 1.2 1997/05/07 15:18:34 wan Exp $ 18 | * $Log: tbl-incl.h,v $ 19 | * Revision 1.2 1997/05/07 15:18:34 wan 20 | * Added (limited) size constraints, bitstring and enumeration names to tables 21 | * 22 | * Revision 1.1 1995/07/27 08:55:57 rj 23 | * first check-in after being merged into .../c-lib/. 24 | * 25 | */ 26 | 27 | #ifndef TBL_INCL_H 28 | #define TBL_INCL_H 29 | #define TTBL 3 30 | 31 | #include "asn-incl.h" 32 | #include "tbl.h" 33 | 34 | typedef void AVal; 35 | 36 | typedef AVal *AStructVal; /* an array of AVal ptrs */ 37 | 38 | typedef struct AChoiceVal 39 | { 40 | enum { achoiceval_notused } choiceId; 41 | AVal *val; 42 | } AChoiceVal; 43 | 44 | 45 | #include "tbl-util.h" 46 | #include "tbl-enc.h" 47 | #include "tbl-dec.h" 48 | #include "tbl-print.h" 49 | #include "tbl-free.h" 50 | 51 | /* 52 | * TblError (char *str) - configure error handler 53 | */ 54 | #define TblError( str) fprintf (stderr, "%s", str) 55 | 56 | #endif /* TBL_INCL_H */ 57 | -------------------------------------------------------------------------------- /compiler/back-ends/cond.c: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/back_ends/cond.c - generate conditional include for C(++) hdr files 3 | * 4 | * MS 92 5 | * Copyright (C) 1991, 1992 Michael Sample 6 | * and the University of British Columbia 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * $Header: /usr/app/odstb/CVS/snacc/compiler/back-ends/cond.c,v 1.1 1995/07/25 19:13:49 rj Exp $ 14 | * $Log: cond.c,v $ 15 | * Revision 1.1 1995/07/25 19:13:49 rj 16 | * PrintConditionalIncludeOpen() and PrintConditionalIncludeClose() moved from back-ends/c-gen/gen-code.[ch]. 17 | * 18 | */ 19 | 20 | #include 21 | 22 | #include "asn-incl.h" 23 | #include "cond.h" 24 | 25 | 26 | void 27 | PrintConditionalIncludeOpen PARAMS ((f, fileName), 28 | FILE *f _AND_ 29 | char *fileName) 30 | { 31 | char hdrFileDefSym[256]; 32 | int i; 33 | 34 | strcpy (hdrFileDefSym, fileName); 35 | for (i = 0; i < strlen (hdrFileDefSym); i++) 36 | if (hdrFileDefSym[i] == '-' || hdrFileDefSym[i] == '.') 37 | hdrFileDefSym[i] = '_'; 38 | 39 | fprintf (f, "#ifndef _%s_\n", hdrFileDefSym); 40 | fprintf(f, "#define _%s_\n\n\n", hdrFileDefSym); 41 | } /* PrintConditionalIncludeOpen */ 42 | 43 | 44 | void 45 | PrintConditionalIncludeClose PARAMS ((f, fileName), 46 | FILE *f _AND_ 47 | char *fileName) 48 | { 49 | fprintf (f, "\n#endif /* conditional include of %s */\n", fileName); 50 | 51 | } /* PrintConditionalIncludeClose */ 52 | -------------------------------------------------------------------------------- /compiler/back-ends/c++-gen/gen-vals.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/back_ends/c++_gen/gen_vals.h 3 | * 4 | * MS 92 5 | * 6 | * Copyright (C) 1991, 1992 Michael Sample 7 | * and the University of British Columbia 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * $Header: /usr/app/odstb/CVS/snacc/compiler/back-ends/c++-gen/gen-vals.h,v 1.3 1995/07/25 18:23:19 rj Exp $ 15 | * $Log: gen-vals.h,v $ 16 | * Revision 1.3 1995/07/25 18:23:19 rj 17 | * changed `_' to `-' in file names. 18 | * 19 | * Revision 1.2 1994/10/08 03:47:58 rj 20 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 21 | * 22 | * Revision 1.1 1994/08/28 09:48:06 rj 23 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 24 | * 25 | */ 26 | 27 | 28 | void PrintCxxValueDef PROTO ((FILE *src, CxxRules *r, ValueDef *v)); 29 | 30 | void PrintCxxValueExtern PROTO ((FILE *hdr, CxxRules *r, ValueDef *v)); 31 | 32 | void PrintCxxValuesClass PROTO ((FILE *f, CxxRules *r, Value *v)); 33 | 34 | void PrintCxxValueInstatiation PROTO ((FILE *f, CxxRules *r, Value *v)); 35 | 36 | void PrintCxxOidValue PROTO ((FILE *f, CxxRules *r, AsnOid *oid)); 37 | 38 | void PrintCxxIntValue PROTO ((FILE *f, CxxRules *r, AsnInt oid)); 39 | -------------------------------------------------------------------------------- /c++-examples/test-lib/makefile: -------------------------------------------------------------------------------- 1 | # c++-examples/test-lib/makefile 2 | # 3 | # $Header: /usr/app/odstb/CVS/snacc/c++-examples/test-lib/makefile,v 1.7 1997/03/03 11:58:30 wan Exp $ 4 | # $Log: makefile,v $ 5 | # Revision 1.7 1997/03/03 11:58:30 wan 6 | # Final pre-delivery stuff (I hope). 7 | # 8 | # Revision 1.6 1997/02/28 13:39:41 wan 9 | # Modifications collected for new version 1.3: Bug fixes, tk4.2. 10 | # 11 | # Revision 1.5 1995/07/24 15:31:14 rj 12 | # changed `_' to `-' in file names. 13 | # 14 | # Revision 1.4 1995/02/13 14:58:17 rj 15 | # augment CPPFLAGS, not overwrite 16 | # 17 | # Revision 1.3 1994/09/01 02:26:58 rj 18 | # use CXX instead of CC to get another default linkage 19 | # 20 | # Revision 1.2 1994/08/31 21:44:25 rj 21 | # rebuild the executables when the c++-lib is newer. 22 | # 23 | # Revision 1.1 1994/08/31 08:48:17 rj 24 | # first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 25 | # 26 | 27 | #include ../../makehead 28 | 29 | TOP = /usr 30 | 31 | ASN1_C++_LIB_DIR = $(TOP)/lib 32 | ASN1_C++_INC_DIR = $(TOP)/include/snacc/c++ 33 | ASN1_C++_LIB = $(ASN1_C++_LIB_DIR)/libasn1c++.a 34 | 35 | CC = $(CXX) 36 | CPPFLAGS += -g -I$(TOP) -I$(ASN1_C++_INC_DIR) 37 | 38 | CFILES = \ 39 | test-lib.cpp 40 | 41 | DISTFILES = \ 42 | README \ 43 | makefile \ 44 | $(CFILES) 45 | 46 | #------------------------------------------------------------------------------- 47 | 48 | default:: check 49 | 50 | check:: test-lib 51 | ./test-lib 52 | 53 | test-lib: $(ASN1_C++_LIB) test-lib.o 54 | $(CXX) $(LDFLAGS) -o $@ test-lib.o $(ASN1_C++_LIB) $(LIBS) 55 | 56 | clean:: 57 | $(RM) *.o *~ .emacs* test-lib core 58 | 59 | #include ../../maketail 60 | -------------------------------------------------------------------------------- /c-lib/inc/asn-real.h: -------------------------------------------------------------------------------- 1 | /* 2 | * asn_real.h 3 | * 4 | * MS 92 5 | * Copyright (C) 1992 Michael Sample and the University of British Columbia 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it provided that this copyright/license information is retained 9 | * in original form. 10 | * 11 | * If you modify this file, you must clearly indicate your changes. 12 | * 13 | * This source code is distributed in the hope that it will be 14 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 15 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * 17 | * $Header: /usr/app/odstb/CVS/snacc/c-lib/inc/asn-real.h,v 1.2 1995/07/24 21:01:18 rj Exp $ 18 | * $Log: asn-real.h,v $ 19 | * Revision 1.2 1995/07/24 21:01:18 rj 20 | * changed `_' to `-' in file names. 21 | * 22 | * Revision 1.1 1994/08/28 09:21:35 rj 23 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 24 | * 25 | */ 26 | 27 | 28 | #ifndef _asn_real_h_ 29 | #define _asn_real_h_ 30 | 31 | typedef double AsnReal; 32 | 33 | extern AsnReal PLUS_INFINITY; 34 | extern AsnReal MINUS_INFINITY; 35 | 36 | 37 | void InitAsnInfinity PROTO((void)); 38 | 39 | AsnLen BEncAsnReal PROTO ((BUF_TYPE b, AsnReal *data)); 40 | 41 | void BDecAsnReal PROTO ((BUF_TYPE b, AsnReal *result, AsnLen *bytesDecoded, ENV_TYPE env)); 42 | 43 | AsnLen BEncAsnRealContent PROTO ((BUF_TYPE b, AsnReal *data)); 44 | 45 | void BDecAsnRealContent PROTO ((BUF_TYPE b, AsnTag tag, AsnLen len, AsnReal *result, AsnLen *bytesDecoded, ENV_TYPE env)); 46 | 47 | /* do nothing */ 48 | #define FreeAsnReal( v) 49 | 50 | void PrintAsnReal PROTO ((FILE *f, AsnReal *b, unsigned short int indent)); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /c++-lib/src/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | AUTOMAKE_OPTIONS = 1.4 foreign 4 | 5 | # This Makefile is never actually run - it exists to generate a 6 | # template Makefile.in that configure modifies into Makefiles for the 7 | # c++ and tcl build directories: 8 | 9 | lib_LTLIBRARIES = libasn1cxxtcl.la 10 | BUILT_SOURCES = asn-useful.C asn-useful.h 11 | libasn1cxxtcl_la_SOURCES = asn-any.C asn-bits.C asn-bool.C asn-enum.C \ 12 | asn-int.C asn-len.C asn-list.C asn-null.C asn-octs.C asn-oid.C \ 13 | asn-real.C asn-tag.C asn-type.C hash.C meta.C print.C \ 14 | tcl-if.C str-stk.C tkAppInit.c $(BUILT_SOURCES) 15 | cxxpkgincludedir = $(pkgincludedir)/c++ 16 | cxxpkginclude_HEADERS = asn-useful.h 17 | AM_CPPFLAGS = -I$(top_srcdir)/c++-lib/inc $(BUFFLAGS) 18 | 19 | ASN1_SRC_DIR = $(top_srcdir)/asn1specs 20 | COMPILERDIR = $(top_srcdir)/compiler/core 21 | SNACC = $(COMPILERDIR)/snacc 22 | USEFUL_TYPES = $(ASN1_SRC_DIR)/asn-useful.asn1 23 | 24 | # dependency to get the built sources made: 25 | # NB: meta.lo was chosen because it is the first object referenced 26 | # by libasn1cxxtcl_la_SOURCES that requires the built sources. 27 | meta.lo: $(BUILT_SOURCES) 28 | 29 | # target to make asn-useful.h and asn-useful.C: 30 | $(BUILT_SOURCES): $(SNACC) $(USEFUL_TYPES) 31 | if test "x$(BUFFLAGS)" = x-DTCL; then \ 32 | $(SNACC) -C @SNACC_NOVOLAT@ -l 50 -tcl "" $(USEFUL_TYPES); \ 33 | rm modules.C; \ 34 | else \ 35 | $(SNACC) -C @SNACC_NOVOLAT@ -l 50 $(USEFUL_TYPES); \ 36 | fi 37 | 38 | # target to make remote things: 39 | $(SNACC): force 40 | cd `dirname $@` && $(MAKE) `basename $@` 41 | force: ; 42 | 43 | # target to hook the distribution: 44 | dist-hook: 45 | for built in $(BUILT_SOURCES); do rm -f $(distdir)/$build; done 46 | 47 | -------------------------------------------------------------------------------- /c-lib/inc/nibble-alloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * nibble_alloc.h - handles buffer allocation 3 | * MS 91 4 | * 5 | * Copyright (C) 1992 Michael Sample and the University of British Columbia 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it provided that this copyright/license information is retained 9 | * in original form. 10 | * 11 | * If you modify this file, you must clearly indicate your changes. 12 | * 13 | * This source code is distributed in the hope that it will be 14 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 15 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * 17 | * $Header: /usr/app/odstb/CVS/snacc/c-lib/inc/nibble-alloc.h,v 1.2 1995/07/24 21:01:22 rj Exp $ 18 | * $Log: nibble-alloc.h,v $ 19 | * Revision 1.2 1995/07/24 21:01:22 rj 20 | * changed `_' to `-' in file names. 21 | * 22 | * Revision 1.1 1994/08/28 09:21:43 rj 23 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 24 | * 25 | */ 26 | 27 | #ifndef _nibble_alloc_h_ 28 | #define _nibble_alloc_h_ 29 | 30 | typedef struct NibbleBuf 31 | { 32 | char *start; 33 | char *end; 34 | char *curr; 35 | struct NibbleBuf *next; 36 | } NibbleBuf; 37 | 38 | 39 | typedef struct NibbleMem 40 | { 41 | NibbleBuf *firstNibbleBuf; 42 | NibbleBuf *currNibbleBuf; 43 | unsigned long int incrementSize; 44 | } NibbleMem; 45 | 46 | 47 | 48 | void InitNibbleMem PROTO ((unsigned long int initialSize, unsigned long int incrementSize)); 49 | 50 | void ShutdownNibbleMem PROTO ((void)); 51 | 52 | void ServiceNibbleFault PROTO ((unsigned long int size)); 53 | 54 | void *NibbleAlloc PROTO ((unsigned long int size)); 55 | 56 | void ResetNibbleMem PROTO ((void)); 57 | 58 | 59 | #endif /* conditional include */ 60 | -------------------------------------------------------------------------------- /compiler/core/lib-types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/core/lib_types.h 3 | * 4 | * Copyright (C) 1991, 1992 Michael Sample 5 | * and the University of British Columbia 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * $Header: /usr/app/odstb/CVS/snacc/compiler/core/lib-types.h,v 1.3 1995/07/25 19:41:34 rj Exp $ 13 | * $Log: lib-types.h,v $ 14 | * Revision 1.3 1995/07/25 19:41:34 rj 15 | * changed `_' to `-' in file names. 16 | * 17 | * Revision 1.2 1994/10/08 03:48:46 rj 18 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 19 | * 20 | * Revision 1.1 1994/08/28 09:49:15 rj 21 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 22 | * 23 | */ 24 | 25 | 26 | typedef struct LibType 27 | { 28 | enum BasicTypeChoiceId typeId; 29 | BER_UNIV_CODE univTagCode; 30 | BER_FORM tagForm; 31 | AnyRefList *anyRefs; /* these may be filled in do_macros.c*/ 32 | } LibType; 33 | 34 | 35 | extern LibType libTypesG[]; 36 | 37 | #define LIBTYPE_GET_UNIV_TAG_CODE( tId) (libTypesG[tId].univTagCode) 38 | #define LIBTYPE_GET_TAG_FORM( tId) (libTypesG[tId].tagForm) 39 | #define LIBTYPE_GET_ANY_REFS( tId) (libTypesG[tId].anyRefs) 40 | #define LIBTYPE_GET_ANY_REFS_HNDL( tId) (&libTypesG[tId].anyRefs) 41 | #define LIBTYPE_GET_ANY_REFS( tId) (libTypesG[tId].anyRefs) 42 | -------------------------------------------------------------------------------- /c-lib/inc/tbl-util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * tbl-util.h - type table utilities. 3 | * 4 | * 5 | * Mike Sample 6 | * 7 | * Copyright (C) 1993 Michael Sample 8 | * and the University of British Columbia 9 | * 10 | * This library is free software; you can redistribute it and/or 11 | * modify it provided that this copyright/license information is retained 12 | * in original form. 13 | * 14 | * If you modify this file, you must clearly indicate your changes. 15 | * 16 | * This source code is distributed in the hope that it will be 17 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 18 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 19 | * 20 | * $Header: /usr/app/odstb/CVS/snacc/c-lib/inc/tbl-util.h,v 1.1 1995/07/27 08:55:59 rj Exp $ 21 | * $Log: tbl-util.h,v $ 22 | * Revision 1.1 1995/07/27 08:55:59 rj 23 | * first check-in after being merged into .../c-lib/. 24 | * 25 | */ 26 | 27 | /* 28 | * these rely on the TBLTagClass enum starting at zero 29 | * and being in the order: UNIVERSAL, APPLICATION, CONTEXT, PRIVATE 30 | */ 31 | #define TblTagClassToBer(tblClass) (tblClass << 6) 32 | #define BerTagClassToTbl(berClass) (berClass >> 6) 33 | #define TagsEquiv(asnTag, tblTag) (((tblTag)->encTag == (asnTag)) ||\ 34 | (((tblTag)->form == ANY_FORM) &&\ 35 | ((tblTag)->encTag == DECONSIFY (asnTag)))) 36 | 37 | 38 | char *LoadFile PROTO ((char *tblFileName, unsigned long int *size)); 39 | 40 | TBL *LoadTblFile PROTO ((char *tblFileName)); 41 | 42 | TBLTypeDef *TblFindTypeDef PROTO ((TBL *tbl, char *moduleName, char *typeName, TBLModule **tblModHndl)); 43 | 44 | TBLTypeDef *TblFindTypeDefInMod PROTO ((TBLModule *tbl, char *typeName)); 45 | 46 | TBLTypeDef *TblFindTypeDefByIndex PROTO ((TBL *tbl,TBLTypeDefId id)); 47 | 48 | TBLModule *TblFindModule PROTO ((TBL *tbl, char *modName)); 49 | -------------------------------------------------------------------------------- /compiler/core/exports.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/core/exports.h - 3 | * 4 | * ExportElmt list set up during parse. 5 | * (not kept in Module data struct) 6 | * 7 | * SetExports runs through type, value & macro defs and sets the 8 | * exports flag accordingly. 9 | * 10 | * the exportsParsed boolean means whether the symbol "EXPORTS" 11 | * was parsed - since if EXPORTS was parsed and the export list 12 | * is empty, NOTHING is exported, otherwise if the "EXPORTS" 13 | * symbol was not parsed (export list is empty) then EVERYTHING 14 | * is exported 15 | * 16 | * Mike Sample 17 | * 91/09/04 18 | * 19 | * Copyright (C) 1991, 1992 Michael Sample 20 | * and the University of British Columbia 21 | * 22 | * This program is free software; you can redistribute it and/or modify 23 | * it under the terms of the GNU General Public License as published by 24 | * the Free Software Foundation; either version 2 of the License, or 25 | * (at your option) any later version. 26 | * 27 | * $Header: /usr/app/odstb/CVS/snacc/compiler/core/exports.h,v 1.2 1994/10/08 03:48:43 rj Exp $ 28 | * $Log: exports.h,v $ 29 | * Revision 1.2 1994/10/08 03:48:43 rj 30 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 31 | * 32 | * Revision 1.1 1994/08/28 09:49:09 rj 33 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 34 | * 35 | */ 36 | 37 | 38 | typedef struct ExportElmt 39 | { 40 | char *name; 41 | long int lineNo; 42 | struct ExportElmt *next; 43 | } ExportElmt; 44 | 45 | 46 | void SetExports PROTO ((Module *m, ExportElmt *e, int exportsParsed)); 47 | -------------------------------------------------------------------------------- /compiler/core/lex-stuff.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/core/lex_stuff.h 3 | * 4 | * Copyright (C) 1991, 1992 Michael Sample 5 | * and the University of British Columbia 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * $Header: /usr/app/odstb/CVS/snacc/compiler/core/lex-stuff.h,v 1.4 1995/07/25 19:41:31 rj Exp $ 13 | * $Log: lex-stuff.h,v $ 14 | * Revision 1.4 1995/07/25 19:41:31 rj 15 | * changed `_' to `-' in file names. 16 | * 17 | * Revision 1.3 1994/10/08 03:48:45 rj 18 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 19 | * 20 | * Revision 1.2 1994/09/01 01:16:07 rj 21 | * decide upon type of yytext thru cxx macro provided by autoconf. 22 | * 23 | * Revision 1.1 1994/08/28 09:49:13 rj 24 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 25 | * 26 | */ 27 | 28 | extern unsigned long myLineNoG; 29 | 30 | #ifdef YYTEXT_POINTER 31 | extern char *yytext; 32 | #else 33 | extern char yytext[]; 34 | #endif 35 | 36 | extern FILE *yyin; 37 | 38 | int LexBeginIntialContext(); 39 | int LexBeginMacroDefContext(); 40 | int LexBeginBraceBalContext(); 41 | int LexBeginCommentContext(); 42 | 43 | 44 | #define COUNT_NEWLINES( cumulativeTotal, nullTermStr)\ 45 | {\ 46 | int cnlStrIndex;\ 47 | for (cnlStrIndex = 0; nullTermStr[cnlStrIndex] != '\0'; cnlStrIndex++)\ 48 | if (nullTermStr[cnlStrIndex] == '\n')\ 49 | cumulativeTotal++;\ 50 | } 51 | -------------------------------------------------------------------------------- /c-lib/inc/hash.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hash.h 3 | * 4 | * Based on hashing stuff from UBC Raven Code (Terry Coatta & Don Acton) 5 | * 6 | * MS 92 7 | * Copyright (C) 1992 the University of British Columbia 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it provided that this copyright/license information is retained 11 | * in original form. 12 | * 13 | * If you modify this file, you must clearly indicate your changes. 14 | * 15 | * This source code is distributed in the hope that it will be 16 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 17 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 18 | * 19 | * $Header: /usr/app/odstb/CVS/snacc/c-lib/inc/hash.h,v 1.3 1997/02/28 13:39:49 wan Exp $ 20 | * $Log: hash.h,v $ 21 | * Revision 1.3 1997/02/28 13:39:49 wan 22 | * Modifications collected for new version 1.3: Bug fixes, tk4.2. 23 | * 24 | * Revision 1.2 1995/07/24 21:01:19 rj 25 | * changed `_' to `-' in file names. 26 | * 27 | * Revision 1.1 1994/08/28 09:21:41 rj 28 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 29 | * 30 | */ 31 | 32 | #ifndef _asn_hash_h_ 33 | #define _asn_hash_h_ 34 | 35 | #define TABLESIZE 256 36 | #define INDEXMASK 0xFF 37 | #define INDEXSHIFT 8 38 | 39 | typedef void *Table[TABLESIZE]; 40 | 41 | typedef unsigned int Hash; 42 | 43 | typedef struct HashSlot 44 | { 45 | int leaf; 46 | Hash hash; 47 | void *value; 48 | Table *table; 49 | } HashSlot; 50 | 51 | Hash MakeHash PROTO ((char *str, unsigned long int len)); 52 | 53 | Table *InitHash PROTO((void)); 54 | 55 | int Insert PROTO ((Table *table, void *element, Hash hash)); 56 | 57 | int CheckFor PROTO ((Table *table, Hash hash)); 58 | 59 | int CheckForAndReturnValue PROTO ((Table *table, Hash hash, void **value)); 60 | 61 | 62 | #endif /* conditional include */ 63 | -------------------------------------------------------------------------------- /compiler/core/define.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/core/define.h 3 | * 4 | * Copyright (C) 1991, 1992 Michael Sample 5 | * and the University of British Columbia 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * $Header: /usr/app/odstb/CVS/snacc/compiler/core/define.h,v 1.2 1994/10/08 03:48:35 rj Exp $ 13 | * $Log: define.h,v $ 14 | * Revision 1.2 1994/10/08 03:48:35 rj 15 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 16 | * 17 | * Revision 1.1 1994/08/28 09:48:59 rj 18 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 19 | * 20 | */ 21 | 22 | 23 | typedef struct DefinedObj 24 | { 25 | void *obj; 26 | struct DefinedObj *next; 27 | } DefinedObj; 28 | 29 | 30 | typedef int (*CmpObjsRoutine) PROTO ((void *obj1, void *obj2)); 31 | typedef int (*FreeObjRoutine) PROTO ((void *obj)); 32 | 33 | int StrObjCmp PROTO ((void *s1, void *s2)); 34 | 35 | int IntObjCmp PROTO ((void *s1, void *s2)); 36 | 37 | int OidObjCmp PROTO ((void *o1, void *o2)); 38 | 39 | int ObjPtrCmp PROTO ((void *s1, void *s2)); 40 | 41 | DefinedObj *NewObjList(); 42 | 43 | void DefineObj PROTO ((DefinedObj **l, void *obj)); 44 | 45 | void UndefineObj PROTO ((DefinedObj **l, void *obj, CmpObjsRoutine cmpRoutine)); 46 | 47 | int ObjIsDefined PROTO ((DefinedObj *l, void *obj, CmpObjsRoutine cmp)); 48 | 49 | void FreeDefinedObjs PROTO ((DefinedObj **l)); 50 | 51 | void FreeDefinedObjsAndContent PROTO ((DefinedObj **l)); 52 | -------------------------------------------------------------------------------- /acconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * file: acconfig.h 3 | * 4 | * $Header: /usr/app/odstb/CVS/snacc/acconfig.h,v 1.7 1997/03/03 11:58:26 wan Exp $ 5 | * $Log: acconfig.h,v $ 6 | * Revision 1.7 1997/03/03 11:58:26 wan 7 | * Final pre-delivery stuff (I hope). 8 | * 9 | * Revision 1.6 1997/02/28 13:39:34 wan 10 | * Modifications collected for new version 1.3: Bug fixes, tk4.2. 11 | * 12 | * Revision 1.5 1997/02/15 20:01:37 rj 13 | * check whether the compiler supports volatile functions (and whether abort() is volatile). 14 | * 15 | * Revision 1.4 1995/02/20 11:16:57 rj 16 | * cpp switch HAVE_VARIABLE_SIZED_AUTOMATIC_ARRAYS added. 17 | * 18 | * Revision 1.3 1995/02/13 14:46:49 rj 19 | * settings for IEEE_REAL_FMT/IEEE_REAL_LIB moved from {c_lib,c++_lib}/inc/asn_config.h to acconfig.h. 20 | * 21 | * Revision 1.2 1994/10/08 04:38:56 rj 22 | * slot for autoconf Tcl detection added. 23 | * 24 | * Revision 1.1 1994/09/01 00:51:19 rj 25 | * first check-in (new file). 26 | * 27 | */ 28 | 29 | /* 30 | * define IEEE_REAL_FMT if your system/compiler uses the native ieee double 31 | * this should improve the performance of encoding reals. 32 | * If your system has the IEEE library routines (iszero, isinf etc) 33 | * then define IEEE_REAL_LIB. If neither are defined then 34 | * frexp is used. Performance is probaby best for IEEE_REAL_FMT. 35 | * 36 | * #define IEEE_REAL_FMT 37 | * #define IEEE_REAL_LIB 38 | */ 39 | /* use ANSI or K&R style C? */ 40 | #undef __USE_ANSI_C__ 41 | 42 | /* does the C++ compiler have the bool type built-in? */ 43 | #undef BOOL_BUILTIN 44 | 45 | /* does the C++ compiler allow variable sized automatic arryas? */ 46 | #undef HAVE_VARIABLE_SIZED_AUTOMATIC_ARRAYS 47 | 48 | /* do we have all the libs we need for the Tcl interface? */ 49 | #undef HAVE_TCL 50 | 51 | /* does the compiler support volatile functions (and is abort() volatile?) */ 52 | #undef COMPILER_WITHOUT_VOLATILE_FUNCTIONS 53 | -------------------------------------------------------------------------------- /doc/modifying.tex: -------------------------------------------------------------------------------- 1 | % file: .../doc/modifying.tex 2 | 3 | % $Header: /usr/app/odstb/CVS/snacc/doc/modifying.tex,v 1.1 1997/01/01 22:47:44 rj Exp $ 4 | % $Log: modifying.tex,v $ 5 | % Revision 1.1 1997/01/01 22:47:44 rj 6 | % first check-in 7 | % 8 | 9 | \chapter{\label{modifying-chapter}Modifying the Compiler} 10 | 11 | The compiler consists of about 30,000 lines of yacc, lex and C code 12 | (another 7,000+ for the runtime library routines). The best way to 13 | understand the compiler internals is to understand the module data 14 | structure ({\ufn \dots/compiler/core/asn1module.h}) and to read the compiler 15 | chapter in this document to gain a conceptual understanding of each 16 | pass of the compiler. 17 | 18 | The most common form of modification will likely be for macro 19 | handling. To understand this, look at the way the OBJECT-TYPE macro is 20 | treated in: 21 | \begin{description} 22 | \item[lex-asn1.l] {add any new keywords} 23 | \item[parse-asn1.y] { parse the macro into the desired data structure. 24 | Use the existing productions as much as possible.} 25 | \item[link-type.c] { link any type defined or referenced in the 26 | macro} 27 | \item[link-values.c] { link any value defined or referenced in the 28 | macro} 29 | \item[do-macros.c] { perform any semantic action for the macro } 30 | 31 | \item[normalize.c] { move any type and value definitions in the macro 32 | to the top level so the code generator can generate code for them 33 | (without looking in the macro).} 34 | 35 | \item[code generators] { to convert any special semantics into useful 36 | C or C++. This phase is likely to be dependent on the generated 37 | code's target environment.} 38 | \end{description} 39 | 40 | In general I have tried to put comments where funky things happen and 41 | to use function and variable names that are meaningful. However, 42 | things may get ugly in certain places. Thesis writing is harmful to 43 | your coding style! 44 | -------------------------------------------------------------------------------- /compiler/core/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | AUTOMAKE_OPTIONS = 1.3 foreign 4 | 5 | noinst_PROGRAMS = snaccC 6 | bin_PROGRAMS = snacc 7 | SNACC_UNBUILT = parse-asn1.y lex-asn1.l \ 8 | asn1module.h define.h dependency.h do-macros.h err-chk.h \ 9 | exports.h gen-tbls.h lex-stuff.h lib-types.h link-types.h \ 10 | link-values.h mem.h meta.h normalize.h oid.h parser.h \ 11 | print.h recursive.h snacc-util.h val-parser.h \ 12 | define.c dependency.c do-macros.c err-chk.c exports.c \ 13 | gen-tbls.c lib-types.c link-types.c link-values.c mem.c \ 14 | meta.c normalize.c oid.c print.c recursive.c snacc.c \ 15 | snacc-util.c val-parser.c 16 | SNACC_BUILT = tbl.h tbl.c 17 | snacc_SOURCES = $(SNACC_UNBUILT) $(SNACC_BUILT) 18 | snaccC_SOURCES = $(SNACC_UNBUILT) tbl-boot.h tbl-boot.c 19 | YFLAGS = -d 20 | BACKEND_DIR = $(top_srcdir)/compiler/back-ends 21 | ASN1_SRC_DIR = $(top_srcdir)/asn1specs 22 | ASN1_LIB_DIR = $(top_srcdir)/c-lib 23 | ASN1_INC_DIR = $(ASN1_LIB_DIR)/inc 24 | ASN1_BOOT_DIR = $(ASN1_LIB_DIR)/boot 25 | USEFUL_TYPES = $(ASN1_SRC_DIR)/asn-useful.asn1 26 | snacc_DEPENDENCIES = ../back-ends/LIBOBJ $(ASN1_LIB_DIR)/Cebuf/libasn1cCebuf.la 27 | snacc_LDADD = `cat ../back-ends/LIBOBJ` $(ASN1_LIB_DIR)/Cebuf/libasn1cCebuf.la @LEXLIB@ 28 | snaccC_DEPENDENCIES = $(snacc_DEPENDENCIES) 29 | snaccC_LDADD = $(snacc_LDADD) 30 | AM_CPPFLAGS = -DCOMPILER -DUSE_NIBBLE_MEMORY=0 -DUSE_EXP_BUF \ 31 | -I$(ASN1_INC_DIR) -I$(ASN1_BOOT_DIR) -I$(BACKEND_DIR) 32 | CLEANFILES = $(SNACC_BUILT) 33 | EXTRA_DIST = parse-asn1.h 34 | 35 | # target to make tbl.h and tbl.c: 36 | $(SNACC_BUILT): snaccC $(USEFUL_TYPES) $(ASN1_SRC_DIR)/tbl.asn1 37 | ./snaccC -c -t -e -u $(USEFUL_TYPES) $(ASN1_SRC_DIR)/tbl.asn1 38 | 39 | # target to make remote things: 40 | $(snacc_DEPENDENCIES): force 41 | cd `dirname $@` && $(MAKE) `basename $@` 42 | force: ; 43 | 44 | # target to capture the distribution: 45 | dist-hook: 46 | cd $(distdir) && rm -f $(SNACC_BUILT) -------------------------------------------------------------------------------- /c-lib/inc/asn-octs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * asn_octs.h 3 | * 4 | * MS 92 5 | * Copyright (C) 1992 Michael Sample and the University of British Columbia 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it provided that this copyright/license information is retained 9 | * in original form. 10 | * 11 | * If you modify this file, you must clearly indicate your changes. 12 | * 13 | * This source code is distributed in the hope that it will be 14 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 15 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * 17 | * $Header: /usr/app/odstb/CVS/snacc/c-lib/inc/asn-octs.h,v 1.3 1995/07/24 21:01:17 rj Exp $ 18 | * $Log: asn-octs.h,v $ 19 | * Revision 1.3 1995/07/24 21:01:17 rj 20 | * changed `_' to `-' in file names. 21 | * 22 | * Revision 1.2 1994/12/11 21:49:38 rj 23 | * argument order of BDecAsnOctsContent() fixed. 24 | * 25 | * Revision 1.1 1994/08/28 09:21:32 rj 26 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 27 | * 28 | */ 29 | 30 | 31 | #ifndef _asn_octs_h_ 32 | #define _asn_octs_h_ 33 | 34 | typedef struct AsnOcts 35 | { 36 | unsigned long int octetLen; 37 | char *octs; 38 | } AsnOcts; 39 | 40 | #define ASNOCTS_PRESENT( aocts) ((aocts)->octs != NULL) 41 | 42 | 43 | 44 | AsnLen BEncAsnOcts PROTO ((BUF_TYPE b, AsnOcts *data)); 45 | 46 | void BDecAsnOcts PROTO ((BUF_TYPE b, AsnOcts *result, AsnLen *bytesDecoded, ENV_TYPE env)); 47 | 48 | AsnLen BEncAsnOctsContent PROTO ((BUF_TYPE b, AsnOcts *octs)); 49 | 50 | void BDecAsnOctsContent PROTO ((BUF_TYPE b, AsnTag tagId, AsnLen len, AsnOcts *result, AsnLen *bytesDecoded, ENV_TYPE env)); 51 | 52 | void FreeAsnOcts PROTO ((AsnOcts *o)); 53 | 54 | void PrintAsnOcts PROTO ((FILE *f, AsnOcts *o, unsigned short int indent)); 55 | 56 | int AsnOctsEquiv PROTO ((AsnOcts *o1, AsnOcts *o2)); 57 | 58 | 59 | #endif /* conditional include */ 60 | -------------------------------------------------------------------------------- /compiler/back-ends/c-gen/rules.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/back-ends/c-gen/rules.h 3 | * 4 | * Copyright (C) 1991, 1992 Michael Sample 5 | * and the University of British Columbia 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * $Header: /usr/app/odstb/CVS/snacc/compiler/back-ends/c-gen/rules.h,v 1.3 1995/07/25 18:46:35 rj Exp $ 13 | * $Log: rules.h,v $ 14 | * Revision 1.3 1995/07/25 18:46:35 rj 15 | * file name has been shortened for redundant part: c-gen/c-rules -> c-gen/rules. 16 | * 17 | * Revision 1.2 1994/10/08 03:48:16 rj 18 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 19 | * 20 | * Revision 1.1 1994/08/28 09:48:36 rj 21 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 22 | * 23 | */ 24 | 25 | /* see asn1module.h for CTDI (C type def info) */ 26 | 27 | typedef struct CRules 28 | { 29 | int maxDigitsToAppend; 30 | char *choiceIdFieldName; /* name of choiceId field */ 31 | char *choiceIdEnumSuffix; /* suffix for choiceId enum def name */ 32 | char *choiceUnionFieldName; /* what the name of the choice's union is */ 33 | char *choiceUnionDefSuffix; /* suffix for choice union def name */ 34 | int capitalizeNamedElmts; 35 | char *printRoutineBaseName; /* eg if "Print" -> PrintFoo (..) */ 36 | char *encodeRoutineBaseName; 37 | char *decodeRoutineBaseName; 38 | char *freeRoutineBaseName; 39 | CTDI typeConvTbl[BASICTYPE_MACRODEF + 1]; 40 | } CRules; 41 | 42 | extern CRules cRulesG; 43 | -------------------------------------------------------------------------------- /tbl-tools/ptbl/ptbl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * file: .../tbl-tools/ptbl/ptbl.c - given a type table generated by snacc (-T option) 3 | * ptbl prints the contents of the table to stdout. 4 | * 5 | * This may be useful for debugging. 6 | * 7 | * Copyright (C) 1993 Michael Sample 8 | * and the University of British Columbia 9 | * 10 | * $Header: /usr/app/odstb/CVS/snacc/tbl-tools/ptbl/ptbl.c,v 1.1 1997/02/15 19:26:23 rj Exp $ 11 | * $Log: ptbl.c,v $ 12 | * Revision 1.1 1997/02/15 19:26:23 rj 13 | * first check-in 14 | * 15 | */ 16 | 17 | #include "tbl-incl.h" 18 | #include "tbl-gen-c-hdr.h" 19 | 20 | void Usage PARAMS ((prg), 21 | char *prg) 22 | { 23 | fprintf (stderr,"Usage: %s [-a] \n",prg); 24 | fprintf (stderr," -a means print in ASN.1 format instead of the table data structure\n\n"); 25 | fprintf (stderr," ptbl reads the type table from tbl-file and prints"); 26 | fprintf (stderr," its contents\n to stdout."); 27 | fprintf (stderr," The table files are generated with the snacc -T option.\n"); 28 | } 29 | 30 | int 31 | main PARAMS ((argc, argv), 32 | int argc _AND_ 33 | char **argv) 34 | { 35 | char *tblFileName; 36 | FILE *outputFile; 37 | int asn1Mode = FALSE; 38 | TBL *tbl; 39 | 40 | if ((argc != 2) && (argc != 3)) 41 | { 42 | Usage (argv[0]); 43 | return 1; 44 | } 45 | 46 | /* danger - no error checking here */ 47 | if (argc == 2) 48 | tblFileName = argv[1]; 49 | else 50 | { 51 | asn1Mode = TRUE; 52 | tblFileName = argv[2]; 53 | } 54 | 55 | outputFile = stdout; 56 | 57 | InitNibbleMem (1024,1024); 58 | 59 | tbl = LoadTblFile (tblFileName); 60 | 61 | if (tbl == NULL) 62 | return 1; /* Load routine will have printed errs */ 63 | 64 | if (asn1Mode) 65 | PrintTblInAsn1 (outputFile, tbl); 66 | else 67 | PrintTBL (outputFile, tbl, 0); 68 | 69 | return 0; 70 | } /* main */ 71 | -------------------------------------------------------------------------------- /c-lib/src/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | AUTOMAKE_OPTIONS = 1.4 foreign 4 | 5 | # This Makefile is never actually run - it exists to generate a 6 | # template Makefile.in that configure modifies into Makefiles for the 7 | # buffer-type build directories: 8 | 9 | lib_LTLIBRARIES = libasn1cbuf.la 10 | BUILT_SOURCES = asn-useful.c asn-useful.h tbl.h tbl.c 11 | libasn1cbuf_la_SOURCES = asn-any.c asn-len.c asn-real.c print.c tbl-enc.c \ 12 | asn-bits.c asn-list.c asn-tag.c tbl-free.c \ 13 | asn-bool.c asn-null.c exp-buf.c str-stk.c tbl-gen.c \ 14 | asn-enum.c asn-octs.c hash.c tbl-dbg.c tbl-print.c \ 15 | asn-int.c asn-oid.c sbuf.c nibble-alloc.c tbl-dec.c tbl-util.c $(BUILT_SOURCES) 16 | cpkgincludedir = $(pkgincludedir)/c 17 | cpkginclude_HEADERS = asn-useful.h tbl.h 18 | AM_CPPFLAGS = -I$(top_srcdir)/c-lib/inc $(BUFFLAGS) 19 | 20 | COMPILERDIR = $(top_srcdir)/compiler 21 | SNACC = $(COMPILERDIR)/core/snacc 22 | ASN1_SRC_DIR = $(top_srcdir)/asn1specs 23 | USEFUL_TYPES = $(ASN1_SRC_DIR)/asn-useful.asn1 24 | 25 | # dependency to get the built sources made: 26 | # NB: tbl-enc.lo was chosen because it is the first object referenced 27 | # by libasn1cbuf_la_SOURCES that requires the built sources. 28 | tbl-enc.lo: $(BUILT_SOURCES) 29 | 30 | # target to make asn-useful.c and asn-useful.h: 31 | asn-useful.h asn-useful.c: $(SNACC) $(USEFUL_TYPES) 32 | $(SNACC) -c -l 50 $(USEFUL_TYPES) 33 | 34 | # target to make tbl.c and tbl.h: 35 | tbl.h tbl.c: $(SNACC) $(USEFUL_TYPES) $(ASN1_SRC_DIR)/tbl.asn1 36 | $(SNACC) -u $(USEFUL_TYPES) $(ASN1_SRC_DIR)/tbl.asn1 37 | @PATCH@ < $(top_srcdir)/c-lib/tbl.h.patch 38 | echo '#if TTBL' > tbl.c.tmp 39 | cat tbl.c >> tbl.c.tmp 40 | echo '#endif /* TTBL */' >> tbl.c.tmp 41 | mv tbl.c.tmp tbl.c 42 | 43 | # target to make remote things: 44 | $(SNACC): force 45 | cd `dirname $@` && $(MAKE) `basename $@` 46 | force: ; 47 | 48 | # target to hook the distribution: 49 | dist-hook: 50 | cd $(distdir) && rm -rf $(BUILT_SOURCES) 51 | -------------------------------------------------------------------------------- /compiler/back-ends/c-gen/util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/back-ends/c-gen/util.c - C encoder/decode related utility routines 3 | * 4 | * MS 91/11/04 5 | * 6 | * Copyright (C) 1992 Michael Sample and the University of British Columbia 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * $Header: /usr/app/odstb/CVS/snacc/compiler/back-ends/c-gen/util.h,v 1.3 1995/07/25 18:48:39 rj Exp $ 14 | * $Log: util.h,v $ 15 | * Revision 1.3 1995/07/25 18:48:39 rj 16 | * changed `_' to `-' in file names. 17 | * 18 | * Revision 1.2 1994/10/08 03:48:21 rj 19 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 20 | * 21 | * Revision 1.1 1994/08/28 09:48:45 rj 22 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 23 | * 24 | */ 25 | 26 | 27 | #define FIRST_LEVEL 1 /* must be 1 or greater */ 28 | #define MAX_VAR_REF 512 /* max chars for ref'ing a var eg v->foo->bar.x->v*/ 29 | 30 | void MakeVarPtrRef PROTO ((CRules *r, TypeDef *td, Type *parent, Type *fieldType, char *parentVarName, char *newVarName)); 31 | 32 | void MakeVarValueRef PROTO ((CRules *r, TypeDef *td, Type *parent, Type *fieldType, char *parentVarName, char *newVarName)); 33 | 34 | void MakeChoiceIdValueRef PROTO ((CRules *r, TypeDef *td, Type *parent, Type *fieldType, char *parentVarName, char *newVarName)); 35 | 36 | void PrintElmtAllocCode PROTO ((FILE *f, Type *type, char *varPtrRefName)); 37 | 38 | void PrintEocDecoders PROTO ((FILE *f, int maxLenLevel, int minLenLevel, char *lenBaseVarName, int totalLevel, char *totalBaseVarName)); 39 | -------------------------------------------------------------------------------- /compiler/back-ends/c++-gen/rules.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/back_ends/c++_gen/rules.h 3 | * 4 | * Copyright (C) 1991, 1992 Michael Sample 5 | * and the University of British Columbia 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * $Header: /usr/app/odstb/CVS/snacc/compiler/back-ends/c++-gen/rules.h,v 1.3 1995/07/25 18:24:21 rj Exp $ 13 | * $Log: rules.h,v $ 14 | * Revision 1.3 1995/07/25 18:24:21 rj 15 | * file name has been shortened for redundant part: c++-gen/c++-rules -> c++-gen/rules. 16 | * 17 | * Revision 1.2 1994/10/08 03:47:50 rj 18 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 19 | * 20 | * Revision 1.1 1994/08/28 09:47:55 rj 21 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 22 | * 23 | */ 24 | 25 | /* see asn1module.h for CxxTDI (C++ type def info) */ 26 | 27 | typedef struct CxxRules 28 | { 29 | int maxDigitsToAppend; 30 | char *choiceIdFieldName; /* name of choiceId field */ 31 | char *choiceIdEnumName; /* name (tag) for choiceId enum def name */ 32 | char *choiceUnionFieldName; /* what the name of the choice's union is */ 33 | char *choiceUnionName; /* name (tag) for choice union def name */ 34 | int capitalizeNamedElmts; 35 | char *encodeBaseName; 36 | char *decodeBaseName; 37 | char *encodeContentBaseName; 38 | char *decodeContentBaseName; 39 | char *encodePduBaseName; 40 | char *decodePduBaseName; 41 | CxxTDI typeConvTbl[BASICTYPE_MACRODEF + 1]; 42 | } CxxRules; 43 | 44 | extern CxxRules cxxRulesG; 45 | -------------------------------------------------------------------------------- /c++-lib/inc/print.h: -------------------------------------------------------------------------------- 1 | // file: .../c++-lib/inc/print.h 2 | // 3 | // MS 92 4 | // 5 | // Copyright (C) 1992 Michael Sample and the University of British Columbia 6 | // 7 | // This library is free software; you can redistribute it and/or 8 | // modify it provided that this copyright/license information is retained 9 | // in original form. 10 | // 11 | // If you modify this file, you must clearly indicate your changes. 12 | // 13 | // This source code is distributed in the hope that it will be 14 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 15 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | // 17 | // $Header: /usr/app/odstb/CVS/snacc/c++-lib/inc/print.h,v 1.4 1997/02/16 20:25:54 rj Exp $ 18 | // $Log: print.h,v $ 19 | // Revision 1.4 1997/02/16 20:25:54 rj 20 | // check-in of a few cosmetic changes 21 | // 22 | // Revision 1.3 1994/10/08 04:18:13 rj 23 | // code for meta structures added (provides information about the generated code itself). 24 | // 25 | // code for Tcl interface added (makes use of the above mentioned meta code). 26 | // 27 | // virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. 28 | // 29 | // made Print() const (and some other, mainly comparison functions). 30 | // 31 | // several `unsigned long int' turned into `size_t'. 32 | // 33 | // Revision 1.2 1994/08/28 10:01:00 rj 34 | // comment leader fixed. 35 | // 36 | // Revision 1.1 1994/08/28 09:20:47 rj 37 | // first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 38 | 39 | #ifndef _snacccpp_print_h_ 40 | #define _snacccpp_print_h_ 41 | 42 | extern unsigned short int indentG; 43 | extern unsigned short int stdIndentG; 44 | 45 | void Indent (std::ostream &os, unsigned short int i); 46 | 47 | std::ostream &operator << (std::ostream &os, const AsnType &a); 48 | 49 | #endif /* conditional include */ 50 | -------------------------------------------------------------------------------- /tbl-example/makefile: -------------------------------------------------------------------------------- 1 | # file: .../tbl-example/makefile 2 | # 3 | # $Header: /usr/app/odstb/CVS/snacc/tbl-example/makefile,v 1.1 1997/02/15 19:33:26 rj Exp $ 4 | # $Log: makefile,v $ 5 | # Revision 1.1 1997/02/15 19:33:26 rj 6 | # first check-in 7 | # 8 | 9 | #include ../../makehead 10 | 11 | TOP = /usr 12 | 13 | ASN1_SRC_DIR = $(TOP)/include/snacc/asn1 14 | 15 | ASN1_C_LIB_DIR = $(TOP)/lib 16 | ASN1_C_INC_DIR = $(TOP)/include/snacc/c 17 | TTBL_ASN1_LIB = $(ASN1_C_LIB_DIR)/libasn1ctbl.a 18 | 19 | COMPILERDIR = $(TOP)/bin 20 | SNACC = $(COMPILERDIR)/snacc 21 | USEFUL_TYPES = $(ASN1_SRC_DIR)/asn-useful.asn1 22 | SNACCFLAGS = -u $(USEFUL_TYPES) 23 | 24 | TBLTOOLSDIR = $(TOP)/bin 25 | MKHDR = $(TBLTOOLSDIR)/mkchdr 26 | 27 | ASN1FILES = $(ASN1_SRC_DIR)/p-rec.asn1 28 | ASN1TTFILE = p-rec.tt 29 | ASN1TTHFILE = p-rec.h 30 | 31 | CFILES = example.c 32 | OFILES = example.o 33 | 34 | DISTFILES = \ 35 | README \ 36 | makefile \ 37 | $(CFILES) \ 38 | p-rec.ber 39 | 40 | CPPFLAGS += -g -I$(TOP) -I$(ASN1_C_INC_DIR) -DUSE_GEN_BUF 41 | LIBS += -lm 42 | 43 | #------------------------------------------------------------------------------- 44 | 45 | all:: depend example 46 | 47 | example: $(OFILES) $(TTBL_ASN1_LIB) 48 | $(REASON) 49 | $(CC) $(CFLAGS) -o example $(OFILES) $(TTBL_ASN1_LIB) $(LIBS) 50 | 51 | $(ASN1TTFILE): $(ASN1FILES) 52 | $(REASON) 53 | $(SNACC) $(SNACCFLAGS) -T $@ $(ASN1FILES) 54 | 55 | $(SNACC) $(MKHDR): 56 | cd $(@D) && $(MAKE) $(@F) 57 | 58 | $(TTBL_ASN1_LIB): 59 | cd $(@D) && $(MAKE) tbl-lib 60 | 61 | $(ASN1TTHFILE): $(ASN1TTFILE) 62 | $(REASON) 63 | $(MKHDR) $? $@ 64 | 65 | check:: depend example $(ASN1TTFILE) 66 | 67 | check:: 68 | uudecode -o p-rec.ber p-rec.ber.uu 69 | ./example p-rec.tt p-rec.ber 70 | cmp p-rec.ber p-rec.out.ber 71 | @echo "+++ the test was successful" 72 | 73 | # dummy: 74 | install:: 75 | 76 | clean:: 77 | $(RM) example *.o *~ core .emacs* $(ASN1TTFILE) $(ASN1TTHFILE) p-rec.out.ber p-rec.ber 78 | 79 | depend:: 80 | $(MAKE) $(MKHDR) 81 | 82 | depend:: $(ASN1TTHFILE) 83 | 84 | #include ../maketail 85 | -------------------------------------------------------------------------------- /compiler/back-ends/c++-gen/gen-code.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/back_ends/c++_gen/gen_code.h 3 | * 4 | * Copyright (C) 1991, 1992 Michael Sample 5 | * and the University of British Columbia 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * $Header: /usr/app/odstb/CVS/snacc/compiler/back-ends/c++-gen/gen-code.h,v 1.6 1997/02/16 15:14:10 rj Exp $ 13 | * $Log: gen-code.h,v $ 14 | * Revision 1.6 1997/02/16 15:14:10 rj 15 | * made return *this after calling abort()'' a compile time option. 16 | * 17 | * Revision 1.5 1995/09/07 19:18:25 rj 18 | * boolean genMeta changed to enum type MetaNameStyle 19 | * 20 | * Revision 1.4 1995/08/17 15:00:08 rj 21 | * the PDU flag belongs to the metacode, not only to the tcl interface. (type and variable named adjusted) 22 | * 23 | * Revision 1.3 1995/07/27 10:53:03 rj 24 | * file name has been shortened for redundant part: c++-gen/gen-c++-code -> c++-gen/gen-code. 25 | * 26 | * changed `_' to `-' in file names. 27 | * 28 | * Revision 1.2 1994/10/08 03:47:55 rj 29 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 30 | * 31 | * Revision 1.1 1994/08/28 09:48:04 rj 32 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 33 | * 34 | */ 35 | 36 | void PrintCxxCode PROTO ((FILE *src, FILE *hdr, if_IBM_ENC (FILE *dbsrc COMMA FILE *dbhdr COMMA) if_META (MetaNameStyle genMeta COMMA const Meta *meta COMMA MetaPDU *metapdus COMMA) ModuleList *mods, Module *m, CxxRules *r, long int longJmpVal, int printTypes, int printValues, int printEncoders, int printDecoders, int printPrinters, int printFree, if_TCL (int printTcl COMMA) int novolatilefuncs)); 37 | -------------------------------------------------------------------------------- /doc/ptbl.1: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1993 by Mike Sample and UBC 2 | .\" See section COPYING for conditions for redistribution 3 | .\" $Header: /usr/app/odstb/CVS/snacc/doc/ptbl.1,v 1.2 1997/01/01 22:47:19 rj Exp $ 4 | .\" $Log: ptbl.1,v $ 5 | .\" Revision 1.2 1997/01/01 22:47:19 rj 6 | .\" first check-in 7 | .\" 8 | .TH PTBL 1 "11 July 1993" 9 | .SH NAME 10 | ptbl \- print a type table 11 | .SH SYNOPSIS 12 | .nf 13 | ptbl [\-a] 14 | .SH DESCRIPTION 15 | 16 | ptbl prints the give type table to stdout. It will print it in one of 17 | two formats: internal style and ASN.1 stlye. The internal style shows 18 | the contents of the type table data structure in ASN.1 value notation. 19 | You will need to look at the tbl.asn1 file to understand the internal 20 | form. The ASN.1 form attempts to re-create the ASN.1 that generated 21 | the given type table. 22 | 23 | .SH OPTIONS 24 | 25 | .TP 26 | .B \-a 27 | Print the table in ASN.1 style (recommended) 28 | .PP 29 | .\" there is a tab between the file name and the description 30 | .SH FILES 31 | .PD 0 32 | .TP 28 33 | .B snacc/tbl-tools/ptbl/ 34 | Source code for the ptbl program 35 | .B snacc/asn1specs/tbl.asn1 36 | ASN.1 definition for the type table data structure 37 | .PD 38 | .SH BUGS 39 | ptbl does not attempt to print the IMPORTs information even though it 40 | is possible with a bit of work. 41 | .SH COPYING 42 | Copyright (c) 1993 Mike Sample and the University of British Columbia 43 | .PP 44 | Permission is granted to make and distribute verbatim copies of 45 | this manual provided the copyright notice and this permission notice 46 | are preserved on all copies. 47 | .PP 48 | Permission is granted to copy and distribute modified versions of this 49 | manual under the conditions for verbatim copying, provided that the 50 | entire resulting derived work is distributed under the terms of a 51 | permission notice identical to this one. 52 | .PP 53 | .SH AUTHOR 54 | Mike Sample , University of British Columbia 55 | .SH ACKNOWLEDGEMENTS 56 | This work was made possible by grants from the Canadian Institute for 57 | Telecommunications Research (CITR) and Natural Sciences and 58 | Engineering Research Council of Canada (NSERC). 59 | -------------------------------------------------------------------------------- /tbl-tools/mkchdr/mkchdr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * file: .../tbl-tools/mkchdr/mkchdr.c - given a type table generated 3 | * by snacc (-T option) mkchdr generates a .h file that contains the C 4 | * type defs for the types in the given table. 5 | * 6 | * NOTE: these C typedefs are as the table decoder/encoder will 7 | * return/expect. They are DIFFERENT from the ones usually 8 | * generated by snacc's C backend 9 | * 10 | * 11 | * Mike Sample 12 | * 13 | * Copyright (C) 1993 Michael Sample 14 | * and the University of British Columbia 15 | * 16 | * $Header: /usr/app/odstb/CVS/snacc/tbl-tools/mkchdr/mkchdr.c,v 1.1 1997/02/15 19:05:30 rj Exp $ 17 | * $Log: mkchdr.c,v $ 18 | * Revision 1.1 1997/02/15 19:05:30 rj 19 | * first check-in 20 | * 21 | */ 22 | 23 | #include "tbl-incl.h" 24 | #include "tbl-gen-c-hdr.h" 25 | 26 | void Usage PARAMS ((prg), 27 | char *prg) 28 | { 29 | fprintf (stderr,"Usage: %s [output-file]\n\n",prg); 30 | fprintf (stderr,"Reads the type table from tbl-file and writes\n"); 31 | fprintf (stderr,"the equivalent C typedefs to output-file.\n"); 32 | fprintf (stderr,"If no output-file is given, stdout is used.\n\n"); 33 | fprintf (stderr,"The table files are generated with the snacc -T option.\n"); 34 | } 35 | 36 | int 37 | main PARAMS ((argc, argv), 38 | int argc _AND_ 39 | char **argv) 40 | { 41 | char *tblFileName; 42 | FILE *outputFile; 43 | TBL *tbl; 44 | 45 | if (argc < 2) 46 | { 47 | Usage (argv[0]); 48 | return 1; 49 | } 50 | 51 | tblFileName = argv[1]; 52 | 53 | if (argc == 3) 54 | { 55 | /* open output file */ 56 | outputFile = fopen (argv[2], "w"); 57 | if (outputFile == NULL) 58 | { 59 | perror ("fopen: "); 60 | return 1; 61 | } 62 | } 63 | else /* use stdout */ 64 | outputFile = stdout; 65 | 66 | InitNibbleMem (1024,1024); 67 | 68 | 69 | tbl = LoadTblFile (tblFileName); 70 | 71 | if (tbl == NULL) 72 | return 1; /* Load routine will have printed errs */ 73 | 74 | TblPrintCHdr (tbl, outputFile); 75 | 76 | return 0; 77 | } /* main */ 78 | -------------------------------------------------------------------------------- /c++-lib/src/print.C: -------------------------------------------------------------------------------- 1 | // file: .../c++-lib/src/print.C 2 | // 3 | // MS 92 4 | // Copyright (C) 1992 Michael Sample and the University of British Columbia 5 | // 6 | // This library is free software; you can redistribute it and/or 7 | // modify it provided that this copyright/license information is retained 8 | // in original form. 9 | // 10 | // If you modify this file, you must clearly indicate your changes. 11 | // 12 | // This source code is distributed in the hope that it will be 13 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 14 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | // 16 | // $Header: /usr/app/odstb/CVS/snacc/c++-lib/src/print.C,v 1.5 1997/02/16 20:26:09 rj Exp $ 17 | // $Log: print.C,v $ 18 | // Revision 1.5 1997/02/16 20:26:09 rj 19 | // check-in of a few cosmetic changes 20 | // 21 | // Revision 1.4 1995/07/24 20:34:55 rj 22 | // changed `_' to `-' in file names. 23 | // 24 | // Revision 1.3 1994/10/08 04:18:33 rj 25 | // code for meta structures added (provides information about the generated code itself). 26 | // 27 | // code for Tcl interface added (makes use of the above mentioned meta code). 28 | // 29 | // virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. 30 | // 31 | // made Print() const (and some other, mainly comparison functions). 32 | // 33 | // several `unsigned long int' turned into `size_t'. 34 | // 35 | // Revision 1.2 1994/08/28 10:01:22 rj 36 | // comment leader fixed. 37 | // 38 | // Revision 1.1 1994/08/28 09:21:12 rj 39 | // first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 40 | 41 | #include "asn-incl.h" 42 | 43 | // the generated operator << routines for aggregate types use these globals 44 | unsigned short int indentG = 0; 45 | unsigned short int stdIndentG = 4; 46 | 47 | void 48 | Indent (std::ostream &os, unsigned short int i) 49 | { 50 | while (i-->0) 51 | os << ' '; 52 | } 53 | 54 | std::ostream &operator << (std::ostream &os, const AsnType &v) 55 | { 56 | v.Print (os); 57 | return os; 58 | } 59 | -------------------------------------------------------------------------------- /c-lib/inc/asn-bits.h: -------------------------------------------------------------------------------- 1 | /* 2 | * asn_bits.h 3 | * 4 | * MS 92 5 | * Copyright (C) 1992 Michael Sample and the University of British Columbia 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it provided that this copyright/license information is retained 9 | * in original form. 10 | * 11 | * If you modify this file, you must clearly indicate your changes. 12 | * 13 | * This source code is distributed in the hope that it will be 14 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 15 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * 17 | * $Header: /usr/app/odstb/CVS/snacc/c-lib/inc/asn-bits.h,v 1.3 1995/07/24 21:01:09 rj Exp $ 18 | * $Log: asn-bits.h,v $ 19 | * Revision 1.3 1995/07/24 21:01:09 rj 20 | * changed `_' to `-' in file names. 21 | * 22 | * Revision 1.2 1994/12/11 21:48:28 rj 23 | * argument order of BDecAsnBitsContent() fixed. 24 | * 25 | * Revision 1.1 1994/08/28 09:21:23 rj 26 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 27 | * 28 | */ 29 | 30 | 31 | #ifndef _asn_bits_h_ 32 | #define _asn_bits_h_ 33 | 34 | 35 | typedef struct AsnBits 36 | { 37 | int bitLen; 38 | char *bits; 39 | } AsnBits; 40 | 41 | extern char numToHexCharTblG[]; 42 | 43 | #define TO_HEX( fourBits) (numToHexCharTblG[(fourBits) & 0x0f]) 44 | 45 | 46 | #define ASNBITS_PRESENT( abits) ((abits)->bits != NULL) 47 | 48 | 49 | AsnLen BEncAsnBits PROTO ((BUF_TYPE b, AsnBits *data)); 50 | 51 | void BDecAsnBits PROTO ((BUF_TYPE b, AsnBits *result, AsnLen *bytesDecoded, ENV_TYPE env)); 52 | 53 | AsnLen BEncAsnBitsContent PROTO ((BUF_TYPE b, AsnBits *bits)); 54 | 55 | void BDecAsnBitsContent PROTO ((BUF_TYPE b, AsnTag tagId, AsnLen len, AsnBits *result, AsnLen *bytesDecoded, ENV_TYPE env)); 56 | 57 | void FreeAsnBits PROTO ((AsnBits *v)); 58 | 59 | void PrintAsnBits PROTO ((FILE *f, AsnBits *b, unsigned short int indent)); 60 | 61 | int AsnBitsEquiv PROTO ((AsnBits *b1, AsnBits *b2)); 62 | 63 | void SetAsnBit PROTO ((AsnBits *b1, unsigned long int bit)); 64 | 65 | void ClrAsnBit PROTO ((AsnBits *b1, unsigned long int bit)); 66 | 67 | int GetAsnBit PROTO ((AsnBits *b1, unsigned long int bit)); 68 | 69 | #endif /* conditional include */ 70 | -------------------------------------------------------------------------------- /doc/pval.1: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1993 by Mike Sample and UBC 2 | .\" See section COPYING for conditions for redistribution 3 | .\" $Header: /usr/app/odstb/CVS/snacc/doc/pval.1,v 1.2 1997/01/01 22:47:20 rj Exp $ 4 | .\" $Log: pval.1,v $ 5 | .\" Revision 1.2 1997/01/01 22:47:20 rj 6 | .\" first check-in 7 | .\" 8 | .TH PVAL 1 "11 July 1993" 9 | .SH NAME 10 | pval \- print BER values in ASN.1 value notation 11 | .SH SYNOPSIS 12 | .nf 13 | pval \-T [\-m ] \-n 14 | 15 | .SH DESCRIPTION 16 | pval prints the given BER values in their value notation. You must 17 | specify the type name and optionally the module name of the type in 18 | the given BER files. 19 | .SH OPTIONS 20 | .TP 21 | .BI "\-T " file\c 22 | Use the type table in the file to look for the named types definition. 23 | .TP 24 | .BI "\-m " modulename\c 25 | Specifies the module in which the named type is defined. If the 26 | module name is not specified with this option, pval looks for the 27 | first occurence of the named type in the modules in the given type 28 | table. 29 | .TP 30 | .BI "\-n " typename\c 31 | Specifies the type of the values in the given BER files. If you 32 | give the wrong type name, decoding errors will occur. 33 | .PP 34 | .\" there is a tab between the file name and the description 35 | .SH FILES 36 | .PD 0 37 | .TP 28 38 | .B snacc/tbl-tools/pval/ 39 | Source code for the pval program 40 | .SH COPYING 41 | Copyright (c) 1993 Mike Sample and the University of British Columbia 42 | .PP 43 | Permission is granted to make and distribute verbatim copies of 44 | this manual provided the copyright notice and this permission notice 45 | are preserved on all copies. 46 | .PP 47 | Permission is granted to copy and distribute modified versions of this 48 | manual under the conditions for verbatim copying, provided that the 49 | entire resulting derived work is distributed under the terms of a 50 | permission notice identical to this one. 51 | .PP 52 | .SH AUTHOR 53 | Mike Sample , University of British Columbia 54 | .SH ACKNOWLEDGEMENTS 55 | This work was made possible by grants from the Canadian Institute for 56 | Telecommunications Research (CITR) and Natural Sciences and 57 | Engineering Research Council of Canada (NSERC). 58 | -------------------------------------------------------------------------------- /c-lib/inc/asn-oid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * asn_oid.h 3 | * 4 | * this file depends on asn_octs.h 5 | * MS 92 6 | * Copyright (C) 1992 Michael Sample and the University of British Columbia 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it provided that this copyright/license information is retained 10 | * in original form. 11 | * 12 | * If you modify this file, you must clearly indicate your changes. 13 | * 14 | * This source code is distributed in the hope that it will be 15 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 16 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | * 18 | * $Header: /usr/app/odstb/CVS/snacc/c-lib/inc/asn-oid.h,v 1.2 1995/07/27 10:24:00 rj Exp $ 19 | * $Log: asn-oid.h,v $ 20 | * Revision 1.2 1995/07/27 10:24:00 rj 21 | * minor change to merge with type table code. 22 | * 23 | * Revision 1.1 1994/08/28 09:21:34 rj 24 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 25 | * 26 | */ 27 | 28 | 29 | #ifndef _asn_oid_h_ 30 | #define _asn_oid_h_ 31 | 32 | #include "asn-octs.h" 33 | 34 | typedef AsnOcts AsnOid; /* standard oid type */ 35 | 36 | 37 | #define ASNOID_PRESENT( aoid) ASNOCTS_PRESENT (aoid) 38 | 39 | AsnLen BEncAsnOid PROTO ((BUF_TYPE b, AsnOid *data)); 40 | 41 | void BDecAsnOid PROTO ((BUF_TYPE b, AsnOid *result, AsnLen *bytesDecoded, ENV_TYPE env)); 42 | 43 | #define BEncAsnOidContent( b, oid) BEncAsnOctsContent (b, oid) 44 | 45 | 46 | void BDecAsnOidContent PROTO ((BUF_TYPE b, AsnTag tag, AsnLen len, AsnOid *result, AsnLen *bytesDecoded, ENV_TYPE env)); 47 | 48 | 49 | #define FreeAsnOid FreeAsnOcts 50 | 51 | void PrintAsnOid PROTO ((FILE *f, AsnOid *b, unsigned short int indent)); 52 | 53 | #define AsnOidsEquiv( o1, o2) AsnOctsEquiv (o1, o2) 54 | 55 | /* linked oid type that may be easier to use in some circumstances */ 56 | #define NULL_OID_ARCNUM -1 57 | typedef struct OID 58 | { 59 | struct OID *next; 60 | long int arcNum; 61 | #if COMPILER || TTBL 62 | struct Value *valueRef; 63 | #endif 64 | } OID; 65 | 66 | AsnLen EncodedOidLen PROTO ((OID *oid)); 67 | 68 | void BuildEncodedOid PROTO ((OID *oid, AsnOid *result)); 69 | 70 | void UnbuildEncodedOid PROTO ((AsnOid *eoid, OID **result)); 71 | 72 | #endif /* conditional include */ 73 | -------------------------------------------------------------------------------- /c++-lib/inc/asn-incl.h: -------------------------------------------------------------------------------- 1 | // file: .../c++-lib/inc/asn-incl.h - includes all of the asn1 library files 2 | // 3 | // Copyright (C) 1992 Michael Sample and the University of British Columbia 4 | // 5 | // This library is free software; you can redistribute it and/or 6 | // modify it provided that this copyright/license information is retained 7 | // in original form. 8 | // 9 | // If you modify this file, you must clearly indicate your changes. 10 | // 11 | // This source code is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | // 15 | // $Header: /usr/app/odstb/CVS/snacc/c++-lib/inc/asn-incl.h,v 1.5 1997/02/16 20:25:37 rj Exp $ 16 | // $Log: asn-incl.h,v $ 17 | // Revision 1.5 1997/02/16 20:25:37 rj 18 | // check-in of a few cosmetic changes 19 | // 20 | // Revision 1.4 1995/07/24 17:52:33 rj 21 | // changed `_' to `-' in file names. 22 | // 23 | // Revision 1.3 1994/10/08 04:18:01 rj 24 | // code for meta structures added (provides information about the generated code itself). 25 | // 26 | // code for Tcl interface added (makes use of the above mentioned meta code). 27 | // 28 | // virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. 29 | // 30 | // made Print() const (and some other, mainly comparison functions). 31 | // 32 | // several `unsigned long int' turned into `size_t'. 33 | // 34 | // Revision 1.2 1994/08/28 10:00:49 rj 35 | // comment leader fixed. 36 | // 37 | // Revision 1.1 1994/08/28 09:20:33 rj 38 | // first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 39 | 40 | #ifdef _IBM_ENC_ 41 | #define ChoiceUnion 42 | #endif /* _IBM_ENC_ */ 43 | 44 | #include "asn-config.h" 45 | #include "asn-buf.h" 46 | #include "asn-len.h" 47 | #include "asn-tag.h" 48 | #include "asn-type.h" 49 | #include "asn-int.h" 50 | #include "asn-bool.h" 51 | #include "asn-real.h" 52 | #include "asn-oid.h" 53 | #include "asn-octs.h" 54 | #include "asn-bits.h" 55 | #include "asn-enum.h" 56 | #include "asn-null.h" 57 | #include "asn-any.h" 58 | #include "asn-useful.h" 59 | #include "print.h" 60 | -------------------------------------------------------------------------------- /c-lib/src/print.c: -------------------------------------------------------------------------------- 1 | /* 2 | * print.c - library routines for printing ASN.1 values. 3 | * 4 | * Copyright (C) 1992 Michael Sample and the University of British Columbia 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it provided that this copyright/license information is retained 8 | * in original form. 9 | * 10 | * If you modify this file, you must clearly indicate your changes. 11 | * 12 | * This source code is distributed in the hope that it will be 13 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 14 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | * 16 | * $Header: /usr/app/odstb/CVS/snacc/c-lib/src/print.c,v 1.3 1997/03/13 09:15:19 wan Exp $ 17 | * $Log: print.c,v $ 18 | * Revision 1.3 1997/03/13 09:15:19 wan 19 | * Improved dependency generation for stupid makedepends. 20 | * Corrected PeekTag to peek into buffer only as far as necessary. 21 | * Added installable error handler. 22 | * Fixed small glitch in idl-code generator (Markku Savela ). 23 | * 24 | * Revision 1.2 1995/07/24 21:04:55 rj 25 | * changed `_' to `-' in file names. 26 | * 27 | * Revision 1.1 1994/08/28 09:46:08 rj 28 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 29 | * 30 | */ 31 | 32 | #include "asn-config.h" 33 | #include "print.h" 34 | 35 | unsigned short int stdIndentG = 4; 36 | 37 | 38 | void 39 | Indent PARAMS ((f, i), 40 | FILE *f _AND_ 41 | unsigned short int i) 42 | { 43 | for (; i > 0; i--) 44 | fputc (' ', f); /* this may be slow */ 45 | } 46 | 47 | void Asn1DefaultErrorHandler PARAMS ((str, severity), 48 | char* str _AND_ 49 | int severity) 50 | { 51 | fprintf(stderr,"%s",str); 52 | } 53 | 54 | static Asn1ErrorHandler asn1CurrentErrorHandler = Asn1DefaultErrorHandler; 55 | 56 | void 57 | Asn1Error PARAMS ((str), 58 | char* str) 59 | { 60 | (*asn1CurrentErrorHandler)(str,1); 61 | } 62 | 63 | void 64 | Asn1Warning PARAMS ((str), 65 | char* str) 66 | { 67 | (*asn1CurrentErrorHandler)(str,0); 68 | } 69 | 70 | Asn1ErrorHandler 71 | Asn1InstallErrorHandler PARAMS ((handler), 72 | Asn1ErrorHandler handler) 73 | { 74 | Asn1ErrorHandler former = asn1CurrentErrorHandler; 75 | asn1CurrentErrorHandler = handler; 76 | return former; 77 | } 78 | 79 | -------------------------------------------------------------------------------- /doc/mkchdr.1: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1993 by Mike Sample and UBC 2 | .\" See section COPYING for conditions for redistribution 3 | .\" $Header: /usr/app/odstb/CVS/snacc/doc/mkchdr.1,v 1.2 1997/01/01 22:47:18 rj Exp $ 4 | .\" $Log: mkchdr.1,v $ 5 | .\" Revision 1.2 1997/01/01 22:47:18 rj 6 | .\" first check-in 7 | .\" 8 | .TH MKCHDR 1 "11 July 1993" 9 | .SH NAME 10 | mkchdr \- creates a C header file from a type table 11 | .SH SYNOPSIS 12 | .nf 13 | mkchdr [output-file] 14 | .SH DESCRIPTION 15 | mkchdr will generate a C header file from the given type table. The C 16 | data structures will be written to the given output file. If an 17 | output file is not given, the C header is written to stdout. 18 | 19 | The generated C data structure is the value representation that table 20 | driven encoder expects (and decoder returns) for the type definitions 21 | in the given type table. The table driven encoder and decoder, etc. 22 | routines do not use the generated header - they treat the data in a 23 | generic way. The generated header file simply saves you the hassle of 24 | dealing with ASN.1 values in the same generic way. Instead you get 25 | properly named structs and field names. You do not need to use mkchdr 26 | to use the table driven encoders etc. but it is recommended. 27 | .PP 28 | .\" there is a tab between the file name and the description 29 | .SH FILES 30 | .PD 0 31 | .TP 28 32 | .B snacc/tbl-tools/mkchdr/ 33 | Source code for the mkchdr program 34 | .PD 35 | .SH BUGS 36 | There is no means of customizing the generated data structure. 37 | .SH COPYING 38 | Copyright (c) 1993 Mike Sample and the University of British Columbia 39 | .PP 40 | Permission is granted to make and distribute verbatim copies of 41 | this manual provided the copyright notice and this permission notice 42 | are preserved on all copies. 43 | .PP 44 | Permission is granted to copy and distribute modified versions of this 45 | manual under the conditions for verbatim copying, provided that the 46 | entire resulting derived work is distributed under the terms of a 47 | permission notice identical to this one. 48 | .PP 49 | .SH AUTHOR 50 | Mike Sample , University of British Columbia 51 | .SH ACKNOWLEDGEMENTS 52 | This work was made possible by grants from the Canadian Institute for 53 | Telecommunications Research (CITR) and Natural Sciences and 54 | Engineering Research Council of Canada (NSERC). 55 | -------------------------------------------------------------------------------- /c++-lib/inc/tcl-if.h: -------------------------------------------------------------------------------- 1 | // file: .../c++-lib/inc/tcl-if.h 2 | // 3 | // $Header: /usr/app/odstb/CVS/snacc/c++-lib/inc/tcl-if.h,v 1.5 1997/01/01 23:27:22 rj Exp $ 4 | // $Log: tcl-if.h,v $ 5 | // Revision 1.5 1997/01/01 23:27:22 rj 6 | // `typename' appears to be a reserved word in gcc 2.7, so prefix it with `_' 7 | // 8 | // Revision 1.4 1995/09/07 18:50:34 rj 9 | // duplicate code merged into a new function SnaccTcl::gettypedesc(). 10 | // 11 | // Revision 1.3 1995/08/17 15:06:43 rj 12 | // snacced.[hC] renamed to tcl-if.[hC]. 13 | // class SnaccEd renamed to SnaccTcl. 14 | // 15 | // Revision 1.2 1995/07/27 09:53:25 rj 16 | // comment leader fixed 17 | // 18 | // Revision 1.1 1995/07/27 09:52:12 rj 19 | // new file: tcl interface used by snacced. 20 | 21 | #ifdef DEBUG 22 | #include 23 | #endif 24 | 25 | class SnaccTcl 26 | { 27 | Tcl_Interp *interp; 28 | Tcl_HashTable modules, 29 | types, 30 | files; 31 | 32 | Tcl_HashEntry *create(); 33 | const AsnTypeDesc *gettypedesc (const char *cmdname, const char *type_name); 34 | 35 | public: 36 | SnaccTcl (Tcl_Interp *); 37 | ~SnaccTcl(); 38 | 39 | int create (int argc, char **argv); 40 | int openfile (int argc, char **argv); 41 | int finfo (int argc, char **argv); 42 | int read (int argc, char **argv); 43 | int write (int argc, char **argv); 44 | int closefile (int argc, char **argv); 45 | 46 | int modulesinfo (int argc, char **argv); 47 | int typesinfo (int argc, char **argv); 48 | int typeinfo (int argc, char **argv); 49 | int info (int argc, char **argv); 50 | 51 | int getval (int argc, char **argv); 52 | int setval (int argc, char **argv); 53 | int unsetval (int argc, char **argv); 54 | 55 | int test (int argc, char **argv); 56 | 57 | #ifdef DEBUG 58 | void ckip (Tcl_Interp *i) { assert (i == interp); } 59 | #endif 60 | }; 61 | 62 | class ASN1File 63 | { 64 | const AsnTypeDesc *type; 65 | AsnType *pdu; 66 | 67 | char *fn; 68 | int fd; 69 | off_t filesize; 70 | 71 | public: 72 | ASN1File (const AsnTypeDesc *); 73 | ASN1File (const AsnTypeDesc *, const char *fn, int fd); 74 | virtual ~ASN1File(); 75 | 76 | bool bad(); 77 | 78 | operator AsnType * () { return pdu; } 79 | 80 | int finfo (Tcl_Interp *); 81 | 82 | int read (Tcl_Interp *, const char *fn=NULL); 83 | int write (Tcl_Interp *, const char *fn=NULL); 84 | }; 85 | -------------------------------------------------------------------------------- /c++-lib/inc/str-stk.h: -------------------------------------------------------------------------------- 1 | // file: .../c++-lib/inc/str-stk.h - maintains a stack of the components of a bit string or octet string so they can be copied into a single chunk 2 | // 3 | // MS 92/07/06 4 | // 5 | // Copyright (C) 1992 Michael Sample and the University of British Columbia 6 | // 7 | // This library is free software; you can redistribute it and/or 8 | // modify it provided that this copyright/license information is retained 9 | // in original form. 10 | // 11 | // If you modify this file, you must clearly indicate your changes. 12 | // 13 | // This source code is distributed in the hope that it will be 14 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 15 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | // 17 | // $Header: /usr/app/odstb/CVS/snacc/c++-lib/inc/str-stk.h,v 1.5 1997/02/16 20:25:56 rj Exp $ 18 | // $Log: str-stk.h,v $ 19 | // Revision 1.5 1997/02/16 20:25:56 rj 20 | // check-in of a few cosmetic changes 21 | // 22 | // Revision 1.4 1995/07/25 21:09:14 rj 23 | // changed `_' to `-' in file names. 24 | // 25 | // Revision 1.3 1994/10/08 04:15:30 rj 26 | // fixed both Copy()'s name and implementation to CopyOut() that always returns the number of bytes copied out instead of 0 in case less than the requested amount is available. 27 | // 28 | // several `unsigned long int' turned into `size_t'. 29 | // 30 | // Revision 1.2 1994/08/28 10:01:01 rj 31 | // comment leader fixed. 32 | // 33 | // Revision 1.1 1994/08/28 09:20:49 rj 34 | // first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 35 | 36 | #ifndef _str_stk_h_ 37 | #define _str_stk_h_ 38 | 39 | #ifndef _IBM_ENC_ 40 | class StrStk 41 | #else 42 | #include "shmmgr.h" // Guido Grassel 4.8.93 43 | 44 | class StrStk: public MemMgr // Guido Grassel 12.8.93 45 | #endif /* _IBM_ENC_ */ 46 | { 47 | public: 48 | struct Elmt 49 | { 50 | char *str; 51 | size_t len; 52 | } *stk; 53 | size_t size; 54 | size_t growSize; 55 | size_t nextFreeElmt; 56 | size_t totalByteLen; 57 | 58 | StrStk (int stkSize, int growIncrement); 59 | 60 | void Reset(); 61 | 62 | void Push (char *str, size_t strLen); 63 | 64 | // copy string pieces (buffer refs) into single block. 65 | // assumes that the buf is at least totalByteLen byte long. 66 | void CopyOut (char *buf); 67 | 68 | }; 69 | 70 | #endif /* conditional include */ 71 | -------------------------------------------------------------------------------- /c-lib/src/asn-enum.c: -------------------------------------------------------------------------------- 1 | /* 2 | * asn_enum.c - routines for the ASN.1 ENUMERATED type 3 | * 4 | * MS 92 5 | * Copyright (C) 1992 Michael Sample and the University of British Columbia 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it provided that this copyright/license information is retained 9 | * in original form. 10 | * 11 | * If you modify this file, you must clearly indicate your changes. 12 | * 13 | * This source code is distributed in the hope that it will be 14 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 15 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * 17 | * $Header: /usr/app/odstb/CVS/snacc/c-lib/src/asn-enum.c,v 1.3 1995/07/24 21:04:50 rj Exp $ 18 | * $Log: asn-enum.c,v $ 19 | * Revision 1.3 1995/07/24 21:04:50 rj 20 | * changed `_' to `-' in file names. 21 | * 22 | * Revision 1.2 1994/09/01 01:04:38 rj 23 | * reduce the risk of unwanted surprises with macro expansion by properly separating the C tokens. 24 | * 25 | * Revision 1.1 1994/08/28 09:45:52 rj 26 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 27 | * 28 | */ 29 | 30 | #include "asn-config.h" 31 | #include "asn-len.h" 32 | #include "asn-tag.h" 33 | #include "asn-int.h" 34 | #include "asn-enum.h" 35 | 36 | /* 37 | * encodes universal TAG LENGTH and Contents of and ASN.1 ENUMERATED 38 | */ 39 | AsnLen 40 | BEncAsnEnum PARAMS ((b, data), 41 | BUF_TYPE b _AND_ 42 | AsnEnum *data) 43 | { 44 | AsnLen len; 45 | 46 | len = BEncAsnEnumContent (b, data); 47 | len += BEncDefLen (b, len); 48 | len += BEncTag1 (b, UNIV, PRIM, ENUM_TAG_CODE); 49 | return len; 50 | } /* BEncAsnEnum */ 51 | 52 | /* 53 | * decodes universal TAG LENGTH and Contents of and ASN.1 ENUMERATED 54 | */ 55 | void 56 | BDecAsnEnum PARAMS ((b, result, bytesDecoded, env), 57 | BUF_TYPE b _AND_ 58 | AsnEnum *result _AND_ 59 | AsnLen *bytesDecoded _AND_ 60 | jmp_buf env) 61 | { 62 | AsnTag tag; 63 | AsnLen elmtLen; 64 | 65 | if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, ENUM_TAG_CODE)) 66 | { 67 | Asn1Error ("BDecAsnInt: ERROR wrong tag on ENUMERATED.\n"); 68 | longjmp (env, -40); 69 | } 70 | 71 | elmtLen = BDecLen (b, bytesDecoded, env); 72 | BDecAsnEnumContent (b, tag, elmtLen, result, bytesDecoded, env); 73 | 74 | } /* BDecAsnEnum */ 75 | -------------------------------------------------------------------------------- /compiler/back-ends/c-gen/type-info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/back-ends/c-gen/type-info.h - fills in c type information 3 | * 4 | * Copyright (C) 1991, 1992 Michael Sample 5 | * and the University of British Columbia 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * $Header: /usr/app/odstb/CVS/snacc/compiler/back-ends/c-gen/type-info.h,v 1.3 1995/07/25 18:47:46 rj Exp $ 13 | * $Log: type-info.h,v $ 14 | * Revision 1.3 1995/07/25 18:47:46 rj 15 | * changed `_' to `-' in file names. 16 | * 17 | * Revision 1.2 1994/10/08 03:48:20 rj 18 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 19 | * 20 | * Revision 1.1 1994/08/28 09:48:43 rj 21 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 22 | * 23 | */ 24 | 25 | 26 | /* 27 | typedef struct CNamedElmt 28 | { 29 | struct CNamedElmt *next; 30 | int value; 31 | char *name; 32 | } CNamedElmt; 33 | 34 | 35 | 36 | typedef struct CTypeInfo 37 | { 38 | CTypeId cTypeId; 39 | char *cFieldName; 40 | char *cTypeName; 41 | int isPtr; 42 | int isEndCType; 43 | CNamedElmt *cNamedElmts; 44 | int choiceIdValue; 45 | char *choiceIdSymbol; 46 | char *choiceIdEnumName; 47 | char *choiceIdEnumFieldName; 48 | char *printRoutineName; 49 | char *encodeRoutineName; 50 | char *decodeRoutineName; 51 | } CTypeInfo; 52 | 53 | 54 | */ 55 | 56 | /* 57 | * allows upto 9999 unamed fields of the same type in a single structure 58 | * or 9999 values (diff asn1 scopes -> global c scope) with same name 59 | */ 60 | 61 | /* 62 | #define MAX_C_FIELD_NAME_DIGITS 4 63 | #define MAX_C_VALUE_NAME_DIGITS 4 64 | #define MAX_C_TYPE_NAME_DIGITS 4 65 | #define MAX_C_ROUTINE_NAME_DIGITS 4 66 | 67 | */ 68 | 69 | void PrintCTypeInfo PROTO ((FILE *f, Type *t)); 70 | 71 | void FillCTypeInfo PROTO ((CRules *r, ModuleList *m)); 72 | -------------------------------------------------------------------------------- /compiler/back-ends/c-gen/kwd.c: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/back-ends/c-gen/kwd.c - routines for determining whether a given str is a C keyword 3 | * 4 | * NOTE: this was hacked up really quickly. It uses a slow linear 5 | * search. A much better approach is to use a hash tbl. 6 | * 7 | * MS 92 8 | * Copyright (C) 1991, 1992 Michael Sample 9 | * and the University of British Columbia 10 | * 11 | * This program is free software; you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation; either version 2 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * $Header: /usr/app/odstb/CVS/snacc/compiler/back-ends/c-gen/kwd.c,v 1.4 1995/07/25 18:45:38 rj Exp $ 17 | * $Log: kwd.c,v $ 18 | * Revision 1.4 1995/07/25 18:45:38 rj 19 | * file name has been shortened for redundant part: c-gen/c-kwd -> c-gen/kwd. 20 | * 21 | * Revision 1.3 1994/10/08 03:48:06 rj 22 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 23 | * 24 | * Revision 1.2 1994/09/01 00:20:28 rj 25 | * snacc_config.h removed; more portable .h file inclusion. 26 | * 27 | * Revision 1.1 1994/08/28 09:48:13 rj 28 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 29 | * 30 | */ 31 | 32 | #include "snacc.h" 33 | 34 | #if STDC_HEADERS || HAVE_STRING_H 35 | #include 36 | #else 37 | #include 38 | #endif 39 | 40 | #include "kwd.h" 41 | 42 | /* 43 | * last elmt must be NULL. 44 | * key words grabbed from K&R 2nd Ed 45 | */ 46 | static char *cKWdG[] = 47 | { 48 | "auto", "break", "case", "char", "const", "continue", 49 | "default", "do", "double", "else", "enum", "extern", 50 | "float", "for", "goto", "if", "int", "long", "register", 51 | "return", "short", "signed", "sizeof", "static", "struct", 52 | "switch", "typedef", "union", "unsigned", "void", "volatile", 53 | "while", NULL 54 | }; 55 | 56 | 57 | /* 58 | * returns non-zero if the given str is a C key word 59 | */ 60 | int 61 | IsCKeyWord PARAMS ((str), 62 | char *str) 63 | { 64 | int i; 65 | 66 | for (i=0; (cKWdG[i] != NULL) && (strcmp (cKWdG[i],str) != 0); i++) 67 | ; 68 | 69 | return cKWdG[i] != NULL; 70 | } 71 | -------------------------------------------------------------------------------- /c-lib/inc/min-buf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .../c-lib/inc/min-buf.h - trivial buffer routines. 3 | * only use these for 4 | * encoding - if you know you 'buffer' is big enough 5 | * to hold the encoded value 6 | * 7 | * decoding - if you know that the encoding is error 8 | * free. 9 | * 10 | * 11 | * The minimal buffer is simply a block of mem referenced 12 | * by a char **(ie BUF_TYPE char**). These are very efficient 13 | * but should only be used when it is safe (see above) or you're 14 | * willing to risk reading past the end of the buffer or writing 15 | * 'past' the beginning (segmentation faults/bus errors etc). 16 | * 17 | * No checks for reading or writing past the buffer are done. 18 | * every operation is assumed to succeed. 19 | * MS 92 20 | * 21 | * Copyright (C) 1992 Michael Sample and the University of British Columbia 22 | * 23 | * This library is free software; you can redistribute it and/or 24 | * modify it provided that this copyright/license information is retained 25 | * in original form. 26 | * 27 | * If you modify this file, you must clearly indicate your changes. 28 | * 29 | * This source code is distributed in the hope that it will be 30 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 31 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 32 | * 33 | * $Header: /usr/app/odstb/CVS/snacc/c-lib/inc/min-buf.h,v 1.2 1995/07/24 21:01:21 rj Exp $ 34 | * $Log: min-buf.h,v $ 35 | * Revision 1.2 1995/07/24 21:01:21 rj 36 | * changed `_' to `-' in file names. 37 | * 38 | * Revision 1.1 1994/08/28 09:21:42 rj 39 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 40 | * 41 | */ 42 | 43 | #ifndef _min_buf_h_ 44 | #define _min_buf_h_ 45 | 46 | #define MinBufGetByte(b)\ 47 | (unsigned char)(*((*(b))++)) 48 | 49 | #define MinBufGetSeg( b, lenPtr)\ 50 | *(b);\ 51 | (*b) += *lenPtr; 52 | 53 | #define MinBufCopy( dst, b, len)\ 54 | memcpy ((dst), *(b), (len));\ 55 | (*(b)) += (len); 56 | 57 | #define MinBufSkip( b, len) ((*(b)) += len) 58 | 59 | #define MinBufPeekByte( b) (**(b)) 60 | 61 | 62 | #define MinBufPutByteRvs( b, byte)\ 63 | (*(--(*(b))) = (byte)) 64 | 65 | #define MinBufPutSegRvs( b, data, len)\ 66 | ((*(b)) = (*(b)) - (len));\ 67 | memcpy (*(b), (data), (len)); 68 | 69 | 70 | #define MinBufReadError( b) 0 /* always false */ 71 | #define MinBufWriteError( b) 0 /* always false */ 72 | 73 | #endif /* conditional include */ 74 | -------------------------------------------------------------------------------- /c++-lib/inc/hash.h: -------------------------------------------------------------------------------- 1 | // file: .../c++-lib/inc/hash.h - C++ hash tbl routines 2 | // 3 | // Based on hashing stuff from UBC Raven Code (Terry Coatta & Don Acton) 4 | // 5 | // MS 92 6 | // Copyright (C) 1992 the University of British Columbia 7 | // 8 | // This library is free software; you can redistribute it and/or 9 | // modify it provided that this copyright/license information is retained 10 | // in original form. 11 | // 12 | // If you modify this file, you must clearly indicate your changes. 13 | // 14 | // This source code is distributed in the hope that it will be 15 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 16 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | // 18 | // $Header: /usr/app/odstb/CVS/snacc/c++-lib/inc/hash.h,v 1.5 1997/02/28 13:39:42 wan Exp $ 19 | // $Log: hash.h,v $ 20 | // Revision 1.5 1997/02/28 13:39:42 wan 21 | // Modifications collected for new version 1.3: Bug fixes, tk4.2. 22 | // 23 | // Revision 1.4 1997/02/16 20:25:51 rj 24 | // check-in of a few cosmetic changes 25 | // 26 | // Revision 1.3 1994/10/08 04:18:12 rj 27 | // code for meta structures added (provides information about the generated code itself). 28 | // 29 | // code for Tcl interface added (makes use of the above mentioned meta code). 30 | // 31 | // virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. 32 | // 33 | // made Print() const (and some other, mainly comparison functions). 34 | // 35 | // several `unsigned long int' turned into `size_t'. 36 | // 37 | // Revision 1.2 1994/08/28 10:00:59 rj 38 | // comment leader fixed. 39 | // 40 | // Revision 1.1 1994/08/28 09:20:46 rj 41 | // first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 42 | 43 | #ifndef _asn_hash_h_ 44 | #define _asn_hash_h_ 45 | 46 | #define TABLESIZE 256 47 | #define INDEXMASK 0xFF 48 | #define INDEXSHIFT 8 49 | 50 | typedef void *Table[TABLESIZE]; 51 | 52 | typedef unsigned int Hash; 53 | 54 | typedef struct HashSlot 55 | { 56 | int leaf; 57 | Hash hash; 58 | void *value; 59 | Table *table; 60 | } HashSlot; 61 | 62 | Hash MakeHash (const char *str, size_t len); 63 | 64 | Table *InitHash(); 65 | 66 | int Insert (Table *table, void *element, Hash hash); 67 | 68 | int CheckFor (Table *table, Hash hash); 69 | 70 | int CheckForAndReturnValue (Table *table, Hash hash, void **value); 71 | 72 | 73 | #endif /* conditional include */ 74 | -------------------------------------------------------------------------------- /c-lib/inc/asn-int.h: -------------------------------------------------------------------------------- 1 | /* 2 | * asn_int.h 3 | * 4 | * MS 92 5 | * Copyright (C) 1992 Michael Sample and the University of British Columbia 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it provided that this copyright/license information is retained 9 | * in original form. 10 | * 11 | * If you modify this file, you must clearly indicate your changes. 12 | * 13 | * This source code is distributed in the hope that it will be 14 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 15 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * 17 | * $Header: /usr/app/odstb/CVS/snacc/c-lib/inc/asn-int.h,v 1.3 1995/07/27 08:38:58 rj Exp $ 18 | * $Log: asn-int.h,v $ 19 | * Revision 1.3 1995/07/27 08:38:58 rj 20 | * ``#error "..."'' instead of ``#error ...''. 21 | * 22 | * changed `_' to `-' in file names. 23 | * 24 | * Revision 1.2 1995/02/18 16:19:42 rj 25 | * let cpp choose a 32 bit integer type. 26 | * 27 | * Revision 1.1 1994/08/28 09:21:28 rj 28 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 29 | * 30 | */ 31 | 32 | #ifndef _asn_int_h_ 33 | #define _asn_int_h_ 34 | 35 | #if SIZEOF_INT == 4 36 | # define I int 37 | #else 38 | # if SIZEOF_LONG == 4 39 | # define I long 40 | # else 41 | # if SIZEOF_SHORT == 4 42 | # define I short 43 | # endif 44 | # endif 45 | #endif 46 | #ifdef I 47 | typedef I AsnInt; 48 | typedef unsigned I UAsnInt; 49 | #else 50 | #error "can't find integer type which is 4 bytes in size" 51 | #endif 52 | #undef I 53 | 54 | AsnLen BEncAsnInt PROTO ((BUF_TYPE b, AsnInt *data)); 55 | 56 | void BDecAsnInt PROTO ((BUF_TYPE b, AsnInt *result, AsnLen *bytesDecoded, ENV_TYPE env)); 57 | 58 | AsnLen BEncAsnIntContent PROTO ((BUF_TYPE b, AsnInt *data)); 59 | 60 | void BDecAsnIntContent PROTO ((BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnInt *result, AsnLen *bytesDecoded, ENV_TYPE env)); 61 | 62 | /* do nothing */ 63 | #define FreeAsnInt( v) 64 | 65 | void PrintAsnInt PROTO ((FILE *f, AsnInt *v, unsigned short int indent)); 66 | 67 | 68 | 69 | 70 | AsnLen BEncUAsnInt PROTO ((BUF_TYPE b, UAsnInt *data)); 71 | 72 | void BDecUAsnInt PROTO ((BUF_TYPE b, UAsnInt *result, AsnLen *bytesDecoded, ENV_TYPE env)); 73 | 74 | AsnLen BEncUAsnIntContent PROTO ((BUF_TYPE b, UAsnInt *data)); 75 | 76 | void BDecUAsnIntContent PROTO ((BUF_TYPE b, AsnTag tagId, AsnLen len, UAsnInt *result, AsnLen *bytesDecoded, ENV_TYPE env)); 77 | 78 | /* do nothing */ 79 | #define FreeUAsnInt( v) 80 | 81 | void PrintUAsnInt PROTO ((FILE *f, UAsnInt *v, unsigned short int indent)); 82 | 83 | 84 | #endif /* conditional include */ 85 | -------------------------------------------------------------------------------- /c-examples/snmp/makefile: -------------------------------------------------------------------------------- 1 | # c-examples/snmp/makefile 2 | # 3 | # $Header: /usr/app/odstb/CVS/snacc/c-examples/snmp/makefile,v 1.6 1995/07/27 09:57:38 rj Exp $ 4 | # $Log: makefile,v $ 5 | # Revision 1.6 1995/07/27 09:57:38 rj 6 | # rfc1155-smi.asn1, rfc1157-snmp.asn1 and rfc1213-mib2.asn1 renamed from 1155-smi.asn1, 1157-snmp.asn1 and 1213-mib2.asn1 to accomodate to snacc's new file name generation scheme. 7 | # 8 | # Revision 1.5 1995/07/24 20:48:27 rj 9 | # `cd && make' instead of `cd; make'. 10 | # 11 | # changed `_' to `-' in file names. 12 | # 13 | # Revision 1.4 1995/02/20 11:52:11 rj 14 | # build snacc if it doesn't exist. 15 | # 16 | # Revision 1.3 1995/02/13 15:05:48 rj 17 | # augment CPPFLAGS, not overwrite. 18 | # we need the compiler for the dependencies, so make it if it doesn't yet exist. 19 | # 20 | # Revision 1.2 1994/08/31 23:25:46 rj 21 | # print a less irritating usage. 22 | # 23 | # Revision 1.1 1994/08/31 08:46:34 rj 24 | # first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 25 | # 26 | 27 | #include ../../makehead 28 | 29 | TOP = /usr 30 | 31 | ASN1_SRC_DIR = $(TOP)/include/snacc/asn1 32 | 33 | ASN1_C_LIB_DIR = $(TOP)/lib 34 | ASN1_C_INC_DIR = $(TOP)/include/snacc/c 35 | ASN1_C_LIB = $(ASN1_C_LIB_DIR)/libasn1csbuf.a 36 | 37 | COMPILERDIR = $(TOP)/bin 38 | SNACC = $(COMPILERDIR)/snacc 39 | 40 | CPPFLAGS += -g -I$(TOP) -I$(ASN1_C_INC_DIR) -DUSE_SBUF 41 | 42 | ASN1FILES = \ 43 | $(ASN1_SPEC_DIR)/rfc1155-smi.asn1 \ 44 | $(ASN1_SPEC_DIR)/rfc1157-snmp.asn1 \ 45 | $(ASN1_SPEC_DIR)/rfc1213-mib2.asn1 46 | 47 | ASN1HFILES = \ 48 | rfc1155-smi.h \ 49 | rfc1213-mib2.h \ 50 | rfc1157-snmp.h 51 | 52 | ASN1CFILES = \ 53 | rfc1155-smi.c \ 54 | rfc1213-mib2.c \ 55 | rfc1157-snmp.c 56 | 57 | DISTFILES = \ 58 | README \ 59 | makefile \ 60 | 61 | #------------------------------------------------------------------------------- 62 | 63 | default:: warning 64 | 65 | warning:: 66 | @echo '' 67 | @echo 'read the README and enter `$(MAKE) fail` to test for yourself' 68 | @echo '' 69 | 70 | fail:: $(ASN1HFILES) $(ASN1CFILES) 71 | $(CC) $(CPPFLAGS) $(CFLAGS) -c $(ASN1CFILES) 72 | 73 | $(ASN1HFILES) \ 74 | $(ASN1CFILES): $(SNACC) $(ASN1FILES) 75 | $(REASON) 76 | $(SNACC) -P $(ASN1FILES) > snacc.output~ 77 | mv snacc.output~ snacc.output 78 | 79 | $(SNACC): 80 | cd $(@D) && $(MAKE) $(@F) 81 | 82 | check:: 83 | @echo "the purpose of this directories' contents is to show deficiencies." 84 | @echo "if you want to exercise 'em, make the phony target "'`'"fail'" 85 | 86 | clean:: 87 | $(RM) *.o *~ .emacs* core $(ASN1HFILES) $(ASN1CFILES) snacc.output 88 | 89 | depend:: $(SNACC) 90 | 91 | #include ../../maketail 92 | -------------------------------------------------------------------------------- /c++-lib/inc/asn-null.h: -------------------------------------------------------------------------------- 1 | // file: .../c++-lib/inc/asn-null.h - C++ version of ASN.1 NULL 2 | // 3 | // MS 92/06/15 4 | // Copyright (C) 1992 Michael Sample and the University of British Columbia 5 | // 6 | // This library is free software; you can redistribute it and/or 7 | // modify it provided that this copyright/license information is retained 8 | // in original form. 9 | // 10 | // If you modify this file, you must clearly indicate your changes. 11 | // 12 | // This source code is distributed in the hope that it will be 13 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 14 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | // 16 | // $Header: /usr/app/odstb/CVS/snacc/c++-lib/inc/asn-null.h,v 1.5 1997/02/16 10:08:29 rj Exp $ 17 | // $Log: asn-null.h,v $ 18 | // Revision 1.5 1997/02/16 10:08:29 rj 19 | // comment out an unused argument 20 | // 21 | // Revision 1.4 1995/07/24 17:53:57 rj 22 | // #if TCL ... #endif wrapped into #if META ... #endif 23 | // 24 | // changed `_' to `-' in file names. 25 | // 26 | // Revision 1.3 1994/10/08 04:18:06 rj 27 | // code for meta structures added (provides information about the generated code itself). 28 | // 29 | // code for Tcl interface added (makes use of the above mentioned meta code). 30 | // 31 | // virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. 32 | // 33 | // made Print() const (and some other, mainly comparison functions). 34 | // 35 | // several `unsigned long int' turned into `size_t'. 36 | // 37 | // Revision 1.2 1994/08/28 10:00:52 rj 38 | // comment leader fixed. 39 | // 40 | // Revision 1.1 1994/08/28 09:20:38 rj 41 | // first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 42 | 43 | #ifndef _asn_null_h_ 44 | #define _asn_null_h_ 45 | 46 | class AsnNull: public AsnType 47 | { 48 | public: 49 | AsnNull() {} 50 | 51 | AsnType *Clone() const; 52 | 53 | AsnLen BEncContent (BUF_TYPE /*b*/) { return 0; } 54 | void BDecContent (BUF_TYPE b, AsnTag tagId, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); 55 | AsnLen BEnc (BUF_TYPE b); 56 | void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); 57 | 58 | PDU_MEMBER_MACROS 59 | 60 | void Print (std::ostream &os) const; 61 | 62 | #if META 63 | static const AsnNullTypeDesc _desc; 64 | 65 | const AsnTypeDesc *_getdesc() const; 66 | 67 | #if TCL 68 | int TclGetVal (Tcl_Interp *) const; 69 | int TclSetVal (Tcl_Interp *, const char *val); 70 | #endif /* TCL */ 71 | #endif /* META */ 72 | }; 73 | 74 | #endif /* conditional include */ 75 | -------------------------------------------------------------------------------- /c++-lib/src/str-stk.C: -------------------------------------------------------------------------------- 1 | // file: .../c++-lib/src/str-stk.C 2 | // 3 | // MS 92/07/06 4 | // Copyright (C) 1992 Michael Sample and the University of British Columbia 5 | // 6 | // This library is free software; you can redistribute it and/or 7 | // modify it provided that this copyright/license information is retained 8 | // in original form. 9 | // 10 | // If you modify this file, you must clearly indicate your changes. 11 | // 12 | // This source code is distributed in the hope that it will be 13 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 14 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | // 16 | // $Header: /usr/app/odstb/CVS/snacc/c++-lib/src/str-stk.C,v 1.5 1997/02/16 20:26:11 rj Exp $ 17 | // $Log: str-stk.C,v $ 18 | // Revision 1.5 1997/02/16 20:26:11 rj 19 | // check-in of a few cosmetic changes 20 | // 21 | // Revision 1.4 1995/07/24 20:34:57 rj 22 | // changed `_' to `-' in file names. 23 | // 24 | // Revision 1.3 1994/10/08 04:15:22 rj 25 | // fixed both Copy()'s name and implementation to CopyOut() that always returns the number of bytes copied out instead of 0 in case less than the requested amount is available. 26 | // 27 | // several `unsigned long int' turned into `size_t'. 28 | // 29 | // Revision 1.2 1994/08/28 10:01:24 rj 30 | // comment leader fixed. 31 | // 32 | // Revision 1.1 1994/08/28 09:21:13 rj 33 | // first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 34 | 35 | #include "asn-config.h" 36 | #include "str-stk.h" 37 | 38 | // global for use by AsnBits and AsnOcts 39 | 40 | StrStk strStkG (128, 64); 41 | 42 | StrStk::StrStk (int stkSize, int growIncrement) 43 | { 44 | stk = new struct Elmt[stkSize]; 45 | size = stkSize; 46 | growSize = growIncrement; 47 | } 48 | 49 | void StrStk::Reset() 50 | { 51 | nextFreeElmt = 0; 52 | totalByteLen = 0; 53 | } 54 | 55 | void StrStk::Push (char *str, size_t strLen) 56 | { 57 | if (nextFreeElmt >= size) 58 | { 59 | struct Elmt *tmpStk; 60 | // alloc bigger stack and copy old elmts to it 61 | tmpStk = new struct Elmt[size + growSize]; 62 | for (int i = 0; i < size; i++) 63 | tmpStk[i] = stk[i]; 64 | delete stk; 65 | stk = tmpStk; 66 | size += growSize; 67 | } 68 | totalByteLen += strLen; 69 | stk[nextFreeElmt].str = str; 70 | stk[nextFreeElmt++].len = strLen; 71 | } 72 | 73 | /* 74 | * copy string pieces (buffer refs) into single block. 75 | * assumes that the buf is at least totalByteLen byte long. 76 | */ 77 | void StrStk::CopyOut (char *buf) 78 | { 79 | unsigned long int curr; 80 | char *bufCurr; 81 | 82 | bufCurr = buf; 83 | for (curr = 0; curr < nextFreeElmt; curr++) 84 | { 85 | memcpy (bufCurr, stk[curr].str, stk[curr].len); 86 | bufCurr += stk[curr].len; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /asn1specs/any.asn1: -------------------------------------------------------------------------------- 1 | -- file: asn1specs/any.asn1 2 | -- 3 | -- this file is used in ../c{,++}-examples/any/ 4 | -- 5 | -- $Header: /usr/app/odstb/CVS/snacc/asn1specs/any.asn1,v 1.2 1997/02/16 20:25:20 rj Exp $ 6 | -- $Log: any.asn1,v $ 7 | -- Revision 1.2 1997/02/16 20:25:20 rj 8 | -- check-in of a few cosmetic changes 9 | -- 10 | -- Revision 1.1 1994/08/31 22:44:44 rj 11 | -- first check-in. 12 | 13 | ANY-TEST DEFINITIONS ::= BEGIN 14 | 15 | -- 16 | -- use the SNMP OBJECT type to define the correlation between 17 | -- the identifying INTEGER/OBJECT IDENTIFIER 18 | -- and the ANY DEFINED BY type 19 | -- 20 | 21 | intId OBJECT-TYPE 22 | SYNTAX INTEGER 23 | ACCESS read-write 24 | STATUS mandatory 25 | ::= 1 26 | 27 | boolId OBJECT-TYPE 28 | SYNTAX BOOLEAN 29 | ACCESS read-write 30 | STATUS mandatory 31 | ::= 2 32 | 33 | octsId OBJECT-TYPE 34 | SYNTAX [PRIVATE 2] IMPLICIT OCTET STRING 35 | ACCESS read-write 36 | STATUS mandatory 37 | ::= 3 38 | 39 | bitsId OBJECT-TYPE 40 | SYNTAX [PRIVATE 1] BIT STRING 41 | ACCESS read-write 42 | STATUS mandatory 43 | ::= 4 44 | 45 | realId OBJECT-TYPE 46 | SYNTAX REAL 47 | ACCESS read-write 48 | STATUS mandatory 49 | ::= 5 50 | 51 | -- 52 | -- note that the following OBJECT-TYPE OBJECT IDENTIFIER values 53 | -- reference the previous OBJECT-TYPE INTEGER values 54 | 55 | intOid OBJECT-TYPE 56 | SYNTAX INTEGER 57 | ACCESS read-write 58 | STATUS mandatory 59 | ::= { 0 1 2 3 4 intId} 60 | 61 | boolOid OBJECT-TYPE 62 | SYNTAX BOOLEAN 63 | ACCESS read-write 64 | STATUS mandatory 65 | ::= { 0 1 2 3 4 boolId} 66 | 67 | octsOid OBJECT-TYPE 68 | SYNTAX OCTET STRING 69 | ACCESS read-write 70 | STATUS mandatory 71 | ::= { 0 1 2 3 4 octsId} 72 | 73 | bitsOid OBJECT-TYPE 74 | SYNTAX BIT STRING 75 | ACCESS read-write 76 | STATUS mandatory 77 | ::= { 0 1 2 3 4 bitsId} 78 | 79 | realOid OBJECT-TYPE 80 | SYNTAX REAL 81 | ACCESS read-write 82 | STATUS mandatory 83 | ::= { 0 1 2 3 4 realId} 84 | 85 | 86 | -- this type tests both the INTEGER and OBJECT IDENTIFIER mapping 87 | AnyTestType ::= --snacc isPdu:"TRUE" -- SEQUENCE 88 | { 89 | intMap TSeq1, 90 | oidMap TSeq2 91 | } 92 | 93 | TSeq1 ::= SEQUENCE OF AttrValue1 94 | 95 | 96 | AttrValue1 ::= SEQUENCE 97 | { 98 | id INTEGER, 99 | ANY DEFINED BY id 100 | } 101 | 102 | TSeq2 ::= SEQUENCE OF AttrValue2 103 | 104 | AttrValue2 ::= SEQUENCE 105 | { 106 | id OBJECT IDENTIFIER, 107 | ANY DEFINED BY id 108 | } 109 | 110 | END 111 | -------------------------------------------------------------------------------- /compiler/core/mem.c: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/core/mem.c - used for allocating the components of the Module 3 | * data structure. The program expects 0'ed memory 4 | * to be returned by Malloc - this initializes ptrs 5 | * to NULL. 6 | * 7 | * If there is not enough memory the Malloc exits 8 | * (Callers of Malloc will never get a NULL return value) 9 | * 10 | * Copyright (C) 1991, 1992 Michael Sample 11 | * and the University of British Columbia 12 | * 13 | * This program is free software; you can redistribute it and/or modify 14 | * it under the terms of the GNU General Public License as published by 15 | * the Free Software Foundation; either version 2 of the License, or 16 | * (at your option) any later version. 17 | * 18 | * $Header: /usr/app/odstb/CVS/snacc/compiler/core/mem.c,v 1.4 1995/07/25 19:11:50 rj Exp $ 19 | * $Log: mem.c,v $ 20 | * Revision 1.4 1995/07/25 19:11:50 rj 21 | * use memzero that is defined in .../snacc.h to use either memset or bzero. 22 | * 23 | * Realloc() now checks realloc(3)'s return value. 24 | * 25 | * Revision 1.3 1994/10/08 03:48:49 rj 26 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 27 | * 28 | * Revision 1.2 1994/09/01 00:39:27 rj 29 | * snacc_config.h removed; more portable .h file inclusion. 30 | * 31 | * Revision 1.1 1994/08/28 09:49:21 rj 32 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 33 | */ 34 | 35 | #include "snacc.h" 36 | 37 | #if STDC_HEADERS 38 | #include 39 | #include 40 | #else 41 | #if HAVE_STRING_H 42 | #include 43 | #else 44 | #include 45 | #endif 46 | #if HAVE_MALLOC_H 47 | #include 48 | #endif 49 | #endif 50 | 51 | #include 52 | 53 | #include "mem.h" 54 | 55 | void* 56 | Malloc PARAMS ((size), int size) 57 | { 58 | void *retVal = malloc (size); 59 | 60 | if (retVal == NULL) 61 | { 62 | fprintf (stderr, "out of memory! bye!\n"); 63 | fprintf (stderr, "tried to allocate %d byes\n", size); 64 | exit (1); 65 | } 66 | 67 | memzero (retVal, size); 68 | return retVal; 69 | 70 | } /* Malloc */ 71 | 72 | void *Realloc PARAMS ((ptr, newsize), 73 | void *ptr _AND_ 74 | int newsize) 75 | { 76 | void *retval = realloc (ptr, newsize); 77 | 78 | if (retval == NULL) 79 | { 80 | fprintf (stderr, "out of memory! bye!\n"); 81 | fprintf (stderr, "tried to reallocate %d byes\n", newsize); 82 | exit (1); 83 | } 84 | 85 | return retval; 86 | } 87 | 88 | void Free PARAMS ((ptr), 89 | void *ptr) 90 | { 91 | free (ptr); 92 | } 93 | -------------------------------------------------------------------------------- /c++-lib/inc/asn-enum.h: -------------------------------------------------------------------------------- 1 | // file: .../c++-lib/inc/asn-enum.h - c++ version of ASN.1 ENUMERATED 2 | // 3 | // inherits from AsnInt but changes universal tag stuff 4 | // MS 92/06/15 5 | // 6 | // Copyright (C) 1992 Michael Sample and the University of British Columbia 7 | // 8 | // This library is free software; you can redistribute it and/or 9 | // modify it provided that this copyright/license information is retained 10 | // in original form. 11 | // 12 | // If you modify this file, you must clearly indicate your changes. 13 | // 14 | // This source code is distributed in the hope that it will be 15 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 16 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | // 18 | // $Header: /usr/app/odstb/CVS/snacc/c++-lib/inc/asn-enum.h,v 1.5 1995/08/17 15:17:07 rj Exp $ 19 | // $Log: asn-enum.h,v $ 20 | // Revision 1.5 1995/08/17 15:17:07 rj 21 | // AsnEnumTypeDesc gets its own TclGetVal and TclSetVal functions. 22 | // 23 | // Revision 1.4 1995/07/24 17:52:00 rj 24 | // Clone() added, or else the _desc would be wrong (and the wrong BEnc etc... would get called for Clone-d objects). 25 | // 26 | // _desc changed from AsnIntTypeDesc to AsnEnumTypeDesc. 27 | // 28 | // changed `_' to `-' in file names. 29 | // 30 | // Revision 1.3 1994/10/08 04:17:59 rj 31 | // code for meta structures added (provides information about the generated code itself). 32 | // 33 | // code for Tcl interface added (makes use of the above mentioned meta code). 34 | // 35 | // virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. 36 | // 37 | // made Print() const (and some other, mainly comparison functions). 38 | // 39 | // several `unsigned long int' turned into `size_t'. 40 | // 41 | // Revision 1.2 1994/08/28 10:00:48 rj 42 | // comment leader fixed. 43 | // 44 | // Revision 1.1 1994/08/28 09:20:31 rj 45 | // first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 46 | 47 | #ifndef _asn_enum_h_ 48 | #define _asn_enum_h_ 49 | 50 | class AsnEnum: public AsnInt 51 | { 52 | public: 53 | #if !TCL 54 | AsnEnum(): 55 | AsnInt() 56 | {} 57 | #endif 58 | AsnEnum (int i): 59 | AsnInt (i) 60 | {} 61 | 62 | AsnType *Clone() const; 63 | 64 | AsnLen BEnc (BUF_TYPE b); 65 | void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); 66 | 67 | PDU_MEMBER_MACROS 68 | 69 | #if META 70 | static const AsnEnumTypeDesc _desc; 71 | 72 | const AsnTypeDesc *_getdesc() const; 73 | 74 | #if TCL 75 | int TclGetVal (Tcl_Interp *) const; 76 | int TclSetVal (Tcl_Interp *, const char *val); 77 | #endif /* TCL */ 78 | #endif /* META */ 79 | }; 80 | 81 | #endif /* conditional include */ 82 | -------------------------------------------------------------------------------- /tbl-example/README: -------------------------------------------------------------------------------- 1 | (RCS control information is at the end of this file.) 2 | 3 | 4 | Table encoder/decoder example README - MS 93 5 | ------------------------------------ 6 | 7 | This directory contains an example that shows: 8 | 9 | 1. the process of creating and using tables. 10 | 2. examples of decoding, printing, and encoding. 11 | 12 | 13 | To dive right in just type "make" in this directory. That will 14 | create the "example" executable (you should have previously installed 15 | the snacc and mkchdr progs and the table library). 16 | 17 | Then type: 18 | 19 | make check 20 | 21 | and see what happens. Look in example.c and makefile to see how things 22 | work. 23 | 24 | 25 | 26 | Questions and Answers 27 | --------------------- 28 | 29 | Q. What is a table? (also refered to a type table or type tree) 30 | 31 | A. A table is simply a data structure that holds a description of 32 | the types from an ASN.1 module. This table can then be used 33 | by a number of "generic" routines to do ASN.1 related (BER 34 | encoding/decoding) or other useful things such as printing 35 | values, freeing values and whatever else you can dream up. 36 | 37 | 38 | Q. How do I create a table from my ASN.1 source files? 39 | 40 | A. Run snacc with the -T option, e.g.: 41 | 42 | snacc -T mytbls.tt myMod1.asn1 myMod2.asn1 43 | 44 | the above command will create the "mytbls.tt" file that 45 | holds the descriptions of the ASN.1 types in the "myMod1.asn1" 46 | and "myMod2.asn1" files. (look in the makefile in this directory) 47 | 48 | 49 | Q. Why is there only a C interface to tables? 50 | 51 | A. Time. Tables drivers create/read/free these types 52 | without having seen a typedef for them. The C implementation 53 | uses some assumptions about how structures etc. are allocated 54 | and accessed. With C++ this is much more difficult. It can 55 | be done but required more time than I had. 56 | 57 | 58 | Q. Ok, tables sound great, what's the catch? 59 | 60 | A. Well, 61 | 62 | 1. table driven encoding and decoding is something like 63 | 4 times slower than the C or C++ version. 64 | (but tables are *way* smaller than the .o's for the compiled approach) 65 | 2. the ANY DEFINED BY stuff is not supported at all. 66 | 3. subtype information is not included in the tables (time crunch again) 67 | (PER encoders/decoders will need the subtype info) 68 | 4. Values from the ASN.1 source are not included in the table. 69 | 70 | If you have the time and skills, you can fix 2, 3 and 4. 1 is harder. 71 | 72 | 73 | 74 | Q. Tell me more. 75 | 76 | A. Look at the manual. (in .../doc/) 77 | 78 | #------------------------------------------------------------------------------- 79 | # $Header: /usr/app/odstb/CVS/snacc/tbl-example/README,v 1.1 1997/02/15 19:33:24 rj Exp $ 80 | # $Log: README,v $ 81 | # Revision 1.1 1997/02/15 19:33:24 rj 82 | # first check-in 83 | # 84 | -------------------------------------------------------------------------------- /compiler/back-ends/str-util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/back_ends/c_gen/str_util.h 3 | * 4 | * Mike Sample 5 | * 91/08/12 6 | * Copyright (C) 1991, 1992 Michael Sample 7 | * and the University of British Columbia 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * $Header: /usr/app/odstb/CVS/snacc/compiler/back-ends/str-util.h,v 1.3 1995/07/25 18:13:55 rj Exp $ 15 | * $Log: str-util.h,v $ 16 | * Revision 1.3 1995/07/25 18:13:55 rj 17 | * by default, snacc now derives output file names from the .asn1 input file name instead of the module name. 18 | * the global keepbaseG variable switches between the two behaviours. 19 | * 20 | * additional filename generator for idl backend. 21 | * 22 | * changed `_' to `-' in file names. 23 | * 24 | * Revision 1.2 1994/10/08 03:48:18 rj 25 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 26 | * 27 | * Revision 1.1 1994/08/28 09:48:38 rj 28 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 29 | * 30 | */ 31 | 32 | char *Asn1TypeName2CTypeName PROTO ((char *aName)); 33 | 34 | char *Asn1FieldName2CFieldName PROTO ((char *aName)); 35 | 36 | char *Asn1ValueName2CValueName PROTO ((char *aName)); 37 | 38 | char *GetCaps PROTO ((char *str)); 39 | 40 | char *GetCapsAndDigits PROTO ((char *str)); 41 | 42 | void Str2UCase PROTO ((char *str, int len)); 43 | 44 | void Str2LCase PROTO ((char *str, int len)); 45 | 46 | void Dash2Underscore PROTO ((char *str, int len)); 47 | 48 | void AppendDigit PROTO ((char *str, int digit)); 49 | 50 | void MakeCStrUnique PROTO ((DefinedObj *nameList, char *str, int maxDigits, int startingDigit)); 51 | 52 | void MakeCxxStrUnique PROTO ((DefinedObj *nameList, char *str, int maxDigits, int startingDigit)); 53 | 54 | extern int keepbaseG; 55 | 56 | char *MakeBaseFileName PROTO ((const char *moduleName)); 57 | char *MakeFileName PROTO ((const char *moduleName, const char *suffix)); 58 | char *MakeCHdrFileName PROTO ((const char *moduleName)); 59 | char *MakeCSrcFileName PROTO ((const char *moduleName)); 60 | char *MakeCxxHdrFileName PROTO ((const char *moduleName)); 61 | char *MakeCxxSrcFileName PROTO ((const char *moduleName)); 62 | #ifdef _IBM_ENC_ 63 | char *MakedbHdrFileName PROTO ((const char *moduleName)); /* 19.8.93 IBM-ENC */ 64 | char *MakedbSrcFileName PROTO ((const char *moduleName)); /* 19.8.93 IBM-ENC */ 65 | #endif /* _IBM_ENC_ */ 66 | #if IDL 67 | char *MakeIDLFileName PROTO ((const char *moduleName)); 68 | #endif 69 | -------------------------------------------------------------------------------- /compiler/core/lib-types.c: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/core/lib_types.c - tag form/code and any refs info 3 | * 4 | * 5 | * Copyright (C) 1991, 1992 Michael Sample 6 | * and the University of British Columbia 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * $Header: /usr/app/odstb/CVS/snacc/compiler/core/lib-types.c,v 1.3 1995/07/25 19:41:33 rj Exp $ 14 | * $Log: lib-types.c,v $ 15 | * Revision 1.3 1995/07/25 19:41:33 rj 16 | * changed `_' to `-' in file names. 17 | * 18 | * Revision 1.2 1994/09/01 00:37:51 rj 19 | * snacc_config.h removed. 20 | * 21 | * Revision 1.1 1994/08/28 09:49:14 rj 22 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 23 | * 24 | */ 25 | 26 | #include "asn-incl.h" 27 | #include "asn1module.h" /* for BASICTYPE_... choice ids */ 28 | #include "lib-types.h" 29 | 30 | /* 31 | * Warning: this table must be in order of ascending 32 | * BASICTYPE ids such that 33 | * libTypesG[BASICTYPE_X].typeId == BASICTYPE_X 34 | * is alwas true 35 | */ 36 | LibType libTypesG[ BASICTYPE_MACRODEF + 1] = 37 | { 38 | { BASICTYPE_UNKNOWN, NO_TAG_CODE, NULL_FORM, NULL }, 39 | { BASICTYPE_BOOLEAN, BOOLEAN_TAG_CODE, PRIM, NULL }, 40 | { BASICTYPE_INTEGER, INTEGER_TAG_CODE, PRIM, NULL }, 41 | { BASICTYPE_BITSTRING, BITSTRING_TAG_CODE, ANY_FORM, NULL }, 42 | { BASICTYPE_OCTETSTRING, OCTETSTRING_TAG_CODE, ANY_FORM, NULL }, 43 | { BASICTYPE_NULL, NULLTYPE_TAG_CODE, PRIM, NULL }, 44 | { BASICTYPE_OID, OID_TAG_CODE, PRIM, NULL }, 45 | { BASICTYPE_REAL, REAL_TAG_CODE, PRIM, NULL }, 46 | { BASICTYPE_ENUMERATED, ENUM_TAG_CODE, PRIM, NULL }, 47 | { BASICTYPE_SEQUENCE, SEQ_TAG_CODE, CONS, NULL }, 48 | { BASICTYPE_SEQUENCEOF, SEQ_TAG_CODE, CONS, NULL }, 49 | { BASICTYPE_SET, SET_TAG_CODE, CONS, NULL }, 50 | { BASICTYPE_SETOF, SET_TAG_CODE, CONS, NULL }, 51 | { BASICTYPE_CHOICE, NO_TAG_CODE, CONS, NULL }, 52 | { BASICTYPE_SELECTION, NO_TAG_CODE, NULL_FORM, NULL }, 53 | { BASICTYPE_COMPONENTSOF, NO_TAG_CODE, CONS, NULL }, 54 | { BASICTYPE_ANY, NO_TAG_CODE, CONS, NULL }, 55 | { BASICTYPE_ANYDEFINEDBY, NO_TAG_CODE, CONS, NULL }, 56 | { BASICTYPE_LOCALTYPEREF, NO_TAG_CODE, NULL_FORM, NULL }, 57 | { BASICTYPE_IMPORTTYPEREF, NO_TAG_CODE, NULL_FORM, NULL }, 58 | { BASICTYPE_MACROTYPE, NO_TAG_CODE, NULL_FORM, NULL }, 59 | { BASICTYPE_MACRODEF, NO_TAG_CODE, NULL_FORM, NULL } 60 | }; 61 | -------------------------------------------------------------------------------- /c++-lib/inc/asn-real.h: -------------------------------------------------------------------------------- 1 | // file: .../c++-lib/inc/asn-real.h - ASN.1 REAL type 2 | // 3 | // Mike Sample 4 | // 92/07/02 5 | // Copyright (C) 1992 Michael Sample and the University of British Columbia 6 | // 7 | // This library is free software; you can redistribute it and/or 8 | // modify it provided that this copyright/license information is retained 9 | // in original form. 10 | // 11 | // If you modify this file, you must clearly indicate your changes. 12 | // 13 | // This source code is distributed in the hope that it will be 14 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 15 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | // 17 | // $Header: /usr/app/odstb/CVS/snacc/c++-lib/inc/asn-real.h,v 1.5 1997/02/16 20:25:42 rj Exp $ 18 | // $Log: asn-real.h,v $ 19 | // Revision 1.5 1997/02/16 20:25:42 rj 20 | // check-in of a few cosmetic changes 21 | // 22 | // Revision 1.4 1995/07/24 17:53:59 rj 23 | // #if TCL ... #endif wrapped into #if META ... #endif 24 | // 25 | // changed `_' to `-' in file names. 26 | // 27 | // Revision 1.3 1994/10/08 04:18:09 rj 28 | // code for meta structures added (provides information about the generated code itself). 29 | // 30 | // code for Tcl interface added (makes use of the above mentioned meta code). 31 | // 32 | // virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. 33 | // 34 | // made Print() const (and some other, mainly comparison functions). 35 | // 36 | // several `unsigned long int' turned into `size_t'. 37 | // 38 | // Revision 1.2 1994/08/28 10:00:55 rj 39 | // comment leader fixed. 40 | // 41 | // Revision 1.1 1994/08/28 09:20:41 rj 42 | // first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 43 | 44 | #ifndef _asn_real_h_ 45 | #define _asn_real_h_ 46 | 47 | class AsnReal: public AsnType 48 | { 49 | protected: 50 | double value; 51 | 52 | public: 53 | AsnReal(): 54 | value (0.0) 55 | {} 56 | AsnReal (double val): 57 | value (val) 58 | {} 59 | 60 | AsnType *Clone() const; 61 | 62 | operator double() const { return value; } 63 | AsnReal &operator = (double newvalue) { value = newvalue; return *this; } 64 | 65 | AsnLen BEncContent (BUF_TYPE b); 66 | void BDecContent (BUF_TYPE b, AsnTag tagId, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); 67 | AsnLen BEnc (BUF_TYPE b); 68 | void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); 69 | 70 | void Print (std::ostream &os) const; 71 | 72 | PDU_MEMBER_MACROS 73 | 74 | #if META 75 | static const AsnRealTypeDesc _desc; 76 | 77 | const AsnTypeDesc *_getdesc() const; 78 | 79 | #if TCL 80 | int TclGetVal (Tcl_Interp *) const; 81 | int TclSetVal (Tcl_Interp *, const char *val); 82 | #endif /* TCL */ 83 | #endif /* META */ 84 | }; 85 | 86 | extern const AsnReal PLUS_INFINITY; 87 | extern const AsnReal MINUS_INFINITY; 88 | 89 | #endif /* conditional include */ 90 | -------------------------------------------------------------------------------- /asn1specs/asn-useful.asn1: -------------------------------------------------------------------------------- 1 | ASN-USEFUL DEFINITIONS ::= 2 | BEGIN 3 | 4 | -- file: .../asn1specs/asn-useful.asn1 5 | -- 6 | -- NOTE: every one of these types is marked as a PDU so the compiler 7 | -- will produce the encode and decode routines that 8 | -- enc/dec the top tag/len pairs, not just the content decoders. 9 | -- (only nec for re-generating the library files "asn_useful.[ch]"). 10 | -- The isPdu field does not affect how this module is linked 11 | -- with other modules during compilation. 12 | -- 13 | -- (type DEF comment directives immediately follow the "::=") 14 | -- 15 | -- MS 92 16 | -- 17 | -- $Header: /usr/app/odstb/CVS/snacc/asn1specs/asn-useful.asn1,v 1.3 1995/07/24 15:12:35 rj Exp $ 18 | -- $Log: asn-useful.asn1,v $ 19 | -- Revision 1.3 1995/07/24 15:12:35 rj 20 | -- useful.asn1 renamed to asn-useful.asn1 to accomodate to snacc's new file name generation scheme. 21 | -- 22 | -- Revision 1.2 1994/08/28 09:54:19 rj 23 | -- comment leader fixed. 24 | -- 25 | -- Revision 1.1 1994/08/28 09:51:15 rj 26 | -- first check-in. 27 | 28 | 29 | ObjectDescriptor ::= -- isPdu:"TRUE" -- 30 | [UNIVERSAL 7] IMPLICIT OCTET STRING 31 | 32 | NumericString ::= --snacc isPdu:"TRUE" -- 33 | [UNIVERSAL 18] IMPLICIT OCTET STRING 34 | 35 | PrintableString ::= --snacc isPdu:"TRUE" -- 36 | [UNIVERSAL 19] IMPLICIT OCTET STRING 37 | 38 | TeletexString ::= --snacc isPdu:"TRUE" -- 39 | [UNIVERSAL 20] IMPLICIT OCTET STRING 40 | 41 | T61String ::= --snacc isPdu:"TRUE" -- 42 | [UNIVERSAL 20] IMPLICIT OCTET STRING 43 | 44 | VideotexString ::= --snacc isPdu:"TRUE" -- 45 | [UNIVERSAL 21] IMPLICIT OCTET STRING 46 | 47 | IA5String ::= --snacc isPdu:"TRUE" -- 48 | [UNIVERSAL 22] IMPLICIT OCTET STRING 49 | 50 | GraphicString ::= --snacc isPdu:"TRUE" -- 51 | [UNIVERSAL 25] IMPLICIT OCTET STRING 52 | 53 | VisibleString ::= --snacc isPdu:"TRUE" -- 54 | [UNIVERSAL 26] IMPLICIT OCTET STRING 55 | 56 | ISO646String ::= --snacc isPdu:"TRUE" -- 57 | [UNIVERSAL 26] IMPLICIT OCTET STRING 58 | 59 | GeneralString ::= --snacc isPdu:"TRUE" -- 60 | [UNIVERSAL 27] IMPLICIT OCTET STRING 61 | 62 | UTCTime ::= --snacc isPdu:"TRUE" -- 63 | [UNIVERSAL 23] IMPLICIT OCTET STRING 64 | 65 | GeneralizedTime ::= --snacc isPdu:"TRUE" -- 66 | [UNIVERSAL 24] IMPLICIT OCTET STRING 67 | 68 | 69 | EXTERNAL ::= --snacc isPdu:"TRUE" -- [UNIVERSAL 8] IMPLICIT SEQUENCE 70 | { 71 | direct-reference OBJECT IDENTIFIER OPTIONAL, 72 | indirect-reference INTEGER OPTIONAL, 73 | data-value-descriptor ObjectDescriptor OPTIONAL, 74 | encoding CHOICE 75 | { 76 | single-ASN1-type [0] OCTET STRING, -- should be ANY 77 | octet-aligned [1] IMPLICIT OCTET STRING, 78 | arbitrary [2] IMPLICIT BIT STRING 79 | } 80 | } 81 | 82 | END -- of ASN-USEFUL type definitions 83 | -------------------------------------------------------------------------------- /compiler/back-ends/c++-gen/kwd.c: -------------------------------------------------------------------------------- 1 | /* 2 | * compiler/back_ends/c++_gen/kwd.c - routines for determining whether a given str is a C++ 3 | * keyword 4 | * 5 | * NOTE: this was hacked up really quickly. It uses a slow linear 6 | * search. A much better approach is to use a hash tbl. 7 | * 8 | * MS 92 9 | * Copyright (C) 1991, 1992 Michael Sample 10 | * and the University of British Columbia 11 | * 12 | * This program is free software; you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation; either version 2 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * $Header: /usr/app/odstb/CVS/snacc/compiler/back-ends/c++-gen/kwd.c,v 1.7 1995/09/07 19:05:01 rj Exp $ 18 | * $Log: kwd.c,v $ 19 | * Revision 1.7 1995/09/07 19:05:01 rj 20 | * where the C++ compiler has got the bool type built-in, let the C++ backend avoid conflicts with the new keywords. 21 | * 22 | * Revision 1.6 1995/08/17 14:56:12 rj 23 | * bool added to the list of reserved words 24 | * 25 | * Revision 1.5 1995/07/25 18:22:40 rj 26 | * file name has been shortened for redundant part: c++-gen/c++-kwd -> c++-gen/kwd. 27 | * 28 | * Revision 1.4 1995/02/17 20:10:40 rj 29 | * inclusion order fixed. 30 | * 31 | * Revision 1.3 1994/10/08 03:48:04 rj 32 | * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long. 33 | * 34 | * Revision 1.2 1994/09/01 00:19:44 rj 35 | * snacc_config.h removed; more portable .h file inclusion. 36 | * 37 | * Revision 1.1 1994/08/28 09:48:11 rj 38 | * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 39 | * 40 | */ 41 | 42 | #include "snacc.h" 43 | 44 | #if STDC_HEADERS || HAVE_STRING_H 45 | #include 46 | #else 47 | #include 48 | #endif 49 | 50 | #include "kwd.h" 51 | 52 | /* 53 | * last elmt will be NULL. 54 | * key words grabbed from C++/Stroustrup 2.0 55 | */ 56 | static char *cxxKWdG[] = 57 | { 58 | "asm", "auto", "break", "case", "catch", "char", "class", "const", 59 | "continue", "default", "delete", "do", "double", "else", "enum", 60 | "extern", "float", "for", "friend", "goto", "if", "inline", "int", 61 | "long", "new", "operator", "private", "protected", "public", 62 | "register", "return", "short", "signed", "sizeof", "static", 63 | "struct", "switch", "template", "this", "throw", "try", "typedef", 64 | "union", "unsigned", "virtual", "void", "volatile", "while", 65 | #if BOOL_BUILTIN 66 | "bool", "true", "false", 67 | #endif 68 | NULL 69 | }; 70 | 71 | 72 | /* 73 | * returns non-zero if the given str is a C++ key word 74 | */ 75 | int 76 | IsCxxKeyWord PARAMS ((str), 77 | char *str) 78 | { 79 | int i; 80 | 81 | for (i=0; (cxxKWdG[i] != NULL) && (strcmp (cxxKWdG[i],str) != 0); i++) 82 | ; 83 | 84 | return cxxKWdG[i] != NULL; 85 | } 86 | -------------------------------------------------------------------------------- /c++-lib/inc/asn-int.h: -------------------------------------------------------------------------------- 1 | // file: .../c++-lib/inc/asn-int.h - c++ version of ASN.1 integer 2 | // 3 | // MS 92/06/15 4 | // Copyright (C) 1992 Michael Sample and the University of British Columbia 5 | // 6 | // This library is free software; you can redistribute it and/or 7 | // modify it provided that this copyright/license information is retained 8 | // in original form. 9 | // 10 | // If you modify this file, you must clearly indicate your changes. 11 | // 12 | // This source code is distributed in the hope that it will be 13 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 14 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | // 16 | // $Header: /usr/app/odstb/CVS/snacc/c++-lib/inc/asn-int.h,v 1.5 1995/09/07 18:49:19 rj Exp $ 17 | // $Log: asn-int.h,v $ 18 | // Revision 1.5 1995/09/07 18:49:19 rj 19 | // long int replaced by newly introduced AsnIntType at a lot of places. 20 | // it shall provide a 32 bit integer type on all platforms. 21 | // 22 | // Revision 1.4 1995/07/24 17:53:56 rj 23 | // #if TCL ... #endif wrapped into #if META ... #endif 24 | // 25 | // changed `_' to `-' in file names. 26 | // 27 | // Revision 1.3 1994/10/08 04:18:02 rj 28 | // code for meta structures added (provides information about the generated code itself). 29 | // 30 | // code for Tcl interface added (makes use of the above mentioned meta code). 31 | // 32 | // virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included. 33 | // 34 | // made Print() const (and some other, mainly comparison functions). 35 | // 36 | // several `unsigned long int' turned into `size_t'. 37 | // 38 | // Revision 1.2 1994/08/28 10:00:49 rj 39 | // comment leader fixed. 40 | // 41 | // Revision 1.1 1994/08/28 09:20:35 rj 42 | // first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog. 43 | 44 | #ifndef _asn_int_h_ 45 | #define _asn_int_h_ 46 | 47 | class AsnInt: public AsnType 48 | { 49 | protected: 50 | AsnIntType value; 51 | 52 | public: 53 | AsnInt() {} 54 | AsnInt (AsnIntType val): 55 | value (val) 56 | {} 57 | 58 | AsnType *Clone() const; 59 | 60 | operator AsnIntType() const { return value; } 61 | AsnInt &operator = (AsnIntType newvalue) { value = newvalue; return *this; } 62 | 63 | void Set (AsnIntType i) { value = i; } 64 | void ReSet (AsnIntType i) { value = i; } 65 | 66 | AsnLen BEncContent (BUF_TYPE b); 67 | void BDecContent (BUF_TYPE b, AsnTag tagId, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env); 68 | AsnLen BEnc (BUF_TYPE b); 69 | void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env); 70 | 71 | PDU_MEMBER_MACROS 72 | 73 | void Print (std::ostream &os) const; 74 | 75 | #if META 76 | static const AsnIntTypeDesc _desc; 77 | 78 | const AsnTypeDesc *_getdesc() const; 79 | 80 | #if TCL 81 | int TclGetVal (Tcl_Interp *) const; 82 | int TclSetVal (Tcl_Interp *, const char *val); 83 | #endif /* TCL */ 84 | #endif /* META */ 85 | }; 86 | 87 | #endif /* conditional include */ 88 | --------------------------------------------------------------------------------