Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
nsXPCOMGlue.cpp File Reference
#include "nsXPCOMGlue.h"
#include "nsGlueLinking.h"
#include "nspr.h"
#include "nsDebug.h"
#include "nsIServiceManager.h"
#include "nsGREDirServiceProvider.h"
#include "nsXPCOMPrivate.h"
#include "nsCOMPtr.h"
#include <stdlib.h>
#include <stdio.h>

Go to the source code of this file.

Defines

#define READ_TEXTMODE

Functions

nsresult GlueStartupDebug ()
void GlueShutdownDebug ()
nsresult XPCOMGlueStartup (const char *xpcomFile)
void XPCOMGlueLoadDependentLibs (const char *xpcomDir, DependentLibsCallback cb)
nsresult XPCOMGlueShutdown ()
NS_COM nsresult NS_InitXPCOM2 (nsIServiceManager **result, nsIFile *binDirectory, nsIDirectoryServiceProvider *appFileLocationProvider)
 Initialises XPCOM.
NS_COM nsresult NS_InitXPCOM3 (nsIServiceManager **result, nsIFile *binDirectory, nsIDirectoryServiceProvider *appFileLocationProvider, nsStaticModuleInfo const *staticComponents, PRUint32 componentCount)
 Initialises XPCOM with static components.
NS_COM nsresult NS_ShutdownXPCOM (nsIServiceManager *servMgr)
 Shutdown XPCOM.
NS_COM nsresult NS_GetServiceManager (nsIServiceManager **result)
 Public Method to access to the service manager.
NS_COM nsresult NS_GetComponentManager (nsIComponentManager **result)
 Public Method to access to the component manager.
NS_COM nsresult NS_GetComponentRegistrar (nsIComponentRegistrar **result)
 Public Method to access to the component registration manager.
NS_COM nsresult NS_GetMemoryManager (nsIMemory **result)
 Public Method to access to the memory manager.
NS_COM nsresult NS_NewLocalFile (const nsAString &path, PRBool followLinks, nsILocalFile **result)
 Public Method to create an instance of a nsILocalFile.
NS_COM nsresult NS_NewNativeLocalFile (const nsACString &path, PRBool followLinks, nsILocalFile **result)
NS_COM nsresult NS_RegisterXPCOMExitRoutine (XPCOMExitRoutine exitRoutine, PRUint32 priority)
NS_COM nsresult NS_UnregisterXPCOMExitRoutine (XPCOMExitRoutine exitRoutine)
NS_COM nsresult NS_GetDebug (nsIDebug **result)
NS_COM nsresult NS_GetTraceRefcnt (nsITraceRefcnt **result)
NS_COM nsresult NS_StringContainerInit (nsStringContainer &aStr)
 NS_StringContainerInit.
NS_COM nsresult NS_StringContainerInit2 (nsStringContainer &aStr, const PRUnichar *aData, PRUint32 aDataLength, PRUint32 aFlags)
 NS_StringContainerInit2.
NS_COM void NS_StringContainerFinish (nsStringContainer &aStr)
 NS_StringContainerFinish.
NS_COM PRUint32 NS_StringGetData (const nsAString &aStr, const PRUnichar **aBuf, PRBool *aTerm)
 NS_StringGetData.
NS_COM PRUint32 NS_StringGetMutableData (nsAString &aStr, PRUint32 aLen, PRUnichar **aBuf)
 NS_StringGetMutableData.
NS_COM PRUnicharNS_StringCloneData (const nsAString &aStr)
 NS_StringCloneData.
NS_COM nsresult NS_StringSetData (nsAString &aStr, const PRUnichar *aBuf, PRUint32 aCount)
 NS_StringSetData.
NS_COM nsresult NS_StringSetDataRange (nsAString &aStr, PRUint32 aCutStart, PRUint32 aCutLength, const PRUnichar *aBuf, PRUint32 aCount)
 NS_StringSetDataRange.
NS_COM nsresult NS_StringCopy (nsAString &aDest, const nsAString &aSrc)
 NS_StringCopy.
NS_COM nsresult NS_CStringContainerInit (nsCStringContainer &aStr)
 NS_CStringContainerInit.
NS_COM nsresult NS_CStringContainerInit2 (nsCStringContainer &aStr, const char *aData, PRUint32 aDataLength, PRUint32 aFlags)
 NS_CStringContainerInit2.
NS_COM void NS_CStringContainerFinish (nsCStringContainer &aStr)
 NS_CStringContainerFinish.
NS_COM PRUint32 NS_CStringGetData (const nsACString &aStr, const char **aBuf, PRBool *aTerm)
 NS_CStringGetData.
NS_COM PRUint32 NS_CStringGetMutableData (nsACString &aStr, PRUint32 aLen, char **aBuf)
 NS_CStringGetMutableData.
NS_COM char * NS_CStringCloneData (const nsACString &aStr)
 NS_CStringCloneData.
NS_COM nsresult NS_CStringSetData (nsACString &aStr, const char *aBuf, PRUint32 aCount)
 NS_CStringSetData.
NS_COM nsresult NS_CStringSetDataRange (nsACString &aStr, PRUint32 aCutStart, PRUint32 aCutLength, const char *aBuf, PRUint32 aCount)
 NS_CStringSetDataRange.
NS_COM nsresult NS_CStringCopy (nsACString &aDest, const nsACString &aSrc)
 NS_CStringCopy.
NS_COM nsresult NS_CStringToUTF16 (const nsACString &aSrc, nsCStringEncoding aSrcEncoding, nsAString &aDest)
 NS_CStringToUTF16.
NS_COM nsresult NS_UTF16ToCString (const nsAString &aSrc, nsCStringEncoding aDestEncoding, nsACString &aDest)
 NS_UTF16ToCString.
NS_COM voidNS_Alloc (PRSize size)
 Allocates a block of memory of a particular size.
NS_COM voidNS_Realloc (void *ptr, PRSize size)
 Reallocates a block of memory to a new size.
NS_COM void NS_Free (void *ptr)
 Frees a block of memory.
nsresult GRE_Startup ()
nsresult GRE_Shutdown ()

Variables

static XPCOMFunctions xpcomFunctions

Define Documentation

Definition at line 99 of file nsXPCOMGlue.cpp.


Function Documentation

Here is the caller graph for this function:

Here is the caller graph for this function:

Definition at line 515 of file nsXPCOMGlue.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 460 of file nsXPCOMGlue.cpp.

{
    const char* xpcomLocation = GRE_GetXPCOMPath();

    // Startup the XPCOM Glue that links us up with XPCOM.
    nsresult rv = XPCOMGlueStartup(xpcomLocation);
    
    if (NS_FAILED(rv)) {
        NS_WARNING("gre: XPCOMGlueStartup failed");
        return rv;
    }

#ifdef XP_WIN
    // On windows we have legacy GRE code that does not load the GRE dependent
    // libs (seamonkey GRE, not libxul)... add the GRE to the PATH.
    // See bug 301043.

    const char *lastSlash = strrchr(xpcomLocation, '\\');
    if (lastSlash) {
        int xpcomPathLen = lastSlash - xpcomLocation;
        DWORD pathLen = GetEnvironmentVariable("PATH", nsnull, 0);

        char *newPath = (char*) _alloca(xpcomPathLen + pathLen + 1);
        strncpy(newPath, xpcomLocation, xpcomPathLen);
        // in case GetEnvironmentVariable fails
        newPath[xpcomPathLen] = ';';
        newPath[xpcomPathLen + 1] = '\0';

        GetEnvironmentVariable("PATH", newPath + xpcomPathLen + 1, pathLen);
        SetEnvironmentVariable("PATH", newPath);
    }
#endif

    nsGREDirServiceProvider *provider = new nsGREDirServiceProvider();
    if ( !provider ) {
        NS_WARNING("GRE_Startup failed");
        XPCOMGlueShutdown();
        return NS_ERROR_OUT_OF_MEMORY;
    }

    nsCOMPtr<nsIServiceManager> servMan;
    NS_ADDREF( provider );
    rv = NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, provider);
    NS_RELEASE(provider);

    if ( NS_FAILED(rv) || !servMan) {
        NS_WARNING("gre: NS_InitXPCOM failed");
        XPCOMGlueShutdown();
        return rv;
    }

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_COM void* NS_Alloc ( PRSize  size)

Allocates a block of memory of a particular size.

If the memory cannot be allocated (because of an out-of-memory condition), null is returned.

FROZEN

Parameters:
sizeThe size of the block to allocate
Returns:
The block of memory
Note:
This function is thread-safe.

Definition at line 435 of file nsXPCOMGlue.cpp.

NS_COM char* NS_CStringCloneData ( const nsACString &  aStr)

NS_CStringCloneData.

This function returns a null-terminated copy of the string's internal buffer.

Parameters:
aStrabstract string reference
Returns:
null-terminated copy of the string's internal buffer (it must be free'd using using nsMemory::Free)

FROZEN

Definition at line 386 of file nsXPCOMGlue.cpp.

NS_CStringContainerFinish.

Parameters:
aContainerstring container reference

This function frees any memory owned by aContainer.

FROZEN

Definition at line 359 of file nsXPCOMGlue.cpp.

NS_CStringContainerInit.

Parameters:
aContainerstring container reference
Returns:
NS_OK if string container successfully initialized

This function may allocate additional memory for aContainer. When aContainer is no longer needed, NS_CStringContainerFinish should be called.

FROZEN

Definition at line 340 of file nsXPCOMGlue.cpp.

NS_COM nsresult NS_CStringContainerInit2 ( nsCStringContainer aContainer,
const char *  aData = nsnull,
PRUint32  aDataLength = PR_UINT32_MAX,
PRUint32  aFlags = 0 
)

NS_CStringContainerInit2.

Parameters:
aContainerstring container reference
aDatacharacter buffer (may be null)
aDataLengthnumber of characters stored at aData (may pass PR_UINT32_MAX if aData is null-terminated)
aFlagsflags affecting how the string container is initialized. this parameter is ignored when aData is null. otherwise, if this parameter is 0, then aData is copied into the string.

This function resembles NS_CStringContainerInit but provides further options that permit more efficient memory usage. When aContainer is no longer needed, NS_CStringContainerFinish should be called.

NOTE: NS_CStringContainerInit2(container, nsnull, 0, 0) is equivalent to NS_CStringContainerInit(container).

FROZEN

Definition at line 348 of file nsXPCOMGlue.cpp.

NS_COM nsresult NS_CStringCopy ( nsACString &  aDestStr,
const nsACString &  aSrcStr 
)

NS_CStringCopy.

This function makes aDestStr have the same value as aSrcStr. It is provided as an optimization.

Parameters:
aDestStrabstract string reference to be modified
aSrcStrabstract string reference containing source string
Returns:
NS_OK if function succeeded

This function does not necessarily null-terminate aDestStr after copying data from aSrcStr. The behavior depends on the implementation of the abstract string, aDestStr. If aDestStr is a reference to a nsStringContainer, then its data will be null-terminated by this function.

FROZEN

Definition at line 411 of file nsXPCOMGlue.cpp.

NS_COM PRUint32 NS_CStringGetData ( const nsACString &  aStr,
const char **  aData,
PRBool aTerminated = nsnull 
)

NS_CStringGetData.

This function returns a const character pointer to the string's internal buffer, the length of the string, and a boolean value indicating whether or not the buffer is null-terminated.

Parameters:
aStrabstract string reference
aDataout param that will hold the address of aStr's internal buffer
aTerminatedif non-null, this out param will be set to indicate whether or not aStr's internal buffer is null- terminated
Returns:
length of aStr's internal buffer

FROZEN

Definition at line 366 of file nsXPCOMGlue.cpp.

{
    if (!xpcomFunctions.cstringGetData) {
        *aBuf = nsnull;
        return 0;
    }
    return xpcomFunctions.cstringGetData(aStr, aBuf, aTerm);
}
NS_COM PRUint32 NS_CStringGetMutableData ( nsACString &  aStr,
PRUint32  aDataLength,
char **  aData 
)

NS_CStringGetMutableData.

This function provides mutable access to a string's internal buffer. It returns a pointer to an array of characters that may be modified. The returned pointer remains valid until the string object is passed to some other string function.

Optionally, this function may be used to resize the string's internal buffer. The aDataLength parameter specifies the requested length of the string's internal buffer. By passing some value other than PR_UINT32_MAX, the caller can request that the buffer be resized to the specified number of characters before returning. The caller is not responsible for writing a null-terminator.

Parameters:
aStrabstract string reference
aDataLengthnumber of characters to resize the string's internal buffer to or PR_UINT32_MAX if no resizing is needed
aDataout param that upon return holds the address of aStr's internal buffer or null if the function failed
Returns:
number of characters or zero if the function failed

This function does not necessarily null-terminate aStr after resizing its internal buffer. The behavior depends on the implementation of the abstract string, aStr. If aStr is a reference to a nsStringContainer, then its data will be null-terminated by this function.

FROZEN

Definition at line 376 of file nsXPCOMGlue.cpp.

{
    if (!xpcomFunctions.cstringGetMutableData) {
        *aBuf = nsnull;
        return 0;
    }
    return xpcomFunctions.cstringGetMutableData(aStr, aLen, aBuf);
}
NS_COM nsresult NS_CStringSetData ( nsACString &  aStr,
const char *  aData,
PRUint32  aDataLength = PR_UINT32_MAX 
)

NS_CStringSetData.

This function copies aData into aStr.

Parameters:
aStrabstract string reference
aDatacharacter buffer
aDataLengthnumber of characters to copy from source string (pass PR_UINT32_MAX to copy until end of aData, designated by a null character)
Returns:
NS_OK if function succeeded

This function does not necessarily null-terminate aStr after copying data from aData. The behavior depends on the implementation of the abstract string, aStr. If aStr is a reference to a nsStringContainer, then its data will be null-terminated by this function.

FROZEN

Definition at line 394 of file nsXPCOMGlue.cpp.

NS_COM nsresult NS_CStringSetDataRange ( nsACString &  aStr,
PRUint32  aCutOffset,
PRUint32  aCutLength,
const char *  aData,
PRUint32  aDataLength = PR_UINT32_MAX 
)

NS_CStringSetDataRange.

This function copies aData into a section of aStr. As a result it can be used to insert new characters into the string.

Parameters:
aStrabstract string reference
aCutOffsetstarting index where the string's existing data is to be overwritten (pass PR_UINT32_MAX to cause aData to be appended to the end of aStr, in which case the value of aCutLength is ignored).
aCutLengthnumber of characters to overwrite starting at aCutOffset (pass PR_UINT32_MAX to overwrite until the end of aStr).
aDatacharacter buffer (pass null to cause this function to simply remove the "cut" range)
aDataLengthnumber of characters to copy from source string (pass PR_UINT32_MAX to copy until end of aData, designated by a null character)
Returns:
NS_OK if function succeeded

This function does not necessarily null-terminate aStr after copying data from aData. The behavior depends on the implementation of the abstract string, aStr. If aStr is a reference to a nsStringContainer, then its data will be null-terminated by this function.

FROZEN

Definition at line 402 of file nsXPCOMGlue.cpp.

{
    if (!xpcomFunctions.cstringSetDataRange)
        return NS_ERROR_NOT_INITIALIZED;
    return xpcomFunctions.cstringSetDataRange(aStr, aCutStart, aCutLength, aBuf, aCount);
}
NS_COM nsresult NS_CStringToUTF16 ( const nsACString &  aSource,
nsCStringEncoding  aSrcEncoding,
nsAString &  aDest 
)

NS_CStringToUTF16.

This function converts the characters in a nsACString to an array of UTF-16 characters, in the platform endianness. The result is stored in a nsAString object.

Parameters:
aSourceabstract string reference containing source string
aSrcEncodingcharacter encoding of the source string
aDestabstract string reference to hold the result

FROZEN

Definition at line 419 of file nsXPCOMGlue.cpp.

NS_COM void NS_Free ( void ptr)

Frees a block of memory.

Null is a permissible value, in which case no action is taken.

FROZEN

Parameters:
ptrThe block of memory to free. This block must originally have been allocated by NS_Alloc or NS_Realloc
Note:
This function is thread-safe.

Definition at line 451 of file nsXPCOMGlue.cpp.

Public Method to access to the component manager.

FROZEN

Parameters:
resultInterface pointer to the service
Returns:
NS_OK for success; other error codes indicate a failure during initialisation.

Definition at line 185 of file nsXPCOMGlue.cpp.

Public Method to access to the component registration manager.

FROZEN

Parameters:
resultInterface pointer to the service
Returns:
NS_OK for success; other error codes indicate a failure during initialisation.

Definition at line 193 of file nsXPCOMGlue.cpp.

Definition at line 241 of file nsXPCOMGlue.cpp.

Public Method to access to the memory manager.

See nsIMemory

FROZEN

Parameters:
resultInterface pointer to the memory manager
Returns:
NS_OK for success; other error codes indicate a failure during initialisation.

Definition at line 201 of file nsXPCOMGlue.cpp.

Public Method to access to the service manager.

FROZEN

Parameters:
resultInterface pointer to the service manager
Returns:
NS_OK for success; other error codes indicate a failure during initialisation.

Definition at line 177 of file nsXPCOMGlue.cpp.

Definition at line 250 of file nsXPCOMGlue.cpp.

NS_COM nsresult NS_InitXPCOM2 ( nsIServiceManager **  result,
nsIFile binDirectory,
nsIDirectoryServiceProvider appFileLocationProvider 
)

Initialises XPCOM.

You must call one of the NS_InitXPCOM methods before proceeding to use xpcom. The one exception is that you may call NS_NewLocalFile to create a nsIFile.

FROZEN

Note:
Use NS_NewLocalFile or NS_NewNativeLocalFile to create the file object you supply as the bin directory path in this call. The function may be safely called before the rest of XPCOM or embedding has been initialised.
Parameters:
resultThe service manager. You may pass null.
binDirectoryThe directory containing the component registry and runtime libraries; or use nsnull to use the working directory.
appFileLocationProviderThe object to be used by Gecko that specifies to Gecko where to find profiles, the component registry preferences and so on; or use nsnull for the default behaviour.
See also:
NS_NewLocalFile
nsILocalFile
nsIDirectoryServiceProvider
Returns:
NS_OK for success; NS_ERROR_NOT_INITIALIZED if static globals were not initialized, which can happen if XPCOM is reloaded, but did not completly shutdown. Other error codes indicate a failure during initialisation.

Definition at line 146 of file nsXPCOMGlue.cpp.

{
    if (!xpcomFunctions.init)
        return NS_ERROR_NOT_INITIALIZED;
    return xpcomFunctions.init(result, binDirectory, appFileLocationProvider);
}
NS_COM nsresult NS_InitXPCOM3 ( nsIServiceManager **  result,
nsIFile binDirectory,
nsIDirectoryServiceProvider appFileLocationProvider,
nsStaticModuleInfo const staticComponents,
PRUint32  componentCount 
)

Initialises XPCOM with static components.

You must call one of the NS_InitXPCOM methods before proceeding to use xpcom. The one exception is that you may call NS_NewLocalFile to create a nsIFile.

FROZEN

Note:
Use NS_NewLocalFile or NS_NewNativeLocalFile to create the file object you supply as the bin directory path in this call. The function may be safely called before the rest of XPCOM or embedding has been initialised.
Parameters:
resultThe service manager. You may pass null.
binDirectoryThe directory containing the component registry and runtime libraries; or use nsnull to use the working directory.
appFileLocationProviderThe object to be used by Gecko that specifies to Gecko where to find profiles, the component registry preferences and so on; or use nsnull for the default behaviour.
staticComponentsAn array of static components. Passing null causes default (builtin) components to be registered, if present.
componentCountNumber of elements in staticComponents
See also:
NS_NewLocalFile
nsILocalFile
nsIDirectoryServiceProvider
XRE_GetStaticComponents
Returns:
NS_OK for success; NS_ERROR_NOT_INITIALIZED if static globals were not initialized, which can happen if XPCOM is reloaded, but did not completly shutdown. Other error codes indicate a failure during initialisation.

Definition at line 156 of file nsXPCOMGlue.cpp.

{
    if (!xpcomFunctions.init3)
        return NS_ERROR_NOT_INITIALIZED;
    return xpcomFunctions.init3(result, binDirectory, appFileLocationProvider,
                                staticComponents, componentCount);
}
NS_COM nsresult NS_NewLocalFile ( const nsAString &  path,
PRBool  followLinks,
nsILocalFile **  result 
)

Public Method to create an instance of a nsILocalFile.

This function may be called prior to NS_InitXPCOM.

FROZEN

Parameters:
pathA string which specifies a full file path to a location. Relative paths will be treated as an error (NS_ERROR_FILE_UNRECOGNIZED_PATH). |NS_NewNativeLocalFile|'s path must be in the filesystem charset.
followLinksThis attribute will determine if the nsLocalFile will auto resolve symbolic links. By default, this value will be false on all non unix systems. On unix, this attribute is effectively a noop.
resultInterface pointer to a new instance of an nsILocalFile
Returns:
NS_OK for success; other error codes indicate a failure.

Definition at line 209 of file nsXPCOMGlue.cpp.

{
    if (!xpcomFunctions.newLocalFile)
        return NS_ERROR_NOT_INITIALIZED;
    return xpcomFunctions.newLocalFile(path, followLinks, result);
}
NS_COM nsresult NS_NewNativeLocalFile ( const nsACString &  path,
PRBool  followLinks,
nsILocalFile **  result 
)

Definition at line 217 of file nsXPCOMGlue.cpp.

NS_COM void* NS_Realloc ( void ptr,
PRSize  size 
)

Reallocates a block of memory to a new size.

FROZEN

Parameters:
ptrThe block of memory to reallocate. This block must originally have been allocated by NS_Alloc or NS_Realloc
sizeThe new size. If 0, frees the block like NS_Free
Returns:
The reallocated block of memory
Note:
This function is thread-safe.

If ptr is null, this function behaves like NS_Alloc. If s is the size of the block to which ptr points, the first min(s, size) bytes of ptr's block are copied to the new block. If the allocation succeeds, ptr is freed and a pointer to the new block is returned. If the allocation fails, ptr is not freed and null is returned. The returned value may be the same as ptr.

Definition at line 443 of file nsXPCOMGlue.cpp.

Shutdown XPCOM.

You must call this method after you are finished using xpcom.

FROZEN

Parameters:
servMgrThe service manager which was returned by NS_InitXPCOM. This will release servMgr. You may pass null.
Returns:
NS_OK for success; other error codes indicate a failure during initialisation.

Definition at line 169 of file nsXPCOMGlue.cpp.

NS_COM PRUnichar* NS_StringCloneData ( const nsAString &  aStr)

NS_StringCloneData.

This function returns a null-terminated copy of the string's internal buffer.

Parameters:
aStrabstract string reference
Returns:
null-terminated copy of the string's internal buffer (it must be free'd using using nsMemory::Free)

FROZEN

Definition at line 305 of file nsXPCOMGlue.cpp.

NS_StringContainerFinish.

Parameters:
aContainerstring container reference

This function frees any memory owned by aContainer.

FROZEN

Definition at line 278 of file nsXPCOMGlue.cpp.

NS_StringContainerInit.

Parameters:
aContainerstring container reference
Returns:
NS_OK if string container successfully initialized

This function may allocate additional memory for aContainer. When aContainer is no longer needed, NS_StringContainerFinish should be called.

FROZEN

Definition at line 259 of file nsXPCOMGlue.cpp.

NS_COM nsresult NS_StringContainerInit2 ( nsStringContainer aContainer,
const PRUnichar aData = nsnull,
PRUint32  aDataLength = PR_UINT32_MAX,
PRUint32  aFlags = 0 
)

NS_StringContainerInit2.

Parameters:
aContainerstring container reference
aDatacharacter buffer (may be null)
aDataLengthnumber of characters stored at aData (may pass PR_UINT32_MAX if aData is null-terminated)
aFlagsflags affecting how the string container is initialized. this parameter is ignored when aData is null. otherwise, if this parameter is 0, then aData is copied into the string.

This function resembles NS_StringContainerInit but provides further options that permit more efficient memory usage. When aContainer is no longer needed, NS_StringContainerFinish should be called.

NOTE: NS_StringContainerInit2(container, nsnull, 0, 0) is equivalent to NS_StringContainerInit(container).

FROZEN

Definition at line 267 of file nsXPCOMGlue.cpp.

NS_COM nsresult NS_StringCopy ( nsAString &  aDestStr,
const nsAString &  aSrcStr 
)

NS_StringCopy.

This function makes aDestStr have the same value as aSrcStr. It is provided as an optimization.

Parameters:
aDestStrabstract string reference to be modified
aSrcStrabstract string reference containing source string
Returns:
NS_OK if function succeeded

This function does not necessarily null-terminate aDestStr after copying data from aSrcStr. The behavior depends on the implementation of the abstract string, aDestStr. If aDestStr is a reference to a nsStringContainer, then its data will be null-terminated by this function.

FROZEN

Definition at line 331 of file nsXPCOMGlue.cpp.

NS_COM PRUint32 NS_StringGetData ( const nsAString &  aStr,
const PRUnichar **  aData,
PRBool aTerminated = nsnull 
)

NS_StringGetData.

This function returns a const character pointer to the string's internal buffer, the length of the string, and a boolean value indicating whether or not the buffer is null-terminated.

Parameters:
aStrabstract string reference
aDataout param that will hold the address of aStr's internal buffer
aTerminatedif non-null, this out param will be set to indicate whether or not aStr's internal buffer is null- terminated
Returns:
length of aStr's internal buffer

FROZEN

Definition at line 285 of file nsXPCOMGlue.cpp.

{
    if (!xpcomFunctions.stringGetData) {
        *aBuf = nsnull;
        return 0;
    }
    return xpcomFunctions.stringGetData(aStr, aBuf, aTerm);
}
NS_COM PRUint32 NS_StringGetMutableData ( nsAString &  aStr,
PRUint32  aDataLength,
PRUnichar **  aData 
)

NS_StringGetMutableData.

This function provides mutable access to a string's internal buffer. It returns a pointer to an array of characters that may be modified. The returned pointer remains valid until the string object is passed to some other string function.

Optionally, this function may be used to resize the string's internal buffer. The aDataLength parameter specifies the requested length of the string's internal buffer. By passing some value other than PR_UINT32_MAX, the caller can request that the buffer be resized to the specified number of characters before returning. The caller is not responsible for writing a null-terminator.

Parameters:
aStrabstract string reference
aDataLengthnumber of characters to resize the string's internal buffer to or PR_UINT32_MAX if no resizing is needed
aDataout param that upon return holds the address of aStr's internal buffer or null if the function failed
Returns:
number of characters or zero if the function failed

This function does not necessarily null-terminate aStr after resizing its internal buffer. The behavior depends on the implementation of the abstract string, aStr. If aStr is a reference to a nsStringContainer, then its data will be null-terminated by this function.

FROZEN

Definition at line 295 of file nsXPCOMGlue.cpp.

{
    if (!xpcomFunctions.stringGetMutableData) {
        *aBuf = nsnull;
        return 0;
    }
    return xpcomFunctions.stringGetMutableData(aStr, aLen, aBuf);
}
NS_COM nsresult NS_StringSetData ( nsAString &  aStr,
const PRUnichar aData,
PRUint32  aDataLength = PR_UINT32_MAX 
)

NS_StringSetData.

This function copies aData into aStr.

Parameters:
aStrabstract string reference
aDatacharacter buffer
aDataLengthnumber of characters to copy from source string (pass PR_UINT32_MAX to copy until end of aData, designated by a null character)
Returns:
NS_OK if function succeeded

This function does not necessarily null-terminate aStr after copying data from aData. The behavior depends on the implementation of the abstract string, aStr. If aStr is a reference to a nsStringContainer, then its data will be null-terminated by this function.

FROZEN

Definition at line 313 of file nsXPCOMGlue.cpp.

NS_COM nsresult NS_StringSetDataRange ( nsAString &  aStr,
PRUint32  aCutOffset,
PRUint32  aCutLength,
const PRUnichar aData,
PRUint32  aDataLength = PR_UINT32_MAX 
)

NS_StringSetDataRange.

This function copies aData into a section of aStr. As a result it can be used to insert new characters into the string.

Parameters:
aStrabstract string reference
aCutOffsetstarting index where the string's existing data is to be overwritten (pass PR_UINT32_MAX to cause aData to be appended to the end of aStr, in which case the value of aCutLength is ignored).
aCutLengthnumber of characters to overwrite starting at aCutOffset (pass PR_UINT32_MAX to overwrite until the end of aStr).
aDatacharacter buffer (pass null to cause this function to simply remove the "cut" range)
aDataLengthnumber of characters to copy from source string (pass PR_UINT32_MAX to copy until end of aData, designated by a null character)
Returns:
NS_OK if function succeeded

This function does not necessarily null-terminate aStr after copying data from aData. The behavior depends on the implementation of the abstract string, aStr. If aStr is a reference to a nsStringContainer, then its data will be null-terminated by this function.

FROZEN

Definition at line 322 of file nsXPCOMGlue.cpp.

{
    if (!xpcomFunctions.stringSetDataRange)
        return NS_ERROR_NOT_INITIALIZED;
    return xpcomFunctions.stringSetDataRange(aStr, aCutStart, aCutLength, aBuf, aCount);
}

Definition at line 233 of file nsXPCOMGlue.cpp.

NS_COM nsresult NS_UTF16ToCString ( const nsAString &  aSource,
nsCStringEncoding  aDestEncoding,
nsACString &  aDest 
)

NS_UTF16ToCString.

This function converts the UTF-16 characters in a nsAString to a single-byte encoding. The result is stored in a nsACString object. In some cases this conversion may be lossy. In such cases, the conversion may succeed with a return code indicating loss of information. The exact behavior is not specified at this time.

Parameters:
aSourceabstract string reference containing source string
aDestEncodingcharacter encoding of the resulting string
aDestabstract string reference to hold the result

FROZEN

Definition at line 427 of file nsXPCOMGlue.cpp.

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 135 of file nsXPCOMGlue.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult XPCOMGlueStartup ( const char *  xpcomFile)

Definition at line 65 of file nsXPCOMGlue.cpp.

{
    xpcomFunctions.version = XPCOM_GLUE_VERSION;
    xpcomFunctions.size    = sizeof(XPCOMFunctions);

    GetFrozenFunctionsFunc func = nsnull;

    if (!xpcomFile)
        xpcomFile = XPCOM_DLL;

    func = XPCOMGlueLoad(xpcomFile);

    if (!func)
        return NS_ERROR_FAILURE;

    nsresult rv = (*func)(&xpcomFunctions, nsnull);
    if (NS_FAILED(rv)) {
        XPCOMGlueUnload();
        return rv;
    }

    rv = GlueStartupDebug();
    if (NS_FAILED(rv)) {
        memset(&xpcomFunctions, 0, sizeof(xpcomFunctions));
        XPCOMGlueUnload();
        return rv;
    }

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 62 of file nsXPCOMGlue.cpp.