mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-15 20:25:12 +01:00
Whitespace cleanup
This commit is contained in:
parent
489b780bb9
commit
5d4ef36f91
120
glib/gbase64.c
120
glib/gbase64.c
@ -10,7 +10,7 @@
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
@ -54,7 +54,7 @@
|
||||
*/
|
||||
|
||||
static const char base64_alphabet[] =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
/**
|
||||
* g_base64_encode_step:
|
||||
@ -88,11 +88,11 @@ static const char base64_alphabet[] =
|
||||
*/
|
||||
gsize
|
||||
g_base64_encode_step (const guchar *in,
|
||||
gsize len,
|
||||
gboolean break_lines,
|
||||
gchar *out,
|
||||
gint *state,
|
||||
gint *save)
|
||||
gsize len,
|
||||
gboolean break_lines,
|
||||
gchar *out,
|
||||
gint *state,
|
||||
gint *save)
|
||||
{
|
||||
char *outptr;
|
||||
const guchar *inptr;
|
||||
@ -117,40 +117,40 @@ g_base64_encode_step (const guchar *in,
|
||||
already = *state;
|
||||
|
||||
switch (((char *) save) [0])
|
||||
{
|
||||
case 1:
|
||||
c1 = ((unsigned char *) save) [1];
|
||||
goto skip1;
|
||||
case 2:
|
||||
{
|
||||
case 1:
|
||||
c1 = ((unsigned char *) save) [1];
|
||||
c2 = ((unsigned char *) save) [2];
|
||||
goto skip1;
|
||||
case 2:
|
||||
c1 = ((unsigned char *) save) [1];
|
||||
c2 = ((unsigned char *) save) [2];
|
||||
goto skip2;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* yes, we jump into the loop, no i'm not going to change it,
|
||||
* it's beautiful!
|
||||
*/
|
||||
while (inptr < inend)
|
||||
{
|
||||
c1 = *inptr++;
|
||||
skip1:
|
||||
c2 = *inptr++;
|
||||
skip2:
|
||||
c3 = *inptr++;
|
||||
*outptr++ = base64_alphabet [ c1 >> 2 ];
|
||||
*outptr++ = base64_alphabet [ c2 >> 4 |
|
||||
((c1&0x3) << 4) ];
|
||||
*outptr++ = base64_alphabet [ ((c2 &0x0f) << 2) |
|
||||
(c3 >> 6) ];
|
||||
*outptr++ = base64_alphabet [ c3 & 0x3f ];
|
||||
/* this is a bit ugly ... */
|
||||
if (break_lines && (++already) >= 19)
|
||||
{
|
||||
*outptr++ = '\n';
|
||||
already = 0;
|
||||
}
|
||||
}
|
||||
{
|
||||
c1 = *inptr++;
|
||||
skip1:
|
||||
c2 = *inptr++;
|
||||
skip2:
|
||||
c3 = *inptr++;
|
||||
*outptr++ = base64_alphabet [ c1 >> 2 ];
|
||||
*outptr++ = base64_alphabet [ c2 >> 4 |
|
||||
((c1&0x3) << 4) ];
|
||||
*outptr++ = base64_alphabet [ ((c2 &0x0f) << 2) |
|
||||
(c3 >> 6) ];
|
||||
*outptr++ = base64_alphabet [ c3 & 0x3f ];
|
||||
/* this is a bit ugly ... */
|
||||
if (break_lines && (++already) >= 19)
|
||||
{
|
||||
*outptr++ = '\n';
|
||||
already = 0;
|
||||
}
|
||||
}
|
||||
|
||||
((char *)save)[0] = 0;
|
||||
len = 2 - (inptr - inend);
|
||||
@ -166,10 +166,10 @@ g_base64_encode_step (const guchar *in,
|
||||
|
||||
/* len can only be 0 1 or 2 */
|
||||
switch(len)
|
||||
{
|
||||
case 2: *saveout++ = *inptr++;
|
||||
case 1: *saveout++ = *inptr++;
|
||||
}
|
||||
{
|
||||
case 2: *saveout++ = *inptr++;
|
||||
case 1: *saveout++ = *inptr++;
|
||||
}
|
||||
((char *)save)[0] += len;
|
||||
}
|
||||
|
||||
@ -195,9 +195,9 @@ g_base64_encode_step (const guchar *in,
|
||||
*/
|
||||
gsize
|
||||
g_base64_encode_close (gboolean break_lines,
|
||||
gchar *out,
|
||||
gint *state,
|
||||
gint *save)
|
||||
gchar *out,
|
||||
gint *state,
|
||||
gint *save)
|
||||
{
|
||||
int c1, c2;
|
||||
char *outptr = out;
|
||||
@ -314,10 +314,10 @@ static const unsigned char mime_base64_rank[256] = {
|
||||
**/
|
||||
gsize
|
||||
g_base64_decode_step (const gchar *in,
|
||||
gsize len,
|
||||
guchar *out,
|
||||
gint *state,
|
||||
guint *save)
|
||||
gsize len,
|
||||
guchar *out,
|
||||
gint *state,
|
||||
guint *save)
|
||||
{
|
||||
const guchar *inptr;
|
||||
guchar *outptr;
|
||||
@ -348,21 +348,21 @@ g_base64_decode_step (const gchar *in,
|
||||
c = *inptr++;
|
||||
rank = mime_base64_rank [c];
|
||||
if (rank != 0xff)
|
||||
{
|
||||
last[1] = last[0];
|
||||
last[0] = c;
|
||||
v = (v<<6) | rank;
|
||||
i++;
|
||||
if (i==4)
|
||||
{
|
||||
*outptr++ = v>>16;
|
||||
if (last[1] != '=')
|
||||
*outptr++ = v>>8;
|
||||
if (last[0] != '=')
|
||||
*outptr++ = v;
|
||||
i=0;
|
||||
}
|
||||
}
|
||||
{
|
||||
last[1] = last[0];
|
||||
last[0] = c;
|
||||
v = (v<<6) | rank;
|
||||
i++;
|
||||
if (i==4)
|
||||
{
|
||||
*outptr++ = v>>16;
|
||||
if (last[1] != '=')
|
||||
*outptr++ = v>>8;
|
||||
if (last[0] != '=')
|
||||
*outptr++ = v;
|
||||
i=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*save = v;
|
||||
@ -386,7 +386,7 @@ g_base64_decode_step (const gchar *in,
|
||||
*/
|
||||
guchar *
|
||||
g_base64_decode (const gchar *text,
|
||||
gsize *out_len)
|
||||
gsize *out_len)
|
||||
{
|
||||
guchar *ret;
|
||||
gsize input_length;
|
||||
|
@ -9,7 +9,7 @@
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
@ -29,27 +29,27 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
gsize g_base64_encode_step (const guchar *in,
|
||||
gsize len,
|
||||
gboolean break_lines,
|
||||
gchar *out,
|
||||
gint *state,
|
||||
gint *save);
|
||||
gsize g_base64_encode_close (gboolean break_lines,
|
||||
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,
|
||||
gint *state,
|
||||
guint *save);
|
||||
guchar *g_base64_decode (const gchar *text,
|
||||
gsize *out_len) G_GNUC_MALLOC;
|
||||
guchar *g_base64_decode_inplace (gchar *text,
|
||||
gsize *out_len);
|
||||
gsize g_base64_encode_step (const guchar *in,
|
||||
gsize len,
|
||||
gboolean break_lines,
|
||||
gchar *out,
|
||||
gint *state,
|
||||
gint *save);
|
||||
gsize g_base64_encode_close (gboolean break_lines,
|
||||
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,
|
||||
gint *state,
|
||||
guint *save);
|
||||
guchar *g_base64_decode (const gchar *text,
|
||||
gsize *out_len) G_GNUC_MALLOC;
|
||||
guchar *g_base64_decode_inplace (gchar *text,
|
||||
gsize *out_len);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
Loading…
x
Reference in New Issue
Block a user