X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=attach.c;h=ccc0a8d6cab998027a017584f13a7aedace46ebd;hp=4e6fff13a979dd352b4e00a4b2ca4fb752f6b097;hb=b71c0979112af784bfa104e6abfb7072a84a00dd;hpb=9ed7a487e3a922f2cbb222961c2c9710c3a65f91 diff --git a/attach.c b/attach.c index 4e6fff1..ccc0a8d 100644 --- a/attach.c +++ b/attach.c @@ -45,7 +45,7 @@ int mutt_get_tmp_attachment (BODY * a) if (stat (a->filename, &st) == -1) return -1; - if ((fpin = fopen (a->filename, "r")) && (fpout = safe_fopen (tempfile, "w"))) { /* __FOPEN_CHECKED__ */ + if ((fpin = fopen (a->filename, "r")) && (fpout = safe_fopen (tempfile, "w"))) { mutt_copy_stream (fpin, fpout); m_strreplace(&a->filename, tempfile); a->unlink = 1; @@ -373,8 +373,9 @@ int mutt_view_attachment (FILE * fp, BODY * a, int flag, HEADER * hdr, rfc1524_entry *entry = NULL; int rc = -1; int unlink_tempfile = 0; + int pagerfd = -1; - is_message = mutt_is_message_type (a->type, a->subtype); + is_message = mutt_is_message_type(a); if (is_message && a->hdr && (a->hdr->security & ENCRYPT) && !crypt_valid_passphrase (a->hdr->security)) return (rc); @@ -444,26 +445,20 @@ int mutt_view_attachment (FILE * fp, BODY * a, int flag, HEADER * hdr, } if (use_pager) { - if (fp && !use_mailcap && a->filename) { - /* recv case */ - m_strcpy(pagerfile, sizeof(pagerfile), a->filename); - mutt_adv_mktemp (NULL, pagerfile, sizeof (pagerfile)); - } else { - mutt_mktemp (pagerfile); - } + /* recv case */ + pagerfd = m_tempfd(pagerfile, sizeof(pagerfile), NONULL(Tempdir), + fp && !use_mailcap ? a->filename : NULL); } if (use_mailcap) { pid_t thepid = 0; - int tempfd = -1, pagerfd = -1; + int tempfd = -1; if (!use_pager) mutt_endwin (NULL); if (use_pager || use_pipe) { - if (use_pager - && ((pagerfd = safe_open (pagerfile, O_CREAT | O_EXCL | O_WRONLY)) - == -1)) { + if (use_pager && pagerfd == -1) { mutt_perror ("open"); goto return_error; } @@ -671,7 +666,7 @@ static FILE *mutt_save_attachment_open (char *path, int flags) * as safe_fopen returns w/ an error if path exists */ if (flags == M_SAVE_OVERWRITE) - return fopen (path, "w"); /* __FOPEN_CHECKED__ */ + return fopen (path, "w"); return safe_fopen (path, "w"); } @@ -688,7 +683,7 @@ int mutt_save_attachment (FILE * fp, BODY * m, char *path, int flags, m->hdr && m->encoding != ENCBASE64 && m->encoding != ENCQUOTEDPRINTABLE && - mutt_is_message_type (m->type, m->subtype)) { + mutt_is_message_type(m)) { /* message type attachments are written to mail folders. */ char buf[HUGE_STRING]; @@ -789,8 +784,6 @@ int mutt_decode_save_attachment (FILE * fp, BODY * m, char *path, if (flags == M_SAVE_APPEND) s.fpout = fopen (path, "a"); - else if (flags == M_SAVE_OVERWRITE) - s.fpout = safe_fopen (path, "w"); /* __FOPEN_CHECKED__ */ else s.fpout = safe_fopen (path, "w");