45# include <sys/utsname.h>
55# include <sys/types.h>
56# include <sys/socket.h>
57# include <netinet/in.h>
58# include <arpa/inet.h>
76 gettimeofday(&start, NULL);
82 cout << html().set(
"lang",
"en").set(
"dir",
"ltr") << endl;
87 cout << head() << endl;
90 cout << style() <<
comment() << endl;
92 cout <<
comment() << style() << endl;
94 cout << title(
"DNS Gateway") << endl;
95 cout << head() << endl;
97 cout << h1() <<
"GNU cgi" << span(
"cc").
set(
"class",
"red")
98 <<
" DNS Gateway" << h1() << endl;
103 if(ip != (*cgi).end()) {
104 cout << h3() <<
"Query results for " << **ip << h3() << endl;
110 if((
int)(addr = inet_addr((**ip).c_str())) == -1) {
111 cout << cgicc::div().set(
"class",
"notice") << endl
112 << strong(span(
"ERROR").
set(
"class",
"red"))
113 <<
" - IP address must be of the form x.x.x.x"
114 << endl << cgicc::div() << endl;
117 hp = gethostbyaddr((
char*)&addr,
sizeof (addr), AF_INET);
119 cout << cgicc::div().set(
"class",
"notice") << endl
120 << strong(span(
"ERROR").
set(
"class",
"red"))
121 <<
" - Host information for " << em((**ip)) <<
" not found."
122 << endl << cgicc::div() << endl;
125 for(p = hp->h_addr_list; *p != 0; p++) {
129 (void) memcpy(&in.s_addr, *p,
sizeof(in.s_addr));
131 cout << cgicc::div().set(
"class",
"notice") << endl
132 << span(inet_ntoa(in)).set(
"class",
"blue")
133 <<
" - " <<
' ' << hp->h_name;
136 cout << endl << cgicc::div() << endl;
143 if(name != (*cgi).end()) {
144 cout << h3() <<
"Query results for " << **name << h3() << endl;
149 hp = gethostbyname((**name).c_str());
151 cout << cgicc::div().set(
"class",
"notice") << endl
152 << strong(span(
"ERROR").
set(
"class",
"red"))
153 <<
" - Host information for " << em(**name) <<
" not found."
154 << endl << cgicc::div() << endl;
157 for(p = hp->h_addr_list; *p != 0; p++) {
161 (void) memcpy(&in.s_addr, *p,
sizeof(in.s_addr));
163 cout << cgicc::div().set(
"class",
"notice") << endl
164 << inet_ntoa(in) <<
" - " <<
' '
165 << span(hp->h_name).set(
"class",
"blue");
168 cout << endl << cgicc::div() << endl;
173 cout << p(
"Please enter an IP address or a hostname.") << endl;
175 cout << table() << endl;
177 cout <<
"<form method=\"post\" action=\""
180 cout << tr() << endl;
181 cout << td(strong(
"IP Address: ")).set(
"class",
"title") << endl;
182 cout << td().set(
"class",
"data") <<
"<input type=\"text\" name=\"ip\"";
183 if(ip != (*cgi).end())
184 cout <<
" value=\"" << **ip <<
"\">";
187 cout << td() << tr() <<
"</form>" << endl;
189 cout <<
"<form method=\"post\" action=\""
192 cout << tr() << endl;
193 cout << td(strong(
"Hostname: ")).set(
"class",
"title") << endl;
194 cout << td().set(
"class",
"data")
195 <<
"<input type=\"text\" name=\"hostname\"";
196 if(name != (*cgi).end())
197 cout <<
" value=\"" << **name <<
"\">";
200 cout << td() << tr() << endl;
201 cout <<
"</form>" << table() << p() << endl;
204 cout << hr(
set(
"class",
"half")) << endl;
205 cout << cgicc::div().set(
"align",
"center").set(
"class",
"smaller") << endl;
206 cout <<
"GNU cgi" << span(
"cc").set(
"class",
"red") <<
" v"
211 cout <<
"Configured for " << cgi.
getHost();
215 if(uname(&info) != -1) {
216 cout <<
". Running on " << info.sysname;
217 cout <<
' ' << info.release <<
" (";
218 cout << info.nodename <<
')' << endl;
227 gettimeofday(&end, NULL);
228 long us = ((end.tv_sec - start.tv_sec) * 1000000)
229 + (end.tv_usec - start.tv_usec);
231 cout << br() <<
"Total time for request = " << us <<
" us";
232 cout <<
" (" <<
static_cast<double>(us/1000000.0) <<
" s)";
236 cout << cgicc::div() << endl;
237 cout << body() << html() << endl;
242 catch(
const std::exception& e) {
Platform and operating system specific macro definitions.
The main header file for the GNU cgicc library.
The header file containing HTML output classes.
std::string getScriptName() const
Get the full path to this CGI application.
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.
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< FormEntry >::iterator form_iterator
A vector of FormEntry objects.
HTMLAttributeList set(const std::string &name)
Create a new HTMLAttributeList, and set an HTMLAttribute.