Commit d8129bd2 authored by Omar Kallel's avatar Omar Kallel

Fix cpd warnings

parent 196ae20a
Pipeline #13535 passed with stage
in 8 seconds
This diff is collapsed.
......@@ -199,3 +199,44 @@ bool folder_exists(const char *path)
return (stat(path, &folder_stat) == 0 && S_ISDIR(folder_stat.st_mode));
}
int find_method_attrs_in_array(struct method_attributes_settings method_settings[], char *name, size_t size)
{
int i;
for (i=0; i<(int)size; i++) {
if (strcmp(method_settings[i].attribute_name, name) == 0)
return i;
}
return -1;
}
void load_mxmlnode_in_method_attribtues(mxml_node_t *tree, struct method_attributes_settings method_settings[], size_t size)
{
mxml_node_t *b = tree, *c;
int method_settings_idx = -1;
b = mxmlWalkNext(b, tree, MXML_DESCEND);
while (b) {
if (b && b->type == MXML_ELEMENT) {
method_settings_idx = find_method_attrs_in_array(method_settings, b->value.element.name, size);
if (method_settings_idx == -1)
continue;
c = mxmlWalkNext(b, b, MXML_DESCEND);
if (c && c->type == MXML_OPAQUE) {
if (c->value.opaque != NULL) {
if (method_settings[method_settings_idx].type == PSTRING)
*(method_settings[method_settings_idx].value.sptr) = strdup(c->value.opaque);
if (method_settings[method_settings_idx].type == PINTEGER)
*(method_settings[method_settings_idx].value.iptr) = atoi(c->value.opaque);
if (method_settings[method_settings_idx].type == PLONG)
*(method_settings[method_settings_idx].value.lptr) = atol(c->value.opaque);
if (method_settings[method_settings_idx].type == PBOOLEAN)
*(method_settings[method_settings_idx].value.bptr) = c->value.opaque;
}
}
}
b = mxmlWalkNext(b, tree, MXML_NO_DESCEND);
}
}
......@@ -19,6 +19,7 @@
#include <libubox/list.h>
#include <sys/time.h>
#include <pthread.h>
#include <microxml.h>
#ifndef CWMP_VERSION
#define CWMP_VERSION "3.0.0"
......@@ -437,6 +438,26 @@ typedef struct opfault {
char *fault_string;
} opfault;
enum attribtutes_types {
PSTRING,
PINTEGER,
PLONG,
PBOOLEAN
};
union value_address {
char **sptr;
int *iptr;
long *lptr;
bool *bptr;
};
struct method_attributes_settings {
char *attribute_name;
union value_address value;
enum attribtutes_types type;
};
extern struct cwmp cwmp_main;
int cwmp_exit(void);
void add_dm_parameter_tolist(struct list_head *head, char *param_name, char *param_data, char *param_type);
......@@ -450,6 +471,7 @@ void cwmp_del_list_param_value(struct cwmp_param_value *param_value);
void cwmp_free_all_list_param_value(struct list_head *list_param_value);
int cwmp_asprintf(char **s, const char *format, ...);
bool folder_exists(const char *path);
void load_mxmlnode_in_method_attribtues(mxml_node_t *tree, struct method_attributes_settings method_settings[], size_t size);
#ifndef FREE
#define FREE(x) \
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment