1
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
1
|
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. |
1
|
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/>. |
1
|
20 |
|
21 */ |
|
22 |
240
|
23 #ifdef HAVE_CONFIG_H |
1192
|
24 #include <config.h> |
1
|
25 #endif |
|
26 |
|
27 #include "procstream.h" |
|
28 |
4051
|
29 procstreambase::procstreambase (const std::string& command, int mode) |
|
30 { |
|
31 pb_init (); |
|
32 |
|
33 if (! pb.open (command.c_str (), mode)) |
|
34 std::ios::setstate (std::ios::badbit); |
|
35 } |
|
36 |
1965
|
37 procstreambase::procstreambase (const char *command, int mode) |
1
|
38 { |
1965
|
39 pb_init (); |
1380
|
40 |
1965
|
41 if (! pb.open (command, mode)) |
3563
|
42 std::ios::setstate (std::ios::badbit); |
1
|
43 } |
|
44 |
|
45 void |
1965
|
46 procstreambase::open (const char *command, int mode) |
1
|
47 { |
|
48 clear (); |
1380
|
49 |
1965
|
50 if (! pb.open (command, mode)) |
3563
|
51 std::ios::setstate (std::ios::badbit); |
1
|
52 } |
|
53 |
483
|
54 int |
1965
|
55 procstreambase::close (void) |
1380
|
56 { |
|
57 int status = 0; |
|
58 |
|
59 if (is_open ()) |
|
60 { |
1965
|
61 if (! pb.close ()) |
3563
|
62 std::ios::setstate (std::ios::failbit); |
3189
|
63 |
|
64 status = pb.wait_status (); |
1380
|
65 } |
|
66 |
|
67 return status; |
|
68 } |
|
69 |
1
|
70 /* |
|
71 ;;; Local Variables: *** |
|
72 ;;; mode: C++ *** |
|
73 ;;; End: *** |
|
74 */ |