1989-05-30 13:34:25 +00:00
|
|
|
/*
|
|
|
|
* tmpfile.c - create and open a temporary file
|
|
|
|
*/
|
|
|
|
/* $Header$ */
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "loc_incl.h"
|
|
|
|
|
|
|
|
unsigned int getpid(void);
|
|
|
|
|
|
|
|
FILE *
|
|
|
|
tmpfile(void) {
|
|
|
|
static char name_buffer[L_tmpnam] = "/tmp/tmp." ;
|
|
|
|
static char *name = NULL;
|
|
|
|
FILE *file;
|
|
|
|
|
|
|
|
if (!name) {
|
|
|
|
name = name_buffer + strlen(name_buffer);
|
1989-06-26 10:37:05 +00:00
|
|
|
name = _i_compute(getpid(), 10, name, 5);
|
|
|
|
*name = '\0';
|
1989-05-30 13:34:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
file = fopen(name_buffer,"wb+");
|
|
|
|
if (!file) return (FILE *)NULL;
|
1989-06-26 10:37:05 +00:00
|
|
|
(void) remove(name_buffer);
|
1989-05-30 13:34:25 +00:00
|
|
|
return file;
|
|
|
|
}
|