summaryrefslogtreecommitdiff
path: root/libc/stdio
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-03-31 04:17:44 +0000
committerEric Andersen <andersen@codepoet.org>2002-03-31 04:17:44 +0000
commitcdb29e3ea6c22f0c0358f0414e3ddb615b1c394f (patch)
tree2c867e60effb9df51b1a0fa615bb55b398561341 /libc/stdio
parent9116dff92e5b362011431f073fe6aa98327be254 (diff)
Rework __gen_tempname() to better match glibc, and add mkstemp64(),
which is needed for busybox ash when using largefile support. -Erik
Diffstat (limited to 'libc/stdio')
-rw-r--r--libc/stdio/tempnam.c7
-rw-r--r--libc/stdio/tmpfile.c6
-rw-r--r--libc/stdio/tmpnam.c10
-rw-r--r--libc/stdio/tmpnam_r.c6
4 files changed, 6 insertions, 23 deletions
diff --git a/libc/stdio/tempnam.c b/libc/stdio/tempnam.c
index 4beb5af83..109276de7 100644
--- a/libc/stdio/tempnam.c
+++ b/libc/stdio/tempnam.c
@@ -19,11 +19,6 @@
#include <stdio.h>
#include <string.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);
-
-
/* Generate a unique temporary filename using up to five characters of PFX
if it is not NULL. The directory to put this file in is searched for
as follows: First the environment variable "TMPDIR" is checked.
@@ -39,7 +34,7 @@ tempnam (const char *dir, const char *pfx)
if (__path_search (buf, FILENAME_MAX, dir, pfx, 1))
return NULL;
- if (__gen_tempname (buf, 0))
+ if (__gen_tempname (buf, __GT_NOCREATE))
return NULL;
return strdup (buf);
diff --git a/libc/stdio/tmpfile.c b/libc/stdio/tmpfile.c
index 7669e46db..f19c497a4 100644
--- a/libc/stdio/tmpfile.c
+++ b/libc/stdio/tmpfile.c
@@ -20,10 +20,6 @@
#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);
-
/* This returns a new stream opened on a temporary file (generated
by tmpnam). The file is opened with mode "w+b" (binary read/write).
If we couldn't generate a unique filename or the file couldn't
@@ -36,7 +32,7 @@ FILE * tmpfile (void)
if (__path_search (buf, FILENAME_MAX, NULL, "tmpf", 0))
return NULL;
- fd = __gen_tempname (buf, 1);
+ fd = __gen_tempname (buf, __GT_FILE);
if (fd < 0)
return NULL;
diff --git a/libc/stdio/tmpnam.c b/libc/stdio/tmpnam.c
index 296f67f27..23cba46ed 100644
--- a/libc/stdio/tmpnam.c
+++ b/libc/stdio/tmpnam.c
@@ -19,15 +19,11 @@
#include <stdio.h>
#include <string.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);
-
static char tmpnam_buffer[L_tmpnam];
/* Generate a unique filename in P_tmpdir.
-
- This function is *not* thread safe when S == NULL! */
+ This function is *not* thread safe when S == NULL!
+*/
char * tmpnam (char *s)
{
/* By using two buffers we manage to be thread safe in the case
@@ -40,7 +36,7 @@ char * tmpnam (char *s)
if (__path_search (s ? : tmpbuf, L_tmpnam, NULL, NULL, 0))
return NULL;
- if (__gen_tempname (s ? : tmpbuf, 0))
+ if (__gen_tempname (s ? : tmpbuf, __GT_NOCREATE))
return NULL;
if (s == NULL)
diff --git a/libc/stdio/tmpnam_r.c b/libc/stdio/tmpnam_r.c
index 630d96eb3..6309aac06 100644
--- a/libc/stdio/tmpnam_r.c
+++ b/libc/stdio/tmpnam_r.c
@@ -18,10 +18,6 @@
#include <stdio.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);
-
/* Generate a unique filename in P_tmpdir. If S is NULL return NULL.
This makes this function thread safe. */
char * tmpnam_r (char *s)
@@ -31,7 +27,7 @@ char * tmpnam_r (char *s)
if (__path_search (s, L_tmpnam, NULL, NULL, 0))
return NULL;
- if (__gen_tempname (s, 0))
+ if (__gen_tempname (s, __GT_NOCREATE))
return NULL;
return s;