Use BUF_strlcpy instead of strlcpy for portability.
Add support for XPC service.

Remove some warnings.