debfile.h 2.4 KB

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