2094
|
1 /* |
|
2 |
11523
|
3 Copyright (C) 1996-2011 John W. Eaton |
2094
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
7016
|
9 Free Software Foundation; either version 3 of the License, or (at your |
|
10 option) any later version. |
2094
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
7016
|
18 along with Octave; see the file COPYING. If not, see |
|
19 <http://www.gnu.org/licenses/>. |
2094
|
20 |
|
21 */ |
|
22 |
|
23 // This class is based on the procbuf class from libg++, written by |
|
24 // Per Bothner, Copyright (C) 1993 Free Software Foundation. |
|
25 |
|
26 #if !defined (octave_octave_procbuf_h) |
|
27 #define octave_octave_procbuf_h 1 |
|
28 |
|
29 #include <sys/types.h> |
|
30 |
3631
|
31 #include "c-file-ptr-stream.h" |
|
32 |
2094
|
33 class |
3631
|
34 octave_procbuf : public c_file_ptr_buf |
2094
|
35 { |
|
36 public: |
|
37 |
|
38 octave_procbuf (void) |
3631
|
39 : c_file_ptr_buf (0), wstatus (-1), open_p (false), proc_pid (-1), |
|
40 next (0) { } |
2094
|
41 |
|
42 octave_procbuf (const char *command, int mode) |
3631
|
43 : c_file_ptr_buf (0), wstatus (-1), open_p (false), proc_pid (-1), |
|
44 next (0) { open (command, mode); } |
2094
|
45 |
|
46 ~octave_procbuf (void) { close (); } |
|
47 |
|
48 octave_procbuf *open (const char *command, int mode); |
|
49 |
3631
|
50 octave_procbuf *close (void); |
2094
|
51 |
3189
|
52 int wait_status (void) const { return wstatus; } |
|
53 |
3631
|
54 bool is_open (void) const { return open_p; } |
|
55 |
6316
|
56 pid_t pid (void) const { return proc_pid; } |
2094
|
57 |
|
58 protected: |
|
59 |
3189
|
60 int wstatus; |
|
61 |
3631
|
62 bool open_p; |
|
63 |
2094
|
64 pid_t proc_pid; |
|
65 |
|
66 octave_procbuf *next; |
|
67 }; |
|
68 |
3174
|
69 extern void symbols_of_oct_procbuf (void); |
|
70 |
2094
|
71 #endif |