/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2005 Hiroyuki Yamamoto & The Sylpheed-Claws Team
+ * Copyright (C) 1999-2006 Hiroyuki Yamamoto & The Sylpheed-Claws 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
last = g_list_last(list);
if (last) {
g_free(last->data);
- g_list_remove(list, last->data);
+ list = g_list_remove(list, last->data);
}
}
return 0;
}
+gint open_txt_editor(const gchar *filepath, const gchar *cmdline)
+{
+ gchar buf[BUFFSIZE];
+ gchar *p;
+
+ g_return_val_if_fail(filepath != NULL, -1);
+
+ if (cmdline &&
+ (p = strchr(cmdline, '%')) && *(p + 1) == 's' &&
+ !strchr(p + 2, '%'))
+ g_snprintf(buf, sizeof(buf), cmdline, filepath);
+ else {
+ if (cmdline)
+ g_warning("Open Text Editor command line is invalid "
+ "(there must be only one '%%s'): %s",
+ cmdline);
+ g_snprintf(buf, sizeof(buf), DEFAULT_EDITOR_CMD, filepath);
+ }
+
+ execute_command_line(buf, TRUE);
+
+ return 0;
+}
+
time_t remote_tzoffset_sec(const gchar *zone)
{
static gchar ustzstr[] = "PSTPDTMSTMDTCSTCDTESTEDT";
/* find end point of URI */
for (ep_ = scanpos; *ep_ != '\0'; ep_++) {
- if (!isgraph(*(const guchar *)ep_) ||
+ if (!g_ascii_isgraph(*(const guchar *)ep_) ||
!IS_ASCII(*(const guchar *)ep_) ||
strchr("[]{}()<>\"", *ep_))
break;
* should pass some URI type to this function and decide on that whether
* to perform punctuation stripping */
-#define IS_REAL_PUNCT(ch) (ispunct(ch) && ((ch) != '/'))
+#define IS_REAL_PUNCT(ch) (g_ascii_ispunct(ch) && !strchr("/?=", ch))
for (; ep_ - 1 > scanpos + 1 &&
- IS_REAL_PUNCT(*(const guchar *)(ep_ - 1));
+ IS_REAL_PUNCT(*(ep_ - 1));
ep_--)
;
}
return 0;
}
+
+/* crude test to see if a file is an email. */
+gboolean file_is_email (const gchar *filename)
+{
+ FILE *fp = NULL;
+ gchar buffer[2048];
+ gint i = 0;
+ gint score = 0;
+ if (filename == NULL)
+ return FALSE;
+ if ((fp = g_fopen(filename, "rb")) == NULL)
+ return FALSE;
+ while (i < 60 && score < 4
+ && fgets(buffer, sizeof (buffer), fp) > 0) {
+ if (!strncmp(buffer, "Return-Path:", strlen("Return-Path:")))
+ score++;
+ if (!strncmp(buffer, "From:", strlen("From:")))
+ score++;
+ if (!strncmp(buffer, "To:", strlen("To:")))
+ score++;
+ if (!strncmp(buffer, "Subject:", strlen("Subject:")))
+ score++;
+ i++;
+ }
+ fclose(fp);
+ return (score >= 4);
+}