Provide an up to date version of g_base64_decode() for older GLib.
authorAndrej Kacian <ticho@claws-mail.org>
Thu, 13 Aug 2015 18:24:48 +0000 (20:24 +0200)
committerAndrej Kacian <ticho@claws-mail.org>
Thu, 13 Aug 2015 18:24:48 +0000 (20:24 +0200)
Patch by Jean Diraison, closes bug #3473.

src/common/utils.c
src/common/utils.h
src/unmime.c

index b753ac874af83cd363d1aec0cf1a6f5ae0b0284c..64ca25a8aec780837108a6bf1b307d3564d8c02b 100644 (file)
@@ -89,6 +89,24 @@ static gboolean debug_mode = FALSE;
 static GSList *tempfiles=NULL;
 #endif
 
 static GSList *tempfiles=NULL;
 #endif
 
+#if !GLIB_CHECK_VERSION(2, 26, 0)
+guchar *g_base64_decode_wa(const gchar *text, gsize *out_len)
+{
+       guchar *ret;
+       gsize input_length;
+       gint state = 0;
+       guint save = 0;
+
+       input_length = strlen(text);
+
+       ret = g_malloc0((input_length / 4) * 3 + 1);
+
+       *out_len = g_base64_decode_step(text, input_length, ret, &state, &save);
+
+       return ret;
+}
+#endif
+
 /* Return true if we are running as root.  This function should beused
    instead of getuid () == 0.  */
 gboolean superuser_p (void)
 /* Return true if we are running as root.  This function should beused
    instead of getuid () == 0.  */
 gboolean superuser_p (void)
index 3771d45186aa0aec3fdcdea02ef1ae06f155535a..0a38d34ab81e27982a2a1a784a22e1b1db8d32c5 100644 (file)
@@ -75,6 +75,11 @@ typedef gint64 goffset;
   #define HAVE_U32_TYPEDEF
 #endif
 
   #define HAVE_U32_TYPEDEF
 #endif
 
+#if !GLIB_CHECK_VERSION(2, 26, 0)
+#define g_base64_decode(t,l)   g_base64_decode_wa((t),(l))
+guchar *g_base64_decode_wa(const gchar *text, gsize *out_len);
+#endif
+
 #if !GLIB_CHECK_VERSION(2, 25, 0)
 # ifdef G_OS_WIN32
        typedef _g_stat_struct GStatBuf;
 #if !GLIB_CHECK_VERSION(2, 25, 0)
 # ifdef G_OS_WIN32
        typedef _g_stat_struct GStatBuf;
index e9588e307c22b16cf246237b484b61d786c3bbb0..424bde99a856a271b16cae5e260589f12eb04ba5 100644 (file)
@@ -26,6 +26,7 @@
 #include <string.h>
 #include <ctype.h>
 
 #include <string.h>
 #include <ctype.h>
 
+#include "utils.h"
 #include "codeconv.h"
 #include "quoted-printable.h"
 
 #include "codeconv.h"
 #include "quoted-printable.h"