diff options
author | Roland McGrath <roland@gnu.org> | 1995-11-20 03:48:11 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 1995-11-20 03:48:11 +0000 |
commit | 96aa2d94a2355cdc55c96e808d14a0e7f2ebe77d (patch) | |
tree | f7c87e6742af0707b858a1387ca85b679aa8d13e /sysdeps/posix | |
parent | a5a81fecc7194d050066265a15b1ba8bc3abc627 (diff) | |
download | glibc-96aa2d94a2355cdc55c96e808d14a0e7f2ebe77d.tar.gz glibc-96aa2d94a2355cdc55c96e808d14a0e7f2ebe77d.tar.xz glibc-96aa2d94a2355cdc55c96e808d14a0e7f2ebe77d.zip |
Sat Nov 18 16:46:01 1995 Ulrich Drepper <drepper@gnu.ai.mit.edu>
* libio/Makefile, libio/cleanup.c, libio/clearerr.c, libio/feof.c, libio/ferror.c, libio/fgetc.c, libio/filedoalloc.c, libio/fileno.c, libio/fileops.c, libio/fputc.c, libio/freopen.c, libio/fseek.c, libio/genops.c, libio/getc.c, libio/getchar.c, libio/iofclose.c, libio/iofdopen.c, libio/iofflush.c, libio/iofgetpos.c, libio/iofgets.c, libio/iofopen.c, libio/iofprintf.c, libio/iofputs.c, libio/iofread.c, libio/iofscanf.c, libio/iofsetpos.c, libio/ioftell.c, libio/iofwrite.c, libio/iogetdelim.c, libio/iogetline.c, libio/iogets.c, libio/iolibio.h, libio/iopadn.c, libio/ioprims.c, libio/ioputs.c, libio/ioseekoff.c, libio/ioseekpos.c, libio/iosetbuffer.c, libio/iosetvbuf.c, libio/iosprintf.c, libio/ioungetc.c, libio/iovsprintf.c, libio/iovsscanf.c, libio/libio.h, libio/libioP.h, libio/putc.c, libio/putchar.c, libio/rewind.c, libio/setbuf.c, libio/setlinebuf.c, libio/stdfiles.c, libio/stdio.c, libio/stdio.h, libio/strfile.h, libio/strops.c, libio/vasprintf.c, libio/vscanf.c, libio/vsnprintf.c: New files. Slightly modified version from Linux libc. * libio/memstream.c, libio/vdprintf.c: New files for functions not (yet) part of GNU libio. * libio/iofopncook.c: Implementation of `fopencookie', mainly written by Per Bothner. * stdio-common/getline.c: Adapted to libio. * stdio-common/snprintf.c: Adapted to libio. * stdio-common/vfprintf.c: Adapted to libio. * stdio-common/vfscanf.c: Adapted to libio. * sysdeps/posix/tempname.c: Adapted to libio.
Diffstat (limited to 'sysdeps/posix')
-rw-r--r-- | sysdeps/posix/tempname.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/sysdeps/posix/tempname.c b/sysdeps/posix/tempname.c index f2da66a211..c70a6e8d35 100644 --- a/sysdeps/posix/tempname.c +++ b/sysdeps/posix/tempname.c @@ -27,6 +27,11 @@ Cambridge, MA 02139, USA. */ #include <fcntl.h> #include <unistd.h> +#ifdef USE_IN_LIBIO +# include "libioP.h" +# include <libio.h> +#endif + /* Return nonzero if DIR is an existent directory. */ static int DEFUN(diraccess, (dir), CONST char *dir) @@ -169,6 +174,41 @@ DEFUN(__stdio_gen_tempname, (dir, pfx, dir_search, lenptr, streamptr), { /* We got a new file that did not previously exist. Create a stream for it. */ +#ifdef USE_IN_LIBIO + int save; + struct _IO_FILE_plus *fp; + + fp = (struct _IO_FILE_plus *) + malloc(sizeof (struct _IO_FILE_plus)); + if (fp == NULL) + { + /* We lost trying to create a stream (out of memory?). + Nothing to do but remove the file, close the descriptor, + and return failure. */ + save = errno; + lose: + (void) remove (buf); + (void) __close (fd); + errno = save; + return NULL; + } + _IO_init (&fp->file, 0); + _IO_JUMPS (&fp->file) = &_IO_file_jumps; + _IO_file_init (&fp->file); +# if !_IO_UNIFIED_JUMPTABLES + fp->vtable = NULL; +# endif + if (_IO_file_attach (&fp->file, fd) == NULL) + { + save = errno; + free (fp); + goto lose; + } + fp->file._flags &= ~_IO_DELETE_DONT_CLOSE; + fp->file._IO_file_flags = 0; + + *streamptr = (FILE *) fp; +#else *streamptr = __newstream (); if (*streamptr == NULL) { @@ -185,6 +225,7 @@ DEFUN(__stdio_gen_tempname, (dir, pfx, dir_search, lenptr, streamptr), (*streamptr)->__mode.__write = 1; (*streamptr)->__mode.__read = 1; (*streamptr)->__mode.__binary = 1; +#endif } else continue; |