source: trunk/libs/newlib/src/newlib/libc/stdio/setbuffer.c @ 567

Last change on this file since 567 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 2.3 KB
Line 
1/*
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are permitted
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * advertising materials, and other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley.  The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16 */
17/*
18Modified copy of setbuf.c to support the setbuffer function
19defined as part of BSD.
20Modifications by Gareth Pearce, 2001.
21*/
22
23/*
24FUNCTION
25<<setbuffer>>---specify full buffering for a file or stream with size
26
27INDEX
28        setbuffer
29
30SYNOPSIS
31        #include <stdio.h>
32        void setbuffer(FILE *<[fp]>, char *<[buf]>, int <[size]>);
33
34DESCRIPTION
35<<setbuffer>> specifies that output to the file or stream identified by
36<[fp]> should be fully buffered.  All output for this file will go to a
37buffer (of size <[size]>).  Output will be passed on to the host system
38only when the buffer is full, or when an input operation intervenes.
39
40You may, if you wish, supply your own buffer by passing a pointer to
41it as the argument <[buf]>.  It must have size <[size]>.  You can
42also use <<NULL>> as the value of <[buf]>, to signal that the
43<<setbuffer>> function is to allocate the buffer.
44
45WARNINGS
46You may only use <<setbuffer>> before performing any file operation
47other than opening the file.
48
49If you supply a non-null <[buf]>, you must ensure that the associated
50storage continues to be available until you close the stream
51identified by <[fp]>.
52
53RETURNS
54<<setbuffer>> does not return a result.
55
56PORTABILITY
57This function comes from BSD not ANSI or POSIX.
58
59Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
60<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
61*/
62
63#include <_ansi.h>
64#include <stdio.h>
65#include "local.h"
66
67void
68setbuffer (FILE * fp,
69       char *buf,
70       int size)
71{
72  (void) setvbuf (fp, buf, buf ? _IOFBF : _IONBF, (size_t) size);
73}
Note: See TracBrowser for help on using the repository browser.