tester2.c

Mon, 17 Jan 2005 22:02:09 +0100

author
tuomov
date
Mon, 17 Jan 2005 22:02:09 +0100
changeset 85
9f94b2e96e3b
parent 70
e866dc825481
permissions
-rw-r--r--

trunk: changeset 1934
Fixed everything that requires locale stuff to check CF_NO_LOCALE.

0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
1 /*
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
2 * libtu/tester2.c
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
3 *
36
63cd573ffbcf trunk: changeset 39
tuomov
parents: 17
diff changeset
4 * Copyright (c) Tuomo Valkonen 1999-2002.
53
f8f9366b359c trunk: changeset 57
tuomov
parents: 36
diff changeset
5 *
f8f9366b359c trunk: changeset 57
tuomov
parents: 36
diff changeset
6 * You may distribute and modify this library under the terms of either
f8f9366b359c trunk: changeset 57
tuomov
parents: 36
diff changeset
7 * the Clarified Artistic License or the GNU LGPL, version 2.1 or later.
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
8 */
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
9
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
10 #include <stdio.h>
5
f878a9ffa3e0 trunk: changeset 8
tuomov
parents: 2
diff changeset
11
70
e866dc825481 trunk: changeset 1408
tuomov
parents: 62
diff changeset
12 #include "misc.h"
e866dc825481 trunk: changeset 1408
tuomov
parents: 62
diff changeset
13 #include "tokenizer.h"
e866dc825481 trunk: changeset 1408
tuomov
parents: 62
diff changeset
14 #include "parser.h"
e866dc825481 trunk: changeset 1408
tuomov
parents: 62
diff changeset
15 #include "util.h"
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
16
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
17
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
18 static bool test_fn(Tokenizer *tokz, int n, Token *toks)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
19 {
62
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 53
diff changeset
20 printf("test_fn() %d %s\n", n, TOK_IDENT_VAL(toks));
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 53
diff changeset
21
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 53
diff changeset
22 return TRUE;
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
23 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
24
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
25
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
26
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
27 static bool sect_fn(Tokenizer *tokz, int n, Token *toks)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
28 {
62
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 53
diff changeset
29 printf("sect_fn() %d %s\n", n, TOK_IDENT_VAL(toks+1));
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 53
diff changeset
30
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 53
diff changeset
31 return TRUE;
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
32 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
33
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
34
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
35 static bool test2_fn(Tokenizer *tokz, int n, Token *toks)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
36 {
62
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 53
diff changeset
37 printf("test2_fn() %d %s %f\n", n, TOK_BOOL_VAL(toks+1) ? "TRUE" : "FALSE", TOK_DOUBLE_VAL(toks+2));
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
38
62
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 53
diff changeset
39 return TRUE;
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
40 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
41
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
42 static bool test3_fn(Tokenizer *tokz, int n, Token *toks)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
43 {
62
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 53
diff changeset
44 if(n<=2)
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 53
diff changeset
45 printf("test3_fn() %d \"%s\"\n", n, TOK_STRING_VAL(toks+1));
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 53
diff changeset
46 else
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 53
diff changeset
47 printf("test3_fn() %d \"%s\" %ld\n", n, TOK_STRING_VAL(toks+1), TOK_LONG_VAL(toks+2));
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
48
62
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 53
diff changeset
49 return TRUE;
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
50 }
62
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 53
diff changeset
51
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 53
diff changeset
52
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
53 static ConfOpt opts[]={
62
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 53
diff changeset
54 {"test", NULL, test_fn, NULL},
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 53
diff changeset
55 {"t2", "bd", test2_fn, NULL},
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 53
diff changeset
56 {"foo", "s?l", test3_fn, NULL},
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 53
diff changeset
57 {"sect", "s", sect_fn, opts},
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 53
diff changeset
58 {NULL, NULL, NULL, NULL}
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
59 };
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
60
62
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 53
diff changeset
61
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
62 int main(int argc, char *argv[])
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
63 {
62
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 53
diff changeset
64 libtu_init(argv[0]);
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 53
diff changeset
65 parse_config_file(stdin, opts, TOKZ_ERROR_TOLERANT);
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 53
diff changeset
66
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 53
diff changeset
67 return EXIT_SUCCESS;
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
68 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
69

mercurial