Improve libswmhack.

Refactor the code so that the error checking is not duplicated every time
dlopen() or dlsym() are called. If either fails, use exit() instead of
assert() to abort the running program.