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