]>
Commit | Line | Data |
---|---|---|
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 | ||
8 | #include <apt-pkg/hashes.h> | |
9 | ||
10 | #include <map> | |
11 | #include <vector> | |
12 | #include <ctime> | |
13 | #include <string> | |
14 | ||
15 | #ifndef APT_8_CLEANER_HEADERS | |
16 | #include <apt-pkg/fileutl.h> | |
17 | #endif | |
18 | #ifndef APT_10_CLEANER_HEADERS | |
19 | #include <apt-pkg/pkgcache.h> | |
20 | #endif | |
21 | ||
22 | class indexRecords | |
23 | { | |
24 | APT_HIDDEN bool parseSumData(const char *&Start, const char *End, std::string &Name, | |
25 | std::string &Hash, unsigned long long &Size); | |
26 | public: | |
27 | struct checkSum; | |
28 | std::string ErrorText; | |
29 | ||
30 | private: | |
31 | enum APT_HIDDEN { ALWAYS_TRUSTED, NEVER_TRUSTED, CHECK_TRUST } Trusted; | |
32 | // dpointer (for later) | |
33 | void * d; | |
34 | ||
35 | protected: | |
36 | std::string Dist; | |
37 | std::string Suite; | |
38 | std::string ExpectedDist; | |
39 | time_t ValidUntil; | |
40 | bool SupportsAcquireByHash; | |
41 | ||
42 | std::map<std::string,checkSum *> Entries; | |
43 | ||
44 | public: | |
45 | ||
46 | indexRecords(const std::string &ExpectedDist = ""); | |
47 | ||
48 | // Lookup function | |
49 | virtual checkSum *Lookup(const std::string MetaKey); | |
50 | /** \brief tests if a checksum for this file is available */ | |
51 | bool Exists(std::string const &MetaKey) const; | |
52 | std::vector<std::string> MetaKeys(); | |
53 | ||
54 | virtual bool Load(std::string Filename); | |
55 | virtual bool CheckDist(const std::string MaybeDist) const; | |
56 | ||
57 | std::string GetDist() const; | |
58 | std::string GetSuite() const; | |
59 | bool GetSupportsAcquireByHash() const; | |
60 | time_t GetValidUntil() const; | |
61 | std::string GetExpectedDist() const; | |
62 | ||
63 | /** \brief check if source is marked as always trusted */ | |
64 | bool IsAlwaysTrusted() const; | |
65 | /** \brief check if source is marked as never trusted */ | |
66 | bool IsNeverTrusted() const; | |
67 | ||
68 | /** \brief sets an explicit trust value | |
69 | * | |
70 | * \b true means that the source should always be considered trusted, | |
71 | * while \b false marks a source as always untrusted, even if we have | |
72 | * a valid signature and everything. | |
73 | */ | |
74 | void SetTrusted(bool const Trusted); | |
75 | ||
76 | virtual ~indexRecords(); | |
77 | }; | |
78 | ||
79 | #if __GNUC__ >= 4 | |
80 | // ensure that con- & de-structor don't trigger this warning | |
81 | #pragma GCC diagnostic push | |
82 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" | |
83 | #endif | |
84 | struct indexRecords::checkSum | |
85 | { | |
86 | std::string MetaKeyFilename; | |
87 | HashStringList Hashes; | |
88 | unsigned long long Size; | |
89 | ||
90 | APT_DEPRECATED HashString Hash; | |
91 | }; | |
92 | #if __GNUC__ >= 4 | |
93 | #pragma GCC diagnostic pop | |
94 | #endif | |
95 | ||
96 | #endif |