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