/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2004 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
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include <glib/gi18n.h>
#include <stdio.h>
#include <string.h>
-#include <locale.h>
+#if HAVE_LOCALE_H
+# include <locale.h>
+#endif
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
switch (mimeinfo->content) {
case MIMECONTENT_FILE:
if (mimeinfo->tmp)
- unlink(mimeinfo->data.filename);
+ g_unlink(mimeinfo->data.filename);
g_free(mimeinfo->data.filename);
break;
g_free(mimeinfo->subtype);
g_free(mimeinfo->description);
g_free(mimeinfo->id);
+ g_free(mimeinfo->location);
g_hash_table_foreach_remove(mimeinfo->typeparameters,
procmime_mimeinfo_parameters_destroy, NULL);
g_node_destroy(node);
}
-#if 0 /* UNUSED */
-MimeInfo *procmime_mimeinfo_insert(MimeInfo *parent, MimeInfo *mimeinfo)
-{
- MimeInfo *child = parent->children;
-
- if (!child)
- parent->children = mimeinfo;
- else {
- while (child->next != NULL)
- child = child->next;
-
- child->next = mimeinfo;
- }
-
- mimeinfo->parent = parent;
- mimeinfo->level = parent->level + 1;
-
- return mimeinfo;
-}
-
-void procmime_mimeinfo_replace(MimeInfo *old, MimeInfo *new)
-{
- MimeInfo *parent = old->parent;
- MimeInfo *child;
-
- g_return_if_fail(parent != NULL);
- g_return_if_fail(new->next == NULL);
-
- for (child = parent->children; child && child != old;
- child = child->next)
- ;
- if (!child) {
- g_warning("oops: parent can't find it's own child");
- return;
- }
- procmime_mimeinfo_free_all(old);
-
- if (child == parent->children) {
- new->next = parent->children->next;
- parent->children = new;
- } else {
- new->next = child->next;
- child = new;
- }
-}
-#endif
-
MimeInfo *procmime_mimeinfo_parent(MimeInfo *mimeinfo)
{
g_return_val_if_fail(mimeinfo != NULL, NULL);
if (!filename || !is_file_exist(filename))
return NULL;
- if (msginfo->folder->stype != F_QUEUE &&
- msginfo->folder->stype != F_DRAFT)
+ if (!folder_has_parent_of_type(msginfo->folder, F_QUEUE) &&
+ !folder_has_parent_of_type(msginfo->folder, F_DRAFT))
mimeinfo = procmime_scan_file(filename);
else
mimeinfo = procmime_scan_queue_file(filename);
encoding == ENC_BINARY)
return TRUE;
- infp = fopen(mimeinfo->data.filename, "rb");
+ infp = g_fopen(mimeinfo->data.filename, "rb");
if (!infp) {
perror("fopen");
return FALSE;
outfp = get_tmpfile_in_dir(get_mime_tmp_dir(), &tmpfilename);
if (!outfp) {
perror("tmpfile");
+ fclose(infp);
return FALSE;
}
tmp_file = TRUE;
while ((ftell(infp) < readend) && (fgets(buf, sizeof(buf), infp) != NULL)) {
gint len;
len = qp_decode_line(buf);
- fwrite(buf, len, 1, outfp);
+ fwrite(buf, 1, len, outfp);
}
} else if (encoding == ENC_BASE64) {
gchar outbuf[BUFFSIZE];
if (!tmpfp) {
perror("tmpfile");
if (tmp_file) fclose(outfp);
+ fclose(infp);
return FALSE;
}
}
stat(tmpfilename, &statbuf);
if (mimeinfo->tmp && (mimeinfo->data.filename != NULL))
- unlink(mimeinfo->data.filename);
- if (mimeinfo->data.filename != NULL)
- g_free(mimeinfo->data.filename);
+ g_unlink(mimeinfo->data.filename);
+ g_free(mimeinfo->data.filename);
mimeinfo->data.filename = tmpfilename;
mimeinfo->tmp = TRUE;
mimeinfo->offset = 0;
gchar *tmpfilename;
struct stat statbuf;
+ if (mimeinfo->content == MIMECONTENT_EMPTY)
+ return TRUE;
+
if (mimeinfo->encoding_type != ENC_UNKNOWN &&
mimeinfo->encoding_type != ENC_BINARY &&
mimeinfo->encoding_type != ENC_7BIT &&
}
if (mimeinfo->content == MIMECONTENT_FILE) {
- if ((infp = fopen(mimeinfo->data.filename, "rb")) == NULL) {
+ if ((infp = g_fopen(mimeinfo->data.filename, "rb")) == NULL) {
g_warning("Can't open file %s\n", mimeinfo->data.filename);
return FALSE;
}
fclose(infp);
return FALSE;
}
- if ((tmp_fp = fopen(tmp_file, "rb")) == NULL) {
+ if ((tmp_fp = g_fopen(tmp_file, "rb")) == NULL) {
FILE_OP_ERROR(tmp_file, "fopen");
- unlink(tmp_file);
+ g_unlink(tmp_file);
g_free(tmp_file);
fclose(infp);
return FALSE;
if (tmp_file) {
fclose(tmp_fp);
- unlink(tmp_file);
+ g_unlink(tmp_file);
g_free(tmp_file);
}
} else if (encoding == ENC_QUOTED_PRINTABLE) {
if (mimeinfo->content == MIMECONTENT_FILE) {
if (mimeinfo->tmp && (mimeinfo->data.filename != NULL))
- unlink(mimeinfo->data.filename);
+ g_unlink(mimeinfo->data.filename);
g_free(mimeinfo->data.filename);
} else if (mimeinfo->content == MIMECONTENT_MEM) {
if (mimeinfo->tmp && (mimeinfo->data.mem != NULL))
if (mimeinfo->encoding_type != ENC_BINARY && !procmime_decode_content(mimeinfo))
return -1;
- if ((infp = fopen(mimeinfo->data.filename, "rb")) == NULL) {
+ if ((infp = g_fopen(mimeinfo->data.filename, "rb")) == NULL) {
FILE_OP_ERROR(mimeinfo->data.filename, "fopen");
return -1;
}
fclose(infp);
return -1;
}
- if ((outfp = fopen(outfile, "wb")) == NULL) {
+ if ((outfp = g_fopen(outfile, "wb")) == NULL) {
FILE_OP_ERROR(outfile, "fopen");
fclose(infp);
return -1;
fclose(infp);
if (fclose(outfp) == EOF) {
FILE_OP_ERROR(outfile, "fclose");
- unlink(outfile);
+ g_unlink(outfile);
return -1;
}
renderer_list = NULL;
rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, RENDERER_RC, NULL);
- f = fopen(rcpath, "rb");
+ f = g_fopen(rcpath, "rb");
g_free(rcpath);
if (f == NULL)
return NULL;
}
- tmpfp = fopen(tmpfile, "rb");
+ tmpfp = g_fopen(tmpfile, "rb");
if (tmpfp == NULL) {
g_free(tmpfile);
return NULL;
oldout = dup(1);
dup2(fileno(outfp), 1);
-
+
p = popen(renderer->renderer, "w");
if (p != NULL) {
size_t count;
dup2(oldout, 1);
/* CodeConverter seems to have no effect here */
} else if (mimeinfo->type == MIMETYPE_TEXT && !g_ascii_strcasecmp(mimeinfo->subtype, "html")) {
- HTMLParser *parser;
+ SC_HTMLParser *parser;
CodeConverter *conv;
conv = conv_code_converter_new(src_codeset);
- parser = html_parser_new(tmpfp, conv);
- while ((str = html_parse(parser)) != NULL) {
+ parser = sc_html_parser_new(tmpfp, conv);
+ while ((str = sc_html_parse(parser)) != NULL) {
fputs(str, outfp);
}
- html_parser_destroy(parser);
+ sc_html_parser_destroy(parser);
conv_code_converter_destroy(conv);
} else if (mimeinfo->type == MIMETYPE_TEXT && !g_ascii_strcasecmp(mimeinfo->subtype, "enriched")) {
ERTFParser *parser;
fclose(tmpfp);
rewind(outfp);
- unlink(tmpfile);
+ g_unlink(tmpfile);
g_free(tmpfile);
return outfp;
if (!mimeinfo) return NULL;
partinfo = mimeinfo;
- while (partinfo && partinfo->type != MIMETYPE_TEXT)
+ while (partinfo && partinfo->type != MIMETYPE_TEXT) {
partinfo = procmime_mimeinfo_next(partinfo);
+ }
+ if (partinfo)
+ outfp = procmime_get_text_content(partinfo);
+
+ procmime_mimeinfo_free_all(mimeinfo);
+
+ return outfp;
+}
+
+
+static gboolean find_encrypted_func(GNode *node, gpointer data)
+{
+ MimeInfo *mimeinfo = (MimeInfo *) node->data;
+ MimeInfo **encinfo = (MimeInfo **) data;
+
+ if (privacy_mimeinfo_is_encrypted(mimeinfo)) {
+ *encinfo = mimeinfo;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static MimeInfo *find_encrypted_part(MimeInfo *rootinfo)
+{
+ MimeInfo *encinfo = NULL;
+
+ g_node_traverse(rootinfo->node, G_IN_ORDER, G_TRAVERSE_ALL, -1,
+ find_encrypted_func, &encinfo);
+
+ return encinfo;
+}
+
+/* search the first encrypted text part of (multipart) MIME message,
+ decode, convert it and output to outfp. */
+FILE *procmime_get_first_encrypted_text_content(MsgInfo *msginfo)
+{
+ FILE *outfp = NULL;
+ MimeInfo *mimeinfo, *partinfo, *encinfo;
+
+ g_return_val_if_fail(msginfo != NULL, NULL);
+
+ mimeinfo = procmime_scan_message(msginfo);
+ if (!mimeinfo) {
+ return NULL;
+ }
+
+ partinfo = mimeinfo;
+ if ((encinfo = find_encrypted_part(partinfo)) != NULL) {
+ debug_print("decrypting message part\n");
+ if (privacy_mimeinfo_decrypt(encinfo) < 0)
+ return NULL;
+ }
+ partinfo = mimeinfo;
+ while (partinfo && partinfo->type != MIMETYPE_TEXT) {
+ partinfo = procmime_mimeinfo_next(partinfo);
+ }
if (partinfo)
outfp = procmime_get_text_content(partinfo);
return outfp;
}
+gboolean procmime_msginfo_is_encrypted(MsgInfo *msginfo)
+{
+ MimeInfo *mimeinfo, *partinfo;
+ gboolean result = FALSE;
+
+ g_return_val_if_fail(msginfo != NULL, FALSE);
+
+ mimeinfo = procmime_scan_message(msginfo);
+ if (!mimeinfo) {
+ return FALSE;
+ }
+
+ partinfo = mimeinfo;
+ result = (find_encrypted_part(partinfo) != NULL);
+ procmime_mimeinfo_free_all(mimeinfo);
+
+ return result;
+}
+
gboolean procmime_find_string_part(MimeInfo *mimeinfo, const gchar *filename,
const gchar *str, StrFindFunc find_func)
{
if (basetmp == NULL)
basetmp = "mimetmp";
basetmp = g_path_get_basename(basetmp);
- if (*basetmp == '\0') basetmp = g_strdup("mimetmp");
+ if (*basetmp == '\0')
+ basetmp = g_strdup("mimetmp");
base = conv_filename_from_utf8(basetmp);
+ g_free((gchar*)basetmp);
subst_for_shellsafe_filename(base);
}
GList *list = NULL;
FILE *fp;
gchar buf[BUFFSIZE];
- guchar *p;
+ gchar *p;
gchar *delim;
MimeType *mime_type;
gboolean fp_is_glob_file = TRUE;
if (mime_type_list)
return mime_type_list;
- if ((fp = fopen("/usr/share/mime/globs", "rb")) == NULL) {
+ if ((fp = g_fopen("/usr/share/mime/globs", "rb")) == NULL) {
fp_is_glob_file = FALSE;
- if ((fp = fopen("/etc/mime.types", "rb")) == NULL) {
- if ((fp = fopen(SYSCONFDIR "/mime.types", "rb"))
+ if ((fp = g_fopen("/etc/mime.types", "rb")) == NULL) {
+ if ((fp = g_fopen(SYSCONFDIR "/mime.types", "rb"))
== NULL) {
FILE_OP_ERROR(SYSCONFDIR "/mime.types",
"fopen");
p = buf;
if (fp_is_glob_file) {
- while (*p && !isspace(*p) && (*p!=':')) p++;
+ while (*p && !g_ascii_isspace(*p) && (*p!=':')) p++;
} else {
- while (*p && !isspace(*p)) p++;
+ while (*p && !g_ascii_isspace(*p)) p++;
}
if (*p) {
mime_type->sub_type = g_strdup(delim + 1);
if (fp_is_glob_file) {
- while (*p && (isspace(*p)||(*p=='*')||(*p=='.'))) p++;
+ while (*p && (g_ascii_isspace(*p)||(*p=='*')||(*p=='.'))) p++;
} else {
- while (*p && isspace(*p)) p++;
+ while (*p && g_ascii_isspace(*p)) p++;
}
if (*p)
return ENC_8BIT;
}
-EncodingType procmime_get_encoding_for_text_file(const gchar *file)
+EncodingType procmime_get_encoding_for_text_file(const gchar *file, gboolean *has_binary)
{
FILE *fp;
guchar buf[BUFFSIZE];
size_t octet_chars = 0;
size_t total_len = 0;
gfloat octet_percentage;
+ gboolean force_b64 = FALSE;
- if ((fp = fopen(file, "rb")) == NULL) {
+ if ((fp = g_fopen(file, "rb")) == NULL) {
FILE_OP_ERROR(file, "fopen");
return ENC_UNKNOWN;
}
for (p = buf, i = 0; i < len; ++p, ++i) {
if (*p & 0x80)
++octet_chars;
+ if (*p == '\0') {
+ force_b64 = TRUE;
+ *has_binary = TRUE;
+ }
}
total_len += len;
}
"8bit chars: %d / %d (%f%%)\n", octet_chars, total_len,
100.0 * octet_percentage);
- if (octet_percentage > 0.20) {
+ if (octet_percentage > 0.20 || force_b64) {
debug_print("using BASE64\n");
return ENC_BASE64;
} else if (octet_chars > 0) {
return g_strdup_printf("%s/%s", type_str, subtype);
}
-int procmime_parse_mimepart(MimeInfo *parent,
+static int procmime_parse_mimepart(MimeInfo *parent,
gchar *content_type,
gchar *content_encoding,
gchar *content_description,
gchar *content_id,
gchar *content_disposition,
+ gchar *content_location,
const gchar *filename,
guint offset,
guint length);
NULL, TRUE},
{"Content-Disposition:",
NULL, TRUE},
+ {"Content-Location:",
+ NULL, TRUE},
{"MIME-Version:",
NULL, TRUE},
{NULL, NULL, FALSE}};
procmime_decode_content(mimeinfo);
- fp = fopen(mimeinfo->data.filename, "rb");
+ fp = g_fopen(mimeinfo->data.filename, "rb");
if (fp == NULL) {
FILE_OP_ERROR(mimeinfo->data.filename, "fopen");
return;
g_free(hentry[4].body);
hentry[4].body = tmp;
}
+ if (hentry[5].body != NULL) {
+ tmp = conv_unmime_header(hentry[5].body, NULL);
+ g_free(hentry[5].body);
+ hentry[5].body = tmp;
+ }
content_start = ftell(fp);
fclose(fp);
procmime_parse_mimepart(mimeinfo,
hentry[0].body, hentry[1].body,
hentry[2].body, hentry[3].body,
- hentry[4].body,
+ hentry[4].body, hentry[5].body,
mimeinfo->data.filename, content_start,
mimeinfo->length - (content_start - mimeinfo->offset));
NULL, TRUE},
{"Content-Disposition:",
NULL, TRUE},
+ {"Content-Location:",
+ NULL, TRUE},
{NULL, NULL, FALSE}};
gchar *p, *tmp;
gchar *boundary;
procmime_decode_content(mimeinfo);
- fp = fopen(mimeinfo->data.filename, "rb");
+ fp = g_fopen(mimeinfo->data.filename, "rb");
if (fp == NULL) {
FILE_OP_ERROR(mimeinfo->data.filename, "fopen");
return;
result = procmime_parse_mimepart(mimeinfo,
hentry[0].body, hentry[1].body,
hentry[2].body, hentry[3].body,
- hentry[4].body,
+ hentry[4].body, hentry[5].body,
mimeinfo->data.filename, lastoffset,
(ftell(fp) - strlen(buf)) - lastoffset - 1);
}
g_free(hentry[4].body);
hentry[4].body = tmp;
}
+ if (hentry[5].body != NULL) {
+ tmp = conv_unmime_header(hentry[5].body, NULL);
+ g_free(hentry[5].body);
+ hentry[5].body = tmp;
+ }
lastoffset = ftell(fp);
}
}
value[0] = '\0';
value++;
+ while (value[0] == ' ')
+ value++;
g_strdown(attribute);
*tmp = '\0';
}
+ if (attribute) {
+ while (attribute[0] == ' ')
+ attribute++;
+ while (attribute[strlen(attribute)-1] == ' ')
+ attribute[strlen(attribute)-1] = '\0';
+ }
+ if (value) {
+ while (value[0] == ' ')
+ value++;
+ while (value[strlen(value)-1] == ' ')
+ value[strlen(value)-1] = '\0';
+ }
if (strrchr(attribute, '*') != NULL) {
gchar *tmpattr;
gchar *charset, *lang, *oldvalue, *newvalue;
attribute = (gchar *) cur->data;
- if (!g_hash_table_lookup_extended(table, attribute, (gpointer *) &key, (gpointer *) &value))
+ if (!g_hash_table_lookup_extended(
+ table, attribute, (gpointer *)(gchar *) &key, (gpointer *)(gchar *) &value))
continue;
charset = value;
mimeinfo->type = MIMETYPE_TEXT;
mimeinfo->subtype = g_strdup("plain");
if (g_hash_table_lookup(mimeinfo->typeparameters,
- "charset") == NULL)
+ "charset") == NULL) {
g_hash_table_insert(mimeinfo->typeparameters,
- g_strdup("charset"),
- g_strdup("us-ascii"));
+ g_strdup("charset"),
+ g_strdup(
+ conv_get_locale_charset_str_no_utf8()));
+ }
} else {
gchar *type, *subtype, *params;
return;
}
-int procmime_parse_mimepart(MimeInfo *parent,
+static int procmime_parse_mimepart(MimeInfo *parent,
gchar *content_type,
gchar *content_encoding,
gchar *content_description,
gchar *content_id,
gchar *content_disposition,
+ gchar *content_location,
const gchar *filename,
guint offset,
guint length)
mimeinfo->type = MIMETYPE_TEXT;
mimeinfo->subtype = g_strdup("plain");
if (g_hash_table_lookup(mimeinfo->typeparameters,
- "charset") == NULL)
- g_hash_table_insert(mimeinfo->typeparameters, g_strdup("charset"), g_strdup("us-ascii"));
+ "charset") == NULL) {
+ g_hash_table_insert(mimeinfo->typeparameters,
+ g_strdup("charset"),
+ g_strdup(
+ conv_get_locale_charset_str_no_utf8()));
+ }
}
if (content_encoding != NULL) {
else
mimeinfo->id = NULL;
+ if (content_location != NULL)
+ mimeinfo->location = g_strdup(content_location);
+ else
+ mimeinfo->location = NULL;
+
if (content_disposition != NULL)
procmime_parse_content_disposition(content_disposition, mimeinfo);
else
g_return_val_if_fail(filename != NULL, NULL);
/* Open file */
- if ((fp = fopen(filename, "rb")) == NULL)
+ if ((fp = g_fopen(filename, "rb")) == NULL)
return NULL;
/* Skip queue header */
while (fgets(buf, sizeof(buf), fp) != NULL)
ENC_AS_TOKEN,
ENC_AS_QUOTED_STRING,
ENC_AS_EXTENDED,
+ ENC_TO_ASCII,
} EncodeAs;
typedef struct _ParametersData {
FILE *fp;
guint len;
+ guint ascii_only;
} ParametersData;
static void write_parameters(gpointer key, gpointer value, gpointer user_data)
{
gchar *param = key;
- gchar *val = value, *valpos;
+ gchar *val = value, *valpos, *tmp;
ParametersData *pdata = (ParametersData *)user_data;
GString *buf = g_string_new("");
EncodeAs encas = ENC_AS_TOKEN;
for (valpos = val; *valpos != 0; valpos++) {
- if (!IS_ASCII(*valpos)) {
+ if (!IS_ASCII(*valpos) || *valpos == '"') {
encas = ENC_AS_EXTENDED;
break;
}
case ';':
case ':':
case '\\':
- case '"':
+ case '\'':
case '/':
case '[':
case ']':
continue;
}
}
+
+ if (encas == ENC_AS_EXTENDED && pdata->ascii_only == TRUE)
+ encas = ENC_TO_ASCII;
switch (encas) {
case ENC_AS_TOKEN:
g_string_append_printf(buf, "%s=%s", param, val);
break;
+ case ENC_TO_ASCII:
+ tmp = g_strdup(val);
+ g_strcanon(tmp,
+ " ()<>@,';:\\/[]?=.0123456789"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz",
+ '_');
+ g_string_append_printf(buf, "%s=\"%s\"", param, tmp);
+ g_free(tmp);
+ break;
+
case ENC_AS_QUOTED_STRING:
g_string_append_printf(buf, "%s=\"%s\"", param, val);
break;
g_string_append_printf(buf, "%%%s", hexstr);
}
}
- break;
+ break;
}
if (buf->str && strlen(buf->str)) {
debug_print("procmime_write_mime_header\n");
pdata->fp = fp;
+ pdata->ascii_only = FALSE;
for (type_table = mime_type_table; type_table->str != NULL; type_table++)
if (mimeinfo->type == type_table->type) {
"Content-Type: %s/%s", type_table->str, mimeinfo->subtype);
fprintf(fp, "%s", buf);
pdata->len = strlen(buf);
+ pdata->ascii_only = TRUE;
g_free(buf);
break;
}
if (mimeinfo->id != NULL)
fprintf(fp, "Content-ID: %s\n", mimeinfo->id);
+ if (mimeinfo->location != NULL)
+ fprintf(fp, "Content-Location: %s\n", mimeinfo->location);
+
if (mimeinfo->disposition != DISPOSITIONTYPE_UNKNOWN) {
ParametersData *pdata = g_new0(ParametersData, 1);
gchar *buf = NULL;
g_free(buf);
pdata->fp = fp;
+ pdata->ascii_only = FALSE;
+
g_hash_table_foreach(mimeinfo->dispositionparameters, write_parameters, pdata);
g_free(pdata);
fprintf(fp, "\n");
/* write header */
switch (mimeinfo->content) {
case MIMECONTENT_FILE:
- if ((infp = fopen(mimeinfo->data.filename, "rb")) == NULL) {
+ if ((infp = g_fopen(mimeinfo->data.filename, "rb")) == NULL) {
FILE_OP_ERROR(mimeinfo->data.filename, "fopen");
return -1;
}
g_ascii_strncasecmp(buf, "Content-Transfer-Encoding:", 26) == 0 ||
g_ascii_strncasecmp(buf, "Content-Description:", 20) == 0 ||
g_ascii_strncasecmp(buf, "Content-ID:", 11) == 0 ||
+ g_ascii_strncasecmp(buf, "Content-Location:", 17) == 0 ||
g_ascii_strncasecmp(buf, "Content-Disposition:", 20) == 0) {
skip = TRUE;
continue;
break;
case MIMECONTENT_MEM:
- fwrite(mimeinfo->data.mem, strlen(mimeinfo->data.mem), sizeof(gchar), fp);
+ fwrite(mimeinfo->data.mem,
+ sizeof(gchar),
+ strlen(mimeinfo->data.mem),
+ fp);
break;
default:
switch (mimeinfo->content) {
case MIMECONTENT_FILE:
- if ((infp = fopen(mimeinfo->data.filename, "rb")) == NULL) {
+ if ((infp = g_fopen(mimeinfo->data.filename, "rb")) == NULL) {
FILE_OP_ERROR(mimeinfo->data.filename, "fopen");
return -1;
}
if (((str2 = strstr(str, boundary)) != NULL) && ((str2 - str) >= 2) &&
(*(str2 - 1) == '-') && (*(str2 - 2) == '-'))
*(str2 - 2) = '\0';
- fwrite(str, strlen(str), sizeof(gchar), fp);
+ fwrite(str, sizeof(gchar), strlen(str), fp);
g_free(str);
break;
if (G_NODE_IS_LEAF(mimeinfo->node)) {
switch (mimeinfo->content) {
case MIMECONTENT_FILE:
- if ((infp = fopen(mimeinfo->data.filename, "rb")) == NULL) {
+ if ((infp = g_fopen(mimeinfo->data.filename, "rb")) == NULL) {
FILE_OP_ERROR(mimeinfo->data.filename, "fopen");
return -1;
}
return 0;
case MIMECONTENT_MEM:
- fwrite(mimeinfo->data.mem, strlen(mimeinfo->data.mem), sizeof(gchar), fp);
+ fwrite(mimeinfo->data.mem,
+ sizeof(gchar),
+ strlen(mimeinfo->data.mem),
+ fp);
return 0;
default:
/* Call writer for mime type */
switch (mimeinfo->type) {
case MIMETYPE_MESSAGE:
- if (g_ascii_strcasecmp(mimeinfo->subtype, "rfc822") == 0)
+ if (g_ascii_strcasecmp(mimeinfo->subtype, "rfc822") == 0) {
return procmime_write_message_rfc822(mimeinfo, fp);
+ }
break;
case MIMETYPE_MULTIPART: