added strndup() for systems that don't have it