X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-mime%2Frfc3676.c;h=68bf1f5c6fb8598e0a99dccdb5fe428d69f78db9;hp=51b64508c5f0265ef3341afa4050b633087d1b00;hb=9ed7a487e3a922f2cbb222961c2c9710c3a65f91;hpb=35f4e8cefa22d98782a720e4df428a1ce3be2237 diff --git a/lib-mime/rfc3676.c b/lib-mime/rfc3676.c index 51b6450..68bf1f5 100644 --- a/lib-mime/rfc3676.c +++ b/lib-mime/rfc3676.c @@ -9,29 +9,14 @@ * 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 -#include +#include + +#include #include -#include "mutt.h" -#include "handler.h" #include "state.h" -#include "lib.h" +#include "rfc3676.h" #define FLOWED_MAX 77 @@ -138,7 +123,7 @@ int rfc3676_handler (BODY * a, STATE * s) { *curline='\0'; /* respect DelSP of RfC3676 only with f=f parts */ - if ((t = (char*) mutt_get_parameter ("delsp", a->parameter))) { + if ((t = parameter_getval(a->parameter, "delsp"))) { delsp = m_strlen(t) == 3 && ascii_strncasecmp (t, "yes", 3) == 0; t = NULL; } @@ -217,31 +202,44 @@ 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]; - char tmpfile[_POSIX_PATH_MAX]; + char tmpf[_POSIX_PATH_MAX]; if (!hdr || !hdr->content || !hdr->content->filename) return; if ((in = safe_fopen (hdr->content->filename, "r")) == NULL) return; - mutt_mktemp (tmpfile); - if ((out = safe_fopen (tmpfile, "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)) { - 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); } - fclose (in); - fclose (out); - mutt_set_mtime (hdr->content->filename, tmpfile); + m_fclose(&in); + m_fclose(&out); + mutt_set_mtime (hdr->content->filename, tmpf); unlink (hdr->content->filename); - m_strreplace(&hdr->content->filename, tmpfile); + m_strreplace(&hdr->content->filename, tmpf); }