Index: trunk/src/msvcrt/LICENSE.TXT
===================================================================
--- trunk/src/msvcrt/LICENSE.TXT	(revision 10001)
+++ trunk/src/msvcrt/LICENSE.TXT	(revision 10005)
@@ -1,3 +1,3 @@
-$Id: LICENSE.TXT,v 1.2 2003-01-10 13:13:48 sandervl Exp $
+$Id: LICENSE.TXT,v 1.3 2003-04-10 10:27:59 sandervl Exp $
 This is an additional Odin license agreement.
 It supercedes the main Odin license, but is only valid in 
Index: trunk/src/msvcrt/console.c
===================================================================
--- trunk/src/msvcrt/console.c	(revision 10001)
+++ trunk/src/msvcrt/console.c	(revision 10005)
@@ -29,8 +29,11 @@
 #include "mtdll.h"
 
+#include <stdio.h>
+#include <string.h>
+
 #include "wine/debug.h"
 
+
 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
-
 
 
@@ -74,5 +77,5 @@
  *		_cputs (MSVCRT.@)
  */
-int _cputs(const char* str)
+int MSVCRT__cputs(const char* str)
 {
   DWORD count;
@@ -90,5 +93,5 @@
  *		_getch (MSVCRT.@)
  */
-int _getch(void)
+int MSVCRT__getch(void)
 {
   int retval = MSVCRT_EOF;
@@ -135,5 +138,5 @@
  *		_putch (MSVCRT.@)
  */
-int _putch(int c)
+int MSVCRT__putch(int c)
 {
   int retval = MSVCRT_EOF;
@@ -149,11 +152,11 @@
  *		_getche (MSVCRT.@)
  */
-int _getche(void)
+int MSVCRT__getche(void)
 {
   int retval;
   LOCK_CONSOLE;
-  retval = _getch();
+  retval = MSVCRT__getch();
   if (retval != MSVCRT_EOF)
-    retval = _putch(retval);
+    retval = MSVCRT__putch(retval);
   UNLOCK_CONSOLE;
   return retval;
@@ -163,14 +166,15 @@
  *		_cgets (MSVCRT.@)
  */
-char* _cgets(char* str)
+char* MSVCRT__cgets(char* str)
 {
   char *buf = str + 2;
   int c;
   str[1] = 0; /* Length */
+  dprintf(("MSVCRT: _cgets"));  
   /* FIXME: No editing of string supported */
   LOCK_CONSOLE;
   do
   {
-    if (str[1] >= str[0] || (str[1]++, c = _getche()) == MSVCRT_EOF || c == '\n')
+    if (str[1] >= str[0] || (str[1]++, c = MSVCRT__getche()) == MSVCRT_EOF || c == '\n')
       break;
     *buf++ = c & 0xff;
@@ -184,5 +188,5 @@
  *		_ungetch (MSVCRT.@)
  */
-int _ungetch(int c)
+int MSVCRT__ungetch(int c)
 {
   int retval = MSVCRT_EOF;
@@ -197,8 +201,8 @@
  *		_kbhit (MSVCRT.@)
  */
-int _kbhit(void)
+int MSVCRT__kbhit(void)
 {
   int retval = 0;
-
+  dprintf(("MSVCRT: kbhit()"));
   LOCK_CONSOLE;
   if (__MSVCRT_console_buffer != MSVCRT_EOF)
@@ -235,10 +239,10 @@
  *		_cprintf (MSVCRT.@)
  */
-int _cprintf(const char* format, ...)
+int MSVCRT__cprintf(const char* format, ...)
 {
   char buf[2048], *mem = buf;
   int written, resize = sizeof(buf), retval;
   va_list valist;
-
+  dprintf(("MSVCRT: _cprintf %s",format));
   va_start( valist, format );
   /* There are two conventions for snprintf failing:
@@ -259,5 +263,5 @@
   va_end(valist);
   LOCK_CONSOLE;
-  retval = _cputs( mem );
+  retval = MSVCRT__cputs( mem );
   UNLOCK_CONSOLE;
   if (mem != buf)
Index: trunk/src/msvcrt/cpp.c
===================================================================
--- trunk/src/msvcrt/cpp.c	(revision 10001)
+++ trunk/src/msvcrt/cpp.c	(revision 10005)
@@ -22,9 +22,8 @@
 #include "msvcrt/eh.h"
 #include "msvcrt/stdlib.h"
-
+#include <string.h>
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
-
 
 typedef void (*v_table_ptr)();
@@ -100,5 +99,5 @@
 void MSVCRT_exception_ctor(exception * _this, const char ** name)
 {
-  TRACE("(%p %s)\n",_this,*name);
+  TRACE("MSVCRT: exception_ctor (%p %s)\n",_this,*name);
   _this->vtable = exception_vtable;
   _this->name = *name;
@@ -112,5 +111,5 @@
 void MSVCRT_exception_copy_ctor(exception * _this, const exception * rhs)
 {
-  TRACE("(%p %p)\n",_this,rhs);
+  TRACE("MSVCRT: exception_copy_ctor (%p %p)\n",_this,rhs);
   if (_this != rhs)
     memcpy (_this, rhs, sizeof (*_this));
@@ -123,5 +122,5 @@
 void MSVCRT_exception_default_ctor(exception * _this)
 {
-  TRACE("(%p)\n",_this);
+  TRACE("MSVCRT: exception_default_ctor (%p)\n",_this);
   _this->vtable = exception_vtable;
   _this->name = "";
@@ -134,5 +133,5 @@
 void MSVCRT_exception_dtor(exception * _this)
 {
-  TRACE("(%p)\n",_this);
+  TRACE("MSVCRT: exception_dtor(%p)\n",_this);
 }
 
@@ -500,5 +499,5 @@
 {
   /* Note: cppobj _isn't_ a type_info, we use that struct for its vtable ptr */
-  TRACE("(%p)\n",cppobj);
+  TRACE("MSVCRT: ___RTCastToVoid (%p)\n",cppobj);
 
   /* Casts to void* simply cast to the base object */
Index: trunk/src/msvcrt/cppexcept.c
===================================================================
--- trunk/src/msvcrt/cppexcept.c	(revision 10001)
+++ trunk/src/msvcrt/cppexcept.c	(revision 10005)
@@ -25,4 +25,5 @@
 #ifdef __WIN32OS2__
 #include <emxheader.h>
+#include <string.h>
 #include "winbase.h"
 #else
@@ -38,99 +39,7 @@
 #include "wine/debug.h"
 
+#include "cppexcept.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 */
@@ -170,15 +79,15 @@
 
 
-static void dump_type( cxx_type_info *type )
+static void dump_type( const 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 );
+    if (type->type_info) DPRINTF( " (%p %s)", type->type_info->name, type->type_info->mangled );
     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;
+static void dump_exception_type( const cxx_exception_type *type )
+{
+    UINT i;
 
     DPRINTF( "exception type:\n" );
@@ -192,7 +101,8 @@
 }
 
-static void dump_function_descr( cxx_function_descr *descr, cxx_exception_type *info )
-{
-    int i, j;
+static void dump_function_descr( const cxx_function_descr *descr, const cxx_exception_type *info )
+{
+    UINT i;
+    int j;
 
     DPRINTF( "function descr:\n" );
@@ -216,5 +126,5 @@
             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 );
+            if (ptr->type_info) DPRINTF( " (%p %s)", ptr->type_info->name, ptr->type_info->mangled );
             DPRINTF( "\n" );
         }
@@ -223,5 +133,5 @@
 
 /* compute the this pointer for a base class of a given type */
-static void *get_this_pointer( cxx_type_info *type, void *object )
+static void *get_this_pointer( const cxx_type_info *type, void *object )
 {
     void *this_ptr;
@@ -242,5 +152,5 @@
 
 /* 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 )
+static const cxx_type_info *find_caught_type( cxx_exception_type *exc_type, catchblock_info *catchblock )
 {
     UINT i;
@@ -248,10 +158,10 @@
     for (i = 0; i < exc_type->type_info_table->count; i++)
     {
-        cxx_type_info *type = exc_type->type_info_table->info[i];
+        const 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;
+            if (strcmp( catchblock->type_info->mangled, type->type_info->mangled )) continue;
         }
         /* type is the same, now check the flags */
@@ -268,9 +178,9 @@
 /* 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 )
+                            catchblock_info *catchblock, const cxx_type_info *type )
 {
     void **dest_ptr;
 
-    if (!catchblock->type_info || !catchblock->type_info->name[0]) return;
+    if (!catchblock->type_info || !catchblock->type_info->mangled[0]) return;
     if (!catchblock->offset) return;
     dest_ptr = (void **)((char *)&frame->ebp + catchblock->offset);
@@ -357,5 +267,6 @@
                                       cxx_exception_type *info )
 {
-    int i, j;
+    UINT i;
+    int j;
     void *addr, *object = (void *)rec->ExceptionInformation[1];
     struct catch_func_nested_frame nested_frame;
@@ -374,5 +285,5 @@
         {
             catchblock_info *catchblock = &tryblock->catchblock[j];
-            cxx_type_info *type = find_caught_type( info, catchblock );
+            const cxx_type_info *type = find_caught_type( info, catchblock );
             if (!type) continue;
 
@@ -497,5 +408,5 @@
  *		_CxxThrowException (MSVCRT.@)
  */
-void _CxxThrowException( void *object, cxx_exception_type *type )
+void _CxxThrowException( void *object, const cxx_exception_type *type )
 {
     DWORD args[3];
@@ -506,2 +417,33 @@
     RaiseException( CXX_EXCEPTION, EH_NONCONTINUABLE, 3, args );
 }
+
+/*********************************************************************
+ *		__CxxDetectRethrow (MSVCRT.@)
+ */
+BOOL __CxxDetectRethrow(PEXCEPTION_POINTERS ptrs)
+{
+  PEXCEPTION_RECORD rec;
+
+  if (!ptrs)
+    return FALSE;
+
+  rec = ptrs->ExceptionRecord;
+
+  if (rec->ExceptionCode == CXX_EXCEPTION &&
+      rec->NumberParameters == 3 &&
+      rec->ExceptionInformation[0] == CXX_FRAME_MAGIC &&
+      rec->ExceptionInformation[2])
+  {
+    ptrs->ExceptionRecord = msvcrt_get_thread_data()->exc_record;
+    return TRUE;
+  }
+  return (msvcrt_get_thread_data()->exc_record == rec);
+}
+
+/*********************************************************************
+ *		__CxxQueryExceptionSize (MSVCRT.@)
+ */
+unsigned int __CxxQueryExceptionSize(void)
+{
+  return sizeof(cxx_exception_type);
+}
Index: trunk/src/msvcrt/cppexcept.h
===================================================================
--- trunk/src/msvcrt/cppexcept.h	(revision 10005)
+++ trunk/src/msvcrt/cppexcept.h	(revision 10005)
@@ -0,0 +1,124 @@
+/*
+ * 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
+ */
+
+#ifndef __MSVCRT_CPPEXCEPT_H
+#define __MSVCRT_CPPEXCEPT_H
+
+#define CXX_FRAME_MAGIC    0x19930520
+#define CXX_EXCEPTION      0xe06d7363
+
+typedef void (*vtable_ptr)();
+
+/* type_info object, see cpp.c for inplementation */
+typedef struct __type_info
+{
+  vtable_ptr *vtable;
+  char *name;        /* Unmangled name, allocated lazily */
+  char  mangled[32]; /* Variable length, but we declare it large enough for static RTTI */
+} 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;
+
+typedef void (*cxx_copy_ctor)(void);
+
+/* 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 */
+    cxx_copy_ctor 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 */
+    const cxx_type_info *info[3];   /* variable length, we declare it large enough for static RTTI */
+} 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 */
+    const cxx_type_info_table *type_info_table;  /* list of types for this exception object */
+} cxx_exception_type;
+
+void _CxxThrowException(void*,const cxx_exception_type*);
+
+#endif /* __MSVCRT_CPPEXCEPT_H */
Index: trunk/src/msvcrt/ctype.c
===================================================================
--- trunk/src/msvcrt/ctype.c	(revision 10001)
+++ trunk/src/msvcrt/ctype.c	(revision 10005)
@@ -19,6 +19,7 @@
  */
 #include "msvcrt.h"
-
+#include <ctype.h>
 #include "msvcrt/ctype.h"
+
 
 #include "wine/debug.h"
@@ -82,4 +83,5 @@
 int _isctype(int c, int type)
 {
+  dprintf(("MSVCRT: _isctype %d %d",c, type));
   if (c >= -1 && c <= 255)
     return MSVCRT__pctype[c] & type;
Index: trunk/src/msvcrt/data.c
===================================================================
--- trunk/src/msvcrt/data.c	(revision 10001)
+++ trunk/src/msvcrt/data.c	(revision 10005)
@@ -22,9 +22,10 @@
 #else
 #include <emxheader.h>
+#include <math.h>
+#include <string.h>
 #endif
 
 #include "wine/port.h"
 
-#include <math.h>
 #include "msvcrt.h"
 
@@ -69,4 +70,6 @@
 int MSVCRT_timezone;
 int MSVCRT_app_type;
+char MSVCRT_pgm[MAX_PATH];
+char* MSVCRT__pgmptr = 0;
 
 /* Get a snapshot of the current environment
@@ -147,55 +150,60 @@
  *		__p___argc (MSVCRT.@)
  */
-int* __p___argc(void) { return &MSVCRT___argc; }
+int* __p___argc(void) { dprintf(("MSVCRT: Query of p__argc")); return &MSVCRT___argc; }
 
 /***********************************************************************
  *		__p__commode (MSVCRT.@)
  */
-unsigned int* __p__commode(void) { return &MSVCRT__commode; }
+unsigned int* __p__commode(void) { dprintf(("MSVCRT: Query of p__commode"));  return &MSVCRT__commode; }
+
+/***********************************************************************
+ *              __p__pgmptr (MSVCRT.@)
+ */
+char** __p__pgmptr(void) { return &MSVCRT__pgmptr; }
 
 /***********************************************************************
  *		__p__fmode (MSVCRT.@)
  */
-unsigned int* __p__fmode(void) { return &MSVCRT__fmode; }
+unsigned int* __p__fmode(void) {  dprintf(("MSVCRT: Query of p__fmode"));  return &MSVCRT__fmode; }
 
 /***********************************************************************
  *		__p__osver (MSVCRT.@)
  */
-unsigned int* __p__osver(void) { return &MSVCRT__osver; }
+unsigned int* __p__osver(void) {  dprintf(("MSVCRT: Query of p__osver")); return &MSVCRT__osver; }
 
 /***********************************************************************
  *		__p__winmajor (MSVCRT.@)
  */
-unsigned int* __p__winmajor(void) { return &MSVCRT__winmajor; }
+unsigned int* __p__winmajor(void) {  dprintf(("MSVCRT: Query of p__winmajor")); return &MSVCRT__winmajor; }
 
 /***********************************************************************
  *		__p__winminor (MSVCRT.@)
  */
-unsigned int* __p__winminor(void) { return &MSVCRT__winminor; }
+unsigned int* __p__winminor(void) {  dprintf(("MSVCRT: Query of p__winminor")); return &MSVCRT__winminor; }
 
 /***********************************************************************
  *		__p__winver (MSVCRT.@)
  */
-unsigned int* __p__winver(void) { return &MSVCRT__winver; }
+unsigned int* __p__winver(void) {  dprintf(("MSVCRT: Query of p__winver")); return &MSVCRT__winver; }
 
 /*********************************************************************
  *		__p__acmdln (MSVCRT.@)
  */
-char** __p__acmdln(void) { return &MSVCRT__acmdln; }
+char** __p__acmdln(void) {  dprintf(("MSVCRT: Query of p__acmdln")); return &MSVCRT__acmdln; }
 
 /*********************************************************************
  *		__p__wcmdln (MSVCRT.@)
  */
-MSVCRT_wchar_t** __p__wcmdln(void) { return &MSVCRT__wcmdln; }
+MSVCRT_wchar_t** __p__wcmdln(void) {  dprintf(("MSVCRT: Query of p__wcmdln")); return &MSVCRT__wcmdln; }
 
 /*********************************************************************
  *		__p___argv (MSVCRT.@)
  */
-char*** __p___argv(void) { return &MSVCRT___argv; }
+char*** __p___argv(void) {  dprintf(("MSVCRT: Query of p__argv"));  return &MSVCRT___argv; }
 
 /*********************************************************************
  *		__p___wargv (MSVCRT.@)
  */
-MSVCRT_wchar_t*** __p___wargv(void) { return &MSVCRT___wargv; }
+MSVCRT_wchar_t*** __p___wargv(void) {  dprintf(("MSVCRT: Query of p__wargv"));  return &MSVCRT___wargv; }
 
 /*********************************************************************
@@ -204,4 +212,5 @@
 char*** __p__environ(void)
 {
+  dprintf(("MSVCRT: Query of p__environ")); 
   if (!MSVCRT__environ)
     MSVCRT__environ = msvcrt_SnapshotOfEnvironmentA(NULL);
@@ -214,4 +223,5 @@
 MSVCRT_wchar_t*** __p__wenviron(void)
 {
+  dprintf(("MSVCRT: Query of p__wenviron")); 
   if (!MSVCRT__wenviron)
     MSVCRT__wenviron = msvcrt_SnapshotOfEnvironmentW(NULL);
@@ -222,15 +232,15 @@
  *		__p___initenv (MSVCRT.@)
  */
-char*** __p___initenv(void) { return &MSVCRT___initenv; }
+char*** __p___initenv(void) {  dprintf(("MSVCRT: Query of p__initenv")); return &MSVCRT___initenv; }
 
 /*********************************************************************
  *		__p___winitenv (MSVCRT.@)
  */
-MSVCRT_wchar_t*** __p___winitenv(void) { return &MSVCRT___winitenv; }
+MSVCRT_wchar_t*** __p___winitenv(void) {  dprintf(("MSVCRT: Query of p__winitenv")); return &MSVCRT___winitenv; }
 
 /*********************************************************************
  *		__p__timezone (MSVCRT.@)
  */
-int* __p__timezone(void) { return &MSVCRT_timezone; }
+int* __p__timezone(void) {  dprintf(("MSVCRT: Query of p__timezone")); return &MSVCRT_timezone; }
 
 /* INTERNAL: Create a wide string from an ascii string */
@@ -238,4 +248,5 @@
 {
   const size_t len = strlen(str) + 1 ;
+  dprintf(("MSVCRT: wstrdupa %s",str)); 
   MSVCRT_wchar_t *wstr = MSVCRT_malloc(len* sizeof (MSVCRT_wchar_t));
   if (!wstr)
@@ -252,6 +263,4 @@
 static WCHAR **__wine_main_wargv = NULL;
 char *argv[255];
-
-extern char* strtok(char*,const char*);
 
 static void set_library_argv( char **incargv)
@@ -313,5 +322,5 @@
   DWORD version;
 
-  MSVCRT__acmdln = _strdup( GetCommandLineA() );
+  MSVCRT__acmdln = MSVCRT__strdup( GetCommandLineA() );
   MSVCRT__wcmdln = wstrdupa(MSVCRT__acmdln);
 #ifdef __WIN32OS2__
@@ -342,9 +351,10 @@
   MSVCRT_timezone = 0;
 
-  /* FIXME: set app type for Winelib apps */
-
   MSVCRT___initenv= msvcrt_SnapshotOfEnvironmentA(NULL);
   MSVCRT___winitenv= msvcrt_SnapshotOfEnvironmentW(NULL);
 
+  MSVCRT_pgm[0] = '\0';
+  GetModuleFileNameA(0, MSVCRT_pgm, sizeof(MSVCRT_pgm)/sizeof(MSVCRT_pgm[0]));
+  MSVCRT__pgmptr = MSVCRT_pgm;
 }
 
Index: trunk/src/msvcrt/dbgcalls.c
===================================================================
--- trunk/src/msvcrt/dbgcalls.c	(revision 10005)
+++ trunk/src/msvcrt/dbgcalls.c	(revision 10005)
@@ -0,0 +1,244 @@
+#ifdef __WIN32OS2__
+#include <winbase.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <string.h>
+#endif
+
+#include "wine/unicode.h"
+#include "msvcrt.h"
+
+#include "msvcrt/stdlib.h"
+
+
+#include "wine/debug.h"
+
+char *dbgemx__gcvt (double a, int b, char * c)
+{ 
+ char *ret;
+ dprintf(("MSVCRT: _gcvt %f, %d %s", a, b, c));
+ ret = emx__gcvt(a, b, c);
+ dprintf(("MSVCRT: dbgemx_gcvt returned %s", ret));
+ return ret; 
+}
+
+double _emx__hypot (double, double);
+
+double _dbgemx__hypot (double a, double b)
+{
+ double ret;
+ dprintf(("MSVCRT: _hypot %f, %f", a, b));
+ ret = _emx__hypot(a, b);
+ dprintf(("MSVCRT: _hypot returned %f", ret));
+ return ret; 
+}
+
+char *dbgemx__itoa(int a,char *b, int c)
+{
+ char *ret;
+ dprintf(("MSVCRT: _itoa %d, %s %d", a, b, c));
+ ret =emx__itoa(a, b, c);
+ dprintf(("MSVCRT: _itoa returned %s", ret));
+ return ret; 
+}
+
+char *dbgemx__ltoa(long a,char *b, int c)
+{
+ char *ret;
+ dprintf(("MSVCRT: _ltoa %d, %s %d", a, b, c));
+ ret =emx__ltoa(a, b, c);
+ dprintf(("MSVCRT: _ltoa returned %s", ret));
+ return ret; 
+}
+
+char *dbgemx_strcpy (char * a, const char * b)
+{
+ char *ret;
+ dprintf(("MSVCRT: strcpy %s, %s", a, b));
+ ret =emx_strcpy(a, b);
+ dprintf(("MSVCRT: strcpy returned %s", ret));
+ return ret; 
+}
+
+char *dbgemx_strncpy (char * a, const char * b, size_t c)
+{
+ char *ret;
+ dprintf(("MSVCRT: strncpy %p, %s, %d", a, b, c));
+ ret =emx_strncpy(a, b, c);
+ dprintf(("MSVCRT: strncpy returned %s", ret));
+ return ret; 
+}
+
+char *dbgemx_strcat (char * a, const char * b)
+{
+ char *ret;
+ dprintf(("MSVCRT: strcat %s, %s", a, b));
+ ret =emx_strcat(a, b);
+ dprintf(("MSVCRT: strcat returned %s", ret));
+ return ret; 
+}
+
+char *dbgemx_strncat (char * a, const char * b, size_t c)
+{
+ char *ret;
+ dprintf(("MSVCRT: strncat %s, %s, %d", a, b, c));
+ ret =emx_strncat(a, b, c);
+ dprintf(("MSVCRT: strncat returned %s", ret));
+ return ret; 
+}
+
+char *dbgemx_strstr (const char * a, const char * b)
+{
+ char *ret;
+ dprintf(("MSVCRT: strstr %s, %s", a, b));
+ ret =emx_strstr(a, b);
+ dprintf(("MSVCRT: strstr returned %s", ret));
+ return ret; 
+}
+
+char *dbgemx__strupr (char * a)
+{
+ char *ret;
+ dprintf(("MSVCRT: strupr %s", a));
+ ret =emx__strupr(a);
+ dprintf(("MSVCRT: strupr returned %s", ret));
+ return ret; 
+}
+
+char *dbgemx__strlwr (char * a)
+{
+ char *ret;
+ dprintf(("MSVCRT: strlwr %s", a));
+ ret =emx__strlwr(a);
+ dprintf(("MSVCRT: strlwr returned %s", ret));
+ return ret; 
+}
+
+void *dbgemx__memccpy (void * a, const void *b, int c, size_t d)
+{
+ void *ret;
+ dprintf(("MSVCRT: _memccpy %p %p %d %d", a, b, c, d));
+ ret =emx__memccpy(a, b, c, d);
+ dprintf(("MSVCRT: _memccpy returned %p", ret));
+ return ret; 
+}
+
+void *dbgemx_bsearch (const void * a, const void *b, size_t c, size_t d,
+    int (*e)(const void *, const void *))
+{
+ void *ret;
+ dprintf(("MSVCRT: bsearch %p %p %d %d %p", a, b, c, d, e));
+ ret = bsearch(a, b, c, d, e);
+ dprintf(("MSVCRT: bsearch returned %p", ret));
+ return ret; 
+}
+
+void dbgemx_qsort (void *a, size_t b, size_t c,
+    int (*d)(__const__ void *, __const__ void *))
+{
+ dprintf(("MSVCRT: qsort %p %d %d %p", a, b, c, d));
+ qsort(a, b, c, d);
+}
+
+int dbgemx_vsprintf (char * a, const char * b, va_list c)
+{
+ int ret;
+ dprintf(("MSVCRT: vsprintf %s %s %p", a, b, c));
+ ret = vsprintf(a, b, c);
+ dprintf(("MSVCRT: vsprintf returned %d", ret));
+ return ret; 
+}
+
+int dbgemx__vsnprintf (char * a, size_t b, const char * c, va_list d)
+{
+ int ret;
+ dprintf(("MSVCRT: _vsnprintf %p %d %s %p", a, b, c, d));
+ ret = _vsnprintf(a, b, c, d);
+ dprintf(("MSVCRT: _vsnprintf returned %d", ret));
+ return ret; 
+}
+
+char *dbgemx__ultoa (unsigned long a, char * b, int c)
+{
+ char *ret;
+ dprintf(("MSVCRT: _ultoa %ld %p %d", a, b, c));
+ ret =emx__ultoa(a, b, c);
+ dprintf(("MSVCRT: _ultoa returned %s", ret));
+ return ret; 
+}
+
+double dbgemx_floor (double a)
+{
+ double ret;
+ dprintf(("MSVCRT: floor %f", a));
+ ret = floor(a);
+ dprintf(("MSVCRT: floor returned %f", ret));
+ return ret;
+}
+
+int dbgemx_atoi (const char * a)
+{
+ int ret;
+ dprintf(("MSVCRT: atoi %s", a));
+ ret = atoi(a);
+ dprintf(("MSVCRT: atoi returned %d", ret));
+ return ret; 
+}
+
+int dbgemx_atol (const char * a)
+{
+ long ret;
+ dprintf(("MSVCRT: atol %s", a));
+ ret = atol(a);
+ dprintf(("MSVCRT: atol returned %d", ret));
+ return ret; 
+}
+
+double dbgemx_fabs (double a)
+{
+ double ret;
+ dprintf(("MSVCRT: fabs %f", a));
+ ret = fabs(a);
+ dprintf(("MSVCRT: fabs returned %f", ret));
+ return ret;
+}
+
+int dbgemx__stricmp (const char *a, const char *b)
+{
+ int ret;
+ dprintf(("MSVCRT: _stricmp %s, %s", a, b));
+ ret =emx__stricmp(a, b);
+ dprintf(("MSVCRT: stricmp returned %d", ret));
+ return ret; 
+}
+
+int dbgemx__strnicmp (const char *a, const char *b, size_t c)
+{
+ int ret;
+ dprintf(("MSVCRT: _strnicmp %s, %s, %d", a, b, c));
+ ret =emx__strnicmp(a, b, c);
+ dprintf(("MSVCRT: _strnicmp returned %d", ret));
+ return ret; 
+}
+
+char *dbgemx_strchr (const char *a, int b)
+{
+ char *ret;
+ dprintf(("MSVCRT: strchr %a, %d", a, b));
+ ret =emx_strchr(a, b);
+ dprintf(("MSVCRT: strchr returned %s", ret));
+ return ret; 
+}
+
+
+int dbgemx_strcmp (const char *a, const char *b)
+{
+ int ret;
+ dprintf(("MSVCRT: strcmp %s, %s", a, b));
+ ret =emx_strcmp(a, b);
+ dprintf(("MSVCRT: strcmp returned %d", ret));
+ return ret; 
+}
Index: trunk/src/msvcrt/dir.c
===================================================================
--- trunk/src/msvcrt/dir.c	(revision 10001)
+++ trunk/src/msvcrt/dir.c	(revision 10005)
@@ -23,4 +23,7 @@
 #ifdef __WIN32OS2__
 #include <emxheader.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
 #include <winbase.h>
 #else
@@ -90,5 +93,5 @@
  *		_chdir (MSVCRT.@)
  */
-int _chdir(const char * newdir)
+int MSVCRT__chdir(const char * newdir)
 {
   if (!SetCurrentDirectoryA(newdir))
@@ -116,5 +119,5 @@
  *		_chdrive (MSVCRT.@)
  */
-int _chdrive(int newdrive)
+int MSVCRT__chdrive(int newdrive)
 {
   char buffer[3] = "A:";
@@ -219,5 +222,5 @@
  *		_getcwd (MSVCRT.@)
  */
-char* _getcwd(char * buf, int size)
+char* MSVCRT__getcwd(char * buf, int size)
 {
   char dir[MAX_PATH];
@@ -230,5 +233,5 @@
   {
     if (size < 0)
-      return _strdup(dir);
+      return MSVCRT__strdup(dir);
     return msvcrt_strndup(dir,size);
   }
@@ -271,5 +274,5 @@
  *		_getdrive (MSVCRT.@)
  */
-int _getdrive(void)
+int MSVCRT__getdrive(void)
 {
     char buffer[MAX_PATH];
@@ -282,5 +285,5 @@
  *		_getdcwd (MSVCRT.@)
  */
-char* _getdcwd(int drive, char * buf, int size)
+char* MSVCRT__getdcwd(int drive, char * buf, int size)
 {
   static char* dummy;
@@ -288,6 +291,6 @@
   TRACE(":drive %d(%c), size %d\n",drive, drive + 'A' - 1, size);
 
-  if (!drive || drive == _getdrive())
-    return _getcwd(buf,size); /* current */
+  if (!drive || drive == MSVCRT__getdrive())
+    return MSVCRT__getcwd(buf,size); /* current */
   else
   {
@@ -312,5 +315,5 @@
     TRACE(":returning '%s'\n", dir);
     if (!buf)
-      return _strdup(dir); /* allocate */
+      return MSVCRT__strdup(dir); /* allocate */
 
     strcpy(buf,dir);
@@ -328,5 +331,5 @@
   TRACE(":drive %d(%c), size %d\n",drive, drive + 'A' - 1, size);
 
-  if (!drive || drive == _getdrive())
+  if (!drive || drive == MSVCRT__getdrive())
     return _wgetcwd(buf,size); /* current */
   else
@@ -388,5 +391,5 @@
  *		_mkdir (MSVCRT.@)
  */
-int _mkdir(const char * newdir)
+int MSVCRT__mkdir(const char * newdir)
 {
   if (CreateDirectoryA(newdir,NULL))
@@ -410,5 +413,5 @@
  *		_rmdir (MSVCRT.@)
  */
-int _rmdir(const char * dir)
+int MSVCRT__rmdir(const char * dir)
 {
   if (RemoveDirectoryA(dir))
@@ -439,5 +442,5 @@
   MSVCRT_wchar_t pathbuff[MAX_PATH],*path=pathbuff;
 
-  TRACE(":splitting path %s\n",debugstr_w(path));
+  TRACE("MSVCRT: _wsplitpath %s\n",debugstr_w(path));
   /* FIXME: Should be an strncpyW or something */
   strcpyW(pathbuff, inpath);
@@ -586,5 +589,5 @@
       if (q > r)
       {
-	strcpy(q, p + 3);
+        strcpy(q, p + 3);
 	s = q;
       }
@@ -622,5 +625,5 @@
  *		_fullpath (MSVCRT.@)
  */
-char *_fullpath(char * absPath, const char* relPath, unsigned int size)
+char *MSVCRT__fullpath(char * absPath, const char* relPath, unsigned int size)
 {
   char drive[5],dir[MAX_PATH],file[MAX_PATH],ext[MAX_PATH];
@@ -631,5 +634,5 @@
 
   if (!relPath || !*relPath)
-    return _getcwd(absPath, size);
+    return MSVCRT__getcwd(absPath, size);
 
   if (size < 4)
@@ -639,5 +642,5 @@
   }
 
-  TRACE(":resolving relative path '%s'\n",relPath);
+  TRACE("MSVCRT: _fullpath '%s'\n",relPath);
 
   _splitpath(relPath, drive, dir, file, ext);
@@ -670,5 +673,5 @@
 
   if (!absPath)
-    return _strdup(res);
+    return MSVCRT__strdup(res);
   strcpy(absPath,res);
   return absPath;
@@ -678,5 +681,5 @@
  *		_makepath (MSVCRT.@)
  */
-VOID _makepath(char * path, const char * drive,
+VOID MSVCRT__makepath(char * path, const char * drive,
                               const char *directory, const char * filename,
                               const char * extension )
@@ -767,5 +770,5 @@
  *		_searchenv (MSVCRT.@)
  */
-void _searchenv(const char* file, const char* env, char *buf)
+void MSVCRT__searchenv(const char* file, const char* env, char *buf)
 {
   char*envVal, *penv;
@@ -824,2 +827,18 @@
   } while(1);
 }
+
+MSVCRT_wchar_t* _wfullpath(MSVCRT_wchar_t* absPath,const MSVCRT_wchar_t* relPath,MSVCRT(size_t) size)
+{
+   MSVCRT_wchar_t ch;
+   char asciiabsPath[280], asciirelPath[280];
+
+   TRACE("MSVCRT: _wfullpath %s %d\n", debugstr_w(relPath),size);
+
+   WideCharToMultiByte(CP_ACP, 0, relPath, -1, (LPSTR)asciirelPath, 280, NULL, NULL);
+   
+   MSVCRT__fullpath(asciiabsPath, asciirelPath, size);
+   
+   MultiByteToWideChar(CP_ACP, 0, asciiabsPath, -1, absPath, size);
+
+   return absPath;  
+}
Index: trunk/src/msvcrt/emxheader.h
===================================================================
--- trunk/src/msvcrt/emxheader.h	(revision 10001)
+++ trunk/src/msvcrt/emxheader.h	(revision 10005)
@@ -2,66 +2,4 @@
 #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
Index: trunk/src/msvcrt/environ.c
===================================================================
--- trunk/src/msvcrt/environ.c	(revision 10001)
+++ trunk/src/msvcrt/environ.c	(revision 10005)
@@ -23,4 +23,5 @@
 #ifdef __WIN32OS2__
 #include <winbase.h>
+#include <string.h>
 #endif
 
@@ -44,4 +45,6 @@
   unsigned int length=strlen(name);
 
+  dprintf(("MSVCRT: %s",name));
+
   for (pp = environ; (*pp); pp = pp + strlen(pp) +1)
   {
@@ -49,5 +52,5 @@
       if ((pos) && ((pos - pp) == length))
       {
-          if (!strncasecmp(pp,name,length)) break;
+          if (!_strnicmp(pp,name,length)) break;
       }
   }
@@ -71,4 +74,6 @@
   MSVCRT_wchar_t* pp,*pos = NULL;
   unsigned int length=strlenW(name);
+
+  dprintf(("MSVCRT: _wgetenv %s",debugstr_w(name)));  
 
   for (pp = environ; (*pp); pp = pp + strlenW(pp) + 1)
@@ -95,5 +100,5 @@
  *		_putenv (MSVCRT.@)
  */
-int _putenv(const char *str)
+int MSVCRT__putenv(const char *str)
 {
  char name[256], value[512];
Index: trunk/src/msvcrt/errno.c
===================================================================
--- trunk/src/msvcrt/errno.c	(revision 10001)
+++ trunk/src/msvcrt/errno.c	(revision 10005)
@@ -38,7 +38,7 @@
 void MSVCRT__set_errno(int err)
 {
-  int *errno = MSVCRT__errno();
-  unsigned long *doserrno = __doserrno();
-
+  int *msv_errno = MSVCRT__errno();
+  unsigned long *doserrno = MSVCRT_doserrno();
+ 
   *doserrno = err;
 
@@ -46,5 +46,5 @@
   {
 #define ERR_CASE(oserr) case oserr:
-#define ERR_MAPS(oserr,crterr) case oserr:*errno = crterr;break;
+#define ERR_MAPS(oserr,crterr) case oserr:*msv_errno = crterr;break;
     ERR_CASE(ERROR_ACCESS_DENIED)
     ERR_CASE(ERROR_NETWORK_ACCESS_DENIED)
@@ -91,5 +91,5 @@
     /*  Remaining cases map to EINVAL */
     /* FIXME: may be missing some errors above */
-    *errno = MSVCRT_EINVAL;
+    *msv_errno = MSVCRT_EINVAL;
   }
 }
@@ -100,12 +100,14 @@
 int* MSVCRT__errno(void)
 {
-    return &msvcrt_get_thread_data()->errno;
+    dprintf(("MSVCRT: __errno %d",msvcrt_get_thread_data()->msv_errno));  
+    return &msvcrt_get_thread_data()->msv_errno;
 }
 
 /*********************************************************************
- *		__doserrno (MSVCRT.@)
+ *		MSVCRT_doserrno (MSVCRT.@)
  */
-unsigned long* __doserrno(void)
+unsigned long* MSVCRT_doserrno(void)
 {
+    dprintf(("MSVCRT: _doserrno %d",msvcrt_get_thread_data()->doserrno));  
     return &msvcrt_get_thread_data()->doserrno;
 }
@@ -122,8 +124,8 @@
  *		_strerror	(MSVCRT.@)
  */
-char* _strerror(const char* err)
+char* MSVCRT__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));
+  sprintf(strerrbuff,"%s: %s\n",err,MSVCRT_strerror(msvcrt_get_thread_data()->msv_errno));
   return strerrbuff;
 }
@@ -134,4 +136,4 @@
 void MSVCRT_perror(const char* str)
 {
-  _cprintf("%s: %s\n",str,MSVCRT_strerror(msvcrt_get_thread_data()->errno));
+  MSVCRT__cprintf("%s: %s\n",str,MSVCRT_strerror(msvcrt_get_thread_data()->msv_errno));
 }
Index: trunk/src/msvcrt/except.c
===================================================================
--- trunk/src/msvcrt/except.c	(revision 10001)
+++ trunk/src/msvcrt/except.c	(revision 10005)
@@ -28,4 +28,6 @@
 #ifdef __WIN32OS2__
 #include <emxheader.h>
+#include <stdlib.h>
+#include <string.h>
 #include <winbase.h>
 #else
@@ -40,4 +42,5 @@
 #include "msvcrt.h"
 
+#include "msvcrt/stdlib.h"
 #include "msvcrt/setjmp.h"
 #include "excpt.h"
@@ -144,5 +147,5 @@
   EXCEPTION_FRAME reg;
 
-  TRACE("(%p,%d,%d)\n",frame, frame->trylevel, trylevel);
+  TRACE("MSVCRT: _local_unwind2 (%p,%d,%d)\n",frame, frame->trylevel, trylevel);
 
   /* Register a handler in case of a nested exception */
@@ -195,5 +198,5 @@
   PSCOPETABLE pScopeTable;
 
-  TRACE("exception %lx flags=%lx at %p handler=%p %p %p semi-stub\n",
+  TRACE("MSVCRT: exception %lx flags=%lx at %p handler=%p %p %p semi-stub\n",
         rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress,
         frame->handler, context, dispatcher);
@@ -290,5 +293,5 @@
 #endif
 {
-    TRACE("(%p)\n",jmp);
+    TRACE("MSVCRT: _setjmp (%p)\n",jmp);
     jmp->Ebp = context->Ebp;
     jmp->Ebx = context->Ebx;
@@ -316,5 +319,5 @@
 #endif
 {
-    TRACE("(%p,%d)\n",jmp,nb_args);
+    TRACE("MSVCRT: _setjmp3 (%p,%d)\n",jmp,nb_args);
     jmp->Ebp = context->Ebp;
     jmp->Ebx = context->Ebx;
@@ -359,5 +362,5 @@
     unsigned long cur_frame = 0;
 
-    TRACE("(%p,%d)\n", jmp, retval);
+    TRACE("MSVCRT: longjmp (%p,%d)\n", jmp, retval);
 
     cur_frame=(unsigned long)NtCurrentTeb()->except;
@@ -404,4 +407,5 @@
 #endif /* i386 */
 
+
 /*********************************************************************
  *		signal (MSVCRT.@)
@@ -409,5 +413,5 @@
 void* MSVCRT_signal(int sig, MSVCRT_sig_handler_func func)
 {
-  FIXME("(%d %p):stub\n", sig, func);
-  return (void*)-1;
-}
+  dprintf(("MSVCRT: signal(%d %p): NOT COMPLETE\n", sig, func));
+  return SIG_IGN_W;
+}
Index: trunk/src/msvcrt/exit.c
===================================================================
--- trunk/src/msvcrt/exit.c	(revision 10001)
+++ trunk/src/msvcrt/exit.c	(revision 10005)
@@ -23,5 +23,6 @@
 #include "msvcrt/stdlib.h"
 #include "mtdll.h"
-
+#include "winuser.h"
+#include <string.h>
 #include "wine/debug.h"
 
@@ -37,4 +38,7 @@
 
 extern int MSVCRT_app_type;
+extern char *MSVCRT__pgmptr;
+
+static LPCSTR szMsgBoxTitle = "Wine C++ Runtime Library";
 
 /* INTERNAL: call atexit functions */
@@ -92,8 +96,35 @@
 void MSVCRT__exit(int exitcode)
 {
-  TRACE("(%d)\n", exitcode);
+  TRACE("MSVCRT: _exit (%d)\n", exitcode);
   ExitProcess(exitcode);
 }
 
+/* Print out an error message with an option to debug */
+static void DoMessageBox(LPCSTR lead, LPCSTR message)
+{
+  MSGBOXPARAMSA msgbox;
+  char text[2048];
+  INT ret;
+
+  _snprintf(text,sizeof(text),"%s\n\nProgram: %s\n%s\n\n"
+               "Press OK to exit the program, or Cancel to start the Wine debugger.\n ",
+               lead, MSVCRT__pgmptr, message);
+
+  msgbox.cbSize = sizeof(msgbox);
+  msgbox.hwndOwner = GetActiveWindow();
+  msgbox.hInstance = 0;
+  msgbox.lpszText = text;
+  msgbox.lpszCaption = szMsgBoxTitle;
+  msgbox.dwStyle = MB_OKCANCEL|MB_ICONERROR;
+  msgbox.lpszIcon = NULL;
+  msgbox.dwContextHelpId = 0;
+  msgbox.lpfnMsgBoxCallback = NULL;
+  msgbox.dwLanguageId = LANG_NEUTRAL;
+
+  ret = MessageBoxIndirectA(&msgbox);
+  if (ret == IDCANCEL)
+    DebugBreak();
+}
+
 /*********************************************************************
  *		_amsg_exit (MSVCRT.@)
@@ -101,11 +132,14 @@
 void MSVCRT__amsg_exit(int errnum)
 {
-  TRACE("(%d)\n", errnum);
+  TRACE("MSVCRT: _amsg_exit (%d)\n", errnum);
   /* FIXME: text for the error number. */
   if (MSVCRT_app_type == 2)
   {
-    /* FIXME: MsgBox */
-  }
-  _cprintf("\nruntime error R60%d\n",errnum);
+    char text[32];
+    sprintf(text, "Error: R60%d",errnum);
+    DoMessageBox("Runtime error!", text);
+  }
+  else
+    MSVCRT__cprintf("\nruntime error R60%d\n",errnum);
   MSVCRT__exit(255);
 }
@@ -116,10 +150,11 @@
 void MSVCRT_abort(void)
 {
-  TRACE("(void)\n");
+  TRACE("MSVCRT: _abort");
   if (MSVCRT_app_type == 2)
   {
-    /* FIXME: MsgBox */
-  }
-  _cputs("\nabnormal program termination\n");
+    DoMessageBox("Runtime error!", "abnormal program termination");
+  }
+  else
+    MSVCRT__cputs("\nabnormal program termination\n");
   MSVCRT__exit(3);
 }
@@ -130,11 +165,14 @@
 void MSVCRT__assert(const char* str, const char* file, unsigned int line)
 {
-  TRACE("(%s,%s,%d)\n",str,file,line);
+  TRACE("MSVCRT: _assert (%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();
+    char text[2048];
+    _snprintf(text, sizeof(text), "File: %s\nLine: %d\n\nEpression: \"%s\"", file, line, str);
+    DoMessageBox("Assertion failed!", text);
+  }
+  else
+    MSVCRT__cprintf("Assertion failed: %s, file %s, line %d\n\n",str, file, line);
+  MSVCRT__exit(3);
 }
 
@@ -144,5 +182,5 @@
 void MSVCRT__c_exit(void)
 {
-  TRACE("(void)\n");
+  TRACE("MSVCRT: _c_exit (void)\n");
   /* All cleanup is done on DLL detach; Return to caller */
 }
@@ -153,5 +191,5 @@
 void MSVCRT__cexit(void)
 {
-  TRACE("(void)\n");
+  TRACE("MSVCRT: _cexit (void)\n");
   /* All cleanup is done on DLL detach; Return to caller */
 }
@@ -160,7 +198,7 @@
  *		_onexit (MSVCRT.@)
  */
-_onexit_t _onexit(_onexit_t func)
-{
-  TRACE("(%p)\n",func);
+_onexit_t MSVCRT__onexit(_onexit_t func)
+{
+  TRACE("MSVCRT: _onexit (%p)\n",func);
 
   if (!func)
@@ -196,5 +234,5 @@
 void MSVCRT_exit(int exitcode)
 {
-  TRACE("(%d)\n",exitcode);
+  TRACE("MSVCRT: _exit (%d)\n",exitcode);
   LOCK_EXIT;
   __MSVCRT__call_atexit();
@@ -208,6 +246,6 @@
 int MSVCRT_atexit(void (*func)(void))
 {
-  TRACE("(%p)\n", func);
-  return _onexit((_onexit_t)func) == (_onexit_t)func ? 0 : -1;
+  TRACE("MSVCRT: _atexit (%p)\n", func);
+  return MSVCRT__onexit((_onexit_t)func) == (_onexit_t)func ? 0 : -1;
 }
 
@@ -218,5 +256,5 @@
 void _purecall(void)
 {
-  TRACE("(void)\n");
+  TRACE("MSVCRT: _purecall (void)\n");
   MSVCRT__amsg_exit( 25 );
 }
Index: trunk/src/msvcrt/file.c
===================================================================
--- trunk/src/msvcrt/file.c	(revision 10001)
+++ trunk/src/msvcrt/file.c	(revision 10005)
@@ -23,4 +23,6 @@
 #ifdef __WIN32OS2__
 #include <emxheader.h>
+/* thanks to stupid unistd.h in win dir! */
+#include <emxruntime\unistd.h>
 #include <winbase.h>
 #else
@@ -29,11 +31,13 @@
 #endif
 
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
 #include <time.h>
-#include <stdio.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
+
 
 #include "winternl.h"
+#include "debugstr.h"
 #include "msvcrt.h"
 #include "msvcrt/errno.h"
@@ -82,5 +86,5 @@
 
 /* INTERNAL: process umask */
-static int MSVCRT_umask = 0;
+static int MSVCRT__umask = 0;
 
 /* INTERNAL: Static buffer for temp file name */
@@ -124,5 +128,5 @@
   {
     WARN(":fd (%d) - no handle!\n",fd);
-    *__doserrno() = 0;
+    *MSVCRT_doserrno() = 0; 
     *MSVCRT__errno() = MSVCRT_EBADF;
    return INVALID_HANDLE_VALUE;
@@ -177,10 +181,10 @@
 static MSVCRT_FILE* msvcrt_alloc_fp(int fd)
 {
-  TRACE(":fd (%d) allocating FILE*\n",fd);
+  TRACE("MSVCRT: 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_doserrno() = 0;
     *MSVCRT__errno() = MSVCRT_EBADF;
     return NULL;
@@ -227,8 +231,8 @@
 void msvcrt_free_io(void)
 {
-    _fcloseall();
-    _close(0);
-    _close(1);
-    _close(2);
+    MSVCRT__fcloseall();
+    MSVCRT__close(0);
+    MSVCRT__close(1);
+    MSVCRT__close(2);
 }
 
@@ -238,5 +242,5 @@
   if(file->_bufsiz) {
         int cnt=file->_ptr-file->_base;
-        if(cnt>0 && _write(file->_file, file->_base, cnt) != cnt) {
+        if(cnt>0 && MSVCRT__write(file->_file, file->_base, cnt) != cnt) {
                 return MSVCRT_EOF;
         }
@@ -268,4 +272,5 @@
 MSVCRT_FILE *__p__iob(void)
 {
+ dprintf(("MSVCRT: __p__iob request"));
  return &MSVCRT__iob[0];
 }
@@ -274,9 +279,9 @@
  *		_access (MSVCRT.@)
  */
-int _access(const char *filename, int mode)
+int MSVCRT__access(const char *filename, int mode)
 {
   DWORD attr = GetFileAttributesA(filename);
 
-  TRACE("(%s,%d) %ld\n",filename,mode,attr);
+  TRACE("MSVCRT _access (%s,%d) %ld\n",filename,mode,attr);
 
   if (!filename || attr == 0xffffffff)
@@ -300,5 +305,5 @@
   DWORD attr = GetFileAttributesW(filename);
 
-  TRACE("(%s,%d) %ld\n",debugstr_w(filename),mode,attr);
+  TRACE("MSVCRT: _waccess (%s,%d) %ld\n",debugstr_w(filename),mode,attr);
 
   if (!filename || attr == 0xffffffff)
@@ -318,7 +323,9 @@
  *		_chmod (MSVCRT.@)
  */
-int _chmod(const char *path, int flags)
+int MSVCRT__chmod(const char *path, int flags)
 {
   DWORD oldFlags = GetFileAttributesA(path);
+
+  dprintf(("MSVCRT: _chmod %s",path));
 
   if (oldFlags != 0x0FFFFFFFF)
@@ -341,4 +348,6 @@
   DWORD oldFlags = GetFileAttributesW(path);
 
+  dprintf(("MSVCRT: _wchmod %s",debugstr_w(path)));
+
   if (oldFlags != 0x0FFFFFFFF)
   {
@@ -356,7 +365,7 @@
  *		_unlink (MSVCRT.@)
  */
-int _unlink(const char *path)
-{
-  TRACE("(%s)\n",path);
+int MSVCRT__unlink(const char *path)
+{
+  TRACE("MSVCRT: _unlink (%s)\n",path);
   if(DeleteFileA(path))
     return 0;
@@ -382,9 +391,9 @@
  *		_close (MSVCRT.@)
  */
-int _close(int fd)
+int MSVCRT__close(int fd)
 {
   HANDLE hand = msvcrt_fdtoh(fd);
 
-  TRACE(":fd (%d) handle (%p)\n",fd,hand);
+  TRACE("MSVCRT: _close fd (%d) handle (%p)\n",fd,hand);
   if (hand == INVALID_HANDLE_VALUE)
     return -1;
@@ -413,10 +422,10 @@
   {
     TRACE("deleting temporary file '%s'\n",MSVCRT_tempfiles[fd]);
-    _unlink(MSVCRT_tempfiles[fd]);
+    MSVCRT__unlink(MSVCRT_tempfiles[fd]);
     MSVCRT_free(MSVCRT_tempfiles[fd]);
     MSVCRT_tempfiles[fd] = NULL;
   }
 
-  TRACE(":ok\n");
+  TRACE("MSVCRT: _close ok\n");
   return 0;
 }
@@ -429,5 +438,5 @@
   HANDLE hand = msvcrt_fdtoh(fd);
 
-  TRACE(":fd (%d) handle (%p)\n",fd,hand);
+  TRACE("MSVCRT: _commit fd (%d) handle (%p)\n",fd,hand);
   if (hand == INVALID_HANDLE_VALUE)
     return -1;
@@ -458,5 +467,5 @@
   HANDLE hand = msvcrt_fdtoh(fd);
 
-  TRACE(":fd (%d) handle (%p)\n",fd,hand);
+  TRACE("MSVCRT: _eof fd (%d) handle (%p)\n",fd,hand);
 
   if (hand == INVALID_HANDLE_VALUE)
@@ -483,12 +492,14 @@
  *		_fcloseall (MSVCRT.@)
  */
-int _fcloseall(void)
+int MSVCRT__fcloseall(void)
 {
   int num_closed = 0, i;
+
+  dprintf(("MSVCRT: _fcloseall"));
 
   for (i = 3; i < MSVCRT_fdend; i++)
     if (MSVCRT_handles[i] != INVALID_HANDLE_VALUE)
     {
-      _close(i);
+      MSVCRT__close(i);
       num_closed++;
     }
@@ -506,5 +517,5 @@
   HANDLE hand = msvcrt_fdtoh(fd);
 
-  TRACE(":fd (%d) handle (%p)\n",fd,hand);
+  TRACE("MSVCRT: _lseeki64 fd (%d) handle (%p)\n",fd,hand);
   if (hand == INVALID_HANDLE_VALUE)
     return -1;
@@ -516,5 +527,5 @@
   }
 
-  TRACE(":fd (%d) to 0x%08lx%08lx pos %s\n",
+  TRACE("MSVCRT: _lseek fd (%d) to 0x%08lx%08lx pos %s\n",
         fd,hoffset,(long)offset,
         (whence==SEEK_SET)?"SEEK_SET":
@@ -549,5 +560,5 @@
  *		_lseek (MSVCRT.@)
  */
-LONG _lseek(int fd, LONG offset, int whence)
+LONG MSVCRT__lseek(int fd, LONG offset, int whence)
 {
     return _lseeki64(fd, offset, whence);
@@ -565,5 +576,5 @@
   HANDLE hand = msvcrt_fdtoh(fd);
 
-  TRACE(":fd (%d) handle (%p)\n",fd,hand);
+  TRACE("MSVCRT: _locking fd (%d) handle (%p)\n",fd,hand);
   if (hand == INVALID_HANDLE_VALUE)
     return -1;
@@ -597,5 +608,5 @@
       ret = LockFile(hand, cur_locn, 0L, nbytes, 0L);
       if (ret) break;
-      sleep (1);
+      Sleep (1);
     }
   }
@@ -613,5 +624,5 @@
 void MSVCRT_rewind(MSVCRT_FILE* file)
 {
-  TRACE(":file (%p) fd (%d)\n",file,file->_file);
+  TRACE("MSVCRT: rewind file (%p) fd (%d)\n",file,file->_file);
   MSVCRT_fseek(file, 0L, SEEK_SET);
   MSVCRT_clearerr(file);
@@ -621,9 +632,9 @@
  *		_fdopen (MSVCRT.@)
  */
-MSVCRT_FILE* _fdopen(int fd, const char *mode)
+MSVCRT_FILE* MSVCRT__fdopen(int fd, const char *mode)
 {
   MSVCRT_FILE* file = msvcrt_alloc_fp(fd);
 
-  TRACE(":fd (%d) mode (%s) FILE* (%p)\n",fd,mode,file);
+  TRACE("MSVCRT: _fdopen fd (%d) mode (%s) FILE* (%p)\n",fd,mode,file);
 
   return file;
@@ -637,5 +648,5 @@
   MSVCRT_FILE* file = msvcrt_alloc_fp(fd);
 
-  TRACE(":fd (%d) mode (%s) FILE* (%p)\n",fd,debugstr_w(mode),file);
+  TRACE("MSVCRT: _wfdopen fd (%d) mode (%s) FILE* (%p)\n",fd,debugstr_w(mode),file);
   if (file)
     MSVCRT_rewind(file);
@@ -647,14 +658,17 @@
  *		_filelength (MSVCRT.@)
  */
-LONG _filelength(int fd)
-{
-  LONG curPos = _lseek(fd, 0, SEEK_CUR);
+LONG MSVCRT__filelength(int fd)
+{
+  LONG curPos = MSVCRT__lseek(fd, 0, SEEK_CUR);
+
+  dprintf(("MSVCRT: _filelength"));
+
   if (curPos != -1)
   {
-    LONG endPos = _lseek(fd, 0, SEEK_END);
+    LONG endPos = MSVCRT__lseek(fd, 0, SEEK_END);
     if (endPos != -1)
     {
       if (endPos != curPos)
-        _lseek(fd, curPos, SEEK_SET);
+        MSVCRT__lseek(fd, curPos, SEEK_SET);
       return endPos;
     }
@@ -666,7 +680,7 @@
  *		_fileno (MSVCRT.@)
  */
-int _fileno(MSVCRT_FILE* file)
-{
-  TRACE(":FILE* (%p) fd (%d)\n",file,file->_file);
+int MSVCRT__fileno(MSVCRT_FILE* file)
+{
+  TRACE("MSVCRT: _fileno FILE* (%p) fd (%d)\n",file,file->_file);
   return file->_file;
 }
@@ -675,7 +689,9 @@
  *		_flushall (MSVCRT.@)
  */
-int _flushall(void)
+int MSVCRT__flushall(void)
 {
   int num_flushed = 0, i = 3;
+
+  dprintf(("MSVCRT: _flushall"));
 
   while(i < MSVCRT_fdend)
@@ -707,5 +723,5 @@
   HANDLE hand = msvcrt_fdtoh(fd);
 
-  TRACE(":fd (%d) stat (%p)\n",fd,buf);
+  TRACE("MSVCRT: _fstati64 fd (%d) stat (%p)\n",fd,buf);
   if (hand == INVALID_HANDLE_VALUE)
     return -1;
@@ -722,5 +738,5 @@
   if (!GetFileInformationByHandle(hand, &hfi))
   {
-    WARN(":failed-last error (%ld)\n",GetLastError());
+    WARN("MSVCRT: _fstati64 failed-last error (%ld)\n",GetLastError());
     MSVCRT__set_errno(ERROR_INVALID_PARAMETER);
     return -1;
@@ -735,4 +751,5 @@
   return 0;
 }
+
 
 /*********************************************************************
@@ -810,5 +827,5 @@
  *		_isatty (MSVCRT.@)
  */
-int _isatty(int fd)
+int MSVCRT__isatty(int fd)
 {
   HANDLE hand = msvcrt_fdtoh(fd);
@@ -948,14 +965,13 @@
 
 
-  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;
-  }
-
+  if (oflags & _O_BINARY)
+    ioflag |= _O_BINARY;
+  else if (oflags & _O_TEXT)
+    ioflag |= _O_TEXT;
+  else if (*__p__fmode() & _O_BINARY)
+    ioflag |= _O_BINARY;
+  else
+    ioflag |= _O_TEXT; /* default to TEXT*/
+  
   switch( shflags )
   {
@@ -1001,7 +1017,7 @@
   {
     if (oflags & _O_TEMPORARY)
-      MSVCRT_tempfiles[fd] = _strdup(path);
+      MSVCRT_tempfiles[fd] = MSVCRT__strdup(path);
     if (ioflag & MSVCRT__IOAPPEND)
-      _lseek(fd, 0, FILE_END);
+      MSVCRT__lseek(fd, 0, FILE_END);
   }
 
@@ -1037,14 +1053,18 @@
  *              _open (MSVCRT.@)
  */
-int _open( const char *path, int flags, ... )
+int MSVCRT__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 );
+
+  if (flags & _O_CREAT)
+  {
+    int pmode;
+    va_start(ap, flags);
+    pmode = va_arg(ap, int);
+    va_end(ap);
+    return MSVCRT__sopen( path, flags, _SH_DENYNO, pmode );
+  }
+  else
+    return MSVCRT__sopen( path, flags, _SH_DENYNO);
 }
 
@@ -1065,5 +1085,5 @@
   if (patha && WideCharToMultiByte(CP_ACP,0,path,len,patha,len,NULL,NULL))
   {
-    int retval = _open(patha,flags,pmode);
+    int retval = MSVCRT__open(patha,flags,pmode);
     MSVCRT_free(patha);
     return retval;
@@ -1077,8 +1097,8 @@
  *		_creat (MSVCRT.@)
  */
-int _creat(const char *path, int flags)
+int MSVCRT__creat(const char *path, int flags)
 {
   int usedFlags = (flags & _O_TEXT)| _O_CREAT| _O_WRONLY| _O_TRUNC;
-  return _open(path, usedFlags);
+  return MSVCRT__open(path, usedFlags);
 }
 
@@ -1107,5 +1127,5 @@
  *		_rmtmp (MSVCRT.@)
  */
-int _rmtmp(void)
+int MSVCRT__rmtmp(void)
 {
   int num_removed = 0, i;
@@ -1114,5 +1134,5 @@
     if (MSVCRT_tempfiles[i])
     {
-      _close(i);
+      MSVCRT__close(i);
       num_removed++;
     }
@@ -1126,5 +1146,5 @@
  *		_read (MSVCRT.@)
  */
-int _read(int fd, void *buf, unsigned int count)
+int MSVCRT__read(int fd, void *buf, unsigned int count)
 {
   DWORD num_read;
@@ -1137,20 +1157,54 @@
     return -1;
 
-  if (ReadFile(hand, buf, count, &num_read, NULL))
-  {
-    if (num_read != count && MSVCRT_files[fd])
+  if (MSVCRT_flags[fd]& _O_BINARY)
     {
-      TRACE(":EOF\n");
-	MSVCRT_flags[fd] |= MSVCRT__IOEOF;
-/*
-      MSVCRT_files[fd]->_flag |= MSVCRT__IOEOF;
-*/
+      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;
+	      */
+	    }
+	  dprintf(("%s\n",debugstr_an(buf,num_read)));
+	  return num_read;
+	}
+      TRACE(":failed-last error (%ld)\n",GetLastError());
+      if (MSVCRT_files[fd])
+	MSVCRT_files[fd]->_flag |= MSVCRT__IOERR;
+      return -1;
     }
-    return num_read;
-  }
-  TRACE(":failed-last error (%ld)\n",GetLastError());
-  if (MSVCRT_files[fd])
-     MSVCRT_files[fd]->_flag |= MSVCRT__IOERR;
-  return -1;
+  else
+    {
+      char cc, *s=(char*)buf,* buf_start=(char*)buf;
+      unsigned int i;
+      
+      for (i = 0 , num_read = 1; i < count && (num_read == 1);)
+	{
+	  if (ReadFile(hand, &cc, 1, &num_read, NULL))
+	    if (num_read == 1)
+	      if ((cc != '\r') || MSVCRT_flags[fd] & _O_BINARY)
+		{
+		  *s++ = (char)cc;
+		  i++;
+		}
+	}
+      if (num_read != 1)
+	{
+	  TRACE(":EOF\n");
+	  if (MSVCRT_files[fd])
+	    MSVCRT_flags[fd] |= MSVCRT__IOEOF;
+	  /*
+	    MSVCRT_files[fd]->_flag |= MSVCRT__IOEOF;
+	  */
+	}
+  
+      if (count > 4)
+	dprintf(("%s\n",debugstr_an(buf_start, s-buf_start)));
+      return s-buf_start;
+    }
+  return 0;
 }
 
@@ -1158,8 +1212,8 @@
  *		_getw (MSVCRT.@)
  */
-int _getw(MSVCRT_FILE* file)
+int MSVCRT__getw(MSVCRT_FILE* file)
 {
   int i;
-  if (_read(file->_file, &i, sizeof(int)) != 1)
+  if (MSVCRT__read(file->_file, &i, sizeof(int)) != 1)
     return MSVCRT_EOF;
   return i;
@@ -1169,9 +1223,12 @@
  *		_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;
+int MSVCRT__setmode(int fd,int mode)
+{
+  int ret = MSVCRT_flags[fd] & (_O_TEXT | _O_BINARY);
+  if (mode & (~(_O_TEXT|_O_BINARY)))
+    FIXME("fd (%d) mode (0x%08x) unknown\n",fd,mode);
+  MSVCRT_flags[fd] &= ~(_O_TEXT|_O_BINARY);
+  MSVCRT_flags[fd] |= mode & (_O_TEXT | _O_BINARY);
+  return ret;
 }
 
@@ -1202,8 +1259,8 @@
 		 as drive letter
   */
-  if (isalpha(*path)&& (*(path+1)==':'))
+  if (isalpha((int)*path) && (*(path+1)==':'))
     buf->st_dev = buf->st_rdev = toupper(*path) - 'A'; /* drive num */
   else
-    buf->st_dev = buf->st_rdev = _getdrive() - 1;
+    buf->st_dev = buf->st_rdev = MSVCRT__getdrive() - 1;
 
   plen = strlen(path);
@@ -1280,5 +1337,5 @@
     buf->st_dev = buf->st_rdev = toupperW(*path - 'A'); /* drive num */
   else
-    buf->st_dev = buf->st_rdev = _getdrive() - 1;
+    buf->st_dev = buf->st_rdev = MSVCRT__getdrive() - 1;
 
   plen = strlenW(path);
@@ -1319,7 +1376,7 @@
  *		_tell (MSVCRT.@)
  */
-LONG _tell(int fd)
-{
-  return _lseek(fd, 0, SEEK_CUR);
+LONG MSVCRT__tell(int fd)
+{
+  return MSVCRT__lseek(fd, 0, SEEK_CUR);
 }
 
@@ -1327,5 +1384,5 @@
  *		_tempnam (MSVCRT.@)
  */
-char *_tempnam(const char *dir, const char *prefix)
+char *MSVCRT__tempnam(const char *dir, const char *prefix)
 {
   char tmpbuf[MAX_PATH];
@@ -1335,5 +1392,5 @@
   {
     TRACE("got name (%s)\n",tmpbuf);
-    return _strdup(tmpbuf);
+    return MSVCRT__strdup(tmpbuf);
   }
   TRACE("failed (%ld)\n",GetLastError());
@@ -1361,9 +1418,9 @@
  *		_umask (MSVCRT.@)
  */
-int _umask(int umask)
-{
-  int old_umask = MSVCRT_umask;
-  TRACE("(%d)\n",umask);
-  MSVCRT_umask = umask;
+int MSVCRT_umask(int umask)
+{
+  int old_umask = MSVCRT__umask;
+  TRACE("MSVCRT: _umask (%d)\n",umask);
+  MSVCRT__umask = umask;
   return old_umask;
 }
@@ -1372,12 +1429,12 @@
  *		_utime (MSVCRT.@)
  */
-int _utime(const char* path, struct _utimbuf *t)
-{
-  int fd = _open(path, _O_WRONLY | _O_BINARY);
+int MSVCRT_utime(const char* path, struct _utimbuf *t)
+{
+  int fd = MSVCRT__open(path, _O_WRONLY | _O_BINARY);
 
   if (fd > 0)
   {
     int retVal = _futime(fd, t);
-    _close(fd);
+    MSVCRT__close(fd);
     return retVal;
   }
@@ -1395,5 +1452,5 @@
   {
     int retVal = _futime(fd, t);
-    _close(fd);
+     MSVCRT__close(fd);
     return retVal;
   }
@@ -1404,5 +1461,5 @@
  *		_write (MSVCRT.@)
  */
-int _write(int fd, const void* buf, unsigned int count)
+int MSVCRT__write(int fd, const void* buf, unsigned int count)
 {
   DWORD num_written;
@@ -1415,18 +1472,56 @@
 #endif
   if (hand == INVALID_HANDLE_VALUE)
-    return -1;
+    {
+      *MSVCRT__errno() = MSVCRT_EBADF;
+      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;
-
+    MSVCRT__lseek(fd, 0, FILE_END);
+
+  if (MSVCRT_flags[fd] & _O_BINARY)
+    {
+      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;
+	  *MSVCRT__errno() = MSVCRT_ENOSPC;
+	}
+    }
+  else
+    {
+      char *s=(char*)buf, *buf_start=(char*)buf, *p;
+      char crlf[]= {'\r','\n'};
+      unsigned int i;
+      DWORD num_to_write;
+      for (i = 0; i< count && !(MSVCRT_flags[fd] & MSVCRT__IOERR);i++, s++)
+	{
+	  if (*s == '\n')
+	    {
+	      p = crlf;
+	      num_to_write = 2;
+	    }
+	  else
+	    { 
+	      p = s;
+	      num_to_write = 1;
+	    }
+	  if ((WriteFile(hand, p, num_to_write, &num_written, NULL) == 0 ) || (num_written != num_to_write))
+	    {
+	      TRACE(":failed-last error (%ld) num_written %ld\n",GetLastError(),num_written);
+	      if (MSVCRT_files[fd])
+		{
+		  MSVCRT_files[fd]->_flag |= MSVCRT__IOERR;
+		  *MSVCRT__errno() = MSVCRT_ENOSPC;
+		  return s - buf_start;
+		}
+	    }
+	}
+      return s - buf_start;
+    }
   return -1;
 }
@@ -1435,7 +1530,7 @@
  *		_putw (MSVCRT.@)
  */
-int _putw(int val, MSVCRT_FILE* file)
-{
-  return _write(file->_file, &val, sizeof(val)) == 1? val : MSVCRT_EOF;
+int MSVCRT__putw(int val, MSVCRT_FILE* file)
+{
+  return MSVCRT__write(file->_file, &val, sizeof(val)) == 1? val : MSVCRT_EOF;
 }
 
@@ -1455,5 +1550,5 @@
 {
   int r;
-  r=_close(file->_file);
+  r=MSVCRT__close(file->_file);
   return ((r==MSVCRT_EOF) || (file->_flag & MSVCRT__IOERR) ? MSVCRT_EOF : 0);
 }
@@ -1481,5 +1576,5 @@
 {
   if(!file) {
-	_flushall();
+	MSVCRT__flushall();
 	return 0;
   } else {
@@ -1505,5 +1600,5 @@
  *		_fgetchar (MSVCRT.@)
  */
-int _fgetchar(void)
+int MSVCRT__fgetchar(void)
 {
   return MSVCRT_fgetc(MSVCRT_stdin);
@@ -1529,5 +1624,5 @@
   if(file->_flag & MSVCRT__IONBF) {
 	unsigned char c;
-  	if (_read(file->_file,&c,1) != 1) {
+  	if (MSVCRT__read(file->_file,&c,1) != 1) {
 		file->_flag |= MSVCRT__IOEOF;
     		return MSVCRT_EOF;
@@ -1535,5 +1630,5 @@
   	return c;
   } else {
-	file->_cnt = _read(file->_file, file->_base, file->_bufsiz);
+	file->_cnt = MSVCRT__read(file->_file, file->_base, file->_bufsiz);
 	if(file->_cnt<0) file->_cnt = 0;
 	if(!file->_cnt) {
@@ -1589,11 +1684,28 @@
 /*********************************************************************
  *		fgetwc (MSVCRT.@)
+ *
+ * In _O_TEXT mode, bultibyte characters are read from the file, dropping
+ * the CR from CR/LF combinations
  */
 MSVCRT_wint_t MSVCRT_fgetwc(MSVCRT_FILE* file)
 {
-  MSVCRT_wchar_t wc;
-  if (_read(file->_file, &wc, sizeof(wc)) != sizeof(wc))
+  char c;
+
+  if (file->_flag & _O_BINARY)
+    {
+      MSVCRT_wchar_t wc;
+      if (MSVCRT__read(file->_file, &wc, sizeof(wc)) != sizeof(wc))
+	return MSVCRT_WEOF;
+      return wc;
+    }
+  c = MSVCRT_fgetc(file);
+  if ((*__p___mb_cur_max() > 1) && MSVCRT_isleadbyte(c))
+    {
+      FIXME("Treat Multibyte characters\n");
+    }
+  if (c == MSVCRT_EOF)
     return MSVCRT_WEOF;
-  return wc;
+  else
+    return (MSVCRT_wint_t)c;
 }
 
@@ -1721,5 +1833,5 @@
     }
 
-  fd = _open(path, flags);
+  fd = MSVCRT__open(path, flags);
 
   if (fd < 0)
@@ -1729,5 +1841,5 @@
   TRACE(":got (%p)\n",file);
   if (!file)
-    _close(fd);
+    MSVCRT__close(fd);
 
   return file;
@@ -1762,5 +1874,5 @@
  *		_fsopen (MSVCRT.@)
  */
-MSVCRT_FILE*  _fsopen(const char *path, const char *mode, int share)
+MSVCRT_FILE*  MSVCRT__fsopen(const char *path, const char *mode, int share)
 {
   FIXME(":(%s,%s,%d),ignoring share mode!\n",path,mode,share);
@@ -1813,5 +1925,5 @@
   } else {
 	unsigned char cc=c;
-  	return _write(file->_file, &cc, 1) == 1? c : MSVCRT_EOF;
+  	return MSVCRT__write(file->_file, &cc, 1) == 1? c : MSVCRT_EOF;
   }
 }
@@ -1820,5 +1932,5 @@
  *		_fputchar (MSVCRT.@)
  */
-int _fputchar(int c)
+int MSVCRT__fputchar(int c)
 {
   return MSVCRT_fputc(c, MSVCRT_stdout);
@@ -1847,5 +1959,5 @@
 		return 0;
   }
-  if(rcnt) pread = _read(file->_file,ptr, rcnt);
+  if(rcnt) pread = MSVCRT__read(file->_file,ptr, rcnt);
   if (MSVCRT_flags[file->_file] & MSVCRT__IOEOF)
      /* expose feof condition in the flags
@@ -1915,5 +2027,5 @@
 int MSVCRT_fsetpos(MSVCRT_FILE* file, MSVCRT_fpos_t *pos)
 {
-  return _lseek(file->_file,*pos,SEEK_SET);
+  return MSVCRT__lseek(file->_file,*pos,SEEK_SET);
 }
 
@@ -1937,5 +2049,5 @@
         file->_flag &= ~(MSVCRT__IOREAD|MSVCRT__IOWRT);
   }
-  return (_lseek(file->_file,offset,whence) == -1)?-1:0;
+  return (MSVCRT__lseek(file->_file,offset,whence) == -1)?-1:0;
 }
 
@@ -1954,5 +2066,5 @@
 	}
   }
-  pos = _tell(file->_file);
+  pos = MSVCRT__tell(file->_file);
   if(pos == -1) return pos;
   return off + pos;
@@ -1986,5 +2098,5 @@
   	int res=msvcrt_flush_buffer(file);
 	if(!res) {
-		int pwritten = _write(file->_file, ptr, wrcnt);
+		int pwritten = MSVCRT__write(file->_file, ptr, wrcnt);
   		if (pwritten <= 0) pwritten=0;
 		written += pwritten;
@@ -1999,6 +2111,11 @@
 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;
+    size_t i, len = strlen(s);
+    if (file->_flag & _O_BINARY)
+      return MSVCRT_fwrite(s,sizeof(*s),len,file) == len ? 0 : MSVCRT_EOF;
+    for (i=0; i<len; i++)
+      if (MSVCRT_fputc(s[i], file) == MSVCRT_EOF) 
+	return MSVCRT_EOF;
+    return 0;
 }
 
@@ -2008,7 +2125,17 @@
 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;
-}
+    size_t i, len = strlenW(s);
+    if (file->_flag & _O_BINARY)
+      return MSVCRT_fwrite(s,sizeof(*s),len,file) == len ? 0 : MSVCRT_EOF;
+    for (i=0; i<len; i++)
+      {
+	if ((s[i] == L'\n') && (MSVCRT_fputc('\r', file) == MSVCRT_EOF))
+	  return MSVCRT_WEOF;
+	if (MSVCRT_fputwc(s[i], file) == MSVCRT_WEOF)
+	  return MSVCRT_WEOF; 
+      }
+    return 0;
+}
+
 
 /*********************************************************************
@@ -2239,5 +2366,5 @@
   char *filename = MSVCRT_tmpnam(NULL);
   int fd;
-  fd = _open(filename, _O_CREAT | _O_BINARY | _O_RDWR | _O_TEMPORARY);
+  fd = MSVCRT__open(filename, _O_CREAT | _O_BINARY | _O_RDWR | _O_TEMPORARY);
   if (fd != -1)
     return msvcrt_alloc_fp(fd);
@@ -2257,5 +2384,6 @@
    * The code below handles both cases
    */
-  while ((written = vsnprintf(mem, resize, format, valist)) == -1 ||
+  dprintf(("MSVCRT: vfprintf %p %s",file,format));
+  while ((written = _vsnprintf(mem, resize, format, valist)) == -1 ||
           written > resize)
   {
@@ -2398,2 +2526,23 @@
     return res;
 }
+
+/*********************************************************************
+ *		_wstati64 (MSVCRT.@)
+ */
+int _wstati64(const MSVCRT(wchar_t)* path, struct _stati64 * buf)
+{
+  LPSTR asciipath;
+  int   ret,len;
+
+  TRACE("MSVCRT: _wstati64 file (%s) %x buf(%p)\n",debugstr_w(path),sizeof(*buf),buf);
+ 
+  len = WideCharToMultiByte( CP_ACP, 0, path, -1, NULL, 0, 0, NULL);
+  asciipath = (LPSTR)MSVCRT_malloc(len);
+  WideCharToMultiByte(CP_ACP, 0, path, -1, asciipath, len, 0, NULL );
+
+  ret = _stati64(asciipath,buf);  
+
+  MSVCRT_free(asciipath);
+
+  return 0; 
+}
Index: trunk/src/msvcrt/forwarders.c
===================================================================
--- trunk/src/msvcrt/forwarders.c	(revision 10005)
+++ trunk/src/msvcrt/forwarders.c	(revision 10005)
@@ -0,0 +1,32 @@
+/*
+ * msvcrt.dll stdcall to cdecl forwarders
+ *
+ */
+
+#include <winbase.h>
+#include "wine/port.h"
+
+#include "winternl.h"
+#include "wine/exception.h"
+#include "thread.h"
+#include "msvcrt.h"
+
+HANDLE MSVCRT_GetCurrentThread(void)
+{
+ return GetCurrentThread();
+}
+
+DWORD MSVCRT_GetCurrentThreadId(void)
+{
+ return GetCurrentThreadId();
+}
+
+DWORD MSVCRT_GetCurrentProcessId(void)
+{
+ return GetCurrentProcessId();
+}
+
+DWORD MSVCRT_GetLogicalDrives(void)
+{
+ return GetLogicalDrives();
+}
Index: trunk/src/msvcrt/heap.c
===================================================================
--- trunk/src/msvcrt/heap.c	(revision 10001)
+++ trunk/src/msvcrt/heap.c	(revision 10005)
@@ -23,4 +23,7 @@
 
 #include "msvcrt.h"
+
+#include <string.h>
+
 #include "ms_errno.h"
 
@@ -43,5 +46,4 @@
 static int MSVCRT_new_mode;
 
-
 /*********************************************************************
  *		??2@YAPAXI@Z (MSVCRT.@)
@@ -50,5 +52,5 @@
 {
   void *retval = HeapAlloc(GetProcessHeap(), 0, size);
-  TRACE("(%ld) returning %p\n", size, retval);
+  TRACE("MSVCRT: operator_new (%ld) returning %p\n", size, retval);
   LOCK_HEAP;
   if(!retval && MSVCRT_new_handler)
@@ -63,5 +65,5 @@
 void MSVCRT_operator_delete(void *mem)
 {
-  TRACE("(%p)\n", mem);
+  TRACE("MSVCRT: operator_delete (%p)\n", mem);
   HeapFree(GetProcessHeap(), 0, mem);
 }
@@ -73,4 +75,5 @@
 MSVCRT_new_handler_func MSVCRT__query_new_handler(void)
 {
+  dprintf(("MSVCRT: _query_new_handler"));
   return MSVCRT_new_handler;
 }
@@ -82,4 +85,5 @@
 int MSVCRT__query_new_mode(void)
 {
+  dprintf(("MSVCRT: _query_new_mode"));
   return MSVCRT_new_mode;
 }
@@ -91,4 +95,7 @@
 {
   MSVCRT_new_handler_func old_handler;
+
+  dprintf(("MSVCRT: _set_new_mode"));
+
   LOCK_HEAP;
   old_handler = MSVCRT_new_handler;
@@ -103,5 +110,5 @@
 MSVCRT_new_handler_func MSVCRT_set_new_handler(void *func)
 {
-  TRACE("(%p)\n",func);
+  TRACE("MSVCRT: set_new_handler (%p)\n",func);
   MSVCRT__set_new_handler(NULL);
   return NULL;
@@ -114,4 +121,5 @@
 {
   int old_mode;
+  TRACE("MSVCRT: set_new_mode (%d)\n",mode);
   LOCK_HEAP;
   old_mode = MSVCRT_new_mode;
@@ -126,4 +134,5 @@
 int _callnewh(unsigned long size)
 {
+  TRACE("MSVCRT: _callnewh (%d)\n",size);
   if(MSVCRT_new_handler)
     (*MSVCRT_new_handler)(size);
@@ -136,4 +145,5 @@
 void* _expand(void* mem, MSVCRT_size_t size)
 {
+  TRACE("MSVCRT: _expand (%p)\n",mem);
   return HeapReAlloc(GetProcessHeap(), HEAP_REALLOC_IN_PLACE_ONLY, mem, size);
 }
@@ -142,6 +152,7 @@
  *		_heapchk (MSVCRT.@)
  */
-int _heapchk(void)
-{
+int MSVCRT__heapchk(void)
+{
+  TRACE("MSVCRT: _heapchk");
   if (!HeapValidate( GetProcessHeap(), 0, NULL))
   {
@@ -155,6 +166,7 @@
  *		_heapmin (MSVCRT.@)
  */
-int _heapmin(void)
-{
+int MSVCRT__heapmin(void)
+{
+  TRACE("MSVCRT: _heapmin");
   if (!HeapCompact( GetProcessHeap(), 0 ))
   {
@@ -169,7 +181,9 @@
  *		_heapwalk (MSVCRT.@)
  */
-int _heapwalk(_HEAPINFO* next)
+int MSVCRT__heapwalk(_HEAPINFO* next)
 {
   PROCESS_HEAP_ENTRY phe;
+
+  TRACE("MSVCRT: _heapwalk");
 
   LOCK_HEAP;
@@ -210,12 +224,14 @@
  *		_heapset (MSVCRT.@)
  */
-int _heapset(unsigned int value)
+int MSVCRT__heapset(unsigned int value)
 {
   int retval;
   _HEAPINFO heap;
 
+  TRACE("MSVCRT: _heapset");
+
   memset( &heap, 0, sizeof(_HEAPINFO) );
   LOCK_HEAP;
-  while ((retval = _heapwalk(&heap)) == _HEAPOK)
+  while ((retval = MSVCRT__heapwalk(&heap)) == _HEAPOK)
   {
     if (heap._useflag == _FREEENTRY)
@@ -229,7 +245,7 @@
  *		_heapadd (MSVCRT.@)
  */
-int _heapadd(void* mem, MSVCRT_size_t size)
-{
-  TRACE("(%p,%d) unsupported in Win32\n", mem,size);
+int MSVCRT__heapadd(void* mem, MSVCRT_size_t size)
+{
+  TRACE("MSVCRT: _heapadd (%p,%d) unsupported in Win32\n", mem,size);
   *MSVCRT__errno() = MSVCRT_ENOSYS;
   return -1;
@@ -239,7 +255,10 @@
  *		_msize (MSVCRT.@)
  */
-MSVCRT_size_t _msize(void* mem)
+MSVCRT_size_t MSVCRT__msize(void* mem)
 {
   long size = HeapSize(GetProcessHeap(),0,mem);
+
+  TRACE("MSVCRT: _msize (%p)",mem);
+
   if (size == -1)
   {
@@ -255,5 +274,8 @@
 void* MSVCRT_calloc(MSVCRT_size_t size, MSVCRT_size_t count)
 {
-  return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, size * count );
+  void *ret;
+  ret = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, size * count );
+  TRACE("MSVCRT: calloc (%d,%d) returned %p",size, count, ret);
+  return ret;
 }
 
@@ -263,5 +285,5 @@
 void MSVCRT_free(void* ptr)
 {
-  dprintf(("MSVCRT_free %x ptr",ptr));
+  dprintf(("MSVCRT: free %x ptr",ptr));
   HeapFree(GetProcessHeap(),0,ptr);
 }
@@ -269,5 +291,5 @@
 void* MSVCRT(memset)(void* ptr,int fill,MSVCRT(size_t) size)
 {
-  dprintf(("MSVCRT_memset %x(%d bytes) with %d",ptr,size,fill));
+  dprintf(("MSVCRT: memset %x(%d bytes) with %d",ptr,size,fill));
   return memset(ptr,fill,size);
 }
@@ -276,5 +298,5 @@
 void* MSVCRT(memcpy)(void* ptr,const void* ptr2,MSVCRT(size_t) size)
 {
-  dprintf(("MSVCRT_memcpy %x->%x (%d bytes)",ptr2,ptr,size));
+  dprintf(("MSVCRT: memcpy %x->%x (%d bytes)",ptr2,ptr,size));
   return memcpy(ptr,ptr2,size);
 }
@@ -287,5 +309,5 @@
 {
   void *ret = HeapAlloc(GetProcessHeap(),0,size);
-  dprintf(("MSVCRT_malloc of %d size returned %x",size,ret));
+  dprintf(("MSVCRT: malloc of %d size returned %x",size,ret));
   if (!ret)
     MSVCRT__set_errno(GetLastError());
@@ -298,5 +320,5 @@
 void* MSVCRT_realloc(void* ptr, MSVCRT_size_t size)
 {
-  dprintf(("MSVCRT_realloc %x",ptr));
+  dprintf(("MSVCRT: realloc %x",ptr));
   return HeapReAlloc(GetProcessHeap(), 0, ptr, size);
 }
Index: trunk/src/msvcrt/initmsvcrtdll.c
===================================================================
--- trunk/src/msvcrt/initmsvcrtdll.c	(revision 10005)
+++ trunk/src/msvcrt/initmsvcrtdll.c	(revision 10005)
@@ -0,0 +1,77 @@
+/*
+ * DLL entry point
+ *
+ * Copyright 1998 Sander van Leeuwen
+ * Copyright 1998 Peter Fitzsimmons
+ *
+ *
+ * Project Odin Software License can be found in LICENSE.TXT
+ *
+ */
+
+/*-------------------------------------------------------------*/
+/* INITERM.C -- Source for a custom dynamic link library       */
+/*              initialization and termination (_DLL_InitTerm) */
+/*              function.                                      */
+/*                                                             */
+/* When called to perform initialization, this sample function */
+/* gets storage for an array of integers, and initializes its  */
+/* elements with random integers.  At termination time, it     */
+/* frees the array.  Substitute your own special processing.   */
+/*-------------------------------------------------------------*/
+
+
+/* Include files */
+#include <windows.h>
+#include <win32type.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <odin.h>
+#include <odinlx.h>
+#include <misc.h>       /*PLF Wed  98-03-18 23:18:15*/
+#include <initdll.h>
+#include <exitlist.h>
+#include <os2sel.h>
+
+BOOL WIN32API MSVCRT_Init(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
+extern DWORD msvcrt_PEResTab;
+
+static HMODULE dllHandle = 0;
+
+//******************************************************************************
+//******************************************************************************
+ULONG inittermMSVCRT(ULONG hModule, ULONG ulFlag)
+{
+   /*-------------------------------------------------------------------------*/
+   /* If ulFlag is zero then the DLL is being loaded so initialization should */
+   /* be performed.  If ulFlag is 1 then the DLL is being freed so            */
+   /* termination should be performed.                                        */
+   /*-------------------------------------------------------------------------*/
+
+   switch (ulFlag) {
+      case 0 :
+         CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
+         dllHandle = RegisterLxDll(hModule, (WIN32DLLENTRY)MSVCRT_Init, (PVOID)&msvcrt_PEResTab,0,0,0);
+         if(dllHandle == 0)
+             return 0UL;
+
+         dprintf(("msvcrt init %s %s (%x)", __DATE__, __TIME__, inittermMSVCRT));
+
+         break;
+      case 1 :
+         if(dllHandle) {
+             UnregisterLxDll(dllHandle);
+         }
+         break;
+      default  :
+         return 0UL;
+   }
+
+   /***********************************************************/
+   /* A non-zero value must be returned to indicate success.  */
+   /***********************************************************/
+   return 1UL;
+}
+//******************************************************************************
+//******************************************************************************
Index: trunk/src/msvcrt/initterm.c
===================================================================
--- trunk/src/msvcrt/initterm.c	(revision 10005)
+++ trunk/src/msvcrt/initterm.c	(revision 10005)
@@ -0,0 +1,75 @@
+/*
+ * DLL entry point
+ *
+ * Copyright 1998 Sander van Leeuwen
+ * Copyright 1998 Peter Fitzsimmons
+ *
+ *
+ * Project Odin Software License can be found in LICENSE.TXT
+ *
+ */
+
+/*-------------------------------------------------------------*/
+/* INITERM.C -- Source for a custom dynamic link library       */
+/*              initialization and termination (_DLL_InitTerm) */
+/*              function.                                      */
+/*                                                             */
+/* When called to perform initialization, this sample function */
+/* gets storage for an array of integers, and initializes its  */
+/* elements with random integers.  At termination time, it     */
+/* frees the array.  Substitute your own special processing.   */
+/*-------------------------------------------------------------*/
+
+
+/* Include files */
+#include <windows.h>
+#include <odinlx.h>
+#include <misc.h>       /*PLF Wed  98-03-18 23:18:15*/
+#include <initdll.h>
+
+ void __ctordtorInit (void);
+ void __ctordtorTerm (void);
+ int _CRT_init (void);
+ void _CRT_term (void);
+
+
+/****************************************************************************/
+/* _DLL_InitTerm is the function that gets called by the operating system   */
+/* loader when it loads and frees this DLL for each process that accesses   */
+/* this DLL.  However, it only gets called the first time the DLL is loaded */
+/* and the last time it is freed for a particular process.  The system      */
+/* linkage convention MUST be used because the operating system loader is   */
+/* calling this function.                                                   */
+/****************************************************************************/
+extern void InitOverrides(void);
+
+unsigned long SYSTEM _DLL_InitTerm(unsigned long hModule, unsigned long
+                                   ulFlag)
+{
+
+   /*-------------------------------------------------------------------------*/
+   /* If ulFlag is zero then the DLL is being loaded so initialization should */
+   /* be performed.  If ulFlag is 1 then the DLL is being freed so            */
+   /* termination should be performed.                                        */
+   /*-------------------------------------------------------------------------*/
+
+   switch (ulFlag) {
+      case 0 :
+         if (_CRT_init () != 0)
+           return 0;
+         __ctordtorInit ();
+         InitOverrides();
+         return inittermMSVCRT(hModule, ulFlag);
+
+      case 1 :
+         return inittermMSVCRT(hModule, ulFlag);
+
+      default  :
+         return 0UL;
+   }
+
+   /***********************************************************/
+   /* A non-zero value must be returned to indicate success.  */
+   /***********************************************************/
+   return 1UL;
+}
Index: trunk/src/msvcrt/locale.c
===================================================================
--- trunk/src/msvcrt/locale.c	(revision 10001)
+++ trunk/src/msvcrt/locale.c	(revision 10005)
@@ -22,4 +22,8 @@
 #else
 #include <emxheader.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
 #endif
 
@@ -88,5 +92,5 @@
   for (i = 0; i < sizeof(_country_synonyms)/sizeof(char*); i += 2 )
   {
-    if (!strcasecmp(_country_synonyms[i],name))
+    if (!_stricmp(_country_synonyms[i],name))
     {
       TRACE(":Mapping synonym %s to %s\n",name,_country_synonyms[i+1]);
@@ -126,5 +130,5 @@
     return 0;
   /* Partial matches are allowed, e.g. "Germ" matches "Germany" */
-  return !strncasecmp(cmp, buff, strlen(cmp));
+  return !_strnicmp(cmp, buff, strlen(cmp));
 }
 
@@ -227,10 +231,10 @@
       {
         /* Special codepage values: OEM & ANSI */
-        if (strcasecmp(locale->search_codepage,"OCP"))
+        if (_stricmp(locale->search_codepage,"OCP"))
         {
           GetLocaleInfoA(lcid, LOCALE_IDEFAULTCODEPAGE,
                          locale->found_codepage, MAX_ELEM_LEN);
         }
-        if (strcasecmp(locale->search_codepage,"ACP"))
+        if (_stricmp(locale->search_codepage,"ACP"))
         {
           GetLocaleInfoA(lcid, LOCALE_IDEFAULTANSICODEPAGE,
@@ -261,5 +265,4 @@
 }
 
-extern int snprintf(char *, int, const char *, ...);
 
 /* INTERNAL: Set ctype behaviour for a codepage */
@@ -315,5 +318,5 @@
   int lc_all = 0;
 
-  TRACE("(%d %s)\n",category,locale);
+  TRACE("MSVCRT: setlocale (%d %s)\n",category,locale);
 
   if (category < MSVCRT_LC_MIN || category > MSVCRT_LC_MAX)
@@ -445,5 +448,5 @@
   MSVCRT_current_lc_all_lcid = lcid;
 
-  snprintf(MSVCRT_current_lc_all,MAX_LOCALE_LENGTH,"%s_%s.%s",
+  _snprintf(MSVCRT_current_lc_all,MAX_LOCALE_LENGTH,"%s_%s.%s",
 	   lc.found_language,lc.found_country,lc.found_codepage);
 
@@ -522,4 +525,5 @@
 {
   LOCK_LOCALE;
+  dprintf(("MSVCRT: _setmbcp %d",cp));
   if (MSVCRT_current_lc_all_cp != cp)
   {
@@ -535,4 +539,20 @@
 int _getmbcp(void)
 {
+  dprintf(("MSVCRT: _getmbcp"));
   return MSVCRT_current_lc_all_cp;
 }
+
+/*********************************************************************
+ *		__crtLCMapStringA (MSVCRT.@)
+ */
+int __crtLCMapStringA(
+  LCID lcid, DWORD mapflags, const char* src, int srclen, char* dst,
+  int dstlen, unsigned int codepage, int xflag
+) {
+  FIXME("(lcid %lx, flags %lx, %s(%d), %p(%d), %x, %d), partial stub!\n",
+        lcid,mapflags,src,srclen,dst,dstlen,codepage,xflag);
+  /* FIXME: A bit incorrect. But msvcrt itself just converts its
+   * arguments to wide strings and then calls LCMapStringW
+   */
+  return LCMapStringA(lcid,mapflags,src,srclen,dst,dstlen);
+}
Index: trunk/src/msvcrt/lock.c
===================================================================
--- trunk/src/msvcrt/lock.c	(revision 10001)
+++ trunk/src/msvcrt/lock.c	(revision 10005)
@@ -101,5 +101,5 @@
 void _lock( int locknum )
 {
-  TRACE( "(%d)\n", locknum );
+  TRACE( "MSVCRT: _lock (%d)\n", locknum );
 
   /* If the lock doesn't exist yet, create it */
@@ -130,5 +130,5 @@
 void _unlock( int locknum )
 {
-  TRACE( "(%d)\n", locknum );
+  TRACE( "MSVCRT: _unlock (%d)\n", locknum );
 
   LeaveCriticalSection( &(lock_table[ locknum ].crit) );
Index: trunk/src/msvcrt/main.c
===================================================================
--- trunk/src/msvcrt/main.c	(revision 10001)
+++ trunk/src/msvcrt/main.c	(revision 10005)
@@ -22,5 +22,5 @@
 #include "msvcrt/locale.h"
 #include "msvcrt/stdio.h"
-
+#include <string.h>
 #include "wine/debug.h"
 
@@ -47,32 +47,4 @@
 
 
-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
@@ -90,5 +62,5 @@
   {
   case DLL_PROCESS_ATTACH:
-    if (!msvcrt_init_tls())
+   if (!msvcrt_init_tls())
       return FALSE;
     msvcrt_init_mt_locks();
Index: trunk/src/msvcrt/mainmsvcrt20.c
===================================================================
--- trunk/src/msvcrt/mainmsvcrt20.c	(revision 10001)
+++ trunk/src/msvcrt/mainmsvcrt20.c	(revision 10005)
@@ -18,4 +18,16 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+#include <windows.h>
+#include <win32type.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <odin.h>
+#include <odinlx.h>
+#include <misc.h>       /*PLF Wed  98-03-18 23:18:15*/
+#include <initdll.h>
+#include <exitlist.h>
+#include <os2sel.h>
+
 #include "msvcrt.h"
 #define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF)
@@ -37,9 +49,4 @@
 typedef void (*MSVCRT_free_func)(void*);
 
-int _CRT_init (void);
-void _CRT_term (void);
-void __ctordtorInit (void);
-void __ctordtorTerm (void);
-
 static HMODULE dllHandle = 0;
 
@@ -53,20 +60,15 @@
     {
        case 0:
-         if (_CRT_init () != 0)
-           return 0;
-         __ctordtorInit ();
 
          dllHandle = RegisterLxDll(mod_handle, MSVCRT20_Init, 0,0,0,0);
+         return 1;
 
-        return 1;
        case 1:
-         __ctordtorTerm ();
-         _CRT_term ();
 
          if(dllHandle) {
              UnregisterLxDll(dllHandle);
          }
+         return 1;
 
-         return 1;
        default:
          return 0;
@@ -80,5 +82,5 @@
 BOOL WINAPI MSVCRT20_Init(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
 {
- return MSVCRT_Init(hinstDLL, fdwReason, lpvReserved);
+ return TRUE;
 }
  
Index: trunk/src/msvcrt/mainmsvcrt40.c
===================================================================
--- trunk/src/msvcrt/mainmsvcrt40.c	(revision 10001)
+++ trunk/src/msvcrt/mainmsvcrt40.c	(revision 10005)
@@ -18,4 +18,17 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
+#include <windows.h>
+#include <win32type.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <odin.h>
+#include <odinlx.h>
+#include <misc.h>       /*PLF Wed  98-03-18 23:18:15*/
+#include <initdll.h>
+#include <exitlist.h>
+#include <os2sel.h>
+
 #include "msvcrt.h"
 #define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF)
@@ -37,9 +50,4 @@
 typedef void (*MSVCRT_free_func)(void*);
 
-int _CRT_init (void);
-void _CRT_term (void);
-void __ctordtorInit (void);
-void __ctordtorTerm (void);
-
 static HMODULE dllHandle = 0;
 
@@ -53,14 +61,7 @@
     {
        case 0:
-         if (_CRT_init () != 0)
-           return 0;
-         __ctordtorInit ();
-
          dllHandle = RegisterLxDll(mod_handle, MSVCRT40_Init, 0,0,0,0);
-
-        return 1;
+         return 1;
        case 1:
-         __ctordtorTerm ();
-         _CRT_term ();
 
          if(dllHandle) {
@@ -80,5 +81,5 @@
 BOOL WINAPI MSVCRT40_Init(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
 {
- return MSVCRT_Init(hinstDLL, fdwReason, lpvReserved);
+ return TRUE;
 }
  
Index: trunk/src/msvcrt/math.c
===================================================================
--- trunk/src/msvcrt/math.c	(revision 10001)
+++ trunk/src/msvcrt/math.c	(revision 10005)
@@ -20,4 +20,9 @@
 #ifdef __WIN32OS2__
 #include <emxheader.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+extern double logb(double);
+extern double scalb(double,double);
 #else
 #include "config.h"
@@ -29,5 +34,5 @@
 #define __USE_ISOC9X 1
 #define __USE_ISOC99 1
-#include <math.h>
+
 #ifdef HAVE_IEEEFP_H
 #include <ieeefp.h>
@@ -43,5 +48,5 @@
 #ifndef finite /* Could be a macro */
 #ifdef isfinite
-#define finite(x) isfinite(x)
+#define finite(x) isfinite(x) 
 #else
 #define finite(x) (!isnan(x)) /* At least catch some cases */
@@ -135,4 +140,5 @@
 {
   FPU_DOUBLE(x);
+  dprintf(("MSVCRT: _CIacos"));
   if (x < -1.0 || x > 1.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
   return acos(x);
@@ -145,4 +151,5 @@
 {
   FPU_DOUBLE(x);
+  dprintf(("MSVCRT: _CIacos"));
   if (x < -1.0 || x > 1.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
   return asin(x);
@@ -155,4 +162,5 @@
 {
   FPU_DOUBLE(x);
+  dprintf(("MSVCRT: _CIacos"));
   if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
   return atan(x);
@@ -165,4 +173,5 @@
 {
   FPU_DOUBLES(x,y);
+  dprintf(("MSVCRT: _CIacos"));
   if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
   return atan2(x,y);
@@ -175,4 +184,5 @@
 {
   FPU_DOUBLE(x);
+  dprintf(("MSVCRT: _CIacos"));
   if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
   return cos(x);
@@ -185,4 +195,5 @@
 {
   FPU_DOUBLE(x);
+  dprintf(("MSVCRT: _CIacos"));
   if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
   return cosh(x);
@@ -195,4 +206,5 @@
 {
   FPU_DOUBLE(x);
+  dprintf(("MSVCRT: _CIacos"));
   if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
   return exp(x);
@@ -205,5 +217,7 @@
 {
   FPU_DOUBLES(x,y);
-  if (!finite(x) || !finite(y)) *MSVCRT__errno() = MSVCRT_EDOM;
+  dprintf(("MSVCRT: _CIfmod %f %f",x,y));  
+  if (!finite(x) || !finite(y)) { *MSVCRT__errno() = MSVCRT_EDOM; dprintf(("ERROR!")); }
+  dprintf(("MSVCRT: _CIfmod returning %f",fmod(x,y)));  
   return fmod(x,y);
 }
@@ -215,4 +229,5 @@
 {
   FPU_DOUBLE(x);
+  dprintf(("MSVCRT: _CIacos"));
   if (x < 0.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
   if (x == 0.0) *MSVCRT__errno() = MSVCRT_ERANGE;
@@ -226,4 +241,5 @@
 {
   FPU_DOUBLE(x);
+  dprintf(("MSVCRT: _CIacos"));
   if (x < 0.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
   if (x == 0.0) *MSVCRT__errno() = MSVCRT_ERANGE;
@@ -238,4 +254,5 @@
   double z;
   FPU_DOUBLES(x,y);
+  dprintf(("MSVCRT: _CIacos"));
   /* FIXME: If x < 0 and y is not integral, set EDOM */
   z = pow(x,y);
@@ -250,4 +267,5 @@
 {
   FPU_DOUBLE(x);
+  dprintf(("MSVCRT: _CIacos"));
   if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
   return sin(x);
@@ -260,4 +278,5 @@
 {
   FPU_DOUBLE(x);
+  dprintf(("MSVCRT: _CIacos"));
   if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
   return sinh(x);
@@ -270,4 +289,5 @@
 {
   FPU_DOUBLE(x);
+  dprintf(("MSVCRT: _CIacos"));
   if (x < 0.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
   return sqrt(x);
@@ -280,4 +300,5 @@
 {
   FPU_DOUBLE(x);
+  dprintf(("MSVCRT: _CIacos"));
   if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
   return tan(x);
@@ -290,4 +311,5 @@
 {
   FPU_DOUBLE(x);
+  dprintf(("MSVCRT: _CIacos"));
   if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
   return tanh(x);
@@ -324,4 +346,5 @@
 int _fpclass(double num)
 {
+  dprintf(("MSVCRT: _fpclass"));
 #if defined(HAVE_FPCLASS) || defined(fpclass)
   switch (fpclass( num ))
@@ -358,5 +381,5 @@
  *		_rotl (MSVCRT.@)
  */
-unsigned int _rotl(unsigned int num, int shift)
+unsigned int MSVCRT__rotl(unsigned int num, int shift)
 {
   shift &= 31;
@@ -369,4 +392,5 @@
 double _logb(double num)
 {
+  dprintf(("MSVCRT: _logb"));
   if (!finite(num)) *MSVCRT__errno() = MSVCRT_EDOM;
   return logb(num);
@@ -376,6 +400,7 @@
  *		_lrotl (MSVCRT.@)
  */
-unsigned long _lrotl(unsigned long num, int shift)
-{
+unsigned long MSVCRT__lrotl(unsigned long num, int shift)
+{
+  dprintf(("MSVCRT: _lrotl"));
   shift &= 0x1f;
   return (num << shift) | (num >> (32-shift));
@@ -385,6 +410,7 @@
  *		_lrotr (MSVCRT.@)
  */
-unsigned long _lrotr(unsigned long num, int shift)
-{
+unsigned long MSVCRT__lrotr(unsigned long num, int shift)
+{
+  dprintf(("MSVCRT: _lrotr"));
   shift &= 0x1f;
   return (num >> shift) | (num << (32-shift));
@@ -394,6 +420,7 @@
  *		_rotr (MSVCRT.@)
  */
-unsigned int _rotr(unsigned int num, int shift)
-{
+unsigned int MSVCRT__rotr(unsigned int num, int shift)
+{
+    dprintf(("MSVCRT: _rotr"));
     shift &= 0x1f;
     return (num >> shift) | (num << (32-shift));
@@ -406,4 +433,5 @@
 {
   /* Note - Can't forward directly as libc expects y as double */
+  dprintf(("MSVCRT: _scalb"));
   double dblpower = (double)power;
   if (!finite(num)) *MSVCRT__errno() = MSVCRT_EDOM;
@@ -414,5 +442,5 @@
  *		_matherr (MSVCRT.@)
  */
-int _matherr(MSVCRT_exception *e)
+int MSVCRT__matherr(MSVCRT_exception *e)
 {
   if (e)
@@ -478,5 +506,5 @@
 {
   double z = ldexp(num,exp);
-
+  dprintf(("MSVCRT: ldexpp"));
   if (!finite(z))
     *MSVCRT__errno() = MSVCRT_ERANGE;
@@ -489,6 +517,7 @@
  *		_cabs (MSVCRT.@)
  */
-double _cabs(MSVCRT_complex num)
-{
+double MSVCRT__cabs(MSVCRT_complex num)
+{
+  dprintf(("MSVCRT: _cabs"));
   return sqrt(num.real * num.real + num.imaginary * num.imaginary);
 }
@@ -499,4 +528,5 @@
 double _chgsign(double num)
 {
+   dprintf(("MSVCRT: _chgsign"));
   /* FIXME: +-infinity,Nan not tested */
   return -num;
@@ -506,5 +536,5 @@
  *		_control87 (MSVCRT.@)
  */
-unsigned int _control87(unsigned int newval, unsigned int mask)
+unsigned int MSVCRT__control87(unsigned int newval, unsigned int mask)
 {
 #if defined(__GNUC__) && defined(__i386__)
@@ -579,5 +609,5 @@
 {
 #ifdef __i386__
-  return _control87( newval, mask & ~_EM_DENORMAL );
+  return MSVCRT__control87( newval, mask & ~_EM_DENORMAL );
 #else
   FIXME(":Not Implemented!\n");
@@ -589,6 +619,7 @@
  *		_copysign (MSVCRT.@)
  */
-double _copysign(double num, double sign)
-{
+double MSVCRT__copysign(double num, double sign)
+{
+  dprintf(("MSVCRT: _CIacos"));
   /* FIXME: Behaviour for Nan/Inf? */
   if (sign < 0.0)
@@ -602,4 +633,5 @@
 int  _finite(double num)
 {
+  dprintf(("MSVCRT: _finite for %f returns %d",num, finite(num)?1:0));
   return (finite(num)?1:0); /* See comment for _isnan() */
 }
@@ -608,5 +640,5 @@
  *		_fpreset (MSVCRT.@)
  */
-void _fpreset(void)
+void MSVCRT__fpreset(void)
 {
 #if defined(__GNUC__) && defined(__i386__)
@@ -625,4 +657,5 @@
    * Do the same, as the result may be used in calculations
    */
+  dprintf(("MSVCRT: _isnan for %f returns %d",num, isnan(num)?1:0));
   return isnan(num) ? 1 : 0;
 }
@@ -631,7 +664,8 @@
  *		_y0 (MSVCRT.@)
  */
-double _y0(double num)
+double MSVCRT__y0(double num)
 {
   double retval;
+  dprintf(("MSVCRT: _CIacos"));
   if (!finite(num)) *MSVCRT__errno() = MSVCRT_EDOM;
   retval  = y0(num);
@@ -647,7 +681,8 @@
  *		_y1 (MSVCRT.@)
  */
-double _y1(double num)
+double MSVCRT__y1(double num)
 {
   double retval;
+  dprintf(("MSVCRT: _CIacos"));
   if (!finite(num)) *MSVCRT__errno() = MSVCRT_EDOM;
   retval  = y1(num);
@@ -663,7 +698,8 @@
  *		_yn (MSVCRT.@)
  */
-double _yn(int order, double num)
+double MSVCRT__yn(int order, double num)
 {
   double retval;
+  dprintf(("MSVCRT: _CIacos"));
   if (!finite(num)) *MSVCRT__errno() = MSVCRT_EDOM;
   retval  = yn(order,num);
@@ -679,10 +715,58 @@
  *		_nextafter (MSVCRT.@)
  */
-double _nextafter(double num, double next)
+double MSVCRT__nextafter(double num, double next)
 {
   double retval;
+  dprintf(("MSVCRT: _CIacos"));
   if (!finite(num) || !finite(next)) *MSVCRT__errno() = MSVCRT_EDOM;
-  retval = nextafter(num,next);
+  retval = MSVCRT__nextafter(num,next);
   return retval;
+}
+
+/*********************************************************************
+ *		_ecvt (MSVCRT.@)
+ */
+char *_ecvt( double number, int ndigits, int *decpt, int *sign )
+{
+    MSVCRT_thread_data *data = msvcrt_get_thread_data();
+    char *dec;
+
+    if (!data->efcvt_buffer)
+        data->efcvt_buffer = MSVCRT_malloc( 80 ); /* ought to be enough */
+
+    _snprintf(data->efcvt_buffer, 80, "%.*e", ndigits /* FIXME wrong */, number);
+    *sign = (number < 0);
+    dec = strchr(data->efcvt_buffer, '.');
+    *decpt = (dec) ? dec - data->efcvt_buffer : -1;
+    return data->efcvt_buffer;
+}
+
+/***********************************************************************
+ *		_fcvt  (MSVCRT.@)
+ */
+char *_fcvt( double number, int ndigits, int *decpt, int *sign )
+{
+    MSVCRT_thread_data *data = msvcrt_get_thread_data();
+    char *dec;
+
+    if (!data->efcvt_buffer)
+        data->efcvt_buffer = MSVCRT_malloc( 80 ); /* ought to be enough */
+
+    _snprintf(data->efcvt_buffer, 80, "%.*e", ndigits, number);
+    *sign = (number < 0);
+    dec = strchr(data->efcvt_buffer, '.');
+    *decpt = (dec) ? dec - data->efcvt_buffer : -1;
+    return data->efcvt_buffer;
+}
+
+/***********************************************************************
+ *		_gcvt  (MSVCRT.@)
+ *
+ * FIXME: uses both E and F.
+ */
+char *MSVCRT__gcvt( double number, int ndigit, char *buff )
+{
+    sprintf(buff, "%.*E", ndigit, number);
+    return buff;
 }
 
@@ -695,9 +779,10 @@
  */
 #ifdef __i386__
-LONGLONG MSVCRT_div(int num, int denom)
-{
-  LONGLONG retval;
+long long MSVCRT_div(int num, int denom)
+{
+  long long retval;
   div_t dt = div(num,denom);
-  retval = ((LONGLONG)dt.rem << 32) | dt.quot;
+  dprintf(("MSVCRT: div"));
+  retval = ((long long)dt.rem << 32) | dt.quot;
   return retval;
 }
@@ -731,4 +816,5 @@
   ULONGLONG retval;
   ldiv_t ldt = ldiv(num,denom);
+  dprintf(("MSVCRT: ldiv"));
   retval = ((ULONGLONG)ldt.rem << 32) | (ULONG)ldt.quot;
   return retval;
@@ -1001,2 +1087,11 @@
   TRACE("(): stub\n");
 }
+
+
+double MSVCRT_atof (__const__ char * str)
+{
+ double res;
+ res = atof(str);
+ dprintf(("MSVCRT: _atof - convert %s - result %f",str,res));
+ return res;
+}
Index: trunk/src/msvcrt/mbcs.c
===================================================================
--- trunk/src/msvcrt/mbcs.c	(revision 10001)
+++ trunk/src/msvcrt/mbcs.c	(revision 10005)
@@ -35,4 +35,7 @@
 #include "wine/debug.h"
 
+#include <string.h>
+#include <ctype.h>
+
 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
 
@@ -67,4 +70,5 @@
 unsigned char* __p__mbctype(void)
 {
+  dprintf(("MSVCRT: Query for __p__mbctype"));
   return MSVCRT_mbctype;
 }
@@ -75,4 +79,5 @@
 int* __p___mb_cur_max(void)
 {
+  dprintf(("MSVCRT: Query for __p__mb_cur_max"));
   return &MSVCRT___mb_cur_max;
 }
@@ -83,4 +88,5 @@
 unsigned int _mbsnextc(const unsigned char* str)
 {
+  dprintf(("MSVCRT: _mbsnextc"));
   if(MSVCRT___mb_cur_max > 1 && MSVCRT_isleadbyte(*str))
     return *str << 8 | str[1];
@@ -93,4 +99,5 @@
 unsigned int _mbctolower(unsigned int c)
 {
+    dprintf(("MSVCRT: _mbctolower"));
     if (MSVCRT_isleadbyte(c))
     {
@@ -106,4 +113,5 @@
 unsigned int _mbctoupper(unsigned int c)
 {
+     dprintf(("MSVCRT: _mbctoupper"));
     if (MSVCRT_isleadbyte(c))
     {
@@ -119,4 +127,5 @@
 unsigned char* _mbsdec(const unsigned char* start, const unsigned char* cur)
 {
+  dprintf(("MSVCRT: _mbsdec"));
   if(MSVCRT___mb_cur_max > 1)
     return (char *)(_ismbstrail(start,cur-1) ? cur - 2 : cur -1);
@@ -130,4 +139,5 @@
 unsigned char* _mbsinc(const unsigned char* str)
 {
+  dprintf(("MSVCRT: _mbsinc"));
   if(MSVCRT___mb_cur_max > 1 && MSVCRT_isleadbyte(*str))
     return (unsigned char*)str + 2; /* MB char */
@@ -141,4 +151,5 @@
 unsigned char* _mbsninc(const unsigned char* str, MSVCRT_size_t num)
 {
+  dprintf(("MSVCRT: _mbsninc"));
   if(!str || num < 1)
     return NULL;
@@ -157,4 +168,5 @@
 unsigned int _mbclen(const unsigned char* str)
 {
+  dprintf(("MSVCRT: _mbclen"));
   return MSVCRT_isleadbyte(*str) ? 2 : 1;
 }
@@ -165,4 +177,5 @@
 int MSVCRT_mblen(const char* str, MSVCRT_size_t size)
 {
+  dprintf(("MSVCRT: mblen"));
   if (str && *str && size)
   {
@@ -180,4 +193,5 @@
 MSVCRT_size_t _mbslen(const unsigned char* str)
 {
+  dprintf(("MSVCRT: _mbslen"));
   if(MSVCRT___mb_cur_max > 1)
   {
@@ -198,4 +212,5 @@
 MSVCRT_size_t _mbstrlen(const char* str)
 {
+  dprintf(("MSVCRT: _mbstrlen"));
   if(MSVCRT___mb_cur_max > 1)
   {
@@ -219,4 +234,5 @@
 void _mbccpy(unsigned char* dest, const unsigned char* src)
 {
+  dprintf(("MSVCRT: _mbccpy"));
   *dest++ = *src;
   if(MSVCRT___mb_cur_max > 1 && MSVCRT_isleadbyte(*src))
@@ -231,4 +247,5 @@
 unsigned char* _mbsncpy(unsigned char* dst, const unsigned char* src, MSVCRT_size_t n)
 {
+  dprintf(("MSVCRT: _mbsncpy"));
   if(!n)
     return dst;
@@ -254,4 +271,5 @@
 unsigned char* _mbsnbcpy(unsigned char* dst, const unsigned char* src, MSVCRT_size_t n)
 {
+  dprintf(("MSVCRT: _mbsnbcpy"));
   if(!n)
     return dst;
@@ -288,4 +306,5 @@
 int _mbscmp(const unsigned char* str, const unsigned char* cmp)
 {
+  dprintf(("MSVCRT: _mbscmp"));
   if(MSVCRT___mb_cur_max > 1)
   {
@@ -308,7 +327,8 @@
 
 /*********************************************************************
- *		_mbsicmp(MSVCRT.@)
- */
-int _mbsicmp(const unsigned char* str, const unsigned char* cmp)
+ *		_mbsicoll(MSVCRT.@)
+ * FIXME: handle locales.
+ */
+int _mbsicoll(const unsigned char* str, const unsigned char* cmp)
 {
   if(MSVCRT___mb_cur_max > 1)
@@ -332,8 +352,34 @@
 
 /*********************************************************************
+ *		_mbsicmp(MSVCRT.@)
+ */
+int _mbsicmp(const unsigned char* str, const unsigned char* cmp)
+{
+  dprintf(("MSVCRT: _mbsicmp"));
+  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 _stricmp(str, cmp); /* ASCII CP */
+}
+
+/*********************************************************************
  *		_mbsncmp(MSVCRT.@)
  */
 int _mbsncmp(const unsigned char* str, const unsigned char* cmp, MSVCRT_size_t len)
 {
+  dprintf(("MSVCRT: _mbsncmp"));
   if(!len)
     return 0;
@@ -367,4 +413,5 @@
 int _mbsnbcmp(const unsigned char* str, const unsigned char* cmp, MSVCRT_size_t len)
 {
+  dprintf(("MSVCRT: _mbsnbcmp"));
   if (!len)
     return 0;
@@ -412,4 +459,5 @@
 int _mbsnicmp(const unsigned char* str, const unsigned char* cmp, MSVCRT_size_t len)
 {
+  dprintf(("MSVCRT: _mbsnicmp"));
   /* FIXME: No tolower() for mb strings yet */
   if(MSVCRT___mb_cur_max > 1)
@@ -439,4 +487,5 @@
 int _mbsnbicmp(const unsigned char* str, const unsigned char* cmp, MSVCRT_size_t len)
 {
+  dprintf(("MSVCRT: _mbsnbicmp"));
   if (!len)
     return 0;
@@ -486,4 +535,5 @@
 unsigned char* _mbschr(const unsigned char* s, unsigned int x)
 {
+  dprintf(("MSVCRT: _mbschr"));
   if(MSVCRT___mb_cur_max > 1)
   {
@@ -507,4 +557,5 @@
 unsigned char* _mbsrchr(const unsigned char* s, unsigned int x)
 {
+  dprintf(("MSVCRT: _mbsrchr"));
   if(MSVCRT___mb_cur_max > 1)
   {
@@ -526,8 +577,44 @@
 
 /*********************************************************************
+ *		_mbstok(MSVCRT.@)
+ *
+ * Find and extract tokens from strings
+ */
+unsigned char* _mbstok(unsigned char *str, const unsigned char *delim)
+{
+    MSVCRT_thread_data *data = msvcrt_get_thread_data();
+    char *ret;
+
+    if(MSVCRT___mb_cur_max > 1)
+    {
+	unsigned int c;
+
+	if (!str)
+    	    if (!(str = data->mbstok_next)) return NULL;
+
+	while ((c = _mbsnextc(str)) && _mbschr(delim, c)) {
+	    str += c > 255 ? 2 : 1;
+	}
+	if (!*str) return NULL;
+	ret = str++;
+	while ((c = _mbsnextc(str)) && !_mbschr(delim, c)) {
+	    str += c > 255 ? 2 : 1;
+	}
+	if (*str) {
+	    *str++ = 0;
+	    if (c > 255) *str++ = 0;
+	}
+	data->mbstok_next = str;
+	return ret;
+    }
+    return strtok(str, delim);	/* ASCII CP */
+}
+
+/*********************************************************************
  *		mbtowc(MSVCRT.@)
  */
 int MSVCRT_mbtowc(MSVCRT_wchar_t *dst, const char* str, MSVCRT_size_t n)
 {
+  dprintf(("MSVCRT: _mbtowc"));
   if(n <= 0 || !str)
     return 0;
@@ -547,4 +634,5 @@
 unsigned int _mbbtombc(unsigned int c)
 {
+  dprintf(("MSVCRT: _mbbtombc"));
   if(MSVCRT___mb_cur_max > 1 &&
      ((c >= 0x20 && c <=0x7e) ||(c >= 0xa1 && c <= 0xdf)))
@@ -562,4 +650,5 @@
 int _ismbbkana(unsigned int c)
 {
+  dprintf(("MSVCRT: _ismbbkana"));
   /* FIXME: use lc_ctype when supported, not lc_all */
   if(MSVCRT_current_lc_all_cp == 932)
@@ -577,4 +666,5 @@
 {
     MSVCRT_wchar_t wch = msvcrt_mbc_to_wc( ch );
+    dprintf(("MSVCRT: _ismbcdigit"));
     return (get_char_typeW( wch ) & C1_DIGIT);
 }
@@ -752,5 +842,5 @@
 
   if(MSVCRT___mb_cur_max == 1 || c < 256)
-    return _strset(str, c); /* ASCII CP or SB char */
+    return MSVCRT__strset(str, c); /* ASCII CP or SB char */
 
   c &= 0xffff; /* Strip high bits */
@@ -768,4 +858,34 @@
 
 /*********************************************************************
+ *		_mbsnbset(MSVCRT.@)
+ */
+unsigned char* _mbsnbset(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 > 1))
+    {
+	*str++ = c >> 8;
+	len--;
+	*str++ = c & 0xff;
+	len--;
+    }
+    if(len && str[0]) {
+	/* as per msdn pad with a blank character */
+	str[0] = ' ';
+    }
+
+    return ret;
+}
+
+/*********************************************************************
  *		_mbsnset(MSVCRT.@)
  */
@@ -778,5 +898,5 @@
 
   if(MSVCRT___mb_cur_max == 1 || c < 256)
-    return _strnset(str, c, len); /* ASCII CP or SB char */
+    return MSVCRT__strnset(str, c, len); /* ASCII CP or SB char */
 
   c &= 0xffff; /* Strip high bits */
@@ -842,4 +962,30 @@
 }
 
+
+/*********************************************************************
+ *		_mbsnbcat(MSVCRT.@)
+ */
+unsigned char* _mbsnbcat(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++)) {
+		if (*dst) {
+		    dst++;
+		} else {
+		    /* as per msdn overwrite the lead byte in front of '\0' */
+		    dst--;
+		    break;
+		}
+	    }
+	}
+        while (*src && len--) *dst++ = *src++;
+        *dst = '\0';
+        return res;
+    }
+    return strncat(dst, src, len); /* ASCII CP */
+}
 
 /*********************************************************************
Index: trunk/src/msvcrt/misc.c
===================================================================
--- trunk/src/msvcrt/misc.c	(revision 10001)
+++ trunk/src/msvcrt/misc.c	(revision 10005)
@@ -21,5 +21,7 @@
 #include "msvcrt.h"
 #include <stdlib.h>
-
+#include <string.h>
+#include <math.h>
+#include "emxheader.h"
 #include "msvcrt/stdlib.h"
 
@@ -50,5 +52,5 @@
  *		_sleep (MSVCRT.@)
  */
-void _sleep(unsigned long timeout)
+void MSVCRT__sleep(unsigned long timeout)
 {
   TRACE("_sleep for %ld milliseconds\n",timeout);
@@ -59,9 +61,10 @@
  *		_lfind (MSVCRT.@)
  */
-void* _lfind(const void* match, const void* start,
+void* MSVCRT__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;
+  dprintf(("MSVCRT: _lfind"));
   if (size)
     do
@@ -77,9 +80,10 @@
  *		_lsearch (MSVCRT.@)
  */
-void* _lsearch(const void* match, void* start,
+void* MSVCRT__lsearch(const void* match, void* start,
                unsigned int* array_size, unsigned int elem_size,
                MSVCRT_compar_fn_t cf)
 {
   unsigned int size = *array_size;
+  dprintf(("MSVCRT: _lsearch"));
   if (size)
     do
@@ -96,11 +100,57 @@
 }
 
+
 /*********************************************************************
  *		_chkesp (MSVCRT.@)
+ *
+ * Trap to a debugger if the value of the stack pointer has changed.
+ *
+ * PARAMS
+ *  None.
+ *
+ * RETURNS
+ *  Does not return.
+ *
+ * NOTES
+ *  This function is available for iX86 only.
+ *
+ *  When VC++ generates debug code, it stores the value of the stack pointer
+ *  before calling any external function, and checks the value following
+ *  the call. It then calls this function, which will trap if the values are
+ *  not the same. Usually this means that the prototype used to call
+ *  the function is incorrect.  It can also mean that the .spec entry has
+ *  the wrong calling convention or parameters.
  */
-void _chkesp(void)
+#ifdef __i386__
+
+# ifdef __GNUC__
+__ASM_GLOBAL_FUNC(_chkesp,
+                  "jnz 1f\n\t"
+                  "ret\n"
+                  "1:\tpushl %ebp\n\t"
+                  "movl %esp,%ebp\n\t"
+                  "pushl %eax\n\t"
+                  "pushl %ecx\n\t"
+                  "pushl %edx\n\t"
+                  "call " __ASM_NAME("MSVCRT_chkesp_fail") "\n\t"
+                  "popl %edx\n\t"
+                  "popl %ecx\n\t"
+                  "popl %eax\n\t"
+                  "popl %ebp\n\t"
+                  "ret");
+
+void MSVCRT_chkesp_fail(void)
 {
+  ERR("Stack pointer incorrect after last function call - Bad prototype/spec entry?\n");
+  DebugBreak();
+}
 
-}
+# else  /* __GNUC__ */
+void _chkesp(void) { }
+# endif  /* __GNUC__ */
+
+#endif  /* __i386__ */
+
+
 
 #ifdef __WIN32OS2__
@@ -116,12 +166,14 @@
  *	[GNUC && i386]
  */
+double _emx_rint (double);
+
 #if defined(__GNUC__) && defined(__i386__)
-LONG __cdecl _ftol(void)
+LONGLONG __cdecl _ftol(double fl)
 {
 	/* 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;
+	return (LONGLONG)(fl);
+
 }
 #endif /* defined(__GNUC__) && defined(__i386__) */
Index: trunk/src/msvcrt/msvcrt.def
===================================================================
--- trunk/src/msvcrt/msvcrt.def	(revision 10001)
+++ trunk/src/msvcrt/msvcrt.def	(revision 10005)
@@ -4,138 +4,9 @@
 
 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
   NTDLL_wcsicmp = NTDLL._wcsicmp
   NTDLL_wcsupr = NTDLL._wcsupr
-  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
-  ODINCRT_fcvt = ODINCRT.277 
   RtlTimeToSecondsSince1970 = NTDLL.559
   RtlSecondsSince1970ToTime = NTDLL.526
@@ -194,6 +65,6 @@
    ??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
+   ??8type_info@@QBEHABV0@@Z = _MSVCRT_type_info_opequals_equals@8	@23
+   ??9type_info@@QBEHABV0@@Z = _MSVCRT_type_info_opnot_equals@8	@24
 
    ??_E__non_rtti_object@@UAEPAXI@Z = MSVCRT___non_rtti_object__unknown_E	@26
@@ -207,6 +78,6 @@
    ?_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
+   ?name@type_info@@QBEPBDXZ = _MSVCRT_type_info_name@4	@36
+   ?raw_name@type_info@@QBEPBDXZ = _MSVCRT_type_info_raw_name@4	@37
    ?set_new_handler@@YAP6AXXZP6AXXZ@Z = MSVCRT__set_new_handler	@38
    ?set_terminate@@YAP6AXXZP6AXXZ@Z = MSVCRT_set_terminate	@39
@@ -252,5 +123,5 @@
    __argv = MSVCRT___argv	@79
    __dllonexit = __dllonexit	@80
-  __doserrno = __doserrno	@81
+  __doserrno = MSVCRT_doserrno	@81
   __getmainargs = __getmainargs	@82
   __initenv = MSVCRT___initenv	@83
@@ -260,4 +131,5 @@
   __lconv_init = __lconv_init	@87
   __mb_cur_max = MSVCRT___mb_cur_max	@88
+  __crtLCMapStringA @89
 
   __p___argc = __p___argc	@90
@@ -268,79 +140,81 @@
   __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
+  __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
+  __p__daylight = MSVCRT___p__daylight @110
+  __p__pgmptr @114
+
+  __set_app_type = MSVCRT___set_app_type	@111
+  __setlc_active = MSVCRT___setlc_active	@112
+  __setusermatherr = MSVCRT___setusermatherr	@113
+
+  __threadhandle = MSVCRT_GetCurrentThread	@115
+  __threadid = MSVCRT_GetCurrentThreadId	@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            	@122
+  __winitenv = MSVCRT___winitenv	@123
+  _abnormal_termination = _abnormal_termination	@124
+  _access = MSVCRT__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
+ _beginthread = MSVCRT__beginthread	@145
  _beginthreadex 	@146
  _c_exit = MSVCRT__c_exit	@147
- _cabs	@148
+ _cabs = MSVCRT__cabs	@148
  _callnewh	@149
  _cexit = MSVCRT__cexit	@150
- _cgets	@151
- _chdir	@152
- _chdrive	@153
+ _cgets = MSVCRT__cgets	@151
+ _chdir = MSVCRT__chdir	@152
+ _chdrive = MSVCRT__chdrive	@153
  _chgsign	@154
  _chkesp	@155
- _chmod	@156
+ _chmod	= MSVCRT__chmod @156
  _clearfp	@157
- _close	@158
+ _close = MSVCRT__close	@158
  _commit	@159
  _commode = MSVCRT__commode	@160
- _control87	@161
+ _control87 = MSVCRT__control87	@161
  _controlfp	@162
  _copysign	@163
- _cprintf	@164
- _cputs	@165
- _creat	@166
- _cscanf	@167
+ _cprintf = MSVCRT__cprintf	@164
+ _cputs = MSVCRT__cputs	@165
+ _creat = MSVCRT__creat	@166
+ _cscanf = MSVCRT__cscanf	@167
  _ctype = MSVCRT__ctype	@168
- _cwait	@169
- _ecvt = CRTDLL_ecvt	@170
- _endthread = MSVCRT_endthread	@171
+ _cwait = MSVCRT__cwait	@169
+ _ecvt   @170
+ _endthread = MSVCRT__endthread	@171
  _endthreadex	@172
  _environ = MSVCRT__environ	@173
@@ -349,24 +223,24 @@
  _except_handler2	@176
  _except_handler3	@177
- _execl	@178
+ _execl	= MSVCRT__execl  @178
 ; @ stub _execle #(str str) varargs	@179
- _execlp	@180
+ _execlp = MSVCRT__execlp	@180
 ;# stub _execlpe #(str str) varargs	@181
- _execv	@182
- _execve	@183
- _execvp	@184
- _execvpe	@185
+ _execv = MSVCRT__execv	@182
+ _execve = MSVCRT__execve	@183
+ _execvp = MSVCRT__execvp @184
+ _execvpe = MSVCRT__execvpe	@185
  _exit = MSVCRT__exit	@186
  _expand	@187
- _fcloseall	@188
- _fcvt = ODINCRT_fcvt    	@189
- _fdopen	@190
- _fgetchar	@191
+ _fcloseall = MSVCRT__fcloseall	@188
+ _fcvt    	@189
+ _fdopen = MSVCRT__fdopen	@190
+ _fgetchar = MSVCRT__fgetchar	@191
  _fgetwchar	@192
  _filbuf	@193
 ;# stub _fileinfo	@194
- _filelength	@195
+ _filelength = MSVCRT__filelength	@195
 ;# stub _filelengthi64 #(long)	@196
-  _fileno	@197
+  _fileno = MSVCRT__fileno	@197
   _findclose	@198
   _findfirst	@199
@@ -376,43 +250,43 @@
   _finite	@203
   _flsbuf	@204
-  _flushall	@205
+  _flushall = MSVCRT__flushall	@205
   _fmode = MSVCRT__fmode	@206
   _fpclass	@207
 ;# stub _fpieee_flt	@208
-  _fpreset	@209
-  _fputchar	@210
+  _fpreset = MSVCRT__fpreset	@209
+  _fputchar = MSVCRT__fputchar	@210
   _fputwchar	@211
-  _fsopen	@212
+  _fsopen = MSVCRT__fsopen	@212
   _fstat = MSVCRT__fstat	@213
   _fstati64	@214
-  _ftime = MSVCRT_ftime	@215
+  _ftime = MSVCRT__ftime	@215
   _ftol	@216
-  _fullpath 	@217
+  _fullpath = MSVCRT__fullpath 	@217
   _futime	@218
-  _gcvt	@219
+  _gcvt = MSVCRT__gcvt  @219
   _get_osfhandle	@220
 ;# stub _get_sbh_threshold #()	@221
-  _getch	@222
-  _getche	@223
-  _getcwd	@224
-  _getdcwd	@225
+  _getch = MSVCRT__getch	@222
+  _getche = MSVCRT__getche	@223
+  _getcwd = MSVCRT__getcwd	@224
+  _getdcwd = MSVCRT__getdcwd	@225
   _getdiskfree	@226
-  _getdllprocaddr = KERNEL32_GetProcAddress	@227
-  _getdrive	@228
-  _getdrives = KERNEL32_GetLogicalDrives	@229
+  _getdllprocaddr  @227
+  _getdrive = MSVCRT__getdrive	@228
+  _getdrives = MSVCRT_GetLogicalDrives	@229
 ;# stub _getmaxstdio #()	@230
   _getmbcp	@231
-  _getpid = KERNEL32_GetCurrentProcessId	@232
+  _getpid = MSVCRT_GetCurrentProcessId	@232
 ;# stub _getsystime #(ptr)	@233
-  _getw	@234
+  _getw = MSVCRT__getw	@234
   _getws = MSVCRT__getws	@235
   _global_unwind2	@236
-  _heapadd	@237
-  _heapchk	@238
-  _heapmin	@239
-  _heapset	@240
+  _heapadd = MSVCRT__heapadd	@237
+  _heapchk = MSVCRT__heapchk	@238
+  _heapmin = MSVCRT__heapmin	@239
+  _heapset = MSVCRT__heapset	@240
 ;# stub _heapused #(ptr ptr)	@241
-  _heapwalk	@242
-  _hypot	@243
+  _heapwalk = MSVCRT__heapwalk	@242
+  _hypot 	@243
 ;# stub _i64toa #(long str long)	@244
 ;# stub _i64tow #(long wstr long)	@245
@@ -423,5 +297,5 @@
   _iob = MSVCRT__iob	@250
 
-  _isatty	@252
+  _isatty = MSVCRT__isatty @252
   _isctype	@253
 ;# stub _ismbbalnum #(long)	@254
@@ -455,11 +329,11 @@
   _ismbstrail	@282
   _isnan	@283
-  _itoa	@284
-  _itow	@285
+  _itoa @284
+  _itow @285
   _j0 = j0	@286
   _j1 = j1	@287
   _jn = jn	@288
-  _kbhit	@289
-  _lfind	@290
+  _kbhit = MSVCRT__kbhit	@289
+  _lfind = MSVCRT__lfind	@290
   _loaddll	@291
   _local_unwind2	@292
@@ -468,13 +342,13 @@
   _logb	@295
 ;# stub _longjmpex	@296
-  _lrotl	@297
-  _lrotr	@298
-  _lsearch	@299
-  _lseek	@300
+  _lrotl = MSVCRT__lrotl	@297
+  _lrotr = MSVCRT__lrotr	@298
+  _lsearch = MSVCRT__lsearch	@299
+  _lseek = MSVCRT__lseek	@300
   _lseeki64  	@301
   _ltoa	@302
   _ltow	@303
-  _makepath	@304
-  _matherr	@305
+  _makepath = MSVCRT__makepath	@304
+  _matherr = MSVCRT__matherr	@305
   _mbbtombc	@306
 ;# stub _mbbtype #(long long)	@307
@@ -500,9 +374,9 @@
   _mbsdup = _strdup	@327
   _mbsicmp	@328
-;# stub _mbsicoll #(str str)	@329
+  _mbsicoll 	@329
   _mbsinc	@330
   _mbslen	@331
   _mbslwr	@332
-;# stub _mbsnbcat #(str str long)	@333
+  _mbsnbcat 	@333
   _mbsnbcmp	@334
   _mbsnbcnt	@335
@@ -511,5 +385,5 @@
   _mbsnbicmp	@338
 ;# stub _mbsnbicoll #(str str long)	@339
-;# stub _mbsnbset #(str long long)	@340
+  _mbsnbset     @340
   _mbsncat	@341
   _mbsnccnt	@342
@@ -529,15 +403,15 @@
 ;# stub _mbsspnp #(str str)	@356
   _mbsstr = strstr	@357
-;# stub _mbstok #(str str)	@358
+  _mbstok	@358
   _mbstrlen	@359
   _mbsupr	@360
-  _memccpy = _memccpy	@361
+  _memccpy  	@361
   _memicmp = NTDLL_memicmp	@362
-  _mkdir	@363
+  _mkdir = MSVCRT__mkdir	@363
   _mktemp	@364
-  _msize	@365
+  _msize = MSVCRT__msize	@365
   _nextafter	@366
-  _onexit	@367
-  _open	@368
+  _onexit = MSVCRT__onexit	@367
+  _open	= MSVCRT__open @368
   _open_osfhandle	@369
 ;# stub _osver	@370
@@ -551,14 +425,14 @@
 ;# stub _popen #(str str)	@378
   _purecall	@379
-  _putch	@380
-  _putenv	@381
-  _putw	@382
+  _putch = MSVCRT__putch	@380
+  _putenv = MSVCRT__putenv	@381
+  _putw = MSVCRT__putw	@382
   _putws	@383
 ;# stub _pwctype	@384
-  _read	@385
-  _rmdir	@386
-  _rmtmp	@387
-  _rotl	@388
-  _rotr	@389
+  _read	= MSVCRT__read @385
+  _rmdir = MSVCRT__rmdir	@386
+  _rmtmp = MSVCRT__rmtmp	@387
+  _rotl = MSVCRT__rotl	@388
+  _rotr = MSVCRT__rotr	@389
   _safe_fdiv	@390
   _safe_fdivr	@391
@@ -566,6 +440,6 @@
   _safe_fprem1	@393
   _scalb	@394
-  _searchenv	@395
-  _seh_longjmp_unwind	@396
+  _searchenv = MSVCRT__searchenv	@395
+  _seh_longjmp_unwind = __seh_longjmp_unwind@4	@396
 ;# stub _set_error_mode #(long)	@397
 ;# stub _set_sbh_threshold #(long)	@398
@@ -575,59 +449,59 @@
 ;# stub _setmaxstdio #(long)	@402
   _setmbcp	@403
-  _setmode	@404
+  _setmode = MSVCRT__setmode	@404
 ;# stub _setsystime #(ptr long)	@405
-  _sleep	@406
-  _snprintf = _snprintf	@407
-  _snwprintf	@408
+  _sleep = MSVCRT__sleep	@406
+  _snprintf = emx__snprintf	@407
+  _snwprintf  @408
   _sopen = MSVCRT__sopen	@409
-  _spawnl = _spawnl	@410
+  _spawnl = MSVCRT__spawnl	@410
 ;# stub _spawnle #(str str) varargs	@411
-  _spawnlp	@412
+  _spawnlp = MSVCRT__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
+  _spawnv = MSVCRT__spawnv	@414
+  _spawnve = MSVCRT__spawnve	@415
+  _spawnvp = MSVCRT__spawnvp	@416
+  _spawnvpe = MSVCRT__spawnvpe	@417
+  _splitpath = emx__splitpath	@418
+  _stat	= MSVCRT__stat @419
+  _stati64	@420
   _statusfp	@421
   _strcmpi = strcasecmp	@422
-  _strdate	@423
-  _strdup	@424
-  _strerror	@425
+  _strdate = MSVCRT__strdate	@423
+  _strdup = MSVCRT__strdup	@424
+  _strerror = MSVCRT__strerror	@425
   _stricmp  = strcasecmp	@426
 ;# stub _stricoll #(str str)	@427
-  _strlwr	@428
+  _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
+  _strnset = MSVCRT__strnset	@432
+  _strrev = MSVCRT__strrev	@433
+  _strset = MSVCRT__strset	@434
+  _strtime = MSVCRT__strtime	@435
+  _strupr  @436
+  _swab	= MSVCRT__swab @437
   _sys_errlist = MSVCRT__sys_errlist	@438
   _sys_nerr = MSVCRT__sys_nerr	@439
-  _tell	@440
+  _tell = MSVCRT__tell	@440
 ;# stub _telli64 #(long)	@441
-  _tempnam	@442
+  _tempnam = MSVCRT__tempnam	@442
 ;# stub _timezone #()	@443
   _tolower = MSVCRT__tolower	@444
   _toupper = MSVCRT__toupper	@445
 ;# stub _tzname	@446
-  _tzset	@447
+  _tzset = emx__tzset	@447
 ;# stub _ui64toa #(long str long)	@448
 ;# stub _ui64tow #(long wstr long)	@449
-  _ultoa 	@450
+  _ultoa  	@450
   _ultow 	@451
-  _umask	@452
-  _ungetch	@453
-  _unlink	@454
+  _umask = MSVCRT_umask	@452
+  _ungetch = MSVCRT__ungetch	@453
+  _unlink = MSVCRT__unlink	@454
   _unloaddll	@455
   _unlock	@456
-  _utime	@457
-  _vsnprintf = _vsnprintf	@458
+  _utime = MSVCRT_utime	@457
+  _vsnprintf 	@458
   _vsnwprintf	@459
   _waccess	@460
@@ -666,5 +540,5 @@
 ;# stub _wfreopen #(wstr wstr ptr)	@493
   _wfsopen	@494
-;# stub _wfullpath #(wstr wstr long)	@495
+  _wfullpath	@495
   _wgetcwd	@496
   _wgetdcwd	@497
@@ -683,5 +557,5 @@
   _wremove	@510
   _wrename	@511
-  _write	@512
+  _write = MSVCRT__write	@512
   _wrmdir	@513
 ;# stub _wsearchenv #(wstr wstr wstr)	@514
@@ -698,5 +572,5 @@
   _wsplitpath	@525
   _wstat	@526
-;# stub _wstati64 #(wstr ptr)	@527
+  _wstati64 			@527
 ;# stub _wstrdate #(wstr)	@528
 ;# stub _wstrtime #(wstr)	@529
@@ -709,31 +583,31 @@
   _wunlink	@536
   _wutime	@537
-  _y0	@538
-  _y1	@539
-  _yn	@540
+  _y0 = MSVCRT__y0	@538
+  _y1 = MSVCRT__y1	@539
+  _yn = MSVCRT__yn	@540
   abort = MSVCRT_abort	@541
-  abs	@542
-  acos	@543
-  asctime	@544
-  asin	@545
-  atan 	@546
-  atan2	@547
+  abs = emx_abs	@542
+  acos = emx_acos	@543
+  asctime = emx_asctime	@544
+  asin = emx_asin	@545
+  atan = emx_atan	@546
+  atan2	= emx_atan2 @547
   atexit = MSVCRT_atexit	@548
-  atof	@549
-  atoi	@550
-  atol	@551
-  bsearch	@552
+  atof = MSVCRT_atof	@549
+  atoi  @550
+  atol  @551
+  bsearch 	@552
   calloc = MSVCRT_calloc	@553
-  ceil	@554
+  ceil = emx_ceil	@554
   clearerr = MSVCRT_clearerr	@555
   clock = MSVCRT_clock	@556
-  cos	@557
-  cosh	@558
-  ctime	@559
+  cos = emx_cos	@557
+  cosh = emx_cosh	@558
+  ctime	= emx_ctime @559
   difftime = MSVCRT_difftime	@560
   div = MSVCRT_div	@561
   exit = MSVCRT_exit	@562
-  exp	@563
-  fabs	@564
+  exp = emx_exp @563
+  fabs = emx_fabs	@564
   fclose = MSVCRT_fclose	@565
   feof = MSVCRT_feof	@566
@@ -745,6 +619,6 @@
   fgetwc = MSVCRT_fgetwc	@572
   fgetws = MSVCRT_fgetws	@573
-  floor	@574
-  fmod	@575
+  floor	= emx_floor @574
+  fmod	= emx_fmod @575
   fopen = MSVCRT_fopen	@576
   fprintf = MSVCRT_fprintf	@577
@@ -756,5 +630,5 @@
   free = MSVCRT_free	@583
   freopen = MSVCRT_freopen	@584
-  frexp = frexp	@585
+  frexp = emx_frexp	@585
   fscanf = MSVCRT_fscanf	@586
   fseek = MSVCRT_fseek	@587
@@ -770,5 +644,5 @@
   getwc = MSVCRT_getwc	@597
   getwchar = MSVCRT_getwchar	@598
-  gmtime = gmtime	@599
+  gmtime = emx_gmtime	@599
   is_wctype = iswctype	@600
   isalnum = MSVCRT_isalnum	@601
@@ -797,25 +671,25 @@
   iswxdigit = MSVCRT_iswxdigit	@624
   isxdigit = MSVCRT_isxdigit	@625
-  labs	@626
+  labs	= emx_labs @626
   ldexp = MSVCRT_ldexp	@627
   ldiv = MSVCRT_ldiv	@628
 ;# stub localeconv #()	@629
-  localtime	@630
-  log	@631
-  log10	@632
+  localtime = emx_localtime	@630
+  log = emx_log	@631
+  log10	= emx_log10 @632
   longjmp = _MSVCRT_longjmp	@633
   malloc = MSVCRT_malloc	@634
   mblen = MSVCRT_mblen	@635
-  mbstowcs 	@636
+  mbstowcs = emx_mbstowcs 	@636
   mbtowc = MSVCRT_mbtowc	@637
-  memchr	@638
-  memcmp	@639
+  memchr = emx_memchr	@638
+  memcmp = emx_memcmp	@639
   memcpy = MSVCRT_memcpy	@640
-  memmove	@641
+  memmove = emx_memmove	@641
   memset = MSVCRT_memset	@642
   mktime = MSVCRT_mktime	@643
-  modf	@644
+  modf	= emx_modf @644
   perror = MSVCRT_perror	@645
-  pow	@646
+  pow = emx_pow	@646
   printf = MSVCRT_printf	@647
   putc = MSVCRT_putc	@648
@@ -824,5 +698,5 @@
   putwc = MSVCRT_fputwc	@651
   putwchar =_fputwchar	@652
-  qsort	@653
+  qsort	= emx_qsort @653
 ;# stub raise #(long)	@654
   rand = MSVCRT_rand	@655
@@ -836,41 +710,41 @@
   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
+  sin = emx_sin	@665
+  sinh = emx_sinh @666
+  sprintf = emx_sprintf	@667
+  sqrt = emx_sqrt @668
+  srand = emx_srand @669
+  sscanf = MSVCRT_sscanf	@670
+  strcat = emx_strcat	@671
+  strchr = emx_strchr	@672
+  strcmp = emx_strcmp	@673
+  strcoll = emx_strcoll	@674
+  strcpy = emx_strcpy	@675
+  strcspn = emx_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
+  strftime = emx_strftime	@678
+  strlen = emx_strlen	@679
+  strncat = emx_strncat	@680
+  strncmp = emx_strncmp	@681
+  strncpy = emx_strncpy	@682
+  strpbrk = emx_strpbrk	@683
+  strrchr = emx_strrchr	@684
+  strspn = emx_strspn	@685
+  strstr = emx_strstr	@686
+  strtod = emx_strtod	@687
+  strtok = emx_strtok   @688 
+  strtol = emx_strtol	@689
+  strtoul = emx_strtoul	@690
+  strxfrm = emx_strxfrm	@691
   swprintf	@692
   swscanf = MSVCRT_swscanf	@693
   system = MSVCRT_system	@694
-  tan	@695
-  tanh	@696
+  tan = emx_tan	@695
+  tanh = emx_tanh @696
   time = MSVCRT_time	@697
   tmpfile = MSVCRT_tmpfile	@698
   tmpnam = MSVCRT_tmpnam	@699
-  tolower	@700
-  toupper	@701
+  tolower = emx_tolower	@700
+  toupper = emx_toupper	@701
   towlower	@702
   towupper	@703
@@ -880,5 +754,5 @@
   vfwprintf = MSVCRT_vfwprintf	@707
   vprintf = MSVCRT_vprintf	@708
-  vsprintf = vsprintf	@709
+  vsprintf = emx_vsprintf	@709
   vswprintf = MSVCRT_vswprintf	@710
   vwprintf = MSVCRT_vwprintf	@711
@@ -910,3 +784,3 @@
 ;# 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 10001)
+++ trunk/src/msvcrt/msvcrt.h	(revision 10005)
@@ -32,6 +32,8 @@
 typedef struct __MSVCRT_thread_data
 {
-    int                      errno;
+    int                      msv_errno;
     unsigned long            doserrno;
+    char                    *mbstok_next;        /* next ptr for mbstok() */
+    char                    *efcvt_buffer;       /* buffer for ecvt/fcvt */
     terminate_function       terminate_handler;
     unexpected_function      unexpected_handler;
@@ -108,3 +110,23 @@
 #define _RT_BANNER      255
 
+/* Signal types */
+
+#define SIGINT_W          2       /* interrupt */
+#define SIGILL_W          4       /* illegal instruction - invalid function image */
+#define SIGFPE_W          8       /* floating point exception */
+#define SIGSEGV_W         11      /* segment violation */
+#define SIGTERM_W         15      /* Software termination signal from kill */
+#define SIGBREAK_W        21      /* Ctrl-Break sequence */
+#define SIGABRT_W         22      /* abnormal termination triggered by abort call */
+
+#define SIG_DFL_W (void (__cdecl *)(int))0           /* default signal action */
+#define SIG_IGN_W (void (__cdecl *)(int))1           /* ignore signal */
+#define SIG_SGE_W (void (__cdecl *)(int))3           /* signal gets error */
+#define SIG_ACK_W (void (__cdecl *)(int))4           /* acknowledge */
+
+/* signal error value (returned by signal call on error) */
+
+#define SIG_ERR (void (__cdecl *)(int))-1          /* signal error value */
+
+
 #endif /* __WINE_MSVCRT_H */
Index: trunk/src/msvcrt/msvcrt.mak
===================================================================
--- trunk/src/msvcrt/msvcrt.mak	(revision 10001)
+++ trunk/src/msvcrt/msvcrt.mak	(revision 10005)
@@ -1,3 +1,3 @@
-# $Id: msvcrt.mak,v 1.7 2003-01-15 10:43:16 sandervl Exp $
+# $Id: msvcrt.mak,v 1.8 2003-04-10 10:28:03 sandervl Exp $
 
 #
@@ -13,4 +13,5 @@
 MAKEFILE = msvcrt.mak
 CCENV = EMX
+WRC_PREFIX_RESOURCE=1
 NOTEXPDEF = 1
 
@@ -22,9 +23,8 @@
 
 !ifndef WMAKE
-CDEFINES    = -I. $(CDEFINES) -DUSE_MSVCRT_PREFIX -D_MT -I$(ODIN32_INCLUDE)\win\msvcrt 
+CDEFINES    = -I$(ODIN32_INCLUDE)\emxruntime -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
-
 
 #
@@ -32,4 +32,6 @@
 #
 OBJS = \
+$(OBJDIR)\initterm.obj \
+$(OBJDIR)\initmsvcrtdll.obj \
 $(OBJDIR)\ctype.obj \
 $(OBJDIR)\cpp.obj \
@@ -37,4 +39,5 @@
 $(OBJDIR)\console.obj \
 $(OBJDIR)\data.obj \
+$(OBJDIR)\dbgcalls.obj \
 $(OBJDIR)\dir.obj \
 $(OBJDIR)\environ.obj \
@@ -49,4 +52,5 @@
 $(OBJDIR)\main.obj \
 $(OBJDIR)\scanf.obj \
+$(OBJDIR)\forwarders.obj \
 $(OBJDIR)\math.obj \
 $(OBJDIR)\mbcs.obj \
@@ -57,8 +61,24 @@
 $(OBJDIR)\time.obj \
 $(OBJDIR)\wcs.obj \
-$(OBJDIR)\rtlbitmap.obj \
 $(OBJDIR)\relay2.obj \
 $(OBJDIR)\$(TARGET)rsrc.obj 
 
+LIBS = \
+$(ODIN32_LIB_)\EmxSupport\EMXOS2FSRoutines.lib \
+$(EMX)\lib\iberty_s.lib \
+$(EMX)\lib\gcc-lib\i386-pc-os2-emx\3.2.1\mt\stdcxx.lib \
+$(EMX)\lib\c_alias.lib \
+$(EMX)\lib\gcc-lib\i386-pc-os2-emx\3.2.1\mt\gcc_eh.lib \
+$(EMX)\lib\gcc-lib\i386-pc-os2-emx\3.2.1\mt\gcc.lib \
+$(EMX)\lib\mt\c.lib \
+$(EMX)\lib\mt\c_dllso.lib \
+$(EMX)\lib\mt\sys.lib \
+$(EMX)\lib\os2.lib \
+$(ODIN32_LIB_)\EmxSupport\ExCRuntime.lib \
+$(ODIN32_LIB_)\EmxSupport\ExDllSupport.lib \
+$(ODIN32_LIB_)\EmxSupport\m.lib \
+$(ODIN32_LIB)\kernel32.lib \
+$(ODIN32_LIB)\ntdll.lib \
+$(ODIN32_LIB)\user32.lib 
 
 #
@@ -69,9 +89,8 @@
 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
+$(TARGET).lib: 
+    implib $(OBJDIR)\$(TARGET).lib msvcrt.def
+    @copy $(OBJDIR)\$(TARGET).lib $(ODIN32_LIB_)\Release
+    @copy $(OBJDIR)\$(TARGET).lib $(ODIN32_LIB_)\Debug
 
 # Includes the common rules.
@@ -79,8 +98,2 @@
 !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:
-
-lib: $(TARGET).lib
Index: trunk/src/msvcrt/msvcrt.spec
===================================================================
--- trunk/src/msvcrt/msvcrt.spec	(revision 10001)
+++ trunk/src/msvcrt/msvcrt.spec	(revision 10005)
@@ -52,34 +52,34 @@
 @ 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
+@ cdecl _CIacos()
+@ cdecl _CIasin()
+@ cdecl _CIatan()
+@ cdecl _CIatan2()
+@ cdecl _CIcos()
+@ cdecl _CIcosh()
+@ cdecl _CIexp()
+@ cdecl _CIfmod()
+@ cdecl _CIlog()
+@ cdecl _CIlog10()
+@ cdecl _CIpow()
+@ cdecl _CIsin()
+@ cdecl _CIsinh()
+@ cdecl _CIsqrt()
+@ cdecl _CItan()
+@ cdecl _CItanh()
+@ cdecl _CxxThrowException(long long)
+@ cdecl -i386 -norelay _EH_prolog()
+@ cdecl _Getdays()
+@ cdecl _Getmonths()
+@ cdecl _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 _Strftime(str long str ptr ptr)
+@ cdecl _XcptFilter(long ptr)
+@ cdecl -register -i386 __CxxFrameHandler(ptr ptr ptr ptr)
+@ stub __CxxLongjmpUnwind #(ptr) stdcall
 @ cdecl __RTCastToVoid(ptr) MSVCRT___RTCastToVoid
 @ cdecl __RTDynamicCast(ptr long ptr ptr long) MSVCRT___RTDynamicCast
 @ cdecl __RTtypeid(ptr) MSVCRT___RTtypeid
-@ stub __STRINGTOLD
+@ stub __STRINGTOLD #(ptr ptr str long)
 @ extern __argc MSVCRT___argc
 @ extern __argv MSVCRT___argv
@@ -87,9 +87,9 @@
 @ stub __crtCompareStringA
 @ stub __crtGetLocaleInfoW
-@ stub __crtLCMapStringA
-@ cdecl __dllonexit(ptr ptr ptr) __dllonexit
-@ cdecl __doserrno() __doserrno
+@ cdecl __crtLCMapStringA(long long str long ptr long long long)
+@ cdecl __dllonexit(ptr ptr ptr)
+@ cdecl __doserrno()
 @ stub __fpecode #()
-@ cdecl __getmainargs(ptr ptr ptr long ptr) __getmainargs
+@ cdecl __getmainargs(ptr ptr ptr long ptr)
 @ extern __initenv MSVCRT___initenv
 @ cdecl __isascii(long) MSVCRT___isascii
@@ -99,34 +99,34 @@
 @ stub __lc_collate
 @ stub __lc_handle
-@ cdecl __lconv_init() __lconv_init
+@ cdecl __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
+@ cdecl __p___argc()
+@ cdecl __p___argv()
+@ cdecl __p___initenv()
+@ cdecl __p___mb_cur_max()
+@ cdecl __p___wargv()
+@ cdecl __p___winitenv()
+@ cdecl __p__acmdln()
 @ stub __p__amblksiz #()
-@ cdecl __p__commode()  __p__commode
-@ stub __p__daylight #()
+@ cdecl __p__commode()
+@ cdecl __p__daylight() MSVCRT___p__daylight
 @ stub __p__dstbias #()
-@ cdecl __p__environ() __p__environ
+@ cdecl __p__environ()
 @ stub __p__fileinfo #()
-@ cdecl __p__fmode() __p__fmode
-@ cdecl __p__iob() __p__iob
+@ cdecl __p__fmode()
+@ cdecl __p__iob()
 @ stub __p__mbcasemap #()
-@ cdecl __p__mbctype() __p__mbctype
-@ cdecl __p__osver()  __p__osver
-@ cdecl __p__pctype() __p__pctype
-@ stub __p__pgmptr #()
+@ cdecl __p__mbctype()
+@ cdecl __p__osver()
+@ cdecl __p__pctype()
+@ cdecl __p__pgmptr()
 @ stub __p__pwctype #()
-@ cdecl __p__timezone() __p__timezone
+@ cdecl __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
+@ cdecl __p__wcmdln()
+@ cdecl __p__wenviron()
+@ cdecl __p__winmajor()
+@ cdecl __p__winminor()
+@ cdecl __p__winver()
 @ stub __p__wpgmptr #()
 @ stub __pioinfo #()
@@ -135,6 +135,6 @@
 @ extern __setlc_active MSVCRT___setlc_active
 @ cdecl __setusermatherr(ptr) MSVCRT___setusermatherr
-@ forward __threadhandle kernel32.GetCurrentThread
-@ forward __threadid kernel32.GetCurrentThreadId
+@ cdecl __threadhandle() kernel32.GetCurrentThread
+@ cdecl __threadid() kernel32.GetCurrentThreadId
 @ cdecl __toascii(long) MSVCRT___toascii
 @ cdecl __unDName(long str ptr ptr long) MSVCRT___unDName
@@ -142,196 +142,196 @@
 @ extern __unguarded_readlc_active MSVCRT___unguarded_readlc_active
 @ extern __wargv MSVCRT___wargv
-@ cdecl __wgetmainargs(ptr ptr ptr long ptr) __wgetmainargs
+@ cdecl __wgetmainargs(ptr ptr ptr long ptr)
 @ extern __winitenv MSVCRT___winitenv
-@ cdecl _abnormal_termination() _abnormal_termination
-@ cdecl _access(str long) _access
+@ cdecl _abnormal_termination()
+@ cdecl _access(str long)
 @ 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
+@ cdecl _adj_fdiv_m16i()
+@ cdecl _adj_fdiv_m32()
+@ cdecl _adj_fdiv_m32i()
+@ cdecl _adj_fdiv_m64()
+@ cdecl _adj_fdiv_r()
+@ cdecl _adj_fdivr_m16i()
+@ cdecl _adj_fdivr_m32()
+@ cdecl _adj_fdivr_m32i()
+@ cdecl _adj_fdivr_m64()
+@ cdecl _adj_fpatan()
+@ cdecl _adj_fprem()
+@ cdecl _adj_fprem1()
+@ cdecl _adj_fptan()
+@ cdecl _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
+@ stub _atodbl #(ptr str)
+@ cdecl -ret64 _atoi64(str) ntdll._atoi64
+@ stub _atoldbl #(ptr str)
+@ cdecl _beep(long long)
+@ cdecl _beginthread (ptr long ptr)
+@ cdecl _beginthreadex (ptr long ptr ptr long ptr)
 @ cdecl _c_exit() MSVCRT__c_exit
-@ cdecl _cabs(long) _cabs
-@ cdecl _callnewh(long) _callnewh
+@ cdecl _cabs(long)
+@ cdecl _callnewh(long)
 @ 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
+@ cdecl _cgets(str)
+@ cdecl _chdir(str)
+@ cdecl _chdrive(long)
+@ cdecl _chgsign( double )
+@ cdecl -i386 _chkesp()
+@ cdecl _chmod(str long)
+@ cdecl _chsize (long long)
+@ cdecl _clearfp()
+@ cdecl _close(long)
+@ cdecl _commit(long)
 @ 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
+@ cdecl _control87(long long)
+@ cdecl _controlfp(long long)
+@ cdecl _copysign( double double )
+@ varargs _cprintf(str)
+@ cdecl _cputs(str)
+@ cdecl _creat(str long)
+@ varargs _cscanf(str)
 @ extern _ctype MSVCRT__ctype
-@ cdecl _cwait(ptr long long) _cwait
-@ stub _daylight
+@ cdecl _cwait(ptr long long)
+@ extern _daylight MSVCRT___daylight
 @ stub _dstbias
-@ stub _dup #(long)
-@ stub _dup2 #(long long)
-@ cdecl _ecvt( double long ptr ptr) ecvt
-@ cdecl _endthread () _endthread
-@ cdecl _endthreadex(long) _endthreadex
+@ cdecl _dup (long)
+@ cdecl _dup2 (long long)
+@ cdecl _ecvt(double long ptr ptr)
+@ cdecl _endthread ()
+@ cdecl _endthreadex(long)
 @ extern _environ MSVCRT__environ
-@ cdecl _eof(long) _eof
+@ cdecl _eof(long)
 @ 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
+@ cdecl _except_handler2(ptr ptr ptr ptr)
+@ cdecl _except_handler3(ptr ptr ptr ptr)
+@ varargs _execl(str str)
 @ stub _execle #(str str) varargs
-@ varargs _execlp(str str) _execlp
+@ varargs _execlp(str str)
 @ 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 _execv(str str)
+@ cdecl _execve(str str str)
+@ cdecl _execvp(str str)
+@ cdecl _execvpe(str str str)
 @ 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
+@ cdecl _expand(ptr long)
+@ cdecl _fcloseall()
+@ cdecl _fcvt(double long ptr ptr)
+@ cdecl _fdopen(long str)
+@ cdecl _fgetchar()
+@ cdecl _fgetwchar()
+@ cdecl _filbuf(ptr)
 @ stub _fileinfo
-@ cdecl _filelength(long) _filelength
+@ cdecl _filelength(long)
 @ stub _filelengthi64 #(long)
-@ cdecl _fileno(ptr) _fileno
-@ cdecl _findclose(long) _findclose
-@ cdecl _findfirst(str ptr) _findfirst
+@ cdecl _fileno(ptr)
+@ cdecl _findclose(long)
+@ cdecl _findfirst(str ptr)
 @ stub _findfirsti64 #(str ptr)
-@ cdecl _findnext(long ptr) _findnext
+@ cdecl _findnext(long ptr)
 @ stub _findnexti64 #(long ptr)
-@ cdecl _finite( double ) _finite
-@ cdecl _flsbuf(long ptr) _flsbuf
-@ cdecl _flushall() _flushall
+@ cdecl _finite( double )
+@ cdecl _flsbuf(long ptr)
+@ cdecl _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 _fpclass(double)
+@ stub _fpieee_flt #(long ptr ptr)
+@ cdecl _fpreset()
+@ cdecl _fputchar(long)
+@ cdecl _fputwchar(long)
+@ cdecl _fsopen(str str long)
 @ 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
+@ cdecl _fstati64(long ptr)
+@ cdecl _ftime(ptr)
+@ cdecl _ftol() ntdll._ftol
+@ cdecl _fullpath(ptr str long)
+@ cdecl _futime(long ptr)
+@ cdecl _gcvt(double long str)
+@ cdecl _get_osfhandle(long)
 @ 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
+@ cdecl _getch()
+@ cdecl _getche()
+@ cdecl _getcwd(str long)
+@ cdecl _getdcwd(long str long)
+@ cdecl _getdiskfree(long ptr)
+@ cdecl _getdllprocaddr(long str long)
+@ cdecl _getdrive()
+@ cdecl _getdrives() kernel32.GetLogicalDrives
 @ stub _getmaxstdio #()
-@ cdecl _getmbcp() _getmbcp
-@ forward _getpid kernel32.GetCurrentProcessId
+@ cdecl _getmbcp()
+@ cdecl _getpid() kernel32.GetCurrentProcessId
 @ stub _getsystime #(ptr)
-@ cdecl _getw(ptr) _getw
+@ cdecl _getw(ptr)
 @ 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
+@ cdecl _global_unwind2(ptr)
+@ cdecl _heapadd (ptr long)
+@ cdecl _heapchk()
+@ cdecl _heapmin()
+@ cdecl _heapset(long)
 @ stub _heapused #(ptr ptr)
-@ cdecl _heapwalk(ptr) _heapwalk
+@ cdecl _heapwalk(ptr)
 @ cdecl _hypot(double double) hypot
-@ stub _i64toa #(long str long)
-@ stub _i64tow #(long wstr long)
-@ cdecl _initterm(ptr ptr) _initterm
+@ cdecl _i64toa(long long ptr long) ntdll._i64toa
+@ cdecl _i64tow(long long ptr long) ntdll._i64tow
+@ cdecl _initterm(ptr ptr)
 @ 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
+@ cdecl _isatty(long)
+@ cdecl _isctype(long long)
 @ stub _ismbbalnum #(long)
 @ stub _ismbbalpha #(long)
 @ stub _ismbbgraph #(long)
 @ stub _ismbbkalnum #(long)
-@ cdecl _ismbbkana(long) _ismbbkana
+@ cdecl _ismbbkana(long)
 @ stub _ismbbkprint #(long)
 @ stub _ismbbkpunct #(long)
-@ cdecl _ismbblead(long) _ismbblead
+@ cdecl _ismbblead(long)
 @ 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
+@ cdecl _ismbbtrail(long)
+@ cdecl _ismbcalnum(long)
+@ cdecl _ismbcalpha(long)
+@ cdecl _ismbcdigit(long)
+@ cdecl _ismbcgraph(long)
+@ cdecl _ismbchira(long)
+@ cdecl _ismbckata(long)
 @ 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 _ismbclower(long)
+@ cdecl _ismbcprint(long)
+@ cdecl _ismbcpunct(long)
+@ cdecl _ismbcspace(long)
+@ cdecl _ismbcsymbol(long)
+@ cdecl _ismbcupper(long)
+@ cdecl _ismbslead(ptr ptr)
+@ cdecl _ismbstrail(ptr ptr)
+@ cdecl _isnan( double )
+@ cdecl _itoa(long ptr long) ntdll._itoa
+@ cdecl _itow(long ptr long) ntdll._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
+@ cdecl _kbhit()
+@ cdecl _lfind(ptr ptr ptr long ptr)
+@ cdecl _loaddll(str)
+@ cdecl _local_unwind2(ptr long)
+@ cdecl _lock(long)
+@ cdecl _locking(long long long)
+@ cdecl _logb( double )
 @ 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
+@ cdecl _lrotl(long long)
+@ cdecl _lrotr(long long)
+@ cdecl _lsearch(ptr ptr long long ptr)
+@ cdecl _lseek(long long long)
+@ cdecl -ret64 _lseeki64(long long long long)
+@ cdecl _ltoa(long ptr long) ntdll._ltoa
+@ cdecl _ltow(long ptr long) ntdll._ltow
+@ cdecl _makepath(str str str str str)
+@ cdecl _matherr(ptr)
+@ cdecl _mbbtombc(long)
 @ stub _mbbtype #(long long)
 @ stub _mbcasemap
@@ -339,62 +339,62 @@
 @ stub _mbcjistojms #(long)
 @ stub _mbcjmstojis #(long)
-@ cdecl _mbclen(ptr) _mbclen
+@ cdecl _mbclen(ptr)
 @ stub _mbctohira #(long)
 @ stub _mbctokata #(long)
-@ cdecl _mbctolower(long) _mbctolower
+@ cdecl _mbctolower(long)
 @ stub _mbctombb #(long)
-@ cdecl _mbctoupper(long) _mbctoupper
+@ cdecl _mbctoupper(long)
 @ stub _mbctype
-@ stub _mbsbtype #(ptr long)
+@ stub _mbsbtype #(str long)
 @ cdecl _mbscat(str str) strcat
-@ cdecl _mbschr(str long) _mbschr
-@ cdecl _mbscmp(str str) _mbscmp
+@ cdecl _mbschr(str long)
+@ cdecl _mbscmp(str str)
 @ stub _mbscoll #(str str)
 @ cdecl _mbscpy(ptr str) strcpy
-@ cdecl _mbscspn (str str) _mbscspn
-@ cdecl _mbsdec(ptr ptr) _mbsdec
+@ cdecl _mbscspn (str str)
+@ cdecl _mbsdec(ptr ptr)
 @ 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
+@ cdecl _mbsicmp(str str)
+@ cdecl _mbsicoll(str str)
+@ cdecl _mbsinc(str)
+@ cdecl _mbslen(str)
+@ cdecl _mbslwr(str)
+@ cdecl _mbsnbcat (str str long)
+@ cdecl _mbsnbcmp(str str long)
+@ cdecl _mbsnbcnt(ptr long)
 @ stub _mbsnbcoll #(str str long)
-@ cdecl _mbsnbcpy(ptr str long) _mbsnbcpy
-@ cdecl _mbsnbicmp(str str long) _mbsnbicmp
+@ cdecl _mbsnbcpy(ptr str long)
+@ cdecl _mbsnbicmp(str str long)
 @ 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
+@ cdecl _mbsnbset(str long long)
+@ cdecl _mbsncat(str str long)
+@ cdecl _mbsnccnt(str long)
+@ cdecl _mbsncmp(str str long)
+@ stub _mbsncoll #(str str long)
+@ cdecl _mbsncpy(str str long)
+@ cdecl _mbsnextc(str)
+@ cdecl _mbsnicmp(str str long)
 @ 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
+@ cdecl _mbsninc(str long)
+@ cdecl _mbsnset(str long long)
+@ cdecl _mbspbrk(str str)
+@ cdecl _mbsrchr(str long)
+@ cdecl _mbsrev(str)
+@ cdecl _mbsset(str long)
+@ cdecl _mbsspn(str str)
 @ stub _mbsspnp #(str str)
 @ cdecl _mbsstr(str str) strstr
-@ stub _mbstok #(str str)
-@ cdecl _mbstrlen(str) _mbstrlen
-@ cdecl _mbsupr(str) _mbsupr
+@ cdecl _mbstok(str str)
+@ cdecl _mbstrlen(str)
+@ cdecl _mbsupr(str)
 @ 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
+@ cdecl _memicmp(str str long) ntdll._memicmp
+@ cdecl _mkdir(str)
+@ cdecl _mktemp(str)
+@ cdecl _msize(ptr)
+@ cdecl _nextafter(double double)
+@ cdecl _onexit(ptr)
+@ varargs _open(str long)
+@ cdecl _open_osfhandle(long long)
 @ stub _osver
 @ stub _outp #(long long)
@@ -403,25 +403,25 @@
 @ stub _pclose #(ptr)
 @ extern _pctype MSVCRT__pctype
-@ stub _pgmptr
+@ extern _pgmptr MSVCRT__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
+@ cdecl _purecall()
+@ cdecl _putch(long)
+@ cdecl _putenv(str)
+@ cdecl _putw(long ptr)
+@ cdecl _putws(wstr)
 @ 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
+@ cdecl _read(long ptr long)
+@ cdecl _rmdir(str)
+@ cdecl _rmtmp()
+@ cdecl _rotl(long long)
+@ cdecl _rotr(long long)
+@ cdecl _safe_fdiv()
+@ cdecl _safe_fdivr()
+@ cdecl _safe_fprem()
+@ cdecl _safe_fprem1()
+@ cdecl _scalb( double long)
+@ cdecl _searchenv(str str ptr)
+@ stdcall -i386 _seh_longjmp_unwind(ptr)
 @ stub _set_error_mode #(long)
 @ stub _set_sbh_threshold #(long)
@@ -430,78 +430,78 @@
 @ cdecl -register -i386 _setjmp3(ptr long) _MSVCRT__setjmp3
 @ stub _setmaxstdio #(long)
-@ cdecl _setmbcp(long) _setmbcp
-@ cdecl _setmode(long long) _setmode
+@ cdecl _setmbcp(long)
+@ cdecl _setmode(long long)
 @ stub _setsystime #(ptr long)
-@ cdecl _sleep(long) _sleep
+@ cdecl _sleep(long)
 @ varargs _snprintf(str long str) snprintf
-@ forward _snwprintf ntdll._snwprintf
+@ varargs _snwprintf(wstr long wstr) 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
+@ varargs _spawnl(long str str)
+@ stub _spawnle #(long str str) varargs
+@ varargs _spawnlp(long str str)
+@ stub _spawnlpe #(long str str) varargs
+@ cdecl _spawnv(long str ptr)
+@ cdecl _spawnve(long str ptr ptr)
+@ cdecl _spawnvp(long str ptr)
+@ cdecl _spawnvpe(long str ptr ptr)
+@ cdecl _splitpath(str ptr ptr ptr ptr) ntdll._splitpath
 @ cdecl _stat(str ptr) MSVCRT__stat
-@ cdecl _stati64(str ptr) _stati64
-@ cdecl _statusfp() _statusfp
+@ cdecl _stati64(str ptr)
+@ cdecl _statusfp()
 @ cdecl _strcmpi(str str) strcasecmp
-@ cdecl _strdate(str) _strdate
-@ cdecl _strdup(str) _strdup
-@ cdecl _strerror(long) _strerror
+@ cdecl _strdate(ptr)
+@ cdecl _strdup(str)
+@ cdecl _strerror(long)
 @ cdecl _stricmp(str str) strcasecmp
 @ stub _stricoll #(str str)
-@ forward _strlwr ntdll._strlwr
+@ cdecl _strlwr(str) 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
+@ cdecl _strnset(str long long)
+@ cdecl _strrev(str)
+@ cdecl _strset(str long)
+@ cdecl _strtime(ptr)
+@ cdecl _strupr(str) ntdll._strupr
+@ cdecl _swab(str str long)
 @ extern _sys_errlist MSVCRT__sys_errlist
 @ extern _sys_nerr MSVCRT__sys_nerr
-@ cdecl _tell(long) _tell
+@ cdecl _tell(long)
 @ stub _telli64 #(long)
-@ cdecl _tempnam(str str) _tempnam
-@ stub _timezone #()
+@ cdecl _tempnam(str str)
+@ stub _timezone # extern
 @ cdecl _tolower(long) MSVCRT__tolower
 @ cdecl _toupper(long) MSVCRT__toupper
-@ stub _tzname
+@ stub _tzname # extern
 @ 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 _ui64toa(long long ptr long) ntdll._ui64toa
+@ cdecl _ui64tow(long long ptr long) ntdll._ui64tow
+@ cdecl _ultoa(long ptr long) ntdll._ultoa
+@ cdecl _ultow(long ptr long) ntdll._ultow
+@ cdecl _umask(long)
+@ cdecl _ungetch(long)
+@ cdecl _unlink(str)
+@ cdecl _unloaddll(long)
+@ cdecl _unlock(long)
+@ cdecl _utime(str ptr)
 @ cdecl _vsnprintf(ptr long ptr ptr) vsnprintf
-@ cdecl _vsnwprintf(ptr long wstr long) _vsnwprintf
-@ cdecl _waccess(wstr long) _waccess
+@ cdecl _vsnwprintf(ptr long wstr long)
+@ cdecl _waccess(wstr long)
 @ stub _wasctime #(ptr)
-@ cdecl _wchdir(wstr) _wchdir
-@ cdecl _wchmod(wstr long) _wchmod
+@ cdecl _wchdir(wstr)
+@ cdecl _wchmod(wstr long)
 @ 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
+@ cdecl _wcreat(wstr long)
+@ cdecl _wcsdup(wstr)
+@ cdecl _wcsicmp(wstr wstr) ntdll._wcsicmp
+@ cdecl _wcsicoll(wstr wstr)
+@ cdecl _wcslwr(wstr) ntdll._wcslwr
 @ stub _wcsncoll #(wstr wstr long)
-@ forward _wcsnicmp ntdll._wcsnicmp
+@ cdecl _wcsnicmp(wstr wstr long) 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
+@ cdecl _wcsnset(wstr long long)
+@ cdecl _wcsrev(wstr)
+@ cdecl _wcsset(wstr long)
+@ cdecl _wcsupr(wstr) ntdll._wcsupr
 @ stub _wctime #(ptr)
 @ extern _wenviron MSVCRT__wenviron
@@ -510,36 +510,36 @@
 @ 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 _wexecv #(wstr ptr)
+@ stub _wexecve #(wstr ptr ptr)
+@ stub _wexecvp #(wstr ptr)
+@ stub _wexecvpe #(wstr ptr ptr)
+@ cdecl _wfdopen(long wstr)
+@ cdecl _wfindfirst(wstr ptr)
 @ stub _wfindfirsti64 #(wstr ptr)
-@ cdecl _wfindnext(long ptr)  _wfindnext
+@ cdecl _wfindnext(long ptr)
 @ stub _wfindnexti64 #(long ptr)
-@ cdecl _wfopen(wstr wstr) _wfopen
+@ cdecl _wfopen(wstr wstr)
 @ 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
+@ cdecl _wfsopen(wstr wstr long)
+@ stub _wfullpath #(ptr wstr long)
+@ cdecl _wgetcwd(wstr long)
+@ cdecl _wgetdcwd(long wstr long)
+@ cdecl _wgetenv(wstr)
 @ 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
+@ cdecl _wmakepath(wstr wstr wstr wstr wstr)
+@ cdecl _wmkdir(wstr)
+@ cdecl _wmktemp(wstr)
+@ varargs _wopen(wstr long)
 @ stub _wperror #(wstr)
-@ stub _wpgmptr
+@ stub _wpgmptr # extern
 @ 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)
+@ cdecl _wputenv(wstr)
+@ cdecl _wremove(wstr)
+@ cdecl _wrename(wstr wstr)
+@ cdecl _write(long ptr long)
+@ cdecl _wrmdir(wstr)
+@ stub _wsearchenv #(wstr wstr ptr)
 @ stub _wsetlocale #(long wstr)
 @ varargs _wsopen (wstr long long) MSVCRT__wsopen
@@ -548,48 +548,48 @@
 @ 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 _wspawnv #(long wstr ptr)
+@ stub _wspawnve #(long wstr ptr ptr)
+@ stub _wspawnvp #(long wstr ptr)
+@ stub _wspawnvpe #(long wstr ptr ptr)
+@ cdecl _wsplitpath(wstr wstr wstr wstr wstr)
+@ cdecl _wstat(wstr ptr)
 @ stub _wstati64 #(wstr ptr)
-@ stub _wstrdate #(wstr)
-@ stub _wstrtime #(wstr)
+@ stub _wstrdate #(ptr)
+@ stub _wstrtime #(ptr)
 @ 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 _wtempnam(wstr wstr)
+@ stub _wtmpnam #(ptr)
+@ cdecl _wtoi(wstr) ntdll._wtoi
+@ cdecl _wtoi64(wstr) ntdll._wtoi64
+@ cdecl _wtol(wstr) ntdll._wtol
+@ cdecl _wunlink(wstr)
+@ cdecl _wutime(wstr ptr)
+@ cdecl _y0(double)
+@ cdecl _y1(double)
+@ cdecl _yn(long double )
 @ 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 abs(long)
+@ cdecl acos(double)
+@ cdecl asctime(ptr)
+@ cdecl asin(double)
+@ cdecl atan(double)
+@ cdecl atan2(double double)
 @ 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 atof(str)
+@ cdecl atoi(str)
+@ cdecl atol(str)
+@ cdecl bsearch(ptr ptr long long ptr)
 @ cdecl calloc(long long) MSVCRT_calloc
-@ cdecl ceil(double) ceil
+@ cdecl ceil(double)
 @ cdecl clearerr(ptr) MSVCRT_clearerr
 @ cdecl clock() MSVCRT_clock
-@ cdecl cos(double) cos
-@ cdecl cosh(double) cosh
-@ cdecl ctime(ptr) ctime
+@ cdecl cos(double)
+@ cdecl cosh(double)
+@ cdecl ctime(ptr)
 @ 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 exp(double)
+@ cdecl fabs(double)
 @ cdecl fclose(ptr) MSVCRT_fclose
 @ cdecl feof(ptr) MSVCRT_feof
@@ -601,6 +601,6 @@
 @ cdecl fgetwc(ptr) MSVCRT_fgetwc
 @ cdecl fgetws(ptr long ptr) MSVCRT_fgetws
-@ cdecl floor(double) floor
-@ cdecl fmod(double double) fmod
+@ cdecl floor(double)
+@ cdecl fmod(double double)
 @ cdecl fopen(str str) MSVCRT_fopen
 @ varargs fprintf(ptr str) MSVCRT_fprintf
@@ -612,5 +612,5 @@
 @ cdecl free(ptr) MSVCRT_free
 @ cdecl freopen(str str ptr) MSVCRT_freopen
-@ cdecl frexp(double ptr) frexp
+@ cdecl frexp(double ptr)
 @ varargs fscanf(ptr str) MSVCRT_fscanf
 @ cdecl fseek(ptr long long) MSVCRT_fseek
@@ -626,6 +626,6 @@
 @ cdecl getwc(ptr) MSVCRT_getwc
 @ cdecl getwchar() MSVCRT_getwchar
-@ cdecl gmtime(ptr) gmtime
-@ forward is_wctype ntdll.iswctype
+@ cdecl gmtime(ptr)
+@ cdecl is_wctype(long long) ntdll.iswctype
 @ cdecl isalnum(long) MSVCRT_isalnum
 @ cdecl isalpha(long) MSVCRT_isalpha
@@ -640,8 +640,8 @@
 @ cdecl isupper(long) MSVCRT_isupper
 @ cdecl iswalnum(long) MSVCRT_iswalnum
-@ forward iswalpha ntdll.iswalpha
+@ cdecl iswalpha(long) ntdll.iswalpha
 @ cdecl iswascii(long) MSVCRT_iswascii
 @ cdecl iswcntrl(long) MSVCRT_iswcntrl
-@ forward iswctype ntdll.iswctype
+@ cdecl iswctype(long long) ntdll.iswctype
 @ cdecl iswdigit(long) MSVCRT_iswdigit
 @ cdecl iswgraph(long) MSVCRT_iswgraph
@@ -653,25 +653,25 @@
 @ cdecl iswxdigit(long) MSVCRT_iswxdigit
 @ cdecl isxdigit(long) MSVCRT_isxdigit
-@ cdecl labs(long) labs
+@ cdecl labs(long)
 @ 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 localtime(ptr)
+@ cdecl log(double)
+@ cdecl log10(double)
 @ cdecl -register -i386 longjmp(ptr long) _MSVCRT_longjmp
 @ cdecl malloc(long) MSVCRT_malloc
 @ cdecl mblen(ptr long) MSVCRT_mblen
-@ forward mbstowcs ntdll.mbstowcs
+@ cdecl mbstowcs(ptr str long) 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 memchr(ptr long long)
+@ cdecl memcmp(ptr ptr long)
+@ cdecl memcpy(ptr ptr long)
+@ cdecl memmove(ptr ptr long)
+@ cdecl memset(ptr long long)
 @ cdecl mktime(ptr) MSVCRT_mktime
-@ cdecl modf(double ptr) modf
+@ cdecl modf(double ptr)
 @ cdecl perror(str) MSVCRT_perror
-@ cdecl pow(double double) pow
+@ cdecl pow(double double)
 @ varargs printf(str) MSVCRT_printf
 @ cdecl putc(long ptr) MSVCRT_putc
@@ -680,5 +680,5 @@
 @ cdecl putwc(long ptr) MSVCRT_fputwc
 @ cdecl putwchar(long) _fputwchar
-@ cdecl qsort(ptr long long ptr) qsort
+@ cdecl qsort(ptr long long ptr)
 @ stub raise #(long)
 @ cdecl rand() MSVCRT_rand
@@ -692,43 +692,43 @@
 @ 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
+@ cdecl sin(double)
+@ cdecl sinh(double)
+@ varargs sprintf(ptr str)
+@ cdecl sqrt(double)
+@ cdecl srand(long)
 @ 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 strcat(str str)
+@ cdecl strchr(str long)
+@ cdecl strcmp(str str)
+@ cdecl strcoll(str str)
+@ cdecl strcpy(ptr str)
+@ cdecl strcspn(str str)
 @ 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
+@ cdecl strftime(str long str ptr)
+@ cdecl strlen(str)
+@ cdecl strncat(str str long)
+@ cdecl strncmp(str str long)
+@ cdecl strncpy(ptr str long)
+@ cdecl strpbrk(str str)
+@ cdecl strrchr(str long)
+@ cdecl strspn(str str)
+@ cdecl strstr(str str)
+@ cdecl strtod(str ptr)
+@ cdecl strtok(str str)
+@ cdecl strtol(str ptr long)
+@ cdecl strtoul(str ptr long)
+@ cdecl strxfrm(ptr str long)
+@ varargs swprintf(wstr wstr) ntdll.swprintf
 @ varargs swscanf(wstr wstr) MSVCRT_swscanf
 @ cdecl system(str) MSVCRT_system
-@ cdecl tan(double) tan
-@ cdecl tanh(double) tanh
+@ cdecl tan(double)
+@ cdecl tanh(double)
 @ 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 tmpnam(ptr) MSVCRT_tmpnam
+@ cdecl tolower(long)
+@ cdecl toupper(long)
+@ cdecl towlower(long) ntdll.towlower
+@ cdecl towupper(long) ntdll.towupper
 @ cdecl ungetc(long ptr) MSVCRT_ungetc
 @ cdecl ungetwc(long ptr) MSVCRT_ungetwc
@@ -736,28 +736,28 @@
 @ cdecl vfwprintf(ptr wstr long) MSVCRT_vfwprintf
 @ cdecl vprintf(str long) MSVCRT_vprintf
-@ cdecl vsprintf(ptr str ptr) vsprintf
+@ cdecl vsprintf(ptr str ptr)
 @ 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 wcscat(wstr wstr) ntdll.wcscat
+@ cdecl wcschr(wstr long) ntdll.wcschr
+@ cdecl wcscmp(wstr wstr) 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 wcscpy(ptr wstr) ntdll.wcscpy
+@ cdecl wcscspn(wstr wstr) ntdll.wcscspn
+@ stub wcsftime #(ptr long wstr ptr)
+@ cdecl wcslen(wstr) ntdll.wcslen
+@ cdecl wcsncat(wstr wstr long) ntdll.wcsncat
+@ cdecl wcsncmp(wstr wstr long) ntdll.wcsncmp
+@ cdecl wcsncpy(ptr wstr long) ntdll.wcsncpy
 @ cdecl wcspbrk(wstr wstr) MSVCRT_wcspbrk
-@ forward wcsrchr ntdll.wcsrchr
-@ forward wcsspn ntdll.wcsspn
-@ forward wcsstr ntdll.wcsstr
+@ cdecl wcsrchr(wstr long) ntdll.wcsrchr
+@ cdecl wcsspn(wstr wstr) ntdll.wcsspn
+@ cdecl wcsstr(wstr wstr) 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 wcstok(wstr wstr) ntdll.wcstok
+@ cdecl wcstol(wstr ptr long) ntdll.wcstol
+@ cdecl wcstombs(ptr ptr long) ntdll.wcstombs
+@ cdecl wcstoul(wstr ptr long) ntdll.wcstoul
+@ stub wcsxfrm #(ptr wstr long)
 @ cdecl wctomb(ptr long) MSVCRT_wctomb
 @ varargs wprintf(wstr) MSVCRT_wprintf
Index: trunk/src/msvcrt/msvcrt20.def
===================================================================
--- trunk/src/msvcrt/msvcrt20.def	(revision 10001)
+++ trunk/src/msvcrt/msvcrt20.def	(revision 10005)
@@ -1,3 +1,3 @@
-; $Id: msvcrt20.def,v 1.12 2003-01-10 13:13:49 sandervl Exp $
+; $Id: msvcrt20.def,v 1.13 2003-04-10 10:28:04 sandervl Exp $
 
 ;
@@ -569,5 +569,5 @@
 ;  _dup2 = _dup2	@555
   _ecvt = _ecvt	@556
-  _endthread = _endthread	@557
+  _endthread @557
   _endthreadex = _endthreadex	@558
   _environ = _environ	@559
Index: trunk/src/msvcrt/msvcrt20.mak
===================================================================
--- trunk/src/msvcrt/msvcrt20.mak	(revision 10001)
+++ trunk/src/msvcrt/msvcrt20.mak	(revision 10005)
@@ -1,3 +1,3 @@
-# $Id: msvcrt20.mak,v 1.7 2003-01-15 10:43:16 sandervl Exp $
+# $Id: msvcrt20.mak,v 1.8 2003-04-10 10:28:04 sandervl Exp $
 
 #
@@ -33,4 +33,15 @@
 $(OBJDIR)\$(TARGET)rsrc.obj 
 
+LIBS = \
+$(ODIN32_LIB)\msvcrt.lib \
+$(ODIN32_LIB)\kernel32.lib \
+$(ODIN32_LIB)\ntdll.lib \
+$(ODIN32_LIB)\user32.lib \
+$(EMX)\lib\mt\c.lib \
+$(EMX)\lib\mt\c_dllso.lib \
+$(EMX)\lib\mt\sys.lib \
+$(EMX)\lib\os2.lib \
+
+
 #
 # Target name - name of the dll without extention and path.
@@ -39,10 +50,4 @@
 
 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: 
Index: trunk/src/msvcrt/msvcrt20.spec
===================================================================
--- trunk/src/msvcrt/msvcrt20.spec	(revision 10001)
+++ trunk/src/msvcrt/msvcrt20.spec	(revision 10005)
@@ -1,3 +1,3 @@
-; $Id: msvcrt20.spec,v 1.2 2003-01-10 13:13:49 sandervl Exp $
+; $Id: msvcrt20.spec,v 1.3 2003-04-10 10:28:04 sandervl Exp $
 
 ;
Index: trunk/src/msvcrt/msvcrt20rsrc.orc
===================================================================
--- trunk/src/msvcrt/msvcrt20rsrc.orc	(revision 10001)
+++ trunk/src/msvcrt/msvcrt20rsrc.orc	(revision 10005)
@@ -1,3 +1,3 @@
-/* $Id: msvcrt20rsrc.orc,v 1.4 2003-01-10 13:13:50 sandervl Exp $ */
+/* $Id: msvcrt20rsrc.orc,v 1.5 2003-04-10 10:28:05 sandervl Exp $ */
 
 #include "winuser.h"
Index: trunk/src/msvcrt/msvcrt40.def
===================================================================
--- trunk/src/msvcrt/msvcrt40.def	(revision 10001)
+++ trunk/src/msvcrt/msvcrt40.def	(revision 10005)
@@ -1,3 +1,3 @@
-; $Id: msvcrt40.def,v 1.12 2003-01-10 13:13:50 sandervl Exp $
+; $Id: msvcrt40.def,v 1.13 2003-04-10 10:28:05 sandervl Exp $
 
 ;
Index: trunk/src/msvcrt/msvcrt40.mak
===================================================================
--- trunk/src/msvcrt/msvcrt40.mak	(revision 10001)
+++ trunk/src/msvcrt/msvcrt40.mak	(revision 10005)
@@ -1,3 +1,3 @@
-# $Id: msvcrt40.mak,v 1.7 2003-01-15 10:43:16 sandervl Exp $
+# $Id: msvcrt40.mak,v 1.8 2003-04-10 10:28:05 sandervl Exp $
 
 #
@@ -33,4 +33,14 @@
 $(OBJDIR)\$(TARGET)rsrc.obj 
 
+LIBS = \
+$(ODIN32_LIB)\kernel32.lib \
+$(ODIN32_LIB)\msvcrt.lib \
+$(ODIN32_LIB)\ntdll.lib \
+$(ODIN32_LIB)\user32.lib \
+$(EMX)\lib\mt\c.lib \
+$(EMX)\lib\mt\c_dllso.lib \
+$(EMX)\lib\mt\sys.lib \
+$(EMX)\lib\os2.lib \
+
 #
 # Target name - name of the dll without extention and path.
@@ -39,10 +49,4 @@
 
 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: 
Index: trunk/src/msvcrt/msvcrt40rsrc.orc
===================================================================
--- trunk/src/msvcrt/msvcrt40rsrc.orc	(revision 10001)
+++ trunk/src/msvcrt/msvcrt40rsrc.orc	(revision 10005)
@@ -1,3 +1,3 @@
-/* $Id: msvcrt40rsrc.orc,v 1.4 2003-01-10 13:13:50 sandervl Exp $ */
+/* $Id: msvcrt40rsrc.orc,v 1.5 2003-04-10 10:28:05 sandervl Exp $ */
 
 #include "winuser.h"
Index: trunk/src/msvcrt/msvcrtrsrc.orc
===================================================================
--- trunk/src/msvcrt/msvcrtrsrc.orc	(revision 10001)
+++ trunk/src/msvcrt/msvcrtrsrc.orc	(revision 10005)
@@ -1,3 +1,3 @@
-/* $Id: msvcrtrsrc.orc,v 1.4 2003-01-10 13:13:51 sandervl Exp $ */
+/* $Id: msvcrtrsrc.orc,v 1.5 2003-04-10 10:28:06 sandervl Exp $ */
 
 #include "winuser.h"
Index: trunk/src/msvcrt/process.c
===================================================================
--- trunk/src/msvcrt/process.c	(revision 10001)
+++ trunk/src/msvcrt/process.c	(revision 10005)
@@ -28,4 +28,5 @@
 #ifdef __WIN32OS2__
 #include <emxheader.h>
+#include <string.h>
 #else
 #include "config.h"
@@ -203,5 +204,5 @@
  *		_cwait (MSVCRT.@)
  */
-int _cwait(int *status, int pid, int action)
+int MSVCRT__cwait(int *status, int pid, int action)
 {
   HANDLE hPid = (HANDLE)pid;
@@ -225,5 +226,5 @@
   {
     *MSVCRT__errno() =  MSVCRT_ECHILD;
-    *__doserrno() = doserrno;
+    *MSVCRT_doserrno() = doserrno;
   }
   else
@@ -239,5 +240,5 @@
  * or double-quotes.
  */
-int _execl(const char* name, const char* arg0, ...)
+int MSVCRT__execl(const char* name, const char* arg0, ...)
 {
   va_list ap;
@@ -261,5 +262,5 @@
  * or double-quotes.
  */
-int _execlp(const char* name, const char* arg0, ...)
+int MSVCRT__execlp(const char* name, const char* arg0, ...)
 {
   va_list ap;
@@ -268,5 +269,5 @@
   char fullname[MAX_PATH];
 
-  _searchenv(name, "PATH", fullname);
+  MSVCRT__searchenv(name, "PATH", fullname);
 
   va_start(ap, arg0);
@@ -286,7 +287,7 @@
  * or double-quotes.
  */
-int _execv(const char* name, char* const* argv)
-{
-  return _spawnve(_P_OVERLAY, name, (const char* const*) argv, NULL);
+int MSVCRT__execv(const char* name, char* const* argv)
+{
+  return MSVCRT__spawnve(_P_OVERLAY, name, (const char* const*) argv, NULL);
 }
 
@@ -297,7 +298,7 @@
  * 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);
+int MSVCRT__execve(const char* name, char* const* argv, const char* const* envv)
+{
+  return MSVCRT__spawnve(_P_OVERLAY, name, (const char* const*) argv, envv);
 }
 
@@ -308,10 +309,10 @@
  * or double-quotes.
  */
-int _execvpe(const char* name, char* const* argv, const char* const* envv)
+int MSVCRT__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,
+  MSVCRT__searchenv(name, "PATH", fullname);
+  return MSVCRT__spawnve(_P_OVERLAY, fullname[0] ? fullname : name,
                   (const char* const*) argv, envv);
 }
@@ -323,7 +324,7 @@
  * or double-quotes.
  */
-int _execvp(const char* name, char* const* argv)
-{
-  return _execvpe(name, argv, NULL);
+int MSVCRT__execvp(const char* name, char* const* argv)
+{
+  return MSVCRT__execvpe(name, argv, NULL);
 }
 
@@ -334,5 +335,5 @@
  * or double-quotes.
  */
-int _spawnl(int flags, const char* name, const char* arg0, ...)
+int MSVCRT__spawnl(int flags, const char* name, const char* arg0, ...)
 {
   va_list ap;
@@ -356,5 +357,5 @@
  * or double-quotes.
  */
-int _spawnlp(int flags, const char* name, const char* arg0, ...)
+int MSVCRT__spawnlp(int flags, const char* name, const char* arg0, ...)
 {
   va_list ap;
@@ -363,5 +364,5 @@
   char fullname[MAX_PATH];
 
-  _searchenv(name, "PATH", fullname);
+  MSVCRT__searchenv(name, "PATH", fullname);
 
   va_start(ap, arg0);
@@ -381,5 +382,5 @@
  * or double-quotes.
  */
-int _spawnve(int flags, const char* name, const char* const* argv,
+int MSVCRT__spawnve(int flags, const char* name, const char* const* argv,
                             const char* const* envv)
 {
@@ -409,7 +410,7 @@
  * or double-quotes.
  */
-int _spawnv(int flags, const char* name, const char* const* argv)
-{
-  return _spawnve(flags, name, argv, NULL);
+int MSVCRT__spawnv(int flags, const char* name, const char* const* argv)
+{
+  return MSVCRT__spawnve(flags, name, argv, NULL);
 }
 
@@ -420,10 +421,10 @@
  * or double-quotes.
  */
-int _spawnvpe(int flags, const char* name, const char* const* argv,
+int MSVCRT__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);
+  MSVCRT__searchenv(name, "PATH", fullname);
+  return MSVCRT__spawnve(flags, fullname[0] ? fullname : name, argv, envv);
 }
 
@@ -434,7 +435,7 @@
  * or double-quotes.
  */
-int _spawnvp(int flags, const char* name, const char* const* argv)
-{
-  return _spawnvpe(flags, name, argv, NULL);
+int MSVCRT__spawnvp(int flags, const char* name, const char* const* argv)
+{
+  return MSVCRT__spawnvpe(flags, name, argv, NULL);
 }
 
@@ -448,5 +449,5 @@
 
     /* Make a writable copy for CreateProcess */
-    cmdcopy=_strdup(cmd);
+    cmdcopy= MSVCRT__strdup(cmd);
     /* FIXME: should probably launch cmd interpreter in COMSPEC */
     res=msvcrt_spawn(_P_WAIT, NULL, cmdcopy, NULL);
@@ -477,2 +478,16 @@
   }
 }
+
+/*********************************************************************
+ *		_getdllprocaddr (MSVCRT.@)
+ */
+void *_getdllprocaddr(int dll, const char *name, int ordinal)
+{
+    if (name)
+    {
+        if (ordinal != -1) return NULL;
+        return GetProcAddress( (HMODULE)dll, name );
+    }
+    if (HIWORD(ordinal)) return NULL;
+    return GetProcAddress( (HMODULE)dll, (LPCSTR)(ULONG_PTR)ordinal );
+}
Index: trunk/src/msvcrt/relay2.S
===================================================================
--- trunk/src/msvcrt/relay2.S	(revision 10001)
+++ trunk/src/msvcrt/relay2.S	(revision 10005)
@@ -81,2 +81,3 @@
 	.stabs "",100,0,0,.Letext
 .Letext:
+
Index: trunk/src/msvcrt/rtlbitmap.c
===================================================================
--- trunk/src/msvcrt/rtlbitmap.c	(revision 10001)
+++ 	(revision )
@@ -1,1078 +1,0 @@
-/*
- * 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 10001)
+++ trunk/src/msvcrt/scanf.c	(revision 10005)
@@ -28,9 +28,10 @@
 #include "msvcrt.h"
 #include "msvcrt/conio.h"
+#include "msvcrt/ctype.h"
 #include "msvcrt/io.h"
 #include "msvcrt/stdio.h"
 #include "msvcrt/wctype.h"
 #include "wine/debug.h"
-
+#include <ctype.h>
 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
 
Index: trunk/src/msvcrt/scanf.h
===================================================================
--- trunk/src/msvcrt/scanf.h	(revision 10001)
+++ trunk/src/msvcrt/scanf.h	(revision 10005)
@@ -34,6 +34,6 @@
 #define _CHAR_ char
 #define _EOF_ MSVCRT_EOF
-#define _ISSPACE_(c) isspace(c)
-#define _ISDIGIT_(c) isdigit(c)
+#define _ISSPACE_(c) MSVCRT_isspace(c)
+#define _ISDIGIT_(c) MSVCRT_isdigit(c)
 #define _CONVERT_(c) c /*** FIXME ***/
 #define _CHAR2DIGIT_(c, base) char2digit((c), (base))
@@ -41,7 +41,7 @@
 
 #ifdef CONSOLE
-#define _GETC_(file) _getch()
-#define _UNGETC_(nch, file) _ungetch(nch)
-#define _FUNCTION_ _cscanf(const _CHAR_ *format, ...)
+#define _GETC_(file) MSVCRT__getch()
+#define _UNGETC_(nch, file) MSVCRT__ungetch(nch)
+#define _FUNCTION_ MSVCRT__cscanf(const _CHAR_ *format, ...)
 #else
 #ifdef STRING
@@ -115,5 +115,5 @@
 	    int w_prefix = 0;
 	    int prefix_finished = 0;
-	    /* int I64_prefix = 0; */
+	    int I64_prefix = 0; 
             format++;
 	    /* look for leading asterisk, which means 'suppress assignment of
@@ -139,5 +139,5 @@
 		    if (*(format + 1) == '6' &&
 			*(format + 2) == '4') {
-			/* I64_prefix = 1; */
+			I64_prefix = 1; 
 			format += 2;
 			FIXME("I64 prefix currently not implemented in fscanf/fwscanf");
@@ -222,5 +222,6 @@
 #define _SET_NUMBER_(type) *va_arg(ap, type*) = negative ? -cur : cur
 			if (number_signed) {
-			    if (l_prefix) _SET_NUMBER_(long int);
+			    if (I64_prefix)  _SET_NUMBER_(long long);
+			    else if (l_prefix) _SET_NUMBER_(long int);
 			    else if (h_prefix) _SET_NUMBER_(short int);
 			    else _SET_NUMBER_(int);
@@ -230,5 +231,6 @@
 				negative = 0;
 			    }
-			    if (l_prefix) _SET_NUMBER_(unsigned long int);
+			    if (I64_prefix)  _SET_NUMBER_(long long);
+			    else if (l_prefix) _SET_NUMBER_(unsigned long int);
 			    else if (h_prefix)
 				_SET_NUMBER_(unsigned short int);
Index: trunk/src/msvcrt/string.c
===================================================================
--- trunk/src/msvcrt/string.c	(revision 10001)
+++ trunk/src/msvcrt/string.c	(revision 10005)
@@ -25,5 +25,5 @@
 #include "msvcrt/stdlib.h"
 #include "msvcrt/string.h"
-
+#include <string.h>
 #include "wine/debug.h"
 
@@ -51,5 +51,5 @@
  *		_strdup (MSVCRT.@)
  */
-char* _strdup(const char* str)
+char* MSVCRT__strdup(const char* str)
 {
     char * ret = MSVCRT_malloc(strlen(str)+1);
@@ -61,6 +61,7 @@
  *		_strnset (MSVCRT.@)
  */
-char* _strnset(char* str, int value, unsigned int len)
+char* MSVCRT__strnset(char* str, int value, unsigned int len)
 {
+  dprintf(("MSVCRT: _strnset %s %d %d",str, value, len));
   if (len > 0 && str)
     while (*str && len--)
@@ -72,8 +73,10 @@
  *		_strrev (MSVCRT.@)
  */
-char* _strrev(char* str)
+char* MSVCRT__strrev(char* str)
 {
   char * p1;
   char * p2;
+
+  dprintf(("MSVCRT: _strrev %s",str));
 
   if (str && *str)
@@ -91,7 +94,10 @@
  *		_strset (MSVCRT.@)
  */
-char* _strset(char* str, int value)
+char* MSVCRT__strset(char* str, int value)
 {
   char *ptr = str;
+
+  dprintf(("MSVCRT: _strset %s %d",str, value));
+
   while (*ptr)
     *ptr++ = value;
@@ -103,6 +109,8 @@
  *		_swab (MSVCRT.@)
  */
-void _swab(char* src, char* dst, int len)
+void MSVCRT__swab(char* src, char* dst, int len)
 {
+  dprintf(("MSVCRT: _swab %s %s %d",src, dst, len));
+
   if (len > 1)
   {
@@ -116,2 +124,9 @@
   }
 }
+
+int MSVCRT_strncmp (const char* a,const char* b,MSVCRT(size_t) c)
+{
+  dprintf(("MSVCRT: strncmp %s,%s (%d)",a,b,c));
+  return strncmp(a,b,c);
+}
+
Index: trunk/src/msvcrt/thread.c
===================================================================
--- trunk/src/msvcrt/thread.c	(revision 10001)
+++ trunk/src/msvcrt/thread.c	(revision 10005)
@@ -19,5 +19,5 @@
  */
 #include "msvcrt.h"
-
+#include <string.h>
 #include "msvcrt/malloc.h"
 #include "msvcrt/process.h"
@@ -75,5 +75,5 @@
  *		_beginthread (MSVCRT.@)
  */
-unsigned long MSVCRT_beginthread(
+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 */
@@ -115,9 +115,9 @@
 
 /*********************************************************************
- *		MSVCRT_endthread (MSVCRT.@)
+ *		MSVCRT__endthread (MSVCRT.@)
  */
-void MSVCRT_endthread(void)
+void MSVCRT__endthread(void)
 {
-  TRACE("(void)\n");
+  TRACE("MSVCRT: _endthread(void)\n");
 
   /* FIXME */
@@ -131,5 +131,5 @@
   unsigned int retval) /* [in] Thread exit code */
 {
-  TRACE("(%d)\n", retval);
+  TRACE("MSVCRT: _endthreadex (%d)\n", retval);
 
   /* FIXME */
Index: trunk/src/msvcrt/time.c
===================================================================
--- trunk/src/msvcrt/time.c	(revision 10001)
+++ trunk/src/msvcrt/time.c	(revision 10005)
@@ -23,5 +23,7 @@
 #ifdef __WIN32OS2__
 #include <emxheader.h>
-#include <sys/times.h>
+#include <unistd.h>
+#include <time.h>
+#include <sys\times.h>
 #else
 #include "config.h"
@@ -63,4 +65,5 @@
 {
   MSVCRT_time_t res;
+  dprintf(("MSVCRT: mktime"));
   struct tm tm;
 
@@ -89,6 +92,7 @@
  *		_strdate (MSVCRT.@)
  */
-char* _strdate(char* date)
+char* MSVCRT__strdate(char* date)
 {
+  dprintf(("MSVCRT: _strdate"));
   return msvcrt_get_current_time(date,"%m/%d/%y");
 }
@@ -97,6 +101,7 @@
  *		_strtime (MSVCRT.@)
  */
-char* _strtime(char* date)
+char* MSVCRT__strtime(char* date)
 {
+  dprintf(("MSVCRT: _strtime"));
   return msvcrt_get_current_time(date,"%H:%M:%S");
 }
@@ -110,5 +115,7 @@
   clock_t res;
 
-  times(&alltimes);
+  dprintf(("MSVCRT: clock"));
+
+  emx__times(&alltimes);
   res = alltimes.tms_utime + alltimes.tms_stime +
         alltimes.tms_cutime + alltimes.tms_cstime;
@@ -124,4 +131,5 @@
 double MSVCRT_difftime(MSVCRT_time_t time1, MSVCRT_time_t time2)
 {
+    dprintf(("MSVCRT: difftime"));
     return (double)(time1 - time2);
 }
@@ -133,4 +141,5 @@
 {
   MSVCRT_time_t curtime = time(NULL);
+  dprintf(("MSVCRT: time"));
   return buf ? *buf = curtime : curtime;
 }
@@ -140,9 +149,10 @@
  */
 #ifdef __WIN32OS2__
-void MSVCRT_ftime(struct _timeb *buf)
+void MSVCRT__ftime(struct _timeb *buf)
 #else
 void _ftime(struct _timeb *buf)
 #endif
 {
+  dprintf(("MSVCRT: _ftime %p",buf));
   buf->time = MSVCRT_time(NULL);
   buf->millitm = 0; /* FIXME */
@@ -150,2 +160,15 @@
   buf->dstflag = 0;
 }
+
+/*********************************************************************
+ *		_daylight (MSVCRT.@)
+ */
+int MSVCRT___daylight = 1; /* FIXME: assume daylight */
+
+/*********************************************************************
+ *		__p_daylight (MSVCRT.@)
+ */
+void *MSVCRT___p__daylight(void)
+{
+	return &MSVCRT___daylight;
+}
Index: trunk/src/msvcrt/wcs.c
===================================================================
--- trunk/src/msvcrt/wcs.c	(revision 10001)
+++ trunk/src/msvcrt/wcs.c	(revision 10005)
@@ -20,5 +20,9 @@
  */
 #include <limits.h>
+#include <stdlib.h>
 #include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+
 #include "msvcrt.h"
 #include "winnls.h"
@@ -58,4 +62,5 @@
 {
   MSVCRT_wchar_t* ret = NULL;
+  dprintf(("MSVCRT: _wcsdup %s",debugstr_w(str)));
   if (str)
   {
@@ -118,122 +123,5 @@
                 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;
+    return vsnprintfW(str, len, format, valist);
 }
 
@@ -243,5 +131,5 @@
 int MSVCRT_vswprintf( MSVCRT_wchar_t* str, const MSVCRT_wchar_t* format, va_list args )
 {
-  return _vsnwprintf( str, INT_MAX, format, args );
+    return vsnprintfW( str, INT_MAX, format, args );
 }
 
@@ -365,23 +253,2 @@
 }
 
-/*********************************************************************
- *		_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;
-}
