summaryrefslogtreecommitdiff
path: root/stdio-common
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-08-03 16:47:01 +0000
committerUlrich Drepper <drepper@redhat.com>1998-08-03 16:47:01 +0000
commit7cabd57c0d64a2ee5ca0c5218c877ff700727880 (patch)
tree4db8d28a07bfb0ee5705e9199fcf1f59d5b27403 /stdio-common
parent2698e32c2c2fae23c5c5f39f73b09553158b482d (diff)
downloadglibc-7cabd57c0d64a2ee5ca0c5218c877ff700727880.tar.gz
Update.
1998-08-03 16:36 Ulrich Drepper <drepper@cygnus.com> * catgets/catgets.c: Use mmap/munmap only is _POSIX_MAPPED_FILES is defined. * catgets/open_catalog.c: Likewise. * iconv/iconv_prog.c: Likewise. * intl/loadmsgcat.c: Likewise. * locale/findlocale.c: Likewise. * locale/loadlocale.c: Likewise. * locale/programs/localedef.c: Likewise. * malloc/malloc.c: Likewise. * elf/elf.h: Fix typo. * math/Makefile: Use $(LN_S) instead of ln. * sysdeps/generic/getpgid.c: Fix return type. 1998-08-01 02:49 -0400 Zack Weinberg <zack@rabi.phys.columbia.edu> * sysdeps/posix/tempname.c (__stdio_gen_tempname): Rename to __gen_tempname and simplify the interface. Strip out the code to do path search and create FILE objects. This function now takes a mktemp() style template and returns either a name or a file descriptor. (__path_search): New function; searches for directories for temp files. * sysdeps/generic/tempname.c: Stub out __gen_tempname and __path_search, not __stdio_gen_tempname. * libio/stdio.h: Prototype __gen_tempname and __path_search, not __stdio_gen_tempname. * stdio/stdio.h: Likewise. * stdio-common/tempnam.c: Use __path_search and __gen_tempname. * stdio-common/tmpfile.c: Likewise. * stdio-common/tmpfile64.c: Likewise. * stdio-common/tmpnam.c: Likewise. * stdio-common/tmpnam_r.c: Likewise. * misc/mkstemp.c: New file. Use __gen_tempname. * misc/mktemp.c: Likewise. * sysdeps/posix/mkstemp.c: Removed. * sysdeps/posix/mktemp.c: Removed. * sysdeps/generic/mkstemp.c: Removed. * sysdeps/generic/mktemp.c: Removed. 1998-08-02 Thorsten Kukuk <kukuk@vt.uni-paderborn.de> * configure.in: Check, if door add-on is installed. * config.make.in: Add have_doors. * sunrpc/Makefile: Add HAVE_DOOR define. * sunrpc/key_call.c: Add keyserv/door interface. * sunrpc/svc_unix.c: Call setsockopt only if SO_PASSCRED is defined. * sunrpc/clnt_unix.c: Likewise. 1998-08-02 Andreas Jaeger <aj@arthur.rhein-neckar.de> * inet/netinet/in.h (IN_CLASSC): Correct mask. Reported by Ian Staniforth <I.Staniforth@sheffield.ac.uk> [fixes PR libc/727]. 1998-08-03 10:23 Ulrich Drepper <drepper@cygnus.com> * misc/Makefile: Fix installation problem with --disable-shared. * posix/Makefile: Likewise. 1998-08-02 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * posix/regex.c (re_search_2): Optimize searching for anchored pattern if '^' cannot match at embedded newlines. (regerror): Renamed from __regerror, which it should only be called if _LIBC. 1998-07-31 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sunrpc/svc_unix.c (__msgread): Check setsockopt return value. 1998-07-31 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/generic/glob.c: Remove obsolete cast. 1998-07-31 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * Rules (tests): Fix last change.
Diffstat (limited to 'stdio-common')
-rw-r--r--stdio-common/tempnam.c17
-rw-r--r--stdio-common/tmpfile.c18
-rw-r--r--stdio-common/tmpfile64.c23
-rw-r--r--stdio-common/tmpnam.c22
-rw-r--r--stdio-common/tmpnam_r.c16
5 files changed, 46 insertions, 50 deletions
diff --git a/stdio-common/tempnam.c b/stdio-common/tempnam.c
index 987fbbbabe..8683643c76 100644
--- a/stdio-common/tempnam.c
+++ b/stdio-common/tempnam.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1993, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1993, 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -16,13 +16,9 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <errno.h>
-#include <stddef.h>
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
-
/* 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.
@@ -34,17 +30,12 @@ char *
tempnam (const char *dir, const char *pfx)
{
char buf[FILENAME_MAX];
- size_t len;
- char *s;
- char *t = __stdio_gen_tempname (buf, sizeof (buf), dir, pfx, 1,
- &len, (FILE **) NULL, 0);
- if (t == NULL)
+ if (__path_search (buf, FILENAME_MAX, dir, pfx))
return NULL;
- s = (char *) malloc (len);
- if (s == NULL)
+ if (__gen_tempname (buf, 0, 0))
return NULL;
- return (char *) memcpy (s, t, len);
+ return strdup (buf);
}
diff --git a/stdio-common/tmpfile.c b/stdio-common/tmpfile.c
index c3afd3f78b..488b43b1f7 100644
--- a/stdio-common/tmpfile.c
+++ b/stdio-common/tmpfile.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1993, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1993, 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -18,6 +18,9 @@
#include <stdio.h>
+#ifdef _USE_IN_LIBIO
+# define fdopen _IO_new_fdopen
+#endif
/* This returns a new stream opened on a temporary file (generated
by tmpnam) The file is opened with mode "w+b" (binary read/write).
@@ -27,17 +30,20 @@ FILE *
tmpfile ()
{
char buf[FILENAME_MAX];
- char *filename;
+ int fd;
FILE *f;
- filename = __stdio_gen_tempname (buf, sizeof (buf), (char *) NULL, "tmpf", 0,
- (size_t *) NULL, &f, 0);
- if (filename == NULL)
+ if (__path_search (buf, FILENAME_MAX, NULL, "tmpf"))
+ return NULL;
+ if ((fd = __gen_tempname (buf, 1, 0)) < 0)
return NULL;
/* Note that this relies on the Unix semantics that
a file is not really removed until it is closed. */
- (void) remove (filename);
+ (void) remove (buf);
+
+ if ((f = fdopen (fd, "w+b")) == NULL)
+ close (fd);
return f;
}
diff --git a/stdio-common/tmpfile64.c b/stdio-common/tmpfile64.c
index 5a6e3238fc..5854f1451d 100644
--- a/stdio-common/tmpfile64.c
+++ b/stdio-common/tmpfile64.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1993, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1993, 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -19,6 +19,9 @@
#include <errno.h>
#include <stdio.h>
+#ifdef _USE_IN_LIBIO
+# define fdopen _IO_new_fdopen
+#endif
/* This returns a new stream opened on a temporary file (generated
by tmpnam) The file is opened with mode "w+b" (binary read/write).
@@ -27,23 +30,21 @@
FILE *
tmpfile64 ()
{
-#ifdef _G_OPEN64
char buf[FILENAME_MAX];
- char *filename;
+ int fd;
FILE *f;
- filename = __stdio_gen_tempname (buf, sizeof (buf), (char *) NULL, "tmpf", 0,
- (size_t *) NULL, &f, 1);
- if (filename == NULL)
+ if (__path_search (buf, FILENAME_MAX, NULL, "tmpf"))
+ return NULL;
+ if ((fd = __gen_tempname (buf, 1, 1)) < 0)
return NULL;
/* Note that this relies on the Unix semantics that
a file is not really removed until it is closed. */
- (void) remove (filename);
+ (void) remove (buf);
+
+ if ((f = fdopen (fd, "w+b")) == NULL)
+ close (fd);
return f;
-#else
- __set_errno (ENOSYS);
- return NULL;
-#endif
}
diff --git a/stdio-common/tmpnam.c b/stdio-common/tmpnam.c
index 3389ff57b4..e5c6bf166d 100644
--- a/stdio-common/tmpnam.c
+++ b/stdio-common/tmpnam.c
@@ -19,7 +19,6 @@
#include <stdio.h>
#include <string.h>
-
/* Generate a unique filename in P_tmpdir.
This function is *not* thread safe! */
@@ -30,20 +29,21 @@ tmpnam (char *s)
where S != NULL. */
static char buf[L_tmpnam];
char tmpbuf[L_tmpnam];
- char *result;
/* In the following call we use the buffer pointed to by S if
non-NULL although we don't know the size. But we limit the size
- to FILENAME_MAX characters in any case. */
- result = __stdio_gen_tempname (s ?: tmpbuf, L_tmpnam, (const char *) NULL,
- (const char *) NULL, 0,
- (size_t *) NULL, (FILE **) NULL, 0);
+ to L_tmpnam characters in any case. */
+ if (__path_search (s ? : tmpbuf, L_tmpnam, NULL, NULL))
+ return NULL;
+
+ if (__gen_tempname (s ? : tmpbuf, 0, 0))
+ return NULL;
- if (result != NULL && s == NULL)
+ if (s == NULL)
{
- memcpy (buf, result, L_tmpnam);
- result = buf;
+ memcpy (buf, tmpbuf, L_tmpnam);
+ return buf;
}
-
- return result;
+ else
+ return s;
}
diff --git a/stdio-common/tmpnam_r.c b/stdio-common/tmpnam_r.c
index 5e67cc6845..07c4650cc0 100644
--- a/stdio-common/tmpnam_r.c
+++ b/stdio-common/tmpnam_r.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1993, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1993, 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -17,8 +17,6 @@
Boston, MA 02111-1307, USA. */
#include <stdio.h>
-#include <string.h>
-
/* Generate a unique filename in P_tmpdir. If S is NULL return NULL.
This makes this function thread safe. */
@@ -28,10 +26,10 @@ tmpnam_r (char *s)
if (s == NULL)
return NULL;
- /* In the following call we use the buffer pointed to by S if
- non-NULL although we don't know the size. But we limit the size
- to L_tmpnam characters in any case. */
- return __stdio_gen_tempname (s, L_tmpnam, (const char *) NULL,
- (const char *) NULL, 0,
- (size_t *) NULL, (FILE **) NULL, 0);
+ if (__path_search (s, L_tmpnam, NULL, NULL))
+ return NULL;
+ if (__gen_tempname (s, 0, 0))
+ return NULL;
+
+ return s;
}