Deprecate Plugin::HookCallFunction(), replace with HookFunctionCall()

This also changes the argument type of Func::operator() to zeek::Args*
to allow plugins to be able to alter function arguments in place as
was previously documented.
This commit is contained in:
Jon Siwek 2020-05-22 21:01:38 -07:00
parent 46c5dea733
commit 272db640aa
27 changed files with 417 additions and 77 deletions

View file

@ -151,6 +151,17 @@ void HookArgument::Describe(ODesc* d) const
d->Add("<null>");
break;
case ARG_LIST:
if ( arg.args)
{
d->Add("(");
describe_vals(*arg.args, d);
d->Add(")");
}
else
d->Add("<null>");
break;
case VOID:
d->Add("<void>");
break;
@ -364,6 +375,26 @@ int Plugin::HookLoadFile(const LoadType type, const std::string& file, const std
return -1;
}
std::pair<bool, IntrusivePtr<Val>>
Plugin::HookFunctionCall(const Func* func, Frame* parent,
zeek::Args* args)
{
val_list vlargs(args->size());
for ( auto& v : *args )
vlargs.push_back(v.release());
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
auto [handled, result] = HookCallFunction(func, parent, &vlargs);
#pragma GCC diagnostic pop
for ( auto i = 0u; i < args->size(); ++i )
(*args)[i] = {AdoptRef{}, vlargs[i]};
return {handled, {AdoptRef{}, result}};
}
std::pair<bool, Val*> Plugin::HookCallFunction(const Func* func, Frame *parent, val_list* args)
{
std::pair<bool, Val*> result(false, NULL);