summaryrefslogtreecommitdiff
path: root/apt-inst
diff options
context:
space:
mode:
Diffstat (limited to 'apt-inst')
-rw-r--r--apt-inst/contrib/arfile.cc6
-rw-r--r--apt-inst/contrib/extracttar.cc20
-rw-r--r--apt-inst/deb/debfile.cc58
-rw-r--r--apt-inst/deb/debfile.h7
-rw-r--r--apt-inst/dirstream.cc24
-rw-r--r--apt-inst/dirstream.h4
-rw-r--r--apt-inst/extract.cc17
-rw-r--r--apt-inst/extract.h5
-rw-r--r--apt-inst/filelist.cc12
-rw-r--r--apt-inst/filelist.h152
10 files changed, 169 insertions, 136 deletions
diff --git a/apt-inst/contrib/arfile.cc b/apt-inst/contrib/arfile.cc
index 9d84c1784..905110781 100644
--- a/apt-inst/contrib/arfile.cc
+++ b/apt-inst/contrib/arfile.cc
@@ -6,7 +6,7 @@
AR File - Handle an 'AR' archive
AR Archives have plain text headers at the start of each file
- section. The headers are aligned on a 2 byte boundry.
+ section. The headers are aligned on a 2 byte boundary.
Information about the structure of AR files can be found in ar(5)
on a BSD system, or in the binutils source.
@@ -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 fb4db42f8..0ba3f0521 100644
--- a/apt-inst/contrib/extracttar.cc
+++ b/apt-inst/contrib/extracttar.cc
@@ -6,7 +6,7 @@
Extract a Tar - Tar Extractor
Some performance measurements showed that zlib performed quite poorly
- in comparision to a forked gzip process. This tar extractor makes use
+ in comparison to a forked gzip process. This tar extractor makes use
of the fact that dup'd file descriptors have the same seek pointer
and that gzip will not read past the end of a compressed stream,
even if there is more data. We use the dup property to track extraction
@@ -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>
@@ -111,10 +113,16 @@ bool ExtractTar::Done(bool Force)
gzip will efficiently ignore the extra bits. */
bool ExtractTar::StartGzip()
{
+ if (DecompressProg.empty())
+ {
+ InFd.OpenDescriptor(File.Fd(), FileFd::ReadOnly, FileFd::None, false);
+ return true;
+ }
+
int Pipes[2];
if (pipe(Pipes) != 0)
return _error->Errno("pipe",_("Failed to create pipes"));
-
+
// Fork off the process
GZPid = ExecFork();
@@ -130,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 79434d8b5..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>
/*}}}*/
@@ -42,12 +48,15 @@ debDebFile::debDebFile(FileFd &File) : File(File), AR(File)
return;
}
- if (!CheckMember("control.tar.gz")) {
- _error->Error(_("This is not a valid DEB archive, missing '%s' member"), "control.tar.gz");
+ if (!CheckMember("control.tar") &&
+ !CheckMember("control.tar.gz") &&
+ !CheckMember("control.tar.xz")) {
+ _error->Error(_("This is not a valid DEB archive, missing '%s' member"), "control.tar");
return;
}
- if (!CheckMember("data.tar.gz") &&
+ if (!CheckMember("data.tar") &&
+ !CheckMember("data.tar.gz") &&
!CheckMember("data.tar.bz2") &&
!CheckMember("data.tar.lzma") &&
!CheckMember("data.tar.xz")) {
@@ -88,21 +97,20 @@ const ARArchive::Member *debDebFile::GotoMember(const char *Name)
return Member;
}
/*}}}*/
-// DebFile::ExtractArchive - Extract the archive data itself /*{{{*/
+// DebFile::ExtractTarMember - Extract the contents of a tar member /*{{{*/
// ---------------------------------------------------------------------
/* Simple wrapper around tar.. */
-bool debDebFile::ExtractArchive(pkgDirStream &Stream)
+bool debDebFile::ExtractTarMember(pkgDirStream &Stream,const char *Name)
{
// Get the archive member
const ARArchive::Member *Member = NULL;
std::string Compressor;
- std::string const data = "data.tar";
std::vector<APT::Configuration::Compressor> compressor = APT::Configuration::getCompressors();
for (std::vector<APT::Configuration::Compressor>::const_iterator c = compressor.begin();
c != compressor.end(); ++c)
{
- Member = AR.FindMember(std::string(data).append(c->Extension).c_str());
+ Member = AR.FindMember(std::string(Name).append(c->Extension).c_str());
if (Member == NULL)
continue;
Compressor = c->Binary;
@@ -110,11 +118,16 @@ bool debDebFile::ExtractArchive(pkgDirStream &Stream)
}
if (Member == NULL)
+ Member = AR.FindMember(std::string(Name).c_str());
+
+ if (Member == NULL)
{
- std::string ext = "data.tar.{";
+ std::string ext = std::string(Name) + ".{";
for (std::vector<APT::Configuration::Compressor>::const_iterator c = compressor.begin();
- c != compressor.end(); ++c)
- ext.append(c->Extension.substr(1));
+ c != compressor.end(); ++c) {
+ if (!c->Extension.empty())
+ ext.append(c->Extension.substr(1));
+ }
ext.append("}");
return _error->Error(_("Internal error, could not locate member %s"), ext.c_str());
}
@@ -129,6 +142,14 @@ bool debDebFile::ExtractArchive(pkgDirStream &Stream)
return Tar.Go(Stream);
}
/*}}}*/
+// DebFile::ExtractArchive - Extract the archive data itself /*{{{*/
+// ---------------------------------------------------------------------
+/* Simple wrapper around DebFile::ExtractTarMember. */
+bool debDebFile::ExtractArchive(pkgDirStream &Stream)
+{
+ return ExtractTarMember(Stream, "data.tar");
+}
+ /*}}}*/
// DebFile::ControlExtract::DoItem - Control Tar Extraction /*{{{*/
// ---------------------------------------------------------------------
@@ -181,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);
@@ -194,14 +215,7 @@ bool debDebFile::MemControlExtract::Process(Item &Itm,const unsigned char *Data,
it parses it into a tag section parser. */
bool debDebFile::MemControlExtract::Read(debDebFile &Deb)
{
- // Get the archive member and positition the file
- const ARArchive::Member *Member = Deb.GotoMember("control.tar.gz");
- if (Member == 0)
- return false;
-
- // Extract it.
- ExtractTar Tar(Deb.GetFile(),Member->Size,"gzip");
- if (Tar.Go(*this) == false)
+ if (Deb.ExtractTarMember(*this, "control.tar") == false)
return false;
if (Control == 0)
diff --git a/apt-inst/deb/debfile.h b/apt-inst/deb/debfile.h
index 38211fb0f..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;
@@ -48,6 +52,7 @@ class debDebFile
class ControlExtract;
class MemControlExtract;
+ bool ExtractTarMember(pkgDirStream &Stream, const char *Name);
bool ExtractArchive(pkgDirStream &Stream);
const ARArchive::Member *GotoMember(const char *Name);
inline FileFd &GetFile() {return File;};
diff --git a/apt-inst/dirstream.cc b/apt-inst/dirstream.cc
index 65d1aa188..39ebb3bb4 100644
--- a/apt-inst/dirstream.cc
+++ b/apt-inst/dirstream.cc
@@ -18,9 +18,8 @@
#include <fcntl.h>
#include <sys/stat.h>
-#include <sys/types.h>
+#include <sys/time.h>
#include <errno.h>
-#include <utime.h>
#include <unistd.h>
#include <apti18n.h>
/*}}}*/
@@ -93,25 +92,24 @@ bool pkgDirStream::FinishedFile(Item &Itm,int Fd)
{
if (Fd < 0)
return true;
-
- if (close(Fd) != 0)
- return _error->Errno("close",_("Failed to close file %s"),Itm.Name);
/* Set the modification times. The only way it can fail is if someone
has futzed with our file, which is intolerable :> */
- struct utimbuf Time;
- Time.actime = Itm.MTime;
- Time.modtime = Itm.MTime;
- if (utime(Itm.Name,&Time) != 0)
- _error->Errno("utime",_("Failed to close file %s"),Itm.Name);
-
- return true;
+ struct timeval times[2];
+ times[0].tv_sec = times[1].tv_sec = Itm.MTime;
+ times[0].tv_usec = times[1].tv_usec = 0;
+ if (utimes(Itm.Name, times) != 0)
+ _error->Errno("utimes", "Failed to set modification time for %s",Itm.Name);
+
+ if (close(Fd) != 0)
+ return _error->Errno("close",_("Failed to close file %s"),Itm.Name);
+ return true;
}
/*}}}*/
// 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 2c95fba92..b60784450 100644
--- a/apt-inst/extract.cc
+++ b/apt-inst/extract.cc
@@ -10,7 +10,7 @@
object is unpacked to '.dpkg.new' then the original is hardlinked to
'.dpkg.tmp' and finally the new object is renamed to overwrite the old
one. From an external perspective the file never ceased to exist.
- After the archive has been sucessfully unpacked the .dpkg.tmp files
+ After the archive has been successfully unpacked the .dpkg.tmp files
are erased. A failure causes all the .dpkg.tmp files to be restored.
Decisions about unpacking go like this:
@@ -22,7 +22,7 @@
[Note, this is reduced to only check if a file was expected to be
there]
- If the existing link/file is not a directory then it is replaced
- irregardless
+ regardless
- If the existing link/directory is being replaced by a directory then
absolutely nothing happens.
- If the existing link/directory is being replaced by a link then
@@ -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 879c07855..4dbc4a2d7 100644
--- a/apt-inst/filelist.cc
+++ b/apt-inst/filelist.cc
@@ -5,14 +5,14 @@
File Listing - Manages a Cache of File -> Package names.
- Diversions add some signficant complexity to the system. To keep
+ Diversions add some significant complexity to the system. To keep
storage space down in the very special case of a diverted file no
extra bytes are allocated in the Node structure. Instead a diversion
is inserted directly into the hash table and its flag bit set. Every
lookup for that filename will always return the diversion.
The hash buckets are stored in sorted form, with diversions having
- the higest sort order. Identical files are assigned the same file
+ the highest sort order. Identical files are assigned the same file
pointer, thus after a search all of the nodes owning that file can be
found by iterating down the bucket.
@@ -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;
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