1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_registry.hxx" 30 31 #include "registry/registry.h" 32 #include "fileurl.hxx" 33 34 #include "rtl/ustring.hxx" 35 36 #include <stdio.h> 37 #include <string.h> 38 39 using rtl::OUString; 40 using namespace registry::tools; 41 42 #if (defined UNX) || (defined OS2) 43 int main( int argc, char * argv[] ) 44 #else 45 int _cdecl main( int argc, char * argv[] ) 46 #endif 47 { 48 RegHandle hReg; 49 RegKeyHandle hRootKey, hKey; 50 51 if (argc < 2 || argc > 3) 52 { 53 fprintf(stderr, "using: regview registryfile [keyName]\n"); 54 exit(1); 55 } 56 57 OUString regName( convertToFileUrl(argv[1], strlen(argv[1])) ); 58 if (reg_openRegistry(regName.pData, &hReg, REG_READONLY)) 59 { 60 fprintf(stderr, "open registry \"%s\" failed\n", argv[1]); 61 exit(1); 62 } 63 64 if (!reg_openRootKey(hReg, &hRootKey)) 65 { 66 if (argc == 3) 67 { 68 OUString keyName( OUString::createFromAscii(argv[2]) ); 69 if (!reg_openKey(hRootKey, keyName.pData, &hKey)) 70 { 71 if (reg_dumpRegistry(hKey)) 72 { 73 fprintf(stderr, "dumping registry \"%s\" failed\n", argv[1]); 74 } 75 76 if (reg_closeKey(hKey)) 77 { 78 fprintf(stderr, "closing key \"%s\" of registry \"%s\" failed\n", 79 argv[2], argv[1]); 80 } 81 } 82 else 83 { 84 fprintf(stderr, "key \"%s\" not exists in registry \"%s\"\n", 85 argv[2], argv[1]); 86 } 87 } 88 else 89 { 90 if (reg_dumpRegistry(hRootKey)) 91 { 92 fprintf(stderr, "dumping registry \"%s\" failed\n", argv[1]); 93 } 94 } 95 96 if (reg_closeKey(hRootKey)) 97 { 98 fprintf(stderr, "closing root key of registry \"%s\" failed\n", argv[1]); 99 } 100 } 101 else 102 { 103 fprintf(stderr, "open root key of registry \"%s\" failed\n", argv[1]); 104 } 105 106 if (reg_closeRegistry(hReg)) 107 { 108 fprintf(stderr, "closing registry \"%s\" failed\n", argv[1]); 109 exit(1); 110 } 111 112 return(0); 113 } 114 115 116