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