home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ool_main.zip / ool / include / xpipe.h < prev    next >
C/C++ Source or Header  |  1997-09-01  |  2KB  |  46 lines

  1. #ifndef __OOL_XPIPE_H__
  2. #define __OOL_XPIPE_H__
  3.  
  4. /*===========================================================================*/
  5. /* OOL ------------------- the Open Object Library ------------------- r 1.0 */
  6. /*===========================================================================*/
  7. /*                              class: XPipe                                 */
  8. /*                       derived from: XIO                                   */
  9. /*                        last update: 9/96                                  */
  10. /*                      programmed by: Stefan von Brauk (sbrauk@gwdg.de)     */
  11. /*===========================================================================*/
  12.  
  13. #include "xio.h"
  14.  
  15. #ifdef OOL_FOR_OS2_X86
  16.    #define XPIPE_DEFAULTSIZE            4096
  17.    #define XPIPE_STDIN           0x00000000
  18.    #define XPIPE_STDOUT          0x00000001
  19.    #define XPIPE_STDERROR        0x00000002
  20. #endif
  21.  
  22.  
  23. class _export_ XPipe: public XIO
  24. {
  25.    private:
  26. public:
  27.       HFILE handle2;
  28.    public:
  29.       XPipe() { handle2 = -1;}
  30.       ~XPipe() { if(handle2 != -1) Close(); }
  31.       void Close();
  32.       static void CloseHandle( HFILE h ) { DosClose( h );}
  33.       static ULONG DuplicateHandle( const ULONG h1, ULONG& h2);
  34.       LONG Open( const LONG size = XPIPE_DEFAULTSIZE );
  35.       LONG GetReadHandle(void) const { return handle; }
  36.       LONG GetWriteHandle(void) const { return handle2; }
  37.       ULONG _Write( const void * buffer, const ULONG sizeofbuffer) const
  38.          {
  39.             ULONG r;
  40.             DosWrite(handle2, (PVOID) buffer, sizeofbuffer, &r);
  41.             return r;
  42.          }
  43. };
  44.  
  45. #endif
  46.