PMDF_decode_message may be used to decode a MIME message. Example
programs illustrating the use of this routine are given in the files
api_example9.pas and api_example10.c and may
be found in the PMDF_ROOT:[doc.examples] directory on
OpenVMS systems or, on UNIX and NT systems, in the
/pmdf/doc/examples directory. Each line of the message to
be decoded may come from either a message currently being dequeued or
from an arbitrary source. If the former, then supply the message
dequeue context generated by PMDF_dequeue_initialize and specify zero
for the input_line argument. The message being
dequeued must have its read point positioned at the start of the
message's outer header. That is the position the read point will be at
after the last envelope recipient address has been read with
PMDF_get_recipient or after calling PMDF_rewind_message. To decode a
message from an arbitrary source, specify zero for the
dq_context argument, and supply with
input_line the address of a procedure to call to
obtain each successive line of the message. The input procedure must be
of the form
int input_line (param, line, len)
void *param
char *line;
int *line_len;
When the procedure is called, param will have the value of
the parameter supplied to PMDF_decode_message with the
param argument, line will be the address
of a buffer to place the message line into, and *line_len
will be the maximum number of bytes which can be written to the buffer.
On output, the procedure should return in *line_len the
number of bytes placed into the buffer. The buffer does not need to be
zero terminated. Finally the procedure should return a value of
PMDF__OK if there is more data to read and PMDF__EOF if there is an
error or no further data to read. The procedures referenced by
output_header, output_line, and
output_block have the form
int output_header (param, hdr, part, depth, index)
void *param;
PMDF_hdr *hdr;
int part;
int depth;
int index;
int output_line (param, line, line_len)
void *param;
char *line;
int line_len;
int output_block (param, data, data_len)
void *param;
char *data;
int data_len;
where the arguments are as follows:
param
|
Value passed to PMDF_decode_message for the
param argument.
|
hdr
|
Pointer to a PMDF_hdr structure containing the header lines to output. |
part
|
Will have the value 2 if the message part associated with the header is textual in nature and the value 1 if the associated part is binary in nature. |
depth
|
Nesting depth in the MIME structure for this message part. |
index
|
Index for this part; first message part at depth N has an index value of 1, second part at depth N has an index value of 2,
etc..
|
line
|
Line of text output. This text comes from the content of a non-binary message part. The line is not null terminated. |
line_len
|
Length in bytes of the line of message text to output. |
data
|
Raw binary data to output. This data comes from the content of a binary data part. The data is not null terminated and may contain nulls within it. |
data_len
|
Length in bytes of the data to output. |
The output routines should return an odd-valued result (e.g.,
1, PMDF__OK) when successful, and an even-valued result otherwise
(e.g., 0, PMDF__NO). When an even-valued result is returned by
an output routine, PMDF_decode_message will abort the decode operation
and return to the caller the value returned by the output routine. When
the lowest bit of flags is set to 1, a message in any
of the various formats which PMDF understands (e.g., RFC 1154,
Pathworks, NeXT, etc.) will be first translated to MIME prior
to decoding. Furthermore, if the message does not have a recognized
format, but does contain embedded information encoded with UUENCODE or
BINHEX, then the message will be converted to MIME prior to decoding
with the encoded material placed in a separate attachment.
Return Values