Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
nsRegistry.cpp File Reference
#include "nsIGenericFactory.h"
#include "nsRegistry.h"
#include "nsIEnumerator.h"
#include "nsDirectoryService.h"
#include "nsDirectoryServiceDefs.h"
#include "nsAppDirectoryServiceDefs.h"
#include "NSReg.h"
#include "prmem.h"
#include "prlock.h"
#include "prlog.h"
#include "prprf.h"
#include "nsCRT.h"
#include "nsMemory.h"
#include "nsCOMPtr.h"
#include "nsILocalFile.h"
#include "nsIServiceManager.h"
#include "nsTextFormatter.h"
#include "nsIFactory.h"

Go to the source code of this file.

Classes

struct  nsRegistryFactory
struct  nsRegSubtreeEnumerator
struct  nsRegValueEnumerator
struct  nsRegistryNode
struct  nsRegistryValue

Defines

#define PR_Lock(x)   (void)0
#define PR_Unlock(x)   (void)0
#define NS_MOZILLA_DIR_PERMISSION   00700

Functions

static nsresult regerr2nsresult (REGERR err)
static void reginfo2DataType (const REGINFO &in, PRUint32 &out)
static void reginfo2Length (const REGINFO &in, PRUint32 &out)
 NS_IMPL_ISUPPORTS2 (nsRegSubtreeEnumerator, nsIEnumerator, nsIRegistryEnumerator) nsRegistry
static void EnsureDefaultRegistryDirectory ()
NS_EXPORT nsresult NS_RegistryGetFactory (nsIFactory **aFactory)

Variables

NS_COM PRLogModuleInfonsComponentManagerLog
PRUnichar widestrFormat [] = { PRUnichar('%'),PRUnichar('s'),PRUnichar(0)}
static const char sEscapeKeyHex [] = "0123456789abcdef0123456789ABCDEF"

Define Documentation

Definition at line 91 of file nsRegistry.cpp.

#define PR_Lock (   x)    (void)0

Definition at line 70 of file nsRegistry.cpp.

#define PR_Unlock (   x)    (void)0

Definition at line 71 of file nsRegistry.cpp.


Function Documentation

static void EnsureDefaultRegistryDirectory ( ) [static]

Definition at line 461 of file nsRegistry.cpp.

                                 {
#if defined(XP_UNIX) && !defined(XP_MACOSX)
    // Create ~/.mozilla as that is the default place for the registry file

    /* The default registry on the unix system is $HOME/.mozilla/registry per
     * vr_findGlobalRegName(). vr_findRegFile() will create the registry file
     * if it doesn't exist. But it wont create directories.
     *
     * Hence we need to create the directory if it doesn't exist already.
     *
     * Why create it here as opposed to the app ?
     * ------------------------------------------
     * The app cannot create the directory in main() as most of the registry
     * and initialization happens due to use of static variables.
     * And we dont want to be dependent on the order in which
     * these static stuff happen.
     *
     * Permission for the $HOME/.mozilla will be Read,Write,Execute
     * for user only. Nothing to group and others.
     */
    char *home = getenv("HOME");
    if (home != NULL)
    {
        char dotMozillaDir[1024];
        PR_snprintf(dotMozillaDir, sizeof(dotMozillaDir),
                    "%s/" MOZ_USER_DIR, home);
        if (PR_Access(dotMozillaDir, PR_ACCESS_EXISTS) != PR_SUCCESS)
        {
            PR_MkDir(dotMozillaDir, NS_MOZILLA_DIR_PERMISSION);
            PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
                   ("nsComponentManager: Creating Directory %s", dotMozillaDir));
        }
    }
#endif /* XP_UNIX */

#ifdef XP_BEOS
    BPath p;
    const char *settings = "/boot/home/config/settings";
    if(find_directory(B_USER_SETTINGS_DIRECTORY, &p) == B_OK)
        settings = p.Path();
    char settingsMozillaDir[1024];
    PR_snprintf(settingsMozillaDir, sizeof(settingsMozillaDir),
                "%s/" MOZ_USER_DIR, settings);
    if (PR_Access(settingsMozillaDir, PR_ACCESS_EXISTS) != PR_SUCCESS) {
        PR_MkDir(settingsMozillaDir, NS_MOZILLA_DIR_PERMISSION);
        PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
               ("nsComponentManager: Creating Directory %s", settingsMozillaDir));
    }
#endif
}

Here is the call graph for this function:

Definition at line 368 of file nsRegistry.cpp.

    : mReg(0), mCurRegID(0) {
#ifdef EXTRA_THREADSAFE
    mregLock = PR_NewLock();
#endif
    NR_StartupRegistry();
    return;
}

Here is the call graph for this function:

Definition at line 2001 of file nsRegistry.cpp.

                                              {
    nsresult rv = NS_OK;

    if( aFactory == 0 ) {
        return NS_ERROR_NULL_POINTER;
    } else {
        *aFactory = 0;
    }

    nsIFactory* inst = new nsRegistryFactory();
    if(0 == inst) {
        rv = NS_ERROR_OUT_OF_MEMORY;
    } else {
        NS_ADDREF(inst);
        *aFactory = inst;
    }

    return rv;
}

Here is the call graph for this function:

static nsresult regerr2nsresult ( REGERR  err) [static]

Definition at line 250 of file nsRegistry.cpp.

Here is the caller graph for this function:

static void reginfo2DataType ( const REGINFO in,
PRUint32 out 
) [static]

Definition at line 311 of file nsRegistry.cpp.

                                                                 {
    // Transfer information, based on entry type.
    switch( in.entryType ) {
        case REGTYPE_ENTRY_STRING_UTF:
            out = nsIRegistry::String;
            //out.length = in.entryLength;
            break;

        case REGTYPE_ENTRY_INT32_ARRAY:
            out = nsIRegistry::Int32;
            // Convert length in bytes to array dimension.
            //out.length = in.entryLength / sizeof(PRInt32);
            break;

        case REGTYPE_ENTRY_BYTES:
            out = nsIRegistry::Bytes;
            //out.length = in.entryLength;
            break;

        case REGTYPE_ENTRY_FILE:
            out = nsIRegistry::File;
            //out.length = in.entryLength;
            break;
    }
}
static void reginfo2Length ( const REGINFO in,
PRUint32 out 
) [static]

Definition at line 341 of file nsRegistry.cpp.

                                                               {
    // Transfer information, based on entry type.
    switch( in.entryType ) {
        case REGTYPE_ENTRY_STRING_UTF:
            out = in.entryLength;
            break;

        case REGTYPE_ENTRY_INT32_ARRAY:
            // Convert length in bytes to array dimension.
            out = in.entryLength / sizeof(PRInt32);
            break;

        case REGTYPE_ENTRY_BYTES:
            out = in.entryLength;
            break;

        case REGTYPE_ENTRY_FILE:
            out = in.entryLength;
            break;
    }
}

Variable Documentation

Definition at line 98 of file nsComponentManager.cpp.

const char sEscapeKeyHex[] = "0123456789abcdef0123456789ABCDEF" [static]

Definition at line 1414 of file nsRegistry.cpp.

Definition at line 77 of file nsRegistry.cpp.