mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 07:38:19 +00:00
Reformat Zeek in Spicy style
This largely copies over Spicy's `.clang-format` configuration file. The one place where we deviate is header include order since Zeek depends on headers being included in a certain order.
This commit is contained in:
parent
7b8e7ed72c
commit
f5a76c1aed
786 changed files with 131714 additions and 153609 deletions
|
@ -8,81 +8,72 @@
|
|||
#include <zeek/Val.h>
|
||||
#include <zeek/threading/Formatter.h>
|
||||
|
||||
namespace btest::plugin::Demo_Hooks
|
||||
{
|
||||
namespace btest::plugin::Demo_Hooks {
|
||||
Plugin plugin;
|
||||
}
|
||||
}
|
||||
|
||||
using namespace btest::plugin::Demo_Hooks;
|
||||
|
||||
zeek::plugin::Configuration Plugin::Configure()
|
||||
{
|
||||
EnableHook(zeek::plugin::HOOK_CALL_FUNCTION);
|
||||
EnableHook(zeek::plugin::META_HOOK_PRE);
|
||||
EnableHook(zeek::plugin::META_HOOK_POST);
|
||||
zeek::plugin::Configuration Plugin::Configure() {
|
||||
EnableHook(zeek::plugin::HOOK_CALL_FUNCTION);
|
||||
EnableHook(zeek::plugin::META_HOOK_PRE);
|
||||
EnableHook(zeek::plugin::META_HOOK_POST);
|
||||
|
||||
zeek::plugin::Configuration config;
|
||||
config.name = "Demo::Hooks";
|
||||
config.description = "Exercises all plugin hooks";
|
||||
config.version.major = 1;
|
||||
config.version.minor = 0;
|
||||
config.version.patch = 0;
|
||||
return config;
|
||||
}
|
||||
zeek::plugin::Configuration config;
|
||||
config.name = "Demo::Hooks";
|
||||
config.description = "Exercises all plugin hooks";
|
||||
config.version.major = 1;
|
||||
config.version.minor = 0;
|
||||
config.version.patch = 0;
|
||||
return config;
|
||||
}
|
||||
|
||||
static void describe_hook_args(const zeek::plugin::HookArgumentList& args, zeek::ODesc* d)
|
||||
{
|
||||
bool first = true;
|
||||
static void describe_hook_args(const zeek::plugin::HookArgumentList& args, zeek::ODesc* d) {
|
||||
bool first = true;
|
||||
|
||||
for ( const auto& arg : args )
|
||||
{
|
||||
if ( ! first )
|
||||
d->Add(", ");
|
||||
for ( const auto& arg : args ) {
|
||||
if ( ! first )
|
||||
d->Add(", ");
|
||||
|
||||
arg.Describe(d);
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
arg.Describe(d);
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<bool, zeek::ValPtr> Plugin::HookFunctionCall(const zeek::Func* func,
|
||||
zeek::detail::Frame* frame, zeek::Args* args)
|
||||
{
|
||||
zeek::ODesc d;
|
||||
d.SetShort();
|
||||
zeek::plugin::HookArgument(func).Describe(&d);
|
||||
zeek::plugin::HookArgument(args).Describe(&d);
|
||||
fprintf(stderr, "%.6f %-15s %s\n", zeek::run_state::network_time, "| HookFunctionCall",
|
||||
d.Description());
|
||||
std::pair<bool, zeek::ValPtr> Plugin::HookFunctionCall(const zeek::Func* func, zeek::detail::Frame* frame,
|
||||
zeek::Args* args) {
|
||||
zeek::ODesc d;
|
||||
d.SetShort();
|
||||
zeek::plugin::HookArgument(func).Describe(&d);
|
||||
zeek::plugin::HookArgument(args).Describe(&d);
|
||||
fprintf(stderr, "%.6f %-15s %s\n", zeek::run_state::network_time, "| HookFunctionCall", d.Description());
|
||||
|
||||
if ( zeek::util::streq(func->Name(), "foo") )
|
||||
{
|
||||
auto& vl = *args;
|
||||
vl[0] = zeek::val_mgr->Count(42);
|
||||
}
|
||||
if ( zeek::util::streq(func->Name(), "foo") ) {
|
||||
auto& vl = *args;
|
||||
vl[0] = zeek::val_mgr->Count(42);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
void Plugin::MetaHookPre(zeek::plugin::HookType hook, const zeek::plugin::HookArgumentList& args)
|
||||
{
|
||||
zeek::ODesc d;
|
||||
d.SetShort();
|
||||
describe_hook_args(args, &d);
|
||||
fprintf(stderr, "%.6f %-15s %s(%s)\n", zeek::run_state::network_time, " MetaHookPre",
|
||||
hook_name(hook), d.Description());
|
||||
}
|
||||
void Plugin::MetaHookPre(zeek::plugin::HookType hook, const zeek::plugin::HookArgumentList& args) {
|
||||
zeek::ODesc d;
|
||||
d.SetShort();
|
||||
describe_hook_args(args, &d);
|
||||
fprintf(stderr, "%.6f %-15s %s(%s)\n", zeek::run_state::network_time, " MetaHookPre", hook_name(hook),
|
||||
d.Description());
|
||||
}
|
||||
|
||||
void Plugin::MetaHookPost(zeek::plugin::HookType hook, const zeek::plugin::HookArgumentList& args,
|
||||
zeek::plugin::HookArgument result)
|
||||
{
|
||||
zeek::ODesc d1;
|
||||
d1.SetShort();
|
||||
describe_hook_args(args, &d1);
|
||||
zeek::plugin::HookArgument result) {
|
||||
zeek::ODesc d1;
|
||||
d1.SetShort();
|
||||
describe_hook_args(args, &d1);
|
||||
|
||||
zeek::ODesc d2;
|
||||
d2.SetShort();
|
||||
result.Describe(&d2);
|
||||
zeek::ODesc d2;
|
||||
d2.SetShort();
|
||||
result.Describe(&d2);
|
||||
|
||||
fprintf(stderr, "%.6f %-15s %s(%s) -> %s\n", zeek::run_state::network_time, " MetaHookPost",
|
||||
hook_name(hook), d1.Description(), d2.Description());
|
||||
}
|
||||
fprintf(stderr, "%.6f %-15s %s(%s) -> %s\n", zeek::run_state::network_time, " MetaHookPost", hook_name(hook),
|
||||
d1.Description(), d2.Description());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue