Move input code to zeek namespaces

This commit is contained in:
Tim Wojtulewicz 2020-08-01 10:47:51 -07:00
parent 14408235b8
commit 9a800265ff
31 changed files with 227 additions and 162 deletions

View file

@ -12,12 +12,13 @@
#include "threading/SerialTypes.h"
using namespace input::reader;
using namespace threading;
using namespace std;
using threading::Value;
using threading::Field;
namespace zeek::input::reader::detail {
FieldMapping::FieldMapping(const string& arg_name, const zeek::TypeTag& arg_type, int arg_position)
: name(arg_name), type(arg_type), subtype(zeek::TYPE_ERROR)
{
@ -47,7 +48,7 @@ FieldMapping FieldMapping::subType()
return FieldMapping(name, subtype, position);
}
Ascii::Ascii(ReaderFrontend *frontend) : ReaderBackend(frontend)
Ascii::Ascii(zeek::input::ReaderFrontend *frontend) : zeek::input::ReaderBackend(frontend)
{
mtime = 0;
ino = 0;
@ -274,7 +275,7 @@ bool Ascii::DoUpdate()
return ! fail_on_file_problem;
switch ( Info().mode ) {
case MODE_REREAD:
case zeek::input::MODE_REREAD:
{
// check if the file has changed
struct stat sb;
@ -301,14 +302,14 @@ bool Ascii::DoUpdate()
// File changed. Fall through to re-read.
}
case MODE_MANUAL:
case MODE_STREAM:
case zeek::input::MODE_MANUAL:
case zeek::input::MODE_STREAM:
{
// dirty, fix me. (well, apparently after trying seeking, etc
// - this is not that bad)
if ( file.is_open() )
{
if ( Info().mode == MODE_STREAM )
if ( Info().mode == zeek::input::MODE_STREAM )
{
file.clear(); // remove end of file evil bits
if ( ! ReadHeader(true) )
@ -434,13 +435,13 @@ bool Ascii::DoUpdate()
//printf("fpos: %d, second.num_fields: %d\n", fpos, (*it).second.num_fields);
assert ( fpos == NumFields() );
if ( Info().mode == MODE_STREAM )
if ( Info().mode == zeek::input::MODE_STREAM )
Put(fields);
else
SendEntry(fields);
}
if ( Info().mode != MODE_STREAM )
if ( Info().mode != zeek::input::MODE_STREAM )
EndCurrentSend();
return true;
@ -453,12 +454,12 @@ bool Ascii::DoHeartbeat(double network_time, double current_time)
switch ( Info().mode )
{
case MODE_MANUAL:
case zeek::input::MODE_MANUAL:
// yay, we do nothing :)
break;
case MODE_REREAD:
case MODE_STREAM:
case zeek::input::MODE_REREAD:
case zeek::input::MODE_STREAM:
Update(); // Call Update, not DoUpdate, because Update
// checks the "disabled" flag.
break;
@ -469,3 +470,5 @@ bool Ascii::DoHeartbeat(double network_time, double current_time)
return true;
}
} // namespace zeek::input::reader::detail