]> git.saurik.com Git - apple/security.git/blame - SecuritySNACCRuntime/c-examples/any/README
Security-54.1.3.tar.gz
[apple/security.git] / SecuritySNACCRuntime / c-examples / any / README
CommitLineData
bac41a7b
A
1(RCS control information is at the end of this file.)
2
3
4C ANY example README
5------------------
6
7This example shows how the snacc compiler handles the ANY DEFINED BY
8type in C. ANY types (not ANY DEFINED BY) require the modifications
9to the generated code. Type "make" to build this example.
10
11This directory should have the following files in it:
12
13 README
14 genber.c
15 example.c
16 makefile
17
18There 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 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 value. Decodes the
28 file and re-encodes it to stdout. Uses indefinite
29 lengths for constructed values.
30
31
32These files use the code generated by snacc from the
33snacc/asn1specs/any.asn1 file. (see the makefile)
34
35Look at genber.c to see how values can be built and printed.
36
37Look at the generated code in any_test.c and any_test.h to see how the
38any hash table is built.
39
40
41try 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
48When you are finished with the example type "make clean" to remove
49the binaries and generated code.
50
51
52
53Things To Note
54--------------
55
56Snacc ASN.1 comment commands
57
58In the snacc/asn1specs/any.asn1 file, the AnyTestType has a special
59"--snacc" ASN.1 comment after ::= to give snacc some extra information
60about the AnyTestType.
61
62AnyTestType ::= --snacc isPdu:"TRUE" -- SEQUENCE { ... etc. ... }
63
64The "isPdu" flag tells snacc that the AnyTestType is a PDU type that
65you will be calling the encoding and decoding routines directly
66from your code. This causes snacc to generate the "BEncAnyTestType"
67and "BDecAnyTestType" routines in addition to the standard
68"BEncAnyTestTypeContent" and "BDecAnyTestTypeContent".
69
70The Content encoding and decoding routines only deal with the content
71of the type, ignoring all of the tag and length pairs on the given
72type (in this case the UNIVERSAL (CONSTRUCTED) 16 tag and the length
73for the SEQUENCE). The "BEncAnyTestType" and "BDecAnyTestType"
74routines do encode the SEQUENCE tag and its length. This design is
75motivated by IMPLICIT tagging.
76
77The compiler generated routines generally only call the content
78oriented routines except in the case of ANY and ANY DEFINED BY types.
79For ANY and ANY DEFINED BY types the PDU form of the rouine is called
80since the tags are not known by the containing type.
81
82
83SNMP OBJECT-TYPE Macro
84
85The SNMP OBJECT-TYPE macro is used to define the id to type mapping
86for ANY DEFINED BY types. The macro has been modified to accept both
87INTEGERs and OBJECT IDENTIFIERs as values (see
88snacc/asn1specs/any.asn1). This macro can be used with other
89protocols to define the id to type mapping.
90
91Two hash tables are used to hold the id to type mappings. One for
92INTEGER to type mappings and the other for OBJECT IDENTIFIER to type
93mappings. You must explicitly initialize the hash tables by calling
94generated init routines once at the beginning of your program. Each
95module that has OBJECT-TYPE macros in it will generate an
96"InitAny<module name>" routine. You must call every init routine to
97add all the mappings to the hash table(s).
98
99#-------------------------------------------------------------------------------
5a719ac8 100# $Header: /cvs/Darwin/src/live/Security/SecuritySNACCRuntime/c-examples/any/README,v 1.1.1.1 2001/05/18 23:14:07 mb Exp $
bac41a7b
A
101# $Log: README,v $
102# Revision 1.1.1.1 2001/05/18 23:14:07 mb
103# Move from private repository to open source repository
104#
105# Revision 1.1.1.1 1999/03/16 18:06:08 aram
106# Originals from SMIME Free Library.
107#
108# Revision 1.2 1997/02/16 20:26:14 rj
109# check-in of a few cosmetic changes
110#
111# Revision 1.1 1994/08/31 08:46:17 rj
112# first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog.
113#