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: 20385 $
00030  * $Author: rjongbloed $
00031  * $Date: 2008-06-04 10:40:38 +0000 (Wed, 04 Jun 2008) $
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,  
00091       ReadWriteStd
00092     };
00093 
00096     PPipeChannel();
00102     PPipeChannel(
00103       const PString & subProgram,  
00104       OpenMode mode = ReadWrite,   
00105       PBoolean searchPath = PTrue,      
00106       PBoolean stderrSeparate = PFalse  
00107     );
00113     PPipeChannel(
00114       const PString & subProgram,  
00115       const PStringArray & argumentList, 
00116       OpenMode mode = ReadWrite,   
00117       PBoolean searchPath = PTrue,      
00118       PBoolean stderrSeparate = PFalse  
00119     );
00125     PPipeChannel(
00126       const PString & subProgram,  
00127       const PStringToString & environment, 
00128       OpenMode mode = ReadWrite,   
00129       PBoolean searchPath = PTrue,      
00130       PBoolean stderrSeparate = PFalse  
00131     );
00137     PPipeChannel(
00138       const PString & subProgram,  
00139       const PStringArray & argumentList, 
00140       const PStringToString & environment, 
00141       OpenMode mode = ReadWrite,   
00142       PBoolean searchPath = PTrue,      
00143       PBoolean stderrSeparate = PFalse  
00144     );
00145 
00147     ~PPipeChannel();
00149 
00159     Comparison Compare(
00160       const PObject & obj   
00161     ) const;
00163 
00164 
00172     virtual PString GetName() const;
00173 
00190     virtual PBoolean Read(
00191       void * buf,   
00192       PINDEX len    
00193     );
00194 
00209     virtual PBoolean Write(
00210       const void * buf, 
00211       PINDEX len        
00212     );
00213 
00222     virtual PBoolean Close();
00224 
00228     PBoolean Open(
00229       const PString & subProgram,  
00230       OpenMode mode = ReadWrite,   
00231       PBoolean searchPath = PTrue,      
00232       PBoolean stderrSeparate = PFalse  
00233     );
00235     PBoolean Open(
00236       const PString & subProgram,  
00237       const PStringArray & argumentList, 
00238       OpenMode mode = ReadWrite,   
00239       PBoolean searchPath = PTrue,      
00240       PBoolean stderrSeparate = PFalse  
00241     );
00243     PBoolean Open(
00244       const PString & subProgram,  
00245       const PStringToString & environment, 
00246       OpenMode mode = ReadWrite,   
00247       PBoolean searchPath = PTrue,      
00248       PBoolean stderrSeparate = PFalse  
00249     );
00287     PBoolean Open(
00288       const PString & subProgram,  
00289       const PStringArray & argumentList, 
00290       const PStringToString & environment, 
00291       OpenMode mode = ReadWrite,   
00292       PBoolean searchPath = PTrue,      
00293       PBoolean stderrSeparate = PFalse  
00294     );
00295 
00301     const PFilePath & GetSubProgram() const;
00302 
00316     PBoolean Execute();
00317 
00326     PBoolean IsRunning() const;
00327 
00333     int GetReturnCode() const;
00334 
00340     int WaitForTermination();
00341     
00348     int WaitForTermination(
00349       const PTimeInterval & timeout  
00350     );
00351 
00359     PBoolean Kill(
00360       int signal = 9  
00361     );
00362 
00372     PBoolean ReadStandardError(
00373       PString & errors,   
00374       PBoolean wait = PFalse   
00375     );
00376 
00383     static PBoolean CanReadAndWrite();
00385 
00386 
00387   protected:
00388     // Member variables
00390     PFilePath subProgName;
00391 
00392 
00393   private:
00394     PBoolean PlatformOpen(const PString & subProgram,
00395                       const PStringArray & arguments,
00396                       OpenMode mode,
00397                       PBoolean searchPath,
00398                       PBoolean stderrSeparate,
00399                       const PStringToString * environment);
00400 
00401 
00402 // Include platform dependent part of class
00403 #ifdef _WIN32
00404 #include "msos/ptlib/pipechan.h"
00405 #else
00406 #include "unix/ptlib/pipechan.h"
00407 #endif
00408 };
00409 
00410 #endif
00411 
00412 // End Of File ///////////////////////////////////////////////////////////////

Generated on Mon Feb 23 01:57:54 2009 for PTLib by  doxygen 1.5.1