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