[inherit('sys$library:starlet','lib$spawn','smgdefs','smg$repaint_line',
'BB.PEN')]
module get_cluster_data;

[global] 
procedure get_cluster_data;

{Obtains information about the VAX cluster the user is logged on to.}

var
  csid : [volatile] unsigned;
  fullnam : [volatile] nodetype;
  i : [volatile] integer;
  rtlen : [volatile] integer;
  status : integer;

begin
  with item_list[1] do
    begin
      length := node_name_length;
      code := lnm$_string;
      adr::node_ptr := address(fullnam);
      retlen := address(rtlen);
    end;
  with item_list[2] do
    begin
      length := 0;
      code := 0;
    end;
  rtlen := 0;

  {Returns information about current node from LNM$SYSTEM_TABLE.  Stores 
   information in item_list.}  
  $trnlnm(tabnam:='LNM$SYSTEM_TABLE',lognam:='SYS$NODE',itmlst:=item_list);

  {Fullnam contains the user's node.  Save user_node and user_id for later
   use by program.}
  user_node := substr(fullnam,1,rtlen-2);
  user_id := substr(substr(fullnam,1,rtlen)+username,1,username_length);

  with item_list[1] do
    begin
      code := syi$_nodename;
      retlen::integer_ptr := address(rtlen);
    end;
  csid := -1;
  i := 1;

  repeat
    rtlen := 0;
    {Get system wide information and wait until information is transferred.
     We are acquiring information about the cluster this system is installed
     on.  This program can handle up to 15 nodes in a VAX/VMS cluster.}
    status := $getsyiw(csidadr:=csid,itmlst:=item_list);

    if (status <> ss$_nomorenode) then
      begin
        {Save node names on the cluster.}
        cluster_usernames[i] :=
          substr(substr(fullnam,1,rtlen)+'::'+username,1,username_length);
        i := i+1;
      end;

  until (status = ss$_nomorenode) or (i > 16);

end;  

end.
