Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include "registry/registry.h"
22 : #include "fileurl.hxx"
23 :
24 : #include "rtl/ustring.hxx"
25 :
26 : #include <stdio.h>
27 : #include <string.h>
28 :
29 : using rtl::OUString;
30 : using namespace registry::tools;
31 :
32 : #if (defined UNX)
33 0 : int main( int argc, char * argv[] )
34 : #else
35 : int __cdecl main( int argc, char * argv[] )
36 : #endif
37 : {
38 : RegHandle hReg;
39 : RegKeyHandle hRootKey, hKey;
40 :
41 0 : if (argc < 2 || argc > 3)
42 : {
43 0 : fprintf(stderr, "using: regview registryfile [keyName]\n");
44 0 : exit(1);
45 : }
46 :
47 0 : OUString regName( convertToFileUrl(argv[1], strlen(argv[1])) );
48 0 : if (reg_openRegistry(regName.pData, &hReg, REG_READONLY))
49 : {
50 0 : fprintf(stderr, "open registry \"%s\" failed\n", argv[1]);
51 0 : exit(1);
52 : }
53 :
54 0 : if (!reg_openRootKey(hReg, &hRootKey))
55 : {
56 0 : if (argc == 3)
57 : {
58 0 : OUString keyName( OUString::createFromAscii(argv[2]) );
59 0 : if (!reg_openKey(hRootKey, keyName.pData, &hKey))
60 : {
61 0 : if (reg_dumpRegistry(hKey))
62 : {
63 0 : fprintf(stderr, "dumping registry \"%s\" failed\n", argv[1]);
64 : }
65 :
66 0 : if (reg_closeKey(hKey))
67 : {
68 : fprintf(stderr, "closing key \"%s\" of registry \"%s\" failed\n",
69 0 : argv[2], argv[1]);
70 : }
71 : }
72 : else
73 : {
74 : fprintf(stderr, "key \"%s\" not exists in registry \"%s\"\n",
75 0 : argv[2], argv[1]);
76 0 : }
77 : }
78 : else
79 : {
80 0 : if (reg_dumpRegistry(hRootKey))
81 : {
82 0 : fprintf(stderr, "dumping registry \"%s\" failed\n", argv[1]);
83 : }
84 : }
85 :
86 0 : if (reg_closeKey(hRootKey))
87 : {
88 0 : fprintf(stderr, "closing root key of registry \"%s\" failed\n", argv[1]);
89 : }
90 : }
91 : else
92 : {
93 0 : fprintf(stderr, "open root key of registry \"%s\" failed\n", argv[1]);
94 : }
95 :
96 0 : if (reg_closeRegistry(hReg))
97 : {
98 0 : fprintf(stderr, "closing registry \"%s\" failed\n", argv[1]);
99 0 : exit(1);
100 : }
101 :
102 0 : return(0);
103 : }
104 :
105 :
106 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|