Back to index

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

Go to the source code of this file.

Classes

struct  DependentLib

Functions

static void AppendDependentLib (HINSTANCE 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
HINSTANCE sXULLibrary

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

Function Documentation

static void AppendDependentLib ( HINSTANCE  libHandle) [static]

Definition at line 56 of file nsGlueLinkingWin.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 81 of file nsGlueLinkingWin.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 69 of file nsGlueLinkingWin.cpp.

{
    HINSTANCE h =
        LoadLibraryEx(aDependentLib, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
    if (!h)
        return;

    AppendDependentLib(h);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 98 of file nsGlueLinkingWin.cpp.

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

            sXULLibrary =
                LoadLibraryEx(xpcomDir, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
        }
    }

    HINSTANCE h =
        LoadLibraryEx(xpcomFile, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);

    if (!h)
        return nsnull;

    AppendDependentLib(h);

    GetFrozenFunctionsFunc sym =
        (GetFrozenFunctionsFunc) GetProcAddress(h, "NS_GetFrozenFunctions");

    if (!sym)
        XPCOMGlueUnload();

    return sym;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult XPCOMGlueLoadXULFunctions ( const nsDynamicFunctionLoad *  symbols)

Definition at line 156 of file nsGlueLinkingWin.cpp.

{
    if (!sXULLibrary)
        return NS_ERROR_NOT_INITIALIZED;

    nsresult rv = NS_OK;
    while (symbols->functionName) {
        *symbols->function = 
            (NSFuncPtr) GetProcAddress(sXULLibrary, symbols->functionName);
        if (!*symbols->function)
            rv = NS_ERROR_LOSS_OF_SIGNIFICANT_DATA;

        ++symbols;
    }

    return rv;
}

Definition at line 138 of file nsGlueLinkingWin.cpp.

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

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

        delete temp;
    }

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

Here is the caller graph for this function:


Variable Documentation

DependentLib* sTop [static]

Definition at line 52 of file nsGlueLinkingWin.cpp.

Definition at line 53 of file nsGlueLinkingWin.cpp.