Added setting position while duplicating file handles with FMF_WRITE mode. It's neede...
[cake.git] / compiler / clib / setvbuf.c
blobc264d7a9a0aae52bf4dcec66ba6b849892bdbd6b
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
5 ANSI C function setvbuf().
6 */
8 #include <dos/stdio.h>
9 #include <proto/dos.h>
10 #include <errno.h>
11 #include "__open.h"
13 /*****************************************************************************
15 NAME */
16 #include <stdio.h>
18 int setvbuf (
20 /* SYNOPSIS */
21 FILE *stream,
22 char *buf,
23 int mode,
24 size_t size)
26 /* FUNCTION
28 INPUTS
30 RESULT
32 NOTES
34 EXAMPLE
36 BUGS
38 SEE ALSO
40 INTERNALS
42 ******************************************************************************/
44 fdesc *desc;
46 if (!stream)
48 errno = EFAULT;
49 return EOF;
52 switch (mode)
54 case _IOFBF: mode = BUF_FULL; break;
55 case _IOLBF: mode = BUF_LINE; break;
56 case _IONBF: mode = BUF_NONE; break;
57 default:
58 errno = EINVAL;
59 return EOF;
62 desc = __getfdesc(stream->fd);
63 if (!desc)
65 errno = EBADF;
66 return EOF;
69 return SetVBuf(desc->fh, buf, mode, size ? size : -1);
70 } /* setvbuf */