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