Index: trunk/src/msvcrt/LICENSE.TXT
===================================================================
--- trunk/src/msvcrt/LICENSE.TXT	(revision 9633)
+++ trunk/src/msvcrt/LICENSE.TXT	(revision 9633)
@@ -0,0 +1,22 @@
+$Id: LICENSE.TXT,v 1.1 2003-01-06 13:26:31 sandervl Exp $
+This is an additional Odin license agreement.
+It supercedes the main Odin license, but is only valid in 
+the source directory in which it is present.
+
+Copyright (c) 1993-2002 the Wine project authors (see the file AUTHORS
+for a complete list)
+
+Wine is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the
+Free Software Foundation; either version 2.1 of the License, or (at
+your option) any later version. 
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Lesser General Public License for more details.
+
+A copy of the GNU Lesser General Public License is included in the
+Wine distribution in the file COPYING.LIB. If you did not receive this
+copy, write to the Free Software Foundation, Inc., 59 Temple Place,
+Suite 330, Boston, MA 02111-1307 USA.
Index: trunk/src/msvcrt/console.c
===================================================================
--- trunk/src/msvcrt/console.c	(revision 9633)
+++ trunk/src/msvcrt/console.c	(revision 9633)
@@ -0,0 +1,266 @@
+/*
+ * msvcrt.dll console functions
+ *
+ * Copyright 2000 Jon Griffiths
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Note: init and free don't need MT locking since they are called at DLL
+ * (de)attachment time, which is syncronised for us
+ */
+#include "msvcrt.h"
+#include "wincon.h"
+
+#include "msvcrt/conio.h"
+#include "msvcrt/malloc.h"
+#include "msvcrt/stdio.h"
+#include "mtdll.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
+
+
+
+/* MT */
+#define LOCK_CONSOLE   _mlock(_CONIO_LOCK)
+#define UNLOCK_CONSOLE _munlock(_CONIO_LOCK)
+
+static HANDLE MSVCRT_console_in = INVALID_HANDLE_VALUE;
+static HANDLE MSVCRT_console_out= INVALID_HANDLE_VALUE;
+static int __MSVCRT_console_buffer = MSVCRT_EOF;
+
+/* INTERNAL: Initialise console handles */
+void msvcrt_init_console(void)
+{
+  TRACE(":Opening console handles\n");
+
+  MSVCRT_console_in = GetStdHandle(STD_INPUT_HANDLE);
+
+  /* FIXME: Should be initialised with:
+   * CreateFileA("CONIN$", GENERIC_READ, FILE_SHARE_READ,
+   * NULL, OPEN_EXISTING, 0, (HANDLE)NULL);
+   */
+
+  MSVCRT_console_out= CreateFileA("CONOUT$", GENERIC_WRITE, FILE_SHARE_WRITE,
+				    NULL, OPEN_EXISTING, 0, (HANDLE)NULL);
+
+  if ((MSVCRT_console_in == INVALID_HANDLE_VALUE) ||
+      (MSVCRT_console_out== INVALID_HANDLE_VALUE))
+    WARN(":Console handle Initialisation FAILED!\n");
+}
+
+/* INTERNAL: Free console handles */
+void msvcrt_free_console(void)
+{
+  TRACE(":Closing console handles\n");
+  CloseHandle(MSVCRT_console_in);
+  CloseHandle(MSVCRT_console_out);
+}
+
+/*********************************************************************
+ *		_cputs (MSVCRT.@)
+ */
+int _cputs(const char* str)
+{
+  DWORD count;
+  int retval = MSVCRT_EOF;
+
+  LOCK_CONSOLE;
+  if (WriteConsoleA(MSVCRT_console_out, str, strlen(str), &count, NULL)
+      && count == 1)
+    retval = 0;
+  UNLOCK_CONSOLE;
+  return retval;
+}
+
+/*********************************************************************
+ *		_getch (MSVCRT.@)
+ */
+int _getch(void)
+{
+  int retval = MSVCRT_EOF;
+
+  LOCK_CONSOLE;
+  if (__MSVCRT_console_buffer != MSVCRT_EOF)
+  {
+    retval = __MSVCRT_console_buffer;
+    __MSVCRT_console_buffer = MSVCRT_EOF;
+  }
+  else
+  {
+    INPUT_RECORD ir;
+    DWORD count;
+    DWORD mode = 0;
+
+    GetConsoleMode(MSVCRT_console_in, &mode);
+    if(mode)
+      SetConsoleMode(MSVCRT_console_in, 0);
+
+    do {
+      if (ReadConsoleInputA(MSVCRT_console_in, &ir, 1, &count))
+      {
+        /* Only interested in ASCII chars */
+        if (ir.EventType == KEY_EVENT &&
+            ir.Event.KeyEvent.bKeyDown &&
+            ir.Event.KeyEvent.uChar.AsciiChar)
+        {
+          retval = ir.Event.KeyEvent.uChar.AsciiChar;
+          break;
+        }
+      }
+      else
+        break;
+    } while(1);
+    if (mode)
+      SetConsoleMode(MSVCRT_console_in, mode);
+  }
+  UNLOCK_CONSOLE;
+  return retval;
+}
+
+/*********************************************************************
+ *		_putch (MSVCRT.@)
+ */
+int _putch(int c)
+{
+  int retval = MSVCRT_EOF;
+  DWORD count;
+  LOCK_CONSOLE;
+  if (WriteConsoleA(MSVCRT_console_out, &c, 1, &count, NULL) && count == 1)
+    retval = c;
+  UNLOCK_CONSOLE;
+  return retval;
+}
+
+/*********************************************************************
+ *		_getche (MSVCRT.@)
+ */
+int _getche(void)
+{
+  int retval;
+  LOCK_CONSOLE;
+  retval = _getch();
+  if (retval != MSVCRT_EOF)
+    retval = _putch(retval);
+  UNLOCK_CONSOLE;
+  return retval;
+}
+
+/*********************************************************************
+ *		_cgets (MSVCRT.@)
+ */
+char* _cgets(char* str)
+{
+  char *buf = str + 2;
+  int c;
+  str[1] = 0; /* Length */
+  /* FIXME: No editing of string supported */
+  LOCK_CONSOLE;
+  do
+  {
+    if (str[1] >= str[0] || (str[1]++, c = _getche()) == MSVCRT_EOF || c == '\n')
+      break;
+    *buf++ = c & 0xff;
+  } while (1);
+  UNLOCK_CONSOLE;
+  *buf = '\0';
+  return str + 2;
+}
+
+/*********************************************************************
+ *		_ungetch (MSVCRT.@)
+ */
+int _ungetch(int c)
+{
+  int retval = MSVCRT_EOF;
+  LOCK_CONSOLE;
+  if (c != MSVCRT_EOF && __MSVCRT_console_buffer == MSVCRT_EOF)
+    retval = __MSVCRT_console_buffer = c;
+  UNLOCK_CONSOLE;
+  return retval;
+}
+
+/*********************************************************************
+ *		_kbhit (MSVCRT.@)
+ */
+int _kbhit(void)
+{
+  int retval = 0;
+
+  LOCK_CONSOLE;
+  if (__MSVCRT_console_buffer != MSVCRT_EOF)
+    retval = 1;
+  else
+  {
+    /* FIXME: There has to be a faster way than this in Win32.. */
+    INPUT_RECORD *ir = NULL;
+    DWORD count = 0, i;
+
+    GetNumberOfConsoleInputEvents(MSVCRT_console_in, &count);
+
+    if (count && (ir = MSVCRT_malloc(count * sizeof(INPUT_RECORD))) &&
+        PeekConsoleInputA(MSVCRT_console_in, ir, count, &count))
+      for(i = 0; i < count - 1; i++)
+      {
+        if (ir[i].EventType == KEY_EVENT &&
+            ir[i].Event.KeyEvent.bKeyDown &&
+            ir[i].Event.KeyEvent.uChar.AsciiChar)
+        {
+          retval = 1;
+          break;
+        }
+      }
+    if (ir)
+      MSVCRT_free(ir);
+  }
+  UNLOCK_CONSOLE;
+  return retval;
+}
+
+
+/*********************************************************************
+ *		_cprintf (MSVCRT.@)
+ */
+int _cprintf(const char* format, ...)
+{
+  char buf[2048], *mem = buf;
+  int written, resize = sizeof(buf), retval;
+  va_list valist;
+
+  va_start( valist, format );
+  /* There are two conventions for snprintf failing:
+   * Return -1 if we truncated, or
+   * Return the number of bytes that would have been written
+   * The code below handles both cases
+   */
+  while ((written = _snprintf( mem, resize, format, valist )) == -1 ||
+          written > resize)
+  {
+    resize = (written == -1 ? resize * 2 : written + 1);
+    if (mem != buf)
+      MSVCRT_free (mem);
+    if (!(mem = (char *)MSVCRT_malloc(resize)))
+      return MSVCRT_EOF;
+    va_start( valist, format );
+  }
+  va_end(valist);
+  LOCK_CONSOLE;
+  retval = _cputs( mem );
+  UNLOCK_CONSOLE;
+  if (mem != buf)
+    MSVCRT_free (mem);
+  return retval;
+}
Index: trunk/src/msvcrt/cpp.c
===================================================================
--- trunk/src/msvcrt/cpp.c	(revision 9633)
+++ trunk/src/msvcrt/cpp.c	(revision 9633)
@@ -0,0 +1,540 @@
+/*
+ * msvcrt.dll C++ objects
+ *
+ * Copyright 2000 Jon Griffiths
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "msvcrt.h"
+#include "msvcrt/eh.h"
+#include "msvcrt/stdlib.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
+
+
+typedef void (*v_table_ptr)();
+
+static v_table_ptr exception_vtable[2];
+static v_table_ptr bad_typeid_vtable[3];
+static v_table_ptr __non_rtti_object_vtable[3];
+static v_table_ptr bad_cast_vtable[3];
+static v_table_ptr type_info_vtable[1];
+
+typedef struct __exception
+{
+  v_table_ptr *vtable;
+  const char *name;
+  int do_free; /* FIXME: take string copy with char* ctor? */
+} exception;
+
+typedef struct __bad_typeid
+{
+  exception base;
+} bad_typeid;
+
+typedef struct ____non_rtti_object
+{
+  bad_typeid base;
+} __non_rtti_object;
+
+typedef struct __bad_cast
+{
+  exception base;
+} bad_cast;
+
+typedef struct __type_info
+{
+  v_table_ptr *vtable;
+  void *data;
+  char name[1];
+} type_info;
+
+typedef struct _rtti_base_descriptor
+{
+  type_info *type_descriptor;
+  int num_base_classes;
+  int base_class_offset;
+  unsigned int flags;
+} rtti_base_descriptor;
+
+typedef struct _rtti_base_array
+{
+  rtti_base_descriptor *bases[1]; /* First element is the class itself */
+} rtti_base_array;
+
+typedef struct _rtti_object_hierachy
+{
+  int unknown1;
+  int unknown2;
+  int array_len; /* Size of the array pointed to by 'base_classes' */
+  rtti_base_array *base_classes;
+} rtti_object_hierachy;
+
+typedef struct _rtti_object_locator
+{
+  int unknown1;
+  int base_class_offset;
+  unsigned int flags;
+  type_info *type_descriptor;
+  rtti_object_hierachy *type_hierachy;
+} rtti_object_locator;
+
+/******************************************************************
+ *		??0exception@@QAE@ABQBD@Z (MSVCRT.@)
+ */
+void MSVCRT_exception_ctor(exception * _this, const char ** name)
+{
+  TRACE("(%p %s)\n",_this,*name);
+  _this->vtable = exception_vtable;
+  _this->name = *name;
+  TRACE("name = %s\n",_this->name);
+  _this->do_free = 0; /* FIXME */
+}
+
+/******************************************************************
+ *		??0exception@@QAE@ABV0@@Z (MSVCRT.@)
+ */
+void MSVCRT_exception_copy_ctor(exception * _this, const exception * rhs)
+{
+  TRACE("(%p %p)\n",_this,rhs);
+  if (_this != rhs)
+    memcpy (_this, rhs, sizeof (*_this));
+  TRACE("name = %s\n",_this->name);
+}
+
+/******************************************************************
+ *		??0exception@@QAE@XZ (MSVCRT.@)
+ */
+void MSVCRT_exception_default_ctor(exception * _this)
+{
+  TRACE("(%p)\n",_this);
+  _this->vtable = exception_vtable;
+  _this->name = "";
+  _this->do_free = 0; /* FIXME */
+}
+
+/******************************************************************
+ *		??1exception@@UAE@XZ (MSVCRT.@)
+ */
+void MSVCRT_exception_dtor(exception * _this)
+{
+  TRACE("(%p)\n",_this);
+}
+
+/******************************************************************
+ *		??4exception@@QAEAAV0@ABV0@@Z (MSVCRT.@)
+ */
+exception * MSVCRT_exception_opequals(exception * _this, const exception * rhs)
+{
+  TRACE("(%p %p)\n",_this,rhs);
+  memcpy (_this, rhs, sizeof (*_this));
+  TRACE("name = %s\n",_this->name);
+  return _this;
+}
+
+/******************************************************************
+ *		??_Eexception@@UAEPAXI@Z (MSVCRT.@)
+ */
+void * MSVCRT_exception__unknown_E(exception * _this, unsigned int arg1)
+{
+  TRACE("(%p %d)\n",_this,arg1);
+  _purecall();
+  return NULL;
+}
+
+/******************************************************************
+ *		??_Gexception@@UAEPAXI@Z (MSVCRT.@)
+ */
+void * MSVCRT_exception__unknown_G(exception * _this, unsigned int arg1)
+{
+  TRACE("(%p %d)\n",_this,arg1);
+  _purecall();
+  return NULL;
+}
+
+/******************************************************************
+ *		?what@exception@@UBEPBDXZ (MSVCRT.@)
+ */
+const char * MSVCRT_what_exception(exception * _this)
+{
+  TRACE("(%p) returning %s\n",_this,_this->name);
+  return _this->name;
+}
+
+
+/******************************************************************
+ *		?set_terminate@@YAP6AXXZP6AXXZ@Z (MSVCRT.@)
+ */
+terminate_function MSVCRT_set_terminate(terminate_function func)
+{
+    MSVCRT_thread_data *data = msvcrt_get_thread_data();
+    terminate_function previous = data->terminate_handler;
+    TRACE("(%p) returning %p\n",func,previous);
+    data->terminate_handler = func;
+    return previous;
+}
+
+/******************************************************************
+ *		?set_unexpected@@YAP6AXXZP6AXXZ@Z (MSVCRT.@)
+ */
+unexpected_function MSVCRT_set_unexpected(unexpected_function func)
+{
+    MSVCRT_thread_data *data = msvcrt_get_thread_data();
+    unexpected_function previous = data->unexpected_handler;
+    TRACE("(%p) returning %p\n",func,previous);
+    data->unexpected_handler = func;
+    return previous;
+}
+
+/******************************************************************
+ *              ?_set_se_translator@@YAP6AXIPAU_EXCEPTION_POINTERS@@@ZP6AXI0@Z@Z  (MSVCRT.@)
+ */
+_se_translator_function MSVCRT__set_se_translator(_se_translator_function func)
+{
+    MSVCRT_thread_data *data = msvcrt_get_thread_data();
+    _se_translator_function previous = data->se_translator;
+    TRACE("(%p) returning %p\n",func,previous);
+    data->se_translator = func;
+    return previous;
+}
+
+/******************************************************************
+ *		?terminate@@YAXXZ (MSVCRT.@)
+ */
+void MSVCRT_terminate(void)
+{
+    MSVCRT_thread_data *data = msvcrt_get_thread_data();
+    if (data->terminate_handler) data->terminate_handler();
+    MSVCRT_abort();
+}
+
+/******************************************************************
+ *		?unexpected@@YAXXZ (MSVCRT.@)
+ */
+void MSVCRT_unexpected(void)
+{
+    MSVCRT_thread_data *data = msvcrt_get_thread_data();
+    if (data->unexpected_handler) data->unexpected_handler();
+    MSVCRT_terminate();
+}
+
+
+/******************************************************************
+ *		??0bad_typeid@@QAE@ABV0@@Z (MSVCRT.@)
+ */
+void MSVCRT_bad_typeid_copy_ctor(bad_typeid * _this, const bad_typeid * rhs)
+{
+  TRACE("(%p %p)\n",_this,rhs);
+  MSVCRT_exception_copy_ctor(&_this->base,&rhs->base);
+}
+
+/******************************************************************
+ *		??0bad_typeid@@QAE@PBD@Z (MSVCRT.@)
+ */
+void MSVCRT_bad_typeid_ctor(bad_typeid * _this, const char * name)
+{
+  TRACE("(%p %s)\n",_this,name);
+  MSVCRT_exception_ctor(&_this->base, &name);
+  _this->base.vtable = bad_typeid_vtable;
+}
+
+/******************************************************************
+ *		??1bad_typeid@@UAE@XZ (MSVCRT.@)
+ */
+void MSVCRT_bad_typeid_dtor(bad_typeid * _this)
+{
+  TRACE("(%p)\n",_this);
+  MSVCRT_exception_dtor(&_this->base);
+}
+
+/******************************************************************
+ *		??4bad_typeid@@QAEAAV0@ABV0@@Z (MSVCRT.@)
+ */
+bad_typeid * MSVCRT_bad_typeid_opequals(bad_typeid * _this, const bad_typeid * rhs)
+{
+  TRACE("(%p %p)\n",_this,rhs);
+  MSVCRT_exception_copy_ctor(&_this->base,&rhs->base);
+  return _this;
+}
+
+/******************************************************************
+ *		??0__non_rtti_object@@QAE@ABV0@@Z (MSVCRT.@)
+ */
+void MSVCRT___non_rtti_object_copy_ctor(__non_rtti_object * _this,
+                                                const __non_rtti_object * rhs)
+{
+  TRACE("(%p %p)\n",_this,rhs);
+  MSVCRT_bad_typeid_copy_ctor(&_this->base,&rhs->base);
+}
+
+/******************************************************************
+ *		??0__non_rtti_object@@QAE@PBD@Z (MSVCRT.@)
+ */
+void MSVCRT___non_rtti_object_ctor(__non_rtti_object * _this,
+                                           const char * name)
+{
+  TRACE("(%p %s)\n",_this,name);
+  MSVCRT_bad_typeid_ctor(&_this->base,name);
+  _this->base.base.vtable = __non_rtti_object_vtable;
+}
+
+/******************************************************************
+ *		??1__non_rtti_object@@UAE@XZ (MSVCRT.@)
+ */
+void MSVCRT___non_rtti_object_dtor(__non_rtti_object * _this)
+{
+  TRACE("(%p)\n",_this);
+  MSVCRT_bad_typeid_dtor(&_this->base);
+}
+
+/******************************************************************
+ *		??4__non_rtti_object@@QAEAAV0@ABV0@@Z (MSVCRT.@)
+ */
+__non_rtti_object * MSVCRT___non_rtti_object_opequals(__non_rtti_object * _this,
+                                                              const __non_rtti_object *rhs)
+{
+  TRACE("(%p %p)\n",_this,rhs);
+  memcpy (_this, rhs, sizeof (*_this));
+  TRACE("name = %s\n",_this->base.base.name);
+  return _this;
+}
+
+/******************************************************************
+ *		??_E__non_rtti_object@@UAEPAXI@Z (MSVCRT.@)
+ */
+void * MSVCRT___non_rtti_object__unknown_E(__non_rtti_object * _this, unsigned int arg1)
+{
+  TRACE("(%p %d)\n",_this,arg1);
+  _purecall();
+  return NULL;
+}
+
+/******************************************************************
+ *		??_G__non_rtti_object@@UAEPAXI@Z (MSVCRT.@)
+ */
+void * MSVCRT___non_rtti_object__unknown_G(__non_rtti_object * _this, unsigned int arg1)
+{
+  TRACE("(%p %d)\n",_this,arg1);
+  _purecall();
+  return NULL;
+}
+
+/******************************************************************
+ *		??0bad_cast@@QAE@ABQBD@Z (MSVCRT.@)
+ */
+void MSVCRT_bad_cast_ctor(bad_cast * _this, const char ** name)
+{
+  TRACE("(%p %s)\n",_this,*name);
+  MSVCRT_exception_ctor(&_this->base, name);
+  _this->base.vtable = bad_cast_vtable;
+}
+
+/******************************************************************
+ *		??0bad_cast@@QAE@ABV0@@Z (MSVCRT.@)
+ */
+void MSVCRT_bad_cast_copy_ctor(bad_cast * _this, const bad_cast * rhs)
+{
+  TRACE("(%p %p)\n",_this,rhs);
+  MSVCRT_exception_copy_ctor(&_this->base,&rhs->base);
+}
+
+/******************************************************************
+ *		??1bad_cast@@UAE@XZ (MSVCRT.@)
+ */
+void MSVCRT_bad_cast_dtor(bad_cast * _this)
+{
+  TRACE("(%p)\n",_this);
+  MSVCRT_exception_dtor(&_this->base);
+}
+
+/******************************************************************
+ *		??4bad_cast@@QAEAAV0@ABV0@@Z (MSVCRT.@)
+ */
+bad_cast * MSVCRT_bad_cast_opequals(bad_cast * _this, const bad_cast * rhs)
+{
+  TRACE("(%p %p)\n",_this,rhs);
+  MSVCRT_exception_copy_ctor(&_this->base,&rhs->base);
+  return _this;
+}
+
+/******************************************************************
+ *		??8type_info@@QBEHABV0@@Z (MSVCRT.@)
+ */
+int __stdcall MSVCRT_type_info_opequals_equals(type_info * _this, const type_info * rhs)
+{
+  TRACE("(%p %p) returning %d\n",_this,rhs,_this->name == rhs->name);
+  return _this->name == rhs->name;
+}
+
+/******************************************************************
+ *		??9type_info@@QBEHABV0@@Z (MSVCRT.@)
+ */
+int __stdcall MSVCRT_type_info_opnot_equals(type_info * _this, const type_info * rhs)
+{
+  TRACE("(%p %p) returning %d\n",_this,rhs,_this->name == rhs->name);
+  return _this->name != rhs->name;
+}
+
+/******************************************************************
+ *		??1type_info@@UAE@XZ (MSVCRT.@)
+ */
+void MSVCRT_type_info_dtor(type_info * _this)
+{
+  TRACE("(%p)\n",_this);
+  if (_this->data)
+    MSVCRT_free(_this->data);
+}
+
+/******************************************************************
+ *		?name@type_info@@QBEPBDXZ (MSVCRT.@)
+ */
+const char * __stdcall MSVCRT_type_info_name(type_info * _this)
+{
+  TRACE("(%p) returning %s\n",_this,_this->name);
+  return _this->name;
+}
+
+/******************************************************************
+ *		?raw_name@type_info@@QBEPBDXZ (MSVCRT.@)
+ */
+const char * __stdcall MSVCRT_type_info_raw_name(type_info * _this)
+{
+  TRACE("(%p) returning %s\n",_this,_this->name);
+  return _this->name;
+}
+
+
+/******************************************************************
+ *		__RTtypeid (MSVCRT.@)
+ */
+type_info* MSVCRT___RTtypeid(type_info *cppobj)
+{
+  /* Note: cppobj _isn't_ a type_info, we use that struct for its vtable ptr */
+  TRACE("(%p)\n",cppobj);
+
+  if (!IsBadReadPtr(cppobj, sizeof(void *)) &&
+      !IsBadReadPtr(cppobj->vtable - 1,sizeof(void *)) &&
+      !IsBadReadPtr((void*)cppobj->vtable[-1], sizeof(rtti_object_locator)))
+  {
+    rtti_object_locator *obj_locator = (rtti_object_locator *)cppobj->vtable[-1];
+    return obj_locator->type_descriptor;
+  }
+  /* FIXME: throw a C++ exception */
+  FIXME("Should throw(bad_typeid). Creating NULL reference, expect crash!\n");
+  return NULL;
+}
+
+/******************************************************************
+ *		__RTDynamicCast (MSVCRT.@)
+ */
+void* MSVCRT___RTDynamicCast(type_info *cppobj, int unknown,
+                             type_info *src, type_info *dst,
+                             int do_throw)
+{
+  /* Note: cppobj _isn't_ a type_info, we use that struct for its vtable ptr */
+  TRACE("(%p,%d,%p,%p,%d)\n",cppobj, unknown, src, dst, do_throw);
+
+  if (unknown)
+    FIXME("Unknown prameter is non-zero: please report\n");
+
+  /* To cast an object at runtime:
+   * 1.Find out the true type of the object from the typeinfo at vtable[-1]
+   * 2.Search for the destination type in the class heirachy
+   * 3.If destination type is found, return base object address + dest offset
+   *   Otherwise, fail the cast
+   */
+  if (!IsBadReadPtr(cppobj, sizeof(void *)) &&
+      !IsBadReadPtr(cppobj->vtable - 1,sizeof(void *)) &&
+      !IsBadReadPtr((void*)cppobj->vtable[-1], sizeof(rtti_object_locator)))
+  {
+    int count = 0;
+    rtti_object_locator *obj_locator = (rtti_object_locator *)cppobj->vtable[-1];
+    rtti_object_hierachy *obj_bases = obj_locator->type_hierachy;
+    rtti_base_descriptor **base_desc = obj_bases->base_classes->bases;
+    int src_offset = obj_locator->base_class_offset, dst_offset = -1;
+
+    while (count < obj_bases->array_len)
+    {
+      type_info *typ = (*base_desc)->type_descriptor;
+
+      if (!strcmp(typ->name, dst->name))
+      {
+        dst_offset = (*base_desc)->base_class_offset;
+        break;
+      }
+      base_desc++;
+      count++;
+    }
+    if (dst_offset >= 0)
+      return (void*)((unsigned long)cppobj - src_offset + dst_offset);
+  }
+
+  /* VC++ sets do_throw to 1 when the result of a dynamic_cast is assigned
+   * to a reference, since references cannot be NULL.
+   */
+  if (do_throw)
+    FIXME("Should throw(bad_cast). Creating NULL reference, expect crash!\n");
+  return NULL;
+}
+
+
+/******************************************************************
+ *		__RTCastToVoid (MSVCRT.@)
+ */
+void* MSVCRT___RTCastToVoid(type_info *cppobj)
+{
+  /* Note: cppobj _isn't_ a type_info, we use that struct for its vtable ptr */
+  TRACE("(%p)\n",cppobj);
+
+  /* Casts to void* simply cast to the base object */
+  if (!IsBadReadPtr(cppobj, sizeof(void *)) &&
+      !IsBadReadPtr(cppobj->vtable - 1,sizeof(void *)) &&
+      !IsBadReadPtr((void*)cppobj->vtable[-1], sizeof(rtti_object_locator)))
+  {
+    rtti_object_locator *obj_locator = (rtti_object_locator *)cppobj->vtable[-1];
+    int src_offset = obj_locator->base_class_offset;
+
+    return (void*)((unsigned long)cppobj - src_offset);
+  }
+  return NULL;
+}
+
+
+/* INTERNAL: Set up vtables
+ * FIXME:should be static, cope with versions?
+ */
+void msvcrt_init_vtables(void)
+{
+  exception_vtable[0] = MSVCRT_exception_dtor;
+  exception_vtable[1] = (void*)MSVCRT_what_exception;
+
+  bad_typeid_vtable[0] = MSVCRT_bad_typeid_dtor;
+  bad_typeid_vtable[1] = exception_vtable[1];
+  bad_typeid_vtable[2] = _purecall; /* FIXME */
+
+  __non_rtti_object_vtable[0] = MSVCRT___non_rtti_object_dtor;
+  __non_rtti_object_vtable[1] = bad_typeid_vtable[1];
+  __non_rtti_object_vtable[2] = bad_typeid_vtable[2];
+
+  bad_cast_vtable[0] = MSVCRT_bad_cast_dtor;
+  bad_cast_vtable[1] = exception_vtable[1];
+  bad_cast_vtable[2] = _purecall; /* FIXME */
+
+  type_info_vtable[0] = MSVCRT_type_info_dtor;
+
+}
Index: trunk/src/msvcrt/cppexcept.c
===================================================================
--- trunk/src/msvcrt/cppexcept.c	(revision 9633)
+++ trunk/src/msvcrt/cppexcept.c	(revision 9633)
@@ -0,0 +1,507 @@
+/*
+ * msvcrt C++ exception handling
+ *
+ * Copyright 2002 Alexandre Julliard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * NOTES
+ * A good reference is the article "How a C++ compiler implements
+ * exception handling" by Vishal Kochhar, available on
+ * www.thecodeproject.com.
+ */
+#ifdef __WIN32OS2__
+#include <emxheader.h>
+#include "winbase.h"
+#else
+#include "config.h"
+#endif
+
+#include "wine/port.h"
+
+#include "winternl.h"
+#include "msvcrt.h"
+#include "wine/exception.h"
+#include "excpt.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(seh);
+
+#define CXX_FRAME_MAGIC    0x19930520
+#define CXX_EXCEPTION      0xe06d7363
+
+typedef struct __type_info
+{
+  void *vtable;
+  void *data;
+  char name[1];
+} type_info;
+
+/* the exception frame used by CxxFrameHandler */
+typedef struct __cxx_exception_frame
+{
+    EXCEPTION_FRAME  frame;    /* the standard exception frame */
+    int              trylevel;
+    DWORD            ebp;
+} cxx_exception_frame;
+
+/* info about a single catch {} block */
+typedef struct __catchblock_info
+{
+    UINT       flags;         /* flags (see below) */
+    type_info *type_info;     /* C++ type caught by this block */
+    int        offset;        /* stack offset to copy exception object to */
+    void     (*handler)();    /* catch block handler code */
+} catchblock_info;
+#define TYPE_FLAG_CONST      1
+#define TYPE_FLAG_VOLATILE   2
+#define TYPE_FLAG_REFERENCE  8
+
+/* info about a single try {} block */
+typedef struct __tryblock_info
+{
+    int              start_level;      /* start trylevel of that block */
+    int              end_level;        /* end trylevel of that block */
+    int              catch_level;      /* initial trylevel of the catch block */
+    int              catchblock_count; /* count of catch blocks in array */
+    catchblock_info *catchblock;       /* array of catch blocks */
+} tryblock_info;
+
+/* info about the unwind handler for a given trylevel */
+typedef struct __unwind_info
+{
+    int    prev;          /* prev trylevel unwind handler, to run after this one */
+    void (*handler)();    /* unwind handler */
+} unwind_info;
+
+/* descriptor of all try blocks of a given function */
+typedef struct __cxx_function_descr
+{
+    UINT           magic;          /* must be CXX_FRAME_MAGIC */
+    UINT           unwind_count;   /* number of unwind handlers */
+    unwind_info   *unwind_table;   /* array of unwind handlers */
+    UINT           tryblock_count; /* number of try blocks */
+    tryblock_info *tryblock;       /* array of try blocks */
+    UINT           unknown[3];
+} cxx_function_descr;
+
+/* complete information about a C++ type */
+typedef struct __cxx_type_info
+{
+    UINT        flags;         /* flags (see CLASS_* flags below) */
+    type_info  *type_info;     /* C++ type info */
+    int         this_offset;   /* offset of base class this pointer from start of object */
+    int         vbase_descr;   /* offset of virtual base class descriptor */
+    int         vbase_offset;  /* offset of this pointer offset in virtual base class descriptor */
+    size_t      size;          /* object size */
+    void      (*copy_ctor)();  /* copy constructor */
+} cxx_type_info;
+#define CLASS_IS_SIMPLE_TYPE          1
+#define CLASS_HAS_VIRTUAL_BASE_CLASS  4
+
+/* table of C++ types that apply for a given object */
+typedef struct __cxx_type_info_table
+{
+    UINT           count;     /* number of types */
+    cxx_type_info *info[1];   /* array of types */
+} cxx_type_info_table;
+
+typedef DWORD (*cxx_exc_custom_handler)( PEXCEPTION_RECORD, cxx_exception_frame*,
+                                         PCONTEXT, struct __EXCEPTION_FRAME**,
+                                         cxx_function_descr*, int nested_trylevel,
+                                         EXCEPTION_FRAME *nested_frame, DWORD unknown3 );
+
+/* type information for an exception object */
+typedef struct __cxx_exception_type
+{
+    UINT                   flags;            /* TYPE_FLAG flags */
+    void                 (*destructor)();    /* exception object destructor */
+    cxx_exc_custom_handler custom_handler;   /* custom handler for this exception */
+    cxx_type_info_table   *type_info_table;  /* list of types for this exception object */
+} cxx_exception_type;
+
+
+#ifdef __i386__  /* CxxFrameHandler is not supported on non-i386 */
+
+static DWORD cxx_frame_handler( PEXCEPTION_RECORD rec, cxx_exception_frame* frame,
+                                PCONTEXT exc_context, EXCEPTION_FRAME** dispatch,
+                                cxx_function_descr *descr, EXCEPTION_FRAME* nested_frame,
+                                int nested_trylevel, CONTEXT86 *context );
+
+/* call a function with a given ebp */
+inline static void *call_ebp_func( void *func, void *ebp )
+{
+    void *ret;
+    __asm__ __volatile__ ("pushl %%ebp; movl %2,%%ebp; call *%%eax; popl %%ebp" \
+                          : "=a" (ret) : "0" (func), "g" (ebp) : "ecx", "edx", "memory" );
+    return ret;
+}
+
+/* call a copy constructor */
+inline static void call_copy_ctor( void *func, void *this, void *src, int has_vbase )
+{
+    TRACE( "calling copy ctor %p object %p src %p\n", func, this, src );
+    if (has_vbase)
+        /* in that case copy ctor takes an extra bool indicating whether to copy the base class */
+        __asm__ __volatile__("pushl $1; pushl %2; call *%0"
+                             : : "r" (func), "c" (this), "g" (src) : "eax", "edx", "memory" );
+    else
+        __asm__ __volatile__("pushl %2; call *%0"
+                             : : "r" (func), "c" (this), "g" (src) : "eax", "edx", "memory" );
+}
+
+/* call the destructor of the exception object */
+inline static void call_dtor( void *func, void *object )
+{
+    __asm__ __volatile__("call *%0" : : "r" (func), "c" (object) : "eax", "edx", "memory" );
+}
+
+
+static void dump_type( cxx_type_info *type )
+{
+    DPRINTF( "flags %x type %p", type->flags, type->type_info );
+    if (type->type_info) DPRINTF( " (%p %s)", type->type_info->data, type->type_info->name );
+    DPRINTF( " offset %d vbase %d,%d size %d copy ctor %p\n", type->this_offset,
+             type->vbase_descr, type->vbase_offset, type->size, type->copy_ctor );
+}
+
+static void dump_exception_type( cxx_exception_type *type )
+{
+    int i;
+
+    DPRINTF( "exception type:\n" );
+    DPRINTF( "flags %x destr %p handler %p type info %p\n",
+             type->flags, type->destructor, type->custom_handler, type->type_info_table );
+    for (i = 0; i < type->type_info_table->count; i++)
+    {
+        DPRINTF( "    %d: ", i );
+        dump_type( type->type_info_table->info[i] );
+    }
+}
+
+static void dump_function_descr( cxx_function_descr *descr, cxx_exception_type *info )
+{
+    int i, j;
+
+    DPRINTF( "function descr:\n" );
+    DPRINTF( "magic %x\n", descr->magic );
+    DPRINTF( "unwind table: %p %d\n", descr->unwind_table, descr->unwind_count );
+    for (i = 0; i < descr->unwind_count; i++)
+    {
+        DPRINTF( "    %d: prev %d func %p\n", i,
+                 descr->unwind_table[i].prev, descr->unwind_table[i].handler );
+    }
+    DPRINTF( "try table: %p %d\n", descr->tryblock, descr->tryblock_count );
+    for (i = 0; i < descr->tryblock_count; i++)
+    {
+        DPRINTF( "    %d: start %d end %d catchlevel %d catch %p %d\n", i,
+                 descr->tryblock[i].start_level, descr->tryblock[i].end_level,
+                 descr->tryblock[i].catch_level, descr->tryblock[i].catchblock,
+                 descr->tryblock[i].catchblock_count );
+        for (j = 0; j < descr->tryblock[i].catchblock_count; j++)
+        {
+            catchblock_info *ptr = &descr->tryblock[i].catchblock[j];
+            DPRINTF( "        %d: flags %x offset %d handler %p type %p",
+                     j, ptr->flags, ptr->offset, ptr->handler, ptr->type_info );
+            if (ptr->type_info) DPRINTF( " (%p %s)", ptr->type_info->data, ptr->type_info->name );
+            DPRINTF( "\n" );
+        }
+    }
+}
+
+/* compute the this pointer for a base class of a given type */
+static void *get_this_pointer( cxx_type_info *type, void *object )
+{
+    void *this_ptr;
+    int *offset_ptr;
+
+    if (!object) return NULL;
+    this_ptr = (char *)object + type->this_offset;
+    if (type->vbase_descr >= 0)
+    {
+        /* move this ptr to vbase descriptor */
+        this_ptr = (char *)this_ptr + type->vbase_descr;
+        /* and fetch additional offset from vbase descriptor */
+        offset_ptr = (int *)(*(char **)this_ptr + type->vbase_offset);
+        this_ptr = (char *)this_ptr + *offset_ptr;
+    }
+    return this_ptr;
+}
+
+/* check if the exception type is caught by a given catch block, and return the type that matched */
+static cxx_type_info *find_caught_type( cxx_exception_type *exc_type, catchblock_info *catchblock )
+{
+    UINT i;
+
+    for (i = 0; i < exc_type->type_info_table->count; i++)
+    {
+        cxx_type_info *type = exc_type->type_info_table->info[i];
+
+        if (!catchblock->type_info) return type;   /* catch(...) matches any type */
+        if (catchblock->type_info != type->type_info)
+        {
+            if (strcmp( catchblock->type_info->name, type->type_info->name )) continue;
+        }
+        /* type is the same, now check the flags */
+        if ((exc_type->flags & TYPE_FLAG_CONST) &&
+            !(catchblock->flags & TYPE_FLAG_CONST)) continue;
+        if ((exc_type->flags & TYPE_FLAG_VOLATILE) &&
+            !(catchblock->flags & TYPE_FLAG_VOLATILE)) continue;
+        return type;  /* it matched */
+    }
+    return NULL;
+}
+
+
+/* copy the exception object where the catch block wants it */
+static void copy_exception( void *object, cxx_exception_frame *frame,
+                            catchblock_info *catchblock, cxx_type_info *type )
+{
+    void **dest_ptr;
+
+    if (!catchblock->type_info || !catchblock->type_info->name[0]) return;
+    if (!catchblock->offset) return;
+    dest_ptr = (void **)((char *)&frame->ebp + catchblock->offset);
+
+    if (catchblock->flags & TYPE_FLAG_REFERENCE)
+    {
+        *dest_ptr = get_this_pointer( type, object );
+    }
+    else if (type->flags & CLASS_IS_SIMPLE_TYPE)
+    {
+        memmove( dest_ptr, object, type->size );
+        /* if it is a pointer, adjust it */
+        if (type->size == sizeof(void *)) *dest_ptr = get_this_pointer( type, *dest_ptr );
+    }
+    else  /* copy the object */
+    {
+        if (type->copy_ctor)
+            call_copy_ctor( type->copy_ctor, dest_ptr, get_this_pointer(type,object),
+                            (type->flags & CLASS_HAS_VIRTUAL_BASE_CLASS) );
+        else
+            memmove( dest_ptr, get_this_pointer(type,object), type->size );
+    }
+}
+
+/* unwind the local function up to a given trylevel */
+static void cxx_local_unwind( cxx_exception_frame* frame, cxx_function_descr *descr, int last_level)
+{
+    void (*handler)();
+    int trylevel = frame->trylevel;
+
+    while (trylevel != last_level)
+    {
+        if (trylevel < 0 || trylevel >= descr->unwind_count)
+        {
+            ERR( "invalid trylevel %d\n", trylevel );
+            MSVCRT_terminate();
+        }
+        handler = descr->unwind_table[trylevel].handler;
+        if (handler)
+        {
+            TRACE( "calling unwind handler %p trylevel %d last %d ebp %p\n",
+                   handler, trylevel, last_level, &frame->ebp );
+            call_ebp_func( handler, &frame->ebp );
+        }
+        trylevel = descr->unwind_table[trylevel].prev;
+    }
+    frame->trylevel = last_level;
+}
+
+/* exception frame for nested exceptions in catch block */
+struct catch_func_nested_frame
+{
+    EXCEPTION_FRAME      frame;     /* standard exception frame */
+    EXCEPTION_RECORD    *prev_rec;  /* previous record to restore in thread data */
+    cxx_exception_frame *cxx_frame; /* frame of parent exception */
+    cxx_function_descr  *descr;     /* descriptor of parent exception */
+    int                  trylevel;  /* current try level */
+};
+
+/* handler for exceptions happening while calling a catch function */
+static DWORD catch_function_nested_handler( EXCEPTION_RECORD *rec, EXCEPTION_FRAME *frame,
+                                            CONTEXT *context, EXCEPTION_FRAME **dispatcher )
+{
+    struct catch_func_nested_frame *nested_frame = (struct catch_func_nested_frame *)frame;
+
+    if (rec->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND))
+    {
+        msvcrt_get_thread_data()->exc_record = nested_frame->prev_rec;
+        return ExceptionContinueSearch;
+    }
+    else
+    {
+        TRACE( "got nested exception in catch function\n" );
+        return cxx_frame_handler( rec, nested_frame->cxx_frame, context,
+                                  NULL, nested_frame->descr, &nested_frame->frame,
+                                  nested_frame->trylevel, context );
+    }
+}
+
+/* find and call the appropriate catch block for an exception */
+/* returns the address to continue execution to after the catch block was called */
+inline static void *call_catch_block( PEXCEPTION_RECORD rec, cxx_exception_frame *frame,
+                                      cxx_function_descr *descr, int nested_trylevel,
+                                      cxx_exception_type *info )
+{
+    int i, j;
+    void *addr, *object = (void *)rec->ExceptionInformation[1];
+    struct catch_func_nested_frame nested_frame;
+    int trylevel = frame->trylevel;
+    MSVCRT_thread_data *thread_data = msvcrt_get_thread_data();
+
+    for (i = 0; i < descr->tryblock_count; i++)
+    {
+        tryblock_info *tryblock = &descr->tryblock[i];
+
+        if (trylevel < tryblock->start_level) continue;
+        if (trylevel > tryblock->end_level) continue;
+
+        /* got a try block */
+        for (j = 0; j < tryblock->catchblock_count; j++)
+        {
+            catchblock_info *catchblock = &tryblock->catchblock[j];
+            cxx_type_info *type = find_caught_type( info, catchblock );
+            if (!type) continue;
+
+            TRACE( "matched type %p in tryblock %d catchblock %d\n", type, i, j );
+
+            /* copy the exception to its destination on the stack */
+            copy_exception( object, frame, catchblock, type );
+
+            /* unwind the stack */
+            RtlUnwind( frame, 0, rec, 0 );
+            cxx_local_unwind( frame, descr, tryblock->start_level );
+            frame->trylevel = tryblock->end_level + 1;
+
+            /* call the catch block */
+            TRACE( "calling catch block %p for type %p addr %p ebp %p\n",
+                   catchblock, type, catchblock->handler, &frame->ebp );
+
+            /* setup an exception block for nested exceptions */
+
+            nested_frame.frame.Handler = catch_function_nested_handler;
+            nested_frame.prev_rec  = thread_data->exc_record;
+            nested_frame.cxx_frame = frame;
+            nested_frame.descr     = descr;
+            nested_frame.trylevel  = nested_trylevel + 1;
+
+            __wine_push_frame( &nested_frame.frame );
+            thread_data->exc_record = rec;
+            addr = call_ebp_func( catchblock->handler, &frame->ebp );
+            thread_data->exc_record = nested_frame.prev_rec;
+            __wine_pop_frame( &nested_frame.frame );
+
+            if (info->destructor) call_dtor( info->destructor, object );
+            TRACE( "done, continuing at %p\n", addr );
+            return addr;
+        }
+    }
+    return NULL;
+}
+
+
+/*********************************************************************
+ *		cxx_frame_handler
+ *
+ * Implementation of __CxxFrameHandler.
+ */
+static DWORD cxx_frame_handler( PEXCEPTION_RECORD rec, cxx_exception_frame* frame,
+                                PCONTEXT exc_context, EXCEPTION_FRAME** dispatch,
+                                cxx_function_descr *descr, EXCEPTION_FRAME* nested_frame,
+                                int nested_trylevel, CONTEXT86 *context )
+{
+    cxx_exception_type *exc_type;
+    void *next_ip;
+
+    if (descr->magic != CXX_FRAME_MAGIC)
+    {
+        ERR( "invalid frame magic %x\n", descr->magic );
+        return ExceptionContinueSearch;
+    }
+    if (rec->ExceptionFlags & (EH_UNWINDING|EH_EXIT_UNWIND))
+    {
+        if (descr->unwind_count && !nested_trylevel) cxx_local_unwind( frame, descr, -1 );
+        return ExceptionContinueSearch;
+    }
+    if (!descr->tryblock_count) return ExceptionContinueSearch;
+
+    exc_type = (cxx_exception_type *)rec->ExceptionInformation[2];
+    if (rec->ExceptionCode == CXX_EXCEPTION &&
+        rec->ExceptionInformation[0] > CXX_FRAME_MAGIC &&
+        exc_type->custom_handler)
+    {
+        return exc_type->custom_handler( rec, frame, exc_context, dispatch,
+                                         descr, nested_trylevel, nested_frame, 0 );
+    }
+
+    if (!exc_type)  /* nested exception, fetch info from original exception */
+    {
+        rec = msvcrt_get_thread_data()->exc_record;
+        exc_type = (cxx_exception_type *)rec->ExceptionInformation[2];
+    }
+
+    if (TRACE_ON(seh))
+    {
+        TRACE("handling C++ exception rec %p frame %p trylevel %d descr %p nested_frame %p\n",
+              rec, frame, frame->trylevel, descr, nested_frame );
+        dump_exception_type( exc_type );
+        dump_function_descr( descr, exc_type );
+    }
+
+    next_ip = call_catch_block( rec, frame, descr, frame->trylevel, exc_type );
+
+    if (!next_ip) return ExceptionContinueSearch;
+    rec->ExceptionFlags &= ~EH_NONCONTINUABLE;
+    context->Eip = (DWORD)next_ip;
+    context->Ebp = (DWORD)&frame->ebp;
+    context->Esp = ((DWORD*)frame)[-1];
+    return ExceptionContinueExecution;
+}
+
+/*********************************************************************
+ *		__CxxFrameHandler (MSVCRT.@)
+ */
+
+#ifdef __WIN32OS2__
+DEFINE_REGS_ENTRYPOINT_4( __CxxFrameHandler, EXC__CxxFrameHandler, PEXCEPTION_RECORD,
+                          EXCEPTION_FRAME*, PCONTEXT ,EXCEPTION_FRAME**);
+
+void EXC__CxxFrameHandler( PEXCEPTION_RECORD rec, EXCEPTION_FRAME* frame,
+#else
+void __CxxFrameHandler( PEXCEPTION_RECORD rec, EXCEPTION_FRAME* frame,
+#endif
+                        PCONTEXT exc_context, EXCEPTION_FRAME** dispatch,
+                        CONTEXT86 *context )
+{
+    cxx_function_descr *descr = (cxx_function_descr *)context->Eax;
+    context->Eax = cxx_frame_handler( rec, (cxx_exception_frame *)frame,
+                                      exc_context, dispatch, descr, NULL, 0, context );
+}
+
+#endif  /* __i386__ */
+
+/*********************************************************************
+ *		_CxxThrowException (MSVCRT.@)
+ */
+void _CxxThrowException( void *object, cxx_exception_type *type )
+{
+    DWORD args[3];
+
+    args[0] = CXX_FRAME_MAGIC;
+    args[1] = (DWORD)object;
+    args[2] = (DWORD)type;
+    RaiseException( CXX_EXCEPTION, EH_NONCONTINUABLE, 3, args );
+}
Index: trunk/src/msvcrt/ctype.c
===================================================================
--- trunk/src/msvcrt/ctype.c	(revision 9633)
+++ trunk/src/msvcrt/ctype.c	(revision 9633)
@@ -0,0 +1,256 @@
+/*
+ * msvcrt.dll ctype functions
+ *
+ * Copyright 2000 Jon Griffiths
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#include "msvcrt.h"
+
+#include "msvcrt/ctype.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
+
+/* Some abbreviations to make the following table readable */
+#define _C_ _CONTROL
+#define _S_ _SPACE
+#define _P_ _PUNCT
+#define _D_ _DIGIT
+#define _H_ _HEX
+#define _U_ _UPPER
+#define _L_ _LOWER
+
+WORD MSVCRT__ctype [257] = {
+  0, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _S_|_C_, _S_|_C_,
+  _S_|_C_, _S_|_C_, _S_|_C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_,
+  _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _S_|_BLANK,
+  _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_,
+  _P_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_,
+  _D_|_H_, _D_|_H_, _D_|_H_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _U_|_H_,
+  _U_|_H_, _U_|_H_, _U_|_H_, _U_|_H_, _U_|_H_, _U_, _U_, _U_, _U_, _U_,
+  _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_,
+  _U_, _P_, _P_, _P_, _P_, _P_, _P_, _L_|_H_, _L_|_H_, _L_|_H_, _L_|_H_,
+  _L_|_H_, _L_|_H_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_,
+  _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _P_, _P_, _P_, _P_,
+  _C_, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/* Internal: Current ctype table for locale */
+WORD MSVCRT_current_ctype[257];
+
+/* pctype is used by macros in the Win32 headers. It must point
+ * To a table of flags exactly like ctype. To allow locale
+ * changes to affect ctypes (i.e. isleadbyte), we use a second table
+ * and update its flags whenever the current locale changes.
+ */
+WORD* MSVCRT__pctype = MSVCRT_current_ctype + 1;
+
+/* mbctype data */
+extern int MSVCRT___mb_cur_max;
+extern LCID MSVCRT_current_lc_all_lcid;
+
+/*********************************************************************
+ *		__p__pctype (MSVCRT.@)
+ */
+WORD** __p__pctype(void)
+{
+  return &MSVCRT__pctype;
+}
+
+/*********************************************************************
+ *		_isctype (MSVCRT.@)
+ */
+int _isctype(int c, int type)
+{
+  if (c >= -1 && c <= 255)
+    return MSVCRT__pctype[c] & type;
+
+  if (MSVCRT___mb_cur_max != 1 && c > 0)
+  {
+    /* FIXME: Is there a faster way to do this? */
+    WORD typeInfo;
+    char convert[3], *pconv = convert;
+
+    if (MSVCRT__pctype[(UINT)c >> 8] & _LEADBYTE)
+      *pconv++ = (UINT)c >> 8;
+    *pconv++ = c & 0xff;
+    *pconv = 0;
+    /* FIXME: Use ctype LCID, not lc_all */
+    if (GetStringTypeExA(MSVCRT_current_lc_all_lcid, CT_CTYPE1,
+                         convert, convert[1] ? 2 : 1, &typeInfo))
+      return typeInfo & type;
+  }
+  return 0;
+}
+
+/*********************************************************************
+ *		isalnum (MSVCRT.@)
+ */
+int MSVCRT_isalnum(int c)
+{
+  return _isctype( c, _ALPHA | _DIGIT );
+}
+
+/*********************************************************************
+ *		isalpha (MSVCRT.@)
+ */
+int MSVCRT_isalpha(int c)
+{
+  return _isctype( c, _ALPHA );
+}
+
+/*********************************************************************
+ *		iscntrl (MSVCRT.@)
+ */
+int MSVCRT_iscntrl(int c)
+{
+  return _isctype( c, _CONTROL );
+}
+
+/*********************************************************************
+ *		isdigit (MSVCRT.@)
+ */
+int MSVCRT_isdigit(int c)
+{
+  return _isctype( c, _DIGIT );
+}
+
+/*********************************************************************
+ *		isgraph (MSVCRT.@)
+ */
+int MSVCRT_isgraph(int c)
+{
+  return _isctype( c, _ALPHA | _DIGIT | _PUNCT );
+}
+
+/*********************************************************************
+ *		isleadbyte (MSVCRT.@)
+ */
+int MSVCRT_isleadbyte(int c)
+{
+  return _isctype( c, _LEADBYTE );
+}
+
+/*********************************************************************
+ *		islower (MSVCRT.@)
+ */
+int MSVCRT_islower(int c)
+{
+  return _isctype( c, _LOWER );
+}
+
+/*********************************************************************
+ *		isprint (MSVCRT.@)
+ */
+int MSVCRT_isprint(int c)
+{
+  return _isctype( c, _ALPHA | _DIGIT | _BLANK | _PUNCT );
+}
+
+/*********************************************************************
+ *		ispunct (MSVCRT.@)
+ */
+int MSVCRT_ispunct(int c)
+{
+  return _isctype( c, _PUNCT );
+}
+
+/*********************************************************************
+ *		isspace (MSVCRT.@)
+ */
+int MSVCRT_isspace(int c)
+{
+  return _isctype( c, _SPACE );
+}
+
+/*********************************************************************
+ *		isupper (MSVCRT.@)
+ */
+int MSVCRT_isupper(int c)
+{
+  return _isctype( c, _UPPER );
+}
+
+/*********************************************************************
+ *		isxdigit (MSVCRT.@)
+ */
+int MSVCRT_isxdigit(int c)
+{
+  return _isctype( c, _HEX );
+}
+
+/*********************************************************************
+ *		__isascii (MSVCRT.@)
+ */
+int MSVCRT___isascii(int c)
+{
+  return isascii((unsigned)c);
+}
+
+/*********************************************************************
+ *		__toascii (MSVCRT.@)
+ */
+int MSVCRT___toascii(int c)
+{
+  return (unsigned)c & 0x7f;
+}
+
+/*********************************************************************
+ *		iswascii (MSVCRT.@)
+ *
+ */
+int MSVCRT_iswascii(MSVCRT_wchar_t c)
+{
+  return ((unsigned)c < 0x80);
+}
+
+/*********************************************************************
+ *		__iscsym (MSVCRT.@)
+ */
+int MSVCRT___iscsym(int c)
+{
+  return (c < 127 && (isalnum(c) || c == '_'));
+}
+
+/*********************************************************************
+ *		__iscsymf (MSVCRT.@)
+ */
+int MSVCRT___iscsymf(int c)
+{
+  return (c < 127 && (isalpha(c) || c == '_'));
+}
+
+/*********************************************************************
+ *		_toupper (MSVCRT.@)
+ */
+int MSVCRT__toupper(int c)
+{
+    return c - 0x20;  /* sic */
+}
+
+/*********************************************************************
+ *		_tolower (MSVCRT.@)
+ */
+int MSVCRT__tolower(int c)
+{
+    return c + 0x20;  /* sic */
+}
Index: trunk/src/msvcrt/data.c
===================================================================
--- trunk/src/msvcrt/data.c	(revision 9633)
+++ trunk/src/msvcrt/data.c	(revision 9633)
@@ -0,0 +1,418 @@
+/*
+ * msvcrt.dll dll data items
+ *
+ * Copyright 2000 Jon Griffiths
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#ifndef __WIN32OS2__
+#include "config.h"
+#else
+#include <emxheader.h>
+#endif
+
+#include "wine/port.h"
+
+#include <math.h>
+#include "msvcrt.h"
+
+#include "msvcrt/stdlib.h"
+#include "msvcrt/string.h"
+
+#ifndef __WIN32OS2__
+#include "wine/library.h"
+#endif
+#include "wine/unicode.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
+
+unsigned int MSVCRT___argc;
+unsigned int MSVCRT_basemajor;/* FIXME: */
+unsigned int MSVCRT_baseminor;/* FIXME: */
+unsigned int MSVCRT_baseversion; /* FIXME: */
+unsigned int MSVCRT__commode;
+unsigned int MSVCRT__fmode;
+unsigned int MSVCRT_osmajor;/* FIXME: */
+unsigned int MSVCRT_osminor;/* FIXME: */
+unsigned int MSVCRT_osmode;/* FIXME: */
+unsigned int MSVCRT__osver;
+unsigned int MSVCRT_osversion; /* FIXME: */
+unsigned int MSVCRT__winmajor;
+unsigned int MSVCRT__winminor;
+unsigned int MSVCRT__winver;
+unsigned int MSVCRT__sys_nerr; /* FIXME: not accessible from Winelib apps */
+char**       MSVCRT__sys_errlist; /* FIXME: not accessible from Winelib apps */
+unsigned int MSVCRT___setlc_active;
+unsigned int MSVCRT___unguarded_readlc_active;
+double MSVCRT__HUGE;
+char **MSVCRT___argv;
+MSVCRT_wchar_t **MSVCRT___wargv;
+char *MSVCRT__acmdln;
+MSVCRT_wchar_t *MSVCRT__wcmdln;
+char **MSVCRT__environ = 0;
+MSVCRT_wchar_t **MSVCRT__wenviron = 0;
+char **MSVCRT___initenv = 0;
+MSVCRT_wchar_t **MSVCRT___winitenv = 0;
+int MSVCRT_timezone;
+int MSVCRT_app_type;
+
+/* Get a snapshot of the current environment
+ * and construct the __p__environ array
+ *
+ * The pointer returned from GetEnvironmentStrings may get invalid when
+ * some other module cause a reallocation of the env-variable block
+ *
+ * blk is an array of pointers to environment strings, ending with a NULL
+ * and after that the actual copy of the environment strings, ending in a \0
+ */
+char ** msvcrt_SnapshotOfEnvironmentA(char **blk)
+{
+  char* environ_strings = GetEnvironmentStringsA();
+  int count = 1, len = 1, i = 0; /* keep space for the trailing NULLS */
+  char *ptr;
+
+  for (ptr = environ_strings; *ptr; ptr += strlen(ptr) + 1)
+  {
+    count++;
+    len += strlen(ptr) + 1;
+  }
+  if (blk)
+      blk = HeapReAlloc( GetProcessHeap(), 0, blk, count* sizeof(char*) + len );
+  else
+    blk = HeapAlloc(GetProcessHeap(), 0, count* sizeof(char*) + len );
+
+  if (blk)
+    {
+      if (count)
+	{
+	  memcpy(&blk[count],environ_strings,len);
+	  for (ptr = (char*) &blk[count]; *ptr; ptr += strlen(ptr) + 1)
+	    {
+	      blk[i++] = ptr;
+	    }
+	}
+      blk[i] = NULL;
+    }
+  FreeEnvironmentStringsA(environ_strings);
+  return blk;
+}
+
+MSVCRT_wchar_t ** msvcrt_SnapshotOfEnvironmentW(MSVCRT_wchar_t **wblk)
+{
+  MSVCRT_wchar_t* wenviron_strings = GetEnvironmentStringsW();
+  int count = 1, len = 1, i = 0; /* keep space for the trailing NULLS */
+  MSVCRT_wchar_t *wptr;
+
+  for (wptr = wenviron_strings; *wptr; wptr += strlenW(wptr) + 1)
+  {
+    count++;
+    len += strlenW(wptr) + 1;
+  }
+  if (wblk)
+      wblk = HeapReAlloc( GetProcessHeap(), 0, wblk, count* sizeof(MSVCRT_wchar_t*) + len * sizeof(MSVCRT_wchar_t));
+  else
+    wblk = HeapAlloc(GetProcessHeap(), 0, count* sizeof(MSVCRT_wchar_t*) + len * sizeof(MSVCRT_wchar_t));
+  if (wblk)
+    {
+      if (count)
+	{
+	  memcpy(&wblk[count],wenviron_strings,len * sizeof(MSVCRT_wchar_t));
+	  for (wptr = (MSVCRT_wchar_t*)&wblk[count]; *wptr; wptr += strlenW(wptr) + 1)
+	    {
+	      wblk[i++] = wptr;
+	    }
+	}
+      wblk[i] = NULL;
+    }
+  FreeEnvironmentStringsW(wenviron_strings);
+  return wblk;
+}
+
+typedef void (*_INITTERMFUN)(void);
+
+/***********************************************************************
+ *		__p___argc (MSVCRT.@)
+ */
+int* __p___argc(void) { return &MSVCRT___argc; }
+
+/***********************************************************************
+ *		__p__commode (MSVCRT.@)
+ */
+unsigned int* __p__commode(void) { return &MSVCRT__commode; }
+
+/***********************************************************************
+ *		__p__fmode (MSVCRT.@)
+ */
+unsigned int* __p__fmode(void) { return &MSVCRT__fmode; }
+
+/***********************************************************************
+ *		__p__osver (MSVCRT.@)
+ */
+unsigned int* __p__osver(void) { return &MSVCRT__osver; }
+
+/***********************************************************************
+ *		__p__winmajor (MSVCRT.@)
+ */
+unsigned int* __p__winmajor(void) { return &MSVCRT__winmajor; }
+
+/***********************************************************************
+ *		__p__winminor (MSVCRT.@)
+ */
+unsigned int* __p__winminor(void) { return &MSVCRT__winminor; }
+
+/***********************************************************************
+ *		__p__winver (MSVCRT.@)
+ */
+unsigned int* __p__winver(void) { return &MSVCRT__winver; }
+
+/*********************************************************************
+ *		__p__acmdln (MSVCRT.@)
+ */
+char** __p__acmdln(void) { return &MSVCRT__acmdln; }
+
+/*********************************************************************
+ *		__p__wcmdln (MSVCRT.@)
+ */
+MSVCRT_wchar_t** __p__wcmdln(void) { return &MSVCRT__wcmdln; }
+
+/*********************************************************************
+ *		__p___argv (MSVCRT.@)
+ */
+char*** __p___argv(void) { return &MSVCRT___argv; }
+
+/*********************************************************************
+ *		__p___wargv (MSVCRT.@)
+ */
+MSVCRT_wchar_t*** __p___wargv(void) { return &MSVCRT___wargv; }
+
+/*********************************************************************
+ *		__p__environ (MSVCRT.@)
+ */
+char*** __p__environ(void)
+{
+  if (!MSVCRT__environ)
+    MSVCRT__environ = msvcrt_SnapshotOfEnvironmentA(NULL);
+  return &MSVCRT__environ;
+}
+
+/*********************************************************************
+ *		__p__wenviron (MSVCRT.@)
+ */
+MSVCRT_wchar_t*** __p__wenviron(void)
+{
+  if (!MSVCRT__wenviron)
+    MSVCRT__wenviron = msvcrt_SnapshotOfEnvironmentW(NULL);
+  return &MSVCRT__wenviron;
+}
+
+/*********************************************************************
+ *		__p___initenv (MSVCRT.@)
+ */
+char*** __p___initenv(void) { return &MSVCRT___initenv; }
+
+/*********************************************************************
+ *		__p___winitenv (MSVCRT.@)
+ */
+MSVCRT_wchar_t*** __p___winitenv(void) { return &MSVCRT___winitenv; }
+
+/*********************************************************************
+ *		__p__timezone (MSVCRT.@)
+ */
+int* __p__timezone(void) { return &MSVCRT_timezone; }
+
+/* INTERNAL: Create a wide string from an ascii string */
+static MSVCRT_wchar_t *wstrdupa(const char *str)
+{
+  const size_t len = strlen(str) + 1 ;
+  MSVCRT_wchar_t *wstr = MSVCRT_malloc(len* sizeof (MSVCRT_wchar_t));
+  if (!wstr)
+    return NULL;
+   MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED,str,len,wstr,len);
+  return wstr;
+}
+
+
+#ifdef __WIN32OS2__
+
+static int __wine_main_argc = 0;
+static char **__wine_main_argv = NULL;
+static WCHAR **__wine_main_wargv = NULL;
+char *argv[255];
+
+extern char* strtok(char*,const char*);
+
+static void set_library_argv( char **incargv)
+{
+    int argc = 0;
+    WCHAR *p;
+    WCHAR **wargv;
+    char *token2 = NULL;
+    DWORD total = 0;
+
+    char argvbuf[255];
+    
+    strcpy(argvbuf,incargv[0]);
+
+    if (argvbuf[0] == '\"')   
+     token2 = strtok(argvbuf, "\"");
+    else
+     token2 = strtok(argvbuf, " ");
+
+    if (token2)
+    do
+    {
+      argv[argc] = HeapAlloc( GetProcessHeap(), 0, strlen(token2)+1);
+      strcpy(argv[argc++],token2);
+    }
+    while (token2 = strtok(NULL, " "));
+
+    argv[argc] = NULL;
+    for (argc = 0; argv[argc]; argc++)
+        total += MultiByteToWideChar( CP_ACP, 0, argv[argc], -1, NULL, 0 );
+
+    wargv = HeapAlloc( GetProcessHeap(), 0,
+                       total * sizeof(WCHAR) + (argc + 1) * sizeof(*wargv) );
+    p = (WCHAR *)(wargv + argc + 1);
+    for (argc = 0; argv[argc]; argc++)
+    {
+        DWORD len = MultiByteToWideChar( CP_ACP, 0, argv[argc], -1, p, total );
+        wargv[argc] = p;
+        p += len;
+        total -= len;
+    }
+    wargv[argc] = NULL;
+   
+    dprintf(("Num of args is %d",argc));    
+
+    __wine_main_argc  = argc;
+    __wine_main_argv  = argv;
+    __wine_main_wargv = wargv;
+}
+#endif
+
+/* INTERNAL: Since we can't rely on Winelib startup code calling w/getmainargs,
+ * we initialise data values during DLL loading. When called by a native
+ * program we simply return the data we've already initialised. This also means
+ * you can call multiple times without leaking
+ */
+void msvcrt_init_args(void)
+{
+  DWORD version;
+
+  MSVCRT__acmdln = _strdup( GetCommandLineA() );
+  MSVCRT__wcmdln = wstrdupa(MSVCRT__acmdln);
+#ifdef __WIN32OS2__
+  set_library_argv(&MSVCRT__acmdln);
+#endif
+  MSVCRT___argc = __wine_main_argc;
+  MSVCRT___argv = __wine_main_argv;
+  MSVCRT___wargv = __wine_main_wargv;
+
+  TRACE("got '%s', wide = %s argc=%d\n", MSVCRT__acmdln,
+        debugstr_w(MSVCRT__wcmdln),MSVCRT___argc);
+
+  version = GetVersion();
+  MSVCRT__osver       = version >> 16;
+  MSVCRT__winminor    = version & 0xFF;
+  MSVCRT__winmajor    = (version>>8) & 0xFF;
+  MSVCRT_baseversion = version >> 16;
+  MSVCRT__winver     = ((version >> 8) & 0xFF) + ((version & 0xFF) << 8);
+  MSVCRT_baseminor   = (version >> 16) & 0xFF;
+  MSVCRT_basemajor   = (version >> 24) & 0xFF;
+  MSVCRT_osversion   = version & 0xFFFF;
+  MSVCRT_osminor     = version & 0xFF;
+  MSVCRT_osmajor     = (version>>8) & 0xFF;
+  MSVCRT__sys_nerr   = 43;
+  MSVCRT__HUGE = HUGE_VAL;
+  MSVCRT___setlc_active = 0;
+  MSVCRT___unguarded_readlc_active = 0;
+  MSVCRT_timezone = 0;
+
+  /* FIXME: set app type for Winelib apps */
+
+  MSVCRT___initenv= msvcrt_SnapshotOfEnvironmentA(NULL);
+  MSVCRT___winitenv= msvcrt_SnapshotOfEnvironmentW(NULL);
+
+}
+
+
+/* INTERNAL: free memory used by args */
+void msvcrt_free_args(void)
+{
+  /* FIXME: more things to free */
+  if (MSVCRT___initenv) HeapFree(GetProcessHeap(), 0,MSVCRT___initenv);
+  if (MSVCRT___winitenv) HeapFree(GetProcessHeap(), 0,MSVCRT___winitenv);
+  if (MSVCRT__environ) HeapFree(GetProcessHeap(), 0,MSVCRT__environ);
+  if (MSVCRT__wenviron) HeapFree(GetProcessHeap(), 0,MSVCRT__wenviron);
+}
+
+/*********************************************************************
+ *		__getmainargs (MSVCRT.@)
+ */
+void __getmainargs(int *argc, char** *argv, char** *envp,
+                                  int expand_wildcards, int *new_mode)
+{
+  TRACE("(%p,%p,%p,%d,%p).\n", argc, argv, envp, expand_wildcards, new_mode);
+  *argc = MSVCRT___argc;
+  *argv = MSVCRT___argv;
+  *envp = MSVCRT___initenv;
+  if (new_mode)
+    MSVCRT__set_new_mode( *new_mode );
+}
+
+/*********************************************************************
+ *		__wgetmainargs (MSVCRT.@)
+ */
+void __wgetmainargs(int *argc, MSVCRT_wchar_t** *wargv, MSVCRT_wchar_t** *wenvp,
+                    int expand_wildcards, int *new_mode)
+{
+  TRACE("(%p,%p,%p,%d,%p).\n", argc, wargv, wenvp, expand_wildcards, new_mode);
+  *argc = MSVCRT___argc;
+  *wargv = MSVCRT___wargv;
+  *wenvp = MSVCRT___winitenv;
+  if (new_mode)
+    MSVCRT__set_new_mode( *new_mode );
+}
+
+/*********************************************************************
+ *		_initterm (MSVCRT.@)
+ */
+unsigned int _initterm(_INITTERMFUN *start,_INITTERMFUN *end)
+{
+  _INITTERMFUN* current = start;
+
+  TRACE("(%p,%p)\n",start,end);
+  while (current<end)
+  {
+    if (*current)
+    {
+      TRACE("Call init function %p\n",*current);
+      (**current)();
+      TRACE("returned\n");
+    }
+    current++;
+  }
+  return 0;
+}
+
+/*********************************************************************
+ *		__set_app_type (MSVCRT.@)
+ */
+void MSVCRT___set_app_type(int app_type)
+{
+  TRACE("(%d) %s application\n", app_type, app_type == 2 ? "Gui" : "Console");
+  MSVCRT_app_type = app_type;
+}
Index: trunk/src/msvcrt/dir.c
===================================================================
--- trunk/src/msvcrt/dir.c	(revision 9633)
+++ trunk/src/msvcrt/dir.c	(revision 9633)
@@ -0,0 +1,825 @@
+/*
+ * msvcrt.dll drive/directory functions
+ *
+ * Copyright 1996,1998 Marcus Meissner
+ * Copyright 1996 Jukka Iivonen
+ * Copyright 1997,2000 Uwe Bonnes
+ * Copyright 2000 Jon Griffiths
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#ifdef __WIN32OS2__
+#include <emxheader.h>
+#include <winbase.h>
+#else
+#include "config.h"
+#endif
+
+#include "wine/port.h"
+
+#include <time.h>
+#include "winternl.h"
+#include "wine/unicode.h"
+#include "msvcrt.h"
+#include "msvcrt/errno.h"
+
+#include "wine/unicode.h"
+#include "msvcrt/direct.h"
+#include "msvcrt/dos.h"
+#include "msvcrt/io.h"
+#include "msvcrt/stdlib.h"
+#include "msvcrt/string.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
+
+/* INTERNAL: Translate finddata_t to PWIN32_FIND_DATAA */
+static void msvcrt_fttofd(LPWIN32_FIND_DATAA fd, struct _finddata_t* ft)
+{
+  DWORD dw;
+
+  if (fd->dwFileAttributes == FILE_ATTRIBUTE_NORMAL)
+    ft->attrib = 0;
+  else
+    ft->attrib = fd->dwFileAttributes;
+
+  RtlTimeToSecondsSince1970( (LARGE_INTEGER *)&fd->ftCreationTime, &dw );
+  ft->time_create = dw;
+  RtlTimeToSecondsSince1970( (LARGE_INTEGER *)&fd->ftLastAccessTime, &dw );
+  ft->time_access = dw;
+  RtlTimeToSecondsSince1970( (LARGE_INTEGER *)&fd->ftLastWriteTime, &dw );
+  ft->time_write = dw;
+  ft->size = fd->nFileSizeLow;
+  strcpy(ft->name, fd->cFileName);
+}
+
+/* INTERNAL: Translate wfinddata_t to PWIN32_FIND_DATAA */
+static void msvcrt_wfttofd(LPWIN32_FIND_DATAW fd, struct _wfinddata_t* ft)
+{
+  DWORD dw;
+
+  if (fd->dwFileAttributes == FILE_ATTRIBUTE_NORMAL)
+    ft->attrib = 0;
+  else
+    ft->attrib = fd->dwFileAttributes;
+
+  RtlTimeToSecondsSince1970( (LARGE_INTEGER *)&fd->ftCreationTime, &dw );
+  ft->time_create = dw;
+  RtlTimeToSecondsSince1970( (LARGE_INTEGER *)&fd->ftLastAccessTime, &dw );
+  ft->time_access = dw;
+  RtlTimeToSecondsSince1970( (LARGE_INTEGER *)&fd->ftLastWriteTime, &dw );
+  ft->time_write = dw;
+  ft->size = fd->nFileSizeLow;
+  strcpyW(ft->name, fd->cFileName);
+}
+
+/*********************************************************************
+ *		_chdir (MSVCRT.@)
+ */
+int _chdir(const char * newdir)
+{
+  if (!SetCurrentDirectoryA(newdir))
+  {
+    MSVCRT__set_errno(newdir?GetLastError():0);
+    return -1;
+  }
+  return 0;
+}
+
+/*********************************************************************
+ *		_wchdir (MSVCRT.@)
+ */
+int _wchdir(const MSVCRT_wchar_t * newdir)
+{
+  if (!SetCurrentDirectoryW(newdir))
+  {
+    MSVCRT__set_errno(newdir?GetLastError():0);
+    return -1;
+  }
+  return 0;
+}
+
+/*********************************************************************
+ *		_chdrive (MSVCRT.@)
+ */
+int _chdrive(int newdrive)
+{
+  char buffer[3] = "A:";
+  buffer[0] += newdrive - 1;
+  if (!SetCurrentDirectoryA( buffer ))
+  {
+    MSVCRT__set_errno(GetLastError());
+    if (newdrive <= 0)
+      *MSVCRT__errno() = MSVCRT_EACCES;
+    return -1;
+  }
+  return 0;
+}
+
+/*********************************************************************
+ *		_findclose (MSVCRT.@)
+ */
+int _findclose(long hand)
+{
+  TRACE(":handle %ld\n",hand);
+  if (!FindClose((HANDLE)hand))
+  {
+    MSVCRT__set_errno(GetLastError());
+    return -1;
+  }
+  return 0;
+}
+
+/*********************************************************************
+ *		_findfirst (MSVCRT.@)
+ */
+long _findfirst(const char * fspec, struct _finddata_t* ft)
+{
+  WIN32_FIND_DATAA find_data;
+  HANDLE hfind;
+
+  hfind  = FindFirstFileA(fspec, &find_data);
+  if (hfind == INVALID_HANDLE_VALUE)
+  {
+    MSVCRT__set_errno(GetLastError());
+    return -1;
+  }
+  msvcrt_fttofd(&find_data,ft);
+  TRACE(":got handle %p\n",hfind);
+  return (long)hfind;
+}
+
+/*********************************************************************
+ *		_wfindfirst (MSVCRT.@)
+ */
+long _wfindfirst(const MSVCRT_wchar_t * fspec, struct _wfinddata_t* ft)
+{
+  WIN32_FIND_DATAW find_data;
+  HANDLE hfind;
+
+  hfind  = FindFirstFileW(fspec, &find_data);
+  if (hfind == INVALID_HANDLE_VALUE)
+  {
+    MSVCRT__set_errno(GetLastError());
+    return -1;
+  }
+  msvcrt_wfttofd(&find_data,ft);
+  TRACE(":got handle %p\n",hfind);
+  return (long)hfind;
+}
+
+/*********************************************************************
+ *		_findnext (MSVCRT.@)
+ */
+int _findnext(long hand, struct _finddata_t * ft)
+{
+  WIN32_FIND_DATAA find_data;
+
+  if (!FindNextFileA((HANDLE)hand, &find_data))
+  {
+    *MSVCRT__errno() = MSVCRT_ENOENT;
+    return -1;
+  }
+
+  msvcrt_fttofd(&find_data,ft);
+  return 0;
+}
+
+/*********************************************************************
+ *		_wfindnext (MSVCRT.@)
+ */
+int _wfindnext(long hand, struct _wfinddata_t * ft)
+{
+  WIN32_FIND_DATAW find_data;
+
+  if (!FindNextFileW((HANDLE)hand, &find_data))
+  {
+    *MSVCRT__errno() = MSVCRT_ENOENT;
+    return -1;
+  }
+
+  msvcrt_wfttofd(&find_data,ft);
+  return 0;
+}
+
+/*********************************************************************
+ *		_getcwd (MSVCRT.@)
+ */
+char* _getcwd(char * buf, int size)
+{
+  char dir[MAX_PATH];
+  int dir_len = GetCurrentDirectoryA(MAX_PATH,dir);
+
+  if (dir_len < 1)
+    return NULL; /* FIXME: Real return value untested */
+
+  if (!buf)
+  {
+    if (size < 0)
+      return _strdup(dir);
+    return msvcrt_strndup(dir,size);
+  }
+  if (dir_len >= size)
+  {
+    *MSVCRT__errno() = MSVCRT_ERANGE;
+    return NULL; /* buf too small */
+  }
+  strcpy(buf,dir);
+  return buf;
+}
+
+/*********************************************************************
+ *		_wgetcwd (MSVCRT.@)
+ */
+MSVCRT_wchar_t* _wgetcwd(MSVCRT_wchar_t * buf, int size)
+{
+  MSVCRT_wchar_t dir[MAX_PATH];
+  int dir_len = GetCurrentDirectoryW(MAX_PATH,dir);
+
+  if (dir_len < 1)
+    return NULL; /* FIXME: Real return value untested */
+
+  if (!buf)
+  {
+    if (size < 0)
+      return _wcsdup(dir);
+    return msvcrt_wstrndup(dir,size);
+  }
+  if (dir_len >= size)
+  {
+    *MSVCRT__errno() = MSVCRT_ERANGE;
+    return NULL; /* buf too small */
+  }
+  strcpyW(buf,dir);
+  return buf;
+}
+
+/*********************************************************************
+ *		_getdrive (MSVCRT.@)
+ */
+int _getdrive(void)
+{
+    char buffer[MAX_PATH];
+    if (!GetCurrentDirectoryA( sizeof(buffer), buffer )) return 0;
+    if (buffer[1] != ':') return 0;
+    return toupper(buffer[0]) - 'A' + 1;
+}
+
+/*********************************************************************
+ *		_getdcwd (MSVCRT.@)
+ */
+char* _getdcwd(int drive, char * buf, int size)
+{
+  static char* dummy;
+
+  TRACE(":drive %d(%c), size %d\n",drive, drive + 'A' - 1, size);
+
+  if (!drive || drive == _getdrive())
+    return _getcwd(buf,size); /* current */
+  else
+  {
+    char dir[MAX_PATH];
+    char drivespec[4] = {'A', ':', '\\', 0};
+    int dir_len;
+
+    drivespec[0] += drive - 1;
+    if (GetDriveTypeA(drivespec) < DRIVE_REMOVABLE)
+    {
+      *MSVCRT__errno() = MSVCRT_EACCES;
+      return NULL;
+    }
+
+    dir_len = GetFullPathNameA(drivespec,MAX_PATH,dir,&dummy);
+    if (dir_len >= size || dir_len < 1)
+    {
+      *MSVCRT__errno() = MSVCRT_ERANGE;
+      return NULL; /* buf too small */
+    }
+
+    TRACE(":returning '%s'\n", dir);
+    if (!buf)
+      return _strdup(dir); /* allocate */
+
+    strcpy(buf,dir);
+  }
+  return buf;
+}
+
+/*********************************************************************
+ *		_wgetdcwd (MSVCRT.@)
+ */
+MSVCRT_wchar_t* _wgetdcwd(int drive, MSVCRT_wchar_t * buf, int size)
+{
+  static MSVCRT_wchar_t* dummy;
+
+  TRACE(":drive %d(%c), size %d\n",drive, drive + 'A' - 1, size);
+
+  if (!drive || drive == _getdrive())
+    return _wgetcwd(buf,size); /* current */
+  else
+  {
+    MSVCRT_wchar_t dir[MAX_PATH];
+    MSVCRT_wchar_t drivespec[4] = {'A', ':', '\\', 0};
+    int dir_len;
+
+    drivespec[0] += drive - 1;
+    if (GetDriveTypeW(drivespec) < DRIVE_REMOVABLE)
+    {
+      *MSVCRT__errno() = MSVCRT_EACCES;
+      return NULL;
+    }
+
+    dir_len = GetFullPathNameW(drivespec,MAX_PATH,dir,&dummy);
+    if (dir_len >= size || dir_len < 1)
+    {
+      *MSVCRT__errno() = MSVCRT_ERANGE;
+      return NULL; /* buf too small */
+    }
+
+    TRACE(":returning %s\n", debugstr_w(dir));
+    if (!buf)
+      return _wcsdup(dir); /* allocate */
+    strcpyW(buf,dir);
+  }
+  return buf;
+}
+
+/*********************************************************************
+ *		_getdiskfree (MSVCRT.@)
+ */
+unsigned int _getdiskfree(unsigned int disk, struct _diskfree_t* d)
+{
+  char drivespec[4] = {'@', ':', '\\', 0};
+  DWORD ret[4];
+  unsigned int err;
+
+  if (disk > 26)
+    return ERROR_INVALID_PARAMETER; /* MSVCRT doesn't set errno here */
+
+  drivespec[0] += disk; /* make a drive letter */
+
+  if (GetDiskFreeSpaceA(disk==0?NULL:drivespec,ret,ret+1,ret+2,ret+3))
+  {
+    d->sectors_per_cluster = (unsigned)ret[0];
+    d->bytes_per_sector = (unsigned)ret[1];
+    d->avail_clusters = (unsigned)ret[2];
+    d->total_clusters = (unsigned)ret[3];
+    return 0;
+  }
+  err = GetLastError();
+  MSVCRT__set_errno(err);
+  return err;
+}
+
+/*********************************************************************
+ *		_mkdir (MSVCRT.@)
+ */
+int _mkdir(const char * newdir)
+{
+  if (CreateDirectoryA(newdir,NULL))
+    return 0;
+  MSVCRT__set_errno(GetLastError());
+  return -1;
+}
+
+/*********************************************************************
+ *		_wmkdir (MSVCRT.@)
+ */
+int _wmkdir(const MSVCRT_wchar_t* newdir)
+{
+  if (CreateDirectoryW(newdir,NULL))
+    return 0;
+  MSVCRT__set_errno(GetLastError());
+  return -1;
+}
+
+/*********************************************************************
+ *		_rmdir (MSVCRT.@)
+ */
+int _rmdir(const char * dir)
+{
+  if (RemoveDirectoryA(dir))
+    return 0;
+  MSVCRT__set_errno(GetLastError());
+  return -1;
+}
+
+/*********************************************************************
+ *		_wrmdir (MSVCRT.@)
+ */
+int _wrmdir(const MSVCRT_wchar_t * dir)
+{
+  if (RemoveDirectoryW(dir))
+    return 0;
+  MSVCRT__set_errno(GetLastError());
+  return -1;
+}
+
+/*********************************************************************
+ *		_wsplitpath (MSVCRT.@)
+ */
+void _wsplitpath(const MSVCRT_wchar_t *inpath, MSVCRT_wchar_t *drv, MSVCRT_wchar_t *dir,
+                 MSVCRT_wchar_t *fname, MSVCRT_wchar_t *ext )
+{
+  /* Modified PD code from 'snippets' collection. */
+  MSVCRT_wchar_t ch, *ptr, *p;
+  MSVCRT_wchar_t pathbuff[MAX_PATH],*path=pathbuff;
+
+  TRACE(":splitting path %s\n",debugstr_w(path));
+  /* FIXME: Should be an strncpyW or something */
+  strcpyW(pathbuff, inpath);
+
+  /* convert slashes to backslashes for searching */
+  for (ptr = (MSVCRT_wchar_t*)path; *ptr; ++ptr)
+    if (*ptr == '/')
+      *ptr = '\\';
+
+  /* look for drive spec */
+  if ((ptr = strchrW(path, ':')) != 0)
+  {
+    ++ptr;
+    if (drv)
+    {
+      strncpyW(drv, path, ptr - path);
+      drv[ptr - path] = 0;
+    }
+    path = ptr;
+  }
+  else if (drv)
+    *drv = 0;
+
+  /* find rightmost backslash or leftmost colon */
+  if ((ptr = strrchrW(path, '\\')) == NULL)
+    ptr = (strchrW(path, ':'));
+
+  if (!ptr)
+  {
+    ptr = (MSVCRT_wchar_t *)path; /* no path */
+    if (dir)
+      *dir = 0;
+  }
+  else
+  {
+    ++ptr; /* skip the delimiter */
+    if (dir)
+    {
+      ch = *ptr;
+      *ptr = 0;
+      strcpyW(dir, path);
+      *ptr = ch;
+    }
+  }
+
+  if ((p = strrchrW(ptr, '.')) == NULL)
+  {
+    if (fname)
+      strcpyW(fname, ptr);
+    if (ext)
+      *ext = 0;
+  }
+  else
+  {
+    *p = 0;
+    if (fname)
+      strcpyW(fname, ptr);
+    *p = '.';
+    if (ext)
+      strcpyW(ext, p);
+  }
+
+  /* Fix pathological case - Win returns ':' as part of the
+   * directory when no drive letter is given.
+   */
+  if (drv && drv[0] == ':')
+  {
+    *drv = 0;
+    if (dir)
+    {
+      pathbuff[0] = ':';
+      pathbuff[1] = 0;
+      strcatW(pathbuff,dir);
+      strcpyW(dir, pathbuff);
+    }
+  }
+}
+
+/* INTERNAL: Helper for _fullpath. Modified PD code from 'snippets'. */
+static void msvcrt_fln_fix(char *path)
+{
+  int dir_flag = 0, root_flag = 0;
+  char *r, *p, *q, *s;
+
+  /* Skip drive */
+  if (NULL == (r = strrchr(path, ':')))
+    r = path;
+  else
+    ++r;
+
+  /* Ignore leading slashes */
+  while ('\\' == *r)
+    if ('\\' == r[1])
+      strcpy(r, &r[1]);
+    else
+    {
+      root_flag = 1;
+      ++r;
+    }
+
+  p = r; /* Change "\\" to "\" */
+  while (NULL != (p = strchr(p, '\\')))
+    if ('\\' ==  p[1])
+      strcpy(p, &p[1]);
+    else
+      ++p;
+
+  while ('.' == *r) /* Scrunch leading ".\" */
+  {
+    if ('.' == r[1])
+    {
+      /* Ignore leading ".." */
+      for (p = (r += 2); *p && (*p != '\\'); ++p)
+	;
+    }
+    else
+    {
+      for (p = r + 1 ;*p && (*p != '\\'); ++p)
+	;
+    }
+    strcpy(r, p + ((*p) ? 1 : 0));
+  }
+
+  while ('\\' == path[strlen(path)-1])   /* Strip last '\\' */
+  {
+    dir_flag = 1;
+    path[strlen(path)-1] = '\0';
+  }
+
+  s = r;
+
+  /* Look for "\." in path */
+
+  while (NULL != (p = strstr(s, "\\.")))
+  {
+    if ('.' == p[2])
+    {
+      /* Execute this section if ".." found */
+      q = p - 1;
+      while (q > r)           /* Backup one level           */
+      {
+	if (*q == '\\')
+	  break;
+	--q;
+      }
+      if (q > r)
+      {
+	strcpy(q, p + 3);
+	s = q;
+      }
+      else if ('.' != *q)
+      {
+	strcpy(q + ((*q == '\\') ? 1 : 0),
+	       p + 3 + ((*(p + 3)) ? 1 : 0));
+	s = q;
+      }
+      else  s = ++p;
+    }
+    else
+    {
+      /* Execute this section if "." found */
+      q = p + 2;
+      for ( ;*q && (*q != '\\'); ++q)
+	;
+      strcpy (p, q);
+    }
+  }
+
+  if (root_flag)  /* Embedded ".." could have bubbled up to root  */
+  {
+    for (p = r; *p && ('.' == *p || '\\' == *p); ++p)
+      ;
+    if (r != p)
+      strcpy(r, p);
+  }
+
+  if (dir_flag)
+    strcat(path, "\\");
+}
+
+/*********************************************************************
+ *		_fullpath (MSVCRT.@)
+ */
+char *_fullpath(char * absPath, const char* relPath, unsigned int size)
+{
+  char drive[5],dir[MAX_PATH],file[MAX_PATH],ext[MAX_PATH];
+  char res[MAX_PATH];
+  size_t len;
+
+  res[0] = '\0';
+
+  if (!relPath || !*relPath)
+    return _getcwd(absPath, size);
+
+  if (size < 4)
+  {
+    *MSVCRT__errno() = MSVCRT_ERANGE;
+    return NULL;
+  }
+
+  TRACE(":resolving relative path '%s'\n",relPath);
+
+  _splitpath(relPath, drive, dir, file, ext);
+
+  /* Get Directory and drive into 'res' */
+  if (!dir[0] || (dir[0] != '/' && dir[0] != '\\'))
+  {
+    /* Relative or no directory given */
+    _getdcwd(drive[0] ? toupper(drive[0]) - 'A' + 1 :  0, res, MAX_PATH);
+    strcat(res,"\\");
+    if (dir[0])
+      strcat(res,dir);
+    if (drive[0])
+      res[0] = drive[0]; /* If given a drive, preserve the letter case */
+  }
+  else
+  {
+    strcpy(res,drive);
+    strcat(res,dir);
+  }
+
+  strcat(res,"\\");
+  strcat(res, file);
+  strcat(res, ext);
+  msvcrt_fln_fix(res);
+
+  len = strlen(res);
+  if (len >= MAX_PATH || len >= (size_t)size)
+    return NULL; /* FIXME: errno? */
+
+  if (!absPath)
+    return _strdup(res);
+  strcpy(absPath,res);
+  return absPath;
+}
+
+/*********************************************************************
+ *		_makepath (MSVCRT.@)
+ */
+VOID _makepath(char * path, const char * drive,
+                              const char *directory, const char * filename,
+                              const char * extension )
+{
+    char ch;
+    TRACE("got %s %s %s %s\n", drive, directory,
+          filename, extension);
+
+    if ( !path )
+        return;
+
+    path[0] = 0;
+    if (drive && drive[0])
+    {
+        path[0] = drive[0];
+        path[1] = ':';
+        path[2] = 0;
+    }
+    if (directory && directory[0])
+    {
+        strcat(path, directory);
+        ch = path[strlen(path)-1];
+        if (ch != '/' && ch != '\\')
+            strcat(path,"\\");
+    }
+    if (filename && filename[0])
+    {
+        strcat(path, filename);
+        if (extension && extension[0])
+        {
+            if ( extension[0] != '.' )
+                strcat(path,".");
+            strcat(path,extension);
+        }
+    }
+
+    TRACE("returning %s\n",path);
+}
+
+/*********************************************************************
+ *		_wmakepath (MSVCRT.@)
+ */
+VOID _wmakepath(MSVCRT_wchar_t *path, const MSVCRT_wchar_t *drive, const MSVCRT_wchar_t *directory,
+		const MSVCRT_wchar_t *filename, const MSVCRT_wchar_t *extension)
+{
+    MSVCRT_wchar_t ch;
+    TRACE("%s %s %s %s\n", debugstr_w(drive), debugstr_w(directory),
+	  debugstr_w(filename), debugstr_w(extension));
+
+    if ( !path )
+        return;
+
+    path[0] = 0;
+    if (drive && drive[0])
+    {
+        path[0] = drive[0];
+        path[1] = ':';
+        path[2] = 0;
+    }
+    if (directory && directory[0])
+    {
+        strcatW(path, directory);
+        ch = path[strlenW(path) - 1];
+        if (ch != '/' && ch != '\\')
+	{
+	    static const MSVCRT_wchar_t backslashW[] = {'\\',0};
+            strcatW(path, backslashW);
+	}
+    }
+    if (filename && filename[0])
+    {
+        strcatW(path, filename);
+        if (extension && extension[0])
+        {
+            if ( extension[0] != '.' )
+	    {
+		static const MSVCRT_wchar_t dotW[] = {'.',0};
+                strcatW(path, dotW);
+	    }
+            strcatW(path, extension);
+        }
+    }
+
+    TRACE("returning %s\n", debugstr_w(path));
+}
+
+/*********************************************************************
+ *		_searchenv (MSVCRT.@)
+ */
+void _searchenv(const char* file, const char* env, char *buf)
+{
+  char*envVal, *penv;
+  char curPath[MAX_PATH];
+
+  *buf = '\0';
+
+  /* Try CWD first */
+  if (GetFileAttributesA( file ) != 0xFFFFFFFF)
+  {
+    GetFullPathNameA( file, MAX_PATH, buf, NULL );
+    /* Sigh. This error is *always* set, regardless of success */
+    MSVCRT__set_errno(ERROR_FILE_NOT_FOUND);
+    return;
+  }
+
+  /* Search given environment variable */
+  envVal = MSVCRT_getenv(env);
+  if (!envVal)
+  {
+    MSVCRT__set_errno(ERROR_FILE_NOT_FOUND);
+    return;
+  }
+
+  penv = envVal;
+  TRACE(":searching for %s in paths %s\n", file, envVal);
+
+  do
+  {
+    char *end = penv;
+
+    while(*end && *end != ';') end++; /* Find end of next path */
+    if (penv == end || !*penv)
+    {
+      MSVCRT__set_errno(ERROR_FILE_NOT_FOUND);
+      return;
+    }
+    strncpy(curPath, penv, end - penv);
+    if (curPath[end - penv] != '/' || curPath[end - penv] != '\\')
+    {
+      curPath[end - penv] = '\\';
+      curPath[end - penv + 1] = '\0';
+    }
+    else
+      curPath[end - penv] = '\0';
+
+    strcat(curPath, file);
+    TRACE("Checking for file %s\n", curPath);
+    if (GetFileAttributesA( curPath ) != 0xFFFFFFFF)
+    {
+      strcpy(buf, curPath);
+      MSVCRT__set_errno(ERROR_FILE_NOT_FOUND);
+      return; /* Found */
+    }
+    penv = *end ? end + 1 : end;
+  } while(1);
+}
Index: trunk/src/msvcrt/emxheader.h
===================================================================
--- trunk/src/msvcrt/emxheader.h	(revision 9633)
+++ trunk/src/msvcrt/emxheader.h	(revision 9633)
@@ -0,0 +1,88 @@
+#ifndef _EMXSTDDEF_H
+#define _EMXSTDDEF_H
+
+#if !defined (_SIZE_T)
+#define _SIZE_T
+typedef unsigned long size_t;
+#endif
+
+   #ifndef __time_t
+      #define __time_t
+      typedef long time_t;
+   #endif
+
+   #ifndef __tm_t
+      #define __tm_t
+      struct tm
+         {
+         int tm_sec;      /* seconds after the minute [0-61]        */
+         int tm_min;      /* minutes after the hour [0-59]          */
+         int tm_hour;     /* hours since midnight [0-23]            */
+         int tm_mday;     /* day of the month [1-31]                */
+         int tm_mon;      /* months since January [0-11]            */
+         int tm_year;     /* years since 1900                       */
+         int tm_wday;     /* days since Sunday [0-6]                */
+         int tm_yday;     /* days since January 1 [0-365]           */
+         int tm_isdst;    /* Daylight Saving Time flag              */
+      };
+   #endif
+
+   typedef struct _div_t
+       {
+       int quot;        /* quotient of integer division       */
+       int rem;         /* remainder of integer division      */
+       } div_t;
+
+   typedef struct _ldiv_t
+       {
+       long int quot;   /* quotient of long integer division  */
+       long int rem;    /* remainder of long integer division */
+       } ldiv_t;
+
+    div_t    div( int, int );
+    ldiv_t   ldiv( long int, long int );
+
+#define STDIN_FILENO  0
+#define STDOUT_FILENO 1
+#define STDERR_FILENO 2
+
+/* more file._flag flags, but these conflict with Unix */
+#define _IOFBF    0x0000
+#define _IONBF    0x0004
+#define _IOLBF    0x0040
+
+#define EOF       (-1)
+#define FILENAME_MAX 260
+#define FOPEN_MAX 20
+#define L_tmpnam  260
+
+#define BUFSIZ    512
+
+#ifndef SEEK_SET
+#define SEEK_SET  0
+#define SEEK_CUR  1
+#define SEEK_END  2
+#endif
+
+#define __ASM_NAME(name) "_" name
+#define __ASM_FUNC(name) ".type " __ASM_NAME(name) ",@function"
+
+#ifdef __GNUC__
+# define __ASM_GLOBAL_FUNC(name,code) \
+      __asm__( ".align 4\n\t" \
+               ".globl " __ASM_NAME(#name) "\n\t" \
+               __ASM_FUNC(#name) "\n" \
+               __ASM_NAME(#name) ":\n\t" \
+               code );
+#else  /* __GNUC__ */
+# define __ASM_GLOBAL_FUNC(name,code) \
+      void __asm_dummy_##name(void) { \
+          asm( ".align 4\n\t" \
+               ".globl " __ASM_NAME(#name) "\n\t" \
+               __ASM_FUNC(#name) "\n" \
+               __ASM_NAME(#name) ":\n\t" \
+               code ); \
+      }
+#endif  /* __GNUC__ */
+
+#endif
Index: trunk/src/msvcrt/environ.c
===================================================================
--- trunk/src/msvcrt/environ.c	(revision 9633)
+++ trunk/src/msvcrt/environ.c	(revision 9633)
@@ -0,0 +1,156 @@
+/*
+ * msvcrt.dll environment functions
+ *
+ * Copyright 1996,1998 Marcus Meissner
+ * Copyright 1996 Jukka Iivonen
+ * Copyright 1997,2000 Uwe Bonnes
+ * Copyright 2000 Jon Griffiths
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#ifdef __WIN32OS2__
+#include <winbase.h>
+#endif
+
+#include "wine/unicode.h"
+#include "msvcrt.h"
+
+#include "msvcrt/stdlib.h"
+
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
+
+/*********************************************************************
+ *		getenv (MSVCRT.@)
+ */
+char *MSVCRT_getenv(const char *name)
+{
+  char *environ = GetEnvironmentStringsA();
+  char *pp,*pos = NULL;
+  unsigned int length=strlen(name);
+
+  for (pp = environ; (*pp); pp = pp + strlen(pp) +1)
+  {
+      pos =strchr(pp,'=');
+      if ((pos) && ((pos - pp) == length))
+      {
+          if (!strncasecmp(pp,name,length)) break;
+      }
+  }
+  if ((*pp)&& (pos))
+  {
+     pp = pos+1;
+     TRACE("got %s\n",pp);
+  }
+  else
+    pp = 0;
+  FreeEnvironmentStringsA( environ );
+  return pp;
+}
+
+/*********************************************************************
+ *		_wgetenv (MSVCRT.@)
+ */
+MSVCRT_wchar_t *_wgetenv(const MSVCRT_wchar_t *name)
+{
+  MSVCRT_wchar_t* environ = GetEnvironmentStringsW();
+  MSVCRT_wchar_t* pp,*pos = NULL;
+  unsigned int length=strlenW(name);
+
+  for (pp = environ; (*pp); pp = pp + strlenW(pp) + 1)
+  {
+      pos = strchrW(pp,'=');
+      if ((pos) && ((pos - pp) == length))
+      {
+          if (!strncmpiW(pp,name,length))
+          {
+              pp = pos+1;
+              TRACE("got %s\n",debugstr_w(pp));
+              /* can't free pointer since we are returning it */
+              /* should probably use MSVCRT_wenviron instead */
+              FIXME( "memory leak\n" );
+              return pp;
+          }
+      }
+  }
+  FreeEnvironmentStringsW( environ );
+  return NULL;
+}
+
+/*********************************************************************
+ *		_putenv (MSVCRT.@)
+ */
+int _putenv(const char *str)
+{
+ char name[256], value[512];
+ char *dst = name;
+ int ret;
+
+ TRACE("%s\n", str);
+
+ if (!str)
+   return -1;
+ while (*str && *str != '=')
+  *dst++ = *str++;
+ if (!*str++)
+   return -1;
+ *dst = '\0';
+ dst = value;
+ while (*str)
+  *dst++ = *str++;
+ *dst = '\0';
+
+ ret = !SetEnvironmentVariableA(name, value[0] ? value : NULL);
+ /* Update the __p__environ array only when already initialized */
+ if (MSVCRT__environ)
+   MSVCRT__environ = msvcrt_SnapshotOfEnvironmentA(MSVCRT__environ);
+ if (MSVCRT__wenviron)
+   MSVCRT__wenviron = msvcrt_SnapshotOfEnvironmentW(MSVCRT__wenviron);
+ return ret;
+}
+
+/*********************************************************************
+ *		_wputenv (MSVCRT.@)
+ */
+int _wputenv(const MSVCRT_wchar_t *str)
+{
+ MSVCRT_wchar_t name[256], value[512];
+ MSVCRT_wchar_t *dst = name;
+ int ret;
+
+ TRACE("%s\n", debugstr_w(str));
+
+ if (!str)
+   return -1;
+ while (*str && *str != '=')
+  *dst++ = *str++;
+ if (!*str++)
+   return -1;
+ *dst = 0;
+ dst = value;
+ while (*str)
+  *dst++ = *str++;
+ *dst = 0;
+
+ ret = !SetEnvironmentVariableW(name, value[0] ? value : NULL);
+ /* Update the __p__environ array only when already initialized */
+ if (MSVCRT__environ)
+   MSVCRT__environ = msvcrt_SnapshotOfEnvironmentA(MSVCRT__environ);
+ if (MSVCRT__wenviron)
+   MSVCRT__wenviron = msvcrt_SnapshotOfEnvironmentW(MSVCRT__wenviron);
+ return ret;
+}
Index: trunk/src/msvcrt/errno.c
===================================================================
--- trunk/src/msvcrt/errno.c	(revision 9633)
+++ trunk/src/msvcrt/errno.c	(revision 9633)
@@ -0,0 +1,137 @@
+/*
+ * msvcrt.dll errno functions
+ *
+ * Copyright 2000 Jon Griffiths
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "msvcrt.h"
+#include "msvcrt/errno.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#include "msvcrt/conio.h"
+#include "msvcrt/stdlib.h"
+#include "msvcrt/string.h"
+
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
+
+
+/* INTERNAL: Set the crt and dos errno's from the OS error given. */
+void MSVCRT__set_errno(int err)
+{
+  int *errno = MSVCRT__errno();
+  unsigned long *doserrno = __doserrno();
+
+  *doserrno = err;
+
+  switch(err)
+  {
+#define ERR_CASE(oserr) case oserr:
+#define ERR_MAPS(oserr,crterr) case oserr:*errno = crterr;break;
+    ERR_CASE(ERROR_ACCESS_DENIED)
+    ERR_CASE(ERROR_NETWORK_ACCESS_DENIED)
+    ERR_CASE(ERROR_CANNOT_MAKE)
+    ERR_CASE(ERROR_SEEK_ON_DEVICE)
+    ERR_CASE(ERROR_LOCK_FAILED)
+    ERR_CASE(ERROR_FAIL_I24)
+    ERR_CASE(ERROR_CURRENT_DIRECTORY)
+    ERR_CASE(ERROR_DRIVE_LOCKED)
+    ERR_CASE(ERROR_NOT_LOCKED)
+    ERR_CASE(ERROR_INVALID_ACCESS)
+    ERR_MAPS(ERROR_LOCK_VIOLATION,       MSVCRT_EACCES);
+    ERR_CASE(ERROR_FILE_NOT_FOUND)
+    ERR_CASE(ERROR_NO_MORE_FILES)
+    ERR_CASE(ERROR_BAD_PATHNAME)
+    ERR_CASE(ERROR_BAD_NETPATH)
+    ERR_CASE(ERROR_INVALID_DRIVE)
+    ERR_CASE(ERROR_BAD_NET_NAME)
+    ERR_CASE(ERROR_FILENAME_EXCED_RANGE)
+    ERR_MAPS(ERROR_PATH_NOT_FOUND,       MSVCRT_ENOENT);
+    ERR_MAPS(ERROR_IO_DEVICE,            MSVCRT_EIO);
+    ERR_MAPS(ERROR_BAD_FORMAT,           MSVCRT_ENOEXEC);
+    ERR_MAPS(ERROR_INVALID_HANDLE,       MSVCRT_EBADF);
+    ERR_CASE(ERROR_OUTOFMEMORY)
+    ERR_CASE(ERROR_INVALID_BLOCK)
+    ERR_CASE(ERROR_NOT_ENOUGH_QUOTA);
+    ERR_MAPS(ERROR_ARENA_TRASHED,        MSVCRT_ENOMEM);
+    ERR_MAPS(ERROR_BUSY,                 MSVCRT_EBUSY);
+    ERR_CASE(ERROR_ALREADY_EXISTS)
+    ERR_MAPS(ERROR_FILE_EXISTS,          MSVCRT_EEXIST);
+    ERR_MAPS(ERROR_BAD_DEVICE,           MSVCRT_ENODEV);
+    ERR_MAPS(ERROR_TOO_MANY_OPEN_FILES,  MSVCRT_EMFILE);
+    ERR_MAPS(ERROR_DISK_FULL,            MSVCRT_ENOSPC);
+    ERR_MAPS(ERROR_BROKEN_PIPE,          MSVCRT_EPIPE);
+    ERR_MAPS(ERROR_POSSIBLE_DEADLOCK,    MSVCRT_EDEADLK);
+    ERR_MAPS(ERROR_DIR_NOT_EMPTY,        MSVCRT_ENOTEMPTY);
+    ERR_MAPS(ERROR_BAD_ENVIRONMENT,      MSVCRT_E2BIG);
+    ERR_CASE(ERROR_WAIT_NO_CHILDREN)
+    ERR_MAPS(ERROR_CHILD_NOT_COMPLETE,   MSVCRT_ECHILD);
+    ERR_CASE(ERROR_NO_PROC_SLOTS)
+    ERR_CASE(ERROR_MAX_THRDS_REACHED)
+    ERR_MAPS(ERROR_NESTING_NOT_ALLOWED,  MSVCRT_EAGAIN);
+  default:
+    /*  Remaining cases map to EINVAL */
+    /* FIXME: may be missing some errors above */
+    *errno = MSVCRT_EINVAL;
+  }
+}
+
+/*********************************************************************
+ *		_errno (MSVCRT.@)
+ */
+int* MSVCRT__errno(void)
+{
+    return &msvcrt_get_thread_data()->errno;
+}
+
+/*********************************************************************
+ *		__doserrno (MSVCRT.@)
+ */
+unsigned long* __doserrno(void)
+{
+    return &msvcrt_get_thread_data()->doserrno;
+}
+
+/*********************************************************************
+ *		strerror (MSVCRT.@)
+ */
+char* MSVCRT_strerror(int err)
+{
+  return strerror(err); /* FIXME */
+}
+
+/**********************************************************************
+ *		_strerror	(MSVCRT.@)
+ */
+char* _strerror(const char* err)
+{
+  static char strerrbuff[256]; /* FIXME: Per thread, nprintf */
+  sprintf(strerrbuff,"%s: %s\n",err,MSVCRT_strerror(msvcrt_get_thread_data()->errno));
+  return strerrbuff;
+}
+
+/*********************************************************************
+ *		perror (MSVCRT.@)
+ */
+void MSVCRT_perror(const char* str)
+{
+  _cprintf("%s: %s\n",str,MSVCRT_strerror(msvcrt_get_thread_data()->errno));
+}
Index: trunk/src/msvcrt/except.c
===================================================================
--- trunk/src/msvcrt/except.c	(revision 9633)
+++ trunk/src/msvcrt/except.c	(revision 9633)
@@ -0,0 +1,413 @@
+/*
+ * msvcrt.dll exception handling
+ *
+ * Copyright 2000 Jon Griffiths
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * NOTES:
+ *
+ * See http://www.microsoft.com/msj/0197/exception/exception.htm,
+ * but don't believe all of it.
+ *
+ * FIXME: Incomplete support for nested exceptions/try block cleanup.
+ */
+
+#ifdef __WIN32OS2__
+#include <emxheader.h>
+#include <winbase.h>
+#else
+#include "config.h"
+#endif
+
+#include "wine/port.h"
+
+#include "winternl.h"
+#include "wine/exception.h"
+#include "thread.h"
+#include "msvcrt.h"
+
+#include "msvcrt/setjmp.h"
+#include "excpt.h"
+
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
+
+typedef void (*MSVCRT_sig_handler_func)(void);
+
+/* VC++ extensions to Win32 SEH */
+typedef struct _SCOPETABLE
+{
+  int previousTryLevel;
+  int (*lpfnFilter)(PEXCEPTION_POINTERS);
+  int (*lpfnHandler)(void);
+} SCOPETABLE, *PSCOPETABLE;
+
+typedef struct _MSVCRT_EXCEPTION_FRAME
+{
+  EXCEPTION_FRAME *prev;
+  void (*handler)(PEXCEPTION_RECORD, PEXCEPTION_FRAME,
+                  PCONTEXT, PEXCEPTION_RECORD);
+  PSCOPETABLE scopetable;
+  int trylevel;
+  int _ebp;
+  PEXCEPTION_POINTERS xpointers;
+} MSVCRT_EXCEPTION_FRAME;
+
+#define TRYLEVEL_END (-1) /* End of trylevel list */
+
+#if defined(__GNUC__) && defined(__i386__)
+inline static void call_finally_block( void *code_block, void *base_ptr )
+{
+    __asm__ __volatile__ ("movl %1,%%ebp; call *%%eax" \
+                          : : "a" (code_block), "g" (base_ptr));
+}
+
+inline static DWORD call_filter( void *func, void *arg, void *ebp )
+{
+    DWORD ret;
+    __asm__ __volatile__ ("pushl %%ebp; pushl %3; movl %2,%%ebp; call *%%eax; popl %%ebp; popl %%ebp"
+                          : "=a" (ret)
+                          : "0" (func), "g" (ebp), "g" (arg)
+                          : "ecx", "edx", "memory" );
+    return ret;
+}
+#endif
+
+static DWORD MSVCRT_nested_handler(PEXCEPTION_RECORD rec,
+                                   struct __EXCEPTION_FRAME* frame,
+                                   PCONTEXT context WINE_UNUSED,
+                                   struct __EXCEPTION_FRAME** dispatch)
+{
+  if (rec->ExceptionFlags & 0x6)
+    return ExceptionContinueSearch;
+  *dispatch = frame;
+  return ExceptionCollidedUnwind;
+}
+
+
+/*********************************************************************
+ *		_XcptFilter (MSVCRT.@)
+ */
+int _XcptFilter(int ex, PEXCEPTION_POINTERS ptr)
+{
+  FIXME("(%d,%p)semi-stub\n", ex, ptr);
+  return UnhandledExceptionFilter(ptr);
+}
+
+/*********************************************************************
+ *		_EH_prolog (MSVCRT.@)
+ */
+#ifdef __i386__
+/* Provided for VC++ binary compatability only */
+__ASM_GLOBAL_FUNC(_EH_prolog,
+                  "pushl $-1\n\t"
+                  "pushl %eax\n\t"
+                  "pushl %fs:0\n\t"
+                  "movl  %esp, %fs:0\n\t"
+                  "movl  12(%esp), %eax\n\t"
+                  "movl  %ebp, 12(%esp)\n\t"
+                  "leal  12(%esp), %ebp\n\t"
+                  "pushl %eax\n\t"
+                  "ret");
+#endif
+
+/*******************************************************************
+ *		_global_unwind2 (MSVCRT.@)
+ */
+void _global_unwind2(PEXCEPTION_FRAME frame)
+{
+    TRACE("(%p)\n",frame);
+    RtlUnwind( frame, 0, 0, 0 );
+}
+
+/*******************************************************************
+ *		_local_unwind2 (MSVCRT.@)
+ */
+void _local_unwind2(MSVCRT_EXCEPTION_FRAME* frame, int trylevel)
+{
+  MSVCRT_EXCEPTION_FRAME *curframe = frame;
+  EXCEPTION_FRAME reg;
+
+  TRACE("(%p,%d,%d)\n",frame, frame->trylevel, trylevel);
+
+  /* Register a handler in case of a nested exception */
+  reg.Handler = (PEXCEPTION_HANDLER)MSVCRT_nested_handler;
+  reg.Prev = NtCurrentTeb()->except;
+  __wine_push_frame(&reg);
+
+  while (frame->trylevel != TRYLEVEL_END && frame->trylevel != trylevel)
+  {
+    int curtrylevel = frame->scopetable[frame->trylevel].previousTryLevel;
+    curframe = frame;
+    curframe->trylevel = curtrylevel;
+    if (!frame->scopetable[curtrylevel].lpfnFilter)
+    {
+      ERR("__try block cleanup not implemented - expect crash!\n");
+      /* FIXME: Remove current frame, set ebp, call
+       * frame->scopetable[curtrylevel].lpfnHandler()
+       */
+    }
+  }
+  __wine_pop_frame(&reg);
+  TRACE("unwound OK\n");
+}
+
+/*********************************************************************
+ *		_except_handler2 (MSVCRT.@)
+ */
+int _except_handler2(PEXCEPTION_RECORD rec,
+                     PEXCEPTION_FRAME frame,
+                     PCONTEXT context,
+                     PEXCEPTION_FRAME* dispatcher)
+{
+  FIXME("exception %lx flags=%lx at %p handler=%p %p %p stub\n",
+        rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress,
+        frame->Handler, context, dispatcher);
+  return ExceptionContinueSearch;
+}
+
+/*********************************************************************
+ *		_except_handler3 (MSVCRT.@)
+ */
+int _except_handler3(PEXCEPTION_RECORD rec,
+                     MSVCRT_EXCEPTION_FRAME* frame,
+                     PCONTEXT context, void* dispatcher)
+{
+#if defined(__GNUC__) && defined(__i386__)
+  long retval;
+  int trylevel;
+  EXCEPTION_POINTERS exceptPtrs;
+  PSCOPETABLE pScopeTable;
+
+  TRACE("exception %lx flags=%lx at %p handler=%p %p %p semi-stub\n",
+        rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress,
+        frame->handler, context, dispatcher);
+
+  __asm__ __volatile__ ("cld");
+
+  if (rec->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND))
+  {
+    /* Unwinding the current frame */
+     _local_unwind2(frame, TRYLEVEL_END);
+    return ExceptionContinueSearch;
+  }
+  else
+  {
+    /* Hunting for handler */
+    exceptPtrs.ExceptionRecord = rec;
+    exceptPtrs.ContextRecord = context;
+    *((DWORD *)frame-1) = (DWORD)&exceptPtrs;
+    trylevel = frame->trylevel;
+    pScopeTable = frame->scopetable;
+
+    while (trylevel != TRYLEVEL_END)
+    {
+      if (pScopeTable[trylevel].lpfnFilter)
+      {
+        TRACE("filter = %p\n", pScopeTable[trylevel].lpfnFilter);
+
+        retval = call_filter( pScopeTable[trylevel].lpfnFilter, &exceptPtrs, &frame->_ebp );
+
+        TRACE("filter returned %s\n", retval == EXCEPTION_CONTINUE_EXECUTION ?
+              "CONTINUE_EXECUTION" : retval == EXCEPTION_EXECUTE_HANDLER ?
+              "EXECUTE_HANDLER" : "CONTINUE_SEARCH");
+
+        if (retval == EXCEPTION_CONTINUE_EXECUTION)
+          return ExceptionContinueExecution;
+
+        if (retval == EXCEPTION_EXECUTE_HANDLER)
+        {
+          /* Unwind all higher frames, this one will handle the exception */
+          _global_unwind2((PEXCEPTION_FRAME)frame);
+          _local_unwind2(frame, trylevel);
+
+          /* Set our trylevel to the enclosing block, and call the __finally
+           * code, which won't return
+           */
+          frame->trylevel = pScopeTable->previousTryLevel;
+          TRACE("__finally block %p\n",pScopeTable[trylevel].lpfnHandler);
+          call_finally_block(pScopeTable[trylevel].lpfnHandler, &frame->_ebp);
+          ERR("Returned from __finally block - expect crash!\n");
+       }
+      }
+      trylevel = pScopeTable->previousTryLevel;
+    }
+  }
+#else
+  TRACE("exception %lx flags=%lx at %p handler=%p %p %p stub\n",
+        rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress,
+        frame->handler, context, dispatcher);
+#endif
+  return ExceptionContinueSearch;
+}
+
+/*********************************************************************
+ *		_abnormal_termination (MSVCRT.@)
+ */
+int _abnormal_termination(void)
+{
+  FIXME("(void)stub\n");
+  return 0;
+}
+
+/*
+ * setjmp/longjmp implementation
+ */
+
+#ifdef __i386__
+#define MSVCRT_JMP_MAGIC 0x56433230 /* ID value for new jump structure */
+typedef void (*MSVCRT_unwind_function)(const void*);
+
+/*
+ * The signatures of the setjmp/longjmp functions do not match that
+ * declared in the setjmp header so they don't follow the regular naming
+ * convention to avoid conflicts.
+ */
+
+/*******************************************************************
+ *		_setjmp (MSVCRT.@)
+ */
+#ifdef __WIN32OS2__
+DEFINE_REGS_ENTRYPOINT_1( _MSVCRT__setjmp, EXC_MSVCRT__setjmp, _JUMP_BUFFER);
+void EXC_MSVCRT__setjmp(_JUMP_BUFFER *jmp, CONTEXT86* context)
+#else
+void _MSVCRT__setjmp(_JUMP_BUFFER *jmp, CONTEXT86* context)
+#endif
+{
+    TRACE("(%p)\n",jmp);
+    jmp->Ebp = context->Ebp;
+    jmp->Ebx = context->Ebx;
+    jmp->Edi = context->Edi;
+    jmp->Esi = context->Esi;
+    jmp->Esp = context->Esp;
+    jmp->Eip = context->Eip;
+    jmp->Registration = (unsigned long)NtCurrentTeb()->except;
+    if (jmp->Registration == TRYLEVEL_END)
+        jmp->TryLevel = TRYLEVEL_END;
+    else
+        jmp->TryLevel = ((MSVCRT_EXCEPTION_FRAME*)jmp->Registration)->trylevel;
+    TRACE("returning 0\n");
+    context->Eax=0;
+}
+
+/*******************************************************************
+ *		_setjmp3 (MSVCRT.@)
+ */
+#ifdef __WIN32OS2__
+DEFINE_REGS_ENTRYPOINT_2( _MSVCRT__setjmp3, EXC_MSVCRT__setjmp3, _JUMP_BUFFER *, int );
+void EXC_MSVCRT__setjmp3(_JUMP_BUFFER *jmp, int nb_args, CONTEXT86* context)
+#else
+void _MSVCRT__setjmp3(_JUMP_BUFFER *jmp, int nb_args, CONTEXT86* context)
+#endif
+{
+    TRACE("(%p,%d)\n",jmp,nb_args);
+    jmp->Ebp = context->Ebp;
+    jmp->Ebx = context->Ebx;
+    jmp->Edi = context->Edi;
+    jmp->Esi = context->Esi;
+    jmp->Esp = context->Esp;
+    jmp->Eip = context->Eip;
+    jmp->Cookie = MSVCRT_JMP_MAGIC;
+    jmp->UnwindFunc = 0;
+    jmp->Registration = (unsigned long)NtCurrentTeb()->except;
+    if (jmp->Registration == TRYLEVEL_END)
+    {
+        jmp->TryLevel = TRYLEVEL_END;
+    }
+    else
+    {
+        void **args = ((void**)context->Esp)+2;
+
+        if (nb_args > 0) jmp->UnwindFunc = (unsigned long)*args++;
+        if (nb_args > 1) jmp->TryLevel = (unsigned long)*args++;
+        else jmp->TryLevel = ((MSVCRT_EXCEPTION_FRAME*)jmp->Registration)->trylevel;
+        if (nb_args > 2)
+        {
+            size_t size = (nb_args - 2) * sizeof(DWORD);
+            memcpy( jmp->UnwindData, args, min( size, sizeof(jmp->UnwindData) ));
+        }
+    }
+    TRACE("returning 0\n");
+    context->Eax = 0;
+}
+
+/*********************************************************************
+ *		longjmp (MSVCRT.@)
+ */
+#ifdef __WIN32OS2__
+DEFINE_REGS_ENTRYPOINT_2( _MSVCRT_longjmp, EXC_MSVCRT_longjmp, _JUMP_BUFFER *, int );
+void EXC_MSVCRT_longjmp(_JUMP_BUFFER *jmp, int retval, CONTEXT86* context)
+#else
+void _MSVCRT_longjmp(_JUMP_BUFFER *jmp, int retval, CONTEXT86* context)
+#endif
+{
+    unsigned long cur_frame = 0;
+
+    TRACE("(%p,%d)\n", jmp, retval);
+
+    cur_frame=(unsigned long)NtCurrentTeb()->except;
+    TRACE("cur_frame=%lx\n",cur_frame);
+
+    if (cur_frame != jmp->Registration)
+        _global_unwind2((PEXCEPTION_FRAME)jmp->Registration);
+
+    if (jmp->Registration)
+    {
+        if (!IsBadReadPtr(&jmp->Cookie, sizeof(long)) &&
+            jmp->Cookie == MSVCRT_JMP_MAGIC && jmp->UnwindFunc)
+        {
+            MSVCRT_unwind_function unwind_func;
+
+            unwind_func=(MSVCRT_unwind_function)jmp->UnwindFunc;
+            unwind_func(jmp);
+        }
+        else
+            _local_unwind2((MSVCRT_EXCEPTION_FRAME*)jmp->Registration,
+                           jmp->TryLevel);
+    }
+
+    if (!retval)
+        retval = 1;
+
+    TRACE("Jump to %lx returning %d\n",jmp->Eip,retval);
+    context->Ebp = jmp->Ebp;
+    context->Ebx = jmp->Ebx;
+    context->Edi = jmp->Edi;
+    context->Esi = jmp->Esi;
+    context->Esp = jmp->Esp;
+    context->Eip = jmp->Eip;
+    context->Eax = retval;
+}
+
+/*********************************************************************
+ *		_seh_longjmp_unwind (MSVCRT.@)
+ */
+void __stdcall _seh_longjmp_unwind(_JUMP_BUFFER *jmp)
+{
+    _local_unwind2( (MSVCRT_EXCEPTION_FRAME *)jmp->Registration, jmp->TryLevel );
+}
+#endif /* i386 */
+
+/*********************************************************************
+ *		signal (MSVCRT.@)
+ */
+void* MSVCRT_signal(int sig, MSVCRT_sig_handler_func func)
+{
+  FIXME("(%d %p):stub\n", sig, func);
+  return (void*)-1;
+}
Index: trunk/src/msvcrt/exit.c
===================================================================
--- trunk/src/msvcrt/exit.c	(revision 9633)
+++ trunk/src/msvcrt/exit.c	(revision 9633)
@@ -0,0 +1,222 @@
+/*
+ * msvcrt.dll exit functions
+ *
+ * Copyright 2000 Jon Griffiths
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#include "msvcrt.h"
+
+#include "msvcrt/conio.h"
+#include "msvcrt/stdlib.h"
+#include "mtdll.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
+
+/* MT */
+#define LOCK_EXIT   _mlock(_EXIT_LOCK1)
+#define UNLOCK_EXIT _munlock(_EXIT_LOCK1)
+
+static _onexit_t *MSVCRT_atexit_table = NULL;
+static int MSVCRT_atexit_table_size = 0;
+static int MSVCRT_atexit_registered = 0; /* Points to free slot */
+
+extern int MSVCRT_app_type;
+
+/* INTERNAL: call atexit functions */
+void __MSVCRT__call_atexit(void)
+{
+  /* Note: should only be called with the exit lock held */
+  TRACE("%d atext functions to call\n", MSVCRT_atexit_registered);
+  /* Last registered gets executed first */
+  while (MSVCRT_atexit_registered > 0)
+  {
+    MSVCRT_atexit_registered--;
+    TRACE("next is %p\n",MSVCRT_atexit_table[MSVCRT_atexit_registered]);
+    if (MSVCRT_atexit_table[MSVCRT_atexit_registered])
+      (*MSVCRT_atexit_table[MSVCRT_atexit_registered])();
+    TRACE("returned\n");
+  }
+}
+
+/*********************************************************************
+ *		__dllonexit (MSVCRT.@)
+ */
+_onexit_t __dllonexit(_onexit_t func, _onexit_t **start, _onexit_t **end)
+{
+  _onexit_t *tmp;
+  int len;
+
+  TRACE("(%p,%p,%p)\n", func, start, end);
+
+  if (!start || !*start || !end || !*end)
+  {
+   FIXME("bad table\n");
+   return NULL;
+  }
+
+  len = (*end - *start);
+
+  TRACE("table start %p-%p, %d entries\n", *start, *end, len);
+
+  if (++len <= 0)
+    return NULL;
+
+  tmp = (_onexit_t *)MSVCRT_realloc(*start, len * sizeof(tmp));
+  if (!tmp)
+    return NULL;
+  *start = tmp;
+  *end = tmp + len;
+  tmp[len - 1] = func;
+  TRACE("new table start %p-%p, %d entries\n", *start, *end, len);
+  return func;
+}
+
+/*********************************************************************
+ *		_exit (MSVCRT.@)
+ */
+void MSVCRT__exit(int exitcode)
+{
+  TRACE("(%d)\n", exitcode);
+  ExitProcess(exitcode);
+}
+
+/*********************************************************************
+ *		_amsg_exit (MSVCRT.@)
+ */
+void MSVCRT__amsg_exit(int errnum)
+{
+  TRACE("(%d)\n", errnum);
+  /* FIXME: text for the error number. */
+  if (MSVCRT_app_type == 2)
+  {
+    /* FIXME: MsgBox */
+  }
+  _cprintf("\nruntime error R60%d\n",errnum);
+  MSVCRT__exit(255);
+}
+
+/*********************************************************************
+ *		abort (MSVCRT.@)
+ */
+void MSVCRT_abort(void)
+{
+  TRACE("(void)\n");
+  if (MSVCRT_app_type == 2)
+  {
+    /* FIXME: MsgBox */
+  }
+  _cputs("\nabnormal program termination\n");
+  MSVCRT__exit(3);
+}
+
+/*********************************************************************
+ *		_assert (MSVCRT.@)
+ */
+void MSVCRT__assert(const char* str, const char* file, unsigned int line)
+{
+  TRACE("(%s,%s,%d)\n",str,file,line);
+  if (MSVCRT_app_type == 2)
+  {
+    /* FIXME: MsgBox */
+  }
+  _cprintf("Assertion failed: %s, file %s, line %d\n\n",str,file, line);
+  MSVCRT_abort();
+}
+
+/*********************************************************************
+ *		_c_exit (MSVCRT.@)
+ */
+void MSVCRT__c_exit(void)
+{
+  TRACE("(void)\n");
+  /* All cleanup is done on DLL detach; Return to caller */
+}
+
+/*********************************************************************
+ *		_cexit (MSVCRT.@)
+ */
+void MSVCRT__cexit(void)
+{
+  TRACE("(void)\n");
+  /* All cleanup is done on DLL detach; Return to caller */
+}
+
+/*********************************************************************
+ *		_onexit (MSVCRT.@)
+ */
+_onexit_t _onexit(_onexit_t func)
+{
+  TRACE("(%p)\n",func);
+
+  if (!func)
+    return NULL;
+
+  LOCK_EXIT;
+  if (MSVCRT_atexit_registered > MSVCRT_atexit_table_size - 1)
+  {
+    _onexit_t *newtable;
+    TRACE("expanding table\n");
+    newtable = MSVCRT_calloc(sizeof(void *),MSVCRT_atexit_table_size + 32);
+    if (!newtable)
+    {
+      TRACE("failed!\n");
+      UNLOCK_EXIT;
+      return NULL;
+    }
+    memcpy (newtable, MSVCRT_atexit_table, MSVCRT_atexit_table_size);
+    MSVCRT_atexit_table_size += 32;
+    if (MSVCRT_atexit_table)
+      MSVCRT_free (MSVCRT_atexit_table);
+    MSVCRT_atexit_table = newtable;
+  }
+  MSVCRT_atexit_table[MSVCRT_atexit_registered] = func;
+  MSVCRT_atexit_registered++;
+  UNLOCK_EXIT;
+  return func;
+}
+
+/*********************************************************************
+ *		exit (MSVCRT.@)
+ */
+void MSVCRT_exit(int exitcode)
+{
+  TRACE("(%d)\n",exitcode);
+  LOCK_EXIT;
+  __MSVCRT__call_atexit();
+  UNLOCK_EXIT;
+  ExitProcess(exitcode);
+}
+
+/*********************************************************************
+ *		atexit (MSVCRT.@)
+ */
+int MSVCRT_atexit(void (*func)(void))
+{
+  TRACE("(%p)\n", func);
+  return _onexit((_onexit_t)func) == (_onexit_t)func ? 0 : -1;
+}
+
+
+/*********************************************************************
+ *		_purecall (MSVCRT.@)
+ */
+void _purecall(void)
+{
+  TRACE("(void)\n");
+  MSVCRT__amsg_exit( 25 );
+}
Index: trunk/src/msvcrt/file.c
===================================================================
--- trunk/src/msvcrt/file.c	(revision 9633)
+++ trunk/src/msvcrt/file.c	(revision 9633)
@@ -0,0 +1,2399 @@
+/*
+ * msvcrt.dll file functions
+ *
+ * Copyright 1996,1998 Marcus Meissner
+ * Copyright 1996 Jukka Iivonen
+ * Copyright 1997,2000 Uwe Bonnes
+ * Copyright 2000 Jon Griffiths
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#ifdef __WIN32OS2__
+#include <emxheader.h>
+#include <winbase.h>
+#else
+#include "config.h"
+#include "wine/port.h"
+#endif
+
+#include <time.h>
+#include <stdio.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#include "winternl.h"
+#include "msvcrt.h"
+#include "msvcrt/errno.h"
+
+#include "wine/unicode.h"
+#include "msvcrt/direct.h"
+#include "msvcrt/fcntl.h"
+#include "msvcrt/io.h"
+#include "msvcrt/sys/locking.h"
+#include "msvcrt/stdio.h"
+#include "msvcrt/stdlib.h"
+#include "msvcrt/string.h"
+#include "msvcrt/sys/stat.h"
+#include "msvcrt/sys/utime.h"
+#include "msvcrt/time.h"
+#include "msvcrt/share.h"
+#include "msvcrt/wctype.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
+
+/* for stat mode, permissions apply to all,owner and group */
+#define MSVCRT_S_IREAD  (_S_IREAD  | (_S_IREAD  >> 3) | (_S_IREAD  >> 6))
+#define MSVCRT_S_IWRITE (_S_IWRITE | (_S_IWRITE >> 3) | (_S_IWRITE >> 6))
+#define MSVCRT_S_IEXEC  (_S_IEXEC  | (_S_IEXEC  >> 3) | (_S_IEXEC  >> 6))
+
+/* _access() bit flags FIXME: incomplete */
+#define MSVCRT_W_OK      0x02
+
+
+/* FIXME: Make this dynamic */
+#define MSVCRT_MAX_FILES 257
+
+HANDLE MSVCRT_handles[MSVCRT_MAX_FILES];
+MSVCRT_FILE* MSVCRT_files[MSVCRT_MAX_FILES];
+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 */
+
+/* INTERNAL: process umask */
+static int MSVCRT_umask = 0;
+
+/* INTERNAL: Static buffer for temp file name */
+static char MSVCRT_tmpname[MAX_PATH];
+
+static const unsigned int EXE = 'e' << 16 | 'x' << 8 | 'e';
+static const unsigned int BAT = 'b' << 16 | 'a' << 8 | 't';
+static const unsigned int CMD = 'c' << 16 | 'm' << 8 | 'd';
+static const unsigned int COM = 'c' << 16 | 'o' << 8 | 'm';
+
+#define TOUL(x) (ULONGLONG)(x)
+static const ULONGLONG WCEXE = TOUL('e') << 32 | TOUL('x') << 16 | TOUL('e');
+static const ULONGLONG WCBAT = TOUL('b') << 32 | TOUL('a') << 16 | TOUL('t');
+static const ULONGLONG WCCMD = TOUL('c') << 32 | TOUL('m') << 16 | TOUL('d');
+static const ULONGLONG WCCOM = TOUL('c') << 32 | TOUL('o') << 16 | TOUL('m');
+
+extern CRITICAL_SECTION MSVCRT_file_cs;
+#define LOCK_FILES     EnterCriticalSection(&MSVCRT_file_cs)
+#define UNLOCK_FILES   LeaveCriticalSection(&MSVCRT_file_cs)
+
+static void msvcrt_cp_from_stati64(const struct _stati64 *bufi64, struct _stat *buf)
+{
+    buf->st_dev   = bufi64->st_dev;
+    buf->st_ino   = bufi64->st_ino;
+    buf->st_mode  = bufi64->st_mode;
+    buf->st_nlink = bufi64->st_nlink;
+    buf->st_uid   = bufi64->st_uid;
+    buf->st_gid   = bufi64->st_gid;
+    buf->st_rdev  = bufi64->st_rdev;
+    buf->st_size  = bufi64->st_size;
+    buf->st_atime = bufi64->st_atime;
+    buf->st_mtime = bufi64->st_mtime;
+    buf->st_ctime = bufi64->st_ctime;
+}
+
+/* INTERNAL: Get the HANDLE for a fd */
+static HANDLE msvcrt_fdtoh(int fd)
+{
+  if (fd < 0 || fd >= MSVCRT_fdend ||
+      MSVCRT_handles[fd] == INVALID_HANDLE_VALUE)
+  {
+    WARN(":fd (%d) - no handle!\n",fd);
+    *__doserrno() = 0;
+    *MSVCRT__errno() = MSVCRT_EBADF;
+   return INVALID_HANDLE_VALUE;
+  }
+  return MSVCRT_handles[fd];
+}
+
+/* INTERNAL: free a file entry fd */
+static void msvcrt_free_fd(int fd)
+{
+  MSVCRT_handles[fd] = INVALID_HANDLE_VALUE;
+  MSVCRT_files[fd] = 0;
+  MSVCRT_flags[fd] = 0;
+  TRACE(":fd (%d) freed\n",fd);
+  if (fd < 3)
+    return; /* dont use 0,1,2 for user files */
+  if (fd == MSVCRT_fdend - 1)
+    MSVCRT_fdend--;
+  if (fd < MSVCRT_fdstart)
+    MSVCRT_fdstart = fd;
+}
+
+/* INTERNAL: Allocate an fd slot from a Win32 HANDLE */
+static int msvcrt_alloc_fd(HANDLE hand, int flag)
+{
+  int fd = MSVCRT_fdstart;
+
+  TRACE(":handle (%p) allocating fd (%d)\n",hand,fd);
+  if (fd >= MSVCRT_MAX_FILES)
+  {
+    WARN(":files exhausted!\n");
+    return -1;
+  }
+  MSVCRT_handles[fd] = hand;
+  MSVCRT_flags[fd] = flag;
+
+  /* locate next free slot */
+  if (fd == MSVCRT_fdend)
+    MSVCRT_fdstart = ++MSVCRT_fdend;
+  else
+    while(MSVCRT_fdstart < MSVCRT_fdend &&
+	  MSVCRT_handles[MSVCRT_fdstart] != INVALID_HANDLE_VALUE)
+      MSVCRT_fdstart++;
+
+  return fd;
+}
+
+/* INTERNAL: Allocate a FILE* for an fd slot
+ * This is done lazily to avoid memory wastage for low level open/write
+ * usage when a FILE* is not requested (but may be later).
+ */
+static MSVCRT_FILE* msvcrt_alloc_fp(int fd)
+{
+  TRACE(":fd (%d) allocating FILE*\n",fd);
+  if (fd < 0 || fd >= MSVCRT_fdend ||
+      MSVCRT_handles[fd] == INVALID_HANDLE_VALUE)
+  {
+    WARN(":invalid fd %d\n",fd);
+    *__doserrno() = 0;
+    *MSVCRT__errno() = MSVCRT_EBADF;
+    return NULL;
+  }
+  if (!MSVCRT_files[fd])
+  {
+    if ((MSVCRT_files[fd] = MSVCRT_calloc(sizeof(MSVCRT_FILE),1)))
+    {
+      MSVCRT_files[fd]->_file = fd;
+      MSVCRT_files[fd]->_flag = MSVCRT_flags[fd];
+      MSVCRT_files[fd]->_flag &= ~MSVCRT__IOAPPEND; /* mask out, see above */
+    }
+  }
+  TRACE(":got FILE* (%p)\n",MSVCRT_files[fd]);
+  return MSVCRT_files[fd];
+}
+
+
+/* INTERNAL: Set up stdin, stderr and stdout */
+void msvcrt_init_io(void)
+{
+  int i;
+  memset(MSVCRT__iob,0,3*sizeof(MSVCRT_FILE));
+  MSVCRT_handles[0] = GetStdHandle(STD_INPUT_HANDLE);
+  MSVCRT_flags[0] = MSVCRT__iob[0]._flag = MSVCRT__IOREAD;
+  MSVCRT_handles[1] = GetStdHandle(STD_OUTPUT_HANDLE);
+  MSVCRT_flags[1] = MSVCRT__iob[1]._flag = MSVCRT__IOWRT;
+  MSVCRT_handles[2] = GetStdHandle(STD_ERROR_HANDLE);
+  MSVCRT_flags[2] = MSVCRT__iob[2]._flag = MSVCRT__IOWRT;
+
+  TRACE(":handles (%p)(%p)(%p)\n",MSVCRT_handles[0],
+	MSVCRT_handles[1],MSVCRT_handles[2]);
+
+  for (i = 0; i < 3; i++)
+  {
+    /* FILE structs for stdin/out/err are static and never deleted */
+    MSVCRT_files[i] = &MSVCRT__iob[i];
+    MSVCRT__iob[i]._file = i;
+    MSVCRT_tempfiles[i] = NULL;
+  }
+}
+
+/* free everything on process exit */
+void msvcrt_free_io(void)
+{
+    _fcloseall();
+    _close(0);
+    _close(1);
+    _close(2);
+}
+
+/* INTERNAL: Flush stdio file buffer */
+static int msvcrt_flush_buffer(MSVCRT_FILE* file)
+{
+  if(file->_bufsiz) {
+        int cnt=file->_ptr-file->_base;
+        if(cnt>0 && _write(file->_file, file->_base, cnt) != cnt) {
+                return MSVCRT_EOF;
+        }
+        file->_ptr=file->_base;
+        file->_cnt=file->_bufsiz;
+  }
+  return 0;
+}
+
+/* INTERNAL: Allocate stdio file buffer */
+static void msvcrt_alloc_buffer(MSVCRT_FILE* file)
+{
+	file->_base = MSVCRT_calloc(MSVCRT_BUFSIZ,1);
+	if(file->_base) {
+		file->_bufsiz = MSVCRT_BUFSIZ;
+		file->_flag |= MSVCRT__IOMYBUF;
+	} else {
+		file->_base = (unsigned char *)(&file->_charbuf);
+		/* put here 2 ??? */
+		file->_bufsiz = sizeof(file->_charbuf);
+	}
+	file->_ptr = file->_base;
+	file->_cnt = 0;
+}
+
+/*********************************************************************
+ *		__p__iob(MSVCRT.@)
+ */
+MSVCRT_FILE *__p__iob(void)
+{
+ return &MSVCRT__iob[0];
+}
+
+/*********************************************************************
+ *		_access (MSVCRT.@)
+ */
+int _access(const char *filename, int mode)
+{
+  DWORD attr = GetFileAttributesA(filename);
+
+  TRACE("(%s,%d) %ld\n",filename,mode,attr);
+
+  if (!filename || attr == 0xffffffff)
+  {
+    MSVCRT__set_errno(GetLastError());
+    return -1;
+  }
+  if ((attr & FILE_ATTRIBUTE_READONLY) && (mode & MSVCRT_W_OK))
+  {
+    MSVCRT__set_errno(ERROR_ACCESS_DENIED);
+    return -1;
+  }
+  return 0;
+}
+
+/*********************************************************************
+ *		_waccess (MSVCRT.@)
+ */
+int _waccess(const MSVCRT_wchar_t *filename, int mode)
+{
+  DWORD attr = GetFileAttributesW(filename);
+
+  TRACE("(%s,%d) %ld\n",debugstr_w(filename),mode,attr);
+
+  if (!filename || attr == 0xffffffff)
+  {
+    MSVCRT__set_errno(GetLastError());
+    return -1;
+  }
+  if ((attr & FILE_ATTRIBUTE_READONLY) && (mode & MSVCRT_W_OK))
+  {
+    MSVCRT__set_errno(ERROR_ACCESS_DENIED);
+    return -1;
+  }
+  return 0;
+}
+
+/*********************************************************************
+ *		_chmod (MSVCRT.@)
+ */
+int _chmod(const char *path, int flags)
+{
+  DWORD oldFlags = GetFileAttributesA(path);
+
+  if (oldFlags != 0x0FFFFFFFF)
+  {
+    DWORD newFlags = (flags & _S_IWRITE)? oldFlags & ~FILE_ATTRIBUTE_READONLY:
+      oldFlags | FILE_ATTRIBUTE_READONLY;
+
+    if (newFlags == oldFlags || SetFileAttributesA(path, newFlags))
+      return 0;
+  }
+  MSVCRT__set_errno(GetLastError());
+  return -1;
+}
+
+/*********************************************************************
+ *		_wchmod (MSVCRT.@)
+ */
+int _wchmod(const MSVCRT_wchar_t *path, int flags)
+{
+  DWORD oldFlags = GetFileAttributesW(path);
+
+  if (oldFlags != 0x0FFFFFFFF)
+  {
+    DWORD newFlags = (flags & _S_IWRITE)? oldFlags & ~FILE_ATTRIBUTE_READONLY:
+      oldFlags | FILE_ATTRIBUTE_READONLY;
+
+    if (newFlags == oldFlags || SetFileAttributesW(path, newFlags))
+      return 0;
+  }
+  MSVCRT__set_errno(GetLastError());
+  return -1;
+}
+
+/*********************************************************************
+ *		_unlink (MSVCRT.@)
+ */
+int _unlink(const char *path)
+{
+  TRACE("(%s)\n",path);
+  if(DeleteFileA(path))
+    return 0;
+  TRACE("failed (%ld)\n",GetLastError());
+  MSVCRT__set_errno(GetLastError());
+  return -1;
+}
+
+/*********************************************************************
+ *		_wunlink (MSVCRT.@)
+ */
+int _wunlink(const MSVCRT_wchar_t *path)
+{
+  TRACE("(%s)\n",debugstr_w(path));
+  if(DeleteFileW(path))
+    return 0;
+  TRACE("failed (%ld)\n",GetLastError());
+  MSVCRT__set_errno(GetLastError());
+  return -1;
+}
+
+/*********************************************************************
+ *		_close (MSVCRT.@)
+ */
+int _close(int fd)
+{
+  HANDLE hand = msvcrt_fdtoh(fd);
+
+  TRACE(":fd (%d) handle (%p)\n",fd,hand);
+  if (hand == INVALID_HANDLE_VALUE)
+    return -1;
+  /* flush stdio buffers */
+  if(MSVCRT_files[fd]) {
+  	if(MSVCRT_files[fd]->_flag & MSVCRT__IOWRT)
+		MSVCRT_fflush(MSVCRT_files[fd]);
+
+  	if(MSVCRT_files[fd]->_flag & MSVCRT__IOMYBUF)
+		MSVCRT_free(MSVCRT_files[fd]->_base);
+  }
+
+  /* Dont free std FILE*'s, they are not dynamic */
+  if (fd > 2 && MSVCRT_files[fd])
+    MSVCRT_free(MSVCRT_files[fd]);
+
+  msvcrt_free_fd(fd);
+
+  if (!CloseHandle(hand))
+  {
+    WARN(":failed-last error (%ld)\n",GetLastError());
+    MSVCRT__set_errno(GetLastError());
+    return -1;
+  }
+  if (MSVCRT_tempfiles[fd])
+  {
+    TRACE("deleting temporary file '%s'\n",MSVCRT_tempfiles[fd]);
+    _unlink(MSVCRT_tempfiles[fd]);
+    MSVCRT_free(MSVCRT_tempfiles[fd]);
+    MSVCRT_tempfiles[fd] = NULL;
+  }
+
+  TRACE(":ok\n");
+  return 0;
+}
+
+/*********************************************************************
+ *		_commit (MSVCRT.@)
+ */
+int _commit(int fd)
+{
+  HANDLE hand = msvcrt_fdtoh(fd);
+
+  TRACE(":fd (%d) handle (%p)\n",fd,hand);
+  if (hand == INVALID_HANDLE_VALUE)
+    return -1;
+
+  if (!FlushFileBuffers(hand))
+  {
+    if (GetLastError() == ERROR_INVALID_HANDLE)
+    {
+      /* FlushFileBuffers fails for console handles
+       * so we ignore this error.
+       */
+      return 0;
+    }
+    TRACE(":failed-last error (%ld)\n",GetLastError());
+    MSVCRT__set_errno(GetLastError());
+    return -1;
+  }
+  TRACE(":ok\n");
+  return 0;
+}
+
+/*********************************************************************
+ *		_eof (MSVCRT.@)
+ */
+int _eof(int fd)
+{
+  DWORD curpos,endpos;
+  HANDLE hand = msvcrt_fdtoh(fd);
+
+  TRACE(":fd (%d) handle (%p)\n",fd,hand);
+
+  if (hand == INVALID_HANDLE_VALUE)
+    return -1;
+
+  /* If we have a FILE* for this file, the EOF flag
+   * will be set by the read()/write() functions.
+   */
+  if (MSVCRT_files[fd])
+    return MSVCRT_flags[fd] & MSVCRT__IOEOF;
+
+  /* Otherwise we do it the hard way */
+  curpos = SetFilePointer(hand, 0, NULL, SEEK_CUR);
+  endpos = SetFilePointer(hand, 0, NULL, FILE_END);
+
+  if (curpos == endpos)
+    return TRUE;
+
+  SetFilePointer(hand, curpos, 0, FILE_BEGIN);
+  return FALSE;
+}
+
+/*********************************************************************
+ *		_fcloseall (MSVCRT.@)
+ */
+int _fcloseall(void)
+{
+  int num_closed = 0, i;
+
+  for (i = 3; i < MSVCRT_fdend; i++)
+    if (MSVCRT_handles[i] != INVALID_HANDLE_VALUE)
+    {
+      _close(i);
+      num_closed++;
+    }
+
+  TRACE(":closed (%d) handles\n",num_closed);
+  return num_closed;
+}
+
+/*********************************************************************
+ *		_lseek (MSVCRT.@)
+ */
+__int64 _lseeki64(int fd, __int64 offset, int whence)
+{
+  DWORD ret, hoffset = (DWORD) (offset >> 32);
+  HANDLE hand = msvcrt_fdtoh(fd);
+
+  TRACE(":fd (%d) handle (%p)\n",fd,hand);
+  if (hand == INVALID_HANDLE_VALUE)
+    return -1;
+
+  if (whence < 0 || whence > 2)
+  {
+    *MSVCRT__errno() = MSVCRT_EINVAL;
+    return -1;
+  }
+
+  TRACE(":fd (%d) to 0x%08lx%08lx pos %s\n",
+        fd,hoffset,(long)offset,
+        (whence==SEEK_SET)?"SEEK_SET":
+        (whence==SEEK_CUR)?"SEEK_CUR":
+        (whence==SEEK_END)?"SEEK_END":"UNKNOWN");
+
+  if (((ret = SetFilePointer(hand, (long)offset, &hoffset,
+                             whence)) != INVALID_SET_FILE_POINTER) || !GetLastError())
+  {
+    if (MSVCRT_files[fd])
+      MSVCRT_files[fd]->_flag &= ~MSVCRT__IOEOF;
+    /* FIXME: What if we seek _to_ EOF - is EOF set? */
+
+    return ((__int64)hoffset << 32) | ret;
+  }
+  TRACE(":error-last error (%ld)\n",GetLastError());
+  if (MSVCRT_files[fd])
+    switch(GetLastError())
+    {
+    case ERROR_NEGATIVE_SEEK:
+    case ERROR_SEEK_ON_DEVICE:
+      MSVCRT__set_errno(GetLastError());
+      MSVCRT_files[fd]->_flag |= MSVCRT__IOERR;
+      break;
+    default:
+      break;
+    }
+  return -1;
+}
+
+/*********************************************************************
+ *		_lseek (MSVCRT.@)
+ */
+LONG _lseek(int fd, LONG offset, int whence)
+{
+    return _lseeki64(fd, offset, whence);
+}
+
+/*********************************************************************
+ *		_locking (MSVCRT.@)
+ *
+ * This is untested; the underlying LockFile doesn't work yet.
+ */
+int _locking(int fd, int mode, LONG nbytes)
+{
+  BOOL ret;
+  DWORD cur_locn;
+  HANDLE hand = msvcrt_fdtoh(fd);
+
+  TRACE(":fd (%d) handle (%p)\n",fd,hand);
+  if (hand == INVALID_HANDLE_VALUE)
+    return -1;
+
+  if (mode < 0 || mode > 4)
+  {
+    *MSVCRT__errno() = MSVCRT_EINVAL;
+    return -1;
+  }
+
+  TRACE(":fd (%d) by 0x%08lx mode %s\n",
+        fd,nbytes,(mode==_LK_UNLCK)?"_LK_UNLCK":
+        (mode==_LK_LOCK)?"_LK_LOCK":
+        (mode==_LK_NBLCK)?"_LK_NBLCK":
+        (mode==_LK_RLCK)?"_LK_RLCK":
+        (mode==_LK_NBRLCK)?"_LK_NBRLCK":
+                          "UNKNOWN");
+
+  if ((cur_locn = SetFilePointer(hand, 0L, NULL, SEEK_CUR)) == 0xffffffff)
+  {
+    FIXME ("Seek failed\n");
+    *MSVCRT__errno() = MSVCRT_EINVAL; /* FIXME */
+    return -1;
+  }
+  if (mode == _LK_LOCK || mode == _LK_RLCK)
+  {
+    int nretry = 10;
+    ret = 1; /* just to satisfy gcc */
+    while (nretry--)
+    {
+      ret = LockFile(hand, cur_locn, 0L, nbytes, 0L);
+      if (ret) break;
+      sleep (1);
+    }
+  }
+  else if (mode == _LK_UNLCK)
+    ret = UnlockFile(hand, cur_locn, 0L, nbytes, 0L);
+  else
+    ret = LockFile(hand, cur_locn, 0L, nbytes, 0L);
+  /* FIXME - what about error settings? */
+  return ret ? 0 : -1;
+}
+
+/*********************************************************************
+ *		rewind (MSVCRT.@)
+ */
+void MSVCRT_rewind(MSVCRT_FILE* file)
+{
+  TRACE(":file (%p) fd (%d)\n",file,file->_file);
+  MSVCRT_fseek(file, 0L, SEEK_SET);
+  MSVCRT_clearerr(file);
+}
+
+/*********************************************************************
+ *		_fdopen (MSVCRT.@)
+ */
+MSVCRT_FILE* _fdopen(int fd, const char *mode)
+{
+  MSVCRT_FILE* file = msvcrt_alloc_fp(fd);
+
+  TRACE(":fd (%d) mode (%s) FILE* (%p)\n",fd,mode,file);
+
+  return file;
+}
+
+/*********************************************************************
+ *		_wfdopen (MSVCRT.@)
+ */
+MSVCRT_FILE* _wfdopen(int fd, const MSVCRT_wchar_t *mode)
+{
+  MSVCRT_FILE* file = msvcrt_alloc_fp(fd);
+
+  TRACE(":fd (%d) mode (%s) FILE* (%p)\n",fd,debugstr_w(mode),file);
+  if (file)
+    MSVCRT_rewind(file);
+
+  return file;
+}
+
+/*********************************************************************
+ *		_filelength (MSVCRT.@)
+ */
+LONG _filelength(int fd)
+{
+  LONG curPos = _lseek(fd, 0, SEEK_CUR);
+  if (curPos != -1)
+  {
+    LONG endPos = _lseek(fd, 0, SEEK_END);
+    if (endPos != -1)
+    {
+      if (endPos != curPos)
+        _lseek(fd, curPos, SEEK_SET);
+      return endPos;
+    }
+  }
+  return -1;
+}
+
+/*********************************************************************
+ *		_fileno (MSVCRT.@)
+ */
+int _fileno(MSVCRT_FILE* file)
+{
+  TRACE(":FILE* (%p) fd (%d)\n",file,file->_file);
+  return file->_file;
+}
+
+/*********************************************************************
+ *		_flushall (MSVCRT.@)
+ */
+int _flushall(void)
+{
+  int num_flushed = 0, i = 3;
+
+  while(i < MSVCRT_fdend)
+    if (MSVCRT_handles[i] != INVALID_HANDLE_VALUE)
+    {
+#if 0
+      /* FIXME: flush, do not commit */
+      if (_commit(i) == -1)
+	if (MSVCRT_files[i])
+	  MSVCRT_files[i]->_flag |= MSVCRT__IOERR;
+#endif
+      if(MSVCRT_files[i] && MSVCRT_files[i]->_flag & MSVCRT__IOWRT) {
+	MSVCRT_fflush(MSVCRT_files[i]);
+        num_flushed++;
+      }
+    }
+
+  TRACE(":flushed (%d) handles\n",num_flushed);
+  return num_flushed;
+}
+
+/*********************************************************************
+ *		_fstati64 (MSVCRT.@)
+ */
+int _fstati64(int fd, struct _stati64* buf)
+{
+  DWORD dw;
+  BY_HANDLE_FILE_INFORMATION hfi;
+  HANDLE hand = msvcrt_fdtoh(fd);
+
+  TRACE(":fd (%d) stat (%p)\n",fd,buf);
+  if (hand == INVALID_HANDLE_VALUE)
+    return -1;
+
+  if (!buf)
+  {
+    WARN(":failed-NULL buf\n");
+    MSVCRT__set_errno(ERROR_INVALID_PARAMETER);
+    return -1;
+  }
+
+  memset(&hfi, 0, sizeof(hfi));
+  memset(buf, 0, sizeof(struct _stati64));
+  if (!GetFileInformationByHandle(hand, &hfi))
+  {
+    WARN(":failed-last error (%ld)\n",GetLastError());
+    MSVCRT__set_errno(ERROR_INVALID_PARAMETER);
+    return -1;
+  }
+  FIXME(":dwFileAttributes = %ld, mode set to 0\n",hfi.dwFileAttributes);
+  buf->st_nlink = hfi.nNumberOfLinks;
+  buf->st_size  = ((__int64)hfi.nFileSizeHigh << 32) + hfi.nFileSizeLow;
+  RtlTimeToSecondsSince1970((LARGE_INTEGER *)&hfi.ftLastAccessTime, &dw);
+  buf->st_atime = dw;
+  RtlTimeToSecondsSince1970((LARGE_INTEGER *)&hfi.ftLastWriteTime, &dw);
+  buf->st_mtime = buf->st_ctime = dw;
+  return 0;
+}
+
+/*********************************************************************
+ *		_fstat (MSVCRT.@)
+ */
+int MSVCRT__fstat(int fd, struct _stat* buf)
+{ int ret;
+  struct _stati64 bufi64;
+
+  ret = _fstati64(fd, &bufi64);
+  if (!ret)
+      msvcrt_cp_from_stati64(&bufi64, buf);
+  return ret;
+}
+
+/*********************************************************************
+ *		_futime (MSVCRT.@)
+ */
+int _futime(int fd, struct _utimbuf *t)
+{
+  HANDLE hand = msvcrt_fdtoh(fd);
+  FILETIME at, wt;
+
+  if (!t)
+  {
+    MSVCRT_time_t currTime;
+    MSVCRT_time(&currTime);
+    RtlSecondsSince1970ToTime(currTime, (LARGE_INTEGER *)&at);
+    memcpy(&wt, &at, sizeof(wt));
+  }
+  else
+  {
+    RtlSecondsSince1970ToTime(t->actime, (LARGE_INTEGER *)&at);
+    if (t->actime == t->modtime)
+      memcpy(&wt, &at, sizeof(wt));
+    else
+      RtlSecondsSince1970ToTime(t->modtime, (LARGE_INTEGER *)&wt);
+  }
+
+  if (!SetFileTime(hand, NULL, &at, &wt))
+  {
+    MSVCRT__set_errno(GetLastError());
+    return -1 ;
+  }
+  return 0;
+}
+
+/*********************************************************************
+ *		_get_osfhandle (MSVCRT.@)
+ */
+long _get_osfhandle(int fd)
+{
+  HANDLE hand = msvcrt_fdtoh(fd);
+  HANDLE newhand = hand;
+  TRACE(":fd (%d) handle (%p)\n",fd,hand);
+
+  if (hand != INVALID_HANDLE_VALUE)
+  {
+    /* FIXME: I'm not convinced that I should be copying the
+     * handle here - it may be leaked if the app doesn't
+     * close it (and the API docs dont say that it should)
+     * Not duplicating it means that it can't be inherited
+     * and so lcc's wedit doesn't cope when it passes it to
+     * child processes. I've an idea that it should either
+     * be copied by CreateProcess, or marked as inheritable
+     * when initialised, or maybe both? JG 21-9-00.
+     */
+    DuplicateHandle(GetCurrentProcess(),hand,GetCurrentProcess(),
+		    &newhand,0,TRUE,DUPLICATE_SAME_ACCESS);
+  }
+  return (long)newhand;
+}
+
+/*********************************************************************
+ *		_isatty (MSVCRT.@)
+ */
+int _isatty(int fd)
+{
+  HANDLE hand = msvcrt_fdtoh(fd);
+
+  TRACE(":fd (%d) handle (%p)\n",fd,hand);
+  if (hand == INVALID_HANDLE_VALUE)
+    return 0;
+
+  return GetFileType(hand) == FILE_TYPE_CHAR? 1 : 0;
+}
+
+/*********************************************************************
+ *		_mktemp (MSVCRT.@)
+ */
+char *_mktemp(char *pattern)
+{
+  int numX = 0;
+  char *retVal = pattern;
+  int id;
+  char letter = 'a';
+
+  while(*pattern)
+    numX = (*pattern++ == 'X')? numX + 1 : 0;
+  if (numX < 5)
+    return NULL;
+  pattern--;
+  id = GetCurrentProcessId();
+  numX = 6;
+  while(numX--)
+  {
+    int tempNum = id / 10;
+    *pattern-- = id - (tempNum * 10) + '0';
+    id = tempNum;
+  }
+  pattern++;
+  do
+  {
+    if (GetFileAttributesA(retVal) == 0xFFFFFFFF &&
+        GetLastError() == ERROR_FILE_NOT_FOUND)
+      return retVal;
+    *pattern = letter++;
+  } while(letter != '|');
+  return NULL;
+}
+
+/*********************************************************************
+ *		_wmktemp (MSVCRT.@)
+ */
+MSVCRT_wchar_t *_wmktemp(MSVCRT_wchar_t *pattern)
+{
+  int numX = 0;
+  MSVCRT_wchar_t *retVal = pattern;
+  int id;
+  MSVCRT_wchar_t letter = 'a';
+
+  while(*pattern)
+    numX = (*pattern++ == 'X')? numX + 1 : 0;
+  if (numX < 5)
+    return NULL;
+  pattern--;
+  id = GetCurrentProcessId();
+  numX = 6;
+  while(numX--)
+  {
+    int tempNum = id / 10;
+    *pattern-- = id - (tempNum * 10) + '0';
+    id = tempNum;
+  }
+  pattern++;
+  do
+  {
+    if (GetFileAttributesW(retVal) == 0xFFFFFFFF &&
+        GetLastError() == ERROR_FILE_NOT_FOUND)
+      return retVal;
+    *pattern = letter++;
+  } while(letter != '|');
+  return NULL;
+}
+
+/*********************************************************************
+ *              _sopen (MSVCRT.@)
+ */
+int MSVCRT__sopen( const char *path, int oflags, int shflags, ... )
+{
+  va_list ap;
+  int pmode;
+  DWORD access = 0, creation = 0;
+  DWORD sharing;
+  int ioflag = 0, fd;
+  HANDLE hand;
+  SECURITY_ATTRIBUTES sa;
+
+
+  TRACE(":file (%s) oflags: 0x%04x shflags: 0x%04x\n",
+        path, oflags, shflags);
+
+  switch(oflags & (_O_RDONLY | _O_WRONLY | _O_RDWR))
+  {
+  case _O_RDONLY:
+    access |= GENERIC_READ;
+    ioflag |= MSVCRT__IOREAD;
+    break;
+  case _O_WRONLY:
+    access |= GENERIC_WRITE;
+    ioflag |= MSVCRT__IOWRT;
+    break;
+  case _O_RDWR:
+    access |= GENERIC_WRITE | GENERIC_READ;
+    ioflag |= MSVCRT__IORW;
+    break;
+  }
+
+  if (oflags & _O_CREAT)
+  {
+    va_start(ap, shflags);
+      pmode = va_arg(ap, int);
+    va_end(ap);
+
+    FIXME(": pmode 0x%04x ignored\n", pmode);
+
+    if (oflags & _O_EXCL)
+      creation = CREATE_NEW;
+    else if (oflags & _O_TRUNC)
+      creation = CREATE_ALWAYS;
+    else
+      creation = OPEN_ALWAYS;
+  }
+  else  /* no _O_CREAT */
+  {
+    if (oflags & _O_TRUNC)
+      creation = TRUNCATE_EXISTING;
+    else
+      creation = OPEN_EXISTING;
+  }
+  if (oflags & _O_APPEND)
+    ioflag |= MSVCRT__IOAPPEND;
+
+
+  oflags |= _O_BINARY; /* FIXME: Default to text */
+
+  if (oflags & _O_TEXT)
+  {
+    /* Dont warn when writing */
+    if (ioflag & GENERIC_READ)
+      FIXME(":TEXT node not implemented\n");
+    oflags &= ~_O_TEXT;
+  }
+
+  switch( shflags )
+  {
+    case _SH_DENYRW:
+      sharing = 0L;
+      break;
+    case _SH_DENYWR:
+      sharing = FILE_SHARE_READ;
+      break;
+    case _SH_DENYRD:
+      sharing = FILE_SHARE_WRITE;
+      break;
+    case _SH_DENYNO:
+      sharing = FILE_SHARE_READ | FILE_SHARE_WRITE;
+      break;
+    default:
+      ERR( "Unhandled shflags 0x%x\n", shflags );
+      return -1;
+  }
+
+  if (oflags & ~(_O_BINARY|_O_TEXT|_O_APPEND|_O_TRUNC|_O_EXCL
+                |_O_CREAT|_O_RDWR|_O_TEMPORARY|_O_NOINHERIT))
+    TRACE(":unsupported oflags 0x%04x\n",oflags);
+
+  sa.nLength              = sizeof( SECURITY_ATTRIBUTES );
+  sa.lpSecurityDescriptor = NULL;
+  sa.bInheritHandle       = (oflags & _O_NOINHERIT) ? FALSE : TRUE;
+
+  hand = CreateFileA(path, access, sharing,
+                      &sa, creation, FILE_ATTRIBUTE_NORMAL, 0);
+
+  if (hand == INVALID_HANDLE_VALUE)  {
+    WARN(":failed-last error (%ld)\n",GetLastError());
+    MSVCRT__set_errno(GetLastError());
+    return -1;
+  }
+
+  fd = msvcrt_alloc_fd(hand, ioflag);
+
+  TRACE(":fd (%d) handle (%p)\n",fd, hand);
+
+  if (fd > 0)
+  {
+    if (oflags & _O_TEMPORARY)
+      MSVCRT_tempfiles[fd] = _strdup(path);
+    if (ioflag & MSVCRT__IOAPPEND)
+      _lseek(fd, 0, FILE_END);
+  }
+
+  return fd;
+}
+
+/*********************************************************************
+ *              _wsopen (MSVCRT.@)
+ */
+int MSVCRT__wsopen( const MSVCRT_wchar_t* path, int oflags, int shflags, ... )
+{
+  const unsigned int len = strlenW(path);
+  char *patha = MSVCRT_calloc(len + 1,1);
+  va_list ap;
+  int pmode;
+
+  va_start(ap, shflags);
+  pmode = va_arg(ap, int);
+  va_end(ap);
+
+  if (patha && WideCharToMultiByte(CP_ACP,0,path,len,patha,len,NULL,NULL))
+  {
+    int retval = MSVCRT__sopen(patha,oflags,shflags,pmode);
+    MSVCRT_free(patha);
+    return retval;
+  }
+
+  MSVCRT__set_errno(GetLastError());
+  return -1;
+}
+
+/*********************************************************************
+ *              _open (MSVCRT.@)
+ */
+int _open( const char *path, int flags, ... )
+{
+  va_list ap;
+  int pmode;
+
+  va_start(ap, flags);
+  pmode = va_arg(ap, int);
+  va_end(ap);
+
+  return MSVCRT__sopen( path, flags, _SH_DENYNO, pmode );
+}
+
+/*********************************************************************
+ *              _wopen (MSVCRT.@)
+ */
+int _wopen(const MSVCRT_wchar_t *path,int flags,...)
+{
+  const unsigned int len = strlenW(path);
+  char *patha = MSVCRT_calloc(len + 1,1);
+  va_list ap;
+  int pmode;
+
+  va_start(ap, flags);
+  pmode = va_arg(ap, int);
+  va_end(ap);
+
+  if (patha && WideCharToMultiByte(CP_ACP,0,path,len,patha,len,NULL,NULL))
+  {
+    int retval = _open(patha,flags,pmode);
+    MSVCRT_free(patha);
+    return retval;
+  }
+
+  MSVCRT__set_errno(GetLastError());
+  return -1;
+}
+
+/*********************************************************************
+ *		_creat (MSVCRT.@)
+ */
+int _creat(const char *path, int flags)
+{
+  int usedFlags = (flags & _O_TEXT)| _O_CREAT| _O_WRONLY| _O_TRUNC;
+  return _open(path, usedFlags);
+}
+
+/*********************************************************************
+ *		_wcreat (MSVCRT.@)
+ */
+int _wcreat(const MSVCRT_wchar_t *path, int flags)
+{
+  int usedFlags = (flags & _O_TEXT)| _O_CREAT| _O_WRONLY| _O_TRUNC;
+  return _wopen(path, usedFlags);
+}
+
+/*********************************************************************
+ *		_open_osfhandle (MSVCRT.@)
+ */
+int _open_osfhandle(long hand, int flags)
+{
+  /* _O_RDONLY (0) always matches, so set the read flag*/
+  /* FIXME: handle more flags */
+  int fd= msvcrt_alloc_fd((HANDLE)hand,flags|MSVCRT__IOREAD);
+  TRACE(":handle (%ld) fd (%d) flags 0x%08x\n",hand,fd, flags |MSVCRT__IOREAD);
+  return fd;
+}
+
+/*********************************************************************
+ *		_rmtmp (MSVCRT.@)
+ */
+int _rmtmp(void)
+{
+  int num_removed = 0, i;
+
+  for (i = 3; i < MSVCRT_fdend; i++)
+    if (MSVCRT_tempfiles[i])
+    {
+      _close(i);
+      num_removed++;
+    }
+
+  if (num_removed)
+    TRACE(":removed (%d) temp files\n",num_removed);
+  return num_removed;
+}
+
+/*********************************************************************
+ *		_read (MSVCRT.@)
+ */
+int _read(int fd, void *buf, unsigned int count)
+{
+  DWORD num_read;
+  HANDLE hand = msvcrt_fdtoh(fd);
+
+  /* Dont trace small reads, it gets *very* annoying */
+  if (count > 4)
+    TRACE(":fd (%d) handle (%p) buf (%p) len (%d)\n",fd,hand,buf,count);
+  if (hand == INVALID_HANDLE_VALUE)
+    return -1;
+
+  if (ReadFile(hand, buf, count, &num_read, NULL))
+  {
+    if (num_read != count && MSVCRT_files[fd])
+    {
+      TRACE(":EOF\n");
+	MSVCRT_flags[fd] |= MSVCRT__IOEOF;
+/*
+      MSVCRT_files[fd]->_flag |= MSVCRT__IOEOF;
+*/
+    }
+    return num_read;
+  }
+  TRACE(":failed-last error (%ld)\n",GetLastError());
+  if (MSVCRT_files[fd])
+     MSVCRT_files[fd]->_flag |= MSVCRT__IOERR;
+  return -1;
+}
+
+/*********************************************************************
+ *		_getw (MSVCRT.@)
+ */
+int _getw(MSVCRT_FILE* file)
+{
+  int i;
+  if (_read(file->_file, &i, sizeof(int)) != 1)
+    return MSVCRT_EOF;
+  return i;
+}
+
+/*********************************************************************
+ *		_setmode (MSVCRT.@)
+ */
+int _setmode(int fd,int mode)
+{
+  if (mode & _O_TEXT)
+    FIXME("fd (%d) mode (%d) TEXT not implemented\n",fd,mode);
+  return 0;
+}
+
+/*********************************************************************
+ *		_stati64 (MSVCRT.@)
+ */
+int _stati64(const char* path, struct _stati64 * buf)
+{
+  DWORD dw;
+  WIN32_FILE_ATTRIBUTE_DATA hfi;
+  unsigned short mode = MSVCRT_S_IREAD;
+  int plen;
+
+  TRACE(":file (%s) buf(%p)\n",path,buf);
+
+  if (!GetFileAttributesExA(path, GetFileExInfoStandard, &hfi))
+  {
+      TRACE("failed (%ld)\n",GetLastError());
+      MSVCRT__set_errno(ERROR_FILE_NOT_FOUND);
+      return -1;
+  }
+
+  memset(buf,0,sizeof(struct _stati64));
+
+  /* FIXME: rdev isnt drive num,despite what the docs say-what is it?
+     Bon 011120: This FIXME seems incorrect
+                 Also a letter as first char isn't enough to be classify
+		 as drive letter
+  */
+  if (isalpha(*path)&& (*(path+1)==':'))
+    buf->st_dev = buf->st_rdev = toupper(*path) - 'A'; /* drive num */
+  else
+    buf->st_dev = buf->st_rdev = _getdrive() - 1;
+
+  plen = strlen(path);
+
+  /* Dir, or regular file? */
+  if ((hfi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
+      (path[plen-1] == '\\'))
+    mode |= (_S_IFDIR | MSVCRT_S_IEXEC);
+  else
+  {
+    mode |= _S_IFREG;
+    /* executable? */
+    if (plen > 6 && path[plen-4] == '.')  /* shortest exe: "\x.exe" */
+    {
+      unsigned int ext = tolower(path[plen-1]) | (tolower(path[plen-2]) << 8) |
+                                 (tolower(path[plen-3]) << 16);
+      if (ext == EXE || ext == BAT || ext == CMD || ext == COM)
+          mode |= MSVCRT_S_IEXEC;
+    }
+  }
+
+  if (!(hfi.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
+    mode |= MSVCRT_S_IWRITE;
+
+  buf->st_mode  = mode;
+  buf->st_nlink = 1;
+  buf->st_size  = ((__int64)hfi.nFileSizeHigh << 32) + hfi.nFileSizeLow;
+  RtlTimeToSecondsSince1970((LARGE_INTEGER *)&hfi.ftLastAccessTime, &dw);
+  buf->st_atime = dw;
+  RtlTimeToSecondsSince1970((LARGE_INTEGER *)&hfi.ftLastWriteTime, &dw);
+  buf->st_mtime = buf->st_ctime = dw;
+  TRACE("%d %d 0x%08lx%08lx %ld %ld %ld\n", buf->st_mode,buf->st_nlink,
+        (long)(buf->st_size >> 32),(long)buf->st_size,
+        buf->st_atime,buf->st_mtime, buf->st_ctime);
+  return 0;
+}
+
+/*********************************************************************
+ *		_stat (MSVCRT.@)
+ */
+int MSVCRT__stat(const char* path, struct _stat * buf)
+{ int ret;
+  struct _stati64 bufi64;
+
+  ret = _stati64( path, &bufi64);
+  if (!ret)
+      msvcrt_cp_from_stati64(&bufi64, buf);
+  return ret;
+}
+
+/*********************************************************************
+ *		_wstat (MSVCRT.@)
+ */
+int _wstat(const MSVCRT_wchar_t* path, struct _stat * buf)
+{
+  DWORD dw;
+  WIN32_FILE_ATTRIBUTE_DATA hfi;
+  unsigned short mode = MSVCRT_S_IREAD;
+  int plen;
+
+  TRACE(":file (%s) buf(%p)\n",debugstr_w(path),buf);
+
+  if (!GetFileAttributesExW(path, GetFileExInfoStandard, &hfi))
+  {
+      TRACE("failed (%ld)\n",GetLastError());
+      MSVCRT__set_errno(ERROR_FILE_NOT_FOUND);
+      return -1;
+  }
+
+  memset(buf,0,sizeof(struct _stat));
+
+  /* FIXME: rdev isn't drive num, despite what the docs says-what is it? */
+  if (MSVCRT_iswalpha(*path))
+    buf->st_dev = buf->st_rdev = toupperW(*path - 'A'); /* drive num */
+  else
+    buf->st_dev = buf->st_rdev = _getdrive() - 1;
+
+  plen = strlenW(path);
+
+  /* Dir, or regular file? */
+  if ((hfi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
+      (path[plen-1] == '\\'))
+    mode |= (_S_IFDIR | MSVCRT_S_IEXEC);
+  else
+  {
+    mode |= _S_IFREG;
+    /* executable? */
+    if (plen > 6 && path[plen-4] == '.')  /* shortest exe: "\x.exe" */
+    {
+      ULONGLONG ext = tolowerW(path[plen-1]) | (tolowerW(path[plen-2]) << 16) |
+                               ((ULONGLONG)tolowerW(path[plen-3]) << 32);
+      if (ext == WCEXE || ext == WCBAT || ext == WCCMD || ext == WCCOM)
+        mode |= MSVCRT_S_IEXEC;
+    }
+  }
+
+  if (!(hfi.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
+    mode |= MSVCRT_S_IWRITE;
+
+  buf->st_mode  = mode;
+  buf->st_nlink = 1;
+  buf->st_size  = hfi.nFileSizeLow;
+  RtlTimeToSecondsSince1970((LARGE_INTEGER *)&hfi.ftLastAccessTime, &dw);
+  buf->st_atime = dw;
+  RtlTimeToSecondsSince1970((LARGE_INTEGER *)&hfi.ftLastWriteTime, &dw);
+  buf->st_mtime = buf->st_ctime = dw;
+  TRACE("\n%d %d %d %ld %ld %ld\n", buf->st_mode,buf->st_nlink,buf->st_size,
+        buf->st_atime,buf->st_mtime, buf->st_ctime);
+  return 0;
+}
+
+/*********************************************************************
+ *		_tell (MSVCRT.@)
+ */
+LONG _tell(int fd)
+{
+  return _lseek(fd, 0, SEEK_CUR);
+}
+
+/*********************************************************************
+ *		_tempnam (MSVCRT.@)
+ */
+char *_tempnam(const char *dir, const char *prefix)
+{
+  char tmpbuf[MAX_PATH];
+
+  TRACE("dir (%s) prefix (%s)\n",dir,prefix);
+  if (GetTempFileNameA(dir,prefix,0,tmpbuf))
+  {
+    TRACE("got name (%s)\n",tmpbuf);
+    return _strdup(tmpbuf);
+  }
+  TRACE("failed (%ld)\n",GetLastError());
+  return NULL;
+}
+
+/*********************************************************************
+ *		_wtempnam (MSVCRT.@)
+ */
+MSVCRT_wchar_t *_wtempnam(const MSVCRT_wchar_t *dir, const MSVCRT_wchar_t *prefix)
+{
+  MSVCRT_wchar_t tmpbuf[MAX_PATH];
+
+  TRACE("dir (%s) prefix (%s)\n",debugstr_w(dir),debugstr_w(prefix));
+  if (GetTempFileNameW(dir,prefix,0,tmpbuf))
+  {
+    TRACE("got name (%s)\n",debugstr_w(tmpbuf));
+    return _wcsdup(tmpbuf);
+  }
+  TRACE("failed (%ld)\n",GetLastError());
+  return NULL;
+}
+
+/*********************************************************************
+ *		_umask (MSVCRT.@)
+ */
+int _umask(int umask)
+{
+  int old_umask = MSVCRT_umask;
+  TRACE("(%d)\n",umask);
+  MSVCRT_umask = umask;
+  return old_umask;
+}
+
+/*********************************************************************
+ *		_utime (MSVCRT.@)
+ */
+int _utime(const char* path, struct _utimbuf *t)
+{
+  int fd = _open(path, _O_WRONLY | _O_BINARY);
+
+  if (fd > 0)
+  {
+    int retVal = _futime(fd, t);
+    _close(fd);
+    return retVal;
+  }
+  return -1;
+}
+
+/*********************************************************************
+ *		_wutime (MSVCRT.@)
+ */
+int _wutime(const MSVCRT_wchar_t* path, struct _utimbuf *t)
+{
+  int fd = _wopen(path, _O_WRONLY | _O_BINARY);
+
+  if (fd > 0)
+  {
+    int retVal = _futime(fd, t);
+    _close(fd);
+    return retVal;
+  }
+  return -1;
+}
+
+/*********************************************************************
+ *		_write (MSVCRT.@)
+ */
+int _write(int fd, const void* buf, unsigned int count)
+{
+  DWORD num_written;
+  HANDLE hand = msvcrt_fdtoh(fd);
+
+  /* Dont trace small writes, it gets *very* annoying */
+#if 0
+  if (count > 32)
+    TRACE(":fd (%d) handle (%d) buf (%p) len (%d)\n",fd,hand,buf,count);
+#endif
+  if (hand == INVALID_HANDLE_VALUE)
+    return -1;
+
+  /* If appending, go to EOF */
+  if (MSVCRT_flags[fd] & MSVCRT__IOAPPEND)
+    _lseek(fd, 0, FILE_END);
+
+  if (WriteFile(hand, buf, count, &num_written, NULL)
+      &&  (num_written == count))
+    return num_written;
+
+  TRACE(":failed-last error (%ld)\n",GetLastError());
+  if (MSVCRT_files[fd])
+     MSVCRT_files[fd]->_flag |= MSVCRT__IOERR;
+
+  return -1;
+}
+
+/*********************************************************************
+ *		_putw (MSVCRT.@)
+ */
+int _putw(int val, MSVCRT_FILE* file)
+{
+  return _write(file->_file, &val, sizeof(val)) == 1? val : MSVCRT_EOF;
+}
+
+/*********************************************************************
+ *		clearerr (MSVCRT.@)
+ */
+void MSVCRT_clearerr(MSVCRT_FILE* file)
+{
+  TRACE(":file (%p) fd (%d)\n",file,file->_file);
+  file->_flag &= ~(MSVCRT__IOERR | MSVCRT__IOEOF);
+}
+
+/*********************************************************************
+ *		fclose (MSVCRT.@)
+ */
+int MSVCRT_fclose(MSVCRT_FILE* file)
+{
+  int r;
+  r=_close(file->_file);
+  return ((r==MSVCRT_EOF) || (file->_flag & MSVCRT__IOERR) ? MSVCRT_EOF : 0);
+}
+
+/*********************************************************************
+ *		feof (MSVCRT.@)
+ */
+int MSVCRT_feof(MSVCRT_FILE* file)
+{
+  return file->_flag & MSVCRT__IOEOF;
+}
+
+/*********************************************************************
+ *		ferror (MSVCRT.@)
+ */
+int MSVCRT_ferror(MSVCRT_FILE* file)
+{
+  return file->_flag & MSVCRT__IOERR;
+}
+
+/*********************************************************************
+ *		fflush (MSVCRT.@)
+ */
+int MSVCRT_fflush(MSVCRT_FILE* file)
+{
+  if(!file) {
+	_flushall();
+	return 0;
+  } else {
+  	int res=msvcrt_flush_buffer(file);
+  	return res;
+  }
+}
+
+/*********************************************************************
+ *		fgetc (MSVCRT.@)
+ */
+int MSVCRT_fgetc(MSVCRT_FILE* file)
+{
+  if (file->_cnt>0) {
+	file->_cnt--;
+	return *(unsigned char *)file->_ptr++;
+  } else {
+	return _filbuf(file);
+  }
+}
+
+/*********************************************************************
+ *		_fgetchar (MSVCRT.@)
+ */
+int _fgetchar(void)
+{
+  return MSVCRT_fgetc(MSVCRT_stdin);
+}
+
+/*********************************************************************
+ *		_filbuf (MSVCRT.@)
+ */
+int _filbuf(MSVCRT_FILE* file)
+{
+
+  /* Allocate buffer if needed */
+  if(file->_bufsiz == 0 && !(file->_flag & MSVCRT__IONBF) ) {
+	msvcrt_alloc_buffer(file);
+  }
+  if(!(file->_flag & MSVCRT__IOREAD)) {
+	if(file->_flag & MSVCRT__IORW) {
+		file->_flag |= MSVCRT__IOREAD;
+	} else {
+		return MSVCRT_EOF;
+	}
+  }
+  if(file->_flag & MSVCRT__IONBF) {
+	unsigned char c;
+  	if (_read(file->_file,&c,1) != 1) {
+		file->_flag |= MSVCRT__IOEOF;
+    		return MSVCRT_EOF;
+	}
+  	return c;
+  } else {
+	file->_cnt = _read(file->_file, file->_base, file->_bufsiz);
+	if(file->_cnt<0) file->_cnt = 0;
+	if(!file->_cnt) {
+		file->_flag |= MSVCRT__IOEOF;
+		return MSVCRT_EOF;
+	}
+	file->_cnt--;
+	file->_ptr = file->_base+1;
+	return *(unsigned char *)file->_base;
+  }
+}
+
+/*********************************************************************
+ *		fgetpos (MSVCRT.@)
+ */
+int MSVCRT_fgetpos(MSVCRT_FILE* file, MSVCRT_fpos_t *pos)
+{
+  *pos = MSVCRT_ftell(file);
+  return (*pos == -1? -1 : 0);
+}
+
+/*********************************************************************
+ *		fgets (MSVCRT.@)
+ */
+char *MSVCRT_fgets(char *s, int size, MSVCRT_FILE* file)
+{
+  int    cc;
+  char * buf_start = s;
+
+  TRACE(":file(%p) fd (%d) str (%p) len (%d)\n",
+	file,file->_file,s,size);
+
+  for(cc = MSVCRT_fgetc(file); cc != MSVCRT_EOF && cc != '\n';
+      cc = MSVCRT_fgetc(file))
+    if (cc != '\r')
+    {
+      if (--size <= 0) break;
+      *s++ = (char)cc;
+    }
+  if ((cc == MSVCRT_EOF) && (s == buf_start)) /* If nothing read, return 0*/
+  {
+    TRACE(":nothing read\n");
+    return 0;
+  }
+  if (cc == '\n')
+    if (--size > 0)
+      *s++ = '\n';
+  *s = '\0';
+  TRACE(":got '%s'\n", buf_start);
+  return buf_start;
+}
+
+/*********************************************************************
+ *		fgetwc (MSVCRT.@)
+ */
+MSVCRT_wint_t MSVCRT_fgetwc(MSVCRT_FILE* file)
+{
+  MSVCRT_wchar_t wc;
+  if (_read(file->_file, &wc, sizeof(wc)) != sizeof(wc))
+    return MSVCRT_WEOF;
+  return wc;
+}
+
+/*********************************************************************
+ *		getwc (MSVCRT.@)
+ */
+MSVCRT_wint_t MSVCRT_getwc(MSVCRT_FILE* file)
+{
+  return MSVCRT_fgetwc(file);
+}
+
+/*********************************************************************
+ *		_fgetwchar (MSVCRT.@)
+ */
+MSVCRT_wint_t _fgetwchar(void)
+{
+  return MSVCRT_fgetwc(MSVCRT_stdin);
+}
+
+/*********************************************************************
+ *		getwchar (MSVCRT.@)
+ */
+MSVCRT_wint_t MSVCRT_getwchar(void)
+{
+  return _fgetwchar();
+}
+
+/*********************************************************************
+ *              fgetws (MSVCRT.@)
+ */
+MSVCRT_wchar_t *MSVCRT_fgetws(MSVCRT_wchar_t *s, int size, MSVCRT_FILE* file)
+{
+  int    cc;
+  MSVCRT_wchar_t * buf_start = s;
+
+  TRACE(":file(%p) fd (%d) str (%p) len (%d)\n",
+        file,file->_file,s,size);
+
+  for(cc = MSVCRT_fgetwc(file); cc != MSVCRT_WEOF && cc != L'\n';
+      cc = MSVCRT_fgetwc(file))
+    if (cc != L'\r')
+    {
+      if (--size <= 0) break;
+      *s++ = cc;
+    }
+  if ((cc == MSVCRT_EOF) && (s == buf_start)) /* If nothing read, return 0*/
+  {
+    TRACE(":nothing read\n");
+    return 0;
+  }
+  if (cc == L'\n')
+    if (--size > 0)
+      *s++ = '\n';
+  *s = '\0';
+/*  TRACE(":got '%s'\n", buf_start); */
+  return buf_start;
+}
+
+
+/*********************************************************************
+ *		fputwc (MSVCRT.@)
+ */
+MSVCRT_wint_t MSVCRT_fputwc(MSVCRT_wint_t wc, MSVCRT_FILE* file)
+{
+  MSVCRT_wchar_t mwc=wc;
+  if (MSVCRT_fwrite( &mwc, sizeof(mwc), 1, file) != 1)
+    return MSVCRT_WEOF;
+  return wc;
+}
+
+/*********************************************************************
+ *		_fputwchar (MSVCRT.@)
+ */
+MSVCRT_wint_t _fputwchar(MSVCRT_wint_t wc)
+{
+  return MSVCRT_fputwc(wc, MSVCRT_stdout);
+}
+
+/*********************************************************************
+ *		fopen (MSVCRT.@)
+ */
+MSVCRT_FILE* MSVCRT_fopen(const char *path, const char *mode)
+{
+  MSVCRT_FILE* file;
+  int flags = 0, plus = 0, fd;
+  const char* search = mode;
+
+  TRACE("(%s,%s)\n",path,mode);
+
+  while (*search)
+    if (*search++ == '+')
+      plus = 1;
+
+  /* map mode string to open() flags. "man fopen" for possibilities. */
+  switch(*mode++)
+  {
+  case 'R': case 'r':
+    flags = (plus ? _O_RDWR : _O_RDONLY);
+    break;
+  case 'W': case 'w':
+    flags = _O_CREAT | _O_TRUNC | (plus  ? _O_RDWR : _O_WRONLY);
+    break;
+  case 'A': case 'a':
+    flags = _O_CREAT | _O_APPEND | (plus  ? _O_RDWR : _O_WRONLY);
+    break;
+  default:
+    return NULL;
+  }
+
+  while (*mode)
+    switch (*mode++)
+    {
+    case 'B': case 'b':
+      flags |=  _O_BINARY;
+      flags &= ~_O_TEXT;
+      break;
+    case 'T': case 't':
+      flags |=  _O_TEXT;
+      flags &= ~_O_BINARY;
+      break;
+    case '+':
+      break;
+    default:
+      FIXME(":unknown flag %c not supported\n",mode[-1]);
+    }
+
+  fd = _open(path, flags);
+
+  if (fd < 0)
+    return NULL;
+
+  file = msvcrt_alloc_fp(fd);
+  TRACE(":got (%p)\n",file);
+  if (!file)
+    _close(fd);
+
+  return file;
+}
+
+/*********************************************************************
+ *		_wfopen (MSVCRT.@)
+ */
+MSVCRT_FILE *_wfopen(const MSVCRT_wchar_t *path, const MSVCRT_wchar_t *mode)
+{
+  const unsigned int plen = strlenW(path), mlen = strlenW(mode);
+  char *patha = MSVCRT_calloc(plen + 1, 1);
+  char *modea = MSVCRT_calloc(mlen + 1, 1);
+
+  TRACE("(%s,%s)\n",debugstr_w(path),debugstr_w(mode));
+
+  if (patha && modea &&
+      WideCharToMultiByte(CP_ACP,0,path,plen,patha,plen,NULL,NULL) &&
+      WideCharToMultiByte(CP_ACP,0,mode,mlen,modea,mlen,NULL,NULL))
+  {
+    MSVCRT_FILE *retval = MSVCRT_fopen(patha,modea);
+    MSVCRT_free(patha);
+    MSVCRT_free(modea);
+    return retval;
+  }
+
+  MSVCRT__set_errno(GetLastError());
+  return NULL;
+}
+
+/*********************************************************************
+ *		_fsopen (MSVCRT.@)
+ */
+MSVCRT_FILE*  _fsopen(const char *path, const char *mode, int share)
+{
+  FIXME(":(%s,%s,%d),ignoring share mode!\n",path,mode,share);
+  return MSVCRT_fopen(path,mode);
+}
+
+/*********************************************************************
+ *		_wfsopen (MSVCRT.@)
+ */
+MSVCRT_FILE*  _wfsopen(const MSVCRT_wchar_t *path, const MSVCRT_wchar_t *mode, int share)
+{
+  FIXME(":(%s,%s,%d),ignoring share mode!\n",
+        debugstr_w(path),debugstr_w(mode),share);
+  return _wfopen(path,mode);
+}
+
+/*********************************************************************
+ *		fputc (MSVCRT.@)
+ */
+int MSVCRT_fputc(int c, MSVCRT_FILE* file)
+{
+  if(file->_cnt>0) {
+	*file->_ptr++=c;
+	file->_cnt--;
+	return c;
+  } else {
+	return _flsbuf(c, file);
+  }
+}
+
+/*********************************************************************
+ *		_flsbuf (MSVCRT.@)
+ */
+int _flsbuf(int c, MSVCRT_FILE* file)
+{
+  /* Flush output buffer */
+  if(file->_bufsiz == 0 && !(file->_flag & MSVCRT__IONBF)) {
+	msvcrt_alloc_buffer(file);
+  }
+  if(!(file->_flag & MSVCRT__IOWRT)) {
+	if(file->_flag & MSVCRT__IORW) {
+		file->_flag |= MSVCRT__IOWRT;
+	} else {
+		return MSVCRT_EOF;
+	}
+  }
+  if(file->_bufsiz) {
+        int res=msvcrt_flush_buffer(file);
+	return res?res : MSVCRT_fputc(c, file);
+  } else {
+	unsigned char cc=c;
+  	return _write(file->_file, &cc, 1) == 1? c : MSVCRT_EOF;
+  }
+}
+
+/*********************************************************************
+ *		_fputchar (MSVCRT.@)
+ */
+int _fputchar(int c)
+{
+  return MSVCRT_fputc(c, MSVCRT_stdout);
+}
+
+/*********************************************************************
+ *		fread (MSVCRT.@)
+ */
+MSVCRT_size_t MSVCRT_fread(void *ptr, MSVCRT_size_t size, MSVCRT_size_t nmemb, MSVCRT_FILE* file)
+{ MSVCRT_size_t rcnt=size * nmemb;
+  MSVCRT_size_t read=0;
+  int pread=0;
+  /* first buffered data */
+  if(file->_cnt>0) {
+	int pcnt= (rcnt>file->_cnt)? file->_cnt:rcnt;
+	memcpy(ptr, file->_ptr, pcnt);
+	file->_cnt -= pcnt;
+	file->_ptr += pcnt;
+	read += pcnt ;
+	rcnt -= pcnt ;
+       ptr = (char*)ptr + pcnt;
+  } else if(!(file->_flag & MSVCRT__IOREAD )) {
+	if(file->_flag & MSVCRT__IORW) {
+		file->_flag |= MSVCRT__IOREAD;
+	} else
+		return 0;
+  }
+  if(rcnt) pread = _read(file->_file,ptr, rcnt);
+  if (MSVCRT_flags[file->_file] & MSVCRT__IOEOF)
+     /* expose feof condition in the flags
+        MFC tests file->_flag for feof, and doesn't not call feof())
+    */
+    file->_flag |= MSVCRT__IOEOF;
+  if (pread <= 0)
+    pread = 0;
+  read+=pread;
+  return read / size;
+}
+
+/*********************************************************************
+ *		freopen (MSVCRT.@)
+ *
+ */
+MSVCRT_FILE* MSVCRT_freopen(const char *path, const char *mode,MSVCRT_FILE* file)
+{
+  MSVCRT_FILE* newfile;
+  int fd;
+
+  TRACE(":path (%p) mode (%s) file (%p) fd (%d)\n",path,mode,file,file->_file);
+  if (!file || ((fd = file->_file) < 0) || fd > MSVCRT_fdend)
+    return NULL;
+
+  if (fd > 2)
+  {
+#if 0
+    FIXME(":reopen on user file not implemented!\n");
+    MSVCRT__set_errno(ERROR_CALL_NOT_IMPLEMENTED);
+    return NULL;
+#endif
+    if(MSVCRT_fclose(file))
+	return NULL;
+    return MSVCRT_fopen(path, mode);
+  }
+
+  /* first, create the new file */
+  if ((newfile = MSVCRT_fopen(path,mode)) == NULL)
+    return NULL;
+
+  if (fd < 3 && SetStdHandle(fd == 0 ? STD_INPUT_HANDLE :
+     (fd == 1? STD_OUTPUT_HANDLE : STD_ERROR_HANDLE),
+      MSVCRT_handles[newfile->_file]))
+  {
+    /* Redirecting std handle to file , copy over.. */
+    MSVCRT_handles[fd] = MSVCRT_handles[newfile->_file];
+    MSVCRT_flags[fd] = MSVCRT_flags[newfile->_file];
+    memcpy(&MSVCRT__iob[fd], newfile, sizeof (MSVCRT_FILE));
+    MSVCRT__iob[fd]._file = fd;
+    /* And free up the resources allocated by fopen, but
+     * not the HANDLE we copied. */
+    MSVCRT_free(MSVCRT_files[fd]);
+    msvcrt_free_fd(newfile->_file);
+    return &MSVCRT__iob[fd];
+  }
+
+  WARN(":failed-last error (%ld)\n",GetLastError());
+  MSVCRT_fclose(newfile);
+  MSVCRT__set_errno(GetLastError());
+  return NULL;
+}
+
+/*********************************************************************
+ *		fsetpos (MSVCRT.@)
+ */
+int MSVCRT_fsetpos(MSVCRT_FILE* file, MSVCRT_fpos_t *pos)
+{
+  return _lseek(file->_file,*pos,SEEK_SET);
+}
+
+/*********************************************************************
+ *		fseek (MSVCRT.@)
+ */
+int MSVCRT_fseek(MSVCRT_FILE* file, long offset, int whence)
+{
+  /* Flush output if needed */
+  if(file->_flag & MSVCRT__IOWRT)
+	msvcrt_flush_buffer(file);
+
+  if(whence == SEEK_CUR && file->_flag & MSVCRT__IOREAD ) {
+	offset -= file->_cnt;
+  }
+  /* Discard buffered input */
+  file->_cnt = 0;
+  file->_ptr = file->_base;
+  /* Reset direction of i/o */
+  if(file->_flag & MSVCRT__IORW) {
+        file->_flag &= ~(MSVCRT__IOREAD|MSVCRT__IOWRT);
+  }
+  return (_lseek(file->_file,offset,whence) == -1)?-1:0;
+}
+
+/*********************************************************************
+ *		ftell (MSVCRT.@)
+ */
+LONG MSVCRT_ftell(MSVCRT_FILE* file)
+{
+  int off=0;
+  long pos;
+  if(file->_bufsiz)  {
+	if( file->_flag & MSVCRT__IOWRT ) {
+		off = file->_ptr - file->_base;
+	} else {
+		off = -file->_cnt;
+	}
+  }
+  pos = _tell(file->_file);
+  if(pos == -1) return pos;
+  return off + pos;
+}
+
+/*********************************************************************
+ *		fwrite (MSVCRT.@)
+ */
+MSVCRT_size_t MSVCRT_fwrite(const void *ptr, MSVCRT_size_t size, MSVCRT_size_t nmemb, MSVCRT_FILE* file)
+{
+  MSVCRT_size_t wrcnt=size * nmemb;
+  int written = 0;
+  if (size == 0)
+      return 0;
+  if(file->_cnt) {
+	int pcnt=(file->_cnt>wrcnt)? wrcnt: file->_cnt;
+	memcpy(file->_ptr, ptr, pcnt);
+	file->_cnt -= pcnt;
+	file->_ptr += pcnt;
+	written = pcnt;
+	wrcnt -= pcnt;
+       ptr = (char*)ptr + pcnt;
+  } else if(!(file->_flag & MSVCRT__IOWRT)) {
+	if(file->_flag & MSVCRT__IORW) {
+		file->_flag |= MSVCRT__IOWRT;
+	} else
+		return 0;
+  }
+  if(wrcnt) {
+	/* Flush buffer */
+  	int res=msvcrt_flush_buffer(file);
+	if(!res) {
+		int pwritten = _write(file->_file, ptr, wrcnt);
+  		if (pwritten <= 0) pwritten=0;
+		written += pwritten;
+	}
+  }
+  return written / size;
+}
+
+/*********************************************************************
+ *		fputs (MSVCRT.@)
+ */
+int MSVCRT_fputs(const char *s, MSVCRT_FILE* file)
+{
+    size_t len = strlen(s);
+    return MSVCRT_fwrite(s,sizeof(*s),len,file) == len ? 0 : MSVCRT_EOF;
+}
+
+/*********************************************************************
+ *		fputws (MSVCRT.@)
+ */
+int MSVCRT_fputws(const MSVCRT_wchar_t *s, MSVCRT_FILE* file)
+{
+    size_t len = strlenW(s);
+    return MSVCRT_fwrite(s,sizeof(*s),len,file) == len ? 0 : MSVCRT_EOF;
+}
+
+/*********************************************************************
+ *		getchar (MSVCRT.@)
+ */
+int MSVCRT_getchar(void)
+{
+  return MSVCRT_fgetc(MSVCRT_stdin);
+}
+
+/*********************************************************************
+ *		getc (MSVCRT.@)
+ */
+int MSVCRT_getc(MSVCRT_FILE* file)
+{
+  return MSVCRT_fgetc(file);
+}
+
+/*********************************************************************
+ *		gets (MSVCRT.@)
+ */
+char *MSVCRT_gets(char *buf)
+{
+  int    cc;
+  char * buf_start = buf;
+
+  for(cc = MSVCRT_fgetc(MSVCRT_stdin); cc != MSVCRT_EOF && cc != '\n';
+      cc = MSVCRT_fgetc(MSVCRT_stdin))
+  if(cc != '\r') *buf++ = (char)cc;
+
+  *buf = '\0';
+
+  TRACE("got '%s'\n", buf_start);
+  return buf_start;
+}
+
+/*********************************************************************
+ *		_getws (MSVCRT.@)
+ */
+MSVCRT_wchar_t* MSVCRT__getws(MSVCRT_wchar_t* buf)
+{
+    MSVCRT_wint_t cc;
+    MSVCRT_wchar_t* ws = buf;
+
+    for (cc = MSVCRT_fgetwc(MSVCRT_stdin); cc != MSVCRT_WEOF && cc != '\n';
+         cc = MSVCRT_fgetwc(MSVCRT_stdin))
+    {
+        if (cc != '\r')
+            *buf++ = (MSVCRT_wchar_t)cc;
+    }
+    *buf = '\0';
+
+    TRACE("got '%s'\n", debugstr_w(ws));
+    return ws;
+}
+
+/*********************************************************************
+ *		putc (MSVCRT.@)
+ */
+int MSVCRT_putc(int c, MSVCRT_FILE* file)
+{
+  return MSVCRT_fputc(c, file);
+}
+
+/*********************************************************************
+ *		putchar (MSVCRT.@)
+ */
+int MSVCRT_putchar(int c)
+{
+  return MSVCRT_fputc(c, MSVCRT_stdout);
+}
+
+/*********************************************************************
+ *		puts (MSVCRT.@)
+ */
+int MSVCRT_puts(const char *s)
+{
+    size_t len = strlen(s);
+    if (MSVCRT_fwrite(s,sizeof(*s),len,MSVCRT_stdout) != len) return MSVCRT_EOF;
+    return MSVCRT_fwrite("\n",1,1,MSVCRT_stdout) == 1 ? 0 : MSVCRT_EOF;
+}
+
+/*********************************************************************
+ *		_putws (MSVCRT.@)
+ */
+int _putws(const MSVCRT_wchar_t *s)
+{
+    static const MSVCRT_wchar_t nl = '\n';
+    size_t len = strlenW(s);
+    if (MSVCRT_fwrite(s,sizeof(*s),len,MSVCRT_stdout) != len) return MSVCRT_EOF;
+    return MSVCRT_fwrite(&nl,sizeof(nl),1,MSVCRT_stdout) == 1 ? 0 : MSVCRT_EOF;
+}
+
+/*********************************************************************
+ *		remove (MSVCRT.@)
+ */
+int MSVCRT_remove(const char *path)
+{
+  TRACE("(%s)\n",path);
+  if (DeleteFileA(path))
+    return 0;
+  TRACE(":failed (%ld)\n",GetLastError());
+  MSVCRT__set_errno(GetLastError());
+  return -1;
+}
+
+/*********************************************************************
+ *		_wremove (MSVCRT.@)
+ */
+int _wremove(const MSVCRT_wchar_t *path)
+{
+  TRACE("(%s)\n",debugstr_w(path));
+  if (DeleteFileW(path))
+    return 0;
+  TRACE(":failed (%ld)\n",GetLastError());
+  MSVCRT__set_errno(GetLastError());
+  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.@)
+ */
+int MSVCRT_rename(const char *oldpath,const char *newpath)
+{
+  TRACE(":from %s to %s\n",oldpath,newpath);
+  if (MoveFileExA(oldpath, newpath, MOVEFILE_COPY_ALLOWED))
+    return 0;
+  TRACE(":failed (%ld)\n",GetLastError());
+  MSVCRT__set_errno(GetLastError());
+  return -1;
+}
+
+/*********************************************************************
+ *		_wrename (MSVCRT.@)
+ */
+int _wrename(const MSVCRT_wchar_t *oldpath,const MSVCRT_wchar_t *newpath)
+{
+  TRACE(":from %s to %s\n",debugstr_w(oldpath),debugstr_w(newpath));
+  if (MoveFileExW(oldpath, newpath, MOVEFILE_COPY_ALLOWED))
+    return 0;
+  TRACE(":failed (%ld)\n",GetLastError());
+  MSVCRT__set_errno(GetLastError());
+  return -1;
+}
+
+/*********************************************************************
+ *		setvbuf (MSVCRT.@)
+ */
+int MSVCRT_setvbuf(MSVCRT_FILE* file, char *buf, int mode, MSVCRT_size_t size)
+{
+  /* TODO: Check if file busy */
+  if(file->_bufsiz) {
+	MSVCRT_free(file->_base);
+	file->_bufsiz = 0;
+	file->_cnt = 0;
+  }
+  if(mode == MSVCRT__IOFBF) {
+	file->_flag &= ~MSVCRT__IONBF;
+  	file->_base = file->_ptr = buf;
+  	if(buf) {
+		file->_bufsiz = size;
+	}
+  } else {
+	file->_flag |= MSVCRT__IONBF;
+  }
+  return 0;
+}
+
+/*********************************************************************
+ *		setbuf (MSVCRT.@)
+ */
+void MSVCRT_setbuf(MSVCRT_FILE* file, char *buf)
+{
+  MSVCRT_setvbuf(file, buf, buf ? MSVCRT__IOFBF : MSVCRT__IONBF, MSVCRT_BUFSIZ);
+}
+
+/*********************************************************************
+ *		tmpnam (MSVCRT.@)
+ */
+char *MSVCRT_tmpnam(char *s)
+{
+  char tmpbuf[MAX_PATH];
+  char* prefix = "TMP";
+  if (!GetTempPathA(MAX_PATH,tmpbuf) ||
+      !GetTempFileNameA(tmpbuf,prefix,0,MSVCRT_tmpname))
+  {
+    TRACE(":failed-last error (%ld)\n",GetLastError());
+    return NULL;
+  }
+  TRACE(":got tmpnam %s\n",MSVCRT_tmpname);
+  s = MSVCRT_tmpname;
+  return s;
+}
+
+/*********************************************************************
+ *		tmpfile (MSVCRT.@)
+ */
+MSVCRT_FILE* MSVCRT_tmpfile(void)
+{
+  char *filename = MSVCRT_tmpnam(NULL);
+  int fd;
+  fd = _open(filename, _O_CREAT | _O_BINARY | _O_RDWR | _O_TEMPORARY);
+  if (fd != -1)
+    return msvcrt_alloc_fp(fd);
+  return NULL;
+}
+
+/*********************************************************************
+ *		vfprintf (MSVCRT.@)
+ */
+int MSVCRT_vfprintf(MSVCRT_FILE* file, const char *format, va_list valist)
+{
+  char buf[2048], *mem = buf;
+  int written, resize = sizeof(buf), retval;
+  /* There are two conventions for vsnprintf failing:
+   * Return -1 if we truncated, or
+   * Return the number of bytes that would have been written
+   * The code below handles both cases
+   */
+  while ((written = vsnprintf(mem, resize, format, valist)) == -1 ||
+          written > resize)
+  {
+    resize = (written == -1 ? resize * 2 : written + 1);
+    if (mem != buf)
+      MSVCRT_free (mem);
+    if (!(mem = (char *)MSVCRT_malloc(resize)))
+      return MSVCRT_EOF;
+  }
+  retval = MSVCRT_fwrite(mem, sizeof(*mem), written, file);
+  if (mem != buf)
+    MSVCRT_free (mem);
+  return retval;
+}
+
+/*********************************************************************
+ *		vfwprintf (MSVCRT.@)
+ * FIXME:
+ * Is final char included in written (then resize is too big) or not
+ * (then we must test for equality too)?
+ */
+int MSVCRT_vfwprintf(MSVCRT_FILE* file, const MSVCRT_wchar_t *format, va_list valist)
+{
+  MSVCRT_wchar_t buf[2048], *mem = buf;
+  int written, resize = sizeof(buf) / sizeof(MSVCRT_wchar_t), retval;
+  /* See vfprintf comments */
+  while ((written = _vsnwprintf(mem, resize, format, valist)) == -1 ||
+          written > resize)
+  {
+    resize = (written == -1 ? resize * 2 : written + sizeof(MSVCRT_wchar_t));
+    if (mem != buf)
+      MSVCRT_free (mem);
+    if (!(mem = (MSVCRT_wchar_t *)MSVCRT_malloc(resize*sizeof(*mem))))
+      return MSVCRT_EOF;
+  }
+  retval = MSVCRT_fwrite(mem, sizeof(*mem), written, file);
+  if (mem != buf)
+    MSVCRT_free (mem);
+  return retval;
+}
+
+/*********************************************************************
+ *		vprintf (MSVCRT.@)
+ */
+int MSVCRT_vprintf(const char *format, va_list valist)
+{
+  return MSVCRT_vfprintf(MSVCRT_stdout,format,valist);
+}
+
+/*********************************************************************
+ *		vwprintf (MSVCRT.@)
+ */
+int MSVCRT_vwprintf(const MSVCRT_wchar_t *format, va_list valist)
+{
+  return MSVCRT_vfwprintf(MSVCRT_stdout,format,valist);
+}
+
+/*********************************************************************
+ *		fprintf (MSVCRT.@)
+ */
+int MSVCRT_fprintf(MSVCRT_FILE* file, const char *format, ...)
+{
+    va_list valist;
+    int res;
+    va_start(valist, format);
+    res = MSVCRT_vfprintf(file, format, valist);
+    va_end(valist);
+    return res;
+}
+
+/*********************************************************************
+ *		fwprintf (MSVCRT.@)
+ */
+int MSVCRT_fwprintf(MSVCRT_FILE* file, const MSVCRT_wchar_t *format, ...)
+{
+    va_list valist;
+    int res;
+    va_start(valist, format);
+    res = MSVCRT_vfwprintf(file, format, valist);
+    va_end(valist);
+    return res;
+}
+
+/*********************************************************************
+ *		printf (MSVCRT.@)
+ */
+int MSVCRT_printf(const char *format, ...)
+{
+    va_list valist;
+    int res;
+    va_start(valist, format);
+    res = MSVCRT_vfprintf(MSVCRT_stdout, format, valist);
+    va_end(valist);
+    return res;
+}
+
+/*********************************************************************
+ *		ungetc (MSVCRT.@)
+ */
+int MSVCRT_ungetc(int c, MSVCRT_FILE * file)
+{
+	if(file->_bufsiz == 0 && !(file->_flag & MSVCRT__IONBF)) {
+		msvcrt_alloc_buffer(file);
+		file->_ptr++;
+	}
+	if(file->_ptr>file->_base) {
+		file->_ptr--;
+		*file->_ptr=c;
+		file->_cnt++;
+		return c;
+	}
+	return MSVCRT_EOF;
+}
+
+/*********************************************************************
+ *              ungetwc (MSVCRT.@)
+ */
+MSVCRT_wint_t MSVCRT_ungetwc(MSVCRT_wint_t wc, MSVCRT_FILE * file)
+{
+	MSVCRT_wchar_t mwc = wc;
+	char * pp = (char *)&mwc;
+	int i;
+	for(i=sizeof(MSVCRT_wchar_t)-1;i>=0;i--) {
+		if(pp[i] != MSVCRT_ungetc(pp[i],file))
+			return MSVCRT_WEOF;
+	}
+	return mwc;
+}
+
+/*********************************************************************
+ *		wprintf (MSVCRT.@)
+ */
+int MSVCRT_wprintf(const MSVCRT_wchar_t *format, ...)
+{
+    va_list valist;
+    int res;
+    va_start(valist, format);
+    res = MSVCRT_vwprintf(format, valist);
+    va_end(valist);
+    return res;
+}
Index: trunk/src/msvcrt/heap.c
===================================================================
--- trunk/src/msvcrt/heap.c	(revision 9633)
+++ trunk/src/msvcrt/heap.c	(revision 9633)
@@ -0,0 +1,302 @@
+/*
+ * msvcrt.dll heap functions
+ *
+ * Copyright 2000 Jon Griffiths
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Note: Win32 heap operations are MT safe. We only lock the new
+ *       handler and non atomic heap operations
+ */
+
+#include "msvcrt.h"
+#include "ms_errno.h"
+
+#include "msvcrt/malloc.h"
+#include "msvcrt/stdlib.h"
+#include "mtdll.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
+
+/* MT */
+#define LOCK_HEAP   _mlock( _HEAP_LOCK )
+#define UNLOCK_HEAP _munlock( _HEAP_LOCK )
+
+
+typedef void (*MSVCRT_new_handler_func)(unsigned long size);
+
+static MSVCRT_new_handler_func MSVCRT_new_handler;
+static int MSVCRT_new_mode;
+
+
+/*********************************************************************
+ *		??2@YAPAXI@Z (MSVCRT.@)
+ */
+void* MSVCRT_operator_new(unsigned long size)
+{
+  void *retval = HeapAlloc(GetProcessHeap(), 0, size);
+  TRACE("(%ld) returning %p\n", size, retval);
+  LOCK_HEAP;
+  if(!retval && MSVCRT_new_handler)
+    (*MSVCRT_new_handler)(size);
+  UNLOCK_HEAP;
+  return retval;
+}
+
+/*********************************************************************
+ *		??3@YAXPAX@Z (MSVCRT.@)
+ */
+void MSVCRT_operator_delete(void *mem)
+{
+  TRACE("(%p)\n", mem);
+  HeapFree(GetProcessHeap(), 0, mem);
+}
+
+
+/*********************************************************************
+ *		?_query_new_handler@@YAP6AHI@ZXZ (MSVCRT.@)
+ */
+MSVCRT_new_handler_func MSVCRT__query_new_handler(void)
+{
+  return MSVCRT_new_handler;
+}
+
+
+/*********************************************************************
+ *		?_query_new_mode@@YAHXZ (MSVCRT.@)
+ */
+int MSVCRT__query_new_mode(void)
+{
+  return MSVCRT_new_mode;
+}
+
+/*********************************************************************
+ *		?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z (MSVCRT.@)
+ */
+MSVCRT_new_handler_func MSVCRT__set_new_handler(MSVCRT_new_handler_func func)
+{
+  MSVCRT_new_handler_func old_handler;
+  LOCK_HEAP;
+  old_handler = MSVCRT_new_handler;
+  MSVCRT_new_handler = func;
+  UNLOCK_HEAP;
+  return old_handler;
+}
+
+/*********************************************************************
+ *		?set_new_handler@@YAP6AXXZP6AXXZ@Z (MSVCRT.@)
+ */
+MSVCRT_new_handler_func MSVCRT_set_new_handler(void *func)
+{
+  TRACE("(%p)\n",func);
+  MSVCRT__set_new_handler(NULL);
+  return NULL;
+}
+
+/*********************************************************************
+ *		?_set_new_mode@@YAHH@Z (MSVCRT.@)
+ */
+int MSVCRT__set_new_mode(int mode)
+{
+  int old_mode;
+  LOCK_HEAP;
+  old_mode = MSVCRT_new_mode;
+  MSVCRT_new_mode = mode;
+  UNLOCK_HEAP;
+  return old_mode;
+}
+
+/*********************************************************************
+ *		_callnewh (MSVCRT.@)
+ */
+int _callnewh(unsigned long size)
+{
+  if(MSVCRT_new_handler)
+    (*MSVCRT_new_handler)(size);
+  return 0;
+}
+
+/*********************************************************************
+ *		_expand (MSVCRT.@)
+ */
+void* _expand(void* mem, MSVCRT_size_t size)
+{
+  return HeapReAlloc(GetProcessHeap(), HEAP_REALLOC_IN_PLACE_ONLY, mem, size);
+}
+
+/*********************************************************************
+ *		_heapchk (MSVCRT.@)
+ */
+int _heapchk(void)
+{
+  if (!HeapValidate( GetProcessHeap(), 0, NULL))
+  {
+    MSVCRT__set_errno(GetLastError());
+    return _HEAPBADNODE;
+  }
+  return _HEAPOK;
+}
+
+/*********************************************************************
+ *		_heapmin (MSVCRT.@)
+ */
+int _heapmin(void)
+{
+  if (!HeapCompact( GetProcessHeap(), 0 ))
+  {
+    if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
+      MSVCRT__set_errno(GetLastError());
+    return -1;
+  }
+  return 0;
+}
+
+/*********************************************************************
+ *		_heapwalk (MSVCRT.@)
+ */
+int _heapwalk(_HEAPINFO* next)
+{
+  PROCESS_HEAP_ENTRY phe;
+
+  LOCK_HEAP;
+  phe.lpData = next->_pentry;
+  phe.cbData = next->_size;
+  phe.wFlags = next->_useflag == _USEDENTRY ? PROCESS_HEAP_ENTRY_BUSY : 0;
+
+  if (phe.lpData && phe.wFlags & PROCESS_HEAP_ENTRY_BUSY &&
+      !HeapValidate( GetProcessHeap(), 0, phe.lpData ))
+  {
+    UNLOCK_HEAP;
+    MSVCRT__set_errno(GetLastError());
+    return _HEAPBADNODE;
+  }
+
+  do
+  {
+    if (!HeapWalk( GetProcessHeap(), &phe ))
+    {
+      UNLOCK_HEAP;
+      if (GetLastError() == ERROR_NO_MORE_ITEMS)
+         return _HEAPEND;
+      MSVCRT__set_errno(GetLastError());
+      if (!phe.lpData)
+        return _HEAPBADBEGIN;
+      return _HEAPBADNODE;
+    }
+  } while (phe.wFlags & (PROCESS_HEAP_REGION|PROCESS_HEAP_UNCOMMITTED_RANGE));
+
+  UNLOCK_HEAP;
+  next->_pentry = phe.lpData;
+  next->_size = phe.cbData;
+  next->_useflag = phe.wFlags & PROCESS_HEAP_ENTRY_BUSY ? _USEDENTRY : _FREEENTRY;
+  return _HEAPOK;
+}
+
+/*********************************************************************
+ *		_heapset (MSVCRT.@)
+ */
+int _heapset(unsigned int value)
+{
+  int retval;
+  _HEAPINFO heap;
+
+  memset( &heap, 0, sizeof(_HEAPINFO) );
+  LOCK_HEAP;
+  while ((retval = _heapwalk(&heap)) == _HEAPOK)
+  {
+    if (heap._useflag == _FREEENTRY)
+      memset(heap._pentry, value, heap._size);
+  }
+  UNLOCK_HEAP;
+  return retval == _HEAPEND? _HEAPOK : retval;
+}
+
+/*********************************************************************
+ *		_heapadd (MSVCRT.@)
+ */
+int _heapadd(void* mem, MSVCRT_size_t size)
+{
+  TRACE("(%p,%d) unsupported in Win32\n", mem,size);
+  *MSVCRT__errno() = MSVCRT_ENOSYS;
+  return -1;
+}
+
+/*********************************************************************
+ *		_msize (MSVCRT.@)
+ */
+MSVCRT_size_t _msize(void* mem)
+{
+  long size = HeapSize(GetProcessHeap(),0,mem);
+  if (size == -1)
+  {
+    WARN(":Probably called with non wine-allocated memory, ret = -1\n");
+    /* At least the Win32 crtdll/msvcrt also return -1 in this case */
+  }
+  return size;
+}
+
+/*********************************************************************
+ *		calloc (MSVCRT.@)
+ */
+void* MSVCRT_calloc(MSVCRT_size_t size, MSVCRT_size_t count)
+{
+  return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, size * count );
+}
+
+/*********************************************************************
+ *		free (MSVCRT.@)
+ */
+void MSVCRT_free(void* ptr)
+{
+  dprintf(("MSVCRT_free %x ptr",ptr));
+  HeapFree(GetProcessHeap(),0,ptr);
+}
+
+void* MSVCRT(memset)(void* ptr,int fill,MSVCRT(size_t) size)
+{
+  dprintf(("MSVCRT_memset %x(%d bytes) with %d",ptr,size,fill));
+  return memset(ptr,fill,size);
+}
+
+
+void* MSVCRT(memcpy)(void* ptr,const void* ptr2,MSVCRT(size_t) size)
+{
+  dprintf(("MSVCRT_memcpy %x->%x (%d bytes)",ptr2,ptr,size));
+  return memcpy(ptr,ptr2,size);
+}
+
+
+/*********************************************************************
+ *                  malloc (MSVCRT.@)
+ */
+void* MSVCRT_malloc(MSVCRT_size_t size)
+{
+  void *ret = HeapAlloc(GetProcessHeap(),0,size);
+  dprintf(("MSVCRT_malloc of %d size returned %x",size,ret));
+  if (!ret)
+    MSVCRT__set_errno(GetLastError());
+  return ret;
+}
+
+/*********************************************************************
+ *		realloc (MSVCRT.@)
+ */
+void* MSVCRT_realloc(void* ptr, MSVCRT_size_t size)
+{
+  dprintf(("MSVCRT_realloc %x",ptr));
+  return HeapReAlloc(GetProcessHeap(), 0, ptr, size);
+}
Index: trunk/src/msvcrt/lconv.c
===================================================================
--- trunk/src/msvcrt/lconv.c	(revision 9633)
+++ trunk/src/msvcrt/lconv.c	(revision 9633)
@@ -0,0 +1,37 @@
+/*
+ * msvcrt.dll lconv functions
+ *
+ * Copyright 2002 Uwe Bonnes
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * NOTE: just stubs for now 020325
+ */
+#ifdef __WIN32OS2__
+#include <winbase.h>
+#endif
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
+
+
+/*********************************************************************
+ *		__lconv_init (MSVCRT.@)
+ */
+void __lconv_init(void)
+{
+  FIXME(" stub\n");
+}
Index: trunk/src/msvcrt/libs/README
===================================================================
--- trunk/src/msvcrt/libs/README	(revision 9633)
+++ trunk/src/msvcrt/libs/README	(revision 9633)
@@ -0,0 +1,4 @@
+This m.lib is a free math library for *nix. It is a part of Posix/2 project
+and may be distributed freely.
+
+
Index: trunk/src/msvcrt/locale.c
===================================================================
--- trunk/src/msvcrt/locale.c	(revision 9633)
+++ trunk/src/msvcrt/locale.c	(revision 9633)
@@ -0,0 +1,538 @@
+/*
+ * msvcrt.dll locale functions
+ *
+ * Copyright 2000 Jon Griffiths
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#ifndef __WIN32OS2__
+#include "config.h"
+#else
+#include <emxheader.h>
+#endif
+
+#include "wine/port.h"
+
+#include "winbase.h"
+#include "winuser.h"
+
+#include "msvcrt.h"
+#include "msvcrt/locale.h"
+#include "mtdll.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
+
+/* FIXME: Need to hold locale for each LC_* type and aggregate
+ * string to produce lc_all.
+ */
+#define MAX_ELEM_LEN 64 /* Max length of country/language/CP string */
+#define MAX_LOCALE_LENGTH 256
+char MSVCRT_current_lc_all[MAX_LOCALE_LENGTH];
+LCID MSVCRT_current_lc_all_lcid;
+int MSVCRT_current_lc_all_cp;
+
+/* MT */
+#define LOCK_LOCALE   _mlock(_SETLOCALE_LOCK);
+#define UNLOCK_LOCALE _munlock(_SETLOCALE_LOCK);
+
+/* ctype data modified when the locale changes */
+extern WORD MSVCRT__ctype [257];
+extern WORD MSVCRT_current_ctype[257];
+extern WORD* MSVCRT__pctype;
+
+/* mbctype data modified when the locale changes */
+extern int MSVCRT___mb_cur_max;
+extern unsigned char MSVCRT_mbctype[257];
+
+#define MSVCRT_LEADBYTE  0x8000
+
+/* Friendly country strings & iso codes for synonym support.
+ * Based on MS documentation for setlocale().
+ */
+static const char* _country_synonyms[] =
+{
+  "Hong Kong","HK",
+  "Hong-Kong","HK",
+  "New Zealand","NZ",
+  "New-Zealand","NZ",
+  "PR China","CN",
+  "PR-China","CN",
+  "United Kingdom","GB",
+  "United-Kingdom","GB",
+  "Britain","GB",
+  "England","GB",
+  "Great Britain","GB",
+  "United States","US",
+  "United-States","US",
+  "America","US"
+};
+
+/* INTERNAL: Map a synonym to an ISO code */
+static void remap_synonym(char *name)
+{
+  size_t i;
+  for (i = 0; i < sizeof(_country_synonyms)/sizeof(char*); i += 2 )
+  {
+    if (!strcasecmp(_country_synonyms[i],name))
+    {
+      TRACE(":Mapping synonym %s to %s\n",name,_country_synonyms[i+1]);
+      name[0] = _country_synonyms[i+1][0];
+      name[1] = _country_synonyms[i+1][1];
+      name[2] = '\0';
+      return;
+    }
+  }
+}
+
+/* Note: Flags are weighted in order of matching importance */
+#define FOUND_LANGUAGE         0x4
+#define FOUND_COUNTRY          0x2
+#define FOUND_CODEPAGE         0x1
+
+typedef struct {
+  char search_language[MAX_ELEM_LEN];
+  char search_country[MAX_ELEM_LEN];
+  char search_codepage[MAX_ELEM_LEN];
+  char found_language[MAX_ELEM_LEN];
+  char found_country[MAX_ELEM_LEN];
+  char found_codepage[MAX_ELEM_LEN];
+  unsigned int match_flags;
+  LANGID found_lang_id;
+} locale_search_t;
+
+#define CONTINUE_LOOKING TRUE
+#define STOP_LOOKING     FALSE
+
+/* INTERNAL: Get and compare locale info with a given string */
+static int compare_info(LCID lcid, DWORD flags, char* buff, const char* cmp)
+{
+  buff[0] = 0;
+  GetLocaleInfoA(lcid, flags|LOCALE_NOUSEROVERRIDE,buff, MAX_ELEM_LEN);
+  if (!buff[0] || !cmp[0])
+    return 0;
+  /* Partial matches are allowed, e.g. "Germ" matches "Germany" */
+  return !strncasecmp(cmp, buff, strlen(cmp));
+}
+
+static BOOL CALLBACK
+find_best_locale_proc(HMODULE hModule WINE_UNUSED, LPCSTR type WINE_UNUSED,
+                      LPCSTR name WINE_UNUSED, WORD LangID, LONG lParam)
+{
+  locale_search_t *res = (locale_search_t *)lParam;
+  const LCID lcid = MAKELCID(LangID, SORT_DEFAULT);
+  char buff[MAX_ELEM_LEN];
+  unsigned int flags = 0;
+
+  if(PRIMARYLANGID(LangID) == LANG_NEUTRAL)
+    return CONTINUE_LOOKING;
+
+  /* Check Language */
+  if (compare_info(lcid,LOCALE_SISO639LANGNAME,buff,res->search_language) ||
+      compare_info(lcid,LOCALE_SABBREVLANGNAME,buff,res->search_language) ||
+      compare_info(lcid,LOCALE_SENGLANGUAGE,buff,res->search_language))
+  {
+    TRACE(":Found language: %s->%s\n", res->search_language, buff);
+    flags |= FOUND_LANGUAGE;
+    memcpy(res->found_language,res->search_language,MAX_ELEM_LEN);
+  }
+  else if (res->match_flags & FOUND_LANGUAGE)
+  {
+    return CONTINUE_LOOKING;
+  }
+
+  /* Check Country */
+  if (compare_info(lcid,LOCALE_SISO3166CTRYNAME,buff,res->search_country) ||
+      compare_info(lcid,LOCALE_SABBREVCTRYNAME,buff,res->search_country) ||
+      compare_info(lcid,LOCALE_SENGCOUNTRY,buff,res->search_country))
+  {
+    TRACE("Found country:%s->%s\n", res->search_country, buff);
+    flags |= FOUND_COUNTRY;
+    memcpy(res->found_country,res->search_country,MAX_ELEM_LEN);
+  }
+  else if (res->match_flags & FOUND_COUNTRY)
+  {
+    return CONTINUE_LOOKING;
+  }
+
+  /* Check codepage */
+  if (compare_info(lcid,LOCALE_IDEFAULTCODEPAGE,buff,res->search_codepage) ||
+      (compare_info(lcid,LOCALE_IDEFAULTANSICODEPAGE,buff,res->search_codepage)))
+  {
+    TRACE("Found codepage:%s->%s\n", res->search_codepage, buff);
+    flags |= FOUND_CODEPAGE;
+    memcpy(res->found_codepage,res->search_codepage,MAX_ELEM_LEN);
+  }
+  else if (res->match_flags & FOUND_CODEPAGE)
+  {
+    return CONTINUE_LOOKING;
+  }
+
+  if (flags > res->match_flags)
+  {
+    /* Found a better match than previously */
+    res->match_flags = flags;
+    res->found_lang_id = LangID;
+  }
+  if (flags & (FOUND_LANGUAGE & FOUND_COUNTRY & FOUND_CODEPAGE))
+  {
+    TRACE(":found exact locale match\n");
+    return STOP_LOOKING;
+  }
+  return CONTINUE_LOOKING;
+}
+
+extern int atoi(const char *);
+
+/* Internal: Find the LCID for a locale specification */
+static LCID MSVCRT_locale_to_LCID(locale_search_t* locale)
+{
+  LCID lcid;
+  EnumResourceLanguagesA(GetModuleHandleA("KERNEL32"), RT_STRINGA,
+			 (LPCSTR)LOCALE_ILANGUAGE,find_best_locale_proc,
+			 (LONG)locale);
+
+  if (!locale->match_flags)
+    return 0;
+
+  /* If we were given something that didn't match, fail */
+  if (locale->search_country[0] && !(locale->match_flags & FOUND_COUNTRY))
+    return 0;
+
+  lcid =  MAKELCID(locale->found_lang_id, SORT_DEFAULT);
+
+  /* Populate partial locale, translating LCID to locale string elements */
+  if (!locale->found_codepage[0])
+  {
+    /* Even if a codepage is not enumerated for a locale
+     * it can be set if valid */
+    if (locale->search_codepage[0])
+    {
+      if (IsValidCodePage(atoi(locale->search_codepage)))
+        memcpy(locale->found_codepage,locale->search_codepage,MAX_ELEM_LEN);
+      else
+      {
+        /* Special codepage values: OEM & ANSI */
+        if (strcasecmp(locale->search_codepage,"OCP"))
+        {
+          GetLocaleInfoA(lcid, LOCALE_IDEFAULTCODEPAGE,
+                         locale->found_codepage, MAX_ELEM_LEN);
+        }
+        if (strcasecmp(locale->search_codepage,"ACP"))
+        {
+          GetLocaleInfoA(lcid, LOCALE_IDEFAULTANSICODEPAGE,
+                         locale->found_codepage, MAX_ELEM_LEN);
+        }
+        else
+          return 0;
+
+        if (!atoi(locale->found_codepage))
+           return 0;
+      }
+    }
+    else
+    {
+      /* Prefer ANSI codepages if present */
+      GetLocaleInfoA(lcid, LOCALE_IDEFAULTANSICODEPAGE,
+                     locale->found_codepage, MAX_ELEM_LEN);
+      if (!locale->found_codepage[0] || !atoi(locale->found_codepage))
+          GetLocaleInfoA(lcid, LOCALE_IDEFAULTCODEPAGE,
+                         locale->found_codepage, MAX_ELEM_LEN);
+    }
+  }
+  GetLocaleInfoA(lcid, LOCALE_SENGLANGUAGE|LOCALE_NOUSEROVERRIDE,
+                 locale->found_language, MAX_ELEM_LEN);
+  GetLocaleInfoA(lcid, LOCALE_SENGCOUNTRY|LOCALE_NOUSEROVERRIDE,
+                 locale->found_country, MAX_ELEM_LEN);
+  return lcid;
+}
+
+extern int snprintf(char *, int, const char *, ...);
+
+/* INTERNAL: Set ctype behaviour for a codepage */
+static void msvcrt_set_ctype(unsigned int codepage, LCID lcid)
+{
+  CPINFO cp;
+
+  memset(&cp, 0, sizeof(CPINFO));
+
+  if (GetCPInfo(codepage, &cp))
+  {
+    int i;
+    char str[3];
+    unsigned char *traverse = (unsigned char *)cp.LeadByte;
+
+    memset(MSVCRT_current_ctype, 0, sizeof(MSVCRT__ctype));
+    MSVCRT_current_lc_all_cp = codepage;
+
+    /* Switch ctype macros to MBCS if needed */
+    MSVCRT___mb_cur_max = cp.MaxCharSize;
+
+    /* Set remaining ctype flags: FIXME: faster way to do this? */
+    str[1] = str[2] = 0;
+    for (i = 0; i < 256; i++)
+    {
+      if (!(MSVCRT__pctype[i] & MSVCRT_LEADBYTE))
+      {
+        str[0] = i;
+        GetStringTypeA(lcid, CT_CTYPE1, str, 1, MSVCRT__pctype + i);
+      }
+    }
+
+    /* Set leadbyte flags */
+    while (traverse[0] || traverse[1])
+    {
+      for( i = traverse[0]; i <= traverse[1]; i++ )
+        MSVCRT_current_ctype[i+1] |= MSVCRT_LEADBYTE;
+      traverse += 2;
+    };
+  }
+}
+
+
+/*********************************************************************
+ *		setlocale (MSVCRT.@)
+ */
+char* MSVCRT_setlocale(int category, const char* locale)
+{
+  LCID lcid = 0;
+  locale_search_t lc;
+  int haveLang, haveCountry, haveCP;
+  char* next;
+  int lc_all = 0;
+
+  TRACE("(%d %s)\n",category,locale);
+
+  if (category < MSVCRT_LC_MIN || category > MSVCRT_LC_MAX)
+    return NULL;
+
+  if (locale == NULL)
+  {
+    /* Report the current Locale */
+    return MSVCRT_current_lc_all;
+  }
+
+  LOCK_LOCALE;
+
+  if (locale[0] == 'L' && locale[1] == 'C' && locale[2] == '_')
+  {
+    FIXME(":restore previous locale not implemented!\n");
+    /* FIXME: Easiest way to do this is parse the string and
+     * call this function recursively with its elements,
+     * Where they differ for each lc_ type.
+     */
+    UNLOCK_LOCALE;
+    return MSVCRT_current_lc_all;
+  }
+
+  /* Default Locale: Special case handling */
+  if (!strlen(locale) || ((toupper(locale[0]) == 'C') && !locale[1]))
+  {
+    MSVCRT_current_lc_all[0] = 'C';
+    MSVCRT_current_lc_all[1] = '\0';
+    MSVCRT_current_lc_all_cp = GetACP();
+
+    switch (category) {
+    case MSVCRT_LC_ALL:
+      lc_all = 1; /* Fall through all cases ... */
+    case MSVCRT_LC_COLLATE:
+      if (!lc_all) break;
+    case MSVCRT_LC_CTYPE:
+      /* Restore C locale ctype info */
+      MSVCRT___mb_cur_max = 1;
+      memcpy(MSVCRT_current_ctype, MSVCRT__ctype, sizeof(MSVCRT__ctype));
+      memset(MSVCRT_mbctype, 0, sizeof(MSVCRT_mbctype));
+      if (!lc_all) break;
+    case MSVCRT_LC_MONETARY:
+      if (!lc_all) break;
+    case MSVCRT_LC_NUMERIC:
+      if (!lc_all) break;
+    case MSVCRT_LC_TIME:
+      break;
+    }
+    UNLOCK_LOCALE;
+    return MSVCRT_current_lc_all;
+  }
+
+  /* Get locale elements */
+  haveLang = haveCountry = haveCP = 0;
+  memset(&lc,0,sizeof(lc));
+
+  next = strchr(locale,'_');
+  if (next && next != locale)
+  {
+    haveLang = 1;
+    strncpy(lc.search_language,locale,next-locale);
+    locale += next-locale+1;
+  }
+
+  next = strchr(locale,'.');
+  if (next)
+  {
+    haveCP = 1;
+    if (next == locale)
+    {
+      locale++;
+      strncpy(lc.search_codepage, locale, MAX_ELEM_LEN);
+    }
+    else
+    {
+      if (haveLang)
+      {
+        haveCountry = 1;
+        strncpy(lc.search_country,locale,next-locale);
+        locale += next-locale+1;
+      }
+      else
+      {
+        haveLang = 1;
+        strncpy(lc.search_language,locale,next-locale);
+        locale += next-locale+1;
+      }
+      strncpy(lc.search_codepage, locale, MAX_ELEM_LEN);
+    }
+  }
+  else
+  {
+    if (haveLang)
+    {
+      haveCountry = 1;
+      strncpy(lc.search_country, locale, MAX_ELEM_LEN);
+    }
+    else
+    {
+      haveLang = 1;
+      strncpy(lc.search_language, locale, MAX_ELEM_LEN);
+    }
+  }
+
+  if (haveCountry)
+    remap_synonym(lc.search_country);
+
+  if (haveCP && !haveCountry && !haveLang)
+  {
+    FIXME(":Codepage only locale not implemented\n");
+    /* FIXME: Use default lang/country and skip locale_to_LCID()
+     * call below...
+     */
+    UNLOCK_LOCALE;
+    return NULL;
+  }
+
+  lcid = MSVCRT_locale_to_LCID(&lc);
+
+  TRACE(":found LCID %ld\n",lcid);
+
+  if (lcid == 0)
+  {
+    UNLOCK_LOCALE;
+    return NULL;
+  }
+
+  MSVCRT_current_lc_all_lcid = lcid;
+
+  snprintf(MSVCRT_current_lc_all,MAX_LOCALE_LENGTH,"%s_%s.%s",
+	   lc.found_language,lc.found_country,lc.found_codepage);
+
+  switch (category) {
+  case MSVCRT_LC_ALL:
+    lc_all = 1; /* Fall through all cases ... */
+  case MSVCRT_LC_COLLATE:
+    if (!lc_all) break;
+  case MSVCRT_LC_CTYPE:
+    msvcrt_set_ctype(atoi(lc.found_codepage),lcid);
+    if (!lc_all) break;
+  case MSVCRT_LC_MONETARY:
+    if (!lc_all) break;
+  case MSVCRT_LC_NUMERIC:
+    if (!lc_all) break;
+  case MSVCRT_LC_TIME:
+    break;
+  }
+  UNLOCK_LOCALE;
+  return MSVCRT_current_lc_all;
+}
+
+
+/*********************************************************************
+ *		_Getdays (MSVCRT.@)
+ */
+const char* _Getdays(void)
+{
+  static const char *MSVCRT_days = ":Sun:Sunday:Mon:Monday:Tue:Tuesday:Wed:"
+                            "Wednesday:Thu:Thursday:Fri:Friday:Sat:Saturday";
+  /* FIXME: Use locale */
+  TRACE("(void) semi-stub\n");
+  return MSVCRT_days;
+}
+
+/*********************************************************************
+ *		_Getmonths (MSVCRT.@)
+ */
+const char* _Getmonths(void)
+{
+  static const char *MSVCRT_months = ":Jan:January:Feb:February:Mar:March:Apr:"
+                "April:May:May:Jun:June:Jul:July:Aug:August:Sep:September:Oct:"
+                "October:Nov:November:Dec:December";
+  /* FIXME: Use locale */
+  TRACE("(void) semi-stub\n");
+  return MSVCRT_months;
+}
+
+/*********************************************************************
+ *		_Getnames (MSVCRT.@)
+ */
+const char* _Getnames(void)
+{
+  /* FIXME: */
+  TRACE("(void) stub\n");
+  return "";
+}
+
+/*********************************************************************
+ *		_Strftime (MSVCRT.@)
+ */
+const char* _Strftime(char *out, unsigned int len, const char *fmt,
+                                     const void *tm, void *foo)
+{
+  /* FIXME: */
+  TRACE("(%p %d %s %p %p) stub\n", out, len, fmt, tm, foo);
+  return "";
+}
+
+/* FIXME: MBCP probably belongs in mbcs.c */
+
+/*********************************************************************
+ *		_setmbcp (MSVCRT.@)
+ */
+void _setmbcp(int cp)
+{
+  LOCK_LOCALE;
+  if (MSVCRT_current_lc_all_cp != cp)
+  {
+    /* FIXME: set ctype behaviour for this cp */
+    MSVCRT_current_lc_all_cp = cp;
+  }
+  UNLOCK_LOCALE;
+}
+
+/*********************************************************************
+ *		_getmbcp (MSVCRT.@)
+ */
+int _getmbcp(void)
+{
+  return MSVCRT_current_lc_all_cp;
+}
Index: trunk/src/msvcrt/lock.c
===================================================================
--- trunk/src/msvcrt/lock.c	(revision 9633)
+++ trunk/src/msvcrt/lock.c	(revision 9633)
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2002, TransGaming Technologies Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#include "winbase.h"
+#include "mtdll.h"
+
+#include "wine/debug.h"
+
+
+WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
+
+typedef struct
+{
+  BOOL             bInit;
+  CRITICAL_SECTION crit;
+} LOCKTABLEENTRY;
+
+static LOCKTABLEENTRY lock_table[ _TOTAL_LOCKS ];
+
+static inline void msvcrt_mlock_set_entry_initialized( int locknum, BOOL initialized )
+{
+  lock_table[ locknum ].bInit = initialized;
+}
+
+static inline void msvcrt_initialize_mlock( int locknum )
+{
+  InitializeCriticalSection( &(lock_table[ locknum ].crit) );
+  msvcrt_mlock_set_entry_initialized( locknum, TRUE );
+}
+
+static inline void msvcrt_uninitialize_mlock( int locknum )
+{
+  DeleteCriticalSection( &(lock_table[ locknum ].crit) );
+  msvcrt_mlock_set_entry_initialized( locknum, FALSE );
+}
+
+/**********************************************************************
+ *     msvcrt_init_mt_locks (internal)
+ *
+ * Initialize the table lock. All other locks will be initialized
+ * upon first use.
+ *
+ */
+void msvcrt_init_mt_locks(void)
+{
+  int i;
+
+  TRACE( "initializing mtlocks\n" );
+
+  /* Initialize the table */
+  for( i=0; i < _TOTAL_LOCKS; i++ )
+  {
+    msvcrt_mlock_set_entry_initialized( i, FALSE );
+  }
+
+  /* Initialize our lock table lock */
+  msvcrt_initialize_mlock( _LOCKTAB_LOCK );
+}
+
+/**********************************************************************
+ *     msvcrt_free_mt_locks (internal)
+ *
+ * Uninitialize all mt locks. Assume that neither _lock or _unlock will
+ * be called once we're calling this routine (ie _LOCKTAB_LOCK can be deleted)
+ *
+ */
+void msvcrt_free_mt_locks(void)
+{
+  int i;
+
+  TRACE( ": uninitializing all mtlocks\n" );
+
+  /* Uninitialize the table */
+  for( i=0; i < _TOTAL_LOCKS; i++ )
+  {
+    if( lock_table[ i ].bInit == TRUE )
+    {
+      msvcrt_uninitialize_mlock( i );
+    }
+  }
+}
+
+
+/**********************************************************************
+ *              _lock (MSVCRT.@)
+ */
+void _lock( int locknum )
+{
+  TRACE( "(%d)\n", locknum );
+
+  /* If the lock doesn't exist yet, create it */
+  if( lock_table[ locknum ].bInit == FALSE )
+  {
+    /* Lock while we're changing the lock table */
+    _lock( _LOCKTAB_LOCK );
+
+    /* Check again if we've got a bit of a race on lock creation */
+    if( lock_table[ locknum ].bInit == FALSE )
+    {
+      TRACE( ": creating lock #%d\n", locknum );
+      msvcrt_initialize_mlock( locknum );
+    }
+
+    /* Unlock ourselves */
+    _unlock( _LOCKTAB_LOCK );
+  }
+
+  EnterCriticalSection( &(lock_table[ locknum ].crit) );
+}
+
+/**********************************************************************
+ *              _unlock (MSVCRT.@)
+ *
+ * NOTE: There is no error detection to make sure the lock exists and is acquired.
+ */
+void _unlock( int locknum )
+{
+  TRACE( "(%d)\n", locknum );
+
+  LeaveCriticalSection( &(lock_table[ locknum ].crit) );
+}
+
Index: trunk/src/msvcrt/main.c
===================================================================
--- trunk/src/msvcrt/main.c	(revision 9633)
+++ trunk/src/msvcrt/main.c	(revision 9633)
@@ -0,0 +1,204 @@
+/*
+ * msvcrt.dll initialisation functions
+ *
+ * Copyright 2000 Jon Griffiths
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#include "msvcrt.h"
+#define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF)
+#include "msvcrt/locale.h"
+#include "msvcrt/stdio.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
+
+/* Index to TLS */
+DWORD MSVCRT_tls_index;
+
+static inline BOOL msvcrt_init_tls(void);
+static inline BOOL msvcrt_free_tls(void);
+const char* msvcrt_get_reason(DWORD reason) WINE_UNUSED;
+
+typedef void* (*MSVCRT_malloc_func)(unsigned int);
+typedef void (*MSVCRT_free_func)(void*);
+
+int _CRT_init (void);
+void _CRT_term (void);
+void __ctordtorInit (void);
+void __ctordtorTerm (void);
+
+static HMODULE dllHandle = 0;
+
+BOOL WINAPI MSVCRT_Init(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
+
+
+unsigned long _DLL_InitTerm (unsigned long mod_handle,
+                                unsigned long flag)
+{
+  switch (flag)
+    {
+       case 0:
+         if (_CRT_init () != 0)
+           return 0;
+         __ctordtorInit ();
+
+         dllHandle = RegisterLxDll(mod_handle, MSVCRT_Init, 0,0,0,0);
+
+        return 1;
+       case 1:
+         __ctordtorTerm ();
+         _CRT_term ();
+
+         if(dllHandle) {
+             UnregisterLxDll(dllHandle);
+         }
+
+         return 1;
+       default:
+         return 0;
+       }
+     return 1;
+   }
+
+/*********************************************************************
+ *                  Init
+ */
+BOOL WINAPI MSVCRT_Init(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+  MSVCRT_thread_data *tls;
+
+  TRACE("(0x%08x, %s, %p) pid(%ld), tid(%ld), tls(%ld)\n",
+        hinstDLL, msvcrt_get_reason(fdwReason), lpvReserved,
+        (long)GetCurrentProcessId(), (long)GetCurrentThreadId(),
+        (long)MSVCRT_tls_index);
+
+  switch (fdwReason)
+  {
+  case DLL_PROCESS_ATTACH:
+    if (!msvcrt_init_tls())
+      return FALSE;
+    msvcrt_init_mt_locks();
+    msvcrt_init_vtables();
+    msvcrt_init_io();
+    msvcrt_init_console();
+    msvcrt_init_args();
+    MSVCRT_setlocale(0, "C");
+    TRACE("finished process init\n");
+    break;
+  case DLL_THREAD_ATTACH:
+    break;
+  case DLL_PROCESS_DETACH:
+    msvcrt_free_mt_locks();
+    msvcrt_free_io();
+    msvcrt_free_console();
+    msvcrt_free_args();
+    if (!msvcrt_free_tls())
+      return FALSE;
+    TRACE("finished process free\n");
+    break;
+  case DLL_THREAD_DETACH:
+    /* Free TLS */
+    tls = TlsGetValue(MSVCRT_tls_index);
+    if (tls) HeapFree(GetProcessHeap(), 0, tls);
+    TRACE("finished thread free\n");
+    break;
+  }
+  return TRUE;
+}
+
+static inline BOOL msvcrt_init_tls(void)
+{
+  MSVCRT_tls_index = TlsAlloc();
+
+  if (MSVCRT_tls_index == TLS_OUT_OF_INDEXES)
+  {
+    ERR("TlsAlloc() failed!\n");
+    return FALSE;
+  }
+  return TRUE;
+}
+
+static inline BOOL msvcrt_free_tls(void)
+{
+  if (!TlsFree(MSVCRT_tls_index))
+  {
+    ERR("TlsFree() failed!\n");
+    return FALSE;
+  }
+  return TRUE;
+}
+
+const char* msvcrt_get_reason(DWORD reason)
+{
+  switch (reason)
+  {
+  case DLL_PROCESS_ATTACH: return "DLL_PROCESS_ATTACH";
+  case DLL_PROCESS_DETACH: return "DLL_PROCESS_DETACH";
+  case DLL_THREAD_ATTACH:  return "DLL_THREAD_ATTACH";
+  case DLL_THREAD_DETACH:  return "DLL_THREAD_DETACH";
+  }
+  return "UNKNOWN";
+}
+
+
+/*********************************************************************
+ *		$I10_OUTPUT (MSVCRT.@)
+ * Function not really understood but needed to make the DLL work
+ */
+void MSVCRT_I10_OUTPUT(void)
+{
+  /* FIXME: This is probably data, not a function */
+}
+
+
+/*********************************************************************
+ *		__unDName (MSVCRT.@)
+ * Function not really understood but needed to make the DLL work
+ */
+char* MSVCRT___unDName(int unknown, const char* mangled,
+                       MSVCRT_malloc_func memget,
+                       MSVCRT_free_func memfree,
+                       unsigned int flags)
+{
+  char* ret;
+
+  FIXME("(%d,%s,%p,%p,%x) stub!\n", unknown, mangled, memget, memfree, flags);
+
+  /* Experimentation reveals the following flag meanings when set:
+   * 0x0001 - Dont show __ in calling convention
+   * 0x0002 - Dont show calling convention at all
+   * 0x0004 - Dont show function/method return value
+   * 0x0010 - Same as 0x1
+   * 0x0080 - Dont show access specifier (public/protected/private)
+   * 0x0200 - Dont show static specifier
+   * 0x1000 - Only report the variable/class name
+   */
+  /* Duplicate the mangled name; for comparisons it doesn't matter anyway */
+  ret = memget(strlen(mangled) + 1);
+  strcpy(ret, mangled);
+  return ret;
+}
+
+
+/*********************************************************************
+ *		__unDNameEx (MSVCRT.@)
+ * Function not really understood but needed to make the DLL work
+ */
+char* MSVCRT___unDNameEx(void)
+{
+   return NULL;
+}
Index: trunk/src/msvcrt/mainmsvcrt20.c
===================================================================
--- trunk/src/msvcrt/mainmsvcrt20.c	(revision 9633)
+++ trunk/src/msvcrt/mainmsvcrt20.c	(revision 9633)
@@ -0,0 +1,85 @@
+/*
+ * msvcrt.dll initialisation functions
+ *
+ * Copyright 2000 Jon Griffiths
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#include "msvcrt.h"
+#define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF)
+#include "msvcrt/locale.h"
+#include "msvcrt/stdio.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
+
+/* Index to TLS */
+DWORD MSVCRT_tls_index;
+
+static inline BOOL msvcrt_init_tls(void);
+static inline BOOL msvcrt_free_tls(void);
+const char* msvcrt_get_reason(DWORD reason) WINE_UNUSED;
+
+typedef void* (*MSVCRT_malloc_func)(unsigned int);
+typedef void (*MSVCRT_free_func)(void*);
+
+int _CRT_init (void);
+void _CRT_term (void);
+void __ctordtorInit (void);
+void __ctordtorTerm (void);
+
+static HMODULE dllHandle = 0;
+
+BOOL WINAPI MSVCRT20_Init(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
+
+
+unsigned long _DLL_InitTerm (unsigned long mod_handle,
+                                unsigned long flag)
+{
+  switch (flag)
+    {
+       case 0:
+         if (_CRT_init () != 0)
+           return 0;
+         __ctordtorInit ();
+
+         dllHandle = RegisterLxDll(mod_handle, MSVCRT20_Init, 0,0,0,0);
+
+        return 1;
+       case 1:
+         __ctordtorTerm ();
+         _CRT_term ();
+
+         if(dllHandle) {
+             UnregisterLxDll(dllHandle);
+         }
+
+         return 1;
+       default:
+         return 0;
+       }
+     return 1;
+   }
+
+/*********************************************************************
+ *                  Init
+ */
+BOOL WINAPI MSVCRT20_Init(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+ return MSVCRT_Init(hinstDLL, fdwReason, lpvReserved);
+}
+ 
+
Index: trunk/src/msvcrt/mainmsvcrt40.c
===================================================================
--- trunk/src/msvcrt/mainmsvcrt40.c	(revision 9633)
+++ trunk/src/msvcrt/mainmsvcrt40.c	(revision 9633)
@@ -0,0 +1,85 @@
+/*
+ * msvcrt.dll initialisation functions
+ *
+ * Copyright 2000 Jon Griffiths
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#include "msvcrt.h"
+#define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF)
+#include "msvcrt/locale.h"
+#include "msvcrt/stdio.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
+
+/* Index to TLS */
+DWORD MSVCRT_tls_index;
+
+static inline BOOL msvcrt_init_tls(void);
+static inline BOOL msvcrt_free_tls(void);
+const char* msvcrt_get_reason(DWORD reason) WINE_UNUSED;
+
+typedef void* (*MSVCRT_malloc_func)(unsigned int);
+typedef void (*MSVCRT_free_func)(void*);
+
+int _CRT_init (void);
+void _CRT_term (void);
+void __ctordtorInit (void);
+void __ctordtorTerm (void);
+
+static HMODULE dllHandle = 0;
+
+BOOL WINAPI MSVCRT40_Init(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
+
+
+unsigned long _DLL_InitTerm (unsigned long mod_handle,
+                                unsigned long flag)
+{
+  switch (flag)
+    {
+       case 0:
+         if (_CRT_init () != 0)
+           return 0;
+         __ctordtorInit ();
+
+         dllHandle = RegisterLxDll(mod_handle, MSVCRT40_Init, 0,0,0,0);
+
+        return 1;
+       case 1:
+         __ctordtorTerm ();
+         _CRT_term ();
+
+         if(dllHandle) {
+             UnregisterLxDll(dllHandle);
+         }
+
+         return 1;
+       default:
+         return 0;
+       }
+     return 1;
+   }
+
+/*********************************************************************
+ *                  Init
+ */
+BOOL WINAPI MSVCRT40_Init(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+ return MSVCRT_Init(hinstDLL, fdwReason, lpvReserved);
+}
+ 
+
Index: trunk/src/msvcrt/makefile
===================================================================
--- trunk/src/msvcrt/makefile	(revision 9633)
+++ trunk/src/msvcrt/makefile	(revision 9633)
@@ -0,0 +1,37 @@
+# $Id: makefile,v 1.22 2003-01-06 13:26:34 sandervl Exp $
+
+#
+# Odin32 API
+#
+#       msvcrt.dll, msvcrt20.dll and msvcrt40.dll makefile
+#
+
+CCENV = EMX
+
+#
+# Compiler, tools, and interference rules.
+#
+!include ../../makefile.inc
+
+
+#
+# Generic rules which forwards to the real makefiles.
+#   The all rule has to stand alone, else make will make all the rules if it
+#   is invoked without any target.
+#
+_all: all
+
+all clean lib:  # add all common rules here
+    $(MAKE_CMD) -f msvcrt.mak $@
+    $(MAKE_CMD) -f msvcrt20.mak $@
+    $(MAKE_CMD) -f msvcrt40.mak $@
+
+# don't have to make deps more than once.
+dep:
+    $(MAKE_CMD) -f msvcrt.mak $@
+
+
+#
+# Do not includes the common rules.
+#
+
Index: trunk/src/msvcrt/math.c
===================================================================
--- trunk/src/msvcrt/math.c	(revision 9633)
+++ trunk/src/msvcrt/math.c	(revision 9633)
@@ -0,0 +1,1002 @@
+/*
+ * msvcrt.dll math functions
+ *
+ * Copyright 2000 Jon Griffiths
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#ifdef __WIN32OS2__
+#include <emxheader.h>
+#else
+#include "config.h"
+#endif
+
+#include "msvcrt.h"
+#include "msvcrt/errno.h"
+
+#define __USE_ISOC9X 1
+#define __USE_ISOC99 1
+#include <math.h>
+#ifdef HAVE_IEEEFP_H
+#include <ieeefp.h>
+#endif
+
+#include "msvcrt/stdlib.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
+
+#ifndef HAVE_FINITE
+#ifndef finite /* Could be a macro */
+#ifdef isfinite
+#define finite(x) isfinite(x)
+#else
+#define finite(x) (!isnan(x)) /* At least catch some cases */
+#endif
+#endif
+#endif
+
+#ifndef signbit
+#define signbit(x) 0
+#endif
+
+/* fpclass constants */
+#define _FPCLASS_SNAN 1
+#define _FPCLASS_QNAN 2
+#define _FPCLASS_NINF 4
+#define _FPCLASS_NN   8
+#define _FPCLASS_ND   16
+#define _FPCLASS_NZ   32
+#define _FPCLASS_PZ   64
+#define _FPCLASS_PD   128
+#define _FPCLASS_PN   256
+#define _FPCLASS_PINF 512
+
+/* _statusfp bit flags */
+#define _SW_INEXACT    0x1
+#define _SW_UNDERFLOW  0x2
+#define _SW_OVERFLOW   0x4
+#define _SW_ZERODIVIDE 0x8
+#define _SW_INVALID    0x10
+#define _SW_DENORMAL   0x80000
+
+/* _controlfp masks and bitflags - x86 only so far*/
+#ifdef __i386__
+#define _MCW_EM        0x8001f
+#define _EM_INEXACT    0x1
+#define _EM_UNDERFLOW  0x2
+#define _EM_OVERFLOW   0x4
+#define _EM_ZERODIVIDE 0x8
+#define _EM_INVALID    0x10
+
+#define _MCW_RC        0x300
+#define _RC_NEAR       0x0
+#define _RC_DOWN       0x100
+#define _RC_UP         0x200
+#define _RC_CHOP       0x300
+
+#define _MCW_PC        0x30000
+#define _PC_64         0x0
+#define _PC_53         0x10000
+#define _PC_24         0x20000
+
+#define _MCW_IC        0x40000
+#define _IC_AFFINE     0x40000
+#define _IC_PROJECTIVE 0x0
+
+#define _EM_DENORMAL   0x80000
+#endif
+
+typedef struct __MSVCRT_complex
+{
+  double real;
+  double imaginary;
+} MSVCRT_complex;
+
+typedef struct __MSVCRT_exception
+{
+  int type;
+  char *name;
+  double arg1;
+  double arg2;
+  double retval;
+} MSVCRT_exception;
+
+
+typedef int (*MSVCRT_matherr_func)(MSVCRT_exception *);
+
+static MSVCRT_matherr_func MSVCRT_default_matherr_func = NULL;
+
+#if defined(__GNUC__) && defined(__i386__)
+
+#define FPU_DOUBLE(var) double var; \
+  __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var) : )
+#define FPU_DOUBLES(var1,var2) double var1,var2; \
+  __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var2) : ); \
+  __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var1) : )
+
+/*********************************************************************
+ *		_CIacos (MSVCRT.@)
+ */
+double _CIacos(void)
+{
+  FPU_DOUBLE(x);
+  if (x < -1.0 || x > 1.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
+  return acos(x);
+}
+
+/*********************************************************************
+ *		_CIasin (MSVCRT.@)
+ */
+double _CIasin(void)
+{
+  FPU_DOUBLE(x);
+  if (x < -1.0 || x > 1.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
+  return asin(x);
+}
+
+/*********************************************************************
+ *		_CIatan (MSVCRT.@)
+ */
+double _CIatan(void)
+{
+  FPU_DOUBLE(x);
+  if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
+  return atan(x);
+}
+
+/*********************************************************************
+ *		_CIatan2 (MSVCRT.@)
+ */
+double _CIatan2(void)
+{
+  FPU_DOUBLES(x,y);
+  if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
+  return atan2(x,y);
+}
+
+/*********************************************************************
+ *		_CIcos (MSVCRT.@)
+ */
+double _CIcos(void)
+{
+  FPU_DOUBLE(x);
+  if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
+  return cos(x);
+}
+
+/*********************************************************************
+ *		_CIcosh (MSVCRT.@)
+ */
+double _CIcosh(void)
+{
+  FPU_DOUBLE(x);
+  if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
+  return cosh(x);
+}
+
+/*********************************************************************
+ *		_CIexp (MSVCRT.@)
+ */
+double _CIexp(void)
+{
+  FPU_DOUBLE(x);
+  if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
+  return exp(x);
+}
+
+/*********************************************************************
+ *		_CIfmod (MSVCRT.@)
+ */
+double _CIfmod(void)
+{
+  FPU_DOUBLES(x,y);
+  if (!finite(x) || !finite(y)) *MSVCRT__errno() = MSVCRT_EDOM;
+  return fmod(x,y);
+}
+
+/*********************************************************************
+ *		_CIlog (MSVCRT.@)
+ */
+double _CIlog(void)
+{
+  FPU_DOUBLE(x);
+  if (x < 0.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
+  if (x == 0.0) *MSVCRT__errno() = MSVCRT_ERANGE;
+  return log(x);
+}
+
+/*********************************************************************
+ *		_CIlog10 (MSVCRT.@)
+ */
+double _CIlog10(void)
+{
+  FPU_DOUBLE(x);
+  if (x < 0.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
+  if (x == 0.0) *MSVCRT__errno() = MSVCRT_ERANGE;
+  return log10(x);
+}
+
+/*********************************************************************
+ *		_CIpow (MSVCRT.@)
+ */
+double _CIpow(void)
+{
+  double z;
+  FPU_DOUBLES(x,y);
+  /* FIXME: If x < 0 and y is not integral, set EDOM */
+  z = pow(x,y);
+  if (!finite(z)) *MSVCRT__errno() = MSVCRT_EDOM;
+  return z;
+}
+
+/*********************************************************************
+ *		_CIsin (MSVCRT.@)
+ */
+double _CIsin(void)
+{
+  FPU_DOUBLE(x);
+  if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
+  return sin(x);
+}
+
+/*********************************************************************
+ *		_CIsinh (MSVCRT.@)
+ */
+double _CIsinh(void)
+{
+  FPU_DOUBLE(x);
+  if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
+  return sinh(x);
+}
+
+/*********************************************************************
+ *		_CIsqrt (MSVCRT.@)
+ */
+double _CIsqrt(void)
+{
+  FPU_DOUBLE(x);
+  if (x < 0.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
+  return sqrt(x);
+}
+
+/*********************************************************************
+ *		_CItan (MSVCRT.@)
+ */
+double _CItan(void)
+{
+  FPU_DOUBLE(x);
+  if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
+  return tan(x);
+}
+
+/*********************************************************************
+ *		_CItanh (MSVCRT.@)
+ */
+double _CItanh(void)
+{
+  FPU_DOUBLE(x);
+  if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
+  return tanh(x);
+}
+
+#else /* defined(__GNUC__) && defined(__i386__) */
+
+/* The above cannot be called on non x86 platforms, stub them for linking */
+
+#define IX86_ONLY(func) double func(void) { return 0.0; }
+
+IX86_ONLY(_CIacos)
+IX86_ONLY(_CIasin)
+IX86_ONLY(_CIatan)
+IX86_ONLY(_CIatan2)
+IX86_ONLY(_CIcos)
+IX86_ONLY(_CIcosh)
+IX86_ONLY(_CIexp)
+IX86_ONLY(_CIfmod)
+IX86_ONLY(_CIlog)
+IX86_ONLY(_CIlog10)
+IX86_ONLY(_CIpow)
+IX86_ONLY(_CIsin)
+IX86_ONLY(_CIsinh)
+IX86_ONLY(_CIsqrt)
+IX86_ONLY(_CItan)
+IX86_ONLY(_CItanh)
+
+#endif /* defined(__GNUC__) && defined(__i386__) */
+
+/*********************************************************************
+ *		_fpclass (MSVCRT.@)
+ */
+int _fpclass(double num)
+{
+#if defined(HAVE_FPCLASS) || defined(fpclass)
+  switch (fpclass( num ))
+  {
+  case FP_SNAN:  return _FPCLASS_SNAN;
+  case FP_QNAN:  return _FPCLASS_QNAN;
+  case FP_NINF:  return _FPCLASS_NINF;
+  case FP_PINF:  return _FPCLASS_PINF;
+  case FP_NDENORM: return _FPCLASS_ND;
+  case FP_PDENORM: return _FPCLASS_PD;
+  case FP_NZERO: return _FPCLASS_NZ;
+  case FP_PZERO: return _FPCLASS_PZ;
+  case FP_NNORM: return _FPCLASS_NN;
+  case FP_PNORM: return _FPCLASS_PN;
+  }
+  return _FPCLASS_PN;
+#elif defined (fpclassify)
+  switch (fpclassify( num ))
+  {
+  case FP_NAN: return _FPCLASS_QNAN;
+  case FP_INFINITE: return signbit(num) ? _FPCLASS_NINF : _FPCLASS_PINF;
+  case FP_SUBNORMAL: return signbit(num) ?_FPCLASS_ND : _FPCLASS_PD;
+  case FP_ZERO: return signbit(num) ? _FPCLASS_NZ : _FPCLASS_PZ;
+  }
+  return signbit(num) ? _FPCLASS_NN : _FPCLASS_PN;
+#else
+  if (!finite(num))
+    return _FPCLASS_QNAN;
+  return num == 0.0 ? _FPCLASS_PZ : (num < 0 ? _FPCLASS_NN : _FPCLASS_PN);
+#endif
+}
+
+/*********************************************************************
+ *		_rotl (MSVCRT.@)
+ */
+unsigned int _rotl(unsigned int num, int shift)
+{
+  shift &= 31;
+  return (num << shift) | (num >> (32-shift));
+}
+
+/*********************************************************************
+ *		_logb (MSVCRT.@)
+ */
+double _logb(double num)
+{
+  if (!finite(num)) *MSVCRT__errno() = MSVCRT_EDOM;
+  return logb(num);
+}
+
+/*********************************************************************
+ *		_lrotl (MSVCRT.@)
+ */
+unsigned long _lrotl(unsigned long num, int shift)
+{
+  shift &= 0x1f;
+  return (num << shift) | (num >> (32-shift));
+}
+
+/*********************************************************************
+ *		_lrotr (MSVCRT.@)
+ */
+unsigned long _lrotr(unsigned long num, int shift)
+{
+  shift &= 0x1f;
+  return (num >> shift) | (num << (32-shift));
+}
+
+/*********************************************************************
+ *		_rotr (MSVCRT.@)
+ */
+unsigned int _rotr(unsigned int num, int shift)
+{
+    shift &= 0x1f;
+    return (num >> shift) | (num << (32-shift));
+}
+
+/*********************************************************************
+ *		_scalb (MSVCRT.@)
+ */
+double _scalb(double num, long power)
+{
+  /* Note - Can't forward directly as libc expects y as double */
+  double dblpower = (double)power;
+  if (!finite(num)) *MSVCRT__errno() = MSVCRT_EDOM;
+  return scalb(num, dblpower);
+}
+
+/*********************************************************************
+ *		_matherr (MSVCRT.@)
+ */
+int _matherr(MSVCRT_exception *e)
+{
+  if (e)
+    TRACE("(%p = %d, %s, %g %g %g)\n",e, e->type, e->name, e->arg1, e->arg2,
+          e->retval);
+  else
+    TRACE("(null)\n");
+  if (MSVCRT_default_matherr_func)
+    return MSVCRT_default_matherr_func(e);
+  ERR(":Unhandled math error!\n");
+  return 0;
+}
+
+/*********************************************************************
+ *		__setusermatherr (MSVCRT.@)
+ */
+void MSVCRT___setusermatherr(MSVCRT_matherr_func func)
+{
+  MSVCRT_default_matherr_func = func;
+  TRACE(":new matherr handler %p\n", func);
+}
+
+/**********************************************************************
+ *		_statusfp (MSVCRT.@)
+ */
+unsigned int _statusfp(void)
+{
+   unsigned int retVal = 0;
+#if defined(__GNUC__) && defined(__i386__)
+  unsigned int fpword;
+
+  __asm__ __volatile__( "fstsw %0" : "=m" (fpword) : );
+  if (fpword & 0x1)  retVal |= _SW_INVALID;
+  if (fpword & 0x2)  retVal |= _SW_DENORMAL;
+  if (fpword & 0x4)  retVal |= _SW_ZERODIVIDE;
+  if (fpword & 0x8)  retVal |= _SW_OVERFLOW;
+  if (fpword & 0x10) retVal |= _SW_UNDERFLOW;
+  if (fpword & 0x20) retVal |= _SW_INEXACT;
+#else
+  FIXME(":Not implemented!\n");
+#endif
+  return retVal;
+}
+
+/*********************************************************************
+ *		_clearfp (MSVCRT.@)
+ */
+unsigned int _clearfp(void)
+{
+  unsigned int retVal = _statusfp();
+#if defined(__GNUC__) && defined(__i386__)
+  __asm__ __volatile__( "fnclex" );
+#else
+  FIXME(":Not Implemented\n");
+#endif
+  return retVal;
+}
+
+/*********************************************************************
+ *		ldexp (MSVCRT.@)
+ */
+double MSVCRT_ldexp(double num, long exp)
+{
+  double z = ldexp(num,exp);
+
+  if (!finite(z))
+    *MSVCRT__errno() = MSVCRT_ERANGE;
+  else if (z == 0 && signbit(z))
+    z = 0.0; /* Convert -0 -> +0 */
+  return z;
+}
+
+/*********************************************************************
+ *		_cabs (MSVCRT.@)
+ */
+double _cabs(MSVCRT_complex num)
+{
+  return sqrt(num.real * num.real + num.imaginary * num.imaginary);
+}
+
+/*********************************************************************
+ *		_chgsign (MSVCRT.@)
+ */
+double _chgsign(double num)
+{
+  /* FIXME: +-infinity,Nan not tested */
+  return -num;
+}
+
+/*********************************************************************
+ *		_control87 (MSVCRT.@)
+ */
+unsigned int _control87(unsigned int newval, unsigned int mask)
+{
+#if defined(__GNUC__) && defined(__i386__)
+  unsigned int fpword = 0;
+  unsigned int flags = 0;
+
+  TRACE("(%08x, %08x): Called\n", newval, mask);
+
+  /* Get fp control word */
+  __asm__ __volatile__( "fstcw %0" : "=m" (fpword) : );
+
+  TRACE("Control word before : %08x\n", fpword);
+
+  /* Convert into mask constants */
+  if (fpword & 0x1)  flags |= _EM_INVALID;
+  if (fpword & 0x2)  flags |= _EM_DENORMAL;
+  if (fpword & 0x4)  flags |= _EM_ZERODIVIDE;
+  if (fpword & 0x8)  flags |= _EM_OVERFLOW;
+  if (fpword & 0x10) flags |= _EM_UNDERFLOW;
+  if (fpword & 0x20) flags |= _EM_INEXACT;
+  switch(fpword & 0xC00) {
+  case 0xC00: flags |= _RC_UP|_RC_DOWN; break;
+  case 0x800: flags |= _RC_UP; break;
+  case 0x400: flags |= _RC_DOWN; break;
+  }
+  switch(fpword & 0x300) {
+  case 0x0:   flags |= _PC_24; break;
+  case 0x200: flags |= _PC_53; break;
+  case 0x300: flags |= _PC_64; break;
+  }
+  if (fpword & 0x1000) flags |= _IC_AFFINE;
+
+  /* Mask with parameters */
+  flags = (flags & ~mask) | (newval & mask);
+
+  /* Convert (masked) value back to fp word */
+  fpword = 0;
+  if (flags & _EM_INVALID)    fpword |= 0x1;
+  if (flags & _EM_DENORMAL)   fpword |= 0x2;
+  if (flags & _EM_ZERODIVIDE) fpword |= 0x4;
+  if (flags & _EM_OVERFLOW)   fpword |= 0x8;
+  if (flags & _EM_UNDERFLOW)  fpword |= 0x10;
+  if (flags & _EM_INEXACT)    fpword |= 0x20;
+  switch(flags & (_RC_UP | _RC_DOWN)) {
+  case _RC_UP|_RC_DOWN: fpword |= 0xC00; break;
+  case _RC_UP:          fpword |= 0x800; break;
+  case _RC_DOWN:        fpword |= 0x400; break;
+  }
+  switch (flags & (_PC_24 | _PC_53)) {
+  case _PC_64: fpword |= 0x300; break;
+  case _PC_53: fpword |= 0x200; break;
+  case _PC_24: fpword |= 0x0; break;
+  }
+  if (flags & _IC_AFFINE) fpword |= 0x1000;
+
+  TRACE("Control word after  : %08x\n", fpword);
+
+  /* Put fp control word */
+  __asm__ __volatile__( "fldcw %0" : : "m" (fpword) );
+
+  return flags;
+#else
+  FIXME(":Not Implemented!\n");
+  return 0;
+#endif
+}
+
+/*********************************************************************
+ *		_controlfp (MSVCRT.@)
+ */
+unsigned int _controlfp(unsigned int newval, unsigned int mask)
+{
+#ifdef __i386__
+  return _control87( newval, mask & ~_EM_DENORMAL );
+#else
+  FIXME(":Not Implemented!\n");
+  return 0;
+#endif
+}
+
+/*********************************************************************
+ *		_copysign (MSVCRT.@)
+ */
+double _copysign(double num, double sign)
+{
+  /* FIXME: Behaviour for Nan/Inf? */
+  if (sign < 0.0)
+    return num < 0.0 ? num : -num;
+  return num < 0.0 ? -num : num;
+}
+
+/*********************************************************************
+ *		_finite (MSVCRT.@)
+ */
+int  _finite(double num)
+{
+  return (finite(num)?1:0); /* See comment for _isnan() */
+}
+
+/*********************************************************************
+ *		_fpreset (MSVCRT.@)
+ */
+void _fpreset(void)
+{
+#if defined(__GNUC__) && defined(__i386__)
+  __asm__ __volatile__( "fninit" );
+#else
+  FIXME(":Not Implemented!\n");
+#endif
+}
+
+/*********************************************************************
+ *		_isnan (MSVCRT.@)
+ */
+INT  _isnan(double num)
+{
+  /* Some implementations return -1 for true(glibc), msvcrt/crtdll return 1.
+   * Do the same, as the result may be used in calculations
+   */
+  return isnan(num) ? 1 : 0;
+}
+
+/*********************************************************************
+ *		_y0 (MSVCRT.@)
+ */
+double _y0(double num)
+{
+  double retval;
+  if (!finite(num)) *MSVCRT__errno() = MSVCRT_EDOM;
+  retval  = y0(num);
+  if (_fpclass(retval) == _FPCLASS_NINF)
+  {
+    *MSVCRT__errno() = MSVCRT_EDOM;
+    retval = sqrt(-1);
+  }
+  return retval;
+}
+
+/*********************************************************************
+ *		_y1 (MSVCRT.@)
+ */
+double _y1(double num)
+{
+  double retval;
+  if (!finite(num)) *MSVCRT__errno() = MSVCRT_EDOM;
+  retval  = y1(num);
+  if (_fpclass(retval) == _FPCLASS_NINF)
+  {
+    *MSVCRT__errno() = MSVCRT_EDOM;
+    retval = sqrt(-1);
+  }
+  return retval;
+}
+
+/*********************************************************************
+ *		_yn (MSVCRT.@)
+ */
+double _yn(int order, double num)
+{
+  double retval;
+  if (!finite(num)) *MSVCRT__errno() = MSVCRT_EDOM;
+  retval  = yn(order,num);
+  if (_fpclass(retval) == _FPCLASS_NINF)
+  {
+    *MSVCRT__errno() = MSVCRT_EDOM;
+    retval = sqrt(-1);
+  }
+  return retval;
+}
+
+/*********************************************************************
+ *		_nextafter (MSVCRT.@)
+ */
+double _nextafter(double num, double next)
+{
+  double retval;
+  if (!finite(num) || !finite(next)) *MSVCRT__errno() = MSVCRT_EDOM;
+  retval = nextafter(num,next);
+  return retval;
+}
+
+#include <stdlib.h> /* div_t, ldiv_t */
+
+/*********************************************************************
+ *		div (MSVCRT.@)
+ * VERSION
+ *	[i386] Windows binary compatible - returns the struct in eax/edx.
+ */
+#ifdef __i386__
+LONGLONG MSVCRT_div(int num, int denom)
+{
+  LONGLONG retval;
+  div_t dt = div(num,denom);
+  retval = ((LONGLONG)dt.rem << 32) | dt.quot;
+  return retval;
+}
+#else
+/*********************************************************************
+ *		div (MSVCRT.@)
+ * VERSION
+ *	[!i386] Non-x86 can't run win32 apps so we don't need binary compatibility
+ */
+MSVCRT_div_t MSVCRT_div(int num, int denom)
+{
+  div_t dt = div(num,denom);
+  MSVCRT_div_t     ret;
+  ret.quot = dt.quot;
+  ret.rem = dt.rem;
+
+  return ret;
+
+}
+#endif /* ifdef __i386__ */
+
+
+/*********************************************************************
+ *		ldiv (MSVCRT.@)
+ * VERSION
+ * 	[i386] Windows binary compatible - returns the struct in eax/edx.
+ */
+#ifdef __i386__
+ULONGLONG MSVCRT_ldiv(long num, long denom)
+{
+  ULONGLONG retval;
+  ldiv_t ldt = ldiv(num,denom);
+  retval = ((ULONGLONG)ldt.rem << 32) | (ULONG)ldt.quot;
+  return retval;
+}
+#else
+/*********************************************************************
+ *		ldiv (MSVCRT.@)
+ * VERSION
+ *	[!i386] Non-x86 can't run win32 apps so we don't need binary compatibility
+ */
+MSVCRT_ldiv_t MSVCRT_ldiv(long num, long denom)
+{
+  ldiv_t result = ldiv(num,denom);
+
+  MSVCRT_ldiv_t ret;
+  ret.quot = result.quot;
+  ret.rem = result.rem;
+
+  return ret;
+}
+#endif /* ifdef __i386__ */
+
+/***********************************************************************
+ *		_adj_fdiv_m16i (MSVCRT.@)
+ * FIXME
+ *    This function is likely to have the wrong number of arguments.
+ *
+ * NOTE
+ *    I _think_ this function is intended to work around the Pentium
+ *    fdiv bug.
+ */
+void _adj_fdiv_m16i(void)
+{
+  TRACE("(): stub\n");
+}
+
+/***********************************************************************
+ *		_adj_fdiv_m32 (MSVCRT.@)
+ * FIXME
+ *    This function is likely to have the wrong number of arguments.
+ *
+ * NOTE
+ *    I _think_ this function is intended to work around the Pentium
+ *    fdiv bug.
+ */
+void _adj_fdiv_m32(void)
+{
+  TRACE("(): stub\n");
+}
+
+/***********************************************************************
+ *		_adj_fdiv_m32i (MSVCRT.@)
+ * FIXME
+ *    This function is likely to have the wrong number of arguments.
+ *
+ * NOTE
+ *    I _think_ this function is intended to work around the Pentium
+ *    fdiv bug.
+ */
+void _adj_fdiv_m32i(void)
+{
+  TRACE("(): stub\n");
+}
+
+/***********************************************************************
+ *		_adj_fdiv_m64 (MSVCRT.@)
+ * FIXME
+ *    This function is likely to have the wrong number of arguments.
+ *
+ * NOTE
+ *    I _think_ this function is intended to work around the Pentium
+ *    fdiv bug.
+ */
+void _adj_fdiv_m64(void)
+{
+  TRACE("(): stub\n");
+}
+
+/***********************************************************************
+ *		_adj_fdiv_r (MSVCRT.@)
+ * FIXME
+ *    This function is likely to have the wrong number of arguments.
+ *
+ * NOTE
+ *    I _think_ this function is intended to work around the Pentium
+ *    fdiv bug.
+ */
+void _adj_fdiv_r(void)
+{
+  TRACE("(): stub\n");
+}
+
+/***********************************************************************
+ *		_adj_fdivr_m16i (MSVCRT.@)
+ * FIXME
+ *    This function is likely to have the wrong number of arguments.
+ *
+ * NOTE
+ *    I _think_ this function is intended to work around the Pentium
+ *    fdiv bug.
+ */
+void _adj_fdivr_m16i(void)
+{
+  TRACE("(): stub\n");
+}
+
+/***********************************************************************
+ *		_adj_fdivr_m32 (MSVCRT.@)
+ * FIXME
+ *    This function is likely to have the wrong number of arguments.
+ *
+ * NOTE
+ *    I _think_ this function is intended to work around the Pentium
+ *    fdiv bug.
+ */
+void _adj_fdivr_m32(void)
+{
+  TRACE("(): stub\n");
+}
+
+/***********************************************************************
+ *		_adj_fdivr_m32i (MSVCRT.@)
+ * FIXME
+ *    This function is likely to have the wrong number of arguments.
+ *
+ * NOTE
+ *    I _think_ this function is intended to work around the Pentium
+ *    fdiv bug.
+ */
+void _adj_fdivr_m32i(void)
+{
+  TRACE("(): stub\n");
+}
+
+/***********************************************************************
+ *		_adj_fdivr_m64 (MSVCRT.@)
+ * FIXME
+ *    This function is likely to have the wrong number of arguments.
+ *
+ * NOTE
+ *    I _think_ this function is intended to work around the Pentium
+ *    fdiv bug.
+ */
+void _adj_fdivr_m64(void)
+{
+  TRACE("(): stub\n");
+}
+
+/***********************************************************************
+ *		_adj_fpatan (MSVCRT.@)
+ * FIXME
+ *    This function is likely to have the wrong number of arguments.
+ *
+ * NOTE
+ *    I _think_ this function is intended to work around the Pentium
+ *    fdiv bug.
+ */
+void _adj_fpatan(void)
+{
+  TRACE("(): stub\n");
+}
+
+/***********************************************************************
+ *		_adj_fprem (MSVCRT.@)
+ * FIXME
+ *    This function is likely to have the wrong number of arguments.
+ *
+ * NOTE
+ *    I _think_ this function is intended to work around the Pentium
+ *    fdiv bug.
+ */
+void _adj_fprem(void)
+{
+  TRACE("(): stub\n");
+}
+
+/***********************************************************************
+ *		_adj_fprem1 (MSVCRT.@)
+ * FIXME
+ *    This function is likely to have the wrong number of arguments.
+ *
+ * NOTE
+ *    I _think_ this function is intended to work around the Pentium
+ *    fdiv bug.
+ */
+void _adj_fprem1(void)
+{
+  TRACE("(): stub\n");
+}
+
+/***********************************************************************
+ *		_adj_fptan (MSVCRT.@)
+ * FIXME
+ *    This function is likely to have the wrong number of arguments.
+ *
+ * NOTE
+ *    I _think_ this function is intended to work around the Pentium
+ *    fdiv bug.
+ */
+void _adj_fptan(void)
+{
+  TRACE("(): stub\n");
+}
+
+/***********************************************************************
+ *		_adjust_fdiv (MSVCRT.@)
+ * FIXME
+ *    I _think_ this function should be a variable indicating whether
+ *    Pentium fdiv bug safe code should be used.
+ */
+void _adjust_fdiv(void)
+{
+  TRACE("(): stub\n");
+}
+
+/***********************************************************************
+ *		_safe_fdiv (MSVCRT.@)
+ * FIXME
+ *    This function is likely to have the wrong number of arguments.
+ *
+ * NOTE
+ *    I _think_ this function is intended to work around the Pentium
+ *    fdiv bug.
+ */
+void _safe_fdiv(void)
+{
+  TRACE("(): stub\n");
+}
+
+/***********************************************************************
+ *		_safe_fdivr (MSVCRT.@)
+ * FIXME
+ *    This function is likely to have the wrong number of arguments.
+ *
+ * NOTE
+ *    I _think_ this function is intended to work around the Pentium
+ *    fdiv bug.
+ */
+void _safe_fdivr(void)
+{
+  TRACE("(): stub\n");
+}
+
+/***********************************************************************
+ *		_safe_fprem (MSVCRT.@)
+ * FIXME
+ *    This function is likely to have the wrong number of arguments.
+ *
+ * NOTE
+ *    I _think_ this function is intended to work around the Pentium
+ *    fdiv bug.
+ */
+void _safe_fprem(void)
+{
+  TRACE("(): stub\n");
+}
+
+/***********************************************************************
+ *		_safe_fprem1 (MSVCRT.@)
+ *
+ * FIXME
+ *    This function is likely to have the wrong number of arguments.
+ *
+ * NOTE
+ *    I _think_ this function is intended to work around the Pentium
+ *    fdiv bug.
+ */
+void _safe_fprem1(void)
+{
+  TRACE("(): stub\n");
+}
Index: trunk/src/msvcrt/mbcs.c
===================================================================
--- trunk/src/msvcrt/mbcs.c	(revision 9633)
+++ trunk/src/msvcrt/mbcs.c	(revision 9633)
@@ -0,0 +1,1032 @@
+/*
+ * msvcrt.dll mbcs functions
+ *
+ * Copyright 1999 Alexandre Julliard
+ * Copyright 2000 Jon Griffths
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * FIXME
+ * Not currently binary compatible with win32. MSVCRT_mbctype must be
+ * populated correctly and the ismb* functions should reference it.
+ */
+
+#include "msvcrt.h"
+
+#include "msvcrt/mbctype.h"
+#include "msvcrt/mbstring.h"
+#include "msvcrt/stdlib.h"
+#include "msvcrt/string.h"
+#include "msvcrt/wctype.h"
+
+#include "wine/unicode.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
+
+unsigned char MSVCRT_mbctype[257];
+int MSVCRT___mb_cur_max = 1;
+
+static MSVCRT_wchar_t msvcrt_mbc_to_wc(unsigned int ch)
+{
+  MSVCRT_wchar_t chW;
+  char mbch[2];
+  int n_chars;
+
+  if (ch <= 0xff) {
+    mbch[0] = ch;
+    n_chars = 1;
+  } else {
+    mbch[0] = (ch >> 8) & 0xff;
+    mbch[1] = ch & 0xff;
+    n_chars = 2;
+  }
+  if (!MultiByteToWideChar(MSVCRT_current_lc_all_cp, 0, mbch, n_chars, &chW, 1))
+  {
+    WARN("MultiByteToWideChar failed on %x\n", ch);
+    return 0;
+  }
+  return chW;
+}
+
+/*********************************************************************
+ *		__p__mbctype (MSVCRT.@)
+ */
+unsigned char* __p__mbctype(void)
+{
+  return MSVCRT_mbctype;
+}
+
+/*********************************************************************
+ *		__p___mb_cur_max(MSVCRT.@)
+ */
+int* __p___mb_cur_max(void)
+{
+  return &MSVCRT___mb_cur_max;
+}
+
+/*********************************************************************
+ *		_mbsnextc(MSVCRT.@)
+ */
+unsigned int _mbsnextc(const unsigned char* str)
+{
+  if(MSVCRT___mb_cur_max > 1 && MSVCRT_isleadbyte(*str))
+    return *str << 8 | str[1];
+  return *str; /* ASCII CP or SB char */
+}
+
+/*********************************************************************
+ *		_mbctolower(MSVCRT.@)
+ */
+unsigned int _mbctolower(unsigned int c)
+{
+    if (MSVCRT_isleadbyte(c))
+    {
+      FIXME("Handle MBC chars\n");
+      return c;
+    }
+    return tolower(c); /* ASCII CP or SB char */
+}
+
+/*********************************************************************
+ *		_mbctoupper(MSVCRT.@)
+ */
+unsigned int _mbctoupper(unsigned int c)
+{
+    if (MSVCRT_isleadbyte(c))
+    {
+      FIXME("Handle MBC chars\n");
+      return c;
+    }
+    return toupper(c); /* ASCII CP or SB char */
+}
+
+/*********************************************************************
+ *		_mbsdec(MSVCRT.@)
+ */
+unsigned char* _mbsdec(const unsigned char* start, const unsigned char* cur)
+{
+  if(MSVCRT___mb_cur_max > 1)
+    return (char *)(_ismbstrail(start,cur-1) ? cur - 2 : cur -1);
+
+  return (char *)cur - 1; /* ASCII CP or SB char */
+}
+
+/*********************************************************************
+ *		_mbsinc(MSVCRT.@)
+ */
+unsigned char* _mbsinc(const unsigned char* str)
+{
+  if(MSVCRT___mb_cur_max > 1 && MSVCRT_isleadbyte(*str))
+    return (unsigned char*)str + 2; /* MB char */
+
+  return (unsigned char*)str + 1; /* ASCII CP or SB char */
+}
+
+/*********************************************************************
+ *		_mbsninc(MSVCRT.@)
+ */
+unsigned char* _mbsninc(const unsigned char* str, MSVCRT_size_t num)
+{
+  if(!str || num < 1)
+    return NULL;
+  if(MSVCRT___mb_cur_max > 1)
+  {
+    while(num--)
+      str = _mbsinc(str);
+    return (unsigned char*)str;
+  }
+  return (unsigned char*)str + num; /* ASCII CP */
+}
+
+/*********************************************************************
+ *		_mbclen(MSVCRT.@)
+ */
+unsigned int _mbclen(const unsigned char* str)
+{
+  return MSVCRT_isleadbyte(*str) ? 2 : 1;
+}
+
+/*********************************************************************
+ *		mblen(MSVCRT.@)
+ */
+int MSVCRT_mblen(const char* str, MSVCRT_size_t size)
+{
+  if (str && *str && size)
+  {
+    if(MSVCRT___mb_cur_max == 1)
+      return 1; /* ASCII CP */
+
+    return !MSVCRT_isleadbyte(*str) ? 1 : (size>1 ? 2 : -1);
+  }
+  return 0;
+}
+
+/*********************************************************************
+ *		_mbslen(MSVCRT.@)
+ */
+MSVCRT_size_t _mbslen(const unsigned char* str)
+{
+  if(MSVCRT___mb_cur_max > 1)
+  {
+    MSVCRT_size_t len = 0;
+    while(*str)
+    {
+      str += MSVCRT_isleadbyte(*str) ? 2 : 1;
+      len++;
+    }
+    return len;
+  }
+  return strlen(str); /* ASCII CP */
+}
+
+/*********************************************************************
+ *		_mbstrlen(MSVCRT.@)
+ */
+MSVCRT_size_t _mbstrlen(const char* str)
+{
+  if(MSVCRT___mb_cur_max > 1)
+  {
+    MSVCRT_size_t len = 0;
+    while(*str)
+    {
+      /* FIXME: According to the documentation we are supposed to test for
+       * multi-byte character validity. Whatever that means
+       */
+      str += MSVCRT_isleadbyte(*str) ? 2 : 1;
+      len++;
+    }
+    return len;
+  }
+  return strlen(str); /* ASCII CP */
+}
+
+/*********************************************************************
+ *		_mbccpy(MSVCRT.@)
+ */
+void _mbccpy(unsigned char* dest, const unsigned char* src)
+{
+  *dest++ = *src;
+  if(MSVCRT___mb_cur_max > 1 && MSVCRT_isleadbyte(*src))
+    *dest = *++src; /* MB char */
+  else
+    ERR("failure.. is this ok?\n");
+}
+
+/*********************************************************************
+ *		_mbsncpy(MSVCRT.@)
+ */
+unsigned char* _mbsncpy(unsigned char* dst, const unsigned char* src, MSVCRT_size_t n)
+{
+  if(!n)
+    return dst;
+  if(MSVCRT___mb_cur_max > 1)
+  {
+    unsigned char* ret = dst;
+    while (*src && n--)
+    {
+      *dst++ = *src;
+      if (MSVCRT_isleadbyte(*src++))
+          *dst++ = *src++;
+    }
+    while(n--)
+      *dst++ = '\0';
+    return ret;
+  }
+  return strncpy(dst, src, n); /* ASCII CP */
+}
+
+/*********************************************************************
+ *              _mbsnbcpy(MSVCRT.@)
+ */
+unsigned char* _mbsnbcpy(unsigned char* dst, const unsigned char* src, MSVCRT_size_t n)
+{
+  if(!n)
+    return dst;
+  if(MSVCRT___mb_cur_max > 1)
+  {
+    unsigned char* ret = dst;
+    while (*src && (n-- > 1))
+    {
+      *dst++ = *src;
+      if (MSVCRT_isleadbyte(*src++))
+      {
+        *dst++ = *src++;
+        n--;
+      }
+    }
+    if (*src && n && !MSVCRT_isleadbyte(*src))
+    {
+      /* If the last character is a multi-byte character then
+       * we cannot copy it since we have only one byte left
+       */
+      *dst++ = *src;
+      n--;
+    }
+    while (n--)
+      *dst++ = '\0';
+    return ret;
+  }
+  return strncpy(dst, src, n); /* ASCII CP */
+}
+
+/*********************************************************************
+ *		_mbscmp(MSVCRT.@)
+ */
+int _mbscmp(const unsigned char* str, const unsigned char* cmp)
+{
+  if(MSVCRT___mb_cur_max > 1)
+  {
+    unsigned int strc, cmpc;
+    do {
+      if(!*str)
+        return *cmp ? -1 : 0;
+      if(!*cmp)
+        return 1;
+      strc = _mbsnextc(str);
+      cmpc = _mbsnextc(cmp);
+      if(strc != cmpc)
+        return strc < cmpc ? -1 : 1;
+      str +=(strc > 255) ? 2 : 1;
+      cmp +=(strc > 255) ? 2 : 1; /* equal, use same increment */
+    } while(1);
+  }
+  return strcmp(str, cmp); /* ASCII CP */
+}
+
+/*********************************************************************
+ *		_mbsicmp(MSVCRT.@)
+ */
+int _mbsicmp(const unsigned char* str, const unsigned char* cmp)
+{
+  if(MSVCRT___mb_cur_max > 1)
+  {
+    unsigned int strc, cmpc;
+    do {
+      if(!*str)
+        return *cmp ? -1 : 0;
+      if(!*cmp)
+        return 1;
+      strc = _mbctolower(_mbsnextc(str));
+      cmpc = _mbctolower(_mbsnextc(cmp));
+      if(strc != cmpc)
+        return strc < cmpc ? -1 : 1;
+      str +=(strc > 255) ? 2 : 1;
+      cmp +=(strc > 255) ? 2 : 1; /* equal, use same increment */
+    } while(1);
+  }
+  return strcasecmp(str, cmp); /* ASCII CP */
+}
+
+/*********************************************************************
+ *		_mbsncmp(MSVCRT.@)
+ */
+int _mbsncmp(const unsigned char* str, const unsigned char* cmp, MSVCRT_size_t len)
+{
+  if(!len)
+    return 0;
+
+  if(MSVCRT___mb_cur_max > 1)
+  {
+    unsigned int strc, cmpc;
+    while(len--)
+    {
+      int inc;
+      if(!*str)
+        return *cmp ? -1 : 0;
+      if(!*cmp)
+        return 1;
+      strc = _mbsnextc(str);
+      cmpc = _mbsnextc(cmp);
+      if(strc != cmpc)
+        return strc < cmpc ? -1 : 1;
+      inc=(strc > 255) ? 2 : 1; /* Equal, use same increment */
+      str += inc;
+      cmp += inc;
+    }
+    return 0; /* Matched len chars */
+  }
+  return strncmp(str, cmp, len); /* ASCII CP */
+}
+
+/*********************************************************************
+ *              _mbsnbcmp(MSVCRT.@)
+ */
+int _mbsnbcmp(const unsigned char* str, const unsigned char* cmp, MSVCRT_size_t len)
+{
+  if (!len)
+    return 0;
+  if(MSVCRT___mb_cur_max > 1)
+  {
+    unsigned int strc, cmpc;
+    while (len)
+    {
+      int clen;
+      if(!*str)
+        return *cmp ? -1 : 0;
+      if(!*cmp)
+        return 1;
+      if (MSVCRT_isleadbyte(*str))
+      {
+        strc=(len>=2)?_mbsnextc(str):0;
+        clen=2;
+      }
+      else
+      {
+        strc=*str;
+        clen=1;
+      }
+      if (MSVCRT_isleadbyte(*cmp))
+        cmpc=(len>=2)?_mbsnextc(cmp):0;
+      else
+        cmpc=*str;
+      if(strc != cmpc)
+        return strc < cmpc ? -1 : 1;
+      len -= clen;
+      str += clen;
+      cmp += clen;
+    }
+    return 0; /* Matched len chars */
+      FIXME("%s %s %d\n",str,cmp,len);
+  }
+  return strncmp(str,cmp,len);
+}
+
+/*********************************************************************
+ *		_mbsnicmp(MSVCRT.@)
+ *
+ * Compare two multibyte strings case insensitively to 'len' characters.
+ */
+int _mbsnicmp(const unsigned char* str, const unsigned char* cmp, MSVCRT_size_t len)
+{
+  /* FIXME: No tolower() for mb strings yet */
+  if(MSVCRT___mb_cur_max > 1)
+  {
+    unsigned int strc, cmpc;
+    while(len--)
+    {
+      if(!*str)
+        return *cmp ? -1 : 0;
+      if(!*cmp)
+        return 1;
+      strc = _mbctolower(_mbsnextc(str));
+      cmpc = _mbctolower(_mbsnextc(cmp));
+      if(strc != cmpc)
+        return strc < cmpc ? -1 : 1;
+      str +=(strc > 255) ? 2 : 1;
+      cmp +=(strc > 255) ? 2 : 1; /* Equal, use same increment */
+    }
+    return 0; /* Matched len chars */
+  }
+  return strncasecmp(str, cmp, len); /* ASCII CP */
+}
+
+/*********************************************************************
+ *              _mbsnbicmp(MSVCRT.@)
+ */
+int _mbsnbicmp(const unsigned char* str, const unsigned char* cmp, MSVCRT_size_t len)
+{
+  if (!len)
+    return 0;
+  if(MSVCRT___mb_cur_max > 1)
+  {
+    unsigned int strc, cmpc;
+    while (len)
+    {
+      int clen;
+      if(!*str)
+        return *cmp ? -1 : 0;
+      if(!*cmp)
+        return 1;
+      if (MSVCRT_isleadbyte(*str))
+      {
+        strc=(len>=2)?_mbsnextc(str):0;
+        clen=2;
+      }
+      else
+      {
+        strc=*str;
+        clen=1;
+      }
+      if (MSVCRT_isleadbyte(*cmp))
+        cmpc=(len>=2)?_mbsnextc(cmp):0;
+      else
+        cmpc=*str;
+      strc = _mbctolower(strc);
+      cmpc = _mbctolower(cmpc);
+      if(strc != cmpc)
+        return strc < cmpc ? -1 : 1;
+      len -= clen;
+      str += clen;
+      cmp += clen;
+    }
+    return 0; /* Matched len bytes */
+      FIXME("%s %s %d\n",str,cmp,len);
+  }
+  return strncmp(str,cmp,len);
+}
+
+/*********************************************************************
+ *		_mbschr(MSVCRT.@)
+ *
+ * Find a multibyte character in a multibyte string.
+ */
+unsigned char* _mbschr(const unsigned char* s, unsigned int x)
+{
+  if(MSVCRT___mb_cur_max > 1)
+  {
+    unsigned int c;
+    while (1)
+    {
+      c = _mbsnextc(s);
+      if (c == x)
+        return (unsigned char*)s;
+      if (!c)
+        return NULL;
+      s += c > 255 ? 2 : 1;
+    }
+  }
+  return strchr(s, x); /* ASCII CP */
+}
+
+/*********************************************************************
+ *		_mbsrchr(MSVCRT.@)
+ */
+unsigned char* _mbsrchr(const unsigned char* s, unsigned int x)
+{
+  if(MSVCRT___mb_cur_max > 1)
+  {
+    unsigned int c;
+    unsigned char* match=NULL;
+    if(!s)
+      return NULL;
+    while (1) {
+      c = _mbsnextc(s);
+      if (c == x)
+        match=(unsigned char*)s;
+      if (!c)
+        return match;
+      s +=(c > 255) ? 2 : 1;
+    }
+  }
+  return strrchr(s,x);
+}
+
+/*********************************************************************
+ *		mbtowc(MSVCRT.@)
+ */
+int MSVCRT_mbtowc(MSVCRT_wchar_t *dst, const char* str, MSVCRT_size_t n)
+{
+  if(n <= 0 || !str)
+    return 0;
+  if(!MultiByteToWideChar(CP_ACP, 0, str, n, dst, 1))
+    return 0;
+  /* return the number of bytes from src that have been used */
+  if(!*str)
+    return 0;
+  if(n >= 2 && MSVCRT_isleadbyte(*str) && str[1])
+    return 2;
+  return 1;
+}
+
+/*********************************************************************
+ *		_mbbtombc(MSVCRT.@)
+ */
+unsigned int _mbbtombc(unsigned int c)
+{
+  if(MSVCRT___mb_cur_max > 1 &&
+     ((c >= 0x20 && c <=0x7e) ||(c >= 0xa1 && c <= 0xdf)))
+  {
+    /* FIXME: I can't get this function to return anything
+     * different to what I pass it...
+     */
+  }
+  return c;  /* ASCII CP or no MB char */
+}
+
+/*********************************************************************
+ *		_ismbbkana(MSVCRT.@)
+ */
+int _ismbbkana(unsigned int c)
+{
+  /* FIXME: use lc_ctype when supported, not lc_all */
+  if(MSVCRT_current_lc_all_cp == 932)
+  {
+    /* Japanese/Katakana, CP 932 */
+    return (c >= 0xa1 && c <= 0xdf);
+  }
+  return 0;
+}
+
+/*********************************************************************
+ *              _ismbcdigit(MSVCRT.@)
+ */
+int _ismbcdigit(unsigned int ch)
+{
+    MSVCRT_wchar_t wch = msvcrt_mbc_to_wc( ch );
+    return (get_char_typeW( wch ) & C1_DIGIT);
+}
+
+/*********************************************************************
+ *              _ismbcgraph(MSVCRT.@)
+ */
+int _ismbcgraph(unsigned int ch)
+{
+    MSVCRT_wchar_t wch = msvcrt_mbc_to_wc( ch );
+    return (get_char_typeW( wch ) & (C1_UPPER | C1_LOWER | C1_DIGIT | C1_PUNCT | C1_ALPHA));
+}
+
+/*********************************************************************
+ *              _ismbcalpha (MSVCRT.@)
+ */
+int _ismbcalpha(unsigned int ch)
+{
+    MSVCRT_wchar_t wch = msvcrt_mbc_to_wc( ch );
+    return (get_char_typeW( wch ) & C1_ALPHA);
+}
+
+/*********************************************************************
+ *              _ismbclower (MSVCRT.@)
+ */
+int _ismbclower(unsigned int ch)
+{
+    MSVCRT_wchar_t wch = msvcrt_mbc_to_wc( ch );
+    return (get_char_typeW( wch ) & C1_UPPER);
+}
+
+/*********************************************************************
+ *              _ismbcupper (MSVCRT.@)
+ */
+int _ismbcupper(unsigned int ch)
+{
+    MSVCRT_wchar_t wch = msvcrt_mbc_to_wc( ch );
+    return (get_char_typeW( wch ) & C1_LOWER);
+}
+
+/*********************************************************************
+ *              _ismbcsymbol(MSVCRT.@)
+ */
+int _ismbcsymbol(unsigned int ch)
+{
+    MSVCRT_wchar_t wch = msvcrt_mbc_to_wc( ch );
+    WORD ctype;
+    if (!GetStringTypeW(CT_CTYPE3, &wch, 1, &ctype))
+    {
+        WARN("GetStringTypeW failed on %x\n", ch);
+        return 0;
+    }
+    return ((ctype & C3_SYMBOL) != 0);
+}
+
+/*********************************************************************
+ *              _ismbcalnum (MSVCRT.@)
+ */
+int _ismbcalnum(unsigned int ch)
+{
+    MSVCRT_wchar_t wch = msvcrt_mbc_to_wc( ch );
+    return (get_char_typeW( wch ) & (C1_ALPHA | C1_DIGIT));
+}
+
+/*********************************************************************
+ *              _ismbcspace (MSVCRT.@)
+ */
+int _ismbcspace(unsigned int ch)
+{
+    MSVCRT_wchar_t wch = msvcrt_mbc_to_wc( ch );
+    return (get_char_typeW( wch ) & C1_SPACE);
+}
+
+/*********************************************************************
+ *              _ismbcprint (MSVCRT.@)
+ */
+int _ismbcprint(unsigned int ch)
+{
+    MSVCRT_wchar_t wch = msvcrt_mbc_to_wc( ch );
+    return (get_char_typeW( wch ) & (C1_UPPER | C1_LOWER | C1_DIGIT | C1_PUNCT | C1_ALPHA | C1_SPACE));
+}
+
+/*********************************************************************
+ *              _ismbcpunct(MSVCRT.@)
+ */
+int _ismbcpunct(unsigned int ch)
+{
+    MSVCRT_wchar_t wch = msvcrt_mbc_to_wc( ch );
+    return (get_char_typeW( wch ) & C1_PUNCT);
+}
+
+/*********************************************************************
+ *		_ismbchira(MSVCRT.@)
+ */
+int _ismbchira(unsigned int c)
+{
+  /* FIXME: use lc_ctype when supported, not lc_all */
+  if(MSVCRT_current_lc_all_cp == 932)
+  {
+    /* Japanese/Hiragana, CP 932 */
+    return (c >= 0x829f && c <= 0x82f1);
+  }
+  return 0;
+}
+
+/*********************************************************************
+ *		_ismbckata(MSVCRT.@)
+ */
+int _ismbckata(unsigned int c)
+{
+  /* FIXME: use lc_ctype when supported, not lc_all */
+  if(MSVCRT_current_lc_all_cp == 932)
+  {
+    if(c < 256)
+      return _ismbbkana(c);
+    /* Japanese/Katakana, CP 932 */
+    return (c >= 0x8340 && c <= 0x8396 && c != 0x837f);
+  }
+  return 0;
+}
+
+/*********************************************************************
+ *		_ismbblead(MSVCRT.@)
+ */
+int _ismbblead(unsigned int c)
+{
+  /* FIXME: should reference MSVCRT_mbctype */
+  return MSVCRT___mb_cur_max > 1 && MSVCRT_isleadbyte(c);
+}
+
+
+/*********************************************************************
+ *		_ismbbtrail(MSVCRT.@)
+ */
+int _ismbbtrail(unsigned int c)
+{
+  /* FIXME: should reference MSVCRT_mbctype */
+  return !_ismbblead(c);
+}
+
+/*********************************************************************
+ *		_ismbslead(MSVCRT.@)
+ */
+int _ismbslead(const unsigned char* start, const unsigned char* str)
+{
+  /* Lead bytes can also be trail bytes if caller messed up
+   * iterating through the string...
+   */
+  if(MSVCRT___mb_cur_max > 1)
+  {
+    while(start < str)
+      start += MSVCRT_isleadbyte(*str) ? 2 : 1;
+
+    if(start == str)
+      return MSVCRT_isleadbyte(*str);
+  }
+  return 0; /* Must have been a trail, we skipped it */
+}
+
+/*********************************************************************
+ *		_ismbstrail(MSVCRT.@)
+ */
+int _ismbstrail(const unsigned char* start, const unsigned char* str)
+{
+  /* Must not be a lead, and must be preceeded by one */
+  return !_ismbslead(start, str) && MSVCRT_isleadbyte(str[-1]);
+}
+
+/*********************************************************************
+ *		_mbsset(MSVCRT.@)
+ */
+unsigned char* _mbsset(unsigned char* str, unsigned int c)
+{
+  unsigned char* ret = str;
+
+  if(MSVCRT___mb_cur_max == 1 || c < 256)
+    return _strset(str, c); /* ASCII CP or SB char */
+
+  c &= 0xffff; /* Strip high bits */
+
+  while(str[0] && str[1])
+  {
+    *str++ = c >> 8;
+    *str++ = c & 0xff;
+  }
+  if(str[0])
+    str[0] = '\0'; /* FIXME: OK to shorten? */
+
+  return ret;
+}
+
+/*********************************************************************
+ *		_mbsnset(MSVCRT.@)
+ */
+unsigned char* _mbsnset(unsigned char* str, unsigned int c, MSVCRT_size_t len)
+{
+  unsigned char *ret = str;
+
+  if(!len)
+    return ret;
+
+  if(MSVCRT___mb_cur_max == 1 || c < 256)
+    return _strnset(str, c, len); /* ASCII CP or SB char */
+
+  c &= 0xffff; /* Strip high bits */
+
+  while(str[0] && str[1] && len--)
+  {
+    *str++ = c >> 8;
+    *str++ = c & 0xff;
+  }
+  if(len && str[0])
+    str[0] = '\0'; /* FIXME: OK to shorten? */
+
+  return ret;
+}
+
+/*********************************************************************
+ *		_mbsnccnt(MSVCRT.@)
+ * 'c' is for 'character'.
+ */
+MSVCRT_size_t _mbsnccnt(const unsigned char* str, MSVCRT_size_t len)
+{
+  MSVCRT_size_t ret;
+  if(MSVCRT___mb_cur_max > 1)
+  {
+    ret=0;
+    while(*str && len-- > 0)
+    {
+      if(MSVCRT_isleadbyte(*str))
+      {
+        if (!len)
+          break;
+        len--;
+        str++;
+      }
+      str++;
+      ret++;
+    }
+    return ret;
+  }
+  ret=strlen(str);
+  return min(ret, len); /* ASCII CP */
+}
+
+/*********************************************************************
+ *		_mbsnbcnt(MSVCRT.@)
+ * 'b' is for byte count.
+ */
+MSVCRT_size_t _mbsnbcnt(const unsigned char* str, MSVCRT_size_t len)
+{
+  MSVCRT_size_t ret;
+  if(MSVCRT___mb_cur_max > 1)
+  {
+    const unsigned char* xstr = str;
+    while(*xstr && len-- > 0)
+    {
+      if (MSVCRT_isleadbyte(*xstr++))
+        xstr++;
+    }
+    return xstr-str;
+  }
+  ret=strlen(str);
+  return min(ret, len); /* ASCII CP */
+}
+
+
+/*********************************************************************
+ *		_mbsncat(MSVCRT.@)
+ */
+unsigned char* _mbsncat(unsigned char* dst, const unsigned char* src, MSVCRT_size_t len)
+{
+  if(MSVCRT___mb_cur_max > 1)
+  {
+    char *res = dst;
+    while (*dst)
+    {
+      if (MSVCRT_isleadbyte(*dst++))
+        dst++;
+    }
+    while (*src && len--)
+    {
+      *dst++ = *src;
+      if(MSVCRT_isleadbyte(*src++))
+        *dst++ = *src++;
+    }
+    *dst = '\0';
+    return res;
+  }
+  return strncat(dst, src, len); /* ASCII CP */
+}
+
+
+/*********************************************************************
+ *              _mbslwr(MSVCRT.@)
+ */
+unsigned char* _mbslwr(unsigned char* s)
+{
+  if (!s)
+    return NULL;
+  if (MSVCRT___mb_cur_max > 1)
+  {
+    unsigned int c;
+    unsigned char* p=s;
+    while (*s)
+    {
+      c = _mbctolower(_mbsnextc(s));
+      /* Note that I assume that the size of the character is unchanged */
+      if (c > 255)
+      {
+          *s++=(c>>8);
+          c=c & 0xff;
+      }
+      *s++=c;
+    }
+    return p;
+  }
+  return _strlwr(s);
+}
+
+
+/*********************************************************************
+ *              _mbsupr(MSVCRT.@)
+ */
+unsigned char* _mbsupr(unsigned char* s)
+{
+  if (!s)
+    return NULL;
+  if (MSVCRT___mb_cur_max > 1)
+  {
+    unsigned int c;
+    unsigned char* p=s;
+    while (*s)
+    {
+      c = _mbctoupper(_mbsnextc(s));
+      /* Note that I assume that the size of the character is unchanged */
+      if (c > 255)
+      {
+          *s++=(c>>8);
+          c=c & 0xff;
+      }
+      *s++=c;
+    }
+    return p;
+  }
+  return _strupr(s);
+}
+
+
+/*********************************************************************
+ *              _mbsspn (MSVCRT.@)
+ */
+MSVCRT_size_t _mbsspn(const unsigned char* string, const unsigned char* set)
+{
+  const unsigned char *p, *q;
+
+  for (p = string; *p; p++)
+    {
+      if (MSVCRT_isleadbyte(*p))
+	{
+	  for (q = set; *q; q++)
+	    {
+	      if (!q[1])
+		break;
+	      if ((*p == *q) &&  (p[1] == q[1]))
+		break;
+	      q++;
+	    }
+	  if (*++p == '\0')
+	    break;
+	}
+      else
+	for (q = set; *q; q++)
+	  if (*p == *q)
+	    break;
+    }
+  return p - string;
+}
+
+/*********************************************************************
+ *		_mbscspn(MSVCRT.@)
+ */
+MSVCRT_size_t _mbscspn(const unsigned char* str, const unsigned char* cmp)
+{
+  if (MSVCRT___mb_cur_max > 1)
+    FIXME("don't handle double character case\n");
+  return strcspn(str, cmp);
+}
+
+/*********************************************************************
+ *              _mbsrev (MSVCRT.@)
+ */
+unsigned char* _mbsrev(unsigned char* str)
+{
+    int i, len = _mbslen(str);
+    unsigned char *p, *temp=MSVCRT_malloc(len*2);
+
+    if(!temp)
+        return str;
+
+    /* unpack multibyte string to temp buffer */
+    p=str;
+    for(i=0; i<len; i++)
+    {
+        if (MSVCRT_isleadbyte(*p))
+        {
+            temp[i*2]=*p++;
+            temp[i*2+1]=*p++;
+        }
+        else
+        {
+            temp[i*2]=*p++;
+            temp[i*2+1]=0;
+        }
+    }
+
+    /* repack it in the reverse order */
+    p=str;
+    for(i=len-1; i>=0; i--)
+    {
+        if(MSVCRT_isleadbyte(temp[i*2]))
+        {
+            *p++=temp[i*2];
+            *p++=temp[i*2+1];
+        }
+        else
+        {
+            *p++=temp[i*2];
+        }
+    }
+
+    MSVCRT_free(temp);
+
+    return str;
+}
+
+/*********************************************************************
+ *		_mbspbrk (MSVCRT.@)
+ */
+unsigned char* _mbspbrk(const unsigned char* str, const unsigned char* accept)
+{
+    const unsigned char* p;
+
+    while(*str)
+    {
+        for(p = accept; *p; p += (MSVCRT_isleadbyte(*p)?2:1) )
+        {
+            if (*p == *str)
+                if( !MSVCRT_isleadbyte(*p) || ( *(p+1) == *(str+1) ) )
+                     return (unsigned char*)str;
+        }
+        str += (MSVCRT_isleadbyte(*str)?2:1);
+    }
+    return NULL;
+}
Index: trunk/src/msvcrt/misc.c
===================================================================
--- trunk/src/msvcrt/misc.c	(revision 9633)
+++ trunk/src/msvcrt/misc.c	(revision 9633)
@@ -0,0 +1,128 @@
+/*
+ * msvcrt.dll misc functions
+ *
+ * Copyright 2000 Jon Griffiths
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "msvcrt.h"
+#include <stdlib.h>
+
+#include "msvcrt/stdlib.h"
+
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
+
+
+/*********************************************************************
+ *		_beep (MSVCRT.@)
+ */
+void _beep( unsigned int freq, unsigned int duration)
+{
+    TRACE(":Freq %d, Duration %d\n",freq,duration);
+    Beep(freq, duration);
+}
+
+/*********************************************************************
+ *		rand (MSVCRT.@)
+ */
+int MSVCRT_rand()
+{
+  return (rand() & 0x7fff);
+}
+
+/*********************************************************************
+ *		_sleep (MSVCRT.@)
+ */
+void _sleep(unsigned long timeout)
+{
+  TRACE("_sleep for %ld milliseconds\n",timeout);
+  Sleep((timeout)?timeout:1);
+}
+
+/*********************************************************************
+ *		_lfind (MSVCRT.@)
+ */
+void* _lfind(const void* match, const void* start,
+             unsigned int* array_size, unsigned int elem_size,
+             MSVCRT_compar_fn_t cf)
+{
+  unsigned int size = *array_size;
+  if (size)
+    do
+    {
+      if (cf(match, start) == 0)
+        return (void *)start; /* found */
+      start = (char*)start + elem_size;
+    } while (--size);
+  return NULL;
+}
+
+/*********************************************************************
+ *		_lsearch (MSVCRT.@)
+ */
+void* _lsearch(const void* match, void* start,
+               unsigned int* array_size, unsigned int elem_size,
+               MSVCRT_compar_fn_t cf)
+{
+  unsigned int size = *array_size;
+  if (size)
+    do
+    {
+      if (cf(match, start) == 0)
+        return start; /* found */
+      start = (char*)start + elem_size;
+    } while (--size);
+
+  /* not found, add to end */
+  memcpy(start, match, elem_size);
+  array_size[0]++;
+  return start;
+}
+
+/*********************************************************************
+ *		_chkesp (MSVCRT.@)
+ */
+void _chkesp(void)
+{
+
+}
+
+#ifdef __WIN32OS2__
+#if defined(__GNUC__) && defined(__i386__)
+#define DO_FPU(x,y) __asm__ __volatile__( x " %0;fwait" : "=m" (y) : )
+#define POP_FPU(x) DO_FPU("fstpl",x)
+#endif
+
+/*********************************************************************
+ *                  _ftol   (NTDLL.@)
+ *
+ * VERSION
+ *	[GNUC && i386]
+ */
+#if defined(__GNUC__) && defined(__i386__)
+LONG __cdecl _ftol(void)
+{
+	/* don't just do DO_FPU("fistp",retval), because the rounding
+	 * mode must also be set to "round towards zero"... */
+	double fl;
+	POP_FPU(fl);
+	return (LONG)fl;
+}
+#endif /* defined(__GNUC__) && defined(__i386__) */
+#endif
Index: trunk/src/msvcrt/ms_errno.h
===================================================================
--- trunk/src/msvcrt/ms_errno.h	(revision 9633)
+++ trunk/src/msvcrt/ms_errno.h	(revision 9633)
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2001 Jon Griffiths
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef __WINE_MSVCRT_ERRNO_H
+#define __WINE_MSVCRT_ERRNO_H
+
+#define MSVCRT_EPERM   1
+#define MSVCRT_ENOENT  2
+#define MSVCRT_ESRCH   3
+#define MSVCRT_EINTR   4
+#define MSVCRT_EIO     5
+#define MSVCRT_ENXIO   6
+#define MSVCRT_E2BIG   7
+#define MSVCRT_ENOEXEC 8
+#define MSVCRT_EBADF   9
+#define MSVCRT_ECHILD  10
+#define MSVCRT_EAGAIN  11
+#define MSVCRT_ENOMEM  12
+#define MSVCRT_EACCES  13
+#define MSVCRT_EFAULT  14
+#define MSVCRT_EBUSY   16
+#define MSVCRT_EEXIST  17
+#define MSVCRT_EXDEV   18
+#define MSVCRT_ENODEV  19
+#define MSVCRT_ENOTDIR 20
+#define MSVCRT_EISDIR  21
+#define MSVCRT_EINVAL  22
+#define MSVCRT_ENFILE  23
+#define MSVCRT_EMFILE  24
+#define MSVCRT_ENOTTY  25
+#define MSVCRT_EFBIG   27
+#define MSVCRT_ENOSPC  28
+#define MSVCRT_ESPIPE  29
+#define MSVCRT_EROFS   30
+#define MSVCRT_EMLINK  31
+#define MSVCRT_EPIPE   32
+#define MSVCRT_EDOM    33
+#define MSVCRT_ERANGE  34
+#define MSVCRT_EDEADLK 36
+#define MSVCRT_ENAMETOOLONG 38
+#define MSVCRT_ENOLCK  39
+#define MSVCRT_ENOSYS  40
+#define MSVCRT_ENOTEMPTY 41
+
+#endif  /* __WINE_MSVCRT_ERRNO_H */
Index: trunk/src/msvcrt/msvcrt.def
===================================================================
--- trunk/src/msvcrt/msvcrt.def	(revision 9633)
+++ trunk/src/msvcrt/msvcrt.def	(revision 9633)
@@ -0,0 +1,909 @@
+LIBRARY MSVCRT INITINSTANCE TERMINSTANCE
+DESCRIPTION 'Odin32 System DLL - MSVCrt'
+DATA MULTIPLE NONSHARED
+
+IMPORTS
+  KERNEL32_threadhandle = KERNEL32.308
+  KERNEL32_threadid = KERNEL32.309
+  KERNEL32_GetCurrentProcessId = KERNEL32.307
+  KERNEL32_GetProcAddress = KERNEL32.372
+  KERNEL32_GetLogicalDrives = KERNEL32.346
+  NTDLL_memicmp = NTDLL.956
+  WriteLog = KERNEL32.1202
+  GetCurrentThreadId = KERNEL32.309
+  ; Due to problem with _stdcall convention here is a large import table
+  ; This is a temporary measure and soon it will be fixed (GCC-3.2)
+  ; KERNEL32 imports
+  Beep = KERNEL32.110
+  CloseHandle = KERNEL32.137
+  CreateDirectoryA = KERNEL32.152
+  CreateDirectoryW = KERNEL32.155
+  CreateFileA = KERNEL32.158
+  CreateProcessA = KERNEL32.171
+  CreateThread = KERNEL32.178
+  DeleteCriticalSection = KERNEL32.185
+  DeleteFileA = KERNEL32.186
+  DeleteFileW = KERNEL32.187
+  DuplicateHandle = KERNEL32.192
+  EnterCriticalSection = KERNEL32.195
+  EnumResourceLanguagesA = KERNEL32.200
+  ExitProcess =  KERNEL32.214
+  ExitThread = KERNEL32.215
+  FindClose = KERNEL32.246
+  FindFirstFileA = KERNEL32.250
+  FindFirstFileW = KERNEL32.251
+  FindNextFileA = KERNEL32.253
+  FindNextFileW = KERNEL32.254
+  FlushFileBuffers = KERNEL32.260
+  FreeEnvironmentStringsA = KERNEL32.268
+  FreeEnvironmentStringsW = KERNEL32.269
+  FreeLibrary = KERNEL32.271
+  GetACP = KERNEL32.276
+  GetCPInfo = KERNEL32.282
+  GetCommandLineA = KERNEL32.289
+  GetConsoleMode = KERNEL32.297
+  GetCurrentDirectoryA = KERNEL32.304
+  GetCurrentDirectoryW = KERNEL32.305
+  GetCurrentProcess = KERNEL32.306
+  GetCurrentProcessId = KERNEL32.307
+  GetDiskFreeSpaceA = KERNEL32.315
+  GetDriveTypeA = KERNEL32.317
+  GetDriveTypeW = KERNEL32.318
+  GetEnvironmentStringsA = KERNEL32.320
+  GetEnvironmentStringsW = KERNEL32.321
+  GetExitCodeProcess = KERNEL32.325
+  GetFileAttributesA = KERNEL32.327
+  GetFileAttributesExA =  KERNEL32.874
+  GetFileAttributesExW =  KERNEL32.875
+  GetFileAttributesW = KERNEL32.328
+  GetFileInformationByHandle = KERNEL32.329
+  GetFileType = KERNEL32.332
+  GetFullPathNameA = KERNEL32.333
+  GetFullPathNameW = KERNEL32.334
+  GetLastError = KERNEL32.340
+  GetLocaleInfoA = KERNEL32.342
+  GetModuleFileNameA = KERNEL32.348
+  GetModuleHandleA = KERNEL32.350
+  GetNumberOfConsoleInputEvents = KERNEL32.357
+  GetProcessHeap = KERNEL32.375
+  GetStdHandle = KERNEL32.395
+  GetStringTypeA = KERNEL32.396
+  GetStringTypeW =  KERNEL32.399
+  GetStringTypeExA = KERNEL32.397
+  GetTempFileNameA = KERNEL32.412
+  GetTempFileNameW = KERNEL32.413
+  GetTempPathA = KERNEL32.414
+  GetThreadTEB = KERNEL32.1234
+  GetVersion = KERNEL32.427
+  HeapAlloc = KERNEL32.459
+  HeapCompact = KERNEL32.460
+  HeapFree = KERNEL32.463
+  HeapReAlloc = KERNEL32.465
+  "HeapSize" = KERNEL32.467
+  HeapValidate = KERNEL32.469
+  HeapWalk = KERNEL32.470
+  InitializeCriticalSection = KERNEL32.472
+  IsBadReadPtr = KERNEL32.480
+  IsValidCodePage = KERNEL32.488
+  LeaveCriticalSection = KERNEL32.494
+  LoadLibraryA = KERNEL32.495
+  LockFile = KERNEL32.512
+  MoveFileExA = KERNEL32.530
+  MoveFileExW = KERNEL32.531
+  MultiByteToWideChar = KERNEL32.534
+  PeekConsoleInputA = KERNEL32.550
+  RaiseException = KERNEL32.567
+  ReadConsoleInputA = KERNEL32.569
+  ReadFile = KERNEL32.577
+  RegisterLxDll = KERNEL32.1238
+  RemoveDirectoryA = KERNEL32.584
+  RemoveDirectoryW = KERNEL32.585
+  SetConsoleMode = KERNEL32.628
+  SetCurrentDirectoryA = KERNEL32.635
+  SetCurrentDirectoryW = KERNEL32.636
+  SetEnvironmentVariableA = KERNEL32.641
+  SetEnvironmentVariableW = KERNEL32.642
+  SetFileAttributesA = KERNEL32.647
+  SetFileAttributesW = KERNEL32.648
+  SetFilePointer = KERNEL32.649
+  SetFileTime = KERNEL32.650
+  SetLastError = KERNEL32.654
+  SetStdHandle = KERNEL32.663
+  Sleep = KERNEL32.679
+  TlsAlloc = KERNEL32.689 
+  TlsFree = KERNEL32.691
+  TlsGetValue = KERNEL32.693
+  TlsSetValue = KERNEL32.694
+  UnhandledExceptionFilter = KERNEL32.702
+  UnlockFile = KERNEL32.704
+  UnregisterLxDll = KERNEL32.1239
+  WaitForSingleObject = KERNEL32.723
+  WideCharToMultiByte = KERNEL32.727
+  WriteConsoleA = KERNEL32.729
+  WriteFile = KERNEL32.738
+  casemap_lower = KERNEL32.2008
+  casemap_upper = KERNEL32.2007
+  lstrcmpiA = KERNEL32.770
+  lstrcpy = KERNEL32.772
+  lstrlenW = KERNEL32.780
+  lstrncmpiA = KERNEL32.887
+  lstrncmpiW = KERNEL32.888
+  strcmpiW = KERNEL32.2020
+  strncmpiW = KERNEL32.2022
+  wctype_table = KERNEL32.2006
+
+  ; Other exports
+  CRTDLL_ecvt = ODINCRT.274
+  RtlTimeToSecondsSince1970 = NTDLL.559
+  RtlSecondsSince1970ToTime = NTDLL.526
+  RtlUnwind  = NTDLL.575
+  _wtoi = NTDLL.974
+  _wtol = NTDLL.976
+  wcscat = NTDLL.1034
+  wcschr = NTDLL.1035
+  wcscmp = NTDLL.1036
+  wcscpy = NTDLL.1037
+  wcscspn = NTDLL.1038
+  wcslen = NTDLL.1039
+  wcsncat = NTDLL.1040
+  wcsncmp = NTDLL.1041
+  wcsncpy = NTDLL.1042
+  wcspbrk = NTDLL.1043
+  wcsrchr = NTDLL.1044
+  wcsspn = NTDLL.1045
+  wcsstr = NTDLL.1046
+  wcstok = NTDLL.1050
+  wcstol = NTDLL.1047
+  wcstombs = NTDLL.1048
+  wcstoul = NTDLL.1049
+  _ultow = NTDLL.968
+  _wcslwr = NTDLL.971
+  iswalpha = NTDLL.995
+  towupper  = NTDLL.1032
+  towlower = NTDLL.1031
+  swprintf  = NTDLL.1027
+  _wcsnicmp = NTDLL.972
+  iswctype = NTDLL.996
+  is_wctype = NTDLL.996
+  _snwprintf = NTDLL.958
+
+EXPORTS
+   $I10_OUTPUT()  = MSVCRT_I10_OUTPUT 	@1
+   ??0__non_rtti_object@@QAE@ABV0@@Z = MSVCRT___non_rtti_object_copy_ctor 	@2
+   ??0bad_cast@@QAE@ABQBD@Z = MSVCRT___non_rtti_object_ctor	@3
+   ??0bad_cast@@QAE@ABV0@@Z = MSVCRT_bad_cast_copy_ctor	@4
+   ??0bad_typeid@@QAE@PBD@Z = MSVCRT_bad_typeid_ctor 	@5
+   ??0bad_typeid@@QAE@ABV0@@Z = MSVCRT_bad_typeid_copy_ctor	@6
+   ??0exception@@QAE@ABQBD@Z = MSVCRT_exception_ctor 	@7
+   ??0exception@@QAE@ABV0@@Z = MSVCRT_exception_copy_ctor 	@8
+   ??0exception@@QAE@XZ = MSVCRT_exception_default_ctor 	@9
+   ??1__non_rtti_object@@UAE@XZ =  MSVCRT___non_rtti_object_dtor	@10
+   ??1bad_cast@@UAE@XZ = MSVCRT_bad_cast_dtor	@11
+   ??1bad_typeid@@UAE@XZ = MSVCRT_bad_typeid_dtor	@12
+   ??1exception@@UAE@XZ = MSVCRT_exception_dtor	@13
+   ??1type_info@@UAE@XZ = MSVCRT_type_info_dtor	@14
+   ??2@YAPAXI@Z = MSVCRT_operator_new	@15
+   ??_U@YAPAXI@Z = MSVCRT_operator_new	@16
+   ??3@YAXPAX@Z = MSVCRT_operator_delete	@17
+   ??_V@YAXPAX@Z = MSVCRT_operator_delete	@18
+   ??4__non_rtti_object@@QAEAAV0@ABV0@@Z = MSVCRT___non_rtti_object_opequals	@19
+   ??4bad_cast@@QAEAAV0@ABV0@@Z = MSVCRT_bad_cast_opequals	@20
+   ??4bad_typeid@@QAEAAV0@ABV0@@Z = MSVCRT_bad_typeid_opequals	@21
+   ??4exception@@QAEAAV0@ABV0@@Z = MSVCRT_exception_opequals	@22
+   ??8type_info@@QBEHABV0@@Z = MSVCRT_type_info_opequals_equals	@23
+   ??9type_info@@QBEHABV0@@Z = MSVCRT_type_info_opnot_equals	@24
+
+   ??_E__non_rtti_object@@UAEPAXI@Z = MSVCRT___non_rtti_object__unknown_E	@26
+   ??_Eexception@@UAEPAXI@Z = MSVCRT_exception__unknown_E	@27
+
+   ??_G__non_rtti_object@@UAEPAXI@Z = MSVCRT___non_rtti_object__unknown_G	@29
+   ??_Gexception@@UAEPAXI@Z = MSVCRT_exception__unknown_G	@30
+   ?_query_new_handler@@YAP6AHI@ZXZ = MSVCRT__query_new_handler	@31
+   ?_query_new_mode@@YAHXZ = MSVCRT__query_new_mode	@32
+   ?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z = MSVCRT__set_new_handler	@33
+   ?_set_new_mode@@YAHH@Z = MSVCRT__set_new_mode	@34
+   ?_set_se_translator@@YAP6AXIPAU_EXCEPTION_POINTERS@@@ZP6AXI0@Z@Z = MSVCRT__set_se_translator	@35
+   ?name@type_info@@QBEPBDXZ = MSVCRT_type_info_name	@36
+   ?raw_name@type_info@@QBEPBDXZ = MSVCRT_type_info_raw_name	@37
+   ?set_new_handler@@YAP6AXXZP6AXXZ@Z = MSVCRT__set_new_handler	@38
+   ?set_terminate@@YAP6AXXZP6AXXZ@Z = MSVCRT_set_terminate	@39
+   ?set_unexpected@@YAP6AXXZP6AXXZ@Z = MSVCRT_set_unexpected	@40
+   ?terminate@@YAXXZ = MSVCRT_terminate	@41
+   ?unexpected@@YAXXZ = MSVCRT_unexpected	@42
+   ?what@exception@@UBEPBDXZ = MSVCRT_what_exception	@43
+
+    _CIacos	@45
+    _CIasin	@46
+    _CIatan	@47
+    _CIatan2	@48
+    _CIcos	@49
+    _CIcosh	@50
+    _CIexp	@51
+    _CIfmod	@52
+    _CIlog	@53
+    _CIlog10	@54
+    _CIpow	@55
+    _CIsin	@56
+    _CIsinh	@57
+    _CIsqrt	@58
+    _CItan	@59
+    _CItanh	@60
+
+   _EH_prolog	@62
+   _CxxThrowException	@63
+
+   _Getdays	@65
+   _Getmonths	@66
+   _Getnames	@67
+   _HUGE = MSVCRT__HUGE	@68
+   _Strftime	@69
+   _XcptFilter	@70
+
+; Relay call
+   __CxxFrameHandler 	@73
+   __RTCastToVoid  = MSVCRT___RTCastToVoid	@74
+   __RTDynamicCast = MSVCRT___RTDynamicCast	@75
+   __RTtypeid = MSVCRT___RTtypeid	@76
+
+   __argc = MSVCRT___argc	@78
+   __argv = MSVCRT___argv	@79
+   __dllonexit = __dllonexit	@80
+  __doserrno = __doserrno	@81
+  __getmainargs = __getmainargs	@82
+  __initenv = MSVCRT___initenv	@83
+  __isascii = MSVCRT___isascii	@84
+  __iscsym = MSVCRT___iscsym	@85
+  __iscsymf = MSVCRT___iscsymf	@86
+  __lconv_init = __lconv_init	@87
+  __mb_cur_max = MSVCRT___mb_cur_max	@88
+
+  __p___argc = __p___argc	@90
+  __p___argv = __p___argv	@91
+  __p___initenv = __p___initenv	@92
+  __p___mb_cur_max = __p___mb_cur_max	@93
+  __p___wargv = __p___wargv	@94
+  __p___winitenv = __p___winitenv	@95
+  __p__acmdln =  __p__acmdln	@96
+ __p__commode =  __p__commode	@97
+ __p__environ = __p__environ	@98
+ __p__fmode = __p__fmode	@99
+ __p__iob = __p__iob	@100
+ __p__mbctype = __p__mbctype	@101
+ __p__osver =  __p__osver	@102
+ __p__pctype = __p__pctype	@103
+ __p__timezone = __p__timezone	@104
+ __p__wcmdln = __p__wcmdln	@105
+ __p__wenviron = __p__wenviron	@106
+ __p__winmajor = __p__winmajor	@107
+ __p__winminor = __p__winminor	@108
+ __p__winver = __p__winver	@109
+
+ __set_app_type = MSVCRT___set_app_type	@111
+ __setlc_active = MSVCRT___setlc_active	@112
+ __setusermatherr = MSVCRT___setusermatherr	@113
+
+ __threadhandle = KERNEL32_threadhandle	@115
+ __threadid = KERNEL32_threadid	@116
+ __toascii = MSVCRT___toascii	@117
+ __unDName = MSVCRT___unDName	@118
+ __unDNameEx = MSVCRT___unDNameEx 	@119
+ __unguarded_readlc_active = MSVCRT___unguarded_readlc_active	@120
+ __wargv = MSVCRT___wargv	@121
+ __wgetmainargs =__wgetmainargs	@122
+ __winitenv = MSVCRT___winitenv	@123
+ _abnormal_termination = _abnormal_termination	@124
+ _access = _access	@125
+ _acmdln = MSVCRT__acmdln	@126
+ _adj_fdiv_m16i	@127
+ _adj_fdiv_m32	@128
+ _adj_fdiv_m32i	@129
+ _adj_fdiv_m64	@130
+ _adj_fdiv_r	@131
+ _adj_fdivr_m16i	@132
+ _adj_fdivr_m32	@133
+ _adj_fdivr_m32i	@134
+ _adj_fdivr_m64	@135
+ _adj_fpatan	@136
+ _adj_fprem	@137
+ _adj_fprem1	@138
+ _adj_fptan	@139
+ _adjust_fdiv	@140
+ _amsg_exit = MSVCRT__amsg_exit	@141
+ _assert = MSVCRT__assert	@142
+ _beep	@143
+; We want not EMX one but our own	@144
+ _beginthread = MSVCRT_beginthread	@145
+ _beginthreadex 	@146
+ _c_exit = MSVCRT__c_exit	@147
+ _cabs	@148
+ _callnewh	@149
+ _cexit = MSVCRT__cexit	@150
+ _cgets	@151
+ _chdir	@152
+ _chdrive	@153
+ _chgsign	@154
+ _chkesp	@155
+ _chmod	@156
+ _clearfp	@157
+ _close	@158
+ _commit	@159
+ _commode = MSVCRT__commode	@160
+ _control87	@161
+ _controlfp	@162
+ _copysign	@163
+ _cprintf	@164
+ _cputs	@165
+ _creat	@166
+ _cscanf	@167
+ _ctype = MSVCRT__ctype	@168
+ _cwait	@169
+ _ecvt = CRTDLL_ecvt	@170
+ _endthread = MSVCRT_endthread	@171
+ _endthreadex	@172
+ _environ = MSVCRT__environ	@173
+ _eof	@174
+ _errno = MSVCRT__errno	@175
+ _except_handler2	@176
+ _except_handler3	@177
+ _execl	@178
+; @ stub _execle #(str str) varargs	@179
+ _execlp	@180
+;# stub _execlpe #(str str) varargs	@181
+ _execv	@182
+ _execve	@183
+ _execvp	@184
+ _execvpe	@185
+ _exit = MSVCRT__exit	@186
+ _expand	@187
+ _fcloseall	@188
+; _fcvt = _fcvt	@189
+ _fdopen	@190
+ _fgetchar	@191
+ _fgetwchar	@192
+ _filbuf	@193
+;# stub _fileinfo	@194
+ _filelength	@195
+;# stub _filelengthi64 #(long)	@196
+  _fileno	@197
+  _findclose	@198
+  _findfirst	@199
+;# stub _findfirsti64 #(str ptr)	@200
+  _findnext	@201
+;# stub _findnexti64 #(long ptr)	@202
+  _finite	@203
+  _flsbuf	@204
+  _flushall	@205
+  _fmode = MSVCRT__fmode	@206
+  _fpclass	@207
+;# stub _fpieee_flt	@208
+  _fpreset	@209
+  _fputchar	@210
+  _fputwchar	@211
+  _fsopen	@212
+  _fstat = MSVCRT__fstat	@213
+  _fstati64	@214
+  _ftime = MSVCRT_ftime	@215
+  _ftol	@216
+  _fullpath 	@217
+  _futime	@218
+  _gcvt	@219
+  _get_osfhandle	@220
+;# stub _get_sbh_threshold #()	@221
+  _getch	@222
+  _getche	@223
+  _getcwd	@224
+  _getdcwd	@225
+  _getdiskfree	@226
+  _getdllprocaddr = KERNEL32_GetProcAddress	@227
+  _getdrive	@228
+  _getdrives = KERNEL32_GetLogicalDrives	@229
+;# stub _getmaxstdio #()	@230
+  _getmbcp	@231
+  _getpid = KERNEL32_GetCurrentProcessId	@232
+;# stub _getsystime #(ptr)	@233
+  _getw	@234
+  _getws = MSVCRT__getws	@235
+  _global_unwind2	@236
+  _heapadd	@237
+  _heapchk	@238
+  _heapmin	@239
+  _heapset	@240
+;# stub _heapused #(ptr ptr)	@241
+  _heapwalk	@242
+  _hypot	@243
+;# stub _i64toa #(long str long)	@244
+;# stub _i64tow #(long wstr long)	@245
+  _initterm	@246
+;# stub _inp #(long) -i386	@247
+;# stub _inpd #(long) -i386	@248
+;# stub _inpw #(long) -i386	@249
+  _iob = MSVCRT__iob	@250
+
+  _isatty	@252
+  _isctype	@253
+;# stub _ismbbalnum #(long)	@254
+;# stub _ismbbalpha #(long)	@255
+;# stub _ismbbgraph #(long)	@256
+;# stub _ismbbkalnum #(long)	@257
+  _ismbbkana	@258
+;# stub _ismbbkprint #(long)	@259
+;# stub _ismbbkpunct #(long)	@260
+  _ismbblead	@261
+;# stub _ismbbprint #(long)	@262
+;# stub _ismbbpunct #(long)	@263
+  _ismbbtrail	@264
+  _ismbcalnum	@265
+  _ismbcalpha	@266
+  _ismbcdigit	@267
+  _ismbcgraph 	@268
+  _ismbchira	@269
+  _ismbckata	@270
+;# stub _ismbcl0 #(long)	@271
+;# stub _ismbcl1 #(long)	@272
+;# stub _ismbcl2 #(long)	@273
+;# stub _ismbclegal #(long)	@274
+  _ismbclower	@275
+  _ismbcprint	@276
+  _ismbcpunct	@277
+  _ismbcspace	@278
+  _ismbcsymbol	@279
+  _ismbcupper	@280
+  _ismbslead	@281
+  _ismbstrail	@282
+  _isnan	@283
+  _itoa	@284
+  _itow	@285
+  _j0 = j0	@286
+  _j1 = j1	@287
+  _jn = jn	@288
+  _kbhit	@289
+  _lfind	@290
+  _loaddll	@291
+  _local_unwind2	@292
+  _lock	@293
+  _locking	@294
+  _logb	@295
+;# stub _longjmpex	@296
+  _lrotl	@297
+  _lrotr	@298
+  _lsearch	@299
+  _lseek	@300
+  _lseeki64  	@301
+  _ltoa	@302
+  _ltow	@303
+  _makepath	@304
+  _matherr	@305
+  _mbbtombc	@306
+;# stub _mbbtype #(long long)	@307
+;# stub _mbcasemap	@308
+  _mbccpy = strcpy	@309
+;# stub _mbcjistojms #(long)	@310
+;# stub _mbcjmstojis #(long)	@311
+  _mbclen	@312
+;# stub _mbctohira #(long)	@313
+;# stub _mbctokata #(long)	@314
+  _mbctolower	@315
+;# stub _mbctombb #(long)	@316
+  _mbctoupper	@317
+;# stub _mbctype	@318
+;# stub _mbsbtype #(ptr long)	@319
+  _mbscat = strcat	@320
+  _mbschr	@321
+  _mbscmp	@322
+;# stub _mbscoll #(str str)	@323
+  _mbscpy = strcpy	@324
+  _mbscspn	@325
+  _mbsdec	@326
+  _mbsdup = _strdup	@327
+  _mbsicmp	@328
+;# stub _mbsicoll #(str str)	@329
+  _mbsinc	@330
+  _mbslen	@331
+  _mbslwr	@332
+;# stub _mbsnbcat #(str str long)	@333
+  _mbsnbcmp	@334
+  _mbsnbcnt	@335
+;# stub _mbsnbcoll #(str str long)	@336
+  _mbsnbcpy	@337
+  _mbsnbicmp	@338
+;# stub _mbsnbicoll #(str str long)	@339
+;# stub _mbsnbset #(str long long)	@340
+  _mbsncat	@341
+  _mbsnccnt	@342
+  _mbsncmp	@343
+;# stub _mbsncoll #(ptr str long)	@344
+  _mbsncpy	@345
+  _mbsnextc	@346
+  _mbsnicmp	@347
+;# stub _mbsnicoll #(str str long)	@348
+  _mbsninc	@349
+  _mbsnset	@350
+  _mbspbrk	@351
+  _mbsrchr	@352
+  _mbsrev	@353
+  _mbsset	@354
+  _mbsspn	@355
+;# stub _mbsspnp #(str str)	@356
+  _mbsstr = strstr	@357
+;# stub _mbstok #(str str)	@358
+  _mbstrlen	@359
+  _mbsupr	@360
+  _memccpy = _memccpy	@361
+  _memicmp = NTDLL_memicmp	@362
+  _mkdir	@363
+  _mktemp	@364
+  _msize	@365
+  _nextafter	@366
+  _onexit	@367
+  _open	@368
+  _open_osfhandle	@369
+;# stub _osver	@370
+;# stub _outp #(long long)	@371
+;# stub _outpd #(long long)	@372
+;# stub _outpw #(long long)	@373
+;# stub _pclose #(ptr)	@374
+  _pctype = MSVCRT__pctype	@375
+;# stub _pgmptr	@376
+;# stub _pipe #(ptr long long)	@377
+;# stub _popen #(str str)	@378
+  _purecall	@379
+  _putch	@380
+  _putenv	@381
+  _putw	@382
+  _putws	@383
+;# stub _pwctype	@384
+  _read	@385
+  _rmdir	@386
+  _rmtmp	@387
+  _rotl	@388
+  _rotr	@389
+  _safe_fdiv	@390
+  _safe_fdivr	@391
+  _safe_fprem	@392
+  _safe_fprem1	@393
+  _scalb	@394
+  _searchenv	@395
+  _seh_longjmp_unwind	@396
+;# stub _set_error_mode #(long)	@397
+;# stub _set_sbh_threshold #(long)	@398
+;# stub _seterrormode #(long)	@399
+  _setjmp = _MSVCRT__setjmp	@400
+  _setjmp3 = _MSVCRT__setjmp3	@401
+;# stub _setmaxstdio #(long)	@402
+  _setmbcp	@403
+  _setmode	@404
+;# stub _setsystime #(ptr long)	@405
+  _sleep	@406
+  _snprintf = _snprintf	@407
+  _snwprintf	@408
+  _sopen = MSVCRT__sopen	@409
+  _spawnl = _spawnl	@410
+;# stub _spawnle #(str str) varargs	@411
+  _spawnlp	@412
+;# stub _spawnlpe #(str str) varargs	@413
+  _spawnv	@414
+  _spawnve	@415
+  _spawnvp	@416
+  _spawnvpe	@417
+  _splitpath	@418
+  _stat	@419
+;# stub _stati64 #(str ptr)	@420
+  _statusfp	@421
+  _strcmpi = strcasecmp	@422
+  _strdate	@423
+  _strdup	@424
+  _strerror	@425
+  _stricmp  = strcasecmp	@426
+;# stub _stricoll #(str str)	@427
+  _strlwr	@428
+;# stub _strncoll #(str str long)	@429
+  _strnicmp = strncasecmp	@430
+;# stub _strnicoll #(str str long)	@431
+  _strnset	@432
+  _strrev	@433
+  _strset	@434
+  _strtime	@435
+  _strupr	@436
+  _swab	@437
+  _sys_errlist = MSVCRT__sys_errlist	@438
+  _sys_nerr = MSVCRT__sys_nerr	@439
+  _tell	@440
+;# stub _telli64 #(long)	@441
+  _tempnam	@442
+;# stub _timezone #()	@443
+  _tolower = MSVCRT__tolower	@444
+  _toupper = MSVCRT__toupper	@445
+;# stub _tzname	@446
+  _tzset	@447
+;# stub _ui64toa #(long str long)	@448
+;# stub _ui64tow #(long wstr long)	@449
+  _ultoa 	@450
+  _ultow 	@451
+  _umask	@452
+  _ungetch	@453
+  _unlink	@454
+  _unloaddll	@455
+  _unlock	@456
+  _utime	@457
+  _vsnprintf = _vsnprintf	@458
+  _vsnwprintf	@459
+  _waccess	@460
+;# stub _wasctime #(ptr)	@461
+  _wchdir	@462
+  _wchmod	@463
+  _wcmdln = MSVCRT__wcmdln	@464
+  _wcreat	@465
+  _wcsdup	@466
+;#   _wcsicmp ntdll._wcsicmp	@467
+  _wcsicoll	@468
+  _wcslwr = _wcslwr	@469
+;# stub _wcsncoll #(wstr wstr long)	@470
+   _wcsnicmp = _wcsnicmp	@471
+;# stub _wcsnicoll #(wstr wstr long)	@472
+  _wcsnset	@473
+  _wcsrev	@474
+  _wcsset	@475
+;#   _wcsupr ntdll._wcsupr	@476
+;# stub _wctime #(ptr)	@477
+  _wenviron = MSVCRT__wenviron	@478
+;# stub _wexecl #(wstr wstr) varargs	@479
+;# stub _wexecle #(wstr wstr) varargs	@480
+;# stub _wexeclp #(wstr wstr) varargs	@481
+;# stub _wexeclpe #(wstr wstr) varargs	@482
+;# stub _wexecv #(wstr wstr)	@483
+;# stub _wexecve #(wstr wstr wstr)	@484
+;# stub _wexecvp #(wstr wstr)	@485
+;# stub _wexecvpe #(wstr wstr wstr)	@486
+  _wfdopen	@487
+  _wfindfirst	@488
+;# stub _wfindfirsti64 #(wstr ptr)	@489
+  _wfindnext	@490
+;# stub _wfindnexti64 #(long ptr)	@491
+  _wfopen	@492
+;# stub _wfreopen #(wstr wstr ptr)	@493
+  _wfsopen	@494
+;# stub _wfullpath #(wstr wstr long)	@495
+  _wgetcwd	@496
+  _wgetdcwd	@497
+  _wgetenv	@498
+  _winmajor = MSVCRT__winmajor	@499
+  _winminor = MSVCRT__winminor	@500
+  _winver = MSVCRT__winver	@501
+  _wmakepath	@502
+  _wmkdir	@503
+  _wmktemp	@504
+  _wopen	@505
+;# stub _wperror #(wstr)	@506
+;# stub _wpgmptr	@507
+;# stub _wpopen #(wstr wstr)	@508
+  _wputenv	@509
+  _wremove	@510
+  _wrename	@511
+  _write	@512
+  _wrmdir	@513
+;# stub _wsearchenv #(wstr wstr wstr)	@514
+;# stub _wsetlocale #(long wstr)	@515
+  _wsopen = MSVCRT__wsopen	@516
+;# stub _wspawnl #(long wstr wstr) varargs	@517
+;# stub _wspawnle #(long wstr wstr) varargs	@518
+;# stub _wspawnlp #(long wstr wstr) varargs	@519
+;# stub _wspawnlpe #(long wstr wstr) varargs	@520
+;# stub _wspawnv #(long wstr wstr)	@521
+;# stub _wspawnve #(long wstr wstr wstr)	@522
+;# stub _wspawnvp #(long wstr wstr)	@523
+;# stub _wspawnvpe #(long wstr wstr wstr)	@524
+  _wsplitpath	@525
+  _wstat	@526
+;# stub _wstati64 #(wstr ptr)	@527
+;# stub _wstrdate #(wstr)	@528
+;# stub _wstrtime #(wstr)	@529
+;# stub _wsystem #(wstr)	@530
+  _wtempnam	@531
+;# stub _wtmpnam #(wstr)	@532
+  _wtoi	@533
+;# stub _wtoi64 #(wstr)	@534
+  _wtol	@535
+  _wunlink	@536
+  _wutime	@537
+  _y0	@538
+  _y1	@539
+  _yn	@540
+  abort = MSVCRT_abort	@541
+  abs	@542
+  acos	@543
+  asctime	@544
+  asin	@545
+  atan 	@546
+  atan2	@547
+  atexit = MSVCRT_atexit	@548
+  atof	@549
+  atoi	@550
+  atol	@551
+  bsearch	@552
+  calloc = MSVCRT_calloc	@553
+  ceil	@554
+  clearerr = MSVCRT_clearerr	@555
+  clock = MSVCRT_clock	@556
+  cos	@557
+  cosh	@558
+  ctime	@559
+  difftime = MSVCRT_difftime	@560
+  div = MSVCRT_div	@561
+  exit = MSVCRT_exit	@562
+  exp	@563
+  fabs	@564
+  fclose = MSVCRT_fclose	@565
+  feof = MSVCRT_feof	@566
+  ferror = MSVCRT_ferror	@567
+  fflush = MSVCRT_fflush	@568
+  fgetc = MSVCRT_fgetc	@569
+  fgetpos = MSVCRT_fgetpos	@570
+  fgets = MSVCRT_fgets	@571
+  fgetwc = MSVCRT_fgetwc	@572
+  fgetws = MSVCRT_fgetws	@573
+  floor	@574
+  fmod	@575
+  fopen = MSVCRT_fopen	@576
+  fprintf = MSVCRT_fprintf	@577
+  fputc = MSVCRT_fputc	@578
+  fputs = MSVCRT_fputs	@579
+  fputwc = MSVCRT_fputwc	@580
+  fputws = MSVCRT_fputws	@581
+  fread = MSVCRT_fread	@582
+  free = MSVCRT_free	@583
+  freopen = MSVCRT_freopen	@584
+  frexp = frexp	@585
+  fscanf = MSVCRT_fscanf	@586
+  fseek = MSVCRT_fseek	@587
+  fsetpos = MSVCRT_fsetpos	@588
+  ftell = MSVCRT_ftell	@589
+  fwprintf = MSVCRT_fwprintf	@590
+  fwrite = MSVCRT_fwrite	@591
+;# stub fwscanf #(ptr wstr) varargs	@592
+  getc = MSVCRT_getc	@593
+  getchar = MSVCRT_getchar	@594
+  getenv = MSVCRT_getenv	@595
+  gets = MSVCRT_gets	@596
+  getwc = MSVCRT_getwc	@597
+  getwchar = MSVCRT_getwchar	@598
+  gmtime = gmtime	@599
+  is_wctype = iswctype	@600
+  isalnum = MSVCRT_isalnum	@601
+  isalpha = MSVCRT_isalpha	@602
+  iscntrl = MSVCRT_iscntrl	@603
+  isdigit = MSVCRT_isdigit	@604
+  isgraph = MSVCRT_isgraph	@605
+  isleadbyte = MSVCRT_isleadbyte	@606
+  islower = MSVCRT_islower	@607
+  isprint = MSVCRT_isprint	@608
+  ispunct = MSVCRT_ispunct	@609
+  isspace = MSVCRT_isspace	@610
+  isupper = MSVCRT_isupper	@611
+  iswalnum = MSVCRT_iswalnum	@612
+  iswalpha	@613
+  iswascii = MSVCRT_iswascii	@614
+  iswcntrl = MSVCRT_iswcntrl	@615
+  iswctype	@616
+  iswdigit = MSVCRT_iswdigit	@617
+  iswgraph = MSVCRT_iswgraph	@618
+  iswlower = MSVCRT_iswlower	@619
+  iswprint = MSVCRT_iswprint	@620
+  iswpunct = MSVCRT_iswpunct	@621
+  iswspace = MSVCRT_iswspace	@622
+  iswupper = MSVCRT_iswupper	@623
+  iswxdigit = MSVCRT_iswxdigit	@624
+  isxdigit = MSVCRT_isxdigit	@625
+  labs	@626
+  ldexp = MSVCRT_ldexp	@627
+  ldiv = MSVCRT_ldiv	@628
+;# stub localeconv #()	@629
+  localtime	@630
+  log	@631
+  log10	@632
+  longjmp = _MSVCRT_longjmp	@633
+  malloc = MSVCRT_malloc	@634
+  mblen = MSVCRT_mblen	@635
+  mbstowcs 	@636
+  mbtowc = MSVCRT_mbtowc	@637
+  memchr	@638
+  memcmp	@639
+  memcpy = MSVCRT_memcpy	@640
+  memmove	@641
+  memset = MSVCRT_memset	@642
+  mktime = MSVCRT_mktime	@643
+  modf	@644
+  perror = MSVCRT_perror	@645
+  pow	@646
+  printf = MSVCRT_printf	@647
+  putc = MSVCRT_putc	@648
+  putchar = MSVCRT_putchar	@649
+  puts = MSVCRT_puts	@650
+  putwc = MSVCRT_fputwc	@651
+  putwchar =_fputwchar	@652
+  qsort	@653
+;# stub raise #(long)	@654
+  rand = MSVCRT_rand	@655
+  realloc = MSVCRT_realloc	@656
+  remove = MSVCRT_remove	@657
+  rename = MSVCRT_rename	@658
+  rewind = MSVCRT_rewind	@659
+  scanf = MSVCRT_scanf	@660
+  setbuf = MSVCRT_setbuf	@661
+  setlocale = MSVCRT_setlocale	@662
+  setvbuf = MSVCRT_setvbuf	@663
+  signal = MSVCRT_signal	@664
+  sin	@665
+  sinh	@666
+  sprintf	@667
+  sqrt	@668
+  srand	@669
+  sscanf	@670
+  strcat	@671
+  strchr	@672
+  strcmp	@673
+  strcoll	@674
+  strcpy 	@675
+  strcspn	@676
+  strerror = MSVCRT_strerror	@677
+  strftime	@678
+  strlen	@679
+  strncat	@680
+  strncmp	@681
+  strncpy	@682
+  strpbrk	@683
+  strrchr	@684
+  strspn	@685
+  strstr	@686
+  strtod	@687
+  strtok        @688 
+  strtol	@689
+  strtoul	@690
+  strxfrm	@691
+  swprintf	@692
+;# stub swscanf #(wstr wstr) varargs	@693
+  system = MSVCRT_system	@694
+  tan	@695
+  tanh	@696
+  time = MSVCRT_time	@697
+  tmpfile = MSVCRT_tmpfile	@698
+  tmpnam = MSVCRT_tmpnam	@699
+  tolower	@700
+  toupper	@701
+  towlower	@702
+  towupper	@703
+  ungetc = MSVCRT_ungetc	@704
+  ungetwc = MSVCRT_ungetwc	@705
+  vfprintf = MSVCRT_vfprintf	@706
+  vfwprintf = MSVCRT_vfwprintf	@707
+  vprintf = MSVCRT_vprintf	@708
+  vsprintf = vsprintf	@709
+  vswprintf = MSVCRT_vswprintf	@710
+  vwprintf = MSVCRT_vwprintf	@711
+  wcscat	@712
+  wcschr	@713
+  wcscmp	@714
+  wcscoll =  MSVCRT_wcscoll	@715
+  wcscpy 	@716
+  wcscspn	@717
+;# stub wcsftime #(wstr long wstr ptr)	@718
+  wcslen 	@719
+  wcsncat	@720
+  wcsncmp	@721
+  wcsncpy	@722
+  wcspbrk = MSVCRT_wcspbrk	@723
+  wcsrchr 	@724
+  wcsspn	@725
+  wcsstr	@726
+;# stub wcstod #(wstr ptr)	@727
+  wcstok	@728
+  wcstol	@729
+  wcstombs	@730
+  wcstoul 	@731
+;# stub wcsxfrm #(wstr wstr long)	@732
+  wctomb = MSVCRT_wctomb	@733
+  wprintf = MSVCRT_wprintf	@734
+  wscanf  = MSVCRT_wscanf       @735
+;# stub _Gettnames	@736
+;# stub __lc_collate_cp	@737
+;# stub __lc_collate_c	@738
+  MSVCRT_Init @739
Index: trunk/src/msvcrt/msvcrt.h
===================================================================
--- trunk/src/msvcrt/msvcrt.h	(revision 9633)
+++ trunk/src/msvcrt/msvcrt.h	(revision 9633)
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2001 Jon Griffiths
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef __WINE_MSVCRT_H
+#define __WINE_MSVCRT_H
+
+#include <stdarg.h>
+
+#include "winbase.h"
+#include "winnls.h"
+#include "winerror.h"
+#include "msvcrt/eh.h"
+
+/* TLS data */
+extern DWORD MSVCRT_tls_index;
+
+typedef struct __MSVCRT_thread_data
+{
+    int                      errno;
+    unsigned long            doserrno;
+    terminate_function       terminate_handler;
+    unexpected_function      unexpected_handler;
+    _se_translator_function  se_translator;
+    EXCEPTION_RECORD        *exc_record;
+} MSVCRT_thread_data;
+
+extern MSVCRT_thread_data *msvcrt_get_thread_data(void);
+
+extern int MSVCRT_current_lc_all_cp;
+
+void _purecall(void);
+void   MSVCRT__set_errno(int);
+char*  msvcrt_strndup(const char*,unsigned int);
+LPWSTR msvcrt_wstrndup(LPCWSTR, unsigned int);
+
+void MSVCRT__amsg_exit(int errnum);
+
+extern char **MSVCRT__environ;
+extern WCHAR **MSVCRT__wenviron;
+
+extern char ** msvcrt_SnapshotOfEnvironmentA(char **);
+extern WCHAR ** msvcrt_SnapshotOfEnvironmentW(WCHAR **);
+
+/* FIXME: This should be declared in new.h but it's not an extern "C" so
+ * it would not be much use anyway. Even for Winelib applications.
+ */
+int    MSVCRT__set_new_mode(int mode);
+
+/* Setup and teardown multi threaded locks */
+extern void msvcrt_init_mt_locks(void);
+extern void msvcrt_free_mt_locks(void);
+
+extern void msvcrt_init_io(void);
+extern void msvcrt_free_io(void);
+extern void msvcrt_init_console(void);
+extern void msvcrt_free_console(void);
+extern void msvcrt_init_args(void);
+extern void msvcrt_free_args(void);
+extern void msvcrt_init_vtables(void);
+
+/* run-time error codes */
+#define _RT_STACK       0
+#define _RT_NULLPTR     1
+#define _RT_FLOAT       2
+#define _RT_INTDIV      3
+#define _RT_EXECMEM     5
+#define _RT_EXECFORM    6
+#define _RT_EXECENV     7
+#define _RT_SPACEARG    8
+#define _RT_SPACEENV    9
+#define _RT_ABORT       10
+#define _RT_NPTR        12
+#define _RT_FPTR        13
+#define _RT_BREAK       14
+#define _RT_INT         15
+#define _RT_THREAD      16
+#define _RT_LOCK        17
+#define _RT_HEAP        18
+#define _RT_OPENCON     19
+#define _RT_QWIN        20
+#define _RT_NOMAIN      21
+#define _RT_NONCONT     22
+#define _RT_INVALDISP   23
+#define _RT_ONEXIT      24
+#define _RT_PUREVIRT    25
+#define _RT_STDIOINIT   26
+#define _RT_LOWIOINIT   27
+#define _RT_HEAPINIT    28
+#define _RT_DOMAIN      120
+#define _RT_SING        121
+#define _RT_TLOSS       122
+#define _RT_CRNL        252
+#define _RT_BANNER      255
+
+#endif /* __WINE_MSVCRT_H */
Index: trunk/src/msvcrt/msvcrt.mak
===================================================================
--- trunk/src/msvcrt/msvcrt.mak	(revision 9633)
+++ trunk/src/msvcrt/msvcrt.mak	(revision 9633)
@@ -0,0 +1,85 @@
+# $Id: msvcrt.mak,v 1.5 2003-01-06 13:26:36 sandervl Exp $
+
+#
+# Odin32 API
+#
+#       msvcrt.dll makefile
+#
+
+
+#
+# Tell buildenvironment that we have a non-default makefilename.
+#
+MAKEFILE = msvcrt.mak
+CCENV = EMX
+NOTEXPDEF = 1
+
+#
+# Compiler, tools, and interference rules.
+#
+!include ../../makefile.inc
+
+
+!ifndef WMAKE
+CDEFINES    = -I. $(CDEFINES) -DUSE_MSVCRT_PREFIX -D_MT -I$(ODIN32_INCLUDE)\win\msvcrt 
+!else
+CDEFINES   += -DUSE_MSVCRT_PREFIX -D_MT -I$(ODIN32_INCLUDE)\win\msvcrt
+!endif
+
+
+#
+# Object files. Prefix with OBJDIR and one space before the '\'.
+#
+OBJS = \
+$(OBJDIR)\ctype.obj \
+$(OBJDIR)\cpp.obj \
+$(OBJDIR)\cppexcept.obj \
+$(OBJDIR)\console.obj \
+$(OBJDIR)\data.obj \
+$(OBJDIR)\dir.obj \
+$(OBJDIR)\environ.obj \
+$(OBJDIR)\errno.obj \
+$(OBJDIR)\except.obj \
+$(OBJDIR)\exit.obj \
+$(OBJDIR)\file.obj \
+$(OBJDIR)\heap.obj \
+$(OBJDIR)\lconv.obj \
+$(OBJDIR)\locale.obj \
+$(OBJDIR)\lock.obj \
+$(OBJDIR)\main.obj \
+$(OBJDIR)\scanf.obj \
+$(OBJDIR)\math.obj \
+$(OBJDIR)\mbcs.obj \
+$(OBJDIR)\misc.obj \
+$(OBJDIR)\process.obj \
+$(OBJDIR)\string.obj \
+$(OBJDIR)\thread.obj \
+$(OBJDIR)\time.obj \
+$(OBJDIR)\wcs.obj \
+$(OBJDIR)\rtlbitmap.obj \
+$(OBJDIR)\relay2.obj \
+$(OBJDIR)\$(TARGET)rsrc.obj 
+
+
+#
+# Target name - name of the dll without extention and path.
+#
+TARGET = msvcrt
+
+all: $(OBJDIR) $(OBJDIR)\$(TARGET).dll $(TARGET).lib
+
+$(OBJDIR)\$(TARGET).dll: $(OBJS) $(TARGET).def
+    $(LD) $(LDFLAGS) -Zso -Zsys $(OBJS) $(TARGET).def -L.\libs -lm\
+      -liberty_s -o $(OBJDIR)\$(TARGET).dll
+    touch $(OBJDIR)\$(TARGET).map
+    @echo "Illegal Sym File for EMX" > $(OBJDIR)\$(TARGET).sym
+
+# Includes the common rules.
+#
+!include $(ODIN32_POST_INC)
+
+$(TARGET).lib: 
+    implib $(OBJDIR)\$(TARGET).lib msvcrt.def
+    @copy $(OBJDIR)\$(TARGET).lib $(ODIN32_LIB_)\Release > nul:
+    @copy $(OBJDIR)\$(TARGET).lib $(ODIN32_LIB_)\Debug  > nul:
+
Index: trunk/src/msvcrt/msvcrt.spec
===================================================================
--- trunk/src/msvcrt/msvcrt.spec	(revision 9633)
+++ trunk/src/msvcrt/msvcrt.spec	(revision 9633)
@@ -0,0 +1,766 @@
+# msvcrt.dll - MS VC++ Run Time Library
+
+@ cdecl $I10_OUTPUT() MSVCRT_I10_OUTPUT
+@ cdecl ??0__non_rtti_object@@QAE@ABV0@@Z(ptr ptr) MSVCRT___non_rtti_object_copy_ctor
+@ cdecl ??0__non_rtti_object@@QAE@PBD@Z(ptr ptr) MSVCRT___non_rtti_object_ctor
+@ cdecl ??0bad_cast@@QAE@ABQBD@Z(ptr ptr) MSVCRT_bad_cast_ctor
+@ cdecl ??0bad_cast@@QAE@ABV0@@Z(ptr ptr) MSVCRT_bad_cast_copy_ctor
+@ cdecl ??0bad_typeid@@QAE@ABV0@@Z(ptr ptr) MSVCRT_bad_typeid_copy_ctor
+@ cdecl ??0bad_typeid@@QAE@PBD@Z(ptr ptr) MSVCRT_bad_typeid_ctor
+@ cdecl ??0exception@@QAE@ABQBD@Z(ptr ptr) MSVCRT_exception_ctor
+@ cdecl ??0exception@@QAE@ABV0@@Z(ptr ptr) MSVCRT_exception_copy_ctor
+@ cdecl ??0exception@@QAE@XZ(ptr) MSVCRT_exception_default_ctor
+@ cdecl ??1__non_rtti_object@@UAE@XZ(ptr) MSVCRT___non_rtti_object_dtor
+@ cdecl ??1bad_cast@@UAE@XZ(ptr) MSVCRT_bad_cast_dtor
+@ cdecl ??1bad_typeid@@UAE@XZ(ptr) MSVCRT_bad_typeid_dtor
+@ cdecl ??1exception@@UAE@XZ(ptr) MSVCRT_exception_dtor
+@ cdecl ??1type_info@@UAE@XZ(ptr) MSVCRT_type_info_dtor
+@ cdecl ??2@YAPAXI@Z(long) MSVCRT_operator_new
+@ cdecl ??_U@YAPAXI@Z(long) MSVCRT_operator_new
+@ cdecl ??3@YAXPAX@Z(ptr) MSVCRT_operator_delete
+@ cdecl ??_V@YAXPAX@Z(ptr) MSVCRT_operator_delete
+@ cdecl ??4__non_rtti_object@@QAEAAV0@ABV0@@Z(ptr ptr) MSVCRT___non_rtti_object_opequals
+@ cdecl ??4bad_cast@@QAEAAV0@ABV0@@Z(ptr ptr) MSVCRT_bad_cast_opequals
+@ cdecl ??4bad_typeid@@QAEAAV0@ABV0@@Z(ptr ptr)MSVCRT_bad_typeid_opequals
+@ cdecl ??4exception@@QAEAAV0@ABV0@@Z(ptr ptr) MSVCRT_exception_opequals
+@ stdcall ??8type_info@@QBEHABV0@@Z(ptr ptr) MSVCRT_type_info_opequals_equals
+@ stdcall ??9type_info@@QBEHABV0@@Z(ptr ptr) MSVCRT_type_info_opnot_equals
+@ stub ??_7__non_rtti_object@@6B@
+@ stub ??_7bad_cast@@6B@
+@ stub ??_7bad_typeid@@6B@
+@ stub ??_7exception@@6B@
+@ cdecl ??_E__non_rtti_object@@UAEPAXI@Z(ptr long) MSVCRT___non_rtti_object__unknown_E
+@ stub ??_Ebad_cast@@UAEPAXI@Z #(ptr long)
+@ stub ??_Ebad_typeid@@UAEPAXI@Z #(ptr long)
+@ cdecl ??_Eexception@@UAEPAXI@Z(ptr long) MSVCRT_exception__unknown_E
+@ cdecl ??_G__non_rtti_object@@UAEPAXI@Z(ptr long) MSVCRT___non_rtti_object__unknown_G
+@ stub ??_Gbad_cast@@UAEPAXI@Z #(ptr long)
+@ stub ??_Gbad_typeid@@UAEPAXI@Z #(ptr long)
+@ cdecl ??_Gexception@@UAEPAXI@Z(ptr long) MSVCRT_exception__unknown_G
+@ cdecl ?_query_new_handler@@YAP6AHI@ZXZ() MSVCRT__query_new_handler
+@ cdecl ?_query_new_mode@@YAHXZ() MSVCRT__query_new_mode
+@ cdecl ?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z(ptr) MSVCRT__set_new_handler
+@ cdecl ?_set_new_mode@@YAHH@Z(long) MSVCRT__set_new_mode
+@ cdecl ?_set_se_translator@@YAP6AXIPAU_EXCEPTION_POINTERS@@@ZP6AXI0@Z@Z(ptr) MSVCRT__set_se_translator
+@ stub ?before@type_info@@QBEHABV1@@Z #(ptr ptr) stdcall
+@ stdcall ?name@type_info@@QBEPBDXZ(ptr) MSVCRT_type_info_name
+@ stdcall ?raw_name@type_info@@QBEPBDXZ(ptr) MSVCRT_type_info_raw_name
+@ cdecl ?set_new_handler@@YAP6AXXZP6AXXZ@Z(ptr) MSVCRT__set_new_handler
+@ cdecl ?set_terminate@@YAP6AXXZP6AXXZ@Z(ptr) MSVCRT_set_terminate
+@ cdecl ?set_unexpected@@YAP6AXXZP6AXXZ@Z(ptr) MSVCRT_set_unexpected
+@ cdecl ?terminate@@YAXXZ() MSVCRT_terminate
+@ cdecl ?unexpected@@YAXXZ() MSVCRT_unexpected
+@ cdecl ?what@exception@@UBEPBDXZ(ptr) MSVCRT_what_exception
+@ cdecl _CIacos() _CIacos
+@ cdecl _CIasin() _CIasin
+@ cdecl _CIatan() _CIatan
+@ cdecl _CIatan2() _CIatan2
+@ cdecl _CIcos() _CIcos
+@ cdecl _CIcosh() _CIcosh
+@ cdecl _CIexp() _CIexp
+@ cdecl _CIfmod() _CIfmod
+@ cdecl _CIlog() _CIlog
+@ cdecl _CIlog10() _CIlog10
+@ cdecl _CIpow() _CIpow
+@ cdecl _CIsin() _CIsin
+@ cdecl _CIsinh() _CIsinh
+@ cdecl _CIsqrt() _CIsqrt
+@ cdecl _CItan() _CItan
+@ cdecl _CItanh() _CItanh
+@ cdecl _CxxThrowException(long long) _CxxThrowException
+@ cdecl -i386 -norelay _EH_prolog() _EH_prolog
+@ cdecl _Getdays() _Getdays
+@ cdecl _Getmonths() _Getmonths
+@ cdecl _Getnames() _Getnames
+@ extern _HUGE MSVCRT__HUGE
+@ cdecl _Strftime(str long str ptr ptr) _Strftime
+@ cdecl _XcptFilter(long ptr) _XcptFilter
+@ cdecl -register -i386 __CxxFrameHandler(ptr ptr ptr ptr) __CxxFrameHandler
+@ stub __CxxLongjmpUnwind
+@ cdecl __RTCastToVoid(ptr) MSVCRT___RTCastToVoid
+@ cdecl __RTDynamicCast(ptr long ptr ptr long) MSVCRT___RTDynamicCast
+@ cdecl __RTtypeid(ptr) MSVCRT___RTtypeid
+@ stub __STRINGTOLD
+@ extern __argc MSVCRT___argc
+@ extern __argv MSVCRT___argv
+@ stub __badioinfo
+@ stub __crtCompareStringA
+@ stub __crtGetLocaleInfoW
+@ stub __crtLCMapStringA
+@ cdecl __dllonexit(ptr ptr ptr) __dllonexit
+@ cdecl __doserrno() __doserrno
+@ stub __fpecode #()
+@ cdecl __getmainargs(ptr ptr ptr long ptr) __getmainargs
+@ extern __initenv MSVCRT___initenv
+@ cdecl __isascii(long) MSVCRT___isascii
+@ cdecl __iscsym(long) MSVCRT___iscsym
+@ cdecl __iscsymf(long) MSVCRT___iscsymf
+@ stub __lc_codepage
+@ stub __lc_collate
+@ stub __lc_handle
+@ cdecl __lconv_init() __lconv_init
+@ extern __mb_cur_max MSVCRT___mb_cur_max
+@ cdecl __p___argc() __p___argc
+@ cdecl __p___argv() __p___argv
+@ cdecl __p___initenv() __p___initenv
+@ cdecl __p___mb_cur_max() __p___mb_cur_max
+@ cdecl __p___wargv() __p___wargv
+@ cdecl __p___winitenv() __p___winitenv
+@ cdecl __p__acmdln()  __p__acmdln
+@ stub __p__amblksiz #()
+@ cdecl __p__commode()  __p__commode
+@ stub __p__daylight #()
+@ stub __p__dstbias #()
+@ cdecl __p__environ() __p__environ
+@ stub __p__fileinfo #()
+@ cdecl __p__fmode() __p__fmode
+@ cdecl __p__iob() __p__iob
+@ stub __p__mbcasemap #()
+@ cdecl __p__mbctype() __p__mbctype
+@ cdecl __p__osver()  __p__osver
+@ cdecl __p__pctype() __p__pctype
+@ stub __p__pgmptr #()
+@ stub __p__pwctype #()
+@ cdecl __p__timezone() __p__timezone
+@ stub __p__tzname #()
+@ cdecl __p__wcmdln() __p__wcmdln
+@ cdecl __p__wenviron() __p__wenviron
+@ cdecl __p__winmajor() __p__winmajor
+@ cdecl __p__winminor() __p__winminor
+@ cdecl __p__winver() __p__winver
+@ stub __p__wpgmptr #()
+@ stub __pioinfo #()
+@ stub __pxcptinfoptrs #()
+@ cdecl __set_app_type(long) MSVCRT___set_app_type
+@ extern __setlc_active MSVCRT___setlc_active
+@ cdecl __setusermatherr(ptr) MSVCRT___setusermatherr
+@ forward __threadhandle kernel32.GetCurrentThread
+@ forward __threadid kernel32.GetCurrentThreadId
+@ cdecl __toascii(long) MSVCRT___toascii
+@ cdecl __unDName(long str ptr ptr long) MSVCRT___unDName
+@ cdecl __unDNameEx() MSVCRT___unDNameEx #FIXME
+@ extern __unguarded_readlc_active MSVCRT___unguarded_readlc_active
+@ extern __wargv MSVCRT___wargv
+@ cdecl __wgetmainargs(ptr ptr ptr long ptr) __wgetmainargs
+@ extern __winitenv MSVCRT___winitenv
+@ cdecl _abnormal_termination() _abnormal_termination
+@ cdecl _access(str long) _access
+@ extern _acmdln MSVCRT__acmdln
+@ cdecl _adj_fdiv_m16i() _adj_fdiv_m16i
+@ cdecl _adj_fdiv_m32() _adj_fdiv_m32
+@ cdecl _adj_fdiv_m32i() _adj_fdiv_m32i
+@ cdecl _adj_fdiv_m64() _adj_fdiv_m64
+@ cdecl _adj_fdiv_r() _adj_fdiv_r
+@ cdecl _adj_fdivr_m16i() _adj_fdivr_m16i
+@ cdecl _adj_fdivr_m32() _adj_fdivr_m32
+@ cdecl _adj_fdivr_m32i() _adj_fdivr_m32i
+@ cdecl _adj_fdivr_m64() _adj_fdivr_m64
+@ cdecl _adj_fpatan() _adj_fpatan
+@ cdecl _adj_fprem() _adj_fprem
+@ cdecl _adj_fprem1() _adj_fprem1
+@ cdecl _adj_fptan() _adj_fptan
+@ cdecl _adjust_fdiv() _adjust_fdiv
+@ stub _aexit_rtn
+@ cdecl _amsg_exit(long) MSVCRT__amsg_exit
+@ cdecl _assert(str str long) MSVCRT__assert
+@ stub _atodbl
+@ stub _atoi64 #(str)
+@ stub _atoldbl
+@ cdecl _beep(long long) _beep
+@ cdecl _beginthread (ptr long ptr) _beginthread
+@ cdecl _beginthreadex (ptr long ptr ptr long ptr) _beginthreadex
+@ cdecl _c_exit() MSVCRT__c_exit
+@ cdecl _cabs(long) _cabs
+@ cdecl _callnewh(long) _callnewh
+@ cdecl _cexit() MSVCRT__cexit
+@ cdecl _cgets(str) _cgets
+@ cdecl _chdir(str) _chdir
+@ cdecl _chdrive(long) _chdrive
+@ cdecl _chgsign( double ) _chgsign
+@ cdecl -i386 _chkesp() _chkesp
+@ cdecl _chmod(str long) _chmod
+@ stub _chsize #(long long)
+@ cdecl _clearfp() _clearfp
+@ cdecl _close(long) _close
+@ cdecl _commit(long) _commit
+@ extern _commode MSVCRT__commode
+@ cdecl _control87(long long) _control87
+@ cdecl _controlfp(long long) _controlfp
+@ cdecl _copysign( double double ) _copysign
+@ varargs _cprintf(str) _cprintf
+@ cdecl _cputs(str) _cputs
+@ cdecl _creat(str long) _creat
+@ varargs _cscanf(str) _cscanf
+@ extern _ctype MSVCRT__ctype
+@ cdecl _cwait(ptr long long) _cwait
+@ stub _daylight
+@ stub _dstbias
+@ stub _dup #(long)
+@ stub _dup2 #(long long)
+@ cdecl _ecvt( double long ptr ptr) ecvt
+@ cdecl _endthread () _endthread
+@ cdecl _endthreadex(long) _endthreadex
+@ extern _environ MSVCRT__environ
+@ cdecl _eof(long) _eof
+@ cdecl _errno() MSVCRT__errno
+@ cdecl _except_handler2(ptr ptr ptr ptr) _except_handler2
+@ cdecl _except_handler3(ptr ptr ptr ptr) _except_handler3
+@ varargs _execl(str str) _execl
+@ stub _execle #(str str) varargs
+@ varargs _execlp(str str) _execlp
+@ stub _execlpe #(str str) varargs
+@ cdecl _execv(str str) _execv
+@ cdecl _execve(str str str) _execve
+@ cdecl _execvp(str str) _execvp
+@ cdecl _execvpe(str str str) _execvpe
+@ cdecl _exit(long) MSVCRT__exit
+@ cdecl _expand(ptr long) _expand
+@ cdecl _fcloseall() _fcloseall
+@ cdecl _fcvt( double long ptr ptr) fcvt
+@ cdecl _fdopen(long str) _fdopen
+@ cdecl _fgetchar() _fgetchar
+@ cdecl _fgetwchar() _fgetwchar
+@ cdecl _filbuf(ptr) _filbuf
+@ stub _fileinfo
+@ cdecl _filelength(long) _filelength
+@ stub _filelengthi64 #(long)
+@ cdecl _fileno(ptr) _fileno
+@ cdecl _findclose(long) _findclose
+@ cdecl _findfirst(str ptr) _findfirst
+@ stub _findfirsti64 #(str ptr)
+@ cdecl _findnext(long ptr) _findnext
+@ stub _findnexti64 #(long ptr)
+@ cdecl _finite( double ) _finite
+@ cdecl _flsbuf(long ptr) _flsbuf
+@ cdecl _flushall() _flushall
+@ extern _fmode MSVCRT__fmode
+@ cdecl _fpclass(double) _fpclass
+@ stub _fpieee_flt
+@ cdecl _fpreset() _fpreset
+@ cdecl _fputchar(long) _fputchar
+@ cdecl _fputwchar(long) _fputwchar
+@ cdecl _fsopen(str str long) _fsopen
+@ cdecl _fstat(long ptr) MSVCRT__fstat
+@ cdecl _fstati64(long ptr) _fstati64
+@ cdecl _ftime(ptr) _ftime
+@ forward _ftol ntdll._ftol
+@ cdecl _fullpath(ptr str long) _fullpath
+@ cdecl _futime(long ptr) _futime
+@ cdecl _gcvt( double long str) gcvt
+@ cdecl _get_osfhandle(long) _get_osfhandle
+@ stub _get_sbh_threshold #()
+@ cdecl _getch() _getch
+@ cdecl _getche() _getche
+@ cdecl _getcwd(str long) _getcwd
+@ cdecl _getdcwd(long str long) _getdcwd
+@ cdecl _getdiskfree(long ptr) _getdiskfree
+@ forward _getdllprocaddr kernel32.GetProcAddress
+@ cdecl _getdrive() _getdrive
+@ forward _getdrives kernel32.GetLogicalDrives
+@ stub _getmaxstdio #()
+@ cdecl _getmbcp() _getmbcp
+@ forward _getpid kernel32.GetCurrentProcessId
+@ stub _getsystime #(ptr)
+@ cdecl _getw(ptr) _getw
+@ cdecl _getws(ptr) MSVCRT__getws
+@ cdecl _global_unwind2(ptr) _global_unwind2
+@ cdecl _heapadd (ptr long) _heapadd
+@ cdecl _heapchk() _heapchk
+@ cdecl _heapmin() _heapmin
+@ cdecl _heapset(long) _heapset
+@ stub _heapused #(ptr ptr)
+@ cdecl _heapwalk(ptr) _heapwalk
+@ cdecl _hypot(double double) hypot
+@ stub _i64toa #(long str long)
+@ stub _i64tow #(long wstr long)
+@ cdecl _initterm(ptr ptr) _initterm
+@ stub _inp #(long) -i386
+@ stub _inpd #(long) -i386
+@ stub _inpw #(long) -i386
+@ extern _iob MSVCRT__iob
+@ cdecl _isatty(long) _isatty
+@ cdecl _isctype(long long) _isctype
+@ stub _ismbbalnum #(long)
+@ stub _ismbbalpha #(long)
+@ stub _ismbbgraph #(long)
+@ stub _ismbbkalnum #(long)
+@ cdecl _ismbbkana(long) _ismbbkana
+@ stub _ismbbkprint #(long)
+@ stub _ismbbkpunct #(long)
+@ cdecl _ismbblead(long) _ismbblead
+@ stub _ismbbprint #(long)
+@ stub _ismbbpunct #(long)
+@ cdecl _ismbbtrail(long) _ismbbtrail
+@ cdecl _ismbcalnum(long) _ismbcalnum
+@ cdecl _ismbcalpha(long) _ismbcalpha
+@ cdecl _ismbcdigit(long) _ismbcdigit
+@ cdecl _ismbcgraph(long) _ismbcgraph
+@ cdecl _ismbchira(long) _ismbchira
+@ cdecl _ismbckata(long) _ismbckata
+@ stub _ismbcl0 #(long)
+@ stub _ismbcl1 #(long)
+@ stub _ismbcl2 #(long)
+@ stub _ismbclegal #(long)
+@ cdecl _ismbclower(long) _ismbclower
+@ cdecl _ismbcprint(long) _ismbcprint
+@ cdecl _ismbcpunct(long) _ismbcpunct
+@ cdecl _ismbcspace(long) _ismbcspace
+@ cdecl _ismbcsymbol(long) _ismbcsymbol
+@ cdecl _ismbcupper(long) _ismbcupper
+@ cdecl _ismbslead(ptr ptr) _ismbslead
+@ cdecl _ismbstrail(ptr ptr) _ismbstrail
+@ cdecl _isnan( double ) _isnan
+@ forward _itoa ntdll._itoa
+@ cdecl _itow(long wstr long) _itow
+@ cdecl _j0(double) j0
+@ cdecl _j1(double) j1
+@ cdecl _jn(long double) jn
+@ cdecl _kbhit() _kbhit
+@ cdecl _lfind(ptr ptr ptr long ptr) _lfind
+@ cdecl _loaddll(str) _loaddll
+@ cdecl _local_unwind2(ptr long) _local_unwind2
+@ cdecl _lock(long) _lock
+@ cdecl _locking(long long long) _locking
+@ cdecl _logb( double ) _logb
+@ stub _longjmpex
+@ cdecl _lrotl(long long) _lrotl
+@ cdecl _lrotr(long long) _lrotr
+@ cdecl _lsearch(ptr ptr long long ptr) _lsearch
+@ cdecl _lseek(long long long) _lseek
+@ cdecl -ret64 _lseeki64(long long long long) _lseeki64
+@ forward _ltoa ntdll._ltoa
+@ cdecl _ltow(long ptr long) _ltow
+@ cdecl _makepath(str str str str str) _makepath
+@ cdecl _matherr(ptr) _matherr
+@ cdecl _mbbtombc(long) _mbbtombc
+@ stub _mbbtype #(long long)
+@ stub _mbcasemap
+@ cdecl _mbccpy (str str) strcpy
+@ stub _mbcjistojms #(long)
+@ stub _mbcjmstojis #(long)
+@ cdecl _mbclen(ptr) _mbclen
+@ stub _mbctohira #(long)
+@ stub _mbctokata #(long)
+@ cdecl _mbctolower(long) _mbctolower
+@ stub _mbctombb #(long)
+@ cdecl _mbctoupper(long) _mbctoupper
+@ stub _mbctype
+@ stub _mbsbtype #(ptr long)
+@ cdecl _mbscat(str str) strcat
+@ cdecl _mbschr(str long) _mbschr
+@ cdecl _mbscmp(str str) _mbscmp
+@ stub _mbscoll #(str str)
+@ cdecl _mbscpy(ptr str) strcpy
+@ cdecl _mbscspn (str str) _mbscspn
+@ cdecl _mbsdec(ptr ptr) _mbsdec
+@ cdecl _mbsdup(str) _strdup
+@ cdecl _mbsicmp(str str) _mbsicmp
+@ stub _mbsicoll #(str str)
+@ cdecl _mbsinc(str) _mbsinc
+@ cdecl _mbslen(str) _mbslen
+@ cdecl _mbslwr(str) _mbslwr
+@ stub _mbsnbcat #(str str long)
+@ cdecl _mbsnbcmp(str str long) _mbsnbcmp
+@ cdecl _mbsnbcnt(ptr long) _mbsnbcnt
+@ stub _mbsnbcoll #(str str long)
+@ cdecl _mbsnbcpy(ptr str long) _mbsnbcpy
+@ cdecl _mbsnbicmp(str str long) _mbsnbicmp
+@ stub _mbsnbicoll #(str str long)
+@ stub _mbsnbset #(str long long)
+@ cdecl _mbsncat(str str long) _mbsncat
+@ cdecl _mbsnccnt(str long) _mbsnccnt
+@ cdecl _mbsncmp(str str long) _mbsncmp
+@ stub _mbsncoll #(ptr str long)
+@ cdecl _mbsncpy(str str long) _mbsncpy
+@ cdecl _mbsnextc(str) _mbsnextc
+@ cdecl _mbsnicmp(str str long) _mbsnicmp
+@ stub _mbsnicoll #(str str long)
+@ cdecl _mbsninc(str long) _mbsninc
+@ cdecl _mbsnset(str long long) _mbsnset
+@ cdecl _mbspbrk(str str) _mbspbrk
+@ cdecl _mbsrchr(str long) _mbsrchr
+@ cdecl _mbsrev(str) _mbsrev
+@ cdecl _mbsset(str long) _mbsset
+@ cdecl _mbsspn(str str) _mbsspn
+@ stub _mbsspnp #(str str)
+@ cdecl _mbsstr(str str) strstr
+@ stub _mbstok #(str str)
+@ cdecl _mbstrlen(str) _mbstrlen
+@ cdecl _mbsupr(str) _mbsupr
+@ cdecl _memccpy(ptr ptr long long) memccpy
+@ forward _memicmp ntdll._memicmp
+@ cdecl _mkdir(str) _mkdir
+@ cdecl _mktemp(str) _mktemp
+@ cdecl _msize(ptr) _msize
+@ cdecl _nextafter(double double) _nextafter
+@ cdecl _onexit(ptr) _onexit
+@ varargs _open(str long) _open
+@ cdecl _open_osfhandle(long long) _open_osfhandle
+@ stub _osver
+@ stub _outp #(long long)
+@ stub _outpd #(long long)
+@ stub _outpw #(long long)
+@ stub _pclose #(ptr)
+@ extern _pctype MSVCRT__pctype
+@ stub _pgmptr
+@ stub _pipe #(ptr long long)
+@ stub _popen #(str str)
+@ cdecl _purecall() _purecall
+@ cdecl _putch(long) _putch
+@ cdecl _putenv(str) _putenv
+@ cdecl _putw(long ptr) _putw
+@ cdecl _putws(wstr) _putws
+@ stub _pwctype
+@ cdecl _read(long ptr long) _read
+@ cdecl _rmdir(str) _rmdir
+@ cdecl _rmtmp() _rmtmp
+@ cdecl _rotl(long long) _rotl
+@ cdecl _rotr(long long) _rotr
+@ cdecl _safe_fdiv() _safe_fdiv
+@ cdecl _safe_fdivr() _safe_fdivr
+@ cdecl _safe_fprem() _safe_fprem
+@ cdecl _safe_fprem1() _safe_fprem1
+@ cdecl _scalb( double long) _scalb
+@ cdecl _searchenv(str str str) _searchenv
+@ stdcall -i386 _seh_longjmp_unwind(ptr) _seh_longjmp_unwind
+@ stub _set_error_mode #(long)
+@ stub _set_sbh_threshold #(long)
+@ stub _seterrormode #(long)
+@ cdecl -register -i386 _setjmp(ptr) _MSVCRT__setjmp
+@ cdecl -register -i386 _setjmp3(ptr long) _MSVCRT__setjmp3
+@ stub _setmaxstdio #(long)
+@ cdecl _setmbcp(long) _setmbcp
+@ cdecl _setmode(long long) _setmode
+@ stub _setsystime #(ptr long)
+@ cdecl _sleep(long) _sleep
+@ varargs _snprintf(str long str) snprintf
+@ forward _snwprintf ntdll._snwprintf
+@ varargs _sopen(str long long) MSVCRT__sopen
+@ varargs _spawnl(long str str) _spawnl
+@ stub _spawnle #(str str) varargs
+@ varargs _spawnlp(long str str) _spawnlp
+@ stub _spawnlpe #(str str) varargs
+@ cdecl _spawnv(long str ptr) _spawnv
+@ cdecl _spawnve(long str ptr ptr) _spawnve
+@ cdecl _spawnvp(long str ptr) _spawnvp
+@ cdecl _spawnvpe(long str ptr ptr) _spawnvpe
+@ forward _splitpath ntdll._splitpath
+@ cdecl _stat(str ptr) MSVCRT__stat
+@ cdecl _stati64(str ptr) _stati64
+@ cdecl _statusfp() _statusfp
+@ cdecl _strcmpi(str str) strcasecmp
+@ cdecl _strdate(str) _strdate
+@ cdecl _strdup(str) _strdup
+@ cdecl _strerror(long) _strerror
+@ cdecl _stricmp(str str) strcasecmp
+@ stub _stricoll #(str str)
+@ forward _strlwr ntdll._strlwr
+@ stub _strncoll #(str str long)
+@ cdecl _strnicmp(str str long) strncasecmp
+@ stub _strnicoll #(str str long)
+@ cdecl _strnset(str long long) _strnset
+@ cdecl _strrev(str) _strrev
+@ cdecl _strset(str long) _strset
+@ cdecl _strtime(str) _strtime
+@ forward _strupr ntdll._strupr
+@ cdecl _swab(str str long) _swab
+@ extern _sys_errlist MSVCRT__sys_errlist
+@ extern _sys_nerr MSVCRT__sys_nerr
+@ cdecl _tell(long) _tell
+@ stub _telli64 #(long)
+@ cdecl _tempnam(str str) _tempnam
+@ stub _timezone #()
+@ cdecl _tolower(long) MSVCRT__tolower
+@ cdecl _toupper(long) MSVCRT__toupper
+@ stub _tzname
+@ cdecl _tzset() tzset
+@ stub _ui64toa #(long str long)
+@ stub _ui64tow #(long wstr long)
+@ forward _ultoa ntdll._ultoa
+@ forward _ultow ntdll._ultow
+@ cdecl _umask(long) _umask
+@ cdecl _ungetch(long) _ungetch
+@ cdecl _unlink(str) _unlink
+@ cdecl _unloaddll(long) _unloaddll
+@ cdecl _unlock(long) _unlock
+@ cdecl _utime(str ptr) _utime
+@ cdecl _vsnprintf(ptr long ptr ptr) vsnprintf
+@ cdecl _vsnwprintf(ptr long wstr long) _vsnwprintf
+@ cdecl _waccess(wstr long) _waccess
+@ stub _wasctime #(ptr)
+@ cdecl _wchdir(wstr) _wchdir
+@ cdecl _wchmod(wstr long) _wchmod
+@ extern _wcmdln MSVCRT__wcmdln
+@ cdecl _wcreat(wstr long) _wcreat
+@ cdecl _wcsdup(wstr) _wcsdup
+@ forward _wcsicmp ntdll._wcsicmp
+@ cdecl _wcsicoll(wstr wstr) _wcsicoll
+@ forward _wcslwr ntdll._wcslwr
+@ stub _wcsncoll #(wstr wstr long)
+@ forward _wcsnicmp ntdll._wcsnicmp
+@ stub _wcsnicoll #(wstr wstr long)
+@ cdecl _wcsnset(wstr long long) _wcsnset
+@ cdecl _wcsrev(wstr) _wcsrev
+@ cdecl _wcsset(wstr long) _wcsset
+@ forward _wcsupr ntdll._wcsupr
+@ stub _wctime #(ptr)
+@ extern _wenviron MSVCRT__wenviron
+@ stub _wexecl #(wstr wstr) varargs
+@ stub _wexecle #(wstr wstr) varargs
+@ stub _wexeclp #(wstr wstr) varargs
+@ stub _wexeclpe #(wstr wstr) varargs
+@ stub _wexecv #(wstr wstr)
+@ stub _wexecve #(wstr wstr wstr)
+@ stub _wexecvp #(wstr wstr)
+@ stub _wexecvpe #(wstr wstr wstr)
+@ cdecl _wfdopen(long wstr) _wfdopen
+@ cdecl _wfindfirst(wstr ptr) _wfindfirst
+@ stub _wfindfirsti64 #(wstr ptr)
+@ cdecl _wfindnext(long ptr)  _wfindnext
+@ stub _wfindnexti64 #(long ptr)
+@ cdecl _wfopen(wstr wstr) _wfopen
+@ stub _wfreopen #(wstr wstr ptr)
+@ cdecl _wfsopen(wstr wstr long) _wfsopen
+@ stub _wfullpath #(wstr wstr long)
+@ cdecl _wgetcwd(wstr long) _wgetcwd
+@ cdecl _wgetdcwd(long wstr long) _wgetdcwd
+@ cdecl _wgetenv(wstr) _wgetenv
+@ extern _winmajor MSVCRT__winmajor
+@ extern _winminor MSVCRT__winminor
+@ extern _winver MSVCRT__winver
+@ cdecl _wmakepath(wstr wstr wstr wstr wstr) _wmakepath
+@ cdecl _wmkdir(wstr) _wmkdir
+@ cdecl _wmktemp(wstr) _wmktemp
+@ varargs _wopen(wstr long) _wopen
+@ stub _wperror #(wstr)
+@ stub _wpgmptr
+@ stub _wpopen #(wstr wstr)
+@ cdecl _wputenv(wstr) _wputenv
+@ cdecl _wremove(wstr) _wremove
+@ cdecl _wrename(wstr wstr) _wrename
+@ cdecl _write(long ptr long) _write
+@ cdecl _wrmdir(wstr) _wrmdir
+@ stub _wsearchenv #(wstr wstr wstr)
+@ stub _wsetlocale #(long wstr)
+@ varargs _wsopen (wstr long long) MSVCRT__wsopen
+@ stub _wspawnl #(long wstr wstr) varargs
+@ stub _wspawnle #(long wstr wstr) varargs
+@ stub _wspawnlp #(long wstr wstr) varargs
+@ stub _wspawnlpe #(long wstr wstr) varargs
+@ stub _wspawnv #(long wstr wstr)
+@ stub _wspawnve #(long wstr wstr wstr)
+@ stub _wspawnvp #(long wstr wstr)
+@ stub _wspawnvpe #(long wstr wstr wstr)
+@ cdecl _wsplitpath(wstr wstr wstr wstr wstr) _wsplitpath
+@ cdecl _wstat(wstr ptr) _wstat
+@ stub _wstati64 #(wstr ptr)
+@ stub _wstrdate #(wstr)
+@ stub _wstrtime #(wstr)
+@ stub _wsystem #(wstr)
+@ cdecl _wtempnam(wstr wstr) _wtempnam
+@ stub _wtmpnam #(wstr)
+@ forward _wtoi NTDLL._wtoi
+@ stub _wtoi64 #(wstr)
+@ forward _wtol NTDLL._wtol
+@ cdecl _wunlink(wstr) _wunlink
+@ cdecl _wutime(wstr ptr) _wutime
+@ cdecl _y0(double) _y0
+@ cdecl _y1(double) _y1
+@ cdecl _yn(long double ) _yn
+@ cdecl abort() MSVCRT_abort
+@ cdecl abs(long) abs
+@ cdecl acos(double) acos
+@ cdecl asctime(ptr) asctime
+@ cdecl asin(double) asin
+@ cdecl atan(double) atan
+@ cdecl atan2(double double) atan2
+@ cdecl atexit(ptr) MSVCRT_atexit
+@ cdecl atof(str) atof
+@ cdecl atoi(str) atoi
+@ cdecl atol(str) atol
+@ cdecl bsearch(ptr ptr long long ptr) bsearch
+@ cdecl calloc(long long) MSVCRT_calloc
+@ cdecl ceil(double) ceil
+@ cdecl clearerr(ptr) MSVCRT_clearerr
+@ cdecl clock() MSVCRT_clock
+@ cdecl cos(double) cos
+@ cdecl cosh(double) cosh
+@ cdecl ctime(ptr) ctime
+@ cdecl difftime(long long) MSVCRT_difftime
+@ cdecl div(long long) MSVCRT_div
+@ cdecl exit(long) MSVCRT_exit
+@ cdecl exp(double) exp
+@ cdecl fabs(double) fabs
+@ cdecl fclose(ptr) MSVCRT_fclose
+@ cdecl feof(ptr) MSVCRT_feof
+@ cdecl ferror(ptr) MSVCRT_ferror
+@ cdecl fflush(ptr) MSVCRT_fflush
+@ cdecl fgetc(ptr) MSVCRT_fgetc
+@ cdecl fgetpos(ptr ptr) MSVCRT_fgetpos
+@ cdecl fgets(ptr long ptr) MSVCRT_fgets
+@ cdecl fgetwc(ptr) MSVCRT_fgetwc
+@ cdecl fgetws(ptr long ptr) MSVCRT_fgetws
+@ cdecl floor(double) floor
+@ cdecl fmod(double double) fmod
+@ cdecl fopen(str str) MSVCRT_fopen
+@ varargs fprintf(ptr str) MSVCRT_fprintf
+@ cdecl fputc(long ptr) MSVCRT_fputc
+@ cdecl fputs(str ptr) MSVCRT_fputs
+@ cdecl fputwc(long ptr) MSVCRT_fputwc
+@ cdecl fputws(wstr ptr) MSVCRT_fputws
+@ cdecl fread(ptr long long ptr) MSVCRT_fread
+@ cdecl free(ptr) MSVCRT_free
+@ cdecl freopen(str str ptr) MSVCRT_freopen
+@ cdecl frexp(double ptr) frexp
+@ varargs fscanf(ptr str) MSVCRT_fscanf
+@ cdecl fseek(ptr long long) MSVCRT_fseek
+@ cdecl fsetpos(ptr ptr) MSVCRT_fsetpos
+@ cdecl ftell(ptr) MSVCRT_ftell
+@ varargs fwprintf(ptr wstr) MSVCRT_fwprintf
+@ cdecl fwrite(ptr long long ptr) MSVCRT_fwrite
+@ varargs fwscanf(ptr wstr) MSVCRT_fwscanf
+@ cdecl getc(ptr) MSVCRT_getc
+@ cdecl getchar() MSVCRT_getchar
+@ cdecl getenv(str) MSVCRT_getenv
+@ cdecl gets(str) MSVCRT_gets
+@ cdecl getwc(ptr) MSVCRT_getwc
+@ cdecl getwchar() MSVCRT_getwchar
+@ cdecl gmtime(ptr) gmtime
+@ forward is_wctype ntdll.iswctype
+@ cdecl isalnum(long) MSVCRT_isalnum
+@ cdecl isalpha(long) MSVCRT_isalpha
+@ cdecl iscntrl(long) MSVCRT_iscntrl
+@ cdecl isdigit(long) MSVCRT_isdigit
+@ cdecl isgraph(long) MSVCRT_isgraph
+@ cdecl isleadbyte(long) MSVCRT_isleadbyte
+@ cdecl islower(long) MSVCRT_islower
+@ cdecl isprint(long) MSVCRT_isprint
+@ cdecl ispunct(long) MSVCRT_ispunct
+@ cdecl isspace(long) MSVCRT_isspace
+@ cdecl isupper(long) MSVCRT_isupper
+@ cdecl iswalnum(long) MSVCRT_iswalnum
+@ forward iswalpha ntdll.iswalpha
+@ cdecl iswascii(long) MSVCRT_iswascii
+@ cdecl iswcntrl(long) MSVCRT_iswcntrl
+@ forward iswctype ntdll.iswctype
+@ cdecl iswdigit(long) MSVCRT_iswdigit
+@ cdecl iswgraph(long) MSVCRT_iswgraph
+@ cdecl iswlower(long) MSVCRT_iswlower
+@ cdecl iswprint(long) MSVCRT_iswprint
+@ cdecl iswpunct(long) MSVCRT_iswpunct
+@ cdecl iswspace(long) MSVCRT_iswspace
+@ cdecl iswupper(long) MSVCRT_iswupper
+@ cdecl iswxdigit(long) MSVCRT_iswxdigit
+@ cdecl isxdigit(long) MSVCRT_isxdigit
+@ cdecl labs(long) labs
+@ cdecl ldexp( double long) MSVCRT_ldexp
+@ cdecl ldiv(long long) MSVCRT_ldiv
+@ stub localeconv #()
+@ cdecl localtime(ptr) localtime
+@ cdecl log(double) log
+@ cdecl log10(double) log10
+@ cdecl -register -i386 longjmp(ptr long) _MSVCRT_longjmp
+@ cdecl malloc(long) MSVCRT_malloc
+@ cdecl mblen(ptr long) MSVCRT_mblen
+@ forward mbstowcs ntdll.mbstowcs
+@ cdecl mbtowc(wstr str long) MSVCRT_mbtowc
+@ cdecl memchr(ptr long long) memchr
+@ cdecl memcmp(ptr ptr long) memcmp
+@ cdecl memcpy(ptr ptr long) memcpy
+@ cdecl memmove(ptr ptr long) memmove
+@ cdecl memset(ptr long long) memset
+@ cdecl mktime(ptr) MSVCRT_mktime
+@ cdecl modf(double ptr) modf
+@ cdecl perror(str) MSVCRT_perror
+@ cdecl pow(double double) pow
+@ varargs printf(str) MSVCRT_printf
+@ cdecl putc(long ptr) MSVCRT_putc
+@ cdecl putchar(long) MSVCRT_putchar
+@ cdecl puts(str) MSVCRT_puts
+@ cdecl putwc(long ptr) MSVCRT_fputwc
+@ cdecl putwchar(long) _fputwchar
+@ cdecl qsort(ptr long long ptr) qsort
+@ stub raise #(long)
+@ cdecl rand() MSVCRT_rand
+@ cdecl realloc(ptr long) MSVCRT_realloc
+@ cdecl remove(str) MSVCRT_remove
+@ cdecl rename(str str) MSVCRT_rename
+@ cdecl rewind(ptr) MSVCRT_rewind
+@ varargs scanf(str) MSVCRT_scanf
+@ cdecl setbuf(ptr ptr) MSVCRT_setbuf
+@ cdecl setlocale(long str) MSVCRT_setlocale
+@ cdecl setvbuf(ptr str long long) MSVCRT_setvbuf
+@ cdecl signal(long long) MSVCRT_signal
+@ cdecl sin(double) sin
+@ cdecl sinh(double) sinh
+@ varargs sprintf(ptr str) sprintf
+@ cdecl sqrt(double) sqrt
+@ cdecl srand(long) srand
+@ varargs sscanf(str str) MSVCRT_sscanf
+@ cdecl strcat(str str) strcat
+@ cdecl strchr(str long) strchr
+@ cdecl strcmp(str str) strcmp
+@ cdecl strcoll(str str) strcoll
+@ cdecl strcpy(ptr str) strcpy
+@ cdecl strcspn(str str) strcspn
+@ cdecl strerror(long) MSVCRT_strerror
+@ cdecl strftime(str long str ptr) strftime
+@ cdecl strlen(str) strlen
+@ cdecl strncat(str str long) strncat
+@ cdecl strncmp(str str long) strncmp
+@ cdecl strncpy(ptr str long) strncpy
+@ cdecl strpbrk(str str) strpbrk
+@ cdecl strrchr(str long) strrchr
+@ cdecl strspn(str str) strspn
+@ cdecl strstr(str str) strstr
+@ cdecl strtod(str ptr) strtod
+@ cdecl strtok(str str) strtok
+@ cdecl strtol(str ptr long) strtol
+@ cdecl strtoul(str ptr long) strtoul
+@ cdecl strxfrm(ptr str long) strxfrm
+@ forward swprintf ntdll.swprintf
+@ varargs swscanf(wstr wstr) MSVCRT_swscanf
+@ cdecl system(str) MSVCRT_system
+@ cdecl tan(double) tan
+@ cdecl tanh(double) tanh
+@ cdecl time(ptr) MSVCRT_time
+@ cdecl tmpfile() MSVCRT_tmpfile
+@ cdecl tmpnam(str) MSVCRT_tmpnam
+@ cdecl tolower(long) tolower
+@ cdecl toupper(long) toupper
+@ forward towlower ntdll.towlower
+@ forward towupper ntdll.towupper
+@ cdecl ungetc(long ptr) MSVCRT_ungetc
+@ cdecl ungetwc(long ptr) MSVCRT_ungetwc
+@ cdecl vfprintf(ptr str long) MSVCRT_vfprintf
+@ cdecl vfwprintf(ptr wstr long) MSVCRT_vfwprintf
+@ cdecl vprintf(str long) MSVCRT_vprintf
+@ cdecl vsprintf(ptr str ptr) vsprintf
+@ cdecl vswprintf(ptr wstr long) MSVCRT_vswprintf
+@ cdecl vwprintf(wstr long) MSVCRT_vwprintf
+@ forward wcscat ntdll.wcscat
+@ forward wcschr ntdll.wcschr
+@ forward wcscmp ntdll.wcscmp
+@ cdecl wcscoll(wstr wstr) MSVCRT_wcscoll
+@ forward wcscpy ntdll.wcscpy
+@ forward wcscspn ntdll.wcscspn
+@ stub wcsftime #(wstr long wstr ptr)
+@ forward wcslen ntdll.wcslen
+@ forward wcsncat ntdll.wcsncat
+@ forward wcsncmp ntdll.wcsncmp
+@ forward wcsncpy ntdll.wcsncpy
+@ cdecl wcspbrk(wstr wstr) MSVCRT_wcspbrk
+@ forward wcsrchr ntdll.wcsrchr
+@ forward wcsspn ntdll.wcsspn
+@ forward wcsstr ntdll.wcsstr
+@ stub wcstod #(wstr ptr)
+@ forward wcstok ntdll.wcstok
+@ forward wcstol ntdll.wcstol
+@ forward wcstombs ntdll.wcstombs
+@ forward wcstoul ntdll.wcstoul
+@ stub wcsxfrm #(wstr wstr long)
+@ cdecl wctomb(ptr long) MSVCRT_wctomb
+@ varargs wprintf(wstr) MSVCRT_wprintf
+@ varargs wscanf(wstr) MSVCRT_wscanf
+@ stub _Gettnames
+@ stub __lc_collate_cp
Index: trunk/src/msvcrt/msvcrt20.def
===================================================================
--- trunk/src/msvcrt/msvcrt20.def	(revision 9633)
+++ trunk/src/msvcrt/msvcrt20.def	(revision 9633)
@@ -0,0 +1,1141 @@
+; $Id: msvcrt20.def,v 1.11 2003-01-06 13:26:37 sandervl Exp $
+
+;
+; Based on Windows 98 : MSVCRT20.DLL (v2.11.000)
+;
+LIBRARY MSVCRT20 INITINSTANCE TERMINSTANCE
+DESCRIPTION 'Odin32 System DLL - MSVCrt20'
+DATA MULTIPLE NONSHARED
+
+IMPORTS
+  RegisterLxDll = KERNEL32.1238
+  UnregisterLxDll = KERNEL32.1239
+
+EXPORTS
+; stub ??0Iostream_init@@QAE@AAVios@@H@Z  #	@1
+; stub ??0Iostream_init@@QAE@XZ #	@2
+; stub ??0filebuf@@QAE@ABV0@@Z #	@3
+; stub ??0filebuf@@QAE@H@Z #	@4
+; stub ??0filebuf@@QAE@HPADH@Z #	@5
+; stub ??0filebuf@@QAE@XZ #	@6
+; stub ??0fstream@@QAE@ABV0@@Z #	@7
+; stub ??0fstream@@QAE@H@Z #	@8
+; stub ??0fstream@@QAE@HPADH@Z #	@9
+; stub ??0fstream@@QAE@PBDHH@Z #	@10
+; stub ??0fstream@@QAE@XZ #	@11
+; stub ??0ifstream@@QAE@ABV0@@Z #	@12
+; stub ??0ifstream@@QAE@H@Z #	@13
+; stub ??0ifstream@@QAE@HPADH@Z #	@14
+; stub ??0ifstream@@QAE@PBDHH@Z #	@15
+; stub ??0ifstream@@QAE@XZ #	@16
+; stub ??0ios@@IAE@ABV0@@Z #	@17
+; stub ??0ios@@IAE@XZ #	@18
+; stub ??0ios@@QAE@PAVstreambuf@@@Z #	@19
+; stub ??0iostream@@IAE@ABV0@@Z #	@20
+; stub ??0iostream@@IAE@XZ #	@21
+; stub ??0iostream@@QAE@PAVstreambuf@@@Z #	@22
+; stub ??0istream@@IAE@ABV0@@Z #	@23
+; stub ??0istream@@IAE@XZ #	@24
+; stub ??0istream@@QAE@PAVstreambuf@@@Z #	@25
+; stub ??0istream_withassign@@QAE@ABV0@@Z #	@26
+; stub ??0istream_withassign@@QAE@PAVstreambuf@@@Z #	@27
+; stub ??0istream_withassign@@QAE@XZ #	@28
+; stub ??0istrstream@@QAE@ABV0@@Z #	@29
+; stub ??0istrstream@@QAE@PAD@Z #	@30
+; stub ??0istrstream@@QAE@PADH@Z #	@31
+; stub ??0ofstream@@QAE@ABV0@@Z #	@32
+; stub ??0ofstream@@QAE@H@Z #	@33
+; stub ??0ofstream@@QAE@HPADH@Z #	@34
+; stub ??0ofstream@@QAE@PBDHH@Z #	@35
+; stub ??0ofstream@@QAE@XZ #	@36
+; stub ??0ostream@@IAE@ABV0@@Z #	@37
+; stub ??0ostream@@IAE@XZ #	@38
+; stub ??0ostream@@QAE@PAVstreambuf@@@Z #	@39
+; stub ??0ostream_withassign@@QAE@ABV0@@Z #	@40
+; stub ??0ostream_withassign@@QAE@PAVstreambuf@@@Z #	@41
+; stub ??0ostream_withassign@@QAE@XZ #	@42
+; stub ??0ostrstream@@QAE@ABV0@@Z #	@43
+; stub ??0ostrstream@@QAE@PADHH@Z #	@44
+; stub ??0ostrstream@@QAE@XZ #	@45
+; stub ??0stdiobuf@@QAE@ABV0@@Z #	@46
+; stub ??0stdiobuf@@QAE@PAU_iobuf@@@Z #	@47
+; stub ??0stdiostream@@QAE@ABV0@@Z #	@48
+; stub ??0stdiostream@@QAE@PAU_iobuf@@@Z #	@49
+; stub ??0streambuf@@IAE@PADH@Z #	@50
+; stub ??0streambuf@@IAE@XZ #	@51
+; stub ??0streambuf@@QAE@ABV0@@Z #	@52
+; stub ??0strstream@@QAE@ABV0@@Z #	@53
+; stub ??0strstream@@QAE@PADHH@Z #	@54
+; stub ??0strstream@@QAE@XZ #	@55
+; stub ??0strstreambuf@@QAE@ABV0@@Z #	@56
+; stub ??0strstreambuf@@QAE@H@Z #	@57
+; stub ??0strstreambuf@@QAE@P6APAXJ@ZP6AXPAX@Z@Z #	@58
+; stub ??0strstreambuf@@QAE@PADH0@Z #	@59
+; stub ??0strstreambuf@@QAE@XZ #	@60
+; stub ??1Iostream_init@@QAE@XZ #	@61
+; stub ??1filebuf@@UAE@XZ #	@62
+; stub ??1fstream@@UAE@XZ #	@63
+; stub ??1ifstream@@UAE@XZ #	@64
+; stub ??1ios@@UAE@XZ #	@65
+; stub ??1iostream@@UAE@XZ #	@66
+; stub ??1istream@@UAE@XZ #	@67
+; stub ??1istream_withassign@@UAE@XZ #	@68
+; stub ??1istrstream@@UAE@XZ #	@69
+; stub ??1ofstream@@UAE@XZ #	@70
+; stub ??1ostream@@UAE@XZ #	@71
+; stub ??1ostream_withassign@@UAE@XZ #	@72
+; stub ??1ostrstream@@UAE@XZ #	@73
+; stub ??1stdiobuf@@UAE@XZ #	@74
+; stub ??1stdiostream@@UAE@XZ #	@75
+; stub ??1streambuf@@UAE@XZ #	@76
+; stub ??1strstream@@UAE@XZ #	@77
+; stub ??1strstreambuf@@UAE@XZ #	@78
+  ??2@YAPAXI@Z	@79
+  ??3@YAXPAX@Z 	@80
+; stub ??4Iostream_init@@QAEAAV0@ABV0@@Z #	@81
+; stub ??4filebuf@@QAEAAV0@ABV0@@Z #	@82
+; stub ??4fstream@@QAEAAV0@AAV0@@Z #	@83
+; stub ??4ifstream@@QAEAAV0@ABV0@@Z #	@84
+; stub ??4ios@@IAEAAV0@ABV0@@Z #	@85
+; stub ??4iostream@@IAEAAV0@AAV0@@Z #	@86
+; stub ??4iostream@@IAEAAV0@PAVstreambuf@@@Z #	@87
+; stub ??4istream@@IAEAAV0@ABV0@@Z #	@88
+; stub ??4istream@@IAEAAV0@PAVstreambuf@@@Z #	@89
+; stub ??4istream_withassign@@QAEAAV0@ABV0@@Z #	@90
+; stub ??4istream_withassign@@QAEAAVistream@@ABV1@@Z #	@91
+; stub ??4istream_withassign@@QAEAAVistream@@PAVstreambuf@@@Z #	@92
+; stub ??4istrstream@@QAEAAV0@ABV0@@Z #	@93
+; stub ??4ofstream@@QAEAAV0@ABV0@@Z #	@94
+; stub ??4ostream@@IAEAAV0@ABV0@@Z #	@95
+; stub ??4ostream@@IAEAAV0@PAVstreambuf@@@Z #	@96
+; stub ??4ostream_withassign@@QAEAAV0@ABV0@@Z #	@97
+; stub ??4ostream_withassign@@QAEAAVostream@@ABV1@@Z #	@98
+; stub ??4ostream_withassign@@QAEAAVostream@@PAVstreambuf@@@Z #	@99
+; stub ??4ostrstream@@QAEAAV0@ABV0@@Z #	@100
+; stub ??4stdiobuf@@QAEAAV0@ABV0@@Z #	@101
+; stub ??4stdiostream@@QAEAAV0@AAV0@@Z #	@102
+; stub ??4streambuf@@QAEAAV0@ABV0@@Z #	@103
+; stub ??4strstream@@QAEAAV0@AAV0@@Z #	@104
+; stub ??4strstreambuf@@QAEAAV0@ABV0@@Z #	@105
+; stub ??5istream@@QAEAAV0@AAC@Z #	@106
+; stub ??5istream@@QAEAAV0@AAD@Z #	@107
+; stub ??5istream@@QAEAAV0@AAE@Z #	@108
+; stub ??5istream@@QAEAAV0@AAF@Z #	@109
+; stub ??5istream@@QAEAAV0@AAG@Z #	@110
+; stub ??5istream@@QAEAAV0@AAH@Z #	@111
+; stub ??5istream@@QAEAAV0@AAI@Z #	@112
+; stub ??5istream@@QAEAAV0@AAJ@Z #	@113
+; stub ??5istream@@QAEAAV0@AAK@Z #	@114
+; stub ??5istream@@QAEAAV0@AAM@Z #	@115
+; stub ??5istream@@QAEAAV0@AAN@Z #	@116
+; stub ??5istream@@QAEAAV0@AAO@Z #	@117
+; stub ??5istream@@QAEAAV0@P6AAAV0@AAV0@@Z@Z #	@118
+; stub ??5istream@@QAEAAV0@P6AAAVios@@AAV1@@Z@Z #	@119
+; stub ??5istream@@QAEAAV0@PAC@Z #	@120
+; stub ??5istream@@QAEAAV0@PAD@Z #	@121
+; stub ??5istream@@QAEAAV0@PAE@Z #	@122
+; stub ??5istream@@QAEAAV0@PAVstreambuf@@@Z #	@123
+; stub ??6ostream@@QAEAAV0@C@Z #	@124
+; stub ??6ostream@@QAEAAV0@D@Z #	@125
+; stub ??6ostream@@QAEAAV0@E@Z #	@126
+; stub ??6ostream@@QAEAAV0@F@Z #	@127
+; stub ??6ostream@@QAEAAV0@G@Z #	@128
+; stub ??6ostream@@QAEAAV0@H@Z #	@129
+; stub ??6ostream@@QAEAAV0@I@Z #	@130
+; stub ??6ostream@@QAEAAV0@J@Z #	@131
+; stub ??6ostream@@QAEAAV0@K@Z #	@132
+; stub ??6ostream@@QAEAAV0@M@Z #	@133
+; stub ??6ostream@@QAEAAV0@N@Z #	@134
+; stub ??6ostream@@QAEAAV0@O@Z #	@135
+; stub ??6ostream@@QAEAAV0@P6AAAV0@AAV0@@Z@Z #	@136
+; stub ??6ostream@@QAEAAV0@P6AAAVios@@AAV1@@Z@Z #	@137
+; stub ??6ostream@@QAEAAV0@PAVstreambuf@@@Z #	@138
+; stub ??6ostream@@QAEAAV0@PBC@Z #	@139
+; stub ??6ostream@@QAEAAV0@PBD@Z #	@140
+; stub ??6ostream@@QAEAAV0@PBE@Z #	@141
+; stub ??6ostream@@QAEAAV0@PBX@Z #	@142
+; stub ??7ios@@QBEHXZ #	@143
+; stub ??Bios@@QBEPAXXZ #	@144
+; stub ??_7filebuf@@6B@ #	@145
+; stub ??_7fstream@@6B@ #	@146
+; stub ??_7ifstream@@6B@ #	@147
+; stub ??_7ios@@6B@ #	@148
+; stub ??_7iostream@@6B@ #	@149
+; stub ??_7istream@@6B@ #	@150
+; stub ??_7istream_withassign@@6B@ #	@151
+; stub ??_7istrstream@@6B@ #	@152
+; stub ??_7ofstream@@6B@ #	@153
+; stub ??_7ostream@@6B@ #	@154
+; stub ??_7ostream_withassign@@6B@ #	@155
+; stub ??_7ostrstream@@6B@ #	@156
+; stub ??_7stdiobuf@@6B@ #	@157
+; stub ??_7stdiostream@@6B@ #	@158
+; stub ??_7streambuf@@6B@ #	@159
+; stub ??_7strstream@@6B@ #	@160
+; stub ??_7strstreambuf@@6B@ #	@161
+; stub ??_8fstream@@7Bistream@@@ #	@162
+; stub ??_8fstream@@7Bostream@@@ #	@163
+; stub ??_8ifstream@@7B@ #	@164
+; stub ??_8iostream@@7Bistream@@@ #	@165
+; stub ??_8iostream@@7Bostream@@@ #	@166
+; stub ??_8istream@@7B@ #	@167
+; stub ??_8istream_withassign@@7B@ #	@168
+; stub ??_8istrstream@@7B@ #	@169
+; stub ??_8ofstream@@7B@ #	@170
+; stub ??_8ostream@@7B@ #	@171
+; stub ??_8ostream_withassign@@7B@ #	@172
+; stub ??_8ostrstream@@7B@ #	@173
+; stub ??_8stdiostream@@7Bistream@@@ #	@174
+; stub ??_8stdiostream@@7Bostream@@@ #	@175
+; stub ??_8strstream@@7Bistream@@@ #	@176
+; stub ??_8strstream@@7Bostream@@@ #	@177
+; stub ??_Dfstream@@QAEXXZ #	@178
+; stub ??_Difstream@@QAEXXZ #	@179
+; stub ??_Diostream@@QAEXXZ #	@180
+; stub ??_Distream@@QAEXXZ #	@181
+; stub ??_Distream_withassign@@QAEXXZ #	@182
+; stub ??_Distrstream@@QAEXXZ #	@183
+; stub ??_Dofstream@@QAEXXZ #	@184
+; stub ??_Dostream@@QAEXXZ #	@185
+; stub ??_Dostream_withassign@@QAEXXZ #	@186
+; stub ??_Dostrstream@@QAEXXZ #	@187
+; stub ??_Dstdiostream@@QAEXXZ #	@188
+; stub ??_Dstrstream@@QAEXXZ #	@189
+; stub ??_EIostream_init@@QAEPAXI@Z #	@190
+; stub ??_Efilebuf@@UAEPAXI@Z #	@191
+; stub ??_Efstream@@UAEPAXI@Z #	@192
+; stub ??_Eifstream@@UAEPAXI@Z #	@193
+; stub ??_Eios@@UAEPAXI@Z #	@194
+; stub ??_Eiostream@@UAEPAXI@Z #	@195
+; stub ??_Eistream@@UAEPAXI@Z #	@196
+; stub ??_Eistream_withassign@@UAEPAXI@Z #	@197
+; stub ??_Eistrstream@@UAEPAXI@Z #	@198
+; stub ??_Eofstream@@UAEPAXI@Z #	@199
+; stub ??_Eostream@@UAEPAXI@Z #	@200
+; stub ??_Eostream_withassign@@UAEPAXI@Z #	@201
+; stub ??_Eostrstream@@UAEPAXI@Z #	@202
+; stub ??_Estdiobuf@@UAEPAXI@Z #	@203
+; stub ??_Estdiostream@@UAEPAXI@Z #	@204
+; stub ??_Estreambuf@@UAEPAXI@Z #	@205
+; stub ??_Estrstream@@UAEPAXI@Z #	@206
+; stub ??_Estrstreambuf@@UAEPAXI@Z #	@207
+; stub ??_GIostream_init@@QAEPAXI@Z #	@208
+; stub ??_Gfilebuf@@UAEPAXI@Z #	@209
+; stub ??_Gfstream@@UAEPAXI@Z #	@210
+; stub ??_Gifstream@@UAEPAXI@Z #	@211
+; stub ??_Gios@@UAEPAXI@Z #	@212
+; stub ??_Giostream@@UAEPAXI@Z #	@213
+; stub ??_Gistream@@UAEPAXI@Z #	@214
+; stub ??_Gistream_withassign@@UAEPAXI@Z #	@215
+; stub ??_Gistrstream@@UAEPAXI@Z #	@216
+; stub ??_Gofstream@@UAEPAXI@Z #	@217
+; stub ??_Gostream@@UAEPAXI@Z #	@218
+; stub ??_Gostream_withassign@@UAEPAXI@Z #	@219
+; stub ??_Gostrstream@@UAEPAXI@Z #	@220
+; stub ??_Gstdiobuf@@UAEPAXI@Z #	@221
+; stub ??_Gstdiostream@@UAEPAXI@Z #	@222
+; stub ??_Gstreambuf@@UAEPAXI@Z #	@223
+; stub ??_Gstrstream@@UAEPAXI@Z #	@224
+; stub ??_Gstrstreambuf@@UAEPAXI@Z #	@225
+  ?_query_new_handler@@YAP6AHI@ZXZ	@226
+  ?_query_new_mode@@YAHXZ	@227
+  ?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z	@228
+  ?_set_new_mode@@YAHH@Z 	@229
+  ?_set_se_translator@@YAP6AXIPAU_EXCEPTION_POINTERS@@@ZP6AXI0@Z@Z	@230
+; stub ?adjustfield@ios@@2JB #	@231
+; stub ?allocate@streambuf@@IAEHXZ #	@232
+; stub ?attach@filebuf@@QAEPAV1@H@Z #	@233
+; stub ?attach@fstream@@QAEXH@Z #	@234
+; stub ?attach@ifstream@@QAEXH@Z #	@235
+; stub ?attach@ofstream@@QAEXH@Z #	@236
+; stub ?bad@ios@@QBEHXZ #	@237
+; stub ?base@streambuf@@IBEPADXZ #	@238
+; stub ?basefield@ios@@2JB #	@239
+; stub ?binary@filebuf@@2HB #	@240
+; stub ?bitalloc@ios@@SAJXZ #	@241
+; stub ?blen@streambuf@@IBEHXZ #	@242
+; stub ?cerr@@3Vostream_withassign@@A #	@243
+; stub ?cin@@3Vistream_withassign@@A #	@244
+; stub ?clear@ios@@QAEXH@Z #	@245
+; stub ?clog@@3Vostream_withassign@@A #	@246
+; stub ?close@filebuf@@QAEPAV1@XZ #	@247
+; stub ?close@fstream@@QAEXXZ #	@248
+; stub ?close@ifstream@@QAEXXZ #	@249
+; stub ?close@ofstream@@QAEXXZ #	@250
+; stub ?clrlock@ios@@QAAXXZ #	@251
+; stub ?clrlock@streambuf@@QAEXXZ #	@252
+; stub ?cout@@3Vostream_withassign@@A #	@253
+; stub ?dbp@streambuf@@QAEXXZ #	@254
+; stub ?dec@@YAAAVios@@AAV1@@Z #	@255
+; stub ?delbuf@ios@@QAEXH@Z #	@256
+; stub ?delbuf@ios@@QBEHXZ #	@257
+; stub ?doallocate@streambuf@@MAEHXZ #	@258
+; stub ?doallocate@strstreambuf@@MAEHXZ #	@259
+; stub ?eatwhite@istream@@QAEXXZ #	@260
+; stub ?eback@streambuf@@IBEPADXZ #	@261
+; stub ?ebuf@streambuf@@IBEPADXZ #	@262
+; stub ?egptr@streambuf@@IBEPADXZ #	@263
+; stub ?endl@@YAAAVostream@@AAV1@@Z #	@264
+; stub ?ends@@YAAAVostream@@AAV1@@Z #	@265
+; stub ?eof@ios@@QBEHXZ #	@266
+; stub ?epptr@streambuf@@IBEPADXZ #	@267
+; stub ?fLockcInit@ios@@0HA #	@268
+; stub ?fail@ios@@QBEHXZ #	@269
+; stub ?fd@filebuf@@QBEHXZ #	@270
+; stub ?fd@fstream@@QBEHXZ #	@271
+; stub ?fd@ifstream@@QBEHXZ #	@272
+; stub ?fd@ofstream@@QBEHXZ #	@273
+; stub ?fill@ios@@QAEDD@Z #	@274
+; stub ?fill@ios@@QBEDXZ #	@275
+; stub ?flags@ios@@QAEJJ@Z #	@276
+; stub ?flags@ios@@QBEJXZ #	@277
+; stub ?floatfield@ios@@2JB #	@278
+; stub ?flush@@YAAAVostream@@AAV1@@Z #	@279
+; stub ?flush@ostream@@QAEAAV1@XZ #	@280
+; stub ?freeze@strstreambuf@@QAEXH@Z #	@281
+; stub ?gbump@streambuf@@IAEXH@Z #	@282
+; stub ?gcount@istream@@QBEHXZ #	@283
+; stub ?get@istream@@QAEAAV1@AAC@Z #	@284
+; stub ?get@istream@@QAEAAV1@AAD@Z #	@285
+; stub ?get@istream@@QAEAAV1@AAE@Z #	@286
+; stub ?get@istream@@QAEAAV1@AAVstreambuf@@D@Z #	@287
+; stub ?get@istream@@QAEAAV1@PACHD@Z #	@288
+; stub ?get@istream@@QAEAAV1@PADHD@Z #	@289
+; stub ?get@istream@@QAEAAV1@PAEHD@Z #	@290
+; stub ?get@istream@@QAEHXZ #	@291
+; stub ?getdouble@istream@@AAEHPADH@Z #	@292
+; stub ?getint@istream@@AAEHPAD@Z #	@293
+; stub ?getline@istream@@QAEAAV1@PACHD@Z #	@294
+; stub ?getline@istream@@QAEAAV1@PADHD@Z #	@295
+; stub ?getline@istream@@QAEAAV1@PAEHD@Z #	@296
+; stub ?good@ios@@QBEHXZ #	@297
+; stub ?gptr@streambuf@@IBEPADXZ #	@298
+; stub ?hex@@YAAAVios@@AAV1@@Z #	@299
+; stub ?ignore@istream@@QAEAAV1@HH@Z #	@300
+; stub ?in_avail@streambuf@@QBEHXZ #	@301
+; stub ?init@ios@@IAEXPAVstreambuf@@@Z #	@302
+; stub ?ipfx@istream@@QAEHH@Z #	@303
+; stub ?is_open@filebuf@@QBEHXZ #	@304
+; stub ?is_open@fstream@@QBEHXZ #	@305
+; stub ?is_open@ifstream@@QBEHXZ #	@306
+; stub ?is_open@ofstream@@QBEHXZ #	@307
+; stub ?isfx@istream@@QAEXXZ #	@308
+; stub ?iword@ios@@QBEAAJH@Z #	@309
+; stub ?lock@ios@@QAAXXZ #	@310
+; stub ?lock@streambuf@@QAEXXZ #	@311
+; stub ?lockbuf@ios@@QAAXXZ #	@312
+; stub ?lockc@ios@@KAXXZ #	@313
+; stub ?lockptr@ios@@IAEPAU_RTL_CRITICAL_SECTION@@XZ #	@314
+; stub ?lockptr@streambuf@@IAEPAU_RTL_CRITICAL_SECTION@@XZ #	@315
+; stub ?oct@@YAAAVios@@AAV1@@Z #	@316
+; stub ?open@filebuf@@QAEPAV1@PBDHH@Z #	@317
+; stub ?open@fstream@@QAEXPBDHH@Z #	@318
+; stub ?open@ifstream@@QAEXPBDHH@Z #	@319
+; stub ?open@ofstream@@QAEXPBDHH@Z #	@320
+; stub ?openprot@filebuf@@2HB #	@321
+; stub ?opfx@ostream@@QAEHXZ #	@322
+; stub ?osfx@ostream@@QAEXXZ #	@323
+; stub ?out_waiting@streambuf@@QBEHXZ #	@324
+; stub ?overflow@filebuf@@UAEHH@Z #	@325
+; stub ?overflow@stdiobuf@@UAEHH@Z #	@326
+; stub ?overflow@strstreambuf@@UAEHH@Z #	@327
+; stub ?pbackfail@stdiobuf@@UAEHH@Z #	@328
+; stub ?pbackfail@streambuf@@UAEHH@Z #	@329
+; stub ?pbase@streambuf@@IBEPADXZ #	@330
+; stub ?pbump@streambuf@@IAEXH@Z #	@331
+; stub ?pcount@ostrstream@@QBEHXZ #	@332
+; stub ?pcount@strstream@@QBEHXZ #	@333
+; stub ?peek@istream@@QAEHXZ #	@334
+; stub ?pptr@streambuf@@IBEPADXZ #	@335
+; stub ?precision@ios@@QAEHH@Z #	@336
+; stub ?precision@ios@@QBEHXZ #	@337
+; stub ?put@ostream@@QAEAAV1@C@Z #	@338
+; stub ?put@ostream@@QAEAAV1@D@Z #	@339
+; stub ?put@ostream@@QAEAAV1@E@Z #	@340
+; stub ?putback@istream@@QAEAAV1@D@Z #	@341
+; stub ?pword@ios@@QBEAAPAXH@Z #	@342
+; stub ?rdbuf@fstream@@QBEPAVfilebuf@@XZ #	@343
+; stub ?rdbuf@ifstream@@QBEPAVfilebuf@@XZ #	@344
+; stub ?rdbuf@ios@@QBEPAVstreambuf@@XZ #	@345
+; stub ?rdbuf@istrstream@@QBEPAVstrstreambuf@@XZ #	@346
+; stub ?rdbuf@ofstream@@QBEPAVfilebuf@@XZ #	@347
+; stub ?rdbuf@ostrstream@@QBEPAVstrstreambuf@@XZ #	@348
+; stub ?rdbuf@stdiostream@@QBEPAVstdiobuf@@XZ #	@349
+; stub ?rdbuf@strstream@@QBEPAVstrstreambuf@@XZ #	@350
+; stub ?rdstate@ios@@QBEHXZ #	@351
+; stub ?read@istream@@QAEAAV1@PACH@Z #	@352
+; stub ?read@istream@@QAEAAV1@PADH@Z #	@353
+; stub ?read@istream@@QAEAAV1@PAEH@Z #	@354
+; stub ?sbumpc@streambuf@@QAEHXZ #	@355
+; stub ?seekg@istream@@QAEAAV1@J@Z #	@356
+; stub ?seekg@istream@@QAEAAV1@JW4seek_dir@ios@@@Z #	@357
+; stub ?seekoff@filebuf@@UAEJJW4seek_dir@ios@@H@Z #	@358
+; stub ?seekoff@stdiobuf@@UAEJJW4seek_dir@ios@@H@Z #	@359
+; stub ?seekoff@streambuf@@UAEJJW4seek_dir@ios@@H@Z #	@360
+; stub ?seekoff@strstreambuf@@UAEJJW4seek_dir@ios@@H@Z #	@361
+; stub ?seekp@ostream@@QAEAAV1@J@Z #	@362
+; stub ?seekp@ostream@@QAEAAV1@JW4seek_dir@ios@@@Z #	@363
+; stub ?seekpos@streambuf@@UAEJJH@Z #	@364
+  ?set_terminate@@YAP6AXXZP6AXXZ@Z	@365
+  ?set_unexpected@@YAP6AXXZP6AXXZ@Z 	@366
+; stub ?setb@streambuf@@IAEXPAD0H@Z #	@367
+; stub ?setbuf@filebuf@@UAEPAVstreambuf@@PADH@Z #	@368
+; stub ?setbuf@fstream@@QAEPAVstreambuf@@PADH@Z #	@369
+; stub ?setbuf@ifstream@@QAEPAVstreambuf@@PADH@Z #	@370
+; stub ?setbuf@ofstream@@QAEPAVstreambuf@@PADH@Z #	@371
+; stub ?setbuf@streambuf@@UAEPAV1@PADH@Z #	@372
+; stub ?setbuf@strstreambuf@@UAEPAVstreambuf@@PADH@Z #	@373
+; stub ?setf@ios@@QAEJJ@Z #	@374
+; stub ?setf@ios@@QAEJJJ@Z #	@375
+; stub ?setg@streambuf@@IAEXPAD00@Z #	@376
+; stub ?setlock@ios@@QAAXXZ #	@377
+; stub ?setlock@streambuf@@QAEXXZ #	@378
+; stub ?setmode@filebuf@@QAEHH@Z #	@379
+; stub ?setmode@fstream@@QAEHH@Z #	@380
+; stub ?setmode@ifstream@@QAEHH@Z #	@381
+; stub ?setmode@ofstream@@QAEHH@Z #	@382
+; stub ?setp@streambuf@@IAEXPAD0@Z #	@383
+; stub ?setrwbuf@stdiobuf@@QAEHHH@Z #	@384
+; stub ?sgetc@streambuf@@QAEHXZ #	@385
+; stub ?sgetn@streambuf@@QAEHPADH@Z #	@386
+; stub ?sh_none@filebuf@@2HB #	@387
+; stub ?sh_read@filebuf@@2HB #	@388
+; stub ?sh_write@filebuf@@2HB #	@389
+; stub ?snextc@streambuf@@QAEHXZ #	@390
+; stub ?sputbackc@streambuf@@QAEHD@Z #	@391
+; stub ?sputc@streambuf@@QAEHH@Z #	@392
+; stub ?sputn@streambuf@@QAEHPBDH@Z #	@393
+; stub ?stdiofile@stdiobuf@@QAEPAU_iobuf@@XZ #	@394
+; stub ?stossc@streambuf@@QAEXXZ #	@395
+; stub ?str@istrstream@@QAEPADXZ #	@396
+; stub ?str@ostrstream@@QAEPADXZ #	@397
+; stub ?str@strstream@@QAEPADXZ #	@398
+; stub ?str@strstreambuf@@QAEPADXZ #	@399
+; stub ?sunk_with_stdio@ios@@0HA #	@400
+; stub ?sync@filebuf@@UAEHXZ #	@401
+; stub ?sync@istream@@QAEHXZ #	@402
+; stub ?sync@stdiobuf@@UAEHXZ #	@403
+; stub ?sync@streambuf@@UAEHXZ #	@404
+; stub ?sync@strstreambuf@@UAEHXZ #	@405
+; stub ?sync_with_stdio@ios@@SAXXZ #	@406
+; stub ?tellg@istream@@QAEJXZ #	@407
+; stub ?tellp@ostream@@QAEJXZ #	@408
+  ?terminate@@YAXXZ	@409
+; stub ?text@filebuf@@2HB #	@410
+; stub ?tie@ios@@QAEPAVostream@@PAV2@@Z #	@411
+; stub ?tie@ios@@QBEPAVostream@@XZ #	@412
+; stub ?unbuffered@streambuf@@IAEXH@Z #	@413
+; stub ?unbuffered@streambuf@@IBEHXZ #	@414
+; stub ?underflow@filebuf@@UAEHXZ #	@415
+; stub ?underflow@stdiobuf@@UAEHXZ #	@416
+; stub ?underflow@strstreambuf@@UAEHXZ #	@417
+  ?unexpected@@YAXXZ 	@418
+; stub ?unlock@ios@@QAAXXZ #	@419
+; stub ?unlock@streambuf@@QAEXXZ #	@420
+; stub ?unlockbuf@ios@@QAAXXZ #	@421
+; stub ?unlockc@ios@@KAXXZ #	@422
+; stub ?unsetf@ios@@QAEJJ@Z #	@423
+; stub ?width@ios@@QAEHH@Z #	@424
+; stub ?width@ios@@QBEHXZ #	@425
+; stub ?write@ostream@@QAEAAV1@PBCH@Z #	@426
+; stub ?write@ostream@@QAEAAV1@PBDH@Z #	@427
+; stub ?write@ostream@@QAEAAV1@PBEH@Z #	@428
+; stub ?writepad@ostream@@AAEAAV1@PBD0@Z #	@429
+; stub ?ws@@YAAAVistream@@AAV1@@Z #	@430
+; stub ?x_curindex@ios@@0HA #	@431
+; stub ?x_lockc@ios@@0U_RTL_CRITICAL_SECTION@@A #	@432
+; stub ?x_maxbit@ios@@0JA #	@433
+; stub ?x_statebuf@ios@@0QAJA #	@434
+; stub ?xalloc@ios@@SAHXZ #	@435
+; stub ?xsgetn@streambuf@@UAEHPADH@Z #	@436
+; stub ?xsputn@streambuf@@UAEHPBDH@Z #	@437
+; stub $I10_OUTPUT #	@438
+  _CIacos 	@439
+  _CIasin 	@440
+  _CIatan	@441
+  _CIatan2 	@442
+  _CIcos	@443
+  _CIcosh 	@444
+  _CIexp	@445
+  _CIfmod	@446
+  _CIlog 	@447
+  _CIlog10 	@448
+  _CIpow 	@449
+  _CIsin	@450
+  _CIsinh	@451
+  _CIsqrt	@452
+  _CItan 	@453
+  _CItanh	@454
+  _CxxThrowException	@455
+  _HUGE 	@456
+  _XcptFilter	@457
+  __CxxFrameHandler	@458
+;  __CxxLongjmpUnwind	@459
+; __STRINGTOLD 	@460
+  __argc 	@461
+  __argv	@462
+  __dllonexit	@463
+  __doserrno	@464
+;  __fpecode	@465
+; cdecl __getmainargs(ptr ptr ptr long long) MSVCRT20__getmainargs	@466
+  __initenv	@467
+  __isascii	@468
+  __iscsym	@469
+  __iscsymf	@470
+  __lconv_init	@471
+  __mb_cur_max 	@472
+  __p___argc	@473
+  __p___argv	@474
+  __p___initenv	@475
+  __p___mb_cur_max	@476
+  __p___wargv	@477
+  __p___winitenv	@478
+  __p__acmdln	@479
+;  __p__amblksiz	@480
+  __p__commode	@481
+;  __p__daylight	@482
+  __p__environ	@483
+  __p__fmode	@484
+  __p__iob	@485
+  __p__mbctype	@486
+  __p__osver	@487
+  __p__pctype	@488
+;  __p__pgmptr	@489
+;  __p__pwctype	@490
+  __p__timezone	@491
+;  __p__tzname	@492
+  __p__wcmdln	@493
+  __p__wenviron	@494
+  __p__winmajor	@495
+  __p__winminor	@496
+  __p__winver 	@497
+;  __p__wpgmptr	@498
+;  __pxcptinfoptrs	@499
+  __threadhandle	@500
+  __threadid	@501
+  __toascii	@502
+  __wargv	@503
+;@ cdecl __wgetmainargs(ptr ptr ptr long long) MSVCRT20__wgetmainargs	@504
+  __winitenv	@505
+  _abnormal_termination	@506
+  _access 	@507
+  _acmdln	@508
+  _adj_fdiv_m16i	@509
+  _adj_fdiv_m32	@510
+  _adj_fdiv_m32i	@511
+  _adj_fdiv_m64 	@512
+  _adj_fdiv_r	@513
+  _adj_fdivr_m16i 	@514
+  _adj_fdivr_m32	@515
+  _adj_fdivr_m32i	@516
+  _adj_fdivr_m64	@517
+  _adj_fpatan	@518
+  _adj_fprem	@519
+  _adj_fprem1	@520
+  _adj_fptan	@521
+  _adjust_fdiv	@522
+;  _aexit_rtn	@523
+  _amsg_exit 	@524
+  _assert	@525
+;  _atodbl	@526
+;  _atoldbl	@527
+  _beep	@528
+  _beginthread 	@529
+  _beginthreadex	@530
+  _c_exit	@531
+  _cabs	@532
+  _cexit	@533
+  _cgets	@534
+  _chdir	@535
+  _chdrive	@536
+  _chgsign	@537
+  _chmod	@538
+;  _chsize	@539
+  _clearfp	@540
+  _close	@541
+  _commit	@542
+  _commode	@543
+  _control87	@544
+  _controlfp	@545
+  _copysign	@546
+  _cprintf = _cprintf	@547
+  _cputs = _cputs	@548
+  _creat = _creat	@549
+  _cscanf = _cscanf	@550
+  _ctype = _ctype	@551
+  _cwait = _cwait	@552
+;  _daylight = _daylight	@553
+;  _dup = _dup	@554
+;  _dup2 = _dup2	@555
+  _ecvt = _ecvt	@556
+  _endthread = _endthread	@557
+  _endthreadex = _endthreadex	@558
+  _environ = _environ	@559
+  _eof = _eof	@560
+  _errno = _errno	@561
+  _except_handler2 = _except_handler2	@562
+  _except_handler3 = _except_handler3	@563
+  _execl = _execl	@564
+;  _execle = _execle	@565
+  _execlp = _execlp	@566
+;  _execlpe = _execlpe	@567
+  _execv = _execv	@568
+  _execve = _execve	@569
+  _execvp = _execvp	@570
+  _execvpe = _execvpe	@571
+  _exit = _exit	@572
+  _expand = _expand	@573
+  _fcloseall = _fcloseall	@574
+;  _fcvt = _fcvt	@575
+  _fdopen = _fdopen	@576
+  _fgetchar = _fgetchar	@577
+  _fgetwchar = _fgetwchar	@578
+  _filbuf = _filbuf	@579
+;  _fileinfo = _fileinfo	@580
+  _filelength = _filelength	@581
+  _fileno = _fileno	@582
+  _findclose = _findclose	@583
+  _findfirst = _findfirst	@584
+  _findnext = _findnext	@585
+  _finite = _finite	@586
+  _flsbuf = _flsbuf	@587
+  _flushall = _flushall	@588
+  _fmode = _fmode	@589
+  _fpclass = _fpclass	@590
+;  _fpieee_flt = _fpieee_flt	@591
+  _fpreset = _fpreset	@592
+  _fputchar = _fputchar	@593
+  _fputwchar = _fputwchar	@594
+  _fsopen = _fsopen	@595
+  _fstat = _fstat	@596
+  _ftime = _ftime	@597
+  _ftol = _ftol	@598
+  _fullpath = _fullpath	@599
+  _futime = _futime	@600
+  _gcvt = _gcvt	@601
+  _get_osfhandle = _get_osfhandle	@602
+  _getch = _getch	@603
+  _getche = _getche	@604
+  _getcwd = _getcwd	@605
+  _getdcwd = _getdcwd	@606
+  _getdiskfree = _getdiskfree	@607
+  _getdllprocaddr = _getdllprocaddr	@608
+  _getdrive = _getdrive	@609
+  _getdrives = _getdrives	@610
+  _getmbcp = _getmbcp	@611
+  _getpid = _getpid	@612
+;  _getsystime = _getsystime	@613
+  _getw = _getw	@614
+  _getws = _getws	@615
+  _global_unwind2 = _global_unwind2	@616
+  _heapadd = _heapadd	@617
+  _heapchk = _heapchk	@618
+  _heapmin = _heapmin	@619
+  _heapset = _heapset	@620
+;  _heapused = _heapused	@621
+  _heapwalk = _heapwalk	@622
+  _hypot = _hypot	@623
+  _initterm = _initterm	@624
+  _iob = _iob	@625
+  _isatty = _isatty	@626
+  _isctype = _isctype	@627
+;  _ismbbalnum = _ismbbalnum	@628
+;  _ismbbalpha = _ismbbalpha	@629
+;  _ismbbgraph = _ismbbgraph	@630
+;  _ismbbkalnum = _ismbbkalnum	@631
+  _ismbbkana = _ismbbkana	@632
+;  _ismbbkprint = _ismbbkprint	@633
+;  _ismbbkpunct = _ismbbkpunct	@634
+  _ismbblead = _ismbblead	@635
+;  _ismbbprint = _ismbbprint	@636
+;  _ismbbpunct = _ismbbpunct	@637
+  _ismbbtrail = _ismbbtrail	@638
+  _ismbcalnum = _ismbcalnum	@639
+  _ismbcalpha = _ismbcalpha	@640
+  _ismbcdigit = _ismbcdigit	@641
+  _ismbcgraph = _ismbcgraph	@642
+  _ismbchira = _ismbchira	@643
+  _ismbckata = _ismbckata	@644
+;  _ismbcl0 = _ismbcl0	@645
+;  _ismbcl1 = _ismbcl1	@646
+;  _ismbcl2 = _ismbcl2	@647
+;  _ismbclegal = _ismbclegal	@648
+  _ismbclower = _ismbclower	@649
+  _ismbcprint = _ismbcprint	@650
+  _ismbcpunct = _ismbcpunct	@651
+  _ismbcspace = _ismbcspace	@652
+  _ismbcsymbol = _ismbcsymbol	@653
+  _ismbcupper = _ismbcupper	@654
+  _ismbslead = _ismbslead	@655
+  _ismbstrail = _ismbstrail	@656
+  _isnan = _isnan	@657
+  _itoa = _itoa	@658
+  _itow = _itow	@659
+  _j0 = _j0	@660
+  _j1 = _j1	@661
+  _jn = _jn	@662
+  _kbhit = _kbhit	@663
+  _lfind = _lfind	@664
+  _loaddll = _loaddll	@665
+  _local_unwind2 = _local_unwind2	@666
+  _locking = _locking	@667
+  _logb = _logb	@668
+;  _longjmpex = _longjmpex	@669
+  _lrotl = _lrotl	@670
+  _lrotr = _lrotr	@671
+  _lsearch = _lsearch	@672
+  _lseek = _lseek	@673
+  _ltoa = _ltoa	@674
+  _ltow = _ltow	@675
+  _makepath = _makepath	@676
+  _matherr = _matherr	@677
+  _mbbtombc = _mbbtombc	@678
+;  _mbbtype = _mbbtype	@679
+  _mbccpy = _mbccpy	@680
+;  _mbcjistojms = _mbcjistojms	@681
+;  _mbcjmstojis = _mbcjmstojis	@682
+  _mbclen = _mbclen	@683
+;  _mbctohira = _mbctohira	@684
+;  _mbctokata = _mbctokata	@685
+  _mbctolower = _mbctolower	@686
+;  _mbctombb = _mbctombb	@687
+  _mbctoupper = _mbctoupper	@688
+;  _mbctype = _mbctype	@689
+;  _mbsbtype = _mbsbtype	@690
+  _mbscat = _mbscat	@691
+  _mbschr = _mbschr	@692
+  _mbscmp = _mbscmp	@693
+;  _mbscoll = _mbscoll	@694
+  _mbscpy = _mbscpy	@695
+  _mbscspn = _mbscspn	@696
+  _mbsdec = _mbsdec	@697
+  _mbsdup = _mbsdup	@698
+  _mbsicmp = _mbsicmp	@699
+;  _mbsicoll = _mbsicoll	@700
+  _mbsinc = _mbsinc	@701
+  _mbslen = _mbslen	@702
+  _mbslwr = _mbslwr	@703
+;  _mbsnbcat = _mbsnbcat	@704
+  _mbsnbcmp = _mbsnbcmp	@705
+  _mbsnbcnt = _mbsnbcnt	@706
+;  _mbsnbcoll = _mbsnbcoll	@707
+  _mbsnbcpy = _mbsnbcpy	@708
+  _mbsnbicmp = _mbsnbicmp	@709
+;  _mbsnbicoll = _mbsnbicoll	@710
+;  _mbsnbset = _mbsnbset	@711
+  _mbsncat = _mbsncat	@712
+  _mbsnccnt = _mbsnccnt	@713
+  _mbsncmp = _mbsncmp	@714
+;  _mbsncoll = _mbsncoll	@715
+  _mbsncpy = _mbsncpy	@716
+  _mbsnextc = _mbsnextc	@717
+  _mbsnicmp = _mbsnicmp	@718
+;  _mbsnicoll = _mbsnicoll	@719
+  _mbsninc = _mbsninc	@720
+  _mbsnset = _mbsnset	@721
+  _mbspbrk = _mbspbrk	@722
+  _mbsrchr = _mbsrchr	@723
+  _mbsrev = _mbsrev	@724
+  _mbsset = _mbsset	@725
+  _mbsspn = _mbsspn	@726
+;  _mbsspnp = _mbsspnp	@727
+  _mbsstr = _mbsstr	@728
+;  _mbstok = _mbstok	@729
+  _mbstrlen = _mbstrlen	@730
+  _mbsupr = _mbsupr	@731
+  _memccpy = _memccpy	@732
+  _memicmp = _memicmp	@733
+  _mkdir = _mkdir	@734
+  _mktemp = _mktemp	@735
+  _msize = _msize	@736
+; stub _mtlock	@737
+; stub _mtunlock	@738
+  _nextafter = _nextafter	@739
+  _onexit = _onexit	@740
+  _open = _open	@741
+  _open_osfhandle = _open_osfhandle	@742
+;  _osver = _osver	@743
+;  _pclose = _pclose	@744
+  _pctype = _pctype	@745
+;  _pgmptr = _pgmptr	@746
+;  _pipe = _pipe	@747
+;  _popen = _popen	@748
+  _purecall = _purecall	@749
+  _putch = _putch	@750
+  _putenv = _putenv	@751
+  _putw = _putw	@752
+  _putws = _putws	@753
+;  _pwctype = _pwctype	@754
+  _read = _read	@755
+  _rmdir = _rmdir	@756
+  _rmtmp = _rmtmp	@757
+  _rotl = _rotl	@758
+  _rotr = _rotr	@759
+  _safe_fdiv = _safe_fdiv	@760
+  _safe_fdivr = _safe_fdivr	@761
+  _safe_fprem = _safe_fprem	@762
+  _safe_fprem1 = _safe_fprem1	@763
+  _scalb = _scalb	@764
+  _searchenv = _searchenv	@765
+  __seh_longjmp_unwind = _seh_longjmp_unwind	@766
+;  _seterrormode = _seterrormode	@767
+  _setjmp = _setjmp	@768
+  _setjmp3 = _setjmp3	@769
+  _setmbcp = _setmbcp	@770
+  _setmode = _setmode	@771
+;  _setsystime = _setsystime	@772
+  _sleep = _sleep	@773
+  _snprintf = _snprintf	@774
+  _snwprintf = _snwprintf	@775
+  _sopen = _sopen	@776
+  _spawnl = _spawnl	@777
+;  _spawnle = _spawnle	@778
+  _spawnlp = _spawnlp	@779
+;  _spawnlpe = _spawnlpe	@780
+  _spawnv = _spawnv	@781
+  _spawnve = _spawnve	@782
+  _spawnvp = _spawnvp	@783
+  _spawnvpe = _spawnvpe	@784
+  _splitpath = _splitpath	@785
+  _stat = _stat	@786
+  _statusfp = _statusfp	@787
+  _strcmpi = _strcmpi	@788
+  _strdate = _strdate	@789
+  _strdup = _strdup	@790
+  _strerror = _strerror	@791
+  _stricmp = _stricmp	@792
+;  _stricoll = _stricoll	@793
+  _strlwr = _strlwr	@794
+;  _strncoll = _strncoll	@795
+  _strnicmp = _strnicmp	@796
+;  _strnicoll = _strnicoll	@797
+  _strnset = _strnset	@798
+  _strrev = _strrev	@799
+  _strset = _strset	@800
+  _strtime = _strtime	@801
+  _strupr = _strupr	@802
+  _swab = _swab	@803
+  _sys_errlist = _sys_errlist	@804
+  _sys_nerr = _sys_nerr	@805
+  _tccpy = _mbccpy	@806
+  _tclen = _mbclen	@807
+  _tcschr = _mbschr	@808
+  _tcsclen = _mbslen	@809
+  _tcscmp = _mbscmp	@810
+  _tcscspn = _mbscspn	@811
+  _tcsdec = _mbsdec	@812
+  _tcsicmp = _mbsicmp	@813
+  _tcsinc = _mbsinc	@814
+  _tcslwr = _mbslwr	@815
+  _tcsnbcnt = _mbsnbcnt	@816
+;  _tcsncat = _mbsnbcat	@817
+  _tcsnccat = _mbsncat	@818
+  _tcsnccmp = _mbsncmp	@819
+  _tcsnccnt = _mbsnccnt	@820
+  _tcsnccpy = _mbsncpy	@821
+  _tcsncicmp = _mbsnicmp	@822
+  _tcsncmp = _mbsnbcmp	@823
+  _tcsncpy = _mbsnbcpy	@824
+  _tcsncset = _mbsnset	@825
+  _tcsnextc = _mbsnextc	@826
+  _tcsnicmp = _mbsnbicmp	@827
+  _tcsninc = _mbsninc	@828
+;  _tcsnset = _mbsnbset	@829
+  _tcspbrk = _mbspbrk	@830
+  _tcsrchr = _mbsrchr	@831
+  _tcsrev = _mbsrev	@832
+  _tcsset = _mbsset	@833
+  _tcsspn = _mbsspn	@834
+;  _tcsspnp = _mbsspnp	@835
+  _tcsstr = _mbsstr	@836
+;  _tcstok = _mbstok	@837
+  _tcsupr = _mbsupr	@838
+  _tell = _tell	@839
+  _tempnam = _tempnam	@840
+;  _timezone = _timezone	@841
+  _tolower = _tolower	@842
+  _toupper = _toupper	@843
+;  _tzname = _tzname	@844
+  _tzset = _tzset	@845
+  _ultoa = _ultoa	@846
+  _ultow = _ultow	@847
+  _umask = _umask	@848
+  _ungetch = _ungetch	@849
+  _unlink = _unlink	@850
+  _unloaddll = _unloaddll	@851
+  _utime = _utime	@852
+  _vsnprintf = _vsnprintf	@853
+  _vsnwprintf = _vsnwprintf	@854
+  _waccess = _waccess	@855
+;  _wasctime = _wasctime	@856
+  _wchdir = _wchdir	@857
+  _wchmod = _wchmod	@858
+  _wcmdln = _wcmdln	@859
+  _wcreat = _wcreat	@860
+  _wcsdup = _wcsdup	@861
+;  _wcsicmp = _wcsicmp	@862
+  _wcsicoll = _wcsicoll	@863
+  _wcslwr = _wcslwr	@864
+;  _wcsncoll = _wcsncoll	@865
+  _wcsnicmp = _wcsnicmp	@866
+;  _wcsnicoll = _wcsnicoll	@867
+  _wcsnset = _wcsnset	@868
+  _wcsrev = _wcsrev	@869
+  _wcsset = _wcsset	@870
+;  _wcsupr = _wcsupr	@871
+;  _wctime = _wctime	@872
+  _wenviron = _wenviron	@873
+;  _wexecl = _wexecl	@874
+;  _wexecle = _wexecle	@875
+;  _wexeclp = _wexeclp	@876
+;  _wexeclpe = _wexeclpe	@877
+;  _wexecv = _wexecv	@878
+;  _wexecve = _wexecve	@879
+;  _wexecvp = _wexecvp	@880
+;  _wexecvpe = _wexecvpe	@881
+  _wfdopen = _wfdopen	@882
+  _wfindfirst = _wfindfirst	@883
+  _wfindnext = _wfindnext	@884
+  _wfopen = _wfopen	@885
+;  _wfreopen = _wfreopen	@886
+  _wfsopen = _wfsopen	@887
+;  _wfullpath = _wfullpath	@888
+  _wgetcwd = _wgetcwd	@889
+  _wgetdcwd = _wgetdcwd	@890
+  _wgetenv = _wgetenv	@891
+  _winmajor = _winmajor	@892
+  _winminor = _winminor	@893
+  _winver = _winver	@894
+  _wmakepath = _wmakepath	@895
+  _wmkdir = _wmkdir	@896
+  _wmktemp = _wmktemp	@897
+  _wopen = _wopen	@898
+;  _wperror = _wperror	@899
+;  _wpgmptr = _wpgmptr	@900
+;  _wpopen = _wpopen	@901
+  _wputenv = _wputenv	@902
+  _wremove = _wremove	@903
+  _wrename = _wrename	@904
+  _write = _write	@905
+  _wrmdir = _wrmdir	@906
+;  _wsearchenv = _wsearchenv	@907
+;  _wsetlocale = _wsetlocale	@908
+  _wsopen = _wsopen	@909
+;  _wspawnl = _wspawnl	@910
+;  _wspawnle = _wspawnle	@911
+;  _wspawnlp = _wspawnlp	@912
+;  _wspawnlpe = _wspawnlpe	@913
+;  _wspawnv = _wspawnv	@914
+;  _wspawnve = _wspawnve	@915
+;  _wspawnvp = _wspawnvp	@916
+;  _wspawnvpe = _wspawnvpe	@917
+  _wsplitpath = _wsplitpath	@918
+  _wstat = _wstat	@919
+;  _wstrdate = _wstrdate	@920
+;  _wstrtime = _wstrtime	@921
+;  _wsystem = _wsystem	@922
+  _wtempnam = _wtempnam	@923
+;  _wtmpnam = _wtmpnam	@924
+  _wtoi = _wtoi	@925
+  _wtol = _wtol	@926
+  _wunlink = _wunlink	@927
+  _wutime = _wutime	@928
+  _y0 = _y0	@929
+  _y1 = _y1	@930
+  _yn = _yn	@931
+  abort = abort	@932
+  abs = abs	@933
+  acos = acos	@934
+  asctime = asctime	@935
+  asin = asin	@936
+  atan = atan	@937
+  atan2 = atan2	@938
+  atexit = atexit	@939
+  atof = atof	@940
+  atoi = atoi	@941
+  atol = atol	@942
+  bsearch = bsearch	@943
+  calloc = calloc	@944
+  ceil = ceil	@945
+  clearerr = clearerr	@946
+  clock = clock	@947
+  cos = cos	@948
+  cosh = cosh	@949
+  ctime = ctime	@950
+  difftime = difftime	@951
+  div = div	@952
+  exit = exit	@953
+  exp = exp	@954
+  fabs = fabs	@955
+  fclose = fclose	@956
+  feof = feof	@957
+  ferror = ferror	@958
+  fflush = fflush	@959
+  fgetc = fgetc	@960
+  fgetpos = fgetpos	@961
+  fgets = fgets	@962
+  fgetwc = fgetwc	@963
+  fgetws = fgetws	@964
+  floor = floor	@965
+  fmod = fmod	@966
+  fopen = fopen	@967
+  fprintf = fprintf	@968
+  fputc = fputc	@969
+  fputs = fputs	@970
+  fputwc = fputwc	@971
+  fputws = fputws	@972
+  fread = fread	@973
+  free = free	@974
+  freopen = freopen	@975
+  frexp = frexp	@976
+  fscanf = fscanf	@977
+  fseek = fseek	@978
+  fsetpos = fsetpos	@979
+  ftell = ftell	@980
+  fwprintf = fwprintf	@981
+  fwrite = fwrite	@982
+;  fwscanf = fwscanf	@983
+  getc = getc	@984
+  getchar = getchar	@985
+  getenv = getenv	@986
+  gets = gets	@987
+  getwc = getwc	@988
+  getwchar = getwchar	@989
+  gmtime = gmtime	@990
+  is_wctype = is_wctype	@991
+  isalnum = isalnum	@992
+  isalpha = isalpha	@993
+  iscntrl = iscntrl	@994
+  isdigit = isdigit	@995
+  isgraph = isgraph	@996
+  isleadbyte = isleadbyte	@997
+  islower = islower	@998
+  isprint = isprint	@999
+  ispunct = ispunct	@1000
+  isspace = isspace	@1001
+  isupper = isupper	@1002
+  iswalnum = iswalnum	@1003
+  iswalpha = iswalpha	@1004
+  iswascii = iswascii	@1005
+  iswcntrl = iswcntrl	@1006
+  iswctype = iswctype	@1007
+  iswdigit = iswdigit	@1008
+  iswgraph = iswgraph	@1009
+  iswlower = iswlower	@1010
+  iswprint = iswprint	@1011
+  iswpunct = iswpunct	@1012
+  iswspace = iswspace	@1013
+  iswupper = iswupper	@1014
+  iswxdigit = iswxdigit	@1015
+  isxdigit = isxdigit	@1016
+  labs = labs	@1017
+  ldexp = ldexp	@1018
+  ldiv = ldiv	@1019
+;  localeconv = localeconv	@1020
+  localtime = localtime	@1021
+  log = log	@1022
+  log10 = log10	@1023
+  longjmp = longjmp	@1024
+  malloc = malloc	@1025
+  mblen = mblen	@1026
+  mbstowcs = mbstowcs	@1027
+  mbtowc = mbtowc	@1028
+  memchr = memchr	@1029
+  memcmp = memcmp	@1030
+  memcpy = memcpy	@1031
+  memmove = memmove	@1032
+  memset = memset	@1033
+  mktime = mktime	@1034
+  modf = modf	@1035
+  perror = perror	@1036
+  pow = pow	@1037
+  printf = printf	@1038
+  putc = putc	@1039
+  putchar = putchar	@1040
+  puts = puts	@1041
+  putwc = putwc	@1042
+  putwchar = putwchar	@1043
+  qsort = qsort	@1044
+;  raise = raise	@1045
+  rand = rand	@1046
+  realloc = realloc	@1047
+  remove = remove	@1048
+  rename = rename	@1049
+  rewind = rewind	@1050
+  scanf = scanf	@1051
+  setbuf = setbuf	@1052
+  setlocale = setlocale	@1053
+  setvbuf = setvbuf	@1054
+  signal = signal	@1055
+  sin = sin	@1056
+  sinh = sinh	@1057
+  sprintf = sprintf	@1058
+  sqrt = sqrt	@1059
+  srand = srand	@1060
+  sscanf = sscanf	@1061
+  strcat = strcat	@1062
+  strchr = strchr	@1063
+  strcmp = strcmp	@1064
+  strcoll = strcoll	@1065
+  strcpy = strcpy	@1066
+  strcspn = strcspn	@1067
+  strerror = strerror	@1068
+  strftime = strftime	@1069
+  strlen = strlen	@1070
+  strncat = strncat	@1071
+  strncmp = strncmp	@1072
+  strncpy = strncpy	@1073
+  strpbrk = strpbrk	@1074
+  strrchr = strrchr	@1075
+  strspn = strspn	@1076
+  strstr = strstr	@1077
+  strtod = strtod	@1078
+  strtok = strtok	@1079
+  strtol = strtol	@1080
+  strtoul = strtoul	@1081
+  strxfrm = strxfrm	@1082
+  swprintf = swprintf	@1083
+;  swscanf = swscanf	@1084
+  system = system	@1085
+  tan = tan	@1086
+  tanh = tanh	@1087
+  time = time	@1088
+  tmpfile = tmpfile	@1089
+  tmpnam = tmpnam	@1090
+  tolower = tolower	@1091
+  toupper = toupper	@1092
+  towlower = towlower	@1093
+  towupper = towupper	@1094
+  ungetc = ungetc	@1095
+  ungetwc = ungetwc	@1096
+  vfprintf = vfprintf	@1097
+  vfwprintf = vfwprintf	@1098
+  vprintf = vprintf	@1099
+  vsprintf = vsprintf	@1100
+  vswprintf = vswprintf	@1101
+  vwprintf = vwprintf	@1102
+  wcscat = wcscat	@1103
+  wcschr = wcschr	@1104
+  wcscmp = wcscmp	@1105
+  wcscoll = wcscoll	@1106
+  wcscpy = wcscpy	@1107
+  wcscspn = wcscspn	@1108
+;  wcsftime = wcsftime	@1109
+  wcslen = wcslen	@1110
+  wcsncat = wcsncat	@1111
+  wcsncmp = wcsncmp	@1112
+  wcsncpy = wcsncpy	@1113
+  wcspbrk = wcspbrk	@1114
+  wcsrchr = wcsrchr	@1115
+  wcsspn = wcsspn	@1116
+  wcsstr = wcsstr	@1117
+;  wcstod = wcstod	@1118
+  wcstok = wcstok	@1119
+  wcstol = wcstol	@1120
+  wcstombs = wcstombs	@1121
+  wcstoul = wcstoul	@1122
+;  wcsxfrm = wcsxfrm	@1123
+  wctomb = wctomb	@1124
+  wprintf = wprintf	@1125
+;  wscanf = wscanf	@1126
+;  wscanf = wscan	@1127
Index: trunk/src/msvcrt/msvcrt20.mak
===================================================================
--- trunk/src/msvcrt/msvcrt20.mak	(revision 9633)
+++ trunk/src/msvcrt/msvcrt20.mak	(revision 9633)
@@ -0,0 +1,58 @@
+# $Id: msvcrt20.mak,v 1.5 2003-01-06 13:26:37 sandervl Exp $
+
+#
+# Odin32 API
+#
+#       msvcrt.dll makefile
+#
+
+
+#
+# Tell buildenvironment that we have a non-default makefilename.
+#
+MAKEFILE = msvcrt20.mak
+CCENV = EMX
+NOTEXPDEF = 1
+
+#
+# Compiler, tools, and interference rules.
+#
+!include ../../makefile.inc
+
+!ifndef WMAKE
+CDEFINES    = -I. $(CDEFINES) -DUSE_MSVCRT_PREFIX -D_MT -I$(ODIN32_INCLUDE)\win\msvcrt 
+!else
+CDEFINES   += -DUSE_MSVCRT_PREFIX -D_MT -I$(ODIN32_INCLUDE)\win\msvcrt
+!endif
+
+#
+# Object files. Prefix with OBJDIR and one space before the '\'.
+#
+OBJS = \
+$(OBJDIR)\mainmsvcrt20.obj \
+$(OBJDIR)\$(TARGET)rsrc.obj 
+
+#
+# Target name - name of the dll without extention and path.
+#
+TARGET = msvcrt20
+
+all: $(OBJDIR) $(OBJDIR)\$(TARGET).dll $(TARGET).lib
+
+$(OBJDIR)\$(TARGET).dll: $(OBJS) $(TARGET).def
+    $(LD) $(LDFLAGS) -Zso -Zsys $(OBJS) $(TARGET).def -L.\libs -lm\
+      -L$(OBJDIR) -liberty_s -lmsvcrt -o $(OBJDIR)\$(TARGET).dll
+    touch $(OBJDIR)\$(TARGET).map
+    @echo "Illegal Sym File for EMX" > $(OBJDIR)\$(TARGET).sym
+
+$(TARGET).lib: 
+    implib $(OBJDIR)\$(TARGET).lib msvcrt20.def
+    @copy $(OBJDIR)\$(TARGET).lib $(ODIN32_LIB_)\Release
+    @copy $(OBJDIR)\$(TARGET).lib $(ODIN32_LIB_)\Debug
+
+
+#
+# Includes the common rules.
+#
+!include $(ODIN32_POST_INC)
+
Index: trunk/src/msvcrt/msvcrt20.spec
===================================================================
--- trunk/src/msvcrt/msvcrt20.spec	(revision 9633)
+++ trunk/src/msvcrt/msvcrt20.spec	(revision 9633)
@@ -0,0 +1,1135 @@
+; $Id: msvcrt20.spec,v 1.1 2003-01-06 13:26:37 sandervl Exp $
+
+;
+; Based on Windows 98 : MSVCRT20.DLL (v2.11.000)
+;
+LIBRARY MSVCRT20 INITINSTANCE TERMINSTANCE
+DESCRIPTION 'Odin32 System DLL - MSVCrt20'
+DATA MULTIPLE NONSHARED
+
+; stub ??0Iostream_init@@QAE@AAVios@@H@Z  #
+; stub ??0Iostream_init@@QAE@XZ #
+; stub ??0filebuf@@QAE@ABV0@@Z #
+; stub ??0filebuf@@QAE@H@Z #
+; stub ??0filebuf@@QAE@HPADH@Z #
+; stub ??0filebuf@@QAE@XZ #
+; stub ??0fstream@@QAE@ABV0@@Z #
+; stub ??0fstream@@QAE@H@Z #
+; stub ??0fstream@@QAE@HPADH@Z #
+; stub ??0fstream@@QAE@PBDHH@Z #
+; stub ??0fstream@@QAE@XZ #
+; stub ??0ifstream@@QAE@ABV0@@Z #
+; stub ??0ifstream@@QAE@H@Z #
+; stub ??0ifstream@@QAE@HPADH@Z #
+; stub ??0ifstream@@QAE@PBDHH@Z #
+; stub ??0ifstream@@QAE@XZ #
+; stub ??0ios@@IAE@ABV0@@Z #
+; stub ??0ios@@IAE@XZ #
+; stub ??0ios@@QAE@PAVstreambuf@@@Z #
+; stub ??0iostream@@IAE@ABV0@@Z #
+; stub ??0iostream@@IAE@XZ #
+; stub ??0iostream@@QAE@PAVstreambuf@@@Z #
+; stub ??0istream@@IAE@ABV0@@Z #
+; stub ??0istream@@IAE@XZ #
+; stub ??0istream@@QAE@PAVstreambuf@@@Z #
+; stub ??0istream_withassign@@QAE@ABV0@@Z #
+; stub ??0istream_withassign@@QAE@PAVstreambuf@@@Z #
+; stub ??0istream_withassign@@QAE@XZ #
+; stub ??0istrstream@@QAE@ABV0@@Z #
+; stub ??0istrstream@@QAE@PAD@Z #
+; stub ??0istrstream@@QAE@PADH@Z #
+; stub ??0ofstream@@QAE@ABV0@@Z #
+; stub ??0ofstream@@QAE@H@Z #
+; stub ??0ofstream@@QAE@HPADH@Z #
+; stub ??0ofstream@@QAE@PBDHH@Z #
+; stub ??0ofstream@@QAE@XZ #
+; stub ??0ostream@@IAE@ABV0@@Z #
+; stub ??0ostream@@IAE@XZ #
+; stub ??0ostream@@QAE@PAVstreambuf@@@Z #
+; stub ??0ostream_withassign@@QAE@ABV0@@Z #
+; stub ??0ostream_withassign@@QAE@PAVstreambuf@@@Z #
+; stub ??0ostream_withassign@@QAE@XZ #
+; stub ??0ostrstream@@QAE@ABV0@@Z #
+; stub ??0ostrstream@@QAE@PADHH@Z #
+; stub ??0ostrstream@@QAE@XZ #
+; stub ??0stdiobuf@@QAE@ABV0@@Z #
+; stub ??0stdiobuf@@QAE@PAU_iobuf@@@Z #
+; stub ??0stdiostream@@QAE@ABV0@@Z #
+; stub ??0stdiostream@@QAE@PAU_iobuf@@@Z #
+; stub ??0streambuf@@IAE@PADH@Z #
+; stub ??0streambuf@@IAE@XZ #
+; stub ??0streambuf@@QAE@ABV0@@Z #
+; stub ??0strstream@@QAE@ABV0@@Z #
+; stub ??0strstream@@QAE@PADHH@Z #
+; stub ??0strstream@@QAE@XZ #
+; stub ??0strstreambuf@@QAE@ABV0@@Z #
+; stub ??0strstreambuf@@QAE@H@Z #
+; stub ??0strstreambuf@@QAE@P6APAXJ@ZP6AXPAX@Z@Z #
+; stub ??0strstreambuf@@QAE@PADH0@Z #
+; stub ??0strstreambuf@@QAE@XZ #
+; stub ??1Iostream_init@@QAE@XZ #
+; stub ??1filebuf@@UAE@XZ #
+; stub ??1fstream@@UAE@XZ #
+; stub ??1ifstream@@UAE@XZ #
+; stub ??1ios@@UAE@XZ #
+; stub ??1iostream@@UAE@XZ #
+; stub ??1istream@@UAE@XZ #
+; stub ??1istream_withassign@@UAE@XZ #
+; stub ??1istrstream@@UAE@XZ #
+; stub ??1ofstream@@UAE@XZ #
+; stub ??1ostream@@UAE@XZ #
+; stub ??1ostream_withassign@@UAE@XZ #
+; stub ??1ostrstream@@UAE@XZ #
+; stub ??1stdiobuf@@UAE@XZ #
+; stub ??1stdiostream@@UAE@XZ #
+; stub ??1streambuf@@UAE@XZ #
+; stub ??1strstream@@UAE@XZ #
+; stub ??1strstreambuf@@UAE@XZ #
+  ??2@YAPAXI@Z
+@ forward ??3@YAXPAX@Z msvcrt.??3@YAXPAX@Z
+@ stub ??4Iostream_init@@QAEAAV0@ABV0@@Z #
+@ stub ??4filebuf@@QAEAAV0@ABV0@@Z #
+@ stub ??4fstream@@QAEAAV0@AAV0@@Z #
+@ stub ??4ifstream@@QAEAAV0@ABV0@@Z #
+@ stub ??4ios@@IAEAAV0@ABV0@@Z #
+@ stub ??4iostream@@IAEAAV0@AAV0@@Z #
+@ stub ??4iostream@@IAEAAV0@PAVstreambuf@@@Z #
+@ stub ??4istream@@IAEAAV0@ABV0@@Z #
+@ stub ??4istream@@IAEAAV0@PAVstreambuf@@@Z #
+@ stub ??4istream_withassign@@QAEAAV0@ABV0@@Z #
+@ stub ??4istream_withassign@@QAEAAVistream@@ABV1@@Z #
+@ stub ??4istream_withassign@@QAEAAVistream@@PAVstreambuf@@@Z #
+@ stub ??4istrstream@@QAEAAV0@ABV0@@Z #
+@ stub ??4ofstream@@QAEAAV0@ABV0@@Z #
+@ stub ??4ostream@@IAEAAV0@ABV0@@Z #
+@ stub ??4ostream@@IAEAAV0@PAVstreambuf@@@Z #
+@ stub ??4ostream_withassign@@QAEAAV0@ABV0@@Z #
+@ stub ??4ostream_withassign@@QAEAAVostream@@ABV1@@Z #
+@ stub ??4ostream_withassign@@QAEAAVostream@@PAVstreambuf@@@Z #
+@ stub ??4ostrstream@@QAEAAV0@ABV0@@Z #
+@ stub ??4stdiobuf@@QAEAAV0@ABV0@@Z #
+@ stub ??4stdiostream@@QAEAAV0@AAV0@@Z #
+@ stub ??4streambuf@@QAEAAV0@ABV0@@Z #
+@ stub ??4strstream@@QAEAAV0@AAV0@@Z #
+@ stub ??4strstreambuf@@QAEAAV0@ABV0@@Z #
+@ stub ??5istream@@QAEAAV0@AAC@Z #
+@ stub ??5istream@@QAEAAV0@AAD@Z #
+@ stub ??5istream@@QAEAAV0@AAE@Z #
+@ stub ??5istream@@QAEAAV0@AAF@Z #
+@ stub ??5istream@@QAEAAV0@AAG@Z #
+@ stub ??5istream@@QAEAAV0@AAH@Z #
+@ stub ??5istream@@QAEAAV0@AAI@Z #
+@ stub ??5istream@@QAEAAV0@AAJ@Z #
+@ stub ??5istream@@QAEAAV0@AAK@Z #
+@ stub ??5istream@@QAEAAV0@AAM@Z #
+@ stub ??5istream@@QAEAAV0@AAN@Z #
+@ stub ??5istream@@QAEAAV0@AAO@Z #
+@ stub ??5istream@@QAEAAV0@P6AAAV0@AAV0@@Z@Z #
+@ stub ??5istream@@QAEAAV0@P6AAAVios@@AAV1@@Z@Z #
+@ stub ??5istream@@QAEAAV0@PAC@Z #
+@ stub ??5istream@@QAEAAV0@PAD@Z #
+@ stub ??5istream@@QAEAAV0@PAE@Z #
+@ stub ??5istream@@QAEAAV0@PAVstreambuf@@@Z #
+@ stub ??6ostream@@QAEAAV0@C@Z #
+@ stub ??6ostream@@QAEAAV0@D@Z #
+@ stub ??6ostream@@QAEAAV0@E@Z #
+@ stub ??6ostream@@QAEAAV0@F@Z #
+@ stub ??6ostream@@QAEAAV0@G@Z #
+@ stub ??6ostream@@QAEAAV0@H@Z #
+@ stub ??6ostream@@QAEAAV0@I@Z #
+@ stub ??6ostream@@QAEAAV0@J@Z #
+@ stub ??6ostream@@QAEAAV0@K@Z #
+@ stub ??6ostream@@QAEAAV0@M@Z #
+@ stub ??6ostream@@QAEAAV0@N@Z #
+@ stub ??6ostream@@QAEAAV0@O@Z #
+@ stub ??6ostream@@QAEAAV0@P6AAAV0@AAV0@@Z@Z #
+@ stub ??6ostream@@QAEAAV0@P6AAAVios@@AAV1@@Z@Z #
+@ stub ??6ostream@@QAEAAV0@PAVstreambuf@@@Z #
+@ stub ??6ostream@@QAEAAV0@PBC@Z #
+@ stub ??6ostream@@QAEAAV0@PBD@Z #
+@ stub ??6ostream@@QAEAAV0@PBE@Z #
+@ stub ??6ostream@@QAEAAV0@PBX@Z #
+@ stub ??7ios@@QBEHXZ #
+@ stub ??Bios@@QBEPAXXZ #
+@ stub ??_7filebuf@@6B@ #
+@ stub ??_7fstream@@6B@ #
+@ stub ??_7ifstream@@6B@ #
+@ stub ??_7ios@@6B@ #
+@ stub ??_7iostream@@6B@ #
+@ stub ??_7istream@@6B@ #
+@ stub ??_7istream_withassign@@6B@ #
+@ stub ??_7istrstream@@6B@ #
+@ stub ??_7ofstream@@6B@ #
+@ stub ??_7ostream@@6B@ #
+@ stub ??_7ostream_withassign@@6B@ #
+@ stub ??_7ostrstream@@6B@ #
+@ stub ??_7stdiobuf@@6B@ #
+@ stub ??_7stdiostream@@6B@ #
+@ stub ??_7streambuf@@6B@ #
+@ stub ??_7strstream@@6B@ #
+@ stub ??_7strstreambuf@@6B@ #
+@ stub ??_8fstream@@7Bistream@@@ #
+@ stub ??_8fstream@@7Bostream@@@ #
+@ stub ??_8ifstream@@7B@ #
+@ stub ??_8iostream@@7Bistream@@@ #
+@ stub ??_8iostream@@7Bostream@@@ #
+@ stub ??_8istream@@7B@ #
+@ stub ??_8istream_withassign@@7B@ #
+@ stub ??_8istrstream@@7B@ #
+@ stub ??_8ofstream@@7B@ #
+@ stub ??_8ostream@@7B@ #
+@ stub ??_8ostream_withassign@@7B@ #
+@ stub ??_8ostrstream@@7B@ #
+@ stub ??_8stdiostream@@7Bistream@@@ #
+@ stub ??_8stdiostream@@7Bostream@@@ #
+@ stub ??_8strstream@@7Bistream@@@ #
+@ stub ??_8strstream@@7Bostream@@@ #
+@ stub ??_Dfstream@@QAEXXZ #
+@ stub ??_Difstream@@QAEXXZ #
+@ stub ??_Diostream@@QAEXXZ #
+@ stub ??_Distream@@QAEXXZ #
+@ stub ??_Distream_withassign@@QAEXXZ #
+@ stub ??_Distrstream@@QAEXXZ #
+@ stub ??_Dofstream@@QAEXXZ #
+@ stub ??_Dostream@@QAEXXZ #
+@ stub ??_Dostream_withassign@@QAEXXZ #
+@ stub ??_Dostrstream@@QAEXXZ #
+@ stub ??_Dstdiostream@@QAEXXZ #
+@ stub ??_Dstrstream@@QAEXXZ #
+@ stub ??_EIostream_init@@QAEPAXI@Z #
+@ stub ??_Efilebuf@@UAEPAXI@Z #
+@ stub ??_Efstream@@UAEPAXI@Z #
+@ stub ??_Eifstream@@UAEPAXI@Z #
+@ stub ??_Eios@@UAEPAXI@Z #
+@ stub ??_Eiostream@@UAEPAXI@Z #
+@ stub ??_Eistream@@UAEPAXI@Z #
+@ stub ??_Eistream_withassign@@UAEPAXI@Z #
+@ stub ??_Eistrstream@@UAEPAXI@Z #
+@ stub ??_Eofstream@@UAEPAXI@Z #
+@ stub ??_Eostream@@UAEPAXI@Z #
+@ stub ??_Eostream_withassign@@UAEPAXI@Z #
+@ stub ??_Eostrstream@@UAEPAXI@Z #
+@ stub ??_Estdiobuf@@UAEPAXI@Z #
+@ stub ??_Estdiostream@@UAEPAXI@Z #
+@ stub ??_Estreambuf@@UAEPAXI@Z #
+@ stub ??_Estrstream@@UAEPAXI@Z #
+@ stub ??_Estrstreambuf@@UAEPAXI@Z #
+@ stub ??_GIostream_init@@QAEPAXI@Z #
+@ stub ??_Gfilebuf@@UAEPAXI@Z #
+@ stub ??_Gfstream@@UAEPAXI@Z #
+@ stub ??_Gifstream@@UAEPAXI@Z #
+@ stub ??_Gios@@UAEPAXI@Z #
+@ stub ??_Giostream@@UAEPAXI@Z #
+@ stub ??_Gistream@@UAEPAXI@Z #
+@ stub ??_Gistream_withassign@@UAEPAXI@Z #
+@ stub ??_Gistrstream@@UAEPAXI@Z #
+@ stub ??_Gofstream@@UAEPAXI@Z #
+@ stub ??_Gostream@@UAEPAXI@Z #
+@ stub ??_Gostream_withassign@@UAEPAXI@Z #
+@ stub ??_Gostrstream@@UAEPAXI@Z #
+@ stub ??_Gstdiobuf@@UAEPAXI@Z #
+@ stub ??_Gstdiostream@@UAEPAXI@Z #
+@ stub ??_Gstreambuf@@UAEPAXI@Z #
+@ stub ??_Gstrstream@@UAEPAXI@Z #
+@ stub ??_Gstrstreambuf@@UAEPAXI@Z #
+@ forward ?_query_new_handler@@YAP6AHI@ZXZ msvcrt.?_query_new_handler@@YAP6AHI@ZXZ
+@ forward ?_query_new_mode@@YAHXZ  msvcrt.?_query_new_mode@@YAHXZ
+@ forward ?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z msvcrt.?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z
+@ forward ?_set_new_mode@@YAHH@Z msvcrt.?_set_new_mode@@YAHH@Z
+@ forward ?_set_se_translator@@YAP6AXIPAU_EXCEPTION_POINTERS@@@ZP6AXI0@Z@Z msvcrt.?_set_se_translator@@YAP6AXIPAU_EXCEPTION_POINTERS@@@ZP6AXI0@Z@Z
+@ stub ?adjustfield@ios@@2JB #
+@ stub ?allocate@streambuf@@IAEHXZ #
+@ stub ?attach@filebuf@@QAEPAV1@H@Z #
+@ stub ?attach@fstream@@QAEXH@Z #
+@ stub ?attach@ifstream@@QAEXH@Z #
+@ stub ?attach@ofstream@@QAEXH@Z #
+@ stub ?bad@ios@@QBEHXZ #
+@ stub ?base@streambuf@@IBEPADXZ #
+@ stub ?basefield@ios@@2JB #
+@ stub ?binary@filebuf@@2HB #
+@ stub ?bitalloc@ios@@SAJXZ #
+@ stub ?blen@streambuf@@IBEHXZ #
+@ stub ?cerr@@3Vostream_withassign@@A #
+@ stub ?cin@@3Vistream_withassign@@A #
+@ stub ?clear@ios@@QAEXH@Z #
+@ stub ?clog@@3Vostream_withassign@@A #
+@ stub ?close@filebuf@@QAEPAV1@XZ #
+@ stub ?close@fstream@@QAEXXZ #
+@ stub ?close@ifstream@@QAEXXZ #
+@ stub ?close@ofstream@@QAEXXZ #
+@ stub ?clrlock@ios@@QAAXXZ #
+@ stub ?clrlock@streambuf@@QAEXXZ #
+@ stub ?cout@@3Vostream_withassign@@A #
+@ stub ?dbp@streambuf@@QAEXXZ #
+@ stub ?dec@@YAAAVios@@AAV1@@Z #
+@ stub ?delbuf@ios@@QAEXH@Z #
+@ stub ?delbuf@ios@@QBEHXZ #
+@ stub ?doallocate@streambuf@@MAEHXZ #
+@ stub ?doallocate@strstreambuf@@MAEHXZ #
+@ stub ?eatwhite@istream@@QAEXXZ #
+@ stub ?eback@streambuf@@IBEPADXZ #
+@ stub ?ebuf@streambuf@@IBEPADXZ #
+@ stub ?egptr@streambuf@@IBEPADXZ #
+@ stub ?endl@@YAAAVostream@@AAV1@@Z #
+@ stub ?ends@@YAAAVostream@@AAV1@@Z #
+@ stub ?eof@ios@@QBEHXZ #
+@ stub ?epptr@streambuf@@IBEPADXZ #
+@ stub ?fLockcInit@ios@@0HA #
+@ stub ?fail@ios@@QBEHXZ #
+@ stub ?fd@filebuf@@QBEHXZ #
+@ stub ?fd@fstream@@QBEHXZ #
+@ stub ?fd@ifstream@@QBEHXZ #
+@ stub ?fd@ofstream@@QBEHXZ #
+@ stub ?fill@ios@@QAEDD@Z #
+@ stub ?fill@ios@@QBEDXZ #
+@ stub ?flags@ios@@QAEJJ@Z #
+@ stub ?flags@ios@@QBEJXZ #
+@ stub ?floatfield@ios@@2JB #
+@ stub ?flush@@YAAAVostream@@AAV1@@Z #
+@ stub ?flush@ostream@@QAEAAV1@XZ #
+@ stub ?freeze@strstreambuf@@QAEXH@Z #
+@ stub ?gbump@streambuf@@IAEXH@Z #
+@ stub ?gcount@istream@@QBEHXZ #
+@ stub ?get@istream@@QAEAAV1@AAC@Z #
+@ stub ?get@istream@@QAEAAV1@AAD@Z #
+@ stub ?get@istream@@QAEAAV1@AAE@Z #
+@ stub ?get@istream@@QAEAAV1@AAVstreambuf@@D@Z #
+@ stub ?get@istream@@QAEAAV1@PACHD@Z #
+@ stub ?get@istream@@QAEAAV1@PADHD@Z #
+@ stub ?get@istream@@QAEAAV1@PAEHD@Z #
+@ stub ?get@istream@@QAEHXZ #
+@ stub ?getdouble@istream@@AAEHPADH@Z #
+@ stub ?getint@istream@@AAEHPAD@Z #
+@ stub ?getline@istream@@QAEAAV1@PACHD@Z #
+@ stub ?getline@istream@@QAEAAV1@PADHD@Z #
+@ stub ?getline@istream@@QAEAAV1@PAEHD@Z #
+@ stub ?good@ios@@QBEHXZ #
+@ stub ?gptr@streambuf@@IBEPADXZ #
+@ stub ?hex@@YAAAVios@@AAV1@@Z #
+@ stub ?ignore@istream@@QAEAAV1@HH@Z #
+@ stub ?in_avail@streambuf@@QBEHXZ #
+@ stub ?init@ios@@IAEXPAVstreambuf@@@Z #
+@ stub ?ipfx@istream@@QAEHH@Z #
+@ stub ?is_open@filebuf@@QBEHXZ #
+@ stub ?is_open@fstream@@QBEHXZ #
+@ stub ?is_open@ifstream@@QBEHXZ #
+@ stub ?is_open@ofstream@@QBEHXZ #
+@ stub ?isfx@istream@@QAEXXZ #
+@ stub ?iword@ios@@QBEAAJH@Z #
+@ stub ?lock@ios@@QAAXXZ #
+@ stub ?lock@streambuf@@QAEXXZ #
+@ stub ?lockbuf@ios@@QAAXXZ #
+@ stub ?lockc@ios@@KAXXZ #
+@ stub ?lockptr@ios@@IAEPAU_RTL_CRITICAL_SECTION@@XZ #
+@ stub ?lockptr@streambuf@@IAEPAU_RTL_CRITICAL_SECTION@@XZ #
+@ stub ?oct@@YAAAVios@@AAV1@@Z #
+@ stub ?open@filebuf@@QAEPAV1@PBDHH@Z #
+@ stub ?open@fstream@@QAEXPBDHH@Z #
+@ stub ?open@ifstream@@QAEXPBDHH@Z #
+@ stub ?open@ofstream@@QAEXPBDHH@Z #
+@ stub ?openprot@filebuf@@2HB #
+@ stub ?opfx@ostream@@QAEHXZ #
+@ stub ?osfx@ostream@@QAEXXZ #
+@ stub ?out_waiting@streambuf@@QBEHXZ #
+@ stub ?overflow@filebuf@@UAEHH@Z #
+@ stub ?overflow@stdiobuf@@UAEHH@Z #
+@ stub ?overflow@strstreambuf@@UAEHH@Z #
+@ stub ?pbackfail@stdiobuf@@UAEHH@Z #
+@ stub ?pbackfail@streambuf@@UAEHH@Z #
+@ stub ?pbase@streambuf@@IBEPADXZ #
+@ stub ?pbump@streambuf@@IAEXH@Z #
+@ stub ?pcount@ostrstream@@QBEHXZ #
+@ stub ?pcount@strstream@@QBEHXZ #
+@ stub ?peek@istream@@QAEHXZ #
+@ stub ?pptr@streambuf@@IBEPADXZ #
+@ stub ?precision@ios@@QAEHH@Z #
+@ stub ?precision@ios@@QBEHXZ #
+@ stub ?put@ostream@@QAEAAV1@C@Z #
+@ stub ?put@ostream@@QAEAAV1@D@Z #
+@ stub ?put@ostream@@QAEAAV1@E@Z #
+@ stub ?putback@istream@@QAEAAV1@D@Z #
+@ stub ?pword@ios@@QBEAAPAXH@Z #
+@ stub ?rdbuf@fstream@@QBEPAVfilebuf@@XZ #
+@ stub ?rdbuf@ifstream@@QBEPAVfilebuf@@XZ #
+@ stub ?rdbuf@ios@@QBEPAVstreambuf@@XZ #
+@ stub ?rdbuf@istrstream@@QBEPAVstrstreambuf@@XZ #
+@ stub ?rdbuf@ofstream@@QBEPAVfilebuf@@XZ #
+@ stub ?rdbuf@ostrstream@@QBEPAVstrstreambuf@@XZ #
+@ stub ?rdbuf@stdiostream@@QBEPAVstdiobuf@@XZ #
+@ stub ?rdbuf@strstream@@QBEPAVstrstreambuf@@XZ #
+@ stub ?rdstate@ios@@QBEHXZ #
+@ stub ?read@istream@@QAEAAV1@PACH@Z #
+@ stub ?read@istream@@QAEAAV1@PADH@Z #
+@ stub ?read@istream@@QAEAAV1@PAEH@Z #
+@ stub ?sbumpc@streambuf@@QAEHXZ #
+@ stub ?seekg@istream@@QAEAAV1@J@Z #
+@ stub ?seekg@istream@@QAEAAV1@JW4seek_dir@ios@@@Z #
+@ stub ?seekoff@filebuf@@UAEJJW4seek_dir@ios@@H@Z #
+@ stub ?seekoff@stdiobuf@@UAEJJW4seek_dir@ios@@H@Z #
+@ stub ?seekoff@streambuf@@UAEJJW4seek_dir@ios@@H@Z #
+@ stub ?seekoff@strstreambuf@@UAEJJW4seek_dir@ios@@H@Z #
+@ stub ?seekp@ostream@@QAEAAV1@J@Z #
+@ stub ?seekp@ostream@@QAEAAV1@JW4seek_dir@ios@@@Z #
+@ stub ?seekpos@streambuf@@UAEJJH@Z #
+@ forward ?set_terminate@@YAP6AXXZP6AXXZ@Z msvcrt.?set_terminate@@YAP6AXXZP6AXXZ@Z
+@ forward ?set_unexpected@@YAP6AXXZP6AXXZ@Z msvcrt.?set_unexpected@@YAP6AXXZP6AXXZ@Z
+@ stub ?setb@streambuf@@IAEXPAD0H@Z #
+@ stub ?setbuf@filebuf@@UAEPAVstreambuf@@PADH@Z #
+@ stub ?setbuf@fstream@@QAEPAVstreambuf@@PADH@Z #
+@ stub ?setbuf@ifstream@@QAEPAVstreambuf@@PADH@Z #
+@ stub ?setbuf@ofstream@@QAEPAVstreambuf@@PADH@Z #
+@ stub ?setbuf@streambuf@@UAEPAV1@PADH@Z #
+@ stub ?setbuf@strstreambuf@@UAEPAVstreambuf@@PADH@Z #
+@ stub ?setf@ios@@QAEJJ@Z #
+@ stub ?setf@ios@@QAEJJJ@Z #
+@ stub ?setg@streambuf@@IAEXPAD00@Z #
+@ stub ?setlock@ios@@QAAXXZ #
+@ stub ?setlock@streambuf@@QAEXXZ #
+@ stub ?setmode@filebuf@@QAEHH@Z #
+@ stub ?setmode@fstream@@QAEHH@Z #
+@ stub ?setmode@ifstream@@QAEHH@Z #
+@ stub ?setmode@ofstream@@QAEHH@Z #
+@ stub ?setp@streambuf@@IAEXPAD0@Z #
+@ stub ?setrwbuf@stdiobuf@@QAEHHH@Z #
+@ stub ?sgetc@streambuf@@QAEHXZ #
+@ stub ?sgetn@streambuf@@QAEHPADH@Z #
+@ stub ?sh_none@filebuf@@2HB #
+@ stub ?sh_read@filebuf@@2HB #
+@ stub ?sh_write@filebuf@@2HB #
+@ stub ?snextc@streambuf@@QAEHXZ #
+@ stub ?sputbackc@streambuf@@QAEHD@Z #
+@ stub ?sputc@streambuf@@QAEHH@Z #
+@ stub ?sputn@streambuf@@QAEHPBDH@Z #
+@ stub ?stdiofile@stdiobuf@@QAEPAU_iobuf@@XZ #
+@ stub ?stossc@streambuf@@QAEXXZ #
+@ stub ?str@istrstream@@QAEPADXZ #
+@ stub ?str@ostrstream@@QAEPADXZ #
+@ stub ?str@strstream@@QAEPADXZ #
+@ stub ?str@strstreambuf@@QAEPADXZ #
+@ stub ?sunk_with_stdio@ios@@0HA #
+@ stub ?sync@filebuf@@UAEHXZ #
+@ stub ?sync@istream@@QAEHXZ #
+@ stub ?sync@stdiobuf@@UAEHXZ #
+@ stub ?sync@streambuf@@UAEHXZ #
+@ stub ?sync@strstreambuf@@UAEHXZ #
+@ stub ?sync_with_stdio@ios@@SAXXZ #
+@ stub ?tellg@istream@@QAEJXZ #
+@ stub ?tellp@ostream@@QAEJXZ #
+@ forward ?terminate@@YAXXZ msvcrt.?terminate@@YAXXZ
+@ stub ?text@filebuf@@2HB #
+@ stub ?tie@ios@@QAEPAVostream@@PAV2@@Z #
+@ stub ?tie@ios@@QBEPAVostream@@XZ #
+@ stub ?unbuffered@streambuf@@IAEXH@Z #
+@ stub ?unbuffered@streambuf@@IBEHXZ #
+@ stub ?underflow@filebuf@@UAEHXZ #
+@ stub ?underflow@stdiobuf@@UAEHXZ #
+@ stub ?underflow@strstreambuf@@UAEHXZ #
+@ forward ?unexpected@@YAXXZ msvcrt.?unexpected@@YAXXZ
+@ stub ?unlock@ios@@QAAXXZ #
+@ stub ?unlock@streambuf@@QAEXXZ #
+@ stub ?unlockbuf@ios@@QAAXXZ #
+@ stub ?unlockc@ios@@KAXXZ #
+@ stub ?unsetf@ios@@QAEJJ@Z #
+@ stub ?width@ios@@QAEHH@Z #
+@ stub ?width@ios@@QBEHXZ #
+@ stub ?write@ostream@@QAEAAV1@PBCH@Z #
+@ stub ?write@ostream@@QAEAAV1@PBDH@Z #
+@ stub ?write@ostream@@QAEAAV1@PBEH@Z #
+@ stub ?writepad@ostream@@AAEAAV1@PBD0@Z #
+@ stub ?ws@@YAAAVistream@@AAV1@@Z #
+@ stub ?x_curindex@ios@@0HA #
+@ stub ?x_lockc@ios@@0U_RTL_CRITICAL_SECTION@@A #
+@ stub ?x_maxbit@ios@@0JA #
+@ stub ?x_statebuf@ios@@0QAJA #
+@ stub ?xalloc@ios@@SAHXZ #
+@ stub ?xsgetn@streambuf@@UAEHPADH@Z #
+@ stub ?xsputn@streambuf@@UAEHPBDH@Z #
+@ stub $I10_OUTPUT #
+@ forward _CIacos msvcrt._CIacos
+@ forward _CIasin msvcrt._CIasin
+@ forward _CIatan msvcrt._CIatan
+@ forward _CIatan2 msvcrt._CIatan2
+@ forward _CIcos msvcrt._CIcos
+@ forward _CIcosh msvcrt._CIcosh
+@ forward _CIexp msvcrt._CIexp
+@ forward _CIfmod msvcrt._CIfmod
+@ forward _CIlog msvcrt._CIlog
+@ forward _CIlog10 msvcrt._CIlog10
+@ forward _CIpow msvcrt._CIpow
+@ forward _CIsin msvcrt._CIsin
+@ forward _CIsinh msvcrt._CIsinh
+@ forward _CIsqrt msvcrt._CIsqrt
+@ forward _CItan msvcrt._CItan
+@ forward _CItanh msvcrt._CItanh
+@ forward _CxxThrowException msvcrt._CxxThrowException
+@ forward _HUGE msvcrt._HUGE
+@ forward _XcptFilter msvcrt._XcptFilter
+@ forward __CxxFrameHandler msvcrt.__CxxFrameHandler
+@ forward __CxxLongjmpUnwind msvcrt.__CxxLongjmpUnwind
+@ forward __STRINGTOLD msvcrt.__STRINGTOLD
+@ forward __argc msvcrt.__argc
+@ forward __argv msvcrt.__argv
+@ forward __dllonexit msvcrt.__dllonexit
+@ forward __doserrno msvcrt.__doserrno
+@ forward __fpecode msvcrt.__fpecode
+@ cdecl __getmainargs(ptr ptr ptr long long) MSVCRT20__getmainargs
+@ forward __initenv msvcrt.__initenv
+@ forward __isascii msvcrt.__isascii
+@ forward __iscsym msvcrt.__iscsym
+@ forward __iscsymf msvcrt.__iscsymf
+@ forward __lconv_init msvcrt.__lconv_init
+@ forward __mb_cur_max msvcrt.__mb_cur_max
+@ forward __p___argc msvcrt.__p___argc
+@ forward __p___argv msvcrt.__p___argv
+@ forward __p___initenv msvcrt.__p___initenv
+@ forward __p___mb_cur_max msvcrt.__p___mb_cur_max
+@ forward __p___wargv msvcrt.__p___wargv
+@ forward __p___winitenv msvcrt.__p___winitenv
+@ forward __p__acmdln msvcrt.__p__acmdln
+@ forward __p__amblksiz msvcrt.__p__amblksiz
+@ forward __p__commode msvcrt.__p__commode
+@ forward __p__daylight msvcrt.__p__daylight
+@ forward __p__environ msvcrt.__p__environ
+@ forward __p__fmode msvcrt.__p__fmode
+@ forward __p__iob msvcrt.__p__iob
+@ forward __p__mbctype msvcrt.__p__mbctype
+@ forward __p__osver msvcrt.__p__osver
+@ forward __p__pctype msvcrt.__p__pctype
+@ forward __p__pgmptr msvcrt.__p__pgmptr
+@ forward __p__pwctype msvcrt.__p__pwctype
+@ forward __p__timezone msvcrt.__p__timezone
+@ forward __p__tzname msvcrt.__p__tzname
+@ forward __p__wcmdln msvcrt.__p__wcmdln
+@ forward __p__wenviron msvcrt.__p__wenviron
+@ forward __p__winmajor msvcrt.__p__winmajor
+@ forward __p__winminor msvcrt.__p__winminor
+@ forward __p__winver msvcrt.__p__winver
+@ forward __p__wpgmptr msvcrt.__p__wpgmptr
+@ forward __pxcptinfoptrs msvcrt.__pxcptinfoptrs
+@ forward __threadhandle msvcrt.__threadhandle
+@ forward __threadid msvcrt.__threadid
+@ forward __toascii msvcrt.__toascii
+@ forward __wargv msvcrt.__wargv
+@ cdecl __wgetmainargs(ptr ptr ptr long long) MSVCRT20__wgetmainargs
+@ forward __winitenv msvcrt.__winitenv
+@ forward _abnormal_termination msvcrt._abnormal_termination
+@ forward _access msvcrt._access
+@ forward _acmdln msvcrt._acmdln
+@ forward _adj_fdiv_m16i msvcrt._adj_fdiv_m16i
+@ forward _adj_fdiv_m32 msvcrt._adj_fdiv_m32
+@ forward _adj_fdiv_m32i msvcrt._adj_fdiv_m32i
+@ forward _adj_fdiv_m64 msvcrt._adj_fdiv_m64
+@ forward _adj_fdiv_r msvcrt._adj_fdiv_r
+@ forward _adj_fdivr_m16i msvcrt._adj_fdivr_m16i
+@ forward _adj_fdivr_m32 msvcrt._adj_fdivr_m32
+@ forward _adj_fdivr_m32i msvcrt._adj_fdivr_m32i
+@ forward _adj_fdivr_m64 msvcrt._adj_fdivr_m64
+@ forward _adj_fpatan msvcrt._adj_fpatan
+@ forward _adj_fprem msvcrt._adj_fprem
+@ forward _adj_fprem1 msvcrt._adj_fprem1
+@ forward _adj_fptan msvcrt._adj_fptan
+@ forward _adjust_fdiv msvcrt._adjust_fdiv
+@ forward _aexit_rtn msvcrt._aexit_rtn
+@ forward _amsg_exit msvcrt._amsg_exit
+@ forward _assert msvcrt._assert
+@ forward _atodbl msvcrt._atodbl
+@ forward _atoldbl msvcrt._atoldbl
+@ forward _beep msvcrt._beep
+@ forward _beginthread msvcrt._beginthread
+@ forward _beginthreadex msvcrt._beginthreadex
+@ forward _c_exit msvcrt._c_exit
+@ forward _cabs msvcrt._cabs
+@ forward _cexit msvcrt._cexit
+@ forward _cgets msvcrt._cgets
+@ forward _chdir msvcrt._chdir
+@ forward _chdrive msvcrt._chdrive
+@ forward _chgsign msvcrt._chgsign
+@ forward _chmod msvcrt._chmod
+@ forward _chsize msvcrt._chsize
+@ forward _clearfp msvcrt._clearfp
+@ forward _close msvcrt._close
+@ forward _commit msvcrt._commit
+@ forward _commode msvcrt._commode
+@ forward _control87 msvcrt._control87
+@ forward _controlfp msvcrt._controlfp
+@ forward _copysign msvcrt._copysign
+@ forward _cprintf msvcrt._cprintf
+@ forward _cputs msvcrt._cputs
+@ forward _creat msvcrt._creat
+@ forward _cscanf msvcrt._cscanf
+@ forward _ctype msvcrt._ctype
+@ forward _cwait msvcrt._cwait
+@ forward _daylight msvcrt._daylight
+@ forward _dup msvcrt._dup
+@ forward _dup2 msvcrt._dup2
+@ forward _ecvt msvcrt._ecvt
+@ forward _endthread msvcrt._endthread
+@ forward _endthreadex msvcrt._endthreadex
+@ forward _environ msvcrt._environ
+@ forward _eof msvcrt._eof
+@ forward _errno msvcrt._errno
+@ forward _except_handler2 msvcrt._except_handler2
+@ forward _except_handler3 msvcrt._except_handler3
+@ forward _execl msvcrt._execl
+@ forward _execle msvcrt._execle
+@ forward _execlp msvcrt._execlp
+@ forward _execlpe msvcrt._execlpe
+@ forward _execv msvcrt._execv
+@ forward _execve msvcrt._execve
+@ forward _execvp msvcrt._execvp
+@ forward _execvpe msvcrt._execvpe
+@ forward _exit msvcrt._exit
+@ forward _expand msvcrt._expand
+@ forward _fcloseall msvcrt._fcloseall
+@ forward _fcvt msvcrt._fcvt
+@ forward _fdopen msvcrt._fdopen
+@ forward _fgetchar msvcrt._fgetchar
+@ forward _fgetwchar msvcrt._fgetwchar
+@ forward _filbuf msvcrt._filbuf
+@ forward _fileinfo msvcrt._fileinfo
+@ forward _filelength msvcrt._filelength
+@ forward _fileno msvcrt._fileno
+@ forward _findclose msvcrt._findclose
+@ forward _findfirst msvcrt._findfirst
+@ forward _findnext msvcrt._findnext
+@ forward _finite msvcrt._finite
+@ forward _flsbuf msvcrt._flsbuf
+@ forward _flushall msvcrt._flushall
+@ forward _fmode msvcrt._fmode
+@ forward _fpclass msvcrt._fpclass
+@ forward _fpieee_flt msvcrt._fpieee_flt
+@ forward _fpreset msvcrt._fpreset
+@ forward _fputchar msvcrt._fputchar
+@ forward _fputwchar msvcrt._fputwchar
+@ forward _fsopen msvcrt._fsopen
+@ forward _fstat msvcrt._fstat
+@ forward _ftime msvcrt._ftime
+@ forward _ftol msvcrt._ftol
+@ forward _fullpath msvcrt._fullpath
+@ forward _futime msvcrt._futime
+@ forward _gcvt msvcrt._gcvt
+@ forward _get_osfhandle msvcrt._get_osfhandle
+@ forward _getch msvcrt._getch
+@ forward _getche msvcrt._getche
+@ forward _getcwd msvcrt._getcwd
+@ forward _getdcwd msvcrt._getdcwd
+@ forward _getdiskfree msvcrt._getdiskfree
+@ forward _getdllprocaddr msvcrt._getdllprocaddr
+@ forward _getdrive msvcrt._getdrive
+@ forward _getdrives msvcrt._getdrives
+@ forward _getmbcp msvcrt._getmbcp
+@ forward _getpid msvcrt._getpid
+@ forward _getsystime msvcrt._getsystime
+@ forward _getw msvcrt._getw
+@ forward _getws msvcrt._getws
+@ forward _global_unwind2 msvcrt._global_unwind2
+@ forward _heapadd msvcrt._heapadd
+@ forward _heapchk msvcrt._heapchk
+@ forward _heapmin msvcrt._heapmin
+@ forward _heapset msvcrt._heapset
+@ forward _heapused msvcrt._heapused
+@ forward _heapwalk msvcrt._heapwalk
+@ forward _hypot msvcrt._hypot
+@ forward _initterm msvcrt._initterm
+@ forward _iob msvcrt._iob
+@ forward _isatty msvcrt._isatty
+@ forward _isctype msvcrt._isctype
+@ forward _ismbbalnum msvcrt._ismbbalnum
+@ forward _ismbbalpha msvcrt._ismbbalpha
+@ forward _ismbbgraph msvcrt._ismbbgraph
+@ forward _ismbbkalnum msvcrt._ismbbkalnum
+@ forward _ismbbkana msvcrt._ismbbkana
+@ forward _ismbbkprint msvcrt._ismbbkprint
+@ forward _ismbbkpunct msvcrt._ismbbkpunct
+@ forward _ismbblead msvcrt._ismbblead
+@ forward _ismbbprint msvcrt._ismbbprint
+@ forward _ismbbpunct msvcrt._ismbbpunct
+@ forward _ismbbtrail msvcrt._ismbbtrail
+@ forward _ismbcalnum msvcrt._ismbcalnum
+@ forward _ismbcalpha msvcrt._ismbcalpha
+@ forward _ismbcdigit msvcrt._ismbcdigit
+@ forward _ismbcgraph msvcrt._ismbcgraph
+@ forward _ismbchira msvcrt._ismbchira
+@ forward _ismbckata msvcrt._ismbckata
+@ forward _ismbcl0 msvcrt._ismbcl0
+@ forward _ismbcl1 msvcrt._ismbcl1
+@ forward _ismbcl2 msvcrt._ismbcl2
+@ forward _ismbclegal msvcrt._ismbclegal
+@ forward _ismbclower msvcrt._ismbclower
+@ forward _ismbcprint msvcrt._ismbcprint
+@ forward _ismbcpunct msvcrt._ismbcpunct
+@ forward _ismbcspace msvcrt._ismbcspace
+@ forward _ismbcsymbol msvcrt._ismbcsymbol
+@ forward _ismbcupper msvcrt._ismbcupper
+@ forward _ismbslead msvcrt._ismbslead
+@ forward _ismbstrail msvcrt._ismbstrail
+@ forward _isnan msvcrt._isnan
+@ forward _itoa msvcrt._itoa
+@ forward _itow msvcrt._itow
+@ forward _j0 msvcrt._j0
+@ forward _j1 msvcrt._j1
+@ forward _jn msvcrt._jn
+@ forward _kbhit msvcrt._kbhit
+@ forward _lfind msvcrt._lfind
+@ forward _loaddll msvcrt._loaddll
+@ forward _local_unwind2 msvcrt._local_unwind2
+@ forward _locking msvcrt._locking
+@ forward _logb msvcrt._logb
+@ forward _longjmpex msvcrt._longjmpex
+@ forward _lrotl msvcrt._lrotl
+@ forward _lrotr msvcrt._lrotr
+@ forward _lsearch msvcrt._lsearch
+@ forward _lseek msvcrt._lseek
+@ forward _ltoa msvcrt._ltoa
+@ forward _ltow msvcrt._ltow
+@ forward _makepath msvcrt._makepath
+@ forward _matherr msvcrt._matherr
+@ forward _mbbtombc msvcrt._mbbtombc
+@ forward _mbbtype msvcrt._mbbtype
+@ forward _mbccpy msvcrt._mbccpy
+@ forward _mbcjistojms msvcrt._mbcjistojms
+@ forward _mbcjmstojis msvcrt._mbcjmstojis
+@ forward _mbclen msvcrt._mbclen
+@ forward _mbctohira msvcrt._mbctohira
+@ forward _mbctokata msvcrt._mbctokata
+@ forward _mbctolower msvcrt._mbctolower
+@ forward _mbctombb msvcrt._mbctombb
+@ forward _mbctoupper msvcrt._mbctoupper
+@ forward _mbctype msvcrt._mbctype
+@ forward _mbsbtype msvcrt._mbsbtype
+@ forward _mbscat msvcrt._mbscat
+@ forward _mbschr msvcrt._mbschr
+@ forward _mbscmp msvcrt._mbscmp
+@ forward _mbscoll msvcrt._mbscoll
+@ forward _mbscpy msvcrt._mbscpy
+@ forward _mbscspn msvcrt._mbscspn
+@ forward _mbsdec msvcrt._mbsdec
+@ forward _mbsdup msvcrt._mbsdup
+@ forward _mbsicmp msvcrt._mbsicmp
+@ forward _mbsicoll msvcrt._mbsicoll
+@ forward _mbsinc msvcrt._mbsinc
+@ forward _mbslen msvcrt._mbslen
+@ forward _mbslwr msvcrt._mbslwr
+@ forward _mbsnbcat msvcrt._mbsnbcat
+@ forward _mbsnbcmp msvcrt._mbsnbcmp
+@ forward _mbsnbcnt msvcrt._mbsnbcnt
+@ forward _mbsnbcoll msvcrt._mbsnbcoll
+@ forward _mbsnbcpy msvcrt._mbsnbcpy
+@ forward _mbsnbicmp msvcrt._mbsnbicmp
+@ forward _mbsnbicoll msvcrt._mbsnbicoll
+@ forward _mbsnbset msvcrt._mbsnbset
+@ forward _mbsncat msvcrt._mbsncat
+@ forward _mbsnccnt msvcrt._mbsnccnt
+@ forward _mbsncmp msvcrt._mbsncmp
+@ forward _mbsncoll msvcrt._mbsncoll
+@ forward _mbsncpy msvcrt._mbsncpy
+@ forward _mbsnextc msvcrt._mbsnextc
+@ forward _mbsnicmp msvcrt._mbsnicmp
+@ forward _mbsnicoll msvcrt._mbsnicoll
+@ forward _mbsninc msvcrt._mbsninc
+@ forward _mbsnset msvcrt._mbsnset
+@ forward _mbspbrk msvcrt._mbspbrk
+@ forward _mbsrchr msvcrt._mbsrchr
+@ forward _mbsrev msvcrt._mbsrev
+@ forward _mbsset msvcrt._mbsset
+@ forward _mbsspn msvcrt._mbsspn
+@ forward _mbsspnp msvcrt._mbsspnp
+@ forward _mbsstr msvcrt._mbsstr
+@ forward _mbstok msvcrt._mbstok
+@ forward _mbstrlen msvcrt._mbstrlen
+@ forward _mbsupr msvcrt._mbsupr
+@ forward _memccpy msvcrt._memccpy
+@ forward _memicmp msvcrt._memicmp
+@ forward _mkdir msvcrt._mkdir
+@ forward _mktemp msvcrt._mktemp
+@ forward _msize msvcrt._msize
+@ stub _mtlock
+@ stub _mtunlock
+@ forward _nextafter msvcrt._nextafter
+@ forward _onexit msvcrt._onexit
+@ forward _open msvcrt._open
+@ forward _open_osfhandle msvcrt._open_osfhandle
+@ forward _osver msvcrt._osver
+@ forward _pclose msvcrt._pclose
+@ forward _pctype msvcrt._pctype
+@ forward _pgmptr msvcrt._pgmptr
+@ forward _pipe msvcrt._pipe
+@ forward _popen msvcrt._popen
+@ forward _purecall msvcrt._purecall
+@ forward _putch msvcrt._putch
+@ forward _putenv msvcrt._putenv
+@ forward _putw msvcrt._putw
+@ forward _putws msvcrt._putws
+@ forward _pwctype msvcrt._pwctype
+@ forward _read msvcrt._read
+@ forward _rmdir msvcrt._rmdir
+@ forward _rmtmp msvcrt._rmtmp
+@ forward _rotl msvcrt._rotl
+@ forward _rotr msvcrt._rotr
+@ forward _safe_fdiv msvcrt._safe_fdiv
+@ forward _safe_fdivr msvcrt._safe_fdivr
+@ forward _safe_fprem msvcrt._safe_fprem
+@ forward _safe_fprem1 msvcrt._safe_fprem1
+@ forward _scalb msvcrt._scalb
+@ forward _searchenv msvcrt._searchenv
+@ forward __seh_longjmp_unwind msvcrt._seh_longjmp_unwind
+@ forward _seterrormode msvcrt._seterrormode
+@ forward _setjmp msvcrt._setjmp
+@ forward _setjmp3 msvcrt._setjmp3
+@ forward _setmbcp msvcrt._setmbcp
+@ forward _setmode msvcrt._setmode
+@ forward _setsystime msvcrt._setsystime
+@ forward _sleep msvcrt._sleep
+@ forward _snprintf msvcrt._snprintf
+@ forward _snwprintf msvcrt._snwprintf
+@ forward _sopen msvcrt._sopen
+@ forward _spawnl msvcrt._spawnl
+@ forward _spawnle msvcrt._spawnle
+@ forward _spawnlp msvcrt._spawnlp
+@ forward _spawnlpe msvcrt._spawnlpe
+@ forward _spawnv msvcrt._spawnv
+@ forward _spawnve msvcrt._spawnve
+@ forward _spawnvp msvcrt._spawnvp
+@ forward _spawnvpe msvcrt._spawnvpe
+@ forward _splitpath msvcrt._splitpath
+@ forward _stat msvcrt._stat
+@ forward _statusfp msvcrt._statusfp
+@ forward _strcmpi msvcrt._strcmpi
+@ forward _strdate msvcrt._strdate
+@ forward _strdup msvcrt._strdup
+@ forward _strerror msvcrt._strerror
+@ forward _stricmp msvcrt._stricmp
+@ forward _stricoll msvcrt._stricoll
+@ forward _strlwr msvcrt._strlwr
+@ forward _strncoll msvcrt._strncoll
+@ forward _strnicmp msvcrt._strnicmp
+@ forward _strnicoll msvcrt._strnicoll
+@ forward _strnset msvcrt._strnset
+@ forward _strrev msvcrt._strrev
+@ forward _strset msvcrt._strset
+@ forward _strtime msvcrt._strtime
+@ forward _strupr msvcrt._strupr
+@ forward _swab msvcrt._swab
+@ forward _sys_errlist msvcrt._sys_errlist
+@ forward _sys_nerr msvcrt._sys_nerr
+@ forward _tccpy msvcrt._mbccpy
+@ forward _tclen msvcrt._mbclen
+@ forward _tcschr msvcrt._mbschr
+@ forward _tcsclen msvcrt._mbslen
+@ forward _tcscmp msvcrt._mbscmp
+@ forward _tcscspn msvcrt._mbscspn
+@ forward _tcsdec msvcrt._mbsdec
+@ forward _tcsicmp msvcrt._mbsicmp
+@ forward _tcsinc msvcrt._mbsinc
+@ forward _tcslwr msvcrt._mbslwr
+@ forward _tcsnbcnt msvcrt._mbsnbcnt
+@ forward _tcsncat msvcrt._mbsnbcat
+@ forward _tcsnccat msvcrt._mbsncat
+@ forward _tcsnccmp msvcrt._mbsncmp
+@ forward _tcsnccnt msvcrt._mbsnccnt
+@ forward _tcsnccpy msvcrt._mbsncpy
+@ forward _tcsncicmp msvcrt._mbsnicmp
+@ forward _tcsncmp msvcrt._mbsnbcmp
+@ forward _tcsncpy msvcrt._mbsnbcpy
+@ forward _tcsncset msvcrt._mbsnset
+@ forward _tcsnextc msvcrt._mbsnextc
+@ forward _tcsnicmp msvcrt._mbsnbicmp
+@ forward _tcsninc msvcrt._mbsninc
+@ forward _tcsnset msvcrt._mbsnbset
+@ forward _tcspbrk msvcrt._mbspbrk
+@ forward _tcsrchr msvcrt._mbsrchr
+@ forward _tcsrev msvcrt._mbsrev
+@ forward _tcsset msvcrt._mbsset
+@ forward _tcsspn msvcrt._mbsspn
+@ forward _tcsspnp msvcrt._mbsspnp
+@ forward _tcsstr msvcrt._mbsstr
+@ forward _tcstok msvcrt._mbstok
+@ forward _tcsupr msvcrt._mbsupr
+@ forward _tell msvcrt._tell
+@ forward _tempnam msvcrt._tempnam
+@ forward _timezone msvcrt._timezone
+@ forward _tolower msvcrt._tolower
+@ forward _toupper msvcrt._toupper
+@ forward _tzname msvcrt._tzname
+@ forward _tzset msvcrt._tzset
+@ forward _ultoa msvcrt._ultoa
+@ forward _ultow msvcrt._ultow
+@ forward _umask msvcrt._umask
+@ forward _ungetch msvcrt._ungetch
+@ forward _unlink msvcrt._unlink
+@ forward _unloaddll msvcrt._unloaddll
+@ forward _utime msvcrt._utime
+@ forward _vsnprintf msvcrt._vsnprintf
+@ forward _vsnwprintf msvcrt._vsnwprintf
+@ forward _waccess msvcrt._waccess
+@ forward _wasctime msvcrt._wasctime
+@ forward _wchdir msvcrt._wchdir
+@ forward _wchmod msvcrt._wchmod
+@ forward _wcmdln msvcrt._wcmdln
+@ forward _wcreat msvcrt._wcreat
+@ forward _wcsdup msvcrt._wcsdup
+@ forward _wcsicmp msvcrt._wcsicmp
+@ forward _wcsicoll msvcrt._wcsicoll
+@ forward _wcslwr msvcrt._wcslwr
+@ forward _wcsncoll msvcrt._wcsncoll
+@ forward _wcsnicmp msvcrt._wcsnicmp
+@ forward _wcsnicoll msvcrt._wcsnicoll
+@ forward _wcsnset msvcrt._wcsnset
+@ forward _wcsrev msvcrt._wcsrev
+@ forward _wcsset msvcrt._wcsset
+@ forward _wcsupr msvcrt._wcsupr
+@ forward _wctime msvcrt._wctime
+@ forward _wenviron msvcrt._wenviron
+@ forward _wexecl msvcrt._wexecl
+@ forward _wexecle msvcrt._wexecle
+@ forward _wexeclp msvcrt._wexeclp
+@ forward _wexeclpe msvcrt._wexeclpe
+@ forward _wexecv msvcrt._wexecv
+@ forward _wexecve msvcrt._wexecve
+@ forward _wexecvp msvcrt._wexecvp
+@ forward _wexecvpe msvcrt._wexecvpe
+@ forward _wfdopen msvcrt._wfdopen
+@ forward _wfindfirst msvcrt._wfindfirst
+@ forward _wfindnext msvcrt._wfindnext
+@ forward _wfopen msvcrt._wfopen
+@ forward _wfreopen msvcrt._wfreopen
+@ forward _wfsopen msvcrt._wfsopen
+@ forward _wfullpath msvcrt._wfullpath
+@ forward _wgetcwd msvcrt._wgetcwd
+@ forward _wgetdcwd msvcrt._wgetdcwd
+@ forward _wgetenv msvcrt._wgetenv
+@ forward _winmajor msvcrt._winmajor
+@ forward _winminor msvcrt._winminor
+@ forward _winver msvcrt._winver
+@ forward _wmakepath msvcrt._wmakepath
+@ forward _wmkdir msvcrt._wmkdir
+@ forward _wmktemp msvcrt._wmktemp
+@ forward _wopen msvcrt._wopen
+@ forward _wperror msvcrt._wperror
+@ forward _wpgmptr msvcrt._wpgmptr
+@ forward _wpopen msvcrt._wpopen
+@ forward _wputenv msvcrt._wputenv
+@ forward _wremove msvcrt._wremove
+@ forward _wrename msvcrt._wrename
+@ forward _write msvcrt._write
+@ forward _wrmdir msvcrt._wrmdir
+@ forward _wsearchenv msvcrt._wsearchenv
+@ forward _wsetlocale msvcrt._wsetlocale
+@ forward _wsopen msvcrt._wsopen
+@ forward _wspawnl msvcrt._wspawnl
+@ forward _wspawnle msvcrt._wspawnle
+@ forward _wspawnlp msvcrt._wspawnlp
+@ forward _wspawnlpe msvcrt._wspawnlpe
+@ forward _wspawnv msvcrt._wspawnv
+@ forward _wspawnve msvcrt._wspawnve
+@ forward _wspawnvp msvcrt._wspawnvp
+@ forward _wspawnvpe msvcrt._wspawnvpe
+@ forward _wsplitpath msvcrt._wsplitpath
+@ forward _wstat msvcrt._wstat
+@ forward _wstrdate msvcrt._wstrdate
+@ forward _wstrtime msvcrt._wstrtime
+@ forward _wsystem msvcrt._wsystem
+@ forward _wtempnam msvcrt._wtempnam
+@ forward _wtmpnam msvcrt._wtmpnam
+@ forward _wtoi msvcrt._wtoi
+@ forward _wtol msvcrt._wtol
+@ forward _wunlink msvcrt._wunlink
+@ forward _wutime msvcrt._wutime
+@ forward _y0 msvcrt._y0
+@ forward _y1 msvcrt._y1
+@ forward _yn msvcrt._yn
+@ forward abort msvcrt.abort
+@ forward abs msvcrt.abs
+@ forward acos msvcrt.acos
+@ forward asctime msvcrt.asctime
+@ forward asin msvcrt.asin
+@ forward atan msvcrt.atan
+@ forward atan2 msvcrt.atan2
+@ forward atexit msvcrt.atexit
+@ forward atof msvcrt.atof
+@ forward atoi msvcrt.atoi
+@ forward atol msvcrt.atol
+@ forward bsearch msvcrt.bsearch
+@ forward calloc msvcrt.calloc
+@ forward ceil msvcrt.ceil
+@ forward clearerr msvcrt.clearerr
+@ forward clock msvcrt.clock
+@ forward cos msvcrt.cos
+@ forward cosh msvcrt.cosh
+@ forward ctime msvcrt.ctime
+@ forward difftime msvcrt.difftime
+@ forward div msvcrt.div
+@ forward exit msvcrt.exit
+@ forward exp msvcrt.exp
+@ forward fabs msvcrt.fabs
+@ forward fclose msvcrt.fclose
+@ forward feof msvcrt.feof
+@ forward ferror msvcrt.ferror
+@ forward fflush msvcrt.fflush
+@ forward fgetc msvcrt.fgetc
+@ forward fgetpos msvcrt.fgetpos
+@ forward fgets msvcrt.fgets
+@ forward fgetwc msvcrt.fgetwc
+@ forward fgetws msvcrt.fgetws
+@ forward floor msvcrt.floor
+@ forward fmod msvcrt.fmod
+@ forward fopen msvcrt.fopen
+@ forward fprintf msvcrt.fprintf
+@ forward fputc msvcrt.fputc
+@ forward fputs msvcrt.fputs
+@ forward fputwc msvcrt.fputwc
+@ forward fputws msvcrt.fputws
+@ forward fread msvcrt.fread
+@ forward free msvcrt.free
+@ forward freopen msvcrt.freopen
+@ forward frexp msvcrt.frexp
+@ forward fscanf msvcrt.fscanf
+@ forward fseek msvcrt.fseek
+@ forward fsetpos msvcrt.fsetpos
+@ forward ftell msvcrt.ftell
+@ forward fwprintf msvcrt.fwprintf
+@ forward fwrite msvcrt.fwrite
+@ forward fwscanf msvcrt.fwscanf
+@ forward getc msvcrt.getc
+@ forward getchar msvcrt.getchar
+@ forward getenv msvcrt.getenv
+@ forward gets msvcrt.gets
+@ forward getwc msvcrt.getwc
+@ forward getwchar msvcrt.getwchar
+@ forward gmtime msvcrt.gmtime
+@ forward is_wctype msvcrt.is_wctype
+@ forward isalnum msvcrt.isalnum
+@ forward isalpha msvcrt.isalpha
+@ forward iscntrl msvcrt.iscntrl
+@ forward isdigit msvcrt.isdigit
+@ forward isgraph msvcrt.isgraph
+@ forward isleadbyte msvcrt.isleadbyte
+@ forward islower msvcrt.islower
+@ forward isprint msvcrt.isprint
+@ forward ispunct msvcrt.ispunct
+@ forward isspace msvcrt.isspace
+@ forward isupper msvcrt.isupper
+@ forward iswalnum msvcrt.iswalnum
+@ forward iswalpha msvcrt.iswalpha
+@ forward iswascii msvcrt.iswascii
+@ forward iswcntrl msvcrt.iswcntrl
+@ forward iswctype msvcrt.iswctype
+@ forward iswdigit msvcrt.iswdigit
+@ forward iswgraph msvcrt.iswgraph
+@ forward iswlower msvcrt.iswlower
+@ forward iswprint msvcrt.iswprint
+@ forward iswpunct msvcrt.iswpunct
+@ forward iswspace msvcrt.iswspace
+@ forward iswupper msvcrt.iswupper
+@ forward iswxdigit msvcrt.iswxdigit
+@ forward isxdigit msvcrt.isxdigit
+@ forward labs msvcrt.labs
+@ forward ldexp msvcrt.ldexp
+@ forward ldiv msvcrt.ldiv
+@ forward localeconv msvcrt.localeconv
+@ forward localtime msvcrt.localtime
+@ forward log msvcrt.log
+@ forward log10 msvcrt.log10
+@ forward longjmp msvcrt.longjmp
+@ forward malloc msvcrt.malloc
+@ forward mblen msvcrt.mblen
+@ forward mbstowcs msvcrt.mbstowcs
+@ forward mbtowc msvcrt.mbtowc
+@ forward memchr msvcrt.memchr
+@ forward memcmp msvcrt.memcmp
+@ forward memcpy msvcrt.memcpy
+@ forward memmove msvcrt.memmove
+@ forward memset msvcrt.memset
+@ forward mktime msvcrt.mktime
+@ forward modf msvcrt.modf
+@ forward perror msvcrt.perror
+@ forward pow msvcrt.pow
+@ forward printf msvcrt.printf
+@ forward putc msvcrt.putc
+@ forward putchar msvcrt.putchar
+@ forward puts msvcrt.puts
+@ forward putwc msvcrt.putwc
+@ forward putwchar msvcrt.putwchar
+@ forward qsort msvcrt.qsort
+@ forward raise msvcrt.raise
+@ forward rand msvcrt.rand
+@ forward realloc msvcrt.realloc
+@ forward remove msvcrt.remove
+@ forward rename msvcrt.rename
+@ forward rewind msvcrt.rewind
+@ forward scanf msvcrt.scanf
+@ forward setbuf msvcrt.setbuf
+@ forward setlocale msvcrt.setlocale
+@ forward setvbuf msvcrt.setvbuf
+@ forward signal msvcrt.signal
+@ forward sin msvcrt.sin
+@ forward sinh msvcrt.sinh
+@ forward sprintf msvcrt.sprintf
+@ forward sqrt msvcrt.sqrt
+@ forward srand msvcrt.srand
+@ forward sscanf msvcrt.sscanf
+@ forward strcat msvcrt.strcat
+@ forward strchr msvcrt.strchr
+@ forward strcmp msvcrt.strcmp
+@ forward strcoll msvcrt.strcoll
+@ forward strcpy msvcrt.strcpy
+@ forward strcspn msvcrt.strcspn
+@ forward strerror msvcrt.strerror
+@ forward strftime msvcrt.strftime
+@ forward strlen msvcrt.strlen
+@ forward strncat msvcrt.strncat
+@ forward strncmp msvcrt.strncmp
+@ forward strncpy msvcrt.strncpy
+@ forward strpbrk msvcrt.strpbrk
+@ forward strrchr msvcrt.strrchr
+@ forward strspn msvcrt.strspn
+@ forward strstr msvcrt.strstr
+@ forward strtod msvcrt.strtod
+@ forward strtok msvcrt.strtok
+@ forward strtol msvcrt.strtol
+@ forward strtoul msvcrt.strtoul
+@ forward strxfrm msvcrt.strxfrm
+@ forward swprintf msvcrt.swprintf
+@ forward swscanf msvcrt.swscanf
+@ forward system msvcrt.system
+@ forward tan msvcrt.tan
+@ forward tanh msvcrt.tanh
+@ forward time msvcrt.time
+@ forward tmpfile msvcrt.tmpfile
+@ forward tmpnam msvcrt.tmpnam
+@ forward tolower msvcrt.tolower
+@ forward toupper msvcrt.toupper
+@ forward towlower msvcrt.towlower
+@ forward towupper msvcrt.towupper
+@ forward ungetc msvcrt.ungetc
+@ forward ungetwc msvcrt.ungetwc
+@ forward vfprintf msvcrt.vfprintf
+@ forward vfwprintf msvcrt.vfwprintf
+@ forward vprintf msvcrt.vprintf
+@ forward vsprintf msvcrt.vsprintf
+@ forward vswprintf msvcrt.vswprintf
+@ forward vwprintf msvcrt.vwprintf
+@ forward wcscat msvcrt.wcscat
+@ forward wcschr msvcrt.wcschr
+@ forward wcscmp msvcrt.wcscmp
+@ forward wcscoll msvcrt.wcscoll
+@ forward wcscpy msvcrt.wcscpy
+@ forward wcscspn msvcrt.wcscspn
+@ forward wcsftime msvcrt.wcsftime
+@ forward wcslen msvcrt.wcslen
+@ forward wcsncat msvcrt.wcsncat
+@ forward wcsncmp msvcrt.wcsncmp
+@ forward wcsncpy msvcrt.wcsncpy
+@ forward wcspbrk msvcrt.wcspbrk
+@ forward wcsrchr msvcrt.wcsrchr
+@ forward wcsspn msvcrt.wcsspn
+@ forward wcsstr msvcrt.wcsstr
+@ forward wcstod msvcrt.wcstod
+@ forward wcstok msvcrt.wcstok
+@ forward wcstol msvcrt.wcstol
+@ forward wcstombs msvcrt.wcstombs
+@ forward wcstoul msvcrt.wcstoul
+@ forward wcsxfrm msvcrt.wcsxfrm
+@ forward wctomb msvcrt.wctomb
+@ forward wprintf msvcrt.wprintf
+@ forward wscanf msvcrt.wscanf
Index: trunk/src/msvcrt/msvcrt20rsrc.orc
===================================================================
--- trunk/src/msvcrt/msvcrt20rsrc.orc	(revision 9633)
+++ trunk/src/msvcrt/msvcrt20rsrc.orc	(revision 9633)
@@ -0,0 +1,40 @@
+/* $Id: msvcrt20rsrc.orc,v 1.3 2003-01-06 13:26:38 sandervl Exp $ */
+
+#include "winuser.h"
+#include "odinrsrc.h"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version (MSVCRT20.DLL from NT 4, SP3)
+//
+
+1 VERSIONINFO
+ FILEVERSION ODIN_FILEVERSION
+ PRODUCTVERSION ODIN_PRODUCTVERSION
+ FILEFLAGSMASK 0x3fL
+ FILEFLAGS 0xaL
+ FILEOS 0x10001L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "040904E4"
+        BEGIN
+            VALUE "Comments", "Odin32 System Dll\0"
+            VALUE "CompanyName", "Odin Team\0"
+            VALUE "FileDescription", "C/C++ Runtime library\0"
+            VALUE "FileVersion", "2.11.000\0"
+            VALUE "InternalName", "MSVCRT20\0"
+            VALUE "LegalCopyright", "Copyright (C) 1999\0"
+            VALUE "LegalTrademarks", "\0"
+            VALUE "OriginalFilename", "MSVCRT20.DLL\0"
+            VALUE "ProductName", "Odin32 - MSVCRT20\0"
+            VALUE "ProductVersion", "2.10.000\0"
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+	VALUE "Translation", 0x409, 0x04E4
+    END
+END
Index: trunk/src/msvcrt/msvcrt40.def
===================================================================
--- trunk/src/msvcrt/msvcrt40.def	(revision 9633)
+++ trunk/src/msvcrt/msvcrt40.def	(revision 9633)
@@ -0,0 +1,1141 @@
+; $Id: msvcrt40.def,v 1.11 2003-01-06 13:26:38 sandervl Exp $
+
+;
+; Based on Windows 98 : MSVCRT20.DLL (v2.11.000)
+;
+LIBRARY MSVCRT40 INITINSTANCE TERMINSTANCE
+DESCRIPTION 'Odin32 System DLL - MSVCrt40'
+DATA MULTIPLE NONSHARED
+
+IMPORTS
+  RegisterLxDll = KERNEL32.1238
+  UnregisterLxDll = KERNEL32.1239
+
+EXPORTS
+; stub ??0Iostream_init@@QAE@AAVios@@H@Z  #	@1
+; stub ??0Iostream_init@@QAE@XZ #	@2
+; stub ??0filebuf@@QAE@ABV0@@Z #	@3
+; stub ??0filebuf@@QAE@H@Z #	@4
+; stub ??0filebuf@@QAE@HPADH@Z #	@5
+; stub ??0filebuf@@QAE@XZ #	@6
+; stub ??0fstream@@QAE@ABV0@@Z #	@7
+; stub ??0fstream@@QAE@H@Z #	@8
+; stub ??0fstream@@QAE@HPADH@Z #	@9
+; stub ??0fstream@@QAE@PBDHH@Z #	@10
+; stub ??0fstream@@QAE@XZ #	@11
+; stub ??0ifstream@@QAE@ABV0@@Z #	@12
+; stub ??0ifstream@@QAE@H@Z #	@13
+; stub ??0ifstream@@QAE@HPADH@Z #	@14
+; stub ??0ifstream@@QAE@PBDHH@Z #	@15
+; stub ??0ifstream@@QAE@XZ #	@16
+; stub ??0ios@@IAE@ABV0@@Z #	@17
+; stub ??0ios@@IAE@XZ #	@18
+; stub ??0ios@@QAE@PAVstreambuf@@@Z #	@19
+; stub ??0iostream@@IAE@ABV0@@Z #	@20
+; stub ??0iostream@@IAE@XZ #	@21
+; stub ??0iostream@@QAE@PAVstreambuf@@@Z #	@22
+; stub ??0istream@@IAE@ABV0@@Z #	@23
+; stub ??0istream@@IAE@XZ #	@24
+; stub ??0istream@@QAE@PAVstreambuf@@@Z #	@25
+; stub ??0istream_withassign@@QAE@ABV0@@Z #	@26
+; stub ??0istream_withassign@@QAE@PAVstreambuf@@@Z #	@27
+; stub ??0istream_withassign@@QAE@XZ #	@28
+; stub ??0istrstream@@QAE@ABV0@@Z #	@29
+; stub ??0istrstream@@QAE@PAD@Z #	@30
+; stub ??0istrstream@@QAE@PADH@Z #	@31
+; stub ??0ofstream@@QAE@ABV0@@Z #	@32
+; stub ??0ofstream@@QAE@H@Z #	@33
+; stub ??0ofstream@@QAE@HPADH@Z #	@34
+; stub ??0ofstream@@QAE@PBDHH@Z #	@35
+; stub ??0ofstream@@QAE@XZ #	@36
+; stub ??0ostream@@IAE@ABV0@@Z #	@37
+; stub ??0ostream@@IAE@XZ #	@38
+; stub ??0ostream@@QAE@PAVstreambuf@@@Z #	@39
+; stub ??0ostream_withassign@@QAE@ABV0@@Z #	@40
+; stub ??0ostream_withassign@@QAE@PAVstreambuf@@@Z #	@41
+; stub ??0ostream_withassign@@QAE@XZ #	@42
+; stub ??0ostrstream@@QAE@ABV0@@Z #	@43
+; stub ??0ostrstream@@QAE@PADHH@Z #	@44
+; stub ??0ostrstream@@QAE@XZ #	@45
+; stub ??0stdiobuf@@QAE@ABV0@@Z #	@46
+; stub ??0stdiobuf@@QAE@PAU_iobuf@@@Z #	@47
+; stub ??0stdiostream@@QAE@ABV0@@Z #	@48
+; stub ??0stdiostream@@QAE@PAU_iobuf@@@Z #	@49
+; stub ??0streambuf@@IAE@PADH@Z #	@50
+; stub ??0streambuf@@IAE@XZ #	@51
+; stub ??0streambuf@@QAE@ABV0@@Z #	@52
+; stub ??0strstream@@QAE@ABV0@@Z #	@53
+; stub ??0strstream@@QAE@PADHH@Z #	@54
+; stub ??0strstream@@QAE@XZ #	@55
+; stub ??0strstreambuf@@QAE@ABV0@@Z #	@56
+; stub ??0strstreambuf@@QAE@H@Z #	@57
+; stub ??0strstreambuf@@QAE@P6APAXJ@ZP6AXPAX@Z@Z #	@58
+; stub ??0strstreambuf@@QAE@PADH0@Z #	@59
+; stub ??0strstreambuf@@QAE@XZ #	@60
+; stub ??1Iostream_init@@QAE@XZ #	@61
+; stub ??1filebuf@@UAE@XZ #	@62
+; stub ??1fstream@@UAE@XZ #	@63
+; stub ??1ifstream@@UAE@XZ #	@64
+; stub ??1ios@@UAE@XZ #	@65
+; stub ??1iostream@@UAE@XZ #	@66
+; stub ??1istream@@UAE@XZ #	@67
+; stub ??1istream_withassign@@UAE@XZ #	@68
+; stub ??1istrstream@@UAE@XZ #	@69
+; stub ??1ofstream@@UAE@XZ #	@70
+; stub ??1ostream@@UAE@XZ #	@71
+; stub ??1ostream_withassign@@UAE@XZ #	@72
+; stub ??1ostrstream@@UAE@XZ #	@73
+; stub ??1stdiobuf@@UAE@XZ #	@74
+; stub ??1stdiostream@@UAE@XZ #	@75
+; stub ??1streambuf@@UAE@XZ #	@76
+; stub ??1strstream@@UAE@XZ #	@77
+; stub ??1strstreambuf@@UAE@XZ #	@78
+  ??2@YAPAXI@Z	@79
+  ??3@YAXPAX@Z 	@80
+; stub ??4Iostream_init@@QAEAAV0@ABV0@@Z #	@81
+; stub ??4filebuf@@QAEAAV0@ABV0@@Z #	@82
+; stub ??4fstream@@QAEAAV0@AAV0@@Z #	@83
+; stub ??4ifstream@@QAEAAV0@ABV0@@Z #	@84
+; stub ??4ios@@IAEAAV0@ABV0@@Z #	@85
+; stub ??4iostream@@IAEAAV0@AAV0@@Z #	@86
+; stub ??4iostream@@IAEAAV0@PAVstreambuf@@@Z #	@87
+; stub ??4istream@@IAEAAV0@ABV0@@Z #	@88
+; stub ??4istream@@IAEAAV0@PAVstreambuf@@@Z #	@89
+; stub ??4istream_withassign@@QAEAAV0@ABV0@@Z #	@90
+; stub ??4istream_withassign@@QAEAAVistream@@ABV1@@Z #	@91
+; stub ??4istream_withassign@@QAEAAVistream@@PAVstreambuf@@@Z #	@92
+; stub ??4istrstream@@QAEAAV0@ABV0@@Z #	@93
+; stub ??4ofstream@@QAEAAV0@ABV0@@Z #	@94
+; stub ??4ostream@@IAEAAV0@ABV0@@Z #	@95
+; stub ??4ostream@@IAEAAV0@PAVstreambuf@@@Z #	@96
+; stub ??4ostream_withassign@@QAEAAV0@ABV0@@Z #	@97
+; stub ??4ostream_withassign@@QAEAAVostream@@ABV1@@Z #	@98
+; stub ??4ostream_withassign@@QAEAAVostream@@PAVstreambuf@@@Z #	@99
+; stub ??4ostrstream@@QAEAAV0@ABV0@@Z #	@100
+; stub ??4stdiobuf@@QAEAAV0@ABV0@@Z #	@101
+; stub ??4stdiostream@@QAEAAV0@AAV0@@Z #	@102
+; stub ??4streambuf@@QAEAAV0@ABV0@@Z #	@103
+; stub ??4strstream@@QAEAAV0@AAV0@@Z #	@104
+; stub ??4strstreambuf@@QAEAAV0@ABV0@@Z #	@105
+; stub ??5istream@@QAEAAV0@AAC@Z #	@106
+; stub ??5istream@@QAEAAV0@AAD@Z #	@107
+; stub ??5istream@@QAEAAV0@AAE@Z #	@108
+; stub ??5istream@@QAEAAV0@AAF@Z #	@109
+; stub ??5istream@@QAEAAV0@AAG@Z #	@110
+; stub ??5istream@@QAEAAV0@AAH@Z #	@111
+; stub ??5istream@@QAEAAV0@AAI@Z #	@112
+; stub ??5istream@@QAEAAV0@AAJ@Z #	@113
+; stub ??5istream@@QAEAAV0@AAK@Z #	@114
+; stub ??5istream@@QAEAAV0@AAM@Z #	@115
+; stub ??5istream@@QAEAAV0@AAN@Z #	@116
+; stub ??5istream@@QAEAAV0@AAO@Z #	@117
+; stub ??5istream@@QAEAAV0@P6AAAV0@AAV0@@Z@Z #	@118
+; stub ??5istream@@QAEAAV0@P6AAAVios@@AAV1@@Z@Z #	@119
+; stub ??5istream@@QAEAAV0@PAC@Z #	@120
+; stub ??5istream@@QAEAAV0@PAD@Z #	@121
+; stub ??5istream@@QAEAAV0@PAE@Z #	@122
+; stub ??5istream@@QAEAAV0@PAVstreambuf@@@Z #	@123
+; stub ??6ostream@@QAEAAV0@C@Z #	@124
+; stub ??6ostream@@QAEAAV0@D@Z #	@125
+; stub ??6ostream@@QAEAAV0@E@Z #	@126
+; stub ??6ostream@@QAEAAV0@F@Z #	@127
+; stub ??6ostream@@QAEAAV0@G@Z #	@128
+; stub ??6ostream@@QAEAAV0@H@Z #	@129
+; stub ??6ostream@@QAEAAV0@I@Z #	@130
+; stub ??6ostream@@QAEAAV0@J@Z #	@131
+; stub ??6ostream@@QAEAAV0@K@Z #	@132
+; stub ??6ostream@@QAEAAV0@M@Z #	@133
+; stub ??6ostream@@QAEAAV0@N@Z #	@134
+; stub ??6ostream@@QAEAAV0@O@Z #	@135
+; stub ??6ostream@@QAEAAV0@P6AAAV0@AAV0@@Z@Z #	@136
+; stub ??6ostream@@QAEAAV0@P6AAAVios@@AAV1@@Z@Z #	@137
+; stub ??6ostream@@QAEAAV0@PAVstreambuf@@@Z #	@138
+; stub ??6ostream@@QAEAAV0@PBC@Z #	@139
+; stub ??6ostream@@QAEAAV0@PBD@Z #	@140
+; stub ??6ostream@@QAEAAV0@PBE@Z #	@141
+; stub ??6ostream@@QAEAAV0@PBX@Z #	@142
+; stub ??7ios@@QBEHXZ #	@143
+; stub ??Bios@@QBEPAXXZ #	@144
+; stub ??_7filebuf@@6B@ #	@145
+; stub ??_7fstream@@6B@ #	@146
+; stub ??_7ifstream@@6B@ #	@147
+; stub ??_7ios@@6B@ #	@148
+; stub ??_7iostream@@6B@ #	@149
+; stub ??_7istream@@6B@ #	@150
+; stub ??_7istream_withassign@@6B@ #	@151
+; stub ??_7istrstream@@6B@ #	@152
+; stub ??_7ofstream@@6B@ #	@153
+; stub ??_7ostream@@6B@ #	@154
+; stub ??_7ostream_withassign@@6B@ #	@155
+; stub ??_7ostrstream@@6B@ #	@156
+; stub ??_7stdiobuf@@6B@ #	@157
+; stub ??_7stdiostream@@6B@ #	@158
+; stub ??_7streambuf@@6B@ #	@159
+; stub ??_7strstream@@6B@ #	@160
+; stub ??_7strstreambuf@@6B@ #	@161
+; stub ??_8fstream@@7Bistream@@@ #	@162
+; stub ??_8fstream@@7Bostream@@@ #	@163
+; stub ??_8ifstream@@7B@ #	@164
+; stub ??_8iostream@@7Bistream@@@ #	@165
+; stub ??_8iostream@@7Bostream@@@ #	@166
+; stub ??_8istream@@7B@ #	@167
+; stub ??_8istream_withassign@@7B@ #	@168
+; stub ??_8istrstream@@7B@ #	@169
+; stub ??_8ofstream@@7B@ #	@170
+; stub ??_8ostream@@7B@ #	@171
+; stub ??_8ostream_withassign@@7B@ #	@172
+; stub ??_8ostrstream@@7B@ #	@173
+; stub ??_8stdiostream@@7Bistream@@@ #	@174
+; stub ??_8stdiostream@@7Bostream@@@ #	@175
+; stub ??_8strstream@@7Bistream@@@ #	@176
+; stub ??_8strstream@@7Bostream@@@ #	@177
+; stub ??_Dfstream@@QAEXXZ #	@178
+; stub ??_Difstream@@QAEXXZ #	@179
+; stub ??_Diostream@@QAEXXZ #	@180
+; stub ??_Distream@@QAEXXZ #	@181
+; stub ??_Distream_withassign@@QAEXXZ #	@182
+; stub ??_Distrstream@@QAEXXZ #	@183
+; stub ??_Dofstream@@QAEXXZ #	@184
+; stub ??_Dostream@@QAEXXZ #	@185
+; stub ??_Dostream_withassign@@QAEXXZ #	@186
+; stub ??_Dostrstream@@QAEXXZ #	@187
+; stub ??_Dstdiostream@@QAEXXZ #	@188
+; stub ??_Dstrstream@@QAEXXZ #	@189
+; stub ??_EIostream_init@@QAEPAXI@Z #	@190
+; stub ??_Efilebuf@@UAEPAXI@Z #	@191
+; stub ??_Efstream@@UAEPAXI@Z #	@192
+; stub ??_Eifstream@@UAEPAXI@Z #	@193
+; stub ??_Eios@@UAEPAXI@Z #	@194
+; stub ??_Eiostream@@UAEPAXI@Z #	@195
+; stub ??_Eistream@@UAEPAXI@Z #	@196
+; stub ??_Eistream_withassign@@UAEPAXI@Z #	@197
+; stub ??_Eistrstream@@UAEPAXI@Z #	@198
+; stub ??_Eofstream@@UAEPAXI@Z #	@199
+; stub ??_Eostream@@UAEPAXI@Z #	@200
+; stub ??_Eostream_withassign@@UAEPAXI@Z #	@201
+; stub ??_Eostrstream@@UAEPAXI@Z #	@202
+; stub ??_Estdiobuf@@UAEPAXI@Z #	@203
+; stub ??_Estdiostream@@UAEPAXI@Z #	@204
+; stub ??_Estreambuf@@UAEPAXI@Z #	@205
+; stub ??_Estrstream@@UAEPAXI@Z #	@206
+; stub ??_Estrstreambuf@@UAEPAXI@Z #	@207
+; stub ??_GIostream_init@@QAEPAXI@Z #	@208
+; stub ??_Gfilebuf@@UAEPAXI@Z #	@209
+; stub ??_Gfstream@@UAEPAXI@Z #	@210
+; stub ??_Gifstream@@UAEPAXI@Z #	@211
+; stub ??_Gios@@UAEPAXI@Z #	@212
+; stub ??_Giostream@@UAEPAXI@Z #	@213
+; stub ??_Gistream@@UAEPAXI@Z #	@214
+; stub ??_Gistream_withassign@@UAEPAXI@Z #	@215
+; stub ??_Gistrstream@@UAEPAXI@Z #	@216
+; stub ??_Gofstream@@UAEPAXI@Z #	@217
+; stub ??_Gostream@@UAEPAXI@Z #	@218
+; stub ??_Gostream_withassign@@UAEPAXI@Z #	@219
+; stub ??_Gostrstream@@UAEPAXI@Z #	@220
+; stub ??_Gstdiobuf@@UAEPAXI@Z #	@221
+; stub ??_Gstdiostream@@UAEPAXI@Z #	@222
+; stub ??_Gstreambuf@@UAEPAXI@Z #	@223
+; stub ??_Gstrstream@@UAEPAXI@Z #	@224
+; stub ??_Gstrstreambuf@@UAEPAXI@Z #	@225
+  ?_query_new_handler@@YAP6AHI@ZXZ	@226
+  ?_query_new_mode@@YAHXZ	@227
+  ?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z	@228
+  ?_set_new_mode@@YAHH@Z 	@229
+  ?_set_se_translator@@YAP6AXIPAU_EXCEPTION_POINTERS@@@ZP6AXI0@Z@Z	@230
+; stub ?adjustfield@ios@@2JB #	@231
+; stub ?allocate@streambuf@@IAEHXZ #	@232
+; stub ?attach@filebuf@@QAEPAV1@H@Z #	@233
+; stub ?attach@fstream@@QAEXH@Z #	@234
+; stub ?attach@ifstream@@QAEXH@Z #	@235
+; stub ?attach@ofstream@@QAEXH@Z #	@236
+; stub ?bad@ios@@QBEHXZ #	@237
+; stub ?base@streambuf@@IBEPADXZ #	@238
+; stub ?basefield@ios@@2JB #	@239
+; stub ?binary@filebuf@@2HB #	@240
+; stub ?bitalloc@ios@@SAJXZ #	@241
+; stub ?blen@streambuf@@IBEHXZ #	@242
+; stub ?cerr@@3Vostream_withassign@@A #	@243
+; stub ?cin@@3Vistream_withassign@@A #	@244
+; stub ?clear@ios@@QAEXH@Z #	@245
+; stub ?clog@@3Vostream_withassign@@A #	@246
+; stub ?close@filebuf@@QAEPAV1@XZ #	@247
+; stub ?close@fstream@@QAEXXZ #	@248
+; stub ?close@ifstream@@QAEXXZ #	@249
+; stub ?close@ofstream@@QAEXXZ #	@250
+; stub ?clrlock@ios@@QAAXXZ #	@251
+; stub ?clrlock@streambuf@@QAEXXZ #	@252
+; stub ?cout@@3Vostream_withassign@@A #	@253
+; stub ?dbp@streambuf@@QAEXXZ #	@254
+; stub ?dec@@YAAAVios@@AAV1@@Z #	@255
+; stub ?delbuf@ios@@QAEXH@Z #	@256
+; stub ?delbuf@ios@@QBEHXZ #	@257
+; stub ?doallocate@streambuf@@MAEHXZ #	@258
+; stub ?doallocate@strstreambuf@@MAEHXZ #	@259
+; stub ?eatwhite@istream@@QAEXXZ #	@260
+; stub ?eback@streambuf@@IBEPADXZ #	@261
+; stub ?ebuf@streambuf@@IBEPADXZ #	@262
+; stub ?egptr@streambuf@@IBEPADXZ #	@263
+; stub ?endl@@YAAAVostream@@AAV1@@Z #	@264
+; stub ?ends@@YAAAVostream@@AAV1@@Z #	@265
+; stub ?eof@ios@@QBEHXZ #	@266
+; stub ?epptr@streambuf@@IBEPADXZ #	@267
+; stub ?fLockcInit@ios@@0HA #	@268
+; stub ?fail@ios@@QBEHXZ #	@269
+; stub ?fd@filebuf@@QBEHXZ #	@270
+; stub ?fd@fstream@@QBEHXZ #	@271
+; stub ?fd@ifstream@@QBEHXZ #	@272
+; stub ?fd@ofstream@@QBEHXZ #	@273
+; stub ?fill@ios@@QAEDD@Z #	@274
+; stub ?fill@ios@@QBEDXZ #	@275
+; stub ?flags@ios@@QAEJJ@Z #	@276
+; stub ?flags@ios@@QBEJXZ #	@277
+; stub ?floatfield@ios@@2JB #	@278
+; stub ?flush@@YAAAVostream@@AAV1@@Z #	@279
+; stub ?flush@ostream@@QAEAAV1@XZ #	@280
+; stub ?freeze@strstreambuf@@QAEXH@Z #	@281
+; stub ?gbump@streambuf@@IAEXH@Z #	@282
+; stub ?gcount@istream@@QBEHXZ #	@283
+; stub ?get@istream@@QAEAAV1@AAC@Z #	@284
+; stub ?get@istream@@QAEAAV1@AAD@Z #	@285
+; stub ?get@istream@@QAEAAV1@AAE@Z #	@286
+; stub ?get@istream@@QAEAAV1@AAVstreambuf@@D@Z #	@287
+; stub ?get@istream@@QAEAAV1@PACHD@Z #	@288
+; stub ?get@istream@@QAEAAV1@PADHD@Z #	@289
+; stub ?get@istream@@QAEAAV1@PAEHD@Z #	@290
+; stub ?get@istream@@QAEHXZ #	@291
+; stub ?getdouble@istream@@AAEHPADH@Z #	@292
+; stub ?getint@istream@@AAEHPAD@Z #	@293
+; stub ?getline@istream@@QAEAAV1@PACHD@Z #	@294
+; stub ?getline@istream@@QAEAAV1@PADHD@Z #	@295
+; stub ?getline@istream@@QAEAAV1@PAEHD@Z #	@296
+; stub ?good@ios@@QBEHXZ #	@297
+; stub ?gptr@streambuf@@IBEPADXZ #	@298
+; stub ?hex@@YAAAVios@@AAV1@@Z #	@299
+; stub ?ignore@istream@@QAEAAV1@HH@Z #	@300
+; stub ?in_avail@streambuf@@QBEHXZ #	@301
+; stub ?init@ios@@IAEXPAVstreambuf@@@Z #	@302
+; stub ?ipfx@istream@@QAEHH@Z #	@303
+; stub ?is_open@filebuf@@QBEHXZ #	@304
+; stub ?is_open@fstream@@QBEHXZ #	@305
+; stub ?is_open@ifstream@@QBEHXZ #	@306
+; stub ?is_open@ofstream@@QBEHXZ #	@307
+; stub ?isfx@istream@@QAEXXZ #	@308
+; stub ?iword@ios@@QBEAAJH@Z #	@309
+; stub ?lock@ios@@QAAXXZ #	@310
+; stub ?lock@streambuf@@QAEXXZ #	@311
+; stub ?lockbuf@ios@@QAAXXZ #	@312
+; stub ?lockc@ios@@KAXXZ #	@313
+; stub ?lockptr@ios@@IAEPAU_RTL_CRITICAL_SECTION@@XZ #	@314
+; stub ?lockptr@streambuf@@IAEPAU_RTL_CRITICAL_SECTION@@XZ #	@315
+; stub ?oct@@YAAAVios@@AAV1@@Z #	@316
+; stub ?open@filebuf@@QAEPAV1@PBDHH@Z #	@317
+; stub ?open@fstream@@QAEXPBDHH@Z #	@318
+; stub ?open@ifstream@@QAEXPBDHH@Z #	@319
+; stub ?open@ofstream@@QAEXPBDHH@Z #	@320
+; stub ?openprot@filebuf@@2HB #	@321
+; stub ?opfx@ostream@@QAEHXZ #	@322
+; stub ?osfx@ostream@@QAEXXZ #	@323
+; stub ?out_waiting@streambuf@@QBEHXZ #	@324
+; stub ?overflow@filebuf@@UAEHH@Z #	@325
+; stub ?overflow@stdiobuf@@UAEHH@Z #	@326
+; stub ?overflow@strstreambuf@@UAEHH@Z #	@327
+; stub ?pbackfail@stdiobuf@@UAEHH@Z #	@328
+; stub ?pbackfail@streambuf@@UAEHH@Z #	@329
+; stub ?pbase@streambuf@@IBEPADXZ #	@330
+; stub ?pbump@streambuf@@IAEXH@Z #	@331
+; stub ?pcount@ostrstream@@QBEHXZ #	@332
+; stub ?pcount@strstream@@QBEHXZ #	@333
+; stub ?peek@istream@@QAEHXZ #	@334
+; stub ?pptr@streambuf@@IBEPADXZ #	@335
+; stub ?precision@ios@@QAEHH@Z #	@336
+; stub ?precision@ios@@QBEHXZ #	@337
+; stub ?put@ostream@@QAEAAV1@C@Z #	@338
+; stub ?put@ostream@@QAEAAV1@D@Z #	@339
+; stub ?put@ostream@@QAEAAV1@E@Z #	@340
+; stub ?putback@istream@@QAEAAV1@D@Z #	@341
+; stub ?pword@ios@@QBEAAPAXH@Z #	@342
+; stub ?rdbuf@fstream@@QBEPAVfilebuf@@XZ #	@343
+; stub ?rdbuf@ifstream@@QBEPAVfilebuf@@XZ #	@344
+; stub ?rdbuf@ios@@QBEPAVstreambuf@@XZ #	@345
+; stub ?rdbuf@istrstream@@QBEPAVstrstreambuf@@XZ #	@346
+; stub ?rdbuf@ofstream@@QBEPAVfilebuf@@XZ #	@347
+; stub ?rdbuf@ostrstream@@QBEPAVstrstreambuf@@XZ #	@348
+; stub ?rdbuf@stdiostream@@QBEPAVstdiobuf@@XZ #	@349
+; stub ?rdbuf@strstream@@QBEPAVstrstreambuf@@XZ #	@350
+; stub ?rdstate@ios@@QBEHXZ #	@351
+; stub ?read@istream@@QAEAAV1@PACH@Z #	@352
+; stub ?read@istream@@QAEAAV1@PADH@Z #	@353
+; stub ?read@istream@@QAEAAV1@PAEH@Z #	@354
+; stub ?sbumpc@streambuf@@QAEHXZ #	@355
+; stub ?seekg@istream@@QAEAAV1@J@Z #	@356
+; stub ?seekg@istream@@QAEAAV1@JW4seek_dir@ios@@@Z #	@357
+; stub ?seekoff@filebuf@@UAEJJW4seek_dir@ios@@H@Z #	@358
+; stub ?seekoff@stdiobuf@@UAEJJW4seek_dir@ios@@H@Z #	@359
+; stub ?seekoff@streambuf@@UAEJJW4seek_dir@ios@@H@Z #	@360
+; stub ?seekoff@strstreambuf@@UAEJJW4seek_dir@ios@@H@Z #	@361
+; stub ?seekp@ostream@@QAEAAV1@J@Z #	@362
+; stub ?seekp@ostream@@QAEAAV1@JW4seek_dir@ios@@@Z #	@363
+; stub ?seekpos@streambuf@@UAEJJH@Z #	@364
+  ?set_terminate@@YAP6AXXZP6AXXZ@Z	@365
+  ?set_unexpected@@YAP6AXXZP6AXXZ@Z 	@366
+; stub ?setb@streambuf@@IAEXPAD0H@Z #	@367
+; stub ?setbuf@filebuf@@UAEPAVstreambuf@@PADH@Z #	@368
+; stub ?setbuf@fstream@@QAEPAVstreambuf@@PADH@Z #	@369
+; stub ?setbuf@ifstream@@QAEPAVstreambuf@@PADH@Z #	@370
+; stub ?setbuf@ofstream@@QAEPAVstreambuf@@PADH@Z #	@371
+; stub ?setbuf@streambuf@@UAEPAV1@PADH@Z #	@372
+; stub ?setbuf@strstreambuf@@UAEPAVstreambuf@@PADH@Z #	@373
+; stub ?setf@ios@@QAEJJ@Z #	@374
+; stub ?setf@ios@@QAEJJJ@Z #	@375
+; stub ?setg@streambuf@@IAEXPAD00@Z #	@376
+; stub ?setlock@ios@@QAAXXZ #	@377
+; stub ?setlock@streambuf@@QAEXXZ #	@378
+; stub ?setmode@filebuf@@QAEHH@Z #	@379
+; stub ?setmode@fstream@@QAEHH@Z #	@380
+; stub ?setmode@ifstream@@QAEHH@Z #	@381
+; stub ?setmode@ofstream@@QAEHH@Z #	@382
+; stub ?setp@streambuf@@IAEXPAD0@Z #	@383
+; stub ?setrwbuf@stdiobuf@@QAEHHH@Z #	@384
+; stub ?sgetc@streambuf@@QAEHXZ #	@385
+; stub ?sgetn@streambuf@@QAEHPADH@Z #	@386
+; stub ?sh_none@filebuf@@2HB #	@387
+; stub ?sh_read@filebuf@@2HB #	@388
+; stub ?sh_write@filebuf@@2HB #	@389
+; stub ?snextc@streambuf@@QAEHXZ #	@390
+; stub ?sputbackc@streambuf@@QAEHD@Z #	@391
+; stub ?sputc@streambuf@@QAEHH@Z #	@392
+; stub ?sputn@streambuf@@QAEHPBDH@Z #	@393
+; stub ?stdiofile@stdiobuf@@QAEPAU_iobuf@@XZ #	@394
+; stub ?stossc@streambuf@@QAEXXZ #	@395
+; stub ?str@istrstream@@QAEPADXZ #	@396
+; stub ?str@ostrstream@@QAEPADXZ #	@397
+; stub ?str@strstream@@QAEPADXZ #	@398
+; stub ?str@strstreambuf@@QAEPADXZ #	@399
+; stub ?sunk_with_stdio@ios@@0HA #	@400
+; stub ?sync@filebuf@@UAEHXZ #	@401
+; stub ?sync@istream@@QAEHXZ #	@402
+; stub ?sync@stdiobuf@@UAEHXZ #	@403
+; stub ?sync@streambuf@@UAEHXZ #	@404
+; stub ?sync@strstreambuf@@UAEHXZ #	@405
+; stub ?sync_with_stdio@ios@@SAXXZ #	@406
+; stub ?tellg@istream@@QAEJXZ #	@407
+; stub ?tellp@ostream@@QAEJXZ #	@408
+  ?terminate@@YAXXZ	@409
+; stub ?text@filebuf@@2HB #	@410
+; stub ?tie@ios@@QAEPAVostream@@PAV2@@Z #	@411
+; stub ?tie@ios@@QBEPAVostream@@XZ #	@412
+; stub ?unbuffered@streambuf@@IAEXH@Z #	@413
+; stub ?unbuffered@streambuf@@IBEHXZ #	@414
+; stub ?underflow@filebuf@@UAEHXZ #	@415
+; stub ?underflow@stdiobuf@@UAEHXZ #	@416
+; stub ?underflow@strstreambuf@@UAEHXZ #	@417
+  ?unexpected@@YAXXZ 	@418
+; stub ?unlock@ios@@QAAXXZ #	@419
+; stub ?unlock@streambuf@@QAEXXZ #	@420
+; stub ?unlockbuf@ios@@QAAXXZ #	@421
+; stub ?unlockc@ios@@KAXXZ #	@422
+; stub ?unsetf@ios@@QAEJJ@Z #	@423
+; stub ?width@ios@@QAEHH@Z #	@424
+; stub ?width@ios@@QBEHXZ #	@425
+; stub ?write@ostream@@QAEAAV1@PBCH@Z #	@426
+; stub ?write@ostream@@QAEAAV1@PBDH@Z #	@427
+; stub ?write@ostream@@QAEAAV1@PBEH@Z #	@428
+; stub ?writepad@ostream@@AAEAAV1@PBD0@Z #	@429
+; stub ?ws@@YAAAVistream@@AAV1@@Z #	@430
+; stub ?x_curindex@ios@@0HA #	@431
+; stub ?x_lockc@ios@@0U_RTL_CRITICAL_SECTION@@A #	@432
+; stub ?x_maxbit@ios@@0JA #	@433
+; stub ?x_statebuf@ios@@0QAJA #	@434
+; stub ?xalloc@ios@@SAHXZ #	@435
+; stub ?xsgetn@streambuf@@UAEHPADH@Z #	@436
+; stub ?xsputn@streambuf@@UAEHPBDH@Z #	@437
+; stub $I10_OUTPUT #	@438
+  _CIacos 	@439
+  _CIasin 	@440
+  _CIatan	@441
+  _CIatan2 	@442
+  _CIcos	@443
+  _CIcosh 	@444
+  _CIexp	@445
+  _CIfmod	@446
+  _CIlog 	@447
+  _CIlog10 	@448
+  _CIpow 	@449
+  _CIsin	@450
+  _CIsinh	@451
+  _CIsqrt	@452
+  _CItan 	@453
+  _CItanh	@454
+  _CxxThrowException	@455
+  _HUGE 	@456
+  _XcptFilter	@457
+  __CxxFrameHandler	@458
+;  __CxxLongjmpUnwind	@459
+; __STRINGTOLD 	@460
+  __argc 	@461
+  __argv	@462
+  __dllonexit	@463
+  __doserrno	@464
+;  __fpecode	@465
+; cdecl __getmainargs(ptr ptr ptr long long) MSVCRT20__getmainargs	@466
+  __initenv	@467
+  __isascii	@468
+  __iscsym	@469
+  __iscsymf	@470
+  __lconv_init	@471
+  __mb_cur_max 	@472
+  __p___argc	@473
+  __p___argv	@474
+  __p___initenv	@475
+  __p___mb_cur_max	@476
+  __p___wargv	@477
+  __p___winitenv	@478
+  __p__acmdln	@479
+;  __p__amblksiz	@480
+  __p__commode	@481
+;  __p__daylight	@482
+  __p__environ	@483
+  __p__fmode	@484
+  __p__iob	@485
+  __p__mbctype	@486
+  __p__osver	@487
+  __p__pctype	@488
+;  __p__pgmptr	@489
+;  __p__pwctype	@490
+  __p__timezone	@491
+;  __p__tzname	@492
+  __p__wcmdln	@493
+  __p__wenviron	@494
+  __p__winmajor	@495
+  __p__winminor	@496
+  __p__winver 	@497
+;  __p__wpgmptr	@498
+;  __pxcptinfoptrs	@499
+  __threadhandle	@500
+  __threadid	@501
+  __toascii	@502
+  __wargv	@503
+;@ cdecl __wgetmainargs(ptr ptr ptr long long) MSVCRT20__wgetmainargs	@504
+  __winitenv	@505
+  _abnormal_termination	@506
+  _access 	@507
+  _acmdln	@508
+  _adj_fdiv_m16i	@509
+  _adj_fdiv_m32	@510
+  _adj_fdiv_m32i	@511
+  _adj_fdiv_m64 	@512
+  _adj_fdiv_r	@513
+  _adj_fdivr_m16i 	@514
+  _adj_fdivr_m32	@515
+  _adj_fdivr_m32i	@516
+  _adj_fdivr_m64	@517
+  _adj_fpatan	@518
+  _adj_fprem	@519
+  _adj_fprem1	@520
+  _adj_fptan	@521
+  _adjust_fdiv	@522
+;  _aexit_rtn	@523
+  _amsg_exit 	@524
+  _assert	@525
+;  _atodbl	@526
+;  _atoldbl	@527
+  _beep	@528
+  _beginthread 	@529
+  _beginthreadex	@530
+  _c_exit	@531
+  _cabs	@532
+  _cexit	@533
+  _cgets	@534
+  _chdir	@535
+  _chdrive	@536
+  _chgsign	@537
+  _chmod	@538
+;  _chsize	@539
+  _clearfp	@540
+  _close	@541
+  _commit	@542
+  _commode	@543
+  _control87	@544
+  _controlfp	@545
+  _copysign	@546
+  _cprintf = _cprintf	@547
+  _cputs = _cputs	@548
+  _creat = _creat	@549
+  _cscanf = _cscanf	@550
+  _ctype = _ctype	@551
+  _cwait = _cwait	@552
+;  _daylight = _daylight	@553
+;  _dup = _dup	@554
+;  _dup2 = _dup2	@555
+  _ecvt = _ecvt	@556
+  _endthread = _endthread	@557
+  _endthreadex = _endthreadex	@558
+  _environ = _environ	@559
+  _eof = _eof	@560
+  _errno = _errno	@561
+  _except_handler2 = _except_handler2	@562
+  _except_handler3 = _except_handler3	@563
+  _execl = _execl	@564
+;  _execle = _execle	@565
+  _execlp = _execlp	@566
+;  _execlpe = _execlpe	@567
+  _execv = _execv	@568
+  _execve = _execve	@569
+  _execvp = _execvp	@570
+  _execvpe = _execvpe	@571
+  _exit = _exit	@572
+  _expand = _expand	@573
+  _fcloseall = _fcloseall	@574
+;  _fcvt = _fcvt	@575
+  _fdopen = _fdopen	@576
+  _fgetchar = _fgetchar	@577
+  _fgetwchar = _fgetwchar	@578
+  _filbuf = _filbuf	@579
+;  _fileinfo = _fileinfo	@580
+  _filelength = _filelength	@581
+  _fileno = _fileno	@582
+  _findclose = _findclose	@583
+  _findfirst = _findfirst	@584
+  _findnext = _findnext	@585
+  _finite = _finite	@586
+  _flsbuf = _flsbuf	@587
+  _flushall = _flushall	@588
+  _fmode = _fmode	@589
+  _fpclass = _fpclass	@590
+;  _fpieee_flt = _fpieee_flt	@591
+  _fpreset = _fpreset	@592
+  _fputchar = _fputchar	@593
+  _fputwchar = _fputwchar	@594
+  _fsopen = _fsopen	@595
+  _fstat = _fstat	@596
+  _ftime = _ftime	@597
+  _ftol = _ftol	@598
+  _fullpath = _fullpath	@599
+  _futime = _futime	@600
+  _gcvt = _gcvt	@601
+  _get_osfhandle = _get_osfhandle	@602
+  _getch = _getch	@603
+  _getche = _getche	@604
+  _getcwd = _getcwd	@605
+  _getdcwd = _getdcwd	@606
+  _getdiskfree = _getdiskfree	@607
+  _getdllprocaddr = _getdllprocaddr	@608
+  _getdrive = _getdrive	@609
+  _getdrives = _getdrives	@610
+  _getmbcp = _getmbcp	@611
+  _getpid = _getpid	@612
+;  _getsystime = _getsystime	@613
+  _getw = _getw	@614
+  _getws = _getws	@615
+  _global_unwind2 = _global_unwind2	@616
+  _heapadd = _heapadd	@617
+  _heapchk = _heapchk	@618
+  _heapmin = _heapmin	@619
+  _heapset = _heapset	@620
+;  _heapused = _heapused	@621
+  _heapwalk = _heapwalk	@622
+  _hypot = _hypot	@623
+  _initterm = _initterm	@624
+  _iob = _iob	@625
+  _isatty = _isatty	@626
+  _isctype = _isctype	@627
+;  _ismbbalnum = _ismbbalnum	@628
+;  _ismbbalpha = _ismbbalpha	@629
+;  _ismbbgraph = _ismbbgraph	@630
+;  _ismbbkalnum = _ismbbkalnum	@631
+  _ismbbkana = _ismbbkana	@632
+;  _ismbbkprint = _ismbbkprint	@633
+;  _ismbbkpunct = _ismbbkpunct	@634
+  _ismbblead = _ismbblead	@635
+;  _ismbbprint = _ismbbprint	@636
+;  _ismbbpunct = _ismbbpunct	@637
+  _ismbbtrail = _ismbbtrail	@638
+  _ismbcalnum = _ismbcalnum	@639
+  _ismbcalpha = _ismbcalpha	@640
+  _ismbcdigit = _ismbcdigit	@641
+  _ismbcgraph = _ismbcgraph	@642
+  _ismbchira = _ismbchira	@643
+  _ismbckata = _ismbckata	@644
+;  _ismbcl0 = _ismbcl0	@645
+;  _ismbcl1 = _ismbcl1	@646
+;  _ismbcl2 = _ismbcl2	@647
+;  _ismbclegal = _ismbclegal	@648
+  _ismbclower = _ismbclower	@649
+  _ismbcprint = _ismbcprint	@650
+  _ismbcpunct = _ismbcpunct	@651
+  _ismbcspace = _ismbcspace	@652
+  _ismbcsymbol = _ismbcsymbol	@653
+  _ismbcupper = _ismbcupper	@654
+  _ismbslead = _ismbslead	@655
+  _ismbstrail = _ismbstrail	@656
+  _isnan = _isnan	@657
+  _itoa = _itoa	@658
+  _itow = _itow	@659
+  _j0 = _j0	@660
+  _j1 = _j1	@661
+  _jn = _jn	@662
+  _kbhit = _kbhit	@663
+  _lfind = _lfind	@664
+  _loaddll = _loaddll	@665
+  _local_unwind2 = _local_unwind2	@666
+  _locking = _locking	@667
+  _logb = _logb	@668
+;  _longjmpex = _longjmpex	@669
+  _lrotl = _lrotl	@670
+  _lrotr = _lrotr	@671
+  _lsearch = _lsearch	@672
+  _lseek = _lseek	@673
+  _ltoa = _ltoa	@674
+  _ltow = _ltow	@675
+  _makepath = _makepath	@676
+  _matherr = _matherr	@677
+  _mbbtombc = _mbbtombc	@678
+;  _mbbtype = _mbbtype	@679
+  _mbccpy = _mbccpy	@680
+;  _mbcjistojms = _mbcjistojms	@681
+;  _mbcjmstojis = _mbcjmstojis	@682
+  _mbclen = _mbclen	@683
+;  _mbctohira = _mbctohira	@684
+;  _mbctokata = _mbctokata	@685
+  _mbctolower = _mbctolower	@686
+;  _mbctombb = _mbctombb	@687
+  _mbctoupper = _mbctoupper	@688
+;  _mbctype = _mbctype	@689
+;  _mbsbtype = _mbsbtype	@690
+  _mbscat = _mbscat	@691
+  _mbschr = _mbschr	@692
+  _mbscmp = _mbscmp	@693
+;  _mbscoll = _mbscoll	@694
+  _mbscpy = _mbscpy	@695
+  _mbscspn = _mbscspn	@696
+  _mbsdec = _mbsdec	@697
+  _mbsdup = _mbsdup	@698
+  _mbsicmp = _mbsicmp	@699
+;  _mbsicoll = _mbsicoll	@700
+  _mbsinc = _mbsinc	@701
+  _mbslen = _mbslen	@702
+  _mbslwr = _mbslwr	@703
+;  _mbsnbcat = _mbsnbcat	@704
+  _mbsnbcmp = _mbsnbcmp	@705
+  _mbsnbcnt = _mbsnbcnt	@706
+;  _mbsnbcoll = _mbsnbcoll	@707
+  _mbsnbcpy = _mbsnbcpy	@708
+  _mbsnbicmp = _mbsnbicmp	@709
+;  _mbsnbicoll = _mbsnbicoll	@710
+;  _mbsnbset = _mbsnbset	@711
+  _mbsncat = _mbsncat	@712
+  _mbsnccnt = _mbsnccnt	@713
+  _mbsncmp = _mbsncmp	@714
+;  _mbsncoll = _mbsncoll	@715
+  _mbsncpy = _mbsncpy	@716
+  _mbsnextc = _mbsnextc	@717
+  _mbsnicmp = _mbsnicmp	@718
+;  _mbsnicoll = _mbsnicoll	@719
+  _mbsninc = _mbsninc	@720
+  _mbsnset = _mbsnset	@721
+  _mbspbrk = _mbspbrk	@722
+  _mbsrchr = _mbsrchr	@723
+  _mbsrev = _mbsrev	@724
+  _mbsset = _mbsset	@725
+  _mbsspn = _mbsspn	@726
+;  _mbsspnp = _mbsspnp	@727
+  _mbsstr = _mbsstr	@728
+;  _mbstok = _mbstok	@729
+  _mbstrlen = _mbstrlen	@730
+  _mbsupr = _mbsupr	@731
+  _memccpy = _memccpy	@732
+  _memicmp = _memicmp	@733
+  _mkdir = _mkdir	@734
+  _mktemp = _mktemp	@735
+  _msize = _msize	@736
+; stub _mtlock	@737
+; stub _mtunlock	@738
+  _nextafter = _nextafter	@739
+  _onexit = _onexit	@740
+  _open = _open	@741
+  _open_osfhandle = _open_osfhandle	@742
+;  _osver = _osver	@743
+;  _pclose = _pclose	@744
+  _pctype = _pctype	@745
+;  _pgmptr = _pgmptr	@746
+;  _pipe = _pipe	@747
+;  _popen = _popen	@748
+  _purecall = _purecall	@749
+  _putch = _putch	@750
+  _putenv = _putenv	@751
+  _putw = _putw	@752
+  _putws = _putws	@753
+;  _pwctype = _pwctype	@754
+  _read = _read	@755
+  _rmdir = _rmdir	@756
+  _rmtmp = _rmtmp	@757
+  _rotl = _rotl	@758
+  _rotr = _rotr	@759
+  _safe_fdiv = _safe_fdiv	@760
+  _safe_fdivr = _safe_fdivr	@761
+  _safe_fprem = _safe_fprem	@762
+  _safe_fprem1 = _safe_fprem1	@763
+  _scalb = _scalb	@764
+  _searchenv = _searchenv	@765
+  __seh_longjmp_unwind = _seh_longjmp_unwind	@766
+;  _seterrormode = _seterrormode	@767
+  _setjmp = _setjmp	@768
+  _setjmp3 = _setjmp3	@769
+  _setmbcp = _setmbcp	@770
+  _setmode = _setmode	@771
+;  _setsystime = _setsystime	@772
+  _sleep = _sleep	@773
+  _snprintf = _snprintf	@774
+  _snwprintf = _snwprintf	@775
+  _sopen = _sopen	@776
+  _spawnl = _spawnl	@777
+;  _spawnle = _spawnle	@778
+  _spawnlp = _spawnlp	@779
+;  _spawnlpe = _spawnlpe	@780
+  _spawnv = _spawnv	@781
+  _spawnve = _spawnve	@782
+  _spawnvp = _spawnvp	@783
+  _spawnvpe = _spawnvpe	@784
+  _splitpath = _splitpath	@785
+  _stat = _stat	@786
+  _statusfp = _statusfp	@787
+  _strcmpi = _strcmpi	@788
+  _strdate = _strdate	@789
+  _strdup = _strdup	@790
+  _strerror = _strerror	@791
+  _stricmp = _stricmp	@792
+;  _stricoll = _stricoll	@793
+  _strlwr = _strlwr	@794
+;  _strncoll = _strncoll	@795
+  _strnicmp = _strnicmp	@796
+;  _strnicoll = _strnicoll	@797
+  _strnset = _strnset	@798
+  _strrev = _strrev	@799
+  _strset = _strset	@800
+  _strtime = _strtime	@801
+  _strupr = _strupr	@802
+  _swab = _swab	@803
+  _sys_errlist = _sys_errlist	@804
+  _sys_nerr = _sys_nerr	@805
+  _tccpy = _mbccpy	@806
+  _tclen = _mbclen	@807
+  _tcschr = _mbschr	@808
+  _tcsclen = _mbslen	@809
+  _tcscmp = _mbscmp	@810
+  _tcscspn = _mbscspn	@811
+  _tcsdec = _mbsdec	@812
+  _tcsicmp = _mbsicmp	@813
+  _tcsinc = _mbsinc	@814
+  _tcslwr = _mbslwr	@815
+  _tcsnbcnt = _mbsnbcnt	@816
+;  _tcsncat = _mbsnbcat	@817
+  _tcsnccat = _mbsncat	@818
+  _tcsnccmp = _mbsncmp	@819
+  _tcsnccnt = _mbsnccnt	@820
+  _tcsnccpy = _mbsncpy	@821
+  _tcsncicmp = _mbsnicmp	@822
+  _tcsncmp = _mbsnbcmp	@823
+  _tcsncpy = _mbsnbcpy	@824
+  _tcsncset = _mbsnset	@825
+  _tcsnextc = _mbsnextc	@826
+  _tcsnicmp = _mbsnbicmp	@827
+  _tcsninc = _mbsninc	@828
+;  _tcsnset = _mbsnbset	@829
+  _tcspbrk = _mbspbrk	@830
+  _tcsrchr = _mbsrchr	@831
+  _tcsrev = _mbsrev	@832
+  _tcsset = _mbsset	@833
+  _tcsspn = _mbsspn	@834
+;  _tcsspnp = _mbsspnp	@835
+  _tcsstr = _mbsstr	@836
+;  _tcstok = _mbstok	@837
+  _tcsupr = _mbsupr	@838
+  _tell = _tell	@839
+  _tempnam = _tempnam	@840
+;  _timezone = _timezone	@841
+  _tolower = _tolower	@842
+  _toupper = _toupper	@843
+;  _tzname = _tzname	@844
+  _tzset = _tzset	@845
+  _ultoa = _ultoa	@846
+  _ultow = _ultow	@847
+  _umask = _umask	@848
+  _ungetch = _ungetch	@849
+  _unlink = _unlink	@850
+  _unloaddll = _unloaddll	@851
+  _utime = _utime	@852
+  _vsnprintf = _vsnprintf	@853
+  _vsnwprintf = _vsnwprintf	@854
+  _waccess = _waccess	@855
+;  _wasctime = _wasctime	@856
+  _wchdir = _wchdir	@857
+  _wchmod = _wchmod	@858
+  _wcmdln = _wcmdln	@859
+  _wcreat = _wcreat	@860
+  _wcsdup = _wcsdup	@861
+;  _wcsicmp = _wcsicmp	@862
+  _wcsicoll = _wcsicoll	@863
+  _wcslwr = _wcslwr	@864
+;  _wcsncoll = _wcsncoll	@865
+  _wcsnicmp = _wcsnicmp	@866
+;  _wcsnicoll = _wcsnicoll	@867
+  _wcsnset = _wcsnset	@868
+  _wcsrev = _wcsrev	@869
+  _wcsset = _wcsset	@870
+;  _wcsupr = _wcsupr	@871
+;  _wctime = _wctime	@872
+  _wenviron = _wenviron	@873
+;  _wexecl = _wexecl	@874
+;  _wexecle = _wexecle	@875
+;  _wexeclp = _wexeclp	@876
+;  _wexeclpe = _wexeclpe	@877
+;  _wexecv = _wexecv	@878
+;  _wexecve = _wexecve	@879
+;  _wexecvp = _wexecvp	@880
+;  _wexecvpe = _wexecvpe	@881
+  _wfdopen = _wfdopen	@882
+  _wfindfirst = _wfindfirst	@883
+  _wfindnext = _wfindnext	@884
+  _wfopen = _wfopen	@885
+;  _wfreopen = _wfreopen	@886
+  _wfsopen = _wfsopen	@887
+;  _wfullpath = _wfullpath	@888
+  _wgetcwd = _wgetcwd	@889
+  _wgetdcwd = _wgetdcwd	@890
+  _wgetenv = _wgetenv	@891
+  _winmajor = _winmajor	@892
+  _winminor = _winminor	@893
+  _winver = _winver	@894
+  _wmakepath = _wmakepath	@895
+  _wmkdir = _wmkdir	@896
+  _wmktemp = _wmktemp	@897
+  _wopen = _wopen	@898
+;  _wperror = _wperror	@899
+;  _wpgmptr = _wpgmptr	@900
+;  _wpopen = _wpopen	@901
+  _wputenv = _wputenv	@902
+  _wremove = _wremove	@903
+  _wrename = _wrename	@904
+  _write = _write	@905
+  _wrmdir = _wrmdir	@906
+;  _wsearchenv = _wsearchenv	@907
+;  _wsetlocale = _wsetlocale	@908
+  _wsopen = _wsopen	@909
+;  _wspawnl = _wspawnl	@910
+;  _wspawnle = _wspawnle	@911
+;  _wspawnlp = _wspawnlp	@912
+;  _wspawnlpe = _wspawnlpe	@913
+;  _wspawnv = _wspawnv	@914
+;  _wspawnve = _wspawnve	@915
+;  _wspawnvp = _wspawnvp	@916
+;  _wspawnvpe = _wspawnvpe	@917
+  _wsplitpath = _wsplitpath	@918
+  _wstat = _wstat	@919
+;  _wstrdate = _wstrdate	@920
+;  _wstrtime = _wstrtime	@921
+;  _wsystem = _wsystem	@922
+  _wtempnam = _wtempnam	@923
+;  _wtmpnam = _wtmpnam	@924
+  _wtoi = _wtoi	@925
+  _wtol = _wtol	@926
+  _wunlink = _wunlink	@927
+  _wutime = _wutime	@928
+  _y0 = _y0	@929
+  _y1 = _y1	@930
+  _yn = _yn	@931
+  abort = abort	@932
+  abs = abs	@933
+  acos = acos	@934
+  asctime = asctime	@935
+  asin = asin	@936
+  atan = atan	@937
+  atan2 = atan2	@938
+  atexit = atexit	@939
+  atof = atof	@940
+  atoi = atoi	@941
+  atol = atol	@942
+  bsearch = bsearch	@943
+  calloc = calloc	@944
+  ceil = ceil	@945
+  clearerr = clearerr	@946
+  clock = clock	@947
+  cos = cos	@948
+  cosh = cosh	@949
+  ctime = ctime	@950
+  difftime = difftime	@951
+  div = div	@952
+  exit = exit	@953
+  exp = exp	@954
+  fabs = fabs	@955
+  fclose = fclose	@956
+  feof = feof	@957
+  ferror = ferror	@958
+  fflush = fflush	@959
+  fgetc = fgetc	@960
+  fgetpos = fgetpos	@961
+  fgets = fgets	@962
+  fgetwc = fgetwc	@963
+  fgetws = fgetws	@964
+  floor = floor	@965
+  fmod = fmod	@966
+  fopen = fopen	@967
+  fprintf = fprintf	@968
+  fputc = fputc	@969
+  fputs = fputs	@970
+  fputwc = fputwc	@971
+  fputws = fputws	@972
+  fread = fread	@973
+  free = free	@974
+  freopen = freopen	@975
+  frexp = frexp	@976
+  fscanf = fscanf	@977
+  fseek = fseek	@978
+  fsetpos = fsetpos	@979
+  ftell = ftell	@980
+  fwprintf = fwprintf	@981
+  fwrite = fwrite	@982
+;  fwscanf = fwscanf	@983
+  getc = getc	@984
+  getchar = getchar	@985
+  getenv = getenv	@986
+  gets = gets	@987
+  getwc = getwc	@988
+  getwchar = getwchar	@989
+  gmtime = gmtime	@990
+  is_wctype = is_wctype	@991
+  isalnum = isalnum	@992
+  isalpha = isalpha	@993
+  iscntrl = iscntrl	@994
+  isdigit = isdigit	@995
+  isgraph = isgraph	@996
+  isleadbyte = isleadbyte	@997
+  islower = islower	@998
+  isprint = isprint	@999
+  ispunct = ispunct	@1000
+  isspace = isspace	@1001
+  isupper = isupper	@1002
+  iswalnum = iswalnum	@1003
+  iswalpha = iswalpha	@1004
+  iswascii = iswascii	@1005
+  iswcntrl = iswcntrl	@1006
+  iswctype = iswctype	@1007
+  iswdigit = iswdigit	@1008
+  iswgraph = iswgraph	@1009
+  iswlower = iswlower	@1010
+  iswprint = iswprint	@1011
+  iswpunct = iswpunct	@1012
+  iswspace = iswspace	@1013
+  iswupper = iswupper	@1014
+  iswxdigit = iswxdigit	@1015
+  isxdigit = isxdigit	@1016
+  labs = labs	@1017
+  ldexp = ldexp	@1018
+  ldiv = ldiv	@1019
+;  localeconv = localeconv	@1020
+  localtime = localtime	@1021
+  log = log	@1022
+  log10 = log10	@1023
+  longjmp = longjmp	@1024
+  malloc = malloc	@1025
+  mblen = mblen	@1026
+  mbstowcs = mbstowcs	@1027
+  mbtowc = mbtowc	@1028
+  memchr = memchr	@1029
+  memcmp = memcmp	@1030
+  memcpy = memcpy	@1031
+  memmove = memmove	@1032
+  memset = memset	@1033
+  mktime = mktime	@1034
+  modf = modf	@1035
+  perror = perror	@1036
+  pow = pow	@1037
+  printf = printf	@1038
+  putc = putc	@1039
+  putchar = putchar	@1040
+  puts = puts	@1041
+  putwc = putwc	@1042
+  putwchar = putwchar	@1043
+  qsort = qsort	@1044
+;  raise = raise	@1045
+  rand = rand	@1046
+  realloc = realloc	@1047
+  remove = remove	@1048
+  rename = rename	@1049
+  rewind = rewind	@1050
+  scanf = scanf	@1051
+  setbuf = setbuf	@1052
+  setlocale = setlocale	@1053
+  setvbuf = setvbuf	@1054
+  signal = signal	@1055
+  sin = sin	@1056
+  sinh = sinh	@1057
+  sprintf = sprintf	@1058
+  sqrt = sqrt	@1059
+  srand = srand	@1060
+  sscanf = sscanf	@1061
+  strcat = strcat	@1062
+  strchr = strchr	@1063
+  strcmp = strcmp	@1064
+  strcoll = strcoll	@1065
+  strcpy = strcpy	@1066
+  strcspn = strcspn	@1067
+  strerror = strerror	@1068
+  strftime = strftime	@1069
+  strlen = strlen	@1070
+  strncat = strncat	@1071
+  strncmp = strncmp	@1072
+  strncpy = strncpy	@1073
+  strpbrk = strpbrk	@1074
+  strrchr = strrchr	@1075
+  strspn = strspn	@1076
+  strstr = strstr	@1077
+  strtod = strtod	@1078
+  strtok = strtok	@1079
+  strtol = strtol	@1080
+  strtoul = strtoul	@1081
+  strxfrm = strxfrm	@1082
+  swprintf = swprintf	@1083
+;  swscanf = swscanf	@1084
+  system = system	@1085
+  tan = tan	@1086
+  tanh = tanh	@1087
+  time = time	@1088
+  tmpfile = tmpfile	@1089
+  tmpnam = tmpnam	@1090
+  tolower = tolower	@1091
+  toupper = toupper	@1092
+  towlower = towlower	@1093
+  towupper = towupper	@1094
+  ungetc = ungetc	@1095
+  ungetwc = ungetwc	@1096
+  vfprintf = vfprintf	@1097
+  vfwprintf = vfwprintf	@1098
+  vprintf = vprintf	@1099
+  vsprintf = vsprintf	@1100
+  vswprintf = vswprintf	@1101
+  vwprintf = vwprintf	@1102
+  wcscat = wcscat	@1103
+  wcschr = wcschr	@1104
+  wcscmp = wcscmp	@1105
+  wcscoll = wcscoll	@1106
+  wcscpy = wcscpy	@1107
+  wcscspn = wcscspn	@1108
+;  wcsftime = wcsftime	@1109
+  wcslen = wcslen	@1110
+  wcsncat = wcsncat	@1111
+  wcsncmp = wcsncmp	@1112
+  wcsncpy = wcsncpy	@1113
+  wcspbrk = wcspbrk	@1114
+  wcsrchr = wcsrchr	@1115
+  wcsspn = wcsspn	@1116
+  wcsstr = wcsstr	@1117
+;  wcstod = wcstod	@1118
+  wcstok = wcstok	@1119
+  wcstol = wcstol	@1120
+  wcstombs = wcstombs	@1121
+  wcstoul = wcstoul	@1122
+;  wcsxfrm = wcsxfrm	@1123
+  wctomb = wctomb	@1124
+  wprintf = wprintf	@1125
+;  wscanf = wscanf	@1126
+;  wscanf = wscan	@1127
Index: trunk/src/msvcrt/msvcrt40.mak
===================================================================
--- trunk/src/msvcrt/msvcrt40.mak	(revision 9633)
+++ trunk/src/msvcrt/msvcrt40.mak	(revision 9633)
@@ -0,0 +1,58 @@
+# $Id: msvcrt40.mak,v 1.5 2003-01-06 13:26:38 sandervl Exp $
+
+#
+# Odin32 API
+#
+#       msvcrt.dll makefile
+#
+
+
+#
+# Tell buildenvironment that we have a non-default makefilename.
+#
+MAKEFILE = msvcrt40.mak
+CCENV = EMX
+NOTEXPDEF = 1
+
+#
+# Compiler, tools, and interference rules.
+#
+!include ../../makefile.inc
+
+!ifndef WMAKE
+CDEFINES    = -I. $(CDEFINES) -DUSE_MSVCRT_PREFIX -D_MT -I$(ODIN32_INCLUDE)\win\msvcrt 
+!else
+CDEFINES   += -DUSE_MSVCRT_PREFIX -D_MT -I$(ODIN32_INCLUDE)\win\msvcrt
+!endif
+
+#
+# Object files. Prefix with OBJDIR and one space before the '\'.
+#
+OBJS = \
+$(OBJDIR)\mainmsvcrt40.obj \
+$(OBJDIR)\$(TARGET)rsrc.obj 
+
+#
+# Target name - name of the dll without extention and path.
+#
+TARGET = msvcrt40
+
+all: $(OBJDIR) $(OBJDIR)\$(TARGET).dll $(TARGET).lib
+
+$(OBJDIR)\$(TARGET).dll: $(OBJS) $(TARGET).def
+    $(LD) $(LDFLAGS) -Zso -Zsys $(OBJS) $(TARGET).def -L.\libs -lm\
+      -L$(OBJDIR) -liberty_s -lmsvcrt -o $(OBJDIR)\$(TARGET).dll
+    touch $(OBJDIR)\$(TARGET).map
+    @echo "Illegal Sym File for EMX" > $(OBJDIR)\$(TARGET).sym
+
+$(TARGET).lib: 
+    implib $(OBJDIR)\$(TARGET).lib msvcrt40.def
+    @copy $(OBJDIR)\$(TARGET).lib $(ODIN32_LIB_)\Release
+    @copy $(OBJDIR)\$(TARGET).lib $(ODIN32_LIB_)\Debug
+
+
+#
+# Includes the common rules.
+#
+!include $(ODIN32_POST_INC)
+
Index: trunk/src/msvcrt/msvcrt40rsrc.orc
===================================================================
--- trunk/src/msvcrt/msvcrt40rsrc.orc	(revision 9633)
+++ trunk/src/msvcrt/msvcrt40rsrc.orc	(revision 9633)
@@ -0,0 +1,40 @@
+/* $Id: msvcrt40rsrc.orc,v 1.3 2003-01-06 13:26:39 sandervl Exp $ */
+
+#include "winuser.h"
+#include "odinrsrc.h"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version (MSVCRT40.DLL from Win98SE)
+//
+
+1 VERSIONINFO
+ FILEVERSION ODIN_FILEVERSION
+ PRODUCTVERSION ODIN_PRODUCTVERSION
+ FILEFLAGSMASK 0x3fL
+ FILEFLAGS 0xaL
+ FILEOS 0x10001L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "040904E4"
+        BEGIN
+            VALUE "Comments", "Odin32 System Dll\0"
+            VALUE "CompanyName", "Odin Team\0"
+            VALUE "FileDescription", "C/C++ Runtime library\0"
+            VALUE "FileVersion", "4.22\0"
+            VALUE "InternalName", "MSVCRT40\0"
+            VALUE "LegalCopyright", "Copyright (C) 1999\0"
+            VALUE "LegalTrademarks", "\0"
+            VALUE "OriginalFilename", "MSVCRT40.DLL\0"
+            VALUE "ProductName", "Odin32 - MSVCRT40\0"
+            VALUE "ProductVersion", "4.22.0000\0"
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+	VALUE "Translation", 0x409, 0x04E4
+    END
+END
Index: trunk/src/msvcrt/msvcrtrsrc.orc
===================================================================
--- trunk/src/msvcrt/msvcrtrsrc.orc	(revision 9633)
+++ trunk/src/msvcrt/msvcrtrsrc.orc	(revision 9633)
@@ -0,0 +1,40 @@
+/* $Id: msvcrtrsrc.orc,v 1.3 2003-01-06 13:26:39 sandervl Exp $ */
+
+#include "winuser.h"
+#include "odinrsrc.h"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version (MSVCRT.DLL from NT 4, SP3)
+//
+
+1 VERSIONINFO
+ FILEVERSION ODIN_FILEVERSION
+ PRODUCTVERSION ODIN_PRODUCTVERSION
+ FILEFLAGSMASK 0x3fL
+ FILEFLAGS 0xaL
+ FILEOS 0x10001L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "040904E4"
+        BEGIN
+            VALUE "Comments", "Odin32 System Dll\0"
+            VALUE "CompanyName", "Odin Team\0"
+            VALUE "FileDescription", "C/C++ Runtime library\0"
+            VALUE "FileVersion", "6.00.8397.0\0"
+            VALUE "InternalName", "MSVCRT\0"
+            VALUE "LegalCopyright", "Copyright (C) 1999\0"
+            VALUE "LegalTrademarks", "\0"
+            VALUE "OriginalFilename", "MSVCRT.DLL\0"
+            VALUE "ProductName", "Odin32 - MSVCRT\0"
+            VALUE "ProductVersion", "6.00.8397.0\0"
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+	VALUE "Translation", 0x409, 0x04E4
+    END
+END
Index: trunk/src/msvcrt/mtdll.h
===================================================================
--- trunk/src/msvcrt/mtdll.h	(revision 9633)
+++ trunk/src/msvcrt/mtdll.h	(revision 9633)
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2002, TransGaming Technologies Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef WINE_MTDLL_H
+#define WINE_MTDLL_H
+
+#if defined(_MT)
+
+#define _mlock(locknum)   _lock(locknum)
+#define _munlock(locknum) _unlock(locknum)
+
+void _unlock( int locknum );
+void _lock( int locknum );
+
+#else
+
+#define _mlock(locknum)   do {} while(0)
+#define _munlock(locknum) do {} while(0)
+
+#endif
+
+
+#define _SIGNAL_LOCK    1
+#define _IOB_SCAN_LOCK  2
+#define _TMPNAM_LOCK    3
+#define _INPUT_LOCK     4
+#define _OUTPUT_LOCK    5
+#define _CSCANF_LOCK    6
+#define _CPRINTF_LOCK   7
+#define _CONIO_LOCK     8
+#define _HEAP_LOCK      9
+#define _BHEAP_LOCK          10 /* No longer used? */
+#define _TIME_LOCK      11
+#define _ENV_LOCK       12
+#define _EXIT_LOCK1     13
+#define _EXIT_LOCK2          14 /* No longer used? */
+#define _THREADDATA_LOCK     15 /* No longer used? */
+#define _POPEN_LOCK     16
+#define _LOCKTAB_LOCK   17
+#define _OSFHND_LOCK    18
+#define _SETLOCALE_LOCK 19
+#define _LC_COLLATE_LOCK     20 /* No longer used? */
+#define _LC_CTYPE_LOCK       21 /* No longer used? */
+#define _LC_MONETARY_LOCK    22 /* No longer used? */
+#define _LC_NUMERIC_LOCK     23 /* No longer used? */
+#define _LC_TIME_LOCK        24 /* No longer used? */
+#define _MB_CP_LOCK     25
+#define _NLG_LOCK       26
+#define _TYPEINFO_LOCK  27
+#define _STREAM_LOCKS   28
+
+/* Must match definition in msvcrt/stdio.h */
+#define _IOB_ENTRIES    20
+
+#define _LAST_STREAM_LOCK  (_STREAM_LOCKS+_IOB_ENTRIES-1)
+
+#define _TOTAL_LOCKS        (_LAST_STREAM_LOCK+1)
+
+#endif /* WINE_MTDLL_H */
Index: trunk/src/msvcrt/process.c
===================================================================
--- trunk/src/msvcrt/process.c	(revision 9633)
+++ trunk/src/msvcrt/process.c	(revision 9633)
@@ -0,0 +1,478 @@
+/*
+ * msvcrt.dll spawn/exec functions
+ *
+ * Copyright 1996,1998 Marcus Meissner
+ * Copyright 1996 Jukka Iivonen
+ * Copyright 1997,2000 Uwe Bonnes
+ * Copyright 2000 Jon Griffiths
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * FIXME:
+ * -File handles need some special handling. Sometimes children get
+ *  open file handles, sometimes not. The docs are confusing
+ * -No check for maximum path/argument/environment size is done
+ */
+#ifdef __WIN32OS2__
+#include <emxheader.h>
+#else
+#include "config.h"
+#endif
+
+#include <stdarg.h>
+
+#include "msvcrt.h"
+#include "msvcrt/errno.h"
+
+#include "msvcrt/process.h"
+#include "msvcrt/stdlib.h"
+#include "msvcrt/string.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
+
+/* FIXME: Check file extensions for app to run */
+static const unsigned int EXE = 'e' << 16 | 'x' << 8 | 'e';
+static const unsigned int BAT = 'b' << 16 | 'a' << 8 | 't';
+static const unsigned int CMD = 'c' << 16 | 'm' << 8 | 'd';
+static const unsigned int COM = 'c' << 16 | 'o' << 8 | 'm';
+
+/* INTERNAL: Spawn a child process */
+static int msvcrt_spawn(int flags, const char* exe, char* cmdline, char* env)
+{
+  STARTUPINFOA si;
+  PROCESS_INFORMATION pi;
+
+  if (sizeof(HANDLE) != sizeof(int))
+    WARN("This call is unsuitable for your architecture\n");
+
+  if ((unsigned)flags > _P_DETACH)
+  {
+    *MSVCRT__errno() = MSVCRT_EINVAL;
+    return -1;
+  }
+
+  FIXME(":must dup/kill streams for child process\n");
+
+  memset(&si, 0, sizeof(si));
+  si.cb = sizeof(si);
+
+  if (!CreateProcessA(exe, cmdline, NULL, NULL, TRUE,
+                     flags == _P_DETACH ? DETACHED_PROCESS : 0,
+                     env, NULL, &si, &pi))
+  {
+    MSVCRT__set_errno(GetLastError());
+    return -1;
+  }
+
+  switch(flags)
+  {
+  case _P_WAIT:
+    WaitForSingleObject(pi.hProcess,-1); /* wait forvever */
+    GetExitCodeProcess(pi.hProcess,&pi.dwProcessId);
+    CloseHandle(pi.hProcess);
+    CloseHandle(pi.hThread);
+    return (int)pi.dwProcessId;
+  case _P_DETACH:
+    CloseHandle(pi.hProcess);
+    pi.hProcess = 0;
+    /* fall through */
+  case _P_NOWAIT:
+  case _P_NOWAITO:
+    CloseHandle(pi.hThread);
+    return (int)pi.hProcess;
+  case  _P_OVERLAY:
+    MSVCRT__exit(0);
+  }
+  return -1; /* can't reach here */
+}
+
+/* INTERNAL: Convert argv list to a single 'delim'-separated string, with an
+ * extra '\0' to terminate it
+ */
+static char* msvcrt_argvtos(const char* const* arg, char delim)
+{
+  const char* const* a;
+  long size;
+  char* p;
+  char* ret;
+
+  if (!arg && !delim)
+  {
+      /* Return NULL for an empty environment list */
+      return NULL;
+  }
+
+  /* get length */
+  a = arg;
+  size = 0;
+  while (*a)
+  {
+    size += strlen(*a) + 1;
+    a++;
+  }
+
+  ret = (char*)MSVCRT_malloc(size + 1);
+  if (!ret)
+    return NULL;
+
+  /* fill string */
+  a = arg;
+  p = ret;
+  while (*a)
+  {
+    int len = strlen(*a);
+    memcpy(p,*a,len);
+    p += len;
+    *p++ = delim;
+    a++;
+  }
+  if (delim && p > ret) p[-1] = 0;
+  else *p = 0;
+  return ret;
+}
+
+/* INTERNAL: Convert va_list to a single 'delim'-separated string, with an
+ * extra '\0' to terminate it
+ */
+static char* msvcrt_valisttos(const char* arg0, va_list alist, char delim)
+{
+  va_list alist2;
+  long size;
+  const char *arg;
+  char* p;
+  char *ret;
+
+#if HAVE_VA_COPY
+  va_copy(alist2,alist);
+#else
+# if HAVE___VA_COPY
+  __va_copy(alist2,alist);
+# else
+  alist2 = alist;
+# endif
+#endif
+
+  if (!arg0 && !delim)
+  {
+      /* Return NULL for an empty environment list */
+      return NULL;
+  }
+
+  /* get length */
+  arg = arg0;
+  size = 0;
+  do {
+      size += strlen(arg) + 1;
+      arg = va_arg(alist, char*);
+  } while (arg != NULL);
+
+  ret = (char*)MSVCRT_malloc(size + 1);
+  if (!ret)
+    return NULL;
+
+  /* fill string */
+  arg = arg0;
+  p = ret;
+  do {
+      int len = strlen(arg);
+      memcpy(p,arg,len);
+      p += len;
+      *p++ = delim;
+      arg = va_arg(alist2, char*);
+  } while (arg != NULL);
+  if (delim && p > ret) p[-1] = 0;
+  else *p = 0;
+  return ret;
+}
+
+/*********************************************************************
+ *		_cwait (MSVCRT.@)
+ */
+int _cwait(int *status, int pid, int action)
+{
+  HANDLE hPid = (HANDLE)pid;
+  int doserrno;
+
+  action = action; /* Remove warning */
+
+  if (!WaitForSingleObject(hPid, -1)) /* wait forever */
+  {
+    if (status)
+    {
+      DWORD stat;
+      GetExitCodeProcess(hPid, &stat);
+      *status = (int)stat;
+    }
+    return (int)pid;
+  }
+  doserrno = GetLastError();
+
+  if (doserrno == ERROR_INVALID_HANDLE)
+  {
+    *MSVCRT__errno() =  MSVCRT_ECHILD;
+    *__doserrno() = doserrno;
+  }
+  else
+    MSVCRT__set_errno(doserrno);
+
+  return status ? *status = -1 : -1;
+}
+
+/*********************************************************************
+ *		_execl (MSVCRT.@)
+ *
+ * Like on Windows, this function does not handle arguments with spaces
+ * or double-quotes.
+ */
+int _execl(const char* name, const char* arg0, ...)
+{
+  va_list ap;
+  char * args;
+  int ret;
+
+  va_start(ap, arg0);
+  args = msvcrt_valisttos(arg0, ap, ' ');
+  va_end(ap);
+
+  ret = msvcrt_spawn(_P_OVERLAY, name, args, NULL);
+  MSVCRT_free(args);
+
+  return ret;
+}
+
+/*********************************************************************
+ *		_execlp (MSVCRT.@)
+ *
+ * Like on Windows, this function does not handle arguments with spaces
+ * or double-quotes.
+ */
+int _execlp(const char* name, const char* arg0, ...)
+{
+  va_list ap;
+  char * args;
+  int ret;
+  char fullname[MAX_PATH];
+
+  _searchenv(name, "PATH", fullname);
+
+  va_start(ap, arg0);
+  args = msvcrt_valisttos(arg0, ap, ' ');
+  va_end(ap);
+
+  ret = msvcrt_spawn(_P_OVERLAY, fullname[0] ? fullname : name, args, NULL);
+  MSVCRT_free(args);
+
+  return ret;
+}
+
+/*********************************************************************
+ *		_execv (MSVCRT.@)
+ *
+ * Like on Windows, this function does not handle arguments with spaces
+ * or double-quotes.
+ */
+int _execv(const char* name, char* const* argv)
+{
+  return _spawnve(_P_OVERLAY, name, (const char* const*) argv, NULL);
+}
+
+/*********************************************************************
+ *		_execve (MSVCRT.@)
+ *
+ * Like on Windows, this function does not handle arguments with spaces
+ * or double-quotes.
+ */
+int _execve(const char* name, char* const* argv, const char* const* envv)
+{
+  return _spawnve(_P_OVERLAY, name, (const char* const*) argv, envv);
+}
+
+/*********************************************************************
+ *		_execvpe (MSVCRT.@)
+ *
+ * Like on Windows, this function does not handle arguments with spaces
+ * or double-quotes.
+ */
+int _execvpe(const char* name, char* const* argv, const char* const* envv)
+{
+  char fullname[MAX_PATH];
+
+  _searchenv(name, "PATH", fullname);
+  return _spawnve(_P_OVERLAY, fullname[0] ? fullname : name,
+                  (const char* const*) argv, envv);
+}
+
+/*********************************************************************
+ *		_execvp (MSVCRT.@)
+ *
+ * Like on Windows, this function does not handle arguments with spaces
+ * or double-quotes.
+ */
+int _execvp(const char* name, char* const* argv)
+{
+  return _execvpe(name, argv, NULL);
+}
+
+/*********************************************************************
+ *		_spawnl (MSVCRT.@)
+ *
+ * Like on Windows, this function does not handle arguments with spaces
+ * or double-quotes.
+ */
+int _spawnl(int flags, const char* name, const char* arg0, ...)
+{
+  va_list ap;
+  char * args;
+  int ret;
+
+  va_start(ap, arg0);
+  args = msvcrt_valisttos(arg0, ap, ' ');
+  va_end(ap);
+
+  ret = msvcrt_spawn(flags, name, args, NULL);
+  MSVCRT_free(args);
+
+  return ret;
+}
+
+/*********************************************************************
+ *		_spawnlp (MSVCRT.@)
+ *
+ * Like on Windows, this function does not handle arguments with spaces
+ * or double-quotes.
+ */
+int _spawnlp(int flags, const char* name, const char* arg0, ...)
+{
+  va_list ap;
+  char * args;
+  int ret;
+  char fullname[MAX_PATH];
+
+  _searchenv(name, "PATH", fullname);
+
+  va_start(ap, arg0);
+  args = msvcrt_valisttos(arg0, ap, ' ');
+  va_end(ap);
+
+  ret = msvcrt_spawn(flags, fullname[0] ? fullname : name, args, NULL);
+  MSVCRT_free(args);
+
+  return ret;
+}
+
+/*********************************************************************
+ *		_spawnve (MSVCRT.@)
+ *
+ * Like on Windows, this function does not handle arguments with spaces
+ * or double-quotes.
+ */
+int _spawnve(int flags, const char* name, const char* const* argv,
+                            const char* const* envv)
+{
+  char * args = msvcrt_argvtos(argv,' ');
+  char * envs = msvcrt_argvtos(envv,0);
+  const char *fullname = name;
+  int ret = -1;
+
+  FIXME(":not translating name %s to locate program\n",fullname);
+  TRACE(":call (%s), params (%s), env (%s)\n",name,args,envs?"Custom":"Null");
+
+  if (args)
+  {
+    ret = msvcrt_spawn(flags, fullname, args, envs);
+    MSVCRT_free(args);
+  }
+  if (envs)
+    MSVCRT_free(envs);
+
+  return ret;
+}
+
+/*********************************************************************
+ *		_spawnv (MSVCRT.@)
+ *
+ * Like on Windows, this function does not handle arguments with spaces
+ * or double-quotes.
+ */
+int _spawnv(int flags, const char* name, const char* const* argv)
+{
+  return _spawnve(flags, name, argv, NULL);
+}
+
+/*********************************************************************
+ *		_spawnvpe (MSVCRT.@)
+ *
+ * Like on Windows, this function does not handle arguments with spaces
+ * or double-quotes.
+ */
+int _spawnvpe(int flags, const char* name, const char* const* argv,
+                            const char* const* envv)
+{
+  char fullname[MAX_PATH];
+  _searchenv(name, "PATH", fullname);
+  return _spawnve(flags, fullname[0] ? fullname : name, argv, envv);
+}
+
+/*********************************************************************
+ *		_spawnvp (MSVCRT.@)
+ *
+ * Like on Windows, this function does not handle arguments with spaces
+ * or double-quotes.
+ */
+int _spawnvp(int flags, const char* name, const char* const* argv)
+{
+  return _spawnvpe(flags, name, argv, NULL);
+}
+
+/*********************************************************************
+ *		system (MSVCRT.@)
+ */
+int MSVCRT_system(const char* cmd)
+{
+    char* cmdcopy;
+    int res;
+
+    /* Make a writable copy for CreateProcess */
+    cmdcopy=_strdup(cmd);
+    /* FIXME: should probably launch cmd interpreter in COMSPEC */
+    res=msvcrt_spawn(_P_WAIT, NULL, cmdcopy, NULL);
+    MSVCRT_free(cmdcopy);
+    return res;
+}
+
+/*********************************************************************
+ *		_loaddll (MSVCRT.@)
+ */
+int _loaddll(const char* dllname)
+{
+  return (int)LoadLibraryA(dllname);
+}
+
+/*********************************************************************
+ *		_unloaddll (MSVCRT.@)
+ */
+int _unloaddll(int dll)
+{
+  if (FreeLibrary((HMODULE)dll))
+    return 0;
+  else
+  {
+    int err = GetLastError();
+    MSVCRT__set_errno(err);
+    return err;
+  }
+}
Index: trunk/src/msvcrt/relay2.S
===================================================================
--- trunk/src/msvcrt/relay2.S	(revision 9633)
+++ trunk/src/msvcrt/relay2.S	(revision 9633)
@@ -0,0 +1,82 @@
+/* File generated automatically. Do not edit! */
+
+	.text
+
+	.align 4
+	.stabs "__wine_call_from_32_regs:F1",36,0,0,___wine_call_from_32_regs
+	.type ___wine_call_from_32_regs,@function
+	.globl ___wine_call_from_32_regs
+___wine_call_from_32_regs:
+	pushl %ebp
+	movl %esp,%ebp
+ 	leal -332(%esp), %esp
+	movl %eax,-156(%ebp)
+	pushfl
+	popl %eax
+	movl %eax,-140(%ebp)
+	movl 0(%ebp),%eax
+	movl %eax,-152(%ebp)
+	movl %ebx,-168(%ebp)
+	movl %ecx,-160(%ebp)
+	movl %edx,-164(%ebp)
+	movl %esi,-172(%ebp)
+	movl %edi,-176(%ebp)
+	xorl %eax,%eax
+	movw %cs,%ax
+	movl %eax,-144(%ebp)
+	movw %es,%ax
+	movl %eax,-184(%ebp)
+	movw %fs,%ax
+	movl %eax,-188(%ebp)
+	movw %gs,%ax
+	movl %eax,-192(%ebp)
+	movw %ss,%ax
+	movl %eax,-132(%ebp)
+	movw %ds,%ax
+	movl %eax,-180(%ebp)
+	movw %ax,%es
+	movl $0x10007,%eax
+	movl %eax,-332(%ebp)
+	movl 8(%ebp),%eax
+	movl %eax,-148(%ebp)
+	movl 4(%ebp),%ebx
+	pushl %esp
+	movzbl 4(%ebx),%ecx
+	jecxz 1f
+	subl %ecx,%esp
+	leal 12(%ebp),%esi
+	movl %esp,%edi
+	shrl $2,%ecx
+	cld
+	rep
+	movsl
+1:	movzbl 5(%ebx),%eax
+	leal 12(%ebp,%eax),%eax
+	movl %eax,-136(%ebp)
+	call *0(%ebx)
+	movl -136(%ebp),%edx
+	movl -148(%ebp),%eax
+	movl %eax,-4(%edx)
+	movl -152(%ebp),%eax
+	movl %eax,-8(%edx)
+	movl -184(%ebp),%eax
+	movw %ax,%es
+	movl -188(%ebp),%eax
+	movw %ax,%fs
+	movl -192(%ebp),%eax
+	movw %ax,%gs
+	movl -176(%ebp),%edi
+	movl -172(%ebp),%esi
+	movl -164(%ebp),%edx
+	movl -160(%ebp),%ecx
+	movl -168(%ebp),%ebx
+	movl -140(%ebp),%eax
+	pushl %eax
+	popfl
+	movl -156(%ebp),%eax
+	movl -136(%ebp),%ebp
+        leal -8(%ebp),%esp
+	popl %ebp
+	ret
+	.stabs "",100,0,0,.Letext
+.Letext:
Index: trunk/src/msvcrt/rtlbitmap.c
===================================================================
--- trunk/src/msvcrt/rtlbitmap.c	(revision 9633)
+++ trunk/src/msvcrt/rtlbitmap.c	(revision 9633)
@@ -0,0 +1,1078 @@
+/*
+ * NTDLL bitmap functions
+ *
+ * Copyright 2002 Jon Griffiths
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * NOTES
+ *  Bitmaps are an efficient type for manipulating large arrays of bits. They
+ *  are commonly used by device drivers (e.g. For holding dirty/free blocks),
+ *  but are also available to applications that need this functionality.
+ *
+ *  Bits are set LSB to MSB in each consecutive byte, making this implementation
+ *  binary compatable with Win32.
+ *
+ *  Note that to avoid unexpected behaviour, the size of a bitmap should be set
+ *  to a multiple of 32.
+
+ */
+#include <winbase.h>
+#include "winternl.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
+
+/* Bits set from LSB to MSB; used as mask for runs < 8 bits */
+static const BYTE NTDLL_maskBits[8] = { 0, 1, 3, 7, 15, 31, 63, 127 };
+
+/* Number of set bits for each value of a nibble; used for counting */
+static const BYTE NTDLL_nibbleBitCount[16] = {
+  0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4
+};
+
+/* First set bit in a nibble; used for determining least significant bit */
+static const BYTE NTDLL_leastSignificant[16] = {
+  0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
+};
+
+/* Last set bit in a nibble; used for determining most significant bit */
+static const BYTE NTDLL_mostSignificant[16] = {
+  0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3
+};
+
+/*************************************************************************
+ * RtlInitializeBitMap	[NTDLL.@]
+ *
+ * Initialise a new bitmap.
+ *
+ * PARAMS
+ *  lpBits [I] Bitmap pointer
+ *  lpBuff [I] Memory for the bitmap
+ *  ulSize [I] Size of lpBuff in bits
+ *
+ * RETURNS
+ *  Nothing.
+ *
+ * NOTES
+ *  lpBuff must be aligned on a ULONG suitable boundary, to a multiple of 32 bytes
+ *  in size (irrespective of ulSize given).
+ */
+#undef RtlInitializeBitMap
+VOID WINAPI RtlInitializeBitMap(PRTL_BITMAP lpBits, LPBYTE lpBuff, ULONG ulSize)
+{
+  TRACE("(%p,%p,%ld)\n", lpBits,lpBuff,ulSize);
+  lpBits->SizeOfBitMap = ulSize;
+  lpBits->BitMapBuffer = lpBuff;
+}
+
+/*************************************************************************
+ * RtlSetAllBits	[NTDLL.@]
+ *
+ * Set all bits in a bitmap.
+ *
+ * PARAMS
+ *  lpBits [I] Bitmap pointer
+ *
+ * RETURNS
+ *  Nothing.
+ */
+#undef RtlSetAllBits
+VOID WINAPI RtlSetAllBits(PRTL_BITMAP lpBits)
+{
+  TRACE("(%p)\n", lpBits);
+  memset(lpBits->BitMapBuffer, 0xff, ((lpBits->SizeOfBitMap + 31) & 0xffffffe0) >> 3);
+}
+
+/*************************************************************************
+ * RtlClearAllBits	[NTDLL.@]
+ *
+ * Clear all bits in a bitmap.
+ *
+ * PARAMS
+ *  lpBit [I] Bitmap pointer
+ *
+ * RETURNS
+ *  Nothing.
+ */
+#undef RtlClearAllBits
+VOID WINAPI RtlClearAllBits(PRTL_BITMAP lpBits)
+{
+  TRACE("(%p)\n", lpBits);
+  memset(lpBits->BitMapBuffer, 0, ((lpBits->SizeOfBitMap + 31) & 0xffffffe0) >> 3);
+}
+
+/*************************************************************************
+ * RtlSetBits	[NTDLL.@]
+ *
+ * Set a range of bits in a bitmap.
+ *
+ * PARAMS
+ *  lpBits  [I] Bitmap pointer
+ *  ulStart [I] First bit to set
+ *  ulCount [I] Number of consecutive bits to set
+ *
+ * RETURNS
+ *  Nothing.
+ */
+VOID WINAPI RtlSetBits(PRTL_BITMAP lpBits, ULONG ulStart, ULONG ulCount)
+{
+  LPBYTE lpOut;
+
+  TRACE("(%p,%ld,%ld)\n", lpBits, ulStart, ulCount);
+
+  if (!lpBits || !ulCount || ulStart + ulCount > lpBits->SizeOfBitMap)
+    return;
+
+  lpOut = lpBits->BitMapBuffer + (ulStart >> 3u);
+
+  /* Set bits in first byte, if ulStart isn't a byte boundary */
+  if (ulStart & 7)
+  {
+    if (ulCount > 7)
+    {
+      /* Set from start bit to the end of the byte */
+      *lpOut++ |= 0xff << (ulStart & 7);
+      ulCount -= (8 - (ulStart & 7));
+    }
+    else
+    {
+      /* Set from the start bit, possibly into the next byte also */
+      USHORT initialWord = NTDLL_maskBits[ulCount] << (ulStart & 7);
+
+      *lpOut++ |= (initialWord & 0xff);
+      *lpOut |= (initialWord >> 8);
+      return;
+    }
+  }
+
+  /* Set bits up to complete byte count */
+  if (ulCount >> 3)
+  {
+    memset(lpOut, 0xff, ulCount >> 3);
+    lpOut = lpOut + (ulCount >> 3);
+  }
+
+  /* Set remaining bits, if any */
+  *lpOut |= NTDLL_maskBits[ulCount & 0x7];
+}
+
+/*************************************************************************
+ * RtlClearBits	[NTDLL.@]
+ *
+ * Clear bits in a bitmap.
+ *
+ * PARAMS
+ *  lpBits  [I] Bitmap pointer
+ *  ulStart [I] First bit to set
+ *  ulCount [I] Number of consecutive bits to clear
+ *
+ * RETURNS
+ *  Nothing.
+ */
+VOID WINAPI RtlClearBits(PRTL_BITMAP lpBits, ULONG ulStart, ULONG ulCount)
+{
+  LPBYTE lpOut;
+
+  TRACE("(%p,%ld,%ld)\n", lpBits, ulStart, ulCount);
+
+  if (!lpBits || !ulCount || ulStart + ulCount > lpBits->SizeOfBitMap)
+    return;
+
+  lpOut = lpBits->BitMapBuffer + (ulStart >> 3u);
+
+  /* Clear bits in first byte, if ulStart isn't a byte boundary */
+  if (ulStart & 7)
+  {
+    if (ulCount > 7)
+    {
+      /* Clear from start bit to the end of the byte */
+      *lpOut++ &= ~(0xff << (ulStart & 7));
+      ulCount -= (8 - (ulStart & 7));
+    }
+    else
+    {
+      /* Clear from the start bit, possibly into the next byte also */
+      USHORT initialWord = ~(NTDLL_maskBits[ulCount] << (ulStart & 7));
+
+      *lpOut++ &= (initialWord & 0xff);
+      *lpOut &= (initialWord >> 8);
+      return;
+    }
+  }
+
+  /* Clear bits (in blocks of 8) on whole byte boundaries */
+  if (ulCount >> 3)
+  {
+    memset(lpOut, 0, ulCount >> 3);
+    lpOut = lpOut + (ulCount >> 3);
+  }
+
+  /* Clear remaining bits, if any */
+  if (ulCount & 0x7)
+    *lpOut &= ~NTDLL_maskBits[ulCount & 0x7];
+}
+
+/*************************************************************************
+ * RtlAreBitsSet	[NTDLL.@]
+ *
+ * Determine if part of a bitmap is set.
+ *
+ * PARAMS
+ *  lpBits  [I] Bitmap pointer
+ *  ulStart [I] First bit to check from
+ *  ulCount [I] Number of consecutive bits to check
+ *
+ * RETURNS
+ *  TRUE,  If ulCount bits from ulStart are set.
+ *  FALSE, Otherwise.
+ */
+BOOLEAN WINAPI RtlAreBitsSet(PCRTL_BITMAP lpBits, ULONG ulStart, ULONG ulCount)
+{
+  LPBYTE lpOut;
+  ULONG ulRemainder;
+
+  TRACE("(%p,%ld,%ld)\n", lpBits, ulStart, ulCount);
+
+  if (!lpBits || !ulCount || ulStart + ulCount > lpBits->SizeOfBitMap)
+    return FALSE;
+
+  lpOut = lpBits->BitMapBuffer + (ulStart >> 3u);
+
+  /* Check bits in first byte, if ulStart isn't a byte boundary */
+  if (ulStart & 7)
+  {
+    if (ulCount > 7)
+    {
+      /* Check from start bit to the end of the byte */
+      if ((*lpOut &
+          ((0xff << (ulStart & 7))) & 0xff) != ((0xff << (ulStart & 7) & 0xff)))
+        return FALSE;
+      lpOut++;
+      ulCount -= (8 - (ulStart & 7));
+    }
+    else
+    {
+      /* Check from the start bit, possibly into the next byte also */
+      USHORT initialWord = NTDLL_maskBits[ulCount] << (ulStart & 7);
+
+      if ((*lpOut & (initialWord & 0xff)) != (initialWord & 0xff))
+        return FALSE;
+      if ((initialWord & 0xff00) &&
+          ((lpOut[1] & (initialWord >> 8)) != (initialWord >> 8)))
+        return FALSE;
+      return TRUE;
+    }
+  }
+
+  /* Check bits in blocks of 8 bytes */
+  ulRemainder = ulCount & 7;
+  ulCount >>= 3;
+  while (ulCount--)
+  {
+    if (*lpOut++ != 0xff)
+      return FALSE;
+  }
+
+  /* Check remaining bits, if any */
+  if (ulRemainder &&
+      (*lpOut & NTDLL_maskBits[ulRemainder]) != NTDLL_maskBits[ulRemainder])
+    return FALSE;
+  return TRUE;
+}
+
+/*************************************************************************
+ * RtlAreBitsClear	[NTDLL.@]
+ *
+ * Determine if part of a bitmap is clear.
+ *
+ * PARAMS
+ *  lpBits  [I] Bitmap pointer
+ *  ulStart [I] First bit to check from
+ *  ulCount [I] Number of consecutive bits to check
+ *
+ * RETURNS
+ *  TRUE,  If ulCount bits from ulStart are clear.
+ *  FALSE, Otherwise.
+ */
+BOOLEAN WINAPI RtlAreBitsClear(PCRTL_BITMAP lpBits, ULONG ulStart, ULONG ulCount)
+{
+  LPBYTE lpOut;
+  ULONG ulRemainder;
+
+  TRACE("(%p,%ld,%ld)\n", lpBits, ulStart, ulCount);
+
+  if (!lpBits || !ulCount || ulStart + ulCount > lpBits->SizeOfBitMap)
+    return FALSE;
+
+  lpOut = lpBits->BitMapBuffer + (ulStart >> 3u);
+
+  /* Check bits in first byte, if ulStart isn't a byte boundary */
+  if (ulStart & 7)
+  {
+    if (ulCount > 7)
+    {
+      /* Check from start bit to the end of the byte */
+      if (*lpOut & ((0xff << (ulStart & 7)) & 0xff))
+        return FALSE;
+      lpOut++;
+      ulCount -= (8 - (ulStart & 7));
+    }
+    else
+    {
+      /* Check from the start bit, possibly into the next byte also */
+      USHORT initialWord = NTDLL_maskBits[ulCount] << (ulStart & 7);
+
+      if (*lpOut & (initialWord & 0xff))
+        return FALSE;
+      if ((initialWord & 0xff00) && (lpOut[1] & (initialWord >> 8)))
+        return FALSE;
+      return TRUE;
+    }
+  }
+
+  /* Check bits in blocks of 8 bytes */
+  ulRemainder = ulCount & 7;
+  ulCount >>= 3;
+  while (ulCount--)
+  {
+    if (*lpOut++)
+      return FALSE;
+  }
+
+  /* Check remaining bits, if any */
+  if (ulRemainder && *lpOut & NTDLL_maskBits[ulRemainder])
+    return FALSE;
+  return TRUE;
+}
+
+/*************************************************************************
+ * RtlFindSetBits	[NTDLL.@]
+ *
+ * Find a block of set bits in a bitmap.
+ *
+ * PARAMS
+ *  lpBits  [I] Bitmap pointer
+ *  ulCount [I] Number of consecutive set bits to find
+ *  ulHint  [I] Suggested starting position for set bits
+ *
+ * RETURNS
+ *  The bit at which the match was found, or -1 if no match was found.
+ */
+ULONG WINAPI RtlFindSetBits(PCRTL_BITMAP lpBits, ULONG ulCount, ULONG ulHint)
+{
+  ULONG ulPos, ulEnd;
+
+  TRACE("(%p,%ld,%ld)\n", lpBits, ulCount, ulHint);
+
+  if (!lpBits || !ulCount || ulCount > lpBits->SizeOfBitMap)
+    return -1u;
+
+  ulEnd = lpBits->SizeOfBitMap;
+
+  if (ulHint + ulCount > lpBits->SizeOfBitMap)
+    ulHint = 0;
+
+  ulPos = ulHint;
+
+  while (ulPos < ulEnd)
+  {
+    /* FIXME: This could be made a _lot_ more efficient */
+    if (RtlAreBitsSet(lpBits, ulPos, ulCount))
+      return ulPos;
+
+    /* Start from the beginning if we hit the end and had a hint */
+    if (ulPos == ulEnd - 1 && ulHint)
+    {
+      ulEnd = ulHint;
+      ulPos = ulHint = 0;
+    }
+    else
+      ulPos++;
+  }
+  return -1u;
+}
+
+/*************************************************************************
+ * RtlFindClearBits	[NTDLL.@]
+ *
+ * Find a block of clear bits in a bitmap.
+ *
+ * PARAMS
+ *  lpBits  [I] Bitmap pointer
+ *  ulCount [I] Number of consecutive clear bits to find
+ *  ulHint  [I] Suggested starting position for clear bits
+ *
+ * RETURNS
+ *  The bit at which the match was found, or -1 if no match was found.
+ */
+ULONG WINAPI RtlFindClearBits(PCRTL_BITMAP lpBits, ULONG ulCount, ULONG ulHint)
+{
+  ULONG ulPos, ulEnd;
+
+  TRACE("(%p,%ld,%ld)\n", lpBits, ulCount, ulHint);
+
+  if (!lpBits || !ulCount || ulCount > lpBits->SizeOfBitMap)
+    return -1u;
+
+  ulEnd = lpBits->SizeOfBitMap;
+
+  if (ulHint + ulCount > lpBits->SizeOfBitMap)
+    ulHint = 0;
+
+  ulPos = ulHint;
+
+  while (ulPos < ulEnd)
+  {
+    /* FIXME: This could be made a _lot_ more efficient */
+    if (RtlAreBitsClear(lpBits, ulPos, ulCount))
+      return ulPos;
+
+    /* Start from the beginning if we hit the end and started from ulHint */
+    if (ulPos == ulEnd - 1 && ulHint)
+    {
+      ulEnd = ulHint;
+      ulPos = ulHint = 0;
+    }
+    else
+      ulPos++;
+  }
+  return -1u;
+}
+
+/*************************************************************************
+ * RtlFindSetBitsAndClear	[NTDLL.@]
+ *
+ * Find a block of set bits in a bitmap, and clear them if found.
+ *
+ * PARAMS
+ *  lpBits  [I] Bitmap pointer
+ *  ulCount [I] Number of consecutive set bits to find
+ *  ulHint  [I] Suggested starting position for set bits
+ *
+ * RETURNS
+ *  The bit at which the match was found, or -1 if no match was found.
+ */
+ULONG WINAPI RtlFindSetBitsAndClear(PRTL_BITMAP lpBits, ULONG ulCount, ULONG ulHint)
+{
+  ULONG ulPos;
+
+  TRACE("(%p,%ld,%ld)\n", lpBits, ulCount, ulHint);
+
+  ulPos = RtlFindSetBits(lpBits, ulCount, ulHint);
+  if (ulPos != -1u)
+    RtlClearBits(lpBits, ulPos, ulCount);
+  return ulPos;
+}
+
+/*************************************************************************
+ * RtlFindClearBitsAndSet	[NTDLL.@]
+ *
+ * Find a block of clear bits in a bitmap, and set them if found.
+ *
+ * PARAMS
+ *  lpBits  [I] Bitmap pointer
+ *  ulCount [I] Number of consecutive clear bits to find
+ *  ulHint  [I] Suggested starting position for clear bits
+ *
+ * RETURNS
+ *  The bit at which the match was found, or -1 if no match was found.
+ */
+ULONG WINAPI RtlFindClearBitsAndSet(PRTL_BITMAP lpBits, ULONG ulCount, ULONG ulHint)
+{
+  ULONG ulPos;
+
+  TRACE("(%p,%ld,%ld)\n", lpBits, ulCount, ulHint);
+
+  ulPos = RtlFindClearBits(lpBits, ulCount, ulHint);
+  if (ulPos != -1u)
+    RtlSetBits(lpBits, ulPos, ulCount);
+  return ulPos;
+}
+
+/*************************************************************************
+ * RtlNumberOfSetBits	[NTDLL.@]
+ *
+ * Find the number of set bits in a bitmap.
+ *
+ * PARAMS
+ *  lpBits [I] Bitmap pointer
+ *
+ * RETURNS
+ *  The number of set bits.
+ */
+ULONG WINAPI RtlNumberOfSetBits(PCRTL_BITMAP lpBits)
+{
+  ULONG ulSet = 0;
+
+  TRACE("(%p)\n", lpBits);
+
+  if (lpBits)
+  {
+    LPBYTE lpOut = lpBits->BitMapBuffer;
+    ULONG ulCount, ulRemainder;
+    BYTE bMasked;
+
+    ulCount = lpBits->SizeOfBitMap >> 3;
+    ulRemainder = lpBits->SizeOfBitMap & 0x7;
+
+    while (ulCount--)
+    {
+      ulSet += NTDLL_nibbleBitCount[*lpOut >> 4];
+      ulSet += NTDLL_nibbleBitCount[*lpOut & 0xf];
+      lpOut++;
+    }
+
+    bMasked = *lpOut & NTDLL_maskBits[ulRemainder];
+    ulSet += NTDLL_nibbleBitCount[bMasked >> 4];
+    ulSet += NTDLL_nibbleBitCount[bMasked & 0xf];
+  }
+  return ulSet;
+}
+
+/*************************************************************************
+ * RtlNumberOfClearBits	[NTDLL.@]
+ *
+ * Find the number of clear bits in a bitmap.
+ *
+ * PARAMS
+ *  lpBits [I] Bitmap pointer
+ *
+ * RETURNS
+ *  The number of clear bits.
+ */
+ULONG WINAPI RtlNumberOfClearBits(PCRTL_BITMAP lpBits)
+{
+  TRACE("(%p)\n", lpBits);
+
+  if (lpBits)
+    return lpBits->SizeOfBitMap - RtlNumberOfSetBits(lpBits);
+  return 0;
+}
+
+/*************************************************************************
+ * RtlFindMostSignificantBit	[NTDLL.@]
+ *
+ * Find the most significant bit in a 64 bit integer.
+ *
+ * PARAMS
+ *  lpBits  [I] Bitmap pointer
+ *  ulStart [I] First bit to search from
+ *
+ * RETURNS
+ *  The position of the most significant bit.
+ */
+CCHAR WINAPI RtlFindMostSignificantBit(ULONGLONG ulLong)
+{
+  LONG lCount = 64;
+  LPBYTE lpOut = (LPBYTE)&ulLong + 7;
+
+  TRACE("(%lld)\n", ulLong);
+
+  if (!(ulLong & 0xffffffff00000000ul))
+  {
+    lpOut -= 4;
+    lCount -= 32;
+  }
+
+  for (; lCount > 0; lCount -= 8)
+  {
+    if (*lpOut)
+    {
+      if (*lpOut & 0x0f)
+        return lCount - 8 + NTDLL_mostSignificant[*lpOut & 0x0f];
+      return lCount - 4 + NTDLL_mostSignificant[*lpOut >> 4];
+    }
+    lpOut--;
+  }
+  return -1;
+}
+
+/*************************************************************************
+ * RtlFindLeastSignificantBit	[NTDLL.@]
+ *
+ * Find the least significant bit in a 64 bit integer.
+ *
+ * PARAMS
+ *  lpBits  [I] Bitmap pointer
+ *  ulStart [I] First bit to search from
+ *
+ * RETURNS
+ *  The position of the least significant bit.
+ */
+CCHAR WINAPI RtlFindLeastSignificantBit(ULONGLONG ulLong)
+{
+  ULONG ulCount = 0;
+  LPBYTE lpOut = (LPBYTE)&ulLong;
+
+  TRACE("(%lld)\n", ulLong);
+
+  if (!(ulLong & 0xffffffff))
+  {
+    lpOut += 4;
+    ulCount = 32;
+  }
+
+  for (; ulCount < 64; ulCount += 8)
+  {
+    if (*lpOut)
+    {
+      if (*lpOut & 0x0f)
+        return ulCount + NTDLL_leastSignificant[*lpOut & 0x0f];
+      return ulCount + 4 + NTDLL_leastSignificant[*lpOut >> 4];
+    }
+    lpOut++;
+  }
+  return -1;
+}
+
+/*************************************************************************
+ * NTDLL_RunSortFn
+ *
+ * Internal helper: qsort comparason function for RTL_BITMAP_RUN arrays
+ */
+static int NTDLL_RunSortFn(const void *lhs, const void *rhs)
+{
+  if (((PCRTL_BITMAP_RUN)lhs)->SizeOfRun > ((PRTL_BITMAP_RUN)rhs)->SizeOfRun)
+    return -1;
+  return 1;
+}
+
+/*************************************************************************
+ * NTDLL_FindSetRun
+ *
+ * Internal helper: Find the next run of set bits in a bitmap.
+ */
+static ULONG NTDLL_FindSetRun(PCRTL_BITMAP lpBits, ULONG ulStart, PULONG lpSize)
+{
+  LPBYTE lpOut;
+  ULONG ulFoundAt = 0, ulCount = 0;
+
+  lpOut = lpBits->BitMapBuffer + (ulStart >> 3u);
+
+  while (1)
+  {
+    /* Check bits in first byte */
+    const BYTE bMask = (0xff << (ulStart & 7)) & 0xff;
+    const BYTE bFirst = *lpOut & bMask;
+
+    if (bFirst)
+    {
+      /* Have a set bit in first byte */
+      if (bFirst != bMask)
+      {
+        /* Not every bit is set */
+        ULONG ulOffset;
+
+        if (bFirst & 0x0f)
+          ulOffset = NTDLL_leastSignificant[bFirst & 0x0f];
+        else
+          ulOffset = 4 + NTDLL_leastSignificant[bFirst >> 4];
+        ulStart += ulOffset;
+        ulFoundAt = ulStart;
+        for (;ulOffset < 8; ulOffset++)
+        {
+          if (!(bFirst & (1 << ulOffset)))
+          {
+            *lpSize = ulCount;
+            return ulFoundAt; /* Set from start, but not until the end */
+          }
+          ulCount++;
+          ulStart++;
+        }
+        /* Set to the end - go on to count further bits */
+        lpOut++;
+        break;
+      }
+      /* every bit from start until the end of the byte is set */
+      ulFoundAt = ulStart;
+      ulCount = 8 - (ulStart & 7);
+      ulStart = (ulStart & ~7u) + 8;
+      lpOut++;
+      break;
+    }
+    ulStart = (ulStart & ~7u) + 8;
+    lpOut++;
+    if (ulStart >= lpBits->SizeOfBitMap)
+      return -1u;
+  }
+
+  /* Count blocks of 8 set bits */
+  while (*lpOut == 0xff)
+  {
+    ulCount += 8;
+    ulStart += 8;
+    if (ulStart >= lpBits->SizeOfBitMap)
+    {
+      *lpSize = ulCount - (ulStart - lpBits->SizeOfBitMap);
+      return ulFoundAt;
+    }
+    lpOut++;
+  }
+
+  /* Count remaining contigious bits, if any */
+  if (*lpOut & 1)
+  {
+    ULONG ulOffset = 0;
+
+    for (;ulOffset < 7u; ulOffset++)
+    {
+      if (!(*lpOut & (1 << ulOffset)))
+        break;
+      ulCount++;
+    }
+  }
+  *lpSize = ulCount;
+  return ulFoundAt;
+}
+
+/*************************************************************************
+ * NTDLL_FindClearRun
+ *
+ * Internal helper: Find the next run of set bits in a bitmap.
+ */
+static ULONG NTDLL_FindClearRun(PCRTL_BITMAP lpBits, ULONG ulStart, PULONG lpSize)
+{
+  LPBYTE lpOut;
+  ULONG ulFoundAt = 0, ulCount = 0;
+
+  lpOut = lpBits->BitMapBuffer + (ulStart >> 3u);
+
+  while (1)
+  {
+    /* Check bits in first byte */
+    const BYTE bMask = (0xff << (ulStart & 7)) & 0xff;
+    const BYTE bFirst = (~*lpOut) & bMask;
+
+    if (bFirst)
+    {
+      /* Have a clear bit in first byte */
+      if (bFirst != bMask)
+      {
+        /* Not every bit is clear */
+        ULONG ulOffset;
+
+        if (bFirst & 0x0f)
+          ulOffset = NTDLL_leastSignificant[bFirst & 0x0f];
+        else
+          ulOffset = 4 + NTDLL_leastSignificant[bFirst >> 4];
+        ulStart += ulOffset;
+        ulFoundAt = ulStart;
+        for (;ulOffset < 8; ulOffset++)
+        {
+          if (!(bFirst & (1 << ulOffset)))
+          {
+            *lpSize = ulCount;
+            return ulFoundAt; /* Clear from start, but not until the end */
+          }
+          ulCount++;
+          ulStart++;
+        }
+        /* Clear to the end - go on to count further bits */
+        lpOut++;
+        break;
+      }
+      /* Every bit from start until the end of the byte is clear */
+      ulFoundAt = ulStart;
+      ulCount = 8 - (ulStart & 7);
+      ulStart = (ulStart & ~7u) + 8;
+      lpOut++;
+      break;
+    }
+    ulStart = (ulStart & ~7u) + 8;
+    lpOut++;
+    if (ulStart >= lpBits->SizeOfBitMap)
+      return -1u;
+  }
+
+  /* Count blocks of 8 clear bits */
+  while (!*lpOut)
+  {
+    ulCount += 8;
+    ulStart += 8;
+    if (ulStart >= lpBits->SizeOfBitMap)
+    {
+      *lpSize = ulCount - (ulStart - lpBits->SizeOfBitMap);
+      return ulFoundAt;
+    }
+    lpOut++;
+  }
+
+  /* Count remaining contigious bits, if any */
+  if (!(*lpOut & 1))
+  {
+    ULONG ulOffset = 0;
+
+    for (;ulOffset < 7u; ulOffset++)
+    {
+      if (*lpOut & (1 << ulOffset))
+        break;
+      ulCount++;
+    }
+  }
+  *lpSize = ulCount;
+  return ulFoundAt;
+}
+
+/*************************************************************************
+ * RtlFindNextForwardRunSet	[NTDLL.@]
+ *
+ * Find the next run of set bits in a bitmap.
+ *
+ * PARAMS
+ *  lpBits  [I] Bitmap pointer
+ *  ulStart [I] Bit position to start searching from
+ *  lpPos   [O] Start of run
+ *
+ * RETURNS
+ *  Success: The length of the next set run in the bitmap. lpPos is set to
+ *           the start of the run.
+ *  Failure: 0, if no run is found or any parameters are invalid.
+ */
+ULONG WINAPI RtlFindNextForwardRunSet(PCRTL_BITMAP lpBits, ULONG ulStart, PULONG lpPos)
+{
+  ULONG ulSize = 0;
+
+  TRACE("(%p,%ld,%p)\n", lpBits, ulStart, lpPos);
+
+  if (lpBits && ulStart < lpBits->SizeOfBitMap && lpPos)
+    *lpPos = NTDLL_FindSetRun(lpBits, ulStart, &ulSize);
+
+  return ulSize;
+}
+
+/*************************************************************************
+ * RtlFindNextForwardRunClear	[NTDLL.@]
+ *
+ * Find the next run of clear bits in a bitmap.
+ *
+ * PARAMS
+ *  lpBits  [I] Bitmap pointer
+ *  ulStart [I] Bit position to start searching from
+ *  lpPos   [O] Start of run
+ *
+ * RETURNS
+ *  Success: The length of the next clear run in the bitmap. lpPos is set to
+ *           the start of the run.
+ *  Failure: 0, if no run is found or any parameters are invalid.
+ */
+ULONG WINAPI RtlFindNextForwardRunClear(PCRTL_BITMAP lpBits, ULONG ulStart, PULONG lpPos)
+{
+  ULONG ulSize = 0;
+
+  TRACE("(%p,%ld,%p)\n", lpBits, ulStart, lpPos);
+
+  if (lpBits && ulStart < lpBits->SizeOfBitMap && lpPos)
+    *lpPos = NTDLL_FindClearRun(lpBits, ulStart, &ulSize);
+
+  return ulSize;
+}
+
+/*************************************************************************
+ * RtlFindLastBackwardRunSet	[NTDLL.@]
+ *
+ * Find a previous run of set bits in a bitmap.
+ *
+ * PARAMS
+ *  lpBits  [I] Bitmap pointer
+ *  ulStart [I] Bit position to start searching from
+ *  lpPos   [O] Start of run
+ *
+ * RETURNS
+ *  Success: The length of the previous set run in the bitmap. lpPos is set to
+ *           the start of the run.
+ *  Failure: 0, if no run is found or any parameters are invalid.
+ */
+ULONG WINAPI RtlFindLastBackwardRunSet(PCRTL_BITMAP lpBits, ULONG ulStart, PULONG lpPos)
+{
+  FIXME("(%p,%ld,%p)-stub!\n", lpBits, ulStart, lpPos);
+  return 0;
+}
+
+/*************************************************************************
+ * RtlFindLastBackwardRunClear	[NTDLL.@]
+ *
+ * Find a previous run of clear bits in a bitmap.
+ *
+ * PARAMS
+ *  lpBits  [I] Bitmap pointer
+ *  ulStart [I] Bit position to start searching from
+ *  lpPos   [O] Start of run
+ *
+ * RETURNS
+ *  Success: The length of the previous clear run in the bitmap. lpPos is set
+ *           to the start of the run.
+ *  Failure: 0, if no run is found or any parameters are invalid.
+ */
+ULONG WINAPI RtlFindLastBackwardRunClear(PCRTL_BITMAP lpBits, ULONG ulStart, PULONG lpPos)
+{
+  FIXME("(%p,%ld,%p)-stub!\n", lpBits, ulStart, lpPos);
+  return 0;
+}
+
+/*************************************************************************
+ * NTDLL_FindRuns
+ *
+ * Internal implementation of RtlFindSetRuns/RtlFindClearRuns.
+ */
+static ULONG WINAPI NTDLL_FindRuns(PCRTL_BITMAP lpBits, PRTL_BITMAP_RUN lpSeries,
+                                   ULONG ulCount, BOOLEAN bLongest,
+                                   ULONG (*fn)(PCRTL_BITMAP,ULONG,PULONG))
+{
+  BOOL bNeedSort = ulCount > 1 ? TRUE : FALSE;
+  ULONG ulPos = 0, ulRuns = 0;
+
+  TRACE("(%p,%p,%ld,%d)\n", lpBits, lpSeries, ulCount, bLongest);
+
+  if (!ulCount)
+    return -1u;
+
+  while (ulPos < lpBits->SizeOfBitMap)
+  {
+    /* Find next set/clear run */
+    ULONG ulSize, ulNextPos = fn(lpBits, ulPos, &ulSize);
+
+    if (ulNextPos == -1u)
+      break;
+
+    if (bLongest && ulRuns == ulCount)
+    {
+      /* Sort runs with shortest at end, if they are out of order */
+      if (bNeedSort)
+        qsort(lpSeries, ulRuns, sizeof(RTL_BITMAP_RUN), NTDLL_RunSortFn);
+
+      /* Replace last run if this one is bigger */
+      if (ulSize > lpSeries[ulRuns - 1].SizeOfRun)
+      {
+        lpSeries[ulRuns - 1].StartOfRun = ulNextPos;
+        lpSeries[ulRuns - 1].SizeOfRun = ulSize;
+
+        /* We need to re-sort the array, _if_ we didn't leave it sorted */
+        if (ulRuns > 1 && ulSize > lpSeries[ulRuns - 2].SizeOfRun)
+          bNeedSort = TRUE;
+      }
+    }
+    else
+    {
+      /* Append to found runs */
+      lpSeries[ulRuns].StartOfRun = ulNextPos;
+      lpSeries[ulRuns].SizeOfRun = ulSize;
+      ulRuns++;
+
+      if (!bLongest && ulRuns == ulCount)
+        break;
+    }
+    ulPos = ulNextPos + ulSize;
+  }
+  return ulRuns;
+}
+
+/*************************************************************************
+ * RtlFindSetRuns	[NTDLL.@]
+ *
+ * Find a series of set runs in a bitmap.
+ *
+ * PARAMS
+ *  lpBits   [I] Bitmap pointer
+ *  ulSeries [O] Array for each run found
+ *  ulCount  [I] Number of runs to find
+ *  bLongest [I] Whether to find the very longest runs or not
+ *
+ * RETURNS
+ *  The number of set runs found.
+ */
+ULONG WINAPI RtlFindSetRuns(PCRTL_BITMAP lpBits, PRTL_BITMAP_RUN lpSeries,
+                            ULONG ulCount, BOOLEAN bLongest)
+{
+  TRACE("(%p,%p,%ld,%d)\n", lpBits, lpSeries, ulCount, bLongest);
+
+  return NTDLL_FindRuns(lpBits, lpSeries, ulCount, bLongest, NTDLL_FindSetRun);
+}
+
+/*************************************************************************
+ * RtlFindClearRuns	[NTDLL.@]
+ *
+ * Find a series of clear runs in a bitmap.
+ *
+ * PARAMS
+ *  lpBits   [I] Bitmap pointer
+ *  ulSeries [O] Array for each run found
+ *  ulCount  [I] Number of runs to find
+ *  bLongest [I] Whether to find the very longest runs or not
+ *
+ * RETURNS
+ *  The number of clear runs found.
+ */
+ULONG WINAPI RtlFindClearRuns(PCRTL_BITMAP lpBits, PRTL_BITMAP_RUN lpSeries,
+                              ULONG ulCount, BOOLEAN bLongest)
+{
+  TRACE("(%p,%p,%ld,%d)\n", lpBits, lpSeries, ulCount, bLongest);
+
+  return NTDLL_FindRuns(lpBits, lpSeries, ulCount, bLongest, NTDLL_FindClearRun);
+}
+
+/*************************************************************************
+ * RtlFindLongestRunSet	[NTDLL.@]
+ *
+ * Find the longest set run in a bitmap.
+ *
+ * PARAMS
+ *  lpBits   [I] Bitmap pointer
+ *  pulStart [O] Destination for start of run
+ *
+ * RETURNS
+ *  The length of the run found, or 0 if no run is found.
+ */
+ULONG WINAPI RtlFindLongestRunSet(PCRTL_BITMAP lpBits, PULONG pulStart)
+{
+  RTL_BITMAP_RUN br;
+
+  TRACE("(%p,%p)\n", lpBits, pulStart);
+
+  if (RtlFindSetRuns(lpBits, &br, 1, TRUE) == 1)
+  {
+    if (pulStart)
+      *pulStart = br.StartOfRun;
+    return br.SizeOfRun;
+  }
+  return 0;
+}
+
+/*************************************************************************
+ * RtlFindLongestRunClear	[NTDLL.@]
+ *
+ * Find the longest clear run in a bitmap.
+ *
+ * PARAMS
+ *  lpBits   [I] Bitmap pointer
+ *  pulStart [O] Destination for start of run
+ *
+ * RETURNS
+ *  The length of the run found, or 0 if no run is found.
+ */
+ULONG WINAPI RtlFindLongestRunClear(PCRTL_BITMAP lpBits, PULONG pulStart)
+{
+  RTL_BITMAP_RUN br;
+
+  TRACE("(%p,%p)\n", lpBits, pulStart);
+
+  if (RtlFindClearRuns(lpBits, &br, 1, TRUE) == 1)
+  {
+    if (pulStart)
+      *pulStart = br.StartOfRun;
+    return br.SizeOfRun;
+  }
+  return 0;
+}
Index: trunk/src/msvcrt/scanf.c
===================================================================
--- trunk/src/msvcrt/scanf.c	(revision 9633)
+++ trunk/src/msvcrt/scanf.c	(revision 9633)
@@ -0,0 +1,98 @@
+/*
+ * general implementation of scanf used by scanf, sscanf, fscanf,
+ * _cscanf, wscanf, swscanf and fwscanf
+ *
+ * Copyright 1996,1998 Marcus Meissner
+ * Copyright 1996 Jukka Iivonen
+ * Copyright 1997,2000 Uwe Bonnes
+ * Copyright 2000 Jon Griffiths
+ * Copyright 2002 Daniel Gudbjartsson
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "winbase.h"
+#include "winternl.h"
+#include "msvcrt.h"
+#include "msvcrt/conio.h"
+#include "msvcrt/io.h"
+#include "msvcrt/stdio.h"
+#include "msvcrt/wctype.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
+
+/* 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.
+ */
+static int char2digit(char c, int base) {
+    if ((c>='0') && (c<='9') && (c<='0'+base-1)) return (c-'0');
+    if (base<=10) return -1;
+    if ((c>='A') && (c<='Z') && (c<='A'+base-11)) return (c-'A'+10);
+    if ((c>='a') && (c<='z') && (c<='a'+base-11)) return (c-'a'+10);
+    return -1;
+}
+
+/* helper function for *wscanf.  Returns the value of character c in the
+ * given base, or -1 if the given character is not a digit of the base.
+ */
+static int wchar2digit(MSVCRT_wchar_t c, int base) {
+    if ((c>=L'0') && (c<=L'9') && (c<=L'0'+base-1)) return (c-L'0');
+    if (base<=10) return -1;
+    if ((c>=L'A') && (c<=L'Z') && (c<=L'A'+base-11)) return (c-L'A'+10);
+    if ((c>=L'a') && (c<=L'z') && (c<=L'a'+base-11)) return (c-L'a'+10);
+    return -1;
+}
+
+
+/*********************************************************************
+ *		fscanf (MSVCRT.@)
+ */
+#undef WIDE_SCANF
+#undef CONSOLE
+#undef STRING
+#include "scanf.h"
+
+/*********************************************************************
+ *		fwscanf (MSVCRT.@)
+ */
+#define WIDE_SCANF 1
+#undef CONSOLE
+#undef STRING
+#include "scanf.h"
+
+/*********************************************************************
+ *		sscanf (MSVCRT.@)
+ */
+#undef WIDE_SCANF
+#undef CONSOLE
+#define STRING 1
+#include "scanf.h"
+
+/*********************************************************************
+ *		swscanf (MSVCRT.@)
+ */
+#define WIDE_SCANF 1
+#undef CONSOLE
+#define STRING 1
+#include "scanf.h"
+
+/*********************************************************************
+ *		_cscanf (MSVCRT.@)
+ */
+#undef WIDE_SCANF
+#define CONSOLE 1
+#undef STRING
+#include "scanf.h"
Index: trunk/src/msvcrt/scanf.h
===================================================================
--- trunk/src/msvcrt/scanf.h	(revision 9633)
+++ trunk/src/msvcrt/scanf.h	(revision 9633)
@@ -0,0 +1,545 @@
+/*
+ * general implementation of scanf used by scanf, sscanf, fscanf,
+ * _cscanf, wscanf, swscanf and fwscanf
+ *
+ * Copyright 1996,1998 Marcus Meissner
+ * Copyright 1996 Jukka Iivonen
+ * Copyright 1997,2000 Uwe Bonnes
+ * Copyright 2000 Jon Griffiths
+ * Copyright 2002 Daniel Gudbjartsson
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifdef WIDE_SCANF
+#define _CHAR_ MSVCRT_wchar_t
+#define _EOF_ MSVCRT_WEOF
+#define _ISSPACE_(c) MSVCRT_iswspace(c)
+#define _ISDIGIT_(c) MSVCRT_iswdigit(c)
+#define _CONVERT_(c) c /*** FIXME ***/
+#define _CHAR2DIGIT_(c, base) wchar2digit((c), (base))
+#else /* WIDE_SCANF */
+#define _CHAR_ char
+#define _EOF_ MSVCRT_EOF
+#define _ISSPACE_(c) isspace(c)
+#define _ISDIGIT_(c) isdigit(c)
+#define _CONVERT_(c) c /*** FIXME ***/
+#define _CHAR2DIGIT_(c, base) char2digit((c), (base))
+#endif /* WIDE_SCANF */
+
+#ifdef CONSOLE
+#define _GETC_(file) _getch()
+#define _UNGETC_(nch, file) _ungetch(nch)
+#define _FUNCTION_ _cscanf(const _CHAR_ *format, ...)
+#else
+#ifdef STRING
+#undef _EOF_
+#define _EOF_ 0
+#define _GETC_(file) *file++
+#define _UNGETC_(nch, file) file--
+#ifdef WIDE_SCANF
+#define _FUNCTION_ MSVCRT_swscanf(const MSVCRT_wchar_t *file, const MSVCRT_wchar_t *format, ...)
+#else /* WIDE_SCANF */
+#define _FUNCTION_ MSVCRT_sscanf(const char *file, const char *format, ...)
+#endif /* WIDE_SCANF */
+#else /* STRING */
+#ifdef WIDE_SCANF
+#define _GETC_(file) MSVCRT_fgetwc(file)
+#define _UNGETC_(nch, file) MSVCRT_ungetwc(nch, file)
+#define _FUNCTION_ MSVCRT_fwscanf(MSVCRT_FILE* file, const MSVCRT_wchar_t *format, ...)
+#else /* WIDE_SCANF */
+#define _GETC_(file) MSVCRT_fgetc(file)
+#define _UNGETC_(nch, file) MSVCRT_ungetc(nch, file)
+#define _FUNCTION_ MSVCRT_fscanf(MSVCRT_FILE* file, const char *format, ...)
+#endif /* WIDE_SCANF */
+#endif /* STRING */
+#endif /* CONSOLE */
+
+/*********************************************************************
+ * Implemented based on
+ * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/_crt_format_specification_fields_.2d_.scanf_and_wscanf_functions.asp
+ * Extended by C. Scott Ananian <cananian@alumni.princeton.edu> to handle
+ * more types of format spec.
+ */
+int _FUNCTION_ {
+    int rd = 0;
+    int nch;
+    va_list ap;
+    if (!*format) return 0;
+#ifndef WIDE_SCANF
+#ifdef CONSOLE
+    WARN("(\"%s\"): semi-stub\n", format);
+#else /* CONSOLE */
+#ifdef STRING
+    WARN("%s (\"%s\"): semi-stub\n", file, format);
+#else /* STRING */
+    WARN("%p (\"%s\"): semi-stub\n", file, format);
+#endif /* STRING */
+#endif /* CONSOLE */
+#endif /* WIDE_SCANF */
+    nch = _GETC_(file);
+    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
+	 * up to the next non-white-space character.  One white space character
+	 * in the input matches any number (including zero) and combination of
+	 * white-space characters in the input. */
+	if (_ISSPACE_(*format)) {
+            /* skip whitespace */
+            while ((nch!=_EOF_) && _ISSPACE_(nch))
+                nch = _GETC_(file);
+        }
+	/* a format specification causes scanf to read and convert characters
+	 * in the input into values of a specified type.  The value is assigned
+	 * to an argument in the argument list.  Format specifications have
+	 * the form %[*][width][{h | l | I64 | L}]type */
+        else if (*format == '%') {
+            int st = 0; int suppress = 0; int width = 0;
+	    int base, number_signed;
+	    int h_prefix = 0;
+	    int l_prefix = 0;
+	    int L_prefix = 0;
+	    int w_prefix = 0;
+	    int prefix_finished = 0;
+	    /* int I64_prefix = 0; */
+            format++;
+	    /* look for leading asterisk, which means 'suppress assignment of
+	     * this field'. */
+	    if (*format=='*') {
+		format++;
+		suppress=1;
+	    }
+	    /* look for width specification */
+	    while (_ISDIGIT_(*format)) {
+		width*=10;
+		width+=*format++ - '0';
+	    }
+	    if (width==0) width=-1; /* no width spec seen */
+	    /* read prefix (if any) */
+	    while (!prefix_finished) {
+		switch(*format) {
+		case 'h': h_prefix = 1; break;
+		case 'l': l_prefix = 1; break;
+		case 'w': w_prefix = 1; break;
+		case 'L': L_prefix = 1; break;
+		case 'I':
+		    if (*(format + 1) == '6' &&
+			*(format + 2) == '4') {
+			/* I64_prefix = 1; */
+			format += 2;
+			FIXME("I64 prefix currently not implemented in fscanf/fwscanf");
+		    }
+		    break;
+		default:
+		    prefix_finished = 1;
+		}
+		if (!prefix_finished) format++;
+	    }
+	    /* read type */
+            switch(*format) {
+	    case 'x':
+	    case 'X': /* hexadecimal integer. */
+		base = 16; number_signed = 0;
+		goto number;
+	    case 'o': /* octal integer */
+		base = 8; number_signed = 0;
+		goto number;
+	    case 'u': /* unsigned decimal integer */
+		base = 10; number_signed = 0;
+		goto number;
+	    case 'd': /* signed decimal integer */
+		base = 10; number_signed = 1;
+		goto number;
+	    case 'i': /* generic integer */
+		base = 0; number_signed = 1;
+	    number: {
+		    /* read an integer */
+                    long unsigned int cur = 0;
+		    int negative = 0;
+		    int seendigit=0;
+                    /* skip initial whitespace */
+                    while ((nch!=_EOF_) && _ISSPACE_(nch))
+                        nch = _GETC_(file);
+                    /* get sign */
+                    if (number_signed && (nch == '-' ||
+					  nch == '+')) {
+			negative = (nch=='-');
+                        nch = _GETC_(file);
+			if (width>0) width--;
+                    }
+		    /* look for leading indication of base */
+		    if (width!=0 && nch == '0') {
+                        nch = _GETC_(file);
+			if (width>0) width--;
+			seendigit=1;
+			if (width!=0 && (nch=='x' || nch=='X')) {
+			    if (base==0)
+				base=16;
+			    if (base==16) {
+				nch = _GETC_(file);
+				if (width>0) width--;
+				seendigit=0;
+			    }
+			} else if (base==0)
+			    base = 8;
+		    }
+		    /* throw away leading zeros */
+		    while (width!=0 && nch=='0') {
+                        nch = _GETC_(file);
+			if (width>0) width--;
+			seendigit=1;
+		    }
+		    if (width!=0 && _CHAR2DIGIT_(nch, base)!=-1) {
+			cur = _CHAR2DIGIT_(nch, base);
+			nch = _GETC_(file);
+			if (width>0) width--;
+			seendigit=1;
+		    }
+                    /* read until no more digits */
+                    while (width!=0 && (nch!=_EOF_) && _CHAR2DIGIT_(nch, base)!=-1) {
+                        cur = cur*base + _CHAR2DIGIT_(nch, base);
+                        nch = _GETC_(file);
+			if (width>0) width--;
+			seendigit=1;
+                    }
+		    /* okay, done! */
+		    if (!seendigit) break; /* not a valid number */
+                    st = 1;
+                    if (!suppress) {
+#define _SET_NUMBER_(type) *va_arg(ap, type*) = negative ? -cur : cur
+			if (number_signed) {
+			    if (l_prefix) _SET_NUMBER_(long int);
+			    else if (h_prefix) _SET_NUMBER_(short int);
+			    else _SET_NUMBER_(int);
+			} else {
+			    if (negative) {
+				WARN("Dropping sign in reading a negative number into an unsigned value");
+				negative = 0;
+			    }
+			    if (l_prefix) _SET_NUMBER_(unsigned long int);
+			    else if (h_prefix)
+				_SET_NUMBER_(unsigned short int);
+			    else _SET_NUMBER_(unsigned int);
+			}
+		    }
+                }
+                break;
+	    case 'e':
+	    case 'E':
+	    case 'f':
+	    case 'g':
+            case 'G': { /* read a float */
+                    long double cur = 0;
+		    int negative = 0;
+                    /* skip initial whitespace */
+                    while ((nch!=_EOF_) && _ISSPACE_(nch))
+                        nch = _GETC_(file);
+		    /* get sign. */
+                    if (nch == '-' || nch == '+') {
+			negative = (nch=='-');
+			if (width>0) width--;
+			if (width==0) break;
+                        nch = _GETC_(file);
+                    }
+		    /* get first digit. */
+		    if (!_ISDIGIT_(nch)) break;
+		    cur = (nch - '0') * (negative ? -1 : 1);
+                    nch = _GETC_(file);
+		    if (width>0) width--;
+                    /* read until no more digits */
+                    while (width!=0 && (nch!=_EOF_) && _ISDIGIT_(nch)) {
+                        cur = cur*10 + (nch - '0');
+                        nch = _GETC_(file);
+			if (width>0) width--;
+                    }
+		    /* handle decimals */
+                    if (width!=0 && nch == '.') {
+                        float dec = 1;
+                        nch = _GETC_(file);
+			if (width>0) width--;
+                        while (width!=0 && (nch!=_EOF_) && _ISDIGIT_(nch)) {
+                            dec /= 10;
+                            cur += dec * (nch - '0');
+                            nch = _GETC_(file);
+			    if (width>0) width--;
+                        }
+                    }
+		    /* handle exponent */
+		    if (width!=0 && (nch == 'e' || nch == 'E')) {
+			int exponent = 0, negexp = 0;
+			float expcnt;
+                        nch = _GETC_(file);
+			if (width>0) width--;
+			/* possible sign on the exponent */
+			if (width!=0 && (nch=='+' || nch=='-')) {
+			    negexp = (nch=='-');
+                            nch = _GETC_(file);
+			    if (width>0) width--;
+			}
+			/* exponent digits */
+			while (width!=0 && (nch!=_EOF_) && _ISDIGIT_(nch)) {
+			    exponent *= 10;
+			    exponent += (nch - '0');
+                            nch = _GETC_(file);
+			    if (width>0) width--;
+                        }
+			/* update 'cur' with this exponent. */
+			expcnt =  negexp ? .1 : 10;
+			while (exponent!=0) {
+			    if (exponent&1)
+				cur*=expcnt;
+			    exponent/=2;
+			    expcnt=expcnt*expcnt;
+			}
+		    }
+                    st = 1;
+                    if (!suppress) {
+			if (L_prefix) _SET_NUMBER_(long double);
+			else if (l_prefix) _SET_NUMBER_(double);
+			else _SET_NUMBER_(float);
+		    }
+                }
+                break;
+		/* According to
+		 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_scanf_type_field_characters.asp
+		 * 's' reads a character string in a call to fscanf
+		 * and 'S' a wide character string and vice versa in a
+		 * call to fwscanf. The 'h', 'w' and 'l' prefixes override
+		 * this behaviour. 'h' forces reading char * but 'l' and 'w'
+		 * force reading WCHAR. */
+	    case 's':
+		    if (w_prefix || l_prefix) goto widecharstring;
+		    else if (h_prefix) goto charstring;
+#ifdef WIDE_SCANF
+		    else goto widecharstring;
+#else /* WIDE_SCANF */
+		    else goto charstring;
+#endif /* WIDE_SCANF */
+	    case 'S':
+		    if (w_prefix || l_prefix) goto widecharstring;
+		    else if (h_prefix) goto charstring;
+#ifdef WIDE_SCANF
+		    else goto charstring;
+#else /* WIDE_SCANF */
+		    else goto widecharstring;
+#endif /* WIDE_SCANF */
+	    charstring: { /* read a word into a char */
+		    char*str = suppress ? NULL : va_arg(ap, char*);
+                    char*sptr = str;
+                    /* skip initial whitespace */
+                    while ((nch!=_EOF_) && _ISSPACE_(nch))
+                        nch = _GETC_(file);
+                    /* read until whitespace */
+                    while (width!=0 && (nch!=_EOF_) && !_ISSPACE_(nch)) {
+#ifdef WIDE_SCANF
+                        if (!suppress) *sptr++ = _CONVERT_(nch);
+#else /* WIDE_SCANF */
+                        if (!suppress) *sptr++ = nch;
+#endif /* WIDE_SCANF */
+			st++;
+                        nch = _GETC_(file);
+			if (width>0) width--;
+                    }
+                    /* terminate */
+                    if (!suppress) *sptr = 0;
+                }
+                break;
+	    widecharstring: { /* read a word into a wchar_t* */
+		    MSVCRT_wchar_t*str =
+			suppress ? NULL : va_arg(ap, MSVCRT_wchar_t*);
+                    MSVCRT_wchar_t*sptr = str;
+                    /* skip initial whitespace */
+                    while ((nch!=_EOF_) && _ISSPACE_(nch))
+                        nch = _GETC_(file);
+                    /* read until whitespace */
+                    while (width!=0 && (nch!=_EOF_) && !_ISSPACE_(nch)) {
+#ifdef WIDE_SCANF
+                        if (!suppress) *sptr++ = nch;
+#else /* WIDE_SCANF */
+                        if (!suppress) *sptr++ = _CONVERT_(nch);
+#endif /* WIDE_SCANF */
+			st++;
+                        nch = _GETC_(file);
+			if (width>0) width--;
+                    }
+                    /* terminate */
+                    if (!suppress) *sptr = 0;
+                }
+                break;
+            /* 'c' and 'C work analogously to 's' and 'S' as described
+	     * above */
+	    case 'c':
+		    if (w_prefix || l_prefix) goto widecharacter;
+		    else if (h_prefix) goto character;
+#ifdef WIDE_SCANF
+		    else goto widecharacter;
+#else /* WIDE_SCANF */
+		    else goto character;
+#endif /* WIDE_SCANF */
+	    case 'C':
+		    if (w_prefix || l_prefix) goto widecharacter;
+		    else if (h_prefix) goto character;
+#ifdef WIDE_SCANF
+		    else goto character;
+#else /* WIDE_SCANF */
+		    else goto widecharacter;
+#endif /* WIDE_SCANF */
+	  character: { /* read single character into char */
+		    if (!suppress) {
+			char*c = va_arg(ap, char*);
+#ifdef WIDE_SCANF
+			*c = _CONVERT_(nch);
+#else /* WIDE_SCANF */
+			*c = nch;
+#endif /* WIDE_SCANF */
+			st = 1;
+		    }
+ 		    nch = _GETC_(file);
+	        }
+		break;
+	  widecharacter: {
+		    if (!suppress) { /* read single character into a wchar_t */
+			MSVCRT_wchar_t*c = va_arg(ap, MSVCRT_wchar_t*);
+#ifdef WIDE_SCANF
+			*c = nch;
+#else /* WIDE_SCANF */
+			*c = _CONVERT_(nch);
+#endif /* WIDE_SCANF */
+			st = 1;
+		    }
+		    nch = _GETC_(file);
+	        }
+		break;
+	    case 'n': {
+ 		    if (!suppress) {
+			int*n = va_arg(ap, int*);
+			*n = rd;
+		    }
+	        }
+		break;
+	    case '[': {
+                    _CHAR_ *str = suppress ? NULL : va_arg(ap, _CHAR_*);
+                    _CHAR_ *sptr = str;
+		    RTL_BITMAP bitMask;
+                    LPBYTE Mask;
+		    int invert = 0; /* Set if we are NOT to find the chars */
+
+		    /* Init our bitmap */
+#ifdef WIDE_SCANF
+		    Mask = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 65536/8);
+		    RtlInitializeBitMap(&bitMask, Mask, 65536);
+#else /* WIDE_SCANF */
+		    Mask = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 256/8);
+		    RtlInitializeBitMap(&bitMask, Mask, 256);
+#endif /* WIDE_SCANF */
+
+		    /* Read the format */
+		    format++;
+		    if(*format == '^') {
+			invert = 1;
+			format++;
+		    }
+		    if(*format == ']') {
+			RtlSetBits(&bitMask, ']', 1);
+			format++;
+		    }
+                    while(*format && (*format != ']')) {
+			if((*format == '-') && (*(format + 1) != ']')) {
+			    int n = 0;
+			    for(;(n + *(format - 1)) < *(format + 1); n++)
+				RtlSetBits(&bitMask, n + *(format - 1), 1);
+			    format++;
+			}
+			RtlSetBits(&bitMask, *format, 1);
+			format++;
+		    }
+                    /* read until char is not suitable */
+                    while ((width != 0) && (nch != _EOF_)) {
+			if(!invert) {
+			    if(RtlAreBitsSet(&bitMask, nch, 1)) {
+#ifdef WIDE_SCANF
+				if (!suppress) *sptr++ = _CONVERT_(nch);
+#else /* WIDE_SCANF */
+				if (!suppress) *sptr++ = nch;
+#endif /* WIDE_SCANF */
+			    } else
+				break;
+			} else {
+			    if(RtlAreBitsClear(&bitMask, nch, 1)) {
+#ifdef WIDE_SCANF
+				if (!suppress) *sptr++ = _CONVERT_(nch);
+#else /* WIDE_SCANF */
+				if (!suppress) *sptr++ = nch;
+#endif /* WIDE_SCANF */
+			    } else
+				break;
+			}
+                        st++;
+                        nch = _GETC_(file);
+                        if (width>0) width--;
+                    }
+                    /* terminate */
+                    if (!suppress) *sptr = 0;
+		    HeapFree(GetProcessHeap(), 0, Mask);
+                }
+                break;
+            default:
+		/* From spec: "if a percent sign is followed by a character
+		 * that has no meaning as a format-control character, that
+		 * character and the following characters are treated as
+		 * an ordinary sequence of characters, that is, a sequence
+		 * of characters that must match the input.  For example,
+		 * to specify that a percent-sign character is to be input,
+		 * use %%." */
+                while ((nch!=_EOF_) && _ISSPACE_(nch))
+                    nch = _GETC_(file);
+                if (nch==*format) {
+                    suppress = 1; /* whoops no field to be read */
+                    st = 1; /* but we got what we expected */
+                    nch = _GETC_(file);
+                }
+                break;
+            }
+            if (st && !suppress) rd++;
+            else if (!st) break;
+        }
+	/* a non-white-space character causes scanf to read, but not store,
+	 * a matching non-white-space character. */
+        else {
+            /* check for character match */
+            if (nch == *format) {
+		nch = _GETC_(file);
+            } else break;
+        }
+        format++;
+    }
+    if (nch!=_EOF_) {
+	_UNGETC_(nch, file);
+    }
+    va_end(ap);
+    TRACE("returning %d\n", rd);
+    return rd;
+}
+
+#undef _CHAR_
+#undef _EOF_
+#undef _ISSPACE_
+#undef _ISDIGIT_
+#undef _CONVERT_
+#undef _CHAR2DIGIT_
+#undef _GETC_
+#undef _UNGETC_
+#undef _FUNCTION_
Index: trunk/src/msvcrt/string.c
===================================================================
--- trunk/src/msvcrt/string.c	(revision 9633)
+++ trunk/src/msvcrt/string.c	(revision 9633)
@@ -0,0 +1,117 @@
+/*
+ * MSVCRT string functions
+ *
+ * Copyright 1996,1998 Marcus Meissner
+ * Copyright 1996 Jukka Iivonen
+ * Copyright 1997,2000 Uwe Bonnes
+ * Copyright 2000 Jon Griffiths
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "msvcrt.h"
+#include "msvcrt/stdlib.h"
+#include "msvcrt/string.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
+
+/* INTERNAL: MSVCRT_malloc() based strndup */
+char* msvcrt_strndup(const char* buf, unsigned int size)
+{
+  char* ret;
+  unsigned int len = strlen(buf), max_len;
+
+  max_len = size <= len? size : len + 1;
+
+  ret = MSVCRT_malloc(max_len);
+  if (ret)
+  {
+    memcpy(ret,buf,max_len);
+    ret[max_len] = 0;
+  }
+  return ret;
+}
+
+/*********************************************************************
+ *		_mbsdup (MSVCRT.@)
+ *		_strdup (MSVCRT.@)
+ */
+char* _strdup(const char* str)
+{
+    char * ret = MSVCRT_malloc(strlen(str)+1);
+    if (ret) strcpy( ret, str );
+    return ret;
+}
+
+/*********************************************************************
+ *		_strnset (MSVCRT.@)
+ */
+char* _strnset(char* str, int value, unsigned int len)
+{
+  if (len > 0 && str)
+    while (*str && len--)
+      *str++ = value;
+  return str;
+}
+
+/*********************************************************************
+ *		_strrev (MSVCRT.@)
+ */
+char* _strrev(char* str)
+{
+  char * p1;
+  char * p2;
+
+  if (str && *str)
+    for (p1 = str, p2 = str + strlen(str) - 1; p2 > p1; ++p1, --p2)
+    {
+      *p1 ^= *p2;
+      *p2 ^= *p1;
+      *p1 ^= *p2;
+    }
+
+  return str;
+}
+
+/*********************************************************************
+ *		_strset (MSVCRT.@)
+ */
+char* _strset(char* str, int value)
+{
+  char *ptr = str;
+  while (*ptr)
+    *ptr++ = value;
+
+  return str;
+}
+
+/*********************************************************************
+ *		_swab (MSVCRT.@)
+ */
+void _swab(char* src, char* dst, int len)
+{
+  if (len > 1)
+  {
+    len = (unsigned)len >> 1;
+
+    while (len--) {
+      *dst++ = src[1];
+      *dst++ = *src++;
+      src++;
+    }
+  }
+}
Index: trunk/src/msvcrt/thread.c
===================================================================
--- trunk/src/msvcrt/thread.c	(revision 9633)
+++ trunk/src/msvcrt/thread.c	(revision 9633)
@@ -0,0 +1,137 @@
+/*
+ * msvcrt.dll thread functions
+ *
+ * Copyright 2000 Jon Griffiths
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#include "msvcrt.h"
+
+#include "msvcrt/malloc.h"
+#include "msvcrt/process.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
+
+/********************************************************************/
+
+typedef struct {
+  _beginthread_start_routine_t start_address;
+  void *arglist;
+} _beginthread_trampoline_t;
+
+/*********************************************************************
+ *		msvcrt_get_thread_data
+ *
+ * Return the thread local storage structure.
+ */
+MSVCRT_thread_data *msvcrt_get_thread_data(void)
+{
+    MSVCRT_thread_data *ptr;
+    DWORD err = GetLastError();  /* need to preserve last error */
+
+    if (!(ptr = TlsGetValue( MSVCRT_tls_index )))
+    {
+        if (!(ptr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ptr) )))
+            MSVCRT__amsg_exit(16);
+        if (!TlsSetValue( MSVCRT_tls_index, ptr )) MSVCRT__amsg_exit(16);
+    }
+    SetLastError( err );
+    return ptr;
+}
+
+
+/*********************************************************************
+ *		_beginthread_trampoline
+ */
+static DWORD CALLBACK _beginthread_trampoline(LPVOID arg)
+{
+    _beginthread_trampoline_t local_trampoline;
+
+    /* Maybe it's just being paranoid, but freeing arg right
+     * away seems safer.
+     */
+    memcpy(&local_trampoline,arg,sizeof(local_trampoline));
+    MSVCRT_free(arg);
+
+    local_trampoline.start_address(local_trampoline.arglist);
+    return 0;
+}
+
+/*********************************************************************
+ *		_beginthread (MSVCRT.@)
+ */
+unsigned long MSVCRT_beginthread(
+  _beginthread_start_routine_t start_address, /* [in] Start address of routine that begins execution of new thread */
+  unsigned int stack_size, /* [in] Stack size for new thread or 0 */
+  void *arglist)           /* [in] Argument list to be passed to new thread or NULL */
+{
+  _beginthread_trampoline_t* trampoline;
+
+  TRACE("(%p, %d, %p)\n", start_address, stack_size, arglist);
+
+  /* Allocate the trampoline here so that it is still valid when the thread
+   * starts... typically after this function has returned.
+   * _beginthread_trampoline is responsible for freeing the trampoline
+   */
+  trampoline=MSVCRT_malloc(sizeof(*trampoline));
+  trampoline->start_address = start_address;
+  trampoline->arglist = arglist;
+
+  /* FIXME */
+  return CreateThread(NULL, stack_size, _beginthread_trampoline, trampoline, 0, NULL);
+}
+
+/*********************************************************************
+ *		_beginthreadex (MSVCRT.@)
+ */
+unsigned long _beginthreadex(
+  void *security,          /* [in] Security descriptor for new thread; must be NULL for Windows 9x applications */
+  unsigned int stack_size, /* [in] Stack size for new thread or 0 */
+  _beginthreadex_start_routine_t start_address, /* [in] Start address of routine that begins execution of new thread */
+  void *arglist,           /* [in] Argument list to be passed to new thread or NULL */
+  unsigned int initflag,   /* [in] Initial state of new thread (0 for running or CREATE_SUSPEND for suspended) */
+  unsigned int *thrdaddr)  /* [out] Points to a 32-bit variable that receives the thread identifier */
+{
+  TRACE("(%p, %d, %p, %p, %d, %p)\n", security, stack_size, start_address, arglist, initflag, thrdaddr);
+
+  /* FIXME */
+  return CreateThread(security, stack_size, (LPTHREAD_START_ROUTINE) start_address,
+                      arglist, initflag, (LPDWORD) thrdaddr);
+}
+
+/*********************************************************************
+ *		MSVCRT_endthread (MSVCRT.@)
+ */
+void MSVCRT_endthread(void)
+{
+  TRACE("(void)\n");
+
+  /* FIXME */
+  ExitThread(0);
+}
+
+/*********************************************************************
+ *		_endthreadex (MSVCRT.@)
+ */
+void _endthreadex(
+  unsigned int retval) /* [in] Thread exit code */
+{
+  TRACE("(%d)\n", retval);
+
+  /* FIXME */
+  ExitThread(retval);
+}
Index: trunk/src/msvcrt/time.c
===================================================================
--- trunk/src/msvcrt/time.c	(revision 9633)
+++ trunk/src/msvcrt/time.c	(revision 9633)
@@ -0,0 +1,151 @@
+/*
+ * msvcrt.dll date/time functions
+ *
+ * Copyright 1996,1998 Marcus Meissner
+ * Copyright 1996 Jukka Iivonen
+ * Copyright 1997,2000 Uwe Bonnes
+ * Copyright 2000 Jon Griffiths
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#ifdef __WIN32OS2__
+#include <emxheader.h>
+#include <sys/times.h>
+#else
+#include "config.h"
+#endif
+
+#include <time.h>
+#ifdef HAVE_SYS_TIMES_H
+# include <sys/times.h>
+#endif
+
+#include "msvcrt.h"
+#include "msvcrt/sys/timeb.h"
+#include "msvcrt/time.h"
+
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
+
+
+/* INTERNAL: Return formatted current time/date */
+char* msvcrt_get_current_time(char* out, const char* format)
+{
+  static const MSVCRT_time_t bad_time = (MSVCRT_time_t)-1;
+  time_t t;
+  struct tm *_tm = NULL;
+  char *retval = NULL;
+
+  if (time(&t) != bad_time && (_tm = localtime(&t)) &&
+      strftime(out,9,format,_tm) == 8)
+    retval = out;
+  return retval;
+}
+
+/**********************************************************************
+ *		mktime (MSVCRT.@)
+ */
+MSVCRT_time_t MSVCRT_mktime(struct MSVCRT_tm *t)
+{
+  MSVCRT_time_t res;
+  struct tm tm;
+
+  tm.tm_sec = t->tm_sec;
+  tm.tm_min = t->tm_min;
+  tm.tm_hour = t->tm_hour;
+  tm.tm_mday = t->tm_mday;
+  tm.tm_mon = t->tm_mon;
+  tm.tm_year = t->tm_year;
+  tm.tm_isdst = t->tm_isdst;
+  res = mktime(&tm);
+  if (res != -1)
+  {
+      t->tm_sec = tm.tm_sec;
+      t->tm_min = tm.tm_min;
+      t->tm_hour = tm.tm_hour;
+      t->tm_mday = tm.tm_mday;
+      t->tm_mon = tm.tm_mon;
+      t->tm_year = tm.tm_year;
+      t->tm_isdst = tm.tm_isdst;
+  }
+  return res;
+}
+
+/**********************************************************************
+ *		_strdate (MSVCRT.@)
+ */
+char* _strdate(char* date)
+{
+  return msvcrt_get_current_time(date,"%m/%d/%y");
+}
+
+/*********************************************************************
+ *		_strtime (MSVCRT.@)
+ */
+char* _strtime(char* date)
+{
+  return msvcrt_get_current_time(date,"%H:%M:%S");
+}
+
+/*********************************************************************
+ *		clock (MSVCRT.@)
+ */
+MSVCRT_clock_t MSVCRT_clock(void)
+{
+  struct tms alltimes;
+  clock_t res;
+
+  times(&alltimes);
+  res = alltimes.tms_utime + alltimes.tms_stime +
+        alltimes.tms_cutime + alltimes.tms_cstime;
+  /* FIXME: We need some symbolic representation for CLOCKS_PER_SEC,
+   *  10 holds only for Windows/Linux_i86)
+   */
+  return 10*res;
+}
+
+/*********************************************************************
+ *		difftime (MSVCRT.@)
+ */
+double MSVCRT_difftime(MSVCRT_time_t time1, MSVCRT_time_t time2)
+{
+    return (double)(time1 - time2);
+}
+
+/*********************************************************************
+ *		time (MSVCRT.@)
+ */
+MSVCRT_time_t MSVCRT_time(MSVCRT_time_t* buf)
+{
+  MSVCRT_time_t curtime = time(NULL);
+  return buf ? *buf = curtime : curtime;
+}
+
+/*********************************************************************
+ *		_ftime (MSVCRT.@)
+ */
+#ifdef __WIN32OS2__
+void MSVCRT_ftime(struct _timeb *buf)
+#else
+void _ftime(struct _timeb *buf)
+#endif
+{
+  buf->time = MSVCRT_time(NULL);
+  buf->millitm = 0; /* FIXME */
+  buf->timezone = 0;
+  buf->dstflag = 0;
+}
Index: trunk/src/msvcrt/wcs.c
===================================================================
--- trunk/src/msvcrt/wcs.c	(revision 9633)
+++ trunk/src/msvcrt/wcs.c	(revision 9633)
@@ -0,0 +1,387 @@
+/*
+ * msvcrt.dll wide-char functions
+ *
+ * Copyright 1999 Alexandre Julliard
+ * Copyright 2000 Jon Griffiths
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#include <limits.h>
+#include <stdio.h>
+#include "msvcrt.h"
+#include "winnls.h"
+#include "wine/unicode.h"
+
+#include "msvcrt/stdio.h"
+#include "msvcrt/stdlib.h"
+#include "msvcrt/string.h"
+#include "msvcrt/wctype.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
+
+
+/* INTERNAL: MSVCRT_malloc() based wstrndup */
+MSVCRT_wchar_t* msvcrt_wstrndup(const MSVCRT_wchar_t *buf, unsigned int size)
+{
+  MSVCRT_wchar_t* ret;
+  unsigned int len = strlenW(buf), max_len;
+
+  max_len = size <= len? size : len + 1;
+
+  ret = MSVCRT_malloc(max_len * sizeof (MSVCRT_wchar_t));
+  if (ret)
+  {
+    memcpy(ret,buf,max_len * sizeof (MSVCRT_wchar_t));
+    ret[max_len] = 0;
+  }
+  return ret;
+}
+
+/*********************************************************************
+ *		_wcsdup (MSVCRT.@)
+ */
+MSVCRT_wchar_t* _wcsdup( const MSVCRT_wchar_t* str )
+{
+  MSVCRT_wchar_t* ret = NULL;
+  if (str)
+  {
+    int size = (strlenW(str) + 1) * sizeof(MSVCRT_wchar_t);
+    ret = MSVCRT_malloc( size );
+    if (ret) memcpy( ret, str, size );
+  }
+  return ret;
+}
+
+/*********************************************************************
+ *		_wcsicoll (MSVCRT.@)
+ */
+INT _wcsicoll( const MSVCRT_wchar_t* str1, const MSVCRT_wchar_t* str2 )
+{
+  /* FIXME: handle collates */
+  return strcmpiW( str1, str2 );
+}
+
+/*********************************************************************
+ *		_wcsnset (MSVCRT.@)
+ */
+MSVCRT_wchar_t* _wcsnset( MSVCRT_wchar_t* str, MSVCRT_wchar_t c, MSVCRT_size_t n )
+{
+  MSVCRT_wchar_t* ret = str;
+  while ((n-- > 0) && *str) *str++ = c;
+  return ret;
+}
+
+/*********************************************************************
+ *		_wcsrev (MSVCRT.@)
+ */
+MSVCRT_wchar_t* _wcsrev( MSVCRT_wchar_t* str )
+{
+  MSVCRT_wchar_t* ret = str;
+  MSVCRT_wchar_t* end = str + strlenW(str) - 1;
+  while (end > str)
+  {
+    MSVCRT_wchar_t t = *end;
+    *end--  = *str;
+    *str++  = t;
+  }
+  return ret;
+}
+
+/*********************************************************************
+ *		_wcsset (MSVCRT.@)
+ */
+MSVCRT_wchar_t* _wcsset( MSVCRT_wchar_t* str, MSVCRT_wchar_t c )
+{
+  MSVCRT_wchar_t* ret = str;
+  while (*str) *str++ = c;
+  return ret;
+}
+
+/*********************************************************************
+ *		_vsnwprintf (MSVCRT.@)
+ */
+int _vsnwprintf(MSVCRT_wchar_t *str, unsigned int len,
+                const MSVCRT_wchar_t *format, va_list valist)
+{
+/* If you fix a bug in this function, fix it in ntdll/wcstring.c also! */
+  unsigned int written = 0;
+  const MSVCRT_wchar_t *iter = format;
+  char bufa[256], fmtbufa[64], *fmta;
+
+  TRACE("(%d,%s)\n",len,debugstr_w(format));
+
+  while (*iter)
+  {
+    while (*iter && *iter != '%')
+    {
+     if (written++ >= len)
+       return -1;
+     *str++ = *iter++;
+    }
+    if (*iter == '%')
+    {
+      fmta = fmtbufa;
+      *fmta++ = *iter++;
+      while (*iter == '0' ||
+             *iter == '+' ||
+             *iter == '-' ||
+             *iter == ' ' ||
+             *iter == '0' ||
+             *iter == '*' ||
+             *iter == '#')
+      {
+        if (*iter == '*')
+        {
+          char *buffiter = bufa;
+          int fieldlen = va_arg(valist, int);
+          sprintf(buffiter, "%d", fieldlen);
+          while (*buffiter)
+            *fmta++ = *buffiter++;
+        }
+        else
+          *fmta++ = *iter;
+        iter++;
+      }
+
+      while (isdigit(*iter))
+        *fmta++ = *iter++;
+
+      if (*iter == '.')
+      {
+        *fmta++ = *iter++;
+        if (*iter == '*')
+        {
+          char *buffiter = bufa;
+          int fieldlen = va_arg(valist, int);
+          sprintf(buffiter, "%d", fieldlen);
+          while (*buffiter)
+            *fmta++ = *buffiter++;
+        }
+        else
+          while (isdigit(*iter))
+            *fmta++ = *iter++;
+      }
+      if (*iter == 'h' ||
+          *iter == 'l')
+          *fmta++ = *iter++;
+
+      switch (*iter)
+      {
+      case 's':
+        {
+          static const MSVCRT_wchar_t none[] = { '(', 'n', 'u', 'l', 'l', ')', 0 };
+          const MSVCRT_wchar_t *wstr = va_arg(valist, const MSVCRT_wchar_t *);
+          const MSVCRT_wchar_t *striter = wstr ? wstr : none;
+          while (*striter)
+          {
+            if (written++ >= len)
+              return -1;
+            *str++ = *striter++;
+          }
+          iter++;
+          break;
+        }
+
+      case 'c':
+        if (written++ >= len)
+          return -1;
+        *str++ = (MSVCRT_wchar_t)va_arg(valist, int);
+        iter++;
+        break;
+
+      default:
+        {
+          /* For non wc types, use system sprintf and append to wide char output */
+          /* FIXME: for unrecognised types, should ignore % when printing */
+          char *bufaiter = bufa;
+          if (*iter == 'p')
+            sprintf(bufaiter, "%08lX", va_arg(valist, long));
+          else
+          {
+            *fmta++ = *iter;
+            *fmta = '\0';
+            if (*iter == 'f')
+              sprintf(bufaiter, fmtbufa, va_arg(valist, double));
+            else
+              sprintf(bufaiter, fmtbufa, va_arg(valist, void *));
+          }
+          while (*bufaiter)
+          {
+            if (written++ >= len)
+              return -1;
+            *str++ = *bufaiter++;
+          }
+          iter++;
+          break;
+        }
+      }
+    }
+  }
+  if (written >= len)
+    return -1;
+  *str++ = 0;
+  return (int)written;
+}
+
+/*********************************************************************
+ *		vswprintf (MSVCRT.@)
+ */
+int MSVCRT_vswprintf( MSVCRT_wchar_t* str, const MSVCRT_wchar_t* format, va_list args )
+{
+  return _vsnwprintf( str, INT_MAX, format, args );
+}
+
+/*********************************************************************
+ *		wcscoll (MSVCRT.@)
+ */
+int MSVCRT_wcscoll( const MSVCRT_wchar_t* str1, const MSVCRT_wchar_t* str2 )
+{
+  /* FIXME: handle collates */
+  return strcmpW( str1, str2 );
+}
+
+/*********************************************************************
+ *		wcspbrk (MSVCRT.@)
+ */
+MSVCRT_wchar_t* MSVCRT_wcspbrk( const MSVCRT_wchar_t* str, const MSVCRT_wchar_t* accept )
+{
+  const MSVCRT_wchar_t* p;
+  while (*str)
+  {
+    for (p = accept; *p; p++) if (*p == *str) return (MSVCRT_wchar_t*)str;
+      str++;
+  }
+  return NULL;
+}
+
+/*********************************************************************
+ *		wctomb (MSVCRT.@)
+ */
+INT MSVCRT_wctomb( char *dst, MSVCRT_wchar_t ch )
+{
+  return WideCharToMultiByte( CP_ACP, 0, &ch, 1, dst, 6, NULL, NULL );
+}
+
+/*********************************************************************
+ *		iswalnum (MSVCRT.@)
+ */
+INT MSVCRT_iswalnum( MSVCRT_wchar_t wc )
+{
+    return isalnumW( wc );
+}
+
+/*********************************************************************
+ *		iswalpha (MSVCRT.@)
+ */
+INT MSVCRT_iswalpha( MSVCRT_wchar_t wc )
+{
+    return isalphaW( wc );
+}
+
+/*********************************************************************
+ *		iswcntrl (MSVCRT.@)
+ */
+INT MSVCRT_iswcntrl( MSVCRT_wchar_t wc )
+{
+    return iscntrlW( wc );
+}
+
+/*********************************************************************
+ *		iswdigit (MSVCRT.@)
+ */
+INT MSVCRT_iswdigit( MSVCRT_wchar_t wc )
+{
+    return isdigitW( wc );
+}
+
+/*********************************************************************
+ *		iswgraph (MSVCRT.@)
+ */
+INT MSVCRT_iswgraph( MSVCRT_wchar_t wc )
+{
+    return isgraphW( wc );
+}
+
+/*********************************************************************
+ *		iswlower (MSVCRT.@)
+ */
+INT MSVCRT_iswlower( MSVCRT_wchar_t wc )
+{
+    return islowerW( wc );
+}
+
+/*********************************************************************
+ *		iswprint (MSVCRT.@)
+ */
+INT MSVCRT_iswprint( MSVCRT_wchar_t wc )
+{
+    return isprintW( wc );
+}
+
+/*********************************************************************
+ *		iswpunct (MSVCRT.@)
+ */
+INT MSVCRT_iswpunct( MSVCRT_wchar_t wc )
+{
+    return ispunctW( wc );
+}
+
+/*********************************************************************
+ *		iswspace (MSVCRT.@)
+ */
+INT MSVCRT_iswspace( MSVCRT_wchar_t wc )
+{
+    return isspaceW( wc );
+}
+
+/*********************************************************************
+ *		iswupper (MSVCRT.@)
+ */
+INT MSVCRT_iswupper( MSVCRT_wchar_t wc )
+{
+    return isupperW( wc );
+}
+
+/*********************************************************************
+ *		iswxdigit (MSVCRT.@)
+ */
+INT MSVCRT_iswxdigit( MSVCRT_wchar_t wc )
+{
+    return isxdigitW( wc );
+}
+
+/*********************************************************************
+ *		_itow (MSVCRT.@)
+ */
+MSVCRT_wchar_t* _itow(int value,MSVCRT_wchar_t* out,int base)
+{
+  char buf[64];
+  _itoa(value, buf, base);
+  MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, buf, -1, out, 128);
+  return out;
+}
+
+/*********************************************************************
+ *		_ltow (MSVCRT.@)
+ */
+MSVCRT_wchar_t* _ltow(long value,MSVCRT_wchar_t* out,int base)
+{
+  char buf[128];
+  _ltoa(value, buf, base);
+  MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, buf, -1, out, 128);
+  return out;
+}
