/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2009 Hiroyuki Yamamoto & The Claws Mail Team
+ * Copyright (C) 1999-2011 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
#include <glib/gi18n.h>
+#ifdef USE_PTHREAD
+#include <pthread.h>
+#endif
+
#include <stdio.h>
#include <string.h>
#include <ctype.h>
}
}
-gboolean str_find(const gchar *haystack, const gchar *needle)
-{
- return strstr(haystack, needle) != NULL ? TRUE : FALSE;
-}
-
-gboolean str_case_find(const gchar *haystack, const gchar *needle)
-{
- return strcasestr(haystack, needle) != NULL ? TRUE : FALSE;
-}
-
gint to_number(const gchar *nstr)
{
register const gchar *p;
GList *add_history(GList *list, const gchar *str)
{
GList *old;
+ gchar *oldstr;
cm_return_val_if_fail(str != NULL, list);
old = g_list_find_custom(list, (gpointer)str, (GCompareFunc)strcmp2);
if (old) {
- g_free(old->data);
+ oldstr = old->data;
list = g_list_remove(list, old->data);
+ g_free(oldstr);
} else if (g_list_length(list) >= MAX_HISTORY_SIZE) {
GList *last;
last = g_list_last(list);
if (last) {
- g_free(last->data);
+ oldstr = last->data;
list = g_list_remove(list, last->data);
+ g_free(oldstr);
}
}
int i;
if (quote_chars == NULL)
- return FALSE;
+ return NULL;
for (i = 0; i < strlen(quote_chars); i++) {
tmp_pos = strrchr (str, quote_chars[i]);
if (strchr(quote_chars, *p))
quote_level++;
else if (*p != '-' && !g_ascii_isspace(*p) && p <= last_pos) {
- /* any characters are allowed except '-' and space */
- while (*p != '-'
+ /* any characters are allowed except '-','<' and space */
+ while (*p != '-' && *p != '<'
&& !strchr(quote_chars, *p)
&& !g_ascii_isspace(*p)
&& p < last_pos)
}
gint scan_mailto_url(const gchar *mailto, gchar **from, gchar **to, gchar **cc, gchar **bcc,
- gchar **subject, gchar **body, gchar ***attach)
+ gchar **subject, gchar **body, gchar ***attach, gchar **inreplyto)
{
gchar *tmp_mailto;
gchar *p;
my_att[num_attach-1] = tmp;
my_att[num_attach] = NULL;
}
+ } else if (inreplyto && !*inreplyto &&
+ !g_ascii_strcasecmp(field, "in-reply-to")) {
+ *inreplyto = decode_uri_gdup(value);
}
}
}
#endif
+/* Return the filepath of the claws-mail.desktop file */
+const gchar *get_desktop_file(void)
+{
+#ifdef DESKTOPFILEPATH
+ return DESKTOPFILEPATH;
+#else
+ return NULL;
+#endif
+}
+
/* Return the default directory for Plugins. */
const gchar *get_plugin_dir(void)
{
{
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 */
};
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 @.
+ */
+ while (strchr(addr, '@') != NULL && strchr(addr, '@') != strrchr(addr, '@'))
+ *(strchr(addr, '@')) = '_';
g_snprintf(buf, len, "%04d%02d%02d%02d%02d%02d.%08x%s",
lt->tm_year + 1900, lt->tm_mon + 1,
* should pass some URI type to this function and decide on that whether
* to perform punctuation stripping */
-#define IS_REAL_PUNCT(ch) (g_ascii_ispunct(ch) && !strchr("/?=-)", ch))
+#define IS_REAL_PUNCT(ch) (g_ascii_ispunct(ch) && !strchr("/?=-_)", ch))
for (; ep_ - 1 > scanpos + 1 &&
IS_REAL_PUNCT(*(ep_ - 1));
&& 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++;
+ else if (!strncmp(buffer, "Message-ID:", strlen("Message-ID:")))
score++;
- if (!strncmp(buffer, "Subject:", strlen("Subject:")))
+ else if (!strncmp(buffer, "Subject:", strlen("Subject:")))
score++;
i++;
}