pipechan.h

Go to the documentation of this file.
00001 /*
00002  * pipechan.h
00003  *
00004  * Sub-process with communications using pipe I/O channel class.
00005  *
00006  * Portable Windows Library
00007  *
00008  * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
00009  *
00010  * The contents of this file are subject to the Mozilla Public License
00011  * Version 1.0 (the "License"); you may not use this file except in
00012  * compliance with the License. You may obtain a copy of the License at
00013  * http://www.mozilla.org/MPL/
00014  *
00015  * Software distributed under the License is distributed on an "AS IS"
00016  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00017  * the License for the specific language governing rights and limitations
00018  * under the License.
00019  *
00020  * The Original Code is Portable Windows Library.
00021  *
00022  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
00023  *
00024  * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
00025  * All Rights Reserved.
00026  *
00027  * Contributor(s): ______________________________________.
00028  *
00029  * $Revision: 19008 $
00030  * $Author: rjongbloed $
00031  * $Date: 2007-11-29 09:17:41 +0000 (Thu, 29 Nov 2007) $
00032  */
00033 
00034 #ifndef _PPIPECHANNEL
00035 #define _PPIPECHANNEL
00036 
00037 #ifdef P_USE_PRAGMA
00038 #pragma interface
00039 #endif
00040 
00041 #include <ptlib/channel.h>
00042 
00043 
00070 class PChannel;
00071 
00072 
00073 class PPipeChannel : public PChannel
00074 {
00075   PCLASSINFO(PPipeChannel, PChannel);
00076 
00077   public:
00080 
00081     enum OpenMode {
00083       ReadOnly,   
00085       WriteOnly,  
00087       ReadWrite,  
00090       ReadWriteStd
00091     };
00092 
00095     PPipeChannel();
00101     PPipeChannel(
00102       const PString & subProgram,  
00103       OpenMode mode = ReadWrite,   
00104       PBoolean searchPath = PTrue,      
00105       PBoolean stderrSeparate = PFalse  
00106     );
00112     PPipeChannel(
00113       const PString & subProgram,  
00114       const PStringArray & argumentList, 
00115       OpenMode mode = ReadWrite,   
00116       PBoolean searchPath = PTrue,      
00117       PBoolean stderrSeparate = PFalse  
00118     );
00124     PPipeChannel(
00125       const PString & subProgram,  
00126       const PStringToString & environment, 
00127       OpenMode mode = ReadWrite,   
00128       PBoolean searchPath = PTrue,      
00129       PBoolean stderrSeparate = PFalse  
00130     );
00136     PPipeChannel(
00137       const PString & subProgram,  
00138       const PStringArray & argumentList, 
00139       const PStringToString & environment, 
00140       OpenMode mode = ReadWrite,   
00141       PBoolean searchPath = PTrue,      
00142       PBoolean stderrSeparate = PFalse  
00143     );
00144 
00146     ~PPipeChannel();
00148 
00158     Comparison Compare(
00159       const PObject & obj   
00160     ) const;
00162 
00163 
00171     virtual PString GetName() const;
00172 
00189     virtual PBoolean Read(
00190       void * buf,   
00191       PINDEX len    
00192     );
00193 
00208     virtual PBoolean Write(
00209       const void * buf, 
00210       PINDEX len        
00211     );
00212 
00221     virtual PBoolean Close();
00223 
00227     PBoolean Open(
00228       const PString & subProgram,  
00229       OpenMode mode = ReadWrite,   
00230       PBoolean searchPath = PTrue,      
00231       PBoolean stderrSeparate = PFalse  
00232     );
00234     PBoolean Open(
00235       const PString & subProgram,  
00236       const PStringArray & argumentList, 
00237       OpenMode mode = ReadWrite,   
00238       PBoolean searchPath = PTrue,      
00239       PBoolean stderrSeparate = PFalse  
00240     );
00242     PBoolean Open(
00243       const PString & subProgram,  
00244       const PStringToString & environment, 
00245       OpenMode mode = ReadWrite,   
00246       PBoolean searchPath = PTrue,      
00247       PBoolean stderrSeparate = PFalse  
00248     );
00286     PBoolean Open(
00287       const PString & subProgram,  
00288       const PStringArray & argumentList, 
00289       const PStringToString & environment, 
00290       OpenMode mode = ReadWrite,   
00291       PBoolean searchPath = PTrue,      
00292       PBoolean stderrSeparate = PFalse  
00293     );
00294 
00300     const PFilePath & GetSubProgram() const;
00301 
00315     PBoolean Execute();
00316 
00325     PBoolean IsRunning() const;
00326 
00332     int GetReturnCode() const;
00333 
00339     int WaitForTermination();
00340     
00347     int WaitForTermination(
00348       const PTimeInterval & timeout  
00349     );
00350 
00358     PBoolean Kill(
00359       int signal = 9  
00360     );
00361 
00371     PBoolean ReadStandardError(
00372       PString & errors,   
00373       PBoolean wait = PFalse   
00374     );
00375 
00382     static PBoolean CanReadAndWrite();
00384 
00385 
00386   protected:
00387     // Member variables
00389     PFilePath subProgName;
00390 
00391 
00392   private:
00393     PBoolean PlatformOpen(const PString & subProgram,
00394                       const PStringArray & arguments,
00395                       OpenMode mode,
00396                       PBoolean searchPath,
00397                       PBoolean stderrSeparate,
00398                       const PStringToString * environment);
00399 
00400 
00401 // Include platform dependent part of class
00402 #ifdef _WIN32
00403 #include "msos/ptlib/pipechan.h"
00404 #else
00405 #include "unix/ptlib/pipechan.h"
00406 #endif
00407 };
00408 
00409 #endif
00410 
00411 // End Of File ///////////////////////////////////////////////////////////////

Generated on Mon Dec 10 11:18:57 2007 for PTLib by  doxygen 1.5.1