static gboolean debug_mode = FALSE;
-#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)
#endif
}
-void list_free_strings(GList *list)
+void list_free_strings_full(GList *list)
{
- list = g_list_first(list);
-
- while (list != NULL) {
- g_free(list->data);
- list = list->next;
- }
-}
-
-void slist_free_strings(GSList *list)
-{
- while (list != NULL) {
- g_free(list->data);
- list = list->next;
- }
+ g_list_free_full(list, (GDestroyNotify)g_free);
}
void slist_free_strings_full(GSList *list)
{
-#if GLIB_CHECK_VERSION(2,28,0)
g_slist_free_full(list, (GDestroyNotify)g_free);
-#else
- g_slist_foreach(list, (GFunc)g_free, NULL);
- g_slist_free(list);
-#endif
}
static void hash_free_strings_func(gpointer key, gpointer value, gpointer data)
off_t get_file_size(const gchar *file)
{
+#ifdef G_OS_WIN32
+ GFile *f;
+ GFileInfo *fi;
+ GError *error = NULL;
+ goffset size;
+
+ f = g_file_new_for_path(file);
+ fi = g_file_query_info(f, "standard::size",
+ G_FILE_QUERY_INFO_NONE, NULL, &error);
+ if (error != NULL) {
+ debug_print("get_file_size error: %s\n", error->message);
+ g_error_free(error);
+ g_object_unref(f);
+ return -1;
+ }
+ size = g_file_info_get_size(fi);
+ g_object_unref(fi);
+ g_object_unref(f);
+ return size;
+
+#else
GStatBuf s;
if (g_stat(file, &s) < 0) {
}
return s.st_size;
+#endif
}
time_t get_file_mtime(const gchar *file)
gchar buf2[RFC822_DATE_BUFFSIZE];
t = time(NULL);
- lt = localtime_r(&t, &buf1);
+ if (hidetz)
+ lt = gmtime_r(&t, &buf1);
+ else
+ lt = localtime_r(&t, &buf1);
- sscanf(asctime_r(lt, buf2), "%3s %3s %d %d:%d:%d %d\n",
- day, mon, &dd, &hh, &mm, &ss, &yyyy);
+ if (sscanf(asctime_r(lt, buf2), "%3s %3s %d %d:%d:%d %d\n",
+ day, mon, &dd, &hh, &mm, &ss, &yyyy) != 7)
+ g_warning("failed reading date/time");
g_snprintf(buf, len, "%s, %d %s %d %02d:%02d:%02d %s",
day, dd, mon, yyyy, hh, mm, ss, (hidetz? "-0000": tzoffset(&t)));