xref: /csrg-svn/lib/libc/stdio/tmpnam.c (revision 58800)
146111Sbostic /*-
246111Sbostic  * Copyright (c) 1990 The Regents of the University of California.
346111Sbostic  * All rights reserved.
446111Sbostic  *
546111Sbostic  * This code is derived from software contributed to Berkeley by
646111Sbostic  * Chris Torek.
746111Sbostic  *
846111Sbostic  * %sccs.include.redist.c%
946111Sbostic  */
1046111Sbostic 
1146111Sbostic #if defined(LIBC_SCCS) && !defined(lint)
12*58800Sbostic static char sccsid[] = "@(#)tmpnam.c	5.4 (Berkeley) 03/25/93";
1346111Sbostic #endif /* LIBC_SCCS and not lint */
1446111Sbostic 
1546559Sbostic #include <unistd.h>
1646111Sbostic #include <stdio.h>
1746111Sbostic 
1846111Sbostic char *
1946111Sbostic tmpnam(s)
2046111Sbostic 	char *s;
2146111Sbostic {
2246559Sbostic 	static char buf[L_tmpnam];
2346111Sbostic 
2446111Sbostic 	if (s == NULL)
2546111Sbostic 		s = buf;
26*58800Sbostic 	(void)snprintf(s, L_tmpnam, "%stmp.XXXXXX", P_tmpdir);
2746559Sbostic 	return(mktemp(s));
2846111Sbostic }
29