diff options
Diffstat (limited to 'apt-inst')
-rw-r--r-- | apt-inst/contrib/arfile.cc | 4 | ||||
-rw-r--r-- | apt-inst/contrib/extracttar.cc | 12 | ||||
-rw-r--r-- | apt-inst/deb/debfile.cc | 14 | ||||
-rw-r--r-- | apt-inst/deb/debfile.h | 6 | ||||
-rw-r--r-- | apt-inst/dirstream.cc | 3 | ||||
-rw-r--r-- | apt-inst/dirstream.h | 4 | ||||
-rw-r--r-- | apt-inst/extract.cc | 13 | ||||
-rw-r--r-- | apt-inst/extract.h | 5 | ||||
-rw-r--r-- | apt-inst/filelist.cc | 8 | ||||
-rw-r--r-- | apt-inst/filelist.h | 152 |
10 files changed, 120 insertions, 101 deletions
diff --git a/apt-inst/contrib/arfile.cc b/apt-inst/contrib/arfile.cc index 77dbc55d6..905110781 100644 --- a/apt-inst/contrib/arfile.cc +++ b/apt-inst/contrib/arfile.cc @@ -21,7 +21,9 @@ #include <apt-pkg/fileutl.h> #include <apt-pkg/error.h> -#include <stdlib.h> +#include <string.h> +#include <sys/types.h> +#include <string> #include <apti18n.h> /*}}}*/ diff --git a/apt-inst/contrib/extracttar.cc b/apt-inst/contrib/extracttar.cc index 41301d1a6..0ba3f0521 100644 --- a/apt-inst/contrib/extracttar.cc +++ b/apt-inst/contrib/extracttar.cc @@ -23,9 +23,11 @@ #include <apt-pkg/error.h> #include <apt-pkg/strutl.h> #include <apt-pkg/configuration.h> -#include <apt-pkg/macros.h> +#include <apt-pkg/fileutl.h> -#include <stdlib.h> +#include <string.h> +#include <algorithm> +#include <string> #include <unistd.h> #include <signal.h> #include <fcntl.h> @@ -120,7 +122,7 @@ bool ExtractTar::StartGzip() int Pipes[2]; if (pipe(Pipes) != 0) return _error->Errno("pipe",_("Failed to create pipes")); - + // Fork off the process GZPid = ExecFork(); @@ -136,9 +138,9 @@ bool ExtractTar::StartGzip() dup2(Fd,STDERR_FILENO); close(Fd); SetCloseExec(STDOUT_FILENO,false); - SetCloseExec(STDIN_FILENO,false); + SetCloseExec(STDIN_FILENO,false); SetCloseExec(STDERR_FILENO,false); - + const char *Args[3]; string confvar = string("dir::bin::") + DecompressProg; string argv0 = _config->Find(confvar.c_str(),DecompressProg.c_str()); diff --git a/apt-inst/deb/debfile.cc b/apt-inst/deb/debfile.cc index 8f2a83547..a63cb6716 100644 --- a/apt-inst/deb/debfile.cc +++ b/apt-inst/deb/debfile.cc @@ -21,11 +21,17 @@ #include <apt-pkg/debfile.h> #include <apt-pkg/extracttar.h> #include <apt-pkg/error.h> -#include <apt-pkg/deblistparser.h> #include <apt-pkg/aptconfiguration.h> - +#include <apt-pkg/arfile.h> +#include <apt-pkg/dirstream.h> +#include <apt-pkg/fileutl.h> +#include <apt-pkg/tagfile.h> + +#include <string.h> +#include <string> +#include <vector> #include <sys/stat.h> -#include <unistd.h> + #include <apti18n.h> /*}}}*/ @@ -196,7 +202,7 @@ bool debDebFile::MemControlExtract::DoItem(Item &Itm,int &Fd) // --------------------------------------------------------------------- /* Just memcopy the block from the tar extractor and put it in the right place in the pre-allocated memory block. */ -bool debDebFile::MemControlExtract::Process(Item &Itm,const unsigned char *Data, +bool debDebFile::MemControlExtract::Process(Item &/*Itm*/,const unsigned char *Data, unsigned long Size,unsigned long Pos) { memcpy(Control + Pos, Data,Size); diff --git a/apt-inst/deb/debfile.h b/apt-inst/deb/debfile.h index ecef71d21..880bcf6c5 100644 --- a/apt-inst/deb/debfile.h +++ b/apt-inst/deb/debfile.h @@ -27,11 +27,15 @@ #include <apt-pkg/arfile.h> #include <apt-pkg/dirstream.h> #include <apt-pkg/tagfile.h> -#include <apt-pkg/pkgcache.h> + +#include <string> #ifndef APT_8_CLEANER_HEADERS #include <apt-pkg/md5.h> #endif +#ifndef APT_10_CLEANER_HEADERS +#include <apt-pkg/pkgcache.h> +#endif class FileFd; diff --git a/apt-inst/dirstream.cc b/apt-inst/dirstream.cc index e06c30a57..39ebb3bb4 100644 --- a/apt-inst/dirstream.cc +++ b/apt-inst/dirstream.cc @@ -18,7 +18,6 @@ #include <fcntl.h> #include <sys/stat.h> -#include <sys/types.h> #include <sys/time.h> #include <errno.h> #include <unistd.h> @@ -110,7 +109,7 @@ bool pkgDirStream::FinishedFile(Item &Itm,int Fd) // DirStream::Fail - Failed processing a file /*{{{*/ // --------------------------------------------------------------------- /* */ -bool pkgDirStream::Fail(Item &Itm,int Fd) +bool pkgDirStream::Fail(Item &/*Itm*/, int Fd) { if (Fd < 0) return true; diff --git a/apt-inst/dirstream.h b/apt-inst/dirstream.h index 9d1af2188..1be2688a1 100644 --- a/apt-inst/dirstream.h +++ b/apt-inst/dirstream.h @@ -49,8 +49,8 @@ class pkgDirStream virtual bool DoItem(Item &Itm,int &Fd); virtual bool Fail(Item &Itm,int Fd); virtual bool FinishedFile(Item &Itm,int Fd); - virtual bool Process(Item &Itm,const unsigned char *Data, - unsigned long Size,unsigned long Pos) {return true;}; + virtual bool Process(Item &/*Itm*/,const unsigned char * /*Data*/, + unsigned long /*Size*/,unsigned long /*Pos*/) {return true;}; virtual ~pkgDirStream() {}; }; diff --git a/apt-inst/extract.cc b/apt-inst/extract.cc index b3dfccfc6..b60784450 100644 --- a/apt-inst/extract.cc +++ b/apt-inst/extract.cc @@ -50,13 +50,20 @@ #include <apt-pkg/error.h> #include <apt-pkg/debversion.h> #include <apt-pkg/fileutl.h> +#include <apt-pkg/dirstream.h> +#include <apt-pkg/filelist.h> +#include <apt-pkg/mmap.h> +#include <apt-pkg/pkgcache.h> +#include <apt-pkg/cacheiterators.h> +#include <string.h> +#include <string> #include <sys/stat.h> #include <stdio.h> -#include <unistd.h> #include <errno.h> #include <dirent.h> #include <iostream> + #include <apti18n.h> /*}}}*/ using namespace std; @@ -79,7 +86,7 @@ pkgExtract::pkgExtract(pkgFLCache &FLCache,pkgCache::VerIterator Ver) : // Extract::DoItem - Handle a single item from the stream /*{{{*/ // --------------------------------------------------------------------- /* This performs the setup for the extraction.. */ -bool pkgExtract::DoItem(Item &Itm,int &Fd) +bool pkgExtract::DoItem(Item &Itm, int &/*Fd*/) { /* Strip any leading/trailing /s from the filename, then copy it to the temp buffer and re-apply the leading / We use a class variable @@ -253,7 +260,7 @@ bool pkgExtract::DoItem(Item &Itm,int &Fd) // Extract::Finished - Sequence finished, erase the temp files /*{{{*/ // --------------------------------------------------------------------- /* */ -bool pkgExtract::Finished() +APT_CONST bool pkgExtract::Finished() { return true; } diff --git a/apt-inst/extract.h b/apt-inst/extract.h index 7143fa409..8ad9ac629 100644 --- a/apt-inst/extract.h +++ b/apt-inst/extract.h @@ -17,11 +17,12 @@ #ifndef PKGLIB_EXTRACT_H #define PKGLIB_EXTRACT_H - - #include <apt-pkg/dirstream.h> #include <apt-pkg/filelist.h> #include <apt-pkg/pkgcache.h> +#include <apt-pkg/cacheiterators.h> + +#include <string> class pkgExtract : public pkgDirStream { diff --git a/apt-inst/filelist.cc b/apt-inst/filelist.cc index defc4f4df..4dbc4a2d7 100644 --- a/apt-inst/filelist.cc +++ b/apt-inst/filelist.cc @@ -39,8 +39,6 @@ #include <apt-pkg/error.h> #include <apt-pkg/strutl.h> -#include <stdio.h> -#include <stdlib.h> #include <string.h> #include <iostream> #include <apti18n.h> @@ -87,7 +85,7 @@ pkgFLCache::Header::Header() // FLCache::Header::CheckSizes - Check if the two headers have same *sz /*{{{*/ // --------------------------------------------------------------------- /* Compare to make sure we are matching versions */ -bool pkgFLCache::Header::CheckSizes(Header &Against) const +APT_PURE bool pkgFLCache::Header::CheckSizes(Header &Against) const { if (HeaderSz == Against.HeaderSz && NodeSz == Against.NodeSz && @@ -355,7 +353,7 @@ pkgFLCache::NodeIterator pkgFLCache::GetNode(const char *Name, // --------------------------------------------------------------------- /* This is one of two hashing functions. The other is inlined into the GetNode routine. */ -pkgFLCache::Node *pkgFLCache::HashNode(NodeIterator const &Nde) +APT_PURE pkgFLCache::Node *pkgFLCache::HashNode(NodeIterator const &Nde) { // Hash the node unsigned long HashPos = 0; @@ -572,7 +570,7 @@ bool pkgFLCache::AddConfFile(const char *Name,const char *NameEnd, // --------------------------------------------------------------------- /* Since the package pointer is indirected in all sorts of interesting ways this is used to get a pointer to the owning package */ -pkgFLCache::Package *pkgFLCache::NodeIterator::RealPackage() const +APT_PURE pkgFLCache::Package *pkgFLCache::NodeIterator::RealPackage() const { if (Nde->Pointer == 0) return 0; diff --git a/apt-inst/filelist.h b/apt-inst/filelist.h index 0405d61df..8c4891bcf 100644 --- a/apt-inst/filelist.h +++ b/apt-inst/filelist.h @@ -42,25 +42,25 @@ class pkgFLCache struct Package; struct Diversion; struct ConfFile; - + class NodeIterator; class DirIterator; class PkgIterator; class DiverIterator; - + protected: std::string CacheFile; DynamicMMap ⤅ map_ptrloc LastTreeLookup; unsigned long LastLookupSize; - + // Helpers for the addition algorithms map_ptrloc TreeLookup(map_ptrloc *Base,const char *Text,const char *TextEnd, unsigned long Size,unsigned int *Count = 0, bool Insert = false); - + public: - + // Pointers to the arrays of items Header *HeaderP; Node *NodeP; @@ -70,10 +70,10 @@ class pkgFLCache ConfFile *ConfP; char *StrP; unsigned char *AnyP; - + // Quick accessors Node *FileHash; - + // Accessors Header &Head() {return *HeaderP;}; void PrintTree(map_ptrloc Base,unsigned long Size); @@ -89,7 +89,7 @@ class pkgFLCache void DropNode(map_ptrloc Node); inline DiverIterator DiverBegin(); - + // Diversion control void BeginDiverLoad(); void FinishDiverLoad(); @@ -97,7 +97,7 @@ class pkgFLCache const char *To); bool AddConfFile(const char *Name,const char *NameEnd, PkgIterator const &Owner,const unsigned char *Sum); - + pkgFLCache(DynamicMMap &Map); // ~pkgFLCache(); }; @@ -109,7 +109,7 @@ struct pkgFLCache::Header short MajorVersion; short MinorVersion; bool Dirty; - + // Size of structure values unsigned HeaderSz; unsigned NodeSz; @@ -117,7 +117,7 @@ struct pkgFLCache::Header unsigned PackageSz; unsigned DiversionSz; unsigned ConfFileSz; - + // Structure Counts; unsigned int NodeCount; unsigned int DirCount; @@ -126,13 +126,13 @@ struct pkgFLCache::Header unsigned int ConfFileCount; unsigned int HashSize; unsigned long UniqNodes; - + // Offsets map_ptrloc FileHash; map_ptrloc DirTree; map_ptrloc Packages; map_ptrloc Diversions; - + /* Allocation pools, there should be one of these for each structure excluding the header */ DynamicMMap::Pool Pools[5]; @@ -177,7 +177,7 @@ struct pkgFLCache::Diversion map_ptrloc OwnerPkg; // Package map_ptrloc DivertFrom; // Node map_ptrloc DivertTo; // String - + map_ptrloc Next; // Diversion unsigned long Flags; @@ -194,120 +194,120 @@ class pkgFLCache::PkgIterator { Package *Pkg; pkgFLCache *Owner; - + public: - + inline bool end() const {return Owner == 0 || Pkg == Owner->PkgP?true:false;} - + // Accessors - inline Package *operator ->() {return Pkg;}; - inline Package const *operator ->() const {return Pkg;}; - 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 unsigned long Offset() const {return Pkg - Owner->PkgP;}; - inline const char *Name() const {return Pkg->Name == 0?0:Owner->StrP + Pkg->Name;}; + inline Package *operator ->() {return Pkg;} + inline Package const *operator ->() const {return Pkg;} + 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 unsigned long Offset() const {return Pkg - Owner->PkgP;} + inline const char *Name() const {return Pkg->Name == 0?0:Owner->StrP + Pkg->Name;} inline pkgFLCache::NodeIterator Files() const; - PkgIterator() : Pkg(0), Owner(0) {}; - PkgIterator(pkgFLCache &Owner,Package *Trg) : Pkg(Trg), Owner(&Owner) {}; + PkgIterator() : Pkg(0), Owner(0) {} + PkgIterator(pkgFLCache &Owner,Package *Trg) : Pkg(Trg), Owner(&Owner) {} }; class pkgFLCache::DirIterator { Directory *Dir; pkgFLCache *Owner; - + public: - + // Accessors - inline Directory *operator ->() {return Dir;}; - inline Directory const *operator ->() const {return Dir;}; - inline Directory const &operator *() const {return *Dir;}; - inline operator Directory *() {return Dir == Owner->DirP?0:Dir;}; - inline operator Directory const *() const {return Dir == Owner->DirP?0:Dir;}; + inline Directory *operator ->() {return Dir;} + inline Directory const *operator ->() const {return Dir;} + inline Directory const &operator *() const {return *Dir;} + inline operator Directory *() {return Dir == Owner->DirP?0:Dir;} + inline operator Directory const *() const {return Dir == Owner->DirP?0:Dir;} - inline const char *Name() const {return Dir->Name == 0?0:Owner->StrP + Dir->Name;}; + inline const char *Name() const {return Dir->Name == 0?0:Owner->StrP + Dir->Name;} - DirIterator() : Dir(0), Owner(0) {}; - DirIterator(pkgFLCache &Owner,Directory *Trg) : Dir(Trg), Owner(&Owner) {}; + DirIterator() : Dir(0), Owner(0) {} + DirIterator(pkgFLCache &Owner,Directory *Trg) : Dir(Trg), Owner(&Owner) {} }; class pkgFLCache::DiverIterator { Diversion *Diver; pkgFLCache *Owner; - + public: // Iteration - void operator ++(int) {if (Diver != Owner->DiverP) Diver = Owner->DiverP + Diver->Next;}; - inline void operator ++() {operator ++(0);}; - inline bool end() const {return Owner == 0 || Diver == Owner->DiverP;}; + void operator ++(int) {if (Diver != Owner->DiverP) Diver = Owner->DiverP + Diver->Next;} + inline void operator ++() {operator ++(0);} + inline bool end() const {return Owner == 0 || Diver == Owner->DiverP;} // Accessors - inline Diversion *operator ->() {return Diver;}; - inline Diversion const *operator ->() const {return Diver;}; - inline Diversion const &operator *() const {return *Diver;}; - inline operator Diversion *() {return Diver == Owner->DiverP?0:Diver;}; - inline operator Diversion const *() const {return Diver == Owner->DiverP?0:Diver;}; + inline Diversion *operator ->() {return Diver;} + inline Diversion const *operator ->() const {return Diver;} + inline Diversion const &operator *() const {return *Diver;} + inline operator Diversion *() {return Diver == Owner->DiverP?0:Diver;} + inline operator Diversion const *() const {return Diver == Owner->DiverP?0:Diver;} - inline PkgIterator OwnerPkg() const {return PkgIterator(*Owner,Owner->PkgP + Diver->OwnerPkg);}; + inline PkgIterator OwnerPkg() const {return PkgIterator(*Owner,Owner->PkgP + Diver->OwnerPkg);} inline NodeIterator DivertFrom() const; inline NodeIterator DivertTo() const; DiverIterator() : Diver(0), Owner(0) {}; - DiverIterator(pkgFLCache &Owner,Diversion *Trg) : Diver(Trg), Owner(&Owner) {}; + DiverIterator(pkgFLCache &Owner,Diversion *Trg) : Diver(Trg), Owner(&Owner) {} }; class pkgFLCache::NodeIterator { Node *Nde; - enum {NdePkg, NdeHash} Type; + enum {NdePkg, NdeHash} Type; pkgFLCache *Owner; - + public: - + // Iteration - void operator ++(int) {if (Nde != Owner->NodeP) Nde = Owner->NodeP + - (Type == NdePkg?Nde->NextPkg:Nde->Next);}; - inline void operator ++() {operator ++(0);}; - inline bool end() const {return Owner == 0 || Nde == Owner->NodeP;}; + void operator ++(int) {if (Nde != Owner->NodeP) Nde = Owner->NodeP + + (Type == NdePkg?Nde->NextPkg:Nde->Next);} + inline void operator ++() {operator ++(0);} + inline bool end() const {return Owner == 0 || Nde == Owner->NodeP;} // Accessors - inline Node *operator ->() {return Nde;}; - inline Node const *operator ->() const {return Nde;}; - inline Node const &operator *() const {return *Nde;}; - inline operator Node *() {return Nde == Owner->NodeP?0:Nde;}; - inline operator Node const *() const {return Nde == Owner->NodeP?0:Nde;}; - inline unsigned long Offset() const {return Nde - Owner->NodeP;}; - inline DirIterator Dir() const {return DirIterator(*Owner,Owner->DirP + Nde->Dir);}; - inline DiverIterator Diversion() const {return DiverIterator(*Owner,Owner->DiverP + Nde->Pointer);}; - inline const char *File() const {return Nde->File == 0?0:Owner->StrP + Nde->File;}; - inline const char *DirN() const {return Owner->StrP + Owner->DirP[Nde->Dir].Name;}; + inline Node *operator ->() {return Nde;} + inline Node const *operator ->() const {return Nde;} + inline Node const &operator *() const {return *Nde;} + inline operator Node *() {return Nde == Owner->NodeP?0:Nde;} + inline operator Node const *() const {return Nde == Owner->NodeP?0:Nde;} + inline unsigned long Offset() const {return Nde - Owner->NodeP;} + inline DirIterator Dir() const {return DirIterator(*Owner,Owner->DirP + Nde->Dir);} + inline DiverIterator Diversion() const {return DiverIterator(*Owner,Owner->DiverP + Nde->Pointer);} + inline const char *File() const {return Nde->File == 0?0:Owner->StrP + Nde->File;} + inline const char *DirN() const {return Owner->StrP + Owner->DirP[Nde->Dir].Name;} Package *RealPackage() const; - + NodeIterator() : Nde(0), Type(NdeHash), Owner(0) {}; - NodeIterator(pkgFLCache &Owner) : Nde(Owner.NodeP), Type(NdeHash), Owner(&Owner) {}; - NodeIterator(pkgFLCache &Owner,Node *Trg) : Nde(Trg), Type(NdeHash), Owner(&Owner) {}; - NodeIterator(pkgFLCache &Owner,Node *Trg,Package *) : Nde(Trg), Type(NdePkg), Owner(&Owner) {}; + NodeIterator(pkgFLCache &Owner) : Nde(Owner.NodeP), Type(NdeHash), Owner(&Owner) {} + NodeIterator(pkgFLCache &Owner,Node *Trg) : Nde(Trg), Type(NdeHash), Owner(&Owner) {} + NodeIterator(pkgFLCache &Owner,Node *Trg,Package *) : Nde(Trg), Type(NdePkg), Owner(&Owner) {} }; /* Inlines with forward references that cannot be included directly in their respsective classes */ -inline pkgFLCache::NodeIterator pkgFLCache::DiverIterator::DivertFrom() const - {return NodeIterator(*Owner,Owner->NodeP + Diver->DivertFrom);}; +inline pkgFLCache::NodeIterator pkgFLCache::DiverIterator::DivertFrom() const + {return NodeIterator(*Owner,Owner->NodeP + Diver->DivertFrom);} inline pkgFLCache::NodeIterator pkgFLCache::DiverIterator::DivertTo() const - {return NodeIterator(*Owner,Owner->NodeP + Diver->DivertTo);}; + {return NodeIterator(*Owner,Owner->NodeP + Diver->DivertTo);} inline pkgFLCache::NodeIterator pkgFLCache::PkgIterator::Files() const - {return NodeIterator(*Owner,Owner->NodeP + Pkg->Files,Pkg);}; + {return NodeIterator(*Owner,Owner->NodeP + Pkg->Files,Pkg);} inline pkgFLCache::DiverIterator pkgFLCache::DiverBegin() - {return DiverIterator(*this,DiverP + HeaderP->Diversions);}; + {return DiverIterator(*this,DiverP + HeaderP->Diversions);} -inline pkgFLCache::PkgIterator pkgFLCache::GetPkg(const char *Name,bool Insert) - {return GetPkg(Name,Name+strlen(Name),Insert);}; +inline pkgFLCache::PkgIterator pkgFLCache::GetPkg(const char *Name,bool Insert) + {return GetPkg(Name,Name+strlen(Name),Insert);} #endif |