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 |
6098
|
32 // FIXME -- perhaps this should be handled more globally. See also |
|
33 // oct-procbuf.cc. |
|
34 |
6097
|
35 #if defined (_MSC_VER) |
|
36 #define popen _popen |
|
37 #define pclose _pclose |
|
38 #endif |
|
39 |
3951
|
40 static int |
|
41 cxx_pclose (FILE *f) |
|
42 { |
|
43 return ::pclose (f); |
|
44 } |
|
45 |
3340
|
46 octave_stream |
3544
|
47 octave_iprocstream::create (const std::string& n, std::ios::openmode arg_md, |
4587
|
48 oct_mach_info::float_format ff) |
3340
|
49 { |
4587
|
50 return octave_stream (new octave_iprocstream (n, arg_md, ff)); |
3340
|
51 } |
|
52 |
3523
|
53 octave_iprocstream::octave_iprocstream (const std::string& n, |
3544
|
54 std::ios::openmode arg_md, |
4587
|
55 oct_mach_info::float_format ff) |
4327
|
56 : octave_stdiostream (n, ::popen (n.c_str (), "r"), |
4587
|
57 arg_md, ff, cxx_pclose) |
2081
|
58 { |
|
59 } |
|
60 |
|
61 octave_iprocstream::~octave_iprocstream (void) |
|
62 { |
3652
|
63 do_close (); |
|
64 } |
|
65 |
3340
|
66 octave_stream |
3544
|
67 octave_oprocstream::create (const std::string& n, std::ios::openmode arg_md, |
4587
|
68 oct_mach_info::float_format ff) |
3340
|
69 { |
4587
|
70 return octave_stream (new octave_oprocstream (n, arg_md, ff)); |
3340
|
71 } |
|
72 |
3523
|
73 octave_oprocstream::octave_oprocstream (const std::string& n, |
3544
|
74 std::ios::openmode arg_md, |
4587
|
75 oct_mach_info::float_format ff) |
4327
|
76 : octave_stdiostream (n, ::popen (n.c_str (), "w"), |
4587
|
77 arg_md, ff, cxx_pclose) |
2081
|
78 { |
|
79 } |
|
80 |
|
81 octave_oprocstream::~octave_oprocstream (void) |
|
82 { |
3652
|
83 do_close (); |
|
84 } |
|
85 |
2081
|
86 /* |
|
87 ;;; Local Variables: *** |
|
88 ;;; mode: C++ *** |
|
89 ;;; End: *** |
|
90 */ |