+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
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
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;
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)
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");
/* 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) {
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__ */