Index: trunk/src/NTDLL/LICENSE.TXT
===================================================================
--- trunk/src/NTDLL/LICENSE.TXT	(revision 6378)
+++ trunk/src/NTDLL/LICENSE.TXT	(revision 6378)
@@ -0,0 +1,28 @@
+$Id: LICENSE.TXT,v 1.1 2001-07-21 08:47:45 sandervl Exp $
+@c This is an additional Odin license agreement.
+@c It supercedes the main Odin license, but is only valid in 
+@c the source directory in which it is present.
+
+@c This file is processed by GNU's TeXinfo
+@c If you modify it or move it to another location, make sure that
+@c TeXinfo works (type `make' in directory documentation).
+
+Copyright (c) 1993-2000 the Wine project authors (see the file AUTHORS
+for a complete list)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Index: trunk/src/NTDLL/dllinitstub.asm
===================================================================
--- trunk/src/NTDLL/dllinitstub.asm	(revision 6376)
+++ 	(revision )
@@ -1,18 +1,0 @@
-; $Id: dllinitstub.asm,v 1.1 2000-11-19 15:44:53 bird Exp $
-;
-;
-;
-; Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@mynd.no)
-;
-; Project Odin Software License can be found in LICENSE.TXT
-;
-
-    .386
-
-    extrn _DLL_InitTerm:far
-
-DATA32 SEGMENT DWORD PUBLIC USE32 "DATA"
-_DllEntry dd 0
-DATA32 ENDS
-
-END _DLL_InitTerm
Index: trunk/src/NTDLL/makefile
===================================================================
--- trunk/src/NTDLL/makefile	(revision 6376)
+++ trunk/src/NTDLL/makefile	(revision 6378)
@@ -1,3 +1,3 @@
-# $Id: makefile,v 1.29 2001-07-20 15:39:46 sandervl Exp $
+# $Id: makefile,v 1.30 2001-07-21 08:47:27 sandervl Exp $
 
 #
@@ -26,4 +26,5 @@
 $(OBJDIR)\rtl.obj \
 $(OBJDIR)\rtlstr.obj \
+$(OBJDIR)\wcstring.obj \
 $(OBJDIR)\sec.obj \
 $(OBJDIR)\sync.obj \
Index: trunk/src/NTDLL/ntdll.def
===================================================================
--- trunk/src/NTDLL/ntdll.def	(revision 6376)
+++ trunk/src/NTDLL/ntdll.def	(revision 6378)
@@ -1,3 +1,3 @@
-; $Id: ntdll.def,v 1.39 2001-07-20 15:39:47 sandervl Exp $
+; $Id: ntdll.def,v 1.40 2001-07-21 08:47:27 sandervl Exp $
 
 ;
@@ -988,11 +988,11 @@
 ;    _ultow                        = _MSVCRT__ultow                         @968
     _vsnprintf                    = _CRTDLL__vsnprintf                  @969
-    _wcsicmp                      = _CRTDLL__wcsicmp                    @970
-    _wcslwr                       = _CRTDLL__wcslwr                     @971
-    _wcsnicmp                     = _CRTDLL__wcsnicmp                   @972
-    _wcsupr                       = _CRTDLL__wcsupr                     @973
-    _wtoi                         = _CRTDLL__wtoi                       @974
+    _wcsicmp                      = _NTDLL__wcsicmp                     @970
+    _wcslwr                       = _NTDLL__wcslwr                      @971
+    _wcsnicmp                     = _NTDLL__wcsnicmp                    @972
+    _wcsupr                       = _NTDLL__wcsupr                      @973
+    _wtoi                         = __wtoi                              @974
 ;    _wtoi64                    = _MSVCRT__wtoi64               @975
-    _wtol                         = _CRTDLL__wtol                       @976
+    _wtol                         = __wtol                              @976
     abs                           = _CRTDLL_abs                         @977
     atan                          = _CRTDLL_atan                        @978
@@ -1013,10 +1013,10 @@
     isspace                       = _CRTDLL_isspace                     @993
     isupper                       = _CRTDLL_isupper                     @994
-    iswalpha                      = _CRTDLL_iswalpha                    @995
-    iswctype                      = _CRTDLL_iswctype                    @996
+    iswalpha                      = _NTDLL_iswalpha 	                @995
+    iswctype                      = _NTDLL_iswctype                     @996
     isxdigit                      = _CRTDLL_isxdigit                    @997
     labs                          = _CRTDLL_labs                        @998
     log                           = _CRTDLL_log                         @999
-    mbstowcs                      = _CRTDLL_mbstowcs                    @1000
+    mbstowcs                      = _NTDLL_mbstowcs                     @1000
 
     memchr                        = _CRTDLL_memchr                      @1001
@@ -1046,26 +1046,28 @@
     strtol                  = _CRTDLL_strtol                @1025
     strtoul                 = _CRTDLL_strtoul               @1026
-    swprintf                      = _CRTDLL_swprintf                    @1027
+    swprintf                      = _NTDLL_swprintf                     @1027
     tan                           = _CRTDLL_tan                         @1028
     tolower                       = _CRTDLL_tolower                     @1029
     toupper                       = _CRTDLL_toupper                     @1030
-    towlower                      = _CRTDLL_towlower                    @1031
-    towupper                      = _CRTDLL_towupper                    @1032
+    towlower                      = _NTDLL_towlower                     @1031
+    towupper                      = _NTDLL_towupper                     @1032
     vsprintf                      = _CRTDLL_vsprintf                    @1033
-    wcscat                        = _CRTDLL_wcscat                      @1034
-    wcschr                        = _CRTDLL_wcschr                      @1035
-    wcscmp                        = _CRTDLL_wcscmp                      @1036
-    wcscpy                        = _CRTDLL_wcscpy                      @1037
-    wcscspn                       = _CRTDLL_wcscspn             @1038
-    wcslen                        = _CRTDLL_wcslen                      @1039
-    wcsncat                       = _CRTDLL_wcsncat                     @1040
-    wcsncmp                       = _CRTDLL_wcsncmp                     @1041
-    wcsncpy                       = _CRTDLL_wcsncpy                     @1042
-    wcspbrk                       = _CRTDLL_wcspbrk                     @1043
-    wcsrchr                       = _CRTDLL_wcsrchr                     @1044
-    wcsspn                        = _CRTDLL_wcsspn                      @1045
-    wcsstr                        = _CRTDLL_wcsstr              @1046
-    wcstol                        = _CRTDLL_wcstol                      @1047
-    wcstombs                      = _CRTDLL_wcstombs                    @1048
+
+    wcscat                        = _NTDLL_wcscat                       @1034
+    wcschr                        = _NTDLL_wcschr                       @1035
+    wcscmp                        = _NTDLL_wcscmp                       @1036
+    wcscpy                        = _NTDLL_wcscpy                       @1037
+    wcscspn                       = _NTDLL_wcscspn                      @1038
+    wcslen                        = _NTDLL_wcslen                       @1039
+    wcsncat                       = _NTDLL_wcsncat                      @1040
+    wcsncmp                       = _NTDLL_wcsncmp                      @1041
+    wcsncpy                       = _NTDLL_wcsncpy                      @1042
+    wcspbrk                       = _NTDLL_wcspbrk                      @1043
+    wcsrchr                       = _NTDLL_wcsrchr                      @1044
+    wcsspn                        = _NTDLL_wcsspn                       @1045
+    wcsstr                        = _NTDLL_wcsstr                       @1046
+    wcstok                        = _NTDLL_wcstok                       @1050
+    wcstol                        = _NTDLL_wcstol                       @1047
+    wcstombs                      = _NTDLL_wcstombs                     @1048
     wcstoul                       = _CRTDLL_wcstoul                     @1049
 
Index: trunk/src/NTDLL/wcstring.c
===================================================================
--- trunk/src/NTDLL/wcstring.c	(revision 6378)
+++ trunk/src/NTDLL/wcstring.c	(revision 6378)
@@ -0,0 +1,519 @@
+/*
+ * NTDLL wide-char functions
+ *
+ * Copyright 2000 Alexandre Julliard
+ * Copyright 2000 Jon Griffiths
+ */
+
+#include "config.h"
+
+#include <ctype.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#ifdef __WIN32OS2__
+#include <stdarg.h>
+#include <heapstring.h>
+#endif
+
+#include "windef.h"
+#include "winbase.h"
+#include "winnls.h"
+#include "wine/unicode.h"
+#include "heap.h"
+#include "debugtools.h"
+
+DEFAULT_DEBUG_CHANNEL(ntdll);
+
+
+/*********************************************************************
+ *           _wcsicmp    (NTDLL.@)
+ */
+INT __cdecl NTDLL__wcsicmp( LPCWSTR str1, LPCWSTR str2 )
+{
+    return strcmpiW( str1, str2 );
+}
+
+
+/*********************************************************************
+ *           _wcslwr    (NTDLL.@)
+ */
+LPWSTR __cdecl NTDLL__wcslwr( LPWSTR str )
+{
+    return strlwrW( str );
+}
+
+
+/*********************************************************************
+ *           _wcsnicmp    (NTDLL.@)
+ */
+INT __cdecl NTDLL__wcsnicmp( LPCWSTR str1, LPCWSTR str2, INT n )
+{
+    return strncmpiW( str1, str2, n );
+}
+
+
+/*********************************************************************
+ *           _wcsupr    (NTDLL.@)
+ */
+LPWSTR __cdecl NTDLL__wcsupr( LPWSTR str )
+{
+    return struprW( str );
+}
+
+
+/*********************************************************************
+ *           towlower    (NTDLL.@)
+ */
+WCHAR __cdecl NTDLL_towlower( WCHAR ch )
+{
+    return tolowerW(ch);
+}
+
+
+/*********************************************************************
+ *           towupper    (NTDLL.@)
+ */
+WCHAR __cdecl NTDLL_towupper( WCHAR ch )
+{
+    return toupperW(ch);
+}
+
+
+/***********************************************************************
+ *           wcscat    (NTDLL.@)
+ */
+LPWSTR __cdecl NTDLL_wcscat( LPWSTR dst, LPCWSTR src )
+{
+    return strcatW( dst, src );
+}
+
+
+/*********************************************************************
+ *           wcschr    (NTDLL.@)
+ */
+LPWSTR __cdecl NTDLL_wcschr( LPCWSTR str, WCHAR ch )
+{
+    return strchrW( str, ch );
+}
+
+
+/*********************************************************************
+ *           wcscmp    (NTDLL.@)
+ */
+INT __cdecl NTDLL_wcscmp( LPCWSTR str1, LPCWSTR str2 )
+{
+    return strcmpW( str1, str2 );
+}
+
+
+/***********************************************************************
+ *           wcscpy    (NTDLL.@)
+ */
+LPWSTR __cdecl NTDLL_wcscpy( LPWSTR dst, LPCWSTR src )
+{
+    return strcpyW( dst, src );
+}
+
+
+/*********************************************************************
+ *           wcscspn    (NTDLL.@)
+ */
+INT __cdecl NTDLL_wcscspn( LPCWSTR str, LPCWSTR reject )
+{
+    LPCWSTR start = str;
+    while (*str)
+    {
+        LPCWSTR p = reject;
+        while (*p && (*p != *str)) p++;
+        if (*p) break;
+        str++;
+    }
+    return str - start;
+}
+
+
+/***********************************************************************
+ *           wcslen    (NTDLL.@)
+ */
+INT __cdecl NTDLL_wcslen( LPCWSTR str )
+{
+    return strlenW( str );
+}
+
+
+/*********************************************************************
+ *           wcsncat    (NTDLL.@)
+ */
+LPWSTR __cdecl NTDLL_wcsncat( LPWSTR s1, LPCWSTR s2, INT n )
+{
+    LPWSTR ret = s1;
+    while (*s1) s1++;
+    while (n-- > 0) if (!(*s1++ = *s2++)) return ret;
+    *s1 = 0;
+    return ret;
+}
+
+
+/*********************************************************************
+ *           wcsncmp    (NTDLL.@)
+ */
+INT __cdecl NTDLL_wcsncmp( LPCWSTR str1, LPCWSTR str2, INT n )
+{
+    return strncmpW( str1, str2, n );
+}
+
+
+/*********************************************************************
+ *           wcsncpy    (NTDLL.@)
+ */
+LPWSTR __cdecl NTDLL_wcsncpy( LPWSTR s1, LPCWSTR s2, INT n )
+{
+    return strncpyW( s1, s2, n );
+}
+
+
+/*********************************************************************
+ *           wcspbrk    (NTDLL.@)
+ */
+LPWSTR __cdecl NTDLL_wcspbrk( LPCWSTR str, LPCWSTR accept )
+{
+    LPCWSTR p;
+    while (*str)
+    {
+        for (p = accept; *p; p++) if (*p == *str) return (LPWSTR)str;
+        str++;
+    }
+    return NULL;
+}
+
+
+/*********************************************************************
+ *           wcsrchr    (NTDLL.@)
+ */
+LPWSTR __cdecl NTDLL_wcsrchr( LPWSTR str, WCHAR ch )
+{
+    LPWSTR last = NULL;
+    while (*str)
+    {
+        if (*str == ch) last = str;
+        str++;
+    }
+    return last;
+}
+
+
+/*********************************************************************
+ *           wcsspn    (NTDLL.@)
+ */
+INT __cdecl NTDLL_wcsspn( LPCWSTR str, LPCWSTR accept )
+{
+    LPCWSTR start = str;
+    while (*str)
+    {
+        LPCWSTR p = accept;
+        while (*p && (*p != *str)) p++;
+        if (!*p) break;
+        str++;
+    }
+    return str - start;
+}
+
+
+/*********************************************************************
+ *           wcsstr    (NTDLL.@)
+ */
+LPWSTR __cdecl NTDLL_wcsstr( LPCWSTR str, LPCWSTR sub )
+{
+    return strstrW( str, sub );
+}
+
+
+/*********************************************************************
+ *           wcstok    (NTDLL.@)
+ */
+LPWSTR __cdecl NTDLL_wcstok( LPWSTR str, LPCWSTR delim )
+{
+    static LPWSTR next = NULL;
+    LPWSTR ret;
+
+    if (!str)
+        if (!(str = next)) return NULL;
+
+    while (*str && NTDLL_wcschr( delim, *str )) str++;
+    if (!*str) return NULL;
+    ret = str++;
+    while (*str && !NTDLL_wcschr( delim, *str )) str++;
+    if (*str) *str++ = 0;
+    next = str;
+    return ret;
+}
+
+
+/*********************************************************************
+ *           wcstombs    (NTDLL.@)
+ */
+INT __cdecl NTDLL_wcstombs( LPSTR dst, LPCWSTR src, INT n )
+{
+    INT ret;
+    if (n <= 0) return 0;
+    ret = WideCharToMultiByte( CP_ACP, 0, src, -1, dst, dst ? n : 0, NULL, NULL );
+    if (!ret) return n;  /* overflow */
+    return ret - 1;  /* do not count terminating NULL */
+}
+
+
+/*********************************************************************
+ *           mbstowcs    (NTDLL.@)
+ */
+INT __cdecl NTDLL_mbstowcs( LPWSTR dst, LPCSTR src, INT n )
+{
+    INT ret;
+    if (n <= 0) return 0;
+    ret = MultiByteToWideChar( CP_ACP, 0, src, -1, dst, dst ? n : 0 );
+    if (!ret) return n;  /* overflow */
+    return ret - 1;  /* do not count terminating NULL */
+}
+
+
+/*********************************************************************
+ *                  wcstol  (NTDLL.@)
+ * Like strtol, but for wide character strings.
+ */
+INT __cdecl NTDLL_wcstol(LPWSTR s,LPWSTR *end,INT base)
+{
+    LPSTR sA = HEAP_strdupWtoA(GetProcessHeap(),0,s),endA;
+    INT	ret = strtol(sA,&endA,base);
+
+    HeapFree(GetProcessHeap(),0,sA);
+    if (end) *end = s+(endA-sA); /* pointer magic checked. */
+    return ret;
+}
+
+
+/*********************************************************************
+ *           iswctype    (NTDLL.@)
+ */
+INT __cdecl NTDLL_iswctype( WCHAR wc, WCHAR wct )
+{
+    return (get_char_typeW(wc) & 0xfff) & wct;
+}
+
+
+/*********************************************************************
+ *           iswalpha    (NTDLL.@)
+ */
+INT __cdecl NTDLL_iswalpha( WCHAR wc )
+{
+    return get_char_typeW(wc) & C1_ALPHA;
+}
+
+
+/*********************************************************************
+ *           _ultow    (NTDLL.@)
+ * Like _ultoa, but for wide character strings.
+ */
+LPWSTR __cdecl _ultow(ULONG value, LPWSTR string, INT radix)
+{
+    WCHAR tmp[33];
+    LPWSTR tp = tmp;
+    LPWSTR sp;
+    LONG i;
+    ULONG v = value;
+
+    if (radix > 36 || radix <= 1)
+	return 0;
+
+    while (v || tp == tmp)
+    {
+	i = v % radix;
+	v = v / radix;
+	if (i < 10)
+	    *tp++ = i + '0';
+	else
+	    *tp++ = i + 'a' - 10;
+    }
+
+    sp = string;
+    while (tp > tmp)
+	*sp++ = *--tp;
+    *sp = 0;
+    return string;
+}
+
+/*********************************************************************
+ *           _wtol    (NTDLL.@)
+ * Like atol, but for wide character strings.
+ */
+LONG __cdecl _wtol(LPWSTR string)
+{
+    char buffer[30];
+    NTDLL_wcstombs( buffer, string, sizeof(buffer) );
+    return atol( buffer );
+}
+
+/*********************************************************************
+ *           _wtoi    (NTDLL.@)
+ */
+INT __cdecl _wtoi(LPWSTR string)
+{
+    return _wtol(string);
+}
+
+/* INTERNAL: Wide char snprintf
+ * If you fix a bug in this function, fix it in msvcrt/wcs.c also!
+ */
+static int __cdecl NTDLL_vsnwprintf(WCHAR *str, unsigned int len,
+                                    const WCHAR *format, va_list valist)
+{
+  unsigned int written = 0;
+  const WCHAR *iter = format;
+  char bufa[256], fmtbufa[64], *fmta;
+
+  TRACE("(%d,%s)\n",len,debugstr_w(format));
+
+  while (*iter)
+  {
+    while (*iter && *iter != (WCHAR)L'%')
+    {
+     if (written++ >= len)
+       return -1;
+     *str++ = *iter++;
+    }
+    if (*iter == (WCHAR)L'%')
+    {
+      fmta = fmtbufa;
+      *fmta++ = *iter++;
+      while (*iter == (WCHAR)L'0' ||
+             *iter == (WCHAR)L'+' ||
+             *iter == (WCHAR)L'-' ||
+             *iter == (WCHAR)L' ' ||
+             *iter == (WCHAR)L'0' ||
+             *iter == (WCHAR)L'*' ||
+             *iter == (WCHAR)L'#')
+      {
+        if (*iter == (WCHAR)L'*')
+        {
+          char *buffiter = bufa;
+          int fieldlen = va_arg(valist, int);
+          sprintf(buffiter, "%d", fieldlen);
+          while (*buffiter)
+            *fmta++ = *buffiter++;
+        }
+        else
+          *fmta++ = *iter;
+        iter++;
+      }
+
+      while (isdigit(*iter))
+        *fmta++ = *iter++;
+
+      if (*iter == (WCHAR)L'.')
+      {
+        *fmta++ = *iter++;
+        if (*iter == (WCHAR)L'*')
+        {
+          char *buffiter = bufa;
+          int fieldlen = va_arg(valist, int);
+          sprintf(buffiter, "%d", fieldlen);
+          while (*buffiter)
+            *fmta++ = *buffiter++;
+        }
+        else
+          while (isdigit(*iter))
+            *fmta++ = *iter++;
+      }
+      if (*iter == (WCHAR)L'h' ||
+          *iter == (WCHAR)L'l')
+      {
+          *fmta++ = *iter++;
+          *fmta++ = *iter++;
+      }
+
+      switch (*iter)
+      {
+      case (WCHAR)L's':
+        {
+          static const WCHAR none[] = { '(', 'n', 'u', 'l', 'l', ')', 0 };
+          const WCHAR *wstr = va_arg(valist, const WCHAR *);
+          const WCHAR *striter = wstr ? wstr : none;
+          while (*striter)
+          {
+            if (written++ >= len)
+              return -1;
+            *str++ = *striter++;
+          }
+          iter++;
+          break;
+        }
+
+      case (WCHAR)L'c':
+        if (written++ >= len)
+          return -1;
+        *str++ = (WCHAR)va_arg(valist, int);
+        iter++;
+        break;
+
+      default:
+        {
+          /* For non wc types, use system sprintf and append to wide char output */
+          /* FIXME: for unrecognised types, should ignore % when printing */
+          char *bufaiter = bufa;
+          if (*iter == (WCHAR)L'p')
+            sprintf(bufaiter, "%08lX", va_arg(valist, long));
+          else
+          {
+            *fmta++ = *iter;
+            *fmta = '\0';
+            if (*iter == (WCHAR)L'f')
+              sprintf(bufaiter, fmtbufa, va_arg(valist, double));
+            else
+              sprintf(bufaiter, fmtbufa, va_arg(valist, void *));
+          }
+          while (*bufaiter)
+          {
+            if (written++ >= len)
+              return -1;
+            *str++ = *bufaiter++;
+          }
+          iter++;
+          break;
+        }
+      }
+    }
+  }
+  if (written >= len)
+    return -1;
+  *str++ = (WCHAR)L'\0';
+  return (int)written;
+}
+
+
+/***********************************************************************
+ *        _snwprintf (NTDLL.@)
+ */
+int __cdecl _snwprintf(WCHAR *str, unsigned int len, const WCHAR *format, ...)
+{
+  int retval;
+  va_list valist;
+  va_start(valist, format);
+  retval = NTDLL_vsnwprintf(str, len, format, valist);
+  va_end(valist);
+  return retval;
+}
+
+
+/***********************************************************************
+ *        swprintf (NTDLL.@)
+ */
+int __cdecl NTDLL_swprintf(WCHAR *str, const WCHAR *format, ...)
+{
+  int retval;
+  va_list valist;
+  va_start(valist, format);
+  retval = NTDLL_vsnwprintf(str, INT_MAX, format, valist);
+  va_end(valist);
+  return retval;
+}
