Mercurial > hg > octave-nkf
annotate src/procstream.cc @ 10160:cd96d29c5efa
remove Emacs local-variable settings from source files in src directory
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 20 Jan 2010 20:39:26 -0500 |
parents | 16f53d29049f |
children | 57a59eae83cc |
rev | line source |
---|---|
1 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2002, 2004, |
9245 | 4 2005, 2007, 2009 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 | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
1 | 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 | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
1 | 21 |
22 */ | |
23 | |
240 | 24 #ifdef HAVE_CONFIG_H |
1192 | 25 #include <config.h> |
1 | 26 #endif |
27 | |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
28 #include <iostream> |
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
29 |
1 | 30 #include "procstream.h" |
31 | |
4051 | 32 procstreambase::procstreambase (const std::string& command, int mode) |
33 { | |
34 pb_init (); | |
35 | |
36 if (! pb.open (command.c_str (), mode)) | |
37 std::ios::setstate (std::ios::badbit); | |
38 } | |
39 | |
1965 | 40 procstreambase::procstreambase (const char *command, int mode) |
1 | 41 { |
1965 | 42 pb_init (); |
1380 | 43 |
1965 | 44 if (! pb.open (command, mode)) |
3563 | 45 std::ios::setstate (std::ios::badbit); |
1 | 46 } |
47 | |
48 void | |
1965 | 49 procstreambase::open (const char *command, int mode) |
1 | 50 { |
51 clear (); | |
1380 | 52 |
1965 | 53 if (! pb.open (command, mode)) |
3563 | 54 std::ios::setstate (std::ios::badbit); |
1 | 55 } |
56 | |
483 | 57 int |
1965 | 58 procstreambase::close (void) |
1380 | 59 { |
60 int status = 0; | |
61 | |
62 if (is_open ()) | |
63 { | |
1965 | 64 if (! pb.close ()) |
3563 | 65 std::ios::setstate (std::ios::failbit); |
3189 | 66 |
67 status = pb.wait_status (); | |
1380 | 68 } |
69 | |
70 return status; | |
71 } |