| acquire-item.h | | acquire-item.h | |
| | | | |
| skipping to change at line 30 | | skipping to change at line 30 | |
| #ifndef PKGLIB_ACQUIRE_ITEM_H | | #ifndef PKGLIB_ACQUIRE_ITEM_H | |
| #define PKGLIB_ACQUIRE_ITEM_H | | #define PKGLIB_ACQUIRE_ITEM_H | |
| | | | |
| #include <apt-pkg/acquire.h> | | #include <apt-pkg/acquire.h> | |
| #include <apt-pkg/indexfile.h> | | #include <apt-pkg/indexfile.h> | |
| #include <apt-pkg/vendor.h> | | #include <apt-pkg/vendor.h> | |
| #include <apt-pkg/sourcelist.h> | | #include <apt-pkg/sourcelist.h> | |
| #include <apt-pkg/pkgrecords.h> | | #include <apt-pkg/pkgrecords.h> | |
| #include <apt-pkg/indexrecords.h> | | #include <apt-pkg/indexrecords.h> | |
| #include <apt-pkg/hashes.h> | | #include <apt-pkg/hashes.h> | |
|
| | | #include <apt-pkg/weakptr.h> | |
| | | | |
| /** \addtogroup acquire | | /** \addtogroup acquire | |
| * @{ | | * @{ | |
| * | | * | |
| * \file acquire-item.h | | * \file acquire-item.h | |
| */ | | */ | |
| | | | |
| /** \brief Represents the process by which a pkgAcquire object should {{{ | | /** \brief Represents the process by which a pkgAcquire object should {{{ | |
| * retrieve a file or a collection of files. | | * retrieve a file or a collection of files. | |
| * | | * | |
| * By convention, Item subclasses should insert themselves into the | | * By convention, Item subclasses should insert themselves into the | |
| * acquire queue when they are created by calling QueueURI(), and | | * acquire queue when they are created by calling QueueURI(), and | |
| * remove themselves by calling Dequeue() when either Done() or | | * remove themselves by calling Dequeue() when either Done() or | |
| * Failed() is invoked. Item objects are also responsible for | | * Failed() is invoked. Item objects are also responsible for | |
| * notifying the download progress indicator (accessible via | | * notifying the download progress indicator (accessible via | |
| * #Owner->Log) of their status. | | * #Owner->Log) of their status. | |
| * | | * | |
| * \see pkgAcquire | | * \see pkgAcquire | |
| */ | | */ | |
|
| class pkgAcquire::Item | | class pkgAcquire::Item : public WeakPointable | |
| { | | { | |
| protected: | | protected: | |
| | | | |
| /** \brief The acquire object with which this item is associated. */ | | /** \brief The acquire object with which this item is associated. */ | |
| pkgAcquire *Owner; | | pkgAcquire *Owner; | |
| | | | |
| /** \brief Insert this item into its owner's queue. | | /** \brief Insert this item into its owner's queue. | |
| * | | * | |
| * \param ItemDesc Metadata about this item (its URI and | | * \param ItemDesc Metadata about this item (its URI and | |
| * description). | | * description). | |
| | | | |
| skipping to change at line 114 | | skipping to change at line 115 | |
| */ | | */ | |
| StatTransientNetworkError | | StatTransientNetworkError | |
| } Status; | | } Status; | |
| | | | |
| /** \brief Contains a textual description of the error encountered | | /** \brief Contains a textual description of the error encountered | |
| * if #Status is #StatError or #StatAuthError. | | * if #Status is #StatError or #StatAuthError. | |
| */ | | */ | |
| string ErrorText; | | string ErrorText; | |
| | | | |
| /** \brief The size of the object to fetch. */ | | /** \brief The size of the object to fetch. */ | |
|
| unsigned long FileSize; | | unsigned long long FileSize; | |
| | | | |
| /** \brief How much of the object was already fetched. */ | | /** \brief How much of the object was already fetched. */ | |
|
| unsigned long PartialSize; | | unsigned long long PartialSize; | |
| | | | |
| /** \brief If not \b NULL, contains the name of a subprocess that | | /** \brief If not \b NULL, contains the name of a subprocess that | |
| * is operating on this object (for instance, "gzip" or "gpgv"). | | * is operating on this object (for instance, "gzip" or "gpgv"). | |
| */ | | */ | |
| const char *Mode; | | const char *Mode; | |
| | | | |
| /** \brief A client-supplied unique identifier. | | /** \brief A client-supplied unique identifier. | |
| * | | * | |
| * This field is initalized to 0; it is meant to be filled in by | | * This field is initalized to 0; it is meant to be filled in by | |
| * clients that wish to use it to uniquely identify items. | | * clients that wish to use it to uniquely identify items. | |
| | | | |
| skipping to change at line 145 | | skipping to change at line 146 | |
| * Subclasses should set this to \b true when appropriate. | | * Subclasses should set this to \b true when appropriate. | |
| */ | | */ | |
| bool Complete; | | bool Complete; | |
| | | | |
| /** \brief If \b true, the URI of this object is "local". | | /** \brief If \b true, the URI of this object is "local". | |
| * | | * | |
| * The only effect of this field is to exclude the object from the | | * The only effect of this field is to exclude the object from the | |
| * download progress indicator's overall statistics. | | * download progress indicator's overall statistics. | |
| */ | | */ | |
| bool Local; | | bool Local; | |
|
| | | string UsedMirror; | |
| | | | |
| /** \brief The number of fetch queues into which this item has been | | /** \brief The number of fetch queues into which this item has been | |
| * inserted. | | * inserted. | |
| * | | * | |
| * There is one queue for each source from which an item could be | | * There is one queue for each source from which an item could be | |
| * downloaded. | | * downloaded. | |
| * | | * | |
| * \sa pkgAcquire | | * \sa pkgAcquire | |
| */ | | */ | |
| unsigned int QueueCounter; | | unsigned int QueueCounter; | |
| | | | |
| skipping to change at line 246 | | skipping to change at line 248 | |
| * empty string. | | * empty string. | |
| */ | | */ | |
| virtual string HashSum() {return string();}; | | virtual string HashSum() {return string();}; | |
| | | | |
| /** \return the acquire process with which this item is associated. */ | | /** \return the acquire process with which this item is associated. */ | |
| pkgAcquire *GetOwner() {return Owner;}; | | pkgAcquire *GetOwner() {return Owner;}; | |
| | | | |
| /** \return \b true if this object is being fetched from a trusted sourc
e. */ | | /** \return \b true if this object is being fetched from a trusted sourc
e. */ | |
| virtual bool IsTrusted() {return false;}; | | virtual bool IsTrusted() {return false;}; | |
| | | | |
|
| | | // report mirror problems | |
| | | /** \brief Report mirror problem | |
| | | * | |
| | | * This allows reporting mirror failures back to a centralized | |
| | | * server. The apt-report-mirror-failure script is called for this | |
| | | * | |
| | | * \param FailCode A short failure string that is send | |
| | | */ | |
| | | void ReportMirrorFailure(string FailCode); | |
| | | | |
| /** \brief Initialize an item. | | /** \brief Initialize an item. | |
| * | | * | |
| * Adds the item to the list of items known to the acquire | | * Adds the item to the list of items known to the acquire | |
| * process, but does not place it into any fetch queues (you must | | * process, but does not place it into any fetch queues (you must | |
| * manually invoke QueueURI() to do so). | | * manually invoke QueueURI() to do so). | |
| * | | * | |
| * Initializes all fields of the item other than Owner to 0, | | * Initializes all fields of the item other than Owner to 0, | |
| * false, or the empty string. | | * false, or the empty string. | |
| * | | * | |
| * \param Owner The new owner of this item. | | * \param Owner The new owner of this item. | |
| | | | |
| skipping to change at line 424 | | skipping to change at line 436 | |
| | | | |
| /** The patches that remain to be downloaded, including the patch | | /** The patches that remain to be downloaded, including the patch | |
| * being downloaded right now. This list should be ordered so | | * being downloaded right now. This list should be ordered so | |
| * that each diff appears before any diff that depends on it. | | * that each diff appears before any diff that depends on it. | |
| * | | * | |
| * \todo These are indexed by sha1sum; why not use some sort of | | * \todo These are indexed by sha1sum; why not use some sort of | |
| * dictionary instead of relying on ordering and stripping them | | * dictionary instead of relying on ordering and stripping them | |
| * off the front? | | * off the front? | |
| */ | | */ | |
| vector<DiffInfo> available_patches; | | vector<DiffInfo> available_patches; | |
|
| | | | |
| | | /** Stop applying patches when reaching that sha1 */ | |
| | | string ServerSha1; | |
| | | | |
| /** The current status of this patch. */ | | /** The current status of this patch. */ | |
| enum DiffState | | enum DiffState | |
| { | | { | |
| /** \brief The diff is in an unknown state. */ | | /** \brief The diff is in an unknown state. */ | |
| StateFetchUnkown, | | StateFetchUnkown, | |
| | | | |
| /** \brief The diff is currently being fetched. */ | | /** \brief The diff is currently being fetched. */ | |
| StateFetchDiff, | | StateFetchDiff, | |
| | | | |
| /** \brief The diff is currently being uncompressed. */ | | /** \brief The diff is currently being uncompressed. */ | |
| | | | |
| skipping to change at line 477 | | skipping to change at line 493 | |
| * \param ExpectedHash The expected md5sum of the completely | | * \param ExpectedHash The expected md5sum of the completely | |
| * reconstructed package index file; the index file will be tested | | * reconstructed package index file; the index file will be tested | |
| * against this value when it is entirely reconstructed. | | * against this value when it is entirely reconstructed. | |
| * | | * | |
| * \param diffs The remaining diffs from the index of diffs. They | | * \param diffs The remaining diffs from the index of diffs. They | |
| * should be ordered so that each diff appears before any diff | | * should be ordered so that each diff appears before any diff | |
| * that depends on it. | | * that depends on it. | |
| */ | | */ | |
| pkgAcqIndexDiffs(pkgAcquire *Owner,string URI,string URIDesc, | | pkgAcqIndexDiffs(pkgAcquire *Owner,string URI,string URIDesc, | |
| string ShortDesc, HashString ExpectedHash, | | string ShortDesc, HashString ExpectedHash, | |
|
| | | string ServerSha1, | |
| vector<DiffInfo> diffs=vector<DiffInfo>()); | | vector<DiffInfo> diffs=vector<DiffInfo>()); | |
| }; | | }; | |
| /*}}
}*/ | | /*}}
}*/ | |
| /** \brief An acquire item that is responsible for fetching an index {{{ | | /** \brief An acquire item that is responsible for fetching an index {{{ | |
| * file (e.g., Packages or Sources). | | * file (e.g., Packages or Sources). | |
| * | | * | |
| * \sa pkgAcqDiffIndex, pkgAcqIndexDiffs, pkgAcqIndexTrans | | * \sa pkgAcqDiffIndex, pkgAcqIndexDiffs, pkgAcqIndexTrans | |
| * | | * | |
| * \todo Why does pkgAcqIndex have protected members? | | * \todo Why does pkgAcqIndex have protected members? | |
| */ | | */ | |
| | | | |
| skipping to change at line 547 | | skipping to change at line 564 | |
| * | | * | |
| * \param ExpectedHash The expected hashsum of this index file. | | * \param ExpectedHash The expected hashsum of this index file. | |
| * | | * | |
| * \param compressExt The compression-related extension with which | | * \param compressExt The compression-related extension with which | |
| * this index file should be downloaded, or "" to autodetect | | * this index file should be downloaded, or "" to autodetect | |
| * Compression types can be set with config Acquire::CompressionTypes, | | * Compression types can be set with config Acquire::CompressionTypes, | |
| * default is ".lzma" or ".bz2" (if the needed binaries are present) | | * default is ".lzma" or ".bz2" (if the needed binaries are present) | |
| * fallback is ".gz" or none. | | * fallback is ".gz" or none. | |
| */ | | */ | |
| pkgAcqIndex(pkgAcquire *Owner,string URI,string URIDesc, | | pkgAcqIndex(pkgAcquire *Owner,string URI,string URIDesc, | |
|
| string ShortDesc, HashString ExpectedHash, string compressExt | | string ShortDesc, HashString ExpectedHash, | |
| =""); | | string compressExt=""); | |
| }; | | }; | |
| /*}}
}*/ | | /*}}
}*/ | |
| /** \brief An acquire item that is responsible for fetching a {{{ | | /** \brief An acquire item that is responsible for fetching a {{{ | |
| * translated index file. | | * translated index file. | |
| * | | * | |
| * The only difference from pkgAcqIndex is that transient failures | | * The only difference from pkgAcqIndex is that transient failures | |
| * are suppressed: no error occurs if the translated index file is | | * are suppressed: no error occurs if the translated index file is | |
| * missing. | | * missing. | |
| */ | | */ | |
| class pkgAcqIndexTrans : public pkgAcqIndex | | class pkgAcqIndexTrans : public pkgAcqIndex | |
| { | | { | |
| public: | | public: | |
| | | | |
| virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); | | virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); | |
|
| | | virtual string Custom600Headers(); | |
| | | | |
| /** \brief Create a pkgAcqIndexTrans. | | /** \brief Create a pkgAcqIndexTrans. | |
| * | | * | |
| * \param Owner The pkgAcquire object with which this item is | | * \param Owner The pkgAcquire object with which this item is | |
| * associated. | | * associated. | |
| * | | * | |
| * \param URI The URI of the index file that is to be downloaded. | | * \param URI The URI of the index file that is to be downloaded. | |
| * | | * | |
| * \param URIDesc A "URI-style" description of this index file. | | * \param URIDesc A "URI-style" description of this index file. | |
| * | | * | |
| | | | |
| skipping to change at line 857 | | skipping to change at line 876 | |
| pkgAcquire::ItemDesc Desc; | | pkgAcquire::ItemDesc Desc; | |
| | | | |
| /** \brief The hashsum of the file to download, if it is known. */ | | /** \brief The hashsum of the file to download, if it is known. */ | |
| HashString ExpectedHash; | | HashString ExpectedHash; | |
| | | | |
| /** \brief How many times to retry the download, set from | | /** \brief How many times to retry the download, set from | |
| * Acquire::Retries. | | * Acquire::Retries. | |
| */ | | */ | |
| unsigned int Retries; | | unsigned int Retries; | |
| | | | |
|
| | | /** \brief Should this file be considered a index file */ | |
| | | bool IsIndexFile; | |
| | | | |
| public: | | public: | |
| | | | |
| // Specialized action members | | // Specialized action members | |
| virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); | | virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); | |
| virtual void Done(string Message,unsigned long Size,string CalcHash, | | virtual void Done(string Message,unsigned long Size,string CalcHash, | |
| pkgAcquire::MethodConfig *Cnf); | | pkgAcquire::MethodConfig *Cnf); | |
| virtual string DescURI() {return Desc.URI;}; | | virtual string DescURI() {return Desc.URI;}; | |
| virtual string HashSum() {return ExpectedHash.toStr(); }; | | virtual string HashSum() {return ExpectedHash.toStr(); }; | |
|
| | | virtual string Custom600Headers(); | |
| | | | |
| /** \brief Create a new pkgAcqFile object. | | /** \brief Create a new pkgAcqFile object. | |
| * | | * | |
| * \param Owner The pkgAcquire object with which this object is | | * \param Owner The pkgAcquire object with which this object is | |
| * associated. | | * associated. | |
| * | | * | |
| * \param URI The URI to download. | | * \param URI The URI to download. | |
| * | | * | |
| * \param Hash The hashsum of the file to download, if it is known; | | * \param Hash The hashsum of the file to download, if it is known; | |
| * otherwise "". | | * otherwise "". | |
| | | | |
| skipping to change at line 888 | | skipping to change at line 911 | |
| * | | * | |
| * \param Desc A description of the file being downloaded. | | * \param Desc A description of the file being downloaded. | |
| * | | * | |
| * \param ShortDesc A brief description of the file being | | * \param ShortDesc A brief description of the file being | |
| * downloaded. | | * downloaded. | |
| * | | * | |
| * \param DestDir The directory the file should be downloaded into. | | * \param DestDir The directory the file should be downloaded into. | |
| * | | * | |
| * \param DestFilename The filename+path the file is downloaded to. | | * \param DestFilename The filename+path the file is downloaded to. | |
| * | | * | |
|
| | | * \param IsIndexFile The file is considered a IndexFile and cache-cont | |
| | | rol | |
| | | * headers like "cache-control: max-age=0" are send | |
| * | | * | |
| * If DestFilename is empty, download to DestDir/<basename> if | | * If DestFilename is empty, download to DestDir/<basename> if | |
| * DestDir is non-empty, $CWD/<basename> otherwise. If | | * DestDir is non-empty, $CWD/<basename> otherwise. If | |
| * DestFilename is NOT empty, DestDir is ignored and DestFilename | | * DestFilename is NOT empty, DestDir is ignored and DestFilename | |
| * is the absolute name to which the file should be downloaded. | | * is the absolute name to which the file should be downloaded. | |
| */ | | */ | |
| | | | |
| pkgAcqFile(pkgAcquire *Owner, string URI, string Hash, unsigned long Siz
e, | | pkgAcqFile(pkgAcquire *Owner, string URI, string Hash, unsigned long Siz
e, | |
| string Desc, string ShortDesc, | | string Desc, string ShortDesc, | |
|
| const string &DestDir="", const string &DestFilename=""); | | const string &DestDir="", const string &DestFilename="", | |
| | | bool IsIndexFile=false); | |
| }; | | }; | |
| /*}}
}*/ | | /*}}
}*/ | |
| /** @} */ | | /** @} */ | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 14 change blocks. |
| 6 lines changed or deleted | | 32 lines changed or added | |
|
| cacheiterators.h | | cacheiterators.h | |
| // -*- mode: cpp; mode: fold -*- | | // -*- mode: cpp; mode: fold -*- | |
| // Description /*{{
{*/ | | // Description /*{{
{*/ | |
|
| // $Id: cacheiterators.h,v 1.18.2.1 2004/05/08 22:44:27 mdz Exp $ | | | |
| /* ###################################################################### | | /* ###################################################################### | |
| | | | |
| Cache Iterators - Iterators for navigating the cache structure | | Cache Iterators - Iterators for navigating the cache structure | |
| | | | |
| The iterators all provides ++,==,!=,->,* and end for their type. | | The iterators all provides ++,==,!=,->,* and end for their type. | |
| The end function can be used to tell if the list has been fully | | The end function can be used to tell if the list has been fully | |
| traversed. | | traversed. | |
| | | | |
| Unlike STL iterators these contain helper functions to access the data | | Unlike STL iterators these contain helper functions to access the data | |
| that is being iterated over. This is because the data structures can't | | that is being iterated over. This is because the data structures can't | |
| | | | |
| skipping to change at line 33 | | skipping to change at line 32 | |
| structure passed to the constructor, which should be the structure | | structure passed to the constructor, which should be the structure | |
| that has the depends pointer as a member. The provide iterator has the | | that has the depends pointer as a member. The provide iterator has the | |
| same system. | | same system. | |
| | | | |
| This header is not user includable, please use apt-pkg/pkgcache.h | | This header is not user includable, please use apt-pkg/pkgcache.h | |
| | | | |
| ##################################################################### */ | | ##################################################################### */ | |
| /*}}
}*/ | | /*}}
}*/ | |
| #ifndef PKGLIB_CACHEITERATORS_H | | #ifndef PKGLIB_CACHEITERATORS_H | |
| #define PKGLIB_CACHEITERATORS_H | | #define PKGLIB_CACHEITERATORS_H | |
|
| | | #include<iterator> | |
| | | | |
|
| // Package Iterator /*{{ | | #include<string.h> | |
| {*/ | | // abstract Iterator template /*{{ | |
| class pkgCache::PkgIterator | | {*/ | |
| { | | /* This template provides the very basic iterator methods we | |
| friend class pkgCache; | | need to have for doing some walk-over-the-cache magic */ | |
| Package *Pkg; | | template<typename Str, typename Itr> class pkgCache::Iterator : | |
| pkgCache *Owner; | | public std::iterator<std::forward_iterator_tag, Str> | |
| long HashIndex; | | { | |
| | | protected: | |
| protected: | | Str *S; | |
| | | pkgCache *Owner; | |
| // This constructor is the 'begin' constructor, never use it. | | | |
| inline PkgIterator(pkgCache &Owner) : Owner(&Owner), HashIndex(-1) | | | |
| { | | | |
| Pkg = Owner.PkgP; | | | |
| operator ++(0); | | | |
| }; | | | |
| | | | |
| public: | | | |
| | | | |
| enum OkState {NeedsNothing,NeedsUnpack,NeedsConfigure}; | | | |
| | | | |
|
| // Iteration | | /** \brief Returns the Pointer for this struct in the owner | |
| void operator ++(int); | | * The implementation of this method should be pretty short | |
| inline void operator ++() {operator ++(0);}; | | * as it will only return the Pointer into the mmap stored | |
| inline bool end() const {return Owner == 0 || Pkg == Owner->PkgP?true:fa | | * in the owner but the name of this pointer is different for | |
| lse;}; | | * each stucture and we want to abstract here at least for the | |
| | | * basic methods from the actual structure. | |
| | | * \return Pointer to the first structure of this type | |
| | | */ | |
| | | virtual Str* OwnerPointer() const = 0; | |
| | | | |
|
| // Comparison | | public: | |
| inline bool operator ==(const PkgIterator &B) const {return Pkg == B.Pkg | | // Iteration | |
| ;}; | | virtual void operator ++(int) = 0; | |
| inline bool operator !=(const PkgIterator &B) const {return Pkg != B.Pkg | | virtual void operator ++() = 0; // Should be {operator ++(0);}; | |
| ;}; | | inline bool end() const {return Owner == 0 || S == OwnerPointer();}; | |
| | | | |
|
| // Accessors | | // Comparison | |
| inline Package *operator ->() {return Pkg;}; | | inline bool operator ==(const Itr &B) const {return S == B.S;}; | |
| inline Package const *operator ->() const {return Pkg;}; | | inline bool operator !=(const Itr &B) const {return S != B.S;}; | |
| inline Package const &operator *() const {return *Pkg;}; | | | |
| inline operator Package *() {return Pkg == Owner->PkgP?0:Pkg;}; | | | |
| inline operator Package const *() const {return Pkg == Owner->PkgP?0:Pkg | | | |
| ;}; | | | |
| inline pkgCache *Cache() {return Owner;}; | | | |
| | | | |
|
| inline const char *Name() const {return Pkg->Name == 0?0:Owner->StrP + P | | // Accessors | |
| kg->Name;}; | | inline Str *operator ->() {return S;}; | |
| inline const char *Section() const {return Pkg->Section == 0?0:Owner->St | | inline Str const *operator ->() const {return S;}; | |
| rP + Pkg->Section;}; | | inline operator Str *() {return S == OwnerPointer() ? 0 : S;}; | |
| inline bool Purge() const {return Pkg->CurrentState == pkgCache::State:: | | inline operator Str const *() const {return S == OwnerPointer() ? 0 | |
| Purge || | | : S;}; | |
| (Pkg->CurrentVer == 0 && Pkg->CurrentState == pkgCache::State::NotI | | inline Str &operator *() {return *S;}; | |
| nstalled);}; | | inline Str const &operator *() const {return *S;}; | |
| inline VerIterator VersionList() const; | | inline pkgCache *Cache() const {return Owner;}; | |
| inline VerIterator CurrentVer() const; | | | |
| inline DepIterator RevDependsList() const; | | | |
| inline PrvIterator ProvidesList() const; | | | |
| inline unsigned long Index() const {return Pkg - Owner->PkgP;}; | | | |
| OkState State() const; | | | |
| | | | |
|
| //Nice printable representation | | // Mixed stuff | |
| friend std::ostream& operator<<(std::ostream& out, pkgCache::PkgIterator | | inline void operator =(const Itr &B) {S = B.S; Owner = B.Owner;}; | |
| Pkg); | | inline bool IsGood() const { return S && Owner && ! end();}; | |
| | | inline unsigned long Index() const {return S - OwnerPointer();}; | |
| | | | |
|
| const char *CandVersion() const; | | void ReMap(void const * const oldMap, void const * const newMap) { | |
| const char *CurVersion() const; | | if (Owner == 0 || S == 0) | |
| | | return; | |
| | | S += (Str*)(newMap) - (Str*)(oldMap); | |
| | | } | |
| | | | |
|
| // Constructors | | // Constructors - look out for the variable assigning | |
| inline PkgIterator(pkgCache &Owner,Package *Trg) : Pkg(Trg), Owner(&Owne | | inline Iterator() : S(0), Owner(0) {}; | |
| r), | | inline Iterator(pkgCache &Owner,Str *T = 0) : S(T), Owner(&Owner) {} | |
| HashIndex(0) | | ; | |
| { | | | |
| if (Pkg == 0) | | | |
| Pkg = Owner.PkgP; | | | |
| }; | | | |
| inline PkgIterator() : Pkg(0), Owner(0), HashIndex(0) {}; | | | |
| }; | | }; | |
| /*}}
}*/ | | /*}}
}*/ | |
|
| // Version Iterator /*{{ | | // Group Iterator /*{{ | |
| {*/ | | {*/ | |
| class pkgCache::VerIterator | | /* Packages with the same name are collected in a Group so someone only | |
| { | | interest in package names can iterate easily over the names, so the | |
| Version *Ver; | | different architectures can be treated as of the "same" package | |
| pkgCache *Owner; | | (apt internally treat them as totally different packages) */ | |
| | | class pkgCache::GrpIterator: public Iterator<Group, GrpIterator> { | |
| void _dummy(); | | long HashIndex; | |
| | | | |
|
| public: | | protected: | |
| | | inline Group* OwnerPointer() const { | |
| | | return Owner->GrpP; | |
| | | }; | |
| | | | |
|
| // Iteration | | public: | |
| void operator ++(int) {if (Ver != Owner->VerP) Ver = Owner->VerP + Ver-> | | // This constructor is the 'begin' constructor, never use it. | |
| NextVer;}; | | inline GrpIterator(pkgCache &Owner) : Iterator<Group, GrpIterator>(O | |
| inline void operator ++() {operator ++(0);}; | | wner), HashIndex(-1) { | |
| inline bool end() const {return Owner == 0 || (Ver == Owner->VerP?true:f | | S = OwnerPointer(); | |
| alse);}; | | operator ++(0); | |
| inline void operator =(const VerIterator &B) {Ver = B.Ver; Owner = B.Own | | }; | |
| er;}; | | | |
| | | | |
|
| // Comparison | | virtual void operator ++(int); | |
| inline bool operator ==(const VerIterator &B) const {return Ver == B.Ver | | virtual void operator ++() {operator ++(0);}; | |
| ;}; | | | |
| inline bool operator !=(const VerIterator &B) const {return Ver != B.Ver | | | |
| ;}; | | | |
| int CompareVer(const VerIterator &B) const; | | | |
| | | | |
|
| // Testing | | inline const char *Name() const {return S->Name == 0?0:Owner->StrP + | |
| inline bool IsGood() const { return Ver && Owner && ! end();}; | | S->Name;}; | |
| | | inline PkgIterator PackageList() const; | |
| | | PkgIterator FindPkg(string Arch = "any") const; | |
| | | /** \brief find the package with the "best" architecture | |
| | | | |
|
| // Accessors | | The best architecture is either the "native" or the first | |
| inline Version *operator ->() {return Ver;}; | | in the list of Architectures which is not an end-Pointer | |
| inline Version const *operator ->() const {return Ver;}; | | | |
| inline Version &operator *() {return *Ver;}; | | | |
| inline Version const &operator *() const {return *Ver;}; | | | |
| inline operator Version *() {return Ver == Owner->VerP?0:Ver;}; | | | |
| inline operator Version const *() const {return Ver == Owner->VerP?0:Ver | | | |
| ;}; | | | |
| inline pkgCache *Cache() {return Owner;}; | | | |
| | | | |
|
| inline const char *VerStr() const {return Ver->VerStr == 0?0:Owner->StrP | | \param PreferNonVirtual tries to respond with a non-virtual pack | |
| + Ver->VerStr;}; | | age | |
| inline const char *Section() const {return Ver->Section == 0?0:Owner->St | | and only if this fails returns the best virtual package * | |
| rP + Ver->Section;}; | | / | |
| inline const char *Arch() const {return Ver->Arch == 0?0:Owner->StrP + V | | PkgIterator FindPreferredPkg(bool const &PreferNonVirtual = true) co | |
| er->Arch;}; | | nst; | |
| inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->P | | PkgIterator NextPkg(PkgIterator const &Pkg) const; | |
| kgP + Ver->ParentPkg);}; | | | |
| inline DescIterator DescriptionList() const; | | | |
| DescIterator TranslatedDescription() const; | | | |
| inline DepIterator DependsList() const; | | | |
| inline PrvIterator ProvidesList() const; | | | |
| inline VerFileIterator FileList() const; | | | |
| inline unsigned long Index() const {return Ver - Owner->VerP;}; | | | |
| bool Downloadable() const; | | | |
| inline const char *PriorityType() {return Owner->Priority(Ver->Priority) | | | |
| ;}; | | | |
| string RelStr(); | | | |
| | | | |
|
| bool Automatic() const; | | // Constructors | |
| VerFileIterator NewestFile() const; | | inline GrpIterator(pkgCache &Owner, Group *Trg) : Iterator<Group, Gr | |
| | | pIterator>(Owner, Trg), HashIndex(0) { | |
| | | if (S == 0) | |
| | | S = OwnerPointer(); | |
| | | }; | |
| | | inline GrpIterator() : Iterator<Group, GrpIterator>(), HashIndex(0) | |
| | | {}; | |
| | | | |
|
| inline VerIterator() : Ver(0), Owner(0) {}; | | | |
| inline VerIterator(pkgCache &Owner,Version *Trg = 0) : Ver(Trg), | | | |
| Owner(&Owner) | | | |
| { | | | |
| if (Ver == 0) | | | |
| Ver = Owner.VerP; | | | |
| }; | | | |
| }; | | }; | |
| /*}}
}*/ | | /*}}
}*/ | |
|
| // Description Iterator | | // Package Iterator /*{{ | |
| /*{{{*/ | | {*/ | |
| class pkgCache::DescIterator | | class pkgCache::PkgIterator: public Iterator<Package, PkgIterator> { | |
| { | | long HashIndex; | |
| Description *Desc; | | | |
| pkgCache *Owner; | | | |
| | | | |
|
| void _dummy(); | | protected: | |
| | | inline Package* OwnerPointer() const { | |
| | | return Owner->PkgP; | |
| | | }; | |
| | | | |
|
| public: | | public: | |
| | | // This constructor is the 'begin' constructor, never use it. | |
| | | inline PkgIterator(pkgCache &Owner) : Iterator<Package, PkgIterator> | |
| | | (Owner), HashIndex(-1) { | |
| | | S = OwnerPointer(); | |
| | | operator ++(0); | |
| | | }; | |
| | | | |
|
| // Iteration | | virtual void operator ++(int); | |
| void operator ++(int) {if (Desc != Owner->DescP) Desc = Owner->DescP + D | | virtual void operator ++() {operator ++(0);}; | |
| esc->NextDesc;}; | | | |
| inline void operator ++() {operator ++(0);}; | | | |
| inline bool end() const {return Owner == 0 || Desc == Owner->DescP?true: | | | |
| false;}; | | | |
| inline void operator =(const DescIterator &B) {Desc = B.Desc; Owner = B. | | | |
| Owner;}; | | | |
| | | | |
|
| // Comparison | | enum OkState {NeedsNothing,NeedsUnpack,NeedsConfigure}; | |
| inline bool operator ==(const DescIterator &B) const {return Desc == B.D | | | |
| esc;}; | | | |
| inline bool operator !=(const DescIterator &B) const {return Desc != B.D | | | |
| esc;}; | | | |
| int CompareDesc(const DescIterator &B) const; | | | |
| | | | |
|
| // Accessors | | // Accessors | |
| inline Description *operator ->() {return Desc;}; | | inline const char *Name() const {return S->Name == 0?0:Owner->StrP + | |
| inline Description const *operator ->() const {return Desc;}; | | S->Name;}; | |
| inline Description &operator *() {return *Desc;}; | | inline const char *Section() const {return S->Section == 0?0:Owner-> | |
| inline Description const &operator *() const {return *Desc;}; | | StrP + S->Section;}; | |
| inline operator Description *() {return Desc == Owner->DescP?0:Desc;}; | | inline bool Purge() const {return S->CurrentState == pkgCache::State | |
| inline operator Description const *() const {return Desc == Owner->DescP | | ::Purge || | |
| ?0:Desc;}; | | (S->CurrentVer == 0 && S->CurrentState == pkgCache::State::N | |
| inline pkgCache *Cache() {return Owner;}; | | otInstalled);}; | |
| | | inline const char *Arch() const {return S->Arch == 0?0:Owner->StrP + | |
| | | S->Arch;}; | |
| | | inline GrpIterator Group() const { return GrpIterator(*Owner, Owner- | |
| | | >GrpP + S->Group);}; | |
| | | | |
|
| inline const char *LanguageCode() const {return Owner->StrP + Desc->lang | | inline VerIterator VersionList() const; | |
| uage_code;}; | | inline VerIterator CurrentVer() const; | |
| inline const char *md5() const {return Owner->StrP + Desc->md5sum;}; | | inline DepIterator RevDependsList() const; | |
| inline DescFileIterator FileList() const; | | inline PrvIterator ProvidesList() const; | |
| inline unsigned long Index() const {return Desc - Owner->DescP;}; | | OkState State() const; | |
| | | const char *CandVersion() const; | |
| | | const char *CurVersion() const; | |
| | | | |
|
| inline DescIterator() : Desc(0), Owner(0) {}; | | //Nice printable representation | |
| inline DescIterator(pkgCache &Owner,Description *Trg = 0) : Desc(Trg), | | friend std::ostream& operator <<(std::ostream& out, PkgIterator i); | |
| Owner(&Owner) | | std::string FullName(bool const &Pretty = false) const; | |
| { | | | |
| if (Desc == 0) | | // Constructors | |
| Desc = Owner.DescP; | | inline PkgIterator(pkgCache &Owner,Package *Trg) : Iterator<Package, | |
| }; | | PkgIterator>(Owner, Trg), HashIndex(0) { | |
| | | if (S == 0) | |
| | | S = OwnerPointer(); | |
| | | }; | |
| | | inline PkgIterator() : Iterator<Package, PkgIterator>(), HashIndex(0 | |
| | | ) {}; | |
| }; | | }; | |
| /*}}
}*/ | | /*}}
}*/ | |
|
| // Dependency iterator /*{{ | | // Version Iterator /*{{ | |
| {*/ | | {*/ | |
| class pkgCache::DepIterator | | class pkgCache::VerIterator : public Iterator<Version, VerIterator> { | |
| { | | protected: | |
| Dependency *Dep; | | inline Version* OwnerPointer() const { | |
| enum {DepVer, DepRev} Type; | | return Owner->VerP; | |
| pkgCache *Owner; | | }; | |
| | | | |
|
| void _dummy(); | | public: | |
| | | // Iteration | |
| | | void operator ++(int) {if (S != Owner->VerP) S = Owner->VerP + S->Ne | |
| | | xtVer;}; | |
| | | inline void operator ++() {operator ++(0);}; | |
| | | | |
|
| public: | | // Comparison | |
| | | int CompareVer(const VerIterator &B) const; | |
| | | /** \brief compares two version and returns if they are similar | |
| | | | |
|
| // Iteration | | This method should be used to identify if two pseudo versions ar | |
| void operator ++(int) {if (Dep != Owner->DepP) Dep = Owner->DepP + | | e | |
| (Type == DepVer?Dep->NextDepends:Dep->NextRevDepends);}; | | refering to the same "real" version */ | |
| inline void operator ++() {operator ++(0);}; | | inline bool SimilarVer(const VerIterator &B) const { | |
| inline bool end() const {return Owner == 0 || Dep == Owner->DepP?true:fa | | return (B.end() == false && S->Hash == B->Hash && strcmp(Ver | |
| lse;}; | | Str(), B.VerStr()) == 0); | |
| | | }; | |
| | | | |
|
| // Comparison | | // Accessors | |
| inline bool operator ==(const DepIterator &B) const {return Dep == B.Dep | | inline const char *VerStr() const {return S->VerStr == 0?0:Owner->St | |
| ;}; | | rP + S->VerStr;}; | |
| inline bool operator !=(const DepIterator &B) const {return Dep != B.Dep | | inline const char *Section() const {return S->Section == 0?0:Owner-> | |
| ;}; | | StrP + S->Section;}; | |
| | | inline const char *Arch() const { | |
| | | if(S->MultiArch == pkgCache::Version::All) | |
| | | return "all"; | |
| | | return S->ParentPkg == 0?0:Owner->StrP + ParentPkg()->Arch; | |
| | | }; | |
| | | inline const char *Arch(bool const pseudo) const { | |
| | | if(pseudo == false) | |
| | | return Arch(); | |
| | | return S->ParentPkg == 0?0:Owner->StrP + ParentPkg()->Arch; | |
| | | }; | |
| | | inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owne | |
| | | r->PkgP + S->ParentPkg);}; | |
| | | | |
|
| // Accessors | | inline DescIterator DescriptionList() const; | |
| inline Dependency *operator ->() {return Dep;}; | | DescIterator TranslatedDescription() const; | |
| inline Dependency const *operator ->() const {return Dep;}; | | inline DepIterator DependsList() const; | |
| inline Dependency &operator *() {return *Dep;}; | | inline PrvIterator ProvidesList() const; | |
| inline Dependency const &operator *() const {return *Dep;}; | | inline VerFileIterator FileList() const; | |
| inline operator Dependency *() {return Dep == Owner->DepP?0:Dep;}; | | bool Downloadable() const; | |
| inline operator Dependency const *() const {return Dep == Owner->DepP?0: | | inline const char *PriorityType() const {return Owner->Priority(S->P | |
| Dep;}; | | riority);}; | |
| inline pkgCache *Cache() {return Owner;}; | | string RelStr() const; | |
| | | | |
|
| inline const char *TargetVer() const {return Dep->Version == 0?0:Owner-> | | bool Automatic() const; | |
| StrP + Dep->Version;}; | | bool Pseudo() const; | |
| inline PkgIterator TargetPkg() {return PkgIterator(*Owner,Owner->PkgP + | | VerFileIterator NewestFile() const; | |
| Dep->Package);}; | | | |
| inline PkgIterator SmartTargetPkg() {PkgIterator R(*Owner,0);SmartTarget | | | |
| Pkg(R);return R;}; | | | |
| inline VerIterator ParentVer() {return VerIterator(*Owner,Owner->VerP + | | | |
| Dep->ParentVer);}; | | | |
| inline PkgIterator ParentPkg() {return PkgIterator(*Owner,Owner->PkgP + | | | |
| Owner->VerP[Dep->ParentVer].ParentPkg);}; | | | |
| inline bool Reverse() {return Type == DepRev;}; | | | |
| inline unsigned long Index() const {return Dep - Owner->DepP;}; | | | |
| bool IsCritical(); | | | |
| void GlobOr(DepIterator &Start,DepIterator &End); | | | |
| Version **AllTargets(); | | | |
| bool SmartTargetPkg(PkgIterator &Result); | | | |
| inline const char *CompType() {return Owner->CompType(Dep->CompareOp);}; | | | |
| inline const char *DepType() {return Owner->DepType(Dep->Type);}; | | | |
| | | | |
|
| inline DepIterator(pkgCache &Owner,Dependency *Trg,Version * = 0) : | | inline VerIterator(pkgCache &Owner,Version *Trg = 0) : Iterator<Vers | |
| Dep(Trg), Type(DepVer), Owner(&Owner) | | ion, VerIterator>(Owner, Trg) { | |
| { | | if (S == 0) | |
| if (Dep == 0) | | S = OwnerPointer(); | |
| Dep = Owner.DepP; | | }; | |
| }; | | inline VerIterator() : Iterator<Version, VerIterator>() {}; | |
| inline DepIterator(pkgCache &Owner,Dependency *Trg,Package *) : | | | |
| Dep(Trg), Type(DepRev), Owner(&Owner) | | | |
| { | | | |
| if (Dep == 0) | | | |
| Dep = Owner.DepP; | | | |
| }; | | | |
| inline DepIterator() : Dep(0), Type(DepVer), Owner(0) {}; | | | |
| }; | | }; | |
| /*}}
}*/ | | /*}}
}*/ | |
|
| // Provides iterator /*{{ | | // Description Iterator | |
| {*/ | | /*{{{*/ | |
| class pkgCache::PrvIterator | | class pkgCache::DescIterator : public Iterator<Description, DescIterator> { | |
| { | | protected: | |
| Provides *Prv; | | inline Description* OwnerPointer() const { | |
| enum {PrvVer, PrvPkg} Type; | | return Owner->DescP; | |
| pkgCache *Owner; | | }; | |
| | | | |
|
| void _dummy(); | | public: | |
| | | // Iteration | |
| | | void operator ++(int) {if (S != Owner->DescP) S = Owner->DescP + S-> | |
| | | NextDesc;}; | |
| | | inline void operator ++() {operator ++(0);}; | |
| | | | |
|
| public: | | // Comparison | |
| | | int CompareDesc(const DescIterator &B) const; | |
| | | | |
|
| // Iteration | | // Accessors | |
| void operator ++(int) {if (Prv != Owner->ProvideP) Prv = Owner->ProvideP | | inline const char *LanguageCode() const {return Owner->StrP + S->lan | |
| + | | guage_code;}; | |
| (Type == PrvVer?Prv->NextPkgProv:Prv->NextProvides);}; | | inline const char *md5() const {return Owner->StrP + S->md5sum;}; | |
| inline void operator ++() {operator ++(0);}; | | inline DescFileIterator FileList() const; | |
| inline bool end() const {return Owner == 0 || Prv == Owner->ProvideP?tru | | | |
| e:false;}; | | | |
| | | | |
|
| // Comparison | | inline DescIterator() : Iterator<Description, DescIterator>() {}; | |
| inline bool operator ==(const PrvIterator &B) const {return Prv == B.Prv | | inline DescIterator(pkgCache &Owner,Description *Trg = 0) : Iterator | |
| ;}; | | <Description, DescIterator>(Owner, Trg) { | |
| inline bool operator !=(const PrvIterator &B) const {return Prv != B.Prv | | if (S == 0) | |
| ;}; | | S = Owner.DescP; | |
| | | }; | |
| | | }; | |
| | | /*}} | |
| | | }*/ | |
| | | // Dependency iterator /*{{ | |
| | | {*/ | |
| | | class pkgCache::DepIterator : public Iterator<Dependency, DepIterator> { | |
| | | enum {DepVer, DepRev} Type; | |
| | | | |
|
| // Accessors | | protected: | |
| inline Provides *operator ->() {return Prv;}; | | inline Dependency* OwnerPointer() const { | |
| inline Provides const *operator ->() const {return Prv;}; | | return Owner->DepP; | |
| inline Provides &operator *() {return *Prv;}; | | }; | |
| inline Provides const &operator *() const {return *Prv;}; | | | |
| inline operator Provides *() {return Prv == Owner->ProvideP?0:Prv;}; | | | |
| inline operator Provides const *() const {return Prv == Owner->ProvideP? | | | |
| 0:Prv;}; | | | |
| inline pkgCache *Cache() {return Owner;}; | | | |
| | | | |
|
| inline const char *Name() const {return Owner->StrP + Owner->PkgP[Prv->P | | public: | |
| arentPkg].Name;}; | | // Iteration | |
| inline const char *ProvideVersion() const {return Prv->ProvideVersion == | | void operator ++(int) {if (S != Owner->DepP) S = Owner->DepP + | |
| 0?0:Owner->StrP + Prv->ProvideVersion;}; | | (Type == DepVer ? S->NextDepends : S->NextRevDepends);}; | |
| inline PkgIterator ParentPkg() {return PkgIterator(*Owner,Owner->PkgP + | | inline void operator ++() {operator ++(0);}; | |
| Prv->ParentPkg);}; | | | |
| inline VerIterator OwnerVer() {return VerIterator(*Owner,Owner->VerP + P | | | |
| rv->Version);}; | | | |
| inline PkgIterator OwnerPkg() {return PkgIterator(*Owner,Owner->PkgP + O | | | |
| wner->VerP[Prv->Version].ParentPkg);}; | | | |
| inline unsigned long Index() const {return Prv - Owner->ProvideP;}; | | | |
| | | | |
|
| inline PrvIterator() : Prv(0), Type(PrvVer), Owner(0) {}; | | // Accessors | |
| | | inline const char *TargetVer() const {return S->Version == 0?0:Owner | |
| | | ->StrP + S->Version;}; | |
| | | inline PkgIterator TargetPkg() const {return PkgIterator(*Owner,Owne | |
| | | r->PkgP + S->Package);}; | |
| | | inline PkgIterator SmartTargetPkg() const {PkgIterator R(*Owner,0);S | |
| | | martTargetPkg(R);return R;}; | |
| | | inline VerIterator ParentVer() const {return VerIterator(*Owner,Owne | |
| | | r->VerP + S->ParentVer);}; | |
| | | inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owne | |
| | | r->PkgP + Owner->VerP[S->ParentVer].ParentPkg);}; | |
| | | inline bool Reverse() const {return Type == DepRev;}; | |
| | | bool IsCritical() const; | |
| | | void GlobOr(DepIterator &Start,DepIterator &End); | |
| | | Version **AllTargets() const; | |
| | | bool SmartTargetPkg(PkgIterator &Result) const; | |
| | | inline const char *CompType() const {return Owner->CompType(S->Compa | |
| | | reOp);}; | |
| | | inline const char *DepType() const {return Owner->DepType(S->Type);} | |
| | | ; | |
| | | | |
|
| inline PrvIterator(pkgCache &Owner,Provides *Trg,Version *) : | | //Nice printable representation | |
| Prv(Trg), Type(PrvVer), Owner(&Owner) | | friend std::ostream& operator <<(std::ostream& out, DepIterator D); | |
| { | | | |
| if (Prv == 0) | | inline DepIterator(pkgCache &Owner, Dependency *Trg, Version* = 0) : | |
| Prv = Owner.ProvideP; | | Iterator<Dependency, DepIterator>(Owner, Trg), Type(DepVer) | |
| }; | | { | |
| inline PrvIterator(pkgCache &Owner,Provides *Trg,Package *) : | | if (S == 0) | |
| Prv(Trg), Type(PrvPkg), Owner(&Owner) | | S = Owner.DepP; | |
| { | | }; | |
| if (Prv == 0) | | inline DepIterator(pkgCache &Owner, Dependency *Trg, Package*) : | |
| Prv = Owner.ProvideP; | | Iterator<Dependency, DepIterator>(Owner, Trg), Type(DepRev) | |
| }; | | { | |
| | | if (S == 0) | |
| | | S = Owner.DepP; | |
| | | }; | |
| | | inline DepIterator() : Iterator<Dependency, DepIterator>(), Type(Dep | |
| | | Ver) {}; | |
| }; | | }; | |
| /*}}
}*/ | | /*}}
}*/ | |
|
| // Package file | | // Provides iterator /*{{ | |
| /*{{{*/ | | {*/ | |
| class pkgCache::PkgFileIterator | | class pkgCache::PrvIterator : public Iterator<Provides, PrvIterator> { | |
| { | | enum {PrvVer, PrvPkg} Type; | |
| pkgCache *Owner; | | | |
| PackageFile *File; | | | |
| | | | |
|
| public: | | protected: | |
| | | inline Provides* OwnerPointer() const { | |
| | | return Owner->ProvideP; | |
| | | }; | |
| | | | |
|
| // Iteration | | public: | |
| void operator ++(int) {if (File!= Owner->PkgFileP) File = Owner->PkgFile | | // Iteration | |
| P + File->NextFile;}; | | void operator ++(int) {if (S != Owner->ProvideP) S = Owner->ProvideP | |
| inline void operator ++() {operator ++(0);}; | | + | |
| inline bool end() const {return Owner == 0 || File == Owner->PkgFileP?tr | | (Type == PrvVer?S->NextPkgProv:S->NextProvides);}; | |
| ue:false;}; | | inline void operator ++() {operator ++(0);}; | |
| | | | |
|
| // Comparison | | // Accessors | |
| inline bool operator ==(const PkgFileIterator &B) const {return File == | | inline const char *Name() const {return Owner->StrP + Owner->PkgP[S- | |
| B.File;}; | | >ParentPkg].Name;}; | |
| inline bool operator !=(const PkgFileIterator &B) const {return File != | | inline const char *ProvideVersion() const {return S->ProvideVersion | |
| B.File;}; | | == 0?0:Owner->StrP + S->ProvideVersion;}; | |
| | | inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owne | |
| | | r->PkgP + S->ParentPkg);}; | |
| | | inline VerIterator OwnerVer() const {return VerIterator(*Owner,Owner | |
| | | ->VerP + S->Version);}; | |
| | | inline PkgIterator OwnerPkg() const {return PkgIterator(*Owner,Owner | |
| | | ->PkgP + Owner->VerP[S->Version].ParentPkg);}; | |
| | | | |
|
| // Accessors | | inline PrvIterator() : Iterator<Provides, PrvIterator>(), Type(PrvVe | |
| inline PackageFile *operator ->() {return File;}; | | r) {}; | |
| inline PackageFile const *operator ->() const {return File;}; | | | |
| inline PackageFile const &operator *() const {return *File;}; | | | |
| inline operator PackageFile *() {return File == Owner->PkgFileP?0:File;} | | | |
| ; | | | |
| inline operator PackageFile const *() const {return File == Owner->PkgFi | | | |
| leP?0:File;}; | | | |
| inline pkgCache *Cache() {return Owner;}; | | | |
| | | | |
|
| inline const char *FileName() const {return File->FileName == 0?0:Owner- | | inline PrvIterator(pkgCache &Owner, Provides *Trg, Version*) : | |
| >StrP + File->FileName;}; | | Iterator<Provides, PrvIterator>(Owner, Trg), Type(PrvVer) { | |
| inline const char *Archive() const {return File->Archive == 0?0:Owner->S | | if (S == 0) | |
| trP + File->Archive;}; | | S = Owner.ProvideP; | |
| inline const char *Component() const {return File->Component == 0?0:Owne | | }; | |
| r->StrP + File->Component;}; | | inline PrvIterator(pkgCache &Owner, Provides *Trg, Package*) : | |
| inline const char *Version() const {return File->Version == 0?0:Owner->S | | Iterator<Provides, PrvIterator>(Owner, Trg), Type(PrvPkg) { | |
| trP + File->Version;}; | | if (S == 0) | |
| inline const char *Origin() const {return File->Origin == 0?0:Owner->Str | | S = Owner.ProvideP; | |
| P + File->Origin;}; | | }; | |
| inline const char *Codename() const {return File->Codename ==0?0:Owner-> | | }; | |
| StrP + File->Codename;}; | | /*}} | |
| inline const char *Label() const {return File->Label == 0?0:Owner->StrP | | }*/ | |
| + File->Label;}; | | // Package file | |
| inline const char *Site() const {return File->Site == 0?0:Owner->StrP + | | /*{{{*/ | |
| File->Site;}; | | class pkgCache::PkgFileIterator : public Iterator<PackageFile, PkgFileItera | |
| inline const char *Architecture() const {return File->Architecture == 0? | | tor> { | |
| 0:Owner->StrP + File->Architecture;}; | | protected: | |
| inline const char *IndexType() const {return File->IndexType == 0?0:Owne | | inline PackageFile* OwnerPointer() const { | |
| r->StrP + File->IndexType;}; | | return Owner->PkgFileP; | |
| | | }; | |
| | | | |
|
| inline unsigned long Index() const {return File - Owner->PkgFileP;}; | | public: | |
| | | // Iteration | |
| | | void operator ++(int) {if (S != Owner->PkgFileP) S = Owner->PkgFileP | |
| | | + S->NextFile;}; | |
| | | inline void operator ++() {operator ++(0);}; | |
| | | | |
|
| bool IsOk(); | | // Accessors | |
| string RelStr(); | | inline const char *FileName() const {return S->FileName == 0?0:Owner | |
| | | ->StrP + S->FileName;}; | |
| | | inline const char *Archive() const {return S->Archive == 0?0:Owner-> | |
| | | StrP + S->Archive;}; | |
| | | inline const char *Component() const {return S->Component == 0?0:Own | |
| | | er->StrP + S->Component;}; | |
| | | inline const char *Version() const {return S->Version == 0?0:Owner-> | |
| | | StrP + S->Version;}; | |
| | | inline const char *Origin() const {return S->Origin == 0?0:Owner->St | |
| | | rP + S->Origin;}; | |
| | | inline const char *Codename() const {return S->Codename ==0?0:Owner- | |
| | | >StrP + S->Codename;}; | |
| | | inline const char *Label() const {return S->Label == 0?0:Owner->StrP | |
| | | + S->Label;}; | |
| | | inline const char *Site() const {return S->Site == 0?0:Owner->StrP + | |
| | | S->Site;}; | |
| | | inline const char *Architecture() const {return S->Architecture == 0 | |
| | | ?0:Owner->StrP + S->Architecture;}; | |
| | | inline const char *IndexType() const {return S->IndexType == 0?0:Own | |
| | | er->StrP + S->IndexType;}; | |
| | | | |
|
| // Constructors | | bool IsOk(); | |
| inline PkgFileIterator() : Owner(0), File(0) {}; | | string RelStr(); | |
| inline PkgFileIterator(pkgCache &Owner) : Owner(&Owner), File(Owner.PkgF | | | |
| ileP) {}; | | // Constructors | |
| inline PkgFileIterator(pkgCache &Owner,PackageFile *Trg) : Owner(&Owner) | | inline PkgFileIterator() : Iterator<PackageFile, PkgFileIterator>() | |
| , File(Trg) {}; | | {}; | |
| | | inline PkgFileIterator(pkgCache &Owner) : Iterator<PackageFile, PkgF | |
| | | ileIterator>(Owner, Owner.PkgFileP) {}; | |
| | | inline PkgFileIterator(pkgCache &Owner,PackageFile *Trg) : Iterator< | |
| | | PackageFile, PkgFileIterator>(Owner, Trg) {}; | |
| }; | | }; | |
| /*}}
}*/ | | /*}}
}*/ | |
| // Version File
/*{{{*/ | | // Version File
/*{{{*/ | |
|
| class pkgCache::VerFileIterator | | class pkgCache::VerFileIterator : public pkgCache::Iterator<VerFile, VerFil | |
| { | | eIterator> { | |
| pkgCache *Owner; | | protected: | |
| VerFile *FileP; | | inline VerFile* OwnerPointer() const { | |
| | | return Owner->VerFileP; | |
| public: | | }; | |
| | | | |
| // Iteration | | | |
| void operator ++(int) {if (FileP != Owner->VerFileP) FileP = Owner->VerF | | | |
| ileP + FileP->NextFile;}; | | | |
| inline void operator ++() {operator ++(0);}; | | | |
| inline bool end() const {return Owner == 0 || FileP == Owner->VerFileP?t | | | |
| rue:false;}; | | | |
| | | | |
| // Comparison | | | |
| inline bool operator ==(const VerFileIterator &B) const {return FileP == | | | |
| B.FileP;}; | | | |
| inline bool operator !=(const VerFileIterator &B) const {return FileP != | | | |
| B.FileP;}; | | | |
| | | | |
|
| // Accessors | | public: | |
| inline VerFile *operator ->() {return FileP;}; | | // Iteration | |
| inline VerFile const *operator ->() const {return FileP;}; | | void operator ++(int) {if (S != Owner->VerFileP) S = Owner->VerFileP | |
| inline VerFile const &operator *() const {return *FileP;}; | | + S->NextFile;}; | |
| inline operator VerFile *() {return FileP == Owner->VerFileP?0:FileP;}; | | inline void operator ++() {operator ++(0);}; | |
| inline operator VerFile const *() const {return FileP == Owner->VerFileP | | | |
| ?0:FileP;}; | | | |
| inline pkgCache *Cache() {return Owner;}; | | | |
| | | | |
|
| inline PkgFileIterator File() const {return PkgFileIterator(*Owner,FileP | | // Accessors | |
| ->File + Owner->PkgFileP);}; | | inline PkgFileIterator File() const {return PkgFileIterator(*Owner,S | |
| inline unsigned long Index() const {return FileP - Owner->VerFileP;}; | | ->File + Owner->PkgFileP);}; | |
| | | | |
|
| >File + Owner->PkgFileP);}; | | inline VerFileIterator() : Iterator<VerFile, VerFileIterator>() {}; | |
| inline VerFileIterator() : Owner(0), FileP(0) {}; | | inline VerFileIterator(pkgCache &Owner,VerFile *Trg) : Iterator<VerF | |
| inline VerFileIterator(pkgCache &Owner,VerFile *Trg) : Owner(&Owner), Fi | | ile, VerFileIterator>(Owner, Trg) {}; | |
| leP(Trg) {}; | | | |
| }; | | }; | |
| /*}}
}*/ | | /*}}
}*/ | |
| // Description File /*{{
{*/ | | // Description File /*{{
{*/ | |
|
| class pkgCache::DescFileIterator | | class pkgCache::DescFileIterator : public Iterator<DescFile, DescFileIterat | |
| { | | or> { | |
| pkgCache *Owner; | | protected: | |
| DescFile *FileP; | | inline DescFile* OwnerPointer() const { | |
| | | return Owner->DescFileP; | |
| public: | | }; | |
| | | | |
| // Iteration | | | |
| void operator ++(int) {if (FileP != Owner->DescFileP) FileP = Owner->Des | | | |
| cFileP + FileP->NextFile;}; | | | |
| inline void operator ++() {operator ++(0);}; | | | |
| inline bool end() const {return Owner == 0 || FileP == Owner->DescFileP | | | |
| ?true:false;}; | | | |
| | | | |
| // Comparison | | | |
| inline bool operator ==(const DescFileIterator &B) const {return FileP = | | | |
| = B.FileP;}; | | | |
| inline bool operator !=(const DescFileIterator &B) const {return FileP ! | | | |
| = B.FileP;}; | | | |
| | | | |
|
| // Accessors | | public: | |
| inline DescFile *operator ->() {return FileP;}; | | // Iteration | |
| inline DescFile const *operator ->() const {return FileP;}; | | void operator ++(int) {if (S != Owner->DescFileP) S = Owner->DescFil | |
| inline DescFile const &operator *() const {return *FileP;}; | | eP + S->NextFile;}; | |
| inline operator DescFile *() {return FileP == Owner->DescFileP?0:FileP;} | | inline void operator ++() {operator ++(0);}; | |
| ; | | | |
| inline operator DescFile const *() const {return FileP == Owner->DescFil | | | |
| eP?0:FileP;}; | | | |
| inline pkgCache *Cache() {return Owner;}; | | | |
| | | | |
|
| inline PkgFileIterator File() const {return PkgFileIterator(*Owner,FileP | | // Accessors | |
| ->File + Owner->PkgFileP);}; | | inline PkgFileIterator File() const {return PkgFileIterator(*Owner,S | |
| inline unsigned long Index() const {return FileP - Owner->DescFileP;}; | | ->File + Owner->PkgFileP);}; | |
| | | | |
|
| >File + Owner->PkgFileP);}; | | inline DescFileIterator() : Iterator<DescFile, DescFileIterator>() { | |
| inline DescFileIterator() : Owner(0), FileP(0) {}; | | }; | |
| inline DescFileIterator(pkgCache &Owner,DescFile *Trg) : Owner(&Owner), | | inline DescFileIterator(pkgCache &Owner,DescFile *Trg) : Iterator<De | |
| FileP(Trg) {}; | | scFile, DescFileIterator>(Owner, Trg) {}; | |
| }; | | }; | |
| /*}}
}*/ | | /*}}
}*/ | |
| // Inlined Begin functions cant be in the class because of order problems /
*{{{*/ | | // Inlined Begin functions cant be in the class because of order problems /
*{{{*/ | |
|
| | | inline pkgCache::PkgIterator pkgCache::GrpIterator::PackageList() const | |
| | | {return PkgIterator(*Owner,Owner->PkgP + S->FirstPackage);}; | |
| inline pkgCache::VerIterator pkgCache::PkgIterator::VersionList() const | | inline pkgCache::VerIterator pkgCache::PkgIterator::VersionList() const | |
|
| {return VerIterator(*Owner,Owner->VerP + Pkg->VersionList);}; | | {return VerIterator(*Owner,Owner->VerP + S->VersionList);}; | |
| inline pkgCache::VerIterator pkgCache::PkgIterator::CurrentVer() const | | inline pkgCache::VerIterator pkgCache::PkgIterator::CurrentVer() const | |
|
| {return VerIterator(*Owner,Owner->VerP + Pkg->CurrentVer);}; | | {return VerIterator(*Owner,Owner->VerP + S->CurrentVer);}; | |
| inline pkgCache::DepIterator pkgCache::PkgIterator::RevDependsList() const | | inline pkgCache::DepIterator pkgCache::PkgIterator::RevDependsList() const | |
|
| {return DepIterator(*Owner,Owner->DepP + Pkg->RevDepends,Pkg);}; | | {return DepIterator(*Owner,Owner->DepP + S->RevDepends,S);}; | |
| inline pkgCache::PrvIterator pkgCache::PkgIterator::ProvidesList() const | | inline pkgCache::PrvIterator pkgCache::PkgIterator::ProvidesList() const | |
|
| {return PrvIterator(*Owner,Owner->ProvideP + Pkg->ProvidesList,Pkg);
}; | | {return PrvIterator(*Owner,Owner->ProvideP + S->ProvidesList,S);}; | |
| inline pkgCache::DescIterator pkgCache::VerIterator::DescriptionList() cons
t | | inline pkgCache::DescIterator pkgCache::VerIterator::DescriptionList() cons
t | |
|
| {return DescIterator(*Owner,Owner->DescP + Ver->DescriptionList);}; | | {return DescIterator(*Owner,Owner->DescP + S->DescriptionList);}; | |
| inline pkgCache::PrvIterator pkgCache::VerIterator::ProvidesList() const | | inline pkgCache::PrvIterator pkgCache::VerIterator::ProvidesList() const | |
|
| {return PrvIterator(*Owner,Owner->ProvideP + Ver->ProvidesList,Ver);
}; | | {return PrvIterator(*Owner,Owner->ProvideP + S->ProvidesList,S);}; | |
| inline pkgCache::DepIterator pkgCache::VerIterator::DependsList() const | | inline pkgCache::DepIterator pkgCache::VerIterator::DependsList() const | |
|
| {return DepIterator(*Owner,Owner->DepP + Ver->DependsList,Ver);}; | | {return DepIterator(*Owner,Owner->DepP + S->DependsList,S);}; | |
| inline pkgCache::VerFileIterator pkgCache::VerIterator::FileList() const | | inline pkgCache::VerFileIterator pkgCache::VerIterator::FileList() const | |
|
| {return VerFileIterator(*Owner,Owner->VerFileP + Ver->FileList);}; | | {return VerFileIterator(*Owner,Owner->VerFileP + S->FileList);}; | |
| inline pkgCache::DescFileIterator pkgCache::DescIterator::FileList() const | | inline pkgCache::DescFileIterator pkgCache::DescIterator::FileList() const | |
|
| {return DescFileIterator(*Owner,Owner->DescFileP + Desc->FileList);}
; | | {return DescFileIterator(*Owner,Owner->DescFileP + S->FileList);}; | |
| /*}}
}*/ | | /*}}
}*/ | |
| #endif | | #endif | |
| | | | |
End of changes. 71 change blocks. |
| 420 lines changed or deleted | | 409 lines changed or added | |
|
| configuration.h | | configuration.h | |
| | | | |
| skipping to change at line 31 | | skipping to change at line 31 | |
| A special extension, support for ordered lists is provided by using the | | A special extension, support for ordered lists is provided by using the | |
| special syntax, "block::list::" the trailing :: designates the | | special syntax, "block::list::" the trailing :: designates the | |
| item as a list. To access the list you must use the tree function on | | item as a list. To access the list you must use the tree function on | |
| "block::list". | | "block::list". | |
| | | | |
| ##################################################################### */ | | ##################################################################### */ | |
| /*}}
}*/ | | /*}}
}*/ | |
| #ifndef PKGLIB_CONFIGURATION_H | | #ifndef PKGLIB_CONFIGURATION_H | |
| #define PKGLIB_CONFIGURATION_H | | #define PKGLIB_CONFIGURATION_H | |
| | | | |
|
| | | #include <regex.h> | |
| | | | |
| #include <string> | | #include <string> | |
| #include <vector> | | #include <vector> | |
| #include <iostream> | | #include <iostream> | |
| | | | |
| using std::string; | | using std::string; | |
| | | | |
| class Configuration | | class Configuration | |
| { | | { | |
| public: | | public: | |
| | | | |
| | | | |
| skipping to change at line 59 | | skipping to change at line 61 | |
| string FullTag(const Item *Stop = 0) const; | | string FullTag(const Item *Stop = 0) const; | |
| | | | |
| Item() : Parent(0), Child(0), Next(0) {}; | | Item() : Parent(0), Child(0), Next(0) {}; | |
| }; | | }; | |
| | | | |
| private: | | private: | |
| | | | |
| Item *Root; | | Item *Root; | |
| bool ToFree; | | bool ToFree; | |
| | | | |
|
| Item *Lookup(Item *Head,const char *S,unsigned long Len,bool Create); | | Item *Lookup(Item *Head,const char *S,unsigned long const &Len,bool cons | |
| Item *Lookup(const char *Name,bool Create); | | t &Create); | |
| | | Item *Lookup(const char *Name,const bool &Create); | |
| inline const Item *Lookup(const char *Name) const | | inline const Item *Lookup(const char *Name) const | |
| { | | { | |
| return ((Configuration *)this)->Lookup(Name,false); | | return ((Configuration *)this)->Lookup(Name,false); | |
| } | | } | |
| | | | |
| public: | | public: | |
| | | | |
| string Find(const char *Name,const char *Default = 0) const; | | string Find(const char *Name,const char *Default = 0) const; | |
|
| string Find(const string Name,const char *Default = 0) const {return Fin | | string Find(string const &Name,const char *Default = 0) const {return Fi | |
| d(Name.c_str(),Default);}; | | nd(Name.c_str(),Default);}; | |
| | | string Find(string const &Name, string const &Default) const {return Fin | |
| | | d(Name.c_str(),Default.c_str());}; | |
| string FindFile(const char *Name,const char *Default = 0) const; | | string FindFile(const char *Name,const char *Default = 0) const; | |
| string FindDir(const char *Name,const char *Default = 0) const; | | string FindDir(const char *Name,const char *Default = 0) const; | |
|
| std::vector<string> FindVector(const string &Name) const; | | std::vector<string> FindVector(string const &Name) const; | |
| std::vector<string> FindVector(const char *Name) const; | | std::vector<string> FindVector(const char *Name) const; | |
|
| int FindI(const char *Name,int Default = 0) const; | | int FindI(const char *Name,int const &Default = 0) const; | |
| int FindI(const string Name,int Default = 0) const {return FindI(Name.c_ | | int FindI(string const &Name,int const &Default = 0) const {return FindI | |
| str(),Default);}; | | (Name.c_str(),Default);}; | |
| bool FindB(const char *Name,bool Default = false) const; | | bool FindB(const char *Name,bool const &Default = false) const; | |
| bool FindB(const string Name,bool Default = false) const {return FindB(N | | bool FindB(string const &Name,bool const &Default = false) const {return | |
| ame.c_str(),Default);}; | | FindB(Name.c_str(),Default);}; | |
| string FindAny(const char *Name,const char *Default = 0) const; | | string FindAny(const char *Name,const char *Default = 0) const; | |
| | | | |
|
| inline void Set(const string Name,string Value) {Set(Name.c_str(),Value)
;}; | | inline void Set(const string &Name,const string &Value) {Set(Name.c_str(
),Value);}; | |
| void CndSet(const char *Name,const string &Value); | | void CndSet(const char *Name,const string &Value); | |
| void Set(const char *Name,const string &Value); | | void Set(const char *Name,const string &Value); | |
|
| void Set(const char *Name,int Value); | | void Set(const char *Name,const int &Value); | |
| | | | |
|
| inline bool Exists(const string Name) const {return Exists(Name.c_str())
;}; | | inline bool Exists(const string &Name) const {return Exists(Name.c_str()
);}; | |
| bool Exists(const char *Name) const; | | bool Exists(const char *Name) const; | |
| bool ExistsAny(const char *Name) const; | | bool ExistsAny(const char *Name) const; | |
| | | | |
| // clear a whole tree | | // clear a whole tree | |
|
| void Clear(const string Name); | | void Clear(const string &Name); | |
| | | | |
| // remove a certain value from a list (e.g. the list of "APT::Keep-Fds") | | // remove a certain value from a list (e.g. the list of "APT::Keep-Fds") | |
|
| void Clear(const string List, string Value); | | void Clear(string const &List, string const &Value); | |
| void Clear(const string List, int Value); | | void Clear(string const &List, int const &Value); | |
| | | | |
| inline const Item *Tree(const char *Name) const {return Lookup(Name);}; | | inline const Item *Tree(const char *Name) const {return Lookup(Name);}; | |
| | | | |
| inline void Dump() { Dump(std::clog); }; | | inline void Dump() { Dump(std::clog); }; | |
| void Dump(std::ostream& str); | | void Dump(std::ostream& str); | |
| | | | |
| Configuration(const Item *Root); | | Configuration(const Item *Root); | |
| Configuration(); | | Configuration(); | |
| ~Configuration(); | | ~Configuration(); | |
|
| | | | |
| | | /** \brief match a string against a configurable list of patterns */ | |
| | | class MatchAgainstConfig | |
| | | { | |
| | | std::vector<regex_t *> patterns; | |
| | | | |
| | | public: | |
| | | MatchAgainstConfig(char const * Config); | |
| | | virtual ~MatchAgainstConfig(); | |
| | | | |
| | | /** \brief Returns \b true for a string matching one of the patterns * | |
| | | / | |
| | | bool Match(char const * str) const; | |
| | | bool Match(std::string const &str) const { return Match(str.c_str()); | |
| | | }; | |
| | | | |
| | | /** \brief returns if the matcher setup was successful */ | |
| | | bool wasConstructedSuccessfully() const { return patterns.empty() == f | |
| | | alse; } | |
| | | }; | |
| }; | | }; | |
| | | | |
| extern Configuration *_config; | | extern Configuration *_config; | |
| | | | |
| bool ReadConfigFile(Configuration &Conf,const string &FName, | | bool ReadConfigFile(Configuration &Conf,const string &FName, | |
|
| bool AsSectional = false, | | bool const &AsSectional = false, | |
| unsigned Depth = 0); | | unsigned const &Depth = 0); | |
| | | | |
| bool ReadConfigDir(Configuration &Conf,const string &Dir, | | bool ReadConfigDir(Configuration &Conf,const string &Dir, | |
|
| bool AsSectional = false, | | bool const &AsSectional = false, | |
| unsigned Depth = 0); | | unsigned const &Depth = 0); | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 13 change blocks. |
| 21 lines changed or deleted | | 46 lines changed or added | |
|
| depcache.h | | depcache.h | |
| | | | |
| skipping to change at line 41 | | skipping to change at line 41 | |
| state (Delete, Keep, Install) field and can be either the Current Versio
n | | state (Delete, Keep, Install) field and can be either the Current Versio
n | |
| or the Candidate version. | | or the Candidate version. | |
| | | | |
| The Candidate version is what is shown the 'Install Version' field. | | The Candidate version is what is shown the 'Install Version' field. | |
| | | | |
| ##################################################################### */ | | ##################################################################### */ | |
| /*}}
}*/ | | /*}}
}*/ | |
| #ifndef PKGLIB_DEPCACHE_H | | #ifndef PKGLIB_DEPCACHE_H | |
| #define PKGLIB_DEPCACHE_H | | #define PKGLIB_DEPCACHE_H | |
| | | | |
|
| | | #include <apt-pkg/configuration.h> | |
| #include <apt-pkg/pkgcache.h> | | #include <apt-pkg/pkgcache.h> | |
| #include <apt-pkg/progress.h> | | #include <apt-pkg/progress.h> | |
|
| | | #include <apt-pkg/error.h> | |
| #include <regex.h> | | | |
| | | | |
| #include <vector> | | #include <vector> | |
| #include <memory> | | #include <memory> | |
|
| | | #include <set> | |
| | | | |
| class pkgDepCache : protected pkgCache::Namespace | | class pkgDepCache : protected pkgCache::Namespace | |
| { | | { | |
| public: | | public: | |
| | | | |
| /** \brief An arbitrary predicate on packages. */ | | /** \brief An arbitrary predicate on packages. */ | |
| class InRootSetFunc | | class InRootSetFunc | |
| { | | { | |
| public: | | public: | |
| virtual bool InRootSet(const pkgCache::PkgIterator &pkg) {return false
;}; | | virtual bool InRootSet(const pkgCache::PkgIterator &pkg) {return false
;}; | |
| | | | |
| skipping to change at line 80 | | skipping to change at line 81 | |
| * \param ver The version of the package that is to be marked. | | * \param ver The version of the package that is to be marked. | |
| * | | * | |
| * \param follow_recommends If \b true, recommendations of the | | * \param follow_recommends If \b true, recommendations of the | |
| * package will be recursively marked. | | * package will be recursively marked. | |
| * | | * | |
| * \param follow_suggests If \b true, suggestions of the package | | * \param follow_suggests If \b true, suggestions of the package | |
| * will be recursively marked. | | * will be recursively marked. | |
| */ | | */ | |
| void MarkPackage(const pkgCache::PkgIterator &pkg, | | void MarkPackage(const pkgCache::PkgIterator &pkg, | |
| const pkgCache::VerIterator &ver, | | const pkgCache::VerIterator &ver, | |
|
| bool follow_recommends, | | bool const &follow_recommends, | |
| bool follow_suggests); | | bool const &follow_suggests); | |
| | | | |
| /** \brief Update the Marked field of all packages. | | /** \brief Update the Marked field of all packages. | |
| * | | * | |
| * Each package's StateCache::Marked field will be set to \b true | | * Each package's StateCache::Marked field will be set to \b true | |
| * if and only if it can be reached from the root set. By | | * if and only if it can be reached from the root set. By | |
| * default, the root set consists of the set of manually installed | | * default, the root set consists of the set of manually installed | |
| * or essential packages, but it can be extended using the | | * or essential packages, but it can be extended using the | |
| * parameter #rootFunc. | | * parameter #rootFunc. | |
| * | | * | |
| * \param rootFunc A callback that can be used to add extra | | * \param rootFunc A callback that can be used to add extra | |
| | | | |
| skipping to change at line 185 | | skipping to change at line 186 | |
| * | | * | |
| * If this is the last action group, the automatic cache | | * If this is the last action group, the automatic cache | |
| * cleanup operations will be undertaken. | | * cleanup operations will be undertaken. | |
| */ | | */ | |
| ~ActionGroup(); | | ~ActionGroup(); | |
| }; | | }; | |
| | | | |
| /** \brief Returns \b true for packages matching a regular | | /** \brief Returns \b true for packages matching a regular | |
| * expression in APT::NeverAutoRemove. | | * expression in APT::NeverAutoRemove. | |
| */ | | */ | |
|
| class DefaultRootSetFunc : public InRootSetFunc | | class DefaultRootSetFunc : public InRootSetFunc, public Configuration::M
atchAgainstConfig | |
| { | | { | |
|
| std::vector<regex_t *> rootSetRegexp; | | | |
| bool constructedSuccessfully; | | | |
| | | | |
| public: | | public: | |
|
| DefaultRootSetFunc(); | | DefaultRootSetFunc() : Configuration::MatchAgainstConfig("APT::NeverRe | |
| ~DefaultRootSetFunc(); | | move") {}; | |
| | | virtual ~DefaultRootSetFunc() {}; | |
| /** \return \b true if the class initialized successfully, \b | | | |
| * false otherwise. Used to avoid throwing an exception, since | | | |
| * APT classes generally don't. | | | |
| */ | | | |
| bool wasConstructedSuccessfully() const { return constructedSuccessful | | | |
| ly; } | | | |
| | | | |
|
| bool InRootSet(const pkgCache::PkgIterator &pkg); | | bool InRootSet(const pkgCache::PkgIterator &pkg) { return pkg.end() ==
true && Match(pkg.Name()); }; | |
| }; | | }; | |
| | | | |
| struct StateCache | | struct StateCache | |
| { | | { | |
| // Epoch stripped text versions of the two version fields | | // Epoch stripped text versions of the two version fields | |
| const char *CandVersion; | | const char *CandVersion; | |
| const char *CurVersion; | | const char *CurVersion; | |
| | | | |
| // Pointer to the candidate install version. | | // Pointer to the candidate install version. | |
| Version *CandidateVer; | | Version *CandidateVer; | |
| | | | |
| skipping to change at line 267 | | skipping to change at line 259 | |
| | | | |
| // Helper functions | | // Helper functions | |
| void BuildGroupOrs(VerIterator const &V); | | void BuildGroupOrs(VerIterator const &V); | |
| void UpdateVerState(PkgIterator Pkg); | | void UpdateVerState(PkgIterator Pkg); | |
| | | | |
| // User Policy control | | // User Policy control | |
| class Policy | | class Policy | |
| { | | { | |
| public: | | public: | |
| | | | |
|
| virtual VerIterator GetCandidateVer(PkgIterator Pkg); | | virtual VerIterator GetCandidateVer(PkgIterator const &Pkg); | |
| virtual bool IsImportantDep(DepIterator Dep); | | virtual bool IsImportantDep(DepIterator const &Dep); | |
| | | | |
| virtual ~Policy() {}; | | virtual ~Policy() {}; | |
| }; | | }; | |
| | | | |
| private: | | private: | |
| /** The number of open "action groups"; certain post-action | | /** The number of open "action groups"; certain post-action | |
| * operations are suppressed if this number is > 0. | | * operations are suppressed if this number is > 0. | |
| */ | | */ | |
| int group_level; | | int group_level; | |
| | | | |
| friend class ActionGroup; | | friend class ActionGroup; | |
| | | | |
| protected: | | protected: | |
| | | | |
| // State information | | // State information | |
| pkgCache *Cache; | | pkgCache *Cache; | |
| StateCache *PkgState; | | StateCache *PkgState; | |
| unsigned char *DepState; | | unsigned char *DepState; | |
| | | | |
|
| double iUsrSize; | | /** Stores the space changes after installation */ | |
| double iDownloadSize; | | signed long long iUsrSize; | |
| | | /** Stores how much we need to download to get the packages */ | |
| | | unsigned long long iDownloadSize; | |
| unsigned long iInstCount; | | unsigned long iInstCount; | |
| unsigned long iDelCount; | | unsigned long iDelCount; | |
| unsigned long iKeepCount; | | unsigned long iKeepCount; | |
| unsigned long iBrokenCount; | | unsigned long iBrokenCount; | |
| unsigned long iPolicyBrokenCount; | | unsigned long iPolicyBrokenCount; | |
| unsigned long iBadCount; | | unsigned long iBadCount; | |
| | | | |
| bool DebugMarker; | | bool DebugMarker; | |
| bool DebugAutoInstall; | | bool DebugAutoInstall; | |
| | | | |
| | | | |
| skipping to change at line 322 | | skipping to change at line 316 | |
| unsigned char DependencyState(DepIterator &D); | | unsigned char DependencyState(DepIterator &D); | |
| unsigned char VersionState(DepIterator D,unsigned char Check, | | unsigned char VersionState(DepIterator D,unsigned char Check, | |
| unsigned char SetMin, | | unsigned char SetMin, | |
| unsigned char SetPolicy); | | unsigned char SetPolicy); | |
| | | | |
| // Recalculates various portions of the cache, call after changing somet
hing | | // Recalculates various portions of the cache, call after changing somet
hing | |
| void Update(DepIterator Dep); // Mostly internal | | void Update(DepIterator Dep); // Mostly internal | |
| void Update(PkgIterator const &P); | | void Update(PkgIterator const &P); | |
| | | | |
| // Count manipulators | | // Count manipulators | |
|
| void AddSizes(const PkgIterator &Pkg,signed long Mult = 1); | | void AddSizes(const PkgIterator &Pkg, bool const &Invert = false); | |
| inline void RemoveSizes(const PkgIterator &Pkg) {AddSizes(Pkg,-1);}; | | inline void RemoveSizes(const PkgIterator &Pkg) {AddSizes(Pkg, true);}; | |
| | | void AddSizes(const PkgIterator &Pkg,signed long Mult) __deprecated; | |
| void AddStates(const PkgIterator &Pkg,int Add = 1); | | void AddStates(const PkgIterator &Pkg,int Add = 1); | |
| inline void RemoveStates(const PkgIterator &Pkg) {AddStates(Pkg,-1);}; | | inline void RemoveStates(const PkgIterator &Pkg) {AddStates(Pkg,-1);}; | |
| | | | |
| public: | | public: | |
| | | | |
| // Legacy.. We look like a pkgCache | | // Legacy.. We look like a pkgCache | |
| inline operator pkgCache &() {return *Cache;}; | | inline operator pkgCache &() {return *Cache;}; | |
| inline Header &Head() {return *Cache->HeaderP;}; | | inline Header &Head() {return *Cache->HeaderP;}; | |
|
| | | inline GrpIterator GrpBegin() {return Cache->GrpBegin();}; | |
| inline PkgIterator PkgBegin() {return Cache->PkgBegin();}; | | inline PkgIterator PkgBegin() {return Cache->PkgBegin();}; | |
|
| | | inline GrpIterator FindGrp(string const &Name) {return Cache->FindGrp(Na
me);}; | |
| inline PkgIterator FindPkg(string const &Name) {return Cache->FindPkg(Na
me);}; | | inline PkgIterator FindPkg(string const &Name) {return Cache->FindPkg(Na
me);}; | |
|
| | | inline PkgIterator FindPkg(string const &Name, string const &Arch) {retu
rn Cache->FindPkg(Name, Arch);}; | |
| | | | |
| inline pkgCache &GetCache() {return *Cache;}; | | inline pkgCache &GetCache() {return *Cache;}; | |
| inline pkgVersioningSystem &VS() {return *Cache->VS;}; | | inline pkgVersioningSystem &VS() {return *Cache->VS;}; | |
| | | | |
| // Policy implementation | | // Policy implementation | |
|
| inline VerIterator GetCandidateVer(PkgIterator Pkg) {return LocalPolicy-
>GetCandidateVer(Pkg);}; | | inline VerIterator GetCandidateVer(PkgIterator const &Pkg) {return Local
Policy->GetCandidateVer(Pkg);}; | |
| inline bool IsImportantDep(DepIterator Dep) {return LocalPolicy->IsImpor
tantDep(Dep);}; | | inline bool IsImportantDep(DepIterator Dep) {return LocalPolicy->IsImpor
tantDep(Dep);}; | |
| inline Policy &GetPolicy() {return *LocalPolicy;}; | | inline Policy &GetPolicy() {return *LocalPolicy;}; | |
| | | | |
| // Accessors | | // Accessors | |
| inline StateCache &operator [](PkgIterator const &I) {return PkgState[I-
>ID];}; | | inline StateCache &operator [](PkgIterator const &I) {return PkgState[I-
>ID];}; | |
| inline unsigned char &operator [](DepIterator const &I) {return DepState
[I->ID];}; | | inline unsigned char &operator [](DepIterator const &I) {return DepState
[I->ID];}; | |
| | | | |
| /** \return A function identifying packages in the root set other | | /** \return A function identifying packages in the root set other | |
| * than manually installed packages and essential packages, or \b | | * than manually installed packages and essential packages, or \b | |
| * NULL if an error occurs. | | * NULL if an error occurs. | |
| | | | |
| skipping to change at line 400 | | skipping to change at line 398 | |
| // @{ | | // @{ | |
| void MarkKeep(PkgIterator const &Pkg, bool Soft = false, | | void MarkKeep(PkgIterator const &Pkg, bool Soft = false, | |
| bool FromUser = true, unsigned long Depth = 0); | | bool FromUser = true, unsigned long Depth = 0); | |
| void MarkDelete(PkgIterator const &Pkg, bool Purge = false, | | void MarkDelete(PkgIterator const &Pkg, bool Purge = false, | |
| unsigned long Depth = 0, bool FromUser = true); | | unsigned long Depth = 0, bool FromUser = true); | |
| void MarkInstall(PkgIterator const &Pkg,bool AutoInst = true, | | void MarkInstall(PkgIterator const &Pkg,bool AutoInst = true, | |
| unsigned long Depth = 0, bool FromUser = true, | | unsigned long Depth = 0, bool FromUser = true, | |
| bool ForceImportantDeps = false); | | bool ForceImportantDeps = false); | |
| | | | |
| void SetReInstall(PkgIterator const &Pkg,bool To); | | void SetReInstall(PkgIterator const &Pkg,bool To); | |
|
| void SetCandidateVersion(VerIterator TargetVer); | | void SetCandidateVersion(VerIterator TargetVer, bool const &Pseudo = tru
e); | |
| | | | |
| /** Set the "is automatically installed" flag of Pkg. */ | | /** Set the "is automatically installed" flag of Pkg. */ | |
| void MarkAuto(const PkgIterator &Pkg, bool Auto); | | void MarkAuto(const PkgIterator &Pkg, bool Auto); | |
| // @} | | // @} | |
| | | | |
| /** \return \b true if it's OK for MarkInstall to install | | /** \return \b true if it's OK for MarkInstall to install | |
| * the given package. | | * the given package. | |
| * | | * | |
| * See the default implementation for a simple example how this | | * See the default implementation for a simple example how this | |
| * method can be used. | | * method can be used. | |
| | | | |
| skipping to change at line 444 | | skipping to change at line 442 | |
| * | | * | |
| * The parameters are the same as in the calling MarkDelete: | | * The parameters are the same as in the calling MarkDelete: | |
| * \param Pkg the package that MarkDelete wants to remove. | | * \param Pkg the package that MarkDelete wants to remove. | |
| * \param Purge should we purge instead of "only" remove? | | * \param Purge should we purge instead of "only" remove? | |
| * \param Depth recursive deep of this Marker call | | * \param Depth recursive deep of this Marker call | |
| * \param FromUser was the remove requested by the user? | | * \param FromUser was the remove requested by the user? | |
| */ | | */ | |
| virtual bool IsDeleteOk(const PkgIterator &Pkg,bool Purge = false, | | virtual bool IsDeleteOk(const PkgIterator &Pkg,bool Purge = false, | |
| unsigned long Depth = 0, bool FromUser = true); | | unsigned long Depth = 0, bool FromUser = true); | |
| | | | |
|
| // This is for debuging | | | |
| void Update(OpProgress *Prog = 0); | | | |
| | | | |
| // read persistent states | | // read persistent states | |
| bool readStateFile(OpProgress *prog); | | bool readStateFile(OpProgress *prog); | |
|
| bool writeStateFile(OpProgress *prog, bool InstalledOnly=false); | | bool writeStateFile(OpProgress *prog, bool InstalledOnly=true); | |
| | | | |
| // Size queries | | // Size queries | |
|
| inline double UsrSize() {return iUsrSize;}; | | inline signed long long UsrSize() {return iUsrSize;}; | |
| inline double DebSize() {return iDownloadSize;}; | | inline unsigned long long DebSize() {return iDownloadSize;}; | |
| inline unsigned long DelCount() {return iDelCount;}; | | inline unsigned long DelCount() {return iDelCount;}; | |
| inline unsigned long KeepCount() {return iKeepCount;}; | | inline unsigned long KeepCount() {return iKeepCount;}; | |
| inline unsigned long InstCount() {return iInstCount;}; | | inline unsigned long InstCount() {return iInstCount;}; | |
| inline unsigned long BrokenCount() {return iBrokenCount;}; | | inline unsigned long BrokenCount() {return iBrokenCount;}; | |
| inline unsigned long PolicyBrokenCount() {return iPolicyBrokenCount;}; | | inline unsigned long PolicyBrokenCount() {return iPolicyBrokenCount;}; | |
| inline unsigned long BadCount() {return iBadCount;}; | | inline unsigned long BadCount() {return iBadCount;}; | |
| | | | |
| bool Init(OpProgress *Prog); | | bool Init(OpProgress *Prog); | |
|
| | | // Generate all state information | |
| | | void Update(OpProgress *Prog = 0); | |
| | | | |
| pkgDepCache(pkgCache *Cache,Policy *Plcy = 0); | | pkgDepCache(pkgCache *Cache,Policy *Plcy = 0); | |
| virtual ~pkgDepCache(); | | virtual ~pkgDepCache(); | |
|
| | | | |
| | | private: | |
| | | // Helper for Update(OpProgress) to remove pseudoinstalled arch all pack | |
| | | ages | |
| | | bool RemovePseudoInstalledPkg(PkgIterator &Pkg, std::set<unsigned long> | |
| | | &recheck); | |
| | | bool ReInstallPseudoForGroup(unsigned long const &Grp, std::set<unsigned | |
| | | long> &recheck); | |
| | | bool ReInstallPseudoForGroup(pkgCache::PkgIterator const &P, std::set<un | |
| | | signed long> &recheck); | |
| }; | | }; | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 21 change blocks. |
| 32 lines changed or deleted | | 39 lines changed or added | |
|
| error.h | | error.h | |
| | | | |
| skipping to change at line 45 | | skipping to change at line 45 | |
| This source is placed in the Public Domain, do with it what you will | | This source is placed in the Public Domain, do with it what you will | |
| It was originally written by Jason Gunthorpe. | | It was originally written by Jason Gunthorpe. | |
| | | | |
| ##################################################################### */ | | ##################################################################### */ | |
| /*}}
}*/ | | /*}}
}*/ | |
| #ifndef PKGLIB_ERROR_H | | #ifndef PKGLIB_ERROR_H | |
| #define PKGLIB_ERROR_H | | #define PKGLIB_ERROR_H | |
| | | | |
| #include <apt-pkg/macros.h> | | #include <apt-pkg/macros.h> | |
| | | | |
|
| | | #include <iostream> | |
| | | #include <list> | |
| #include <string> | | #include <string> | |
| | | | |
|
| class GlobalError | | #include <stdarg.h> | |
| | | | |
| | | class GlobalError /*{{ | |
| | | {*/ | |
| { | | { | |
|
| struct Item | | public: | |
| { | | /*{{{*/ | |
| std::string Text; | | /** \brief a message can have one of following severity */ | |
| bool Error; | | enum MsgType { | |
| Item *Next; | | /** \brief Message will be printed instantly as it is likely | |
| }; | | that | |
| | | this error will lead to a complete crash */ | |
| | | FATAL = 40, | |
| | | /** \brief An error does hinder the correct execution and sh | |
| | | ould be corrected */ | |
| | | ERROR = 30, | |
| | | /** \brief indicates problem that can lead to errors later o | |
| | | n */ | |
| | | WARNING = 20, | |
| | | /** \brief deprecation warnings, old fallback behavior, … */ | |
| | | NOTICE = 10, | |
| | | /** \brief for developers only in areas it is hard to print | |
| | | something directly */ | |
| | | DEBUG = 0 | |
| | | }; | |
| | | | |
|
| Item *List; | | /** \brief add a fatal error message with errno to the list | |
| bool PendingFlag; | | * | |
| void Insert(Item *I); | | * \param Function name of the function generating the error | |
| | | * \param Description format string for the error message | |
| | | * | |
| | | * \return \b false | |
| | | */ | |
| | | bool FatalE(const char *Function,const char *Description,...) __like | |
| | | _printf(3) __cold; | |
| | | | |
|
| public: | | /** \brief add an Error message with errno to the list | |
| | | * | |
| | | * \param Function name of the function generating the error | |
| | | * \param Description format string for the error message | |
| | | * | |
| | | * \return \b false | |
| | | */ | |
| | | bool Errno(const char *Function,const char *Description,...) __like_ | |
| | | printf(3) __cold; | |
| | | | |
|
| // Call to generate an error from a library call. | | /** \brief add a warning message with errno to the list | |
| bool Errno(const char *Function,const char *Description,...) __like_prin | | * | |
| tf_2 __cold; | | * A warning should be considered less severe than an error and | |
| bool WarningE(const char *Function,const char *Description,...) __like_p | | * may be ignored by the client. | |
| rintf_2 __cold; | | * | |
| | | * \param Function Name of the function generates the warning. | |
| | | * \param Description Format string for the warning message. | |
| | | * | |
| | | * \return \b false | |
| | | */ | |
| | | bool WarningE(const char *Function,const char *Description,...) __li | |
| | | ke_printf(3) __cold; | |
| | | | |
|
| /* A warning should be considered less severe than an error, and may be | | /** \brief add a notice message with errno to the list | |
| ignored by the client. */ | | * | |
| bool Error(const char *Description,...) __like_printf_1 __cold; | | * \param Function name of the function generating the error | |
| bool Warning(const char *Description,...) __like_printf_1 __cold; | | * \param Description format string for the error message | |
| | | * | |
| | | * \return \b false | |
| | | */ | |
| | | bool NoticeE(const char *Function,const char *Description,...) __lik | |
| | | e_printf(3) __cold; | |
| | | | |
|
| // Simple accessors | | /** \brief add a debug message with errno to the list | |
| inline bool PendingError() {return PendingFlag;}; | | * | |
| inline bool empty() {return List == 0;}; | | * \param Function name of the function generating the error | |
| bool PopMessage(std::string &Text); | | * \param Description format string for the error message | |
| void Discard(); | | * | |
| | | * \return \b false | |
| | | */ | |
| | | bool DebugE(const char *Function,const char *Description,...) __like | |
| | | _printf(3) __cold; | |
| | | | |
|
| // Usefull routine to dump to cerr | | /** \brief adds an errno message with the given type | |
| void DumpErrors(); | | * | |
| | | * \param type of the error message | |
| | | * \param Function which failed | |
| | | * \param Description of the error | |
| | | */ | |
| | | bool InsertErrno(MsgType const &type, const char* Function, | |
| | | const char* Description,...) __like_printf(4) __col | |
| | | d; | |
| | | | |
|
| GlobalError(); | | /** \brief add an fatal error message to the list | |
| | | * | |
| | | * Most of the stuff we consider as "error" is also "fatal" for | |
| | | * the user as the application will not have the expected result, | |
| | | * but a fatal message here means that it gets printed directly | |
| | | * to stderr in addiction to adding it to the list as the error | |
| | | * leads sometimes to crashes and a maybe duplicated message | |
| | | * is better than "Segfault" as the only displayed text | |
| | | * | |
| | | * \param Description Format string for the fatal error message. | |
| | | * | |
| | | * \return \b false | |
| | | */ | |
| | | bool Fatal(const char *Description,...) __like_printf(2) __cold; | |
| | | | |
| | | /** \brief add an Error message to the list | |
| | | * | |
| | | * \param Description Format string for the error message. | |
| | | * | |
| | | * \return \b false | |
| | | */ | |
| | | bool Error(const char *Description,...) __like_printf(2) __cold; | |
| | | | |
| | | /** \brief add a warning message to the list | |
| | | * | |
| | | * A warning should be considered less severe than an error and | |
| | | * may be ignored by the client. | |
| | | * | |
| | | * \param Description Format string for the message | |
| | | * | |
| | | * \return \b false | |
| | | */ | |
| | | bool Warning(const char *Description,...) __like_printf(2) __cold; | |
| | | | |
| | | /** \brief add a notice message to the list | |
| | | * | |
| | | * A notice should be considered less severe than an error or a | |
| | | * warning and can be ignored by the client without further problem | |
| | | s | |
| | | * for some times, but he should consider fixing the problem. | |
| | | * This error type can be used for e.g. deprecation warnings of opt | |
| | | ions. | |
| | | * | |
| | | * \param Description Format string for the message | |
| | | * | |
| | | * \return \b false | |
| | | */ | |
| | | bool Notice(const char *Description,...) __like_printf(2) __cold; | |
| | | | |
| | | /** \brief add a debug message to the list | |
| | | * | |
| | | * \param Description Format string for the message | |
| | | * | |
| | | * \return \b false | |
| | | */ | |
| | | bool Debug(const char *Description,...) __like_printf(2) __cold; | |
| | | | |
| | | /** \brief adds an error message with the given type | |
| | | * | |
| | | * \param type of the error message | |
| | | * \param Description of the error | |
| | | */ | |
| | | bool Insert(MsgType const &type, const char* Description,...) __like | |
| | | _printf(3) __cold; | |
| | | | |
| | | /** \brief is an error in the list? | |
| | | * | |
| | | * \return \b true if an error is included in the list, \b false ot | |
| | | herwise | |
| | | */ | |
| | | inline bool PendingError() const {return PendingFlag;}; | |
| | | | |
| | | /** \brief is the list empty? | |
| | | * | |
| | | * The default checks if the list is empty or contains only notices | |
| | | , | |
| | | * if you want to check if also no notices happend set the paramete | |
| | | r | |
| | | * flag to \b false. | |
| | | * | |
| | | * \param WithoutNotice does notices count, default is \b true, so | |
| | | no | |
| | | * | |
| | | * \return \b true if an the list is empty, \b false otherwise | |
| | | */ | |
| | | bool empty(MsgType const &trashhold = WARNING) const; | |
| | | | |
| | | /** \brief returns and removes the first (or last) message in the li | |
| | | st | |
| | | * | |
| | | * \param[out] Text message of the first/last item | |
| | | * | |
| | | * \return \b true if the message was an error, \b false otherwise | |
| | | */ | |
| | | bool PopMessage(std::string &Text); | |
| | | | |
| | | /** \brief clears the list of messages */ | |
| | | void Discard(); | |
| | | | |
| | | /** \brief outputs the list of messages to the given stream | |
| | | * | |
| | | * Note that all messages are discarded, also the notices | |
| | | * displayed or not. | |
| | | * | |
| | | * \param[out] out output stream to write the messages in | |
| | | * \param threshold minimim level considered | |
| | | * \param mergeStack | |
| | | */ | |
| | | void DumpErrors(std::ostream &out, MsgType const &threshold = WARNIN | |
| | | G, | |
| | | bool const &mergeStack = true); | |
| | | | |
| | | /** \brief dumps the list of messages to std::cerr | |
| | | * | |
| | | * Note that all messages are discarded, also the notices | |
| | | * displayed or not. | |
| | | * | |
| | | * \param threshold minimum level printed | |
| | | */ | |
| | | void inline DumpErrors(MsgType const &threshold) { | |
| | | DumpErrors(std::cerr, threshold); | |
| | | } | |
| | | | |
| | | // mvo: we do this instead of using a default parameter in the | |
| | | // previous declaration to avoid a (subtle) API break for | |
| | | // e.g. sigc++ and mem_fun0 | |
| | | /** \brief dumps the messages of type WARNING or higher to std::cerr | |
| | | * | |
| | | * Note that all messages are discarded, displayed or not. | |
| | | * | |
| | | */ | |
| | | void inline DumpErrors() { | |
| | | DumpErrors(WARNING); | |
| | | } | |
| | | | |
| | | /** \brief put the current Messages into the stack | |
| | | * | |
| | | * All "old" messages will be pushed into a stack to | |
| | | * them later back, but for now the Message query will be | |
| | | * empty and performs as no messages were present before. | |
| | | * | |
| | | * The stack can be as deep as you want - all stack operations | |
| | | * will only operate on the last element in the stack. | |
| | | */ | |
| | | void PushToStack(); | |
| | | | |
| | | /** \brief throw away all current messages */ | |
| | | void RevertToStack(); | |
| | | | |
| | | /** \brief merge current and stack together */ | |
| | | void MergeWithStack(); | |
| | | | |
| | | /** \brief return the deep of the stack */ | |
| | | size_t StackCount() const { | |
| | | return Stacks.size(); | |
| | | } | |
| | | | |
| | | GlobalError(); | |
| | | /*}} | |
| | | }*/ | |
| | | private: /*{{ | |
| | | {*/ | |
| | | struct Item { | |
| | | std::string Text; | |
| | | MsgType Type; | |
| | | | |
| | | Item(char const *Text, MsgType const &Type) : | |
| | | Text(Text), Type(Type) {}; | |
| | | | |
| | | friend std::ostream& operator<< (std::ostream &out, Item i) | |
| | | { | |
| | | switch(i.Type) { | |
| | | case FATAL: | |
| | | case ERROR: out << "E"; break; | |
| | | case WARNING: out << "W"; break; | |
| | | case NOTICE: out << "N"; break; | |
| | | case DEBUG: out << "D"; break; | |
| | | } | |
| | | return out << ": " << i.Text; | |
| | | } | |
| | | }; | |
| | | | |
| | | std::list<Item> Messages; | |
| | | bool PendingFlag; | |
| | | | |
| | | struct MsgStack { | |
| | | std::list<Item> const Messages; | |
| | | bool const PendingFlag; | |
| | | | |
| | | MsgStack(std::list<Item> const &Messages, bool const &Pendin | |
| | | g) : | |
| | | Messages(Messages), PendingFlag(Pending) {}; | |
| | | }; | |
| | | | |
| | | std::list<MsgStack> Stacks; | |
| | | | |
| | | bool InsertErrno(MsgType type, const char* Function, | |
| | | const char* Description, va_list &args); | |
| | | bool Insert(MsgType type, const char* Description, | |
| | | va_list &args); | |
| | | /*}} | |
| | | }*/ | |
| }; | | }; | |
|
| | | /*}}
}*/ | |
| | | | |
| // The 'extra-ansi' syntax is used to help with collisions. | | // The 'extra-ansi' syntax is used to help with collisions. | |
| GlobalError *_GetErrorObj(); | | GlobalError *_GetErrorObj(); | |
| #define _error _GetErrorObj() | | #define _error _GetErrorObj() | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 11 change blocks. |
| 28 lines changed or deleted | | 286 lines changed or added | |
|
| pkgcache.h | | pkgcache.h | |
| // -*- mode: cpp; mode: fold -*- | | // -*- mode: cpp; mode: fold -*- | |
| // Description /*{{
{*/ | | // Description /*{{
{*/ | |
|
| // $Id: pkgcache.h,v 1.25 2001/07/01 22:28:24 jgg Exp $ | | /**\file pkgcache.h | |
| /* ###################################################################### | | \brief pkgCache - Structure definitions for the cache file | |
| | | | |
|
| Cache - Structure definitions for the cache file | | The goal of the cache file is two fold: | |
| | | Firstly to speed loading and processing of the package file array and | |
| | | secondly to reduce memory consumption of the package file array. | |
| | | | |
|
| Please see doc/apt-pkg/cache.sgml for a more detailed description of | | The implementation is aimed at an environment with many primary package | |
| this format. Also be sure to keep that file up-to-date!! | | files, for instance someone that has a Package file for their CD-ROM, a | |
| | | Package file for the latest version of the distribution on the CD-ROM an | |
| | | d a | |
| | | package file for the development version. Always present is the informat | |
| | | ion | |
| | | contained in the status file which might be considered a separate packag | |
| | | e | |
| | | file. | |
| | | | |
|
| | | Please understand, this is designed as a <b>Cache file</b> it is not mea | |
| | | nt to be | |
| | | used on any system other than the one it was created for. It is not mean | |
| | | t to | |
| | | be authoritative either, i.e. if a system crash or software failure occu | |
| | | rs it | |
| | | must be perfectly acceptable for the cache file to be in an inconsistent | |
| | | state. Furthermore at any time the cache file may be erased without losi | |
| | | ng | |
| | | any information. | |
| | | | |
| | | Also the structures and storage layout is optimized for use by the APT | |
| | | and may not be suitable for all purposes. However it should be possible | |
| | | to extend it with associate cache files that contain other information. | |
| | | | |
| | | To keep memory use down the cache file only contains often used fields a | |
| | | nd | |
| | | fields that are inexpensive to store, the Package file has a full list o | |
| | | f | |
| | | fields. Also the client may assume that all items are perfectly valid an | |
| | | d | |
| | | need not perform checks against their correctness. Removal of informatio | |
| | | n | |
| | | from the cache is possible, but blanks will be left in the file, and | |
| | | unused strings will also be present. The recommended implementation is t | |
| | | o | |
| | | simply rebuild the cache each time any of the data files change. It is | |
| | | possible to add a new package file to the cache without any negative sid | |
| | | e | |
| | | effects. | |
| | | | |
| | | <b>Note on Pointer access</b> | |
| Clients should always use the CacheIterators classes for access to the | | Clients should always use the CacheIterators classes for access to the | |
|
| cache. They provide a simple STL-like method for traversing the links | | cache and the data in it. They also provide a simple STL-like method for | |
| of the datastructure. | | traversing the links of the datastructure. | |
| | | | |
|
| See pkgcachegen.h for information about generating cache structures. | | Every item in every structure is stored as the index to that structure. | |
| | | What this means is that once the files is mmaped every data access has t | |
| | | o | |
| | | go through a fix up stage to get a real memory pointer. This is done | |
| | | by taking the index, multiplying it by the type size and then adding | |
| | | it to the start address of the memory block. This sounds complex, but | |
| | | in C it is a single array dereference. Because all items are aligned to | |
| | | their size and indexes are stored as multiples of the size of the struct | |
| | | ure | |
| | | the format is immediately portable to all possible architectures - BUT t | |
| | | he | |
| | | generated files are -NOT-. | |
| | | | |
|
| ##################################################################### */ | | This scheme allows code like this to be written: | |
| | | <example> | |
| | | void *Map = mmap(...); | |
| | | Package *PkgList = (Package *)Map; | |
| | | Header *Head = (Header *)Map; | |
| | | char *Strings = (char *)Map; | |
| | | cout << (Strings + PkgList[Head->HashTable[0]]->Name) << endl; | |
| | | </example> | |
| | | Notice the lack of casting or multiplication. The net result is to retur | |
| | | n | |
| | | the name of the first package in the first hash bucket, without error | |
| | | checks. | |
| | | | |
| | | The generator uses allocation pools to group similarly sized structures | |
| | | in | |
| | | large blocks to eliminate any alignment overhead. The generator also | |
| | | assures that no structures overlap and all indexes are unique. Although | |
| | | at first glance it may seem like there is the potential for two structur | |
| | | es | |
| | | to exist at the same point the generator never allows this to happen. | |
| | | (See the discussion of free space pools) | |
| | | | |
| | | See \ref pkgcachegen.h for more information about generating cache struc | |
| | | tures. */ | |
| /*}}
}*/ | | /*}}
}*/ | |
| #ifndef PKGLIB_PKGCACHE_H | | #ifndef PKGLIB_PKGCACHE_H | |
| #define PKGLIB_PKGCACHE_H | | #define PKGLIB_PKGCACHE_H | |
| | | | |
| #include <string> | | #include <string> | |
| #include <time.h> | | #include <time.h> | |
| #include <apt-pkg/mmap.h> | | #include <apt-pkg/mmap.h> | |
| | | | |
| using std::string; | | using std::string; | |
| | | | |
| class pkgVersioningSystem; | | class pkgVersioningSystem; | |
| class pkgCache /*{{
{*/ | | class pkgCache /*{{
{*/ | |
| { | | { | |
| public: | | public: | |
| // Cache element predeclarations | | // Cache element predeclarations | |
| struct Header; | | struct Header; | |
|
| | | struct Group; | |
| struct Package; | | struct Package; | |
| struct PackageFile; | | struct PackageFile; | |
| struct Version; | | struct Version; | |
| struct Description; | | struct Description; | |
| struct Provides; | | struct Provides; | |
| struct Dependency; | | struct Dependency; | |
| struct StringItem; | | struct StringItem; | |
| struct VerFile; | | struct VerFile; | |
| struct DescFile; | | struct DescFile; | |
| | | | |
| // Iterators | | // Iterators | |
|
| | | template<typename Str, typename Itr> class Iterator; | |
| | | class GrpIterator; | |
| class PkgIterator; | | class PkgIterator; | |
| class VerIterator; | | class VerIterator; | |
| class DescIterator; | | class DescIterator; | |
| class DepIterator; | | class DepIterator; | |
| class PrvIterator; | | class PrvIterator; | |
| class PkgFileIterator; | | class PkgFileIterator; | |
| class VerFileIterator; | | class VerFileIterator; | |
| class DescFileIterator; | | class DescFileIterator; | |
|
| friend class PkgIterator; | | | |
| friend class VerIterator; | | | |
| friend class DescInterator; | | | |
| friend class DepIterator; | | | |
| friend class PrvIterator; | | | |
| friend class PkgFileIterator; | | | |
| friend class VerFileIterator; | | | |
| friend class DescFileIterator; | | | |
| | | | |
| class Namespace; | | class Namespace; | |
| | | | |
| // These are all the constants used in the cache structures | | // These are all the constants used in the cache structures | |
| | | | |
| // WARNING - if you change these lists you must also edit | | // WARNING - if you change these lists you must also edit | |
| // the stringification in pkgcache.cc and also consider whether | | // the stringification in pkgcache.cc and also consider whether | |
| // the cache file will become incompatible. | | // the cache file will become incompatible. | |
| struct Dep | | struct Dep | |
| { | | { | |
| enum DepType {Depends=1,PreDepends=2,Suggests=3,Recommends=4, | | enum DepType {Depends=1,PreDepends=2,Suggests=3,Recommends=4, | |
| Conflicts=5,Replaces=6,Obsoletes=7,DpkgBreaks=8,Enhances=9}; | | Conflicts=5,Replaces=6,Obsoletes=7,DpkgBreaks=8,Enhances=9}; | |
|
| | | /** \brief available compare operators | |
| | | | |
| | | The lower 4 bits are used to indicate what operator is being spec | |
| | | ified and | |
| | | the upper 4 bits are flags. OR indicates that the next package is | |
| | | or'd with the current package. */ | |
| enum DepCompareOp {Or=0x10,NoOp=0,LessEq=0x1,GreaterEq=0x2,Less=0x3, | | enum DepCompareOp {Or=0x10,NoOp=0,LessEq=0x1,GreaterEq=0x2,Less=0x3, | |
| Greater=0x4,Equals=0x5,NotEquals=0x6}; | | Greater=0x4,Equals=0x5,NotEquals=0x6}; | |
| }; | | }; | |
| | | | |
| struct State | | struct State | |
| { | | { | |
|
| | | /** \brief priority of a package version | |
| | | | |
| | | Zero is used for unparsable or absent Priority fields. */ | |
| enum VerPriority {Important=1,Required=2,Standard=3,Optional=4,Extra=
5}; | | enum VerPriority {Important=1,Required=2,Standard=3,Optional=4,Extra=
5}; | |
| enum PkgSelectedState {Unknown=0,Install=1,Hold=2,DeInstall=3,Purge=4
}; | | enum PkgSelectedState {Unknown=0,Install=1,Hold=2,DeInstall=3,Purge=4
}; | |
| enum PkgInstState {Ok=0,ReInstReq=1,HoldInst=2,HoldReInstReq=3}; | | enum PkgInstState {Ok=0,ReInstReq=1,HoldInst=2,HoldReInstReq=3}; | |
| enum PkgCurrentState {NotInstalled=0,UnPacked=1,HalfConfigured=2, | | enum PkgCurrentState {NotInstalled=0,UnPacked=1,HalfConfigured=2, | |
| HalfInstalled=4,ConfigFiles=5,Installed=6, | | HalfInstalled=4,ConfigFiles=5,Installed=6, | |
| TriggersAwaited=7,TriggersPending=8}; | | TriggersAwaited=7,TriggersPending=8}; | |
| }; | | }; | |
| | | | |
| struct Flag | | struct Flag | |
| { | | { | |
| | | | |
| skipping to change at line 106 | | skipping to change at line 164 | |
| string CacheFile; | | string CacheFile; | |
| MMap ⤅ | | MMap ⤅ | |
| | | | |
| unsigned long sHash(const string &S) const; | | unsigned long sHash(const string &S) const; | |
| unsigned long sHash(const char *S) const; | | unsigned long sHash(const char *S) const; | |
| | | | |
| public: | | public: | |
| | | | |
| // Pointers to the arrays of items | | // Pointers to the arrays of items | |
| Header *HeaderP; | | Header *HeaderP; | |
|
| | | Group *GrpP; | |
| Package *PkgP; | | Package *PkgP; | |
| VerFile *VerFileP; | | VerFile *VerFileP; | |
| DescFile *DescFileP; | | DescFile *DescFileP; | |
| PackageFile *PkgFileP; | | PackageFile *PkgFileP; | |
| Version *VerP; | | Version *VerP; | |
| Description *DescP; | | Description *DescP; | |
| Provides *ProvideP; | | Provides *ProvideP; | |
| Dependency *DepP; | | Dependency *DepP; | |
| StringItem *StringItemP; | | StringItem *StringItemP; | |
| char *StrP; | | char *StrP; | |
| | | | |
|
| virtual bool ReMap(); | | virtual bool ReMap(bool const &Errorchecks = true); | |
| inline bool Sync() {return Map.Sync();}; | | inline bool Sync() {return Map.Sync();}; | |
| inline MMap &GetMap() {return Map;}; | | inline MMap &GetMap() {return Map;}; | |
| inline void *DataEnd() {return ((unsigned char *)Map.Data()) + Map.Size(
);}; | | inline void *DataEnd() {return ((unsigned char *)Map.Data()) + Map.Size(
);}; | |
| | | | |
| // String hashing function (512 range) | | // String hashing function (512 range) | |
| inline unsigned long Hash(const string &S) const {return sHash(S);}; | | inline unsigned long Hash(const string &S) const {return sHash(S);}; | |
| inline unsigned long Hash(const char *S) const {return sHash(S);}; | | inline unsigned long Hash(const char *S) const {return sHash(S);}; | |
| | | | |
|
| // Usefull transformation things | | // Useful transformation things | |
| const char *Priority(unsigned char Priority); | | const char *Priority(unsigned char Priority); | |
| | | | |
| // Accessors | | // Accessors | |
|
| | | GrpIterator FindGrp(const string &Name); | |
| PkgIterator FindPkg(const string &Name); | | PkgIterator FindPkg(const string &Name); | |
|
| | | PkgIterator FindPkg(const string &Name, const string &Arch); | |
| | | | |
| Header &Head() {return *HeaderP;}; | | Header &Head() {return *HeaderP;}; | |
|
| | | inline GrpIterator GrpBegin(); | |
| | | inline GrpIterator GrpEnd(); | |
| inline PkgIterator PkgBegin(); | | inline PkgIterator PkgBegin(); | |
| inline PkgIterator PkgEnd(); | | inline PkgIterator PkgEnd(); | |
| inline PkgFileIterator FileBegin(); | | inline PkgFileIterator FileBegin(); | |
| inline PkgFileIterator FileEnd(); | | inline PkgFileIterator FileEnd(); | |
| | | | |
|
| | | inline bool MultiArchCache() const { return MultiArchEnabled; }; | |
| | | | |
| // Make me a function | | // Make me a function | |
| pkgVersioningSystem *VS; | | pkgVersioningSystem *VS; | |
| | | | |
| // Converters | | // Converters | |
| static const char *CompTypeDeb(unsigned char Comp); | | static const char *CompTypeDeb(unsigned char Comp); | |
| static const char *CompType(unsigned char Comp); | | static const char *CompType(unsigned char Comp); | |
| static const char *DepType(unsigned char Dep); | | static const char *DepType(unsigned char Dep); | |
| | | | |
| pkgCache(MMap *Map,bool DoMap = true); | | pkgCache(MMap *Map,bool DoMap = true); | |
| virtual ~pkgCache() {}; | | virtual ~pkgCache() {}; | |
|
| | | | |
| | | private: | |
| | | bool MultiArchEnabled; | |
| | | PkgIterator SingleArchFindPkg(const string &Name); | |
| }; | | }; | |
| /*}}
}*/ | | /*}}
}*/ | |
| // Header structure /*{{
{*/ | | // Header structure /*{{
{*/ | |
| struct pkgCache::Header | | struct pkgCache::Header | |
| { | | { | |
|
| // Signature information | | /** \brief Signature information | |
| | | | |
| | | This must contain the hex value 0x98FE76DC which is designed to | |
| | | verify that the system loading the image has the same byte order | |
| | | and byte size as the system saving the image */ | |
| unsigned long Signature; | | unsigned long Signature; | |
|
| | | /** These contain the version of the cache file */ | |
| short MajorVersion; | | short MajorVersion; | |
| short MinorVersion; | | short MinorVersion; | |
|
| | | /** \brief indicates if the cache should be erased | |
| | | | |
| | | Dirty is true if the cache file was opened for reading, the client | |
| | | expects to have written things to it and have not fully synced it. | |
| | | The file should be erased and rebuilt if it is true. */ | |
| bool Dirty; | | bool Dirty; | |
| | | | |
|
| // Size of structure values | | /** \brief Size of structure values | |
| | | | |
| | | All *Sz variables contains the sizeof() that particular structure. | |
| | | It is used as an extra consistency check on the structure of the fil | |
| | | e. | |
| | | | |
| | | If any of the size values do not exactly match what the client expec | |
| | | ts | |
| | | then the client should refuse the load the file. */ | |
| unsigned short HeaderSz; | | unsigned short HeaderSz; | |
|
| | | unsigned short GroupSz; | |
| unsigned short PackageSz; | | unsigned short PackageSz; | |
| unsigned short PackageFileSz; | | unsigned short PackageFileSz; | |
| unsigned short VersionSz; | | unsigned short VersionSz; | |
| unsigned short DescriptionSz; | | unsigned short DescriptionSz; | |
| unsigned short DependencySz; | | unsigned short DependencySz; | |
| unsigned short ProvidesSz; | | unsigned short ProvidesSz; | |
| unsigned short VerFileSz; | | unsigned short VerFileSz; | |
| unsigned short DescFileSz; | | unsigned short DescFileSz; | |
| | | | |
|
| // Structure counts | | /** \brief Structure counts | |
| | | | |
| | | These indicate the number of each structure contained in the cache. | |
| | | PackageCount is especially useful for generating user state structur | |
| | | es. | |
| | | See Package::Id for more info. */ | |
| | | unsigned long GroupCount; | |
| unsigned long PackageCount; | | unsigned long PackageCount; | |
| unsigned long VersionCount; | | unsigned long VersionCount; | |
| unsigned long DescriptionCount; | | unsigned long DescriptionCount; | |
| unsigned long DependsCount; | | unsigned long DependsCount; | |
| unsigned long PackageFileCount; | | unsigned long PackageFileCount; | |
| unsigned long VerFileCount; | | unsigned long VerFileCount; | |
| unsigned long DescFileCount; | | unsigned long DescFileCount; | |
| unsigned long ProvidesCount; | | unsigned long ProvidesCount; | |
| | | | |
|
| // Offsets | | /** \brief index of the first PackageFile structure | |
| map_ptrloc FileList; // struct PackageFile | | | |
| map_ptrloc StringList; // struct StringItem | | The PackageFile structures are singly linked lists that represent | |
| map_ptrloc VerSysName; // StringTable | | all package files that have been merged into the cache. */ | |
| map_ptrloc Architecture; // StringTable | | map_ptrloc FileList; | |
| | | /** \brief index of the first StringItem structure | |
| | | | |
| | | The cache contains a list of all the unique strings (StringItems). | |
| | | The parser reads this list into memory so it can match strings | |
| | | against it.*/ | |
| | | map_ptrloc StringList; | |
| | | /** \brief String representing the version system used */ | |
| | | map_ptrloc VerSysName; | |
| | | /** \brief Architecture(s) the cache was built against */ | |
| | | map_ptrloc Architecture; | |
| | | /** \brief The maximum size of a raw entry from the original Package fil | |
| | | e */ | |
| unsigned long MaxVerFileSize; | | unsigned long MaxVerFileSize; | |
|
| | | /** \brief The maximum size of a raw entry from the original Translation
file */ | |
| unsigned long MaxDescFileSize; | | unsigned long MaxDescFileSize; | |
| | | | |
|
| /* Allocation pools, there should be one of these for each structure | | /** \brief The Pool structures manage the allocation pools that the gene | |
| excluding the header */ | | rator uses | |
| DynamicMMap::Pool Pools[8]; | | | |
| | | | |
|
| // Rapid package name lookup | | Start indicates the first byte of the pool, Count is the number of o | |
| map_ptrloc HashTable[2*1048]; | | bjects | |
| | | remaining in the pool and ItemSize is the structure size (alignment | |
| | | factor) | |
| | | of the pool. An ItemSize of 0 indicates the pool is empty. There sho | |
| | | uld be | |
| | | the same number of pools as there are structure types. The generator | |
| | | stores this information so future additions can make use of any unus | |
| | | ed pool | |
| | | blocks. */ | |
| | | DynamicMMap::Pool Pools[9]; | |
| | | | |
| | | /** \brief hash tables providing rapid group/package name lookup | |
| | | | |
| | | Each group/package name is inserted into the hash table using pkgCac | |
| | | he::Hash(const &string) | |
| | | By iterating over each entry in the hash table it is possible to ite | |
| | | rate over | |
| | | the entire list of packages. Hash Collisions are handled with a sing | |
| | | ly linked | |
| | | list of packages based at the hash item. The linked list contains on | |
| | | ly | |
| | | packages that match the hashing function. | |
| | | In the PkgHashTable is it possible that multiple packages have the s | |
| | | ame name - | |
| | | these packages are stored as a sequence in the list. | |
| | | | |
| | | Beware: The Hashmethod assumes that the hash table sizes are equal * | |
| | | / | |
| | | map_ptrloc PkgHashTable[2*1048]; | |
| | | map_ptrloc GrpHashTable[2*1048]; | |
| | | | |
| bool CheckSizes(Header &Against) const; | | bool CheckSizes(Header &Against) const; | |
| Header(); | | Header(); | |
| }; | | }; | |
| /*}}
}*/ | | /*}}
}*/ | |
|
| struct pkgCache::Package /*{{ | | // Group structure /*{{ | |
| {*/ | | {*/ | |
| | | /** \brief groups architecture depending packages together | |
| | | | |
| | | On or more packages with the same name form a group, so we have | |
| | | a simple way to access a package built for different architectures | |
| | | Group exists in a singly linked list of group records starting at | |
| | | the hash index of the name in the pkgCache::Header::GrpHashTable */ | |
| | | struct pkgCache::Group | |
| { | | { | |
|
| // Pointers | | /** \brief Name of the group */ | |
| map_ptrloc Name; // Stringtable | | map_ptrloc Name; // StringItem | |
| | | | |
| | | // Linked List | |
| | | /** \brief Link to the first package which belongs to the group */ | |
| | | map_ptrloc FirstPackage; // Package | |
| | | /** \brief Link to the last package which belongs to the group */ | |
| | | map_ptrloc LastPackage; // Package | |
| | | /** \brief Link to the next Group */ | |
| | | map_ptrloc Next; // Group | |
| | | /** \brief unique sequel ID */ | |
| | | unsigned int ID; | |
| | | | |
| | | }; | |
| | | /*}} | |
| | | }*/ | |
| | | // Package structure /*{{ | |
| | | {*/ | |
| | | /** \brief contains information for a single unique package | |
| | | | |
| | | There can be any number of versions of a given package. | |
| | | Package exists in a singly linked list of package records starting at | |
| | | the hash index of the name in the pkgCache::Header::PkgHashTable | |
| | | | |
| | | A package can be created for every architecture so package names are | |
| | | not unique, but it is garanteed that packages with the same name | |
| | | are sequencel ordered in the list. Packages with the same name can be | |
| | | accessed with the Group. | |
| | | */ | |
| | | struct pkgCache::Package | |
| | | { | |
| | | /** \brief Name of the package */ | |
| | | map_ptrloc Name; // StringItem | |
| | | /** \brief Architecture of the package */ | |
| | | map_ptrloc Arch; // StringItem | |
| | | /** \brief Base of a singly linked list of versions | |
| | | | |
| | | Each structure represents a unique version of the package. | |
| | | The version structures contain links into PackageFile and the | |
| | | original text file as well as detailed information about the size | |
| | | and dependencies of the specific package. In this way multiple | |
| | | versions of a package can be cleanly handled by the system. | |
| | | Furthermore, this linked list is guaranteed to be sorted | |
| | | from Highest version to lowest version with no duplicate entries. */ | |
| map_ptrloc VersionList; // Version | | map_ptrloc VersionList; // Version | |
|
| | | /** \brief index to the installed version */ | |
| map_ptrloc CurrentVer; // Version | | map_ptrloc CurrentVer; // Version | |
|
| map_ptrloc Section; // StringTable (StringItem) | | /** \brief indicates the deduced section | |
| | | | |
| | | Should be the index to the string "Unknown" or to the section | |
| | | of the last parsed item. */ | |
| | | map_ptrloc Section; // StringItem | |
| | | /** \brief index of the group this package belongs to */ | |
| | | map_ptrloc Group; // Group the Package belongs to | |
| | | | |
| // Linked list | | // Linked list | |
|
| | | /** \brief Link to the next package in the same bucket */ | |
| map_ptrloc NextPackage; // Package | | map_ptrloc NextPackage; // Package | |
|
| | | /** \brief List of all dependencies on this package */ | |
| map_ptrloc RevDepends; // Dependency | | map_ptrloc RevDepends; // Dependency | |
|
| | | /** \brief List of all "packages" this package provide */ | |
| map_ptrloc ProvidesList; // Provides | | map_ptrloc ProvidesList; // Provides | |
| | | | |
| // Install/Remove/Purge etc | | // Install/Remove/Purge etc | |
|
| | | /** \brief state that the user wishes the package to be in */ | |
| unsigned char SelectedState; // What | | unsigned char SelectedState; // What | |
|
| | | /** \brief installation state of the package | |
| | | | |
| | | This should be "ok" but in case the installation failed | |
| | | it will be different. | |
| | | */ | |
| unsigned char InstState; // Flags | | unsigned char InstState; // Flags | |
|
| | | /** \brief indicates if the package is installed */ | |
| unsigned char CurrentState; // State | | unsigned char CurrentState; // State | |
| | | | |
|
| | | /** \brief unique sequel ID | |
| | | | |
| | | ID is a unique value from 0 to Header->PackageCount assigned by the | |
| | | generator. | |
| | | This allows clients to create an array of size PackageCount and use | |
| | | it to store | |
| | | state information for the package map. For instance the status file | |
| | | emitter uses | |
| | | this to track which packages have been emitted already. */ | |
| unsigned int ID; | | unsigned int ID; | |
|
| | | /** \brief some useful indicators of the package's state */ | |
| unsigned long Flags; | | unsigned long Flags; | |
| }; | | }; | |
| /*}}
}*/ | | /*}}
}*/ | |
|
| struct pkgCache::PackageFile /*{{ | | // Package File structure /*{{ | |
| {*/ | | {*/ | |
| | | /** \brief stores information about the files used to generate the cache | |
| | | | |
| | | Package files are referenced by Version structures to be able to know | |
| | | after the generation still from which Packages file includes this Versi | |
| | | on | |
| | | as we need this information later on e.g. for pinning. */ | |
| | | struct pkgCache::PackageFile | |
| { | | { | |
|
| // Names | | /** \brief physical disk file that this PackageFile represents */ | |
| map_ptrloc FileName; // Stringtable | | map_ptrloc FileName; // StringItem | |
| map_ptrloc Archive; // Stringtable | | /** \brief the release information | |
| map_ptrloc Codename; // Stringtable | | | |
| map_ptrloc Component; // Stringtable | | Please see the files document for a description of what the | |
| map_ptrloc Version; // Stringtable | | release information means. */ | |
| map_ptrloc Origin; // Stringtable | | map_ptrloc Archive; // StringItem | |
| map_ptrloc Label; // Stringtable | | map_ptrloc Codename; // StringItem | |
| map_ptrloc Architecture; // Stringtable | | map_ptrloc Component; // StringItem | |
| map_ptrloc Site; // Stringtable | | map_ptrloc Version; // StringItem | |
| map_ptrloc IndexType; // Stringtable | | map_ptrloc Origin; // StringItem | |
| | | map_ptrloc Label; // StringItem | |
| | | map_ptrloc Architecture; // StringItem | |
| | | /** \brief The site the index file was fetched from */ | |
| | | map_ptrloc Site; // StringItem | |
| | | /** \brief indicates what sort of index file this is | |
| | | | |
| | | @TODO enumerate at least the possible indexes */ | |
| | | map_ptrloc IndexType; // StringItem | |
| | | /** \brief Size of the file | |
| | | | |
| | | Used together with the modification time as a | |
| | | simple check to ensure that the Packages | |
| | | file has not been altered since Cache generation. */ | |
| unsigned long Size; | | unsigned long Size; | |
|
| | | /** \brief Modification time for the file */ | |
| | | time_t mtime; | |
| | | | |
| | | /* @TODO document PackageFile::Flags */ | |
| unsigned long Flags; | | unsigned long Flags; | |
| | | | |
| // Linked list | | // Linked list | |
|
| | | /** \brief Link to the next PackageFile in the Cache */ | |
| map_ptrloc NextFile; // PackageFile | | map_ptrloc NextFile; // PackageFile | |
|
| | | /** \brief unique sequel ID */ | |
| unsigned int ID; | | unsigned int ID; | |
|
| time_t mtime; // Modification time for the file | | | |
| }; | | }; | |
| /*}}
}*/ | | /*}}
}*/ | |
|
| struct pkgCache::VerFile /*{{ | | // VerFile structure /*{{ | |
| {*/ | | {*/ | |
| | | /** \brief associates a version with a PackageFile | |
| | | | |
| | | This allows a full description of all Versions in all files | |
| | | (and hence all sources) under consideration. */ | |
| | | struct pkgCache::VerFile | |
| { | | { | |
|
| | | /** \brief index of the package file that this version was found in */ | |
| map_ptrloc File; // PackageFile | | map_ptrloc File; // PackageFile | |
|
| | | /** \brief next step in the linked list */ | |
| map_ptrloc NextFile; // PkgVerFile | | map_ptrloc NextFile; // PkgVerFile | |
|
| | | /** \brief position in the package file */ | |
| map_ptrloc Offset; // File offset | | map_ptrloc Offset; // File offset | |
|
| unsigned short Size; | | /* @TODO document pkgCache::VerFile::Size */ | |
| | | unsigned long Size; | |
| }; | | }; | |
| /*}}
}*/ | | /*}}
}*/ | |
|
| struct pkgCache::DescFile /*{{ | | // DescFile structure /*{{ | |
| {*/ | | {*/ | |
| | | /** \brief associates a description with a Translation file */ | |
| | | struct pkgCache::DescFile | |
| { | | { | |
|
| | | /** \brief index of the file that this description was found in */ | |
| map_ptrloc File; // PackageFile | | map_ptrloc File; // PackageFile | |
|
| | | /** \brief next step in the linked list */ | |
| map_ptrloc NextFile; // PkgVerFile | | map_ptrloc NextFile; // PkgVerFile | |
|
| | | /** \brief position in the file */ | |
| map_ptrloc Offset; // File offset | | map_ptrloc Offset; // File offset | |
|
| unsigned short Size; | | /* @TODO document pkgCache::DescFile::Size */ | |
| | | unsigned long Size; | |
| }; | | }; | |
| /*}}
}*/ | | /*}}
}*/ | |
|
| struct pkgCache::Version /*{{ | | // Version structure /*{{ | |
| {*/ | | {*/ | |
| | | /** \brief information for a single version of a package | |
| | | | |
| | | The version list is always sorted from highest version to lowest | |
| | | version by the generator. Equal version numbers are either merged | |
| | | or handled as separate versions based on the Hash value. */ | |
| | | struct pkgCache::Version | |
| { | | { | |
|
| map_ptrloc VerStr; // Stringtable | | /** \brief complete version string */ | |
| map_ptrloc Section; // StringTable (StringItem) | | map_ptrloc VerStr; // StringItem | |
| map_ptrloc Arch; // StringTable | | /** \brief section this version is filled in */ | |
| | | map_ptrloc Section; // StringItem | |
| | | /** \brief stores the MultiArch capabilities of this version | |
| | | | |
|
| // Lists | | None is the default and doesn't trigger special behaviour, | |
| | | Foreign means that this version can fulfill dependencies even | |
| | | if it is built for another architecture as the requester. | |
| | | Same indicates that builds for different architectures can | |
| | | be co-installed on the system and All is the marker for a | |
| | | version with the Architecture: all. */ | |
| | | enum {None, All, Foreign, Same, Allowed} MultiArch; | |
| | | | |
| | | /** \brief references all the PackageFile's that this version came from | |
| | | | |
| | | FileList can be used to determine what distribution(s) the Version | |
| | | applies to. If FileList is 0 then this is a blank version. | |
| | | The structure should also have a 0 in all other fields excluding | |
| | | pkgCache::Version::VerStr and Possibly pkgCache::Version::NextVer. * | |
| | | / | |
| map_ptrloc FileList; // VerFile | | map_ptrloc FileList; // VerFile | |
|
| | | /** \brief next (lower or equal) version in the linked list */ | |
| map_ptrloc NextVer; // Version | | map_ptrloc NextVer; // Version | |
|
| | | /** \brief next description in the linked list */ | |
| map_ptrloc DescriptionList; // Description | | map_ptrloc DescriptionList; // Description | |
|
| | | /** \brief base of the dependency list */ | |
| map_ptrloc DependsList; // Dependency | | map_ptrloc DependsList; // Dependency | |
|
| | | /** \brief links to the owning package | |
| | | | |
| | | This allows reverse dependencies to determine the package */ | |
| map_ptrloc ParentPkg; // Package | | map_ptrloc ParentPkg; // Package | |
|
| | | /** \brief list of pkgCache::Provides */ | |
| map_ptrloc ProvidesList; // Provides | | map_ptrloc ProvidesList; // Provides | |
| | | | |
|
| map_ptrloc Size; // These are the .deb size | | /** \brief archive size for this version | |
| map_ptrloc InstalledSize; | | | |
| | | For Debian this is the size of the .deb file. */ | |
| | | unsigned long long Size; // These are the .deb size | |
| | | /** \brief uncompressed size for this version */ | |
| | | unsigned long long InstalledSize; | |
| | | /** \brief characteristic value representing this version | |
| | | | |
| | | No two packages in existence should have the same VerStr | |
| | | and Hash with different contents. */ | |
| unsigned short Hash; | | unsigned short Hash; | |
|
| | | /** \brief unique sequel ID */ | |
| unsigned int ID; | | unsigned int ID; | |
|
| | | /** \brief parsed priority value */ | |
| unsigned char Priority; | | unsigned char Priority; | |
| }; | | }; | |
| /*}}
}*/ | | /*}}
}*/ | |
|
| struct pkgCache::Description /*{{ | | // Description structure /*{{ | |
| {*/ | | {*/ | |
| | | /** \brief datamember of a linked list of available description for a versi | |
| | | on */ | |
| | | struct pkgCache::Description | |
| { | | { | |
|
| // Language Code store the description translation language code. If | | /** \brief Language code of this description (translation) | |
| // the value has a 0 lenght then this is readed using the Package | | | |
| // file else the Translation-CODE are used. | | | |
| map_ptrloc language_code; // StringTable | | | |
| map_ptrloc md5sum; // StringTable | | | |
| | | | |
|
| // Linked list | | If the value has a 0 length then this is read using the Package | |
| | | file else the Translation-CODE file is used. */ | |
| | | map_ptrloc language_code; // StringItem | |
| | | /** \brief MD5sum of the original description | |
| | | | |
| | | Used to map Translations of a description to a version | |
| | | and to check that the Translation is up-to-date. */ | |
| | | map_ptrloc md5sum; // StringItem | |
| | | | |
| | | /* @TODO document pkgCache::Description::FileList */ | |
| map_ptrloc FileList; // DescFile | | map_ptrloc FileList; // DescFile | |
|
| | | /** \brief next translation for this description */ | |
| map_ptrloc NextDesc; // Description | | map_ptrloc NextDesc; // Description | |
|
| | | /** \brief the text is a description of this package */ | |
| map_ptrloc ParentPkg; // Package | | map_ptrloc ParentPkg; // Package | |
| | | | |
|
| | | /** \brief unique sequel ID */ | |
| unsigned int ID; | | unsigned int ID; | |
| }; | | }; | |
| /*}}
}*/ | | /*}}
}*/ | |
|
| struct pkgCache::Dependency /*{{ | | // Dependency structure | |
| {*/ | | /*{{{*/ | |
| | | /** \brief information for a single dependency record | |
| | | | |
| | | The records are split up like this to ease processing by the client. | |
| | | The base of the linked list is pkgCache::Version::DependsList. | |
| | | All forms of dependencies are recorded here including Depends, | |
| | | Recommends, Suggests, Enhances, Conflicts, Replaces and Breaks. */ | |
| | | struct pkgCache::Dependency | |
| { | | { | |
|
| map_ptrloc Version; // Stringtable | | /** \brief string of the version the dependency is applied against */ | |
| | | map_ptrloc Version; // StringItem | |
| | | /** \brief index of the package this depends applies to | |
| | | | |
| | | The generator will - if the package does not already exist - | |
| | | create a blank (no version records) package. */ | |
| map_ptrloc Package; // Package | | map_ptrloc Package; // Package | |
|
| | | /** \brief next dependency of this version */ | |
| map_ptrloc NextDepends; // Dependency | | map_ptrloc NextDepends; // Dependency | |
|
| | | /** \brief next reverse dependency of this package */ | |
| map_ptrloc NextRevDepends; // Dependency | | map_ptrloc NextRevDepends; // Dependency | |
|
| | | /** \brief version of the package which has the reverse depends */ | |
| map_ptrloc ParentVer; // Version | | map_ptrloc ParentVer; // Version | |
| | | | |
|
| // Specific types of depends | | /** \brief unique sequel ID */ | |
| map_ptrloc ID; | | map_ptrloc ID; | |
|
| | | /** \brief Dependency type - Depends, Recommends, Conflicts, etc */ | |
| unsigned char Type; | | unsigned char Type; | |
|
| | | /** \brief comparison operator specified on the depends line | |
| | | | |
| | | If the high bit is set then it is a logical OR with the previous rec | |
| | | ord. */ | |
| unsigned char CompareOp; | | unsigned char CompareOp; | |
| }; | | }; | |
| /*}}
}*/ | | /*}}
}*/ | |
|
| struct pkgCache::Provides /*{{ | | // Provides structure /*{{ | |
| {*/ | | {*/ | |
| | | /** \brief handles virtual packages | |
| | | | |
| | | When a Provides: line is encountered a new provides record is added | |
| | | associating the package with a virtual package name. | |
| | | The provides structures are linked off the package structures. | |
| | | This simplifies the analysis of dependencies and other aspects A provid | |
| | | es | |
| | | refers to a specific version of a specific package, not all versions ne | |
| | | ed to | |
| | | provide that provides.*/ | |
| | | struct pkgCache::Provides | |
| { | | { | |
|
| map_ptrloc ParentPkg; // Pacakge | | /** \brief index of the package providing this */ | |
| | | map_ptrloc ParentPkg; // Package | |
| | | /** \brief index of the version this provide line applies to */ | |
| map_ptrloc Version; // Version | | map_ptrloc Version; // Version | |
|
| map_ptrloc ProvideVersion; // Stringtable | | /** \brief version in the provides line (if any) | |
| | | | |
| | | This version allows dependencies to depend on specific versions of a | |
| | | Provides, as well as allowing Provides to override existing packages | |
| | | . | |
| | | This is experimental. Note that Debian doesn't allow versioned provi | |
| | | des */ | |
| | | map_ptrloc ProvideVersion; // StringItem | |
| | | /** \brief next provides (based of package) */ | |
| map_ptrloc NextProvides; // Provides | | map_ptrloc NextProvides; // Provides | |
|
| | | /** \brief next provides (based of version) */ | |
| map_ptrloc NextPkgProv; // Provides | | map_ptrloc NextPkgProv; // Provides | |
| }; | | }; | |
| /*}}
}*/ | | /*}}
}*/ | |
|
| struct pkgCache::StringItem /*{{ | | // StringItem structure | |
| {*/ | | /*{{{*/ | |
| | | /** \brief used for generating single instances of strings | |
| | | | |
| | | Some things like Section Name are are useful to have as unique tags. | |
| | | It is part of a linked list based at pkgCache::Header::StringList | |
| | | | |
| | | All strings are simply inlined any place in the file that is natural | |
| | | for the writer. The client should make no assumptions about the positio | |
| | | ning | |
| | | of strings. All StringItems should be null-terminated. */ | |
| | | struct pkgCache::StringItem | |
| { | | { | |
|
| map_ptrloc String; // Stringtable | | /** \brief string this refers to */ | |
| | | map_ptrloc String; // StringItem | |
| | | /** \brief Next link in the chain */ | |
| map_ptrloc NextItem; // StringItem | | map_ptrloc NextItem; // StringItem | |
| }; | | }; | |
| /*}}
}*/ | | /*}}
}*/ | |
| #include <apt-pkg/cacheiterators.h> | | #include <apt-pkg/cacheiterators.h> | |
| | | | |
|
| | | inline pkgCache::GrpIterator pkgCache::GrpBegin() | |
| | | {return GrpIterator(*this);}; | |
| | | inline pkgCache::GrpIterator pkgCache::GrpEnd() | |
| | | {return GrpIterator(*this,GrpP);}; | |
| inline pkgCache::PkgIterator pkgCache::PkgBegin() | | inline pkgCache::PkgIterator pkgCache::PkgBegin() | |
| {return PkgIterator(*this);}; | | {return PkgIterator(*this);}; | |
| inline pkgCache::PkgIterator pkgCache::PkgEnd() | | inline pkgCache::PkgIterator pkgCache::PkgEnd() | |
| {return PkgIterator(*this,PkgP);}; | | {return PkgIterator(*this,PkgP);}; | |
| inline pkgCache::PkgFileIterator pkgCache::FileBegin() | | inline pkgCache::PkgFileIterator pkgCache::FileBegin() | |
| {return PkgFileIterator(*this,PkgFileP + HeaderP->FileList);}; | | {return PkgFileIterator(*this,PkgFileP + HeaderP->FileList);}; | |
| inline pkgCache::PkgFileIterator pkgCache::FileEnd() | | inline pkgCache::PkgFileIterator pkgCache::FileEnd() | |
| {return PkgFileIterator(*this,PkgFileP);}; | | {return PkgFileIterator(*this,PkgFileP);}; | |
| | | | |
| // Oh I wish for Real Name Space Support | | // Oh I wish for Real Name Space Support | |
| class pkgCache::Namespace /*{{
{*/ | | class pkgCache::Namespace /*{{
{*/ | |
| { | | { | |
| public: | | public: | |
|
| | | typedef pkgCache::GrpIterator GrpIterator; | |
| typedef pkgCache::PkgIterator PkgIterator; | | typedef pkgCache::PkgIterator PkgIterator; | |
| typedef pkgCache::VerIterator VerIterator; | | typedef pkgCache::VerIterator VerIterator; | |
| typedef pkgCache::DescIterator DescIterator; | | typedef pkgCache::DescIterator DescIterator; | |
| typedef pkgCache::DepIterator DepIterator; | | typedef pkgCache::DepIterator DepIterator; | |
| typedef pkgCache::PrvIterator PrvIterator; | | typedef pkgCache::PrvIterator PrvIterator; | |
| typedef pkgCache::PkgFileIterator PkgFileIterator; | | typedef pkgCache::PkgFileIterator PkgFileIterator; | |
| typedef pkgCache::VerFileIterator VerFileIterator; | | typedef pkgCache::VerFileIterator VerFileIterator; | |
| typedef pkgCache::Version Version; | | typedef pkgCache::Version Version; | |
| typedef pkgCache::Description Description; | | typedef pkgCache::Description Description; | |
| typedef pkgCache::Package Package; | | typedef pkgCache::Package Package; | |
| | | | |
End of changes. 91 change blocks. |
| 85 lines changed or deleted | | 466 lines changed or added | |
|
| pkgcachegen.h | | pkgcachegen.h | |
| | | | |
| skipping to change at line 25 | | skipping to change at line 25 | |
| their contents | | their contents | |
| | | | |
| ##################################################################### */ | | ##################################################################### */ | |
| /*}}
}*/ | | /*}}
}*/ | |
| #ifndef PKGLIB_PKGCACHEGEN_H | | #ifndef PKGLIB_PKGCACHEGEN_H | |
| #define PKGLIB_PKGCACHEGEN_H | | #define PKGLIB_PKGCACHEGEN_H | |
| | | | |
| #include <apt-pkg/pkgcache.h> | | #include <apt-pkg/pkgcache.h> | |
| #include <apt-pkg/md5.h> | | #include <apt-pkg/md5.h> | |
| | | | |
|
| | | #include <vector> | |
| | | | |
| class pkgSourceList; | | class pkgSourceList; | |
| class OpProgress; | | class OpProgress; | |
| class MMap; | | class MMap; | |
| class pkgIndexFile; | | class pkgIndexFile; | |
| | | | |
| class pkgCacheGenerator
/*{{{*/ | | class pkgCacheGenerator
/*{{{*/ | |
| { | | { | |
| private: | | private: | |
| | | | |
| pkgCache::StringItem *UniqHash[26]; | | pkgCache::StringItem *UniqHash[26]; | |
|
| | | map_ptrloc WriteStringInMap(std::string const &String) { return WriteStr | |
| | | ingInMap(String.c_str()); }; | |
| | | map_ptrloc WriteStringInMap(const char *String); | |
| | | map_ptrloc WriteStringInMap(const char *String, const unsigned long &Len | |
| | | ); | |
| | | map_ptrloc AllocateInMap(const unsigned long &size); | |
| | | | |
| public: | | public: | |
| | | | |
| class ListParser; | | class ListParser; | |
| friend class ListParser; | | friend class ListParser; | |
| | | | |
|
| | | template<typename Iter> class Dynamic { | |
| | | public: | |
| | | static std::vector<Iter*> toReMap; | |
| | | Dynamic(Iter &I) { | |
| | | toReMap.push_back(&I); | |
| | | } | |
| | | | |
| | | ~Dynamic() { | |
| | | toReMap.pop_back(); | |
| | | } | |
| | | }; | |
| | | | |
| protected: | | protected: | |
| | | | |
| DynamicMMap ⤅ | | DynamicMMap ⤅ | |
| pkgCache Cache; | | pkgCache Cache; | |
| OpProgress *Progress; | | OpProgress *Progress; | |
| | | | |
| string PkgFileName; | | string PkgFileName; | |
| pkgCache::PackageFile *CurrentFile; | | pkgCache::PackageFile *CurrentFile; | |
| | | | |
| // Flag file dependencies | | // Flag file dependencies | |
| bool FoundFileDeps; | | bool FoundFileDeps; | |
| | | | |
|
| bool NewPackage(pkgCache::PkgIterator &Pkg,const string &PkgName); | | bool NewGroup(pkgCache::GrpIterator &Grp,const string &Name); | |
| | | bool NewPackage(pkgCache::PkgIterator &Pkg,const string &Name, const str | |
| | | ing &Arch); | |
| bool NewFileVer(pkgCache::VerIterator &Ver,ListParser &List); | | bool NewFileVer(pkgCache::VerIterator &Ver,ListParser &List); | |
| bool NewFileDesc(pkgCache::DescIterator &Desc,ListParser &List); | | bool NewFileDesc(pkgCache::DescIterator &Desc,ListParser &List); | |
|
| | | bool NewDepends(pkgCache::PkgIterator &Pkg, pkgCache::VerIterator &Ver, | |
| | | string const &Version, unsigned int const &Op, | |
| | | unsigned int const &Type, map_ptrloc *OldDepLast); | |
| unsigned long NewVersion(pkgCache::VerIterator &Ver,const string &VerStr
,unsigned long Next); | | unsigned long NewVersion(pkgCache::VerIterator &Ver,const string &VerStr
,unsigned long Next); | |
| map_ptrloc NewDescription(pkgCache::DescIterator &Desc,const string &Lan
g,const MD5SumValue &md5sum,map_ptrloc Next); | | map_ptrloc NewDescription(pkgCache::DescIterator &Desc,const string &Lan
g,const MD5SumValue &md5sum,map_ptrloc Next); | |
| | | | |
| public: | | public: | |
| | | | |
| unsigned long WriteUniqString(const char *S,unsigned int Size); | | unsigned long WriteUniqString(const char *S,unsigned int Size); | |
| inline unsigned long WriteUniqString(const string &S) {return WriteUniqS
tring(S.c_str(),S.length());}; | | inline unsigned long WriteUniqString(const string &S) {return WriteUniqS
tring(S.c_str(),S.length());}; | |
| | | | |
| void DropProgress() {Progress = 0;}; | | void DropProgress() {Progress = 0;}; | |
| bool SelectFile(const string &File,const string &Site,pkgIndexFile const
&Index, | | bool SelectFile(const string &File,const string &Site,pkgIndexFile const
&Index, | |
| unsigned long Flags = 0); | | unsigned long Flags = 0); | |
| bool MergeList(ListParser &List,pkgCache::VerIterator *Ver = 0); | | bool MergeList(ListParser &List,pkgCache::VerIterator *Ver = 0); | |
| inline pkgCache &GetCache() {return Cache;}; | | inline pkgCache &GetCache() {return Cache;}; | |
| inline pkgCache::PkgFileIterator GetCurFile() | | inline pkgCache::PkgFileIterator GetCurFile() | |
| {return pkgCache::PkgFileIterator(Cache,CurrentFile);}; | | {return pkgCache::PkgFileIterator(Cache,CurrentFile);}; | |
| | | | |
| bool HasFileDeps() {return FoundFileDeps;}; | | bool HasFileDeps() {return FoundFileDeps;}; | |
| bool MergeFileProvides(ListParser &List); | | bool MergeFileProvides(ListParser &List); | |
|
| | | bool FinishCache(OpProgress *Progress); | |
| | | | |
| | | static bool MakeStatusCache(pkgSourceList &List,OpProgress *Progress, | |
| | | MMap **OutMap = 0,bool AllowMem = false); | |
| | | static bool MakeOnlyStatusCache(OpProgress *Progress,DynamicMMap **OutMa | |
| | | p); | |
| | | static DynamicMMap* CreateDynamicMMap(FileFd *CacheF, unsigned long Flag | |
| | | s = 0); | |
| | | | |
| | | void ReMap(void const * const oldMap, void const * const newMap); | |
| | | | |
| pkgCacheGenerator(DynamicMMap *Map,OpProgress *Progress); | | pkgCacheGenerator(DynamicMMap *Map,OpProgress *Progress); | |
| ~pkgCacheGenerator(); | | ~pkgCacheGenerator(); | |
| }; | | }; | |
| /*}}
}*/ | | /*}}
}*/ | |
| // This is the abstract package list parser class. /*{{
{*/ | | // This is the abstract package list parser class. /*{{
{*/ | |
| class pkgCacheGenerator::ListParser | | class pkgCacheGenerator::ListParser | |
| { | | { | |
| pkgCacheGenerator *Owner; | | pkgCacheGenerator *Owner; | |
| friend class pkgCacheGenerator; | | friend class pkgCacheGenerator; | |
| | | | |
| skipping to change at line 96 | | skipping to change at line 126 | |
| pkgCache::VerIterator OldDepVer; | | pkgCache::VerIterator OldDepVer; | |
| map_ptrloc *OldDepLast; | | map_ptrloc *OldDepLast; | |
| | | | |
| // Flag file dependencies | | // Flag file dependencies | |
| bool FoundFileDeps; | | bool FoundFileDeps; | |
| | | | |
| protected: | | protected: | |
| | | | |
| inline unsigned long WriteUniqString(string S) {return Owner->WriteUniqS
tring(S);}; | | inline unsigned long WriteUniqString(string S) {return Owner->WriteUniqS
tring(S);}; | |
| inline unsigned long WriteUniqString(const char *S,unsigned int Size) {r
eturn Owner->WriteUniqString(S,Size);}; | | inline unsigned long WriteUniqString(const char *S,unsigned int Size) {r
eturn Owner->WriteUniqString(S,Size);}; | |
|
| inline unsigned long WriteString(const string &S) {return Owner->Map.Wri | | inline unsigned long WriteString(const string &S) {return Owner->WriteSt | |
| teString(S);}; | | ringInMap(S);}; | |
| inline unsigned long WriteString(const char *S,unsigned int Size) {retur | | inline unsigned long WriteString(const char *S,unsigned int Size) {retur | |
| n Owner->Map.WriteString(S,Size);}; | | n Owner->WriteStringInMap(S,Size);}; | |
| bool NewDepends(pkgCache::VerIterator Ver,const string &Package, | | bool NewDepends(pkgCache::VerIterator &Ver,const string &Package, const | |
| | | string &Arch, | |
| const string &Version,unsigned int Op, | | const string &Version,unsigned int Op, | |
| unsigned int Type); | | unsigned int Type); | |
|
| bool NewProvides(pkgCache::VerIterator Ver,const string &Package, | | bool NewProvides(pkgCache::VerIterator &Ver,const string &PkgName, | |
| const string &Version); | | const string &PkgArch, const string &Version); | |
| | | | |
| public: | | public: | |
| | | | |
| // These all operate against the current section | | // These all operate against the current section | |
| virtual string Package() = 0; | | virtual string Package() = 0; | |
|
| | | virtual string Architecture() = 0; | |
| | | virtual bool ArchitectureAll() = 0; | |
| virtual string Version() = 0; | | virtual string Version() = 0; | |
|
| virtual bool NewVersion(pkgCache::VerIterator Ver) = 0; | | virtual bool NewVersion(pkgCache::VerIterator &Ver) = 0; | |
| virtual string Description() = 0; | | virtual string Description() = 0; | |
| virtual string DescriptionLanguage() = 0; | | virtual string DescriptionLanguage() = 0; | |
| virtual MD5SumValue Description_md5() = 0; | | virtual MD5SumValue Description_md5() = 0; | |
| virtual unsigned short VersionHash() = 0; | | virtual unsigned short VersionHash() = 0; | |
|
| virtual bool UsePackage(pkgCache::PkgIterator Pkg, | | virtual bool UsePackage(pkgCache::PkgIterator &Pkg, | |
| pkgCache::VerIterator Ver) = 0; | | pkgCache::VerIterator &Ver) = 0; | |
| virtual unsigned long Offset() = 0; | | virtual unsigned long Offset() = 0; | |
| virtual unsigned long Size() = 0; | | virtual unsigned long Size() = 0; | |
| | | | |
| virtual bool Step() = 0; | | virtual bool Step() = 0; | |
| | | | |
| inline bool HasFileDeps() {return FoundFileDeps;}; | | inline bool HasFileDeps() {return FoundFileDeps;}; | |
| virtual bool CollectFileProvides(pkgCache &Cache, | | virtual bool CollectFileProvides(pkgCache &Cache, | |
|
| pkgCache::VerIterator Ver) {return true;
}; | | pkgCache::VerIterator &Ver) {return true
;}; | |
| | | | |
| ListParser() : FoundFileDeps(false) {}; | | ListParser() : FoundFileDeps(false) {}; | |
| virtual ~ListParser() {}; | | virtual ~ListParser() {}; | |
| }; | | }; | |
| /*}}
}*/ | | /*}}
}*/ | |
|
| | | | |
| bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress, | | bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress, | |
| MMap **OutMap = 0,bool AllowMem = false); | | MMap **OutMap = 0,bool AllowMem = false); | |
| bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap); | | bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap); | |
| | | | |
| #ifdef APT_COMPATIBILITY | | #ifdef APT_COMPATIBILITY | |
| #if APT_COMPATIBILITY != 986 | | #if APT_COMPATIBILITY != 986 | |
| #warning "Using APT_COMPATIBILITY" | | #warning "Using APT_COMPATIBILITY" | |
| #endif | | #endif | |
| MMap *pkgMakeStatusCacheMem(pkgSourceList &List,OpProgress &Progress) | | MMap *pkgMakeStatusCacheMem(pkgSourceList &List,OpProgress &Progress) | |
| { | | { | |
| | | | |
| skipping to change at line 140 | | skipping to change at line 173 | |
| MMap **OutMap = 0,bool AllowMem = false); | | MMap **OutMap = 0,bool AllowMem = false); | |
| bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap); | | bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap); | |
| | | | |
| #ifdef APT_COMPATIBILITY | | #ifdef APT_COMPATIBILITY | |
| #if APT_COMPATIBILITY != 986 | | #if APT_COMPATIBILITY != 986 | |
| #warning "Using APT_COMPATIBILITY" | | #warning "Using APT_COMPATIBILITY" | |
| #endif | | #endif | |
| MMap *pkgMakeStatusCacheMem(pkgSourceList &List,OpProgress &Progress) | | MMap *pkgMakeStatusCacheMem(pkgSourceList &List,OpProgress &Progress) | |
| { | | { | |
| MMap *Map = 0; | | MMap *Map = 0; | |
|
| if (pkgMakeStatusCache(List,Progress,&Map,true) == false) | | if (pkgCacheGenerator::MakeStatusCache(List,&Progress,&Map,true) == fals
e) | |
| return 0; | | return 0; | |
| return Map; | | return Map; | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 14 change blocks. |
| 13 lines changed or deleted | | 52 lines changed or added | |
|
| strutl.h | | strutl.h | |
| | | | |
| skipping to change at line 26 | | skipping to change at line 26 | |
| #ifndef STRUTL_H | | #ifndef STRUTL_H | |
| #define STRUTL_H | | #define STRUTL_H | |
| | | | |
| #include <stdlib.h> | | #include <stdlib.h> | |
| #include <string> | | #include <string> | |
| #include <cstring> | | #include <cstring> | |
| #include <vector> | | #include <vector> | |
| #include <iostream> | | #include <iostream> | |
| #include <time.h> | | #include <time.h> | |
| | | | |
|
| | | #include "macros.h" | |
| | | | |
| using std::string; | | using std::string; | |
| using std::vector; | | using std::vector; | |
| using std::ostream; | | using std::ostream; | |
| | | | |
|
| #ifdef __GNUG__ | | | |
| // Methods have a hidden this parameter that is visible to this attribute | | | |
| #define APT_FORMAT2 __attribute__ ((format (printf, 2, 3))) | | | |
| #define APT_FORMAT3 __attribute__ ((format (printf, 3, 4))) | | | |
| #else | | | |
| #define APT_FORMAT2 | | | |
| #define APT_FORMAT3 | | | |
| #endif | | | |
| | | | |
| bool UTF8ToCodeset(const char *codeset, const string &orig, string *dest); | | bool UTF8ToCodeset(const char *codeset, const string &orig, string *dest); | |
| char *_strstrip(char *String); | | char *_strstrip(char *String); | |
| char *_strtabexpand(char *String,size_t Len); | | char *_strtabexpand(char *String,size_t Len); | |
| bool ParseQuoteWord(const char *&String,string &Res); | | bool ParseQuoteWord(const char *&String,string &Res); | |
| bool ParseCWord(const char *&String,string &Res); | | bool ParseCWord(const char *&String,string &Res); | |
| string QuoteString(const string &Str,const char *Bad); | | string QuoteString(const string &Str,const char *Bad); | |
| string DeQuoteString(const string &Str); | | string DeQuoteString(const string &Str); | |
|
| | | string DeQuoteString(string::const_iterator const &begin, string::const_ite
rator const &end); | |
| string SizeToStr(double Bytes); | | string SizeToStr(double Bytes); | |
| string TimeToStr(unsigned long Sec); | | string TimeToStr(unsigned long Sec); | |
| string Base64Encode(const string &Str); | | string Base64Encode(const string &Str); | |
| string OutputInDepth(const unsigned long Depth, const char* Separator=" ")
; | | string OutputInDepth(const unsigned long Depth, const char* Separator=" ")
; | |
| string URItoFileName(const string &URI); | | string URItoFileName(const string &URI); | |
| string TimeRFC1123(time_t Date); | | string TimeRFC1123(time_t Date); | |
|
| bool StrToTime(const string &Val,time_t &Result); | | bool RFC1123StrToTime(const char* const str,time_t &time) __must_check; | |
| | | bool FTPMDTMStrToTime(const char* const str,time_t &time) __must_check; | |
| | | __deprecated bool StrToTime(const string &Val,time_t &Result); | |
| string LookupTag(const string &Message,const char *Tag,const char *Default
= 0); | | string LookupTag(const string &Message,const char *Tag,const char *Default
= 0); | |
| int StringToBool(const string &Text,int Default = -1); | | int StringToBool(const string &Text,int Default = -1); | |
| bool ReadMessages(int Fd, vector<string> &List); | | bool ReadMessages(int Fd, vector<string> &List); | |
| bool StrToNum(const char *Str,unsigned long &Res,unsigned Len,unsigned Base
= 0); | | bool StrToNum(const char *Str,unsigned long &Res,unsigned Len,unsigned Base
= 0); | |
| bool Hex2Num(const string &Str,unsigned char *Num,unsigned int Length); | | bool Hex2Num(const string &Str,unsigned char *Num,unsigned int Length); | |
| bool TokSplitString(char Tok,char *Input,char **List, | | bool TokSplitString(char Tok,char *Input,char **List, | |
| unsigned long ListMax); | | unsigned long ListMax); | |
|
| void ioprintf(ostream &out,const char *format,...) APT_FORMAT2; | | vector<string> VectorizeString(string const &haystack, char const &split) _ | |
| void strprintf(string &out,const char *format,...) APT_FORMAT2; | | _attrib_const; | |
| char *safe_snprintf(char *Buffer,char *End,const char *Format,...) APT_FORM | | void ioprintf(ostream &out,const char *format,...) __like_printf(2); | |
| AT3; | | void strprintf(string &out,const char *format,...) __like_printf(2); | |
| | | char *safe_snprintf(char *Buffer,char *End,const char *Format,...) __like_p | |
| | | rintf(3); | |
| bool CheckDomainList(const string &Host, const string &List); | | bool CheckDomainList(const string &Host, const string &List); | |
|
| int tolower_ascii(int c); | | int tolower_ascii(int const c) __attrib_const __hot; | |
| | | | |
| #define APT_MKSTRCMP(name,func) \ | | #define APT_MKSTRCMP(name,func) \ | |
| inline int name(const char *A,const char *B) {return func(A,A+strlen(A),B,B
+strlen(B));}; \ | | inline int name(const char *A,const char *B) {return func(A,A+strlen(A),B,B
+strlen(B));}; \ | |
| inline int name(const char *A,const char *AEnd,const char *B) {return func(
A,AEnd,B,B+strlen(B));}; \ | | inline int name(const char *A,const char *AEnd,const char *B) {return func(
A,AEnd,B,B+strlen(B));}; \ | |
| inline int name(const string& A,const char *B) {return func(A.c_str(),A.c_s
tr()+A.length(),B,B+strlen(B));}; \ | | inline int name(const string& A,const char *B) {return func(A.c_str(),A.c_s
tr()+A.length(),B,B+strlen(B));}; \ | |
| inline int name(const string& A,const string& B) {return func(A.c_str(),A.c
_str()+A.length(),B.c_str(),B.c_str()+B.length());}; \ | | inline int name(const string& A,const string& B) {return func(A.c_str(),A.c
_str()+A.length(),B.c_str(),B.c_str()+B.length());}; \ | |
| inline int name(const string& A,const char *B,const char *BEnd) {return fun
c(A.c_str(),A.c_str()+A.length(),B,BEnd);}; | | inline int name(const string& A,const char *B,const char *BEnd) {return fun
c(A.c_str(),A.c_str()+A.length(),B,BEnd);}; | |
| | | | |
| #define APT_MKSTRCMP2(name,func) \ | | #define APT_MKSTRCMP2(name,func) \ | |
| inline int name(const char *A,const char *AEnd,const char *B) {return func(
A,AEnd,B,B+strlen(B));}; \ | | inline int name(const char *A,const char *AEnd,const char *B) {return func(
A,AEnd,B,B+strlen(B));}; \ | |
| | | | |
| skipping to change at line 121 | | skipping to change at line 118 | |
| string User; | | string User; | |
| string Password; | | string Password; | |
| string Host; | | string Host; | |
| string Path; | | string Path; | |
| unsigned int Port; | | unsigned int Port; | |
| | | | |
| operator string(); | | operator string(); | |
| inline void operator =(const string &From) {CopyFrom(From);}; | | inline void operator =(const string &From) {CopyFrom(From);}; | |
| inline bool empty() {return Access.empty();}; | | inline bool empty() {return Access.empty();}; | |
| static string SiteOnly(const string &URI); | | static string SiteOnly(const string &URI); | |
|
| | | static string NoUserPassword(const string &URI); | |
| | | | |
| URI(string Path) {CopyFrom(Path);}; | | URI(string Path) {CopyFrom(Path);}; | |
| URI() : Port(0) {}; | | URI() : Port(0) {}; | |
| }; | | }; | |
| | | | |
| struct SubstVar | | struct SubstVar | |
| { | | { | |
| const char *Subst; | | const char *Subst; | |
| const string *Contents; | | const string *Contents; | |
| }; | | }; | |
| | | | |
| skipping to change at line 143 | | skipping to change at line 141 | |
| | | | |
| struct RxChoiceList | | struct RxChoiceList | |
| { | | { | |
| void *UserData; | | void *UserData; | |
| const char *Str; | | const char *Str; | |
| bool Hit; | | bool Hit; | |
| }; | | }; | |
| unsigned long RegexChoice(RxChoiceList *Rxs,const char **ListBegin, | | unsigned long RegexChoice(RxChoiceList *Rxs,const char **ListBegin, | |
| const char **ListEnd); | | const char **ListEnd); | |
| | | | |
|
| #undef APT_FORMAT2 | | | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 8 change blocks. |
| 17 lines changed or deleted | | 14 lines changed or added | |
|