Major rewrite of leading comments
[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
0db8e993 15\r
05a90809 16 for_each(ip, ips)\r
17 {\r
18 if( ip->lmsid > 0 \r
19 and (ip->traffic or ip->direct or ip->proxy or ip->upload))\r
20 {\r
21 if(jsoncount)\r
22 {\r
23 fprintf(f, ",\n");\r
24 }\r
0db8e993 25 fprintf(f, \r
26 " \"%s\":{ \"lms\": %d, \"ip\":\"%s\", \"total\":%Lu, \"down\":%Lu, \"proxy\":%Lu, \"up\":%Lu, \\r
27\"min\":%d, \"max\":%d, \"limit\":%d, \"realquota\":%Lu, \"credit\":%Lu, \"dailyquota\":%ld }",\r
28 ip->name, ip->lmsid, ip->addr, ip->traffic, ip->direct, ip->proxy, ip->upload, \r
29 ip->min, ip->desired, ip->max, ip->realquota, ip->credit, \r
30 (ip->min*ip->keyword->data_limit+(ip->keyword->fixed_limit<<20)));\r
05a90809 31 jsoncount++;\r
32 }\r
33 }\r
34 fprintf(f, "}\n");\r
35 fclose(f);\r
36 puts("done.");\r
37 }\r
38 else\r
39 {\r
40 perror(json);\r
41 }\r
42}
This page took 0.157014 seconds and 4 git commands to generate.