Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/waterbox/libc/functions/stdio/fprintf.c
2 views
1
/* fprintf( FILE *, const char *, ... )
2
3
This file is part of the Public Domain C Library (PDCLib).
4
Permission is granted to use, modify, and / or redistribute at will.
5
*/
6
7
#include <stdio.h>
8
#include <stdarg.h>
9
10
#ifndef REGTEST
11
#include "_PDCLIB_io.h"
12
13
int _PDCLIB_fprintf_unlocked( FILE * _PDCLIB_restrict stream,
14
const char * _PDCLIB_restrict format, ... )
15
{
16
int rc;
17
va_list ap;
18
va_start( ap, format );
19
rc = _PDCLIB_vfprintf_unlocked( stream, format, ap );
20
va_end( ap );
21
return rc;
22
}
23
24
int fprintf( FILE * _PDCLIB_restrict stream,
25
const char * _PDCLIB_restrict format, ... )
26
{
27
int rc;
28
va_list ap;
29
va_start( ap, format );
30
_PDCLIB_flockfile( stream );
31
rc = _PDCLIB_vfprintf_unlocked( stream, format, ap );
32
_PDCLIB_funlockfile( stream );
33
va_end( ap );
34
return rc;
35
}
36
37
#endif
38
39
#ifdef TEST
40
#include <stdint.h>
41
#include <stddef.h>
42
#define _PDCLIB_FILEID "stdio/fprintf.c"
43
#define _PDCLIB_FILEIO
44
45
#include "_PDCLIB_test.h"
46
47
#define testprintf( stream, ... ) fprintf( stream, __VA_ARGS__ )
48
49
int main( void )
50
{
51
FILE * target;
52
TESTCASE( ( target = tmpfile() ) != NULL );
53
#include "printf_testcases.h"
54
TESTCASE( fclose( target ) == 0 );
55
return TEST_RESULTS;
56
}
57
58
#endif
59
60
61