This source file includes following definitions.
- main
1 #include "package.h"
2 #include "disassemble.h"
3 #include "load.h"
4
5
6
7
8 static struct option longopts[] = {
9 {"version", no_argument, NULL, 'v' },
10 {"help", no_argument, NULL, 'h'},
11 {0, 0, 0, 0},
12 };
13
14
15
16
17
18
19
20
21
22 int main(int argc, char *argv[])
23 {
24 int opt = 0;
25 int stat = 0;
26 const char *version = PACKAGE_VERSION;
27 const char *cmdversion = "disassemble of YACASL2 version %s\n";
28 const char *usage = "Usage: %s [-vh] FILE\n";
29
30
31 cerr_init();
32 addcerrlist_load();
33
34
35 while((opt = getopt_long(argc, argv, "vh", longopts, NULL)) != -1) {
36 switch(opt) {
37 case 'v':
38 fprintf(stdout, cmdversion, version);
39 goto casl2revfin;
40 case 'h':
41 fprintf(stdout, usage, argv[0]);
42 goto casl2revfin;
43 case '?':
44 fprintf(stderr, usage, argv[0]);
45 setcerr(212, "");
46 goto casl2revfin;
47 }
48 }
49 if(argv[optind] == NULL) {
50 setcerr(211, "");
51 fprintf(stderr, "disassemble error - %d: %s\n", cerr->num, cerr->msg);
52 goto casl2revfin;
53 }
54 disassemble_file(argv[optind]);
55 casl2revfin:
56 if(cerr->num > 0) {
57 stat = 1;
58 }
59 freecerr();
60 return stat;
61 }