X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=attach.c;h=febe91eeab5c3c69e176aa0fb8989547423fdab5;hp=5e43321884e0b1657d128fad43c16b07f4848d30;hb=7b392ef7b50798f9eb3e7c869e634c5fef0092d1;hpb=49081299c673ceebc38d9a4f0985608cb3aecfce diff --git a/attach.c b/attach.c index 5e43321..febe91e 100644 --- a/attach.c +++ b/attach.c @@ -8,31 +8,13 @@ * 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 - #include - #include #include +#include #include "mutt.h" #include "handler.h" @@ -40,7 +22,6 @@ #include "keymap.h" #include "pager.h" #include "copy.h" -#include "mx.h" #include int mutt_get_tmp_attachment (BODY * a) @@ -130,7 +111,6 @@ int mutt_compose_attachment (BODY * a) if (r != -1 && entry->composetypecommand) { BODY *b; FILE *fp, *tfp; - char tempfile[_POSIX_PATH_MAX]; if ((fp = safe_fopen (a->filename, "r")) == NULL) { mutt_perror (_("Failure to open file to parse headers.")); @@ -140,6 +120,8 @@ int mutt_compose_attachment (BODY * a) b = mutt_read_mime_header (fp, 0); if (b) { + char tempfile[_POSIX_PATH_MAX]; + if (b->parameter) { parameter_list_wipe(&a->parameter); a->parameter = b->parameter; @@ -159,10 +141,9 @@ int mutt_compose_attachment (BODY * a) /* Remove headers by copying out data to another file, then * copying the file back */ fseeko (fp, b->offset, 0); - mutt_mktemp (tempfile); - if ((tfp = safe_fopen (tempfile, "w")) == NULL) { + tfp = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + if (!tfp) { mutt_perror (_("Failure to open file to strip headers.")); - goto bailout; } mutt_copy_stream (fp, tfp); @@ -175,7 +156,7 @@ int mutt_compose_attachment (BODY * a) goto bailout; } - mutt_free_body (&b); + body_list_wipe(&b); } } } @@ -358,7 +339,7 @@ int mutt_is_autoview (BODY * b, const char *type) mutt_check_lookup_list (b, _type, sizeof (_type)); type = _type; - if (mutt_needs_mailcap (b)) { + if (rfc1524_mailcap_isneeded(b)) { if (option (OPTIMPLICITAUTOVIEW)) return 1; @@ -400,7 +381,7 @@ int mutt_view_attachment (FILE * fp, BODY * a, int flag, HEADER * hdr, !crypt_valid_passphrase (a->hdr->security)) return (rc); use_mailcap = (flag == M_MAILCAP || - (flag == M_REGULAR && mutt_needs_mailcap (a))); + (flag == M_REGULAR && rfc1524_mailcap_isneeded(a))); snprintf (type, sizeof (type), "%s/%s", TYPE (a), a->subtype); if (use_mailcap) { @@ -469,9 +450,9 @@ int mutt_view_attachment (FILE * fp, BODY * a, int flag, HEADER * hdr, /* recv case */ m_strcpy(pagerfile, sizeof(pagerfile), a->filename); mutt_adv_mktemp (NULL, pagerfile, sizeof (pagerfile)); - } - else + } else { mutt_mktemp (pagerfile); + } } if (use_mailcap) {