[server] correct usage of g_strndup

  - g_strndup will always allocate a n+1 bytes string, and terminate it by NULL.
  - there is no need for manually doing this.
  - see more at glib's source (glib/gstrfuncs.c)
  - see more at glib's document
    https://developer.gnome.org/glib/2.28/glib-String-Utility-Functions.html
Merge pull request #703 from Chilledheart/correct_usage_of_g_strndup

[server] correct usage of g_strndup
fixed strftime on win32 server, Closes haiwen/seafile-client#134
Merge pull request #710 from haiwen/fix-win-strftime

fixed strftime on win32 server, Closes haiwen/seafile-client#134
[lib] better byte ordering detection

     - originally inspired by redis (src/config.h) and
       llvm (include/llvm/Support/Host.h)
     - BSDs detection inspired by this platform detection manual
       http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefined_macros_detect_operating_system#BSD
     - Apple's OSX and iOS is based on a fork of FreeBSD, including
       machine/endian.h as what we do to other BSDs should be enough.