Chapter 13. Event Handler Interface

Table of Contents

How it Works
How to Use It

The –events command line switch causes hooks for user-defined event handlers to be inserted into the generated decode functions. What these event handlers do is up to the user. They fire when key message-processing events or errors occur during the course of parsing an ASN.1 message. They are similar in functionality to the Simple API for XML (SAX) that was introduced to provide a simple interface for parsing XML messages.

The -notypes option can be used in conjunction with the -events option to generate pure parsing functions. In this case, no C types or encode or decode functions are generated for the productions within the given ASN.1 source file. Instead, only a set of parser functions are generated that invoke the event handler callback functions. This gives the user total control over what is done with the message data. Data that is not needed can be discarded and only the parts of the message needed for a given application need to be saved.