fix log msg typo
[obnox/wireshark/wip.git] / mkstemp.c
index 90051bdaf42338a1020305fd4069c2dd925e58b2..dc847f68cc9a42361901f396322ebfa3c6328cc9 100644 (file)
--- a/mkstemp.c
+++ b/mkstemp.c
 #include <unistd.h>
 #endif
 
-#ifndef __set_errno
-#define __set_errno(x) errno=(x) 
+#ifdef _WIN32
+#include <process.h>    /* For spawning child process */
 #endif
-#ifndef O_BINARY
-#define O_BINARY 0
+
+#include <glib.h>
+
+#include "file_util.h"
+
+#ifndef __set_errno
+#define __set_errno(x) errno=(x)
 #endif
 
 /* Generate a unique temporary file name from TEMPLATE.
@@ -60,7 +65,7 @@ mkstemp (template)
       return -1;
     }
 
-  if (sprintf (&template[len - 5], "%.5u",
+  if (g_snprintf (&template[len - 5], 6, "%.5u",
               (unsigned int) getpid () % 100000) != 5)
     /* Inconceivable lossage.  */
     return -1;
@@ -71,7 +76,7 @@ mkstemp (template)
 
       template[len - 6] = letters[i];
 
-      fd = open (template, O_RDWR|O_BINARY|O_CREAT|O_EXCL, 0600);
+      fd = eth_open (template, O_RDWR|O_BINARY|O_CREAT|O_EXCL, 0600);
       if (fd >= 0)
        return fd;
     }