include/libtu/parser.h

Mon, 17 Nov 2003 14:28:28 +0100

author
tuomov
date
Mon, 17 Nov 2003 14:28:28 +0100
changeset 55
d32ef6ce17a4
parent 53
f8f9366b359c
permissions
-rw-r--r--

trunk: changeset 59
Set _GNU_SOURCE when compiling with system asprintf. Default to system
asprintf.

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

mercurial