Commit 671bf120 authored by Omar Kallel's avatar Omar Kallel
Browse files

revert the use of set_download_attributes

parent 860e6c60
Pipeline #14142 passed with stage
in 9 seconds
......@@ -3859,42 +3859,10 @@ error:
return -1;
}
int set_download_attributes(mxml_node_t *b, char **command_key, char **file_type, char **file_type_var, char **url, char **username, char **password, int *file_size)
{
char *tmp = NULL;
if (b && b->type == MXML_OPAQUE && b->value.opaque && b->parent->type == MXML_ELEMENT && !strcmp(b->parent->value.element.name, "CommandKey")) {
*command_key = strdup(b->value.opaque);
}
if (b && b->type == MXML_OPAQUE && b->value.opaque && b->parent->type == MXML_ELEMENT && !strcmp(b->parent->value.element.name, "FileType")) {
if (*file_type == NULL) {
*file_type = strdup(b->value.opaque);
*file_type_var = strdup(b->value.opaque);
} else {
tmp = *file_type_var;
if (cwmp_asprintf(file_type_var, "%s %s", tmp, b->value.opaque) == -1)
return FAULT_CPE_INTERNAL_ERROR;
FREE(tmp);
}
}
if (b && b->type == MXML_OPAQUE && b->value.opaque && b->parent->type == MXML_ELEMENT && !strcmp(b->parent->value.element.name, "URL")) {
*url = strdup(b->value.opaque);
}
if (b && b->type == MXML_OPAQUE && b->value.opaque && b->parent->type == MXML_ELEMENT && !strcmp(b->parent->value.element.name, "Username")) {
*username = strdup(b->value.opaque);
}
if (b && b->type == MXML_OPAQUE && b->value.opaque && b->parent->type == MXML_ELEMENT && !strcmp(b->parent->value.element.name, "Password")) {
*password = strdup(b->value.opaque);
}
if (b && b->type == MXML_OPAQUE && b->value.opaque && b->parent->type == MXML_ELEMENT && !strcmp(b->parent->value.element.name, "FileSize")) {
*file_size = atoi(b->value.opaque);
}
return FAULT_CPE_NO_FAULT;
}
int cwmp_handle_rpc_cpe_download(struct session *session, struct rpc *rpc)
{
mxml_node_t *n, *t, *b = session->body_in;
char *c, *file_type = NULL;
char *c, *tmp, *file_type = NULL;
int error = FAULT_CPE_NO_FAULT;
struct download *download = NULL, *idownload;
struct list_head *ilist;
......@@ -3920,10 +3888,34 @@ int cwmp_handle_rpc_cpe_download(struct session *session, struct rpc *rpc)
}
while (b != NULL) {
error = set_download_attributes(b, &(download->command_key), &(download->file_type), &file_type, &(download->url), &(download->username), &(download->password), &(download->file_size));
if (error != FAULT_CPE_NO_FAULT)
goto fault;
if (b && b->type == MXML_OPAQUE && b->value.opaque && b->parent->type == MXML_ELEMENT && !strcmp(b->parent->value.element.name, "CommandKey")) {
download->command_key = strdup(b->value.opaque);
}
if (b && b->type == MXML_OPAQUE && b->value.opaque && b->parent->type == MXML_ELEMENT && !strcmp(b->parent->value.element.name, "FileType")) {
if (download->file_type == NULL) {
download->file_type = strdup(b->value.opaque);
file_type = strdup(b->value.opaque);
} else {
tmp = file_type;
if (cwmp_asprintf(&file_type, "%s %s", tmp, b->value.opaque) == -1) {
error = FAULT_CPE_INTERNAL_ERROR;
goto fault;
}
FREE(tmp);
}
}
if (b && b->type == MXML_OPAQUE && b->value.opaque && b->parent->type == MXML_ELEMENT && !strcmp(b->parent->value.element.name, "URL")) {
download->url = strdup(b->value.opaque);
}
if (b && b->type == MXML_OPAQUE && b->value.opaque && b->parent->type == MXML_ELEMENT && !strcmp(b->parent->value.element.name, "Username")) {
download->username = strdup(b->value.opaque);
}
if (b && b->type == MXML_OPAQUE && b->value.opaque && b->parent->type == MXML_ELEMENT && !strcmp(b->parent->value.element.name, "Password")) {
download->password = strdup(b->value.opaque);
}
if (b && b->type == MXML_OPAQUE && b->value.opaque && b->parent->type == MXML_ELEMENT && !strcmp(b->parent->value.element.name, "FileSize")) {
download->file_size = atoi(b->value.opaque);
}
if (b && b->type == MXML_OPAQUE && b->value.opaque && b->parent->type == MXML_ELEMENT && !strcmp(b->parent->value.element.name, "DelaySeconds")) {
download_delay = atol(b->value.opaque);
}
......@@ -4050,9 +4042,34 @@ int cwmp_handle_rpc_cpe_schedule_download(struct session *session, struct rpc *r
while (b != NULL) {
t = b;
error = set_download_attributes(b, &(schedule_download->command_key), &(schedule_download->file_type), &file_type, &(schedule_download->url), &(schedule_download->username), &(schedule_download->password), &(schedule_download->file_size));
if (error != FAULT_CPE_NO_FAULT)
goto fault;
if (b && b->type == MXML_OPAQUE && b->value.opaque && b->parent->type == MXML_ELEMENT && !strcmp(b->parent->value.element.name, "CommandKey")) {
schedule_download->command_key = strdup(b->value.opaque);
}
if (b && b->type == MXML_OPAQUE && b->value.opaque && b->parent->type == MXML_ELEMENT && !strcmp(b->parent->value.element.name, "FileType")) {
if (schedule_download->file_type == NULL) {
schedule_download->file_type = strdup(b->value.opaque);
file_type = strdup(b->value.opaque);
} else {
tmp = file_type;
if (cwmp_asprintf(&file_type, "%s %s", tmp, b->value.opaque) == -1) {
error = FAULT_CPE_INTERNAL_ERROR;
goto fault;
}
FREE(tmp);
}
}
if (b && b->type == MXML_OPAQUE && b->value.opaque && b->parent->type == MXML_ELEMENT && !strcmp(b->parent->value.element.name, "URL")) {
schedule_download->url = strdup(b->value.opaque);
}
if (b && b->type == MXML_OPAQUE && b->value.opaque && b->parent->type == MXML_ELEMENT && !strcmp(b->parent->value.element.name, "Username")) {
schedule_download->username = strdup(b->value.opaque);
}
if (b && b->type == MXML_OPAQUE && b->value.opaque && b->parent->type == MXML_ELEMENT && !strcmp(b->parent->value.element.name, "Password")) {
schedule_download->password = strdup(b->value.opaque);
}
if (b && b->type == MXML_OPAQUE && b->value.opaque && b->parent->type == MXML_ELEMENT && !strcmp(b->parent->value.element.name, "FileSize")) {
schedule_download->file_size = atoi(b->value.opaque);
}
if (b && b->type == MXML_ELEMENT && !strcmp(b->parent->value.element.name, "TimeWindowList")) {
if (!t)
......
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