Index: trunk/src/crtdll/bsearch.c
===================================================================
--- trunk/src/crtdll/bsearch.c	(revision 2617)
+++ 	(revision )
@@ -1,33 +1,0 @@
-/* $Id: bsearch.c,v 1.2 1999-12-21 12:27:11 sandervl Exp $ */
-/* bsearch.c (emx+gcc) -- Copyright (c) 1990-1995 by Eberhard Mattes */
-
-#include <odin.h>
-#include <builtin.h>
-
-/*********************************************************************
- *                  bsearch	(CRTDLL.346)
- */
-
-void *CDECL CRTDLL_bsearch (const void *key, const void *base, size_t num, size_t width,
-                     int (* CDECL compare)(const void *key, const void *element))
-{
-  int left, right, median, sign;
-  const void *element;
-  
-  if (width == 0)
-    return 0;
-  left = 1; right = num;
-  while (left <= right)
-    {
-      median = (left + right) / 2;
-      element = (void *)((char *)base + (median-1)*width);
-      sign = compare (key, element);
-      if (sign == 0)
-        return (void *)element;
-      if (sign > 0)
-        left = median + 1;
-      else
-        right = median - 1;
-    }
-  return 0;
-}
Index: trunk/src/crtdll/crt.cpp
===================================================================
--- trunk/src/crtdll/crt.cpp	(revision 2617)
+++ 	(revision )
@@ -1,2248 +1,0 @@
-/* $Id: crt.cpp,v 1.5 2000-01-08 14:24:03 sandervl Exp $ */
-
-/*
- * Project Odin Software License can be found in LICENSE.TXT
- * Win32 NT Runtime / NTDLL for OS/2
- *
- * Copyright 1999 Patrick Haller (phaller@gmx.net)
- * Copyright 1999 Alexandre Julliard (CRTDLL__wcsnicmp)
- *
- */
-
-/****************************************************************************
- * Include                                                                  *
- ****************************************************************************/
-
-#include <odin.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-#include <ctype.h>
-#include <wchar.h>
-#include <wcstr.h>
-#include <wctype.h>
-
-#include <os2win.h>
-#include <misc.h>
-
-#include <ntdef.h>
-#include <winnt.h>
-#include "winbase.h"                     /* fixme: should be taken out sometimes */
-#include <heapstring.h>
-#include "asmhlp.h"
-
-
-/****************************************************************************
- * Local Prototypes                                                         *
- ****************************************************************************/
-
-
-LPWSTR CDECL CRTDLL__wcsupr(LPWSTR str);
-int    CDECL CRTDLL__wcsnicmp(LPWSTR str1, LPWSTR str2, long l);
-
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.879
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-int CDECL CRTDLL__wcsicmp(LPWSTR str1, LPWSTR str2)
-{
-  dprintf2(("CRTDLL: _wcsicmp(%08xh,%08xh)\n",
-           str1,
-           str2));
-
-  return (CRTDLL__wcsnicmp(str1,
-                       str2,
-                       wcslen((wchar_t*) str1)));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.880
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-LPWSTR CDECL CRTDLL__wcslwr(LPWSTR str)
-{
-  DWORD dwIndex;
-
-  dprintf2(("CRTDLL: _wcslwr(%08xh)\n",
-           str));
-
-  for (dwIndex = wcslen((const wchar_t*)str);
-       dwIndex;
-       dwIndex--)
-  {
-    towlower(str[dwIndex]);
-  }
-
-  return (str);
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.881
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-int CDECL CRTDLL__wcsnicmp(LPWSTR str1, LPWSTR str2, long n)
-{
-  dprintf2(("CRTDLL: _wcsnicmp(%08xh,%08xh,%08xh)\n",
-           str1,
-           str2,
-           l));
-
-    if (!n) return 0;
-    while ((--n > 0) && *str1 && (towupper(*str1) == towupper(*str2)))
-    {
-        str1++;
-        str2++;
-    }
-    return towupper(*str1) - towupper(*str2);
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.882
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-LPWSTR CDECL CRTDLL__wcsupr(LPWSTR str)
-{
-  DWORD dwIndex;
-
-  dprintf2(("CRTDLL: _wcsupr(%08xh)\n",
-           str));
-
-  for (dwIndex = wcslen((const wchar_t*)str);
-       dwIndex;
-       dwIndex--)
-  {
-    towupper(str[dwIndex]);
-  }
-
-  return (str);
-}
-
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.883
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-double CDECL CRTDLL_abs(double d)
-{
-  dprintf2(("CRTDLL: abs(%f)\n",
-           d));
-
-  return (abs(d));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.884
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-double CDECL CRTDLL_atan(double d)
-{
-  dprintf2(("CRTDLL: atan(%f)\n",
-           d));
-
-  return (atan(d));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.885
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-int CDECL CRTDLL_atoi(LPSTR str)
-{
-  dprintf2(("CRTDLL: atoi(%s)\n",
-           str));
-
-  return (atoi(str));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.886
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-long CDECL CRTDLL_atol(LPSTR str)
-{
-  dprintf2(("CRTDLL: atol(%s)\n",
-           str));
-
-  return (atol(str));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.887
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-double CDECL CRTDLL_ceil(double d)
-{
-  dprintf2(("CRTDLL: ceil(%f)\n",
-           d));
-
-  return (ceil(d));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.888
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-double CDECL CRTDLL_cos(double d)
-{
-  dprintf2(("CRTDLL: cos(%f)\n",
-           d));
-
-  return (cos(d));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.889
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-double CDECL CRTDLL_fabs(double d)
-{
-  dprintf2(("CRTDLL: fabs(%f)\n",
-           d));
-
-  return (fabs(d));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.890
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-double CDECL CRTDLL_floor(double d)
-{
-  dprintf2(("CRTDLL: floor(%f)\n",
-           d));
-
-  return (floor(d));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.891
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-int CDECL CRTDLL_isalpha(int i)
-{
-  dprintf2(("CRTDLL: isalpha(%08xh)\n",
-           i));
-
-  return (isalpha(i));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.892
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-int CDECL CRTDLL_isdigit(int i)
-{
-  dprintf2(("CRTDLL: isdigit(%08xh)\n",
-           i));
-
-  return (isdigit(i));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.893
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-int CDECL CRTDLL_islower(int i)
-{
-  dprintf2(("CRTDLL: islower(%08xh)\n",
-           i));
-
-  return (islower(i));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.894
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-int CDECL CRTDLL_isprint(int i)
-{
-  dprintf2(("CRTDLL: isprint(%08xh)\n",
-           i));
-
-  return (isprint(i));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.895
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-int CDECL CRTDLL_isspace(int i)
-{
-  dprintf2(("CRTDLL: isspace(%08xh)\n",
-           i));
-
-  return (isspace(i));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.896
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-int CDECL CRTDLL_isupper(int i)
-{
-  dprintf2(("CRTDLL: isupper(%08xh)\n",
-           i));
-
-  return (isupper(i));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.911
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-LPSTR CDECL CRTDLL_sprintf(LPSTR lpstrBuffer,
-                       LPSTR lpstrFormat,
-                       ...)
-{
-  va_list argptr;                          /* -> variable argument list */
-
-  dprintf2(("CRTDLL: sprintf(%08xh,%s)\n",
-           lpstrBuffer,
-           lpstrFormat));
-
-  va_start(argptr,
-           lpstrFormat);                   /* get pointer to argument list */
-  vsprintf(lpstrBuffer,
-           lpstrFormat,
-           argptr);
-  va_end(argptr);                          /* done with variable arguments */
-
-  return (lpstrBuffer);
-}
-
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.914
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-LPSTR CDECL CRTDLL_strcat(      LPSTR str1,
-                      const LPSTR str2)
-{
-  dprintf2(("CRTDLL: strcat\n"));
-
-  return (strcat(str1, str2));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.915
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-LPSTR CDECL CRTDLL_strchr(const LPSTR str,
-                       int         i)
-{
-  dprintf2(("CRTDLL: strchr(%s,%08xh)\n",
-           str,
-           i));
-
-  return (strchr(str, i));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.916
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-int CDECL CRTDLL_strcmp(const LPSTR str1,
-                      const LPSTR str2)
-{
-  dprintf2(("CRTDLL: strcmp(%s,%s)\n",
-           str1,
-           str2));
-
-  return (strcmp(str1, str2));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.?
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-int CDECL CRTDLL__stricmp(const LPSTR str1,
-                      const LPSTR str2)
-{
-  dprintf2(("CRTDLL: _stricmp(%s,%s)\n",
-           str1,
-           str2));
-
-  return (stricmp(str1, str2));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.917
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-LPSTR CDECL CRTDLL_strcpy(      LPSTR str1,
-                       const LPSTR str2)
-{
-  dprintf2(("CRTDLL: strcpy\n"));
-
-  return (strcpy(str1, str2));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.918
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-size_t CDECL CRTDLL_strcspn(const LPSTR str1,
-                                LPSTR str2)
-{
-  dprintf2(("CRTDLL: strcspn(%s,%s)\n",
-           str1,
-           str2));
-
-  return (strcspn(str1, str2));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.919
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-size_t CDECL CRTDLL_strlen(const LPSTR str)
-{
-  dprintf2(("CRTDLL: strlen(%s)\n",
-           str));
-
-  return (strlen(str));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.920
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-LPSTR CDECL CRTDLL_strncat(      LPSTR str1,
-                        const LPSTR str2,
-                        size_t      i)
-{
-  dprintf2(("CRTDLL: strncat(%s,%s,%08xh)\n",
-           str1,
-           str2,
-           i));
-
-  return (strncat(str1, str2, i));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.921
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-int CDECL CRTDLL_strncmp(const LPSTR str1,
-                       const LPSTR str2,
-                       size_t      i)
-{
-  dprintf2(("CRTDLL: strncmp(%s,%s,%08xh)\n",
-           str1,
-           str2,
-           i));
-
-  return (strncmp(str1, str2, i));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.922
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-LPSTR CDECL CRTDLL_strncpy(const LPSTR str1,
-                        const LPSTR str2,
-                        size_t      i)
-{
-  dprintf2(("CRTDLL: strncpy(%s,%s,%08xh)\n",
-           str1,
-           str2,
-           i));
-
-  return (strncpy(str1, str2, i));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.923
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-LPSTR CDECL CRTDLL_strpbrk(const LPSTR str1,
-                      const LPSTR str2)
-{
-  dprintf2(("CRTDLL: strpbrk(%s,%s)\n",
-           str1,
-           str2));
-
-  return (strpbrk(str1, str2));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.924
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-LPSTR CDECL CRTDLL_strrchr(const LPSTR str,
-                        size_t      i)
-{
-  dprintf2(("CRTDLL: strrchr(%s,%08xh)\n",
-           str,
-           i));
-
-  return (strrchr(str, i));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.925
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-size_t CDECL CRTDLL_strspn(const LPSTR str1,
-                       const LPSTR str2)
-{
-  dprintf2(("CRTDLL: strspn(%s,%s)\n",
-           str1,
-           str2));
-
-  return (strspn(str1, str2));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.926
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-LPSTR CDECL CRTDLL_strstr(const LPSTR str1,
-                       const LPSTR str2)
-{
-  dprintf2(("CRTDLL: strstr(%s,%s)\n",
-           str1,
-           str2));
-
-  return (strstr(str1, str2));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.927
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-int CDECL CRTDLL_swprintf(const LPWSTR str,
-                      int   i,
-                      const LPWSTR format,
-                      ...)
-{
-  va_list valist;
-  int     rc;
-
-  dprintf2(("CRTDLL: swprintf(%s,%d,%s)\n",
-           str,
-           i,
-           format));
-
-  va_start( valist, format );
-  rc = vswprintf( (wchar_t*)str,
-                  i,
-                  (wchar_t*)format,
-                  valist );
-  va_end( valist );
-  return rc;
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.928
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-double CDECL CRTDLL_tan(double d)
-{
-  dprintf2(("CRTDLL: tan(%f)\n",
-           d));
-
-  return (tan(d));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.929
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-int CDECL CRTDLL_toupper(int c)
-{
-  dprintf2(("CRTDLL: toupper(%c)\n",
-           c));
-
-  return (toupper(c));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.930
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-int CDECL CRTDLL_tolower(int c)
-{
-  dprintf2(("CRTDLL: tolower(%c)\n",
-           c));
-
-  return (tolower(c));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.931
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-int CDECL CRTDLL_towupper(int c)
-{
-  dprintf2(("CRTDLL: towupper(%c)\n",
-           c));
-
-  return (towupper(c));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.932
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-int CDECL CRTDLL_towlower(int c)
-{
-  dprintf2(("CRTDLL: towlower(%c)\n",
-           c));
-
-  return (towlower(c));
-}
-
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.934
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-wchar_t* CDECL CRTDLL_wcscat(      wchar_t* str1,
-                       const wchar_t* str2)
-{
-  dprintf2(("CRTDLL: wcscat(%08xh,%08xh)\n",
-           str1,
-           str2));
-
-  return (wcscat(str1, str2));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.935
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-wchar_t* CDECL CRTDLL_wcschr(const wchar_t* str,
-                       int          i)
-{
-  dprintf2(("CRTDLL: wcschr(%08xh,%08xh)\n",
-           str,
-           i));
-
-  return (wcschr(str, i));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.936
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-int CDECL CRTDLL_wcscmp(const wchar_t* str1,
-                    const wchar_t* str2)
-{
-  dprintf2(("CRTDLL: wcscmp(%08xh,%08xh)\n",
-           str1,
-           str2));
-
-  return (wcscmp(str1, str2));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.937
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-wchar_t* CDECL CRTDLL_wcscpy(      wchar_t* str1,
-                       const wchar_t* str2)
-{
-  dprintf2(("CRTDLL: wcscpy(%08xh,%08xh)\n",
-           str1,
-           str2));
-
-  return (wcscpy(str1, str2));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.938
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-size_t CDECL CRTDLL_wcscspn(const wchar_t* str1,
-                              wchar_t* str2)
-{
-  dprintf2(("CRTDLL: wcscspn(%08xh,%08xh)\n",
-           str1,
-           str2));
-
-  return (wcscspn(str1, str2));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.939
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-size_t CDECL CRTDLL_wcslen(const wchar_t* str)
-{
-  dprintf2(("CRTDLL: wcslen(%08xh)\n",
-           str));
-
-  return (wcslen(str));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.940
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-wchar_t* CDECL CRTDLL_wcsncat(      wchar_t* str1,
-                        const wchar_t* str2,
-                        size_t      i)
-{
-  dprintf2(("CRTDLL: wcsncat(%08xh,%08xh,%08xh)\n",
-           str1,
-           str2,
-           i));
-
-  return (wcsncat(str1, str2, i));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.941
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-int CDECL CRTDLL_wcsncmp(const wchar_t* str1,
-                     const wchar_t* str2,
-                     size_t      i)
-{
-  dprintf2(("CRTDLL: wcsncmp(%08xh,%08xh,%08xh)\n",
-           str1,
-           str2,
-           i));
-
-  return (wcsncmp(str1, str2, i));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.942
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-wchar_t* CDECL CRTDLL_wcsncpy(      wchar_t* str1,
-                          const wchar_t* str2,
-                          size_t       i)
-{
-  dprintf2(("CRTDLL: wcsncpy(%s,%s,%08xh)\n",
-           str1,
-           str2,
-           i));
-
-  return (wcsncpy(str1, str2, i));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.943
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-wchar_t* CDECL CRTDLL_wcspbrk(const wchar_t* str1,
-                        const wchar_t* str2)
-{
-  dprintf2(("CRTDLL: wcspbrk(%08xh,%08xh)\n",
-           str1,
-           str2));
-
-  return (wcspbrk(str1, str2));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.944
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-wchar_t* CDECL CRTDLL_wcsrchr(const wchar_t* str,
-                        size_t       i)
-{
-  dprintf2(("CRTDLL: wcsrchr(%08xh,%08xh)\n",
-           str,
-           i));
-
-  return (wcsrchr(str, i));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.945
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-size_t CDECL CRTDLL_wcsspn(const wchar_t* str1,
-                       const wchar_t* str2)
-{
-  dprintf2(("CRTDLL: wcsspn(%08xh,%08xh)\n",
-           str1,
-           str2));
-
-  return (wcsspn(str1, str2));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.946
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-wchar_t* CDECL CRTDLL_wcsstr(const wchar_t* str1,
-                         const wchar_t* str2)
-{
-  dprintf2(("CRTDLL: wcsstr(%s,%s)\n",
-           str1,
-           str2));
-
-  return (wcsstr(str1, str2));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.?
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-char * CDECL CRTDLL__itoa(int i, char *s, int r)
-{
-  dprintf2(("CRTDLL: _itoa(%08xh, %08xh, %08xh)\n",
-           i,
-           s,
-           r));
-
-  return (itoa(i,s,r));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.?
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/06/22 20:44]
- *****************************************************************************/
-
-char * CDECL CRTDLL__itow(int i, char *s, int r)
-{
-  dprintf(("CRTDLL: _itow(%08xh, %08xh, %08xh) no unicode support !\n",
-           i,
-           s,
-           r));
-
-  return (itoa(i,s,r));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.749
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-LONG CDECL CRTDLL__CIpow()
-{
-	double x,y;
-	POP_FPU(y);
-	POP_FPU(x);
-	return pow(x,y);
-}
-
-
-/*********************************************************************
- *                  _CIacos    (CRTDLL.004)
- */
-double CDECL CRTDLL__CIacos()
-{
- double x;
-
-  dprintf2(("CRTDLL: _CIacos\n"));
-  POP_FPU(x);
-  return acos(x);
-}
-
-
-/*********************************************************************
- *                  _CIasin    (CRTDLL.005)
- */
-double CDECL CRTDLL__CIasin()
-{
- double x;
-
-  dprintf2(("CRTDLL: _CIasin\n"));
-  POP_FPU(x);
-  return asin(x);
-}
-
-
-/*********************************************************************
- *                  _CIatan    (CRTDLL.006)
- */
-double CDECL CRTDLL__CIatan()
-{
- double x;
-
-  dprintf2(("CRTDLL: _CIatan\n"));
-  POP_FPU(x);
-  return atan(x);
-}
-
-
-/*********************************************************************
- *                  _CIatan2    (CRTDLL.007)
- */
-double CDECL CRTDLL__CIatan2()
-{
- double x, y;
-
-  dprintf2(("CRTDLL: _CIatan2\n"));
-  POP_FPU(y);
-  POP_FPU(x);
-  return atan2(x,y);
-}
-
-
-/*********************************************************************
- *                  _CIcos    (CRTDLL.008)
- */
-double CDECL CRTDLL__CIcos()
-{
- double x;
-
-  dprintf2(("CRTDLL: _CIcos\n"));
-  POP_FPU(x);
-  return cos(x);
-}
-
-
-/*********************************************************************
- *                  _CIcosh    (CRTDLL.009)
- */
-double CDECL CRTDLL__CIcosh()
-{
- double x;
-
-  dprintf2(("CRTDLL: _CIcosh\n"));
-  POP_FPU(x);
-  return cosh(x);
-}
-
-
-/*********************************************************************
- *                  _CIexp    (CRTDLL.010)
- */
-double CDECL CRTDLL__CIexp()
-{
- double x;
-
-  dprintf2(("CRTDLL: _CIexp\n"));
-  POP_FPU(x);
-  return exp(x);
-}
-
-
-/*********************************************************************
- *                  _CIfmod     (CRTDLL.011)
- */
-double CDECL CRTDLL__CIfmod( )
-{
- double x, y;
-
-  dprintf2(("CRTDLL: _CIfmod\n"));
-  POP_FPU(y);
-  POP_FPU(x);
-  return fmod(x,y);
-}
-
-
-/*********************************************************************
- *                  _CIlog    (CRTDLL.012)
- */
-double CDECL CRTDLL__CIlog()
-{
- double x;
-
-  dprintf2(("CRTDLL: _CIlog\n"));
-  POP_FPU(x);
-  return log(x);
-}
-
-
-/*********************************************************************
- *                  _CIlog10    (CRTDLL.013)
- */
-double CDECL CRTDLL__CIlog10()
-{
- double x;
-
-  dprintf2(("CRTDLL: _CIlog10\n"));
-  POP_FPU(x);
-  return log10(x);
-}
-
-
-/*********************************************************************
- *                  _CIsin     (CRTDLL.015)
- */
-double CDECL CRTDLL__CIsin()
-{
- double x;
-
-  dprintf2(("CRTDLL: _CIsin\n"));
-  POP_FPU(x);
-  return sin(x);
-}
-
-
-/*********************************************************************
- *                  _CIsinh    (CRTDLL.016)
- */
-double CDECL CRTDLL__CIsinh()
-{
- double x;
-
-  dprintf2(("CRTDLL: _CIsinh\n"));
-  POP_FPU(x);
-  return sinh(x);
-}
-
-
-/*********************************************************************
- *                  _CIsqrt    (CRTDLL.017)
- */
-double CDECL CRTDLL__CIsqrt()
-{
- double x;
-
-  dprintf2(("CRTDLL: _CIsqrt\n"));
-  POP_FPU(x);
-  return sqrt(x);
-}
-
-
-/*********************************************************************
- *                  _CItan    (CRTDLL.018)
- */
-double CDECL CRTDLL__CItan()
-{
- double x;
-
-  dprintf2(("CRTDLL: _CItan\n"));
-  POP_FPU(x);
-  return tan(x);
-}
-
-
-/*********************************************************************
- *                  _CItanh    (CRTDLL.019)
- */
-double CDECL CRTDLL__CItanh()
-{
- double x;
-
-  dprintf2(("CRTDLL: _CItanh\n"));
-  POP_FPU(x);
-  return tanh(x);
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.864
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-LONG CDECL CRTDLL__ftol(void)
-{
-	/* don't just do DO_FPU("fistp",retval), because the rounding
-	 * mode must also be set to "round towards zero"... */
-	double fl;
-	POP_FPU(fl);
-	return (LONG)fl;
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.866
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-LPSTR  CDECL CRTDLL__ltoa(long x,LPSTR buf,INT radix)
-{
-    return ltoa(x,buf,radix);
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.868
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-INT CDECL CRTDLL__memicmp(
-	LPCSTR s1,	/* [in] first string */
-	LPCSTR s2,	/* [in] second string */
-	DWORD len	/* [in] length to compare */ )
-{
-	dprintf2(("CRTDLL: memicmp(%08xh, %08xh, %08xh)\n",s1,s2,len));
-	int	i;
-
-	for (i=0;i<len;i++) {
-		if (tolower(s1[i])<tolower(s2[i]))
-			return -1;
-		if (tolower(s1[i])>tolower(s2[i]))
-			return  1;
-	}
-	return 0;
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.869
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-int  CDECL CRTDLL__snprintf( char *buf, size_t bufsize, const char *fmt, ... )
-{
-  dprintf(("CRTDLL: _snprintf(%08xh, %08xh, %08xh) not implemented\n",
-           buf,
-           bufsize,
-           fmt));
-
-  return 0;
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.870
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-int  CDECL CRTDLL__snwprintf( wchar_t *buf, size_t bufsize, const wchar_t *fmt, ... )
-{
-  dprintf(("CRTDLL: _snwprintf(%08xh, %08xh, %08xh) not implemented\n",
-           buf,
-           bufsize,
-           fmt));
-
-  return 0;
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.871
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-void CDECL CRTDLL__splitpath( const char *path, char *drive, char *dir, char *fname, char *ext )
-{
-	dprintf2(("CRTDLL: _splitpath"));
-
-	char *tmp_drive;
-	char *tmp_dir;
-	char *tmp_ext;
-
-	tmp_drive = (char *)strchr(path,':');
-	if ( tmp_drive != (char *)NULL ) {
-		strncpy(drive,tmp_drive-1,1);
-		*(drive+1) = 0;
-	}
-	else {
-		*drive = 0;
-		tmp_drive = (char *)path;
-	}
-
-	tmp_dir = (char *)strrchr(path,'\\');
-	if( tmp_dir != NULL && tmp_dir != tmp_drive + 1 ) {
-		strncpy(dir,tmp_drive+1,tmp_dir - tmp_drive);
-		*(dir + (tmp_dir - tmp_drive)) = 0;
-	}
-	else 	
-		*dir =0;
-
-	tmp_ext = ( char *)strrchr(path,'.');
-	if ( tmp_ext != NULL ) {
-		strcpy(ext,tmp_ext);
-	}
-	else
-		*ext = 0;
-    if ( tmp_dir != NULL ) {
-		strncpy(fname,tmp_dir+1,tmp_ext - tmp_dir - 1);
-		*(fname + (tmp_ext - tmp_dir -1)) = 0;
-	}
-	else
-		strncpy(fname,path,tmp_ext - path);
-
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.872
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-void CDECL CRTDLL__strcmpi( LPCSTR s1, LPCSTR s2 )
-{
-  dprintf2(("CRTDLL: _strcmpi(%08xh, %08xh)\n",
-           s1,
-           s2));
-
-  lstrcmpiA( s1, s2 );
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.874
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-CHAR * CDECL CRTDLL__strlwr(char *x)
-{
-  char *y =x;
-
-  dprintf2(("CRTDLL: _strlwr got %s\n", x));
-  while (*y) {
-    if ((*y > 0x40) && (*y< 0x5b))
-      *y = *y + 0x20;
-    y++;
-  }
-  dprintf2(("   returned %s\n", x));
-		
-  return x;
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.875
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-int  CDECL CRTDLL__strnicmp( LPCSTR s1, LPCSTR s2, INT n )
-{
-  dprintf2(("CRTDLL: _strnicmp (%s,%s,%d)\n",
-           s1,
-           s2,
-           n));
-
-  // @@@PH: sure it's not a UNICODE API?
-  return (lstrncmpiA(s1,s2,n));
-
-/*
-  if (n == 0)
-    return 0;
-  do {
-    if (toupper(*s1) != toupper(*s2++))
-      return toupper(*(unsigned const char *)s1) - toupper(*(unsigned const char *)--s2);
-    if (*s1++ == 0)
-      break;
-  } while (--n != 0);
-  return 0;
-*/
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.876
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-LPSTR CDECL CRTDLL__strupr(LPSTR x)
-{
-  dprintf2(("CRTDLL: _strupr(%s)\n",
-           x));
-
-  LPSTR y=x;
-
-  while (*y)
-  {
-    *y=toupper(*y);
-    y++;
-  }
-  return x;
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.877
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-LPSTR  CDECL CRTDLL__ultoa(long x,LPSTR buf,INT radix)
-{
-    return ultoa(x,buf,radix);
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.878
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-int CDECL CRTDLL__vsnprintf( char *s, size_t bufsize, const char *format, va_list arg )
-{
-  dprintf2(("CRTDLL: _vsnprintf(%08xh, %08xh, %08xh)\n",
-           s,
-           bufsize,
-           format));
-
-  return wvsnprintfA(s, bufsize, format, arg);
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.897
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-int CDECL CRTDLL_iswalpha(wint_t i)
-{
-  dprintf2(("CRTDLL: iswalpha(%08xh)\n", i));
-
-  return (iswalpha(i));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.898
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-int CDECL CRTDLL_iswctype(wint_t i, wctype_t wct)
-{
-  dprintf2(("CRTDLL: iswctype(%08xh, %08xh)\n", i, wct));
-
-  return (iswctype(i, wct));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.899
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-int CDECL CRTDLL_isxdigit(int i)
-{
-  dprintf2(("CRTDLL: isxdigit(%08xh)\n", i));
-
-  return (isxdigit(i));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.900
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-long int CDECL CRTDLL_labs( long int j )
-{
-  dprintf2(("CRTDLL: labs(%08xh)\n", j));
-
-  return (labs(j));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.901
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-double CDECL CRTDLL_log( double x )
-{
-  dprintf2(("CRTDLL: log(%08xh)\n", x));
-  return (log(x));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.902
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-size_t CDECL CRTDLL_mbstowcs( wchar_t *pwcs, const char *s, size_t n )
-{
-      dprintf2(("CRTDLL: mbstowcs(%08xh, %08xh, %08xh)\n", pwcs, s, n));
-      return (mbstowcs(pwcs, s, n));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.903
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-void * CDECL CRTDLL_memchr( const void *s, int c, size_t n )
-{
-    dprintf2(("CRTDLL: memchr(%08xh, %08xh, %08xh)\n", s, c, n));
-    return memchr( s, c, n );
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.904
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-int CDECL CRTDLL_memcmp( const void * c1, const void * c2, size_t n )
-{
-    dprintf2(("CRTDLL: memcmp(%08xh, %08xh, %08xh)\n", c1, c2, n));
-    return memcmp( c1, c2, n );
-}
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.905
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-void * CDECL CRTDLL_memcpy( void *s1, const void *s2, size_t n )
-{
-    dprintf2(("CRTDLL: memcpy(%08xh, %08xh, %08xh)\n", s1, s2, n));
-    return memcpy( s1, s2, n );
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.907
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-void * CDECL CRTDLL_memset( void *s, int i, size_t n )
-{
-    dprintf2(("CRTDLL: memset(%08xh, %08xh, %08xh)\n", s, i, n));
-    return memset( s, i, n );
-}
-//******************************************************************************
-VOID CDECL CRTDLL_memmove(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, DWORD Length)
-{
-  memmove(Destination, Source, Length);
-}
-//******************************************************************************
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.908
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-double CDECL CRTDLL_pow( double x, double y )	
-{
-    dprintf2(("CRTDLL: pow(%08xh, %08xh)\n",x, y));
-    return pow( x, y );
-}
-
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.910
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-double CDECL CRTDLL_sin( double x )
-{
-  dprintf2(("CRTDLL: sin(%08xh)\n", x));
-  return (sin(x));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.912
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-double CDECL CRTDLL_sqrt( double x )
-{
-  dprintf2(("CRTDLL: sqrt(%08xh)\n", x));
-  return (sqrt(x));
-}
-
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.913
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-int CDECL CRTDLL_sscanf( const char *s, const char *format, ... )
-{
-  dprintf(("CRTDLL: sscanf(%08xh, %08xh) not implemented.\n"));
-  return 0;
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.933
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-int CDECL CRTDLL_vsprintf( char *s, const char *format, va_list arg )
-{
-  dprintf2(("CRTDLL: vsprintf(%08xh, %08xh)\n", s, format));
-  return (vsprintf(s, format, arg));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.947
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-wchar_t * CDECL CRTDLL_wcstok( wchar_t *s1, const wchar_t *s2, wchar_t **ptr )
-{
-  dprintf2(("CRTDLL: wcstok(%08xh, %08xh, %08xh)\n",s1,s2,ptr));
-  return (wcstok(s1, s2, ptr));
-}
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.948
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-long int CDECL CRTDLL_wcstol( const wchar_t *s1, wchar_t **s2, int i )
-{
-  dprintf2(("CRTDLL: wcstol(%08xh, %08xh, %08xh)\n",s1,s2,i));
-  return (wcstol(s1, s2, i));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.949
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-size_t CDECL CRTDLL_wcstombs( char *s, const wchar_t *pwcs, size_t n )
-{
-  dprintf2(("CRTDLL: wcstombs(%08xh, %08xh, %08xh)\n",s,pwcs,n));
-  return (wcstombs(s, pwcs, n));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.950
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-unsigned long int CDECL CRTDLL_wcstoul( const wchar_t *s1, wchar_t **s2, int i )
-{
-  dprintf2(("CRTDLL: wcstoul(%08xh, %08xh, %08xh)\n",s1,s2,i));
-  return (wcstoul(s1, s2, i));
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.983
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-int CDECL CRTDLL__wtoi( const wchar_t *s )
-{
-  dprintf(("CRTDLL: _wtoi(%08xh) not implemented.\n"));
-  return 0;
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    : NTDLL.984
- * Status    :
- *
- * Author    : Jens Wiessner
- *****************************************************************************/
-
-long int CDECL CRTDLL__wtol( const wchar_t *s )
-{
-  dprintf(("CRTDLL: _wtol(%08xh) not implemented.\n"));
-  return 0;
-}
Index: trunk/src/crtdll/crt_mb.cpp
===================================================================
--- trunk/src/crtdll/crt_mb.cpp	(revision 2618)
+++ trunk/src/crtdll/crt_mb.cpp	(revision 2618)
@@ -0,0 +1,180 @@
+/* $Id: crt_mb.cpp,v 1.1 2000-02-03 21:37:47 sandervl Exp $ */
+
+/*
+ * The C RunTime DLL
+ * 
+ * Implements C run-time functionality as known from UNIX.
+ *
+ * Partialy based on Wine
+ *
+ * Copyright 1996,1998 Marcus Meissner
+ * Copyright 1996 Jukka Iivonen
+ * Copyright 1997 Uwe Bonnes
+ * Copyright 1999-2000 Jens Wiessner
+ *
+ * CRTDLL - multibyte functions
+ *
+ */
+
+#include <odin.h>
+#include <os2win.h>
+#include <ctype.h>
+#include <heapstring.h>
+#include <string.h>
+
+#define MB_LEN_MAX	2
+
+
+/*********************************************************************
+ *                  _mbscat       (CRTDLL.195)
+ */
+unsigned char * CDECL CRTDLL__mbscat( unsigned char *dst, const unsigned char *src )
+{
+  dprintf2(("CRTDLL: _mbscat\n"));
+  return (unsigned char*)strcat((char*)dst,(char*)src);
+}
+
+
+/*********************************************************************
+ *                  _mbschr       (CRTDLL.196)
+ */
+unsigned char * CDECL CRTDLL__mbschr( const unsigned char *str, unsigned int c )
+{
+  dprintf2(("CRTDLL: _mbschr\n"));
+  return (unsigned char*)strchr((char*)str,c);
+}
+
+
+/*********************************************************************
+ *                  _mbscmp       (CRTDLL.197)
+ */
+int CDECL CRTDLL__mbscmp( const unsigned char *s1, const unsigned char *s2 )
+{
+  dprintf2(("CRTDLL: _mbscmp\n"));
+  return strcmp((char*)s1,(char*)s2);
+}
+
+
+/*********************************************************************
+ *                  _mbscpy       (CRTDLL.198)
+ */
+unsigned char * CDECL CRTDLL__mbscpy( unsigned char *s1, const unsigned char *s2 )
+{
+  dprintf2(("CRTDLL: _mbscpy\n"));
+  return (unsigned char*)strcpy((char*)s1,(char*)s2);
+}
+
+
+/*********************************************************************
+ *           _mbsdup    (CRTDLL.201)
+ */
+unsigned char * CDECL CRTDLL__mbsdup( unsigned char *s1 )
+{
+  dprintf2(("CRTDLL: _mbsdup\n"));
+  return (unsigned char*)strdup((const char*)s1);
+}
+
+
+/*********************************************************************
+ *           CRTDLL__mbsicmp   (CRTDLL.202)
+ */
+int CDECL CRTDLL__mbsicmp( const unsigned char *x, const unsigned char *y )
+{
+  dprintf2(("CRTDLL: _mbsicmp\n"));
+    do {
+	if (!*x)
+	    return !!*y;
+	if (!*y)
+	    return !!*x;
+	/* FIXME: MBCS handling... */
+	if (*x!=*y)
+	    return 1;
+        x++;
+        y++;
+    } while (1);
+}
+
+
+/*********************************************************************
+ *           _mbsinc    (CRTDLL.203)
+ */
+LPSTR CDECL CRTDLL__mbsinc( LPCSTR str )
+{
+    dprintf2(("CRTDLL: _mbsinc\n"));
+    int len = mblen( str, MB_LEN_MAX );
+    if (len < 1) len = 1;
+    return (LPSTR)(str + len);
+}
+
+
+/*********************************************************************
+ *           _mbslen    (CRTDLL.204)
+ */
+INT CDECL CRTDLL__mbslen( LPCSTR str )
+{
+    dprintf2(("CRTDLL: _mbslen\n"));
+    INT len, total = 0;
+    while ((len = mblen( str, MB_LEN_MAX )) > 0)
+    {
+        str += len;
+        total++;
+    }
+    return total;
+}
+
+
+/*********************************************************************
+ *           _mbsrchr   (CRTDLL.221)
+ */
+LPSTR CDECL CRTDLL__mbsrchr(LPSTR s,CHAR x)
+{
+  dprintf2(("CRTDLL: _mbsrchr\n"));
+	/* FIXME: handle multibyte strings */
+	return strrchr(s,x);
+}
+
+
+/*********************************************************************
+ *           _mbsstr    (CRTDLL.226)
+ */
+unsigned char * CDECL CRTDLL__mbsstr( const unsigned char *s1, const unsigned char *s2 )
+{
+  dprintf2(("CRTDLL: _mbsstr\n"));
+  return (unsigned char*)strstr((const char*)s1,(const char*)s2);
+}
+
+
+/*********************************************************************
+ *	mblen					(CRTDLL.425)
+ */
+INT CDECL CRTDLL_mblen( const char *s, size_t n )
+{
+      dprintf2(("CRTDLL: mblen\n"));
+      return (mblen(s, n));
+}
+
+
+/*********************************************************************
+ *	mbstowcs				(CRTDLL.426)
+ */
+size_t CDECL CRTDLL_mbstowcs( wchar_t *pwcs, const char *s, size_t n )
+{
+      dprintf2(("CRTDLL: mbstowcs(%08xh, %08xh, %08xh)\n", pwcs, s, n));
+      return (mbstowcs(pwcs, s, n));
+}
+
+
+/*********************************************************************
+ *	mbtowc					(CRTDLL.427)
+ */
+INT CDECL CRTDLL_mbtowc( WCHAR *dst, LPCSTR str, INT n )
+{
+    dprintf2(("CRTDLL: mbtowc\n"));
+    wchar_t res;
+    int ret = mbtowc( &res, str, n );
+    if (dst) *dst = (WCHAR)res;
+    return ret;
+}
+
+
+
Index: trunk/src/crtdll/crt_memory.cpp
===================================================================
--- trunk/src/crtdll/crt_memory.cpp	(revision 2618)
+++ trunk/src/crtdll/crt_memory.cpp	(revision 2618)
@@ -0,0 +1,111 @@
+/* $Id: crt_memory.cpp,v 1.1 2000-02-03 21:37:48 sandervl Exp $ */
+
+/*
+ * The C RunTime DLL
+ * 
+ * Implements C run-time functionality as known from UNIX.
+ *
+ * Partialy based on Wine
+ *
+ * Copyright 1996,1998 Marcus Meissner
+ * Copyright 1996 Jukka Iivonen
+ * Copyright 1997 Uwe Bonnes
+ * Copyright 1999-2000 Jens Wiessner
+ *
+ * CRTDLL - memory functions
+ *
+ */
+
+#include <odin.h>
+#include <os2win.h>
+#include <ctype.h>
+#include <memory.h>
+
+
+/*********************************************************************
+ *	_memccpy				(CRTDLL.230)
+ */
+void * CDECL CRTDLL__memccpy (void *s1, const void *s2, int c, size_t n)
+{
+  dprintf2(("CRTDLL: _memccpy\n"));
+  size_t i;
+  
+  for (i = 0; i < n; ++i)
+    {
+      if ((((char *)s1)[i] = ((char *)s2)[i]) == (char)c)
+        return (char *)s1+i+1;
+    }
+  return NULL;
+}
+
+
+/*********************************************************************
+ *	_memicmp				(CRTDLL.231)
+ */
+INT CDECL CRTDLL__memicmp(
+	LPCSTR s1,	/* [in] first string */
+	LPCSTR s2,	/* [in] second string */
+	DWORD len	/* [in] length to compare */ )
+{
+	dprintf2(("CRTDLL: _memicmp(%08xh, %08xh, %08xh)\n",s1,s2,len));
+	int	i;
+
+	for (i=0;i<len;i++) {
+		if (tolower(s1[i])<tolower(s2[i]))
+			return -1;
+		if (tolower(s1[i])>tolower(s2[i]))
+			return  1;
+	}
+	return 0;
+}
+
+
+
+/*********************************************************************
+ *	memchr				(CRTDLL.428)
+ */
+void * CDECL CRTDLL_memchr( const void *s, int c, size_t n )
+{
+    dprintf2(("CRTDLL: memchr(%08xh, %08xh, %08xh)\n", s, c, n));
+    return memchr( s, c, n );
+}
+
+
+/*********************************************************************
+ *	memcmp				(CRTDLL.429)
+ */
+int CDECL CRTDLL_memcmp( const void * c1, const void * c2, size_t n )
+{
+    dprintf2(("CRTDLL: memcmp(%08xh, %08xh, %08xh)\n", c1, c2, n));
+    return memcmp( c1, c2, n );
+}
+
+
+/*********************************************************************
+ *	memcpy				(CRTDLL.430)
+ */
+void * CDECL CRTDLL_memcpy( void *s1, const void *s2, size_t n )
+{
+    dprintf2(("CRTDLL: memcpy(%08xh, %08xh, %08xh)\n", s1, s2, n));
+    return memcpy( s1, s2, n );
+}
+
+
+/*********************************************************************
+ *	memmove				(CRTDLL.431)
+ */
+VOID CDECL CRTDLL_memmove(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, DWORD Length)
+{
+  dprintf2(("CRTDLL: memmove"));
+  memmove(Destination, Source, Length);
+}
+
+
+/*********************************************************************
+ *	memset				(CRTDLL.432)
+ */
+void * CDECL CRTDLL_memset( void *s, int i, size_t n )
+{
+    dprintf2(("CRTDLL: memset(%08xh, %08xh, %08xh)\n", s, i, n));
+    return memset( s, i, n );
+}
Index: trunk/src/crtdll/crt_string.cpp
===================================================================
--- trunk/src/crtdll/crt_string.cpp	(revision 2618)
+++ trunk/src/crtdll/crt_string.cpp	(revision 2618)
@@ -0,0 +1,521 @@
+/* $Id: crt_string.cpp,v 1.1 2000-02-03 21:37:48 sandervl Exp $ */
+
+/*
+ * The C RunTime DLL
+ * 
+ * Implements C run-time functionality as known from UNIX.
+ *
+ * Partialy based on Wine
+ *
+ * Copyright 1996,1998 Marcus Meissner
+ * Copyright 1996 Jukka Iivonen
+ * Copyright 1997 Uwe Bonnes
+ * Copyright 1999-2000 Jens Wiessner
+ *
+ * CRTDLL - string functions
+ *
+ */
+
+#include <odin.h>
+#include <os2win.h>
+#include <ctype.h>
+#include <heapstring.h>
+#include <string.h>
+
+
+/*********************************************************************
+ *           _strcmpi   	 (CRTDLL.280)
+ */
+void CDECL CRTDLL__strcmpi( LPCSTR s1, LPCSTR s2 )
+{
+  dprintf2(("CRTDLL: _strcmpi(%08xh, %08xh)\n",
+           s1,
+           s2));
+
+  lstrcmpiA( s1, s2 );
+}
+
+
+/*********************************************************************
+ *           CRTDLL__strdate   	 (CRTDLL.281)
+ */
+char * CDECL CRTDLL__strdate( char *buf )
+{
+  dprintf2(("CRTDLL: _strdate\n"));
+  return(_strdate(buf));
+}
+
+
+/*********************************************************************
+ *           CRTDLL__strdec    	 (CRTDLL.282)
+ */
+char * CDECL CRTDLL__strdec( const char *, const char *p ) 
+{
+  dprintf2(("CRTDLL: _strdec\n"));
+  return( (char *)(p-1) );
+}
+
+
+/*********************************************************************
+ *           CRTDLL__strdup    	 (CRTDLL.283)
+ */
+LPSTR CDECL CRTDLL__strdup(LPCSTR ptr)
+{
+  dprintf2(("CRTDLL: _strdup\n"));
+  return HEAP_strdupA(GetProcessHeap(),0,ptr);
+}
+
+
+/*********************************************************************
+ *           _stricmp  	 (CRTDLL.285)
+ */
+int CDECL CRTDLL__stricmp(const LPSTR str1,
+                      const LPSTR str2)
+{
+  dprintf2(("CRTDLL: _stricmp(%s,%s)\n",
+           str1,
+           str2));
+
+  return (stricmp(str1, str2));
+}
+
+
+
+/*********************************************************************
+ *           CRTDLL__stricoll  	 (CRTDLL.286)
+ */
+int CDECL CRTDLL__stricoll( const char *s1, const char *s2 )
+{
+  dprintf2(("CRTDLL: _stricoll\n"));
+  return stricmp(s1,s2);
+}
+
+
+/*********************************************************************
+ *           CRTDLL__strinc  	 (CRTDLL.287)
+ */
+char * CDECL CRTDLL__strinc( const char *p )
+{
+    dprintf2(("CRTDLL: _strinc\n"));
+    return( (char *)(p+1) );
+}
+
+
+/*********************************************************************
+ *           _strlwr  	 (CRTDLL.288)
+ */
+CHAR * CDECL CRTDLL__strlwr(char *x)
+{
+  char *y =x;
+
+  dprintf2(("CRTDLL: _strlwr got %s\n", x));
+  while (*y) {
+    if ((*y > 0x40) && (*y< 0x5b))
+      *y = *y + 0x20;
+    y++;
+  }
+  dprintf2(("   returned %s\n", x));
+		
+  return x;
+}
+
+
+/*********************************************************************
+ *           CRTDLL__strncnt	 (CRTDLL.289)
+ */
+size_t CDECL CRTDLL__strncnt( const char *p, size_t l ) 
+{
+    dprintf2(("CRTDLL: _strncnt\n"));
+    size_t i;
+    i = strlen(p);
+    return( (i>l) ? l : i );
+}
+
+/*********************************************************************
+ *           CRTDLL__strnextc	 (CRTDLL.290)
+ */
+unsigned int CDECL CRTDLL__strnextc( const char *p )
+{
+    dprintf2(("CRTDLL: _strnextc\n"));
+    return( (unsigned int)*p );
+}
+
+
+/*********************************************************************
+ *           CRTDLL__strnicmp	 (CRTDLL.291)
+ */
+int  CDECL CRTDLL__strnicmp( LPCSTR s1, LPCSTR s2, INT n )
+{
+  dprintf2(("CRTDLL: _strnicmp (%s,%s,%d)\n",
+           s1,
+           s2,
+           n));
+
+  // @@@PH: sure it's not a UNICODE API?
+  return (lstrncmpiA(s1,s2,n));
+}
+
+
+/*********************************************************************
+ *           CRTDLL__strninc	 (CRTDLL.292)
+ */
+char * CDECL CRTDLL__strninc( const char *p, size_t l )
+{
+    dprintf2(("CRTDLL: _strninc\n"));
+    return( (char *)(p+l) );
+}
+
+
+/*********************************************************************
+ *           CRTDLL__strnset	 (CRTDLL.293)
+ */
+char * CDECL CRTDLL__strnset(char *string, int c, size_t count)
+{
+  dprintf2(("CRTDLL: _strnset\n"));
+  char *dst;
+
+  dst = string;
+  while (count > 0 && *dst != 0)
+    {
+      *dst++ = (char)c;
+      --count;
+    }
+  return string;
+}
+
+
+/*********************************************************************
+ *           CRTDLL__strrev	 (CRTDLL.294)
+ */
+char * CDECL CRTDLL__strrev( char *string )
+{
+  dprintf2(("CRTDLL: _strrev\n"));
+  char *p, *q, c;
+
+  p = q = string;
+  while (*q != 0)
+    ++q;
+  --q;                                  /* Benign, as string must be != 0 */
+  while ((size_t)q > (size_t)p)
+    {
+      c = *p; *p = *q; *q = c;
+      ++p; --q;
+    }
+  return string;
+}
+
+
+/*********************************************************************
+ *           CRTDLL__strset	 (CRTDLL.295)
+ */
+char * CDECL CRTDLL__strset(char *string, int c)
+{
+  dprintf2(("CRTDLL: _strset\n"));
+  char *dst;
+
+  dst = string;
+  while (*dst != 0)
+    *dst++ = (char)c;
+  return string;
+}
+
+
+/*********************************************************************
+ *           CRTDLL__strspnp	 (CRTDLL.296)
+ */
+char * CDECL CRTDLL__strspnp( const char *p1, const char *p2 ) 
+{
+    dprintf2(("CRTDLL: _strspnp\n"));
+    return( (*(p1 += strspn(p1,p2))!='\0') ? (char*)p1 : NULL );
+}
+
+
+/*********************************************************************
+ *           CRTDLL__strtime	 (CRTDLL.297)
+ */
+char * CDECL CRTDLL__strtime( char *buf )
+{
+  dprintf2(("CRTDLL: _strtime\n"));
+  return (_strtime(buf));
+}
+
+
+/*********************************************************************
+ *           _strupr 	 (CRTDLL.298)
+ */
+LPSTR CDECL CRTDLL__strupr(LPSTR x)
+{
+  dprintf2(("CRTDLL: _strupr(%s)\n",
+           x));
+
+  LPSTR y=x;
+
+  while (*y)
+  {
+    *y=toupper(*y);
+    y++;
+  }
+  return x;
+}
+
+
+/*********************************************************************
+ *                  strcat         (CRTDLL.459)
+ */
+LPSTR CDECL CRTDLL_strcat(      LPSTR str1,
+                      const LPSTR str2)
+{
+  dprintf2(("CRTDLL: strcat\n"));
+
+  return (strcat(str1, str2));
+}
+
+
+/*********************************************************************
+ *                  strchr         (CRTDLL.460)
+ */
+LPSTR CDECL CRTDLL_strchr(const LPSTR str,
+                       int         i)
+{
+  dprintf2(("CRTDLL: strchr(%s,%08xh)\n",
+           str,
+           i));
+
+  return (strchr(str, i));
+}
+
+
+/*********************************************************************
+ *                  strcmp         (CRTDLL.461)
+ */
+int CDECL CRTDLL_strcmp(const LPSTR str1,
+                      const LPSTR str2)
+{
+  dprintf2(("CRTDLL: strcmp(%s,%s)\n",
+           str1,
+           str2));
+
+  return (strcmp(str1, str2));
+}
+
+
+/*********************************************************************
+ *                  strcoll        (CRTDLL.462)
+ */
+int CDECL CRTDLL_strcoll( const char *s1, const char *s2 )
+{
+  dprintf2(("CRTDLL: strcoll\n"));
+  return strcoll(s1, s2);
+}
+
+
+/*********************************************************************
+ *                  strcpy         (CRTDLL.463)
+ */
+LPSTR CDECL CRTDLL_strcpy(      LPSTR str1,
+                       const LPSTR str2)
+{
+  dprintf2(("CRTDLL: strcpy\n"));
+
+  return (strcpy(str1, str2));
+}
+
+
+/*********************************************************************
+ *                  strcspn         (CRTDLL.464)
+ */
+size_t CDECL CRTDLL_strcspn(const LPSTR str1,
+                                LPSTR str2)
+{
+  dprintf2(("CRTDLL: strcspn(%s,%s)\n",
+           str1,
+           str2));
+
+  return (strcspn(str1, str2));
+}
+
+
+/*********************************************************************
+ *                  strerror        (CRTDLL.465)
+ */
+char * CDECL CRTDLL_strerror( int errnum )
+{
+  dprintf2(("CRTDLL: strerror\n"));
+  return strerror(errnum);
+}
+
+
+/*********************************************************************
+ *                  strftime        (CRTDLL.466)
+ */
+size_t CDECL CRTDLL_strftime( char *s, size_t maxsiz, const char *fmt, const struct tm *tp )
+{
+  dprintf2(("CRTDLL: strftime\n"));
+  return strftime(s, maxsiz, fmt, tp);
+}
+
+
+/*********************************************************************
+ *                  strlen          (CRTDLL.467)
+ */
+size_t CDECL CRTDLL_strlen(const LPSTR str)
+{
+  dprintf2(("CRTDLL: strlen(%s)\n",
+           str));
+
+  return (strlen(str));
+}
+
+
+/*********************************************************************
+ *                  strncat        (CRTDLL.468)
+ */
+LPSTR CDECL CRTDLL_strncat(      LPSTR str1,
+                        const LPSTR str2,
+                        size_t      i)
+{
+  dprintf2(("CRTDLL: strncat(%s,%s,%08xh)\n",
+           str1,
+           str2,
+           i));
+
+  return (strncat(str1, str2, i));
+}
+
+
+/*********************************************************************
+ *                  strncmp        (CRTDLL.469)
+ */
+int CDECL CRTDLL_strncmp(const LPSTR str1,
+                       const LPSTR str2,
+                       size_t      i)
+{
+  dprintf2(("CRTDLL: strncmp(%s,%s,%08xh)\n",
+           str1,
+           str2,
+           i));
+
+  return (strncmp(str1, str2, i));
+}
+
+
+/*********************************************************************
+ *                  strncpy        (CRTDLL.470)
+ */
+LPSTR CDECL CRTDLL_strncpy(const LPSTR str1,
+                        const LPSTR str2,
+                        size_t      i)
+{
+  dprintf2(("CRTDLL: strncpy(%s,%s,%08xh)\n",
+           str1,
+           str2,
+           i));
+
+  return (strncpy(str1, str2, i));
+}
+
+
+/*********************************************************************
+ *                  strpbrk        (CRTDLL.471)
+ */
+LPSTR CDECL CRTDLL_strpbrk(const LPSTR str1,
+                      const LPSTR str2)
+{
+  dprintf2(("CRTDLL: strpbrk(%s,%s)\n",
+           str1,
+           str2));
+
+  return (strpbrk(str1, str2));
+}
+
+
+/*********************************************************************
+ *                  strrchr        (CRTDLL.472)
+ */
+LPSTR CDECL CRTDLL_strrchr(const LPSTR str,
+                        size_t      i)
+{
+  dprintf2(("CRTDLL: strrchr(%s,%08xh)\n",
+           str,
+           i));
+
+  return (strrchr(str, i));
+}
+
+
+/*********************************************************************
+ *                  strspn        (CRTDLL.473)
+ */
+size_t CDECL CRTDLL_strspn(const LPSTR str1,
+                       const LPSTR str2)
+{
+  dprintf2(("CRTDLL: strspn(%s,%s)\n",
+           str1,
+           str2));
+
+  return (strspn(str1, str2));
+}
+
+
+/*********************************************************************
+ *                  strstr        (CRTDLL.474)
+ */
+LPSTR CDECL CRTDLL_strstr(const LPSTR str1,
+                       const LPSTR str2)
+{
+  dprintf2(("CRTDLL: strstr(%s,%s)\n",
+           str1,
+           str2));
+
+  return (strstr(str1, str2));
+}
+ 
+
+/*********************************************************************
+ *                  strtod        (CRTDLL.475)
+ */
+double CDECL CRTDLL_strtod( const char *nptr, char **endptr )
+{
+  dprintf2(("CRTDLL: strtod\n"));
+  return strtod(nptr, endptr);
+}
+
+
+/*********************************************************************
+ *                  strtok        (CRTDLL.476)
+ */
+char * CDECL CRTDLL_strtok( char *s1, const char *s2 )
+{
+  dprintf2(("CRTDLL: strtok\n"));
+  return strtok(s1, s2);
+}
+
+
+/*********************************************************************
+ *                  strtol        (CRTDLL.477)
+ */
+long int CDECL CRTDLL_strtol( const char *nptr, char **endptr, int base )
+{
+  dprintf2(("CRTDLL: strtol\n"));
+  return strtol(nptr, endptr, base);
+}
+
+
+/*********************************************************************
+ *                  strtoul        (CRTDLL.478)
+ */
+unsigned long CDECL CRTDLL_strtoul( const char *nptr, char **endptr, int base )
+{
+  dprintf2(("CRTDLL: strtoul\n"));
+  return strtoul(nptr, endptr, base);
+}
+
+
+/*********************************************************************
+ *                  strxfrm        (CRTDLL.479)
+ */
+size_t CDECL CRTDLL_strxfrm( char *s1, const char *s2, size_t n )
+{
+  dprintf2(("CRTDLL: strxfrm\n"));
+  return strxfrm(s1, s2, n);
+}
Index: trunk/src/crtdll/crt_wc.cpp
===================================================================
--- trunk/src/crtdll/crt_wc.cpp	(revision 2618)
+++ trunk/src/crtdll/crt_wc.cpp	(revision 2618)
@@ -0,0 +1,690 @@
+/* $Id: crt_wc.cpp,v 1.1 2000-02-03 21:37:48 sandervl Exp $ */
+
+/*
+ * The C RunTime DLL
+ * 
+ * Implements C run-time functionality as known from UNIX.
+ *
+ * Partialy based on Wine
+ *
+ * Copyright 1996,1998 Marcus Meissner
+ * Copyright 1996 Jukka Iivonen
+ * Copyright 1997 Uwe Bonnes
+ * Copyright 1999-2000 Jens Wiessner
+ *
+ * CRTDLL - widechar functions
+ *
+ */
+
+#include <odin.h>
+#include <os2win.h>
+#include <wchar.h>
+#include <wctype.h>
+#include <heapstring.h>
+#include <string.h>
+#include "crtimps.h"
+
+
+/*********************************************************************
+ *           _fgetwchar  (CRTDLL.93)
+ */
+wint_t CDECL CRTDLL__fgetwchar( void *i )
+{
+  // TODO: Check if really ok.
+  dprintf2(("CRTDLL: _fgetwchar -> _getch\n"));
+  return CRTDLL__getch();
+}
+
+
+/*********************************************************************
+ *           CRTDLL__wcsdup	 (CRTDLL.317)
+ */
+LPWSTR CDECL CRTDLL__wcsdup( LPCWSTR str )
+{
+  dprintf2(("CRTDLL: _wcsdup\n"));
+  LPWSTR ret = NULL;
+  if (str)
+  {
+      int size = (wcslen((const wchar_t*)str) + 1) * sizeof(WCHAR);
+      ret = (WCHAR*)CRTDLL_malloc( size );
+      if (ret) memcpy( ret, str, size );
+  }
+  return ret;
+}
+
+
+/*********************************************************************
+ *           CRTDLL__wcsicmp	 (CRTDLL.318)
+ */
+int CDECL CRTDLL__wcsicmp(LPWSTR str1, LPWSTR str2)
+{
+  dprintf2(("CRTDLL: _wcsicmp(%08xh,%08xh)\n",
+           str1,
+           str2));
+
+  return (CRTDLL__wcsnicmp(str1,
+                       str2,
+                       wcslen((wchar_t*) str1)));
+}
+
+
+/*********************************************************************
+ *           CRTDLL__wcsicoll	 (CRTDLL.319)
+ */
+int CDECL CRTDLL__wcsicoll( LPCWSTR str1, LPCWSTR str2 )
+{
+  dprintf2(("CRTDLL: _wcsicoll\n"));
+  return CRTDLL__wcsicmp( (LPWSTR)str1, (LPWSTR)str2 );
+}
+
+
+/*********************************************************************
+ *           CRTDLL__wcslwr	 (CRTDLL.320)
+ */
+LPWSTR CDECL CRTDLL__wcslwr(LPWSTR str)
+{
+  DWORD dwIndex;
+
+  dprintf2(("CRTDLL: _wcslwr(%08xh)\n",
+           str));
+
+  for (dwIndex = wcslen((const wchar_t*)str);
+       dwIndex;
+       dwIndex--)
+  {
+    towlower(str[dwIndex]);
+  }
+
+  return (str);
+}
+
+
+/*********************************************************************
+ *           CRTDLL__wcsnicmp	 (CRTDLL.321)
+ */
+int CDECL CRTDLL__wcsnicmp(LPCWSTR str1, LPCWSTR str2, int n)
+{
+  dprintf2(("CRTDLL: _wcsnicmp(%08xh,%08xh,%08xh)\n",
+           str1,
+           str2,
+           l));
+
+    if (!n) return 0;
+    while ((--n > 0) && *str1 && (towupper(*str1) == towupper(*str2)))
+    {
+        str1++;
+        str2++;
+    }
+    return towupper(*str1) - towupper(*str2);
+}
+
+
+/*********************************************************************
+ *           CRTDLL__wcsnset    (CRTDLL.322)
+ */
+LPWSTR CDECL CRTDLL__wcsnset( LPWSTR str, WCHAR c, INT n )
+{
+    dprintf2(("CRTDLL: _wcsnset\n"));
+    LPWSTR ret = str;
+    while ((n-- > 0) && *str) *str++ = c;
+    return ret;
+}
+
+
+/*********************************************************************
+ *           CRTDLL__wcsrev	 (CRTDLL.323)
+ */
+LPWSTR CDECL CRTDLL__wcsrev( LPWSTR str )
+{
+  dprintf2(("CRTDLL: _wcsrev\n"));
+  LPWSTR ret = str;
+  LPWSTR end = str + wcslen((const wchar_t*)str) - 1;
+  while (end > str)
+  {
+      WCHAR t = *end;
+      *end--  = *str;
+      *str++  = t;
+  }
+  return ret;
+}
+
+
+/*********************************************************************
+ *           CRTDLL__wcsset    (CRTDLL.324)
+ */
+LPWSTR CDECL CRTDLL__wcsset( LPWSTR str, WCHAR c )
+{
+    dprintf2(("CRTDLL: _wcsset\n"));
+    LPWSTR ret = str;
+    while (*str) *str++ = c;
+    return ret;
+}
+
+
+/*********************************************************************
+ *           CRTDLL__wcsupr    (CRTDLL.325)
+ */
+LPWSTR CDECL CRTDLL__wcsupr(LPWSTR str)
+{
+  DWORD dwIndex;
+
+  dprintf2(("CRTDLL: _wcsupr(%08xh)\n",
+           str));
+
+  for (dwIndex = wcslen((const wchar_t*)str);
+       dwIndex;
+       dwIndex--)
+  {
+    towupper(str[dwIndex]);
+  }
+
+  return (str);
+}
+
+
+/*********************************************************************
+ *                  fgetwc	(CRTDLL.366)
+ */
+wint_t CDECL CRTDLL_fgetwc( FILE *f )
+{
+  dprintf2(("CRTDLL: fgetwc\n"));
+  return (fgetwc(f));
+}
+
+
+/*********************************************************************
+ *                  fputwc  (CRTDLL.373)
+ */
+wint_t CDECL CRTDLL_fputwc( wint_t wc, FILE *strm )
+{
+  dprintf2(("CRTDLL: fputwc\n"));
+  return (fputwc(wc, strm));
+}
+
+
+/*********************************************************************
+ *                  iswalnum    (CRTDLL.402)
+ */
+int CDECL CRTDLL_iswalnum(wint_t i)
+{
+  dprintf2(("CRTDLL: iswalnum(%08xh)\n", i));
+  return (iswalnum(i));
+}
+
+
+/*********************************************************************
+ *                  iswalpha    (CRTDLL.403)
+ */
+int CDECL CRTDLL_iswalpha(wint_t i)
+{
+  dprintf2(("CRTDLL: iswalpha(%08xh)\n", i));
+  return (iswalpha(i));
+}
+
+
+/*********************************************************************
+ *                  iswascii    (CRTDLL.404)
+ */
+int CDECL CRTDLL_iswascii(wint_t c)
+{
+  dprintf2(("CRTDLL: iswascii\n", c));
+  return  (!((c)&(~0x7f)));
+}
+
+
+/*********************************************************************
+ *                  iswcntrl    (CRTDLL.405)
+ */
+int CDECL CRTDLL_iswcntrl(wint_t i)
+{
+  dprintf2(("CRTDLL: iswcntrl(%08xh)\n", i));
+  return (iswcntrl(i));
+}
+
+
+/*********************************************************************
+ *                  iswctype    (CRTDLL.406)
+ */
+int CDECL CRTDLL_iswctype(wint_t i, wctype_t wct)
+{
+  dprintf2(("CRTDLL: iswctype(%08xh, %08xh)\n", i, wct));
+  return (iswctype(i, wct));
+}
+
+
+/*********************************************************************
+ *                  iswdigit    (CRTDLL.407)
+ */
+int CDECL CRTDLL_iswdigit(wint_t i)
+{
+  dprintf2(("CRTDLL: iswdigit(%08xh)\n", i));
+  return (iswdigit(i));
+}
+
+
+/*********************************************************************
+ *                  iswgraph    (CRTDLL.408)
+ */
+int CDECL CRTDLL_iswgraph(wint_t i)
+{
+  dprintf2(("CRTDLL: iswgraph(%08xh)\n", i));
+  return (iswgraph(i));
+}
+
+
+/*********************************************************************
+ *                  iswlower    (CRTDLL.409)
+ */
+int CDECL CRTDLL_iswlower(wint_t i)
+{
+  dprintf2(("CRTDLL: iswlower(%08xh)\n", i));
+  return (iswlower(i));
+}
+
+
+/*********************************************************************
+ *                  iswprint    (CRTDLL.410)
+ */
+int CDECL CRTDLL_iswprint(wint_t i)
+{
+  dprintf2(("CRTDLL: iswprint(%08xh)\n", i));
+  return (iswprint(i));
+}
+
+
+/*********************************************************************
+ *                  iswpunct    (CRTDLL.411)
+ */
+int CDECL CRTDLL_iswpunct(wint_t i)
+{
+  dprintf2(("CRTDLL: iswpunct(%08xh)\n", i));
+  return (iswpunct(i));
+}
+
+
+/*********************************************************************
+ *                  iswspace    (CRTDLL.412)
+ */
+int CDECL CRTDLL_iswspace(wint_t i)
+{
+  dprintf2(("CRTDLL: iswspace(%08xh)\n", i));
+  return (iswspace(i));
+}
+
+
+/*********************************************************************
+ *                  iswupper    (CRTDLL.413)
+ */
+int CDECL CRTDLL_iswupper(wint_t i)
+{
+  dprintf2(("CRTDLL: iswupper(%08xh)\n", i));
+  return (iswupper(i));
+}
+
+
+/*********************************************************************
+ *                  iswxdigit    (CRTDLL.414)
+ */
+int CDECL CRTDLL_iswxdigit(wint_t i)
+{
+  dprintf2(("CRTDLL: iswxdigit(%08xh)\n", i));
+  return (iswxdigit(i));
+}
+
+
+/*********************************************************************
+ *                  swprintf         (CRTDLL.480)
+ */
+int CDECL CRTDLL_swprintf(const LPWSTR str,
+                      int   i,
+                      const LPWSTR format,
+                      ...)
+{
+  va_list valist;
+  int     rc;
+
+  dprintf2(("CRTDLL: swprintf(%s,%d,%s)\n",
+           str,
+           i,
+           format));
+
+  va_start( valist, format );
+  rc = vswprintf( (wchar_t*)str,
+                  i,
+                  (wchar_t*)format,
+                  valist );
+  va_end( valist );
+  return rc;
+}
+
+
+/*********************************************************************
+ *	swscanf				   	(CRTDLL.481)
+ */
+int CDECL CRTDLL_swscanf( const wchar_t *s1, const wchar_t *s2, va_list arg )
+{
+  dprintf(("CRTDLL: swscanf\n"));
+  return (swscanf(s1, s2, arg));
+}
+
+
+/*********************************************************************
+ *                  towlower       (CRTDLL.490)
+ */
+WCHAR CDECL CRTDLL_towlower(WCHAR c)
+{
+  dprintf2(("CRTDLL: towlower(%c)\n",
+           c));
+
+  return (towlower(c));
+}
+
+
+/*********************************************************************
+ *                  towupper       (CRTDLL.491)
+ */
+WCHAR CDECL CRTDLL_towupper(WCHAR c)
+{
+  dprintf2(("CRTDLL: towupper(%c)\n",
+           c));
+
+  return (towupper(c));
+}
+
+
+/*********************************************************************
+ *                  ungetwc           (CRTDLL.493)
+ */
+wint_t CDECL CRTDLL_ungetwc( wint_t wc, FILE *strm )
+{
+  dprintf2(("CRTDLL: ungetwc\n"));
+  return (ungetwc(wc, strm));
+}
+
+
+/*********************************************************************
+ *                  vswprintf       (CRTDLL.498)
+ */
+int CDECL CRTDLL_vswprintf( wchar_t *s , size_t t, const wchar_t *format, va_list arg )
+{
+  dprintf2(("CRTDLL: vswprintf\n"));
+  return (vswprintf(s, t, format, arg));
+}
+
+
+/*********************************************************************
+ *                  wcscat            (CRTDLL.500)
+ */
+wchar_t* CDECL CRTDLL_wcscat(      wchar_t* str1,
+                       const wchar_t* str2)
+{
+  dprintf2(("CRTDLL: wcscat(%08xh,%08xh)\n",
+           str1,
+           str2));
+
+  return (wcscat(str1, str2));
+}
+
+
+/*********************************************************************
+ *                  wcschr            (CRTDLL.501)
+ */
+wchar_t* CDECL CRTDLL_wcschr(const wchar_t* str,
+                       int          i)
+{
+  dprintf2(("CRTDLL: wcschr(%08xh,%08xh)\n",
+           str,
+           i));
+
+  return (wcschr(str, i));
+}
+
+
+/*********************************************************************
+ *                  wcscmp            (CRTDLL.502)
+ */
+int CDECL CRTDLL_wcscmp(const wchar_t* str1,
+                    const wchar_t* str2)
+{
+  dprintf2(("CRTDLL: wcscmp(%08xh,%08xh)\n",
+           str1,
+           str2));
+
+  return (wcscmp(str1, str2));
+}
+
+
+/*********************************************************************
+ *                  wcscoll    (CRTDLL.503)
+ */
+DWORD CDECL CRTDLL_wcscoll(LPCWSTR str1, LPCWSTR str2)
+{
+  dprintf2(("CRTDLL: wcscoll\n"));
+  return (wcscoll((const wchar_t*)str1, (const wchar_t*)str2));
+}
+
+
+/*********************************************************************
+ *                  wcscpy            (CRTDLL.504)
+ */
+wchar_t* CDECL CRTDLL_wcscpy(      wchar_t* str1,
+                       const wchar_t* str2)
+{
+  dprintf2(("CRTDLL: wcscpy(%08xh,%08xh)\n",
+           str1,
+           str2));
+
+  return (wcscpy(str1, str2));
+}
+
+
+/*********************************************************************
+ *                  wcscspn            (CRTDLL.505)
+ */
+size_t CDECL CRTDLL_wcscspn(const wchar_t* str1,
+                              wchar_t* str2)
+{
+  dprintf2(("CRTDLL: wcscspn(%08xh,%08xh)\n",
+           str1,
+           str2));
+
+  return (wcscspn(str1, str2));
+}
+
+
+/*********************************************************************
+ *                  wcsftime   (CRTDLL.506)
+ */
+size_t CDECL CRTDLL_wcsftime( wchar_t *s, size_t maxsize, 
+		const wchar_t *format, const struct tm *timeptr )
+{
+  dprintf2(("CRTDLL: wcsftime\n"));
+  return (wcsftime(s, maxsize, format, timeptr));
+}
+
+
+/*********************************************************************
+ *                  wcslen            (CRTDLL.507)
+ */
+size_t CDECL CRTDLL_wcslen(const wchar_t* str)
+{
+  dprintf2(("CRTDLL: wcslen(%08xh)\n",
+           str));
+
+  return (wcslen(str));
+}
+
+
+/*********************************************************************
+ *                  wcsncat            (CRTDLL.508)
+ */
+wchar_t* CDECL CRTDLL_wcsncat(      wchar_t* str1,
+                        const wchar_t* str2,
+                        size_t      i)
+{
+  dprintf2(("CRTDLL: wcsncat(%08xh,%08xh,%08xh)\n",
+           str1,
+           str2,
+           i));
+
+  return (wcsncat(str1, str2, i));
+}
+
+
+
+/*********************************************************************
+ *                  wcsncmp            (CRTDLL.509)
+ */
+int CDECL CRTDLL_wcsncmp(const wchar_t* str1,
+                     const wchar_t* str2,
+                     size_t      i)
+{
+  dprintf2(("CRTDLL: wcsncmp(%08xh,%08xh,%08xh)\n",
+           str1,
+           str2,
+           i));
+
+  return (wcsncmp(str1, str2, i));
+}
+
+
+/*********************************************************************
+ *                  wcsncmp            (CRTDLL.510)
+ */
+wchar_t* CDECL CRTDLL_wcsncpy(      wchar_t* str1,
+                          const wchar_t* str2,
+                          size_t       i)
+{
+  dprintf2(("CRTDLL: wcsncpy(%s,%s,%08xh)\n",
+           str1,
+           str2,
+           i));
+
+  return (wcsncpy(str1, str2, i));
+}
+
+
+/*********************************************************************
+ *                  wcspbrk            (CRTDLL.511)
+ */
+wchar_t* CDECL CRTDLL_wcspbrk(const wchar_t* str1,
+                        const wchar_t* str2)
+{
+  dprintf2(("CRTDLL: wcspbrk(%08xh,%08xh)\n",
+           str1,
+           str2));
+
+  return (wcspbrk(str1, str2));
+}
+
+
+/*********************************************************************
+ *                  wcsrchr            (CRTDLL.512)
+ */
+wchar_t* CDECL CRTDLL_wcsrchr(const wchar_t* str,
+                        size_t       i)
+{
+  dprintf2(("CRTDLL: wcsrchr(%08xh,%08xh)\n",
+           str,
+           i));
+
+  return (wcsrchr(str, i));
+}
+
+
+/*********************************************************************
+ *                  wcsspn             (CRTDLL.513)
+ */
+size_t CDECL CRTDLL_wcsspn(const wchar_t* str1,
+                       const wchar_t* str2)
+{
+  dprintf2(("CRTDLL: wcsspn(%08xh,%08xh)\n",
+           str1,
+           str2));
+
+  return (wcsspn(str1, str2));
+}
+
+
+/*********************************************************************
+ *                  wcsstr   (CRTDLL.514)
+ */
+wchar_t* CDECL CRTDLL_wcsstr(const wchar_t* str1,
+                         const wchar_t* str2)
+{
+  dprintf2(("CRTDLL: wcsstr(%s,%s)\n",
+           str1,
+           str2));
+
+  return (wcsstr(str1, str2));
+}
+
+
+/*********************************************************************
+ *                  wcstod   (CRTDLL.515)
+ */
+double CDECL CRTDLL_wcstod( const wchar_t *nptr, wchar_t **endptr )
+{
+  dprintf2(("CRTDLL: wcstod\n"));
+  return (wcstod(nptr, endptr));
+}
+
+
+/*********************************************************************
+ *                  wcstok   (CRTDLL.516)
+ */
+wchar_t * CDECL CRTDLL_wcstok( wchar_t *s1, const wchar_t *s2, wchar_t **ptr )
+{
+  dprintf2(("CRTDLL: wcstok(%08xh, %08xh, %08xh)\n",s1,s2,ptr));
+  return (wcstok(s1, s2, ptr));
+}
+
+
+/*********************************************************************
+ *                  wcstol   (CRTDLL.517)
+ */
+long int CDECL CRTDLL_wcstol( const wchar_t *s1, wchar_t **s2, int i )
+{
+  dprintf2(("CRTDLL: wcstol(%08xh, %08xh, %08xh)\n",s1,s2,i));
+  return (wcstol(s1, s2, i));
+}
+
+
+/*********************************************************************
+ *                  wcstombs   (CRTDLL.518)
+ */
+size_t CDECL CRTDLL_wcstombs( char *s, const wchar_t *pwcs, size_t n )
+{
+  dprintf2(("CRTDLL: wcstombs(%08xh, %08xh, %08xh)\n",s,pwcs,n));
+  return (wcstombs(s, pwcs, n));
+}
+
+
+/*********************************************************************
+ *                  wcstoul   (CRTDLL.519)
+ */
+unsigned long int CDECL CRTDLL_wcstoul( const wchar_t *s1, wchar_t **s2, int i )
+{
+  dprintf2(("CRTDLL: wcstoul(%08xh, %08xh, %08xh)\n",s1,s2,i));
+  return (wcstoul(s1, s2, i));
+}
+
+
+/*********************************************************************
+ *                  wcsxfrm   (CRTDLL.520)
+ */
+size_t CDECL CRTDLL_wcsxfrm( wchar_t *s1, const wchar_t *s2, size_t n )
+{
+  dprintf2(("CRTDLL: wcsxfrm\n"));
+  return (wcsxfrm(s1, s2, n));
+}
+
+
+/*********************************************************************
+ *                  wctomb   (CRTDLL.521)
+ */
+int CDECL CRTDLL_wctomb( LPSTR dst, WCHAR ch )
+{
+  dprintf2(("CRTDLL: wctomb\n"));
+  return (wctomb((char*)dst,ch));
+}
Index: trunk/src/crtdll/crtdll.cpp
===================================================================
--- trunk/src/crtdll/crtdll.cpp	(revision 2617)
+++ trunk/src/crtdll/crtdll.cpp	(revision 2618)
@@ -1,3 +1,3 @@
-/* $Id: crtdll.cpp,v 1.21 2000-01-08 14:24:04 sandervl Exp $ */
+/* $Id: crtdll.cpp,v 1.22 2000-02-03 21:37:48 sandervl Exp $ */
 
 /*
@@ -8,10 +8,10 @@
  * TODO: Check setjmp(3) 
  *
- * Partialy based on Wine and ReactOS
+ * Partialy based on Wine
  *
  * Copyright 1996,1998 Marcus Meissner
  * Copyright 1996 Jukka Iivonen
  * Copyright 1997 Uwe Bonnes
- * Copyright 1999 Jens Wiessner
+ * Copyright 1999-2000 Jens Wiessner
  */
 
@@ -29,6 +29,4 @@
 #include <debugtools.h>
 
-#include <wchar.h>
-#include <wctype.h>
 #include <math.h>
 #include <libc\locale.h>
@@ -48,14 +46,14 @@
 #include <sys\utime.h>
 #include <sys\stat.h>
+#include "signal.h"
 
 #include <crtdll.h>
+// #include <ieee.h>
+#include <asmhlp.h>
 #include "crtinc.h"
-#include "ieee.h"
+
 
 DEFAULT_DEBUG_CHANNEL(crtdll)
 
-//SvL: per process heap for CRTDLL
-HANDLE CRTDLL_hHeap = 0;
-
 
 /*********************************************************************
@@ -65,7 +63,7 @@
 {
 	if (fdwReason == DLL_PROCESS_ATTACH) {
-		CRTDLL__fdopen(0,"r");
-		CRTDLL__fdopen(1,"w");
-		CRTDLL__fdopen(2,"w");
+		_fdopen(0,"r");
+		_fdopen(1,"w");
+		_fdopen(2,"w");
 	     	CRTDLL_hHeap = HeapCreate(0, 0x10000, 0);
 	}
@@ -113,4 +111,202 @@
 }
 
+
+/*********************************************************************
+ *                  _CIacos    (CRTDLL.004)
+ */
+double CDECL CRTDLL__CIacos()
+{
+  double x;
+  dprintf2(("CRTDLL: _CIacos\n"));
+  POP_FPU(x);
+  return acos(x);
+}
+
+
+/*********************************************************************
+ *                  _CIasin    (CRTDLL.005)
+ */
+double CDECL CRTDLL__CIasin()
+{
+  double x;
+  dprintf2(("CRTDLL: _CIasin\n"));
+  POP_FPU(x);
+  return asin(x);
+}
+
+
+/*********************************************************************
+ *                  _CIatan    (CRTDLL.006)
+ */
+double CDECL CRTDLL__CIatan()
+{
+  double x;
+  dprintf2(("CRTDLL: _CIatan\n"));
+  POP_FPU(x);
+  return atan(x);
+}
+
+
+/*********************************************************************
+ *                  _CIatan2    (CRTDLL.007)
+ */
+double CDECL CRTDLL__CIatan2()
+{
+  double x, y;
+  dprintf2(("CRTDLL: _CIatan2\n"));
+  POP_FPU(y);
+  POP_FPU(x);
+  return atan2(x,y);
+}
+
+
+/*********************************************************************
+ *                  _CIcos    (CRTDLL.008)
+ */
+double CDECL CRTDLL__CIcos()
+{
+  double x;
+  dprintf2(("CRTDLL: _CIcos\n"));
+  POP_FPU(x);
+  return cos(x);
+}
+
+
+/*********************************************************************
+ *                  _CIcosh    (CRTDLL.009)
+ */
+double CDECL CRTDLL__CIcosh()
+{
+  double x;
+  dprintf2(("CRTDLL: _CIcosh\n"));
+  POP_FPU(x);
+  return cosh(x);
+}
+
+
+/*********************************************************************
+ *                  _CIexp    (CRTDLL.010)
+ */
+double CDECL CRTDLL__CIexp()
+{
+  double x;
+  dprintf2(("CRTDLL: _CIexp\n"));
+  POP_FPU(x);
+  return exp(x);
+}
+
+
+/*********************************************************************
+ *                  _CIfmod     (CRTDLL.011)
+ */
+double CDECL CRTDLL__CIfmod( )
+{
+  double x, y;
+  dprintf2(("CRTDLL: _CIfmod\n"));
+  POP_FPU(y);
+  POP_FPU(x);
+  return fmod(x,y);
+}
+
+
+/*********************************************************************
+ *                  _CIlog    (CRTDLL.012)
+ */
+double CDECL CRTDLL__CIlog()
+{
+  double x;
+  dprintf2(("CRTDLL: _CIlog\n"));
+  POP_FPU(x);
+  return log(x);
+}
+
+
+/*********************************************************************
+ *                  _CIlog10    (CRTDLL.013)
+ */
+double CDECL CRTDLL__CIlog10()
+{
+  double x;
+  dprintf2(("CRTDLL: _CIlog10\n"));
+  POP_FPU(x);
+  return log10(x);
+}
+
+
+/*********************************************************************
+ *                  _CIpow     (CRTDLL.014)
+ */
+LONG CDECL CRTDLL__CIpow()
+{
+  double x,y;
+  dprintf2(("CRTDLL: _CIpow\n"));
+  POP_FPU(y);
+  POP_FPU(x);
+  return pow(x,y);
+}
+
+
+
+
+/*********************************************************************
+ *                  _CIsin     (CRTDLL.015)
+ */
+double CDECL CRTDLL__CIsin()
+{
+  double x;
+  dprintf2(("CRTDLL: _CIsin\n"));
+  POP_FPU(x);
+  return sin(x);
+}
+
+
+/*********************************************************************
+ *                  _CIsinh    (CRTDLL.016)
+ */
+double CDECL CRTDLL__CIsinh()
+{
+  double x;
+  dprintf2(("CRTDLL: _CIsinh\n"));
+  POP_FPU(x);
+  return sinh(x);
+}
+
+
+/*********************************************************************
+ *                  _CIsqrt    (CRTDLL.017)
+ */
+double CDECL CRTDLL__CIsqrt()
+{
+  double x;
+  dprintf2(("CRTDLL: _CIsqrt\n"));
+  POP_FPU(x);
+  return sqrt(x);
+}
+
+
+/*********************************************************************
+ *                  _CItan    (CRTDLL.018)
+ */
+double CDECL CRTDLL__CItan()
+{
+  double x;
+  dprintf2(("CRTDLL: _CItan\n"));
+  POP_FPU(x);
+  return tan(x);
+}
+
+
+/*********************************************************************
+ *                  _CItanh    (CRTDLL.019)
+ */
+double CDECL CRTDLL__CItanh()
+{
+  double x;
+  dprintf2(("CRTDLL: _CItanh\n"));
+  POP_FPU(x);
+  return tanh(x);
+}
+
+
 /*********************************************************************
  *                  _XcptFilter    (CRTDLL.21)
@@ -121,4 +317,5 @@
   return UnhandledExceptionFilter(ExceptionInfo);
 }
+
 
 /*********************************************************************
@@ -189,32 +386,10 @@
 
 /*********************************************************************
- *                  __dllonexit           (CRTDLL.25)
- */
-VOID CDECL CRTDLL___dllonexit ()
-{	
-	dprintf(("__dllonexit not implemented.\n"));
-}
-
-
-/*********************************************************************
  *                  __doserrno            (CRTDLL.26)
  */
 int * CDECL CRTDLL___doserrno()
 {	
-	dprintf2(("__doserrno\n"));
-	_doserrno = GetLastError();
-	return &_doserrno;
-}
-
-
-/*********************************************************************
- *                  __fpecode            (CRTDLL.27)
- */
-int fpecode = 0;
-
-int * CDECL CRTDLL___fpecode ( void )
-{	
-	dprintf2(("__fpecode\n"));
-        return &fpecode;
+	dprintf2(("CRTDLL: __doserrno\n"));
+	return (__doserrno());
 }
 
@@ -225,6 +400,7 @@
 int CDECL CRTDLL___isascii(int i)
 {
-  dprintf2(("CRTDLL: __isascii\n"));
-  return  (!((i)&(~0x7f)));
+  //TODO: Check if really ok.
+  dprintf(("CRTDLL: __isascii -> _isascii\n"));
+  return (_isascii(i));
 }
 
@@ -235,6 +411,7 @@
 int CDECL CRTDLL___iscsym(int c)
 {
-  dprintf2(("CRTDLL: __iscsym\n"));
-  return (CRTDLL_isalnum(c) || ( c == '_' )) ;
+  //TODO: Check if really ok.
+  dprintf(("CRTDLL: __iscsym -> _iscsym\n"));
+  return (_iscsym(c));
 }
 
@@ -245,17 +422,7 @@
 int CDECL CRTDLL___iscsymf(int c)
 {
-  dprintf2(("CRTDLL: __iscsymf\n"));
-  return (isalpha(c) || ( c == '_' )) ;
-}
-
-
-/*********************************************************************
- *           CRTDLL___pxcptinfoptrs   (CRTDLL.32)
- */
-void ** CDECL CRTDLL___pxcptinfoptrs (void)
-{
-  dprintf(("CRTDLL: __pxcptinfoptrs not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return NULL;
+  //TODO: Check if really ok.
+  dprintf(("CRTDLL: __iscsymf -> _iscsymf\n"));
+  return (_iscsymf(c));
 }
 
@@ -282,15 +449,4 @@
 
 /*********************************************************************
- *           CRTDLL__abnormal_termination   (CRTDLL.36)
- */
-int CDECL CRTDLL__abnormal_termination(void)
-{
-  dprintf(("CRTDLL: _abnormal_termination  not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
-}
-
-
-/*********************************************************************
  *           CRTDLL__access   (CRTDLL.37)
  */
@@ -307,6 +463,7 @@
 int CDECL CRTDLL___toascii(int c)
 {
-  dprintf2(("CRTDLL: __toascii\n"));
-  return ((unsigned)(c) & 0x7F );
+  //TODO: Check if really ok.
+  dprintf(("CRTDLL: __toascii -> _toascii\n"));
+  return (_toascii(c));
 }
 
@@ -348,26 +505,65 @@
 void CDECL CRTDLL__beep(unsigned nFreq, unsigned nDur)
 {	
-	dprintf2(("_beep\n"));
-	Beep(nFreq,nDur);
-}
-
-
-/*********************************************************************
- *           CRTDLL__beginthread   (CRTDLL.46)
- */
-unsigned long CDECL CRTDLL__beginthread(void (*pfuncStart)(void *),
-		unsigned unStackSize, void* pArgList)
-{
-	DWORD  ThreadId;
- 	HANDLE hThread;
-	if (  pfuncStart == NULL )
-		__set_errno(EINVAL);
-
-	hThread = CreateThread( NULL,unStackSize,(LPTHREAD_START_ROUTINE)pfuncStart,pArgList,0, &ThreadId);
-	if (hThread == NULL ) {
-		__set_errno(EAGAIN);
-		return -1;
-	}
-	return (unsigned long)hThread;
+  dprintf2(("_beep\n"));
+  Beep(nFreq,nDur);
+}
+
+
+/*********************************************************************
+ *           _beginthread   (CRTDLL.46)
+ */
+int CDECL CRTDLL__beginthread (void (*start)(void *arg), void *stack, unsigned stack_size,
+                  void *arg_list)
+{
+  dprintf(("CRTDLL: _beginthread\n"));
+/*
+  ULONG rc;
+  TID tid;
+  struct _thread *tp;
+  tp = __alloc_thread ();
+  if (tp == NULL)
+    {
+      errno = ENOMEM;
+      return -1;
+    }
+  tp->_th_start = start;
+  tp->_th_arg = arg_list;
+  rc = DosCreateThread (&tid, (PFNTHREAD)start_thread, (ULONG)tp,
+                        3, stack_size);
+  if (rc != 0)
+    {
+      if (rc == ERROR_NOT_ENOUGH_MEMORY)
+        errno = ENOMEM;
+      else if (rc == ERROR_MAX_THRDS_REACHED)
+        errno = EAGAIN;
+      else
+        errno = EINVAL;
+      DosFreeMem (tp);
+      return -1;
+    }
+  if (tid > MAX_THREADS)
+    {
+      DosKillThread (tid);
+      errno = EAGAIN;
+      DosFreeMem (tp);
+      return -1;
+    }
+  if (__newthread (tid) != 0)
+    {
+      DosKillThread (tid);
+      DosFreeMem (tp);
+      return -1;
+    }
+  _thread_tab[tid] = tp;
+  rc = DosResumeThread (tid);
+  if (rc != 0)
+    {
+      errno = ESRCH;
+      DosFreeMem (tp);
+      return -1;
+    }
+  return tid;
+*/
+  return 0;
 }
 
@@ -385,10 +581,10 @@
 
 /*********************************************************************
- *           CRTDLL__cabs   (CRTDLL.48)
- */
-double CDECL CRTDLL__cabs(struct _complex z)
+ *           _cabs   (CRTDLL.48)
+ */
+double CDECL CRTDLL__cabs(struct complex z)
 {
   dprintf2(("CRTDLL: _cabs\n"));
-  return sqrt( z.x*z.x + z.y*z.y );
+  return (_cabs(z));
 }
 
@@ -399,6 +595,6 @@
 void CDECL CRTDLL__cexit(INT ret)
 {
-        dprintf2(("_cexit(%d)\n",ret));
-	ExitProcess(ret);
+  dprintf2(("_cexit(%d)\n",ret));
+  ExitProcess(ret);
 }
 
@@ -419,5 +615,5 @@
 INT CDECL CRTDLL__chdir(LPCSTR newdir)
 {
-	dprintf2(("CRTDLL: chdir\n"));
+	dprintf2(("CRTDLL: _chdir\n"));
 	if (!SetCurrentDirectoryA(newdir))
 		return 1;
@@ -441,20 +637,4 @@
 
 /*********************************************************************
- *           CRTDLL__chgsign	 (CRTDLL.53)
- */
-double CDECL CRTDLL__chgsign(double __x)
-{
-  dprintf2(("CRTDLL: _chgsign\n"));
-  double_t *x = (double_t *)&x;
-  if ( x->sign == 1 )
-	x->sign = 0;
-  else 
-	x->sign = 1;
-
-  return __x;
-}
-
-
-/*********************************************************************
  *           CRTDLL__chmod   (CRTDLL.54)
  */
@@ -497,18 +677,4 @@
 
 /*********************************************************************
- *                  CRTDLL__commit    (CRTDLL.58)
- */
-int CDECL CRTDLL__commit( int _fd )
-{
-  dprintf2(("CRTDLL: _commit\n"));
-  if (! FlushFileBuffers((HFILE)CRTDLL__get_osfhandle(_fd)) ) {
-	__set_errno(EBADF);
-	return -1;
-  }
-  return 0;
-}
-
-
-/*********************************************************************
  *           CRTDLL__control87   (CRTDLL.60)
  */
@@ -531,35 +697,10 @@
 
 /*********************************************************************
- *                  CRTDLL__copysign    (CRTDLL.62)
- */
-double CDECL CRTDLL__copysign( double __d, double __s )
-{
-  dprintf2(("CRTDLL: _copysign\n"));
-  double_t *d = (double_t *)&__d;
-  double_t *s = (double_t *)&__s;
-
-  d->sign = s->sign;
-
-  return __d;
-}
-
-
-/*********************************************************************
  *                  _cprintf    (CRTDLL.63)
  */
-INT CDECL CRTDLL__cprintf( char *fmt, ... )
+INT CDECL CRTDLL__cprintf( char *fmt, va_list arg )
 {
   dprintf2(("CRTDLL: _cprintf.\n"));
-
-  int     cnt;
-  char    buf[ 2048 ];		/* this is buggy, because buffer might be too small. */
-  va_list ap;
-  
-  va_start(ap, fmt);
-  cnt = vsprintf(buf, fmt, ap);
-  va_end(ap);
-  
-  _cputs(buf);
-  return cnt;
+  return (_cprintf(fmt, arg));
 }
 
@@ -586,11 +727,10 @@
 
 /*********************************************************************
- *                  CRTDLL__cscanf    (CRTDLL.67)
- */
-INT CDECL CRTDLL__cscanf( char *s, ... )
-{
-  dprintf(("CRTDLL: _cscanf not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
+ *	_cscanf	    				(CRTDLL.67)
+ */
+INT CDECL CRTDLL__cscanf( char *s, va_list arg )
+{
+  dprintf(("CRTDLL: _cscanf\n"));
+  return (_cscanf(s, arg));
 }
 
@@ -647,18 +787,10 @@
 
 /*********************************************************************
- *           CRTDLL___eof   (CRTDLL.76)
+ *           _eof   (CRTDLL.76)
  */
 int CDECL CRTDLL__eof( int _fd )
 {
   dprintf2(("CRTDLL: _eof\n"));
-  int cur_pos = CRTDLL__lseek(_fd, 0, SEEK_CUR);
-  int end_pos = CRTDLL__filelength( _fd );
-  if ( cur_pos == -1 || end_pos == -1)
-	return -1;
-
-  if ( cur_pos == end_pos )
-	return 1;
-
-  return 0;
+  return (__eof(_fd));
 }
 
@@ -681,6 +813,8 @@
 	PEXCEPTION_FRAME  *dispatcher)
 {
-        dprintf2(("CRTDLL: _except_handler2\n"));
-	return 1;
+	dprintf (("exception %lx flags=%lx at %p handler=%p %p %p stub\n",
+	rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress,
+	frame->Handler, context, dispatcher));
+	return ExceptionContinueSearch;
 }
 
@@ -689,50 +823,18 @@
  *           _execl   (CRTDLL.79)
  */
-int CDECL CRTDLL__execl(const char* szPath, const char* szArgv0, ...)
+int CDECL CRTDLL__execl(char* szPath, char* szArgv0, va_list arg)
 {
   dprintf2(("CRTDLL: _execl\n"));
-
-  char *szArg[100];
-  const char *a;
-  int i = 0;
-  va_list l = 0;
-  va_start(l,szArgv0);
-  do {
-  	a = va_arg(l,const char *);
-	szArg[i++] = (char *)a;
-  } while ( a != NULL && i < 100 );
-
-  return _spawnve(P_OVERLAY, (char*)szPath, szArg, _environ);
-}
-
-
-/*********************************************************************
- *           CRTDLL__execle   (CRTDLL.80)
- */
-int CDECL CRTDLL__execle(char *path, char *szArgv0, ...)
-{
-  dprintf2(("CRTDLL: _execle not correct implemented.\n"));
-  char *szArg[100];
-  const char *a;
-  char *ptr;
-  int i = 0;
-  va_list l = 0;
-  va_start(l,szArgv0);
-  do {
-  	a = (const char *)va_arg(l,const char *);
-	szArg[i++] = (char *)a;
-  } while ( a != NULL && i < 100 );
-
-
-// szArg0 is passed and not environment if there is only one parameter;
-
-  if ( i >=2 ) {
-  	ptr = szArg[i-2];
-  	szArg[i-2] = NULL;
-  }
-  else
-	ptr = NULL;
-
-  return _spawnve(P_OVERLAY, path, szArg, (char**)ptr);
+  return (_execl(szPath, szArgv0, arg));
+}
+
+
+/*********************************************************************
+ *           _execle   (CRTDLL.80)
+ */
+int CDECL CRTDLL__execle(char *path, char *szArgv0, va_list arg)
+{
+  dprintf2(("CRTDLL: _execle\n"));
+  return (_execle(path, szArgv0, arg));
 }
 
@@ -741,17 +843,8 @@
  *           CRTDLL__execlp   (CRTDLL.81)
  */
-int CDECL CRTDLL__execlp( char *szPath, char *szArgv0, ...)
+int CDECL CRTDLL__execlp( char *szPath, char *szArgv0, va_list arg)
 {
   dprintf2(("CRTDLL: _execlp\n"));
-  char *szArg[100];
-  const char *a;
-  int i = 0;
-  va_list l = 0;
-  va_start(l,szArgv0);
-  do {
-  	a = (const char *)va_arg(l,const char *);
-	szArg[i++] = (char *)a;
-  } while ( a != NULL && i < 100 );
-  return _spawnvpe(P_OVERLAY, szPath,szArg, _environ);
+  return (_execlp(szPath, szArgv0, arg));
 }
 
@@ -760,28 +853,8 @@
  *           CRTDLL__execlpe   (CRTDLL.82)
  */
-int CDECL CRTDLL__execlpe( char *path, char *szArgv0, ...)
-{
-  dprintf2(("CRTDLL: _execlpe not correct implemented.\n"));
-  char *szArg[100];
-  const char *a;
-  char *ptr;
-  int i = 0;
-  va_list l = 0;
-  va_start(l,szArgv0);
-  do {
-  	a = (const char *)va_arg(l,const char *);
-	szArg[i++] = (char *)a;
-  } while ( a != NULL && i < 100 );
-
-
-// szArg0 is passed and not environment if there is only one parameter;
-
-  if ( i >=2 ) {
-  	ptr = szArg[i-2];
-  	szArg[i-2] = NULL;
-  }
-  else
-	ptr = NULL;
-  return spawnvpe(P_OVERLAY, path, szArg, (char**)ptr);
+int CDECL CRTDLL__execlpe( char *path, char *szArgv0, va_list arg)
+{
+  dprintf2(("CRTDLL: _execlpe\n"));
+  return (_execlpe(path, szArgv0, arg));
 }
 
@@ -838,15 +911,4 @@
 
 /*********************************************************************
- *           _expand   (CRTDLL.88)
- */
-void * CDECL CRTDLL__expand( void *ptr, size_t size )
-{
-  dprintf(("CRTDLL: _expand not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
-}
-
-
-/*********************************************************************
  *           _fcloseall   (CRTDLL.89)
  */
@@ -871,29 +933,8 @@
  *                  _fdopen     (CRTDLL.91)
  */
-CRTDLL_FILE * CDECL CRTDLL__fdopen(INT handle, LPCSTR mode)
-{
-    dprintf2(("CRTDLL: fdopen\n"));
-    CRTDLL_FILE *file;
-
-    switch (handle) 
-    {
-    case 0:
-        file = CRTDLL_stdin;
-        if (!file->handle) file->handle = GetStdHandle( STD_INPUT_HANDLE );
-        break;
-    case 1:
-        file = CRTDLL_stdout;
-        if (!file->handle) file->handle = GetStdHandle( STD_OUTPUT_HANDLE );
-        break;
-    case 2:
-        file=CRTDLL_stderr;
-        if (!file->handle) file->handle = GetStdHandle( STD_ERROR_HANDLE );
-        break;
-    default:
-        file = (PCRTDLL_FILE)Heap_Alloc(sizeof(*file) );
-        file->handle = handle;
-        break;
-    }
-  return file;
+FILE * CDECL CRTDLL__fdopen(INT handle, LPCSTR mode)
+{
+    dprintf2(("CRTDLL: _fdopen\n"));
+    return (_fdopen(handle, mode));
 }
 
@@ -910,25 +951,4 @@
 
 /*********************************************************************
- *           _fgetwchar  (CRTDLL.93)
- */
-wint_t CDECL CRTDLL__fgetwchar( void *i )
-{
-  dprintf2(("CRTDLL: _fgetwchar\n"));
-  return CRTDLL__getch();
-}
-
-
-/*********************************************************************
- *           _filbuf     (CRTDLL.94)
- */
-int CDECL CRTDLL__filbuf(FILE * f)
-{
-  dprintf(("CRTDLL: _filbuf not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
-}
-
-
-/*********************************************************************
  *           CRTDLL__filelength     (CRTDLL.96)
  */
@@ -951,60 +971,4 @@
 
 /*********************************************************************
-*                  _findclose    (CRTDLL.098)
-*/
-int CDECL CRTDLL__findclose( long handle )
-{
-  dprintf2(("CRTDLL: _findclose\n"));
-  // check no wildcards or invalid handle
-  if ( handle == 0 || handle == -1)
-	return 0;
-  return FindClose(handle);
-}
-
-
- /*********************************************************************
- *                  _findfirst    (CRTDLL.099)
- */
-DWORD CDECL CRTDLL__findfirst(LPCSTR fname,  struct find_t * x2)
-{
-  dprintf(("CRTDLL: _findfirst not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
-}
-
-
-/*********************************************************************
- *                  _findnext     (CRTDLL.100)
- */
-INT CDECL CRTDLL__findnext(DWORD hand, struct find_t * x2)
-{
-  dprintf(("CRTDLL: _findnext not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
-}
-
-
-/*********************************************************************
- *                  _finite     (CRTDLL.101)
- */
-INT CDECL CRTDLL__finite(double x)
-{
-  dprintf2(("CRTDLL: _finite\n"));
-  return !_isinf(x);
-}
-
-
-/*********************************************************************
- *                  _flsbuf     (CRTDLL.102)
- */
-INT CDECL CRTDLL__flsbuf(int i, FILE * f)
-{
-  dprintf(("CRTDLL: _flsbuf not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
-}
-
-
-/*********************************************************************
  *                  _flushall     (CRTDLL.103)
  */
@@ -1017,67 +981,4 @@
 
 /*********************************************************************
- *                  _fpclass     (CRTDLL.105)
- */
-INT CDECL CRTDLL__fpclass( double __d )
-{
-  dprintf2(("CRTDLL: _fpclass\n"));
-	double_t *d = (double_t *)&__d;
-
-	if ( d->exponent == 0 ) {
-		if ( d->mantissah == 0 &&  d->mantissal == 0 ) {
-			if ( d->sign ==0 )
-				return FP_NZERO;
-			else
-				return FP_PZERO;
-		} else {
-			if ( d->sign ==0 )
-				return FP_NDENORM;
-			else
-				return FP_PDENORM;
-		}
-	}
-	if (d->exponent == 0x7ff ) {
-		if ( d->mantissah == 0 &&  d->mantissal == 0 ) {
-			if ( d->sign ==0 )
-				return FP_NINF;
-			else
-				return FP_PINF;
-		} 
-		else if ( d->mantissah == 0 &&  d->mantissal != 0 ) {
-			return FP_QNAN;
-		}
-		else if ( d->mantissah == 0 &&  d->mantissal != 0 ) {
-			return FP_SNAN;
-		}
-	
-	}
-
-	return 0;
-}
-
-
-/*********************************************************************
- *                  _fpieee_flt     (CRTDLL.106)
- */
-INT CDECL CRTDLL__fpieee_flt( unsigned long exc_code, struct _EXCEPTION_POINTERS *exc_info, int handler)
-{
-  dprintf(("CRTDLL: _fpieee_flt not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return 0;
-}
-
-
-
-/*********************************************************************
- *                  _fpreset     (CRTDLL.107)
- */
-void CDECL CRTDLL__fpreset(void)
-{
-  dprintf(("CRTDLL: _fpreset not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-}
-
-
-/*********************************************************************
  *                  _fputchar     (CRTDLL.108)
  */
@@ -1090,44 +991,13 @@
 
 /*********************************************************************
- *                  _fputwchar     (CRTDLL.109)
- */
-wint_t CDECL CRTDLL__fputwchar( wint_t )
-{
-  dprintf(("CRTDLL: _fputwchar not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
-}
-
-
-/*********************************************************************
- *                  _fsopen     (CRTDLL.110)
- */
-FILE * CDECL CRTDLL__fsopen( const char *file, const char *mode, int shflag )
-{
-  dprintf(("CRTDLL: _fsopen not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
-}
-
-
-/*********************************************************************
- *                  _fstat        (CRTDLL.111)
- */
-int CDECL CRTDLL__fstat(int file, struct stat* buf)
-{
-  dprintf(("CRTDLL: _fstat not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
-}
-
-
-/*********************************************************************
- *                  _ftime        (CRTDLL.112)
- */
-int CDECL CRTDLL__ftime( struct timeb *timebuf )
-{
-  dprintf(("CRTDLL: _ftime not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
+ *                  _ftol         (CRTDLL.113)
+ */
+LONG CDECL CRTDLL__ftol(void)
+{
+	/* don't just do DO_FPU("fistp",retval), because the rounding
+	 * mode must also be set to "round towards zero"... */
+	double fl;
+	POP_FPU(fl);
+	return (LONG)fl;
 }
 
@@ -1144,15 +1014,4 @@
 
 /*********************************************************************
- *                  _futime        (CRTDLL.115)
- */
-int CDECL CRTDLL__futime( int handle, struct _utimbuf *filetime )
-{
-  dprintf(("CRTDLL: _futime not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
-}
-
-
-/*********************************************************************
  *                  _gcvt     (CRTDLL.116)
  */
@@ -1165,14 +1024,4 @@
 
 /*********************************************************************
- *                  _get_osfhandle     (CRTDLL.117)
- */
-void* CDECL CRTDLL__get_osfhandle( int fileno )
-{
-  dprintf2(("CRTDLL: _get_osfhandle\n"));
-  return filehnd(fileno);
-}
-
-
-/*********************************************************************
  *                  _getch     (CRTDLL.118)
  */
@@ -1215,39 +1064,4 @@
 
 /*********************************************************************
- *                  _getdiskfree     (CRTDLL.122)
- */
-unsigned int CDECL CRTDLL__getdiskfree( unsigned int drive, struct _diskfree_t *diskspace)
-{
-  dprintf2(("CRTDLL: _getdiskfree\n"));
-  char RootPathName[10];
-  RootPathName[0] = toupper(drive +'@');
-  RootPathName[1] = ':';
-  RootPathName[2] = '\\';
-  RootPathName[3] = 0;
-  if ( diskspace == NULL )
-	return 0;
-
-  if ( !GetDiskFreeSpaceA(RootPathName,(LPDWORD)&diskspace->sectors_per_cluster,(LPDWORD)&diskspace->bytes_per_sector,
-		(LPDWORD )&diskspace->avail_clusters,(LPDWORD )&diskspace->total_clusters ) )
-	return 0;
-  return diskspace->avail_clusters;
-}
-
-
-/*********************************************************************
- *                  _getdllprocaddr     (CRTDLL.123)
- */
-FARPROC CDECL  CRTDLL__getdllprocaddr(HMODULE hModule,char * lpProcName, int iOrdinal)
-{
-  dprintf2(("CRTDLL: _getdllprocaddr\n"));   
-  if ( lpProcName != NULL ) 
-	return GetProcAddress(hModule, lpProcName);
-  else
-	return GetProcAddress(hModule, (LPSTR)iOrdinal);
-  return (NULL);
-}
-
-
-/*********************************************************************
  *                  _getdrive    (CRTDLL.124)
  */
@@ -1280,15 +1094,4 @@
 
 /*********************************************************************
- *                  _getsystime    (CRTDLL.127)
- */
-unsigned int CDECL CRTDLL__getsystime(struct tm *tp)
-{
-  dprintf(("CRTDLL: _getsystime not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
-}
-
-
-/*********************************************************************
  *                  _getw     (CRTDLL.128)
  */
@@ -1296,10 +1099,6 @@
 {
   dprintf2(("CRTDLL: _getw\n"));
-  int w;
-
-  /* Is there a better way?  */
-  if (CRTDLL_fread( &w, sizeof(w), 1, stream) != 1)
-    return(EOF);
-  return(w);
+  int x;
+  return (fread (&x, sizeof (x), 1, stream) == 1 ? x : EOF);
 }
 
@@ -1310,5 +1109,5 @@
 void CDECL CRTDLL__global_unwind2( PEXCEPTION_FRAME frame )
 {
-    dprintf2(("CRTDLL: global_undwind2\n"));
+    dprintf2(("CRTDLL: _global_unwind2\n"));
     RtlUnwind( frame, 0, NULL, 0 );
 }
@@ -1342,15 +1141,4 @@
   dprintf2(("CRTDLL: _heapset\n"));
   return (_heapset(fill));
-}
-
-
-/*********************************************************************
- *                  _heapwalk     (CRTDLL.133)
- */
-int CDECL CRTDLL__heapwalk( struct _heapinfo *entry )
-{
-  dprintf(("CRTDLL: _heapwalk not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return 0;
 }
 
@@ -1380,14 +1168,4 @@
 	}
 	return 0;
-}
-
-
-/*********************************************************************
- *                  _isatty       (CRTDLL.137)
- */
-BOOL CDECL CRTDLL__isatty(DWORD x)
-{
-   dprintf2(("(%ld)\n",x));
-   return TRUE;
 }
 
@@ -1419,332 +1197,15 @@
 
 /*********************************************************************
- *                  _ismbbalnum     (CRTDLL.139)
- */
-int CDECL CRTDLL__ismbbalnum( unsigned int c )
-{
-  dprintf2(("CRTDLL: _ismbbalnum\n"));
-  return (CRTDLL_isalnum(c) || CRTDLL__ismbbkalnum(c));
-}
-
-
-/*********************************************************************
- *                  _ismbbalpha     (CRTDLL.140)
- */
-int CDECL CRTDLL__ismbbalpha( unsigned int c )
-{
-  dprintf2(("CRTDLL: _ismbbalpha\n"));
-  return (isalpha(c) || CRTDLL__ismbbkalnum(c));
-}
-
-
-/*********************************************************************
- *                  _ismbbgraph     (CRTDLL.141)
- */
-int CDECL CRTDLL__ismbbgraph( unsigned int c )
-{
-  dprintf2(("CRTDLL: _ismbbgraph\n"));
-  return (CRTDLL_isgraph(c) || CRTDLL__ismbbkana(c));
-}
-
-
-/*********************************************************************
- *                  _ismbbkalnum     (CRTDLL.142)
- */
-int CDECL CRTDLL__ismbbkalnum( unsigned int c )
-{
-  dprintf2(("CRTDLL: _ismbbkalnum\n"));
-  return  ((_jctype+1)[(unsigned char)(c)] & (_KNJ_P));
-}
-
-
-/*********************************************************************
- *                  _ismbbkana     (CRTDLL.143)
- */
-int CDECL CRTDLL__ismbbkana( unsigned int c )
-{
-  dprintf2(("CRTDLL: _ismbbkana\n"));
-  return ((_jctype+1)[(unsigned char)(c)] & (_KNJ_M|_KNJ_P));
-}
-
-
-/*********************************************************************
- *                  _ismbbkpunct     (CRTDLL.144)
- */
-int CDECL CRTDLL__ismbbkpunct( unsigned int c )
-{
-  dprintf2(("CRTDLL: _ismbbkpunct\n"));
-  return  ((_jctype+1)[(unsigned char)(c)] & (_KNJ_P));
-}
-
-
-/*********************************************************************
- *                  _ismbblead     (CRTDLL.145)
- */
-int CDECL CRTDLL__ismbblead( unsigned int c )
-{
-  dprintf2(("CRTDLL: _ismbblead\n"));
-  return ((_jctype+1)[(unsigned char)(c)] & _KNJ_1);
-}
-
-
-/*********************************************************************
- *                  _ismbbprint     (CRTDLL.146)
- */
-int CDECL CRTDLL__ismbbprint( unsigned int c )
-{
-  dprintf2(("CRTDLL: _ismbbprint\n"));
-  return (isprint(c) || CRTDLL__ismbbkana(c));
-}
-
-
-/*********************************************************************
- *                  _ismbbpunct     (CRTDLL.147)
- */
-int CDECL CRTDLL__ismbbpunct( unsigned int c )
-{
-  dprintf2(("CRTDLL: _ismbbpunct\n"));
-  return (ispunct(c) ||  CRTDLL__ismbbkana(c));
-}
-
-
-/*********************************************************************
- *                  _ismbbtrail     (CRTDLL.148)
- */
-int CDECL CRTDLL__ismbbtrail( unsigned int c )
-{
-  dprintf2(("CRTDLL: _ismbbtrail\n"));
-  return ((_jctype+1)[(unsigned char)(c)] & _KNJ_2);
-}
-
-
-/*********************************************************************
- *                  _ismbcalpha     (CRTDLL.149)
- */
-int CDECL CRTDLL__ismbcalpha( unsigned int c )
-{
-  dprintf2(("CRTDLL: _ismbcalpha\n"));
-  if ((c & 0xFF00) != 0) {
-	// true multibyte character
-	return 0;
-  }
-  else
-	return CRTDLL__ismbbalpha(c);
-
-  return 0;
-}
-
-
-/*********************************************************************
- *                  _ismbcdigit     (CRTDLL.150)
- */
-int CDECL CRTDLL__ismbcdigit( unsigned int c )
-{
-  dprintf2(("CRTDLL: _ismbcdigit\n"));
-  if ((c & 0xFF00) != 0) {
-	// true multibyte character
-	return 0;
-  }
-  else
-	return 0;
-//		return _ismbbdigit(c);
-
-	return 0;
-}
-
-
-/*********************************************************************
- *                  _ismbchira     (CRTDLL.151)
- */
-int CDECL CRTDLL__ismbchira( unsigned int c )
-{
-  dprintf2(("CRTDLL: _ismbchira\n"));
-  return ((c>=0x829F) && (c<=0x82F1));
-}
-
-
-/*********************************************************************
- *                  _ismbckata     (CRTDLL.152)
- */
-int CDECL CRTDLL__ismbckata( unsigned int c )
-{
-  dprintf2(("CRTDLL: _ismbckata\n"));
-  return ((c>=0x8340) && (c<=0x8396));
-}
-
-/*********************************************************************
- *                  _ismbcl0     (CRTDLL.153)
- */
-int CDECL CRTDLL__ismbcl0( unsigned int ch )
-{
-  dprintf(("CRTDLL: _ismbcl0 not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return 0;
-}
-
-
-/*********************************************************************
- *                  _ismbcl1     (CRTDLL.154)
- */
-int CDECL CRTDLL__ismbcl1( unsigned int ch )
-{
-  dprintf(("CRTDLL: _ismbcl1 not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return 0;
-}
-
-
-/*********************************************************************
- *                  _ismbcl2     (CRTDLL.155)
- */
-int CDECL CRTDLL__ismbcl2( unsigned int ch )
-{
-  dprintf(("CRTDLL: _ismbcl2 not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return 0;
-}
-
-
-/*********************************************************************
- *                  _ismbclegal     (CRTDLL.156)
- */
-int CDECL CRTDLL__ismbclegal( unsigned int c )
-{
-  dprintf2(("CRTDLL: _ismbclegal\n"));
-  if ((c & 0xFF00) != 0) {
-	return CRTDLL__ismbblead(c>>8) && CRTDLL__ismbbtrail(c&0xFF);
-  }
-  else
-	return CRTDLL__ismbbtrail(c&0xFF);
-
-  return 0;
-}
-
-
-/*********************************************************************
- *                  _ismbclower     (CRTDLL.157)
- */
-int CDECL CRTDLL__ismbclower( unsigned int c )
-{
-  dprintf2(("CRTDLL: _ismbclower\n"));
-  if ((c & 0xFF00) != 0) {
-	if ( c >= 0x829A && c<= 0x829A )
-		return 1;
-  }
-  else
-    return isupper(c);
-}
-
-
-/*********************************************************************
- *                  _ismbcprint     (CRTDLL.158)
- */
-int CDECL CRTDLL__ismbcprint( unsigned int c )
-{
-  dprintf2(("CRTDLL: _ismbcprint\n"));
-  if ((c & 0xFF00) != 0) {
-	// true multibyte character
-	return 0;
-  }
-  else
-	return 0;
-//	return _ismbbdigit(c);
-
-  return 0;
-}
-
-
-/*********************************************************************
- *                  _ismbcspace     (CRTDLL.159)
- */
-int CDECL CRTDLL__ismbcspace( unsigned int c )
-{
-  dprintf(("CRTDLL: _ismbcspace not implemented.\n"));
-  if ((c & 0xFF00) != 0) {
-	// true multibyte character
-	return 0;
-  }
-  else
-	return 0;
-//	return _ismbbdigit(c);
-
-  return 0;
-}
-
-
-/*********************************************************************
- *                  _ismbcsymbol     (CRTDLL.160)
- */
-int CDECL CRTDLL__ismbcsymbol( unsigned int c )
-{
-  dprintf(("CRTDLL: _ismbcsymbol not implemented.\n"));
-  if ((c & 0xFF00) != 0) {
-	// true multibyte character
-	return 0;
-  }
-  else
-	return 0;
-//	return _ismbbdigit(c);
-
-  return 0;
-}
-
-
-/*********************************************************************
- *                  _ismbcupper     (CRTDLL.161)
- */
-int CDECL CRTDLL__ismbcupper( unsigned int c )
-{
-  dprintf2(("CRTDLL: _ismbcupper\n"));
-  if ((c & 0xFF00) != 0) {
-	if ( c >= 0x8260 && c<= 0x8279 )
-		return 1;
-  }
-  else
-  return isupper(c);
-}
-
-
-/*********************************************************************
- *                  _ismbslead     (CRTDLL.162)
- */
-int CDECL CRTDLL__ismbslead(const unsigned char *str, const unsigned char *t)
-{
-  dprintf2(("CRTDLL: _ismbslead\n"));
-  unsigned char *s = (unsigned char *)str;
-  while(*s != 0 && s != t) 
-  {  
-	s+= _mbclen2(*s);
-  }		
-  return CRTDLL__ismbblead( *s);
-}
-
-
-/*********************************************************************
- *                  _ismbstrail     (CRTDLL.163)
- */
-int CDECL CRTDLL__ismbstrail(const unsigned char *str, const unsigned char *t)
-{
-  dprintf2(("CRTDLL: _ismbstrail\n"));
-  unsigned char *s = (unsigned char *)str;
-  while(*s != 0 && s != t) 
-  {
-		
-	s+= _mbclen2(*s);
-  }
-		
-  return CRTDLL__ismbbtrail(*s);
-}
-
-
-/*********************************************************************
- *                  _isnan     (CRTDLL.164)
- */
-int CDECL CRTDLL__isnan( double __x )
-{
-  dprintf2(("CRTDLL: _isnan\n"));
-  double_t * x = (double_t *)&__x;
-  return ( x->exponent == 0x7ff  && ( x->mantissah != 0 || x->mantissal != 0 ));
-}
-
+ *                  _itoa      (CRTDLL.165)
+ */
+char * CDECL CRTDLL__itoa(int i, char *s, int r)
+{
+  dprintf2(("CRTDLL: _itoa(%08xh, %08xh, %08xh)\n",
+           i,
+           s,
+           r));
+
+  return (itoa(i,s,r));
+}
 
 /*********************************************************************
@@ -1788,22 +1249,4 @@
 
 /*********************************************************************
- *                  _lfind     (CRTDLL.170)
- */
-void * CDECL CRTDLL__lfind(const void *key, const void *base, size_t *nelp,
-         size_t width, int (*compar)(const void *, const void *))
-{
-  dprintf2(("CRTDLL: _lfind\n"));
-  char *char_base = (char *)base;
-  int i;
-  for(i=0;i<*nelp;i++) {
- 	if ( compar(key,char_base) == 0)
-		return char_base;
-	char_base += width;
-  }
-  return NULL;
-}
-
-
-/*********************************************************************
  *                  _loaddll    (CRTDLL.171)
  */
@@ -1820,27 +1263,5 @@
 void CDECL CRTDLL__local_unwind2( PEXCEPTION_FRAME endframe, DWORD nr )
 {
-	dprintf2(("CRTDLL: local_undwind2\n"));
-}
-
-
-/*********************************************************************
- *                  _locking        (CRTDLL.173)
- */
-int CDECL CRTDLL__locking(int handle,int mode,unsigned long nbyte)
-{
-  dprintf(("CRTDLL: _locking not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
-}
-
-
-/*********************************************************************
- *                  _logb     (CRTDLL.174)
- */
-double CDECL CRTDLL__logb( double x )
-{
-  dprintf(("CRTDLL: _logb not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
+	dprintf2(("CRTDLL: _local_unwind2\n"));
 }
 
@@ -1867,16 +1288,4 @@
 
 /*********************************************************************
- *                  _lsearch   (CRTDLL.177)
- */
-void * CDECL CRTDLL__lsearch(const void *key, void *base, size_t *nelp, size_t width,
-         int (*compar)(const void *, const void *))
-{
-  dprintf(("CRTDLL: _lsearch not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
-}
-
-
-/*********************************************************************
  *                  _lseek	(CRTDLL.178)
  */
@@ -1889,4 +1298,13 @@
 
 /*********************************************************************
+ *                  _ltoa 	(CRTDLL.179)
+ */
+LPSTR  CDECL CRTDLL__ltoa(long x,LPSTR buf,INT radix)
+{
+    return ltoa(x,buf,radix);
+}
+
+
+/*********************************************************************
  *                  _makepath	(CRTDLL.180)
  */
@@ -1910,1066 +1328,9 @@
 
 /*********************************************************************
- *                  _mbbtombc        (CRTDLL.182)
- */
-unsigned int CDECL CRTDLL__mbbtombc( unsigned int c )
-{
-  dprintf2(("CRTDLL: _mbbtombc\n"));
-  if (c >= 0x20 && c <= 0x7e) {
-    return han_to_zen_ascii_table[c - 0x20];
-  } else if (ISKANA(c)) {
-    return han_to_zen_kana_table[c - 0xa0];
-  }
-  return c;
-}
-
-
-/*********************************************************************
- *                  _mbbtype        (CRTDLL.183)
- */
-int CDECL CRTDLL__mbbtype( unsigned char c, int type )
-{
-  dprintf2(("CRTDLL: _mbbtype\n"));
-	if ( type == 1 ) {
-		if ((c >= 0x40 && c <= 0x7e ) || (c >= 0x80 && c <= 0xfc ) )
-		{
-			return _MBC_TRAIL;
-		}
-		else if (( c >= 0x20 && c >= 0x7E ) || ( c >= 0xA1 && c <= 0xDF ) || 
-			 ( c >= 0x81 && c <= 0x9F ) || ( c >= 0xE0 && c <= 0xFC ) )
-			 return _MBC_ILLEGAL;
-		else
-			return 0;
-		
-	}
-	else  {
-		if (( c >= 0x20 && c <= 0x7E ) || ( c >= 0xA1  && c <= 0xDF )) {
-			return _MBC_SINGLE;
-		}
-		else if ( (c >= 0x81 && c <= 0x9F ) || ( c >= 0xE0 && c <= 0xFC) )
-			return _MBC_LEAD;
-		else if (( c >= 0x20 && c >= 0x7E ) || ( c >= 0xA1 && c <= 0xDF ) || 
-			 ( c >= 0x81 && c <= 0x9F ) || ( c >= 0xE0 && c <= 0xFC ) )
-			 return _MBC_ILLEGAL;
-		else
-			return 0;
-		
-	}
-	
-	
-	return 0;	
-}
-
-
-/*********************************************************************
- *                  _mbccpy        (CRTDLL.184)
- */
-void CDECL CRTDLL__mbccpy( unsigned char *dst, const unsigned char *src )
-{
-  dprintf2(("CRTDLL: _mbccpy\n"));
-
-  if (!CRTDLL__ismbblead(*src) )
-	return;
-		
-  memcpy(dst,src,_mbclen2(*src));
-}
-
-
-/*********************************************************************
- *                  _mbcjistojms     (CRTDLL.185)
- */
-int CDECL CRTDLL__mbcjistojms( unsigned int c )
-{
-  dprintf2(("CRTDLL: _mbcjistojms\n"));
-  int c1, c2;
-
-  c2 = (unsigned char)c;
-  c1 = c >> 8;
-  if (c1 >= 0x21 && c1 <= 0x7e && c2 >= 0x21 && c2 <= 0x7e) {
-    if (c1 & 0x01) {
-      c2 += 0x1f;
-      if (c2 >= 0x7f)
-        c2 ++;
-    } else {
-      c2 += 0x7e;
-    }
-    c1 += 0xe1;
-    c1 >>= 1;
-    if (c1 >= 0xa0)
-      c1 += 0x40;
-    return ((c1 << 8) | c2);
-  }
-  return 0;
-}
-
-
-/*********************************************************************
- *                  _mbcjmstojis     (CRTDLL.186)
- */
-int CDECL CRTDLL__mbcjmstojis( unsigned int c )
-{
-  dprintf2(("CRTDLL: _mbcjmstojis\n"));
-  int c1, c2;
-
-  c2 = (unsigned char)c;
-  c1 = c >> 8;
-  if (c1 < 0xf0 && CRTDLL__ismbblead(c1) && CRTDLL__ismbbtrail(c2)) {
-    if (c1 >= 0xe0)
-      c1 -= 0x40;
-    c1 -= 0x70;
-    c1 <<= 1;
-    if (c2 < 0x9f) {
-      c1 --;
-      c2 -= 0x1f;
-      if (c2 >= (0x80-0x1f))
-        c2 --;
-    } else {
-      c2 -= 0x7e;
-    }
-    return ((c1 << 8) | c2);
-  }
-  return 0;
-}
-
-
-/*********************************************************************
- *                  _mbclen    (CRTDLL.187)
- */
-size_t CDECL CRTDLL__mbclen( const unsigned char *s )
-{
-  dprintf2(("CRTDLL: _mbclen\n"));
-  return (CRTDLL__ismbblead(*s>>8) && CRTDLL__ismbbtrail(*s&0x00FF)) ? 2 : 1;
-}
-
-
-/*********************************************************************
- *                  _mbctohira     (CRTDLL.188)
- */
-int CDECL CRTDLL__mbctohira( unsigned int c )
-{
-  dprintf2(("CRTDLL: _mbctohira\n"));
-  return c;
-}
-
-
-/*********************************************************************
- *                  _mbctokata     (CRTDLL.189)
- */
-int CDECL CRTDLL__mbctokata( unsigned int c )
-{
-  dprintf2(("CRTDLL: _mbctokata\n"));
-  return c;
-}
-
-
-/*********************************************************************
- *                  _mbctolower     (CRTDLL.190)
- */
-unsigned int CDECL CRTDLL__mbctolower( unsigned int c )
-{
-  dprintf2(("CRTDLL: _mbctolower\n"));
-        if ((c & 0xFF00) != 0) {
-// true multibyte case conversion needed
-		if ( CRTDLL__ismbclower(c) )
-			return c + CASE_DIFF;
-
-        } else
-		return _mbbtolower(c);
-
-	return 0;
-}
-
-
-/*********************************************************************
- *                  _mbctombb        (CRTDLL.191)
- */
-unsigned int CDECL CRTDLL__mbctombb( unsigned int c )
-{
-  dprintf2(("CRTDLL: _mbctombb\n"));
-  int i;
-  unsigned short *p;
-
-  if (JISKANA(c)) {
-    return zen_to_han_kana_table[c - 0x8340];
-  } else if (JISHIRA(c)) {
-    c = JTOKANA(c);
-    return zen_to_han_kana_table[c - 0x8340];
-  } else if (c <= 0x8396) {
-    for (i = 0x20, p = han_to_zen_ascii_table; i <= 0x7e; i++, p++) {
-      if (*p == c) {
-        return i;
-      }
-    }
-    for (i = 0; i < ZTOH_SYMBOLS; i++) {
-      if (zen_to_han_symbol_table_1[i] == c) {
-        return zen_to_han_symbol_table_2[i];
-      }
-    }
-  }
-  return c;
-}
-
-
-/*********************************************************************
- *                  _mbctoupper     (CRTDLL.192)
- */
-unsigned int CDECL CRTDLL__mbctoupper( unsigned int c )
-{
-  dprintf2(("CRTDLL: _mbctoupper\n"));
-  if ((c & 0xFF00) != 0) {
-// true multibyte case conversion needed
-  if ( CRTDLL__ismbcupper(c) )
-	return c + CASE_DIFF;
-
-  } else
-	return _mbbtoupper(c);
-
-  return 0;
-}
-
-
-/*********************************************************************
- *                  _mbsbtype     (CRTDLL.194)
- */
-int CDECL CRTDLL__mbsbtype( const unsigned char *str, int n )
-{
-  dprintf2(("CRTDLL: _mbsbtype\n"));
-  if ( str == NULL )
-	return -1;
-  return CRTDLL__mbbtype(*(str+n),1);
-}
-
-
-/*********************************************************************
- *                  _mbscat       (CRTDLL.195)
- */
-unsigned char * CDECL CRTDLL__mbscat( unsigned char *dst, const unsigned char *src )
-{
-  dprintf2(("CRTDLL: _mbscat\n"));
-  return (unsigned char*)strcat((char*)dst,(char*)src);
-}
-
-
-/*********************************************************************
- *                  _mbschr       (CRTDLL.196)
- */
-unsigned char * CDECL CRTDLL__mbschr( const unsigned char *str, unsigned int c )
-{
-  dprintf2(("CRTDLL: _mbschr\n"));
-  return (unsigned char*)strchr((char*)str,c);
-}
-
-
-/*********************************************************************
- *                  _mbscmp       (CRTDLL.197)
- */
-int CDECL CRTDLL__mbscmp( const unsigned char *s1, const unsigned char *s2 )
-{
-  dprintf2(("CRTDLL: _mbscmp\n"));
-  return strcmp((char*)s1,(char*)s2);
-}
-
-
-/*********************************************************************
- *                  _mbscpy       (CRTDLL.198)
- */
-unsigned char * CDECL CRTDLL__mbscpy( unsigned char *s1, const unsigned char *s2 )
-{
-  dprintf2(("CRTDLL: _mbscpy\n"));
-  return (unsigned char*)strcpy((char*)s1,(char*)s2);
-}
-
-
-/*********************************************************************
- *                  _mbscspn        (CRTDLL.199)
- */
-size_t CDECL CRTDLL__mbscspn( const unsigned char *s1, const unsigned char *s2 )
-{
-  dprintf2(("CRTDLL: _mbscspn\n"));
-  const char *p, *spanp;
-  char c, sc;
-
-  for (p = (const char*)s1;;)
-  {
-    c = *p++;
-    spanp = (const char*)s2;
-    do {
-      if ((sc = *spanp++) == c)
-	return (size_t)(p - 1) - (size_t)s1;
-    } while (sc != 0);
-  }
-  /* NOTREACHED */
-}
-
-
-/*********************************************************************
- *           _mbsdec    (CRTDLL.200)
- */
-unsigned char * CDECL CRTDLL__mbsdec( const unsigned char *str, const unsigned char *cur )
-{
-  dprintf2(("CRTDLL: _mbsdec\n"));
-  unsigned char *s = (unsigned char *)cur;
-  if ( str >= cur )
-	return NULL;
-  s--;
-  if (CRTDLL__ismbblead(*(s-1)) )
- 	s--;
-
-  return s; 
-}
-
-
-/*********************************************************************
- *           _mbsdup    (CRTDLL.201)
- */
-unsigned char * CDECL CRTDLL__mbsdup( unsigned char *_s )
-{
-  dprintf2(("CRTDLL: _mbsdup\n"));
-  char *rv;
-  if (_s == 0)
-	return 0;
-  rv = (char *)malloc(CRTDLL__mbslen((LPCSTR)_s) + 1);
-  if (rv == 0)
- 	return 0;
-  CRTDLL__mbscpy((unsigned char*)rv, _s);
-  return (unsigned char*)rv;
-}
-
-
-/*********************************************************************
- *           CRTDLL__mbsicmp   (CRTDLL.202)
- */
-int CDECL CRTDLL__mbsicmp( const unsigned char *x, const unsigned char *y )
-{
-  dprintf2(("CRTDLL: _mbsicmp\n"));
-    do {
-	if (!*x)
-	    return !!*y;
-	if (!*y)
-	    return !!*x;
-	/* FIXME: MBCS handling... */
-	if (*x!=*y)
-	    return 1;
-        x++;
-        y++;
-    } while (1);
-}
-
-
-/*********************************************************************
- *           CRTDLL__mbsinc    (CRTDLL.203)
- */
-LPSTR CDECL CRTDLL__mbsinc( LPCSTR str )
-{
-    dprintf2(("CRTDLL: _mbsinc\n"));
-    int len = mblen( str, MB_LEN_MAX );
-    if (len < 1) len = 1;
-    return (LPSTR)(str + len);
-}
-
-
-/*********************************************************************
- *           CRTDLL__mbslen    (CRTDLL.204)
- */
-INT CDECL CRTDLL__mbslen( LPCSTR str )
-{
-    dprintf2(("CRTDLL: _mbslen\n"));
-    INT len, total = 0;
-    while ((len = mblen( str, MB_LEN_MAX )) > 0)
-    {
-        str += len;
-        total++;
-    }
-    return total;
-}
-
-
-/*********************************************************************
- *           _mbslwr    (CRTDLL.205)
- */
-unsigned char * CDECL CRTDLL__mbslwr( unsigned char *x )
-{
-  dprintf2(("CRTDLL: _mbslwr\n"));
-  unsigned char  *y=x;
-
-  while (*y) {
-	if (!CRTDLL__ismbblead(*y) )
-		*y = tolower(*y);
-	else {
-               	*y=CRTDLL__mbctolower(*(unsigned short *)y);
-               	y++;
-	}
-  }
-  return x;
-}
-
-
-/*********************************************************************
- *           _mbsnbcat  (CRTDLL.206)
- */
-unsigned char * CDECL CRTDLL__mbsnbcat( unsigned char *dst, const unsigned char *src, size_t n )
-{
-  dprintf2(("CRTDLL: _mbsnbcat\n"));
-	char *d; 
-    	char *s = (char *)src;	
-    	if (n != 0) {
-		d = (char*)dst + strlen((char*)dst); // get the end of string 
-		d += _mbclen2(*d); // move 1 or 2 up
-
-		do {
-			if ((*d++ = *s++) == 0)
-			{
-				while (--n != 0)
-					*d++ = 0;
-				break;
-      			}
-			if ( !(n==1 && CRTDLL__ismbblead(*s)) )
-				n--;
-    		} while (n > 0);
-  	}
-  	return dst;
-}
-
-
-/*********************************************************************
- *           _mbsnbcmp  (CRTDLL.207)
- */
-int CDECL CRTDLL__mbsnbcmp( const unsigned char *str1, const unsigned char *str2, size_t n )
-{
-  dprintf2(("CRTDLL: _mbsnbcmp\n"));
-	unsigned char *s1 = (unsigned char *)str1;
-	unsigned char *s2 = (unsigned char *)str2;
-
-	unsigned short *short_s1, *short_s2;
-
-	int l1, l2;
-
-	if (n == 0)
-		return 0;
-	do {
-		
-		if (*s1 == 0)
-			break;	
-
-		l1 = CRTDLL__ismbblead(*s1);
-		l2 = CRTDLL__ismbblead(*s2);
-		if ( !l1 &&  !l2  ) {
-
-			if (*s1 != *s2)
-				return *s1 - *s2;
-			else {
-				s1 += 1;
-				s2 += 1;
-				n--;
-			}
-		}
-		else if ( l1 && l2 ){
-			short_s1 = (unsigned short *)s1;
-			short_s2 = (unsigned short *)s2;
-			if ( *short_s1 != *short_s2 )
-				return *short_s1 - *short_s2;
-			else {
-				s1 += 2;
-				s2 += 2;
-				n-=2;
-
-			}
-		}
-		else
-			return *s1 - *s2;
-	} while (n > 0);
-	return 0;
-}
-
-
-/*********************************************************************
- *           _mbsnbcnt  (CRTDLL.208)
- */
-size_t CDECL CRTDLL__mbsnbcnt( const unsigned char *str, size_t n )
-{
-  dprintf2(("CRTDLL: _mbsnbcnt\n"));
-	unsigned char *s = (unsigned char *)str;
-	while(*s != 0 && n > 0) {
-		if (!CRTDLL__ismbblead(*s) )
-			n--;
-		s++;
-	}
-	
-	return (size_t)(s - str);
-}
-
-
-/*********************************************************************
- *           _mbsnbcpy  (CRTDLL.209)
- */
-unsigned char * CDECL CRTDLL__mbsnbcpy( unsigned char *str1, const unsigned char *str2, size_t n )
-{
-  dprintf2(("CRTDLL: _mbsnbcpy\n"));
-	unsigned char *s1 = (unsigned char *)str1;
-	unsigned char *s2 = (unsigned char *)str2;
-
-	unsigned short *short_s1, *short_s2;
-
-	if (n == 0)
-		return 0;
-	do {
-		
-		if (*s2 == 0)
-			break;	
-
-		if (  !CRTDLL__ismbblead(*s2) ) {
-
-			*s1 = *s2;
-			s1 += 1;
-			s2 += 1;
-			n--;
-		}
-		else {
-			short_s1 = (unsigned short *)s1;
-			short_s2 = (unsigned short *)s2;
-			*short_s1 = *short_s2;
-			s1 += 2;
-			s2 += 2;
-			n-=2;
-		}
-	} while (n > 0);
-	return str1;
-}
-
-
-/*********************************************************************
- *           _mbsnbicmp (CRTDLL.210)
- */
-int CDECL CRTDLL__mbsnbicmp( const unsigned char *s1, const unsigned char *s2, size_t n )
-{
-  dprintf2(("CRTDLL: _mbsnbicmp\n"));
-  if (n == 0)
-    return 0;
-  do {
-    if (_mbbtoupper(*s1) != _mbbtoupper(*s2))
-      return _mbbtoupper(*(unsigned const char *)s1) - _mbbtoupper(*(unsigned const char *)s2);
-    s1 += _mbclen2(*s1);
-    s2 += _mbclen2(*s2);
-
-
-    if (*s1 == 0)
-      break;
-    n--;
-  } while (n > 0);
-  return 0;
-}
-
-
-/*********************************************************************
- *           _mbsnbset (CRTDLL.211)
- */
-unsigned char * CDECL CRTDLL__mbsnbset( unsigned char *src, unsigned int val, size_t count )
-{
-  dprintf2(("CRTDLL: _mbsnbset\n"));
-	unsigned char *char_src = (unsigned char *)src;
-	unsigned short *short_src = (unsigned short *)src;
-       
-	if ( _mbclen2(val) == 1 ) {
-	
-		while(count > 0) {
-                	*char_src = val;
-                	char_src++;
-                	count--;
-        	}
-        	*char_src = 0;
-        }
-        else {
-		while(count > 0) {
-                	*short_src = val;
-                	short_src++;
-                	count-=2;
-        	}    	
-        	*short_src = 0;
-        }
-        
-        return src;
-}
-
-
-/*********************************************************************
- *           _mbsncat (CRTDLL.212)
- */
-unsigned char * CDECL CRTDLL__mbsncat( unsigned char *dst, const unsigned char *src, size_t n )
-{
-  dprintf2(("CRTDLL: _mbsncat\n"));
-	char *d = (char *)dst; 
-    	char *s = (char *)src;	
-    	if (n != 0) {
-		d = (char*)dst + strlen((char*)dst); // get the end of string 
-		d += _mbclen2(*d); // move 1 or 2 up
-
-		do {
-			if ((*d++ = *s++) == 0)
-			{
-				while (--n != 0)
-					*d++ = 0;
-				break;
-      			}
-			if (!CRTDLL__ismbblead(*s) )
-				n--;
-    		} while (n > 0);
-  	}
-  	return dst;
-}
-
-
-/*********************************************************************
- *           _mbsnccnt (CRTDLL.213)
- */
-size_t CDECL CRTDLL__mbsnccnt( const unsigned char *str, size_t n )
-{
-  dprintf2(("CRTDLL: _mbsnccnt\n"));
-	unsigned char *s = (unsigned char *)str;
-	size_t cnt = 0;
-	while(*s != 0 && n > 0) {
-		if (CRTDLL__ismbblead(*s) ) 
-			s++;
-		else
-			n--;
-		s++;
-		cnt++;
-	}
-	
-	return cnt;
-}
-
-
-/*********************************************************************
- *           _mbsncmp (CRTDLL.214)
- */
-int CDECL CRTDLL__mbsncmp( const unsigned char *str1, const unsigned char *str2, size_t n )
-{
-  dprintf2(("CRTDLL: _mbsncmp\n"));
-	unsigned char *s1 = (unsigned char *)str1;
-	unsigned char *s2 = (unsigned char *)str2;
-
-	unsigned short *short_s1, *short_s2;
-
-	int l1, l2;
-
-	if (n == 0)
-		return 0;
-	do {
-		
-		if (*s1 == 0)
-			break;	
-
-		l1 = CRTDLL__ismbblead(*s1);
-		l2 = CRTDLL__ismbblead(*s2);
-		if ( !l1 &&  !l2  ) {
-
-			if (*s1 != *s2)
-				return *s1 - *s2;
-			else {
-				s1 += 1;
-				s2 += 1;
-				n--;
-			}
-		}
-		else if ( l1 && l2 ){
-			short_s1 = (unsigned short *)s1;
-			short_s2 = (unsigned short *)s2;
-			if ( *short_s1 != *short_s2 )
-				return *short_s1 - *short_s2;
-			else {
-				s1 += 2;
-				s2 += 2;
-				n--;
-
-			}
-		}
-		else
-			return *s1 - *s2;
-	} while (n > 0);
-	return 0;
-}
-
-
-/*********************************************************************
- *           _mbsncpy (CRTDLL.215)
- */
-unsigned char * CDECL CRTDLL__mbsncpy( unsigned char *str1, const unsigned char *str2, size_t n )
-{
-  dprintf2(("CRTDLL: _mbsncpy\n"));
-	unsigned char *s1 = (unsigned char *)str1;
-	unsigned char *s2 = (unsigned char *)str2;
-
-	unsigned short *short_s1, *short_s2;
-
-	if (n == 0)
-		return 0;
-	do {
-		
-		if (*s2 == 0)
-			break;	
-
-		if (  !CRTDLL__ismbblead(*s2) ) {
-
-			*s1 = *s2;
-			s1 += 1;
-			s2 += 1;
-			n--;
-		}
-		else {
-			short_s1 = (unsigned short *)s1;
-			short_s2 = (unsigned short *)s2;
-			*short_s1 = *short_s2;
-			s1 += 2;
-			s2 += 2;
-			n--;
-		}
-	} while (n > 0);
-	return str1;
-}
-
-
-/*********************************************************************
- *           _mbsnextc (CRTDLL.216)
- */
-unsigned int CDECL CRTDLL__mbsnextc( const unsigned char *src )
-{
-  dprintf2(("CRTDLL: _mbsnextc\n"));
-	unsigned char *char_src = (unsigned char *)src;
-	unsigned short *short_src = (unsigned short *)src;
-
-	if ( src == NULL )
-		return 0;
-
-	if ( !CRTDLL__ismbblead(*src) )
-		return *char_src;
-	else
-		return *short_src;
-	return 0;
-
-}
-
-
-/*********************************************************************
- *           _mbsnicmp (CRTDLL.217)
- */
-int CDECL CRTDLL__mbsnicmp( const unsigned char *s1, const unsigned char *s2, size_t n )
-{
-  dprintf2(("CRTDLL: _mbsnicmp\n"));
-  if (n == 0)
-    return 0;
-  do {
-    if (_mbbtoupper(*s1) != _mbbtoupper(*s2))
-      return _mbbtoupper(*(unsigned const char *)s1) - _mbbtoupper(*(unsigned const char *)s2);
-
-// Next 2 lines won't compile
-//    *s1 += _mbclen2(*s1);
-//    *s2 += _mbclen2(*s2);
-
-
-    if (*s1 == 0)
-      break;
-    if (!CRTDLL__ismbblead(*s1) )
-	n--;
-  } while (n > 0);
-  return 0;
-}
-
-
-/*********************************************************************
- *           _mbsninc (CRTDLL.218)
- */
-unsigned char * CDECL CRTDLL__mbsninc( const unsigned char *str, size_t n )
-{
-  dprintf2(("CRTDLL: _mbsninc\n"));
-	unsigned char *s = (unsigned char *)str;
-	while(*s != 0 && n > 0) {
-		if (!CRTDLL__ismbblead(*s) )
-			n--;
-		s++;
-	}
-	
-	return s;
-}
-
-
-/*********************************************************************
- *           _mbsnset (CRTDLL.219)
- */
-unsigned char * CDECL CRTDLL__mbsnset( unsigned char *src, unsigned int val, size_t count )
-{
-  dprintf2(("CRTDLL: _mbsnset\n"));
-	unsigned char *char_src = (unsigned char *)src;
-	unsigned short *short_src = (unsigned short *)src;
-       
-	if ( _mbclen2(val) == 1 ) {
-	
-		while(count > 0) {
-                	*char_src = val;
-                	char_src++;
-                	count--;
-        	}
-        	*char_src = 0;
-        }
-        else {
-		while(count > 0) {
-                	*short_src = val;
-                	short_src++;
-                	count-=2;
-        	}    	
-        	*short_src = 0;
-        }
-        
-        return src;
-
-}
-
-
-/*********************************************************************
- *           _mbspbrk   (CRTDLL.220)
- */
-unsigned char * CDECL CRTDLL__mbspbrk( const unsigned char *s1, const unsigned char *s2 )
-{
-  dprintf2(("CRTDLL: _mbspbrk\n"));
-  const char *scanp;
-  int c, sc;
-
-  while ((c = *s1++) != 0)
-  {
-    for (scanp = (char*)s2; (sc = *scanp++) != 0;)
-      if (sc == c)
-	return (unsigned char *)((char *)s1 - (char *)1);
-  }
-  return 0;
-}
-
-
-/*********************************************************************
- *           CRTDLL__mbsrchr   (CRTDLL.221)
- */
-LPSTR CDECL CRTDLL__mbsrchr(LPSTR s,CHAR x)
-{
-  dprintf2(("CRTDLL: _mbsrchr\n"));
-	/* FIXME: handle multibyte strings */
-	return strrchr(s,x);
-}
-
-
-/*********************************************************************
- *           _mbsrev    (CRTDLL.222)
- */
-unsigned char * CDECL CRTDLL__mbsrev( unsigned char *s )
-{
-  dprintf2(("CRTDLL: _mbsrev\n"));
-	unsigned char  *e;
-	unsigned char  a;
-	e=s;
-	while (*e) {
-		if ( CRTDLL__ismbblead(*e) ) {
-			a = *e;
-			*e = *++e;
-			if ( *e == 0 )
-				break;
-			*e = a;
-		} 
-		e++;
-	}
-	while (s<e) {
-		a=*s;
-		*s=*e;
-		*e=a;
-		s++;
-		e--;
-	}
-	
-
-	return s;
-}
-
-
-/*********************************************************************
- *           _mbsset    (CRTDLL.223)
- */
-unsigned char * CDECL CRTDLL__mbsset( unsigned char *src, unsigned int c )
-{
-  dprintf2(("CRTDLL: _mbsset\n"));
-	unsigned char *char_src = src;
-	unsigned short *short_src = (unsigned short*)src;
-       
-	if ( _mbclen2(c) == 1 ) {
-	
-		while(*char_src != 0) {
-                	*char_src = c;
-                	char_src++;
-        	}
-        	*char_src = 0;
-        }
-        else {
-		while(*short_src != 0) {
-                	*short_src = c;
-                	short_src++;
-        	}    	
-        	*short_src = 0;
-        }
-        
-        return src;
-}
-
-
-/*********************************************************************
- *           _mbsspn   (CRTDLL.224)
- */
-size_t CDECL CRTDLL__mbsspn( const unsigned char *s1, const unsigned char *s2 )
-{
-  dprintf2(("CRTDLL: _mbsspn\n"));
-  const char *p = (char*)s1, *spanp;
-  char c, sc;
-
- cont:
-  c = *p++;
-  for (spanp = (char*)s2; (sc = *spanp++) != 0;)
-    if (sc == c)
-      goto cont;
-  return (size_t)(p - 1) - (size_t)s1;
-}
-
-
-/*********************************************************************
- *           _mbsspnp   (CRTDLL.225)
- */
-unsigned char * CDECL CRTDLL__mbsspnp( const unsigned char *s1, const unsigned char *s2 )
-{
-  dprintf2(("CRTDLL: _mbsspnp\n"));
-  const char *p = (char*)s1, *spanp;
-  char c, sc;
-
- cont:
-  c = *p++;
-  for (spanp = (char*)s2; (sc = *spanp++) != 0;)
-    if (sc == c)
-      goto cont;
-  return (unsigned char*)p;
-}
-
-
-/*********************************************************************
- *           _mbsstr    (CRTDLL.226)
- */
-unsigned char * CDECL CRTDLL__mbsstr( const unsigned char *s1, const unsigned char *s2 )
-{
-  dprintf2(("CRTDLL: _mbsstr\n"));
-  return (unsigned char*)strstr((const char*)s1,(const char*)s2);
-}
-
-
-/*********************************************************************
- *           _mbstok    (CRTDLL.227)
- */
-unsigned char * CDECL CRTDLL__mbstok( unsigned char *s, const unsigned char *delim )
-{
-  dprintf2(("CRTDLL: _mbstok\n"));
-  const char *spanp;
-  int c, sc;
-  char *tok;
-  static char *last;
-
-
-  if (s == NULL && (s = (unsigned char*)last) == NULL)
-    return (NULL);
-
-  /*
-   * Skip (span) leading delimiters (s += strspn(s, delim), sort of).
-   */
- cont:
-  c = *s;
-  s = (unsigned char*)CRTDLL__mbsinc((LPCSTR)s);
-
-  for (spanp = (const char*)delim; (sc = *spanp) != 0; spanp = CRTDLL__mbsinc(spanp)) {
-    if (c == sc)
-      goto cont;
-  }
-
-  if (c == 0) {			/* no non-delimiter characters */
-    last = NULL;
-    return (NULL);
-  }
-  tok = (char*)s - 1;
-
-  /*
-   * Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
-   * Note that delim must have one NUL; we stop if we see that, too.
-   */
-  for (;;) {
-    c = *s;
-    s = (unsigned char*)CRTDLL__mbsinc((LPCSTR)s);
-    spanp = (const char*)delim;
-    do {
-      if ((sc = *spanp) == c) {
-	if (c == 0)
-	  s = NULL;
-	else
-	  s[-1] = 0;
-	last = (char*)s;
-	return ((unsigned char*)tok);
-      }
-      spanp = CRTDLL__mbsinc(spanp);
-    } while (sc != 0);
-  }
-  /* NOTREACHED */
-}
-
-
-/*********************************************************************
- *           _mbstrlen   (CRTDLL.228)
- */
-size_t CDECL CRTDLL__mbstrlen(const char *string)
-{
-  dprintf2(("CRTDLL: _mbstrlen\n"));
-	char *s = (char *)string;
-	size_t i;
-	while ( *s != 0 ) {
-		if ( CRTDLL__ismbblead(*s) )
-			s++;
-		s++;
-		i++;
-	}
-	return i;
-}
-
-
-/*********************************************************************
- *           _mbsupr    (CRTDLL.229)
- */
-unsigned char * CDECL CRTDLL__mbsupr( unsigned char *x )
-{
-  dprintf2(("CRTDLL: _mbsupr\n"));
-	unsigned char  *y=x;
-        while (*y) {
-		if (!CRTDLL__ismbblead(*y) )
-			*y = toupper(*y);
-		else {
-                	*y=CRTDLL__mbctoupper(*(unsigned short *)y);
-                	y++;
-		}
-        }
-        return x;
-}
-
-
-/*********************************************************************
- *           CRTDLL__memccpy   (CRTDLL.230)
- */
-void * CDECL CRTDLL__memccpy(void *to, const void *from,int c,size_t count)
-{
-  dprintf2(("CRTDLL: _memccpy\n"));
-  memcpy(to,from,count);
-  return memchr(to,c,count);
-}
-
-
-/*********************************************************************
  *                  _mkdir           (CRTDLL.232)
  */
 INT CDECL CRTDLL__mkdir(LPCSTR newdir)
 {
-	dprintf2(("CRTDLL: mkdir\n"));
+	dprintf2(("CRTDLL: _mkdir\n"));
 	if (!CreateDirectoryA(newdir,NULL))
 		return -1;
@@ -2981,55 +1342,37 @@
  *                  _mktemp        (CRTDLL.233)
  */
-char * CDECL CRTDLL__mktemp( char * _template )
+char * CDECL CRTDLL__mktemp( char *string )
 {
   dprintf2(("CRTDLL: _mktemp\n"));
-  static int count = 0;
-  char *cp, *dp;
-  int i, len, xcount, loopcnt;
-
- 
-
-  len = strlen (_template);
-  cp = _template + len;
-
-  xcount = 0;
-  while (xcount < 6 && cp > _template && cp[-1] == 'X')
-    xcount++, cp--;
-
-  if (xcount) {
-    dp = cp;
-    while (dp > _template && dp[-1] != '/' && dp[-1] != '\\' && dp[-1] != ':')
-      dp--;
-
-    /* Keep the first characters of the template, but turn the rest into
-       Xs.  */
-    while (cp > dp + 8 - xcount) {
-      *--cp = 'X';
-      xcount = (xcount >= 6) ? 6 : 1 + xcount;
+  int pid, n, saved_errno;
+  char *s;
+
+  pid = _getpid ();
+  s = strchr (string, 0);
+  n = 0;
+  while (s != string && s[-1] == 'X')
+    {
+      --s; ++n;
+      *s = (char)(pid % 10) + '0';
+      pid /= 10;
     }
-
-    /* If dots occur too early -- squash them.  */
-    while (dp < cp) {
-      if (*dp == '.') *dp = 'a';
-      dp++;
+  if (n < 2)
+    return NULL;
+  *s = 'a'; saved_errno = errno;
+  for (;;)
+    {
+      errno = 0;
+      if (_access (string, 0) != 0 && errno == ENOENT)
+        {
+          errno = saved_errno;
+          return string;
+        }
+      if (*s == 'z')
+        {
+          errno = saved_errno;
+          return NULL;
+        }
+      ++*s;
     }
-
-    /* Try to add ".tmp" to the filename.  Truncate unused Xs.  */
-    if (cp + xcount + 3 < _template + len)
-      strcpy (cp + xcount, ".tmp");
-    else
-      cp[xcount] = 0;
-
-    for (loopcnt = 0; loopcnt < (1 << (5 * xcount)); loopcnt++) {
-      int c = count++;
-      for (i = 0; i < xcount; i++, c >>= 5)
-	cp[i] = "abcdefghijklmnopqrstuvwxyz012345"[c & 0x1f];
-      if (CRTDLL__access(_template,0) == -1)
-	return _template;
-    }
-  }
-  /* Failure:  truncate the template and return NULL.  */
-  *_template = 0;
-  return 0;
 }
 
@@ -3042,19 +1385,4 @@
   dprintf2(("CRTDLL: _msize\n"));
   return (_msize(ptr));
-}
-
-
-/*********************************************************************
- *                  _nextafter        (CRTDLL.235)
- */
-double CDECL CRTDLL__nextafter( double x, double y )
-{
-  dprintf2(("CRTDLL: _nextafter\n"));
-  if ( x == y)
-	return x;
-  if ( CRTDLL__isnan(x) || CRTDLL__isnan(y) )
-	return x;
-
-  return x;
 }
 
@@ -3146,37 +1474,4 @@
 
 /*********************************************************************
- *                  _pclose     (CRTDLL.244)
- */
-INT CDECL CRTDLL__pclose( FILE *fp )
-{
-  dprintf(("CRTDLL: _pclose not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
-}
-
-
-/*********************************************************************
- *                  _pipe     (CRTDLL.247)
- */
-INT CDECL CRTDLL__pipe( int *phandles, unsigned psize, int textmode )
-{
-  dprintf(("CRTDLL: _pipe not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
-}
-
-
-/*********************************************************************
- *                  _popen    (CRTDLL.248)
- */
-FILE * CDECL CRTDLL__popen( const char *command, const char *mode )
-{
-  dprintf(("CRTDLL: _popen not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
-}
-
-
-/*********************************************************************
  *                  _purecall     (CRTDLL.249)
  */
@@ -3210,10 +1505,8 @@
  *                  _putw     (CRTDLL.252)
  */
-INT CDECL CRTDLL__putw( int w, FILE *stream )
+INT CDECL CRTDLL__putw( int x, FILE *stream )
 {
   dprintf2(("CRTDLL: _putw\n"));
-  if (fwrite( &w, sizeof(w), 1, stream) < 1)
-    return(EOF);
-  return(0);
+  return (fwrite (&x, sizeof (x), 1, stream) == 1 ? x : EOF);
 }
 
@@ -3222,9 +1515,71 @@
  *                  _read     (CRTDLL.254)
  */
-INT CDECL CRTDLL__read(INT fd, LPVOID buf, UINT count)
-{
-  dprintf(("CRTDLL: _read not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
+INT CDECL CRTDLL__read(int handle, void *buf, size_t nbyte)
+{
+  dprintf(("CRTDLL: _read\n"));
+/*
+  int n, *pflags, *pla;
+  size_t j, k;
+  char *dst, c;
+
+  if ((pflags = _fd_flags (handle)) == NULL
+      || (pla = _fd_lookahead (handle)) == NULL)
+    {
+      errno = EBADF;
+      return -1;
+    }
+
+  *pflags &= ~F_CRLF;
+  if (nbyte > 0 && (*pflags & F_EOF))
+    return 0;
+  dst = buf;
+  n = read_lookahead (handle, dst, nbyte, pla);
+  if (n == -1)
+    return -1;
+  if ((*pflags & O_TEXT) && !(*pflags & F_TERMIO) && n > 0)
+    {
+      if (!(*pflags & (F_PIPE|F_SOCKET|F_DEV)) && dst[n-1] == 0x1a &&
+          _eof (handle))
+        {
+          --n;
+          *pflags |= F_EOF;
+          if (n == 0)
+            return 0;
+        }
+      if (n == 1 && dst[0] == '\r')
+        {
+          int saved_errno = errno;
+          j = read_lookahead (handle, &c, 1, pla);
+          if (j == -1 && errno == EAGAIN)
+            {
+              *pla = dst[0];
+              return -1;
+            }
+          errno = saved_errno;                
+          if (j == 1 && c == '\n')            
+            {
+              dst[0] = '\n';
+              *pflags |= F_CRLF;
+            }
+          else
+            *pla = c;
+        }
+      else
+        {
+
+          if (_crlf (dst, n, &k))
+            {
+
+              *pla = '\r';
+              --n;
+            }
+          if (k != n)
+            *pflags |= F_CRLF;
+          n = k;
+        }
+    }
+  return n;
+*/
+  return 0;
 }
 
@@ -3273,43 +1628,10 @@
 
 /*********************************************************************
- *           _scalb 	 (CRTDLL.259)
- */
-double CDECL CRTDLL__scalb( double __x, long e )
-{
-  dprintf2(("CRTDLL: _scalb\n"));
-  double_t *x = (double_t *)&__x;
-	
-  x->exponent += e;
-
-  return __x;
-}
-
-
-/*********************************************************************
  *           CRTDLL__searchenv 	 (CRTDLL.260)
  */
-void CDECL CRTDLL__searchenv(const char *file,const char *var,char *path )
+void CDECL CRTDLL__searchenv(char *file, char *var,char *path )
 {
   dprintf2(("CRTDLL: _searchenv\n"));
-  char *env = CRTDLL_getenv(var);
-
-  char *x;
-  char *y;
-  char *FilePart;
-  x = strchr(env,'=');
-  if ( x != NULL ) {
-	*x = 0;
-	x++;
-  }
-  y = strchr(env,';');
-  while ( y != NULL ) {
-	*y = 0;
-	if ( SearchPathA(x,file,NULL,MAX_PATH,path,&FilePart) > 0 ) {
-			return;
-	}
-	x = y+1;
-	y = strchr(env,';');
-  }
-  return;
+  _searchenv(file, var, path);
 }
 
@@ -3318,8 +1640,8 @@
  *           CRTDLL__seterrormode 	 (CRTDLL.261)
  */
-void CDECL CRTDLL__seterrormode(int i)
+void CDECL CRTDLL__seterrormode(int uMode)
 {
   dprintf2(("CRTDLL: _seterrormode\n"));
-  SetErrorMode(i);
+  SetErrorMode(uMode);
   return;
 }
@@ -3336,14 +1658,4 @@
 }
 
-/*********************************************************************
- *           CRTDLL__setjmp3 	 (CRTDLL.262)
- */
-int CDECL CRTDLL__setjmp3( jmp_buf env )
-{
-  //TODO:
-  dprintf2(("CRTDLL: _setjmp3 -> setjmp (NOT IDENTICAL!!!)\n"));
-  return(setjmp( env));
-}
-
 
 /*********************************************************************
@@ -3358,20 +1670,9 @@
 
 /*********************************************************************
- *                  _setsystime    (CRTDLL.264)
- */
-unsigned int CDECL CRTDLL__setsystime(struct tm *tp, unsigned int ms)
-{
-  dprintf(("CRTDLL: _setsystime not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
-}
-
-
-/*********************************************************************
  *                  _sleep           (CRTDLL.265)
  */
 VOID CDECL CRTDLL__sleep(unsigned long timeout) 
 {
-  dprintf2(("CRTDLL__sleep for %ld milliseconds\n",timeout));
+  dprintf2(("_sleep for %ld milliseconds\n",timeout));
   Sleep((timeout)?timeout:1);
 }
@@ -3379,31 +1680,10 @@
 
 /*********************************************************************
- *           _sopen 	 (CRTDLL.268)
- */
-int CDECL CRTDLL__sopen( const char *s, int i1, int i2, ... )
-{
-  dprintf(("CRTDLL: _sopen not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
-}
-
-
-/*********************************************************************
  *           CRTDLL__spawnl 	 (CRTDLL.269)
  */
-int CDECL CRTDLL__spawnl(int nMode, const char* szPath, const char* szArgv0,...)
+int CDECL CRTDLL__spawnl(int nMode, char* szPath, char* szArgv0, va_list arg)
 {
   dprintf2(("CRTDLL: _spawnl\n"));
-  char *szArg[100];
-  const char *a;
-  int i = 0;
-  va_list l = 0;
-  va_start(l,szArgv0);
-  do {
-  	a = va_arg(l,const char *);
-	szArg[i++] = (char *)a;
-  } while ( a != NULL && i < 100 );
-  
-  return _spawnve(nMode, (char*)szPath, szArg, _environ);
+  return (_spawnl(nMode, szPath, szArgv0, arg));
 }
 
@@ -3412,29 +1692,8 @@
  *           CRTDLL__spawnle 	 (CRTDLL.270)
  */
-int CDECL CRTDLL__spawnle( int mode, char *path, char **szArgv0, ... )
-{
-  dprintf2(("CRTDLL: _spawnle not correct implemented.\n"));
-  char *szArg[100];
-  char *a;
-  char *ptr;
-  int i = 0;
-  va_list l = 0;
-  va_start(l,szArgv0);
-  do {
-  	a = (char*)va_arg(l,const char *);
-	szArg[i++] = (char *)a;
-  } while ( a != NULL && i < 100 );
-
-
-// szArg0 is passed and not environment if there is only one parameter;
-
-  if ( i >=2 ) {
-  	ptr = szArg[i-2];
-  	szArg[i-2] = NULL;
-  }
-  else
-	ptr = NULL;
-
-  return _spawnve(mode, path, szArg, (char**)ptr);
+int CDECL CRTDLL__spawnle( int mode, char *path, char **szArgv0, va_list arg )
+{
+  dprintf2(("CRTDLL: _spawnle\n"));
+  return (_spawnle(mode, path, (char*)szArgv0, arg));
 }
 
@@ -3443,17 +1702,8 @@
  *           CRTDLL__spawnlp 	 (CRTDLL.271)
  */
-int CDECL CRTDLL__spawnlp(int nMode, const char* szPath, const char* szArgv0, ...)
+int CDECL CRTDLL__spawnlp(int nMode, char* szPath, char* szArgv0, va_list arg)
 {
   dprintf2(("CRTDLL: _spawnlp\n"));
-  char *szArg[100];
-  const char *a;
-  int i = 0;
-  va_list l = 0;
-  va_start(l,szArgv0);
-  do {
-  	a = (const char *)va_arg(l,const char *);
-	szArg[i++] = (char *)a;
-  } while ( a != NULL && i < 100 );
-  return _spawnvpe(nMode, (char*)szPath,szArg, _environ);
+  return (_spawnlp(nMode, szPath, szArgv0, arg));
 }
 
@@ -3462,29 +1712,8 @@
  *           CRTDLL__spawnlpe 	 (CRTDLL.272)
  */
-int CDECL CRTDLL__spawnlpe( int mode, char *path, char *szArgv0, ... )
-{
-  dprintf2(("CRTDLL: _spawnlpe not correct implemented.\n"));
-  char *szArg[100];
-  const char *a;
-  char *ptr;
-  int i = 0;
-  va_list l = 0;
-  va_start(l,szArgv0);
-  do {
-  	a = (char *)va_arg(l,const char *);
-	szArg[i++] = (char *)a;
-  } while ( a != NULL && i < 100 );
-
-
-// szArg0 is passed and not environment if there is only one parameter;
-
-  if ( i >=2 ) {
-  	ptr = szArg[i-2];
-  	szArg[i-2] = NULL;
-  }
-  else
-	ptr = NULL;
-
-  return _spawnvpe(mode, path, szArg, (char**)ptr);
+int CDECL CRTDLL__spawnlpe( int mode, char *path, char *szArgv0, va_list arg )
+{
+  dprintf2(("CRTDLL: _spawnlpe\n"));
+  return (_spawnlpe(mode, path, szArgv0, arg));
 }
 
@@ -3530,4 +1759,14 @@
 
 /*********************************************************************
+ *           _splitpath     	 (CRTDLL.277)
+ */
+void CDECL CRTDLL__splitpath( char *path, char *drive, char *dir, char *fname, char *ext )
+{
+  dprintf2(("CRTDLL: _splitpath"));
+  _splitpath( path, drive, dir, fname, ext);
+}
+
+
+/*********************************************************************
  *           CRTDLL__stat   	 (CRTDLL.278)
  */
@@ -3550,173 +1789,4 @@
 
 /*********************************************************************
- *           CRTDLL__strdate   	 (CRTDLL.281)
- */
-char * CDECL CRTDLL__strdate( char *buf )
-{
-  dprintf2(("CRTDLL: _strdate\n"));
-  return(_strdate(buf));
-}
-
-
-/*********************************************************************
- *           CRTDLL__strdec    	 (CRTDLL.282)
- */
-char * CDECL CRTDLL__strdec( const char *, const char *p ) 
-{
-  dprintf2(("CRTDLL: _strdec\n"));
-  return( (char *)(p-1) );
-}
-
-
-/*********************************************************************
- *           CRTDLL__strdup    	 (CRTDLL.283)
- */
-LPSTR CDECL CRTDLL__strdup(LPCSTR ptr)
-{
-  dprintf2(("CRTDLL: _strdup\n"));
-  return HEAP_strdupA(GetProcessHeap(),0,ptr);
-}
-
-
-/*********************************************************************
- *           _strerror  	 (CRTDLL.284)
- */
-char * CDECL CRTDLL__strerror(const char *s)
-{
-  dprintf(("CRTDLL: _strerror not implemented\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
-//  return (_strerror(s));
-}
-
-
-/*********************************************************************
- *           CRTDLL__stricoll  	 (CRTDLL.286)
- */
-int CDECL CRTDLL__stricoll( const char *s1, const char *s2 )
-{
-  dprintf2(("CRTDLL: _stricoll\n"));
-  return stricmp(s1,s2);
-}
-
-
-/*********************************************************************
- *           CRTDLL__strinc  	 (CRTDLL.287)
- */
-char * CDECL CRTDLL__strinc( const char *p )
-{
-    dprintf2(("CRTDLL: _strinc\n"));
-    return( (char *)(p+1) );
-}
-
-
-/*********************************************************************
- *           CRTDLL__strncnt	 (CRTDLL.289)
- */
-size_t CDECL CRTDLL__strncnt( const char *p, size_t l ) 
-{
-    dprintf2(("CRTDLL: _strncnt\n"));
-    size_t i;
-    i = strlen(p);
-    return( (i>l) ? l : i );
-}
-
-/*********************************************************************
- *           CRTDLL__strnextc	 (CRTDLL.290)
- */
-unsigned int CDECL CRTDLL__strnextc( const char *p )
-{
-    dprintf2(("CRTDLL: _strnextc\n"));
-    return( (unsigned int)*p );
-}
-
-
-/*********************************************************************
- *           CRTDLL__strninc	 (CRTDLL.292)
- */
-char * CDECL CRTDLL__strninc( const char *p, size_t l )
-{
-    dprintf2(("CRTDLL: _strninc\n"));
-    return( (char *)(p+l) );
-}
-
-
-/*********************************************************************
- *           CRTDLL__strnset	 (CRTDLL.293)
- */
-char * CDECL CRTDLL__strnset(char* szToFill, int szFill, size_t sizeMaxFill)
-{
-  dprintf2(("CRTDLL: _strnset\n"));
-  char *t = szToFill;
-  int i = 0;
-  while( *szToFill != 0 && i < sizeMaxFill)
-  {
- 	*szToFill = szFill;
-	szToFill++;
-	i++;
-  }
-  return t;
-}
-
-
-/*********************************************************************
- *           CRTDLL__strrev	 (CRTDLL.294)
- */
-char * CDECL CRTDLL__strrev( char *s )
-{
-  dprintf2(("CRTDLL: _strrev\n"));
-  char  *e;
-  char   a;
-  e=s;
-  while (*e)
-	e++;
-  while (s<e) {
- 	a=*s;
-	*s=*e;
-	*e=a;
-	s++;
-	e--;
-  }
-  return s;
-}
-
-
-/*********************************************************************
- *           CRTDLL__strset	 (CRTDLL.295)
- */
-char * CDECL CRTDLL__strset(char* szToFill, int szFill)
-{
-  dprintf2(("CRTDLL: _strset\n"));
-  char *t = szToFill;
-  while( *szToFill != 0 )
-  {
- 	*szToFill = szFill;
-	szToFill++;
-  }
-  return t;
-}
-
-
-/*********************************************************************
- *           CRTDLL__strspnp	 (CRTDLL.296)
- */
-char * CDECL CRTDLL__strspnp( const char *p1, const char *p2 ) 
-{
-    dprintf2(("CRTDLL: _strspnp\n"));
-    return( (*(p1 += strspn(p1,p2))!='\0') ? (char*)p1 : NULL );
-}
-
-
-/*********************************************************************
- *           CRTDLL__strtime	 (CRTDLL.297)
- */
-char * CDECL CRTDLL__strtime( char *buf )
-{
-  dprintf2(("CRTDLL: _strtime\n"));
-  return (_strtime(buf));
-}
-
-
-/*********************************************************************
  *           CRTDLL__swab	 (CRTDLL.299)
  */
@@ -3769,10 +1839,10 @@
 
 /*********************************************************************
- *           _tzset 	 (CRTDLL.308)
- */
-void CDECL CRTDLL__tzset( void )
-{
-  dprintf(("CRTDLL: _tzset not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+ *           _ultoa		 (CRTDLL.309)
+ */
+LPSTR  CDECL CRTDLL__ultoa(long x,LPSTR buf,INT radix)
+{
+  dprintf2(("CRTDLL: _ultoa\n"));
+  return _ultoa(x,buf,radix);
 }
 
@@ -3823,5 +1893,5 @@
 
 /*********************************************************************
- *           CRTDLL__unloaddll	 (CRTDLL.313)
+ *           _unloaddll	 (CRTDLL.313)
  */
 int CDECL CRTDLL__unloaddll(void *handle)
@@ -3833,5 +1903,5 @@
 
 /*********************************************************************
- *           CRTDLL__utime	 (CRTDLL.314)
+ *           _utime		 (CRTDLL.314)
  */
 int CDECL CRTDLL__utime( char *path, struct utimbuf * times )
@@ -3843,80 +1913,14 @@
 
 /*********************************************************************
- *           CRTDLL__vsnwprintf	 (CRTDLL.316)
- */
-int CDECL CRTDLL__vsnwprintf( wchar_t *s1, size_t n, const wchar_t *s2, va_list arg )
-{
-  dprintf(("CRTDLL: _vsnwprintf not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
-}
-
-
-/*********************************************************************
- *           CRTDLL__wcsdup	 (CRTDLL.317)
- */
-LPWSTR CDECL CRTDLL__wcsdup( LPCWSTR str )
-{
-  dprintf2(("CRTDLL: _wcsdup\n"));
-  LPWSTR ret = NULL;
-  if (str)
-  {
-      int size = (wcslen((const wchar_t*)str) + 1) * sizeof(WCHAR);
-// FIXME      ret = CRTDLL_malloc( size );
-      if (ret) memcpy( ret, str, size );
-  }
-  return ret;
-}
-
-
-/*********************************************************************
- *           CRTDLL__wcsicoll	 (CRTDLL.319)
- */
-int CDECL CRTDLL__wcsicoll( LPCWSTR str1, LPCWSTR str2 )
-{
-  dprintf2(("CRTDLL: _wcsicoll\n"));
-  return CRTDLL__wcsicmp( str1, str2 );
-}
-
-
-/*********************************************************************
- *           CRTDLL__wcsnset    (CRTDLL.322)
- */
-LPWSTR CDECL CRTDLL__wcsnset( LPWSTR str, WCHAR c, INT n )
-{
-    dprintf2(("CRTDLL: _wcsnset\n"));
-    LPWSTR ret = str;
-    while ((n-- > 0) && *str) *str++ = c;
-    return ret;
-}
-
-
-/*********************************************************************
- *           CRTDLL__wcsrev	 (CRTDLL.323)
- */
-LPWSTR CDECL CRTDLL__wcsrev( LPWSTR str )
-{
-  dprintf2(("CRTDLL: _wcsrev\n"));
-  LPWSTR ret = str;
-  LPWSTR end = str + wcslen((const wchar_t*)str) - 1;
-  while (end > str)
-  {
-      WCHAR t = *end;
-      *end--  = *str;
-      *str++  = t;
-  }
-  return ret;
-}
-
-
-/*********************************************************************
- *           CRTDLL__wcsset    (CRTDLL.324)
- */
-LPWSTR CDECL CRTDLL__wcsset( LPWSTR str, WCHAR c )
-{
-    dprintf2(("CRTDLL: _wcsset\n"));
-    LPWSTR ret = str;
-    while (*str) *str++ = c;
-    return ret;
+ *	_vsnprintf			 	(CRTDLL.315)
+ */
+int CDECL CRTDLL__vsnprintf( char *s, size_t bufsize, const char *format, va_list arg )
+{
+  dprintf2(("CRTDLL: _vsnprintf(%08xh, %08xh, %08xh)\n",
+           s,
+           bufsize,
+           format));
+
+  return wvsnprintfA(s, bufsize, format, arg);
 }
 
@@ -3973,5 +1977,5 @@
 
 /*********************************************************************
- *                  isleadbyte	(CRTDLL.335)
+ *                  abort     	(CRTDLL.335)
  */
 void CDECL CRTDLL_abort( void )
@@ -3983,5 +1987,17 @@
 
 /*********************************************************************
- *                  acos	(CRTDLL.336)
+ *                  abs		(CRTDLL.336)
+ */
+double CDECL CRTDLL_abs(double d)
+{
+  dprintf2(("CRTDLL: abs(%f)\n",
+           d));
+
+  return (abs(d));
+}
+
+
+/*********************************************************************
+ *                  acos	(CRTDLL.337)
  */
 double CDECL CRTDLL_acos( double x )
@@ -4013,4 +2029,16 @@
 
 /*********************************************************************
+ *                  atan 	(CRTDLL.340)
+ */
+double CDECL CRTDLL_atan(double d)
+{
+  dprintf2(("CRTDLL: atan(%f)\n",
+           d));
+
+  return (atan(d));
+}
+
+
+/*********************************************************************
  *                  atan2	(CRTDLL.341)
  */
@@ -4025,9 +2053,11 @@
  *                  atexit	(CRTDLL.342)
  */
-int CDECL CRTDLL_atexit( register void ( *func )( void ) )
-{
-  dprintf(("CRTDLL: atexit not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
+int CDECL CRTDLL_atexit(void (*func)(void))
+{
+  dprintf(("CRTDLL: atexit\n"));
+  if (_atexit_n >= sizeof (_atexit_v) / sizeof (_atexit_v[0]))
+    return -1;
+  _atexit_v[_atexit_n++] = func;
+  return 0;
 }
 
@@ -4042,4 +2072,57 @@
 }
 
+
+/*********************************************************************
+ *                  atoi 	(CRTDLL.344)
+ */
+int CDECL CRTDLL_atoi(LPSTR str)
+{
+  dprintf2(("CRTDLL: atoi(%s)\n",
+           str));
+
+  return (atoi(str));
+}
+
+
+/*********************************************************************
+ *                  atol 	(CRTDLL.345)
+ */
+long CDECL CRTDLL_atol(LPSTR str)
+{
+  dprintf2(("CRTDLL: atol(%s)\n",
+           str));
+
+  return (atol(str));
+}
+
+
+/*********************************************************************
+ *                  bsearch	(CRTDLL.346)
+ */
+void *CDECL CRTDLL_bsearch (const void *key, const void *base, size_t num, size_t width,
+                     int (* CDECL compare)(const void *key, const void *element))
+{
+  int left, right, median, sign;
+  const void *element;
+  
+  if (width == 0)
+    return 0;
+  left = 1; right = num;
+  while (left <= right)
+    {
+      median = (left + right) / 2;
+      element = (void *)((char *)base + (median-1)*width);
+      sign = compare (key, element);
+      if (sign == 0)
+        return (void *)element;
+      if (sign > 0)
+        left = median + 1;
+      else
+        right = median - 1;
+    }
+  return 0;
+}
+
+
 /*********************************************************************
  *                  calloc	(CRTDLL.347)
@@ -4053,4 +2136,15 @@
 
 /*********************************************************************
+ *                  ceil  	(CRTDLL.348)
+ */
+double CDECL CRTDLL_ceil(double d)
+{
+  dprintf2(("CRTDLL: ceil(%f)\n",
+           d));
+  return (ceil(d));
+}
+
+
+/*********************************************************************
  *                  clearerr	(CRTDLL.349)
  */
@@ -4073,4 +2167,16 @@
 
 /*********************************************************************
+ *                  cos 	(CRTDLL.351)
+ */
+double CDECL CRTDLL_cos(double d)
+{
+  dprintf2(("CRTDLL: cos(%f)\n",
+           d));
+
+  return (cos(d));
+}
+
+
+/*********************************************************************
  *                  cosh	(CRTDLL.352)
  */
@@ -4133,4 +2239,16 @@
 
 /*********************************************************************
+ *                  fabs  	(CRTDLL.358)
+ */
+double CDECL CRTDLL_fabs(double d)
+{
+  dprintf2(("CRTDLL: fabs(%f)\n",
+           d));
+
+  return (fabs(d));
+}
+
+
+/*********************************************************************
  *                  fclose	(CRTDLL.359)
  */
@@ -4203,10 +2321,12 @@
 
 /*********************************************************************
- *                  fgetwc	(CRTDLL.366)
- */
-wint_t CDECL CRTDLL_fgetwc( FILE *f )
-{
-  dprintf2(("CRTDLL: fgetwc\n"));
-  return (fgetwc(f));
+ *                  floor		(CRTDLL.367)
+ */
+double CDECL CRTDLL_floor(double d)
+{
+  dprintf2(("CRTDLL: floor(%f)\n",
+           d));
+
+  return (floor(d));
 }
 
@@ -4235,14 +2355,8 @@
  *                  fprintf       (CRTDLL.370)
  */
-INT CDECL CRTDLL_fprintf( CRTDLL_FILE *file, LPSTR format, ... )
+INT CDECL CRTDLL_fprintf( FILE *file, LPSTR format, va_list arg )
 {
     dprintf2(("CRTDLL: fprintf\n"));
-    va_list valist;
-    INT res;
-
-    va_start( valist, format );
-    res = CRTDLL_vfprintf( file, format, valist );
-    va_end( valist );
-    return res;
+    return (fprintf(file, format, arg));
 }
 
@@ -4268,13 +2382,4 @@
 
 
-/*********************************************************************
- *                  fputwc  (CRTDLL.373)
- */
-wint_t CDECL CRTDLL_fputwc( wint_t wc, FILE *strm )
-{
-  dprintf2(("CRTDLL: fputwc\n"));
-  return (fputwc(wc, strm));
-}
-
 
 /*********************************************************************
@@ -4321,20 +2426,8 @@
  *                  fscanf	  (CRTDLL.378)
  */
-int CDECL CRTDLL_fscanf( FILE*fp, const char *format, ... )
+int CDECL CRTDLL_fscanf( FILE*fp, const char *format, va_list arg )
 {
   dprintf2(("CRTDLL: fscanf\n"));
-#if 0
-    va_list valist;
-    INT res;
-
-    va_start( valist, format );
-#ifdef HAVE_VFSCANF
-    res = vfscanf( xlat_file_ptr(stream), format, valist );
-#endif
-    va_end( valist );
-    return res;
-#endif
-    dprintf2(("broken\n"));
-    return 0;
+  return (fscanf(fp, format, arg));
 }
 
@@ -4346,12 +2439,5 @@
 {
   dprintf2(("CRTDLL: fseek\n"));
-  dprintf2(("file %p to 0x%08lx pos %s\n",
-        file,offset,(whence==SEEK_SET)?"SEEK_SET":
-        (whence==SEEK_CUR)?"SEEK_CUR":
-        (whence==SEEK_END)?"SEEK_END":"UNKNOWN"));
-// FIXME if (SetFilePointer( file->handle, offset, NULL, whence ) != 0xffffffff)
-// FIXME     return 0;
-  dprintf2((" failed!\n"));
-  return -1;
+  return (fseek(file, offset, whence));
 }
 
@@ -4378,37 +2464,10 @@
 
 /*********************************************************************
- *                  fwprintf 	  (CRTDLL.382)
- */
-int CDECL CRTDLL_fwprintf( FILE *iop, const wchar_t *fmt, ... )
-{
-  dprintf(("CRTDLL: fwprintf not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
-}
-
-
-/*********************************************************************
  *                  fwrite     (CRTDLL.383)
  */
-DWORD CDECL CRTDLL_fwrite( LPVOID ptr, INT size, INT nmemb, CRTDLL_FILE *file )
-{
-    DWORD ret;
-
+DWORD CDECL CRTDLL_fwrite( LPVOID ptr, INT size, INT nmemb, FILE *file )
+{
     dprintf2(("CRTDLL: fwrite\n"));
-    if (!WriteFile( file->handle, ptr, size * nmemb, &ret, NULL ))
-        dprintf2((" failed!\n"));
-
-    return ret / size;
-}
-
-
-/*********************************************************************
- *                  fwscanf 	  (CRTDLL.384)
- */
-int CDECL CRTDLL_fwscanf( FILE *strm, const wchar_t *format, ... )
-{
-  dprintf(("CRTDLL: fwscanf not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
+    return (fwrite( ptr, size, nmemb, file));
 }
 
@@ -4465,14 +2524,4 @@
 
 /*********************************************************************
- *                  is_wctype    (CRTDLL.390)
- */
-INT CDECL CRTDLL_is_wctype(wint_t wc, wctype_t wctypeFlags)
-{
-        dprintf2(("CRTDLL: is_wctype\n"));
-	return ((CRTDLL_pwctype_dll[(unsigned char)(wc & 0xFF)]&wctypeFlags) == wctypeFlags );
-}
-
-
-/*********************************************************************
  *                  isalnum    (CRTDLL.391)
  */
@@ -4485,4 +2534,16 @@
 
 /*********************************************************************
+ *                  isalpha    (CRTDLL.392)
+ */
+int CDECL CRTDLL_isalpha(int i)
+{
+  dprintf2(("CRTDLL: isalpha(%08xh)\n",
+           i));
+
+  return (isalpha(i));
+}
+
+
+/*********************************************************************
  *                  iscntrl    (CRTDLL.393)
  */
@@ -4495,4 +2556,16 @@
 
 /*********************************************************************
+ *                  isdigit    (CRTDLL.394)
+ */
+int CDECL CRTDLL_isdigit(int i)
+{
+  dprintf2(("CRTDLL: isdigit(%08xh)\n",
+           i));
+
+  return (isdigit(i));
+}
+
+
+/*********************************************************************
  *                  isgraph    (CRTDLL.395)
  */
@@ -4505,11 +2578,24 @@
 
 /*********************************************************************
- *                  isleadbyte	(CRTDLL.396)
- */
-int CDECL CRTDLL_isleadbyte(int i)
-{
-  dprintf(("CRTDLL: isleadbyte(%08xh) not implemented.\n", i));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
+ *                  islower    (CRTDLL.397)
+ */
+int CDECL CRTDLL_islower(int i)
+{
+  dprintf2(("CRTDLL: islower(%08xh)\n",
+           i));
+
+  return (islower(i));
+}
+
+
+/*********************************************************************
+ *                  isprint    (CRTDLL.398)
+ */
+int CDECL CRTDLL_isprint(int i)
+{
+  dprintf2(("CRTDLL: isprint(%08xh)\n",
+           i));
+
+  return (isprint(i));
 }
 
@@ -4526,110 +2612,44 @@
 
 /*********************************************************************
- *                  iswalnum    (CRTDLL.402)
- */
-int CDECL CRTDLL_iswalnum(wint_t i)
-{
-  dprintf2(("CRTDLL: iswalnum(%08xh)\n", i));
-  return (iswalnum(i));
-}
-
-
-/*********************************************************************
- *                  iswascii    (CRTDLL.404)
- */
-int CDECL CRTDLL_iswascii(wint_t c)
-{
-  dprintf2(("CRTDLL: iswascii\n", c));
-  return  (!((c)&(~0x7f)));
-}
-
-
-/*********************************************************************
- *                  iswcntrl    (CRTDLL.405)
- */
-int CDECL CRTDLL_iswcntrl(wint_t i)
-{
-  dprintf2(("CRTDLL: iswcntrl(%08xh)\n", i));
-  return (iswcntrl(i));
-}
-
-
-/*********************************************************************
- *                  iswdigit    (CRTDLL.407)
- */
-int CDECL CRTDLL_iswdigit(wint_t i)
-{
-  dprintf2(("CRTDLL: iswdigit(%08xh)\n", i));
-  return (iswdigit(i));
-}
-
-
-/*********************************************************************
- *                  iswgraph    (CRTDLL.408)
- */
-int CDECL CRTDLL_iswgraph(wint_t i)
-{
-  dprintf2(("CRTDLL: iswgraph(%08xh)\n", i));
-  return (iswgraph(i));
-}
-
-
-/*********************************************************************
- *                  iswlower    (CRTDLL.409)
- */
-int CDECL CRTDLL_iswlower(wint_t i)
-{
-  dprintf2(("CRTDLL: iswlower(%08xh)\n", i));
-  return (iswlower(i));
-}
-
-
-/*********************************************************************
- *                  iswprint    (CRTDLL.410)
- */
-int CDECL CRTDLL_iswprint(wint_t i)
-{
-  dprintf2(("CRTDLL: iswprint(%08xh)\n", i));
-  return (iswprint(i));
-}
-
-
-/*********************************************************************
- *                  iswpunct    (CRTDLL.411)
- */
-int CDECL CRTDLL_iswpunct(wint_t i)
-{
-  dprintf2(("CRTDLL: iswpunct(%08xh)\n", i));
-  return (iswpunct(i));
-}
-
-
-/*********************************************************************
- *                  iswspace    (CRTDLL.412)
- */
-int CDECL CRTDLL_iswspace(wint_t i)
-{
-  dprintf2(("CRTDLL: iswspace(%08xh)\n", i));
-  return (iswspace(i));
-}
-
-
-/*********************************************************************
- *                  iswupper    (CRTDLL.413)
- */
-int CDECL CRTDLL_iswupper(wint_t i)
-{
-  dprintf2(("CRTDLL: iswupper(%08xh)\n", i));
-  return (iswupper(i));
-}
-
-
-/*********************************************************************
- *                  iswxdigit    (CRTDLL.414)
- */
-int CDECL CRTDLL_iswxdigit(wint_t i)
-{
-  dprintf2(("CRTDLL: iswxdigit(%08xh)\n", i));
-  return (iswxdigit(i));
+ *                  isspace    (CRTDLL.400)
+ */
+int CDECL CRTDLL_isspace(int i)
+{
+  dprintf2(("CRTDLL: isspace(%08xh)\n",
+           i));
+
+  return (isspace(i));
+}
+
+
+/*********************************************************************
+ *                  isupper       (CRTDLL.401)
+ */
+int CDECL CRTDLL_isupper(int i)
+{
+  dprintf2(("CRTDLL: isupper(%08xh)\n",
+           i));
+
+  return (isupper(i));
+}
+
+
+/*********************************************************************
+ *                  isxdigit    (CRTDLL.415)
+ */
+int CDECL CRTDLL_isxdigit(int i)
+{
+  dprintf2(("CRTDLL: isxdigit(%08xh)\n", i));
+  return (isxdigit(i));
+}
+
+
+/*********************************************************************
+ *                  labs	(CRTDLL.416)
+ */
+long int CDECL CRTDLL_labs( long int j )
+{
+  dprintf2(("CRTDLL: labs(%08xh)\n", j));
+  return (labs(j));
 }
 
@@ -4676,4 +2696,14 @@
 
 /*********************************************************************
+ *                  log  	(CRTDLL.421)
+ */
+double CDECL CRTDLL_log( double x )
+{
+  dprintf2(("CRTDLL: log(%08xh)\n", x));
+  return (log(x));
+}
+
+
+/*********************************************************************
  *                  log10	(CRTDLL.422)
  */
@@ -4706,27 +2736,4 @@
 
 /*********************************************************************
- *                  mblen        (CRTDLL.425)
- */
-INT CDECL CRTDLL_mblen( const char *s, size_t n )
-{
-      dprintf2(("CRTDLL: mblen\n"));
-      return (mblen(s, n));
-}
-
-
-/*********************************************************************
- *           CRTDLL_mbtowc    (CRTDLL.427)
- */
-INT CDECL CRTDLL_mbtowc( WCHAR *dst, LPCSTR str, INT n )
-{
-    dprintf2(("CRTDLL: _mbtowc\n"));
-    wchar_t res;
-    int ret = mbtowc( &res, str, n );
-    if (dst) *dst = (WCHAR)res;
-    return ret;
-}
-
-
-/*********************************************************************
  *                  mktime   (CRTDLL.433)
  */
@@ -4759,16 +2766,20 @@
 
 /*********************************************************************
+ *                  pow      (CRTDLL.436)
+ */
+double CDECL CRTDLL_pow( double x, double y )	
+{
+    dprintf2(("CRTDLL: pow(%08xh, %08xh)\n",x, y));
+    return pow( x, y );
+}
+
+
+/*********************************************************************
  *                  printf   (CRTDLL.437)
  */
-int CDECL CRTDLL_printf( const char *format, ... )
+int CDECL CRTDLL_printf( const char *format, va_list arg )
 {
   dprintf2(("CRTDLL: printf\n"));
-  va_list arg;
-  int done;
-
-  va_start (arg, format);
-  done = vprintf (format, arg);
-  va_end (arg);
-  return done;
+  return (printf(format, arg));
 }
 
@@ -4805,4 +2816,16 @@
 
 /*********************************************************************
+ *                  qsort        (CRTDLL.441)
+ */
+void CDECL CRTDLL_qsort (void *base, size_t num, size_t width,
+                         int (*CDECL compare)(const void *x1, const void *x2))
+{
+  dprintf2(("CRTDLL: qsort\n"));
+  if (width > 0 && num > 1 && base != 0)
+    qsort1 ((char *)base, (char *)base+(num-1)*width, width, compare);
+}
+
+
+/*********************************************************************
  *                  raise        (CRTDLL.442)
  */
@@ -4837,10 +2860,8 @@
  *                  remove           (CRTDLL.445)
  */
-INT CDECL CRTDLL_remove(LPCSTR file)
-{
-        dprintf2(("CRTDLL: remove\n"));
-	if (!DeleteFileA(file))
-		return -1;
-	return 0;
+INT CDECL CRTDLL_remove(const char* file)
+{
+  dprintf2(("CRTDLL: remove\n"));
+  return (remove(file));
 }
 
@@ -4867,14 +2888,13 @@
 
 /*********************************************************************
- *                  scanf       (CRTDLL.448)
- */
-int CDECL CRTDLL_scanf( const char *format, ... )
-{
-  dprintf(("CRTDLL: scanf not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
-}
-
-	
+ *	scanf					(CRTDLL.448)
+ */
+int CDECL CRTDLL_scanf( const char *format, va_list arg )
+{
+  dprintf(("CRTDLL: scanf\n"));
+  return (scanf(format, arg));
+}
+
+
 /*********************************************************************
  *                  setbuf      (CRTDLL.449)
@@ -4910,8 +2930,18 @@
  *                  signal       (CRTDLL.452)
  */
-void CDECL CRTDLL_signal( int sig, void (*func)(int)) 
-{
-    dprintf(("CRTDLL: signal not implemented.\n"));
-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+_SigFunc CDECL CRTDLL_signal(int sig, _SigFunc func)
+{
+  dprintf(("CRTDLL: signal\n"));
+  return (signal(sig, func));
+}
+
+
+/*********************************************************************
+ *                  sin          (CRTDLL.453)
+ */
+double CDECL CRTDLL_sin( double x )
+{
+  dprintf2(("CRTDLL: sin(%08xh)\n", x));
+  return (sin(x));
 }
 
@@ -4928,4 +2958,38 @@
 
 /*********************************************************************
+ *                  sprintf      (CRTDLL.455)
+ */
+LPSTR CDECL CRTDLL_sprintf(LPSTR lpstrBuffer,
+                       LPSTR lpstrFormat,
+                       ...)
+{
+  va_list argptr;                          /* -> variable argument list */
+
+  dprintf2(("CRTDLL: sprintf(%08xh,%s)\n",
+           lpstrBuffer,
+           lpstrFormat));
+
+  va_start(argptr,
+           lpstrFormat);                   /* get pointer to argument list */
+  vsprintf(lpstrBuffer,
+           lpstrFormat,
+           argptr);
+  va_end(argptr);                          /* done with variable arguments */
+
+  return (lpstrBuffer);
+}
+
+
+/*********************************************************************
+ *                  sqrt         (CRTDLL.456)
+ */
+double CDECL CRTDLL_sqrt( double x )
+{
+  dprintf2(("CRTDLL: sqrt(%08xh)\n", x));
+  return (sqrt(x));
+}
+
+
+/*********************************************************************
  *                  srand        (CRTDLL.457)
  */
@@ -4938,91 +3002,10 @@
 
 /*********************************************************************
- *                  strcoll        (CRTDLL.462)
- */
-int CDECL CRTDLL_strcoll( const char *s1, const char *s2 )
-{
-  dprintf2(("CRTDLL: strcoll\n"));
-  return strcoll(s1, s2);
-}
-
-
-/*********************************************************************
- *                  strerror        (CRTDLL.465)
- */
-char * CDECL CRTDLL_strerror( int errnum )
-{
-  dprintf2(("CRTDLL: strerror\n"));
-  return strerror(errnum);
-}
-
-
-/*********************************************************************
- *                  strftime        (CRTDLL.466)
- */
-size_t CDECL CRTDLL_strftime( char *s, size_t maxsiz, const char *fmt, const struct tm *tp )
-{
-  dprintf2(("CRTDLL: strftime\n"));
-  return strftime(s, maxsiz, fmt, tp);
-}
- 
-
-/*********************************************************************
- *                  strtod        (CRTDLL.475)
- */
-double CDECL CRTDLL_strtod( const char *nptr, char **endptr )
-{
-  dprintf2(("CRTDLL: strtod\n"));
-  return strtod(nptr, endptr);
-}
-
-
-/*********************************************************************
- *                  strtok        (CRTDLL.476)
- */
-char * CDECL CRTDLL_strtok( char *s1, const char *s2 )
-{
-  dprintf2(("CRTDLL: strtok\n"));
-  return strtok(s1, s2);
-}
-
-
-/*********************************************************************
- *                  strtol        (CRTDLL.477)
- */
-long int CDECL CRTDLL_strtol( const char *nptr, char **endptr, int base )
-{
-  dprintf2(("CRTDLL: strtol\n"));
-  return strtol(nptr, endptr, base);
-}
-
-
-/*********************************************************************
- *                  strtoul        (CRTDLL.478)
- */
-unsigned long CDECL CRTDLL_strtoul( const char *nptr, char **endptr, int base )
-{
-  dprintf2(("CRTDLL: strtoul\n"));
-  return strtoul(nptr, endptr, base);
-}
-
-
-/*********************************************************************
- *                  strxfrm        (CRTDLL.479)
- */
-size_t CDECL CRTDLL_strxfrm( char *s1, const char *s2, size_t n )
-{
-  dprintf2(("CRTDLL: strxfrm\n"));
-  return strxfrm(s1, s2, n);
-}
-
-
-/*********************************************************************
- *                  swscanf           (CRTDLL.481)
- */
-int CDECL CRTDLL_swscanf( const wchar_t *s1, const wchar_t *s2, ... )
-{
-  dprintf(("CRTDLL: swscanf not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
+ *	sscanf					(CRTDLL.458)
+ */
+int CDECL CRTDLL_sscanf( const char *s, const char *format, va_list arg )
+{
+  dprintf(("CRTDLL: sscanf\n"));
+  return (sscanf(s, format, arg));
 }
 
@@ -5039,5 +3022,17 @@
 
 /*********************************************************************
- *                  tanh           (CRTDLL.485)
+ *                  tan           (CRTDLL.483)
+ */
+double CDECL CRTDLL_tan(double d)
+{
+  dprintf2(("CRTDLL: tan(%f)\n",
+           d));
+
+  return (tan(d));
+}
+
+
+/*********************************************************************
+ *                  tanh           (CRTDLL.484)
  */
 double CDECL CRTDLL_tanh( double x )
@@ -5080,43 +3075,34 @@
 
 /*********************************************************************
- *                  ungetc           (CRTDLL.492)
- */
-INT CDECL CRTDLL_ungetc(int c, FILE *f)
-{
-  dprintf(("CRTDLL: ungetc not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
-}
-
-
-/*********************************************************************
- *                  ungetwc           (CRTDLL.493)
- */
-wint_t CDECL CRTDLL_ungetwc( wint_t wc, FILE *strm )
-{
-  dprintf2(("CRTDLL: ungetwc\n"));
-  return (ungetwc(wc, strm));
-}
+ *                  tolower       (CRTDLL.488)
+ */
+int CDECL CRTDLL_tolower(int c)
+{
+  dprintf2(("CRTDLL: tolower(%c)\n",
+           c));
+
+  return (tolower(c));
+}
+
+
+/*********************************************************************
+ *                  toupper       (CRTDLL.489)
+ */
+int CDECL CRTDLL_toupper(int c)
+{
+  dprintf2(("CRTDLL: toupper(%c)\n",
+           c));
+
+  return (toupper(c));
+}
+
 
 /*********************************************************************
  *                  vfprintf       (CRTDLL.494)
  */
-INT CDECL CRTDLL_vfprintf( CRTDLL_FILE *file, LPSTR format, va_list args )
-{
-    dprintf2(("CRTDLL: vprintf\n"));
-    char buffer[2048];  /* FIXME... */
-    vsprintf( buffer, format, args );
-    return CRTDLL_fwrite( buffer, 1, strlen(buffer), file );
-}
-
-
-/*********************************************************************
- *                  vfwprintf     (CRTDLL.495)
- */
-int CDECL CRTDLL_vfwprintf( FILE *F, const wchar_t *s, va_list arg )
-{
-  dprintf(("CRTDLL: vfwprintf not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
+INT CDECL CRTDLL_vfprintf( FILE *file, LPSTR format, va_list args )
+{
+    dprintf2(("CRTDLL: vfprintf\n"));
+    return (vfprintf(file, format, args));
 }
 
@@ -5133,181 +3119,34 @@
 
 /*********************************************************************
- *                  vswprintf       (CRTDLL.498)
- */
-int CDECL CRTDLL_vswprintf( wchar_t *s , size_t t, const wchar_t *format, va_list arg )
-{
-  dprintf2(("CRTDLL: vswprintf\n"));
-  return (vswprintf(s, t, format, arg));
-}
-
-
-/*********************************************************************
- *                  vwprintf     (CRTDLL.499)
- */
-int CDECL CRTDLL_vwprintf( const wchar_t *s, va_list arg)
-{
-  dprintf(("CRTDLL: vwprintf not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
-}
-
-
-/*********************************************************************
- *                  wcscoll    (CRTDLL.503)
- */
-DWORD CDECL CRTDLL_wcscoll(LPCWSTR str1, LPCWSTR str2)
-{
-  dprintf2(("CRTDLL: wcscoll\n"));
-  return (wcscoll((const wchar_t*)str1, (const wchar_t*)str2));
-}
-
-
-/*********************************************************************
- *                  wcsftime   (CRTDLL.506)
- */
-size_t CDECL CRTDLL_wcsftime( wchar_t *s, size_t maxsize, 
-		const wchar_t *format, const struct tm *timeptr )
-{
-  dprintf2(("CRTDLL: wcsftime\n"));
-  return (wcsftime(s, maxsize, format, timeptr));
-}
-
-
-/*********************************************************************
- *                  wcstod   (CRTDLL.515)
- */
-double CDECL CRTDLL_wcstod( const wchar_t *nptr, wchar_t **endptr )
-{
-  dprintf2(("CRTDLL: wcstod\n"));
-  return (wcstod(nptr, endptr));
-}
-
-
-/*********************************************************************
- *                  wcsxfrm   (CRTDLL.520)
- */
-size_t CDECL CRTDLL_wcsxfrm( wchar_t *s1, const wchar_t *s2, size_t n )
-{
-  dprintf2(("CRTDLL: wcsxfrm\n"));
-  return (wcsxfrm(s1, s2, n));
-}
-
-
-/*********************************************************************
- *                  wctomb   (CRTDLL.521)
- */
-int CDECL CRTDLL_wctomb( LPSTR dst, WCHAR ch )
-{
-  dprintf2(("CRTDLL: wctomb\n"));
-  return (wctomb((char*)dst,ch));
-}
-
-
-/*********************************************************************
- *                  wprintf   (CRTDLL.522)
- */
-int CDECL CRTDLL_wprintf( const wchar_t *s, ... )
-{
-  dprintf(("CRTDLL: wprintf not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
-}
-
-
-/*********************************************************************
- *                  wscanf    (CRTDLL.523)
- */
-int CDECL CRTDLL_wscanf( const wchar_t *s, ... )
-{
-  dprintf(("CRTDLL: wscanf not implemented.\n"));
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
-}
-
-
-
-/*********************************************************************
- *                  __set_errno    (INTERNAL-#1)
- */
-int __set_errno (int error)
-{
-	errno = error;
-	return error;
-}
-
-
-/*********************************************************************
- *                  _mbbtoupper    (INTERNAL-#2)
- */
-unsigned int _mbbtoupper(unsigned int c)
-{
-	if (!CRTDLL__ismbblead(c) )
-		return toupper(c);
-	
-	return c;
-}
-
-
-/*********************************************************************
- *                  _mbbtolower    (INTERNAL-#3)
- */
-unsigned int _mbbtolower(unsigned int c)
-{
-	if (!CRTDLL__ismbblead(c) )
-		return tolower(c);
-	return c;
-}
-
-
-/*********************************************************************
- *                  _mbclen2    (INTERNAL-#4)
- */
-size_t _mbclen2(const unsigned int s)
-{
-	return (CRTDLL__ismbblead(s>>8) && CRTDLL__ismbbtrail(s&0x00FF)) ? 2 : 1;
-}
-
-
-/*********************************************************************
- *                  _isinf    (INTERNAL-#5)
- */
-int _isinf(double __x)
-{
-	double_t * x = (double_t *)&__x;
-	return ( x->exponent == 0x7ff  && ( x->mantissah == 0 && x->mantissal == 0 ));	
-}
-
-
-/*********************************************************************
- *                  _filehnd    (INTERNAL-#6)
- */
-void* filehnd(int fileno)
-{
-	if ( fileno < 0 )
-		return (void *)-1;
-#define STD_AUX_HANDLE 3
-#define STD_PRINTER_HANDLE 4
-
-	switch(fileno)
-	{
-	case 0:
-		return (void*)GetStdHandle(STD_INPUT_HANDLE);
-	case 1:
-		return (void*)GetStdHandle(STD_OUTPUT_HANDLE);
-	case 2:
-		return (void*)GetStdHandle(STD_ERROR_HANDLE);
-	case 3:
-		return (void*)GetStdHandle(STD_AUX_HANDLE);
-	case 4:
-		return (void*)GetStdHandle(STD_PRINTER_HANDLE);
-	default:
-		break;
-	}
-		
-	if ( fileno >= maxfno )
-		return (void *)-1;
-
-	if ( fileno_modes[fileno].fd == -1 )
-		return (void *)-1;
-	return (void*)fileno_modes[fileno].hFile;
-}
+ *                  vsprintf       (CRTDLL.497)
+ */
+int CDECL CRTDLL_vsprintf( char *s, const char *format, va_list arg )
+{
+  dprintf2(("CRTDLL: vsprintf(%08xh, %08xh)\n", s, format));
+  return (vsprintf(s, format, arg));
+}
+
+
+/*********************************************************************
+ *           CRTDLL__itow    	 (CRTDLL.600)
+ */
+char * CDECL CRTDLL__itow(int i, char *s, int r)
+{
+  dprintf(("CRTDLL: _itow(%08xh, %08xh, %08xh) no unicode support !\n",
+           i,
+           s,
+           r));
+
+  return (itoa(i,s,r));
+}
+
+
+/*********************************************************************
+ *           CRTDLL__setjmp3 	 (CRTDLL.600)
+ */
+int CDECL CRTDLL__setjmp3( jmp_buf env )
+{
+  //TODO:
+  dprintf2(("CRTDLL: _setjmp3 -> setjmp (NOT IDENTICAL!!!)\n"));
+  return(setjmp( env));
+}
Index: trunk/src/crtdll/crtimps.h
===================================================================
--- trunk/src/crtdll/crtimps.h	(revision 2618)
+++ trunk/src/crtdll/crtimps.h	(revision 2618)
@@ -0,0 +1,18 @@
+/* $Id: crtimps.h,v 1.1 2000-02-03 21:37:49 sandervl Exp $ */
+
+/* Definitions for the CRTDLL internal imports 
+ *
+ * Copyright 1999-2000 Jens Wiessner
+ *
+ */
+
+#ifndef _CRTINTIMP_H
+#define _CRTINTIMP_H
+
+
+int 		CDECL CRTDLL__getch(void);
+VOID* 		CDECL CRTDLL_malloc(DWORD size);
+int    		CDECL CRTDLL__wcsnicmp(LPCWSTR, LPCWSTR, int);
+extern USHORT 	*CRTDLL_pwctype_dll;
+
+#endif
Index: trunk/src/crtdll/crtinc.h
===================================================================
--- trunk/src/crtdll/crtinc.h	(revision 2617)
+++ trunk/src/crtdll/crtinc.h	(revision 2618)
@@ -1,10 +1,11 @@
-/* $Id: crtinc.h,v 1.13 1999-12-21 13:46:25 sandervl Exp $ */
+/* $Id: crtinc.h,v 1.14 2000-02-03 21:37:49 sandervl Exp $ */
 
 /* Definitions for the CRTDLL library (CRTDLL.DLL)
  *
- * Copyright 1999 Jens Wiessner
+ * Copyright 1999-2000 Jens Wiessner
+ *
  */
 
-#define MB_LEN_MAX	2
+
 #ifndef MAX_PATHNAME_LEN 
 #define MAX_PATHNAME_LEN 260 
@@ -16,53 +17,11 @@
 #define Heap_Free(a)	HeapFree(CRTDLL_hHeap, 0, (PVOID)a)
 
-// MBC Defs
-#define _MBC_SINGLE	 0	
-#define _MBC_LEAD	 1	
-#define _MBC_TRAIL	 2		
-#define _MBC_ILLEGAL	-1		
-
-#define _MB_CP_SBCS      0
-#define _MB_CP_OEM      -2
-#define _MB_CP_ANSI     -3
-#define _MB_CP_LOCALE   -4
-
-#define _KNJ_M  ((char)0x01)    /* Non-punctuation of Kana-set */
-#define _KNJ_P  ((char)0x02)    /* Punctuation of Kana-set */
-#define _KNJ_1  ((char)0x04)    /* Legal 1st byte of double byte stream */
-#define _KNJ_2  ((char)0x08)    /* Legal 2nd btye of double byte stream */
-
-#define ___     0
-#define _1_     _KNJ_1 /* Legal 1st byte of double byte code */
-#define __2     _KNJ_2 /* Legal 2nd byte of double byte code */
-#define _M_     _KNJ_M /* Non-puntuation in Kana-set */
-#define _P_     _KNJ_P /* Punctuation of Kana-set */
-#define _12     (_1_|__2)
-#define _M2     (_M_|__2)
-#define _P2     (_P_|__2)
-
-#define CASE_DIFF (0x8281 - 0x8260)
-
-
-// fpclass Defs
-#define FP_SNAN       0x0001  //    signaling NaN
-#define	FP_QNAN       0x0002  //    quiet NaN
-#define	FP_NINF       0x0004  //    negative infinity
-#define FP_PINF       0x0200  //    positive infinity
-#define FP_NDENORM    0x0008  //    negative denormalized non-zero
-#define FP_PDENORM    0x0010  //    positive denormalized non-zero
-#define FP_NZERO      0x0020  //    negative zero
-#define FP_PZERO      0x0040  //    positive zero
-#define FP_NNORM      0x0080  //    negative normalized non-zero
-#define FP_PNORM      0x0100  //    positive normalized non-zero
-
+//SvL: per process heap for CRTDLL
+HANDLE CRTDLL_hHeap = 0;
+int __fileno_alloc(HANDLE hFile, int mode);
 
 // Defs
 #define DOSFS_GetFullName(a,b,c) strcpy(c,a) 
 
-#if defined(__GNUC__) && defined(__i386__)
-#define USING_REAL_FPU
-#define DO_FPU(x,y) __asm__ __volatile__( x " %0;fwait" : "=m" (y) : )
-#define POP_FPU(x) DO_FPU("fstpl",x)
-#endif
 
 #if (__IBMCPP__ > 300)
@@ -86,22 +45,9 @@
 
 /* Definition for _cabs */
-struct _complex
+struct complex
 {
 	double	x;	/* Real part */
 	double	y;	/* Imaginary part */
 };
-
-#ifndef _DISKFREE_T_DEFINED
-#define _DISKFREE_T_DEFINED
-#define _DISKFREE_T_DEFINED_
-struct _diskfree_t {
-        unsigned total_clusters;
-        unsigned avail_clusters;
-        unsigned sectors_per_cluster;
-        unsigned bytes_per_sector;
-};
-#define diskfree_t _diskfree_t
-#endif
-
 
 typedef VOID (*new_handler_type)(VOID);
@@ -115,4 +61,5 @@
 static CRTDLL_FILE * const CRTDLL_stderr = &CRTDLL_iob[2];
 static new_handler_type new_handler;
+
 
 // CRTDLL Exports
@@ -148,143 +95,87 @@
 
 
-// CRTDLL Functions
-CRTDLL_FILE * 	CDECL CRTDLL__fdopen(INT handle, LPCSTR mode);
-INT 		CDECL CRTDLL__wcsicmp( LPCWSTR str1, LPCWSTR str2 );
-INT 		CDECL CRTDLL_vfprintf( CRTDLL_FILE *file, LPSTR format, va_list args );
-VOID *		CDECL CRTDLL_malloc(DWORD size);
-long 		CDECL CRTDLL__lseek(int handle,long offset,int origin);
-long 		CDECL CRTDLL__filelength( int i );
-VOID 		CDECL CRTDLL__exit(DWORD ret);
-INT		CDECL CRTDLL_isalnum(int i);
-int 		CDECL CRTDLL_isgraph(int i);
-int 		CDECL CRTDLL__access(const char *path,int mode);
-int 		CDECL CRTDLL__getch(void);
-size_t 		CDECL CRTDLL_fread( void *ptr, size_t size, size_t n, FILE *fp );
-int 		CDECL CRTDLL__mbbtype( unsigned char c, int type );
-unsigned char * CDECL CRTDLL__mbscpy( unsigned char *s1, const unsigned char *s2 );
-LPSTR 		CDECL CRTDLL__mbsinc( LPCSTR str );
-INT 		CDECL CRTDLL__mbslen( LPCSTR str );
-int 		CDECL CRTDLL__ismbbkalnum( unsigned int c );
-int 		CDECL CRTDLL__ismbbkana( unsigned int c );
-int 		CDECL CRTDLL__ismbbalpha( unsigned int c );
-int 		CDECL CRTDLL__ismbbtrail( unsigned int c );
-int 		CDECL CRTDLL__ismbblead( unsigned int c );
-char * 		CDECL CRTDLL_getenv( const char *name );
-int 		CDECL CRTDLL__isnan( double __x );
-void * 		CDECL CRTDLL__get_osfhandle( int fileno );
-
 //
 // Definitions for internal functions
 //
-int 		__set_errno (int error);
-unsigned int 	_mbbtoupper(unsigned int c);
-unsigned int 	_mbbtolower(unsigned int c);
-size_t 		_mbclen2(const unsigned int s);
-int 		_isinf(double __x);
-void 		*filehnd(int fileno);
-
-
-//
-// Defs for filehnd
-//
-typedef struct _fileno_modes_type
-{
-	HANDLE hFile;
-	int mode;
-	int fd;
-} fileno_modes_type;
-
-fileno_modes_type *fileno_modes = NULL;
-
-int maxfno = 5;
-int minfno = 5;
-
-
-//
-// MBC Includes
-//
-static unsigned short han_to_zen_ascii_table[0x5f] = {
-  0x8140, 0x8149, 0x8168, 0x8194, 0x8190, 0x8193, 0x8195, 0x8166,
-  0x8169, 0x816a, 0x8196, 0x817b, 0x8143, 0x817c, 0x8144, 0x815e,
-  0x824f, 0x8250, 0x8251, 0x8252, 0x8253, 0x8254, 0x8255, 0x8256,
-  0x8257, 0x8258, 0x8146, 0x8147, 0x8183, 0x8181, 0x8184, 0x8148,
-  0x8197, 0x8260, 0x8261, 0x8262, 0x8263, 0x8264, 0x8265, 0x8266,
-  0x8267, 0x8268, 0x8269, 0x826a, 0x826b, 0x826c, 0x826d, 0x826e,
-  0x826f, 0x8270, 0x8271, 0x8272, 0x8273, 0x8274, 0x8275, 0x8276,
-  0x8277, 0x8278, 0x8279, 0x816d, 0x818f, 0x816e, 0x814f, 0x8151,
-  0x8165, 0x8281, 0x8282, 0x8283, 0x8284, 0x8285, 0x8286, 0x8287,
-  0x8288, 0x8289, 0x828a, 0x828b, 0x828c, 0x828d, 0x828e, 0x828f,
-  0x8290, 0x8291, 0x8292, 0x8293, 0x8294, 0x8295, 0x8296, 0x8297,
-  0x8298, 0x8299, 0x829a, 0x816f, 0x8162, 0x8170, 0x8150
-};
-static unsigned short han_to_zen_kana_table[0x40] = {
-  0x8140, 0x8142, 0x8175, 0x8176, 0x8141, 0x8145, 0x8392, 0x8340,
-  0x8342, 0x8344, 0x8346, 0x8348, 0x8383, 0x8385, 0x8387, 0x8362,
-  0x815b, 0x8341, 0x8343, 0x8345, 0x8347, 0x8349, 0x834a, 0x834c,
-  0x834e, 0x8350, 0x8352, 0x8354, 0x8356, 0x8358, 0x835a, 0x835c,
-  0x835e, 0x8360, 0x8363, 0x8365, 0x8367, 0x8369, 0x836a, 0x836b,
-  0x836c, 0x836d, 0x836e, 0x8371, 0x8374, 0x8377, 0x837a, 0x837d,
-  0x837e, 0x8380, 0x8381, 0x8382, 0x8384, 0x8386, 0x8388, 0x8389,
-  0x838a, 0x838b, 0x838c, 0x838d, 0x838f, 0x8393, 0x814a, 0x814b
-};
-static unsigned char zen_to_han_kana_table[0x8396-0x8340+1] = {
-  0xa7, 0xb1, 0xa8, 0xb2, 0xa9, 0xb3, 0xaa, 0xb4,
-  0xab, 0xb5, 0xb6, 0xb6, 0xb7, 0xb7, 0xb8, 0xb8,
-  0xb9, 0xb9, 0xba, 0xba, 0xbb, 0xbb, 0xbc, 0xbc,
-  0xbd, 0xbd, 0xbe, 0xbe, 0xbf, 0xbf, 0xc0, 0xc0,
-  0xc1, 0xc1, 0xaf, 0xc2, 0xc2, 0xc3, 0xc3, 0xc4,
-  0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xca,
-  0xca, 0xcb, 0xcb, 0xcb, 0xcc, 0xcc, 0xcc, 0xcd,
-  0xcd, 0xcd, 0xce, 0xce, 0xce, 0xcf, 0xd0, 0,
-  0xd1, 0xd2, 0xd3, 0xac, 0xd4, 0xad, 0xd5, 0xae,
-  0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdc,
-  0xb2, 0xb4, 0xa6, 0xdd, 0xb3, 0xb6, 0xb9
-};
-#define ZTOH_SYMBOLS 9
-static unsigned short zen_to_han_symbol_table_1[ZTOH_SYMBOLS] = {
-  0x8142, 0x8175, 0x8176, 0x8141, 0x8145, 0x815b, 0x814a, 0x814b
-};
-static unsigned char zen_to_han_symbol_table_2[ZTOH_SYMBOLS] = {
-  0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xb0, 0xde, 0xdf
-};
-#define ISKANA(c) ((c) >= 0xa1 && (c) <= 0xdf)
-#define JISHIRA(c) ((c) >= 0x829f && (c) <= 0x82f1)
-#define JISKANA(c) ((c) >= 0x8340 && (c) <= 0x8396 && (c) != 0x837f)
-#define JTOKANA(c) ((c) <= 0x82dd ? (c) + 0xa1 : (c) + 0xa2)
-
-char _jctype[257] = {
-/*-1*/  ___,
-/*0x*/  ___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,
-/*1x*/  ___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,
-/*2x*/  ___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,
-/*3x*/  ___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,
-/*4x*/  __2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,
-/*5x*/  __2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,
-/*6x*/  __2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,
-/*7x*/  __2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,___,
-/*8x*/  __2,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,
-/*9x*/  _12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,
-/*Ax*/  __2,_P2,_P2,_P2,_P2,_P2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,
-/*Bx*/  _M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,
-/*Cx*/  _M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,
-/*Dx*/  _M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,
-/*Ex*/  _12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,
-/*Fx*/  _12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,___,___,___
-};
+void 		qsort1 (char*, char*, size_t,
+                    int (* CDECL)(const void*, const void*));
 
 
 // syserr / sysnerr Defs
 const char *CRTDLL_sys_errlist[] = {
-__syserr00, __syserr01, __syserr02, __syserr03, __syserr04,
-__syserr05, __syserr06, __syserr07, __syserr08, __syserr09,
-__syserr10, __syserr11, __syserr12, __syserr13, __syserr14,
-__syserr15, __syserr16, __syserr17, __syserr18, __syserr19,
-__syserr20, __syserr21, __syserr22, __syserr23, __syserr24,
-__syserr25, __syserr26, __syserr27, __syserr28, __syserr29,
-__syserr30, __syserr31, __syserr32, __syserr33, __syserr34,
-__syserr35, __syserr36, __syserr37, __syserr38
+  /*  0 EZERO          */ "Error 0",
+  /*  1 EPERM          */ "Operation not permitted",
+  /*  2 ENOENT         */ "No such file or directory",
+  /*  3 ESRCH          */ "No such process",
+  /*  4 EINTR          */ "Interrupted system call",
+  /*  5 EIO            */ "I/O error",
+  /*  6 ENXIO          */ "No such device or address",
+  /*  7 E2BIG          */ "Arguments or environment too big",
+  /*  8 ENOEXEC        */ "Invalid executable file format",
+  /*  9 EBADF          */ "Bad file number",
+  /* 10 ECHILD         */ "No children",
+  /* 11 EAGAIN         */ "Resource temporarily unavailable",
+  /* 12 ENOMEM         */ "Not enough memory",
+  /* 13 EACCES         */ "Permission denied",
+  /* 14 EFAULT         */ "Bad address",
+  /* 15 ENOLCK         */ "No locks available",
+  /* 16 EBUSY          */ "Resource busy",
+  /* 17 EEXIST         */ "File exists",
+  /* 18 EXDEV          */ "Cross-device link",
+  /* 19 ENODEV         */ "No such device",
+  /* 20 ENOTDIR        */ "Not a directory",
+  /* 21 EISDIR         */ "Is a directory",
+  /* 22 EINVAL         */ "Invalid argument",
+  /* 23 ENFILE         */ "Too many open files in system",
+  /* 24 EMFILE         */ "Too many open files",
+  /* 25 ENOTTY         */ "Inappropriate ioctl",
+  /* 26 EDEADLK        */ "Resource deadlock avoided",
+  /* 27 EFBIG          */ "File too large",
+  /* 28 ENOSPC         */ "Disk full",
+  /* 29 ESPIPE         */ "Invalid seek",
+  /* 30 EROFS          */ "Read-only file system",
+  /* 31 EMLINK         */ "Too many links",
+  /* 32 EPIPE          */ "Broken pipe",
+  /* 33 EDOM           */ "Domain error",
+  /* 34 ERANGE         */ "Result too large",
+  /* 35 ENOTEMPTY      */ "Directory not empty",
+  /* 36 EINPROGRESS    */ "Operation now in progress",
+  /* 37 ENOSYS         */ "Function not implemented",
+  /* 38 ENAMETOOLONG   */ "File name too long",
+  /* 39 EDESTADDRREQ   */ "Destination address required",
+  /* 40 EMSGSIZE       */ "Message too long",
+  /* 41 EPROTOTYPE     */ "Protocol wrong type for socket",
+  /* 42 ENOPROTOOPT    */ "Option not supported by protocol",
+  /* 43 EPROTONOSUPPORT */ "Protocol not supported",
+  /* 44 ESOCKTNOSUPPORT */ "Socket type not supported",
+  /* 45 EOPNOTSUPP     */ "Operation not supported on socket",
+  /* 46 EPFNOSUPPORT   */ "Protocol family not supported",
+  /* 47 EAFNOSUPPORT   */ "Address family not supported by protocol family",
+  /* 48 EADDRINUSE     */ "Address already in use",
+  /* 49 EADDRNOTAVAIL  */ "Can't assign requested address",
+  /* 50 ENETDOWN       */ "Network is down",
+  /* 51 ENETUNREACH    */ "Network is unreachable",
+  /* 52 ENETRESET      */ "Network dropped connection on reset",
+  /* 53 ECONNABORTED   */ "Software caused connection abort",
+  /* 54 ECONNRESET     */ "Connection reset by peer",
+  /* 55 ENOBUFS        */ "No buffer space available",
+  /* 56 EISCONN        */ "Socket is already connected",
+  /* 57 ENOTCONN       */ "Socket is not connected",
+  /* 58 ESHUTDOWN      */ "Can't send after socket shutdown",
+  /* 59 ETOOMANYREFS   */ "Too many references: can't splice",
+  /* 60 ETIMEDOUT      */ "Connection timed out",
+  /* 61 ECONNREFUSED   */ "Connection refused",
+  /* 62 ELOOP          */ "Too many levels of symbolic links",
+  /* 63 ENOTSOCK       */ "Socket operation on non-socket",
+  /* 64 EHOSTDOWN      */ "Host is down",
+  /* 65 EHOSTUNREACH   */ "No route to host",
+  /* 66 EALREADY       */ "Operation already in progress"
 };
 
 int __sys_nerr = sizeof(CRTDLL_sys_errlist) / sizeof(CRTDLL_sys_errlist[0]);
+int*	CRTDLL_sys_nerr_dll = &__sys_nerr;
 
-int*	CRTDLL_sys_nerr_dll = &__sys_nerr;
+
+// atexit
+void (*_atexit_v[64])(void);
+int _atexit_n = 0;
Index: trunk/src/crtdll/ieee.h
===================================================================
--- trunk/src/crtdll/ieee.h	(revision 2617)
+++ 	(revision )
@@ -1,29 +1,0 @@
-/* $Id: ieee.h,v 1.1 1999-10-09 13:32:26 sandervl Exp $ */
-
-#ifndef _IEEE_H
-#define _IEEE_H
-
-typedef struct {
-  unsigned int mantissa:23;
-  unsigned int exponent:8;
-  unsigned int sign:1;
-} float_t;
-
-typedef struct {
-  unsigned int mantissal:32;
-  unsigned int mantissah:20;
-  unsigned int exponent:11;
-  unsigned int sign:1;
-} double_t;
-
-typedef struct {
-  unsigned int mantissal:32;
-  unsigned int mantissah:32;
-  unsigned int exponent:15;
-  unsigned int sign:1;
-  unsigned int empty:16;
-} long_double_t;
-
-
-
-#endif
Index: trunk/src/crtdll/internal.cpp
===================================================================
--- trunk/src/crtdll/internal.cpp	(revision 2618)
+++ trunk/src/crtdll/internal.cpp	(revision 2618)
@@ -0,0 +1,102 @@
+/* $Id: internal.cpp,v 1.1 2000-02-03 21:37:49 sandervl Exp $ */
+
+/*
+ * The C RunTime DLL
+ * 
+ * Implements C run-time functionality as known from UNIX.
+ *
+ * Partialy based on Wine
+ *
+ * Copyright 1996,1998 Marcus Meissner
+ * Copyright 1996 Jukka Iivonen
+ * Copyright 1997 Uwe Bonnes
+ * Copyright 1999-2000 Jens Wiessner
+ *
+ * CRTDLL - internal functions
+ *
+ */
+
+#include <odin.h>
+#include <os2win.h>
+#include <ctype.h>
+#include <memory.h>
+#include <stdio.h>
+#include <wchar.h>
+
+
+/*********************************************************************
+ *	_memswap				(INTERNAL-#1)
+ */
+void _memswap (void *s1, void *s2, size_t n)
+{
+   char *c1, *c2, c;
+   int *i1, *i2, i;
+ 
+   i1 = (int*)s1; i2 = (int*)s2;
+   while (n >= sizeof (int))
+     {
+       i = *i1; *i1++ = *i2; *i2++ = i;
+       n -= sizeof (int);
+       }
+   c1 = (char *)i1; c2 = (char *)i2;
+   while (n >= 1)
+     {
+       c = *c1; *c1++ = *c2; *c2++ = c;
+       --n;
+     }
+ }
+
+
+/*********************************************************************
+ *	qsort1 					(INTERNAL-#2)
+ */
+void qsort1 (char *l, char *r, size_t width,
+                    int (* CDECL compare)(const void *x1, const void *x2))
+{
+  char *i, *j, *x;
+
+redo:
+  i = l; j = r;
+  x = l + width * (((r-l) / width) >> 1);
+  do
+    {
+      while (i != x && compare ((void *)i, (void *)x) < 0)
+        i += width;
+      while (j != x && compare ((void *)j, (void *)x) > 0)
+        j -= width;
+      if (i < j)
+        {
+          _memswap (i, j, width);
+          if (x == i)
+            x = j;
+          else if (x == j)
+            x = i;
+        }
+      if (i <= j)
+        {
+          i += width;           /* (almost) no danger */
+          if (j > l)
+            j -= width;         /* avoid wrap-around */
+        }
+    } while (i <= j);
+  if (j-l < r-i)
+    {
+      if (l < j)
+        qsort1 (l, j, width, compare);
+      if (i < r)
+        {
+          l = i;
+          goto redo;            /* qsort1 (i, r, width, compare) */
+        }
+    }
+  else
+    {
+      if (i < r)
+        qsort1 (i, r, width, compare);
+      if (l < j)
+        {
+          r = j;                /* qsort1 (l, j, width, compare) */
+          goto redo;
+        }
+    }
+}
Index: trunk/src/crtdll/makefile
===================================================================
--- trunk/src/crtdll/makefile	(revision 2617)
+++ trunk/src/crtdll/makefile	(revision 2618)
@@ -1,3 +1,3 @@
-# $Id: makefile,v 1.5 1999-12-21 12:27:12 sandervl Exp $
+# $Id: makefile,v 1.6 2000-02-03 21:37:49 sandervl Exp $
 
 #
@@ -22,5 +22,6 @@
 TARGET = crtdll
 
-OBJS =  crtdll.obj bsearch.obj initterm.obj qsort.obj crt.obj asmhlp.obj
+OBJS =  crtdll.obj asmhlp.obj stubs.obj internal.obj crt_string.obj \
+	crt_memory.obj crt_mb.obj crt_wc.obj initterm.obj
 
 all: $(TARGET).dll $(TARGET).lib
@@ -42,10 +43,14 @@
 
 
-initterm.obj: initterm.cpp
-crtdll.obj: crtdll.cpp
-bsearch.obj: bsearch.c
-qsort.obj:    qsort.c
-crt.obj:	crt.cpp
-asmhlp.obj: asmhlp.asm
+initterm.obj:	initterm.cpp
+asmhlp.obj: 	asmhlp.asm
+stubs.obj:	stubs.cpp
+internal.obj:	internal.cpp
+crt_string.obj:	crt_string.cpp
+crt_mb.obj:	crt_mb.cpp
+crt_memory.obj:	crt_memory.cpp
+crt_wc.obj:	crt_wc.cpp
+
+crtdll.obj:	crtdll.cpp
 
 clean:
Index: trunk/src/crtdll/qsort.c
===================================================================
--- trunk/src/crtdll/qsort.c	(revision 2617)
+++ 	(revision )
@@ -1,86 +1,0 @@
-/* qsort.c (emx+gcc) -- Copyright (c) 1990-1994 by Eberhard Mattes */
-
-#include <odin.h>
-#include <memory.h>
-#include <string.h>
-
- void _memswap (void *s1, void *s2, size_t n)
- {
-   char *c1, *c2, c;
-   int *i1, *i2, i;
- 
-   i1 = s1; i2 = s2;
-   while (n >= sizeof (int))
-     {
-       i = *i1; *i1++ = *i2; *i2++ = i;
-       n -= sizeof (int);
-       }
-   c1 = (char *)i1; c2 = (char *)i2;
-   while (n >= 1)
-     {
-       c = *c1; *c1++ = *c2; *c2++ = c;
-       --n;
-     }
- }
-
-static void qsort1 (char *l, char *r, size_t width,
-                    int (* CDECL compare)(const void *x1, const void *x2));
-
-void CDECL CRTDLL_qsort (void *base, size_t num, size_t width,
-                         int (*CDECL compare)(const void *x1, const void *x2))
-{
-  if (width > 0 && num > 1 && base != 0)
-    qsort1 ((char *)base, (char *)base+(num-1)*width, width, compare);
-}
-
-
-static void qsort1 (char *l, char *r, size_t width,
-                    int (* CDECL compare)(const void *x1, const void *x2))
-{
-  char *i, *j, *x;
-
-redo:
-  i = l; j = r;
-  x = l + width * (((r-l) / width) >> 1);
-  do
-    {
-      while (i != x && compare ((void *)i, (void *)x) < 0)
-        i += width;
-      while (j != x && compare ((void *)j, (void *)x) > 0)
-        j -= width;
-      if (i < j)
-        {
-          _memswap (i, j, width);
-          if (x == i)
-            x = j;
-          else if (x == j)
-            x = i;
-        }
-      if (i <= j)
-        {
-          i += width;           /* (almost) no danger */
-          if (j > l)
-            j -= width;         /* avoid wrap-around */
-        }
-    } while (i <= j);
-  if (j-l < r-i)
-    {
-      if (l < j)
-        qsort1 (l, j, width, compare);
-      if (i < r)
-        {
-          l = i;
-          goto redo;            /* qsort1 (i, r, width, compare) */
-        }
-    }
-  else
-    {
-      if (i < r)
-        qsort1 (i, r, width, compare);
-      if (l < j)
-        {
-          r = j;                /* qsort1 (l, j, width, compare) */
-          goto redo;
-        }
-    }
-}
Index: trunk/src/crtdll/stubs.cpp
===================================================================
--- trunk/src/crtdll/stubs.cpp	(revision 2618)
+++ trunk/src/crtdll/stubs.cpp	(revision 2618)
@@ -0,0 +1,1327 @@
+/* $Id: stubs.cpp,v 1.1 2000-02-03 21:37:50 sandervl Exp $ */
+
+/*
+ * The C RunTime DLL
+ * 
+ * Implements C run-time functionality as known from UNIX.
+ *
+ * Partialy based on Wine
+ *
+ * Copyright 1996,1998 Marcus Meissner
+ * Copyright 1996 Jukka Iivonen
+ * Copyright 1997 Uwe Bonnes
+ * Copyright 1999-2000 Jens Wiessner
+ *
+ * CRTDLL - Stubs
+ *
+ */
+
+#include <odin.h>
+#include <os2win.h>
+#include <conio.h>
+#include <stdio.h>
+#include <wchar.h>
+#include <wctype.h>
+
+
+/*********************************************************************
+ *	__dllonexit           			(CRTDLL.25)
+ */
+VOID CDECL CRTDLL___dllonexit ()
+{	
+  dprintf(("__dllonexit not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+}
+
+
+/*********************************************************************
+ *                  __fpecode            (CRTDLL.27)
+ */
+int * CDECL CRTDLL___fpecode ( void )
+{	
+  dprintf(("CRTDLL: __fpecode not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *	__pxcptinfoptrs		   		(CRTDLL.32)
+ */
+void ** CDECL CRTDLL___pxcptinfoptrs (void)
+{
+  dprintf(("CRTDLL: __pxcptinfoptrs not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return NULL;
+}
+
+
+/*********************************************************************
+ *	_abnormal_termination			(CRTDLL.36)
+ */
+int CDECL CRTDLL__abnormal_termination(void)
+{
+  dprintf(("CRTDLL: _abnormal_termination  not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *           CRTDLL__chgsign	 (CRTDLL.53)
+ */
+double CDECL CRTDLL__chgsign(double x)
+{
+  dprintf(("CRTDLL: _chgsign not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *                  CRTDLL__commit    (CRTDLL.58)
+ */
+int CDECL CRTDLL__commit( int fd )
+{
+  dprintf(("CRTDLL: _commit not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *                  CRTDLL__copysign    (CRTDLL.62)
+ */
+double CDECL CRTDLL__copysign( double d, double s )
+{
+  dprintf(("CRTDLL: _copysign not implemented\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *	_expand   				(CRTDLL.88)
+ */
+void * CDECL CRTDLL__expand( void *ptr, size_t size )
+{
+  dprintf(("CRTDLL: _expand not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *	_filbuf					(CRTDLL.94)
+ */
+int CDECL CRTDLL__filbuf(FILE * f)
+{
+  dprintf(("CRTDLL: _filbuf not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+*                  _findclose    (CRTDLL.098)
+*/
+int CDECL CRTDLL__findclose( long handle )
+{
+  dprintf(("CRTDLL: _findclose not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *	_findfirst				(CRTDLL.099)
+ */
+DWORD CDECL CRTDLL__findfirst(const char *_name, struct _finddata_t *result)
+{
+  dprintf(("CRTDLL: _findfirst not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *	_findnext				(CRTDLL.100)
+ */
+INT CDECL CRTDLL__findnext(DWORD hand, struct find_t * x2)
+{
+  dprintf(("CRTDLL: _findnext not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *                  _finite     (CRTDLL.101)
+ */
+INT CDECL CRTDLL__finite(double x)
+{
+  dprintf(("CRTDLL: _finite not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *	_flsbuf					(CRTDLL.102)
+ */
+INT CDECL CRTDLL__flsbuf(int i, FILE * f)
+{
+  dprintf(("CRTDLL: _flsbuf not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *                  _fpclass     (CRTDLL.105)
+ */
+INT CDECL CRTDLL__fpclass( double d )
+{
+  dprintf(("CRTDLL: _fpclass not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *	_fpieee_flt				(CRTDLL.106)
+ */
+INT CDECL CRTDLL__fpieee_flt( unsigned long exc_code, struct _EXCEPTION_POINTERS *exc_info, int handler)
+{
+  dprintf(("CRTDLL: _fpieee_flt not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *	_fpreset				(CRTDLL.107)
+ */
+void CDECL CRTDLL__fpreset(void)
+{
+  dprintf(("CRTDLL: _fpreset not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+}
+
+
+/*********************************************************************
+ *	_fputwchar				(CRTDLL.109)
+ */
+wint_t CDECL CRTDLL__fputwchar( wint_t )
+{
+  dprintf(("CRTDLL: _fputwchar not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *	_fsopen					(CRTDLL.110)
+ */
+FILE * CDECL CRTDLL__fsopen( const char *file, const char *mode, int shflag )
+{
+  dprintf(("CRTDLL: _fsopen not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *	_fstat					(CRTDLL.111)
+ */
+int CDECL CRTDLL__fstat(int file, struct stat* buf)
+{
+  dprintf(("CRTDLL: _fstat not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *	_ftime					(CRTDLL.112)
+ */
+int CDECL CRTDLL__ftime( struct timeb *timebuf )
+{
+  dprintf(("CRTDLL: _ftime not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *	_futime					(CRTDLL.115)
+ */
+int CDECL CRTDLL__futime( int handle, struct _utimbuf *filetime )
+{
+  dprintf(("CRTDLL: _futime not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *                  _get_osfhandle     (CRTDLL.117)
+ */
+void* CDECL CRTDLL__get_osfhandle( int fileno )
+{
+  dprintf(("CRTDLL: _get_osfhandle not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *                  _getdiskfree     (CRTDLL.122)
+ */
+unsigned int CDECL CRTDLL__getdiskfree( unsigned int drive, struct _diskfree_t *diskspace)
+{
+  dprintf(("CRTDLL: _getdiskfree not implemented\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *                  _getdllprocaddr     (CRTDLL.123)
+ */
+FARPROC CDECL  CRTDLL__getdllprocaddr(HMODULE hModule,char * lpProcName, int iOrdinal)
+{
+  dprintf(("CRTDLL: _getdllprocaddr not implemented.\n"));   
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *                  _getsystime    (CRTDLL.127)
+ */
+unsigned int CDECL CRTDLL__getsystime(struct tm *tp)
+{
+  dprintf(("CRTDLL: _getsystime not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *	_heapwalk				(CRTDLL.133)
+ */
+int CDECL CRTDLL__heapwalk( struct _heapinfo *entry )
+{
+  dprintf(("CRTDLL: _heapwalk not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *                  _isatty       (CRTDLL.137)
+ */
+BOOL CDECL CRTDLL__isatty(DWORD x)
+{
+   dprintf(("CRTDLL: _isatty(%ld) not implemented.\n",x));
+   SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+   return TRUE;
+}
+
+
+/*********************************************************************
+ *                  _ismbbalnum     (CRTDLL.139)
+ */
+int CDECL CRTDLL__ismbbalnum( unsigned int c )
+{
+  dprintf(("CRTDLL: _ismbbalnum\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *                  _ismbbalpha     (CRTDLL.140)
+ */
+int CDECL CRTDLL__ismbbalpha( unsigned int c )
+{
+  dprintf(("CRTDLL: _ismbbalpha\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *                  _ismbbgraph     (CRTDLL.141)
+ */
+int CDECL CRTDLL__ismbbgraph( unsigned int c )
+{
+  dprintf(("CRTDLL: _ismbbgraph\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *                  _ismbbkalnum     (CRTDLL.142)
+ */
+int CDECL CRTDLL__ismbbkalnum( unsigned int c )
+{
+  dprintf(("CRTDLL: _ismbbkalnum\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *                  _ismbbkana     (CRTDLL.143)
+ */
+int CDECL CRTDLL__ismbbkana( unsigned int c )
+{
+  dprintf(("CRTDLL: _ismbbkana\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *                  _ismbbkpunct     (CRTDLL.144)
+ */
+int CDECL CRTDLL__ismbbkpunct( unsigned int c )
+{
+  dprintf(("CRTDLL: _ismbbkpunct\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *                  _ismbblead     (CRTDLL.145)
+ */
+int CDECL CRTDLL__ismbblead( unsigned int c )
+{
+  dprintf(("CRTDLL: _ismbblead\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *                  _ismbbprint     (CRTDLL.146)
+ */
+int CDECL CRTDLL__ismbbprint( unsigned int c )
+{
+  dprintf(("CRTDLL: _ismbbprint\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *                  _ismbbpunct     (CRTDLL.147)
+ */
+int CDECL CRTDLL__ismbbpunct( unsigned int c )
+{
+  dprintf(("CRTDLL: _ismbbpunct\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *                  _ismbbtrail     (CRTDLL.148)
+ */
+int CDECL CRTDLL__ismbbtrail( unsigned int c )
+{
+  dprintf(("CRTDLL: _ismbbtrail\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *                  _ismbcalpha     (CRTDLL.149)
+ */
+int CDECL CRTDLL__ismbcalpha( unsigned int c )
+{
+  dprintf(("CRTDLL: _ismbcalpha\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *                  _ismbcdigit     (CRTDLL.150)
+ */
+int CDECL CRTDLL__ismbcdigit( unsigned int c )
+{
+  dprintf(("CRTDLL: _ismbcdigit\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *                  _ismbchira     (CRTDLL.151)
+ */
+int CDECL CRTDLL__ismbchira( unsigned int c )
+{
+  dprintf(("CRTDLL: _ismbchira\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *                  _ismbckata     (CRTDLL.152)
+ */
+int CDECL CRTDLL__ismbckata( unsigned int c )
+{
+  dprintf(("CRTDLL: _ismbckata\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *	_ismbcl0				(CRTDLL.153)
+ */
+int CDECL CRTDLL__ismbcl0( unsigned int ch )
+{
+  dprintf(("CRTDLL: _ismbcl0 not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *	_ismbcl1				(CRTDLL.154)
+ */
+int CDECL CRTDLL__ismbcl1( unsigned int ch )
+{
+  dprintf(("CRTDLL: _ismbcl1 not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *	_ismbcl2				(CRTDLL.155)
+ */
+int CDECL CRTDLL__ismbcl2( unsigned int ch )
+{
+  dprintf(("CRTDLL: _ismbcl2 not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *                  _ismbclegal     (CRTDLL.156)
+ */
+int CDECL CRTDLL__ismbclegal( unsigned int c )
+{
+  dprintf(("CRTDLL: _ismbclegal\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *                  _ismbclower     (CRTDLL.157)
+ */
+int CDECL CRTDLL__ismbclower( unsigned int c )
+{
+  dprintf(("CRTDLL: _ismbclower\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *                  _ismbcprint     (CRTDLL.158)
+ */
+int CDECL CRTDLL__ismbcprint( unsigned int c )
+{
+  dprintf(("CRTDLL: _ismbcprint\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *	_ismbcspace				(CRTDLL.159)
+ */
+int CDECL CRTDLL__ismbcspace( unsigned int c )
+{
+  dprintf(("CRTDLL: _ismbcspace not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *	_ismbcsymbol				(CRTDLL.160)
+ */
+int CDECL CRTDLL__ismbcsymbol( unsigned int c )
+{
+  dprintf(("CRTDLL: _ismbcsymbol not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *                  _ismbcupper     (CRTDLL.161)
+ */
+int CDECL CRTDLL__ismbcupper( unsigned int c )
+{
+  dprintf(("CRTDLL: _ismbcupper\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *                  _ismbslead     (CRTDLL.162)
+ */
+int CDECL CRTDLL__ismbslead(const unsigned char *str, const unsigned char *t)
+{
+  dprintf(("CRTDLL: _ismbslead\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *                  _ismbstrail     (CRTDLL.163)
+ */
+int CDECL CRTDLL__ismbstrail(const unsigned char *str, const unsigned char *t)
+{
+  dprintf(("CRTDLL: _ismbstrail\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *                  _isnan     (CRTDLL.164)
+ */
+int CDECL CRTDLL__isnan( double x )
+{
+  dprintf(("CRTDLL: _isnan not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *                  _lfind     (CRTDLL.170)
+ */
+void * CDECL CRTDLL__lfind(const void *key, const void *base, size_t *nelp,
+         size_t width, int (*compar)(const void *, const void *))
+{
+  dprintf(("CRTDLL: _lfind not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *                  _locking        (CRTDLL.173)
+ */
+int CDECL CRTDLL__locking( int fd, int mode, long nbytes )
+{
+  dprintf(("CRTDLL: _locking not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *	_logb					(CRTDLL.174)
+ */
+double CDECL CRTDLL__logb( double x )
+{
+  dprintf(("CRTDLL: _logb not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *	_lsearch				(CRTDLL.177)
+ */
+void * CDECL CRTDLL__lsearch(const void *key, void *base, size_t *nelp, size_t width,
+         int (*compar)(const void *, const void *))
+{
+  dprintf(("CRTDLL: _lsearch not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *                  _mbbtombc        (CRTDLL.182)
+ */
+unsigned int CDECL CRTDLL__mbbtombc( unsigned int c )
+{
+  dprintf(("CRTDLL: _mbbtombc not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *                  _mbbtype        (CRTDLL.183)
+ */
+int CDECL CRTDLL__mbbtype( unsigned char c, int type )
+{
+  dprintf(("CRTDLL: _mbbtype not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *                  _mbccpy        (CRTDLL.184)
+ */
+void CDECL CRTDLL__mbccpy( unsigned char *dst, const unsigned char *src )
+{
+  dprintf(("CRTDLL: _mbccpy not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+}
+
+
+/*********************************************************************
+ *                  _mbcjistojms     (CRTDLL.185)
+ */
+int CDECL CRTDLL__mbcjistojms( unsigned int c )
+{
+  dprintf(("CRTDLL: _mbcjistojms not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *                  _mbcjmstojis     (CRTDLL.186)
+ */
+int CDECL CRTDLL__mbcjmstojis( unsigned int c )
+{
+  dprintf(("CRTDLL: _mbcjmstojis not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *                  _mbclen    (CRTDLL.187)
+ */
+size_t CDECL CRTDLL__mbclen( const unsigned char *s )
+{
+  dprintf(("CRTDLL: _mbclen not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *                  _mbctohira     (CRTDLL.188)
+ */
+int CDECL CRTDLL__mbctohira( unsigned int c )
+{
+  dprintf(("CRTDLL: _mbctohira not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *                  _mbctokata     (CRTDLL.189)
+ */
+int CDECL CRTDLL__mbctokata( unsigned int c )
+{
+  dprintf(("CRTDLL: _mbctokata not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *                  _mbctolower     (CRTDLL.190)
+ */
+unsigned int CDECL CRTDLL__mbctolower( unsigned int c )
+{
+  dprintf(("CRTDLL: _mbctolower not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *                  _mbctombb        (CRTDLL.191)
+ */
+unsigned int CDECL CRTDLL__mbctombb( unsigned int c )
+{
+  dprintf(("CRTDLL: _mbctombb not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *                  _mbctoupper     (CRTDLL.192)
+ */
+unsigned int CDECL CRTDLL__mbctoupper( unsigned int c )
+{
+  dprintf(("CRTDLL: _mbctoupper not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *                  _mbsbtype     (CRTDLL.194)
+ */
+int CDECL CRTDLL__mbsbtype( const unsigned char *str, int n )
+{
+  dprintf(("CRTDLL: _mbsbtype not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *                  _mbscspn        (CRTDLL.199)
+ */
+size_t CDECL CRTDLL__mbscspn( const unsigned char *s1, const unsigned char *s2 )
+{
+  dprintf(("CRTDLL: _mbscspn not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *           _mbsdec    (CRTDLL.200)
+ */
+unsigned char * CDECL CRTDLL__mbsdec( const unsigned char *str, const unsigned char *cur )
+{
+  dprintf(("CRTDLL: _mbsdec not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *           _mbslwr    (CRTDLL.205)
+ */
+unsigned char * CDECL CRTDLL__mbslwr( unsigned char *x )
+{
+  dprintf(("CRTDLL: _mbslwr not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *           _mbsnbcat  (CRTDLL.206)
+ */
+unsigned char * CDECL CRTDLL__mbsnbcat( unsigned char *dst, const unsigned char *src, size_t n )
+{
+  dprintf(("CRTDLL: _mbsnbcat not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *           _mbsnbcmp  (CRTDLL.207)
+ */
+int CDECL CRTDLL__mbsnbcmp( const unsigned char *str1, const unsigned char *str2, size_t n )
+{
+  dprintf(("CRTDLL: _mbsnbcmp not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *           _mbsnbcnt  (CRTDLL.208)
+ */
+size_t CDECL CRTDLL__mbsnbcnt( const unsigned char *str, size_t n )
+{
+  dprintf(("CRTDLL: _mbsnbcnt not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *           _mbsnbcpy  (CRTDLL.209)
+ */
+unsigned char * CDECL CRTDLL__mbsnbcpy( unsigned char *str1, const unsigned char *str2, size_t n )
+{
+  dprintf(("CRTDLL: _mbsnbcpy not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *           _mbsnbicmp (CRTDLL.210)
+ */
+int CDECL CRTDLL__mbsnbicmp( const unsigned char *s1, const unsigned char *s2, size_t n )
+{
+  dprintf(("CRTDLL: _mbsnbicmp not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *           _mbsnbset (CRTDLL.211)
+ */
+unsigned char * CDECL CRTDLL__mbsnbset( unsigned char *src, unsigned int val, size_t count )
+{
+  dprintf(("CRTDLL: _mbsnbset not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *           _mbsncat (CRTDLL.212)
+ */
+unsigned char * CDECL CRTDLL__mbsncat( unsigned char *dst, const unsigned char *src, size_t n )
+{
+  dprintf(("CRTDLL: _mbsncat not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *           _mbsnccnt (CRTDLL.213)
+ */
+size_t CDECL CRTDLL__mbsnccnt( const unsigned char *str, size_t n )
+{
+  dprintf(("CRTDLL: _mbsnccnt not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *           _mbsncmp (CRTDLL.214)
+ */
+int CDECL CRTDLL__mbsncmp( const unsigned char *str1, const unsigned char *str2, size_t n )
+{
+  dprintf(("CRTDLL: _mbsncmp not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *           _mbsncpy (CRTDLL.215)
+ */
+unsigned char * CDECL CRTDLL__mbsncpy( unsigned char *str1, const unsigned char *str2, size_t n )
+{
+  dprintf(("CRTDLL: _mbsncpy not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *           _mbsnextc (CRTDLL.216)
+ */
+unsigned int CDECL CRTDLL__mbsnextc( const unsigned char *src )
+{
+  dprintf(("CRTDLL: _mbsnextc not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *           _mbsnicmp (CRTDLL.217)
+ */
+int CDECL CRTDLL__mbsnicmp( const unsigned char *s1, const unsigned char *s2, size_t n )
+{
+  dprintf(("CRTDLL: _mbsnicmp not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *           _mbsninc (CRTDLL.218)
+ */
+unsigned char * CDECL CRTDLL__mbsninc( const unsigned char *str, size_t n )
+{
+  dprintf(("CRTDLL: _mbsninc not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *           _mbsnset (CRTDLL.219)
+ */
+unsigned char * CDECL CRTDLL__mbsnset( unsigned char *src, unsigned int val, size_t count )
+{
+  dprintf(("CRTDLL: _mbsnset not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *           _mbspbrk   (CRTDLL.220)
+ */
+unsigned char * CDECL CRTDLL__mbspbrk( const unsigned char *s1, const unsigned char *s2 )
+{
+  dprintf(("CRTDLL: _mbspbrk not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *           _mbsrev    (CRTDLL.222)
+ */
+unsigned char * CDECL CRTDLL__mbsrev( unsigned char *s )
+{
+  dprintf(("CRTDLL: _mbsrev not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *           _mbsset    (CRTDLL.223)
+ */
+unsigned char * CDECL CRTDLL__mbsset( unsigned char *src, unsigned int c )
+{
+  dprintf(("CRTDLL: _mbsset not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *           _mbsspn   (CRTDLL.224)
+ */
+size_t CDECL CRTDLL__mbsspn( const unsigned char *s1, const unsigned char *s2 )
+{
+  dprintf(("CRTDLL: _mbsspn not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *           _mbsspnp   (CRTDLL.225)
+ */
+unsigned char * CDECL CRTDLL__mbsspnp( const unsigned char *s1, const unsigned char *s2 )
+{
+  dprintf(("CRTDLL: _mbsspnp not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *           _mbstok    (CRTDLL.227)
+ */
+unsigned char * CDECL CRTDLL__mbstok( unsigned char *s, const unsigned char *delim )
+{
+  dprintf(("CRTDLL: _mbstok not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *           _mbstrlen   (CRTDLL.228)
+ */
+size_t CDECL CRTDLL__mbstrlen(const char *string)
+{
+  dprintf(("CRTDLL: _mbstrlen not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *           _mbsupr    (CRTDLL.229)
+ */
+unsigned char * CDECL CRTDLL__mbsupr( unsigned char *x )
+{
+  dprintf(("CRTDLL: _mbsupr not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *                  _nextafter        (CRTDLL.235)
+ */
+double CDECL CRTDLL__nextafter( double x, double y )
+{
+  dprintf(("CRTDLL: _nextafter not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *	_pclose					(CRTDLL.244)
+ */
+INT CDECL CRTDLL__pclose( FILE *fp )
+{
+  dprintf(("CRTDLL: _pclose not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *                  _pipe     (CRTDLL.247)
+ */
+INT CDECL CRTDLL__pipe(int _fildes[2], unsigned int size, int mode )
+{
+  dprintf(("CRTDLL: _pipe not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *                  _popen    (CRTDLL.248)
+ */
+FILE * CDECL CRTDLL__popen(const char *cm, const char *md)
+{
+  dprintf(("CRTDLL: _popen not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *           _scalb 	 (CRTDLL.259)
+ */
+double CDECL CRTDLL__scalb( double x, long e )
+{
+  dprintf(("CRTDLL: _scalb not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *                  _setsystime    (CRTDLL.264)
+ */
+unsigned int CDECL CRTDLL__setsystime(struct tm *tp, unsigned int ms)
+{
+  dprintf(("CRTDLL: _setsystime not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *	_snprintf				(CRTDLL.266)
+ */
+int  CDECL CRTDLL__snprintf( char *buf, size_t bufsize, const char *fmt, ... )
+{
+  dprintf(("CRTDLL: _snprintf(%08xh, %08xh, %08xh) not implemented\n",
+           buf,
+           bufsize,
+           fmt));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *	_snwprintf				(CRTDLL.267)
+ */
+int  CDECL CRTDLL__snwprintf( wchar_t *buf, size_t bufsize, const wchar_t *fmt, ... )
+{
+  dprintf(("CRTDLL: _snwprintf(%08xh, %08xh, %08xh) not implemented\n",
+           buf,
+           bufsize,
+           fmt));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *	_sopen					(CRTDLL.268)
+ */
+int CDECL CRTDLL__sopen( const char *s, int i1, int i2, ... )
+{
+  dprintf(("CRTDLL: _sopen not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *           _strerror  	 (CRTDLL.284)
+ */
+char * CDECL CRTDLL__strerror(const char *s)
+{
+  dprintf(("CRTDLL: _strerror not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *	_tzset					(CRTDLL.308)
+ */
+void CDECL CRTDLL__tzset( void )
+{
+  dprintf(("CRTDLL: _tzset not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+}
+
+
+/*********************************************************************
+ *	_vsnwprintf				(CRTDLL.316)
+ */
+int CDECL CRTDLL__vsnwprintf( wchar_t *s1, size_t n, const wchar_t *s2, va_list arg )
+{
+  dprintf(("CRTDLL: _vsnwprintf not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+			
+/*********************************************************************
+ *      _wtoi			 		(CRTDLL.330)
+ */
+int CDECL CRTDLL__wtoi( const wchar_t *s )
+{
+  dprintf(("CRTDLL: _wtoi(%08xh) not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+						
+/*********************************************************************
+ *	_wtol			 		(CRTDLL.331)
+ */
+long int CDECL CRTDLL__wtol( const wchar_t *s )
+{
+  dprintf(("CRTDLL: _wtol(%08xh) not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return 0;
+}
+
+
+/*********************************************************************
+ *	fwprintf				(CRTDLL.382)
+ */
+int CDECL CRTDLL_fwprintf( FILE *iop, const wchar_t *fmt, ... )
+{
+  dprintf(("CRTDLL: fwprintf not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *	fwscanf					(CRTDLL.384)
+ */
+int CDECL CRTDLL_fwscanf( FILE *strm, const wchar_t *format, ... )
+{
+  dprintf(("CRTDLL: fwscanf not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *                  is_wctype    (CRTDLL.390)
+ */
+INT CDECL CRTDLL_is_wctype(wint_t wc, wctype_t wctype)
+{
+  dprintf(("CRTDLL: is_wctype not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *	isleadbyte				(CRTDLL.396)
+ */
+int CDECL CRTDLL_isleadbyte(int i)
+{
+  dprintf(("CRTDLL: isleadbyte(%08xh) not implemented.\n", i));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *	ungetc					(CRTDLL.492)
+ */
+INT CDECL CRTDLL_ungetc(int c, FILE *f)
+{
+  dprintf(("CRTDLL: ungetc not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *	vfwprintf				(CRTDLL.495)
+ */
+int CDECL CRTDLL_vfwprintf( FILE *F, const wchar_t *s, va_list arg )
+{
+  dprintf(("CRTDLL: vfwprintf not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *	vwprintf				(CRTDLL.499)
+ */
+int CDECL CRTDLL_vwprintf( const wchar_t *s, va_list arg)
+{
+  dprintf(("CRTDLL: vwprintf not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *	wprintf					(CRTDLL.522)
+ */
+int CDECL CRTDLL_wprintf( const wchar_t *s, ... )
+{
+  dprintf(("CRTDLL: wprintf not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
+
+/*********************************************************************
+ *	wscanf					(CRTDLL.523)
+ */
+int CDECL CRTDLL_wscanf( const wchar_t *s, ... )
+{
+  dprintf(("CRTDLL: wscanf not implemented.\n"));
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
+}
+
