Mon, 17 Nov 2003 14:28:28 +0100
trunk: changeset 59
Set _GNU_SOURCE when compiling with system asprintf. Default to system
asprintf.
0 | 1 | /* |
2 | * libtu/tester3.c | |
3 | * | |
36 | 4 | * Copyright (c) Tuomo Valkonen 1999-2002. |
53 | 5 | * |
6 | * You may distribute and modify this library under the terms of either | |
7 | * the Clarified Artistic License or the GNU LGPL, version 2.1 or later. | |
0 | 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[]= | |
12 | 18 | "Usage: $p [options]\n" |
0 | 19 | "\n" |
20 | "Where options are:\n" | |
12 | 21 | "$o\n"; |
0 | 22 | |
23 | ||
24 | static OptParserOpt opts[]={ | |
12 | 25 | {'o', "opt", OPT_ARG, "OPTION", "foo bar baz quk asdf jklö äölk dfgh quik aaaa bbbb cccc dddd eeee ffff"}, |
26 | {'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 | 27 | {'v', "view", 0, NULL, "asfasdf"}, |
28 | {'z', "zip", 0, NULL, "asdfasdf"}, | |
29 | {'x', "extract", 0, NULL, "asdfasdf"}, | |
12 | 30 | {0, NULL, 0, NULL, NULL} |
0 | 31 | }; |
32 | ||
17 | 33 | static OptParserCommonInfo tester3_cinfo={ |
34 | NULL, | |
35 | usage, | |
36 | NULL | |
37 | }; | |
38 | ||
0 | 39 | |
40 | int main(int argc, char *argv[]) | |
41 | { | |
42 | int opt; | |
43 | ||
12 | 44 | libtu_init(argv[0]); |
0 | 45 | |
17 | 46 | optparser_init(argc, argv, OPTP_NO_DASH, opts, &tester3_cinfo); |
0 | 47 | |
48 | while((opt=optparser_get_opt())){ | |
49 | switch(opt){ | |
50 | case 'o': | |
51 | printf("opt: %s\n", optparser_get_arg()); | |
52 | break; | |
53 | case 'f': | |
54 | printf("file: %s\n", optparser_get_arg()); | |
55 | break; | |
56 | case 'v': | |
57 | printf("view\n"); | |
58 | break; | |
59 | case 'z': | |
60 | printf("zip\n"); | |
61 | break; | |
62 | case 'x': | |
63 | printf("extract\n"); | |
64 | break; | |
65 | default: | |
66 | optparser_print_error(); | |
67 | return 1; | |
68 | } | |
69 | } | |
70 | return 0; | |
71 | } | |
72 |