]> git.ipfire.org Git - thirdparty/nftables.git/commit
parser_json: Introduce parse_flags_array()
authorPhil Sutter <phil@nwl.cc>
Thu, 10 Apr 2025 14:42:42 +0000 (16:42 +0200)
committerPhil Sutter <phil@nwl.cc>
Tue, 13 May 2025 08:48:53 +0000 (10:48 +0200)
commit3550dd69632f3a883ab6593daeffb514c67dfb8c
tree0574e76caf537d6ae72c6fca3b71a8a086b38126
parentbe737a1986bfee0ddea4bee7863dca0123a2bcbc
parser_json: Introduce parse_flags_array()

Various objects support a 'flags' property with value usually being an
array of strings. There is a special case, when merely a single flag is
set: The value may be a string representing this flag.

Introduce a function assisting in parsing this polymorphic value. Have
callers pass a parser callback translating a single flag name into a
corresponding value. Luckily, these single flag parsers are very common
already.

As a side-effect, enable the single flag spec for set flags as well and
update the documentation accordingly.

Signed-off-by: Phil Sutter <phil@nwl.cc>
doc/libnftables-json.adoc
src/parser_json.c