#include "cmd_stat.h" void *cmd_stat(void *data) { char *param = (char *)data; char *ret = NULL; int i; int count; sds params; sds out_result; sds *tokens; const int buf_size = 128; char buf[buf_size+1]; printf("STAT\n"); params = sdsnew(param); out_result = sdsempty(); tokens = sdssplitargs(params, &count); out_result = sdscat(out_result,"+----------+----------+\n"); out_result = sdscat(out_result,"| STAT | VAL |\n"); out_result = sdscat(out_result,"+----------+----------+\n"); //cmd_success snprintf(buf,buf_size,"| CMD_SUCC | %08s |\n", tokens[0]); out_result = sdscat(out_result, buf); //cmd_err snprintf(buf,buf_size,"| CMD_ERR | %08s |\n", tokens[1]); out_result = sdscat(out_result, buf); //ipc tx snprintf(buf,buf_size,"| IPC_TX | %08s |\n", tokens[2]); out_result = sdscat(out_result, buf); //ipc rx snprintf(buf,buf_size,"| IPC_RX | %08s |\n", tokens[3]); out_result = sdscat(out_result, buf); out_result = sdscat(out_result,"+----------+----------+"); sdsfreesplitres(tokens, count); //snprintf(buf, buf_size, "%s\n", param); ret = alloc_new_str(out_result); printf("%s",ret); sdsfree(out_result); sdsfree(params); return ret; }