Article 4426 of vmsnet.internals:
Path: nntpd.lkg.dec.com!pa.dec.com!news1.digital.com!nntp-hub2.barrnet.net!nntp-ucb.barrnet.net!agate!newsxfer.itd.umich.edu!chi-news.cic.net!nntp.coast.net!harbinger.cc.monash.edu.au!news.uwa.edu.au!info.curtin.edu.au!newsmaster
From: crobw@cuppa.curtin.edu.au
Newsgroups: vmsnet.internals
Subject: Need to port CHECKDIR.MAR to Alpha
Date: Mon, 18 Dec 95 11:56:20 +800
Organization: Curtin University
Lines: 59
Message-ID: <4b2op3$q15@info.curtin.edu.au>
NNTP-Posting-Host: alpha4.curtin.edu.au

A large project here relies on a routine, CHECKDIR, originally provided by Dale
O. Miller of University of Arkansas at Little Rock. He informs me that he has
not yet had to face the problem of porting this to the Alpha platform.

CHECKDIR returns the full file specification of the command file from which the
current executing image was invoked.

I have appended the source below my .sig in the hope that someone knows how to
get the same result on OpenVMS/Alpha.

/Robert J Wright  Virtual Memory Systematist and Digital Command Linguist
Curtin University Computing Centre.            (+61-9) 351-7385 voice (24hrs)
Kent Street, Bentley 6102, Western Australia.  (+61-9) 351-2673 fax
GPO Box U1987, Perth 6001, Western Australia.  R.Wright@curtin.edu.au

	.TITLE CHECKDIR
	.IDENT /1.0/
;-------------------------------------------------------------------------------
;
;	This routine returns the name of the currently executing command
;	procedure.
;
;	Call with the address of a string descriptor.
;	Status is returned in R0
;
;-------------------------------------------------------------------------------

	.LIBRARY /SYS$LIBRARY:LIB/	; Executive macro library
	.LINK 'SYS$SYSTEM:SYS.STB'/SELECTIVE_SEARCH
	.LINK "SYS$SYSTEM:DCLDEF.STB"/SELECTIVE_SEARCH

	$PCBDEF				; Process Control Block offsets
	$STSDEF				; Command Lang defs
	$UAIDEF
;-------------------------------------------------------------------------------

	.PSECT	CODE RD,NOWRT,PIC,EXE,LONG
	.ENTRY	CHECKDIR ^M<r6,r7,r8>		; Routine entry point
	movzwl	@4(ap),r6
	movl	4(ap),r7

        $CMEXEC_S ROUTIN=200$		;call the retreival code in EXEC mode
        BLBS	R0,5$			;quit if problem (nopriv)
	BRW	90$
5$:	MOVL	#SS$_NORMAL,R0
90$:	RET				; back to the caller

200$:   .WORD   0			; Exec entry point
        MOVAL   G^CTL$AG_CLIDATA, R1    ;get address of process's cli area
        MOVAL   @PPD$L_PRC(R1), R1      ;pointer to process permanent data
        MOVAL   @PRC_L_IDFLNK(R1), R1   ;   "    to indirect command file
        MOVAB   @IDF_L_FILENAME(R1), R1 ;   "    to command proc name
        MOVZBl  (R1), r8		;save length of name
        MOVC5   r8, 1(R1), #^A' ', -	;copy name--padded with blanks--
                r6, @4(r7)		; into passed string
        MOVZWL  #SS$_NORMAL, R0		; Set success
        RET				; Return from exec
;
	.END


Article 4427 of vmsnet.internals:
Path: nntpd.lkg.dec.com!sousa.amt.tay1.dec.com!pa.dec.com!decwrl!infopiz!news1.best.com!sdd.hp.com!swrinde!newsfeed.internetmci.com!news.mathworks.com!mvb.saic.com!macro32
Newsgroups: vmsnet.internals
Subject: RE: Need to port CHECKDIR.MAR to Alpha
Message-ID: <0099B0A7.A85B94CF.19@ALPHA.WKU.EDU>
From: Hunter Goatley <goathunter@LOKI.COM>
Date: Mon, 18 Dec 1995 08:02:36 CST
Organization: Macro32<==>Vmsnet.Internals Gateway
X-Gateway-Source-Info: Mailing List
Lines: 104

crobw@cuppa.curtin.edu.au writes:
>
>A large project here relies on a routine, CHECKDIR, originally provided by Dale
>O. Miller of University of Arkansas at Little Rock. He informs me that he has
>not yet had to face the problem of porting this to the Alpha platform.
>
>CHECKDIR returns the full file specification of the command file from which the
>current executing image was invoked.
>
It was simple to change.  I made a few other changes to it, as well.
For example, STR$COPY_DX is used to return the file spec, instead of
assuming a static descriptor.

New code is below my sig.  To use it on Alpha:

	$ macro checkdir
	$ link main,checkdir,sys$input/options/sysexe
	sys$loadable_images:dcldef.stb/sel
	^Z
	$

On VAX:

	$ macro checkdir
	$ link main,checkdir


Hunter
------
Hunter Goatley, Sr. OpenVMS Systems Programmer, The LOKI Group, Inc.
<goathunter@LOKI.COM>
--------------------------------------------------------------------------------
	.TITLE CHECKDIR
	.IDENT /2.0/
;-------------------------------------------------------------------------------
;
;	This routine returns the name of the currently executing command
;	procedure.
;
;	Call with the address of a string descriptor.
;	Status is returned in R0
;
;	Modified by Hunter Goatley, 18-DEC-1995, for use on VAX and Alpha.
;-------------------------------------------------------------------------------

	.LIBRARY /SYS$LIBRARY:LIB/	; Executive macro library

;
;  Define ALPHA if R22 is a register and not a symbol
;
	.NTYPE	...IS_IT_ALPHA,R22		;Get the type of R22
	...IS_IT_ALPHA = <...IS_IT_ALPHA@-4&^XF>-5
	.IIF EQ,...IS_IT_ALPHA,	ALPHA=1

.IF NOT_DEFINED ALPHA
	.LINK	"SYS$SYSTEM:SYS.STB"/SELECTIVE_SEARCH
	.LINK	"SYS$SYSTEM:DCLDEF.STB"/SELECTIVE_SEARCH
.ENDC

	$LIBDEF
	$NAMDEF				; NAM$ symbols
	$PCBDEF				; Process Control Block offsets
	$STSDEF				; Command Lang defs
	$UAIDEF
;-------------------------------------------------------------------------------

	.PSECT	DATA RD,WRT,LONG

TMP:	.WORD	0
	.BYTE	DSC$K_DTYPE_T
	.BYTE	DSC$K_CLASS_S
	.ADDRESS .+4
	.BLKB	NAM$C_MAXRSS

	.PSECT	CODE RD,NOWRT,PIC,EXE,LONG
.IF DEFINED ALPHA
CHECKDIR::	.CALL_ENTRY	HOME_ARGS=TRUE,MAX_ARGS=1,PRESERVE=<R6,R7,R8>
.IFF
	.ENTRY	CHECKDIR ^M<r6,r7,r8>		; Routine entry point
.ENDC
	MOVL	#LIB$_WRONUMARG,R0	; Assume error
	CMPW	#1,(AP)			; Check the number of args
	BNEQU	10$			; Return error if wrong number
	$CMEXEC_S -			;call the retreival code in EXEC mode
		ROUTIN=CHECKDIR_EXEC
	BLBC	R0,10$			; Branch on error
	PUSHAL	TMP			; Now copy the returned string to the
	PUSHL	4(AP)			; .... caller's buffer
	CALLS	#2,G^STR$COPY_DX	; ....
 10$:	RET				; back to the caller

	.ENTRY	CHECKDIR_EXEC,^M<R2,R3,R4,R5>	; Exec entry point
	MOVAL	G^CTL$AG_CLIDATA, R1	;get address of process's cli area
	MOVAL	@PPD$L_PRC(R1), R1	;pointer to process permanent data
	MOVAL	@PRC_L_IDFLNK(R1), R1	;   "    to indirect command file
	MOVAB	@IDF_L_FILENAME(R1), R1 ;   "    to command proc name
	MOVZBL	(R1)+, R0		;save length of name
	BEQLU	10$			; Branch if no string
	MOVW	R0,TMP			; Save length in descriptor
	MOVC3	R0,(R1),@TMP+4		;copy name to temporary buffer
 10$:	MOVZWL	#SS$_NORMAL, R0		; Set success
	RET				; Return from exec

	.END


