Sun, 03 Nov 2002 03:51:35 +0100
trunk: changeset 45
(void*)+n fixed
0 | 1 | /* |
2 | * libtu/tester3.c | |
3 | * | |
36 | 4 | * Copyright (c) Tuomo Valkonen 1999-2002. |
0 | 5 | * See the included file LICENSE for details. |
6 | */ | |
7 | ||
8 | #include <stdio.h> | |
5 | 9 | |
10 | #include <libtu/util.h> | |
11 | #include <libtu/misc.h> | |
12 | #include <libtu/optparser.h> | |
0 | 13 | |
14 | ||
15 | static const char usage[]= | |
12 | 16 | "Usage: $p [options]\n" |
0 | 17 | "\n" |
18 | "Where options are:\n" | |
12 | 19 | "$o\n"; |
0 | 20 | |
21 | ||
22 | static OptParserOpt opts[]={ | |
12 | 23 | {'o', "opt", OPT_ARG, "OPTION", "foo bar baz quk asdf jklö äölk dfgh quik aaaa bbbb cccc dddd eeee ffff"}, |
24 | {'f', "file", OPT_ARG, "FILE", "asdfsadlfölökjasdflökjasdflkjöasdflkjöas dlöfjkasdfölkjasdfölkjasdfasdflöjasdfkasödjlfkasdlföjasdölfjkölkasjdfasdfölkjasd asdöljfasöldf asdölfköasdlf asfdlök asdföljkadsfölasdfölasdölkfjasdölfasödlflöskflasdföaölsdf"}, | |
17 | 25 | {'v', "view", 0, NULL, "asfasdf"}, |
26 | {'z', "zip", 0, NULL, "asdfasdf"}, | |
27 | {'x', "extract", 0, NULL, "asdfasdf"}, | |
12 | 28 | {0, NULL, 0, NULL, NULL} |
0 | 29 | }; |
30 | ||
17 | 31 | static OptParserCommonInfo tester3_cinfo={ |
32 | NULL, | |
33 | usage, | |
34 | NULL | |
35 | }; | |
36 | ||
0 | 37 | |
38 | int main(int argc, char *argv[]) | |
39 | { | |
40 | int opt; | |
41 | ||
12 | 42 | libtu_init(argv[0]); |
0 | 43 | |
17 | 44 | optparser_init(argc, argv, OPTP_NO_DASH, opts, &tester3_cinfo); |
0 | 45 | |
46 | while((opt=optparser_get_opt())){ | |
47 | switch(opt){ | |
48 | case 'o': | |
49 | printf("opt: %s\n", optparser_get_arg()); | |
50 | break; | |
51 | case 'f': | |
52 | printf("file: %s\n", optparser_get_arg()); | |
53 | break; | |
54 | case 'v': | |
55 | printf("view\n"); | |
56 | break; | |
57 | case 'z': | |
58 | printf("zip\n"); | |
59 | break; | |
60 | case 'x': | |
61 | printf("extract\n"); | |
62 | break; | |
63 | default: | |
64 | optparser_print_error(); | |
65 | return 1; | |
66 | } | |
67 | } | |
68 | return 0; | |
69 | } | |
70 |