indexrecords.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // -*- mode: cpp; mode: fold -*-
  2. #ifndef PKGLIB_INDEXRECORDS_H
  3. #define PKGLIB_INDEXRECORDS_H
  4. #include <apt-pkg/hashes.h>
  5. #include <map>
  6. #include <vector>
  7. #include <ctime>
  8. #include <string>
  9. #ifndef APT_8_CLEANER_HEADERS
  10. #include <apt-pkg/fileutl.h>
  11. #endif
  12. #ifndef APT_10_CLEANER_HEADERS
  13. #include <apt-pkg/pkgcache.h>
  14. #endif
  15. class indexRecords
  16. {
  17. APT_HIDDEN bool parseSumData(const char *&Start, const char *End, std::string &Name,
  18. std::string &Hash, unsigned long long &Size);
  19. public:
  20. struct checkSum;
  21. std::string ErrorText;
  22. private:
  23. enum APT_HIDDEN { ALWAYS_TRUSTED, NEVER_TRUSTED, CHECK_TRUST } Trusted;
  24. // dpointer (for later)
  25. void * d;
  26. protected:
  27. std::string Dist;
  28. std::string Suite;
  29. std::string ExpectedDist;
  30. time_t Date;
  31. time_t ValidUntil;
  32. bool SupportsAcquireByHash;
  33. std::map<std::string,checkSum *> Entries;
  34. public:
  35. #if APT_PKG_ABI >= 413
  36. indexRecords(const std::string &ExpectedDist = "");
  37. #else
  38. indexRecords();
  39. indexRecords(const std::string ExpectedDist);
  40. #endif
  41. // Lookup function
  42. virtual checkSum *Lookup(const std::string MetaKey);
  43. /** \brief tests if a checksum for this file is available */
  44. bool Exists(std::string const &MetaKey) const;
  45. std::vector<std::string> MetaKeys();
  46. virtual bool Load(std::string Filename);
  47. virtual bool CheckDist(const std::string MaybeDist) const;
  48. std::string GetDist() const;
  49. std::string GetSuite() const;
  50. bool GetSupportsAcquireByHash() const;
  51. time_t GetValidUntil() const;
  52. time_t GetDate() const;
  53. std::string GetExpectedDist() const;
  54. /** \brief check if source is marked as always trusted */
  55. bool IsAlwaysTrusted() const;
  56. /** \brief check if source is marked as never trusted */
  57. bool IsNeverTrusted() const;
  58. /** \brief sets an explicit trust value
  59. *
  60. * \b true means that the source should always be considered trusted,
  61. * while \b false marks a source as always untrusted, even if we have
  62. * a valid signature and everything.
  63. */
  64. void SetTrusted(bool const Trusted);
  65. virtual ~indexRecords();
  66. };
  67. APT_IGNORE_DEPRECATED_PUSH
  68. struct indexRecords::checkSum
  69. {
  70. std::string MetaKeyFilename;
  71. HashStringList Hashes;
  72. unsigned long long Size;
  73. APT_DEPRECATED HashString Hash;
  74. };
  75. APT_IGNORE_DEPRECATED_POP
  76. #endif