From 04e5a756ba25f79036aa5e03e7412ed5e5539a12 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Wed, 28 Feb 2018 16:23:26 -0800 Subject: fixes #250 nngcat may not build if protocols are missing --- tests/multistress.c | 2 ++ tests/stubs.h | 4 ++++ tools/nngcat/nngcat.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/tests/multistress.c b/tests/multistress.c index 556718fa..0a98d5fc 100644 --- a/tests/multistress.c +++ b/tests/multistress.c @@ -31,6 +31,8 @@ #include #include +#include "stubs.h" + #ifdef NDEBUG #define dprintf(...) #else diff --git a/tests/stubs.h b/tests/stubs.h index 99f92f7d..da3a6d5f 100644 --- a/tests/stubs.h +++ b/tests/stubs.h @@ -94,4 +94,8 @@ nosocket(nng_socket *s) #define nng_respondent0_open nosocket #endif +#ifndef NNG_HAVE_BUS0 +#define nng_bus0_open nosocket +#endif + #endif // STUBS_H diff --git a/tools/nngcat/nngcat.c b/tools/nngcat/nngcat.c index 4e61d41a..728f0c3f 100644 --- a/tools/nngcat/nngcat.c +++ b/tools/nngcat/nngcat.c @@ -787,37 +787,81 @@ main(int ac, const char **av) switch (proto) { case OPT_REQ0: +#ifdef NNG_HAVE_REQ0 rv = nng_req0_open(&sock); +#else + fatal("Protocol not supported."); +#endif break; case OPT_REP0: +#ifdef NNG_HAVE_REP0 rv = nng_rep0_open(&sock); +#else + fatal("Protocol not supported."); +#endif break; case OPT_SUB0: +#ifdef NNG_HAVE_SUB0 rv = nng_sub0_open(&sock); +#else + fatal("Protocol not supported."); +#endif break; case OPT_PUB0: +#ifdef NNG_HAVE_PUB0 rv = nng_pub0_open(&sock); +#else + fatal("Protocol not supported."); +#endif break; case OPT_PAIR0: +#ifdef NNG_HAVE_PAIR0 rv = nng_pair0_open(&sock); +#else + fatal("Protocol not supported."); +#endif break; case OPT_PAIR1: +#ifdef NNG_HAVE_PAIR1 rv = nng_pair1_open(&sock); +#else + fatal("Protocol not supported"); +#endif break; case OPT_BUS0: +#ifdef NNG_HAVE_BUS0 rv = nng_bus0_open(&sock); +#else + fatal("Protocol not supported."); +#endif break; case OPT_PUSH0: +#ifdef NNG_HAVE_PUSH0 rv = nng_push0_open(&sock); +#else + fatal("Protocol not supported."); +#endif break; case OPT_PULL0: +#ifdef NNG_HAVE_PULL0 rv = nng_pull0_open(&sock); +#else + fatal("Protocol not supported."); +#endif break; case OPT_SURVEY0: +#ifdef NNG_HAVE_SURVEYOR0 rv = nng_surveyor0_open(&sock); +#else + fatal("Protocol not supported."); +#endif break; case OPT_RESPOND0: +#ifdef NNG_HAVE_RESPONDENT0 rv = nng_respondent0_open(&sock); +#else + fatal("Protocol not supported"); +#endif break; case 0: default: -- cgit v1.2.3-70-g09d2