indexrecords.h 2.4 KB

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