]> git.sur5r.net Git - cc65/blob - libsrc/common/vsprintf.c
This commit was generated by cvs2svn to compensate for changes in r2,
[cc65] / libsrc / common / vsprintf.c
1 /*
2  * vsprintf.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     /* String - be shure to check the size */
19     while (count-- && d->ccount < d->uns) {
20         ((char*) d->ptr) [d->ccount] = *buf;
21         ++buf;
22         ++d->ccount;
23     }
24 }
25
26
27
28 int vsprintf (char* buf, char* format, va_list ap)
29 {
30     struct outdesc d;
31
32     /* Setup descriptor */
33     d.fout = out;
34     d.ptr  = buf;
35     d.uns  = 0x7FFF;
36
37     /* Do formatting and output */
38     _printf (&d, format, ap);
39
40     /* Return bytes written */
41     return d.ccount;
42 }
43
44
45