home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd1.bin / zkuste / Delphi / kompon / d345 / GUI2ConsoleDemo.EXE / lib / bcb4 / ConsoleIO.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-03-09  |  8.5 KB  |  280 lines

  1. // Borland C++ Builder
  2. // Copyright (c) 1995, 1999 by Borland International
  3. // All rights reserved
  4.  
  5. // (DO NOT EDIT: machine generated header) 'ConsoleIO.pas' rev: 4.00
  6.  
  7. #ifndef ConsoleIOHPP
  8. #define ConsoleIOHPP
  9.  
  10. #pragma delphiheader begin
  11. #pragma option push -w-
  12. #include <SyncObjs.hpp>    // Pascal unit
  13. #include <Dialogs.hpp>    // Pascal unit
  14. #include <Forms.hpp>    // Pascal unit
  15. #include <Controls.hpp>    // Pascal unit
  16. #include <Graphics.hpp>    // Pascal unit
  17. #include <Classes.hpp>    // Pascal unit
  18. #include <SysUtils.hpp>    // Pascal unit
  19. #include <Messages.hpp>    // Pascal unit
  20. #include <Windows.hpp>    // Pascal unit
  21. #include <SysInit.hpp>    // Pascal unit
  22. #include <System.hpp>    // Pascal unit
  23.  
  24. //-- user supplied -----------------------------------------------------------
  25.  
  26. namespace Consoleio
  27. {
  28. //-- type declarations -------------------------------------------------------
  29. #pragma option push -b-
  30. enum TProcessState { psRunning, psTimeOut, psFinished };
  31. #pragma option pop
  32.  
  33. #pragma option push -b-
  34. enum TBufferSize { bs256, bs512, bs1k, bs2k, bs4k, bs8k };
  35. #pragma option pop
  36.  
  37. #pragma option push -b-
  38. enum TPipeSize { ps1k, ps2k, ps4k, ps8k, ps16k, ps32k, ps64k, ps96K, ps128k, ps256k };
  39. #pragma option pop
  40.  
  41. typedef unsigned TABufferSize[6];
  42.  
  43. typedef int TAPipeSize[10];
  44.  
  45. typedef Word TTimeOutDelay;
  46.  
  47. typedef char TBuffer[1];
  48.  
  49. typedef char *pTBuffer;
  50.  
  51. #pragma option push -b-
  52. enum TAppType { at16bit, at32bit, atDontCare };
  53. #pragma option pop
  54.  
  55. typedef void __fastcall (__closure *TStartEvent)(System::TObject* Sender, const AnsiString Command);
  56.     
  57.  
  58. typedef void __fastcall (__closure *TDoneEvent)(System::TObject* Sender);
  59.  
  60. typedef void __fastcall (__closure *TSendLine)(System::TObject* Sender, const AnsiString Line);
  61.  
  62. typedef void __fastcall (__closure *TError)(System::TObject* Sender, const AnsiString Error);
  63.  
  64. typedef void __fastcall (__closure *TTimeOut)(System::TObject* Sender, bool &Kill);
  65.  
  66. typedef void __fastcall (__closure *TPromptEvent)(System::TObject* Sender, const AnsiString Line);
  67.  
  68. typedef void __fastcall (__closure *TStatusEvent)(System::TObject* Sender, const AnsiString Status);
  69.     
  70.  
  71. typedef void __fastcall (__closure *TPreTerminateEvent)(System::TObject* Sender);
  72.  
  73. #pragma pack(push, 4)
  74. struct TConsoleProperties
  75. {
  76.     TTimeOutDelay FTimeOutDelay;
  77.     TPipeSize FPipeSize;
  78.     TBufferSize FBufferSize;
  79.     bool FAutoTerminate;
  80.     AnsiString FLogFile;
  81.     AnsiString FEnvironment;
  82.     AnsiString FApp;
  83.     TAppType FAppType;
  84.     AnsiString FCommand;
  85.     AnsiString FPrompt;
  86.     int FPromptLength;
  87.     AnsiString FHomeDir;
  88.     Classes::TThreadPriority FPriority;
  89. } ;
  90. #pragma pack(pop)
  91.  
  92. #pragma pack(push, 4)
  93. struct TConsoleEvents
  94. {
  95.     TStartEvent FStart;
  96.     TDoneEvent FDone;
  97.     TSendLine FSendLine;
  98.     TError FError;
  99.     TStatusEvent FStatus;
  100.     TTimeOut FTimeOut;
  101.     TAppType FAppType;
  102.     TPromptEvent FPromptEvent;
  103.     TPreTerminateEvent FPreTerminate;
  104. } ;
  105. #pragma pack(pop)
  106.  
  107. class DELPHICLASS TLogFile;
  108. #pragma pack(push, 4)
  109. class PASCALIMPLEMENTATION TLogFile : public Classes::TFileStream 
  110. {
  111.     typedef Classes::TFileStream inherited;
  112.     
  113. public:
  114.     void __fastcall WriteString(const AnsiString Str);
  115. public:
  116.     #pragma option push -w-inl
  117.     /* TFileStream.Create */ inline __fastcall TLogFile(const AnsiString FileName, Word Mode) : Classes::TFileStream(
  118.         FileName, Mode) { }
  119.     #pragma option pop
  120.     #pragma option push -w-inl
  121.     /* TFileStream.Destroy */ inline __fastcall virtual ~TLogFile(void) { }
  122.     #pragma option pop
  123.     
  124. };
  125.  
  126. #pragma pack(pop)
  127.  
  128. class DELPHICLASS TLineStream;
  129. #pragma pack(push, 4)
  130. class PASCALIMPLEMENTATION TLineStream : public Classes::TMemoryStream 
  131. {
  132.     typedef Classes::TMemoryStream inherited;
  133.     
  134. protected:
  135.     char __fastcall GetChar(int Index);
  136.     void __fastcall SetChar(int Index, char C);
  137.     
  138. public:
  139.     __property char Chr[int Index] = {read=GetChar, write=SetChar};
  140. public:
  141.     #pragma option push -w-inl
  142.     /* TMemoryStream.Destroy */ inline __fastcall virtual ~TLineStream(void) { }
  143.     #pragma option pop
  144.     
  145. public:
  146.     #pragma option push -w-inl
  147.     /* TObject.Create */ inline __fastcall TLineStream(void) : Classes::TMemoryStream() { }
  148.     #pragma option pop
  149.     
  150. };
  151.  
  152. #pragma pack(pop)
  153.  
  154. class DELPHICLASS TConsoleThread;
  155. class DELPHICLASS TGUI2Console;
  156. #pragma pack(push, 4)
  157. class PASCALIMPLEMENTATION TConsoleThread : public Classes::TThread 
  158. {
  159.     typedef Classes::TThread inherited;
  160.     
  161. private:
  162.     TConsoleProperties FCP;
  163.     TConsoleEvents FCE;
  164.     System::TObject* FCO;
  165.     bool FAtPrompt;
  166.     unsigned hInputRead;
  167.     unsigned hInputWrite;
  168.     unsigned hOutputRead;
  169.     unsigned hOutputWrite;
  170.     _PROCESS_INFORMATION pi;
  171.     TLineStream* FStream;
  172.     Classes::TStringList* List;
  173.     AnsiString FLine;
  174.     _SECURITY_DESCRIPTOR sd;
  175.     _SECURITY_ATTRIBUTES sa;
  176.     _SECURITY_ATTRIBUTES *lpsa;
  177.     _STARTUPINFOA si;
  178.     int Timer;
  179.     char *FBuffer;
  180.     unsigned Flag;
  181.     TLogFile* FLogFile;
  182.     bool FFreed;
  183.     unsigned __fastcall WaitForSingleObject(unsigned Handle);
  184.     void __fastcall CheckSecurity(void);
  185.     void __fastcall CreateProcess(void);
  186.     void __fastcall CloseHandles(void);
  187.     void __fastcall RunPipe(void);
  188.     void __fastcall TerminateProcess(const AnsiString Msg);
  189.     
  190. protected:
  191.     AnsiString Message;
  192.     void __fastcall DoStart(void);
  193.     void __fastcall DoDone(void);
  194.     void __fastcall DoPreTerminate(void);
  195.     void __fastcall SendLine(void);
  196.     void __fastcall DoError(void);
  197.     void __fastcall DoTimeOut(void);
  198.     void __fastcall DoStatus(void);
  199.     void __fastcall DoPrompt(void);
  200.     void __fastcall WriteBuffer(int Count);
  201.     AnsiString __fastcall Cmd(void);
  202.     
  203. public:
  204.     __fastcall TConsoleThread(TGUI2Console* Console);
  205.     virtual void __fastcall Execute(void);
  206.     __fastcall virtual ~TConsoleThread(void);
  207. public:
  208.     #pragma option push -w-inl
  209.     /* TThread.Create */ inline __fastcall TConsoleThread(bool CreateSuspended) : Classes::TThread(CreateSuspended
  210.         ) { }
  211.     #pragma option pop
  212.     
  213. };
  214.  
  215. #pragma pack(pop)
  216.  
  217. #pragma pack(push, 4)
  218. class PASCALIMPLEMENTATION TGUI2Console : public Classes::TComponent 
  219. {
  220.     typedef Classes::TComponent inherited;
  221.     
  222. private:
  223.     TConsoleProperties FCP;
  224.     TConsoleEvents FCE;
  225.     TConsoleThread* FConsoleThread;
  226.     void __fastcall Terminate(System::TObject* Sender);
  227.     void __fastcall SetPrompt(AnsiString P);
  228.     
  229. public:
  230.     void __fastcall Start(void);
  231.     __fastcall virtual TGUI2Console(Classes::TComponent* AOwner);
  232.     __fastcall virtual ~TGUI2Console(void);
  233.     void __fastcall Stop(void);
  234.     void __fastcall Write(AnsiString Buffer);
  235.     void __fastcall WriteLN(AnsiString Buffer);
  236.     
  237. __published:
  238.     __property AnsiString Application = {read=FCP.FApp, write=FCP.FApp};
  239.     __property TAppType AppType = {read=FCP.FAppType, write=FCP.FAppType, nodefault};
  240.     __property AnsiString Environment = {read=FCP.FEnvironment, write=FCP.FEnvironment};
  241.     __property AnsiString Command = {read=FCP.FCommand, write=FCP.FCommand};
  242.     __property AnsiString HomeDirectory = {read=FCP.FHomeDir, write=FCP.FHomeDir};
  243.     __property AnsiString LogFile = {read=FCP.FLogFile, write=FCP.FLogFile};
  244.     __property AnsiString Prompt = {read=FCP.FPrompt, write=SetPrompt};
  245.     __property bool AutoTerminate = {read=FCP.FAutoTerminate, write=FCP.FAutoTerminate, nodefault};
  246.     __property TPipeSize PipeSize = {read=FCP.FPipeSize, write=FCP.FPipeSize, nodefault};
  247.     __property TBufferSize BufferSize = {read=FCP.FBufferSize, write=FCP.FBufferSize, nodefault};
  248.     __property TTimeOutDelay TimeOutDelay = {read=FCP.FTimeOutDelay, write=FCP.FTimeOutDelay, nodefault
  249.         };
  250.     __property Classes::TThreadPriority Priority = {read=FCP.FPriority, write=FCP.FPriority, nodefault}
  251.         ;
  252.     __property TStartEvent OnStart = {read=FCE.FStart, write=FCE.FStart};
  253.     __property TDoneEvent OnDone = {read=FCE.FDone, write=FCE.FDone};
  254.     __property TSendLine OnLine = {read=FCE.FSendLine, write=FCE.FSendLine};
  255.     __property TError OnError = {read=FCE.FError, write=FCE.FError};
  256.     __property TTimeOut OnTimeOut = {read=FCE.FTimeOut, write=FCE.FTimeOut};
  257.     __property TStatusEvent OnStatus = {read=FCE.FStatus, write=FCE.FStatus};
  258.     __property TPromptEvent OnPrompt = {read=FCE.FPromptEvent, write=FCE.FPromptEvent};
  259.     __property TPreTerminateEvent OnPreTerminate = {read=FCE.FPreTerminate, write=FCE.FPreTerminate};
  260. };
  261.  
  262. #pragma pack(pop)
  263.  
  264. //-- var, const, procedure ---------------------------------------------------
  265. static const char CR = '\xd';
  266. static const char LF = '\xa';
  267. static const char Space = '\x20';
  268. #define CRLF "\r\n"
  269. extern PACKAGE void __fastcall Register(void);
  270.  
  271. }    /* namespace Consoleio */
  272. #if !defined(NO_IMPLICIT_NAMESPACE_USE)
  273. using namespace Consoleio;
  274. #endif
  275. #pragma option pop    // -w-
  276.  
  277. #pragma delphiheader end.
  278. //-- end unit ----------------------------------------------------------------
  279. #endif    // ConsoleIO
  280.