Fixes for /usr/xbin binaries bootstrap dir.
[minix3.git] / lib / stdio / tmpfile.c
blobc24dced0d7fdf8e12ba08ce28d4e2f3f680d3935
1 /*
2 * tmpfile.c - create and open a temporary file
3 */
4 /* $Header$ */
6 #if defined(_POSIX_SOURCE)
7 #include <sys/types.h>
8 #endif
9 #include <stdio.h>
10 #include <string.h>
11 #include "loc_incl.h"
13 pid_t _getpid(void);
15 FILE *
16 tmpfile(void) {
17 static char name_buffer[L_tmpnam] = "/tmp/tmp." ;
18 static char *name = NULL;
19 FILE *file;
21 if (!name) {
22 name = name_buffer + strlen(name_buffer);
23 name = _i_compute(_getpid(), 10, name, 5);
24 *name = '\0';
27 file = fopen(name_buffer,"wb+");
28 if (!file) return (FILE *)NULL;
29 (void) remove(name_buffer);
30 return file;