Here is the code:
#include <QtCore/QCoreApplication>
#include <QProcess>
#include <QProcessEnvironment>
int main(int argc, char *argv[])
{
QProcessEnvironment env;
// Environment variables required by CGI apps
env.insert("QUERY_STRING", url.encodedQuery());
env.insert("REQUEST_URI", url.toString());
env.insert("REQUEST_METHOD", "GET");
env.insert("REMOTE_ADDR", pSocket->peerAddress().toString());
//==========
QProcess process;
process.setProcessEnvironment(env);
process.start("php-cgi",QProcess::ReadWrite);
process.write("<?php print_r($_GET); ?>");
process.closeWriteChannel();
process.waitForFinished();
qDebug(process.readAll().data());
return 0;
}
Qt Creator reports more than 14000 errors. Here is a small sample of them:
In file included from ../QProcess/main.cpp:2: ../QProcess/QProcess:1: error: stray ‘\177’ in program ../QProcess/QProcess:1: error: stray ‘\2’ in program ../QProcess/QProcess:1: error: stray ‘\1’ in program ../QProcess/QProcess:1: error: stray ‘\1’ in program In file included from ../QProcess/main.cpp:2: ../QProcess/QProcess:1:8: warning: null character(s) ignored ../QProcess/QProcess:1: error: stray ‘\2’ in program