api: Fix C APIs to null-terminate when copying string objects into C strings.
experimental: Add limited FreeBSD support

Tested on FreeBSD 10.0-RELEASE on amd64, clang 3.3 and 3.4.