Convert most of the file APIs to Unicode.

diff --git a/msdos/dosconf.c b/msdos/dosconf.c
index f297894..636e8f7 100644
--- a/msdos/dosconf.c
+++ b/msdos/dosconf.c
@@ -435,17 +435,19 @@
 
 int DOSCONF_ReadConfig(void)
 {
-    char buffer[256];
+    WCHAR filename[MAX_PATH];
     DOS_FULL_NAME fullname;
-    char *filename, *menuname;
+    WCHAR *p;
     int ret = 1;
+    static const WCHAR wineW[] = {'w','i','n','e',0};
+    static const WCHAR config_sysW[] = {'c','o','n','f','i','g','.','s','y','s',0};
+    static const WCHAR empty_strW[] = { 0 };
 
-    PROFILE_GetWineIniString( "wine", "config.sys", "", buffer, sizeof(buffer) );
-    if (!(filename = strtok(buffer, ","))) return ret;
-    menuname = strtok(NULL,   ",");
+    PROFILE_GetWineIniString( wineW, config_sysW, empty_strW, filename, MAX_PATH );
+    if ((p = strchrW(filename, ','))) *p = 0;
+    if (!filename[0]) return ret;
 
     DOSFS_GetFullName(filename, FALSE, &fullname);
-    if (menuname) menu_default = strdup(menuname);
     if ((cfg_fd = fopen(fullname.long_name, "r")))
     {
         DOSCONF_Parse(NULL);
@@ -453,10 +455,9 @@
     }
     else
     {
-        MESSAGE("Couldn't open config.sys file given as \"%s\" in" \
-            " wine.conf or .winerc, section [wine] !\n", filename);
+        MESSAGE("Couldn't open config.sys file given as %s in" \
+            " wine.conf or .winerc, section [wine] !\n", debugstr_w(filename));
         ret = 0;
     }
-    if (menu_default) free(menu_default);
     return ret;
 }
diff --git a/msdos/int11.c b/msdos/int11.c
index d7ac9d7..bdcd34d 100644
--- a/msdos/int11.c
+++ b/msdos/int11.c
@@ -28,6 +28,7 @@
 #include "miscemu.h"
 #include "msdos.h"
 #include "file.h"
+#include "wine/unicode.h"
 #include "wine/debug.h"
 
 /**********************************************************************
@@ -74,16 +75,21 @@
 
     for (x=0; x < 9; x++)
     {
-        char temp[16],name[16];
+        WCHAR temp[16];
+        WCHAR comW[] = {'C','O','M','?',0};
+        WCHAR lptW[] = {'L','P','T','?',0};
+        static const WCHAR serialportsW[] = {'s','e','r','i','a','l','p','o','r','t','s',0};
+        static const WCHAR parallelportsW[] = {'p','a','r','a','l','l','e','l','p','o','r','t','s',0};
+        static const WCHAR asteriskW[] = {'*',0};
 
-        sprintf(name,"COM%d",x+1);
-        PROFILE_GetWineIniString("serialports",name,"*",temp,sizeof temp);
-        if(strcmp(temp,"*"))
+        comW[3] = '0' + x;
+        PROFILE_GetWineIniString(serialportsW, comW, asteriskW, temp, 16);
+        if(strcmpW(temp, asteriskW))
 	    serialports++;
 
-        sprintf(name,"LPT%d",x+1);
-        PROFILE_GetWineIniString("parallelports",name,"*",temp,sizeof temp);
-        if(strcmp(temp,"*"))
+        lptW[3] = '0' + x;
+        PROFILE_GetWineIniString(parallelportsW, lptW, asteriskW, temp, 16);
+        if(strcmpW(temp, asteriskW))
 	    parallelports++;
     }
     if (serialports > 7)		/* 3 bits -- maximum value = 7 */
diff --git a/msdos/int21.c b/msdos/int21.c
index cf7b3f3..d4851e0 100644
--- a/msdos/int21.c
+++ b/msdos/int21.c
@@ -57,6 +57,7 @@
 #include "msdos.h"
 #include "miscemu.h"
 #include "task.h"
+#include "wine/unicode.h"
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(int21);
@@ -428,30 +429,37 @@
         CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Esi );
     char *fcb =
         CTX_SEG_OFF_TO_LIN(context, context->SegEs, context->Edi );
-    char *buffer, *s, *d;
+    char *s;
+    WCHAR *buffer;
+    WCHAR fcbW[12];
+    INT buffer_len, len;
 
     AL_reg(context) = 0xff; /* failed */
 
     TRACE("filename: '%s'\n", filename);
 
-    buffer = HeapAlloc( GetProcessHeap(), 0, strlen(filename) + 1);
-
     s = filename;
-    d = buffer;
+    len = 0;
     while (*s)
     {
         if ((*s != ' ') && (*s != '\r') && (*s != '\n'))
-            *d++ = *s++;
+        {
+            s++;
+            len++;
+        }
         else
             break;
     }
 
-    *d = '\0';
-    DOSFS_ToDosFCBFormat(buffer, fcb + 1);
+    buffer_len = MultiByteToWideChar(CP_OEMCP, 0, filename, len, NULL, 0);
+    buffer = HeapAlloc( GetProcessHeap(), 0, (buffer_len + 1) * sizeof(WCHAR));
+    len = MultiByteToWideChar(CP_OEMCP, 0, filename, len, buffer, buffer_len);
+    buffer[len] = 0;
+    DOSFS_ToDosFCBFormat(buffer, fcbW);
+    HeapFree(GetProcessHeap(), 0, buffer);
+    WideCharToMultiByte(CP_OEMCP, 0, fcbW, 12, fcb + 1, 12, NULL, NULL);
     *fcb = 0;
-    TRACE("FCB: '%s'\n", ((CHAR *)fcb + 1));
-
-    HeapFree( GetProcessHeap(), 0, buffer);
+    TRACE("FCB: '%s'\n", fcb + 1);
 
     AL_reg(context) =
         ((strchr(filename, '*')) || (strchr(filename, '$'))) != 0;
@@ -618,6 +626,7 @@
 {
     int drive;
     char *dirname = CTX_SEG_OFF_TO_LIN(context, context->SegDs,context->Edx);
+    WCHAR dirnameW[MAX_PATH];
 
     TRACE("changedir %s\n", dirname);
     if (dirname[0] && (dirname[1] == ':'))
@@ -626,7 +635,8 @@
         dirname += 2;
     }
     else drive = DRIVE_GetCurrentDrive();
-    return DRIVE_Chdir( drive, dirname );
+    MultiByteToWideChar(CP_OEMCP, 0, dirname, -1, dirnameW, MAX_PATH);
+    return DRIVE_Chdir( drive, dirnameW );
 }
 
 
@@ -636,10 +646,14 @@
     const char *path;
     DOS_FULL_NAME full_name;
     FINDFILE_DTA *dta = (FINDFILE_DTA *)GetCurrentDTA(context);
+    WCHAR pathW[MAX_PATH];
+    WCHAR maskW[12];
 
     path = (const char *)CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx);
+    MultiByteToWideChar(CP_OEMCP, 0, path, -1, pathW, MAX_PATH);
+
     dta->unixPath = NULL;
-    if (!DOSFS_GetFullName( path, FALSE, &full_name ))
+    if (!DOSFS_GetFullName( pathW, FALSE, &full_name ))
     {
         AX_reg(context) = GetLastError();
         SET_CFLAG(context);
@@ -650,10 +664,12 @@
     p = strrchr( dta->unixPath, '/' );
     *p = '\0';
 
+    MultiByteToWideChar(CP_OEMCP, 0, p + 1, -1, pathW, MAX_PATH);
+
     /* Note: terminating NULL in dta->mask overwrites dta->search_attr
      *       (doesn't matter as it is set below anyway)
      */
-    if (!DOSFS_ToDosFCBFormat( p + 1, dta->mask ))
+    if (!DOSFS_ToDosFCBFormat( pathW, maskW ))
     {
         HeapFree( GetProcessHeap(), 0, dta->unixPath );
         dta->unixPath = NULL;
@@ -662,6 +678,7 @@
         SET_CFLAG(context);
         return 0;
     }
+    WideCharToMultiByte(CP_OEMCP, 0, maskW, 12, dta->mask, sizeof(dta->mask), NULL, NULL);
     dta->drive = (path[0] && (path[1] == ':')) ? toupper(path[0]) - 'A'
                                                : DRIVE_GetCurrentDrive();
     dta->count = 0;
@@ -743,7 +760,8 @@
         SetLastError( ERROR_INVALID_DRIVE );
         return FALSE;
     }
-    lstrcpynA( ptr, DRIVE_GetDosCwd(drive), 64 );
+    WideCharToMultiByte(CP_OEMCP, 0, DRIVE_GetDosCwd(drive), -1, ptr, 64, NULL, NULL);
+    ptr[63] = 0; /* ensure 0 termination */
     AX_reg(context) = 0x0100;			     /* success return code */
     return TRUE;
 }
@@ -1586,8 +1604,9 @@
             break;
         case 0x02:{
             const DOS_DEVICE *dev;
+            static const WCHAR scsimgrW[] = {'S','C','S','I','M','G','R','$',0};
             if ((dev = DOSFS_GetDeviceByHandle( DosFileHandleToWin32Handle(BX_reg(context)) )) &&
-                !strcasecmp( dev->name, "SCSIMGR$" ))
+                !strcmpiW( dev->name, scsimgrW ))
             {
                 ASPI_DOS_HandleInt(context);
             }
diff --git a/msdos/ioports.c b/msdos/ioports.c
index 3a36ce3..f8e3b7c 100644
--- a/msdos/ioports.c
+++ b/msdos/ioports.c
@@ -36,6 +36,7 @@
 # include <unistd.h>
 #endif
 #include "windef.h"
+#include "winnls.h"
 #include "callback.h"
 #include "file.h"
 #include "miscemu.h"
@@ -249,17 +250,22 @@
 static void IO_port_init(void)
 {
 	char temp[1024];
+	WCHAR tempW[1024];
+        static const WCHAR portsW[] = {'p','o','r','t','s',0};
+        static const WCHAR readW[] = {'r','e','a','d',0};
+        static const WCHAR writeW[] = {'w','r','i','t','e',0};
+        static const WCHAR asteriskW[] = {'*',0};
 
         do_direct_port_access = 0;
 	/* Can we do that? */
 	if (!iopl(3)) {
 		iopl(0);
 
-		PROFILE_GetWineIniString( "ports", "read", "*",
-					 temp, sizeof(temp) );
+		PROFILE_GetWineIniString( portsW, readW, asteriskW, tempW, 1024 );
+		WideCharToMultiByte(CP_ACP, 0, tempW, -1, temp, 1024, NULL, NULL);
 		do_IO_port_init_read_or_write(temp, IO_READ);
-		PROFILE_GetWineIniString( "ports", "write", "*",
-					 temp, sizeof(temp) );
+		PROFILE_GetWineIniString( portsW, writeW, asteriskW, tempW, 1024 );
+		WideCharToMultiByte(CP_ACP, 0, tempW, -1, temp, 1024, NULL, NULL);
 		do_IO_port_init_read_or_write(temp, IO_WRITE);
 	}
     IO_FixCMOSCheckSum();