PageRenderTime 22ms CodeModel.GetById 13ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/src/wrappers/glib/library/utilities/glib_base64_encoding.e

http://github.com/tybor/Liberty
Specman e | 161 lines | 2 code | 45 blank | 114 comment | 0 complexity | 457b2e5cd45a9c7a2a6fd8d1f2784186 MD5 | raw file
  1deferred class GLIB_BASE64_ENCODING
  2   -- Base64 Encoding
  3
  4--    Base64 Encoding -- encodes and decodes data in Base64 format
  5
  6-- Synopsis
  7
  8
  9--  #include <glib.h>
 10
 11
 12--  gsize       g_base64_encode_step            (const guchar *in,
 13--                                               gsize len,
 14--                                               gboolean break_lines,
 15--                                               gchar *out,
 16--                                               gint *state,
 17--                                               gint *save);
 18--  gsize       g_base64_encode_close           (gboolean break_lines,
 19--                                               gchar *out,
 20--                                               gint *state,
 21--                                               gint *save);
 22--  gchar*      g_base64_encode                 (const guchar *data,
 23--                                               gsize len);
 24--  gsize       g_base64_decode_step            (const gchar *in,
 25--                                               gsize len,
 26--                                               guchar *out,
 27--                                               gint *state,
 28--                                               guint *save);
 29--  guchar*     g_base64_decode                 (const gchar *text,
 30--                                               gsize *out_len);
 31
 32-- Description
 33
 34--    Base64 is an encoding that allows to encode a sequence of arbitrary bytes as a
 35--    sequence of printable ASCII characters. For the definition of Base64, see RFC
 36--    1421 or RFC 2045. Base64 is most commonly used as a MIME transfer encoding for
 37--    email.
 38
 39--    GLib supports incremental encoding using g_base64_encode_step() and
 40--    g_base64_encode_close(). Incremental decoding can be done with
 41--    g_base64_decode_step(). To encode or decode data in one go, use g_base64_encode()
 42--    or g_base64_decode().
 43
 44--    Support for Base64 encoding has been added in GLib 2.12.
 45
 46-- Details
 47
 48--   g_base64_encode_step ()
 49
 50--  gsize       g_base64_encode_step            (const guchar *in,
 51--                                               gsize len,
 52--                                               gboolean break_lines,
 53--                                               gchar *out,
 54--                                               gint *state,
 55--                                               gint *save);
 56
 57--    Incrementally encode a sequence of binary data into it's Base-64 stringified
 58--    representation. By calling this function multiple times you can convert data in
 59--    chunks to avoid having to have the full encoded data in memory.
 60
 61--    When all of the data has been converted you must call g_base64_encode_close() to
 62--    flush the saved state.
 63
 64--    The output buffer must be large enough to fit all the data that will be written
 65--    to it. Due to the way base64 encodes you will need at least: len * 4 / 3 + 6
 66--    bytes. If you enable line-breaking you will need at least: len * 4 / 3 + len * 4
 67--    / (3 * 72) + 7 bytes.
 68
 69--    break_lines is typically used when putting base64-encoded data in emails. It
 70--    breaks the lines at 72 columns instead of putting all of the text on the same
 71--    line. This avoids problems with long lines in the email system.
 72
 73--    in :          the binary data to encode.
 74--    len :         the length of in.
 75--    break_lines : whether to break long lines
 76--    out :         pointer to destination buffer
 77--    state :       Saved state between steps, initialize to 0
 78--    save :        Saved state between steps, initialize to 0
 79--    Returns :     The number of bytes of output that was written
 80
 81--    Since 2.12
 82
 83--    ---------------------------------------------------------------------------------
 84
 85--   g_base64_encode_close ()
 86
 87--  gsize       g_base64_encode_close           (gboolean break_lines,
 88--                                               gchar *out,
 89--                                               gint *state,
 90--                                               gint *save);
 91
 92--    Flush the status from a sequence of calls to g_base64_encode_step().
 93
 94--    break_lines : whether to break long lines
 95--    out :         pointer to destination buffer
 96--    state :       Saved state from g_base64_encode_step()
 97--    save :        Saved state from g_base64_encode_step()
 98--    Returns :     The number of bytes of output that was written
 99
100--    Since 2.12
101
102--    ---------------------------------------------------------------------------------
103
104--   g_base64_encode ()
105
106--  gchar*      g_base64_encode                 (const guchar *data,
107--                                               gsize len);
108
109--    Encode a sequence of binary data into its Base-64 stringified representation.
110
111--    data :    the binary data to encode.
112--    len :     the length of data.
113--    Returns : a newly allocated, zero-terminated Base-64 encoded string representing
114--              data.
115
116--    Since 2.12
117
118--    ---------------------------------------------------------------------------------
119
120--   g_base64_decode_step ()
121
122--  gsize       g_base64_decode_step            (const gchar *in,
123--                                               gsize len,
124--                                               guchar *out,
125--                                               gint *state,
126--                                               guint *save);
127
128--    Incrementally decode a sequence of binary data from its Base-64 stringified
129--    representation. By calling this function multiple times you can convert data in
130--    chunks to avoid having to have the full encoded data in memory.
131
132--    The output buffer must be large enough to fit all the data that will be written
133--    to it. Since base64 encodes 3 bytes in 4 chars you need at least: len * 3 / 4
134--    bytes.
135
136--    in :      binary input data
137--    len :     max length of in data to decode
138--    out :     output buffer
139--    state :   Saved state between steps, initialize to 0
140--    save :    Saved state between steps, initialize to 0
141--    Returns : The number of bytes of output that was written
142
143--    Since 2.12
144
145--    ---------------------------------------------------------------------------------
146
147--   g_base64_decode ()
148
149--  guchar*     g_base64_decode                 (const gchar *text,
150--                                               gsize *out_len);
151
152--    Decode a sequence of Base-64 encoded text into binary data
153
154--    text :    zero-terminated string with base64 text to decode.
155--    out_len : The length of the decoded data is written here.
156--    Returns : a newly allocated buffer containing the binary data that text
157--              represents
158
159--    Since 2.12
160end -- class GLIB_BASE64_ENCODING
161