From: solar Date: Thu, 20 Sep 2007 21:21:15 +0000 (+0000) Subject: Added test for interactive streams (_IOLBF / _IOFBF) X-Git-Tag: v0.5~135 X-Git-Url: https://pd.if.org/git/?p=pdclib;a=commitdiff_plain;h=e47de3b4ecdbd4164b77c95b34932596f2dc5cad Added test for interactive streams (_IOLBF / _IOFBF) --- diff --git a/includes/stdio.h b/includes/stdio.h index 7f79390..68f1cb7 100644 --- a/includes/stdio.h +++ b/includes/stdio.h @@ -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 diff --git a/internals/_PDCLIB_glue.h b/internals/_PDCLIB_glue.h index 505b919..02ba7f9 100644 --- a/internals/_PDCLIB_glue.h +++ b/internals/_PDCLIB_glue.h @@ -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 index 0000000..ec3e778 --- /dev/null +++ b/platform/example/functions/_PDCLIB/isinteractive.c @@ -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