mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 01:58:20 +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
|
@ -7,77 +7,67 @@
|
|||
|
||||
#include "zeek/iosource/Manager.h"
|
||||
|
||||
namespace btest::plugin::Demo_Iosource
|
||||
{
|
||||
namespace btest::plugin::Demo_Iosource {
|
||||
|
||||
class TimeoutSource : public zeek::iosource::IOSource
|
||||
{
|
||||
class TimeoutSource : public zeek::iosource::IOSource {
|
||||
public:
|
||||
TimeoutSource(std::string_view ident) : ident(ident)
|
||||
{
|
||||
zeek::iosource_mgr->Register(this, true /* don't count */);
|
||||
};
|
||||
TimeoutSource(std::string_view ident) : ident(ident) {
|
||||
zeek::iosource_mgr->Register(this, true /* don't count */);
|
||||
};
|
||||
|
||||
void Process() override
|
||||
{
|
||||
std::fprintf(stdout, "%.3f %s TimeoutSource.Process()\n", zeek::run_state::network_time,
|
||||
ident.c_str());
|
||||
on = false;
|
||||
}
|
||||
void Process() override {
|
||||
std::fprintf(stdout, "%.3f %s TimeoutSource.Process()\n", zeek::run_state::network_time, ident.c_str());
|
||||
on = false;
|
||||
}
|
||||
|
||||
double GetNextTimeout() override { return on ? 0.0 : 0.1; };
|
||||
double GetNextTimeout() override { return on ? 0.0 : 0.1; };
|
||||
|
||||
const char* Tag() override { return ident.c_str(); };
|
||||
const char* Tag() override { return ident.c_str(); };
|
||||
|
||||
void Fire() { on = true; }
|
||||
void Fire() { on = true; }
|
||||
|
||||
private:
|
||||
std::string ident;
|
||||
bool on = false;
|
||||
};
|
||||
std::string ident;
|
||||
bool on = false;
|
||||
};
|
||||
|
||||
class FdSource : public zeek::iosource::IOSource
|
||||
{
|
||||
class FdSource : public zeek::iosource::IOSource {
|
||||
public:
|
||||
FdSource(std::string_view ident) : ident(ident)
|
||||
{
|
||||
zeek::iosource_mgr->Register(this, true /* don't count */);
|
||||
if ( ! zeek::iosource_mgr->RegisterFd(flare.FD(), this) )
|
||||
zeek::reporter->FatalError("Failed to register flare FD");
|
||||
}
|
||||
FdSource(std::string_view ident) : ident(ident) {
|
||||
zeek::iosource_mgr->Register(this, true /* don't count */);
|
||||
if ( ! zeek::iosource_mgr->RegisterFd(flare.FD(), this) )
|
||||
zeek::reporter->FatalError("Failed to register flare FD");
|
||||
}
|
||||
|
||||
void Process() override
|
||||
{
|
||||
std::fprintf(stdout, "%.3f %s FdSource.Process()\n", zeek::run_state::network_time,
|
||||
ident.c_str());
|
||||
flare.Extinguish();
|
||||
}
|
||||
void Process() override {
|
||||
std::fprintf(stdout, "%.3f %s FdSource.Process()\n", zeek::run_state::network_time, ident.c_str());
|
||||
flare.Extinguish();
|
||||
}
|
||||
|
||||
double GetNextTimeout() override { return -1; }
|
||||
double GetNextTimeout() override { return -1; }
|
||||
|
||||
const char* Tag() override { return ident.c_str(); };
|
||||
const char* Tag() override { return ident.c_str(); };
|
||||
|
||||
void Fire() { flare.Fire(); }
|
||||
void Fire() { flare.Fire(); }
|
||||
|
||||
private:
|
||||
std::string ident;
|
||||
zeek::detail::Flare flare;
|
||||
};
|
||||
std::string ident;
|
||||
zeek::detail::Flare flare;
|
||||
};
|
||||
|
||||
class Plugin : public zeek::plugin::Plugin
|
||||
{
|
||||
class Plugin : public zeek::plugin::Plugin {
|
||||
protected:
|
||||
zeek::plugin::Configuration Configure() override;
|
||||
void InitPostScript() override;
|
||||
void HookDrainEvents() override;
|
||||
zeek::plugin::Configuration Configure() override;
|
||||
void InitPostScript() override;
|
||||
void HookDrainEvents() override;
|
||||
|
||||
private:
|
||||
int round = 0;
|
||||
TimeoutSource* ts1 = nullptr;
|
||||
TimeoutSource* ts2 = nullptr;
|
||||
FdSource* fd1 = nullptr;
|
||||
FdSource* fd2 = nullptr;
|
||||
};
|
||||
int round = 0;
|
||||
TimeoutSource* ts1 = nullptr;
|
||||
TimeoutSource* ts2 = nullptr;
|
||||
FdSource* fd1 = nullptr;
|
||||
FdSource* fd2 = nullptr;
|
||||
};
|
||||
|
||||
extern Plugin plugin;
|
||||
}
|
||||
} // namespace btest::plugin::Demo_Iosource
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue