Merge branch 'Daedaluz-develop' into develop

pull/2485/head
Roger A. Light 4 years ago
commit 6b054b60ea

@ -617,6 +617,21 @@ mosq_EXPORT const char *mosquitto_client_username(const struct mosquitto *client
*/
mosq_EXPORT int mosquitto_set_username(struct mosquitto *client, const char *username);
/* Function: mosquitto_set_clientid
*
* Set the client id for a client.
*
* This effectively forces the client onto another message queue.
* Can be used to scope client ids by prefixing the client id with some user-specific data.
* eg. "client1" could become "user1-client1".
*
* Returns:
* MOSQ_ERR_SUCCESS - on success
* MOSQ_ERR_INVAL - if client is NULL, or if clientid is not a valid utf-8 string
* MOSQ_ERR_NOMEM - on out of memory
*/
mosq_EXPORT int mosquitto_set_clientid(struct mosquitto *client, const char *clientid);
/* =========================================================================
*

@ -54,6 +54,7 @@ _mosquitto_property_read_varint
_mosquitto_pub_topic_check
_mosquitto_realloc
_mosquitto_set_username
_mosquitto_set_clientid
_mosquitto_strdup
_mosquitto_string_to_property_info
_mosquitto_sub_matches_acl

@ -55,6 +55,7 @@
mosquitto_pub_topic_check;
mosquitto_realloc;
mosquitto_set_username;
mosquitto_set_clientid;
mosquitto_strdup;
mosquitto_string_to_property_info;
mosquitto_sub_matches_acl;

@ -318,6 +318,28 @@ int mosquitto_set_username(struct mosquitto *client, const char *username)
}
}
int mosquitto_set_clientid(struct mosquitto *client, const char *clientid)
{
char *u_dup;
char *old;
if(!client) return MOSQ_ERR_INVAL;
int clientid_len = (int)strlen(clientid);
if(mosquitto_validate_utf8(clientid, clientid_len)){
return MOSQ_ERR_INVAL;
}
u_dup = mosquitto__strdup(clientid);
if(!u_dup) return MOSQ_ERR_NOMEM;
old = client->id;
client->id = u_dup;
mosquitto__free(old);
return MOSQ_ERR_SUCCESS;
}
/* Check to see whether durable clients still have rights to their subscriptions. */
static void check_subscription_acls(struct mosquitto *context)

Loading…
Cancel
Save