summaryrefslogtreecommitdiff
path: root/lib/freadable.h
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2007-04-14 00:10:31 +0000
committerBruno Haible <bruno@clisp.org>2007-04-14 00:10:31 +0000
commit0acbfc1aeae85899f244dbab5fae5ba8e52aa060 (patch)
tree57e26a1e81dce7fb49faf07910d6797eb56bd198 /lib/freadable.h
parent8ea29bc26b6efadac667ab8f648971fc50209b9a (diff)
downloadgnulib-0acbfc1aeae85899f244dbab5fae5ba8e52aa060.tar.gz
New module 'freadable'.
Diffstat (limited to 'lib/freadable.h')
-rw-r--r--lib/freadable.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/freadable.h b/lib/freadable.h
new file mode 100644
index 0000000000..4adf15a758
--- /dev/null
+++ b/lib/freadable.h
@@ -0,0 +1,43 @@
+/* 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 supports reading, false if it supports
+ only writing, i.e. if it was opened write-only or append-only.
+ STREAM must not be wide-character oriented.
+ The result doesn't change until the stream is closed or re-opened. */
+
+#if HAVE___FREADABLE /* glibc >= 2.2, Solaris >= 7 */
+
+# include <stdio_ext.h>
+# define freadable(stream) (__freadable (stream) != 0)
+
+#else
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+extern bool freadable (FILE *stream);
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif