00001 #ifdef TEST 00002 #include "headers.h" 00003 00004 static const string httpTestProcessorCommandString = "httpTestProcessor"; 00005 static const string changePortCommandString = "changeport"; 00006 00007 00008 HttpTestProcessorCommand::HttpTestProcessorCommand(HttpTestCommandProcessor* processor) : MetaCommand(processor) 00009 { 00010 m_commandProcessor = processor; 00011 } 00012 00013 00014 void 00015 HttpTestProcessorCommand::run(std::ostream& s) { 00016 if (m_args[1] == showCommandString) { 00017 s << *m_commandProcessor; 00018 return; 00019 } 00020 if (m_args[1] == changePortCommandString) { 00021 changePort(s); 00022 return; 00023 } 00024 else { 00025 getHelp(s); 00026 return; 00027 } 00028 } 00029 00030 00031 void 00032 HttpTestProcessorCommand::getHelp(std::ostream& s) { 00033 s << "Help: \n" 00034 << httpTestProcessorCommandString << " --- subcommands:\n" 00035 << " " << showCommandString << "\n" 00036 << " " << changePortCommandString << " [port]\n"; 00037 } 00038 00039 00040 void 00041 HttpTestProcessorCommand::changePort(std::ostream& s) { 00042 m_commandProcessor->changePort(atoi(m_args[2].c_str())); 00043 s << "Port changed to " << m_args[2] << "\n"; 00044 } 00045 00046 00047 string 00048 HttpTestProcessorCommand::getCommandString() { 00049 return httpTestProcessorCommandString; 00050 } 00051 00052 00053 void 00054 HttpTestProcessorCommand::getHtmlInterface(std::ostream& s) { 00055 s << "<h2>Http Test Processor</h2>"; 00056 beginUl(s); 00057 generateHtmlSubcmd(s, showCommandString, "show"); 00058 generateHtmlSubcmdArg1(s, changePortCommandString, "Change proxy listening port to: ", "ChangePort"); 00059 endUl(s); 00060 } 00061 00062 #endif 00063