43# include <sys/utsname.h>
57printForm(
const Cgicc& cgi)
59 cout <<
"<form method=\"post\" action=\""
62 cout <<
"<table>" << endl;
64 cout <<
"<tr><td class=\"title\">Cookie Name</td>"
65 <<
"<td class=\"form\">"
66 <<
"<input type=\"text\" name=\"name\" />"
67 <<
"</td></tr>" << endl;
69 cout <<
"<tr><td class=\"title\">Cookie Value</td>"
70 <<
"<td class=\"form\">"
71 <<
"<input type=\"text\" name=\"value\" />"
72 <<
"</td></tr>" << endl;
74 cout <<
"</table>" << endl;
76 cout <<
"<div class=\"center\"><p>"
77 <<
"<input type=\"submit\" name=\"submit\" value=\"Set the cookie\" />"
78 <<
"<input type=\"reset\" value=\"Nevermind\" />"
79 <<
"</p></div></form>" << endl;
90 gettimeofday(&start, NULL);
103 && value->getValue().empty() ==
false)
111 cout << html().set(
"lang",
"en").set(
"dir",
"ltr") << endl;
115 cout << head() << endl;
118 cout << style() <<
comment() << endl;
120 cout <<
comment() << style() << endl;
122 cout << title() <<
"GNU cgicc v" << cgi.
getVersion()
123 <<
" HTTPCookie" << title() << endl;
125 cout << head() << endl;
128 cout << body() << endl;
130 cout << h1() <<
"GNU cgi" << span(
"cc").set(
"class",
"red")
131 <<
" v"<< cgi.
getVersion() <<
" HTTPCookie Test Results"
138 cout <<
comment() <<
"This page generated by cgicc for "
140 cout << h4() <<
"Thanks for using cgi" << span(
"cc").
set(
"class",
"red")
145 && value->getValue().empty() ==
false) {
146 cout << p() <<
"A cookie with the name " << em(name->getValue())
147 <<
" and value " << em(value->getValue()) <<
" was set." << br();
148 cout <<
"In order for the cookie to show up here you must "
153 cout << h2(
"Cookie Information from the Environment") << endl;
155 cout << cgicc::div().set(
"align",
"center") << endl;
157 cout << table() << endl;
159 cout << tr() << td(
"HTTPCookie").set(
"class",
"title")
160 << td(env.
getCookies()).set(
"class",
"data") << tr() << endl;
162 cout << table() << cgicc::div() << endl;
166 cout << h2(
"HTTP Cookies via vector") << endl;
168 cout << cgicc::div().set(
"align",
"center") << endl;
170 cout << table() << endl;
172 cout << tr().set(
"class",
"title") << td(
"Cookie Name")
173 << td(
"Cookie Value") << tr() << endl;
180 cout << tr().set(
"class",
"data") << td(iter->getName())
181 << td(iter->getValue()) << tr() << endl;
183 cout << table() << cgicc::div() << endl;
187 cout << br() << endl;
189 cout << hr().set(
"class",
"half") << endl;
192 cout << cgicc::div().set(
"align",
"center").set(
"class",
"smaller") << endl;
193 cout <<
"GNU cgi" << span(
"cc").set(
"class",
"red") <<
" v";
198 cout <<
"Configured for " << cgi.
getHost();
201 if(uname(&info) != -1) {
202 cout <<
". Running on " << info.sysname;
203 cout <<
' ' << info.release <<
" (";
204 cout << info.nodename <<
")." << endl;
213 gettimeofday(&end, NULL);
214 long us = ((end.tv_sec - start.tv_sec) * 1000000)
215 + (end.tv_usec - start.tv_usec);
217 cout << br() <<
"Total time for request = " << us <<
" us";
218 cout <<
" (" <<
static_cast<double>(us/1000000.0) <<
" s)";
222 cout << cgicc::div() << endl;
223 cout << body() << html() << endl;
230 catch(
const std::exception& e) {
237 html::reset(); head::reset(); body::reset();
238 title::reset(); h1::reset(); h4::reset();
239 comment::reset(); td::reset(); tr::reset();
240 table::reset(); cgicc::div::reset(); p::reset();
241 a::reset(); h2::reset(); colgroup::reset();
245 cout << html().set(
"lang",
"en").set(
"dir",
"ltr") << endl;
249 cout << head() << endl;
252 cout << style() <<
comment() << endl;
253 cout <<
"body { color: black; background-color: white; }" << endl;
254 cout <<
"hr.half { width: 60%; align: center; }" << endl;
255 cout <<
"span.red, strong.red { color: red; }" << endl;
256 cout <<
"div.notice { border: solid thin; padding: 1em; margin: 1em 0; "
257 <<
"background: #ddd; }" << endl;
259 cout <<
comment() << style() << endl;
261 cout << title(
"GNU cgicc exception") << endl;
262 cout << head() << endl;
264 cout << body() << endl;
266 cout << h1() <<
"GNU cgi" << span(
"cc",
set(
"class",
"red"))
267 <<
" caught an exception" << h1() << endl;
269 cout << cgicc::div().
set(
"align",
"center").
set(
"class",
"notice") << endl;
271 cout << h2(e.what()) << endl;
274 cout << cgicc::div() << endl;
275 cout << hr().
set(
"class",
"half") << endl;
276 cout << body() << html() << endl;
Platform and operating system specific macro definitions.
The main header file for the GNU cgicc library.
The header file containing HTML output classes.
Class encapsulating the CGI runtime environment.
std::string getCookies() const
Get the HTTP cookies associated with this query, if any.
const std::vector< HTTPCookie > & getCookieList() const
Get a vector containing the HTTP cookies associated with this query.
std::string getScriptName() const
Get the full path to this CGI application.
std::string getRemoteAddr() const
Get the IP address of the remote machine making this request.
std::string getRemoteHost() const
Get the hostname of the remote machine making this request.
The main class of the GNU cgicc library.
const char * getCompileDate() const
Get the date on which this library was compiled.
const CgiEnvironment & getEnvironment() const
const char * getVersion() const
Get the version number of cgicc.
const char * getCompileTime() const
Get the time at which this library was compiled.
const char * getHost() const
Get the platform for which Cgicc was configured.
const std::vector< FormEntry > & getElements() const
Get all the submitted form elements, excluding files.
form_iterator getElement(const std::string &name)
Find a radio button in a radio group, or a selected list item.
Specifies the DTD of the HTML 4 document.
HTMLElement & set(const std::string &name)
Set an HTMLAttribute on this HTMLElement.
The namespace containing the cgicc library.
std::vector< HTTPCookie >::const_iterator const_cookie_iterator
A vector of const HTTPCookie objects.
std::vector< FormEntry >::const_iterator const_form_iterator
A vector of const FormEntry objects.
HTMLAttributeList set(const std::string &name)
Create a new HTMLAttributeList, and set an HTMLAttribute.