deblistparser.h 3.5 KB

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