Blob


1 #include "stdinc.h"
2 #include "dat.h"
3 #include "fns.h"
4 #include "httpd.h"
5 #include "xml.h"
7 void xmlarena(Hio *hout, Arena *s, char *tag, int indent){
8 xmlindent(hout, indent);
9 hprint(hout, "<%s", tag);
10 xmlaname(hout, s->name, "name");
11 xmlu32int(hout, s->version, "version");
12 xmlaname(hout, s->part->name, "partition");
13 xmlu32int(hout, s->blocksize, "blocksize");
14 xmlu64int(hout, s->base, "start");
15 xmlu64int(hout, s->base+2*s->blocksize, "stop");
16 xmlu32int(hout, s->ctime, "created");
17 xmlu32int(hout, s->wtime, "modified");
18 xmlsealed(hout, s->sealed, "sealed");
19 xmlscore(hout, s->score, "score");
20 xmlu32int(hout, s->clumps, "clumps");
21 xmlu32int(hout, s->cclumps, "compressedclumps");
22 xmlu64int(hout, s->uncsize, "data");
23 xmlu64int(hout, s->used - s->clumps * ClumpSize, "compresseddata");
24 xmlu64int(hout, s->used + s->clumps * ClumpInfoSize, "storage");
25 hprint(hout, "/>\n");
26 }
28 void xmlindex(Hio *hout, Index *s, char *tag, int indent){
29 int i;
30 xmlindent(hout, indent);
31 hprint(hout, "<%s", tag);
32 xmlaname(hout, s->name, "name");
33 xmlu32int(hout, s->version, "version");
34 xmlu32int(hout, s->blocksize, "blocksize");
35 xmlu32int(hout, s->tabsize, "tabsize");
36 xmlu32int(hout, s->buckets, "buckets");
37 xmlu32int(hout, s->div, "buckdiv");
38 hprint(hout, ">\n");
39 xmlindent(hout, indent + 1);
40 hprint(hout, "<sects>\n");
41 for(i = 0; i < s->nsects; i++)
42 xmlamap(hout, &s->smap[i], "sect", indent + 2);
43 xmlindent(hout, indent + 1);
44 hprint(hout, "</sects>\n");
45 xmlindent(hout, indent + 1);
46 hprint(hout, "<amaps>\n");
47 for(i = 0; i < s->narenas; i++)
48 xmlamap(hout, &s->amap[i], "amap", indent + 2);
49 xmlindent(hout, indent + 1);
50 hprint(hout, "</amaps>\n");
51 xmlindent(hout, indent + 1);
52 hprint(hout, "<arenas>\n");
53 for(i = 0; i < s->narenas; i++)
54 xmlarena(hout, s->arenas[i], "arena", indent + 2);
55 xmlindent(hout, indent + 1);
56 hprint(hout, "</arenas>\n");
57 xmlindent(hout, indent);
58 hprint(hout, "</%s>\n", tag);
59 }
61 void xmlamap(Hio *hout, AMap *s, char *tag, int indent){
62 xmlindent(hout, indent);
63 hprint(hout, "<%s", tag);
64 xmlaname(hout, s->name, "name");
65 xmlu64int(hout, s->start, "start");
66 xmlu64int(hout, s->stop, "stop");
67 hprint(hout, "/>\n");
68 }