mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 18:48:20 +00:00
Merge branch 'topic/robin/dynamic-plugins-2.3' into topic/robin/reader-writer-plugins
This commit is contained in:
commit
48b251abd1
21 changed files with 781 additions and 804 deletions
84
src/Func.cc
84
src/Func.cc
|
@ -245,44 +245,12 @@ TraversalCode Func::Traverse(TraversalCallback* cb) const
|
|||
HANDLE_TC_STMT_POST(tc);
|
||||
}
|
||||
|
||||
BroFunc::BroFunc(ID* arg_id, Stmt* arg_body, id_list* aggr_inits,
|
||||
int arg_frame_size, int priority)
|
||||
: Func(BRO_FUNC)
|
||||
{
|
||||
name = arg_id->Name();
|
||||
type = arg_id->Type()->Ref();
|
||||
frame_size = arg_frame_size;
|
||||
|
||||
if ( arg_body )
|
||||
{
|
||||
Body b;
|
||||
b.stmts = AddInits(arg_body, aggr_inits);
|
||||
b.priority = priority;
|
||||
bodies.push_back(b);
|
||||
}
|
||||
}
|
||||
|
||||
BroFunc::~BroFunc()
|
||||
{
|
||||
for ( unsigned int i = 0; i < bodies.size(); ++i )
|
||||
Unref(bodies[i].stmts);
|
||||
}
|
||||
|
||||
int BroFunc::IsPure() const
|
||||
{
|
||||
for ( unsigned int i = 0; i < bodies.size(); ++i )
|
||||
if ( ! bodies[i].stmts->IsPure() )
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
Val* BroFunc::HandlePluginResult(Val* plugin_result, val_list* args) const
|
||||
Val* Func::HandlePluginResult(Val* plugin_result, val_list* args, function_flavor flavor) const
|
||||
{
|
||||
// Helper function factoring out this code from BroFunc:Call() for better
|
||||
// readability.
|
||||
|
||||
switch ( Flavor() ) {
|
||||
switch ( flavor ) {
|
||||
case FUNC_FLAVOR_EVENT:
|
||||
Unref(plugin_result);
|
||||
plugin_result = 0;
|
||||
|
@ -320,16 +288,53 @@ Val* BroFunc::HandlePluginResult(Val* plugin_result, val_list* args) const
|
|||
return plugin_result;
|
||||
}
|
||||
|
||||
BroFunc::BroFunc(ID* arg_id, Stmt* arg_body, id_list* aggr_inits,
|
||||
int arg_frame_size, int priority)
|
||||
: Func(BRO_FUNC)
|
||||
{
|
||||
name = arg_id->Name();
|
||||
type = arg_id->Type()->Ref();
|
||||
frame_size = arg_frame_size;
|
||||
|
||||
if ( arg_body )
|
||||
{
|
||||
Body b;
|
||||
b.stmts = AddInits(arg_body, aggr_inits);
|
||||
b.priority = priority;
|
||||
bodies.push_back(b);
|
||||
}
|
||||
}
|
||||
|
||||
BroFunc::~BroFunc()
|
||||
{
|
||||
for ( unsigned int i = 0; i < bodies.size(); ++i )
|
||||
Unref(bodies[i].stmts);
|
||||
}
|
||||
|
||||
int BroFunc::IsPure() const
|
||||
{
|
||||
for ( unsigned int i = 0; i < bodies.size(); ++i )
|
||||
if ( ! bodies[i].stmts->IsPure() )
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
Val* BroFunc::Call(val_list* args, Frame* parent) const
|
||||
{
|
||||
#ifdef PROFILE_BRO_FUNCTIONS
|
||||
DEBUG_MSG("Function: %s\n", id->Name());
|
||||
#endif
|
||||
|
||||
SegmentProfiler(segment_logger, location);
|
||||
|
||||
if ( sample_logger )
|
||||
sample_logger->FunctionSeen(this);
|
||||
|
||||
Val* plugin_result = PLUGIN_HOOK_WITH_RESULT(HOOK_CALL_FUNCTION, HookCallFunction(this, args), 0);
|
||||
|
||||
if ( plugin_result )
|
||||
return HandlePluginResult(plugin_result, args);
|
||||
return HandlePluginResult(plugin_result, args, Flavor());
|
||||
|
||||
if ( bodies.empty() )
|
||||
{
|
||||
|
@ -341,7 +346,6 @@ Val* BroFunc::Call(val_list* args, Frame* parent) const
|
|||
return Flavor() == FUNC_FLAVOR_HOOK ? new Val(true, TYPE_BOOL) : 0;
|
||||
}
|
||||
|
||||
SegmentProfiler(segment_logger, location);
|
||||
Frame* f = new Frame(frame_size, this, args);
|
||||
|
||||
// Hand down any trigger.
|
||||
|
@ -369,9 +373,6 @@ Val* BroFunc::Call(val_list* args, Frame* parent) const
|
|||
|
||||
Val* result = 0;
|
||||
|
||||
if ( sample_logger )
|
||||
sample_logger->FunctionSeen(this);
|
||||
|
||||
for ( size_t i = 0; i < bodies.size(); ++i )
|
||||
{
|
||||
if ( sample_logger )
|
||||
|
@ -547,6 +548,11 @@ Val* BuiltinFunc::Call(val_list* args, Frame* parent) const
|
|||
if ( sample_logger )
|
||||
sample_logger->FunctionSeen(this);
|
||||
|
||||
Val* plugin_result = PLUGIN_HOOK_WITH_RESULT(HOOK_CALL_FUNCTION, HookCallFunction(this, args), 0);
|
||||
|
||||
if ( plugin_result )
|
||||
return HandlePluginResult(plugin_result, args, FUNC_FLAVOR_FUNCTION);
|
||||
|
||||
if ( g_trace_state.DoTrace() )
|
||||
{
|
||||
ODesc d;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue