apt-key del: Ignore case when checking if a keyid exists in a keyring.
[ntk/apt.git] / apt-pkg / srcrecords.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 // $Id: srcrecords.h,v 1.8.2.1 2003/12/26 16:27:34 mdz Exp $
4 /* ######################################################################
5
6 Source Package Records - Allows access to source package records
7
8 Parses and allows access to the list of source records and searching by
9 source name on that list.
10
11 ##################################################################### */
12 /*}}}*/
13 #ifndef PKGLIB_SRCRECORDS_H
14 #define PKGLIB_SRCRECORDS_H
15
16 #include <apt-pkg/macros.h>
17 #include <apt-pkg/hashes.h>
18
19 #include <string>
20 #include <vector>
21
22 #ifndef APT_8_CLEANER_HEADERS
23 using std::string;
24 using std::vector;
25 #endif
26
27 class pkgSourceList;
28 class pkgIndexFile;
29 class pkgSrcRecords
30 {
31 public:
32
33 #if __GNUC__ >= 4
34 // ensure that con- & de-structor don't trigger this warning
35 #pragma GCC diagnostic push
36 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
37 #endif
38 // Describes a single file
39 struct File
40 {
41 APT_DEPRECATED std::string MD5Hash;
42 APT_DEPRECATED unsigned long Size;
43 std::string Path;
44 std::string Type;
45 };
46 struct File2 : public File
47 {
48 unsigned long long FileSize;
49 HashStringList Hashes;
50 };
51 #if __GNUC__ >= 4
52 #pragma GCC diagnostic pop
53 #endif
54
55 // Abstract parser for each source record
56 class Parser
57 {
58 protected:
59
60 const pkgIndexFile *iIndex;
61
62 public:
63
64 enum BuildDep {BuildDepend=0x0,BuildDependIndep=0x1,
65 BuildConflict=0x2,BuildConflictIndep=0x3};
66
67 struct BuildDepRec
68 {
69 std::string Package;
70 std::string Version;
71 unsigned int Op;
72 unsigned char Type;
73 };
74
75 inline const pkgIndexFile &Index() const {return *iIndex;};
76
77 virtual bool Restart() = 0;
78 virtual bool Step() = 0;
79 virtual bool Jump(unsigned long const &Off) = 0;
80 virtual unsigned long Offset() = 0;
81 virtual std::string AsStr() = 0;
82
83 virtual std::string Package() const = 0;
84 virtual std::string Version() const = 0;
85 virtual std::string Maintainer() const = 0;
86 virtual std::string Section() const = 0;
87 virtual const char **Binaries() = 0; // Ownership does not transfer
88
89 //FIXME: Add a parameter to specify which architecture to use for [wildcard] matching
90 virtual bool BuildDepends(std::vector<BuildDepRec> &BuildDeps, bool const &ArchOnly, bool const &StripMultiArch = true) = 0;
91 static const char *BuildDepType(unsigned char const &Type) APT_PURE;
92
93 virtual bool Files(std::vector<pkgSrcRecords::File> &F) = 0;
94 bool Files2(std::vector<pkgSrcRecords::File2> &F);
95
96 Parser(const pkgIndexFile *Index) : iIndex(Index) {};
97 virtual ~Parser() {};
98 };
99
100 private:
101 /** \brief dpointer placeholder (for later in case we need it) */
102 void *d;
103
104 // The list of files and the current parser pointer
105 std::vector<Parser*> Files;
106 std::vector<Parser *>::iterator Current;
107
108 public:
109
110 // Reset the search
111 bool Restart();
112
113 // Step to the next SourcePackage and return pointer to the
114 // next SourceRecord. The pointer is owned by libapt.
115 const Parser* Step();
116
117 // Locate a package by name and return pointer to the Parser.
118 // The pointer is owned by libapt.
119 Parser* Find(const char *Package,bool const &SrcOnly = false);
120
121 pkgSrcRecords(pkgSourceList &List);
122 virtual ~pkgSrcRecords();
123 };
124
125 #endif