The rtxContext.h file contains the definition of the runtime context block structure – OSCTXT. This structure is used in practically all runtime function calls. It provides a common work area for the functions to preserve state information needed in the encoding or decoding of messages.
A brief description of some of the key fields within this structure is as follows:
buffer – This contains information on the memory buffer to which a message is being encoded or holds an in-memory copy of a message being decoded. This may also be used as a temporary buffer if stream-based encoding or decoding is being done. The OSBuffer structure contains a data pointer to the memory buffer itself as well as the current byte index and bit offset.
savedInfo – This is used to save a copy of the buffer information in places where an alternate buffer may need to be substituted. Sometimes it is possible to save the buffer information on the stack, but there are instances where this variable is needed for that purpose.
errInfo – This is a stack containing information on errors that were encountered in formatting or parsing a message. The OSErrInfo type contains a status code, run-time error parameter stack, and an error location stack that is used to save source file/line number information so that a trace stack can be provided in the error message print routine.
pMemHeap – This is a pointer to the memory heap managed by the runtime software. This tracks all of the memory usage used in the encoding or decoding of a specific message. See the section on memory management functions for more details on this.
level – This variable contains the current nesting level of the data within the current XML or other message type that is being encoded or decoded.
state – This is used to hold the current processing state when parsing an XML message. It is primarily used in SAX parsing to determine if the last element parsed was a start tag, data, or end tag.
pStream – This is used to hold information about an input or output stream if data is being directly read from or written to a stream. See the section on stream handling functions for more details on this.
pAppInfo – This is reserved for application specific information.