/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2001 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2002 Hiroyuki Yamamoto
*
* 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
}
}
+void subst_chars(gchar *str, gchar *orig, gchar subst)
+{
+ register gchar *p = str;
+
+ while (*p) {
+ if (strchr(orig, *p) != NULL)
+ *p = subst;
+ p++;
+ }
+}
+
+void subst_for_filename(gchar *str)
+{
+ subst_chars(str, " \t\r\n\"/\\", '_');
+}
+
gboolean is_header_line(const gchar *str)
{
if (str[0] == ':') return FALSE;
return quote_level;
}
-GList *uri_list_extract_filenames(const gchar *uri_list)
-{
- GList *result = NULL;
- const gchar *p, *q;
- gchar *file;
-
- p = uri_list;
-
- while (p) {
- if (*p != '#') {
- while (isspace(*p)) p++;
- if (!strncmp(p, "file:", 5)) {
- p += 5;
- q = p;
- while (*q && *q != '\n' && *q != '\r') q++;
-
- if (q > p) {
- q--;
- while (q > p && isspace(*q)) q--;
- file = g_malloc(q - p + 2);
- strncpy(file, p, q - p + 1);
- file[q - p + 1] = '\0';
- result = g_list_append(result,file);
- }
- }
- }
- p = strchr(p, '\n');
- if (p) p++;
- }
-
- return result;
-}
-
gchar *strstr_with_skip_quote(const gchar *haystack, const gchar *needle)
{
register guint haystack_len, needle_len;
return str_array;
}
+GList *uri_list_extract_filenames(const gchar *uri_list)
+{
+ GList *result = NULL;
+ const gchar *p, *q;
+ gchar *file;
+
+ p = uri_list;
+
+ while (p) {
+ if (*p != '#') {
+ while (isspace(*p)) p++;
+ if (!strncmp(p, "file:", 5)) {
+ p += 5;
+ q = p;
+ while (*q && *q != '\n' && *q != '\r') q++;
+
+ if (q > p) {
+ q--;
+ while (q > p && isspace(*q)) q--;
+ file = g_malloc(q - p + 2);
+ strncpy(file, p, q - p + 1);
+ file[q - p + 1] = '\0';
+ result = g_list_append(result,file);
+ }
+ }
+ }
+ p = strchr(p, '\n');
+ if (p) p++;
+ }
+
+ return result;
+}
+
+#define HEX_TO_INT(val, hex) \
+{ \
+ gchar c = hex; \
+ \
+ if ('0' <= c && c <= '9') { \
+ val = c - '0'; \
+ } else if ('a' <= c && c <= 'f') { \
+ val = c - 'a' + 10; \
+ } else if ('A' <= c && c <= 'F') { \
+ val = c - 'A' + 10; \
+ } else { \
+ val = 0; \
+ } \
+}
+
/*
* We need this wrapper around g_get_home_dir(), so that
* we can fix some Windoze things here. Should be done in glibc of course
- * but as long as we are not able to do our own extensions to glibc, we do
+ * but as long as we are not able to do our own extensions to glibc, we do
* it here.
*/
gchar *get_home_dir(void)
return s.st_size;
}
+off_t get_file_size_as_crlf(const gchar *file)
+{
+ FILE *fp;
+ off_t size = 0;
+ gchar buf[BUFFSIZE];
+
+ if ((fp = fopen(file, "r")) == NULL) {
+ FILE_OP_ERROR(file, "fopen");
+ return -1;
+ }
+
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
+ strretchomp(buf);
+ size += strlen(buf) + 2;
+ }
+
+ if (ferror(fp)) {
+ FILE_OP_ERROR(file, "fgets");
+ size = -1;
+ }
+
+ fclose(fp);
+
+ return size;
+}
+
off_t get_left_file_size(FILE *fp)
{
glong pos;
return tmpfile();
}
+gchar *write_buffer_to_file(const gchar *buf, guint bufsize)
+{
+ FILE *fp;
+ gchar *tmp_file = NULL;
+
+ tmp_file = get_tmp_file();
+ fp = fopen(tmp_file, "w");
+ if (fp) {
+ fwrite(buf, 1, bufsize, fp);
+ fclose(fp);
+ }
+ else tmp_file = NULL;
+
+ return tmp_file;
+}
+
gint execute_async(gchar *const argv[])
{
pid_t pid;
gchar *p;
gchar c;
gint iustz;
- gint h, m;
+ gint offset;
time_t remoteoffset;
strncpy(zone3, zone, 3);
zone3[3] = '\0';
remoteoffset = 0;
- if (sscanf(zone, "%c%2d%2d", &c, &h, &m) == 3 &&
+ if (sscanf(zone, "%c%d", &c, &offset) == 2 &&
(c == '+' || c == '-')) {
- remoteoffset = ((h * 60) + m) * 60;
+ remoteoffset = ((offset / 100) * 60 + (offset % 100)) * 60;
if (c == '-')
remoteoffset = -remoteoffset;
} else if (!strncmp(zone, "UT" , 2) ||
* advanced Re: detection like "Re[4]", "ANTW:" or
* Re: Re: Re: Re: Re: Re: Re: Re:" stuff. */
if (subject == NULL) return FALSE;
- else return 0 == g_strcasecmp(subject, "Re: ");
+ else return 0 == g_strncasecmp(subject, "Re: ", 4);
}