X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-mime%2Frfc3676.c;h=133fe3cfc0d7a24b66e1b6e1cb6863ec79876db5;hp=18680919cd1110078ff72622d787815a6783f8f1;hb=7b392ef7b50798f9eb3e7c869e634c5fef0092d1;hpb=230399f9632c37b66c1c117a17e8327eae6b3235 diff --git a/lib-mime/rfc3676.c b/lib-mime/rfc3676.c index 1868091..133fe3c 100644 --- a/lib-mime/rfc3676.c +++ b/lib-mime/rfc3676.c @@ -9,19 +9,10 @@ * please see the file GPL in the top level source directory. */ -#if HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include -#include -#include -#include -#include - #include +#include + #include #include "state.h" @@ -211,6 +202,18 @@ int rfc3676_handler (BODY * a, STATE * s) { return (0); } +/* sets mtime of 'to' to mtime of 'from' */ +static void mutt_set_mtime (const char* from, const char* to) { + struct utimbuf utim; + struct stat st; + + if (stat (from, &st) != -1) { + utim.actime = st.st_mtime; + utim.modtime = st.st_mtime; + utime (to, &utim); + } +} + void rfc3676_space_stuff (HEADER* hdr) { FILE* in = NULL, *out = NULL; char buf[LONG_STRING]; @@ -221,14 +224,15 @@ void rfc3676_space_stuff (HEADER* hdr) { if ((in = safe_fopen (hdr->content->filename, "r")) == NULL) return; - mutt_mktemp (tmpf); - if ((out = safe_fopen (tmpf, "w+")) == NULL) { - fclose (in); + + out = m_tempfile(tmpf, sizeof(tmpf), NONULL(Tempdir), NULL); + if (!out) { + fclose(in); return; } - while (fgets (buf, sizeof (buf), in)) { - if (ascii_strncmp ("From ", buf, 4) == 0 || buf[0] == ' ') { + while (fgets(buf, sizeof (buf), in)) { + if (m_strncmp("From ", buf, 4) == 0 || buf[0] == ' ') { fputc (' ', out); } fputs (buf, out);