summaryrefslogtreecommitdiff
path: root/libopie/oprocess.cpp
Side-by-side diff
Diffstat (limited to 'libopie/oprocess.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/oprocess.cpp94
1 files changed, 49 insertions, 45 deletions
diff --git a/libopie/oprocess.cpp b/libopie/oprocess.cpp
index f3e52bd..5db2b6c 100644
--- a/libopie/oprocess.cpp
+++ b/libopie/oprocess.cpp
@@ -81,48 +81,68 @@
/////////////////////////////
// public member functions //
/////////////////////////////
class OProcessPrivate {
public:
OProcessPrivate() : useShell(false) { }
bool useShell;
QMap<QString,QString> env;
QString wd;
QCString shell;
};
-OProcess::OProcess()
- : QObject(),
- run_mode(NotifyOnExit),
- runs(false),
- pid_(0),
- status(0),
- keepPrivs(false),
- innot(0),
- outnot(0),
- errnot(0),
- communication(NoCommunication),
- input_data(0),
- input_sent(0),
- input_total(0),
- d(0)
+OProcess::OProcess(QObject *parent, const char *name)
+ : QObject(parent, name)
{
+ init ( );
+}
+
+OProcess::OProcess(const QString &arg0, QObject *parent, const char *name)
+ : QObject(parent, name)
+{
+ init ( );
+ *this << arg0;
+}
+
+OProcess::OProcess(const QStringList &args, QObject *parent, const char *name)
+ : QObject(parent, name)
+{
+ init ( );
+ *this << args;
+}
+
+void OProcess::init ( )
+{
+ run_mode = NotifyOnExit;
+ runs = false;
+ pid_ = 0;
+ status = 0;
+ keepPrivs = false;
+ innot = 0;
+ outnot = 0;
+ errnot = 0;
+ communication = NoCommunication;
+ input_data = 0;
+ input_sent = 0;
+ input_total = 0;
+ d = 0;
+
if (0 == OProcessController::theOProcessController) {
(void) new OProcessController();
CHECK_PTR(OProcessController::theOProcessController);
}
OProcessController::theOProcessController->addOProcess(this);
out[0] = out[1] = -1;
in[0] = in[1] = -1;
err[0] = err[1] = -1;
}
void
OProcess::setEnvironment(const QString &name, const QString &value)
{
if (!d)
d = new OProcessPrivate;
@@ -459,32 +479,46 @@ bool OProcess::writeStdin(const char *buffer, int buflen)
// kprocess...
if (0 != input_data)
return false;
if (runs && (communication & Stdin)) {
input_data = buffer;
input_sent = 0;
input_total = buflen;
slotSendData(0);
innot->setEnabled(true);
rv = true;
} else
rv = false;
return rv;
}
+void OProcess::flushStdin ( )
+{
+ if ( !input_data || ( input_sent == input_total ))
+ return;
+
+ int d1, d2;
+
+ do {
+ d1 = input_total - input_sent;
+ slotSendData ( 0 );
+ d2 = input_total - input_sent;
+ } while ( d2 <= d1 );
+}
+
void OProcess::suspend()
{
if ((communication & Stdout) && outnot)
outnot->setEnabled(false);
}
void OProcess::resume()
{
if ((communication & Stdout) && outnot)
outnot->setEnabled(true);
}
bool OProcess::closeStdin()
{
bool rv;
@@ -875,48 +909,18 @@ bool OProcess::isExecutable(const QCString &filename)
#ifdef S_ISSOCK
// CC: SYSVR4 systems don't have that macro
(S_ISSOCK(fileinfo.st_mode)) ||
#endif
(S_ISFIFO(fileinfo.st_mode)) ||
(S_ISDIR(fileinfo.st_mode)) ) {
return false;
}
// CC: now check for permission to execute the file
if (access(filename.data(), X_OK) != 0) return false;
// CC: we've passed all the tests...
return true;
}
-void OProcess::virtual_hook( int, void* )
-{ /*BASE::virtual_hook( id, data );*/ }
-
-
-///////////////////////////
-// CC: Class KShellProcess
-///////////////////////////
-
-KShellProcess::KShellProcess(const char *shellname):
- OProcess()
-{
- setUseShell(true, shellname);
-}
-
-
-KShellProcess::~KShellProcess() {
-}
-
-QString KShellProcess::quote(const QString &arg)
-{
- return OProcess::quote(arg);
-}
-
-bool KShellProcess::start(RunMode runmode, Communication comm)
-{
- return OProcess::start(runmode, comm);
-}
-void KShellProcess::virtual_hook( int id, void* data )
-{ OProcess::virtual_hook( id, data ); }
-//#include "kprocess.moc"