Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

democlient: simple working democlient

  • Loading branch information...
commit 14c81405364d9ef1822a3175467942bf61c75544 1 parent 614826f
Daniel Marjamäki authored
Showing with 17 additions and 10 deletions.
  1. +15 −9 democlient/democlient.cpp
  2. +1 −1  htdocs/demo/index.php
  3. +1 −0  runastyle
24 democlient/democlient.cpp
View
@@ -39,16 +39,12 @@ class CppcheckExecutor : public ErrorLogger {
}
void run(const char code[]) {
- printf("%s\n", ErrorLogger::ErrorMessage::getXMLHeader(2).c_str());
cppcheck.check("test.c", code);
- printf("%s\n", ErrorLogger::ErrorMessage::getXMLFooter(2).c_str());
- printf("\n\n");
}
void reportOut(const std::string &outmsg) { }
void reportErr(const ErrorLogger::ErrorMessage &msg) {
- const std::string str(msg.toXML(true,2U));
- printf("%s\n", str.c_str());
+ printf("%s\n", msg.toString(true).c_str());
}
void reportProgress(const
@@ -70,28 +66,38 @@ int main()
{
char data[4096] = {0};
+ const char *query_string = getenv("QUERY_STRING");
+ if (query_string)
+ std::strncpy(data, query_string, sizeof(data)-2);
+
const char *lenstr = getenv("CONTENT_LENGTH");
if (lenstr) {
int len = std::min(1 + atoi(lenstr), (int)(sizeof(data) - 2));
fgets(data, len, stdin);
- } else {
- const char *s = getenv("QUERY_STRING");
- std::strncpy(data, s?s:"", sizeof(data)-2);
}
char code[4096] = {0};
unencode(data, code);
+ if (strlen(code) > 1000) {
+ puts("Content-type: text/html\r\n\r\n");
+ puts("<html><body>For performance reasons the code must be shorter than 1000 chars.</body></html>");
+ return EXIT_SUCCESS;
+ }
+
FILE *logfile = fopen("democlient.log", "at");
if (logfile != NULL) {
fprintf(logfile, "===========================================================\n%s\n", code);
fclose(logfile);
}
- printf("Content-type: text/plain\n\n");
+ puts("Content-type: text/html\r\n\r\n");
+ puts("<html><body><pre>");
CppcheckExecutor cppcheckExecutor;
cppcheckExecutor.run(code);
+ puts("</pre>Done!</body></html>");
+
return EXIT_SUCCESS;
}
2  htdocs/demo/index.php
View
@@ -46,7 +46,7 @@ function checkCodeLength() {
<div id="content">
<div class="wrap">
<h2>Online Demo</h2>
-<form action="/demo/report/" name="f" onsubmit="return checkCodeLength();" method="post" target="_blank">
+<form action="/cgi-bin/democlient-test.cgi" name="f" onsubmit="return checkCodeLength();" method="get" target="_blank">
<p><label for="code">Enter code:</label> <span class="maxChars">(max 1024 characters)</span><br />
<textarea id="code" name="code" rows="20" cols="80">
void f()
1  runastyle
View
@@ -18,6 +18,7 @@ options="--pad-header --unpad-paren --suffix=none --convert-tabs"
astyle $style $options cli/*.cpp
astyle $style $options cli/*.h
+astyle $style $options democlient/*.cpp
astyle $style $options gui/*.cpp
astyle $style $options gui/*.h
astyle $style $options -r gui/test/*.cpp
Please sign in to comment.
Something went wrong with that request. Please try again.