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