UNSAFE MODULE; IMPORT XClient, Uutmp, Uugid, Upwd, M3toC, Env; VAR mu := NEW(MUTEX); inited := FALSE; PROCEDURE TrestleOS Init () = BEGIN LOCK mu DO IF NOT inited THEN XClient.Init(); inited := TRUE END END END Init; PROCEDUREUserName (): TEXT = VAR res: TEXT; BEGIN res := Env.Get("USER"); IF res = NIL THEN VAR logname := Uutmp.getlogin(); BEGIN IF logname # NIL THEN res := M3toC.CopyStoT(logname) ELSE VAR pwent := Upwd.getpwuid(Uugid.geteuid()); BEGIN IF pwent # NIL THEN res := M3toC.CopyStoT(pwent.pw_name) ELSE res := "Unknown user" END END END END END; RETURN res END UserName; BEGIN END TrestleOS.