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:
Robin Sommer 2011-07-07 18:41:50 -07:00
parent cdd8827cc4
commit 8bacb6eb3d
9 changed files with 99 additions and 9 deletions

View file

@ -183,6 +183,17 @@ type script_id: record {
value: any &optional;
};
type id_table: table[string] of script_id;
type record_field: record {
type_name: string;
log: bool;
value: any &optional;
default_val: any &optional;
};
type record_field_table: table[string] of record_field;
# The following two variables are defined here until the core is not
# dependent on the names remaining as they are now.
## This is the list of capture filters indexed by some user-definable ID.
@ -190,8 +201,6 @@ global capture_filters: table[string] of string &redef;
## This is the list of restriction filters indexed by some user-definable ID.
global restrict_filters: table[string] of string &redef;
type id_table: table[string] of script_id;
# {precompile,install}_pcap_filter identify the filter by IDs
type PcapFilterID: enum { None };