Add bare_mode bif.

This commit is contained in:
Benjamin Bannier 2022-03-25 12:07:11 +01:00
parent 0f1dd8ef1b
commit e83c4c834d
6 changed files with 30 additions and 0 deletions

View file

@ -63,6 +63,7 @@ double current_wallclock = 0.0;
double current_pseudo = 0.0;
bool zeek_init_done = false;
bool time_updated = false;
bool bare_mode = false;
RETSIGTYPE watchdog(int /* signo */)
{

View file

@ -65,6 +65,8 @@ extern double current_pseudo;
extern bool zeek_init_done;
extern bool bare_mode; // True if Zeek was started in bare mode.
} // namespace detail
// Functions to temporarily suspend processing of live input (network packets

View file

@ -516,6 +516,8 @@ SetupResult setup(int argc, char** argv, Options* zopts)
auto options = zopts ? *zopts : parse_cmdline(argc, argv);
run_state::detail::bare_mode = options.bare_mode;
// Set up the global that facilitates access to analysis/optimization
// options from deep within some modules.
analysis_options = options.analysis_options;

View file

@ -1748,6 +1748,20 @@ function zeek_version%(%): string
return zeek::make_intrusive<zeek::StringVal>(zeek::zeek_version());
%}
%%{
namespace zeek::run_state::detail {
extern bool bare_mode;
} // namespace zeek::run_state::detail
%%}
## Returns whether Zeek was started in bare mode.
##
## Returns: True if Zeek was started in bare mode, false otherwise.
function bare_mode%(%): bool
%{
return zeek::val_mgr->Bool(zeek::run_state::detail::bare_mode);
%}
## Converts a record type name to a vector of strings, where each element is
## the name of a record field. Nested records are flattened.
##

View file

@ -0,0 +1,3 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
F
T

View file

@ -0,0 +1,8 @@
# @TEST-EXEC: zeek %INPUT >>output
# @TEST-EXEC: zeek -b %INPUT >>output
# @TEST-EXEC: btest-diff output
event zeek_init()
{
print bare_mode();
}