diff --git a/democlient/democlient.cpp b/democlient/democlient.cpp index c4844169c..997aed421 100644 --- a/democlient/democlient.cpp +++ b/democlient/democlient.cpp @@ -44,7 +44,15 @@ public: 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 @@ -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("For performance reasons the code must be shorter than 1000 chars."); 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);