Prevent to get 0 font size in the auto-fitting algorithm
[LibreOffice.git] / registry / tools / regview.cxx
blob56aa343f4254ddbc24b5955dccc41988c48497d7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <regapi.hxx>
22 #include "fileurl.hxx"
24 #include <rtl/ustring.hxx>
26 #include <stdio.h>
27 #include <string.h>
29 using namespace registry::tools;
31 #if (defined UNX)
32 int main( int argc, char * argv[] )
33 #else
34 int __cdecl main( int argc, char * argv[] )
35 #endif
37 try
39 RegHandle hReg;
40 RegKeyHandle hRootKey, hKey;
42 if (argc < 2 || argc > 3)
44 fprintf(stderr, "using: regview registryfile [keyName]\n");
45 exit(1);
48 OUString regName( convertToFileUrl(argv[1], strlen(argv[1])) );
49 if (reg_openRegistry(regName.pData, &hReg) != RegError::NO_ERROR)
51 fprintf(stderr, "open registry \"%s\" failed\n", argv[1]);
52 exit(1);
55 if (reg_openRootKey(hReg, &hRootKey) == RegError::NO_ERROR)
57 if (argc == 3)
59 OUString keyName( OUString::createFromAscii(argv[2]) );
60 if (reg_openKey(hRootKey, keyName.pData, &hKey) == RegError::NO_ERROR)
62 if (reg_dumpRegistry(hKey) != RegError::NO_ERROR)
64 fprintf(stderr, "dumping registry \"%s\" failed\n", argv[1]);
67 if (reg_closeKey(hKey) != RegError::NO_ERROR)
69 fprintf(stderr, "closing key \"%s\" of registry \"%s\" failed\n",
70 argv[2], argv[1]);
73 else
75 fprintf(stderr, "key \"%s\" not exists in registry \"%s\"\n",
76 argv[2], argv[1]);
79 else
81 if (reg_dumpRegistry(hRootKey) != RegError::NO_ERROR)
83 fprintf(stderr, "dumping registry \"%s\" failed\n", argv[1]);
87 if (reg_closeKey(hRootKey) != RegError::NO_ERROR)
89 fprintf(stderr, "closing root key of registry \"%s\" failed\n", argv[1]);
92 else
94 fprintf(stderr, "open root key of registry \"%s\" failed\n", argv[1]);
97 if (reg_closeRegistry(hReg) != RegError::NO_ERROR)
99 fprintf(stderr, "closing registry \"%s\" failed\n", argv[1]);
100 exit(1);
103 return 0;
105 catch (std::exception& e)
107 fprintf(stderr, "failure: \"%s\"\n", e.what());
108 return 1;
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */