Use better error msgs for tempfile
[apps/madmutt.git] / lib-mx / mh.c
index bfaaab2..2ff376f 100644 (file)
@@ -151,7 +151,7 @@ static void mh_read_sequences (struct mh_sequences *mhs, const char *path)
   }
 
   p_delete(&buff);
-  safe_fclose (&fp);
+  m_fclose(&fp);
 }
 
 int mh_buffy (const char *path)
@@ -171,6 +171,7 @@ int mh_buffy (const char *path)
 
 static int mh_mkstemp (CONTEXT * dest, FILE ** fp, char **tgt)
 {
+  static int Counter = 0;
   int fd;
   char path[_POSIX_PATH_MAX];
 
@@ -291,7 +292,7 @@ static void mh_update_sequences (CONTEXT * ctx)
       fprintf (nfp, "%s\n", buff);
     }
   }
-  safe_fclose (&ofp);
+  m_fclose(&ofp);
 
   /* now, update our unseen, flagged, and replied sequences */
   for (l = 0; l < ctx->msgcount; l++) {
@@ -331,7 +332,7 @@ static void mh_update_sequences (CONTEXT * ctx)
 
 
   /* try to commit the changes - no guarantee here */
-  safe_fclose (&nfp);
+  m_fclose(&nfp);
 
   unlink (sequences);
   if (safe_rename (tmpfname, sequences) != 0) {
@@ -390,7 +391,7 @@ static void mh_sequences_add_one (CONTEXT * ctx, int n, short unseen,
         fprintf (nfp, "%s\n", buff);
     }
   }
-  safe_fclose (&ofp);
+  m_fclose(&ofp);
   p_delete(&buff);
 
   if (!unseen_done && unseen)
@@ -400,7 +401,7 @@ static void mh_sequences_add_one (CONTEXT * ctx, int n, short unseen,
   if (!replied_done && replied)
     fprintf (nfp, "%s: %d\n", NONULL (MhReplied), n);
 
-  safe_fclose (&nfp);
+  m_fclose(&nfp);
 
   unlink (sequences);
   if (safe_rename (tmpfname, sequences) != 0)
@@ -547,7 +548,7 @@ static HEADER *maildir_parse_message (int magic, const char *fname,
     h->env = mutt_read_rfc822_header (f, h, 0, 0);
 
     fstat (fileno (f), &st);
-    fclose (f);
+    m_fclose(&f);
 
     if (!h->received)
       h->received = h->date_sent;
@@ -905,6 +906,7 @@ static void maildir_flags (char *dest, ssize_t destlen, HEADER * hdr)
 
 static int maildir_open_new_message (MESSAGE * msg, CONTEXT * dest, HEADER * hdr)
 {
+  static int Counter = 0;
   int fd;
   char path[_POSIX_PATH_MAX];
   char suffix[16];
@@ -979,13 +981,14 @@ static int maildir_open_new_message (MESSAGE * msg, CONTEXT * dest, HEADER * hdr
 
 static int maildir_commit_message (MESSAGE * msg, CONTEXT * ctx, HEADER * hdr)
 {
+  static int Counter = 0;
   char subdir[4];
   char suffix[16];
   char path[_POSIX_PATH_MAX];
   char full[_POSIX_PATH_MAX];
   char *s;
 
-  if (safe_fclose (&msg->fp) != 0)
+  if (m_fclose(&msg->fp) != 0)
     return -1;
 
   /* extract the subdir */
@@ -1053,7 +1056,7 @@ static int _mh_commit_message (MESSAGE * msg, CONTEXT * ctx, HEADER * hdr,
   char path[_POSIX_PATH_MAX];
   char tmp[16];
 
-  if (safe_fclose (&msg->fp) != 0)
+  if (m_fclose(&msg->fp) != 0)
     return -1;
 
   if ((dirp = opendir (ctx->path)) == NULL) {
@@ -1591,7 +1594,7 @@ static int mh_check_mailbox (CONTEXT * ctx, int *index_hint, int unused __attrib
     FILE *fp = NULL;
 
     if (mh_mkstemp (ctx, &fp, &tmp) == 0) {
-      safe_fclose (&fp);
+      m_fclose(&fp);
       if (safe_rename (tmp, buf) == -1)
         unlink (tmp);
       p_delete(&tmp);