home *** CD-ROM | disk | FTP | other *** search
-
- /*
- * S_SHELL.C
- *
- * DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
- *
- * SHELL SERVER. THIS REQUIRES MY PIPE DEVICE TO WORK!!!!!!!!!!
- *
- * Use DSOC on the UNIX end (DSOC 8193)
- *
- * Only one connection accepted at a time in this baby.
- * HUGE CLUDGE!!!
- */
-
- #include <stdio.h>
- #include <fcntl.h>
-
- int Enable_Abort;
- char Buf[4096];
-
- typedef struct Process PROC;
-
- extern struct MsgPort *DListen();
- extern PROC *FindTask();
-
- _main()
- {
- struct MsgPort *port;
- PROC *proc = FindTask(NULL);
- long chan;
- long mask, rmask;
- long len, n;
- char nl, co;
- int fd;
- long namei = (long)proc;
- APTR oldwptr;
-
- Enable_Abort = 0;
- port = DListen(8196);
- WaitPort(&proc->pr_MsgPort);
- ReplyMsg(GetMsg(&proc->pr_MsgPort));
- if (!port)
- exit(1);
- mask = SIGBREAKF_CTRL_C|(1 << port->mp_SigBit);
- oldwptr = proc->pr_WindowPtr;
- proc->pr_WindowPtr = (APTR)-1;
- for (;;) {
- rmask = Wait(mask);
- if (rmask & SIGBREAKF_CTRL_C)
- break;
- if (chan = DAccept(port)) {
- long fh;
- long mask;
- long fhmask, smask;
- short sig;
- char pname[16];
- char buf[64];
-
- sprintf(pname, "%08lx", namei++);
- sprintf(buf, "newcli <nil: >nil: pipe:%s/t", pname);
- Execute(buf, NULL, NULL);
- sig = AllocSignal(-1);
- fhmask = 1 << sig;
- smask = 1 << ((struct MsgPort *)chan)->mp_SigBit;
- sprintf(buf, "pipe:%s/tns%ld", pname, sig);
- fh = Open(buf, 1006);
- if (fh) {
- char notdone = 1;
- DWrite(chan, "Amiga CLI running\n", 20);
- while (notdone) {
- char buf[256];
- int n;
- mask = Wait(fhmask | smask | SIGBREAKF_CTRL_C);
- while ((n = Read(fh, buf, 256)) > 0) {
- DWrite(chan, buf, n);
- }
- if (n < 0)
- notdone = 0;
- while ((n = DNRead(chan, buf, 256)) > 0) {
- DWrite(chan, buf, n);
- Write(fh, buf, n);
- }
- if (n < 0)
- notdone = 0;
- }
- Write(fh, "ENDCLI\n", 7);
- Write(fh, "ENDCLI\n", 7);
- Close(fh);
- }
- DClose(chan);
- FreeSignal(sig);
- puts("DONE");
- }
- }
- proc->pr_WindowPtr = oldwptr;
- DUnListen(port);
- }
-
-
-
-