aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/cmd_stat.c
blob: dc2a097168f90f7b327ab76b15fa8ada6e17cdf4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "cmd_stat.h"

void *cmd_stat(void *data)
{
	char *param = (char *)data;
	char *ret = NULL;

	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 | %8s |\n", tokens[0]);
	out_result = sdscat(out_result, buf);
	//cmd_err
	snprintf(buf,buf_size,"| CMD_ERR  | %8s |\n", tokens[1]);
	out_result = sdscat(out_result, buf);
	//ipc tx
	snprintf(buf,buf_size,"| IPC_TX   | %8s |\n", tokens[2]);
	out_result = sdscat(out_result, buf);
	//ipc rx
	snprintf(buf,buf_size,"| IPC_RX   | %8s |\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;
}