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.
 
 
 
 
 
 

96 lines
2.4 KiB

  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. /* ######################################################################
  4. Debian Archive File (.deb)
  5. This Class handles all the operations performed directly on .deb
  6. files. It makes use of the AR and TAR classes to give the necessary
  7. external interface.
  8. There are only two things that can be done with a raw package,
  9. extract it's control information and extract the contents itself.
  10. This should probably subclass an as-yet unwritten super class to
  11. produce a generic archive mechanism.
  12. The memory control file extractor is useful to extract a single file
  13. into memory from the control.tar.gz
  14. ##################################################################### */
  15. /*}}}*/
  16. #ifndef PKGLIB_DEBFILE_H
  17. #define PKGLIB_DEBFILE_H
  18. #include <apt-pkg/arfile.h>
  19. #include <apt-pkg/dirstream.h>
  20. #include <apt-pkg/macros.h>
  21. #include <apt-pkg/tagfile.h>
  22. #include <string>
  23. #ifndef APT_8_CLEANER_HEADERS
  24. #include <apt-pkg/md5.h>
  25. #endif
  26. #ifndef APT_10_CLEANER_HEADERS
  27. #include <apt-pkg/pkgcache.h>
  28. #endif
  29. class FileFd;
  30. class debDebFile
  31. {
  32. protected:
  33. FileFd &File;
  34. ARArchive AR;
  35. bool CheckMember(const char *Name);
  36. public:
  37. class ControlExtract;
  38. class MemControlExtract;
  39. bool ExtractTarMember(pkgDirStream &Stream, const char *Name);
  40. bool ExtractArchive(pkgDirStream &Stream);
  41. const ARArchive::Member *GotoMember(const char *Name);
  42. inline FileFd &GetFile() {return File;};
  43. explicit debDebFile(FileFd &File);
  44. };
  45. class debDebFile::ControlExtract : public pkgDirStream
  46. {
  47. public:
  48. virtual bool DoItem(Item &Itm,int &Fd) APT_OVERRIDE;
  49. };
  50. class debDebFile::MemControlExtract : public pkgDirStream
  51. {
  52. bool IsControl;
  53. public:
  54. char *Control;
  55. pkgTagSection Section;
  56. unsigned long Length;
  57. std::string Member;
  58. // Members from DirStream
  59. virtual bool DoItem(Item &Itm,int &Fd) APT_OVERRIDE;
  60. virtual bool Process(Item &Itm,const unsigned char *Data,
  61. unsigned long long Size,unsigned long long Pos) APT_OVERRIDE;
  62. // Helpers
  63. bool Read(debDebFile &Deb);
  64. bool TakeControl(const void *Data,unsigned long long Size);
  65. MemControlExtract() : IsControl(false), Control(0), Length(0), Member("control") {};
  66. explicit MemControlExtract(std::string Member) : IsControl(false), Control(0), Length(0), Member(Member) {};
  67. ~MemControlExtract() {delete [] Control;};
  68. };
  69. /*}}}*/
  70. #endif