Skip to content

Commit

Permalink
Minor build fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralight committed Mar 21, 2021
1 parent cca41d1 commit 2de8c15
Show file tree
Hide file tree
Showing 41 changed files with 123 additions and 162 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ Clients:
- Set `receive-maximum` to not exceed the `-C` message count in mosquitto_sub
and mosquitto_rr, to avoid potentially lost messages. Closes #2134.

Build:
- A variety of minor build related fixes, like functions not having previous
declarations.


2.0.9 - 2021-03-11
==================
Expand Down
1 change: 1 addition & 0 deletions apps/db_dump/db_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#include <sys/stat.h>
#include <time.h>

#include "db_dump.h"
#include <mosquitto_broker_internal.h>
#include <memory_mosq.h>
#include <persist.h>
Expand Down
11 changes: 6 additions & 5 deletions apps/db_dump/print.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#include <inttypes.h>
#include <stdio.h>

#include "db_dump.h"
#include <mosquitto_broker_internal.h>
#include <memory_mosq.h>
#include <mqtt_protocol.h>
Expand Down Expand Up @@ -142,7 +143,7 @@ static void print__properties(mosquitto_property *properties)
}


void print__client(struct P_client *chunk, int length)
void print__client(struct P_client *chunk, uint32_t length)
{
printf("DB_CHUNK_CLIENT:\n");
printf("\tLength: %d\n", length);
Expand All @@ -159,7 +160,7 @@ void print__client(struct P_client *chunk, int length)
}


void print__client_msg(struct P_client_msg *chunk, int length)
void print__client_msg(struct P_client_msg *chunk, uint32_t length)
{
printf("DB_CHUNK_CLIENT_MSG:\n");
printf("\tLength: %d\n", length);
Expand All @@ -175,8 +176,10 @@ void print__client_msg(struct P_client_msg *chunk, int length)
}


void print__msg_store(struct P_msg_store *chunk, int length)
void print__msg_store(struct P_msg_store *chunk, uint32_t length)
{
uint8_t *payload;

printf("DB_CHUNK_MSG_STORE:\n");
printf("\tLength: %d\n", length);
printf("\tStore ID: %" PRIu64 "\n", chunk->F.store_id);
Expand All @@ -190,8 +193,6 @@ void print__msg_store(struct P_msg_store *chunk, int length)
printf("\tPayload Length: %d\n", chunk->F.payloadlen);
printf("\tExpiry Time: %" PRIu64 "\n", chunk->F.expiry_time);

uint8_t *payload;

payload = chunk->payload;
if(chunk->F.payloadlen < 256){
/* Print payloads with UTF-8 data below an arbitrary limit of 256 bytes */
Expand Down
2 changes: 2 additions & 0 deletions apps/db_dump/stubs.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#include <stdlib.h>
#include <string.h>

#include "misc_mosq.h"
#include "mosquitto_broker_internal.h"
#include "mosquitto_internal.h"
#include "util_mosq.h"

struct mosquitto *context__init(mosq_sock_t sock)
{
Expand Down
2 changes: 1 addition & 1 deletion apps/mosquitto_ctrl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LIBMOSQ:=../../lib/libmosquitto.a
endif
endif

LOCAL_CPPFLAGS:=-I../mosquitto_passwd
LOCAL_CPPFLAGS:=-I../mosquitto_passwd -DWITH_CJSON

OBJS= mosquitto_ctrl.o \
client.o \
Expand Down
2 changes: 1 addition & 1 deletion apps/mosquitto_ctrl/dynsec.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ static cJSON *init_create(const char *username, const char *password, const char
}

/* mosquitto_ctrl dynsec init <filename> <admin-user> <admin-password> [role-name] */
int dynsec_init(int argc, char *argv[])
static int dynsec_init(int argc, char *argv[])
{
char *filename;
char *admin_user;
Expand Down
16 changes: 8 additions & 8 deletions apps/mosquitto_ctrl/mosquitto_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#include "mosquitto.h"
#include "mosquitto_ctrl.h"

void print_version(void)
static void print_version(void)
{
int major, minor, revision;

mosquitto_lib_version(&major, &minor, &revision);
printf("mosquitto_ctrl version %s running on libmosquitto %d.%d.%d.\n", VERSION, major, minor, revision);
}

void print_usage(void)
static void print_usage(void)
{
printf("mosquitto_ctrl is a tool for administering certain Mosquitto features.\n");
print_version();
Expand All @@ -51,7 +51,7 @@ int main(int argc, char *argv[])
{
struct mosq_ctrl ctrl;
int rc = MOSQ_ERR_SUCCESS;
FUNC_ctrl_main ctrl_main = NULL;
FUNC_ctrl_main l_ctrl_main = NULL;
void *lib = NULL;
char lib_name[200];

Expand All @@ -76,22 +76,22 @@ int main(int argc, char *argv[])

/* In built modules */
if(!strcasecmp(argv[0], "dynsec")){
ctrl_main = dynsec__main;
l_ctrl_main = dynsec__main;
}else{
/* Attempt external module */
snprintf(lib_name, sizeof(lib_name), "mosquitto_ctrl_%s.so", argv[0]);
lib = LIB_LOAD(lib_name);
if(lib){
ctrl_main = (FUNC_ctrl_main)LIB_SYM(lib, "ctrl_main");
l_ctrl_main = (FUNC_ctrl_main)LIB_SYM(lib, "ctrl_main");
}
}
if(ctrl_main == NULL){
if(l_ctrl_main == NULL){
fprintf(stderr, "Error: Module '%s' not supported.\n", argv[0]);
rc = MOSQ_ERR_NOT_SUPPORTED;
}

if(ctrl_main){
rc = ctrl_main(argc-1, &argv[1], &ctrl);
if(l_ctrl_main){
rc = l_ctrl_main(argc-1, &argv[1], &ctrl);
if(rc < 0){
/* Usage print */
rc = 0;
Expand Down
4 changes: 3 additions & 1 deletion apps/mosquitto_passwd/get_password.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
# include <sys/stat.h>
#endif

#define MAX_BUFFER_LEN 65536
#include "get_password.h"

#define MAX_BUFFER_LEN 65500
#define SALT_LEN 12

void get_password__reset_term(void)
Expand Down
18 changes: 9 additions & 9 deletions apps/mosquitto_passwd/mosquitto_passwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
# include <sys/stat.h>
#endif

#define MAX_BUFFER_LEN 65536
#define MAX_BUFFER_LEN 65500
#define SALT_LEN 12

#include "misc_mosq.h"
Expand Down Expand Up @@ -107,7 +107,7 @@ static FILE *mpw_tmpfile(void)
#endif


void print_usage(void)
static void print_usage(void)
{
printf("mosquitto_passwd is a tool for managing password files for mosquitto.\n\n");
printf("Usage: mosquitto_passwd [-H sha512 | -H sha512-pbkdf2] [-c | -D] passwordfile username\n");
Expand All @@ -122,7 +122,7 @@ void print_usage(void)
printf("\nSee https://mosquitto.org/ for more information.\n\n");
}

int output_new_password(FILE *fptr, const char *username, const char *password, int iterations)
static int output_new_password(FILE *fptr, const char *username, const char *password, int iterations)
{
int rc;
char *salt64 = NULL, *hash64 = NULL;
Expand Down Expand Up @@ -255,7 +255,7 @@ static int delete_pwuser_cb(FILE *fptr, FILE *ftmp, const char *username, const
return 0;
}

int delete_pwuser(FILE *fptr, FILE *ftmp, const char *username)
static int delete_pwuser(FILE *fptr, FILE *ftmp, const char *username)
{
struct cb_helper helper;
int rc;
Expand Down Expand Up @@ -288,7 +288,7 @@ static int update_file_cb(FILE *fptr, FILE *ftmp, const char *username, const ch
}
}

int update_file(FILE *fptr, FILE *ftmp)
static int update_file(FILE *fptr, FILE *ftmp)
{
return pwfile_iterate(fptr, ftmp, update_file_cb, NULL);
}
Expand All @@ -315,7 +315,7 @@ static int update_pwuser_cb(FILE *fptr, FILE *ftmp, const char *username, const
return rc;
}

int update_pwuser(FILE *fptr, FILE *ftmp, const char *username, const char *password, int iterations)
static int update_pwuser(FILE *fptr, FILE *ftmp, const char *username, const char *password, int iterations)
{
struct cb_helper helper;
int rc;
Expand All @@ -334,7 +334,7 @@ int update_pwuser(FILE *fptr, FILE *ftmp, const char *username, const char *pass
}


int copy_contents(FILE *src, FILE *dest)
static int copy_contents(FILE *src, FILE *dest)
{
char buf[MAX_BUFFER_LEN];
size_t len;
Expand All @@ -361,7 +361,7 @@ int copy_contents(FILE *src, FILE *dest)
return 0;
}

int create_backup(const char *backup_file, FILE *fptr)
static int create_backup(const char *backup_file, FILE *fptr)
{
FILE *fbackup;

Expand All @@ -380,7 +380,7 @@ int create_backup(const char *backup_file, FILE *fptr)
return 0;
}

void handle_sigint(int signal)
static void handle_sigint(int signal)
{
get_password__reset_term();

Expand Down
4 changes: 2 additions & 2 deletions client/client_shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ static int check_format(const char *str)
}


void init_config(struct mosq_config *cfg, int pub_or_sub)
static void init_config(struct mosq_config *cfg, int pub_or_sub)
{
memset(cfg, 0, sizeof(*cfg));
cfg->port = PORT_UNDEFINED;
Expand Down Expand Up @@ -485,7 +485,7 @@ int client_config_load(struct mosq_config *cfg, int pub_or_sub, int argc, char *
return MOSQ_ERR_SUCCESS;
}

int cfg_add_topic(struct mosq_config *cfg, int type, char *topic, const char *arg)
static int cfg_add_topic(struct mosq_config *cfg, int type, char *topic, const char *arg)
{
if(mosquitto_validate_utf8(topic, (int )strlen(topic))){
fprintf(stderr, "Error: Malformed UTF-8 in %s argument.\n\n", arg);
Expand Down
8 changes: 4 additions & 4 deletions client/pub_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ int pub_shared_init(void)
}


int pub_stdin_line_loop(struct mosquitto *mosq)
static int pub_stdin_line_loop(struct mosquitto *mosq)
{
char *buf2;
int buf_len_actual = 0;
Expand Down Expand Up @@ -334,7 +334,7 @@ int pub_stdin_line_loop(struct mosquitto *mosq)
}


int pub_other_loop(struct mosquitto *mosq)
static int pub_other_loop(struct mosquitto *mosq)
{
int rc;
int loop_delay = 1000;
Expand Down Expand Up @@ -387,15 +387,15 @@ void pub_shared_cleanup(void)
}


void print_version(void)
static void print_version(void)
{
int major, minor, revision;

mosquitto_lib_version(&major, &minor, &revision);
printf("mosquitto_pub version %s running on libmosquitto %d.%d.%d.\n", VERSION, major, minor, revision);
}

void print_usage(void)
static void print_usage(void)
{
int major, minor, revision;

Expand Down
12 changes: 5 additions & 7 deletions client/rr_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,14 @@ enum rr__state {

static enum rr__state client_state = rr_s_new;

extern struct mosq_config cfg;

bool process_messages = true;
int msg_count = 0;
struct mosquitto *g_mosq = NULL;
static bool timed_out = false;
static int connack_result = 0;

#ifndef WIN32
void my_signal_handler(int signum)
static void my_signal_handler(int signum)
{
if(signum == SIGALRM){
process_messages = false;
Expand All @@ -80,7 +78,7 @@ int my_publish(struct mosquitto *mosq, int *mid, const char *topic, int payloadl
}


void my_message_callback(struct mosquitto *mosq, void *obj, const struct mosquitto_message *message, const mosquitto_property *properties)
static void my_message_callback(struct mosquitto *mosq, void *obj, const struct mosquitto_message *message, const mosquitto_property *properties)
{
UNUSED(mosq);
UNUSED(obj);
Expand Down Expand Up @@ -151,7 +149,7 @@ void my_connect_callback(struct mosquitto *mosq, void *obj, int result, int flag
}


void my_subscribe_callback(struct mosquitto *mosq, void *obj, int mid, int qos_count, const int *granted_qos)
static void my_subscribe_callback(struct mosquitto *mosq, void *obj, int mid, int qos_count, const int *granted_qos)
{
UNUSED(obj);
UNUSED(mid);
Expand Down Expand Up @@ -179,15 +177,15 @@ void my_publish_callback(struct mosquitto *mosq, void *obj, int mid, int reason_
}


void print_version(void)
static void print_version(void)
{
int major, minor, revision;

mosquitto_lib_version(&major, &minor, &revision);
printf("mosquitto_rr version %s running on libmosquitto %d.%d.%d.\n", VERSION, major, minor, revision);
}

void print_usage(void)
static void print_usage(void)
{
int major, minor, revision;

Expand Down
Loading

0 comments on commit 2de8c15

Please sign in to comment.