home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GEMini Atari
/
GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso
/
zip
/
mint
/
mntlib16.lzh
/
MNTLIB16
/
TMPNAM.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-03
|
800b
|
34 lines
/* tmpnam.c : return a temporary file name */
/* written by Eric R. Smith and placed in the public domain */
/**
* - retuned name can be passed outside via system(); other programs
* may not dig '/' as a path separator
* - somehow more frugal in a memory use
* (mj - October 1990)
**/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static char pattern[] = "\\__XXXXXX";
char *tmpnam(buf)
char *buf;
{
char *tmpdir;
extern char *mktemp __PROTO((char *));
if (!(tmpdir = getenv("TEMP")) && !(tmpdir = getenv("TMPDIR")))
tmpdir = ".";
if (!buf) {
size_t blen;
blen = strlen (tmpdir) + sizeof(pattern);
if (NULL == (buf = malloc(blen)))
return NULL;
}
(void) strcat(strcpy(buf, tmpdir), pattern);
return(mktemp(buf));
}