Sat, 22 Apr 2000 17:34:20 +0200
trunk: changeset 11
Portability fixes
0 | 1 | /* |
2 | * libtu/tester3.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> | |
5 | 11 | |
12 | #include <libtu/util.h> | |
13 | #include <libtu/misc.h> | |
14 | #include <libtu/optparser.h> | |
0 | 15 | |
16 | ||
17 | static const char usage[]= | |
18 | "$u [options]\n" | |
19 | "\n" | |
20 | "Where options are:\n" | |
21 | "\n" | |
22 | " -o, -f, -v, -z, -x\n" | |
23 | "$c \n" | |
24 | "\n"; | |
25 | ||
26 | ||
27 | static ProgInfo proginfo={ | |
28 | "Tester III", | |
29 | "0.1", | |
30 | "foo", | |
31 | "bar", | |
32 | usage | |
33 | }; | |
34 | ||
35 | ||
36 | static OptParserOpt opts[]={ | |
3 | 37 | {'o', "opt", OPT_ARG}, |
38 | {'f', "file", OPT_ARG}, | |
39 | {'v', "view", 0}, | |
40 | {'z', "zip", 0}, | |
41 | {'x', "extract", 0}, | |
0 | 42 | {0, NULL, 0} |
43 | }; | |
44 | ||
45 | ||
46 | int main(int argc, char *argv[]) | |
47 | { | |
48 | int opt; | |
49 | ||
50 | libtu_init(&argc, argv, &proginfo); | |
51 | ||
3 | 52 | optparser_init(argc, argv, OPTP_NO_DASH, opts); |
0 | 53 | |
54 | while((opt=optparser_get_opt())){ | |
55 | switch(opt){ | |
56 | case 'o': | |
57 | printf("opt: %s\n", optparser_get_arg()); | |
58 | break; | |
59 | case 'f': | |
60 | printf("file: %s\n", optparser_get_arg()); | |
61 | break; | |
62 | case 'v': | |
63 | printf("view\n"); | |
64 | break; | |
65 | case 'z': | |
66 | printf("zip\n"); | |
67 | break; | |
68 | case 'x': | |
69 | printf("extract\n"); | |
70 | break; | |
71 | default: | |
72 | optparser_print_error(); | |
73 | return 1; | |
74 | } | |
75 | } | |
76 | return 0; | |
77 | } | |
78 |