Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

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 * $Log: pipechan.h,v $ 00030 * Revision 1.22 2003/09/17 05:41:59 csoutheren 00031 * Removed recursive includes 00032 * 00033 * Revision 1.21 2003/09/17 01:18:02 csoutheren 00034 * Removed recursive include file system and removed all references 00035 * to deprecated coooperative threading support 00036 * 00037 * Revision 1.20 2002/09/16 01:08:59 robertj 00038 * Added #define so can select if #pragma interface/implementation is used on 00039 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan. 00040 * 00041 * Revision 1.19 2001/05/22 12:49:32 robertj 00042 * Did some seriously wierd rewrite of platform headers to eliminate the 00043 * stupid GNU compiler warning about braces not matching. 00044 * 00045 * Revision 1.18 1999/03/09 02:59:50 robertj 00046 * Changed comments to doc++ compatible documentation. 00047 * 00048 * Revision 1.17 1999/02/16 08:11:09 robertj 00049 * MSVC 6.0 compatibility changes. 00050 * 00051 * Revision 1.16 1998/11/02 10:06:39 robertj 00052 * Added capability of pip output to go to stdout/stderr. 00053 * 00054 * Revision 1.15 1998/10/30 10:42:29 robertj 00055 * Better function arrangement for multi platforming. 00056 * 00057 * Revision 1.14 1998/10/29 11:29:17 robertj 00058 * Added ability to set environment in sub-process. 00059 * 00060 * Revision 1.13 1998/10/26 09:11:05 robertj 00061 * Added ability to separate out stdout from stderr on pipe channels. 00062 * 00063 * Revision 1.12 1998/09/23 06:21:08 robertj 00064 * Added open source copyright license. 00065 * 00066 * Revision 1.11 1997/01/03 05:25:05 robertj 00067 * Added Wait and Kill functions. 00068 * 00069 * Revision 1.10 1996/03/31 08:50:51 robertj 00070 * Changed string list to array. 00071 * Added function to idicate if sub-process is running. 00072 * 00073 * Revision 1.9 1995/07/31 12:15:45 robertj 00074 * Removed PContainer from PChannel ancestor. 00075 * 00076 * Revision 1.8 1995/06/17 11:12:53 robertj 00077 * Documentation update. 00078 * 00079 * Revision 1.7 1995/03/14 12:42:02 robertj 00080 * Updated documentation to use HTML codes. 00081 * 00082 * Revision 1.6 1995/01/09 12:39:01 robertj 00083 * Documentation. 00084 * 00085 * Revision 1.5 1994/10/23 04:50:55 robertj 00086 * Further refinement of semantics after implementation. 00087 * 00088 * Revision 1.4 1994/09/25 10:43:19 robertj 00089 * Added more implementation. 00090 * 00091 * Revision 1.3 1994/08/23 11:32:52 robertj 00092 * Oops 00093 * 00094 * Revision 1.2 1994/08/22 00:46:48 robertj 00095 * Added pragma fro GNU C++ compiler. 00096 * 00097 * Revision 1.1 1994/04/20 12:17:44 robertj 00098 * Initial revision 00099 * 00100 */ 00101 00102 #ifndef _PPIPECHANNEL 00103 #define _PPIPECHANNEL 00104 00105 #ifdef P_USE_PRAGMA 00106 #pragma interface 00107 #endif 00108 00109 00135 class PPipeChannel : public PChannel 00136 { 00137 PCLASSINFO(PPipeChannel, PChannel); 00138 00139 public: 00142 00143 enum OpenMode { 00145 ReadOnly, 00147 WriteOnly, 00149 ReadWrite, 00152 ReadWriteStd 00153 }; 00154 00157 PPipeChannel(); 00163 PPipeChannel( 00164 const PString & subProgram, 00165 OpenMode mode = ReadWrite, 00166 BOOL searchPath = TRUE, 00167 BOOL stderrSeparate = FALSE 00168 ); 00174 PPipeChannel( 00175 const PString & subProgram, 00176 const PStringArray & argumentList, 00177 OpenMode mode = ReadWrite, 00178 BOOL searchPath = TRUE, 00179 BOOL stderrSeparate = FALSE 00180 ); 00186 PPipeChannel( 00187 const PString & subProgram, 00188 const PStringToString & environment, 00189 OpenMode mode = ReadWrite, 00190 BOOL searchPath = TRUE, 00191 BOOL stderrSeparate = FALSE 00192 ); 00198 PPipeChannel( 00199 const PString & subProgram, 00200 const PStringArray & argumentList, 00201 const PStringToString & environment, 00202 OpenMode mode = ReadWrite, 00203 BOOL searchPath = TRUE, 00204 BOOL stderrSeparate = FALSE 00205 ); 00206 00208 ~PPipeChannel(); 00210 00220 Comparison Compare( 00221 const PObject & obj 00222 ) const; 00224 00225 00233 virtual PString GetName() const; 00234 00251 virtual BOOL Read( 00252 void * buf, 00253 PINDEX len 00254 ); 00255 00270 virtual BOOL Write( 00271 const void * buf, 00272 PINDEX len 00273 ); 00274 00283 virtual BOOL Close(); 00285 00289 BOOL Open( 00290 const PString & subProgram, 00291 OpenMode mode = ReadWrite, 00292 BOOL searchPath = TRUE, 00293 BOOL stderrSeparate = FALSE 00294 ); 00296 BOOL Open( 00297 const PString & subProgram, 00298 const PStringArray & argumentList, 00299 OpenMode mode = ReadWrite, 00300 BOOL searchPath = TRUE, 00301 BOOL stderrSeparate = FALSE 00302 ); 00304 BOOL Open( 00305 const PString & subProgram, 00306 const PStringToString & environment, 00307 OpenMode mode = ReadWrite, 00308 BOOL searchPath = TRUE, 00309 BOOL stderrSeparate = FALSE 00310 ); 00348 BOOL Open( 00349 const PString & subProgram, 00350 const PStringArray & argumentList, 00351 const PStringToString & environment, 00352 OpenMode mode = ReadWrite, 00353 BOOL searchPath = TRUE, 00354 BOOL stderrSeparate = FALSE 00355 ); 00356 00362 const PFilePath & GetSubProgram() const; 00363 00377 BOOL Execute(); 00378 00387 BOOL IsRunning() const; 00388 00394 int GetReturnCode() const; 00395 00401 int WaitForTermination(); 00402 00409 int WaitForTermination( 00410 const PTimeInterval & timeout 00411 ); 00412 00420 BOOL Kill( 00421 int signal = 9 00422 ); 00423 00433 BOOL ReadStandardError( 00434 PString & errors, 00435 BOOL wait = FALSE 00436 ); 00437 00444 static BOOL CanReadAndWrite(); 00446 00447 00448 protected: 00449 // Member variables 00451 PFilePath subProgName; 00452 00453 00454 private: 00455 BOOL PlatformOpen(const PString & subProgram, 00456 const PStringArray & arguments, 00457 OpenMode mode, 00458 BOOL searchPath, 00459 BOOL stderrSeparate, 00460 const PStringToString * environment); 00461 00462 00463 // Include platform dependent part of class 00464 #ifdef _WIN32 00465 #include "msos/ptlib/pipechan.h" 00466 #else 00467 #include "unix/ptlib/pipechan.h" 00468 #endif 00469 }; 00470 00471 #endif 00472 00473 // End Of File ///////////////////////////////////////////////////////////////

Generated on Sat Jul 24 15:35:56 2004 for PWLib by doxygen 1.3.7