/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2009 Hiroyuki Yamamoto & The Claws Mail Team
+ * Copyright (C) 1999-2012 Hiroyuki Yamamoto & 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
#ifdef HAVE_CONFIG_H
# include "config.h"
+#include "claws-features.h"
#endif
#include "defs.h"
#include <glib/gi18n.h>
+#ifdef USE_PTHREAD
+#include <pthread.h>
+#endif
+
#include <stdio.h>
#include <string.h>
#include <ctype.h>
register gchar *srcp, *destp;
gint in_brace;
- srcp = destp = str;
+ destp = str;
while ((destp = strchr(destp, op))) {
in_brace = 1;
register gchar *srcp, *destp;
gint in_brace;
- srcp = destp = str;
+ destp = str;
while ((srcp = strchr(destp, op))) {
if (destp > str)
gint in_brace;
gboolean in_quote = FALSE;
- srcp = destp = str;
+ destp = str;
while ((srcp = strchr_with_skip_quote(destp, quote_chr, op))) {
if (destp > str)
register gchar *srcp, *destp;
gint in_brace;
- srcp = destp = str;
+ destp = str;
while ((destp = strchr(destp, '"'))) {
if ((srcp = strchr(destp + 1, '"'))) {
}
}
- srcp = destp = str;
+ destp = str;
while ((destp = strchr_with_skip_quote(destp, '"', '('))) {
in_brace = 1;
gchar *prev_dir;
gint file_no;
+ if (first == last) {
+ /* Skip all the dir reading part. */
+ gchar *filename = g_strdup_printf("%s%s%u", dir, G_DIR_SEPARATOR_S, first);
+ if (claws_unlink(filename) < 0) {
+ FILE_OP_ERROR(filename, "unlink");
+ g_free(filename);
+ return -1;
+ }
+ g_free(filename);
+ return 0;
+ }
+
prev_dir = g_get_current_dir();
if (g_chdir(dir) < 0) {
const gchar *dir_name;
gchar *prev_dir;
gint file_no;
+ GHashTable *file_no_tbl;
+
+ if (numberlist == NULL)
+ return 0;
prev_dir = g_get_current_dir();
return -1;
}
+ file_no_tbl = g_hash_table_new(g_direct_hash, g_direct_equal);
while ((dir_name = g_dir_read_name(dp)) != NULL) {
file_no = to_number(dir_name);
- if (file_no > 0 && (g_slist_find(numberlist, GINT_TO_POINTER(file_no)) == NULL)) {
- debug_print("removing unwanted file %d from %s\n", file_no, dir);
- if (is_dir_exist(dir_name))
- continue;
+ if (is_dir_exist(dir_name))
+ continue;
+ if (file_no > 0)
+ g_hash_table_insert(file_no_tbl, GINT_TO_POINTER(file_no), GINT_TO_POINTER(1));
+ }
+
+ do {
+ if (g_hash_table_lookup(file_no_tbl, numberlist->data) == NULL) {
+ debug_print("removing unwanted file %d from %s\n",
+ GPOINTER_TO_INT(numberlist->data), dir);
if (claws_unlink(dir_name) < 0)
FILE_OP_ERROR(dir_name, "unlink");
}
- }
+ } while ((numberlist = g_slist_next(numberlist)));
g_dir_close(dp);
+ g_hash_table_destroy(file_no_tbl);
if (g_chdir(prev_dir) < 0) {
FILE_OP_ERROR(prev_dir, "chdir");
gchar *normalize_newlines(const gchar *str)
{
- const gchar *p = str;
+ const gchar *p;
gchar *out, *outp;
out = outp = g_malloc(strlen(str) + 1);
{
struct tm gmt, *lt;
gint off;
-#ifndef G_OS_WIN32
struct tm buf1, buf2;
-#endif
#ifdef G_OS_WIN32
if (now && *now < 0)
return 0;
struct tm gmt, *lt;
gint off;
gchar sign = '+';
-#ifndef G_OS_WIN32
struct tm buf1, buf2;
-#endif
#ifdef G_OS_WIN32
if (now && *now < 0)
return 0;
time_t t;
gchar day[4], mon[4];
gint dd, hh, mm, ss, yyyy;
-#ifndef G_OS_WIN32
struct tm buf1;
gchar buf2[BUFFSIZE];
-#endif
t = time(NULL);
lt = localtime_r(&t, &buf1);
"Vs\\:", /* "Vs" (Norwegian) */
"Ad\\:", /* "Ad" (Norwegian) */
"\347\255\224\345\244\215\\:", /* "Re" (Chinese, UTF-8) */
- "R\303\251f\\. \\:", /* "Réf. :" (French Lotus Notes) */
+ "R\303\251f\\. \\:", /* "R�f. :" (French Lotus Notes) */
"Re \\:", /* "Re :" (French Yahoo Mail) */
/* add more */
};
"sv:", /* "Sv" (Norwegian) */
"vs:", /* "Vs" (Norwegian) */
"ad:", /* "Ad" (Norwegian) */
- "R\303\251f. :", /* "Réf. :" (French Lotus Notes) */
+ "R\303\251f. :", /* "R�f. :" (French Lotus Notes) */
"Re :", /* "Re :" (French Yahoo Mail) */
/* add more */
};
struct tm *lt;
time_t t;
gchar *addr;
-#ifndef G_OS_WIN32
struct tm buft;
-#endif
t = time(NULL);
lt = localtime_r(&t, &buft);
- if (strcmp(buf, "") == 0) {
- if (user_addr != NULL)
- addr = g_strconcat(".", user_addr, "@", get_domain_name(), NULL);
- else
- addr = g_strconcat("@", get_domain_name(), NULL);
- } else {
- if (user_addr != NULL)
- addr = g_strconcat(".", user_addr, "@", buf, NULL);
- else
- addr = g_strconcat("@", buf, NULL);
- }
+ if (user_addr != NULL)
+ addr = g_strdup_printf(".%s", user_addr);
+ else if (strlen(buf) != 0)
+ addr = g_strdup_printf("@%s", buf);
+ else
+ addr = g_strdup_printf("@%s", get_domain_name());
/* Replace all @ but the last one in addr, with underscores.
* RFC 2822 States that msg-id syntax only allows one @.
return a quoted string safely usable in argument of a command.
- code is extracted and adapted from etPan! project -- DINH V. Hoà.
+ code is extracted and adapted from etPan! project -- DINH V. Ho�.
*/
gint quote_cmd_argument(gchar * result, guint size,
INT_TO_HEX(hex, ch >> 4);
*out++ = hex;
INT_TO_HEX(hex, ch & 0x0f);
- *out++ = hex;
+ *out = hex;
}
#undef REF_DEBUG
&& fgets(buffer, sizeof (buffer), fp) > 0) {
if (!strncmp(buffer, "From:", strlen("From:")))
score++;
- if (!strncmp(buffer, "To:", strlen("To:")))
+ else if (!strncmp(buffer, "Date:", strlen("Date:")))
score++;
- if (!strncmp(buffer, "Subject:", strlen("Subject:")))
+ else if (!strncmp(buffer, "Message-ID:", strlen("Message-ID:")))
+ score++;
+ else if (!strncmp(buffer, "Subject:", strlen("Subject:")))
score++;
i++;
}
*curpos++ = *format++;
}
}
- *curpos++ = '\0';
+ *curpos = '\0';
return total_done;
}
}
return g_unlink(filename);
}
+
+GMutex *cm_mutex_new(void) {
+#if GLIB_CHECK_VERSION(2,32,0)
+ GMutex *m = g_new0(GMutex, 1);
+ g_mutex_init(m);
+ return m;
+#else
+ return g_mutex_new();
+#endif
+}
+
+void cm_mutex_free(GMutex *mutex) {
+#if GLIB_CHECK_VERSION(2,32,0)
+ g_mutex_clear(mutex);
+ g_free(mutex);
+#else
+ g_mutex_free(mutex);
+#endif
+}