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> | |
20 | #include <string.h> | |
21 | #include <ctype.h> | |
bfbc528f GM |
22 | #include "../ascii/ascebc.h" |
23 | #include "../ctlr/ebc_disp.h" | |
24 | #include "../ctlr/function.h" | |
c2ecccb2 GM |
25 | |
26 | #include "dohits.h" | |
27 | ||
28 | ||
29 | void | |
d5c90a59 GM |
30 | main(argc, argv) |
31 | int argc; | |
32 | char *argv[]; | |
c2ecccb2 GM |
33 | { |
34 | int scancode; | |
35 | int empty; | |
36 | int i; | |
37 | struct hits *ph; | |
38 | struct Hits *Ph; | |
d5c90a59 | 39 | char *aidfile = 0, *fcnfile = 0; |
c2ecccb2 | 40 | |
d5c90a59 GM |
41 | if (argc > 1) { |
42 | if (argv[1][0] != '-') { | |
43 | aidfile = argv[1]; | |
44 | } | |
45 | } | |
46 | if (argc > 2) { | |
47 | if (argv[2][0] != '-') { | |
48 | fcnfile = argv[2]; | |
49 | } | |
50 | } | |
51 | ||
52 | dohits(aidfile, fcnfile); /* Set up "Hits" */ | |
c2ecccb2 GM |
53 | |
54 | printf("struct hits hits[] = {\n"); | |
55 | empty = 0; | |
56 | scancode = -1; | |
57 | for (Ph = Hits; Ph < Hits+(sizeof Hits/sizeof Hits[0]); Ph++) { | |
58 | ph = &Ph->hits; | |
59 | scancode++; | |
d5c90a59 GM |
60 | if ((ph->hit[0].ctlrfcn == undefined) |
61 | && (ph->hit[1].ctlrfcn == undefined) | |
62 | && (ph->hit[2].ctlrfcn == undefined) | |
63 | && (ph->hit[3].ctlrfcn == undefined)) { | |
c2ecccb2 GM |
64 | empty++; |
65 | continue; | |
66 | } else { | |
67 | while (empty) { | |
d5c90a59 GM |
68 | printf("\t{ 0, { {undefined}, {undefined}"); |
69 | printf(", {undefined}, {undefined} } },\n"); | |
c2ecccb2 GM |
70 | empty--; |
71 | } | |
72 | } | |
73 | printf("\t{ %d, {\t/* 0x%02x */\n\t", ph->keynumber, scancode); | |
74 | for (i = 0; i < 4; i++) { | |
75 | printf("\t{ "); | |
d5c90a59 | 76 | switch (ph->hit[i].ctlrfcn) { |
c2ecccb2 | 77 | case undefined: |
d5c90a59 | 78 | printf("undefined"); |
c2ecccb2 | 79 | break; |
d5c90a59 GM |
80 | case FCN_CHARACTER: |
81 | printf("FCN_CHARACTER, 0x%02x", ph->hit[i].code); | |
c2ecccb2 | 82 | break; |
d5c90a59 GM |
83 | case FCN_AID: |
84 | printf("FCN_AID, %s", Ph->name[i]); | |
c2ecccb2 | 85 | break; |
d5c90a59 GM |
86 | case FCN_NULL: |
87 | default: | |
88 | if ((Ph->name[i] != 0) | |
89 | && (strcmp(Ph->name[i], "FCN_NULL") != 0)) { | |
90 | printf("%s", Ph->name[i]); | |
91 | } else { | |
92 | printf("undefined"); | |
93 | } | |
c2ecccb2 GM |
94 | break; |
95 | } | |
96 | printf(" },\n\t"); | |
97 | } | |
98 | printf("} },\n"); | |
99 | } | |
100 | printf("};\n"); | |
101 | } |