GMime 2.4 Reference Manual | ||||
---|---|---|---|---|
enum GMimeContentEncoding; GMimeContentEncoding g_mime_content_encoding_from_string (const char *str); const char* g_mime_content_encoding_to_string (GMimeContentEncoding encoding); GMimeEncoding; void g_mime_encoding_init_encode (GMimeEncoding *state, GMimeContentEncoding encoding); void g_mime_encoding_init_decode (GMimeEncoding *state, GMimeContentEncoding encoding); void g_mime_encoding_reset (GMimeEncoding *state); size_t g_mime_encoding_outlen (GMimeEncoding *state, size_t inlen); size_t g_mime_encoding_step (GMimeEncoding *state, const char *inbuf, size_t inlen, char *outbuf); size_t g_mime_encoding_flush (GMimeEncoding *state, const char *inbuf, size_t inlen, char *outbuf); #define GMIME_BASE64_ENCODE_LEN (x) size_t g_mime_encoding_base64_decode_step (unsigned char *inbuf, size_t inlen, unsigned char *outbuf, int *state, guint32 *save); size_t g_mime_encoding_base64_encode_step (unsigned char *inbuf, size_t inlen, unsigned char *outbuf, int *state, guint32 *save); size_t g_mime_encoding_base64_encode_close (unsigned char *inbuf, size_t inlen, unsigned char *outbuf, int *state, guint32 *save); #define GMIME_UUDECODE_STATE_INIT #define GMIME_UUDECODE_STATE_BEGIN #define GMIME_UUDECODE_STATE_END #define GMIME_UUENCODE_LEN (x) size_t g_mime_encoding_uudecode_step (unsigned char *inbuf, size_t inlen, unsigned char *outbuf, int *state, guint32 *save); size_t g_mime_encoding_uuencode_step (unsigned char *inbuf, size_t inlen, unsigned char *outbuf, unsigned char *uubuf, int *state, guint32 *save); size_t g_mime_encoding_uuencode_close (unsigned char *inbuf, size_t inlen, unsigned char *outbuf, unsigned char *uubuf, int *state, guint32 *save); #define GMIME_QP_ENCODE_LEN (x) size_t g_mime_encoding_quoted_decode_step (unsigned char *inbuf, size_t inlen, unsigned char *outbuf, int *state, guint32 *save); size_t g_mime_encoding_quoted_encode_step (unsigned char *inbuf, size_t inlen, unsigned char *outbuf, int *state, guint32 *save); size_t g_mime_encoding_quoted_encode_close (unsigned char *inbuf, size_t inlen, unsigned char *outbuf, int *state, guint32 *save);
typedef enum { GMIME_CONTENT_ENCODING_DEFAULT, GMIME_CONTENT_ENCODING_7BIT, GMIME_CONTENT_ENCODING_8BIT, GMIME_CONTENT_ENCODING_BINARY, GMIME_CONTENT_ENCODING_BASE64, GMIME_CONTENT_ENCODING_QUOTEDPRINTABLE, GMIME_CONTENT_ENCODING_UUENCODE } GMimeContentEncoding;
A Content-Transfer-Encoding enumeration.
Default transfer encoding. | |
7bit text transfer encoding. | |
8bit text transfer encoding. | |
Binary transfer encoding. | |
Base64 transfer encoding. | |
Quoted-printable transfer encoding. | |
Uuencode transfer encoding. |
GMimeContentEncoding g_mime_content_encoding_from_string (const char *str);
Gets the appropriate GMimeContentEncoding enumeration value based on the input string.
|
string representing a Content-Transfer-Encoding value |
Returns : |
the GMimeContentEncoding specified by str or
GMIME_CONTENT_ENCODING_DEFAULT on error.
|
const char* g_mime_content_encoding_to_string (GMimeContentEncoding encoding);
Gets the string value of the content encoding.
|
a GMimeContentEncoding |
Returns : |
the encoding type as a string or NULL on error. Available
values for the encoding are: GMIME_CONTENT_ENCODING_DEFAULT,
GMIME_CONTENT_ENCODING_7BIT, GMIME_CONTENT_ENCODING_8BIT,
GMIME_CONTENT_ENCODING_BINARY, GMIME_CONTENT_ENCODING_BASE64,
GMIME_CONTENT_ENCODING_QUOTEDPRINTABLE and
GMIME_CONTENT_ENCODING_UUENCODE.
|
typedef struct { GMimeContentEncoding encoding; unsigned char uubuf[60]; gboolean encode; guint32 save; int state; } GMimeEncoding;
A context used for encoding or decoding data.
GMimeContentEncoding |
the type of encoding |
unsigned char |
a temporary buffer needed when uuencoding data |
gboolean |
TRUE if encoding or FALSE if decoding
|
guint32 |
saved bytes from the previous step |
int |
current encder/decoder state |
void g_mime_encoding_init_encode (GMimeEncoding *state, GMimeContentEncoding encoding);
Initializes a GMimeEncoding state machine for encoding to
encoding
.
|
a GMimeEncoding to initialize |
|
a GMimeContentEncoding to use |
void g_mime_encoding_init_decode (GMimeEncoding *state, GMimeContentEncoding encoding);
Initializes a GMimeEncoding state machine for decoding from
encoding
.
|
a GMimeEncoding to initialize |
|
a GMimeContentEncoding to use |
void g_mime_encoding_reset (GMimeEncoding *state);
Resets the state of the GMimeEncoding.
|
a GMimeEncoding to reset |
size_t g_mime_encoding_outlen (GMimeEncoding *state, size_t inlen);
Given the input length, inlen
, calculate the needed output length
to perform an encoding or decoding step.
|
a GMimeEncoding |
|
an input length |
Returns : |
the maximum number of bytes needed to encode or decode a
buffer of inlen bytes.
|
size_t g_mime_encoding_step (GMimeEncoding *state, const char *inbuf, size_t inlen, char *outbuf);
Incrementally encodes or decodes (depending on state
) an input
stream by 'stepping' through a block of input at a time.
You should make sure outbuf
is large enough by calling
g_mime_encoding_outlen()
to find out how large outbuf
might need
to be.
|
a GMimeEncoding |
|
an input buffer to encode or decode |
|
input buffer length |
|
an output buffer |
Returns : |
the number of bytes written to outbuf .
|
size_t g_mime_encoding_flush (GMimeEncoding *state, const char *inbuf, size_t inlen, char *outbuf);
Completes the incremental encode or decode of the input stream (see
g_mime_encoding_step()
for details).
|
a GMimeEncoding |
|
an input buffer to encode or decode |
|
input buffer length |
|
an output buffer |
Returns : |
the number of bytes written to outbuf .
|
#define GMIME_BASE64_ENCODE_LEN(x) ((size_t) (((((x) + 2) / 57) * 77) + 77))
Calculates the maximum number of bytes needed to base64 encode the
full input buffer of length x
.
|
Length of the input data to encode |
size_t g_mime_encoding_base64_decode_step (unsigned char *inbuf, size_t inlen, unsigned char *outbuf, int *state, guint32 *save);
Decodes a chunk of base64 encoded data.
|
input buffer |
|
input buffer length |
|
output buffer |
|
holds the number of bits that are stored in save
|
|
leftover bits that have not yet been decoded |
Returns : |
the number of bytes decoded (which have been dumped in
outbuf ).
|
size_t g_mime_encoding_base64_encode_step (unsigned char *inbuf, size_t inlen, unsigned char *outbuf, int *state, guint32 *save);
Base64 encodes a chunk of data. Performs an 'encode step', only encodes blocks of 3 characters to the output at a time, saves left-over state in state and save (initialise to 0 on first invocation).
|
input buffer |
|
input buffer length |
|
output buffer |
|
holds the number of bits that are stored in save
|
|
leftover bits that have not yet been encoded |
Returns : |
the number of bytes encoded. |
size_t g_mime_encoding_base64_encode_close (unsigned char *inbuf, size_t inlen, unsigned char *outbuf, int *state, guint32 *save);
Base64 encodes the input stream to the output stream. Call this
when finished encoding data with g_mime_encoding_base64_encode_step()
to flush off the last little bit.
|
input buffer |
|
input buffer length |
|
output buffer |
|
holds the number of bits that are stored in save
|
|
leftover bits that have not yet been encoded |
Returns : |
the number of bytes encoded. |
#define GMIME_UUDECODE_STATE_INIT (0)
Initial state for the g_mime_utils_uudecode_step()
function.
#define GMIME_UUDECODE_STATE_BEGIN (1 << 16)
State for the g_mime_utils_uudecode_step()
function, denoting that
the 'begin' line has been found.
#define GMIME_UUDECODE_STATE_END (1 << 17)
State for the g_mime_utils_uudecode_step()
function, denoting that
the end of the UU encoded block has been found.
#define GMIME_UUENCODE_LEN(x) ((size_t) (((((x) + 2) / 45) * 62) + 62))
Calculates the maximum number of bytes needed to uuencode the full
input buffer of length x
.
|
Length of the input data to encode |
size_t g_mime_encoding_uudecode_step (unsigned char *inbuf, size_t inlen, unsigned char *outbuf, int *state, guint32 *save);
Uudecodes a chunk of data. Performs a 'decode step' on a chunk of uuencoded data. Assumes the "begin mode filename" line has been stripped off.
|
input buffer |
|
input buffer length |
|
output buffer |
|
holds the number of bits that are stored in save
|
|
leftover bits that have not yet been decoded |
Returns : |
the number of bytes decoded. |
size_t g_mime_encoding_uuencode_step (unsigned char *inbuf, size_t inlen, unsigned char *outbuf, unsigned char *uubuf, int *state, guint32 *save);
Uuencodes a chunk of data. Performs an 'encode step', only encodes
blocks of 45 characters to the output at a time, saves left-over
state in uubuf
, state
and save
(initialize to 0 on first
invocation).
|
input buffer |
|
input buffer length |
|
output stream |
|
temporary buffer of 60 bytes |
|
holds the number of bits that are stored in save
|
|
leftover bits that have not yet been encoded |
Returns : |
the number of bytes encoded. |
size_t g_mime_encoding_uuencode_close (unsigned char *inbuf, size_t inlen, unsigned char *outbuf, unsigned char *uubuf, int *state, guint32 *save);
Uuencodes a chunk of data. Call this when finished encoding data
with g_mime_encoding_uuencode_step()
to flush off the last little bit.
|
input buffer |
|
input buffer length |
|
output buffer |
|
temporary buffer of 60 bytes |
|
holds the number of bits that are stored in save
|
|
leftover bits that have not yet been encoded |
Returns : |
the number of bytes encoded. |
#define GMIME_QP_ENCODE_LEN(x) ((size_t) ((((x) + 1) * 3) + 1))
Calculates the maximum number of bytes needed to encode the full
input buffer of length x
using the quoted-printable encoding.
|
Length of the input data to encode |
size_t g_mime_encoding_quoted_decode_step (unsigned char *inbuf, size_t inlen, unsigned char *outbuf, int *state, guint32 *save);
Decodes a block of quoted-printable encoded data. Performs a 'decode step' on a chunk of QP encoded data.
|
input buffer |
|
input buffer length |
|
output buffer |
|
holds the number of bits that are stored in save
|
|
leftover bits that have not yet been decoded |
Returns : |
the number of bytes decoded. |
size_t g_mime_encoding_quoted_encode_step (unsigned char *inbuf, size_t inlen, unsigned char *outbuf, int *state, guint32 *save);
Quoted-printable encodes a block of text. Performs an 'encode step', saves left-over state in state and save (initialise to -1 on first invocation).
|
input buffer |
|
input buffer length |
|
output buffer |
|
holds the number of bits that are stored in save
|
|
leftover bits that have not yet been encoded |
Returns : |
the number of bytes encoded. |
size_t g_mime_encoding_quoted_encode_close (unsigned char *inbuf, size_t inlen, unsigned char *outbuf, int *state, guint32 *save);
Quoted-printable encodes a block of text. Call this when finished
encoding data with g_mime_encoding_quoted_encode_step()
to flush off
the last little bit.
|
input buffer |
|
input buffer length |
|
output buffer |
|
holds the number of bits that are stored in save
|
|
leftover bits that have not yet been encoded |
Returns : |
the number of bytes encoded. |