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> 22 #include "../ascii/ascebc.h" 23 #include "../ctlr/ebc_disp.h" 24 #include "../ctlr/function.h" 25 26 #include "dohits.h" 27 28 29 void 30 main(argc, argv) 31 int argc; 32 char *argv[]; 33 { 34 int scancode; 35 int empty; 36 int i; 37 struct hits *ph; 38 struct Hits *Ph; 39 char *aidfile = 0, *fcnfile = 0; 40 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" */ 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++; 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)) { 64 empty++; 65 continue; 66 } else { 67 while (empty) { 68 printf("\t{ 0, { {undefined}, {undefined}"); 69 printf(", {undefined}, {undefined} } },\n"); 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{ "); 76 switch (ph->hit[i].ctlrfcn) { 77 case undefined: 78 printf("undefined"); 79 break; 80 case FCN_CHARACTER: 81 printf("FCN_CHARACTER, 0x%02x", ph->hit[i].code); 82 break; 83 case FCN_AID: 84 printf("FCN_AID, %s", Ph->name[i]); 85 break; 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 } 94 break; 95 } 96 printf(" },\n\t"); 97 } 98 printf("} },\n"); 99 } 100 printf("};\n"); 101 } 102