define __KERNEL_STRICT_NAMES to avoid inclusion of kernel types on systems that carry...
[cake.git] / compiler / clib / vfprintf.c
blob3df3648cc69ba425c662cbe2bec422a4924782c2
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Format a string and call a usercallback to output each char.
6 */
7 /* Original source from libnix */
10 #include <proto/dos.h>
11 #include <errno.h>
12 #include "__errno.h"
13 #include "__open.h"
15 static int __putc(int c, BPTR fh);
17 /*****************************************************************************
19 NAME */
20 #include <stdio.h>
21 #include <stdarg.h>
23 int vfprintf (
25 /* SYNOPSIS */
26 FILE * stream,
27 const char * format,
28 va_list args)
30 /* FUNCTION
31 Format a list of arguments and print them on the specified stream.
33 INPUTS
34 stream - A stream on which one can write
35 format - A printf() format string.
36 args - A list of arguments for the format string.
38 RESULT
39 The number of characters written.
41 NOTES
43 EXAMPLE
45 BUGS
47 SEE ALSO
49 INTERNALS
51 ******************************************************************************/
53 fdesc *fdesc = __getfdesc(stream->fd);
55 if (!fdesc)
57 errno = EBADF;
58 return 0;
61 return __vcformat (fdesc->fcb->fh, __putc, format, args);
62 } /* vfprintf */
65 static int __putc(int c, BPTR fh)
67 if (FPutC(fh, c) == EOF)
69 errno = IoErr2errno(IoErr());
70 return EOF;
73 return c;