summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwtchang%redhat.com <devnull@localhost>2006-02-20 20:00:53 +0000
committerwtchang%redhat.com <devnull@localhost>2006-02-20 20:00:53 +0000
commit37a8991d27e5801409b8e8fd494e6e6222c992be (patch)
tree6f139b8582a920ba1529651aa17ae141c751fa2b
parent285dc32ecc68f6424e994feff0e24e82513d137a (diff)
downloadnspr-hg-37a8991d27e5801409b8e8fd494e6e6222c992be.tar.gz
Bugzilla Bug 327448: it's not necessary to do dynamic lookup of the W
functions because they are also defined (as stubs) on Windows 9x. Map ERROR_CALL_NOT_IMPLEMENTED to PR_NOT_IMPLEMENTED_ERROR. The patch is contributed by Masatoshi Kimura (emk) <VYV03354@nifty.ne.jp>. r=wtc,jshin. Tag: NSPRPUB_PRE_4_2_CLIENT_BRANCH
-rw-r--r--pr/src/md/windows/w95io.c49
-rw-r--r--pr/src/md/windows/win32_errors.c3
2 files changed, 11 insertions, 41 deletions
diff --git a/pr/src/md/windows/w95io.c b/pr/src/md/windows/w95io.c
index fb178b5c..81be67b1 100644
--- a/pr/src/md/windows/w95io.c
+++ b/pr/src/md/windows/w95io.c
@@ -1120,36 +1120,23 @@ _PR_MD_PIPEAVAILABLE(PRFileDesc *fd)
#ifdef MOZ_UNICODE
typedef HANDLE (WINAPI *CreateFileWFn) (LPCWSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE);
-static CreateFileWFn createFileW = NULL;
+static CreateFileWFn createFileW = CreateFileW;
typedef HANDLE (WINAPI *FindFirstFileWFn) (LPCWSTR, LPWIN32_FIND_DATAW);
-static FindFirstFileWFn findFirstFileW = NULL;
+static FindFirstFileWFn findFirstFileW = FindFirstFileW;
typedef BOOL (WINAPI *FindNextFileWFn) (HANDLE, LPWIN32_FIND_DATAW);
-static FindNextFileWFn findNextFileW = NULL;
+static FindNextFileWFn findNextFileW = FindNextFileW;
typedef DWORD (WINAPI *GetFullPathNameWFn) (LPCWSTR, DWORD, LPWSTR, LPWSTR *);
-static GetFullPathNameWFn getFullPathNameW = NULL;
+static GetFullPathNameWFn getFullPathNameW = GetFullPathNameW;
typedef UINT (WINAPI *GetDriveTypeWFn) (LPCWSTR);
-static GetDriveTypeWFn getDriveTypeW = NULL;
+static GetDriveTypeWFn getDriveTypeW = GetDriveTypeW;
static void InitUnicodeSupport(void)
{
- HMODULE module;
-
/*
- * The W functions do not exist on Win9x. NSPR won't run on Win9x
- * if we call the W functions directly. Use GetProcAddress() to
- * look up their addresses at run time.
+ * The W functions exist on Win9x as stubs that fail with the
+ * ERROR_CALL_NOT_IMPLEMENTED error. We plan to emulate the
+ * MSLU W functions on Win9x in the future.
*/
-
- module = GetModuleHandle("Kernel32.dll");
- if (!module) {
- return;
- }
-
- createFileW = (CreateFileWFn)GetProcAddress(module, "CreateFileW");
- findFirstFileW = (FindFirstFileWFn)GetProcAddress(module, "FindFirstFileW");
- findNextFileW = (FindNextFileWFn)GetProcAddress(module, "FindNextFileW");
- getDriveTypeW = (GetDriveTypeWFn)GetProcAddress(module, "GetDriveTypeW");
- getFullPathNameW = (GetFullPathNameWFn)GetProcAddress(module, "GetFullPathNameW");
}
/* ================ UTF16 Interfaces ================================ */
@@ -1175,11 +1162,6 @@ _PR_MD_OPEN_FILE_UTF16(const PRUnichar *name, PRIntn osflags, int mode)
PSECURITY_DESCRIPTOR pSD = NULL;
PACL pACL = NULL;
- if (!createFileW) {
- PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
- return -1;
- }
-
if (osflags & PR_CREATE_FILE) {
if (_PR_NT_MakeSecurityDescriptorACL(mode, fileAccessTable,
&pSD, &pACL) == PR_SUCCESS) {
@@ -1235,11 +1217,6 @@ _PR_MD_OPEN_DIR_UTF16(_MDDirUTF16 *d, const PRUnichar *name)
PRUnichar filename[ MAX_PATH ];
int len;
- if (!findFirstFileW) {
- PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
- return PR_FAILURE;
- }
-
len = wcslen(name);
/* Need 5 bytes for \*.* and the trailing null byte. */
if (len + 5 > MAX_PATH) {
@@ -1275,11 +1252,6 @@ _PR_MD_READ_DIR_UTF16(_MDDirUTF16 *d, PRIntn flags)
BOOL rv;
PRUnichar *fileName;
- if (!findNextFileW) {
- PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
- return NULL;
- }
-
if ( d ) {
while (1) {
if (d->firstEntry) {
@@ -1425,11 +1397,6 @@ _PR_MD_GETFILEINFO64_UTF16(const PRUnichar *fn, PRFileInfo64 *info)
WIN32_FIND_DATAW findFileData;
PRUnichar pathbuf[MAX_PATH + 1];
- if (!findFirstFileW || !getFullPathNameW || !getDriveTypeW) {
- PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
- return -1;
- }
-
if (NULL == fn || L'\0' == *fn) {
PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
return -1;
diff --git a/pr/src/md/windows/win32_errors.c b/pr/src/md/windows/win32_errors.c
index 0cf1bb58..ced1b7aa 100644
--- a/pr/src/md/windows/win32_errors.c
+++ b/pr/src/md/windows/win32_errors.c
@@ -89,6 +89,9 @@ void _MD_win32_map_default_error(PRInt32 err)
case ERROR_ALREADY_EXISTS:
prError = PR_FILE_EXISTS_ERROR;
break;
+ case ERROR_CALL_NOT_IMPLEMENTED:
+ prError = PR_NOT_IMPLEMENTED_ERROR;
+ break;
case ERROR_DISK_CORRUPT:
prError = PR_IO_ERROR;
break;