1: #include "hd.h"
   2: #include "command.h"
   3: 
   4: /* This loads the command table from the .vshrc file */
   5: 
   6: cmdldrc () {
   7:     FILE *rcstream,     /* Stream of .vshrc */
   8:          *fopen();      /* Stdio open proc */
   9: 
  10:     char cbuf [STRMAX], /* Buffer for input parm */
  11:          *argv [ARGVMAX];   /* Pointers to input parm */
  12:     int argc;       /* Number of parm */
  13: 
  14:     int line = 1;       /* Current line num of rcstream */
  15: 
  16:     /* initialize */
  17: 
  18:     strcpy (cbuf, envhome);
  19:     strcat (cbuf, "/.vshrc");
  20:     rcstream = fopen (cbuf, "r");
  21:     if (rcstream == NULL) return;
  22:     printf ("Loading .vshrc\n");
  23: 
  24:     while (!feof (rcstream)) {
  25:         if (readarg (rcstream, &line, &argc, argv, cbuf)
  26:             != FAILURE)
  27:             cmdldarg (line-1, argc, argv);
  28:     }
  29: }
  30: 
  31: /* This loads command tables as specified in its arguments */
  32: cmdldarg (line, argc, argv)
  33:     int line, argc;  char *argv[]; {
  34: 
  35:     char *malloc();     /* Standard allocation proc */
  36:     register i;     /* An index */
  37: 
  38:     register struct cmdstruct *cmdp;    /* Pointers */
  39:     register struct classstruct *classp;
  40:     register struct parmstruct *parmp;
  41: 
  42:     /* An addressable representation of CNULL (0) */
  43:     extern char *cnull;
  44: 
  45:     if (argc <= 0) ;
  46:     else if (argc == 1) lderror ("Too few args", line);
  47: 
  48:     else if (strlen (argv [0]) == 1) {
  49:         cmdp = cmdloc (*argv [0]);
  50:         if (cmdp->cmd_char == 0) {
  51:             lderror ("Not a proper command",
  52:             line);
  53:             return;
  54:         }
  55:         classp = classloc (argv [1]);
  56:         if (*classp->cl_name == 0) {
  57:             lderror ("Illegal keyword", line);
  58:             return;
  59:         }
  60:         if (!(
  61:             argc-2 == classp->cl_count ||
  62:             (classp->cl_count == -1 && argc <= 3) ||
  63:             (classp->cl_count == -2 && argc >= 3))){
  64: 
  65:             lderror
  66:             ("Improper number number of parmeters", line);
  67:             return;
  68:         }
  69:         /* All testing over with--store new command */
  70: 
  71:         cmdp->cmd_proc = classp->cl_proc;
  72:         cmdp->cmd_xdir = classp->cl_xdir;
  73: 
  74:         if (argc <= 2) cmdp->cmd_argv = &cnull;
  75:         else cmdp->cmd_argv  =
  76:             (char **) malloc ((argc - 1) * (sizeof *argv));
  77: 
  78:         for (i=2; i<argc; i++) {
  79:             cmdp->cmd_argv [i-2] =
  80:                 malloc (strlen (argv [i]) + 1);
  81:             strcpy (cmdp->cmd_argv[i-2], argv [i]);
  82:             cmdp->cmd_argv [i-1] = CNULL;
  83:         }
  84:     }
  85:     else {
  86:         for (parmp = parmtab;
  87:             parmp->p_name &&
  88:             strcmp (parmp->p_name, argv[0]);
  89:             parmp++);
  90:         if (parmp->p_name) {
  91:             parmp->p_val = malloc
  92:                 (strlen (argv[1]) + 1);
  93:             strcpy (parmp->p_val, argv[1]);
  94:         }
  95:         else lderror ("Bad parameter name", line);
  96:         if (argc != 2) lderror
  97:             ("Too many args", line);
  98:     }
  99: }

Defined functions

cmdldarg defined in line 32; used 2 times
cmdldrc defined in line 6; used 1 times
Last modified: 1980-08-11
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 793
Valid CSS Valid XHTML 1.0 Strict