mirror of
https://github.com/eclipse-mosquitto/mosquitto.git
synced 2026-09-22 16:15:05 +08:00
Add plugin version helper.
This commit is contained in:
@@ -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; i<supported_version_count; i++){ \
|
||||
if(supported_versions[i] == (A)){ \
|
||||
return (A); \
|
||||
} \
|
||||
} \
|
||||
return -1; \
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: mosquitto_plugin_init
|
||||
*
|
||||
|
||||
@@ -33,6 +33,8 @@ Contributors:
|
||||
|
||||
#include "dynamic_security.h"
|
||||
|
||||
MOSQUITTO_PLUGIN_DECLARE_VERSION(5);
|
||||
|
||||
static mosquitto_plugin_id_t *plg_id = NULL;
|
||||
static char *config_file = NULL;
|
||||
struct dynsec__acl_default_access default_access = {false, false, false, false};
|
||||
@@ -274,18 +276,6 @@ internal_error:
|
||||
}
|
||||
|
||||
|
||||
int mosquitto_plugin_version(int supported_version_count, const int *supported_versions)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0; i<supported_version_count; i++){
|
||||
if(supported_versions[i] == 5){
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int dynsec__general_config_load(cJSON *tree)
|
||||
{
|
||||
cJSON *j_default_access, *jtmp;
|
||||
|
||||
@@ -46,6 +46,8 @@ Contributors:
|
||||
#define PLUGIN_NAME "add-properties"
|
||||
#define PLUGIN_VERSION "1.0"
|
||||
|
||||
MOSQUITTO_PLUGIN_DECLARE_VERSION(5);
|
||||
|
||||
static mosquitto_plugin_id_t *mosq_pid = NULL;
|
||||
|
||||
static int callback_message(int event, void *event_data, void *userdata)
|
||||
@@ -89,18 +91,6 @@ static int callback_message(int event, void *event_data, void *userdata)
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_plugin_version(int supported_version_count, const int *supported_versions)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0; i<supported_version_count; i++){
|
||||
if(supported_versions[i] == 5){
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **user_data, struct mosquitto_opt *opts, int opt_count)
|
||||
{
|
||||
UNUSED(user_data);
|
||||
|
||||
@@ -45,6 +45,8 @@ Contributors:
|
||||
#define PLUGIN_NAME "auth-by-ip"
|
||||
#define PLUGIN_VERSION "1.0"
|
||||
|
||||
MOSQUITTO_PLUGIN_DECLARE_VERSION(5);
|
||||
|
||||
static mosquitto_plugin_id_t *mosq_pid = NULL;
|
||||
|
||||
static int basic_auth_callback(int event, void *event_data, void *userdata)
|
||||
@@ -64,18 +66,6 @@ static int basic_auth_callback(int event, void *event_data, void *userdata)
|
||||
}
|
||||
}
|
||||
|
||||
int mosquitto_plugin_version(int supported_version_count, const int *supported_versions)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0; i<supported_version_count; i++){
|
||||
if(supported_versions[i] == 5){
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **user_data, struct mosquitto_opt *opts, int opt_count)
|
||||
{
|
||||
UNUSED(user_data);
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
#define UNUSED(A) (void)(A)
|
||||
|
||||
MOSQUITTO_PLUGIN_DECLARE_VERSION(5);
|
||||
|
||||
static mosquitto_plugin_id_t *mosq_pid = NULL;
|
||||
|
||||
static int callback_message(int event, void *event_data, void *userdata)
|
||||
@@ -41,18 +43,6 @@ static int callback_message(int event, void *event_data, void *userdata)
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_plugin_version(int supported_version_count, const int *supported_versions)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0; i<supported_version_count; i++){
|
||||
if(supported_versions[i] == 5){
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **user_data, struct mosquitto_opt *opts, int opt_count)
|
||||
{
|
||||
UNUSED(user_data);
|
||||
|
||||
@@ -45,6 +45,8 @@ Contributors:
|
||||
|
||||
#define UNUSED(A) (void)(A)
|
||||
|
||||
MOSQUITTO_PLUGIN_DECLARE_VERSION(5);
|
||||
|
||||
static mosquitto_plugin_id_t *mosq_pid = NULL;
|
||||
|
||||
static int connect_callback(int event, void *event_data, void *userdata)
|
||||
@@ -97,18 +99,6 @@ static int disconnect_callback(int event, void *event_data, void *userdata)
|
||||
}
|
||||
|
||||
|
||||
int mosquitto_plugin_version(int supported_version_count, const int *supported_versions)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0; i<supported_version_count; i++){
|
||||
if(supported_versions[i] == 5){
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **user_data, struct mosquitto_opt *opts, int opt_count)
|
||||
{
|
||||
int rc;
|
||||
|
||||
@@ -51,6 +51,8 @@ Contributors:
|
||||
# define UNUSED(A) (void)(A)
|
||||
#endif
|
||||
|
||||
MOSQUITTO_PLUGIN_DECLARE_VERSION(5);
|
||||
|
||||
struct client_list{
|
||||
UT_hash_handle hh;
|
||||
char *id;
|
||||
@@ -141,18 +143,6 @@ static int tick_callback(int event, void *event_data, void *userdata)
|
||||
}
|
||||
|
||||
|
||||
int mosquitto_plugin_version(int supported_version_count, const int *supported_versions)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0; i<supported_version_count; i++){
|
||||
if(supported_versions[i] == 5){
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **user_data, struct mosquitto_opt *opts, int opt_count)
|
||||
{
|
||||
int rc;
|
||||
|
||||
@@ -42,6 +42,8 @@ Contributors:
|
||||
|
||||
#define UNUSED(A) (void)(A)
|
||||
|
||||
MOSQUITTO_PLUGIN_DECLARE_VERSION(5);
|
||||
|
||||
static mosquitto_plugin_id_t *mosq_pid = NULL;
|
||||
|
||||
static int callback_message(int event, void *event_data, void *userdata)
|
||||
@@ -56,18 +58,6 @@ static int callback_message(int event, void *event_data, void *userdata)
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_plugin_version(int supported_version_count, const int *supported_versions)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0; i<supported_version_count; i++){
|
||||
if(supported_versions[i] == 5){
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **user_data, struct mosquitto_opt *opts, int opt_count)
|
||||
{
|
||||
UNUSED(user_data);
|
||||
|
||||
@@ -41,6 +41,8 @@ Contributors:
|
||||
#define PLUGIN_NAME "message-timestamp"
|
||||
#define PLUGIN_VERSION "1.0"
|
||||
|
||||
MOSQUITTO_PLUGIN_DECLARE_VERSION(5);
|
||||
|
||||
static mosquitto_plugin_id_t *mosq_pid = NULL;
|
||||
|
||||
static int callback_message(int event, void *event_data, void *userdata)
|
||||
@@ -60,18 +62,6 @@ static int callback_message(int event, void *event_data, void *userdata)
|
||||
return mosquitto_property_add_string_pair(&ed->properties, 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<supported_version_count; i++){
|
||||
if(supported_versions[i] == 5){
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **user_data, struct mosquitto_opt *opts, int opt_count)
|
||||
{
|
||||
UNUSED(user_data);
|
||||
|
||||
@@ -45,6 +45,8 @@ Contributors:
|
||||
|
||||
#define UNUSED(A) (void)(A)
|
||||
|
||||
MOSQUITTO_PLUGIN_DECLARE_VERSION(5);
|
||||
|
||||
static mosquitto_plugin_id_t *mosq_pid = NULL;
|
||||
|
||||
static int callback_message(int event, void *event_data, void *userdata)
|
||||
@@ -83,18 +85,6 @@ static int callback_message(int event, void *event_data, void *userdata)
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_plugin_version(int supported_version_count, const int *supported_versions)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0; i<supported_version_count; i++){
|
||||
if(supported_versions[i] == 5){
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **user_data, struct mosquitto_opt *opts, int opt_count)
|
||||
{
|
||||
UNUSED(user_data);
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#define PLUGIN_NAME "print-ip-on-publish"
|
||||
#define PLUGIN_VERSION "1.0"
|
||||
|
||||
MOSQUITTO_PLUGIN_DECLARE_VERSION(5);
|
||||
|
||||
static mosquitto_plugin_id_t *mosq_pid = NULL;
|
||||
|
||||
static char my_topic[] = "troublesome/topic";
|
||||
@@ -30,18 +32,6 @@ static int message_callback(int event, void *event_data, void *userdata)
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_plugin_version(int supported_version_count, const int *supported_versions)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0; i<supported_version_count; i++){
|
||||
if(supported_versions[i] == 5){
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **user_data, struct mosquitto_opt *opts, int opt_count)
|
||||
{
|
||||
UNUSED(user_data);
|
||||
|
||||
@@ -45,6 +45,8 @@ Contributors:
|
||||
|
||||
#define UNUSED(A) (void)(A)
|
||||
|
||||
MOSQUITTO_PLUGIN_DECLARE_VERSION(5);
|
||||
|
||||
static mosquitto_plugin_id_t *mosq_pid = NULL;
|
||||
|
||||
static int callback_message(int event, void *event_data, void *userdata)
|
||||
@@ -67,18 +69,6 @@ static int callback_message(int event, void *event_data, void *userdata)
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_plugin_version(int supported_version_count, const int *supported_versions)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0; i<supported_version_count; i++){
|
||||
if(supported_versions[i] == 5){
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **user_data, struct mosquitto_opt *opts, int opt_count)
|
||||
{
|
||||
UNUSED(user_data);
|
||||
|
||||
Reference in New Issue
Block a user