debfile.h 2.5 KB

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