include/libtu/parser.h

Wed, 16 Apr 2003 09:09:34 +0200

author
tuomov
date
Wed, 16 Apr 2003 09:09:34 +0200
changeset 52
0228b3741a42
parent 46
c6deeee169aa
child 53
f8f9366b359c
permissions
-rw-r--r--

trunk: changeset 56
set_warn_handler returns default_warn_handler instead of NULL when no
other warn handlers are set.

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

mercurial