mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
event from c++ to script works (at last...)
This commit is contained in:
parent
f8be3519c7
commit
9c8b0dec3b
8 changed files with 33 additions and 16 deletions
1
scripts/base/frameworks/input/__load__.bro
Normal file
1
scripts/base/frameworks/input/__load__.bro
Normal file
|
@ -0,0 +1 @@
|
|||
@load ./main
|
11
scripts/base/frameworks/input/main.bro
Normal file
11
scripts/base/frameworks/input/main.bro
Normal file
|
@ -0,0 +1,11 @@
|
|||
|
||||
module Input;
|
||||
|
||||
export {
|
||||
type Event: record {
|
||||
name: string;
|
||||
columns: any;
|
||||
};
|
||||
}
|
||||
|
||||
@load base/input.bif
|
|
@ -1509,4 +1509,5 @@ const parse_udp_tunnels = F &redef;
|
|||
# BiFs and script-land defined types.
|
||||
@load base/frameworks/logging
|
||||
|
||||
@load base/input.bif
|
||||
@load base/frameworks/input
|
||||
|
||||
|
|
|
@ -35,11 +35,11 @@ InputMgr::InputMgr()
|
|||
|
||||
|
||||
// create a new input reader object to be used at whomevers leisure lateron.
|
||||
InputReader* InputMgr::CreateReader(EnumVal* reader, string source, string eventName, RecordVal* eventDescription)
|
||||
InputReader* InputMgr::CreateReader(EnumVal* reader, string source, RecordVal* event)
|
||||
{
|
||||
InputReaderDefinition* ir = input_readers;
|
||||
|
||||
RecordType* rtype = eventDescription->Type()->AsRecordType();
|
||||
RecordType* rtype = InputReaderDefinition->Type()->AsRecordType();
|
||||
if ( ! same_type(rtype, BifType::Record::Input::Event, 0) )
|
||||
{
|
||||
reporter->Error("eventDescription argument not of right type");
|
||||
|
@ -49,7 +49,6 @@ InputReader* InputMgr::CreateReader(EnumVal* reader, string source, string event
|
|||
while ( true ) {
|
||||
if ( ir->type == BifEnum::Input::READER_DEFAULT )
|
||||
{
|
||||
DBG_LOG(DBG_LOGGING, "unknown reader when creating reader");
|
||||
reporter->Error("unknown reader when creating reader");
|
||||
return 0;
|
||||
}
|
||||
|
@ -89,6 +88,8 @@ InputReader* InputMgr::CreateReader(EnumVal* reader, string source, string event
|
|||
InputReader* reader_obj = (*ir->factory)();
|
||||
assert(reader_obj);
|
||||
|
||||
reader_obj->Init(source, eventName);
|
||||
|
||||
return reader_obj;
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class InputMgr {
|
|||
public:
|
||||
InputMgr();
|
||||
|
||||
InputReader* CreateReader(EnumVal* reader, string source, string eventName, RecordVal* eventDescription);
|
||||
InputReader* CreateReader(EnumVal* reader, string source, RecordVal* event);
|
||||
|
||||
protected:
|
||||
friend class InputReader;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
#include "InputReader.h"
|
||||
#include "EventRegistry.h"
|
||||
#include "Event.h"
|
||||
// #include "EventRegistry.h"
|
||||
// #include "Event.h"
|
||||
|
||||
InputReader::InputReader()
|
||||
{
|
||||
|
@ -19,13 +19,16 @@ void InputReader::Error(const char *msg)
|
|||
}
|
||||
|
||||
bool InputReader::Init(string source, string eventName) {
|
||||
EventHandler* handler = event_registry->Lookup(eventName.c_str());
|
||||
//EventHandler* handler = event_registry->Lookup(eventName.c_str());
|
||||
|
||||
//if ( handler == 0 ) {
|
||||
// reporter->Error("Event %s not found", eventName.c_str());
|
||||
// return false;
|
||||
//}
|
||||
|
||||
if ( handler == 0 ) {
|
||||
reporter->Error("Event %s not found", eventName.c_str());
|
||||
return false;
|
||||
}
|
||||
//val_list* vl = new val_list;
|
||||
//vl->append(new Val(12, TYPE_COUNT));
|
||||
|
||||
mgr.Dispatch(new Event(handler, 0));
|
||||
//mgr.Dispatch(new Event(handler, vl));
|
||||
return true;
|
||||
}
|
|
@ -475,7 +475,7 @@ void LogMgr::RemoveDisabledWriters(Stream* stream)
|
|||
stream->writers.erase(*j);
|
||||
}
|
||||
|
||||
bool LogMgr::CreateStream(EnumVal* id, RecordVal* sval)
|
||||
bool LogMgr::(EnumVal* id, RecordVal* sval)
|
||||
{
|
||||
RecordType* rtype = sval->Type()->AsRecordType();
|
||||
|
||||
|
|
|
@ -9,9 +9,9 @@ module Input;
|
|||
|
||||
type Event: record;
|
||||
|
||||
function Input::__create_reader%(reader: Input::Reader, source: string, eventName: string, eventDescription: Input::Event%) : bool
|
||||
function Input::__create_reader%(reader: Input::Reader, source: string, eventDescription: Input::Event%) : bool
|
||||
%{
|
||||
InputReader *the_reader = input_mgr->CreateReader(reader->AsEnumVal(), source->AsString()->CheckString(), eventName->AsString()->CheckString(), eventDescription->AsRecordVal());
|
||||
InputReader *the_reader = input_mgr->CreateReader(reader->AsEnumVal(), source->AsString()->CheckString(), eventDescription->AsRecordVal());
|
||||
return new Val( the_reader != 0, TYPE_BOOL );
|
||||
%}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue