improved ffi error checking

Signed-off-by: Jan Dvořák <mordae@anilinux.org>
added some basic domain operations

Signed-off-by: Jan Dvořák <mordae@anilinux.org>