The following numbered explanatory text corresponds to the numbered comments in Example 5–1.
The MIME message to be decoded. It is a multipart message with two parts. The first part contains text, the second part a PostScriptTM attachment.
The private context to be passed to mtaDecodeMessage() and, in turn, passed by it to the supplied input routine, decode_read(). The input routine uses this context to track how many bytes of the input message it has supplied to mtaDecodeMessage().
The call to mtaDecodeMessage(). An input routine, decode_read(), is supplied to provide the message to be decoded. Since the message source has each record terminated by line feeds, the MTA_TERM_LF option is also specified. The routine decode_inspect() is passed for use as an inspection routine.
The input routine, decode_read(). This routine provides the message to be decoded 200 bytes at a time. Note that providing only 200 bytes at a time is arbitrary: the routine could, if it chose, provide the entire message, or 2000 bytes at a time, or a random number of bytes on each call. After the entire message has been supplied, subsequent calls to decode_read() return the MTA_EOF status.
The inspection routine, decode_inspect(). For each atomic message part, this routine is called repeatedly. The repeated calls provide, line by line, the part’s header and decoded content.
For a given message part, the final call to decode_inspect() provides no part data. This final call serves to give decode_inspect() a last chance to accept or discard the part when outputting the final form of the message via an optional output routine supplied to mtaDecodeMessage(). That optional routine is not used here.
The part number for this message part is obtained with a call to mtaDecodeMessageInfoInt().
The following shows the output generated by the program in Example 5–1.
1H: Content-type: text/plain; charset=us-ascii 1H: Content-disposition: inline 1T: This is a 1T: test message! 2H: Content-type: application/postscript 2H: Content-transfer-encoding: base64 2H: Content-disposition: attachment; filename="a.ps" 2B: #!PS 100 100 moveto 300 300 lineto stroke showpage