OpenCPN Partial API docs
Loading...
Searching...
No Matches
plugin_blacklist.h
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2022 by Alec Leamas *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
16 **************************************************************************/
17
24#ifndef PLUGIN_BLACKLIST_H
25#define PLUGIN_BLACKLIST_H
26
27#include <string>
28#include <sstream>
29#include <memory>
30
31// Handle gnu's major/minor macros
32#ifdef major
33#define gnu_major major
34#define gnu_minor minor
35#undef major
36#undef minor
37#endif
38
39typedef enum class plug_status {
40 unblocked,
42 hard,
43 soft
45
46typedef struct plug_data {
47 std::string name;
48 int major;
49 int minor;
50
51 plug_data(std::string n, int _major, int _minor)
52 : name(n), major(_major), minor(_minor) {}
53
54} plug_data;
55
66public:
67 virtual ~AbstractBlacklist() = default;
68
70 virtual plug_status get_status(const std::string& name, int _major,
71 int _minor) = 0;
72
74 virtual plug_status get_status(const plug_data pd) = 0;
75
77 virtual plug_data get_library_data(const std::string& library_file) = 0;
78
83 virtual bool mark_unloadable(const std::string& path) = 0;
84
89 virtual bool mark_unloadable(const std::string& name, int major,
90 int minor) = 0;
91
93 virtual bool is_loadable(const std::string path) = 0;
94
96 virtual std::string get_message(plug_status sts, const plug_data& data) = 0;
97};
98
99std::unique_ptr<AbstractBlacklist> blacklist_factory();
100
101#ifdef gnu_major
102#define major gnu_major
103#define minor gnu_minor
104#endif
105
106#endif // PLUGIN_BLACKLIST_H
Plugins could be blacklisted in runtime if they are unloadable or in hardcoded, compile-time list.
virtual bool is_loadable(const std::string path)=0
Return true iff plugin (a path) is loadable.
virtual bool mark_unloadable(const std::string &name, int major, int minor)=0
Given plugin name and version mark it as unloadable.
virtual bool mark_unloadable(const std::string &path)=0
Given a path, mark filename as unloadable.
virtual plug_status get_status(const std::string &name, int _major, int _minor)=0
Return status for given official plugin name and version.
virtual std::string get_message(plug_status sts, const plug_data &data)=0
Return plugin-specific message, possibly "".
virtual plug_data get_library_data(const std::string &library_file)=0
Best effort attempt to get data for a library file.
virtual plug_status get_status(const plug_data pd)=0
Return status for given official plugin name and version.
plug_status
@ unloadable
Not blocked for any reason.
@ hard
Tried with load error.
@ soft
Hard block from code or configuration.