| 1 | /* |
| 2 | * Copyright (c) 1988 Regents of the University of California. |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms are permitted |
| 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. |
| 16 | */ |
| 17 | |
| 18 | #ifndef lint |
| 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 |
| 25 | static char sccsid[] = "@(#)mkhits.c 4.1 (Berkeley) %G%"; |
| 26 | #endif /* not lint */ |
| 27 | |
| 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> |
| 47 | #if defined(unix) |
| 48 | #include <strings.h> |
| 49 | #else /* defined(unix) */ |
| 50 | #include <string.h> |
| 51 | #endif /* defined(unix) */ |
| 52 | #include <ctype.h> |
| 53 | #include "../ctlr/function.h" |
| 54 | |
| 55 | #include "dohits.h" |
| 56 | |
| 57 | |
| 58 | int |
| 59 | main(argc, argv) |
| 60 | int argc; |
| 61 | char *argv[]; |
| 62 | { |
| 63 | int scancode; |
| 64 | int empty; |
| 65 | int i; |
| 66 | struct hits *ph; |
| 67 | struct Hits *Ph; |
| 68 | char *aidfile = 0, *fcnfile = 0; |
| 69 | |
| 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" */ |
| 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++; |
| 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)) { |
| 93 | empty++; |
| 94 | continue; |
| 95 | } else { |
| 96 | while (empty) { |
| 97 | printf("\t{ 0, { {undefined}, {undefined}"); |
| 98 | printf(", {undefined}, {undefined} } },\n"); |
| 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{ "); |
| 105 | switch (ph->hit[i].ctlrfcn) { |
| 106 | case undefined: |
| 107 | printf("undefined"); |
| 108 | break; |
| 109 | case FCN_CHARACTER: |
| 110 | printf("FCN_CHARACTER, 0x%02x", ph->hit[i].code); |
| 111 | break; |
| 112 | case FCN_AID: |
| 113 | printf("FCN_AID, %s", Ph->name[i]); |
| 114 | break; |
| 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 | } |
| 123 | break; |
| 124 | } |
| 125 | printf(" },\n\t"); |
| 126 | } |
| 127 | printf("} },\n"); |
| 128 | } |
| 129 | printf("};\n"); |
| 130 | return 0; |
| 131 | } |