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