home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / ECO30603.ZIP / ECO30603.LZH / ECOLIBII / DEMOS / NOVELL / WHO.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1992-12-11  |  3.8 KB  |  144 lines

  1. uses 
  2.   eco_lib, eco_novl,
  3.   crt, dos
  4.   
  5.   ;
  6.  
  7.  
  8. var
  9.   count,
  10.   total,
  11.   station,
  12.   conntype,
  13.   retcode,
  14.   x,
  15.   write_it,
  16.   pservers,
  17.   not_logged_in : integer;
  18.   username,
  19.   hex_id,
  20.   datetime,
  21.   server,
  22.   node,
  23.   network,
  24.   socket,
  25.   filler,
  26.   search        : string;
  27.  
  28.  
  29.  
  30.   procedure header;
  31.   begin
  32.     filler := '                    ';
  33.     getservername(server,retcode);
  34.     getnode(node,retcode);
  35.     getstation(station,retcode);
  36.     getconnectioninfo(station,username,hex_id,conntype,datetime,retcode);
  37.     if search = '' then 
  38.       writeln('List of currently logged on users for server ',server) else
  39.       writeln('List for user ',__up(search),' on ',server,'.');
  40.     writeln;
  41.   end;
  42.  
  43.  
  44.   
  45.   procedure display_all_users;
  46.   begin
  47.     total := 0; not_logged_in := 0; x := 0; pservers := 0; getserverinfo;
  48.     for count := 1 to serverinfo.connections_max do begin
  49.       get_internet_address(count,network,node,socket,retcode);
  50.       if retcode=0 then begin
  51.         getuser(count,username,retcode);
  52.         if username <> '' then begin
  53.           total := total + 1;
  54.           write_it := 0;
  55.           if search = '' then write_it := 1;
  56.           if ((search <> '') and ( pos(__up(search),__up(username))>0) ) then write_it := 1;
  57.             getconnectioninfo(count,username,hex_id,conntype,datetime,retcode);
  58.           if write_it = 1 then inc(x);
  59.           if write_it = 1 then if count=station then write('*') else write(' ');
  60.           {is the connection an USER or an utility connection}
  61.           if conntype <> 1 then begin
  62.             username := '<'+username+'>'; inc(pservers)
  63.           end;
  64.           if write_it = 1 then write(
  65.             copy(__num(count)+filler,1,3), ' ',
  66.             copy(username+filler,1,15), ' ', datetime
  67.           );
  68.           if write_it = 1 then if x=1 then write('  |  ');
  69.           if x=2 then begin; x:= 0; writeln end;
  70.         end else not_logged_in := not_logged_in + 1;
  71.       end;  {end of connection in use}
  72.     end;
  73.   end;
  74.  
  75.  
  76.   
  77.   procedure footer;
  78.   begin
  79.     writeln;
  80.     if x=1 then writeln;
  81.     write(total,' user');
  82.     if total=1 then write(' is ') else write('s are ');
  83.     writeln('logged into ',server,' as of ', __curdate);
  84.     if not_logged_in > 0 then begin
  85.       write(not_logged_in,' other connection');
  86.       if not_logged_in = 1 then write(' is ') else write('s are ');
  87.       writeln('in use, but the workstation has logged out.');
  88.     end;
  89.     if pservers > 0 then writeln(
  90.       pservers, ' of the ', total, ' users were logged-in on ',
  91.       server, ' as print servers.'
  92.     );
  93.   end;
  94.  
  95.  
  96.   
  97.   procedure credits;
  98.   begin
  99.     writeln;
  100.     writeln('WHO:  Displays a list of currently logged in users.');
  101.     writeln;
  102.     writeln('Example:     C> WHO             Display everyone');
  103.     writeln('             C> WHO username    Display a particular user.');
  104.     writeln('             C> WHO server/     Display a different server.');
  105.     writeln;
  106.     halt;
  107.   end;
  108.  
  109.  
  110.   
  111.   procedure change_server;    { change default server to something else }
  112.   var
  113.     x, y, z    : integer;
  114.     new_server,
  115.     servername :  string;
  116.  
  117.   begin
  118.     z := 0; x := pos('/',search); new_server := __nw(__up(copy(search,1,x-1)));
  119.     search := __up(__nw(copy(search,x+1,255)));
  120.     for y := 1 to 8 do begin
  121.       get_file_server_name(y, servername);
  122.       writeln(y,':',servername);
  123.       if servername = new_server then begin
  124.         z := 1;
  125.         set_preferred_connection_id(y);
  126.       end;
  127.     end;
  128.     if z=0 then begin
  129.       writeln('Server ',new_server,' not found.');
  130.       halt;
  131.     end;
  132.   end;
  133.  
  134.  
  135.  
  136. begin
  137.   if paramcount > 0 then search := paramstr(1) else search := '';
  138.   if search = '?' then credits;
  139.   if pos('/', search) > 1 then change_server;
  140.   header;
  141.   display_all_users;
  142.   footer;
  143. end.
  144.