mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 17:18:20 +00:00
Restore globally-namespaced plugin_mgr variable, move zeek::plugin::plugin_mgr to zeek::plugin_mgr
This commit is contained in:
parent
9400b863ea
commit
834b76f94f
7 changed files with 35 additions and 29 deletions
|
@ -350,7 +350,7 @@ PktSrc* Manager::OpenPktSrc(const std::string& path, bool is_live)
|
|||
|
||||
PktSrcComponent* component = nullptr;
|
||||
|
||||
std::list<PktSrcComponent*> all_components = plugin_mgr->Components<PktSrcComponent>();
|
||||
std::list<PktSrcComponent*> all_components = zeek::plugin_mgr->Components<PktSrcComponent>();
|
||||
for ( const auto& c : all_components )
|
||||
{
|
||||
if ( c->HandlesPrefix(prefix) &&
|
||||
|
@ -388,7 +388,7 @@ PktDumper* Manager::OpenPktDumper(const std::string& path, bool append)
|
|||
|
||||
PktDumperComponent* component = nullptr;
|
||||
|
||||
std::list<PktDumperComponent*> all_components = plugin_mgr->Components<PktDumperComponent>();
|
||||
std::list<PktDumperComponent*> all_components = zeek::plugin_mgr->Components<PktDumperComponent>();
|
||||
for ( const auto& c : all_components )
|
||||
{
|
||||
if ( c->HandlesPrefix(prefix) )
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
#include "../Reporter.h"
|
||||
#include "../ZeekArgs.h"
|
||||
|
||||
namespace zeek::plugin {
|
||||
namespace zeek {
|
||||
namespace plugin {
|
||||
|
||||
// Macros that trigger plugin hooks. We put this into macros to short-cut the
|
||||
// code for the most common case that no plugin defines the hook.
|
||||
|
@ -25,7 +26,7 @@ namespace zeek::plugin {
|
|||
* @param method_call The \a Manager method corresponding to the hook.
|
||||
*/
|
||||
#define PLUGIN_HOOK_VOID(hook, method_call) \
|
||||
{ if ( plugin_mgr->HavePluginForHook(zeek::plugin::hook) ) plugin_mgr->method_call; }
|
||||
{ if ( zeek::plugin_mgr->HavePluginForHook(zeek::plugin::hook) ) zeek::plugin_mgr->method_call; }
|
||||
|
||||
/**
|
||||
* Macro to trigger hooks that return a result.
|
||||
|
@ -38,7 +39,7 @@ namespace zeek::plugin {
|
|||
* the hook.
|
||||
*/
|
||||
#define PLUGIN_HOOK_WITH_RESULT(hook, method_call, default_result) \
|
||||
(plugin_mgr->HavePluginForHook(zeek::plugin::hook) ? plugin_mgr->method_call : (default_result))
|
||||
(zeek::plugin_mgr->HavePluginForHook(zeek::plugin::hook) ? zeek::plugin_mgr->method_call : (default_result))
|
||||
|
||||
/**
|
||||
* A singleton object managing all plugins.
|
||||
|
@ -480,7 +481,11 @@ std::list<T *> Manager::Components() const
|
|||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace plugin
|
||||
|
||||
extern zeek::plugin::Manager* plugin_mgr;
|
||||
|
||||
} // namespace zeek
|
||||
|
||||
// TOOD: should this just be zeek::detail?
|
||||
namespace zeek::detail::plugin {
|
||||
|
@ -499,10 +504,10 @@ public:
|
|||
}
|
||||
|
||||
namespace plugin {
|
||||
using Manager [[deprecated("Remove in v4.1. Use zeek::plugin::Manager instead.")]] = zeek::plugin::Manager;
|
||||
using Manager [[deprecated("Remove in v4.1. Use zeek::plugin::Manager.")]] = zeek::plugin::Manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* The global plugin manager singleton.
|
||||
*/
|
||||
extern zeek::plugin::Manager* plugin_mgr;
|
||||
extern zeek::plugin::Manager*& plugin_mgr [[deprecated("Remove in v4.1. Use zeek::plugin_mgr.")]];
|
||||
|
|
|
@ -347,27 +347,27 @@ void Plugin::AddComponent(zeek::plugin::Component* c)
|
|||
|
||||
Plugin::hook_list Plugin::EnabledHooks() const
|
||||
{
|
||||
return plugin_mgr->HooksEnabledForPlugin(this);
|
||||
return zeek::plugin_mgr->HooksEnabledForPlugin(this);
|
||||
}
|
||||
|
||||
void Plugin::EnableHook(zeek::plugin::HookType hook, int priority)
|
||||
{
|
||||
plugin_mgr->EnableHook(hook, this, priority);
|
||||
zeek::plugin_mgr->EnableHook(hook, this, priority);
|
||||
}
|
||||
|
||||
void Plugin::DisableHook(zeek::plugin::HookType hook)
|
||||
{
|
||||
plugin_mgr->DisableHook(hook, this);
|
||||
zeek::plugin_mgr->DisableHook(hook, this);
|
||||
}
|
||||
|
||||
void Plugin::RequestEvent(EventHandlerPtr handler)
|
||||
{
|
||||
plugin_mgr->RequestEvent(handler, this);
|
||||
zeek::plugin_mgr->RequestEvent(handler, this);
|
||||
}
|
||||
|
||||
void Plugin::RequestBroObjDtor(Obj* obj)
|
||||
{
|
||||
plugin_mgr->RequestBroObjDtor(obj, this);
|
||||
zeek::plugin_mgr->RequestBroObjDtor(obj, this);
|
||||
}
|
||||
|
||||
int Plugin::HookLoadFile(const LoadType type, const std::string& file, const std::string& resolved)
|
||||
|
|
|
@ -375,7 +375,7 @@ when return TOK_WHEN;
|
|||
switch ( rc ) {
|
||||
case -1:
|
||||
// No plugin in charge of this file.
|
||||
plugin_mgr->ActivateDynamicPlugin(plugin);
|
||||
zeek::plugin_mgr->ActivateDynamicPlugin(plugin);
|
||||
break;
|
||||
|
||||
case 0:
|
||||
|
|
|
@ -89,6 +89,8 @@ zeek::ValManager* zeek::val_mgr = nullptr;
|
|||
zeek::ValManager*& val_mgr = zeek::val_mgr;
|
||||
zeek::analyzer::Manager* zeek::analyzer_mgr = nullptr;
|
||||
zeek::analyzer::Manager*& analyzer_mgr = zeek::analyzer_mgr;
|
||||
zeek::plugin::Manager* zeek::plugin_mgr = nullptr;
|
||||
zeek::plugin::Manager*& plugin_mgr = zeek::plugin_mgr;
|
||||
|
||||
DNS_Mgr* dns_mgr;
|
||||
TimerMgr* timer_mgr;
|
||||
|
@ -96,7 +98,6 @@ TimerMgr* timer_mgr;
|
|||
logging::Manager* log_mgr = nullptr;
|
||||
threading::Manager* thread_mgr = nullptr;
|
||||
input::Manager* input_mgr = nullptr;
|
||||
zeek::plugin::Manager* plugin_mgr = nullptr;
|
||||
file_analysis::Manager* file_mgr = nullptr;
|
||||
zeekygen::Manager* zeekygen_mgr = nullptr;
|
||||
iosource::Manager* iosource_mgr = nullptr;
|
||||
|
@ -164,7 +165,7 @@ static std::vector<const char*> to_cargs(const std::vector<std::string>& args)
|
|||
|
||||
bool show_plugins(int level)
|
||||
{
|
||||
zeek::plugin::Manager::plugin_list plugins = plugin_mgr->ActivePlugins();
|
||||
zeek::plugin::Manager::plugin_list plugins = zeek::plugin_mgr->ActivePlugins();
|
||||
|
||||
if ( ! plugins.size() )
|
||||
{
|
||||
|
@ -195,7 +196,7 @@ bool show_plugins(int level)
|
|||
|
||||
printf("%s", d.Description());
|
||||
|
||||
zeek::plugin::Manager::inactive_plugin_list inactives = plugin_mgr->InactivePlugins();
|
||||
zeek::plugin::Manager::inactive_plugin_list inactives = zeek::plugin_mgr->InactivePlugins();
|
||||
|
||||
if ( inactives.size() && ! requested_plugins.size() )
|
||||
{
|
||||
|
@ -300,7 +301,7 @@ void terminate_bro()
|
|||
|
||||
mgr.Drain();
|
||||
|
||||
plugin_mgr->FinishPlugins();
|
||||
zeek::plugin_mgr->FinishPlugins();
|
||||
|
||||
delete zeekygen_mgr;
|
||||
delete zeek::analyzer_mgr;
|
||||
|
@ -310,7 +311,7 @@ void terminate_bro()
|
|||
delete event_registry;
|
||||
delete log_mgr;
|
||||
delete reporter;
|
||||
delete plugin_mgr;
|
||||
delete zeek::plugin_mgr;
|
||||
delete zeek::val_mgr;
|
||||
|
||||
// free the global scope
|
||||
|
@ -471,7 +472,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv,
|
|||
zeek::val_mgr = new ValManager();
|
||||
reporter = new Reporter(options.abort_on_scripting_errors);
|
||||
thread_mgr = new threading::Manager();
|
||||
plugin_mgr = new zeek::plugin::Manager();
|
||||
zeek::plugin_mgr = new zeek::plugin::Manager();
|
||||
|
||||
#ifdef DEBUG
|
||||
if ( options.debug_log_streams )
|
||||
|
@ -537,7 +538,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv,
|
|||
if ( ! options.bare_mode )
|
||||
add_input_file("base/init-default.zeek");
|
||||
|
||||
plugin_mgr->SearchDynamicPlugins(bro_plugin_path());
|
||||
zeek::plugin_mgr->SearchDynamicPlugins(bro_plugin_path());
|
||||
|
||||
if ( options.plugins_to_load.empty() && options.scripts_to_load.empty() &&
|
||||
options.script_options_to_set.empty() &&
|
||||
|
@ -575,7 +576,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv,
|
|||
broker_mgr = new bro_broker::Manager(broker_real_time);
|
||||
trigger_mgr = new zeek::detail::trigger::Manager();
|
||||
|
||||
plugin_mgr->InitPreScript();
|
||||
zeek::plugin_mgr->InitPreScript();
|
||||
zeek::analyzer_mgr->InitPreScript();
|
||||
file_mgr->InitPreScript();
|
||||
zeekygen_mgr->InitPreScript();
|
||||
|
@ -585,14 +586,14 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv,
|
|||
for ( set<string>::const_iterator i = requested_plugins.begin();
|
||||
i != requested_plugins.end(); i++ )
|
||||
{
|
||||
if ( ! plugin_mgr->ActivateDynamicPlugin(*i) )
|
||||
if ( ! zeek::plugin_mgr->ActivateDynamicPlugin(*i) )
|
||||
missing_plugin = true;
|
||||
}
|
||||
|
||||
if ( missing_plugin )
|
||||
reporter->FatalError("Failed to activate requested dynamic plugin(s).");
|
||||
|
||||
plugin_mgr->ActivateDynamicPlugins(! options.bare_mode);
|
||||
zeek::plugin_mgr->ActivateDynamicPlugins(! options.bare_mode);
|
||||
|
||||
init_event_handlers();
|
||||
|
||||
|
@ -640,14 +641,14 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv,
|
|||
"BinPAC::flowbuffer_contract_threshold")->GetVal()->AsCount();
|
||||
binpac::init(&flowbuffer_policy);
|
||||
|
||||
plugin_mgr->InitBifs();
|
||||
zeek::plugin_mgr->InitBifs();
|
||||
|
||||
if ( reporter->Errors() > 0 )
|
||||
exit(1);
|
||||
|
||||
iosource_mgr->InitPostScript();
|
||||
log_mgr->InitPostScript();
|
||||
plugin_mgr->InitPostScript();
|
||||
zeek::plugin_mgr->InitPostScript();
|
||||
zeekygen_mgr->InitPostScript();
|
||||
broker_mgr->InitPostScript();
|
||||
timer_mgr->InitPostScript();
|
||||
|
|
|
@ -54,7 +54,7 @@ static string RemoveLeadingSpace(const string& s)
|
|||
// use for indexing.
|
||||
static string NormalizeScriptPath(const string& path)
|
||||
{
|
||||
if ( auto p = plugin_mgr->LookupPluginByPath(path) )
|
||||
if ( auto p = zeek::plugin_mgr->LookupPluginByPath(path) )
|
||||
{
|
||||
auto rval = normalize_path(path);
|
||||
auto prefix = SafeBasename(p->PluginDirectory()).result;
|
||||
|
|
|
@ -265,7 +265,7 @@ void ProtoAnalyzerTarget::DoCreateAnalyzerDoc(FILE* f) const
|
|||
|
||||
WriteAnalyzerTagDefn(f, "Analyzer");
|
||||
|
||||
zeek::plugin::Manager::plugin_list plugins = plugin_mgr->ActivePlugins();
|
||||
zeek::plugin::Manager::plugin_list plugins = zeek::plugin_mgr->ActivePlugins();
|
||||
zeek::plugin::Manager::plugin_list::const_iterator it;
|
||||
|
||||
for ( it = plugins.begin(); it != plugins.end(); ++it )
|
||||
|
@ -291,7 +291,7 @@ void FileAnalyzerTarget::DoCreateAnalyzerDoc(FILE* f) const
|
|||
|
||||
WriteAnalyzerTagDefn(f, "Files");
|
||||
|
||||
zeek::plugin::Manager::plugin_list plugins = plugin_mgr->ActivePlugins();
|
||||
zeek::plugin::Manager::plugin_list plugins = zeek::plugin_mgr->ActivePlugins();
|
||||
zeek::plugin::Manager::plugin_list::const_iterator it;
|
||||
|
||||
for ( it = plugins.begin(); it != plugins.end(); ++it )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue