From 2a9743509407210d719888eeaae3ed0f414cc42b Mon Sep 17 00:00:00 2001 From: Amin Ben Romdhane Date: Mon, 16 Sep 2024 12:22:55 +0000 Subject: [PATCH] static-analysis: Fix issues reported in libbbfdm-api --- libbbfdm-api/dmapi.c | 6 +- libbbfdm-api/dmbbf.c | 2 +- libbbfdm-api/dmbbf.h | 2 +- libbbfdm-api/dmcommon.c | 199 ++++++++++++++++------------ libbbfdm-api/dmcommon.h | 107 +++++++-------- libbbfdm-api/dmentry.c | 4 +- libbbfdm-api/dmentry.h | 4 +- libbbfdm-api/dmjson.c | 29 ++-- libbbfdm-api/dmjson.h | 2 +- libbbfdm-api/dmplugin.c | 22 +-- libbbfdm-api/dmplugin.h | 6 +- libbbfdm-api/dmubus.c | 26 ++-- libbbfdm-api/dmubus.h | 14 +- libbbfdm-api/dmuci.c | 77 +++++------ libbbfdm-api/dmuci.h | 108 +++++++-------- libbbfdm-api/include/libbbfdm_api.h | 32 ++--- 16 files changed, 339 insertions(+), 301 deletions(-) diff --git a/libbbfdm-api/dmapi.c b/libbbfdm-api/dmapi.c index 9b81f8ee..b079bbe0 100644 --- a/libbbfdm-api/dmapi.c +++ b/libbbfdm-api/dmapi.c @@ -91,7 +91,7 @@ int bbf_uci_set_section_name(char *sec_name, char *str, size_t size) return dmuci_set_section_name(sec_name, str, size); } -struct uci_section *bbf_uci_walk_section(char *package, char *type, void *arg1, void *arg2, int cmp, int (*filter)(struct uci_section *s, void *value), struct uci_section *prev_section, int walk) +struct uci_section *bbf_uci_walk_section(char *package, char *type, void *arg1, void *arg2, int cmp, int (*filter)(struct uci_section *s, const void *value), struct uci_section *prev_section, int walk) { return dmuci_walk_section(package, type, arg1, arg2, cmp, filter, prev_section, walk); @@ -317,7 +317,7 @@ int bbfdm_get_reference_linker(struct dmctx *ctx, char *reference_path, struct d return 0; } -static char *bbfdm_get_reference_value(char *reference_path) +static char *bbfdm_get_reference_value(const char *reference_path) { unsigned int reference_path_dot_num = count_occurrences(reference_path, '.'); json_object *res = NULL; @@ -379,7 +379,7 @@ static char *bbfdm_get_reference_value(char *reference_path) return NULL; } -int bbfdm_operate_reference_linker(struct dmctx *ctx, char *reference_path, char **reference_value) +int bbfdm_operate_reference_linker(struct dmctx *ctx, const char *reference_path, char **reference_value) { if (!ctx) { BBF_ERR("%s: ctx should not be null", __func__); diff --git a/libbbfdm-api/dmbbf.c b/libbbfdm-api/dmbbf.c index fa3ed83d..8cb62504 100644 --- a/libbbfdm-api/dmbbf.c +++ b/libbbfdm-api/dmbbf.c @@ -793,7 +793,7 @@ void fill_blob_operate(struct blob_buf *bb, const char *path, const char *data, blobmsg_close_table(bb, op_table); } -int string_to_bool(char *v, bool *b) +int string_to_bool(const char *v, bool *b) { if (v[0] == '1' && v[1] == '\0') { *b = true; diff --git a/libbbfdm-api/dmbbf.h b/libbbfdm-api/dmbbf.h index 7405dc30..bd123ec2 100644 --- a/libbbfdm-api/dmbbf.h +++ b/libbbfdm-api/dmbbf.h @@ -39,7 +39,7 @@ void fill_blob_param(struct blob_buf *bb, const char *path, const char *data, co void fill_blob_event(struct blob_buf *bb, const char *path, const char *type, void *data); void fill_blob_operate(struct blob_buf *bb, const char *path, const char *data, const char *type, void *in_out); -int string_to_bool(char *v, bool *b); +int string_to_bool(const char *v, bool *b); char *get_value_by_reference(struct dmctx *ctx, char *value); int dm_entry_get_value(struct dmctx *dmctx); int dm_entry_get_name(struct dmctx *ctx); diff --git a/libbbfdm-api/dmcommon.c b/libbbfdm-api/dmcommon.c index 79f19567..d0469f9f 100644 --- a/libbbfdm-api/dmcommon.c +++ b/libbbfdm-api/dmcommon.c @@ -28,19 +28,23 @@ char *IPv6Prefix[] = {"^$", "^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-f pid_t get_pid(const char *pname) { - DIR* dir; - struct dirent* ent; - char* endptr; - char buf[512]; + DIR *dir = NULL; + struct dirent *ent = NULL; - if (!(dir = opendir("/proc"))) { + if (!pname) return -1; - } + + if (!(dir = opendir("/proc"))) + return -1; + while((ent = readdir(dir)) != NULL) { + char *endptr = NULL; + char buf[512] = {0}; + long lpid = strtol(ent->d_name, &endptr, 10); - if (*endptr != '\0') { + if (*endptr != '\0') continue; - } + snprintf(buf, sizeof(buf), "/proc/%ld/cmdline", lpid); FILE* fp = fopen(buf, "r"); if (fp) { @@ -56,6 +60,7 @@ pid_t get_pid(const char *pname) } } closedir(dir); + return -1; } @@ -82,13 +87,18 @@ char *get_uptime(void) return uptime; } -int check_file(char *path) +int check_file(const char *path) { glob_t globbuf; + + if (!path) + return 0; + if(glob(path, 0, NULL, &globbuf) == 0) { globfree(&globbuf); return 1; } + return 0; } @@ -131,15 +141,20 @@ int netmask2cidr(const char *netmask) } -bool is_strword_in_optionvalue(char *optionvalue, char *str) +bool is_strword_in_optionvalue(const char *option_value, const char *str) { - char *s = optionvalue; + if (!option_value || !str) + return false; + + const char *s = option_value; + while ((s = DM_STRSTR(s, str))) { int len = DM_STRLEN(str); //should be inside while, optimization reason if(s[len] == '\0' || s[len] == ' ') return true; s++; } + return false; } @@ -168,14 +183,14 @@ static void dmcmd_exec(char *argv[]) exit(127); } -int dmcmd(char *cmd, int n, ...) +int dmcmd(const char *cmd, int n, ...) { char *argv[n + 2]; va_list arg; int i, status; pid_t pid, wpid; - argv[0] = cmd; + argv[0] = (char *)cmd; va_start(arg, n); for (i = 0; i < n; i++) { argv[i + 1] = va_arg(arg, char *); @@ -202,14 +217,14 @@ int dmcmd(char *cmd, int n, ...) return -1; } -int dmcmd_no_wait(char *cmd, int n, ...) +int dmcmd_no_wait(const char *cmd, int n, ...) { char *argv[n + 2]; va_list arg; int i; pid_t pid; - argv[0] = cmd; + argv[0] = (char *)cmd; va_start(arg, n); for (i = 0; i < n; i++) { argv[i + 1] = va_arg(arg, char *); @@ -252,16 +267,21 @@ int run_cmd(const char *cmd, char *output, size_t out_len) return ret; } -void hex_to_ip(char *address, char *ret, size_t size) +int hex_to_ip(const char *address, char *ret, size_t size) { unsigned int ip[4] = {0}; + if (!address || !ret || !size) + return -1; + sscanf(address, "%2x%2x%2x%2x", &(ip[0]), &(ip[1]), &(ip[2]), &(ip[3])); if (htonl(13) == 13) { snprintf(ret, size, "%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]); } else { snprintf(ret, size, "%u.%u.%u.%u", ip[3], ip[2], ip[1], ip[0]); } + + return 0; } /* @@ -290,7 +310,7 @@ void free_dmmap_config_dup_list(struct list_head *dup_list) /* * Function allows to synchronize config section with dmmap config */ -struct uci_section *get_origin_section_from_config(char *package, char *section_type, char *orig_section_name) +struct uci_section *get_origin_section_from_config(const char *package, const char *section_type, const char *orig_section_name) { struct uci_section *s = NULL; @@ -302,7 +322,7 @@ struct uci_section *get_origin_section_from_config(char *package, char *section_ return NULL; } -struct uci_section *get_origin_section_from_dmmap(char *package, char *section_type, char *orig_section_name) +struct uci_section *get_origin_section_from_dmmap(const char *package, const char *section_type, const char *orig_section_name) { struct uci_section *s = NULL; @@ -314,9 +334,9 @@ struct uci_section *get_origin_section_from_dmmap(char *package, char *section_t return NULL; } -struct uci_section *get_dup_section_in_dmmap(char *dmmap_package, char *section_type, char *orig_section_name) +struct uci_section *get_dup_section_in_dmmap(const char *dmmap_package, const char *section_type, const char *orig_section_name) { - struct uci_section *s; + struct uci_section *s = NULL; uci_path_foreach_sections(bbfdm, dmmap_package, section_type, s) { char *dmmap_sec_name = NULL; @@ -330,9 +350,9 @@ struct uci_section *get_dup_section_in_dmmap(char *dmmap_package, char *section_ return NULL; } -struct uci_section *get_dup_section_in_config_opt(char *package, char *section_type, char *opt_name, char *opt_value) +struct uci_section *get_dup_section_in_config_opt(const char *package, const char *section_type, const char *opt_name, const char *opt_value) { - struct uci_section *s; + struct uci_section *s = NULL; uci_foreach_option_eq(package, section_type, opt_name, opt_value, s) { return s; @@ -341,9 +361,9 @@ struct uci_section *get_dup_section_in_config_opt(char *package, char *section_t return NULL; } -struct uci_section *get_dup_section_in_dmmap_opt(char *dmmap_package, char *section_type, char *opt_name, char *opt_value) +struct uci_section *get_dup_section_in_dmmap_opt(const char *dmmap_package, const char *section_type, const char *opt_name, const char *opt_value) { - struct uci_section *s; + struct uci_section *s = NULL; uci_path_foreach_option_eq(bbfdm, dmmap_package, section_type, opt_name, opt_value, s) { return s; @@ -352,20 +372,23 @@ struct uci_section *get_dup_section_in_dmmap_opt(char *dmmap_package, char *sect return NULL; } -struct uci_section *get_dup_section_in_dmmap_eq(char *dmmap_package, char* section_type, char*sect_name, char *opt_name, char *opt_value) +struct uci_section *get_dup_section_in_dmmap_eq(const char *dmmap_package, const char *section_type, + const char *sect_name, const char *opt_name, const char *opt_value) { - struct uci_section *s; - char *v; + struct uci_section *s = NULL; + char *v = NULL; uci_path_foreach_option_eq(bbfdm, dmmap_package, section_type, "section_name", sect_name, s) { dmuci_get_value_by_section_string(s, opt_name, &v); if (DM_STRCMP(v, opt_value) == 0) return s; } + return NULL; } -struct uci_section *get_section_in_dmmap_with_options_eq(char *dmmap_package, char *section_type, char *opt1_name, char *opt1_value, char *opt2_name, char *opt2_value) +struct uci_section *get_section_in_dmmap_with_options_eq(const char *dmmap_package, const char *section_type, + const char *opt1_name, const char *opt1_value, const char *opt2_name, const char *opt2_value) { struct uci_section *s = NULL; @@ -380,10 +403,10 @@ struct uci_section *get_section_in_dmmap_with_options_eq(char *dmmap_package, ch return NULL; } -void synchronize_specific_config_sections_with_dmmap(char *package, char *section_type, char *dmmap_package, struct list_head *dup_list) +void synchronize_specific_config_sections_with_dmmap(const char *package, const char *section_type, const char *dmmap_package, struct list_head *dup_list) { - struct uci_section *s, *stmp, *dmmap_sect; - char *v; + struct uci_section *s = NULL, *stmp = NULL, *dmmap_sect = NULL; + char *v = NULL; uci_foreach_sections(package, section_type, s) { /* @@ -410,7 +433,8 @@ void synchronize_specific_config_sections_with_dmmap(char *package, char *sectio } } -void synchronize_specific_config_sections_with_dmmap_eq(char *package, char *section_type, char *dmmap_package, char* option_name, char* option_value, struct list_head *dup_list) +void synchronize_specific_config_sections_with_dmmap_eq(const char *package, const char *section_type, const char *dmmap_package, + const char *option_name, const char *option_value, struct list_head *dup_list) { struct uci_section *s, *stmp, *dmmap_sec; char *v; @@ -440,10 +464,11 @@ void synchronize_specific_config_sections_with_dmmap_eq(char *package, char *sec } } -void synchronize_specific_config_sections_with_dmmap_cont(char *package, char *section_type, char *dmmap_package, char* option_name, char* option_value, struct list_head *dup_list) +void synchronize_specific_config_sections_with_dmmap_cont(const char *package, const char *section_type, const char *dmmap_package, + const char *option_name, const char *option_value, struct list_head *dup_list) { - struct uci_section *uci_s, *stmp, *dmmap_sect; - char *v; + struct uci_section *uci_s = NULL, *stmp = NULL, *dmmap_sect = NULL; + char *v = NULL; uci_foreach_option_cont(package, section_type, option_name, option_value, uci_s) { /* @@ -470,9 +495,9 @@ void synchronize_specific_config_sections_with_dmmap_cont(char *package, char *s } } -void get_dmmap_section_of_config_section(char* dmmap_package, char* section_type, char *section_name, struct uci_section **dmmap_section) +void get_dmmap_section_of_config_section(const char *dmmap_package, const char *section_type, const char *section_name, struct uci_section **dmmap_section) { - struct uci_section *s; + struct uci_section *s = NULL; uci_path_foreach_option_eq(bbfdm, dmmap_package, section_type, "section_name", section_name, s) { *dmmap_section = s; @@ -481,9 +506,9 @@ void get_dmmap_section_of_config_section(char* dmmap_package, char* section_type *dmmap_section = NULL; } -void get_dmmap_section_of_config_section_eq(char* dmmap_package, char* section_type, char *opt, char* value, struct uci_section **dmmap_section) +void get_dmmap_section_of_config_section_eq(const char *dmmap_package, const char *section_type, const char *opt, const char *value, struct uci_section **dmmap_section) { - struct uci_section *s; + struct uci_section *s = NULL; uci_path_foreach_option_eq(bbfdm, dmmap_package, section_type, opt, value, s) { *dmmap_section = s; @@ -492,9 +517,9 @@ void get_dmmap_section_of_config_section_eq(char* dmmap_package, char* section_t *dmmap_section = NULL; } -void get_dmmap_section_of_config_section_cont(char* dmmap_package, char* section_type, char *opt, char* value, struct uci_section **dmmap_section) +void get_dmmap_section_of_config_section_cont(const char *dmmap_package, const char *section_type, const char *opt, const char *value, struct uci_section **dmmap_section) { - struct uci_section *s; + struct uci_section *s = NULL; uci_path_foreach_option_cont(bbfdm, dmmap_package, section_type, opt, value, s) { *dmmap_section = s; @@ -503,9 +528,9 @@ void get_dmmap_section_of_config_section_cont(char* dmmap_package, char* section *dmmap_section = NULL; } -void get_config_section_of_dmmap_section(char* package, char* section_type, char *section_name, struct uci_section **config_section) +void get_config_section_of_dmmap_section(const char *package, const char *section_type, const char *section_name, struct uci_section **config_section) { - struct uci_section *s; + struct uci_section *s = NULL; uci_foreach_sections(package, section_type, s) { if (strcmp(section_name(s), section_name) == 0) { @@ -516,11 +541,14 @@ void get_config_section_of_dmmap_section(char* package, char* section_type, char *config_section = NULL; } -char *check_create_dmmap_package(const char *dmmap_package) +static char *check_create_dmmap_package(const char *dmmap_package) { - char *path; + char *path = NULL; int rc; + if (!dmmap_package) + return NULL; + rc = dmasprintf(&path, "/etc/bbfdm/dmmap/%s", dmmap_package); if (rc == -1) return NULL; @@ -533,12 +561,13 @@ char *check_create_dmmap_package(const char *dmmap_package) if (fp) fclose(fp); } + return path; } -struct uci_section *is_dmmap_section_exist(char* package, char* section) +struct uci_section *is_dmmap_section_exist(const char *package, const char *section) { - struct uci_section *s; + struct uci_section *s = NULL; uci_path_foreach_sections(bbfdm, package, section, s) { return s; @@ -546,9 +575,9 @@ struct uci_section *is_dmmap_section_exist(char* package, char* section) return NULL; } -struct uci_section *is_dmmap_section_exist_eq(char* package, char* section, char* opt, char* value) +struct uci_section *is_dmmap_section_exist_eq(const char *package, const char *section, const char *opt, const char *value) { - struct uci_section *s; + struct uci_section *s = NULL; uci_path_foreach_option_eq(bbfdm, package, section, opt, value, s) { return s; @@ -695,7 +724,7 @@ void convert_str_to_uppercase(char *str) } } -char *get_macaddr(char *interface_name) +char *get_macaddr(const char *interface_name) { char *device = get_device(interface_name); char *mac; @@ -714,7 +743,7 @@ char *get_macaddr(char *interface_name) return mac; } -char *get_device(char *interface_name) +char *get_device(const char *interface_name) { json_object *res; @@ -722,7 +751,7 @@ char *get_device(char *interface_name) return dmjson_get_value(res, 1, "device"); } -char *get_l3_device(char *interface_name) +char *get_l3_device(const char *interface_name) { json_object *res; @@ -745,7 +774,7 @@ bool value_exists_in_uci_list(struct uci_list *list, const char *value) return false; } -bool value_exits_in_str_list(char *str_list, const char *delimitor, const char *str) +bool value_exits_in_str_list(const char *str_list, const char *delimitor, const char *str) { char *pch = NULL, *spch = NULL; @@ -762,7 +791,7 @@ bool value_exits_in_str_list(char *str_list, const char *delimitor, const char * return false; } -char *add_str_to_str_list(char *str_list, const char *delimitor, const char *str) +char *add_str_to_str_list(const char *str_list, const char *delimitor, const char *str) { char *res = ""; @@ -774,7 +803,7 @@ char *add_str_to_str_list(char *str_list, const char *delimitor, const char *str return res; } -char *remove_str_from_str_list(char *str_list, const char *delimitor, const char *str) +char *remove_str_from_str_list(const char *str_list, const char *delimitor, const char *str) { char *pch = NULL, *spch = NULL; unsigned pos = 0; @@ -1006,6 +1035,9 @@ bool match(const char *string, const char *pattern, size_t nmatch, regmatch_t pm { regex_t re; + if (!string || !pattern) + return 0; + if (regcomp(&re, pattern, REG_EXTENDED) != 0) return 0; @@ -1029,7 +1061,7 @@ void bbfdm_set_fault_message(struct dmctx *ctx, const char *format, ...) va_end(args); } -static int bbfdm_validate_string_length(struct dmctx *ctx, char *value, int min_length, int max_length) +static int bbfdm_validate_string_length(struct dmctx *ctx, const char *value, int min_length, int max_length) { if ((min_length > 0) && (DM_STRLEN(value) < min_length)) { bbfdm_set_fault_message(ctx, "The length of '%s' value must be greater than '%d'.", value, min_length); @@ -1044,7 +1076,7 @@ static int bbfdm_validate_string_length(struct dmctx *ctx, char *value, int min_ return 0; } -static int bbfdm_validate_string_enumeration(struct dmctx *ctx, char *value, char *enumeration[]) +static int bbfdm_validate_string_enumeration(struct dmctx *ctx, const char *value, char *enumeration[]) { for (; *enumeration; enumeration++) { if (DM_STRCMP(*enumeration, value) == 0) @@ -1055,7 +1087,7 @@ static int bbfdm_validate_string_enumeration(struct dmctx *ctx, char *value, cha return -1; } -static int bbfdm_validate_string_pattern(struct dmctx *ctx, char *value, char *pattern[]) +static int bbfdm_validate_string_pattern(struct dmctx *ctx, const char *value, char *pattern[]) { for (; *pattern; pattern++) { if (match(value, *pattern, 0, NULL)) @@ -1066,7 +1098,7 @@ static int bbfdm_validate_string_pattern(struct dmctx *ctx, char *value, char *p return -1; } -int bbfdm_validate_string(struct dmctx *ctx, char *value, int min_length, int max_length, char *enumeration[], char *pattern[]) +int bbfdm_validate_string(struct dmctx *ctx, const char *value, int min_length, int max_length, char *enumeration[], char *pattern[]) { /* check size */ if (bbfdm_validate_string_length(ctx, value, min_length, max_length)) @@ -1083,7 +1115,7 @@ int bbfdm_validate_string(struct dmctx *ctx, char *value, int min_length, int ma return 0; } -int bbfdm_validate_boolean(struct dmctx *ctx, char *value) +int bbfdm_validate_boolean(struct dmctx *ctx, const char *value) { /* check format */ if ((value[0] == '1' && value[1] == '\0') || @@ -1097,7 +1129,7 @@ int bbfdm_validate_boolean(struct dmctx *ctx, char *value) return -1; } -int bbfdm_validate_unsignedInt(struct dmctx *ctx, char *value, struct range_args r_args[], int r_args_size) +int bbfdm_validate_unsignedInt(struct dmctx *ctx, const char *value, struct range_args r_args[], int r_args_size) { if (!value || value[0] == 0) { bbfdm_set_fault_message(ctx, "Value should not be blank."); @@ -1160,7 +1192,7 @@ int bbfdm_validate_unsignedInt(struct dmctx *ctx, char *value, struct range_args return 0; } -int bbfdm_validate_int(struct dmctx *ctx, char *value, struct range_args r_args[], int r_args_size) +int bbfdm_validate_int(struct dmctx *ctx, const char *value, struct range_args r_args[], int r_args_size) { if (!value || value[0] == 0) { bbfdm_set_fault_message(ctx, "Value should not be blank."); @@ -1218,7 +1250,7 @@ int bbfdm_validate_int(struct dmctx *ctx, char *value, struct range_args r_args[ return 0; } -int bbfdm_validate_unsignedLong(struct dmctx *ctx, char *value, struct range_args r_args[], int r_args_size) +int bbfdm_validate_unsignedLong(struct dmctx *ctx, const char *value, struct range_args r_args[], int r_args_size) { if (!value || value[0] == 0) { bbfdm_set_fault_message(ctx, "Value should not be blank."); @@ -1276,7 +1308,7 @@ int bbfdm_validate_unsignedLong(struct dmctx *ctx, char *value, struct range_arg return 0; } -int bbfdm_validate_long(struct dmctx *ctx, char *value, struct range_args r_args[], int r_args_size) +int bbfdm_validate_long(struct dmctx *ctx, const char *value, struct range_args r_args[], int r_args_size) { if (!value || value[0] == 0) { bbfdm_set_fault_message(ctx, "Value should not be blank."); @@ -1329,7 +1361,7 @@ int bbfdm_validate_long(struct dmctx *ctx, char *value, struct range_args r_args return 0; } -int bbfdm_validate_dateTime(struct dmctx *ctx, char *value) +int bbfdm_validate_dateTime(struct dmctx *ctx, const char *value) { /* * Allowed format: @@ -1361,7 +1393,7 @@ int bbfdm_validate_dateTime(struct dmctx *ctx, char *value) return 0; } -int bbfdm_validate_hexBinary(struct dmctx *ctx, char *value, struct range_args r_args[], int r_args_size) +int bbfdm_validate_hexBinary(struct dmctx *ctx, const char *value, struct range_args r_args[], int r_args_size) { int i; @@ -1421,7 +1453,7 @@ static int bbfdm_validate_size_list(struct dmctx *ctx, int min_item, int max_ite return 0; } -int bbfdm_validate_string_list(struct dmctx *ctx, char *value, int min_item, int max_item, int max_size, int min, int max, char *enumeration[], char *pattern[]) +int bbfdm_validate_string_list(struct dmctx *ctx, const char *value, int min_item, int max_item, int max_size, int min, int max, char *enumeration[], char *pattern[]) { char *pch, *pchr; int nbr_item = 0; @@ -1455,7 +1487,7 @@ int bbfdm_validate_string_list(struct dmctx *ctx, char *value, int min_item, int return 0; } -int bbfdm_validate_unsignedInt_list(struct dmctx *ctx, char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size) +int bbfdm_validate_unsignedInt_list(struct dmctx *ctx, const char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size) { char *tmp, *saveptr; int nbr_item = 0; @@ -1489,7 +1521,7 @@ int bbfdm_validate_unsignedInt_list(struct dmctx *ctx, char *value, int min_item return 0; } -int bbfdm_validate_int_list(struct dmctx *ctx, char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size) +int bbfdm_validate_int_list(struct dmctx *ctx, const char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size) { char *token, *pchr; int nbr_item = 0; @@ -1523,7 +1555,7 @@ int bbfdm_validate_int_list(struct dmctx *ctx, char *value, int min_item, int ma return 0; } -int bbfdm_validate_unsignedLong_list(struct dmctx *ctx, char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size) +int bbfdm_validate_unsignedLong_list(struct dmctx *ctx, const char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size) { char *token, *tmp; int nbr_item = 0; @@ -1557,7 +1589,7 @@ int bbfdm_validate_unsignedLong_list(struct dmctx *ctx, char *value, int min_ite return 0; } -int bbfdm_validate_long_list(struct dmctx *ctx, char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size) +int bbfdm_validate_long_list(struct dmctx *ctx, const char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size) { char *pch, *saveptr; int nbr_item = 0; @@ -1591,7 +1623,7 @@ int bbfdm_validate_long_list(struct dmctx *ctx, char *value, int min_item, int m return 0; } -int bbfdm_validate_hexBinary_list(struct dmctx *ctx, char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size) +int bbfdm_validate_hexBinary_list(struct dmctx *ctx, const char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size) { char *pch, *spch; int nbr_item = 0; @@ -1851,7 +1883,7 @@ void strip_lead_trail_whitespace(char *str) } } -int dm_buf_to_file(char *buf, const char *filename) +int dm_buf_to_file(const char *buf, const char *filename) { FILE *file; int ret = -1; @@ -1868,7 +1900,7 @@ int dm_buf_to_file(char *buf, const char *filename) return ret; } -int dm_file_to_buf(const char *filename, void *buf, size_t buf_size) +int dm_file_to_buf(const char *filename, char *buf, size_t buf_size) { FILE *file; int ret = -1; @@ -1878,11 +1910,11 @@ int dm_file_to_buf(const char *filename, void *buf, size_t buf_size) ret = fread(buf, 1, buf_size - 1, file); fclose(file); } - ((char *)buf)[ret > 0 ? ret : 0] = '\0'; + buf[ret > 0 ? ret : 0] = '\0'; return ret; } -int dm_file_copy(char *src, char *dst) +int dm_file_copy(const char *src, const char *dst) { size_t n; char buf[1024]; @@ -1941,20 +1973,23 @@ int parse_proc_intf6_line(const char *line, const char *device, char *ipstr, siz return 0; } -char *diagnostics_get_option(char *sec_name, char *option) +char *diagnostics_get_option(const char *sec_name, const char *option) { char *value = NULL; dmuci_get_option_value_string_bbfdm(DMMAP_DIAGNOSTIGS, sec_name, option, &value); return value; } -char *diagnostics_get_option_fallback_def(char *sec_name, char *option, char *default_value) +char *diagnostics_get_option_fallback_def(const char *sec_name, const char *option, const char *default_value) { char *value = diagnostics_get_option(sec_name, option); - return (*value != '\0') ? value : default_value; + if (DM_STRLEN(value) == 0) + value = dmstrdup(default_value); + + return value; } -void diagnostics_set_option(char *sec_name, char *option, char *value) +void diagnostics_set_option(const char *sec_name, const char *option, const char *value) { check_create_dmmap_package(DMMAP_DIAGNOSTIGS); struct uci_section *section = dmuci_walk_section_bbfdm(DMMAP_DIAGNOSTIGS, sec_name, NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION); @@ -1964,7 +1999,7 @@ void diagnostics_set_option(char *sec_name, char *option, char *value) dmuci_set_value_bbfdm(DMMAP_DIAGNOSTIGS, sec_name, option, value); } -void diagnostics_reset_state(char *sec_name) +void diagnostics_reset_state(const char *sec_name) { char *diag_state = diagnostics_get_option(sec_name, "DiagnosticState"); if (strcmp(diag_state, "Requested") != 0) { @@ -1972,7 +2007,7 @@ void diagnostics_reset_state(char *sec_name) } } -char *diagnostics_get_interface_name(struct dmctx *ctx, char *value) +char *diagnostics_get_interface_name(struct dmctx *ctx, const char *value) { char *linker = NULL; diff --git a/libbbfdm-api/dmcommon.h b/libbbfdm-api/dmcommon.h index 5095b8d2..aefc4433 100644 --- a/libbbfdm-api/dmcommon.h +++ b/libbbfdm-api/dmcommon.h @@ -131,28 +131,29 @@ struct dhcp_options_type { pid_t get_pid(const char *pname); int compare_strings(const void *a, const void *b); char *get_uptime(void); -int check_file(char *path); +int check_file(const char *path); char *cidr2netmask(int bits); int netmask2cidr(const char *netmask); -bool is_strword_in_optionvalue(char *optionvalue, char *str); +bool is_strword_in_optionvalue(const char *option_value, const char *str); void remove_new_line(char *buf); -int dmcmd(char *cmd, int n, ...); -int dmcmd_no_wait(char *cmd, int n, ...); +int dmcmd(const char *cmd, int n, ...); +int dmcmd_no_wait(const char *cmd, int n, ...); int run_cmd(const char *cmd, char *output, size_t out_len); -void hex_to_ip(char *address, char *ret, size_t size); +int hex_to_ip(const char *address, char *ret, size_t size); void add_dmmap_config_dup_list(struct list_head *dup_list, struct uci_section *config_section, struct uci_section *dmmap_section); void free_dmmap_config_dup_list(struct list_head *dup_list); -void synchronize_specific_config_sections_with_dmmap(char *package, char *section_type, char *dmmap_package, struct list_head *dup_list); -void synchronize_specific_config_sections_with_dmmap_eq(char *package, char *section_type, char *dmmap_package,char* option_name, char* option_value, struct list_head *dup_list); -void synchronize_specific_config_sections_with_dmmap_cont(char *package, char *section_type, char *dmmap_package,char* option_name, char* option_value, struct list_head *dup_list); -void get_dmmap_section_of_config_section(char* dmmap_package, char* section_type, char *section_name, struct uci_section **dmmap_section); -void get_dmmap_section_of_config_section_eq(char* dmmap_package, char* section_type, char *opt, char* value, struct uci_section **dmmap_section); -void get_dmmap_section_of_config_section_cont(char* dmmap_package, char* section_type, char *opt, char* value, struct uci_section **dmmap_section); -void get_config_section_of_dmmap_section(char* package, char* section_type, char *section_name, struct uci_section **config_section); +void synchronize_specific_config_sections_with_dmmap(const char *package, const char *section_type, const char *dmmap_package, struct list_head *dup_list); +void synchronize_specific_config_sections_with_dmmap_eq(const char *package, const char *section_type, const char *dmmap_package, + const char *option_name, const char *option_value, struct list_head *dup_list); +void synchronize_specific_config_sections_with_dmmap_cont(const char *package, const char *section_type, const char *dmmap_package, + const char *option_name, const char *option_value, struct list_head *dup_list); +void get_dmmap_section_of_config_section(const char *dmmap_package, const char *section_type, const char *section_name, struct uci_section **dmmap_section); +void get_dmmap_section_of_config_section_eq(const char *dmmap_package, const char *section_type, const char *opt, const char *value, struct uci_section **dmmap_section); +void get_dmmap_section_of_config_section_cont(const char *dmmap_package, const char *section_type, const char *opt, const char *value, struct uci_section **dmmap_section); +void get_config_section_of_dmmap_section(const char *package, const char *section_type, const char *section_name, struct uci_section **config_section); int adm_entry_get_reference_param(struct dmctx *ctx, char *param, char *linker, char **value); -int adm_entry_get_reference_value(struct dmctx *ctx, char *param, char **value); +int adm_entry_get_reference_value(struct dmctx *ctx, const char *param, char **value); int dm_validate_allowed_objects(struct dmctx *ctx, struct dm_reference *reference, char *objects[]); -char *check_create_dmmap_package(const char *dmmap_package); unsigned int count_occurrences(const char *str, char c); bool isdigit_str(const char *str); bool ishex_str(const char *str); @@ -162,24 +163,26 @@ void replace_special_char(char *str, char c); char *dm_strword(char *src, char *str); char **strsplit(const char* str, const char* delim, size_t* numtokens); void convert_str_to_uppercase(char *str); -char *get_macaddr(char *interface_name); -char *get_device(char *interface_name); -char *get_l3_device(char *interface_name); +char *get_macaddr(const char *interface_name); +char *get_device(const char *interface_name); +char *get_l3_device(const char *interface_name); bool value_exists_in_uci_list(struct uci_list *list, const char *value); -bool value_exits_in_str_list(char *str_list, const char *delimitor, const char *str); -char *add_str_to_str_list(char *str_list, const char *delimitor, const char *str); -char *remove_str_from_str_list(char *str_list, const char *delimitor, const char *str); -struct uci_section *get_origin_section_from_config(char *package, char *section_type, char *orig_section_name); -struct uci_section *get_origin_section_from_dmmap(char *package, char *section_type, char *orig_section_name); -struct uci_section *get_dup_section_in_dmmap(char *dmmap_package, char *section_type, char *orig_section_name); -struct uci_section *get_dup_section_in_config_opt(char *package, char *section_type, char *opt_name, char *opt_value); -struct uci_section *get_dup_section_in_dmmap_opt(char *dmmap_package, char *section_type, char *opt_name, char *opt_value); -struct uci_section *get_dup_section_in_dmmap_eq(char *dmmap_package, char* section_type, char*sect_name, char *opt_name, char* opt_value); -struct uci_section *get_section_in_dmmap_with_options_eq(char *dmmap_package, char *section_type, char *opt1_name, char *opt1_value, char *opt2_name, char *opt2_value); +bool value_exits_in_str_list(const char *str_list, const char *delimitor, const char *str); +char *add_str_to_str_list(const char *str_list, const char *delimitor, const char *str); +char *remove_str_from_str_list(const char *str_list, const char *delimitor, const char *str); +struct uci_section *get_origin_section_from_config(const char *package, const char *section_type, const char *orig_section_name); +struct uci_section *get_origin_section_from_dmmap(const char *package, const char *section_type, const char *orig_section_name); +struct uci_section *get_dup_section_in_dmmap(const char *dmmap_package, const char *section_type, const char *orig_section_name); +struct uci_section *get_dup_section_in_config_opt(const char *package, const char *section_type, const char *opt_name, const char *opt_value); +struct uci_section *get_dup_section_in_dmmap_opt(const char *dmmap_package, const char *section_type, const char *opt_name, const char *opt_value); +struct uci_section *get_dup_section_in_dmmap_eq(const char *dmmap_package, const char *section_type, + const char *sect_name, const char *opt_name, const char *opt_value); +struct uci_section *get_section_in_dmmap_with_options_eq(const char *dmmap_package, const char *section_type, + const char *opt1_name, const char *opt1_value, const char *opt2_name, const char *opt2_value); int get_shift_utc_time(int shift_time, char *utc_time, int size); int get_shift_time_time(int shift_time, char *local_time, int size); -struct uci_section *is_dmmap_section_exist(char* package, char* section); -struct uci_section *is_dmmap_section_exist_eq(char* package, char* section, char* opt, char* value); +struct uci_section *is_dmmap_section_exist(const char *package, const char *section); +struct uci_section *is_dmmap_section_exist_eq(const char *package, const char *section, const char *opt, const char *value); int dm_read_sysfs_file(const char *file, char *dst, unsigned len); int get_net_iface_sysfs(const char *uci_iface, const char *name, char **value); int get_net_device_sysfs(const char *device, const char *name, char **value); @@ -190,26 +193,26 @@ void convert_string_to_hex(const char *str, char *hex, size_t size); void convert_hex_to_string(const char *hex, char *str, size_t size); bool match(const char *string, const char *pattern, size_t nmatch, regmatch_t pmatch[]); void bbfdm_set_fault_message(struct dmctx *ctx, const char *format, ...); -int bbfdm_validate_boolean(struct dmctx *ctx, char *value); -int bbfdm_validate_unsignedInt(struct dmctx *ctx, char *value, struct range_args r_args[], int r_args_size); -int bbfdm_validate_int(struct dmctx *ctx, char *value, struct range_args r_args[], int r_args_size); -int bbfdm_validate_unsignedLong(struct dmctx *ctx, char *value, struct range_args r_args[], int r_args_size); -int bbfdm_validate_long(struct dmctx *ctx, char *value, struct range_args r_args[], int r_args_size); -int bbfdm_validate_string(struct dmctx *ctx, char *value, int min_length, int max_length, char *enumeration[], char *pattern[]); -int bbfdm_validate_dateTime(struct dmctx *ctx, char *value); -int bbfdm_validate_hexBinary(struct dmctx *ctx, char *value, struct range_args r_args[], int r_args_size); -int bbfdm_validate_unsignedInt_list(struct dmctx *ctx, char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size); -int bbfdm_validate_int_list(struct dmctx *ctx, char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size); -int bbfdm_validate_unsignedLong_list(struct dmctx *ctx, char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size); -int bbfdm_validate_long_list(struct dmctx *ctx, char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size); -int bbfdm_validate_string_list(struct dmctx *ctx, char *value, int min_item, int max_item, int max_size, int min, int max, char *enumeration[], char *pattern[]); -int bbfdm_validate_hexBinary_list(struct dmctx *ctx, char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size); +int bbfdm_validate_boolean(struct dmctx *ctx, const char *value); +int bbfdm_validate_unsignedInt(struct dmctx *ctx, const char *value, struct range_args r_args[], int r_args_size); +int bbfdm_validate_int(struct dmctx *ctx, const char *value, struct range_args r_args[], int r_args_size); +int bbfdm_validate_unsignedLong(struct dmctx *ctx, const char *value, struct range_args r_args[], int r_args_size); +int bbfdm_validate_long(struct dmctx *ctx, const char *value, struct range_args r_args[], int r_args_size); +int bbfdm_validate_string(struct dmctx *ctx, const char *value, int min_length, int max_length, char *enumeration[], char *pattern[]); +int bbfdm_validate_dateTime(struct dmctx *ctx, const char *value); +int bbfdm_validate_hexBinary(struct dmctx *ctx, const char *value, struct range_args r_args[], int r_args_size); +int bbfdm_validate_unsignedInt_list(struct dmctx *ctx, const char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size); +int bbfdm_validate_int_list(struct dmctx *ctx, const char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size); +int bbfdm_validate_unsignedLong_list(struct dmctx *ctx, const char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size); +int bbfdm_validate_long_list(struct dmctx *ctx, const char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size); +int bbfdm_validate_string_list(struct dmctx *ctx, const char *value, int min_item, int max_item, int max_size, int min, int max, char *enumeration[], char *pattern[]); +int bbfdm_validate_hexBinary_list(struct dmctx *ctx, const char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size); int bbf_get_alias(struct dmctx *ctx, struct uci_section *s, char *option_name, char *instance, char **value); int bbf_set_alias(struct dmctx *ctx, struct uci_section *s, char *option_name, char *instance, char *value); int bbfdm_get_references(struct dmctx *ctx, int match_action, const char *base_path, char *key_name, char *key_value, char *out, size_t out_len); int _bbfdm_get_references(struct dmctx *ctx, const char *base_path, char *key_name, char *key_value, char **value); int bbfdm_get_reference_linker(struct dmctx *ctx, char *reference_path, struct dm_reference *reference_args); -int bbfdm_operate_reference_linker(struct dmctx *ctx, char *reference_path, char **reference_value); +int bbfdm_operate_reference_linker(struct dmctx *ctx, const char *reference_path, char **reference_value); char *base64_decode(const char *src); void string_to_mac(const char *str, size_t str_len, char *out, size_t out_len); bool folder_exists(const char *path); @@ -219,16 +222,16 @@ unsigned long file_system_size(const char *path, const enum fs_size_type_enum ty void remove_char(char *str, const char c); char *replace_char(char *str, char find, char replace); char *replace_str(const char *input_str, const char *old_substr, const char *new_substr, char *result_str, size_t buffer_len); -int dm_file_to_buf(const char *filename, void *buf, size_t buf_size); -int dm_file_copy(char *src, char *dst); +int dm_file_to_buf(const char *filename, char *buf, size_t buf_size); +int dm_file_copy(const char *src, const char *dst); int parse_proc_intf6_line(const char *line, const char *device, char *ipstr, size_t str_len); void strip_lead_trail_whitespace(char *str); -int dm_buf_to_file(char *buf, const char *filename); -char *diagnostics_get_option(char *sec_name, char *option); -char *diagnostics_get_option_fallback_def(char *sec_name, char *option, char *default_value); -void diagnostics_set_option(char *sec_name, char *option, char *value); -void diagnostics_reset_state(char *sec_name); -char *diagnostics_get_interface_name(struct dmctx *ctx, char *value); +int dm_buf_to_file(const char *buf, const char *filename); +char *diagnostics_get_option(const char *sec_name, const char *option); +char *diagnostics_get_option_fallback_def(const char *sec_name, const char *option, const char *default_value); +void diagnostics_set_option(const char *sec_name, const char *option, const char *value); +void diagnostics_reset_state(const char *sec_name); +char *diagnostics_get_interface_name(struct dmctx *ctx, const char *value); long download_file(char *file_path, const char *url, const char *username, const char *password); long upload_file(const char *file_path, const char *url, const char *username, const char *password); diff --git a/libbbfdm-api/dmentry.c b/libbbfdm-api/dmentry.c index c67cecec..a9c8ea2a 100644 --- a/libbbfdm-api/dmentry.c +++ b/libbbfdm-api/dmentry.c @@ -293,7 +293,7 @@ int adm_entry_get_reference_param(struct dmctx *ctx, char *param, char *linker, return 0; } -int adm_entry_get_reference_value(struct dmctx *ctx, char *param, char **value) +int adm_entry_get_reference_value(struct dmctx *ctx, const char *param, char **value) { struct dmctx dmctx = {0}; char linker[256] = {0}; @@ -316,7 +316,7 @@ int adm_entry_get_reference_value(struct dmctx *ctx, char *param, char **value) return 0; } -bool adm_entry_object_exists(struct dmctx *ctx, char *param) // To be removed later!!!!!!!!!!!! (After moving all Objects outside bbfdm core) +bool adm_entry_object_exists(struct dmctx *ctx, const char *param) // To be removed later!!!!!!!!!!!! (After moving all Objects outside bbfdm core) { struct dmctx dmctx = {0}; char linker[256] = {0}; diff --git a/libbbfdm-api/dmentry.h b/libbbfdm-api/dmentry.h index 66a5669c..ee9acde5 100644 --- a/libbbfdm-api/dmentry.h +++ b/libbbfdm-api/dmentry.h @@ -30,12 +30,12 @@ void bbf_global_clean(DMOBJ *dm_entryobj); int dm_validate_allowed_objects(struct dmctx *ctx, struct dm_reference *reference, char *objects[]); -bool adm_entry_object_exists(struct dmctx *ctx, char *param); // To be removed later!!!!!!!!!!!! (After moving all Objects outside bbfdm core) +bool adm_entry_object_exists(struct dmctx *ctx, const char *param); // To be removed later!!!!!!!!!!!! (After moving all Objects outside bbfdm core) void bbf_entry_services(unsigned int proto, bool is_commit, bool reload_required); void get_list_of_registered_service(struct list_head *srvlist, struct blob_buf *bb); -bool load_service(DMOBJ *main_dm, struct list_head *srv_list, char *srv_name, char *srv_parent_dm, char *srv_obj); +bool load_service(DMOBJ *main_dm, struct list_head *srv_list, const char *srv_name, const char *srv_parent_dm, const char *srv_obj); void free_services_from_list(struct list_head *clist); #endif //__DMENTRY_H__ diff --git a/libbbfdm-api/dmjson.c b/libbbfdm-api/dmjson.c index e87ae440..f4f9809f 100644 --- a/libbbfdm-api/dmjson.c +++ b/libbbfdm-api/dmjson.c @@ -12,7 +12,7 @@ #include "dmjson.h" -static json_object *dmjson_select_obj(json_object *jobj, char *argv[]) +static json_object *dmjson_select_obj(json_object *jobj, const char *argv[]) { int i; for (i = 0; argv[i]; i++) { @@ -45,7 +45,7 @@ static char *dmjson_print_value(json_object *jobj) return ret; } -static char *____dmjson_get_value_in_obj(json_object *mainjobj, char *argv[]) +static char *____dmjson_get_value_in_obj(json_object *mainjobj, const char *argv[]) { json_object *jobj = dmjson_select_obj(mainjobj, argv); return dmjson_print_value(jobj); @@ -54,7 +54,7 @@ static char *____dmjson_get_value_in_obj(json_object *mainjobj, char *argv[]) char *__dmjson_get_value_in_obj(json_object *mainjobj, int argc, ...) { va_list arg; - char *argv[64]; + const char *argv[64]; int i; if (!mainjobj) @@ -72,7 +72,7 @@ char *__dmjson_get_value_in_obj(json_object *mainjobj, int argc, ...) json_object *__dmjson_get_obj(json_object *mainjobj, int argc, ...) { va_list arg; - char *argv[64]; + const char *argv[64]; int i; va_start(arg, argc); @@ -84,7 +84,7 @@ json_object *__dmjson_get_obj(json_object *mainjobj, int argc, ...) return dmjson_select_obj(mainjobj, argv); } -static json_object *____dmjson_select_obj_in_array_idx(json_object *mainjobj, json_object **arrobj, int index, char *argv[]) +static json_object *____dmjson_select_obj_in_array_idx(json_object *mainjobj, json_object **arrobj, int index, const char *argv[]) { json_object *jobj = NULL; @@ -110,7 +110,7 @@ json_object *__dmjson_select_obj_in_array_idx(json_object *mainjobj, json_object { va_list arg; json_object *jobj; - char *argv[64]; + const char *argv[64]; int i; if (mainjobj == NULL) @@ -129,7 +129,7 @@ json_object *__dmjson_select_obj_in_array_idx(json_object *mainjobj, json_object return jobj; } -static char *____dmjson_get_value_in_array_idx(json_object *mainjobj, json_object **arrobj, int index, char *argv[]) +static char *____dmjson_get_value_in_array_idx(json_object *mainjobj, json_object **arrobj, int index, const char *argv[]) { json_object *jobj = NULL; char *value = NULL; @@ -158,7 +158,8 @@ static char *____dmjson_get_value_in_array_idx(json_object *mainjobj, json_objec char *__dmjson_get_value_in_array_idx(json_object *mainjobj, json_object **arrobj, char *defret, int index, int argc, ...) { va_list arg; - char *argv[64], *v; + const char *argv[64]; + char *v = NULL; int i; if (mainjobj == NULL) @@ -174,13 +175,12 @@ char *__dmjson_get_value_in_array_idx(json_object *mainjobj, json_object **arrob return (v ? v : defret) ; } -static char *____dmjson_get_value_array_all(json_object *mainjobj, char *delim, char *argv[]) +static char *____dmjson_get_value_array_all(json_object *mainjobj, const char *delim, const char *argv[]) { json_object *arrobj; char *v, *ret = ""; int i, dlen, rlen; - delim = (delim) ? delim : ","; dlen = (delim) ? DM_STRLEN(delim) : 1; for (i = 0, arrobj = NULL, v = ____dmjson_get_value_in_array_idx(mainjobj, &arrobj, i, argv); @@ -192,15 +192,15 @@ static char *____dmjson_get_value_array_all(json_object *mainjobj, char *delim, } else if (*v) { rlen = strlen(ret); ret = dmrealloc(ret, rlen + dlen + strlen(v) + 1); - snprintf(&ret[rlen], dlen + strlen(v) + 1, "%s%s", delim, v); + snprintf(&ret[rlen], dlen + strlen(v) + 1, "%s%s", delim ? delim : ",", v); } } return ret; } -char *__dmjson_get_value_array_all(json_object *mainjobj, char *delim, int argc, ...) +char *__dmjson_get_value_array_all(json_object *mainjobj, const char *delim, int argc, ...) { - char *argv[64], *ret; + const char *argv[64]; va_list arg; int i; @@ -210,6 +210,5 @@ char *__dmjson_get_value_array_all(json_object *mainjobj, char *delim, int argc, } argv[argc] = NULL; va_end(arg); - ret = ____dmjson_get_value_array_all(mainjobj, delim, argv); - return ret; + return ____dmjson_get_value_array_all(mainjobj, delim, argv); } diff --git a/libbbfdm-api/dmjson.h b/libbbfdm-api/dmjson.h index 66a86b29..117aa17d 100644 --- a/libbbfdm-api/dmjson.h +++ b/libbbfdm-api/dmjson.h @@ -31,7 +31,7 @@ json_object *__dmjson_get_obj(json_object *mainjobj, int argc, ...); char *__dmjson_get_value_in_obj(json_object *mainjobj, int argc, ...); char *__dmjson_get_value_in_array_idx(json_object *mainjobj, json_object **arrobj, char *defret, int index, int argc, ...); json_object *__dmjson_select_obj_in_array_idx(json_object *mainjobj, json_object **arrobj, int index, int argc, ...); -char *__dmjson_get_value_array_all(json_object *mainjobj, char *delim, int argc, ...); +char *__dmjson_get_value_array_all(json_object *mainjobj, const char *delim, int argc, ...); #define dmjson_get_value(JOBJ,ARGC,args...) \ __dmjson_get_value_in_obj(JOBJ, ARGC, ##args) diff --git a/libbbfdm-api/dmplugin.c b/libbbfdm-api/dmplugin.c index 313cf189..04aeb24c 100644 --- a/libbbfdm-api/dmplugin.c +++ b/libbbfdm-api/dmplugin.c @@ -24,7 +24,7 @@ struct service char *object; }; -static bool add_service_to_main_tree(DMOBJ *main_dm, char *srv_name, char *srv_parent_dm, char *srv_obj) +static bool add_service_to_main_tree(DMOBJ *main_dm, const char *srv_name, const char *srv_parent_dm, const char *srv_obj) { DMOBJ *dm_entryobj = find_entry_obj(main_dm, srv_parent_dm); if (!dm_entryobj) @@ -59,7 +59,7 @@ static bool add_service_to_main_tree(DMOBJ *main_dm, char *srv_name, char *srv_p return true; } -static bool is_service_registered(struct list_head *srvlist, char *srv_name, char *srv_parent_dm, char *srv_obj) +static bool is_service_registered(struct list_head *srvlist, const char *srv_name, const char *srv_parent_dm, const char *srv_obj) { struct service *srv = NULL; @@ -73,7 +73,7 @@ static bool is_service_registered(struct list_head *srvlist, char *srv_name, cha return false; } -static void add_service_to_list(struct list_head *srvlist, char *srv_name, char *srv_parent_dm, char *srv_object) +static void add_service_to_list(struct list_head *srvlist, const char *srv_name, const char *srv_parent_dm, const char *srv_object) { struct service *srv = NULL; @@ -99,7 +99,7 @@ void free_services_from_list(struct list_head *clist) } } -bool load_service(DMOBJ *main_dm, struct list_head *srv_list, char *srv_name, char *srv_parent_dm, char *srv_obj) +bool load_service(DMOBJ *main_dm, struct list_head *srv_list, const char *srv_name, const char *srv_parent_dm, const char *srv_obj) { if (!main_dm || !srv_list || !srv_name || !srv_parent_dm || !srv_obj) { BBF_ERR("Invalid arguments: main_dm, srv_list, srv_name, srv_parent_dm, and srv_obj must not be NULL."); @@ -170,7 +170,7 @@ static void free_all_dynamic_nodes(DMOBJ *entryobj) } } -static int plugin_obj_match(char *in_param, struct dmnode *node) +static int plugin_obj_match(const char *in_param, struct dmnode *node) { if (node->matched) return 0; @@ -186,8 +186,8 @@ static int plugin_obj_match(char *in_param, struct dmnode *node) return FAULT_9005; } -static void dm_check_dynamic_obj(struct list_head *mem_list, DMNODE *parent_node, DMOBJ *entryobj, char *full_obj, DMOBJ **root_entry); -static void dm_check_dynamic_obj_entry(struct list_head *mem_list, DMNODE *parent_node, DMOBJ *entryobj, char *parent_obj, char *full_obj, DMOBJ **root_entry) +static void dm_check_dynamic_obj(struct list_head *mem_list, DMNODE *parent_node, DMOBJ *entryobj, const char *full_obj, DMOBJ **root_entry); +static void dm_check_dynamic_obj_entry(struct list_head *mem_list, DMNODE *parent_node, DMOBJ *entryobj, const char *parent_obj, const char *full_obj, DMOBJ **root_entry) { DMNODE node = {0}; node.obj = entryobj; @@ -209,7 +209,7 @@ static void dm_check_dynamic_obj_entry(struct list_head *mem_list, DMNODE *paren dm_check_dynamic_obj(mem_list, &node, entryobj->nextobj, full_obj, root_entry); } -static void dm_check_dynamic_obj(struct list_head *mem_list, DMNODE *parent_node, DMOBJ *entryobj, char *full_obj, DMOBJ **root_entry) +static void dm_check_dynamic_obj(struct list_head *mem_list, DMNODE *parent_node, DMOBJ *entryobj, const char *full_obj, DMOBJ **root_entry) { char *parent_obj = parent_node->current_object; @@ -238,7 +238,7 @@ static void dm_check_dynamic_obj(struct list_head *mem_list, DMNODE *parent_node } } -DMOBJ *find_entry_obj(DMOBJ *entryobj, char *obj_path) +DMOBJ *find_entry_obj(DMOBJ *entryobj, const char *obj_path) { if (!entryobj || !obj_path) return NULL; @@ -259,7 +259,7 @@ DMOBJ *find_entry_obj(DMOBJ *entryobj, char *obj_path) return obj; } -void disable_entry_obj(DMOBJ *entryobj, char *obj_path, const char *parent_obj, const char *plugin_path) +void disable_entry_obj(DMOBJ *entryobj, const char *obj_path, const char *parent_obj, const char *plugin_path) { if (!entryobj || !plugin_path || DM_STRLEN(obj_path) == 0) return; @@ -281,7 +281,7 @@ void disable_entry_obj(DMOBJ *entryobj, char *obj_path, const char *parent_obj, } } -void disable_entry_leaf(DMOBJ *entryobj, char *leaf_path, const char *parent_obj, const char *plugin_path) +void disable_entry_leaf(DMOBJ *entryobj, const char *leaf_path, const char *parent_obj, const char *plugin_path) { if (!entryobj || !plugin_path || DM_STRLEN(leaf_path) == 0) return; diff --git a/libbbfdm-api/dmplugin.h b/libbbfdm-api/dmplugin.h index b60b9abe..b4c6ef63 100644 --- a/libbbfdm-api/dmplugin.h +++ b/libbbfdm-api/dmplugin.h @@ -11,10 +11,10 @@ #ifndef __DMPLUGIN_H__ #define __DMPLUGIN_H__ -DMOBJ *find_entry_obj(DMOBJ *entryobj, char *obj_path); +DMOBJ *find_entry_obj(DMOBJ *entryobj, const char *obj_path); -void disable_entry_obj(DMOBJ *entryobj, char *obj_path, const char *parent_obj, const char *plugin_path); -void disable_entry_leaf(DMOBJ *entryobj, char *leaf_path, const char *parent_obj, const char *plugin_path); +void disable_entry_obj(DMOBJ *entryobj, const char *obj_path, const char *parent_obj, const char *plugin_path); +void disable_entry_leaf(DMOBJ *entryobj, const char *leaf_path, const char *parent_obj, const char *plugin_path); int get_entry_obj_idx(DMOBJ *entryobj); int get_entry_leaf_idx(DMLEAF *entryleaf); diff --git a/libbbfdm-api/dmubus.c b/libbbfdm-api/dmubus.c index 75b934e4..9aac9759 100644 --- a/libbbfdm-api/dmubus.c +++ b/libbbfdm-api/dmubus.c @@ -34,7 +34,7 @@ struct dm_ubus_hash_req { struct ubus_struct { - char *ubus_method_name; + const char *ubus_method_name; bool ubus_method_exists; }; @@ -67,7 +67,7 @@ static void prepare_blob_message(struct blob_buf *b, const struct ubus_arg u_arg blobmsg_add_u32(b, u_args[i].key, DM_STRTOL(u_args[i].val)); } else if (u_args[i].type == Boolean) { bool val = false; - string_to_bool((char *)u_args[i].val, &val); + string_to_bool(u_args[i].val, &val); blobmsg_add_u8(b, u_args[i].key, val); } else if (u_args[i].type == Table) { json_object *jobj = json_tokener_parse(u_args[i].val); @@ -130,7 +130,7 @@ static int __ubus_call_blocking(const char *obj, const char *method, struct blob return __dm_ubus_call_internal(obj, method, UBUS_MAX_BLOCK_TIME, attr); } -int dmubus_call_set(char *obj, char *method, struct ubus_arg u_args[], int u_args_size) +int dmubus_call_set(const char *obj, const char *method, struct ubus_arg u_args[], int u_args_size) { struct blob_buf b; @@ -215,13 +215,13 @@ end: return; } -static inline json_object *ubus_call_req(char *obj, char *method, struct blob_attr *attr) +static inline json_object *ubus_call_req(const char *obj, const char *method, struct blob_attr *attr) { __dm_ubus_call(obj, method, attr); return json_res; } -static int dmubus_call_blob_internal(char *obj, char *method, void *value, int timeout, json_object **resp) +static int dmubus_call_blob_internal(const char *obj, const char *method, json_object *value, int timeout, json_object **resp) { uint32_t id; struct blob_buf blob; @@ -242,7 +242,7 @@ static int dmubus_call_blob_internal(char *obj, char *method, void *value, int t blob_buf_init(&blob, 0); if (value != NULL) { - if (!blobmsg_add_object(&blob, (json_object *)value)) { + if (!blobmsg_add_object(&blob, value)) { blob_buf_free(&blob); return rc; } @@ -258,17 +258,17 @@ static int dmubus_call_blob_internal(char *obj, char *method, void *value, int t return rc; } -int dmubus_call_blob(char *obj, char *method, void *value, json_object **resp) +int dmubus_call_blob(const char *obj, const char *method, json_object *value, json_object **resp) { return dmubus_call_blob_internal(obj, method, value, UBUS_TIMEOUT, resp); } -int dmubus_call_blob_blocking(char *obj, char *method, void *value, json_object **resp) +int dmubus_call_blob_blocking(const char *obj, const char *method, json_object *value, json_object **resp) { return dmubus_call_blob_internal(obj, method, value, UBUS_MAX_BLOCK_TIME, resp); } -int dmubus_call_blob_set(char *obj, char *method, void *value) +int dmubus_call_blob_set(const char *obj, const char *method, json_object *value) { int rc = dmubus_call_blob_internal(obj, method, value, UBUS_TIMEOUT, NULL); @@ -280,7 +280,7 @@ int dmubus_call_blob_set(char *obj, char *method, void *value) return rc; } -static int dmubus_call_blob_msg_internal(char *obj, char *method, struct blob_buf *data, int timeout, json_object **resp) +static int dmubus_call_blob_msg_internal(const char *obj, const char *method, struct blob_buf *data, int timeout, json_object **resp) { uint32_t id = 0; int rc = -1; @@ -309,7 +309,7 @@ static int dmubus_call_blob_msg_internal(char *obj, char *method, struct blob_bu return rc; } -int dmubus_call_blob_msg_set(char *obj, char *method, struct blob_buf *data) +int dmubus_call_blob_msg_set(const char *obj, const char *method, struct blob_buf *data) { int rc = dmubus_call_blob_msg_internal(obj, method, data, UBUS_TIMEOUT, NULL); @@ -388,7 +388,7 @@ static void dm_ubus_cache_entry_free(struct dm_ubus_cache_entry *entry) FREE(entry); } -int dmubus_call(char *obj, char *method, struct ubus_arg u_args[], int u_args_size, json_object **req_res) +int dmubus_call(const char *obj, const char *method, struct ubus_arg u_args[], int u_args_size, json_object **req_res) { struct blob_buf bmsg; @@ -417,7 +417,7 @@ int dmubus_call(char *obj, char *method, struct ubus_arg u_args[], int u_args_si return 0; } -int dmubus_call_blocking(char *obj, char *method, struct ubus_arg u_args[], int u_args_size, json_object **req_res) +int dmubus_call_blocking(const char *obj, const char *method, struct ubus_arg u_args[], int u_args_size, json_object **req_res) { int rc = 0; struct blob_buf bmsg; diff --git a/libbbfdm-api/dmubus.h b/libbbfdm-api/dmubus.h index 98b2159b..d9a99c0a 100644 --- a/libbbfdm-api/dmubus.h +++ b/libbbfdm-api/dmubus.h @@ -36,15 +36,15 @@ typedef void (*CB_FUNC_PTR)(struct ubus_context *ctx, struct ubus_event_handler void dmubus_wait_for_event(const char *event, int timeout, void *ev_data, CB_FUNC_PTR ev_callback, struct dmubus_ev_subtask *subtask); -int dmubus_call(char *obj, char *method, struct ubus_arg u_args[], int u_args_size, json_object **req_res); -int dmubus_call_blocking(char *obj, char *method, struct ubus_arg u_args[], int u_args_size, json_object **req_res); -int dmubus_call_set(char *obj, char *method, struct ubus_arg u_args[], int u_args_size); +int dmubus_call(const char *obj, const char *method, struct ubus_arg u_args[], int u_args_size, json_object **req_res); +int dmubus_call_blocking(const char *obj, const char *method, struct ubus_arg u_args[], int u_args_size, json_object **req_res); +int dmubus_call_set(const char *obj, const char *method, struct ubus_arg u_args[], int u_args_size); -int dmubus_call_blob(char *obj, char *method, void *value, json_object **resp); -int dmubus_call_blob_blocking(char *obj, char *method, void *value, json_object **resp); -int dmubus_call_blob_set(char *obj, char *method, void *value); +int dmubus_call_blob(const char *obj, const char *method, json_object *value, json_object **resp); +int dmubus_call_blob_blocking(const char *obj, const char *method, json_object *value, json_object **resp); +int dmubus_call_blob_set(const char *obj, const char *method, json_object *value); -int dmubus_call_blob_msg_set(char *obj, char *method, struct blob_buf *blob_msg); +int dmubus_call_blob_msg_set(const char *obj, const char *method, struct blob_buf *blob_msg); void dmubus_free(); diff --git a/libbbfdm-api/dmuci.c b/libbbfdm-api/dmuci.c index 3b8429e5..927136d5 100644 --- a/libbbfdm-api/dmuci.c +++ b/libbbfdm-api/dmuci.c @@ -114,7 +114,7 @@ static inline bool check_section_name(const char *str, bool name) } /**** UCI LOOKUP ****/ -int dmuci_lookup_ptr(struct uci_context *ctx, struct uci_ptr *ptr, char *package, char *section, char *option, char *value) +int dmuci_lookup_ptr(struct uci_context *ctx, struct uci_ptr *ptr, const char *package, const char *section, const char *option, const char *value) { /*value*/ ptr->value = value; @@ -149,7 +149,7 @@ lookup: } /**** UCI GET *****/ -int dmuci_get_section_type(char *package, char *section, char **value) +int dmuci_get_section_type(const char *package, const char *section, char **value) { struct uci_ptr ptr = {0}; @@ -166,7 +166,7 @@ int dmuci_get_section_type(char *package, char *section, char **value) return 0; } -int dmuci_get_option_value_string(char *package, char *section, char *option, char **value) +int dmuci_get_option_value_string(const char *package, const char *section, const char *option, char **value) { struct uci_ptr ptr = {0}; @@ -185,18 +185,18 @@ int dmuci_get_option_value_string(char *package, char *section, char *option, ch return 0; } -char *dmuci_get_option_value_fallback_def(char *package, char *section, char *option, char *default_value) +char *dmuci_get_option_value_fallback_def(const char *package, const char *section, const char *option, const char *default_value) { char *value = ""; dmuci_get_option_value_string(package, section, option, &value); if (*value == '\0') - value = default_value; + value = dmstrdup(default_value); return value; } -int dmuci_get_option_value_list(char *package, char *section, char *option, struct uci_list **value) +int dmuci_get_option_value_list(const char *package, const char *section, const char *option, struct uci_list **value) { struct uci_element *e = NULL; struct uci_ptr ptr = {0}; @@ -237,7 +237,7 @@ int dmuci_get_option_value_list(char *package, char *section, char *option, stru return 0; } -static struct uci_option *dmuci_get_option_ptr(char *cfg_path, char *package, char *section, char *option) +static struct uci_option *dmuci_get_option_ptr(char *cfg_path, const char *package, const char *section, const char *option) { struct uci_option *o = NULL; struct uci_element *e = NULL; @@ -264,7 +264,7 @@ end: } /**** UCI IMPORT *****/ -int dmuci_import(char *package_name, const char *input_path) +int dmuci_import(const char *package_name, const char *input_path) { struct uci_package *package = NULL; struct uci_element *e = NULL; @@ -455,7 +455,7 @@ int dmuci_revert(void) } /**** UCI SET *****/ -int dmuci_set_value(char *package, char *section, char *option, char *value) +int dmuci_set_value(const char *package, const char *section, const char *option, const char *value) { struct uci_ptr ptr = {0}; @@ -469,7 +469,7 @@ int dmuci_set_value(char *package, char *section, char *option, char *value) } /**** UCI ADD LIST *****/ -int dmuci_add_list_value(char *package, char *section, char *option, char *value) +int dmuci_add_list_value(const char *package, const char *section, const char *option, const char *value) { struct uci_ptr ptr = {0}; @@ -483,7 +483,7 @@ int dmuci_add_list_value(char *package, char *section, char *option, char *value } /**** UCI DEL LIST *****/ -int dmuci_del_list_value(char *package, char *section, char *option, char *value) +int dmuci_del_list_value(const char *package, const char *section, const char *option, const char *value) { struct uci_ptr ptr = {0}; @@ -497,7 +497,7 @@ int dmuci_del_list_value(char *package, char *section, char *option, char *value } /****** UCI ADD *******/ -int dmuci_add_section(char *package, char *stype, struct uci_section **s) +int dmuci_add_section(const char *package, const char *stype, struct uci_section **s) { struct uci_ptr ptr = {0}; char fname[128]; @@ -523,7 +523,7 @@ int dmuci_add_section(char *package, char *stype, struct uci_section **s) } /**** UCI DELETE *****/ -int dmuci_delete(char *package, char *section, char *option, char *value) +int dmuci_delete(const char *package, const char *section, const char *option, const char *value) { struct uci_ptr ptr = {0}; @@ -537,7 +537,7 @@ int dmuci_delete(char *package, char *section, char *option, char *value) } /**** UCI RENAME SECTION *****/ -int dmuci_rename_section(char *package, char *section, char *value) +int dmuci_rename_section(const char *package, const char *section, const char *value) { struct uci_ptr ptr = {0}; @@ -551,7 +551,7 @@ int dmuci_rename_section(char *package, char *section, char *value) } /**** UCI LOOKUP by section pointer ****/ -static int dmuci_lookup_ptr_by_section(struct uci_context *ctx, struct uci_ptr *ptr, struct uci_section *s, char *option, char *value) +static int dmuci_lookup_ptr_by_section(struct uci_context *ctx, struct uci_ptr *ptr, struct uci_section *s, const char *option, const char *value) { if (s == NULL || s->package == NULL) return -1; @@ -583,7 +583,7 @@ lookup: } /**** UCI GET by section pointer*****/ -int dmuci_get_value_by_section_string(struct uci_section *s, char *option, char **value) +int dmuci_get_value_by_section_string(struct uci_section *s, const char *option, char **value) { struct uci_element *e = NULL; struct uci_option *o; @@ -608,18 +608,18 @@ not_found: return -1; } -char *dmuci_get_value_by_section_fallback_def(struct uci_section *s, char *option, char *default_value) +char *dmuci_get_value_by_section_fallback_def(struct uci_section *s, const char *option, const char *default_value) { char *value = ""; dmuci_get_value_by_section_string(s, option, &value); if (*value == '\0') - value = default_value; + value = dmstrdup(default_value); return value; } -int dmuci_get_value_by_section_list(struct uci_section *s, char *option, struct uci_list **value) +int dmuci_get_value_by_section_list(struct uci_section *s, const char *option, struct uci_list **value) { struct uci_element *e = NULL; struct uci_option *o; @@ -662,7 +662,7 @@ int dmuci_get_value_by_section_list(struct uci_section *s, char *option, struct } /**** UCI SET by section pointer ****/ -int dmuci_set_value_by_section(struct uci_section *s, char *option, char *value) +int dmuci_set_value_by_section(struct uci_section *s, const char *option, const char *value) { struct uci_ptr up = {0}; @@ -676,7 +676,7 @@ int dmuci_set_value_by_section(struct uci_section *s, char *option, char *value) } /**** UCI DELETE by section pointer *****/ -int dmuci_delete_by_section(struct uci_section *s, char *option, char *value) +int dmuci_delete_by_section(struct uci_section *s, const char *option, const char *value) { struct uci_ptr up = {0}; uci_ctx->flags |= UCI_FLAG_EXPORT_NAME; @@ -690,7 +690,7 @@ int dmuci_delete_by_section(struct uci_section *s, char *option, char *value) return 0; } -int dmuci_delete_by_section_unnamed(struct uci_section *s, char *option, char *value) +int dmuci_delete_by_section_unnamed(struct uci_section *s, const char *option, const char *value) { struct uci_ptr up = {0}; @@ -704,7 +704,7 @@ int dmuci_delete_by_section_unnamed(struct uci_section *s, char *option, char *v } /**** UCI ADD LIST by section pointer *****/ -int dmuci_add_list_value_by_section(struct uci_section *s, char *option, char *value) +int dmuci_add_list_value_by_section(struct uci_section *s, const char *option, const char *value) { struct uci_ptr up = {0}; @@ -718,7 +718,7 @@ int dmuci_add_list_value_by_section(struct uci_section *s, char *option, char *v } /**** UCI DEL LIST by section pointer *****/ -int dmuci_del_list_value_by_section(struct uci_section *s, char *option, char *value) +int dmuci_del_list_value_by_section(struct uci_section *s, const char *option, const char *value) { struct uci_ptr up = {0}; @@ -732,7 +732,7 @@ int dmuci_del_list_value_by_section(struct uci_section *s, char *option, char *v } /**** UCI RENAME SECTION by section pointer *****/ -int dmuci_rename_section_by_section(struct uci_section *s, char *value) +int dmuci_rename_section_by_section(struct uci_section *s, const char *value) { struct uci_ptr up = {0}; @@ -760,7 +760,7 @@ int dmuci_reoder_section_by_section(struct uci_section *s, char *pos) } /**** UCI WALK SECTIONS *****/ -struct uci_section *dmuci_walk_section (char *package, char *stype, void *arg1, void *arg2, int cmp , int (*filter)(struct uci_section *s, void *value), struct uci_section *prev_section, int walk) +struct uci_section *dmuci_walk_section (const char *package, const char *stype, const void *arg1, const void *arg2, int cmp , int (*filter)(struct uci_section *s, const void *value), struct uci_section *prev_section, int walk) { struct uci_section *s = NULL; struct uci_element *e, *m = NULL; @@ -786,17 +786,17 @@ struct uci_section *dmuci_walk_section (char *package, char *stype, void *arg1, case CMP_SECTION: goto end; case CMP_OPTION_EQUAL: - dmuci_get_value_by_section_string(s, (char *)arg1, &value); + dmuci_get_value_by_section_string(s, (const char *)arg1, &value); if (DM_STRCMP(value, (char *)arg2) == 0) goto end; break; case CMP_OPTION_CONTAINING: - dmuci_get_value_by_section_string(s, (char *)arg1, &value); + dmuci_get_value_by_section_string(s, (const char *)arg1, &value); if (DM_STRSTR(value, (char *)arg2)) goto end; break; case CMP_OPTION_CONT_WORD: - dmuci_get_value_by_section_string(s, (char *)arg1, &value); + dmuci_get_value_by_section_string(s, (const char *)arg1, &value); dup = dmstrdup(value); pch = strtok_r(dup, " ", &spch); while (pch != NULL) { @@ -809,7 +809,7 @@ struct uci_section *dmuci_walk_section (char *package, char *stype, void *arg1, dmfree(dup); break; case CMP_LIST_CONTAINING: - dmuci_get_value_by_section_list(s, (char *)arg1, &list_value); + dmuci_get_value_by_section_list(s, (const char *)arg1, &list_value); if (list_value != NULL) { uci_foreach_element(list_value, m) { if (DM_STRCMP(m->name, (char *)arg2) == 0) @@ -832,7 +832,7 @@ end: return s; } -struct uci_section *dmuci_walk_all_sections(char *package, struct uci_section *prev_section, int walk) +struct uci_section *dmuci_walk_all_sections(const char *package, struct uci_section *prev_section, int walk) { struct uci_element *e = NULL; struct uci_list *list_section; @@ -853,7 +853,7 @@ struct uci_section *dmuci_walk_all_sections(char *package, struct uci_section *p } /**** UCI GET db config *****/ -int db_get_value_string(char *package, char *section, char *option, char **value) +int db_get_value_string(const char *package, const char *section, const char *option, char **value) { struct uci_option *o; @@ -871,12 +871,13 @@ void commit_and_free_uci_ctx_bbfdm(char *dmmap_config) { dmuci_commit_package_bbfdm(dmmap_config); - if (uci_ctx_bbfdm) + if (uci_ctx_bbfdm) { uci_free_context(uci_ctx_bbfdm); - uci_ctx_bbfdm = NULL; + uci_ctx_bbfdm = NULL; + } } -bool dmuci_string_to_boolean(char *value) +bool dmuci_string_to_boolean(const char *value) { if (!value) return false; @@ -891,7 +892,7 @@ bool dmuci_string_to_boolean(char *value) return false; } -bool dmuci_is_option_value_empty(struct uci_section *s, char *option_name) +bool dmuci_is_option_value_empty(struct uci_section *s, const char *option_name) { char *option_value = NULL; @@ -903,7 +904,7 @@ bool dmuci_is_option_value_empty(struct uci_section *s, char *option_name) return (DM_STRLEN(option_value) == 0) ? true : false; } -int dmuci_get_section_name(char *sec_name, char **value) +int dmuci_get_section_name(const char *sec_name, char **value) { if (!sec_name) return -1; @@ -924,7 +925,7 @@ int dmuci_get_section_name(char *sec_name, char **value) return 0; } -int dmuci_set_section_name(char *sec_name, char *str, size_t size) +int dmuci_set_section_name(const char *sec_name, char *str, size_t size) { if (!sec_name || !str || size == 0) return -1; diff --git a/libbbfdm-api/dmuci.h b/libbbfdm-api/dmuci.h index db820b1a..6f95085d 100644 --- a/libbbfdm-api/dmuci.h +++ b/libbbfdm-api/dmuci.h @@ -147,7 +147,7 @@ static inline void uci_list_init(struct uci_list *ptr) #define NEW_UCI_PATH(UCI_PATH) \ struct uci_context *uci_ctx_##UCI_PATH = NULL; \ -int dmuci_get_section_type_##UCI_PATH(char *package, char *section,char **value) \ +int dmuci_get_section_type_##UCI_PATH(const char *package, const char *section,char **value) \ {\ struct uci_context *save_uci_ctx; \ save_uci_ctx = uci_ctx; \ @@ -156,7 +156,7 @@ int dmuci_get_section_type_##UCI_PATH(char *package, char *section,char **value) uci_ctx = save_uci_ctx; \ return res; \ }\ -int dmuci_get_option_value_string_##UCI_PATH(char *package, char *section, char *option, char **value) \ +int dmuci_get_option_value_string_##UCI_PATH(const char *package, const char *section, const char *option, char **value) \ {\ struct uci_context *save_uci_ctx; \ save_uci_ctx = uci_ctx; \ @@ -165,7 +165,7 @@ int dmuci_get_option_value_string_##UCI_PATH(char *package, char *section, char uci_ctx = save_uci_ctx; \ return res; \ }\ -int dmuci_get_option_value_list_##UCI_PATH(char *package, char *section, char *option, struct uci_list **value) \ +int dmuci_get_option_value_list_##UCI_PATH(const char *package, const char *section, const char *option, struct uci_list **value) \ {\ struct uci_context *save_uci_ctx; \ save_uci_ctx = uci_ctx; \ @@ -174,7 +174,7 @@ int dmuci_get_option_value_list_##UCI_PATH(char *package, char *section, char *o uci_ctx = save_uci_ctx; \ return res; \ }\ -int dmuci_set_value_##UCI_PATH(char *package, char *section, char *option, char *value) \ +int dmuci_set_value_##UCI_PATH(const char *package, const char *section, const char *option, const char *value) \ {\ struct uci_context *save_uci_ctx; \ save_uci_ctx = uci_ctx; \ @@ -183,7 +183,7 @@ int dmuci_set_value_##UCI_PATH(char *package, char *section, char *option, char uci_ctx = save_uci_ctx; \ return res; \ }\ -int dmuci_add_list_value_##UCI_PATH(char *package, char *section, char *option, char *value) \ +int dmuci_add_list_value_##UCI_PATH(const char *package, const char *section, const char *option, const char *value) \ {\ struct uci_context *save_uci_ctx; \ save_uci_ctx = uci_ctx; \ @@ -192,7 +192,7 @@ int dmuci_add_list_value_##UCI_PATH(char *package, char *section, char *option, uci_ctx = save_uci_ctx; \ return res; \ }\ -int dmuci_del_list_value_##UCI_PATH(char *package, char *section, char *option, char *value) \ +int dmuci_del_list_value_##UCI_PATH(const char *package, const char *section, const char *option, const char *value) \ {\ struct uci_context *save_uci_ctx; \ save_uci_ctx = uci_ctx; \ @@ -201,7 +201,7 @@ int dmuci_del_list_value_##UCI_PATH(char *package, char *section, char *option, uci_ctx = save_uci_ctx; \ return res; \ }\ -int dmuci_add_section_##UCI_PATH(char *package, char *stype, struct uci_section **s)\ +int dmuci_add_section_##UCI_PATH(const char *package, const char *stype, struct uci_section **s)\ {\ struct uci_context *save_uci_ctx; \ save_uci_ctx = uci_ctx; \ @@ -210,7 +210,7 @@ int dmuci_add_section_##UCI_PATH(char *package, char *stype, struct uci_section uci_ctx = save_uci_ctx; \ return res; \ }\ -int dmuci_delete_##UCI_PATH(char *package, char *section, char *option, char *value) \ +int dmuci_delete_##UCI_PATH(const char *package, const char *section, const char *option, const char *value) \ {\ struct uci_context *save_uci_ctx; \ save_uci_ctx = uci_ctx; \ @@ -219,7 +219,7 @@ int dmuci_delete_##UCI_PATH(char *package, char *section, char *option, char *va uci_ctx = save_uci_ctx; \ return res; \ }\ -int dmuci_set_value_by_section_##UCI_PATH(struct uci_section *s, char *option, char *value)\ +int dmuci_set_value_by_section_##UCI_PATH(struct uci_section *s, const char *option, const char *value)\ {\ struct uci_context *save_uci_ctx; \ save_uci_ctx = uci_ctx; \ @@ -228,7 +228,7 @@ int dmuci_set_value_by_section_##UCI_PATH(struct uci_section *s, char *option, c uci_ctx = save_uci_ctx; \ return res; \ }\ -int dmuci_delete_by_section_##UCI_PATH(struct uci_section *s, char *option, char *value)\ +int dmuci_delete_by_section_##UCI_PATH(struct uci_section *s, const char *option, const char *value)\ {\ struct uci_context *save_uci_ctx; \ save_uci_ctx = uci_ctx; \ @@ -237,7 +237,7 @@ int dmuci_delete_by_section_##UCI_PATH(struct uci_section *s, char *option, char uci_ctx = save_uci_ctx; \ return res; \ }\ -struct uci_section *dmuci_walk_section_##UCI_PATH(char *package, char *stype, void *arg1, void *arg2, int cmp , int (*filter)(struct uci_section *s, void *value), struct uci_section *prev_section, int walk)\ +struct uci_section *dmuci_walk_section_##UCI_PATH(const char *package, const char *stype, const void *arg1, const void *arg2, int cmp , int (*filter)(struct uci_section *s, const void *value), struct uci_section *prev_section, int walk)\ {\ struct uci_context *save_uci_ctx; \ save_uci_ctx = uci_ctx; \ @@ -291,7 +291,7 @@ int dmuci_revert_package_##UCI_PATH(char *package) \ uci_ctx = save_uci_ctx; \ return res; \ }\ -int dmuci_delete_by_section_unnamed_##UCI_PATH(struct uci_section *s, char *option, char *value)\ +int dmuci_delete_by_section_unnamed_##UCI_PATH(struct uci_section *s, const char *option, const char *value)\ {\ struct uci_context *save_uci_ctx; \ save_uci_ctx = uci_ctx; \ @@ -305,8 +305,8 @@ void bbfdm_uci_init(struct dmctx *bbf_ctx); void bbfdm_uci_exit(struct dmctx *bbf_ctx); char *dmuci_list_to_string(struct uci_list *list, const char *delimitor); -int dmuci_lookup_ptr(struct uci_context *ctx, struct uci_ptr *ptr, char *package, char *section, char *option, char *value); -int dmuci_import(char *package_name, const char *input_path); +int dmuci_lookup_ptr(struct uci_context *ctx, struct uci_ptr *ptr, const char *package, const char *section, const char *option, const char *value); +int dmuci_import(const char *package_name, const char *input_path); int dmuci_export_package(char *package, const char *output_path); int dmuci_export(const char *output_path); int dmuci_commit_package(char *package); @@ -316,56 +316,56 @@ int dmuci_save(void); int dmuci_revert_package(char *package); int dmuci_revert(void); -int dmuci_get_section_type(char *package, char *section, char **value); -int dmuci_get_option_value_string(char *package, char *section, char *option, char **value); -char *dmuci_get_option_value_fallback_def(char *package, char *section, char *option, char *default_value); -int dmuci_get_option_value_list(char *package, char *section, char *option, struct uci_list **value); -int dmuci_set_value(char *package, char *section, char *option, char *value); -int dmuci_add_list_value(char *package, char *section, char *option, char *value); -int dmuci_del_list_value(char *package, char *section, char *option, char *value); -int dmuci_add_section(char *package, char *stype, struct uci_section **s); -int dmuci_delete(char *package, char *section, char *option, char *value); -int dmuci_rename_section(char *package, char *section, char *value); -int dmuci_get_value_by_section_string(struct uci_section *s, char *option, char **value); -char *dmuci_get_value_by_section_fallback_def(struct uci_section *s, char *option, char *default_value); -int dmuci_get_value_by_section_list(struct uci_section *s, char *option, struct uci_list **value); -int dmuci_set_value_by_section(struct uci_section *s, char *option, char *value); -int dmuci_delete_by_section(struct uci_section *s, char *option, char *value); -int dmuci_delete_by_section_unnamed(struct uci_section *s, char *option, char *value); -int dmuci_add_list_value_by_section(struct uci_section *s, char *option, char *value); -int dmuci_del_list_value_by_section(struct uci_section *s, char *option, char *value); -int dmuci_rename_section_by_section(struct uci_section *s, char *value); +int dmuci_get_section_type(const char *package, const char *section, char **value); +int dmuci_get_option_value_string(const char *package, const char *section, const char *option, char **value); +char *dmuci_get_option_value_fallback_def(const char *package, const char *section, const char *option, const char *default_value); +int dmuci_get_option_value_list(const char *package, const char *section, const char *option, struct uci_list **value); +int dmuci_set_value(const char *package, const char *section, const char *option, const char *value); +int dmuci_add_list_value(const char *package, const char *section, const char *option, const char *value); +int dmuci_del_list_value(const char *package, const char *section, const char *option, const char *value); +int dmuci_add_section(const char *package, const char *stype, struct uci_section **s); +int dmuci_delete(const char *package, const char *section, const char *option, const char *value); +int dmuci_rename_section(const char *package, const char *section, const char *value); +int dmuci_get_value_by_section_string(struct uci_section *s, const char *option, char **value); +char *dmuci_get_value_by_section_fallback_def(struct uci_section *s, const char *option, const char *default_value); +int dmuci_get_value_by_section_list(struct uci_section *s, const char *option, struct uci_list **value); +int dmuci_set_value_by_section(struct uci_section *s, const char *option, const char *value); +int dmuci_delete_by_section(struct uci_section *s, const char *option, const char *value); +int dmuci_delete_by_section_unnamed(struct uci_section *s, const char *option, const char *value); +int dmuci_add_list_value_by_section(struct uci_section *s, const char *option, const char *value); +int dmuci_del_list_value_by_section(struct uci_section *s, const char *option, const char *value); +int dmuci_rename_section_by_section(struct uci_section *s, const char *value); int dmuci_reoder_section_by_section(struct uci_section *s, char *pos); -struct uci_section *dmuci_walk_section(char *package, char *stype, void *arg1, void *arg2, int cmp , int (*filter)(struct uci_section *s, void *value), struct uci_section *prev_section, int walk); -struct uci_section *dmuci_walk_all_sections(char *package, struct uci_section *prev_section, int walk); +struct uci_section *dmuci_walk_section(const char *package, const char *stype, const void *arg1, const void *arg2, int cmp , int (*filter)(struct uci_section *s, const void *value), struct uci_section *prev_section, int walk); +struct uci_section *dmuci_walk_all_sections(const char *package, struct uci_section *prev_section, int walk); -int dmuci_get_option_value_string_bbfdm(char *package, char *section, char *option, char **value); -int dmuci_set_value_bbfdm(char *package, char *section, char *option, char *value); -int dmuci_set_value_by_section_bbfdm(struct uci_section *s, char *option, char *value); -int dmuci_set_value_by_section_varstate(struct uci_section *s, char *option, char *value); -int dmuci_add_section_bbfdm(char *package, char *stype, struct uci_section **s); -int dmuci_delete_bbfdm(char *package, char *section, char *option, char *value); -int dmuci_delete_by_section_unnamed_bbfdm(struct uci_section *s, char *option, char *value); -int dmuci_delete_by_section_bbfdm(struct uci_section *s, char *option, char *value); -int dmuci_delete_by_section_varstate(struct uci_section *s, char *option, char *value); +int dmuci_get_option_value_string_bbfdm(const char *package, const char *section, const char *option, char **value); +int dmuci_set_value_bbfdm(const char *package, const char *section, const char *option, const char *value); +int dmuci_set_value_by_section_bbfdm(struct uci_section *s, const char *option, const char *value); +int dmuci_set_value_by_section_varstate(struct uci_section *s, const char *option, const char *value); +int dmuci_add_section_bbfdm(const char *package, const char *stype, struct uci_section **s); +int dmuci_delete_bbfdm(const char *package, const char *section, const char *option, const char *value); +int dmuci_delete_by_section_unnamed_bbfdm(struct uci_section *s, const char *option, const char *value); +int dmuci_delete_by_section_bbfdm(struct uci_section *s, const char *option, const char *value); +int dmuci_delete_by_section_varstate(struct uci_section *s, const char *option, const char *value); int dmuci_commit_package_bbfdm(char *package); int dmuci_commit_bbfdm(void); int dmuci_revert_bbfdm(void); int dmuci_commit_package_varstate(char *package); int dmuci_save_package_varstate(char *package); int dmuci_revert_package_varstate(char *package); -struct uci_section *dmuci_walk_section_bbfdm(char *package, char *stype, void *arg1, void *arg2, int cmp , int (*filter)(struct uci_section *s, void *value), struct uci_section *prev_section, int walk); -struct uci_section *dmuci_walk_section_varstate(char *package, char *stype, void *arg1, void *arg2, int cmp , int (*filter)(struct uci_section *s, void *value), struct uci_section *prev_section, int walk); +struct uci_section *dmuci_walk_section_bbfdm(const char *package, const char *stype, const void *arg1, const void *arg2, int cmp , int (*filter)(struct uci_section *s, const void *value), struct uci_section *prev_section, int walk); +struct uci_section *dmuci_walk_section_varstate(const char *package, const char *stype, const void *arg1, const void *arg2, int cmp , int (*filter)(struct uci_section *s, const void *value), struct uci_section *prev_section, int walk); void commit_and_free_uci_ctx_bbfdm(char *dmmap_config); -int dmuci_add_section_varstate(char *package, char *stype, struct uci_section **s); -int db_get_value_string(char *package, char *section, char *option, char **value); -int dmuci_get_option_value_string_varstate(char *package, char *section, char *option, char **value); -int dmuci_set_value_varstate(char *package, char *section, char *option, char *value); +int dmuci_add_section_varstate(const char *package, const char *stype, struct uci_section **s); +int db_get_value_string(const char *package, const char *section, const char *option, char **value); +int dmuci_get_option_value_string_varstate(const char *package, const char *section, const char *option, char **value); +int dmuci_set_value_varstate(const char *package, const char *section, const char *option, const char *value); -int dmuci_get_section_name(char *sec_name, char **value); -int dmuci_set_section_name(char *sec_name, char *str, size_t size); -bool dmuci_string_to_boolean(char *value); -bool dmuci_is_option_value_empty(struct uci_section *s, char *option_name); +int dmuci_get_section_name(const char *sec_name, char **value); +int dmuci_set_section_name(const char *sec_name, char *str, size_t size); +bool dmuci_string_to_boolean(const char *value); +bool dmuci_is_option_value_empty(struct uci_section *s, const char *option_name); #endif diff --git a/libbbfdm-api/include/libbbfdm_api.h b/libbbfdm-api/include/libbbfdm_api.h index 5bd91154..3a787a3e 100644 --- a/libbbfdm-api/include/libbbfdm_api.h +++ b/libbbfdm-api/include/libbbfdm_api.h @@ -318,7 +318,7 @@ int bbf_uci_get_section_name(char *sec_name, char **value); int bbf_uci_set_section_name(char *sec_name, char *str, size_t size); -struct uci_section *bbf_uci_walk_section(char *package, char *type, void *arg1, void *arg2, int cmp, int (*filter)(struct uci_section *s, void *value), struct uci_section *prev_section, int walk); +struct uci_section *bbf_uci_walk_section(char *package, char *type, void *arg1, void *arg2, int cmp, int (*filter)(struct uci_section *s, const void *value), struct uci_section *prev_section, int walk); /******************* @@ -650,7 +650,7 @@ int bbfdm_get_reference_linker(struct dmctx *ctx, char *reference_path, struct d ** ** Note: This API is only allowed to be used during operate command **************************************************************************/ -int bbfdm_operate_reference_linker(struct dmctx *ctx, char *reference_path, char **reference_value); +int bbfdm_operate_reference_linker(struct dmctx *ctx, const char *reference_path, char **reference_value); /*********************************************************************//** ** @@ -667,7 +667,7 @@ int bbfdm_operate_reference_linker(struct dmctx *ctx, char *reference_path, char ** \return 0 if the string value is valid, -1 otherwise ** **************************************************************************/ -int bbfdm_validate_string(struct dmctx *ctx, char *value, int min_length, int max_length, char *enumeration[], char *pattern[]); +int bbfdm_validate_string(struct dmctx *ctx, const char *value, int min_length, int max_length, char *enumeration[], char *pattern[]); /*********************************************************************//** ** @@ -681,7 +681,7 @@ int bbfdm_validate_string(struct dmctx *ctx, char *value, int min_length, int ma ** \return 0 if the bool value is valid, -1 otherwise ** **************************************************************************/ -int bbfdm_validate_boolean(struct dmctx *ctx, char *value); +int bbfdm_validate_boolean(struct dmctx *ctx, const char *value); /*********************************************************************//** ** @@ -696,7 +696,7 @@ int bbfdm_validate_boolean(struct dmctx *ctx, char *value); ** \return 0 if the unsigned int value is valid, -1 otherwise ** **************************************************************************/ -int bbfdm_validate_unsignedInt(struct dmctx *ctx, char *value, struct range_args r_args[], int r_args_size); +int bbfdm_validate_unsignedInt(struct dmctx *ctx, const char *value, struct range_args r_args[], int r_args_size); /*********************************************************************//** ** @@ -711,7 +711,7 @@ int bbfdm_validate_unsignedInt(struct dmctx *ctx, char *value, struct range_args ** \return 0 if the int value is valid, -1 otherwise ** **************************************************************************/ -int bbfdm_validate_int(struct dmctx *ctx, char *value, struct range_args r_args[], int r_args_size); +int bbfdm_validate_int(struct dmctx *ctx, const char *value, struct range_args r_args[], int r_args_size); /*********************************************************************//** ** @@ -726,7 +726,7 @@ int bbfdm_validate_int(struct dmctx *ctx, char *value, struct range_args r_args[ ** \return 0 if the unsigned long value is valid, -1 otherwise ** **************************************************************************/ -int bbfdm_validate_unsignedLong(struct dmctx *ctx, char *value, struct range_args r_args[], int r_args_size); +int bbfdm_validate_unsignedLong(struct dmctx *ctx, const char *value, struct range_args r_args[], int r_args_size); /*********************************************************************//** ** @@ -741,7 +741,7 @@ int bbfdm_validate_unsignedLong(struct dmctx *ctx, char *value, struct range_arg ** \return 0 if the long value is valid, -1 otherwise ** **************************************************************************/ -int bbfdm_validate_long(struct dmctx *ctx, char *value, struct range_args r_args[], int r_args_size); +int bbfdm_validate_long(struct dmctx *ctx, const char *value, struct range_args r_args[], int r_args_size); /*********************************************************************//** ** @@ -754,7 +754,7 @@ int bbfdm_validate_long(struct dmctx *ctx, char *value, struct range_args r_args ** \return 0 if the date time value is valid, -1 otherwise ** **************************************************************************/ -int bbfdm_validate_dateTime(struct dmctx *ctx, char *value); +int bbfdm_validate_dateTime(struct dmctx *ctx, const char *value); /*********************************************************************//** ** @@ -769,7 +769,7 @@ int bbfdm_validate_dateTime(struct dmctx *ctx, char *value); ** \return 0 if the hexbinary value is valid, -1 otherwise ** **************************************************************************/ -int bbfdm_validate_hexBinary(struct dmctx *ctx, char *value, struct range_args r_args[], int r_args_size); +int bbfdm_validate_hexBinary(struct dmctx *ctx, const char *value, struct range_args r_args[], int r_args_size); /*********************************************************************//** ** @@ -789,7 +789,7 @@ int bbfdm_validate_hexBinary(struct dmctx *ctx, char *value, struct range_args r ** \return 0 if the list of string value is valid, -1 otherwise ** **************************************************************************/ -int bbfdm_validate_string_list(struct dmctx *ctx, char *value, int min_item, int max_item, int max_size, int min, int max, char *enumeration[], char *pattern[]); +int bbfdm_validate_string_list(struct dmctx *ctx, const char *value, int min_item, int max_item, int max_size, int min, int max, char *enumeration[], char *pattern[]); /*********************************************************************//** ** @@ -807,7 +807,7 @@ int bbfdm_validate_string_list(struct dmctx *ctx, char *value, int min_item, int ** \return 0 if the list of unsigned int value is valid, -1 otherwise ** **************************************************************************/ -int bbfdm_validate_unsignedInt_list(struct dmctx *ctx, char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size); +int bbfdm_validate_unsignedInt_list(struct dmctx *ctx, const char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size); /*********************************************************************//** ** @@ -825,7 +825,7 @@ int bbfdm_validate_unsignedInt_list(struct dmctx *ctx, char *value, int min_item ** \return 0 if the list of int value is valid, -1 otherwise ** **************************************************************************/ -int bbfdm_validate_int_list(struct dmctx *ctx, char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size); +int bbfdm_validate_int_list(struct dmctx *ctx, const char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size); /*********************************************************************//** ** @@ -843,7 +843,7 @@ int bbfdm_validate_int_list(struct dmctx *ctx, char *value, int min_item, int ma ** \return 0 if the list of unsigned long value is valid, -1 otherwise ** **************************************************************************/ -int bbfdm_validate_unsignedLong_list(struct dmctx *ctx, char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size); +int bbfdm_validate_unsignedLong_list(struct dmctx *ctx, const char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size); /*********************************************************************//** ** @@ -861,7 +861,7 @@ int bbfdm_validate_unsignedLong_list(struct dmctx *ctx, char *value, int min_ite ** \return 0 if the list of long value is valid, -1 otherwise ** **************************************************************************/ -int bbfdm_validate_long_list(struct dmctx *ctx, char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size); +int bbfdm_validate_long_list(struct dmctx *ctx, const char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size); /*********************************************************************//** ** @@ -879,7 +879,7 @@ int bbfdm_validate_long_list(struct dmctx *ctx, char *value, int min_item, int m ** \return 0 if the list of hexBinary value is valid, -1 otherwise ** **************************************************************************/ -int bbfdm_validate_hexBinary_list(struct dmctx *ctx, char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size); +int bbfdm_validate_hexBinary_list(struct dmctx *ctx, const char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size); /*********************************************************************//** **