regxpcom.cpp revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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):
* Pierre Phaneuf <pp@ludusdesign.com>
* Mike Shaver <shaver@mozilla.org>
*
* 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 "stdlib.h"
#include "prenv.h"
#include "nspr.h"
#include "nsXPCOMPrivate.h" // for XPCOM_DLL defines.
#include "nsXPCOMGlue.h"
#include "nsIComponentManager.h"
#include "nsIComponentRegistrar.h"
#include "nsIServiceManager.h"
#include "nsCOMPtr.h"
#include "nsILocalFile.h"
#include "nsEmbedString.h"
#include "nsIDirectoryService.h"
#include "nsDirectoryServiceDefs.h"
static const char* gXPCOMLocation = nsnull;
static const char* gCompRegLocation = nsnull;
static const char* gXPTIDatLocation = nsnull;
static char* gPathEnvString = nsnull;
class DirectoryServiceProvider : public nsIDirectoryServiceProvider
{
public:
private:
~DirectoryServiceProvider() {}
};
{
*persistant = PR_TRUE;
const char* fileLocation = nsnull;
{
}
{
}
{
}
else
return NS_ERROR_FAILURE;
}
int startup_xpcom()
{
if (gXPCOMLocation) {
if (!path) {
path = "";
}
if (gPathEnvString)
path);
if (gXPCOMLocation)
}
else
{
}
{
printf("Can not initialize XPCOM Glue\n");
return -1;
}
if ( !provider )
{
NS_WARNING("GRE_Startup failed");
return -1;
}
if (gXPCOMLocation)
{
}
printf("Can not initialize XPCOM\n");
return -1;
}
return 0;
}
void shutdown_xpcom()
{
printf("Can not shutdown XPCOM cleanly\n");
}
rv = XPCOMGlueShutdown();
printf("Can not shutdown XPCOM Glue cleanly\n");
}
if (gPathEnvString)
}
{
if (path) {
}
printf("Can not aquire component registrar\n");
return rv;
}
if (gUnreg)
else
spec = 0;
registrar = 0;
return rv;
}
void ReportSuccess(const char *file)
{
if (gQuiet)
return;
if (gUnreg)
else
}
{
if (gUnreg)
printf("Unregistration failed: (");
else
printf("Registration failed: (");
switch (err)
{
printf("Factory not loaded");
break;
case NS_NOINTERFACE:
printf("No Interface");
break;
case NS_ERROR_NULL_POINTER:
printf("Null pointer");
break;
case NS_ERROR_OUT_OF_MEMORY:
printf("Out of memory");
break;
default:
}
}
void printHelp()
{
"Mozilla regxpcom - a registration tool for xpcom components \n"
" \n"
"Usage: regxpcom [options] [file-or-directory] \n"
" \n"
"Options: \n"
" -x path Specifies the location of a directory containing the \n"
" xpcom library which will be used when registering new \n"
" component libraries. This path will also be added to \n"
" the \"load library\" path. If not specified, the \n"
" current working directory will be used. \n"
" -c path Specifies the location of the compreg.dat file. If \n"
" not specifed, the compreg.dat file will be in its \n"
" default location. \n"
" -d path Specifies the location of the xpti.dat file. If not \n"
" specifed, the xpti.dat file will be in its default \n"
" location. \n"
" -a Option to register all files in the default component \n"
" directories. This is the default behavior if regxpcom \n"
" is called without any arguments. \n"
" -h Displays this help screen. Must be the only option \n"
" specified. \n"
" -u Option to uninstall the files-or-directory instead of \n"
" registering them. \n"
" -q Quiets some of the output of regxpcom. \n\n");
}
{
int i = 1, result = 0;
while (i < argc)
{
if (argv[i][0] == '-')
{
int j;
{
switch (argv[i][j])
{
case 'h':
printHelp();
return 0; // we are all done!
case 'u':
break;
case 'q':
break;
case 'a':
{
{
result = -1;
}
else
{
ReportSuccess("component directory");
}
}
break;
case 'x':
gXPCOMLocation = argv[++i];
break;
case 'c':
gCompRegLocation = argv[++i];
break;
case 'd':
gXPTIDatLocation = argv[++i];
break;
default:
}
}
}
else
{
{
result = -1;
}
else
{
ReportSuccess(argv[i]);
}
}
i++;
}
return result;
}
{
int ret;
/* With no arguments, regxpcom will autoregister */
if (argc <= 1)
{
printf("Can not aquire component registrar\n");
return -1;
}
registrar = 0;
} else
return ret;
}