#include <unistd.h>
#endif
+#ifdef _WIN32
+#include <process.h> /* For spawning child process */
+#endif
+
+#include <glib.h>
+
+#include "file_util.h"
+
#ifndef __set_errno
-#define __set_errno(x) errno=(x)
+#define __set_errno(x) errno=(x)
#endif
/* Generate a unique temporary file name from 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;
template[len - 6] = letters[i];
- fd = open (template, O_RDWR|O_CREAT|O_EXCL, 0600);
+ fd = eth_open (template, O_RDWR|O_BINARY|O_CREAT|O_EXCL, 0600);
if (fd >= 0)
return fd;
}