Mac OSX port

Around 25% of the sources compile with these changes. Build with:

    cmake . -DCMAKE_BUILD_TYPE=debug -DENABLE_MANPAGES=OFF -DENABLE_PLUGINS=OFF -DENABLE_PLUGIN_SSL=OFF