summaryrefslogtreecommitdiff
path: root/lib/freading.h
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2007-04-26 13:16:50 +0000
committerEric Blake <ebb9@byu.net>2007-04-26 13:16:50 +0000
commita8f956440539cf954fb92e2396cc58e2a111455f (patch)
tree3bc679ef8b296a14ff820d287dd2b5d6887b9499 /lib/freading.h
parentedd8cd8de79b5872627d2ccd5817e0e6c1a2da70 (diff)
downloadgnulib-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/freading.h')
-rw-r--r--lib/freading.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/freading.h b/lib/freading.h
new file mode 100644
index 0000000000..e0db1f7d05
--- /dev/null
+++ b/lib/freading.h
@@ -0,0 +1,44 @@
+/* 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 <stdbool.h>
+#include <stdio.h>
+
+/* Return true if the stream STREAM is opened read-only, or if the last
+ operation on the stream was a read operation. Return false if the stream
+ supports writing and the last operation on it was a write operation or
+ there was no such operation.
+ STREAM must not be wide-character oriented. */
+
+#if HAVE___FREADING && !defined __GLIBC__ /* Solaris >= 7, not glibc >= 2.2 */
+
+# include <stdio_ext.h>
+# define freading(stream) (__freading (stream) != 0)
+
+#else
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+extern bool freading (FILE *stream);
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif