From c41017a0bd664e6dfd99ebb7201c44122a31097f Mon Sep 17 00:00:00 2001 From: Colin Leroy Date: Thu, 21 Nov 2002 14:19:29 +0000 Subject: [PATCH] * src/procmsg.[ch] Add procmsg_remove_special_headers() * src/mh.c Use procmsg_remove_special_headers() for previous fix --- ChangeLog.claws | 8 ++++++++ configure.in | 2 +- src/mh.c | 46 ++++++++-------------------------------------- src/procmsg.c | 41 ++++++++++++++++++++++++----------------- src/procmsg.h | 3 +++ 5 files changed, 44 insertions(+), 56 deletions(-) diff --git a/ChangeLog.claws b/ChangeLog.claws index 15ab0fdae..a14d05948 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,3 +1,11 @@ +2002-11-21 [colin] 0.8.5claws175 + + * src/procmsg.[ch] + Add procmsg_remove_special_headers() + * src/mh.c + Use procmsg_remove_special_headers() for + previous fix + 2002-11-21 [colin] 0.8.5claws174 * src/mh.c diff --git a/configure.in b/configure.in index 252fb03e7..de2063dc4 100644 --- a/configure.in +++ b/configure.in @@ -11,7 +11,7 @@ MINOR_VERSION=8 MICRO_VERSION=5 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=claws174 +EXTRA_VERSION=claws175 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION dnl set $target diff --git a/src/mh.c b/src/mh.c index b8d5f0bca..55bcf56b3 100644 --- a/src/mh.c +++ b/src/mh.c @@ -566,40 +566,6 @@ gint mh_move_msgs_with_dest(Folder *folder, FolderItem *dest, GSList *msglist) return ret; } -static void mh_remove_queue_headers (const gchar *file) -{ - FILE *fp, *fp2; - char *tmp; - fp = fopen(file, "rb"); - tmp = get_tmp_file(); - - fp2 = fopen(tmp, "wb"); - if (fp && fp2) { - char buf[BUFFSIZE]; - int len; - while (fgets(buf, sizeof(buf), fp) != NULL) - if (buf[0] == '\r' || buf[0] == '\n') - break; - - while ((len=fread(buf, sizeof(char), sizeof(buf), fp)) > 0) { - fwrite(buf, len, 1, fp2); - } - fclose(fp); - fclose(fp2); - move_file(tmp, file, TRUE); - } else { - if (fp) - fclose(fp); - else - g_warning (_("Couldn't fopen(\"%s\",\"rb\")\n"), file); - if (fp2) - fclose(fp2); - else - g_warning (_("Couldn't fopen(\"%s\",\"wb\")\n"), tmp); - } - g_free(tmp); -} - gint mh_copy_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo) { gchar *srcfile; @@ -634,16 +600,20 @@ gint mh_copy_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo) msginfo->msgnum, dest->path); - if (copy_file(srcfile, destfile, TRUE) < 0) { + if ((MSG_IS_QUEUED(msginfo->flags) || MSG_IS_DRAFT(msginfo->flags)) + && dest->stype != F_QUEUE && dest->stype != F_DRAFT) { + if (procmsg_remove_special_headers(srcfile, destfile) !=0) { + g_free(srcfile); + g_free(destfile); + return -1; + } + } else if (copy_file(srcfile, destfile, TRUE) < 0) { FILE_OP_ERROR(srcfile, "copy"); g_free(srcfile); g_free(destfile); return -1; } - if ((MSG_IS_QUEUED(msginfo->flags) || MSG_IS_DRAFT(msginfo->flags)) - && dest->stype != F_QUEUE && dest->stype != F_DRAFT) - mh_remove_queue_headers(destfile); if (prefs && prefs->enable_folder_chmod && prefs->folder_chmod) { if (chmod(destfile, prefs->folder_chmod) < 0) diff --git a/src/procmsg.c b/src/procmsg.c index 98e0edce8..aca7ca05b 100644 --- a/src/procmsg.c +++ b/src/procmsg.c @@ -903,12 +903,33 @@ gint procmsg_send_queue(FolderItem *queue, gboolean save_msgs) return ret; } +gint procmsg_remove_special_headers(const gchar *in, const gchar *out) +{ + FILE *fp, *outfp; + gchar buf[BUFFSIZE]; + + if ((fp = fopen(in, "rb")) == NULL) { + FILE_OP_ERROR(in, "fopen"); + return -1; + } + if ((outfp = fopen(out, "wb")) == NULL) { + FILE_OP_ERROR(out, "fopen"); + fclose(fp); + return -1; + } + while (fgets(buf, sizeof(buf), fp) != NULL) + if (buf[0] == '\r' || buf[0] == '\n') break; + while (fgets(buf, sizeof(buf), fp) != NULL) + fputs(buf, outfp); + fclose(outfp); + fclose(fp); + return 0; +} gint procmsg_save_to_outbox(FolderItem *outbox, const gchar *file, gboolean is_queued) { gint num; - FILE *fp; MsgInfo *msginfo; debug_print("saving sent message...\n"); @@ -920,26 +941,12 @@ gint procmsg_save_to_outbox(FolderItem *outbox, const gchar *file, /* remove queueing headers */ if (is_queued) { gchar tmp[MAXPATHLEN + 1]; - gchar buf[BUFFSIZE]; - FILE *outfp; g_snprintf(tmp, sizeof(tmp), "%s%ctmpmsg.out.%08x", get_rc_dir(), G_DIR_SEPARATOR, (guint)random()); - if ((fp = fopen(file, "rb")) == NULL) { - FILE_OP_ERROR(file, "fopen"); - return -1; - } - if ((outfp = fopen(tmp, "wb")) == NULL) { - FILE_OP_ERROR(tmp, "fopen"); - fclose(fp); + + if (procmsg_remove_special_headers(file, tmp) !=0) return -1; - } - while (fgets(buf, sizeof(buf), fp) != NULL) - if (buf[0] == '\r' || buf[0] == '\n') break; - while (fgets(buf, sizeof(buf), fp) != NULL) - fputs(buf, outfp); - fclose(outfp); - fclose(fp); folder_item_scan(outbox); if ((num = folder_item_add_msg(outbox, tmp, TRUE)) < 0) { diff --git a/src/procmsg.h b/src/procmsg.h index e618b32d5..f493b9883 100644 --- a/src/procmsg.h +++ b/src/procmsg.h @@ -287,4 +287,7 @@ gint msginfo_update_callback_register(MsgInfoUpdateFunc func, gpointer data); void msginfo_update_callback_unregister(gint id); void msginfo_update_item (MsgInfo *info); +gint procmsg_remove_special_headers (const gchar *in, + const gchar *out); + #endif /* __PROCMSG_H__ */ -- 2.25.1