Commit | Line | Data |
---|---|---|
b8f253e8 KM |
1 | #ifndef lint |
2 | static char sccsid[] = "@(#)mktemp.c 5.1 (Berkeley) %G%"; | |
3 | #endif not lint | |
55221028 BJ |
4 | |
5 | char * | |
6 | mktemp(as) | |
7 | char *as; | |
8 | { | |
9 | register char *s; | |
10 | register unsigned pid; | |
11 | register i; | |
12 | ||
13 | pid = getpid(); | |
14 | s = as; | |
15 | while (*s++) | |
16 | ; | |
17 | s--; | |
18 | while (*--s == 'X') { | |
19 | *s = (pid%10) + '0'; | |
20 | pid /= 10; | |
21 | } | |
22 | s++; | |
23 | i = 'a'; | |
24 | while (access(as, 0) != -1) { | |
25 | if (i=='z') | |
26 | return("/"); | |
27 | *s = i++; | |
28 | } | |
29 | return(as); | |
30 | } |