21 #define _DIAGASSERT(x) do {} while (0)
55 #if HAVE_NBTOOL_CONFIG_H
56 #include "nbtool_config.h"
59 #if !HAVE_NBTOOL_CONFIG_H || !HAVE_MKSTEMP || !HAVE_MKDTEMP
62 #include <sys/cdefs.h>
63 #if defined(LIBC_SCCS) && !defined(lint)
65 static char sccsid[] =
"@(#)mktemp.c 8.1 (Berkeley) 6/4/93";
67 __RCSID(
"$NetBSD: gettemp.c,v 1.17 2014/01/21 19:09:48 seanb Exp $");
72 #include <sys/types.h>
84 #if HAVE_NBTOOL_CONFIG_H
85 #define GETTEMP __nbcompat_gettemp
87 #include "reentrant.h"
89 #define GETTEMP __gettemp
94 GETTEMP(
char *path,
int *doopen,
int domkdir)
106 static char xtra[2] =
"aa";
115 for (trv = path; *trv; ++trv)
134 for (; xcnt > 0; xcnt--)
136 *--trv = (pid % 10) +
'0';
156 for (
start = trv + 1;; --trv)
165 e =
stat(path, &sbuf);
168 return doopen == NULL && !domkdir;
172 return doopen == NULL && !domkdir;
183 open(path, O_CREAT | O_EXCL | O_RDWR, 0600)) >= 0)
190 if (
mkdir(path, 0700) >= 0)
195 else if (
lstat(path, &sbuf))
196 return errno == ENOENT ? 1 : 0;
207 if (isdigit((
unsigned char) *trv))
253 #if HAVE_NBTOOL_CONFIG_H
254 #include "nbtool_config.h"
257 #if !HAVE_NBTOOL_CONFIG_H || !HAVE_MKDTEMP
259 #ifdef NOT_POSTGRESQL
261 #include <sys/cdefs.h>
262 #if defined(LIBC_SCCS) && !defined(lint)
264 static char sccsid[] =
"@(#)mktemp.c 8.1 (Berkeley) 6/4/93";
266 __RCSID(
"$NetBSD: mkdtemp.c,v 1.11 2012/03/15 18:22:30 christos Exp $");
270 #if HAVE_NBTOOL_CONFIG_H
271 #define GETTEMP __nbcompat_gettemp
278 #include "reentrant.h"
280 #define GETTEMP __gettemp
290 return GETTEMP(path, NULL, 1) ? path : NULL;
static int GETTEMP(char *path, int *doopen, int domkdir)
char * mkdtemp(char *path)