This source file includes following definitions.
- main
1 #include "package.h"
2 #include "word.h"
3
4
5
6
7 static struct option longopts[] = {
8 { "arithmetic", no_argument, NULL, 'a' },
9 { "logical", no_argument, NULL, 'l' },
10 { "version", no_argument, NULL, 'v' },
11 { "help", no_argument, NULL, 'h' },
12 { 0, 0, 0, 0 },
13 };
14
15
16
17
18
19
20
21
22
23 int main(int argc, char *argv[])
24 {
25 bool logicalmode = false;
26 int opt = 0;
27 int stat = 0;
28 WORD word = 0;
29 const char *version = PACKAGE_VERSION;
30 const char *cmdversion = "dumpword of YACASL2 version %s\n";
31 const char *usage = "Usage: %s [-alh] WORD\n";
32
33
34 cerr_init();
35 addcerrlist_word();
36
37
38 while((opt = getopt_long(argc, argv, "alvh", longopts, NULL)) != -1) {
39 switch(opt) {
40 case 'l':
41 logicalmode = true;
42 break;
43 case 'v':
44 fprintf(stdout, cmdversion, version);
45 goto dumpwordfin;
46 case 'h':
47 fprintf(stdout, usage, argv[0]);
48 goto dumpwordfin;
49 case '?':
50 fprintf(stderr, usage, argv[0]);
51 setcerr(999, "");
52 goto dumpwordfin;
53 }
54 }
55
56 if(argv[optind] == NULL) {
57 fprintf(stderr, usage, argv[0]);
58 setcerr(999, "");
59 goto dumpwordfin;
60 }
61
62 word = nh2word(argv[optind]);
63 if(cerr->num > 0) {
64 fprintf(stderr, "Dumpword Error - %d: %s\n", cerr->num, cerr->msg);
65 goto dumpwordfin;
66 }
67 fprintf(stdout, "%6s: ", argv[optind]);
68 print_dumpword(word, logicalmode);
69 fprintf(stdout, "\n");
70 dumpwordfin:
71 if(cerr->num > 0) {
72 stat = 1;
73 }
74 freecerr();
75 return stat;
76 }