Commit | Line | Data |
---|---|---|
992de934 GM |
1 | /* |
2 | * Copyright (c) 1984-1987 by the Regents of the | |
3 | * University of California and by Gregory Glenn Minshall. | |
4 | * | |
5 | * Permission to use, copy, modify, and distribute these | |
6 | * programs and their documentation for any purpose and | |
7 | * without fee is hereby granted, provided that this | |
8 | * copyright and permission appear on all copies and | |
9 | * supporting documentation, the name of the Regents of | |
10 | * the University of California not be used in advertising | |
11 | * or publicity pertaining to distribution of the programs | |
12 | * without specific prior permission, and notice be given in | |
13 | * supporting documentation that copying and distribution is | |
14 | * by permission of the Regents of the University of California | |
15 | * and by Gregory Glenn Minshall. Neither the Regents of the | |
16 | * University of California nor Gregory Glenn Minshall make | |
17 | * representations about the suitability of this software | |
18 | * for any purpose. It is provided "as is" without | |
19 | * express or implied warranty. | |
20 | */ | |
21 | ||
22 | #ifndef lint | |
c578271f | 23 | static char sccsid[] = "@(#)mkhits.c 3.1 (Berkeley) %G%"; |
992de934 GM |
24 | #endif /* not lint */ |
25 | ||
c2ecccb2 GM |
26 | /* |
27 | * This program scans a file which describes a keyboard. The output | |
28 | * of the program is a series of 'C' declarations which describe a | |
29 | * mapping between (scancode, shiftstate, altstate) and 3270 functions, | |
30 | * characters, and AIDs. | |
31 | * | |
32 | * The format of the input file is as follows: | |
33 | * | |
34 | * keynumber [ scancode [ unshifted [ shifted [ alted [ shiftalted ] ] ] ] ] | |
35 | * | |
36 | * keynumber is in decimal, and starts in column 1. | |
37 | * scancode is hexadecimal. | |
38 | * unshifted, etc. - these are either a single ascii character, | |
39 | * or the name of a function or an AID-generating key. | |
40 | * | |
41 | * all fields are separated by a single space. | |
42 | */ | |
43 | ||
44 | #include <stdio.h> | |
e56fc5cb | 45 | #if defined(unix) |
577b1ba9 | 46 | #include <strings.h> |
e56fc5cb GM |
47 | #else /* defined(unix) */ |
48 | #include <string.h> | |
49 | #endif /* defined(unix) */ | |
c2ecccb2 | 50 | #include <ctype.h> |
bfbc528f | 51 | #include "../ctlr/function.h" |
c2ecccb2 GM |
52 | |
53 | #include "dohits.h" | |
54 | ||
55 | ||
e56fc5cb | 56 | int |
d5c90a59 GM |
57 | main(argc, argv) |
58 | int argc; | |
59 | char *argv[]; | |
c2ecccb2 GM |
60 | { |
61 | int scancode; | |
62 | int empty; | |
63 | int i; | |
64 | struct hits *ph; | |
65 | struct Hits *Ph; | |
d5c90a59 | 66 | char *aidfile = 0, *fcnfile = 0; |
c2ecccb2 | 67 | |
d5c90a59 GM |
68 | if (argc > 1) { |
69 | if (argv[1][0] != '-') { | |
70 | aidfile = argv[1]; | |
71 | } | |
72 | } | |
73 | if (argc > 2) { | |
74 | if (argv[2][0] != '-') { | |
75 | fcnfile = argv[2]; | |
76 | } | |
77 | } | |
78 | ||
79 | dohits(aidfile, fcnfile); /* Set up "Hits" */ | |
c2ecccb2 GM |
80 | |
81 | printf("struct hits hits[] = {\n"); | |
82 | empty = 0; | |
83 | scancode = -1; | |
84 | for (Ph = Hits; Ph < Hits+(sizeof Hits/sizeof Hits[0]); Ph++) { | |
85 | ph = &Ph->hits; | |
86 | scancode++; | |
d5c90a59 GM |
87 | if ((ph->hit[0].ctlrfcn == undefined) |
88 | && (ph->hit[1].ctlrfcn == undefined) | |
89 | && (ph->hit[2].ctlrfcn == undefined) | |
90 | && (ph->hit[3].ctlrfcn == undefined)) { | |
c2ecccb2 GM |
91 | empty++; |
92 | continue; | |
93 | } else { | |
94 | while (empty) { | |
d5c90a59 GM |
95 | printf("\t{ 0, { {undefined}, {undefined}"); |
96 | printf(", {undefined}, {undefined} } },\n"); | |
c2ecccb2 GM |
97 | empty--; |
98 | } | |
99 | } | |
100 | printf("\t{ %d, {\t/* 0x%02x */\n\t", ph->keynumber, scancode); | |
101 | for (i = 0; i < 4; i++) { | |
102 | printf("\t{ "); | |
d5c90a59 | 103 | switch (ph->hit[i].ctlrfcn) { |
c2ecccb2 | 104 | case undefined: |
d5c90a59 | 105 | printf("undefined"); |
c2ecccb2 | 106 | break; |
d5c90a59 GM |
107 | case FCN_CHARACTER: |
108 | printf("FCN_CHARACTER, 0x%02x", ph->hit[i].code); | |
c2ecccb2 | 109 | break; |
d5c90a59 GM |
110 | case FCN_AID: |
111 | printf("FCN_AID, %s", Ph->name[i]); | |
c2ecccb2 | 112 | break; |
d5c90a59 GM |
113 | case FCN_NULL: |
114 | default: | |
115 | if ((Ph->name[i] != 0) | |
116 | && (strcmp(Ph->name[i], "FCN_NULL") != 0)) { | |
117 | printf("%s", Ph->name[i]); | |
118 | } else { | |
119 | printf("undefined"); | |
120 | } | |
c2ecccb2 GM |
121 | break; |
122 | } | |
123 | printf(" },\n\t"); | |
124 | } | |
125 | printf("} },\n"); | |
126 | } | |
127 | printf("};\n"); | |
e56fc5cb | 128 | return 0; |
c2ecccb2 | 129 | } |