1/* 2 * Copyright (c) 1988 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that this notice is preserved and that due credit is given 7 * to the University of California at Berkeley. The name of the University 8 * may not be used to endorse or promote products derived from this 9 * software without specific written prior permission. This software 10 * is provided ``as is'' without express or implied warranty. 11 * 12 * RCS: @(#) $Id: tmpnam.c,v 1.2 1998/09/14 18:39:45 stanton Exp $ 13 */ 14 15#include <sys/param.h> 16#include <sys/stat.h> 17#include <sys/file.h> 18#include <stdio.h> 19 20/* 21 * Use /tmp instead of /usr/tmp, because L_tmpname is only 14 chars 22 * on some machines (like NeXT machines) and /usr/tmp will cause 23 * buffer overflows. 24 */ 25 26#ifdef P_tmpdir 27# undef P_tmpdir 28#endif 29#define P_tmpdir "/tmp" 30 31char * 32tmpnam(s) 33 char *s; 34{ 35 static char name[50]; 36 char *mktemp(); 37 38 if (!s) 39 s = name; 40 (void)sprintf(s, "%s/XXXXXX", P_tmpdir); 41 return(mktemp(s)); 42} 43