mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +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,66 +8,59 @@
|
|||
#include <RunState.h>
|
||||
#include <threading/Formatter.h>
|
||||
|
||||
namespace btest::plugin::Log_Hooks
|
||||
{
|
||||
namespace btest::plugin::Log_Hooks {
|
||||
Plugin plugin;
|
||||
}
|
||||
}
|
||||
|
||||
using namespace btest::plugin::Log_Hooks;
|
||||
|
||||
zeek::plugin::Configuration Plugin::Configure()
|
||||
{
|
||||
round = 0;
|
||||
EnableHook(zeek::plugin::HOOK_LOG_INIT);
|
||||
EnableHook(zeek::plugin::HOOK_LOG_WRITE);
|
||||
zeek::plugin::Configuration Plugin::Configure() {
|
||||
round = 0;
|
||||
EnableHook(zeek::plugin::HOOK_LOG_INIT);
|
||||
EnableHook(zeek::plugin::HOOK_LOG_WRITE);
|
||||
|
||||
zeek::plugin::Configuration config;
|
||||
config.name = "Log::Hooks";
|
||||
config.description = "Exercises Log hooks";
|
||||
config.version.major = 1;
|
||||
config.version.minor = 0;
|
||||
config.version.patch = 0;
|
||||
return config;
|
||||
}
|
||||
zeek::plugin::Configuration config;
|
||||
config.name = "Log::Hooks";
|
||||
config.description = "Exercises Log hooks";
|
||||
config.version.major = 1;
|
||||
config.version.minor = 0;
|
||||
config.version.patch = 0;
|
||||
return config;
|
||||
}
|
||||
|
||||
void Plugin::HookLogInit(const std::string& writer, const std::string& instantiating_filter,
|
||||
bool local, bool remote,
|
||||
void Plugin::HookLogInit(const std::string& writer, const std::string& instantiating_filter, bool local, bool remote,
|
||||
const zeek::logging::WriterBackend::WriterInfo& info, int num_fields,
|
||||
const zeek::threading::Field* const* fields)
|
||||
{
|
||||
zeek::ODesc d;
|
||||
const zeek::threading::Field* const* fields) {
|
||||
zeek::ODesc d;
|
||||
|
||||
d.Add("{");
|
||||
for ( int i = 0; i < num_fields; i++ )
|
||||
{
|
||||
const zeek::threading::Field* f = fields[i];
|
||||
d.Add("{");
|
||||
for ( int i = 0; i < num_fields; i++ ) {
|
||||
const zeek::threading::Field* f = fields[i];
|
||||
|
||||
if ( i > 0 )
|
||||
d.Add(", ");
|
||||
if ( i > 0 )
|
||||
d.Add(", ");
|
||||
|
||||
d.Add(f->name);
|
||||
d.Add(" (");
|
||||
d.Add(f->TypeName());
|
||||
d.Add(")");
|
||||
}
|
||||
d.Add("}");
|
||||
d.Add(f->name);
|
||||
d.Add(" (");
|
||||
d.Add(f->TypeName());
|
||||
d.Add(")");
|
||||
}
|
||||
d.Add("}");
|
||||
|
||||
fprintf(stderr, "%.6f %-15s %s %d/%d %s\n", zeek::run_state::network_time, "| HookLogInit",
|
||||
info.path, local, remote, d.Description());
|
||||
}
|
||||
fprintf(stderr, "%.6f %-15s %s %d/%d %s\n", zeek::run_state::network_time, "| HookLogInit", info.path, local,
|
||||
remote, d.Description());
|
||||
}
|
||||
|
||||
bool Plugin::HookLogWrite(const std::string& writer, const std::string& filter,
|
||||
const zeek::logging::WriterBackend::WriterInfo& info, int num_fields,
|
||||
const zeek::threading::Field* const* fields,
|
||||
zeek::threading::Value** vals)
|
||||
{
|
||||
round++;
|
||||
if ( round == 1 ) // do not output line
|
||||
return false;
|
||||
else if ( round == 2 )
|
||||
vals[0]->val.int_val = 0;
|
||||
else if ( round == 3 )
|
||||
vals[1]->present = false;
|
||||
const zeek::threading::Field* const* fields, zeek::threading::Value** vals) {
|
||||
round++;
|
||||
if ( round == 1 ) // do not output line
|
||||
return false;
|
||||
else if ( round == 2 )
|
||||
vals[0]->val.int_val = 0;
|
||||
else if ( round == 3 )
|
||||
vals[1]->present = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -3,27 +3,24 @@
|
|||
|
||||
#include <plugin/Plugin.h>
|
||||
|
||||
namespace btest::plugin::Log_Hooks
|
||||
{
|
||||
namespace btest::plugin::Log_Hooks {
|
||||
|
||||
class Plugin : public zeek::plugin::Plugin
|
||||
{
|
||||
class Plugin : public zeek::plugin::Plugin {
|
||||
protected:
|
||||
void HookLogInit(const std::string& writer, const std::string& instantiating_filter, bool local,
|
||||
bool remote, const zeek::logging::WriterBackend::WriterInfo& info,
|
||||
int num_fields, const zeek::threading::Field* const* fields) override;
|
||||
bool HookLogWrite(const std::string& writer, const std::string& filter,
|
||||
const zeek::logging::WriterBackend::WriterInfo& info, int num_fields,
|
||||
const zeek::threading::Field* const* fields,
|
||||
zeek::threading::Value** vals) override;
|
||||
void HookLogInit(const std::string& writer, const std::string& instantiating_filter, bool local, bool remote,
|
||||
const zeek::logging::WriterBackend::WriterInfo& info, int num_fields,
|
||||
const zeek::threading::Field* const* fields) override;
|
||||
bool HookLogWrite(const std::string& writer, const std::string& filter,
|
||||
const zeek::logging::WriterBackend::WriterInfo& info, int num_fields,
|
||||
const zeek::threading::Field* const* fields, zeek::threading::Value** vals) override;
|
||||
|
||||
// Overridden from plugin::Plugin.
|
||||
zeek::plugin::Configuration Configure() override;
|
||||
// Overridden from plugin::Plugin.
|
||||
zeek::plugin::Configuration Configure() override;
|
||||
|
||||
private:
|
||||
int round;
|
||||
};
|
||||
int round;
|
||||
};
|
||||
|
||||
extern Plugin plugin;
|
||||
|
||||
}
|
||||
} // namespace btest::plugin::Log_Hooks
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue