xref: /csrg-svn/lib/libc/stdio/tmpnam.c (revision 46559)
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*46559Sbostic static char sccsid[] = "@(#)tmpnam.c	5.2 (Berkeley) 02/22/91";
1346111Sbostic #endif /* LIBC_SCCS and not lint */
1446111Sbostic 
1546111Sbostic #include <sys/param.h>
16*46559Sbostic #include <unistd.h>
1746111Sbostic #include <stdio.h>
1846111Sbostic 
1946111Sbostic char *
2046111Sbostic tmpnam(s)
2146111Sbostic 	char *s;
2246111Sbostic {
23*46559Sbostic 	static char buf[L_tmpnam];
2446111Sbostic 
2546111Sbostic 	if (s == NULL)
2646111Sbostic 		s = buf;
27*46559Sbostic 	(void)snprintf(s, L_tmpnam, "%s/tmp.XXXXXX", P_tmpdir);
28*46559Sbostic 	return(mktemp(s));
2946111Sbostic }
30