]> pd.if.org Git - pdclib/blob - functions/stdio/vsnprintf.c
Temporary integration of _PDCLIB_print(), broken.
[pdclib] / functions / stdio / vsnprintf.c
1 /* $Id$ */
2
3 /* vsnprintf( char *, size_t, const char *, va_list ap )
4
5    This file is part of the Public Domain C Library (PDCLib).
6    Permission is granted to use, modify, and / or redistribute at will.
7 */
8
9 #include <stdio.h>
10 #include <stdarg.h>
11
12 #ifndef REGTEST
13
14 int vsnprintf( char * s, size_t n, const char * format, _PDCLIB_va_list arg )
15 {
16     /* TODO: This function should interpret format as multibyte characters.  */
17     /* Members: base, flags, n, i, this, s, width, prec, stream, arg         */
18     struct _PDCLIB_status_t status = { 0, 0, n, 0, 0, s, 0, 0, NULL, arg };
19     while ( *format != '\0' )
20     {
21         const char * rc;
22         if ( ( *format != '%' ) || ( ( rc = _PDCLIB_print( format, &status ) ) == format ) )
23         {
24             /* No conversion specifier, print verbatim */
25             s[ status.i++ ] = *(format++);
26         }
27         else
28         {
29             /* Continue parsing after conversion specifier */
30             format = rc;
31         }
32     }
33     s[ status.i ] = '\0';
34     return status.i;
35 }
36
37 #endif
38
39 #ifdef TEST
40 #include <_PDCLIB_test.h>
41
42 int main( void )
43 {
44     TESTCASE( NO_TESTDRIVER );
45     return TEST_RESULTS;
46 }
47
48 #endif