You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

93 lines
2.1 KiB

  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. /* ######################################################################
  4. contents - Contents of archive things.
  5. ##################################################################### */
  6. /*}}}*/
  7. #ifndef CONTENTS_H
  8. #define CONTENTS_H
  9. #include <apt-pkg/dirstream.h>
  10. #include <string>
  11. #include <stddef.h>
  12. #include <stdio.h>
  13. class debDebFile;
  14. class FileFd;
  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(std::string &out, size_t Current, size_t Target);
  46. void DoPrint(FileFd &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(FileFd &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) APT_OVERRIDE;
  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