-#if HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <ctype.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <string.h>
-#include <errno.h>
-
-#include <lib-lib/mem.h>
-#include <lib-lib/ascii.h>
-#include <lib-lib/str.h>
-#include <lib-lib/file.h>
-#include <lib-lib/macros.h>
+#include <lib-lib/lib-lib.h>
#include <lib-crypt/crypt.h>
int mutt_get_tmp_attachment (BODY * a)
{
char type[STRING];
char tempfile[_POSIX_PATH_MAX];
#include <lib-crypt/crypt.h>
int mutt_get_tmp_attachment (BODY * a)
{
char type[STRING];
char tempfile[_POSIX_PATH_MAX];
rfc1524_expand_filename (entry->nametemplate, a->filename,
tempfile, sizeof (tempfile));
rfc1524_expand_filename (entry->nametemplate, a->filename,
tempfile, sizeof (tempfile));
mutt_copy_stream (fpin, fpout);
m_strreplace(&a->filename, tempfile);
a->unlink = 1;
if (a->stamp >= st.st_mtime)
mutt_stamp_attachment (a);
mutt_copy_stream (fpin, fpout);
m_strreplace(&a->filename, tempfile);
a->unlink = 1;
if (a->stamp >= st.st_mtime)
mutt_stamp_attachment (a);
if (rfc1524_expand_command (a, newfile, type,
command, sizeof (command))) {
/* For now, editing requires a file, no piping */
mutt_error _("Mailcap compose entry requires %%s");
if (rfc1524_expand_command (a, newfile, type,
command, sizeof (command))) {
/* For now, editing requires a file, no piping */
mutt_error _("Mailcap compose entry requires %%s");
if ((fp = safe_fopen (a->filename, "r")) == NULL) {
mutt_perror (_("Failure to open file to parse headers."));
if ((fp = safe_fopen (a->filename, "r")) == NULL) {
mutt_perror (_("Failure to open file to parse headers."));
/* Remove headers by copying out data to another file, then
* copying the file back */
fseeko (fp, b->offset, 0);
/* 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_unlink (a->filename);
if (mutt_rename_file (tempfile, a->filename) != 0) {
mutt_perror (_("Failure to rename file."));
mutt_unlink (a->filename);
if (mutt_rename_file (tempfile, a->filename) != 0) {
mutt_perror (_("Failure to rename file."));
if (rfc1524_expand_command (a, newfile, type,
command, sizeof (command))) {
/* For now, editing requires a file, no piping */
mutt_error _("Mailcap Edit entry requires %%s");
goto bailout;
if (rfc1524_expand_command (a, newfile, type,
command, sizeof (command))) {
/* For now, editing requires a file, no piping */
mutt_error _("Mailcap Edit entry requires %%s");
goto bailout;
mutt_endwin (NULL);
if (mutt_system (command) == -1) {
mutt_error (_("Error running \"%s\"!"), command);
mutt_endwin (NULL);
if (mutt_system (command) == -1) {
mutt_error (_("Error running \"%s\"!"), command);
else if (a->type == TYPETEXT) {
/* On text, default to editor */
mutt_edit_file (NONULL (Editor), a->filename);
else if (a->type == TYPETEXT) {
/* On text, default to editor */
mutt_edit_file (NONULL (Editor), a->filename);
int mutt_is_autoview (BODY * b, const char *type)
{
string_list_t *t = AutoViewList;
int mutt_is_autoview (BODY * b, const char *type)
{
string_list_t *t = AutoViewList;
- snprintf (_type, sizeof (_type), "%s/%s", TYPE (b), b->subtype);
+ snprintf(_type, sizeof(_type), "%s/%s", TYPE(b), b->subtype);
else
m_strcpy(_type, sizeof(_type), type);
mutt_check_lookup_list (b, _type, sizeof (_type));
type = _type;
else
m_strcpy(_type, sizeof(_type), type);
mutt_check_lookup_list (b, _type, sizeof (_type));
type = _type;
if (is_message && a->hdr && (a->hdr->security & ENCRYPT) &&
!crypt_valid_passphrase (a->hdr->security))
return (rc);
use_mailcap = (flag == M_MAILCAP ||
if (is_message && a->hdr && (a->hdr->security & ENCRYPT) &&
!crypt_valid_passphrase (a->hdr->security))
return (rc);
use_mailcap = (flag == M_MAILCAP ||
snprintf (type, sizeof (type), "%s/%s", TYPE (a), a->subtype);
if (use_mailcap) {
snprintf (type, sizeof (type), "%s/%s", TYPE (a), a->subtype);
if (use_mailcap) {
if (!rfc1524_mailcap_lookup (a, type, entry, 0)) {
if (flag == M_REGULAR) {
/* fallback to view as text */
if (!rfc1524_mailcap_lookup (a, type, entry, 0)) {
if (flag == M_REGULAR) {
/* fallback to view as text */
- 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);
fseeko ((s.fpin = fp), m->offset, 0);
mutt_decode_attachment (m, &s);
fseeko ((s.fpin = fp), m->offset, 0);
mutt_decode_attachment (m, &s);
return (-1);
}
if (mutt_copy_stream (ofp, nfp) == -1) {
mutt_error _("Write fault!");
return (-1);
}
if (mutt_copy_stream (ofp, nfp) == -1) {
mutt_error _("Write fault!");
if (flags == M_SAVE_APPEND)
s.fpout = fopen (path, "a");
if (flags == M_SAVE_APPEND)
s.fpout = fopen (path, "a");
snprintf (type, sizeof (type), "%s/%s", TYPE (a), a->subtype);
snprintf (type, sizeof (type), "%s/%s", TYPE (a), a->subtype);
rfc1524_mailcap_lookup (a, type, entry, M_PRINT);
if (rfc1524_expand_filename (entry->nametemplate, a->filename,
newfile, sizeof (newfile))) {
rfc1524_mailcap_lookup (a, type, entry, M_PRINT);
if (rfc1524_expand_filename (entry->nametemplate, a->filename,
newfile, sizeof (newfile))) {
if (safe_symlink (a->filename, newfile) == -1) {
if (mutt_yesorno (_("Can't match nametemplate, continue?"), M_YES)
!= M_YES) {
if (safe_symlink (a->filename, newfile) == -1) {
if (mutt_yesorno (_("Can't match nametemplate, continue?"), M_YES)
!= M_YES) {
return (0);
}
if ((thepid = mutt_create_filter (command, &fpout, NULL, NULL)) < 0) {
mutt_perror (_("Can't create filter"));
return (0);
}
if ((thepid = mutt_create_filter (command, &fpout, NULL, NULL)) < 0) {
mutt_perror (_("Can't create filter"));
- if (!ascii_strcasecmp ("text/plain", type) ||
- !ascii_strcasecmp ("application/postscript", type)) {
+ tok = mime_which_token(type, -1);
+ if (tok == MIME_TEXT_PLAIN || tok == MIME_APPLICATION_POSTSCRIPT) {
return (mutt_pipe_attachment (fp, a, NONULL (PrintCmd), NULL));
}
else if (mutt_can_decode (a)) {
return (mutt_pipe_attachment (fp, a, NONULL (PrintCmd), NULL));
}
else if (mutt_can_decode (a)) {