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