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 |
1315
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
1
|
20 |
|
21 */ |
|
22 |
4192
|
23 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
1297
|
24 #pragma implementation |
|
25 #endif |
|
26 |
240
|
27 #ifdef HAVE_CONFIG_H |
1192
|
28 #include <config.h> |
1
|
29 #endif |
|
30 |
|
31 #include "procstream.h" |
|
32 |
4051
|
33 procstreambase::procstreambase (const std::string& command, int mode) |
|
34 { |
|
35 pb_init (); |
|
36 |
|
37 if (! pb.open (command.c_str (), mode)) |
|
38 std::ios::setstate (std::ios::badbit); |
|
39 } |
|
40 |
1965
|
41 procstreambase::procstreambase (const char *command, int mode) |
1
|
42 { |
1965
|
43 pb_init (); |
1380
|
44 |
1965
|
45 if (! pb.open (command, mode)) |
3563
|
46 std::ios::setstate (std::ios::badbit); |
1
|
47 } |
|
48 |
|
49 void |
1965
|
50 procstreambase::open (const char *command, int mode) |
1
|
51 { |
|
52 clear (); |
1380
|
53 |
1965
|
54 if (! pb.open (command, mode)) |
3563
|
55 std::ios::setstate (std::ios::badbit); |
1
|
56 } |
|
57 |
483
|
58 int |
1965
|
59 procstreambase::close (void) |
1380
|
60 { |
|
61 int status = 0; |
|
62 |
|
63 if (is_open ()) |
|
64 { |
1965
|
65 if (! pb.close ()) |
3563
|
66 std::ios::setstate (std::ios::failbit); |
3189
|
67 |
|
68 status = pb.wait_status (); |
1380
|
69 } |
|
70 |
|
71 return status; |
|
72 } |
|
73 |
1
|
74 /* |
|
75 ;;; Local Variables: *** |
|
76 ;;; mode: C++ *** |
|
77 ;;; End: *** |
|
78 */ |