1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/LSTDIO/SETBUF.C Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,94 @@
1.4 +/* SETBUF.C
1.5 + *
1.6 + * Portions Copyright (c) 1990-1999 Nokia Corporation and/or its subsidiary(-ies).
1.7 + * All rights reserved.
1.8 + */
1.9 +
1.10 +/*
1.11 + * Copyright (c) 1990 The Regents of the University of California.
1.12 + * All rights reserved.
1.13 + *
1.14 + * Redistribution and use in source and binary forms are permitted
1.15 + * provided that the above copyright notice and this paragraph are
1.16 + * duplicated in all such forms and that any documentation,
1.17 + * advertising materials, and other materials related to such
1.18 + * distribution and use acknowledge that the software was developed
1.19 + * by the University of California, Berkeley. The name of the
1.20 + * University may not be used to endorse or promote products derived
1.21 + * from this software without specific prior written permission.
1.22 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
1.23 + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
1.24 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1.25 + */
1.26 +
1.27 +/*
1.28 +FUNCTION
1.29 +<<setbuf>>---specify full buffering for a file or stream
1.30 +
1.31 +INDEX
1.32 + setbuf
1.33 +
1.34 +ANSI_SYNOPSIS
1.35 + #include <stdio.h>
1.36 + void setbuf(FILE *<[fp]>, char *<[buf]>);
1.37 +
1.38 +TRAD_SYNOPSIS
1.39 + #include <stdio.h>
1.40 + void setbuf(<[fp]>, <[buf]>)
1.41 + FILE *<[fp]>;
1.42 + char *<[buf]>;
1.43 +
1.44 +DESCRIPTION
1.45 +<<setbuf>> specifies that output to the file or stream identified by <[fp]>
1.46 +should be fully buffered. All output for this file will go to a
1.47 +buffer (of size <<BUFSIZ>>, specified in `<<stdio.h>>'). Output will
1.48 +be passed on to the host system only when the buffer is full, or when
1.49 +an input operation intervenes.
1.50 +
1.51 +You may, if you wish, supply your own buffer by passing a pointer to
1.52 +it as the argument <[buf]>. It must have size <<BUFSIZ>>. You can
1.53 +also use <<NULL>> as the value of <[buf]>, to signal that the
1.54 +<<setbuf>> function is to allocate the buffer.
1.55 +
1.56 +WARNINGS
1.57 +You may only use <<setbuf>> before performing any file operation other
1.58 +than opening the file.
1.59 +
1.60 +If you supply a non-null <[buf]>, you must ensure that the associated
1.61 +storage continues to be available until you close the stream
1.62 +identified by <[fp]>.
1.63 +
1.64 +RETURNS
1.65 +<<setbuf>> does not return a result.
1.66 +
1.67 +PORTABILITY
1.68 +Both ANSI C and the System V Interface Definition (Issue 2) require
1.69 +<<setbuf>>. However, they differ on the meaning of a <<NULL>> buffer
1.70 +pointer: the SVID issue 2 specification says that a <<NULL>> buffer
1.71 +pointer requests unbuffered output. For maximum portability, avoid
1.72 +<<NULL>> buffer pointers.
1.73 +
1.74 +Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
1.75 +<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
1.76 +*/
1.77 +
1.78 +#include <stdio.h>
1.79 +#include "LOCAL.H"
1.80 +
1.81 +/**
1.82 +Change stream buffering.
1.83 +Changes the buffer used for I/O operations with the specified stream, or,
1.84 +if the specified buffer is NULL it disables buffering with the stream.
1.85 +This function should be called once the file associated with the stream
1.86 +has been opened but before any input or output operation has been done.
1.87 +With buffered streams writing operations do not write directly
1.88 +to the device associated with them; the data is accumulated in the buffer
1.89 +and written to the device as a block.
1.90 +All buffers are also flushed when program terminates.
1.91 +@param fp pointer to an open file.
1.92 +@param buf User allocated buffer. Must have a length of BUFSIZ bytes.
1.93 +*/
1.94 +EXPORT_C void setbuf (FILE * fp, char *buf)
1.95 +{
1.96 + (void) setvbuf (fp, buf, buf ? _IOFBF : _IONBF, BUFSIZ);
1.97 +}