## CamelMimeFilterYenc

CamelMimeFilterYenc

## Synopsis

                        CamelMimeFilterYenc;
    enum                CamelMimeFilterYencDirection;
    #define             CAMEL_MIME_YDECODE_STATE_INIT
    #define             CAMEL_MIME_YENCODE_STATE_INIT
    #define             CAMEL_MIME_YDECODE_STATE_EOLN
    #define             CAMEL_MIME_YDECODE_STATE_ESCAPE
    #define             CAMEL_MIME_YDECODE_STATE_BEGIN
    #define             CAMEL_MIME_YDECODE_STATE_PART
    #define             CAMEL_MIME_YDECODE_STATE_DECODE
    #define             CAMEL_MIME_YDECODE_STATE_END
    #define             CAMEL_MIME_YENCODE_CRC_INIT
    #define             CAMEL_MIME_YENCODE_CRC_FINAL        (crc)
    CamelMimeFilter *   camel_mime_filter_yenc_new          (CamelMimeFilterYencDirection direction);
    void                camel_mime_filter_yenc_set_state    (CamelMimeFilterYenc *yenc,
                                                             gint state);
    void                camel_mime_filter_yenc_set_crc      (CamelMimeFilterYenc *yenc,
                                                             guint32 crc);
    guint32             camel_mime_filter_yenc_get_pcrc     (CamelMimeFilterYenc *yenc);
    guint32             camel_mime_filter_yenc_get_crc      (CamelMimeFilterYenc *yenc);
    gsize               camel_ydecode_step                  (const guchar *in,
                                                             gsize inlen,
                                                             guchar *out,
                                                             gint *state,
                                                             guint32 *pcrc,
                                                             guint32 *crc);
    gsize               camel_yencode_step                  (const guchar *in,
                                                             gsize inlen,
                                                             guchar *out,
                                                             gint *state,
                                                             guint32 *pcrc,
                                                             guint32 *crc);
    gsize               camel_yencode_close                 (const guchar *in,
                                                             gsize inlen,
                                                             guchar *out,
                                                             gint *state,
                                                             guint32 *pcrc,
                                                             guint32 *crc);

## Object Hierarchy

      GObject
       +----CamelObject
             +----CamelMimeFilter
                   +----CamelMimeFilterYenc

## Description

## Details

### CamelMimeFilterYenc

    typedef struct _CamelMimeFilterYenc CamelMimeFilterYenc;

### enum CamelMimeFilterYencDirection

    typedef enum {
    	CAMEL_MIME_FILTER_YENC_DIRECTION_ENCODE,
    	CAMEL_MIME_FILTER_YENC_DIRECTION_DECODE
    } CamelMimeFilterYencDirection;

### CAMEL_MIME_YDECODE_STATE_INIT

    #define CAMEL_MIME_YDECODE_STATE_INIT     (0)

### CAMEL_MIME_YENCODE_STATE_INIT

    #define CAMEL_MIME_YENCODE_STATE_INIT     (0)

### CAMEL_MIME_YDECODE_STATE_EOLN

    #define CAMEL_MIME_YDECODE_STATE_EOLN     (1 << 8)

### CAMEL_MIME_YDECODE_STATE_ESCAPE

    #define CAMEL_MIME_YDECODE_STATE_ESCAPE   (1 << 9)

### CAMEL_MIME_YDECODE_STATE_BEGIN

    #define CAMEL_MIME_YDECODE_STATE_BEGIN    (1 << 12)

### CAMEL_MIME_YDECODE_STATE_PART

    #define CAMEL_MIME_YDECODE_STATE_PART     (1 << 13)

### CAMEL_MIME_YDECODE_STATE_DECODE

    #define CAMEL_MIME_YDECODE_STATE_DECODE   (1 << 14)

### CAMEL_MIME_YDECODE_STATE_END

    #define CAMEL_MIME_YDECODE_STATE_END      (1 << 15)

### CAMEL_MIME_YENCODE_CRC_INIT

    #define CAMEL_MIME_YENCODE_CRC_INIT       (~0)

### CAMEL_MIME_YENCODE_CRC_FINAL()

    #define CAMEL_MIME_YENCODE_CRC_FINAL(crc) (~crc)

`crc` : |

### camel_mime_filter_yenc_new ()

    CamelMimeFilter *   camel_mime_filter_yenc_new          (CamelMimeFilterYencDirection direction);

Create a new CamelMimeFilterYenc filter object.

`direction` : | encode direction
Returns : | a new CamelMimeFilterYenc object

### camel_mime_filter_yenc_set_state ()

    void                camel_mime_filter_yenc_set_state    (CamelMimeFilterYenc *yenc,
                                                             gint state);

Sets the current state of the yencoder/ydecoder

`yenc` : | a CamelMimeFilterYenc object
`state` : | encode/decode state

### camel_mime_filter_yenc_set_crc ()

    void                camel_mime_filter_yenc_set_crc      (CamelMimeFilterYenc *yenc,
                                                             guint32 crc);

Sets the current crc32 value on the yEnc filter `yenc` to `crc`.

`yenc` : | a CamelMimeFilterYenc object
`crc` : | crc32 value

### camel_mime_filter_yenc_get_pcrc ()

    guint32             camel_mime_filter_yenc_get_pcrc     (CamelMimeFilterYenc *yenc);

Get the computed part crc or (guint32) `-1` on fail.

`yenc` : | a CamelMimeFilterYenc object
Returns : | the computed part crc or (guint32) `-1` on fail.

### camel_mime_filter_yenc_get_crc ()

    guint32             camel_mime_filter_yenc_get_crc      (CamelMimeFilterYenc *yenc);

Get the computed crc or (guint32) -1 on fail.

`yenc` : | a CamelMimeFiletrYenc object
Returns : | the computed crc or (guint32) -1 on fail.

### camel_ydecode_step ()

    gsize               camel_ydecode_step                  (const guchar *in,
                                                             gsize inlen,
                                                             guchar *out,
                                                             gint *state,
                                                             guint32 *pcrc,
                                                             guint32 *crc);

Performs a 'decode step' on a chunk of yEncoded data of length `inlen` pointed to by `in` and writes to `out`. Assumes the =ybegin and =ypart lines have already been stripped off.

To get the crc32 value of the part, use CAMEL_MIME_YENCODE_CRC_FINAL (`pcrc`). If there are more parts, you should reuse `crc` without re-initializing. Once all parts have been decoded, you may get the combined crc32 value of all the parts using CAMEL_MIME_YENCODE_CRC_FINAL (`crc`).

`in` : | input buffer
`inlen` : | input buffer length
`out` : | output buffer
`state` : | ydecode state
`pcrc` : | part crc state
`crc` : | crc state
Returns : | the number of bytes decoded

### camel_yencode_step ()

    gsize               camel_yencode_step                  (const guchar *in,
                                                             gsize inlen,
                                                             guchar *out,
                                                             gint *state,
                                                             guint32 *pcrc,
                                                             guint32 *crc);

Performs an yEncode 'encode step' on a chunk of raw data of length `inlen` pointed to by `in` and writes to `out`.

`state` should be initialized to CAMEL_MIME_YENCODE_STATE_INIT before beginning making the first call to this function. Subsequent calls should reuse `state`.

Along the same lines, `pcrc` and `crc` should be initialized to CAMEL_MIME_YENCODE_CRC_INIT before using.

`in` : | input buffer
`inlen` : | input buffer length
`out` : | output buffer
`state` : | yencode state
`pcrc` : | part crc state
`crc` : | crc state
Returns : | the number of bytes encoded

### camel_yencode_close ()

    gsize               camel_yencode_close                 (const guchar *in,
                                                             gsize inlen,
                                                             guchar *out,
                                                             gint *state,
                                                             guint32 *pcrc,
                                                             guint32 *crc);

Call this function when finished encoding data with `camel_yencode_step()` to flush off the remaining state.

CAMEL_MIME_YENCODE_CRC_FINAL (`pcrc`) will give you the crc32 of the encoded "part". If there are more "parts" to encode, you should re-use `crc` when encoding the next "parts" and then use CAMEL_MIME_YENCODE_CRC_FINAL (`crc`) to get the combined crc32 value of all the parts.

`in` : | input buffer
`inlen` : | input buffer length
`out` : | output buffer
`state` : | yencode state
`pcrc` : | part crc state
`crc` : | crc state
Returns : | the number of bytes encoded.