// g++ FcgiFrontEndTest.C FcgiFrontEnd.C ../ax_alert_server/XmlSupport.C ../shared/MiscSupport.C // This simple test dumps all of it's input back to the user, like php_info(). #include #include #include #include #include #include "../ax_alert_server/XmlSupport.h" #include "FcgiFrontEnd.h" //static std::fstream logFile; static std::ostream &logFile = std::cout; static int externalSocket; static FcgiFrontEnd *frontEnd; class MyActions : public FcgiExternalActions { public: void newResponderRequest(FcgiRequestId id, PropertyList const ¶ms, std::string stdin); void abort(FcgiRequestId id); void assertionFailed(std::string message); void debugInformation(std::string message); void sendBytes(std::string); }; void MyActions::newResponderRequest(FcgiRequestId id, PropertyList const ¶ms, std::string stdin) { logFile<<"newResponderRequest id="<setHeader(id, "Content-Type", "text/xml"); XmlNode body; body.properties["id"] = ntoa(id); XmlNode &p = body["params"]; for (PropertyList::const_iterator it = params.begin(); it != params.end(); it++) { XmlNode ¶m = p[-1]; param.properties["name"] = it->first; param.properties["value"] = it->second; } body.properties["stdin"] = stdin; frontEnd->sendBody(id, body.asString()); //logFile<<"frontEnd->sendBody("<close(id, 0); logFile.flush(); } void MyActions::abort(FcgiRequestId id) { logFile<<"abort requested, id="< 0) { ssize_t result = write(externalSocket, start, remaining); if (result < 0) { logFile<bytesReceived(std::string(buffer, result)); } close(externalSocket); } }