:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[reactos.git] / lib / crtdll / stdio / sscanf.c
1 /* Copyright (C) 1991, 1995, 1996 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 not,
16    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17    Boston, MA 02111-1307, USA.  */
18
19 #include <stdarg.h>
20 #include <crtdll/stdio.h>
21 #include <crtdll/wchar.h>
22 #include <crtdll/alloc.h>
23
24
25 int __vsscanf (const char *s,const char *format,va_list arg);
26
27 /* Read formatted input from S, according to the format string FORMAT.  */
28 /* VARARGS2 */
29 int sscanf (const char *s,const char *format, ...)
30 {
31   va_list arg;
32   int done;
33
34   va_start (arg, format);
35   done = __vsscanf (s, format, arg);
36   va_end (arg);
37
38   return done;
39 }
40
41 #ifdef USE_IN_LIBIO
42 # undef _IO_sscanf
43 /* This is for libg++.  */
44 strong_alias (sscanf, _IO_sscanf)
45 #endif
46
47
48
49
50 int
51 swscanf(const wchar_t *str, const wchar_t *fmt, ...)
52 {
53   va_list arg;
54   int done;
55   char *f , *s;
56   int i,len = wcslen(fmt);
57
58   f = malloc(len+1);
59   for(i=0;i<len;i++)
60         f[i] = fmt[i];
61   f[i] = 0;  
62
63   len = wcslen(str);
64   s = alloca(len+1);
65   for(i=0;i<len;i++)
66         s[i] = str[i];
67   s[i] = 0;  
68
69   va_start (arg, fmt);
70   done = __vsscanf (s, f, arg);
71   va_end (arg);
72
73   free(f);
74   return done;
75
76
77 }
78
79