X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/d63d2c3c6cbbd574dda4f8b00ebe6c661735edd5..3c282ef6f5bd54f2b0f4cb407d075cf321405b84:/lib/base/console.h diff --git a/lib/base/console.h b/lib/base/console.h index e69de29b..60540da0 100644 --- a/lib/base/console.h +++ b/lib/base/console.h @@ -0,0 +1,54 @@ +#ifndef __LIB_BASE_CONSOLE_H__ +#define __LIB_BASE_CONSOLE_H__ + +#include +#include +#include +#include + +struct queue_data +{ + queue_data( char *data, int len ) + :data(data), len(len), dataSent(0) + { + } + char *data; + int len; + int dataSent; +}; + +class eConsoleAppContainer: public Object, public iObject +{ + DECLARE_REF(eConsoleAppContainer); + int fd[3]; + int filefd[3]; + int pid; + int killstate; + std::string m_cwd; + std::queue outbuf; + ePtr in, out, err; + void readyRead(int what); + void readyErrRead(int what); + void readyWrite(int what); + void closePipes(); +public: + eConsoleAppContainer(); + ~eConsoleAppContainer(); + int setCWD( const char *path ); + int execute( const char *str ); + int execute( const char *cmdline, const char *const argv[] ); + int getPID() { return pid; } + void kill(); + void sendCtrlC(); + void sendEOF(); + void write( const char *data, int len ); + void setFileFD(int num, int fd) { if (num >= 0 && num <= 2) filefd[num] = fd; } + bool running() { return (fd[0]!=-1) && (fd[1]!=-1) && (fd[2]!=-1); } + PSignal1 dataAvail; + PSignal1 stdoutAvail; + PSignal1 stderrAvail; + PSignal1 dataSent; + PSignal1 appClosed; +}; + +#endif // __LIB_BASE_CONSOLE_H__