home · contact · privacy
Server: Remove log_help(), this should be serverd by the client.
[plomrogue] / src / client / parse.h
1 /* src/client/parse.h
2  *
3  * This file is part of PlomRogue. PlomRogue is licensed under the GPL version 3
4  * or any later version. For details on its copyright, license, and warranties,
5  * see the file NOTICE in the root directory of the PlomRogue source package.
6  *
7  * Routines for file parsing.
8  */
9
10 #ifndef PARSE_H
11 #define PARSE_H
12
13 #include <stddef.h> /* size_t */
14 #include <stdint.h> /* uint8_t */
15
16
17
18 enum parse_flags
19 {
20     EDIT_STARTED  = 0x01
21 };
22
23
24
25 /* Parse file at "path" by passing each line's first two tokens to
26  * "token_to_entry". Ignore empty lines. Non-empty lines must feature at least
27  * two tokens as delimited either be whitespace or single quotes (to allow for
28  * tokens featuring whitespaces). When EOF is reached, token_to_entry() is
29  * called a last time with a first token of NULL.
30  */
31 extern void parse_file(char * path, void ( *token_to_entry) (char *, char *));
32
33 /* Calls err_line() with fitting message if EDIT_STARTED not set in "flags". */
34 extern void parsetest_defcontext(uint8_t flags);
35
36 /* Ensure token_from_line() does not find any more tokens on the line. */
37 extern void parsetest_too_many_values();
38
39 /* Trigger err_line() with "Unknown argument" message. */
40 extern void parse_unknown_arg();
41
42 /* If "test"!=0 call err_line() with "Declaration of ID already used" message.*/
43 extern void parse_id_uniq(int test);
44
45 /* Set "flags"=EDIT_STARTED and return pointer to new zeroed array of "size". */
46 extern char * parse_init_entry(uint8_t * flags, size_t size);
47
48 /* Wrapper to parse_val() that sets "flags" to "flags"|"set_flag" on success. */
49 extern uint8_t parse_flagval(char * token0, char * token1, char * comparand,
50                              uint8_t * flags, uint8_t set_flag, char type,
51                              char * element);
52
53 /* Check "ready_flag" is set in "flags", re-set "flags" to "ready_flag" only. */
54 extern void parse_and_reduce_to_readyflag(uint8_t * flags, uint8_t ready_flag);
55
56
57
58 #endif
59