aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/venti/xml.c
blob: d50d5bc99555069eda8586d02544612bf65d627b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "stdinc.h"
#include "dat.h"
#include "fns.h"
#include "httpd.h"
#include "xml.h"

void xmlarena(Hio *hout, Arena *s, char *tag, int indent){
	xmlindent(hout, indent);
	hprint(hout, "<%s", tag);
	xmlaname(hout, s->name, "name");
	xmlu32int(hout, s->version, "version");
	xmlaname(hout, s->part->name, "partition");
	xmlu32int(hout, s->blocksize, "blocksize");
	xmlu64int(hout, s->base, "start");
	xmlu64int(hout, s->base+2*s->blocksize, "stop");
	xmlu32int(hout, s->ctime, "created");
	xmlu32int(hout, s->wtime, "modified");
	xmlsealed(hout, s->sealed, "sealed");
	xmlscore(hout, s->score, "score");
	xmlu32int(hout, s->clumps, "clumps");
	xmlu32int(hout, s->cclumps, "compressedclumps");
	xmlu64int(hout, s->uncsize, "data");
	xmlu64int(hout, s->used - s->clumps * ClumpSize, "compresseddata");
	xmlu64int(hout, s->used + s->clumps * ClumpInfoSize, "storage");
	hprint(hout, "/>\n");
}

void xmlindex(Hio *hout, Index *s, char *tag, int indent){
	int i;
	xmlindent(hout, indent);
	hprint(hout, "<%s", tag);
	xmlaname(hout, s->name, "name");
	xmlu32int(hout, s->version, "version");
	xmlu32int(hout, s->blocksize, "blocksize");
	xmlu32int(hout, s->tabsize, "tabsize");
	xmlu32int(hout, s->buckets, "buckets");
	xmlu32int(hout, s->div, "buckdiv");
	hprint(hout, ">\n");
	xmlindent(hout, indent + 1);
	hprint(hout, "<sects>\n");
	for(i = 0; i < s->nsects; i++)
		xmlamap(hout, &s->smap[i], "sect", indent + 2);
	xmlindent(hout, indent + 1);
	hprint(hout, "</sects>\n");
	xmlindent(hout, indent + 1);
	hprint(hout, "<amaps>\n");
	for(i = 0; i < s->narenas; i++)
		xmlamap(hout, &s->amap[i], "amap", indent + 2);
	xmlindent(hout, indent + 1);
	hprint(hout, "</amaps>\n");
	xmlindent(hout, indent + 1);
	hprint(hout, "<arenas>\n");
	for(i = 0; i < s->narenas; i++)
		xmlarena(hout, s->arenas[i], "arena", indent + 2);
	xmlindent(hout, indent + 1);
	hprint(hout, "</arenas>\n");
	xmlindent(hout, indent);
	hprint(hout, "</%s>\n", tag);
}

void xmlamap(Hio *hout, AMap *s, char *tag, int indent){
	xmlindent(hout, indent);
	hprint(hout, "<%s", tag);
	xmlaname(hout, s->name, "name");
	xmlu64int(hout, s->start, "start");
	xmlu64int(hout, s->stop, "stop");
	hprint(hout, "/>\n");
}