| |
1 /* |
| |
2 * libtu/tester2.c |
| |
3 * |
| |
4 * Copyright (c) Tuomo Valkonen 1999-2000. |
| |
5 * |
| |
6 * This file is distributed under the terms of the "Artistic License". |
| |
7 * See the included file LICENSE for details. |
| |
8 */ |
| |
9 |
| |
10 #include <stdio.h> |
| |
11 #include "include/misc.h" |
| |
12 #include "include/tokenizer.h" |
| |
13 #include "include/parser.h" |
| |
14 #include "include/util.h" |
| |
15 |
| |
16 |
| |
17 static bool test_fn(Tokenizer *tokz, int n, Token *toks) |
| |
18 { |
| |
19 printf("test_fn() %d %s\n", n, TOK_IDENT_VAL(toks)); |
| |
20 |
| |
21 return TRUE; |
| |
22 } |
| |
23 |
| |
24 |
| |
25 |
| |
26 static bool sect_fn(Tokenizer *tokz, int n, Token *toks) |
| |
27 { |
| |
28 printf("sect_fn() %d %s\n", n, TOK_IDENT_VAL(toks+1)); |
| |
29 |
| |
30 return TRUE; |
| |
31 } |
| |
32 |
| |
33 |
| |
34 static bool test2_fn(Tokenizer *tokz, int n, Token *toks) |
| |
35 { |
| |
36 printf("test2_fn() %d %ld %f\n", n, TOK_LONG_VAL(toks+1), TOK_DOUBLE_VAL(toks+2)); |
| |
37 |
| |
38 return TRUE; |
| |
39 } |
| |
40 |
| |
41 static bool test3_fn(Tokenizer *tokz, int n, Token *toks) |
| |
42 { |
| |
43 if(n==1) |
| |
44 printf("test3_fn() \"%s\"\n", TOK_STRING_VAL(toks+1)); |
| |
45 else |
| |
46 printf("test3_fn() \"%s\" %ld\n", TOK_STRING_VAL(toks+1), TOK_LONG_VAL(toks+2)); |
| |
47 |
| |
48 return TRUE; |
| |
49 } |
| |
50 |
| |
51 |
| |
52 static ConfOpt opts[]={ |
| |
53 {"test", NULL, test_fn, NULL}, |
| |
54 {"t2", "ld", test2_fn, NULL}, |
| |
55 {"foo", "s?l", test3_fn, NULL}, |
| |
56 {"sect", "s", sect_fn, opts}, |
| |
57 {NULL, NULL, NULL, NULL} |
| |
58 }; |
| |
59 |
| |
60 |
| |
61 int main(int argc, char *argv[]) |
| |
62 { |
| |
63 libtu_init_argv0(argv[0], NULL); |
| |
64 parse_config_file(stdin, opts); |
| |
65 |
| |
66 return EXIT_SUCCESS; |
| |
67 } |
| |
68 |