icinga2/lib/cli/consolecommand.hpp

63 lines
1.8 KiB
C++
Raw Permalink Normal View History

Replace all existing copyright headers with `SPDX` headers I've used the following command to replace the original copyright header lines in a C-style comment block: ``` $ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f -exec perl -pi -e 's{/\*[^*]*\(\s*c\s*\)\s*(\d{4})\s*Icinga\s+GmbH[^*]*\*/}{// SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n// SPDX-License-Identifier: GPL-2.0-or-later}gi' {} + ``` For files that use shell-style comments (#) like CMakeLists.txt, I've used this command: ``` $ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f -exec perl -pi -e 's{#.*\(\s*c\s*\)\s(\d{4})\sIcinga\s+GmbH.*}{# SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n# SPDX-License-Identifier: GPL-2.0-or-later}gi' {} + ``` And for SQL files: ``` $ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f \( -name '*.sql' \) -exec perl -pi -e 's{--.*\(c\)\s(\d{4})\sIcinga\sGmbH.*}{-- SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n-- SPDX-License-Identifier: GPL-2.0-or-later}gi' {} + $ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f \( -name '*.sql' \) -exec perl -pi -e 's{-- Copyright \(c\)\s(\d{4})\sIcinga\s+Development\sTeam.*}{-- SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n-- SPDX-License-Identifier: GPL-2.0-or-later}gi' {} + ```
2026-01-27 09:06:40 -05:00
// SPDX-FileCopyrightText: 2012 Icinga GmbH <https://icinga.com>
// SPDX-License-Identifier: GPL-2.0-or-later
2014-11-23 06:35:13 -05:00
#ifndef CONSOLECOMMAND_H
#define CONSOLECOMMAND_H
2014-11-23 06:35:13 -05:00
#include "cli/clicommand.hpp"
#include "base/exception.hpp"
#include "base/scriptframe.hpp"
#include "base/tlsstream.hpp"
#include "remote/url.hpp"
2021-02-02 04:16:04 -05:00
#include <condition_variable>
2014-11-23 06:35:13 -05:00
namespace icinga
{
/**
* The "console" CLI command.
2014-11-23 06:35:13 -05:00
*
* @ingroup cli
*/
2018-01-04 00:11:04 -05:00
class ConsoleCommand final : public CLICommand
2014-11-23 06:35:13 -05:00
{
public:
DECLARE_PTR_TYPEDEFS(ConsoleCommand);
2014-11-23 06:35:13 -05:00
static void StaticInitialize();
String GetDescription() const override;
String GetShortDescription() const override;
ImpersonationLevel GetImpersonationLevel() const override;
void InitParameters(boost::program_options::options_description& visibleDesc,
boost::program_options::options_description& hiddenDesc) const override;
int Run(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap) const override;
static int RunScriptConsole(ScriptFrame& scriptFrame, const String& connectAddr = String(),
const String& session = String(), const String& commandOnce = String(), const String& commandOnceFileName = String(),
bool syntaxOnly = false);
private:
2021-02-02 04:16:04 -05:00
mutable std::mutex m_Mutex;
mutable std::condition_variable m_CV;
static Shared<AsioTlsStream>::Ptr Connect();
static Value ExecuteScript(const String& session, const String& command, bool sandboxed);
static Array::Ptr AutoCompleteScript(const String& session, const String& command, bool sandboxed);
static Dictionary::Ptr SendRequest();
#ifdef HAVE_EDITLINE
static char *ConsoleCompleteHelper(const char *word, int state);
#endif /* HAVE_EDITLINE */
static void BreakpointHandler(ScriptFrame& frame, ScriptError *ex, const DebugInfo& di);
2014-11-23 06:35:13 -05:00
};
}
#endif /* CONSOLECOMMAND_H */