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