GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
oct-procbuf.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2013 John W. Eaton
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 3 of the License, or (at your
10 option) any 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, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 // This class is based on the procbuf class from libg++, written by
24 // Per Bothner, Copyright (C) 1993 Free Software Foundation.
25 
26 #if !defined (octave_oct_procbuf_h)
27 #define octave_oct_procbuf_h 1
28 
29 #include <sys/types.h>
30 
31 #include "c-file-ptr-stream.h"
32 
33 class
35 {
36 public:
37 
39  : c_file_ptr_buf (0), wstatus (-1), open_p (false), proc_pid (-1),
40  next (0) { }
41 
42  octave_procbuf (const char *command, int mode)
43  : c_file_ptr_buf (0), wstatus (-1), open_p (false), proc_pid (-1),
44  next (0) { open (command, mode); }
45 
46  ~octave_procbuf (void) { close (); }
47 
48  octave_procbuf *open (const char *command, int mode);
49 
50  octave_procbuf *close (void);
51 
52  int wait_status (void) const { return wstatus; }
53 
54  bool is_open (void) const { return open_p; }
55 
56  pid_t pid (void) const { return proc_pid; }
57 
58 protected:
59 
60  int wstatus;
61 
62  bool open_p;
63 
64  pid_t proc_pid;
65 
67 
68 private:
69 
70  // No copying!
71 
73 
74  octave_procbuf& operator = (const octave_procbuf&);
75 };
76 
77 extern void symbols_of_oct_procbuf (void);
78 
79 #endif