read header line in bro logfile format

This commit is contained in:
Bernhard Amann 2011-11-08 15:33:32 -08:00
parent 1d39eaf32d
commit 5983d44d95
2 changed files with 19 additions and 3 deletions

View file

@ -62,7 +62,7 @@ bool InputReaderAscii::DoInit(string path, int num_fields, int idx_fields, const
bool InputReaderAscii::ReadHeader() {
// try to read the header line...
string line;
if ( !getline(*file, line) ) {
if ( !GetLine(line) ) {
Error("could not read first line");
return false;
}
@ -111,6 +111,21 @@ bool InputReaderAscii::ReadHeader() {
return true;
}
bool InputReaderAscii::GetLine(string& str) {
while ( getline(*file, str) ) {
if ( str[0] != '#' ) {
return true;
}
if ( str.compare(0,8, "#fields\t") == 0 ) {
str = str.substr(8);
return true;
}
}
return false;
}
// read the entire file and send appropriate thingies back to InputMgr
bool InputReaderAscii::DoUpdate() {
@ -143,7 +158,7 @@ bool InputReaderAscii::DoUpdate() {
//map<string, string> *newKeyMap = new map<string, string>();
string line;
while ( getline(*file, line ) ) {
while ( GetLine(line ) ) {
// split on tabs
istringstream splitstream(line);

View file

@ -37,8 +37,9 @@ protected:
virtual bool DoUpdate();
private:
bool ReadHeader();
bool GetLine(string& str);
ifstream* file;
string fname;