9b9d03e3ce717ed1728b6069c969c23754f7eb01
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
42 #include <internal/file.h>
45 #define NTOS_MODE_USER
46 #include <ndk/umtypes.h>
47 #include <ndk/extypes.h>
48 #include <ndk/rtlfuncs.h>
51 #include <internal/debug.h>
53 //#include "wine/debug.h"
57 //WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
61 /* helper function for *scanf. Returns the value of character c in the
62 * given base, or -1 if the given character is not a digit of the base.
64 static int char2digit(char c
, int base
) {
65 if ((c
>='0') && (c
<='9') && (c
<='0'+base
-1)) return (c
-'0');
66 if (base
<=10) return -1;
67 if ((c
>='A') && (c
<='Z') && (c
<='A'+base
-11)) return (c
-'A'+10);
68 if ((c
>='a') && (c
<='z') && (c
<='a'+base
-11)) return (c
-'a'+10);
72 /* helper function for *wscanf. Returns the value of character c in the
73 * given base, or -1 if the given character is not a digit of the base.
75 static int wchar2digit(wchar_t c
, int base
) {
76 if ((c
>=L
'0') && (c
<=L
'9') && (c
<=L
'0'+base
-1)) return (c
-L
'0');
77 if (base
<=10) return -1;
78 if ((c
>=L
'A') && (c
<=L
'Z') && (c
<=L
'A'+base
-11)) return (c
-L
'A'+10);
79 if ((c
>=L
'a') && (c
<=L
'z') && (c
<=L
'a'+base
-11)) return (c
-L
'a'+10);
114 /*********************************************************************
117 int fscanf(FILE *file
, const char *format
, ...)
122 va_start(valist
, format
);
123 res
= vfscanf(file
, format
, valist
);
128 /*********************************************************************
131 int scanf(const char *format
, ...)
136 va_start(valist
, format
);
137 res
= vfscanf(stdin
, format
, valist
);
142 /*********************************************************************
145 int fwscanf(FILE *file
, const wchar_t *format
, ...)
150 va_start(valist
, format
);
151 res
= vfwscanf(file
, format
, valist
);
157 /*********************************************************************
160 int wscanf(const wchar_t *format
, ...)
165 va_start(valist
, format
);
166 res
= vfwscanf(stdin
, format
, valist
);
172 /*********************************************************************
175 int crt_sscanf(const char *str
, const char *format
, ...)
180 va_start(valist
, format
);
181 res
= vsscanf(str
, format
, valist
);
187 /*********************************************************************
190 int swscanf(const wchar_t *str
, const wchar_t *format
, ...)
195 va_start(valist
, format
);
196 res
= vswscanf(str
, format
, valist
);
202 /*********************************************************************
205 int _cscanf(/*const*/ char *format
, ...)
210 va_start(valist
, format
);
211 res
= vcscanf(format
, valist
);