aboutsummaryrefslogtreecommitdiff
path: root/src/process.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-11-23 22:58:19 +0000
committerMike Buland <eichlan@xagasoft.com>2007-11-23 22:58:19 +0000
commitcd215f0da23e16c3f1a7200f2b9f67f23c9b4be7 (patch)
treeef4b144cbc9a68110c1ea6a0b2eb73be2cbd02bb /src/process.h
parentb5b68088f28b2593bfbf910a46fd52775007e8b3 (diff)
downloadlibbu++-cd215f0da23e16c3f1a7200f2b9f67f23c9b4be7.tar.gz
libbu++-cd215f0da23e16c3f1a7200f2b9f67f23c9b4be7.tar.bz2
libbu++-cd215f0da23e16c3f1a7200f2b9f67f23c9b4be7.tar.xz
libbu++-cd215f0da23e16c3f1a7200f2b9f67f23c9b4be7.zip
Added the Process stream class, this will allow us to do some really cool stuff
coming up...it's just like popen only cool and managed, and streamey.
Diffstat (limited to 'src/process.h')
-rw-r--r--src/process.h64
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
17namespace 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