perm filename WHOIS.FAI[S,NET]2 blob sn#836049 filedate 1987-03-10 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00002 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	 A B C P PDLEN PDL CMDLIN SVRNAM NAMSTAN NAMNIC WISPRT NIORTS ERRHAN ERRTNS HSTTAB WHOIS SCAN1 SWITCH SWNIC0 SWNIC SWSTAN PROMPT GETCMD GETCM1 GETCM2 GETCM3 SEND1 SEND2 RECV1 HSTERR
C00007 ENDMK
C⊗;
;⊗ A B C P PDLEN PDL CMDLIN SVRNAM NAMSTAN NAMNIC WISPRT NIORTS ERRHAN ERRTNS HSTTAB WHOIS SCAN1 SWITCH SWNIC0 SWNIC SWSTAN PROMPT GETCMD GETCM1 GETCM2 GETCM3 SEND1 SEND2 RECV1 HSTERR

Comment ⊗ History:

01 Mar 87  JJW	Initial implementation.
10 Mar 87  ME	Added NICNAME command, like /NIC.

⊗;end of history (please add changes)

A←1
B←2
C←3
P←17
PDLEN←20

PDL:	BLOCK PDLEN
CMDLIN:	BLOCK 20
SVRNAM:	BLOCK 1			;Pointer to server name

NAMSTAN:ASCIZ/Argus.Stanford.EDU/
NAMNIC:	ASCIZ/SRI-NIC.ARPA/

WISPRT←←=43			;TCP port number for WHOIS

NIORTS←←-1			;include I/O routines
ERRHAN←←-1			;include automagic error handling
ERRTNS←←-1			;include error routines
HSTTAB←←-1			;include host table routines

.INSERT NETWRK.FAI[S,NET]

WHOIS:	RESET
	MOVE P,[IOWD PDLEN,PDL]
	MOVEI A,0
	JBTSTS A,
	TLNN A,10000		;JLOG
	OUTSTR [BYTE (7)15,12]
	MOVEI A,NAMSTAN		;Default server name
	MOVEM A,SVRNAM
	MOVEI A,WISPRT		;Set up port for CONECT
	MOVEM A,CONFPR
	MOVE B,[POINT 7,CMDLIN]
	MOVEI C,";"		;Delimiter to scan for (unless system command)
	RESCAN
	INCHWL A
	CAIE A,"N"		;NICNAME command
	CAIN A,"n"
	JRST SWNIC0
	CAIE A,"W"		;WHOIS command?
	CAIN A,"w"
	MOVEI C," "
	CAIE A,"T"		;or TEST command?
	CAIN A,"t"
	MOVEI C," "
SCAN1:	INCHWL A
	CAIN A,(C)
	JRST GETCMD		;Found delimiter, get command
	CAIN A,"/"
	JRST SWITCH
	CAIE A,12
	CAIN A,175
	JRST PROMPT
	JRST SCAN1

SWITCH:	MOVEI C," "		;Set delimiter following switch
	INCHWL A
	CAIE A,"N"
	CAIN A,"n"
	JRST SWNIC
	CAIE A,"S"
	CAIN A,"s"
	JRST SWSTAN
	OUTSTR [ASCIZ/Unknown switch/]
	CLRBFI
	EXIT

SWNIC0:	MOVEI C," "		;set delimiter
SWNIC:	MOVEI A,NAMNIC
	MOVEM A,SVRNAM
	JRST SCAN1

SWSTAN:	MOVEI A,NAMSTAN
	MOVEM A,SVRNAM
	JRST SCAN1

PROMPT:	OUTSTR [ASCIZ/Ident: /]
GETCMD:	INCHWL A
	CAIE A," "		;Ignore leading blanks
	CAIN A,11
	JRST GETCMD
GETCM1:	CAIN A,15
	JRST GETCM2
	CAIE A,12
	CAIN A,175
	JRST GETCM3
	IDPB A,B		;Store a command char
GETCM2:	INCHWL A
	JRST GETCM1

GETCM3:	CAMN B,[POINT 7,CMDLIN]
	JRST PROMPT		;Don't allow empty text
	MOVEI A,0
	IDPB A,B

	SKIPN HSTADR
	PUSHJ P,ATTHST		;Attach host table upper segment
	MOVE 0,SVRNAM
	PUSHJ P,HSTNAM
	 JRST HSTERR
	 JRST HSTERR
	MOVEM 0,HOST
	OUTSTR [ASCIZ/Accessing database at /]
	OUTSTR @SVRNAM
	OUTSTR [ASCIZ/ ...
/]
	PUSHJ P,CONECT
	MOVE B,[POINT 7,CMDLIN]
SEND1:	ILDB 0,B
	JUMPE 0,SEND2
	PUSHJ P,NETOCH
	JRST SEND1

SEND2:	MOVEI 0,15		;Send CRLF
	PUSHJ P,NETOCH
	MOVEI 0,12
	PUSHJ P,NETOCH
	PUSHJ P,NETSND

RECV1:	PUSHJ P,NETICW
	OUTCHR 0
	JRST RECV1

HSTERR:	OUTSTR [ASCIZ/Unknown host/]
	EXIT

	END WHOIS