	.TITLE NTCONB
	.ENABLE LC
	.IDENT /060188/
;
;     Description: Build DECNET Connect Block
;  	     File: [22,310]NTCONB.MAC
;	   Author: Jim Bostwick   1-JUN-1988 
;	Last Edit: 15-NOV-1988 12:18:56 
;	  History: 
;		 3-AUG-1989 10:50:29 - JMB - changed location of PASMAC (again)
;		 15-NOV-88 12:00:00 - JMB - Conform to AMI Header specs. 
; 		 23-JUN-1988 21:17:23  - JMB PA3UTL upgrade.
;

.REM |
{*CALL*}

Procedure NTCONB (
	node: Ch6;
	obj: byte;
	task: packed array [lo..hi:Integer] of char;
	VAR conb: Net_Request_block;
	VAR Stat: Integer
	);External;

{*USER*

 Builds a network connect block in CONB. The connect block is in a format
suitable for DECnet - no attempt has been made to map it's contents to 
Pascal. 
 NODE specifies the remote node name. 
 OBJ is the remote object number to be connected to. Specify 0 (zero) for 
named objects, or an object number (1..255). If OBJ is zero, TASK must
be specified. 
 TASK is the remote task name for OBJ=0 connections. It is ignored if OBJ
is not zero. Although specified as a conformant array parameter, TASK 
must be less than or equal to 16. characters. 
 } 

{*WIZARD*

 No access control information is provided by this procedure. It is assumed
that all network tasks will use network aliases, thus moving the access
control  out of the program and into the alias definitions. 

 Although no record definition for the connect block exists, masochists may
crack the thing using the offsets defined in the CONL$$ section of the 
MACRO-11 section of the DECNET-RSX Programmer's Reference Manual.
The information in this section may also be used to manually initialize
the user access information fields in the connect block. 

 The 'short' connect block formats are not supported.  
 }

|

;
; Assemble with PASMAC.MAC as prefix file.
;

	.include /pas$utl:pasmac.mac/
	.library /lb:[1,1]netlib.mlb/
	.mcall CRBDF$

	CRBDF$				; define connect block offsets

	PROC NTCONB
	PARAM NODE, 6*CHAR		; node name (ch6)
	PARAM OBJ, CHAR			; object number (BYTE)
	PARAM TASK, Address		; task name string address
	PARAM tasklo, Integer		; lo bound
	PARAM taskhi, Integer		; hi bound
	PARAM conb, Address		; connect block
	PARAM status, Integer		; return status

	SAVE <R0,R1,R2,R3,R4>
	BEGIN
	mov	conb(sp), r0		; r0-> conb
	mov	sp, r1			; r1 -> node string
	add	#node, r1		; 
	mov	#6, r2			; count
	mov	r0, r3			; r3 -> node in conb
	add	#n.rnd, r3		;

10$:	movb	(r1)+, (r3)+		; copy node name
	sob	r2, 10$

	clrb	n.RFM(r0)		; assume format 0 (obj <> 0)
	movb	obj(sp), n.ROT(r0)	; copy object number
	bne	100$			; if ne, skip task name

	incb	n.RFM(r0)		; obj=0 ==> format 1
	mov	sp, r1			; r1 -> task name
;
;
	.GLOBL XXSLEN
	
	mov	task(r1), -(sp)		; set up for XXSLEN call
	mov	tasklo(r1), -(sp)
	mov	taskhi(r1), -(sp)
	call	xxslen
	
	tst	(sp)+			; don't care about type
	mov	(sp)+, r1		; get length
	mov	(sp)+, r3		; get adjusted address
	cmp	#16., r1		; length within specs?
	bhis	60$			; yes - br
	mov	#-1, @status(sp)	; return IE.BAD
	br	errout			; and quit

60$:	; common copy loop
	mov	r1, n.RDEC(r0)		; stuff task name length
	mov	r0, r4			; r4 -> conb
	add	#n.RDE, r4		; r3 -> task name in conb

70$:	movb	(r3)+, (r4)+		; copy task name to conb
	sob	r1, 70$

100$: 	; zap unused accounting fields
	add	#n.ridc, r0		; r0-> access info area
	mov	#<<n.rql-n.ridc>/2>, r2	; r2 = word count

110$:	clr	(r0)+			; clear access area
	sob	r2, 110$

	mov	#1, @status(sp)		; show success (clears carry)
	br	done

errout:	sec

done:	
	ENDPR

	.END

