X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-mime%2Frfc3676.c;h=68bf1f5c6fb8598e0a99dccdb5fe428d69f78db9;hp=e9ae0a7054fec78d3f057f77c2b2af3bb3a2a04a;hb=9ed7a487e3a922f2cbb222961c2c9710c3a65f91;hpb=16536d59024177409f49134c3f03f69855c144b9 diff --git a/lib-mime/rfc3676.c b/lib-mime/rfc3676.c index e9ae0a7..68bf1f5 100644 --- a/lib-mime/rfc3676.c +++ b/lib-mime/rfc3676.c @@ -11,6 +11,8 @@ #include +#include + #include #include "state.h" @@ -200,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]; @@ -210,20 +224,21 @@ 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) { + m_fclose(&in); return; } - while (fgets (buf, sizeof (buf), in)) { + while (fgets(buf, sizeof (buf), in)) { if (m_strncmp("From ", buf, 4) == 0 || buf[0] == ' ') { fputc (' ', out); } fputs (buf, out); } - fclose (in); - fclose (out); + m_fclose(&in); + m_fclose(&out); mutt_set_mtime (hdr->content->filename, tmpf); unlink (hdr->content->filename); m_strreplace(&hdr->content->filename, tmpf);