what’s the difference between < if > and <@if>,
seems they can do the same things.
I don’t find more details from the document
what’s the difference between < if > and <@if>,
seems they can do the same things.
I don’t find more details from the document
@if
is a directive which is evaluated before the script is executed; if
on the other hand is evaluated at runtime when the script is executed. In that sense @if
is similar to e.g., the C preprocessor directive #if
.
With @if
you can influence which version of a piece of code is even considered. This makes it possible to e.g., define completely different functions depending on some constant value at the time the directive is evaluated (cannot be value filled at runtime).
@if ( Version::number >= 50000 )
# Take `count` argument for >=zeek-5.0.0.
function foo(x: count) { }
@else
# Take `string` argument for <zeek-5.0.0.
function foo(x: string) { }
@endif
In above example @if
ensures exactly one definition for foo
exists (anything else would be an error as functions cannot be redefined).
Thanks.
I have a kafka.zeek, I want to load this script when zeek-kafka plugin is loaded,
So I want something like follows:
@if (exp) // I don’t know how to special the expression
@load $zeek_path/kafka
@endif
I use a global var in configuration zeek file, it works
@load config
@if (CONFIG::Zeek_active)
@load $zeek_path/kafka
@endif
but i still wonder if that the CONFIG::Zeek_active is still something at runtime
just like theVersion::number is still something at runtime
I use a global var in configuration zeek file, it works
@load config @if (CONFIG::Zeek_active) @load $zeek_path/kafka @endif
but i still wonder if that the
CONFIG::Zeek_active
is still something at runtime
just like theVersion::number is still something at runtime
Version::number
is a constant which is why it can be used in directives like @if
.
I have a kafka.zeek, I want to load this script when zeek-kafka plugin is loaded,
So I want something like follows:
@if (exp) // I don’t know how to special the expression @load $zeek_path/kafka @endif
Instead of @if
you could use @ifdef
to check whether a known identifier from zeek-kafka is defined (this should only happen if the file is indeed loaded), e.g.,
@ifdef ( Kafka::logs_to_send )
@load $zeek_path/kafka
@endif
It is clearly, Thanks