X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/bc4927948a1b01bf2ae8b952dfd2639c1f929f00..06efa573c7894caa4e5aa1ac7c64bd10ea25928b:/sbr/m_mktemp.c?ds=inline diff --git a/sbr/m_mktemp.c b/sbr/m_mktemp.c index 15bee939..123da576 100644 --- a/sbr/m_mktemp.c +++ b/sbr/m_mktemp.c @@ -1,5 +1,4 @@ -/* - * m_mktemp.c -- Construct a temporary file. +/* m_mktemp.c -- Construct a temporary file. * * This code is Copyright (c) 2010, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for @@ -9,6 +8,8 @@ #include #include #include +#include "m_maildir.h" +#include "m_mktemp.h" static void register_for_removal(const char *); @@ -50,7 +51,6 @@ m_mktemp ( { static char tmpfil[BUFSIZ]; int fd = -1; - int keep_open = 0; mode_t oldmode = umask(077); if (pfx_in == NULL) { @@ -68,9 +68,10 @@ m_mktemp ( register_for_removal(tmpfil); + bool keep_open = false; if (fd_ret != NULL) { *fd_ret = fd; - keep_open = 1; + keep_open = true; } if (fp_ret != NULL) { FILE *fp = fdopen(fd, "w+"); @@ -83,7 +84,7 @@ m_mktemp ( return NULL; } *fp_ret = fp; - keep_open = 1; + keep_open = true; } if (!keep_open) { close(fd); @@ -150,7 +151,6 @@ m_mktemps( { char *tmpfil; int fd = -1; - int keep_open = 0; mode_t oldmode = umask(077); if (suffix == NULL) { @@ -201,9 +201,10 @@ m_mktemps( register_for_removal(tmpfil); + bool keep_open = false; if (fd_ret != NULL) { *fd_ret = fd; - keep_open = 1; + keep_open = true; } if (fp_ret != NULL) { FILE *fp = fdopen(fd, "w+"); @@ -217,7 +218,7 @@ m_mktemps( return NULL; } *fp_ret = fp; - keep_open = 1; + keep_open = true; } if (!keep_open) { close(fd); @@ -229,7 +230,7 @@ m_mktemps( char * -get_temp_dir() +get_temp_dir(void) { /* Ignore envvars if we are setuid */ if ((getuid()==geteuid()) && (getgid()==getegid())) { @@ -257,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); - (void) svector_push_back(exit_filelist, add(pathname, NULL)); + (void) svector_push_back(exit_filelist, mh_xstrdup(pathname)); } /* @@ -320,7 +321,7 @@ m_unlink(const char *pathname) { * Remove all registered temporary files. */ void -remove_registered_files_atexit() { +remove_registered_files_atexit(void) { unregister_for_removal(1); }