]> git.lizzy.rs Git - plan9front.git/blob - sys/src/libstdio/tmpnam.c
libregexp: improve the transition to next available thread, instruction, and generation
[plan9front.git] / sys / src / libstdio / tmpnam.c
1 /*
2  * pANS stdio -- tmpnam
3  */
4 #include "iolib.h"
5
6 char *tmpnam(char *s){
7         static char name[]="/tmp/tn000000000000";
8         char *p;
9         do{
10                 p=name+7;
11                 while(*p=='9') *p++='0';
12                 if(*p=='\0') return NULL;
13                 ++*p;
14         }while(access(name, 0)==0);
15         if(s){
16                 strcpy(s, name);
17                 return s;
18         }
19         return name;
20 }