When using a caller-supplied input routine to supply the message to be decoded, specify MTA_DECODE_PROC for the input_type argument, and pass the address of the input routine as the input argument.
The following code fragment shows the syntax of a caller-supplied input routine:
int input_routine(void * ctx, const char **line, size_t * line_len); |
The following table lists the arguments for a caller-supplied input routine, and gives a description of each.
Arguments |
Description |
---|---|
ctx |
The caller-supplied private context. |
line |
A pointer to the start of the next line or section of data to return. The line or data does not need to be NULL terminated. |
line_len |
The length in bytes of the line or block of data being returned. A zero length signifies zero bytes of data. That is, a zero length does not cause mtaMessageDecode() to automatically determine the length by searching for a NULL terminator. |
On each successful call, the input routine should return a status code of 0 (MTA_OK). When there is no more message data to provide, then the input routine should return MTA_EOF. The call that returns the last byte of data should return 0; it is the subsequent call that must return MTA_EOF. In the event of an error, the input routine should return a non-zero status code other than MTA_EOF, such as MTA_NO. This will terminate the message parsing process and mtaDecodeMessage() will return an error.
By default, each block of data must be a single line of the message. This corresponds to the MTA_TERM_NONE item code. If the MTA_TERM_CR, MTA_TERM_CRLF, MTA_TERM_LF, or MTA_TERM_LFCR item code is specified, then the block of data need not correspond to a single, complete line of message data It may be a portion of a line, multiple lines, or even the entire message. See Item Codes for information about mtaDecodeMessage() item codes.