Skip to content

Commit

Permalink
democlient: skip the leading 'code='. output warnings in the log.
Browse files Browse the repository at this point in the history
  • Loading branch information
danmar committed Nov 23, 2015
1 parent e818239 commit 9f41fcf
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions democlient/democlient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,15 @@ class CppcheckExecutor : public ErrorLogger {

void reportOut(const std::string &outmsg) { }
void reportErr(const ErrorLogger::ErrorMessage &msg) {
printf("%s\n", msg.toString(true).c_str());
const std::string s = msg.toString(true);

printf("%s\n", s.c_str());

FILE *logfile = fopen("democlient.log", "at");
if (logfile != NULL) {
fprintf(logfile, "%s\n", s.c_str());
fclose(logfile);
}
}

void reportProgress(const
Expand Down Expand Up @@ -76,15 +84,19 @@ int main()
fgets(data, len, stdin);
}

char code[4096] = {0};
unencode(data, code);

if (strlen(code) > 1000) {
if (data[4000] != '\0') {
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;
}

const char *pdata = data;
if (std::strncmp(pdata, "code=", 5)==0)
pdata += 5;

char code[4096] = {0};
unencode(pdata, code);

FILE *logfile = fopen("democlient.log", "at");
if (logfile != NULL) {
fprintf(logfile, "===========================================================\n%s\n", code);
Expand Down

0 comments on commit 9f41fcf

Please sign in to comment.