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 ValidUntil;
  34. bool SupportsAcquireByHash;
  35. std::map<std::string,checkSum *> Entries;
  36. public:
  37. indexRecords(const std::string &ExpectedDist = "");
  38. // Lookup function
  39. virtual checkSum *Lookup(const std::string MetaKey);
  40. /** \brief tests if a checksum for this file is available */
  41. bool Exists(std::string const &MetaKey) const;
  42. std::vector<std::string> MetaKeys();
  43. virtual bool Load(std::string Filename);
  44. virtual bool CheckDist(const std::string MaybeDist) const;
  45. std::string GetDist() const;
  46. std::string GetSuite() const;
  47. bool GetSupportsAcquireByHash() const;
  48. time_t GetValidUntil() const;
  49. std::string GetExpectedDist() const;
  50. /** \brief check if source is marked as always trusted */
  51. bool IsAlwaysTrusted() const;
  52. /** \brief check if source is marked as never trusted */
  53. bool IsNeverTrusted() const;
  54. /** \brief sets an explicit trust value
  55. *
  56. * \b true means that the source should always be considered trusted,
  57. * while \b false marks a source as always untrusted, even if we have
  58. * a valid signature and everything.
  59. */
  60. void SetTrusted(bool const Trusted);
  61. virtual ~indexRecords();
  62. };
  63. #if __GNUC__ >= 4
  64. // ensure that con- & de-structor don't trigger this warning
  65. #pragma GCC diagnostic push
  66. #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
  67. #endif
  68. struct indexRecords::checkSum
  69. {
  70. std::string MetaKeyFilename;
  71. HashStringList Hashes;
  72. unsigned long long Size;
  73. APT_DEPRECATED HashString Hash;
  74. };
  75. #if __GNUC__ >= 4
  76. #pragma GCC diagnostic pop
  77. #endif
  78. #endif