123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- #include <stdio.h>
- #include <unistd.h>
- extern int __path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx,
- int try_tmpdir);
- extern int __gen_tempname (char *tmpl, int openit);
- FILE * tmpfile (void)
- {
- char buf[FILENAME_MAX];
- int fd;
- FILE *f;
- if (__path_search (buf, FILENAME_MAX, NULL, "tmpf", 0))
- return NULL;
- fd = __gen_tempname (buf, 1);
- if (fd < 0)
- return NULL;
-
- (void) remove (buf);
- if ((f = fdopen (fd, "w+b")) == NULL)
- close (fd);
- return f;
- }
|