|
|
1.1 root 1: /* addarg.c - addarg */
2:
3: #include <conf.h>
4: #include <kernel.h>
5: #include <proc.h>
6: #include <shell.h>
7:
8: /*------------------------------------------------------------------------
9: * addarg - copy arguments to area reserved on process stack
10: *------------------------------------------------------------------------
11: */
12: addarg(pid, nargs, len)
13: int pid; /* process to receive arguments */
14: int nargs; /* number of arguments to copy */
15: int len; /* size of arg. area (in bytes) */
16: {
17: struct pentry *pptr;
18: char **fromarg;
19: int *toarg;
20: char *to;
21:
22: if (isbadpid(pid) || (pptr= &proctab[pid])->pstate != PRSUSP)
23: return(SYSERR);
24: toarg = (int *) ( ((unsigned)pptr->pbase) - (unsigned)len );
25: to = (char *) (toarg + (nargs + 2));
26: *toarg++ = (int)(toarg + 1);
27: for (fromarg= Shl.shtok ; nargs > 0 ; nargs--) {
28: *toarg++ = (int)to;
29: strcpy(to, *fromarg++);
30: to += strlen(to) + 1;
31: }
32: *toarg = 0;
33: return(OK);
34: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.