*/
static void shrink_histfile(void)
{
- char tmpfname[PATH_MAX];
- FILE *tmp = NULL;
+ FILE *tmpfp = NULL;
int n[HC_LAST] = { 0 };
int line, hclass, read;
char *linebuf = NULL, *p = NULL;
if (regen_file)
{
- mutt_mktemp(tmpfname, sizeof(tmpfname));
- tmp = mutt_file_fopen(tmpfname, "w+");
- if (!tmp)
+ tmpfp = mutt_file_mkstemp();
+ if (!tmpfp)
{
- mutt_perror(tmpfname);
+ mutt_perror("mutt_file_mkstemp() failed!");
goto cleanup;
}
rewind(f);
}
*p = '|';
if (n[hclass]-- <= SaveHistory)
- fprintf(tmp, "%s\n", linebuf);
+ fprintf(tmpfp, "%s\n", linebuf);
}
}
cleanup:
mutt_file_fclose(&f);
FREE(&linebuf);
- if (tmp)
+ if (tmpfp)
{
- if (fflush(tmp) == 0 && (f = fopen(HistoryFile, "w")) != NULL)
+ if (fflush(tmpfp) == 0 && (f = fopen(HistoryFile, "w")) != NULL)
{
- rewind(tmp);
- mutt_file_copy_stream(tmp, f);
+ rewind(tmpfp);
+ mutt_file_copy_stream(tmpfp, f);
mutt_file_fclose(&f);
}
- mutt_file_fclose(&tmp);
- unlink(tmpfname);
+ mutt_file_fclose(&tmpfp);
}
if (HistoryRemoveDups)
for (hclass = 0; hclass < HC_LAST; hclass++)
int imap_read_headers(struct ImapData *idata, unsigned int msn_begin, unsigned int msn_end)
{
char *hdrreq = NULL;
- FILE *fp = NULL;
- char tempfile[PATH_MAX];
int msgno, idx;
struct ImapHeader h;
struct ImapStatus *status = NULL;
/* instead of downloading all headers and then parsing them, we parse them
* as they come in. */
- mutt_mktemp(tempfile, sizeof(tempfile));
- fp = mutt_file_fopen(tempfile, "w+");
+ FILE *fp = mutt_file_mkstemp();
if (!fp)
{
- mutt_error(_("Could not create temporary file %s"), tempfile);
+ mutt_perror("mutt_file_mkstemp() failed!");
goto error_out_0;
}
- unlink(tempfile);
/* make sure context has room to hold the mailbox */
while (msn_end > ctx->hdrmax)