/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim:set ts=4 sw=4 et cindent: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsXPCOMGlue.h"
#include "nspr.h"
#include "nsMemory.h"
#include "nsGREDirServiceProvider.h"
#include "nsXPCOMPrivate.h"
#include <stdlib.h>
#ifdef VBOX
# include <limits.h>
#endif
#if XP_WIN32
#include <windows.h>
#endif
void GRE_AddGREToEnvironment();
// functions provided by nsMemory.cpp and nsDebug.cpp
void GlueShutdownMemory();
void GlueShutdownDebug();
extern "C"
{
return NS_OK;
#else
//
// if xpcomFile == ".", then we assume xpcom is already loaded, and we'll
// use NSPR to find NS_GetFrozenFunctions from the list of already loaded
// libraries.
//
// otherwise, we try to load xpcom and then look for NS_GetFrozenFunctions.
// if xpcomFile == NULL, then we try to load xpcom by name w/o a fully
// qualified path.
//
if (!function) {
// The symbol was not found, so failover to loading XPCOM_DLL,
// and look for the symbol there. See bug 240986 for details.
}
else {
if (!libPath)
else {
}
}
}
if (!function) {
if (!xpcomFile)
else
#ifdef RT_OS_DARWIN /* vbox */
/* works around bundle problem. */
if (!xpcomLib) {
if (home) {
}
}
#endif
if (!xpcomLib)
return NS_ERROR_FAILURE;
if (!function)
else
}
goto bail;
rv = GlueStartupDebug();
goto bail;
// startup the nsMemory
rv = GlueStartupMemory();
goto bail;
}
return NS_OK;
bail:
return NS_ERROR_FAILURE;
#endif
}
extern "C"
{
return NS_OK;
#else
if (xpcomLib) {
}
return NS_OK;
#endif
}
#ifndef XPCOM_GLUE_NO_DYNAMIC_LOADING
{
if (!xpcomFunctions.init)
return NS_ERROR_NOT_INITIALIZED;
}
{
if (!xpcomFunctions.shutdown)
return NS_ERROR_NOT_INITIALIZED;
}
{
return NS_ERROR_NOT_INITIALIZED;
}
{
return NS_ERROR_NOT_INITIALIZED;
}
{
return NS_ERROR_NOT_INITIALIZED;
}
{
return NS_ERROR_NOT_INITIALIZED;
}
{
if (!xpcomFunctions.newLocalFile)
return NS_ERROR_NOT_INITIALIZED;
}
{
return NS_ERROR_NOT_INITIALIZED;
}
{
return NS_ERROR_NOT_INITIALIZED;
}
{
return NS_ERROR_NOT_INITIALIZED;
}
{
if (!xpcomFunctions.getDebug)
return NS_ERROR_NOT_INITIALIZED;
}
{
if (!xpcomFunctions.getTraceRefcnt)
return NS_ERROR_NOT_INITIALIZED;
}
{
return NS_ERROR_NOT_INITIALIZED;
}
extern "C" NS_COM void
{
}
{
if (!xpcomFunctions.stringGetData) {
return 0;
}
}
{
return nsnull;
}
{
if (!xpcomFunctions.stringSetData)
return NS_ERROR_NOT_INITIALIZED;
}
{
return NS_ERROR_NOT_INITIALIZED;
}
{
if (!xpcomFunctions.stringCopy)
return NS_ERROR_NOT_INITIALIZED;
}
{
return NS_ERROR_NOT_INITIALIZED;
}
extern "C" NS_COM void
{
}
{
if (!xpcomFunctions.cstringGetData) {
return 0;
}
}
extern "C" NS_COM char *
{
return nsnull;
}
{
if (!xpcomFunctions.cstringSetData)
return NS_ERROR_NOT_INITIALIZED;
}
{
return NS_ERROR_NOT_INITIALIZED;
}
{
if (!xpcomFunctions.cstringCopy)
return NS_ERROR_NOT_INITIALIZED;
}
{
if (!xpcomFunctions.cstringToUTF16)
return NS_ERROR_NOT_INITIALIZED;
}
{
if (!xpcomFunctions.utf16ToCString)
return NS_ERROR_NOT_INITIALIZED;
}
#endif // #ifndef XPCOM_GLUE_NO_DYNAMIC_LOADING
static char* spEnvString = 0;
void
{
if (!grePath)
return;
if (!path)
path = "";
#ifdef VBOX
else
{
/* sEnvString is part of the environment because of putenv().
* path is only temporarily used and not argument of putenv() itself */
}
#endif
/**
* if the PATH string is longer than our static buffer, allocate a
* buffer for the environment string. This buffer will be leaked at shutdown!
*/
path)) {
}
} else {
if (sprintf(sEnvString,
path) > 0) {
}
}
#if XP_WIN32
// On windows, the current directory is searched before the
// PATH environment variable. This is a very bad thing
// since libraries in the cwd will be picked up before
// any that are in either the application or GRE directory.
if (grePath) {
}
#endif
}
extern "C"
{
// Startup the XPCOM Glue that links us up with XPCOM.
NS_WARNING("gre: XPCOMGlueStartup failed");
return rv;
}
if ( !provider ) {
NS_WARNING("GRE_Startup failed");
return NS_ERROR_OUT_OF_MEMORY;
}
NS_WARNING("gre: NS_InitXPCOM failed");
return rv;
}
return NS_OK;
}
extern "C"
{
return NS_OK;
}