Remove duplicate code.

pull/2345/merge
Roger A. Light 3 years ago
parent 3cbcc2e2b2
commit 67d0792fd6

@ -13,6 +13,7 @@ if(WITH_TLS AND CJSON_FOUND)
../../lib/memory_mosq.c ../../lib/memory_mosq.h
../../src/memory_public.c
options.c
../../common/json_help.c ../../common/json_help.h
../../common/password_mosq.c ../../common/password_mosq.h
)

@ -28,6 +28,7 @@ OBJS= mosquitto_ctrl.o \
dynsec_hash.o \
dynsec_role.o \
get_password.o \
json_help.o \
memory_mosq.o \
memory_public.o \
options.o \
@ -87,6 +88,9 @@ example.o : example.c mosquitto_ctrl.h
get_password.o : ${R}/apps/mosquitto_passwd/get_password.c ${R}/apps/mosquitto_passwd/get_password.h
${CROSS_COMPILE}${CC} $(LOCAL_CPPFLAGS) $(APP_CPPFLAGS) $(APP_CFLAGS) -c $< -o $@
json_help.o : ${R}/common/json_help.c ${R}/common/json_help.h
${CROSS_COMPILE}${CC} $(APP_CPPFLAGS) $(APP_CFLAGS) -DWITH_CJSON=yes -c $< -o $@
memory_mosq.o : ${R}/lib/memory_mosq.c
${CROSS_COMPILE}${CC} $(APP_CPPFLAGS) $(APP_CFLAGS) -c $< -o $@

@ -92,14 +92,6 @@ void dynsec__print_usage(void)
printf(" https://mosquitto.org/documentation/dynamic-security/\n\n");
}
cJSON *cJSON_AddIntToObject(cJSON * const object, const char * const name, int number)
{
char buf[30];
snprintf(buf, sizeof(buf), "%d", number);
return cJSON_AddRawToObject(object, name, buf);
}
/* ################################################################
* #
* # Payload callback

@ -23,6 +23,7 @@ Contributors:
#include "mosquitto.h"
#include "mosquitto_ctrl.h"
#include "get_password.h"
#include "json_help.h"
#include "password_mosq.h"
#include "dynamic_security.h"

@ -24,6 +24,7 @@ Contributors:
#include "mosquitto.h"
#include "mosquitto_ctrl.h"
#include "json_help.h"
#include "password_mosq.h"
int dynsec_group__create(int argc, char *argv[], cJSON *j_command)

@ -28,6 +28,7 @@ Contributors:
#include "mosquitto.h"
#include "mosquitto_ctrl.h"
#include "json_help.h"
#include "password_mosq.h"
int dynsec_role__create(int argc, char *argv[], cJSON *j_command)

@ -87,8 +87,6 @@ int client_request_response(struct mosq_ctrl *ctrl);
int client_opts_set(struct mosquitto *mosq, struct mosq_config *cfg);
int client_connect(struct mosquitto *mosq, struct mosq_config *cfg);
cJSON *cJSON_AddIntToObject(cJSON * const object, const char * const name, int number);
void broker__print_usage(void);
int broker__main(int argc, char *argv[], struct mosq_ctrl *ctrl);

@ -96,11 +96,11 @@ int json_get_string(cJSON *json, const char *name, char **value, bool optional)
}
cJSON *cJSON_AddIntToObject(cJSON * const object, const char * const name, int number)
cJSON *cJSON_AddIntToObject(cJSON * const object, const char * const name, long long number)
{
char buf[30];
snprintf(buf, sizeof(buf), "%d", number);
snprintf(buf, sizeof(buf), "%lld", number);
return cJSON_AddRawToObject(object, name, buf);
}
#endif

@ -27,7 +27,7 @@ int json_get_bool(cJSON *json, const char *name, bool *value, bool optional, boo
int json_get_int(cJSON *json, const char *name, int *value, bool optional, int default_value);
int json_get_string(cJSON *json, const char *name, char **value, bool optional);
cJSON *cJSON_AddIntToObject(cJSON * const object, const char * const name, int number);
cJSON *cJSON_AddIntToObject(cJSON * const object, const char * const name, long long number);
cJSON *cJSON_CreateInt(int num);
#endif

Loading…
Cancel
Save