|
|
1.1 root 1: /*
2: * Standard I/O Library.
3: * Create a unique name for a temporary file ala SYS V.
4: */
5:
6: #include <stdio.h>
7:
8: #ifdef GEMDOS
9: #define FSPATHSEP "\\"
10: #ifndef P_tmpdir
11: #define P_tmpdir "\\tmp"
12: #endif
13: #endif
14: #ifdef DOS
15: #define FSPATHSEP "\\"
16: #ifndef P_tmpdir
17: #define P_tmpdir "\\tmp"
18: #endif
19: #endif
20: #ifndef FSPATHSEP
21: #define FSPATHSEP "/"
22: #ifndef P_tmpdir
23: #define P_tmpdir "/tmp"
24: #endif
25: #endif
26: #ifndef L_tmpnam
27: #define L_tmpnam 64
28: #endif
29: #define TEMPLATE "tXXXXXX"
30:
31: char *
32: tmpnam(s)
33: register char *s;
34: {
35: char *name;
36: static char namebuf[L_tmpnam];
37: extern char *mktemp(), *strcpy(), *strcat();
38:
39: for (;;) {
40: if (s == NULL)
41: s = namebuf;
42: strcpy(s, P_tmpdir);
43: strcat(s, FSPATHSEP);
44: strcat(s, TEMPLATE);
45: name = mktemp(s);
46: if (access(name, 0) == -1)
47: break;
48: }
49: return (s);
50: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.