democlient: skip the leading 'code='. output warnings in the log.

This commit is contained in:
Daniel Marjamäki 2015-11-23 09:27:33 +01:00
parent e8182395f7
commit 9f41fcfbcb
1 changed files with 17 additions and 5 deletions

View File

@ -44,7 +44,15 @@ public:
void reportOut(const std::string &outmsg) { } void reportOut(const std::string &outmsg) { }
void reportErr(const ErrorLogger::ErrorMessage &msg) { 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 void reportProgress(const
@ -76,15 +84,19 @@ int main()
fgets(data, len, stdin); fgets(data, len, stdin);
} }
char code[4096] = {0}; if (data[4000] != '\0') {
unencode(data, code);
if (strlen(code) > 1000) {
puts("Content-type: text/html\r\n\r\n"); 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>"); puts("<html><body>For performance reasons the code must be shorter than 1000 chars.</body></html>");
return EXIT_SUCCESS; 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"); FILE *logfile = fopen("democlient.log", "at");
if (logfile != NULL) { if (logfile != NULL) {
fprintf(logfile, "===========================================================\n%s\n", code); fprintf(logfile, "===========================================================\n%s\n", code);