3 * Routines for file parsing.
9 #include <stddef.h> /* size_t */
10 #include <stdint.h> /* uint8_t */
21 /* Parse file at "path" by passing each line's first two tokens to
22 * "token_to_entry". Ignore empty lines. Non-empty lines must feature at least
23 * two tokens as delimited either be whitespace or single quotes (to allow for
24 * tokens featuring whitespaces). When EOF is reached, token_to_entry() is
25 * called a last time with a first token of NULL.
27 extern void parse_file(char * path, void ( *token_to_entry) (char *, char *));
29 /* Calls err_line() with fitting message if EDIT_STARTED not set in "flags". */
30 extern void parsetest_defcontext(uint8_t flags);
32 /* Ensure token_from_line() does not find any more tokens on the line. */
33 extern void parsetest_too_many_values();
35 /* Trigger err_line() with "Unknown argument" message. */
36 extern void parse_unknown_arg();
38 /* If "test"!=0 call err_line() with "Declaration of ID already used" message.*/
39 extern void parse_id_uniq(int test);
41 /* Set "flags"=EDIT_STARTED and return pointer to new zeroed array of "size". */
42 extern char * parse_init_entry(uint8_t * flags, size_t size);
44 /* Wrapper to parse_val() that sets "flags" to "flags"|"set_flag" on success. */
45 extern uint8_t parse_flagval(char * token0, char * token1, char * comparand,
46 uint8_t * flags, uint8_t set_flag, char type,
49 /* Check "ready_flag" is set in "flags", re-set "flags" to "ready_flag" only. */
50 extern void parse_and_reduce_to_readyflag(uint8_t * flags, uint8_t ready_flag);