1
|
1 // procstream.cc -*- C++ -*- |
|
2 /* |
|
3 |
1884
|
4 Copyright (C) 1996 John W. Eaton |
1
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
1315
|
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
1
|
21 |
|
22 */ |
|
23 |
1297
|
24 #if defined (__GNUG__) |
|
25 #pragma implementation |
|
26 #endif |
|
27 |
240
|
28 #ifdef HAVE_CONFIG_H |
1192
|
29 #include <config.h> |
1
|
30 #endif |
|
31 |
|
32 #include "procstream.h" |
|
33 |
1965
|
34 procstreambase::procstreambase (const char *command, int mode) |
1
|
35 { |
1965
|
36 pb_init (); |
1380
|
37 |
1965
|
38 if (! pb.open (command, mode)) |
1
|
39 set (ios::badbit); |
|
40 } |
|
41 |
|
42 void |
1965
|
43 procstreambase::open (const char *command, int mode) |
1
|
44 { |
|
45 clear (); |
1380
|
46 |
1965
|
47 if (! pb.open (command, mode)) |
1
|
48 set (ios::badbit); |
|
49 } |
|
50 |
483
|
51 int |
1965
|
52 procstreambase::close (void) |
1380
|
53 { |
|
54 int status = 0; |
|
55 |
|
56 if (is_open ()) |
|
57 { |
1965
|
58 status = pb.sys_close (); |
1380
|
59 |
1965
|
60 if (! pb.close ()) |
1380
|
61 set (ios::failbit); |
|
62 } |
|
63 |
|
64 return status; |
|
65 } |
|
66 |
1
|
67 /* |
|
68 ;;; Local Variables: *** |
|
69 ;;; mode: C++ *** |
|
70 ;;; page-delimiter: "^/\\*" *** |
|
71 ;;; End: *** |
|
72 */ |