summaryrefslogtreecommitdiff
path: root/cmd/cmd_stat.c
blob: 73b7fa6f2ee9101f8bd245f4135bb854c33c8eb8 (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
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,"+----------+----------+");

	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;
}