scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

tmpfile.c (270B)


      1 #include <stdio.h>
      2 
      3 #include "../../syscall.h"
      4 
      5 #undef tmpfile
      6 
      7 FILE *
      8 tmpfile(void)
      9 {
     10 	char *fname;
     11 	FILE *fp;
     12 
     13 	for (;;) {
     14 		if ((fname = tmpnam(NULL)) == NULL)
     15 			return NULL;
     16 		if ((fp = fopen(fname, "wt+")) == NULL)
     17 			continue;
     18 		_unlink(fname);
     19 		return fp;
     20 	}
     21 }