websrv useless if(), then string copy
This commit is contained in:
committed by
Robert Schmidt
parent
990414572a
commit
f9835e996a
@@ -621,26 +621,21 @@ int websrv_callback_get_softmodemcmd(const struct _u_request *request, struct _u
|
|||||||
snprintf(confstr, sizeof(confstr), "Confirm %s ?", modulestruct->cmd[j].cmdname);
|
snprintf(confstr, sizeof(confstr), "Confirm %s ?", modulestruct->cmd[j].cmdname);
|
||||||
acmd = json_pack("{s:s,s:s}", "name", modulestruct->cmd[j].cmdname, "confirm", confstr);
|
acmd = json_pack("{s:s,s:s}", "name", modulestruct->cmd[j].cmdname, "confirm", confstr);
|
||||||
} else if (modulestruct->cmd[j].cmdflags & TELNETSRV_CMDFLAG_NEEDPARAM) {
|
} else if (modulestruct->cmd[j].cmdflags & TELNETSRV_CMDFLAG_NEEDPARAM) {
|
||||||
char *question[] = {NULL,NULL};
|
char *question[] = {NULL, NULL};
|
||||||
char *helpcp = NULL;
|
|
||||||
json_t *jQ1=NULL, *jQ2=NULL;
|
json_t *jQ1=NULL, *jQ2=NULL;
|
||||||
json_t *jQs = json_array();
|
json_t *jQs = json_array();
|
||||||
if (modulestruct->cmd[j].helpstr != NULL) {
|
int ns = sscanf(modulestruct->cmd[j].helpstr, "<%m[^<>]> <%m[^<>]>", &question[0], &question[1]);
|
||||||
helpcp = strdup(modulestruct->cmd[j].helpstr);
|
if (ns == 0) {
|
||||||
int ns=sscanf(helpcp,"<%m[^<>]> <%m[^<>]>",&question[0],&question[1]);
|
LOG_W(UTIL, "[websrv] Cannot find parameters for command %s %s\n", modulestruct->module, modulestruct->cmd[j].cmdname);
|
||||||
if (ns == 0) {
|
continue;
|
||||||
LOG_W(UTIL, "[websrv] Cannot find parameters for command %s %s\n", modulestruct->module, modulestruct->cmd[j].cmdname);
|
}
|
||||||
continue;
|
jQ1 = json_pack("{s:s,s:s,s:s}", "display", question[0], "pname", "P0", "type", "string");
|
||||||
}
|
json_array_append_new(jQs, jQ1);
|
||||||
jQ1=json_pack("{s:s,s:s,s:s}", "display",question[0], "pname", "P0", "type", "string");
|
if (ns > 1) {
|
||||||
json_array_append_new(jQs, jQ1);
|
jQ2 = json_pack("{s:s,s:s,s:s}", "display", (question[1] == NULL) ? "" : question[1], "pname", "P1", "type", "string");
|
||||||
if (ns >1) {
|
json_array_append_new(jQs, jQ2);
|
||||||
jQ2=json_pack("{s:s,s:s,s:s}","display", (question[1] == NULL) ? "" : question[1], "pname", "P1" , "type", "string");
|
|
||||||
json_array_append_new(jQs, jQ2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
acmd = json_pack("{s:s,s:o}", "name", modulestruct->cmd[j].cmdname, "question", jQs);
|
acmd = json_pack("{s:s,s:o}", "name", modulestruct->cmd[j].cmdname, "question", jQs);
|
||||||
free(helpcp);
|
|
||||||
free(question[0]);
|
free(question[0]);
|
||||||
free(question[1]);
|
free(question[1]);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user