Bro's doc mode now terminates after processing bro_init but before net_run

Generated script reST documentation is also written out at this time
instead of at the end of lexical scanning.

The persistence serializer will no longer write out Bro's state to the
.state directory when in doc mode.
This commit is contained in:
Jon Siwek 2011-05-04 20:54:10 -05:00
parent 481a1d097b
commit d919ebed58
2 changed files with 15 additions and 12 deletions

View file

@ -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 <list>
#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<BroDoc*> 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<BroDoc*>::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 )

View file

@ -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<BroDoc*> docs_generated;
std::list<BroDoc*> docs_generated;
// reST comments (those starting with ##) seen so far.
std::list<std::string>* reST_doc_comments = 0;
@ -877,18 +877,7 @@ int yywrap()
}
if ( generate_documentation )
{
std::list<BroDoc*>::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;