f8f33e7e99c32275c91c9fd2909ce90d2ceefbaf
[reactos.git] / reactos / lib / crtdll / stdio / fscanf.c
1 /* Copyright (C) 1991 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If
16 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
17 Cambridge, MA 02139, USA. */
18
19
20 #include <stdarg.h>
21 #include <crtdll/stdio.h>
22 #include <crtdll/wchar.h>
23 #include <crtdll/alloc.h>
24
25
26 int __vfscanf (FILE *s, const char *format, va_list argptr);
27 /* Read formatted input from STREAM according to the format string FORMAT. */
28 /* VARARGS2 */
29 int fscanf(FILE *stream,const char *format, ...)
30 {
31 va_list arg;
32 int done;
33
34 va_start(arg, format);
35 done = __vfscanf(stream, format, arg);
36 va_end(arg);
37
38 return done;
39 }
40
41 int
42 fwscanf(FILE *stream, const wchar_t *fmt, ...)
43 {
44 va_list arg;
45 int done;
46 char *cf;
47 int i,len = wcslen(fmt);
48
49 cf = malloc(len+1);
50 for(i=0;i<len;i++)
51 cf[i] = fmt[i];
52 cf[i] = 0;
53
54 va_start(arg, fmt);
55 done = __vfscanf(stream, cf, arg);
56 va_end(arg);
57 free(cf);
58 return done;
59 }
60