|
|
1.1 root 1: #include <stdio.h>
2: #include <errno.h>
3:
4: #if defined(V9) || defined(BSD4_2)
5: char *tempnam(dir, pfx)
6: char *dir, *pfx;
7: {
8: int pid;
9: unsigned int len;
10: char *tnm, *malloc();
11: static int seq = 0;
12:
13: pid = getpid();
14: len = strlen(dir) + strlen(pfx) + 10;
15: if ((tnm = malloc(len)) != NULL) {
16: sprintf(tnm, "%s", dir);
17: if (access(tnm, 7) == -1)
18: return(NULL);
19: do {
20: sprintf(tnm, "%s/%s%d%d", dir, pfx, pid, seq++);
21: errno = 0;
22: if (access(tnm, 7) == -1)
23: if (errno == ENOENT)
24: return(tnm);
25: } while (1);
26: }
27: return(tnm);
28: }
29: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.