1 (RCS control information is at the end of this file.)
7 This example shows how the snacc compiler handles the ANY DEFINED BY
8 type in C++. ANY types (not ANY DEFINED BY) require modifications
9 to the generated code. Type "make" to build this example.
11 This directory should have the following 4 files in it:
18 There are 3 programs generated by the makefile:
20 genber - builds a BER value of the AnyTestType and writes it
21 to a file called "att.ber"
23 def - takes file name of an AnyTestType BER value. Decodes the
24 file and re-encodes it to stdout. Uses definite
25 lengths for constructed values.
27 indef - takes file name of an AnyTestType BER value. Decodes the
28 file and re-encodes it to stdout. Uses indefinite
29 lengths for constructed values.
32 These files use the code generated by snacc from the
33 snacc/asn1specs/any.asn1 file. (see the makefile)
35 Look at genber.C to see how values can be built and printed.
37 Look at the generated code in any_test.C and any_test.h to see how the
38 any hash table is built.
41 try the following commands in your c-shell:
43 %1 genber # generate the att.ber file
44 %2 indef att.ber > tmp.ber # decode att.ber an re-encode into tmp.ber
45 %3 def tmp.ber > tmp2.ber # decode tmp.ber an re-encode into tmp2.ber
46 %4 diff att.ber tmp2.ber # compare .ber files (should be the same)
48 When you are finished with the example type "make clean" to remove
49 the binaries and generated code.
56 Snacc ASN.1 comment commands
58 In the snacc/asn1specs/any.asn1 file, the AnyTestType has a special
59 "--snacc" ASN.1 comment after ::= to give snacc some extra information
60 about the AnyTestType.
62 AnyTestType ::= --snacc isPdu:"TRUE" -- SEQUENCE { ... etc. ... }
64 The "isPdu" flag only affects the generated C code, not C++. Each
65 C++ type gets PDU methods by default.
68 SNMP OBJECT-TYPE Macro
70 The SNMP OBJECT-TYPE macro is used to define the id value to type
71 mapping for ANY DEFINED BY types. The macro has been modified to
72 accept both INTEGERs and OBJECT IDENTIFIERs as id values (see
73 snacc/asn1specs/any.asn1). This macro can be used with other
74 protocols to define the id to type mapping.
76 Two hash tables are used to hold the id to type mappings. One for
77 INTEGER to type mappings and the other for OBJECT IDENTIFIER to type
78 mappings. The hash tables are automatically initialized in each
79 module that has OBJECT-TYPE macros. In C the hash table must be
80 explicitly initialized.
82 #-------------------------------------------------------------------------------
83 # $Header: /cvs/Darwin/Security/SecuritySNACCRuntime/c++-examples/any/README,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $
85 # Revision 1.1.1.1 2001/05/18 23:14:05 mb
86 # Move from private repository to open source repository
88 # Revision 1.1.1.1 1999/03/16 18:05:57 aram
89 # Originals from SMIME Free Library.
91 # Revision 1.2 1997/02/16 20:25:26 rj
92 # check-in of a few cosmetic changes
94 # Revision 1.1 1994/08/31 08:47:59 rj
95 # first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog.