tmpnam.c - scc - simple c99 compiler
(HTM) git clone git://git.simple-cc.org/scc
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Submodules
(DIR) README
(DIR) LICENSE
---
tmpnam.c (353B)
---
1 #include <sys.h>
2
3 #include <stdio.h>
4 #include <string.h>
5
6 #include "../syscall.h"
7
8 #undef tmpnam
9
10 char *
11 tmpnam(char *s)
12 {
13 static char tmpl[] = _TMPNAME;
14 char *p;
15
16 for (;;) {
17 for (p = tmpl; *p && *p != '9'; ++p)
18 ;
19 if (*p == '\0')
20 return NULL;
21 ++*p;
22
23 if (_access(tmpl, F_OK) != 0)
24 break;
25 }
26 if (s)
27 strcpy(s, tmpl);
28 return tmpl;
29 }