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