debfile.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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/pkgcache.h>
  23. #ifndef APT_8_CLEANER_HEADERS
  24. #include <apt-pkg/md5.h>
  25. #endif
  26. class FileFd;
  27. class debDebFile
  28. {
  29. protected:
  30. FileFd &File;
  31. ARArchive AR;
  32. bool CheckMember(const char *Name);
  33. public:
  34. class ControlExtract;
  35. class MemControlExtract;
  36. bool ExtractArchive(pkgDirStream &Stream);
  37. const ARArchive::Member *GotoMember(const char *Name);
  38. inline FileFd &GetFile() {return File;};
  39. debDebFile(FileFd &File);
  40. };
  41. class debDebFile::ControlExtract : public pkgDirStream
  42. {
  43. public:
  44. virtual bool DoItem(Item &Itm,int &Fd);
  45. };
  46. class debDebFile::MemControlExtract : public pkgDirStream
  47. {
  48. bool IsControl;
  49. public:
  50. char *Control;
  51. pkgTagSection Section;
  52. unsigned long Length;
  53. std::string Member;
  54. // Members from DirStream
  55. virtual bool DoItem(Item &Itm,int &Fd);
  56. virtual bool Process(Item &Itm,const unsigned char *Data,
  57. unsigned long Size,unsigned long Pos);
  58. // Helpers
  59. bool Read(debDebFile &Deb);
  60. bool TakeControl(const void *Data,unsigned long Size);
  61. MemControlExtract() : IsControl(false), Control(0), Length(0), Member("control") {};
  62. MemControlExtract(std::string Member) : IsControl(false), Control(0), Length(0), Member(Member) {};
  63. ~MemControlExtract() {delete [] Control;};
  64. };
  65. /*}}}*/
  66. #endif