Tue, 11 Mar 2003 20:01:42 +0100
trunk: changeset 51
minor glitch
5 | 1 | /* |
2 | * libtu/parser.h | |
3 | * | |
36 | 4 | * Copyright (c) Tuomo Valkonen 1999-2002. |
5 | 5 | * See the included file LICENSE for details. |
6 | */ | |
7 | ||
8 | 8 | #ifndef LIBTU_PARSER_H |
9 | #define LIBTU_PARSER_H | |
5 | 10 | |
11 | #include "tokenizer.h" | |
12 | ||
13 | /* | |
14 | * format: | |
15 | * l = long | |
16 | * d = double | |
17 | * i = identifier | |
18 | * s = string | |
19 | * c = char | |
20 | * . = 1 times any ("l.d") | |
21 | * * = 0 or more times any (must be the last, "sd*") | |
22 | * ? = optional ("?c") | |
23 | * : = conditional (":c:s") | |
24 | * + = 1 or more times last (most be the last, "l+") | |
25 | * special entries: | |
26 | * | |
27 | * "#end" call this handler at the end of section. | |
28 | * "#cancel" call this handler when recovering from error | |
29 | */ | |
30 | ||
38 | 31 | #define END_CONFOPTS {NULL, NULL, NULL, NULL} |
32 | ||
5 | 33 | typedef struct _ConfOpt{ |
34 | const char *optname; | |
35 | const char *argfmt; | |
36 | bool (*fn)(Tokenizer *tokz, int n, Token *toks); | |
37 | struct _ConfOpt *opts; | |
38 | } ConfOpt; | |
39 | ||
46 | 40 | #define CONFOPTS_NOT_SET libtu_dummy_confopts |
41 | extern ConfOpt libtu_dummy_confopts[]; | |
5 | 42 | |
43 | extern bool parse_config_tokz(Tokenizer *tokz, const ConfOpt *options); | |
46 | 44 | extern bool parse_config_tokz_skip_section(Tokenizer *tokz); |
5 | 45 | extern bool parse_config(const char *fname, const ConfOpt *options, int flags); |
46 | extern bool parse_config_file(FILE *file, const ConfOpt *options, int flags); | |
20 | 47 | extern bool check_args(const Tokenizer *tokz, Token *tokens, int ntokens, |
48 | const char *fmt); | |
40 | 49 | extern bool check_args_loose(const Tokenizer *tokz, Token *tokens, int ntokens, |
50 | const char *fmt); | |
5 | 51 | |
8 | 52 | #endif /* LIBTU_PARSER_H */ |