enhancement: sort directory listing output

Also, be a bit more c99 compliant
fix: SIGSEGV when serving 0-sized files