|
|
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 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[] = "@(#)mkastosc.c 4.1 (Berkeley) 12/4/88"; ! 26: #endif /* not lint */ ! 27: ! 28: #include <stdio.h> ! 29: #if defined(unix) ! 30: #include <strings.h> ! 31: #else /* defined(unix) */ ! 32: #include <string.h> ! 33: #endif /* defined(unix) */ ! 34: #include <ctype.h> ! 35: ! 36: #include "../general/general.h" ! 37: #include "../ctlr/function.h" ! 38: ! 39: #include "dohits.h" ! 40: ! 41: static struct tbl { ! 42: unsigned char ! 43: scancode, ! 44: used; ! 45: char ! 46: *shiftstate; ! 47: } tbl[128]; ! 48: ! 49: int ! 50: main(argc, argv) ! 51: int argc; ! 52: char *argv[]; ! 53: { ! 54: int scancode; ! 55: int asciicode; ! 56: int empty; ! 57: int i; ! 58: int c; ! 59: int found; ! 60: struct hits *ph; ! 61: struct Hits *Ph; ! 62: struct thing *this; ! 63: struct thing **attable; ! 64: struct tbl *Pt; ! 65: static char *shiftof[] = ! 66: { "0", "SHIFT_UPSHIFT", "SHIFT_ALT", "SHIFT_ALT|SHIFT_UPSHIFT" }; ! 67: char *aidfile = 0, *fcnfile = 0; ! 68: ! 69: if (argc > 1) { ! 70: if (argv[1][0] != '-') { ! 71: aidfile = argv[1]; ! 72: } ! 73: } ! 74: if (argc > 2) { ! 75: if (argv[2][0] != '-') { ! 76: fcnfile = argv[2]; ! 77: } ! 78: } ! 79: ! 80: dohits(aidfile, fcnfile); /* Set up "Hits" */ ! 81: ! 82: printf("/*\n"); ! 83: printf(" * Ascii to scancode conversion table. First\n"); ! 84: printf(" * 128 bytes (0-127) correspond with actual Ascii\n"); ! 85: printf(" * characters; the rest are functions from ctrl/function.h\n"); ! 86: printf(" */\n"); ! 87: /* Build the ascii part of the table. */ ! 88: for (Ph = Hits, scancode = 0; Ph <= Hits+highestof(Hits); ! 89: Ph++, scancode++) { ! 90: ph = &Ph->hits; ! 91: for (i = 0; i < 4; i++) { ! 92: if (ph->hit[i].ctlrfcn == FCN_CHARACTER) { ! 93: c = Ph->name[i][0]; /* "name" of this one */ ! 94: if (tbl[c].used == 0) { ! 95: tbl[c].used = 1; ! 96: tbl[c].shiftstate = shiftof[i]; ! 97: tbl[c].scancode = scancode; ! 98: } ! 99: } ! 100: } ! 101: } ! 102: /* Now, output the table */ ! 103: for (Pt = tbl, asciicode = 0; Pt <= tbl+highestof(tbl); Pt++, asciicode++) { ! 104: if (Pt->used == 0) { ! 105: if (isprint(asciicode) && (asciicode != ' ')) { ! 106: fprintf(stderr, "Unable to produce scancode sequence for"); ! 107: fprintf(stderr, " ASCII character [%c]!\n", asciicode); ! 108: } ! 109: printf("\t{ 0, 0, undefined, 0 },\t"); ! 110: } else { ! 111: printf("\t{ 0x%02x, %s, FCN_CHARACTER, 0 },", ! 112: Pt->scancode, Pt->shiftstate); ! 113: } ! 114: printf("\t/* 0x%x", asciicode); ! 115: if (isprint(asciicode)) { ! 116: printf(" [%c]", asciicode); ! 117: } ! 118: printf(" */\n"); ! 119: } ! 120: ! 121: ! 122: for (attable = &table[0]; attable <= &table[highestof(table)]; attable++) { ! 123: for (this = *attable; this; this = this->next) { ! 124: Ph = this->hits; ! 125: if (Ph == 0) { ! 126: continue; ! 127: } ! 128: for (i = 0; i < 4; i++) { ! 129: if ((Ph->name[i] != 0) && ! 130: (Ph->name[i][0] == this->name[0]) && ! 131: (strcmp(Ph->name[i], this->name) == 0)) { ! 132: printf("\t{ 0x%02x, %s, ", ! 133: Ph-Hits, shiftof[i]); ! 134: if (memcmp("AID_", this->name, 4) == 0) { /* AID key */ ! 135: printf("FCN_AID, "); ! 136: } else { ! 137: printf("%s, ", Ph->name[i]); ! 138: } ! 139: if (memcmp("PF", this->name+4, 2) == 0) { ! 140: printf("\"PFK%s\" },\n", Ph->name[i]+4+2); ! 141: } else { ! 142: printf("\"%s\" },\n", Ph->name[i]+4); ! 143: } ! 144: } ! 145: } ! 146: } ! 147: } ! 148: ! 149: return 0; ! 150: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.