.TITLE SETPRN - SETS THE PROCESS NAME. ;++ ; ; FUNCTIONAL DESCRIPTION ; The routine in this module, SETPRN, will set the process name ; as specified by the arguments, and will optionally return the ; old process name. ; It accepts 0, 1, or 2 arguments. ; The first argument, if specified, is the descriptor of the name ; which is to become the new process name. If omitted, or ; if there are no arguments, the process name is set ; to the user name. ; The second argument, if specified, is the descriptor of an area ; to receive the old process name. If omitted, or if there ; is one argument only, the process name is set to the user ; name. ; In any case, if the $SETPRN system service fails, the process name ; is set to the terminal number (e.g. _TTA1:), and the failure code ; is returned in R0. For normal termination, i.e. success, the ; return code is SS$_NORMAL. ; ; N.B. Omitting an argument is not the same as passing a zero argument. ; CALL FOO(0) passes to FOO an argument list whose only element is the ; address of a literal 0, while ; CALL FOO passes to FOO an argument list whose only element IS the ; literal 0. ; ; EXAMPLES ; CALL SETPRN('FOOBAR',X) sets the process name to FOOBAR and returns ; the current process name in the character string X. ; CALL SETPRN(,Y) sets the process name to the user name and returns ; the current process name in Y. ; CALL SETPRN and CALL SETPRN() both simply set the process name to the ; user name. ; ; CALLING SEQUENCE ; CALL SETPRN([NEW][,[OLD]]) ; ;-- $JPIDEF $SSDEF .PSECT SETPRN_CODE,LONG,RD,NOWRT,EXE,SHR .ENTRY SETPRN,^M<> CASEL (AP),#0,#2 ; DISPATCH ON THE NUMBER OF ARGUMENTS. 1$: .WORD 30$-1$ ; NO ARGS .WORD 20$-1$ ; 1 ARG .WORD 10$-1$ ; 2 ARGS 10$: TSTL 8(AP) ; TEST THE SECOND ARGUMENT FOR 0. BEQL 20$ ; IF ZERO, BRANCH. MOVQ @8(AP),R0 ; ELSE, GET THE OUTPUT DESCRIPTOR. MOVL R1,GETNAM+4 ; PUT STRING ADDR IN PLACE FOR GETJPI. $GETJPI_S ,,,GETNAM,,, ; USE $GETJPI TO GET THE PROCESS NAME. 20$: TSTL 4(AP) ; IS ARG ZERO? BEQL 30$ ; IF SO, BRANCH AND PRETEND 0 ARGS. $SETPRN_S @4(AP) ; ATTEMPT TO SET PROCESS NAME TO NAME CMPL R0,#SS$_NORMAL ; SPECIFIED. TEST RETURN STATUS CODE. BNEQ 100$ ; IF OTHER THAN NORMAL, BRANCH. RET ; OK. RETURN. 30$: MOVC5 #0,0,#^A/ /,#15,USERNAME ; BLANK OUT THE USERNAME SPACE. $GETJPI_S ,,,GETUSER,,, ; GET THE USER NAME. $SETPRN_S USER_DESC ; AND SET THE PROCESS NAME TO THAT. CMPL R0,#SS$_NORMAL ; CHECK FOR NORMAL RETURN. BNEQ 100$ ; BRANCH IF NOT. RET ; NORMAL STATUS, RETURN. 100$: PUSHL R0 ; SAVE STATUS CODE FOR RETURN. MOVC5 #0,0,#^A/ /,#15,USERNAME ; BLANK OUT THE USERNAME SPACE. $TRNLOG_S IN_DESC,,USER_DESC1,,, ; GET TERMINAL DESIGNATION. $SETPRN_S USER_DESC ; SET PROCESS NAME TO THAT. POPL R0 ; RESTORE STATUS CODE RET ; AND RETURN. .PSECT SETPRN_RWDATA,QUAD,RD,WRT,NOEXE,NOSHR .ALIGN QUAD USER_DESC: .WORD 15,^X010E .LONG USERNAME USER_DESC1: .WORD 15,^X010E .LONG USERNAME-4 IN_DESC: .WORD 9,^X010E .LONG SYSINPUT .ALIGN LONG GETNAM: .WORD 15,JPI$_PRCNAM .LONG 0 .LONG 0 .LONG 0 GETUSER: .WORD 12,JPI$_USERNAME .LONG USERNAME .LONG 0 .LONG 0 .ALIGN BYTE .BLKB 4 USERNAME: .BLKB 15 SYSINPUT: .ASCII /SYS$INPUT/ .END