9ab876fcdcbe59f3c346a004f18d42cf26067417
2 * general implementation of scanf used by scanf, sscanf, fscanf,
3 * _cscanf, wscanf, swscanf and fwscanf
5 * Copyright 1996,1998 Marcus Meissner
6 * Copyright 1996 Jukka Iivonen
7 * Copyright 1997,2000 Uwe Bonnes
8 * Copyright 2000 Jon Griffiths
9 * Copyright 2002 Daniel Gudbjartsson
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
30 #include <wine/debug.h>
34 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt
);
38 /* helper function for *scanf. Returns the value of character c in the
39 * given base, or -1 if the given character is not a digit of the base.
41 static int char2digit(char c
, int base
) {
42 if ((c
>='0') && (c
<='9') && (c
<='0'+base
-1)) return (c
-'0');
43 if (base
<=10) return -1;
44 if ((c
>='A') && (c
<='Z') && (c
<='A'+base
-11)) return (c
-'A'+10);
45 if ((c
>='a') && (c
<='z') && (c
<='a'+base
-11)) return (c
-'a'+10);
49 /* helper function for *wscanf. Returns the value of character c in the
50 * given base, or -1 if the given character is not a digit of the base.
52 static int wchar2digit(wchar_t c
, int base
) {
53 if ((c
>='0') && (c
<='9') && (c
<='0'+base
-1)) return (c
-'0');
54 if (base
<=10) return -1;
55 if ((c
>='A') && (c
<='Z') && (c
<='A'+base
-11)) return (c
-'A'+10);
56 if ((c
>='a') && (c
<='z') && (c
<='a'+base
-11)) return (c
-'a'+10);
74 #endif /* !_LIBCNT_ */
99 /*********************************************************************
102 int CDECL
fscanf(FILE *file
, const char *format
, ...)
107 va_start(valist
, format
);
108 res
= vfscanf_l(file
, format
, NULL
, valist
);
113 /*********************************************************************
116 int CDECL
scanf(const char *format
, ...)
121 va_start(valist
, format
);
122 res
= vfscanf_l(stdin
, format
, NULL
, valist
);
127 /*********************************************************************
130 int CDECL
fwscanf(FILE *file
, const wchar_t *format
, ...)
135 va_start(valist
, format
);
136 res
= vfwscanf_l(file
, format
, NULL
, valist
);
142 /*********************************************************************
145 int CDECL
wscanf(const wchar_t *format
, ...)
150 va_start(valist
, format
);
151 res
= vfwscanf_l(stdin
, format
, NULL
, valist
);
155 #endif /* !_LIBCNT_ */
158 /*********************************************************************
161 int CDECL
sscanf(const char *str
, const char *format
, ...)
166 va_start(valist
, format
);
167 res
= vsscanf_l(str
, format
, NULL
, valist
);
173 /*********************************************************************
176 int CDECL
swscanf(const wchar_t *str
, const wchar_t *format
, ...)
181 va_start(valist
, format
);
182 res
= vswscanf_l(str
, format
, NULL
, valist
);
188 /*********************************************************************
191 int CDECL
_cscanf(const char *format
, ...)
196 va_start(valist
, format
);
197 res
= vcscanf_l(format
, NULL
, valist
);