contents.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: contents.h,v 1.2 2001/02/20 07:03:18 jgg Exp $
  4. /* ######################################################################
  5. contents - Contents of archive things.
  6. ##################################################################### */
  7. /*}}}*/
  8. #ifndef CONTENTS_H
  9. #define CONTENTS_H
  10. #include <apt-pkg/dirstream.h>
  11. #include <stddef.h>
  12. #include <stdio.h>
  13. #include <string>
  14. class debDebFile;
  15. class GenContents
  16. {
  17. struct Node
  18. {
  19. // Binary Tree links
  20. Node *BTreeLeft;
  21. Node *BTreeRight;
  22. Node *DirDown;
  23. Node *Dups;
  24. const char *Path;
  25. const char *Package;
  26. void *operator new(size_t Amount,GenContents *Owner);
  27. void operator delete(void *) {};
  28. Node() : BTreeLeft(0), BTreeRight(0), DirDown(0), Dups(0),
  29. Path(0), Package(0) {};
  30. };
  31. friend struct Node;
  32. struct BigBlock
  33. {
  34. void *Block;
  35. BigBlock *Next;
  36. };
  37. Node Root;
  38. // Big block allocation pools
  39. BigBlock *BlockList;
  40. char *StrPool;
  41. unsigned long StrLeft;
  42. Node *NodePool;
  43. unsigned long NodeLeft;
  44. Node *Grab(Node *Top,const char *Name,const char *Package);
  45. void WriteSpace(FILE *Out,unsigned int Current,unsigned int Target);
  46. void DoPrint(FILE *Out,Node *Top, char *Buf);
  47. public:
  48. char *Mystrdup(const char *From);
  49. void Add(const char *Dir,const char *Package);
  50. void Print(FILE *Out);
  51. GenContents() : BlockList(0), StrPool(0), StrLeft(0),
  52. NodePool(0), NodeLeft(0) {};
  53. ~GenContents();
  54. };
  55. class ContentsExtract : public pkgDirStream
  56. {
  57. public:
  58. // The Data Block
  59. char *Data;
  60. unsigned long long MaxSize;
  61. unsigned long long CurSize;
  62. void AddData(const char *Text);
  63. bool Read(debDebFile &Deb);
  64. virtual bool DoItem(Item &Itm,int &Fd);
  65. void Reset() {CurSize = 0;};
  66. bool TakeContents(const void *Data,unsigned long long Length);
  67. void Add(GenContents &Contents,std::string const &Package);
  68. ContentsExtract();
  69. virtual ~ContentsExtract();
  70. };
  71. #endif