Import libtu instead of using submodules
[notion/jeffpc.git] / libtu / tester2.c
blob832c4744cbfc15b0e04b8d867810baacbce9852f
1 /*
2 * libtu/tester2.c
4 * Copyright (c) Tuomo Valkonen 1999-2002.
6 * You may distribute and modify this library under the terms of either
7 * the Clarified Artistic License or the GNU LGPL, version 2.1 or later.
8 */
10 #include <stdio.h>
12 #include "misc.h"
13 #include "tokenizer.h"
14 #include "parser.h"
15 #include "util.h"
18 static bool test_fn(Tokenizer *tokz, int n, Token *toks)
20 printf("test_fn() %d %s\n", n, TOK_IDENT_VAL(toks));
22 return TRUE;
27 static bool sect_fn(Tokenizer *tokz, int n, Token *toks)
29 printf("sect_fn() %d %s\n", n, TOK_IDENT_VAL(toks+1));
31 return TRUE;
35 static bool test2_fn(Tokenizer *tokz, int n, Token *toks)
37 printf("test2_fn() %d %s %f\n", n, TOK_BOOL_VAL(toks+1) ? "TRUE" : "FALSE", TOK_DOUBLE_VAL(toks+2));
39 return TRUE;
42 static bool test3_fn(Tokenizer *tokz, int n, Token *toks)
44 if(n<=2)
45 printf("test3_fn() %d \"%s\"\n", n, TOK_STRING_VAL(toks+1));
46 else
47 printf("test3_fn() %d \"%s\" %ld\n", n, TOK_STRING_VAL(toks+1), TOK_LONG_VAL(toks+2));
49 return TRUE;
53 static ConfOpt opts[]={
54 {"test", NULL, test_fn, NULL},
55 {"t2", "bd", test2_fn, NULL},
56 {"foo", "s?l", test3_fn, NULL},
57 {"sect", "s", sect_fn, opts},
58 {NULL, NULL, NULL, NULL}
62 int main(int argc, char *argv[])
64 libtu_init(argv[0]);
65 parse_config_file(stdin, opts, TOKZ_ERROR_TOLERANT);
67 return EXIT_SUCCESS;