This version of these things seems to work.
authorGregory Minshall <minshall@ucbvax.Berkeley.EDU>
Thu, 13 Nov 1986 08:45:04 +0000 (00:45 -0800)
committerGregory Minshall <minshall@ucbvax.Berkeley.EDU>
Thu, 13 Nov 1986 08:45:04 +0000 (00:45 -0800)
SCCS-vsn: usr.bin/tn3270/tools/mkhits/dohits.h 1.2
SCCS-vsn: usr.bin/tn3270/tools/mkhits/dohits.c 1.2
SCCS-vsn: usr.bin/tn3270/tools/mkhits/mkhits.c 1.2
SCCS-vsn: usr.bin/tn3270/tools/mkastosc/mkastosc.c 1.2

usr/src/usr.bin/tn3270/tools/mkastosc/mkastosc.c
usr/src/usr.bin/tn3270/tools/mkhits/dohits.c
usr/src/usr.bin/tn3270/tools/mkhits/dohits.h
usr/src/usr.bin/tn3270/tools/mkhits/mkhits.c

index 5a70d4c..8eb79c8 100644 (file)
 #include <ctype.h>
 
 #define        LETS_SEE_ASCII
 #include <ctype.h>
 
 #define        LETS_SEE_ASCII
-#include "../m4.out"
+#include "../keyboard/m4.out"
 #undef LETS_SEE_ASCII
 
 #undef LETS_SEE_ASCII
 
-#include "../ascebc.h"
-#include "../ebc_disp.h"
-#include "../kbd3270.h"
+#include "../ascii/ascebc.h"
+#include "../ctlr/ebc_disp.h"
+#include "../ctlr/function.h"
 
 #include "dohits.h"
 
 
 #include "dohits.h"
 
@@ -35,21 +35,73 @@ void
 main()
 {
     int scancode;
 main()
 {
     int scancode;
+    int asciicode;
     int empty;
     int i;
     int empty;
     int i;
+    int c;
     int found;
     struct hits *ph;
     struct Hits *Ph;
     TC_Ascii_t *TC;
     struct thing *this;
     int found;
     struct hits *ph;
     struct Hits *Ph;
     TC_Ascii_t *TC;
     struct thing *this;
+    struct {
+       char *shift;
+       int     scancode;
+    } tbl[128], *Pt;
+    static char *shiftof[] = { "normal", "shifted", "alted", "shiftalted" };
 
     dohits();          /* Set up "Hits" */
 
 
     dohits();          /* Set up "Hits" */
 
-    printf("struct tctokbd {\n\tenum { cantdo, normal, shifted, alted,");
+    printf("/*\n");
+    printf(" * Ascii to scancode conversion table.  First\n");
+    printf(" * 128 bytes (0-127) correspond with actual Ascii\n");
+    printf(" * characters; the rest are TC types from termcodes.m4\n");
+    printf(" * (actually, from m4.out).\n");
+    printf(" */\n");
+    printf("struct asctosc {\n");
+    printf("\tenum shiftvalue { cantdo, normal, shifted, alted,");
     printf(" shiftalted } shift;\n\tunsigned char scancode;");
     printf(" shiftalted } shift;\n\tunsigned char scancode;");
-    printf("\n} tctokbd[] = {\n");
+    printf("\n} asctosc[] = {\n");
+    /* Build the ascii part of the table. */
+    for (Ph = Hits, scancode = 0; Ph <= Hits+highestof(Hits);
+                                                       Ph++, scancode++) {
+       ph = &Ph->hits;
+       for (i = 0; i < 4; i++) {
+           if (ph->hit[i].type == character) {
+               c = Ph->name[i][0];     /* "name" of this one */
+               if (tbl[c].shift[0] == 0) {
+                   tbl[c].shift = shiftof[i];
+                   tbl[c].scancode = scancode;
+               }
+           }
+       }
+    }
+    /* Now, output the table */
+    for (Pt = tbl, asciicode = 0; Pt <= tbl+highestof(tbl); Pt++, asciicode++) {
+       if (Pt->shift[0] == 0) {
+           if (isprint(asciicode) && (asciicode != ' ')) {
+               fprintf(stderr, "Unable to produce scancode sequence for");
+               fprintf(stderr, " ASCII character [%c]!\n", asciicode);
+           }
+           printf("\t{ cantdo, 0 },\t");
+       } else {
+           printf("\t{ %s, 0x%x },", Pt->shift, Pt->scancode);
+       }
+       printf("\t/* 0x%x", asciicode);
+       if (isprint(asciicode)) {
+           printf(" [%c]", asciicode);
+       }
+       printf(" */\n");
+    }
+               
+
+    for (TC = &TC_Ascii[TC_LOWEST-TC_LOWEST];
+               TC < &TC_Ascii[TC_LOWEST_USER-TC_LOWEST]; TC++, asciicode++) {
+       printf("\t{ cantdo, 0 },\t");
+       printf("\t/* 0x%x */\n", asciicode);
+    }
     for (TC = &TC_Ascii[TC_LOWEST_USER-TC_LOWEST];
     for (TC = &TC_Ascii[TC_LOWEST_USER-TC_LOWEST];
-               TC <= &TC_Ascii[TC_HIGHEST-TC_LOWEST]; TC++) {
+               TC <= &TC_Ascii[TC_HIGHEST-TC_LOWEST]; TC++, asciicode++) {
        /* Hack for "PFK" names (which should be "PF") */
        if (memcmp(TC->tc_name, "PFK", 3) == 0) {
            static char PFonly[100] = "PF";
        /* Hack for "PFK" names (which should be "PF") */
        if (memcmp(TC->tc_name, "PFK", 3) == 0) {
            static char PFonly[100] = "PF";
@@ -88,16 +140,18 @@ main()
                            printf("shitfalted, ");
                            break;
                        }
                            printf("shitfalted, ");
                            break;
                        }
-                       printf("0x%x },\n", Ph-Hits);
+                       printf("0x%02x },", Ph-Hits);
+                       break;
                    }
                }
            }
        }
        if (!found) {
                    }
                }
            }
        }
        if (!found) {
-           printf("\t{ cantdo, 0 },\n");
+           printf("\t{ cantdo, 0 },\t");
            fprintf(stderr, "Unable to produce TC_%s with scan codes!\n",
                                TC->tc_name);
        }
            fprintf(stderr, "Unable to produce TC_%s with scan codes!\n",
                                TC->tc_name);
        }
+       printf("\t/* 0x%x - %s */\n", asciicode, TC->tc_name);
     }
     printf("};\n");
 }
     }
     printf("};\n");
 }
index 8371579..a092f6c 100644 (file)
@@ -19,9 +19,9 @@
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
-#include "../ascebc.h"
-#include "../ebc_disp.h"
-#include "../kbd3270.h"
+#include "../ascii/ascebc.h"
+#include "../ctlr/ebc_disp.h"
+#include "../ctlr/function.h"
 
 #include "dohits.h"
 
 
 #include "dohits.h"
 
@@ -29,6 +29,8 @@ struct Hits Hits[256];                /* one for each of 0x00-0xff */
 
 struct thing *table[100];
 
 
 struct thing *table[100];
 
+extern char *malloc();
+
 unsigned int
 dohash(seed, string)
 unsigned int seed;
 unsigned int
 dohash(seed, string)
 unsigned int seed;
@@ -102,6 +104,19 @@ char *file,                /* Name of file to scan */
     }
 }
 
     }
 }
 
+char *savechr(c)
+unsigned char c;
+{
+    char *foo;
+
+    foo = malloc(sizeof c);
+    if (foo == 0) {
+       fprintf(stderr, "No room for ascii characters!\n");
+       exit(1);
+    }
+    *foo = c;
+    return foo;
+}
 
 char *
 doit(hit, type, hits)
 
 char *
 doit(hit, type, hits)
@@ -118,6 +133,7 @@ struct Hits *hits;
     if (type[1] == 0) {                /* character */
        hit->type = character;
        hit->code = ebc_disp[ascebc[AE_IN][type[0]]];
     if (type[1] == 0) {                /* character */
        hit->type = character;
        hit->code = ebc_disp[ascebc[AE_IN][type[0]]];
+       return savechr(*type);          /* The character is the name */
     } else {
        for (this = firstentry(type); this; this = this->next) {
            if ((type[0] == this->name[4])
     } else {
        for (this = firstentry(type); this; this = this->next) {
            if ((type[0] == this->name[4])
@@ -131,7 +147,7 @@ struct Hits *hits;
                return this->name;
            }
        }
                return this->name;
            }
        }
-       printf("Error: Unknown type %s.\n", type);
+       fprintf(stderr, "Error: Unknown type %s.\n", type);
        return 0;
     }
 }
        return 0;
     }
 }
@@ -157,8 +173,8 @@ dohits()
      * of various FCNs.
      */
 
      * of various FCNs.
      */
 
-    scan("host3270.h", "AID_");
-    scan("kbd3270.h", "FCN_");
+    scan("../ctlr/hostctlr.h", "AID_");
+    scan("../ctlr/function.h", "FCN_");
 
     while (gets(line) != NULL) {
        if (!isdigit(line[0])) {
 
     while (gets(line) != NULL) {
        if (!isdigit(line[0])) {
@@ -177,12 +193,14 @@ dohits()
            continue;
        }
        if (scancode >= 256) {
            continue;
        }
        if (scancode >= 256) {
-           printf("Error: scancode 0x%02x for keynumber %d\n", scancode,
+           fprintf(stderr,
+               "Error: scancode 0x%02x for keynumber %d\n", scancode,
                    keynumber);
            break;
        }
        if (Hits[scancode].hits.hit[0].type != undefined) {
                    keynumber);
            break;
        }
        if (Hits[scancode].hits.hit[0].type != undefined) {
-           printf("Error: duplicate scancode 0x%02x for keynumber %d\n",
+           fprintf(stderr,
+               "Error: duplicate scancode 0x%02x for keynumber %d\n",
                    scancode, keynumber);
            break;
        }
                    scancode, keynumber);
            break;
        }
index 804058c..d13cbc2 100644 (file)
@@ -3,7 +3,7 @@
 
 #define        firstentry(x)   (table[dohash(0, (x))%highestof(table)])
 
 
 #define        firstentry(x)   (table[dohash(0, (x))%highestof(table)])
 
-extern struct Hits {
+struct Hits {
     struct hits hits;
     char *name[4];
 };
     struct hits hits;
     char *name[4];
 };
index 7fbf1f3..dee6aaa 100644 (file)
@@ -19,9 +19,9 @@
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
-#include "../ascebc.h"
-#include "../ebc_disp.h"
-#include "../kbd3270.h"
+#include "../ascii/ascebc.h"
+#include "../ctlr/ebc_disp.h"
+#include "../ctlr/function.h"
 
 #include "dohits.h"
 
 
 #include "dohits.h"