]> pd.if.org Git - pdclib/blobdiff - functions/stdio/setbuf.c
Removed the $Name$ tags (not supported by SVN). Added $Id$ to Makefile / text files.
[pdclib] / functions / stdio / setbuf.c
index 6d689b0f3f0fc2f8fdf66fb7cba894abfbd1a318..d51582f975c3c8b13afb3d0c066d8849d369a294 100644 (file)
@@ -1,8 +1,37 @@
-// ----------------------------------------------------------------------------
-// $Id$
-// ----------------------------------------------------------------------------
-// Public Domain C Library - http://pdclib.sourceforge.net
-// This code is Public Domain. Use, modify, and redistribute at will.
-// ----------------------------------------------------------------------------
-
-void setbuf( FILE * restrict stream, char * restrict buf ) { /* TODO */ };
+/* $Id$ */
+
+/* setbuf( FILE *, char * )
+
+   This file is part of the Public Domain C Library (PDCLib).
+   Permission is granted to use, modify, and / or redistribute at will.
+*/
+
+#include <stdio.h>
+
+#ifndef REGTEST
+
+void setbuf( FILE * _PDCLIB_restrict stream, char * _PDCLIB_restrict buf )
+{
+    /* TODO: Only allowed on a "virgin" stream; add check. */
+    if ( buf == NULL )
+    {
+        setvbuf( stream, buf, _IONBF, BUFSIZ );
+    }
+    else
+    {
+        setvbuf( stream, buf, _IOFBF, BUFSIZ );
+    }
+}
+
+#endif
+
+#ifdef TEST
+#include <_PDCLIB_test.h>
+
+int main( void )
+{
+    TESTCASE( NO_TESTDRIVER );
+    return TEST_RESULTS;
+}
+
+#endif