From 940b4d1848e8c70ab7642901a68594e8016caffc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 18:51:28 +0200 Subject: Adding upstream version 1:7.0.4. Signed-off-by: Daniel Baumann --- registry/tools/fileurl.cxx | 79 +++++++++++++++++++ registry/tools/fileurl.hxx | 37 +++++++++ registry/tools/options.cxx | 144 ++++++++++++++++++++++++++++++++++ registry/tools/options.hxx | 60 +++++++++++++++ registry/tools/regmerge.cxx | 183 ++++++++++++++++++++++++++++++++++++++++++++ registry/tools/regview.cxx | 113 +++++++++++++++++++++++++++ 6 files changed, 616 insertions(+) create mode 100644 registry/tools/fileurl.cxx create mode 100644 registry/tools/fileurl.hxx create mode 100644 registry/tools/options.cxx create mode 100644 registry/tools/options.hxx create mode 100644 registry/tools/regmerge.cxx create mode 100644 registry/tools/regview.cxx (limited to 'registry/tools') diff --git a/registry/tools/fileurl.cxx b/registry/tools/fileurl.cxx new file mode 100644 index 000000000..dec3be5e5 --- /dev/null +++ b/registry/tools/fileurl.cxx @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "fileurl.hxx" + +#include +#include +#include +#include + +#include + +#ifdef SAL_UNX +#define SEPARATOR '/' +#else +#define SEPARATOR '\\' +#endif + +using osl::FileBase; + +namespace registry::tools +{ + +OUString convertToFileUrl(char const * filename, sal_Int32 length) +{ + OUString const uFileName(filename, length, osl_getThreadTextEncoding()); + if (strncmp(filename, "file://", 7) == 0) + { + // already a FileUrl. + return uFileName; + } + + OUString uFileUrl; + if (length > 0) + { + if (filename[0] != SEPARATOR) + { + // relative path name. + OUString uWorkingDir; + if (osl_getProcessWorkingDir(&uWorkingDir.pData) != osl_Process_E_None) + { + assert(false); + } + if (FileBase::getAbsoluteFileURL(uWorkingDir, uFileName, uFileUrl) != FileBase::E_None) + { + assert(false); + } + } + else + { + // absolute path name. + if (FileBase::getFileURLFromSystemPath(uFileName, uFileUrl) != FileBase::E_None) + { + assert(false); + } + } + } + return uFileUrl; +} + +} // namespace registry::tools + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/registry/tools/fileurl.hxx b/registry/tools/fileurl.hxx new file mode 100644 index 000000000..684ca8c3c --- /dev/null +++ b/registry/tools/fileurl.hxx @@ -0,0 +1,37 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_REGISTRY_TOOLS_FILEURL_HXX +#define INCLUDED_REGISTRY_TOOLS_FILEURL_HXX + +#include + +namespace registry +{ +namespace tools +{ + +OUString convertToFileUrl(char const * filename, sal_Int32 length); + +} // namespace tools +} // namespace registry + +#endif /* INCLUDED_REGISTRY_TOOLS_FILEURL_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/registry/tools/options.cxx b/registry/tools/options.cxx new file mode 100644 index 000000000..81d1131f7 --- /dev/null +++ b/registry/tools/options.cxx @@ -0,0 +1,144 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "options.hxx" + +#include + +#include + +namespace registry::tools +{ + +Options::Options (char const * program) + : m_program (program) +{} + +Options::~Options() +{} + +// static +bool Options::checkArgument(std::vector< std::string> & rArgs, char const * arg, size_t len) +{ + bool result = ((arg != nullptr) && (len > 0)); + OSL_PRECOND(result, "registry::tools::Options::checkArgument(): invalid arguments"); + if (result) + { + switch (arg[0]) + { + case '@': + result = len > 1; + if (result) + { + // "@" + result = Options::checkCommandFile(rArgs, &(arg[1])); + } + break; + case '-': + result = len > 1; + if (result) + { + // "-