xml.c 2.2 KB

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