GNU Octave  8.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
oct-procbuf.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1996-2023 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 // This class is based on the procbuf class from libg++, written by
27 // Per Bothner, Copyright (C) 1993 Free Software Foundation.
28 
29 #if ! defined (octave_oct_procbuf_h)
30 #define octave_oct_procbuf_h 1
31 
32 #include "octave-config.h"
33 
34 #include <sys/types.h>
35 
36 #include "c-file-ptr-stream.h"
37 
39 
40 class
41 procbuf : public c_file_ptr_buf
42 {
43 public:
44 
45  procbuf (void)
46  : c_file_ptr_buf (nullptr), m_wstatus (-1), m_open_p (false),
47  m_proc_pid (-1), m_next (nullptr)
48  { }
49 
50  procbuf (const char *command, int mode)
51  : c_file_ptr_buf (nullptr), m_wstatus (-1), m_open_p (false),
52  m_proc_pid (-1), m_next (nullptr)
53  { open (command, mode); }
54 
55  // No copying!
56 
57  procbuf (const procbuf&) = delete;
58 
59  procbuf& operator = (const procbuf&) = delete;
60 
61  ~procbuf (void) { close (); }
62 
63  procbuf * open (const char *command, int mode);
64 
65  procbuf * close (void);
66 
67  int wait_status (void) const { return m_wstatus; }
68 
69  bool is_open (void) const { return m_open_p; }
70 
71  pid_t pid (void) const { return m_proc_pid; }
72 
73 protected:
74 
75  int m_wstatus;
76 
77  bool m_open_p;
78 
79  pid_t m_proc_pid;
80 
82 };
83 
85 
86 #if defined (OCTAVE_PROVIDE_DEPRECATED_SYMBOLS)
87 
88 OCTAVE_DEPRECATED (7, "use octave::procbuf' instead")
89 typedef octave::procbuf procbuf;
90 
91 #endif
92 
93 #endif
OCTAVE_END_NAMESPACE(octave)
procbuf(void)
Definition: oct-procbuf.h:45
~procbuf(void)
Definition: oct-procbuf.h:61
int wait_status(void) const
Definition: oct-procbuf.h:67
pid_t m_proc_pid
Definition: oct-procbuf.h:79
int m_wstatus
Definition: oct-procbuf.h:75
procbuf * m_next
Definition: oct-procbuf.h:81
procbuf(const char *command, int mode)
Definition: oct-procbuf.h:50
bool m_open_p
Definition: oct-procbuf.h:77
procbuf(const procbuf &)=delete
bool is_open(void) const
Definition: oct-procbuf.h:69
pid_t pid(void) const
Definition: oct-procbuf.h:71
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn