diff options
author | Eric Blake <ebb9@byu.net> | 2007-04-26 13:16:50 +0000 |
---|---|---|
committer | Eric Blake <ebb9@byu.net> | 2007-04-26 13:16:50 +0000 |
commit | a8f956440539cf954fb92e2396cc58e2a111455f (patch) | |
tree | 3bc679ef8b296a14ff820d287dd2b5d6887b9499 /lib/fwriting.c | |
parent | edd8cd8de79b5872627d2ccd5817e0e6c1a2da70 (diff) | |
download | gnulib-a8f956440539cf954fb92e2396cc58e2a111455f.tar.gz |
Implement freading and fwriting.
* lib/freading.c: New file.
* lib/freading.h: Likewise.
* m4/freading.m4: Likewise.
* modules/freading: Likewise.
* modules/freading-tests: Likewise.
* tests/test-freading.c: Likewise.
* lib/fwriting.c: New file.
* lib/fwriting.h: Likewise.
* m4/fwriting.m4: Likewise.
* modules/fwriting: Likewise.
* modules/fwriting-tests: Likewise.
* tests/test-fwriting.c: Likewise.
* MODULES.html.sh (File stream based Input/Output): Mention them.
Diffstat (limited to 'lib/fwriting.c')
-rw-r--r-- | lib/fwriting.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/fwriting.c b/lib/fwriting.c new file mode 100644 index 0000000000..302053733a --- /dev/null +++ b/lib/fwriting.c @@ -0,0 +1,38 @@ +/* Retrieve information about a FILE stream. + Copyright (C) 2007 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#include <config.h> + +/* Specification. */ +#include "fwriting.h" + +bool +fwriting (FILE *fp) +{ + /* Most systems provide FILE as a struct and the necessary bitmask in + <stdio.h>, because they need it for implementing getc() and putc() as + fast macros. */ +#if defined _IO_ferror_unlocked /* GNU libc, BeOS */ + return (fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) != 0; +#elif defined __sferror /* FreeBSD, NetBSD, OpenBSD, MacOS X, Cygwin */ + return (fp->_flags & __SWR) != 0; +#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, mingw */ + return (fp->_flag & _IOWRT) != 0; +#else + #error "Please port gnulib fwriting.c to your platform!" +#endif +} |