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