]> pd.if.org Git - pdclib/commitdiff
Added test for interactive streams (_IOLBF / _IOFBF)
authorsolar <unknown>
Thu, 20 Sep 2007 21:21:15 +0000 (21:21 +0000)
committersolar <unknown>
Thu, 20 Sep 2007 21:21:15 +0000 (21:21 +0000)
includes/stdio.h
internals/_PDCLIB_glue.h
platform/example/functions/_PDCLIB/isinteractive.c [new file with mode: 0644]

index 7f793903eeda607033372928a620dbc6f60ecc3f..68f1cb7de20fb0823d584d0dad068b6fbbcf69ac 100644 (file)
@@ -146,8 +146,7 @@ int fflush( struct _PDCLIB_file_t * stream );
    given.
 
    The stream is fully buffered if and only if it can be determined not to
-   refer to an interactive device. As the generic code of this implementation
-   cannot determine this, _IOLBF (line buffering) is used for all streams.
+   refer to an interactive device.
 
    If the mode string begins with but is longer than one of the above sequences
    the implementation is at liberty to ignore the additional characters, or do
index 505b91930cd78ade1a12f127ea445bf7070d9b62..02ba7f9e40af87b38b7a8dc0b60ffab8a51c648e 100644 (file)
@@ -61,3 +61,9 @@ int _PDCLIB_remove( const char * filename );
    must still be accessible by old name.
 */
 int _PDCLIB_rename( const char * old, const char * new );
+
+/* A system call that returns one if the given file descriptor refers to an
+   interactive device, and zero otherwise.
+ */
+int _PDCLIB_isinteractive( _PDCLIB_fd_t fd );
+
diff --git a/platform/example/functions/_PDCLIB/isinteractive.c b/platform/example/functions/_PDCLIB/isinteractive.c
new file mode 100644 (file)
index 0000000..ec3e778
--- /dev/null
@@ -0,0 +1,38 @@
+/* $Id$ */
+
+/* _PDCLIB_isinteractive( _PDCLIB_fd_t fd )
+
+   This file is part of the Public Domain C Library (PDCLib).
+   Permission is granted to use, modify, and / or redistribute at will.
+*/
+
+/* This is an example implementation of _PDCLIB_isinteractive() (declared in
+   _PDCLIB_glue.h), fit for use in POSIX kernels.
+   If you do not have an equivalent function, replace this with a return (1)
+   and you will have all streams line-buffered by default.
+*/
+
+#ifndef REGTEST
+#include <_PDCLIB_glue.h>
+
+int isatty( int );
+
+int _PDCLIB_isinteractive( int fd )
+{
+    return isatty( fd );
+}
+
+#endif
+
+#ifdef TEST
+/* TODO: Work around the following undef */
+#undef SEEK_SET
+#include <_PDCLIB_test.h>
+
+int main( void )
+{
+    TESTCASE( NO_TESTDRIVER );
+    return TEST_RESULTS;
+}
+
+#endif