include/libtu/parser.h

Sun, 03 Nov 2002 03:09:04 +0100

author
tuomov
date
Sun, 03 Nov 2002 03:09:04 +0100
changeset 41
28628406763e
parent 40
0a050a9536a1
child 46
c6deeee169aa
permissions
-rw-r--r--

trunk: changeset 44
remalloczero changes

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
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
40
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
41 extern bool parse_config_tokz(Tokenizer *tokz, const ConfOpt *options);
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
42 extern bool parse_config(const char *fname, const ConfOpt *options, int flags);
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
43 extern bool parse_config_file(FILE *file, const ConfOpt *options, int flags);
20
3f11f764772a trunk: changeset 23
tuomov
parents: 9
diff changeset
44 extern bool check_args(const Tokenizer *tokz, Token *tokens, int ntokens,
3f11f764772a trunk: changeset 23
tuomov
parents: 9
diff changeset
45 const char *fmt);
40
0a050a9536a1 trunk: changeset 43
tuomov
parents: 38
diff changeset
46 extern bool check_args_loose(const Tokenizer *tokz, Token *tokens, int ntokens,
0a050a9536a1 trunk: changeset 43
tuomov
parents: 38
diff changeset
47 const char *fmt);
5
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
48
8
c1994196683f trunk: changeset 11
tuomov
parents: 5
diff changeset
49 #endif /* LIBTU_PARSER_H */

mercurial