diff options
Diffstat (limited to 'libio')
-rw-r--r-- | libio/Makefile | 4 | ||||
-rw-r--r-- | libio/iofdopen.c | 2 | ||||
-rw-r--r-- | libio/iofopen64.c | 4 | ||||
-rw-r--r-- | libio/iopopen.c | 5 | ||||
-rw-r--r-- | libio/oldtmpfile.c | 51 |
5 files changed, 59 insertions, 7 deletions
diff --git a/libio/Makefile b/libio/Makefile index 84240bd852..ca1a3e4b80 100644 --- a/libio/Makefile +++ b/libio/Makefile @@ -43,7 +43,7 @@ all: # Make this the default target; it will be defined in Rules. include ../Makeconfig ifeq ($(versioning),yes) -routines += oldiofopen oldiofdopen oldiofclose +routines += oldiofopen oldiofdopen oldiofclose oldtmpfile endif CPPFLAGS-.o += -DIO_DEBUG @@ -63,7 +63,7 @@ aux += oldfileops oldstdfiles endif shared-only-routines = oldiofopen oldiofdopen oldiofclose oldfileops \ - oldstdfiles + oldstdfiles oldtmpfile distribute := iolibio.h libioP.h strfile.h Banner diff --git a/libio/iofdopen.c b/libio/iofdopen.c index 44be50a37d..40419bd267 100644 --- a/libio/iofdopen.c +++ b/libio/iofdopen.c @@ -130,7 +130,7 @@ _IO_new_fdopen (fd, mode) _IO_mask_flags (&new_f->fp.file, read_write, _IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING); - return (_IO_FILE *) &new_f->fp; + return &new_f->fp.file; } #if defined PIC && DO_VERSIONING diff --git a/libio/iofopen64.c b/libio/iofopen64.c index 3572295ad8..f5e799466d 100644 --- a/libio/iofopen64.c +++ b/libio/iofopen64.c @@ -51,10 +51,10 @@ _IO_fopen64 (filename, mode) _IO_JUMPS (&new_f->fp) = &_IO_file_jumps; _IO_file_init (&new_f->fp.file); #if !_IO_UNIFIED_JUMPTABLES - new_f->fp.plus.vtable = NULL; + new_f->fp.vtable = NULL; #endif if (_IO_file_fopen (&new_f->fp.file, filename, mode, 1) != NULL) - return (_IO_FILE *) &new_f->fp; + return &new_f->fp.file; _IO_un_link (&new_f->fp.file); free (new_f); return NULL; diff --git a/libio/iopopen.c b/libio/iopopen.c index 30ff4b8ae7..62a6de20f5 100644 --- a/libio/iopopen.c +++ b/libio/iopopen.c @@ -196,15 +196,16 @@ _IO_popen (command, mode) #ifdef _IO_MTSAFE_IO new_f->fpx.file.file._lock = &new_f->lock; #endif - fp = (_IO_FILE*)&new_f->fpx; + fp = &new_f->fpx.file.file; _IO_init (fp, 0); _IO_JUMPS (fp) = &_IO_proc_jumps; _IO_file_init (fp); #if !_IO_UNIFIED_JUMPTABLES - ((struct _IO_FILE_plus *) fp)->vtable = NULL; + new_f->fpx.file.vtable = NULL; #endif if (_IO_proc_open (fp, command, mode) != NULL) return fp; + _IO_un_link (fp); free (new_f); return NULL; } diff --git a/libio/oldtmpfile.c b/libio/oldtmpfile.c new file mode 100644 index 0000000000..6c4275d00c --- /dev/null +++ b/libio/oldtmpfile.c @@ -0,0 +1,51 @@ +/* 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 + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#define _IO_USE_OLD_IO_FILE +#include <stdio.h> +#include <unistd.h> +#include <iolibio.h> + +/* 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 + be opened, NULL is returned. */ +FILE * +__old_tmpfile (void) +{ + char buf[FILENAME_MAX]; + int fd; + FILE *f; + + if (__path_search (buf, FILENAME_MAX, NULL, "tmpf")) + return NULL; + fd = __gen_tempname (buf, 1, 0); + if (fd < 0) + return NULL; + + /* Note that this relies on the Unix semantics that + a file is not really removed until it is closed. */ + (void) remove (buf); + + if ((f = _IO_old_fdopen (fd, "w+b")) == NULL) + close (fd); + + return f; +} + +symbol_version (__old_tmpfile, tmpfile, GLIBC_2.0); |