From 08f96759f9b1d5e8b1dd300971d23f833b819e7c Mon Sep 17 00:00:00 2001 From: FreeArtMan Date: Thu, 7 Sep 2017 22:37:43 +0100 Subject: Added stat command --- cmd/cmd_stat.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ cmd/cmd_stat.h | 13 +++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 cmd/cmd_stat.c create mode 100644 cmd/cmd_stat.h (limited to 'cmd') diff --git a/cmd/cmd_stat.c b/cmd/cmd_stat.c new file mode 100644 index 0000000..ce19085 --- /dev/null +++ b/cmd/cmd_stat.c @@ -0,0 +1,55 @@ +#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,"+----------+----------+\n"); + + 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; +} diff --git a/cmd/cmd_stat.h b/cmd/cmd_stat.h new file mode 100644 index 0000000..91d30ff --- /dev/null +++ b/cmd/cmd_stat.h @@ -0,0 +1,13 @@ +#ifndef __CMD_STAT_H +#define __CMD_STAT_H + +#include +#include + +#include "sds.h" +#include "util.h" +#include "debug.h" + +void *cmd_stat(void *data); + +#endif \ No newline at end of file -- cgit v1.2.3