removed sizeof(char)

sizeof(char) == 1 according to standard
refactored mkdir_recursive

Now this function returns result of operation. TRUE is success.
most FREE_SET_NULL replaced with free

FREE_SET_NULL makes extra assignment of NULL for pointers in stack or
dynamic memory that is going to be freed.
FREE_SET_NULL is useful for pointers that can be used in future.
refactored logging

Use ftell instead of stat syscall to increase portability.
fixed memory leaks

Also avoided several NULL pointer dereferences.
replace struct stat and stat() for windows
removed assignment to NULL in _chat_session_free
use posix stat syscall for windows
Merge remote-tracking branch 'dmitry/nextdev-patches' into nextdev