debfile.h 2.4 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 <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. debDebFile(FileFd &File);
  44. };
  45. class debDebFile::ControlExtract : public pkgDirStream
  46. {
  47. public:
  48. virtual bool DoItem(Item &Itm,int &Fd);
  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);
  60. virtual bool Process(Item &Itm,const unsigned char *Data,
  61. unsigned long long Size,unsigned long long Pos);
  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. MemControlExtract(std::string Member) : IsControl(false), Control(0), Length(0), Member(Member) {};
  67. ~MemControlExtract() {delete [] Control;};
  68. };
  69. /*}}}*/
  70. #endif