]> pd.if.org Git - pdclib/blob - functions/stdio/printf.c
PDCLIB-16: Add _unlocked variations of all I/O routines; move work into these versions
[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
14 int printf( const char * _PDCLIB_restrict format, ... )
15 {
16     int rc;
17     va_list ap;
18     va_start( ap, format );
19     rc = vfprintf( stdout, format, ap );
20     va_end( ap );
21     return rc;
22 }
23
24 int printf_unlocked( const char * _PDCLIB_restrict format, ... )
25 {
26     int rc;
27     va_list ap;
28     va_start( ap, format );
29     rc = vfprintf_unlocked( stdout, format, ap );
30     va_end( ap );
31     return rc;
32 }
33
34 #endif
35
36 #ifdef TEST
37 #define _PDCLIB_FILEID "stdio/printf.c"
38 #define _PDCLIB_FILEIO
39
40 #include <_PDCLIB_test.h>
41
42 #define testprintf( stream, ... ) printf( __VA_ARGS__ )
43
44 int main( void )
45 {
46     FILE * target;
47     TESTCASE( ( target = freopen( testfile, "wb+", stdout ) ) != NULL );
48 #include "printf_testcases.h"
49     TESTCASE( fclose( target ) == 0 );
50     TESTCASE( remove( testfile ) == 0 );
51     return TEST_RESULTS;
52 }
53
54 #endif