Move Func and associated classes into zeek::detail namespace

This commit is contained in:
Tim Wojtulewicz 2020-06-22 15:45:40 -07:00
parent 937a462e70
commit d6f1ea16ac
51 changed files with 516 additions and 453 deletions

@ -1 +1 @@
Subproject commit 001e1c30f9646ea1198da6f8d24dc2235dbcd390
Subproject commit d7096e916aa04e54d7501424485f1651b38d7234

View file

@ -849,7 +849,7 @@ const char* CompositeHash::RecoverOneVal(
const uint32_t* const kp = AlignType<uint32_t>(kp0);
kp1 = reinterpret_cast<const char*>(kp+1);
const auto& f = Func::GetFuncPtrByID(*kp);
const auto& f = zeek::detail::Func::GetFuncPtrByID(*kp);
if ( ! f )
reporter->InternalError("failed to look up unique function id %" PRIu32 " in CompositeHash::RecoverOneVal()", *kp);

View file

@ -13,10 +13,10 @@
#include "IPAddr.h"
#include "util.h"
class Func;
class EventHandler;
class DNS_Mgr_Request;
ZEEK_FORWARD_DECLARE_NAMESPACED(Func, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(RecordType, zeek);
ZEEK_FORWARD_DECLARE_NAMESPACED(Val, zeek);
ZEEK_FORWARD_DECLARE_NAMESPACED(ListVal, zeek);

View file

@ -351,7 +351,7 @@ void DbgBreakpoint::PrintHitMsg()
{
ODesc d;
zeek::detail::Frame* f = g_frame_stack.back();
const BroFunc* func = f->GetFunction();
const zeek::detail::BroFunc* func = f->GetFunction();
if ( func )
func->DescribeDebug (&d, f->GetFuncArgs());

View file

@ -146,7 +146,7 @@ int TraceState::LogTrace(const char* fmt, ...)
loc = *stmt->GetLocationInfo();
else
{
const BroFunc* f = g_frame_stack.back()->GetFunction();
const zeek::detail::BroFunc* f = g_frame_stack.back()->GetFunction();
if ( f )
loc = *f->GetLocationInfo();
}
@ -221,8 +221,8 @@ static void parse_function_name(vector<ParseLocationRec>& result,
return;
}
const Func* func = id->GetVal()->AsFunc();
const vector<Func::Body>& bodies = func->GetBodies();
const zeek::detail::Func* func = id->GetVal()->AsFunc();
const vector<zeek::detail::Func::Body>& bodies = func->GetBodies();
if ( bodies.size() == 0 )
{
@ -731,7 +731,7 @@ static char* get_prompt(bool reset_counter = false)
string get_context_description(const zeek::detail::Stmt* stmt, const zeek::detail::Frame* frame)
{
ODesc d;
const BroFunc* func = frame ? frame->GetFunction() : nullptr;
const zeek::detail::BroFunc* func = frame ? frame->GetFunction() : nullptr;
if ( func )
func->DescribeDebug(&d, frame->GetFuncArgs());
@ -770,7 +770,7 @@ int dbg_handle_debug_input()
}
zeek::detail::Frame* curr_frame = g_frame_stack.back();
const BroFunc* func = curr_frame->GetFunction();
const zeek::detail::BroFunc* func = curr_frame->GetFunction();
if ( func )
zeek::detail::current_module = extract_module_name(func->Name());
else
@ -963,7 +963,7 @@ zeek::ValPtr dbg_eval_expr(const char* expr)
if ( ! (frame) )
reporter->InternalError("Assertion failed: frame");
const BroFunc* func = frame->GetFunction();
const zeek::detail::BroFunc* func = frame->GetFunction();
if ( func )
{
Ref(func->GetScope());

View file

@ -7,11 +7,14 @@
#include "IntrusivePtr.h"
class IP_Hdr;
class Func;
using FuncPtr = zeek::IntrusivePtr<Func>;
ZEEK_FORWARD_DECLARE_NAMESPACED(Func, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(Val, zeek);
namespace zeek::detail {
using FuncPtr = zeek::IntrusivePtr<Func>;
}
class Discarder {
public:
Discarder();
@ -24,10 +27,10 @@ public:
protected:
zeek::Val* BuildData(const u_char* data, int hdrlen, int len, int caplen);
FuncPtr check_ip;
FuncPtr check_tcp;
FuncPtr check_udp;
FuncPtr check_icmp;
zeek::detail::FuncPtr check_ip;
zeek::detail::FuncPtr check_tcp;
zeek::detail::FuncPtr check_udp;
zeek::detail::FuncPtr check_icmp;
// Maximum amount of application data passed to filtering functions.
int discarder_maxlen;

View file

@ -44,10 +44,10 @@ const zeek::FuncTypePtr& EventHandler::GetType(bool check_export)
return type;
}
void EventHandler::SetFunc(FuncPtr f)
void EventHandler::SetFunc(zeek::detail::FuncPtr f)
{ local = std::move(f); }
void EventHandler::SetLocalHandler(Func* f)
void EventHandler::SetLocalHandler(zeek::detail::Func* f)
{ SetFunc({zeek::NewRef{}, f}); }
void EventHandler::Call(zeek::Args* vl, bool no_remote)

View file

@ -9,8 +9,10 @@
#include <unordered_set>
#include <string>
class Func;
using FuncPtr = zeek::IntrusivePtr<Func>;
ZEEK_FORWARD_DECLARE_NAMESPACED(Func, zeek::detail);
namespace zeek::detail {
using FuncPtr = zeek::IntrusivePtr<zeek::detail::Func>;
}
class EventHandler {
public:
@ -18,11 +20,11 @@ public:
const char* Name() { return name.data(); }
const FuncPtr& GetFunc()
const zeek::detail::FuncPtr& GetFunc()
{ return local; }
[[deprecated("Remove in v4.1. Use GetFunc().")]]
Func* LocalHandler() { return local.get(); }
zeek::detail::Func* LocalHandler() { return local.get(); }
const zeek::FuncTypePtr& GetType(bool check_export = true);
@ -30,10 +32,10 @@ public:
zeek::FuncType* FType(bool check_export = true)
{ return GetType().get(); }
void SetFunc(FuncPtr f);
void SetFunc(zeek::detail::FuncPtr f);
[[deprecated("Remove in v4.1. Use SetFunc().")]]
void SetLocalHandler(Func* f);
void SetLocalHandler(zeek::detail::Func* f);
void AutoPublish(std::string topic)
{
@ -69,7 +71,7 @@ private:
void NewEvent(zeek::Args* vl); // Raise new_event() meta event.
std::string name;
FuncPtr local;
zeek::detail::FuncPtr local;
zeek::FuncTypePtr type;
bool used; // this handler is indeed used somewhere
bool enabled;

View file

@ -4051,8 +4051,8 @@ CallExpr::CallExpr(ExprPtr arg_func, ListExprPtr arg_args, bool in_hook)
did_builtin_init &&
(func_val = func->Eval(nullptr)) )
{
::Func* f = func_val->AsFunc();
if ( f->GetKind() == Func::BUILTIN_FUNC &&
zeek::detail::Func* f = func_val->AsFunc();
if ( f->GetKind() == zeek::detail::Func::BUILTIN_FUNC &&
! check_built_in_call((BuiltinFunc*) f, this) )
SetError();
}
@ -4072,7 +4072,7 @@ bool CallExpr::IsPure() const
if ( ! func_val )
return false;
::Func* f = func_val->AsFunc();
zeek::detail::Func* f = func_val->AsFunc();
// Only recurse for built-in functions, as recursing on script
// functions can lead to infinite recursion if the function being
@ -4080,7 +4080,7 @@ bool CallExpr::IsPure() const
// or indirectly).
bool pure = false;
if ( f->GetKind() == Func::BUILTIN_FUNC )
if ( f->GetKind() == zeek::detail::Func::BUILTIN_FUNC )
pure = f->IsPure() && args->IsPure();
return pure;
@ -4114,7 +4114,7 @@ ValPtr CallExpr::Eval(Frame* f) const
if ( func_val && v )
{
const ::Func* funcv = func_val->AsFunc();
const zeek::detail::Func* funcv = func_val->AsFunc();
const CallExpr* current_call = f ? f->GetCall() : nullptr;
if ( f )

View file

@ -19,7 +19,9 @@
ZEEK_FORWARD_DECLARE_NAMESPACED(Frame, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(Scope, zeek::detail);
struct function_ingredients;
namespace zeek::detail { struct function_ingredients; }
using function_ingredients [[deprecated("Remove in v4.1. Use zeek::detail::function_ingredients.")]] = zeek::detail::function_ingredients;
namespace zeek {
template <class T> class IntrusivePtr;

View file

@ -16,8 +16,7 @@
#include <broker/data.hh>
#include <broker/expected.hh>
class BroFunc;
ZEEK_FORWARD_DECLARE_NAMESPACED(BroFunc, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(CallExpr, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(Trigger, zeek::detail::trigger);

View file

@ -55,8 +55,25 @@
#include "iosource/PktSrc.h"
#include "iosource/PktDumper.h"
#include "zeek.bif.func_h"
#include "stats.bif.func_h"
#include "reporter.bif.func_h"
#include "strings.bif.func_h"
#include "option.bif.func_h"
#include "supervisor.bif.func_h"
#include "zeek.bif.func_def"
#include "stats.bif.func_def"
#include "reporter.bif.func_def"
#include "strings.bif.func_def"
#include "option.bif.func_def"
#include "supervisor.bif.func_def"
extern RETSIGTYPE sig_handler(int signo);
namespace zeek {
namespace detail {
std::vector<CallInfo> call_stack;
bool did_builtin_init = false;
@ -134,7 +151,7 @@ void Func::SetScope(zeek::detail::ScopePtr newscope)
scope = std::move(newscope);
}
FuncPtr Func::DoClone()
zeek::detail::FuncPtr Func::DoClone()
{
// By default, ok just to return a reference. Func does not have any state
// that is different across instances.
@ -541,7 +558,7 @@ bool BroFunc::UpdateClosure(const broker::vector& data)
}
FuncPtr BroFunc::DoClone()
zeek::detail::FuncPtr BroFunc::DoClone()
{
// BroFunc could hold a closure. In this case a clone of it must
// store a copy of this closure.
@ -665,132 +682,6 @@ void BuiltinFunc::Describe(ODesc* d) const
d->AddCount(is_pure);
}
void builtin_error(const char* msg)
{
builtin_error(msg, zeek::ValPtr{});
}
void builtin_error(const char* msg, zeek::ValPtr arg)
{
builtin_error(msg, arg.get());
}
void builtin_error(const char* msg, BroObj* arg)
{
auto emit = [=](const zeek::detail::CallExpr* ce)
{
if ( ce )
ce->Error(msg, arg);
else
reporter->Error(msg, arg);
};
if ( call_stack.empty() )
{
emit(nullptr);
return;
}
auto last_call = call_stack.back();
if ( call_stack.size() < 2 )
{
// Don't need to check for wrapper function like "<module>::__<func>"
emit(last_call.call);
return;
}
auto starts_with_double_underscore = [](const std::string& name) -> bool
{ return name.size() > 2 && name[0] == '_' && name[1] == '_'; };
std::string last_func = last_call.func->Name();
auto pos = last_func.find_first_of("::");
std::string wrapper_func;
if ( pos == std::string::npos )
{
if ( ! starts_with_double_underscore(last_func) )
{
emit(last_call.call);
return;
}
wrapper_func = last_func.substr(2);
}
else
{
auto module_name = last_func.substr(0, pos);
auto func_name = last_func.substr(pos + 2);
if ( ! starts_with_double_underscore(func_name) )
{
emit(last_call.call);
return;
}
wrapper_func = module_name + "::" + func_name.substr(2);
}
auto parent_call = call_stack[call_stack.size() - 2];
auto parent_func = parent_call.func->Name();
if ( wrapper_func == parent_func )
emit(parent_call.call);
else
emit(last_call.call);
}
#include "zeek.bif.func_h"
#include "stats.bif.func_h"
#include "reporter.bif.func_h"
#include "strings.bif.func_h"
#include "option.bif.func_h"
#include "supervisor.bif.func_h"
#include "zeek.bif.func_def"
#include "stats.bif.func_def"
#include "reporter.bif.func_def"
#include "strings.bif.func_def"
#include "option.bif.func_def"
#include "supervisor.bif.func_def"
#include "__all__.bif.cc" // Autogenerated for compiling in the bif_target() code.
#include "__all__.bif.register.cc" // Autogenerated for compiling in the bif_target() code.
void init_builtin_funcs()
{
ProcStats = zeek::id::find_type<zeek::RecordType>("ProcStats");
NetStats = zeek::id::find_type<zeek::RecordType>("NetStats");
MatcherStats = zeek::id::find_type<zeek::RecordType>("MatcherStats");
ConnStats = zeek::id::find_type<zeek::RecordType>("ConnStats");
ReassemblerStats = zeek::id::find_type<zeek::RecordType>("ReassemblerStats");
DNSStats = zeek::id::find_type<zeek::RecordType>("DNSStats");
GapStats = zeek::id::find_type<zeek::RecordType>("GapStats");
EventStats = zeek::id::find_type<zeek::RecordType>("EventStats");
TimerStats = zeek::id::find_type<zeek::RecordType>("TimerStats");
FileAnalysisStats = zeek::id::find_type<zeek::RecordType>("FileAnalysisStats");
ThreadStats = zeek::id::find_type<zeek::RecordType>("ThreadStats");
BrokerStats = zeek::id::find_type<zeek::RecordType>("BrokerStats");
ReporterStats = zeek::id::find_type<zeek::RecordType>("ReporterStats");
var_sizes = zeek::id::find_type("var_sizes")->AsTableType();
#include "zeek.bif.func_init"
#include "stats.bif.func_init"
#include "reporter.bif.func_init"
#include "strings.bif.func_init"
#include "option.bif.func_init"
#include "supervisor.bif.func_init"
did_builtin_init = true;
}
void init_builtin_funcs_subdirs()
{
#include "__all__.bif.init.cc" // Autogenerated for compiling in the bif_target() code.
}
bool check_built_in_call(BuiltinFunc* f, zeek::detail::CallExpr* call)
{
if ( f->TheFunc() != zeek::BifFunc::fmt_bif)
@ -894,3 +785,134 @@ function_ingredients::function_ingredients(zeek::detail::ScopePtr scope, zeek::d
priority = (attrs ? get_func_priority(*attrs) : 0);
this->body = std::move(body);
}
} // namespace detail
void emit_builtin_error(const char* msg)
{
emit_builtin_error(msg, zeek::ValPtr{});
}
void emit_builtin_error(const char* msg, zeek::ValPtr arg)
{
emit_builtin_error(msg, arg.get());
}
void emit_builtin_error(const char* msg, BroObj* arg)
{
auto emit = [=](const zeek::detail::CallExpr* ce)
{
if ( ce )
ce->Error(msg, arg);
else
reporter->Error(msg, arg);
};
if ( zeek::detail::call_stack.empty() )
{
emit(nullptr);
return;
}
auto last_call = zeek::detail::call_stack.back();
if ( zeek::detail::call_stack.size() < 2 )
{
// Don't need to check for wrapper function like "<module>::__<func>"
emit(last_call.call);
return;
}
auto starts_with_double_underscore = [](const std::string& name) -> bool
{ return name.size() > 2 && name[0] == '_' && name[1] == '_'; };
std::string last_func = last_call.func->Name();
auto pos = last_func.find_first_of("::");
std::string wrapper_func;
if ( pos == std::string::npos )
{
if ( ! starts_with_double_underscore(last_func) )
{
emit(last_call.call);
return;
}
wrapper_func = last_func.substr(2);
}
else
{
auto module_name = last_func.substr(0, pos);
auto func_name = last_func.substr(pos + 2);
if ( ! starts_with_double_underscore(func_name) )
{
emit(last_call.call);
return;
}
wrapper_func = module_name + "::" + func_name.substr(2);
}
auto parent_call = zeek::detail::call_stack[zeek::detail::call_stack.size() - 2];
auto parent_func = parent_call.func->Name();
if ( wrapper_func == parent_func )
emit(parent_call.call);
else
emit(last_call.call);
}
} // namespace zeek
void builtin_error(const char* msg)
{
zeek::emit_builtin_error(msg);
}
void builtin_error(const char* msg, zeek::ValPtr arg)
{
zeek::emit_builtin_error(msg, arg);
}
void builtin_error(const char* msg, BroObj* arg)
{
zeek::emit_builtin_error(msg, arg);
}
#include "__all__.bif.cc" // Autogenerated for compiling in the bif_target() code.
#include "__all__.bif.register.cc" // Autogenerated for compiling in the bif_target() code.
void init_builtin_funcs()
{
ProcStats = zeek::id::find_type<zeek::RecordType>("ProcStats");
NetStats = zeek::id::find_type<zeek::RecordType>("NetStats");
MatcherStats = zeek::id::find_type<zeek::RecordType>("MatcherStats");
ConnStats = zeek::id::find_type<zeek::RecordType>("ConnStats");
ReassemblerStats = zeek::id::find_type<zeek::RecordType>("ReassemblerStats");
DNSStats = zeek::id::find_type<zeek::RecordType>("DNSStats");
GapStats = zeek::id::find_type<zeek::RecordType>("GapStats");
EventStats = zeek::id::find_type<zeek::RecordType>("EventStats");
TimerStats = zeek::id::find_type<zeek::RecordType>("TimerStats");
FileAnalysisStats = zeek::id::find_type<zeek::RecordType>("FileAnalysisStats");
ThreadStats = zeek::id::find_type<zeek::RecordType>("ThreadStats");
BrokerStats = zeek::id::find_type<zeek::RecordType>("BrokerStats");
ReporterStats = zeek::id::find_type<zeek::RecordType>("ReporterStats");
var_sizes = zeek::id::find_type("var_sizes")->AsTableType();
#include "zeek.bif.func_init"
#include "stats.bif.func_init"
#include "reporter.bif.func_init"
#include "strings.bif.func_init"
#include "option.bif.func_init"
#include "supervisor.bif.func_init"
zeek::detail::did_builtin_init = true;
}
void init_builtin_funcs_subdirs()
{
#include "__all__.bif.init.cc" // Autogenerated for compiling in the bif_target() code.
}

View file

@ -41,8 +41,6 @@ namespace detail {
using ScopePtr = zeek::IntrusivePtr<zeek::detail::Scope>;
using IDPtr = zeek::IntrusivePtr<ID>;
using StmtPtr = zeek::IntrusivePtr<Stmt>;
}
}
class Func;
using FuncPtr = zeek::IntrusivePtr<Func>;
@ -244,13 +242,6 @@ protected:
bool is_pure;
};
extern void builtin_error(const char* msg);
extern void builtin_error(const char* msg, zeek::ValPtr);
extern void builtin_error(const char* msg, BroObj* arg);
extern void init_builtin_funcs();
extern void init_builtin_funcs_subdirs();
extern bool check_built_in_call(BuiltinFunc* f, zeek::detail::CallExpr* call);
struct CallInfo {
@ -265,14 +256,14 @@ struct function_ingredients {
// Gathers all of the information from a scope and a function body needed
// to build a function.
function_ingredients(zeek::detail::ScopePtr scope, zeek::detail::StmtPtr body);
function_ingredients(ScopePtr scope, StmtPtr body);
zeek::detail::IDPtr id;
zeek::detail::StmtPtr body;
std::vector<zeek::detail::IDPtr> inits;
IDPtr id;
StmtPtr body;
std::vector<IDPtr> inits;
int frame_size;
int priority;
zeek::detail::ScopePtr scope;
ScopePtr scope;
};
extern std::vector<CallInfo> call_stack;
@ -281,3 +272,37 @@ extern std::string render_call_stack();
// This is set to true after the built-in functions have been initialized.
extern bool did_builtin_init;
} // namespace detail
// These methods are used by BIFs, so they're in the public namespace.
extern void emit_builtin_error(const char* msg);
extern void emit_builtin_error(const char* msg, zeek::ValPtr);
extern void emit_builtin_error(const char* msg, BroObj* arg);
} // namespace zeek
using Func [[deprecated("Remove in v4.1. Use zeek::detail::Func.")]] = zeek::detail::Func;
using BroFunc [[deprecated("Remove in v4.1. Use zeek::detail::BroFunc.")]] = zeek::detail::BroFunc;
using BuiltinFunc [[deprecated("Remove in v4.1. Use zeek::detail::BroFunc.")]] = zeek::detail::BuiltinFunc;
using CallInfo [[deprecated("Remove in v4.1. Use zeek::detail::CallInfo.")]] = zeek::detail::CallInfo;
using function_ingredients [[deprecated("Remove in v4.1. Use zeek::detail::function_ingredients.")]] = zeek::detail::function_ingredients;
constexpr auto check_built_in_call [[deprecated("Remove in v4.1. Use zeek::detail::check_built_in_call.")]] = zeek::detail::check_built_in_call;
constexpr auto render_call_stack [[deprecated("Remove in v4.1. Use zeek::detail::render_call_stack.")]] = zeek::detail::render_call_stack;
// TODO: these are still here because of how all of the bif code gets included in Func.c. There could be a
// renamed version inside the namespace, but the way that the code gets included complicates the matter. It
// might need to be revisited after everything is namespaced everywhere else.
void init_builtin_funcs();
void init_builtin_funcs_subdirs();
// TODO: do call_stack and did_builtin_init need to be aliased?
// These have to be implemented as actual methods due to function overloading breaking the use of aliases.
[[deprecated("Remove in v4.1. Use zeek::emit_builtin_error.")]]
extern void builtin_error(const char* msg);
[[deprecated("Remove in v4.1. Use zeek::emit_builtin_error.")]]
extern void builtin_error(const char* msg, zeek::ValPtr);
[[deprecated("Remove in v4.1. Use zeek::emit_builtin_error.")]]
extern void builtin_error(const char* msg, BroObj* arg);

View file

@ -74,7 +74,7 @@ const zeek::ValPtr& zeek::id::find_const(std::string_view name)
return id->GetVal();
}
FuncPtr zeek::id::find_func(std::string_view name)
zeek::detail::FuncPtr zeek::id::find_func(std::string_view name)
{
const auto& v = zeek::id::find_val(name);
@ -643,7 +643,7 @@ void ID::UpdateValID()
}
#endif
void ID::AddOptionHandler(FuncPtr callback, int priority)
void ID::AddOptionHandler(zeek::detail::FuncPtr callback, int priority)
{
option_handlers.emplace(priority, std::move(callback));
}

View file

@ -13,9 +13,7 @@
#include <string_view>
#include <vector>
class Func;
using FuncPtr = zeek::IntrusivePtr<Func>;
ZEEK_FORWARD_DECLARE_NAMESPACED(Func, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(Val, zeek);
ZEEK_FORWARD_DECLARE_NAMESPACED(RecordType, zeek);
ZEEK_FORWARD_DECLARE_NAMESPACED(TableType, zeek);
@ -31,6 +29,7 @@ namespace zeek {
using EnumTypePtr = zeek::IntrusivePtr<zeek::EnumType>;
using ValPtr = zeek::IntrusivePtr<zeek::Val>;
}
using BroType [[deprecated("Remove in v4.1. Use zeek::Type instead.")]] = zeek::Type;
namespace zeek::detail {
@ -38,6 +37,7 @@ namespace zeek::detail {
class Attributes;
class Expr;
using ExprPtr = zeek::IntrusivePtr<Expr>;
using FuncPtr = zeek::IntrusivePtr<zeek::detail::Func>;
enum InitClass { INIT_NONE, INIT_FULL, INIT_EXTRA, INIT_REMOVE, };
enum IDScope { SCOPE_FUNCTION, SCOPE_MODULE, SCOPE_GLOBAL };
@ -156,7 +156,7 @@ public:
bool HasOptionHandlers() const
{ return !option_handlers.empty(); }
void AddOptionHandler(FuncPtr callback, int priority);
void AddOptionHandler(zeek::detail::FuncPtr callback, int priority);
std::vector<Func*> GetOptionHandlers() const;
protected:
@ -176,7 +176,7 @@ protected:
ValPtr val;
AttributesPtr attrs;
// contains list of functions that are called when an option changes
std::multimap<int, FuncPtr> option_handlers;
std::multimap<int, zeek::detail::FuncPtr> option_handlers;
};
@ -254,7 +254,7 @@ zeek::IntrusivePtr<T> find_const(std::string_view name)
* @param name The identifier name to lookup
* @return The current function value the identifier references.
*/
FuncPtr find_func(std::string_view name);
zeek::detail::FuncPtr find_func(std::string_view name);
extern RecordTypePtr conn_id;
extern RecordTypePtr endpoint;

View file

@ -6,10 +6,11 @@
#include "List.h"
class CCL;
class Func;
class NFA_State;
class EquivClass;
ZEEK_FORWARD_DECLARE_NAMESPACED(Func, zeek::detail);
typedef PList<NFA_State> NFA_state_list;
#define NO_ACCEPT 0

View file

@ -98,7 +98,7 @@ void BroObj::Internal(const char* msg) const
{
ODesc d;
DoMsg(&d, msg);
auto rcs = render_call_stack();
auto rcs = zeek::detail::render_call_stack();
if ( rcs.empty() )
reporter->InternalError("%s", d.Description());

View file

@ -223,7 +223,7 @@ Scope* global_scope()
}
const zeek::detail::IDPtr& lookup_ID(
const zeek::detail::IDPtr lookup_ID(
const char* name, const char* module,
bool no_global,
bool same_module_only,

View file

@ -128,7 +128,7 @@ constexpr auto global_scope [[deprecated("Remove in v4.1 Use zeek::detail::globa
// Because of the use of default arguments, this function can't be aliased like the rest.
[[deprecated("Remove in v4.1 Use zeek::detail::lookup_ID instead.")]]
extern const zeek::detail::IDPtr& lookup_ID(
extern const zeek::detail::IDPtr lookup_ID(
const char* name, const char* module,
bool no_global = false,
bool same_module_only = false,

View file

@ -352,7 +352,7 @@ SampleLogger::~SampleLogger()
Unref(load_samples);
}
void SampleLogger::FunctionSeen(const Func* func)
void SampleLogger::FunctionSeen(const zeek::detail::Func* func)
{
auto idx = zeek::make_intrusive<zeek::StringVal>(func->Name());
load_samples->Assign(std::move(idx), nullptr);

View file

@ -9,10 +9,10 @@
#include <sys/resource.h>
#include <stdint.h>
class Func;
class Location;
class BroFile;
ZEEK_FORWARD_DECLARE_NAMESPACED(Func, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(TableVal, zeek);
// Object called by SegmentProfiler when it is done and reports its
@ -94,7 +94,7 @@ public:
// These are called to report that a given function or location
// has been seen during the sampling.
void FunctionSeen(const Func* func);
void FunctionSeen(const zeek::detail::Func* func);
void LocationSeen(const Location* loc);
protected:

View file

@ -4,8 +4,7 @@
#include "TraverseTypes.h"
class Func;
ZEEK_FORWARD_DECLARE_NAMESPACED(Func, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(Scope, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
@ -16,8 +15,8 @@ public:
TraversalCallback() { current_scope = nullptr; }
virtual ~TraversalCallback() {}
virtual TraversalCode PreFunction(const Func*) { return TC_CONTINUE; }
virtual TraversalCode PostFunction(const Func*) { return TC_CONTINUE; }
virtual TraversalCode PreFunction(const zeek::detail::Func*) { return TC_CONTINUE; }
virtual TraversalCode PostFunction(const zeek::detail::Func*) { return TC_CONTINUE; }
virtual TraversalCode PreStmt(const zeek::detail::Stmt*) { return TC_CONTINUE; }
virtual TraversalCode PostStmt(const zeek::detail::Stmt*) { return TC_CONTINUE; }

View file

@ -44,10 +44,10 @@ using namespace std;
namespace zeek {
Val::Val(Func* f) : Val({NewRef{}, f})
Val::Val(zeek::detail::Func* f) : Val({NewRef{}, f})
{}
Val::Val(FuncPtr f)
Val::Val(zeek::detail::FuncPtr f)
: val(f.release()), type(val.func_val->GetType())
{}
@ -155,7 +155,7 @@ ValPtr Val::DoClone(CloneState* state)
return nullptr;
}
FuncPtr Val::AsFuncPtr() const
zeek::detail::FuncPtr Val::AsFuncPtr() const
{
CHECK_TAG(type->Tag(), TYPE_FUNC, "Val::Func", type_name)
return {NewRef{}, val.func_val};
@ -1858,7 +1858,7 @@ ValPtr TableVal::Default(const ValPtr& index)
return nullptr;
}
const Func* f = def_val->AsFunc();
const zeek::detail::Func* f = def_val->AsFunc();
Args vl;
if ( index->GetType()->Tag() == TYPE_LIST )
@ -2056,7 +2056,7 @@ void TableVal::CallChangeFunc(const Val* index,
return;
}
const Func* f = thefunc->AsFunc();
const zeek::detail::Func* f = thefunc->AsFunc();
auto lv = index->AsListVal();
Args vl;
@ -2514,7 +2514,7 @@ double TableVal::CallExpireFunc(ListValPtr idx)
return 0;
}
const Func* f = vf->AsFunc();
const zeek::detail::Func* f = vf->AsFunc();
Args vl;
const auto& func_args = f->GetType()->ParamList()->GetTypes();

View file

@ -30,8 +30,6 @@ template<typename T> class PDict;
class IterCookie;
class BroString;
class BroFunc;
class Func;
class BroFile;
class PrefixTable;
class IPAddr;
@ -43,13 +41,18 @@ class CompositeHash;
class HashKey;
ZEEK_FORWARD_DECLARE_NAMESPACED(Frame, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(Func, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(BroFunc, zeek::detail);
extern double bro_start_network_time;
namespace zeek {
using BroFilePtr = zeek::IntrusivePtr<BroFile>;
namespace detail {
using FuncPtr = zeek::IntrusivePtr<Func>;
}
using BroFilePtr = zeek::IntrusivePtr<BroFile>;
class Val;
class PortVal;
@ -93,7 +96,7 @@ union BroValUnion {
double double_val;
BroString* string_val;
Func* func_val;
zeek::detail::Func* func_val;
BroFile* file_val;
RE_Matcher* re_val;
PDict<TableEntryVal>* table_val;
@ -120,7 +123,7 @@ union BroValUnion {
constexpr BroValUnion(BroString* value) noexcept
: string_val(value) {}
constexpr BroValUnion(Func* value) noexcept
constexpr BroValUnion(zeek::detail::Func* value) noexcept
: func_val(value) {}
constexpr BroValUnion(BroFile* value) noexcept
@ -143,8 +146,8 @@ public:
{}
[[deprecated("Remove in v4.1. Construct from IntrusivePtr instead.")]]
explicit Val(Func* f);
explicit Val(FuncPtr f);
explicit Val(zeek::detail::Func* f);
explicit Val(zeek::detail::FuncPtr f);
[[deprecated("Remove in v4.1. Construct from IntrusivePtr instead.")]]
explicit Val(BroFile* f);
@ -233,7 +236,7 @@ public:
CONST_ACCESSOR2(zeek::TYPE_INTERVAL, double, double_val, AsInterval)
CONST_ACCESSOR2(zeek::TYPE_ENUM, int, int_val, AsEnum)
CONST_ACCESSOR(zeek::TYPE_STRING, BroString*, string_val, AsString)
CONST_ACCESSOR(zeek::TYPE_FUNC, Func*, func_val, AsFunc)
CONST_ACCESSOR(zeek::TYPE_FUNC, zeek::detail::Func*, func_val, AsFunc)
CONST_ACCESSOR(zeek::TYPE_TABLE, PDict<TableEntryVal>*, table_val, AsTable)
CONST_ACCESSOR(zeek::TYPE_RECORD, std::vector<ValPtr>*, record_val, AsRecord)
CONST_ACCESSOR(zeek::TYPE_FILE, BroFile*, file_val, AsFile)
@ -269,12 +272,12 @@ public:
// Accessors for mutable values are called AsNonConst* and
// are protected to avoid external state changes.
// ACCESSOR(zeek::TYPE_STRING, BroString*, string_val, AsString)
ACCESSOR(zeek::TYPE_FUNC, Func*, func_val, AsFunc)
ACCESSOR(zeek::TYPE_FUNC, zeek::detail::Func*, func_val, AsFunc)
ACCESSOR(zeek::TYPE_FILE, BroFile*, file_val, AsFile)
ACCESSOR(zeek::TYPE_PATTERN, RE_Matcher*, re_val, AsPattern)
ACCESSOR(zeek::TYPE_VECTOR, std::vector<ValPtr>*, vector_val, AsVector)
FuncPtr AsFuncPtr() const;
zeek::detail::FuncPtr AsFuncPtr() const;
const IPPrefix& AsSubNet()
{

View file

@ -307,7 +307,7 @@ static void make_var(const zeek::detail::IDPtr& id, zeek::TypePtr t,
// we can later access the ID even if no implementations have been
// defined.
std::vector<zeek::detail::IDPtr> inits;
auto f = zeek::make_intrusive<BroFunc>(id, nullptr, inits, 0, 0);
auto f = zeek::make_intrusive<zeek::detail::BroFunc>(id, nullptr, inits, 0, 0);
id->SetVal(zeek::make_intrusive<zeek::Val>(std::move(f)));
}
}
@ -644,7 +644,7 @@ TraversalCode OuterIDBindingFinder::PostExpr(const zeek::detail::Expr* expr)
void end_func(zeek::detail::StmtPtr body)
{
auto ingredients = std::make_unique<function_ingredients>(zeek::detail::pop_scope(),
auto ingredients = std::make_unique<zeek::detail::function_ingredients>(zeek::detail::pop_scope(),
std::move(body));
if ( ingredients->id->HasVal() )
@ -655,7 +655,7 @@ void end_func(zeek::detail::StmtPtr body)
ingredients->priority);
else
{
auto f = zeek::make_intrusive<BroFunc>(
auto f = zeek::make_intrusive<zeek::detail::BroFunc>(
ingredients->id,
ingredients->body,
ingredients->inits,
@ -781,7 +781,7 @@ zeek::Type* internal_type(const char* name)
return zeek::id::find_type(name).get();
}
Func* internal_func(const char* name)
zeek::detail::Func* internal_func(const char* name)
{
const auto& v = zeek::id::find_val(name);

View file

@ -86,7 +86,7 @@ extern zeek::ListVal* internal_list_val(const char* name);
extern zeek::Type* internal_type(const char* name);
[[deprecated("Remove in v4.1. Use zeek::id::find_func().")]]
extern Func* internal_func(const char* name);
extern zeek::detail::Func* internal_func(const char* name);
[[deprecated("Remove in v4.1. Use event_registry->Register().")]]
extern EventHandlerPtr internal_handler(const char* name);

View file

@ -213,7 +213,7 @@ function fmt_ftp_port%(a: addr, p: port%): string
}
else
{
builtin_error("conversion of non-IPv4 address in fmt_ftp_port",
zeek::emit_builtin_error("conversion of non-IPv4 address in fmt_ftp_port",
@ARG@[0]);
return val_mgr->EmptyString();
}

View file

@ -132,9 +132,9 @@ function get_contents_file%(cid: conn_id, direction: count%): file
// Return some sort of error value.
if ( ! c )
builtin_error("unknown connection id in get_contents_file()", cid);
zeek::emit_builtin_error("unknown connection id in get_contents_file()", cid);
else
builtin_error("no contents file for given direction");
zeek::emit_builtin_error("no contents file for given direction");
return zeek::make_intrusive<zeek::Val>(zeek::make_intrusive<BroFile>(stderr, "-", "w"));
%}

View file

@ -370,7 +370,7 @@ struct val_converter {
if ( ! frame )
return nullptr;
BroFunc* b = dynamic_cast<BroFunc*>(rval->AsFunc());
auto* b = dynamic_cast<zeek::detail::BroFunc*>(rval->AsFunc());
if ( ! b )
return nullptr;
@ -852,7 +852,7 @@ broker::expected<broker::data> bro_broker::val_to_data(const zeek::Val* v)
return {string(v->AsFile()->Name())};
case zeek::TYPE_FUNC:
{
const Func* f = v->AsFunc();
const zeek::detail::Func* f = v->AsFunc();
std::string name(f->Name());
broker::vector rval;
@ -861,7 +861,7 @@ broker::expected<broker::data> bro_broker::val_to_data(const zeek::Val* v)
if ( name.find("lambda_<") == 0 )
{
// Only BroFuncs have closures.
if ( auto b = dynamic_cast<const BroFunc*>(f) )
if ( auto b = dynamic_cast<const zeek::detail::BroFunc*>(f) )
{
auto bc = b->SerializeClosure();
if ( ! bc )

View file

@ -633,7 +633,7 @@ void Manager::Error(const char* format, ...)
va_end(args);
if ( script_scope )
builtin_error(msg);
zeek::emit_builtin_error(msg);
else
reporter->Error("%s", msg);
}
@ -704,7 +704,7 @@ zeek::RecordVal* Manager::MakeEvent(val_list* args, zeek::detail::Frame* frame)
auto rval = new zeek::RecordVal(zeek::BifType::Record::Broker::Event);
auto arg_vec = zeek::make_intrusive<zeek::VectorVal>(vector_of_data_type);
rval->Assign(1, arg_vec);
Func* func = nullptr;
zeek::detail::Func* func = nullptr;
scoped_reporter_location srl{frame};
for ( auto i = 0; i < args->length(); ++i )

View file

@ -21,10 +21,10 @@
#include "iosource/IOSource.h"
#include "logging/WriterBackend.h"
class Func;
ZEEK_FORWARD_DECLARE_NAMESPACED(Func, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(Frame, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(VectorType, zeek);
namespace zeek {
using VectorTypePtr = zeek::IntrusivePtr<zeek::VectorType>;
}
@ -400,7 +400,7 @@ private:
int peer_count;
size_t log_batch_size;
Func* log_topic_func;
zeek::detail::Func* log_topic_func;
zeek::VectorTypePtr vector_of_data_type;
zeek::EnumType* log_id_type;
zeek::EnumType* writer_id_type;

View file

@ -55,7 +55,7 @@ function Broker::__listen%(a: string, p: port%): port
if ( ! p->IsTCP() )
{
builtin_error("listen port must use tcp");
zeek::emit_builtin_error("listen port must use tcp");
return val_mgr->Port(0, TRANSPORT_UNKNOWN);
}
@ -69,7 +69,7 @@ function Broker::__peer%(a: string, p: port, retry: interval%): bool
if ( ! p->IsTCP() )
{
builtin_error("remote connection port must use tcp");
zeek::emit_builtin_error("remote connection port must use tcp");
return val_mgr->False();
}
@ -83,7 +83,7 @@ function Broker::__unpeer%(a: string, p: port%): bool
if ( ! p->IsTCP() )
{
builtin_error("remote connection port must use tcp");
zeek::emit_builtin_error("remote connection port must use tcp");
return val_mgr->False();
}

View file

@ -48,7 +48,7 @@ function Broker::__opaque_clone_through_serialization%(d: any%): any
if ( ! x )
{
builtin_error("cannot serialize object to clone");
zeek::emit_builtin_error("cannot serialize object to clone");
return val_mgr->False();
}
@ -83,7 +83,7 @@ function Broker::__set_contains%(s: Broker::Data, key: any%): bool
if ( ! k )
{
builtin_error("invalid Broker data conversion for key argument");
zeek::emit_builtin_error("invalid Broker data conversion for key argument");
return val_mgr->False();
}
@ -99,7 +99,7 @@ function Broker::__set_insert%(s: Broker::Data, key: any%): bool
if ( ! k )
{
builtin_error("invalid Broker data conversion for key argument");
zeek::emit_builtin_error("invalid Broker data conversion for key argument");
return val_mgr->False();
}
@ -114,7 +114,7 @@ function Broker::__set_remove%(s: Broker::Data, key: any%): bool
if ( ! k )
{
builtin_error("invalid Broker data conversion for key argument");
zeek::emit_builtin_error("invalid Broker data conversion for key argument");
return val_mgr->False();
}
@ -150,7 +150,7 @@ function Broker::__set_iterator_value%(it: opaque of Broker::SetIterator%): Brok
if ( set_it->it == set_it->dat.end() )
{
builtin_error("attempt to retrieve value of invalid set iterator");
zeek::emit_builtin_error("attempt to retrieve value of invalid set iterator");
return rval;
}
@ -187,7 +187,7 @@ function Broker::__table_contains%(t: Broker::Data, key: any%): bool
if ( ! k )
{
builtin_error("invalid Broker data conversion for key argument");
zeek::emit_builtin_error("invalid Broker data conversion for key argument");
return val_mgr->False();
}
@ -203,7 +203,7 @@ function Broker::__table_insert%(t: Broker::Data, key: any, val: any%): Broker::
if ( ! k )
{
builtin_error("invalid Broker data conversion for key argument");
zeek::emit_builtin_error("invalid Broker data conversion for key argument");
return zeek::make_intrusive<zeek::RecordVal>(zeek::BifType::Record::Broker::Data);
}
@ -211,7 +211,7 @@ function Broker::__table_insert%(t: Broker::Data, key: any, val: any%): Broker::
if ( ! v )
{
builtin_error("invalid Broker data conversion for value argument");
zeek::emit_builtin_error("invalid Broker data conversion for value argument");
return zeek::make_intrusive<zeek::RecordVal>(zeek::BifType::Record::Broker::Data);
}
@ -238,7 +238,7 @@ function Broker::__table_remove%(t: Broker::Data, key: any%): Broker::Data
if ( ! k )
{
builtin_error("invalid Broker data conversion for key argument");
zeek::emit_builtin_error("invalid Broker data conversion for key argument");
return zeek::make_intrusive<zeek::RecordVal>(zeek::BifType::Record::Broker::Data);
}
@ -263,7 +263,7 @@ function Broker::__table_lookup%(t: Broker::Data, key: any%): Broker::Data
if ( ! k )
{
builtin_error("invalid Broker data conversion for key argument");
zeek::emit_builtin_error("invalid Broker data conversion for key argument");
return zeek::make_intrusive<zeek::RecordVal>(zeek::BifType::Record::Broker::Data);
}
@ -308,7 +308,7 @@ function Broker::__table_iterator_value%(it: opaque of Broker::TableIterator%):
if ( ti->it == ti->dat.end() )
{
builtin_error("attempt to retrieve value of invalid table iterator");
zeek::emit_builtin_error("attempt to retrieve value of invalid table iterator");
return rval;
}
@ -345,7 +345,7 @@ function Broker::__vector_insert%(v: Broker::Data, idx:count, d: any%): bool
if ( ! item )
{
builtin_error("invalid Broker data conversion for item argument");
zeek::emit_builtin_error("invalid Broker data conversion for item argument");
return val_mgr->False();
}
@ -362,7 +362,7 @@ function Broker::__vector_replace%(v: Broker::Data, idx: count, d: any%): Broker
if ( ! item )
{
builtin_error("invalid Broker data conversion for item argument");
zeek::emit_builtin_error("invalid Broker data conversion for item argument");
return val_mgr->False();
}
@ -427,7 +427,7 @@ function Broker::__vector_iterator_value%(it: opaque of Broker::VectorIterator%)
if ( vi->it == vi->dat.end() )
{
builtin_error("attempt to retrieve value of invalid vector iterator");
zeek::emit_builtin_error("attempt to retrieve value of invalid vector iterator");
return rval;
}
@ -458,7 +458,7 @@ function Broker::__record_assign%(r: Broker::Data, idx: count, d: any%): bool
if ( ! item )
{
builtin_error("invalid Broker data conversion for item argument");
zeek::emit_builtin_error("invalid Broker data conversion for item argument");
return val_mgr->False();
}
@ -506,7 +506,7 @@ function Broker::__record_iterator_value%(it: opaque of Broker::RecordIterator%)
if ( ri->it == ri->dat.end() )
{
builtin_error("attempt to retrieve value of invalid record iterator");
zeek::emit_builtin_error("attempt to retrieve value of invalid record iterator");
return rval;
}

View file

@ -182,7 +182,7 @@ type Cluster::Pool: record;
## Returns: true if the message is sent.
function Cluster::publish_rr%(pool: Pool, key: string, ...%): bool
%{
static Func* topic_func = 0;
static zeek::detail::Func* topic_func = nullptr;
if ( ! topic_func )
topic_func = zeek::detail::global_scope()->Find("Cluster::rr_topic")->GetVal()->AsFunc();
@ -219,7 +219,7 @@ function Cluster::publish_rr%(pool: Pool, key: string, ...%): bool
## Returns: true if the message is sent.
function Cluster::publish_hrw%(pool: Pool, key: any, ...%): bool
%{
static Func* topic_func = 0;
static zeek::detail::Func* topic_func = nullptr;
if ( ! topic_func )
topic_func = zeek::detail::global_scope()->Find("Cluster::hrw_topic")->GetVal()->AsFunc();

View file

@ -52,7 +52,7 @@ function Broker::__create_master%(id: string, b: BackendType,
if ( ! store )
{
builtin_error(fmt("Could not create Broker master store '%s'", name));
zeek::emit_builtin_error(fmt("Could not create Broker master store '%s'", name));
return nullptr;
}
@ -77,7 +77,7 @@ function Broker::__create_clone%(id: string, resync_interval: interval,
if ( ! store )
{
builtin_error(fmt("Could not create clone of Broker store '%s'", name));
zeek::emit_builtin_error(fmt("Could not create clone of Broker store '%s'", name));
return nullptr;
}
@ -90,7 +90,7 @@ function Broker::__is_closed%(h: opaque of Broker::Store%): bool
if ( ! h )
{
builtin_error("invalid Broker store handle");
zeek::emit_builtin_error("invalid Broker store handle");
return val_mgr->False();
}
@ -104,7 +104,7 @@ function Broker::__close%(h: opaque of Broker::Store%): bool
if ( ! h )
{
builtin_error("invalid Broker store handle");
zeek::emit_builtin_error("invalid Broker store handle");
return val_mgr->False();
}
@ -116,7 +116,7 @@ function Broker::__store_name%(h: opaque of Broker::Store%): string
%{
if ( ! h )
{
builtin_error("invalid Broker store handle");
zeek::emit_builtin_error("invalid Broker store handle");
return val_mgr->EmptyString();
}
@ -129,7 +129,7 @@ function Broker::__exists%(h: opaque of Broker::Store,
%{
if ( ! h )
{
builtin_error("invalid Broker store handle");
zeek::emit_builtin_error("invalid Broker store handle");
return val_mgr->False();
}
@ -138,7 +138,7 @@ function Broker::__exists%(h: opaque of Broker::Store,
if ( ! key )
{
builtin_error("invalid Broker data conversion for key argument");
zeek::emit_builtin_error("invalid Broker data conversion for key argument");
return bro_broker::query_result();
}
@ -146,7 +146,7 @@ function Broker::__exists%(h: opaque of Broker::Store,
if ( ! trigger )
{
builtin_error("Broker queries can only be called inside when-condition");
zeek::emit_builtin_error("Broker queries can only be called inside when-condition");
return bro_broker::query_result();
}
@ -154,7 +154,7 @@ function Broker::__exists%(h: opaque of Broker::Store,
if ( timeout < 0 )
{
builtin_error("Broker queries must specify a timeout block");
zeek::emit_builtin_error("Broker queries must specify a timeout block");
return bro_broker::query_result();
}
@ -174,7 +174,7 @@ function Broker::__get%(h: opaque of Broker::Store,
%{
if ( ! h )
{
builtin_error("invalid Broker store handle");
zeek::emit_builtin_error("invalid Broker store handle");
return val_mgr->False();
}
@ -183,7 +183,7 @@ function Broker::__get%(h: opaque of Broker::Store,
if ( ! key )
{
builtin_error("invalid Broker data conversion for key argument");
zeek::emit_builtin_error("invalid Broker data conversion for key argument");
return bro_broker::query_result();
}
@ -191,7 +191,7 @@ function Broker::__get%(h: opaque of Broker::Store,
if ( ! trigger )
{
builtin_error("Broker queries can only be called inside when-condition");
zeek::emit_builtin_error("Broker queries can only be called inside when-condition");
return bro_broker::query_result();
}
@ -199,7 +199,7 @@ function Broker::__get%(h: opaque of Broker::Store,
if ( timeout < 0 )
{
builtin_error("Broker queries must specify a timeout block");
zeek::emit_builtin_error("Broker queries must specify a timeout block");
return bro_broker::query_result();
}
@ -219,7 +219,7 @@ function Broker::__put_unique%(h: opaque of Broker::Store,
%{
if ( ! h )
{
builtin_error("invalid Broker store handle");
zeek::emit_builtin_error("invalid Broker store handle");
return val_mgr->False();
}
@ -229,13 +229,13 @@ function Broker::__put_unique%(h: opaque of Broker::Store,
if ( ! key )
{
builtin_error("invalid Broker data conversion for key argument");
zeek::emit_builtin_error("invalid Broker data conversion for key argument");
return bro_broker::query_result();
}
if ( ! val )
{
builtin_error("invalid Broker data conversion for value argument");
zeek::emit_builtin_error("invalid Broker data conversion for value argument");
return bro_broker::query_result();
}
@ -243,7 +243,7 @@ function Broker::__put_unique%(h: opaque of Broker::Store,
if ( ! trigger )
{
builtin_error("Broker queries can only be called inside when-condition");
zeek::emit_builtin_error("Broker queries can only be called inside when-condition");
return bro_broker::query_result();
}
@ -251,7 +251,7 @@ function Broker::__put_unique%(h: opaque of Broker::Store,
if ( timeout < 0 )
{
builtin_error("Broker queries must specify a timeout block");
zeek::emit_builtin_error("Broker queries must specify a timeout block");
return bro_broker::query_result();
}
@ -273,7 +273,7 @@ function Broker::__get_index_from_value%(h: opaque of Broker::Store,
%{
if ( ! h )
{
builtin_error("invalid Broker store handle");
zeek::emit_builtin_error("invalid Broker store handle");
return val_mgr->False();
}
@ -282,7 +282,7 @@ function Broker::__get_index_from_value%(h: opaque of Broker::Store,
if ( ! key )
{
builtin_error("invalid Broker data conversion for key argument");
zeek::emit_builtin_error("invalid Broker data conversion for key argument");
return bro_broker::query_result();
}
@ -290,7 +290,7 @@ function Broker::__get_index_from_value%(h: opaque of Broker::Store,
if ( ! index )
{
builtin_error("invalid Broker data conversion for index argument");
zeek::emit_builtin_error("invalid Broker data conversion for index argument");
return bro_broker::query_result();
}
@ -298,7 +298,7 @@ function Broker::__get_index_from_value%(h: opaque of Broker::Store,
if ( ! trigger )
{
builtin_error("Broker queries can only be called inside when-condition");
zeek::emit_builtin_error("Broker queries can only be called inside when-condition");
return bro_broker::query_result();
}
@ -306,7 +306,7 @@ function Broker::__get_index_from_value%(h: opaque of Broker::Store,
if ( timeout < 0 )
{
builtin_error("Broker queries must specify a timeout block");
zeek::emit_builtin_error("Broker queries must specify a timeout block");
return bro_broker::query_result();
}
@ -326,7 +326,7 @@ function Broker::__keys%(h: opaque of Broker::Store%): Broker::QueryResult
%{
if ( ! h )
{
builtin_error("invalid Broker store handle");
zeek::emit_builtin_error("invalid Broker store handle");
return val_mgr->False();
}
@ -336,7 +336,7 @@ function Broker::__keys%(h: opaque of Broker::Store%): Broker::QueryResult
if ( ! trigger )
{
builtin_error("Broker queries can only be called inside when-condition");
zeek::emit_builtin_error("Broker queries can only be called inside when-condition");
return bro_broker::query_result();
}
@ -344,7 +344,7 @@ function Broker::__keys%(h: opaque of Broker::Store%): Broker::QueryResult
if ( timeout < 0 )
{
builtin_error("Broker queries must specify a timeout block");
zeek::emit_builtin_error("Broker queries must specify a timeout block");
return bro_broker::query_result();
}
@ -364,7 +364,7 @@ function Broker::__put%(h: opaque of Broker::Store,
%{
if ( ! h )
{
builtin_error("invalid Broker store handle");
zeek::emit_builtin_error("invalid Broker store handle");
return val_mgr->False();
}
@ -374,13 +374,13 @@ function Broker::__put%(h: opaque of Broker::Store,
if ( ! key )
{
builtin_error("invalid Broker data conversion for key argument");
zeek::emit_builtin_error("invalid Broker data conversion for key argument");
return val_mgr->False();
}
if ( ! val )
{
builtin_error("invalid Broker data conversion for value argument");
zeek::emit_builtin_error("invalid Broker data conversion for value argument");
return val_mgr->False();
}
@ -392,7 +392,7 @@ function Broker::__erase%(h: opaque of Broker::Store, k: any%): bool
%{
if ( ! h )
{
builtin_error("invalid Broker store handle");
zeek::emit_builtin_error("invalid Broker store handle");
return val_mgr->False();
}
@ -401,7 +401,7 @@ function Broker::__erase%(h: opaque of Broker::Store, k: any%): bool
if ( ! key )
{
builtin_error("invalid Broker data conversion for key argument");
zeek::emit_builtin_error("invalid Broker data conversion for key argument");
return val_mgr->False();
}
@ -414,7 +414,7 @@ function Broker::__increment%(h: opaque of Broker::Store, k: any, a: any,
%{
if ( ! h )
{
builtin_error("invalid Broker store handle");
zeek::emit_builtin_error("invalid Broker store handle");
return val_mgr->False();
}
@ -424,13 +424,13 @@ function Broker::__increment%(h: opaque of Broker::Store, k: any, a: any,
if ( ! key )
{
builtin_error("invalid Broker data conversion for key argument");
zeek::emit_builtin_error("invalid Broker data conversion for key argument");
return val_mgr->False();
}
if ( ! amount )
{
builtin_error("invalid Broker data conversion for amount argument");
zeek::emit_builtin_error("invalid Broker data conversion for amount argument");
return val_mgr->False();
}
@ -444,7 +444,7 @@ function Broker::__decrement%(h: opaque of Broker::Store, k: any, a: any,
%{
if ( ! h )
{
builtin_error("invalid Broker store handle");
zeek::emit_builtin_error("invalid Broker store handle");
return val_mgr->False();
}
@ -454,13 +454,13 @@ function Broker::__decrement%(h: opaque of Broker::Store, k: any, a: any,
if ( ! key )
{
builtin_error("invalid Broker data conversion for key argument");
zeek::emit_builtin_error("invalid Broker data conversion for key argument");
return val_mgr->False();
}
if ( ! amount )
{
builtin_error("invalid Broker data conversion for amount argument");
zeek::emit_builtin_error("invalid Broker data conversion for amount argument");
return val_mgr->False();
}
@ -473,7 +473,7 @@ function Broker::__append%(h: opaque of Broker::Store, k: any, s: any,
%{
if ( ! h )
{
builtin_error("invalid Broker store handle");
zeek::emit_builtin_error("invalid Broker store handle");
return val_mgr->False();
}
@ -483,13 +483,13 @@ function Broker::__append%(h: opaque of Broker::Store, k: any, s: any,
if ( ! key )
{
builtin_error("invalid Broker data conversion for key argument");
zeek::emit_builtin_error("invalid Broker data conversion for key argument");
return val_mgr->False();
}
if ( ! str )
{
builtin_error("invalid Broker data conversion for str argument");
zeek::emit_builtin_error("invalid Broker data conversion for str argument");
return val_mgr->False();
}
@ -502,7 +502,7 @@ function Broker::__insert_into_set%(h: opaque of Broker::Store, k: any, i: any,
%{
if ( ! h )
{
builtin_error("invalid Broker store handle");
zeek::emit_builtin_error("invalid Broker store handle");
return val_mgr->False();
}
@ -512,13 +512,13 @@ function Broker::__insert_into_set%(h: opaque of Broker::Store, k: any, i: any,
if ( ! key )
{
builtin_error("invalid Broker data conversion for key argument");
zeek::emit_builtin_error("invalid Broker data conversion for key argument");
return val_mgr->False();
}
if ( ! idx )
{
builtin_error("invalid Broker data conversion for index argument");
zeek::emit_builtin_error("invalid Broker data conversion for index argument");
return val_mgr->False();
}
@ -532,7 +532,7 @@ function Broker::__insert_into_table%(h: opaque of Broker::Store, k: any,
%{
if ( ! h )
{
builtin_error("invalid Broker store handle");
zeek::emit_builtin_error("invalid Broker store handle");
return val_mgr->False();
}
@ -543,19 +543,19 @@ function Broker::__insert_into_table%(h: opaque of Broker::Store, k: any,
if ( ! key )
{
builtin_error("invalid Broker data conversion for key argument");
zeek::emit_builtin_error("invalid Broker data conversion for key argument");
return val_mgr->False();
}
if ( ! idx )
{
builtin_error("invalid Broker data conversion for index argument");
zeek::emit_builtin_error("invalid Broker data conversion for index argument");
return val_mgr->False();
}
if ( ! val )
{
builtin_error("invalid Broker data conversion for value argument");
zeek::emit_builtin_error("invalid Broker data conversion for value argument");
return val_mgr->False();
}
@ -569,7 +569,7 @@ function Broker::__remove_from%(h: opaque of Broker::Store, k: any, i: any,
%{
if ( ! h )
{
builtin_error("invalid Broker store handle");
zeek::emit_builtin_error("invalid Broker store handle");
return val_mgr->False();
}
@ -579,13 +579,13 @@ function Broker::__remove_from%(h: opaque of Broker::Store, k: any, i: any,
if ( ! key )
{
builtin_error("invalid Broker data conversion for key argument");
zeek::emit_builtin_error("invalid Broker data conversion for key argument");
return val_mgr->False();
}
if ( ! idx )
{
builtin_error("invalid Broker data conversion for index argument");
zeek::emit_builtin_error("invalid Broker data conversion for index argument");
return val_mgr->False();
}
@ -599,7 +599,7 @@ function Broker::__push%(h: opaque of Broker::Store, k: any, v: any,
%{
if ( ! h )
{
builtin_error("invalid Broker store handle");
zeek::emit_builtin_error("invalid Broker store handle");
return val_mgr->False();
}
@ -609,13 +609,13 @@ function Broker::__push%(h: opaque of Broker::Store, k: any, v: any,
if ( ! key )
{
builtin_error("invalid Broker data conversion for key argument");
zeek::emit_builtin_error("invalid Broker data conversion for key argument");
return val_mgr->False();
}
if ( ! val )
{
builtin_error("invalid Broker data conversion for value argument");
zeek::emit_builtin_error("invalid Broker data conversion for value argument");
return val_mgr->False();
}
@ -627,7 +627,7 @@ function Broker::__pop%(h: opaque of Broker::Store, k: any, e: interval%): bool
%{
if ( ! h )
{
builtin_error("invalid Broker store handle");
zeek::emit_builtin_error("invalid Broker store handle");
return val_mgr->False();
}
@ -636,7 +636,7 @@ function Broker::__pop%(h: opaque of Broker::Store, k: any, e: interval%): bool
if ( ! key )
{
builtin_error("invalid Broker data conversion for key argument");
zeek::emit_builtin_error("invalid Broker data conversion for key argument");
return val_mgr->False();
}
@ -648,7 +648,7 @@ function Broker::__clear%(h: opaque of Broker::Store%): bool
%{
if ( ! h )
{
builtin_error("invalid Broker store handle");
zeek::emit_builtin_error("invalid Broker store handle");
return val_mgr->False();
}

View file

@ -260,7 +260,7 @@ X509_STORE* file_analysis::X509::GetRootStore(zeek::TableVal* root_certs)
::X509* x = d2i_X509(NULL, &data, sv->Len());
if ( ! x )
{
builtin_error(fmt("Root CA error: %s", ERR_error_string(ERR_get_error(), NULL)));
zeek::emit_builtin_error(fmt("Root CA error: %s", ERR_error_string(ERR_get_error(), NULL)));
return nullptr;
}

View file

@ -123,7 +123,7 @@ public:
/**
* Sets the callback when a certificate cache hit is encountered
*/
static void SetCertificateCacheHitCallback(FuncPtr func)
static void SetCertificateCacheHitCallback(zeek::detail::FuncPtr func)
{ cache_hit_callback = std::move(func); }
protected:
@ -142,7 +142,7 @@ private:
/** X509 stores associated with global script-layer values */
inline static std::map<zeek::Val*, X509_STORE*> x509_stores = std::map<zeek::Val*, X509_STORE*>();
inline static zeek::TableValPtr certificate_cache = nullptr;
inline static FuncPtr cache_hit_callback = nullptr;
inline static zeek::detail::FuncPtr cache_hit_callback = nullptr;
};
/**

View file

@ -29,7 +29,8 @@ STACK_OF(X509)* x509_get_untrusted_stack(zeek::VectorVal* certs_vec)
STACK_OF(X509)* untrusted_certs = sk_X509_new_null();
if ( ! untrusted_certs )
{
builtin_error(fmt("Untrusted certificate stack initialization error: %s", ERR_error_string(ERR_get_error(),NULL)));
zeek::emit_builtin_error(fmt("Untrusted certificate stack initialization error: %s",
ERR_error_string(ERR_get_error(),NULL)));
return 0;
}
@ -45,7 +46,7 @@ STACK_OF(X509)* x509_get_untrusted_stack(zeek::VectorVal* certs_vec)
if ( ! x )
{
sk_X509_free(untrusted_certs);
builtin_error(fmt("No certificate in opaque in stack"));
zeek::emit_builtin_error(fmt("No certificate in opaque in stack"));
return 0;
}
@ -233,7 +234,7 @@ function x509_ocsp_verify%(certs: x509_opaque_vector, ocsp_reply: string, root_c
const auto& sv = certs_vec->At(index);
if ( ! sv )
{
builtin_error("undefined value in certificate vector");
zeek::emit_builtin_error("undefined value in certificate vector");
return x509_result_record(-1, "undefined value in certificate vector");
}
@ -242,7 +243,7 @@ function x509_ocsp_verify%(certs: x509_opaque_vector, ocsp_reply: string, root_c
X509* cert = cert_handle->GetCertificate();
if ( ! cert )
{
builtin_error(fmt("No certificate in opaque"));
zeek::emit_builtin_error(fmt("No certificate in opaque"));
return x509_result_record(-1, "No certificate in opaque");
}
@ -519,7 +520,7 @@ function x509_verify%(certs: x509_opaque_vector, root_certs: table_string_of_str
const auto& sv = certs_vec->At(index);
if ( !sv )
{
builtin_error("undefined value in certificate vector");
zeek::emit_builtin_error("undefined value in certificate vector");
return x509_result_record(-1, "undefined value in certificate vector");
}
file_analysis::X509Val* cert_handle = (file_analysis::X509Val*) sv.get();
@ -527,7 +528,7 @@ function x509_verify%(certs: x509_opaque_vector, root_certs: table_string_of_str
X509* cert = cert_handle->GetCertificate();
if ( ! cert )
{
builtin_error(fmt("No certificate in opaque"));
zeek::emit_builtin_error(fmt("No certificate in opaque"));
return x509_result_record(-1, "No certificate in opaque");
}
@ -774,7 +775,7 @@ zeek::StringValPtr x509_entity_hash(file_analysis::X509Val *cert_handle, unsigne
X509 *cert_x509 = cert_handle->GetCertificate();
if ( cert_x509 == nullptr )
{
builtin_error("cannot get cert from opaque");
zeek::emit_builtin_error("cannot get cert from opaque");
return nullptr;
}
@ -782,14 +783,14 @@ zeek::StringValPtr x509_entity_hash(file_analysis::X509Val *cert_handle, unsigne
X509_NAME *issuer_name = X509_get_issuer_name(cert_x509);
if ( subject_name == nullptr || issuer_name == nullptr )
{
builtin_error("fail to get subject/issuer name from certificate");
zeek::emit_builtin_error("fail to get subject/issuer name from certificate");
return nullptr;
}
const EVP_MD *dgst = hash_to_evp(hash_alg);
if ( dgst == nullptr )
{
builtin_error("Unknown hash algorithm.");
zeek::emit_builtin_error("Unknown hash algorithm.");
return nullptr;
}
@ -809,7 +810,7 @@ zeek::StringValPtr x509_entity_hash(file_analysis::X509Val *cert_handle, unsigne
int pklen = i2d_X509_PUBKEY(X509_get_X509_PUBKEY(cert_x509), &spki);
if ( ! pklen )
{
builtin_error("Could not get SPKI");
zeek::emit_builtin_error("Could not get SPKI");
return nullptr;
}
res = EVP_Digest(spki, pklen, md, &len, dgst, nullptr);
@ -818,7 +819,7 @@ zeek::StringValPtr x509_entity_hash(file_analysis::X509Val *cert_handle, unsigne
if ( ! res )
{
builtin_error("Could not perform hash");
zeek::emit_builtin_error("Could not perform hash");
return nullptr;
}

View file

@ -102,7 +102,7 @@ public:
PDict<InputHash>* currDict;
PDict<InputHash>* lastDict;
Func* pred;
zeek::detail::Func* pred;
EventHandlerPtr event;
@ -320,7 +320,7 @@ bool Manager::CreateEventStream(zeek::RecordVal* fval)
auto want_record = fval->GetFieldOrDefault("want_record");
auto ev_val = fval->GetFieldOrDefault("ev");
Func* event = ev_val->AsFunc();
zeek::detail::Func* event = ev_val->AsFunc();
const auto& etype = event->GetType();
@ -409,7 +409,7 @@ bool Manager::CreateEventStream(zeek::RecordVal* fval)
assert(false);
auto error_event_val = fval->GetFieldOrDefault("error_ev");
Func* error_event = error_event_val ? error_event_val->AsFunc() : nullptr;
zeek::detail::Func* error_event = error_event_val ? error_event_val->AsFunc() : nullptr;
if ( ! CheckErrorEventTypes(stream_name, error_event, false) )
return false;
@ -545,7 +545,7 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval)
}
auto event_val = fval->GetFieldOrDefault("ev");
Func* event = event_val ? event_val->AsFunc() : nullptr;
zeek::detail::Func* event = event_val ? event_val->AsFunc() : nullptr;
if ( event )
{
@ -618,7 +618,7 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval)
}
auto error_event_val = fval->GetFieldOrDefault("error_ev");
Func* error_event = error_event_val ? error_event_val->AsFunc() : nullptr;
zeek::detail::Func* error_event = error_event_val ? error_event_val->AsFunc() : nullptr;
if ( ! CheckErrorEventTypes(stream_name, error_event, true) )
return false;
@ -691,7 +691,7 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval)
return true;
}
bool Manager::CheckErrorEventTypes(const std::string& stream_name, const Func* ev, bool table) const
bool Manager::CheckErrorEventTypes(const std::string& stream_name, const zeek::detail::Func* ev, bool table) const
{
if ( ev == nullptr )
return true;
@ -1756,7 +1756,7 @@ bool Manager::Delete(ReaderFrontend* reader, Value* *vals)
return success;
}
bool Manager::CallPred(Func* pred_func, const int numvals, ...) const
bool Manager::CallPred(zeek::detail::Func* pred_func, const int numvals, ...) const
{
bool result = false;
zeek::Args vl;

View file

@ -185,7 +185,7 @@ private:
// Check if the types of the error_ev event are correct. If table is
// true, check for tablestream type, otherwhise check for eventstream
// type.
bool CheckErrorEventTypes(const std::string& stream_name, const Func* error_event, bool table) const;
bool CheckErrorEventTypes(const std::string& stream_name, const zeek::detail::Func* error_event, bool table) const;
// SendEntry implementation for Table stream.
int SendEntryTable(Stream* i, const threading::Value* const *vals);
@ -209,7 +209,7 @@ private:
void SendEndOfData(const Stream *i);
// Call predicate function and return result.
bool CallPred(Func* pred_func, const int numvals, ...) const;
bool CallPred(zeek::detail::Func* pred_func, const int numvals, ...) const;
// Get a hashkey for a set of threading::Values.
HashKey* HashValues(const int num_elements, const threading::Value* const *vals) const;

View file

@ -33,7 +33,7 @@ function precompile_pcap_filter%(id: PcapFilterID, s: string%): bool
// We use a vector as underlying data structure for fast
// lookups and limit the ID space so that that doesn't grow too
// large.
builtin_error(fmt("PCAP filter ids must remain below 100 (is %" PRId64 ")", id->AsInt()));
zeek::emit_builtin_error(fmt("PCAP filter ids must remain below 100 (is %" PRId64 ")", id->AsInt()));
return val_mgr->False();
}

View file

@ -34,8 +34,8 @@ struct Manager::Filter {
zeek::Val* fval;
string name;
zeek::EnumVal* id;
Func* pred;
Func* path_func;
zeek::detail::Func* pred;
zeek::detail::Func* path_func;
string path;
zeek::Val* path_val;
zeek::EnumVal* writer;
@ -43,12 +43,12 @@ struct Manager::Filter {
zeek::TableVal* field_name_map;
string scope_sep;
string ext_prefix;
Func* ext_func;
zeek::detail::Func* ext_func;
int num_ext_fields;
bool local;
bool remote;
double interval;
Func* postprocessor;
zeek::detail::Func* postprocessor;
int num_fields;
threading::Field** fields;
@ -66,7 +66,7 @@ struct Manager::WriterInfo {
double open_time;
Timer* rotation_timer;
double interval;
Func* postprocessor;
zeek::detail::Func* postprocessor;
WriterFrontend* writer;
WriterBackend::WriterInfo* info;
bool from_remote;
@ -264,7 +264,7 @@ bool Manager::CreateStream(zeek::EnumVal* id, zeek::RecordVal* sval)
}
const auto& event_val = sval->GetField("ev");
Func* event = event_val ? event_val->AsFunc() : nullptr;
zeek::detail::Func* event = event_val ? event_val->AsFunc() : nullptr;
if ( event )
{
@ -997,7 +997,7 @@ threading::Value* Manager::ValToLogVal(zeek::Val* val, zeek::Type* ty)
case zeek::TYPE_FUNC:
{
ODesc d;
const Func* f = val->AsFunc();
const zeek::detail::Func* f = val->AsFunc();
f->Describe(&d);
const char* s = d.Description();
lval->val.string_val.data = copy_string(s);
@ -1517,7 +1517,7 @@ bool Manager::FinishedRotation(WriterFrontend* writer, const char* new_name, con
info->Assign(4, zeek::make_intrusive<zeek::TimeVal>(close));
info->Assign(5, val_mgr->Bool(terminating));
Func* func = winfo->postprocessor;
zeek::detail::Func* func = winfo->postprocessor;
if ( ! func )
{
const auto& id = zeek::detail::global_scope()->Find("Log::__default_rotation_postprocessor");

View file

@ -61,20 +61,20 @@ function Option::set%(ID: string, val: any, location: string &default=""%): bool
const auto& i = zeek::detail::global_scope()->Find(ID->CheckString());
if ( ! i )
{
builtin_error(fmt("Could not find ID named '%s'", ID->CheckString()));
zeek::emit_builtin_error(fmt("Could not find ID named '%s'", ID->CheckString()));
return val_mgr->False();
}
if ( ! i->HasVal() )
{
// should be impossible because initialization is enforced
builtin_error(fmt("ID '%s' has no value", ID->CheckString()));
zeek::emit_builtin_error(fmt("ID '%s' has no value", ID->CheckString()));
return val_mgr->False();
}
if ( ! i->IsOption() )
{
builtin_error(fmt("ID '%s' is not an option", ID->CheckString()));
zeek::emit_builtin_error(fmt("ID '%s' is not an option", ID->CheckString()));
return val_mgr->False();
}
@ -85,8 +85,9 @@ function Option::set%(ID: string, val: any, location: string &default=""%): bool
if ( ! val_from_data )
{
builtin_error(fmt("Incompatible type for set of ID '%s': got broker data '%s', need '%s'",
ID->CheckString(), dv->data.get_type_name(), type_name(i->GetType()->Tag())));
zeek::emit_builtin_error(fmt("Incompatible type for set of ID '%s': got broker data '%s', need '%s'",
ID->CheckString(), dv->data.get_type_name(),
type_name(i->GetType()->Tag())));
return val_mgr->False();
}
@ -108,8 +109,9 @@ function Option::set%(ID: string, val: any, location: string &default=""%): bool
return val_mgr->Bool(rval);
}
builtin_error(fmt("Incompatible type for set of ID '%s': got '%s', need '%s'",
ID->CheckString(), type_name(val->GetType()->Tag()), type_name(i->GetType()->Tag())));
zeek::emit_builtin_error(fmt("Incompatible type for set of ID '%s': got '%s', need '%s'",
ID->CheckString(), type_name(val->GetType()->Tag()),
type_name(i->GetType()->Tag())));
return val_mgr->False();
}
@ -146,62 +148,64 @@ function Option::set_change_handler%(ID: string, on_change: any, priority: int &
const auto& i = zeek::detail::global_scope()->Find(ID->CheckString());
if ( ! i )
{
builtin_error(fmt("Could not find ID named '%s'", ID->CheckString()));
zeek::emit_builtin_error(fmt("Could not find ID named '%s'", ID->CheckString()));
return val_mgr->False();
}
if ( ! i->IsOption() )
{
builtin_error(fmt("ID '%s' is not an option", ID->CheckString()));
zeek::emit_builtin_error(fmt("ID '%s' is not an option", ID->CheckString()));
return val_mgr->False();
}
if ( on_change->GetType()->Tag() != TYPE_FUNC )
{
builtin_error(fmt("Option::on_change needs function argument; got '%s' for ID '%s'",
zeek::emit_builtin_error(fmt("Option::on_change needs function argument; got '%s' for ID '%s'",
type_name(on_change->GetType()->Tag()), ID->CheckString()));
return val_mgr->False();
}
if ( on_change->GetType()->AsFuncType()->Flavor() != zeek::FUNC_FLAVOR_FUNCTION )
{
builtin_error("Option::on_change needs function argument; not hook or event");
zeek::emit_builtin_error("Option::on_change needs function argument; not hook or event");
return val_mgr->False();
}
const auto& args = on_change->GetType()->AsFuncType()->ParamList()->GetTypes();
if ( args.size() < 2 || args.size() > 3 )
{
builtin_error(fmt("Wrong number of arguments for passed function in Option::on_change for ID '%s'; expected 2 or 3, got %zu",
zeek::emit_builtin_error(fmt("Wrong number of arguments for passed function in Option::on_change for ID '%s'; expected 2 or 3, got %zu",
ID->CheckString(), args.size()));
return val_mgr->False();
}
if ( args[0]->Tag() != TYPE_STRING )
{
builtin_error(fmt("First argument of passed function has to be string in Option::on_change for ID '%s'; got '%s'",
zeek::emit_builtin_error(fmt("First argument of passed function has to be string in Option::on_change for ID '%s'; got '%s'",
ID->CheckString(), type_name(args[0]->Tag())));
return val_mgr->False();
}
if ( ! same_type(args[1], i->GetType()) )
{
builtin_error(fmt("Second argument of passed function has to be %s in Option::on_change for ID '%s'; got '%s'",
type_name(i->GetType()->Tag()), ID->CheckString(), type_name(args[1]->Tag())));
zeek::emit_builtin_error(fmt("Second argument of passed function has to be %s in Option::on_change for ID '%s'; got '%s'",
type_name(i->GetType()->Tag()), ID->CheckString(),
type_name(args[1]->Tag())));
return val_mgr->False();
}
if ( args.size() == 3 && args[2]->Tag() != TYPE_STRING )
{
builtin_error(fmt("Third argument of passed function has to be string in Option::on_change for ID '%s'; got '%s'",
zeek::emit_builtin_error(fmt("Third argument of passed function has to be string in Option::on_change for ID '%s'; got '%s'",
ID->CheckString(), type_name(args[2]->Tag())));
return val_mgr->False();
}
if ( ! same_type(on_change->GetType()->AsFuncType()->Yield(), i->GetType()) )
{
builtin_error(fmt("Passed function needs to return type '%s' for ID '%s'; got '%s'",
type_name(i->GetType()->Tag()), ID->CheckString(), type_name(on_change->GetType()->AsFuncType()->Yield()->Tag())));
zeek::emit_builtin_error(fmt("Passed function needs to return type '%s' for ID '%s'; got '%s'",
type_name(i->GetType()->Tag()), ID->CheckString(),
type_name(on_change->GetType()->AsFuncType()->Yield()->Tag())));
return val_mgr->False();
}

View file

@ -1260,7 +1260,9 @@ lambda_body:
// a lambda expression.
// Gather the ingredients for a BroFunc from the current scope
auto ingredients = std::make_unique<function_ingredients>(zeek::IntrusivePtr{zeek::NewRef{}, zeek::detail::current_scope()}, zeek::IntrusivePtr{zeek::AdoptRef{}, $3});
auto ingredients = std::make_unique<zeek::detail::function_ingredients>(
zeek::IntrusivePtr{zeek::NewRef{}, zeek::detail::current_scope()},
zeek::IntrusivePtr{zeek::AdoptRef{}, $3});
id_list outer_ids = gather_outer_ids(zeek::detail::pop_scope().get(), ingredients->body.get());
$$ = new zeek::detail::LambdaExpr(std::move(ingredients), std::move(outer_ids));

View file

@ -617,7 +617,7 @@ int Manager::HookLoadFile(const Plugin::LoadType type, const string& file, const
}
std::pair<bool, zeek::ValPtr>
Manager::HookCallFunction(const Func* func, zeek::detail::Frame* parent,
Manager::HookCallFunction(const zeek::detail::Func* func, zeek::detail::Frame* parent,
zeek::Args* vecargs) const
{
HookArgumentList args;

View file

@ -256,7 +256,7 @@ public:
* the method returns null.
*/
std::pair<bool, ValPtr>
HookCallFunction(const Func* func, zeek::detail::Frame* parent, zeek::Args* args) const;
HookCallFunction(const zeek::detail::Func* func, zeek::detail::Frame* parent, zeek::Args* args) const;
/**
* Hook that filters the queuing of an event.

View file

@ -376,7 +376,7 @@ int Plugin::HookLoadFile(const LoadType type, const std::string& file, const std
}
std::pair<bool, zeek::ValPtr>
Plugin::HookFunctionCall(const Func* func, zeek::detail::Frame* parent,
Plugin::HookFunctionCall(const zeek::detail::Func* func, zeek::detail::Frame* parent,
zeek::Args* args)
{
val_list vlargs(args->size());
@ -396,7 +396,7 @@ Plugin::HookFunctionCall(const Func* func, zeek::detail::Frame* parent,
}
std::pair<bool, zeek::Val*> Plugin::HookCallFunction(
const Func* func, zeek::detail::Frame *parent, val_list* args)
const zeek::detail::Func* func, zeek::detail::Frame *parent, val_list* args)
{
std::pair<bool, zeek::Val*> result(false, NULL);
return result;

View file

@ -17,9 +17,9 @@
#define BRO_PLUGIN_BRO_VERSION BRO_VERSION_FUNCTION
class ODesc;
class Func;
class Event;
ZEEK_FORWARD_DECLARE_NAMESPACED(Func, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(Frame, zeek::detail);
namespace zeek {
@ -201,7 +201,7 @@ public:
/**
* Constructor with a function argument.
*/
explicit HookArgument(const Func* a) { type = FUNC; arg.func = a; }
explicit HookArgument(const zeek::detail::Func* a) { type = FUNC; arg.func = a; }
/**
* Constructor with an integer argument.
@ -286,7 +286,7 @@ public:
* Returns the value for a function argument. The argument's type must
* match accordingly.
*/
const Func* AsFunc() const { assert(type == FUNC); return arg.func; }
const zeek::detail::Func* AsFunc() const { assert(type == FUNC); return arg.func; }
/**
* Returns the value for an integer argument. The argument's type must
@ -366,7 +366,7 @@ private:
double double_;
const Event* event;
const Connection* conn;
const Func* func;
const zeek::detail::Func* func;
const zeek::detail::Frame* frame;
int int_;
const Val* val;
@ -674,10 +674,10 @@ protected:
* pair with the first member set to 'false' and null result value.
*/
virtual std::pair<bool, ValPtr>
HookFunctionCall(const Func* func, zeek::detail::Frame* parent, zeek::Args* args);
HookFunctionCall(const zeek::detail::Func* func, zeek::detail::Frame* parent, zeek::Args* args);
[[deprecated("Remove in v4.1. Use HookFunctionCall()")]]
virtual std::pair<bool, Val*> HookCallFunction(const Func* func, zeek::detail::Frame *parent, val_list* args);
virtual std::pair<bool, Val*> HookCallFunction(const zeek::detail::Func* func, zeek::detail::Frame *parent, val_list* args);
/**
* Hook into raising events. Whenever the script interpreter is about

View file

@ -138,7 +138,7 @@ function join_string_vec%(vec: string_vec, sep: string%): string
function edit%(arg_s: string, arg_edit_char: string%): string
%{
if ( arg_edit_char->Len() != 1 )
builtin_error("not exactly one edit character", @ARG@[1]);
zeek::emit_builtin_error("not exactly one edit character", @ARG@[1]);
const u_char* s = arg_s->Bytes();
const u_char* edit_s = arg_edit_char->Bytes();

View file

@ -23,7 +23,7 @@ function Supervisor::__status%(node: string%): Supervisor::Status
%{
if ( ! zeek::supervisor_mgr )
{
builtin_error("supervisor mode not enabled");
zeek::emit_builtin_error("supervisor mode not enabled");
return zeek::make_intrusive<zeek::RecordVal>(zeek::BifType::Record::Supervisor::Status);
}
@ -34,7 +34,7 @@ function Supervisor::__create%(node: Supervisor::NodeConfig%): string
%{
if ( ! zeek::supervisor_mgr )
{
builtin_error("supervisor mode not enabled");
zeek::emit_builtin_error("supervisor mode not enabled");
return zeek::make_intrusive<zeek::StringVal>("supervisor mode not enabled");
}
@ -46,7 +46,7 @@ function Supervisor::__destroy%(node: string%): bool
%{
if ( ! zeek::supervisor_mgr )
{
builtin_error("supervisor mode not enabled");
zeek::emit_builtin_error("supervisor mode not enabled");
return val_mgr->Bool(false);
}
@ -58,7 +58,7 @@ function Supervisor::__restart%(node: string%): bool
%{
if ( ! zeek::supervisor_mgr )
{
builtin_error("supervisor mode not enabled");
zeek::emit_builtin_error("supervisor mode not enabled");
return val_mgr->Bool(false);
}
@ -83,7 +83,7 @@ function Supervisor::__node%(%): Supervisor::NodeConfig
%{
if ( ! zeek::Supervisor::ThisNode() )
{
builtin_error("not a supervised process");
zeek::emit_builtin_error("not a supervised process");
const auto& rt = zeek::BifType::Record::Supervisor::NodeConfig;
auto rval = zeek::make_intrusive<zeek::RecordVal>(rt);
rval->Assign<zeek::StringVal>(rt->FieldOffset("name"), "<invalid>");
@ -107,6 +107,6 @@ function Supervisor::__stem_pid%(%): int
if ( zeek::Supervisor::ThisNode() )
return val_mgr->Int(zeek::Supervisor::ThisNode()->parent_pid);
builtin_error("supervisor mode not enabled and not a supervised node");
zeek::emit_builtin_error("supervisor mode not enabled and not a supervised node");
return val_mgr->Int(-1);
%}

View file

@ -104,7 +104,7 @@ static void do_fmt(const char*& fmt, zeek::Val* v, ODesc* d)
if ( field_width > 128 || precision > 128 )
{
builtin_error("excessive field width or precision");
zeek::emit_builtin_error("excessive field width or precision");
return;
}
@ -130,7 +130,7 @@ static void do_fmt(const char*& fmt, zeek::Val* v, ODesc* d)
s.SetStyle(RAW_STYLE);
if ( precision >= 0 && *fmt != 'e' && *fmt != 'f' && *fmt != 'g' )
builtin_error("precision specified for non-floating point");
zeek::emit_builtin_error("precision specified for non-floating point");
switch ( *fmt ) {
case 'D':
@ -138,7 +138,7 @@ static void do_fmt(const char*& fmt, zeek::Val* v, ODesc* d)
{
if ( t != zeek::TYPE_TIME )
{
builtin_error("bad type for Date/Time format", v);
zeek::emit_builtin_error("bad type for Date/Time format", v);
break;
}
@ -190,7 +190,7 @@ static void do_fmt(const char*& fmt, zeek::Val* v, ODesc* d)
else if ( ! check_fmt_type(t, ok_d_fmt) )
{
builtin_error("bad type for %d/%x format", v);
zeek::emit_builtin_error("bad type for %d/%x format", v);
break;
}
@ -233,7 +233,7 @@ static void do_fmt(const char*& fmt, zeek::Val* v, ODesc* d)
{
if ( ! check_fmt_type(t, ok_f_fmt) )
{
builtin_error("bad type for floating-point format", v);
zeek::emit_builtin_error("bad type for floating-point format", v);
break;
}
@ -244,7 +244,7 @@ static void do_fmt(const char*& fmt, zeek::Val* v, ODesc* d)
break;
default:
builtin_error("bad format");
zeek::emit_builtin_error("bad format");
}
// Left-padding with whitespace, if any.
@ -411,7 +411,7 @@ static bool prepare_environment(zeek::TableVal* tbl, bool set)
if ( key->GetType()->Tag() != zeek::TYPE_STRING ||
val->GetType()->Tag() != zeek::TYPE_STRING )
{
builtin_error("system_env() needs a table[string] of string");
zeek::emit_builtin_error("system_env() needs a table[string] of string");
return false;
}
@ -489,7 +489,7 @@ function system_env%(str: string, env: table_string_of_string%): int
%{
if ( env->GetType()->Tag() != zeek::TYPE_TABLE )
{
builtin_error("system_env() requires a table argument");
zeek::emit_builtin_error("system_env() requires a table argument");
return val_mgr->Int(-1);
}
@ -1159,7 +1159,7 @@ function clear_table%(v: any%): any
if ( v->GetType()->Tag() == zeek::TYPE_TABLE )
v->AsTableVal()->RemoveAll();
else
builtin_error("clear_table() requires a table/set argument");
zeek::emit_builtin_error("clear_table() requires a table/set argument");
return nullptr;
%}
@ -1265,7 +1265,7 @@ function resize%(aggr: any, newsize: count%) : count
%{
if ( aggr->GetType()->Tag() != zeek::TYPE_VECTOR )
{
builtin_error("resize() operates on vectors");
zeek::emit_builtin_error("resize() operates on vectors");
return nullptr;
}
@ -1285,7 +1285,7 @@ function any_set%(v: any%) : bool
if ( v->GetType()->Tag() != zeek::TYPE_VECTOR ||
v->GetType()->Yield()->Tag() != zeek::TYPE_BOOL )
{
builtin_error("any_set() requires vector of bool");
zeek::emit_builtin_error("any_set() requires vector of bool");
return val_mgr->False();
}
@ -1314,7 +1314,7 @@ function all_set%(v: any%) : bool
if ( v->GetType()->Tag() != zeek::TYPE_VECTOR ||
v->GetType()->Yield()->Tag() != zeek::TYPE_BOOL )
{
builtin_error("all_set() requires vector of bool");
zeek::emit_builtin_error("all_set() requires vector of bool");
return val_mgr->False();
}
@ -1327,7 +1327,7 @@ function all_set%(v: any%) : bool
%}
%%{
static Func* sort_function_comp = nullptr;
static zeek::detail::Func* sort_function_comp = nullptr;
static std::vector<const zeek::ValPtr*> index_map; // used for indirect sorting to support order()
bool sort_function(const zeek::ValPtr& a, const zeek::ValPtr& b)
@ -1405,22 +1405,22 @@ function sort%(v: any, ...%) : any
if ( v->GetType()->Tag() != zeek::TYPE_VECTOR )
{
builtin_error("sort() requires vector");
zeek::emit_builtin_error("sort() requires vector");
return rval;
}
const auto& elt_type = v->GetType()->Yield();
Func* comp = 0;
zeek::detail::Func* comp = nullptr;
if ( @ARG@.size() > 2 )
builtin_error("sort() called with extraneous argument");
zeek::emit_builtin_error("sort() called with extraneous argument");
if ( @ARG@.size() == 2 )
{
Val* comp_val = @ARG@[1].get();
if ( ! IsFunc(comp_val->GetType()->Tag()) )
{
builtin_error("second argument to sort() needs to be comparison function");
zeek::emit_builtin_error("second argument to sort() needs to be comparison function");
return rval;
}
@ -1428,7 +1428,7 @@ function sort%(v: any, ...%) : any
}
if ( ! comp && ! IsIntegral(elt_type->Tag()) )
builtin_error("comparison function required for sort() with non-integral types");
zeek::emit_builtin_error("comparison function required for sort() with non-integral types");
auto& vv = *v->AsVector();
@ -1439,7 +1439,7 @@ function sort%(v: any, ...%) : any
if ( comp_type->Yield()->Tag() != zeek::TYPE_INT ||
! comp_type->ParamList()->AllMatch(elt_type, 0) )
{
builtin_error("invalid comparison function in call to sort()");
zeek::emit_builtin_error("invalid comparison function in call to sort()");
return rval;
}
@ -1475,22 +1475,22 @@ function order%(v: any, ...%) : index_vec
if ( v->GetType()->Tag() != zeek::TYPE_VECTOR )
{
builtin_error("order() requires vector");
zeek::emit_builtin_error("order() requires vector");
return result_v;
}
const auto& elt_type = v->GetType()->Yield();
Func* comp = 0;
zeek::detail::Func* comp = nullptr;
if ( @ARG@.size() > 2 )
builtin_error("order() called with extraneous argument");
zeek::emit_builtin_error("order() called with extraneous argument");
if ( @ARG@.size() == 2 )
{
Val* comp_val = @ARG@[1].get();
if ( ! IsFunc(comp_val->GetType()->Tag()) )
{
builtin_error("second argument to order() needs to be comparison function");
zeek::emit_builtin_error("second argument to order() needs to be comparison function");
return zeek::ValPtr{zeek::NewRef{}, v};
}
@ -1498,7 +1498,7 @@ function order%(v: any, ...%) : index_vec
}
if ( ! comp && ! IsIntegral(elt_type->Tag()) )
builtin_error("comparison function required for order() with non-integral types");
zeek::emit_builtin_error("comparison function required for order() with non-integral types");
auto& vv = *v->AsVector();
auto n = vv.size();
@ -1520,7 +1520,7 @@ function order%(v: any, ...%) : index_vec
if ( comp_type->Yield()->Tag() != zeek::TYPE_INT ||
! comp_type->ParamList()->AllMatch(elt_type, 0) )
{
builtin_error("invalid comparison function in call to order()");
zeek::emit_builtin_error("invalid comparison function in call to order()");
return zeek::ValPtr{zeek::NewRef{}, v};
}
@ -1674,13 +1674,13 @@ function fmt%(...%): string
if ( n < static_cast<int>(@ARGC@) - 1 )
{
builtin_error("too many arguments for format", fmt_v);
zeek::emit_builtin_error("too many arguments for format", fmt_v);
return val_mgr->EmptyString();
}
else if ( n >= static_cast<int>(@ARGC@) )
{
builtin_error("too few arguments for format", fmt_v);
zeek::emit_builtin_error("too few arguments for format", fmt_v);
return val_mgr->EmptyString();
}
@ -2252,7 +2252,7 @@ function counts_to_addr%(v: index_vec%): addr
}
else
{
builtin_error("invalid vector size", @ARG@[0]);
zeek::emit_builtin_error("invalid vector size", @ARG@[0]);
uint32_t bytes[4];
memset(bytes, 0, sizeof(bytes));
return zeek::make_intrusive<zeek::AddrVal>(bytes);
@ -2268,7 +2268,7 @@ function enum_to_int%(e: any%): int
%{
if ( e->GetType()->Tag() != zeek::TYPE_ENUM )
{
builtin_error("enum_to_int() requires enum value");
zeek::emit_builtin_error("enum_to_int() requires enum value");
return val_mgr->Int(-1);
}
@ -2293,7 +2293,7 @@ function to_int%(str: string%): int
// Not clear we should complain. For example, is " 205 "
// a legal conversion?
if ( s[0] == '\0' || end_s[0] != '\0' )
builtin_error("bad conversion to integer", @ARG@[0]);
zeek::emit_builtin_error("bad conversion to integer", @ARG@[0]);
#endif
return val_mgr->Int(i);
@ -2309,7 +2309,7 @@ function int_to_count%(n: int%): count
%{
if ( n < 0 )
{
builtin_error("bad conversion to count", @ARG@[0]);
zeek::emit_builtin_error("bad conversion to count", @ARG@[0]);
n = 0;
}
return val_mgr->Count(n);
@ -2325,7 +2325,7 @@ function int_to_count%(n: int%): count
function double_to_count%(d: double%): count
%{
if ( d < 0.0 )
builtin_error("bad conversion to count", @ARG@[0]);
zeek::emit_builtin_error("bad conversion to count", @ARG@[0]);
return val_mgr->Count(bro_uint_t(rint(d)));
%}
@ -2347,7 +2347,7 @@ function to_count%(str: string%): count
if ( s[0] == '\0' || end_s[0] != '\0' )
{
builtin_error("bad conversion to count", @ARG@[0]);
zeek::emit_builtin_error("bad conversion to count", @ARG@[0]);
u = 0;
}
@ -2448,7 +2448,7 @@ function to_addr%(ip: string%): addr
else
{
ret = zeek::make_intrusive<zeek::AddrVal>(IPAddr());
builtin_error("failed converting string to IP address", ip);
zeek::emit_builtin_error("failed converting string to IP address", ip);
}
delete [] s;
@ -2483,7 +2483,7 @@ function to_subnet%(sn: string%): subnet
IPPrefix tmp;
if ( ! IPPrefix::ConvertString(s, &tmp) )
builtin_error("failed converting string to IP prefix", sn);
zeek::emit_builtin_error("failed converting string to IP prefix", sn);
auto ret = zeek::make_intrusive<zeek::SubNetVal>(tmp);
delete [] s;
@ -2544,7 +2544,7 @@ function to_double%(str: string%): double
if ( s[0] == '\0' || end_s[0] != '\0' )
{
builtin_error("bad conversion to double", @ARG@[0]);
zeek::emit_builtin_error("bad conversion to double", @ARG@[0]);
d = 0;
}
@ -2562,7 +2562,7 @@ function count_to_v4_addr%(ip: count%): addr
%{
if ( ip > 4294967295LU )
{
builtin_error("conversion of non-IPv4 count to addr", @ARG@[0]);
zeek::emit_builtin_error("conversion of non-IPv4 count to addr", @ARG@[0]);
return zeek::make_intrusive<zeek::AddrVal>(uint32_t(0));
}
@ -2583,7 +2583,7 @@ function raw_bytes_to_v4_addr%(b: string%): addr
uint32_t a = 0;
if ( b->Len() < 4 )
builtin_error("too short a string as input to raw_bytes_to_v4_addr()");
zeek::emit_builtin_error("too short a string as input to raw_bytes_to_v4_addr()");
else
{
@ -2621,7 +2621,7 @@ function to_port%(s: string%): port
}
}
builtin_error("wrong port format, must be /[0-9]{1,5}\\/(tcp|udp|icmp)/");
zeek::emit_builtin_error("wrong port format, must be /[0-9]{1,5}\\/(tcp|udp|icmp)/");
return val_mgr->Port(port, TRANSPORT_UNKNOWN);
%}
@ -2636,7 +2636,7 @@ function bytestring_to_double%(s: string%): double
%{
if ( s->Len() != sizeof(double) )
{
builtin_error("bad conversion to double");
zeek::emit_builtin_error("bad conversion to double");
return zeek::make_intrusive<zeek::DoubleVal>(0.0);
}
@ -2733,7 +2733,7 @@ function bytestring_to_count%(s: string, is_le: bool &default=F%): count
}
}
builtin_error("unsupported byte length for bytestring_to_count");
zeek::emit_builtin_error("unsupported byte length for bytestring_to_count");
return val_mgr->Count(0);
%}
@ -2758,7 +2758,7 @@ function ptr_name_to_addr%(s: string%): addr
a, a+1, a+2, a+3, ss) != 5
|| strcmp(ss, "in-addr.arpa") != 0 )
{
builtin_error("bad PTR name", @ARG@[0]);
zeek::emit_builtin_error("bad PTR name", @ARG@[0]);
addr = 0;
}
else
@ -2782,7 +2782,7 @@ function ptr_name_to_addr%(s: string%): addr
b+7, b+6, b+5, b+4, b+3, b+2, b+1, b, ss) != 33
|| strcmp(ss, "ip6.arpa") != 0 )
{
builtin_error("bad PTR name", @ARG@[0]);
zeek::emit_builtin_error("bad PTR name", @ARG@[0]);
memset(addr6, 0, sizeof addr6);
}
else
@ -2946,7 +2946,7 @@ function decode_base64_conn%(cid: conn_id, s: string, a: string &default=""%): s
Connection* conn = sessions->FindConnection(cid);
if ( ! conn )
{
builtin_error("connection ID not a known connection", cid);
zeek::emit_builtin_error("connection ID not a known connection", cid);
return val_mgr->EmptyString();
}
@ -3247,7 +3247,7 @@ function get_conn_transport_proto%(cid: conn_id%): transport_proto
Connection* c = sessions->FindConnection(cid);
if ( ! c )
{
builtin_error("unknown connection id in get_conn_transport_proto()", cid);
zeek::emit_builtin_error("unknown connection id in get_conn_transport_proto()", cid);
return zeek::id::transport_proto->GetVal(0);
}
@ -3297,7 +3297,7 @@ function lookup_connection%(cid: conn_id%): connection
if ( conn )
return conn->ConnVal();
builtin_error("connection ID not a known connection", cid);
zeek::emit_builtin_error("connection ID not a known connection", cid);
// Return a dummy connection record.
auto c = zeek::make_intrusive<zeek::RecordVal>(zeek::id::connection);
@ -3554,7 +3554,7 @@ function lookup_addr%(host: addr%) : string
if ( ! trigger)
{
builtin_error("lookup_addr() can only be called inside a when-condition");
zeek::emit_builtin_error("lookup_addr() can only be called inside a when-condition");
return zeek::make_intrusive<zeek::StringVal>("<error>");
}
@ -3583,7 +3583,7 @@ function lookup_hostname_txt%(host: string%) : string
if ( ! trigger)
{
builtin_error("lookup_hostname_txt() can only be called inside a when-condition");
zeek::emit_builtin_error("lookup_hostname_txt() can only be called inside a when-condition");
return zeek::make_intrusive<zeek::StringVal>("<error>");
}
@ -3612,7 +3612,7 @@ function lookup_hostname%(host: string%) : addr_set
if ( ! trigger)
{
builtin_error("lookup_hostname() can only be called inside a when-condition");
zeek::emit_builtin_error("lookup_hostname() can only be called inside a when-condition");
return zeek::make_intrusive<zeek::StringVal>("<error>");
}
@ -4009,7 +4009,7 @@ function lookup_location%(a: addr%) : geo_location
if ( ! did_mmdb_loc_db_error )
{
did_mmdb_loc_db_error = true;
builtin_error("Failed to open GeoIP location database");
zeek::emit_builtin_error("Failed to open GeoIP location database");
}
return location;
@ -4061,7 +4061,7 @@ function lookup_location%(a: addr%) : geo_location
if ( ! missing_geoip_reported )
{
builtin_error("Zeek was not configured for GeoIP support");
zeek::emit_builtin_error("Zeek was not configured for GeoIP support");
missing_geoip_reported = 1;
}
#endif
@ -4092,7 +4092,7 @@ function lookup_asn%(a: addr%) : count
if ( ! did_mmdb_asn_db_error )
{
did_mmdb_asn_db_error = true;
builtin_error("Failed to open GeoIP ASN database");
zeek::emit_builtin_error("Failed to open GeoIP ASN database");
}
return val_mgr->Count(0);
@ -4118,7 +4118,7 @@ function lookup_asn%(a: addr%) : count
if ( ! missing_geoip_reported )
{
builtin_error("Zeek was not configured for GeoIP ASN support");
zeek::emit_builtin_error("Zeek was not configured for GeoIP ASN support");
missing_geoip_reported = 1;
}
#endif
@ -4503,7 +4503,7 @@ function mkdir%(f: string%): bool
&& S_ISDIR(filestat.st_mode) )
return val_mgr->True();
builtin_error(fmt("cannot create directory '%s': %s", filename,
zeek::emit_builtin_error(fmt("cannot create directory '%s': %s", filename,
strerror(error)));
return val_mgr->False();
}
@ -4528,7 +4528,7 @@ function rmdir%(d: string%): bool
if ( rmdir(dirname) < 0 )
{
builtin_error(fmt("cannot remove directory '%s': %s", dirname,
zeek::emit_builtin_error(fmt("cannot remove directory '%s': %s", dirname,
strerror(errno)));
return val_mgr->False();
}
@ -4552,7 +4552,7 @@ function unlink%(f: string%): bool
if ( unlink(filename) < 0 )
{
builtin_error(fmt("cannot unlink file '%s': %s", filename,
zeek::emit_builtin_error(fmt("cannot unlink file '%s': %s", filename,
strerror(errno)));
return val_mgr->False();
}
@ -4578,7 +4578,7 @@ function rename%(src_f: string, dst_f: string%): bool
if ( rename(src_filename, dst_filename) < 0 )
{
builtin_error(fmt("cannot rename file '%s' to '%s': %s", src_filename,
zeek::emit_builtin_error(fmt("cannot rename file '%s' to '%s': %s", src_filename,
dst_filename, strerror(errno)));
return val_mgr->False();
}
@ -5028,7 +5028,7 @@ function preserve_prefix%(a: addr, width: count%): any
if ( ip_anon )
{
if ( a->AsAddr().GetFamily() == IPv6 )
builtin_error("preserve_prefix() not supported for IPv6 addresses");
zeek::emit_builtin_error("preserve_prefix() not supported for IPv6 addresses");
else
{
const uint32_t* bytes;
@ -5054,7 +5054,7 @@ function preserve_subnet%(a: subnet%): any
if ( ip_anon )
{
if ( a->AsSubNet().Prefix().GetFamily() == IPv6 )
builtin_error("preserve_subnet() not supported for IPv6 addresses");
zeek::emit_builtin_error("preserve_subnet() not supported for IPv6 addresses");
else
{
const uint32_t* bytes;
@ -5087,11 +5087,11 @@ function anonymize_addr%(a: addr, cl: IPAddrAnonymizationClass%): addr
%{
int anon_class = cl->InternalInt();
if ( anon_class < 0 || anon_class >= zeek::detail::NUM_ADDR_ANONYMIZATION_CLASSES )
builtin_error("anonymize_addr(): invalid ip addr anonymization class");
zeek::emit_builtin_error("anonymize_addr(): invalid ip addr anonymization class");
if ( a->AsAddr().GetFamily() == IPv6 )
{
builtin_error("anonymize_addr() not supported for IPv6 addresses");
zeek::emit_builtin_error("anonymize_addr() not supported for IPv6 addresses");
return nullptr;
}
else