/* recv case */
m_strcpy(pagerfile, sizeof(pagerfile), a->filename);
mutt_adv_mktemp (NULL, pagerfile, sizeof (pagerfile));
- }
- else
+ } else {
mutt_mktemp (pagerfile);
+ }
}
if (use_mailcap) {
mutt_parse_mime_message (Context, cur);
mutt_message_hook (Context, cur, M_MESSAGEHOOK);
- mutt_mktemp (tempfile);
- if ((fpout = safe_fopen (tempfile, "w")) == NULL) {
+ fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL);
+ if (!fpout) {
mutt_error _("Could not create temporary file!");
-
- return (0);
+ return 0;
}
if (DisplayFilter && *DisplayFilter) {
if (!plaintext) {
/* decode to a tempfile, saving the original destination */
fp = s->fpout;
- mutt_mktemp (tempfile);
- if ((s->fpout = safe_fopen (tempfile, "w")) == NULL) {
+ s->fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL);
+ if (!s->fpout) {
mutt_error _("Unable to open temporary file!");
-
goto bail;
}
/* decoding the attachment changes the size and offset, so save a copy
s->prefix = NULL;
decode = 1;
- }
- else
+ } else {
b->type = TYPETEXT;
+ }
mutt_decode_attachment (b, s);
struct stat st;
string_list_t *cur, **last = NULL, *tmp;
- mutt_mktemp (path);
- if ((ofp = safe_fopen (path, "w")) == NULL) {
+ ofp = m_tempfile(path, sizeof(path), NONULL(Tempdir), NULL);
+ if (!ofp) {
mutt_perror (path);
return;
}
void mutt_help (int menu)
{
- char t[_POSIX_PATH_MAX];
- char buf[SHORT_STRING];
- const char *desc;
- FILE *f;
- struct binding_t *funcs;
-
- mutt_mktemp (t);
-
- funcs = km_get_table (menu);
- desc = mutt_getnamebyvalue (menu, Menus);
- if (!desc)
- desc = _("<UNKNOWN>");
+ char tmp[_POSIX_PATH_MAX];
+ char buf[SHORT_STRING];
+ const char *desc;
+ FILE *f;
+ struct binding_t *funcs;
+
+ funcs = km_get_table (menu);
+ desc = mutt_getnamebyvalue (menu, Menus);
+ if (!desc)
+ desc = _("<UNKNOWN>");
+
+ do {
+ f = m_tempfile(tmp, sizeof(tmp), NONULL(Tempdir), NULL);
+ if (!f) {
+ mutt_perror(tmp);
+ return;
+ }
- do {
- if ((f = safe_fopen (t, "w")) == NULL) {
- mutt_perror (t);
- return;
- }
+ dump_menu(f, menu);
+ if (menu != MENU_EDITOR && menu != MENU_PAGER) {
+ fputs(_("\nGeneric bindings:\n\n"), f);
+ dump_menu(f, MENU_GENERIC);
+ }
- dump_menu (f, menu);
- if (menu != MENU_EDITOR && menu != MENU_PAGER) {
- fputs (_("\nGeneric bindings:\n\n"), f);
- dump_menu (f, MENU_GENERIC);
- }
+ fputs(_("\nUnbound functions:\n\n"), f);
+ if (funcs)
+ dump_unbound(f, funcs, Keymaps[menu], NULL);
- fputs (_("\nUnbound functions:\n\n"), f);
- if (funcs)
- dump_unbound (f, funcs, Keymaps[menu], NULL);
- if (menu != MENU_PAGER)
- dump_unbound (f, OpGeneric, Keymaps[MENU_GENERIC], Keymaps[menu]);
+ if (menu != MENU_PAGER)
+ dump_unbound (f, OpGeneric, Keymaps[MENU_GENERIC], Keymaps[menu]);
- fclose (f);
+ fclose(f);
- snprintf (buf, sizeof (buf), _("Help for %s"), desc);
- }
- while
- (mutt_do_pager (buf, t,
- M_PAGER_RETWINCH | M_PAGER_MARKER | M_PAGER_NSKIP, NULL)
- == OP_REFORMAT_WINCH);
+ snprintf(buf, sizeof (buf), _("Help for %s"), desc);
+ } while (mutt_do_pager(buf, tmp,
+ M_PAGER_RETWINCH | M_PAGER_MARKER | M_PAGER_NSKIP,
+ NULL) == OP_REFORMAT_WINCH);
}
CONTEXT * dest __attribute__ ((unused)),
HEADER * hdr __attribute__ ((unused)))
{
- char tmp[_POSIX_PATH_MAX];
+ char tmp[_POSIX_PATH_MAX];
- mutt_mktemp (tmp);
- if ((msg->fp = safe_fopen (tmp, "w")) == NULL) {
- mutt_perror (tmp);
- return (-1);
- }
- msg->path = m_strdup(tmp);
- return 0;
+ msg->fp = m_tempfile(tmp, sizeof(tmp), NONULL(Tempdir), NULL);
+ if (!msg->fp) {
+ mutt_perror(tmp);
+ return -1;
+ }
+
+ msg->path = m_strdup(tmp);
+ return 0;
}
/* this ugly kludge is required since the last int to
/* instead of downloading all headers and then parsing them, we parse them
* as they come in. */
- mutt_mktemp (tempfile);
- if (!(fp = safe_fopen (tempfile, "w+"))) {
- mutt_error (_("Could not create temporary file %s"), tempfile);
- mutt_sleep (2);
+ fp = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL);
+ if (!fp) {
+ mutt_error(_("Could not create temporary file"));
+ mutt_sleep(2);
return -1;
}
- unlink (tempfile);
+ unlink(tempfile);
/* make sure context has room to hold the mailbox */
while ((msgend) >= idata->ctx->hdrmax)
mutt_message _("Fetching message...");
cache->uid = HEADER_DATA (h)->uid;
- mutt_mktemp (path);
- cache->path = m_strdup(path);
- if (!(msg->fp = safe_fopen (path, "w+"))) {
- p_delete(&cache->path);
+ msg->fp = m_tempfile(path, sizeof(path), NONULL(Tempdir), NULL);
+ if (!msg->fp) {
return -1;
}
+ cache->path = m_strdup(path);
/* mark this header as currently inactive so the command handler won't
* also try to update it. HACK until all this code can be moved into the
address_t *tmp = NULL;
FILE *fpout;
- mutt_mktemp (tempfname);
- if (!(fpout = safe_fopen (tempfname, "w"))) {
- mutt_perror (tempfname);
+ fpout = m_tempfile(tempfname, sizeof(tempfname), NONULL(Tempdir), NULL);
+ if (!fpout) {
+ mutt_error(_("Could not create temporary file"));
return;
}
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(Tempdir), NULL);
+ if (!out) {
+ fclose(in);
return;
}
- while (fgets (buf, sizeof (buf), in)) {
+ while (fgets(buf, sizeof (buf), in)) {
if (m_strncmp("From ", buf, 4) == 0 || buf[0] == ' ') {
fputc (' ', out);
}
return (-1);
/* Create a temporary file to write the new version of the mailbox in. */
- fp = m_tempfile (tempfile, _POSIX_PATH_MAX, NONULL(Tempdir), NULL);
+ fp = m_tempfile(tempfile, _POSIX_PATH_MAX, NONULL(Tempdir), NULL);
if (fp == NULL) {
mutt_error _("Could not create temporary file!");
mutt_sleep (5);
unlink (tempfile);
goto bail;
}
-
}
/* save the new offset for this message. we add `offset' because the
int ret;
HEADER *h = ctx->hdrs[ctx->msgcount];
- mutt_mktemp (tempfile);
- if (!(f = safe_fopen (tempfile, "w+")))
+ f = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL);
+ if (!f)
return -1;
if (!msgid)
p_delete(&cache->path);
cache->index = ctx->hdrs[msgno]->index;
- mutt_mktemp (path);
- cache->path = m_strdup(path);
- if (!(msg->fp = safe_fopen (path, "w+"))) {
- p_delete(&cache->path);
+ msg->fp = m_tempfile(path, sizeof(path), NONULL(Tempdir), NULL);
+ if (!msg->fp) {
return -1;
}
+ cache->path = m_strdup(path);
if (ctx->hdrs[msgno]->article_num == 0)
snprintf (buf, sizeof (buf), "ARTICLE %s\r\n",
p_clear(&s, 1);
s.fpin = msg->fp;
s.flags = M_CHARCONV;
- mutt_mktemp (tempfile);
- if ((s.fpout = safe_fopen (tempfile, "w+")) == NULL) {
- mutt_perror (tempfile);
+ s.fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL);
+ if (!s.fpout) {
+ mutt_error(_("Could not create temporary file"));
return (0);
}
char buf[LONG_STRING];
char tempfile[_POSIX_PATH_MAX];
- mutt_mktemp (tempfile);
- if (!(f = safe_fopen (tempfile, "w+"))) {
- mutt_perror (tempfile);
+ f = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL);
+ if (!f) {
+ mutt_error(_("Could not create temporary file"));
return PFD_FUNCT_ERROR;
}
bar.msg = _("Fetching message...");
mutt_progress_bar (&bar, 0);
- mutt_mktemp (path);
- msg->fp = safe_fopen (path, "w+");
+ msg->fp = m_tempfile(path, sizeof(path), NONULL(Tempdir), NULL);
if (!msg->fp) {
- mutt_perror (path);
- mutt_sleep (2);
+ mutt_error(_("Could not create temporary file"));
+ mutt_sleep(2);
return -1;
}
tmphdr->env = envelope_new();
mutt_make_forward_subject (tmphdr->env, Context, parent);
- mutt_mktemp (tmpbody);
- if ((tmpfp = safe_fopen (tmpbody, "w")) == NULL) {
- mutt_error (_("Can't open temporary file %s."), tmpbody);
+ tmpfp = m_tempfile(tmpbody, sizeof(tmpbody), NONULL(Tempdir), NULL);
+ if (!tmpfp) {
+ mutt_error(_("Could not create temporary file"));
return;
}
/* no MIME encapsulation */
- mutt_mktemp (tmpbody);
- if (!(tmpfp = safe_fopen (tmpbody, "w"))) {
- mutt_error (_("Can't create %s."), tmpbody);
+ tmpfp = m_tempfile(tmpbody, sizeof(tmpbody), NONULL(Tempdir), NULL);
+ if (!tmpfp) {
+ mutt_error(_("Could not create temporary file"));
header_delete(&tmphdr);
return;
}
return;
}
- mutt_mktemp (tmpbody);
- if ((tmpfp = safe_fopen (tmpbody, "w")) == NULL) {
- mutt_error (_("Can't create %s."), tmpbody);
+ tmpfp = m_tempfile(tmpbody, sizeof(tmpbody), NONULL(Tempdir), NULL);
+ if (!tmpfp) {
+ mutt_error(_("Could not create temporary file"));
header_delete(&tmphdr);
return;
}
int i;
/* Write out the message in MIME form. */
- mutt_mktemp (tempfile);
- if ((tempfp = safe_fopen (tempfile, "w")) == NULL)
- return (-1);
+ tempfp = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL);
+ if (!tempfp)
+ return -1;
#ifdef MIXMASTER
mutt_write_rfc822_header (tempfp, msg->env, msg->content, 0,
CONTEXT * ctx, /* current mailbox */
HEADER * cur)
{ /* current message */
- char buffer[LONG_STRING];
char fcc[_POSIX_PATH_MAX] = ""; /* where to copy this message */
FILE *tempfp = NULL;
BODY *pbody;
}
if (!tempfile) {
- mutt_mktemp (buffer);
- tempfp = safe_fopen (buffer, "w+");
+ char buffer[_POSIX_PATH_MAX];
+ tempfp = m_tempfile(buffer, sizeof(buffer), NONULL(Tempdir), NULL);
msg->content->filename = m_strdup(buffer);
- }
- else {
- tempfp = safe_fopen (tempfile, "a+");
+ } else {
+ tempfp = safe_fopen(tempfile, "a+");
msg->content->filename = m_strdup(tempfile);
}
a->length = sb.st_size;
}
- mutt_mktemp (temp);
- if (!(fpout = safe_fopen (temp, "w+"))) {
- mutt_perror ("fopen");
+ fpout = m_tempfile(temp, sizeof(temp), NONULL(Tempdir), NULL);
+ if (!fpout) {
+ mutt_error(_("Could not create temporary file"));
goto cleanup;
}
a->noconv = 1;
a->force_charset = 1;
- mutt_mktemp (buff);
- if ((s.fpout = safe_fopen (buff, "w")) == NULL) {
- mutt_perror ("fopen");
+ s.fpout = m_tempfile(buff, sizeof(buff), NONULL(Tempdir), NULL);
+ if (!s.fpout) {
+ mutt_error(_("Could not create temporary file"));
return;
}
s.fpin = fpin;
if (!fp)
fp = msg->fp;
- mutt_mktemp (tempfile);
- if ((f = safe_fopen (tempfile, "w")) != NULL) {
+ f = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL);
+ if (f) {
int ch_flags = CH_XMIT | CH_NONEWLINE | CH_NOQFROM;
if (!option (OPTBOUNCEDELIVERED))
mutt_copy_bytes (fp, f, h->content->length);
fclose (f);
- ret = mutt_invoke_mta (env_from, to, NULL, NULL, tempfile,
- h->content->encoding == ENC8BIT);
+ ret = mutt_invoke_mta(env_from, to, NULL, NULL, tempfile,
+ h->content->encoding == ENC8BIT);
}
if (msg)
* the message body begins with "From "
*/
if (f.magic == M_MMDF || f.magic == M_MBOX) {
- mutt_mktemp (tempfile);
- if ((tempfp = safe_fopen (tempfile, "w+")) == NULL) {
- mutt_perror (tempfile);
+ tempfp = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL);
+ if (!tempfp) {
+ mutt_error(_("Could not create temporary file"));
mx_close_mailbox (&f, NULL);
- return (-1);
+ return -1;
}
}