gbase64.h File Reference

__G_BASE64_H__

g_base64_encode_step ( const guchar *, gsize, gboolean, gchar *, gint *, gint * )

G_BEGIN_DECLS IMPORT_C gsizeg_base64_encode_step(const guchar *in,
gsizelen,
gbooleanbreak_lines,
gchar *out,
gint *state,
gint *save
)

g_base64_encode_step: : the binary data to encode : the length of : whether to break long lines : pointer to destination buffer : Saved state between steps, initialize to 0 : Saved state between steps, initialize to 0

Incrementally encode a sequence of binary data into its Base-64 stringified representation. By calling this function multiple times you can convert data in chunks to avoid having to have the full encoded data in memory.

When all of the data has been converted you must call g_base64_encode_close() to flush the saved state.

The output buffer must be large enough to fit all the data that will be written to it. Due to the way base64 encodes you will need at least: ( / 3 + 1) * 4 + 4 bytes (+ 4 may be needed in case of non-zero state). If you enable line-breaking you will need at least: (( / 3 + 1) * 4 + 4) / 72 + 1 bytes of extra space.

is typically used when putting base64-encoded data in emails. It breaks the lines at 72 columns instead of putting all of the text on the same line. This avoids problems with long lines in the email system.

Return value: The number of bytes of output that was written

Since: 2.12

g_base64_encode_close ( gboolean, gchar *, gint *, gint * )

IMPORT_C gsizeg_base64_encode_close(gbooleanbreak_lines,
gchar *out,
gint *state,
gint *save
)

g_base64_encode_close: : whether to break long lines : pointer to destination buffer : Saved state from g_base64_encode_step() : Saved state from g_base64_encode_step()

Flush the status from a sequence of calls to g_base64_encode_step().

Return value: The number of bytes of output that was written

Since: 2.12

g_base64_encode ( const guchar *, gsize )

IMPORT_C gchar *g_base64_encode(const guchar *data,
gsizelen
)

g_base64_encode: : the binary data to encode : the length of

Encode a sequence of binary data into its Base-64 stringified representation.

Return value: a newly allocated, zero-terminated Base-64 encoded string representing . The returned string must be freed with g_free().

Since: 2.12

g_base64_decode_step ( const gchar *, gsize, guchar *, gint *, guint * )

IMPORT_C gsizeg_base64_decode_step(const gchar *in,
gsizelen,
guchar *out,
gint *state,
guint *save
)

g_base64_decode_step: : binary input data : max length of data to decode : output buffer : Saved state between steps, initialize to 0 : Saved state between steps, initialize to 0

Incrementally decode a sequence of binary data from its Base-64 stringified representation. By calling this function multiple times you can convert data in chunks to avoid having to have the full encoded data in memory.

The output buffer must be large enough to fit all the data that will be written to it. Since base64 encodes 3 bytes in 4 chars you need at least: ( / 4) * 3 + 3 bytes (+ 3 may be needed in case of non-zero state).

Return value: The number of bytes of output that was written

Since: 2.12

g_base64_decode ( const gchar *, gsize * )

IMPORT_C guchar *g_base64_decode(const gchar *text,
gsize *out_len
)

g_base64_decode: : zero-terminated string with base64 text to decode : The length of the decoded data is written here

Decode a sequence of Base-64 encoded text into binary data

Return value: a newly allocated buffer containing the binary data that represents. The returned buffer must be freed with g_free().

Since: 2.12

g_base64_decode_inplace ( gchar *, gsize * )

IMPORT_C guchar *g_base64_decode_inplace(gchar *text,
gsize *out_len
)

g_base64_decode_inplace: : zero-terminated string with base64 text to decode : The length of the decoded data is written here

Decode a sequence of Base-64 encoded text into binary data by overwriting the input data.

Return value: The binary data that responds. This pointer is the same as the input .

Since: 2.20