	.title  SETUSER - Set User Name
;****************************************************************************
;*                                                                          *
;*  COPYRIGHT (c) 1982                                                      *
;*  By Westinghouse Electric Corporation                                    *
;*                                                                          *
;*  THIS SOFTWARE IS FURNISHED WITHOUT LICENSE AND MAY BE USED AND COPIED   *
;*  ONLY WITH THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE.                  *
;*                                                                          *
;*  THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE    *
;*  AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY WESTINGHOUSE.            *
;*                                                                          *
;*  WESTINGHOUSE ASSUMES NO RESPONSIBILITY FOR THE USE OR  RELIABILITY      *
;*  OF THIS SOFTWARE.                                                       *
;*                                                                          *
;****************************************************************************
;  See V3.0 microfiche #129 I-10
;
;It is necessary to use a LINK ...,SETUSER,SYS$SYSTEM:SYS.STB/SELECTIVE
;to correctly resolve the value for the CTL$T_ parameters needed.
;
;	Calling sequence:
;
;	 ret-status.wlc.v = setuser (user-name.rt.dx)
;
;		user-name:	New user-name
;		ret-status:	SS$_NORMAL, SS$_NOPRIV
;
	.LIBRARY /SYS$LIBRARY:LIB.MLB/
 	$SSDEF
	$JIBDEF
	$PCBDEF

	USER	=	4
	BLANK	=	32
 
	.entry  setuser,^M<r6,r7>

	movq	@USER(ap),r6			;Get User Name
	movzwl	r6,r6
	$cmkrnl_s 10$				;Stuff it in the PCB
	ret					;Return when done
;
; Code to actually stuff the User Name into process header
; and JIB.
;
10$:	.word   ^M<r1,r2,r3,r4,r5,r6,r7>

	movc5	r6,(r7),#BLANK,-
		#JIB$S_USERNAME, CTL$T_USERNAME	;Set User Name in control reg
	movl    CTL$GL_PCB,r0
	movl	PCB$L_JIB(r0),r1		;Get address of JIB
	movc5	r6,(r7),#BLANK,-
		#JIB$S_USERNAME, JIB$T_USERNAME(r1) ;Stuff User Name in JIB as well
	movzbl	#SS$_NORMAL,r0			;Set successful completion

	ret					;Return from CMKRNL
	.end
