tester3.c

Tue, 15 Feb 2005 18:57:52 +0100

author
tailor@f281.ttorni.ton.tut.fi
date
Tue, 15 Feb 2005 18:57:52 +0100
changeset 0
86b7f6f9c5c0
child 3
b1fbfab67908
permissions
-rw-r--r--

Tailorization of trunk
Import of the upstream sources from the repository

http://tao.uab.es/ion/svn/libtu/trunk

as of revision 2

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 *
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
4 * Copyright (c) Tuomo Valkonen 1999-2000.
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
5 *
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
6 * This file is distributed under the terms of the "Artistic License".
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
7 * See the included file LICENSE for details.
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
8 */
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
9
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
10 #include <stdio.h>
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
11 #include "include/util.h"
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
12 #include "include/misc.h"
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
13 #include "include/optparser.h"
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
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
16 static const char usage[]=
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
17 "$u [options]\n"
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
18 "\n"
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
19 "Where options are:\n"
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
20 "\n"
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
21 " -o, -f, -v, -z, -x\n"
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
22 "$c \n"
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
23 "\n";
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
24
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
25
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
26 static ProgInfo proginfo={
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
27 "Tester III",
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
28 "0.1",
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
29 "foo",
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
30 "bar",
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
31 usage
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
32 };
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
33
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
34
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
35 static OptParserOpt opts[]={
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
36 {'o', "opt", OPT_IMM_ARG},
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
37 {'f', "file", OPT_CHAINABLE|OPT_NO_DASH|OPT_ARG},
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
38 {'v', "view", OPT_CHAINABLE|OPT_NO_DASH},
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
39 {'z', "zip", OPT_CHAINABLE|OPT_NO_DASH},
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
40 {'x', "extract", OPT_CHAINABLE|OPT_NO_DASH},
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
41 {0, NULL, 0}
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
42 };
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
43
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
44
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
45 int main(int argc, char *argv[])
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
46 {
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
47 int opt;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
48
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
49 libtu_init(&argc, argv, &proginfo);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
50
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
51 optparser_init(argc, argv, opts);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
52
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
53 while((opt=optparser_get_opt())){
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
54 switch(opt){
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
55 case 'o':
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
56 printf("opt: %s\n", optparser_get_arg());
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
57 break;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
58 case 'f':
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
59 printf("file: %s\n", optparser_get_arg());
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
60 break;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
61 case 'v':
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
62 printf("view\n");
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
63 break;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
64 case 'z':
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
65 printf("zip\n");
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
66 break;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
67 case 'x':
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
68 printf("extract\n");
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
69 break;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
70 default:
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
71 optparser_print_error();
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
72 return 1;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
73 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
74 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
75 return 0;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
76 }
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
77

mercurial