tester3.c

Wed, 16 Apr 2003 09:09:34 +0200

author
tuomov
date
Wed, 16 Apr 2003 09:09:34 +0200
changeset 52
0228b3741a42
parent 36
63cd573ffbcf
child 53
f8f9366b359c
permissions
-rw-r--r--

trunk: changeset 56
set_warn_handler returns default_warn_handler instead of NULL when no
other warn handlers are set.

0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
1 /*
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
2 * libtu/tester3.c
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
3 *
36
63cd573ffbcf trunk: changeset 39
tuomov
parents: 17
diff changeset
4 * Copyright (c) Tuomo Valkonen 1999-2002.
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
5 * See the included file LICENSE for details.
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
6 */
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
7
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
8 #include <stdio.h>
5
f878a9ffa3e0 trunk: changeset 8
tuomov
parents: 3
diff changeset
9
f878a9ffa3e0 trunk: changeset 8
tuomov
parents: 3
diff changeset
10 #include <libtu/util.h>
f878a9ffa3e0 trunk: changeset 8
tuomov
parents: 3
diff changeset
11 #include <libtu/misc.h>
f878a9ffa3e0 trunk: changeset 8
tuomov
parents: 3
diff changeset
12 #include <libtu/optparser.h>
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
13
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
14
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
15 static const char usage[]=
12
5fd153b29d40 trunk: changeset 15
tuomov
parents: 9
diff changeset
16 "Usage: $p [options]\n"
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
17 "\n"
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
18 "Where options are:\n"
12
5fd153b29d40 trunk: changeset 15
tuomov
parents: 9
diff changeset
19 "$o\n";
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
20
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
21
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
22 static OptParserOpt opts[]={
12
5fd153b29d40 trunk: changeset 15
tuomov
parents: 9
diff changeset
23 {'o', "opt", OPT_ARG, "OPTION", "foo bar baz quk asdf jklö äölk dfgh quik aaaa bbbb cccc dddd eeee ffff"},
5fd153b29d40 trunk: changeset 15
tuomov
parents: 9
diff changeset
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
a034888a2227 trunk: changeset 20
tuomov
parents: 12
diff changeset
25 {'v', "view", 0, NULL, "asfasdf"},
a034888a2227 trunk: changeset 20
tuomov
parents: 12
diff changeset
26 {'z', "zip", 0, NULL, "asdfasdf"},
a034888a2227 trunk: changeset 20
tuomov
parents: 12
diff changeset
27 {'x', "extract", 0, NULL, "asdfasdf"},
12
5fd153b29d40 trunk: changeset 15
tuomov
parents: 9
diff changeset
28 {0, NULL, 0, NULL, NULL}
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
29 };
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
30
17
a034888a2227 trunk: changeset 20
tuomov
parents: 12
diff changeset
31 static OptParserCommonInfo tester3_cinfo={
a034888a2227 trunk: changeset 20
tuomov
parents: 12
diff changeset
32 NULL,
a034888a2227 trunk: changeset 20
tuomov
parents: 12
diff changeset
33 usage,
a034888a2227 trunk: changeset 20
tuomov
parents: 12
diff changeset
34 NULL
a034888a2227 trunk: changeset 20
tuomov
parents: 12
diff changeset
35 };
a034888a2227 trunk: changeset 20
tuomov
parents: 12
diff changeset
36
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
37
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
38 int main(int argc, char *argv[])
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
39 {
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
40 int opt;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
41
12
5fd153b29d40 trunk: changeset 15
tuomov
parents: 9
diff changeset
42 libtu_init(argv[0]);
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
43
17
a034888a2227 trunk: changeset 20
tuomov
parents: 12
diff changeset
44 optparser_init(argc, argv, OPTP_NO_DASH, opts, &tester3_cinfo);
0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
45
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
46 while((opt=optparser_get_opt())){
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
47 switch(opt){
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
48 case 'o':
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
49 printf("opt: %s\n", optparser_get_arg());
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
50 break;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
51 case 'f':
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
52 printf("file: %s\n", optparser_get_arg());
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
53 break;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
54 case 'v':
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
55 printf("view\n");
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
56 break;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
57 case 'z':
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
58 printf("zip\n");
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
59 break;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
60 case 'x':
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
61 printf("extract\n");
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
62 break;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
63 default:
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
64 optparser_print_error();
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
65 return 1;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
66 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
67 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
68 return 0;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
69 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
70

mercurial