Merge remote-tracking branch 'origin/topic/bernhard/sqlite'

* origin/topic/bernhard/sqlite:
  fix a few small rough edges (mostly comments that do no longer apply)
  fix bug in input-manager regarding enums that a writer reads without 0-terminating the string
  actually make sqlite work again (tests passed because the writer was not actually defined because of the define.)
  add sqlite distribution.
  fix warnings, update baselines, handle rotation
  add sqlite tests and fix small vector/set escaping bugs
  fix small bug with vectors and sets.
  make work with newer AsciiFormatter.
  start adding a different text for empty records for the sqlite writer.
  no, you will never guess from where I copied this file...
  make sqlite support more or less work for logging and input
  make sqlite-writer more stable.
  make it compile with new version of AsciiInputOutput
  and adapt to AsciiInputOutput - seems to work...
  make it compile
  add SQLite reader.
  ...adapt to new api...
  now the writer supports tables and vectors.
  basic sqlite writer seems to work.
This commit is contained in:
Robin Sommer 2013-05-14 17:11:09 -07:00
commit de88645d05
28 changed files with 146709 additions and 10 deletions

View file

@ -8,6 +8,7 @@
#include "readers/Ascii.h"
#include "readers/Raw.h"
#include "readers/Benchmark.h"
#include "readers/SQLite.h"
#include "Event.h"
#include "EventHandler.h"
@ -34,6 +35,7 @@ ReaderDefinition input_readers[] = {
{ BifEnum::Input::READER_ASCII, "Ascii", 0, reader::Ascii::Instantiate },
{ BifEnum::Input::READER_RAW, "Raw", 0, reader::Raw::Instantiate },
{ BifEnum::Input::READER_BENCHMARK, "Benchmark", 0, reader::Benchmark::Instantiate },
{ BifEnum::Input::READER_SQLITE, "SQLite", 0, reader::SQLite::Instantiate },
// End marker
{ BifEnum::Input::READER_DEFAULT, "None", 0, (ReaderBackend* (*)(ReaderFrontend* frontend))0 }
@ -2114,19 +2116,25 @@ Val* Manager::ValueToVal(const Value* val, BroType* request_type)
}
case TYPE_ENUM: {
// well, this is kind of stupid, because EnumType just mangles the module name and the var name together again...
// but well
string module = extract_module_name(val->val.string_val.data);
string var = extract_var_name(val->val.string_val.data);
// Convert to string first to not have to deal with missing
// \0's...
string module_string(val->val.string_val.data, val->val.string_val.length);
string var_string(val->val.string_val.data, val->val.string_val.length);
string module = extract_module_name(module_string.c_str());
string var = extract_var_name(var_string.c_str());
// Well, this is kind of stupid, because EnumType just
// mangles the module name and the var name together again...
// but well.
bro_int_t index = request_type->AsEnumType()->Lookup(module, var.c_str());
if ( index == -1 )
reporter->InternalError("Value not found in enum mappimg. Module: %s, var: %s",
module.c_str(), var.c_str());
reporter->InternalError("Value not found in enum mappimg. Module: %s, var: %s, var size: %zu",
module.c_str(), var.c_str(), var.size());
return new EnumVal(index, request_type->Ref()->AsEnumType() );
return new EnumVal(index, request_type->Ref()->AsEnumType());
}
default:
reporter->InternalError("unsupported type for input_read");
}