Change FCN_... from #define's into enum's.
authorGregory Minshall <minshall@ucbvax.Berkeley.EDU>
Mon, 17 Nov 1986 07:22:23 +0000 (23:22 -0800)
committerGregory Minshall <minshall@ucbvax.Berkeley.EDU>
Mon, 17 Nov 1986 07:22:23 +0000 (23:22 -0800)
SCCS-vsn: usr.bin/tn3270/tools/mkhits/dohits.c 1.3
SCCS-vsn: usr.bin/tn3270/tools/mkhits/mkhits.c 1.3
SCCS-vsn: usr.bin/tn3270/tools/mkastosc/mkastosc.c 1.3

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/mkhits.c

index 8eb79c8..8973ef6 100644 (file)
@@ -32,7 +32,9 @@
 
 
 void
 
 
 void
-main()
+main(argc, argv)
+int    argc;
+char   *argv[];
 {
     int scancode;
     int asciicode;
 {
     int scancode;
     int asciicode;
@@ -49,8 +51,20 @@ main()
        int     scancode;
     } tbl[128], *Pt;
     static char *shiftof[] = { "normal", "shifted", "alted", "shiftalted" };
        int     scancode;
     } tbl[128], *Pt;
     static char *shiftof[] = { "normal", "shifted", "alted", "shiftalted" };
+    char *aidfile = 0, *fcnfile = 0;
 
 
-    dohits();          /* Set up "Hits" */
+    if (argc > 1) {
+       if (argv[1][0] != '-') {
+           aidfile = argv[1];
+       }
+    }
+    if (argc > 2) {
+       if (argv[2][0] != '-') {
+           fcnfile = argv[2];
+       }
+    }
+
+    dohits(aidfile, fcnfile);          /* Set up "Hits" */
 
     printf("/*\n");
     printf(" * Ascii to scancode conversion table.  First\n");
 
     printf("/*\n");
     printf(" * Ascii to scancode conversion table.  First\n");
@@ -67,7 +81,7 @@ main()
                                                        Ph++, scancode++) {
        ph = &Ph->hits;
        for (i = 0; i < 4; i++) {
                                                        Ph++, scancode++) {
        ph = &Ph->hits;
        for (i = 0; i < 4; i++) {
-           if (ph->hit[i].type == character) {
+           if (ph->hit[i].ctlrfcn == FCN_CHARACTER) {
                c = Ph->name[i][0];     /* "name" of this one */
                if (tbl[c].shift[0] == 0) {
                    tbl[c].shift = shiftof[i];
                c = Ph->name[i][0];     /* "name" of this one */
                if (tbl[c].shift[0] == 0) {
                    tbl[c].shift = shiftof[i];
index a092f6c..7bc87b8 100644 (file)
@@ -52,6 +52,8 @@ char *string;
 
 void
 add(first, second, value)
 
 void
 add(first, second, value)
+char *first, *second;
+int value;
 {
     struct thing **item, *this;
 
 {
     struct thing **item, *this;
 
@@ -65,8 +67,38 @@ add(first, second, value)
 }
 
 void
 }
 
 void
-scan(file, prefix)
-char *file,            /* Name of file to scan */
+scanwhite(file, prefix)
+char *file,            /* Name of file to scan for whitespace prefix */
+     *prefix;          /* prefix of what should be picked up */
+{
+    FILE *ourfile;
+    char compare[100];
+    char what[100], value[100];
+    char line[200];
+
+    sprintf(compare, " %s%%[^,\t \n]", prefix);
+    if ((ourfile = fopen(file, "r")) == NULL) {
+       perror("fopen");
+       exit(1);
+    }
+    while (!feof(ourfile)) {
+       if (fscanf(ourfile, compare,  what) == 1) {
+           add(prefix, what, 0);
+       }
+       do {
+           if (fgets(line, sizeof line, ourfile) == NULL) {
+               if (!feof(ourfile)) {
+                   perror("fgets");
+               }
+               break;
+           }
+       } while (line[strlen(line)-1] != '\n');
+    }
+}
+
+void
+scandefine(file, prefix)
+char *file,            /* Name of file to scan for #define prefix */
      *prefix;          /* prefix of what should be picked up */
 {
     FILE *ourfile;
      *prefix;          /* prefix of what should be picked up */
 {
     FILE *ourfile;
@@ -126,12 +158,12 @@ struct Hits *hits;
 {
     struct thing *this;
 
 {
     struct thing *this;
 
-    hit->type = illegal;
+    hit->ctlrfcn = FCN_NULL;
     if (type[0] == 0) {
        return 0;
     }
     if (type[1] == 0) {                /* character */
     if (type[0] == 0) {
        return 0;
     }
     if (type[1] == 0) {                /* character */
-       hit->type = character;
+       hit->ctlrfcn = FCN_CHARACTER;
        hit->code = ebc_disp[ascebc[AE_IN][type[0]]];
        return savechr(*type);          /* The character is the name */
     } else {
        hit->code = ebc_disp[ascebc[AE_IN][type[0]]];
        return savechr(*type);          /* The character is the name */
     } else {
@@ -140,9 +172,9 @@ struct Hits *hits;
                                && (strcmp(type, this->name+4) == 0)) {
                this->hits = hits;
                if (this->name[0] == 'F') {
                                && (strcmp(type, this->name+4) == 0)) {
                this->hits = hits;
                if (this->name[0] == 'F') {
-                   hit->type = function;
+                   hit->ctlrfcn = FCN_NULL;    /* XXX */
                } else {
                } else {
-                   hit->type = aid;
+                   hit->ctlrfcn = FCN_AID;
                }
                return this->name;
            }
                }
                return this->name;
            }
@@ -154,7 +186,8 @@ struct Hits *hits;
 
 
 void
 
 
 void
-dohits()
+dohits(aidfile, fcnfile)
+char   *aidfile, *fcnfile;
 {
     unsigned char plain[100], shifted[100], alted[100], shiftalted[100];
     unsigned char line[200];
 {
     unsigned char plain[100], shifted[100], alted[100], shiftalted[100];
     unsigned char line[200];
@@ -173,8 +206,14 @@ dohits()
      * of various FCNs.
      */
 
      * of various FCNs.
      */
 
-    scan("../ctlr/hostctlr.h", "AID_");
-    scan("../ctlr/function.h", "FCN_");
+    if (aidfile == 0) {
+       aidfile = "../ctlr/hostctlr.h";
+    }
+    scandefine(aidfile, "AID_");
+    if (fcnfile == 0) {
+        fcnfile = "../ctlr/function.h";
+    }
+    scanwhite(fcnfile, "FCN_");
 
     while (gets(line) != NULL) {
        if (!isdigit(line[0])) {
 
     while (gets(line) != NULL) {
        if (!isdigit(line[0])) {
@@ -198,7 +237,7 @@ dohits()
                    keynumber);
            break;
        }
                    keynumber);
            break;
        }
-       if (Hits[scancode].hits.hit[0].type != undefined) {
+       if (Hits[scancode].hits.hit[0].ctlrfcn != undefined) {
            fprintf(stderr,
                "Error: duplicate scancode 0x%02x for keynumber %d\n",
                    scancode, keynumber);
            fprintf(stderr,
                "Error: duplicate scancode 0x%02x for keynumber %d\n",
                    scancode, keynumber);
index dee6aaa..4ca070e 100644 (file)
 
 
 void
 
 
 void
-main()
+main(argc, argv)
+int    argc;
+char   *argv[];
 {
     int scancode;
     int empty;
     int i;
     struct hits *ph;
     struct Hits *Ph;
 {
     int scancode;
     int empty;
     int i;
     struct hits *ph;
     struct Hits *Ph;
+    char *aidfile = 0, *fcnfile = 0;
 
 
-    dohits();          /* Set up "Hits" */
+    if (argc > 1) {
+       if (argv[1][0] != '-') {
+           aidfile = argv[1];
+       }
+    }
+    if (argc > 2) {
+       if (argv[2][0] != '-') {
+           fcnfile = argv[2];
+       }
+    }
+
+    dohits(aidfile, fcnfile);          /* Set up "Hits" */
 
     printf("struct hits hits[] = {\n");
     empty = 0;
 
     printf("struct hits hits[] = {\n");
     empty = 0;
@@ -43,35 +57,40 @@ main()
     for (Ph = Hits; Ph < Hits+(sizeof Hits/sizeof Hits[0]); Ph++) {
        ph = &Ph->hits;
        scancode++;
     for (Ph = Hits; Ph < Hits+(sizeof Hits/sizeof Hits[0]); Ph++) {
        ph = &Ph->hits;
        scancode++;
-       if ((ph->hit[0].type == undefined)
-               && (ph->hit[1].type == undefined)
-               && (ph->hit[2].type == undefined)
-               && (ph->hit[3].type == undefined)) {
+       if ((ph->hit[0].ctlrfcn == undefined)
+               && (ph->hit[1].ctlrfcn == undefined)
+               && (ph->hit[2].ctlrfcn == undefined)
+               && (ph->hit[3].ctlrfcn == undefined)) {
            empty++;
            continue;
        } else {
            while (empty) {
            empty++;
            continue;
        } else {
            while (empty) {
-               printf("\t{ 0, {\t{ illegal },\t{ illegal }");
-               printf(",\t{ illegal },\t{ illegal } } },\n");
+               printf("\t{ 0, {  {undefined}, {undefined}");
+               printf(", {undefined}, {undefined}  } },\n");
                empty--;
            }
        }
        printf("\t{ %d, {\t/* 0x%02x */\n\t", ph->keynumber, scancode);
        for (i = 0; i < 4; i++) {
            printf("\t{ ");
                empty--;
            }
        }
        printf("\t{ %d, {\t/* 0x%02x */\n\t", ph->keynumber, scancode);
        for (i = 0; i < 4; i++) {
            printf("\t{ ");
-           switch (ph->hit[i].type) {
+           switch (ph->hit[i].ctlrfcn) {
            case undefined:
            case undefined:
-           case illegal:
-               printf("illegal");
+               printf("undefined");
                break;
                break;
-           case character:
-               printf("character, 0x%02x", ph->hit[i].code);
+           case FCN_CHARACTER:
+               printf("FCN_CHARACTER, 0x%02x", ph->hit[i].code);
                break;
                break;
-           case function:
-               printf("function, %s", Ph->name[i]);
+           case FCN_AID:
+               printf("FCN_AID, %s", Ph->name[i]);
                break;
                break;
-           case aid:
-               printf("aid, %s", Ph->name[i]);
+           case FCN_NULL:
+           default:
+               if ((Ph->name[i] != 0)
+                                   && (strcmp(Ph->name[i], "FCN_NULL") != 0)) {
+                   printf("%s", Ph->name[i]);
+               } else {
+                   printf("undefined");
+               }
                break;
            }
            printf(" },\n\t");
                break;
            }
            printf(" },\n\t");