From 836ec9014a9ba31067ab1a65874e51420a45b351 Mon Sep 17 00:00:00 2001 From: "mkaply%us.ibm.com" Date: Fri, 18 Nov 2005 18:48:45 +0000 Subject: [PATCH] OS/2 version of 316098 --- xpcom/glue/standalone/nsGlueLinkingOS2.cpp | 57 +++++++++++++++++----- 1 file changed, 45 insertions(+), 12 deletions(-) diff --git a/xpcom/glue/standalone/nsGlueLinkingOS2.cpp b/xpcom/glue/standalone/nsGlueLinkingOS2.cpp index 45b72cdd417..fabd99598f9 100644 --- a/xpcom/glue/standalone/nsGlueLinkingOS2.cpp +++ b/xpcom/glue/standalone/nsGlueLinkingOS2.cpp @@ -37,11 +37,13 @@ * ***** END LICENSE BLOCK ***** */ #include "nsGlueLinking.h" +#include "nsXPCOMGlue.h" #define INCL_DOS #define INCL_DOSERRORS #include #include +#include struct DependentLib { @@ -50,6 +52,7 @@ struct DependentLib }; static DependentLib *sTop; +HMODULE sXULLibrary = NULLHANDLE; static void AppendDependentLib(HMODULE libHandle) @@ -68,12 +71,12 @@ static void ReadDependentCB(const char *aDependentLib) { CHAR pszError[_MAX_PATH]; - ULONG ulRc = NO_ERROR; + ULONG ulrc = NO_ERROR; HMODULE h; - ulRc = DosLoadModule(pszError, _MAX_PATH, aDependentLib, &h); + ulrc = DosLoadModule(pszError, _MAX_PATH, aDependentLib, &h); - if (ulRc != NO_ERROR) + if (ulrc != NO_ERROR) return; AppendDependentLib(h); @@ -85,9 +88,11 @@ ns_strrpbrk(char *string, const char *strCharSet) { char *found = NULL; for (; *string; ++string) { - for(const char *search = strCharSet; *search; ++search) { + for (const char *search = strCharSet; *search; ++search) { if (*search == *string) { found = string; + // Since we're looking for the last char, we save "found" + // until we're at the end of the string. } } } @@ -98,6 +103,10 @@ ns_strrpbrk(char *string, const char *strCharSet) GetFrozenFunctionsFunc XPCOMGlueLoad(const char *xpcomFile) { + CHAR pszError[_MAX_PATH]; + ULONG ulrc = NO_ERROR; + HMODULE h; + if (xpcomFile[0] == '.' && xpcomFile[1] == '\0') { xpcomFile = XPCOM_DLL; } @@ -110,22 +119,20 @@ XPCOMGlueLoad(const char *xpcomFile) *lastSlash = '\0'; XPCOMGlueLoadDependentLibs(xpcomDir, ReadDependentCB); + + sprintf(lastSlash, "\\" XUL_DLL); + + DosLoadModule(pszError, _MAX_PATH, xpcomDir, &sXULLibrary); } } - CHAR pszError[_MAX_PATH]; - ULONG ulRc = NO_ERROR; - HMODULE h; + ulrc = DosLoadModule(pszError, _MAX_PATH, xpcomFile, &h); - ulRc = DosLoadModule(pszError, _MAX_PATH, xpcomFile, &h); - - if (ulRc != NO_ERROR) + if (ulrc != NO_ERROR) return nsnull; AppendDependentLib(h); - ULONG ulrc = NO_ERROR; - GetFrozenFunctionsFunc sym; ulrc = DosQueryProcAddr(h, 0, "NS_GetFrozenFunctions", (PFN*)&sym); @@ -147,4 +154,30 @@ XPCOMGlueUnload() delete temp; } + + if (sXULLibrary) { + DosFreeModule(sXULLibrary); + sXULLibrary = nsnull; + } +} + +nsresult +XPCOMGlueLoadXULFunctions(nsDynamicFunctionLoad *symbols) +{ + ULONG ulrc = NO_ERROR; + + if (!sXULLibrary) + return NS_ERROR_NOT_INITIALIZED; + + nsresult rv = NS_OK; + while (symbols->functionName) { + ulrc = DosQueryProcAddr(sXULLibrary, 0, symbols->functionName, (PFN*)symbols->function); + + if (ulrc != NO_ERROR) + rv = NS_ERROR_LOSS_OF_SIGNIFICANT_DATA; + + ++symbols; + } + + return rv; }