regExport.cpp revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
/* -*- Mode: C++; tab-width: 4; 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):
*
* 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 <stdio.h>
#include "nsIServiceManager.h"
#include "nsIComponentManager.h"
#include "nsCOMPtr.h"
#include "nsIRegistry.h"
#include "nsIEnumerator.h"
#include "nsILocalFile.h"
#include "nsDependentString.h"
#include "prmem.h"
#include "plstr.h"
#include "nsMemory.h"
#ifdef __MWERKS__
// Hack in some arguments. A NULL registry name is supposed to tell libreg
// to use the default registry (which does seem to work).
argc = 1;
const char* myArgs[] =
{
"regExport"
};
#endif
// Initialize XPCOM
{
// Cannot initialize XPCOM
exit(-1);
}
{
// Get the component manager
{
// Cant get component manager
exit(-1);
}
if (argc>1) {
// Create the registry
(void **) ®);
// Check result.
{
return rv;
}
// Open it against the input file name.
return rv;
}
{
// Recurse over all 3 branches.
}
}
else
{
// Called with no arguments. Print both the default registry and
// the components registry. We already printed the default regsitry.
// So just do the component registry.
(void **) ®);
// Check result.
{
return rv;
}
if ( rv == NS_ERROR_REG_BADTYPE ) {
printf( "\n\n\nThere is no <Application Component Registry>\n" );
}
// Recurse over all 3 branches.
}
}
}
return rv;
}
// Print out key name.
// Make sure it isn't a "root" key.
&&
&&
// Print values stored under this key.
}
// Enumerate all subkeys (immediately) under the given node.
// Check result.
// Set enumerator to beginning.
// Enumerate subkeys till done.
// Test result.
// Get specific interface.
// Test that result.
// Get node name.
char *name;
// Test result.
// Build complete name.
// Display contents under this subkey.
printf( "\n" );
} else {
}
delete [] fullName;
} else {
}
// Release node.
} else {
}
// Release item.
// Advance to next key.
// Check result.
if ( NS_SUCCEEDED( rv ) ) {
} else {
}
} else {
}
}
// Release key enumerator.
} else {
printf( "Error creating enumerator for %s, root=0x%08X, rv=0x%08X\n",
}
return;
}
// Emumerate values at this registry location.
// Check result.
// Go to beginning.
// Enumerate values till done.
// Test result.
// Get specific interface.
// Test that result.
// Get node name.
char *name;
// Test result.
// Print name:
// Get info about this value.
// Print value contents.
switch ( type ) {
case nsIRegistry::String: {
char *strValue;
} else {
}
}
break;
case nsIRegistry::Int32:
{
if (NS_SUCCEEDED(rv)) {
}
else {
}
}
break;
case nsIRegistry::Bytes:
printf( "\t= Bytes" );
break;
case nsIRegistry::File:
printf( "\t= File (?)" );
break;
default:
break;
}
} else {
}
printf("\n");
} else {
}
// Release node.
} else {
}
// Release item.
// Advance to next key.
// Check result.
if ( NS_SUCCEEDED( rv ) ) {
} else {
break;
}
} else {
break;
}
}
} else {
}
return;
}
// For now, just dump contents.
return;
}