@@ -39,16 +39,12 @@ class CppcheckExecutor : public ErrorLogger {
39
39
}
40
40
41
41
void run (const char code[]) {
42
- printf (" %s\n " , ErrorLogger::ErrorMessage::getXMLHeader (2 ).c_str ());
43
42
cppcheck.check (" test.c" , code);
44
- printf (" %s\n " , ErrorLogger::ErrorMessage::getXMLFooter (2 ).c_str ());
45
- printf (" \n\n " );
46
43
}
47
44
48
45
void reportOut (const std::string &outmsg) { }
49
46
void reportErr (const ErrorLogger::ErrorMessage &msg) {
50
- const std::string str (msg.toXML (true ,2U ));
51
- printf (" %s\n " , str.c_str ());
47
+ printf (" %s\n " , msg.toString (true ).c_str ());
52
48
}
53
49
54
50
void reportProgress (const
@@ -70,28 +66,38 @@ int main()
70
66
{
71
67
char data[4096 ] = {0 };
72
68
69
+ const char *query_string = getenv (" QUERY_STRING" );
70
+ if (query_string)
71
+ std::strncpy (data, query_string, sizeof (data)-2 );
72
+
73
73
const char *lenstr = getenv (" CONTENT_LENGTH" );
74
74
if (lenstr) {
75
75
int len = std::min (1 + atoi (lenstr), (int )(sizeof (data) - 2 ));
76
76
fgets (data, len, stdin);
77
- } else {
78
- const char *s = getenv (" QUERY_STRING" );
79
- std::strncpy (data, s?s:" " , sizeof (data)-2 );
80
77
}
81
78
82
79
char code[4096 ] = {0 };
83
80
unencode (data, code);
84
81
82
+ if (strlen (code) > 1000 ) {
83
+ puts (" Content-type: text/html\r\n\r\n " );
84
+ puts (" <html><body>For performance reasons the code must be shorter than 1000 chars.</body></html>" );
85
+ return EXIT_SUCCESS;
86
+ }
87
+
85
88
FILE *logfile = fopen (" democlient.log" , " at" );
86
89
if (logfile != NULL ) {
87
90
fprintf (logfile, " ===========================================================\n %s\n " , code);
88
91
fclose (logfile);
89
92
}
90
93
91
- printf (" Content-type: text/plain\n\n " );
94
+ puts (" Content-type: text/html\r\n\r\n " );
95
+ puts (" <html><body><pre>" );
92
96
93
97
CppcheckExecutor cppcheckExecutor;
94
98
cppcheckExecutor.run (code);
95
99
100
+ puts (" </pre>Done!</body></html>" );
101
+
96
102
return EXIT_SUCCESS;
97
103
}
0 commit comments