Commit | Line | Data |
---|---|---|
992de934 | 1 | /* |
0de390c0 KB |
2 | * Copyright (c) 1988 Regents of the University of California. |
3 | * All rights reserved. | |
992de934 | 4 | * |
0de390c0 | 5 | * Redistribution and use in source and binary forms are permitted |
b36fc510 KB |
6 | * provided that the above copyright notice and this paragraph are |
7 | * duplicated in all such forms and that any documentation, | |
8 | * advertising materials, and other materials related to such | |
9 | * distribution and use acknowledge that the software was developed | |
10 | * by the University of California, Berkeley. The name of the | |
11 | * University may not be used to endorse or promote products derived | |
12 | * from this software without specific prior written permission. | |
13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
14 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
15 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
992de934 GM |
16 | */ |
17 | ||
18 | #ifndef lint | |
0de390c0 KB |
19 | char copyright[] = |
20 | "@(#) Copyright (c) 1988 Regents of the University of California.\n\ | |
21 | All rights reserved.\n"; | |
22 | #endif /* not lint */ | |
23 | ||
24 | #ifndef lint | |
d43d1075 | 25 | static char sccsid[] = "@(#)mkhits.c 4.1 (Berkeley) %G%"; |
0de390c0 | 26 | #endif /* not lint */ |
992de934 | 27 | |
c2ecccb2 GM |
28 | /* |
29 | * This program scans a file which describes a keyboard. The output | |
30 | * of the program is a series of 'C' declarations which describe a | |
31 | * mapping between (scancode, shiftstate, altstate) and 3270 functions, | |
32 | * characters, and AIDs. | |
33 | * | |
34 | * The format of the input file is as follows: | |
35 | * | |
36 | * keynumber [ scancode [ unshifted [ shifted [ alted [ shiftalted ] ] ] ] ] | |
37 | * | |
38 | * keynumber is in decimal, and starts in column 1. | |
39 | * scancode is hexadecimal. | |
40 | * unshifted, etc. - these are either a single ascii character, | |
41 | * or the name of a function or an AID-generating key. | |
42 | * | |
43 | * all fields are separated by a single space. | |
44 | */ | |
45 | ||
46 | #include <stdio.h> | |
e56fc5cb | 47 | #if defined(unix) |
577b1ba9 | 48 | #include <strings.h> |
e56fc5cb GM |
49 | #else /* defined(unix) */ |
50 | #include <string.h> | |
51 | #endif /* defined(unix) */ | |
c2ecccb2 | 52 | #include <ctype.h> |
bfbc528f | 53 | #include "../ctlr/function.h" |
c2ecccb2 GM |
54 | |
55 | #include "dohits.h" | |
56 | ||
57 | ||
e56fc5cb | 58 | int |
d5c90a59 GM |
59 | main(argc, argv) |
60 | int argc; | |
61 | char *argv[]; | |
c2ecccb2 GM |
62 | { |
63 | int scancode; | |
64 | int empty; | |
65 | int i; | |
66 | struct hits *ph; | |
67 | struct Hits *Ph; | |
d5c90a59 | 68 | char *aidfile = 0, *fcnfile = 0; |
c2ecccb2 | 69 | |
d5c90a59 GM |
70 | if (argc > 1) { |
71 | if (argv[1][0] != '-') { | |
72 | aidfile = argv[1]; | |
73 | } | |
74 | } | |
75 | if (argc > 2) { | |
76 | if (argv[2][0] != '-') { | |
77 | fcnfile = argv[2]; | |
78 | } | |
79 | } | |
80 | ||
81 | dohits(aidfile, fcnfile); /* Set up "Hits" */ | |
c2ecccb2 GM |
82 | |
83 | printf("struct hits hits[] = {\n"); | |
84 | empty = 0; | |
85 | scancode = -1; | |
86 | for (Ph = Hits; Ph < Hits+(sizeof Hits/sizeof Hits[0]); Ph++) { | |
87 | ph = &Ph->hits; | |
88 | scancode++; | |
d5c90a59 GM |
89 | if ((ph->hit[0].ctlrfcn == undefined) |
90 | && (ph->hit[1].ctlrfcn == undefined) | |
91 | && (ph->hit[2].ctlrfcn == undefined) | |
92 | && (ph->hit[3].ctlrfcn == undefined)) { | |
c2ecccb2 GM |
93 | empty++; |
94 | continue; | |
95 | } else { | |
96 | while (empty) { | |
d5c90a59 GM |
97 | printf("\t{ 0, { {undefined}, {undefined}"); |
98 | printf(", {undefined}, {undefined} } },\n"); | |
c2ecccb2 GM |
99 | empty--; |
100 | } | |
101 | } | |
102 | printf("\t{ %d, {\t/* 0x%02x */\n\t", ph->keynumber, scancode); | |
103 | for (i = 0; i < 4; i++) { | |
104 | printf("\t{ "); | |
d5c90a59 | 105 | switch (ph->hit[i].ctlrfcn) { |
c2ecccb2 | 106 | case undefined: |
d5c90a59 | 107 | printf("undefined"); |
c2ecccb2 | 108 | break; |
d5c90a59 GM |
109 | case FCN_CHARACTER: |
110 | printf("FCN_CHARACTER, 0x%02x", ph->hit[i].code); | |
c2ecccb2 | 111 | break; |
d5c90a59 GM |
112 | case FCN_AID: |
113 | printf("FCN_AID, %s", Ph->name[i]); | |
c2ecccb2 | 114 | break; |
d5c90a59 GM |
115 | case FCN_NULL: |
116 | default: | |
117 | if ((Ph->name[i] != 0) | |
118 | && (strcmp(Ph->name[i], "FCN_NULL") != 0)) { | |
119 | printf("%s", Ph->name[i]); | |
120 | } else { | |
121 | printf("undefined"); | |
122 | } | |
c2ecccb2 GM |
123 | break; |
124 | } | |
125 | printf(" },\n\t"); | |
126 | } | |
127 | printf("} },\n"); | |
128 | } | |
129 | printf("};\n"); | |
e56fc5cb | 130 | return 0; |
c2ecccb2 | 131 | } |