diff --git a/src/main.cc b/src/main.cc index b51280f4f2..6ab6fe62ee 100644 --- a/src/main.cc +++ b/src/main.cc @@ -47,6 +47,8 @@ extern "C" void OPENSSL_add_all_algorithms_conf(void); #include "Stats.h" #include "ConnCompressor.h" #include "DPM.h" +#include "BroDoc.h" +#include #include "binpac_bro.h" @@ -94,6 +96,7 @@ int do_notice_analysis = 0; int rule_bench = 0; int print_loaded_scripts = 0; int generate_documentation = 0; +extern std::list docs_generated; SecondaryPath* secondary_path = 0; ConnCompressor* conn_compressor = 0; extern char version[]; @@ -971,6 +974,17 @@ int main(int argc, char** argv) mgr.Drain(); + if ( generate_documentation ) + { + std::list::iterator it; + for ( it = docs_generated.begin(); it != docs_generated.end(); ++it ) + (*it)->WriteDocFile(); + for ( it = docs_generated.begin(); it != docs_generated.end(); ++it ) + delete *it; + terminate_bro(); + return 0; + } + have_pending_timers = ! reading_traces && timer_mgr->Size() > 0; if ( io_sources.Size() > 0 || have_pending_timers ) diff --git a/src/scan.l b/src/scan.l index b56583ab44..1d2c9f932c 100644 --- a/src/scan.l +++ b/src/scan.l @@ -58,7 +58,7 @@ char last_tok[128]; static PList(char) files_scanned; // reST documents that we've created (or have at least opened so far). -static std::list docs_generated; +std::list docs_generated; // reST comments (those starting with ##) seen so far. std::list* reST_doc_comments = 0; @@ -877,18 +877,7 @@ int yywrap() } if ( generate_documentation ) - { - std::list::iterator it; - - for ( it = docs_generated.begin(); it != docs_generated.end(); ++it ) - { - (*it)->WriteDocFile(); - delete *it; - } - - docs_generated.clear(); clear_reST_doc_comments(); - } // Otherwise, we are done. return 1;