ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

scanf.c
Go to the documentation of this file.
00001 /*
00002  * general implementation of scanf used by scanf, sscanf, fscanf,
00003  * _cscanf, wscanf, swscanf and fwscanf
00004  *
00005  * Copyright 1996,1998 Marcus Meissner
00006  * Copyright 1996 Jukka Iivonen
00007  * Copyright 1997,2000 Uwe Bonnes
00008  * Copyright 2000 Jon Griffiths
00009  * Copyright 2002 Daniel Gudbjartsson
00010  *
00011  * This library is free software; you can redistribute it and/or
00012  * modify it under the terms of the GNU Lesser General Public
00013  * License as published by the Free Software Foundation; either
00014  * version 2.1 of the License, or (at your option) any later version.
00015  *
00016  * This library is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019  * Lesser General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Lesser General Public
00022  * License along with this library; if not, write to the Free Software
00023  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00024  */
00025 
00026 #include <precomp.h>
00027 #include <ctype.h>
00028 
00029 // HACK for LIBCNT
00030 #ifndef debugstr_a
00031 #define debugstr_a
00032 #endif
00033 
00034 //extern FILE _iob[];
00035 
00036 /* helper function for *scanf.  Returns the value of character c in the
00037  * given base, or -1 if the given character is not a digit of the base.
00038  */
00039 static int char2digit(char c, int base) {
00040     if ((c>='0') && (c<='9') && (c<='0'+base-1)) return (c-'0');
00041     if (base<=10) return -1;
00042     if ((c>='A') && (c<='Z') && (c<='A'+base-11)) return (c-'A'+10);
00043     if ((c>='a') && (c<='z') && (c<='a'+base-11)) return (c-'a'+10);
00044     return -1;
00045 }
00046 
00047 /* helper function for *wscanf.  Returns the value of character c in the
00048  * given base, or -1 if the given character is not a digit of the base.
00049  */
00050 static int wchar2digit(wchar_t c, int base) {
00051     if ((c>='0') && (c<='9') && (c<='0'+base-1)) return (c-'0');
00052     if (base<=10) return -1;
00053     if ((c>='A') && (c<='Z') && (c<='A'+base-11)) return (c-'A'+10);
00054     if ((c>='a') && (c<='z') && (c<='a'+base-11)) return (c-'a'+10);
00055     return -1;
00056 }
00057 
00058 #ifndef _LIBCNT_
00059 /* vfscanf */
00060 #undef WIDE_SCANF
00061 #undef CONSOLE
00062 #undef STRING
00063 #include "scanf.h"
00064 
00065 /* vfwscanf */
00066 #define WIDE_SCANF 1
00067 #undef CONSOLE
00068 #undef STRING
00069 #include "scanf.h"
00070 #endif
00071 
00072 /* vsscanf */
00073 #undef WIDE_SCANF
00074 #undef CONSOLE
00075 #define STRING 1
00076 #include "scanf.h"
00077 
00078 /* vswscanf */
00079 #define WIDE_SCANF 1
00080 #undef CONSOLE
00081 #define STRING 1
00082 #include "scanf.h"
00083 
00084 #ifndef _LIBCNT_
00085 /* vcscanf */
00086 #undef WIDE_SCANF
00087 #define CONSOLE 1
00088 #undef STRING
00089 #include "scanf.h"
00090 
00091 
00092 /*********************************************************************
00093  *      fscanf (MSVCRT.@)
00094  */
00095 int fscanf(FILE *file, const char *format, ...)
00096 {
00097     va_list valist;
00098     int res;
00099 
00100     va_start(valist, format);
00101     res = vfscanf(file, format, valist);
00102     va_end(valist);
00103     return res;
00104 }
00105 
00106 /*********************************************************************
00107  *      scanf (MSVCRT.@)
00108  */
00109 int scanf(const char *format, ...)
00110 {
00111     va_list valist;
00112     int res;
00113 
00114     va_start(valist, format);
00115     res = vfscanf(stdin, format, valist);
00116     va_end(valist);
00117     return res;
00118 }
00119 
00120 /*********************************************************************
00121  *      fwscanf (MSVCRT.@)
00122  */
00123 int fwscanf(FILE *file, const wchar_t *format, ...)
00124 {
00125     va_list valist;
00126     int res;
00127 
00128     va_start(valist, format);
00129     res = vfwscanf(file, format, valist);
00130     va_end(valist);
00131     return res;
00132 }
00133 
00134 
00135 /*********************************************************************
00136  *      wscanf (MSVCRT.@)
00137  */
00138 int wscanf(const wchar_t *format, ...)
00139 {
00140     va_list valist;
00141     int res;
00142 
00143     va_start(valist, format);
00144     res = vfwscanf(stdin, format, valist);
00145     va_end(valist);
00146     return res;
00147 }
00148 #endif
00149 
00150 
00151 /*********************************************************************
00152  *      sscanf (MSVCRT.@)
00153  */
00154 int sscanf(const char *str, const char *format, ...)
00155 {
00156     va_list valist;
00157     int res;
00158 
00159     va_start(valist, format);
00160     res = vsscanf(str, format, valist);
00161     va_end(valist);
00162     return res;
00163 }
00164 
00165 
00166 /*********************************************************************
00167  *      swscanf (MSVCRT.@)
00168  */
00169 int CDECL swscanf(const wchar_t *str, const wchar_t *format, ...)
00170 {
00171     va_list valist;
00172     int res;
00173 
00174     va_start(valist, format);
00175     res = vswscanf(str, format, valist);
00176     va_end(valist);
00177     return res;
00178 }
00179 
00180 #ifndef _LIBCNT_
00181 /*********************************************************************
00182  *      _cscanf (MSVCRT.@)
00183  */
00184 int CDECL _cscanf(const char *format, ...)
00185 {
00186     va_list valist;
00187     int res;
00188 
00189     va_start(valist, format);
00190     res = vcscanf(format, valist);
00191     va_end(valist);
00192     return res;
00193 }
00194 #endif

Generated on Sun May 27 2012 04:36:39 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.