summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2011-02-15 01:25:15 +0000
committerrandomdan <randomdan@localhost>2011-02-15 01:25:15 +0000
commit3fc84507bf1da84a6cee2f73054bdfb19b2ea4f0 (patch)
treead1d78078e525a5f7571ab8479018aa5ed8bbc96
parentCommit some changes I'd swear blind I'd done already (diff)
downloadproject2-3fc84507bf1da84a6cee2f73054bdfb19b2ea4f0.tar.bz2
project2-3fc84507bf1da84a6cee2f73054bdfb19b2ea4f0.tar.xz
project2-3fc84507bf1da84a6cee2f73054bdfb19b2ea4f0.zip
Add debug option for dumping the data document before sending it to the web server
-rw-r--r--project2/cgi/cgiAppEngine.cpp5
-rw-r--r--project2/cgi/cgiEnvironment.cpp6
-rw-r--r--project2/cgi/cgiEnvironment.h4
-rw-r--r--project2/environment.cpp11
4 files changed, 25 insertions, 1 deletions
diff --git a/project2/cgi/cgiAppEngine.cpp b/project2/cgi/cgiAppEngine.cpp
index 364d393..1d00c18 100644
--- a/project2/cgi/cgiAppEngine.cpp
+++ b/project2/cgi/cgiAppEngine.cpp
@@ -62,6 +62,11 @@ CgiApplicationEngine::process() const
header->setCookie(cgicc::HTTPCookie(SESSIONID, sessionID.str(), "Session ID",
_env->getServerName().substr(_env->getServerName().find(".")), 3600, "/", false));
}
+#ifndef NDEBUG
+ if (!_env->dumpdatadoc.empty()) {
+ doc->write_to_file_formatted(_env->dumpdatadoc);
+ }
+#endif
}
CgiApplicationEngine::Stage::Stage(const CgiApplicationEngine * e) : appEngine(e)
diff --git a/project2/cgi/cgiEnvironment.cpp b/project2/cgi/cgiEnvironment.cpp
index ae65183..aa9e57f 100644
--- a/project2/cgi/cgiEnvironment.cpp
+++ b/project2/cgi/cgiEnvironment.cpp
@@ -27,6 +27,12 @@ boost::program_options::options_description
CgiEnvironment::addOptions(boost::program_options::positional_options_description &)
{
boost::program_options::options_description cgi("Project2 CGI options");
+#ifndef NDEBUG
+ cgi.add_options()
+ ("dumpdatadoc", boost::program_options::value<std::string>(&dumpdatadoc),
+ "Write a copy of the data document before sending it to the web server")
+ ;
+#endif
return cgi;
}
diff --git a/project2/cgi/cgiEnvironment.h b/project2/cgi/cgiEnvironment.h
index 005a49b..1774417 100644
--- a/project2/cgi/cgiEnvironment.h
+++ b/project2/cgi/cgiEnvironment.h
@@ -26,6 +26,10 @@ class CgiEnvironment : public Environment, public cgicc::CgiEnvironment {
private:
boost::program_options::options_description addOptions(boost::program_options::positional_options_description &);
void postinit(const boost::program_options::options_description &, const boost::program_options::variables_map &);
+#ifndef NDEBUG
+ public:
+ std::string dumpdatadoc;
+#endif
};
#endif
diff --git a/project2/environment.cpp b/project2/environment.cpp
index 5c50517..5510b1a 100644
--- a/project2/environment.cpp
+++ b/project2/environment.cpp
@@ -36,7 +36,16 @@ Environment::init()
po::store(po::parse_environment(all, "P2_"), settings);
if (boost::filesystem::exists(".p2config")) {
std::ifstream f(".p2config");
- po::store(po::parse_config_file(f, all), settings);
+ // Allow anything in release, but valid the config file in debug
+ // Some options only work in debug and you wouldn't want extra
+ // config entries to break an install
+ po::store(po::parse_config_file(f, all,
+#if NDEBUG
+ true
+#else
+ false
+#endif
+ ), settings);
}
po::notify(settings);