2
0

IdRexecServer.pas 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. {
  2. $Project$
  3. $Workfile$
  4. $Revision$
  5. $DateUTC$
  6. $Id$
  7. This file is part of the Indy (Internet Direct) project, and is offered
  8. under the dual-licensing agreement described on the Indy website.
  9. (http://www.indyproject.org/)
  10. Copyright:
  11. (c) 1993-2005, Chad Z. Hower and the Indy Pit Crew. All rights reserved.
  12. }
  13. {
  14. $Log$
  15. }
  16. {
  17. Rev 1.2 1/21/2004 3:27:20 PM JPMugaas
  18. InitComponent
  19. Rev 1.1 1/31/2003 02:32:10 PM JPMugaas
  20. Should now compile.
  21. Rev 1.0 11/13/2002 07:59:50 AM JPMugaas
  22. 2001, Feb 17 - J. Peter Mugaas
  23. moved much of the code into IdRemoteCMDServer so it can be
  24. reused in IdRSHServer
  25. 2001, Feb 15 - J. Peter Mugaas
  26. made methods for error and sucess command results
  27. 2001, Feb 14 - J. Peter Mugaas
  28. started this unit
  29. }
  30. unit IdRexecServer;
  31. {
  32. based on
  33. http://www.winsock.com/hypermail/winsock2/2235.html
  34. http://www.private.org.il/mini-tcpip.faq.html
  35. This is based on the IdRexec.pas unit and
  36. programming comments at http://www.abandoned.org/nemon/rexeclib.py
  37. }
  38. interface
  39. {$i IdCompilerDefines.inc}
  40. uses
  41. Classes,
  42. IdAssignedNumbers, IdContext, IdRemoteCMDServer, IdTCPClient;
  43. type
  44. TIdRexecCommandEvent = procedure (AThread: TIdContext;
  45. AStdError : TIdTCPClient; AUserName, APassword, ACommand : String) of object;
  46. TIdRexecServer = class(TIdRemoteCMDServer)
  47. protected
  48. FOnCommand : TIdRexecCommandEvent;
  49. procedure DoCMD(AThread: TIdContext;
  50. AStdError : TIdTCPClient; AParam1, AParam2, ACommand : String); override;
  51. public
  52. constructor Create(AOwner: TComponent); override;
  53. published
  54. property OnCommand : TIdRexecCommandEvent read FOnCommand write FOnCommand;
  55. property DefaultPort default Id_PORT_exec;
  56. end;
  57. implementation
  58. { TIdRexecServer }
  59. constructor TIdRexecServer.Create(AOwner: TComponent);
  60. begin
  61. inherited Create(AOwner);
  62. DefaultPort := Id_PORT_exec;
  63. {This variable is defined in the TIdRemoteCMDServer component. We do not
  64. use it here because Rexec does not require it. However, we have to set this to
  65. to false to disable forcing ports to be in a specific range. The variable in is the
  66. anscestor because only accepting clients in a specific range would require a change
  67. to the base component.}
  68. FForcePortsInRange := False;
  69. FStdErrorPortsInRange := False;
  70. end;
  71. procedure TIdRexecServer.DoCMD(AThread: TIdContext;
  72. AStdError: TIdTCPClient; AParam1, AParam2, ACommand: String);
  73. begin
  74. if Assigned(FOnCommand) then begin
  75. FOnCommand(AThread,AStdError,AParam1,AParam2,ACommand);
  76. end;
  77. end;
  78. end.