home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / PASCAL / NWTP04 / XSERV / CLRCONN.PAS next >
Pascal/Delphi Source File  |  1993-12-29  |  1KB  |  53 lines

  1. {$X+,V-,B-}
  2. Program ClrConn;
  3.  
  4. { Example for the nwServ unit / NwTP 0.4 API. (c) 1994, R.Spronk }
  5.  
  6. { utility for users with console privileges:
  7.  
  8.   Terminate a connection on the current server. }
  9.  
  10. Uses nwMisc,nwServ;
  11.  
  12. Var errCode:Integer;
  13.     connNbr:byte;
  14.     connStr:String;
  15.     showHelp:boolean;
  16.  
  17. begin
  18.  
  19. IF NOT CheckConsolePrivileges
  20.  then begin
  21.       IF nwServ.result=$C6
  22.        then writeln('You need console privileges to run this util.')
  23.        else writeln('Error checking console privileges, err#',nwServ.result);
  24.       halt(1);
  25.       end;
  26.  
  27. IF ParamCount=1
  28.  then begin
  29.       connStr:=ParamStr(1);
  30.       Val(connStr,connNbr,errCode);
  31.       showhelp:=(errCode<>0);
  32.       end
  33.  else showHelp:=true;
  34.  
  35. IF showHelp
  36.  then begin
  37.       writeln('CLRCONN-- usage:');
  38.       writeln;
  39.       writeln('CLRCONN connection_number');
  40.       writeln;
  41.       writeln('the connection_number must be supplied.');
  42.       writeln('it should contain numbers only (range 1..255)');
  43.       halt(1);
  44.       end;
  45. IF ClearConnectionNumber(connNbr)
  46.  then writeln('Connection ',connNbr,' was terminated.')
  47.  else if nwServ.result=253
  48.       then writeln('Connection NOT cleared. The supplied ConnectionNumber was too high.')
  49.       else if nwServ.result=162
  50.            then writeln('You cleared your own connection!')
  51.            else writeln('Connection NOT cleared. Error# ',nwServ.result);
  52.  
  53. end.