From 6763d94962b0377be72be2e945d15fbc6ef58c1b Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Thu, 30 Sep 2021 10:56:48 +0100 Subject: [PATCH] Add plugin version helper. --- include/mosquitto_plugin.h | 17 +++++++++++++++++ plugins/dynamic-security/plugin.c | 14 ++------------ .../add-properties/mosquitto_add_properties.c | 14 ++------------ .../examples/auth-by-ip/mosquitto_auth_by_ip.c | 14 ++------------ .../mosquitto_client_properties.c | 14 ++------------ .../mosquitto_connection_state.c | 14 ++------------ .../delayed-auth/mosquitto_delayed_auth.c | 14 ++------------ .../force-retain/mosquitto_force_retain.c | 14 ++------------ .../mosquitto_message_timestamp.c | 14 ++------------ .../mosquitto_payload_modification.c | 14 ++------------ .../mosquitto_print_ip_on_publish.c | 14 ++------------ .../mosquitto_topic_modification.c | 14 ++------------ 12 files changed, 39 insertions(+), 132 deletions(-) diff --git a/include/mosquitto_plugin.h b/include/mosquitto_plugin.h index d8a6c72c..447f4b89 100644 --- a/include/mosquitto_plugin.h +++ b/include/mosquitto_plugin.h @@ -140,9 +140,26 @@ struct mosquitto_acl_msg { * * If the broker does not support the version that you require, return -1 to * indicate failure. + * + * HELPER: If you only wish to declare support for a single version, you can + * use the helper macro: + * + * MOSQUITTO_PLUGIN_DECLARE_VERSION(5); */ mosq_plugin_EXPORT int mosquitto_plugin_version(int supported_version_count, const int *supported_versions); +#define MOSQUITTO_PLUGIN_DECLARE_VERSION(A) \ + int mosquitto_plugin_version(int supported_version_count, const int *supported_versions) \ + { \ + int i; \ + for(i=0; iproperties, MQTT_PROP_USER_PROPERTY, "timestamp", time_buf); } -int mosquitto_plugin_version(int supported_version_count, const int *supported_versions) -{ - int i; - - for(i=0; i