Fri, 26 May 2000 18:34:04 +0200
trunk: changeset 16
Increased MAX_NEST and MAX_TOKENS to 256
0 | 1 | /* |
2 | * libtu/tester3.c | |
3 | * | |
9 | 4 | * Copyright (c) Tuomo Valkonen 1999-2000. |
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"}, | |
25 | {'v', "view", 0, NULL, NULL}, | |
26 | {'z', "zip", 0, NULL, NULL}, | |
27 | {'x', "extract", 0, NULL, NULL}, | |
28 | {0, NULL, 0, NULL, NULL} | |
0 | 29 | }; |
30 | ||
31 | ||
32 | int main(int argc, char *argv[]) | |
33 | { | |
34 | int opt; | |
35 | ||
12 | 36 | libtu_init(argv[0]); |
0 | 37 | |
12 | 38 | optparser_init(argc, argv, OPTP_NO_DASH, opts, NULL); |
0 | 39 | |
40 | while((opt=optparser_get_opt())){ | |
41 | switch(opt){ | |
42 | case 'o': | |
43 | printf("opt: %s\n", optparser_get_arg()); | |
44 | break; | |
45 | case 'f': | |
46 | printf("file: %s\n", optparser_get_arg()); | |
47 | break; | |
48 | case 'v': | |
49 | printf("view\n"); | |
50 | break; | |
51 | case 'z': | |
52 | printf("zip\n"); | |
53 | break; | |
54 | case 'x': | |
55 | printf("extract\n"); | |
56 | break; | |
57 | default: | |
58 | optparser_print_error(); | |
59 | return 1; | |
60 | } | |
61 | } | |
62 | return 0; | |
63 | } | |
64 |