From 460995652e795144518857d61c19a7095d11bc85 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Wed, 17 Sep 2025 11:06:50 +0100 Subject: [PATCH] Formatting: Apply to C headers --- apps/mosquitto_ctrl/ctrl_shell_internal.h | 4 +- apps/mosquitto_ctrl/mosquitto_ctrl.h | 2 +- apps/mosquitto_signal/mosquitto_signal.h | 2 +- common/lib_load.h | 16 +-- config.h | 2 +- fuzzing/broker/broker_fuzz.h | 2 +- include/mosquitto/broker.h | 10 +- include/mosquitto/broker_control.h | 4 +- include/mosquitto/broker_plugin.h | 18 +-- include/mosquitto/defs.h | 22 +-- include/mosquitto/libcommon_file.h | 2 +- include/mosquitto/libcommon_memory.h | 2 +- include/mosquitto/libcommon_password.h | 4 +- include/mosquitto/libcommon_properties.h | 2 +- include/mosquitto/libmosquitto.h | 20 +-- include/mosquitto/libmosquittopp.h | 20 +-- include/mosquitto/mqtt_protocol.h | 146 ++++++++++---------- lib/http_client.h | 2 +- lib/mosquitto_internal.h | 52 +++---- lib/net_mosq.h | 2 +- plugins/dynamic-security/dynamic_security.h | 24 ++-- plugins/persist-sqlite/persist_sqlite.h | 2 +- plugins/persist-sqlite/util.h | 19 ++- src/acl_file.h | 6 +- src/mosquitto_broker_internal.h | 67 ++++----- src/password_file.h | 4 +- src/persist.h | 26 ++-- src/sys_tree.h | 4 +- test/path_helper.h | 8 +- 29 files changed, 252 insertions(+), 242 deletions(-) diff --git a/apps/mosquitto_ctrl/ctrl_shell_internal.h b/apps/mosquitto_ctrl/ctrl_shell_internal.h index c59d1a1a..bfff76ae 100644 --- a/apps/mosquitto_ctrl/ctrl_shell_internal.h +++ b/apps/mosquitto_ctrl/ctrl_shell_internal.h @@ -30,7 +30,7 @@ extern "C" { #include "ctrl_shell.h" #include "mosquitto_ctrl.h" -struct ctrl_shell{ +struct ctrl_shell { char **subscription_list; int subscription_list_count; int run; @@ -59,7 +59,7 @@ struct ctrl_shell{ int transport; }; -struct ctrl_shell__module{ +struct ctrl_shell__module { struct completion_tree_root *completion_commands; const char *request_topic; const char *response_topic; diff --git a/apps/mosquitto_ctrl/mosquitto_ctrl.h b/apps/mosquitto_ctrl/mosquitto_ctrl.h index da35d097..04495f41 100644 --- a/apps/mosquitto_ctrl/mosquitto_ctrl.h +++ b/apps/mosquitto_ctrl/mosquitto_ctrl.h @@ -74,7 +74,7 @@ struct mosq_ctrl { char *request_topic; char *response_topic; char *payload; - void (*payload_callback)(struct mosq_ctrl *, long , const void *); + void (*payload_callback)(struct mosq_ctrl *, long, const void *); void *userdata; }; diff --git a/apps/mosquitto_signal/mosquitto_signal.h b/apps/mosquitto_signal/mosquitto_signal.h index d10f8445..989b5dbf 100644 --- a/apps/mosquitto_signal/mosquitto_signal.h +++ b/apps/mosquitto_signal/mosquitto_signal.h @@ -1,7 +1,7 @@ #ifndef MOSQUITTO_SIGNAL_H #define MOSQUITTO_SIGNAL_H -enum mosq_signal{ +enum mosq_signal { MSIG_CONFIG_RELOAD, MSIG_LOG_ROTATE, MSIG_SHUTDOWN, diff --git a/common/lib_load.h b/common/lib_load.h index f8ecc706..58a60a72 100644 --- a/common/lib_load.h +++ b/common/lib_load.h @@ -20,19 +20,19 @@ Contributors: #define LIB_LOAD_H #ifdef WIN32 -# include +# include #else -# include +# include #endif #ifdef WIN32 -# define LIB_LOAD(A) LoadLibrary(A) -# define LIB_CLOSE(A) FreeLibrary(A) -# define LIB_SYM(HANDLE, SYM) GetProcAddress(HANDLE, SYM) +# define LIB_LOAD(A) LoadLibrary(A) +# define LIB_CLOSE(A) FreeLibrary(A) +# define LIB_SYM(HANDLE, SYM) GetProcAddress(HANDLE, SYM) #else -# define LIB_LOAD(A) dlopen(A, RTLD_NOW|RTLD_LOCAL) -# define LIB_CLOSE(A) dlclose(A) -# define LIB_SYM(HANDLE, SYM) dlsym(HANDLE, SYM) +# define LIB_LOAD(A) dlopen(A, RTLD_NOW|RTLD_LOCAL) +# define LIB_CLOSE(A) dlclose(A) +# define LIB_SYM(HANDLE, SYM) dlsym(HANDLE, SYM) #endif #define LIB_SYM_EASY(MEMBER, HANDLE, SYM) if(!(MEMBER = LIB_SYM(HANDLE, SYM)) return 1 diff --git a/config.h b/config.h index c32d2d60..4bf110aa 100644 --- a/config.h +++ b/config.h @@ -49,7 +49,7 @@ typedef SSIZE_T ssize_t; #define uthash_malloc(sz) mosquitto_malloc(sz) -#define uthash_free(ptr,sz) mosquitto_free(ptr) +#define uthash_free(ptr, sz) mosquitto_free(ptr) #ifdef WITH_TLS diff --git a/fuzzing/broker/broker_fuzz.h b/fuzzing/broker/broker_fuzz.h index f57d69cb..4e7175f5 100644 --- a/fuzzing/broker/broker_fuzz.h +++ b/fuzzing/broker/broker_fuzz.h @@ -21,7 +21,7 @@ Contributors: #define kMinInputLength 5 #define kMaxInputLength 10000 -struct fuzz_data{ +struct fuzz_data { uint8_t *data; size_t size; uint16_t port; diff --git a/include/mosquitto/broker.h b/include/mosquitto/broker.h index c213260a..9a4cd1f1 100644 --- a/include/mosquitto/broker.h +++ b/include/mosquitto/broker.h @@ -29,9 +29,9 @@ extern "C" { #endif #if defined(WIN32) && defined(mosquitto_EXPORTS) -# define mosq_EXPORT __declspec(dllexport) +# define mosq_EXPORT __declspec(dllexport) #else -# define mosq_EXPORT +# define mosq_EXPORT #endif #include @@ -52,7 +52,7 @@ enum mosquitto_protocol { enum mosquitto_broker_msg_direction { mosq_bmd_in = 0, mosq_bmd_out = 1, - mosq_bmd_all = 2 + mosq_bmd_all = 2, }; @@ -907,7 +907,7 @@ mosq_EXPORT int mosquitto_broker_publish_copy( * the call to `mosquitto_complete_basic_auth()` must happen in the main * mosquitto thread. Using the MOSQ_EVT_TICK event for this is suggested. */ -mosq_EXPORT void mosquitto_complete_basic_auth(const char* clientid, int result); +mosq_EXPORT void mosquitto_complete_basic_auth(const char *clientid, int result); /* Function: mosquitto_broker_node_id_set @@ -1276,7 +1276,7 @@ mosq_EXPORT const char *mosquitto_persistence_location(void); * MOSQ_ERR_PAYLOAD_SIZE - if payloadlen is too large. * MOSQ_ERR_MALFORMED_UTF8 - if the topic is not valid UTF-8. */ -mosq_EXPORT int mosquitto_client_will_set(const char* clientid, const char *topic, int payloadlen, const void *payload, int qos, bool retain, mosquitto_property *properties); +mosq_EXPORT int mosquitto_client_will_set(const char *clientid, const char *topic, int payloadlen, const void *payload, int qos, bool retain, mosquitto_property *properties); #ifdef __cplusplus diff --git a/include/mosquitto/broker_control.h b/include/mosquitto/broker_control.h index 9bb32e86..93b679ff 100644 --- a/include/mosquitto/broker_control.h +++ b/include/mosquitto/broker_control.h @@ -41,7 +41,7 @@ extern "C" { * * ========================================================================= */ -struct mosquitto_control_cmd{ +struct mosquitto_control_cmd { struct mosquitto *client; cJSON *j_responses; cJSON *j_command; @@ -50,7 +50,7 @@ struct mosquitto_control_cmd{ }; mosq_EXPORT void mosquitto_control_command_reply(struct mosquitto_control_cmd *cmd, const char *error); -mosq_EXPORT void mosquitto_control_send_response(cJSON *tree, const char* topic); +mosq_EXPORT void mosquitto_control_send_response(cJSON *tree, const char *topic); mosq_EXPORT int mosquitto_control_generic_callback(struct mosquitto_evt_control *event_data, const char *response_topic, void *userdata, int (*cmd_cb)(struct mosquitto_control_cmd *cmd, void *userdata)); diff --git a/include/mosquitto/broker_plugin.h b/include/mosquitto/broker_plugin.h index 2c07656b..95d9ec43 100644 --- a/include/mosquitto/broker_plugin.h +++ b/include/mosquitto/broker_plugin.h @@ -135,16 +135,16 @@ struct mosquitto_acl_msg { 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 /* Log types */ -#define MOSQ_LOG_NONE 0 -#define MOSQ_LOG_INFO (1<<0) -#define MOSQ_LOG_NOTICE (1<<1) -#define MOSQ_LOG_WARNING (1<<2) -#define MOSQ_LOG_ERR (1<<3) -#define MOSQ_LOG_DEBUG (1<<4) -#define MOSQ_LOG_SUBSCRIBE (1<<5) -#define MOSQ_LOG_UNSUBSCRIBE (1<<6) -#define MOSQ_LOG_WEBSOCKETS (1<<7) -#define MOSQ_LOG_INTERNAL 0x80000000U -#define MOSQ_LOG_ALL 0xFFFFFFFFU +#define MOSQ_LOG_NONE 0 +#define MOSQ_LOG_INFO (1<<0) +#define MOSQ_LOG_NOTICE (1<<1) +#define MOSQ_LOG_WARNING (1<<2) +#define MOSQ_LOG_ERR (1<<3) +#define MOSQ_LOG_DEBUG (1<<4) +#define MOSQ_LOG_SUBSCRIBE (1<<5) +#define MOSQ_LOG_UNSUBSCRIBE (1<<6) +#define MOSQ_LOG_WEBSOCKETS (1<<7) +#define MOSQ_LOG_INTERNAL 0x80000000U +#define MOSQ_LOG_ALL 0xFFFFFFFFU /* Enum: mosq_err_t * Integer values returned from many libmosquitto functions. */ diff --git a/include/mosquitto/libcommon_file.h b/include/mosquitto/libcommon_file.h index 719dc3be..3dd8c4d8 100644 --- a/include/mosquitto/libcommon_file.h +++ b/include/mosquitto/libcommon_file.h @@ -45,7 +45,7 @@ libmosqcommon_EXPORT char *mosquitto_fgets(char **buf, int *buflen, FILE *stream /* * Function: mosquitto_write_file */ -libmosqcommon_EXPORT int mosquitto_write_file(const char* target_path, bool restrict_read, int (*write_fn)(FILE* fptr, void* user_data), void* user_data, void (*log_fn)(const char* msg)); +libmosqcommon_EXPORT int mosquitto_write_file(const char *target_path, bool restrict_read, int (*write_fn)(FILE *fptr, void *user_data), void *user_data, void (*log_fn)(const char *msg)); /* diff --git a/include/mosquitto/libcommon_memory.h b/include/mosquitto/libcommon_memory.h index eb07a783..512fc38b 100644 --- a/include/mosquitto/libcommon_memory.h +++ b/include/mosquitto/libcommon_memory.h @@ -72,7 +72,7 @@ libmosqcommon_EXPORT void mosquitto_memory_set_limit(size_t lim); libmosqcommon_EXPORT unsigned long mosquitto_memory_used(void); libmosqcommon_EXPORT unsigned long mosquitto_max_memory_used(void); -#define mosquitto_FREE(A) do { mosquitto_free(A); (A) = NULL;} while(0) +#define mosquitto_FREE(A) do{ mosquitto_free(A); (A) = NULL;}while(0) #ifdef __cplusplus } diff --git a/include/mosquitto/libcommon_password.h b/include/mosquitto/libcommon_password.h index e98c5ffb..72d7cbc1 100644 --- a/include/mosquitto/libcommon_password.h +++ b/include/mosquitto/libcommon_password.h @@ -26,14 +26,14 @@ Contributors: extern "C" { #endif -enum mosquitto_pwhash_type{ +enum mosquitto_pwhash_type { MOSQ_PW_DEFAULT, MOSQ_PW_SHA512 = 6, MOSQ_PW_SHA512_PBKDF2 = 7, MOSQ_PW_ARGON2ID = 8, }; -enum mosquitto_pw_params{ +enum mosquitto_pw_params { MOSQ_PW_PARAM_ITERATIONS = 1, }; diff --git a/include/mosquitto/libcommon_properties.h b/include/mosquitto/libcommon_properties.h index 2d54cabd..521e3f6d 100644 --- a/include/mosquitto/libcommon_properties.h +++ b/include/mosquitto/libcommon_properties.h @@ -748,7 +748,7 @@ libmosqcommon_EXPORT int mosquitto_string_to_property_info(const char *propname, libmosqcommon_EXPORT void mosquitto_property_free(mosquitto_property **property); libmosqcommon_EXPORT unsigned int mosquitto_property_get_length(const mosquitto_property *property); libmosqcommon_EXPORT unsigned int mosquitto_property_get_length_all(const mosquitto_property *property); -libmosqcommon_EXPORT unsigned int mosquitto_property_get_remaining_length(const mosquitto_property* props); +libmosqcommon_EXPORT unsigned int mosquitto_property_get_remaining_length(const mosquitto_property *props); libmosqcommon_EXPORT unsigned int mosquitto_varint_bytes(uint32_t word); #ifdef __cplusplus diff --git a/include/mosquitto/libmosquitto.h b/include/mosquitto/libmosquitto.h index c2066a21..770a985f 100644 --- a/include/mosquitto/libmosquitto.h +++ b/include/mosquitto/libmosquitto.h @@ -44,15 +44,15 @@ extern "C" { #endif #if defined(_MSC_VER) && _MSC_VER < 1900 && !defined(bool) -# ifndef __cplusplus -# define bool char -# define true 1 -# define false 0 -# endif +# ifndef __cplusplus +# define bool char +# define true 1 +# define false 0 +# endif #else -# ifndef __cplusplus -# include -# endif +# ifndef __cplusplus +# include +# endif #endif #include @@ -111,7 +111,7 @@ enum mosq_opt_t { * * bool retain - set to true for stale retained messages. */ -struct mosquitto_message{ +struct mosquitto_message { int mid; char *topic; void *payload; @@ -120,7 +120,7 @@ struct mosquitto_message{ bool retain; }; -struct mosquitto_message_v5{ +struct mosquitto_message_v5 { void *payload; char *topic; mosquitto_property *properties; diff --git a/include/mosquitto/libmosquittopp.h b/include/mosquitto/libmosquittopp.h index dcccf917..d6054d69 100644 --- a/include/mosquitto/libmosquittopp.h +++ b/include/mosquitto/libmosquittopp.h @@ -18,25 +18,25 @@ Contributors: #define MOSQUITTO_LIBMOSQUITTOPP_H #if defined(_WIN32) && !defined(LIBMOSQUITTO_STATIC) -# ifdef mosquittopp_EXPORTS -# define mosqpp_EXPORT __declspec(dllexport) -# else -# define mosqpp_EXPORT __declspec(dllimport) -# endif +# ifdef mosquittopp_EXPORTS +# define mosqpp_EXPORT __declspec(dllexport) +# else +# define mosqpp_EXPORT __declspec(dllimport) +# endif #else -# define mosqpp_EXPORT +# define mosqpp_EXPORT #endif #include #include #include -namespace mosqpp { +namespace mosqpp{ -mosqpp_EXPORT const char * strerror(int mosq_errno); -mosqpp_EXPORT const char * connack_string(int connack_code); -mosqpp_EXPORT const char * reason_string(int reason_code); +mosqpp_EXPORT const char *strerror(int mosq_errno); +mosqpp_EXPORT const char *connack_string(int connack_code); +mosqpp_EXPORT const char *reason_string(int reason_code); mosqpp_EXPORT int sub_topic_tokenise(const char *subtopic, char ***topics, int *count); mosqpp_EXPORT int sub_topic_tokens_free(char ***topics, int count); mosqpp_EXPORT int lib_version(int *major, int *minor, int *revision); diff --git a/include/mosquitto/mqtt_protocol.h b/include/mosquitto/mqtt_protocol.h index b5a6b475..27dac54e 100644 --- a/include/mosquitto/mqtt_protocol.h +++ b/include/mosquitto/mqtt_protocol.h @@ -128,52 +128,52 @@ enum mqtt311_connack_codes { * MQTT_RC_WILDCARD_SUBS_NOT_SUPPORTED - 162 */ enum mqtt5_return_codes { - MQTT_RC_SUCCESS = 0, /* CONNACK, PUBACK, PUBREC, PUBREL, PUBCOMP, UNSUBACK, AUTH */ - MQTT_RC_NORMAL_DISCONNECTION = 0, /* DISCONNECT */ - MQTT_RC_GRANTED_QOS0 = 0, /* SUBACK */ - MQTT_RC_GRANTED_QOS1 = 1, /* SUBACK */ - MQTT_RC_GRANTED_QOS2 = 2, /* SUBACK */ - MQTT_RC_DISCONNECT_WITH_WILL_MSG = 4, /* DISCONNECT */ - MQTT_RC_NO_MATCHING_SUBSCRIBERS = 16, /* PUBACK, PUBREC */ - MQTT_RC_NO_SUBSCRIPTION_EXISTED = 17, /* UNSUBACK */ - MQTT_RC_CONTINUE_AUTHENTICATION = 24, /* AUTH */ - MQTT_RC_REAUTHENTICATE = 25, /* AUTH */ + MQTT_RC_SUCCESS = 0, /* CONNACK, PUBACK, PUBREC, PUBREL, PUBCOMP, UNSUBACK, AUTH */ + MQTT_RC_NORMAL_DISCONNECTION = 0, /* DISCONNECT */ + MQTT_RC_GRANTED_QOS0 = 0, /* SUBACK */ + MQTT_RC_GRANTED_QOS1 = 1, /* SUBACK */ + MQTT_RC_GRANTED_QOS2 = 2, /* SUBACK */ + MQTT_RC_DISCONNECT_WITH_WILL_MSG = 4, /* DISCONNECT */ + MQTT_RC_NO_MATCHING_SUBSCRIBERS = 16, /* PUBACK, PUBREC */ + MQTT_RC_NO_SUBSCRIPTION_EXISTED = 17, /* UNSUBACK */ + MQTT_RC_CONTINUE_AUTHENTICATION = 24, /* AUTH */ + MQTT_RC_REAUTHENTICATE = 25, /* AUTH */ - MQTT_RC_UNSPECIFIED = 128, /* CONNACK, PUBACK, PUBREC, SUBACK, UNSUBACK, DISCONNECT */ - MQTT_RC_MALFORMED_PACKET = 129, /* CONNACK, DISCONNECT */ - MQTT_RC_PROTOCOL_ERROR = 130, /* DISCONNECT */ - MQTT_RC_IMPLEMENTATION_SPECIFIC = 131, /* CONNACK, PUBACK, PUBREC, SUBACK, UNSUBACK, DISCONNECT */ - MQTT_RC_UNSUPPORTED_PROTOCOL_VERSION = 132, /* CONNACK */ - MQTT_RC_CLIENTID_NOT_VALID = 133, /* CONNACK */ - MQTT_RC_BAD_USERNAME_OR_PASSWORD = 134, /* CONNACK */ - MQTT_RC_NOT_AUTHORIZED = 135, /* CONNACK, PUBACK, PUBREC, SUBACK, UNSUBACK, DISCONNECT */ - MQTT_RC_SERVER_UNAVAILABLE = 136, /* CONNACK */ - MQTT_RC_SERVER_BUSY = 137, /* CONNACK, DISCONNECT */ - MQTT_RC_BANNED = 138, /* CONNACK */ - MQTT_RC_SERVER_SHUTTING_DOWN = 139, /* DISCONNECT */ - MQTT_RC_BAD_AUTHENTICATION_METHOD = 140, /* CONNACK */ - MQTT_RC_KEEP_ALIVE_TIMEOUT = 141, /* DISCONNECT */ - MQTT_RC_SESSION_TAKEN_OVER = 142, /* DISCONNECT */ - MQTT_RC_TOPIC_FILTER_INVALID = 143, /* SUBACK, UNSUBACK, DISCONNECT */ - MQTT_RC_TOPIC_NAME_INVALID = 144, /* CONNACK, PUBACK, PUBREC, DISCONNECT */ - MQTT_RC_PACKET_ID_IN_USE = 145, /* PUBACK, SUBACK, UNSUBACK */ - MQTT_RC_PACKET_ID_NOT_FOUND = 146, /* PUBREL, PUBCOMP */ - MQTT_RC_RECEIVE_MAXIMUM_EXCEEDED = 147, /* DISCONNECT */ - MQTT_RC_TOPIC_ALIAS_INVALID = 148, /* DISCONNECT */ - MQTT_RC_PACKET_TOO_LARGE = 149, /* CONNACK, PUBACK, PUBREC, DISCONNECT */ - MQTT_RC_MESSAGE_RATE_TOO_HIGH = 150, /* DISCONNECT */ - MQTT_RC_QUOTA_EXCEEDED = 151, /* PUBACK, PUBREC, SUBACK, DISCONNECT */ - MQTT_RC_ADMINISTRATIVE_ACTION = 152, /* DISCONNECT */ - MQTT_RC_PAYLOAD_FORMAT_INVALID = 153, /* CONNACK, PUBACK, PUBREC, DISCONNECT */ - MQTT_RC_RETAIN_NOT_SUPPORTED = 154, /* CONNACK, DISCONNECT */ - MQTT_RC_QOS_NOT_SUPPORTED = 155, /* CONNACK, DISCONNECT */ - MQTT_RC_USE_ANOTHER_SERVER = 156, /* CONNACK, DISCONNECT */ - MQTT_RC_SERVER_MOVED = 157, /* CONNACK, DISCONNECT */ - MQTT_RC_SHARED_SUBS_NOT_SUPPORTED = 158, /* SUBACK, DISCONNECT */ - MQTT_RC_CONNECTION_RATE_EXCEEDED = 159, /* CONNACK, DISCONNECT */ - MQTT_RC_MAXIMUM_CONNECT_TIME = 160, /* DISCONNECT */ + MQTT_RC_UNSPECIFIED = 128, /* CONNACK, PUBACK, PUBREC, SUBACK, UNSUBACK, DISCONNECT */ + MQTT_RC_MALFORMED_PACKET = 129, /* CONNACK, DISCONNECT */ + MQTT_RC_PROTOCOL_ERROR = 130, /* DISCONNECT */ + MQTT_RC_IMPLEMENTATION_SPECIFIC = 131, /* CONNACK, PUBACK, PUBREC, SUBACK, UNSUBACK, DISCONNECT */ + MQTT_RC_UNSUPPORTED_PROTOCOL_VERSION = 132, /* CONNACK */ + MQTT_RC_CLIENTID_NOT_VALID = 133, /* CONNACK */ + MQTT_RC_BAD_USERNAME_OR_PASSWORD = 134, /* CONNACK */ + MQTT_RC_NOT_AUTHORIZED = 135, /* CONNACK, PUBACK, PUBREC, SUBACK, UNSUBACK, DISCONNECT */ + MQTT_RC_SERVER_UNAVAILABLE = 136, /* CONNACK */ + MQTT_RC_SERVER_BUSY = 137, /* CONNACK, DISCONNECT */ + MQTT_RC_BANNED = 138, /* CONNACK */ + MQTT_RC_SERVER_SHUTTING_DOWN = 139, /* DISCONNECT */ + MQTT_RC_BAD_AUTHENTICATION_METHOD = 140, /* CONNACK */ + MQTT_RC_KEEP_ALIVE_TIMEOUT = 141, /* DISCONNECT */ + MQTT_RC_SESSION_TAKEN_OVER = 142, /* DISCONNECT */ + MQTT_RC_TOPIC_FILTER_INVALID = 143, /* SUBACK, UNSUBACK, DISCONNECT */ + MQTT_RC_TOPIC_NAME_INVALID = 144, /* CONNACK, PUBACK, PUBREC, DISCONNECT */ + MQTT_RC_PACKET_ID_IN_USE = 145, /* PUBACK, SUBACK, UNSUBACK */ + MQTT_RC_PACKET_ID_NOT_FOUND = 146, /* PUBREL, PUBCOMP */ + MQTT_RC_RECEIVE_MAXIMUM_EXCEEDED = 147, /* DISCONNECT */ + MQTT_RC_TOPIC_ALIAS_INVALID = 148, /* DISCONNECT */ + MQTT_RC_PACKET_TOO_LARGE = 149, /* CONNACK, PUBACK, PUBREC, DISCONNECT */ + MQTT_RC_MESSAGE_RATE_TOO_HIGH = 150, /* DISCONNECT */ + MQTT_RC_QUOTA_EXCEEDED = 151, /* PUBACK, PUBREC, SUBACK, DISCONNECT */ + MQTT_RC_ADMINISTRATIVE_ACTION = 152, /* DISCONNECT */ + MQTT_RC_PAYLOAD_FORMAT_INVALID = 153, /* CONNACK, PUBACK, PUBREC, DISCONNECT */ + MQTT_RC_RETAIN_NOT_SUPPORTED = 154, /* CONNACK, DISCONNECT */ + MQTT_RC_QOS_NOT_SUPPORTED = 155, /* CONNACK, DISCONNECT */ + MQTT_RC_USE_ANOTHER_SERVER = 156, /* CONNACK, DISCONNECT */ + MQTT_RC_SERVER_MOVED = 157, /* CONNACK, DISCONNECT */ + MQTT_RC_SHARED_SUBS_NOT_SUPPORTED = 158, /* SUBACK, DISCONNECT */ + MQTT_RC_CONNECTION_RATE_EXCEEDED = 159, /* CONNACK, DISCONNECT */ + MQTT_RC_MAXIMUM_CONNECT_TIME = 160, /* DISCONNECT */ MQTT_RC_SUBSCRIPTION_IDS_NOT_SUPPORTED = 161, /* SUBACK, DISCONNECT */ - MQTT_RC_WILDCARD_SUBS_NOT_SUPPORTED = 162, /* SUBACK, DISCONNECT */ + MQTT_RC_WILDCARD_SUBS_NOT_SUPPORTED = 162, /* SUBACK, DISCONNECT */ }; /* Enum: mqtt5_property @@ -209,33 +209,33 @@ enum mqtt5_return_codes { * MQTT_PROP_SHARED_SUB_AVAILABLE - property option. */ enum mqtt5_property { - MQTT_PROP_PAYLOAD_FORMAT_INDICATOR = 1, /* Byte : PUBLISH, Will Properties */ - MQTT_PROP_MESSAGE_EXPIRY_INTERVAL = 2, /* 4 byte int : PUBLISH, Will Properties */ - MQTT_PROP_CONTENT_TYPE = 3, /* UTF-8 string : PUBLISH, Will Properties */ - MQTT_PROP_RESPONSE_TOPIC = 8, /* UTF-8 string : PUBLISH, Will Properties */ - MQTT_PROP_CORRELATION_DATA = 9, /* Binary Data : PUBLISH, Will Properties */ - MQTT_PROP_SUBSCRIPTION_IDENTIFIER = 11, /* Variable byte int : PUBLISH, SUBSCRIBE */ - MQTT_PROP_SESSION_EXPIRY_INTERVAL = 17, /* 4 byte int : CONNECT, CONNACK, DISCONNECT */ - MQTT_PROP_ASSIGNED_CLIENT_IDENTIFIER = 18, /* UTF-8 string : CONNACK */ - MQTT_PROP_SERVER_KEEP_ALIVE = 19, /* 2 byte int : CONNACK */ - MQTT_PROP_AUTHENTICATION_METHOD = 21, /* UTF-8 string : CONNECT, CONNACK, AUTH */ - MQTT_PROP_AUTHENTICATION_DATA = 22, /* Binary Data : CONNECT, CONNACK, AUTH */ - MQTT_PROP_REQUEST_PROBLEM_INFORMATION = 23, /* Byte : CONNECT */ - MQTT_PROP_WILL_DELAY_INTERVAL = 24, /* 4 byte int : Will properties */ + MQTT_PROP_PAYLOAD_FORMAT_INDICATOR = 1, /* Byte : PUBLISH, Will Properties */ + MQTT_PROP_MESSAGE_EXPIRY_INTERVAL = 2, /* 4 byte int : PUBLISH, Will Properties */ + MQTT_PROP_CONTENT_TYPE = 3, /* UTF-8 string : PUBLISH, Will Properties */ + MQTT_PROP_RESPONSE_TOPIC = 8, /* UTF-8 string : PUBLISH, Will Properties */ + MQTT_PROP_CORRELATION_DATA = 9, /* Binary Data : PUBLISH, Will Properties */ + MQTT_PROP_SUBSCRIPTION_IDENTIFIER = 11, /* Variable byte int : PUBLISH, SUBSCRIBE */ + MQTT_PROP_SESSION_EXPIRY_INTERVAL = 17, /* 4 byte int : CONNECT, CONNACK, DISCONNECT */ + MQTT_PROP_ASSIGNED_CLIENT_IDENTIFIER = 18, /* UTF-8 string : CONNACK */ + MQTT_PROP_SERVER_KEEP_ALIVE = 19, /* 2 byte int : CONNACK */ + MQTT_PROP_AUTHENTICATION_METHOD = 21, /* UTF-8 string : CONNECT, CONNACK, AUTH */ + MQTT_PROP_AUTHENTICATION_DATA = 22, /* Binary Data : CONNECT, CONNACK, AUTH */ + MQTT_PROP_REQUEST_PROBLEM_INFORMATION = 23, /* Byte : CONNECT */ + MQTT_PROP_WILL_DELAY_INTERVAL = 24, /* 4 byte int : Will properties */ MQTT_PROP_REQUEST_RESPONSE_INFORMATION = 25,/* Byte : CONNECT */ - MQTT_PROP_RESPONSE_INFORMATION = 26, /* UTF-8 string : CONNACK */ - MQTT_PROP_SERVER_REFERENCE = 28, /* UTF-8 string : CONNACK, DISCONNECT */ - MQTT_PROP_REASON_STRING = 31, /* UTF-8 string : All except Will properties */ - MQTT_PROP_RECEIVE_MAXIMUM = 33, /* 2 byte int : CONNECT, CONNACK */ - MQTT_PROP_TOPIC_ALIAS_MAXIMUM = 34, /* 2 byte int : CONNECT, CONNACK */ - MQTT_PROP_TOPIC_ALIAS = 35, /* 2 byte int : PUBLISH */ - MQTT_PROP_MAXIMUM_QOS = 36, /* Byte : CONNACK */ - MQTT_PROP_RETAIN_AVAILABLE = 37, /* Byte : CONNACK */ - MQTT_PROP_USER_PROPERTY = 38, /* UTF-8 string pair : All */ - MQTT_PROP_MAXIMUM_PACKET_SIZE = 39, /* 4 byte int : CONNECT, CONNACK */ - MQTT_PROP_WILDCARD_SUB_AVAILABLE = 40, /* Byte : CONNACK */ - MQTT_PROP_SUBSCRIPTION_ID_AVAILABLE = 41, /* Byte : CONNACK */ - MQTT_PROP_SHARED_SUB_AVAILABLE = 42, /* Byte : CONNACK */ + MQTT_PROP_RESPONSE_INFORMATION = 26, /* UTF-8 string : CONNACK */ + MQTT_PROP_SERVER_REFERENCE = 28, /* UTF-8 string : CONNACK, DISCONNECT */ + MQTT_PROP_REASON_STRING = 31, /* UTF-8 string : All except Will properties */ + MQTT_PROP_RECEIVE_MAXIMUM = 33, /* 2 byte int : CONNECT, CONNACK */ + MQTT_PROP_TOPIC_ALIAS_MAXIMUM = 34, /* 2 byte int : CONNECT, CONNACK */ + MQTT_PROP_TOPIC_ALIAS = 35, /* 2 byte int : PUBLISH */ + MQTT_PROP_MAXIMUM_QOS = 36, /* Byte : CONNACK */ + MQTT_PROP_RETAIN_AVAILABLE = 37, /* Byte : CONNACK */ + MQTT_PROP_USER_PROPERTY = 38, /* UTF-8 string pair : All */ + MQTT_PROP_MAXIMUM_PACKET_SIZE = 39, /* 4 byte int : CONNECT, CONNACK */ + MQTT_PROP_WILDCARD_SUB_AVAILABLE = 40, /* Byte : CONNACK */ + MQTT_PROP_SUBSCRIPTION_ID_AVAILABLE = 41, /* Byte : CONNACK */ + MQTT_PROP_SHARED_SUB_AVAILABLE = 42, /* Byte : CONNACK */ }; enum mqtt5_property_type { @@ -245,7 +245,7 @@ enum mqtt5_property_type { MQTT_PROP_TYPE_VARINT = 4, MQTT_PROP_TYPE_BINARY = 5, MQTT_PROP_TYPE_STRING = 6, - MQTT_PROP_TYPE_STRING_PAIR = 7 + MQTT_PROP_TYPE_STRING_PAIR = 7, }; /* Enum: mqtt5_sub_options @@ -283,8 +283,8 @@ enum mqtt5_sub_options { #define MQTT_MAX_PAYLOAD 268435455U #define MQTT_SUB_OPT_GET_QOS(opt) ((opt) & 0x03) -#define MQTT_SUB_OPT_GET_NO_LOCAL(opt) ((opt) & MQTT_SUB_OPT_NO_LOCAL) -#define MQTT_SUB_OPT_GET_RETAIN_AS_PUBLISHED(opt) ((opt) & MQTT_SUB_OPT_RETAIN_AS_PUBLISHED) +#define MQTT_SUB_OPT_GET_NO_LOCAL(opt) ((opt)&MQTT_SUB_OPT_NO_LOCAL) +#define MQTT_SUB_OPT_GET_RETAIN_AS_PUBLISHED(opt) ((opt)&MQTT_SUB_OPT_RETAIN_AS_PUBLISHED) #define MQTT_SUB_OPT_GET_SEND_RETAIN(opt) ((opt) & (MQTT_SUB_OPT_SEND_RETAIN_NEW | MQTT_SUB_OPT_SEND_RETAIN_NEVER)) #define MQTT_SUB_OPT_GET_RETAIN_HANDLING(opt) ((opt) & (MQTT_SUB_OPT_SEND_RETAIN_NEW | MQTT_SUB_OPT_SEND_RETAIN_NEVER)) diff --git a/lib/http_client.h b/lib/http_client.h index 54f0e46e..272f0dec 100644 --- a/lib/http_client.h +++ b/lib/http_client.h @@ -32,4 +32,4 @@ int http_c__read(struct mosquitto *mosq); #endif -#endif +#endif diff --git a/lib/mosquitto_internal.h b/lib/mosquitto_internal.h index f3c54623..fe417c5d 100644 --- a/lib/mosquitto_internal.h +++ b/lib/mosquitto_internal.h @@ -40,16 +40,16 @@ Contributors: #endif #ifdef WIN32 -# if _MSC_VER < 1600 - typedef unsigned char uint8_t; - typedef unsigned short uint16_t; - typedef unsigned int uint32_t; - typedef unsigned long long uint64_t; -# else -# include -# endif +# if _MSC_VER < 1600 +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; +# else +# include +# endif #else -# include +# include #endif #include "mosquitto.h" @@ -77,21 +77,21 @@ typedef int mosq_sock_t; #ifdef WIN32 # define WINDOWS_SET_ERRNO() \ - if(errno != EAGAIN){ \ - errno = WSAGetLastError(); \ - } + if(errno != EAGAIN){ \ + errno = WSAGetLastError(); \ + } #else # define WINDOWS_SET_ERRNO() #endif #define SAFE_PRINT(A) (A)?(A):"null" -#define SAFE_FREE(A) do { free(A); (A) = NULL;} while(0) +#define SAFE_FREE(A) do{ free(A); (A) = NULL;}while(0) #define MSG_EXPIRY_INFINITE UINT32_MAX enum mosquitto_msg_direction { mosq_md_in = 0, - mosq_md_out = 1 + mosq_md_out = 1, }; enum mosquitto_msg_state { @@ -107,7 +107,7 @@ enum mosquitto_msg_state { mosq_ms_resend_pubcomp = 8, mosq_ms_wait_for_pubcomp = 9, mosq_ms_send_pubrec = 10, - mosq_ms_queued = 11 + mosq_ms_queued = 11, }; enum mosquitto_client_state { @@ -144,9 +144,9 @@ enum mosquitto__protocol { }; enum mosquitto__threaded_state { - mosq_ts_none, /* No threads in use */ - mosq_ts_self, /* Threads started by libmosquitto */ - mosq_ts_external /* Threads started by external code */ + mosq_ts_none, /* No threads in use */ + mosq_ts_self, /* Threads started by libmosquitto */ + mosq_ts_external, /* Threads started by external code */ }; enum mosquitto__transport { @@ -163,7 +163,7 @@ enum mosquitto__transport { #define ALIAS_DIR_L2R 1 #define ALIAS_DIR_R2L 2 -struct mosquitto__alias{ +struct mosquitto__alias { char *topic; uint16_t alias; }; @@ -174,7 +174,7 @@ struct session_expiry_list { struct session_expiry_list *next; }; -struct mosquitto__packet{ +struct mosquitto__packet { struct mosquitto__packet *next; uint32_t remaining_length; uint32_t packet_length; @@ -186,7 +186,7 @@ struct mosquitto__packet{ uint8_t payload[]; }; -struct mosquitto__packet_in{ +struct mosquitto__packet_in { uint8_t *payload; uint32_t remaining_mult; uint32_t remaining_length; @@ -201,7 +201,7 @@ struct mosquitto__packet_in{ int8_t remaining_count; }; -struct mosquitto_message_all{ +struct mosquitto_message_all { struct mosquitto_message_all *next; struct mosquitto_message_all *prev; mosquitto_property *properties; @@ -224,7 +224,7 @@ struct will_delay_list { struct will_delay_list *next; }; -struct mosquitto_msg_data{ +struct mosquitto_msg_data { #ifdef WITH_BROKER struct mosquitto__client_msg *inflight; struct mosquitto__client_msg *queued; @@ -256,7 +256,7 @@ struct mosquitto_msg_data{ #define WS_PONG 0x0A #if defined(WITH_WEBSOCKETS) && WITH_WEBSOCKETS == WS_IS_BUILTIN -struct ws_data{ +struct ws_data { struct mosquitto__packet *out_packet; char *http_path; char *accept_key; @@ -273,7 +273,7 @@ struct ws_data{ }; #endif -struct proxy_data{ +struct proxy_data { uint8_t *buf; char *cipher; char *tls_version; @@ -284,7 +284,7 @@ struct proxy_data{ bool have_tls; }; -struct client_stats{ +struct client_stats { uint64_t messages_received; uint64_t messages_sent; uint64_t messages_dropped; diff --git a/lib/net_mosq.h b/lib/net_mosq.h index e798a16a..6cd556dc 100644 --- a/lib/net_mosq.h +++ b/lib/net_mosq.h @@ -88,7 +88,7 @@ ssize_t net__write(struct mosquitto *mosq, const void *buf, size_t count); void net__print_ssl_error(struct mosquitto *mosq, const char *msg); int net__socket_apply_tls(struct mosquitto *mosq); int net__socket_connect_tls(struct mosquitto *mosq); -int mosquitto__verify_ocsp_status_cb(SSL * ssl, void *arg); +int mosquitto__verify_ocsp_status_cb(SSL *ssl, void *arg); UI_METHOD *net__get_ui_method(void); #define ENGINE_FINISH(e) if(e) ENGINE_finish(e) #define ENGINE_SECRET_MODE "SECRET_MODE" diff --git a/plugins/dynamic-security/dynamic_security.h b/plugins/dynamic-security/dynamic_security.h index c08ff49b..863425fd 100644 --- a/plugins/dynamic-security/dynamic_security.h +++ b/plugins/dynamic-security/dynamic_security.h @@ -55,31 +55,31 @@ Contributors: * # * ################################################################ */ -struct dynsec__clientlist{ +struct dynsec__clientlist { UT_hash_handle hh; struct dynsec__client *client; int priority; }; -struct dynsec__grouplist{ +struct dynsec__grouplist { UT_hash_handle hh; struct dynsec__group *group; int priority; }; -struct dynsec__rolelist{ +struct dynsec__rolelist { UT_hash_handle hh; struct dynsec__role *role; int priority; char rolename[]; }; -struct dynsec__kicklist{ +struct dynsec__kicklist { struct dynsec__kicklist *next, *prev; char username[]; }; -struct dynsec__client{ +struct dynsec__client { UT_hash_handle hh; struct mosquitto_pw *pw; struct dynsec__rolelist *rolelist; @@ -91,7 +91,7 @@ struct dynsec__client{ char username[]; }; -struct dynsec__group{ +struct dynsec__group { UT_hash_handle hh; struct dynsec__rolelist *rolelist; struct dynsec__clientlist *clientlist; @@ -101,14 +101,14 @@ struct dynsec__group{ }; -struct dynsec__acl{ +struct dynsec__acl { UT_hash_handle hh; int priority; bool allow; char topic[]; }; -struct dynsec__acls{ +struct dynsec__acls { struct dynsec__acl *publish_c_send; struct dynsec__acl *publish_c_recv; struct dynsec__acl *subscribe_literal; @@ -117,7 +117,7 @@ struct dynsec__acls{ struct dynsec__acl *unsubscribe_pattern; }; -struct dynsec__role{ +struct dynsec__role { UT_hash_handle hh; struct dynsec__acls acls; struct dynsec__clientlist *clientlist; @@ -128,20 +128,20 @@ struct dynsec__role{ char rolename[]; }; -struct dynsec__acl_default_access{ +struct dynsec__acl_default_access { bool publish_c_send; bool publish_c_recv; bool subscribe; bool unsubscribe; }; -enum dynsec_pw_init_mode{ +enum dynsec_pw_init_mode { dpwim_file = 1, dpwim_env = 2, dpwim_random = 3, }; -struct dynsec__data{ +struct dynsec__data { char *config_file; char *password_init_file; struct dynsec__client *clients; diff --git a/plugins/persist-sqlite/persist_sqlite.h b/plugins/persist-sqlite/persist_sqlite.h index 263a274a..3b7cfd34 100644 --- a/plugins/persist-sqlite/persist_sqlite.h +++ b/plugins/persist-sqlite/persist_sqlite.h @@ -60,7 +60,7 @@ void persist_sqlite__cleanup(struct mosquitto_sqlite *ms); int persist_sqlite__restore_cb(int event, void *event_data, void *userdata); -int persist_sqlite__client_msg_remove(struct mosquitto_sqlite *ms, const char* clientid, int64_t store_id, int direction); +int persist_sqlite__client_msg_remove(struct mosquitto_sqlite *ms, const char *clientid, int64_t store_id, int direction); int persist_sqlite__client_add_cb(int event, void *event_data, void *userdata); int persist_sqlite__client_update_cb(int event, void *event_data, void *userdata); diff --git a/plugins/persist-sqlite/util.h b/plugins/persist-sqlite/util.h index 158a3370..ef0e895e 100644 --- a/plugins/persist-sqlite/util.h +++ b/plugins/persist-sqlite/util.h @@ -16,41 +16,48 @@ SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause #include #include -static inline int sqlite3_bind_text_from_c_str(sqlite3_stmt* stmt, int col_index, const char* str) + +static inline int sqlite3_bind_text_from_c_str(sqlite3_stmt *stmt, int col_index, const char *str) { return sqlite3_bind_text(stmt, col_index, str, (int)strlen(str), SQLITE_STATIC); } -static inline int sqlite3_bind_text_from_optional_c_str(sqlite3_stmt* stmt, int col_index, const char* str) + +static inline int sqlite3_bind_text_from_optional_c_str(sqlite3_stmt *stmt, int col_index, const char *str) { return str ? sqlite3_bind_text_from_c_str(stmt, col_index, str) : sqlite3_bind_null(stmt, col_index); } -static inline int sqlite3_bind_blob_optional(sqlite3_stmt* stmt, int col_index, const void* ptr, int blob_len) + +static inline int sqlite3_bind_blob_optional(sqlite3_stmt *stmt, int col_index, const void *ptr, int blob_len) { return ptr ? sqlite3_bind_blob(stmt, col_index, ptr, blob_len, SQLITE_STATIC) : sqlite3_bind_null(stmt, col_index); } -static inline int sqlite3_single_step_stmt(int rc, struct mosquitto_sqlite* ms, sqlite3_stmt* stmt) + +static inline int sqlite3_single_step_stmt(int rc, struct mosquitto_sqlite *ms, sqlite3_stmt *stmt) { - if (rc != MOSQ_ERR_SUCCESS){ + if(rc != MOSQ_ERR_SUCCESS){ return rc; } ms->event_count++; return sqlite3_step(stmt) == SQLITE_DONE ? MOSQ_ERR_SUCCESS : MOSQ_ERR_UNKNOWN; } + static inline char *properties_to_json_str(const mosquitto_property *properties) { cJSON *array; char *json_str; array = mosquitto_properties_to_json(properties); - if(!array) return NULL; + if(!array){ + return NULL; + } json_str = cJSON_PrintUnformatted(array); cJSON_Delete(array); diff --git a/src/acl_file.h b/src/acl_file.h index 2a6fad27..436e5a4e 100644 --- a/src/acl_file.h +++ b/src/acl_file.h @@ -20,7 +20,7 @@ Contributors: #include -struct acl__entry{ +struct acl__entry { struct acl__entry *next, *prev; char *topic; int access; @@ -29,14 +29,14 @@ struct acl__entry{ }; -struct acl__user{ +struct acl__user { UT_hash_handle hh; char *username; struct acl__entry *acl; }; -struct acl_file_data{ +struct acl_file_data { char *acl_file; struct acl__user *acl_users; struct acl__user acl_anon; diff --git a/src/mosquitto_broker_internal.h b/src/mosquitto_broker_internal.h index e97a6f9f..74d06be6 100644 --- a/src/mosquitto_broker_internal.h +++ b/src/mosquitto_broker_internal.h @@ -99,12 +99,12 @@ typedef int (*FUNC_auth_plugin_unpwd_check_v2)(void *, const char *, const char typedef int (*FUNC_auth_plugin_psk_key_get_v2)(void *, const char *, const char *, char *, int); -enum mosquitto_msg_origin{ +enum mosquitto_msg_origin { mosq_mo_client = 0, - mosq_mo_broker = 1 + mosq_mo_broker = 1, }; -struct mosquitto__plugin_lib{ +struct mosquitto__plugin_lib { void *lib; void *user_data; int (*plugin_version)(void); @@ -141,8 +141,7 @@ struct mosquitto__plugin_lib{ int version; }; -struct mosquitto__plugin_config -{ +struct mosquitto__plugin_config { char *path; char *name; struct mosquitto_opt *options; @@ -152,19 +151,19 @@ struct mosquitto__plugin_config bool deny_special_chars; }; -struct mosquitto__callback{ +struct mosquitto__callback { UT_hash_handle hh; /* For callbacks that register for e.g. a specific topic */ struct mosquitto__callback *next, *prev; /* For typical callbacks */ MOSQ_FUNC_generic_callback cb; void *userdata; - union{ + union { char *topic; struct timespec next_tick; } data; mosquitto_plugin_id_t *identifier; }; -struct plugin__callbacks{ +struct plugin__callbacks { struct mosquitto__callback *tick; struct mosquitto__callback *acl_check; struct mosquitto__callback *basic_auth; @@ -220,7 +219,7 @@ struct mosquitto__security_options { }; #if defined(WITH_EPOLL) || defined(WITH_KQUEUE) -enum struct_ident{ +enum struct_ident { id_invalid = 0, id_listener = 1, id_client = 2, @@ -289,7 +288,7 @@ struct mosquitto__listener { }; -struct mosquitto__listener_sock{ +struct mosquitto__listener_sock { #if defined(WITH_EPOLL) || defined(WITH_KQUEUE) /* This *must* be the first element in the struct. */ int ident; @@ -302,13 +301,13 @@ struct mosquitto__listener_sock{ /* Callbacks belonging to a specific plugin * Doesn't include MOSQ_EVT_CONTROL events. */ -struct plugin_own_callback{ +struct plugin_own_callback { struct plugin_own_callback *next, *prev; MOSQ_FUNC_generic_callback cb_func; enum mosquitto_plugin_event event; }; -struct mosquitto_plugin_id_t{ +struct mosquitto_plugin_id_t { struct mosquitto__plugin_config config; struct mosquitto__plugin_lib lib; struct mosquitto__listener *listener; @@ -424,7 +423,7 @@ struct mosquitto__retainhier { char topic[]; }; -struct mosquitto__base_msg{ +struct mosquitto__base_msg { UT_hash_handle hh; struct mosquitto_base_msg data; struct mosquitto__listener *source_listener; @@ -435,7 +434,7 @@ struct mosquitto__base_msg{ bool stored; }; -struct mosquitto__client_msg{ +struct mosquitto__client_msg { struct mosquitto_client_msg data; struct mosquitto__client_msg *prev; struct mosquitto__client_msg *next; @@ -443,25 +442,26 @@ struct mosquitto__client_msg{ }; -struct mosquitto__psk{ +struct mosquitto__psk { UT_hash_handle hh; char *username; char *password; }; -struct mosquitto__message_v5{ +struct mosquitto__message_v5 { struct mosquitto__message_v5 *next, *prev; char *topic; void *payload; mosquitto_property *properties; - char *clientid; /* Used only by mosquitto_broker_publish*() to indicate - this message is for a specific client. */ + /* clientid is used only by mosquitto_broker_publish*() to indicate + this message is for a specific client. */ + char *clientid; int payloadlen; int qos; bool retain; }; -struct mosquitto_db{ +struct mosquitto_db { dbid_t last_db_id; uint64_t node_id_shifted; struct mosquitto__subhier *normal_subs; @@ -504,32 +504,33 @@ struct mosquitto_db{ #endif struct mosquitto__message_v5 *plugin_msgs; #ifdef WITH_TLS - char *tls_keylog; /* This can't be in the config struct because it is used - before the config is allocated. Config probably - shouldn't be separately allocated. */ + /* tls_keylog can't be in the config struct because it is used + before the config is allocated. Config probably + shouldn't be separately allocated. */ + char *tls_keylog; #endif bool shutdown; }; -enum mosquitto__bridge_direction{ +enum mosquitto__bridge_direction { bd_out = 0, bd_in = 1, - bd_both = 2 + bd_both = 2, }; -enum mosquitto_bridge_start_type{ +enum mosquitto_bridge_start_type { bst_automatic = 0, bst_lazy = 1, bst_manual = 2, - bst_once = 3 + bst_once = 3, }; -enum mosquitto_bridge_reload_type{ +enum mosquitto_bridge_reload_type { brt_lazy = 0, brt_immediate = 1, }; -struct mosquitto__bridge_topic{ +struct mosquitto__bridge_topic { struct mosquitto__bridge_topic *next; char *topic; char *local_prefix; @@ -540,12 +541,12 @@ struct mosquitto__bridge_topic{ uint8_t qos; }; -struct bridge_address{ +struct bridge_address { char *address; uint16_t port; }; -struct mosquitto__bridge{ +struct mosquitto__bridge { char *name; struct bridge_address *addresses; int cur_address; @@ -707,7 +708,7 @@ int db__message_count(int *count); int db__message_delete_outgoing(struct mosquitto *context, uint16_t mid, enum mosquitto_msg_state expect_state, int qos); int db__message_insert_outgoing(struct mosquitto *context, uint64_t cmsg_id, uint16_t mid, uint8_t qos, bool retain, struct mosquitto__base_msg *base_msg, uint32_t subscription_identifier, bool update, bool persist); int db__message_insert_incoming(struct mosquitto *context, uint64_t cmsg_id, struct mosquitto__base_msg *base_msg, bool persist); -int db__message_remove_incoming(struct mosquitto* context, uint16_t mid); +int db__message_remove_incoming(struct mosquitto *context, uint16_t mid); int db__message_release_incoming(struct mosquitto *context, uint16_t mid); int db__message_update_outgoing(struct mosquitto *context, uint16_t mid, enum mosquitto_msg_state state, int qos, bool persist); void db__message_dequeue_first(struct mosquitto *context, struct mosquitto_msg_data *msg_data); @@ -910,7 +911,7 @@ int config__plugin_add_secopt(mosquitto_plugin_id_t *plugin, struct mosquitto__s int mosquitto_security_init(bool reload); int mosquitto_security_cleanup(bool reload); -int mosquitto_acl_check(struct mosquitto *context, const char *topic, uint32_t payloadlen, void* payload, uint8_t qos, bool retain, int access); +int mosquitto_acl_check(struct mosquitto *context, const char *topic, uint32_t payloadlen, void *payload, uint8_t qos, bool retain, int access); int mosquitto_basic_auth(struct mosquitto *context); int mosquitto_psk_key_get(struct mosquitto *context, const char *hint, const char *identity, char *key, int max_key_len); @@ -954,7 +955,7 @@ void service_install(char *name); void service_uninstall(char *name); void service_run(char *name); -DWORD WINAPI SigThreadProc(void* data); +DWORD WINAPI SigThreadProc(void *data); #endif /* ============================================================ diff --git a/src/password_file.h b/src/password_file.h index bc43e356..7a4f7068 100644 --- a/src/password_file.h +++ b/src/password_file.h @@ -20,14 +20,14 @@ Contributors: #include -struct mosquitto__unpwd{ +struct mosquitto__unpwd { UT_hash_handle hh; char *username; char *clientid; struct mosquitto_pw *pw; }; -struct password_file_data{ +struct password_file_data { struct mosquitto__unpwd *unpwd; char *password_file; }; diff --git a/src/persist.h b/src/persist.h index f5b22339..f8edf441 100644 --- a/src/persist.h +++ b/src/persist.h @@ -49,25 +49,25 @@ extern const unsigned char magic[15]; * whether what is being added can go in an existing hole in the struct. */ -struct PF_header{ +struct PF_header { uint32_t chunk; uint32_t length; }; -struct PF_cfg{ +struct PF_cfg { uint64_t last_db_id; uint8_t shutdown; uint8_t dbid_size; }; -struct PF_client_v5{ +struct PF_client_v5 { int64_t session_expiry_time; uint32_t session_expiry_interval; uint16_t last_mid; uint16_t id_len; }; -struct PF_client{ +struct PF_client { /* struct PF_client_v5; */ int64_t session_expiry_time; uint32_t session_expiry_interval; @@ -79,14 +79,14 @@ struct PF_client{ /* tail: 4 byte padding, because 64bit member * forces multiple of 8 for struct size */ }; -struct P_client{ +struct P_client { struct PF_client F; char *clientid; char *username; }; -struct PF_client_msg{ +struct PF_client_msg { dbid_t store_id; uint16_t mid; uint16_t id_len; @@ -95,14 +95,14 @@ struct PF_client_msg{ uint8_t retain_dup; uint8_t direction; }; -struct P_client_msg{ +struct P_client_msg { struct PF_client_msg F; char *clientid; uint32_t subscription_identifier; }; -struct PF_base_msg{ +struct PF_base_msg { dbid_t store_id; int64_t expiry_time; uint32_t payloadlen; @@ -114,7 +114,7 @@ struct PF_base_msg{ uint8_t qos; uint8_t retain; }; -struct P_base_msg{ +struct P_base_msg { struct PF_base_msg F; void *payload; struct mosquitto source; @@ -123,24 +123,24 @@ struct P_base_msg{ }; -struct PF_sub{ +struct PF_sub { uint32_t identifier; uint16_t id_len; uint16_t topic_len; uint8_t qos; uint8_t options; }; -struct P_sub{ +struct P_sub { struct PF_sub F; char *clientid; char *topic; }; -struct PF_retain{ +struct PF_retain { dbid_t store_id; }; -struct P_retain{ +struct P_retain { struct PF_retain F; }; diff --git a/src/sys_tree.h b/src/sys_tree.h index 45540cb8..b2225e5e 100644 --- a/src/sys_tree.h +++ b/src/sys_tree.h @@ -22,7 +22,7 @@ Contributors: #if defined(WITH_SYS_TREE) && defined(WITH_BROKER) /* This ordering *must* match the metrics array in sys_tree.c. */ -enum mosq_metric_type{ +enum mosq_metric_type { mosq_gauge_clients_total = 0, mosq_counter_clients_maximum = 1, mosq_gauge_clients_disconnected = 2, @@ -80,7 +80,7 @@ enum mosq_metric_type{ }; /* This ordering *must* match the metrics_load array in sys_tree.c. */ -enum mosq_metric_load_type{ +enum mosq_metric_load_type { mosq_load_messages_received_1min = 0, mosq_load_messages_received_5min = 1, mosq_load_messages_received_15min = 2, diff --git a/test/path_helper.h b/test/path_helper.h index 3af9b8f7..737fdf03 100644 --- a/test/path_helper.h +++ b/test/path_helper.h @@ -7,10 +7,12 @@ #include #include + /* returns / written to */ -void cat_sourcedir_with_relpath(char* dest, const char* relpath) { - strcpy(dest,TEST_SOURCE_DIR); - strcat(dest, relpath); +void cat_sourcedir_with_relpath(char *dest, const char *relpath) +{ + strcpy(dest, TEST_SOURCE_DIR); + strcat(dest, relpath); } #endif