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