Skip to content

Commit

Permalink
[111] Add mosquitto_userdata function to libmosquitto.
Browse files Browse the repository at this point in the history
This allows retrieving mosq->userdata.

Bug: #111
  • Loading branch information
ralight committed Feb 19, 2017
1 parent f72d9b3 commit e4e81a0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ Client library:
according to the UTF-8 spec and to the additional restrictions imposed by
the MQTT spec.
- Topic inputs are checked for UTF-8 validity.
- Add mosquitto_userdata function to allow retrieving the client userdata
member variable. Closes #111.

Client:
- Add -F to mosquitto_sub to allow the user to choose the output format.
Expand Down
1 change: 1 addition & 0 deletions lib/linker.version
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,5 @@ MOSQ_1.5 {
mosquitto_subscribe_callback;
mosquitto_message_free_contents;
mosquitto_validate_utf8;
mosquitto_userdata;
} MOSQ_1.4;
19 changes: 17 additions & 2 deletions lib/mosquitto.h
Original file line number Diff line number Diff line change
Expand Up @@ -1002,15 +1002,17 @@ libmosq_EXPORT int mosquitto_opts_set(struct mosquitto *mosq, enum mosq_opt_t op
* Your callback must write the password into "buf", which is
* "size" bytes long. The return value must be the length of the
* password. "userdata" will be set to the calling mosquitto
* instance.
* instance. The mosquitto userdata member variable can be
* retrieved using <mosquitto_userdata>.
*
* Returns:
* MOSQ_ERR_SUCCESS - on success.
* MOSQ_ERR_INVAL - if the input parameters were invalid.
* MOSQ_ERR_NOMEM - if an out of memory condition occurred.
*
* See Also:
* <mosquitto_tls_opts_set>, <mosquitto_tls_psk_set>, <mosquitto_tls_insecure_set>
* <mosquitto_tls_opts_set>, <mosquitto_tls_psk_set>,
* <mosquitto_tls_insecure_set>, <mosquitto_userdata>
*/
libmosq_EXPORT int mosquitto_tls_set(struct mosquitto *mosq,
const char *cafile, const char *capath,
Expand Down Expand Up @@ -1692,6 +1694,19 @@ libmosq_EXPORT int mosquitto_subscribe_callback(
*/
libmosq_EXPORT int mosquitto_validate_utf8(const char *str, int len);


/* Function: mosquitto_userdata
*
* Retrieve the "userdata" variable for a mosquitto client.
*
* Parameters:
* mosq - a valid mosquitto instance.
*
* Returns:
* A pointer to the userdata member variable.
*/
libmosq_EXPORT void *mosquitto_userdata(struct mosquitto *mosq);

#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit e4e81a0

Please sign in to comment.