]> pd.if.org Git - pdclib/blob - functions/stdio/printf.c
9dcb4fc0fdcd73fe49da53ad1d4ee87d54292d43
[pdclib] / functions / stdio / printf.c
1 /* $Id$ */
2
3 /* printf( const char *, ... )
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 #include <_PDCLIB_io.h>
14
15 int printf( const char * _PDCLIB_restrict format, ... )
16 {
17     int rc;
18     va_list ap;
19     va_start( ap, format );
20     rc = vfprintf( stdout, format, ap );
21     va_end( ap );
22     return rc;
23 }
24
25 int _PDCLIB_printf_unlocked( const char * _PDCLIB_restrict format, ... )
26 {
27     int rc;
28     va_list ap;
29     va_start( ap, format );
30     rc = _PDCLIB_vfprintf_unlocked( stdout, format, ap );
31     va_end( ap );
32     return rc;
33 }
34
35 #endif
36
37 #ifdef TEST
38 #define _PDCLIB_FILEID "stdio/printf.c"
39 #define _PDCLIB_FILEIO
40 #include <stdint.h>
41 #include <stddef.h>
42
43 #include <_PDCLIB_test.h>
44
45 #define testprintf( stream, ... ) printf( __VA_ARGS__ )
46
47 int main( void )
48 {
49     FILE * target;
50     TESTCASE( ( target = freopen( testfile, "wb+", stdout ) ) != NULL );
51 #include "printf_testcases.h"
52     TESTCASE( fclose( target ) == 0 );
53     TESTCASE( remove( testfile ) == 0 );
54     return TEST_RESULTS;
55 }
56
57 #endif