diff options
author | FreeArtMan <dos21h@gmail.com> | 2017-09-07 22:37:43 +0100 |
---|---|---|
committer | FreeArtMan <dos21h@gmail.com> | 2017-09-07 22:37:43 +0100 |
commit | 08f96759f9b1d5e8b1dd300971d23f833b819e7c (patch) | |
tree | aa3a4010910b7a0b70e6f551a82911708c001547 /cmd | |
parent | d8d0925669d1e015f7290caf1a34ad756895b151 (diff) | |
download | agni-08f96759f9b1d5e8b1dd300971d23f833b819e7c.tar.gz agni-08f96759f9b1d5e8b1dd300971d23f833b819e7c.zip |
Added stat command
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/cmd_stat.c | 55 | ||||
-rw-r--r-- | cmd/cmd_stat.h | 13 |
2 files changed, 68 insertions, 0 deletions
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 <stdlib.h> +#include <stdio.h> + +#include "sds.h" +#include "util.h" +#include "debug.h" + +void *cmd_stat(void *data); + +#endif
\ No newline at end of file |