	.title	k11sho	do the show command in an overlay
	.ident	/2.0.01/

;	31-Jan-84  08:28:16  Brian Nelson
;
;	Remove SHOW code from K11CMD.MAC for placement into an overlay.
;	Had not realized how large Kermit was getting.



	.include	/IN:K11MAC.MAC/
	.include	/IN:K11CDF.MAC/
	.enabl	lc
	.enabl	gbl
	.psect	$code


	.sbttl	the show command


c$show::$name	<SHO>
	calls	getcm0	,<#argbuf,#sholst>
	tst	r0
	bmi	110$
	jsr	pc	,@r1
	return

110$:	message	<Unknown SHOW topic>,cr



sho$al:	message
	call	sho$bl
	call	sho$de
	call	sho$df
	call	sho$dl
	call	sho$es
	call	sho$fi
	call	sho$li
	call	sho$pa
	call	sho$pk
	call	sho$ps
	call	sho$rf
	call	sho$ti
	call	sho$ve
	message
	return



	$cmglob	=	0

	command	sholst	,ALL	,3	,sho$al
	command	sholst	,BLOCK_CHECK_TYPE,3,sho$bl
	command	sholst	,BLOCK-CHECK-TYPE,3,sho$bl
	command	sholst	,DEBUG	,3	,sho$de
	command	sholst	,DEFAULT,3	,sho$df
	command	sholst	,DELAY	,3	,sho$dl
	command	sholst	,DIRECTORY,3	,sho$df
	command	sholst	,ESCAPE	,3	,sho$es
	command	sholst	,FILETYPE,3	,sho$fi
	command	sholst	,LINE	,3	,sho$li
	command	sholst	,PACKET	,3	,sho$pk
	command	sholst	,PARAMETERS,3	,sho$pa
	command	sholst	,PAUSE	,3	,sho$ps
	command	sholst	,RECORD_FORMAT,3,sho$rf
	command	sholst	,RECORD-FORMAT,3,sho$rf
	command	sholst	,TIME	,3	,sho$ti
	command	sholst	,VERSION,3	,sho$ve



	.sbttl	routines for the show command
	.enabl	lsb

sho$de:	tst	trace			; any debugging turned on now ?
	bne	10$			; yes
	message	<No debugging or logging is active>,cr
	br	100$			; exit

10$:	message	<Debug file is >
	print	#logfil
	clr	r0			; index := 0
	message

20$:	tst	200$(r0)		; end of the list yet ?
	beq	100$			; yes, bye
	print	205$(r0)		; print the header
	bit	200$(r0),trace		; see if a bit is turned on
	beq	30$			; no
	message	<enabled>,cr		; say so then
	br	40$			; next please
30$:	message	<disabled>,cr		; if off then also say so
40$:	tst	(r0)+			; next please
	br	20$			; all done yet ?

100$:	return				; simple


200$:	.word	log$co	,log$fi	,log$pa	,log$st	,0
205$:	.word	210$	,220$	,230$	,240$
210$:	.asciz	/Remote connection logging /
220$:	.asciz	/File opens and  creations /
230$:	.asciz	/Packet logging to logfile /
240$:	.asciz	/State  logging to logfile /
	.even




sho$li:	tstb	ttdial			; show the terminal show
	bne	300$			; something is there
	message	<No remote line has been set>,cr
	return
300$:	message	<Current remote link device name is >
	print	#ttdial			; print it and exit
	message
	message	<The current speed for the link  is >
	calls	ttspee	,<#ttdial>
	sub	#20	,sp		; try to format the response a little
	mov	sp	,r1		; allocate a buffer and point to it
	deccvt	r0,r1,#4		; convert to decimal, 4 wide
	print	r1	,#4		; print it
	add	#20	,sp		; pop the buffer
	message	< baud>,cr		; and finish off the message
	return

	.dsabl	lsb




	.sbttl	show time and version
	.enabl	lsb

sho$ti:	calls	asctim	,<#errtxt,#0>
	message	<The time is >
	print	#errtxt
	message
	return

sho$df:	message	<Directory for send opens and receive creates: >
	tstb	defdir
	beq	10$
	print	#defdir
	message
	return
10$:	message	<none>,cr
	return


sho$ve::message	<Kermit-11 >
	sub	#40	,sp		; allocate a buffer
	mov	sp	,r1		; point to it
	movb	#release,(r1)+		; is this test or for real
	deccvt	#baselev,r1		; convert baseline level to ascii
	add	#6	,r1		; skip past it
	movb	#'.	,(r1)+		; a dot
	deccvt	#edit	,r1		; the edit number now
	mov	sp	,r1		; point back to the buffer
	calls	cvt$$	,<r1,#14.,#377>	; drop all the extra spaces out
	print	r1,r0			; simple
	message				; a crlf
	add	#40	,sp
	return


	.dsabl	lsb




	.sbttl	show filetype and show block-check
	.enabl	lsb


sho$fi:	cmpb	image	,#text		; text files
	bne	10$			; not text
	message	<Filetype set to ASCII>,cr
	return
10$:	cmpb	image	,#binary	; binary ?
	bne	20$			; really ?
	message	<Filetype set to BINARY>,cr
20$:	return
	


sho$bl:	movb	setrec+p.chkt,r0	; get the checksum type please
	bne	30$			; it's been set already
	movb	#defchk	,r0		; no, set the default checktype in
30$:	sub	#'1	,r0		; convert to an index for printing
	asl	r0			; times 2 for word addressing
	print	100$(r0)		; and say so
	return


100$:	.word	110$,120$,130$
110$:	.asciz	/1-Character-Checksum/<cr><lf>
120$:	.asciz	/2-Character-Checksum/<cr><lf>
130$:	.asciz	/3-Character-CRC-CCITT/<cr><lf>
	.even

	.dsabl	lsb







	.sbttl	show parameters and show escape
	.enabl	lsb

sho$es::mov	conesc	,r1
	bne	10$
	mov	#con$es	,r1
10$:	add	#100	,r1		; echo it back out
	mov	r1	,-(sp)		; allocate a buffer
	mov	sp	,r1		; point to it
	message	<Connection escape character set to ^>
	print	r1	,#1		; simple
	message
	tst	(sp)+			; pop buffer and exit
	return				; bye


sho$pa:	message	<SEND  packet  eol character  >
	movb	conpar+p.eol,r0
	octout	r0
	message	<   (octal)>,cr
	message	<SEND  maximum  packet  size  >
	movb	conpar+p.spsiz,r0
	decout	r0
	message
	message	<SEND/RECEIVE packet timeout  >
	movb	conpar+p.time,r0
	decout	r0
	message
	message	<RETRY  maximum for  packets  >
	decout	maxtry			; retry count
	message
	return

	global	<conpar	,maxtry>

	.dsabl	lsb




	.sbttl	show packet statistics
	.enabl	lsb


sho$pk:	message
	message	<Packet counts from the last transaction>,cr
	message
	message	<Packet type  Sent   Rec  Sent   Rec>,cr
	message
	message	<All types  >
	decout	pcnt.s
	decout	pcnt.r
	mov	pcnt.s	,r1
	add	totp.s	,r1
	decout	r1
	mov	pcnt.r	,r1
	add	totp.r	,r1
	decout	r1
	message
	clr	r0
	mov	#26.	,r2
10$:	tst	(r0)+			; packettypecount + 2
	tst	pcnt.r(r0)		; did we ever get this packet type ?
	bne	20$			; yes, print it then
	tst	pcnt.s(r0)		; did we ever send this kind ?
	beq	50$			; no, skip the entry then
20$:	mov	r0	,r1		; print the packet type
	asr	r1			; /2
	add	#100	,r1		; get the letter type now
	mov	r1	,-(sp)		; make it into a buffer address
	mov	sp	,r1		; and point to it please
	print	r1	,#1		; a single character now
	tst	(sp)+			; pop the buffer now
	print	#200$			; space over
	decout	pcnt.s(r0)		; dump the stats
	decout	pcnt.r(r0)		; simple
	mov	pcnt.s(r0),r1		; also dump the running totals
	add	totp.s(r0),r1		; they get added together when
	decout	r1			; CLRSTA is called to zero out
	mov	pcnt.r(r0),r1		; the current statistics.
	add	totp.r(r0),r1		; so add them up here then
	decout	r1			; simple to do
	message				; next please
50$:	dec	r2			; too far for a SOB r2,10$
	bne	10$			; next please
	message
100$:	return


200$:	.rept	12			; make sure you know this is supposed
	.byte	40			; to be a lot of spaces here.
	.endr
	.byte	0
	.even

	global	<pcnt.r	,pcnt.s	,totp.r	,totp.s>

	.dsabl	lsb





	.sbttl	more show command (delay and pause)



sho$ps:	message	<Pause time before packet transmission >
	decout	pauset
	message
	return

sho$dl:	message	<Delay time  before sending  SEND-INIT >
	decout	sendly
	message
	return


	.enabl	lsb

sho$rf:	cmpb	df$rfm	,#fb$stm	; r.var or stream ascii today ?
	bne	10$
	message	<Created files will be Stream Ascii>,cr
	return
10$:	message	<Created files will be Variable with implied CRLF>,cr
	return


	global	<df$rfm	,fb$stm	,pauset	,sendly>

	.dsabl	lsb



	.sbttl	the copy command

c$copy::$name	<COP>
	call	gettwo			; insure the 'to:' argument is here
	tst	r0			; did it work out ok ?
	bne	100$			; we really could have done this in
	mov	#argbuf	,r2		; the command macro.
	calls	copy	,<#cmdbuf,r2,#0>; do the rename now
	tst	r0			; did it work ?
	bne	40$			; yes
	decout	r1			; print the block count
	print	#210$			; and a header
	print	r2			; and the file copied to
	print	#200$			; a cr/lf
	br	100$			; bye
40$:	direrr	r0			; no, print the error message

100$:	return

200$:	.byte	cr,lf,0
210$:	.asciz	/ blocks copied /
	.even
	

	global	<argbuf	,cmdbuf	,gettwo>






	.sbttl	the rename command

c$rena::$name	<REN>
	call	gettwo			; insure a 'to:' argument is here
	tst	r0			; did it work out ok?
	bne	100$			; no
	mov	#argbuf	,r2		; point to the arguement buffer
	calls	rename	,<#cmdbuf,r2,#0>; do the rename now
	tst	r0			; did it work ?
	beq	100$			; yes
	direrr	r0			; no, print the error message

100$:	return

	global	<argbuf	,cmdbuf	,gettwo>



c$del::	$name	<DEL>
	calls	delete	,<#argbuf,#0>
	direrr	r0
	return

	global	<argbuf	,cmdbuf>




	.sbttl	the local type command
	.enabl	lsb


c$type::$name	<TYP>
	sub	#210	,sp		; allocate a text buffer
	mov	sp	,r4		; and point to it of course
	calls	fparse	,<#argbuf,r4>	; parse the filename please
	tst	r0			; did the $parse work ok ?
	bne	90$			; no
	print	r4			; yes, print the expanded name out
	message

5$:	clr	r2			; assume file not open
	calls	open	,<#argbuf,#lun.in,#text>; try to open the passed filename
	tst	r0			; but did the open work out ?
	bne	90$			; no
	com	r2			; flag it as being open please

10$:	tst	cccnt			; control C typed ?
	bne	90$			; yes, abort this
	calls	getrec	,<r4,#lun.in>	; get the next record
	tst	r0			; did it work ?
	bne	90$			; no
20$:	tst	r1			; null record (ie, cr/lf only) ?
	beq	30$			; yep
	print	r4,r1			; dump the record
30$:	message				; a cr/lf
	br	10$			; next record please

90$:	tst	r0			; forced exit ?
	beq	95$			; yes
	cmp	r0	,#ER$EOF	; end of file ?
	beq	95$			; yes, its ok
	direrr	r0			; no, print the error out
95$:	tst	r2			; is the type file open ?
	beq	100$			; no
96$:	calls	close	,<#lun.in>	; yes, please close it up now
100$:	add	#210	,sp		; pop buffer and exit
	return


	global	<argbuf	,cccnt	,defdir	,ER$EOF	,lun.in>

	.dsabl	lsb


	.end
