#include <lib-lib/lib-lib.h>
#include <lib-ui/curses.h>
+#include <lib-mx/mx.h>
+#include <lib-mx/hcache.h>
#include "mutt.h"
#include "imap_private.h"
#include "message.h"
-#include "mx.h"
-#include "hcache.h"
#ifdef HAVE_PGP
#include "pgp.h"
int rc, mfhrc, oldmsgcount;
int fetchlast = 0;
const char *want_headers =
- "DATE FROM SUBJECT TO CC MESSAGE-ID REFERENCES CONTENT-TYPE CONTENT-DESCRIPTION IN-REPLY-TO REPLY-TO LINES string_list_t-POST X-LABEL";
+ "DATE FROM SUBJECT TO CC MESSAGE-ID REFERENCES CONTENT-TYPE CONTENT-DESCRIPTION IN-REPLY-TO REPLY-TO LINES LIST-POST X-LABEL";
#ifdef USE_HCACHE
void *hc = NULL;
/* 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)
if ((mfhrc < -1) || ((rc != IMAP_CMD_CONTINUE) && (rc != IMAP_CMD_OK))) {
imap_free_header_data((void *)&h.data);
- fclose (fp);
+ m_fclose(&fp);
mutt_hcache_close (hc);
return -1;
}
if ((mfhrc < -1) || ((rc != IMAP_CMD_CONTINUE) && (rc != IMAP_CMD_OK))) {
imap_free_header_data ((void *)&h.data);
- fclose (fp);
+ m_fclose(&fp);
#ifdef USE_HCACHE
mutt_hcache_close (hc);
#endif /* USE_HCACHE */
mutt_hcache_close (hc);
#endif /* USE_HCACHE */
- fclose (fp);
+ m_fclose(&fp);
if (ctx->msgcount > oldmsgcount)
mx_update_context (ctx, ctx->msgcount - oldmsgcount);
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
return 0;
bail:
- safe_fclose (&msg->fp);
+ m_fclose(&msg->fp);
if (cache->path) {
unlink (cache->path);
p_delete(&cache->path);
pc = imap_next_word (pc);
mutt_error ("%s", pc);
mutt_sleep (1);
- fclose (fp);
+ m_fclose(&fp);
goto fail;
}
flush_buffer (buf, &len, idata->conn);
mutt_socket_write (idata->conn, "\r\n");
- fclose (fp);
+ m_fclose(&fp);
do
rc = imap_cmd_step (idata);
/* msg_parse_fetch: handle headers returned from header fetch */
static int msg_parse_fetch (IMAP_HEADER * h, char *s)
{
- char tmp[SHORT_STRING];
+ char tmp[STRING];
char *ptmp;
if (!s)