Switch core from strerror to g_strerror
[claws.git] / src / prefs_gtk.c
index ba1eb541219fdbc9abbd4fc1941c79d61ec477c6..843f9c95b1656fc5d9f7babdc9b9b86acbfe6e8d 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2012 Hiroyuki Yamamoto and the Claws Mail team
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2015 Hiroyuki Yamamoto and the Claws Mail team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -14,7 +14,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * 
+ *
  */
 
 #ifdef HAVE_CONFIG_H
@@ -41,7 +41,6 @@
 #include "utils.h"
 #include "gtkutils.h"
 #include "passcrypt.h"
-#include "base64.h"
 #include "codeconv.h"
 
 #define CL(x)  (((gulong) (x) >> (gulong) 8) & 0xFFUL)
@@ -220,14 +219,15 @@ static void prefs_config_parse_one_line(PrefParam *param, const gchar *buf)
                case P_PASSWORD:
                        g_free(*((gchar **)param[i].data));
                        if (value[0] == '!') {
-                               gchar tmp[1024];
-                               gint len;
+                               gchar *tmp;
+                               gsize len;
 
-                               len = base64_decode(tmp, &value[1], strlen(value) - 1);
+                               tmp = g_base64_decode(&value[1], &len);
                                passcrypt_decrypt(tmp, len);
-                               tmp[len] = '\0';
+
                                *((gchar **)param[i].data) =
                                        *tmp ? g_strdup(tmp) : NULL;
+                               g_free(tmp);
                        } else {
                                *((gchar **)param[i].data) =
                                        *value ? g_strdup(value) : NULL;
@@ -383,7 +383,7 @@ gint prefs_write_param(PrefParam *param, FILE *fp)
                        break;
                case P_PASSWORD:
                        {
-                               gchar *tmp = NULL, tmp2[1024] = {0};
+                               gchar *tmp = NULL, *tmp2 = NULL;
 
                                tmp = *((gchar **)param[i].data);
                                if (tmp) {
@@ -392,13 +392,14 @@ gint prefs_write_param(PrefParam *param, FILE *fp)
                                        tmp = g_strdup(tmp);
                                        len = strlen(tmp);
                                        passcrypt_encrypt(tmp, len);
-                                       base64_encode(tmp2, tmp, len);
+                                       tmp2 = g_base64_encode(tmp, len);
                                        g_free(tmp);
                                        tmp = tmp2;
                                }
                                g_snprintf(buf, sizeof(buf), "%s=!%s\n", param[i].name,
                                           tmp ?
                                           tmp : "");
+                               g_free(tmp);
                        }
                        break;
                default:
@@ -452,11 +453,9 @@ void prefs_set_default(PrefParam *param)
                                                g_strconcat(get_home_dir(),
                                                            param[i].defval + 1,
                                                            NULL);
-                               else if (param[i].defval[0] != '\0')
+                               else 
                                        *((gchar **)param[i].data) =
                                                g_strdup(param[i].defval);
-                               else
-                                       *((gchar **)param[i].data) = NULL;
                        } else
                                *((gchar **)param[i].data) = NULL;
                        break;
@@ -973,7 +972,7 @@ static int prefs_cache_sections(GHashTable *file_cache, const gchar *rcfile)
        if (rcfile)
                fp = g_fopen(rcfile, "rb");
        if (!fp) {
-               debug_print("cache: %s: %s\n", rcfile?rcfile:"(null)", strerror(errno));
+               debug_print("cache: %s: %s\n", rcfile?rcfile:"(null)", g_strerror(errno));
                return -1;
        }