Google
 

Trailing-Edge - PDP-10 Archives - BB-Y393D-SM - monitor-sources/filnsp.mac
There are 18 other files named filnsp.mac in the archive. Click here to see a list.
; UPD ID= 38, FARK:<4-1-WORKING-SOURCES.MONITOR>FILNSP.MAC.2,   2-Apr-82 20:00:14 by ZIMA
;Edit 2607 - add ENDAV.s for ACVARs to use v5 MACSYM.
;<4-1-FIELD-IMAGE.MONITOR>FILNSP.MAC.2, 25-Feb-82 20:21:39, EDIT BY DONAHUE
;UPDATE COPYRIGHT DATE
; UPD ID= 185, FARK:<4-WORKING-SOURCES.MONITOR>FILNSP.MAC.2,   3-Sep-80 14:01:56 by ZIMA
;Edit 1778 - use better error code COMX19 in PRSNAM.
;<4.MONITOR>FILNSP.MAC.51,  3-Jan-80 08:08:44, EDIT BY R.ACE
;UPDATE COPYRIGHT DATE
;<4.MONITOR>FILNSP.MAC.50, 21-Jun-79 11:08:41, EDIT BY KIRSCHEN
;RETURN PROPER ERROR CODE IF HOST STRING TOO LONG ON OPEN OF DCN:
;<4.MONITOR>FILNSP.MAC.49,  4-Mar-79 17:16:24, EDIT BY KONEN
;UPDATE COPYRIGHT FOR RELEASE 4
;<4.MONITOR>FILNSP.MAC.48, 16-Feb-79 14:52:41, EDIT BY ENGEL
;ADD ATS SETTING FLOW CONTROL STUFF
;<4.MONITOR>FILNSP.MAC.47, 18-Aug-78 08:18:04, EDIT BY MILLER
;MAKE MAXHST GLOBAL
;<4.MONITOR>FILNSP.MAC.46, 17-Aug-78 14:35:28, EDIT BY KIRSCHEN
;CLEAR POINTER TO WINDOW PAGE IF NOT ASSIGNED IN ASGWDW
;<4.MONITOR>FILNSP.MAC.45,  9-Aug-78 08:42:55, Edit by KIRSCHEN
;SAVE AND RESTORE ERROR CODE IN CLENUP
;<4.MONITOR>FILNSP.MAC.44, 31-Jul-78 09:33:03, Edit by KIRSCHEN
;FIX CLEAN UP IN OPNDNC
;<4.MONITOR>FILNSP.MAC.43, 24-Jul-78 11:03:06, Edit by KIRSCHEN
;<4.MONITOR>FILNSP.MAC.42, 21-Jul-78 10:19:19, Edit by KIRSCHEN
;SET UP FILE WINDOW BEFORE IT IS NEEDED
;<4.MONITOR>FILNSP.MAC.41, 14-Jul-78 12:50:15, Edit by MCLEAN
;<4.MONITOR>FILNSP.MAC.40, 14-Jul-78 01:45:21, Edit by MCLEAN
;<4.MONITOR>FILNSP.MAC.39, 14-Jul-78 01:37:55, Edit by MCLEAN
;<4.MONITOR>FILNSP.MAC.38, 14-Jul-78 01:18:02, Edit by MCLEAN
;ADD CHECK FOR OPENED FILE IN MTOPR TCO 1770
;<4.MONITOR>FILNSP.MAC.37, 21-Mar-78 12:46:54, Edit by KIRSCHEN
;<4.MONITOR>FILNSP.MAC.36, 21-Mar-78 10:15:51, Edit by KIRSCHEN
;<4.MONITOR>FILNSP.MAC.35,  2-Mar-78 09:52:49, Edit by KIRSCHEN
;<4.MONITOR>FILNSP.MAC.34, 13-Feb-78 16:23:49, Edit by KIRSCHEN
;<4.MONITOR>FILNSP.MAC.33,  3-Feb-78 16:12:11, Edit by KIRSCHEN
;<4.MONITOR>FILNSP.MAC.32, 27-Jan-78 23:34:01, EDIT BY KIRSCHEN
;<4.MONITOR>FILNSP.MAC.31, 27-Jan-78 16:34:50, EDIT BY KIRSCHEN
;<4.MONITOR>FILNSP.MAC.30, 27-Jan-78 16:33:41, EDIT BY KIRSCHEN
;<4.MONITOR>FILNSP.MAC.29, 27-Jan-78 16:32:34, EDIT BY KIRSCHEN
;<4.MONITOR>FILNSP.MAC.28, 26-Jan-78 15:09:24, EDIT BY KIRSCHEN
;<4.MONITOR>FILNSP.MAC.27, 26-Jan-78 14:20:04, EDIT BY KIRSCHEN
;<4.MONITOR>FILNSP.MAC.26, 26-Jan-78 14:08:35, EDIT BY KIRSCHEN
;<4.MONITOR>FILNSP.MAC.24, 24-Jan-78 15:24:56, EDIT BY KIRSCHEN
;<4.MONITOR>FILNSP.MAC.23, 24-Jan-78 15:21:50, EDIT BY KIRSCHEN
;<4.MONITOR>FILNSP.MAC.22, 24-Jan-78 15:07:39, EDIT BY KIRSCHEN
;<4.MONITOR>FILNSP.MAC.21, 24-Jan-78 11:43:43, EDIT BY KIRSCHEN
;<4.MONITOR>FILNSP.MAC.20, 24-Jan-78 11:27:16, EDIT BY KIRSCHEN
;<4.MONITOR>FILNSP.MAC.19, 24-Jan-78 11:26:28, EDIT BY KIRSCHEN
;<4.MONITOR>FILNSP.MAC.18, 18-Jan-78 16:31:41, EDIT BY KIRSCHEN
;<4.MONITOR>FILNSP.MAC.17, 18-Jan-78 16:30:53, EDIT BY KIRSCHEN
;<4.MONITOR>FILNSP.MAC.16, 18-Jan-78 16:20:07, EDIT BY KIRSCHEN
;<4.MONITOR>FILNSP.MAC.15, 16-Jan-78 11:54:38, EDIT BY KIRSCHEN
;<4.MONITOR>FILNSP.MAC.14, 16-Jan-78 10:28:02, EDIT BY KIRSCHEN
;<4.MONITOR>FILNSP.MAC.13, 16-Jan-78 10:16:49, EDIT BY KIRSCHEN
;<4.MONITOR>FILNSP.MAC.12, 16-Jan-78 10:08:04, EDIT BY KIRSCHEN
;<4.MONITOR>FILNSP.MAC.11, 16-Jan-78 10:06:54, EDIT BY KIRSCHEN
;<4.MONITOR>FILNSP.MAC.10, 16-Jan-78 10:01:39, EDIT BY KIRSCHEN
;<4.MONITOR>FILNSP.MAC.9, 12-Jan-78 15:25:52, EDIT BY KIRSCHEN
;<4.MONITOR>FILNSP.MAC.8, 11-Jan-78 11:16:26, EDIT BY KIRSCHEN
;SUBROUTINIZE ROUTINE COMPUT
;<4.MONITOR>FILNSP.MAC.7,  4-Jan-78 15:23:58, EDIT BY KIRSCHEN
;<4.MONITOR>FILNSP.MAC.6, 28-Dec-77 15:27:56, EDIT BY KIRSCHEN
;<4.MONITOR>FILNSP.MAC.5, 28-Dec-77 15:22:48, EDIT BY KIRSCHEN
;<4.MONITOR>FILNSP.MAC.4, 28-Dec-77 14:37:49, EDIT BY KIRSCHEN
;<4.MONITOR>FILNSP.MAC.3, 28-Dec-77 13:19:49, EDIT BY KIRSCHEN
;<4.MONITOR>FILNSP.MAC.2, 28-Dec-77 11:09:41, EDIT BY KIRSCHEN
;BEGIN MOVING FILESYSTEM CODE FROM MODULE NSPSRV
;A PROCESS OWNS ONE END OF A LOGICAL LINK BY VIRTUE OF ITS HAVING
;A JFN ON THE LINK. THIS JFN IS THE PROCESS' TOOL FOR SENDING
;DATA TO ITS COMPANION PROCESS ON THE OTHER SIDE OF THE LINK OR
;FOR RECEIVING DATA SENT TO IT. THE FOLLOWING JFN FIELDS ARE RELEVANT
;TO NETWORK CONNECTIONS ONLY:

;FILLLB CONTAINS THE ADDRESS OF THE LOGICAL LINK ENTRY
;FILBFO CONTAINS A BYTE POINTER FOR THE CURRENT OUTPUT BUFFER
; LH OF FILBCT CONTAINS COUNT OF BYTES REMAINING IN OUTPUT BUFFER
;FILBFI CONTAINS BYTE POINTER TO CURRENT INPUT BUFFER
; RH OF FILBCT CONTAINS COUNT ON INPUT BYTES REMAINING
; RH OF FILWND CONTAINS WINDOW PAGE ADDRESS FOR INPUT
; LH OF FILWND CONTAINS WINDOW PAGE ADDRESS FOR OUTPUT

; THE FIELDS: FILCNT, FILBYN, FILLEN, AND FILBYT ARE SET UP
; BY NSPSRV FOR THE PROPER DIRECTION OF I/O. THAT IS, WHEN
; THE PROCESS WANTS TO DO OUTPUT, THESE LOCATIONS ARE SET UP
; TO THE VALUES RELEVANT FOR OUTPUT; AND WHEN THE PROCESS
; WANT TO DO INPUT, THESE VALUES ARE SET UP FOR INPUT.
	SEARCH PROLOG,PROKL
	TTITLE (FILNSP,,< - Filesystem Interface to NSP>)



;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
;  OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.
;
;COPYRIGHT (C) 1976,1977,1978,1979,1980,1981,1982 BY DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.

; ACCUMULATOR DEFINITIONS

	DEFAC (STS,P1)
	DEFAC (JFN,P2)
	DEFAC (DEV,P4)
	DEFAC (F1,P5)

; TEMPORARY EXTERNALS

	EXTN <DELNOD,ULOKLL,STRSAV,SKPFLI,SKPFLO,GETSTA,SQOSTA>
	EXTN <SRCOPN,NETSQI,NETCLZ,MTSETC,MTSETI,MTSETD,SETEOM>
	EXTN <RFTADN,NETINP,NETOUP,NETATR,SFTADN,OUTRR,SQOOTR>
	EXTN <OPNDWK,OPNSWK,CRTLNK,MAKINP,BLKLOK,BLKULK>
	EXTN <RDSTS,NTRHN,NTRTN,NTRUS,NTRPW,NTRAC>
	EXTN <NTRDA,MTRDIN,MTSNIN,NTRCOB,NTMTCZ,NTACPT>
	EXTN <NTRCN,MTGSS,SETOPI,SETOPW,STMXDF>

;DEFINITIONS FOR FILE SPECS

MAXDSC==^D16			;MAX CHARACTERS IN DESCRIPTOR
TSKMAX==^D16			;MAX CHARACTERS IN A TASK NAME
MAXHST==:6			;MAX SIZE OF A HOST STRING
SUBTTL	Device Dispatch Vectors for SRV: and DCN: Devices

;FOR DEVICE SRV

SRVDTB::DTBDSP (NETDIR)		;DIRECTORY SET
	DTBDSP (SRNSET)		;NAME LOOKUP
	DTBDSP (EXTSET)		;EXTENSION LOOKUP
	DTBDSP (VERSET)		;VERSION LOOKUP
	DTBBAD (DESX9)		;NO PROTECTION
	DTBBAD (DESX9)		;NO ACCOUNT
	DTBBAD (DESX9)		;NO STATUS
	DTBDSP (SRCOPN)		;OPEN
	DTBDSP (NETSQI)		;INPUT
	DTBDSP (NETSQO)		;OUTPUT
	DTBDSP (NETCLZ)		;CLOSE
   REPEAT 7,<
	DTBBAD (DESX9)>	;ILLEGAL FUNCTIONS
	DTBDSP (NTMTOP)		;MTOPR
   REPEAT 2,<DTBBAD (DESX9)>	;ILLEGAL FUNCTIONS
	DTBDSP (NETSQR)		;SOUTR
	DTBDSP (RFTADN)		;NO TIME AND DATE
	DTBDSP (RFTADN)		;NO TIME AND DATE
	DTBDSP (NETINP)		;SET FOR INPUT
	DTBDSP (NETOUP)		;SET FOR OUTPUT
	DTBBAD (GJFX49)		;NO ATTRIBUTES

;FOR THE DCN DEVICE

DCNDTB::DTBDSP (NETDIR)		;DIR SET
	DTBDSP (DCNSET)		;NAME LOOKUP
	DTBDSP (EXTSET)		;EXTENSION LOOKUP
	DTBDSP (VERSET)		;VERSION LOOKUP
   REPEAT 3,<
	DTBBAD (DESX9)>	;ILLEGAL FUNCTIONS
	DTBDSP (DCNOPN)		;OPEN
	DTBDSP (NETSQI)		;INPUT
	DTBDSP (NETSQO)		;OUTPUT
	DTBDSP (NETCLZ)		;CLOSE
   REPEAT 7,<
	DTBBAD (DESX9)>	;ILLEGAL FUNCTIONS
	DTBDSP (NTMTOP)		;MTOPR
   REPEAT 2,<DTBBAD (DESX9)>	;ILLEGAL FUNCITONS
	DTBDSP (NETSQR)		;SOUTR
	DTBDSP (RFTADN)		;NO TIME AND DATE
	DTBDSP (SFTADN)		;NO TIME AND DATE
	DTBDSP (NETINP)		;SET FOR INPUT
	DTBDSP (NETOUP)		;SET FOR OUTPUT
	DTBDSP (NETATR)		;PARSE ATTRIBUTES
SUBTTL	GTJFN Routines

;ROUTINES CALLED FROM GTJFN PROCESSING TO LOOK UP FILE NAMES

;NAME LOOKUP FOR SRC DEVICE

SRNSET::JUMPE T1,[RETBAD (GJFX18,<OKINT>)] ;CANT'T STEP IT
	CALL [	TRVAR <NTCNT,NTPNT,NTOBJ,NTDDSC,NTDSS>
		CALL SRCNAM	;GO PARSE THE NAME
		 RETBAD()	;HAD AS ERROR
		RETSKP]		;GOOD
	 RETBAD ()		;FAILED
OKRET:	TQNE <UNLKF>		;WANT TO UNLOCK?
	JRST SK2RET		;NO. RETURN
	OKINT			;YES. GO OKINT THEN
	JRST SK2RET		;AND RETURN

;ROUTINE TO DO NAME LOOKUP FOR DCN DEVICE

DCNSET::JUMPE T1,[RETBAD (GJFX18,<OKINT>)] ;CANT'T STEP IT
	CALL [	TRVAR <NTCNT,NTPNT,NTOBJ,NTDSC,NTDSS,NTHST,NTHSC>
		CALL DCNNAM	;GO PARSE NAME
		  RETBAD()	;SOME SORT OF ERROR
		RETSKP]		;GOOD
	 RETBAD ()		;SOME SORT OF FAILURE
	JRST OKRET		;AND DONE

;EXTENSION CHECKER

EXTSET::JUMPE T1,[RETBAD (GJFX18,<OKINT>)] ;CANT'T STEP IT
	CALL [	TRVAR <NTCNT,NTPNT>
		CALL NETEXT	;CHECK EXTENSION
		 RETBAD()	;SOME SORT OF ERROR
		RETSKP]		;AND DONE
	 RETBAD ()		;SOME SORT OF FAILURE
	JRST OKRET		;AND DONE

;ROUTINE TO LOOK UP DIRECTORY COMPONENT IN NETWORK FILE SPEC

NETDIR::TQNE <STEPF>		;WANT TO STEP?
	RETBAD (GJFX17)		;YES. CAN'T DO IT
	NOINT			;PREVENT INTS
	JRST SK2RET		;AND SAY IT IS SET

;VERSION LOOKUP

VERSET::TQNN <STEPF>		;TRYING TO STEP?
	JRST OKRET		;NO. ALLOW IT THEN
	JUMPGE T1,OKRET		;IF NOT STEPPING, OKAY
	RETBAD (GJFX18,<OKINT>)	;ALL ELSE IS WRONG
;ROUTINE TO ASSIGN WINDOW PAGES TO A JFN.
;ACCEPTS:	NORMAL FILE SYSTEM REGISTER (JFN,ETC...)
;RETURNS:	+1	FAILED
;		+2	SUCCESS.

ASGWDW::SETZM FILWND(JFN)
	SETZM FILBCT(JFN)	;AND CLEAR COUNTS
	TQNN <READF>		;WANT READ ON THIS FILE?
	JRST ASGWRT		;NO. TRY WRITE
	CALL ASGPAG		;GET A JSB PAGE
	 RETBAD (MONX02)	;COULDN'T
	HRRM T1,FILWND(JFN)	;SAVE WINDOW PAGE
	LDB T3,PBYTSZ		;GET BYTE SIZE
	CALL MAKINP		;GET A POINTER FOR INPUT
	MOVEM T1,FILBFI(JFN)	;INIT INPUT POINTER
ASGWRT:	TQNN <WRTF>		;WANT WRITE
	RETSKP			;NO ALL DONE
	CALL ASGPAG		;GET A PAGE FOR OUTPUT
	 JRST [	SKIPE T1,FILWND(JFN) ;FAILED. HAVE READ WINDOW?
		CALL RELPAG	;RELEASE THE INPUT PAGE
		SETZM FILWND(JFN) ;NOTE NO PAGE WAS ASSIGNED
		SETZM FILBFI(JFN) ;PREVENT RELEASE OF FREE SPACE BY RLJFN
		RETBAD (MONX02)] ;AND FAIL
	HRLM T1,FILWND(JFN)	;STORE WINDOW
	RETSKP			;AND DONE
;ROUTINE TO COMPUTE NUMBER OF USEFUL BYTES IN A JSB STRING.
;CALLED FROM ROUTINES THAT PROCESS NETWORK FILE NAMES.
;ACCEPTS:	T1/FREE BLOCK ADDRESS
;	TRVAR <NTCNT,NTPNT,.....>
;RETURNS:	+1 ALWAYS WITH COUNT IN NTCNT AND POINTER IN NTPNT

	SWAPCD			;IS SWAPPABLE
COMPUT:	HRRZ T3,0(T1)		;GET COUNT OF WORDS IN BLOCK
	SOS T3			;DISCOUNT THE HEADER
	IMULI T3,5		;GET BYTE COUNT
	AOS T3			;ADD IN FINAL TERMINATOR
	HRLI T1,(<POINT 7,0,35>) ;GET STRING POINTER TO THE BLOCK
	MOVEM T1,NTPNT		;AND SAVE THE STARTING POINTER
	CALL CMPLEN		;GET LENGTH OF STRING
	MOVEM T3,NTCNT		;SAVE COUNT
	RET			;DONE, RETURN


;CMPLEN - ROUTINE TO COMPUTE LENGTH OF STRINGS
;
;ACCEPTS IN T1/ POINTER TO START OF STRING
;	    T3/	MAX NUMBER OF BYTES IN STRING
;		CALL CMPLEN
;RETURNS: +1 ALWAYS, WITH T3/ ACTUAL NUMBER OF BYTES IN STRING

CMPLEN::STKVAR <CPLCNT>
	MOVEM T3,CPLCNT		;STARTING COUNT
	MOVE T2,[POINT 0,0,2]	;GET DUMMY POINTER
	SETZ T4,
	SIN			;FIND NUMBER OF USEFUL BYTES IN THE STRING
	JUMPE T3,R		;IF NO NULLS, ALL SET
	SUB T3,CPLCNT		;FOUND A NULL THEN. GET CHARACTERS SKIPPED
	MOVNS T3		;GET COUNT
	RET			;AND DONE

;ROUTINE TO SCAN NAME STRING FOR NETWORK PUNCTUATION CHARACTER AND
;UPDATE COUNTS.
;ACCEPTS:	IN TRVAR'S
;	NTPNT	CURRENT TEXT POINTER
;	NTCNT	CURRENT BYTE COUNT

;RETURNS:
;	NTPNT	UPDATED POINTER
;	NTCNT	UPDATED COUNT
;	T1/ ORIGINAL POINTER
;	T3/ NUMBER OF CHARCTERS FOUND BEFORE PUNCTUATION

NETDSH:	MOVE T1,NTPNT		;GET BYTE POINTER
	MOVE T2,[POINT 0,0,2]	;DUMMY
	MOVE T3,NTCNT		;THE COUNT
	MOVEI T4,"-"		;STOP ON THE END OF THE HOST FIELD
	SIN			;GET IT
	EXCH T1,NTPNT		;STORE NEW POINTER. GET OLD
	EXCH T3,NTCNT		;STORE NEW COUNT. GET OLD COUNT
	SUB T3,NTCNT		;GET BYTES TRANSPIRED
	RET			;AND DONE
;ROUTINE TO PARSE THE NAME FIELD OF A SOURCE SPECIFICATION.
;A NAME FIELD LOOKS LIKE:
;	OBJECT-DESCRIPTOR
;OR
;	-
;WHERE THE FORMER IS THE SYNTAX FOR A GENERIC OBJECT
;AND THE LATTER IS THE SYNTAX FOR A TASK ONLY
;ACCEPTS:
;	T1/ POINTER TO NAME BLOCK
;	TRVAR <NTCNT,NTPNT,NTOBJ,NTDSC,NTDSS>
;RETURNS:
;	+1 SYNTAX OR SEMANTICS ERROR. CODE IN T1
;	+2 ACCEPTABLE NAME.

;	WITH TRVAR'S FILLED IN

SRCNAM::CALL COMPUT		;COMPUTE STRING COUNT
	SETOM NTOBJ		;ASSUME NO OBJECT
	CALL NETDSH		;GO FIND OBJECT NAME
	CAIG T3,1		;WAS IT NULL?
	JRST SRCNOB		;YES. NO GENERIC OBJECT GIVEN
	LDB T4,NTPNT		;GET TERMINATOR
	MOVEM T4,NTOBJ		;SAVE IT
	SETZ T4,		;GET A NULL
	DPB T4,NTPNT		;TIE OFF OBJECT NAME
	CALL OBJLOK		;GO LOOK UP THE OBJECT
	 RETBAD (DCNX3)		;NO SUCH OBJECT. COMPLAIN
	SKIPG T1		;A LEGAL OBJECT TYPE?
	RETBAD (DCNX3)		;NO. COMPLAIN
	CAIG T1,DECOBJ		;IS IT A DEC RESERVED OBJECT?
	JRST [	MOVX T3,SC%WHL!SC%OPR ;YES. MUST BE PRIVILEGED THEN
		TDNE T3,CAPENB	;IS IT ENABLED?
		JRST .+1	;YES. PROCEED
		RETBAD (DCNX3)]	;NO. ERROR
	EXCH T1,NTOBJ		;SAVE GENERIC OBJECT TYPE
	DPB T1,NTPNT		;AND PUT BACK TERMINATOR
SRCNOB:	SETZM NTDSC		;ASSUME NO DESCRIPTOR
	SKIPE T3,NTCNT		;ANY BYTES LEFT IN STRING?
	CAIG T3,1		;YES. ENOUGH TO MAKE A DESCRIPTOR?
	RETSKP			;NO ALL DONE THEN
	MOVEM T3,NTDSC		;STORE COUNT OF DESCRIPTOR
	SKIPGE NTOBJ		;HAVE AN OBJECT?
	RETBAD (DCNX3)		;NO. ILLEGAL SPECIFICATION
	CAILE T3,MAXDSC		;WITHIN RANGE?
	RETBAD (DCNX12)		;NO.ILLEGAL DESCRIPTOR
	MOVE T1,NTPNT		;GET POINTER
	MOVEM T1,NTDSS		;SAVE BEGINNING OF DESCRIPTOR
	RETSKP			;AND DONE
;ROUTINE TO PARSE NAME FOR A CONNECT ATTEMPT.
;AACEPTS:	T1/ BLOCK ADDRESS OF NAME
;	TRVAR <NTCNT,NTPNT,NTOBJ,NTDSC,NTDSS,NTHST,NTHSC>
;RETURNS:
;		+1 SYNTAX ERROR
;		+2 NAME IS GOOD. TRVAR'S FILLED IN

DCNNAM::CALL COMPUT		;FIND COUNT
	CALLRET PRSNAM		;GO PARSE NAME FIELD



;PRSNAM - ROUTINE TO DO THE PARSING OF THE NAME
;
;ACCEPTS:	IN TRVAR'S
;	NTPNT	CURRENT TEXT POINTER
;	NTCNT	CURRENT BYTE COUNT
;		CALL PRSNAM
;RETURNS: +1	 FAILED, SYNTAX ERROR
;	  +2	SUCCESS, WITH APPROPRIATE TRVARS FILLED IN

PRSNAM::CALL NETDSH		;GO PICK OFF HOST NAME
	SKIPN NTCNT		;MORE IN THE STRING?
	RETBAD (DCNX1)		;NO. SYNTAX ERROR THEN
	SETOM NTHSC		;ASSUME LOCAL CONNECTION
	SOSG T3			;HAVE A REAL STRING?
	JRST DCNOBJ		;NO. GO LOOK FOR OBJECT THEN
	CAILE T3,MAXHST		;WITHIN BOUNDS?
;**;[1778] Change one line at PRSNAM: +7L	JGZ	3-SEP-80
	RETBAD (COMX19)		;[1778] NO. STRING TOO LONG
	MOVEM T1,NTHST		;SAVE POINTER TO HOST
	MOVEM T3,NTHSC		;AND SAVE COUNT
DCNOBJ:	CALL NETDSH		;GO FIND OBJECT
	CAIG T3,1		;HAVE A REAL STRING?
	RETBAD (DCNX3)		;NO. INVALID OBJECT THEN
	LDB T4,NTPNT		;GET BACK TERMINATOR
	MOVEM T4,NTOBJ		;SAVE IT
	SETZ T4,		;GET A NULL
	DPB T4,NTPNT		;TIE OFF STRING
	CALL OBJLOK		;GO LOOK UP THE OBJECT
	 RETBAD (DCNX3)		;NO SUCH
	EXCH T1,NTOBJ		;SAVE OBJECT
	DPB T1,NTPNT		;AND PUT BACK TERMINATOR
	JRST SRCNOB		;FINISH UP ON DESCRIPTOR

;ROUTINE TO PARSE EXTENSION. THIS FIELD WILL BE THE TASKNAME

NETEXT:	CALL COMPUT		;GET COUNT
	MOVE T1,NTCNT		;GET THE COMPUTED COUNT
	CAILE T1,TSKMAX		;WITHING RANGE
	RETBAD (DCNX12)		;NO. TOO LONG
	RETSKP			;AND DONE
SUBTTL	Routines to open DCN: or SRV: links

;COMMON ROUTINE FOR OPENF JSYS. THIS CODE IS CALLED BY BOTH SRCOPN
;AND DCNOPN TO ASSIGN A LL BLOCK, ASSIGN A LL ADDRESS, AND FILL
;IN COMMON VALUES.
;	RETURNS +1	FAILED. T1/ ERROR CODE
;		+2 SUCCESS	T1/ LL BLOCK ADDRESS
;			 AND LL TREE LOCKED

OPNDNC::TDZA T4,T4		;NOTE OPENING DCN:
OPNSRC::SETOM T4		;NOTE OPENING SRV:
	TQZE <RNDF>		;WANT APPEND?
	TQO <WRTF>		;YES. FORCE ON WRITE THEN
	TQNN <READF,WRTF>	;WANT SOME FORM OF ACCESS?
	RETBAD (OPNX14)		;NO. ILLEGAL OPEN
	LDB T2,PBYTSZ		;LOOK AT REQUESTED BYTE SIZE
	CAIE T2,10		;BYTES?
	CAIN T2,7		;OR ASCII?
	JRST BYTGUD		;YES. ACCEPTS IT
	CAIE T2,44		;-10 WORD MODE?
	RETBAD (SFBSX2)		;NO. ILLEGAL BYTE SIZE
BYTGUD:	HRRZ T1,FILNEN(JFN)	;GET ADDRESS OF STRING BLOCK
	ADDI T1,1		;GET ADDRESS OF STRING
	LDB T2,PBYTSZ		;GET BYTESIZE OF OPENF
	SKIPE T4		;OPENING DCN: ?
	JRST [	CALL OPNSWK	;NO, CALL WORK ROUTINE TO OPEN SRV:
		 RETBAD ()	;FAILED, RETURN ERROR CODE
		JRST SAVLLB ]	;GO SAVE LL BLOCK ADDRESS IN JFN BLOCK
	CALL OPNDWK		;CALL WORK ROUTINE TO OPEN DCN:
	 RETBAD ()		;FAILED, RETURN ERROR CODE


SAVLLB:	MOVEM T1,FILLLB(JFN)	;SAVE BLOCK ADDRESS
	TQNE <READF>		;WANT BI-DIRECTIONAL LINK?
	CALL SETOPI		;SET INPUT FLAG FOR LOGICAL LINK
	TQNE <WRTF>		;WANT WRITE?
	CALL SETOPW		;SET OUTPUT FLAG FOR LOGICAL LINK
	CALL STMXDF		;SET INPUT/OUTPUT MAX QUEUE DEFAULTS
	RETSKP			;AND DONE
;ROUTINE CALLED FROM THE OPENF JSYS TO OPEN A DCN NETWORK CONNECTION

DCNOPN::TRVAR <NTCNT,NTPNT,NTOBJ,NTDSC,NTDSS,NTHST,NTHSC,NTCIB>
	HLRZ T1,FILNEN(JFN)	;GET NAME FORTHE CONNECTION
	CALL DCNNAM		;GO PARSE THE NAME FIELD
	 RETBAD ()		;FAILED
	CALL OPNDNC		;GO DO COMMON SETUP
	 RETBAD () 		;FAILED
	CALL ASGWDW		;NOW SET UP WINDOWS
	 RETBAD (,<CALL CLENUP>) ;FAILED, RETURN ERROR
	MOVE T1,FILLLB(JFN)	;GET ADDRESS OF LOGICAL LINK BLOCK
	HRL T2,NTHSC		;GET COUNT OF HOST STRING BYTES
	HRR T2,NTDSC		;GET COUNT OF DESCRIPTOR STRING BYTES
	MOVE T3,NTHST		;GET ADDRESS OF BLOCK HOLDING HOST NAME STRING
	MOVE T4,NTDSS		;GET POINTER TO DESCRIPTOR STRING
	CALL STRSAV		;GO MOVE PERMANENT LL STRINGS
	 RETBAD (,<CALL CLENUP>) ;FAILED, RETURN ERROR
	MOVE T1,FILLLB(JFN)	;GET LOGICAL LINK BLOCK ADDRESS
	LOAD T2,FILATL,(JFN)	;GET POINTER TO ATTRIBUTE LIST
	HRL T3,NTOBJ		;GET OBJECT
	HRR T3,NTDSC		;GET DESCRIPTOR COUNT
	MOVE T4,NTDSS		;GET DESCRIPTOR POINTER
	CALL CRTLNK		;GO CREATE THE LOGICAL LINK
	 RETBAD (,<CALL CLENUP>) ;FAILED
	RETSKP			;DONE, RETURN SUCCESS


;CLENUP - ROUTINE TO CLEAN UP JFN BLOCK IF OPEN OF DCN: FAILS
;
;ACCEPTS IN JFN/ OFFSET TO JFN BLOCK
;		CALL CLENUP
;RETURNS: +1 ALWAYS

CLENUP:	STKVAR <CLNERR>
	MOVEM T1,CLNERR		;SAVE ERROR CODE
	DECR DCCUR		;ONE LESS LINK ON FAILURE
	MOVE T1,FILLLB(JFN)	;GET ADDRESS OF LOGICAL LINK BLOCK
	CALL DELNOD		;FREE THE NODE
	HLRZ T1,FILWND(JFN)	;GET WINDOW PAGE ADDRESS
	SKIPE T1		;ANY WINDOW PAGE ASSIGNED YET ?
	CALL RELPAG		;YES, RELEASE IT
	HRRZ T1,FILWND(JFN)	;GET OTHER WINDOW PAGE
	SKIPE T1		;ANY ASSIGNED ?
	CALL RELPAG		;YES, RELEASE IT ALSO
	SETZM FILBFI(JFN)	;PREVENT RELEASE OF SPACE BY RLJFN
	CALL ULOKLL		;UNLOCK THE LL TREE
	MOVE T1,CLNERR		;RESTORE ERROR CODE
	RET
SUBTTL	MTOPR Routines

NTMTOP:	TQNN <OPNF>		;CHECK FOR OPENED
	RETBAD (CLSX1)		;NO IT IS ILLEGAL
	CALL NETINP		;SET UP FOR INPUT
	MOVE T1,FILLLB(JFN)	;MUST LOCK UP BLOCK
	CALL BLKLOK		;DO IT
	 JRST [	TQO BLKF	;CANNOT LOCK IT, INDICATE BLOCK NEEDED
		RET ]		;RETURN AND TRY AGAIN LATER
	XCTU [HRRZ T2,2]	;GET FUNCTION CODE
	MOVSI T3,-NTMTCT	;SCAN TABLE FOR THE FUNCTION
NTMTO1:	HLRZ T4,NTMTTB(T3)	;GET NEXT ENTRY
	CAIN T2,0(T4)		;IS THIS IT?
	JRST [	HRRZ T2,NTMTTB(T3) ;GET DISPATCH ADDRESS
		JRST 0(T2)]	;AND GO DO IT
	AOBJN T3,NTMTO1		;DO ENTIRE TABLE
	MOVE T1,FILLLB(JFN)	;GET LOGICAL LINK BLOCK ADDRESS
	CALL BLKULK		;UNLOCK THE BLOCK
	RETBAD (MTOX1)		;FAIL

NTMTTB:	.MOACN,,MTASGN		;SET CONNECT INTERRUPT
	.MORLS,,NTSTS		;READ LINK STATUS
	.MORHN,,NTRHN		;READ FOREIGN HOST NAME
	.MORTN,,NTRTN		;READ LINK TASK NAME
	.MORUS,,NTRUS		;READ USER STRING
	.MORPW,,NTRPW		;READ PASSWORD
	.MORAC,,NTRAC		;READ ACCOUNT STRING
	.MORDA,,NTRDA		;READ OPTIONAL DATA
	.MORIM,,MTRDIN		;READ INT MESSAGE
	.MOSIM,,MTSNIN		;SEND INT MESSAGE
	.MOROD,,NTRCOB		;READ OBJ-DESC OF CONNECT OBJECT
	.MOCLZ,,NTMTCZ		;CLOSE/REJECT A CONNECTION
	.MOCC,,NTACPT		;ACCEPT A CONNECTION
	.MORCN,,NTRCN		;READ CONNECT OBJECT NUMBER
	.MORSS,,MTGSS		;GET LINK SEGMENT SIZE
NTMTCT==.-NTMTTB		;LENGTH OF TABLE
;SET INTERRUPT CHANNEL NUMBERS

MTASGN:	ACVAR <W1>		;GET A WORK REG
	UMOVE W1,3		;GET ARGUMENT
	LOAD T2,MO%CDN,W1	;GET CONNECT INTERRUPT
	CALL MTSETC		;GO SET IT
	 JRST NTMERR		;BAD
	LOAD T2,MO%INA,W1	;GET INT CHANNEL
	CALL MTSETI		;GO DO INT CHANNEL
	 JRST NTMERR		;BAD
	LOAD T2,MO%DAV,W1	;GET DATA CHANNEL
	CALL MTSETD		;SET IT
	 JRST NTMERR		;BAD
	CALL BLKULK		;FREE BLOCK
	RETSKP			;AND DONE
;**;[2607] Add one line at MTASGN: +13L	JGZ	2-APR-82
	ENDAV.			;[2607] END OF ACVAR

; HERE ON AN ERROR SETTING THE INTERRUPT CHANNELS

NTMERR:	EXCH T1,FILLLB(JFN)	;SAVE ERROR CODE, GET LL BLOCK ADDRESS
	CALL BLKULK		;UNLOCK THE BLOCK
	EXCH T1,FILLLB(JFN)	;RESTORE LL BLOCK ADDRESS, GET ERROR CODE
	RETBAD ()		;FAIL
;READ LINK STATUS

NTSTS:	CALL RDSTS		;GO GET THE STATUS
	UMOVEM T3,3		;RETURN RESULT
	CALL BLKULK		;FREE BLOCK
	RETSKP			;AND DONE
;UNDO OUTPUT

NETUOU::TQZN <FILOUP>		;NOW DOING OUTPUT?
	RET			;NO. ALL DONE
	MOVE T1,FILLLB(JFN)	;GET LL BLOCK
	CALL SKPFLO		;IS FLOW FROM THE FILE-SYSTEM ?
	 RET			;NO. DONE
	MOVE T1,FILCNT(JFN)	;GET COUNT
	SKIPGE T1
	SETZM T1		;ONLY ALLOW DOWN TO ZERO
	HRLM T1,FILBCT(JFN)	;STORE NEW COUNT
	MOVE T1,FILBYT(JFN)	;GET BYTE POINTER
	MOVEM T1,FILBFO(JFN)	;SAVE IT
	RET			;DONE

;UNDO INPUT

NETUIN::TQZN <FILINP>		;NOW DOING INPUT?
	RET			;NO. ALL DONE
	MOVE T1,FILLLB(JFN)	;GET LL BLOCK
	CALL SKPFLI		;IS FLOW TO THE FILE-SYSTEM ?
	 RET			;NO. ALL DONE
	MOVE T1,FILCNT(JFN)	;GET COUNT
	SKIPGE T1		;VALID COUNT?
	SETZM T1		;ONLLY ALLOW DOWN TO ZERO
	HRRM T1,FILBCT(JFN)	;SAVE IT
	MOVE T1,FILBYT(JFN)	;GET BYTE POINTER
	MOVEM T1,FILBFI(JFN)	;SAVE IT
	RET			;AND DONE
SUBTTL	Sequential I/O JSYS's.

;SEQUENTIAL OUTPUT.

NETSQO:	ASUBR <NETCHR>		;SAVE THE CHARACTER
	MOVE T1,FILLLB(JFN)	;GET LL BLOCK ADDRESS
	CALL BLKLOK		;LOCK IT UP
	 JRST [	TQO <BLKF>	;CANNOT LOCK IT,
		RETBAD() ]	; WAIT UNTIL LOCK IS FREE
	CALL GETSTA		;GO GET CURRENT LOGICAL LINK STATE
	JRST @SQOSTA-1(T2)	;AND DO PROPER THING
NETSQ1::SOSGE FILCNT(JFN)	;HAVE ANY CHARACTERS?
	JRST [	CALL OUTRR	;AND SEND SOME MESSAGES
		 RETBAD()	;FAILED
		CALL NETOUP	;SET UP FOR OUTPUT
		MOVE T1,FILLLB(JFN) ;GET BACK LL BLOCK
		JRST NETSQ1]	;AND TRY AGAIN
	MOVE T2,NETCHR		;GET BYTE
	IDPB T2,FILBYT(JFN)	;STASH BYTE
	CALLRET BLKULK		;RELEASE BLOCK AND RETURN

;FORCE OUT ALL BUFFERED CHARACTERS. CALLED FROM SOUTR

NETSQR:	MOVE T1,FILLLB(JFN)	;GET LL BLOCK ADDRESS
	CALL BLKLOK		;LOCK IT
	 JRST [	TQO <BLKF>	;CANNOT LOCK IT,
		RETBAD() ]	; WAIT UNTIL LOCK IS FREE
	CALL GETSTA		;GO GET CURRENT LOGICAL LINK STATE
	JRST @SQOOTR-1(T2)	;DO WORK
NETSR1::CALL SETEOM		;NOTE THAT NEXT OUTPUT IS AN ENTIRE MESSAGE
	CALL OUTRR		;DO THE WORK
	 RETBAD()		;FAILED
	MOVE T1,FILLLB(JFN)	;GET BACK LL BLOCK
	CALL BLKULK		;UNLOCK BLOCK
	RETSKP			;AND RETURN GOOD

	TNXEND
	END