Merge branch 'topic/bernhard/input-logging-commmon-functions' into topic/bernhard/sqlite

This commit is contained in:
Bernhard Amann 2013-01-13 19:24:44 -08:00
commit 5704496f26
357 changed files with 4745 additions and 1311 deletions

View file

@ -19,7 +19,7 @@ Ascii::Ascii(WriterFrontend* frontend) : WriterBackend(frontend)
{
fd = 0;
ascii_done = false;
only_single_header_row = false;
tsv = false;
output_to_stdout = BifConst::LogAscii::output_to_stdout;
include_meta = BifConst::LogAscii::include_meta;
@ -52,7 +52,7 @@ Ascii::Ascii(WriterFrontend* frontend) : WriterBackend(frontend)
desc.EnableEscaping();
desc.AddEscapeSequence(separator);
io = new AsciiInputOutput(this, set_separator, unset_field, empty_field);
io = new AsciiInputOutput(this, AsciiInputOutput::SeparatorInfo(set_separator, unset_field, empty_field));
}
Ascii::~Ascii()
@ -78,7 +78,7 @@ void Ascii::CloseFile(double t)
if ( ! fd )
return;
if ( include_meta && ! only_single_header_row )
if ( include_meta && ! tsv )
WriteHeaderField("close", Timestamp(0));
safe_close(fd);
@ -108,17 +108,17 @@ bool Ascii::DoInit(const WriterInfo& info, int num_fields, const Field* const *
for ( WriterInfo::config_map::const_iterator i = info.config.begin(); i != info.config.end(); i++ )
{
if ( strcmp(i->first, "only_single_header_row") == 0 )
if ( strcmp(i->first, "tsv") == 0 )
{
if ( strcmp(i->second, "T") == 0 )
only_single_header_row = true;
tsv = true;
else if ( strcmp(i->second, "F") == 0 )
only_single_header_row = false;
tsv = false;
else
{
Error("invalid value for 'only_single_header_row', must be boolean (T/F)");
Error("invalid value for 'tsv', must be a string and either \"T\" or \"F\"");
return false;
}
}
@ -141,9 +141,9 @@ bool Ascii::DoInit(const WriterInfo& info, int num_fields, const Field* const *
types += fields[i]->TypeName().c_str();
}
if ( only_single_header_row )
if ( tsv )
{
// A single CSV-style line is all we need.
// A single TSV-style line is all we need.
string str = names + "\n";
if ( ! safe_write(fd, str.c_str(), str.length()) )
goto write_error;

View file

@ -6,7 +6,7 @@
#define LOGGING_WRITER_ASCII_H
#include "../WriterBackend.h"
#include "../../AsciiInputOutput.h"
#include "../../threading/AsciiInputOutput.h"
namespace logging { namespace writer {
@ -45,7 +45,7 @@ private:
// Options set from the script-level.
bool output_to_stdout;
bool include_meta;
bool only_single_header_row;
bool tsv;
string separator;
string set_separator;

View file

@ -16,7 +16,7 @@
#include "BroString.h"
#include "NetVar.h"
#include "threading/SerialTypes.h"
#include "../../AsciiInputOutput.h"
#include "../../threading/AsciiInputOutput.h"
#include <curl/curl.h>
#include <curl/easy.h>