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