Skip to content

Commit

Permalink
Rename internal datatypes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralight committed May 16, 2015
1 parent 3c70340 commit b67c90e
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 56 deletions.
4 changes: 2 additions & 2 deletions lib/mosquitto_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,13 @@ struct mosquitto {
#ifdef WITH_BROKER
bool is_dropping;
bool is_bridge;
struct mqtt3__bridge *bridge;
struct mosquitto__bridge *bridge;
struct mosquitto_client_msg *msgs;
struct mosquitto_client_msg *last_msg;
int msg_count;
int msg_count12;
struct mosquitto__acl_user *acl_list;
struct mqtt3__listener *listener;
struct mosquitto__listener *listener;
time_t disconnect_t;
struct mosquitto__packet *out_packet_last;
struct mosquitto__subhier **subs;
Expand Down
2 changes: 1 addition & 1 deletion lib/send_mosq.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ int send__publish(struct mosquitto *mosq, uint16_t mid, const char *topic, uint3
size_t len;
#ifdef WITH_BRIDGE
int i;
struct mqtt3__bridge_topic *cur_topic;
struct mosquitto__bridge_topic *cur_topic;
bool match;
int rc;
char *mapped_topic = NULL;
Expand Down
2 changes: 1 addition & 1 deletion src/bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ and the Eclipse Distribution License is available at

#ifdef WITH_BRIDGE

int bridge__new(struct mosquitto_db *db, struct mqtt3__bridge *bridge)
int bridge__new(struct mosquitto_db *db, struct mosquitto__bridge *bridge)
{
struct mosquitto *new_context = NULL;
struct mosquitto **bridges;
Expand Down
40 changes: 20 additions & 20 deletions src/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extern SERVICE_STATUS_HANDLE service_handle;
static int conf__parse_bool(char **token, const char *name, bool *value, char *saveptr);
static int conf__parse_int(char **token, const char *name, int *value, char *saveptr);
static int conf__parse_string(char **token, const char *name, char **value, char *saveptr);
static int config__read_file(struct mqtt3_config *config, bool reload, const char *file, struct config_recurse *config_tmp, int level, int *lineno);
static int config__read_file(struct mosquitto__config *config, bool reload, const char *file, struct config_recurse *config_tmp, int level, int *lineno);

static int conf__attempt_resolve(const char *host, const char *text, int log, const char *msg)
{
Expand Down Expand Up @@ -100,7 +100,7 @@ static int conf__attempt_resolve(const char *host, const char *text, int log, co
return MOSQ_ERR_SUCCESS;
}

static void config__init_reload(struct mqtt3_config *config)
static void config__init_reload(struct mosquitto__config *config)
{
int i;
/* Set defaults */
Expand Down Expand Up @@ -168,9 +168,9 @@ static void config__init_reload(struct mqtt3_config *config)
}
}

void config__init(struct mqtt3_config *config)
void config__init(struct mosquitto__config *config)
{
memset(config, 0, sizeof(struct mqtt3_config));
memset(config, 0, sizeof(struct mosquitto__config));
config__init_reload(config);
config->config_file = NULL;
config->daemon = false;
Expand Down Expand Up @@ -208,7 +208,7 @@ void config__init(struct mqtt3_config *config)
config->message_size_limit = 0;
}

void config__cleanup(struct mqtt3_config *config)
void config__cleanup(struct mosquitto__config *config)
{
int i;
#ifdef WITH_BRIDGE
Expand Down Expand Up @@ -320,7 +320,7 @@ static void print_usage(void)
printf("\nSee http:https://mosquitto.org/ for more information.\n\n");
}

int config__parse_args(struct mqtt3_config *config, int argc, char *argv[])
int config__parse_args(struct mosquitto__config *config, int argc, char *argv[])
{
int i;
int port_tmp;
Expand Down Expand Up @@ -394,12 +394,12 @@ int config__parse_args(struct mqtt3_config *config, int argc, char *argv[])
|| config->default_listener.protocol != mp_mqtt){

config->listener_count++;
config->listeners = mosquitto__realloc(config->listeners, sizeof(struct mqtt3__listener)*config->listener_count);
config->listeners = mosquitto__realloc(config->listeners, sizeof(struct mosquitto__listener)*config->listener_count);
if(!config->listeners){
mosquitto__log_printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory.");
return MOSQ_ERR_NOMEM;
}
memset(&config->listeners[config->listener_count-1], 0, sizeof(struct mqtt3__listener));
memset(&config->listeners[config->listener_count-1], 0, sizeof(struct mosquitto__listener));
if(config->default_listener.port){
config->listeners[config->listener_count-1].port = config->default_listener.port;
}else{
Expand Down Expand Up @@ -447,7 +447,7 @@ int config__parse_args(struct mqtt3_config *config, int argc, char *argv[])
return MOSQ_ERR_SUCCESS;
}

int config__read(struct mqtt3_config *config, bool reload)
int config__read(struct mosquitto__config *config, bool reload)
{
int rc = MOSQ_ERR_SUCCESS;
struct config_recurse cr;
Expand Down Expand Up @@ -495,7 +495,7 @@ int config__read(struct mqtt3_config *config, bool reload)
}
#endif
/* Default to drop to mosquitto user if no other user specified. This must
* remain here even though it is covered in mqtt3_parse_args() because this
* remain here even though it is covered in config__parse_args() because this
* function may be called on its own. */
if(!config->user){
config->user = "mosquitto";
Expand Down Expand Up @@ -533,16 +533,16 @@ int config__read(struct mqtt3_config *config, bool reload)
return MOSQ_ERR_SUCCESS;
}

int config__read_file_core(struct mqtt3_config *config, bool reload, const char *file, struct config_recurse *cr, int level, int *lineno, FILE *fptr)
int config__read_file_core(struct mosquitto__config *config, bool reload, const char *file, struct config_recurse *cr, int level, int *lineno, FILE *fptr)
{
int rc;
char buf[1024];
char *token;
int tmp_int;
char *saveptr = NULL;
#ifdef WITH_BRIDGE
struct mqtt3__bridge *cur_bridge = NULL;
struct mqtt3__bridge_topic *cur_topic;
struct mosquitto__bridge *cur_bridge = NULL;
struct mosquitto__bridge_topic *cur_topic;
#endif
time_t expiration_mult;
char *key;
Expand All @@ -556,7 +556,7 @@ int config__read_file_core(struct mqtt3_config *config, bool reload, const char
struct dirent *de;
#endif
int len;
struct mqtt3__listener *cur_listener = &config->default_listener;
struct mosquitto__listener *cur_listener = &config->default_listener;
#ifdef WITH_BRIDGE
char *address;
int i;
Expand Down Expand Up @@ -1023,13 +1023,13 @@ int config__read_file_core(struct mqtt3_config *config, bool reload, const char
token = strtok_r(NULL, " ", &saveptr);
if(token){
config->bridge_count++;
config->bridges = mosquitto__realloc(config->bridges, config->bridge_count*sizeof(struct mqtt3__bridge));
config->bridges = mosquitto__realloc(config->bridges, config->bridge_count*sizeof(struct mosquitto__bridge));
if(!config->bridges){
mosquitto__log_printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory.");
return MOSQ_ERR_NOMEM;
}
cur_bridge = &(config->bridges[config->bridge_count-1]);
memset(cur_bridge, 0, sizeof(struct mqtt3__bridge));
memset(cur_bridge, 0, sizeof(struct mosquitto__bridge));
cur_bridge->name = mosquitto__strdup(token);
if(!cur_bridge->name){
mosquitto__log_printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory.");
Expand Down Expand Up @@ -1177,7 +1177,7 @@ int config__read_file_core(struct mqtt3_config *config, bool reload, const char
token = strtok_r(NULL, " ", &saveptr);
if(token){
config->listener_count++;
config->listeners = mosquitto__realloc(config->listeners, sizeof(struct mqtt3__listener)*config->listener_count);
config->listeners = mosquitto__realloc(config->listeners, sizeof(struct mosquitto__listener)*config->listener_count);
if(!config->listeners){
mosquitto__log_printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory.");
return MOSQ_ERR_NOMEM;
Expand All @@ -1188,7 +1188,7 @@ int config__read_file_core(struct mqtt3_config *config, bool reload, const char
return MOSQ_ERR_INVAL;
}
cur_listener = &config->listeners[config->listener_count-1];
memset(cur_listener, 0, sizeof(struct mqtt3__listener));
memset(cur_listener, 0, sizeof(struct mosquitto__listener));
cur_listener->protocol = mp_mqtt;
cur_listener->port = tmp_int;
token = strtok_r(NULL, " ", &saveptr);
Expand Down Expand Up @@ -1699,7 +1699,7 @@ int config__read_file_core(struct mqtt3_config *config, bool reload, const char
if(token){
cur_bridge->topic_count++;
cur_bridge->topics = mosquitto__realloc(cur_bridge->topics,
sizeof(struct mqtt3__bridge_topic)*cur_bridge->topic_count);
sizeof(struct mosquitto__bridge_topic)*cur_bridge->topic_count);
if(!cur_bridge->topics){
mosquitto__log_printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory.");
return MOSQ_ERR_NOMEM;
Expand Down Expand Up @@ -1911,7 +1911,7 @@ int config__read_file_core(struct mqtt3_config *config, bool reload, const char
return MOSQ_ERR_SUCCESS;
}

int config__read_file(struct mqtt3_config *config, bool reload, const char *file, struct config_recurse *cr, int level, int *lineno)
int config__read_file(struct mosquitto__config *config, bool reload, const char *file, struct config_recurse *cr, int level, int *lineno)
{
int rc;
FILE *fptr = NULL;
Expand Down
2 changes: 1 addition & 1 deletion src/database.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ and the Eclipse Distribution License is available at
static int max_inflight = 20;
static int max_queued = 100;

int db__open(struct mqtt3_config *config, struct mosquitto_db *db)
int db__open(struct mosquitto__config *config, struct mosquitto_db *db)
{
int rc = 0;
struct mosquitto__subhier *child;
Expand Down
4 changes: 2 additions & 2 deletions src/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ HANDLE syslog_h;
static int log_destinations = MQTT3_LOG_STDERR;
static int log_priorities = MOSQ_LOG_ERR | MOSQ_LOG_WARNING | MOSQ_LOG_NOTICE | MOSQ_LOG_INFO;

int log__init(struct mqtt3_config *config)
int log__init(struct mosquitto__config *config)
{
int rc = 0;

Expand Down Expand Up @@ -79,7 +79,7 @@ int log__init(struct mqtt3_config *config)
return rc;
}

int log__close(struct mqtt3_config *config)
int log__close(struct mosquitto__config *config)
{
if(log_destinations & MQTT3_LOG_SYSLOG){
#ifndef WIN32
Expand Down
4 changes: 2 additions & 2 deletions src/mosquitto.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ struct mosquitto_db *mosquitto__get_db(void)
* Note that setting config->user to "root" does not produce an error, but it
* strongly discouraged.
*/
int drop_privileges(struct mqtt3_config *config, bool temporary)
int drop_privileges(struct mosquitto__config *config, bool temporary)
{
#if !defined(__CYGWIN__) && !defined(WIN32)
struct passwd *pwd;
Expand Down Expand Up @@ -186,7 +186,7 @@ int main(int argc, char *argv[])
int *listensock = NULL;
int listensock_count = 0;
int listensock_index = 0;
struct mqtt3_config config;
struct mosquitto__config config;
#ifdef WITH_SYS_TREE
char buf[1024];
#endif
Expand Down
44 changes: 22 additions & 22 deletions src/mosquitto_broker.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ enum mosquitto_protocol {

typedef uint64_t dbid_t;

struct mqtt3__listener {
struct mosquitto__listener {
int fd;
char *host;
uint16_t port;
Expand Down Expand Up @@ -151,7 +151,7 @@ struct mqtt3__listener {
#endif
};

struct mqtt3_config {
struct mosquitto__config {
char *config_file;
char *acl_file;
bool allow_anonymous;
Expand All @@ -164,8 +164,8 @@ struct mqtt3_config {
char *clientid_prefixes;
bool connection_messages;
bool daemon;
struct mqtt3__listener default_listener;
struct mqtt3__listener *listeners;
struct mosquitto__listener default_listener;
struct mosquitto__listener *listeners;
int listener_count;
int log_dest;
int log_facility;
Expand Down Expand Up @@ -193,7 +193,7 @@ struct mqtt3_config {
bool have_websockets_listener;
#endif
#ifdef WITH_BRIDGE
struct mqtt3__bridge *bridges;
struct mosquitto__bridge *bridges;
int bridge_count;
#endif
char *auth_plugin;
Expand Down Expand Up @@ -310,7 +310,7 @@ struct mosquitto_db{
int bridge_count;
#endif
int msg_store_count;
struct mqtt3_config *config;
struct mosquitto__config *config;
int persistence_changes;
struct mosquitto__auth_plugin auth_plugin;
#ifdef WITH_SYS_TREE
Expand All @@ -320,7 +320,7 @@ struct mosquitto_db{
struct mosquitto *ll_for_free;
};

enum mqtt3_bridge_direction{
enum mosquitto__bridge_direction{
bd_out = 0,
bd_in = 1,
bd_both = 2
Expand All @@ -333,10 +333,10 @@ enum mosquitto_bridge_start_type{
bst_once = 3
};

struct mqtt3__bridge_topic{
struct mosquitto__bridge_topic{
char *topic;
int qos;
enum mqtt3_bridge_direction direction;
enum mosquitto__bridge_direction direction;
char *local_prefix;
char *remote_prefix;
char *local_topic; /* topic prefixed with local_prefix */
Expand All @@ -348,7 +348,7 @@ struct bridge_address{
int port;
};

struct mqtt3__bridge{
struct mosquitto__bridge{
char *name;
struct bridge_address *addresses;
int cur_address;
Expand All @@ -359,7 +359,7 @@ struct mqtt3__bridge{
bool try_private_accepted;
bool clean_session;
int keepalive;
struct mqtt3__bridge_topic *topics;
struct mosquitto__bridge_topic *topics;
int topic_count;
bool topic_remapping;
enum mosquitto__protocol protocol_version;
Expand Down Expand Up @@ -414,18 +414,18 @@ struct mosquitto_db *mosquitto__get_db(void);
* Config functions
* ============================================================ */
/* Initialise config struct to default values. */
void config__init(struct mqtt3_config *config);
void config__init(struct mosquitto__config *config);
/* Parse command line options into config. */
int config__parse_args(struct mqtt3_config *config, int argc, char *argv[]);
int config__parse_args(struct mosquitto__config *config, int argc, char *argv[]);
/* Read configuration data from config->config_file into config.
* If reload is true, don't process config options that shouldn't be reloaded (listeners etc)
* Returns 0 on success, 1 if there is a configuration error or if a file cannot be opened.
*/
int config__read(struct mqtt3_config *config, bool reload);
int config__read(struct mosquitto__config *config, bool reload);
/* Free all config data. */
void config__cleanup(struct mqtt3_config *config);
void config__cleanup(struct mosquitto__config *config);

int drop_privileges(struct mqtt3_config *config, bool temporary);
int drop_privileges(struct mosquitto__config *config, bool temporary);
int restore_privileges(void);

/* ============================================================
Expand All @@ -438,7 +438,7 @@ int send__suback(struct mosquitto *context, uint16_t mid, uint32_t payloadlen, c
* Network functions
* ============================================================ */
int net__socket_accept(struct mosquitto_db *db, int listensock);
int net__socket_listen(struct mqtt3__listener *listener);
int net__socket_listen(struct mosquitto__listener *listener);
int net__socket_get_address(int sock, char *buf, int len);

/* ============================================================
Expand All @@ -455,7 +455,7 @@ int handle__unsubscribe(struct mosquitto_db *db, struct mosquitto *context);
/* ============================================================
* Database handling
* ============================================================ */
int db__open(struct mqtt3_config *config, struct mosquitto_db *db);
int db__open(struct mosquitto__config *config, struct mosquitto_db *db);
int db__close(struct mosquitto_db *db);
#ifdef WITH_PERSISTENCE
int persist__backup(struct mosquitto_db *db, bool shutdown);
Expand Down Expand Up @@ -506,15 +506,15 @@ void context__free_disused(struct mosquitto_db *db);
/* ============================================================
* Logging functions
* ============================================================ */
int log__init(struct mqtt3_config *config);
int log__close(struct mqtt3_config *config);
int log__init(struct mosquitto__config *config);
int log__close(struct mosquitto__config *config);
int mosquitto__log_printf(struct mosquitto *mosq, int level, const char *fmt, ...) __attribute__((format(printf, 3, 4)));

/* ============================================================
* Bridge functions
* ============================================================ */
#ifdef WITH_BRIDGE
int bridge__new(struct mosquitto_db *db, struct mqtt3__bridge *bridge);
int bridge__new(struct mosquitto_db *db, struct mosquitto__bridge *bridge);
int bridge__connect(struct mosquitto_db *db, struct mosquitto *context);
void bridge__packet_cleanup(struct mosquitto *context);
#endif
Expand Down Expand Up @@ -552,7 +552,7 @@ void service_run(void);
* Websockets related functions
* ============================================================ */
#ifdef WITH_WEBSOCKETS
struct libwebsocket_context *mosq_websockets_init(struct mqtt3__listener *listener, int log_level);
struct libwebsocket_context *mosq_websockets_init(struct mosquitto__listener *listener, int log_level);
#endif
void do_disconnect(struct mosquitto_db *db, struct mosquitto *context);

Expand Down
Loading

0 comments on commit b67c90e

Please sign in to comment.