muimaster.library: support Listview_List in List
[AROS.git] / compiler / posixc / setvbuf.c
blob0910034d67e8cab1e28e67bfc51e511b0ddba72d
1 /*
2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 C99 function setvbuf().
6 */
8 #include <dos/stdio.h>
9 #include <proto/dos.h>
10 #include <errno.h>
11 #include "__fdesc.h"
12 #include "__stdio.h"
14 /*****************************************************************************
16 NAME */
17 #include <stdio.h>
19 int setvbuf (
21 /* SYNOPSIS */
22 FILE *stream,
23 char *buf,
24 int mode,
25 size_t size)
27 /* FUNCTION
29 INPUTS
31 RESULT
33 NOTES
35 EXAMPLE
37 BUGS
39 SEE ALSO
41 INTERNALS
43 ******************************************************************************/
45 fdesc *desc;
47 if (!stream)
49 errno = EFAULT;
50 return EOF;
53 /* Fail if provided buffer is smaller than minimum required by DOS */
54 if (buf && size < 208)
56 errno = EFAULT;
57 return EOF;
60 switch (mode)
62 case _IOFBF: mode = BUF_FULL; break;
63 case _IOLBF: mode = BUF_LINE; break;
64 case _IONBF: mode = BUF_NONE; break;
65 default:
66 errno = EINVAL;
67 return EOF;
70 desc = __getfdesc(stream->fd);
71 if (!desc)
73 errno = EBADF;
74 return EOF;
77 return SetVBuf(desc->fcb->handle, buf, mode, size ? size : -1);
78 } /* setvbuf */