xml.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #include "stdinc.h"
  2. #include "dat.h"
  3. #include "fns.h"
  4. #include "httpd.h"
  5. #include "xml.h"
  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->sealed, "sealed");
  18. xmlScore(hout, s->score, "score");
  19. xmlU32int(hout, s->clumps, "clumps");
  20. xmlU32int(hout, s->cclumps, "compressedClumps");
  21. xmlU64int(hout, s->uncsize, "data");
  22. xmlU64int(hout, s->used - s->clumps * ClumpSize, "compressedData");
  23. xmlU64int(hout, s->used + s->clumps * ClumpInfoSize, "storage");
  24. hprint(hout, "/>\n");
  25. }
  26. void xmlIndex(Hio *hout, Index *s, char *tag, int indent){
  27. int i;
  28. xmlIndent(hout, indent);
  29. hprint(hout, "<%s", tag);
  30. xmlAName(hout, s->name, "name");
  31. xmlU32int(hout, s->version, "version");
  32. xmlU32int(hout, s->blockSize, "blockSize");
  33. xmlU32int(hout, s->tabSize, "tabSize");
  34. xmlU32int(hout, s->buckets, "buckets");
  35. xmlU32int(hout, s->div, "buckDiv");
  36. hprint(hout, ">\n");
  37. xmlIndent(hout, indent + 1);
  38. hprint(hout, "<sects>\n");
  39. for(i = 0; i < s->nsects; i++)
  40. xmlAmap(hout, &s->smap[i], "sect", indent + 2);
  41. xmlIndent(hout, indent + 1);
  42. hprint(hout, "</sects>\n");
  43. xmlIndent(hout, indent + 1);
  44. hprint(hout, "<amaps>\n");
  45. for(i = 0; i < s->narenas; i++)
  46. xmlAmap(hout, &s->amap[i], "amap", indent + 2);
  47. xmlIndent(hout, indent + 1);
  48. hprint(hout, "</amaps>\n");
  49. xmlIndent(hout, indent + 1);
  50. hprint(hout, "<arenas>\n");
  51. for(i = 0; i < s->narenas; i++)
  52. xmlArena(hout, s->arenas[i], "arena", indent + 2);
  53. xmlIndent(hout, indent + 1);
  54. hprint(hout, "</arenas>\n");
  55. xmlIndent(hout, indent);
  56. hprint(hout, "</%s>\n", tag);
  57. }
  58. void xmlAmap(Hio *hout, AMap *s, char *tag, int indent){
  59. xmlIndent(hout, indent);
  60. hprint(hout, "<%s", tag);
  61. xmlAName(hout, s->name, "name");
  62. xmlU64int(hout, s->start, "start");
  63. xmlU64int(hout, s->stop, "stop");
  64. hprint(hout, "/>\n");
  65. }