diff options
Diffstat (limited to 'linux/fs_parser.c')
-rw-r--r-- | linux/fs_parser.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/linux/fs_parser.c b/linux/fs_parser.c new file mode 100644 index 00000000..b1cd0c72 --- /dev/null +++ b/linux/fs_parser.c @@ -0,0 +1,36 @@ + +#include <linux/kernel.h> +#include <linux/fs_parser.h> +#include <string.h> + +const struct constant_table bool_names[] = { + { "0", false }, + { "1", true }, + { "false", false }, + { "no", false }, + { "true", true }, + { "yes", true }, + { }, +}; + +static const struct constant_table * +__lookup_constant(const struct constant_table *tbl, const char *name) +{ + for ( ; tbl->name; tbl++) + if (strcmp(name, tbl->name) == 0) + return tbl; + return NULL; +} + +/** + * lookup_constant - Look up a constant by name in an ordered table + * @tbl: The table of constants to search. + * @name: The name to look up. + * @not_found: The value to return if the name is not found. + */ +int lookup_constant(const struct constant_table *tbl, const char *name, int not_found) +{ + const struct constant_table *p = __lookup_constant(tbl, name); + + return p ? p->value : not_found; +} |