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