(RCS control information is at the end of this file.)


C++ ANY example README
---------------------

This example shows how the snacc compiler handles the ANY DEFINED BY
type in C++.  ANY types (not ANY DEFINED BY) require modifications
to the generated code.  Type "make" to build this example.

This directory should have the following 4 files in it:

        README
        example.C
        genber.C
        makefile

There are 3 programs generated by the makefile:

        genber - builds a BER value of the AnyTestType and writes it
                 to a file called "att.ber"

        def    - takes file name of an AnyTestType BER value.  Decodes the
                 file and re-encodes it to stdout.  Uses definite
                 lengths for constructed values.

        indef  - takes file name of an AnyTestType BER value.  Decodes the
                 file and re-encodes it to stdout.  Uses indefinite
                 lengths for constructed values.


These files use the code generated by snacc from the
snacc/asn1specs/any.asn1 file. (see the makefile)

Look at genber.C to see how values can be built and printed.

Look at the generated code in any_test.C and any_test.h to see how the
any hash table is built.


try the following commands in your c-shell:

%1 genber                   # generate the att.ber file
%2 indef att.ber > tmp.ber  # decode att.ber an re-encode into tmp.ber
%3 def tmp.ber > tmp2.ber   # decode tmp.ber an re-encode into tmp2.ber
%4 diff att.ber tmp2.ber    # compare .ber files (should be the same)

When you are finished with the example type "make clean"  to remove
the binaries and generated code.



Things To Note
--------------

Snacc ASN.1 comment commands

In the snacc/asn1specs/any.asn1 file, the AnyTestType has a special
"--snacc" ASN.1 comment after ::= to give snacc some extra information
about the AnyTestType.

AnyTestType ::= --snacc isPdu:"TRUE" -- SEQUENCE { ... etc. ... }

The "isPdu" flag only affects the generated C code, not C++.  Each
C++ type gets PDU methods by default.


SNMP OBJECT-TYPE Macro

The SNMP OBJECT-TYPE macro is used to define the id value to type
mapping for ANY DEFINED BY types.  The macro has been modified to
accept both INTEGERs and OBJECT IDENTIFIERs as id values (see
snacc/asn1specs/any.asn1).  This macro can be used with other
protocols to define the id to type mapping.

Two hash tables are used to hold the id to type mappings. One for
INTEGER to type mappings and the other for OBJECT IDENTIFIER to type
mappings.  The hash tables are automatically initialized in each
module that has OBJECT-TYPE macros.  In C the hash table must be
explicitly initialized.

#-------------------------------------------------------------------------------
# $Header: /cvs/Darwin/src/live/Security/SecuritySNACCRuntime/c++-examples/any/README,v 1.1.1.1 2001/05/18 23:14:05 mb Exp $
# $Log: README,v $
# Revision 1.1.1.1  2001/05/18 23:14:05  mb
# Move from private repository to open source repository
#
# Revision 1.1.1.1  1999/03/16 18:05:57  aram
# Originals from SMIME Free Library.
#
# Revision 1.2  1997/02/16 20:25:26  rj
# check-in of a few cosmetic changes
#
# Revision 1.1  1994/08/31  08:47:59  rj
# first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog.
#
