perm filename FNGSER.MID[S,NET]5 blob
sn#820020 filedate 1986-06-27 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00004 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 X FCS FULTWX ECHOFF TERMID CORBEG TERSTR PDL COREND
C00004 00003 FNGSER CPYHST 1DIGTP NOTTIP
C00006 00004 GETCMD GETCM1 GETFNG GETFN2 GETFN3 GETFN1 SUICID ...LIT SVRRTS ERRTNS ERRHAN ERRINS HSTTAB HSTSIX
C00010 ENDMK
C⊗;
;X FCS FULTWX ECHOFF TERMID CORBEG TERSTR PDL COREND
TITLE FNGSER
SUBTTL Definitions
; Mark Crispin, SU-AI, September 1978
; Assembly switches
IFNDEF SVRSKT,SVRSKT==79. ; default listen socket
IFNDEF PDLLEN,PDLLEN==50 ; stack length
; AC definitions. 0→3 are used by NETWRK
X=4 ? A=5 ? B=6 ? P=17
; SAIL system bit definitions
FCS== 000020,, ; full character set mode
FULTWX==000004,, ; no echo
ECHOFF: 001400,,(FULTWX) ; echo off TTYSET command word
TERMID: 'TERMID ; for spies to see where we are
CORBEG==. ; start of initialized core storage
TERSTR: BLOCK 40 ; console location string
PDL: BLOCK PDLLEN ; stack
COREND==.-1 ; end of initialized storage
;FNGSER CPYHST 1DIGTP NOTTIP
SUBTTL Initialize the world
FNGSER: JFCL
RESET
MOVE ['FNGSER]
SETNAM
SETZM CORBEG
MOVE [CORBEG,,CORBEG+1]
BLT COREND
MOVE P,[PDL(-PDLLEN)]
MOVEI [DEBREAK ? JRST SUICID]
MOVEM JOBAPR
CLKINT 5.*60.*60. ; must die if around too long
OUTSTR [ASCIZ/FNGSER started
/]
; Listen for a connection on our socket
MOVEI SVRSKT
MOVEM LSNSKT
PUSHJ P,LISTEN
; Set up terminal id for interested spies
MOVEI TERMID
MOVEM JOBVER
; Log the connection
OUTSTR [ASCIZ/Connected to /]
PUSHJ P,MAPHST ; map in host table
MOVE HOST
PUSHJ P,HSTNUM ; get HDB
JFCL ; sorry about errors
MOVEI A,(1) ; host name
HRLI A,440700
SKIPA X,[440700,,TERSTR]
CPYHST: IDPB B,X
ILDB B,A
JUMPN B,CPYHST
HLRZ A,1 ; pointer to system name
MOVE B,(A) ; get system name
MOVE A,FSOCKT ; and ICP socket
CAMN B,[ASCII/TIP/] ; on a TIP?
TRNE A,177774 ; just paranoia; make sure a TIP port
JRST NOTTIP
MOVEI B,"#
IDPB B,X
LSH A,-16.
IDIVI A,8. ; ports are octal
JUMPE A,1DIGTP
ADDI A,"0 ? IDPB A,X
1DIGTP: ADDI B,"0 ? IDPB B,X
NOTTIP: PUSHJ P,SETANM ; set our job name
PUSHJ P,UNMHST ; map out the host table
OUTSTR TERSTR
OUTSTR [ASCIZ/
/]
;GETCMD GETCM1 GETFNG GETFN2 GETFN3 GETFN1 SUICID ...LIT SVRRTS ERRTNS ERRHAN ERRINS HSTTAB HSTSIX
SUBTTL FINGER over a PTY
; Get a PTY, set it up, and log it in
PTYGET A
JRST SUICID
MOVSI (A)
IORM ECHOFF
MOVSI B,(FCS)
PTSETL A ; set initial bits
HRROI ECHOFF
TTYSET ; echo off
MOVEI B,5 ; LOGIN
PTJOBX A
JRST SUICID
; Send command down PTY's throat
MOVEI B,[ASCIZ/Finger /]
PTWRS7 A ; send prelude
GETCMD: PUSHJ P,NETICW
CAIGE 177 ; rubout or thing with parity bit?
CAIGE <" > ; or a control?
JRST GETCM1 ; better check this out
MOVE B,
PTWR1W A ; ordinary character, send it
JRST GETCMD
GETCM1: CAIE ↑M ; CR is okay though
JRST GETCMD ; ignore other controls
MOVE B,
PTWR1W A ; send that
PUSHJ P,NETICH ; eat the line feed
PTRD1W A ; and the one from the PTY too!
; Get FINGER output from PTY
GETFNG: PTRD1W A
CAIN B,"↑ ; start of ↑C saying dat's it?
JRST GETFN1
GETFN2: MOVEI (B)
;JJW 3/84 Canonicalize from WAITS to standard ASCII
GETFN3: CAIN 33 ; control-Z
JRST [MOVEI 32 ↔ JRST CANON]
CAIN 175 ; ALT
MOVEI 33 ;{
CAIN 176 ; }
MOVEI 175
CAIN 32 ; ~
MOVEI 176
CANON:
PUSHJ P,NETOCH ; send character to user
JRST GETFNG
GETFN1: PTRD1W A
CAIE B,"C ; is it really ↑C?
JRST [ MOVEI "↑ ; oops!
PUSHJ P,NETOCH
JRST GETFN2]
MOVEI B,6 ; IWAITS
PTJOBX A
JRST [ MOVEI "↑
PUSHJ P,NETOCH
MOVEI "C
JRST GETFN3]
PUSHJ P,NETSND ; yes it was, force buffer out
PUSHJ P,CLOSER
SUICID: RESET ? EXIT
...LIT: CONSTANTS
; Wonderful network routines
SVRRTS==-1 ; include server routines
ERRTNS==-1 ; include error routines
ERRHAN==-1 ; include automagic error handling
ERRINS==<JRST SUICID> ; error instruction
HSTTAB==-1 ; include host table magic
HSTSIX==-1 ; and alias name kludge
.INSRT NETWRK
END FNGSER