PTLib  Version 2.10.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
pipechan.h
Go to the documentation of this file.
1 /*
2  * pipechan.h
3  *
4  * Sub-process with communications using pipe I/O channel class.
5  *
6  * Portable Windows Library
7  *
8  * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Portable Windows Library.
21  *
22  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23  *
24  * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
25  * All Rights Reserved.
26  *
27  * Contributor(s): ______________________________________.
28  *
29  * $Revision: 24177 $
30  * $Author: rjongbloed $
31  * $Date: 2010-04-05 06:52:04 -0500 (Mon, 05 Apr 2010) $
32  */
33 
34 #ifndef PTLIB_PIPECHANNEL_H
35 #define PTLIB_PIPECHANNEL_H
36 
37 #ifdef P_USE_PRAGMA
38 #pragma interface
39 #endif
40 
41 #include <ptlib/channel.h>
42 
43 
70 class PChannel;
71 
72 
73 class PPipeChannel : public PChannel
74 {
75  PCLASSINFO(PPipeChannel, PChannel);
76 
77  public:
80 
81  enum OpenMode {
92  };
93 
96  PPipeChannel();
102  PPipeChannel(
103  const PString & subProgram,
104  OpenMode mode = ReadWrite,
105  PBoolean searchPath = true,
106  PBoolean stderrSeparate = false
107  );
113  PPipeChannel(
114  const PString & subProgram,
115  const PStringArray & argumentList,
116  OpenMode mode = ReadWrite,
117  PBoolean searchPath = true,
118  PBoolean stderrSeparate = false
119  );
125  PPipeChannel(
126  const PString & subProgram,
127  const PStringToString & environment,
128  OpenMode mode = ReadWrite,
129  PBoolean searchPath = true,
130  PBoolean stderrSeparate = false
131  );
137  PPipeChannel(
138  const PString & subProgram,
139  const PStringArray & argumentList,
140  const PStringToString & environment,
141  OpenMode mode = ReadWrite,
142  PBoolean searchPath = true,
143  PBoolean stderrSeparate = false
144  );
145 
147  ~PPipeChannel();
149 
160  const PObject & obj
161  ) const;
163 
164 
172  virtual PString GetName() const;
173 
190  virtual PBoolean Read(
191  void * buf,
192  PINDEX len
193  );
194 
209  virtual PBoolean Write(
210  const void * buf,
211  PINDEX len
212  );
213 
222  virtual PBoolean Close();
224 
228  PBoolean Open(
229  const PString & subProgram,
230  OpenMode mode = ReadWrite,
231  PBoolean searchPath = true,
232  PBoolean stderrSeparate = false
233  );
235  PBoolean Open(
236  const PString & subProgram,
237  const PStringArray & argumentList,
238  OpenMode mode = ReadWrite,
239  PBoolean searchPath = true,
240  PBoolean stderrSeparate = false
241  );
243  PBoolean Open(
244  const PString & subProgram,
245  const PStringToString & environment,
246  OpenMode mode = ReadWrite,
247  PBoolean searchPath = true,
248  PBoolean stderrSeparate = false
249  );
287  PBoolean Open(
288  const PString & subProgram,
289  const PStringArray & argumentList,
290  const PStringToString & environment,
291  OpenMode mode = ReadWrite,
292  PBoolean searchPath = true,
293  PBoolean stderrSeparate = false
294  );
295 
301  const PFilePath & GetSubProgram() const;
302 
316  PBoolean Execute();
317 
326  PBoolean IsRunning() const;
327 
335  int GetReturnCode() const;
336 
342  int WaitForTermination();
343 
350  int WaitForTermination(
351  const PTimeInterval & timeout
352  );
353 
361  PBoolean Kill(
362  int signal = 9
363  );
364 
375  PString & errors,
376  PBoolean wait = false
377  );
378 
385  static PBoolean CanReadAndWrite();
387 
388 
389  protected:
390  // Member variables
393 
394 
395  private:
396  PBoolean PlatformOpen(const PString & subProgram,
397  const PStringArray & arguments,
398  OpenMode mode,
399  PBoolean searchPath,
400  PBoolean stderrSeparate,
401  const PStringToString * environment);
402 
403 
404 // Include platform dependent part of class
405 #ifdef _WIN32
406 #include "msos/ptlib/pipechan.h"
407 #else
408 #include "unix/ptlib/pipechan.h"
409 #endif
410 };
411 
412 
413 #endif // PTLIB_PIPECHANNEL_H
414 
415 
416 // End Of File ///////////////////////////////////////////////////////////////