From e611b132f9b8abe35b362e5870b74bce94a1e58e Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 16 May 2020 20:51:50 -0700 Subject: initial commit --- private/crt32/stdio/setbuf.c | 61 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 private/crt32/stdio/setbuf.c (limited to 'private/crt32/stdio/setbuf.c') 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 +* . +* 07-23-90 SBM Replaced by +* 10-03-90 GJF New-style function declarator. +* +*******************************************************************************/ + +#include +#include +#include + +/*** +*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); + +} -- cgit v1.2.3