mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 22:58:20 +00:00
New BiF record_field_vals() that returns the fields of a record in a
table with meta-information. Example: type r: record { a: count; b: string &default="Foo"; c: double &optional; d: string &log; }; event bro_init() { local x: r = [$a=42, $d="Bar"]; print record_fields(x); } This prints: { [a] = [type_name=record, log=F, value=42, default_val=<uninitialized>] [b] = [type_name=record, log=F, value=<uninitialized>, default_val=Foo], [c] = [type_name=record, log=F, value=<uninitialized>, default_val=<uninitialized>], [d] = [type_name=record, log=T, value=Bar, default_val=<uninitialized>], } This is one more step in Seth's quest for full inspection support. :-)
This commit is contained in:
parent
cdd8827cc4
commit
8bacb6eb3d
9 changed files with 99 additions and 9 deletions
8
testing/btest/Baseline/bifs.records_fields/out
Normal file
8
testing/btest/Baseline/bifs.records_fields/out
Normal file
|
@ -0,0 +1,8 @@
|
|||
[a=42, b=<uninitialized>, c=<uninitialized>, d=Bar]
|
||||
{
|
||||
[b] = [type_name=record, log=F, value=<uninitialized>, default_val=Foo],
|
||||
[d] = [type_name=record, log=T, value=Bar, default_val=<uninitialized>],
|
||||
[c] = [type_name=record, log=F, value=<uninitialized>, default_val=<uninitialized>],
|
||||
[a] = [type_name=record, log=F, value=42, default_val=<uninitialized>]
|
||||
}
|
||||
F
|
20
testing/btest/bifs/records_fields.bro
Normal file
20
testing/btest/bifs/records_fields.bro
Normal file
|
@ -0,0 +1,20 @@
|
|||
#
|
||||
# @TEST-EXEC: bro %INPUT >out
|
||||
# @TEST-EXEC: btest-diff out
|
||||
|
||||
type r: record {
|
||||
a: count;
|
||||
b: string &default="Foo";
|
||||
c: double &optional;
|
||||
d: string &log;
|
||||
};
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
local x: r = [$a=42, $d="Bar"];
|
||||
print x;
|
||||
local t: record_field_table;
|
||||
t = record_fields(x);
|
||||
print t;
|
||||
print t["c"]?$value;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue