On the line after the printf where it looks like they’re getting status strings for returns… it looks like there is are three ternary options. Is that right? How does that work?
https://pbs.twimg.com/media/E7mllyLXoAQmjbT?format=png&name=...
https://pbs.twimg.com/media/E7mllyLXoAQmjbT?format=png&name=...
m = n
? /* if (n != 0) */
/* adds index.html if path ends with "/" (means the filename is omitted), otherwise copies zero */
strcpy(b+i-1,b[i-2]-'/'?"":"index.html"),
/* log the requested filename to stdout */
printf("%s\n",b+5),
/* if "/." is in the path or an error occurred while opening the file */
strstr(b,"/.")||!(f=fopen(b+5,"rb"))
? "404 Not Found"
: "200 OK"
: "501 Not Implemented"; /* if (n == 0) */
By filtering filenames with "/." I prevent exploits with ".." and also don't allow to read files starting with a dot, these are hidden files in Unix-like OS.Ok, so sometimes I think I know C pretty well, then I’ll see lunatic code like this and realize I Do Not! Thanks for the answer and reformat.