home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tcl2-73c.zip / tcl7.3 / compat / tmpnam.c < prev    next >
C/C++ Source or Header  |  1993-10-14  |  1KB  |  42 lines

  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.  
  13. #if defined(LIBC_SCCS) && !defined(lint)
  14. static char sccsid[] = "@(#)tmpnam.c    4.4 (Berkeley) 6/8/88";
  15. #endif /* LIBC_SCCS and not lint */
  16.  
  17. #include <sys/param.h>
  18. #include <sys/stat.h>
  19. #include <sys/file.h>
  20. #include <stdio.h>
  21.  
  22. /*
  23.  * Use /tmp instead of /usr/tmp, because L_tmpname is only 14 chars
  24.  * on some machines (like NeXT machines) and /usr/tmp will cause
  25.  * buffer overflows.
  26.  */
  27.  
  28. #define    P_tmpdir    "/tmp"
  29.  
  30. char *
  31. tmpnam(s)
  32.     char *s;
  33. {
  34.     static char name[50];
  35.     char *mktemp();
  36.  
  37.     if (!s)
  38.         s = name;
  39.     (void)sprintf(s, "%s/XXXXXX", P_tmpdir);
  40.     return(mktemp(s));
  41. }
  42.