xutils: break out string handling and locking

Break out all string handling functions and lockme stuff in order
to further eliminate the big code blob in xutils, so that it can
be easier maintained.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>