indexrecords.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 * const 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. explicit indexRecords(const std::string &ExpectedDist = "");
  36. // Lookup function
  37. virtual checkSum *Lookup(std::string const &MetaKey);
  38. /** \brief tests if a checksum for this file is available */
  39. bool Exists(std::string const &MetaKey) const;
  40. std::vector<std::string> MetaKeys();
  41. virtual bool Load(std::string const &Filename);
  42. virtual bool CheckDist(std::string const &MaybeDist) const;
  43. std::string GetDist() const;
  44. std::string GetSuite() const;
  45. bool GetSupportsAcquireByHash() const;
  46. time_t GetValidUntil() const;
  47. time_t GetDate() const;
  48. std::string GetExpectedDist() const;
  49. /** \brief check if source is marked as always trusted */
  50. bool IsAlwaysTrusted() const;
  51. /** \brief check if source is marked as never trusted */
  52. bool IsNeverTrusted() const;
  53. /** \brief sets an explicit trust value
  54. *
  55. * \b true means that the source should always be considered trusted,
  56. * while \b false marks a source as always untrusted, even if we have
  57. * a valid signature and everything.
  58. */
  59. void SetTrusted(bool const Trusted);
  60. virtual ~indexRecords();
  61. };
  62. APT_IGNORE_DEPRECATED_PUSH
  63. struct indexRecords::checkSum
  64. {
  65. std::string MetaKeyFilename;
  66. HashStringList Hashes;
  67. unsigned long long Size;
  68. APT_DEPRECATED HashString Hash;
  69. };
  70. APT_IGNORE_DEPRECATED_POP
  71. #endif