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

mtaDecodeMessageInfoParams()

Obtain an option context describing the current message part’s content parameters.

Syntax


mta_opt_t *mtaDecodeMessageInfoParams(mta_decode_t *dctx,
                                      int           item,
                                      mta_opt_t   **params);

Arguments

Arguments  

Description  

dctx

A decode context created by mtaMessageDecode().

item

Item identifier specifying which content parameter list to return. See the description that follows for the list of permitted values for this argument. 

params

An optional pointer to receive the address of the option context describing the requested parameter list. 

Description

This routine returns the parameter lists for either the Content-type: or Content-disposition: header lines. (When mtaDecodeMessage() calls either a user-supplied inspection or output routine, it provides a decode context describing the current part being processed.)

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

Values  

Description  

MTA_DECODE_CDISP_PARAMS

Parameters associated with the Content-disposition: header line, if any.

MTA_DECODE_CTYPE_PARAMS

Parameters associated with the Content-type: header line, if any.

The option context returned upon normal completion does not need to be disposed of with mtaOptionFinish(). It will automatically be disposed of by mtaDecodeMessage(). The values of individual parameters can be queried using mtaOptionString(), mtaOptionInt(), and mtaOptionFloat(). Program code need not worry about whether the underlying header line exists in the parts header. If it does not, then calls to obtain individual parameter values will succeed, but return no value.


Note –

If the Content-type: header line is not present, mtaOptionString() returns an empty string. This is in contrast to what happens when mtaDecodeMessageInfoString() is used. It always returns a value for the CHARSET parameter of the Content-type: header line. If the Content-type: header line is not present, it returns the MIME default value us-ascii.


It is important to note that the option contexts returned by this routine are only valid during the lifetime of the associated decode context. They are not valid after inspection or output of a new message part begins, nor are they valid after mtaDecodeMessage() returns.

Return Values

Upon normal, successful completion, a pointer to an option context is 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


char buf[64];

strcpy(buf, "us-ascii");
mtaOptionString(
    mtaDecodeMessageInfoParams(dctx, MTA_DECODE_CTYPE_PARAMS,
    NULL), "charset", 0, buf, NULL, sizeof(buf));
printf("Message part’s character set is %s\n", buf);