Back to index

lightning-sunbird  0.9+nobinonly
Defines | Typedefs | Functions
nsGlueLinking.h File Reference
#include "nsXPCOMPrivate.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define XPCOM_DEPENDENT_LIBS_LIST   "dependentlibs.list"

Typedefs

typedef void(* DependentLibsCallback )(const char *aDependentLib)

Functions

 XPCOMGlueLoad (const char *xpcomFile)
 XPCOMGlueUnload ()
 XPCOMGlueLoadDependentLibs (const char *xpcomDir, DependentLibsCallback cb)

Define Documentation

#define XPCOM_DEPENDENT_LIBS_LIST   "dependentlibs.list"

Definition at line 43 of file nsGlueLinking.h.


Typedef Documentation

typedef void(* DependentLibsCallback)(const char *aDependentLib)

Definition at line 51 of file nsGlueLinking.h.


Function Documentation

XPCOMGlueLoad ( const char *  xpcomFile)

Definition at line 87 of file nsGlueLinkingDlopen.cpp.

{
    char xpcomDir[MAXPATHLEN];
    if (realpath(xpcomFile, xpcomDir)) {
        char *lastSlash = strrchr(xpcomDir, '/');
        if (lastSlash) {
            *lastSlash = '\0';

            XPCOMGlueLoadDependentLibs(xpcomDir, ReadDependentCB);

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

            sXULLibHandle = dlopen(xpcomDir, RTLD_GLOBAL | RTLD_LAZY);
        }
    }

    // RTLD_DEFAULT is not defined in non-GNU toolchains, and it is
    // (void*) 0 in any case.

    void *libHandle = nsnull;

    if (xpcomFile[0] != '.' || xpcomFile[1] != '\0') {
        libHandle = dlopen(xpcomFile, RTLD_GLOBAL | RTLD_LAZY);
        if (libHandle) {
            AppendDependentLib(libHandle);
        }
    }

    GetFrozenFunctionsFunc sym =
        (GetFrozenFunctionsFunc) dlsym(libHandle,
                                       LEADING_UNDERSCORE "NS_GetFrozenFunctions");

    if (!sym)
        XPCOMGlueUnload();

    return sym;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 103 of file nsXPCOMGlue.cpp.

{
    char buffer[MAXPATHLEN];
    sprintf(buffer, "%s" XPCOM_FILE_PATH_SEPARATOR XPCOM_DEPENDENT_LIBS_LIST,
            xpcomDir);

    FILE *flist = fopen(buffer, "r" READ_TEXTMODE);
    if (!flist)
        return;

    while (fgets(buffer, sizeof(buffer), flist)) {
        int l = strlen(buffer);

        // ignore empty lines and comments
        if (l == 0 || *buffer == '#')
            continue;

        // cut the trailing newline, if present
        if (buffer[l - 1] == '\n')
            buffer[l - 1] = '\0';

        char buffer2[MAXPATHLEN];
        snprintf(buffer2, sizeof(buffer2),
                 "%s" XPCOM_FILE_PATH_SEPARATOR "%s",
                 xpcomDir, buffer);
        cb(buffer2);
    }

    fclose(flist);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 126 of file nsGlueLinkingDlopen.cpp.

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

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

        delete temp;
    }

    if (sXULLibHandle) {
        dlclose(sXULLibHandle);
        sXULLibHandle = nsnull;
    }
}

Here is the caller graph for this function: