mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Merge remote-tracking branch 'origin/master' into topic/seth/metrics-merge
This commit is contained in:
commit
d61d175a04
189 changed files with 1047 additions and 400 deletions
|
@ -505,15 +505,14 @@ The Bro scripting language supports the following built-in types.
|
|||
A hook is another flavor of function that shares characteristics of
|
||||
both a :bro:type:`function` and a :bro:type:`event`. They are like
|
||||
events in that many handler bodies can be defined for the same hook
|
||||
identifier, they have no return vale, and the order of execution
|
||||
can be enforced with :bro:attr:`&priority`. They are more like
|
||||
functions in the way they are invoked/called, because, unlike
|
||||
events, their execution is immediate and they do not get scheduled
|
||||
through an event queue. Also, a unique feature of a hook is that
|
||||
a given hook handler body can short-circuit the execution of
|
||||
remaining hook handlers simply by exiting from the body as a result
|
||||
of a ``break`` statement (as opposed to a ``return`` or just
|
||||
reaching the end of the body).
|
||||
identifier and the order of execution can be enforced with
|
||||
:bro:attr:`&priority`. They are more like functions in the way they
|
||||
are invoked/called, because, unlike events, their execution is
|
||||
immediate and they do not get scheduled through an event queue.
|
||||
Also, a unique feature of a hook is that a given hook handler body
|
||||
can short-circuit the execution of remaining hook handlers simply by
|
||||
exiting from the body as a result of a ``break`` statement (as
|
||||
opposed to a ``return`` or just reaching the end of the body).
|
||||
|
||||
A hook type is declared like::
|
||||
|
||||
|
@ -549,18 +548,26 @@ The Bro scripting language supports the following built-in types.
|
|||
print "not going to happen", s;
|
||||
}
|
||||
|
||||
Note that, although the first (forward) declaration of ``myhook`` as
|
||||
a hook type isn't strictly required, when it is provided, the
|
||||
argument types must match.
|
||||
Note that the first (forward) declaration of ``myhook`` as a hook
|
||||
type isn't strictly required. Argument types must match for all
|
||||
hook handlers and any forward declaration of a given hook.
|
||||
|
||||
To invoke immediate execution of all hook handler bodies, a ``hook``
|
||||
statement must be used:
|
||||
To invoke immediate execution of all hook handler bodies, they
|
||||
are called similarly to a function, except preceded by the ``hook``
|
||||
keyword:
|
||||
|
||||
.. code:: bro
|
||||
|
||||
hook myhook("hi");
|
||||
|
||||
And the output would like like::
|
||||
or
|
||||
|
||||
.. code:: bro
|
||||
|
||||
if ( hook myhook("hi") )
|
||||
print "all handlers ran";
|
||||
|
||||
And the output would look like::
|
||||
|
||||
priority 10 myhook handler, hi
|
||||
break out of myhook handling, bye
|
||||
|
@ -568,6 +575,12 @@ The Bro scripting language supports the following built-in types.
|
|||
Note how the modification to arguments can be seen by remaining
|
||||
hook handlers.
|
||||
|
||||
The return value of a hook call is an implicit :bro:type:`bool`
|
||||
value with ``T`` meaning that all handlers for the hook were
|
||||
executed and ``F`` meaning that only some of the handlers may have
|
||||
executed due to one handler body exiting as a result of a ``break``
|
||||
statement.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue