deblistparser.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: deblistparser.h,v 1.9 2001/02/20 07:03:17 jgg Exp $
  4. /* ######################################################################
  5. Debian Package List Parser - This implements the abstract parser
  6. interface for Debian package files
  7. ##################################################################### */
  8. /*}}}*/
  9. #ifndef PKGLIB_DEBLISTPARSER_H
  10. #define PKGLIB_DEBLISTPARSER_H
  11. #include <apt-pkg/pkgcachegen.h>
  12. #include <apt-pkg/tagfile.h>
  13. #include <apt-pkg/md5.h>
  14. #include <apt-pkg/pkgcache.h>
  15. #include <string>
  16. #include <vector>
  17. #ifndef APT_8_CLEANER_HEADERS
  18. #include <apt-pkg/indexfile.h>
  19. #endif
  20. class FileFd;
  21. class debListParser : public pkgCacheGenerator::ListParser
  22. {
  23. public:
  24. // Parser Helper
  25. struct WordList
  26. {
  27. const char *Str;
  28. unsigned char Val;
  29. };
  30. private:
  31. /** \brief dpointer placeholder (for later in case we need it) */
  32. void *d;
  33. protected:
  34. pkgTagFile Tags;
  35. pkgTagSection Section;
  36. unsigned long iOffset;
  37. std::string Arch;
  38. std::vector<std::string> Architectures;
  39. bool MultiArchEnabled;
  40. unsigned long UniqFindTagWrite(const char *Tag);
  41. virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver);
  42. bool ParseDepends(pkgCache::VerIterator &Ver,const char *Tag,
  43. unsigned int Type);
  44. bool ParseProvides(pkgCache::VerIterator &Ver);
  45. bool NewProvidesAllArch(pkgCache::VerIterator &Ver, std::string const &Package, std::string const &Version);
  46. static bool GrabWord(std::string Word,WordList *List,unsigned char &Out);
  47. public:
  48. static unsigned char GetPrio(std::string Str);
  49. // These all operate against the current section
  50. virtual std::string Package();
  51. virtual std::string Architecture();
  52. virtual bool ArchitectureAll();
  53. virtual std::string Version();
  54. virtual bool NewVersion(pkgCache::VerIterator &Ver);
  55. virtual std::string Description();
  56. virtual std::string DescriptionLanguage();
  57. virtual MD5SumValue Description_md5();
  58. virtual unsigned short VersionHash();
  59. #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
  60. virtual bool SameVersion(unsigned short const Hash, pkgCache::VerIterator const &Ver);
  61. #endif
  62. virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
  63. pkgCache::VerIterator &Ver);
  64. virtual unsigned long Offset() {return iOffset;};
  65. virtual unsigned long Size() {return Section.size();};
  66. virtual bool Step();
  67. bool LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,FileFd &File,
  68. std::string section);
  69. static const char *ParseDepends(const char *Start,const char *Stop,
  70. std::string &Package,std::string &Ver,unsigned int &Op);
  71. static const char *ParseDepends(const char *Start,const char *Stop,
  72. std::string &Package,std::string &Ver,unsigned int &Op,
  73. bool const &ParseArchFlags);
  74. static const char *ParseDepends(const char *Start,const char *Stop,
  75. std::string &Package,std::string &Ver,unsigned int &Op,
  76. bool const &ParseArchFlags, bool const &StripMultiArch);
  77. static const char *ParseDepends(const char *Start,const char *Stop,
  78. std::string &Package,std::string &Ver,unsigned int &Op,
  79. bool const &ParseArchFlags, bool const &StripMultiArch,
  80. bool const &ParseRestrictionsList);
  81. static const char *ConvertRelation(const char *I,unsigned int &Op);
  82. debListParser(FileFd *File, std::string const &Arch = "");
  83. virtual ~debListParser() {};
  84. private:
  85. unsigned char ParseMultiArch(bool const showErrors);
  86. };
  87. #endif