1: #include "hd.h"
2: #include "command.h"
3:
4: #define MAXLINE 16
5:
6: /* Print and modify command tables interactively */
7:
8: options (parm) char **parm; {
9:
10: int line = 0; /* Current line number */
11: register struct cmdstruct *cmdp;
12: register struct classstruct *classp;
13: register char **argv;
14: struct parmstruct *parmp;
15:
16: /* Print command tab in .vshrc format */
17: /* If parm present, dump to file and quit */
18: erase ();
19: if (*parm) {
20: close (1); creat ("vsh.out", 0644); line= -9999;
21: }
22: for (;;) {
23: for (cmdp = cmdtab; cmdp->cmd_char >= 0; cmdp++) {
24: if (cmdp->cmd_proc) {
25: for (classp = classtab;
26: *classp->cl_name &&
27: classp->cl_proc !=
28: cmdp->cmd_proc;
29: classp++);
30:
31: printf ("%c\t%s", cmdp->cmd_char,
32: classp->cl_name);
33:
34: for (argv = cmdp->cmd_argv; *argv;)
35: printf (" %s", *argv++);
36:
37: if (optline (&line) == FAILURE)
38: return REPLOT;
39: }
40: }
41: for (parmp = parmtab; parmp->p_name; parmp++) {
42: printf ("%s\t%s", parmp->p_name, parmp->p_val);
43: if (optline (&line) == FAILURE) return REPLOT;
44: }
45:
46: if (*parm) leave ();
47: if (line != 0 && optcmd () == FAILURE) break;
48: erase (); line = 0;
49: }
50: return REPLOT;
51: }
52: /* Processing for end of each line includes:
53: 1. Print the newline.
54: 2. If the end of the page, prompt for a command.
55: */
56: optline (line) int *line; {
57: int ret; /* return from optcmd */
58:
59: putch (LF);
60: if (++*line < MAXLINE) return SUCCESS;
61:
62: ret = optcmd (); erase (); *line = 0;
63: return ret;
64: }
65:
66: optcmd () {
67: char cbuf [STRMAX], /* Buffer for input parm */
68: *argv [ARGVMAX]; /* Pointers to input parm */
69: int argc; /* Number of parm */
70: int ret; /* Return from readarg */
71:
72: int line = 0; /* Current line num of rcstream */
73:
74: printf ("\nType in a new parameter, or\n\
75: Press ^D to leave. Press -Return- to display more parameters.\n");
76: for (;;) {
77: tty_push (COOKEDMODE);
78: ret = readarg (stdin, &line, &argc, argv, cbuf);
79: tty_pop ();
80: if (argc == 0) break;
81: if (compe ("quit", argv [0])) {
82: ret = FAILURE; break;
83: }
84: if (ret != FAILURE) cmdldarg (line, argc, argv);
85: }
86: return ret;
87: }
Defined functions
Defined macros