The -print option causes functions to be generated that print the contents of variables of generated types to the standard output device. It is possible to specify the name of a .c or .cpp file as an argument to this option to specify the name of the file to which these functions will be written. This is an optional argument. If not specified, the functions are written to separate files for each module in the source file. The format of the name of each file is <module>Print.c. If an output filename is specified after the –print qualifier, all functions are written to that file.
The format of the name of each generated print function is as follows:
asn1Print_[<prefix>]<prodName>
where <prodName>
is the name of the ASN.1 production for which the
function is being generated and <prefix>
is an optional prefix that can
be set via a configuration file setting. The configuration setting used to set the
prefix is the <typePrefix> element. This element specifies a prefix that will be
applied to all generated typedef names and function names for the production.
The calling sequence for each generated print function is as follows:
asn1Print_<name> (const char* name, <name>* pvalue)
In this definition, <name> denotes the prefixed production name defined above.
The name argument is used to hold the top-level name of the variable being printed. It is typically set to the same name as the pvalue argument in quotes (for example, to print an employee record, a call to asn1Print_Employee (“employee”, &employee) might be used).
The pvalue argument is used to pass a pointer to a variable of the item to be printed.
If C++ code generation is specified, a Print method is added to the ASN1C control class for the type. This method takes only a name argument; the pvalue argument is obtained from the msgData reference contained within the class.