Tue, 25 Feb 2003 20:02:42 +0100
trunk: changeset 47
Added system-inc.mk and modified Makefile to use it
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 | ||
40 | ||
41 | extern bool parse_config_tokz(Tokenizer *tokz, const ConfOpt *options); | |
42 | extern bool parse_config(const char *fname, const ConfOpt *options, int flags); | |
43 | extern bool parse_config_file(FILE *file, const ConfOpt *options, int flags); | |
20 | 44 | extern bool check_args(const Tokenizer *tokz, Token *tokens, int ntokens, |
45 | const char *fmt); | |
40 | 46 | extern bool check_args_loose(const Tokenizer *tokz, Token *tokens, int ntokens, |
47 | const char *fmt); | |
5 | 48 | |
8 | 49 | #endif /* LIBTU_PARSER_H */ |