Reimplementation of the @prefixes statement.

Any added prefixes are now used *after* all input files have been
parsed to look for a prefixed, flattened version of the input file
somewhere in BROPATH and, if found, load it.

For example, if "lcl" is in @prefixes, and site.bro is loaded, then
a file named "lcl.site.bro" that's in BROPATH would end up being
automatically loaded as well.  Packages work similarly, e.g. loading
"protocols/http" means a file named "lcl.protocols.http.bro" in BROPATH
gets loaded automatically.
This commit is contained in:
Jon Siwek 2011-07-14 21:32:02 -05:00
parent e39a49833f
commit d97003892b
6 changed files with 245 additions and 114 deletions

View file

@ -0,0 +1,4 @@
loaded lcl2.site.bro
loaded lcl.site.bro
loaded lcl2.protocols.http.bro
loaded lcl.protocols.http.bro

View file

@ -0,0 +1,25 @@
# A test of prefix-based @load'ing
# @TEST-EXEC: bro addprefixes site protocols/http >output
# @TEST-EXEC: btest-diff output
@TEST-START-FILE addprefixes.bro
@prefixes += lcl
@prefixes += lcl2
@TEST-END-FILE
@TEST-START-FILE lcl.site.bro
print "loaded lcl.site.bro";
@TEST-END-FILE
@TEST-START-FILE lcl2.site.bro
print "loaded lcl2.site.bro";
@TEST-END-FILE
@TEST-START-FILE lcl.protocols.http.bro
print "loaded lcl.protocols.http.bro";
@TEST-END-FILE
@TEST-START-FILE lcl2.protocols.http.bro
print "loaded lcl2.protocols.http.bro";
@TEST-END-FILE