]> git.saurik.com Git - apt.git/blame - apt-pkg/sourcelist.h
enhance apt-key debugging options
[apt.git] / apt-pkg / sourcelist.h
CommitLineData
6c139d6e
AL
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
6c139d6e
AL
3/* ######################################################################
4
5 SourceList - Manage a list of sources
6
7 The Source List class provides access to a list of sources. It
6fc33863
AL
8 can read them from a file and generate a list of all the distinct
9 sources.
10
11 All sources have a type associated with them that defines the layout
12 of the archive. The exact format of the file is documented in
13 files.sgml.
b2e465d6
AL
14
15 The types are mapped through a list of type definitions which handle
a7c835af
AL
16 the actual construction of the back end type. After loading a source
17 list all you have is a list of package index files that have the ability
b2e465d6 18 to be Acquired.
6c139d6e
AL
19
20 ##################################################################### */
21 /*}}}*/
6c139d6e
AL
22#ifndef PKGLIB_SOURCELIST_H
23#define PKGLIB_SOURCELIST_H
24
453b82a3
DK
25#include <apt-pkg/pkgcache.h>
26#include <apt-pkg/cacheiterators.h>
a02db58f 27#include <apt-pkg/macros.h>
453b82a3
DK
28
29#include <time.h>
30
6c139d6e
AL
31#include <string>
32#include <vector>
5dd4c8b8 33#include <map>
0a843901 34
453b82a3
DK
35#ifndef APT_8_CLEANER_HEADERS
36#include <apt-pkg/tagfile.h>
37#endif
b9dadc24
DK
38#ifndef APT_8_CLEANER_HEADERS
39#include <apt-pkg/metaindex.h>
0a843901
AL
40using std::string;
41using std::vector;
b9dadc24 42#endif
6c139d6e 43
453b82a3
DK
44class FileFd;
45class pkgTagSection;
472ff00e
DK
46class pkgAcquire;
47class pkgIndexFile;
48class metaIndex;
49
0dc0b42d 50class pkgSourceList
6c139d6e 51{
6c55f07a 52 void * const d;
6c139d6e 53 public:
0dc0b42d 54
b2e465d6
AL
55 // List of supported source list types
56 class Type
6c139d6e 57 {
b2e465d6 58 public:
0dc0b42d 59
b2e465d6
AL
60 // Global list of Items supported
61 static Type **GlobalList;
62 static unsigned long GlobalListLen;
a02db58f 63 static Type *GetType(const char *Type) APT_PURE;
b2e465d6 64
463c8d80
DK
65 char const * const Name;
66 char const * const Label;
b2e465d6 67
73688d27 68 bool FixupURI(std::string &URI) const;
7037aab5
MV
69 virtual bool ParseStanza(std::vector<metaIndex *> &List,
70 pkgTagSection &Tags,
81460e32 71 unsigned int const stanza_n,
7037aab5 72 FileFd &Fd);
b9dadc24 73 virtual bool ParseLine(std::vector<metaIndex *> &List,
b2e465d6 74 const char *Buffer,
81460e32 75 unsigned int const CurLine,std::string const &File) const;
73688d27 76 virtual bool CreateItem(std::vector<metaIndex *> &List,std::string const &URI,
b9dadc24
DK
77 std::string const &Dist,std::string const &Section,
78 std::map<std::string, std::string> const &Options) const = 0;
463c8d80
DK
79 Type(char const * const Name, char const * const Label);
80 virtual ~Type();
6c139d6e 81 };
0dc0b42d 82
b9dadc24 83 typedef std::vector<metaIndex *>::const_iterator const_iterator;
0dc0b42d
DK
84
85 protected:
86
87 std::vector<metaIndex *> SrcList;
a7c835af 88
81460e32
DK
89 private:
90 APT_HIDDEN bool ParseFileDeb822(std::string const &File);
91 APT_HIDDEN bool ParseFileOldStyle(std::string const &File);
6f447813 92
0dc0b42d
DK
93 public:
94
6c139d6e 95 bool ReadMainList();
81460e32 96 bool Read(std::string const &File);
34b53501
MV
97
98 // CNC:2003-03-03
99 void Reset();
81460e32
DK
100 bool ReadAppend(std::string const &File);
101 bool ReadSourceDir(std::string const &Dir);
6c139d6e
AL
102
103 // List accessors
a7c835af
AL
104 inline const_iterator begin() const {return SrcList.begin();};
105 inline const_iterator end() const {return SrcList.end();};
106 inline unsigned int size() const {return SrcList.size();};
107 inline bool empty() const {return SrcList.empty();};
0118833a 108
b2e465d6
AL
109 bool FindIndex(pkgCache::PkgFileIterator File,
110 pkgIndexFile *&Found) const;
b3d44315 111 bool GetIndexes(pkgAcquire *Owner, bool GetAll=false) const;
b2e465d6 112
2ec858bc
MV
113 // query last-modified time
114 time_t GetLastModifiedTime();
115
6c139d6e 116 pkgSourceList();
c8a4ce6c 117 virtual ~pkgSourceList();
6c139d6e
AL
118};
119
6c139d6e 120#endif