]>
Commit | Line | Data |
---|---|---|
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 | 19 | |
a7c835af AL |
20 | The vendor machanism is similar, except the vendor types are hard |
21 | wired. Before loading the source list the vendor list is loaded. | |
b3d44315 | 22 | This doesn't load key data, just the checks to perform. |
a7c835af | 23 | |
6c139d6e AL |
24 | ##################################################################### */ |
25 | /*}}}*/ | |
6c139d6e AL |
26 | #ifndef PKGLIB_SOURCELIST_H |
27 | #define PKGLIB_SOURCELIST_H | |
28 | ||
453b82a3 DK |
29 | #include <apt-pkg/pkgcache.h> |
30 | #include <apt-pkg/cacheiterators.h> | |
a02db58f | 31 | #include <apt-pkg/macros.h> |
453b82a3 DK |
32 | |
33 | #include <time.h> | |
34 | ||
6c139d6e AL |
35 | #include <string> |
36 | #include <vector> | |
5dd4c8b8 | 37 | #include <map> |
0a843901 | 38 | |
453b82a3 DK |
39 | #ifndef APT_8_CLEANER_HEADERS |
40 | #include <apt-pkg/tagfile.h> | |
41 | #endif | |
b9dadc24 DK |
42 | #ifndef APT_8_CLEANER_HEADERS |
43 | #include <apt-pkg/metaindex.h> | |
0a843901 AL |
44 | using std::string; |
45 | using std::vector; | |
b9dadc24 | 46 | #endif |
6c139d6e | 47 | |
453b82a3 DK |
48 | class FileFd; |
49 | class pkgTagSection; | |
472ff00e DK |
50 | class pkgAcquire; |
51 | class pkgIndexFile; | |
52 | class metaIndex; | |
53 | ||
0dc0b42d | 54 | class pkgSourceList |
6c139d6e | 55 | { |
6c55f07a | 56 | void * const d; |
6c139d6e | 57 | public: |
0dc0b42d | 58 | |
b2e465d6 AL |
59 | // List of supported source list types |
60 | class Type | |
6c139d6e | 61 | { |
b2e465d6 | 62 | public: |
0dc0b42d | 63 | |
b2e465d6 AL |
64 | // Global list of Items supported |
65 | static Type **GlobalList; | |
66 | static unsigned long GlobalListLen; | |
a02db58f | 67 | static Type *GetType(const char *Type) APT_PURE; |
b2e465d6 | 68 | |
463c8d80 DK |
69 | char const * const Name; |
70 | char const * const Label; | |
b2e465d6 | 71 | |
73688d27 | 72 | bool FixupURI(std::string &URI) const; |
7037aab5 MV |
73 | virtual bool ParseStanza(std::vector<metaIndex *> &List, |
74 | pkgTagSection &Tags, | |
75 | int stanza_n, | |
76 | FileFd &Fd); | |
b9dadc24 | 77 | virtual bool ParseLine(std::vector<metaIndex *> &List, |
b2e465d6 | 78 | const char *Buffer, |
b9dadc24 | 79 | unsigned long const &CurLine,std::string const &File) const; |
73688d27 | 80 | virtual bool CreateItem(std::vector<metaIndex *> &List,std::string const &URI, |
b9dadc24 DK |
81 | std::string const &Dist,std::string const &Section, |
82 | std::map<std::string, std::string> const &Options) const = 0; | |
463c8d80 DK |
83 | Type(char const * const Name, char const * const Label); |
84 | virtual ~Type(); | |
6c139d6e | 85 | }; |
0dc0b42d | 86 | |
b9dadc24 | 87 | typedef std::vector<metaIndex *>::const_iterator const_iterator; |
0dc0b42d DK |
88 | |
89 | protected: | |
90 | ||
91 | std::vector<metaIndex *> SrcList; | |
a7c835af | 92 | |
4194c9ae | 93 | int ParseFileDeb822(std::string File); |
1fa78a8a | 94 | bool ParseFileOldStyle(std::string File); |
6f447813 | 95 | |
0dc0b42d DK |
96 | public: |
97 | ||
6c139d6e | 98 | bool ReadMainList(); |
b9dadc24 | 99 | bool Read(std::string File); |
34b53501 MV |
100 | |
101 | // CNC:2003-03-03 | |
102 | void Reset(); | |
b9dadc24 DK |
103 | bool ReadAppend(std::string File); |
104 | bool ReadSourceDir(std::string Dir); | |
6c139d6e AL |
105 | |
106 | // List accessors | |
a7c835af AL |
107 | inline const_iterator begin() const {return SrcList.begin();}; |
108 | inline const_iterator end() const {return SrcList.end();}; | |
109 | inline unsigned int size() const {return SrcList.size();}; | |
110 | inline bool empty() const {return SrcList.empty();}; | |
0118833a | 111 | |
b2e465d6 AL |
112 | bool FindIndex(pkgCache::PkgFileIterator File, |
113 | pkgIndexFile *&Found) const; | |
b3d44315 | 114 | bool GetIndexes(pkgAcquire *Owner, bool GetAll=false) const; |
b2e465d6 | 115 | |
2ec858bc MV |
116 | // query last-modified time |
117 | time_t GetLastModifiedTime(); | |
118 | ||
6c139d6e | 119 | pkgSourceList(); |
e8afd168 | 120 | explicit pkgSourceList(std::string File); |
c8a4ce6c | 121 | virtual ~pkgSourceList(); |
6c139d6e AL |
122 | }; |
123 | ||
6c139d6e | 124 | #endif |