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 |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
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 |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
1
|
21 |
|
22 */ |
|
23 |
240
|
24 #ifdef HAVE_CONFIG_H |
1192
|
25 #include <config.h> |
1
|
26 #endif |
|
27 |
|
28 #include "procstream.h" |
|
29 |
4051
|
30 procstreambase::procstreambase (const std::string& command, int mode) |
|
31 { |
|
32 pb_init (); |
|
33 |
|
34 if (! pb.open (command.c_str (), mode)) |
|
35 std::ios::setstate (std::ios::badbit); |
|
36 } |
|
37 |
1965
|
38 procstreambase::procstreambase (const char *command, int mode) |
1
|
39 { |
1965
|
40 pb_init (); |
1380
|
41 |
1965
|
42 if (! pb.open (command, mode)) |
3563
|
43 std::ios::setstate (std::ios::badbit); |
1
|
44 } |
|
45 |
|
46 void |
1965
|
47 procstreambase::open (const char *command, int mode) |
1
|
48 { |
|
49 clear (); |
1380
|
50 |
1965
|
51 if (! pb.open (command, mode)) |
3563
|
52 std::ios::setstate (std::ios::badbit); |
1
|
53 } |
|
54 |
483
|
55 int |
1965
|
56 procstreambase::close (void) |
1380
|
57 { |
|
58 int status = 0; |
|
59 |
|
60 if (is_open ()) |
|
61 { |
1965
|
62 if (! pb.close ()) |
3563
|
63 std::ios::setstate (std::ios::failbit); |
3189
|
64 |
|
65 status = pb.wait_status (); |
1380
|
66 } |
|
67 |
|
68 return status; |
|
69 } |
|
70 |
1
|
71 /* |
|
72 ;;; Local Variables: *** |
|
73 ;;; mode: C++ *** |
|
74 ;;; End: *** |
|
75 */ |