Problem: selftest failing on libzmq 4.0.x without libsodium

One assertion failure in zcert.c:68, and a bug in zsys_has_curve
which checked 'rc != EINVAL' instead of 'rc != -1'

Solution: fixed these issues.
zsys: don't leak string when realloc fails

We are not interested in realloc since the string is rewritten
in full anyway.  Switch to a more explicit free/malloc style.
Merge pull request #535 from fichtner/realloc_leak

zsys: don't leak string when realloc fails
Merge pull request #536 from hintjens/master

Problem: selftest failing on libzmq 4.0.x without libsodium
Problem: gossip protocol was not broadcasting changes

Due to bug in zproto server engine that was not broadcasting events
properly. Fixed in zproto, engine regenerated here.

Also expanded test case in test_zgossip.c.
Added versioning to zgossip protocol
Merge pull request #537 from hintjens/master

gossip fixes
Merge pull request #538 from ahhentz/master

Trying to fix zbeacon in OSX
Fix CMake include search on MacOS X
Merge pull request #539 from guidefloripa/master

Fix CMake include search on MacOS X
Fix header inclusion order fix
This fixes a header inclusion order bug in czmq_prelude.h

If you're compiling on linux with gcc -std=c99 _AND_
you are including czmq.h _after_ stdint.h _and_
you are not defining _BSD_SOURCE _before_ stdint.h,
uint is not properly defined, causing a build error.
This patch fixes that error. It also fixes the feature detect
code for Linux hosts.
Merge pull request #540 from jricher42/master

Fix header inclusion order fix
Windows zbeacon ZSYS_INTERFACE support and correct default adapter
Default adapter was set to INADDR_ANY, which does not work on Windows when calling getnameinfo.
zbeacon windows interface string comparison fix
Merge pull request #548 from twhittock/win-interface

Windows zbeacon ZSYS_INTERFACE support and correct default adapter
Fix Windows zbeacon port
Problem: does not initialize system before running selftest

This fails on Windows. Solution: call zsys_init() at start of
selftest method.

Fixes #542.
Problem: zsys_file_mode did not return RW attributes on Windows

There was an #ifdef UTYPE_ANDROID in the middle of the Windows
section, which makes no sense.

Solution: remove the #ifdef.

Fixes #543
Problem: initialization sequence was wrong

The sequence has to be:

1. get environment variables, initialize mutex and create socket
   reference list.
2. allow caller to set io_threads, max_sockets
3. create context and then sockets

So bundling (1) and (3) together did not work. Now the context is
created lazily at first zsys_socket(), and the _set methods all call
zsys_init().
Various fixes

Fixes #545
Fixes #544

More work on extended test case for zgossip.