MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / main

Function main

democlient/democlient.cpp:97–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95
96
97int 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}

Callers

nothing calls this directly

Calls 4

unencodeFunction · 0.85
addEnabledMethod · 0.80
enableMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected