summaryrefslogtreecommitdiff
path: root/apt-pkg/indexrecords.h
blob: 3ff0725907a305cb013bf81d7dcbecec76e671b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// -*- mode: cpp; mode: fold -*-
#ifndef PKGLIB_INDEXRECORDS_H
#define PKGLIB_INDEXRECORDS_H

#include <apt-pkg/hashes.h>

#include <map>
#include <vector>
#include <ctime>
#include <string>

#ifndef APT_8_CLEANER_HEADERS
#include <apt-pkg/fileutl.h>
#endif
#ifndef APT_10_CLEANER_HEADERS
#include <apt-pkg/pkgcache.h>
#endif

class indexRecords
{
   APT_HIDDEN bool parseSumData(const char *&Start, const char *End, std::string &Name,
		     std::string &Hash, unsigned long long &Size);
   public:
   struct checkSum;
   std::string ErrorText;

   private:
   enum APT_HIDDEN { ALWAYS_TRUSTED, NEVER_TRUSTED, CHECK_TRUST } Trusted;
   // dpointer (for later)
   void * d;

   protected:
   std::string Dist;
   std::string Suite;
   std::string ExpectedDist;
   time_t Date;
   time_t ValidUntil;
   bool SupportsAcquireByHash;

   std::map<std::string,checkSum *> Entries;

   public:
   explicit indexRecords(const std::string &ExpectedDist = "");

   // Lookup function
   virtual checkSum *Lookup(std::string const &MetaKey);
   /** \brief tests if a checksum for this file is available */
   bool Exists(std::string const &MetaKey) const;
   std::vector<std::string> MetaKeys();

   virtual bool Load(std::string const &Filename);
   virtual bool CheckDist(std::string const &MaybeDist) const;

   std::string GetDist() const;
   std::string GetSuite() const;
   bool GetSupportsAcquireByHash() const;
   time_t GetValidUntil() const;
   time_t GetDate() const;
   std::string GetExpectedDist() const;

   /** \brief check if source is marked as always trusted */
   bool IsAlwaysTrusted() const;
   /** \brief check if source is marked as never trusted */
   bool IsNeverTrusted() const;

   /** \brief sets an explicit trust value
    *
    * \b true means that the source should always be considered trusted,
    * while \b false marks a source as always untrusted, even if we have
    * a valid signature and everything.
    */
   void SetTrusted(bool const Trusted);

   virtual ~indexRecords();
};

APT_IGNORE_DEPRECATED_PUSH
struct indexRecords::checkSum
{
   std::string MetaKeyFilename;
   HashStringList Hashes;
   unsigned long long Size;

   APT_DEPRECATED HashString Hash;
};
APT_IGNORE_DEPRECATED_POP

#endif