]> git.sur5r.net Git - cc65/blob - libsrc/common/vfprintf.c
This commit was generated by cvs2svn to compensate for changes in r2,
[cc65] / libsrc / common / vfprintf.c
1 /*
2  * vfprintf.c
3  *
4  * Ullrich von Bassewitz, 11.08.1998
5  */
6
7
8
9 #include <stdarg.h>
10 #include <stdio.h>
11 #include "_printf.h"
12
13
14
15 static void out (struct outdesc* d, char* buf, unsigned count)
16 /* Routine used for writing */
17 {
18     /* Write to the file */
19     if (fwrite (buf, count, 1, (FILE*) d->ptr) == -1) {
20         d->ccount = -1;
21     } else {
22         d->ccount += count;
23     }
24 }
25
26
27
28 int vfprintf (FILE* f, char* format, va_list ap)
29 {
30     struct outdesc d;
31
32     /* Setup descriptor */
33     d.fout = out;
34     d.ptr  = f;
35
36     /* Do formatting and output */
37     _printf (&d, format, ap);
38
39     /* Return bytes written */
40     return d.ccount;
41 }
42
43
44