h50357
s 00007/00009/01206
d D 2.17 94/05/05 22:14:22 tim 23 22
c changed the checksum mechanism to be based arount the CCITT CRC mechanism
e
s 00001/00000/01214
d D 2.16 94/05/05 21:27:42 tim 22 21
c set things up to seset the sum counter
e
s 00004/00003/01210
d D 2.15 94/05/05 21:19:48 tim 21 20
c changes the checksum method to use a ULONG not a TEXT
e
s 00049/00001/01164
d D 2.14 94/05/05 20:08:04 tim 20 19
c addes code to checksum file
e
s 00002/00002/01163
d D 2.13 94/05/05 19:15:56 tim 19 18
c fix minor typo
e
s 00001/00001/01164
d D 2.12 94/05/05 18:59:41 tim 18 17
c fix minor typo
e
s 00006/00017/01159
d D 2.11 94/05/05 18:56:22 tim 17 16
c modified the routines to convert ascii to hex as they were converting all
c values above 7F to 0F for some reason. Removed the old code and installed a bit mask and array lookup system (probabaly faster)
e
s 00102/00026/01074
d D 2.10 94/03/22 18:35:16 tim 16 15
c added routinet to return the modification tim eof a file, and set is't read / rewa write attribute
e
s 00004/00000/01096
d D 2.9 94/03/21 22:28:20 tim 15 14
c in the routines sunsz and sunft I was using the variable tmp which turned out to be a statis used elsewhere, fixed by adding information to the local
c declarations
e
s 00008/00005/01088
d D 2.8 94/03/21 20:56:40 tim 14 13
c changed the code that does the sunft stuff to return all the attributes, not just the first
e
s 00005/00006/01088
d D 2.7 94/03/21 20:10:10 tim 13 12
c fixed minor typos, unfortunatly the topspeed copilers have to be run under sunpc which means that I have to do an sccs delta for each fix !
e
s 00085/00001/01009
d D 2.6 94/03/21 20:01:27 tim 12 11
c added 3 new calle, sunft (returns the file type) sunsz (returns the file size) and sunrw (returns RO or RW if the file is rw)
e
s 00001/00001/01009
d D 2.5 94/03/21 15:43:24 tim 11 10
c added sccs verioning strings
e
s 00003/00046/01007
d D 2.4 94/03/19 23:00:51 tim 10 9
c remofed the ascii file transfer code
e
s 00002/00001/01051
d D 2.3 94/03/19 22:57:58 tim 9 8
c fixed a bug whereby a sunpf did not close the filehandle
e
s 00001/00001/01051
d D 2.2 93/12/20 12:59:09 tim 8 7
c fixed printing width problem in wpath
e
s 00062/00366/00990
d D 2.1 93/12/20 03:19:35 tim 7 6
c major rewrite to operate on pathnames not the old (and stupid) partition, directory, filename stuff
e
s 00002/00001/01354
d D 1.6 93/12/20 01:02:54 tim 6 5
c fixed iritating problem in wtalk that did something nasty on displaying text
e
s 00052/00015/01303
d D 1.5 93/12/20 00:08:49 tim 5 4
c fixed the sunlx routines and removed the speclist routine 
c this should now (sunctionaly at any rate) be the same as the suncom.opl progs
e
s 00001/00001/01317
d D 1.4 93/12/19 23:46:21 tim 4 3
c fixed a fex windoeing layout probs
e
s 00079/00059/01239
d D 1.3 93/12/19 23:06:05 tim 3 2
c got window code working now
e
s 00199/00018/01099
d D 1.2 93/12/19 18:10:37 tim 2 1
c added the window functionality
e
s 01117/00000/00000
d D 1.1 93/12/19 15:46:40 tim 1 0
c date and time created 93/12/19 15:46:40 by tim
e
u
U
f e 0
t
T
I 1
/* this file is a test implementation of my suncom.opl program */
/* this is as close to a straight port as I can manage */
I 12
/* this program is sort of stateless appart from the fact that */
/* all file operations requite the path to be setup */
E 12
#include <plib.h>
#include <wlib.h>
I 12
D 13
#include <p_file.h>
E 13
E 12
#include <p_serial.h>

/* globals */
/* path strings */
D 7
TEXT sundir[120], sunfile[12], sunpart[10], sunname[145];
E 7
I 7
TEXT sunname[200];
E 7
/* transmition strings */
TEXT hextxt[255], dectxt[255], suncmd[20], cmdlist[200];
/* temporary space */
D 2
TEXT tmp[300] ;
E 2
I 2
D 3
TEXT tmp[300], wtmp[100] ;
E 3
I 3
D 5
TEXT tmp[300], wtmp[200] ;
E 5
I 5
TEXT tmp[300], wtmp[200] , ptmp[200] ;
I 17
/* index array for hex transformations */
TEXT hexarr[16] = "0123456789ABCDEF" ;
E 17
E 5
/* spacestr points to a sequence of spaces */
TEXT * spacestr ;
E 3
E 2
/* file handles */
INT  devh,  fileh ;
/* line counters */
INT lineid, sndline ;
I 3
/* window line counters point */
INT lineidpt, sndlinept ;
E 3
/* toggles */
INT vrb, tmode, scr;
/* window handles */
INT winline, winsnd, wintalk, winpath, wintog ;
I 2
/* window structures */
W_WINDATA wdline, wdsnd, wdtalk, wdpath, wdtog ;
/* graphics contexts */
UINT gcline, gcsnd, gctalk, gcpath, gctog ;
/* gc data setup structs */
G_GC gdline, gdsnd, gdtalk, gdpath, gdtog ;
E 2
/* input controler ??? */
INT linelen;
D 3
/* definr the number of chars to read in each send block */
E 3
I 3
/* line widths */
#define HALFWIDTH 105
#define FULLWIDTH 225
/* define the number of chars to read in each send block */
E 3
#define MAXRD 120

/* debug defines */
/* define CALLDEBUG to track the function calls set it to be the delay in 1/10 seconds */
/*#define CALLDEBUG 5*/
/* define PATHDEBUG (as above) to track file names  */
/*#define PATHDEBUG 5*/
/* set linedbg (as above) to see what goes along the serial line */
/*#define LINEDEBUG 5*/

/* function definitions */
void main(void), getcmd(void), getline(void) ;
int ioget(void) ;
D 7
void execmd(void), feedback(TEXT * msg), putline(TEXT * msg, int line) ;
E 7
I 7
void setdefp(void) ,execmd(void), feedback(TEXT * msg), putline(TEXT * msg, int line) ;
E 7
void initlink(void), setline(void) ;
D 7
void initscr(void), wpart(void), wdir(void), wfile(void), wvb(void) ;
E 7
I 7
void initscr(void), wpath(void), wvb(void) ;
E 7
void wtm(void), wsc(void), wtalk( TEXT * msg), wline(void), wsnd(void), shutdown(void) ;
void initsys(void), sunvn(void), sunol(void), suniv(void), sunia(void), sunis(void), sunds(void);
D 7
void sunvb(void), sunsc(void), suntm(void), sunud(void), sunuf(void), sunup(void), setdefp(void);
void setdefd(void), setdeff(void), sunsd(void), updsd(void), sunsp(void), sundt(void), updsp(void) , sunsf(void) ;
void updsf(void), sunep(void), sunef(void), builddir(void), buildnme(void), suned(void), exlist(void), buildprt(void), sunlf(void) ;
D 5
void sunlp (void), sunld(void), speclist(void), sunrf(void), sunrd(void), sundc(void), sunmd(void) ;
E 5
I 5
void sunlp (void), sunld(void), sunrf(void), sunrd(void), sundc(void), sunmd(void) ;
E 7
I 7
void sunvb(void), sunsc(void), suntm(void), setp(void);
void updsp(void), sunsp(void), sundt(void);
void sunrp(void), sunep(void), exlist(void);
void sunlp (void), sundc(void), sunmd(void) ;
E 7
E 5
D 2
void sungf(void), sungfa(void), sungfb(void);
E 2
I 2
D 10
void sungf(void), sungfa(void), sungfb(void), wsline(void), wssnd(void);
E 10
I 10
void sungf(void), sungfb(void), wsline(void), wssnd(void);
E 10
E 2
void sunpf (void), sunsl(void), sunrl(void), suntalk(TEXT * msg) ;
I 12
D 13
void sunft(void) ;
E 13
I 13
D 16
void sunft(void), sunrw(void), sunsz(void) ;
E 16
I 16
/* return status on files */
D 20
void sunft(void), sunrw(void), sunsz(void), sunti(void), sunwn(void), sunwy(void) ;
E 20
I 20
void sunft(void), sunrw(void), sunsz(void), sunti(void), sunwn(void), sunwy(void), suncs(void) ;
E 20
E 16
E 13
E 12
#ifdef CALLDEBUG
void calldbg (TEXT * msg) ;
void calldbg (TEXT * msg)
{
D 3
	p_printf("call :%s\n", msg) ;
E 3
I 3
	p_print("Call %s\n", msg) ;
E 3
	p_sleep((ULONG) CALLDEBUG) ;
}
#endif
#ifdef PATHDEBUG
void pathdbg (TEXT * msg, TEXT * msg1) ;
void pathdbg (TEXT * msg, TEXT * msg1) 
{
D 3
	p_printf(":%s: :%s:\n",msg, msg1) ;
E 3
I 3
	p_print(":%s: :%s:\n",msg, msg1) ;
E 3
	p_sleep((ULONG) PATHDEBUG) ;
}
#endif

 void main(void)
{
#ifdef CALLDEBUG
	calldbg("main") ;
#endif
	initsys() ;
D 2
	while (p_scmpi("dc", suncmd) != 0)
E 2
I 2
D 3
	p_sleep(100) ;
	/* while (p_scmpi("dc", suncmd) != 0)
E 3
I 3
	while (p_scmpi("dc", suncmd) != 0)
E 3
E 2
        {
		getcmd() ;
		execmd() ;
D 2
	}
E 2
I 2
D 3
	} */
E 3
I 3
	}
E 3
E 2
	shutdown() ;
}

 void getcmd(void) 
{
#ifdef CALLDEBUG
	calldbg("getcmd") ;
#endif
	getline() ;
	suncmd[0] = dectxt[0] ;
	suncmd[1] = dectxt[1] ;
	suncmd[2] = 0 ;
}

 void getline(void) 
{
#ifdef CALLDEBUG
	calldbg("getline") ;
#endif
	linelen=ioget() ;
	if (linelen < 2)
		p_scpy(dectxt, "XX") ;
}

INT ioget(void)
{
	INT ret, cnt;
	UWORD v ;
	TEXT *ptr ;
#ifdef CALLDEBUG
	calldbg("ioget") ;
#endif

	putline(">",0) ;
	ret = p_read(devh, tmp, 3) ;
	/* mod from the origional code, we can do this differently */
	tmp[3] = 0;
	ptr = tmp + 1;
        p_stog(&ptr, &v, 16) ;
	cnt = (INT) v ;
	ret = p_read(devh, dectxt, cnt) ;
	dectxt[cnt] = 0 ;
#ifdef LINEDEBUG
D 3
	p_printf("ioget, count = %d, data :%s:\n", cnt, dectxt) ;
E 3
I 3
	p_print("ioget, count = %d, data :%s:\n", cnt, dectxt) ;
E 3
	p_sleep((ULONG) LINEDEBUG) ;
#endif
	lineid ++ ;
	wline() ;
	return (ret) ;
}


 void execmd(void)
{


#ifdef CALLDEBUG
	calldbg("execmd");
#endif
	
	/* this section is rewritten to operate as a switch */

D 16
	if (p_scmpi("dc", suncmd) == 0)
E 16
I 16
	if (p_scmpi("dc", suncmd) == 0) /* disconnect */
E 16
		sundc() ;
D 16
	else if (p_scmpi("vn", suncmd) == 0)
E 16
I 16
	else if (p_scmpi("vn", suncmd) == 0) /* version number */
E 16
		sunvn() ;
I 12
D 16
	else if (p_scmpi("ft", suncmd) == 0)
E 16
I 16
	else if (p_scmpi("ft", suncmd) == 0) /* file attributes */
E 16
		sunft() ;
D 16
	else if (p_scmpi("sz", suncmd) == 0)
E 16
I 16
	else if (p_scmpi("sz", suncmd) == 0) /* file size */
E 16
		sunsz() ;
D 16
	else if (p_scmpi("rw", suncmd) == 0)
E 16
I 16
	else if (p_scmpi("rw", suncmd) == 0) /* is file ro or rw */
E 16
		sunrw() ;
E 12
D 7
	else if (p_scmpi("sf", suncmd) == 0)
		sunsf() ;
E 7
D 16
	else if (p_scmpi("sp", suncmd) == 0)
E 16
I 16
	else if (p_scmpi("sp", suncmd) == 0) /* set the path */
E 16
		sunsp() ;
D 7
	else if (p_scmpi("sd", suncmd) == 0)
		sunsd() ;
E 7
I 7
D 16
	else if (p_scmpi("rp", suncmd) == 0)
E 16
I 16
	else if (p_scmpi("rp", suncmd) == 0) /* remove the file */
E 16
		sunrp() ;
E 7
D 16
	else if (p_scmpi("lp", suncmd) == 0)
E 16
I 16
	else if (p_scmpi("ti", suncmd) == 0) /* file modified time */
		sunti() ;
	else if (p_scmpi("lp", suncmd) == 0) /* list the path */
E 16
		sunlp() ;
D 7
	else if (p_scmpi("ld", suncmd) == 0)
		sunld() ;
	else if (p_scmpi("lf", suncmd) == 0)
		sunlf() ;
	else if (p_scmpi("ef", suncmd) == 0)
		sunef() ;
E 7
D 16
	else if (p_scmpi("ep", suncmd) == 0)
E 16
I 16
	else if (p_scmpi("ep", suncmd) == 0) /* does the path exist ? */
E 16
		sunep() ;
D 7
	else if (p_scmpi("ed", suncmd) == 0)
		suned() ;
	else if (p_scmpi("rf", suncmd) == 0)
		sunrf() ;
	else if (p_scmpi("rd", suncmd) == 0)
		sunrd() ;
E 7
D 16
	else if (p_scmpi("gf", suncmd) == 0)
E 16
I 16
	else if (p_scmpi("gf", suncmd) == 0) /* get file from the sun */
E 16
		sungf() ;
D 16
	else if (p_scmpi("pf", suncmd) == 0)
E 16
I 16
	else if (p_scmpi("pf", suncmd) == 0) /* put file to the sun */
E 16
		sunpf() ;
D 16
	else if (p_scmpi("md", suncmd) == 0)
E 16
I 16
	else if (p_scmpi("md", suncmd) == 0) /* mkdir the path */
E 16
		sunmd() ;
D 7
	else if (p_scmpi("up", suncmd) == 0)
		sunup() ;
	else if (p_scmpi("ud", suncmd) == 0)
		sunud() ;
	else if (p_scmpi("uf", suncmd) == 0)
		sunuf() ;
E 7
D 16
	else if (p_scmpi("vb", suncmd) == 0)
E 16
I 16
	else if (p_scmpi("vb", suncmd) == 0) /* tobble verbose mode */
E 16
		sunvb() ;
D 16
	else if (p_scmpi("ds", suncmd) == 0)
E 16
I 16
	else if (p_scmpi("ds", suncmd) == 0) /* dump current strings */
E 16
		sunds() ;
D 16
	else if (p_scmpi("tm", suncmd) == 0)
E 16
I 16
	else if (p_scmpi("tm", suncmd) == 0) /* transfer mode */
E 16
		suntm() ;
D 16
	else if (p_scmpi("iv", suncmd) == 0)
E 16
I 16
	else if (p_scmpi("iv", suncmd) == 0) /* are we verbose ? */
E 16
		suniv() ;
D 16
	else if (p_scmpi("ia", suncmd) == 0)
E 16
I 16
	else if (p_scmpi("ia", suncmd) == 0) /* are we using ascii ? */
E 16
		sunia() ;
D 16
	else if (p_scmpi("sc", suncmd) == 0)
E 16
I 16
	else if (p_scmpi("sc", suncmd) == 0) /* toggle the screen mode */
E 16
		sunsc() ;
D 16
	else if (p_scmpi("is", suncmd) == 0)
E 16
I 16
	else if (p_scmpi("is", suncmd) == 0) /* is the screen on ? */
E 16
		sunis() ;
D 16
	else if (p_scmpi("sl", suncmd) == 0)
E 16
I 16
	else if (p_scmpi("sl", suncmd) == 0) /* reset sent line counter */
E 16
		sunsl() ;
D 16
	else if (p_scmpi("rl", suncmd) == 0)
E 16
I 16
	else if (p_scmpi("rl", suncmd) == 0) /* reset recieved line counter */
E 16
		sunrl() ;
D 16
	else if (p_scmpi("ol", suncmd) == 0)
E 16
I 16
	else if (p_scmpi("ol", suncmd) == 0) /* are we online ? */
E 16
		sunol() ;
D 16
	else if (p_scmpi("dt", suncmd) == 0)
E 16
I 16
	else if (p_scmpi("dt", suncmd) == 0) /* display text in window */
E 16
		sundt() ;
I 16
	else if (p_scmpi("wy", suncmd) == 0) /* set rw mode on file */
		sunwy() ;
	else if (p_scmpi("wn", suncmd) == 0) /* set ro mode on file */
		sunwn() ;
I 20
	else if (p_scmpi("cs", suncmd) == 0) /* compute the checksum on a file */		suncs() ;
E 20
E 16
	else
		feedback("BADCMD") ;
}

 void feedback( TEXT  * msg)
{
#ifdef CALLDEBUG
	calldbg("feedback");
#endif
	tmp[0] = 0 ;

	p_scpy(tmp, "X") ;
        p_scat(tmp, msg) ;
	putline(tmp, 1) ;
}

 void putline(TEXT * msg, INT line) 
{
	INT i, len;
#ifdef CALLDEBUG
	calldbg("putline");
#endif
#ifdef LINEDEBUG
D 3
	p_printf("putline :%s:\n", msg) ;
E 3
I 3
	p_print("putline :%s:\n", msg) ;
E 3
	p_sleep ((ULONG) LINEDEBUG) ;
#endif
	p_scpy(tmp, msg) ;
	/* put a CRLF pair at the end of the line and more the NULL allong */
	i = p_slen(tmp) ; 
	tmp[i] = 13 ;
	tmp[i+1] = 10 ;
	tmp[i+2] = 0 ;

	len = p_slen(tmp) ;
	if (len != i + 2)
	{
D 3
		p_printf("Error in printing lengths disagree\n") ;
E 3
I 3
		suntalk("Error in printing lengths disagree\n") ;
E 3
		p_getch() ;
		p_exit(0) ;
	}
	p_write(devh, tmp, len) ;
	if (line)
	{
		sndline ++ ;
		wsnd() ;
	}
}

 void initlink(void)
{
	INT ret ;
#ifdef CALLDEBUG
	calldbg("initlink");
#endif
	ret = p_open(&devh, "TTY:A", -1) ;
	if (ret != 0)
	{
D 3
		p_printf("Error in opening device\n");
E 3
I 3
		suntalk("Error in opening device\n");
E 3
		p_getch() ;
		p_exit(0) ;
	}
	feedback("ONLINE") ;
}

 void setline(void)
{
	P_SRCHAR pchar ;
#ifdef CALLDEBUG
	calldbg("setline");
#endif

	/* get the serial port informatrion */
	p_iow(devh, P_FSENSE, &pchar) ;
	/* not force the data we need */
	pchar.tbaud = P_BAUD_9600 ;
	pchar.rbaud = P_BAUD_9600 ;
	pchar.frame = P_DATA_7 ;
	pchar.parity= P_PAR_EVEN || (! P_TWOSTOP) ;
	pchar.hand  = P_IGN_CTS ;
	p_iow(devh, P_FSET, &pchar) ;
}

 void initsys(void)
{
#ifdef CALLDEBUG
	calldbg("initsys") ;
#endif
	hextxt[0] = 0 ;
	dectxt[0] = 0 ;
	suncmd[0] = 0 ;
D 3

E 3
I 3
	spacestr =  "                                 " ;
E 3
D 7
        p_scpy(cmdlist, "dc,vn,sf,sd,sp,lp,lf,ld,ef,ed,ep,rf,rd,gf,pf,md,up,ud,uf,vb,ds,tm,iv,ia,sc,is,sl,rl,ol,dt") ;

E 7
I 7
        p_scpy(cmdlist, "dc,vn,sp,lp,ep,rp,gf,pf,md,vb,ds,tm,iv,ia,sc,is,sl,rl,ol,dt") ;
E 7
	vrb = 1 ;
	tmode = 0 ;
	lineid = 0 ;
	scr = 1 ;
	setdefp() ;
	initscr () ;
	initlink() ;
}

I 7
void setdefp(void)
{
#ifdef CALLDEBUG
	calldbg("setdefp") ;
#endif
	p_scpy(sunname, "M:") ;
}
E 7

void sunvn(void)
{
#ifdef CALLDEBUG
	calldbg("sunvn") ;
#endif
	suntalk ("Sunvn") ;
D 7
	feedback("2.0") ;
E 7
I 7
D 9
	feedback("%I%") ;
E 9
I 9
D 11
	feedback("2.2") ;
E 11
I 11
	feedback("%I%") ;
E 11
E 9
E 7
}

 void suniv(void)
{
#ifdef CALLDEBUG
	calldbg("suniv") ;
#endif
	suntalk ("Suniv") ;
	if (vrb)
		feedback("YES") ;
	else
		feedback("NO") ;
}

 void sunia (void)
{
#ifdef CALLDEBUG
	calldbg("sunia") ;
#endif
	suntalk ("Sunia") ;
	if (tmode)
		feedback("YES") ;
	else
		feedback("NO") ;
}

 void sunis (void)
{
#ifdef CALLDEBUG
	calldbg("sunis") ;
#endif
	suntalk ("Sunis") ;
	if (scr)
		feedback("YES") ;
	else
		feedback ("NO") ;
}

 void sunds (void)
{
#ifdef CALLDEBUG
	calldbg("sunds") ;
#endif
	suntalk ("Sunds") ;
	feedback ("START") ;
D 7
	p_scpy(tmp, "Sunpart ") ;
	p_scat(tmp, sunpart) ;
E 7
I 7
	p_scpy(tmp, "Path ") ;
	p_scat(tmp, sunname) ;
E 7
	putline(tmp,1) ;
D 7
	p_scpy(tmp, "Sundir ") ;
	p_scat(tmp, sundir) ;
	putline(tmp,1) ;
	p_scpy(tmp, "Sunfile ") ;
	p_scat(tmp, sunfile) ;
	putline(tmp,1) ;
E 7
	feedback ("END") ;
}

 void sunvb (void)
{
#ifdef CALLDEBUG
	calldbg("sunvb") ;
#endif
	if (vrb == 0)
	{
		vrb = 1 ;
		suntalk ("Sunvb on") ;
	}
	else
	{
		vrb = 0 ;
		suntalk("Sunvb off") ;
	}
	feedback("OK") ;
	wvb() ;
}

 void sunsc (void)
{
#ifdef CALLDEBUG
	calldbg("sunsc") ;
#endif
	if (scr == 0)
	{
		scr = 1;
		suntalk("Sunsc ON") ;
I 3
D 7
		wpart() ;
		wdir() ;
		wfile() ;
E 7
I 7
		wpath() ;
E 7
		wsc() ;
		wvb() ;
		wtm() ;
		wsline() ;
		wline() ;
		wssnd() ;
		wsnd() ;
E 3
I 2
		wCancelBusyMsg() ;
E 2
	}
	else
	{
		scr = 0 ;
		suntalk("Sunsc OFF") ;
I 2
D 3
		wSetBusyMsg("Display Updates Disabled", W_CORNER_BOTTOM_LEFT | 0) ; 
E 3
I 3
		wSetBusyMsg("Display Updates OFF", W_CORNER_BOTTOM_LEFT | 0) ; 
E 3
E 2
	}
	feedback ("OK") ;
	wsc() ;
}

 void suntm (void)
{
#ifdef CALLDEBUG
	calldbg("suntm") ;
#endif
	if (tmode == 0)
	{
D 10
		tmode = 1 ;
		suntalk ("ASCII") ;
E 10
I 10
		feedback("BADMODE") ;
E 10
	}
	else
	{
		tmode = 0 ;
		suntalk ("BINARY") ;
	}
	feedback ("OK") ;
	wtm() ;
}

D 7
 void sunud (void)
E 7
I 7
 void setpath(void)
E 7
{
#ifdef CALLDEBUG
D 7
	calldbg("sunud") ;
#endif
	suntalk ("Sunud") ;
	setdefd() ;
	updsd();
	feedback("OK") ;
}

 void sunuf (void)
{
#ifdef CALLDEBUG
	calldbg("sunuf") ;
#endif
	suntalk("Sunuf") ;
	setdeff () ;
	updsf() ;
	feedback("OK") ;
}

 void sunup (void)
{
#ifdef CALLDEBUG
	calldbg("sunup") ;
#endif
	suntalk("Sunup") ;
	setdefp() ;
	updsp() ;
	feedback("OK") ;
}

 void setdefp(void)
{
#ifdef CALLDEBUG
E 7
	calldbg("setdefp") ;
#endif
D 7
	p_scpy(sunpart, "M:") ;
	setdefd() ;
E 7
I 7
	p_scpy(sunname, "M:") ;
E 7
}
D 16

E 16
D 7
 void setdefd(void)
{
#ifdef CALLDEBUG
	calldbg("setdefd") ;
#endif
	p_scpy(sundir, "") ;
	setdeff() ;
}

 void setdeff(void)
{
#ifdef CALLDEBUG
	calldbg("setdeff") ;
#endif
	p_scpy(sunfile, "") ;
}

 void sunsd(void)
{
#ifdef CALLDEBUG
	calldbg("sunsd") ;
#endif
	if (linelen < 4)
	{
		feedback("BADPARAM") ;
		return;
	}
	p_scpy(sundir, (dectxt + 3)) ;
	p_scpy(tmp, "Sunsd ") ;
	p_scat(tmp, sundir) ;
	suntalk (tmp) ;
	setdeff() ;
	updsd() ;
	feedback("OK") ;
}

 void updsd(void)
{
#ifdef CALLDEBUG
	calldbg("updsd") ;
#endif
	wdir() ;
	updsf() ;
}

E 7
 void sunsp(void)
{
#ifdef CALLDEBUG
	calldbg("sunsp") ;
#endif
	if (linelen < 4)
	{
		feedback("BADPARAM") ;
		return;
	}
D 7
	p_scpy(sunpart, (dectxt + 3)) ;
E 7
I 7
	p_scpy(sunname, (dectxt + 3)) ;
E 7
	p_scpy(tmp, "Sunsp ") ;
D 7
	p_scat(tmp, sunpart) ;
E 7
I 7
	p_scat(tmp, sunname) ;
E 7
	suntalk (tmp) ;
D 7
	setdefd() ;
E 7
	updsp() ;
	feedback("OK") ;
}

 void sundt(void)
{
#ifdef CALLDEBUG
	calldbg("sundt") ;
#endif
	if (linelen < 4)
	{
		feedback("BADPARAM") ;
		return ;
	}
	p_scpym(tmp, "Sundt ", (dectxt + 3)) ;
	suntalk (tmp) ;
	feedback ("OK") ;
}

 void updsp(void)
{
#ifdef CALLDEBUG
	calldbg("updsp") ;
#endif
D 7
	wpart() ;
	updsd() ;
E 7
I 7
	wpath() ;
E 7
}


D 7
 void sunsf(void)
{
#ifdef CALLDEBUG
	calldbg("sunsf") ;
#endif
	if (linelen < 4)
	{
		feedback("BADPARAM") ;
		return;
	}
	p_scpy(sunfile, (dectxt + 3)) ;
	p_scpy(tmp, "Sunsf ") ;
	p_scat(tmp, sunfile) ;
	suntalk (tmp) ;
	updsf() ;
	feedback("OK") ;
}

 void updsf(void)
{
#ifdef CALLDEBUG
	calldbg("updsf") ;
#endif
	wfile() ;
}

 void sunef(void)
{
	INT ret ;
	P_INFO fstat ;
#ifdef CALLDEBUG
	calldbg("sunef") ;
#endif
	buildnme() ;
	p_scpym(tmp, "Sunef ", sunname, NULL) ;
	suntalk(tmp) ;
	ret = p_finfo(sunname, &fstat) ;
	if (ret == 0)
		feedback ("YES") ;
	else
		feedback ("NO") ;
}

 void buildnme(void)
{
#ifdef CALLDEBUG
	calldbg("buildnme") ;
#endif
	if (sundir[0] == 0)
		p_scpym(sunname, sunpart, (TEXT *) "\\", sunfile, NULL) ;
	else
		p_scpym(sunname, sunpart, (TEXT *) "\\", sundir, (TEXT *) "\\", sunfile, NULL) ;
#ifdef PATHDEBUG
	pathdbg("buildnme", sunname) ;
#endif
	

}

 void suned(void)
{
	INT ret ;
	P_INFO fstat ;
#ifdef CALLDEBUG
	calldbg("suned") ;
#endif
	builddir() ;
	p_scpym(tmp, "Suned ", sunname, NULL) ;
	suntalk(tmp) ;
	ret = p_finfo(sunname, &fstat) ;
	if (ret == 0)
		feedback("YES") ;
	else
		feedback("NO") ;
}

 void builddir(void) 
{
#ifdef CALLDEBUG
	calldbg("buildir") ;
#endif
	if (sundir[0] == 0)
		p_scpym(sunname, sunpart, (TEXT *) "\\", NULL) ;
	else
		p_scpym(sunname, sunpart, (TEXT *) "\\", sundir,(TEXT *)  "\\", NULL) ;
#ifdef PATHDEBUG
	pathdbg("builddir", sunname) ;
#endif
}

E 7
 void sunep(void)
{
	P_INFO fstat ;
	INT ret ;
#ifdef CALLDEBUG
	calldbg("sunep") ;
#endif
D 7
	buildprt() ;
E 7
	p_scpym(tmp, (TEXT * ) "Sunep ", sunname, NULL) ;
	suntalk(tmp) ;
	ret = p_finfo(sunname, &fstat) ;
	if (ret == 0)
		feedback ("YES") ;
	else
	{
		feedback ("NO") ;
	}
	
}

D 7
 void buildprt(void)
{
#ifdef CALLDEBUG
	calldbg("buildprt") ;
#endif
	p_scpym(sunname, sunpart, (TEXT * ) "\\", NULL) ;
#ifdef PATHDEBUG
	pathdbg("buildprt", sunname) ;
#endif
}
E 7
D 16

E 16
D 7
 void sunlf(void)
{
I 5
	INT tmpd ;
	P_INFO fstat ;
E 5
#ifdef CALLDEBUG
	calldbg("sunlf") ;
#endif
	buildnme() ;
	p_scpym(tmp, "Sunlf ", sunname, NULL) ;
	suntalk(tmp) ;
D 5
	speclist() ;
E 5
I 5
	feedback("STARTLIST") ;
	if (p_open(&tmpd, sunname, P_FDIR) != 0)
	{
		feedback("BADPATH") ;
		return ;
	}
	/* we have used the path here so we can be a little more visious and overwrite it */
	builddir() ;
	while(p_iow(tmpd, P_FREAD, tmp, &fstat) != E_FILE_EOF)
	{
		/* we use ptmp here as we are alread using tmp and I dont like
		the idea of hacking the strings around as I'm not a good enough
		C programer to decide what will be overwritten when ! */
		p_scpym(ptmp, sunname, tmp, NULL) ;
		putline(ptmp,1) ;
	}
	p_close(tmpd) ;
	feedback("ENDLIST") ;
E 5
}

E 7
 void sunlp(void)
{
I 5
	INT tmpd ;
	P_INFO fstat ;
I 7
	P_FPARSE pstruct ;
	TEXT ltmp[300];
E 7
E 5
#ifdef CALLDEBUG
	calldbg("sunlp") ;
#endif
D 7
	buildprt() ;
E 7
	p_scpym(tmp, "Sunlp ", sunname, NULL) ;
	suntalk(tmp) ;
D 5
	speclist() ;
E 5
I 5
	feedback("STARTLIST") ;
	if (p_open(&tmpd, sunname, P_FDIR) != 0)
	{
		feedback("BADPATH") ;
		return ;
	}
I 7
	/* as we are now dealing with the full pathname we need to break it
	down to its parts and to then build it up to get the real pathname */
	/* allow wild cards */
	pstruct.flags = P_PWILD_ANY ;
	p_fparse(sunname, "", tmp, &pstruct) ;
	/* now build up the initial details from the structure , just use the device , directory
	though to save on bandwidth */
	/* set the appropriate nulls */
	tmp[pstruct.system+pstruct.device+pstruct.path] = '\0';
	p_scpy(ltmp, tmp+pstruct.system) ;
E 7
	while(p_iow(tmpd, P_FREAD, tmp, &fstat) != E_FILE_EOF)
	{
		/* we use ptmp here as we are alread using tmp and I dont like
		the idea of hacking the strings around as I'm not a good enough
		C programer to decide what will be overwritten when ! */
D 7
		p_scpym(ptmp, sunname, tmp, NULL) ;
E 7
I 7
		p_scpym(ptmp, ltmp, tmp, NULL) ;
E 7
		putline(ptmp,1) ;
	}
	p_close(tmpd) ;
	feedback("ENDLIST") ;
E 5
}

D 7
 void sunld(void)
E 7
I 7
 void sunrp(void)
E 7
{
I 5
D 7
	INT tmpd ;
	P_INFO fstat ;
E 7
E 5
#ifdef CALLDEBUG
D 7
	calldbg("sunld") ;
#endif
	builddir() ;
	p_scpym(tmp, "Sunld ", sunname, NULL) ;
	suntalk(tmp) ;
D 5
	speclist() ;
}

 void speclist(void)
{
	INT tmpd ;
	P_INFO fstat ;
#ifdef CALLDEBUG
	calldbg("speclist") ;
#endif
E 5
	feedback("STARTLIST") ;
	if (p_open(&tmpd, sunname, P_FDIR) != 0)
	{
		feedback("BADPATH") ;
		return ;
	}
I 5
	/* we have used the path here so we can be a little more visious and overwrite it */
	builddir() ;
E 5
	while(p_iow(tmpd, P_FREAD, tmp, &fstat) != E_FILE_EOF)
D 5
		putline(tmp,1) ;
E 5
I 5
	{
		/* we use ptmp here as we are alread using tmp and I dont like
		the idea of hacking the strings around as I'm not a good enough
		C programer to decide what will be overwritten when ! */
		p_scpym(ptmp, sunname, tmp, NULL) ;
		putline(ptmp,1) ;
	}
E 5
	p_close(tmpd) ;
	feedback("ENDLIST") ;
E 7
I 7
        calldbg("sunrp") ;
#endif 
        p_scpym(tmp, "Sunrp ", sunname, NULL) ;
        suntalk(tmp) ;
        if (p_delete((TEXT * ) sunname) != 0)
        {
                feedback("BADRF") ;
        }
        else
        {
                feedback("OK") ;
        }
E 7
}
I 7
D 12
 
E 12
I 12
 void sunsz(void)
{
D 13
	P_INFO fileinfo
E 13
I 13
	P_INFO fileinfo ;
I 15
	TEXT tmp[100] ;
E 15
E 13
#ifdef CALLDEBUG
	calldbg("sunsz") ;
#endif
	p_scpym(tmp, "Sunsz ", sunname, NULL) ;
	suntalk(tmp) ;
	if (p_finfo(sunname,&fileinfo) != 0)
	{
		feedback("BADPATH") ;
		return ;
	}
	tmp[p_ltob(tmp,fileinfo.size)] = 0 ;
D 13
	feedback(tmp)
E 13
I 13
	feedback(tmp) ;
I 16
}
 void sunti(void)
{
	P_INFO fileinfo ;
	TEXT tmp[100] ;
#ifdef CALLDEBUG
	calldbg("sunti") ;
#endif
	p_scpym(tmp, "Sunti ", sunname, NULL) ;
	suntalk(tmp) ;
	if (p_finfo(sunname,&fileinfo) != 0)
	{
		feedback("BADPATH") ;
		return ;
	}
	/* this is the mod time in seconds, we can just transfer this
	   as unix uses time in seconds from midnight on  1/1/1970 */
	tmp[p_ltob(tmp,fileinfo.modst)] = 0 ;
	feedback(tmp) ;
}
 void sunwy(void)
{
	P_INFO fileinfo ;
#ifdef CALLDEBUG
	calldbg("sunwy") ;
#endif
	p_scpym(tmp, (TEXT * ) "Sunwy ", sunname, NULL) ;
	suntalk(tmp) ;
	/* does the file exist */
	if (p_finfo(sunname,&fileinfo) != 0)
	{
		feedback("BADPATH") ;
		return ;
	}
	/* set the appropriate bit */
	if (p_sfstat(sunname, P_FAWRITE, P_FAWRITE) == 0)
	{
		feedback ("OK") ;
		return ;
	}
	else
	{
		feedback ("BADSET") ;
		return ;
	}
}
 void sunwn(void)
{
	P_INFO fileinfo ;
#ifdef CALLDEBUG
	calldbg("sunwn") ;
#endif
	p_scpym(tmp, (TEXT * ) "Sunwn ", sunname, NULL) ;
	suntalk(tmp) ;
	/* does the file exist */
	if (p_finfo(sunname,&fileinfo) != 0)
	{
		feedback("BADPATH") ;
		return ;
	}
	/* set the appropriate bit */
	if (p_sfstat(sunname, 0, P_FAWRITE) == 0)
	{
		feedback ("OK") ;
		return ;
	}
	else
	{
		feedback ("BADSET") ;
		return ;
	}
E 16
E 13
}

 void sunrw(void)
{
D 13
	P_INFO fileinfo
E 13
I 13
	P_INFO fileinfo ;
I 15
	TEXT tmp[100] ;

E 15
E 13
#ifdef CALLDEBUG
	calldbg("sunrw") ;
#endif
	p_scpym(tmp, "Sunrw ", sunname, NULL) ;
	suntalk(tmp) ;
	if (p_finfo(sunname,&fileinfo) != 0)
	{
		feedback("BADPATH") ;
		return ;
	}
	if (fileinfo.status & P_FAWRITE)
	{
		feedback("RW") ;
	}
	else
	{
		feedback("RO") ;
	}
}

 void sunft(void)
{
D 13
	P_INFO fileinfo
E 13
I 13
	P_INFO fileinfo ;
I 15
	TEXT tmp[100] ;
E 15
E 13
#ifdef CALLDEBUG
	calldbg("sunft") ;
#endif
	p_scpym(tmp, "Sunft ", sunname, NULL) ;
	suntalk(tmp) ;
	if (p_finfo(sunname,&fileinfo) != 0)
	{
		feedback("BADPATH") ;
		return ;
	}
I 14
	tmp[0] = 0 ;
	
E 14
	if (fileinfo.status & P_FADIR)
	{
D 14
		feedback("DIR") ;
E 14
I 14
		p_scat(tmp, "DIR ") ;
E 14
	}
	else if (fileinfo.status & P_FATEXT)
	{
D 14
		feedback("TEXT") ;
E 14
I 14
		p_scat(tmp,"TEXT ") ;
E 14
	}
	else if (fileinfo.status & P_FAHIDDEN)
	{
D 14
		feedback("HIDDEN") ;
E 14
I 14
		p_scat(tmp,"HIDDEN ") ;
E 14
	}
	else if (fileinfo.status & P_FASYSTEM)
	{
D 14
		feedback("SYSTEM") ;
E 14
I 14
		p_scat(tmp,"SYSTEM ") ;
E 14
	}
	else if (fileinfo.status & P_FAVOLUME)
	{
D 14
		feedback("VOLUME") ;
E 14
I 14
		p_scat(tmp,"VOLUME ") ;
E 14
	}
I 14
	feedback(tmp) ;
E 14
}

E 12
E 7
I 5

E 5
D 7

 void sunrf(void)
{
#ifdef CALLDEBUG
	calldbg("sunrf") ;
#endif
	buildnme() ;
	p_scpym(tmp, "Sunrf ", sunname, NULL) ;
	suntalk(tmp) ;
	if (p_delete((TEXT * ) sunname) != 0)
	{
		feedback("BADRF") ;
	}
	else
	{
		feedback("OK") ;
	}
}

 void sunrd(void)
{
#ifdef CALLDEBUG
	calldbg("sunrd") ;
#endif
	builddir() ;
	/* remove the trailing \ from the name */
	sunname[p_slen(sunname) - 1] = 0 ;
	p_scpym(tmp, "Sunrd ", sunname, NULL) ;
	suntalk (tmp) ;
	if (p_delete(sunname) != 0)
	{
		feedback("BADRD") ;
	}
	else
	{
		feedback("OK") ;
	}
}

E 7
 void sundc(void)
{
#ifdef CALLDEBUG
	calldbg("sundc") ;
#endif
	suntalk("Sundc") ;
	feedback("DISCONNECTED") ;
}

 void sunmd(void)
{
#ifdef CALLDEBUG
	calldbg("sunmd") ;
#endif
D 7
	builddir() ;
E 7
	p_scpym(tmp, "Sunmd ", sunname, NULL) ;
	suntalk(tmp) ;
	if (p_mkdir(sunname) != 0)
	{
		feedback("BADMKDIR") ;
	}
	else
	{
		feedback("OK") ;
	}
}

 void sungf (void)
{

#ifdef CALLDEBUG
	calldbg("sungf") ;
#endif
	if (tmode == 1)
	{
D 10
		sungfa() ;
E 10
I 10
		sungfb() ;
E 10
	}
	else
	{
		sungfb() ;
	}
D 10
}

 void sungfa(void)
{
	INT ret ;
#ifdef CALLDEBUG
	calldbg("sungfa") ;
#endif

D 7
	buildnme() ;
E 7
	p_scpym(tmp, "Sungfa ", sunname, NULL) ;
	suntalk(tmp) ;
	feedback("STARTGET") ;
	ret = p_open(&fileh, sunname, P_FSTREAM | P_FUPDATE | P_FREPLACE) ;
	if ( ret != 0 )
	{
		feedback("BADOPEN") ;
		return ;
	}
	else
	{
		feedback("GOODOPEN") ;
	}
	while (ret == 0)
	{
		ioget() ;
		if (p_scmp("XE", dectxt) == 0)
			break ;
		ret = p_write(fileh, dectxt, p_slen(dectxt) ) ;
	}
	if (ret != 0)
	{
		feedback("BADGET") ;
		ret = p_close(fileh) ;
		return ;
	}
	ret = p_close(fileh) ;
	if ( ret != 0)
	{
		feedback("BADGET") ;
		return ;
	}
	feedback("ENDGET") ;
E 10
}

 void sungfb(void)
{
	INT ret, tctr, dctr, max;
#ifdef CALLDEBUG
	calldbg("sungfb") ;
#endif
D 7
	buildnme() ;
E 7
	p_scpym(tmp, "Sunfgb ", sunname, NULL) ;
	suntalk(tmp) ;
	feedback("STARTGET") ;
	ret = p_open(&fileh, sunname, P_FSTREAM | P_FUPDATE | P_FCREATE) ; ;
	if ( ret != 0 )
	{
		feedback("BADOPEN") ;
D 3
		p_printf("p_open returns %d\n", ret) ;
E 3
I 3
		p_print("p_open returns %d\n", ret) ;
E 3
		return ;
	}
	else
	{
		feedback("GOODOPEN") ;
	}
	/* loop, getting the line , decoding it and writting it */
	while (ret == 0)
	{
		ioget() ;
		if (p_scmp("XE", dectxt) == 0)
			break ;
		dctr = 0 ;
		tctr = 0 ;
		max = p_slen(dectxt) ;
		/* decode the line */
		while (dctr < max)
		{
			tmp[tctr] = (((dectxt[dctr] - 'A') * 16) + (dectxt[dctr + 1] - 'A')) ;
			tctr ++ ;
			dctr += 2 ;
		}
		/* we have now assembled the output line, lets write it */
		ret = p_write(fileh, tmp, tctr) ;
	}
	if (ret != 0)
	{
		feedback("BADGET") ;
		ret = p_close(fileh) ;
		return ;
	}
	ret = p_close(fileh) ;
	if (ret != 0)
	{
		feedback("BADGET") ;
		return ;
	}
	
	feedback("ENDGET") ;
}
I 20

 void suncs(void)
{
D 21
	TEXT sum ;
	TEXT htxt [3] ;
E 21
I 21
D 23
	ULONG sum ;
E 23
I 23
	UWORD sum ;
E 23
	TEXT htxt [20] ;
E 21
D 23
	INT ret, dctr ;
E 23
I 23
	INT ret ;
E 23
#ifdef CALLDEBUG
	calldbg("suncs") ;
#endif
	p_scpym(tmp, "Suncs ", sunname, NULL) ;
	suntalk(tmp) ;
	feedback("STARTSUM") ;
	ret = p_open(&fileh, sunname, P_FOPEN | P_FSTREAM | P_FSHARE) ;
	if ( ret < 0 )
	{
		feedback("BADOPEN") ;
		return ;
	}
	else
	{
		feedback("GOODOPEN") ;
	}
I 22
	sum = 0 ;
E 22
	ret = 0 ;
	while ( ret >= 0)
	{
		ret = p_read(fileh, dectxt, MAXRD) ;
		if (ret <= 0)
		{
			break ;
		}
D 23
		dctr = 0 ;
		while (dctr < ret )
D 21
			sum += dectxt[dctr++] ;
E 21
I 21
			sum += (ULONG) dectxt[dctr++] ;
E 23
I 23
		else
		{
			p_crc(&sum, dectxt, ret) ;
		}
E 23
E 21
	}
D 23
	htxt[0] = hexarr[(sum & 0x00F0) >> 4] ;
	htxt[1] = hexarr[sum & 0x000F] ;
	htxt[2] = 0 ;
E 23
	if ((ret != E_FILE_EOF) && ( ret != 0))
	{
		feedback("BADSUM") ;
		p_close(fileh) ;
	}
I 21
D 23
	htxt[p_ltob(htxt,sum)] = 0 ;
E 23
I 23
	htxt[p_ltob(htxt,(ULONG) sum)] = 0 ;
E 23
E 21
	feedback(htxt) ;
	feedback("ENDSUM") ;
	p_close(fileh) ;
}

E 20

 void sunpf(void)
{
	INT ret, hctr, dctr ;
#ifdef CALLDEBUG
	calldbg("sunpf") ;
#endif
D 7
	buildnme() ;
E 7
	p_scpym(tmp, "Sunpf ", sunname, NULL) ;
	suntalk(tmp) ;
	feedback("STARTPUT") ;
	ret = p_open(&fileh, sunname, P_FOPEN | P_FSTREAM | P_FSHARE) ;
	if ( ret < 0 )
	{
		feedback("BADOPEN") ;
		return ;
	}
	else
	{
		feedback("GOODOPEN") ;
	}
	ret = 0 ;
	while ( ret >= 0)
	{
		ret = p_read(fileh, dectxt, MAXRD) ;
		if (ret <= 0)
		{
			break ;
		}
		hctr = dctr = 0 ;
		/* process the string to convert to HEX from ASCII */
		while (dctr < ret)
		{
			/* convert the ascii to hex */
D 17
				/* if the value of the string is less than 16 first put
				a zero into the line and inc tctr by 1 */
			if (dectxt[dctr] < 16)
			{
				hextxt[hctr] = '0' ;
				hctr ++ ;
				p_gtob((hextxt + hctr), (UINT) dectxt[dctr], 16) ;
				hctr ++ ;
				dctr ++ ;
			}
			else
			{
				p_gtob((hextxt + hctr), (UINT) dectxt[dctr], 16) ;
				/* increment the variables */
				hctr += 2 ;
				dctr ++ ;
			}
E 17
I 17
D 19
			/* use a bit mask and index arrat, p_gtob doesn't seem
E 19
I 19
			/* use a bit mask and index array, p_gtob doesn't seem
E 19
			   to be able to handle it properley */
D 19
			hextxt[hctr++] = hexarr[(dectxt[dctr] * 0x00F0) >> 4] ;
E 19
I 19
			hextxt[hctr++] = hexarr[(dectxt[dctr] & 0x00F0) >> 4] ;
E 19
D 18
			hextxt[hctr++] = hexarr[dextxt[dctr++] & 0x000F] ;
E 18
I 18
			hextxt[hctr++] = hexarr[dectxt[dctr++] & 0x000F] ;
E 18
E 17
		}
		/* terminate the string */
		hextxt[hctr] = '\0' ;
		putline(hextxt, 1) ;
		
	}
	feedback("E") ;
	if ((ret != E_FILE_EOF) && ( ret != 0))
	{
		feedback("BADPUT") ;
		p_close(fileh) ;
	}
	feedback("ENDPUT") ;
I 9
	p_close(fileh) ;
E 9
}

 void sunsl(void)
{
#ifdef CALLDEBUG
	calldbg("sunsl") ;
#endif
	suntalk("Sunsl") ;
	sndline = 0 ;
	feedback("OK") ;
	wsnd() ;
}

 void sunrl(void)
{
#ifdef CALLDEBUG
	calldbg("sunrl") ;
#endif
	suntalk("Sunrl") ;
	lineid = 0 ;
	feedback("OK") ;
	wline() ;
}

 void initscr(void)
{
I 2
	
E 2
#ifdef CALLDEBUG
	calldbg("initscr") ;
#endif
D 2
	p_printf("Screen initialisation \n") ;
E 2
I 2
D 3
	/* start up the window system and create the root window */
	wStartup() ;
	/* build the data structures */
E 3
	/* paths window */
	wdpath.extent.tl.x = 0 ;
D 7
	wdpath.extent.tl.y = 0 ;
	wdpath.extent.width = 115 ;
	wdpath.extent.height = 35 ;
E 7
I 7
	wdpath.extent.tl.y = 60 ;
	wdpath.extent.width = 235 ;
	wdpath.extent.height = 15 ;
E 7
D 3
	wdpath.flags = 0 ;
E 3
I 3
	wdpath.flags = W_WIN_PRIORITY ;
E 3
	wdpath.mouse_icon = 0 ;
	wdpath.filler = 0;
	wdpath.background = W_WIN_BACK_BITMAP ;
	/* the toggles window */
	wdtog.extent.tl.x = 120 ;
	wdtog.extent.tl.y = 0 ;
	wdtog.extent.width = 115 ;
	wdtog.extent.height = 35 ;
D 3
	wdtog.flags = 0 ;
E 3
I 3
	wdtog.flags = W_WIN_PRIORITY ;
E 3
	wdtog.mouse_icon = 0 ;
	wdtog.filler = 0;
	wdtog.background = W_WIN_BACK_BITMAP ;
	/* the message window */
	wdtalk.extent.tl.x = 0 ;
	wdtalk.extent.tl.y = 40 ;
	wdtalk.extent.width = 235 ;
	wdtalk.extent.height = 15 ;
D 3
	wdtalk.flags = 0 ;
E 3
I 3
	wdtalk.flags = W_WIN_PRIORITY ;
E 3
	wdtalk.mouse_icon = 0 ;
	wdtalk.filler = 0;
	wdtalk.background = W_WIN_BACK_BITMAP ;
	/* the recieved line window */
	wdline.extent.tl.x = 0 ;
D 7
	wdline.extent.tl.y = 60 ;
E 7
I 7
	wdline.extent.tl.y = 0 ;
E 7
	wdline.extent.width = 115 ;
	wdline.extent.height = 15 ;
D 3
	wdline.flags = 0 ;
E 3
I 3
	wdline.flags = W_WIN_PRIORITY ;
E 3
	wdline.mouse_icon = 0 ;
	wdline.filler = 0;
	wdline.background = W_WIN_BACK_BITMAP ;
	/* the sent line window */
D 3
	wdsnd.extent.tl.x = 0 ;
E 3
I 3
D 7
	wdsnd.extent.tl.x = 120 ;
E 3
	wdsnd.extent.tl.y = 60 ;
E 7
I 7
	wdsnd.extent.tl.x = 0 ;
	wdsnd.extent.tl.y = 20 ;
E 7
	wdsnd.extent.width = 115 ;
	wdsnd.extent.height = 15 ;
D 3
	wdsnd.flags = 0 ;
E 3
I 3
	wdsnd.flags = W_WIN_PRIORITY ;
E 3
	wdsnd.mouse_icon = 0 ;
	wdsnd.filler = 0;
	wdsnd.background = W_WIN_BACK_BITMAP ;
	/* setup the gc data structs (all the same realy ) */
	gdline.gmode = G_TRMODE_SET ;
	gdline.textmode = G_TRMODE_REPL ;
D 3
	gdling.style = G_STY_NORMAL ;
E 3
I 3
	gdline.style = G_STY_NORMAL ;
E 3
	gdline.filler = 0 ;
	gdline.font = WS_FONT_BASE ;
	gdsnd.gmode = G_TRMODE_SET ;
	gdsnd.textmode = G_TRMODE_REPL ;
	gdsnd.style = G_STY_NORMAL ;
	gdsnd.filler = 0 ;
	gdsnd.font = WS_FONT_BASE ;
	gdtog.gmode = G_TRMODE_SET ;
	gdtog.textmode = G_TRMODE_REPL ;
	gdtog.style = G_STY_NORMAL ;
	gdtog.filler = 0 ;
	gdtog.font = WS_FONT_BASE ;
	gdpath.gmode = G_TRMODE_SET ;
	gdpath.textmode = G_TRMODE_REPL ;
	gdpath.style = G_STY_NORMAL ;
	gdpath.filler = 0 ;
	gdpath.font = WS_FONT_BASE ;
	gdtalk.gmode = G_TRMODE_SET ;
	gdtalk.textmode = G_TRMODE_REPL ;
	gdtalk.style = G_STY_NORMAL ;
	gdtalk.filler = 0 ;
	gdtalk.font = WS_FONT_BASE ;
D 3
	/* force the root window to be visible */
	wMakeVisible(0) ;
E 3
	/* actualy create the sub windows */
	/* the path data window */
D 3
	winpath= wCreateWindow(0, W_WIN_EXTENT, &wdpath, 1) ;
E 3
I 3
	winpath= wCreateWindow(0, W_WIN_EXTENT | W_WIN_BACKGROUND , &wdpath, 1) ;
	wInitialiseWindowTree(winpath) ;
E 3
	gcpath= gCreateGC(winpath, G_GC_MASK_GMODE | G_GC_MASK_TEXTMODE | G_GC_MASK_STYLE, &gdpath) ;
I 3
	wMakeVisible(winpath) ;
E 3
	gSetGC0(gcpath) ;
	gBorder(W_BORD_CUSHION|W_BORD_SHADOW_S|W_BORD_SHADOW_ON) ;
D 7
	wpart() ;
	wdir() ;
	wfile() ;
E 7
I 7
	wpath() ;
E 7
D 3
	wMakeVisible(winpath) ;
E 3
	/* the  togles window */
D 3
	wintog= wCreateWindow(0, W_WIN_EXTENT, &wdtog, 2) ;
E 3
I 3
	wintog= wCreateWindow(0, W_WIN_EXTENT | W_WIN_BACKGROUND , &wdtog, 2) ;
	wInitialiseWindowTree(wintog) ;
E 3
	gctog= gCreateGC(wintog, G_GC_MASK_GMODE | G_GC_MASK_TEXTMODE | G_GC_MASK_STYLE, &gdtog) ;
I 3
	wMakeVisible(wintog) ;
E 3
	gSetGC0(gctog) ;
	gBorder(W_BORD_CUSHION|W_BORD_SHADOW_S|W_BORD_SHADOW_ON) ;
	wvb() ;
	wtm() ;
	wsc() ;
D 3
	wMakeVisible(wintog) ;
E 3
	/* the message window */
D 3
	wintalk= wCreateWindow(0, W_WIN_EXTENT, &wdtalk, 3) ;
E 3
I 3
	wintalk= wCreateWindow(0, W_WIN_EXTENT | W_WIN_BACKGROUND , &wdtalk, 3) ;
	wInitialiseWindowTree(wintalk) ;
E 3
	gctalk= gCreateGC(wintalk, G_GC_MASK_GMODE | G_GC_MASK_TEXTMODE | G_GC_MASK_STYLE, &gdtalk) ;
I 3
	wMakeVisible(wintalk) ;
E 3
	gSetGC0(gctalk) ;
	gBorder(W_BORD_CUSHION|W_BORD_SHADOW_S|W_BORD_SHADOW_ON) ;
	wtalk("") ;
D 3
	wMakeVisible(wintalk) ;
E 3
	/* the recieved line count */
D 3
	winline= wCreateWindow(0, W_WIN_EXTENT, &wdline, 4) ;
E 3
I 3
	winline= wCreateWindow(0, W_WIN_EXTENT | W_WIN_BACKGROUND , &wdline, 4) ;
	wInitialiseWindowTree(winline) ;
E 3
	gcline= gCreateGC(winline, G_GC_MASK_GMODE | G_GC_MASK_TEXTMODE | G_GC_MASK_STYLE, &gdline) ;
I 3
	wMakeVisible(winline) ;
E 3
	gSetGC0(gcline) ;
	gBorder(W_BORD_CUSHION|W_BORD_SHADOW_S|W_BORD_SHADOW_ON) ;
	wsline() ;
	wline() ;
D 3
	wMakevisible(winline) ;
E 3
	/* the sent line count */
D 3
	winsnd= wCreateWindow(0, W_WIN_EXTENT, &wdsnd, 5) ;
E 3
I 3
	winsnd= wCreateWindow(0, W_WIN_EXTENT | W_WIN_BACKGROUND , &wdsnd, 5) ;
	wInitialiseWindowTree(winsnd) ;
E 3
	gcsnd= gCreateGC(winsnd, G_GC_MASK_GMODE | G_GC_MASK_TEXTMODE | G_GC_MASK_STYLE, &gdsnd) ;
I 3
	wMakeVisible(winsnd) ;
E 3
	gSetGC0(gcsnd) ;
	gBorder(W_BORD_CUSHION|W_BORD_SHADOW_S|W_BORD_SHADOW_ON) ;
	wssnd() ;
	wsnd() ;
D 3
	wMakeVisible(winsnd) ;
E 3
	/* ensure that any screen message is nolonger displayed */
	wCancelBusyMsg() ;
E 2
}

 void sunol(void)
{
#ifdef CALLDEBUG
	calldbg("sunol") ;
#endif
	feedback("ONLINE") ;
}

 void shutdown(void)
{
#ifdef CALLDEBUG
	calldbg("shutdown") ;
#endif
	p_close(devh) ;
I 2
	/* I think that we should destroy the graphics contexts and windows  */
	wFree(gcline) ;
	wFree(gcsnd) ;
	wFree(gcpath) ;
	wFree(gctog) ;
	wFree(gctalk) ;
	wDisconnect() ;
E 2
}

D 7
 void wpart(void)
E 7
I 7
 void wpath(void)
E 7
{
#ifdef CALLDEBUG
	calldbg("wpart") ;
#endif
	if (scr != 1)
		return ;
D 2
	p_printf("wpart %s\n", sunpart) ;
E 2
I 2
	gSetGC0(gcpath) ;
D 3
	p_scpym(wtmp, "Part : ", sunpart, NULL) ;
	gPrintText(5, 10, wtmp, p_slen(wtmp)) ;
E 3
I 3
D 7
	p_scpym(wtmp, "Part : ", sunpart, spacestr, NULL) ;
E 7
I 7
	p_scpym(wtmp, "Path : ", sunname, spacestr, NULL) ;
E 7
D 8
	gPrintClipText(5, 10, wtmp, p_slen(wtmp), HALFWIDTH) ;
E 8
I 8
	gPrintClipText(5, 10, wtmp, p_slen(wtmp), FULLWIDTH) ;
E 8
E 3
E 2
D 7
}

 void wdir(void)
{
#ifdef CALLDEBUG
	calldbg("wdir") ;
#endif
	if (scr != 1)
		return ;
D 2
	p_printf("wdir %s\n", sundir) ;
E 2
I 2
	gSetGC0(gcpath) ;
D 3
	p_scpym(wtmp, "Dir : ", sundir, NULL) ;
	gPrintText(5,20,wtmp,p_slen(wtmp)) ;
E 3
I 3
	p_scpym(wtmp, "Dir : ", sundir, spacestr,  NULL) ;
	gPrintClipText(5,20,wtmp,p_slen(wtmp), HALFWIDTH) ;
E 3
E 2
}

 void wfile(void)
{
#ifdef CALLDEBUG
	calldbg("wfile") ;
#endif
	if (scr != 1)
		return ;
D 2
	p_printf("wfile %s\n", sunfile) ;
E 2
I 2
	gSetGC0(gcpath) ;
D 3
	p_scpym(wtmp, "File : ", sunfile, NULL) ;
	gPrintText(5,30,wtmp,p_slen(wtmp)) ;
E 3
I 3
	p_scpym(wtmp, "File : ", sunfile, spacestr,  NULL) ;
	gPrintClipText(5,30,wtmp,p_slen(wtmp), HALFWIDTH) ;
E 7
E 3
E 2
}

 void wvb(void)
{
#ifdef CALLDEBUG
	calldbg("wvb") ;
#endif
	if (scr != 1)
		return ;
D 2
	p_printf("wvb %d\n", vrb) ;
E 2
I 2
	gSetGC0(gctog) ;
	if (vrb)
D 3
		p_scpy(wtmp, "Verbose : YES") ;
E 3
I 3
		p_scpym(wtmp, "Verbose : YES", spacestr, NULL) ;
E 3
	else
D 3
		p_scpy(wtmp, "Verbose : NO  ") ;
	gPrintText(5 ,10, wtmp, p_slen(wtmp)) ;
E 3
I 3
		p_scpym(wtmp, "Verbose : NO  ", spacestr, NULL) ;
	gPrintClipText(5 ,10, wtmp, p_slen(wtmp),HALFWIDTH) ;
E 3
E 2
}

 void wtm(void)
{
#ifdef CALLDEBUG
	calldbg("wtm") ;
#endif
	if (scr != 1)
		return ;
	if (tmode == 1)
D 2
		p_printf("wtm ASCII\n") ;
E 2
I 2
D 3
		p_scpy(wtmp, "Transfer : ASCII  ") ;
E 3
I 3
		p_scpym(wtmp, "Transfer : ASCII", spacestr, NULL) ;
E 3
E 2
	else
D 2
		p_printf("wtm BINARY\n") ;
E 2
I 2
D 3
		p_scpy(wtmp, "Transfer : BINARY ") ;
E 3
I 3
		p_scpym(wtmp, "Transfer : BINARY ", spacestr, NULL) ;
E 3
	gSetGC0(gctog) ;
D 3
	gPrintText(5, 20, wtmp, p_slen(wtmp)) ;
E 3
I 3
	gPrintClipText(5, 20, wtmp, p_slen(wtmp), HALFWIDTH) ;
E 3
E 2
}

 void wsc(void)
{
#ifdef CALLDEBUG
	calldbg("wsc") ;
#endif
D 2
	if (scr != 1)
		return ;
	p_printf("Screen %d\n", scr) ;
E 2
I 2
D 3
	gSetGC0(gtog) ;
E 3
I 3
	gSetGC0(gctog) ;
E 3
	if (scr == 0)
D 3
		p_scpy(wtmp, "Screen Update NO ") ;
E 3
I 3
		p_scpym(wtmp, "Screen Update NO", spacestr, NULL) ;
E 3
	else
D 3
		p_scpy(wtmp, "Screen Update YES") ;
	gPrintText(5, 30, wtmp, p_slen(wtmp) ) ;
E 3
I 3
		p_scpym(wtmp, "Screen Update YES", spacestr, NULL) ;
	gPrintClipText(5, 30, wtmp, p_slen(wtmp) , HALFWIDTH) ;
E 3
E 2
}

 void wtalk( TEXT * msg)
{
#ifdef CALLDEBUG
	calldbg("wtalk") ;
#endif
	if (scr != 1)
		return ;
D 2
	p_printf("wtalk :%s:\n", msg) ;
E 2
I 2
	gSetGC0(gctalk) ;
I 6
	wtmp[0] = '\0' ;
E 6
D 3
	gPrintText(5,10,msg, p_slen(msg) ) ;
E 3
I 3
	p_scpym(wtmp, msg, spacestr, NULL) ;
D 4
	gPrintClipText(5,10,msg, p_slen(msg), FULLWIDTH ) ;
E 4
I 4
D 6
	gPrintClipText(5,10,msg, p_slen(wtmp), FULLWIDTH ) ;
E 6
I 6
	gPrintClipText(5,10,wtmp, p_slen(wtmp), FULLWIDTH ) ;
E 6
E 4
E 3
E 2
}

I 2
 void wsline(void)
{
#ifdef CALLDEBUG
	calldbg("wsline") ;
#endif
	gSetGC0(gcline) ;
D 3
	p_scpy(wtmp, "Recieved Ctr : ") ;
E 3
I 3
	p_scpy(wtmp, "Recieved Ctr :");
E 3
	gPrintText(5, 10, wtmp, p_slen(wtmp)) ;
I 3
	lineidpt = gTextWidth(WS_FONT_BASE, G_STY_NORMAL, wtmp, p_slen(wtmp)) ;
E 3
}

 void wssnd(void)
{
#ifdef CALLDEBUG
	calldbg("wssnd") ;
#endif
D 3
	gsetGC0(gcsnd) ;
	p_scpy(wtmp, "Sent Ctr : ") ;
E 3
I 3
	gSetGC0(gcsnd) ;
	p_scpy(wtmp, "Sent Ctr : ");
E 3
	gPrintText(5,10,wtmp, p_slen(wtmp)) ;
I 3
	sndlinept = gTextWidth(WS_FONT_BASE, G_STY_NORMAL, wtmp, p_slen(wtmp)) ;
E 3
}

E 2
 void wline(void)
{
I 2
	TEXT linet[10] ;
E 2
#ifdef CALLDEBUG
	calldbg("wline") ;
#endif
	if (scr != 1) 
		return ;
D 2
	p_printf("rec ctr %d\n", lineid) ;
E 2
I 2
	gSetGC0(gcline) ;
	linet[p_itob(linet, lineid)] = '\0' ;
D 3
	p_scpym(wtmp, linet, "  ", NULL) ;
	gPrintText(70, 10, wtmp, p_slen(wtmp)) ;
E 3
I 3
	p_scpym(wtmp, linet, spacestr, NULL) ;
	gPrintClipText(lineidpt, 10, wtmp, p_slen(wtmp), HALFWIDTH - lineidpt) ;
E 3
	
E 2
}

 void wsnd(void)
{
I 3
	TEXT linet[10] ;
E 3
#ifdef CALLDEBUG
	calldbg("wsnd") ;
#endif
	if (scr != 1)
		return ;
D 2
	p_printf("sent ct %d\n", sndline) ;
E 2
I 2
	gSetGC0(gcsnd) ;
	linet[p_itob(linet, sndline)] = '\0' ;
	p_scpym(wtmp, linet, "  ", NULL) ;
D 3
	gPrintText(70, 10, wtmp, p_slen(wtmp)) ;
E 3
I 3
	gPrintClipText(sndlinept, 10, wtmp, p_slen(wtmp), HALFWIDTH - sndlinept) ;
E 3
E 2
}

 void suntalk(TEXT *msg)
{
	
	if (scr != 1)
		return ;
D 2
	p_printf("Suntalk Message:%s:\n",msg) ;
E 2
I 2
	wtalk(msg) ;
E 2
}
E 1
