KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17
System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64
User : nobody ( 99)
PHP Version : 5.2.17
Disable Function : NONE
Directory :  /proc/22697/root/usr/share/gtk-doc/html/glib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/22697/root/usr/share/gtk-doc/html/glib/glib-Base64-Encoding.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Base64 Encoding</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.69.1">
<link rel="start" href="index.html" title="GLib Reference Manual">
<link rel="up" href="glib-utilities.html" title="GLib Utilities">
<link rel="prev" href="glib-Unicode-Manipulation.html" title="Unicode Manipulation">
<link rel="next" href="glib-I18N.html" title="Internationalization">
<meta name="generator" content="GTK-Doc V1.6 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="chapter" href="glib.html" title="GLib Overview">
<link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals">
<link rel="chapter" href="glib-core.html" title="GLib Core Application Support">
<link rel="chapter" href="glib-utilities.html" title="GLib Utilities">
<link rel="chapter" href="glib-data-types.html" title="GLib Data Types">
<link rel="chapter" href="tools.html" title="GLib Tools">
<link rel="index" href="ix01.html" title="Index">
<link rel="index" href="ix02.html" title="Index of deprecated symbols">
<link rel="index" href="ix03.html" title="Index of new symbols in 2.2">
<link rel="index" href="ix04.html" title="Index of new symbols in 2.4">
<link rel="index" href="ix05.html" title="Index of new symbols in 2.6">
<link rel="index" href="ix06.html" title="Index of new symbols in 2.8">
<link rel="index" href="ix07.html" title="Index of new symbols in 2.10">
<link rel="index" href="ix08.html" title="Index of new symbols in 2.12">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="glib-Unicode-Manipulation.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="glib-utilities.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GLib Reference Manual</th>
<td><a accesskey="n" href="glib-I18N.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id3036614" class="shortcut">Top</a>
                  &#160;|&#160;
                  <a href="#id3036847" class="shortcut">Description</a></nobr></td></tr>
</table>
<div class="refentry" lang="en">
<a name="glib-Base64-Encoding"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2>
<a name="id3036614"></a><span class="refentrytitle">Base64 Encoding</span>
</h2>
<p>Base64 Encoding &#8212; encodes and decodes data in Base64 format</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<h2>Synopsis</h2>
<pre class="synopsis">

#include &lt;glib.h&gt;


<a href="glib-Basic-Types.html#gsize">gsize</a>       <a href="glib-Base64-Encoding.html#g-base64-encode-step">g_base64_encode_step</a>            (const <a href="glib-Basic-Types.html#guchar">guchar</a> *in,
                                             <a href="glib-Basic-Types.html#gsize">gsize</a> len,
                                             <a href="glib-Basic-Types.html#gboolean">gboolean</a> break_lines,
                                             <a href="glib-Basic-Types.html#gchar">gchar</a> *out,
                                             <a href="glib-Basic-Types.html#gint">gint</a> *state,
                                             <a href="glib-Basic-Types.html#gint">gint</a> *save);
<a href="glib-Basic-Types.html#gsize">gsize</a>       <a href="glib-Base64-Encoding.html#g-base64-encode-close">g_base64_encode_close</a>           (<a href="glib-Basic-Types.html#gboolean">gboolean</a> break_lines,
                                             <a href="glib-Basic-Types.html#gchar">gchar</a> *out,
                                             <a href="glib-Basic-Types.html#gint">gint</a> *state,
                                             <a href="glib-Basic-Types.html#gint">gint</a> *save);
<a href="glib-Basic-Types.html#gchar">gchar</a>*      <a href="glib-Base64-Encoding.html#g-base64-encode">g_base64_encode</a>                 (const <a href="glib-Basic-Types.html#guchar">guchar</a> *data,
                                             <a href="glib-Basic-Types.html#gsize">gsize</a> len);
<a href="glib-Basic-Types.html#gsize">gsize</a>       <a href="glib-Base64-Encoding.html#g-base64-decode-step">g_base64_decode_step</a>            (const <a href="glib-Basic-Types.html#gchar">gchar</a> *in,
                                             <a href="glib-Basic-Types.html#gsize">gsize</a> len,
                                             <a href="glib-Basic-Types.html#guchar">guchar</a> *out,
                                             <a href="glib-Basic-Types.html#gint">gint</a> *state,
                                             <a href="glib-Basic-Types.html#guint">guint</a> *save);
<a href="glib-Basic-Types.html#guchar">guchar</a>*     <a href="glib-Base64-Encoding.html#g-base64-decode">g_base64_decode</a>                 (const <a href="glib-Basic-Types.html#gchar">gchar</a> *text,
                                             <a href="glib-Basic-Types.html#gsize">gsize</a> *out_len);
</pre>
</div>
<div class="refsect1" lang="en">
<a name="id3036847"></a><h2>Description</h2>
<p>
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 <a href="http://www.ietf.org/rfc/rfc1421.txt" target="_top">RFC 
1421</a> or <a href="http://www.ietf.org/rfc/rfc2045.txt" target="_top">RFC
2045</a>. Base64 is most commonly used as a MIME transfer encoding
for email.
</p>
<p>
GLib supports incremental encoding using <a href="glib-Base64-Encoding.html#g-base64-encode-step"><code class="function">g_base64_encode_step()</code></a> and
<a href="glib-Base64-Encoding.html#g-base64-encode-close"><code class="function">g_base64_encode_close()</code></a>. Incremental decoding can be done with
<a href="glib-Base64-Encoding.html#g-base64-decode-step"><code class="function">g_base64_decode_step()</code></a>. To encode or decode data in one go, use 
<a href="glib-Base64-Encoding.html#g-base64-encode"><code class="function">g_base64_encode()</code></a> or <a href="glib-Base64-Encoding.html#g-base64-decode"><code class="function">g_base64_decode()</code></a>. 
</p>
<p>
Support for Base64 encoding has been added in GLib 2.12.
</p>
</div>
<div class="refsect1" lang="en">
<a name="id3036941"></a><h2>Details</h2>
<div class="refsect2" lang="en">
<a name="id3036952"></a><h3>
<a name="g-base64-encode-step"></a>g_base64_encode_step ()</h3>
<a class="indexterm" name="id3036967"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gsize">gsize</a>       g_base64_encode_step            (const <a href="glib-Basic-Types.html#guchar">guchar</a> *in,
                                             <a href="glib-Basic-Types.html#gsize">gsize</a> len,
                                             <a href="glib-Basic-Types.html#gboolean">gboolean</a> break_lines,
                                             <a href="glib-Basic-Types.html#gchar">gchar</a> *out,
                                             <a href="glib-Basic-Types.html#gint">gint</a> *state,
                                             <a href="glib-Basic-Types.html#gint">gint</a> *save);</pre>
<p>
Incrementally encode a sequence of binary data into it's 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.
</p>
<p>
When all of the data has been converted you must call 
<a href="glib-Base64-Encoding.html#g-base64-encode-close"><code class="function">g_base64_encode_close()</code></a> to flush the saved state.
</p>
<p>
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: <em class="parameter"><code>len</code></em> * 4 / 3 + 6 bytes. If you enable line-breaking you will
need at least: <em class="parameter"><code>len</code></em> * 4 / 3 + <em class="parameter"><code>len</code></em> * 4 / (3 * 72) + 7 bytes.
</p>
<p>
<em class="parameter"><code>break_lines</code></em> 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.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><em class="parameter"><code>in</code></em>&#160;:</span></td>
<td> the binary data to encode.
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>len</code></em>&#160;:</span></td>
<td> the length of <em class="parameter"><code>in</code></em>.
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>break_lines</code></em>&#160;:</span></td>
<td> whether to break long lines
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>out</code></em>&#160;:</span></td>
<td> pointer to destination buffer
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>state</code></em>&#160;:</span></td>
<td> Saved state between steps, initialize to 0
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>save</code></em>&#160;:</span></td>
<td> Saved state between steps, initialize to 0
</td>
</tr>
<tr>
<td>
<span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td>
<td> The number of bytes of output that was written

</td>
</tr>
</tbody>
</table></div>
<p>Since  2.12
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3037203"></a><h3>
<a name="g-base64-encode-close"></a>g_base64_encode_close ()</h3>
<a class="indexterm" name="id3037219"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gsize">gsize</a>       g_base64_encode_close           (<a href="glib-Basic-Types.html#gboolean">gboolean</a> break_lines,
                                             <a href="glib-Basic-Types.html#gchar">gchar</a> *out,
                                             <a href="glib-Basic-Types.html#gint">gint</a> *state,
                                             <a href="glib-Basic-Types.html#gint">gint</a> *save);</pre>
<p>
Flush the status from a sequence of calls to <a href="glib-Base64-Encoding.html#g-base64-encode-step"><code class="function">g_base64_encode_step()</code></a>.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><em class="parameter"><code>break_lines</code></em>&#160;:</span></td>
<td> whether to break long lines
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>out</code></em>&#160;:</span></td>
<td> pointer to destination buffer
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>state</code></em>&#160;:</span></td>
<td> Saved state from <a href="glib-Base64-Encoding.html#g-base64-encode-step"><code class="function">g_base64_encode_step()</code></a>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>save</code></em>&#160;:</span></td>
<td> Saved state from <a href="glib-Base64-Encoding.html#g-base64-encode-step"><code class="function">g_base64_encode_step()</code></a>
</td>
</tr>
<tr>
<td>
<span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td>
<td> The number of bytes of output that was written

</td>
</tr>
</tbody>
</table></div>
<p>Since  2.12
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3037383"></a><h3>
<a name="g-base64-encode"></a>g_base64_encode ()</h3>
<a class="indexterm" name="id3037398"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gchar">gchar</a>*      g_base64_encode                 (const <a href="glib-Basic-Types.html#guchar">guchar</a> *data,
                                             <a href="glib-Basic-Types.html#gsize">gsize</a> len);</pre>
<p>
Encode a sequence of binary data into its Base-64 stringified
representation.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><em class="parameter"><code>data</code></em>&#160;:</span></td>
<td> the binary data to encode.
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>len</code></em>&#160;:</span></td>
<td> the length of <em class="parameter"><code>data</code></em>.
</td>
</tr>
<tr>
<td>
<span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td>
<td> a newly allocated, zero-terminated Base-64 encoded
              string representing <em class="parameter"><code>data</code></em>.

</td>
</tr>
</tbody>
</table></div>
<p>Since  2.12
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3037499"></a><h3>
<a name="g-base64-decode-step"></a>g_base64_decode_step ()</h3>
<a class="indexterm" name="id3037514"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gsize">gsize</a>       g_base64_decode_step            (const <a href="glib-Basic-Types.html#gchar">gchar</a> *in,
                                             <a href="glib-Basic-Types.html#gsize">gsize</a> len,
                                             <a href="glib-Basic-Types.html#guchar">guchar</a> *out,
                                             <a href="glib-Basic-Types.html#gint">gint</a> *state,
                                             <a href="glib-Basic-Types.html#guint">guint</a> *save);</pre>
<p>
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.
</p>
<p>
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: <em class="parameter"><code>len</code></em> * 3 / 4 bytes.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><em class="parameter"><code>in</code></em>&#160;:</span></td>
<td> binary input data
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>len</code></em>&#160;:</span></td>
<td> max length of <em class="parameter"><code>in</code></em> data to decode
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>out</code></em>&#160;:</span></td>
<td> output buffer
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>state</code></em>&#160;:</span></td>
<td> Saved state between steps, initialize to 0
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>save</code></em>&#160;:</span></td>
<td> Saved state between steps, initialize to 0
</td>
</tr>
<tr>
<td>
<span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td>
<td> The number of bytes of output that was written

</td>
</tr>
</tbody>
</table></div>
<p>Since  2.12
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3037688"></a><h3>
<a name="g-base64-decode"></a>g_base64_decode ()</h3>
<a class="indexterm" name="id3037703"></a><pre class="programlisting"><a href="glib-Basic-Types.html#guchar">guchar</a>*     g_base64_decode                 (const <a href="glib-Basic-Types.html#gchar">gchar</a> *text,
                                             <a href="glib-Basic-Types.html#gsize">gsize</a> *out_len);</pre>
<p>
Decode a sequence of Base-64 encoded text into binary data</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><em class="parameter"><code>text</code></em>&#160;:</span></td>
<td> zero-terminated string with base64 text to decode.
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>out_len</code></em>&#160;:</span></td>
<td> The length of the decoded data is written here.
</td>
</tr>
<tr>
<td>
<span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td>
<td> a newly allocated buffer containing the binary data
              that <em class="parameter"><code>text</code></em> represents

</td>
</tr>
</tbody>
</table></div>
<p>Since  2.12
</p>
</div>
</div>
</div>
</body>
</html>

Anon7 - 2021