add command prefix recognition
authorSam Leffler <sam@ucbvax.Berkeley.EDU>
Mon, 3 Oct 1983 14:00:16 +0000 (06:00 -0800)
committerSam Leffler <sam@ucbvax.Berkeley.EDU>
Mon, 3 Oct 1983 14:00:16 +0000 (06:00 -0800)
SCCS-vsn: usr.bin/systat/cmds.c 1.2
SCCS-vsn: usr.bin/systat/main.c 1.6
SCCS-vsn: usr.bin/systat/systat.h 1.3

usr/src/usr.bin/systat/cmds.c
usr/src/usr.bin/systat/main.c
usr/src/usr.bin/systat/systat.h

index aefd22b..646fb9c 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)cmds.c     1.1 (Lucasfilm) %G%";
+static char sccsid[] = "@(#)cmds.c     1.2 (Lucasfilm) %G%";
 #endif
 
 /*
 #endif
 
 /*
@@ -19,17 +19,13 @@ command(cmd)
                 ;
         if (*cp)
                 *cp++ = '\0';
                 ;
         if (*cp)
                 *cp++ = '\0';
-        if (strcmp(cmd, "quit") == 0)
+        if (strcmp(cmd, "quit") == 0 || strcmp(cmd, "q") == 0)
                 die();
                 die();
-        if (strcmp(cmd, "status") == 0 || strcmp(cmd, "help") == 0) {
-                status();
-                return;
-        }
        if (strcmp(cmd, "load") == 0) {
                load();
                return;
        }
        if (strcmp(cmd, "load") == 0) {
                load();
                return;
        }
-       p = getcmd(cmd);
+       p = lookup(cmd);
         if (p != (struct cmdtab *)-1) {
                 if (curcmd == p)
                         return;
         if (p != (struct cmdtab *)-1) {
                 if (curcmd == p)
                         return;
@@ -55,7 +51,7 @@ command(cmd)
         /* commands with arguments */
         for (; *cp && isspace(*cp); cp++)
                 ;
         /* commands with arguments */
         for (; *cp && isspace(*cp); cp++)
                 ;
-        if (strcmp(cmd, "start") == 0) {
+        if (strcmp(cmd, "start") == 0 || strcmp(cmd, "interval") == 0) {
                 int x;
 
                 if (*cp == '\0')
                 int x;
 
                 if (*cp == '\0')
@@ -80,7 +76,7 @@ command(cmd)
 }
 
 struct cmdtab *
 }
 
 struct cmdtab *
-getcmd(name)
+lookup(name)
        register char *name;
 {
        register char *p, *q;
        register char *name;
 {
        register char *p, *q;
index 94179b4..39fc134 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)main.c     1.5 (Lucasfilm) %G%";
+static char sccsid[] = "@(#)main.c     1.6 (Lucasfilm) %G%";
 #endif
 
 #include "systat.h"
 #endif
 
 #include "systat.h"
@@ -33,10 +33,8 @@ main(argc, argv)
                if (argv[0][0] == '-') {
                        struct cmdtab *p;
 
                if (argv[0][0] == '-') {
                        struct cmdtab *p;
 
-                       for (p = cmdtab; *p->c_name; p++)
-                               if (strcmp(p->c_name, &argv[0][1]) == 0)
-                                       break;
-                       if (*p->c_name == 0) {
+                       p = lookup(&argv[0][1]);
+                       if (p == (struct cmdtab *)-1) {
                                fprintf(stderr, "%s: unknown request\n",
                                    &argv[0][1]);
                                exit(1);
                                fprintf(stderr, "%s: unknown request\n",
                                    &argv[0][1]);
                                exit(1);
@@ -94,9 +92,7 @@ main(argc, argv)
                die();
        }
 
                die();
        }
 
-#ifdef notdef
         gethostname(hostname, sizeof (hostname));
         gethostname(hostname, sizeof (hostname));
-#endif
         lseek(kmem, nlst[X_CCPU].n_value, 0);
         read(kmem, &ccpu, sizeof (ccpu));
         lccpu = log(ccpu);
         lseek(kmem, nlst[X_CCPU].n_value, 0);
         read(kmem, &ccpu, sizeof (ccpu));
         lccpu = log(ccpu);
index 74afc03..7631881 100644 (file)
@@ -52,6 +52,7 @@ struct  cmdtab {
 
 struct cmdtab *curcmd;
 struct cmdtab cmdtab[];
 
 struct cmdtab *curcmd;
 struct cmdtab cmdtab[];
+struct cmdtab *lookup();
 
 char    *kmemf;
 char    *memf;
 
 char    *kmemf;
 char    *memf;