From b4e54243c42ac249943bb6904cd74c82d0350e02 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 10 Mar 2000 08:46:33 +0000 Subject: * mach/devstream.c (devstream_write, devstream_read): New functions. (input, output): Functions removed. (mach_open_devstream): Use devstream_{read,write} as cookie functions, using only the vanilla fopencookie interface. * hurd/fopenport.c [! USE_IN_LIBIO] (cookie_io_functions_t): Define as macro for __io_functions. (funcsio): Use cookie_io_functions_t type name. (fopenport): Renamed from __fopenport. Rewrite to call fopencookie. * libio/iofopncook.c (_IO_cookie_init): New function, broken out of fopencookie. (fopencookie): Use it. * libio/libio.h: Declare _IO_cookie_init. * hurd/vpprintf.c (vpprintf) [USE_IN_LIBIO]: Implement using _IO_cookie_init. * libio/libio.h (__io_seek_fn): Fix second argument type to be a pointer, in line with the manual and the old stdio. * libio/iofopncook.c (_IO_cookie_seek): Fix (sole) caller. * sysdeps/generic/bits/stdio-lock.h: New file. This is a stub with #error, but that's better than no file at all. * sysdeps/unix/sysv/linux/alpha/syscall.S: * manual/message.texi (Using gettextized software): * manual/filesys.texi (File Size): * manual/charset.texi (glibc iconv Implementation): * locale/programs/ld-collate.c (collate_output): * manual/stdio.texi (Output Conversion Syntax): --- libio/iofopncook.c | 48 ++++++++++++++++++++++++++++-------------------- libio/libio.h | 8 ++++++-- 2 files changed, 34 insertions(+), 22 deletions(-) (limited to 'libio') diff --git a/libio/iofopncook.c b/libio/iofopncook.c index 7b76826031..56f2239764 100644 --- a/libio/iofopncook.c +++ b/libio/iofopncook.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1995, 1997, 1999 Free Software Foundation, Inc. +/* Copyright (C) 1993,95,97,99,2000 Free Software Foundation, Inc. This file is part of the GNU IO Library. This library is free software; you can redistribute it and/or @@ -74,10 +74,9 @@ _IO_cookie_seek (fp, offset, dir) { struct _IO_cookie_file *cfile = (struct _IO_cookie_file *) fp; - if (cfile->__io_functions.seek == NULL) - return _IO_pos_BAD; - - return cfile->__io_functions.seek (cfile->__cookie, offset, dir); + return ((cfile->__io_functions.seek == NULL + || cfile->__io_functions.seek (cfile->__cookie, &offset, dir)) + ? _IO_pos_BAD : offset); } static int @@ -117,6 +116,29 @@ static struct _IO_jump_t _IO_cookie_jumps = { }; +void +_IO_cookie_init (struct _IO_cookie_file *cfile, int read_write, + void *cookie, _IO_cookie_io_functions_t io_functions) +{ + _IO_init (&cfile->__file, 0); + _IO_JUMPS (&cfile->__file) = &_IO_cookie_jumps; + + cfile->__cookie = cookie; + cfile->__io_functions = io_functions; + + _IO_file_init(&cfile->__file); + + cfile->__file._IO_file_flags = + _IO_mask_flags (&cfile->__file, read_write, + _IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING); + + /* We use a negative number different from -1 for _fileno to mark that + this special stream is not associated with a real file, but still has + to be treated as such. */ + cfile->__file._fileno = -2; +} + + _IO_FILE * fopencookie (cookie, mode, io_functions) void *cookie; @@ -156,21 +178,7 @@ fopencookie (cookie, mode, io_functions) new_f->cfile.__file._lock = &new_f->lock; #endif - _IO_init (&new_f->cfile.__file, 0); - _IO_JUMPS (&new_f->cfile.__file) = &_IO_cookie_jumps; - new_f->cfile.__cookie = cookie; - new_f->cfile.__io_functions = io_functions; - - _IO_file_init(&new_f->cfile.__file); - - new_f->cfile.__file._IO_file_flags = - _IO_mask_flags (&new_f->cfile.__file, read_write, - _IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING); - - /* We use a negative number different from -1 for _fileno to mark that - this special stream is not associated with a real file, but still has - to be treated as such. */ - new_f->cfile.__file._fileno = -2; + _IO_cookie_init (&new_f->cfile, read_write, cookie, io_functions); return &new_f->cfile.__file; } diff --git a/libio/libio.h b/libio/libio.h index c8f93ac0f3..8fdc55a890 100644 --- a/libio/libio.h +++ b/libio/libio.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,92,93,94,95,97,98,99 Free Software Foundation, Inc. +/* Copyright (C) 1991,92,93,94,95,97,98,99,2000 Free Software Foundation, Inc. This file is part of the GNU IO Library. Written by Per Bothner . @@ -346,7 +346,7 @@ typedef __ssize_t __io_write_fn (void *__cookie, __const char *__buf, or the end of the file (if W is SEEK_END). Set *POS to the new file position. Returns zero if successful, nonzero if not. */ -typedef int __io_seek_fn (void *__cookie, _IO_off_t __pos, int __w); +typedef int __io_seek_fn (void *__cookie, _IO_off64_t *__pos, int __w); /* Close COOKIE. */ typedef int __io_close_fn (void *__cookie); @@ -377,6 +377,10 @@ struct _IO_cookie_file void *__cookie; _IO_cookie_io_functions_t __io_functions; }; + +/* Initialize one of those. */ +extern void _IO_cookie_init (struct _IO_cookie_file *__cfile, int __read_write, + void *__cookie, _IO_cookie_io_functions_t __fns); #endif -- cgit 1.4.1