]> git.proxmox.com Git - mirror_iproute2.git/commit - lib/utils.c
lib: Add parse_one_of(), parse_on_off()
authorPetr Machata <me@pmachata.org>
Thu, 12 Nov 2020 22:24:39 +0000 (23:24 +0100)
committerDavid Ahern <dsahern@gmail.com>
Sat, 14 Nov 2020 02:43:15 +0000 (19:43 -0700)
commit82604d28525aae8d9c5206d5c1d70aee88a7d960
tree9ba299fc84ce2343d868a1cb09727c40c86ca02e
parent1d9a81b8c9f30f9f4abeb875998262f61bf10577
lib: Add parse_one_of(), parse_on_off()

Take from the macsec code parse_one_of() and adapt so that it passes the
primary result as the main return value, and error result through a
pointer. That is the simplest way to make the code reusable across data
types without introducing extra magic.

Also from macsec take the specialization of parse_one_of() for parsing
specifically the strings "off" and "on".

Convert the macsec code to the new helpers.

Signed-off-by: Petr Machata <me@pmachata.org>
Signed-off-by: David Ahern <dsahern@gmail.com>
include/utils.h
ip/ipmacsec.c
lib/utils.c