indexrecords.h 2.3 KB

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