From 64bc6412188b141c010ac3b8e813b837dd991e80 Mon Sep 17 00:00:00 2001 From: Erik Andersen Date: Sun, 14 May 2000 04:16:35 +0000 Subject: Initial revision --- libc/stdlib/mktemp.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 libc/stdlib/mktemp.c (limited to 'libc/stdlib/mktemp.c') diff --git a/libc/stdlib/mktemp.c b/libc/stdlib/mktemp.c new file mode 100644 index 000000000..08b356710 --- /dev/null +++ b/libc/stdlib/mktemp.c @@ -0,0 +1,40 @@ + +#include +#include +#include +#include + +char * mktemp(template) +char * template; +{ + int i; + int num; /* UNINITIALIZED */ + int n2; + int l = strlen(template); + struct stat stbuf; + + if (l<6) { + errno = EINVAL; + return 0; + } + + for(i=l-6;i=l-6;i--) { + template[i] = '0' + n2 % 10; + n2 /= 10; + } + + if (stat(template, &stbuf) == 0) { + num++; + goto again; + } + + return template; +} -- cgit v1.2.3