{
* alluser.pas - get names of all users
* by Deep, 1989
* This program is freely redistributable as long no modifications are made
* DISCLAIMER: I take no responsibility for any use or abuse of this
*             program.  It is given for informational purpose only.
*
* program history:
* 04-May-89   started
* 02-Jun-89   clean up of code
}
[inherit ('sys$library:starlet.pen')]
program alluser(input,output);

  type $word      = [word] 0..65535;
       $byte      = [byte] 0..255;
       $quadword  = record
                      lo,hi : unsigned;
                    end;
       $uquad  = record
                      lo,hi : unsigned;
                    end;
var
  id: unsigned;
  status, status2: integer;
  length: $WORD;
  attrib,context,context2,context3: unsigned;
  ident, ident2: unsigned;
  name: varying [512] of char;
  holder: $uquad;

begin

writeln('Alluser - use at your own risk!');
status := SS$_NORMAL;
{ id = -1 selects next identifier }
id := -1;
context := 0;
while (status <> SS$_NOSUCHID) do
   begin
   { find next identifier }
   status := $idtoasc(id,name.length,name.body,ident,attrib,context);
   if (status <> SS$_NOSUCHID) then begin
      write(pad(name,' ',32));
      if (ident div (65536*32768) > 0) then
         { it's a rights-list, so print the hex-value of the identifier }
         begin
         writeln(oct(ident,12));
         context2 := 0;
         context3 := 0;
         { find all holders of this right }
         repeat
            holder := zero;
            status2 := $find_holder(ident,holder,attrib,context2);
            if (holder.lo <> 0) then begin
                ident2 := ident;
                { get UIC and username }
                status := $idtoasc(holder.lo,name.length,name.body,ident2
                    ,attrib,context3);
                write('                ',pad(name,' ',32));
                writeln('[',oct(holder.lo div 65536,3),','
                    ,oct(holder.lo mod 65536,3),']');
               end;
         until (holder.lo = 0);
         end
      else
         { it's a UIC, so translate to [grp,user] }
         begin
         writeln('[',oct(ident div 65536,3),',',oct(ident mod 65536,3),']');
         end;
      end;
   end;
end.
