+2006-04-04 Matthias Clasen <mclasen@redhat.com>
+
+ * glib/glib.symbols:
+ * glib/gbase64.[hc]: Add G_GNUC_MALLOC where
+ appropriate, use glib types.
+
2006-04-04 Alexander Larsson <alexl@redhat.com>
* glib/Makefile.am:
+2006-04-04 Matthias Clasen <mclasen@redhat.com>
+
+ * glib/glib.symbols:
+ * glib/gbase64.[hc]: Add G_GNUC_MALLOC where
+ appropriate, use glib types.
+
2006-04-04 Alexander Larsson <alexl@redhat.com>
* glib/Makefile.am:
+2006-04-04 Matthias Clasen <mclasen@redhat.com>
+
+ * glib/glib-sections.txt:
+ * glib/glib-docs.sgml: Add Base64 section
+
2006-04-03 Matthias Clasen <mclasen@redhat.com>
* gobject/tmpl/objects.sgml: Add some verbiage to
<!ENTITY glib-Markup SYSTEM "xml/markup.xml">
<!ENTITY glib-Keyfile SYSTEM "xml/keyfile.xml">
<!ENTITY glib-Bookmarkfile SYSTEM "xml/bookmarkfile.xml">
+<!ENTITY glib-Base64 SYSTEM "xml/base64.xml">
<!ENTITY glib-i18n SYSTEM "xml/i18n.xml">
<!ENTITY glib-Version SYSTEM "xml/version.xml">
&glib-String-Utility-Functions;
&glib-Character-Set-Conversion;
&glib-Unicode-Manipulation;
+ &glib-Base64;
&glib-i18n;
&glib-Date-and-Time-Functions;
&glib-Random-Numbers;
<SUBSECTION>
g_get_language_names
</SECTION>
+
+<SECTION>
+<TITLE>Base64 Encoding</TITLE>
+<FILE>base64</FILE>
+g_base64_encode_step
+g_base64_encode_close
+g_base64_encode
+g_base64_decode_step
+g_base64_decode
+</SECTION>
--- /dev/null
+<!-- ##### SECTION Title ##### -->
+Base64 Encoding
+
+<!-- ##### SECTION Short_Description ##### -->
+encodes and decodes data in Base64 format
+
+<!-- ##### SECTION Long_Description ##### -->
+<para>
+Base64 is an encoding that allows to encode a sequence of arbitrary
+bytes as a sequence of printable ASCII characters. For the definition
+of Base64, see <ulink url="http://www.ietf.org/rfc/rfc1421.txt">RFC
+1421</ulink> or <ulink url="http://www.ietf.org/rfc/rfc2045.txt">RFC
+2045</ulink>. Base64 is most commonly used as a MIME transfer encoding
+for email.
+</para>
+
+<para>
+GLib supports incremental encoding using g_base64_encode_step() and
+g_base64_encode_close(). Incremental decoding can be done with
+g_base64_decode_step() and g_base64_decode_close(). To encode or
+decode data in one go, use g_base64_encode() of g_base64_decode().
+</para>
+
+<para>
+Support for Base64 encoding has been added in GLib 2.12.
+</para>
+
+<!-- ##### SECTION See_Also ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### SECTION Stability_Level ##### -->
+
+
+<!-- ##### FUNCTION g_base64_encode_step ##### -->
+<para>
+
+</para>
+
+@in:
+@len:
+@break_lines:
+@out:
+@state:
+@save:
+@Returns:
+
+
+<!-- ##### FUNCTION g_base64_encode_close ##### -->
+<para>
+
+</para>
+
+@break_lines:
+@out:
+@state:
+@save:
+@Returns:
+
+
+<!-- ##### FUNCTION g_base64_encode ##### -->
+<para>
+
+</para>
+
+@data:
+@len:
+@Returns:
+
+
+<!-- ##### FUNCTION g_base64_decode_step ##### -->
+<para>
+
+</para>
+
+@in:
+@len:
+@out:
+@state:
+@save:
+@Returns:
+
+
+<!-- ##### FUNCTION g_base64_decode ##### -->
+<para>
+
+</para>
+
+@text:
+@out_len:
+@Returns:
+
+
* Since: 2.12
*/
gsize
-g_base64_encode_step (const guchar *in,
- gsize len,
- gboolean break_lines,
- char *out,
- int *state,
- int *save)
+g_base64_encode_step (const guchar *in,
+ gsize len,
+ gboolean break_lines,
+ gchar *out,
+ gint *state,
+ gint *save)
{
char *outptr;
const guchar *inptr;
already = *state;
switch (((char *) save) [0])
- {
- case 1: c1 = ((unsigned char *) save) [1]; goto skip1;
- case 2: c1 = ((unsigned char *) save) [1];
- c2 = ((unsigned char *) save) [2]; goto skip2;
+ {
+ case 1:
+ c1 = ((unsigned char *) save) [1];
+ goto skip1;
+ case 2:
+ c1 = ((unsigned char *) save) [1];
+ c2 = ((unsigned char *) save) [2];
+ goto skip2;
}
/*
(c3 >> 6) ];
*outptr++ = base64_alphabet [ c3 & 0x3f ];
/* this is a bit ugly ... */
- if (break_lines && (++already)>=19)
+ if (break_lines && (++already) >= 19)
{
- *outptr++='\n';
+ *outptr++ = '\n';
already = 0;
}
}
((char *)save)[0] = 0;
- len = 2-(inptr-inend);
+ len = 2 - (inptr - inend);
*state = already;
}
case 2: *saveout++ = *inptr++;
case 1: *saveout++ = *inptr++;
}
- ((char *)save)[0]+=len;
+ ((char *)save)[0] += len;
}
- return outptr-out;
+ return outptr - out;
}
/**
* Since: 2.12
*/
gsize
-g_base64_encode_close (gboolean break_lines,
- char *out,
- int *state,
- int *save)
+g_base64_encode_close (gboolean break_lines,
+ gchar *out,
+ gint *state,
+ gint *save)
{
int c1, c2;
char *outptr = out;
*save = 0;
*state = 0;
- return outptr-out;
+ return outptr - out;
}
/**
*
* Since: 2.12
*/
-char *
-g_base64_encode (const guchar *data, gsize len)
+gchar *
+g_base64_encode (const guchar *data,
+ gsize len)
{
- char *out;
- int state = 0, outlen;
- int save = 0;
+ gchar *out;
+ gint state = 0, outlen;
+ gint save = 0;
/* We can use a smaller limit here, since we know the saved state is 0 */
out = g_malloc (len * 4 / 3 + 4);
&state,
&save);
out[outlen] = '\0';
- return (char *) out;
+ return (gchar *) out;
}
static const unsigned char mime_base64_rank[256] = {
};
/**
- * g_base64_decode_step: decode a chunk of base64 encoded data
+ * g_base64_decode_step:
* @in: binary input data
* @len: max length of @in data to decode
* @out: output buffer
* Since: 2.12
**/
gsize
-g_base64_decode_step (const char *in,
- gsize len,
- guchar *out,
- int *state,
- guint *save)
+g_base64_decode_step (const gchar *in,
+ gsize len,
+ guchar *out,
+ gint *state,
+ guint *save)
{
const guchar *inptr;
guchar *outptr;
* Since: 2.12
*/
guchar *
-g_base64_decode (const char *text,
- gsize *out_len)
+g_base64_decode (const gchar *text,
+ gsize *out_len)
{
guchar *ret;
- int inlen, state = 0;
+ gint inlen, state = 0;
guint save = 0;
inlen = strlen (text);
gsize g_base64_encode_step (const guchar *in,
gsize len,
gboolean break_lines,
- char *out,
- int *state,
- int *save);
+ gchar *out,
+ gint *state,
+ gint *save);
gsize g_base64_encode_close (gboolean break_lines,
- char *out,
- int *state,
- int *save);
-char * g_base64_encode (const guchar *data,
- gsize len);
-gsize g_base64_decode_step (const char *in,
+ gchar *out,
+ gint *state,
+ gint *save);
+gchar* g_base64_encode (const guchar *data,
+ gsize len) G_GNUC_MALLOC;
+gsize g_base64_decode_step (const gchar *in,
gsize len,
guchar *out,
- int *state,
+ gint *state,
guint *save);
-guchar *g_base64_decode (const char *text,
- gsize *out_len);
+guchar *g_base64_decode (const gchar *text,
+ gsize *out_len) G_GNUC_MALLOC;
G_END_DECLS
#if IN_FILE(__G_BASE64_C__)
g_base64_encode_step
g_base64_encode_close
-g_base64_encode
+g_base64_encode G_GNUC_MALLOC
g_base64_decode_step
-g_base64_decode
+g_base64_decode G_GNUC_MALLOC
#endif
#endif