aboutsummaryrefslogtreecommitdiffstats
path: root/missing/tmpnam.c
blob: 8f49859a84e14a46a27a8425422c7e37bb6bf267 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
 * tmpnam - an implementation for systems lacking a library version
 *	    this version does not rely on the P_tmpdir and L_tmpnam constants.
 */

#ifndef NULL
#define NULL	0
#endif

static char template[] = "/tmp/gawkXXXXXX";

char *
tmpnam(tmp)
char *tmp;
{
	static char tmpbuf[sizeof(template)];
	
	if (tmp == NULL) {
		(void) strcpy(tmpbuf, template);
		(void) mktemp(tmpbuf);
		return tmpbuf;
	} else {
		(void) strcpy(tmp, template);
		(void) mktemp(tmp);
		return tmp;
	}
}