Pouech).
int MSVCRT_flags[MSVCRT_MAX_FILES];
char *MSVCRT_tempfiles[MSVCRT_MAX_FILES];
MSVCRT_FILE MSVCRT__iob[3];
-#define MSVCRT_stdin (MSVCRT__iob+STDIN_FILENO)
-#define MSVCRT_stdout (MSVCRT__iob+STDOUT_FILENO)
-#define MSVCRT_stderr (MSVCRT__iob+STDERR_FILENO)
static int MSVCRT_fdstart = 3; /* first unallocated fd */
static int MSVCRT_fdend = 3; /* highest allocated fd */
return -1;
}
-/*********************************************************************
- * scanf (MSVCRT.@)
- */
-int MSVCRT_scanf(const char *format, ...)
-{
- va_list valist;
- int res;
-
- va_start(valist, format);
- res = MSVCRT_fscanf(MSVCRT_stdin, format, valist);
- va_end(valist);
- return res;
-}
-
-/*********************************************************************
- * wscanf (MSVCRT.@)
- */
-int MSVCRT_wscanf(const MSVCRT_wchar_t *format, ...)
-{
- va_list valist;
- int res;
-
- va_start(valist, format);
- res = MSVCRT_fwscanf(MSVCRT_stdin, format, valist);
- va_end(valist);
- return res;
-}
-
/*********************************************************************
* rename (MSVCRT.@)
*/
WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
+extern MSVCRT_FILE MSVCRT__iob[];
+
/* helper function for *scanf. Returns the value of character c in the
* given base, or -1 if the given character is not a digit of the base.
*/
return -1;
}
-
-/*********************************************************************
- * fscanf (MSVCRT.@)
- */
+/* vfscanf */
#undef WIDE_SCANF
#undef CONSOLE
#undef STRING
#include "scanf.h"
-/*********************************************************************
- * fwscanf (MSVCRT.@)
- */
+/* vfwscanf */
#define WIDE_SCANF 1
#undef CONSOLE
#undef STRING
#include "scanf.h"
-/*********************************************************************
- * sscanf (MSVCRT.@)
- */
+/* vsscanf */
#undef WIDE_SCANF
#undef CONSOLE
#define STRING 1
#include "scanf.h"
-/*********************************************************************
- * swscanf (MSVCRT.@)
- */
+/* vswscanf */
#define WIDE_SCANF 1
#undef CONSOLE
#define STRING 1
#include "scanf.h"
-/*********************************************************************
- * _cscanf (MSVCRT.@)
- */
+/* vcscanf */
#undef WIDE_SCANF
#define CONSOLE 1
#undef STRING
#include "scanf.h"
+
+
+/*********************************************************************
+ * fscanf (MSVCRT.@)
+ */
+int MSVCRT_fscanf(MSVCRT_FILE *file, const char *format, ...)
+{
+ va_list valist;
+ int res;
+
+ va_start(valist, format);
+ res = MSVCRT_vfscanf(file, format, valist);
+ va_end(valist);
+ return res;
+}
+
+/*********************************************************************
+ * scanf (MSVCRT.@)
+ */
+int MSVCRT_scanf(const char *format, ...)
+{
+ va_list valist;
+ int res;
+
+ va_start(valist, format);
+ res = MSVCRT_vfscanf(MSVCRT_stdin, format, valist);
+ va_end(valist);
+ return res;
+}
+
+/*********************************************************************
+ * fwscanf (MSVCRT.@)
+ */
+int MSVCRT_fwscanf(MSVCRT_FILE *file, const MSVCRT_wchar_t *format, ...)
+{
+ va_list valist;
+ int res;
+
+ va_start(valist, format);
+ res = MSVCRT_vfwscanf(file, format, valist);
+ va_end(valist);
+ return res;
+}
+
+
+/*********************************************************************
+ * wscanf (MSVCRT.@)
+ */
+int MSVCRT_wscanf(const MSVCRT_wchar_t *format, ...)
+{
+ va_list valist;
+ int res;
+
+ va_start(valist, format);
+ res = MSVCRT_vfwscanf(MSVCRT_stdin, format, valist);
+ va_end(valist);
+ return res;
+}
+
+
+/*********************************************************************
+ * sscanf (MSVCRT.@)
+ */
+int MSVCRT_sscanf(const char *str, const char *format, ...)
+{
+ va_list valist;
+ int res;
+
+ va_start(valist, format);
+ res = MSVCRT_vsscanf(str, format, valist);
+ va_end(valist);
+ return res;
+}
+
+
+/*********************************************************************
+ * swscanf (MSVCRT.@)
+ */
+int MSVCRT_swscanf(const MSVCRT_wchar_t *str, const MSVCRT_wchar_t *format, ...)
+{
+ va_list valist;
+ int res;
+
+ va_start(valist, format);
+ res = MSVCRT_vswscanf(str, format, valist);
+ va_end(valist);
+ return res;
+}
+
+
+/*********************************************************************
+ * _cscanf (MSVCRT.@)
+ */
+int _cscanf(const char *format, ...)
+{
+ va_list valist;
+ int res;
+
+ va_start(valist, format);
+ res = MSVCRT_vcscanf(format, valist);
+ va_end(valist);
+ return res;
+}
#ifdef CONSOLE
#define _GETC_(file) (consumed++, _getch())
#define _UNGETC_(nch, file) do { _ungetch(nch); consumed--; } while(0)
-#define _FUNCTION_ _cscanf(const _CHAR_ *format, ...)
+#define _FUNCTION_ static int MSVCRT_vcscanf(const char *format, va_list ap)
#else
#ifdef STRING
#undef _EOF_
#define _GETC_(file) (consumed++, *file++)
#define _UNGETC_(nch, file) do { file--; consumed--; } while(0)
#ifdef WIDE_SCANF
-#define _FUNCTION_ MSVCRT_swscanf(const MSVCRT_wchar_t *file, const MSVCRT_wchar_t *format, ...)
+#define _FUNCTION_ static int MSVCRT_vswscanf(const MSVCRT_wchar_t *file, const MSVCRT_wchar_t *format, va_list ap)
#else /* WIDE_SCANF */
-#define _FUNCTION_ MSVCRT_sscanf(const char *file, const char *format, ...)
+#define _FUNCTION_ static int MSVCRT_vsscanf(const char *file, const char *format, va_list ap)
#endif /* WIDE_SCANF */
#else /* STRING */
#ifdef WIDE_SCANF
#define _GETC_(file) (consumed++, MSVCRT_fgetwc(file))
#define _UNGETC_(nch, file) do { MSVCRT_ungetwc(nch, file); consumed--; } while(0)
-#define _FUNCTION_ MSVCRT_fwscanf(MSVCRT_FILE* file, const MSVCRT_wchar_t *format, ...)
+#define _FUNCTION_ static int MSVCRT_vfwscanf(MSVCRT_FILE* file, const MSVCRT_wchar_t *format, va_list ap)
#else /* WIDE_SCANF */
#define _GETC_(file) (consumed++, MSVCRT_fgetc(file))
#define _UNGETC_(nch, file) do { MSVCRT_ungetc(nch, file); consumed--; } while(0)
-#define _FUNCTION_ MSVCRT_fscanf(MSVCRT_FILE* file, const char *format, ...)
+#define _FUNCTION_ static int MSVCRT_vfscanf(MSVCRT_FILE* file, const char *format, va_list ap)
#endif /* WIDE_SCANF */
#endif /* STRING */
#endif /* CONSOLE */
* Extended by C. Scott Ananian <cananian@alumni.princeton.edu> to handle
* more types of format spec.
*/
-int _FUNCTION_ {
+_FUNCTION_ {
int rd = 0, consumed = 0;
int nch;
- va_list ap;
if (!*format) return 0;
#ifndef WIDE_SCANF
#ifdef CONSOLE
nch = _GETC_(file);
if (nch == _EOF_) return _EOF_RET;
- va_start(ap, format);
while (*format) {
/* a whitespace character in the format string causes scanf to read,
* but not store, all consecutive white-space characters in the input
if (nch!=_EOF_) {
_UNGETC_(nch, file);
}
- va_end(ap);
TRACE("returning %d\n", rd);
return rd;
}
#else
+#define MSVCRT_STDIN_FILENO 0
+#define MSVCRT_STDOUT_FILENO 1
+#define MSVCRT_STDERR_FILENO 2
+
/* more file._flag flags, but these conflict with Unix */
#define MSVCRT__IOFBF 0x0000
#define MSVCRT__IONBF 0x0004
#define stdin (_iob+STDIN_FILENO)
#define stdout (_iob+STDOUT_FILENO)
#define stderr (_iob+STDERR_FILENO)
+#else
+#define MSVCRT_stdin (MSVCRT__iob+MSVCRT_STDIN_FILENO)
+#define MSVCRT_stdout (MSVCRT__iob+MSVCRT_STDOUT_FILENO)
+#define MSVCRT_stderr (MSVCRT__iob+MSVCRT_STDERR_FILENO)
#endif /* USE_MSVCRT_PREFIX */
#ifndef MSVCRT_STDIO_DEFINED