summaryrefslogtreecommitdiffstats
path: root/private/crt32/stdio/setbuf.c
diff options
context:
space:
mode:
authorAdam <you@example.com>2020-05-17 05:51:50 +0200
committerAdam <you@example.com>2020-05-17 05:51:50 +0200
commite611b132f9b8abe35b362e5870b74bce94a1e58e (patch)
treea5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/crt32/stdio/setbuf.c
downloadNT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip
Diffstat (limited to 'private/crt32/stdio/setbuf.c')
-rw-r--r--private/crt32/stdio/setbuf.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/private/crt32/stdio/setbuf.c b/private/crt32/stdio/setbuf.c
new file mode 100644
index 000000000..096049ade
--- /dev/null
+++ b/private/crt32/stdio/setbuf.c
@@ -0,0 +1,61 @@
+/***
+*setbuf.c - give new file buffer
+*
+* Copyright (c) 1985-1991, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* defines setbuf() - given a buffer to a stream or make it unbuffered
+*
+*Revision History:
+* 09-19-83 RN initial version
+* 09-28-87 JCR Corrected _iob2 indexing (now uses _iob_index() macro).
+* 11-02-87 JCR Re-wrote to use setvbuf()
+* 12-11-87 JCR Added "_LOAD_DS" to declaration
+* 05-27-88 PHG Merged DLL and normal versions
+* 02-15-90 GJF Fixed copyright and indents
+* 03-19-90 GJF Replaced _LOAD_DS with _CALLTYPE1 and added #include
+* <cruntime.h>.
+* 07-23-90 SBM Replaced <assertm.h> by <assert.h>
+* 10-03-90 GJF New-style function declarator.
+*
+*******************************************************************************/
+
+#include <cruntime.h>
+#include <assert.h>
+#include <stdio.h>
+
+/***
+*void setbuf(stream, buffer) - give a buffer to a stream
+*
+*Purpose:
+* Allow user to assign his/her own buffer to a stream.
+* if buffer is not NULL, it must be BUFSIZ in length.
+* if buffer is NULL, stream will be unbuffered.
+*
+* Since setbuf()'s functionality is a subset of setvbuf(), simply
+* call the latter routine to do the actual work.
+*
+*Entry:
+* FILE *stream - stream to be buffered or unbuffered
+* char *buffer - buffer of size BUFSIZ or NULL
+*
+*Exit:
+* None.
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+void _CALLTYPE1 setbuf (
+ FILE *stream,
+ char *buffer
+ )
+{
+ assert(stream != NULL);
+
+ if (buffer == NULL)
+ setvbuf(stream, NULL, _IONBF, 0);
+ else
+ setvbuf(stream, buffer, _IOFBF, BUFSIZ);
+
+}