1SNACC(1) General Commands Manual SNACC(1)
2
3
4
6 snacc - ASN.1 to C, C++ or type table Compiler
7
9 snacc [-h] [-P] [-t] [-e] [-d] [-p] [-f]
10 [-c | -C | -idl | -T <table output file>]
11 [-u <useful types ASN.1 file>]
12 [-mf <max file name len>]
13 [-l <neg number>]
14 [-meta] [-tcl <module.type>]
15 [-novolat]
16 <ASN.1 file list>
17
20 Snacc (Sample Neufeld Asn.1 to C/C++ Compiler) generates C or C++
21 source code for BER encode and decode routines as well as print and
22 free routines for each type in the given ASN.1 modules. Alternatively,
23 snacc can produce type tables that can be used for table based/inter‐
24 preted encoding and decoding. The type table based methods tend to be
25 slower than their C or C++ counterparts but they usually use less mem‐
26 ory (table size vs. C/C++ object code).
27
28 Most of the 1990 ASN.1 features are parsed although some do not affect
29 the generated code. Fairly rigourous error checking is performed on
30 the ASN.1 source; any errors detected will be reported (printed to
31 stderr).
32
33 Each file in the ASN.1 file list should contain a complete ASN.1 mod‐
34 ule. ASN.1 modules that use the IMPORTS feature must be compiled
35 together (specify all necessary modules in the ASN.1 file list). The
36 generated source files will include each module's header file in the
37 command line order. This makes it important to order the modules from
38 least dependent to most dependent on the command line to avoid type
39 ordering problems. Currently, snacc assumes that each ASN.1 file given
40 on the command line depends on all of the others on the command line.
41 No attempt is made to only include the header files from modules refer‐
42 enced in the import list for that module.
43
44 If the target language is C, snacc will generate a .h and .c file for
45 each specified ASN.1 module. If the target language is C++, snacc will
46 generate a .h and .C file for each module. The generated file names
47 will be derived from the module names.
48
49
51 -h Help. Prints a synopsis of snacc and exits.
52
53 -c Generate C source code. This is the default behaviour of snacc.
54 Only one of -c , -C or -T should be specified.
55
56 -C Generate C++ source code.
57
58 -novolat
59 Generate ``return *this'' after calling ``abort()''. (Some bro‐
60 ken compilers don't know about volatile functions, or their
61 abort() isn't correctly typed.)
62
63 -meta Generate meta code that describes the generated types. Implies
64 -C.
65
66 -tcl module.type[,module.type] Generate code for a Tcl interpreter
67 where module.type are the top level PDUs. Implies -meta.
68
69 -T file
70 This causes snacc to generate type tables and write them to the
71 given file.
72
73 -P This causes snacc to print the parsed ASN.1 modules to stdout
74 after the types have been linked, sorted, and processed. This
75 option is useful for debugging snacc and observing the modifica‐
76 tions snacc performs on the types to make code generation sim‐
77 pler.
78
79 -t Generate type definitions in the target language for each ASN.1
80 type.
81
82 -v Generate value definitions in the target language for each ASN.1
83 value. Currently value definitions are limited to INTEGERs,
84 BOOLEANs and OBJECT IDENTIFIERs.
85
86 -e Generate encode routines in the target language for each ASN.1
87 type.
88
89 -d Generate decode routines in the target language for each ASN.1
90 type.
91
92 -p Generate print routines in the target language for each ASN.1
93 type.
94
95 -f Generate free routines in the target language for each ASN.1
96 type. This option only works when the target language is C.
97
98 If none of the -t, -v, -e, -d, -p, or -f options are given on
99 the command line, snacc assumes that all of them are in effect.
100 They do not affect type table generation.
101
102 -u file
103 Read the useful types definitions from the ASN.1 module in file
104 file for linking purposes. For some ASN.1 specifications, such
105 as SNMP, the useful types are not needed. The types in the given
106 useful types file are globally available to all modules; a use‐
107 ful type definition is overridden by a local or explicitly
108 imported type with the same name. The current list of useful
109 types is:
110 ObjectDecscriptor
111 NumericString
112 PrintableString
113 TeletexString
114 T61String
115 VideoTexString
116 IA5String
117 GraphicString
118 ISO646String
119 GeneralString
120 UTCTime
121 GeneralizedTime
122 EXTERNAL
123
124 -mf number
125 This causes the generated source files to have a maximum length
126 of number characters, including their suffix. The number must
127 be at least 3. This option is useful for supporting operating
128 systems that only support short file names. A better solution
129 is to shorten the module name of each ASN.1 module.
130
131
132 -l number
133 This is fairly obscure but may be useful. Each error that the
134 decoders can report is given an id number. The number number is
135 where the error ids start decreasing from as they are assigned
136 to errors . The default is -100 if this option is not given.
137 Avoid using a number in the range -100 to 0 since they may con‐
138 flict with the library routines' error ids. If you are re-com‐
139 piling the useful types for the library use -50. Another use of
140 this option is to integrate newly generated code with older
141 code; if done correctly, the error ids will not conflict.
142
143
145 snacc/asn1specs/asn-useful.asn1
146 ASN.1 useful types module (use with -u
147 option)
148 snacc/c-lib/inc/ C runtime library include files
149 snacc/c-lib/libasn1csbuf.a C SBuf runtime library
150 snacc/c-lib/libasn1cmbuf.a C MinBuf runtime library
151 snacc/c-lib/libasn1cebuf.a C ExpBuf runtime library
152 snacc/c++-lib/inc/ C++ runtime library include files
153 snacc/c++-lib/libasn1c++.a C++ runtime library
154 snacc/c-lib/inc/tbl*/ Type table runtime library include files
155 snacc/c-lib/libasn1ctbl.a Type table runtime library
156 snacc/tbl-tools/ Source code for table based tools (mkchdr,
157 ptbl, pval)
158 snacc/c-examples/ directory with ASN.1 to C examples
159 snacc/c++-examples/ directory with ASN.1 to C++ examples
160 snacc/tbl-example directory with an ASN.1 to type table exam‐
161 ple
162 snacc/doc directory with snacc documentation and this
163 man page
164
166 Snacc has problems with the following case:
167
168 Foo ::= SEQUENCE
169 {
170 id IdType,
171 val ANY DEFINED BY id
172 }
173
174 IdType ::= CHOICE
175 {
176 a INTEGER,
177 b OBJECT IDENTIFIER
178 }
179
180 The error checking pass will print an error to the effect that the id
181 type must be INTEGER or OBJECT IDENTIFER. To fix this you must modify
182 the error checking pass as well as the code generation pass. To be
183 cheap about it, disable/fix the error checking and hand modify the gen‐
184 erated code.
185
186 The hashing code used for handling ANY DEFINED BY id to type mappings
187 will encounter problems if the hash table goes more than four levels
188 deep (I think this is unlikely). To fix this just add linear chaining
189 at fourth level.
190
191 Please send bug reports or comments to Robert Joop <rj@rainbow.in-
192 berlin.de>. See the documentation about reporting bugs and (lack of)
193 support.
194
196 Copyright (c) 1993 Mike Sample and the University of British Columbia
197 Copyright (c) 1994 1995 Robert Joop and GMD Fokus.
198
199 Permission is granted to make and distribute verbatim copies of this
200 manual provided the copyright notice and this permission notice are
201 preserved on all copies.
202
203 Permission is granted to copy and distribute modified versions of this
204 manual under the conditions for verbatim copying, provided that the
205 entire resulting derived work is distributed under the terms of a per‐
206 mission notice identical to this one.
207
208 The snacc compiler is released under the GNU General Public License.
209 The runtime libraries are no longer under the GNU Library General Pub‐
210 lic License. The generated code is yours.
211
213 Snacc was written by Mike Sample at the University of British Columbia
214 (UBC). He used it as a tool to do encoding/decoding performance
215 research.
216
217 It was augmented by Robert Joop at GMD Fokus with the help of some of
218 its project partners.
219
221 This work was made possible by grants from the Canadian Institute for
222 Telecommunications Research (CITR) and Natural Sciences and Engineering
223 Research Council of Canada (NSERC).
224
225
226
227 11 July 1993 SNACC(1)