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: 05-Jul-2016 21:48:14 Branch: rpm-5_4 Handle: 2016070519481301 Modified files: (Branch: rpm-5_4) rpm/rpmio rpmmqtt.c rpmmqtt.h Log: - mqtt: resurrect --without-mqtt build. Summary: Revision Changes Path 1.1.2.16 +49 -28 rpm/rpmio/rpmmqtt.c 1.1.2.14 +2 -7 rpm/rpmio/rpmmqtt.h ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/rpmio/rpmmqtt.c ============================================================================ $ cvs diff -u -r1.1.2.15 -r1.1.2.16 rpmmqtt.c --- rpm/rpmio/rpmmqtt.c 5 Jul 2016 15:58:33 -0000 1.1.2.15 +++ rpm/rpmio/rpmmqtt.c 5 Jul 2016 19:48:13 -0000 1.1.2.16 @@ -832,37 +832,52 @@ /*==============================================================*/ +#ifdef WITH_MQTT +struct mqttState_s { + MQTTAsync_connectOptions C; + MQTTAsync_willOptions W; + MQTTAsync_SSLOptions S; + MQTTAsync_disconnectOptions D; + MQTTAsync_responseOptions R; + MQTTAsync_createOptions O; + MQTTAsync_message M; +}; + +static struct mqttState_s mqttStateInitial = { + .C = MQTTAsync_connectOptions_initializer, + .W = MQTTAsync_willOptions_initializer, + .S = MQTTAsync_SSLOptions_initializer, + .D = MQTTAsync_disconnectOptions_initializer, + .R = MQTTAsync_responseOptions_initializer, + .O = MQTTAsync_createOptions_initializer, + .M = MQTTAsync_message_initializer, +}; +#endif /* WITH_MQTT */ + static void * AOBJ(rpmmqtt mqtt, char otype) { void * ptr = NULL; #ifdef WITH_MQTT - static const MQTTAsync_connectOptions _C = - MQTTAsync_connectOptions_initializer; - MQTTAsync_connectOptions *C = &mqtt->C; - static const MQTTAsync_disconnectOptions _D = - MQTTAsync_disconnectOptions_initializer; - MQTTAsync_disconnectOptions *D = &mqtt->D; - static const MQTTAsync_message _M = - MQTTAsync_message_initializer; - MQTTAsync_message *M = &mqtt->M; - static const MQTTAsync_createOptions _O = - MQTTAsync_createOptions_initializer; - MQTTAsync_createOptions *O = &mqtt->O; - static const MQTTAsync_responseOptions _R = - MQTTAsync_responseOptions_initializer; - MQTTAsync_responseOptions *R = &mqtt->R; - static const MQTTAsync_SSLOptions _S = - MQTTAsync_SSLOptions_initializer; - MQTTAsync_SSLOptions *S = &mqtt->S; - static const MQTTAsync_willOptions _W = - MQTTAsync_willOptions_initializer; - MQTTAsync_willOptions *W = &mqtt->W; + mqttState p = NULL; + mqttState q = &mqttStateInitial; + MQTTAsync_connectOptions *C; + MQTTAsync_disconnectOptions *D; + MQTTAsync_message *M; + MQTTAsync_createOptions *O; + MQTTAsync_responseOptions *R; + MQTTAsync_SSLOptions *S; + MQTTAsync_willOptions *W; urlinfo u; + if (mqtt->state == NULL) + mqtt->state = xcalloc(1, sizeof(*p)); + p = (mqttState) mqtt->state; + switch (otype) { case 'C': u = mqtt->u; - memcpy(C, &_C, sizeof(*C)); + C = &p->C; + memcpy(C, &q->C, sizeof(*C)); C->keepAliveInterval = mqtt->keepalive; C->cleansession = (MF_ISSET(CLEAN) ? 1 : 0); C->maxInflight = mqtt->max_inflight; @@ -901,7 +916,8 @@ ptr = (void *) C; break; case 'D': - memcpy(D, &_D, sizeof(*D)); + D = &p->D; + memcpy(D, &q->D, sizeof(*D)); D->timeout = mqtt->timeout; D->onSuccess = onDisconnect; D->onFailure = onDisconnectFailure; @@ -909,7 +925,8 @@ ptr = (void *) D; break; case 'M': - memcpy(M, &_M, sizeof(*M)); + M = &p->M; + memcpy(M, &q->M, sizeof(*M)); M->payloadlen = 0; M->payload = ""; M->qos = mqtt->qos; @@ -919,13 +936,15 @@ ptr = (void *) M; break; case 'O': - memcpy(O, &_O, sizeof(*O)); + O = &p->O; + memcpy(O, &q->O, sizeof(*O)); O->sendWhileDisconnected = 1; /* XXX = 0 */ O->maxBufferedMessages = 100; ptr = (void *) O; break; case 'R': - memcpy(R, &_R, sizeof(*R)); + R = &p->R; + memcpy(R, &q->R, sizeof(*R)); R->onSuccess = NULL; /* XXX multiple uses */ R->onFailure = NULL; /* XXX multiple uses */ R->context = mqtt; @@ -933,7 +952,8 @@ ptr = (void *) R; break; case 'S': - memcpy(S, &_S, sizeof(*S)); + S = &p->S; + memcpy(S, &q->S, sizeof(*S)); S->trustStore = mqtt->cafile; S->keyStore = mqtt->cert; S->privateKey = mqtt->privkey; @@ -942,7 +962,8 @@ ptr = (void *) S; break; case 'W': - memcpy(W, &_W, sizeof(*W)); + W = &p->W; + memcpy(W, &q->W, sizeof(*W)); W->topicName = (mqtt->will_topic ? mqtt->will_topic : mqtt->topic); W->message = (mqtt->will_message ? mqtt->will_message : ""); W->retained = (MF_ISSET(WILL_RETAIN) ? 1 : 0); @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmmqtt.h ============================================================================ $ cvs diff -u -r1.1.2.13 -r1.1.2.14 rpmmqtt.h --- rpm/rpmio/rpmmqtt.h 5 Jul 2016 14:49:11 -0000 1.1.2.13 +++ rpm/rpmio/rpmmqtt.h 5 Jul 2016 19:48:14 -0000 1.1.2.14 @@ -8,6 +8,7 @@ extern int _rpmmqtt_debug; typedef struct rpmmqtt_s * rpmmqtt; +typedef struct mqttState_s * mqttState; #define _KFB(n) (1U << (n)) #define _MFB(n) (_KFB(n) | 0x40000000) @@ -127,13 +128,7 @@ const char * ofn; /*!< -o */ rpmiob iob; - MQTTAsync_connectOptions C; - MQTTAsync_willOptions W; - MQTTAsync_SSLOptions S; - MQTTAsync_disconnectOptions D; - MQTTAsync_responseOptions R; - MQTTAsync_createOptions O; - MQTTAsync_message M; + mqttState state; }; #endif /* _RPMMQTT_INTERNAL */ @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org