Fix subscribe_multiple datatypes.
This commit is contained in:
parent
1635dd3883
commit
366744bad7
@ -96,7 +96,7 @@ void my_connect_callback(struct mosquitto *mosq, void *obj, int result, int flag
|
||||
cfg = (struct mosq_config *)obj;
|
||||
|
||||
if(!result){
|
||||
mosquitto_subscribe_multiple(mosq, NULL, cfg->topic_count, (const char **)cfg->topics, cfg->qos);
|
||||
mosquitto_subscribe_multiple(mosq, NULL, cfg->topic_count, cfg->topics, cfg->qos);
|
||||
|
||||
for(i=0; i<cfg->unsub_topic_count; i++){
|
||||
mosquitto_unsubscribe(mosq, NULL, cfg->unsub_topics[i]);
|
||||
|
@ -105,11 +105,11 @@ int mosquitto_subscribe(struct mosquitto *mosq, int *mid, const char *sub, int q
|
||||
if(mosquitto_sub_topic_check(sub)) return MOSQ_ERR_INVAL;
|
||||
if(mosquitto_validate_utf8(sub, strlen(sub))) return MOSQ_ERR_MALFORMED_UTF8;
|
||||
|
||||
return send__subscribe(mosq, mid, 1, &sub, qos);
|
||||
return send__subscribe(mosq, mid, 1, (char *const *const)&sub, qos);
|
||||
}
|
||||
|
||||
|
||||
int mosquitto_subscribe_multiple(struct mosquitto *mosq, int *mid, int sub_count, const char **sub, int qos)
|
||||
int mosquitto_subscribe_multiple(struct mosquitto *mosq, int *mid, int sub_count, char *const *const sub, int qos)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -646,6 +646,10 @@ libmosq_EXPORT int mosquitto_subscribe(struct mosquitto *mosq, int *mid, const c
|
||||
* sent.
|
||||
* sub_count - the count of subscriptions to be made
|
||||
* sub - array of sub_count pointers, each pointing to a subscription string.
|
||||
* The "char *const *const" datatype ensures that neither the array of
|
||||
* pointers nor the strings that they point to are mutable. If you aren't
|
||||
* familiar with this, just think of it as a safer "char **",
|
||||
* equivalent to "const char *" for a simple string pointer.
|
||||
* qos - the requested Quality of Service for each subscription.
|
||||
*
|
||||
* Returns:
|
||||
@ -655,7 +659,7 @@ libmosq_EXPORT int mosquitto_subscribe(struct mosquitto *mosq, int *mid, const c
|
||||
* MOSQ_ERR_NO_CONN - if the client isn't connected to a broker.
|
||||
* MOSQ_ERR_MALFORMED_UTF8 - if a topic is not valid UTF-8
|
||||
*/
|
||||
int mosquitto_subscribe_multiple(struct mosquitto *mosq, int *mid, int sub_count, const char **sub, int qos);
|
||||
int mosquitto_subscribe_multiple(struct mosquitto *mosq, int *mid, int sub_count, char *const *const sub, int qos);
|
||||
|
||||
/*
|
||||
* Function: mosquitto_unsubscribe
|
||||
|
@ -31,7 +31,7 @@ int send__pubcomp(struct mosquitto *mosq, uint16_t mid);
|
||||
int send__publish(struct mosquitto *mosq, uint16_t mid, const char *topic, uint32_t payloadlen, const void *payload, int qos, bool retain, bool dup);
|
||||
int send__pubrec(struct mosquitto *mosq, uint16_t mid);
|
||||
int send__pubrel(struct mosquitto *mosq, uint16_t mid);
|
||||
int send__subscribe(struct mosquitto *mosq, int *mid, int topic_count, const char **topic, int topic_qos);
|
||||
int send__subscribe(struct mosquitto *mosq, int *mid, int topic_count, char *const *const topic, int topic_qos);
|
||||
int send__unsubscribe(struct mosquitto *mosq, int *mid, const char *topic);
|
||||
|
||||
#endif
|
||||
|
@ -76,7 +76,7 @@ int handle__connack(struct mosquitto_db *db, struct mosquitto *context)
|
||||
}
|
||||
for(i=0; i<context->bridge->topic_count; i++){
|
||||
if(context->bridge->topics[i].direction == bd_in || context->bridge->topics[i].direction == bd_both){
|
||||
if(send__subscribe(context, NULL, 1, &context->bridge->topics[i].remote_topic, &context->bridge->topics[i].qos)){
|
||||
if(send__subscribe(context, NULL, 1, &context->bridge->topics[i].remote_topic, context->bridge->topics[i].qos)){
|
||||
return 1;
|
||||
}
|
||||
}else{
|
||||
|
Loading…
Reference in New Issue
Block a user