]> git.saurik.com Git - apple/security.git/blob - SecuritySNACCRuntime/c++-examples/any/README
Security-28.tar.gz
[apple/security.git] / SecuritySNACCRuntime / c++-examples / any / README
1 (RCS control information is at the end of this file.)
2
3
4 C++ ANY example README
5 ---------------------
6
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.
10
11 This directory should have the following 4 files in it:
12
13 README
14 example.C
15 genber.C
16 makefile
17
18 There are 3 programs generated by the makefile:
19
20 genber - builds a BER value of the AnyTestType and writes it
21 to a file called "att.ber"
22
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.
26
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.
30
31
32 These files use the code generated by snacc from the
33 snacc/asn1specs/any.asn1 file. (see the makefile)
34
35 Look at genber.C to see how values can be built and printed.
36
37 Look at the generated code in any_test.C and any_test.h to see how the
38 any hash table is built.
39
40
41 try the following commands in your c-shell:
42
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)
47
48 When you are finished with the example type "make clean" to remove
49 the binaries and generated code.
50
51
52
53 Things To Note
54 --------------
55
56 Snacc ASN.1 comment commands
57
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.
61
62 AnyTestType ::= --snacc isPdu:"TRUE" -- SEQUENCE { ... etc. ... }
63
64 The "isPdu" flag only affects the generated C code, not C++. Each
65 C++ type gets PDU methods by default.
66
67
68 SNMP OBJECT-TYPE Macro
69
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.
75
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.
81
82 #-------------------------------------------------------------------------------
83 # $Header: /cvs/Darwin/Security/SecuritySNACCRuntime/c++-examples/any/README,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $
84 # $Log: README,v $
85 # Revision 1.1.1.1 2001/05/18 23:14:05 mb
86 # Move from private repository to open source repository
87 #
88 # Revision 1.1.1.1 1999/03/16 18:05:57 aram
89 # Originals from SMIME Free Library.
90 #
91 # Revision 1.2 1997/02/16 20:25:26 rj
92 # check-in of a few cosmetic changes
93 #
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.
96 #