Annotation of 43BSDTahoe/ucb/tn3270/tools/mkastosc.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.