parser.h

changeset 62
aae5facf9fc5
parent 58
789df543d0c3
equal deleted inserted replaced
61:fc585645ad05 62:aae5facf9fc5
12 12
13 #include "tokenizer.h" 13 #include "tokenizer.h"
14 14
15 /* 15 /*
16 * format: 16 * format:
17 * l = long 17 * l = long
18 * d = double 18 * d = double
19 * i = identifier 19 * i = identifier
20 * s = string 20 * s = string
21 * c = char 21 * c = char
22 * . = 1 times any ("l.d") 22 * . = 1 times any ("l.d")
23 * * = 0 or more times any (must be the last, "sd*") 23 * * = 0 or more times any (must be the last, "sd*")
24 * ? = optional ("?c") 24 * ? = optional ("?c")
25 * : = conditional (":c:s") 25 * : = conditional (":c:s")
26 * + = 1 or more times last (most be the last, "l+") 26 * + = 1 or more times last (most be the last, "l+")
27 * special entries: 27 * special entries:
28 * 28 *
29 * "#end" call this handler at the end of section. 29 * "#end" call this handler at the end of section.
30 * "#cancel" call this handler when recovering from error 30 * "#cancel" call this handler when recovering from error
31 */ 31 */
32 32
33 #define END_CONFOPTS {NULL, NULL, NULL, NULL} 33 #define END_CONFOPTS {NULL, NULL, NULL, NULL}
34 34
35 typedef struct _ConfOpt{ 35 typedef struct _ConfOpt{
36 const char *optname; 36 const char *optname;
37 const char *argfmt; 37 const char *argfmt;
38 bool (*fn)(Tokenizer *tokz, int n, Token *toks); 38 bool (*fn)(Tokenizer *tokz, int n, Token *toks);
39 struct _ConfOpt *opts; 39 struct _ConfOpt *opts;
40 } ConfOpt; 40 } ConfOpt;
41 41
42 #define CONFOPTS_NOT_SET libtu_dummy_confopts 42 #define CONFOPTS_NOT_SET libtu_dummy_confopts
43 extern ConfOpt libtu_dummy_confopts[]; 43 extern ConfOpt libtu_dummy_confopts[];
44 44
45 extern bool parse_config_tokz(Tokenizer *tokz, const ConfOpt *options); 45 extern bool parse_config_tokz(Tokenizer *tokz, const ConfOpt *options);
46 extern bool parse_config_tokz_skip_section(Tokenizer *tokz); 46 extern bool parse_config_tokz_skip_section(Tokenizer *tokz);
47 extern bool parse_config(const char *fname, const ConfOpt *options, int flags); 47 extern bool parse_config(const char *fname, const ConfOpt *options, int flags);
48 extern bool parse_config_file(FILE *file, const ConfOpt *options, int flags); 48 extern bool parse_config_file(FILE *file, const ConfOpt *options, int flags);
49 extern bool check_args(const Tokenizer *tokz, Token *tokens, int ntokens, 49 extern bool check_args(const Tokenizer *tokz, Token *tokens, int ntokens,
50 const char *fmt); 50 const char *fmt);
51 extern bool check_args_loose(const Tokenizer *tokz, Token *tokens, int ntokens, 51 extern bool check_args_loose(const Tokenizer *tokz, Token *tokens, int ntokens,
52 const char *fmt); 52 const char *fmt);
53 53
54 #endif /* LIBTU_PARSER_H */ 54 #endif /* LIBTU_PARSER_H */

mercurial