xml.c 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include "stdinc.h"
  10. #include "dat.h"
  11. #include "fns.h"
  12. #include "xml.h"
  13. void xmlarena(Hio *hout, Arena *s, char *tag, int indent){
  14. xmlindent(hout, indent);
  15. hprint(hout, "<%s", tag);
  16. xmlaname(hout, s->name, "name");
  17. xmlu32int(hout, s->version, "version");
  18. xmlaname(hout, s->part->name, "partition");
  19. xmlu32int(hout, s->blocksize, "blocksize");
  20. xmlu64int(hout, s->base, "start");
  21. xmlu64int(hout, s->base+2*s->blocksize, "stop");
  22. xmlu32int(hout, s->ctime, "created");
  23. xmlu32int(hout, s->wtime, "modified");
  24. xmlsealed(hout, s->memstats.sealed, "sealed");
  25. xmlscore(hout, s->score, "score");
  26. xmlu32int(hout, s->memstats.clumps, "clumps");
  27. xmlu32int(hout, s->memstats.cclumps, "compressedclumps");
  28. xmlu64int(hout, s->memstats.uncsize, "data");
  29. xmlu64int(hout, s->memstats.used - s->memstats.clumps * ClumpSize, "compresseddata");
  30. xmlu64int(hout, s->memstats.used + s->memstats.clumps * ClumpInfoSize, "storage");
  31. hprint(hout, "/>\n");
  32. }
  33. void xmlindex(Hio *hout, Index *s, char *tag, int indent){
  34. int i;
  35. xmlindent(hout, indent);
  36. hprint(hout, "<%s", tag);
  37. xmlaname(hout, s->name, "name");
  38. xmlu32int(hout, s->version, "version");
  39. xmlu32int(hout, s->blocksize, "blocksize");
  40. xmlu32int(hout, s->tabsize, "tabsize");
  41. xmlu32int(hout, s->buckets, "buckets");
  42. xmlu32int(hout, s->div, "buckdiv");
  43. hprint(hout, ">\n");
  44. xmlindent(hout, indent + 1);
  45. hprint(hout, "<sects>\n");
  46. for(i = 0; i < s->nsects; i++)
  47. xmlamap(hout, &s->smap[i], "sect", indent + 2);
  48. xmlindent(hout, indent + 1);
  49. hprint(hout, "</sects>\n");
  50. xmlindent(hout, indent + 1);
  51. hprint(hout, "<amaps>\n");
  52. for(i = 0; i < s->narenas; i++)
  53. xmlamap(hout, &s->amap[i], "amap", indent + 2);
  54. xmlindent(hout, indent + 1);
  55. hprint(hout, "</amaps>\n");
  56. xmlindent(hout, indent + 1);
  57. hprint(hout, "<arenas>\n");
  58. for(i = 0; i < s->narenas; i++)
  59. xmlarena(hout, s->arenas[i], "arena", indent + 2);
  60. xmlindent(hout, indent + 1);
  61. hprint(hout, "</arenas>\n");
  62. xmlindent(hout, indent);
  63. hprint(hout, "</%s>\n", tag);
  64. }
  65. void xmlamap(Hio *hout, AMap *s, char *tag, int indent){
  66. xmlindent(hout, indent);
  67. hprint(hout, "<%s", tag);
  68. xmlaname(hout, s->name, "name");
  69. xmlu64int(hout, s->start, "start");
  70. xmlu64int(hout, s->stop, "stop");
  71. hprint(hout, "/>\n");
  72. }