Tue, 17 Oct 2006 00:32:05 +0200
Path fix
58 | 1 | /* |
2 | * libtu/parser.h | |
3 | * | |
4 | * Copyright (c) Tuomo Valkonen 1999-2002. | |
5 | * | |
6 | * You may distribute and modify this library under the terms of either | |
7 | * the Clarified Artistic License or the GNU LGPL, version 2.1 or later. | |
8 | */ | |
9 | ||
10 | #ifndef LIBTU_PARSER_H | |
11 | #define LIBTU_PARSER_H | |
12 | ||
13 | #include "tokenizer.h" | |
14 | ||
15 | /* | |
16 | * format: | |
62 | 17 | * l = long |
18 | * d = double | |
19 | * i = identifier | |
20 | * s = string | |
21 | * c = char | |
58 | 22 | * . = 1 times any ("l.d") |
23 | * * = 0 or more times any (must be the last, "sd*") | |
62 | 24 | * ? = optional ("?c") |
25 | * : = conditional (":c:s") | |
58 | 26 | * + = 1 or more times last (most be the last, "l+") |
27 | * special entries: | |
28 | * | |
62 | 29 | * "#end" call this handler at the end of section. |
30 | * "#cancel" call this handler when recovering from error | |
58 | 31 | */ |
32 | ||
33 | #define END_CONFOPTS {NULL, NULL, NULL, NULL} | |
34 | ||
35 | typedef struct _ConfOpt{ | |
62 | 36 | const char *optname; |
37 | const char *argfmt; | |
38 | bool (*fn)(Tokenizer *tokz, int n, Token *toks); | |
39 | struct _ConfOpt *opts; | |
58 | 40 | } ConfOpt; |
41 | ||
42 | #define CONFOPTS_NOT_SET libtu_dummy_confopts | |
43 | extern ConfOpt libtu_dummy_confopts[]; | |
44 | ||
45 | extern bool parse_config_tokz(Tokenizer *tokz, const ConfOpt *options); | |
46 | extern bool parse_config_tokz_skip_section(Tokenizer *tokz); | |
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); | |
49 | extern bool check_args(const Tokenizer *tokz, Token *tokens, int ntokens, | |
62 | 50 | const char *fmt); |
58 | 51 | extern bool check_args_loose(const Tokenizer *tokz, Token *tokens, int ntokens, |
62 | 52 | const char *fmt); |
58 | 53 | |
54 | #endif /* LIBTU_PARSER_H */ |