ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/Frodo4/Src/CmdPipe.h
Revision: 1.4
Committed: 2005-06-27T19:55:48Z (17 years, 7 months ago) by cebix
Content type: text/plain
Branch: MAIN
CVS Tags: VERSION_4_2, HEAD
Changes since 1.3: +1 -1 lines
Log Message:
updated copyright dates

File Contents

# User Rev Content
1 cebix 1.1 /*
2     * CmdPipe.h
3     *
4 cebix 1.4 * Frodo (C) 1994-1997,2002-2005 Christian Bauer
5 cebix 1.1 *
6     * This program is free software; you can redistribute it and/or modify
7     * it under the terms of the GNU General Public License as published by
8     * the Free Software Foundation; either version 2 of the License, or
9     * (at your option) any later version.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with this program; if not, write to the Free Software
18     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19     */
20    
21     #ifndef CmdPipe_h
22     #define CmdPipe_h
23    
24     extern "C" {
25     #include <stdio.h>
26     #include <sys/types.h>
27     }
28    
29     class Pipe {
30    
31     protected:
32    
33     int fds[2];
34    
35     public:
36    
37     bool fail;
38    
39     Pipe(void);
40     Pipe(int fdin, int fdout) : fail(false) {
41     fds[0] = fdin;
42     fds[1] = fdout;
43     }
44     ~Pipe(void);
45    
46     unsigned long ewrite(const void * buf, unsigned long len);
47     unsigned long eread (void * buf, unsigned long len);
48    
49     int get_read_fd(void) const {
50     return fds[0];
51     }
52    
53     int get_write_fd(void) const {
54     return fds[1];
55     }
56    
57     int probe(void) const;
58     };
59    
60     class CmdPipe {
61    
62     protected:
63    
64     Pipe tocmd;
65     Pipe fromcmd;
66    
67     int childpid;
68    
69     public:
70    
71     bool fail;
72    
73     CmdPipe(const char * command, const char * arg, int nicediff = 0);
74     ~CmdPipe(void);
75    
76     unsigned long ewrite(const void * buf, unsigned long len) {
77     return tocmd.ewrite(buf, len);
78     }
79    
80     unsigned long eread (void * buf, unsigned long len) {
81     return fromcmd.eread(buf, len);
82     }
83    
84     int get_read_fd(void) const {
85     return fromcmd.get_read_fd();
86     }
87    
88     int get_write_fd(void) const {
89     return tocmd.get_write_fd();
90     }
91    
92     int probe(void) const {
93     return fromcmd.probe();
94     }
95    
96     };
97    
98     #endif // CmdPipe_h