Sun Java System Messaging Server 6 2005Q4 MTA Developer's Reference

mtaDecodeMessageInfoString()

Obtain string-valued information relating to the current message part.

Syntax


const char *mtaDecodeMessageInfoString(mta_decode_t *dctx,
                                       int           item,
                                       const char  **str,
                                       size_t       *len);

Arguments

Arguments  

Description  

dctx

A decode context created by mtaMessageDecode().

item

Item identifier specifying which string-value item to return. See the description that follows for the list of permitted values for this argument. 

str

An optional pointer to receive the address of the requested string. The string will be NULL terminated. A value of NULL may be passed for this argument. 

len

An optional pointer to receive the length of the requested string. This length is measured in bytes and does not include the NULL terminator at the end of the string. A value of NULL may be passed for this argument. 

Description

This routine is used to obtain string-valued information about the current message part. (When mtaDecodeMessage() calls either a user-supplied inspection or output routine, it provides a decode context describing the current message part being processed.)

The following table lists the values for the item call argument, and gives a description of each.

Values  

Description  

MTA_DECODE_CCHARSET

The character set specified with the CHARSET parameter of the part’s Content-type: header line. If the part lacks a CHARSET specification, then the value us-ascii will be returned.

MTA_DECODE_CDISP

Value of the Content-disposition: header line, less any optional parameters. If the part lacks a Content-disposition: header line, the returned value will be a zero length string.

MTA_DECODE_CSUBTYPE

The content subtype specified with the part’s Content-type: header line (for example, plain for text/plain, gif for image/gif). Defaults to plain when the part lacks a Content-type: header line.

MTA_DECODE_CTYPE

The major content type specified with the part’s Content-type: header line (for example, text for text/plain, image for image/gif). Defaults to text when the part lacks a Content-type: header line.

Return Values

mtaDecodeMessageInfoString() always returns a value for the CHARSET parameter of the Content-type: header line. When the Content-type: header line is not present, it returns the MIME default value, us-ascii.

Upon normal, successful completion a pointer to the requested string is returned. In addition, if pointers were provided in the str and len call arguments, the address of the string and its length are returned.

In the event of an error, a NULL value is returned and mta_errno is set to indicate the error status code. The following table lists the error status codes, and gives a description of each.

Error Status Codes  

Description  

MTA_BADARGS

A NULL value was supplied for the dctx call argument, or an invalid decode context was supplied for dctx.

MTA_NOSUCHITEM

An invalid value was supplied for the item call argument.

Example


printf("The message part’s character set is %s\n",
       mtaDecodeMessageInfoString(dctx, MTA_DECODE_CCHARSET,
                                  NULL, NULL));