diff options
Diffstat (limited to 'src/process.h')
-rw-r--r-- | src/process.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/process.h b/src/process.h new file mode 100644 index 0000000..dbf1553 --- /dev/null +++ b/src/process.h | |||
@@ -0,0 +1,64 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #ifndef BU_PROCESS_H | ||
9 | #define BU_PROCESS_H | ||
10 | |||
11 | #include <stdint.h> | ||
12 | #include <sys/types.h> | ||
13 | |||
14 | #include "bu/stream.h" | ||
15 | #include "bu/fstring.h" | ||
16 | |||
17 | namespace Bu | ||
18 | { | ||
19 | /** | ||
20 | * Runs a program and attaches streams to it's stdin, stdout, and stderr. | ||
21 | * Reading from a Bu::Process will read from the program's standard output, | ||
22 | * writing to a Bu::Process will write to the program's standard input. | ||
23 | */ | ||
24 | class Process : public Bu::Stream | ||
25 | { | ||
26 | public: | ||
27 | Process( const char *sName, char *const argv[] ); | ||
28 | Process( const char *sName, const char *argv, ...); | ||
29 | virtual ~Process(); | ||
30 | |||
31 | virtual void close(); | ||
32 | virtual size_t read( void *pBuf, size_t nBytes ); | ||
33 | virtual size_t write( const void *pBuf, size_t nBytes ); | ||
34 | |||
35 | virtual long tell(); | ||
36 | virtual void seek( long offset ); | ||
37 | virtual void setPos( long pos ); | ||
38 | virtual void setPosEnd( long pos ); | ||
39 | virtual bool isEOS(); | ||
40 | virtual bool isOpen(); | ||
41 | |||
42 | virtual void flush(); | ||
43 | |||
44 | virtual bool canRead(); | ||
45 | virtual bool canWrite(); | ||
46 | |||
47 | virtual bool isReadable(); | ||
48 | virtual bool isWritable(); | ||
49 | virtual bool isSeekable(); | ||
50 | |||
51 | virtual bool isBlocking(); | ||
52 | virtual void setBlocking( bool bBlocking=true ); | ||
53 | |||
54 | private: | ||
55 | int iStdIn; | ||
56 | int iStdOut; | ||
57 | int iStdErr; | ||
58 | pid_t iPid; | ||
59 | |||
60 | void gexec( const char *sName, char *const argv[] ); | ||
61 | }; | ||
62 | } | ||
63 | |||
64 | #endif | ||