From 8a0efa53e44919bcf5ccb1d3353618a82afdf8bc Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Thu, 17 Feb 2000 19:39:52 +0000 Subject: import newlib-2000-02-17 snapshot --- newlib/libc/stdio/setbuf.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 newlib/libc/stdio/setbuf.c (limited to 'newlib/libc/stdio/setbuf.c') diff --git a/newlib/libc/stdio/setbuf.c b/newlib/libc/stdio/setbuf.c new file mode 100644 index 000000000..15d09e0f3 --- /dev/null +++ b/newlib/libc/stdio/setbuf.c @@ -0,0 +1,79 @@ +/* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* +FUNCTION +<>---specify full buffering for a file or stream + +INDEX + setbuf + +ANSI_SYNOPSIS + #include + void setbuf(FILE *<[fp]>, char *<[buf]>); + +TRAD_SYNOPSIS + #include + void setbuf(<[fp]>, <[buf]>) + FILE *<[fp]>; + char *<[buf]>; + +DESCRIPTION +<> specifies that output to the file or stream identified by <[fp]> +should be fully buffered. All output for this file will go to a +buffer (of size <>, specified in `<>'). Output will +be passed on to the host system only when the buffer is full, or when +an input operation intervenes. + +You may, if you wish, supply your own buffer by passing a pointer to +it as the argument <[buf]>. It must have size <>. You can +also use <> as the value of <[buf]>, to signal that the +<> function is to allocate the buffer. + +WARNINGS +You may only use <> before performing any file operation other +than opening the file. + +If you supply a non-null <[buf]>, you must ensure that the associated +storage continues to be available until you close the stream +identified by <[fp]>. + +RETURNS +<> does not return a result. + +PORTABILITY +Both ANSI C and the System V Interface Definition (Issue 2) require +<>. However, they differ on the meaning of a <> buffer +pointer: the SVID issue 2 specification says that a <> buffer +pointer requests unbuffered output. For maximum portability, avoid +<> buffer pointers. + +Supporting OS subroutines required: <>, <>, <>, +<>, <>, <>, <>. +*/ + +#include <_ansi.h> +#include +#include "local.h" + +void +_DEFUN (setbuf, (fp, buf), + FILE * fp _AND + char *buf) +{ + (void) setvbuf (fp, buf, buf ? _IOFBF : _IONBF, BUFSIZ); +} -- cgit v1.2.3