deblistparser.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
  60. pkgCache::VerIterator &Ver);
  61. virtual unsigned long Offset() {return iOffset;};
  62. virtual unsigned long Size() {return Section.size();};
  63. virtual bool Step();
  64. bool LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,FileFd &File,
  65. std::string section);
  66. static const char *ParseDepends(const char *Start,const char *Stop,
  67. std::string &Package,std::string &Ver,unsigned int &Op);
  68. static const char *ParseDepends(const char *Start,const char *Stop,
  69. std::string &Package,std::string &Ver,unsigned int &Op,
  70. bool const &ParseArchFlags);
  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, bool const &StripMultiArch);
  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. bool const &ParseRestrictionsList);
  78. static const char *ConvertRelation(const char *I,unsigned int &Op);
  79. debListParser(FileFd *File, std::string const &Arch = "");
  80. virtual ~debListParser() {};
  81. private:
  82. unsigned char ParseMultiArch(bool const showErrors);
  83. };
  84. #endif