!PASS: Set password - modded JHB Oct 84 to use current directory/user
!  GDMR 03/02/87  Verify old password only for filestores B & C (interim fix)

%include "inc:fs.imp"
%include "inc:fsutil.imp"
%include "inc:util.imp"

%begin; !Pass: change password
%integer on=1
%integer x
%string(255)old,new1,new2,user
%string(7)directory,owner

  %routine logon(%string(63)u,p)
  %string(127)s = u.",".p
  %integer x
    x = fcomm('M'<<8,""); on = 0
    x = fcomm('L'<<8,s);  on = 1
  %end

  %onevent 3,9 %start
    printstring(event_message)
    printstring(" - you have been logged off") %if on=0
    newline
    %stop
  %finish

  user = current directory
  Define Param ("Owner", user, pam major)
  Process Parameters (cli param)

  directory = current directory
  owner = current user

  set terminal mode(noecho)
  x = testsymbol %until testsymbol<0

  %if (RDTE = 16_15 {FS B} %or RDTE = 16_1B {FS C}) %and user=owner %start
      prompt("Old password:"); readline(old)
      logon(owner,old)
      set directory(directory)
  %finish

  prompt("New password:"); readline(new1)
  prompt("Confirm:"); readline(new2)
  %if new1#new2 %start
    printstring("Not confirmed"); newline; %stop
  %finish
  new1 = new1.",".user %if user#owner
  x = fcomm('P'<<8,new1)
  %stop %if user#owner %or 16_15 # RDTE # 16_1B

  ! Why does he bother with this next bit, I wonder.....?
  logon(owner,new1)
  set directory(directory)
%endofprogram
