emergency commit
[cl-cudd.git] / distr / util / tmpfile.c
blob35b6fbb430eec2c46aebcb78933f269645de61fe
1 /*
2 * tmpfile -- open an unnamed temporary file
4 * This is the ANSI C standard routine; we have hacks here because many
5 * compilers/systems do not have it yet.
6 */
8 /* LINTLIBRARY */
11 #include <stdio.h>
12 #include "util.h"
15 #ifdef UNIX
17 FILE *
18 tmpfile()
20 FILE *fp;
21 char *filename, *junk;
23 junk = strsav((char *)"/usr/tmp/cudd-XXXXXX");
24 filename = mktemp(junk);
25 if ((fp = fopen(filename, "w+")) == NULL) {
26 FREE(junk);
27 return NULL;
29 (void) unlink(filename);
30 FREE(junk);
31 return fp;
34 #else
36 FILE *
37 tmpfile()
39 return fopen("utiltmp", "w+");
42 #endif