Commit | Line | Data |
---|---|---|
c2ecccb2 GM |
1 | /* |
2 | * This program scans a file which describes a keyboard. The output | |
3 | * of the program is a series of 'C' declarations which describe a | |
4 | * mapping between (scancode, shiftstate, altstate) and 3270 functions, | |
5 | * characters, and AIDs. | |
6 | * | |
7 | * The format of the input file is as follows: | |
8 | * | |
9 | * keynumber [ scancode [ unshifted [ shifted [ alted [ shiftalted ] ] ] ] ] | |
10 | * | |
11 | * keynumber is in decimal, and starts in column 1. | |
12 | * scancode is hexadecimal. | |
13 | * unshifted, etc. - these are either a single ascii character, | |
14 | * or the name of a function or an AID-generating key. | |
15 | * | |
16 | * all fields are separated by a single space. | |
17 | */ | |
18 | ||
19 | #include <stdio.h> | |
e56fc5cb | 20 | #if defined(unix) |
577b1ba9 | 21 | #include <strings.h> |
e56fc5cb GM |
22 | #else /* defined(unix) */ |
23 | #include <string.h> | |
24 | #endif /* defined(unix) */ | |
c2ecccb2 | 25 | #include <ctype.h> |
bfbc528f | 26 | #include "../ctlr/function.h" |
c2ecccb2 GM |
27 | |
28 | #include "dohits.h" | |
29 | ||
30 | ||
e56fc5cb | 31 | int |
d5c90a59 GM |
32 | main(argc, argv) |
33 | int argc; | |
34 | char *argv[]; | |
c2ecccb2 GM |
35 | { |
36 | int scancode; | |
37 | int empty; | |
38 | int i; | |
39 | struct hits *ph; | |
40 | struct Hits *Ph; | |
d5c90a59 | 41 | char *aidfile = 0, *fcnfile = 0; |
c2ecccb2 | 42 | |
d5c90a59 GM |
43 | if (argc > 1) { |
44 | if (argv[1][0] != '-') { | |
45 | aidfile = argv[1]; | |
46 | } | |
47 | } | |
48 | if (argc > 2) { | |
49 | if (argv[2][0] != '-') { | |
50 | fcnfile = argv[2]; | |
51 | } | |
52 | } | |
53 | ||
54 | dohits(aidfile, fcnfile); /* Set up "Hits" */ | |
c2ecccb2 GM |
55 | |
56 | printf("struct hits hits[] = {\n"); | |
57 | empty = 0; | |
58 | scancode = -1; | |
59 | for (Ph = Hits; Ph < Hits+(sizeof Hits/sizeof Hits[0]); Ph++) { | |
60 | ph = &Ph->hits; | |
61 | scancode++; | |
d5c90a59 GM |
62 | if ((ph->hit[0].ctlrfcn == undefined) |
63 | && (ph->hit[1].ctlrfcn == undefined) | |
64 | && (ph->hit[2].ctlrfcn == undefined) | |
65 | && (ph->hit[3].ctlrfcn == undefined)) { | |
c2ecccb2 GM |
66 | empty++; |
67 | continue; | |
68 | } else { | |
69 | while (empty) { | |
d5c90a59 GM |
70 | printf("\t{ 0, { {undefined}, {undefined}"); |
71 | printf(", {undefined}, {undefined} } },\n"); | |
c2ecccb2 GM |
72 | empty--; |
73 | } | |
74 | } | |
75 | printf("\t{ %d, {\t/* 0x%02x */\n\t", ph->keynumber, scancode); | |
76 | for (i = 0; i < 4; i++) { | |
77 | printf("\t{ "); | |
d5c90a59 | 78 | switch (ph->hit[i].ctlrfcn) { |
c2ecccb2 | 79 | case undefined: |
d5c90a59 | 80 | printf("undefined"); |
c2ecccb2 | 81 | break; |
d5c90a59 GM |
82 | case FCN_CHARACTER: |
83 | printf("FCN_CHARACTER, 0x%02x", ph->hit[i].code); | |
c2ecccb2 | 84 | break; |
d5c90a59 GM |
85 | case FCN_AID: |
86 | printf("FCN_AID, %s", Ph->name[i]); | |
c2ecccb2 | 87 | break; |
d5c90a59 GM |
88 | case FCN_NULL: |
89 | default: | |
90 | if ((Ph->name[i] != 0) | |
91 | && (strcmp(Ph->name[i], "FCN_NULL") != 0)) { | |
92 | printf("%s", Ph->name[i]); | |
93 | } else { | |
94 | printf("undefined"); | |
95 | } | |
c2ecccb2 GM |
96 | break; |
97 | } | |
98 | printf(" },\n\t"); | |
99 | } | |
100 | printf("} },\n"); | |
101 | } | |
102 | printf("};\n"); | |
e56fc5cb | 103 | return 0; |
c2ecccb2 | 104 | } |