tmpnam.c (1574) | tmpnam.c (50121) |
---|---|
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 * Redistribution and use in source and binary forms, with or without --- 29 unchanged lines hidden (view full) --- 38static char sccsid[] = "@(#)tmpnam.c 8.3 (Berkeley) 3/28/94"; 39#endif /* LIBC_SCCS and not lint */ 40 41#include <sys/types.h> 42 43#include <stdio.h> 44#include <unistd.h> 45 | 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 * Redistribution and use in source and binary forms, with or without --- 29 unchanged lines hidden (view full) --- 38static char sccsid[] = "@(#)tmpnam.c 8.3 (Berkeley) 3/28/94"; 39#endif /* LIBC_SCCS and not lint */ 40 41#include <sys/types.h> 42 43#include <stdio.h> 44#include <unistd.h> 45 |
46__warn_references(tmpnam, 47 "warning: tmpnam() possibly used unsafely; consider using mkstemp()"); 48 49extern char *_mktemp __P((char *)); 50 |
|
46char * 47tmpnam(s) 48 char *s; 49{ 50 static u_long tmpcount; 51 static char buf[L_tmpnam]; 52 53 if (s == NULL) 54 s = buf; 55 (void)snprintf(s, L_tmpnam, "%stmp.%lu.XXXXXX", P_tmpdir, tmpcount); 56 ++tmpcount; 57 return (mktemp(s)); 58} | 51char * 52tmpnam(s) 53 char *s; 54{ 55 static u_long tmpcount; 56 static char buf[L_tmpnam]; 57 58 if (s == NULL) 59 s = buf; 60 (void)snprintf(s, L_tmpnam, "%stmp.%lu.XXXXXX", P_tmpdir, tmpcount); 61 ++tmpcount; 62 return (mktemp(s)); 63} |