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 23 static char sccsid[] = "@(#)mkhits.c 3.1 (Berkeley) 08/11/87"; 24 #endif /* not lint */ 25 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> 45 #if defined(unix) 46 #include <strings.h> 47 #else /* defined(unix) */ 48 #include <string.h> 49 #endif /* defined(unix) */ 50 #include <ctype.h> 51 #include "../ctlr/function.h" 52 53 #include "dohits.h" 54 55 56 int 57 main(argc, argv) 58 int argc; 59 char *argv[]; 60 { 61 int scancode; 62 int empty; 63 int i; 64 struct hits *ph; 65 struct Hits *Ph; 66 char *aidfile = 0, *fcnfile = 0; 67 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" */ 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++; 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)) { 91 empty++; 92 continue; 93 } else { 94 while (empty) { 95 printf("\t{ 0, { {undefined}, {undefined}"); 96 printf(", {undefined}, {undefined} } },\n"); 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{ "); 103 switch (ph->hit[i].ctlrfcn) { 104 case undefined: 105 printf("undefined"); 106 break; 107 case FCN_CHARACTER: 108 printf("FCN_CHARACTER, 0x%02x", ph->hit[i].code); 109 break; 110 case FCN_AID: 111 printf("FCN_AID, %s", Ph->name[i]); 112 break; 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 } 121 break; 122 } 123 printf(" },\n\t"); 124 } 125 printf("} },\n"); 126 } 127 printf("};\n"); 128 return 0; 129 } 130