From 0b44a0315b47dd8eced9f3b7f31580cf14bbfc01 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sat, 12 Feb 2011 00:22:29 -0500 Subject: initial check-in, version 0.5.0 --- src/stdio/tmpfile.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/stdio/tmpfile.c (limited to 'src/stdio/tmpfile.c') diff --git a/src/stdio/tmpfile.c b/src/stdio/tmpfile.c new file mode 100644 index 00000000..185025f1 --- /dev/null +++ b/src/stdio/tmpfile.c @@ -0,0 +1,23 @@ +#include +#include +#include +#include "stdio_impl.h" + +FILE *tmpfile(void) +{ + char buf[L_tmpnam], *s; + int fd; + FILE *f; + for (;;) { + s = tmpnam(buf); + if (!s) return NULL; + fd = __syscall_open(s, O_RDWR | O_CREAT | O_EXCL, 0600); + if (fd >= 0) { + f = __fdopen(fd, "w+"); + remove(s); + return f; + } + } +} + +LFS64(tmpfile); -- cgit v1.2.1