]>
git.saurik.com Git - apt.git/blob - apt-pkg/pkgcache.h
c8fe3a8deedb7ebe29108d608fed1cea36caeb77
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: pkgcache.h,v 1.2 1998/07/04 05:57:36 jgg Exp $
4 /* ######################################################################
6 Cache - Structure definitions for the cache file
8 Please see doc/pkglib/cache.sgml for a more detailed description of
9 this format. Also be sure to keep that file up-to-date!!
11 Clients should always use the CacheIterators classes for access to the
12 cache. They provide a simple STL-like method for traversing the links
15 See pkgcachegen.h for information about generating cache structures.
17 ##################################################################### */
19 // Header section: pkglib
20 #ifndef PKGLIB_PKGCACHE_H
21 #define PKGLIB_PKGCACHE_H
25 #include <pkglib/mmap.h>
30 // Cache element predeclarations
44 class PkgFileIterator
;
49 friend PkgFileIterator
;
51 // These are all the constants used in the cache structures
52 enum DepType
{Depends
=1,PreDepends
=2,Suggests
=3,Recommends
=4,
53 Conflicts
=5,Replaces
=6};
54 enum VerPriority
{Important
=1,Required
=2,Standard
=3,Optional
=5,Extra
=5};
55 enum PkgSelectedState
{Unknown
=0,Install
=1,Hold
=2,DeInstall
=3,Purge
=4};
56 enum PkgFlags
{Auto
=(1<<0),New
=(1<<1),Obsolete
=(1<<2),Essential
=(1<<3),
57 ImmediateConf
=(1<<4)};
58 enum PkgInstState
{Ok
=0,ReInstReq
=1,HoldInst
=2,HoldReInstReq
=3};
59 enum PkgCurrentState
{NotInstalled
=0,UnPacked
=1,HalfConfigured
=2,
60 UnInstalled
=3,HalfInstalled
=4,ConfigFiles
=5,
62 enum PkgFFlags
{NotSource
=(1<<0)};
63 enum DepCompareOp
{Or
=0x10,LessEq
=0x1,GreaterEq
=0x2,Less
=0x3,
64 Greater
=0x4,Equals
=0x5,NotEquals
=0x6};
68 // Memory mapped cache file
75 static unsigned long sHash(string S
);
76 static unsigned long sHash(const char *S
);
80 // Pointers to the arrays of items
83 PackageFile
*PkgFileP
;
87 StringItem
*StringItemP
;
91 inline bool Sync() {return Map
.Sync();};
93 // String hashing function (512 range)
94 inline unsigned long Hash(string S
) const {return sHash(S
);};
95 inline unsigned long Hash(const char *S
) const {return sHash(S
);};
98 PkgIterator
FindPkg(string Name
);
99 Header
&Head() {return *HeaderP
;};
100 inline PkgIterator
PkgBegin();
101 inline PkgIterator
PkgEnd();
104 virtual ~pkgCache() {};
108 struct pkgCache::Header
110 // Signature information
111 unsigned long Signature
;
116 // Size of structure values
117 unsigned short HeaderSz
;
118 unsigned short PackageSz
;
119 unsigned short PackageFileSz
;
120 unsigned short VersionSz
;
121 unsigned short DependencySz
;
122 unsigned short ProvidesSz
;
125 unsigned long PackageCount
;
126 unsigned long VersionCount
;
127 unsigned long DependsCount
;
128 unsigned long PackageFileCount
;
131 unsigned long FileList
; // struct PackageFile
132 unsigned long StringList
; // struct StringItem
134 /* Allocation pools, there should be one of these for each structure
135 excluding the header */
136 DynamicMMap::Pool Pools
[6];
138 // Rapid package name lookup
139 unsigned long HashTable
[512];
141 bool CheckSizes(Header
&Against
) const;
145 struct pkgCache::Package
148 unsigned long Name
; // Stringtable
149 unsigned long VersionList
; // Version
150 unsigned long TargetVer
; // Version
151 unsigned long CurrentVer
; // Version
152 unsigned long TargetDist
; // StringTable (StringItem)
153 unsigned long Section
; // StringTable (StringItem)
156 unsigned long NextPackage
; // Package
157 unsigned long RevDepends
; // Dependency
158 unsigned long ProvidesList
; // Provides
160 // Install/Remove/Purge etc
161 unsigned char SelectedState
; // What
162 unsigned char InstState
; // Flags
163 unsigned char CurrentState
; // State
169 struct pkgCache::PackageFile
172 unsigned long FileName
; // Stringtable
173 unsigned long Version
; // Stringtable
174 unsigned long Distribution
; // Stringtable
178 unsigned long NextFile
; // PackageFile
181 time_t mtime
; // Modification time for the file
184 struct pkgCache::Version
186 unsigned long VerStr
; // Stringtable
187 unsigned long File
; // PackageFile
188 unsigned long Section
; // StringTable (StringItem)
191 unsigned long NextVer
; // Version
192 unsigned long DependsList
; // Dependency
193 unsigned long ParentPkg
; // Package
194 unsigned long ProvidesList
; // Provides
196 unsigned long Offset
;
198 unsigned long InstalledSize
;
200 unsigned char Priority
;
203 struct pkgCache::Dependency
205 unsigned long Version
; // Stringtable
206 unsigned long Package
; // Package
207 unsigned long NextDepends
; // Dependency
208 unsigned long NextRevDepends
; // Dependency
209 unsigned long ParentVer
; // Version
211 // Specific types of depends
213 unsigned char CompareOp
;
217 struct pkgCache::Provides
219 unsigned long ParentPkg
; // Pacakge
220 unsigned long Version
; // Version
221 unsigned long ProvideVersion
; // Stringtable
222 unsigned long NextProvides
; // Provides
223 unsigned long NextPkgProv
; // Provides
226 struct pkgCache::StringItem
228 unsigned long String
; // Stringtable
229 unsigned long NextItem
; // StringItem
232 #include <pkglib/cacheiterators.h>
234 inline pkgCache::PkgIterator
pkgCache::PkgBegin()
235 {return PkgIterator(*this);};
236 inline pkgCache::PkgIterator
pkgCache::PkgEnd()
237 {return PkgIterator(*this,PkgP
);};