2081
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
2081
|
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. |
2081
|
21 |
|
22 */ |
|
23 |
|
24 #ifdef HAVE_CONFIG_H |
|
25 #include <config.h> |
|
26 #endif |
|
27 |
|
28 #include <cstdio> |
|
29 |
|
30 #include "oct-prcstrm.h" |
|
31 |
6097
|
32 #if defined (_MSC_VER) |
|
33 #define popen _popen |
|
34 #define pclose _pclose |
|
35 #endif |
|
36 |
3951
|
37 static int |
|
38 cxx_pclose (FILE *f) |
|
39 { |
|
40 return ::pclose (f); |
|
41 } |
|
42 |
3340
|
43 octave_stream |
3544
|
44 octave_iprocstream::create (const std::string& n, std::ios::openmode arg_md, |
4587
|
45 oct_mach_info::float_format ff) |
3340
|
46 { |
4587
|
47 return octave_stream (new octave_iprocstream (n, arg_md, ff)); |
3340
|
48 } |
|
49 |
3523
|
50 octave_iprocstream::octave_iprocstream (const std::string& n, |
3544
|
51 std::ios::openmode arg_md, |
4587
|
52 oct_mach_info::float_format ff) |
4327
|
53 : octave_stdiostream (n, ::popen (n.c_str (), "r"), |
4587
|
54 arg_md, ff, cxx_pclose) |
2081
|
55 { |
|
56 } |
|
57 |
|
58 octave_iprocstream::~octave_iprocstream (void) |
|
59 { |
3652
|
60 do_close (); |
|
61 } |
|
62 |
3340
|
63 octave_stream |
3544
|
64 octave_oprocstream::create (const std::string& n, std::ios::openmode arg_md, |
4587
|
65 oct_mach_info::float_format ff) |
3340
|
66 { |
4587
|
67 return octave_stream (new octave_oprocstream (n, arg_md, ff)); |
3340
|
68 } |
|
69 |
3523
|
70 octave_oprocstream::octave_oprocstream (const std::string& n, |
3544
|
71 std::ios::openmode arg_md, |
4587
|
72 oct_mach_info::float_format ff) |
4327
|
73 : octave_stdiostream (n, ::popen (n.c_str (), "w"), |
4587
|
74 arg_md, ff, cxx_pclose) |
2081
|
75 { |
|
76 } |
|
77 |
|
78 octave_oprocstream::~octave_oprocstream (void) |
|
79 { |
3652
|
80 do_close (); |
|
81 } |
|
82 |
2081
|
83 /* |
|
84 ;;; Local Variables: *** |
|
85 ;;; mode: C++ *** |
|
86 ;;; End: *** |
|
87 */ |