mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 23:58:20 +00:00
Merge branch 'master' of git.bro.org:bro
This commit is contained in:
commit
8479298e04
4 changed files with 79 additions and 17 deletions
|
@ -241,6 +241,8 @@ bool Manager::ActivateDynamicPluginInternal(const std::string& name, bool ok_if_
|
|||
DBG_LOG(DBG_PLUGINS, " InitialzingComponents");
|
||||
current_plugin->InitializeComponents();
|
||||
|
||||
plugins_by_path.insert(std::make_pair(normalize_path(dir), current_plugin));
|
||||
|
||||
if ( current_plugin->APIVersion() != BRO_PLUGIN_API_VERSION )
|
||||
reporter->FatalError("plugin's API version does not match Bro (expected %d, got %d in %s)",
|
||||
BRO_PLUGIN_API_VERSION, current_plugin->APIVersion(), path);
|
||||
|
@ -328,7 +330,7 @@ void Manager::RegisterPlugin(Plugin *plugin)
|
|||
|
||||
if ( current_dir && current_sopath )
|
||||
// A dynamic plugin, record its location.
|
||||
plugin->SetPluginLocation(current_dir, current_sopath);
|
||||
plugin->SetPluginLocation(normalize_path(current_dir), current_sopath);
|
||||
|
||||
current_plugin = plugin;
|
||||
}
|
||||
|
@ -463,6 +465,31 @@ Manager::bif_init_func_map* Manager::BifFilesInternal()
|
|||
return bifs;
|
||||
}
|
||||
|
||||
Plugin* Manager::LookupPluginByPath(std::string path)
|
||||
{
|
||||
path = normalize_path(path);
|
||||
|
||||
if ( is_file(path) )
|
||||
path = SafeDirname(path).result;
|
||||
|
||||
while ( path.size() )
|
||||
{
|
||||
auto i = plugins_by_path.find(path);
|
||||
|
||||
if ( i != plugins_by_path.end() )
|
||||
return i->second;
|
||||
|
||||
auto j = path.rfind("/");
|
||||
|
||||
if ( j == std::string::npos )
|
||||
break;
|
||||
|
||||
path.erase(j);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static bool hook_cmp(std::pair<int, Plugin*> a, std::pair<int, Plugin*> b)
|
||||
{
|
||||
if ( a.first == b.first )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue