]> pd.if.org Git - pdclib/blob - functions/stdio/fscanf.c
f9b950eee7edcbd4ec68f62532a4ea4ed20d84e2
[pdclib] / functions / stdio / fscanf.c
1 /* $Id$ */
2
3 /* fscanf( 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_fscanf_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_vfscanf_unlocked( stream, format, ap );
22     va_end( ap );
23     return rc;
24 }
25
26 int fscanf( FILE * _PDCLIB_restrict stream, 
27             const char * _PDCLIB_restrict format, ... )
28 {
29     int rc;
30     va_list ap;
31     va_start( ap, format );
32     rc = vfscanf( stream, format, ap );
33     va_end( ap );
34     return rc;
35 }
36
37 #endif
38
39 #ifdef TEST
40 #define _PDCLIB_FILEID "stdio/fscanf.c"
41 #define _PDCLIB_FILEIO
42
43 #include <_PDCLIB_test.h>
44
45 #define testscanf( stream, format, ... ) fscanf( stream, format, __VA_ARGS__ )
46
47 int main( void )
48 {
49     FILE * source;
50     TESTCASE( ( source = tmpfile() ) != NULL );
51 #include "scanf_testcases.h"
52     TESTCASE( fclose( source ) == 0 );
53     return TEST_RESULTS;
54 }
55
56 #endif