Releasing version 3-2014010504
[notion/jeffpc.git] / libtu / parser.h
blob735805335bf4ba7881fb7ea782abb72f9d2f843f
1 /*
2 * libtu/parser.h
4 * Copyright (c) Tuomo Valkonen 1999-2002.
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 */
10 #ifndef LIBTU_PARSER_H
11 #define LIBTU_PARSER_H
13 #include "tokenizer.h"
16 * format:
17 * l = long
18 * d = double
19 * i = identifier
20 * s = string
21 * c = char
22 * . = 1 times any ("l.d")
23 * * = 0 or more times any (must be the last, "sd*")
24 * ? = optional ("?c")
25 * : = conditional (":c:s")
26 * + = 1 or more times last (most be the last, "l+")
27 * special entries:
29 * "#end" call this handler at the end of section.
30 * "#cancel" call this handler when recovering from error
33 #define END_CONFOPTS {NULL, NULL, NULL, NULL}
35 typedef struct _ConfOpt{
36 const char *optname;
37 const char *argfmt;
38 bool (*fn)(Tokenizer *tokz, int n, Token *toks);
39 struct _ConfOpt *opts;
40 } ConfOpt;
42 #define CONFOPTS_NOT_SET libtu_dummy_confopts
43 extern ConfOpt libtu_dummy_confopts[];
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,
50 const char *fmt);
51 extern bool check_args_loose(const Tokenizer *tokz, Token *tokens, int ntokens,
52 const char *fmt);
54 #endif /* LIBTU_PARSER_H */