| 95 | |
| 96 | |
| 97 | int main() |
| 98 | { |
| 99 | std::cout << "Content-type: text/html\r\n\r\n" |
| 100 | << "<!DOCTYPE html>\n"; |
| 101 | |
| 102 | char data[4096] = {0}; |
| 103 | |
| 104 | const char *query_string = std::getenv("QUERY_STRING"); |
| 105 | if (query_string) |
| 106 | std::strncpy(data, query_string, sizeof(data)-2); |
| 107 | |
| 108 | const char *lenstr = std::getenv("CONTENT_LENGTH"); |
| 109 | if (lenstr) { |
| 110 | int len = std::min(1 + std::atoi(lenstr), (int)(sizeof(data) - 2)); |
| 111 | std::fgets(data, len, stdin); |
| 112 | } |
| 113 | |
| 114 | if (data[4000] != '\0') { |
| 115 | std::cout << "<html><body>For performance reasons the code must be shorter than 1000 chars.</body></html>"; |
| 116 | return EXIT_SUCCESS; |
| 117 | } |
| 118 | |
| 119 | const char *pdata = data; |
| 120 | if (std::strncmp(pdata, "code=", 5)==0) |
| 121 | pdata += 5; |
| 122 | |
| 123 | char code[4096] = {0}; |
| 124 | unencode(pdata, code); |
| 125 | |
| 126 | logfile = std::fopen("democlient.log", "at"); |
| 127 | if (logfile != nullptr) |
| 128 | std::fprintf(logfile, "===========================================================\n%s\n", code); |
| 129 | |
| 130 | std::cout << "<html><body>Cppcheck " CPPCHECK_VERSION_STRING "<pre>"; |
| 131 | |
| 132 | Settings s; |
| 133 | s.addEnabled("all"); |
| 134 | s.certainty.enable(Certainty::inconclusive); |
| 135 | CppcheckExecutor cppcheckExecutor(s); |
| 136 | cppcheckExecutor.run(code); |
| 137 | |
| 138 | std::fclose(logfile); |
| 139 | |
| 140 | std::cout << "</pre>Done!</body></html>"; |
| 141 | |
| 142 | return EXIT_SUCCESS; |
| 143 | } |
nothing calls this directly
no test coverage detected