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:
Benjamin Bannier 2023-10-10 21:13:34 +02:00
parent 7b8e7ed72c
commit f5a76c1aed
786 changed files with 131714 additions and 153609 deletions

View file

@ -5,91 +5,66 @@
#include "zeek/Desc.h"
#include "zeek/Reporter.h"
namespace zeek::plugin
{
namespace zeek::plugin {
Tag::type_t Component::type_counter(0);
Component::Component(component::Type arg_type, const std::string& arg_name,
Tag::subtype_t tag_subtype, EnumTypePtr etype)
: type(arg_type), name(arg_name), tag(etype, 1, 0), etype(std::move(etype)),
tag_subtype(tag_subtype)
{
canon_name = util::canonify_name(name);
canon_name_val = make_intrusive<StringVal>(canon_name);
}
Component::Component(component::Type arg_type, const std::string& arg_name, Tag::subtype_t tag_subtype,
EnumTypePtr etype)
: type(arg_type), name(arg_name), tag(etype, 1, 0), etype(std::move(etype)), tag_subtype(tag_subtype) {
canon_name = util::canonify_name(name);
canon_name_val = make_intrusive<StringVal>(canon_name);
}
void Component::Describe(ODesc* d) const
{
d->Add(" ");
d->Add("[");
void Component::Describe(ODesc* d) const {
d->Add(" ");
d->Add("[");
switch ( type )
{
case component::READER:
d->Add("Reader");
break;
switch ( type ) {
case component::READER: d->Add("Reader"); break;
case component::WRITER:
d->Add("Writer");
break;
case component::WRITER: d->Add("Writer"); break;
case component::ANALYZER:
d->Add("Analyzer");
break;
case component::ANALYZER: d->Add("Analyzer"); break;
case component::PACKET_ANALYZER:
d->Add("Packet Analyzer");
break;
case component::PACKET_ANALYZER: d->Add("Packet Analyzer"); break;
case component::FILE_ANALYZER:
d->Add("File Analyzer");
break;
case component::FILE_ANALYZER: d->Add("File Analyzer"); break;
case component::IOSOURCE:
d->Add("I/O Source");
break;
case component::IOSOURCE: d->Add("I/O Source"); break;
case component::PKTSRC:
d->Add("Packet Source");
break;
case component::PKTSRC: d->Add("Packet Source"); break;
case component::PKTDUMPER:
d->Add("Packet Dumper");
break;
case component::PKTDUMPER: d->Add("Packet Dumper"); break;
case component::SESSION_ADAPTER:
d->Add("Session Adapter");
break;
case component::SESSION_ADAPTER: d->Add("Session Adapter"); break;
default:
reporter->InternalWarning("unknown component type in plugin::Component::Describe");
d->Add("<unknown component type>");
break;
}
default:
reporter->InternalWarning("unknown component type in plugin::Component::Describe");
d->Add("<unknown component type>");
break;
}
d->Add("]");
d->Add(" ");
d->Add(name);
d->Add(" (");
DoDescribe(d);
d->Add(")");
}
d->Add("]");
d->Add(" ");
d->Add(name);
d->Add(" (");
DoDescribe(d);
d->Add(")");
}
void Component::InitializeTag()
{
assert(tag_initialized == false);
tag_initialized = true;
tag = zeek::Tag(etype, ++type_counter, tag_subtype);
}
void Component::InitializeTag() {
assert(tag_initialized == false);
tag_initialized = true;
tag = zeek::Tag(etype, ++type_counter, tag_subtype);
}
/**
* @return The component's tag.
*/
zeek::Tag Component::Tag() const
{
assert(tag_initialized);
return tag;
}
zeek::Tag Component::Tag() const {
assert(tag_initialized);
return tag;
}
} // namespace zeek::plugin
} // namespace zeek::plugin