anchor.diff:  	    Values
       end.
   
  -%%%----------------    
  +%%%----------------
   pcollect_pids(undefined, Collector) ->
       Collector;
   
  
positive.code: 	_ -> "alive"
      end.
  
  indent(D, I) -> io__format(D,'~*c',[I,$ ]). 
  
  children(Pid) ->
      Parent = self(),
  
negative.code: 	 collect_pids/0
  	]).
  
  -include("ssh_connect.hrl").
  
  print() ->
      io:format("~s", [string()]).
  
  print(File) when is_list(File) ->
      {ok,D} = file:open(File, write),
      print(D),
      file:close(D);
  print(D) ->
      io:format(D, "~s", [string()]).
  
  string() ->
      try supervisor:which_children(ssh_sup)
      of
  	_ ->
  	    [io_lib:nl(),
  	     print_general(),
  	     io_lib:nl(),
  	     underline("Client part", $=),
  	     print_clients(),
  	     io_lib:nl(),
  	     underline("Server part", $=),
  	     print_servers(),
  	     io_lib:nl(),
  	     underline("Supervisors", $=),
  	     walk_sups(ssh_sup),
  	     io_lib:nl()]
      catch
  	_:_ ->
  	    io_lib:format("Ssh not found~n",[])
      end.
  
  
  %%%================================================================
  -define(INDENT, "    ").
  
  print_general() ->
      {_Name, Slogan, Ver} = lists:keyfind(ssh,1,application:which_applications()),
      [underline(io_lib:format("~s  ~s", [Slogan, Ver]), $=),
       io_lib:format('This printout is generated ~s. ~n',[datetime()])
      ].
  
  print_clients() ->
      try
  	lists:map(fun print_client/1,
  		  supervisor:which_children(sshc_sup))
      catch
  	C:E ->
  	    io_lib:format('***print_clients FAILED: ~p:~p~n',[C,E])
      end.
  
  print_client({undefined,Pid,supervisor,[ssh_connection_handler]}) ->
      {{Local,Remote},_Str} = ssh_connection_handler:get_print_info(Pid),
      [io_lib:format(?INDENT"Local: ~s  Remote: ~s  ConnectionRef = ~p~n",
  		   [fmt_host_port(Local), fmt_host_port(Remote), Pid]),
       case channels(Pid) of
  	 {ok,Channels=[_|_]} ->
  	     [print_ch(ChPid) || #channel{user=ChPid} <- Channels];
  	_ ->
  	    io_lib:format(?INDENT?INDENT?INDENT"No channels~n",[])
       end];
  
  print_client(Other) ->
      io_lib:format("    [[Other 1: ~p]]~n",[Other]).
  
  
  %%%================================================================
  print_servers() ->
      try
  	lists:map(fun print_server/1,
  		  supervisor:which_children(sshd_sup))
      catch
  	C:E ->
  	    io_lib:format('***print_servers FAILED: ~p:~p~n',[C,E])
      end.
  
  
  print_server({{server,ssh_system_sup,LocalHost,LocalPort,Profile},Pid,supervisor,[ssh_system_sup]}) when is_pid(Pid) ->
      Children = supervisor:which_children(Pid),
      [io_lib:format(?INDENT"Listen: ~s (~p children) Profile ~p",[fmt_host_port({LocalHost,LocalPort}),
  								 ssh_acceptor:number_of_connections(Pid),
  								 Profile]),
       case [AccPid 
  	   || {{ssh_acceptor_sup,_LocalHost,_LocalPort,_Profile}, AccPid, supervisor, [ssh_acceptor_sup]} 
  		  <- Children] of
  	 AcceptorPids = [_|_] ->
  	     [io_lib:format("  [Acceptor Pid", []),
  	      [io_lib:format(" ~p",[AccPid]) || AccPid <- AcceptorPids],
  	      io_lib:format("]~n", [])
  	     ];
  	 [] ->
  	     io_lib:nl()
       end,
       lists:map(fun print_system_sup/1,
  	       supervisor:which_children(Pid))
      ].
  
  
  print_system_sup({Ref,Pid,supervisor,[ssh_subsystem_sup]}) when is_reference(Ref),
  								is_pid(Pid) ->
      lists:map(fun print_channels/1,
  		  supervisor:which_children(Pid));
  
  print_system_sup({{ssh_acceptor_sup,_LocalHost,_LocalPort,_Profile}, Pid, supervisor, [ssh_acceptor_sup]}) when is_pid(Pid) ->
      [].
  
  
  
  print_channels({{server,ssh_channel_sup,_,_},Pid,supervisor,[ssh_channel_sup]}) when is_pid(Pid) ->
      Children =  supervisor:which_children(Pid),
      ChannelPids = [P || {R,P,worker,[ssh_channel]} <- Children,
  			is_pid(P),
  			is_reference(R)],
      case ChannelPids of
  	[] -> io_lib:format(?INDENT?INDENT"No channels~n",[]);
  	[Ch1Pid|_] ->
  	    {{ConnManager,_}, _Str} = ssh_channel:get_print_info(Ch1Pid),
  	    {{_,Remote},_} = ssh_connection_handler:get_print_info(ConnManager),
  	    [io_lib:format(?INDENT?INDENT"Remote: ~s ConnectionRef = ~p~n",[fmt_host_port(Remote),ConnManager]),
  	     lists:map(fun print_ch/1, ChannelPids)
  	    ]
      end;
  print_channels({{server,ssh_connection_sup,_,_},Pid,supervisor,[ssh_connection_sup]}) when is_pid(Pid) ->
      []. % The supervisor of the connections socket owning process
  
  print_ch(Pid) ->
      try
  	{{ConnManager,ChannelID}, Str} = ssh_channel:get_print_info(Pid),
  	{_LocalRemote,StrM} = ssh_connection_handler:get_print_info(ConnManager),
  	io_lib:format(?INDENT?INDENT?INDENT"ch ~p ~p: ~s ~s~n",[ChannelID, Pid, StrM, Str])
      catch
  	C:E ->
  	    io_lib:format('****print_ch FAILED for ChanPid ~p: ~p:~p~n',[Pid, C, E])
      end.
  
  
  %%%================================================================
  -define(inc(N), (N+4)).
  
  walk_sups(StartPid) ->
      io_lib:format("Start at ~p, ~s.~n",[StartPid,dead_or_alive(StartPid)]),
      walk_sups(children(StartPid), _Indent=?inc(0)).
  
  walk_sups([H={_,Pid,_,_}|T], Indent) ->
      [indent(Indent),
       io_lib:format('~200p  ~p is ~s~n',[H,Pid,dead_or_alive(Pid)]),
       case H of
  	 {_,_,supervisor,[ssh_connection_handler]} -> "";
  	 {_,Pid,supervisor,_} -> walk_sups(children(Pid), ?inc(Indent));
  	 _ -> ""
       end,
       walk_sups(T, Indent)
      ];
  walk_sups([], _) ->
      "".
  
  dead_or_alive(Name) when is_atom(Name) ->
      case whereis(Name) of
  	undefined ->
  	    "**UNDEFINED**";
  	Pid ->
  	    dead_or_alive(Pid)
      end;
  dead_or_alive(Pid) when is_pid(Pid) ->
  