	.title ethgetl
; By Glenn C. Everhart
;  Purpose:
;  Simple routine callable from Fortran to translate a logical and
;  return its value in an array of characters. Expects args passed
;  by reference. This code is set to translate the name "ETH_SSTR"
;  and return it.
; get logical name for search string (can be modified for other uses)
; to pass further selection to ethermon /analyzer=filename realtime
; filters.
; call:
;  call ethgetl(chars,len)
; where we return data in chars and len, and return len=0 or negative
; to indicate no data.
        .library        "SYS$LIBRARY:LIB"
        $dvidef
        $iodef
	$lnmdef
        $prdef
        $prvdef
        $ucbdef
	.psect	getldat,quad
logt:   .ascid  /LNM$JOB_TABLE/     ;devname logical in system table
logn:   .ascid  /ETH_SSTR/                 ;the switch logical
logitm: .word   64,LNM$_STRING
        .address        log             ;structure of trnlnm(home-made!)
        .address        ztns            ;6 longs
        .long   0                       ;that's it
log:    .blkl   16                      ;look in here
	.align quad
atr:    .long   LNM$M_CASE_BLIND        ;be case blinded!
	.align quad
zt_namedsc:
ztns:   .word   24
        .byte   dsc$k_dtype_t
        .byte   dsc$k_class_s   ;fixed string
ztna:   .address log    ;point at logical name trans. result.
	.psect getlcod
;
; Attempt to translate logical name "ETH_SSTR" and if we get it, return
; the translation as the string to filter on.
;
	.entry ethgetl,^m<r2,r3,r4,r5,r6,r7,r8,r9,r10,r11>
; 4(ap) is data address to return
; @8(ap) is length to return
	movl	#-1,@8(ap)	;store negative result length initially
        $trnlnm_s       attr=atr,tabnam=logt,-
                        lognam=logn,-           ;is the logical there?
                        itmlst=logitm
	blbc	r0,999$
	movl	4(ap),r2	;data destination address to copy to
	movl	ztns,r6		;return length
	bleq	999$		;(if not positive forget it)
	movab	log,r4		;where data is
	movc3	r6,(r4),(r2)	;fill in data
	movl	r6,@8(ap)	;and tell caller how long it was.	
;
999$:
	ret
	.end
