SystemcallPrivate::SystemcallPrivate(const std::string& of) :
process_(new QProcess),
- outIndex_(0),
- errIndex_(0),
- outFile_(of),
- terminalOutExists_(os::is_terminal(os::STDOUT)),
- terminalErrExists_(os::is_terminal(os::STDERR)),
- processEvents_(false)
+ out_index_(0),
+ err_index_(0),
+ out_file_(of),
+ terminal_out_exists_(os::is_terminal(os::STDOUT)),
+ terminal_err_exists_(os::is_terminal(os::STDERR)),
+ process_events_(false)
{
- if (!outFile_.empty()) {
+ if (!out_file_.empty()) {
// Check whether we have to simply throw away the output.
- if (outFile_ != os::nulldev())
- process_->setStandardOutputFile(toqstr(outFile_));
+ if (out_file_ != os::nulldev())
+ process_->setStandardOutputFile(toqstr(out_file_));
}
connect(process_, SIGNAL(readyReadStandardOutput()), SLOT(stdOut()));
void SystemcallPrivate::processEvents()
{
- if(processEvents_) {
+ if(process_events_) {
QCoreApplication::processEvents(/*QEventLoop::ExcludeUserInputEvents*/);
}
}
{
flush();
- if (outIndex_) {
- outData_[outIndex_] = '\0';
- outIndex_ = 0;
- if (terminalOutExists_)
- cout << outData_;
+ if (out_index_) {
+ out_data_[out_index_] = '\0';
+ out_index_ = 0;
+ if (terminal_out_exists_)
+ cout << out_data_;
}
cout.flush();
- if (errIndex_) {
- errData_[errIndex_] = '\0';
- errIndex_ = 0;
- if (terminalErrExists_)
- cerr << errData_;
+ if (err_index_) {
+ err_data_[err_index_] = '\0';
+ err_index_ = 0;
+ if (terminal_err_exists_)
+ cerr << err_data_;
}
cerr.flush();
QString data = QString::fromLocal8Bit(process_->readAllStandardOutput().data());
ProgressInterface::instance()->appendMessage(data);
- if (!terminalOutExists_ && outFile_.empty())
+ if (!terminal_out_exists_ && out_file_.empty())
cout << fromqstr(data);
data = QString::fromLocal8Bit(process_->readAllStandardError().data());
ProgressInterface::instance()->appendError(data);
- if (!terminalErrExists_)
+ if (!terminal_err_exists_)
cerr << fromqstr(data);
}
}
char c;
process_->setReadChannel(QProcess::StandardOutput);
while (process_->getChar(&c)) {
- outData_[outIndex_++] = c;
- if (c == '\n' || outIndex_ + 1 == bufferSize_) {
- outData_[outIndex_] = '\0';
- outIndex_ = 0;
- ProgressInterface::instance()->appendMessage(QString::fromLocal8Bit(outData_));
- if (terminalOutExists_)
- cout << outData_;
+ out_data_[out_index_++] = c;
+ if (c == '\n' || out_index_ + 1 == max_buffer_size_) {
+ out_data_[out_index_] = '\0';
+ out_index_ = 0;
+ ProgressInterface::instance()->appendMessage(QString::fromLocal8Bit(out_data_));
+ if (terminal_out_exists_)
+ cout << out_data_;
}
}
}
char c;
process_->setReadChannel(QProcess::StandardError);
while (process_->getChar(&c)) {
- errData_[errIndex_++] = c;
- if (c == '\n' || errIndex_ + 1 == bufferSize_) {
- errData_[errIndex_] = '\0';
- errIndex_ = 0;
- ProgressInterface::instance()->appendError(QString::fromLocal8Bit(errData_));
- if (terminalErrExists_)
- cerr << errData_;
+ err_data_[err_index_++] = c;
+ if (c == '\n' || err_index_ + 1 == max_buffer_size_) {
+ err_data_[err_index_] = '\0';
+ err_index_ = 0;
+ ProgressInterface::instance()->appendError(QString::fromLocal8Bit(err_data_));
+ if (terminal_err_exists_)
+ cerr << err_data_;
}
}
}
QProcess * process_;
/// Index to the standard output buffer.
- size_t outIndex_;
+ size_t out_index_;
/// Index to the standard error buffer.
- size_t errIndex_;
+ size_t err_index_;
///
- std::string outFile_;
+ std::string out_file_;
/// Size of buffers.
- static size_t const bufferSize_ = 200;
+ static size_t const max_buffer_size_ = 200;
/// Standard output buffer.
- char outData_[bufferSize_];
+ char out_data_[max_buffer_size_];
/// Standard error buffer.
- char errData_[bufferSize_];
+ char err_data_[max_buffer_size_];
- bool terminalErrExists_;
- bool terminalOutExists_;
+ bool terminal_err_exists_;
+ bool terminal_out_exists_;
+
+ QString cmd_;
+ bool process_events_;
- bool processEvents_;
void waitAndProcessEvents();
void processEvents();
- void killProcess();
- QString cmd_;
+ void killProcess();
};