json.c
[svn/Prometheus-QoS/.git] / json.c
CommitLineData
05a90809 1/* Modified by: xChaos, 20121011 */\r
2\r
3#include "cll1-0.6.2.h"\r
4#include "ipstruct.h"\r
5\r
6extern struct IP *ips, *ip;\r
7\r
8void write_json_traffic(char *json)\r
9{\r
10 FILE *f=fopen(json, "w");\r
11 if(f > 0)\r
12 {\r
13 int jsoncount=0;\r
14 fprintf(f, "{\n");\r
15 for_each(ip, ips)\r
16 {\r
17 if( ip->lmsid > 0 \r
18 and (ip->traffic or ip->direct or ip->proxy or ip->upload))\r
19 {\r
20 if(jsoncount)\r
21 {\r
22 fprintf(f, ",\n");\r
23 }\r
24 fprintf(f, " \"%s\":{ \"lms\": %d, \"ip\":\"%s\", \"total\":%Lu, \"down\":%Lu, \"proxy\":%Lu, \"up\":%Lu, \"min\":%d, \"max\":%d, \"limit\":%d }",\r
25 ip->name, ip->lmsid, ip->addr, ip->traffic, ip->direct, ip->proxy, ip->upload, ip->min, ip->desired, ip->max);\r
26 jsoncount++;\r
27 }\r
28 }\r
29 fprintf(f, "}\n");\r
30 fclose(f);\r
31 puts("done.");\r
32 }\r
33 else\r
34 {\r
35 perror(json);\r
36 }\r
37}
This page took 0.124808 seconds and 4 git commands to generate.