X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-mime%2Frfc3676.c;h=0ca9ff74ce114a7c7a22617d30e304354e8f6392;hp=b93a7664c4f0652e29f1e7769fb39543a199d9c2;hb=98533911b5d5279b6f4574c66f77fbd6c772ac6f;hpb=2c56b665394c80195b976537e608b690947fcb14 diff --git a/lib-mime/rfc3676.c b/lib-mime/rfc3676.c index b93a766..0ca9ff7 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; } @@ -180,7 +165,7 @@ int rfc3676_handler (BODY * a, STATE * s) { * which may make the line look like fixed although it wasn't * so keep this in mind for later processing */ fixed = buf_len == 0 || buf[buf_len - 1] != ' ' || - (strcmp(buf + buf_off, "-- ") == 0); + (m_strcmp(buf + buf_off, "-- ") == 0); if (delsp && buf_len >= 1 && buf[buf_len-1] == ' ') buf[--buf_len] = '\0'; @@ -195,14 +180,14 @@ int rfc3676_handler (BODY * a, STATE * s) { } /* signature separator also flushes the previous paragraph */ - if (strcmp(buf + buf_off, "-- ") == 0 && curline && *curline) { + if (m_strcmp(buf + buf_off, "-- ") == 0 && curline && *curline) { print_flowed_line (curline, s, quotelevel); *curline = '\0'; curline_len = 1; } p_realloc(&curline, curline_len + buf_len - buf_off); - strcpy (curline + curline_len - 1, buf + buf_off); + m_strcpy(curline + curline_len - 1, buf_len - buf_off + 1, buf + buf_off); curline_len += buf_len - buf_off; /* if this was a fixed line the paragraph is finished */ @@ -217,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]; @@ -227,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(MCore.tmpdir), 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); + m_fclose(&in); + m_fclose(&out); mutt_set_mtime (hdr->content->filename, tmpf); unlink (hdr->content->filename); m_strreplace(&hdr->content->filename, tmpf);