]> diplodocus.org Git - nmh/blobdiff - sbr/m_mktemp.c
uip: Replace some ints that are only ever 0 or 1 with bool.
[nmh] / sbr / m_mktemp.c
index f4d5c3fa179f37d1d49e1ca3b5fb75c49182e36a..123da576b556b2d9342b012a2f04822afbbd7491 100644 (file)
@@ -8,6 +8,8 @@
 #include <h/mh.h>
 #include <h/utils.h>
 #include <h/signals.h>
 #include <h/mh.h>
 #include <h/utils.h>
 #include <h/signals.h>
+#include "m_maildir.h"
+#include "m_mktemp.h"
 
 static void register_for_removal(const char *);
 
 
 static void register_for_removal(const char *);
 
@@ -49,7 +51,6 @@ m_mktemp (
 {
     static char tmpfil[BUFSIZ];
     int fd = -1;
 {
     static char tmpfil[BUFSIZ];
     int fd = -1;
-    int keep_open = 0;
     mode_t oldmode = umask(077);
 
     if (pfx_in == NULL) {
     mode_t oldmode = umask(077);
 
     if (pfx_in == NULL) {
@@ -67,9 +68,10 @@ m_mktemp (
 
     register_for_removal(tmpfil);
 
 
     register_for_removal(tmpfil);
 
+    bool keep_open = false;
     if (fd_ret != NULL) {
         *fd_ret = fd;
     if (fd_ret != NULL) {
         *fd_ret = fd;
-        keep_open = 1;
+        keep_open = true;
     }
     if (fp_ret != NULL) {
         FILE *fp = fdopen(fd, "w+");
     }
     if (fp_ret != NULL) {
         FILE *fp = fdopen(fd, "w+");
@@ -82,7 +84,7 @@ m_mktemp (
             return NULL;
         }
         *fp_ret = fp;
             return NULL;
         }
         *fp_ret = fp;
-        keep_open = 1;
+        keep_open = true;
     }
     if (!keep_open) {
         close(fd);
     }
     if (!keep_open) {
         close(fd);
@@ -149,7 +151,6 @@ m_mktemps(
 {
     char *tmpfil;
     int fd = -1;
 {
     char *tmpfil;
     int fd = -1;
-    int keep_open = 0;
     mode_t oldmode = umask(077);
 
     if (suffix == NULL) {
     mode_t oldmode = umask(077);
 
     if (suffix == NULL) {
@@ -200,9 +201,10 @@ m_mktemps(
 
     register_for_removal(tmpfil);
 
 
     register_for_removal(tmpfil);
 
+    bool keep_open = false;
     if (fd_ret != NULL) {
         *fd_ret = fd;
     if (fd_ret != NULL) {
         *fd_ret = fd;
-        keep_open = 1;
+        keep_open = true;
     }
     if (fp_ret != NULL) {
         FILE *fp = fdopen(fd, "w+");
     }
     if (fp_ret != NULL) {
         FILE *fp = fdopen(fd, "w+");
@@ -216,7 +218,7 @@ m_mktemps(
             return NULL;
         }
         *fp_ret = fp;
             return NULL;
         }
         *fp_ret = fp;
-        keep_open = 1;
+        keep_open = true;
     }
     if (!keep_open) {
         close(fd);
     }
     if (!keep_open) {
         close(fd);
@@ -256,7 +258,7 @@ static svector_t exit_filelist = NULL;
 static void
 register_for_removal(const char *pathname) {
     if (exit_filelist == NULL) exit_filelist = svector_create(20);
 static void
 register_for_removal(const char *pathname) {
     if (exit_filelist == NULL) exit_filelist = svector_create(20);
-    (void) svector_push_back(exit_filelist, add(pathname, NULL));
+    (void) svector_push_back(exit_filelist, mh_xstrdup(pathname));
 }
 
 /*
 }
 
 /*
@@ -319,7 +321,7 @@ m_unlink(const char *pathname) {
  * Remove all registered temporary files.
  */
 void
  * Remove all registered temporary files.
  */
 void
-remove_registered_files_atexit() {
+remove_registered_files_atexit(void) {
     unregister_for_removal(1);
 }
 
     unregister_for_removal(1);
 }