X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/d63d2c3c6cbbd574dda4f8b00ebe6c661735edd5..936231df33baf5f16adb58b3e19de30332aae398:/lib/base/console.h diff --git a/lib/base/console.h b/lib/base/console.h index e69de29b..07ad6a90 100644 --- a/lib/base/console.h +++ b/lib/base/console.h @@ -0,0 +1,52 @@ +#ifndef __LIB_BASE_CONSOLE_H__ +#define __LIB_BASE_CONSOLE_H__ + +#include "Python.h" +#include +#include +#include +#include + +#ifndef SWIG +struct queue_data +{ + queue_data( char *data, int len ) + :data(data), len(len) + { + } + char *data; + int len; +}; +#endif + +class eConsoleAppContainer: public Object +{ +#ifndef SWIG + int fd[3]; + int pid; + int killstate; + std::queue outbuf; + eSocketNotifier *in, *out, *err; + void readyRead(int what); + void readyErrRead(int what); + void readyWrite(int what); + void closePipes(); +#endif +public: + eConsoleAppContainer(); + int execute( const char *str ); + int execute( const char *cmdline, const char *const argv[] ); + int execute( PyObject *cmdline, PyObject *args ); + ~eConsoleAppContainer(); + int getPID() { return pid; } + void kill(); + void sendCtrlC(); + void write( const char *data, int len ); + void write( PyObject *data ); + bool running() { return (fd[0]!=-1) && (fd[1]!=-1) && (fd[2]!=-1); } + PSignal1 dataAvail; + PSignal1 dataSent; + PSignal1 appClosed; +}; + +#endif // __LIB_BASE_CONSOLE_H__