Accessing and manipulating a message's envelope


Accessing and manipulating a message's envelope

int mm_envelope_getheaders (MM_CTX *ctx, char **result, size_t *length)
int mm_envelope_setheader (MM_CTX *ctx, const char *name, const char *fmt,...)
int mm_envelope_getrecipients (MM_CTX *ctx, char **result, size_t *length)

Function Documentation

int mm_envelope_getheaders ( MM_CTX *  ctx,
char **  result,
size_t *  length 
)

Gets an ASCII representation of all envelope headers

Parameters:
ctx A valid MiniMIME context
result Where to store the resulting ASCII headers
length Where to store the length of the result
Returns:
0 on success or -1 on failure.
Note:
Sets mm_errno on failure
This is mainly a convinience function. It constructs an ASCII representation from all of the message's envelope headers and stores the result in headers. Memory is allocated dynamically, and the total length of the result is stored in length. This function takes care that the output is MIME conform, and folds long lines according to the MIME standard at position 78 of the string. It also nicely formats all MIME related header fields, such as the Content-Type header.

Since the memory needed to store the result is allocated dynamically, one should take care of freeing it again when it's not needed anymore. If an error occurs, *result will be set to NULL, *length will be set to zero and mm_errno will be set to a reasonable value.

int mm_envelope_getrecipients ( MM_CTX *  ctx,
char **  result,
size_t *  length 
)

Gets the list of recipients for a MIME message

Parameters:
ctx A valid MiniMIME context
result Where to store the result
length Where to store the length of the result
Returns:
0 on success or -1 on error
Note:
Sets mm_errno on error
This functions gets the list of recipients for a given MIME message. It does so by concatenating the "From" and "Cc" header fields, and storing the results in recipients. The memory needed to store the result is allocated dynamically, and the total length of the result is stored in length.

One should take care to free() the result once it's not needed anymore.

int mm_envelope_setheader ( MM_CTX *  ctx,
const char *  name,
const char *  fmt,
  ... 
)

Sets a header field in the envelope

Parameters:
ctx A valid MiniMIME context
name The name of the header field to set
fmt A format string specifying the value of the header field
Returns:
0 on success or -1 on failure
This function generates a new MIME header and attaches it to the first MIME part (the envelope) found in the given context. If no part is attached already, the function will return an error. The function will store a copy of ``name'' as the header's name field, and dynamically allocate the memory needed to build the format string.


Generated on Thu Mar 29 17:59:08 2007 for MiniMIME by  doxygen 1.5.1