]> git.saurik.com Git - apt.git/blame - apt-pkg/pkgcache.h
increase Pkg/Grp hash table size from 2k to 64k
[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. */
fbfb2a7c 141 enum VerPriority {Important=1,Required=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;
289 /** \brief Architecture(s) the cache was built against */
290 map_ptrloc Architecture;
291 /** \brief The maximum size of a raw entry from the original Package file */
ad00ae81 292 unsigned long MaxVerFileSize;
94449d7c 293 /** \brief The maximum size of a raw entry from the original Translation file */
a52f938b 294 unsigned long MaxDescFileSize;
578bfd0a 295
94449d7c
DK
296 /** \brief The Pool structures manage the allocation pools that the generator uses
297
298 Start indicates the first byte of the pool, Count is the number of objects
299 remaining in the pool and ItemSize is the structure size (alignment factor)
300 of the pool. An ItemSize of 0 indicates the pool is empty. There should be
301 the same number of pools as there are structure types. The generator
302 stores this information so future additions can make use of any unused pool
303 blocks. */
5bf15716 304 DynamicMMap::Pool Pools[9];
578bfd0a 305
94449d7c
DK
306 /** \brief hash tables providing rapid group/package name lookup
307
308 Each group/package name is inserted into the hash table using pkgCache::Hash(const &string)
309 By iterating over each entry in the hash table it is possible to iterate over
310 the entire list of packages. Hash Collisions are handled with a singly linked
311 list of packages based at the hash item. The linked list contains only
312 packages that match the hashing function.
313 In the PkgHashTable is it possible that multiple packages have the same name -
314 these packages are stored as a sequence in the list.
315
316 Beware: The Hashmethod assumes that the hash table sizes are equal */
43f8819b
MV
317 map_ptrloc PkgHashTable[64*1048];
318 map_ptrloc GrpHashTable[64*1048];
578bfd0a 319
0688ccd8
JAK
320 /** \brief Size of the complete cache file */
321 unsigned long CacheFileSize;
322
a02db58f 323 bool CheckSizes(Header &Against) const APT_PURE;
578bfd0a
AL
324 Header();
325};
92fcbfc1 326 /*}}}*/
94449d7c
DK
327// Group structure /*{{{*/
328/** \brief groups architecture depending packages together
5bf15716 329
94449d7c
DK
330 On or more packages with the same name form a group, so we have
331 a simple way to access a package built for different architectures
332 Group exists in a singly linked list of group records starting at
333 the hash index of the name in the pkgCache::Header::GrpHashTable */
334struct pkgCache::Group
335{
336 /** \brief Name of the group */
337 map_ptrloc Name; // StringItem
338
339 // Linked List
52c41485 340 /** \brief Link to the first package which belongs to the group */
94449d7c 341 map_ptrloc FirstPackage; // Package
52c41485 342 /** \brief Link to the last package which belongs to the group */
94449d7c 343 map_ptrloc LastPackage; // Package
52c41485 344 /** \brief Link to the next Group */
94449d7c 345 map_ptrloc Next; // Group
52c41485
DK
346 /** \brief unique sequel ID */
347 unsigned int ID;
348
5bf15716
DK
349};
350 /*}}}*/
94449d7c
DK
351// Package structure /*{{{*/
352/** \brief contains information for a single unique package
353
354 There can be any number of versions of a given package.
355 Package exists in a singly linked list of package records starting at
356 the hash index of the name in the pkgCache::Header::PkgHashTable
357
358 A package can be created for every architecture so package names are
1e3f4083 359 not unique, but it is guaranteed that packages with the same name
94449d7c
DK
360 are sequencel ordered in the list. Packages with the same name can be
361 accessed with the Group.
362*/
363struct pkgCache::Package
578bfd0a 364{
94449d7c
DK
365 /** \brief Name of the package */
366 map_ptrloc Name; // StringItem
367 /** \brief Architecture of the package */
368 map_ptrloc Arch; // StringItem
369 /** \brief Base of a singly linked list of versions
370
371 Each structure represents a unique version of the package.
372 The version structures contain links into PackageFile and the
373 original text file as well as detailed information about the size
374 and dependencies of the specific package. In this way multiple
375 versions of a package can be cleanly handled by the system.
376 Furthermore, this linked list is guaranteed to be sorted
377 from Highest version to lowest version with no duplicate entries. */
349cd3b8 378 map_ptrloc VersionList; // Version
94449d7c 379 /** \brief index to the installed version */
349cd3b8 380 map_ptrloc CurrentVer; // Version
94449d7c
DK
381 /** \brief indicates the deduced section
382
383 Should be the index to the string "Unknown" or to the section
384 of the last parsed item. */
385 map_ptrloc Section; // StringItem
386 /** \brief index of the group this package belongs to */
5bf15716 387 map_ptrloc Group; // Group the Package belongs to
94449d7c
DK
388
389 // Linked list
390 /** \brief Link to the next package in the same bucket */
349cd3b8 391 map_ptrloc NextPackage; // Package
94449d7c 392 /** \brief List of all dependencies on this package */
349cd3b8 393 map_ptrloc RevDepends; // Dependency
94449d7c 394 /** \brief List of all "packages" this package provide */
349cd3b8 395 map_ptrloc ProvidesList; // Provides
a52f938b 396
578bfd0a 397 // Install/Remove/Purge etc
94449d7c 398 /** \brief state that the user wishes the package to be in */
578bfd0a 399 unsigned char SelectedState; // What
94449d7c
DK
400 /** \brief installation state of the package
401
402 This should be "ok" but in case the installation failed
403 it will be different.
404 */
578bfd0a 405 unsigned char InstState; // Flags
94449d7c 406 /** \brief indicates if the package is installed */
578bfd0a 407 unsigned char CurrentState; // State
94449d7c
DK
408
409 /** \brief unique sequel ID
410
411 ID is a unique value from 0 to Header->PackageCount assigned by the generator.
412 This allows clients to create an array of size PackageCount and use it to store
413 state information for the package map. For instance the status file emitter uses
414 this to track which packages have been emitted already. */
09fab244 415 unsigned int ID;
94449d7c 416 /** \brief some useful indicators of the package's state */
f55a958f 417 unsigned long Flags;
578bfd0a 418};
92fcbfc1 419 /*}}}*/
94449d7c
DK
420// Package File structure /*{{{*/
421/** \brief stores information about the files used to generate the cache
422
423 Package files are referenced by Version structures to be able to know
424 after the generation still from which Packages file includes this Version
425 as we need this information later on e.g. for pinning. */
426struct pkgCache::PackageFile
578bfd0a 427{
94449d7c
DK
428 /** \brief physical disk file that this PackageFile represents */
429 map_ptrloc FileName; // StringItem
430 /** \brief the release information
431
432 Please see the files document for a description of what the
433 release information means. */
434 map_ptrloc Archive; // StringItem
435 map_ptrloc Codename; // StringItem
436 map_ptrloc Component; // StringItem
437 map_ptrloc Version; // StringItem
438 map_ptrloc Origin; // StringItem
439 map_ptrloc Label; // StringItem
440 map_ptrloc Architecture; // StringItem
441 /** \brief The site the index file was fetched from */
442 map_ptrloc Site; // StringItem
443 /** \brief indicates what sort of index file this is
444
445 @TODO enumerate at least the possible indexes */
446 map_ptrloc IndexType; // StringItem
447 /** \brief Size of the file
448
449 Used together with the modification time as a
450 simple check to ensure that the Packages
451 file has not been altered since Cache generation. */
452 unsigned long Size;
453 /** \brief Modification time for the file */
454 time_t mtime;
455
255c9e4b 456 /** @TODO document PackageFile::Flags */
3c124dde 457 unsigned long Flags;
94449d7c 458
578bfd0a 459 // Linked list
94449d7c 460 /** \brief Link to the next PackageFile in the Cache */
349cd3b8 461 map_ptrloc NextFile; // PackageFile
94449d7c 462 /** \brief unique sequel ID */
09fab244 463 unsigned int ID;
578bfd0a 464};
92fcbfc1 465 /*}}}*/
94449d7c
DK
466// VerFile structure /*{{{*/
467/** \brief associates a version with a PackageFile
468
469 This allows a full description of all Versions in all files
470 (and hence all sources) under consideration. */
471struct pkgCache::VerFile
dcb79bae 472{
94449d7c 473 /** \brief index of the package file that this version was found in */
349cd3b8 474 map_ptrloc File; // PackageFile
94449d7c 475 /** \brief next step in the linked list */
349cd3b8 476 map_ptrloc NextFile; // PkgVerFile
94449d7c 477 /** \brief position in the package file */
349cd3b8 478 map_ptrloc Offset; // File offset
255c9e4b 479 /** @TODO document pkgCache::VerFile::Size */
6d3176fb 480 unsigned long Size;
dcb79bae 481};
92fcbfc1 482 /*}}}*/
94449d7c
DK
483// DescFile structure /*{{{*/
484/** \brief associates a description with a Translation file */
485struct pkgCache::DescFile
a52f938b 486{
94449d7c 487 /** \brief index of the file that this description was found in */
a52f938b 488 map_ptrloc File; // PackageFile
94449d7c 489 /** \brief next step in the linked list */
a52f938b 490 map_ptrloc NextFile; // PkgVerFile
94449d7c 491 /** \brief position in the file */
a52f938b 492 map_ptrloc Offset; // File offset
255c9e4b 493 /** @TODO document pkgCache::DescFile::Size */
6d3176fb 494 unsigned long Size;
a52f938b 495};
92fcbfc1 496 /*}}}*/
94449d7c
DK
497// Version structure /*{{{*/
498/** \brief information for a single version of a package
499
500 The version list is always sorted from highest version to lowest
501 version by the generator. Equal version numbers are either merged
502 or handled as separate versions based on the Hash value. */
503struct pkgCache::Version
578bfd0a 504{
94449d7c
DK
505 /** \brief complete version string */
506 map_ptrloc VerStr; // StringItem
507 /** \brief section this version is filled in */
508 map_ptrloc Section; // StringItem
894d672e
DK
509
510 /** \brief Multi-Arch capabilities of a package version */
511 enum VerMultiArch { None = 0, /*!< is the default and doesn't trigger special behaviour */
512 All = (1<<0), /*!< will cause that Ver.Arch() will report "all" */
513 Foreign = (1<<1), /*!< can satisfy dependencies in another architecture */
514 Same = (1<<2), /*!< can be co-installed with itself from other architectures */
00b6a181
DK
515 Allowed = (1<<3), /*!< other packages are allowed to depend on thispkg:any */
516 AllForeign = All | Foreign,
517 AllAllowed = All | Allowed };
94449d7c
DK
518 /** \brief stores the MultiArch capabilities of this version
519
894d672e
DK
520 Flags used are defined in pkgCache::Version::VerMultiArch
521 */
522 unsigned char MultiArch;
25396fb0 523
94449d7c
DK
524 /** \brief references all the PackageFile's that this version came from
525
526 FileList can be used to determine what distribution(s) the Version
527 applies to. If FileList is 0 then this is a blank version.
528 The structure should also have a 0 in all other fields excluding
529 pkgCache::Version::VerStr and Possibly pkgCache::Version::NextVer. */
349cd3b8 530 map_ptrloc FileList; // VerFile
94449d7c 531 /** \brief next (lower or equal) version in the linked list */
349cd3b8 532 map_ptrloc NextVer; // Version
94449d7c 533 /** \brief next description in the linked list */
a52f938b 534 map_ptrloc DescriptionList; // Description
94449d7c 535 /** \brief base of the dependency list */
349cd3b8 536 map_ptrloc DependsList; // Dependency
94449d7c
DK
537 /** \brief links to the owning package
538
539 This allows reverse dependencies to determine the package */
349cd3b8 540 map_ptrloc ParentPkg; // Package
94449d7c 541 /** \brief list of pkgCache::Provides */
349cd3b8 542 map_ptrloc ProvidesList; // Provides
94449d7c
DK
543
544 /** \brief archive size for this version
545
546 For Debian this is the size of the .deb file. */
e2c66de5 547 unsigned long long Size; // These are the .deb size
94449d7c 548 /** \brief uncompressed size for this version */
e2c66de5 549 unsigned long long InstalledSize;
94449d7c
DK
550 /** \brief characteristic value representing this version
551
552 No two packages in existence should have the same VerStr
553 and Hash with different contents. */
204fbdcc 554 unsigned short Hash;
94449d7c 555 /** \brief unique sequel ID */
09fab244 556 unsigned int ID;
94449d7c 557 /** \brief parsed priority value */
578bfd0a
AL
558 unsigned char Priority;
559};
92fcbfc1 560 /*}}}*/
94449d7c
DK
561// Description structure /*{{{*/
562/** \brief datamember of a linked list of available description for a version */
563struct pkgCache::Description
a52f938b 564{
94449d7c
DK
565 /** \brief Language code of this description (translation)
566
567 If the value has a 0 length then this is read using the Package
568 file else the Translation-CODE file is used. */
569 map_ptrloc language_code; // StringItem
570 /** \brief MD5sum of the original description
571
572 Used to map Translations of a description to a version
573 and to check that the Translation is up-to-date. */
574 map_ptrloc md5sum; // StringItem
a52f938b 575
255c9e4b 576 /** @TODO document pkgCache::Description::FileList */
a52f938b 577 map_ptrloc FileList; // DescFile
94449d7c 578 /** \brief next translation for this description */
a52f938b 579 map_ptrloc NextDesc; // Description
94449d7c 580 /** \brief the text is a description of this package */
a52f938b
OS
581 map_ptrloc ParentPkg; // Package
582
94449d7c 583 /** \brief unique sequel ID */
09fab244 584 unsigned int ID;
a52f938b 585};
92fcbfc1 586 /*}}}*/
94449d7c
DK
587// Dependency structure /*{{{*/
588/** \brief information for a single dependency record
589
590 The records are split up like this to ease processing by the client.
591 The base of the linked list is pkgCache::Version::DependsList.
592 All forms of dependencies are recorded here including Depends,
593 Recommends, Suggests, Enhances, Conflicts, Replaces and Breaks. */
594struct pkgCache::Dependency
578bfd0a 595{
94449d7c
DK
596 /** \brief string of the version the dependency is applied against */
597 map_ptrloc Version; // StringItem
598 /** \brief index of the package this depends applies to
599
600 The generator will - if the package does not already exist -
601 create a blank (no version records) package. */
349cd3b8 602 map_ptrloc Package; // Package
94449d7c 603 /** \brief next dependency of this version */
349cd3b8 604 map_ptrloc NextDepends; // Dependency
94449d7c 605 /** \brief next reverse dependency of this package */
349cd3b8 606 map_ptrloc NextRevDepends; // Dependency
94449d7c 607 /** \brief version of the package which has the reverse depends */
349cd3b8 608 map_ptrloc ParentVer; // Version
94449d7c
DK
609
610 /** \brief unique sequel ID */
611 map_ptrloc ID;
612 /** \brief Dependency type - Depends, Recommends, Conflicts, etc */
578bfd0a 613 unsigned char Type;
94449d7c
DK
614 /** \brief comparison operator specified on the depends line
615
616 If the high bit is set then it is a logical OR with the previous record. */
578bfd0a 617 unsigned char CompareOp;
578bfd0a 618};
92fcbfc1 619 /*}}}*/
94449d7c
DK
620// Provides structure /*{{{*/
621/** \brief handles virtual packages
622
623 When a Provides: line is encountered a new provides record is added
624 associating the package with a virtual package name.
625 The provides structures are linked off the package structures.
626 This simplifies the analysis of dependencies and other aspects A provides
627 refers to a specific version of a specific package, not all versions need to
628 provide that provides.*/
629struct pkgCache::Provides
578bfd0a 630{
94449d7c
DK
631 /** \brief index of the package providing this */
632 map_ptrloc ParentPkg; // Package
633 /** \brief index of the version this provide line applies to */
349cd3b8 634 map_ptrloc Version; // Version
94449d7c
DK
635 /** \brief version in the provides line (if any)
636
637 This version allows dependencies to depend on specific versions of a
638 Provides, as well as allowing Provides to override existing packages.
639 This is experimental. Note that Debian doesn't allow versioned provides */
640 map_ptrloc ProvideVersion; // StringItem
641 /** \brief next provides (based of package) */
349cd3b8 642 map_ptrloc NextProvides; // Provides
94449d7c 643 /** \brief next provides (based of version) */
349cd3b8 644 map_ptrloc NextPkgProv; // Provides
578bfd0a 645};
92fcbfc1 646 /*}}}*/
94449d7c
DK
647// StringItem structure /*{{{*/
648/** \brief used for generating single instances of strings
649
650 Some things like Section Name are are useful to have as unique tags.
651 It is part of a linked list based at pkgCache::Header::StringList
652
653 All strings are simply inlined any place in the file that is natural
654 for the writer. The client should make no assumptions about the positioning
655 of strings. All StringItems should be null-terminated. */
656struct pkgCache::StringItem
578bfd0a 657{
94449d7c
DK
658 /** \brief string this refers to */
659 map_ptrloc String; // StringItem
660 /** \brief Next link in the chain */
349cd3b8 661 map_ptrloc NextItem; // StringItem
578bfd0a 662};
92fcbfc1 663 /*}}}*/
959470da
DK
664
665
d64e130a 666inline char const * pkgCache::NativeArch()
d3e8fbb3 667 { return StrP + HeaderP->Architecture; }
959470da 668
094a497d 669#include <apt-pkg/cacheiterators.h>
578bfd0a 670
d3e8fbb3
DK
671inline pkgCache::GrpIterator pkgCache::GrpBegin()
672 {return GrpIterator(*this);}
673inline pkgCache::GrpIterator pkgCache::GrpEnd()
674 {return GrpIterator(*this,GrpP);}
675inline pkgCache::PkgIterator pkgCache::PkgBegin()
676 {return PkgIterator(*this);}
677inline pkgCache::PkgIterator pkgCache::PkgEnd()
678 {return PkgIterator(*this,PkgP);}
ad00ae81 679inline pkgCache::PkgFileIterator pkgCache::FileBegin()
d3e8fbb3 680 {return PkgFileIterator(*this,PkgFileP + HeaderP->FileList);}
ad00ae81 681inline pkgCache::PkgFileIterator pkgCache::FileEnd()
d3e8fbb3 682 {return PkgFileIterator(*this,PkgFileP);}
578bfd0a 683
b2e465d6 684// Oh I wish for Real Name Space Support
92fcbfc1 685class pkgCache::Namespace /*{{{*/
d3e8fbb3 686{
b2e465d6 687 public:
803ea2a8 688 typedef pkgCache::GrpIterator GrpIterator;
b2e465d6
AL
689 typedef pkgCache::PkgIterator PkgIterator;
690 typedef pkgCache::VerIterator VerIterator;
a52f938b 691 typedef pkgCache::DescIterator DescIterator;
b2e465d6
AL
692 typedef pkgCache::DepIterator DepIterator;
693 typedef pkgCache::PrvIterator PrvIterator;
694 typedef pkgCache::PkgFileIterator PkgFileIterator;
d3e8fbb3 695 typedef pkgCache::VerFileIterator VerFileIterator;
b2e465d6 696 typedef pkgCache::Version Version;
a52f938b 697 typedef pkgCache::Description Description;
b2e465d6
AL
698 typedef pkgCache::Package Package;
699 typedef pkgCache::Header Header;
700 typedef pkgCache::Dep Dep;
701 typedef pkgCache::Flag Flag;
702};
92fcbfc1 703 /*}}}*/
578bfd0a 704#endif