Packets6Ou            mt, Packets7Out, Packets8Out;


#ifdef NOTDEF

extern void do_rto	ARGS((IOT *));
extern void do_wto	ARGS((IOT *));
extern void do_rnet	ARGS((ubyte *, long));
extern void do_wnet	ARGS((void));
extern void do_wupdate	ARGS((void));
extern void dumpcheck	ARGS((ubyte *));
extern void do_cmd	ARGS((uword, ubyte *, int));
extern void do_rupdate	ARGS((void));
extern void do_reccmd	ARGS((int, ubyte *, int));
extern void replywindow ARGS((int));

/* Prototypes for functions defined in sernet.c *            2/

extern void NetOpen	ARGS((PORT *, char *, int, int *));
extern void NetClose	ARGS((void));
extern void NetClWrite	ARGS((IOSER *));
extern void NetWrite	ARGS((void *, int, int));
extern void NetBreak	ARGS((void));
extern int  NetReady	ARGS((void));
extern int  SetBaudRate ARGS((int));
extern void DropDTR	ARGS((void));
extern void NetStartRead ARGS((long));
extern IOSER *NetAbortRead ARGS((void));
extern struct IOExtSer *NetReadReady ARGS((void));
extern int  NetReadReturned ARGS((i            *bnt, ubyte **));
extern void NetWaitWrite ARGS((void));
extern void SaveState ARGS((void));
extern void RestoreState ARGS((void));
extern void NetRecvOff ARGS((void));
extern void NetRecvOn ARGS((void));
extern void NetSerialOff ARGS((void));
extern void NetSerialOn ARGS((void));


/* Prototypes for functions defined in time.c */

extern void do_cto	    ARGS((IOT *));
extern void ResetIdle	    ARGS((void));
extern void ResetConnect    ARGS((void));
extern void LessConnect     ARGS((in            NBMt));
extern void SetConnectAlert ARGS((int, char *));
extern void SetIdleAlert    ARGS((int, char *));
extern int  GetIdle	    ARGS((void));
extern int  GetConnect	    ARGS((void));
/*
extern int  doipcmsg	    ARGS((char *, char *, short));
*/

/* Prototypes for functions defined in dnet.c */

void do_netreset ARGS((void));

/* Prototypes for functions defined in ipc.c */

/*
extern int  handle_ipc	    ARGS((void));
extern void  do_online	    ARGS((void));
extern void  do_offline         w       8+	    nw->Height+= Scr.Height;
    }
    if (alen >= 4) {
	if ((nw->LeftEdge= ary[4]) < 0)
	    nw->LeftEdge += Scr.Width - nw->Width;
	if ((nw->TopEdge = ary[5]) < 0)
	    nw->TopEdge += Scr.Height - nw->Height;
    }
    if (nw->LeftEdge < 0 || nw->TopEdge < 0 || nw->Width < 0 || nw->Height < 0 ||
	nw->LeftEdge + nw->Width > Scr.Width || nw->TopEdge + nw->Height > Scr.Height) {

	nw->LeftEdge = nw->TopEdge = 0;
	nw->Width = 320;
	nw->Height= 100;
    }
    if (alen >= 9)
	nw->Detail     w       膌Pen = ary[8] >> 8;
    if (alen >= 10)
	nw->BlockPen  = ary[8];
}

/*
 *
 */

static MLIST CList;

void
LoadConnectList()
{
    char *ptr;

    NewList((LIST *)&CList);

    OpenCfgFile();
    while (ptr = GetCfgLine("AUTA")) {
	long baudrate = atoi(ptr);
	while (*ptr && *ptr != '\"')
	    ++ptr;
	if (*ptr == '\"') {
	    char *en;
	    NODE *node;

	    for (en = ++ptr; *en && *en != '\"'; ++en);
	    *en = 0;

	    if (node = (NODE *)malloc(sizeof(NODE)+strlen(ptr)+1)) {
		AddTail(     w       T[y(LIST *)&CList, node);
		node->ln_Name = (char *)baudrate;
		strcpy((char *)(node + 1), ptr);
	    }
	}
    }
    CloseCfgFile();
}

void
UnLoadConnectList()
{
    NODE *node;
    while (node = RemHead((LIST *)&CList))
	free(node);
}

int
CheckConnect(oldbaud, ptr, n)
int oldbaud;
char *ptr;
int n;
{
    static char tmpbuf[64];
    static short tlen;
    short i;
    NODE *node;
    long newbaud = oldbaud;

    for (i = 0; i < n; ++i) {
	if (ptr[i] == 13 || ptr[i] == 10) {
	    tmpbu     w       [Of[tlen++] = 0;
	    if (tlen < 2) {
		tlen = 0;
		continue;
	    }
	    tlen = 0;
	    for (node = (NODE *)GetHead(&CList); node; node = (NODE *)GetSucc(node)) {
		if (strcmp(tmpbuf, (char *)(node + 1)) == 0) {
		    newbaud = (long)node->ln_Name;
		    if (DDebug)
			printf("Successful compare, baud -> %d\n", newbaud);
		    break;
		}
	    }
	    if (GetHead(&CList) == NULL) {
		if (strncmp(tmpbuf, "CONNECT", 7) == 0) {
		    newbaud = atoi(tmpbuf + 7);
		    if (newbaud == 0)
			n     w          ^[sewbaud = 300;
		}
	    }
	    continue;
	}
	tmpbuf[tlen++] = ptr[i];
	if (tlen == sizeof(tmpbuf))
	    tlen = 0;
    }
    if (oldbaud != newbaud)
	SetBaudRate(newbaud);
    return(newbaud);
}

RemHead((LIST *)&CList))
	free(node);
}

int
CheckConnect(oldbaud, ptr, n)
int oldbaud;
char *ptr;
int n;
{
    static char tmpbuf[64];
    static short tlen;
    short i;
    NODE *node;
    long newbaud = oldbaud;

    for (i = 0; i < n; ++i) {
	if (ptr[i] == 13 || ptr[i] == 10) {
	    tmpbu            Φ structure */

#define ARGS(foo)   foo

typedef struct IORequest    IOR;
typedef struct IOStdReq     IOSTD;
typedef struct IOExtSer     IOSER;
typedef struct IOStdReq     IOCON;
typedef struct timerequest  IOT;
typedef struct Window	    WIN;
typedef struct NewWindow    NW;
typedef struct RastPort     RP;
typedef struct Task	    TASK;
typedef struct Process	    PROC;
typedef struct MsgPort	    PORT;
typedef struct Node	    NODE;
typedef struct MinNode	    MNODE;
typedef struct List	              l  LIST;
typedef struct MinList	    MLIST;
typedef struct Message	    MSG;

typedef unsigned char	ubyte;
typedef unsigned short	uword;
typedef unsigned long	ulong;

#include "/dnet/channel.h"

#ifndef MAX(a,b)
#define MAX(a,b) (((a)>(b))?(a):(b))
#endif

#define CFGFILE "s:dnet.config"

#define PKT	struct _PKT
#define CTLPKT	struct _CTLPKT
#define PNODE	struct _PNODE
#define IOMSG	struct _IOMSG

#define DNETPORTNAME	    "DNET.UNIT."
#define OFFSET(ptr,elem)    ((long)((char *)&(ptr)->            Felem - (char *)(ptr)))

#define EMPTY	0	/*  empty (sent)                    */
#define READY	1	/*  data ready (not sent yet)       */

#define MAXCHAN 128	/*  Max # of channels supported     */
#define SYNC	0x5B	/*  SYNC character		    */
#define MAXPKT	200	/*  maximum packet size 	    */
#define MINPKT	32	/*  minimum maximum packet size
			    (for priority scheme)           */

#define MAXPACKET ((MAXPKT * 8 + 5) / 6 + 64)

#define OVERHEAD    7	/*  for packets with data	    */

PN            bODE {
    NODE    node;
    char    name[32];
    ulong   seg;
};

CTLPKT {
    uword   buflen;	/*  send: length of packet, recv: length of data    */
    ubyte   state;	/*  EMPTY, READY				    */

    ubyte   sync;	/*  THE PACKET	    */
    ubyte   ctl;
    ubyte   cchk;
};

PKT {
    uword   buflen;	/*  send: length of packet, recv: length of data    */
    ubyte   state;	/*  EMPTY, READY				    */

    ubyte   sync;	/*  THE PACKET	    */
    ubyte   ctl;
    ubyte   cchk;
    ubyt            +*e   lenh;
    ubyte   lenl;
    ubyte   dchkh;
    ubyte   dchkl;
    ubyte   data[MAXPACKET];
};

/*
 *  Used by the IoCtl() support routines.
 */

IOMSG {
    MSG     Msg;
    TASK    *ReplyTask;
    ulong   Cmd;
    ulong   Arg1;
    ulong   Arg2;
    ulong   Res;
};

#ifdef NOTDEF
			/*  RECEIVER STATES		    */
#define RS_SYNC 0	    /*	Waiting for sync		*/
#define RS_CTL	1	    /*	Waiting for command		*/
#define RS_CCHK 2	    /*	Waiting for check byte		*/
#define RS_LEN1 3	    /*	            AWaiting for MSB length byte	*/
#define RS_LEN2 4	    /*	Waiting for LSB length byte	*/
#define RS_DATA 5	    /*	Waiting for data & checksum	*/

#endif

#define DNCMD_OPEN	32  /*	Application open		*/
#define DNCMD_SOPEN	33  /*	Server open			*/
#define DNCMD_CLOSE	34  /*	Close a channel 		*/
#define DNCMD_EOF	35  /*	Will no longer write to channel */

#define DNCMD_WRITE	36  /*	Write data to a channel 	*/
#define DNCMD_QUIT	37  /*	Kill the DNET server		*/
#define DNCMD_IOCTL	38
#define     u       netreset()
{
    short i;
    CHAN *ch;
    IOSTD *ior;

    while (ior = (IOSTD *)RemHead((LIST *)&TxList)) {
	ior->io_Error = 1;
	ReplyMsg((MSG *)ior);
    }
    for (i = 0, ch = Chan; i < MAXCHAN; ++i, ++ch) {
	switch(ch->state) {
	case CHAN_OPEN:
	    WritePort(Chan[i].port, DNCMD_CLOSE, NULL, 0, PKT_REQ, i);
	case CHAN_ROPEN:	/*  pending on listen port  */
	    ch->state = CHAN_CLOSE;
	    ch->flags = CHANF_RCLOSE;
	    ch->ior = NULL;
	    break;
	case CHAN_LOPEN:	/*  pending o     u       \6n network	    */
	    ch->ior->io_Error = 1;
	    ReplyMsg((MSG *)ch->ior);
	    ch->ior = NULL;
	    ch->state = CHAN_FREE;
	    ch->flags = 0;
	    --NumCon;
	    break;
	case CHAN_CLOSE:
	    if (!(ch->flags & CHANF_LCLOSE))
		break;
	    ch->ior->io_Error = 1;
	    ReplyMsg((MSG *)ch->ior);
	    ch->ior = NULL;
	    ch->state = CHAN_FREE;
	    ch->flags = 0;
	    --NumCon;
	}
    }
    RPStart = 0;
    WPStart = 0;
    WPUsed  = 0;
    RState  = 0;
    RChan = 0;
    WChan = 0;
      u      t       if (!Cto_act) {
	Cto.tr_time.tv_secs = 1;
	Cto.tr_time.tv_micro= 0;
	SendIO((IOR *)&Cto);
	Cto_act = 1;
    }
}

>io_Error = 1;
	ReplyMsg((MSG *)ior);
    }
    for (i = 0, ch = Chan; i < MAXCHAN; ++i, ++ch) {
	switch(ch->state) {
	case CHAN_OPEN:
	    WritePort(Chan[i].port, DNCMD_CLOSE, NULL, 0, PKT_REQ, i);
	case CHAN_ROPEN:	/*  pending on listen port  */
	    ch->state = CHAN_CLOSE;
	    ch->flags = CHANF_RCLOSE;
	    ch->ior = NULL;
	    break;
	case CHAN_LOPEN:	/*  pending o     w        0 item 0	*/
			NetBreak();
			break;
		    case 0x0001:    /*	menu 0 item 1	*/
			notdone = 0;
			OnLine = 1;
			break;
		    case 0x0002:    /*	menu 0 item 2	*/
			notdone = 0;
			Quit = 1;
			break;
		    case 0x0100:    /*	menu 1 item 0	*/
			break;
		    }
		    break;
		}
		ReplyMsg((MSG *)im);
	    }
	}
	if (mask & smask) {
	    IOSER *ios;
	    if (ios = NetReadReady()) {
		int n;
		int actual;
		ubyte *ptr;

		WaitIO((IOR *)ios);
		actual = NetReadReturned(&ptr);
		if (actua     w        9l > 0) {
		    if (RSync && *ptr == PKCMD_RESTART) {
			OnLine = 1;
			notdone = 0;
		    }
		    RSync = (*ptr == SYNC);
		    for (n = 0; n < actual; ++n)
			ptr[n] &= 0x7F;
		    oldbaud = CheckConnect(oldbaud, ptr, n);
		    iocw->io_Data   = (APTR)ptr;
		    iocw->io_Length = n;
		    DoIO((IOR *)iocw);
		}
		if ((n = NetReady()) >= sizeof(RcvBuf))
		    n = sizeof(RcvBuf) - 1;
		if (n <= 0)
		    n = 1;
		NetStartRead(n);
	    }
	    if (CheckIO(&Wto)) {
		StartWriteTimeout(1);     w       !U
		NetReady();
	    }
	}
	if (mask & conmask) {
	    if (CheckIO((IOR *)iocr)) {
		WaitIO((IOR *)iocr);
		if (!Master8)
		    addparity((ubyte *)iocr->io_Data, iocr->io_Actual);
		NetWrite(iocr->io_Data, iocr->io_Actual, 0);
		NetWaitWrite();
		iocr->io_Data = (APTR)&Cc;
		iocr->io_Length = 1;
		SendIO((IOR *)iocr);
	    }
	}
	NetReady();
	if (Getty && !Cd) {
	    Quit = 1;
	    notdone = 0;
	    break;
	}
	if (AutoAnswer && Cd)
	    break;
    }

    StartWriteTimeout(0);

    UnLoa     w       "`dConnectList();

    {
	IOSER *ios = NetAbortRead();

	if (ios->IOSer.io_Actual > 0) {
	    ubyte *ptr = (ubyte *)ios->IOSer.io_Data;
	    short n;
	    for (n = 0; n < ios->IOSer.io_Actual; ++n)
		ptr[n] &= 0x7F;
	    oldbaud = CheckConnect(oldbaud, ptr, n);
	}
    }

    if (DDebug)
	printf("SETTING BAUD RATE TO %d\n", oldbaud);

    if (AutoAnswer && Cd) {
	char *msg = "\r\nDNET AutoAnswer, Protocol Start\r\n";
	OnLine = 1;
	NetWrite(msg, strlen(msg), 0);
	Cto.tr_time.tv_secs = 3;     w       #C
	Cto.tr_time.tv_micro= 0;
	DoIO((IOR *)&Cto);
    }

    NetStartRead(3);

    AbortIO((IOR *)iocr);
    WaitIO((IOR *)iocr);
    CloseConsole(iocr, iocw);
e3:
    CloseWindow(win);
e1:
    if (IntuitionBase)  CloseLibrary((LIB *)IntuitionBase);
    if (GfxBase)        CloseLibrary((LIB *)GfxBase);
    if (Quit)
	puts("DNET EXITING");
    else
	puts("DNET RUNNING");
    return;
}

/*
 *  PARITY ROUTINES
 */

static ubyte Party[256/8];

void
setparity(pand, por, peven)
int pand, por,     w       $^Pp peven;
{
    short i, j, k, l;

    BZero(Party, sizeof(Party));
    for (i = 0; i < 128; ++i) {
	for (j = (~i & 127), k = 0; j; j >>= 1) {   /*  k = count # of 0's */
	    if (j & 1)
		++k;
	}
	k ^= peven;
	l = (((k & 1) ? 0x01 : 0) | por) & pand;
	Party[i >> 3] |= l << (i & 7);
    }
}

void
addparity(buf, bytes)
ubyte *buf;
int bytes;
{
    short i;

    for (i = bytes - 1; i >= 0; --i) {
	if (Party[buf[i]>>3] & (1 << (buf[i]&7)))
	    buf[i] |= 0x80;
    }
}

void
OpenConsole(wi     w       % n, piocr, piocw)
IOCON **piocr, **piocw;
struct Window *win;
{
    PORT *port;
    static IOCON iocr, iocw;
    int error;

    port = CreatePort(NULL, 0);
    iocr.io_Command = CMD_READ;
    iocr.io_Data = (APTR)win;
    iocr.io_Message.mn_Node.ln_Type = NT_MESSAGE;
    iocr.io_Message.mn_ReplyPort = port;
    error = OpenDevice("console.device", 0, (IOR *)&iocr, 0);
    if (!error) {
	iocw = iocr;
	iocw.io_Command = CMD_WRITE;
	*piocr = &iocr;
	*piocw = &iocw;
    } else {
	*piocr      w       88= *piocw = NULL;
    }
}

void
CloseConsole(iocr, iocw)
IOCON *iocr;
IOCON *iocw;
{
    CloseDevice((IOR *)iocr);
    DeletePort(iocr->io_Message.mn_ReplyPort);
}

void
InitDeemuNW(ary, nw)
short *ary;
NW *nw;
{
    short alen = ary[3];
    SCR Scr;

    if (GetScreenData((char *)&Scr, sizeof(Scr), nw->Type, nw->Screen) == 0) {
	Scr.Width = 320;
	Scr.Height= 200;
    }
    if (alen >= 8) {
	if ((nw->Width   = ary[6]) < 0)
	    nw->Width += Scr.Width;
	if ((nw->Height  = ary[7]) < 0)
     u   	    '8pc_mask)
	    handle_ipc();
	*/

	if (mask & sink_mask) {     /*  IOSink returns      */
	    IOSTD *ior;
	    while (ior = (IOSTD *)GetMsg(IOSink)) {
		switch((long)ior->io_Message.mn_Node.ln_Name) {
		case PKT_REQ:
		    --NumCon;
		    if (ior->io_Length)
			FreeMem(ior->io_Data, ior->io_Length);
		    FreeMem(ior, sizeof(IOSTD));
		    break;
		case CTO_REQ:	/*  Only when line idle 	    */
		    Cto_act = 0;
		    do_cto((IOT *)ior);
		    if (Cd == 0 && AutoHangup)
			OnLine = 0     u   
    (E_;
		    break;
		case RTO_REQ:	/*  Read timeout, reset READ state  */
		    Rto_act = 0;
		    do_rto((IOT *)ior);
		    break;
		case WTO_REQ:	/*  Write-Ack timeout, send CHECK   */
		    Wto_act = 0;
		    do_wto((IOT *)ior);
		    break;
		case RNET_REQ:	/*  Receive data ready, interpret   */
		    {
			char *ptr;
			long bytes = NetReadReturned(&ptr);
			do_rnet(ptr, bytes);
		    }
		    if (Cd == 0 && AutoHangup)
			OnLine = 0;
		    break;
		case WNET_REQ:
		    NetClWrite((IO     u       ),SER *)ior);
		    break;
		}
	    }
	}
	if (mask & dnet_mask) {     /*  Receive commands    */
	    IOSTD *ior;
	    while (ior = (IOSTD *)GetMsg(DNetPort)) {
		ior->io_Actual = 0;
		switch(ior->io_Command) {
		case DNCMD_WRITE:	/*  write data to net	    */
		    {
			uword chan = (ulong)ior->io_Unit;
			if (Chan[chan].state != CHAN_OPEN) {
			    ior->io_Error = 1;
			    break;
			}
			ior->io_Error = 0;
			ior->io_Command = SCMD_DATA;
			ior->io_Message.mn_Node.ln_Pri = Chan[chan]     u       *nQQ.pri;
			Enqueue(&TxList, (NODE *)ior);
			ior = NULL;
		    }
		    break;
		case DNCMD_SOPEN:   /*	Reply from server port on remote    */
				    /*	open request			    */
		    {
			CACKCMD ack;
			uword chan = (ulong)ior->io_Unit;


			ack.chanh = chan >> 8;
			ack.chanl = chan;
			ack.error = ior->io_Error;
			WriteStream(SCMD_ACKCMD, &ack, sizeof(ack), chan);
			if (ack.error) {
			    Chan[chan].state = CHAN_FREE;
			    --NumCon;
			} else {
			    if (Chan[chan].state == CHAN     u       +(a_CLOSE && !ack.error) {
				WritePort(Chan[chan].port, DNCMD_CLOSE, NULL, 0, PKT_REQ, chan);
				goto sopenbrk;
			    }
			    Chan[chan].state = CHAN_OPEN;
			    Chan[chan].port  = (PORT *)ior->io_Offset;
			    Chan[chan].flags = CHANF_ROK|CHANF_WOK;
			}
sopenbrk:
			if (ior->io_Length)
			    FreeMem(ior->io_Data, ior->io_Length);
			FreeMem(ior, sizeof(IOSTD));
			ior = NULL;
		    }
		    break;
		case DNCMD_EOF:
		    {
			CEOFCMD eof;
			uword chan = (ulong)ior->io_Unit;

	     u       ,/r		ior->io_Error = 0;
			eof.chanh = chan >> 8;
			eof.chanl = chan;
			eof.flags = CHANF_ROK;
			WriteStream(SCMD_EOFCMD, &eof, sizeof(CEOFCMD), chan);
			Chan[chan].flags &= ~CHANF_WOK;
		    }
		    break;
		case DNCMD_IOCTL:
		    {
			CIOCTL cio;
			uword chan = (ulong)ior->io_Unit;

			ior->io_Error = 0;
			cio.chanh = chan >> 8;
			cio.chanl = chan;
			cio.valh   = (ubyte)((ulong)ior->io_Data >> 24);
			cio.vall   = (ubyte)((ulong)ior->io_Data >> 16);
			cio.valaux = (ubyte)((u     u       -D˔Clong)ior->io_Data >> 8);
			cio.cmd = (ubyte)(ulong)ior->io_Data;
			WriteStream(SCMD_IOCTL, &cio, sizeof(CIOCTL), chan);
		    }
		    break;
		case DNCMD_QUIT:
		    {
			char dummy;

			WriteStream(SCMD_QUIT, &dummy, 1, (uword)-1);
		    }
		    break;
		case DNCMD_INFO:
		    {
			char *ptr = (char *)ior->io_Data;
			sprintf(ptr, "         Bytes  Packets   Errors\n"
				     "OUT:  %8ld %8ld %8ld\n"
				     "IN :  %8ld %8ld %8ld\n"
				     "Garbage Bytes In: %ld\n\n"
				     "     u       .8                        6-expn   7-comp   8-bin\n"
				     "Packet Breakdown Send: %8ld %8ld %8ld\n"
				     "Packet Breakdown Recv: %8ld %8ld %8ld\n",

				    BytesOut, PacketsOut, PacketsResent,
				    BytesIn,  PacketsIn,  PacketsNakd,
				    GarbageIn,
				    Packets6Out, Packets7Out, Packets8Out,
				    Packets6In,  Packets7In,  Packets8In
			);
		    }
		    break;
		case DNCMD_OPEN:
		    ior->io_Error = 0;
		    {
			uword chan = alloc_channel();
			COPEN co;
			if (ch     u       /nAan >= MAXCHAN) {
			    ior->io_Error = 1;
			    break;
			}
			co.chanh = chan >> 8;
			co.chanl = chan;
			co.porth = (ulong)ior->io_Unit >> 8;  /* port #   */
			co.portl = (ulong)ior->io_Unit;
			co.error= 0;
			co.pri = (char)(long)ior->io_Message.mn_Node.ln_Name;
			Chan[chan].ior = ior;
			Chan[chan].port= (PORT *)ior->io_Offset;
			Chan[chan].state = CHAN_LOPEN;
			Chan[chan].flags = 0;
			Chan[chan].pri = ior->io_Message.mn_Node.ln_Pri;
			WriteStream(SCMD_OPEN, &co, sizeof     u       0)(COPEN), chan);
			ior = NULL;
		    }
		    break;
		case DNCMD_CLOSE:	/*  same io_Command for CCTL_?	*/
		    ior->io_Error = 0;
		    {
			CCLOSE cc;
			uword chan = (ulong)ior->io_Unit;

			cc.chanh = chan >> 8;
			cc.chanl = chan;
			WriteStream(SCMD_CLOSE, &cc, sizeof(CCLOSE), chan);
			Chan[chan].ior = ior;
			Chan[chan].state = CHAN_CLOSE;
			Chan[chan].flags |= CHANF_LCLOSE;
			if (Chan[chan].flags & CHANF_RCLOSE) {
			    Chan[chan].state = CHAN_FREE;
			    Chan[chan].ior      u       Ė= NULL;
			} else {
			    ior = NULL;
			}
		    }
		    break;
		case DNCMD_EXEC:
		    Execute((char *)ior->io_Offset, NULL, NULL);
		    break;
		}
		if (ior)
		    ReplyMsg((MSG *)ior);
	    }
	}
	if (mask & SIGBREAKF_CTRL_C)
	    OnLine = 0;
	do_wupdate();
    }
    do_netreset();
    if (!Cd) {
	ResetConnect();
	ResetIdle();
    }
    if (!Quit)
	do_dnetwindow(baud);
    if (!Cd) {
	ResetConnect();
	ResetIdle();
    }
    if (!Quit)
	goto loop;
    dneterror(NULL);
}

void
do_     p       2                                                                                                                                                                                                                                                                                                                                                         b                      *UUUUU  7  7  7  7ꪪꪪ  7  7  7  7     p       38UUU~  7  7UUUU~  7  7UUUU~  7  7UUUU~  7  7UUU~  7  7UUUU~  7  7UUUU~  7  7  7_  7  0           *UUUUU                                                 UUUG              UUUUG          *UUUUG          UUUUG          UUUUG               p       4!UUUUG          *UUUUG          UUUUG          UUUUG                       @                                                                                                                                                                                                                                                                                                                       p          #                                                                                                                     :c/MuchMore   7UUUU~  7  7UUUU~  7  7  7_  7  0           *UUUUU                                                 UUUG              UUUUG          *UUUUG          UUUUG          UUUUG               u       6kJgup = 1;
	    av[i] = "";
	}
	if (strcmp(av[i], "-DEVICE") == 0) {
	    netdevice = av[i + 1];
	    av[i] = "";
	    av[i+1] = "";
	}
	if (strcmp(av[i], "-UNIT") == 0) {
	    netunit = atoi(av[i+1]);
	    av[i] = "";
	    av[i+1] = "";
	}
    }

    ac = DoOption(ac, av, "p,m%d,b%ld,d%d,n%s,s%s,a,h%d,U%ld,D%s,N%d,8X%d,B%ld,P%d",
	&PDebug, &Mode7, &baud, &DDebug, &HostName, &autoclient, &AutoAnswer,
	&AutoHangup, &netunit, &netdevice, &NetworkNum, &Master8, &DialOut,
	&TOBaud, &Protoc     u       742Qol
    );
    if (ac < 0) {
	puts("Unknown option, valid options:\n");
	puts("dnet -pb#B#d#n<hostname>s<autorunclient>aU#D<device>N<netid>8");
	dneterror("Unknown switch");
    }
    if (AutoAnswer) {
	AutoHangup = 1;
	DialOut = 0;
    }
    sprintf(PortName, "%s%d", DNETPORTNAME, NetworkNum);
    {
	PORT *port;
	if (port = (PORT *)FindPort(PortName)) {
	    puts("DNET: Network number in use");
	    /*
	    CloseLibrary(DResBase);
	    */
	    exit(1);
	}
    }
    DNetPort = (PORT *     u       8h)CreatePort(PortName, 0);
    IOSink   = (PORT *)CreatePort(NULL,0);
    /*
    IPCPort  = (PORT *)OpenIPC("dnet.CMD", 0);
    */
    if (!DNetPort || !IOSink)
	dneterror("CreatePort");

    NewList((LIST *)&TxList);
    Rto_act = Wto_act = Cto_act = 0;
    NetOpen(IOSink, netdevice, netunit, &baud);
    TimerOpen(&Rto, IOSink);
    TimerOpen(&Wto, IOSink);
    TimerOpen(&Cto, IOSink);

    if (TOBaud)
	SetTimeouts(TOBaud);
    else
	SetTimeouts(Baud);

    NetStartRead(3);

    do_d     u       96netwindow(baud);

    if (Quit)
	dneterror(NULL);

    Rto.tr_node.io_Message.mn_Node.ln_Name = (char *)RTO_REQ;
    Wto.tr_node.io_Message.mn_Node.ln_Name = (char *)WTO_REQ;
    Cto.tr_node.io_Message.mn_Node.ln_Name = (char *)CTO_REQ;

    sink_mask = 1 << IOSink->mp_SigBit;
    dnet_mask = 1 << DNetPort->mp_SigBit;
    /*
    ipc_mask = 1 << IPCPort->mp_SigBit;
    */

    do_netreset();
loop:
    if (strcmp(autoclient, "-") != 0) {
	FILE *fi = fopen("T:dscr", "w");
	if (fi) {
	       u       :e  fprintf(fi, "Wait 5\n");
	    fprintf(fi, "%s -N%ld\n", autoclient, NetworkNum);
	    fclose(fi);
	    Execute("RUN <NIL: >NIL: execute T:dscr", NULL, NULL);
	}
    }

    WriteRestart();
    Restart = 1;
    OnLine = 1;

    /*
     *	NOTE:	Routines must be particularly careful not to clear the
     *		signal mask unless it doesn't matter.  Specifically,
     *		routines in the dnet_mask section cannot arbitrarily
     *		clear the signal associated with the sink_mask section.
        u       &z5  *
     *		If you look at NetWrite(), you will note that the signal
     *		is restored if it must do a WaitIO().
     */

    /*
     *	Immediate return from initial Wait() ... due to looping it is
     *	possible one or more requests is ready but the signal bit has
     *	already been cleared.
     */

    Signal(FindTask(NULL), /*ipc_mask|*/sink_mask|dnet_mask);

    while (!Quit && OnLine) {
	long mask = Wait(/*ipc_mask|*/sink_mask|dnet_mask|SIGBREAKF_CTRL_C);

	/*
	if (mask & i     u       5e#rn(0);
}

#endif

void main ARGS((int, char **));

void
main(ac,av)
int ac;
char *av[];
{
    long sink_mask, dnet_mask/*, ipc_mask*/;
    long baud = 0;
    char *netdevice = "serial.device";
    long netunit = 0;
    char *autoclient = "FTERM";
    short i;

    unlink("ENV:DNET_NORUNCLIENT");
#ifndef LATTICE
    Enable_Abort = 0;
#endif
    BZero(Pkts,sizeof(Pkts));
    InitServers();

    for (i = 1; i < ac; ++i) {
	if (strcmp(av[i], "-Getty") == 0) {
	    Getty = 1;
	    AutoHan     h   	    =ahe other end closed it's side in which case
	fewer than the number of bytes requested will be returned.  That
	is, this call will BLOCK waiting for data.

	A negative value is returned on EOF or failure.


    DWRITE()

	Write data to a channel.  The return value is either the # bytes
	written, or a negative error code.

		    -1	Remote end REOF'd the channel
		    -2	Remote end CLOSED the channel

		    note: not much distinction between the two
		    currently.

    DCLOSE()

	Clos     h   
    >e a channel.

    DOPEN()

	Application side OPEN().... Open a port# on a remote host.  Returns
	a channel port or NULL.  Two priorities are given.  Each may be
	in the range (lowest) -127 to 126 (highest) inclusive.  The first
	priority is for transmitting data client->server, the second
	for receiving data server->client.

	The host field should be NULL for now.	In future versions, you
	will be able to run multiple DNET's on your Amiga and this will
	field will determine which one      h     !    xyou are attempting to connect
	through.

    DQUIT()

	Causes DNET on the remote side to quit out.  If running on a
	4.2BSD UNIX machine, the DNET will exit.  If running on another
	Amiga, the DNET will return to terminal-window mode.

	The host has the same definition as for DOpen().



itten, or a negative error code.

		    -1	Remote end REOF'd the channel
		    -2	Remote end CLOSED the channel

		    note: not much distinction between the two
		    currently.

    DCLOSE()

	Clos     j          HLth random modem noise.

ILES

	PUTFILES [-Nnet#] [-dDESTDIR] file/dir file/dir file/dir ..

	File transfer client.  Transfer the specified files and or directories
	to the destination directory on the remote machine.  For instance:

	unix:  putfiles -dram: charlie.txt /usr/include

	 places the file charlie.txt as ram:charlie.txt, and places the
	 directory structure /usr/include as ram:include/(whatever).

	The -N option selects the network number (see -N option for DNET).
	The defa     n       A`f                                         ?      <?                  9      |<?                  Ϗ      3      ?χ      3      ?      ??                                                                                                                                                      n       B                                                                                                                                                                                                                                                                                                                                                         b                      *UUUUU  7  7  7  7ꪪꪪ  7  7  7  7     n       C*UUU~  7  7UUUU~  7  7UUUU~  7  7UUUU~  7  7UUU~  7  7UUUU~  7  7UUUU~  7  7  7_  7  0           *UUUUU                                                 UUUG              UUUUG          *UUUUG          UUUUG          UUUUG               n       D UUUUG          *UUUUG          UUUUG          UUUUG                       @                                                                                                                                                                                                                                                                                                                       n          #                                                                                                                     :c/MuchMore   7UUUU~  7  7UUUU~  7  7  7_  7  0           *UUUUU                                                 UUUG              UUUUG          *UUUUG          UUUUG          UUUUG               p       1`t                                         ?      <?                  9      |<?                  Ϗ      3      ?χ      3      ?      ??                                                                                                                                                      j       ?4OQult is 0 (AMIGA ONLY).

	The default destination directory depends on the remote host.  If the
	destination is an Amiga, the default is DF0: (so you probably always
	want to specify a -d switch).  On the UNIX end, the default is whatever
	is set in the file dnet.servers

	Currently, no file compression is done.  I also hope to add
	semi-automatic crash recovery (continue download where you left off
	after a crash), though it should be noted that it is very difficult
	to crash DNET wi     ]      (    W,ake that brings up a DOS requester!).


t#]

    CLITERM is used between two amigas to open a remote CLI on the remote
    amiga.

    CLITERM is a standard FTERM minus some features and plus some features.
    The big feature is that it line-buffers the data, allowing you to
    edit lines before sending them off to the remote cli.  It also
    defaults to the SCLI server's port # (8196).

    WARNING: You must be at a CLI (or 1.3 NewShell shell) prompt when
    you exit!

    The r     _       I? t field of the requested file or the comment field
	of any parent directory to that file (checked all the way to the
	root directory if necessary) must contain a field:

	    AC=<n>

	where <n> is a value less than or equal to the security level
	(DNET_READ enviroment variable).  For example, if the remote user
	sets the DNET_READ enviroment variable to 5 (normally done by
	modifying the s:dnet.config file), and then sets the comment field
	for his GAMES: volume to AC=5, remote users     _          # who connect to his
	amiga will only be allowed to download files from that volume.

	The comment field will be used to house other parameters in the
	future.

 allowed to be downloaded according to the comment field
	of said files or any parent directory and the current DNET_READ
	accesslevel.

	If the remote AMIGA's DNET_READ enviroment variable is set 9 or
	higher, no access restrictions are imposed.

	If the remote AMIGA's DNET_READ enviroment variable is less than
	9, the commen     h       K is so slow,
	it doesn't really matter.

	You are guarenteed a signal will be present whenever there is
	pending data, even if you only partially read what is available.
	NOTE that you *will* get signals sometimes even when no data is
	available, and should thus take into account DNRead() returning
	0...  Usually DNRead() is used in conjuction with Wait()ing on
	the signal bit of the channel port.

    DEOF()

	Eof a channel.	Implemented ONLY for the Amiga.  You cannot EOF
	a channel     h       Ls( if running between the Amiga and a UNIX machine.   This
	is essentially an unsupported call, and you should use DCLose()
	to close(and send an eof) on a channel.  The network handles it
	just fine, but the UNIX side has no way of sending an EOF over
	a socket without closing the socket.

    DLISTEN()

	This call listens on a virtual port # (0-65535) for connections
	from a remote host.  NULL is returned if the port is already
	being listened on by somebody else.

    DACCEPT()

	Ac     h       MYͫcepts connections over a virtual port #.  Several connections
	may be accepted and worked on simultaniously.  NULL is returned if
	there are no pending connections.  You can WaitPort() on the
	listenport to wait for new connections, but should note that
	even after a WaitPort(), DAccept() might return NULL every
	once in a while.

	DAccept() will set the signal bit associated with the port if
	further connections are pending.

    DNAACCEPT()

	Don't accept connections over a virtual     h       No9 port #.  If there is a
	connection pending, it will return an error on the other end.
	Returns 1 if a connection was refused, 0 if there were no
	pending connections.

    DUNLISTEN()

	Stop listening on a virtual port #.  Any pending requests are
	automatically DNAAccept()ed.

    DPRI()

	Set the priority of a channel (-128 lowest to 127 highest).
	The priority only effects throughput when two or more channels
	at different priorities are transfering data at the same time.

	Not c     h       <^urrently implemented.. priority is what you set in DOpen()

    DNREAD()

	Read data from a channel.  0 is a valid return value, meaning that
	no data is currently ready to read.  You can WaitPort() on the
	channel port to wait for data (or EOF).  A negative value is
	returned on EOF or failure.

	error codes:
		    -1	EOF on channel
		    -2	Remote end CLOSED the channel (not implemented)

    DREAD()

	Read data from a channel.  The number of bytes requested are
	returned, unless t     h       P*es)   (see below)
	    act = DWrite(chanport, buf, bytes)  act = -1 or bytes
		  DEof(chanport)                send eof (amiga<>amiga only)
		  DQueue(chanport, maxq)        set asynchronous queue write
						queue size (default 0)
		  DClose(chanport)              close a channel
		  DUnListen(listenport)         stop listening on a channel

		  DQuit(host)                   cause remote end to quit out
						of the DNET protocol.

General notes:
	The calls have a notion of ownershi     h       JGIϰp.  The task which created
	the listen port or openned the channel owns it.  Foreign tasks
	may DAccept() connections on somebody elses listen port (i.e.
	your server creates a task to handle the accept).  In fact, this
	is the only way you can spawn off tasks to handle new connections
	as only the owner of a channel (caller of DAccept()/DOpen()) may
	use the channel.

	The calls are not extremely efficient at the momement, but since
	the network, by virtue of being on a serial line,     _       H#jemainder will be downloaded and
	appended to the local file.

				    SECURITY

	The remote host, if an amiga, will impose security restrictions on
	those files allowed to be downloaded according to the comment field
	of said files or any parent directory and the current DNET_READ
	accesslevel.

	If the remote AMIGA's DNET_READ enviroment variable is set 9 or
	higher, no access restrictions are imposed.

	If the remote AMIGA's DNET_READ enviroment variable is less than
	9, the commen     S       S;Zure enhancements such as an
    automated email network can be added without the burden of automatically
    starting up a BBS everytime.

    I also plan to implement a CRON based auto-dialer for email transfer.

		----------------------------------------------

			       RUNNING AS A DBBS

    The DBBS server program is a BBS system for the Amiga which runs under
    DNet.  The following is an example command line for automatic
    operation.	Your modem must implement the CD (carri     S       T]Cer detect) line and
    must disconnect when DTR is dropped.

	Run dnet -8 -a -bmaxbaud -sdbbs     (other options may apply)

    That is, 8 bits no parity for the initial window (doesn't matter unless
    you have one of those stupid-smart modems), answer mode (automatic
    protocol startup on carrier detect), the maximum baud rate your modem
    can handle, and to run the DBBS client on protocol startup.

    The DBBS program is the BBS program itself.  It is a client in that you
     S       UMO    RUN it (or allow DNET to run it via the -s option).  It is a server in
    that it passively waits for connections from the remote end.  This
    program also handles disconnecting users when their time runs out or
    they are idle too long.

    REFER to DBBS.DOC FOR FURTHER INFORMATION

    Since PUTFILES is a security hole right now, rather than have users
    of the BBS PUTFILES to upload, they will request the BBS to GETFILES
    the files to upload.

    *NEVER SET YOUR DN     S       VLET_LEVEL or DNET_WRITE TO 9 OR ABOVE!  Doing so gives
     remote users sysop level access to DNet.

    NOTE:   I intend to implement a mail network at some point.  Remember
    that in the future, users will dial up and connect to your machine to
    do things other than just use the DBBS (i.e. they'll connect to the
    EMAIL server in many cases for an automated mail transfer).


VERSION 2.04
    Added -m option
    Added -P option, now supports use of XON-XOFF or 7WIRE modes
        S      V    O Now supports 7 bit lines (only 0x20-0x7F is ever sent)

VERSION 2.00

VERSION 1.00


 passively waits for connections from the remote end.  This
    program also handles disconnecting users when their time runs out or
    they are idle too long.

    REFER to DBBS.DOC FOR FURTHER INFORMATION

    Since PUTFILES is a security hole right now, rather than have users
    of the BBS PUTFILES to upload, they will request the BBS to GETFILES
    the files to upload.

    *NEVER SET YOUR DN     U       Xel-access>  for example,

	example

    USER dillon casmtrek 9 9 9

    This server is useful as it allows you to leave your Amiga unattended
    in auto-answer mode (with default security permissions 0 0 0).  You
    can call up your amiga, connect to the SPASSWD server and enter your
    own personal user-name/password to gain full access to your amiga
    for the duration of the call.  When you hang up, the amiga will
    automatically restore permissions to the default for the ne     U          xt caller.


  Using FTERM to gain access to the SPASSWD server.

    FTERM 8199	    (Amiga<->Amiga connection, from calling amiga)
    DSOC 8199	    (Unix<->Amiga connection, from calling unix machine)

    This connects to the SPASSWD server on the Amiga which requests a
    login and password to gain any level of security access to the amiga.

    S:DNET.CONFIG may contain zero or more entries of the following form:

    USER <username> <password> <read-access> <write-access> <lev     Y         ԹENTED YET)
		->doc	    docs

    s:dnet.servers	    file listing servers and their locations
			    (MODIFY ACCORDING TO WHERE YOU PUT THE BINARIES)

    s:dnet.config	    universal configuration file for various modules

    libs:dres.library	    Required to exist

	      IF RUNNING A DBBS, assign DBBS: to wherever you put your
	      DBBSCTL directory.

	  |
	  |	    (NOT IMPLEMENTED YET)
    DBBS: |
	  |
	  |

oc                                                           L         [       [main with
your own.  You must then setup the listen port and wait/reply the startup
message from DNET.  See the source (for example, SERVER/STERM.C) for
an example.

The server can exit at any time after it DUnListen()'s the port.  Multiple
DNET's will all use the same server for a specific port #.

_main()
{
    struct Message *msg;
    long mask, pmask, hdmask;
    PROC *proc = FindTask(NULL);

    Enable_Abort = 0;
    LisPort= DListen(PORT_IALPHATERM);
    WaitPort(&proc->pr_MsgP     [      U    ԓort);
    ReplyMsg(GetMsg(&proc->pr_MsgPort));
    if (!LisPort)
	exit(1);

	    ...
ver.	This is
accomplished by DNET doing a LoadSeg() and CreatProc().  The server
CANNOT GO THROUGH A NORMAL STARTUP for several reasons:

	(1) There is no CLI and the message passed over the process
	    port is DNET specific (NOT a workbench message)

	(2) Registers contain garbage (no argument line)

	(3) No standard file handles exist


For AZTEC C, this is accomplished by overiding the standard _     ]       Gq_	emote machine must have the Amiga OS V1.3 NewShell command
    installed as well as DPIPE:, and the DNET_LEVEL enviroment variable
    must be at least 9 (accomplished by the remote user running dnet -X or
    modifying s:dnet.config).  A shell initialization from file,
    s:remote-startup, is automatically executed by the shell.

    It is suggested that the program "noreq" be run by s:remote-startup
    to disable requesters (or your remote CLI will freeze when you make
    a mist     S   	    ^Wximately
		25% larger in 7 bit mode.  Packets containing ascii data will
		be normal-sized.

		In 8 bit mode, simple compression may actually occur... packets
		containing all ascii data 0x00-0x7F will be compressed to make
		use of the 8th bit which would normally be 0, giving an
		aproximately 1/8 speed increase.

    -Pn 	n = 0	none
		    1	xon-xoff
		    2	7wire

		if -P not specified then the preferences protocol is used.

    -Zn 	n = 0	8-no parity
		    1	7-odd
		    2	7-even
     S   
    _		    3	7-mark
		    4	7-space

		if no -Z option is specified the preferences parity and
		wordlength is used.

		WARNING:  You CANNOT combine xon/xoff *and* -m0.


	     ---------------------------------------------------
				SECURITY

    The following enviroment variables should exist:

	DNET_LEVEL, DNET_READ, DNET_WRITE, DNET_GROUP, DNET_USERID

    These are setup automatically by the S:dnet.config file depending on
    the mode (Manual, DialOut (-X), AutoAnswer (-a)) and are r     S       `jlead by local
    servers to determine what the remote machine is allowed to do.  These
    variables each hold a single value, normally 0-9 (except for DNET_GROUP
    which can be any number 0-32767).

    SGCOPY (server for getfiles):

	This is a new server.

	DNET_READ and DNET_GROUP  determine which files the remote machine may download
	(read).  In order for the remote to be able to download a file,
	that file and all its parent directories are scanned.  At least
	one comment fie     S       a06ld must have an AC entry (AC=n) less than or
	equal to the current DNET_READ enviroment variable or sgcopy will
	disallow the download.	If NO comment fields have an AC entry
	the download is disallowed.  If any comment field has an AC
	entry > DNET_READ, the download is disallowed unless a GP entry
	was found (GR=n).

	A comment field may have multiple GR entries (GR=n GR=n ...).  If
	any matches DNET_GROUP and all (if any) AC fields are <= DNET_READ,
	the download is allowed.

	Afte     S       bar that point a download will begin and files/dirs need not have
	AC entries.  However, if any do, it will be checked again DNET_READ
	and the download (for that file or directory) disallowed.

    SCOPY (server for putfiles)

	This server allows remote machines to upload a file.  That is,
	transfer from the remote machine to the local machine.	DNET_WRITE
	must be 9 or higher or the upload will be disallowed.  Currently,
	the remote machine may upload anywhere so it is suggested that      S       c`*you
	either NOT have the SCOPY server installed or do not set DNET_WRITE
	to 9 or beyond when talking to possibly hostile remote machines.

    SPRINT (printer server)

	This server copies a stream to PRT:  DNET_WRITE must be at least
	6 or the remote machine will not be allowed to use this server.

    SCLI (CLI server)

	This server is currently a big hack and requires a special pipe
	device to work (The 1.3 pipe: will not work).

	DNET_LEVEL must be at least 9 for a remote machine     S       db\x to be able to
	start a remote cli

    STERM  (terminal window server)

	This server requires no permissions to operate and allows the
	remote machine to bring up a 'terminal window' to talk you
	through.

    AUTOMATIC ENVIROMENT VARIABLE CONFIGURATION CAN BE DONE FROM
    S:DNET.CONFIG

	     ---------------------------------------------------

			    TALKING TO A DBBS

    Amiga users wishing to connect to DBBS hosts should use the following
    command line:

	Run dnet -8 -sbbst     S       eKerm

    The -8 is required only if you have a stupid 'smart' modem which
    figures out the parity and then stays with it forever after.  Since
    neither -a or -X have been given, you are in the medium-security
    'dial-out' mode.

    Then, dial up the BBS in question.	If the other end is indeed a
    DNET-BBS running under automatic operation, the protocol should start
    up almost immediately.  On protocol startup, your side will
    automatically attempt to run the BBSTERM      S       fbprogram (which connects to the
    BBS server on the other end).  NOTE that the BBSTERM executable and
    FTERM executable are one and the same.  The naming 'BBSTERM' causes
    it to use the BBS's port (8200) instead of the STERM port (8195)

    Currently the BBS server will allow only one connection at a time and
    return other attempts with an error.  However, you can still download,
    upload, readmail, and talk to the sysop all at the same time.

			Downloading files from t     S       g,he DBBS

    The getfiles client program is used to retrieve files from the DBBS.
    The DBBS will set security options and such to allow you to download
    files.

		    Allowing the DBBS to upload files from you

    At least one of the directories in the path leading to the eventual
    file/dir that you want to upload to the BBS must have a comment
    field containing the string AC=<n>	(e.g. AC=1) where <n> is at least
    whatever read security level you have set (the DNET_RE     S       RnAD enviroment
    variable, for example:  setenv DNET_READ 1), or the DBBS will be unable
    to retrieve the file(s)/dir(s) and will tell you so.


	     ---------------------------------------------------
			       EMAIL NETWORK

    Has not been implemented yet, but will eventually be just another
    server.  This is one of the reasons why the connect-to-BBS is done
    by the caller rather than have the BBS automatically startup an STERM
    on protocol startup ... this way, fut     F          Ycontrol file

BITL	300
BSTL	30
BLOG	dnet:bbs/bbs.log
BMEN	dnet:bbs/menu.ctl
BMSG	dnet:bbs/message.ctl
BFIL	dnet:bbs/file.ctl
BUSR	dnet:bbs/userinfo.ctl

#   SPASSWD server

USER	dillon	pineapple   9 9 9
USER	bounce	-	    0 0 0

 enviroment
# ENVM	-manual (no -a) option enviroment
#
#   LEVEL   overall access rights
#   READ    basic access rights for reading files from this machine
#   WRITE   basic access rights for writing files to this machine

ENVA DNET_LEVEL     9
ENVA DNET_READ     S       jsince you
    do not know who is calling you up.	DialOut is less so since you know
    who you are dialing, and Manual assumes a non-hostile enviroment.

    These three modes also cause DNet to work differently.


AMIGA/DNET

    DialOutMode:    The default mode is DialOutMode (neither -X or -a
		given).  DNet will look for a CONNECT message on carrier
		detect and modify the baud rate according to the AUTA
		resources.

		DNet will set the security modes to the ENVO (originate)
		r     S       kYO%esources in s:dnet.config

		NOTE:  response through the initial window will be slow due
		to DNet's scanning of the resource file s:dnet.config.

    -X		Manual mode.  DNet will look for a CONNECT message on
		carrier detect and modify the baud rate on connect
		appropriately.

		DNet will set the security modes to the ENVM resources
		which assumes a friendly connection.

    -a		Auto Answer mode.  DNet will send the RESM resources at
		the originally specified baud rate to reset t     S       lhe modem
		whenever carrier is lost.

		The security modes are set the the ENVA resources, which
		normally assume a hostile enviroment.

    -8		Use 8 bits no parity for the initial window rather than
		7 bits even parity.  NOTE!  This only effects the initial
		login window.  The Protocol, when running, always uses
		8 bits no parity.

    -bbaud	Set Initial Baud rate (otherwise uses preferences baud
		rate)

    -Bbaud	Set Baud used to determine timeouts.  If not set, the
		curren     S       m#Uet baud rate, whatever that is, is used.  If set,
		this value is used to calculate timeouts forever after
		no matter what the actual line baud rate is.

		For example, setting this value lower than whatever baud
		rate you normally use will allow for longer line delays
		(such as when dialing through networks and things)

    -sclient	Run the specified client program on protocol start.  If
		running a BBS you want to specify the BBS client program
		here.

		NOTE:  If the DNET_NORUN     S       ne>CLIENT enviroment variable is set,
		no client program will be run even if this option is
		specified.  This is used by DBBS to ensure that DNet does
		not start it several times.  This enviroment variable is
		automatically deleted when DNET is first run.

		The default is to run the FTERM client.


    -nhostname	Set the hostname (not used)

    -h1 	Enable Carrier checking.  Default is to not check the CD
		line (reversed from earlier versions).  Note that carrier
		checking is fo     S       ]^xrced if you use -a (auto answer) mode.

    -U# 	Set the unit number for the low level serial-like device
		to talk over.

    -Ddevice	Set the device name for the low level serial-like device
		to talk over (i.e. "serial.device").

    -N# 	Set the network ID for local client/server rendezvous

    -p		Packet Debug mode

    -d		Debug mode on

    -m0 	Select 8 bit packet mode (default is -m1 which selects
		7 bit packet mode)

		Note that packets containing binary data will be apro     Q       p0ap'.  This adds another process
    to the character-loop.

    The default port# is 8195.	You can also specify another port # to
    connect to.

    The -N option specifies the network (default = 0).  This is the same
    network as was specified when you ran DNET (if was not specified, is 0)

    The -c# option (-c7 for example) sets the 'cooked' mode.  Bits are
    defined as follows:

		bit
		0   turn keyboard CR's into LFs when sent to remote
		1   Local Echo (half duplex)
		2        Q       qcause received LFs to generate a CR+LF (i.e. CSI20h)

    -wcapturefile   Specify name of capture file, else "ram:capture".

    Menus:  (partially implemented):  Capture -capture into ram:capture

				      Paste   -pastes from ram:paste

				      Flush   -get rid of buffered data
					       on remote end (that would
					       otherwise take a long time
					       to display)

    BBSTERM is simply FTERM renamed, and uses PORT_BBS (8200) instead of
    PORT_IALPHATERM (8195).

     Q     @    sAi    RELEASE INFO:

    V1.10   DNET 1.10 release

	    -Implements auto window resize and auto-remote-resize
	    -Implements local echo (cooked mode) and buffering

	    Remote STERM implements equivalent options and now has the
	    same resize/echo/remote-resize capabilities as FTERM.

    V1.00   Initial Release


or example) sets the 'cooked' mode.  Bits are
    defined as follows:

		bit
		0   turn keyboard CR's into LFs when sent to remote
		1   Local Echo (half duplex)
		2        S       in must be in your path.
    (i.e. FTERM, PUTFILES, GETFILES ...)

    Other files will be required if you intend to run DNet *as* a BBS.




			      DNET OPTIONS

    (please refer to S:DNET.CONFIG while reading this)

    DNet runs in three basic modes:  AutoAnswer (-a), DialOut (default),
    and Manual (-X).  Each mode has its own default set of security
    parameters.  The shipped defaults assume a hostile enviroment.
    Generally,	AutoAnswer is assumed to be the most hostile      >   	    tdicw->io_Data = (APTR)buf;
		iocw->io_Length = n;
		DoIO((RIO *)iocw);
	    }
	    if (n == -2) {
		short val;
		short cmd;
		char aux;

		cmd = DGetIoctl(chan, &val, &aux);
		HandleIoctl(cmd, val, aux, Win, iocw);
		/*
		if (cmd == CIO_MODE) {
		    if (val)
			SetWindowTitles(Win, "(Cooked)", (char *)-1);
		    else
			SetWindowTitles(Win, "(Raw)", (char *)-1);
		}
		*/
	    } else if (n < 0)
		notdone = 0;
	}
	if (mask & conmask) {
	    if (CheckIO((RIO *)iocr)) {
		WaitIO((RIO *)io     >   
    ucr);

		if (Cc == '\r')
			Cc = '\n';
		inputbuf[bp++] = Cc;

		if (Cc == 0x08) {
		    if (bp <= 1) {
			bp = 0;
		    } else {
			localecho(0x08);
			localecho(0x20);
			localecho(0x08);
			bp -= 2;
		    }
		} else if (Cc == 0x18) {
		    while (--bp > 0) {
			localecho(0x08);
			localecho(0x20);
			localecho(0x08);
		    }
		} else if (Cc == '\n') {
		    localecho('\n');
		    localecho('\r');
		    DWrite(chan, inputbuf, bp);
		    bp = 0;
		} else {
		    localecho(Cc);
		}

	     >       v
e	iocr->io_Data = (APTR)&Cc;
		iocr->io_Length = 1;
		SendIO((RIO *)iocr);
/*
		if (Cc == '\r') {
		    Cc = '\n';
		    DWrite(chan, &Cc, 1);
		    iocr->io_Data = (APTR)&Cc;
		    iocr->io_Length = 1;
		    SendIO(iocr);
		}
*/
	    }
	}
    }
    AbortIO((RIO *)iocr);
    WaitIO((RIO *)iocr);
    SetWindowTitles(Win, "Closing...", (char *)-1);
    DClose(chan);
e3: CloseConsole(iocr,iocw);
    CloseWindow(Win);
e1: CloseLibrary((LIB *)IntuitionBase);
    CloseLibrary((LIB *)GfxBase     >       w2);
}

void
localecho(c)
int c;
{
    char cc;

    cc = c;
    iocw->io_Data = (APTR)&cc;
    iocw->io_Length = 1;
    DoIO((RIO *)iocw);
}

void
OpenConsole(win, piocr, piocw)
IOCON **piocr, **piocw;
WIN *win;
{
    PORT *port;
    static IOCON iocr, iocw;
    int error;

    port = CreatePort(NULL, 0);
    iocr.io_Command = CMD_READ;
    iocr.io_Data = (APTR)win;
    iocr.io_Message.mn_Node.ln_Type = NT_MESSAGE;
    iocr.io_Message.mn_ReplyPort = port;
    error = OpenDevice("conso     >       x<le.device", 0, (RIO *)&iocr, 0);
    if (!error) {
	iocw = iocr;
	iocw.io_Command = CMD_WRITE;
	*piocr = &iocr;
	*piocw = &iocw;
    } else {
	*piocr = *piocw = NULL;
    }
}

void
CloseConsole(iocr, iocw)
IOCON *iocr;
IOCON *iocw;
{
    IOCON *tmp = (iocr) ? iocr : iocw;
    if (tmp) {
	CloseDevice((RIO *)tmp);
	DeletePort(tmp->io_Message.mn_ReplyPort);
    }
}

void
setsize(iocw, chan, win)
IOCON *iocw;
void *chan;
WIN *win;
{
    struct ConUnit *cu = (struct ConUnit *)iocw->io_Uni     >       yCt;
    static char IStr[] = { "\033c\23320l\233t\233u" };

    /*
    if (Cooked & 4)
	IStr[5] = 'h';
    else
	IStr[5] = 'l';
    */
    iocw->io_Data = (APTR)IStr;
    iocw->io_Length = sizeof(IStr) - 1;
    DoIO((RIO *)iocw);
    if (chan) {
	DIoctl(chan, CIO_SETROWS, (uword)(cu->cu_YMax+1), 0);
	DIoctl(chan, CIO_SETCOLS, (uword)(cu->cu_XMax+1), 0);
    }
    sprintf(Term, "FTERM   %ld x %ld", cu->cu_YMax+1, cu->cu_XMax+1);
    SetWindowTitles(win, Term, (char *)-1);
}

void
Handl     >       zeIoctl(cmd, val, aux, win, iocw)
short cmd, val;
char aux;
WIN *win;
IOCON *iocw;
{
    static short saverows;
    short height, width;
    short dx, dy;

    switch(cmd) {
    case CIO_MODE:
	/*
	Cooked = val;
	*/
	break;
    case CIO_SETROWS:
	saverows = val;
	break;
    case CIO_SETCOLS:
	width = val * win->RPort->TxWidth + win->BorderLeft + win->BorderRight;
	height= saverows * win->RPort->TxHeight + win->BorderTop + win->BorderBottom;

	dx = win->WScreen->Width - (win->LeftEdge      >       {\++ width);
	if (dx > 0)
	    dx = 0;
	if (-dx > win->LeftEdge) {
	    dx = -win->LeftEdge;
	    width = win->WScreen->Width;
	}

	dy = win->WScreen->Height - (win->TopEdge + height);
	if (dy > 0)
	    dy = 0;
	if (-dy > win->TopEdge) {
	    dy = -win->TopEdge;
	    height = win->WScreen->Height;
	}

	if (dx || dy) {
	    MoveWindow(win, dx, dy);
	}
	if (win->Width != width || win->Height != height) {
	    SizeWindow(win, width - win->Width, height - win->Height);
	    ++IgnoreNS;
	}
	     >          /1break;
    }
}

 aux, win, iocw)
short cmd, val;
char aux;
WIN *win;
IOCON *iocw;
{
    static short saverows;
    short height, width;
    short dx, dy;

    switch(cmd) {
    case CIO_MODE:
	/*
	Cooked = val;
	*/
	break;
    case CIO_SETROWS:
	saverows = val;
	break;
    case CIO_SETCOLS:
	width = val * win->RPort->TxWidth + win->BorderLeft + win->BorderRight;
	height= saverows * win->RPort->TxHeight + win->BorderTop + win->BorderBottom;

	dx = win->WScreen->Width - (win->LeftEdge      F       }elt is ENVO.  The -a option for DNET selects ENVA, -X selects
#   ENVM.  Note that the default assumes a hostile enviroment.
#
# ENVA	-auto answer (-a) option enviroment
# ENVO	-originate (you are dialing up somebody else) option enviroment
# ENVM	-manual (no -a) option enviroment
#
#   LEVEL   overall access rights
#   READ    basic access rights for reading files from this machine
#   WRITE   basic access rights for writing files to this machine

ENVA DNET_LEVEL     9
ENVA DNET_READ     F       h	    9
ENVA DNET_WRITE     9

ENVO DNET_LEVEL     1
ENVO DNET_READ	    1
ENVO DNET_WRITE     1

ENVM DNET_LEVEL     9
ENVM DNET_READ	    9
ENVM DNET_WRITE     9


#   BBS control files
#
#   BITL : Idle time limit (no activity), seconds (normally 5 min)
#   BSTL : Base session time limit, minutes (modified by user entry), 30.
#   BLOG : log file
#   BMEN : Menu control file
#   BUSR : User Information control file (information fields)
#   BMSG : Message control file
#   BFIL : DL/UL      3       
{
    static short saverows;
    short height, width;
    short dx, dy;

    switch(cmd) {
    case CIO_MODE:
	Cooked = val;
	break;
    case CIO_SETROWS:
	saverows = val;
	break;
    case CIO_SETCOLS:
	width = val * win->RPort->TxWidth + win->BorderLeft + win->BorderRight;
	height= saverows * win->RPort->TxHeight + win->BorderTop + win->BorderBottom;

	dx = win->WScreen->Width - (win->LeftEdge + width);
	if (dx > 0)
	    dx = 0;
	if (-dx > win->LeftEdge) {
	    dx = -win->LeftEdge;     3         b=n
	    width = win->WScreen->Width;
	}

	dy = win->WScreen->Height - (win->TopEdge + height);
	if (dy > 0)
	    dy = 0;
	if (-dy > win->TopEdge) {
	    dy = -win->TopEdge;
	    height = win->WScreen->Height;
	}

	if (dx || dy) {
	    MoveWindow(win, dx, dy);
	}
	if (win->Width != width || win->Height != height) {
	    SizeWindow(win, width - win->Width, height - win->Height);
	    ++IgnoreNS;
	}
	break;
    }
}


d, val, aux, win, iocw)
short cmd, val;
char aux;
WIN *win;
IOCON *iocw;     >       LNZruct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;
IOCON *iocr, *iocw;

void OpenConsole ARGS((WIN *, IOCON **, IOCON **));
void HandleIoctl ARGS((short, short, char, WIN *, IOCON *));
void CloseConsole ARGS((IOCON *, IOCON *));
void setsize ARGS((IOCON *, void *, WIN *));
void localecho ARGS((int));

void main ARGS((int, char **));

int
brk()
{
    return(0);
}

void
main(ac,av)
char *av[];
{
    void *chan;
    long imask, conmask, dmask, mask;
    char notdone = 1;
    ch     >       4Far portspec = 0;
    char *host = NULL;
    uword port = PORT_AMIGASHELL;
    int i;
    int bp = 0;
    char inputbuf[256];

    onbreak(brk);
    sprintf(Title, "CLITerm V%s%s opening, wait..", VERSION, CLITERM_VERSION);
    {
	short i;
	for (i = 1; i < ac; ++i) {
	    if (strncmp(av[i], "-N", 2) == 0) {
		host = av[i] + 2;
		continue;
	    }
	    portspec = 1;
	    port = atoi(av[i]);
	}
    }
    if (portspec)
	printf("Using port %ld\n", port);
#ifndef LATTICE
    Enable_Abort =      >       }^0;
#endif
    IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 0);
    GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0);
    Win = OpenWindow(&Nw);
    if (Win == NULL)
	goto e1;
    OpenConsole(Win, &iocr, &iocw);
    if (iocr == NULL || iocw == NULL)
	goto e3;

    /*
     *	We delay here to allow DNET to go through its RESTART sequence
     *	(when DNET automatically runs FTERM, it does so to quickly).
     *	Such a hack!
     */

    Delay(50     >       Nb * 4);
    chan = DOpen(host, port, 20, 15);

    if (!chan) {
	puts("Unable to connect");
	goto e3;
    }
    DQueue(chan, 32);
    SetMenuStrip(Win, Menu);
    SetWindowTitles(Win, Term, (char *)-1);
    imask   = 1 << Win->UserPort->mp_SigBit;
    dmask   = 1 << ((PORT *)chan)->mp_SigBit;
    conmask = 1 << iocr->io_Message.mn_ReplyPort->mp_SigBit;
    iocr->io_Data = (APTR)&Cc;
    iocr->io_Length = 1;
    SendIO((RIO *)iocr);

    setsize(iocw, chan, Win);

    while (notdone) {     :      0    ary	    LIB;
typedef struct FileInfoBlock FIB;

                                                                                                                                                                                                                                          7  6              t                                                                                              
    	DMakefile                                                            *         >       ̾
	mask = Wait(imask|dmask|conmask);
	if (mask & imask) {
	    IMESS *im;
	    while (im = (IMESS *)GetMsg(Win->UserPort)) {
		switch(im->Class) {
		case NEWSIZE:
		    if (IgnoreNS) {
			--IgnoreNS;
			setsize(iocw, NULL, Win);
		    } else {
			setsize(iocw, chan, Win);
		    }
		    break;
		case CLOSEWINDOW:
		    notdone = 0;
		    break;
		case MENUPICK:
		    switch((uword)((MENUNUM(im->Code)<<8)|ITEMNUM(im->Code))) {
		    case 0x0000:    /*	menu 0 item 0	*/
			DIoctl(chan, CI     <          PQuit(host);   /*  NULL ok */
    if (ok) {
	Delay(50 * 5);
	DBreak(host);
    } else
	puts("DNET master port for network not found");
}

                                                                                                                                                     9               +                                                                                              
    *syms.c                                                               *         >       s#O_FLUSH, 0, 0);
			break;
		    case 0x0001:    /*	menu 0 item 1	*/
		    case 0x0002:    /*	menu 0 item 2	*/
		    case 0x0100:    /*	menu 1 item 0	*/
			break;
		    }
		    break;
		default:
		    break;
		}
		ReplyMsg((MSG *)im);
	    }
	}
	if (mask & dmask) {
	    char buf[256];
	    int n;
	    if ((n = DNRead(chan, buf, 256)) > 0) {
		for (i = 0; i < n; i++) {
		    if (buf[i] == '\n') {
			movmem(&buf[i], &buf[i + 1], n - i);
			buf[i] = '\r';
			i++;
			n++;
		    }
		}
		io     >       CD|HIGHCOMP, 0, (APTR)&IText[0], NULL, 'o' }
};

MENU Menu[] = {
    { NULL    , 0, 0, 100, 20, MENUENABLED, "Control", &Item[0] }
};

char Title[80];

NW Nw = {
    0, 12, 640, 60, -1, -1,
    NEWSIZE|CLOSEWINDOW|MENUPICK,
    WINDOWSIZING|WINDOWDRAG|WINDOWDEPTH|WINDOWCLOSE|NOCAREREFRESH|ACTIVATE,
    NULL, NULL, (ubyte *)Title, NULL, NULL,
    32, 32, -1, -1, WBENCHSCREEN
};

WIN *Win;

extern int Enable_Abort;
char Buf[512];
char Term[64] = { "FTERM (UNNAMED SHELL)" };
char Cc;

st     3       }apfi = fopen(capfile, "a");
    if (portspec)
	printf("Using port %ld\n", port);
#ifndef LATTICE
    Enable_Abort = 0;
#endif
    IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 0);
    GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0);

    InitDeemuNW(Deemu+DMNWOFF, &Nw);
    {
	char *p1, *p2;
	p1 = (char *)(Deemu+DMFONTSTR) + strlen((char *)(Deemu+DMFONTSTR)) + 1;
	for (p2 = p1 + strlen(p1); p2 != p1 && *p2 != '.'; --p2);
	if (*p2 == '.') {
	      3   	    s[>   *p2 = 0;
	    font = (FONT *)GetFont(p1, (short)atoi(p2+1));
	}
    }

    Win = OpenWindow(&Nw);
    if (Win == NULL)
	goto e1;
    if (font) {
	SetFont(Win->RPort, font);
	SetRast(Win->RPort, 0);
	RefreshWindowFrame(Win);
    }
    OpenConsole(Win, &iocr, &iocw);
    if (iocr == NULL || iocw == NULL)
	goto e3;

    /*
     *	We delay here to allow DNET to go through its RESTART sequence
     *	(when DNET automatically runs FTERM, it does so to quickly).
     *	Such a hack!
          3   
    "EБ*/

    Delay(50 * 4);
    chan = DOpen(host, port, 20, 15);

    if (!chan) {
	puts("Unable to connect");
	goto e3;
    }
    DQueue(chan, 32);
    SetMenuStrip(Win, Menu);
    SetWindowTitles(Win, Term, (char *)-1);
    imask   = 1 << Win->UserPort->mp_SigBit;
    dmask   = 1 << ((PORT *)chan)->mp_SigBit;
    conmask = 1 << iocr->io_Message.mn_ReplyPort->mp_SigBit;

    iocr->io_Data = (APTR)&Cc;
    iocr->io_Length = 1;
    SendIO(iocr);

    setsize(iocw, chan, Win);
    while (n     3       BPotdone) {
	mask = Wait(imask|dmask|conmask);
	if (mask & imask) {
	    IMESS *im;
	    while (im = (IMESS *)GetMsg(Win->UserPort)) {
		switch(im->Class) {
		case NEWSIZE:
		    if (IgnoreNS) {
			--IgnoreNS;
			setsize(iocw, NULL, Win);
		    } else {
			setsize(iocw, chan, Win);
		    }
		    break;
		case CLOSEWINDOW:
		    notdone = 0;
		    break;
		case MENUPICK:
		    switch((uword)((MENUNUM(im->Code)<<8)|ITEMNUM(im->Code))) {
		    case 0x0000:    /*	menu 0 item 0	*/
			DIoctl     3       ҕ(chan, CIO_FLUSH, 0, 0);
			break;
		    case 0x0001:    /*	menu 0 item 1	*/
			if (capfi)
			    fclose(capfi);
			capfi = fopen("ram:capture", "a");
			break;
		    case 0x0002:
			if (capfi)
			    fclose(capfi);
			capfi = fopen("ram:capture", "w");
			break;
		    case 0x0003:    /*	menu 0 item 2	*/
			if (capfi)
			    fclose(capfi);
			capfi = NULL;
			break;
		    case 0x0004:    /*	menu 0 item 3	*/
			{
			    FILE *fi;
			    long n;
			    if (fi = fopen("ram:paste", "r"))     3       P {
				while ((n = fread(Buf, 1, sizeof(Buf), fi)) > 0) {
				    DWrite(chan, Buf, n);
				}
				fclose(fi);
			    }
			}
			break;
		    case 0x0100:    /*	menu 1 item 0	*/
			break;
		    }
		}
		ReplyMsg((MSG *)im);
	    }
	}
	if (mask & dmask) {
	    int n;
	    if ((n = DNRead(chan, Buf, sizeof(Buf))) > 0) {
		iocw->io_Data = (APTR)Buf;
		iocw->io_Length = n;
		DoIO(iocw);
		if (capfi)
		    fwrite(Buf, n, 1, capfi);
	    } else if (n == -2) {
		short val;
		short cmd;
		char      3       ~Vaux;
		cmd = DGetIoctl(chan, &val, &aux);
		HandleIoctl(cmd, val, aux, Win, iocw);
		if (cmd == CIO_MODE) {
		    if (val)
			SetWindowTitles(Win, "(Cooked)", (char *)-1);
		    else
			SetWindowTitles(Win, "(Raw)", (char *)-1);
		}
	    } else if (n < 0) {
		notdone = 0;
	    }
	}
	if (mask & conmask) {
	    if (CheckIO(iocr)) {
		WaitIO(iocr);
		if (Cooked & 2) {       /*  Local Echo  */
		    iocw->io_Data = (APTR)&Cc;
		    iocw->io_Length = 1;
		    DoIO(iocw);
		}
		if ((Cooked     3       [. & 1) && Cc == 13) {
		    Cc = 10;
		    iocw->io_Data = (APTR)&Cc;
		    iocw->io_Length = 1;
		    DoIO(iocw);
		}
		DWrite(chan, &Cc, 1);
		iocr->io_Data = (APTR)&Cc;
		iocr->io_Length = 1;
		SendIO(iocr);
	    }
	}
    }
    AbortIO(iocr);
    WaitIO(iocr);
    SetWindowTitles(Win, "Closing...", (char *)-1);
    DClose(chan);
e3: CloseConsole(iocr,iocw);
    if (font) {
	SetFont(Win->RPort, Win->WScreen->RastPort.Font);
	CloseFont(font);
    }
    CloseWindow(Win);
e1: CloseLibr     3       0ary((LIB *)IntuitionBase);
    CloseLibrary((LIB *)GfxBase);
    if (capfi)
	fclose(capfi);
}

void
OpenConsole(win, piocr, piocw)
IOCON **piocr, **piocw;
WIN *win;
{
    PORT *port;
    static IOCON iocr, iocw;
    int error;

    port = CreatePort(NULL, 0);
    iocr.io_Command = CMD_READ;
    iocr.io_Data = (APTR)win;
    iocr.io_Message.mn_Node.ln_Type = NT_MESSAGE;
    iocr.io_Message.mn_ReplyPort = port;
    error = OpenDevice("console.device", 0, &iocr, 0);
    if (!error) {
	i     3       Focw = iocr;
	iocw.io_Command = CMD_WRITE;
	*piocr = &iocr;
	*piocw = &iocw;
    } else {
	*piocr = *piocw = NULL;
    }
}

void
CloseConsole(iocr, iocw)
IOCON *iocr;
IOCON *iocw;
{
    IOCON *tmp = (iocr) ? iocr : iocw;
    if (tmp) {
	CloseDevice(tmp);
	DeletePort(tmp->io_Message.mn_ReplyPort);
    }
}

void
setsize(iocw, chan, win)
IOCON *iocw;
void *chan;
WIN *win;
{
    struct ConUnit *cu = (struct ConUnit *)iocw->io_Unit;
    static char IStr[] = { "\033c\23320l\233t\233u" };

      3       ~<$   if (Cooked & 4)
	IStr[5] = 'h';
    else
	IStr[5] = 'l';
    iocw->io_Data = (APTR)IStr;
    iocw->io_Length = sizeof(IStr) - 1;
    DoIO(iocw);
    if (chan) {
	DIoctl(chan, CIO_SETROWS, (uword)(cu->cu_YMax+1), 0);
	DIoctl(chan, CIO_SETCOLS, (uword)(cu->cu_XMax+1), 0);
    }
    sprintf(Term, "FTERM   %ld x %ld", cu->cu_YMax+1, cu->cu_XMax+1);
    SetWindowTitles(win, Term, (char *)-1);
}

void
HandleIoctl(cmd, val, aux, win, iocw)
short cmd, val;
char aux;
WIN *win;
IOCON *iocw;     1   	    }cs routines.	************************************************
 */

short WOx, WOy, Ww, Wh;

void
clearwindow()
{
    short i, j, d;

    WOx = Win->BorderLeft;
    WOy = Win->BorderTop;
    Ww	= Win->Width - Win->BorderRight - Win->BorderLeft;
    Wh	= Win->Height- Win->BorderTop	- Win->BorderBottom;

    SetAPen(Rp, 0);
    RectFill(Rp, WOx, WOy, Ww + WOx, Wh + WOy);
    WOx += 2;
    WOy += 2;
    Ww	-= 4;
    Wh	-= 4;

    /*
     *	Redraw the graph.  Scale values relative to GMax     1   
    @J[?] and Wh.
     *
     *	ypos = (WOy + Wh) - (Wh * value / GMax[d])
     *
     */

    for (d = 0; d < GDEPTH; ++d) {
	char move = 1;
	SetAPen(Rp, (d & 1) ? 3 : 1);
	for (i = Ww - 1, j = Gi - 1; i >= 0; --i, --j) {
	    uword value = Wh * Graph[j&GMASK][d] / GMax[GMap[d]];
	    (move) ?
		Move(Rp, WOx + i, WOy + Wh - value - 1) :
		Draw(Rp, WOx + i, WOy + Wh - value - 1)
	    ;
	    move = 0;
	}
    }
}

/*
 *  5:44pm up 2 days, 22:30, 37 users, load average: 5.98, 7.93, 7.97
 *		      1       {     7 mins,
 */

void
updatewindow(str)
char *str;
{
    short d;
    char refresh = 0;
    uword ary[GDEPTH];

    {
	long nusers, i1, f1, i5, f5;
	char *ptr = str;

	while (strncmp(ptr, "users", 5) && *ptr)
	    ++ptr;
	while (*--ptr == ' ' && ptr != str)
	    --ptr;
	while (*--ptr != ' ' && ptr != str)
	    --ptr;
	nusers = atoi(ptr+1);
	while (strncmp(ptr, "load", 4) && *ptr)
	    ++ptr;
	sscanf(ptr, "load average: %ld.%ld, %ld.%ld,",
	    &i1, &f1, &i5, &f5
	);
	/*
	ary[0] = (i     1       *&1 << 8) | ((f1 << 8) / 100);
	*/
	ary[0] = (i5 << 8) | ((f5 << 8) / 100);
	ary[1] = nusers;
    }
    for (d = 0; d < GDEPTH; ++d) {
	while (ary[d] > GMax[GMap[d]] && ary[d] < 65000) {
	    GMax[GMap[d]] += GIncr[GMap[d]];
	    refresh = 1;
	}
	Graph[Gi][d] = ary[d];
    }
    if (!Initial) {
	short i;
	Initial = 1;
	for (i = 0; i < GWIDTH; ++i) {
	    for (d = 0; d < GDEPTH; ++d)
		Graph[i][d] = Graph[Gi][d];
	}
    }
    Gi = (Gi + 1) & GMASK;
    if (refresh) {
	clearwindow();
	re     1     s    dturn;
    }
    ScrollRaster(Rp, 1, 0, WOx, WOy, WOx + Ww - 1, WOy + Wh - 1);
    for (d = 0; d < GDEPTH; ++d) {
	uword value1 = Wh * Graph[(Gi-2)&GMASK][d] / GMax[GMap[d]];
	uword value2 = Wh * Graph[(Gi-1)&GMASK][d] / GMax[GMap[d]];
	SetAPen(Rp, (d & 1) ? 3 : 1);
	Move(Rp, Ww + WOx - 2, WOy + Wh - value1 - 1);
	Draw(Rp, Ww + WOx - 1, WOy + Wh - value2 - 1);
    }
}

 4) && *ptr)
	    ++ptr;
	sscanf(ptr, "load average: %ld.%ld, %ld.%ld,",
	    &i1, &f1, &i5, &f5
	);
	/*
	ary[0] = (i     3       `ITEMTEXT|COMMSEQ|ITEMENABLED|HIGHCOMP, 0, (APTR)&IText[0], NULL, 'o' },
    { &Item[2], 0,10, 100, 10, ITEMTEXT|COMMSEQ|ITEMENABLED|HIGHCOMP, 0, (APTR)&IText[1], NULL, 'a' },
    { &Item[3], 0,20, 100, 10, ITEMTEXT|COMMSEQ|ITEMENABLED|HIGHCOMP, 0, (APTR)&IText[2], NULL, 'n' },
    { &Item[4], 0,30, 100, 10, ITEMTEXT|COMMSEQ|ITEMENABLED|HIGHCOMP, 0, (APTR)&IText[3], NULL, 'c' },
    { NULL    , 0,40, 100, 10, ITEMTEXT|COMMSEQ|ITEMENABLED|HIGHCOMP, 0, (APTR)&IText[4], NULL, 'p' }
};

M     3       ENU Menu[] = {
    { NULL    , 0, 0, 100, 10+40, MENUENABLED, "Control", &Item[0] }
};

ubyte Title[80];

NW Nw = {
    0, 0, 640, 200, -1, -1,
    NEWSIZE|CLOSEWINDOW|MENUPICK,
    WINDOWSIZING|WINDOWDRAG|WINDOWDEPTH|WINDOWCLOSE|NOCAREREFRESH|ACTIVATE,
    NULL, NULL, Title, NULL, NULL,
    32, 32, -1, -1, WBENCHSCREEN
};

WIN *Win;

extern int Enable_Abort;
char Buf[512];
char Term[64];
char Cc;
char Cooked;	/*  bit 0 = cooked,  bit 1 = local echo */
char IgnoreNS;



struct Intuit     3       ionBase *IntuitionBase;
struct GfxBase *GfxBase;

void OpenConsole ARGS((WIN *, IOCON **, IOCON **));
void HandleIoctl ARGS((short, short, char, WIN *, IOCON *));
void CloseConsole ARGS((IOCON *, IOCON *));
void setsize ARGS((IOCON *, void *, WIN *));

void main ARGS((int, char **));

int
brk()
{
    return(0);
}

void
main(ac, av)
char *av[];
{
    void *chan;
    long imask, conmask, dmask, mask;
    IOCON *iocr, *iocw;
    char notdone = 1;
    char portspec = 0;
    char *host =      3       dNULL;
    char *capfile = NULL;
    FILE *capfi = NULL;
    uword port = PORT_IALPHATERM;
    FONT *font = NULL;

    onbreak(brk);
    sprintf(Title, "FTerm V%s%s", VERSION, FTERM_VERSION);
    strcpy(Term, Title);
    strcat(Title, " opening, wait ...");

    {
	char *str = av[0];
	for (str = str + strlen(str); str >= av[0]; --str) {
	    if (*str == '/' || *str == ':')
		break;
	}
	++str;
	if ((*str | 0x20) == 'b')   /*  bbsterm instead of fterm    */
	    port = PORT_BBS;
    }

     3       lM    {
	short i;
	for (i = 1; i < ac; ++i) {
	    char *ptr = av[i];
	    if (*ptr == '-') {
		while (*++ptr) {
		    switch(*ptr) {
		    case 'N':
			host = ptr + 1;
			ptr = "\0";
			break;
		    case 'w':
			capfile = ptr + 1;
			ptr = "\0";
			break;
		    case 'c':
			Cooked = atoi(ptr + 1);
			ptr = "\0";
			break;
		    default:
			printf("Unknown option: '%c'\n", *ptr);
			break;
		    }
		}
	    } else {
		portspec = 1;
		port = atoi(ptr);
	    }
	}
    }
    if (capfile)
	c     3       *V't.','8\0',0,0,0,0,0,0,
    DMEND , 0, 0
};

#define DMNWOFF     4
#define DMFONTSTR   17

TA Ta = { (ubyte *)"topaz.font", 8 };

ITEXT IText[] = {
    { 0, 1, JAM2, 0, 0, &Ta, (ubyte *)"Flush"          },
    { 0, 1, JAM2, 0, 0, &Ta, (ubyte *)"AppendCap"      },
    { 0, 1, JAM2, 0, 0, &Ta, (ubyte *)"NewCap"         },
    { 0, 1, JAM2, 0, 0, &Ta, (ubyte *)"CloseCap"       },
    { 0, 1, JAM2, 0, 0, &Ta, (ubyte *)"Paste"          }
};

ITEM Item[] = {
    { &Item[1], 0, 0, 100, 10,      /       m;
	}
	while (ExNext(lock, fib)) {
	    if (putname(chan, fib->fib_FileName) < 0) {
		ret = -1;
		goto f1;
	    }
	}
	writehdr(chan, 'Y', "?", 0);
f1:
	UnLock(CurrentDir(dirl));
    } else {
	UnLock(lock);
	ret = putfile(chan, file, fib->fib_FileName);
    }
    free(fib);
    return(ret);
}

int
putfile(chan, file, stripedname)
void *chan;
char *file;
char *stripedname;
{
    long fh = (long)Open(file, 1005);
    long n, r, len;
    long ttl = 0;
    char co;

    fflush(stdout);
        /       By if (fh == NULL) {
	puts("FILE NOT FOUND");
	return(0);
    }
    Seek(fh, 0, 1);                 /*  get length */
    len = ttl = Seek(fh, 0, -1);
    if (writehdr(chan, 'W', stripedname, len) != 'Y') {
	puts("REMOTE UNABLE TO ACCEPT FILE");
	Close(fh);
	return(0);
    }
    printf("%6ld/%-6ld", ttl - len, ttl);
    while (len) {
	fflush(stdout);
	r = (len > sizeof(Buf)) ? sizeof(Buf) : len;
	n = Read(fh, Buf, r);
	if (n != r) {
	    puts("Local File error");
	    Close(fh);
	    r     /       Neturn(-1);
	}
	if (DWrite(chan, Buf, n) != n) {
	    puts("Remote error");
	    Close(fh);
	    return(-1);
	}
	if (SetSignal(0,0) & (SIGBREAKF_CTRL_C|SIGBREAKF_CTRL_D)) {
	    puts("\nBreak");
	    Close(fh);
	    return(-1);
	}
	len -= n;
	printf("\010\010\010\010\010\010\010\010\010\010\010\010\010");
	printf("%6ld/%-6ld", ttl - len, ttl);
    }
    Close(fh);
    printf("Queued, waiting...");
    fflush(stdout);
    DRead(chan, &co, 1);
    if (co != 'Y') {
	puts("Remote Server S     /         .oftware Error");
	return(-1);
    }
    puts("  OK");
    return(0);
}

int
writehdr(chan, c, name, len)
void *chan;
unsigned char c;
char *name;
long len;
{
    if (DWrite(chan, &c, 1) != 1)
	return(-1);
    c = strlen(name) + 1;
    if (DWrite(chan, &c, 1) != 1)
	return(-1);
    if (DWrite(chan, name, c) != c)
	return(-1);
    if (DWrite(chan, &len, 4) != 4)
	return(-1);
    if (DRead(chan, &c, 1) == 1)
	return((int)c);
    return(-1);
}

"Local File error");
	    Close(fh);
	    r     1       v1;
    Iot.tr_time.tv_secs  = 0;
    SendIO((IOR *)&Iot);

#ifndef LATTICE
    Enable_Abort = 0;
#endif
    IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 0);
    GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0);

    chan = DOpen(host, PORT_LOADAV, 25, 25);
    if (chan == NULL) {
	puts("no connect");
	goto fail;
    }
    InitDeemuNW(Deemu+DMNWOFF, &Nw);
    Win = OpenWindow(&Nw);
    if (Win == NULL) {
	puts("Unable to open window");
	goto f     1       /ail;
    }
    Rp = Win->RPort;
    imask   = 1 << Win->UserPort->mp_SigBit;
    dmask   = 1 << ((PORT *)chan)->mp_SigBit;
    tmask   = 1 << TimPort->mp_SigBit;

    clearwindow();
    while (notdone) {
	mask = Wait(imask|dmask|tmask|SIGBREAKF_CTRL_C);
	if (mask & SIGBREAKF_CTRL_C)
	    notdone = 0;
	if (mask & imask) {
	    IMESS *im;
	    while (im = (IMESS *)GetMsg(Win->UserPort)) {
		switch(im->Class) {
		case NEWSIZE:
		    clearwindow();
		    break;
		case CLOSEWINDOW:
		         1       Znotdone = 0;
		    break;
		}
		ReplyMsg((MSG *)im);
	    }
	}
	if (mask & dmask) {
	    char dummy;
	    if ((dummy = DNRead(chan, &dummy, 1)) != 0)
		notdone = 0;
	}
	while (mask & tmask) {      /*  while just so we can break */
	    char len = 0;

	    if (GetMsg(TimPort)) {
		Iot.tr_time.tv_micro = 0;
		Iot.tr_time.tv_secs  = numsecs;
		SendIO((IOR *)&Iot);
		if (DWrite(chan, &len, 1) == 1 && DRead(chan, &len, 1) == 1) {
		    if (len < sizeof(Title) && DRead(chan, Title, len) ==     1       F len) {
			Title[len] = 0;
			updatewindow(Title);
			SetWindowTitles(Win, Title, (char *)-1);
			break;
		    }
		}
		notdone = 0;
	    }
	    break;
	}
    }

fail:
    if (Iot.tr_node.io_Device) {
	AbortIO((IOR *)&Iot);
	WaitIO((IOR *)&Iot);
	CloseDevice((IOR *)&Iot);
    }
    DeletePort(TimPort);
    if (Win)
	CloseWindow(Win);
    if (chan)
	DClose(chan);
    if (IntuitionBase)
	CloseLibrary((LIB *)IntuitionBase);
    if (GfxBase)
	CloseLibrary((LIB *)GfxBase);
}

/*
 *  Graphi     1       iWIDTH	(sizeof(Graph)/sizeof(Graph[0]))
#define GDEPTH	(sizeof(GMap)/sizeof(GMap[0]))
#define GMASK	(GWIDTH-1)

uword	GMax[] = { 2*256, 50 };
uword	GIncr[]= { 2*256, 20 };
uword	GMap[2] = { 0, 1 };
uword	Graph[1024][GDEPTH];	/*  5Min,#users.	   */
uword	Gi;

ubyte	Scr[128];
ubyte	Initial;

ubyte Title[128];

extern void updatewindow();

NW Nw = {
    0, 0, 320, 50, -1, -1,
    NEWSIZE|CLOSEWINDOW,
    WINDOWSIZING|WINDOWDRAG|WINDOWDEPTH|WINDOWCLOSE|NOCAREREFRESH,
    NULL, NULL, Title     1       , NULL, NULL,
    32, 18, -1, -1, WBENCHSCREEN
};

WIN *Win;
RP  *Rp;

extern int Enable_Abort;

struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;

void clearwindow ARGS((void));
void updatewindow ARGS((char *));
void main ARGS((int, char **));

int
brk()
{
    return(0);
}

void
main(ac,av)
char *av[];
{
    void *chan = NULL;
    short numsecs = 60;
    long imask, tmask, dmask, mask;
    char notdone = 1;
    char *host = NULL;
    PORT *TimPort = CreatePort(NULL, 0);
     1       a    IOT Iot;

    onbreak(brk);
    sprintf(Title, "LoadAv V%s%s", VERSION, LOADAV_VERSION);
    {
	short i;
	for (i = 1; i < ac; ++i) {
	    if (strncmp(av[i], "-N", 2) == 0) {
		host = av[i]+2;
		continue;
	    }
	    numsecs = atoi(av[i]);
	}
    }


    Iot.tr_node.io_Device = NULL;

    if (OpenDevice("timer.device", UNIT_VBLANK, (IOR *)&Iot, 0))
	goto fail;
    Iot.tr_node.io_Command = TR_ADDREQUEST;
    Iot.tr_node.io_Message.mn_ReplyPort = TimPort;
    Iot.tr_time.tv_micro =      -       2   error = WriteHeader('N', "open error", 0);
	    printf("Unable to open %s for output\n", hdr->Str);
	    if (error)
		return(LostChannel());
	    return(1);
	}
    }
    error = WriteHeader('Y', NULL, pos);    /*  yes, gimme gimme    */

    /*
     *	Retrieve the data
     */

    if (!error) {
	long left = hdr->Val;
	long cnt = pos;
	long total = pos + left;

	while (left) {
	    long n = (left > sizeof(Buf)) ? sizeof(Buf) : left;
	    printf("%6ld/%6ld\23313D", cnt, total);
	       -       _C  fflush(stdout);
	    if (DRead(Chan, Buf, n) != n) {
		error = 5;
		break;
	    }
	    if (CheckBreak()) {
		error = 1;
		break;
	    }
	    if (Write(Fh, Buf, n) != n) {
		puts("Local Write failed!");
		error = 6;
		break;
	    }
	    left -= n;
	    cnt += n;
	    if (CheckBreak()) {
		error = 1;
		break;
	    }
	}
	printf("%6ld/%6ld  %s", cnt, total, ((cnt == total) ? "OK" : "INCOMPLETE"));
    }
    Close(Fh);
    puts("");
    if (error) {
	SetProtection(hdr->Str, 10);    /*       -       Qdisallow reads! */
	return(LostChannel());
    }
    return((int)error);
}

/*
 *  Retrieve a directory.  Create it if necessary.
 */

int
GetDir(hdr, stab)
HDR *hdr;
int stab;
{
    short error = 0;
    long dirlock;
    static HDR Hdr;	    /*	note: static */

    if (CheckBreak())
	return(1);
    printf("%s%-20s(DIR)\n", NSpaces(stab), hdr->Str);
    dirlock = Lock(hdr->Str, SHARED_LOCK);  /*  try to lock directory */
    if (!dirlock) {
	if (dirlock = (long)CreateDir(hdr->Str)) {
     -       6(	    UnLock(dirlock);
	    dirlock = Lock(hdr->Str, SHARED_LOCK);
	}
    }
    if (!dirlock) {
	error = WriteHeader('N', "couldn't create", 0);
	printf("Unable to create local directory: %s\n", hdr->Str);
	if (error)
	    return(LostChannel());
	return(1);
    }
    error = WriteHeader('Y', NULL, 0);  /*  yes, gimme gimme    */
    while (!error) {
	switch(ReadHeader(&Hdr)) {
	case -1:
	    error = 1;
	    break;
	case 'E':                   /*  end of directory    */
	    UnLock(dir     -       hlock);
	    return(0);
	    break;
	case 'F':
	    error = CheckNoPath(Hdr.Str);
	    if (!error) {
		long olddir = (long)CurrentDir(dirlock);
		error = GetFile(&Hdr, stab + 4);
		CurrentDir(olddir);
	    }
	    break;
	case 'D':
	    error = CheckNoPath(Hdr.Str);
	    if (!error) {
		long olddir = (long)CurrentDir(dirlock);
		error = GetDir(&Hdr, stab + 4);
		CurrentDir(olddir);
	    }
	    break;
	case 'S':
	    printf("Access Violation: %s\n", Hdr.Str);
	    break;
	case 'N':
	        -       1h printf("REMOTE ERROR: %s\n", Hdr.Str);
	    error = 10;
	    break;
	default:
	    UnknownCmd(&Hdr);
	    error = 1;
	    break;
	}
    }
    UnLock(dirlock);
    return(LostChannel());
}

int
WriteHeader(c, str, len)
char c;
char *str;
long len;
{
    ubyte sl;

    if (str == NULL)
	str = "";
    sl = strlen(str);

    if (DWrite(Chan, &c, 1) < 0)
	return(1);
    if (DWrite(Chan, &sl,1) < 0)
	return(1);
    if (DWrite(Chan, str, sl) != sl)
	return(1);
    if (DWrite(Chan, &len, 4)     -       MH != 4)
	return(1);
    return(0);
}

int
ReadHeader(hdr)
HDR *hdr;
{
    ubyte sl;
    ubyte cmd;

    hdr->Cmd = -1;
    if (DRead(Chan, &cmd, 1) != 1)
	return(-1);
    if (DRead(Chan, &sl, 1) != 1)
	return(-1);
    if (sl >= sizeof(hdr->Str)) {
	puts("Software error: received file name length too long");
	return(-1);
    }
    if (DRead(Chan, hdr->Str, sl) != sl)
	return(-1);
    hdr->Str[sl] = 0;
    if (DRead(Chan, &hdr->Val, 4) != 4)
	return(-1);
    hdr->Cmd = cmd;
    return((     -         _int)hdr->Cmd);
}

char *
NSpaces(n)
int n;
{
    static char Buf[128];
    static short in = 0;
    static short last;

    if (in == 0) {
	in = 1;
	BSet(Buf, sizeof(Buf)-1, ' ');
    }
    Buf[last] = ' ';
    if (n < 127)
	Buf[n] = 0;
    last = n;
    return(Buf);
}

int
CheckBreak()
{
    if (SetSignal(0,0) & (SIGBREAKF_CTRL_C|SIGBREAKF_CTRL_D)) {
	puts("^C");
	return(1);
    }
    return(0);
}

void
ResetBreak()
{
    SetSignal(0, SIGBREAKF_CTRL_C|SIGBREAKF_CTRL_D);
}

 &len, 4)     /       
    char *dir = NULL;

    printf("PutFiles V%s%s\n", VERSION, PUTFILES_VERSION);
    ac = DoOption(ac, av, "N%sd%s", &host, &dir);

    onbreak(brk);
    if (ac <= 1) {
	puts("putfiles [-Nnetid] [-dremotedir] file/dir file/dir ....");
	exit(1);
    }
    chan = DOpen(host, PORT_FILECOPY, -80, 126);
    if (!chan) {
	puts("Unable to connect");
	exit(1);
    }
    DRead(chan, &fn, 1);
    if (fn == 'S') {
	puts("Remote Server Permission Denied");
	DClose(chan);
	exit(1);
    }
    if      /       r#2(fn != 'Y') {
	puts("Remote Server Software Error");
	DClose(chan);
	exit(1);
    }
    if (dir) {
	if (writehdr(chan, 'C', dir, 0) != 'Y') {
	    printf("Remote directory unavailable: %s\n", dir);
	    goto fail;
	}
    }
    for (i = 1; i < ac; ++i) {
	if (putname(chan, av[i]) < 0)
	    break;
    }
fail:
    printf("\nclosing... ");
    fflush(stdout);
    DClose(chan);
    puts("done");
}

int
putname(chan, file)
void *chan;
char *file;
{
    long lock = Lock(file, SHARED_LOCK);
     /       e?    long dirl;
    int ret = 1;
    FIB *fib = (FIB *)malloc(sizeof(FIB));

    printf("%-20s ", file);
    if (lock == NULL || !Examine(lock, fib)) {
	if (lock)
	    UnLock(lock);
	free(fib);
	puts("NOT FOUND");
	return(1);
    }
    if (fib->fib_DirEntryType > 0) {
	char *dirname = (fib->fib_FileName[0]) ? fib->fib_FileName : "ram";
	puts("DIR");
	dirl = (long)CurrentDir(lock);
	if (writehdr(chan, 'X', dirname, 0) != 'Y') {
	    puts("Remote unable to make directory");
	    goto f1     (         J+ 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;

    /* REMOVED
    if (mycos) {
	Close(proc->pr_COS);
	proc->pr_COS = NULL;
    }
    if (mycis) {
	Close(proc->pr_CIS);
	proc->pr_CIS = NULL;
    }
    */
    DUnListen(port);
}



(buf, "dpipe:%s/Mctns%ld", pname, sig);
	    fh = (long)Open(buf, 1006);
	    if (fh) {
		char     -   	    le exists, try to append to
 *  it.
 */

int
GetFile(hdr, stab)
HDR *hdr;
int stab;
{
    long Fh = NULL;
    long pos = 0;
    short error = 0;

    printf("%s%-20s ", NSpaces(stab), hdr->Str);
    fflush(stdout);
    if (ContMode) {
	SetProtection(hdr->Str, 0);         /*  make sure it's r/w  */
	if (Fh = Open(hdr->Str, 1005)) {    /*  already exists  */
	    long len;

	    Seek(Fh, 0L, 1);
	    len = Seek(Fh, 0L, 0);          /*  get length      */
	    if (len > hdr->Val) {
		Cl     +          }
    }
    fflush(stdout);
    buf[0] = 0;
    ok = DStat(host, (APTR)buf, 2048);
    if (ok)
	write(1, buf, strlen(buf));
    else
	puts("DNET master port for network not found");
}

                                                                                           )                                                                                                            
    
uscli.c                                                                        -   
    }ose(Fh);
		printf("Cont Error, local file is larger than remote!: %s\n", hdr->Str);
		puts("(not downloaded)");
		return(0);
	    }
	    if (len == hdr->Val) {
		Close(Fh);
		if (error = WriteHeader('S', NULL, 0))
		    return(LostChannel());
		puts("HAVE IT, SKIP");
		return(0);
	    }
	    printf("(HAVE %ld/%ld) ", len, hdr->Val);
	    hdr->Val -= len;		/*  that much less  */
	    pos = len;			/*  start at offset */
	}
    }
    if (!Fh) {
	Fh = Open(hdr->Str, 1006);
	if (!Fh) {
	      -       )K		This command assumes the file(s) on both machines have not
 *		been modified since the first attempt.	No other checking
 *		is done at the moment.
 */

#include "defs.h"

void main ARGS((int, char **));

typedef struct {
    char    Cmd;
    char    Str[128];
    long    Val;
} HDR;


extern int Enable_Abort;

char Buf[4096];

short ContMode;
char  *NetId;
long  LocalDirLock;
void *Chan;

void fail ARGS((int));
int CheckNoPath ARGS((char *));
int LostChannel ARGS((void));
void Unkn     -       @ownCmd ARGS((HDR *));
int GetFile ARGS((HDR *, int));
int GetDir ARGS((HDR *, int));
int WriteHeader ARGS((char, char *, long));
int ReadHeader ARGS((HDR *));
char *NSpaces ARGS((int));
int CheckBreak ARGS((void));
void ResetBreak ARGS((void));

int brk()
{
    return(0);
}


void
main(ac,av)
int ac;
char *av[];
{
    HDR Hdr;
    short error;

    onbreak(brk);
#ifndef LATTICE
    Enable_Abort = 0;
#endif
    printf("GetFiles V%s%s\n", VERSION, GETFILES_VERSION);
    ResetBreak();
      -       n   {
	char *ldir = "";
	FIB *fib = malloc(sizeof(FIB));
	ac = DoOption(ac, av, "N%sd%sc", &NetId, &ldir, &ContMode);
	if (ac <= 1) {
	    puts("GETFILES [-Nnetid -dlocaldir -c] remotefile/dir ...");
	    fail(22);
	}
	LocalDirLock = Lock(ldir, SHARED_LOCK);
	if (!LocalDirLock && ldir[0]) {     /*  couldn't find it, try to make it */
	    if (LocalDirLock = (long)CreateDir(ldir)) {
		UnLock(LocalDirLock);
		LocalDirLock = Lock(ldir, SHARED_LOCK);
	    }
	}
	if (!LocalDirLock || !Exami     -       k~ane(LocalDirLock, fib) || fib->fib_DirEntryType < 0) {
	    printf("Unable to CD or create local directory: \"%s\"\n", ldir);
	    fail(21);
	}
    }
    Chan = DOpen(NetId, PORT_GFILECOPY, 126, -80);
    if (!Chan) {
	puts("Unable to connect");
	fail(20);
    }
    error = WriteHeader('H', "Hello, getfiles client V1.30", 0);
    if (error)
	fail(LostChannel());
    switch(ReadHeader(&Hdr)) {
    case -1:
	fail(LostChannel());
    case 'H':
	printf("%s\n", Hdr.Str);
	break;
    }
         -       C{
	short i;

	for (i = 1; i < ac; ++i) {
	    short error;

	    error = WriteHeader('G', av[i], 0);
	    if (error)
		fail(LostChannel());
	    switch(ReadHeader(&Hdr)) {
	    case -1:
		fail(LostChannel());
	    case 'N':
		printf("Remote error on %s: %s\n", av[i], Hdr.Str);
		break;
	    case 'F':
		error = CheckNoPath(Hdr.Str);
		if (!error) {
		    long olddir = (long)CurrentDir(LocalDirLock);
		    error = GetFile(&Hdr, 0);
		    CurrentDir(olddir);
		}
		break;
	    case 'D':
     -       3L		error = CheckNoPath(Hdr.Str);
		if (!error) {
		    long olddir = (long)CurrentDir(LocalDirLock);
		    error = GetDir(&Hdr, 0);
		    CurrentDir(olddir);
		}
		break;
	    case 'S':
		printf("Access Violation: %s\n", Hdr.Str);
		break;
	    default:
		UnknownCmd(&Hdr);
		error = 1;
		break;
	    }
	    if (error)
		fail(error);
	}
	if (!error) {
	    error = WriteHeader('E', "bye", 0);
	    if (error)
		fail(LostChannel());
	}
    }
    fail(0);
}

void
fail(code)
{
    if (Chan)
     -       XR4	DClose(Chan);
    if (LocalDirLock)
	UnLock(LocalDirLock);
    exit(code);
}

int
CheckNoPath(str)
char *str;
{
    while (*str) {
	if (*str == '/' || *str == ':') {
	    puts("SECURITY ALERT: Illegal path spec received");
	    return(40);
	}
	++str;
    }
    return(0);
}

int
LostChannel()
{
    puts("DATA CHANNEL LOST");
    return(10);
}

void
UnknownCmd(hdr)
HDR *hdr;
{
    printf("UnRecognized command code: %02x\n", hdr->Cmd);
}

/*
 *  retrieve a file.  If ContMode set and fi     "       ,O(&iocr);
	    CloseDevice(&iocw);
	    DeletePort(iocw.io_Message.mn_ReplyPort);
	    CloseWindow(win);
	}
	DClose(chan);
	{
	    MSG *msg;
	    msg = AllocMem(sizeof(MSG), MEMF_PUBLIC);
	    Forbid();
	    PutMsg(HdPort, msg);
	}
    } else {
	Forbid();
	Signal(HdPort->mp_SigTask, 1 << HandShakeSig);
    }
    RemTask(NULL);
}

void
HandleIoctl(cmd, val, aux, win, iocw, igns)
short cmd, val;
char aux;
WIN *win;
IOCON *iocw;
short *igns;
{
    static short saverows;
    short height     "       w5, width;
    short dx, dy;

    switch(cmd) {
    case CIO_SETROWS:
	saverows = val;
	break;
    case CIO_SETCOLS:
	width = val * win->RPort->TxWidth + win->BorderLeft + win->BorderRight;
	height= saverows * win->RPort->TxHeight + win->BorderTop + win->BorderBottom;

	dx = win->WScreen->Width - (win->LeftEdge + width);
	if (dx > 0)
	    dx = 0;
	if (-dx > win->LeftEdge) {
	    dx = -win->LeftEdge;
	    width = win->WScreen->Width;
	}

	dy = win->WScreen->Height - (win->TopEdge + heig     "       `~ht);
	if (dy > 0)
	    dy = 0;
	if (-dy > win->TopEdge) {
	    dy = -win->TopEdge;
	    height = win->WScreen->Height;
	}

	if (dx || dy) {
	    MoveWindow(win, dx, dy);
	}
	if (win->Width != width || win->Height != height) {
	    SizeWindow(win, width - win->Width, height - win->Height);
	    ++*igns;
	}
	break;
    }
}

void
setsize(iocw, chan, win)
IOCON *iocw;
void *chan;
WIN *win;
{
    struct ConUnit *cu = (struct ConUnit *)iocw->io_Unit;
    static char Term[64];

    iocw->io     "     N    ._Data = (APTR)"\033c\033[20h\033[t\033[u";
    iocw->io_Length = 13;
    DoIO(iocw);
    if (chan) {
	DIoctl(chan, CIO_SETROWS, (uword)(cu->cu_YMax+1), 0);
	DIoctl(chan, CIO_SETCOLS, (uword)(cu->cu_XMax+1), 0);
    }
    sprintf(Term, "STERM   %ld x %ld", cu->cu_YMax+1, cu->cu_XMax+1);
    SetWindowTitles(win, Term, (char *)-1);
}

	    dx = 0;
	if (-dx > win->LeftEdge) {
	    dx = -win->LeftEdge;
	    width = win->WScreen->Width;
	}

	dy = win->WScreen->Height - (win->TopEdge + heig     (       qPtr;
    proc->pr_WindowPtr = (APTR)-1;

    /* REMOVED
    proc->pr_ConsoleTask = DeviceProc("dpipe:");
    if (!proc->pr_CIS) {
	mycis = 1;
	proc->pr_CIS = Open("nil:", 1006);
    }
    if (!proc->pr_COS) {
	mycos = 1;
	proc->pr_COS = Open("nil:", 1006);
    }
    */
    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];     (       ɱ4k

	    if (GetEnvVal(DNET_LEVEL) < 9) {
		DWrite(chan, "env:DNET_LEVEL must be >= 9\n", 18);
		DClose(chan);
		continue;
	    }

	    sprintf(pname, "%08lx", namei++);
	    sprintf(buf, "newshell <nil: >nil: dpipe:%s/St FROM s:remote-startup", pname);
	    DExec(chan, buf);
	    sig = AllocSignal(-1);
	    fhmask = 1 << sig;
	    smask = 1 << ((struct MsgPort *)chan)->mp_SigBit;
	    sprintf(buf, "dpipe:%s/Mctns%ld", pname, sig);
	    fh = (long)Open(buf, 1006);
	    if (fh) {
		char     $       6/   mask, rmask;

    onbreak(brk);

    if (strncmp(str, "__dnet", 6) != 0) {
	Version("SPrint", VERSION, SPRINT_VERSION);
	_exit(0);
    }

    port = DListen(PORT_PRINTER);
    WaitPort(&myproc->pr_MsgPort);
    ReplyMsg(GetMsg(&myproc->pr_MsgPort));

    mask = SIGBREAKF_CTRL_C|(1 << port->mp_SigBit);
    for (;;) {
	rmask = Wait(mask);
	if (rmask & SIGBREAKF_CTRL_C)
	    break;
	while (chan = DAccept(port)) {
	    if (GetEnvVal(DNET_WRITE) >= 6) {
		DWrite(chan, "Accepted\n", 9);     $         5?
		printfile(chan);
	    } else {
		DWrite(chan, "Permission Denied\n", 18);
	    }
	    DClose(chan);
	}
    }
    DUnListen(port);
}

void
printfile(chan)
void *chan;
{
    long n, fh;
    char rc = 0;
    char buf[256];

    if (fh = Open("PRT:", 1006)) {
	rc = 1;
	while ((n = DRead(chan, buf, 256)) > 0) {
	    if (Write(fh, buf, n) != n) {
		rc = 0;
		break;
	    }
	}
	Close(fh);
    }
    DWrite(chan, &rc, 1);
}

    *myproc = (PROC *)FindTask(NULL);
    void    *chan;
    long      &      P    +.ary	    LIB;
typedef struct FileInfoBlock FIB;
typedef struct Message	    MSG;

                                                                                                                                                                                    #                                                                                                            
    sterm.c                                                                       (       i 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) {
			/* REMOVED
			DWrite(chan, buf, n);
			*/
			Write(fh, buf, n);
		    }
		    if (n == -2) {
			short pv;
			char pa;
			DGetIoctl(chan, &pv, &pa);
		    } else     (       -BqndTask(NULL);
    void    *chan;
    long    mask, rmask;
    long    namei = (long)proc;
    APTR    oldwptr;
    /*short   mycis = 0, mycos = 0;*/

    onbreak(brk);

    if (strncmp(str, "__dnet", 6) != 0) {
	Version("SCli", VERSION, SCLI_VERSION);
	_exit(0);
    }

    port = DListen(PORT_AMIGASHELL);
    WaitPort(&proc->pr_MsgPort);
    ReplyMsg(GetMsg(&proc->pr_MsgPort));
    if (!port)
	_exit(1);
    mask = SIGBREAKF_CTRL_C|(1 << port->mp_SigBit);
    oldwptr = proc->pr_Window            WYn -= n;
    }
done:
    free(fib);
    if (fh)
	Close(fh);
    if (lock)
	UnLock(lock);
    return((int)error);
}

int
WriteHeader(c, str, len)
char c;
char *str;
long len;
{
    ubyte sl;

    if (str == NULL)
	str = "";
    sl = strlen(str);

    if (DWrite(Chan, &c, 1) < 0)
	return(1);
    if (DWrite(Chan, &sl,1) < 0)
	return(1);
    if (DWrite(Chan, str, sl) != sl)
	return(1);
    if (DWrite(Chan, &len, 4) != 4)
	return(1);
    return(0);
}

int
ReadHeader(hdr)
HDR *hdr;
{
    ub          s    !yte sl;
    ubyte cmd;

    hdr->Cmd = -1;
    if (DRead(Chan, &cmd, 1) != 1)
	return(-1);
    if (DRead(Chan, &sl, 1) != 1)
	return(-1);
    if (sl >= sizeof(hdr->Str)) {
	return(-1);
    }
    if (DRead(Chan, hdr->Str, sl) != sl)
	return(-1);
    hdr->Str[sl] = 0;
    if (DRead(Chan, &hdr->Val, 4) != 4)
	return(-1);
    hdr->Cmd = cmd;
    return((int)hdr->Cmd);
}


led! */
	    error = 10;
	    goto done;
	}
	if (DWrite(Chan, Buf, n) != n) {
	    error = 10;
	    goto done;
	}
	le     "   	     CheckIO(&iocr)) {
		    short i;
		    char *ptr;
		    WaitIO(&iocr);
		    ptr = (char *)iocr.io_Data;

		    if (iocr.io_Actual > 0) {
			for (i = 0; i < iocr.io_Actual; ++i) {
			    if (ptr[i] == 13)
				ptr[i] = 10;
			}
			DWrite(chan, ptr, i);
			iocw.io_Data = (APTR)ptr;
			iocw.io_Length = i;
			DoIO(&iocw);
		    }
		    iocr.io_Data = (APTR)conc;
		    iocr.io_Length = sizeof(conc);
		    SendIO(&iocr);
		}
		if (mask & cmask) {
		    long n;
		    char buf[32];
		    wh     "   
    gile (n = DNRead(chan, buf, sizeof(buf))) {
			if (n == -2) {
			    short cmd, val;
			    char aux;
			    cmd = DGetIoctl(chan, &val, &aux);
			    if (cmd >= 0)
				HandleIoctl(cmd, val, aux, win, &iocw, &ignorens);
			    continue;
			}
			if (n < 0) {
			    notdone = 0;
			    break;
			}
			if (buf[0] == 3)        /*  remote ^C -- done   */
			    notdone = 0;
			iocw.io_Data = (APTR)buf;
			iocw.io_Length = n;
			DoIO(&iocw);
		    }
		}
	    }
	    AbortIO(&iocr);
	    WaitI     "       гendShakeSig;

int spawn_handler ARGS((void));
void __saveds term_task ARGS((void));
void HandleIoctl ARGS((short, short, char, WIN *, IOCON *, short*));
void setsize ARGS((IOCON *, void *, WIN *));

int
brk()
{
    return(0);
}

void
#ifdef LATTICE
_main(str)
#else
_main(len,str)
#endif
char *str;
{
    MSG *msg;
    long mask, pmask, hdmask;
    PROC *proc = (PROC *)FindTask(NULL);

    onbreak(brk);

    if (strncmp(str, "__dnet", 6) != 0) {
	Version("STerm", VERSION, STERM_VERSION)     "       ўS;
	_exit(0);
    }

    LisPort= DListen(PORT_IALPHATERM);
    WaitPort(&proc->pr_MsgPort);
    ReplyMsg(GetMsg(&proc->pr_MsgPort));
    if (!LisPort)
	exit(1);
    HdPort = CreatePort(NULL, 0);
    HandShakeSig = AllocSignal(-1);
    pmask = 1 << LisPort->mp_SigBit;
    hdmask= 1 << HdPort->mp_SigBit;

    IntuitionBase   = (struct IntuitionBase *)OpenLibrary("intuition.library", 0);
    GfxBase	    = (struct GfxBase *)OpenLibrary("graphics.library", 0);
    while (mask = Wait(SIGBR     "       yEAKF_CTRL_C|pmask|hdmask)) {
	if (mask & SIGBREAKF_CTRL_C)
	    break;
	if (mask & hdmask) {
	    while (msg = GetMsg(HdPort)) {
		--NHandlers;
		FreeMem(msg, sizeof(*msg));
	    }
	}
	if (mask & pmask) {
	    while (spawn_handler())
		;
	}
    }
    DUnListen(LisPort);
    while (NHandlers) {
	WaitPort(HdPort);
	msg = GetMsg(HdPort);
	FreeMem(msg, sizeof(*msg));
	--NHandlers;
    }
    DeletePort(HdPort);
    CloseLibrary((LIB *)IntuitionBase);
    CloseLibrary((LIB *)GfxBase);
}

/     "       n*
 *  Spawn a handler to accept the new connection, if any.  Task sends
 *  a message to HdPort when through.
 */

int
spawn_handler()
{
    long oldhan = NHandlers;

    CreateTask("Term.channel", 0, (APTR)term_task, 2048);
    Wait(1 << HandShakeSig);
    return (oldhan != NHandlers);
}

static NW Nw = {
    64, 64, 400, 100, -1, -1,
    CLOSEWINDOW|NEWSIZE,
    WINDOWSIZING|WINDOWDRAG|WINDOWDEPTH|WINDOWCLOSE|ACTIVATE|NOCAREREFRESH,
    NULL, NULL, (unsigned char *)"DNET-Term", NUL     "       MsbL, NULL, 32, 32, -1, -1,
    WBENCHSCREEN
};

void __saveds
term_task()
{
    void *chan;
    long imask, cmask, conmask;
    WIN *win;
    char notdone = 1;
    short ignorens = 0;
    char conc[4];
    IOCON iocw;
    IOCON iocr;

#ifndef LATTICE
    geta4();
#endif
    chan = DAccept(LisPort);
    if (chan) {
	DQueue(chan, 32);
	DIoctl(chan, CIO_MODE, 7, 0);
	++NHandlers;
	Signal(HdPort->mp_SigTask, 1 << HandShakeSig);
	if (win = OpenWindow(&Nw)) {
	    iocw.io_Command = CMD_WRITE     "       e;
	    iocw.io_Data = (APTR)win;
	    iocw.io_Message.mn_Node.ln_Type = NT_MESSAGE;
	    iocw.io_Message.mn_ReplyPort = CreatePort(NULL,0);
	    conmask = 1 << iocw.io_Message.mn_ReplyPort->mp_SigBit;
	    OpenDevice("console.device", 0, &iocw, 0);
	    iocr = iocw;
	    iocr.io_Command = CMD_READ;
	    imask = 1 << win->UserPort->mp_SigBit;
	    cmask = 1 << ((PORT *)chan)->mp_SigBit;

	    iocr.io_Data = (APTR)conc;
	    iocr.io_Length = sizeof(conc);
	    SendIO(&iocr);

	    sets     "       >ize(&iocw, NULL, win);
	    while (notdone) {
		long mask;
		mask = Wait(imask|cmask|conmask);

		if (mask & imask) {
		    IMESS *im;
		    while (im = (IMESS *)GetMsg(win->UserPort)) {
			switch(im->Class) {
			case CLOSEWINDOW:
			    notdone = 0;
			    break;
			case NEWSIZE:
			    if (ignorens) {
				--ignorens;
				setsize(&iocw, NULL, win);
			    } else {
				setsize(&iocw, chan, win);
			    }
			    break;
			}
			ReplyMsg((MSG *)im);
		    }
		}
		if ((mask & conmask) &&            ret = -1;
    unsigned char co, nl, rc;

    fib = (FIB *)AllocMem(sizeof(FIB), MEMF_PUBLIC);
    if ((lock = Lock(dirname, SHARED_LOCK)) == NULL) {
	if (lock = CreateDir(dirname)) {
	    UnLock(lock);
	    lock = Lock(dirname, SHARED_LOCK);
	}
    }
    if (lock == NULL || !Examine(lock,fib) || fib->fib_DirEntryType < 0) {
	if (lock)
	    UnLock(lock);
	rc = 'N';
	DWrite(chan, &rc, 1);
	FreeMem(fib, sizeof(FIB));
	return(1);
    }
    rc = 'Y';
    DWrite(chan, &rc, 1);
    oldlock              ki= CurrentDir(lock);
    while (DRead(chan, &co, 1) == 1) {
	if (DRead(chan, &nl, 1) != 1 || DRead(chan, Name, nl) != nl)
	    break;
	if (DRead(chan, &len, 4) != 4)
	    break;
	switch(co) {
	case 'C':
	    {
		char co = 'N';
		long lock = Lock(Name, SHARED_LOCK);    /* CD to dir */
		if (!lock) {
		    if (lock = CreateDir(Name)) {       /* or create */
			UnLock(lock);
			lock = Lock(Name, SHARED_LOCK);
		    }
		}
		if (lock) {
		    co = 'Y';
		    UnLock(CurrentDir(lock));
		}
	            ͙^	DWrite(chan, &co, 1);
	    }
	    break;
	case 'W':
	    if (putfile(chan, Name, len) < 0) {
		ret = -1;
		goto fail;
	    }
	    break;
	case 'X':
	    if (putdir(chan, Name) < 0) {
		ret = -1;
		goto fail;
	    }
	    break;
	case 'Y':
	    ret = 1;
	    co = 'Y';
	    DWrite(chan, &co, 1);
	    goto fail;
	default:
	    co = 'N';
	    DWrite(chan, &co, 1);
	    break;
	}
    }
fail:
    UnLock(CurrentDir(oldlock));
    FreeMem(fib, sizeof(FIB));
    return(ret);
}

int
putfile(ch        	    a@vuan, name, len)
void *chan;
char *name;
int len;
{
    long fh = Open(name, 1006);
    long n, r;
    char rc;

    if (fh == NULL) {
	rc = 'N';
	DWrite(chan, &rc, 1);
	return(0);
    }
    rc = 'Y';
    DWrite(chan, &rc, 1);
    while (len) {
	r = (len > sizeof(Buf)) ? sizeof(Buf) : len;
	n = DRead(chan, Buf, r);
	if (n != r)
	    break;
	if (Write(fh, Buf, n) != n)
	    break;
	len -= n;
    }
    Close(fh);
    if (len) {
	unlink(name);
	return(-1);
    }
    rc = 'Y';
    DWrite(c        
        Nwhan, &rc, 1);
    return(0);
}

   break;
	case 'W':
	    if (putfile(chan, Name, len) < 0) {
		ret = -1;
		goto fail;
	    }
	    break;
	case 'X':
	    if (putdir(chan, Name) < 0) {
		ret = -1;
		goto fail;
	    }
	    break;
	case 'Y':
	    ret = 1;
	    co = 'Y';
	    DWrite(chan, &co, 1);
	    goto fail;
	default:
	    co = 'N';
	    DWrite(chan, &co, 1);
	    break;
	}
    }
fail:
    UnLock(CurrentDir(oldlock));
    FreeMem(fib, sizeof(FIB));
    return(ret);
}

int
putfile(ch            1* done;
    switch(ReadHeader(&Hdr)) {
    case 'Y':
	break;
    case 'S':
	goto done;
    case 'N':
	error = 1;
	break;
    default:
	error = 1;
	break;
    }
    if (error)
	goto done;
    while (ExNext(lock, fib)) {     /*  try to give him the files   */
	if (fib->fib_DirEntryType > 0) {
	    long oldlock = CurrentDir(lock);
	    error = PutDir(fib->fib_FileName, access);
	    CurrentDir(oldlock);
	    if (error)
		break;
	} else {
	    long oldlock = CurrentDir(lock);
	    error =            ݨ; PutFile(fib->fib_FileName, access);
	    CurrentDir(oldlock);
	    if (error)
		break;
	}
    }
    if (!error)
	WriteHeader('E', "Possible Disk Error", 0);
done:
    free(fib);
    if (lock)
	UnLock(lock);
    return((int)error);
}

int
PutFile(name, access)
char *name;
int access;
{
    long lock = Lock(name, SHARED_LOCK);
    long fh = NULL;
    FIB *fib = malloc(sizeof(FIB));
    static HDR Hdr;
    long len;
    short error = 0;
    short ac;

    if (!lock || !Examine(lock, fi            z b)) {
	WriteHeader('N', "Possible Disk Error", 0);
	error = 1;
	goto done;
    }

    ac = ExtractFieldVal(fib->fib_Comment, FS_ACCESS, NULL);
    if (ac >= 0 && ac > access) {
	error = WriteHeader('S', fib->fib_FileName, 0);
	goto done;
    }

    fh = Open(name, 1005);
    if (fh == NULL)         /*  don't do anything if unable to open it */
	goto done;
    Seek(fh, 0L, 1);
    len = Seek(fh, 0L, 0);
    if (error = WriteHeader('F', fib->fib_FileName, len))
	goto done;
    switch(R               G/DNET_LEVEL"
#define DNET_GROUP  "DNET_GROUP"

#define FS_GROUP    "GR="   /*  MUST INCLUDE '=' cause I use strncmp()  */
#define FS_ACCESS   "AC="

                                                                                                                                                                                                                                          
    	spasswd.c                                                                            ˋeadHeader(&Hdr)) {
    case 'Y':
	Seek(fh, Hdr.Val, -1);  /*  start pos.  */
	len -= Hdr.Val;
	if (len < 0)
	    len = 0;
	break;
    case 'S':
	goto done;
    case 'N':
	error = 1;
	break;
    default:
	error = 1;
	break;
    }
    if (error)
	goto done;
    while (len) {
	long n = (len > sizeof(Buf)) ? sizeof(Buf) : len;

	if (Read(fh, Buf, n) != n) {    /*  read failed! */
	    error = 10;
	    goto done;
	}
	if (DWrite(Chan, Buf, n) != n) {
	    error = 10;
	    goto done;
	}
	le           o    GwYMS) -o%(left) %(right)

clean:
    -delete $(OD)#?.o

$(SYMS) : defs.h
    lc $(CFLAGS) -ph -o%(left) syms.c

                                                                                                                                                                           H                                                                                              
    \scopy.c                                                                                 %@;

typedef RtOpen	RtDup;

typedef struct {
    long    DirHandle1;
    long    DirHandle2;
} OpRename;

typedef struct {
    long    Error;
} RtRename;

;

typedef struct {
    long   Handle; 	/*  file handle to read from	    */
    long    Bytes;		/*  # of bytes to read		    */
} OpWrite;

typedef struct {
    long    Bytes;		/*  < 0 == error		    */
} RtWrite;

typedef struct {
    long    Handle;
} OpClose;

typedef struct {
    long    Handle;
    long    Offset;
    long    How;            .[GS((void *, char *, int));

int
brk()
{
    return(0);
}

void
#ifdef LATTICE
_main(str)
#else
_main(len,str)
#endif
char *str;
{
    struct MsgPort *port;
    PROC    *myproc = (PROC *)FindTask(NULL);
    void    *chan;
    long    savedir;
    long    mask, rmask;

    onbreak(brk);

    if (strncmp(str, "__dnet", 6) != 0) {
	Version("SCopy", VERSION, SCOPY_VERSION);
	_exit(0);
    }

    port = DListen(PORT_FILECOPY);
    {
	struct Message *msg;
	char *dir;

	WaitPort(&myproc->pr_            7.MsgPort);
	msg = GetMsg(&myproc->pr_MsgPort);
	dir = (msg->mn_Node.ln_Name) ? msg->mn_Node.ln_Name : "";
	savedir = Lock(dir, SHARED_LOCK);   /* duplicate current dir    */
	ReplyMsg(msg);
    }
    if (!savedir) {
	DUnListen(port);
	_exit(1);
    }
    savedir = CurrentDir(savedir);              /* CD dup, returns original */
    mask = SIGBREAKF_CTRL_C|(1 << port->mp_SigBit);
    for (;;) {
	long dupdir = DupLock(myproc->pr_CurrentDir);
	rmask = Wait(mask);
	if (rmask & SIGBREAKF_C            uTRL_C) {
	    UnLock(CurrentDir(dupdir));
	    break;
	}
	while (chan = DAccept(port)) {
	    if (GetEnvVal(DNET_WRITE) >= 9)
		putdir(chan, "");
	    else
		DWrite(chan, "S", 1);
	    DClose(chan);
	}
	UnLock(CurrentDir(dupdir));
    }
    UnLock(CurrentDir(savedir));                /* restore original         */
    DUnListen(port);
}

static char Name[128];

int
putdir(chan, dirname)
void *chan;
char *dirname;
{
    FIB *fib;
    long lock;
    long oldlock;
    long len;
    int             &7S *str;
{
    struct MsgPort *port;
    PROC    *myproc = (PROC *)FindTask(NULL);
    void    *chan;
    long    mask, rmask;
    short   res;

    onbreak(brk);

    if (strncmp(str, "__dnet", 6) != 0) {
	Version("SPasswd", VERSION, SPASSWD_VERSION);
	_exit(0);
    }

    port = DListen(PORT_PASSWD);
    WaitPort(&myproc->pr_MsgPort);
    ReplyMsg(GetMsg(&myproc->pr_MsgPort));

    mask = SIGBREAKF_CTRL_C|(1 << port->mp_SigBit);
    for (;;) {
	rmask = Wait(mask);
	if (rmask & SIGBRE            ׫w
AKF_CTRL_C)
	    break;
	while (chan = DAccept(port)) {
	    res = do_password(chan);
	    Delay(10L);     /*  prevent name scan   */
	    if (res)
		DPuts(chan, "user-password accepted\n");
	    else
		DPuts(chan, "user-password failed\n");
	    Delay(50L);     /*  prevent name scan   */
	    DClose(chan);
	}
    }
    DUnListen(port);
}

int
do_password(chan)
void *chan;
{
    static char user[64];
    static char pass[64];
    static char buf[128];
    static char suser[64];
    s            -4tatic char spass[64];
    short res;
    long fh;
    short i, n;
    int s_level, s_read, s_write;

    DPuts(chan, "User Name: ");
    res = DGetLine(chan, user, 64);
    if (res < 0)
	return(0);
    DIoctl(chan, CIO_MODE, 0, 0);
    DPuts(chan, "Password : ");
    res = DGetLine(chan, pass, 64);
    DIoctl(chan, CIO_MODE, 7, 0);
    if (res < 0)
	return(0);

    /*
     *	search for USER entry in s:dnet.config
     */

    fh = Open("s:dnet.config", 1005);
    if (fh == NULL) {
	D            WPuts(chan, "s:dnet.config does not exist\n");
	return(0);
    }
    while ((n = Read(fh, buf, 256)) > 0) {
	for (i = 0; i < n - 1; ++i) {
	    if (buf[i] == '\n')
		break;
	}
	buf[i] = 0;
	Seek(fh, (i + 1) - n, 0);
	if (strncmp(buf, "USER", 4) == 0) {
	    suser[0] = spass[0] = 0;
	    s_level = s_read = s_write = 0;
	    sscanf(buf + 4, "%s %s %d %d %d", suser, spass, &s_level, &s_read, &s_write);
	    if (strcmp(user, suser) == 0 && strcmp(pass, spass) == 0) {
		Close(fh);
		sprint            ^	6f(buf, "%d", s_level);
		SetDEnv(DNET_LEVEL, buf);
		sprintf(buf, "%d", s_read);
		SetDEnv(DNET_READ, buf);
		sprintf(buf, "%d", s_write);
		SetDEnv(DNET_WRITE, buf);
		return(1);
	    }
	}
    }
    Close(fh);
    return(0);
}

void
DPuts(chan, str)
void *chan;
char *str;
{
    DWrite(chan, str, strlen(str));
}

int
DGetLine(chan, buf, max)
void *chan;
char *buf;
short max;
{
    short i = 0;
    short n;
    short notdone = 1;
    char c;

    while (notdone) {
	n = DRead(chan, &c,              i, 1);
	if (n == 0) {   /*  ioctl, ignore   */
	    short pv;
	    char pa;
	    DGetIoctl(chan, &pv, &pa);
	    continue;
	}
	if (n < 0) {
	    buf[i] = 0;
	    return(-1);
	}
	switch(c) {
	case 8:     /*	BS  */
	    if (i)
		--i;
	    break;
	case 10:    /*	eol */
	case 13:
	    notdone = 0;
	    break;
	default:
	    if (i < max - 1)
		buf[i++] = c;
	    break;
	}
    }
    buf[i] = 0;
    return(1);
}

f (strcmp(user, suser) == 0 && strcmp(pass, spass) == 0) {
		Close(fh);
		sprint            sse connections.
 *
 *  Receive:
 *	    'V' NLEN NAME FILELEN       -receive compressed file    (V1.1)
 *	    'W' NLEN NAME FILELEN       -receive file
 *	    'X' NLEN NAME   0           -create and CD into directory
 *	    'Y'  0          0           -restore previous directory
 *	    'C' NLEN NAME   0           -set destination directory
 *
 *  length in 68000 longword format.
 */

#include "defs.h"

char Buf[8192];
char Buf2[8192];

int putdir ARGS((void *, char *));
int putfile AR            ϲt Sh f  p !@    "f  NuL ` o p  "g  8H " ,y  LR.'"g  $A* f  "j pN"fNvLDNuL H 0"@Jg  ,"QJg  $ ) 
gg  $@&H
fJ*f 	L Nup L Nu   o  PJg   Nup NuH 0&H$KJg$p A =0  g
r  t `r  R` LNu      paNU"Or
NA 0Jf 	fBN]Nu  NU"O" A A 0f 	fBN]Nu  /	"Hr p / +g -fRH  0m  	n$҂ҁҀ` -fD$ S _ Nu/. R  l)H.NuNU  H 0&o $o B)KHm A"JN lB ,            /}6L N]Nu  Jj  DJj  Da   DNua  DDNuJj  Da  DNu/HA4f  "H@HAHB4 g  0H@4 0HB2$Nu/vA d  QCA d  YCA  d  UCJAk  SC4 HBBBHC6 04HAd  SCЁdr 2HCH@A&$Nu0123456789abcdefQO"O2 A f 	"ᲉfBPONuNUH'0&H$I~ | z p |  r +At+BA@@+A+A+HJg,p @  gW@gQ@gU@f~`|`
z`| R`r0fRAp*f RX+PR` KCNr.f Rp*f RX+PR` KCNrlf
| R`rhfRr  @            8 A Xg nA g SAg$A g SAg @WAg UAg  WAg B` J-g RX ` RX +@l
rD+AJgp-`
Jgp+`p @p "-肀p gRR - mN+@ -Jjr+A -"-H o* m"HN&p -"- m`Sd -+@ѭA+HJg $|  ` J-g RX ` RX +@` pJ-g RX ` RX +@J-g m 0r+A+H mN+@` @| 0 -Jjp+@J-g RX ` RX +@J-g m 0 xr+A+H mNH+@pX-f AN2`  RX"P+IfA +H mJf              
S+H -Jk$o +@`p+@ RX @B-`p `z -"-lt +B`Jg.Smp  m+H m N`Sm<p - m N`Smp - m N`Smp  m+H m N` LN]Nu  NUH0&H$I+m Jg.p% f fR`/ JCa JXO+@g$@`p N`LN]NuJoe SfNuSfNu        	  ^    b  @              o  XB !H Nu       _NewList          f RX+PR` KCNr.f Rp*f RX+PR` KCNrlf
| R`rhfRr  @             UUUUG          *UUUUG          UUUUG          UUUUG                       @                                                                                                                                                                                                                                                                                                                                 #                                                                                                                     :c/MuchMore   7UUUU~  7  7UUUU~  7  7  7_  7  0           *UUUUU                                                 UUUG              UUUUG          *UUUUG          UUUUG          UUUUG                      G@ to read from	    */
    long    Bytes;		/*  # of bytes to read		    */
} OpRead;

typedef struct {
    long    Bytes;		/*  < 0 == error		    */
} RtRead;

typedef struct {
    long   Handle; 	/*  file handle to read from	    */
    long    Bytes;		/*  # of bytes to read		    */
} OpWrite;

typedef struct {
    long    Bytes;		/*  < 0 == error		    */
} RtWrite;

typedef struct {
    long    Handle;
} OpClose;

typedef struct {
    long    Handle;
    long    Offset;
    long    How;            n
} OpSeek;

typedef struct {
    long    OldOffset;
    long    NewOffset;	    /*	-1 = error  */
} RtSeek;

typedef struct {
    long    Handle;
} OpParent;

typedef RtOpen RtParent;

typedef struct {
    long    DirHandle;
} OpDelete;

typedef struct {
    long    Error;
} RtDelete;

typedef OpDelete OpCreateDir;
typedef RtParent RtCreateDir;

typedef struct {
    long    Handle;
    long    Index;
} OpNextDir;

typedef RtOpen RtNextDir;

typedef struct {
    long    Handle;
} OpDup            `                                         ?      <?                  9      |<?                  Ϗ      3      ?χ      3      ?      ??                                                                                                                                                             }                                                                                                                                                                                                                                                                                                                                                         b                      *UUUUU  7  7  7  7ꪪꪪ  7  7  7  7            UUU~  7  7UUUU~  7  7UUUU~  7  7UUUU~  7  7UUU~  7  7UUUU~  7  7UUUU~  7  7  7_  7  0           *UUUUU                                                 UUUG              UUUUG          *UUUUG          UUUUG          UUUUG                  	    `Rp4"<  ,x N: @!|C !R "* 1A !j  !j   "mJfS"	R+@ rN: m!@ 0C $M """ m,m"n 0fAT"m,x N -LL N]NuNU/&m J g.+k "m Q"H,x N"m Q"HpN./-a  fXO"K,x NB  k 0JfS 0 R"k 0N."Kp4N.&_N]NuNU/.- X "<  ,x N: @ C  	.N]Nu/&o Y"K ,x N.&_Nu/&o A@"l f
C@)I `)H  &@A p / /, /N8O p  l B0   &_NuNU/&m +KJg
p:gR`Jf&m`R &_N]NuNUH0&m .- $m ,-          
    ! @Jpg  Hx Hm /,pN O Jk  Hx Hm/,pN O JknHx Hm /,pN O JkVp -/ //,pN O Jk<J g/- /
/,pN fO Jk J g//- /,pN DO fp `Jpg/,pN XOBppLN]NuN    N    N    N    N    N   .N  N                                          	   
      
                         NUH00&m +K m"H $h fC *$h &gp ( r$v   ,x NLN]Nu         DNUH 0&m $m p@"<  ,x             mN: @|  2, +@JAkA `pN m@ N m!@ C /	N  m &.N XO +  m1@ 4'H , 
g&/
Hl ,Hl &HmN vO C,x Nz'@  m!k  " L N]NuNU/&m +Kp  m( 2, Hgr   ,x N"mp@,x N.&_N]Nu  N    N          
                     %NUH0&m $m +K~  m ( < 8od,x N mN+@r @( f4JGf( HgJ $g"h ( ( $N."mp0N. mS <`"m & I"@N
` LN]Nu         ,NU/&m  K;| "p 0( 4+@+H+H+H            :} m h "C,x N mR <B 8Hm/N TPO m &,x N+@Jf mN+@Jg m|  "H,x N`/-N &mN]Nu  N    N                                  UNU/&m +K mJ 8g ( < 8op`p &_N]NuNUH0&m $m .- ,+K+J mJ 8g  B/N POJ@kvp0"<  ,x N: @1| $ r "m2) 4!A !I ,!I +@ rN: m!@ (!G $//( (/-N O  m h ""m,x N mR <`L|`H;| $p 0( 4+@+H+H+m+G m h "C,x NHmN  XOJ-g|/-N  L            uN]NuN  0N    N    N              D        P      
  >  J            NUH0&m $m .- +K+J| z mJ( 6gp`@Jg:Jf m,x N//-/-N *O * Jk܅ۭ mJ( 6g LN]Nu  N    pa           z           NUH70&m $m .- +K+J|  mJ( 6gp` Jg  m &,x N+@Jf mN+@Jg p m( f4"mJ <gS <J $g"h ( ( $,x N."mp0,x N.` m0( @ "gS@gS@gpU@g`  m|  6"m,x N` Zp@ m( f"m & I            "m,x N` m &"m,x N
 m| @ Jf  |`   m (  "( $*n."h (//-/	N O ܅ۭ"m,x N` "h (//-/	N O ܇ mߨ  ~ p@( f"m & I"m,x N` m &"m,x N
 m| @ ` f m|  "H,x N` N/-N 4XO mJ( 6gp ( r$v   ,x N LN]NuN    N                    
  $           7NUH'&m >- ,- *-  fG 8/HmN PO+@r~o*tl*o,l, @J "gZ;|  r 2+A+@+@"A+E h "C,x             o	NHmN :XO-J f - m1@ 4/N * -`
/-N "p LN]Nu  N  0N    N    N                                
             ,dos.library Root    @  DNET.UNIT.  %s%s  DNET.UNIT.  0             (((((                  H          (((((                  H                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     w1fk                                                                                                                                                                                                                                                                                                                                                                                                	             L   / g c  2  f  h2	  f  ^  e  ,"  ,i  "H?>p,`  L|            1澄H?>QHA0L|2 `  # # Q   d0   f  Nu Q   dNu2  f  h2	  f  ^  e  ,"  ,i  "H?>p,`  L|H|QHA0L|2 `  ""Q   d0   f  NuQ   dNur `/  o  /    (c  `  
QNuH?>$  g  S   $BB4HB&(*,."B$B&B(B*B,Br0k  
H?~jA2< Ak  !AjA`  QL|Nu  L  H 2,y  L "|  |   |  /n E G $&    %J #O $IN/
a  6X "LL Nu o p (  g   Nu o p  h Jg   Nu o H 2            :$H&h ,y  L*  f  + p N`N"JNN 
LL NuL  H 8$@&A   (Ot pf  Jg   *f  PB f  p`  0@)  ) RBR`SBk  0@ t JgJBk  |0@$t  RR &t R` ?f  Jf  DJBf`  P  Ae    Zb       Ae   Zb      g  
JBf`  Jf  SJf  S` :p    LNu"y  L"i   g   g  H p a  @L !I Rh NuL `   o p  f  pNupNuL `   o p  f  NuH ",y  LR.' g  2? /.// pN0/  o  fg   P`  NvLD Nu o            vHj \N)@( l(J $POg l("h $/NXO/,(/
N)l(,PON l N
 l!@ gHxHz *N l!@ PO/,,?,0NBgN PO$_N]Nu* NU  H0$m  m J g m  ( (  D ( &@`&lHHЭ T9@2B0,2H/ N)@4POfL0N]NuH: ? KR//,4N~0H @4CDf?- /
/,4N: l4B0P 9| 00HЬ4&@R$KO H: |  g| 	g| g| g| 
fR`  mz "f.R KRH: g JR| "f "fR`B*```8 KRH: g&|  g | 	g| g| g| 
g JR` JRBJEfSRl0` ZBB0,            =|0R@H/ N)@,POfBl0` z &l4`$0H l,!  K JfS0R@HREl0m0H l,B `   0<`0/  o JfSH"o S@WgB / NuL   2/ `WgRA`BQNuNU  J8g l8N?- N TON]NuNU/0- H+@Jg(x `
?N TORDlm0, / /,NPOJ<g l<NJg
/,NLXOJ@g l@ DJHg
/,HNhXOJLg
/,LNXXOJPg
/,PNHXOJTg
/,TN8XO,x . )g/K 
N*_`B_NsJ(f0J4g(0,2H/ /,4N,0,0R@H/ /,,NO `N/,(N"XO -.lNu(N]          d    dpNuNU  H 8- 0 $@JDm
llJf9| XpLpN]Nu*  f/N 
XOBp `"/ ,lN"/ ,lN,lNL  ,lNN ,lNN "/ ,lNN L  ,lNHL  ,lNL Nu"o ,lNbL  ,lN:N "o ,lN,lN|"o  / ,lN. o ,lN"o ,lN o ,lN                                           mz "f.R KRH: g JR| "f "fR`B*```8 KRH: g&|  g | 	g| g| g| 
g JR` JRBJEfSRl0` ZBB0,              F"m#h  /,/-N0PO`dSfB m/( Hx/,/-N0O `<Hx B/,/-NO `$   Rg |[g  g &Sg  Sg``  mB N]NuVer 0.0 (c) Gunnar Nordmark 1988  apCEf2< kt "Q)O,x )NH瀀. )gK N`B_NsC  Nh)@f.< N`NPONudos.library I  NuN "o ,lNN  o ,lNL  ,lNN  o ,lN                                                                                                                   X /a  @+h r .t ///Hx HmHx C+@a r.a 2O ` <>< ` 4>< ` ,"m i /a .a "m i  .+@a .a  mJfS" @JfS$;AH;BH҂T+@ r,x N:"m i .+@a  @+h "m i .a  @+h  m"mf m"HE "mf0-H2-HЁTHx Hm/ /-Hx HmHx ra jO  2-H4-H҂T;@ "m,x N.Jmg>< `Jg
>< `>< Jg JGg mB  H!@ /-a  XO` r2,lPN:,x N|a  JfHlTNXOJg,x Nv` F lDB "lP i "            a#q (  @C "( +@+A+IJg mHg+H m +@` mHf"m"/a XOJpg
/,pN8XOBp"lP,x NbLN]NuNUH 0&m  k "S$l@ \'J #K 
"#J +H+I,x NL N]Nu/
 l@ t$l@"j pVD HH$_NuNUH&m  +@Jg("@ i +HC f `/*H~,x N*_At LN]NuNU/&m  k +H f^Hx a XO+@p"<  ,x N:+@"@A`N m"m#H  !K p!@ "l@ \!I  ,D!@ 'H  &_N]NuNUH 2&m $m  KJfS "KS+I mep/gS            	^OO )@pf| ` 
 m ( [g  Wg Sg 
]g 	RSg Sg 	Sg 
Sg Sg 
Sg 	tSg DSg Sg 8Sg lSg VSg 
Sg 	RSg Ug 
xr3g >[g   g 
\r
gSgSgSg Sg p` 
>| ` 
<"m i /a .a "m i .+@a h @+h  m ( ;@ mJfS RHx Hm/ /-Hx HmHx Oa O  * JEg>< ` 	 -rf>< ` 	"-Jo,+@p / r // /Hx HmHx Ca O >< ` 	z mJf"m i /a 
XO"@ i 0+HHm/a lPO m"(  A!@ $+@` 	4 m+h  m+h  m            
'X+h Hx HmBBHx HmHx Ra  O ;@gp+@ -Jon"m i / //,pNO  m!m `  m+h  m+h  m ( +@ h Hx Hm"m/) /Hx HmHx Wa O ;@gp+@ m!m ` R"m i +H g
C g |4UUH*H~ ,x NL `.+h p / r // /Hx HmHx Ca  .a 
O HlTNXOJf | `  m+h  m+h  m+h  ( R+@Hx HmBBHx HmHx Sa O ;@gp+@ -Jj>< ` t m!m ` f"m i /a XO m"( +@+A @4( JBj>< `             
|2+h  A+PHx HmBBHx HmHx Na 0O ;@fpf>< ` Hx Hm/,pNO Sgp @r  A p -/ Hl/,pNO r -gp @r  A  mR!m !m tB x -!@ | -!@ C$IJfS 
rje|  | ? 	B( 
`$C 	EfA"HJfS 	 m@ p @ @ C A"""`  "m i /a DXO m"( t  A "@6) H!C !i  t!B x$)  !B |$)  !B $i 0JfS 0+@H $
vje|  | ? 	B( 
`(E 	&i 0f"m i 0JfS 0 $m@ p  m@ @ E            *J A $$$$` < m ( ~+@JGg
 m+H` m ( +@ @~ Hx $/N
6pR m!@  ,lR!@ !@ !|    !|DOS   ,D!@ Hl`N	O  m!@  ` "m i /a  @+h Hx HmBBHx HmHx P+@a O  ;@gp +@pf>< ` ^Hx Hm/,pN	pO Sgp @r  A p -/ Hl/,pN	BO r -Űgp @r  A HmHla .+@a PO m!@ ` "m i /a t.a "m i .+@a  @+h  mJfS Rr.Hm/ /-/HmHx Da O ;@fJg n>< ` f"m            C_ i /a .a H"m i .+@a  @+h  mJfS RHx Hm/ /-Hx HmHx Ma .O  ;@gp +@pf>< ` Hm/-a .+@a rPO m!@ ` "m i /a \.a "m i .+@a  @+h ;|"mJfS"	RHx Hm//-Hx HmHx O+@a O  ;@g>< ` Jpf>< ` : mJf$m"j 0+IHm/-a 8.+@a PO m!@ ` "m i /a F @+h Hx HmBBHx HmHx d+@a O  ;@g>< ` pf>< ` Hm m/( 0a .+@a 0PO m!@ ` "m i            "ˆ on the DNETDIR enviroment variable.  Do
    not forget this.

    Copy the UNIX dnet.servers file into ~/.DNET (or whatever directory
    you had defined from DNETDIR.


			******** RUN *******

    Sequence of events (basic options, see dnet.doc for other options).
    2400 baud is assumed in the below example, simply change where it
    applies if running at a different baud rate.

	(1) on amiga

	    (i) The connection to your system is 7 bits and parity is
		ignored.

		    1> r            ;E]un dnet -b2400 -P0 -Z0

	    (ii) The connection to your system is 7 bits even parity and
		parity is enforced.

		    1> run DNET -b2400 -P0 -Z2

	    (iii) The connection to your system is 8 bits and supports raw
		8 bit transfers (no parity).

		    1> run DNET -b2400 -P0 -Z0 -m0

	    Other combinations may apply, see doc/dnet.doc for details. The
	    -P option selects the protocol and -Z selects parity.

	(2) From small DNet window now open on the amiga.

	    Use the AT comman            `d set or otherwise instruct your modem to
	    dial your system.  For hard connections where no modem exists
	    this is not necessary, though with some hard connections you
	    will need to use the SEND-BREAK menu option to send a line
	    break to get a system prompt.

	    Log into your UNIX account

	(3) From the UNIX prompt:   (be sure the DNETDIR enviroment variable
	    is set appropriately and your path contains the dnet executable
	    and clients.

	    (i) The connectio            E@n to your system is 7 bits and parity is ignored,

		    % dnet

	    (ii) The connection to your system is 7 bits even parity and parity
		is enforced

		    % stty -odd
		    % dnet

	    (iii) The connection to your system is 8 bits

		    % dnet -m0

	(4) At this point the small dnet window should disappear.  After a
	    few seconds an FTERM window should open and after another small
	    delay give you a shell prompt.

	    Congratulations, you are running DNet.

	    Now you m        	    {ay do all sorts of things.  You may run other FTERM
	    windows from your amiga (1> run fterm) and therefore have
	    several shell windows... you can run file transfer clients
	    (putfiles and getfiles) on either the amiga or unix sides, etc...
	    read the documentation in the doc directory for more info.


				SHUTTING DOWN

	Logging out of an FTERM window does not kill DNet.  To kill DNet
	use the 'quitdnet' command on the Amiga side.  This should kill all
	connections and b        
      $<+ring back the original small dnet window with the
	original shell prompt from which you should be able to log out
	normally.  If you are unable to get the original shell prompt in
	the small dnet window you may have to restart the protocol (menu
	option) and try 'quitdnet' again.  If all else fails simply hanging
	up the modem should work (in which case you BREAK the dnet process
	on the Amiga side).




you a shell prompt.

	    Congratulations, you are running DNet.

	    Now you m            `                                         ?      <?                  9      |<?                  Ϗ      3      ?χ      3      ?      ??                                                                                                                                                             7z                                                                                                                                                                                                                                                                                                                                                         b   `                   *UUUUU  7  7  7  7ꪪꪪ  7  7  7  7            UUU~  7  7UUUU~  7  7UUUU~  7  7UUUU~  7  7UUU~  7  7UUUU~  7  7UUUU~  7  7  7_  7  0           *UUUUU                                                 UUUG              UUUUG          *UUUUG          UUUUG          UUUUG                       UUUUG          *UUUUG          UUUUG          UUUUG                       @                                                                                                                                                                                                                                                                                                                                 #                                                                                                                     :c/MuchMore   7UUUU~  7  7UUUU~  7  7  7_  7  0           *UUUUU                                                 UUUG              UUUUG          *UUUUG          UUUUG          UUUUG                  
    Gtes	SCopy	    send files to remote computer
    8195    FTerm	STerm	    open a talk window on both computers
    8196    CLITerm	SCli	    remote-CLI (actually newshell)
    8197    LoadAv	------	    Load-Average window (when running DNet
				    to a UNIX machine)
    8198    ------	SPrint	    printer server
    8199    ------	SPasswd     password server.  Used to gain security
				    access for auto-answer callups
    8201    GetFiles	SGCopy	    download files from remote computer

            y,	    NOTE: FTERM may be used to connect to arbitrary ports that otherwise have
    no associated client.  see the docs for FTERM.

		READ THE DOCS FOR EACH OF THESE CLIENTS

			       SECURITY

    Read DOC/DNET.DOC and documentation for each client/server.  DNet
    implements various levels of security.  This is intended for BBS
    support but I have not finished my DNet-BBS program yet.  The security
    is still there, however.

    One example:    If the DNET_READ security optio          b    =Eln (env: var is set
    automatically from S:DNET.CONFIG depending on the option you give
    DNET when you first run it) is anything less than 9, the SGCopy
    server for GetFiles will only allow uploading from directories with
    their comment field set a certain way.  That is, you can control
    exactly what you allow other people to download.



r.  Used to gain security
				    access for auto-answer callups
    8201    GetFiles	SGCopy	    download files from remote computer

            UUU~  7  7UUUU~  7  7UUUU~  7  7UUUU~  7  7UUU~  7  7UUUU~  7  7UUUU~  7  7  7_  7  0           *UUUUU                                                 UUUG              UUUUG          *UUUUG          UUUUG          UUUUG                       UUUUG          *UUUUG          UUUUG          UUUUG                       @                                                                                                                                                                                                                                                                                                                                 #                                                                                                                     :c/MuchMore   7UUUU~  7  7UUUU~  7  7  7_  7  0           *UUUUU                                                 UUUG              UUUUG          *UUUUG          UUUUG          UUUUG                      x)Fr
    executables are in DNET:AMIGA/BIN then you must modify S:DNET.SERVERS
    to point to the appropriate server executables.

    Make sure your path includes DNET:AMIGA/BIN or wherever you have placed
    the client executables.  This is required so DNET knows how to find
    the FTERM executable when starting up the automatic FTERM.


			--- UNIX INSTALL ---

    You must set the enviroment variable DNETDIR in your .cshrc to an
    initially empty directory (i.e. create an unobs             Bgtrusive directory).  This
    directory will hold the UNIX domain sockets DNet uses to communicate.
    Security on the UNIX side is solely determined by who has access to this
    directory.	For example:

    Extract the distribution.

    % cd dnet
    % MAKE		(you may have to chmod this +x, this is a shell script)

	This compiles the code.  Binaries should exist in dnet/unix/bin.  If
	you have problems not easily fixed please email me.  Note that the
	source only compiles on syste            V7hms compatible with BSD 4.3 .  The code
	should compile on Suns running 3.5 but does not appear to run on
	suns running 4.0 (??).  The code compiles and runs on Dynix system
	3.0.12 or higher.  The code has been found to compile pretty well
	on Sys V *with* berkeley socket extensions.

    % cd ~
    % mkdir .DNET
    % vi .cshrc 	(and add the following line)
	setenv DNETDIR ~/.DNET/
    % source .cshrc	(make sure the change is made part of your shell)

    NOTE the trailing slash (/)            "`                                         ?      <?                  9      |<?                  Ϗ      3      ?χ      3      ?      ??                                                                                                                                                             x                                                                                                                                                                                                                                                                                                                                                         b                      *UUUUU  7  7  7  7ꪪꪪ  7  7  7  7            $Wid DPri	ARGS((void *, int));
extern PORT *DOpen	ARGS((char *, uword, int, int));
extern int  DCheckEof	ARGS((void *));
extern short DGetIoctl	ARGS((void *, short *, char *));
extern long DNRead  ARGS((void *, void *, long));
extern long DRead   ARGS((void *, void *, long));
extern void DQueue  ARGS((void *, long));
extern long DWrite  ARGS((void *, void *, long));
extern void DEof    ARGS((void *));
extern void DIoctl  ARGS((void *, ubyte, uword, ubyte));
extern int  DStat   ARGS((ch            %ǄZar *, APTR, long));
extern int  DQuit   ARGS((char *));
extern void DClose  ARGS((void *));
extern int  DExec   ARGS((void *, char *));
extern short WaitQueue	ARGS((void *, IOSTD *));

extern void *MakeChannel    ARGS((IOSTD *, char *));
extern void DeleteChannel   ARGS((void *));
extern void FixSignal	    ARGS((void *));
extern int  GetEnvVal	    ARGS((char *));
extern int  OpenCfgFile     ARGS((void));
extern char *GetCfgLine     ARGS((char *));
extern void CloseCfgFile    ARGS((vo               XSid));
extern void GetOneCfg	    ARGS((char *));
extern int  ExtractFieldVal ARGS((char *, char *, short *));

extern void _elog   ARGS((int, char *, int, char *, void *));

;
extern long DNRead  ARGS((void *, void *, long));
extern long DRead   ARGS((void *, void *, long));
extern void DQueue  ARGS((void *, long));
extern long DWrite  ARGS((void *, void *, long));
extern void DEof    ARGS((void *));
extern void DIoctl  ARGS((void *, ubyte, uword, ubyte));
extern int  DStat   ARGS((ch            '5ecting, executing the START DNET menu option from either
	end will start the protocol.  The small dnet window should go away
	and DNET should attempt to run the FTERM client program, which
	connects to an STERM server program on the other end.  Your friend's
	amiga will do the same.

	If all goes ok, it should flash the window size in the title bar
	and you can type.  If not, the window will go away and an error
	message will be printed out in your CLI: "unable to connect".

	WARNING            (g:    Even if there are no windows open (no clients active),
	DNet is still running!!!!  us the CLI BREAK command to kill DNet
	and give you back the initial DNet window, from which you can
	hit the close-window gadget.

	breaking the DNet protocol will kill any active clients.


			    SERVERS AND CLIENTS


	DNet has a notion of servers and clients.  That is, you run the
protocol as described above, then run other external programs that talk
to the core program "DNet".  These other e            )Hxternal programs "FTerm",
"GetFiles", "PutFiles", etc... obtain virtual connections to special
server programs on the remote machine.

	Thus, when you started the protocol above DNet automatically
ran the FTERM client... you can run as many FTERMs as you have memory
for (well, actually, DNet is limited to 64 simultanious channels).  When
a client program such as FTERM is run on computer A, it causes the
appropriate server program (STERM in this case) to automatically be run
on comput        	    .^er B.	The client and server need some way to rendezvous, and they
do this by giving the same PORT NUMBER to the protocol driver.

	This is what the S:DNET.SERVERS file is ... when you run a client
on computer A it asks for server #<blah> (e.g. 8195 for an FTERM) on the
remote machine.  computer B (the remote machine) looks up 8195 in the
S:DNET.SERVERS file, finds the path to the server in question, and runs it
automatically.

    PORT    CLIENT	SERVER	    PURPOSE

    8192    PutFil            +*as together and run multiple connections between them.  For example,
you can open a talk window or two or three and be doing an upload and be
doing a download all at the same time.

	Currently, DNet can be used to connect two Amiga's together or
an Amiga to a 4.2BSD/4.3BSD compatible UNIX.

	** AN 8 BIT PATH IS NO LONGER REQUIRED.  DNET WILL NOW RUN OVER
    7 BIT PATHS.  (TAB,FF,CR,LF, 0x20-0x7F).


		      INSTALLING DNET ON YOUR AMIGA

	(1) ## REMOVED, was copy dres.library to lib            ,7Rs:.  no longer required.

	(2) copy the DNet binary and all client and server program to
	    somewhere accessable on your path.

	(3) copy s/dnet.servers to s:

	    * modify s:dnet.servers so all server paths point to whereever
	      you stuck the servers

	(4) copy s/dnet.config  to s:

	    * you may have to modify s:dnet.config too ... look into the
	      DOC directory for more information.

		      CALL A FRIEND WHO HAS GOT DNET INSTALLED

	1> RUN DNET -X -8 -b1200

	NOTE:  -            -ހMh0 option in previous versions is now the default.  Use -h1
	       to *enable* carrier detect checking.

	       7 bit mode is now the default.  Use -m0 if you have an 8 bit
	       connection and want to take advantage of it.

	PARITY NOTE:  If your system forces parity you specify the
			appropriate parity option with the -Z switch,
			refer to dnet.doc

	warning: The defaults for -X (manual mode) in S:DNET.CONFIG
	turn off security.  Please read documentation in the doc directory            &
	for more information.  This README file is only intended to get
	you up and running.  The above line also sets the baud to 1200...
	the idea is you set it to what is proper for your modem.  Again,
	read DOC/DNET.DOC for more options and information.

	A small DNET window should appear from which you can dialup your
	friend's amiga.  On CONNECT, DNET should automatically adjust the
	baud rate.  It may be necessary to modify S:DNET.CONFIG in this
	regard (read the docs!)

	After conn            /&	buf += n;
		ReplyMsg((MSG *)ior);
	    } else {
		BMov((char *)ior->io_Data + ior->io_Actual, buf, bytes);
		len += bytes;
		ior->io_Actual += bytes;
		bytes = 0;
		if (ior->io_Message.mn_Node.ln_Type == NT_REQUEUE)
		    AddHead(&chan->rdylist, (NODE *)ior);
		else
		    AddTail(&chan->rdylist, (NODE *)ior);
		ior->io_Message.mn_Node.ln_Type = NT_REQUEUE;
	    }
	    break;
	default:
	    ior->io_Error = 1;
	    ReplyMsg((MSG *)ior);
	}
    }
#ifdef DEBUG
    puts("DONE1");
#endif
               done:
    FixSignal(chan);
    if (chan->eof)
	SetSignal(1 << chan->port.mp_SigBit, 1 << chan->port.mp_SigBit);
#ifdef DEBUG
    printf("RETURN %ld\n", len);
#endif
    return(len);
}

MD_WRITE:
#ifdef DEBUG
	    printf("IOR LEN/ACT %ld/%ld\n", ior->io_Length, ior->io_Actual);
#endif
	    n = ior->io_Length - ior->io_Actual;
#ifdef DEBUG
	    if (n < 0)
		puts("len fail");
#endif
	    if (n <= bytes) {
		BMov((char *)ior->io_Data + ior->io_Actual, buf, n);
		bytes -= n;
		len += n;
	               ove((NODE *)ior);
	    ReplyMsg((MSG *)ior);
	    Permit();
	}
    }
    FixSignal(chan);
    if (chan->eof)
	SetSignal(1 << chan->port.mp_SigBit, 1 << chan->port.mp_SigBit);
    return(cmd);
}
                                                                                    7  5                                                                                                              
    makechannel.c                                                                        2	    return(NULL);
}

void
CloseCfgFile()
{
    if (Fi)
	fclose(Fi);
    Fi = NULL;
}

void
GetOneCfg(what)
char *what;
{
    char *str;
    OpenCfgFile();
    str = GetCfgLine(what);
    CloseCfgFile();
}

int
ExtractFieldVal(str, field, pidx)
char *str, *field;
short *pidx;
{
    short idx = (pidx) ? *pidx : 0;
    short flen = strlen(field);

    while (*str) {
	if (strncmp(str, field, flen) == 0) {
	    if (pidx)
		*pidx = idx + flen;	/*  past the field but not the val */
	    ret           C    *-urn(atoi(str + flen));
	}
	++str;
	++idx;
    }
    return(-1);
}

ib.h"

static FILE *Fi;

int
OpenCfgFile()
{
    CloseCfgFile();
    Fi = fopen("s:dnet.config", "r");
    return (Fi != NULL);
}

char *
GetCfgLine(what)
char *what;
{
    static char Buf[128];
    register char *ptr;
    if (Fi) {
	while (fgets(Buf, sizeof(Buf), Fi)) {
	    if (BCmp(Buf, what, 4) == 0) {
		Buf[strlen(Buf)-1] = 0;
		for (ptr = Buf + 4; *ptr == ' ' || *ptr == 9; ++ptr);
		return(ptr);
	    }
	}
    }
           Y    '>dnetport, (MSG *)&ior);
    WaitMsg(&ior);
    DeletePort(replyport);
    return(1);
}

                                                                                                                                                                                                                   b                                                                                              
    Adeof.c                                                                               #o write queue size    */
    int     queued;	    /*	current # packets queued    */
};

#define EFATAL	0
#define EWARN	1
#define EDEBUG	2

#define NT_REQUEUE  0x40

#define elog(how, ctl, data)    _elog(__LINE__,__FILE__,how,ctl,data)

extern char *Program;

/*
 *  Routines
 */

extern void Version	ARGS((char *, char *, char *));
extern PORT *DListen	ARGS((uword));
extern void DUnListen	ARGS((PORT *));
extern PORT *DAccept	ARGS((PORT *));
extern int  DNAAccept	ARGS((PORT *));
extern vo            7uh&chan->rdylist);
    chan->chan = (long)ior->io_Unit;
    ior->io_Offset = (long)chan;
    if (host) {
	char buf[sizeof(DNETPORTNAME)+32];
	sprintf(buf, "%s%s", DNETPORTNAME, host);
	ior->io_Message.mn_ReplyPort = FindPort(buf);
    }
    chan->dnetport = ior->io_Message.mn_ReplyPort;
    return((void *)chan);
}

void
DeleteChannel(_chan)
void *_chan;
{
    CHANN *chan = (CHANN *)_chan;
    if (chan->port.mp_SigBit != DUseSignal)
	FreeSignal(chan->port.mp_SigBit);
    FreeMem(chan, s               B?   FreeMem(io->io_Data, io->io_Length);
		FreeMem(io, sizeof(IOSTD));
	    }
	    --chan->queued;
	} else {
	    AddTail(&chan->rdylist, (NODE *)io);
	}
    }
    return(error);
}

                                                                                                     A                                                                                                              
    	dquit.c                                                                               ]uizeof(CHANN));
}

l.C
 *
 *  (internal routine)
 */

#include "lib.h"

short	DUseSignal = -1;

void *
MakeChannel(ior, host)
IOSTD *ior;
char *host;
{
    CHANN *chan = AllocMem(sizeof(CHANN), MEMF_PUBLIC|MEMF_CLEAR);

    /*	Name, Pri */
    chan->port.mp_Node.ln_Type = NT_MSGPORT;
    if (DUseSignal >= 0)
	chan->port.mp_SigBit = DUseSignal;
    else
	chan->port.mp_SigBit = AllocSignal(-1);
    chan->port.mp_SigTask = FindTask(NULL);
    NewList(&chan->port.mp_MsgList);
    NewList(           O    4) {
	io->io_Error = 1;
	ReplyMsg((MSG *)io);
    }
    DeleteChannel(chan);
}

                                                                                                                                                                                                                                                                                                                            
    	dcheckeof.c                                                                          :1~G LN]Nu    _WaitQueue        ^  _BMov           _WaitMsg       _FixSignal       .           	NUH&m .- +K m!G 8LN]Nu       NUH0&m $m .- +K+J| z mJ( 6gp`@Jg:Jf m,x N//-/-N  O * Jk܅ۭ mJ( 6g LN]Nu      _DNRead       N           NUH70&m $m .- +K+J|  mJ( 6gp` Jg  m &,x N+@Jf mN+@Jg p m( f4"mJ <gS <J $g"h ( ( $,x N."mp0,x N.` m            ;b50( @ "gS@gS@gpU@g`  m|  6"m,x N` Zp@ m( f"m & I"m,x N` m &"m,x N
 m| @ Jf  |`   m (  "( $*n."h (//-/	N  O ܅ۭ"m,x N` "h (//-/	N  O ܇ mߨ  ~ p@( f"m & I"m,x N` m &"m,x N
 m| @ ` f m|  "H,x N` N/-N  XO mJ( 6gp ( r$v   ,x N LN]Nu    _BMov        v  H  _FixSignal                  5NUH10&m $m +K~ m &/N  XO+@            <WJf m /N  XO+@JgRr& @h fH+h (~ "m) r ) t ) 4) "m ,x N|"mN"mNNv/-N  XO mJ( 6gp ( r$v   ,x N LN]Nu      _GetHead      :   "  _FixSignal                   NU/&m +Kp  m( 6&_N]Nu         1NUH'&m >- ,- *-  fG  /HmN  PO+@r~o*tl*o,l, @J "gZ;|  r 2+A+@+@"A+E h "C,x NHmN  XO-J f - m1@ 4/N   -`
/-N  p LN]Nu                   =\              _MakeChannel      (  _WaitMsg        _FixSignal          _DeleteChannel                   0         \ lib_dpri.c _DPri lib_dnaaccept.c _DNAAccept lib_daccept.c _MakeChannel _DAccept lib_dunlisten.c _DeletePort _DUnListen __MERGED lib_dlisten.c _CreatePort _sprintf _DListen lib_dexec.c _WaitMsg _DExec lib_syms.c lib_version.c _DOSBase _Version lib_elog.c _fclose __flsbf _fprintf _Program _fopen _CloseCfgFile _GetCfgLine _OpenCfgFile __elog             >GKlib_program.c lib_cfg.c _atoi _strncmp _BCmp _fgets _ExtractFieldVal _GetOneCfg lib_getenvval.c _free _GetDEnv _GetEnvVal lib_fixsignal.c _FixSignal lib_makechannel.c _NewList _DeleteChannel _DUseSignal lib_waitqueue.c _WaitQueue lib_dclose.c _DClose lib_dquit.c _DQuit _DBreak lib_dstat.c _DStat lib_dioctl.c _DIoctl lib_deof.c _DEof lib_dwrite.c _BMov _DWrite _DQueueFull lib_dqueue.c _DQueue lib_dread.c _DNRead _DRead lib_dnread.c lib_dgetioctl.c _GetHead _DGetIoctl lib_dcheckeof.c _            ?DCheckEof lib_dopen.c _DOpen                          "    - !    %  :  H    Q Q      ` !  m    x       {             x             `                        $        x      )    =   '5A O    x      x     V          x      d    S ms |      (  6 $ B    x      x !    Z     m    }              A                 n   ;    x       !    %   1   <!    ) 0 I   Q\    7  `    ] R d    x     l    &  `    x    x                O          t    O  0  .        	                        	    5  "   -       =   H    1   : T    x     DNRead _DRead lib_dnread.c lib_dgetioctl.c _GetHead _DGetIoctl lib_dcheckeof.c _          j    ۘ^)chan;
	ior.io_Message.mn_ReplyPort = (PORT *)chan;
	ior.io_Message.mn_Node.ln_Pri = txpri;
	ior.io_Message.mn_Node.ln_Name= (char *)rxpri;

	PutMsg(chan->dnetport, (MSG *)&ior);
	WaitMsg(&ior);
	if (ior.io_Error == 0) {
	    chan->chan = (long)ior.io_Unit;
	    FixSignal(chan);
	    return((PORT *)chan);
	}
    }
    DeleteChannel(chan);
    return(NULL);
}

                                    
    	dlisten.c                                                                              ~", DNETPORTNAME, host);
    if (dnetport = FindPort(buf)) {
	ior.io_Command = DNCMD_QUIT;
	ior.io_Unit = 0;
	ior.io_Offset = 0;
	ior.io_Message.mn_ReplyPort = replyport;
	PutMsg(dnetport, (MSG *)&ior);
	WaitMsg(&ior);
	DeletePort(replyport);
    }
    return(dnetport != NULL);
}

 E                                                                                                               
    lattice_dnet.lib                                                                     C@9!io_Message.mn_Node.ln_Type == NT_REPLYMSG) {
	    if (!chan->queued)
#ifdef DEBUG
		puts("DNRead: Software Error");
#else
		;
#endif
	    else
		--chan->queued;
	    if (ior->io_Length)
		FreeMem(ior->io_Data, ior->io_Length);
	    FreeMem(ior, sizeof(IOSTD));
	    continue;
	}
	switch(ior->io_Command) {
	case DNCMD_CLOSE:
	case DNCMD_EOF:
	    chan->eof = 1;
	    ReplyMsg((MSG *)ior);
	    break;
	case DNCMD_IOCTL:
	    if (ior->io_Message.mn_Node.ln_Type == NT_REQUEUE)
		AddHead(&c            .&	ehan->rdylist, (NODE *)ior);
	    else
		AddTail(&chan->rdylist, (NODE *)ior);
	    ior->io_Message.mn_Node.ln_Type = NT_REQUEUE;
	    if (len == 0)
		len = -2;
	    goto done;
	case DNCMD_WRITE:
#ifdef DEBUG
	    printf("IOR LEN/ACT %ld/%ld\n", ior->io_Length, ior->io_Actual);
#endif
	    n = ior->io_Length - ior->io_Actual;
#ifdef DEBUG
	    if (n < 0)
		puts("len fail");
#endif
	    if (n <= bytes) {
		BMov((char *)ior->io_Data + ior->io_Actual, buf, n);
		bytes -= n;
		len += n;
	           (    = fp_SigBit);
    return((PORT *)chan);
}

                                                                                                                                                                                                                                                                                                                                                                      
    amiga                                                                                   FK9T.XXXXX        NU/>- 
Bpr,x N:r 2/Hl / +@N  O ,x N|"mNzJfB/-N  PO+@Jf"mp,x N.,x Nv -.N]Nu             "        _sprintf      ,  _CreatePort       N           DNET.PORT.XXXXX DNET.PORT.%ld DNET.PORT.XXXXX          NUH 0&m $m +KBBN  ;| 'B+J+@+@ m h "C,x NHmN  .N  pL N]Nu      _CreatePort         _WaitMsg      L  _DeletePort       T                   $            HXNU  H00&m $m ,l  N KJfS" $&NN" A  $vNN JJfS" $
&NN m JfS " &$- NN" A $vNLN]Nu             |   4        _DOSBase                  V  
          =NUH0.- &m ,- $m J  fN  Hl  N  )@  N  XOJ  g  Hl /,  N  PO+@Jg  A +H Jg
SgSg`A 
+H`A +H`A +H///,  /-Hl /-N  . /
/-N  O   mS m h "mR p
r  `/-Hx 
N  PO" /-N  XOLN]Nu                      Y     *)&ior);
	WaitMsg(&ior);
	DeletePort(replyport);
    }
    return(dnetport != NULL);
}

                                                                                                                                                                                                 D                                                                                                              
    	daccept.c                                                                            I#r      x   n   V   >   $         B   6   ,           _OpenCfgFile         _GetCfgLine       (  _CloseCfgFile         0  _fopen        F  _Program        _fprintf           __flsbf       ܃  _fclose                  LOGF  a ? Fatal Warn  Debug %s %s.%s/%ld                                                        Sa  Hl Hl  N  PO)@ JVDHH NuH 0&o J g`/, Hx Hl  N  O JgHHx /Hl  N  O JfA  "HJfSA 	            JJB0 E r gr	fR` 
`p L NuJ g
/, N  XOB NuNU/&m a D/a b+@a&mN]NuNUH0&m $m J g
 m 0H`p .  JJfS,Jg8 H/ /
/N  O JfJ g
 F m 0 K/N  `RRG`pLN]Nu             
                     z   p   b   R   <   4   .           _fopen          _fgets        @  _BCmp         V  _fclose         _strncmp       _atoi        4           s:dnet.config r        !       NUH&m /N            KM  XO~ +@Jg
/ N  XO. /-N   LN]Nu    _GetDEnv        _atoi         "  _free         .           NUH00&m +K m"H $h fC *$h &gp ( r$v   ,x NLN]Nu         ANUH 0&m $m p@"<  ,x N: @|  2,  +@JAkA `pN m@ N m!@ C /	N   m &.N  XO +  m1@ 4'H , 
g&/
Hl Hl HmN  O C,x Nz'@  m!k  " L N]NuNU/&m +Kp  m( 2,  Hgr   ,x N"mp@,x N.&_N]Nu                   LrD               *        _NewList      l   ^  _sprintf                 DNET.UNIT.  %s%s  DNET.UNIT.         %NUH0&m $m +K~  m ( < 8od,x N mN+@r @( f4JGf( HgJ $g"h ( ( $N."mp0N. mS <`"m & I"@N
` LN]Nu         )NU/&m  K;| "p 0( 4+@+H+H+H m h "C,x N mR <B 8Hm/N  PO m &,x N+@Jf mN+@Jg m|  "H,x N`/-N  &mN]Nu      _WaitQueue        P              MbY_DeleteChannel                   7NU/&m  fG /Hl Hl HmN  O C,x Nz+@Jg"@"i  <   N&_N]NuNU/&m BBN  PO+@ fG ,/Hl 4Hl .HmN  O C,x Nz+@g0;| %BB+m @CNHmN  .N  XOJVD HH&_N]Nu           z   v   p                 _sprintf         "  _CreatePort       b  _WaitMsg        _DeletePort                  DNET.UNIT.  0 %s%s  DNET.UNIT.  DNET.UNIT.  0 %s%s  DNET.UNIT.         &        	    NmJNUH 0&m $m BBN  PO+@ fG /Hl Hl HmN  O C,x Nz+@g4;| @BB+J+m @CNHmN  .N  XOJVD HHL N]Nu             .   *   $        _CreatePort         _sprintf      6  _WaitMsg      v  _DeletePort       ~           DNET.UNIT.  0 %s%s  DNET.UNIT.          NUH&m - <- -  K;| &p 0( 4+@+H+Hp 0H@B@r ၀r +@+H m h "C,x NHmN  .N  LN]Nu      _WaitMsg      j          
    9=Yg_FixSignal        r           NU/&m  K;| #p 0( 4+@+H+H+H m h "C,x NHmN  .N  &mN]Nu    _WaitMsg      B  _FixSignal        J           ONU/&m +K mJ 8g ( < 8op`p &_N]NuNUH0&m $m .- ,+K+J mJ 8g  B/N  POJ@kvp0"<  ,x N: @1| $ r "m2) 4!A !I ,!I +@ rN: m!@ (!G $//( (/-N  O  m h ""m,x N mR <`L|`H;| $p 0( 4+@+H+H+m+G m h "C,x NHmN  XOJ-g|/-N              Pھ/-NPO+@pX-f HmNXO`  RX"P+IfA +H mJfS+H -Jk&o"+@`p+@ RX @B-`p `   -"-lp +@` -䑭Jg6Smp  m/ +H m NXO`SmHp -/  m NXO`Smp -/  m NXO`Smp  m/ +H m NXO` LN]Nu  NUH0&o $o "+m Jg4p% f"fR`/Hm/
a O +@g$@`p / NXO`LN]Nu   o  XB !H Nu                                   J        |     d    z  x           F        	    Q5TD         
         __CXM33      _DevOpen      _stcul_d  L   _CXD33    	   __pf  F   __pfmt    
d   _stcl_o   |   _CXD22    	B   _sprintf  N   _movmem      _stci_o   |   __CXM22      _SynchroMsg      _ExtendSize   p   _NewList     _DevClose        _DeletePort      __CXD22   	B   _Init      <   _DUMmySeg      0   _stcd_i      _CXM22       _strupr      _stci_h      _stcl_h      _DevBeginIO   r   _CXM33       _stcu_d   L        
    RD   __CXD33   	   _CoProc      _DevAbortIO   t   _DevExpunge   z   _CreatePort   	           qfmsdisk.device fmsdisk.device 1.0 (3 Nov 1989)
                    dos.library FMS-Dummy        z      r  tFMS:Unit%d  FMS:Unit%d              (((((                  H          (((((                  H          (    w                                                                n   j   b   ^   Z         _SysBase   4   _FPort       _DeviceName        _DevSegment    <   _FProc     @   __ctype       _IdString         _DevVectors    Z   _DevBase   8   _DOSBase        ort      __CXD22   	B   _Init      <   _DUMmySeg      0   _stcd_i      _CXM22       _strupr      _stci_h      _stcl_h      _DevBeginIO   r   _CXM33       _stcu_d   L               t the first time to create the file.
    Format drive FF0: name "FF0" NOICONS

    Repeat above two lines for each simulated partition you wish to add.


d partition
    using fmsdisk.device that uses exactly the same parameters as
    my favorite floppy device (and run the appropriate file system,
    in this case the OFS).  After formatting, I can copy the distribution
    onto the simulated partition and then DiskCopy it to the floppy.

    This also has advantages to people fooli              Q ?                                                       P                               : <       :       4        ':        g4       (       0? ? ? ? ?   ?  ?                            ? ? ? ?uUUUUU zuUUUUU                            p    ;umber of semi-permanent partitions (files)..
very useful for making distributions of software.  Also useful for
those of you testing your home brew file systems without accidently
overwriting something important!
Keywords: $binary disk diskcopy ffs file filesystem fs hard hd ofs
          trackdisk
Download count: 31
------------------------------------------------
                              
    7tag.asm                                                              y                  s ?                                                       P   x                            : <       :       4        ':        g4       (       0? ? ? ? ?   ?  ?                            ? ? ? ?uUUUUU zuUUUUU                             XGF Advantages over RAD / Other ram disks ... doesn't use RAM.
      Designed for hard disk users.  By putting the 'partition'
      file on the hard disk, it sticks around and you don't loose
      the data you wrote to it, so mounting it again after reboot
      or power up yields whatever was there before.

    The fmsdisk.device simulates a trackdisk.device for fixed media
    via a DOS file (one file per unit).  Simply setup your Mountlist,
    mount the simulated trackdisk, and fo            Y*Nrmat, and you are off.

    This has particular advantages for those hard disk users who make
    lots of distributions, like me.  I can create a simulated partition
    using fmsdisk.device that uses exactly the same parameters as
    my favorite floppy device (and run the appropriate file system,
    in this case the OFS).  After formatting, I can copy the distribution
    onto the simulated partition and then DiskCopy it to the floppy.

    This also has advantages to people fooli            SGRng around with writing their
    own file systems, as the disk file used may be examined at any time
    through normal programs while the 'filesystem' is running.

			   INSTALLATION

    copy fmsdisk.device devs:

    Assign FMS: to some empty directory on your hard disk (doesn't have
    to be empty, but might as well be clean, eh?).  Files will be
    named FMS:Unit%d

    Add appropriate entries to your Mountlist (see example Mountlist).

    Mount FF0:

    ; Only need to forma            [ UUUUG          *UUUUG          UUUUG          UUUUG                       @                                                                                                                                                                                                                                                                                                                                 $                                                                                                                      :c/MuchMore   7UUUU~  7  7UUUU~  7  7  7_  7  0           *UUUUU                                                 UUUG              UUUUG          *UUUUG          UUUUG          UUUUG                      ]Oά ACN mN.NLHN]NuNUtH1
I    ~,x  <    NJg r,x AN,x AN+@Jg @+h p 0( @Ug  Sg TQg   gSg  Sg  `  l 8 " -"t2/ Hl vHmxNO ,y  Ax"$<  N m!@ (Jf$,y  Cx"	$<  N m!@ (|  0J (g ,y  "( (t vN m"( (vN m!@ ,` Z mJ (g N,y  "( (N mB (` 4~ ` . mJ (g ""m ) ,Щ $ ,c
/ /a ,PO,y   m"( ( m$( ,vN m"( ( m$( (&( $N m!@  `   mJ( 0g\J            ^C0 (gV,y  "( (N l 8 " -"t2/ Hl HmxNO ,y  Ax"$<  N m!@ (B( 0 mJ (gT"m ) , ,c
/ /a  dPO,y   m"( ( m$( ,vN m"( ( m$( (&( $N m!@  Jf,x N|,x "mN` LPN]NuNUH3&o (./ ,,x  <   "<  N:+@J+ 0f|  0,y  "+ (t vN&"+ (N, l(,y  "+ ($-&<   N   f   `,x "m <   N.LHN]NuH 0&o $KJg$p A 0  g
r  t `r  R` LNu        pa /  o NU"Or
NA 0Jf 	fBN]Nu              _Y /  o NU"O" A A 0f 	fBN]Nu  0123456789abcdef /  o C 2 A f 	"XᲉfBNu o "Hr p / +g -fRH  0m  	n$҂ҁҀ` -fD$ S o  Nu/./ R  l)H.NuNU  H 0&o $o B)KHm /
HzN lB ,L N]Nu o "o  / oe SfNuSfNu  H &o J 
g
"K,x N|  p'@ p + ,x N"Kp"N.LH NuH0 $ &HBHCCHBBBЂL NuJj  DJj  Da   DNua  DDNuJj  Da  DNu/HA4f  "H@HAHB4 g  0H@4 0            c6HB2$Nu/vA d  QCA d  YCA  d  UCJAk  SC4 HBBBHC6 04HAd  SCЁdr 2HCH@A&$NuH2&o ./ p,x N,  fp `fp""<  N:$@ 
f
p N`H%K 
 @ 	|  B* F N%@  g"JN`A %H A %H B |    
LLNu  NUH'0&o \$o `~ | z p |  r +At+BA@@+A+A+HJgBp r]Ak8{fN #`     `   +`   -`  ~`|`
z`| R`r0fRAp*f RX+PR`Hm/NPOr.f"Rp*f RX+PR`Hm/NPOrlf
            a)bs  = 2
	BlocksPerTrack = 11
	Reserved = 2
	Interleave = 0
	LowCyl = 0
	HighCyl = 79
	Buffers = 2
	BufMemType = 0
#

FF3:	Device = fmsdisk.device
	Unit   = 3
	Flags  = 1
	Surfaces  = 2
	BlocksPerTrack = 11
	Reserved = 2
	Interleave = 0
	LowCyl = 0
	HighCyl = 79
	Buffers = 2
	BufMemType = 0
#

/* Mountlist entry for 4 FFx devices, all using the fast file system */

FF4:	Device = fmsdisk.device
	FileSystem = l:FastFileSystem
	Unit   = 4
	Flags  = 1
	Surfaces  = 2
	BlocksPerTrack = 11
	R            bjeserved = 2
	Interleave = 0
	LowCyl = 0
	HighCyl = 79
	Buffers = 2
	BufMemType = 0
	GlobVec = -1
	DosType = 0x444F5301
#


FF5:	Device = fmsdisk.device
	FileSystem = l:FastFileSystem
	Unit   = 5
	Flags  = 1
	Surfaces  = 2
	BlocksPerTrack = 11
	Reserved = 2
	Interleave = 0
	LowCyl = 0
	HighCyl = 79
	Buffers = 2
	BufMemType = 0
	GlobVec = -1
	DosType = 0x444F5301
#


FF6:	Device = fmsdisk.device
	FileSystem = l:FastFileSystem
	Unit   = 6
	Flags  = 1
	Surfaces  = 2
	BlocksPerTrack = 11
          q    	Reserved = 2
	Interleave = 0
	LowCyl = 0
	HighCyl = 79
	Buffers = 2
	BufMemType = 0
	GlobVec = -1
	DosType = 0x444F5301
#


FF7:	Device = fmsdisk.device
	FileSystem = l:FastFileSystem
	Unit   = 7
	Flags  = 1
	Surfaces  = 2
	BlocksPerTrack = 11
	Reserved = 2
	Interleave = 0
	LowCyl = 0
	HighCyl = 79
	Buffers = 2
	BufMemType = 0
	GlobVec = -1
	DosType = 0x444F5301
#

:	Device = fmsdisk.device
	FileSystem = l:FastFileSystem
	Unit   = 4
	Flags  = 1
	Surfaces  = 2
	BlocksPerTrack = 11
	R            O| R`rhfRr  @p0]@k :{ fN  c`  s`  X` t x` n p` T o` 
 u`   d`  J-g RX ` RX +@l
rD+AJgp-`
Jgp+`p @p "-肀p gRR/-/-NBPO+@ -Jjr+A -"-H o8 m"H/-/	/-NBO p -"- m`Sd -+@ -ѭA+HJg 0|  ` &J-g RX ` RX +@` \J-g RX ` RX +@J-g m 0r+A+H/ /-NPO+@` *| 0 -Jjp+@J-g RX ` RX +@J-g m 0 xr+A+H/             \H>U mp 0( "Hr 2 p 0( Ҁ N.B < , <LPN]NuNUH I    &I+l 8 k +HJh &gSh &f/Hxa ^PO mJh  g
Sh  gp `*J @gBHxa 8POB @ m(  ga `p L N]NuH I    &IB+ B  p 0+ @   d  @0; N  *  4 L        d |         |  `  ,x "KAN   `f,x "KAN   `N,x "KAN   `6|  `.p'@  `&B  ` B  `|  `B  `B  `|   g+   f
,x "KNLX NuH I    &IL NuNUH>/ N&o PBBN8+@;G+K,x     z       fTD_GETNUMTRACKS:
	iob->io_Actual = 0; /*	# of tracks?	    */
	break;
    case TD_ADDCHANGEINT:   /*	action never taken  */
    case TD_REMCHANGEINT:
	break;
    default:
	iob->io_Error = IOERR_NOCMD;
	break;
    }
    if (iob) {
	if ((iob->io_Flags & IOF_QUICK) == 0)
	    ReplyMsg((MSG *)iob);
    }
}

__saveds void __asm
DevAbortIO(register __a1 IOBP iob)
{
    /*NDev *nd = DevBase;*/
}

func_ptr DevVectors[] = {
    (func_ptr)DevOpen,
    (func_ptr)DevClose,
    (func_ptr)DevExpung     z       gzvJe,
    NULL,
    (func_ptr)DevBeginIO,
    (func_ptr)DevAbortIO,
    (func_ptr)-1
};

/*
 *  Server communications
 */

void
SynchroMsg(cmd, unit)
UWORD cmd;
struct Unit *unit;
{
    IOB Iob;

    Iob.io_Message.mn_ReplyPort = CreatePort(NULL, 0);
    Iob.io_Command = cmd;
    Iob.io_Unit = unit;

    PutMsg(&FPort, &Iob.io_Message);
    WaitPort(Iob.io_Message.mn_ReplyPort);
    DeletePort(Iob.io_Message.mn_ReplyPort);
}

/*
 *	SERVER SIDE (IS A PROCESS)
 *
 *	File name is:
 */

__s     z       huԥaveds void
CoProc()
{
    IOBP iob;
    NDUnit *unit;
    char buf[128];
    char notdone = 1;
#ifdef DEBUG
    long fh = Open("con:0/0/320/100/Debug", 1006);
#endif

    Wait(SIGBREAKF_CTRL_D);     /*  wait for port init  */

    while (notdone) {
	WaitPort(&FPort);
	while (iob = (IOBP)GetMsg(&FPort)) {
	    unit = (NDUnit *)iob->io_Unit;

#ifdef DEBUG
	    sprintf(buf, "Cmd %08lx/%04x @ %08lx Buf %08lx %04x\n",
		unit, iob->io_Command, iob->io_Offset, iob->io_Data, iob->io_Length
	     z       iҔ    );
	    Write(fh, buf, strlen(buf));
#endif
	    switch(iob->io_Command & ~TDF_EXTCOM) {
	    case CMD_OPENUNIT:
		sprintf(buf, "FMS:Unit%d", unit - &DevBase->Unit[0]);
		unit->Fh = Open(buf, 1005);
		if (unit->Fh == NULL) {
		    unit->Fh = Open(buf, 1006);
		    unit->NotSyn = 1;
		}
		if (unit->Fh) {
		    Seek(unit->Fh, 0L, 1);
		    unit->Size = Seek(unit->Fh, 0L, -1);
		}
		break;
	    case CMD_CLOSEUNIT:
		if (unit->Fh) {
		    Close(unit->Fh);
		    unit->Fh = NULL;
		}
	     z       jԜ`	break;
	    case CMD_KILLPROC:
		notdone = 0;
		break;
	    case CMD_READ:
		if (unit->Fh == NULL)
		    break;
		if (iob->io_Offset + iob->io_Length > unit->Size)
		    ExtendSize(unit, iob->io_Offset + iob->io_Length);
		Seek(unit->Fh, iob->io_Offset, -1);
		iob->io_Actual = Read(unit->Fh, (char *)iob->io_Data, iob->io_Length);
		break;
	    case CMD_WRITE:
		/*
		 *  This causes file to be closed/reopened after
		 *  formatting.
		 */
		if (unit->NotSyn && unit->Fh) {
		    Close     z       kܛ?(unit->Fh);
		    sprintf(buf, "FMS:Unit%d", unit - &DevBase->Unit[0]);
		    unit->Fh = Open(buf, 1005);
		    unit->NotSyn = 0;
		}
		/* fall through */
	    case TD_FORMAT:
		if (unit->Fh == NULL)
		    break;

		if (iob->io_Offset > unit->Size)
		    ExtendSize(unit, iob->io_Offset);
		Seek(unit->Fh, iob->io_Offset, -1);
		iob->io_Actual = Write(unit->Fh, (char *)iob->io_Data, iob->io_Length);
		break;
	    }

	    if (notdone == 0)       /*  forbid before falling through */
		Fo     z       lZ9rbid();           /*  and esp before replying       */
	    ReplyMsg(&iob->io_Message);
	}
    }
    /* fall through to exit */
}

void
ExtendSize(unit, offset)
NDUnit *unit;
long offset;
{
    long pos;
    char *buf = AllocMem(512, MEMF_CLEAR|MEMF_PUBLIC);

    if (unit->NotSyn == 0)
	unit->NotSyn = 1;
    Seek(unit->Fh, 0L, 1);
    pos = Seek(unit->Fh, 0L, 0);
    while (pos < offset) {
	if (Write(unit->Fh, buf, 512) != 512)
	    break;
	pos += 512;
    }
    FreeMem(buf, 512);
}
     z          
unit->Fh);
		    sprintf(buf, "FMS:Unit%d", unit - &DevBase->Unit[0]);
		    unit->Fh = Open(buf, 1005);
		    unit->NotSyn = 0;
		}
		/* fall through */
	    case TD_FORMAT:
		if (unit->Fh == NULL)
		    break;

		if (iob->io_Offset > unit->Size)
		    ExtendSize(unit, iob->io_Offset);
		Seek(unit->Fh, iob->io_Offset, -1);
		iob->io_Actual = Write(unit->Fh, (char *)iob->io_Data, iob->io_Length);
		break;
	    }

	    if (notdone == 0)       /*  forbid before falling through */
		Fo            n`!                                         ?      <?                  9      |<?                  Ϗ      3      ?χ      3      ?      ??                                                                                                                                                             o                                                                                                                                                                                                                                                                                                                                                         b                      *UUUUU  7  7  7  7ꪪꪪ  7  7  7  7            ZUUU~  7  7UUUU~  7  7UUUU~  7  7UUUU~  7  7UUU~  7  7UUUU~  7  7UUUU~  7  7  7_  7  0           *UUUUU                                                 UUUG              UUUUG          *UUUUG          UUUUG          UUUUG                        H    D                              r  t  w          y                                                                    t                                                                                                                                                                                                                                                                   
     AmigaLibDisk294                          
    	  
                                JASb * m N. Jg
   o<p0f6pxgpXf* m N. A0 x f m  p ` BS`BA0 X g
 r0+@A0  X g
 r7+@A0 X g
 rW+@SgbA0 x gV -+@A0 x g
 r0A0  x g
 r7A0 x g
 rW m N. ` 
g  Jf R - `   R `  A0 x f m  p `  |  r
N"tЁ,  m N. SgA0 x f 
g   R 0`| 
g RR So m N. pg 
g RR `pf
 m  p `JA  `B 
g RR  m N. pgSgA0 x      r         sbk6                                                                                                                                                                                                                                                                                              s               ?                                                                                              
    ^.info                                                                p         r      ?    *J;L   
    
DNet
Contents
Distribution
GeneralInfo
FmsDisk
   Zh         	  q    @ Z     !         Z (              ;   zx                       < 1   <     0          `        ?      0                  ?                                                  ;   |     ?        :   \< 0 Q\     `    
  U\        0    \  ?  
  |        ;            t            /                                                                                                                  u                                                                                                                                                                                                                                                                                          
    }c                                                                    p            u   #      v*c                                                                                                                                                      u                                                                    v              B                                                                                              
    	;MuchMore                                                             t         u       ]O                              N                             Out of memory!  Can't open file!  Usage: MuchMore <Text> | -s Read/Write Error  Need arp for FileReq  Console problem MuchMore V2.5  1989 AMOK MM is sleeping  MM is awake NIL:    OK    topaz.font  XFile:                                  xxx % (xxxxxx of xxxxxx Bytes) xxxxxx Lines                MuchMore V2.5 Commands:     Space, LMB:         Start / Stop scrolling. Quit at end of file.  Back     w         xE                                                                                                                                                                                                                       q  p  o  n  m  l  k  j  }  |  {  z  y  x  w  v    ~  x              "                                                                                              
    
GeneralInfo                                                          p         w       ~+;Ew			    Introducing the Amiga

		   Freely Redistributable Software Library


What's Available

	There are "do-nothing-useful" examples of various capabilities of
	the AMIGA, real development tools, editors, languages, games, and
	other odds & ends.  Also included are machine readable form of many
	of the examples (received directly from C-A sources) out of the
	official AMIGA manuals, including the ROM Kernel Manual.


How To Obtain Disks

	First, check with your local dealers and us     y            O                  z                                                                                                                                                                                                                                                                                                                                                                          
    gFmsDisk                                                              p            z         {6                                                                                                                                                                                                                       l  k  j  i  h  g  f  e                ~  }  |  {              "Q                                                                                              
    
fms.c                                                              y         z       |B,
/*
 *  FMS.C
 *
 *  File Disk Device (fmsdisk.device)
 *
 *  Simulates a trackdisk by using a large file to hold the 'blocks'.
 */

#include <exec/types.h>
#include <exec/nodes.h>
#include <exec/errors.h>
#include <exec/memory.h>
#include <devices/trackdisk.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>

#include <proto/all.h>

/*#define DEBUG*/

#define CMD_OPENUNIT	(0x7FF0 & ~TDF_EXTCOM)
#define CMD_CLOSEUNIT	(0x7FF1 & ~TDF_EXTCOM)
#define CMD_KILLPROC	(0x7FF2 & ~T     z       }UR"DF_EXTCOM)

void SynchroMsg();
void ExtendSize();

typedef struct Library	LIB;
typedef struct Device	DEV;
typedef struct Process	PROC;
typedef struct MsgPort	PORT;
typedef struct Message	MSG;
typedef struct List	LIST;
typedef struct Node	NODE;
typedef long (*func_ptr)();

typedef struct {
    struct  Unit    U;
    UWORD   OpenCnt;
    long    Fh; 	/*  file handle     */
    long    Size;	/*  current size    */
    char    NotSyn;
    char    Reserved;
} NDUnit;

typedef struct {
        z       ~k@r LIB     Lib;
    NDUnit  Unit[32];
} NDev;

typedef struct {
    struct  Message io_Message;
    struct  Device  *io_Device;     /* device node pointer  */
    struct  Unit    *io_Unit;	    /* unit (driver private)*/
    UWORD   io_Command; 	    /* device command */
    UBYTE   io_Flags;
    BYTE    io_Error;		    /* error or warning num */
    ULONG   io_Actual;		    /* actual number of bytes transferred */
    ULONG   io_Length;		    /* requested number bytes transferred*/
    APT     z       lR    io_Data;		    /* points to data area */
    ULONG   io_Offset;		    /* offset for block structured devices */

    long    iotd_Count; 	    /*	(extension)     */
    long    iotd_SecLabel;	    /*	(extension)     */
} IOB;

extern char DeviceName[];
extern char IdString[];
extern void DUMmySeg();

typedef NDev	*NDevP;
typedef IOB	*IOBP;

long SysBase	= NULL;
NDev *DevBase	= NULL;
APTR DevSegment = NULL;
PORT *FProc	= NULL;
PORT FPort;

extern func_ptr DevVectors[];

__saveds NDev     z       `qP	__asm
Init(register __a0 APTR seg)
{
    NDev *db;

    SysBase = *(long *)4;
    DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", 0);

    DevBase = db = (NDev *)MakeLibrary((long **)DevVectors,NULL,NULL,sizeof(NDev),NULL);
    db->Lib.lib_Node.ln_Type = NT_DEVICE;
    db->Lib.lib_Node.ln_Name = DeviceName;
    db->Lib.lib_Flags = LIBF_CHANGED|LIBF_SUMUSED;
    db->Lib.lib_Version = 1;
    db->Lib.lib_IdString= (APTR)IdString;

    DevSegment = seg;
    AddDevice((DEV *)d     z       .Tb);
    return(db);
}

__saveds NDevP __asm
DevOpen(register __d0 long unitnum,
	register __a1 IOBP iob,
	register __d1 long flags
       )
{
    NDev *nd = DevBase;
    NDUnit *unit = &nd->Unit[unitnum];

    if (++nd->Lib.lib_OpenCnt == 1) {
	FProc = CreateProc("FMS-Dummy", 0, (long)DUMmySeg >> 2, 4096);
	FPort.mp_SigBit = SIGBREAKB_CTRL_D;	/*  port init */
	FPort.mp_SigTask= FProc->mp_SigTask;
	FPort.mp_Flags = PA_SIGNAL;
	NewList(&FPort.mp_MsgList);
    }

    if (++unit->OpenCnt     z       m == 1)
	SynchroMsg(CMD_OPENUNIT, unit);

    nd->Lib.lib_Flags &= ~LIBF_DELEXP;
    iob->io_Unit = (struct Unit *)unit;
    iob->io_Error = 0;
    return(nd);
}


__saveds APTR
DevExpunge()
{
    NDev *nd = DevBase;

    if (DevSegment == NULL)
	Alert(24, (char *)24);
    if (nd->Lib.lib_OpenCnt) {
	nd->Lib.lib_Flags |= LIBF_DELEXP;
	return(NULL);
    }
    Remove((NODE *)nd);
    FreeMem((char *)nd - nd->Lib.lib_NegSize, nd->Lib.lib_NegSize + nd->Lib.lib_PosSize);
    DevSegment = N     z       Fa7ULL;
    return(DevSegment);
}

__saveds APTR __asm
DevClose(register __a1 IOBP iob)
{
    NDev *nd = DevBase;

    {
	NDUnit *unit = (NDUnit *)iob->io_Unit;
	if (unit->OpenCnt && --unit->OpenCnt == 0)
	    SynchroMsg(CMD_CLOSEUNIT, unit);
    }

    if (nd->Lib.lib_OpenCnt && --nd->Lib.lib_OpenCnt)
	return(NULL);
    if (FProc) {
	SynchroMsg(CMD_KILLPROC, NULL);
	FProc = NULL;
    }
    if (nd->Lib.lib_Flags & LIBF_DELEXP)
	return(DevExpunge());
    /*
     *	close down resources
       z   	    |   */
    return(NULL);
}

__saveds void __asm
DevBeginIO(register __a1 IOBP iob)
{
    /*NDev *nd = DevBase;*/

    iob->io_Error = 0;
    iob->io_Actual = 0;

    switch(iob->io_Command & ~TDF_EXTCOM) {
    case CMD_INVALID:
	iob->io_Error = IOERR_NOCMD;
	break;
    case CMD_RESET:
	break;
    case CMD_READ:
	PutMsg(&FPort, &iob->io_Message);
	iob->io_Flags &= ~IOF_QUICK;	/*  not quick */
	iob = NULL;
	break;
    case CMD_WRITE:
	PutMsg(&FPort, &iob->io_Message);
	iob->io_Flags &=      z   
    ,,G~IOF_QUICK;	/*  not quick */
	iob = NULL;
	break;
    case CMD_UPDATE:
	break;
    case CMD_CLEAR:
	break;
    case CMD_STOP:
	break;
    case CMD_START:
	break;
    case CMD_FLUSH:
	break;
    case TD_MOTOR:	    /*	motor,	no action   */
    case TD_SEEK:	    /*	seek,	no action   */
	break;
    case TD_FORMAT:	    /*	format		    */
	PutMsg(&FPort, &iob->io_Message);
	iob->io_Flags &= ~IOF_QUICK;	/*  not quick */
	iob = NULL;
	break;
    case TD_REMOVE:	    /*	not supported	    */
	io     z       efb->io_Error = IOERR_NOCMD;
	break;
    case TD_CHANGENUM:	    /*	change count never changes  */
	iob->io_Actual = 1;
	break;
    case TD_CHANGESTATE:    /*	0=disk in drive     */
	iob->io_Actual = 0;
	break;
    case TD_PROTSTATUS:     /*	io_Actual -> 0 (rw) */
	iob->io_Actual = 0;
	break;
    case TD_RAWREAD:	    /*	not supported	    */
    case TD_RAWWRITE:
	iob->io_Error = IOERR_NOCMD;
	break;
    case TD_GETDRIVETYPE:   /*	drive type?	    */
	iob->io_Actual = 0;
	break;
    case               'k                                                                                                                                                                                                                                                                          [  Z  o  n  m                

                                                                                              
    fms.doc.info                                                         y                m        b     & &@                  L  ]                           b                            EUUUU@        E_UU@        EVUUE        EVgG        EVggeG        EVffEG        EVfuG        E_G        ETG        EUUUUG        EuuUG        EQqUG        Euq}G        EqqG        EqqG        EqqG        Eyy}G        EAAAG        EUUUUG        EUUUUG        EUUUUG        EUUUUG        EUU@G        EUUUUG                     /        UUUUU              bs$                                                                                                                                                                                                                                                                                                                                                                                                           
     K.info                                                                y                   ͟7L   
    fms.doc
                                                                                             :c/MuchMore   7UUUU~  7  7UUUU~  7  7  7_  7  0           *UUUUU                                                 UUUG              UUUUG          *UUUUG          UUUUG          UUUUG                                                                                                                                                                                                                                                                                                          b  a  `                )                                                                                              
     	Mountlist                                                            y                `T*
/* Mountlist entry for 4 FFx devices, all using the old file system */

FF0:	Device = fmsdisk.device
	Unit   = 0
	Flags  = 1
	Surfaces  = 2
	BlocksPerTrack = 11
	Reserved = 2
	Interleave = 0
	LowCyl = 0
	HighCyl = 79
	Buffers = 2
	BufMemType = 0
#

FF1:	Device = fmsdisk.device
	Unit   = 1
	Flags  = 1
	Surfaces  = 2
	BlocksPerTrack = 11
	Reserved = 2
	Interleave = 0
	LowCyl = 0
	HighCyl = 79
	Buffers = 2
	BufMemType = 0
#

FF2:	Device = fmsdisk.device
	Unit   = 2
	Flags  = 1
	Surface              &Q                                                                                                                                                                                                                                                                                                                                                                                                          
    *	DMakefile                                                            y                  s
OD=   ltmp:fms/
CFLAGS= -cimq -v
EXE=
SYMS= $(OD)all.m
LIBS= lib:lc.lib lib:amiga.lib

all: $(SYMS) $(EXE)fmsdisk.device

$(EXE)fmsdisk.device : $(OD)tag.o $(OD)fms.o
    blink %(right) SC SD LIB $(LIBS) ADDSYM TO %(left)

$(OD)tag.o : tag.asm
    asm -Iinclude:/asminclude/ -o%(left) %(right)

$(OD)fms.o : fms.c
    lc $(CFLAGS) -H$(SYMS) -o%(left) %(right)

$(SYMS) : syms.c
    lc $(CFLAGS) -ph -o%(left) %(right)

ystem
	Unit   = 4
	Flags  = 1
	Surfaces  = 2
	BlocksPerTrack = 11
	R              g                                                                                                                                                                                                                                                      R  Q  P  O  c  _  ^  ]  \  d                8                                                                                              
    fmsdisk.device                                                       y                dJ                     q    p NuJ      1            <                     NqNqNNUH :I    &H0| )P 4,x C Dp N#  A Z$I <  b"	N)@ 8 @|  C  !I 
|  1|  C !I )K <+@"@NP -L\ N]NuNUH;:I    . &I,+l 8 r2N mC " mRh  +Iph  fBE0 
,y  & E P"
t (<   Nv)@ @|  @)h B,HlNdXO mRh &ph &f/Hxa .PO m  'm B+  L\N]NuNUH
I    +l 8J <f0| /,x .*GN*_ mJh  g
  p `2,x "HN              )q                                                                                                                                                                                                                                                                                                                                                                                                        
    7tag.asm                                                              y                I
		include "exec/types.i"
		include "exec/exec.i"
		include "exec/resident.i"

		section text,CODE

		xref	_Init
		xref	_CoProc
		xdef	_DeviceName
		xdef	_IdString
		xdef	_DUMmySeg


		moveq.l #0,D0		;   word
		rts			;   word

InitDesc:
		dc.w	RTC_MATCHWORD
		dc.l	InitDesc
		dc.l	EndCode
		dc.b	0		;   not auto-init
		dc.b	1		;   version
		dc.b	NT_DEVICE
		dc.b	0		;   priority
		dc.l	_DeviceName
		dc.l	_IdString
		dc.l	_Init
		dc.l	0		;   extra ?
		dc.l	0
		dc.l	0

		dc.w	0		;   word                -IF(long align)

		ds.l	0		;   LW align
		dc.l	16
_DUMmySeg:	dc.l	0
		nop
		nop
		jmp	_CoProc(PC)

		section DATA,DATA

_DeviceName:	dc.b	'fmsdisk.device',0
_IdString:	dc.b	'fmsdisk.device 1.0 (3 Nov 1989)',13,10,0

EndCode:

		END

                                                                                                                                                                    
    *	DMakefile                                                            y                  ]                                                                                                                                                                                                                                                                                                                                                                                                           
    syms.c                                                               y                   Z
#include <exec/types.h>
#include <exec/nodes.h>
#include <exec/errors.h>
#include <devices/trackdisk.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>

#include <proto/all.h>


3 Nov 1989)',13,10,0

EndCode:

		END

                                                                                                                                                                    
    *	DMakefile                                                            y                  j1                                                                                                                                                                                                                                                                                          U                X                                                                                              
    POSTER                                                               y                Upǰ------------------------------------------------
fmsdisk.zoo     12288  Approx time (min): 13 at 300 baud,  3 at 1200 baud
Contributed by: mdillon  Date: Mon Nov  6 01:29:49 1989
creates a trackdisk.device configuration via normal file.
For people with HARD DISKS.  Mainly, instead of having to setup
a partition on your HD that looks like a floppy so you can do
DiskCopys, this device will look like a trackdisk device but use a
normal file to store the blocks.  

Useful to create any n              4                                                                                                                                                                                                                                                                              S  Y  X  W                :                                                                                              
    fms.doc                                                              y                W
			       FMS.DOC

		    FILE BASED TRACKDISK SIMULATOR

    * Useful for creating a floppy-like partition on your harddisk
      (so you can diskcopy to a floppy) WITHOUT actually having to
      create a special partition for it.

    * Useful for testing new filesystems and such

    * Up to 32 Units, OFS or FFS selectable via Mountlist

    * THIS IS NOT A RAM DISK.  Operation will be necessarily slower
      than your HD, but that isn't the point behind using the device!

    *                 yT                                                                                                                                                                                                                                                                    r                                                                                                                              
    TDNet                                                                 p                     bn                                                                                                                                                                                                                                                                                                                                                                                                           
    V.info                                                                                   jL   
    unix
amiga
                                                                                                                                                                                                                                                                                                                                                                   
    gFmsDisk                                                              p                                                                                                                                                                                                                                                                                                               T                                                                                                              
    	unix.info                                                                            Tb'      z  P     ' '                  L               H        "   D    @                Z (              P                               : <       : 4 : ?4  _( 0                                                                              ? ? ? ? ? ? ? ? ? ? ?              H                                                                                                                                                                                                                                                                                          V                                                                                                              
    T
amiga.info                                                                           VQ]        P     ' '                  L           6    (          U s    @                Z (              P                               : <       : 4 : ?4  _( 0                                                                              ? ? ? ? ? ? ? ? ? ? ?                 =35                                                                        @      C  L      t                                                                                                                                                                                                                                                                                        
     Namiga                                                                                                                                                                                                                                                                                                                                                                                                                                                    
    lib                                                                                       "ú                                                                                                                                                                                                                                                                                                                                                                                                          
    dunlisten.c                                                                          Ty>X
/*
 *  DUnListen.C
 */

#include "lib.h"

void
DUnListen(lisport)
PORT *lisport;
{
    if (lisport) {
	char *ptr = lisport->mp_Node.ln_Name;
	Forbid();                       /*  task-atomic operation       */
	while (DNAAccept(lisport));     /*  remove all pending requests */
	DeletePort(lisport);            /*  gone!                       */
	Permit();
	FreeMem(ptr, NAMELEN);
    }
}

        
    T
amiga.info                                                                             d9                                                                                                                                                                                                                                                                                          D                                                                                                              
    	daccept.c                                                                            DFx
/*
 *  DAccept.C
 */

#include "lib.h"

PORT *
DAccept(lisport)
PORT *lisport;
{
    IOSTD *ior;
    CHANN *chan = NULL;

    while (!chan && (ior = (IOSTD *)GetMsg(lisport))) {
	switch(ior->io_Command) {
	case DNCMD_SOPEN:
	    chan = (CHANN *)MakeChannel(ior, NULL);
	    break;
	default:
	    ior->io_Error = 1;
	    break;
	}
	ReplyMsg((MSG *)ior);
    }
    if (lisport->mp_MsgList.lh_Head != (NODE *)&lisport->mp_MsgList.lh_Tail)
	SetSignal(1 << lisport->mp_SigBit, 1 << lisport->m              1&                                                                                                                                                                                                                                                                                                                                                                                                          
    hdioctl.c                                                                             Nd
/*
 *  DIoctl.C
 */

#include "lib.h"

void
DIoctl(_chan, cmd, val, aux)
void *_chan;
ubyte cmd;
uword val;
ubyte aux;
{
    CHANN *chan = (CHANN *)_chan;
    IOSTD ior;

    ior.io_Command = DNCMD_IOCTL;
    ior.io_Unit = (void *)chan->chan;
    ior.io_Offset = (long)chan;
    ior.io_Message.mn_ReplyPort = (PORT *)chan;
    ior.io_Data = (APTR)(long)((val<<16)|(aux<<8)|cmd);
    PutMsg(chan->dnetport, (MSG *)&ior);
    WaitMsg(&ior);
    FixSignal(chan);
}

                                   '.*                                                                                                                                                                                                                                                                                          G                A                                                                                              
    dstat.c                                                                              Gp
/*
 *  DStat.C
 */

#include "lib.h"

int
DStat(host, buffer, max)
char *host;
APTR buffer;
long max;
{
    IOSTD ior;
    char buf[sizeof(DNETPORTNAME)+32];
    PORT *replyport = CreatePort(NULL, 0);
    PORT *dnetport;

    if (!host)
	host = "0";
    sprintf(buf, "%s%s", DNETPORTNAME, host);
    if (dnetport = FindPort(buf)) {
	ior.io_Command = DNCMD_INFO;
	ior.io_Unit = 0;
	ior.io_Offset = 0;
	ior.io_Data = buffer;
	ior.io_Message.mn_ReplyPort = replyport;
	PutMsg(dnetport, (MSG              m                                                                                                                                                                                                                                                                                                                                                                                                            
    ldpri.c                                                                                  7
/*
 *  DPri.C
 */

#include "lib.h"

void
DPri(_chan, pri)
void *_chan;
{
    /*
    CHANN *chan = (CHANN *)_chan;
    */
    /* noop */
}

                                                                                                                                             D                                                                                                              
    	daccept.c                                                                              -ɭ                                                                                                                                                                                                                                                                                                                                                                                                           
    getenvval.c                                                                             [</
/*
 *  GetEnvVal.C
 */

#include "lib.h"

int
GetEnvVal(str)
char *str;
{
    char *ptr = GetDEnv(str);
    int val = 0;

    if (ptr)
	val = atoi(ptr);
    free(ptr);
    return(val);
}

                                                                                                                                                                                                                 
    vlib                                                                                       T                                                                                                                                                                                                                                                                                                                                                                                                           
    	dlisten.c                                                                              F
/*
 *  DListen.c
 */

#include "lib.h"

PORT *
DListen(portnum)
uword portnum;
{
    PORT *port = NULL;
    char *ptr;

    ptr = AllocMem(NAMELEN, MEMF_PUBLIC);   /*  memory the the name     */
    sprintf(ptr, NAMEPAT, portnum);
    Forbid();                               /*  task-atomic operation   */
    if (FindPort(ptr) || !(port = CreatePort(ptr,0)))
	FreeMem(ptr, NAMELEN);
    Permit();
    return(port);
}

                                                                            E߼                                                                                                                                                                                                                              ?  >  =  <  ;  :  9  N  M  L  K  J  I  H  F  E                                                                                                               
    lattice_dnet.lib                                                                     E$    R     NU  N]Nu       NUH0&m  K,x N+@Jg @|  "@NA "k gp + r$v   NJVD HHLN]Nu       %NUH0&m BJfH K,x N+@Jg6 @0( @ !fB/-N  PO+@`
 m|  "m,x N`A "k gp + r$v   ,x N -LN]Nu      _MakeChannel      <           NU/&m  g4+k 
,x N|/N  XOJf/N  XO,x Nv"mpN.&_N]Nu    _DNAAccept           _DeletePort       ,           DNET.POR              -.                                                                                                                                                                                                                                                                                          @                R                                                                                              
    	dopen.c                                                                              @g7
/*
 *  DOpen.C
 */

#include "lib.h"

PORT *
DOpen(host, portnum, txpri, rxpri)
char *host;
int txpri, rxpri;
uword portnum;
{
    IOSTD ior;
    CHANN *chan;

    if (!host)
	host = "0";
    chan = (CHANN *)MakeChannel(&ior, host);
    if (rxpri > 126)
	rxpri = 126;
    if (rxpri < -127)
	rxpri = -127;
    if (txpri > 126)
	txpri = 126;
    if (txpri < -127)
	txpri = -127;
    if (chan->dnetport) {
	ior.io_Command = DNCMD_OPEN;
	ior.io_Unit = (void *)portnum;
	ior.io_Offset = (long              '(                                                                                                                                                                                                                                                                                          A                                                                                                              
    	dquit.c                                                                            AѝDH
/*
 *  DQuit.C
 */

#include "lib.h"

int
DBreak(host)
char *host;
{
    char buf[sizeof(DNETPORTNAME)+32];
    PORT *dnetport;

    if (!host)
	host = "0";
    sprintf(buf, "%s%s", DNETPORTNAME, host);
    if (dnetport = FindPort(buf))
	Signal(dnetport->mp_SigTask, SIGBREAKF_CTRL_C);
}

int
DQuit(host)
char *host;
{
    IOSTD ior;
    char buf[sizeof(DNETPORTNAME)+32];
    PORT *replyport = CreatePort(NULL, 0);
    PORT *dnetport;

    if (!host)
	host = "0";
    sprintf(buf, "%s%s              /9                                                                                                                                                                                                                                                                              /  .  C  B                Y                                                                                              
    
kdnread.c                                                                             B%/
/*
 *  DNRead.C
 */

#include "lib.h"

long
DNRead(_chan, _buf, bytes)
void *_chan;
void *_buf;
long bytes;
{
    CHANN *chan = (CHANN *)_chan;
    char *buf = (char *)_buf;
    IOSTD *ior;
    int len = 0;
    long n;

    if (chan->eof)
	return(-1);
    while (bytes && ((ior = (IOSTD *)RemHead(&chan->rdylist)) || (ior = (IOSTD *)GetMsg(&chan->port)))) {
#ifdef DEBUG
	printf("IOR %08lx cmd %d len %d act %d\n", ior, ior->io_Command, ior->io_Length, ior->io_Actual);
#endif
	if (ior->              
                                                                                                                                                                                                                                                                                          6                                                                                                              
    
waitqueue.c                                                                        66$
/*
 *  WaitQueue.C
 */

#include "lib.h"

short
WaitQueue(_chan, skipior)
void *_chan;
IOSTD *skipior;
{
    CHANN *chan = (CHANN *)_chan;
    IOSTD *io;

    short error = 0;
    while (chan->queued > chan->qlen) {     /*  until done  */
	WaitPort(&chan->port);                     /*  something   */
	io = (IOSTD *)GetMsg(&chan->port);
	if (io->io_Message.mn_Node.ln_Type == NT_REPLYMSG) {
	    if (error == 0)
		error = io->io_Error;
	    if (io != skipior) {
		if (io->io_Length)
		               `                                                                                                                                                                                                                                                                                                             P                                                                                              
    P	program.c                                                                           P    
/*
 *  Program.C
 */

char *Program = "";  /*  settable by other progs     */

  --chan->queued;
	} else {
	    AddTail(&chan->rdylist, (NODE *)io);
	}
    }
    return(error);
}

                                                                                                     A                                                                                                              
    	dquit.c                                                                              &                                                                                                                                                                                                                                                                                                                                                                                                          
     	DMakefile                                                                              }rj
#   DMAKEFILE	for DNETLIB, Lattice C V5.02
#

CFLAGS	= -iprivate_include: -cimq -v
OD	= ltmp:dnet/
OBJS	= $(OD)lib_*.o
SRCS	= *.c
LIB	= lattice_dnet.lib
SYMS	= $(OD)lib.m

$(LIB) : $(SYMS) $(OBJS)
    -delete %(left)
    list LFORMAT $(OD)%s TO $(OD)list.lst $(OD)lib_#?.o
    oml %(left) r @$(OD)list.lst

$(OBJS): $(SRCS)
    lc $(CFLAGS) -H$(SYMS) -o%(left) %(right)

$(SYMS): lib.h
    lc $(CFLAGS) -ph -o%(left) syms.c

                                                                         9j                                                                                                                                                                                                                                                                                      2  1                                                                                                              
     cfg.c                                                                                1@B
/*
 *  Cfg.C
 *
 *  CONFIGURATION FILE EXTRACTION
 */

#include "lib.h"

static FILE *Fi;

int
OpenCfgFile()
{
    CloseCfgFile();
    Fi = fopen("s:dnet.config", "r");
    return (Fi != NULL);
}

char *
GetCfgLine(what)
char *what;
{
    static char Buf[128];
    register char *ptr;
    if (Fi) {
	while (fgets(Buf, sizeof(Buf), Fi)) {
	    if (BCmp(Buf, what, 4) == 0) {
		Buf[strlen(Buf)-1] = 0;
		for (ptr = Buf + 4; *ptr == ' ' || *ptr == 9; ++ptr);
		return(ptr);
	    }
	}
    }
              Y                                                                                                                                                                                                                                                                                                                                                                                                           
    	dcheckeof.c                                                                             M|I
/*
 *  DCheckEof.C
 */

#include "lib.h"


int
DCheckEof(_chan)
void *_chan;
{
    CHANN *chan = (CHANN *)_chan;
    return ((int)chan->eof);
}

("s:dnet.config", "r");
    return (Fi != NULL);
}

char *
GetCfgLine(what)
char *what;
{
    static char Buf[128];
    register char *ptr;
    if (Fi) {
	while (fgets(Buf, sizeof(Buf), Fi)) {
	    if (BCmp(Buf, what, 4) == 0) {
		Buf[strlen(Buf)-1] = 0;
		for (ptr = Buf + 4; *ptr == ' ' || *ptr == 9; ++ptr);
		return(ptr);
	    }
	}
    }
              ]                                                                                                                                                                                                                                                                                      7  5                                                                                                              
    makechannel.c                                                                        5x#c
/*
 *  MakeChannel.C
 *
 *  (internal routine)
 */

#include "lib.h"

short	DUseSignal = -1;

void *
MakeChannel(ior, host)
IOSTD *ior;
char *host;
{
    CHANN *chan = AllocMem(sizeof(CHANN), MEMF_PUBLIC|MEMF_CLEAR);

    /*	Name, Pri */
    chan->port.mp_Node.ln_Type = NT_MSGPORT;
    if (DUseSignal >= 0)
	chan->port.mp_SigBit = DUseSignal;
    else
	chan->port.mp_SigBit = AllocSignal(-1);
    chan->port.mp_SigTask = FindTask(NULL);
    NewList(&chan->port.mp_MsgList);
    NewList(              %(O                                                                                                                                                                                                                                                                                          8                7                                                                                              
    dclose.c                                                                           8u%
/*
 *  DClose.C
 */

#include "lib.h"

void
DClose(_chan)
void *_chan;
{
    CHANN *chan = (CHANN *)_chan;
    IOSTD ior;
    IOSTD *io;

    ior.io_Command = DNCMD_CLOSE;
    ior.io_Unit = (void *)chan->chan;
    ior.io_Offset = (long)chan;
    ior.io_Message.mn_ReplyPort = (PORT *)chan;
    PutMsg(chan->dnetport, (MSG *)&ior);
    ++chan->queued;
    chan->qlen = 0;
    WaitQueue(chan, &ior);
    while ((io = (IOSTD *)RemHead(&chan->rdylist)) || (io = (IOSTD *)GetMsg(&chan->port))              ~                                                                                                                                                                                                                                                                                          0                                                                                                              
    dgetioctl.c                                                                          0dG
/*
 *  DGetIoctl.C
 */

#include "lib.h"

short
DGetIoctl(_chan, pval, paux)
void *_chan;
short *pval;
char *paux;
{
    CHANN *chan = (CHANN *)_chan;
    IOSTD *ior;
    short cmd = -1;

    if ((ior = (IOSTD *)GetHead(&chan->rdylist)) || (ior = (IOSTD *)GetHead(&chan->port.mp_MsgList))) {
	if (ior->io_Command == DNCMD_IOCTL) {
	    CIOCTL *cio = (CIOCTL *)ior->io_Data;
	    cmd = cio->cmd;
	    *pval = (cio->valh << 8) | cio->vall;
	    *paux = cio->valaux;
	    Forbid();
	    Rem              +o/                                                                                                                                                                                                                                                                                                             ^                                                                                              
    lib.h                                                                               ^    x-(
/*
 *  LIB.H
 */

#include "/dnet/dnet.h"

#include "/dnet/channel.h"
#include "dnetlib.h"


if (chan->eof)
	SetSignal(1 << chan->port.mp_SigBit, 1 << chan->port.mp_SigBit);
    return(cmd);
}
                                                                                    7  5                                                                                                              
    makechannel.c                                                                          ˆ]                                                                                                                                                                                                                                                                                                                                                                                                           
    syms.c                                                                                  w
#include "lib.h"


                                                                                                                                                                                                                                                                                                                                                              
    Mlib                                                                                       ͗75                                                                                                                                                                                                                                                                                                                                                                                                          
    dread.c                                                                                
/*
 *  DRead.C
 */

#include "lib.h"

long
DRead(_chan, _buf, bytes)
void *_buf;
void *_chan;
long bytes;
{
    CHANN *chan = (CHANN *)_chan;
    char *buf = (char *)_buf;
    long len = 0;
    long n = -1;

    if (chan->eof)
	return(-1);
    while (bytes) {
	if (n == 0)
	    WaitPort(&chan->port);
	n = DNRead(chan, buf, bytes);
	if (n < 0)
	    break;
	len += n;
	buf += n;
	bytes -= n;
	if (chan->eof)
	    break;
    }
    return(len);
}

                                                     /&                                                                                                                                                                                                                                                                                                                                                                                                            
    dqueue.c                                                                                b؈
/*
 *  DQueue.c
 */

#include "lib.h"

void
DQueue(_chan, n)
void *_chan;
long n;
{
    CHANN *chan = (CHANN *)_chan;
    chan->qlen = n;
}

                                                                                                                                                                                                                                                  
    lib                                                                                       "!                                                                                                                                                                                                                                                                                                            e                                                                                              
    Ednaaccept.c                                                                        e    =
/*
 *  DNAAccept.C
 */

#include "lib.h"

int
DNAAccept(lisport)
PORT *lisport;
{
    IOSTD *ior;

    if (ior = (IOSTD *)GetMsg(lisport)) {
	ior->io_Error = 1;
	ReplyMsg((MSG *)ior);
    }
    if (lisport->mp_MsgList.lh_Head != (NODE *)&lisport->mp_MsgList.lh_Tail)
	SetSignal(1 << lisport->mp_SigBit, 1 << lisport->mp_SigBit);
    return(ior != NULL);
}
                                         
    lib                                                                                       Ӓl                                                                                                                                                                                                                                                                                                          e                                                                                              
    welog.c                                                                               ԭ+
/*
 *  elog.c
 */

#include "lib.h"

void
_elog(line, file, how, ctl, data)
int line;
char *file;
int how;
char *ctl;
void *data;
{
    static char *logfile;
    FILE *fi;

    if (logfile == NULL) {
	OpenCfgFile();
	logfile = GetCfgLine("LOGF");
	CloseCfgFile();
    }
    if (logfile && (fi = fopen(logfile, "a"))) {
	char *hdr = "?";
	switch(how) {
	case EFATAL:
	    hdr = "Fatal";
	    break;
	case EWARN:
	    hdr = "Warn";
	    break;
	case EDEBUG:
	    hdr = "Debug";
	    break;           }    PZ>
	}
	fprintf(fi, "%s %s.%s/%ld ", hdr, Program, file, line);
	fprintf(fi, ctl, data);
	putc('\n', fi);
	fclose(fi);
    }
}

                                                                                                                                                                                                                                                                              
    dqueue.c                                                                               T                                                                                                                                                                                                                                                                                                             ,                                                                                              
    	version.c                                                                          ,    4
/*
 *  Version.C
 */

#include "lib.h"

void
Version(name, ver, subver)
char *name;
char *ver;
char *subver;
{
    Write(Output(), name, strlen(name));
    Write(Output(), " V", 2);
    Write(Output(), ver, strlen(ver));
    Write(Output(), subver, strlen(subver));
    Write(Output(), "\n", 1);
}

                                                                                                 
    dqueue.c                                                                               ؓm                                                                                                                                                                                                                                                                                                            b                                                                                              
    Adeof.c                                                                             b    a
/*
 *  DEof.C
 */

#include "lib.h"

void
DEof(_chan)
void *_chan;
{
    CHANN *chan = (CHANN *)_chan;
    IOSTD ior;

    ior.io_Command = DNCMD_EOF;
    ior.io_Unit = (void *)chan->chan;
    ior.io_Offset = (long)chan;
    ior.io_Message.mn_ReplyPort = (PORT *)chan;
    PutMsg(chan->dnetport, (MSG *)&ior);
    WaitMsg(&ior);
    FixSignal(chan);
}

                                            
    
lib                                                                                                                                                                                                                                                                                                                                                                                                   G                                                                                              
    fixsignal.c                                                                      G    JHs
/*
 *  FixSignal.C
 */

#include "lib.h"

void
FixSignal(_chan)
void *_chan;
{
    CHANN *chan = (CHANN *)_chan;
    if (chan->port.mp_MsgList.lh_Head != (NODE *)&chan->port.mp_MsgList.lh_Tail ||
    chan->rdylist.lh_Head != (NODE *)&chan->rdylist.lh_Tail)
	SetSignal(1 << chan->port.mp_SigBit, 1 << chan->port.mp_SigBit);
}

                                                                       
    Klib                                                                                       ܓ8<                                                                                                                                                                                                                                                                                          3                A                                                                                              
    dexec.c                                                                              3y7|s
/*
 *  DExec.C
 *
 *  Request the DNet driver to execute a command.  Due to problems with
 *  the Lattice fork*() calls we cannot Execute() from the server process.
 */

#include "lib.h"

int
DExec(_chan, command)
void *_chan;
char *command;
{
    IOSTD ior;
    CHANN *chan = (CHANN *)_chan;
    PORT *replyport = CreatePort(NULL, 0);

    ior.io_Command = DNCMD_EXEC;
    ior.io_Unit = 0;
    ior.io_Offset = (long)command;
    ior.io_Message.mn_ReplyPort = replyport;
    PutMsg(chan-              +&m                                                                                                                                                                                                                                                                                                                                                                                                      
    fdwrite.c                                                                             BcY
/*
 *  DWrite.c
 */

#include "lib.h"

long
DQueueFull(_chan)
void *_chan;
{
    CHANN *chan = (CHANN *)_chan;

    return (chan->qlen && (chan->queued > chan->qlen));
}

long
DWrite(_chan, _buf, bytes)
void *_chan;
void *_buf;
long bytes;
{
    int error = bytes;
    CHANN *chan = (CHANN *)_chan;
    char *buf = (char *)_buf;

    if (chan->qlen) {
	if (WaitQueue(chan, NULL) >= 0) {
	    IOSTD *ior = AllocMem(sizeof(IOSTD), MEMF_CLEAR|MEMF_PUBLIC);
	    ior->io_Command = DNCMD_WRIT            LǨ@E;
	    ior->io_Unit = (void *)chan->chan;
	    ior->io_Offset = (long)chan;
	    ior->io_Message.mn_ReplyPort = (PORT *)chan;
	    ior->io_Data = AllocMem(bytes, MEMF_PUBLIC);
	    ior->io_Length = bytes;
	    BMov(buf, ior->io_Data, bytes);
	    PutMsg(chan->dnetport, (MSG *)ior);
	    ++chan->queued;
	} else {
	    error = -1;
	}
    } else {
	IOSTD ior;
	ior.io_Command = DNCMD_WRITE;
	ior.io_Unit = (void *)chan->chan;
	ior.io_Offset = (long)chan;
	ior.io_Message.mn_ReplyPort = (P               hōORT *)chan;
	ior.io_Data = (APTR)buf;
	ior.io_Length = bytes;
	PutMsg(chan->dnetport, (MSG *)&ior);
	WaitMsg(&ior);
	if (ior.io_Error)
	    error = -1;
    }
    FixSignal(chan);
    return(error);
}

s)
void *_chan;
void *_buf;
long bytes;
{
    int error = bytes;
    CHANN *chan = (CHANN *)_chan;
    char *buf = (char *)_buf;

    if (chan->qlen) {
	if (WaitQueue(chan, NULL) >= 0) {
	    IOSTD *ior = AllocMem(sizeof(IOSTD), MEMF_CLEAR|MEMF_PUBLIC);
	    ior->io_Command = DNCMD_WRIT              S                                                                                                                                                                                                                                                                              %  $  #  4                M                                                                                              
    !	dnetlib.h                                                                            49
/*
 *  DNETLIB.H
 */

#include "/version.h"

#define CHANN	struct _CHANN

#define NAMELEN sizeof("DNET.PORT.XXXXX")
#define NAMEPAT "DNET.PORT.%ld"

CHANN {
    PORT    port;	    /*	receive data, replies	    */
    PORT    *dnetport;	    /*	dnet's master port          */
    LIST    rdylist;	    /*	ready to be read	    */
    uword   chan;	    /*	channel # for open channels */
    ubyte   eof;	    /*	channel remotely closed/eof */
    ubyte   filler;
    int     qlen;	    /*	allowed              `x                                                                                                                                                                                                                                                        )  (  '  &  -  ,  +  *                Z                                                                                              
    README                                                                               *vxq
			      DNET V2.10
			    27 November 1989

	NEW THIS RELEASE:   7 bit support.

	DNET (c)Copyright 1987-1989 Matthew Dillon, All Rights Reserved

	Matthew Dillon
	891 Regal Rd
	Berkeley, Ca. 94708
	USA

	...!ihnp4!ucbvax!dillon 	USENET
	dillon@ucbvax.Berkeley.edu	ARPANET
	ucbvax.berkeley.edu pub/amiga	ARPANET-FTP

			       WHAT IS DNET

	DNet is a link protocol and should properly be called DLink, but
 the name DNet stuck and so it will stay.  DNet allows one to connect two
 amig              椃l                                                                                                                                                                                                                                                                                "  !                

                                                                                              
    INSTALLATION.info                                                                    !NӬ        b     &( &                   &h                           b                            EUUUU@        E_UU@        EVUUE        EVgG        EVggeG        EVffEG        EVfuG        E_G        ETG        EUUUUG        EuuUG        EQqUG        Euq}G        EqqG        EqqG        EqqG        Eyy}G        EAAAG        EUUUUG        EUUUUG        EUUUUG        EUUUUG        EUU@G        EUUUUG                     /        UUUUU        
                                                                                                                                                                                                                                                                                                                                                                                                
    	oINSTALLATION                                                                         (\{
			BASIC INSTALLATION AND RUN

			   --- AMIGA INSTALL ---

    The 1.3 (or greater) serial.device must be used

    The following must exist in L: and be mounted.

	L:NULL-HANDLER
	L:DPIPE-HANDLER (only required if you use the remote cli server)


    The following must exist in S:

	S:DNET.SERVERS
	S:DNET.CONFIG

    You may have to modify S:DNET.CONFIG to appropriately handle the
    CONNECT message of your modem.

    If you do not have a logical DNET: assignment where the serve              ꒁd                                                                                                                                                                                                                                                                                                  

                                                                                              
    
AREQUIREMENTS.info                                                                         > b     ' '`                  L &           3                 b   Ƙ                         EUUUU@        E_UU@        EVUUE        EVgG        EVggeG        EVffEG        EVfuG        E_G        ETG        EUUUUG        EuuUG        EQqUG        Euq}G        EqqG        EqqG        EqqG        Eyy}G        EAAAG        EUUUUG        EUUUUG        EUUUUG        EUUUUG        EUU@G        EUUUUG                     /        UUUUU              bgp                                                                                                                                                                                                                                                                                                             5                                                                                              
    
.info                                                                               5    d%VL   
    INSTALLATION
REQUIREMENTS
README
doc
                                                                :c/MuchMore   7UUUU~  7  7UUUU~  7  7  7_  7  0           *UUUUU                                                 UUUG              UUUUG          *UUUUG          UUUUG          UUUUG                           y                                                                                                                                                                                                                                                                                                                                                                                                          
    c                                                                                         U                                                                                                                                                                                                                                                                                                                                                                                                           
    
.DistFiles                                                                              ]
root:altc/noreq

                                                                                                                                                                                                                                                                                                                                                                       
    	oINSTALLATION                                                                            P\                                                                                                                                                                                                                                                                                                                                                                                                    
    Rnoreq                                                                                y]                            N NU  BN`XO)@m  o  lB Hx Hz 8N/ NO `" l!| Hx Hz 'N/ NO N]NuDOS requesters on
 DOS requesters off
  NU  N]NuapCEf2< kt "Q)O,x )NH瀀. )gK N`B_NsC  Nh)@f.< N`N PONudos.library I  NuNU  /
Hy   0, / N:)@POfBHy   NPO.lNu lBh  l1|   l1|  
 l , P)@" l" MANXBN$@J XOg./- /- /
N 9| & l h   l h  
O `BHj \N                                                                                                                                                                                                                                                                                                                                                                                                                       
    ul                                                                                         U+                                                                                                                                                                                                                                                                                                                                                                                      
     Pdpipe-handler                                                                        ]                     d       NUH0NrB
BB)x BNXO+@/-NXO$@ * +@ m"m   \!I BHx/-/
NJO | J-g /-NxXO$@%| B +j &j  -` BmBm+|   B;|Bm * .  * *  Ep / Hl ER/NO  Ep A쀒B0 HzNHlN\POJfL j +h  mJ g" m (  @&h $  +|  ` &m  +|  ` A쀒*`   E /f   EBR`   E Sf+|   E Mf+|   E c E qf;|  E nf+| E tf              E bf, ER/NXO+@JlBo+| E sf ER/NXO;@ j +h R EJf P`
R EJf 0&m`Hl/+ NPOJg&S f f  Jmf  Hy  Hx 6NXPO&@Hy  Hx 6NFPO( HlBHlNBXOR/ N*PO/ N PO'@ 'D 0-k  D!|    ,'|    , D!|    ('|    ( D!K  D0-H  h /HmN	0PO  f&k Jmg k Jh fB %|    `  Rk 'm 07m 4 k !m , k  -!@ ( k 0-h  k     (l
 k !m (  f   k    G!K $ G!| J fJ gJ            I] 0g0+ 4Hr//+ 0NhPO/-/
NPO` 2Sk  j "h  0fB 0Jk f  +  g
 k   /-/+ NPO k (  gl k Jh fb(+   g(+ /NXO D/( N
XOR/  D/( NPO/NXO D/( NXOHx 6 D/( NtPOHx 6/NhPO/-/
NPO` l  B / KP/NPO/-/NPO` DB +  g %| %|    /-/
NPO` / k Hh NPO/-/+ NPO` Hx N8XO( Hx / * / NO B / /-/
NjO `  * * A&H EHH E0 : gB&m`8/+ N	VXO EHHf  EHH/             9Gd>/+  ER/N	O Jg&S f gNHx NXO(  D!K  D!j   D"m   \!I  D -!@ B / /-/
NO `Hx B/-/
NO ` J g * / NPXOBHx/-/
NrO `  * (  * * Hx/NPO D"E" &h Af E!|    Hz EHh 	N4PO`, E!| /+  EHh 	NPO E"k  ) $Ы $!@ | EHh 	N
XO E@ BHx/-/
NO `   * (  D*Af*-` E*Jg   D!|  E/(  DHh 	NPO DB t D"E,i "E . $Щ $!@ | DB  DB(  D  DHh 	NtXO D@  DHh NbXO D@ BHx            @9D/-/
N(O `Hx B/-/
NO `bHx B/-/
NO `LQg _g VYg HYg vSg    :g [g ސ  g Sg Sg Sg `` hJg
/,NXON/-NXOJgN` 8 mB NLN]Nu* PIPE: NU  /
X Hy  /- N\PO$@$  
X$_N]NuNU  /
$m  
g/* JY/N\PO$_N]NuNUH0$m +j g  ** g   m&h 
,+   E"E.(  o./ + Ы /  E"h Hi NO ߫  +  f/-N@XO/- /NjPO Eߨ "E (  f, E%P J fB   E (  $ E"h Hi /NPO` H            bm * $ (l  +j g  +j g   m&h 
 m(( 
,+   D"D.(  o./ + Ы /  D"D ( Щ / NO  Dߨ "D (  f/-NfXO/- /NPO߫  +  f/-NBXO/- /NlPO` R0* H   $   fL+j g</-NXO m&h 
J 0gJ f'| '|    /- /NPO`LN]NuJ 0gDJ g0* 4Hr//* 0NPO+j g /-NXO m&h 
/- /NPO`+j g  *  f   m(( 
 D"D.(   * $Ї ,o
  `  B GHh NPO* Jgl/ EHh  D"D ( Щ / NO  EB E!G  EB            ki~ J  g j   %E  `%E  %E  Dߨ /-N XO/- /NPOߪ $` D*  g,+j g$ m&h 
J g/-N XO/- /N PO` NU  H 0$m &m Jg$R`$'J BL N]NuNU  H0$m &j `( k Hh /NPO&D fB  B LN]NuNU  H 0$m &m &'J $Jg S!K  L N]NuNU  /
$m  
gJg R!j   j  BB  
$_N]NuI  NuNU   m /(  m /( /- /- aO N]NuNU  H0$m %m  %m  (* &R m    \%H 'J 
BB //N2POLN]NuNU  H 0$m    \/
N.XO/
NXO&@ + 
L N]NuNU   m "h pJ            'Nfp N]Nup`r `/  o  /    (c`QNuH?>$  gS   $BB4HB&(*,."B$B&B(B*B,Br0kH?~jA2< Ak!AjA`QL|NuL   / g  ct2  fZ2	  fR  e&"  ,iH?>p,`
L|H?>QHA0L|2 `# # Q   d0   fNu Q   dNu2  fZ2	  fR  e&"  ,iH?>p,`
L|H|QHA0L|2 `""Q   d0   fNuQ   dNu o  "o fNu o  Jf SNuNU  H $m   g 	fR`z  -fzR` +fRx `  JR        	    ysHHr
/  N d"Ҁ(   0HHA0  fJg D` L0N]Nu0<`0/ S@k o "o 	fSHJWp NucpNupNuHp 4&HCHCBCԃH@H@B@ЂL NuN "o ,lNbN L  ,lN:N "o ,lNN ,lN|N "o  / ,lN.N  o ,lN,lNvL  ,lN"o  / ,lNN  o ,lN            ~         __H0_org       __whocareswhatthisisnamed          _AllocDS  L   _FreeDS   v   _attemptread     _llinkend        _freepbufs       _llink    "        
    04   _lunlink  N   _mygeta4  |   _returnpktplain      _returnpkt       _taskwait        _taskpktrdy   "   _BZero    <   _BSet     @   _BMov        _strcpy      _strlen      _atoi        _strcmp   Z   _strncmp  `   .mulu        _CloseLibrary        __CloseLibrary       _AllocMem        __AllocMem       _FindTask        __FindTask       _Forbid      __Forbid     _FreeMem     __FreeMem        _GetMsg       __GetMsg                pc   _Permit      _PutMsg      _Signal   &   _WaitPort     6   __WaitPort    :   __H0_end  H           $                      00000                  @@@@@@@@@@@@@@@@@@@@@@						@@@@@@





@@@@         __H1_org       _SysBase       _DOSBase      _Fh       _ctp_         __H1_end      __H2_org      _Buf      __H2_end               read     _llinkend        _freepbufs       _llink    "                                                                                                                                                                                                                                                                                                                                                                                                                        
     null-handler                                                                         B                              NnNU   m /(  m /( /- /- aO N]NuNU m !m   m !m   m +h  m +P m "m    \!I  m!m  
 mB mB /-/-NPON]NuNU m    \+H/-NpXO/-NHXO+@ m ( 
N]NuNUA+H+|   BBNXO)@/,NXO+@ m ( +@ m"l   \!I  m/( Hx/,/-NO Jg /,NNXO+@ m ( `  R m ( +@ m"m#h  $ mB  m/( Hx/,/-NO `   m/( B/,/-NxO `   m                                                                                                                                                                                                                                                                                                                           +                                                                                              
    D
.DistFiles                                                                          +    YT:
root:l/dpipe-handler
root:l/null-handler

Hx/,/-N0O `<Hx B/,/-NO `$   Rg |[g  g &Sg  Sg``  mB N]NuVer 0.0 (c) Gunnar Nordmark 1988  apCEf2< kt "Q)O,x )NH瀀. )gK N`B_NsC  Nh)@f.< N`NPONudos.library I  NuN "o ,lNN  o ,lNL  ,lNN  o ,lN                                                                                                                     b>#                                                                                                                                                                                                                                             
  	                  +t                                                                                              
    @nfs-handler                                                                          t                   v      D   %   ,   U          7  ,         vNUH78I    p )@l0| )PLC  ,x N)@PN)@@Bp @ \N l@ \N @+h 
+@JPg  "lP i " ( Hx ,+@a XO m"( )AD"l@$I \"lD#J )@Hr"@#A $l@ \#J #|DOS   $lD#j ( ($m" +@%@ p!@ p !@ ` mB /a ` /-a HlTNHl`NHx 4HltNO A",lPN@9| A )H|Jg  l@ \,x N l@ \,x N+@Jg @+h 
p m!@ B ~ Jpf p/ / Hx 
BN              Fΰ                                                                                                                                                                                                                                                                                                  

                                                                                              
    README.info                                                                          9        b     ' '                  L 'x                           b   (                         EUUUU@        E_UU@        EVUUE        EVgG        EVggeG        EVffEG        EVfuG        E_G        ETG        EUUUUG        EuuUG        EQqUG        Euq}G        EqqG        EqqG        EqqG        Eyy}G        EAAAG        EUUUUG        EUUUUG        EUUUUG        EUUUUG        EUU@G        EUUUUG                     /        UUUUU                 &Ц                                                                                                                                                                                 "                      $  &                                                              (                                                                                                                  
    
server                                                           *                       	]                                                                                                                                                                                                                                                                                        	              Q                                                                                              
    snfs.h                                                           
                  e
#define ulong unsigned long
#define ubyte unsigned char
#define uword unsigned short

typedef struct {
    long    ds_Days;
    long    ds_Minute;
    long    ds_Tick;
} STAMP;

typedef struct {
    long    DirHandle;		/*  relative to directory (0=root)  */
    uword   Modes;		/*  open modes			    */
} OpOpen;

typedef struct {
    long    Handle;
    ulong   Prot;
    long    Type;
    long    Size;
    STAMP   Date;
} RtOpen;


typedef struct {
    long    Handle; 	/*  file handle     
         7                                                                                                                                                                                                                                                                                                             Z                                                                                              
    
TODO                                                                          
      Z    mQms
    SMAIL server
    SPASSWD server

    * automatic compression for SCOPY and SGCOPY




} OpRename;

typedef struct {
    long    Error;
} RtRename;

;

typedef struct {
    long   Handle; 	/*  file handle to read from	    */
    long    Bytes;		/*  # of bytes to read		    */
} OpWrite;

typedef struct {
    long    Bytes;		/*  < 0 == error		    */
} RtWrite;

typedef struct {
    long    Handle;
} OpClose;

typedef struct {
    long    Handle;
    long    Offset;
    long    How;              T                                                                                                                                                                                                                                                                                                                                                                                              
    	spasswd.c                                                                            #
/*
 *  SPASSWD.C
 *
 *  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
 *
 *  PASSWORD SERVER
 *
 *  user-password entry.  USER entries in s:dnet.config are scanned for
 *  a match and the various dnet enviroment variables are set accordingly.
 */

#include "defs.h"

int do_password ARGS((void *));
void DPuts ARGS((void *, char *));
int DGetLine ARGS((void *, char *, short));

int
brk()
{
    return(0);
}

void
#ifdef LATTICE
_main(str)
#else
_main(len,str)
#endif
char        
                                                                                                                                                                                                                                                                                                H                                                                                              
    \scopy.c                                                                              d?
/*
 *  SCOPY.C	V1.1
 *
 *  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
 *
 *  COPY SERVER FOR PUTFILES (DOWNLOADS, i.e. receives files)
 *
 *  The current version only accepts one connection at a time.	This server
 *  handles downloading of data.  This server will eventually be replaced
 *  by the SGCOPY server.  Currently the SGCOPY server only handles
 *  uploads.
 *
 *  NOTE:   The DNET_WRITE enviroment variable must be 9 or higher or this
 *	    server will refu              Q                                                                                                                                                                                                                                                                                                          |                                                                                              
    	servers.h                                                                            Q
/*
 *  SERVERS.H
 *
 *  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
 *
 */

#include "/version.h"

#define PORT_FILECOPY	8192
#define PORT_ALPHATERM	8193
#define PORT_ECHO	8194
#define PORT_IALPHATERM 8195
#define PORT_AMIGASHELL 8196
#define PORT_LOADAV	8197
#define PORT_PRINTER	8198
#define PORT_PASSWD	8199
#define PORT_BBS	8200
#define PORT_GFILECOPY	8201
#define PORT_NFS	8202

#define DNET_WRITE  "DNET_WRITE"
#define DNET_READ   "DNET_READ"
#define DNET_LEVEL  "              q                                                                                                                                                                                                                                                                                                          W                                                                                              
    T	DMakefile                                                                            /(
#	DNET SERVERS
#
#  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
#
#   Lattice C

CFLAGS	= -iprivate_include: -cim -v
BIN	= /bin/
OD	= ltmp:dnet/
SRCS	= sgcopy.c scopy.c spasswd.c sprint.c sterm.c
OBJS	= $(SRCS:"*.c":"$(OD)*.o")
BINS	= $(SRCS:"*.c":"$(BIN)*")
SYMS	= $(OD)server.m

all: $(SYMS) $(BINS)

$(BINS) : $(OBJS)
    blink FROM LIB:c.o %(right) LIB /lib/lattice_dnet.lib LIB:sup32.lib LIB:amiga.lib LIB:lc.lib TO %(left)

$(OBJS) : $(SRCS)
    lc $(CFLAGS) -H$(S              %                                                                                                                                                                                                                                                                                                                                                                          
    Tsgcopy.c                                                                             %>
/*
 *  SGCOPY.C	 V1.1
 *
 *  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
 *
 *  GET-COPY SERVER	(NEW COPY SERVER)
 *
 *  The current version only accepts one connection at a time.	This server
 *  will send requested files to the remote machine.
 *
 *  length in 68000 longword format.
 *
 *  ACCESS RESTRICTIONS:
 *
 *	Remote access restrictions are according to DNET_GROUP or DNET_READ
 *
 *	DNET_READ >= 9	    Full Access
 *	DNET_READ <  9	    According to comment fie            {uld (AC=n) or group acc.
 *			    (GR=n) matches DNET_GROUP)
 *
 *	When searching for access rights, the comment field of the file/dir
 *	requested is checked first.  If empty, the parent dir is checked.
 *	This continues (parent diring) until root is found or a comment
 *	field with access info in it.
 */

#include "defs.h"

typedef struct {
    char    Cmd;
    char    Str[64];
    long    Val;
} HDR;

extern int Enable_Abort;
char Buf[8192];
void *Chan;

void SGCopy ARGS((void));
i            d"nt PutObject ARGS((char *));
int PutDir ARGS((char *, int));
int PutFile ARGS((char *, int));
int WriteHeader ARGS((char, char *, long));
int ReadHeader ARGS((HDR *));

int
brk()
{
    return(0);
}

void
#ifdef LATTICE
_main(str)
#else
_main(len,str)
#endif
char *str;
{
    struct MsgPort *port;
    PROC    *myproc = (PROC *)FindTask(NULL);
    long    savedir;
    long    mask, rmask;

    onbreak(brk);

    if (strncmp(str, "__dnet", 6) != 0) {
	Version("SGCopy", VERSION, SGCOPY_VE            CRSION);
	_exit(0);
    }

    port = DListen(PORT_GFILECOPY);
    WaitPort(&myproc->pr_MsgPort);
    ReplyMsg(GetMsg(&myproc->pr_MsgPort));
    savedir = Lock("", SHARED_LOCK);   /* duplicate current dir    */
    if (!savedir) {
	DUnListen(port);
	_exit(1);
    }
    savedir = CurrentDir(savedir);              /* CD dup, returns original */
    mask = SIGBREAKF_CTRL_C|(1 << port->mp_SigBit);
    for (;;) {
	long dupdir = DupLock(myproc->pr_CurrentDir);
	rmask = Wait(mask);
	if (rmas            7"k & SIGBREAKF_CTRL_C) {
	    UnLock(CurrentDir(dupdir));
	    break;
	}
	while (Chan = DAccept(port)) {
	    SGCopy();
	    DClose(Chan);
	}
	UnLock(CurrentDir(dupdir));
    }
    UnLock(CurrentDir(savedir));                /* restore original         */
    DUnListen(port);
}

void
SGCopy()
{
    short error;
    static HDR Hdr;

    error = WriteHeader('H', "Hello, GCopy server V1.30", 0);
    if (error)
	return;
    switch(ReadHeader(&Hdr)) {
    case -1:
	return;
    case 'H':
	b            reak;
    }
    while (!error) {
	switch(ReadHeader(&Hdr)) {
	case 'G':
	    error = PutObject(Hdr.Str);
	    break;
	case 'E':
	    goto done;
	case 'P':   /*  put-files, not implemented  */
	default:
	    error = 1;
	    break;
	}
    }
done:
    ;
}

int
PutObject(str)
char *str;
{
    long lock;
    FIB *fib = malloc(sizeof(FIB));
    short error = 0;
    short access = GetEnvVal(DNET_READ);
    short group  = GetEnvVal(DNET_GROUP);

    mountrequest(0);
    lock = Lock(str, SHAR            2ED_LOCK);
    mountrequest(1);
    if (lock == NULL || !Examine(lock, fib)) {     /*  unable to find it!  */
	error = WriteHeader('N', "Unable to find object", 0);
	goto done;
    }

    /*
     *	Determine Access rights
     *
     *	If the file/dir or any parent dir has AC > your_ac, access is
     *	denied.  If the file/dir and all parent dirs have neither an ACcess
     *	or GRoup entry, access is denied.  If a group entry is found that
     *	matches your group, access is allowe            / d (unless an AC is found > your_ac)
     *
     *	If your_ac is >= 9, no access checking of parent directories is
     *	done at all.  However, access checking of downloaded files will
     *	be done, and any AC values > your_ac will be disalloweds.
     */

    if (access < 9) {           /*  must check comment/access   */
	short ok = 0;
	long lock2 = DupLock(lock);
	long tmp;
	for (;;) {
	    short ac = 0;

	    while (ac >= 0) {       /*  check groups    */
		short idx = 0;
		ac =        	     ExtractFieldVal(fib->fib_Comment, FS_GROUP, &idx);
		if (ac >= 0 && ac == group) {
		    ok = 1;
		    break;
		}
	    }
	    ac = ExtractFieldVal(fib->fib_Comment, FS_ACCESS, NULL);
	    if (ac >= 0) {                  /*  valid access field      */
		if (ac <= access) {         /*  access ok               */
		    ok = 1;
		} else {		    /*	access not ok		*/
		    ok = 0;
		    break;
		}
	    }
	    if (tmp = ParentDir(lock2)) {   /*  check the par.dir */
		UnLock(lock2);
		lock2        
    Xw`* = tmp;
		fib->fib_Comment[0] = 0;
		Examine(lock2, fib);
		continue;
	    }
	    break;
	}
	UnLock(lock2);
	if (!ok) {
	    error = WriteHeader('N', "Access Violation", 0);
	    goto done;
	}
    }
    Examine(lock, fib);
    UnLock(lock);
    lock = NULL;
    if (fib->fib_DirEntryType > 0) {
	error = PutDir(str, access);
    } else {
	error = PutFile(str, access);
    }
done:
    if (lock)
	UnLock(lock);
    free(fib);
    return((int)error);
}

int
PutDir(name, access)
char *name;            ۞

int access;
{
    long lock = Lock(name, SHARED_LOCK);
    FIB *fib = malloc(sizeof(FIB));
    static HDR Hdr;
    short error = 0;
    short ac;

    if (!lock || !Examine(lock, fib)) {
	WriteHeader('N', "Possible Disk Error", 0);
	error = 1;
	goto done;
    }

    ac = ExtractFieldVal(fib->fib_Comment, FS_ACCESS, NULL);
    if (ac >= 0 && ac > access) {
	error = WriteHeader('S', fib->fib_FileName, 0);
	goto done;
    }

    if (error = WriteHeader('D', fib->fib_FileName, 0))
	goto               !]                                                                                                                                                                                                                                                                                               !               +                                                                                              
    syms.c                                                                               +    q 
/*
 *  SYMS.C
 *
 */

#include "defs.h"


    if (DRead(Chan, &cmd, 1) != 1)
	return(-1);
    if (DRead(Chan, &sl, 1) != 1)
	return(-1);
    if (sl >= sizeof(hdr->Str)) {
	return(-1);
    }
    if (DRead(Chan, hdr->Str, sl) != sl)
	return(-1);
    hdr->Str[sl] = 0;
    if (DRead(Chan, &hdr->Val, 4) != 4)
	return(-1);
    hdr->Cmd = cmd;
    return((int)hdr->Cmd);
}


led! */
	    error = 10;
	    goto done;
	}
	if (DWrite(Chan, Buf, n) != n) {
	    error = 10;
	    goto done;
	}
	le     "         #                                                                                                                                                                                                                                                                    #                                                                                                            
    sterm.c                                                                       "       Xc
/*
 *  S_TERM.C
 *
 *  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
 *
 *  Terminal window server.
 *	-Echo what is received in the window.
 *	-Transmit stuff typed on keyboard, echoing locally.
 *
 *  Use FTERM on the other Amiga to connect.
 *
 *  NOTE!!!!  Spawned tasks are ... TASKS, not processes.  No DOS calls
 *  allowed.
 */

#include "defs.h"

int NHandlers;

struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;

PORT *HdPort;
PORT *LisPort;
short Ha     $         %+                                                                                                                                                                                                                                                                                          %              v                                                                                              
    	3sprint.c                                                                      $       z
/*
 *  SPRINT.C
 *
 *  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
 *
 *  PRINTER SERVER
 *
 *  Accepting one connection at a time, dump the file to PRT:
 *
 *  DNET_WRITE	must be 6 or higher for this function to work.
 */

#include "defs.h"

void printfile ARGS((void *));

int
brk()
{
    return(0);
}

void
#ifdef LATTICE
_main(str)
#else
_main(len,str)
#endif
char *str;
{
    PORT    *port;
    PROC    *myproc = (PROC *)FindTask(NULL);
    void    *chan;
    long      &         'lt                                                                                                                                                                                                                                                                                            '              8                                                                                              
    	defs.h                                                                        &       H
/*
 *  DEFS.H
 */

#define NOEXT

#include <exec/types.h>
#include <proto/all.h>
#include <devices/conunit.h>
#include <intuition/intuition.h>
#include <dos.h>

#include "/dnet/dnet.h"
#include "/dnet/channel.h"
#include "/lib/dnetlib.h"
#include "/server/servers.h"

typedef struct IntuiMessage IMESS;
typedef struct IntuiText    ITEXT;
typedef struct Menu	    MENU;
typedef struct MenuItem     ITEM;
typedef struct TextAttr     TA;
typedef struct TextFont     FONT;
typedef struct Libr     (         )]                                                                                                                                                                                                                                                                                    )                                                                                                            
    
uscli.c                                                                        (       ʈLe
/*
 *  SCLI.C
 *
 *  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
 *
 *  SHELL SERVER.   THIS REQUIRES MY PIPE DEVICE TO WORK!!!!!!!!!!
 *
 *  Port #8196
 *
 *  Only one connection accepted at a time in this baby.
 *  HUGE CLUDGE!!!
 *
 *  DNET_LEVEL must be 9 or higher.
 */

#include "defs.h"

char Buf[4096];

int
brk()
{
    return(0);
}

void
#ifdef LATTICE
_main(str)
#else
_main(len,str)
#endif
char *str;
{
    struct MsgPort *port;
    PROC    *proc = (PROC *)Fi     *            -A                          +              -                  /  1                                      3                  5                                              8                                          :                          <  >                                                                                                                                                  
    client                                                                           +         ,                                                                                                                                                                                                                                                                                            ,                                                                                                            
    C
statdnet.c                                                           *         +       H
/*
 *  STATDNET.C
 *
 *  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
 *
 *  STATDNET [-Nnet]
 *
 */

#include "defs.h"

void main ARGS((int, char **));

char buf[2048];

int
brk()
{
    return(0);
}

void
main(ac,av)
char *av[];
{
    int ok;
    char *host = NULL;

    printf("StatDNet V%s%s\n", VERSION, STATDNET_VERSION);
    onbreak(brk);

    {
	short i;
	for (i = 1; i < ac; ++i) {
	    if (strncmp(av[i], "-N", 2) == 0) {
		host = av[i] + 2;
		continue;
	    }
	     -         . T                                                                                                                                                                                                                                                            .              "G                                                                                              
     
getfiles.c                                                           *         -       3
/*
 *  GETFILES.C	    V1.30
 *
 *  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
 *
 *
 *  GETFILES [-Nnetid] [-dlocaldir] [-c] file/dir file/dir file/dir
 *
 *  -Nnetid	network identifier
 *
 *  -dlocaldir	local directory to place files
 *
 *  -c		Continue from where you left off before.  Files that already
 *		exist on the local machine will not be re-transfered.  This
 *		will also re-start in the middle of a file that was
 *		partially transfered previously.
 *
 *     /         0rW                                                                                                                                                                                                                                                                                0                                                                                                            
    e
putfiles.c                                                           *         /       h,)
/*
 *  PUTFILES.C
 *
 *  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
 *
 *  Upload one or more files or directories to the remote host
 */

#include "defs.h"

char Buf[1024];

int putname ARGS((void *, char *));
int putfile ARGS((void *, char *, char *));
int writehdr ARGS((void *, ubyte, char *, long));

void main ARGS((int, char **));

int
brk()
{
    return(0);
}

void
main(ac,av)
char *av[];
{
    void *chan;
    short i;
    char fn = 0;
    char *host = NULL;
     1         201                                                                                                                                                                                                                                                                      2              S                                                                                              
    :loadav.c                                                             *         1       q!{
/*
 *  LOADAV.C
 *
 *  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
 *
 *  LOADAV  [frequency]     Connect to remote UNIX system and display
 *			    load average.  Default is every 5 minutes.
 *
 *  frequency in seconds, default is every 60 seconds
 *
 */

#include "defs.h"
#include <local/deemu.h>

int __stdargs CXBRK(void);

short Deemu[] = {
    DMSTRT, 0, 0,
    DMNW  , 0, 10, 2, 2, -80, 40, 0xFFFF,
    DMEND , 0, 0
};

#define DMNWOFF 4

#define NA  0
#define G     3         4+ݺ                                                                                                                                                                                                                    ~                                    4              %                                                                                              
    fterm.c                                                              *         3       
/*
 *  FTERM.C
 *
 *  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
 *
 *  FTERM [-Nnet] [port] [-wcapturefile] [-c#]
 *
 *  -c# = cooked mode.	i.e. -c7    bit 0   convert CR's to LF's keyboard->remote
 *				    bit 1   echo chars locally (half duplex)
 *				    bit 2   received LF->CRLF
 */

#include "defs.h"
#include <local/deemu.h>

short Deemu[] = {
    DMSTRT, 0, 0,
    DMNW  , 0,10, 11, 11, -37, -28, 0xFFFF,
    DMTEXT, 0,30, 'FO','NT','\0t','op','az','.f','on',     5         6                                                                                                                                                                                                                                                                                          7  6              t                                                                                              
    	DMakefile                                                            *         5       7{
#	DNET CLIENTS
#
#  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
#
#   Lattice C

CFLAGS	= -iprivate_include: -cimq -v
BIN	= /bin/
OD	= ltmp:dnet/
SRCS	= cliterm.c fterm.c getfiles.c loadav.c putfiles.c statdnet.c quitdnet.c
OBJS	= $(SRCS:"*.c":"$(OD)*.o")
BINS	= $(SRCS:"*.c":"$(BIN)*")
SYMS	= $(OD)client.m

all: $(SYMS) $(BINS)

$(BINS) : $(OBJS)
    blink FROM LIB:c.o %(right) LIB /lib/lattice_dnet.lib LIB:sup32.lib LIB:lc.lib LIB:amiga.lib TO %(left)

$(OBJS) : $(     5          Q[5$SRCS)
    lc $(CFLAGS) -H$(SYMS) -o%(left) %(right)

clean:
    -delete $(OD)#?.o

$(SYMS) : defs.h
    lc $(CFLAGS) -ph -o%(left) syms.c


                                                                                                                          2              S                                                                                              
    :loadav.c                                                             *         8         9]o                                                                                                                                                                                                                                                                                              9               +                                                                                              
    *syms.c                                                               *         8      +    ,
/*
 *  SYMS.C
 *
 */

#include "defs.h"


%(right)

clean:
    -delete $(OD)#?.o

$(SYMS) : defs.h
    lc $(CFLAGS) -ph -o%(left) syms.c


                                                                                                                          2              S                                                                                              
    :loadav.c                                                             *         :         ;m                                                                                                                                                                                                                                                                                            ;                                                                                                            
    defs.h                                                               *         :       H
/*
 *  DEFS.H
 */

#define NOEXT

#include <exec/types.h>
#include <proto/all.h>
#include <devices/conunit.h>
#include <intuition/intuition.h>
#include <dos.h>

#include "/dnet/dnet.h"
#include "/dnet/channel.h"
#include "/lib/dnetlib.h"
#include "/server/servers.h"

typedef struct IntuiMessage IMESS;
typedef struct IntuiText    ITEXT;
typedef struct Menu	    MENU;
typedef struct MenuItem     ITEM;
typedef struct TextAttr     TA;
typedef struct TextFont     FONT;
typedef struct Libr     <         ==                                                                                                                                                                                                                                                                                            =              q                                                                                              
    "
quitdnet.c                                                           *         <       xK
/*
 *  QUITDNET.C
 *
 *  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
 *
 *  QUITDNET [-Nnet]
 *
 */

#include "defs.h"

void main ARGS((int, char **));

int
brk()
{
    return(0);
}

void
main(ac,av)
char *av[];
{
    int ok;
    char *host = NULL;

    onbreak(brk);
    printf("QuitDNet V%s%s\n", VERSION, QUITDNET_VERSION);
    {
	short i;
	for (i = 1; i < ac; ++i) {
	    if (strncmp(av[i], "-N", 2) == 0) {
		host = av[i] + 2;
		continue;
	    }
	}
    }
    ok = D     >         ?SӮ                                                                                                                                                                                                                              {  z  y  x  w  v  u  t  s                ?                                                                                                            
    !	cliterm.c                                                            *         >       Tk
/*
 *  CLITERM.C
 *
 *  DNET (c)Copyright 1988-1989, Matthew Dillon, All Rights Reserved.
 *
 *  FTERM [-Nnet] [port]
 */

#include "defs.h"

typedef struct IORequest RIO;


#ifndef DEVICES_CONUNIT_H
typedef struct ConUnit	    CONUNIT;
typedef struct IOStdReq     IOCON;
#endif

short IgnoreNS = 0;

TA Ta = { (ubyte *)"topaz", 8 };

ITEXT IText[] = {
    { 0, 1, JAM2, 0, 0, &Ta, (ubyte *)"Flush"          }
};

ITEM Item[] = {
    { NULL    , 0, 0, 100, 10, ITEMTEXT|COMMSEQ|ITEMENABLE     @            r                                                                                  A                                                                                                                                                                                                                                                                                                                          
    wdevs                                                                             A         B                                                                                                                                                                                                                                                                                              B                                                                                                             
    	Mountlist                                                            @         A          
DPIPE:	Handler = l:dpipe-handler
	Stacksize = 6000
	Priority = 5
	GlobVec  = 1
#

NULL:	   Handler = L:null-handler
	   Stacksize = 500
	   Priority = 5
	   GlobVec = 1
#

                                                                                                               =              q                                                                                              
    "
quitdnet.c                                                           *         C            n                                                                                                                          D                              F                  H              J                                                                                                                                                                                                              
    s                                                                                D         E/6                                                                                                                                                                                                                                                                                              E               L                                                                                              
    remote-startup                                                       C         D      L    @Bexecute s:shell-startup
noreq
prompt "%N.%S> "
echo "Remote CLI with shell"
                                                                                                                                                  {  z  y  x  w  v  u  t  s                ?                                                                                                            
    !	cliterm.c                                                            *         F         Gm                                                                                                                                                                                                                                                                                  h  }  |  G                                                                                                            
    Fdnet.config                                                          C         F       |
LOGF ram:dnet.log

# Commands to set the baud rate, determined by messages that occur
# before carrier detect.  Only scanned if -a option used

AUTA 19200  "CONNECT"
AUTA 300    "CONNECT 300"
AUTA 1200   "CONNECT 1200"
AUTA 2400   "CONNECT 2400"
AUTA 9600   "CONNECT 9600"
AUTA 19200  "CONNECT 19200"

# Commands to Reset the Modem.	Only scanned if -a option used

RESM AT
RESM AT
RESM ATS0=2
DISM +++

# Auto-Reset enviroment variable security level to this (DNET_LEVEL)
#
#   The defau     H         I\                                                                                                                                                                                                                                                                                              I               0                                                                                              
    
.DistFiles                                                           C         H      0    }/
s:dnet.config
s:dnet.servers
s:remote-startup

.log
BMEN	dnet:bbs/menu.ctl
BMSG	dnet:bbs/message.ctl
BFIL	dnet:bbs/file.ctl
BUSR	dnet:bbs/userinfo.ctl

#   SPASSWD server

USER	dillon	pineapple   9 9 9
USER	bounce	-	    0 0 0

 enviroment
# ENVM	-manual (no -a) option enviroment
#
#   LEVEL   overall access rights
#   READ    basic access rights for reading files from this machine
#   WRITE   basic access rights for writing files to this machine

ENVA DNET_LEVEL     9
ENVA DNET_READ     J         KH                                                                                                                                                                                                                                                                                              K                                                                                                            
    dnet.servers                                                         C         J         Eܩ
8192	dnet:amiga/bin/scopy	ram:	;File Transfer server
8195	dnet:amiga/bin/sterm	ram:	;Terminal Window server
8196	dnet:amiga/bin/scli	ram:	;Shell Server (needs pipe:)
8197	dnet:amiga/bin/sloadav	ram:	;Load Average Server
8198	dnet:amiga/bin/sprint	ram:	;Printer Server (direct copy)
8199	dnet:amiga/bin/spasswd	ram:	;Password Server
; 8200 reserved for BBS server, handled by dbbs client&server program
8201	dnet:amiga/bin/sgcopy	ram:	;GET files server

                        C         L            (5  M                          O              Q              S                  U                  W                                              [      ]              _  a  h          j  l                                  n      p                                      r                                                                                                                  
    doc                                                                              M         N*×D                                                                                                                                                                                                                                                                                              N                                                                                                             
    
config.doc                                                           L         M          (

    config <executable>

    config fterm

    The 'config' program may be used to set the default window size and
    font for the FTERM program.  The only argument is the path to an
    executable, usually one of my programs that opens windows.



                                  I               0                                                                                              
    
.DistFiles                                                           C         O         Pbh                                                                                                                                                                                                                                                                                              P               6                                                                                              
    !.info                                                                L         O      6    L   
    (dnetlib.doc
dnet.doc
organization.doc
                                                                    D                              F                  H              J                                                                                                                                                                                                              
    s                                                                                Q         R .                                                                                                                                                                                                                                                                                  q  p  o  R                                                                                                            
    	fterm.doc                                                            L         Q       oہ
AMIGA/FTERM
AMIGA/BBSTERM

    FTERM [-Nnet] [port#] [-c#] [-wcapturefile]

    FTERM opens a standard intuition window and connects to a CSH running on
    the remote UNIX machine.  If the remote machine is another Amiga, it
    connects to the terminal-window server (STERM).

    UNIX: The csh runs on a PTY and is NOT named, which means you don't show
    up in WHO or FINGER, and cannot TALK other people (nor can they talk you).
    To get a named shell, you must 'rlogin localhost     S         T lt                                                                                                                                                                                                  V  U  T  S  R  g  f  e  d  c  b  a  `  _  ^  ]  n  m  l  k  j  i  r  T              ,.                                                                                              
    	`dnet.doc                                                             L         S       r)+n
			    AMIGA-DNET V2.10

    New this release:	7 bit support.	In fact, it is the default... see
			options list for 8 bit support.  Also flow control
			may be selected. (refer to -m0 ,-P, and -Z options).

			    AMIGA CONFIGURATION

    ENV:	    must be assigned and writable.
    S:DNET.CONFIG   contains configuration info for DNet
    S:DNET.SERVERS  contains the server list for dnet (and paths to
		    the server executables)

    Any DNet clients you wish to run or have DNet ru     U         V                                                                                                                                                                                                                                                                                      X  W  V                                                                                                            
    	
passwd.doc                                                           L         U       WjAd_
AMIGA/FTERM   Using FTERM to gain access to the SPASSWD server.

    FTERM 8199	    (Amiga<->Amiga connection, from calling amiga)
    DSOC 8199	    (Unix<->Amiga connection, from calling unix machine)

    This connects to the SPASSWD server on the Amiga which requests a
    login and password to gain any level of security access to the amiga.

    S:DNET.CONFIG may contain zero or more entries of the following form:

    USER <username> <password> <read-access> <write-access> <lev     W         X,                                                                                                                                                                                                                                                                                              X              i                                                                                              
    
s
loadav.doc                                                       Y  L         W     i    uAMIGA/LOADAV

    LOADAV [-Nnet] [updatetime]

    Create a load average window on your amiga.  The program 'uptime' must
    exist on the UNIX end for this to work.  The default update time is
    60 seconds.

    The -N option specifies the network (default = 0).  This is the same
    network as was specified when you ran DNET (if was not specified, is 0)

ONFIG may contain zero or more entries of the following form:

    USER <username> <password> <read-access> <write-access> <lev     Y         Z[]                                                                                                                                                                                                                                                                                          Y  Z                                                                                                            
    
organization.doc                                                     L         Y       YB
			   SOURCE ORGANIZATION

	->unix-> (unix source tree)
	|
	|	->bin	    ALL BINARIES
	|	|
	|	->lib	    source to common library of routines
	|	|
	|	->server    source to all dnet servers
    dnet->amiga-|
		->dbbs	    source to the DBBS program
		|		    (NOT FINISHED OR ANYWHERE NEAR FINISHED)
		->client    source to all client programs
		|
		->dnet	    source to the DNET protocol (master program)
		|
		->dbbsctl   control directory for the DBBS, assign to DBBS:
		|		    (NOT IMPLEM     [         \O~                                                                                                                                                                                                                                                                                       [  Z  \              %                                                                                              
    bservers.doc                                                          L         [       ZG
		    HOW TO WRITE SERVER PROGRAMS

SERVERS are run on demand by the DNET device driver.	This is
accomplished by DNET doing a LoadSeg() and CreatProc().  The server
CANNOT GO THROUGH A NORMAL STARTUP for several reasons:

	(1) There is no CLI and the message passed over the process
	    port is DNET specific (NOT a workbench message)

	(2) Registers contain garbage (no argument line)

	(3) No standard file handles exist


For AZTEC C, this is accomplished by overiding the standard _     ]         ^Q҂                                                                                                                                                                                                                                                                                      G  \  ^                                                                                                            
     8cliterm.doc                                                          L         ]       \
AMIGA/CLITERM

    CLITERM [-Nnet] [port#]

    CLITERM is used between two amigas to open a remote CLI on the remote
    amiga.

    CLITERM is a standard FTERM minus some features and plus some features.
    The big feature is that it line-buffers the data, allowing you to
    edit lines before sending them off to the remote cli.  It also
    defaults to the SCLI server's port # (8196).

    WARNING: You must be at a CLI (or 1.3 NewShell shell) prompt when
    you exit!

    The r     _         `                                                                                                                                                                                                                                                                                   I  H  Q  `              X                                                                                              
    getfiles.doc                                                         L         _       Q9UNIX/GETFILES
AMIGA/GETFILES

	GETFILES [-Nnet#] [-dlocaldir] [-c] file/dir file/dir file/dir ..

	GetFiles file transfer client.	Download the specified files and or
	dirs from the remote machine into the current directory, or the
	directory specified if the -d option is used.  Entire directory
	trees may be downloaded

	The -c "continue" option only downloads files which do not already
	exist.	For files which do exist, if the local file size is less
	than the remote file size, the r     a         baN                                                                                                                                                                                                                                                                          g  f  e  d  c  b              

                                                                                              
    dnetlib.doc.info                                                     L         a       c[     &  b     '@ '                  L &      "                    b   ޘ                         EUUUU@        E_UU@        EVUUE        EVgG        EVggeG        EVffEG        EVfuG        E_G        ETG        EUUUUG        EuuUG        EQqUG        Euq}G        EqqG        EqqG        EqqG        Eyy}G        EAAAG        EUUUUG        EUUUUG        EUUUUG        EUUUUG        EUU@G        EUUUUG                     /        UUUUU     a       d`P                                         ?      <?                  9      |<?                  Ϗ      3      ?χ      3      ?      ??                                                                                                                                                      a       e7                                                                                                                                                                                                                                                                                                                                                         b   `                   *UUUUU  7  7  7  7ꪪꪪ  7  7  7  7     a       fUUU~  7  7UUUU~  7  7UUUU~  7  7UUUU~  7  7UUU~  7  7UUUU~  7  7UUUU~  7  7  7_  7  0           *UUUUU                                                 UUUG              UUUUG          *UUUUG          UUUUG          UUUUG               a       gUUUUG          *UUUUG          UUUUG          UUUUG                       @                                                                                                                                                                                                                                                                                                                       a          #%                                                                                                                     :c/MuchMore   7UUUU~  7  7UUUU~  7  7  7_  7  0           *UUUUU                                                 UUUG              UUUUG          *UUUUG          UUUUG          UUUUG               h         iQd                                                                                                                                                                                                                                                      >  =  <  N  M  L  K  J  P  O  i              1                                                                                              
    dnetlib.doc                                                          L         h       O^1
			   DNET LINK LIBRARY

    Link with your server's and client programs.


    listenport	= DListen(port#)                listen for connections
    chanport	= DAccept(listenport)           accept a new connection
		  DNAAccept(listenport)         or refuse a new connection
    chanport	= DOpen(host, port#, txpri, rxpri) open a new channel
		  DPri(chanport, priority)      (not implemented yet)
	    act = DNRead(chanport, buf, bytes)  (see below)
	    act = DRead(chanport, buf, byt     j         k                                                                                                                                                                                                                                                                                      ?  F  k                                                                                                            
    putfiles.doc                                                         L         j       F&rUNIX/PUTFILES
AMIGA/PUTFILES

	PUTFILES [-Nnet#] [-dDESTDIR] file/dir file/dir file/dir ..

	File transfer client.  Transfer the specified files and or directories
	to the destination directory on the remote machine.  For instance:

	unix:  putfiles -dram: charlie.txt /usr/include

	 places the file charlie.txt as ram:charlie.txt, and places the
	 directory structure /usr/include as ram:include/(whatever).

	The -N option selects the network number (see -N option for DNET).
	The defa     l         m')                                                                                                                                                                                                                                                                                              m                                                                                                             
    history                                                              L         l          
			  HISTORY AS OF V2.00

SCOPY
	V2.01.03    Added s:dnet.servers default directory support.  The
		    directory specified in s:dnet.servers (last field)
		    becomes the default directory files are written to.



 For instance:

	unix:  putfiles -dram: charlie.txt /usr/include

	 places the file charlie.txt as ram:charlie.txt, and places the
	 directory structure /usr/include as ram:include/(whatever).

	The -N option selects the network number (see -N option for DNET).
	The defa     n         oσI                                                                                                                                                                                                                                                                          D  C  B  A  @  o              

                                                                                              
    dnet.doc.info                                                        L         n       @~        b     ' '(                  L 'X                           b   (                         EUUUU@        E_UU@        EVUUE        EVgG        EVggeG        EVffEG        EVfuG        E_G        ETG        EUUUUG        EuuUG        EQqUG        Euq}G        EqqG        EqqG        EqqG        Eyy}G        EAAAG        EUUUUG        EUUUUG        EUUUUG        EUUUUG        EUU@G        EUUUUG                     /        UUUUU     p         q                                                                                                                                                                                                                                                                          4  3  2  1  E  q              

                                                                                              
    Oorganization.doc.info                                                L         p       E0G      &  b     (' ((                  L '       "                    b                            EUUUU@        E_UU@        EVUUE        EVgG        EVggeG        EVffEG        EVfuG        E_G        ETG        EUUUUG        EuuUG        EQqUG        Euq}G        EqqG        EqqG        EqqG        Eyy}G        EAAAG        EUUUUG        EUUUUG        EUUUUG        EUUUUG        EUU@G        EUUUUG                     /        UUUUU     r         s                                                                                                                                                                                                                                                                                              s                                                                                                            
    quitdnet.doc                                                         L         r         AMIGA/QUITDNET

    QUITDNET [-Nnet]

    This program causes the remote DNET to exit (remote is UNIX) or return
    to the original window state (remote is an AMIGA).  This is used mainly
    for debugging to allow one to restart a newer copy of the program.

    The -N option specifies the network (default = 0).  This is the same
    network as was specified when you ran DNET (if was not specified, is 0)

UUUUG          UUUUG          UUUUG               t            *                          u          w                                                                                                                                                                                                                                                                                                                                            
    dnet                                                                             u         vl                                                                                                                                                                                                                0  /  .  -  ,  +  *  )  (  '  &  :  9  8  7  6  5  ;  v              (|                                                                                              
    dnet.c                                                               t         u       ;Bi
/*
 *  DNET.C
 *
 *  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
 */

#include "dnet.h"
#include <local/deemu.h>

void do_netreset();
char *GetDEnv();

short Deemu[] = {
    DMSTRT, 0, 0,
    DMNW  , 0,10, 50, 50, 320, 100, 0xFFFF,
    DMEND , 0, 0
};

extern int Enable_Abort;
/*long DResBase;*/
char PortName[sizeof(DNETPORTNAME)+32];

#ifdef LATTICE

int __stdargs CXBRK(void);      /*  get around a bug in lcr.lib : onbreak() */

int __stdargs
CXBRK(void)
{
    retu     w         x0|                                                                                                                                                                                                            %  $  #  "  !                 ~  }  |  {  z  y  x              ,                                                                                              
    wwindow.c                                                             t         w       y
/*
 * WINDOW.C
 *
 *	DNET interactive terminal window.
 */

#include "dnet.h"

#include "/server/servers.h"
#include "/dnet/channel.h"
#include "/lib/dnetlib.h"

void setparity();
void addparity();
void OpenConsole();
void CloseConsole();
void InitDeemuNW();
void LoadConnectList();
void UnLoadConnectList();

IOSER *NetReadReady();
IOSER *NetAbortRead();

typedef struct TextAttr TA;
typedef struct IntuiText ITEXT;
typedef struct IntuiMessage IMESS;
typedef struct Screen SCR;
typedef      w       zMstruct Library LIB;
typedef struct Menu  MENU;
typedef struct MenuItem ITEM;

struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;

TA Ta = { (ubyte *)"topaz", 8 };

ITEXT IText[] = {
    { 0, 1, JAM2, 0, 0, &Ta, (ubyte *)"SendBreak"   },
    { 0, 1, JAM2, 0, 0, &Ta, (ubyte *)"StartDNET"   },
    { 0, 1, JAM2, 0, 0, &Ta, (ubyte *)"QUIT"        }
};

ITEM Item[] = {
    { &Item[1], 0, 0, 120, 10, ITEMTEXT|COMMSEQ|ITEMENABLED|HIGHCOMP, 0, (APTR)&IText[0], NULL, 'b' },
    { &I     w       {Item[2], 0,10, 120, 10, ITEMTEXT|COMMSEQ|ITEMENABLED|HIGHCOMP, 0, (APTR)&IText[1], NULL, 's' },
    { NULL    , 0,20, 120, 10, ITEMTEXT|COMMSEQ|ITEMENABLED|HIGHCOMP, 0, (APTR)&IText[2], NULL, 'q' }
};

MENU Menu[] = {
    { NULL    , 0, 0, 120, 20, MENUENABLED, "DnetControl", &Item[0] }
};

ubyte Title[80];

void
do_dnetwindow(oldbaud)
{
    static struct NewWindow Nw = {
	50, 50, 320, 100, -1, -1,
	CLOSEWINDOW|MENUPICK,
	WINDOWSIZING|WINDOWDRAG|WINDOWDEPTH|WINDOWCLOSE|NOCAREREFRESH|A     w       |jCTIVATE,
	NULL, NULL, Title, NULL, NULL,
	32, 32, -1, -1, WBENCHSCREEN
    };
    struct Window *win;
    char RcvBuf[128];
    char Cc;
    char RSync = 0;
    long imask, smask, conmask, mask, dnet_mask;
#ifdef NOTDEF
    long ipc_mask;
#endif
    IOCON *iocr, *iocw;
    char notdone = 1;

    sprintf(Title, "DNET V%s%s", VERSION, DNET_VERSION);
    setparity(0xFF, 0x00, 1);
    IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 0);
    GfxBase = (struct GfxBa     w       }nH9se *)OpenLibrary("graphics.library", 0);
    if (IntuitionBase == NULL || GfxBase == NULL)
	goto e1;
    InitDeemuNW(Deemu+DMNWOFF, &Nw);
    win = OpenWindow(&Nw);
    if (win == NULL)
	goto e1;
    SetMenuStrip(win, Menu);
    OpenConsole(win, &iocr, &iocw);
    if (iocr == NULL)
	goto e3;
    if (Cto_act) {
	AbortIO((IOR *)&Cto);
	WaitIO((IOR *)&Cto);
	Cto_act = 0;
    }
    if (Wto_act) {
	AbortIO((IOR *)&Wto);
	WaitIO((IOR *)&Wto);
	Wto_act = 0;
    }
    SetBaudRate(oldbaud);

     w       ~ve    if (OpenCfgFile()) {    /*  Automatic enviroment reset.     */
	char *env;
	char *get = (AutoAnswer) ? "ENVA" : ((DialOut) ? "ENVO" : "ENVM");

	while (env = GetCfgLine(get)) {
	    char *ptr;
	    for (ptr = env; *ptr && *ptr != ' ' && *ptr != 9; ++ptr);
	    if (*ptr) {
		*ptr = 0;
		for (++ptr; *ptr == ' ' || *ptr == 9; ++ptr);
		SetDEnv(env, ptr);
	    }
	}
    }

    if (Cd == 0 && AutoAnswer) {
	if (OpenCfgFile()) {
	    char *str;
	    while (str = GetCfgLine("RESM")) {  /     w       "* RESM MODEM-CMD   */
		short len = strlen(str);
		str[len++] = '\r';
		NetWrite(str, len, 0);
		Cto.tr_time.tv_secs = 1;
		Cto.tr_time.tv_micro= 0;
		DoIO((IOR *)&Cto);
	    }
	    CloseCfgFile();
	} else {
	    NetWrite("AT\r", 3, 0);   /*  cause modem to reset baud rate */
	    Cto.tr_time.tv_secs = 1;
	    Cto.tr_time.tv_micro= 0;
	    DoIO((IOR *)&Cto);
	    NetWrite("AT\r", 3, 0);     /*  cause modem to reset baud rate */
	    Cto.tr_time.tv_secs = 1;
	    Cto.tr_time.tv_micro=     w       &I 0;
	    DoIO((IOR *)&Cto);
	    NetWrite("ATS0=1\r", 7, 0); /*  auto answer on */
	}
    }

    iocr->io_Data = (APTR)&Cc;
    iocr->io_Length = 1;
    SendIO((IOR *)iocr);

    imask   = 1 << win->UserPort->mp_SigBit;
    smask   = 1 << IOSink->mp_SigBit;
    conmask = 1 << iocr->io_Message.mn_ReplyPort->mp_SigBit;
    dnet_mask = 1 << DNetPort->mp_SigBit;
#ifdef NOTDEF
    ipc_mask= 1 << IPCPort->mp_SigBit;
#endif

    LoadConnectList();

    Signal(FindTask(NULL), imask|smask|con     w   	    o{mask|dnet_mask/*|ipc_mask*/);

    StartWriteTimeout(1);

    while (!Quit && OnLine == 0) {
	mask = Wait(imask|smask|conmask|dnet_mask/*|ipc_mask*/);
#ifdef NOTDEF
	if (mask & ipc_mask)
	    handle_ipc();
#endif
	if (mask & dnet_mask) {
	    IOSTD *ior;
	    while (ior = (IOSTD *)GetMsg(DNetPort)) {
		switch(ior->io_Command) {
		default:
		case DNCMD_WRITE:
		case DNCMD_EOF:
		case DNCMD_IOCTL:
		case DNCMD_QUIT:
		case DNCMD_OPEN:
		    ior->io_Error = 1;
		    break;
		case DNCMD_     w   
    "	CLOSE:
		    Chan[(ulong)ior->io_Unit].state = CHAN_FREE;
		    break;
		case DNCMD_SOPEN:
		    {
			uword chan = (ulong)ior->io_Unit;
			Chan[chan].state = CHAN_FREE;
			if (!ior->io_Error) {
			    Chan[chan].state = CHAN_CLOSE;
			    Chan[chan].port  = (PORT *)ior->io_Offset;
			    Chan[chan].flags = CHANF_RCLOSE;
			    WritePort(Chan[chan].port, DNCMD_CLOSE, NULL, 0, PKT_REQ, chan);
			}
			if (ior->io_Length)
			    FreeMem(ior->io_Data, ior->io_Length);
			FreeMem(ior, size     w       of(IOSTD));
			ior = NULL;
		    }
		    break;
		case DNCMD_EXEC:
		    Execute((char *)ior->io_Offset, NULL, NULL);
		    break;
		}
		if (ior)
		    ReplyMsg((MSG *)ior);
	    }
	}
	if (mask & imask) {
	    struct IntuiMessage *im;
	    while (im = (IMESS *)GetMsg(win->UserPort)) {
		switch(im->Class) {
		case CLOSEWINDOW:
		    notdone = 0;
		    Quit = 1;
		    break;
		case MENUPICK:
		    switch((uword)((MENUNUM(im->Code)<<8)|ITEMNUM(im->Code))) {
		    case 0x0000:    /*	menu                                                                                                                                                                                                                                                                                                                          3                                                                                              
    TODO                                                                 t              3    S
    -REMOTE CONTROL / AUTO HANGUP PROBLEM (INFINITE WAIT)
    -get priority working

    -arbitrate Transmit queue... round robin active requests in 64 byte
     chunks (data packets only).

    -NumCon not completely implemented

    -Parallel port access
    -Host Names
    -Better term prog response.

tatic char tmpbuf[64];
    static short tlen;
    short i;
    NODE *node;
    long newbaud = oldbaud;

    for (i = 0; i < n; ++i) {
	if (ptr[i] == 13 || ptr[i] == 10) {
	    tmpbu              l                                                                                                                                                                                                                            
  	                                    )#                                                                                              
    dnet.h                                                               t                /
/*
 *  DNET.H
 *
 *  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
 *
 */

#include <exec/types.h>
#include <exec/tasks.h>
#include <exec/memory.h>
#include <devices/serial.h>
#include <devices/timer.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <intuition/intuition.h>
#include <proto/all.h>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "/version.h"

#define DNET_H

#define DMNWOFF     4	    /*	Deemu offset to NewWindow              	C                                                                                                                                                                                                                                                                                                                                                                                                   
    	
dataconv.c                                                           t                 )E
/*
 *  DATACONV.C
 *
 *  Data Conversion.
 */

typedef unsigned char ubyte;
typedef unsigned short uword;
typedef unsigned long ulong;


int
Compress7(s, db, n)
ubyte *s;
ubyte *db;
uword n;    /*	actual source bytes */
{
    ubyte *d = db;

    while (n) {
	*d++ = *s++ << 1;

	if (--n == 0)
	    break;
	d[-1] |= *s >> 6;
	*d++ = *s++ << 2;

	if (--n == 0)
	    break;
	d[-1] |= *s >> 5;
	*d++ = *s++ << 3;

	if (--n == 0)
	    break;
	d[-1] |= *s >> 4;
	*d++ = *s++ << 4;

	if (--n ==              Y                                                                                                                                                                                                                                                                                                                                                                                                    
    
d	channel.h                                                            t                G
/*
 *  CHANNEL.H
 *
 *  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
 *
 *  Channel structures for SCMD_* channel commands.
 */

#ifndef DNET_CHANNEL_H
#define DNET_CHANNEL_H

#ifndef DNET_H
typedef struct IOStdReq IOSTD;
#endif

#define CSWITCH struct _CSWITCH
#define COPEN	struct _COPEN
#define CCLOSE	struct _CCLOSE
#define CACKCMD struct _CACKCMD
#define CEOFCMD struct _CEOFCMD
#define CIOCTL	struct _CIOCTL

CSWITCH {		/*  SWITCH current data channel */
    ubyte               k                                                                                                                                                                                                                                                                                                                                                                                                        
    
	DMakefile                                                            t                ?
#   DNET DRIVER
#
#   Lattice C	V5.02
#
#   DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.

CFLAGS	= -iprivate_include: -cim -v
BIN	= /bin/
OD	= ltmp:dnet/
SRCS	= control.c globals.c sernet.c window.c dnet.c ipc.c \
	  subs.c time.c packet.c dataconv.c
OBJS	= $(SRCS:"*.c":"$(OD)*.o")
SYMS	= $(OD)dnet.m

all:	$(SYMS) $(BIN)dnet

$(BIN)dnet: $(OBJS)
    Assign dnetbin: /bin
    Assign dnetlib: /lib
    cd $(OD)
    blink FROM LIB:c.o $(OBJS:"$(OD)*":"*") LIB dnetlib:latt              ]E                                                                                                                                                                                                                                                                    '                                                                                              
     3subs.c                                                               t                k
/*
 *  SUBS.C
 *
 *  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
 *
 */

#include "dnet.h"
#include <stdio.h>
#ifdef LATTICE
#include <dos.h>
#endif

#ifndef LATTICE
char *FakeArgs;
long  FakeLen;
long  FakeGo;
long  FakeCLI;

extern char *malloc();
#endif

void dneterror();

typedef struct CommandLineInterface CLI;

/*
 *  Add the high-level command to the queue of commands to be sent to
 *  the remote DNET.
 */

void
WriteStream(sdcmd, buf, len, chan)
int sdcmd;
v            ȚHoid *buf;
int len;
uword chan;
{
    IOSTD *ior = AllocMem(sizeof(IOSTD), MEMF_PUBLIC);

    if (DDebug)
	printf("WriteStream: cmd %ld  buflen %ld  chan %ld\n", sdcmd, len, chan);
    ior->io_Message.mn_Node.ln_Name = (char *)PKT_REQ;
    ior->io_Message.mn_ReplyPort = IOSink;
    ior->io_Data = (APTR)AllocMem(len, MEMF_PUBLIC);
    ior->io_Length = len;
    ior->io_Actual = 0;
    ior->io_Command = sdcmd;
    ior->io_Error = 0;
    ior->io_Message.mn_Node.ln_Pri = (chan > MAXCHAN) ?            Qĉ 126 : Chan[chan].pri;
    BMov(buf, ior->io_Data, len);
    Enqueue(&TxList, (NODE *)ior);
    do_wupdate();
}

/*
 *  Send a packet to a port.  Used to send data/eof/close to channel
 *  ports, and to relay open requests to server ports.
 */

void
WritePort(port, scmd, buf, len, rettype, unit)
PORT *port;
int scmd;
void *buf;
int len;
int rettype;
int unit;
{
    IOSTD *ior = AllocMem(sizeof(IOSTD), MEMF_PUBLIC);

    if (DDebug)
	printf("WritePort: cmd %ld  buflen %ld  rt %ld unit            e %ld\n", scmd, len, rettype, unit);
    ior->io_Message.mn_Node.ln_Name = (char *)rettype;
    ior->io_Message.mn_ReplyPort = (rettype) ? IOSink : DNetPort;
    ior->io_Unit = (struct Unit *)unit;
    ior->io_Command = scmd;
    ior->io_Error = 0;
    ior->io_Data  = NULL;
    ior->io_Length = 0;
    ior->io_Actual = 0;
    if (buf) {
	ior->io_Data = (APTR)AllocMem(len, MEMF_PUBLIC);
	ior->io_Length = len;
	BMov(buf, ior->io_Data, len);
    }
    PutMsg(port, (MSG *)ior);
    if (ret            -#_otype == PKT_REQ)
	++NumCon;
}

/*
 *  ALLOC_CHANNEL()
 *
 *	Allocate a channel.  Starting at a random point, find the first
 *	free channel.  Return -1 if no free channels found.
 */

alloc_channel()
{
    static ulong ran = 13;
    long stamp[3];
    uword i;

    DateStamp(stamp);
    ran = ((ran * 13) + 1) ^ (ran >> 9) + stamp[0] + stamp[1] + stamp[2];
    for (i = ran % MAXCHAN; i < MAXCHAN; ++i) {
	if (Chan[i].state == 0) {
	    return((int)i);
	}
    }
    for (i = ran % MAXCHA            *^N; i != 0xFFFF; --i) {  /*  Fixed 28 September 1988 */
	if (Chan[i].state == 0) {
	    return((int)i);
	}
    }
    return(-1);
}

/*
 *  Get next node in a linked list.  If a pointer to a list base
 *  is passed, gets the first node in the linked list.	Returns
 *  NULL if no further nodes in the list.
 */

GetNext(node)
NODE *node;
{
    NODE *next = node->ln_Succ;
    if (*(long *)next)
	return((long)next);
    return(NULL);
}

/*
 *  CHKBUF
 *
 *  Generate a two-byte checksum for             ~data.  Uses a very simple, but
 *  effective algorithm.
 */

chkbuf(buf, bytes)
ubyte *buf;
uword bytes;
{
    uword i;
    ubyte c1,c2;

    for (i = c1 = c2 = 0; i < bytes; ++i) {
	c1 += buf[i];
	c2 += c1;
    }
    c1 = -(c1 + c2);
    return((c1<<8)|c2);
}

void
TimerOpen(req, sink)
IOT *req;
PORT *sink;
{
    if (OpenDevice("timer.device", UNIT_VBLANK, (IOR *)req, 0))
	dneterror("timer.device");
    req->tr_node.io_Message.mn_ReplyPort = sink;
    req->tr_node.io_Command = TR_AD            dgDREQUEST;
}

void
TimerClose(req)
IOT *req;
{
    CloseDevice((IOR *)req);
    req->tr_node.io_Device = NULL;
}


/*
 *  RUNSERVER
 *
 *	Search the file [S:]DNET.SERVERS for the specified server and
 *	attempt to LoadSeg()/CreateProc() it.  The port number must be
 *	non-zero (allows commening out lines in DNET.SERVERS), and
 *	regardless of whether the server is able to DListen(), it must
 *	perform a small handshake sequence with DNET.
 */

#ifdef LATTICE

static struct ProcID *SvB        	    m$t+ase;

void
InitServers()
{
    SvBase = NULL;
}

void
RunServer(portnum)
uword portnum;
{
    FILE *fi;
    char buf[128];
    char s1[64], s2[64];
    long v1;

    if (!portnum)
	return;
    if ((fi = fopen("dnet.servers", "r")) == NULL)
	fi = fopen("s:dnet.servers", "r");
    if (fi) {
	while (fgets(buf, 128, fi)) {
	    if (sscanf(buf, "%ld %s %s", &v1, s1, s2) == 3 && v1 == portnum)
		goto success;
	}
	fclose(fi);
    }
    return;
success:
    fclose(fi);

    {
	PROC	*myproc;
        
    ûZ	MSG	msg;
	struct ProcID *pid = malloc(sizeof(struct ProcID));
	int error;

	BZero(pid, sizeof(*pid));
	error = forkl(s1, "__dnet", "__dnet", NULL, NULL, pid);

	if (error < 0) {
	    printf("Server not found: %s\n", s1);
	    free(pid);
	} else {
	    myproc = (PROC *)FindTask(NULL);

	    msg.mn_ReplyPort = &myproc->pr_MsgPort;
	    msg.mn_Node.ln_Name = s2;
	    printf("Starting Server: %s proc %08lx  ", s1, pid->process);
	    fflush(stdout);
	    PutMsg(&pid->process->pr_MsgPort            .;L, &msg);       /*  startup handshake */
	    WaitPort(&myproc->pr_MsgPort);
	    (void)GetMsg(&myproc->pr_MsgPort);
	    puts("started");
	    fflush(stdout);
	    pid->nextID = SvBase;
	    SvBase = pid;
	}
    }
}

void
DeleteServers()
{
    struct ProcID *pid, *pn;

    for (pid = SvBase; pid; pid = pn) {
	pn = pid->nextID;
	for (;;) {
	    Signal((TASK *)pid->process, SIGBREAKF_CTRL_C);
	    printf("Waiting for pid %08lx to die\n", pid->process);
	    if (CheckPort(pid->parent))
        
      3D                                                                                                                                                                                                                                                                                          N                                                                                              
    ipc.c                                                                t                ̲
/*
 *  IPC.C
 *
 *  Handle IPC messages
 *
 *  NOTE:   Only an explicit disconnect command will drop DTR, or when
 *	    the serial.device is closed.
 */

static int dummy;

#ifdef NOTDEF

#include "dnet.h"
#include <local/ipc.h>

#define IPCMDS struct _IPCMDS

void do_online(), do_offline(), do_stat(), do_quit(), do_disconnect();
void do_state();
void do_recvon(), do_recvoff(), do_serialon(), do_serialoff();
void do_baud();
void do_getidle(), do_getconnect(), do_setidlealert(), do_              ]                                                                                                                                                                                                                                                                                                                                                                                                           
    Xsyms.c                                                               t                   1D
#include "dnet.h"


e();
}

#endif


oid
do_recvon()
{
    NetRecvOn();
}

void
do_recvoff()
{
    NetRecvOff();
}

void
do_serialon()
{
    NetSerialOn();
}

void
do_serialoff()
{
    NetSerialOff();
}

void
do_baud(av)
char **av;
{
    long baud = atoi(av[1]);
    if (baud) {
	Baud = baud;
	SetBaudRate(baud);
    }
}

void
do_getidle(av, pbuf, plen)
char **av;
char **pbuf;
long *plen;
{
    char buf[32];
    sprintf(buf, "%ld", GetIdle());
    AllocAppend(pbuf, plen, buf, strlen(b              e                                                                                                                                                                                                                                                                                                                                                                                                    
    	globals.c                                                            t                M?
/*
 *  GLOBALS.C
 *
 *  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
 *
 *	-restart/packet protocol
 *	-dnet->amiga	    (DNET.READ)
 *	-amiga->dnet	    (DNET.WRITE)
 */

#include "dnet.h"

int Enable_Abort;

IOT Rto;		/*  Read-Timeout/reset		 */
IOT Wto;		/*  Write-Timeout/retry 	 */
IOT Cto;		/*  1 second CD check / idle line*/
PKT Pkts[9];		/*  data buffers for packets	 */
PKT *RPak[4] = { Pkts+0,Pkts+1,Pkts+2,Pkts+3 };
PKT *WPak[4] = { Pkts+4,Pkts+5,Pkts+6,Pkts+7               \                                                                                                                                                                                                                                                                                                    O                                                                                              
    time.c                                                               t                ᩶>6
/*
 *  TIME.C
 *
 *  Handle IPC alert functions & timekeeping for connect and idle time.
 */

#include "dnet.h"
#include <stdio.h>
#include <local/ipc.h>

#define TICKSIZE    10	    /*	10 second intervals */

static long TickIdle;
static long TickConnect;

static long AlertIdle;
static long AlertConnect;

static char AIWho[64];	    /*	app-name to alert   */
static char ACWho[64];	    /*	app-name to alert   */

/*
 *  CTO:    Idle timeout (check carrier)
 *
 */

void
do_cto(ior)
IOT               ))                                                                                                                                                                                                                                                                                    >                                                                                              
    packet.c                                                             t                P
/*
 *  PACKET.C
 */

#include "dnet.h"

void BuildPacket();

#define Ascize(foo) (((foo) & 0x3F) | 0x40)

ubyte	RxTmp[MAXPACKET];

void
BuildDataPacket(pkt, win, dbuf, actlen)
PKT	*pkt;
ubyte	win;
ubyte	*dbuf;
uword	actlen;
{
    ubyte *ptr;
    ubyte *pend;
    ubyte range = 0;
    static ubyte BadCtl[32] = {
	1, 1, 1, 1, 1, 1, 1, 1,
	1, 0, 0, 1, 0, 0, 1, 1,
	1, 1, 1, 1, 1, 1, 1, 1,
	1, 1, 1, 1, 1, 1, 1, 1
    };

    ptr = dbuf;
    pend= dbuf + actlen;

    while (ptr < pend) {
	              &&                                                                                                                                                                                                                                                                                                                                                                              
    sernet.c                                                             t                50
/*
 *  SERNET.C
 *
 *  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
 *
 *  NetWork device interface.
 */

#include "dnet.h"

IOSER *NetAbortRead();
void NetWaitWrite();
void SaveState();
void RestoreState();
void NetSerialOff();
void NetSerialOn();



static IOSER Iosw;
static ubyte IoswIP;
static ubyte LastWasWrite;

static ubyte IosrIP;
static ubyte RBuf[MAXPACKET*2];     /*	Recv Buf.		    */

static IOSER *CNet;		    /*	control-req (synchro)       */
static IOSER             )sһ*RNet;		    /*	read-request		    */
static ubyte SerialIsOpen;	    /*	serial device is open	     */
static ubyte RecvEnabled = 1;
static char *DevName;
static long UnitNum;

void
NetOpen(iosink, devname, unitnum, pbaud)
PORT *iosink;
char *devname;
long *pbaud;
{
    IOSER ios;
    long baud = *pbaud;

    DevName = devname;
    UnitNum = unitnum;

    printf("netopen %s %d\n", devname, unitnum);

    BZero(&ios, sizeof(ios));
    ios.io_CtlChar = 0x11130102;
    ios.io_SerFlags = SE            %/RF_SHARED|SERF_XDISABLED|SERF_RAD_BOOGIE;
    if (OpenDevice(devname, unitnum, (IOR *)&ios, 0))
	dneterror(devname);
    ios.IOSer.io_Message.mn_ReplyPort = iosink;
    SerialIsOpen = 1;

    RNet = (IOSER *)AllocMem(sizeof(IOSER), MEMF_PUBLIC);
    CNet = (IOSER *)AllocMem(sizeof(IOSER), MEMF_PUBLIC);
    *RNet = ios;
    *CNet = ios;

    {
	IOSER *ioc = CNet;

	ioc->IOSer.io_Command = SDCMD_QUERY;
	DoIO((IOR *)ioc);

	if (Getty == 0) {
	    ioc->IOSer.io_Command = SDCMD_SETPARAMS;            $u
	    ioc->io_SerFlags = SERF_SHARED|SERF_XDISABLED|SERF_RAD_BOOGIE;
	    ioc->io_ExtFlags = 0;
	    ioc->io_ReadLen = ioc->io_WriteLen = 8;
	    ioc->io_CtlChar = 0x01020304;

	    if (baud)
		ioc->io_Baud = baud;

	    switch(Protocol) {
	    case 0:
		break;
	    case 1:	/*  xon-xoff	*/
		Mode7 = 1;
		ioc->io_SerFlags &= ~SERF_XDISABLED;
		break;
	    case 2:
		ioc->io_SerFlags |= SERF_7WIRE;
		break;
	    }

	    *pbaud = Baud = ioc->io_Baud;
	    if (DoIO((IOR *)ioc) != 0)
		dne            bterror("Unable to set serial parameters");
	}
    }

    RNet->IOSer.io_Command = CMD_READ;
    RNet->IOSer.io_Message.mn_Node.ln_Name = (char *)RNET_REQ;

    CNet->IOSer.io_Command = CMD_WRITE;
    CNet->IOSer.io_Message.mn_Node.ln_Name = (char *)WNET_REQ;

    Iosw = *CNet;

    CNet->IOSer.io_Message.mn_Node.ln_Name = (char *)CNET_REQ;

    puts("net open");
}

/*
 *  Closedown the network.
 */

void
NetClose()
{
    NetAbortRead();
    NetWaitWrite();
    if (SerialIsOpen)
	Clos            $BeDevice((IOR *)RNet);
    if (RNet)
	FreeMem(RNet, sizeof(IOSER));
    if (CNet)
	FreeMem(CNet, sizeof(IOSER));
    SerialIsOpen = 0;
    RNet = CNet = NULL;
}

/*
 *  NETCLWRITE()
 *
 *  Clear write request which was GetMsg()'d in DNET.C instead of
 *  WaitIO()'d here.
 */

void
NetClWrite(ior)
IOSER *ior;
{
    if (ior == &Iosw)
	IoswIP = 0;
}

void
NetWrite(buf, bytes)
ubyte *buf;
int bytes;
{
    if (PDebug) {
	short i;

	LastWasWrite = 1;
	printf("WRITE %03x Bytes:", bytes);
	fo            vr (i = 0; i < bytes; ++i)
	    printf(" %02x", buf[i]);
	printf("\n");
    }

    if (!SerialIsOpen)
	return;

    if (IoswIP) {
	WaitIO((IOR *)&Iosw);
	IoswIP = 0;
    }

    if (bytes) {
	Iosw.IOSer.io_Message.mn_Node.ln_Name = (char *)WNET_REQ;
	Iosw.IOSer.io_Data = (APTR)buf;
	Iosw.IOSer.io_Length = bytes;
	SendIO((IOR *)&Iosw);
	IoswIP = 1;
    }
    fixsignal(Iosw.IOSer.io_Message.mn_ReplyPort);
}

void
NetBreak()
{
    if (SerialIsOpen) {
	CNet->IOSer.io_Command = SDCMD_BREAK;            $
	DoIO((IOR *)CNet);
	fixsignal(Iosw.IOSer.io_Message.mn_ReplyPort);
    }
}

/*
 *  NETREADY()
 *
 *  Using the specified inactive request, return the # bytes ready and
 *  the carrier status.
 */

NetReady()
{
    long n = 0;

    if (SerialIsOpen && RecvEnabled) {
	CNet->IOSer.io_Command = SDCMD_QUERY;
	if (DoIO((IOR *)CNet) == 0)
	    n = CNet->IOSer.io_Actual;
	Cd = !(CNet->io_Status & (1 << 5));
    }
    return(n);
}

/*
 *  SetBaudRate()
 */

SetBaudRate(baud)
long baud;
{
          	    j:  long result;

    if (Getty)
	return(0);
    if (TOBaud == 0)
	SetTimeouts(baud);
    if (CNet)
	CNet->io_Baud = baud;
    if (!SerialIsOpen)
	return(1);
    SaveState();
    CNet->IOSer.io_Command = SDCMD_SETPARAMS;
    result = DoIO((IOR *)CNet);
    RestoreState();

    if (result)
	printf("Unable to set baud rate to %d\n", baud);

    if (!result && PDebug)
	printf("Baud rate set to %d\n", baud);

    return(0);  /*  don't abort whether we can or not   */
}

/*
 *  Assumes CNet        
     holds current settings
 */

void
DropDTR()
{
    if (SerialIsOpen) {     /*  only if serial.device currently open    */
	NetSerialOff();
	Delay(50*4);
	NetSerialOn();
    }
}

IOSER *
NetAbortRead()
{
    if (IosrIP) {
	if (SerialIsOpen && RecvEnabled) {
	    AbortIO((IOR *)RNet);
	    WaitIO((IOR *)RNet);
	}
	IosrIP = 0;
    }
    return(RNet);
}

/*
 *  NetStartRead(bytes)
 */

static long  SaveLen;

void
NetStartRead(len)
long len;
{
    if (len > sizeof(RBuf))
	len = sizeof(RBuf            8Ѯ);

    if (SerialIsOpen && RecvEnabled) {
	if (IosrIP)
	    NetAbortRead();
	RNet->IOSer.io_Data = (APTR)RBuf;
	SaveLen = RNet->IOSer.io_Length = len;
	SendIO((IOR *)RNet);
    } else {
	SaveLen = len;
	RNet->IOSer.io_Actual = 0;
    }
    IosrIP = 1;
}

IOSER *
NetReadReady()
{
    return((IOSER *)CheckIO((IOR *)RNet));
}

NetReadReturned(pptr)
ubyte **pptr;
{
    long bytes = 0;

    IosrIP = 0;

    bytes = RNet->IOSer.io_Actual;
    *pptr = RBuf;

    if (PDebug) {
	short i = 0;              SƓ                                                                                                                                                                                                                                                        1                                                                                              
    -	control.c                                                            t                2
/*
 *  CONTROL.C
 *
 *  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
 *
 *  Main packet control.  Medium level.  Interprets formatted received
 *  packets and sends formatted tx packets.  Uses low level packet
 *  construction and reception routines in PACKET.C
 */

#include "dnet.h"
#include <stdio.h>

void do_rupdate();
void do_reccmd();
void replywindow();
void StartWriteTimeout();

/*
 *  RTO:    read timeout.   Timeout occured while waiting for the rest of
 *	                r                                                                                                                                                                                                                                                                                                    j                                                                                              
    REQUIREMENTS                                                                       
	DNET (c)Copyright 1987-1989 Matthew Dillon, All Rights Reserved

	Matthew Dillon
	891 Regal Rd
	Berkeley, Ca. 94708
	USA

	...!ihnp4!ucbvax!dillon 	USENET
	dillon@ucbvax.Berkeley.edu	ARPANET
	ucbvax.berkeley.edu pub/amiga	ARPANET-FTP

    CHANGES THIS VERSION:
	7 bit support

	files compile under Lattice C (and don't compile under Aztec C but
	will eventually compiler under the new Aztec).


		     REQUIREMENTS TO RUN DNET ON AN AMIGA
	(This distribution contains the necessary file                 93                                                                                                                                                                                                                                                                                                                                                                                                  
    doshand                                                                           6      2X                                                                          z  y  x  w  v                                                                                                                f                                                                                              
    	$nfs-handler.c                                                                         ho)@+<p`      g   
g| /-/NPO( `< 	fHx/N$PO( Jj 	 	g| )m+</-/NPO( J-g6 rxҁJg*Jk&/N0Hx/N
O ( `Hx/N
PO( Jtgp`$%D  LN]Nu                        H./ ,/ */  /N\XO&@ fp`///+ N	O ( Jtgp` LNu  H0./ Jnp `  pd.  V. GE&R g@ + m2f S$ `n + re K$$H$%@  `L$K&S` ",
8ЁSNZ",
8N2, P V, F/N2XO&@ g//N..a TPO`p LNu                      
/*
 *  NFS-HANDLER.C	V1.11	27-June-89
 *
 *  DNet DOS level NFS handler.
 *
 *  By Matthew Dillon.
 *
 *  This handler converts DOS packets into a form suitable for transmission
 *  over a DNet link to a remote server which will execute the operations.
 */

#include "dos.h"
#include <exec/alerts.h>

/*
 *  Since this code might be called several times in a row without being
 *  unloaded, you CANNOT ASSUME GLOBALS HAVE BEEN ZERO'D!!  This also goes
 *  for any global/static assignmen              !                                                                                                                                                                                                                                                                              }  |  {                                                                                                                
    		uuser.doc                                                                            
			    UUSER.DOC

			    UUSER V1.00 Beta

    Currently UUSER: works only with single sessions started
    by Getty (this has to do with how UUSER: deals with carrier
    detect).  THIS WILL BE FIXED.

    Openning UUSER:

	fopen("UUSER:devicename/unit/options", ...);

    Example:
		    (suggested)

	int  fd = open("UUSER:serial.device/0/R1000", O_RDWR | O_CREAT | O_TRUNC);

		    (also can do this -- see below for problems using
		     stdio to read)

	FILE *rfi = fopen("UUSER:se              Rv                                                                                                                                                                                                                                                                                                                                                                                                          
    
DMakefile.Lattice                                                                      '
#	DNET SERVERS
#
#  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
#
#   Aztec C Compilation and Makefile

CFLAGS	= -iprivate_include: -cim -rr -v -O
BIN	= /bin/
OBDIR	= ltmp:dnet/
SRCS	= *.c
OBJS	= $(OBDIR)*.o

all: $(BIN)*

$(BIN)* : $(OBJS)
    blink FROM %(right) LIB /lib/lattice_dnet.lib LIB:sup32.lib LIB:lcr.lib lib:amiga.lib TO %(left)

$(OBJS): $(SRCS)
    lc $(CFLAGS) -o%(left) %(right)

 carrier is lost
	    when you read 0 bytes... this is so your program th              N                                                                                                                                                                                                                                                                                                             d                                                                                              
    
	mountlist                                                                           d    
UUSER:	   Handler = uucp:l/uuser-handler
	   Stacksize = 6000
	   Priority = 5
	   GlobVec  = 1
#

                                                                                                                                                                                                                                                                                                          
    
@doshand                                                                             	      3A                                                                                                                                                                                                                                                              p  o  n  m  l  k    ~                L                                                                                              
    Cdos.h                                                                                ~
/*
 *  DOS.H
 */

#include <stdio.h>
#include <local/typedefs.h>
#include <local/xmisc.h>
#include "/server/servers.h"
#include "/dnet/channel.h"
#include "/lib/dnetlib.h"

#ifdef LATTICE
#include <stdlib.h>
#include <string.h>
#endif

#ifdef NOTDEF
#include "exec/types.h"
#include "exec/memory.h"
#include "libraries/dos.h"
#include "libraries/dosextens.h"
#include "libraries/filehandler.h"
#endif NOTDEF

/*
 *  ACTIONS which do not exist in dosextens.h but which indeed exist on
 *                                                                                                                                                                                                     ^  ]  \  [  Z  Y  X  W  V  U  j  i  h  g  f  e  d  c  b  a  `  q  u  t  s  r                3s                                                                                              
     uuser.c                                                                              rD>
/*
 *  UUSER.C UUSER:devicename/unitnumber/options
 *	    UUSER:serial.device/0/R1000
 *
 *  options:
 *	Rn	Set read timeout when no data available to n millisecs
 *	C0	Ignore carrier detect
 *
 *  features:
 *	1K asynchronous write capability (write 0 bytes to sync up)
 *	programmable read-timeout (Getty starts procs up w/ 1sec to)
 *
 *	combined together, you can easily implement 100% efficient
 *	protocols even with that 1 second read timeout!
 */

#include <exec/types.h>
#includ              Z1                                                                                                                                                                                                                                                                                          _                                                                                                              
    Mdoc.info                                                                             _vl       G P     '                    L              < ٸ          S F    @ ,     !          Z (              P   x                            : <       : 4 : ?4  _( 0                                                                              ? ? ? ? ? ? ? ? ? ? ?                 3                                                                                                                                                                                                                                                                                                                                                                                      
    
bin                                                                                       ŕ1l                                                                                                                                                                          E  D  C  B  A  @  ?  T  S  R  Q  P  O  N  M  L  K  J  q                                    8                                                                                               
    loadav                                                                               d                  8  H   %   -   J          7      <   L      8H~$H$ I    ,x G   r  <  `&Q)O@)N8B<p "<  0 NCZp N)@fpd`  &n)k 4J gh     )@ k "h  r )IHЁRBgR@UBw  Sԁ    SQ    S    Q"O/	`r)k :pRѬA \NA \N)@</ $@ * $g,l @"(  )A4N"*  g$<  N)@Dg
 @'h   l</Hl  h $)h HNN~p ` / /  ,,g @NN,x "lNbNxJ<g",DgN,x N|"l<N .l@L~Nu            ǔODdos.library L   / g c  2  f  h2	  f  ^  e  ,"  ,i  "H?>p,`  L|H?>QHA0L|2 `  # # Q   d0   f  Nu Q   dNu2  f  h2	  f  ^  e  ,"  ,i  "H?>p,`  L|H|QHA0L|2 `  ""Q   d0   f  NuQ   dNuL  H 2,y  8 "|  |   |  /n E G $&    %J #O $IN/
a  6X "LL Nu o p (  g   Nu o p  h Jg   Nu o H 2$H&h ,y  8*  f  + p N`N"JNN 
LL NuL            ӓ%  H 8$@&A   (Ot pf  Jg   *f  PB f  p`  0@)  ) RBR`SBk  0@ t JgJBk  |0@$t  RR &t R` ?f  Jf  DJBf`  P  Ae    Zb       Ae   Zb      g  
JBf`  Jf  SJf  S` :p    LNu"y  8"i   g   g  H p a  @L !I Rh NuL `   o p  f  pNupNuL `   o p  f  NuH ",y  8R.' g  2? /.// pN0/  o  fg   P`  NvLD Nu o Sh f  p !@    "f  NuL ` o p  "g  8H "             [n,y  8R.'"g  $A* f  "j pN"fNvLDNuL H 0"@Jg  ,"QJg  $ ) 
gg  $@&H
fJ*f 	L Nup L Nu  NuNuNUH/./ 4&o 8(p1 gp` p+  VD HH, J f  +  fzp '@ rg B/NXOJg  p` *  Jg + " D'A ` + '@ S m k C 'I  r  ` r  //a RPO"  ` +  gXpfp `  @Jg"r
fr/Hz/+ +AN<O * `r/Hm/+ +AN O * ~`    JgRpgLT r
f& k C 'I  "+ Jk
// a POR  k C 'I  "+            ޒ Jk ~ +  +@gr+  gRHx B/+ NO +@Jg8Sm2B/-/+ NHx Hm/+ NO Jf
-rg/-/+ /+ N
@O * `z pf  `g  Jg"+ $D'B `+  gr 'A `"+ 'A  k 'H g.S m k C 'I  r  ` r  //a PO" p0 gp`pfp ` LN]Nu
          paH 0&o $KJg$p A0  g
r  t `r  R` LNu        paH0&o $o ./ Jg JgJgp r , Jg `S`JgJgp`
Jgp`p LNuNUH0&o  $o $./ ( JJfS            ˬf, KJfS "K+Ic,  J`Sd mB0h  LN]Nu/&o p A0  gR` &_Nu /  o NU"Or
N,A 0Jf 	fBN]Nu   /  o NU"O" A A 0f 	fBN]Nu  0123456789abcdef /  o C 2 A f 	"XᲉfBNu o "Hr p / +g -fRH  0m  	n$҂ҁҀ` -fD$ S o  NuNUH30&o 8$o <)KA ~ +HJg  | A0 h fp%f  p%f$|  l)HA0 h fp%g `  p*g+mX`R+HB/-HmHz /
N`O H JV            '~pDHHJg$@$-vfJgRJo `N `JJgSJf4 `8p  l+@)H mC 1  f -g  `R`  LN]Nu/~  l)HJg `p.Nu  /./ R  l)H.NuNU  H 0&o $o B)KHm /
HzNp lB ,L N]NuH&o ~ Jg2Sfm l^C )I^ r  ` r  HlZ/NPO" `Sfm l^C )I^p
r  `HlZHx 
NpPO"  LNu        paH./ ,/ */  /NTXO&@ fp`///+ NO ( Jgp` LNu        paH0./ Jnp `  pd.  V. GE0&R             5fg@ + m2f S$4 `n + re K$$H$%@ 4 `L$K&S` ",ЁSNJ",N", P V, F/N.XO&@ g//NJ.a TPO`p LNu              H./ G8 g4+  f(+  g  +  , Jg//+ /+ N2O &S`/NhXOLNu  H7./ &o  ,/ $J0gNB"$&,lN* pfN|)@p)@ LNu                    paH? ./ ,/  */ $J0gN$B S"$& ,lN( pfN|)@p)@    g   gJf ` І`"t v ,lNL Nu  H7./ &o  ,/ $J0gNB        	    P"$&,lN* pfN|)@p)@ LNu  H &o J 
g
"K,x N|  p'@ p + ,x N"Kp"N.LH Nu/./ J0gN&",lNp .NuH0 $ &HBHCCHBBBЂL NuJj  DJj  Da   DNua  DDNuJj  Da  DNu/HA4f  "H@HAHB4 g  0H@4 0HB2$Nu/vA d  QCA d  YCA  d  UCJAk  SC4 HBBBHC6 04HAd  SCЁdr 2HCH@A&$NuH2&o ./ p,x N,  fp `fp""<  N:$@ 
f
p N`H%K 
 @ 	|  B* F N%@  g"JN`A %H         
    9XA %H B |    
LLNu  /./ p )@Jk" l AhJ g Ah `p	)@p .Nu              NU/&o  fp `/N&@Hm/N -&mN]NuH 2&l g$S"K + ,x N.&J`)H)HLL NuH2./ pހ r ,x N:&@ fp `:'G E j 'H &Jf$J g"j "%K J$f)K$A  LLNu              H0./ &o ,/  /NXO$@ 
fp`6*  gHx B/NHO ///* NO * Jgp` LNu  NUH'0&m $m p r +@+@+@A0  g( -r
Nr tЁ+@p A0            qA  frlf
Rp+@`rhfRp+@ m N. pcgA0 x g
 m N. `pf m  p ` p @ Xg l@ g S@g*Y@g _@g  S@g BW@g U@g
W@g >` @| `6| Jg
   o$p-gr+ffp`p ,  m N. SA0 x f m  p ` B -r
N"tЁ+@ m N. SgA0 x f 
g JjDJg R - ` Jg R -0`  R ` p0mp7o m  p ` vB -"tЁ+@ m N. Sgp0mp7o 
g 4Jf R - ` " R ` Jfp+@A0 x f m  p `               ъ1W                                                                                                                                                                                                              -  ,  +  *  )  >  =  <  ;  :  9  8  7  6  5  4  I  H  G  F                &X                                                                                              
    3scopy                                                                                Fm1                  R  I      '      #   %   -   J          &         <   n   
      7           %      RH~$H$ I    ,x G  r  <  `&Q)OP)NHBLp "<  0 NCZp N)@D fpd`  &n)k DJ gh     )@ k "h  r )IXЁRBgR@UBw  Sԁ    SQ    S    Q"O/	`r)k :pRѬA \NA \N)@L/ $@ * $g,lD  @"(  )ADN"*  g$<  N)@Tg
 @'h   lL/Hl h $)h XNN bp ` / /  ,<g @NN,x "lD NbN              ӓ2                                                                                                                                                                                                              (  '  &  %  $  #  "  !         3  2  1  0  /  .                ,                                                                                              
    kconfig                                                                               .                  
C         
CNNU/HzzNnXOx` \Hz0H m /0 NPO+@Jf0H m /0 Hz[NPO` HmHm/-N\O `  /-0H m /0 HzBNO `  0H m /0 HzCNPO`  0H m /0 Hz@NPO`   -/ /-/-NO `J/-Hz?NZPO`RHzONXO`FHztNxXO`:HzNlXO`.HzN`XO`"Ԑ   d
0; N  ` 
,Hd   d
0; N  /-N NXORD0H m (N]NuCONFIG V1.02, Matthew Dillon. r+ Could not open %s for rea        $      Ո+                                                                                                                                                                                                                    
  	                            C                                                                                              
    fterm                                                                              ^p                       %   -   #   J   	      8   7      <   ,   L   I      H~$H$ I    ,x G  Pr  <  ]`&Q)O)NBp "<  0 NCZp N)@
fpd`  &n)k J gh     )@T k "h  r )IЁRBgR@UBw  Sԁ    SQ    S    Q"O/	`r)k :TpRѬTA \NA \N)@/ $@ * $g,l
 @"(  )AN"*  g$<  N)@g
 @'h   l/HlP h $)h NNp ` / /  ,|g @NN,x "l
NbNJg",gN,x N|"l              .e                                                                                                                                                                                                                                                                               8                                                                                              
    >getfiles                                                                              W                  Z     %   -   J          7      <         ZH~$H$ I    ,x G  r  <  `&Q)O)NBp "<  0 NCZp N)@fpd`  &n)k J gh     )@ k "h  r )I ЁRBgR@UBw  Sԁ    SQ    S    Q"O/	`r)k :pRѬA \NA \N)@/ $@ * $g,l @"(  )AN"*  g$<  N)@g
 @'h   l/Hl h $)h  N:Np ` / /  ,g @NNz,x "lNbNJg",gN,x N|"lN .lL~Nu              ِ>                                                                                                                                                                                                                                                                                          "                                                                                              
    	Zsprint                                                                                Ց                  C   y      '      #   %   -   J          &         <   n   
      7           %       CH~$H$ I    ,x G  0r  <   h`&Q)Op)NhBlp "<  0 NCZp N)@fpd`  &n)k dJ gh     )@4 k "h  r )IxЁRBgR@UBw  Sԁ    SQ    S    Q"O/	`r)k :4pRѬ4A \NA \N)@l/ $@ * $g,l @"(  )AdN"*  g$<  N)@tg
 @'h   ll/Hl0 h $)h xNN bp ` / /  ,\g @NN,x "lNbN        H      ܇\                                                                                                                                                                                                                           H                                                                                              
     +dnet                                                                                 1                                                                                                                                                                                                                                                          +   *   )   (   '   &                (H                                                                                              
    ssterm                                                                                ݏ5`                  2      [       I        \      n      2H~$H$ I    ,x G  \r  <  /`&Q)O)NBp "<  0 NCZp N)@+@fpd`  &n)k J gh     )@` k "h  r )IЁRBgR@UBw  Sԁ    SQ    S    Q"O/	`r)k :`pRѬ`A \NA \N)@/ $@ * $g,l+@ @"(  )AN"*  g$<  N)@g
 @'h   l/Hl\ h $)h N~N)p ` / /  ,g @NN ,x "l+@NbNTJg",gN,x N|"lN .lL            Y1~Nudos.library  o "o  / g  @`  Vf     dp NupNuL   / g c  2  f  h2	  f  ^  e  ,"  ,i  "H?>p,`  L|H?>QHA0L|2 `  # # Q   d0   f  Nu Q   dNu2  f  h2	  f  ^  e  ,"  ,i  "H?>p,`  L|H|QHA0L|2 `  ""Q   d0   f  NuQ   dNur `/  o  /    (c  `  
QNuH?>$  g  S   $BB4HB&(*,."B$B&B(B*B,Br0k  
H?~jA2< Ak  !AjA`  QL|            Nu  L  H 2,y   "|  |   |  /n E G $&    %J #O $IN/
a  6X "LL Nu o p (  g   Nu o p  h Jg   Nu o H 2$H&h ,y  *  f  + p N`N"JNN 
LL NuL  H 8$@&A   (Ot pf  Jg   *f  PB f  p`  0@)  ) RBR`SBk  0@ t JgJBk  |0@$t  RR &t R` ?f  Jf  DJBf`  P  Ae    Zb       Ae   Zb      g  
JBf`  Jf  SJf  S` :p    LNu"y  "i   g   g  H p a  @L !I Rh            ^>+ NuL `   o p  f  pNupNuL `   o p  f  NuH ",y  R.' g  2? /.// pN0/  o  fg   P`  NvLD Nu o Sh f  p !@    "f  NuL ` o p  "g  8H " ,y  R.'"g  $A* f  "j pN"fNvLDNuL H 0"@Jg  ,"QJg  $ ) 
gg  $@&H
fJ*f 	L Nup L Nu   o  PJg   Nup NuNuNuNUH2"m  i ,x N&@"m  i NJ fJk f k "m  g"KN`"K,x N.+  m J f
/( NBXO m  ( $@ " ,l+@NdY "J,x             N. LLN]Nu        paH&o  KJfS,~ Jg2S	2m l	*C )I	* r  ` r  Hl	&/NPO" `Hl	&HxNPO LNu      paNUH0&o D| A +HJg 
p% f  p r]Ak  {fN d`  P x`   p`   s`   m$X+H`J m(+HEzJk rA SS`B-` m(+H/HmN%POE/
NXO܀` ^RS	2m l	*C )I	* r  ` >p Hl	&/ N PO" ` (RS	2m l	*C )I	* r  ` p Hl	&/ N lPO" ` Hl	&HxN X LN]Nu0123456789ACDEF   /&o ",l+@NJf            mleN|)@tp)@+<p`p &_Nu            NUH/./ 4&o 8(p1 gp` p+  VD HH, J f  +  fzp '@ rg B/N#"XOJg  p` *  Jg + " D'A ` + '@ S m k C 'I  r  ` r  //a RPO"  ` +  gXpfp `  @Jg"r
fr/Hz/+ +ANO * `r/Hm/+ +ANO * ~`    JgRpgLT r
f& k C 'I  "+ Jk
// a POR  k C 'I  "+ Jk ~ +  +@gr+  gRHx B/+ NO +@Jg8Sm2B/-/+ NHx Hm/+            wYn N#O Jtf
-rg/-/+ /+ NO * `z pf  `g  Jg"+ $D'B `+  gr 'A `"+ 'A  k 'H g.S m k C 'I  r  ` r  //a PO" p0 gp`pfp ` LN]Nu
    H&o +  VD HH. p0 g
B p` X+  g+  g/HxN"POJ f6B +  gp'@ A  'H `  /N jXOJgv  p`  JgfT  + JnZ k C 'I |     g.   f2S m k C 'I p `  /a .XO`    p`   `  +  fN   /+ /+ /+ N!O *             #xJj  Jf  JoJg
 D'@ `'E  k 'H p2 gJgp'@ `p '@ p` S m k C 'I p `/a XOLNu  H 0&o $KJg$p A
U0  g
r  t `r  R` LNu        paH0&o $o ./ Jg JgJgp r , Jg `S`JgJgp`
Jgp`p LNuNUH0&o  $o $./ ( JJfS, KJfS "K+Ic,  J`Sd mB0h  LN]Nu"o  o  JfSfNu  /&o p A
U0  gR` &_Nu /  o NU"Or
N4A 0Jf 	fBN]Nu   /  o NU"O" A A 0        	    Ez^f 	fBN]Nu  0123456789abcdef /  o C 2 A f 	"XᲉfBNu o "Hr p / +g -fRH  0m  	n$҂ҁҀ` -fD$ S o  NuNUH30&o 8$o <)K*A ~ +HJg  | A
U0 h fp%f  p%f$|  l*)H*A
U0 h fp%g `  p*g+mX`R+HB/-HmHz /
N\O H JVDHHJg$@$-vfJgRJo `N `JJgS*Jf4 `8p  l*+@)H* mC
U 1  f -g  `R`  LN]Nu/~  l*)H*Jg `p.Nu  /./ R*  l*        
    {Ą)H*.NuNU  H 0&o $o B*)K*Hm /
HzNl l*B ,*L N]NuH&o ~ Jg2S	2m l	*C )I	* r  ` r  Hl	&/NPO" `S	2m l	*C )I	*p
r  `Hl	&Hx 
NPO"  LNu  /./ R*S	2m l	*C )I	* r  ` r  Hl	&/NPO" .NuNU  /&o B*Hm /HzNHl	&HxNd ,*&mN]Nu  NUH0&o :./ >B-Bt+l+<zl A)J gR` ,谅fp)@+<p` * A)$HJ g-  g
+|  `+|   <   	  g @.  G  r   g   gJf,R`p                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               )Ț                                                                                                                                                                                                                           o   n                  ~   }   |   {   z   y                                                                                                                           
    quitdnet                                                                              lQ6                     4   =  5    H~$H$ I    ,x G  hr  <   `&Q)O)NBp "<  0 NCZp N)@ fpd`  &n)k J gh     )@l k "h  r )IЁRBgR@UBw  Sԁ    SQ    S    Q"O/	`r)k :lpRѬlA \NA \N)@/ $@ * $g,l  @"(  )AN"*  g$<  N)@g
 @'h   l/Hlh h $)h NNRp ` / /  ,g @NN*,x "l NbNdJg",gN,x N|"lN .lL~Nudos.library L  H 2,y   "              %6                                                                                                                                                                                       ]   \   [   Z   Y   X   m   l   k   j   i   h   g   f   e   d   c   r   q   p   x   w   v   u   t   s                2                                                                                              
    putfiles                                                                              sx                  >  o      D   %   ,   U          7         >H~$H$ I    ,x G  r  <  `&Q)O)NBp "<  0 NCZp N)@	tfpd`  &n)k J gh     )@ k "h  r )I ЁRBgR@UBw  Sԁ    SQ    S    Q"O/	`r)k :pRѬA \NA \N)@/ $@ * $g,l	t @"(  )AN"*  g$<  N)@g
 @'h   l/Hl h $)h  NN2p ` / /  ,g @NN
,x "l	tNbNxJg",gN,x N|"lN .lL~Nu              쒌4&                                                                                                                                                                                               I   H   G   F   E   D   C   B   W   V   U   T   S   R   Q   P   O   N   M   ^   b   a   `   _                /                                                                                              
    >scli                                                                                _3                  O         '      "      &         D   %   ,   U      8   n  .    OH~$H$ I    ,x G  r  <  k`&Q)OL)NDBHp "<  0 NCZp N)@fpd`  &n)k @J gh     )@ k "h  r )ITЁRBgR@UBw  Sԁ    SQ    S    Q"O/	`r)k :pRѬA \NA \N)@H/ $@ * $g,l @"(  )A@N"*  g$<  N)@Pg
 @'h   lH/Hl h $)h TNN bp ` / /  ,8g @NN,x "lNbNJHg",PgN,x                                                                                                                                                                                      %   $   #   "   !   6   5   4   3   2   1   0   /   .   -   ,   A   @   ?   >   =   <   ;   :   9   8   7   K   J   L                9h                                                                                              
    2sgcopy                                                                                 '^                                                                                                                                                                                                                                                                                                                                                                         
    statdnet                                                                              Lz(                  :  $      '      #   %   -   J          &   \         <      n          
      7              %  	    :H~$H$ I    ,x G  0r  <  `&Q)Op)NhBlp "<  0 NCZp N)@&fpd`  &n)k dJ gh     )@4 k "h  r )IxЁRBgR@UBw  Sԁ    SQ    S    Q"O/	`r)k :4pRѬ4A \NA \N)@l/ $@ * $g,l& @"(  )AdN"*  g$<  N)@tg
 @'h   ll/Hl0 h $)h xNN bp ` / /  ,\g @N             &>                          '      #   %   -   #   J   	      8   &      <   
      7       /          <       H~$H$ I    ,x G  r  <   ~`&Q)O)NBp "<  0 NCZp N)@fpd`  &n)k J gh     )@ k "h  r )I ЁRBgR@UBw  Sԁ    SQ    S    Q"O/	`r)k :pRѬA \NA \N)@/ $@ * $g,l @"(  )AN"*  g$<  N)@g
 @'h   l/Hl h $)h  NN bp ` / /  ,g @NN,x "l                                                                                                                                                                                                                               
   	                                                          ,                                                                                              
    spasswd                                                                               fV                  v        '      #   %   -   #   J          8   &      <   n   
      7           %  v    vH~$H$ I    ,x G  r  <   `&Q)O)NBp "<  0 NCZp N)@fpd`  &n)k J gh     )@ k "h  r )IЁRBgR@UBw  Sԁ    SQ    S    Q"O/	`r)k :pRѬA \NA \N)@/ $@ * $g,l @"(  )AN"*  g$<  N)@g
 @'h   l/Hl h $)h NN bp ` / /  ,g @NN*,x "lNb              6                                                                                                                                                                                                                                                        3D                                                                                              
    
cliterm                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Ek                    ,   %   -   #   J   	      8   7      <  2    H~$H$ I    ,x G  r  <  N`&Q)O)NBp "<  0 NCZp N)@fpd`  &n)k J gh     )@ k "h  r )IЁRBgR@UBw  Sԁ    SQ    S    Q"O/	`r)k :pRѬA \NA \N)@/ $@ * $g,l @"(  )AN"*  g$<  N)@g
 @'h   l/Hl h $)h NNp ` / /  ,g @NNb,x "lNbNJg",gN,x N|"lN .lL            ]oB                     >   ,  -    H~$H$ I    ,x G  Hr  <  `&Q)O)NBp "<  0 NCZp N)@fpd`  &n)k |J gh     )@L k "h  r )IЁRBgR@UBw  Sԁ    SQ    S    Q"O/	`r)k :LpRѬLA \NA \N)@/ $@ * $g,l @"(  )A|N"*  g$<  N)@g
 @'h   l/HlH h $)h NNRp ` / /  ,tg @NN*,x "lNbNdJg",gN,x N|"lN .lL~Nudos.library L  H 2,y   "            GQ)|  |   |  /n E G $&    %J #O $IN/
a  6X "LL Nu o p (  g   Nu o p  h Jg   Nu o H 2$H&h ,y  *  f  + p N`N"JNN 
LL NuL  H 8$@&A   (Ot pf  Jg   *f  PB f  p`  0@)  ) RBR`SBk  0@ t JgJBk  |0@$t  RR &t R` ?f  Jf  DJBf`  P  Ae    Zb       Ae   Zb      g  
JBf`  Jf  SJf  S` :p    LNu"y  "i   g   g  H p a  @L !I Rh NuL `   o p              Kf  pNupNuL `   o p  f  NuH ",y  R.' g  2? /.// pN0/  o  fg   P`  NvLD Nu o Sh f  p !@    "f  NuL ` o p  "g  8H " ,y  R.'"g  $A* f  "j pN"fNvLDNuL H 0"@Jg  ,"QJg  $ ) 
gg  $@&H
fJ*f 	L Nup L Nu  NuNuH&o  KJfS,~ Jg2S m l C )I  r  ` r  Hl /NvPO" `Hl HxNdPO LNu      paNUH0&o D| A +HJg 
p% f  p r]Ak  {fN d`  P x`   p            2[ `   s`   m$X+H`J m(+HEzJk rA SS`B-` m(+H/HmNPOE/
NXO܀` ^RS m l C )I  r  ` >p Hl / N jPO" ` (RS m l C )I  r  ` p Hl / N 4PO" ` Hl HxN   LN]Nu0123456789ACDEF   NUH/./ 4&o 8(p1 gp` p+  VD HH, J f  +  fzp '@ rg B/NXOJg  p` *  Jg + " D'A ` + '@ S m k C 'I  r  ` r  //a RPO"  ` +  gXpfp `  @Jg"r
fr/Hz            C/+ +AN	O * `r/Hm/+ +AN	O * ~`    JgRpgLT r
f& k C 'I  "+ Jk
// a POR  k C 'I  "+ Jk ~ +  +@gr+  gRHx B/+ NO +@Jg8Sm2B/-/+ NHx Hm/+ NPO J`f
-rg/-/+ /+ NO * `z pf  `g  Jg"+ $D'B `+  gr 'A `"+ 'A  k 'H g.S m k C 'I  r  ` r  //a PO" p0 gp`pfp ` LN]Nu
          paH 0&o $KJg$p A 0  g
r  t `            N47vr  R` LNu        paH0&o $o ./ Jg JgJgp r , Jg `S`JgJgp`
Jgp`p LNuNUH0&o  $o $./ ( JJfS, KJfS "K+Ic,  J`Sd mB0h  LN]Nu /  o NU"Or
NA 0Jf 	fBN]Nu   /  o NU"O" A A 0f 	fBN]Nu  0123456789abcdef /  o C 2 A f 	"XᲉfBNu o "Hr p / +g -fRH  0m  	n$҂ҁҀ` -fD$ S o  Nu/./ R  l)H.NuNU  H 0&o $o B)KHm /
Hz              T                                                                                                                                                                                                                                                                                                          F                                                                                              
     	version.h                                                                            
@
#ifdef LATTICE
#define VERSION 	    "2.10L"
#else
#define VERSION 	    "2.10M"
#endif

#define DNET_VERSION	    ".11"
#define STATDNET_VERSION    ".04"
#define PUTFILES_VERSION    ".03"
#define LOADAV_VERSION	    ".05"
#define FTERM_VERSION	    ".04"
#define QUITDNET_VERSION    ".01"
#define GETFILES_VERSION    ".02"
#define CLITERM_VERSION     ".01"

#define SPRINT_VERSION	    ".01"
#define SGCOPY_VERSION	    ".01"
#define SCOPY_VERSION	    ".03"
#define STERM_VERSION	    ".03"
#de                 =                                                                                            5  B  D                                                                              f                                  h                                                                                                                                                                          
    unix                                                                                         f                                                                                                                                                                                                                                                                                                                                                                                                         
    lib                                                                                        -L
                                                                                                                                                                                                                                                                                                             *                                                                                              
    KMakefile                                                                             *    4

dnetlib.o : dnetlib.c
	cc -c dnetlib.c

                                          @      C  L      t                                                                                                                                                                                                                                                                                        
     Namiga                                                                                     S˕                                                                                                                                                                                                                                                                                                                                                                                  
    	dnetlib.c                                                                            7L
/*
 *  DNETLIB.C
 *
 *	DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
 *
 *  Library Interface for DNET.
 */

#include <sys/types.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <errno.h>
#ifdef O_CREAT
#include <sys/file.h>
#endif
#include "../lib/dnetlib.h"

extern char *getenv();

typedef unsigned short uword;
typedef unsigned long ulong;
typedef unsigned char ubyte;
typedef struct sockaddr SOCKADDR;

typedef struct {
	in              S                                                                                                                                                                                                                                                                                                             4                                                                                              
    	dnetlib.h                                                                           4    
#define EFATAL 0
#define EWARN 1
#define EDEBUG 2

fopen(buf, "a")) {
	strcpy(buf, ctime(&dtime));
	buf[strlen(buf)-1] = 0;
	fprintf(fi, "%s ", buf);
	fprintf(fi, ctl, arg);
	putc('\n', fi);
	fclose(fi);
    }
    if (how == EFATAL)
	exit(1);
}

s' && *op != 'd') {
		switch(*op) {
		case 'h':
		    isshort = 1;
		    break;
		case 'l':
		    isshort = 0;
		    break;
		default:
		    return(-1);
		}
		++op;
	    }
	    switch(*op) {
	    case 's':
		if (ptr[1]) {
		    *(char **)*ap              `                                                                                                                                                                                                                                                                    
  	                  6                                                                                              
    aREADME                                                                               .ֺQ

			   DNET V2.10 UNIX SIDE

			   BSD4.2/4.3 compatible

	Special note this release: default is to run in 7 bit mode (which
	uses a special 6 bit encoding to encode binary data).  The -m0
	option has been added for those who can run over full 8 bit nets.

	DNET (c)Copyright 1987-1989 Matthew Dillon, All Rights Reserved

	Matthew Dillon
	891 Regal Rd
	Berkeley, Ca. 94708
	USA

	...!ihnp4!ucbvax!dillon 	USENET
	dillon@ucbvax.Berkeley.edu	ARPANET
	ucbvax.berkeley.edu pub/amiga	ARPANET            	n-FTP

				UNIX SETUP

	The directory structure must remain intact.  simply say MAKE
	in the main directory and it ought to compile.	There might be
	minor problems depending on how compatible your UNIX is with
	BSD4.3 UNIX ..	I have successfully compiled DNet on the following
	machines:

		    Dec Vax 7xx
		    Sun 3
		    Sequent

	(1) Create a directory.  For example, ~/.DNET   WARNING!  This
	    directory must be on a local partition.  DNET uses a unix
	    domain socket and these            
jW do not work over network fileservers.

	(2) Modify your .cshrc to add the following line:

	    setenv DNETDIR  ~/.DNET/

	    (or wherever you put it.  NOTE! You MUST HAVE THE TRAILING
	     SLASH!)

	(3) All binaries are usually kept in dnet.unix/bin, add this
	    directory to your path (in your .cshrc) so DNet can find
	    the clients.

	(4) Place the file 'dnet.servers' in $DNETDIR.  Modify the file
	    according to your home directory and where you have put the
	    servers             (usually in dnet.unix/bin).  USE ABSOLUTE PATHS,
	    DNET.SERVERS DOES NOT UNDERSTAND ~.

	NOTE: You may want to chmod $DNETDIR 700 to disallow any
	unauthorized access to the network.


			     DIALING UP FROM AN AMIGA

	Follow the installation instructions for the Amiga side.  When
	you dial up the UNIX system you will eventually get a prompt.
	NOTE!  DNET normally uses 7 bit - even parity for dialing up,
	then switches to 8 bit no parity for the protocol.  Sometimes
	the modem or            ?Kv port selector will switch into 7 bit + parity mode
	and NOT SWITCH OUT.  For this reason, you might want to use the
	-8 option for the Amiga side of DNET (read the docs in the Amiga
	section).

	You may have to force parity before running DNet.  To force parity
	to even use (and do this only if running the -Z2 option from the
	Amiga side dnet):	      THIS IS NOT NORMALLY DONE.

	% stty -odd

	From the DNET window's CSH prompt, start the protocol with:

	% dnet

	That was easy.	The D            ָNet window should go away and an FTERM window
	should open.  This does not mean success!  If the FTERM window
	closes again with the message "unable to connect", it was unable
	to connect.  There are several possibilities:

	(a) You do not have an 8 bit connection from your amiga to the
	    UNIX host (DNet must be able to send and receive all 256
	    character codes).

	(b) You did not setup the DNETDIR enviroment variable properly

	(c) You did not copy dnet.servers into $DNETIDR
            
	(d) The absolute file path in dnet.servers for server #8192 (that
	    FTerm tires to connect to) is not correct.

				    KILLING DNET

	In most cases simply turning off the modem will suffice.  You can
	kill dnet more cleanly with the following sequence:

	(1) From an Amiga CLI, run the QuitDnet command.  This will kill
	    the packet protocol and cause the remote DNet to exit.  It
	    will then break the local DNet.

	    You should get the original (small) DNet window and the            h4
	    original login shell. If you get the DNet window but not the
	    shell (you can't type), the protocol may still be running on
	    the other end, in which case it didn't work for some unknown
	    reason.  Restart the protocol w/ the appropriate menu option
	    and try 'quitdnet' again.

	(3) logout normally and close the DNet window.  Turn off your
	    modem.

	    If the kill sequence in (2) does not work, you can simply
	    hangup the line.

			     HANGING SERVER PROCES        	    hSES

	The UNIX side servers are normally left running when the protocol
	dies.  These are very very very small and take 0 CPU (they are
	simply waiting for connections).  These servers will still be
	there when you log in again and DNet will use them.

	You can kill UNIX side servers at any time.

	Many of the same clients and servers exist on the UNIX end as
	on the Amiga end.  The UNIX end is missing several.  The UNIX
	end implements two commands called dsoc and draw which can be
        
    	used to connect to (in cooked or raw tty mode) specific servers
	(by port #) on the Amiga side.  For example, to connect to the
	printer server on the amiga side:

	% dsoc 8198
	This is a test
	^D
	%

	Dumps to PRT: on the Amiga "This is a test"  Gee Wiz!

				SECURITY W/ UNIX

	DNet will be as secure as your account, assuming you chmod DNETDIR
	700 (so nobody else has access to the unix domain sockets).  From
	Home (on the Amiga), I usually RUN DNET -X , login, start the
	protocol,          &     and leave it running all day.

	The -X option turns of security (sets all security levels to 9),
	thus allowing me to drive to the university and at any time from
	my UNIX account do a getfiles or putfiles from and to my Amiga.

	Refer to the amiga side documentation for more information.



me.

	Many of the same clients and servers exist on the UNIX end as
	on the Amiga end.  The UNIX end is missing several.  The UNIX
	end implements two commands called dsoc and draw which can be
              bjT                                                                                                                                                                                                                                                                                                                                                                                                           
    .info                                                                                   lJL   
    README
ll day.

	The -X option turns of security (sets all security levels to 9),
	thus allowing me to drive to the university and at any time from
	my UNIX account do a getfiles or putfiles from and to my Amiga.

	Refer to the amiga side documentation for more information.



me.

	Many of the same clients and servers exist on the UNIX end as
	on the Amiga end.  The UNIX end is missing several.  The UNIX
	end implements two commands called dsoc and draw which can be
              F4                                                                                                                                                                                                                                                                                                  

                                                                                              
    oREADME.info                                                                          |G        b     % &                  L  ]                           b                            EUUUU@        E_UU@        EVUUE        EVgG        EVggeG        EVffEG        EVfuG        E_G        ETG        EUUUUG        EuuUG        EQqUG        Euq}G        EqqG        EqqG        EqqG        Eyy}G        EAAAG        EUUUUG        EUUUUG        EUUUUG        EUUUUG        EUU@G        EUUUUG                     /        UUUUU                 &
                                                                                                                                                !                              #                                                                      %                                                                                                                                          
    Userver                                                           '                       ]#                                                                                                                                                                                      }                                                                  2~                                                                                              
    snfs.c                                                                               }
/*
 *  SNFS.C	 V1.1
 *
 *  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
 *
 *  NETWORK FILE SYSTEM SERVER
 *
 *  Accepts connections to files or directories & read-write or dir-scan calls.
 */

#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/dir.h>
#include <sys/file.h>
#include <sys/resource.h>
#include <stdio.h>
#include <errno.h>
#include <signal.h>

#include "servers.h"
#include "snfs.h"

/* #define DEBUG */
              /                                                                                                                                                                                                                                                                                                        !                                                                                              
    sshell.c                                                                             ɩ
/*
 *  S_SHELL.C		OBSOLETE OBSOLETE OBSOLETE
 *
 *	DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
 *
 *   Connect a csh to a pseudo terminal pair... PORT_ALPHATERM
 *   NOTE!!  PORT_IALPHATERM (a pseudo-terminal csh) is also available
 *   through the FTERM client program on the Amiga side, and much faster
 *   since the server for PORT_IALPHATERM is DNET itself (one less process
 *   to go through).
 *
 *	-doesn't handle SIGWINCH
 *	-doesn't handle flow control ... don              ]                                                                                                                                                                                                                                                                                      ~                Q                                                                                              
    snfs.h                                                                               ~eE
#define ulong unsigned long
#define ubyte unsigned char
#define uword unsigned short

typedef struct {
    long    ds_Days;
    long    ds_Minute;
    long    ds_Tick;
} STAMP;

typedef struct {
    long    DirHandle;		/*  relative to directory (0=root)  */
    uword   Modes;		/*  open modes			    */
} OpOpen;

typedef struct {
    long    Handle;
    ulong   Prot;
    long    Type;
    long    Size;
    STAMP   Date;
} RtOpen;


typedef struct {
    long    Handle; 	/*  file handle              ]                                                                                                                                                                                                                                                                      r                          	                                                                                              
    Rscopy.c                                                                              g{
/*
 *	SCOPY.C
 *
 *	DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
 *
 *	Remote file copy server (putfiles is the client program)
 */

#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/file.h>
#include <sys/resource.h>
#include <stdio.h>
#include <errno.h>
#include <signal.h>

#include "servers.h"
#include "../lib/dnetlib.h"

char Buf[4096];

chandler()
{
    union wait stat;
    struct rusage rus;
    while (wait3(&s               Q7                                                                                                                                                                                                                                                                                                                                                                                                           
    	servers.h                                                                              A
/*
 *  SERVERS.H
 *
 *	DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
 */

#define PORT_FILECOPY	8192
#define PORT_ALPHATERM	8193
#define PORT_ECHO	8194
#define PORT_IALPHATERM 8195
#define PORT_AMIGATERM	8195
#define PORT_AMIGASHELL 8196
#define PORT_LOADAV	8197
#define PORT_PRINTER	8198
#define PORT_PASSWD	8199
#define PORT_BBS	8200
#define PORT_GFILECOPY	8201
#define PORT_NFS	8202
#define PORT_ND		8203


Y';
	    gwrite(chan, &co, 1);
	    goto fail;
	default:
	    c     !         "%2                                                                                                                                                                                                                                                  g  w  v  u  t  s  |  {  z  y  x  "              V                                                                                              
    Osgcopy.c                                                                      !       x'I
/*
 *  SGCOPY.C	 V1.1
 *
 *  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
 *
 *  GET-COPY SERVER	(NEW COPY SERVER)
 *
 *  The current version only accepts one connection at a time.	This server
 *  will send requested files to the remote machine.
 *
 *  length in 68000 longword format.
 */

#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/dir.h>
#include <sys/file.h>
#include <sys/resource.h>
#include <stdio.h>
#in     #         $-K                                                                                                                                                                                                                                                                                          o  $                                                                                                            
    Makefile                                                                      #       oQ
#	DNET SERVERS
#
#
#	DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved

NETLIB = ../lib/dnetlib.o
BIN = ../bin


all:	$(NETLIB) $(BIN)/scopy $(BIN)/sshell \
	$(BIN)/sloadav $(BIN)/sgcopy $(BIN)/snfs

$(NETLIB) : ../lib/dnetlib.c
	cc -c ../lib/dnetlib.c
	mv dnetlib.o ../lib

$(BIN)/snfs:		snfs.o
	cc snfs.o $(NETLIB) -o $(BIN)/snfs

$(BIN)/scopy:		scopy.o
	cc scopy.o $(NETLIB) -o $(BIN)/scopy

$(BIN)/sgcopy:		sgcopy.o
	cc sgcopy.o $(NETLIB) -o $(BIN)/sgcopy

$(BIN)/snfs:		sn     %         &fR                                                                                                                                                                                                                                                                                      h  q  &                                                                                                            
    	sloadav.c                                                                     %       qlN
/*
 *	SLOADAV.C
 *
 *	DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
 *
 *	Reports the load average every 5 minutes or until the connection
 *	is closed.
 */

#include <stdio.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <errno.h>
#include <signal.h>

#include "servers.h"

chandler()
{
    union wait stat;
    struct rusage rus;
    while (wait3(&stat, WNOHANG, &rus) > 0);
}

main(ac,av)
char *av[];
{
    long chann = DListen(PORT_LOA     '            -u                                      (  *                  ,                                                                                                          .      0      2                                                                                                                                                                                                                  
     client                                                                           (         )lݽ                                                                                                                                                                                                                                                                                  k  j  i  )              Q                                                                                              
    	draw.c                                                               '         (       i
/*
 *	DRAW.C
 *
 *	DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
 *
 *	DRAW [port#]
 *
 *	Put terminal into RAW mode and connect to the remote dnet port.
 *	used mainly to test DNET.  Can also be used open a TERM window on
 *	the amiga (via the STERM server), which is the default (port 8195)
 */



#include <sys/types.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <sys/file.h>
#include <signal.h>
#include <errno.h>
#include "../server/servers.h"

int fd;
char bu     *         + U                                                                                                                                                                                                                                  f  e  d  c  b  a  `  _  ^  ]  \  p  n  m  l  +                                                                                                            
    

getfiles.c                                                           '         *       lC#@
/*
 *  GETFILES.C	    V1.30
 *
 *  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
 *
 *  GETFILES [-dlocaldir] [-c] file/dir file/dir file/dir
 *
 *  -dlocaldir	local directory to place files
 *
 *  -c		Continue from where you left off before.  Files that already
 *		exist on the local machine will not be re-transfered.  This
 *		will also re-start in the middle of a file that was
 *		partially transfered previously.
 *
 *		This command assumes the file(s) on both mach     ,         -KE                                                                                                                                                                                                                                                                  W  V  U  T  S  R  Q  -                                                                                                            
    6
putfiles.c                                                           '         ,       QB
/*
 *  PUTFILES.C
 *
 *	DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
 *
 *  Download one or more files from the remote computer
 *
 *  PUTFILES file/dir1 file/dir2 ... file/dirN
 *
 *  placed in directory server ran from on remote host.
 */

#include <sys/types.h>
#include <sys/stat.h>
#include <sys/dir.h>
#include <stdio.h>
#include <sys/file.h>
#include "../server/servers.h"

char Buf[1024];

typedef struct stat STAT;

main(ac,av)
char *av[];
{
    long chan;
    lo     .         /+,]                                                                                                                                                                                                                                                                                          Y  /              \                                                                                              
    dprint.c                                                             '         .       Y'
/*
 *  DPRINT.C
 *
 *	DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
 *
 *  send files to the other computer's printer.
 *
 *  DPRINT [files]	(stdin if no files specified)
 */

#include <stdio.h>
#include "../server/servers.h"

main(ac,av)
char *av[];
{
    register short i;
    long chan;

    chan = DOpen(NULL, PORT_PRINTER, -80, 126);
    if (chan < 0) {
	puts("Unable to connect");
	exit(1);
    }
    for (i = 1; i < ac; ++i) {
	FILE *fi;

	printf("%-20s ", av[i]);
	     0         1l                                                                                                                                                                                                                                                                                      X  [  1                                                                                                            
     dsoc.c                                                               '         0       [L}Ձ
/*
 *	DSOC.C
 *
 *	DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
 *
 *	DSOC [port#]
 *
 *      Connect to the specified port# .. Used to connect to a remote CLI
 *	(s_shell server on the Amiga, which requires PIPE: to work, port 8196,
 *	is the default)
 *
 *	Uses standard cooked mode instead of RAW mode.
 */


#include <sys/types.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <sys/file.h>
#include <signal.h>
#include <errno.h>
#include "../server/servers.h"

in     2         3-L                                                                                                                                                                                                                                                                                          4  3              F                                                                                              
    Makefile                                                             '         2       4zƪ
#	DNET CLIENTS
#
#   DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
#

NETLIB = ../lib/dnetlib.o
BIN = ../bin


all:	$(NETLIB) $(BIN)/draw $(BIN)/dsoc $(BIN)/putfiles $(BIN)/dprint \
	$(BIN)/getfiles

$(BIN)/draw:		draw.o
	cc draw.o $(NETLIB) -o $(BIN)/draw

$(BIN)/dsoc:		dsoc.o
	cc dsoc.o $(NETLIB) -o $(BIN)/dsoc

$(BIN)/getfiles:    	getfiles.o 
	cc getfiles.o $(NETLIB) -o $(BIN)/getfiles

$(BIN)/putfiles:    	putfiles.o 
	cc putfiles.o $(NETLIB) -o $(BIN)/putfiles

     2      ^    <$(BIN)/dprint:		dprint.o
	cc dprint.o $(NETLIB) -o $(BIN)/dprint

clean:
	rm -f *.o make.out

                                                                                                                                                                                            Y  /              \                                                                                              
    dprint.c                                                             '         5            NA                                                              6                                                      8                                                              :          <  >  @                                                                                                                                                                                                  
    doc                                                                              6         7 l                                                                                                                                                                                                                                                                                          Z  7                                                                                                            
    dnet.doc                                                             5         6       Z{4l
UNIX/DNET

	DNET [debug] [-m0]

NEW Nov 89:  DNet for both UNIX and AMIGA sides default to 7 bit packet
	     mode.  If you are running on an 8 bit network use the
	     -m0 option to defeat 6 bit encoding used to send binary on
	     a 7 bit network.

	Run the DNET protocol on descriptor 0.  If the enviroment variable
	DNETDIR exists, DNET will create the rendezvous sockets in the
	specified directory (DNETDIR must have a hanging slash on it),
	otherwise the current directory is us     8         91ln                                                                                                                                                                                                                                                                                          F  9              `                                                                                              
    -dsoc.doc                                                             5         8       F{

UNIX/DSOC


DSOC [port#]

	(default: 8196 = AMIGSHELL (CLI window))

	Connect to the remote port but keep the TTY in COOKED mode (normal).
	The connection will be terminated by killing the process on the UNIX
	end or typing ^C.  NOTE THAT ^C KILLS DSOC AND IS NOT SENT THROUGH TO
	THE REMOTE CLI.

	The default port accesses the SCLI server on the Amiga end, which
	starts up a CLI.  Things work properly only if *MY* PIPE: device is
	installed on the Amiga.  Things close down properly     :         ;QR$                                                                                                                                                                                                                                                                  K  J  I  H  G  P  O  ;                                                                                                            
    dnetlib.doc                                                          5         :       Oz
UNIX/DNETLIB

	UNIX END DNET LIBRARY INTERFACE

	See the server source for good examples of usage.

long	private;
uword	port
char 	*buf;
int 	fd;
int	res1..5, bytes
char	pri;
long	val68, valvax;

private	= DListen(port)				listen on a port (server)
     fd = DAccept(private)			accept a connection (server)
	  DNAAccept(private)			don't accept a conn.(server)
     fd = DOpen(host, port, txpri, rxpri)	open a remote connection (client)
   res1 = read(fd, buf, bytes)			standard unix read     <         =                                                                                                                                                                                                                                                                                          L  =              |                                                                                              
    putfiles.doc                                                         5         <       L_UNIX/PUTFILES
AMIGA/PUTFILES

	PUTFILES [-dDESTDIR] file/dir file/dir file/dir ..

	File transfer client.  Transfer the specified files and or directories
	to the destination directory on the remote machine.  For instance:

	unix:  putfiles -dram: charlie.txt /usr/include

	*places the file charlie.txt as ram:charlie.txt, and places the 
	 directory structure /usr/include as ram:include/(whatever).

	The default destination directory depends on the remote host.  If the
	destination i     >         ?'                                                                                                                                                                                                                                                                                              ?                                                                                                             
    history                                                              5         >          LH*
    V1.00   sometime in 1987
	    First release

    V1.20   sometime in 1988
	    Fixes to the first release

    V2.00   1 March 1989

	    Major fixes, additions, and other items.



ression is done.  I also hope to add 
	semi-automatic crash recovery (continue download where you left off
	after a crash), though it should be noted that it is very difficult
	to crash DNET with random modem noise.

  -dsoc.doc                                                             5         @         Al                                                                                                                                                                                                                                                                                              A              m                                                                                              
    draw.doc                                                             5         @     m    b
UNIX/DRAW


DRAW [port#]

	(default: 8195 = AMIGTERM (talk window))

	Connect to the remote port and place the TTY in RAW mode.  The
	connection can only be terminated by the remote end, or by killing
	the process on the UNIX end.

	The default port brings up a 'talk' window on the Amiga.  AMIGATERM
	will recognize a ^C sent from DRAW and close the connection.

                                 
    doc                                                                              B         Ck                                                                                                                                                                                                                                                                                              C               K                                                                                              
    8MAKE                                                                          B      K    Ck#!/bin/sh
cd lib
make
cd ../dnet
make
cd ../client
make
cd ../server
make

                       5  B                                                                                                                                                                                                                                                                                                  
    unix                                                                             D            &E                          E                  G              I  K                                                          M  O                          Q                          S      V      X                      Z                                  \              ^      d                                                                                                              
    dnet                                                                             E         FlX                                                                                                                                                                                                                                  1  0  E  D  C  B  A  @  ?  >  =  <  ;  N  M  F              s                                                                                              
    dnet.c                                                               D         E       MG
/*
 *  DNET.C
 *
 *	DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
 *
 *	Handles action on all active file descriptors and dispatches
 *	to the proper function in FILES.C
 *
 */

#include "dnet.h"
#include <sys/wait.h>
#include <sys/resource.h>
#include <sys/un.h>

handle_child()
{
    union wait stat;
    struct rusage rus;
    while (wait3(&stat, WNOHANG, &rus) > 0);
}

char *
showselect(ptr)
fd_set *ptr;
{
    static char buf[FD_SETSIZE+32];
    short i;

    for (i      G         Hl                                                                                                                                                                                                                                          (  '  &  %  :  9  8  7  6  5  4  3  2  H                                                                                                            
    dnet.h                                                               D         G       2P<
/*
 *  DNET.H
 *
 *	DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
 */

#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/file.h>

/* V2.01 */
#include <sys/param.h>
#include <pwd.h>

#include <signal.h>
#include <stdio.h>
#include <errno.h>
#ifndef FD_SETSIZE
#define FD_SETSIZE (sizeof(struct fd_set) * 8)
#endif
#ifndef NFDBITS
#define NFDBITS 32
#define	FD_SET(n, p)	((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFD     I         J	y                                                                                                                                                                                                                                                                              ,  +  *  )  J              	:                                                                                              
    ]
dataconv.c                                                           D         I       )
/*
 *  DATACONV.C
 *
 *  Data Conversion.
 */

typedef unsigned char ubyte;
typedef unsigned short uword;
typedef unsigned long ulong;

extern ubyte DDebug;

int
Compress7(s, db, n)
ubyte *s;
ubyte *db;
uword n;    /*	actual source bytes */
{
    ubyte *d = db;

    while (n) {
	*d++ = *s++ << 1;

	if (--n == 0)
	    break;
	d[-1] |= *s >> 6;
	*d++ = *s++ << 2;

	if (--n == 0)
	    break;
	d[-1] |= *s >> 5;
	*d++ = *s++ << 3;

	if (--n == 0)
	    break;
	d[-1] |= *s >> 4;
	*d++ = *s     K         LYz                                                                                                                                                                                                                                                                                /  .  -  L                                                                                                            
    	channel.h                                                            D         K       -~
/*
 *  CHANNEL.H
 *
 *	DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
 *
 *  Channel structures for SCMD_* channel commands.
 *
 *  NOTE: These structures may be ONLY 0,2,4, or 6 bytes in size.
 */

#define CSWITCH struct _CSWITCH
#define COPEN	struct _COPEN
#define CCLOSE	struct _CCLOSE
#define CACKCMD struct _CACKCMD
#define CEOFCMD struct _CEOFCMD
#define CIOCTL  struct _CIOCTL

CSWITCH {		/*  SWITCH current data channel */
    ubyte   chanh;	/*  channel to switch to     M         Nz                                                                                                                                                                                                                                                                                             N                                                                                                            
    s	DMakefile                                                            D         M        x
#	THE DNET DRIVER, UNIX END
# 
# 	DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
#
#	the BIN should be placed in your path for ease of use.  DNET uses 
#	UNIX level sockets allowing multiple users on a system to run it
#	independantly.  You should make a special directory (Example: .DNET)
#	and then setenv DNETDIR ~/.DNET/  ... all clients and servers will
#	use the enviroment variable to find/create the UNIX level sockets.

BIN	= ../bin
SRCS	= dnet.c control.c files.c      O         P]s                                                                                                                                                                                                                                            !            $  #  "  P               7                                                                                              
    subs.c                                                               D         O       "q5+M
/*
 *  SUBS.C
 *
 *	DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
 *
 *	Support subroutines
 *
 */

#include "dnet.h"

/*
 *   WRITESTREAM()
 *
 *	Queues new SCMD_?? level commands to be sent
 */

WriteStream(sdcmd, buf, len, chan)
ubyte *buf;
uword chan;
{
    register XIOR *ior = (XIOR *)malloc(sizeof(XIOR));

    if (DDebug)
	printf("-writestr cmd %ld (%ld bytes chan %ld)\n", sdcmd, len, chan);

    ior->io_Data = (ubyte *)malloc(len);
    ior->io_Length = len;
         Q         R%                                                                                                                                                                                                                                                                                R                                                                                                            
    	9files.c                                                              D         Q       5E2
/*
 * FILES.C
 *
 *	DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
 *
 *	handles actions on a per file descriptor basis, including accepting
 *	new connections, closing old connections, and transfering data
 *	between connections.
 */

#include "dnet.h"

extern void do_localopen(), do_connect(), do_open1(), do_openwait(), do_open();

/*
 *  new connection over master port... open request.  read two byte port
 *  number, allocate a channel, and send off to the remote
 */     S         T-K                                                                                                                                                                                                                                                                                          U  T              r                                                                                              
    	Makefile                                                             D         S       U{
#	THE DNET DRIVER, UNIX END
# 
# 	DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
#
#	the BIN should be placed in your path for ease of use.  DNET uses 
#	UNIX level sockets allowing multiple users on a system to run it
#	independantly.  You should make a special directory (Example: .DNET)
#	and then setenv DNETDIR ~/.DNET/  ... all clients and servers will
#	use the enviroment variable to find/create the UNIX level sockets.

BIN	= ../bin
OBJS	= dnet.o control.o files.o      S          \globals.o net.o subs.o internal.o \
	  dataconv.o packet.o

$(BIN)/dnet:	$(OBJS)
	cc $(OBJS) -o $(BIN)/dnet

clean:	
	rm -f *.o make.out

                                                                                                  !            $  #  "  P               7                                                                                              
    subs.c                                                               D         V   	      W#J                                                                                                                                                                                                                                                                        
  	    W                                                                                                            
    
l
internal.c                                                           D         V       =
/*
 *  INTERNAL.C
 *
 *	DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
 *
 *	Usually SCMD_OPEN requests attempt to connect() to the UNIX
 *	domain socket of the server.  However, some 'ports' are designated
 *	as internal to DNET.  They reside here.
 *
 *	-IALPHATERM
 */

#include "dnet.h"
#include "../server/servers.h"
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/resource.h>
#include <sys/uio.h>
#include <strings.h>

extern char *getenv();

isinternalport(     X         Yek                                                                                                                                                                                                                                                                                            Y                                                                                                            
    
	globals.c                                                            D         X        p
/*
 *  GLOBALS.C
 *
 *	DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
 */

#include "dnet.h"

int Enable_Abort;

int DNet_fd = -1;	/*  Master listen socket	*/
PKT Pkts[9];		/*  data buffers for packets	*/
PKT *Raux = Pkts+8;	/*  next packet in		*/
PKT *RPak[4] = { Pkts+0,Pkts+1,Pkts+2,Pkts+3 };
PKT *WPak[4] = { Pkts+4,Pkts+5,Pkts+6,Pkts+7 };
CHAN Chan[MAXCHAN];    /*  Channels			   */
LIST TxList;	       /*  For pending SCMD_DATA reqs.     */
fd_set Fdread;
fd_set Fdwri     Z         [2./                                                                                                                                                                                                                                                                                        [              5                                                                                              
    double.c                                                             D         Z       ,ۍ
/*
 *  DOUBLE
 *
 *  DOUBLE DNETDIRA DNETDIRB
 *
 *  Run dnet using a pipe (for testing)
 */

#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>

main(ac, av, envp)
char *av[];
char **envp;
{
    int files[2];
    short i;
    char buf[256];
    char cmd[256];

    if (ac != 3) {
	puts("double dnetdira dnetdirb");
	exit(1);
    }

    for (i = 0; envp[i]; ++i) {
	if (strncmp(envp[i], "DNETDIR=", 8) == 0)
	      \         ]))4                                                                                                                                                                                                                                                                    ]                                                                                                            
     packet.c                                                             D         \       O
/*
 *  PACKET.C
 */

#include "dnet.h"

void BuildPacket();

#define Ascize(foo) (((foo) & 0x3F) | 0x40)

ubyte	RxTmp[MAXPACKET];

void
BuildDataPacket(pkt, win, dbuf, actlen)
PKT	*pkt;
ubyte	win;
ubyte	*dbuf;
uword	actlen;
{
    ubyte *ptr;
    ubyte *pend;
    ubyte range = 0;
    static ubyte BadCtl[32] = {
	1, 1, 1, 1, 1, 1, 1, 1,
	1, 1, 1, 1, 1, 1, 1, 1,
	1, 1, 1, 1, 1, 1, 1, 1,
	1, 1, 1, 1, 1, 1, 1, 1
    };

    ptr = dbuf;
    pend= dbuf + actlen;

    while (ptr < pend) {
	     ^         _.Q                                                                                                                                                                                                                                                                              c  b  a  `  _                                                                                                            
    Tnet.c                                                                D         ^       `+~(
/*
 *  NET.C
 *
 *	DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
 *
 *  NetWork raw device interface.  Replace with whatever interface you
 *  want.
 */

#include "dnet.h"
#include <sys/stat.h>

RcvInt()
{
    int n = read(0, RcvBuf + RcvData, RCVBUF - RcvData);
    int i;
    extern int errno;

    errno = 0;
    if (n >= 0)
	RcvData += n;
    if (n <= 0)         /* disallow infinite fast-timeout select loops */
	RExpect = 0;
    if (DDebug)
	printf("read(%d,%d)\n", n     ^       aFg, errno);
}

static struct sgttyb	ttym;
static struct stat	Stat;

NetOpen()
{
    int async = 1;

    fstat(0, &Stat);
    fchmod(0, 0600);
    /*
    signal(SIGIO, RcvInt);
    */
    ioctl (0, TIOCGETP, &ttym);
    if (Mode7) {
        ttym.sg_flags &= ~RAW;
        ttym.sg_flags |= CBREAK;
    } else {
        ttym.sg_flags |= RAW;
        ttym.sg_flags &= ~CBREAK;
    }
    ttym.sg_flags &= ~ECHO;
    ioctl (0, TIOCSETP, &ttym);
    /*
    ioctl (0, FIOASYNC, &async);
    */
         ^       b.HFsioctl (0, FIONBIO, &async);
}

NetClose()
{
    int async = 0;

    fchmod(0, Stat.st_mode);
    ioctl (0, FIONBIO, &async);
    /*
    ioctl (0, FIOASYNC, &async);
    */
    ioctl (0, TIOCGETP, &ttym);
    ttym.sg_flags &= ~RAW;
    ttym.sg_flags |= ECHO;
    ioctl (0, TIOCSETP, &ttym);
}

NetWrite(buf, bytes)
ubyte *buf;
{
    if (DDebug)
	fprintf(stderr, "NETWRITE %08lx %ld\n", buf, bytes);
    gwrite(0, buf, bytes);
}

gwrite(fd, buf, bytes)
register char *buf;
register long byt     ^       c,es;
{
    register long n;
    while (bytes) {
	n = write(fd, buf, bytes);
	if (n > 0) {
	    bytes -= n;
	    buf += n;
	    continue;
	}
	if (errno == EINTR)
	    continue;
	if (errno == EWOULDBLOCK) {
	    fd_set fd_wr;
	    fd_set fd_ex;
	    FD_ZERO(&fd_wr);
	    FD_ZERO(&fd_ex);
	    FD_SET(fd, &fd_wr);
	    FD_SET(fd, &fd_ex);
	    if (select(fd+1, NULL, &fd_wr, &fd_ex, NULL) < 0) {
	 	perror("select");
	    }
	    continue;
	}
	if (errno == EPIPE)
	    return;
	dneterror("gwr     ^          ite");
    }
}

O, &async);
}

NetClose()
{
    int async = 0;

    fchmod(0, Stat.st_mode);
    ioctl (0, FIONBIO, &async);
    /*
    ioctl (0, FIOASYNC, &async);
    */
    ioctl (0, TIOCGETP, &ttym);
    ttym.sg_flags &= ~RAW;
    ttym.sg_flags |= ECHO;
    ioctl (0, TIOCSETP, &ttym);
}

NetWrite(buf, bytes)
ubyte *buf;
{
    if (DDebug)
	fprintf(stderr, "NETWRITE %08lx %ld\n", buf, bytes);
    gwrite(0, buf, bytes);
}

gwrite(fd, buf, bytes)
register char *buf;
register long byt     d         eS)                                                                                                                                                                                                                                          e              1                                                                                              
    	control.c                                                            D         d       J.
/*
 *  CONTROL.C
 *
 *	DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
 *
 *  -handle various actions:
 *	RTO	- read timeout
 *	WTO	- write timeout (a packet not acked)
 *	RNET	- state machine for raw receive packet
 *	WNET	- starts timeout sequence if Write occured
 *	WUPDATE - update write windows, send packets
 *	RUPDATE - execute received packets in correct sequence
 *	RECCMD	- execute decoded SCMD commands obtained from received
 *			packets.
 */

#include "dnet.h"
     f         g                                                                                                                                                                                                                                                                                              g                                                                                                             
    dnet.servers                                                                  f          Q
8192	~/src/dnet/unix/bin/scopy	~
8193	~/src/dnet/unix/bin/sshell	~
8197	~/src/dnet/unix/bin/sloadav	~
8201	~/src/dnet/unix/bin/sgcopy	~
8202	~/src/dnet/unix/bin/snfs	~

                    f                                                                                                                                                                                                              
    unix                                                                             h         in                                                                                                                                                                                                                                                                                              i                                                                                                             
    ICLEAN                                                                         h           X*#!/bin/sh
cd dnet
make clean
cd ../client
make clean
cd ../server
make clean
cd ../test
make clean
cd ../lib
rm -f *.o make.out
cd ..
rm -f *.o make.out MAKE.out

                           f                                  h                                                                                                                                                                          
    unix                                                                             w       k(ng accepted by following a few simple guidelines:

	(1)	Don't submit bootable disks or disks with any other
		proprietary material included, since I then have to
		go examine each file to decide if it is distributable
		or not, and if not, what effect removing it might have.

	(2)	Organize the distribution in a manner similar to the
		library disk organization.  I.E., place all files
		related to a particular program under a single directory
		on the disk.  If there is more than one      w       lLLprogram per disk,
		place each one in its own directory.

	(3)	Try to write a simple entry for the "Contents" listing
		that summarizes your submission.  It should be about 
		3-10 lines, and include the current version number, the
		version and disk number of the most recent version
		(if any) that was last included in the library, whether
		or not source is included, and an "Author" list.

	(4)	Ensure that your submission will run correctly from
		its subdirectory and that it does      w       mgnot depend upon the
		name of the disk.  If necessary, supply a script
		runnable from workbench (via c:IconX) that makes all
		necessary assigns, copies fonts and libraries, etc.


CAT FISH Catalog Listing

	A complete catalog over 200 pages and full of interesting
	information of the entire library cross-referenced by file name
	and subject area is available from the ASCITEC AMIGA User's Group
	now for $20.00.  These listings are made using a laser printer
	on double-sided three-ho     w       nle punched paper for a quality binder
	reference and contain information on disks currently available
	in the library.  Some of the contents include:

		Complete listings of all disks and file descriptions
		(README and CONTENTS files) with disk numbers and page
		numbers for each file.  Currently over 150 pages.

		An alphabetic sorted file name cross-reference listing
		with disk and page numbers given for each file.  Duplicate
		file names are sorted with the most recent listed fi     w       orst.
		Currently over 20 pages.

		A subject category sorted file name cross-reference listing
		based on a three page 15 point major subject category
		outline with disk and page numbers given for each file.
		Currently over 25 pages.

		CLI notes for accessing any public domain disk file for
		reading, copying, and execution of files on the disks.

		The VCHECK documentation from Disk 175 that describes how
		to check disks for the "SCA AMIGA VIRUS" and erase it if
		found.

		The      w       pODMOUSE documentation from Disk 160 that describes how
		to use the ever popular DMOUSE background program.

	Future upgrades are easily obtained and incorporated at a very
	low cost.

	The complete CAT FISH library listings cost $20.00.  Future
	upgrades will cost $7.50.  USA taxes and mailing costs are
	included.  Mailing outside of the USA  and Canada will cost an
	additional $5.00.  Other information will also be included in
	future upgrades based upon prompt user suggestions and      w       qEfeedback.

	To order, make checks payable to "ASCITEC" or "THE AMIGA CLASS"
	at the AMIGA Science and Technology User's Group address given
	below.  Address all orders and questions regarding CAT FISH to
	this address:

		ASCITEC
		CAT FISH Listing
		P. O. Box 201
		Los Altos, CA  94023

CAT FISH Catalog Disk

	These materials are also available on disk for $10.00 -
	with the explicit agreement that they will not be copied
	and will not be placed upon any User Group or computer
	Bull     w      Q    2etin Board.

		ASCITEC
		CAT FISH Listing
		P. O. Box 201
		Los Altos, CA  94023
MOUSE background program.

	Future upgrades are easily obtained and incorporated at a very
	low cost.

	The complete CAT FISH library listings cost $20.00.  Future
	upgrades will cost $7.50.  USA taxes and mailing costs are
	included.  Mailing outside of the USA  and Canada will cost an
	additional $5.00.  Other information will also be included in
	future upgrades based upon prompt user suggestions and      r         sj)                                                                                                                                                                                                                                                                                            s                                                                                                            
    POSTER                                                                        r       `------------------------------------------------
dnet213.zoo    391296  Approx time (min):403 at 300 baud,101 at 1200 baud
Contributed by: mdillon  Date: Sat Dec  9 04:07:21 1989
DNet V2.10.13 now with 7 bit support.
DNet is a link protocol that allows multiple client-server
links over a single serial line.  Normally used to connect
two Amiga's together or an Amiga and a UNIX (4.3 compatible) system
together.  For example, running DNet between an Amiga and UNIX system
one could have      t         Vq                                                                                                                                                                                                                                                                                                        B                                                                                              
    XContents                                                           p         u   #  @    g  2  2  2  2  $  $d  $$  $  #   #  "  "  !  !               *:  *&  *  )  )  )  )N  )  (  (  (  (`  (  '  '  &  &  &  %6  #      b  )   (  (  (*  !  !  !<      `    J        `  ,         z  R    "        #  #  #  #                     $  #t  #Z  "  "  "n  "  !  !  !  !F        ,    B                            ~  r  f  Z  N  B  6  *               w       wϧtile or run for some reason, but was considered
	interesting enough to include anyway.

	Disks are typically 85 to 95 percent full.  


How to Order

	To order, send a list of the disks you want, and payment in U.S.
	funds to:

		Fred Fish
		Amiga Library Disks
		1835 East Belmont Drive
		Tempe, Arizona  85284
		USA

	The per disk fee as of October 1989 is as follows:

		1   to 9 disks		$6 per disk
		10  to 49 disks		$5 per disk
		50  to 99 disks		$4 per disk
		100 or more		$3 per dis     w       xЀk
		complete library	$2 per disk	(see note below)

	The price includes cost of media, mailing materials, and first class
	domestic postage.  Overseas orders add $5 per order for air mail.
	Time and other jobs permitting, all disks will be mailed within
	5 days of receipt of order (most are filled the next day).

	The above prices and address are current as of October 1989.  If
	the per disk charge in effect at the time your order is received
	is less than the amount stated above, you     w       yS will be charged the lower
	rate, and an appropriate credit for the difference added to your
	account.  It is highly unlikely that the per disk charge will be
	higher (it has always decreased, reflecting my decreasing cost for
	disks since beginning distribution of the library).
	
	Feel free to order more than the current number of disks available.
	Excess funds will be placed "in escrow" (refundable at any time) 
	and drawn against for automatic mailings of future disks as they 
	be     w       z-scome available.  These disks will be charged against your account
	at the per disk charge in effect at the time they are shipped.
	I hope to add at least four to six disks per month to the library.

	The "complete library" price ($2 per disk) applies only to orders
	of a complete set of all disks in the library at the time of the
	order.  The funds cannot be applied towards disks not yet completed.
	This offer is intended to provide a relatively low startup cost
	for new user groups,     w       {j5} dealers, or other users, to obtain a complete
	library set.


Notes

	Please keep in mind that most of the materials in this library are
	intended for use by experienced programmers, or at least experienced 
	Amiga users.  Many are runnable only via the CLI user interface, as 
	they contain no icon files (particularly the early disks).  If you
	are inexperienced with the Amiga CLI interface, you may need the
	assistance of an experienced user to make use of some of these disks.
	I d     w   	    |Fo not provide telephone support for instructions on how to
	run specific programs from the library.

	I do not guarantee the performance or usability of any of the 
	materials in this library.  I will replace or rewrite, at no
	additional charge, any disk ordered from me which turns out to be
	defective or unreadable.


Catalog Disk

	Because the current library has grown so large, it is no longer cost
	effective to distribute a printed catalog.  Therefore, the catalog
	disks replace     w   
    }A the printed catalog, and will be updated at each new
	release of disks to reflect the current state of the library.  It
	currently takes two disks to hold a complete catalog.

	There is no duplication fee for the catalog disks.  To receive the
	latest available catalog at any time, simply return the original 
	disks, or send two blank disks, to:

		Fred Fish
		Catalog Disk Update
		1835 East Belmont Drive
		Tempe, Arizona  85284
		USA

	Please enclose sufficient postage for 3 ounces     w       j\: First Class mail.

	Note that you can always obtain the latest catalog automatically
	by following the above procedure but specifying that you want
	the disks to be held until the next update.


Library Submissions

	If you have written a program that you would like to see appear
	in the library, I encourage you to submit it on disk directly to
	me, along with a letter indicating you would like to see it
	included in the library.  You can increase the chances of your
	submission bei     w       )zer groups.  Most already
	have many of the disks.  Since these disks can be copied freely,
	and widespread distribution is encouraged, they propagate out to 
	central distribution points fairly quickly.

	If you just can't wait, or can't find copies locally, I am willing
	to make these disks available for the cost of media, duplication,
	mailing materials, postage, and miscellaneous expenses (like wear
	and tear on my drives).  Naturally, you are encouraged to make
	copies for your f     w       vc#riends, local user groups, dealers, etc.  My goal
	is to get as much software as possible into the hands of people that
	can use and enhance it, and make the AMIGA the success it deserves
	to be.

	Generally, each disk contains all source necessary to recreate the
	executables provided.  Programs are compiled with the latest Lattice 
	C compiler (and/or Manx C compiler) available at the time of 
	release.  In a very few cases (usually noted in the description) the
	code will not comp     u       2 Jl*(mEz 
g (mEz  g>-Eh(mEzp(RmEhREz`>-EhB5p(I (G  r~ f
JgQJf
Hy   $a ۾I (G  t~f
JgQJfB- (a I (/$<  ,y  J"N+@ J g`Pa *`a 4A  xHxIH"Lr ,x  NDJg
Hy   ha >+mII| I&BmEhm @Ehl0;mEhI(II" L>-EhIHGp "KHx  ,mI"NRmEh`I5+L5IEJ+L5+m55| 5ZI  +L5\(mE\, 	RG5[,x N|I5R"LENPEN(m &l VI5R'L Nv~+G,~+G(~+G8+m  $+m  +m  B5HBHBmEh>-EhGIHBp RmEhm 
EhfI (/t,y  J"N     u       <+@5@J5@f
Hy   a  /-5@$-5D,y  J"NJ f
Hy   a (m5D+l |5L"-5@,y  JNB5@J5Lf
Hy  a PHI5R"L -ER,x Na l+@  J  f"- ,y  JNB `(m  )m $ (m $(  +m   $J-EVgI5R"L -ER,x NJ gJ-EXfJ-EZfJ9  25gJ-EWgI5R"L -ER,x N -ER,x NJ-EYgbHy   $<  ,y  J"N+@EpHy   $<  "N+@ElI(/$-Ep&-El"N""-EpNBEp"-ElNBElQEYJ-Jg &I (/$<  ,y  J"N+@EpJEpf,y  JN`  HmJ/-JN  4JJf
Hy   a l/-Ep$-Jv ,y  J"N/-Ep$-J&-     u       cJ"NְJg ,y  JN"-Ep,y  JNBEp`x"-Ep,y  JNBEpII/$<  "N+@ElJElf,y  JN`</-El$-J&-J,y  J"NаJg,y  JN"-El,y  JNBElHmJN  50QJJ-EXg`  J-EZf
J9  25g HJ g"- ,y  JNB a (m BQEZJ9  25ga Fa |a (m &l VI5R'L Qa I (/$<  ,y  J"N+@ J g` xNuIhSTj*z\J-ENgI5R"L,x Na J g"- ,y  JNJEpg"-Ep,y  JNJElg"-El,y  JNJ5@g"-5@,y  JNJ5<g"-5<,y  JNJmEPm>-EPH ,x NJF&     u       ծg"mF&,x NbJ-Ig;| 
IvII+LIIIZ"L,x N8J-IgIIZ"L,x N>J-IGoII8"L,x N-IGHH NN  6N  3^N  2N  3N  5    /K  -BDQP"z4H(i "i &I,L2SABBBBQ2ABg "   d "  m  (    m  WV`b  H8 D@DD`S f  
K  ,f`S f  
K  ,j`S f  
K  ,`S f  
K  ,`S f  K  -` ~S f  K  -2` nS f  K  -b` ^S f  K  -` NS f  K  .
` >S f  K  .0` .S f  K  .` S f  K  .` S f  K  .` S f  K  /R` S f  K  /`      u       u K  /`    @ @DG  M N` ` ` :P P BP P BP P BP P BP P BP P BP P 1P 4P ` 6` P:PP BPP BPP BPP BPP BPP BPP ` :P P BP P BP P BP P BP P BP P BP P 1P 4P ` P:PP P BPP P BPP P BPP P BPP P BPP P BPP P 4P ` 8     u       n"` :P P BP P BP P BP P BP P BP P BP P 1P 4P ` PPPPPPPPԘ` P:P PP BP PP BP PP BP PP BP PP BP PP BP PP 1P ` F:P P BP P BP P BP P BP P BP P BP P 1P 4P `  P:PP P BPP P BPP P BPP P BPP P BPP P BPP P 4P `  P:P PP BP PP BP PP BP PP BP PP BP PP BP PP 1P `  LPP:PP PP BPP PP BPP      u       r,GPP BPP PP BPP PP BPP PP BPP PP RIRL` *_Nu?0<  2 A:<>E F G E   d    P ` p d    P`pd    P`pd    P`pP`pP`pd   P`pd   P`pR@2 A 0gA `gA f
2AA 0@ m $I 0<$F$QO NuN  2&(QNuN       u       hZ2"$QNu z&h (h @G  I  C E @S@Nu      /J9  25g8(  	f  *h E f Bh ,x "zp :NQ  25` P f Nu#  2  J#  JaaL.y  JNu  JIRTf4N  5N  3&*zC  p!,x N*JfB  J y  JNNuISTj*zJg
"U,x NbN  5N  3^Nq#  3  J#  JaaF.y  JNu  JIRTf.N  5*zC  p!,x N*JfB  J y  JNNuISTj*zJg
"U,x NbN  5Nq#  3  J#  JaaF.y  JNu  JIRTf.N  5*zC  p!,x N*JfB  J y  JNNuISTj*z     u        }>Jg
"U,x NbN  5Nq#  4    #   a ra .y   Nu  JH0 J[jDJjFDH@HAJ@gJAg < `@H@4HAH@J@fЁkJgDL NuH< J[jDJ[jD  b64 B@H@" H@20BAHA`&" BAHAH@B@tЀӁbR@QgDJgDL <Nu/*zHY~߯ // "<   ,x  N:.Jf(o B`&(W)o  I  L"W,x N(WG (o (X*_,_PN/*zY(o .   ."W,x N"W(W , N.(o BX*_,_XN/*zЭ $oNB*_NuIRTf0*z+@ +H I +L I +L (m .    +G $NuIdSTj*zXI .-     u   !    nE g(m G +K  Hm  a L` - NuNq#  6  J#  Jaa  .y  JNu  JIRTfpN  5N  3N  2N  3&*zؓ,x N+@ (m J WJg8(m G \ K,x N(m G \ KN+@ (m &l $",y  JNNuISTj*zvJg,x N|"m NN  5N  3N  2N  3^Nq     A     3  3:  2  (L  '  '  &  &  &  %  %z  %Z  %  $  $  #t  #Z  "  "  "n  "  !  !  !  !F        ,    B                            ~  r  f  Z  N  B  6  *               u   "    u3    X      p  >    ,     Y     6  60  6  6*  6  6$  6  6  5  3  3  3  3  3z  30  3  2  2  2  2  2~  2:  2l  *  +f  +t  +  +  +  +  +  +  +  +  +  ,  ,  ,.  ,>  ,H  1  1  )   Z  (@  "  "      4    z  d      \  >  0    
  
  ~  "  "  )j  ):  'j  "  "   .        
F  X  
n    #  *  "F  *  "@  *  ":  *  "4  *  ".      _     6  6  5  5  6  4  3  3  3  3  3  3  3V  3P  3  3  3
  3   2  2     u       mp `\*_,_O N/*z`B5HB8J gR8(o >, H߭5H(o /l  `*_,_XN/*z&]a > /m  >m0l(m Jg(m +T RW`>m0l(o J g(o /l  RW`+o  // a hHy    Pa /- Pa > >m0l+o  Pa xRW`QEj\*_NuJ gPEW -ER,x NQEW,_XNY(o )m (o &o $kI ~B(Q8(o G +K >/ o TGG l  BW|  >o l&(o >I4 p d(o >Itp  RW`(o >/ IBF/ zFp > >/ o >o l (o >RGI&o $k<`p RW`(o >RGI p (o >TG     u       XI&o $k<`p RW(o >SGIJ4p f(o J g(o &l (o E 'J (o J g(o &l (o E &X,_PN(o J g(o &l (o 'l (o J g(o &l (o &,_XNU(o J,
f(,y  JN(m J f+m  `
(m +l  a (o J,
g// a |T,_XN(o Bl (m >, m2l(o &m 9k  `
(o 9m2 (o &m >, k 
l  (o Bl 
(o &o 9k  (m &o >+ 4p am
 zn  (o &o >+ 
4pHf^(o Rl 
(o Rl (o &o >+ 
J4pHfa +m H(o &o >, k ?(o ?, // a N(o P
p`` r(o Rl     u       te ` <p ,_XNL    H (| (Hm(I (/a Hm(Hy   a B-LHm(Hy   a Hm(?< $?<  -5HrdN  4""-5LN  4j/ a ,Hm(?< +?< /-5Ha Hm(?< 5?< /-5La Hm(?< C?< .-8S/a (o 9| O (o >, I(  p (o Rl (o l  l(o >-2TG<, Gm(o >, I(B4p I(/Qa PE`,_XN(U&U>+ l  U,y  JN;| dE>-0G]G(mEl 
;GE>-EG ;GE;| E| E+|  @E+|  EIE+LE+UE;| E;| E;| E>-EYG;GE;| E;|EJ/ g E;| EIF+LE+o F>/ 
SG;GF(o /AE,y  J     u       N4(_)@ D(o J Df`~IE L(o "l D,y  JN2(o &l D(k V/&o $k D&j V+ B&m $k V*  ,x N(_,  g(o  l D,y  JN(U&U>+ G9G ,_O Na Hy  Pa (Hy    Pa Hy  HPa Hy  Pa Hy  Pa Hy  Pa Hy  JPa Hy  Pa Hy  Pa Hy  Pa Hy  LPa Hy  Pa Hy  Pa Hy  Pa Hy  (Pa Hy  vPa tHy  Pa hHy  Pa \Hy  Pa PHy    Pa DHy  <Pa 8Hy  xPa ,Hy    Pa  Hy  Pa (o >-0G G9G (o Jl oHy    Pa      u       z|(o Sl `(m  l V,x N(m  l VN+@Eb(mEb,  g(mEbl  l`"mEb,x N`"mEb,x N+m  a D,_XN(o >-0HǞ89G (o Jl o(o Sl Pa (o Jl fQEj`
+m  a ,_XN// a +m $ (o 9m0 (o l  o(m J g(m +l  (o Sl `a ,_XN(o l BEkJ f"(m Jf(o J, gp`N`(o P `(o Q (o J, g"J-Ejf
(o J, g// a J-EjWEj`(o P PEjp ,_XN(o l BEk(o J, f
J-EjWEj`PEj(o Q ,_XN/*z"O -ER,x NP Q B/ B/ J-HgQHa J-Ejg<     u       [@J/ g -Eka J f(m JVEj`PEj`&-Eka (m J VEj`(m  l V,x N(m  l V,x N+@EbJEbg(mEb,  f`0(m   U"mEb,x N(m  l VN(m   U` X(mEbG ~&Q"mEb,x No  &l"J-E`g
a QE``o  &f
HWa rQEj>/ (G JGV B>/ (G 0JGV C/  %g./  (gHWa J g` ` /  (g HWa `` /  $g o  &l >/ &G @fHWa J g ` ` G Af
HWa ` pG MgG gG fhJ/ Bg&J/ gJ-Ejg
J-EkWEj`PEjPEkP ` 2J/ Cfo  &f>-0SG?G `?|  J/ BWa So     u       ye Jo fQEj` G LgG >gG ?fhJ/ Bg&J/ fJ-Ejg
J-EkWEj`PEjPEkQ ` J/ Cfo ? &f>-0SG?G `?|  J/ BWa QEjSo Jo f` |G DgG CfQa DQEj` bG =f
HWa ` RG f
HWa *` BG PmhG Ynb>/ &G P?G J/ Bf<>/ GIHJp g,>/ GIH+tp  (m J g
(m +l  a ` >/ GIH) p ` G _f
HWa ` G EgG .fJ/ Cf ` ` o @ &l >/ &IHtp / tf
HWa ` | bf
HWa T` l fg ng pf 8/ ffhHo ?< PQHo a BHBo >/ </ I 4`  am
     u       R+ zn  pH>/ 7 pHc>/ 7  pH`>/ J7pHf`Ro `a Q
J/ Hg  ?m0 JHg(mH+THJo o J g.- Hg(m +l  So `.- HfJ f+m  / pg J gNHWa J fDa (m +T ``4(m J g
(m +l  (m +l  J gHWa J g`B HWa @` " wf  JHg JHg 
J-EYf J-Jf BJBJ(mH. (WJ g(W. (W>, H߭J`(mH. Jg(W>, H߭J(W. `.H?m0 o  oJgSo (W>, H߭J(W.`.-JJJJo rHmI?< QHo a HWa PJ"mE\ -ER,x Na ` > ofhJ/     u       ڷU Bg 0J/ Cg (J-EYf  J-Jf L   H (Hm(I (/a .Hm(Hy  "a  HWa ZPEY"mE\ -ER,x N`  lf:a ta PEZ"mE\ -ER,x N -ER,x N>-EP gJ-EZf`  gfFHo ?< 
PHo a .-FH/G +m  J oa J g(m +T S `a ` D hf
HWa ` 4 qg^ xf`V` " sf J-EYf J-Jf 
C   ,x NzJf P  25"mE\ -ER,x N -ERN` ` PEX"mE\ -ER,x Np ,x N`O*_Nu/*zߢJF&fC  8p",x N+@F&JF&g Hm (a ~;@EfJmEfo>-Ef5 :p(g>-Ef5 /p(gSmEf`Jm     u       Eff;|EfBmEh>-EhmEfn>-EhIG<-Eh`(p RmEh`>-EhIGB4p BmEf>-EfIF<-Eh`(p RmEfRmEh>-EhSGJ5p(f,y  JNI   x+LFfIF+LFjIG+LFnBFrIFf L,mF&NJgVIGG (~?&QI ( LIF"L,mF&N,y  JNJ gB m ,y  JN>`2`J/ f
Hy   Ra J/ gHy   $a `B  J y  JN*_,_TN/*z*I   +LIBP  25 -ER,x NI   +LIB*_NuI RTf N  6N  3&N  2N  3N  5*z;|EP(x +lE\;| Ev|IGL   HH I;| Jp,x N;@EPJmEPlB  J y  JN>-EPB+FERHm HxN  4Hm     u       m5DHxN  4J5Df
Hy   a >-EP  24#E\  20Q  25I   +LIB| I@B-IFp,x N@IGJ-IGlB  J y  JNII8"L,x N+mE\IH| Ib;| 0IlII8+LIhBI| 3IA  NBIIZ"Lr  NDJg
Hy  \a DPII  26+LI;| 	IvII+LIIIZ"L,x N8PIJ9  JgZ(y  J    f@(y  J&l $+k E~(mE~G (~?&Q(y  J&l $"+ ,y  JN+@5<` (Pa t`      Jn
Pa ^` +y  JEzBmEhBmEf(mEz  f
REzRmEf`(mEz "fFRmEfREz>-EhmEfHǾ  Jlh(mEz "g^(mEz 
gT>-Eh(mEzp(RmEhREz``<>-EhmEfHǾ       u       HmJN  50+WJ`;| JX*_Nu/*z U,y  JNNz*_Nu/*zU(y  J>, GG;G2m 2o;| 2(y  J>, G;G0>-2G;GE>-02H+G4>-0G;GE;| E;| E(y  JJ 8g>(y  J&l 8(k l  f((y  J&l 8(k l  f(y  J&l 8+k (E`I   +L ;|  I +LE;|EAE,y  JN:*Jf
Hy   a H(U# X  *(U+l PE(mE9|   
(U&U>+ G9G a B-hBmEf  (UG T"KQ,y  JN(UG T"KpNm  EfljBmEhm 0Ehl>-EhI(p RmEhR` f (UG T"KBg(U&l >+ mEf2,y  J0N(UG T"KI( Lp0     u       ̩NPmEf`(U l I<"L>-2N  0L+|  E+UE;| E;| 
E;mEE(U>, G 
;GE+| EAE,y  JN4+@ J f
Hy   a T*_Nu/*zdJ g m ,y  JNB Jg U,y  JNB*_Nu.-(,f4/- I($&<   ,y  J"N+@,J,l
Hy   @a B(J,f
(o B, `2(o .-(G(sx  (o J, f
(o |  R((o Rl ,_XN/*zOJ,fp ` Bo Bo 
Bo -  Exg$- Exg>/  p`
>/  pRo `- Exg>/  pRo - Exg>/  pRo - Exg>/ <-EtFmEvRFpRo `&m EvfJmEtg>/ <-Ev     u       ,`FmEtRFpRo HWa /  g/  g` ?| HWa / 0 e\/ 9 bTRo >/ GIBtp >/ GI</ FG:3`  
BF/ EF 09p HWa @/ 0 e/ 9 c/  am
 zn  G / ? e/ Z cJ/ g
o 	 f `/ M f 6Q&mEx'Bo o fBo Bo>/ o m  o  l  >/ GI<4p F  fB-Ex;| EvBmEtP&`  F f
 Ex`  F f;| EvP&`  F f  Ex`vF f Ex`hF f ExP&`VF m&F %n >/ GI<4p F F ;FEvP&`*F (m$F /n>/ GI<4p F (F ;FEtP&Ro `      u   	    s/'-Exg  o  l  -  Exg - Exg>/  p`*>/  p`- Exg>/  p`
>/  pRo - Exg / 'f6o  l.>/  pRo `/ 'go  l>/  pRo J/&g zo  l p- Exg>/ <-EtFmEvRFp`>/ <-EvFmEtRFpRo ` 6/   e b>/  pRo Ro 
`   e  b/   >/  pRo Ro 
`f fJo 
oZSo So 
`P 	f2>/   pRo Ro 
o  g0>/ 
m2g&>/ G JGf` f>/   pRo Ro 
/ 
 g"J/ g/  g>/ 
m2l
o  m Z?/ a .(W9o  (W9o      u   
    wm 
Jo oSo (W>/ </ `p` O(*_Nu/*z O>-5Pm0G?(o (G  KI<$L2N  *J/ $g&(mEPl 
a ?-2?-04-5P20N  1`  >-5P2H/G (y  *., ޯ /G ./ ޭ4/G (y  *., ޯ /G ./ ޭ4/G ?|  (mERl 
a >-2G>(o &o (X X (o &o (X X SWJWfSo Jo fRm5P>-5Pm0fBm5P(mEBl 
O *_,_\N/*zO(m G~B&Q6(oHTa ;@Eh>-Ehm2m
>-2SG;GEh>-EhRGB7p>-Eh(o<-Eh` p>-Eh7 pc
>-Eh7  pSmEhJmEhlI//a dO*_,_\N/*zV(m JfJ gP     u       IEV -ER,x NQEV(m JV*_Nu/*z"aJ g@(m +T R8(m >, H߭5H``">-0H,-8m(m +T /- / a *_,_TN/*zO(m J g 8(m +l  (m >, Hǟ5HS8(m +l  Jm5Pf(mE>-0G9G 
>-0SG;G5P`Sm5P>-5PG?(m &l I  LI<$L2N  *J/  g&(mEQl 
a ?-2?-04-5P20N  1`  >-5PRG2H/G (y  *., ޯ /G ./ ޭ4/G (y  *., ޯ /G ./ ޭ4/G ?|  (mESl 
a >-2G>Y Y (o &o (Y Y (o &o (SWJWfSo Jo fO *_,_TN/*zvOJm5Pf(mE>-0G9G 
     u       ׈j;m05PSm5P(m J g&>-5PG?(m &l I  LI<$L2N  *` >-5PG?(m G  KI<$L2N  *>-5PHR<-2H "N  4"/@ (y  *., ޯ /G ./ ޭ4/G (y  *., ޯ /G ./ ޭ4/G ?|  (mESl 
a >-2G>Y Y (o &o (Y Y (o &o (SWJWfSo Jo fO&*_Nu/*zN(y  *"l .-4/r ,y  J N(y  *"l .-4/r  NBm5P(mEBl 
*_Nu/*z]>/ o // a o lo  n(o >/ B4p So (o >/  / r
N  4j   0p  / r
N  4j/@ >/ o gJ f>/ o oSo (o >/        u       5cSpace, RMB:     Start / Stop scrolling backwards.   Up/Down:            Move one line up or down.   Shift + Up/Dn:      Start / Stop quick scrolling up or down.  Alt+Up/Dn, PgUp/Dn: Move one page up or down.   T, Home / B, End:   Goto top / bottom of text.  F,N,P:              Find string, Next, Previous occurance   Shift + Fn:         Set textmarker #n to current position   Fn:                 Goto marker #n or set mar     u       ker #n if it wasn't set yet  G:                  Goto line #n  NK 0:               Display Filelength etc.   Shift + Alt + O:    Create printout of the text   W:                  Write block between Marker #1 and #2 to file or prt   L:                  Load new text (arp necessary)   HELP, H:            Show Commands.  ESC, Q, X, NK 5:    Quit.   S:                  Go to Sleep, pop up with left Alt-ESC.  1989 Fridtjof Siebert, Nobileweg 67,      u       *D-7000 Stuttgart 40   Please refer to MuchMore.ReadMe for a detailed copyright notice    This is another great product of the Amiga Modula-2 Klub Stuttgart - AMOK t b f n p f p w o TYPE   TO PRT:  l g h q x s arp.library : / PRT:  input.device  Need input.device " " ? -s  console.device  Show.MM File empty  intuition.library   graphics.library    dos.library W R       #     J#  Ja "a ).y  JNu    /*zU>RWW n(o 
>J4p f0T*_,_XN/*zY// a?@ BWo       u       Q&n2(o >J4p g&>/ m2l(o >/ &o <` p Ro RW`o  n(o >/ B4p X*_,_PN/*z^]J9  Jg  | FS| FT;| FV;| FXL FRH F>L FRH F*I   x+LF^IF>+LFb+o FJ;| FD;| F.;| F0I   +LF6IFR"LIF*&LHx B4<@vA,y  J" N`F,y  JN./$/ /(o HTa $H& ,y  J"N| 
 /I $v"NB  J y  JN\*_,_XN/*z^Qo  >/   gRo >-Jo G n
>/ mJ`2Ho HxN  4J f
Hy   a (o (J+o J;o J(mJ>-Jo Gp P*_,_TN/*zYJJg(mJ.     t       &This is disk 294 of the freely distributable AMIGA software library.
Below is a listing of the significant directories and their contents.


DNet		A link protocol that provides essentially an unlimited
		number of reliable connections between processes on
		two machines, where each end of the link can be
		either an Amiga or a Unix (BSD4.3) machine.  Works
		on the Amiga with any EXEC device that looks like the
		serial.device.  Works on UNIX with tty and socket
		devices.  Achieves      t       #Ӯbetter than 95% average throughput
		on file transfers.  This is version 2.10.13, an update
		to version 2.0 released on disk 220.  Includes sources
		for both the Amiga and Unix versions.
		Author:  Matt Dillon

FmsDisk		A file based trackdisk simulator, useful for creating
		a floppy-like partition on your hard disk (so you can
		diskcopy to a floppy) without actually having to create
		a special partition for it.  Also useful for testing
		new filesystems and such.  Supports up to     t      r    D 32 units,
		with either the old filesystem or the new fast filesystem.
		Includes source.
		Author:  Matt Dillon
ries and their contents.


DNet		A link protocol that provides essentially an unlimited
		number of reliable connections between processes on
		two machines, where each end of the link can be
		either an Amiga or a Unix (BSD4.3) machine.  Works
		on the Amiga with any EXEC device that looks like the
		serial.device.  Works on UNIX with tty and socket
		devices.  Achieves               8                                                                                                                                                                                                                                                                                                                                                                                                        
    	DNet.info                                                            p                f.      : D P     & '                  L           (   9 ^(         O k  <    @ ^               Z (    (         P                               : <       : 4 : ?4  _( 0                                                                              ? ? ? ? ? ? ? ? ? ? ?              bE                                                                                                                                                                                                                                                                                                  

                                                                                              
    Contents.info                                                        p                C     ,  b     'WP '_p                   'c                          b   8                         EUUUU@        E_UU@        EVUUE        EVgG        EVggeG        EVffEG        EVfuG        E_G        ETG        EUUUUG        EuuUG        EQqUG        Euq}G        EqqG        EqqG        EqqG        Eyy}G        EAAAG        EUUUUG        EUUUUG        EUUUUG        EUUUUG        EUU@G        EUUUUG                     /        UUUUU              076                                                                                                                                                                                                                                                                                                  

                                                                                              
    Distribution.info                                                    p                7J        b     '_ '_                   'h                           b                            EUUUU@        E_UU@        EVUUE        EVgG        EVggeG        EVffEG        EVfuG        E_G        ETG        EUUUUG        EuuUG        EQqUG        Euq}G        EqqG        EqqG        EqqG        Eyy}G        EAAAG        EUUUUG        EUUUUG        EUUUUG        EUUUUG        EUU@G        EUUUUG                     /        UUUUU              %                                                                                                                                                                                                                                                                                                                                                                                                        
    	Disk.info                                                            p                Ǹ 
       ;      \                      L            Zh         	  q    @ Z     !         Z (              ;   zx                       < 1   <     0          `        ?      0                  ?                                                  ;   |     ?        :   \< 0 Q\     `    
  U\        0    \  ?  
  |        ;                     Ԃ                                                                                                                                                                                                                                                                                                                                                                                                      
    Distribution                                                         p                nTo the best of my knowledge, materials in this library are freely
redistributable.  This means that they have met one or more of the
following conditions:

(1)	The materials contains explicit copyright notices permitting
	redistribution.

(2)	The materials were posted to a publically accessable electronic
	bulletin board and did not contain any copyright notice.
	(Such materials will be removed if it is subsequently shown
	that copyright notices were illegally removed.)

(3)	The mate              nS                                                                                                                                                                                                                                                                                                  

                                                                                              
    GeneralInfo.info                                                     p                8g      (  b     '_ 'dP                   'c                           b                            EUUUU@        E_UU@        EVUUE        EVgG        EVggeG        EVffEG        EVfuG        E_G        ETG        EUUUUG        EuuUG        EQqUG        Euq}G        EqqG        EqqG        EqqG        Eyy}G        EAAAG        EUUUUG        EUUUUG        EUUUUG        EUUUUG        EUU@G        EUUUUG                     /        UUUUU              tu                                                                                                                                                                                                                                                                                                                                                                                                        
    	7FmsDisk.info                                                         p                       D P     & &                  L              9 P          l  C    @                Z (              P                               : <       : 4 : ?4  _( 0                                                                              ? ? ? ? ? ? ? ? ? ? ?f @                                                                                                                                                                                                                        <       : 4 : ?4  _( 0                                                                              ? ? ? ? ? ? ? ? ? ? ?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            G                                                                                                                                                                                                                                                                                                                                                         b   P                   *UUUUU  7  7  7  7ꪪꪪ  7  7  7  7            tUUU~  7  7UUUU~  7  7UUUU~  7  7UUUU~  7  7UUU~  7  7UUUU~  7  7UUUU~  7  7  7_  7  0           *UUUUU                                                 UUUG              UUUUG          *UUUUG          UUUUG          UUUUG                      BUUUUG          *UUUUG          UUUUG          UUUUG                       @                                                                                                                                                                                                                                                                                                                                 !                                                                                                                     :c/MuchMore   7UUUU~  7  7UUUU~  7  7  7_  7  0           *UUUUU                                                 UUUG              UUUUG          *UUUUG          UUUUG          UUUUG                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        9 ?                                                       P                               : <       :       4        ':        g4       (       0? ? ? ? ?   ?  ?                            ? ? ? ?uUUUUU zuUUUUU                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             AUUUUG          *UUUUG          UUUUG          UUUUG                       @                                                                                                                                                                                                                                                                                                                                 !                                                                                                                     :c/MuchMore   7UUUU~  7  7UUUU~  7  7  7_  7  0           *UUUUU                                                 UUUG              UUUUG          *UUUUG          UUUUG          UUUUG                      űnUUU~  7  7UUUU~  7  7UUUU~  7  7UUUU~  7  7UUU~  7  7UUUU~  7  7UUUU~  7  7  7_  7  0           *UUUUU                                                 UUUG              UUUUG          *UUUUG          UUUUG          UUUUG                      <UUUUG          *UUUUG          UUUUG          UUUUG                       @                                                                                                                                                                                                                                                                                                                                 !                                                                                                                     :c/MuchMore   7UUUU~  7  7UUUU~  7  7  7_  7  0           *UUUUU                                                 UUUG              UUUUG          *UUUUG          UUUUG          UUUUG                         n     SYS:System/DiskCopy                                                                                                                                                                                                                                                                         

                                                                                              
    Contents.info                                                        p                ɝrials were posted to a widely disseminated electronic
	network (such as usenet), thus implying that their author/poster
	intended them to be freely distributed.  This applies only if
	they contain no notice limiting distribution.

(4)	The materials contain an explicit notice placing them in the
	public domain.  This is not the same as condition (1).

(5)	The materials were submitted to me directly by the author
	with a request to consider them for inclusion in the library.
	This is t           >    Qhe ONLY way shareware is included on any disk after
	disk 90.
ely
redistributable.  This means that they have met one or more of the
following conditions:

(1)	The materials contains explicit copyright notices permitting
	redistribution.

(2)	The materials were posted to a publically accessable electronic
	bulletin board and did not contain any copyright notice.
	(Such materials will be removed if it is subsequently shown
	that copyright notices were illegally removed.)

(3)	The mate            `
                                         ?      <?                  9      |<?                  Ϗ      3      ?χ      3      ?      ??                                                                                                                                                             `
                                         ?      <?                  9      |<?                  Ϗ      3      ?χ      3      ?      ??                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      b                      *UUUUU  7  7  7  7ꪪꪪ  7  7  7  7     d       = (CACKCMD *)ptr;
	    uword chan = (cack->chanh<<8)|cack->chanl;
	    if (chan >= MAXCHAN || Chan[chan].state != CHAN_LOPEN)
		break;
	    if (DDebug)
		fprintf(stderr, "ackerr = %ld\n", cack->error);
	    if (cack->error == 33) {
		uword newchan = alloc_channel();
		COPEN co;
		if (newchan < MAXCHAN) {
		    Chan[newchan] = Chan[chan];
		    Chan[chan].state = CHAN_FREE;
		    Chan[chan].fd = -1;
		    co.chanh = newchan >> 8;
		    co.chanl = newchan;
		    co.porth = Chan[chan].p     d       ϗ;ort >> 8;
		    co.portl = Chan[chan].port;
		    co.error = 0;
		    co.pri   = Chan[chan].pri;
		    WriteStream(SCMD_OPEN, &co, sizeof(COPEN), newchan);
		    break;
		}
	    }
	    if (cack->error) {
		extern void nop();
		ubyte error = cack->error;
		int fd = Chan[chan].fd;

		gwrite(fd, &error, 1);
		Fdstate[fd] = nop;
		Chan[chan].fd = -1;
		Chan[chan].state = CHAN_FREE;
		FD_CLR(fd, &Fdread);
		FD_CLR(fd, &Fdexcept);
		close(fd);
	    } else {
		ubyte error = 0;
		extern void     d       * do_open();
		gwrite(Chan[chan].fd, &error, 1);
		Chan[chan].state = CHAN_OPEN;
		Chan[chan].flags = CHANF_ROK|CHANF_WOK;
		Fdstate[Chan[chan].fd] = do_open;
	    }
	}
	break;
    case SCMD_EOFCMD:	/*  EOF on channel		*/
	{
	    register CEOFCMD *eof = (CEOFCMD *)ptr;
	    uword chan = (eof->chanh<<8)|eof->chanl;

	    if (chan < MAXCHAN && Chan[chan].state == CHAN_OPEN) {
		Chan[chan].flags &= ~eof->flags;
		if (eof->flags & CHANF_ROK) {
		    char dummy;
		    shutdown(Chan[chan].f     d       w*d, 1);
		    write(Chan[chan].fd, &dummy, 0);
		}
	    }
	}
	break;
    case SCMD_QUIT:
	dneterror("QUIT");
	break;
    case SCMD_IOCTL:
	{
	    register CIOCTL *cio = (CIOCTL *)ptr;
	    uword chan = (cio->chanh<<8)|cio->chanl;

	    if (chan < MAXCHAN && Chan[chan].state == CHAN_OPEN) {
		switch(cio->cmd) {
		case CIO_SETROWS:
		    isetrows(Chan[chan].fd, (cio->valh<<8)|cio->vall);
		    break;
		case CIO_SETCOLS:
		    isetcols(Chan[chan].fd, (cio->valh<<8)|cio->vall);
		    brea     d       ҍ	k;
		case CIO_STOP:
		    break;
		case CIO_START:
		    break;
		case CIO_FLUSH:
		    ClearChan(&TxList, chan, 0);
		    break;
		}
	    }
	}
	break;
    default:
	break;
    }
}

replywindow(window)
{
    ubyte rwindow = (window - RPStart) & 7;

    if (DDebug) {
	if (rwindow >= 4 || RPak[rwindow]->state == READY)
	    fprintf(stderr, " ACK WINDOW %ld\n", window);
	else
	    fprintf(stderr, " NAK WINDOW %ld\n", window);
    }
    if (rwindow >= 4 || RPak[rwindow]->state == READY)      d      D    ~F /* data ready */
	WriteAck(window);
    else
	WriteNak(window);
}

    case SCMD_QUIT:
	dneterror("QUIT");
	break;
    case SCMD_IOCTL:
	{
	    register CIOCTL *cio = (CIOCTL *)ptr;
	    uword chan = (cio->chanh<<8)|cio->chanl;

	    if (chan < MAXCHAN && Chan[chan].state == CHAN_OPEN) {
		switch(cio->cmd) {
		case CIO_SETROWS:
		    isetrows(Chan[chan].fd, (cio->valh<<8)|cio->vall);
		    break;
		case CIO_SETCOLS:
		    isetcols(Chan[chan].fd, (cio->valh<<8)|cio->vall);
		    brea               ?                                                       P                               : <       :       4        ':        g4       (       0? ? ? ? ?   ?  ?                            ? ? ? ?uUUUUU zuUUUUU                              `
                                         ?      <?                  9      |<?                  Ϗ      3      ?χ      3      ?      ??                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      b                      *UUUUU  7  7  7  7ꪪꪪ  7  7  7  7            ±sUUU~  7  7UUUU~  7  7UUUU~  7  7UUUU~  7  7UUU~  7  7UUUU~  7  7UUUU~  7  7  7_  7  0           *UUUUU                                                 UUUG              UUUUG          *UUUUG          UUUUG          UUUUG               r          useveral remote shell windows and a file transfer 
going in both directions at once.
Keywords: $binary dnet file ne net port protocol serial transfer
Download count: 0
------------------------------------------------
                                                                      g                                                                                                             
    dnet.servers                                                                  d       ksPbyte window = ctl & 7;
    ubyte rwindow;
    static ubyte Chk, Chkwin[8];	/* remember window checks */

    if (ctl == -1)  {                           /* end of sequence */
	dumpcheck(Chkwin);
	Chk = 0;
	return;
    }
    if ((ctl & PKF_MASK) == PKCMD_CHECK) {      /* CHECK packet    */
	Chkwin[window] = 1;
	Chk = 1;
	return;
    }
    if (Chk) {                                  /* NON-CHECK packet*/
	dumpcheck(Chkwin);
	Chk = 0;
    }
    switch(ctl & PKF_MASK) {
    case PKCMD_WR     d       گ̽ITE:
    case PKCMD_WRITE6:
    case PKCMD_WRITE7:
	rwindow = (window - RPStart) & 7;
	if (rwindow < 4) {
	    bcopy(buf, RPak[rwindow]->data, bytes);
	    RPak[rwindow]->buflen = bytes;
	    RPak[rwindow]->state = READY;
	    if (rwindow == 0)
		do_rupdate();
	}
	replywindow(window);
	break;
    case PKCMD_ACK:
	rwindow = (window - WPStart) & 7;
	if (rwindow < WPUsed)       /*  mark as sent    */
	    WPak[rwindow]->state = EMPTY;
	break;
    case PKCMD_NAK:		    /*	resend		*/
	rwin     d       Udow = (window - WPStart) & 7;
	if (rwindow < WPUsed) {     /*  resend          */
	    WritePacket(WPak[rwindow]);
	} else {
	    fprintf(stderr, "Soft Error: Illegal NAK\n");
	}
	break;
    case PKCMD_ACKRSTART:
    case PKCMD_RESTART:
	{
	    uword chan;
	    uword chksum;
	    int len;
	    int fd;

	    if ((ctl & PKF_MASK) == PKCMD_ACKRSTART)
		Restart = 0;
	    do_netreset();
	    if ((ctl & PKF_MASK) == PKCMD_RESTART) {
		WritePacket(BuildRestartAckPacket("3", 1));
	    }
	        d       K- if (bytes)
		setlistenport(buf);
	    else
		setlistenport("3");
	    do_wupdate();
	}
	break;
    default:
	if (DDebug)
	    printf("do_cmd: bad packet ctl %02x\n", ctl);
	break;
    }
    do_rupdate();
}

do_rupdate()
{
    while (RPak[0]->state == READY) {
	register PKT *pkt = RPak[0];
	register ubyte *ptr = pkt->data;
	register uword len;
	uword iolen = pkt->buflen;
	ubyte cmd;

	while (iolen) {
	    if (DDebug)
	        printf("rupdate %02x\n", ptr[0]);
	    cmd = SCMD_DATA;
	      d       Բ    len = ptr[0];
	    ++ptr;
	    --iolen;
	    if (len >= 128) {
		cmd = len & 7;
		len = (len >> 3) & 7;
	    } else {
		if (len < 0x40) {
		    len -= 0x20;
		} else {
		    len = (len - 0x40) * 96 + (*ptr - 0x20);
		    ++ptr;
		    --iolen;
		}
	    } 
	    iolen -= len;
	    if (DDebug)
		fprintf(stderr, " MPXCMD %ld (%ld bytes)\n", cmd, len);
	    do_reccmd(cmd, ptr, len);
	    ptr += len;
	}
	RPak[0] = RPak[1];
	RPak[1] = RPak[2];
	RPak[2] = RPak[3];
	RPak[3] = pkt;
	pkt->sta     d       2te = EMPTY;
	++RPStart;
    }
}

do_reccmd(cmd, ptr, len)
ubyte *ptr;
{
    if (DDebug)
	printf("-reccmd %02x (%ld bytes)\n", cmd, len);
    switch(cmd) {
    case SCMD_DATA:
	if (RChan < MAXCHAN && (Chan[RChan].flags & CHANF_ROK))
	    gwrite(Chan[RChan].fd, ptr, len);
	break;
    case SCMD_SWITCH:
	RChan = (ptr[0]<<8)|ptr[1];
	break;
    case SCMD_OPEN:
	{
	    register COPEN *cop = (COPEN *)ptr;
	    CACKCMD ack;
	    uword chan = (cop->chanh << 8) | cop->chanl;

	    ack.chanh =      d       K	cop->chanh;
	    ack.chanl = cop->chanl;
	    ack.error = 0;

	    if (chan >= MAXCHAN || Chan[chan].state) {
		ack.error = 33;     /* magic */
		WriteStream(SCMD_ACKCMD, &ack, sizeof(CACKCMD), chan);
		break;
	    }
	    {
		int error;
		int s;
		uword port = (cop->porth<<8)|cop->portl;

		if (isinternalport(port)) {
		    error = iconnect(&s, port);
		} else {
		    struct sockaddr sa;
		    s = socket(PF_UNIX, SOCK_STREAM, 0);
		    if (DDebug)
			fprintf(stderr, " REC OPEN, CONNE     d       /CTING ch%d po%d\n",
			    chan, port
			);
		    sa.sa_family = AF_INET;
		    sprintf(sa.sa_data,".PORT.%ld", port);
		    error = connect(s, &sa, sizeof(sa));
		    if (error < 0) {
			startserver(port);
			error = connect(s, &sa, sizeof(sa));
		    }
		    if (DDebug)
			fprintf(stderr, " CONNECTED err=%ld\n", error);
		}
		if (error < 0) {
		    ack.error = 2;
		} else {
		    extern void do_open();
		    fcntl(s, F_SETFL, FNDELAY);
		    Chan[chan].state = CHAN_OPEN;
		    Chan     d       EG>[chan].flags = CHANF_ROK|CHANF_WOK;
		    Chan[chan].fd = s;
		    Chan[chan].pri= cop->pri;
		    FD_SET(s, &Fdread);
		    FD_SET(s, &Fdexcept);
		    FdChan[s] = chan;
		    Fdstate[s] = do_open;
		}
		WriteStream(SCMD_ACKCMD, &ack, sizeof(CACKCMD), -1);
	    }
	}
	break;
    case SCMD_CLOSE:	/*  receive close   */
	{
	    extern void nop();
	    register CCLOSE *clo = (CCLOSE *)ptr;
	    uword chan = (clo->chanh<<8)|clo->chanl;
	    int fd = Chan[chan].fd;

	    if (DDebug)
		fpr     d       2intf(stderr, " SCMD_CLOSE\n");
	    if (chan >= MAXCHAN || Chan[chan].state == CHAN_FREE)
		break;
	    /*
	    Chan[chan].state = CHAN_CLOSE;
	    Chan[chan].flags |= CHANF_RCLOSE;
	    */
	    Chan[chan].flags &= ~(CHANF_ROK|CHANF_WOK);
	    FD_CLR(fd, &Fdread);
	    FD_CLR(fd, &Fdexcept);
	    Chan[chan].state = CHAN_FREE;
	    Chan[chan].fd = -1;
	    Fdstate[fd] = nop;
	    close(fd);
	    ClearChan(&TxList, chan, 0);

	    if (Chan[chan].flags & CHANF_LCLOSE) {
		if (DDebug)
		     d       :fr    fprintf(stderr," REMOTE CLOSE %ld, LOCAL ALREADY CLOSED\n",
			fd
		    );
	    } else {
		CCLOSE cc;
		char dummy;
		cc.chanh = chan >> 8;
		cc.chanl = chan;
		WriteStream(SCMD_CLOSE, &cc, sizeof(CCLOSE), chan);
		/*
		shutdown(Chan[chan].fd, 2);
		write(Chan[chan].fd, &dummy, 0);
		*/
		if (DDebug)
		    fprintf(stderr," REMOTE CLOSE %ld, LOCAL NOT YET CLOSED\n",
			fd
		    );
	    }
	}
	break;
    case SCMD_ACKCMD:	/*  acknowledge of my open	*/
	{
	    register CACKCMD *cack      \       䙌%ld bytes\n", Pkt.ctl, ActLen);

	    do_cmd(Pkt.ctl, dptr, ActLen);

	    RState = 0;
	    break;
	}
    }

    {
	static short ExpAry[] = { 3, 2, 1, 4, 3, 2, 1, 0 };

	expect = ExpAry[RState];

	if (RState == 7)
	    expect = BufLen - DBLen;
    }
#ifdef NOTDEF
    if (Rto_act) {
	AbortIO((IOR *)&Rto);
	WaitIO((IOR *)&Rto);
	Rto_act = 0;
    }
    if (RState == 7) {
	Rto.tr_time.tv_secs = 8;
	Rto.tr_time.tv_micro= 0;
	SendIO((IOR *)&Rto);
	Rto_act = 1;
    }
#endif
    do_cmd((uwor     \      ,    #;d)-1, NULL, 0);
    return((int)expect);
}

break;
		}
	    }

	    switch(Pkt.ctl & PKF_MASK) {
	    case PKCMD_ACKRSTART:
		dptr = Pkt.data;
		break;
	    case PKCMD_WRITE:
		dptr = Pkt.data;
		break;
	    case PKCMD_WRITE6:
		UnExpand6(Pkt.data, RxTmp, ActLen);
		dptr = RxTmp;
		break;
	    case PKCMD_WRITE7:
		UnCompress7(Pkt.data, RxTmp, ActLen);
		dptr = RxTmp;
		break;
	    default:
		puts("BaD2");
		dptr = Pkt.data;
		break;
	    }
	    if (DDebug)
		printf("Recv Body   %02x      d       潋K  while (WPUsed != 4 && (ior = (XIOR *)RemHead(&TxList))) {
	register long offset = 0;

	if (++loop == 2) {
	    WReady = 1;
	    AddHead(&TxList, ior);
	    return(0);
	}

	{
	    short npri;

	    if (ior->io_Command == SCMD_DATA)
		npri = ior->io_Pri << 2;
	    else
		npri = XPri;
	    if (npri >= XPri)  {
		XPri = npri;
	    } else {
		if (XPri - npri > 100)
		    XPri -= 10;
		else if (XPri - npri > 50)
		    XPri -= 5;
		else
		    --XPri;
	    }
	    maxpktsize = MAXPKT - (XPr     d       瑉Ri - npri);
	    if (DDebug)
		fprintf(stderr, "**MAXPKTSIZE = %ld  XPri %ld npri %ld\n",
		    maxpktsize, XPri, npri
		);
	    if (maxpktsize < MINPKT)
		maxpktsize = MINPKT;
	}

	pkt = WPak[WPUsed];

	for (;;) {
	    if (offset > (maxpktsize-8))            /*  not enough room */
		break;
	    if (ior->io_Command == SCMD_DATA && ior->io_Channel != WChan) {
		/*  CSWITCH */
		WChan = ior->io_Channel;
		TmpBuf[offset+0] = 0x80|SCMD_SWITCH|(2<<3);
		TmpBuf[offset+1] = WChan >> 8;
		Tmp     d       &Buf[offset+2] = WChan;
		offset += 3;
		if (DDebug)
		    fprintf(stderr, "SEND SWITCH %ld\n", WChan);
	    }
	    len = ior->io_Length - ior->io_Actual;
	    if (ior->io_Command == SCMD_DATA) {     /*  DATA    */
		if (DDebug)
		    fprintf(stderr, "SEND DATA %ld bytes\n", len);
		if (offset + len > (maxpktsize-4))
		    len = (maxpktsize-4) - offset;
		if (len < 0x20) {
		    TmpBuf[offset] = len + 0x20;
		    ++offset;
		} else {
		    TmpBuf[offset+0] = 0x40 + len / 96;
		    Tmp     d   	    )
Buf[offset+1] = 0x20 + len % 96;
		    offset += 2;
		}
	    } else {				    /*	COMMAND */
		TmpBuf[offset] = 0x80|ior->io_Command|(len<<3);
		++offset;
		if (DDebug)
		    printf("constr sdcmd %02x len %d\n", TmpBuf[0], len);
	    }
	    bcopy((char *)ior->io_Data+ior->io_Actual,TmpBuf+offset,len);
	    offset += len;
	    ior->io_Actual += len;
	    if (ior->io_Actual == ior->io_Length) {
		free(ior->io_Data);
		free(ior);
		ior = (XIOR *)RemHead(&TxList);          /* Next packet       d   
    5\    */
		if (ior == NULL)
		    break;
	    }
	}
	pkt->state = READY;
	BuildDataPacket(pkt, (WPStart + WPUsed) & 7, TmpBuf, offset);
	WritePacket(pkt);

	if (ior) {
	    ++ior->io_Pri;
	    Enqueue(&TxList, ior);
	    --ior->io_Pri;
	}
	++WPUsed;
    }
}

void
dumpcheck(ptr)
register ubyte *ptr;
{
    register short i;
    for (i = 0;i < 8; ++i) {
	if (ptr[i])
	    replywindow(i);
	ptr[i] = 0;
    }
}

void
do_cmd(ctl, buf, bytes)
short ctl;	/* actually a ubyte */
ubyte *buf;
{
    u     d       8ht#include <stdio.h>

extern void do_cmd();

ubyte TmpBuf[MAXPACKET];

/*
 *  RTO:    read timeout.   Timeout occured while waiting for the rest of
 *	    a packet.  Reset state and restart read.
 */

do_rto()
{
    RState = 0;
    RcvData = 0;
    if (DDebug)
	fprintf(stderr, "RTO\n");
}

/*
 *  WTO:    Write timeout (unresolved output windows exist).  Resend a CHECK
 *	    command for all unresolved (READY) output windows
 */

void
do_wto()
{
    register short i;
    register PKT *p     d       C/kt;
    short to = 0;

    if (DDebug)
	fprintf(stderr, "WTO\n");
    if (Restart) {
	WriteRestart();
	return;
    }
    for (i = 0; i < WPUsed; ++i) {
	pkt = WPak[i];
	if (pkt->state == READY) {  /*  send check  */
	    WriteChk((WPStart + i) & 7);
	    ++to;
	}
    }
    if (to)
	WTimeout(WTIME);
}

/*
 *  RNET:   Receved data ready from network.  The RNet request will
 *	    automagically be reissued on return.
 */

do_rnet()
{
    ubyte *ptr = RcvBuf;
    long len = RcvData;

        d       ٘F" RcvData = 0;

    RExpect = RecvPacket(ptr, len);
}


/*
 *  DO_WUPDATE()
 *
 *  (1) Remove EMPTY windows at head of transmit queue.
 *  (2) Fill up transmit queue with pending requests, if any.
 *
 *  First two bits determine CMD as follows:
 *	    0bbbbbbb+0x20	DATA	    0-95 bytes of DATA
 *	    10bbbccc		DATA	    0-7 bytes of DATA, ccc=channel
 *								  command.
 *	    11bbbbbb bbbbbbbb	DATA	    0-1023 bytes of DATA
 *
 *  Note!  By encoding the quick-data packet with the lengt     d       7bh + 0x20, you
 *  don't take the 6 bit encoding hit when sending small amounts of ascii
 *  data such as keystrokes.
 */

do_wupdate()
{
    static short XPri;
    int maxpktsize;
    register XIOR *ior;
    register PKT *pkt;
    register long len;
    short loop = 0;

    WReady = 0;
    while (WPUsed && WPak[0]->state == EMPTY) {
	pkt = WPak[0];
	WPak[0] = WPak[1];
	WPak[1] = WPak[2];
	WPak[2] = WPak[3];
	WPak[3] = pkt;
	--WPUsed;
	++WPStart;
    }
    if (Restart)
	return(0);

       \       	if (*ptr < 0x20 && BadCtl[*ptr])
	    range |= 1;
	if (*ptr >= 0x80)
	    range |= 2;
	++ptr;
    }
    if (Mode7 && range) {
	uword buflen = Expand6(dbuf, pkt->data, actlen);
	BuildPacket(pkt, PKCMD_WRITE6, win, pkt->data, actlen, buflen);
    } else {
	if (Mode7 || (range & 2)) {
	    BuildPacket(pkt, PKCMD_WRITE, win, dbuf, actlen, actlen);
	} else {
	    uword buflen = Compress7(dbuf, pkt->data, actlen);
	    BuildPacket(pkt, PKCMD_WRITE7, win, pkt->data, actlen, buflen);
	}
         \       [?}
}

PKT *
BuildRestartAckPacket(dbuf, bytes)
ubyte *dbuf;
ubyte bytes;
{
    static PKT pkt;
    BuildPacket(&pkt, PKCMD_ACKRSTART, 0, dbuf, bytes, bytes);
    return(&pkt);
}

void
BuildPacket(pkt, ctl, win, dbuf, actlen, buflen)
PKT	*pkt;
ubyte	ctl;
ubyte	*dbuf;
uword	actlen;
uword	buflen;
{
    pkt->buflen = buflen;
    pkt->sync = SYNC;
    pkt->ctl = ctl | win;
    pkt->cchk = Ascize((pkt->sync << 1) ^ pkt->ctl);
    if (actlen) {
	uword chk = chkbuf(dbuf, buflen);
	ubyte dchkh     \       QB = chk >> 8;
	ubyte dchkl = chk;

	pkt->lenh = Ascize(actlen >> 6);
	pkt->lenl = Ascize(actlen);
	pkt->dchkh= Ascize(dchkh);
	pkt->dchkl= Ascize(dchkl);
	if (dbuf != pkt->data)
	    bcopy(dbuf, pkt->data, buflen);
    }
}

void
WritePacket(pkt)
PKT *pkt;
{
    if (DDebug)
	printf("SEND-PACKET %02x %d\n", pkt->ctl, pkt->buflen);

    if (pkt->buflen)
	NetWrite(&pkt->sync, 7 + pkt->buflen);
    else
	NetWrite(&pkt->sync, 3);
    switch(pkt->ctl) {
    case PKCMD_WRITE:
    case PKCMD_W     \       ;CRITE6:
    case PKCMD_WRITE7:
    case PKCMD_RESTART:
	WTimeout(WTIME);
    }
}

void
WriteCtlPacket(ctl, win)
{
    static CTLPKT pkt;

    NetWrite(NULL, 0);
    BuildPacket(&pkt, ctl, win, NULL, 0, 0);
    WritePacket(&pkt);
}

void
WriteNak(win)
{
    WriteCtlPacket(PKCMD_NAK, win);
}

void
WriteAck(win)
{
    WriteCtlPacket(PKCMD_ACK, win);
}

void
WriteChk(win)
{
    WriteCtlPacket(PKCMD_CHECK, win);
}

void
WriteRestart()
{
    WriteCtlPacket(PKCMD_RESTART, 0);
}

/*
 *	RECEIV     \       sE A PACKET
 */

int
RecvPacket(ptr, len)
ubyte *ptr;
long len;
{
    static uword ActLen;    /*	actual # bytes after decoding */
    static uword BufLen;    /*	length of input data buffer   */
    static uword DBLen;     /*	# bytes already in i.d.buf    */
    static ubyte RState;
    static PKT	 Pkt;
    ubyte  *dptr;
    short expect;

    if (ptr == NULL) {
	RState = 0;
	return(3);
    }

    while (len) {
	switch(RState) {
	case 0:
	    --len;
	    Pkt.sync = *ptr++;

	    if (Pk     \       Act.sync == SYNC)
		++RState;
	    break;
	case 1: 	/*  CTL */
	    --len;
	    Pkt.ctl = *ptr++;

	    if (Pkt.ctl < 0x20 || Pkt.ctl > 0x7F) {
		RState = 0;
		break;
	    }
	    ++RState;
	    break;
	case 2: 	/*  CCHK    */
	    --len;
	    Pkt.cchk = *ptr++;

	    if (Ascize((SYNC<<1) ^ Pkt.ctl) != Pkt.cchk) {
		RState = 0;
		break;
	    }
	    switch(Pkt.ctl & PKF_MASK) {
	    case PKCMD_ACKRSTART:
	    case PKCMD_WRITE:
	    case PKCMD_WRITE6:
	    case PKCMD_WRITE7:
		if (DDebug)     \       
		    printf("Recv Header %02x\n", Pkt.ctl & PKF_MASK);
		++RState;
		break;
	    default:
		if (DDebug)
		    printf("Recv Control %02x\n", Pkt.ctl & PKF_MASK);
		do_cmd(Pkt.ctl, NULL, 0);
		RState = 0;
		break;
	    }
	    break;
	case 3: 	/*  LENH    */
	    --len;
	    Pkt.lenh = *ptr++;

	    ++RState;
	    if (Pkt.lenh < 0x20 || Pkt.lenh > 0x7F)
		RState = 0;
	    break;
	case 4: 	/*  LENL    */
	    --len;
	    Pkt.lenl = *ptr++;

	    if (Pkt.lenl < 0x20 || Pkt.lenl > 0x7F)      \   	    K,{
		RState = 0;
		break;
	    }

	    ++RState;

	    ActLen = ((Pkt.lenh & 0x3F) << 6) | (Pkt.lenl & 0x3F);
	    DBLen = 0;

	    switch(Pkt.ctl & PKF_MASK) {
	    case PKCMD_ACKRSTART:
	    case PKCMD_WRITE:
		BufLen = ActLen;
		break;
	    case PKCMD_WRITE6:
		BufLen = (ActLen * 8 + 5) / 6;
		break;
	    case PKCMD_WRITE7:
		BufLen = (ActLen * 7 + 7) / 8;
		break;
	    default:
		puts("BaD");
		break;
	    }

	    if (ActLen > MAXPKT || BufLen > MAXPACKET) {
		if (DDebug || DDebug     \   
    k(]!)
		    printf("Packet Length Error %d %d\n", ActLen, BufLen);
		RState = 0;
	    }
	    break;
	case 5: 	/*  DChkH   */
	    --len;
	    Pkt.dchkh = *ptr++;

	    ++RState;
	    if (Pkt.dchkh < 0x20 || Pkt.dchkh > 0x7F)
		RState = 0;
	    break;
	case 6: 	/*  DCHKL   */
	    --len;
	    Pkt.dchkl = *ptr++;

	    ++RState;
	    if (Pkt.dchkl < 0x20 || Pkt.dchkl > 0x7F)
		RState = 0;
	    break;
	case 7: 	/*  -DATA-  */
	    if (DBLen + len < BufLen) {     /*  not enough  */
		bcopy(p     \       tr, Pkt.data + DBLen, len);
		DBLen += len;
		len = 0;
		break;
	    }

	    /*
	     *	Enough data, check chk
	     */

	    bcopy(ptr, Pkt.data + DBLen, BufLen - DBLen);
	    len -= BufLen - DBLen;
	    ptr += BufLen - DBLen;

	    {
		uword chk;
		ubyte chkh;
		ubyte chkl;

		chk = chkbuf(Pkt.data, BufLen);
		chkh = Ascize(chk >> 8);
		chkl = Ascize(chk);

		if (Pkt.dchkh != chkh || Pkt.dchkl != chkl) {
		    printf("Chksum failure %02x %02x %02x %02x\n",
			Pkt.dchkh, chkh, Pkt.d     \       wnchkl, chkl
		    );
		    RState = 0;
		    break;
		}
	    }

	    switch(Pkt.ctl & PKF_MASK) {
	    case PKCMD_ACKRSTART:
		dptr = Pkt.data;
		break;
	    case PKCMD_WRITE:
		dptr = Pkt.data;
		break;
	    case PKCMD_WRITE6:
		UnExpand6(Pkt.data, RxTmp, ActLen);
		dptr = RxTmp;
		break;
	    case PKCMD_WRITE7:
		UnCompress7(Pkt.data, RxTmp, ActLen);
		dptr = RxTmp;
		break;
	    default:
		puts("BaD2");
		dptr = Pkt.data;
		break;
	    }
	    if (DDebug)
		printf("Recv Body   %02x      X         te;
fd_set Fdexcept;
void (*Fdstate[FD_SETSIZE])();
ubyte Fdperm[FD_SETSIZE];
uword FdChan[FD_SETSIZE];
ubyte RcvBuf[RCVBUF];
uword RcvData;
uword RExpect;
ubyte RTimedout;
ubyte WTimedout;
uword WChan;		/*  Read and Write channels	    */
uword RChan;
uword RPStart;
uword WPStart;
uword WPUsed;
uword RState;
uword Rto_act, Wto_act;
ubyte DDebug;
ubyte PDebug;
ubyte Restart;
ubyte DeldQuit;
ulong NumCon;
ubyte Mode7 = 1;
int WReady;

                                         D                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         Z       }-   break;
    }
    if (envp[i] == NULL) {
	puts("must set a dummy DNETDIR enviroment variable");
	exit(1);
    }


    if (socketpair(AF_UNIX, SOCK_STREAM, 0, files) < 0) {
	perror("socketpair");
	exit(1);
    }

    envp[i] = buf;
    if (fork() == 0) {
	int fd = open("d1.log", O_WRONLY | O_CREAT | O_TRUNC, 0666);
	if (dup2(files[0], 0) < 0)
	    perror("dup2-1");
	dup2(fd, 1);
	dup2(fd, 2);
	if (write(0, "", 0) < 0) {
	    perror("write");
	    exit(1);
	}
        sprintf(buf, "DN     Z       U7ETDIR=%s", av[1]);
	execlp("dnet", "dnet", "debug", NULL);
	perror("exec");
	exit(1);
    }
    if (fork() == 0) {
	int fd = open("d2.log", O_WRONLY | O_CREAT | O_TRUNC, 0666);
	if (dup2(files[1], 0) < 0)
	    perror("dup2-1");
	dup2(fd, 1);
	dup2(fd, 2);
	close(files[0]);
	close(files[1]);
	if (write(0, "", 0) < 0) {
	    perror("write");
	    exit(1);
	}
        sprintf(buf, "DNETDIR=%s", av[2]);
	execlp("dnet", "dnet", "debug", NULL);
	perror("exec");
	exit(1);
    }
    close(fil     Z      }    xes[0]);
    close(files[1]);
    {
	int pid;
        while ((pid = wait(0)) > 0)
	    printf("pid %d exit\n", pid);
    }
}

ocketpair(AF_UNIX, SOCK_STREAM, 0, files) < 0) {
	perror("socketpair");
	exit(1);
    }

    envp[i] = buf;
    if (fork() == 0) {
	int fd = open("d1.log", O_WRONLY | O_CREAT | O_TRUNC, 0666);
	if (dup2(files[0], 0) < 0)
	    perror("dup2-1");
	dup2(fd, 1);
	dup2(fd, 2);
	if (write(0, "", 0) < 0) {
	    perror("write");
	    exit(1);
	}
        sprintf(buf, "DN     Q       :Qbuf[256];
    uword chan = FdChan[fd];
    int n;

    n = read(fd, buf, sizeof(buf));
    if (DDebug) {
	fprintf(stderr, "DO_OPEN %ld %ld, RECEIVE DATA on chan %ld (%ld by)\n",
	    nn, fd, chan, n);
	fprintf(stderr, " fd, chanfd %ld %ld\n", fd, Chan[chan].fd);
	if (n < 0)
	    perror("open:read");
    }
    if (n == 0 || nn == 2) {	/* application closed / exception cond */
	CCLOSE cc;

	if (DDebug)
	    fprintf(stderr, " DO_OPEN: REMOTE EOF, channel %d\n", chan);

	cc.chanh = chan      Q       2m>> 8;
	cc.chanl = chan;
	WriteStream(SCMD_CLOSE, &cc, sizeof(CCLOSE), chan);
	Chan[chan].state = CHAN_CLOSE;
	Chan[chan].flags |= CHANF_LCLOSE;
	if (Chan[chan].flags & CHANF_RCLOSE) {
	    ;
	    /* should never happen
	    int fd = Chan[chan].fd;
	    Chan[chan].state = CHAN_FREE;
	    Chan[chan].fd = -1;
	    Fdstate[fd] = nop;
	    FD_CLR(fd, &Fdread);
	    FD_CLR(fd, &Fdexcept);
	    close(fd);
	    */
	} else {
	    FD_CLR(fd, &Fdread);
	    FD_CLR(fd, &Fdexcept);
	}
    }
    i     Q      <    `D(f (n > 0) {
	WriteStream(SCMD_DATA, buf, n, chan);
    }
}

ead(fd, buf, sizeof(buf));
    if (DDebug) {
	fprintf(stderr, "DO_OPEN %ld %ld, RECEIVE DATA on chan %ld (%ld by)\n",
	    nn, fd, chan, n);
	fprintf(stderr, " fd, chanfd %ld %ld\n", fd, Chan[chan].fd);
	if (n < 0)
	    perror("open:read");
    }
    if (n == 0 || nn == 2) {	/* application closed / exception cond */
	CCLOSE cc;

	if (DDebug)
	    fprintf(stderr, " DO_OPEN: REMOTE EOF, channel %d\n", chan);

	cc.chanh = chan      V   	  ?    N
isetcols(fd, cols)
{
#ifdef TIOCSSIZE
    struct ttysize ts;
    if (ioctl(fd, TIOCGSIZE, &ts) >= 0) {
	ts.ts_cols = cols;
	ioctl(fd, TIOCSSIZE, &ts);
    }
#else
#ifdef TIOCSWINSZ
    struct winsize ws;
    if (ioctl(fd, TIOCGWINSZ, &ws) >= 0) {
	ws.ws_col = cols;
	ioctl(fd, TIOCSWINSZ, &ws);
    }
#endif
#endif
}

(j = 0; ptcs[j]; ++j) {
	    plate[9] = ptcs[j];
	    plate[5] = 'p';
	    if ((*pfdm = open(plate, O_RDWR)) >= 0) {
		plate[5] = 't';
		if ((*pfds = open(plate, O_RDWR)     V       	"&port)
uword port;
{
    if (port == PORT_IALPHATERM)
	return(1);
    return(0);
}

iconnect(ps, port)
int *ps;
uword port;
{
    if (port == PORT_IALPHATERM)
	return(ialphaterm_connect(ps, port));
    return(-1);
}

ialphaterm_connect(pmaster)
int *pmaster;
{
    struct sgttyb sg;
    struct tchars tc;
    struct ltchars ltc;
#ifdef TIOCGSIZE
    struct ttysize ts;
#else
#ifdef TIOCGWINSZ
    struct winsize ws;
#endif
#endif
    int lmode;
    int fdmaster;
    int fdslave;
    int p     V       
T8id;
    char *slavename;

    ioctl(0, TIOCGETP, (char *)&sg);
    ioctl(0, TIOCGETC, (char *)&tc);
    ioctl(0, TIOCGLTC, (char *)&ltc);
    ioctl(0, TIOCLGET, (char *)&lmode);
#ifdef TIOCGSIZE
    ioctl(0, TIOCGSIZE, &ts);
#else
#ifdef TIOCGWINSZ
    ioctl(0, TIOCGWINSZ, &ws);
#endif
#endif

    sg.sg_flags &= ~(RAW);
    sg.sg_flags |= ECHO;
#ifdef TIOCGSIZE
    ts.ts_lines = 23;
    ts.ts_cols = 77;
#else
#ifdef TIOCGWINSZ
    ws.ws_row = 23;
    ws.ws_col = 77;
#endif
#endif

       V       N,  if (DDebug)
	fprintf(stderr, "PTY openning internal pty\n");
    if (openpty(&fdmaster, &fdslave, &slavename) >= 0) {
	if (DDebug)
	    fprintf(stderr, "PTY open successfull\n");
	if ((pid = fork()) == NULL) {
	    int i;
	    setenv("DNET=", "IALPHATERM");
	    setuid(getuid());
	    signal(SIGHUP, SIG_DFL);
	    signal(SIGINT, SIG_DFL);
	    signal(SIGQUIT, SIG_DFL);
	    signal(SIGTERM, SIG_DFL);
	    signal(SIGCHLD, SIG_DFL);
	    signal(SIGTSTP, SIG_IGN);
	    ioctl(open("/dev     V       /tty", 2), TIOCNOTTY, NULL);
	    close(open(slavename, 0));
	    dup2(fdslave, 0);
	    dup2(0, 1);
	    dup2(0, 2);
	    for (i = 3; i < 256; ++i)
		close(i);
	    ioctl(0, TIOCSETN, &sg);
	    ioctl(0, TIOCSETC, &tc);
	    ioctl(0, TIOCSLTC, &ltc);
	    ioctl(0, TIOCLSET, &lmode);
#ifdef TIOCSSIZE
    	    ioctl(0, TIOCSSIZE, &ts);
#else
#ifdef TIOCSWINSZ
    	    ioctl(0, TIOCSWINSZ, &ws);
#endif
#endif
	    {
		char *shell = getenv("SHELL");
		char *home = getenv("HOME");
		if (     V