From e4e81a0fb164016da72609bcb7486a695a3fb7b9 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Sun, 19 Feb 2017 20:45:52 +0000 Subject: [PATCH] [111] Add mosquitto_userdata function to libmosquitto. This allows retrieving mosq->userdata. Bug: https://github.com/eclipse/mosquitto/issues/111 --- ChangeLog.txt | 2 ++ lib/linker.version | 1 + lib/mosquitto.h | 19 +++++++++++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index abb98349..092880e6 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -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. diff --git a/lib/linker.version b/lib/linker.version index 6b03f66d..e07682a1 100644 --- a/lib/linker.version +++ b/lib/linker.version @@ -85,4 +85,5 @@ MOSQ_1.5 { mosquitto_subscribe_callback; mosquitto_message_free_contents; mosquitto_validate_utf8; + mosquitto_userdata; } MOSQ_1.4; diff --git a/lib/mosquitto.h b/lib/mosquitto.h index 70268260..0f8154aa 100644 --- a/lib/mosquitto.h +++ b/lib/mosquitto.h @@ -1002,7 +1002,8 @@ 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 . * * Returns: * MOSQ_ERR_SUCCESS - on success. @@ -1010,7 +1011,8 @@ libmosq_EXPORT int mosquitto_opts_set(struct mosquitto *mosq, enum mosq_opt_t op * MOSQ_ERR_NOMEM - if an out of memory condition occurred. * * See Also: - * , , + * , , + * , */ libmosq_EXPORT int mosquitto_tls_set(struct mosquitto *mosq, const char *cafile, const char *capath, @@ -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