RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: j...@rpm5.org Module: rpm Date: 30-Jun-2016 15:40:17 Branch: rpm-5_4 Handle: 2016063013401700 Modified files: (Branch: rpm-5_4) rpm/rpmio rpmmqtt.c Log: - mqtt: more --without-mqtt portability. Summary: Revision Changes Path 1.1.2.7 +20 -3 rpm/rpmio/rpmmqtt.c ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/rpmio/rpmmqtt.c ============================================================================ $ cvs diff -u -r1.1.2.6 -r1.1.2.7 rpmmqtt.c --- rpm/rpmio/rpmmqtt.c 30 Jun 2016 13:29:23 -0000 1.1.2.6 +++ rpm/rpmio/rpmmqtt.c 30 Jun 2016 13:40:17 -0000 1.1.2.7 @@ -16,6 +16,10 @@ #ifdef WITH_MQTT #include <MQTTAsync.h> +#else +#define MQTTAsync_message void +#define MQTTAsync_successData void +#define MQTTAsync_failureData void #endif #define _RPMMQTT_INTERNAL #include <rpmmqtt.h> @@ -85,9 +89,6 @@ Xcheck(_o, _m, _rc, _rpmmqtt_debug, __FUNCTION__, __FILE__, __LINE__) /*==============================================================*/ -struct MQTTAsync_message; -struct MQTTAsync_successData; -struct MQTTAsync_failureData; static int onMessageArrived(void * _mqtt, char * topic, int topicLen, MQTTAsync_message * message) @@ -143,6 +144,7 @@ { rpmmqtt mqtt = (rpmmqtt) _mqtt; fprintf(stderr, "<-- %s(%p,%p) MQTT disconnect failed\n", __FUNCTION__, _mqtt, response); +#ifdef WITH_MQTT if (response) { const char *s = response->message; int token = response->token; @@ -152,6 +154,7 @@ token, code, s); } else rpmlog(RPMLOG_WARNING, "MQTT disconnect failed\n"); +#endif mqtt->connected = 0; mqtt->finished = 1; } @@ -160,10 +163,12 @@ { rpmmqtt mqtt = (rpmmqtt) _mqtt; +#ifdef WITH_MQTT if (mqtt->debug || _rpmmqtt_debug) rpmlog(RPMLOG_DEBUG, "MQTT disconnect(%s) version(%d) present(%d)\n", mqtt->serverURI, mqtt->MQTTVersion, mqtt->sessionPresent); +#endif mqtt->serverURI = _free(mqtt->serverURI); mqtt->connected = 0; mqtt->finished = 1; @@ -173,6 +178,7 @@ { rpmmqtt mqtt = (rpmmqtt) _mqtt; fprintf(stderr, "<-- %s(%p,%p) MQTT connect failed\n", __FUNCTION__, _mqtt, response); +#ifdef WITH_MQTT if (response) { const char *s = response->message; int token = response->token; @@ -181,6 +187,7 @@ token, code, s); } else rpmlog(RPMLOG_WARNING, "MQTT connect failed\n"); +#endif mqtt->connected = 0; mqtt->finished = 1; } @@ -189,6 +196,7 @@ { rpmmqtt mqtt = (rpmmqtt) _mqtt; +#ifdef WITH_MQTT if (response) { mqtt->serverURI = xstrdup(response->alt.connect.serverURI); mqtt->MQTTVersion = response->alt.connect.MQTTVersion; @@ -199,6 +207,7 @@ rpmlog(RPMLOG_DEBUG, "MQTT connect(%s) version(%d) present(%d)\n", mqtt->serverURI, mqtt->MQTTVersion, mqtt->sessionPresent); +#endif mqtt->connected = 1; mqtt->finished = 1; } @@ -207,6 +216,7 @@ { rpmmqtt mqtt = (rpmmqtt) _mqtt; fprintf(stderr, "<-- %s(%p,%p) MQTT connect failed\n", __FUNCTION__, _mqtt, response); +#ifdef WITH_MQTT if (response) { const char *s = response->message; int token = response->token; @@ -215,6 +225,7 @@ token, code, s); } else rpmlog(RPMLOG_WARNING, "MQTT subscribe failed\n"); +#endif mqtt->subscribed = 0; mqtt->finished = 1; } @@ -222,10 +233,12 @@ static void onSubscribe(void * _mqtt, MQTTAsync_successData * response) { rpmmqtt mqtt = (rpmmqtt) _mqtt; +#ifdef WITH_MQTT int qos = (response ? response->alt.qos : mqtt->qos); if (mqtt->debug || _rpmmqtt_debug) rpmlog(RPMLOG_DEBUG, "MQTT subscribe qos(%d)\n", qos); +#endif mqtt->subscribed = 1; mqtt->finished = 1; } @@ -234,6 +247,7 @@ { rpmmqtt mqtt = (rpmmqtt) _mqtt; +#ifdef WITH_MQTT { const char *s = response->message; int token = response->token; @@ -241,6 +255,7 @@ rpmlog(RPMLOG_WARNING, "MQTT send(%d) failed: code(%d) msg %s\n", token, code, s); } +#endif mqtt->finished = 1; } @@ -248,6 +263,7 @@ { rpmmqtt mqtt = (rpmmqtt) _mqtt; +#ifdef WITH_MQTT if (mqtt->debug || _rpmmqtt_debug) { const char * s = response->alt.pub.message.payload; size_t ns = response->alt.pub.message.payloadlen; @@ -255,6 +271,7 @@ rpmlog(RPMLOG_DEBUG, "MQTT sent(%d) topic(%s) \"%.*s\"\n", token, mqtt->topic, ns, s); } +#endif mqtt->finished = 1; } @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org