1 // -*- mode: cpp; mode: fold -*-
3 // $Id: pkgcache.h,v 1.1 1998/07/02 02:58:12 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>
27 // Definitions for Depends::Type
28 #define pkgDEP_Depends 1
29 #define pkgDEP_PreDepends 2
30 #define pkgDEP_Suggests 3
31 #define pkgDEP_Recommends 4
32 #define pkgDEP_Conflicts 5
33 #define pkgDEP_Replaces 6
35 // Definitions for Version::Priority
36 #define pkgPRIO_Important 1
37 #define pkgPRIO_Required 2
38 #define pkgPRIO_Standard 3
39 #define pkgPRIO_Optional 4
40 #define pkgPRIO_Extra 5
42 // Definitions for Package::SelectedState
43 #define pkgSTATE_Unkown 0
44 #define pkgSTATE_Install 1
45 #define pkgSTATE_Hold 2
46 #define pkgSTATE_DeInstall 3
47 #define pkgSTATE_Purge 4
49 // Definitions for Package::Flags
50 #define pkgFLAG_Auto (1 << 0)
51 #define pkgFLAG_New (1 << 1)
52 #define pkgFLAG_Obsolete (1 << 2)
53 #define pkgFLAG_Essential (1 << 3)
54 #define pkgFLAG_ImmediateConf (1 << 4)
56 // Definitions for Package::InstState
58 #define pkgSTATE_ReInstReq 1
59 #define pkgSTATE_Hold 2
60 #define pkgSTATE_HoldReInstReq 3
62 // Definitions for Package::CurrentState
63 #define pkgSTATE_NotInstalled 0
64 #define pkgSTATE_UnPacked 1
65 #define pkgSTATE_HalfConfigured 2
66 #define pkgSTATE_UnInstalled 3
67 #define pkgSTATE_HalfInstalled 4
68 #define pkgSTATE_ConfigFiles 5
69 #define pkgSTATE_Installed 6
71 // Definitions for PackageFile::Flags
72 #define pkgFLAG_NotSource (1 << 0)
74 // Definitions for Dependency::CompareOp
76 #define pkgOP_LESSEQ 0x1
77 #define pkgOP_GREATEREQ 0x2
78 #define pkgOP_LESS 0x3
79 #define pkgOP_GREATER 0x4
80 #define pkgOP_EQUALS 0x5
81 #define pkgOP_NOTEQUALS 0x6
86 // Cache element predeclarations
100 class PkgFileIterator
;
105 friend PkgFileIterator
;
109 // Memory mapped cache file
116 static unsigned long sHash(string S
);
117 static unsigned long sHash(const char *S
);
121 // Pointers to the arrays of items
124 PackageFile
*PkgFileP
;
128 StringItem
*StringItemP
;
131 virtual bool ReMap();
132 inline bool Sync() {return Map
.Sync();};
134 // String hashing function (512 range)
135 inline unsigned long Hash(string S
) const {return sHash(S
);};
136 inline unsigned long Hash(const char *S
) const {return sHash(S
);};
139 PkgIterator
FindPkg(string Name
);
140 Header
&Head() {return *HeaderP
;};
141 inline PkgIterator
PkgBegin();
142 inline PkgIterator
PkgEnd();
145 virtual ~pkgCache() {};
149 struct pkgCache::Header
151 // Signature information
152 unsigned long Signature
;
157 // Size of structure values
158 unsigned short HeaderSz
;
159 unsigned short PackageSz
;
160 unsigned short PackageFileSz
;
161 unsigned short VersionSz
;
162 unsigned short DependencySz
;
163 unsigned short ProvidesSz
;
166 unsigned long PackageCount
;
167 unsigned long VersionCount
;
168 unsigned long DependsCount
;
169 unsigned long PackageFileCount
;
172 unsigned long FileList
; // struct PackageFile
173 unsigned long StringList
; // struct StringItem
175 /* Allocation pools, there should be one of these for each structure
176 excluding the header */
177 DynamicMMap::Pool Pools
[6];
179 // Rapid package name lookup
180 unsigned long HashTable
[512];
182 bool CheckSizes(Header
&Against
) const;
186 struct pkgCache::Package
189 unsigned long Name
; // Stringtable
190 unsigned long VersionList
; // Version
191 unsigned long TargetVer
; // Version
192 unsigned long CurrentVer
; // Version
193 unsigned long TargetDist
; // StringTable (StringItem)
194 unsigned long Section
; // StringTable (StringItem)
197 unsigned long NextPackage
; // Package
198 unsigned long RevDepends
; // Dependency
199 unsigned long ProvidesList
; // Provides
201 // Install/Remove/Purge etc
202 unsigned char SelectedState
; // What
203 unsigned char InstState
; // Flags
204 unsigned char CurrentState
; // State
207 unsigned short Flags
;
210 struct pkgCache::PackageFile
213 unsigned long FileName
; // Stringtable
214 unsigned long Version
; // Stringtable
215 unsigned long Distribution
; // Stringtable
219 unsigned long NextFile
; // PackageFile
221 unsigned short Flags
;
222 time_t mtime
; // Modification time for the file
225 struct pkgCache::Version
227 unsigned long VerStr
; // Stringtable
228 unsigned long File
; // PackageFile
229 unsigned long Section
; // StringTable (StringItem)
232 unsigned long NextVer
; // Version
233 unsigned long DependsList
; // Dependency
234 unsigned long ParentPkg
; // Package
235 unsigned long ProvidesList
; // Provides
237 unsigned long Offset
;
239 unsigned long InstalledSize
;
241 unsigned char Priority
;
244 struct pkgCache::Dependency
246 unsigned long Version
; // Stringtable
247 unsigned long Package
; // Package
248 unsigned long NextDepends
; // Dependency
249 unsigned long NextRevDepends
; // Dependency
250 unsigned long ParentVer
; // Version
252 // Specific types of depends
254 unsigned char CompareOp
;
258 struct pkgCache::Provides
260 unsigned long ParentPkg
; // Pacakge
261 unsigned long Version
; // Version
262 unsigned long ProvideVersion
; // Stringtable
263 unsigned long NextProvides
; // Provides
264 unsigned long NextPkgProv
; // Provides
267 struct pkgCache::StringItem
269 unsigned long String
; // Stringtable
270 unsigned long NextItem
; // StringItem
273 #include <pkglib/cacheiterators.h>
275 inline pkgCache::PkgIterator
pkgCache::PkgBegin()
276 {return PkgIterator(*this);};
277 inline pkgCache::PkgIterator
pkgCache::PkgEnd()
278 {return PkgIterator(*this,PkgP
);};