sl@0: /* SETBUF.C sl@0: * sl@0: * Portions Copyright (c) 1990-1999 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: */ sl@0: sl@0: /* sl@0: * Copyright (c) 1990 The Regents of the University of California. sl@0: * All rights reserved. sl@0: * sl@0: * Redistribution and use in source and binary forms are permitted sl@0: * provided that the above copyright notice and this paragraph are sl@0: * duplicated in all such forms and that any documentation, sl@0: * advertising materials, and other materials related to such sl@0: * distribution and use acknowledge that the software was developed sl@0: * by the University of California, Berkeley. The name of the sl@0: * University may not be used to endorse or promote products derived sl@0: * from this software without specific prior written permission. sl@0: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR sl@0: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED sl@0: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. sl@0: */ sl@0: sl@0: /* sl@0: FUNCTION sl@0: <>---specify full buffering for a file or stream sl@0: sl@0: INDEX sl@0: setbuf sl@0: sl@0: ANSI_SYNOPSIS sl@0: #include sl@0: void setbuf(FILE *<[fp]>, char *<[buf]>); sl@0: sl@0: TRAD_SYNOPSIS sl@0: #include sl@0: void setbuf(<[fp]>, <[buf]>) sl@0: FILE *<[fp]>; sl@0: char *<[buf]>; sl@0: sl@0: DESCRIPTION sl@0: <> specifies that output to the file or stream identified by <[fp]> sl@0: should be fully buffered. All output for this file will go to a sl@0: buffer (of size <>, specified in `<>'). Output will sl@0: be passed on to the host system only when the buffer is full, or when sl@0: an input operation intervenes. sl@0: sl@0: You may, if you wish, supply your own buffer by passing a pointer to sl@0: it as the argument <[buf]>. It must have size <>. You can sl@0: also use <> as the value of <[buf]>, to signal that the sl@0: <> function is to allocate the buffer. sl@0: sl@0: WARNINGS sl@0: You may only use <> before performing any file operation other sl@0: than opening the file. sl@0: sl@0: If you supply a non-null <[buf]>, you must ensure that the associated sl@0: storage continues to be available until you close the stream sl@0: identified by <[fp]>. sl@0: sl@0: RETURNS sl@0: <> does not return a result. sl@0: sl@0: PORTABILITY sl@0: Both ANSI C and the System V Interface Definition (Issue 2) require sl@0: <>. However, they differ on the meaning of a <> buffer sl@0: pointer: the SVID issue 2 specification says that a <> buffer sl@0: pointer requests unbuffered output. For maximum portability, avoid sl@0: <> buffer pointers. sl@0: sl@0: Supporting OS subroutines required: <>, <>, <>, sl@0: <>, <>, <>, <>. sl@0: */ sl@0: sl@0: #include sl@0: #include "LOCAL.H" sl@0: sl@0: /** sl@0: Change stream buffering. sl@0: Changes the buffer used for I/O operations with the specified stream, or, sl@0: if the specified buffer is NULL it disables buffering with the stream. sl@0: This function should be called once the file associated with the stream sl@0: has been opened but before any input or output operation has been done. sl@0: With buffered streams writing operations do not write directly sl@0: to the device associated with them; the data is accumulated in the buffer sl@0: and written to the device as a block. sl@0: All buffers are also flushed when program terminates. sl@0: @param fp pointer to an open file. sl@0: @param buf User allocated buffer. Must have a length of BUFSIZ bytes. sl@0: */ sl@0: EXPORT_C void setbuf (FILE * fp, char *buf) sl@0: { sl@0: (void) setvbuf (fp, buf, buf ? _IOFBF : _IONBF, BUFSIZ); sl@0: }