Callback struct padding for future use.

pull/1865/head
Roger Light 5 years ago
parent bcf7545015
commit 5b4884a855

@ -45,6 +45,7 @@ enum mosquitto_protocol {
* *
* ========================================================================= */ * ========================================================================= */
/* Callback events */
enum mosquitto_plugin_event { enum mosquitto_plugin_event {
MOSQ_EVT_RELOAD = 1, MOSQ_EVT_RELOAD = 1,
MOSQ_EVT_ACL_CHECK = 2, MOSQ_EVT_ACL_CHECK = 2,
@ -56,12 +57,17 @@ enum mosquitto_plugin_event {
MOSQ_EVT_PSK_KEY = 8, MOSQ_EVT_PSK_KEY = 8,
}; };
/* Data for the MOSQ_EVT_RELOAD event */
struct mosquitto_evt_reload { struct mosquitto_evt_reload {
void *future;
struct mosquitto_opt *options; struct mosquitto_opt *options;
int option_count; int option_count;
void *future2[4];
}; };
/* Data for the MOSQ_EVT_ACL_CHECK event */
struct mosquitto_evt_acl_check { struct mosquitto_evt_acl_check {
void *future;
struct mosquitto *client; struct mosquitto *client;
int access; int access;
const char *topic; const char *topic;
@ -70,31 +76,43 @@ struct mosquitto_evt_acl_check {
int qos; int qos;
bool retain; bool retain;
mosquitto_property *properties; mosquitto_property *properties;
void *future2[4];
}; };
/* Data for the MOSQ_EVT_BASIC_AUTH event */
struct mosquitto_evt_basic_auth { struct mosquitto_evt_basic_auth {
void *future;
struct mosquitto *client; struct mosquitto *client;
char *username; char *username;
char *password; char *password;
void *future2[4];
}; };
/* Data for the MOSQ_EVT_PSK_KEY event */
struct mosquitto_evt_psk_key { struct mosquitto_evt_psk_key {
void *future;
struct mosquitto *client; struct mosquitto *client;
const char *hint; const char *hint;
const char *identity; const char *identity;
char *key; char *key;
int max_key_len; int max_key_len;
void *future2[4];
}; };
/* Data for the MOSQ_EVT_EXTENDED_AUTH event */
struct mosquitto_evt_extended_auth { struct mosquitto_evt_extended_auth {
void *future;
struct mosquitto *client; struct mosquitto *client;
const void *data_in; const void *data_in;
void *data_out; void *data_out;
uint16_t data_in_len; uint16_t data_in_len;
uint16_t data_out_len; uint16_t data_out_len;
void *future2[4];
}; };
/* Data for the MOSQ_EVT_CONTROL event */
struct mosquitto_evt_control { struct mosquitto_evt_control {
void *future;
struct mosquitto *client; struct mosquitto *client;
const char *topic; const char *topic;
const void *payload; const void *payload;
@ -104,9 +122,12 @@ struct mosquitto_evt_control {
int qos; int qos;
uint8_t reason_code; uint8_t reason_code;
bool retain; bool retain;
void *future2[4];
}; };
/* Data for the MOSQ_EVT_MESSAGE event */
struct mosquitto_evt_message { struct mosquitto_evt_message {
void *future;
struct mosquitto *client; struct mosquitto *client;
char *topic; char *topic;
void *payload; void *payload;
@ -116,6 +137,7 @@ struct mosquitto_evt_message {
int qos; int qos;
uint8_t reason_code; uint8_t reason_code;
bool retain; bool retain;
void *future2[4];
}; };

@ -150,7 +150,12 @@ int plugin__handle_message(struct mosquitto_db *db, struct mosquitto *context, s
} }
int mosquitto_callback_register(mosquitto_plugin_id_t *identifier, int event, MOSQ_FUNC_generic_callback cb_func, const void *data, void *userdata) int mosquitto_callback_register(
mosquitto_plugin_id_t *identifier,
int event,
MOSQ_FUNC_generic_callback cb_func,
const void *event_data,
void *userdata)
{ {
struct mosquitto_db *db; struct mosquitto_db *db;
struct mosquitto__callback **cb_base = NULL, *cb_new; struct mosquitto__callback **cb_base = NULL, *cb_new;
@ -185,7 +190,7 @@ int mosquitto_callback_register(mosquitto_plugin_id_t *identifier, int event, MO
cb_base = &security_options->plugin_callbacks.ext_auth_continue; cb_base = &security_options->plugin_callbacks.ext_auth_continue;
break; break;
case MOSQ_EVT_CONTROL: case MOSQ_EVT_CONTROL:
return control__register_callback(db, security_options, cb_func, data, userdata); return control__register_callback(db, security_options, cb_func, event_data, userdata);
break; break;
case MOSQ_EVT_MESSAGE: case MOSQ_EVT_MESSAGE:
cb_base = &security_options->plugin_callbacks.message; cb_base = &security_options->plugin_callbacks.message;
@ -211,7 +216,11 @@ int mosquitto_callback_register(mosquitto_plugin_id_t *identifier, int event, MO
} }
int mosquitto_callback_unregister(mosquitto_plugin_id_t *identifier, int event, MOSQ_FUNC_generic_callback cb_func, const void *data) int mosquitto_callback_unregister(
mosquitto_plugin_id_t *identifier,
int event,
MOSQ_FUNC_generic_callback cb_func,
const void *event_data)
{ {
struct mosquitto_db *db; struct mosquitto_db *db;
struct mosquitto__callback **cb_base = NULL; struct mosquitto__callback **cb_base = NULL;
@ -245,7 +254,7 @@ int mosquitto_callback_unregister(mosquitto_plugin_id_t *identifier, int event,
cb_base = &security_options->plugin_callbacks.ext_auth_continue; cb_base = &security_options->plugin_callbacks.ext_auth_continue;
break; break;
case MOSQ_EVT_CONTROL: case MOSQ_EVT_CONTROL:
return control__unregister_callback(db, security_options, cb_func, data); return control__unregister_callback(db, security_options, cb_func, event_data);
break; break;
case MOSQ_EVT_MESSAGE: case MOSQ_EVT_MESSAGE:
cb_base = &security_options->plugin_callbacks.message; cb_base = &security_options->plugin_callbacks.message;

Loading…
Cancel
Save