15 #include <libtu/util.h> |
15 #include <libtu/util.h> |
16 |
16 |
17 |
17 |
18 static bool test_fn(Tokenizer *tokz, int n, Token *toks) |
18 static bool test_fn(Tokenizer *tokz, int n, Token *toks) |
19 { |
19 { |
20 printf("test_fn() %d %s\n", n, TOK_IDENT_VAL(toks)); |
20 printf("test_fn() %d %s\n", n, TOK_IDENT_VAL(toks)); |
21 |
21 |
22 return TRUE; |
22 return TRUE; |
23 } |
23 } |
24 |
24 |
25 |
25 |
26 |
26 |
27 static bool sect_fn(Tokenizer *tokz, int n, Token *toks) |
27 static bool sect_fn(Tokenizer *tokz, int n, Token *toks) |
28 { |
28 { |
29 printf("sect_fn() %d %s\n", n, TOK_IDENT_VAL(toks+1)); |
29 printf("sect_fn() %d %s\n", n, TOK_IDENT_VAL(toks+1)); |
30 |
30 |
31 return TRUE; |
31 return TRUE; |
32 } |
32 } |
33 |
33 |
34 |
34 |
35 static bool test2_fn(Tokenizer *tokz, int n, Token *toks) |
35 static bool test2_fn(Tokenizer *tokz, int n, Token *toks) |
36 { |
36 { |
37 printf("test2_fn() %d %s %f\n", n, TOK_BOOL_VAL(toks+1) ? "TRUE" : "FALSE", TOK_DOUBLE_VAL(toks+2)); |
37 printf("test2_fn() %d %s %f\n", n, TOK_BOOL_VAL(toks+1) ? "TRUE" : "FALSE", TOK_DOUBLE_VAL(toks+2)); |
38 |
38 |
39 return TRUE; |
39 return TRUE; |
40 } |
40 } |
41 |
41 |
42 static bool test3_fn(Tokenizer *tokz, int n, Token *toks) |
42 static bool test3_fn(Tokenizer *tokz, int n, Token *toks) |
43 { |
43 { |
44 if(n<=2) |
44 if(n<=2) |
45 printf("test3_fn() %d \"%s\"\n", n, TOK_STRING_VAL(toks+1)); |
45 printf("test3_fn() %d \"%s\"\n", n, TOK_STRING_VAL(toks+1)); |
46 else |
46 else |
47 printf("test3_fn() %d \"%s\" %ld\n", n, TOK_STRING_VAL(toks+1), TOK_LONG_VAL(toks+2)); |
47 printf("test3_fn() %d \"%s\" %ld\n", n, TOK_STRING_VAL(toks+1), TOK_LONG_VAL(toks+2)); |
48 |
48 |
49 return TRUE; |
49 return TRUE; |
50 } |
50 } |
51 |
51 |
52 |
52 |
53 static ConfOpt opts[]={ |
53 static ConfOpt opts[]={ |
54 {"test", NULL, test_fn, NULL}, |
54 {"test", NULL, test_fn, NULL}, |
55 {"t2", "bd", test2_fn, NULL}, |
55 {"t2", "bd", test2_fn, NULL}, |
56 {"foo", "s?l", test3_fn, NULL}, |
56 {"foo", "s?l", test3_fn, NULL}, |
57 {"sect", "s", sect_fn, opts}, |
57 {"sect", "s", sect_fn, opts}, |
58 {NULL, NULL, NULL, NULL} |
58 {NULL, NULL, NULL, NULL} |
59 }; |
59 }; |
60 |
60 |
61 |
61 |
62 int main(int argc, char *argv[]) |
62 int main(int argc, char *argv[]) |
63 { |
63 { |
64 libtu_init(argv[0]); |
64 libtu_init(argv[0]); |
65 parse_config_file(stdin, opts, TOKZ_ERROR_TOLERANT); |
65 parse_config_file(stdin, opts, TOKZ_ERROR_TOLERANT); |
66 |
66 |
67 return EXIT_SUCCESS; |
67 return EXIT_SUCCESS; |
68 } |
68 } |
69 |
69 |