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