fixed HTB quantum 1514 instead of r2q
[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, \
27 \"proxy\":%Lu, \"up\":%Lu, \"min\":%d, \"max\":%d, \"limit\":%d, \
28 \"pktsup\":%Lu, \"pktsdown\":%Lu, \"realquota\":%Lu, \"credit\":%Lu, \"dailyquota\":%ld }",
29 ip->name, ip->lmsid, ip->addr, ip->traffic, ip->direct, ip->proxy,
30 ip->upload, ip->min, ip->desired, ip->max, ip->pktsup, ip->pktsdown,
31 ip->realquota, ip->credit, (ip->min*ip->keyword->data_limit+(ip->keyword->fixed_limit<<20)));
32 jsoncount++;
33 }
34 }
35 fprintf(f, "}\n");
36 fclose(f);
37 puts("done.");
38 }
39 else
40 {
41 perror(json);
42 }
43 }
This page took 0.375101 seconds and 5 git commands to generate.