]> pd.if.org Git - pdclib.old/blob - functions/stdio/fprintf.c
[gandr] s/__lp64__/__LP64__/ to match GCC define
[pdclib.old] / functions / stdio / fprintf.c
1 /* $Id$ */
2
3 /* fprintf( FILE *, 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 _PDCLIB_fprintf_unlocked( FILE * _PDCLIB_restrict stream, 
16                       const char * _PDCLIB_restrict format, ... )
17 {
18     int rc;
19     va_list ap;
20     va_start( ap, format );
21     rc = _PDCLIB_vfprintf_unlocked( stream, format, ap );
22     va_end( ap );
23     return rc;
24 }
25
26 int fprintf( FILE * _PDCLIB_restrict stream,
27              const char * _PDCLIB_restrict format, ... )
28 {
29     int rc;
30     va_list ap;
31     va_start( ap, format );
32     _PDCLIB_flockfile( stream );
33     rc = _PDCLIB_vfprintf_unlocked( stream, format, ap );
34     _PDCLIB_funlockfile( stream );
35     va_end( ap );
36     return rc;
37 }
38
39 #endif
40
41 #ifdef TEST
42 #include <stdint.h>
43 #include <stddef.h>
44 #define _PDCLIB_FILEID "stdio/fprintf.c"
45 #define _PDCLIB_FILEIO
46
47 #include <_PDCLIB_test.h>
48
49 #define testprintf( stream, ... ) fprintf( stream, __VA_ARGS__ )
50
51 int main( void )
52 {
53     FILE * target;
54     TESTCASE( ( target = tmpfile() ) != NULL );
55 #include "printf_testcases.h"
56     TESTCASE( fclose( target ) == 0 );
57     return TEST_RESULTS;
58 }
59
60 #endif
61