1 .\" Copyright (c) 1993 by Mike Sample and UBC
2 .\" See section COPYING for conditions for redistribution
3 .\" $Header: /cvs/Darwin/Security/SecuritySNACCRuntime/doc/snacc.1,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $
5 .\" Revision 1.1.1.1 2001/05/18 23:14:10 mb
6 .\" Move from private repository to open source repository
8 .\" Revision 1.1.1.1 1999/03/16 18:05:54 aram
9 .\" Originals from SMIME Free Library.
11 .\" Revision 1.3 1997/02/16 15:26:26 rj
12 .\" made return *this after calling abort()'' a compile time option.
14 .\" Revision 1.2 1997/01/01 22:47:16 rj
17 .TH SNACC 1 "11 July 1993"
19 snacc \- ASN.1 to C, C++ or type table Compiler
22 snacc [\-h] [\-P] [\-t] [\-e] [\-d] [\-p] [\-f]\p
23 [\-c | \-C | \-idl | \-T <table output file>]\p
24 [\-u <useful types ASN.1 file>]\p
25 [\-mf <max file name len>]\p
27 [\-meta] [\-tcl <module.type>]\p
31 For complete and current documentation, refer to the snacc manual.
34 Snacc (Sample Neufeld Asn.1 to C/C++ Compiler) generates C or C++
35 source code for BER encode and decode routines as well as print and
36 free routines for each type in the given ASN.1 modules.
37 Alternatively, snacc can produce type tables that can be used for
38 table based/interpreted encoding and decoding. The type table based
39 methods tend to be slower than their C or C++ counterparts but they
40 usually use less memory (table size vs. C/C++ object code).
42 Most of the 1990 ASN.1 features are parsed although some do not affect
43 the generated code. Fairly rigourous error checking is performed on
44 the ASN.1 source; any errors detected will be reported (printed to
47 Each file in the ASN.1 file list should contain a complete ASN.1
48 module. ASN.1 modules that use the IMPORTS feature must be compiled
49 together (specify all necessary modules in the ASN.1 file list). The
50 generated source files will include each module's header file in the
51 command line order. This makes it important to order the modules from
52 least dependent to most dependent on the command line to avoid type
53 ordering problems. Currently, snacc assumes that each ASN.1 file
54 given on the command line depends on all of the others on the command
55 line. No attempt is made to only include the header files from
56 modules referenced in the import list for that module.
58 If the target language is C, snacc will generate a \c
62 file for each specified ASN.1 module. If the target language is C++,
67 file for each module. The generated file names will be derived from the
74 Help. Prints a synopsis of snacc and exits.
77 Generate C source code. This is the default behaviour of snacc.
87 Generate C++ source code.
90 Generate ``return *this'' after calling ``abort()''.
91 (Some broken compilers don't know about volatile functions, or their abort() isn't correctly typed.)
94 Generate meta code that describes the generated types.
98 .IR module.type [, module.type ]
99 Generate code for a Tcl interpreter where \fImodule.type\fP are the top level PDUs.
103 This causes snacc to generate type tables and write them to the given
107 This causes snacc to print the parsed ASN.1 modules to stdout after
108 the types have been linked, sorted, and processed. This option is
109 useful for debugging snacc and observing the modifications snacc
110 performs on the types to make code generation simpler.
113 Generate type definitions in the target language for each ASN.1 type.
116 Generate value definitions in the target language for each ASN.1 value.
117 Currently value definitions are limited to INTEGERs, BOOLEANs and
121 Generate encode routines in the target language for each ASN.1 type.
124 Generate decode routines in the target language for each ASN.1 type.
127 Generate print routines in the target language for each ASN.1 type.
130 Generate free routines in the target language for each ASN.1 type.
131 This option only works when the target language is C.
134 .B \-t, \-v, \-e, \-d, \-p, or \-f
136 the command line, snacc assumes that all of them are in effect.
137 They do not affect type table generation.
140 \&Read the useful types definitions from the ASN.1 module in file \c
142 \& for linking purposes. For some ASN.1 specifications, such as SNMP,
143 the useful types are not needed. The types in the given useful types
144 file are globally available to all modules; a useful type definition
145 is overridden by a local or explicitly imported type with the same
146 name. The current list of useful types is:
176 \&This causes the generated source files to have a
179 characters, including their suffix. The \c
181 must be at least 3. This option is useful for supporting operating
182 systems that only support short file names. A better solution is to
183 shorten the module name of each ASN.1 module.
187 \&This is fairly obscure but may be useful. Each error that the
188 decoders can report is given an id number. The number \c
190 is where the error ids start decreasing from as they are assigned to
191 errors . The default is -100 if this option is not given. Avoid
192 using a number in the range -100 to 0 since they may conflict with the
193 library routines' error ids. If you are re-compiling the useful types
194 for the library use -50. Another use of this option is to integrate
195 newly generated code with older code; if done correctly, the error ids
199 .\" there is a tab between the file name and the description
203 .B snacc/asn1specs/asn-useful.asn1
204 ASN.1 useful types module (use with \-u option)
207 C runtime library include files
209 .B snacc/c-lib/libasn1csbuf.a
210 C SBuf runtime library
212 .B snacc/c-lib/libasn1cmbuf.a
213 C MinBuf runtime library
215 .B snacc/c-lib/libasn1cebuf.a
216 C ExpBuf runtime library
218 .B snacc/c++-lib/inc/
219 C++ runtime library include files
221 .B snacc/c++-lib/libasn1c++.a
224 .B snacc/c-lib/inc/tbl*/
225 Type table runtime library include files
227 .B snacc/c-lib/libasn1ctbl.a
228 Type table runtime library
231 Source code for table based tools (mkchdr, ptbl, pval)
234 directory with ASN.1 to C examples
236 .B snacc/c++-examples/
237 directory with ASN.1 to C++ examples
240 directory with an ASN.1 to type table example
243 directory with snacc documentation and this man page
246 Snacc has problems with the following case:
253 val ANY DEFINED BY id
264 The error checking pass will print an error to the effect that the id
265 type must be INTEGER or OBJECT IDENTIFER. To fix this you must modify
266 the error checking pass as well as the code generation pass. To be
267 cheap about it, disable/fix the error checking and hand modify the
270 The hashing code used for handling ANY DEFINED BY id to type mappings
271 will encounter problems if the hash table goes more than four levels
272 deep (I think this is unlikely). To fix this just add linear chaining
275 Please send bug reports or comments to
276 .\".BR snacc-bugs@cs.ubc.ca .
277 .BR "Robert Joop <rj@rainbow.in-berlin.de>" .
278 See the documentation about reporting bugs and (lack of) support.
280 Copyright (c) 1993 Mike Sample and the University of British Columbia
282 Copyright (c) 1994 1995 Robert Joop and GMD Fokus.
284 Permission is granted to make and distribute verbatim copies of
285 this manual provided the copyright notice and this permission notice
286 are preserved on all copies.
288 Permission is granted to copy and distribute modified versions of this
289 manual under the conditions for verbatim copying, provided that the
290 entire resulting derived work is distributed under the terms of a
291 permission notice identical to this one.
293 The snacc compiler is released under the GNU General Public License.
294 The runtime libraries are no longer under the GNU Library General
295 Public License. The generated code is yours.
297 Snacc was written by Mike Sample at the University of British Columbia
298 (UBC). He used it as a tool to do encoding/decoding performance
301 It was augmented by Robert Joop at GMD Fokus with the help of some of its project partners.
303 This work was made possible by grants from the Canadian Institute for
304 Telecommunications Research (CITR) and Natural Sciences and
305 Engineering Research Council of Canada (NSERC).