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: 22509 $
00030  * $Author: rjongbloed $
00031  * $Date: 2009-05-04 20:55:17 -0500 (Mon, 04 May 2009) $
00032  */
00033 
00034 #ifndef PTLIB_PIPECHANNEL_H
00035 #define PTLIB_PIPECHANNEL_H
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 
00335     int GetReturnCode() const;
00336 
00342     int WaitForTermination();
00343     
00350     int WaitForTermination(
00351       const PTimeInterval & timeout  
00352     );
00353 
00361     PBoolean Kill(
00362       int signal = 9  
00363     );
00364 
00374     PBoolean ReadStandardError(
00375       PString & errors,   
00376       PBoolean wait = PFalse   
00377     );
00378 
00385     static PBoolean CanReadAndWrite();
00387 
00388 
00389   protected:
00390     // Member variables
00392     PFilePath subProgName;
00393 
00394 
00395   private:
00396     PBoolean PlatformOpen(const PString & subProgram,
00397                       const PStringArray & arguments,
00398                       OpenMode mode,
00399                       PBoolean searchPath,
00400                       PBoolean stderrSeparate,
00401                       const PStringToString * environment);
00402 
00403 
00404 // Include platform dependent part of class
00405 #ifdef _WIN32
00406 #include "msos/ptlib/pipechan.h"
00407 #else
00408 #include "unix/ptlib/pipechan.h"
00409 #endif
00410 };
00411 
00412 
00413 #endif // PTLIB_PIPECHANNEL_H
00414 
00415 
00416 // End Of File ///////////////////////////////////////////////////////////////

Generated on Thu May 27 01:36:48 2010 for PTLib by  doxygen 1.4.7