1 /* src/common/parse_file.h
3 * Tools for parsing config files.
9 #include <stdint.h> /* uint8_t */
13 /* Many functions working on config file lines / tokens work with these elements
14 * that only change on line change. Makes sense to pass them over together.
32 /* Writes "context"->token1 to "target" only if it describes a proper uint8. */
33 extern void set_uint8(struct Context * context, uint8_t * target);
35 /* If "context"->token0 fits "comparand", set "element" to value read from
36 * ->token1 as either string (type: "s"), char ("c") or uint8 ("8"), set
37 * that element's flag to "flags" and return 1; else return 0.
39 extern uint8_t set_val(struct Context * context, char * comparand,
40 uint8_t * flags, uint8_t set_flag, char type,
43 /* Parse file at "path" by passing each line's tokens to "token_to_entry"
44 * encapsulated into "Context". Empty lines are ignored. Non-empty lines have to
45 * feature exactly two tokens as delimited either be whitespace or single quotes
46 * (to allow for tokens featuring whitespaces). When EOF is reached,
47 * token_to_entry() is called a last time with an empty Context.token0.
49 extern void parse_file(char * path, void ( *token_to_entry) (struct Context *));