From 9fd9baba43c8ee17f944a1157b77a8e47cb9ba41 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Fri, 10 Mar 2017 18:13:49 +0100 Subject: Introduce boolean datatype and boolean expression Signed-off-by: Phil Sutter Signed-off-by: Pablo Neira Ayuso --- src/datatype.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/datatype.c') diff --git a/src/datatype.c b/src/datatype.c index 6b1dd4a0..c61c4245 100644 --- a/src/datatype.c +++ b/src/datatype.c @@ -48,6 +48,7 @@ static const struct datatype *datatypes[TYPE_MAX + 1] = { [TYPE_ICMP_CODE] = &icmp_code_type, [TYPE_ICMPV6_CODE] = &icmpv6_code_type, [TYPE_ICMPX_CODE] = &icmpx_code_type, + [TYPE_BOOLEAN] = &boolean_type, }; void datatype_register(const struct datatype *dtype) @@ -1104,3 +1105,21 @@ struct error_record *rate_parse(const struct location *loc, const char *str, return NULL; } + +static const struct symbol_table boolean_tbl = { + .base = BASE_DECIMAL, + .symbols = { + SYMBOL("exists", true), + SYMBOL("missing", false), + SYMBOL_LIST_END + }, +}; + +const struct datatype boolean_type = { + .type = TYPE_BOOLEAN, + .name = "boolean", + .desc = "boolean type", + .size = 1, + .basetype = &integer_type, + .sym_tbl = &boolean_tbl, +}; -- cgit v1.2.3