Mercurial > hg > octave-nkf
annotate src/procstream.cc @ 13254:46f5e41c8610 stable
Fix version numbers in NEWS
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Thu, 29 Sep 2011 17:03:35 -0500 |
parents | fd0a3ac60b0e |
children | 72c96de7a403 |
rev | line source |
---|---|
1 | 1 /* |
2 | |
11523 | 3 Copyright (C) 1993-2011 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 | |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
27 #include <iostream> |
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
28 |
1 | 29 #include "procstream.h" |
30 | |
4051 | 31 procstreambase::procstreambase (const std::string& command, int mode) |
32 { | |
33 pb_init (); | |
34 | |
35 if (! pb.open (command.c_str (), mode)) | |
36 std::ios::setstate (std::ios::badbit); | |
37 } | |
38 | |
1965 | 39 procstreambase::procstreambase (const char *command, int mode) |
1 | 40 { |
1965 | 41 pb_init (); |
1380 | 42 |
1965 | 43 if (! pb.open (command, mode)) |
3563 | 44 std::ios::setstate (std::ios::badbit); |
1 | 45 } |
46 | |
47 void | |
1965 | 48 procstreambase::open (const char *command, int mode) |
1 | 49 { |
50 clear (); | |
1380 | 51 |
1965 | 52 if (! pb.open (command, mode)) |
3563 | 53 std::ios::setstate (std::ios::badbit); |
1 | 54 } |
55 | |
483 | 56 int |
1965 | 57 procstreambase::close (void) |
1380 | 58 { |
59 int status = 0; | |
60 | |
61 if (is_open ()) | |
62 { | |
1965 | 63 if (! pb.close ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
64 std::ios::setstate (std::ios::failbit); |
3189 | 65 |
66 status = pb.wait_status (); | |
1380 | 67 } |
68 | |
69 return status; | |
70 } |