You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

130 lines
3.6 KiB

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