1 /*- 2 * Copyright (c) 1990, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Chris Torek. 7 * 8 * %sccs.include.redist.c% 9 */ 10 11 #if defined(LIBC_SCCS) && !defined(lint) 12 static char sccsid[] = "@(#)tmpnam.c 8.3 (Berkeley) 03/28/94"; 13 #endif /* LIBC_SCCS and not lint */ 14 15 #include <sys/types.h> 16 17 #include <stdio.h> 18 #include <unistd.h> 19 20 char * 21 tmpnam(s) 22 char *s; 23 { 24 static u_long tmpcount; 25 static char buf[L_tmpnam]; 26 27 if (s == NULL) 28 s = buf; 29 (void)snprintf(s, L_tmpnam, "%stmp.%lu.XXXXXX", P_tmpdir, tmpcount); 30 ++tmpcount; 31 return (mktemp(s)); 32 } 33