Accessing and manipulating MIME contexts


Manipulating MiniMIME contexts

MM_CTX * mm_context_new (void)
void mm_context_free (MM_CTX *ctx)
int mm_context_attachpart (MM_CTX *ctx, struct mm_mimepart *part)
int mm_context_attachpart_after (MM_CTX *ctx, struct mm_mimepart *part, int pos)
int mm_context_deletepart (MM_CTX *ctx, int which, int freemem)
int mm_context_countparts (MM_CTX *ctx)
mm_mimepart * mm_context_getpart (MM_CTX *ctx, int which)
int mm_context_iscomposite (MM_CTX *ctx)
int mm_context_haswarnings (MM_CTX *ctx)
int mm_context_generateboundary (MM_CTX *ctx)
int mm_context_setpreamble (MM_CTX *ctx, char *preamble)
char * mm_context_getpreamble (MM_CTX *ctx)
int mm_context_flatten (MM_CTX *ctx, char **flat, size_t *length, int flags)

Detailed Description

Each message in MiniMIME is represented by a so called ``context''. A context holds all necessary information given about a MIME message, such as the envelope, all MIME parts etc.

Function Documentation

int mm_context_attachpart ( MM_CTX *  ctx,
struct mm_mimepart *  part 
)

Attaches a MIME part object to a MiniMIME context.

Parameters:
ctx the MiniMIME context
part the MIME part object to attach
Returns:
0 on success or -1 on failure. Sets mm_errno on failure.
This function attaches a MIME part to a context, appending it to the end of the message.

The MIME part should be initialized before attaching it using mm_mimepart_new().

int mm_context_attachpart_after ( MM_CTX *  ctx,
struct mm_mimepart *  part,
int  pos 
)

Attaches a MIME part object to a MiniMIME context at a given position

Parameters:
ctx A valid MiniMIME context
part The MIME part object to attach
pos After which part to attach the object
Returns:
0 on success or -1 if the given position is invalid
See also:
mm_context_attachpart
This function attaches a MIME part object after a given position in the specified context. If the position is invalid (out of range), the part will not get attached to the message and the function returns -1. If the index was in range, the MIME part will get attached after the MIME part at the given position, moving any possible following MIME parts one down the hierarchy.

int mm_context_countparts ( MM_CTX *  ctx  ) 

Counts the number of attached MIME part objects in a given MiniMIME context

Parameters:
ctx The MiniMIME context
Returns:
The number of attached MIME part objects

int mm_context_deletepart ( MM_CTX *  ctx,
int  which,
int  freemem 
)

Deletes a MIME part object from a MiniMIME context

Parameters:
ctx A valid MiniMIME context object
which The number of the MIME part object to delete
freemem Whether to free the memory associated with the MIME part object
Returns:
0 on success or -1 on failure. Sets mm_errno on failure.
This function deletes a MIME part from a given context. The MIME part to delete is specified as numerical index by the parameter ``which''. If the parameter ``freemem'' is set to anything greater than 0, the memory that is associated will be free'd by using mm_mimepart_free(), otherwise the memory is left untouched (if you still have a pointer to the MIME part around).

int mm_context_flatten ( MM_CTX *  ctx,
char **  flat,
size_t *  length,
int  flags 
)

Creates an ASCII message of the specified context

Parameters:
ctx A valid MiniMIME context object
flat Where to store the message
flags Flags that affect the flattening process
This function ``flattens'' a MiniMIME context, that is, it creates an ASCII represantation of the message the context contains. The flags can be a bitwise combination of the following constants:

Great care is taken to not produce invalid MIME output.

void mm_context_free ( MM_CTX *  ctx  ) 

Releases a MiniMIME context object

Parameters:
ctx A valid MiniMIME context
See also:
mm_context_new
This function releases all memory associated with MiniMIME context object that was created using mm_context_new(). It will also release all memory used for the MIME parts attached, and their specific properties (such as Content-Type information, headers, and the body data).

int mm_context_generateboundary ( MM_CTX *  ctx  ) 

Generates a generic boundary string for a given context

Parameters:
ctx A valid MiniMIME context
Returns:
0 on success or -1 on failure
This function generates a default boundary string for the given context. If there is already a boundary for the context, the memory will be free()'d.

struct mm_mimepart* mm_context_getpart ( MM_CTX *  ctx,
int  which 
)

Gets a specified MIME part object from a MimeMIME context

Parameters:
ctx The MiniMIME context
which The number of the MIME part object to retrieve
Returns:
The requested MIME part object on success or a NULL pointer if there is no such part.

int mm_context_haswarnings ( MM_CTX *  ctx  ) 

Checks whether there are any warnings associated with a given context

Parameters:
ctx A valid MiniMIME context
Returns:
1 if there are warnings associated with the context, otherwise 0

int mm_context_iscomposite ( MM_CTX *  ctx  ) 

Checks whether a given context represents a composite (multipart) message

Parameters:
ctx A valid MiniMIME context object
Returns:
1 if the context is a composite message or 0 if it's flat

MM_CTX* mm_context_new ( void   ) 

Creates a new MiniMIME context object.

Returns:
a new MiniMIME context object
See also:
mm_context_free
This function creates a new MiniMIME context, which will hold a message. The memory needed is allocated dynamically and should later be free'd using mm_context_free().

Before a context can be created, the MiniMIME library needs to be initialized properly using mm_library_init().

int mm_context_setpreamble ( MM_CTX *  ctx,
char *  preamble 
)

Sets a preamble for the given MiniMIME context

Parameters:
ctx A valid MiniMIME context
preamble The preamble to set
Returns:
0 on success or -1 on failure
This function sets the MIME preamble (the text between the end of envelope headers and the beginning of the first MIME part) for a given context object. If preamble is a NULL-pointer then the preamble will be deleted, and the currently associated memory will be free automagically.


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