1: #
   2: #include "hd.h"
   3: #include "command.h"
   4: 
   5: /* Each command called by command.c must return special information.
   6:    First, the next command to execute is returned in the last eight
   7:    bits (and can be masked out with CMDMASK).  If no more commands
   8:    are to be run, these bits are set to 0.  The next bit is the
   9:    REPLOT bit.  If on, the screen has been altered enough to require
  10:    a replot.  The NOOP bit indicates a command was not found.
  11:    Finally, the ENTERDIR bit indicates a new directory has been
  12:    entered.
  13: */
  14: 
  15: command (cmd, ctype) register cmd;  int ctype; {
  16: 
  17:     register ret;       /* return value */
  18:     int next;       /* Temp variable for next command */
  19:     register struct cmdstruct *cmdp;
  20: 
  21:     ret = 0;
  22:     while (cmd) {
  23:         if ((ctype == DIRCMD) &&
  24:             ((next = dircmd (cmd)) != NOOP))
  25:             cmd = next;
  26:         else {
  27:             cmdp = cmdloc (cmd);
  28:             if (cmdp->cmd_proc && (
  29:                 (cmdp->cmd_xdir)||(ctype == DIRCMD))) {
  30: 
  31:                 cmd = (*(cmdp->cmd_proc)) (cmdp->cmd_argv);
  32:             }
  33:             else cmd = NOOP;
  34:         }
  35:         ret |= cmd & (REPLOT | ENTERDIR | NOOP);
  36:         cmd &= CMDMASK;
  37:     }
  38:     if (ret & NOOP) {
  39:         putmsg ("Not found.  Press ? for help.  ");
  40:         if (ret & REPLOT) getrtn ();
  41:     }
  42:     return ret;
  43: }
  44: 
  45: /* Classloc returns the classtab element corresponding the keyword referenced
  46:    by cp */
  47: 
  48: struct classstruct *
  49: classloc (cp) register char *cp; {
  50: 
  51:     register struct classstruct *classp;
  52: 
  53:     for (classp = classtab;
  54:         *classp->cl_name && strcmp (cp, classp->cl_name);
  55:         classp++);
  56:     return classp;
  57: }
  58: 
  59: /* Cmdloc returns the cmdtab element corresponding to ch */
  60: 
  61: struct cmdstruct *
  62: cmdloc (ch) register char ch; {
  63: 
  64:     register struct cmdstruct *cmdp;
  65: 
  66:     for (cmdp = cmdtab;
  67:         cmdp->cmd_char && cmdp->cmd_char != ch;
  68:         cmdp++);
  69: 
  70:     return cmdp;
  71: }
  72: 
  73: /* Cmdproc returns a pointer to the procedure which runs the command
  74:    corresponding to ch.  */
  75: 
  76: int (*
  77: cmdproc (ch))() char ch; {
  78:     extern struct cmdstruct *cmdloc();
  79: 
  80:     return ((*cmdloc)(ch)->cmd_proc);
  81: }

Defined functions

classloc defined in line 48; used 2 times
cmdloc defined in line 61; used 5 times
command defined in line 15; used 2 times

Defined variables

ch defined in line 77; used 5 times
Last modified: 1980-08-21
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 766
Valid CSS Valid XHTML 1.0 Strict