|
|
1.1 root 1: #include "ps.h"
2: #include <sys/vmmac.h>
3:
4: #define NCMD 63
5:
6: static char stack[NSTACK];
7:
8: char *
9: getargs(f, pp, up)
10: int f; register struct proc *pp; register struct user *up;
11: {
12: register char *sp; char *argp, *argend, *envend;
13: int nstack;
14:
15: if (pp->p_stat == SZOMB)
16: goto ucommand;
17: if((nstack = getstack(f, pp, up, stack)) == 0)
18: goto ucommand;
19: sp = stack+nstack;
20: while (*--sp == 0)
21: if (sp <= stack)
22: goto ucommand;
23: envend = sp + 2;
24:
25: sp = (char *)((long)sp & (~3));
26: while (*(long *)(sp -= 4) != 0)
27: if (sp <= stack)
28: goto ucommand;
29: argp = sp + 4;
30:
31: while (*(long *)(sp -= 4) != 0)
32: if (sp <= stack)
33: goto ucommand;
34: argend = *(long *)(sp + 4) - (UBASE - nstack) + stack; /* envp[0] */
35:
36: if (argend <= argp || argend > envend )
37: argend = envend;
38: if (argend > (sp = argp + NCMD))
39: argend = sp;
40: for (sp = argp; sp < argend; sp++) {
41: if (*sp == 0 || *sp == '\t')
42: *sp = ' ';
43: else if (*sp < ' ' || *sp >= 0177)
44: *sp = '?';
45: }
46: while (sp[-1] == ' ')
47: sp--;
48: *sp = 0;
49: return argp;
50:
51: ucommand:
52: sprintf(stack, "(%-.*s)", DIRSIZ, up->u_comm);
53: return stack;
54: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.