Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
nsGlueLinkingOS2.cpp File Reference
#include "nsGlueLinking.h"
#include "nsXPCOMGlue.h"
#include <os2.h>
#include <stdlib.h>
#include <stdio.h>

Go to the source code of this file.

Classes

struct  DependentLib

Defines

#define INCL_DOS
#define INCL_DOSERRORS

Functions

static void AppendDependentLib (HMODULE libHandle)
static void ReadDependentCB (const char *aDependentLib)
static char * ns_strrpbrk (char *string, const char *strCharSet)
GetFrozenFunctionsFunc XPCOMGlueLoad (const char *xpcomFile)
void XPCOMGlueUnload ()
nsresult XPCOMGlueLoadXULFunctions (const nsDynamicFunctionLoad *symbols)

Variables

static DependentLibsTop
HMODULE sXULLibrary = NULLHANDLE

Class Documentation

struct DependentLib

Definition at line 54 of file nsGlueLinkingDlopen.cpp.

Collaboration diagram for DependentLib:
Class Members
HINSTANCE libHandle
HMODULE libHandle
void * libHandle
DependentLib * next

Define Documentation

Definition at line 42 of file nsGlueLinkingOS2.cpp.

Definition at line 43 of file nsGlueLinkingOS2.cpp.


Function Documentation

static void AppendDependentLib ( HMODULE  libHandle) [static]

Definition at line 58 of file nsGlueLinkingOS2.cpp.

{
    DependentLib *d = new DependentLib;
    if (!d)
        return;

    d->next = sTop;
    d->libHandle = libHandle;

    sTop = d;
}

Here is the caller graph for this function:

static char* ns_strrpbrk ( char *  string,
const char *  strCharSet 
) [static]

Definition at line 87 of file nsGlueLinkingOS2.cpp.

{
    char *found = NULL;
    for (; *string; ++string) {
        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. 
            }
        }
    }

    return found;
}

Here is the caller graph for this function:

static void ReadDependentCB ( const char *  aDependentLib) [static]

Definition at line 71 of file nsGlueLinkingOS2.cpp.

{
    CHAR pszError[_MAX_PATH];
    ULONG ulrc = NO_ERROR;
    HMODULE h;

    ulrc = DosLoadModule(pszError, _MAX_PATH, aDependentLib, &h);

    if (ulrc != NO_ERROR)
        return;

    AppendDependentLib(h);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 104 of file nsGlueLinkingOS2.cpp.

{
    CHAR pszError[_MAX_PATH];
    ULONG ulrc = NO_ERROR;
    HMODULE h;

    if (xpcomFile[0] == '.' && xpcomFile[1] == '\0') {
        xpcomFile = XPCOM_DLL;
    }
    else {
        char xpcomDir[MAXPATHLEN];

        _fullpath(xpcomDir, xpcomFile, sizeof(xpcomDir));
        char *lastSlash = ns_strrpbrk(xpcomDir, "/\\");
        if (lastSlash) {
            *lastSlash = '\0';

            XPCOMGlueLoadDependentLibs(xpcomDir, ReadDependentCB);

            snprintf(lastSlash, MAXPATHLEN - strlen(xpcomDir), "\\" XUL_DLL);

            DosLoadModule(pszError, _MAX_PATH, xpcomDir, &sXULLibrary);
        }
    }

    ulrc = DosLoadModule(pszError, _MAX_PATH, xpcomFile, &h);

    if (ulrc != NO_ERROR)
        return nsnull;

    AppendDependentLib(h);

    GetFrozenFunctionsFunc sym;

    ulrc = DosQueryProcAddr(h, 0, "NS_GetFrozenFunctions", (PFN*)&sym);

    if (ulrc != NO_ERROR)
        XPCOMGlueUnload();

    return sym;
}

Here is the call graph for this function:

nsresult XPCOMGlueLoadXULFunctions ( const nsDynamicFunctionLoad *  symbols)

Definition at line 165 of file nsGlueLinkingOS2.cpp.

{
    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;
}

Definition at line 147 of file nsGlueLinkingOS2.cpp.

{
    while (sTop) {
        DosFreeModule(sTop->libHandle);

        DependentLib *temp = sTop;
        sTop = sTop->next;

        delete temp;
    }

    if (sXULLibrary) {
        DosFreeModule(sXULLibrary);
        sXULLibrary = nsnull;
    }
}

Variable Documentation

DependentLib* sTop [static]

Definition at line 54 of file nsGlueLinkingOS2.cpp.

HMODULE sXULLibrary = NULLHANDLE

Definition at line 55 of file nsGlueLinkingOS2.cpp.