## CamelMimeFilter

CamelMimeFilter

## Synopsis

    struct              CamelMimeFilter;
    CamelMimeFilter *   camel_mime_filter_new               (void);
    void                camel_mime_filter_filter            (CamelMimeFilter *filter,
                                                             char *in,
                                                             size_t len,
                                                             size_t prespace,
                                                             char **out,
                                                             size_t *outlen,
                                                             size_t *outprespace);
    void                camel_mime_filter_complete          (CamelMimeFilter *filter,
                                                             char *in,
                                                             size_t len,
                                                             size_t prespace,
                                                             char **out,
                                                             size_t *outlen,
                                                             size_t *outprespace);
    void                camel_mime_filter_reset             (CamelMimeFilter *filter);
    void                camel_mime_filter_backup            (CamelMimeFilter *filter,
                                                             const char *data,
                                                             size_t length);
    void                camel_mime_filter_set_size          (CamelMimeFilter *filter,
                                                             size_t size,
                                                             int keep);

## Description

## Details

### struct CamelMimeFilter

    struct CamelMimeFilter {
    	CamelObject parent;

    	struct _CamelMimeFilterPrivate *priv;

    	char *outreal;		/* real malloc'd buffer */
    	char *outbuf;		/* first 'writable' position allowed (outreal + outpre) */
    	char *outptr;
    	size_t outsize;
    	size_t outpre;		/* prespace of this buffer */

    	char *backbuf;
    	size_t backsize;
    	size_t backlen;		/* significant data there */
    };

### camel_mime_filter_new ()

    CamelMimeFilter *   camel_mime_filter_new               (void);

Create a new CamelMimeFilter object.

Returns : | a new CamelMimeFilter

### camel_mime_filter_filter ()

    void                camel_mime_filter_filter            (CamelMimeFilter *filter,
                                                             char *in,
                                                             size_t len,
                                                             size_t prespace,
                                                             char **out,
                                                             size_t *outlen,
                                                             size_t *outprespace);

Passes the input buffer, `in`, through `filter` and generates an output buffer, `out`.

`filter` : | a CamelMimeFilter object
`in` : | input buffer
`len` : | length of `in`
`prespace` : | amount of prespace
`out` : | pointer to the output buffer (to be set)
`outlen` : | pointer to the length of the output buffer (to be set)
`outprespace` : | pointer to the output prespace length (to be set)

### camel_mime_filter_complete ()

    void                camel_mime_filter_complete          (CamelMimeFilter *filter,
                                                             char *in,
                                                             size_t len,
                                                             size_t prespace,
                                                             char **out,
                                                             size_t *outlen,
                                                             size_t *outprespace);

Passes the input buffer, `in`, through `filter` and generates an output buffer, `out` and makes sure that all data is flushed to the output buffer. This must be the last filtering call made, no further calls to camel_mime_filter_filter may be called on `filter` until `filter` has been reset using camel_mime_filter_reset.

`filter` : | a CamelMimeFilter object
`in` : | input buffer
`len` : | length of `in`
`prespace` : | amount of prespace
`out` : | pointer to the output buffer (to be set)
`outlen` : | pointer to the length of the output buffer (to be set)
`outprespace` : | pointer to the output prespace length (to be set)

### camel_mime_filter_reset ()

    void                camel_mime_filter_reset             (CamelMimeFilter *filter);

Resets the state on `filter` so that it may be used again.

`filter` : | a CamelMimeFilter object

### camel_mime_filter_backup ()

    void                camel_mime_filter_backup            (CamelMimeFilter *filter,
                                                             const char *data,
                                                             size_t length);

Saves `data` to be used as prespace input data to the next call to camel_mime_filter_filter or camel_mime_filter_complete.

Note: New calls replace old data.

`filter` : | a camelMimeFilter object
`data` : | data buffer to backup
`length` : | length of `data`

### camel_mime_filter_set_size ()

    void                camel_mime_filter_set_size          (CamelMimeFilter *filter,
                                                             size_t size,
                                                             int keep);

Ensure that `filter` has enough storage space to store `size` bytes for filter output.

`filter` : | a camelMimeFilter object
`size` : | requested amount of storage space
`keep` : | `TRUE` to keep existing buffered data or `FALSE` otherwise