Commit 12099a91 authored by frtabu's avatar frtabu

Table Response implementation in backend

parent 9cca19e2
...@@ -64,7 +64,7 @@ int loader_show_cmd(char *buff, int debug, telnet_printfunc_t prnt) ...@@ -64,7 +64,7 @@ int loader_show_cmd(char *buff, int debug, telnet_printfunc_t prnt)
prnt( " Default shared lib path: \"%s\"\n", loader_data.shlibpath); prnt( " Default shared lib path: \"%s\"\n", loader_data.shlibpath);
prnt( " Max number of shared lib : %i\n", loader_data.maxshlibs); prnt( " Max number of shared lib : %i\n", loader_data.maxshlibs);
} }
else if (strcasestr(buff,"modules") != NULL || buff[0]==0) { else if (strcasestr(buff,"modules") != NULL || buff[0]==0 || strcasestr(buff,"show") != NULL) {
prnt( "%i shared lib have been dynamicaly loaded by the oai loader\n", loader_data.numshlibs); prnt( "%i shared lib have been dynamicaly loaded by the oai loader\n", loader_data.numshlibs);
for (int i=0 ; i<loader_data.numshlibs ; i++) { for (int i=0 ; i<loader_data.numshlibs ; i++) {
prnt( " Module %i: %s\n", i,loader_data.shlibs[i].name); prnt( " Module %i: %s\n", i,loader_data.shlibs[i].name);
......
...@@ -79,6 +79,7 @@ telnetshell_cmddef_t proc_cmdarray[] = { ...@@ -79,6 +79,7 @@ telnetshell_cmddef_t proc_cmdarray[] = {
{"show loglvl","", proccmd_log,{(webfunc_t)proccmd_websrv_getdata}, TELNETSRV_CMDFLAG_WEBSRVONLY|TELNETSRV_CMDFLAG_GETWEBDATA,NULL}, {"show loglvl","", proccmd_log,{(webfunc_t)proccmd_websrv_getdata}, TELNETSRV_CMDFLAG_WEBSRVONLY|TELNETSRV_CMDFLAG_GETWEBDATA,NULL},
{"show logopt","", proccmd_log,{(webfunc_t)proccmd_websrv_getdata}, TELNETSRV_CMDFLAG_WEBSRVONLY|TELNETSRV_CMDFLAG_GETWEBTBLDATA,NULL}, {"show logopt","", proccmd_log,{(webfunc_t)proccmd_websrv_getdata}, TELNETSRV_CMDFLAG_WEBSRVONLY|TELNETSRV_CMDFLAG_GETWEBTBLDATA,NULL},
{"show dbgopt","", proccmd_log,{(webfunc_t)proccmd_websrv_getdata}, TELNETSRV_CMDFLAG_WEBSRVONLY|TELNETSRV_CMDFLAG_GETWEBTBLDATA,NULL}, {"show dbgopt","", proccmd_log,{(webfunc_t)proccmd_websrv_getdata}, TELNETSRV_CMDFLAG_WEBSRVONLY|TELNETSRV_CMDFLAG_GETWEBTBLDATA,NULL},
{"show config","", proccmd_show,{(webfunc_t)proccmd_show}, TELNETSRV_CMDFLAG_WEBSRVONLY,NULL},
{"thread","(enter help for details)", proccmd_thread,{(webfunc_t)proccmd_websrv_getdata},0,NULL}, {"thread","(enter help for details)", proccmd_thread,{(webfunc_t)proccmd_websrv_getdata},0,NULL},
{"exit","", proccmd_exit,{NULL},TELNETSRV_CMDFLAG_CONFEXEC,NULL}, {"exit","", proccmd_exit,{NULL},TELNETSRV_CMDFLAG_CONFEXEC,NULL},
{"","",NULL}, {"","",NULL},
......
...@@ -181,12 +181,13 @@ void websrv_gettbldata_response(struct _u_response * response,webdatadef_t * wda ...@@ -181,12 +181,13 @@ void websrv_gettbldata_response(struct _u_response * response,webdatadef_t * wda
coltype="string"; coltype="string";
else else
coltype="number"; coltype="number";
json_t *acol=json_pack("{name:s,type:s,modifiable:b}",wdata->columns[i].coltitle,coltype, json_t *acol=json_pack("{s:s,s:s,s:b}","name",wdata->columns[i].coltitle,"type",coltype,
( wdata->columns[i].coltype & TELNET_CHECKVAL_RDONLY)?0:1 ); "modifiable",( wdata->columns[i].coltype & TELNET_CHECKVAL_RDONLY)?0:1 );
json_array_append_new(jcols,acol); json_array_append_new(jcols,acol);
} }
for (int i=0; i<wdata->numlines ; i++) { for (int i=0; i<wdata->numlines ; i++) {
json_t *jval; json_t *jval;
json_t *jline=json_array();
for (int j=0; j<wdata->numcols; j++) { for (int j=0; j<wdata->numcols; j++) {
if(wdata->columns[j].coltype & TELNET_CHECKVAL_BOOL) if(wdata->columns[j].coltype & TELNET_CHECKVAL_BOOL)
jval=json_boolean(wdata->lines[i].val[j]); jval=json_boolean(wdata->lines[i].val[j]);
...@@ -196,9 +197,9 @@ void websrv_gettbldata_response(struct _u_response * response,webdatadef_t * wda ...@@ -196,9 +197,9 @@ void websrv_gettbldata_response(struct _u_response * response,webdatadef_t * wda
// jval=json_real((double)(wdata->lines[i].val[j])); // jval=json_real((double)(wdata->lines[i].val[j]));
else else
jval=json_integer((long)(wdata->lines[i].val[j])); jval=json_integer((long)(wdata->lines[i].val[j]));
json_array_append_new(jdata,jval); json_array_append_new(jline,jval);
} }
json_array_append_new(jdata,jline);
} }
json_t *jbody=json_pack("{s:o,s:o}","columns",jcols,"rows",jdata); json_t *jbody=json_pack("{s:o,s:o}","columns",jcols,"rows",jdata);
websrv_jbody(response,jbody); websrv_jbody(response,jbody);
...@@ -448,7 +449,7 @@ int websrv_processwebfunc(struct _u_response * response, cmdparser_t * modulestr ...@@ -448,7 +449,7 @@ int websrv_processwebfunc(struct _u_response * response, cmdparser_t * modulestr
websrv_gettbldata_response(response,&wdata); websrv_gettbldata_response(response,&wdata);
} else { } else {
websrv_printf_start(response,16384); websrv_printf_start(response,16384);
cmd->cmdfunc("",websrvparams.dbglvl,websrv_printf); cmd->cmdfunc(cmd->cmdname,websrvparams.dbglvl,websrv_printf);
websrv_printf_end(200); websrv_printf_end(200);
} }
return 200; return 200;
......
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