1*51134e9eSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*51134e9eSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*51134e9eSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*51134e9eSAndrew Rist * distributed with this work for additional information
6*51134e9eSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*51134e9eSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*51134e9eSAndrew Rist * "License"); you may not use this file except in compliance
9*51134e9eSAndrew Rist * with the License. You may obtain a copy of the License at
10*51134e9eSAndrew Rist *
11*51134e9eSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*51134e9eSAndrew Rist *
13*51134e9eSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*51134e9eSAndrew Rist * software distributed under the License is distributed on an
15*51134e9eSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*51134e9eSAndrew Rist * KIND, either express or implied. See the License for the
17*51134e9eSAndrew Rist * specific language governing permissions and limitations
18*51134e9eSAndrew Rist * under the License.
19*51134e9eSAndrew Rist *
20*51134e9eSAndrew Rist *************************************************************/
21*51134e9eSAndrew Rist
22*51134e9eSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_registry.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "registry/registry.h"
28cdf0e10cSrcweir #include "fileurl.hxx"
29cdf0e10cSrcweir
30cdf0e10cSrcweir #include "rtl/ustring.hxx"
31cdf0e10cSrcweir
32cdf0e10cSrcweir #include <stdio.h>
33cdf0e10cSrcweir #include <string.h>
34cdf0e10cSrcweir
35cdf0e10cSrcweir using rtl::OUString;
36cdf0e10cSrcweir using namespace registry::tools;
37cdf0e10cSrcweir
38cdf0e10cSrcweir #if (defined UNX) || (defined OS2)
main(int argc,char * argv[])39cdf0e10cSrcweir int main( int argc, char * argv[] )
40cdf0e10cSrcweir #else
41cdf0e10cSrcweir int _cdecl main( int argc, char * argv[] )
42cdf0e10cSrcweir #endif
43cdf0e10cSrcweir {
44cdf0e10cSrcweir RegHandle hReg;
45cdf0e10cSrcweir RegKeyHandle hRootKey, hKey;
46cdf0e10cSrcweir
47cdf0e10cSrcweir if (argc < 2 || argc > 3)
48cdf0e10cSrcweir {
49cdf0e10cSrcweir fprintf(stderr, "using: regview registryfile [keyName]\n");
50cdf0e10cSrcweir exit(1);
51cdf0e10cSrcweir }
52cdf0e10cSrcweir
53cdf0e10cSrcweir OUString regName( convertToFileUrl(argv[1], strlen(argv[1])) );
54cdf0e10cSrcweir if (reg_openRegistry(regName.pData, &hReg, REG_READONLY))
55cdf0e10cSrcweir {
56cdf0e10cSrcweir fprintf(stderr, "open registry \"%s\" failed\n", argv[1]);
57cdf0e10cSrcweir exit(1);
58cdf0e10cSrcweir }
59cdf0e10cSrcweir
60cdf0e10cSrcweir if (!reg_openRootKey(hReg, &hRootKey))
61cdf0e10cSrcweir {
62cdf0e10cSrcweir if (argc == 3)
63cdf0e10cSrcweir {
64cdf0e10cSrcweir OUString keyName( OUString::createFromAscii(argv[2]) );
65cdf0e10cSrcweir if (!reg_openKey(hRootKey, keyName.pData, &hKey))
66cdf0e10cSrcweir {
67cdf0e10cSrcweir if (reg_dumpRegistry(hKey))
68cdf0e10cSrcweir {
69cdf0e10cSrcweir fprintf(stderr, "dumping registry \"%s\" failed\n", argv[1]);
70cdf0e10cSrcweir }
71cdf0e10cSrcweir
72cdf0e10cSrcweir if (reg_closeKey(hKey))
73cdf0e10cSrcweir {
74cdf0e10cSrcweir fprintf(stderr, "closing key \"%s\" of registry \"%s\" failed\n",
75cdf0e10cSrcweir argv[2], argv[1]);
76cdf0e10cSrcweir }
77cdf0e10cSrcweir }
78cdf0e10cSrcweir else
79cdf0e10cSrcweir {
80cdf0e10cSrcweir fprintf(stderr, "key \"%s\" not exists in registry \"%s\"\n",
81cdf0e10cSrcweir argv[2], argv[1]);
82cdf0e10cSrcweir }
83cdf0e10cSrcweir }
84cdf0e10cSrcweir else
85cdf0e10cSrcweir {
86cdf0e10cSrcweir if (reg_dumpRegistry(hRootKey))
87cdf0e10cSrcweir {
88cdf0e10cSrcweir fprintf(stderr, "dumping registry \"%s\" failed\n", argv[1]);
89cdf0e10cSrcweir }
90cdf0e10cSrcweir }
91cdf0e10cSrcweir
92cdf0e10cSrcweir if (reg_closeKey(hRootKey))
93cdf0e10cSrcweir {
94cdf0e10cSrcweir fprintf(stderr, "closing root key of registry \"%s\" failed\n", argv[1]);
95cdf0e10cSrcweir }
96cdf0e10cSrcweir }
97cdf0e10cSrcweir else
98cdf0e10cSrcweir {
99cdf0e10cSrcweir fprintf(stderr, "open root key of registry \"%s\" failed\n", argv[1]);
100cdf0e10cSrcweir }
101cdf0e10cSrcweir
102cdf0e10cSrcweir if (reg_closeRegistry(hReg))
103cdf0e10cSrcweir {
104cdf0e10cSrcweir fprintf(stderr, "closing registry \"%s\" failed\n", argv[1]);
105cdf0e10cSrcweir exit(1);
106cdf0e10cSrcweir }
107cdf0e10cSrcweir
108cdf0e10cSrcweir return(0);
109cdf0e10cSrcweir }
110cdf0e10cSrcweir
111cdf0e10cSrcweir
112