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