pkgcache.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. /**\file pkgcache.h
  4. \brief pkgCache - Structure definitions for the cache file
  5. The goal of the cache file is two fold:
  6. Firstly to speed loading and processing of the package file array and
  7. secondly to reduce memory consumption of the package file array.
  8. The implementation is aimed at an environment with many primary package
  9. files, for instance someone that has a Package file for their CD-ROM, a
  10. Package file for the latest version of the distribution on the CD-ROM and a
  11. package file for the development version. Always present is the information
  12. contained in the status file which might be considered a separate package
  13. file.
  14. Please understand, this is designed as a <b>Cache file</b> it is not meant to be
  15. used on any system other than the one it was created for. It is not meant to
  16. be authoritative either, i.e. if a system crash or software failure occurs it
  17. must be perfectly acceptable for the cache file to be in an inconsistent
  18. state. Furthermore at any time the cache file may be erased without losing
  19. any information.
  20. Also the structures and storage layout is optimized for use by the APT
  21. and may not be suitable for all purposes. However it should be possible
  22. to extend it with associate cache files that contain other information.
  23. To keep memory use down the cache file only contains often used fields and
  24. fields that are inexpensive to store, the Package file has a full list of
  25. fields. Also the client may assume that all items are perfectly valid and
  26. need not perform checks against their correctness. Removal of information
  27. from the cache is possible, but blanks will be left in the file, and
  28. unused strings will also be present. The recommended implementation is to
  29. simply rebuild the cache each time any of the data files change. It is
  30. possible to add a new package file to the cache without any negative side
  31. effects.
  32. <b>Note on Pointer access</b>
  33. Clients should always use the CacheIterators classes for access to the
  34. cache and the data in it. They also provide a simple STL-like method for
  35. traversing the links of the datastructure.
  36. Every item in every structure is stored as the index to that structure.
  37. What this means is that once the files is mmaped every data access has to
  38. go through a fix up stage to get a real memory pointer. This is done
  39. by taking the index, multiplying it by the type size and then adding
  40. it to the start address of the memory block. This sounds complex, but
  41. in C it is a single array dereference. Because all items are aligned to
  42. their size and indexes are stored as multiples of the size of the structure
  43. the format is immediately portable to all possible architectures - BUT the
  44. generated files are -NOT-.
  45. This scheme allows code like this to be written:
  46. <example>
  47. void *Map = mmap(...);
  48. Package *PkgList = (Package *)Map;
  49. Header *Head = (Header *)Map;
  50. char *Strings = (char *)Map;
  51. cout << (Strings + PkgList[Head->HashTable[0]]->Name) << endl;
  52. </example>
  53. Notice the lack of casting or multiplication. The net result is to return
  54. the name of the first package in the first hash bucket, without error
  55. checks.
  56. The generator uses allocation pools to group similarly sized structures in
  57. large blocks to eliminate any alignment overhead. The generator also
  58. assures that no structures overlap and all indexes are unique. Although
  59. at first glance it may seem like there is the potential for two structures
  60. to exist at the same point the generator never allows this to happen.
  61. (See the discussion of free space pools)
  62. See \ref pkgcachegen.h for more information about generating cache structures. */
  63. /*}}}*/
  64. #ifndef PKGLIB_PKGCACHE_H
  65. #define PKGLIB_PKGCACHE_H
  66. #include <string>
  67. #include <time.h>
  68. #include <apt-pkg/mmap.h>
  69. using std::string;
  70. class pkgVersioningSystem;
  71. class pkgCache /*{{{*/
  72. {
  73. public:
  74. // Cache element predeclarations
  75. struct Header;
  76. struct Group;
  77. struct Package;
  78. struct PackageFile;
  79. struct Version;
  80. struct Description;
  81. struct Provides;
  82. struct Dependency;
  83. struct StringItem;
  84. struct VerFile;
  85. struct DescFile;
  86. // Iterators
  87. template<typename Str, typename Itr> class Iterator;
  88. class GrpIterator;
  89. class PkgIterator;
  90. class VerIterator;
  91. class DescIterator;
  92. class DepIterator;
  93. class PrvIterator;
  94. class PkgFileIterator;
  95. class VerFileIterator;
  96. class DescFileIterator;
  97. class Namespace;
  98. // These are all the constants used in the cache structures
  99. // WARNING - if you change these lists you must also edit
  100. // the stringification in pkgcache.cc and also consider whether
  101. // the cache file will become incompatible.
  102. struct Dep
  103. {
  104. enum DepType {Depends=1,PreDepends=2,Suggests=3,Recommends=4,
  105. Conflicts=5,Replaces=6,Obsoletes=7,DpkgBreaks=8,Enhances=9};
  106. /** \brief available compare operators
  107. The lower 4 bits are used to indicate what operator is being specified and
  108. the upper 4 bits are flags. OR indicates that the next package is
  109. or'd with the current package. */
  110. enum DepCompareOp {Or=0x10,NoOp=0,LessEq=0x1,GreaterEq=0x2,Less=0x3,
  111. Greater=0x4,Equals=0x5,NotEquals=0x6};
  112. };
  113. struct State
  114. {
  115. /** \brief priority of a package version
  116. Zero is used for unparsable or absent Priority fields. */
  117. enum VerPriority {Important=1,Required=2,Standard=3,Optional=4,Extra=5};
  118. enum PkgSelectedState {Unknown=0,Install=1,Hold=2,DeInstall=3,Purge=4};
  119. enum PkgInstState {Ok=0,ReInstReq=1,HoldInst=2,HoldReInstReq=3};
  120. enum PkgCurrentState {NotInstalled=0,UnPacked=1,HalfConfigured=2,
  121. HalfInstalled=4,ConfigFiles=5,Installed=6,
  122. TriggersAwaited=7,TriggersPending=8};
  123. };
  124. struct Flag
  125. {
  126. enum PkgFlags {Auto=(1<<0),Essential=(1<<3),Important=(1<<4)};
  127. enum PkgFFlags {NotSource=(1<<0),NotAutomatic=(1<<1)};
  128. };
  129. protected:
  130. // Memory mapped cache file
  131. string CacheFile;
  132. MMap &Map;
  133. unsigned long sHash(const string &S) const;
  134. unsigned long sHash(const char *S) const;
  135. public:
  136. // Pointers to the arrays of items
  137. Header *HeaderP;
  138. Group *GrpP;
  139. Package *PkgP;
  140. VerFile *VerFileP;
  141. DescFile *DescFileP;
  142. PackageFile *PkgFileP;
  143. Version *VerP;
  144. Description *DescP;
  145. Provides *ProvideP;
  146. Dependency *DepP;
  147. StringItem *StringItemP;
  148. char *StrP;
  149. virtual bool ReMap();
  150. inline bool Sync() {return Map.Sync();};
  151. inline MMap &GetMap() {return Map;};
  152. inline void *DataEnd() {return ((unsigned char *)Map.Data()) + Map.Size();};
  153. // String hashing function (512 range)
  154. inline unsigned long Hash(const string &S) const {return sHash(S);};
  155. inline unsigned long Hash(const char *S) const {return sHash(S);};
  156. // Useful transformation things
  157. const char *Priority(unsigned char Priority);
  158. // Accessors
  159. GrpIterator FindGrp(const string &Name);
  160. PkgIterator FindPkg(const string &Name);
  161. PkgIterator FindPkg(const string &Name, const string &Arch);
  162. Header &Head() {return *HeaderP;};
  163. inline GrpIterator GrpBegin();
  164. inline GrpIterator GrpEnd();
  165. inline PkgIterator PkgBegin();
  166. inline PkgIterator PkgEnd();
  167. inline PkgFileIterator FileBegin();
  168. inline PkgFileIterator FileEnd();
  169. inline bool MultiArchCache() const { return MultiArchEnabled; };
  170. // Make me a function
  171. pkgVersioningSystem *VS;
  172. // Converters
  173. static const char *CompTypeDeb(unsigned char Comp);
  174. static const char *CompType(unsigned char Comp);
  175. static const char *DepType(unsigned char Dep);
  176. pkgCache(MMap *Map,bool DoMap = true);
  177. virtual ~pkgCache() {};
  178. private:
  179. bool MultiArchEnabled;
  180. PkgIterator SingleArchFindPkg(const string &Name);
  181. };
  182. /*}}}*/
  183. // Header structure /*{{{*/
  184. struct pkgCache::Header
  185. {
  186. /** \brief Signature information
  187. This must contain the hex value 0x98FE76DC which is designed to
  188. verify that the system loading the image has the same byte order
  189. and byte size as the system saving the image */
  190. unsigned long Signature;
  191. /** These contain the version of the cache file */
  192. short MajorVersion;
  193. short MinorVersion;
  194. /** \brief indicates if the cache should be erased
  195. Dirty is true if the cache file was opened for reading, the client
  196. expects to have written things to it and have not fully synced it.
  197. The file should be erased and rebuilt if it is true. */
  198. bool Dirty;
  199. /** \brief Size of structure values
  200. All *Sz variables contains the sizeof() that particular structure.
  201. It is used as an extra consistency check on the structure of the file.
  202. If any of the size values do not exactly match what the client expects
  203. then the client should refuse the load the file. */
  204. unsigned short HeaderSz;
  205. unsigned short PackageSz;
  206. unsigned short PackageFileSz;
  207. unsigned short VersionSz;
  208. unsigned short DescriptionSz;
  209. unsigned short DependencySz;
  210. unsigned short ProvidesSz;
  211. unsigned short VerFileSz;
  212. unsigned short DescFileSz;
  213. /** \brief Structure counts
  214. These indicate the number of each structure contained in the cache.
  215. PackageCount is especially useful for generating user state structures.
  216. See Package::Id for more info. */
  217. unsigned long GroupCount;
  218. unsigned long PackageCount;
  219. unsigned long VersionCount;
  220. unsigned long DescriptionCount;
  221. unsigned long DependsCount;
  222. unsigned long PackageFileCount;
  223. unsigned long VerFileCount;
  224. unsigned long DescFileCount;
  225. unsigned long ProvidesCount;
  226. /** \brief index of the first PackageFile structure
  227. The PackageFile structures are singly linked lists that represent
  228. all package files that have been merged into the cache. */
  229. map_ptrloc FileList;
  230. /** \brief index of the first StringItem structure
  231. The cache contains a list of all the unique strings (StringItems).
  232. The parser reads this list into memory so it can match strings
  233. against it.*/
  234. map_ptrloc StringList;
  235. /** \brief String representing the version system used */
  236. map_ptrloc VerSysName;
  237. /** \brief Architecture(s) the cache was built against */
  238. map_ptrloc Architecture;
  239. /** \brief The maximum size of a raw entry from the original Package file */
  240. unsigned long MaxVerFileSize;
  241. /** \brief The maximum size of a raw entry from the original Translation file */
  242. unsigned long MaxDescFileSize;
  243. /** \brief The Pool structures manage the allocation pools that the generator uses
  244. Start indicates the first byte of the pool, Count is the number of objects
  245. remaining in the pool and ItemSize is the structure size (alignment factor)
  246. of the pool. An ItemSize of 0 indicates the pool is empty. There should be
  247. the same number of pools as there are structure types. The generator
  248. stores this information so future additions can make use of any unused pool
  249. blocks. */
  250. DynamicMMap::Pool Pools[9];
  251. /** \brief hash tables providing rapid group/package name lookup
  252. Each group/package name is inserted into the hash table using pkgCache::Hash(const &string)
  253. By iterating over each entry in the hash table it is possible to iterate over
  254. the entire list of packages. Hash Collisions are handled with a singly linked
  255. list of packages based at the hash item. The linked list contains only
  256. packages that match the hashing function.
  257. In the PkgHashTable is it possible that multiple packages have the same name -
  258. these packages are stored as a sequence in the list.
  259. Beware: The Hashmethod assumes that the hash table sizes are equal */
  260. map_ptrloc PkgHashTable[2*1048];
  261. map_ptrloc GrpHashTable[2*1048];
  262. bool CheckSizes(Header &Against) const;
  263. Header();
  264. };
  265. /*}}}*/
  266. // Group structure /*{{{*/
  267. /** \brief groups architecture depending packages together
  268. On or more packages with the same name form a group, so we have
  269. a simple way to access a package built for different architectures
  270. Group exists in a singly linked list of group records starting at
  271. the hash index of the name in the pkgCache::Header::GrpHashTable */
  272. struct pkgCache::Group
  273. {
  274. /** \brief Name of the group */
  275. map_ptrloc Name; // StringItem
  276. // Linked List
  277. /** Link to the first package which belongs to the group */
  278. map_ptrloc FirstPackage; // Package
  279. /** Link to the last package which belongs to the group */
  280. map_ptrloc LastPackage; // Package
  281. /** Link to the next Group */
  282. map_ptrloc Next; // Group
  283. };
  284. /*}}}*/
  285. // Package structure /*{{{*/
  286. /** \brief contains information for a single unique package
  287. There can be any number of versions of a given package.
  288. Package exists in a singly linked list of package records starting at
  289. the hash index of the name in the pkgCache::Header::PkgHashTable
  290. A package can be created for every architecture so package names are
  291. not unique, but it is garanteed that packages with the same name
  292. are sequencel ordered in the list. Packages with the same name can be
  293. accessed with the Group.
  294. */
  295. struct pkgCache::Package
  296. {
  297. /** \brief Name of the package */
  298. map_ptrloc Name; // StringItem
  299. /** \brief Architecture of the package */
  300. map_ptrloc Arch; // StringItem
  301. /** \brief Base of a singly linked list of versions
  302. Each structure represents a unique version of the package.
  303. The version structures contain links into PackageFile and the
  304. original text file as well as detailed information about the size
  305. and dependencies of the specific package. In this way multiple
  306. versions of a package can be cleanly handled by the system.
  307. Furthermore, this linked list is guaranteed to be sorted
  308. from Highest version to lowest version with no duplicate entries. */
  309. map_ptrloc VersionList; // Version
  310. /** \brief index to the installed version */
  311. map_ptrloc CurrentVer; // Version
  312. /** \brief indicates the deduced section
  313. Should be the index to the string "Unknown" or to the section
  314. of the last parsed item. */
  315. map_ptrloc Section; // StringItem
  316. /** \brief index of the group this package belongs to */
  317. map_ptrloc Group; // Group the Package belongs to
  318. // Linked list
  319. /** \brief Link to the next package in the same bucket */
  320. map_ptrloc NextPackage; // Package
  321. /** \brief List of all dependencies on this package */
  322. map_ptrloc RevDepends; // Dependency
  323. /** \brief List of all "packages" this package provide */
  324. map_ptrloc ProvidesList; // Provides
  325. // Install/Remove/Purge etc
  326. /** \brief state that the user wishes the package to be in */
  327. unsigned char SelectedState; // What
  328. /** \brief installation state of the package
  329. This should be "ok" but in case the installation failed
  330. it will be different.
  331. */
  332. unsigned char InstState; // Flags
  333. /** \brief indicates if the package is installed */
  334. unsigned char CurrentState; // State
  335. /** \brief unique sequel ID
  336. ID is a unique value from 0 to Header->PackageCount assigned by the generator.
  337. This allows clients to create an array of size PackageCount and use it to store
  338. state information for the package map. For instance the status file emitter uses
  339. this to track which packages have been emitted already. */
  340. unsigned int ID;
  341. /** \brief some useful indicators of the package's state */
  342. unsigned long Flags;
  343. };
  344. /*}}}*/
  345. // Package File structure /*{{{*/
  346. /** \brief stores information about the files used to generate the cache
  347. Package files are referenced by Version structures to be able to know
  348. after the generation still from which Packages file includes this Version
  349. as we need this information later on e.g. for pinning. */
  350. struct pkgCache::PackageFile
  351. {
  352. /** \brief physical disk file that this PackageFile represents */
  353. map_ptrloc FileName; // StringItem
  354. /** \brief the release information
  355. Please see the files document for a description of what the
  356. release information means. */
  357. map_ptrloc Archive; // StringItem
  358. map_ptrloc Codename; // StringItem
  359. map_ptrloc Component; // StringItem
  360. map_ptrloc Version; // StringItem
  361. map_ptrloc Origin; // StringItem
  362. map_ptrloc Label; // StringItem
  363. map_ptrloc Architecture; // StringItem
  364. /** \brief The site the index file was fetched from */
  365. map_ptrloc Site; // StringItem
  366. /** \brief indicates what sort of index file this is
  367. @TODO enumerate at least the possible indexes */
  368. map_ptrloc IndexType; // StringItem
  369. /** \brief Size of the file
  370. Used together with the modification time as a
  371. simple check to ensure that the Packages
  372. file has not been altered since Cache generation. */
  373. unsigned long Size;
  374. /** \brief Modification time for the file */
  375. time_t mtime;
  376. /* @TODO document PackageFile::Flags */
  377. unsigned long Flags;
  378. // Linked list
  379. /** \brief Link to the next PackageFile in the Cache */
  380. map_ptrloc NextFile; // PackageFile
  381. /** \brief unique sequel ID */
  382. unsigned int ID;
  383. };
  384. /*}}}*/
  385. // VerFile structure /*{{{*/
  386. /** \brief associates a version with a PackageFile
  387. This allows a full description of all Versions in all files
  388. (and hence all sources) under consideration. */
  389. struct pkgCache::VerFile
  390. {
  391. /** \brief index of the package file that this version was found in */
  392. map_ptrloc File; // PackageFile
  393. /** \brief next step in the linked list */
  394. map_ptrloc NextFile; // PkgVerFile
  395. /** \brief position in the package file */
  396. map_ptrloc Offset; // File offset
  397. /* @TODO document pkgCache::VerFile::Size */
  398. unsigned long Size;
  399. };
  400. /*}}}*/
  401. // DescFile structure /*{{{*/
  402. /** \brief associates a description with a Translation file */
  403. struct pkgCache::DescFile
  404. {
  405. /** \brief index of the file that this description was found in */
  406. map_ptrloc File; // PackageFile
  407. /** \brief next step in the linked list */
  408. map_ptrloc NextFile; // PkgVerFile
  409. /** \brief position in the file */
  410. map_ptrloc Offset; // File offset
  411. /* @TODO document pkgCache::DescFile::Size */
  412. unsigned long Size;
  413. };
  414. /*}}}*/
  415. // Version structure /*{{{*/
  416. /** \brief information for a single version of a package
  417. The version list is always sorted from highest version to lowest
  418. version by the generator. Equal version numbers are either merged
  419. or handled as separate versions based on the Hash value. */
  420. struct pkgCache::Version
  421. {
  422. /** \brief complete version string */
  423. map_ptrloc VerStr; // StringItem
  424. /** \brief section this version is filled in */
  425. map_ptrloc Section; // StringItem
  426. /** \brief stores the MultiArch capabilities of this version
  427. None is the default and doesn't trigger special behaviour,
  428. Foreign means that this version can fulfill dependencies even
  429. if it is built for another architecture as the requester.
  430. Same indicates that builds for different architectures can
  431. be co-installed on the system and All is the marker for a
  432. version with the Architecture: all. */
  433. enum {None, All, Foreign, Same, Allowed} MultiArch;
  434. /** \brief references all the PackageFile's that this version came from
  435. FileList can be used to determine what distribution(s) the Version
  436. applies to. If FileList is 0 then this is a blank version.
  437. The structure should also have a 0 in all other fields excluding
  438. pkgCache::Version::VerStr and Possibly pkgCache::Version::NextVer. */
  439. map_ptrloc FileList; // VerFile
  440. /** \brief next (lower or equal) version in the linked list */
  441. map_ptrloc NextVer; // Version
  442. /** \brief next description in the linked list */
  443. map_ptrloc DescriptionList; // Description
  444. /** \brief base of the dependency list */
  445. map_ptrloc DependsList; // Dependency
  446. /** \brief links to the owning package
  447. This allows reverse dependencies to determine the package */
  448. map_ptrloc ParentPkg; // Package
  449. /** \brief list of pkgCache::Provides */
  450. map_ptrloc ProvidesList; // Provides
  451. /** \brief archive size for this version
  452. For Debian this is the size of the .deb file. */
  453. map_ptrloc Size; // These are the .deb size
  454. /** \brief uncompressed size for this version */
  455. map_ptrloc InstalledSize;
  456. /** \brief characteristic value representing this version
  457. No two packages in existence should have the same VerStr
  458. and Hash with different contents. */
  459. unsigned short Hash;
  460. /** \brief unique sequel ID */
  461. unsigned int ID;
  462. /** \brief parsed priority value */
  463. unsigned char Priority;
  464. };
  465. /*}}}*/
  466. // Description structure /*{{{*/
  467. /** \brief datamember of a linked list of available description for a version */
  468. struct pkgCache::Description
  469. {
  470. /** \brief Language code of this description (translation)
  471. If the value has a 0 length then this is read using the Package
  472. file else the Translation-CODE file is used. */
  473. map_ptrloc language_code; // StringItem
  474. /** \brief MD5sum of the original description
  475. Used to map Translations of a description to a version
  476. and to check that the Translation is up-to-date. */
  477. map_ptrloc md5sum; // StringItem
  478. /* @TODO document pkgCache::Description::FileList */
  479. map_ptrloc FileList; // DescFile
  480. /** \brief next translation for this description */
  481. map_ptrloc NextDesc; // Description
  482. /** \brief the text is a description of this package */
  483. map_ptrloc ParentPkg; // Package
  484. /** \brief unique sequel ID */
  485. unsigned int ID;
  486. };
  487. /*}}}*/
  488. // Dependency structure /*{{{*/
  489. /** \brief information for a single dependency record
  490. The records are split up like this to ease processing by the client.
  491. The base of the linked list is pkgCache::Version::DependsList.
  492. All forms of dependencies are recorded here including Depends,
  493. Recommends, Suggests, Enhances, Conflicts, Replaces and Breaks. */
  494. struct pkgCache::Dependency
  495. {
  496. /** \brief string of the version the dependency is applied against */
  497. map_ptrloc Version; // StringItem
  498. /** \brief index of the package this depends applies to
  499. The generator will - if the package does not already exist -
  500. create a blank (no version records) package. */
  501. map_ptrloc Package; // Package
  502. /** \brief next dependency of this version */
  503. map_ptrloc NextDepends; // Dependency
  504. /** \brief next reverse dependency of this package */
  505. map_ptrloc NextRevDepends; // Dependency
  506. /** \brief version of the package which has the reverse depends */
  507. map_ptrloc ParentVer; // Version
  508. /** \brief unique sequel ID */
  509. map_ptrloc ID;
  510. /** \brief Dependency type - Depends, Recommends, Conflicts, etc */
  511. unsigned char Type;
  512. /** \brief comparison operator specified on the depends line
  513. If the high bit is set then it is a logical OR with the previous record. */
  514. unsigned char CompareOp;
  515. };
  516. /*}}}*/
  517. // Provides structure /*{{{*/
  518. /** \brief handles virtual packages
  519. When a Provides: line is encountered a new provides record is added
  520. associating the package with a virtual package name.
  521. The provides structures are linked off the package structures.
  522. This simplifies the analysis of dependencies and other aspects A provides
  523. refers to a specific version of a specific package, not all versions need to
  524. provide that provides.*/
  525. struct pkgCache::Provides
  526. {
  527. /** \brief index of the package providing this */
  528. map_ptrloc ParentPkg; // Package
  529. /** \brief index of the version this provide line applies to */
  530. map_ptrloc Version; // Version
  531. /** \brief version in the provides line (if any)
  532. This version allows dependencies to depend on specific versions of a
  533. Provides, as well as allowing Provides to override existing packages.
  534. This is experimental. Note that Debian doesn't allow versioned provides */
  535. map_ptrloc ProvideVersion; // StringItem
  536. /** \brief next provides (based of package) */
  537. map_ptrloc NextProvides; // Provides
  538. /** \brief next provides (based of version) */
  539. map_ptrloc NextPkgProv; // Provides
  540. };
  541. /*}}}*/
  542. // StringItem structure /*{{{*/
  543. /** \brief used for generating single instances of strings
  544. Some things like Section Name are are useful to have as unique tags.
  545. It is part of a linked list based at pkgCache::Header::StringList
  546. All strings are simply inlined any place in the file that is natural
  547. for the writer. The client should make no assumptions about the positioning
  548. of strings. All StringItems should be null-terminated. */
  549. struct pkgCache::StringItem
  550. {
  551. /** \brief string this refers to */
  552. map_ptrloc String; // StringItem
  553. /** \brief Next link in the chain */
  554. map_ptrloc NextItem; // StringItem
  555. };
  556. /*}}}*/
  557. #include <apt-pkg/cacheiterators.h>
  558. inline pkgCache::GrpIterator pkgCache::GrpBegin()
  559. {return GrpIterator(*this);};
  560. inline pkgCache::GrpIterator pkgCache::GrpEnd()
  561. {return GrpIterator(*this,GrpP);};
  562. inline pkgCache::PkgIterator pkgCache::PkgBegin()
  563. {return PkgIterator(*this);};
  564. inline pkgCache::PkgIterator pkgCache::PkgEnd()
  565. {return PkgIterator(*this,PkgP);};
  566. inline pkgCache::PkgFileIterator pkgCache::FileBegin()
  567. {return PkgFileIterator(*this,PkgFileP + HeaderP->FileList);};
  568. inline pkgCache::PkgFileIterator pkgCache::FileEnd()
  569. {return PkgFileIterator(*this,PkgFileP);};
  570. // Oh I wish for Real Name Space Support
  571. class pkgCache::Namespace /*{{{*/
  572. {
  573. public:
  574. typedef pkgCache::GrpIterator GrpIterator;
  575. typedef pkgCache::PkgIterator PkgIterator;
  576. typedef pkgCache::VerIterator VerIterator;
  577. typedef pkgCache::DescIterator DescIterator;
  578. typedef pkgCache::DepIterator DepIterator;
  579. typedef pkgCache::PrvIterator PrvIterator;
  580. typedef pkgCache::PkgFileIterator PkgFileIterator;
  581. typedef pkgCache::VerFileIterator VerFileIterator;
  582. typedef pkgCache::Version Version;
  583. typedef pkgCache::Description Description;
  584. typedef pkgCache::Package Package;
  585. typedef pkgCache::Header Header;
  586. typedef pkgCache::Dep Dep;
  587. typedef pkgCache::Flag Flag;
  588. };
  589. /*}}}*/
  590. #endif