Преглед изворни кода

fix test/integration/test-apt-helper

Michael Vogt пре 12 година
родитељ
комит
83b880c650
100 измењених фајлова са 1854 додато и 1132 уклоњено
  1. 2 2
      .gitignore
  2. 3 1
      apt-inst/contrib/arfile.cc
  3. 7 5
      apt-inst/contrib/extracttar.cc
  4. 10 4
      apt-inst/deb/debfile.cc
  5. 5 1
      apt-inst/deb/debfile.h
  6. 1 2
      apt-inst/dirstream.cc
  7. 2 2
      apt-inst/dirstream.h
  8. 10 3
      apt-inst/extract.cc
  9. 3 2
      apt-inst/extract.h
  10. 3 5
      apt-inst/filelist.cc
  11. 76 76
      apt-inst/filelist.h
  12. 31 26
      apt-pkg/acquire-item.cc
  13. 12 7
      apt-pkg/acquire-item.h
  14. 10 2
      apt-pkg/acquire-method.cc
  15. 1 0
      apt-pkg/acquire-method.h
  16. 5 2
      apt-pkg/acquire-worker.cc
  17. 5 2
      apt-pkg/acquire-worker.h
  18. 10 4
      apt-pkg/acquire.cc
  19. 10 5
      apt-pkg/acquire.h
  20. 42 27
      apt-pkg/algorithms.cc
  21. 5 2
      apt-pkg/algorithms.h
  22. 53 66
      apt-pkg/aptconfiguration.cc
  23. 7 2
      apt-pkg/aptconfiguration.h
  24. 10 3
      apt-pkg/cachefile.cc
  25. 7 2
      apt-pkg/cachefile.h
  26. 3 1
      apt-pkg/cachefilter.cc
  27. 2 1
      apt-pkg/cachefilter.h
  28. 136 131
      apt-pkg/cacheiterators.h
  29. 27 19
      apt-pkg/cacheset.cc
  30. 99 91
      apt-pkg/cacheset.h
  31. 43 38
      apt-pkg/cdrom.cc
  32. 3 1
      apt-pkg/cdrom.h
  33. 4 0
      apt-pkg/clean.cc
  34. 6 1
      apt-pkg/clean.h
  35. 54 36
      apt-pkg/contrib/cdromutl.cc
  36. 5 0
      apt-pkg/contrib/cmndline.cc
  37. 5 3
      apt-pkg/contrib/cmndline.h
  38. 22 6
      apt-pkg/contrib/configuration.cc
  39. 15 1
      apt-pkg/contrib/configuration.h
  40. 3 1
      apt-pkg/contrib/crc-16.h
  41. 4 2
      apt-pkg/contrib/error.cc
  42. 19 18
      apt-pkg/contrib/error.h
  43. 326 149
      apt-pkg/contrib/fileutl.cc
  44. 6 5
      apt-pkg/contrib/fileutl.h
  45. 10 8
      apt-pkg/contrib/gpgv.cc
  46. 8 10
      apt-pkg/contrib/gpgv.h
  47. 6 2
      apt-pkg/contrib/hashes.cc
  48. 11 6
      apt-pkg/contrib/hashes.h
  49. 3 0
      apt-pkg/contrib/hashsum.cc
  50. 28 24
      apt-pkg/contrib/hashsum_template.h
  51. 67 17
      apt-pkg/contrib/macros.h
  52. 1 5
      apt-pkg/contrib/md5.cc
  53. 5 4
      apt-pkg/contrib/md5.h
  54. 3 3
      apt-pkg/contrib/mmap.cc
  55. 2 3
      apt-pkg/contrib/netrc.cc
  56. 4 2
      apt-pkg/contrib/netrc.h
  57. 8 6
      apt-pkg/contrib/progress.cc
  58. 1 4
      apt-pkg/contrib/sha1.cc
  59. 4 3
      apt-pkg/contrib/sha1.h
  60. 7 3
      apt-pkg/contrib/sha2.h
  61. 1 0
      apt-pkg/contrib/sha2_internal.cc
  62. 1 0
      apt-pkg/contrib/sha2_internal.h
  63. 12 5
      apt-pkg/contrib/strutl.cc
  64. 39 36
      apt-pkg/contrib/strutl.h
  65. 13 3
      apt-pkg/deb/debindexfile.cc
  66. 14 6
      apt-pkg/deb/debindexfile.h
  67. 147 29
      apt-pkg/deb/deblistparser.cc
  68. 26 4
      apt-pkg/deb/deblistparser.h
  69. 9 2
      apt-pkg/deb/debmetaindex.cc
  70. 7 1
      apt-pkg/deb/debmetaindex.h
  71. 7 1
      apt-pkg/deb/debrecords.cc
  72. 3 0
      apt-pkg/deb/debrecords.h
  73. 11 4
      apt-pkg/deb/debsrcrecords.cc
  74. 6 1
      apt-pkg/deb/debsrcrecords.h
  75. 9 2
      apt-pkg/deb/debsystem.cc
  76. 9 1
      apt-pkg/deb/debsystem.h
  77. 2 0
      apt-pkg/deb/debversion.cc
  78. 10 10
      apt-pkg/deb/debversion.h
  79. 29 25
      apt-pkg/deb/dpkgpm.cc
  80. 13 4
      apt-pkg/deb/dpkgpm.h
  81. 18 12
      apt-pkg/depcache.cc
  82. 16 7
      apt-pkg/depcache.h
  83. 17 10
      apt-pkg/edsp.cc
  84. 6 5
      apt-pkg/edsp.h
  85. 12 7
      apt-pkg/edsp/edspindexfile.cc
  86. 5 1
      apt-pkg/edsp/edspindexfile.h
  87. 8 6
      apt-pkg/edsp/edsplistparser.cc
  88. 4 0
      apt-pkg/edsp/edsplistparser.h
  89. 11 10
      apt-pkg/edsp/edspsystem.cc
  90. 13 4
      apt-pkg/edsp/edspsystem.h
  91. 18 20
      apt-pkg/indexcopy.cc
  92. 6 4
      apt-pkg/indexcopy.h
  93. 11 5
      apt-pkg/indexfile.cc
  94. 12 9
      apt-pkg/indexfile.h
  95. 15 10
      apt-pkg/indexrecords.cc
  96. 4 2
      apt-pkg/indexrecords.h
  97. 3 1
      apt-pkg/init.cc
  98. 3 10
      apt-pkg/init.h
  99. 24 18
      apt-pkg/install-progress.cc
  100. 0 0
      apt-pkg/install-progress.h

+ 2 - 2
.gitignore

@@ -39,5 +39,5 @@
 /debian/libapt-inst*.install
 /debian/libapt-inst*.install
 /debian/libapt-pkg-dev.install
 /debian/libapt-pkg-dev.install
 /vendor/current
 /vendor/current
-/vendor/debian/sources.list
-/vendor/ubuntu/sources.list
+/vendor/*/sources.list
+/vendor/*/makefile.auto

+ 3 - 1
apt-inst/contrib/arfile.cc

@@ -21,7 +21,9 @@
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 
 
-#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <string>
 
 
 #include <apti18n.h>
 #include <apti18n.h>
 									/*}}}*/
 									/*}}}*/

+ 7 - 5
apt-inst/contrib/extracttar.cc

@@ -23,9 +23,11 @@
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/configuration.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 <unistd.h>
 #include <signal.h>
 #include <signal.h>
 #include <fcntl.h>
 #include <fcntl.h>
@@ -120,7 +122,7 @@ bool ExtractTar::StartGzip()
    int Pipes[2];
    int Pipes[2];
    if (pipe(Pipes) != 0)
    if (pipe(Pipes) != 0)
       return _error->Errno("pipe",_("Failed to create pipes"));
       return _error->Errno("pipe",_("Failed to create pipes"));
-   
+
    // Fork off the process
    // Fork off the process
    GZPid = ExecFork();
    GZPid = ExecFork();
 
 
@@ -136,9 +138,9 @@ bool ExtractTar::StartGzip()
       dup2(Fd,STDERR_FILENO);
       dup2(Fd,STDERR_FILENO);
       close(Fd);
       close(Fd);
       SetCloseExec(STDOUT_FILENO,false);
       SetCloseExec(STDOUT_FILENO,false);
-      SetCloseExec(STDIN_FILENO,false);      
+      SetCloseExec(STDIN_FILENO,false);
       SetCloseExec(STDERR_FILENO,false);
       SetCloseExec(STDERR_FILENO,false);
-      
+
       const char *Args[3];
       const char *Args[3];
       string confvar = string("dir::bin::") + DecompressProg;
       string confvar = string("dir::bin::") + DecompressProg;
       string argv0 = _config->Find(confvar.c_str(),DecompressProg.c_str());
       string argv0 = _config->Find(confvar.c_str(),DecompressProg.c_str());

+ 10 - 4
apt-inst/deb/debfile.cc

@@ -21,11 +21,17 @@
 #include <apt-pkg/debfile.h>
 #include <apt-pkg/debfile.h>
 #include <apt-pkg/extracttar.h>
 #include <apt-pkg/extracttar.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
-#include <apt-pkg/deblistparser.h>
 #include <apt-pkg/aptconfiguration.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 <sys/stat.h>
-#include <unistd.h>
+
 #include <apti18n.h>
 #include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
 
 
@@ -194,7 +200,7 @@ bool debDebFile::MemControlExtract::DoItem(Item &Itm,int &Fd)
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* Just memcopy the block from the tar extractor and put it in the right
 /* Just memcopy the block from the tar extractor and put it in the right
    place in the pre-allocated memory block. */
    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)
 			     unsigned long Size,unsigned long Pos)
 {
 {
    memcpy(Control + Pos, Data,Size);
    memcpy(Control + Pos, Data,Size);

+ 5 - 1
apt-inst/deb/debfile.h

@@ -27,11 +27,15 @@
 #include <apt-pkg/arfile.h>
 #include <apt-pkg/arfile.h>
 #include <apt-pkg/dirstream.h>
 #include <apt-pkg/dirstream.h>
 #include <apt-pkg/tagfile.h>
 #include <apt-pkg/tagfile.h>
-#include <apt-pkg/pkgcache.h>
+
+#include <string>
 
 
 #ifndef APT_8_CLEANER_HEADERS
 #ifndef APT_8_CLEANER_HEADERS
 #include <apt-pkg/md5.h>
 #include <apt-pkg/md5.h>
 #endif
 #endif
+#ifndef APT_10_CLEANER_HEADERS
+#include <apt-pkg/pkgcache.h>
+#endif
 
 
 class FileFd;
 class FileFd;
 
 

+ 1 - 2
apt-inst/dirstream.cc

@@ -18,7 +18,6 @@
 
 
 #include <fcntl.h>
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <sys/stat.h>
-#include <sys/types.h>
 #include <sys/time.h>
 #include <sys/time.h>
 #include <errno.h>
 #include <errno.h>
 #include <unistd.h>
 #include <unistd.h>
@@ -110,7 +109,7 @@ bool pkgDirStream::FinishedFile(Item &Itm,int Fd)
 // DirStream::Fail - Failed processing a file				/*{{{*/
 // DirStream::Fail - Failed processing a file				/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-bool pkgDirStream::Fail(Item &Itm,int Fd)
+bool pkgDirStream::Fail(Item &/*Itm*/, int Fd)
 {
 {
    if (Fd < 0)
    if (Fd < 0)
       return true;
       return true;

+ 2 - 2
apt-inst/dirstream.h

@@ -49,8 +49,8 @@ class pkgDirStream
    virtual bool DoItem(Item &Itm,int &Fd);
    virtual bool DoItem(Item &Itm,int &Fd);
    virtual bool Fail(Item &Itm,int Fd);
    virtual bool Fail(Item &Itm,int Fd);
    virtual bool FinishedFile(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() {};   
    virtual ~pkgDirStream() {};   
 };
 };

+ 10 - 3
apt-inst/extract.cc

@@ -50,13 +50,20 @@
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/debversion.h>
 #include <apt-pkg/debversion.h>
 #include <apt-pkg/fileutl.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 <sys/stat.h>
 #include <stdio.h>
 #include <stdio.h>
-#include <unistd.h>
 #include <errno.h>
 #include <errno.h>
 #include <dirent.h>
 #include <dirent.h>
 #include <iostream>
 #include <iostream>
+
 #include <apti18n.h>
 #include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
 using namespace std;
 using namespace std;
@@ -79,7 +86,7 @@ pkgExtract::pkgExtract(pkgFLCache &FLCache,pkgCache::VerIterator Ver) :
 // Extract::DoItem - Handle a single item from the stream		/*{{{*/
 // Extract::DoItem - Handle a single item from the stream		/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* This performs the setup for the extraction.. */
 /* 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
    /* 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
       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		/*{{{*/
 // Extract::Finished - Sequence finished, erase the temp files		/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-bool pkgExtract::Finished()
+APT_CONST bool pkgExtract::Finished()
 {
 {
    return true;
    return true;
 }
 }

+ 3 - 2
apt-inst/extract.h

@@ -17,11 +17,12 @@
 #ifndef PKGLIB_EXTRACT_H
 #ifndef PKGLIB_EXTRACT_H
 #define PKGLIB_EXTRACT_H
 #define PKGLIB_EXTRACT_H
 
 
-
-
 #include <apt-pkg/dirstream.h>
 #include <apt-pkg/dirstream.h>
 #include <apt-pkg/filelist.h>
 #include <apt-pkg/filelist.h>
 #include <apt-pkg/pkgcache.h>
 #include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+
+#include <string>
 
 
 class pkgExtract : public pkgDirStream
 class pkgExtract : public pkgDirStream
 {
 {

+ 3 - 5
apt-inst/filelist.cc

@@ -39,8 +39,6 @@
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
 
 
-#include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 #include <string.h>
 #include <iostream>
 #include <iostream>
 #include <apti18n.h>
 #include <apti18n.h>
@@ -87,7 +85,7 @@ pkgFLCache::Header::Header()
 // FLCache::Header::CheckSizes - Check if the two headers have same *sz	/*{{{*/
 // FLCache::Header::CheckSizes - Check if the two headers have same *sz	/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* Compare to make sure we are matching versions */
 /* 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 &&
    if (HeaderSz == Against.HeaderSz &&
        NodeSz == Against.NodeSz &&
        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
 /* This is one of two hashing functions. The other is inlined into the
    GetNode routine. */
    GetNode routine. */
-pkgFLCache::Node *pkgFLCache::HashNode(NodeIterator const &Nde)
+APT_PURE pkgFLCache::Node *pkgFLCache::HashNode(NodeIterator const &Nde)
 {
 {
    // Hash the node
    // Hash the node
    unsigned long HashPos = 0;
    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
 /* Since the package pointer is indirected in all sorts of interesting ways
    this is used to get a pointer to the owning package */
    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)
    if (Nde->Pointer == 0)
       return 0;
       return 0;

+ 76 - 76
apt-inst/filelist.h

@@ -42,25 +42,25 @@ class pkgFLCache
    struct Package;
    struct Package;
    struct Diversion;
    struct Diversion;
    struct ConfFile;
    struct ConfFile;
-   
+
    class NodeIterator;
    class NodeIterator;
    class DirIterator;
    class DirIterator;
    class PkgIterator;
    class PkgIterator;
    class DiverIterator;
    class DiverIterator;
-   
+
    protected:
    protected:
    std::string CacheFile;
    std::string CacheFile;
    DynamicMMap &Map;
    DynamicMMap &Map;
    map_ptrloc LastTreeLookup;
    map_ptrloc LastTreeLookup;
    unsigned long LastLookupSize;
    unsigned long LastLookupSize;
-   
+
    // Helpers for the addition algorithms
    // Helpers for the addition algorithms
    map_ptrloc TreeLookup(map_ptrloc *Base,const char *Text,const char *TextEnd,
    map_ptrloc TreeLookup(map_ptrloc *Base,const char *Text,const char *TextEnd,
 			 unsigned long Size,unsigned int *Count = 0,
 			 unsigned long Size,unsigned int *Count = 0,
 			 bool Insert = false);
 			 bool Insert = false);
-   
+
    public:
    public:
-   
+
    // Pointers to the arrays of items
    // Pointers to the arrays of items
    Header *HeaderP;
    Header *HeaderP;
    Node *NodeP;
    Node *NodeP;
@@ -70,10 +70,10 @@ class pkgFLCache
    ConfFile *ConfP;
    ConfFile *ConfP;
    char *StrP;
    char *StrP;
    unsigned char *AnyP;
    unsigned char *AnyP;
-   
+
    // Quick accessors
    // Quick accessors
    Node *FileHash;
    Node *FileHash;
-   
+
    // Accessors
    // Accessors
    Header &Head() {return *HeaderP;};
    Header &Head() {return *HeaderP;};
    void PrintTree(map_ptrloc Base,unsigned long Size);
    void PrintTree(map_ptrloc Base,unsigned long Size);
@@ -89,7 +89,7 @@ class pkgFLCache
    void DropNode(map_ptrloc Node);
    void DropNode(map_ptrloc Node);
 
 
    inline DiverIterator DiverBegin();
    inline DiverIterator DiverBegin();
-   
+
    // Diversion control
    // Diversion control
    void BeginDiverLoad();
    void BeginDiverLoad();
    void FinishDiverLoad();
    void FinishDiverLoad();
@@ -97,7 +97,7 @@ class pkgFLCache
 		     const char *To);
 		     const char *To);
    bool AddConfFile(const char *Name,const char *NameEnd,
    bool AddConfFile(const char *Name,const char *NameEnd,
 		    PkgIterator const &Owner,const unsigned char *Sum);
 		    PkgIterator const &Owner,const unsigned char *Sum);
-			     
+
    pkgFLCache(DynamicMMap &Map);
    pkgFLCache(DynamicMMap &Map);
 //   ~pkgFLCache();
 //   ~pkgFLCache();
 };
 };
@@ -109,7 +109,7 @@ struct pkgFLCache::Header
    short MajorVersion;
    short MajorVersion;
    short MinorVersion;
    short MinorVersion;
    bool Dirty;
    bool Dirty;
-   
+
    // Size of structure values
    // Size of structure values
    unsigned HeaderSz;
    unsigned HeaderSz;
    unsigned NodeSz;
    unsigned NodeSz;
@@ -117,7 +117,7 @@ struct pkgFLCache::Header
    unsigned PackageSz;
    unsigned PackageSz;
    unsigned DiversionSz;
    unsigned DiversionSz;
    unsigned ConfFileSz;
    unsigned ConfFileSz;
-   
+
    // Structure Counts;
    // Structure Counts;
    unsigned int NodeCount;
    unsigned int NodeCount;
    unsigned int DirCount;
    unsigned int DirCount;
@@ -126,13 +126,13 @@ struct pkgFLCache::Header
    unsigned int ConfFileCount;
    unsigned int ConfFileCount;
    unsigned int HashSize;
    unsigned int HashSize;
    unsigned long UniqNodes;
    unsigned long UniqNodes;
-      
+
    // Offsets
    // Offsets
    map_ptrloc FileHash;
    map_ptrloc FileHash;
    map_ptrloc DirTree;
    map_ptrloc DirTree;
    map_ptrloc Packages;
    map_ptrloc Packages;
    map_ptrloc Diversions;
    map_ptrloc Diversions;
-      
+
    /* Allocation pools, there should be one of these for each structure
    /* Allocation pools, there should be one of these for each structure
       excluding the header */
       excluding the header */
    DynamicMMap::Pool Pools[5];
    DynamicMMap::Pool Pools[5];
@@ -177,7 +177,7 @@ struct pkgFLCache::Diversion
    map_ptrloc OwnerPkg;       // Package
    map_ptrloc OwnerPkg;       // Package
    map_ptrloc DivertFrom;     // Node
    map_ptrloc DivertFrom;     // Node
    map_ptrloc DivertTo;       // String
    map_ptrloc DivertTo;       // String
-   
+
    map_ptrloc Next;           // Diversion
    map_ptrloc Next;           // Diversion
    unsigned long Flags;
    unsigned long Flags;
 
 
@@ -194,120 +194,120 @@ class pkgFLCache::PkgIterator
 {
 {
    Package *Pkg;
    Package *Pkg;
    pkgFLCache *Owner;
    pkgFLCache *Owner;
-   
+
    public:
    public:
-   
+
    inline bool end() const {return Owner == 0 || Pkg == Owner->PkgP?true:false;}
    inline bool end() const {return Owner == 0 || Pkg == Owner->PkgP?true:false;}
-   
+
    // Accessors
    // 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;
    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
 class pkgFLCache::DirIterator
 {
 {
    Directory *Dir;
    Directory *Dir;
    pkgFLCache *Owner;
    pkgFLCache *Owner;
-   
+
    public:
    public:
-   
+
    // Accessors
    // 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
 class pkgFLCache::DiverIterator
 {
 {
    Diversion *Diver;
    Diversion *Diver;
    pkgFLCache *Owner;
    pkgFLCache *Owner;
-   
+
    public:
    public:
 
 
    // Iteration
    // 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
    // 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 DivertFrom() const;
    inline NodeIterator DivertTo() const;
    inline NodeIterator DivertTo() const;
 
 
    DiverIterator() : Diver(0), Owner(0) {};
    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
 class pkgFLCache::NodeIterator
 {
 {
    Node *Nde;
    Node *Nde;
-   enum {NdePkg, NdeHash} Type;   
+   enum {NdePkg, NdeHash} Type;
    pkgFLCache *Owner;
    pkgFLCache *Owner;
-   
+
    public:
    public:
-   
+
    // Iteration
    // 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
    // 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;
    Package *RealPackage() const;
-   
+
    NodeIterator() : Nde(0), Type(NdeHash), Owner(0) {};
    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
 /* Inlines with forward references that cannot be included directly in their
    respsective classes */
    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
 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
 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()
 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
 #endif

+ 31 - 26
apt-pkg/acquire-item.cc

@@ -22,12 +22,21 @@
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
-#include <apt-pkg/md5.h>
 #include <apt-pkg/sha1.h>
 #include <apt-pkg/sha1.h>
 #include <apt-pkg/tagfile.h>
 #include <apt-pkg/tagfile.h>
 #include <apt-pkg/indexrecords.h>
 #include <apt-pkg/indexrecords.h>
-#include <apt-pkg/metaindex.h>
-
+#include <apt-pkg/acquire.h>
+#include <apt-pkg/hashes.h>
+#include <apt-pkg/indexfile.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/pkgrecords.h>
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <iostream>
+#include <vector>
 #include <sys/stat.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <unistd.h>
 #include <errno.h>
 #include <errno.h>
@@ -108,8 +117,8 @@ void pkgAcquire::Item::Start(string /*Message*/,unsigned long long Size)
 // Acquire::Item::Done - Item downloaded OK				/*{{{*/
 // Acquire::Item::Done - Item downloaded OK				/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-void pkgAcquire::Item::Done(string Message,unsigned long long Size,string Hash,
-			    pkgAcquire::MethodConfig *Cnf)
+void pkgAcquire::Item::Done(string Message,unsigned long long Size,string /*Hash*/,
+			    pkgAcquire::MethodConfig * /*Cnf*/)
 {
 {
    // We just downloaded something..
    // We just downloaded something..
    string FileName = LookupTag(Message,"Filename");
    string FileName = LookupTag(Message,"Filename");
@@ -253,10 +262,10 @@ string pkgAcqSubIndex::Custom600Headers()
    return "\nIndex-File: true\nFail-Ignore: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
    return "\nIndex-File: true\nFail-Ignore: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
 }
 }
 									/*}}}*/
 									/*}}}*/
-void pkgAcqSubIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf)	/*{{{*/
+void pkgAcqSubIndex::Failed(string Message,pkgAcquire::MethodConfig * /*Cnf*/)/*{{{*/
 {
 {
    if(Debug)
    if(Debug)
-      std::clog << "pkgAcqSubIndex failed: " << Desc.URI << std::endl;
+      std::clog << "pkgAcqSubIndex failed: " << Desc.URI << " with " << Message << std::endl;
 
 
    Complete = false;
    Complete = false;
    Status = StatDone;
    Status = StatDone;
@@ -544,10 +553,10 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string IndexDiffFile)		/*{{{*/
    return false;
    return false;
 }
 }
 									/*}}}*/
 									/*}}}*/
-void pkgAcqDiffIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf)	/*{{{*/
+void pkgAcqDiffIndex::Failed(string Message,pkgAcquire::MethodConfig * /*Cnf*/)/*{{{*/
 {
 {
    if(Debug)
    if(Debug)
-      std::clog << "pkgAcqDiffIndex failed: " << Desc.URI << std::endl
+      std::clog << "pkgAcqDiffIndex failed: " << Desc.URI << " with " << Message << std::endl
 		<< "Falling back to normal index file acquire" << std::endl;
 		<< "Falling back to normal index file acquire" << std::endl;
 
 
    new pkgAcqIndex(Owner, RealURI, Description, Desc.ShortDesc, 
    new pkgAcqIndex(Owner, RealURI, Description, Desc.ShortDesc, 
@@ -624,10 +633,10 @@ pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire *Owner,
    }
    }
 }
 }
 									/*}}}*/
 									/*}}}*/
-void pkgAcqIndexDiffs::Failed(string Message,pkgAcquire::MethodConfig *Cnf)	/*{{{*/
+void pkgAcqIndexDiffs::Failed(string Message,pkgAcquire::MethodConfig * /*Cnf*/)/*{{{*/
 {
 {
    if(Debug)
    if(Debug)
-      std::clog << "pkgAcqIndexDiffs failed: " << Desc.URI << std::endl
+      std::clog << "pkgAcqIndexDiffs failed: " << Desc.URI << " with " << Message << std::endl
 		<< "Falling back to normal index file acquire" << std::endl;
 		<< "Falling back to normal index file acquire" << std::endl;
    new pkgAcqIndex(Owner, RealURI, Description,Desc.ShortDesc, 
    new pkgAcqIndex(Owner, RealURI, Description,Desc.ShortDesc, 
 		   ExpectedHash);
 		   ExpectedHash);
@@ -709,7 +718,7 @@ bool pkgAcqIndexDiffs::QueueNextDiff()					/*{{{*/
    }
    }
 
 
    // queue the right diff
    // queue the right diff
-   Desc.URI = string(RealURI) + ".diff/" + available_patches[0].file + ".gz";
+   Desc.URI = RealURI + ".diff/" + available_patches[0].file + ".gz";
    Desc.Description = Description + " " + available_patches[0].file + string(".pdiff");
    Desc.Description = Description + " " + available_patches[0].file + string(".pdiff");
    DestFile = _config->FindDir("Dir::State::lists") + "partial/";
    DestFile = _config->FindDir("Dir::State::lists") + "partial/";
    DestFile += URItoFileName(RealURI + ".diff/" + available_patches[0].file);
    DestFile += URItoFileName(RealURI + ".diff/" + available_patches[0].file);
@@ -797,7 +806,7 @@ pkgAcqIndexMergeDiffs::pkgAcqIndexMergeDiffs(pkgAcquire *Owner,
    Desc.Owner = this;
    Desc.Owner = this;
    Desc.ShortDesc = ShortDesc;
    Desc.ShortDesc = ShortDesc;
 
 
-   Desc.URI = string(RealURI) + ".diff/" + patch.file + ".gz";
+   Desc.URI = RealURI + ".diff/" + patch.file + ".gz";
    Desc.Description = Description + " " + patch.file + string(".pdiff");
    Desc.Description = Description + " " + patch.file + string(".pdiff");
    DestFile = _config->FindDir("Dir::State::lists") + "partial/";
    DestFile = _config->FindDir("Dir::State::lists") + "partial/";
    DestFile += URItoFileName(RealURI + ".diff/" + patch.file);
    DestFile += URItoFileName(RealURI + ".diff/" + patch.file);
@@ -808,7 +817,7 @@ pkgAcqIndexMergeDiffs::pkgAcqIndexMergeDiffs(pkgAcquire *Owner,
    QueueURI(Desc);
    QueueURI(Desc);
 }
 }
 									/*}}}*/
 									/*}}}*/
-void pkgAcqIndexMergeDiffs::Failed(string Message,pkgAcquire::MethodConfig *Cnf)/*{{{*/
+void pkgAcqIndexMergeDiffs::Failed(string Message,pkgAcquire::MethodConfig * /*Cnf*/)/*{{{*/
 {
 {
    if(Debug)
    if(Debug)
       std::clog << "pkgAcqIndexMergeDiffs failed: " << Desc.URI << " with " << Message << std::endl;
       std::clog << "pkgAcqIndexMergeDiffs failed: " << Desc.URI << " with " << Message << std::endl;
@@ -1558,7 +1567,7 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify)				/*{{{*/
 	 {
 	 {
 	    std::vector<std::string> types = APT::Configuration::getCompressionTypes();
 	    std::vector<std::string> types = APT::Configuration::getCompressionTypes();
 	    for (std::vector<std::string>::const_iterator t = types.begin(); t != types.end(); ++t)
 	    for (std::vector<std::string>::const_iterator t = types.begin(); t != types.end(); ++t)
-	       if (MetaIndexParser->Exists(string((*Target)->MetaKey).append(".").append(*t)) == true)
+	       if (MetaIndexParser->Exists((*Target)->MetaKey + "." + *t) == true)
 	       {
 	       {
 		  compressedAvailable = true;
 		  compressedAvailable = true;
 		  break;
 		  break;
@@ -1596,7 +1605,7 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify)				/*{{{*/
 	 else if (transInRelease == false || Record != NULL || compressedAvailable == true)
 	 else if (transInRelease == false || Record != NULL || compressedAvailable == true)
 	 {
 	 {
 	    if (_config->FindB("Acquire::PDiffs",true) == true && transInRelease == true &&
 	    if (_config->FindB("Acquire::PDiffs",true) == true && transInRelease == true &&
-		MetaIndexParser->Exists(string((*Target)->MetaKey).append(".diff/Index")) == true)
+		MetaIndexParser->Exists((*Target)->MetaKey + ".diff/Index") == true)
 	       new pkgAcqDiffIndex(Owner, (*Target)->URI, (*Target)->Description,
 	       new pkgAcqDiffIndex(Owner, (*Target)->URI, (*Target)->Description,
 				   (*Target)->ShortDesc, ExpectedIndexHash);
 				   (*Target)->ShortDesc, ExpectedIndexHash);
 	    else
 	    else
@@ -1610,7 +1619,7 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify)				/*{{{*/
          in the Meta-Index file. Ideal would be if pkgAcqDiffIndex would test this
          in the Meta-Index file. Ideal would be if pkgAcqDiffIndex would test this
          instead, but passing the required info to it is to much hassle */
          instead, but passing the required info to it is to much hassle */
       if(_config->FindB("Acquire::PDiffs",true) == true && (verify == false ||
       if(_config->FindB("Acquire::PDiffs",true) == true && (verify == false ||
-	  MetaIndexParser->Exists(string((*Target)->MetaKey).append(".diff/Index")) == true))
+	  MetaIndexParser->Exists((*Target)->MetaKey + ".diff/Index") == true))
 	 new pkgAcqDiffIndex(Owner, (*Target)->URI, (*Target)->Description,
 	 new pkgAcqDiffIndex(Owner, (*Target)->URI, (*Target)->Description,
 			     (*Target)->ShortDesc, ExpectedIndexHash);
 			     (*Target)->ShortDesc, ExpectedIndexHash);
       else
       else
@@ -1635,7 +1644,7 @@ bool pkgAcqMetaIndex::VerifyVendor(string Message)			/*{{{*/
       missingkeys += (Fingerprint);
       missingkeys += (Fingerprint);
    }
    }
    if(!missingkeys.empty())
    if(!missingkeys.empty())
-      _error->Warning("%s", string(msg+missingkeys).c_str());
+      _error->Warning("%s", (msg + missingkeys).c_str());
 
 
    string Transformed = MetaIndexParser->GetExpectedDist();
    string Transformed = MetaIndexParser->GetExpectedDist();
 
 
@@ -1698,7 +1707,7 @@ bool pkgAcqMetaIndex::VerifyVendor(string Message)			/*{{{*/
 // pkgAcqMetaIndex::Failed - no Release file present or no signature file present	/*{{{*/
 // pkgAcqMetaIndex::Failed - no Release file present or no signature file present	/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-void pkgAcqMetaIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
+void pkgAcqMetaIndex::Failed(string Message,pkgAcquire::MethodConfig * /*Cnf*/)
 {
 {
    if (AuthPass == true)
    if (AuthPass == true)
    {
    {
@@ -1856,7 +1865,7 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
       _error->Error(_("I wasn't able to locate a file for the %s package. "
       _error->Error(_("I wasn't able to locate a file for the %s package. "
 		      "This might mean you need to manually fix this package. "
 		      "This might mean you need to manually fix this package. "
 		      "(due to missing arch)"),
 		      "(due to missing arch)"),
-		    Version.ParentPkg().Name());
+		    Version.ParentPkg().FullName().c_str());
       return;
       return;
    }
    }
    
    
@@ -1984,7 +1993,7 @@ bool pkgAcqArchive::QueueNext()
       Desc.URI = Index->ArchiveURI(PkgFile);
       Desc.URI = Index->ArchiveURI(PkgFile);
       Desc.Description = Index->ArchiveInfo(Version);
       Desc.Description = Index->ArchiveInfo(Version);
       Desc.Owner = this;
       Desc.Owner = this;
-      Desc.ShortDesc = Version.ParentPkg().Name();
+      Desc.ShortDesc = Version.ParentPkg().FullName(true);
 
 
       // See if we already have the file. (Legacy filenames)
       // See if we already have the file. (Legacy filenames)
       FileSize = Version->Size;
       FileSize = Version->Size;
@@ -2051,10 +2060,6 @@ bool pkgAcqArchive::QueueNext()
 
 
       // Create the item
       // Create the item
       Local = false;
       Local = false;
-      Desc.URI = Index->ArchiveURI(PkgFile);
-      Desc.Description = Index->ArchiveInfo(Version);
-      Desc.Owner = this;
-      Desc.ShortDesc = Version.ParentPkg().Name();
       QueueURI(Desc);
       QueueURI(Desc);
 
 
       ++Vf;
       ++Vf;
@@ -2153,7 +2158,7 @@ void pkgAcqArchive::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
 									/*}}}*/
 									/*}}}*/
 // AcqArchive::IsTrusted - Determine whether this archive comes from a trusted source /*{{{*/
 // AcqArchive::IsTrusted - Determine whether this archive comes from a trusted source /*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
-bool pkgAcqArchive::IsTrusted()
+APT_PURE bool pkgAcqArchive::IsTrusted()
 {
 {
    return Trusted;
    return Trusted;
 }
 }

+ 12 - 7
apt-pkg/acquire-item.h

@@ -24,6 +24,10 @@
 #include <apt-pkg/hashes.h>
 #include <apt-pkg/hashes.h>
 #include <apt-pkg/weakptr.h>
 #include <apt-pkg/weakptr.h>
 #include <apt-pkg/pkgcache.h>
 #include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+
+#include <string>
+#include <vector>
 
 
 #ifndef APT_8_CLEANER_HEADERS
 #ifndef APT_8_CLEANER_HEADERS
 #include <apt-pkg/indexfile.h>
 #include <apt-pkg/indexfile.h>
@@ -64,7 +68,7 @@ class pkgAcquire::Item : public WeakPointable
 
 
    /** \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 Item Metadata about this item (its URI and
     *  description).
     *  description).
     */
     */
    inline void QueueURI(ItemDesc &Item)
    inline void QueueURI(ItemDesc &Item)
@@ -79,7 +83,7 @@ class pkgAcquire::Item : public WeakPointable
     *
     *
     *  \param From The file to be renamed.
     *  \param From The file to be renamed.
     *
     *
-    *  \param To The new name of #From.  If #To exists it will be
+    *  \param To The new name of \a From.  If \a To exists it will be
     *  overwritten.
     *  overwritten.
     */
     */
    void Rename(std::string From,std::string To);
    void Rename(std::string From,std::string To);
@@ -115,7 +119,7 @@ class pkgAcquire::Item : public WeakPointable
      } 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 #ItemState is #StatError or #StatAuthError.
     */
     */
    std::string ErrorText;
    std::string ErrorText;
 
 
@@ -293,7 +297,6 @@ class pkgAcquire::Item : public WeakPointable
    /** \brief Rename failed file and set error
    /** \brief Rename failed file and set error
     *
     *
     * \param state respresenting the error we encountered
     * \param state respresenting the error we encountered
-    * \param errorMsg a message describing the error
     */
     */
    bool RenameOnError(RenameOnErrorState const state);
    bool RenameOnError(RenameOnErrorState const state);
 };
 };
@@ -636,7 +639,7 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item
    /** \brief Create an index diff item.
    /** \brief Create an index diff item.
     *
     *
     *  After filling in its basic fields, this invokes Finish(true) if
     *  After filling in its basic fields, this invokes Finish(true) if
-    *  #diffs is empty, or QueueNextDiff() otherwise.
+    *  \a diffs is empty, or QueueNextDiff() otherwise.
     *
     *
     *  \param Owner The pkgAcquire object that owns this item.
     *  \param Owner The pkgAcquire object that owns this item.
     *
     *
@@ -651,6 +654,8 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item
     *  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 ServerSha1 is the sha1sum of the current file on the server
+    *
     *  \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.
@@ -1162,8 +1167,8 @@ class pkgAcqFile : public pkgAcquire::Item
     *  \param IsIndexFile The file is considered a IndexFile and cache-control
     *  \param IsIndexFile The file is considered a IndexFile and cache-control
     *                     headers like "cache-control: max-age=0" are send
     *                     headers like "cache-control: max-age=0" are send
     *
     *
-    * If DestFilename is empty, download to DestDir/<basename> if
-    * DestDir is non-empty, $CWD/<basename> otherwise.  If
+    * If DestFilename is empty, download to DestDir/\<basename\> 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.
     */
     */

+ 10 - 2
apt-pkg/acquire-method.cc

@@ -23,10 +23,18 @@
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/hashes.h>
 #include <apt-pkg/hashes.h>
-
+#include <apt-pkg/md5.h>
+#include <apt-pkg/sha1.h>
+#include <apt-pkg/sha2.h>
+
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <string>
+#include <vector>
 #include <iostream>
 #include <iostream>
 #include <stdio.h>
 #include <stdio.h>
-#include <sys/signal.h>
 									/*}}}*/
 									/*}}}*/
 
 
 using namespace std;
 using namespace std;

+ 1 - 0
apt-pkg/acquire-method.h

@@ -21,6 +21,7 @@
 #define PKGLIB_ACQUIRE_METHOD_H
 #define PKGLIB_ACQUIRE_METHOD_H
 
 
 #include <stdarg.h>
 #include <stdarg.h>
+#include <time.h>
 
 
 #include <string>
 #include <string>
 #include <vector>
 #include <vector>

+ 5 - 2
apt-pkg/acquire-worker.cc

@@ -14,20 +14,23 @@
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
 #include <config.h>
 #include <config.h>
 
 
+#include <apt-pkg/acquire.h>
 #include <apt-pkg/acquire-worker.h>
 #include <apt-pkg/acquire-worker.h>
 #include <apt-pkg/acquire-item.h>
 #include <apt-pkg/acquire-item.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
+#include <apt-pkg/hashes.h>
 
 
+#include <string>
+#include <vector>
 #include <iostream>
 #include <iostream>
 #include <sstream>
 #include <sstream>
-#include <fstream>
 
 
 #include <sys/stat.h>
 #include <sys/stat.h>
+#include <stdlib.h>
 #include <unistd.h>
 #include <unistd.h>
-#include <fcntl.h>
 #include <signal.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdio.h>
 #include <errno.h>
 #include <errno.h>

+ 5 - 2
apt-pkg/acquire-worker.h

@@ -22,6 +22,9 @@
 #include <apt-pkg/acquire.h>
 #include <apt-pkg/acquire.h>
 #include <apt-pkg/weakptr.h>
 #include <apt-pkg/weakptr.h>
 
 
+#include <sys/types.h>
+#include <string>
+#include <vector>
 
 
 /** \brief A fetch subprocess.
 /** \brief A fetch subprocess.
  *
  *
@@ -136,8 +139,8 @@ class pkgAcquire::Worker : public WeakPointable
    
    
    /** \brief Retrieve any available messages from the subprocess.
    /** \brief Retrieve any available messages from the subprocess.
     *
     *
-    *  The messages are retrieved as in ::ReadMessages(), and
-    *  MessageFailure() is invoked if an error occurs; in particular,
+    *  The messages are retrieved as in \link strutl.h ReadMessages()\endlink, and
+    *  #MethodFailure() is invoked if an error occurs; in particular,
     *  if the pipe to the subprocess dies unexpectedly while a message
     *  if the pipe to the subprocess dies unexpectedly while a message
     *  is being read.
     *  is being read.
     *
     *

+ 10 - 4
apt-pkg/acquire.cc

@@ -23,12 +23,18 @@
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
 
 
+#include <string>
+#include <vector>
 #include <iostream>
 #include <iostream>
 #include <sstream>
 #include <sstream>
 #include <stdio.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
 
 
 #include <dirent.h>
 #include <dirent.h>
 #include <sys/time.h>
 #include <sys/time.h>
+#include <sys/select.h>
 #include <errno.h>
 #include <errno.h>
 
 
 #include <apti18n.h>
 #include <apti18n.h>
@@ -468,7 +474,7 @@ void pkgAcquire::Bump()
 pkgAcquire::Worker *pkgAcquire::WorkerStep(Worker *I)
 pkgAcquire::Worker *pkgAcquire::WorkerStep(Worker *I)
 {
 {
    return I->NextAcquire;
    return I->NextAcquire;
-};
+}
 									/*}}}*/
 									/*}}}*/
 // Acquire::Clean - Cleans a directory					/*{{{*/
 // Acquire::Clean - Cleans a directory					/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
@@ -520,7 +526,7 @@ bool pkgAcquire::Clean(string Dir)
 // Acquire::TotalNeeded - Number of bytes to fetch			/*{{{*/
 // Acquire::TotalNeeded - Number of bytes to fetch			/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* This is the total number of bytes needed */
 /* This is the total number of bytes needed */
-unsigned long long pkgAcquire::TotalNeeded()
+APT_PURE unsigned long long pkgAcquire::TotalNeeded()
 {
 {
    unsigned long long Total = 0;
    unsigned long long Total = 0;
    for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); ++I)
    for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); ++I)
@@ -531,7 +537,7 @@ unsigned long long pkgAcquire::TotalNeeded()
 // Acquire::FetchNeeded - Number of bytes needed to get			/*{{{*/
 // Acquire::FetchNeeded - Number of bytes needed to get			/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* This is the number of bytes that is not local */
 /* This is the number of bytes that is not local */
-unsigned long long pkgAcquire::FetchNeeded()
+APT_PURE unsigned long long pkgAcquire::FetchNeeded()
 {
 {
    unsigned long long Total = 0;
    unsigned long long Total = 0;
    for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); ++I)
    for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); ++I)
@@ -543,7 +549,7 @@ unsigned long long pkgAcquire::FetchNeeded()
 // Acquire::PartialPresent - Number of partial bytes we already have	/*{{{*/
 // Acquire::PartialPresent - Number of partial bytes we already have	/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* This is the number of bytes that is not local */
 /* This is the number of bytes that is not local */
-unsigned long long pkgAcquire::PartialPresent()
+APT_PURE unsigned long long pkgAcquire::PartialPresent()
 {
 {
   unsigned long long Total = 0;
   unsigned long long Total = 0;
    for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); ++I)
    for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); ++I)

+ 10 - 5
apt-pkg/acquire.h

@@ -72,8 +72,13 @@
 #include <vector>
 #include <vector>
 #include <string>
 #include <string>
 
 
+#include <stddef.h>
 #include <sys/time.h>
 #include <sys/time.h>
+#include <sys/select.h>
+
+#ifndef APT_10_CLEANER_HEADERS
 #include <unistd.h>
 #include <unistd.h>
+#endif
 
 
 #ifndef APT_8_CLEANER_HEADERS
 #ifndef APT_8_CLEANER_HEADERS
 using std::vector;
 using std::vector;
@@ -282,18 +287,18 @@ class pkgAcquire
     */
     */
    void Shutdown();
    void Shutdown();
    
    
-   /** \brief Get the first #Worker object.
+   /** \brief Get the first Worker object.
     *
     *
     *  \return the first active worker in this download process.
     *  \return the first active worker in this download process.
     */
     */
    inline Worker *WorkersBegin() {return Workers;};
    inline Worker *WorkersBegin() {return Workers;};
 
 
-   /** \brief Advance to the next #Worker object.
+   /** \brief Advance to the next Worker object.
     *
     *
     *  \return the worker immediately following I, or \b NULL if none
     *  \return the worker immediately following I, or \b NULL if none
     *  exists.
     *  exists.
     */
     */
-   Worker *WorkerStep(Worker *I);
+   Worker *WorkerStep(Worker *I) APT_PURE;
 
 
    /** \brief Get the head of the list of items. */
    /** \brief Get the head of the list of items. */
    inline ItemIterator ItemsBegin() {return Items.begin();};
    inline ItemIterator ItemsBegin() {return Items.begin();};
@@ -353,7 +358,7 @@ class pkgAcquire
    void SetLog(pkgAcquireStatus *Progress) { Log = Progress; }
    void SetLog(pkgAcquireStatus *Progress) { Log = Progress; }
 
 
    /** \brief Construct a new pkgAcquire. */
    /** \brief Construct a new pkgAcquire. */
-   pkgAcquire(pkgAcquireStatus *Log) __deprecated;
+   pkgAcquire(pkgAcquireStatus *Log) APT_DEPRECATED;
    pkgAcquire();
    pkgAcquire();
 
 
    /** \brief Destroy this pkgAcquire object.
    /** \brief Destroy this pkgAcquire object.
@@ -476,7 +481,7 @@ class pkgAcquire::Queue
     *  \return the first item in the queue whose URI is #URI and that
     *  \return the first item in the queue whose URI is #URI and that
     *  is being downloaded by #Owner.
     *  is being downloaded by #Owner.
     */
     */
-   QItem *FindItem(std::string URI,pkgAcquire::Worker *Owner);
+   QItem *FindItem(std::string URI,pkgAcquire::Worker *Owner) APT_PURE;
 
 
    /** Presumably this should start downloading an item?
    /** Presumably this should start downloading an item?
     *
     *

+ 42 - 27
apt-pkg/algorithms.cc

@@ -19,19 +19,18 @@
 #include <apt-pkg/algorithms.h>
 #include <apt-pkg/algorithms.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
-#include <apt-pkg/version.h>
 #include <apt-pkg/sptr.h>
 #include <apt-pkg/sptr.h>
-#include <apt-pkg/acquire-item.h>
 #include <apt-pkg/edsp.h>
 #include <apt-pkg/edsp.h>
-#include <apt-pkg/sourcelist.h>
-#include <apt-pkg/fileutl.h>
 #include <apt-pkg/progress.h>
 #include <apt-pkg/progress.h>
+#include <apt-pkg/depcache.h>
+#include <apt-pkg/packagemanager.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
 
 
-#include <sys/types.h>
+#include <string.h>
+#include <string>
 #include <cstdlib>
 #include <cstdlib>
-#include <algorithm>
 #include <iostream>
 #include <iostream>
-#include <stdio.h>
 
 
 #include <apti18n.h>
 #include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
@@ -394,8 +393,18 @@ void pkgProblemResolver::MakeScores()
    };
    };
    int PrioEssentials = _config->FindI("pkgProblemResolver::Scores::Essentials",100);
    int PrioEssentials = _config->FindI("pkgProblemResolver::Scores::Essentials",100);
    int PrioInstalledAndNotObsolete = _config->FindI("pkgProblemResolver::Scores::NotObsolete",1);
    int PrioInstalledAndNotObsolete = _config->FindI("pkgProblemResolver::Scores::NotObsolete",1);
-   int PrioDepends = _config->FindI("pkgProblemResolver::Scores::Depends",1);
-   int PrioRecommends = _config->FindI("pkgProblemResolver::Scores::Recommends",1);
+   int DepMap[] = {
+      0,
+      _config->FindI("pkgProblemResolver::Scores::Depends",1),
+      _config->FindI("pkgProblemResolver::Scores::PreDepends",1),
+      _config->FindI("pkgProblemResolver::Scores::Suggests",0),
+      _config->FindI("pkgProblemResolver::Scores::Recommends",1),
+      _config->FindI("pkgProblemResolver::Scores::Conflicts",-1),
+      _config->FindI("pkgProblemResolver::Scores::Replaces",0),
+      _config->FindI("pkgProblemResolver::Scores::Obsoletes",0),
+      _config->FindI("pkgProblemResolver::Scores::Breaks",-1),
+      _config->FindI("pkgProblemResolver::Scores::Enhances",0)
+   };
    int AddProtected = _config->FindI("pkgProblemResolver::Scores::AddProtected",10000);
    int AddProtected = _config->FindI("pkgProblemResolver::Scores::AddProtected",10000);
    int AddEssential = _config->FindI("pkgProblemResolver::Scores::AddEssential",5000);
    int AddEssential = _config->FindI("pkgProblemResolver::Scores::AddEssential",5000);
 
 
@@ -408,8 +417,15 @@ void pkgProblemResolver::MakeScores()
          << "  Extra => " << PrioMap[pkgCache::State::Extra] << endl
          << "  Extra => " << PrioMap[pkgCache::State::Extra] << endl
          << "  Essentials => " << PrioEssentials << endl
          << "  Essentials => " << PrioEssentials << endl
          << "  InstalledAndNotObsolete => " << PrioInstalledAndNotObsolete << endl
          << "  InstalledAndNotObsolete => " << PrioInstalledAndNotObsolete << endl
-         << "  Depends => " << PrioDepends << endl
-         << "  Recommends => " << PrioRecommends << endl
+         << "  Pre-Depends => " << DepMap[pkgCache::Dep::PreDepends] << endl
+         << "  Depends => " << DepMap[pkgCache::Dep::Depends] << endl
+         << "  Recommends => " << DepMap[pkgCache::Dep::Recommends] << endl
+         << "  Suggests => " << DepMap[pkgCache::Dep::Suggests] << endl
+         << "  Conflicts => " << DepMap[pkgCache::Dep::Conflicts] << endl
+         << "  Breaks => " << DepMap[pkgCache::Dep::DpkgBreaks] << endl
+         << "  Replaces => " << DepMap[pkgCache::Dep::Replaces] << endl
+         << "  Obsoletes => " << DepMap[pkgCache::Dep::Obsoletes] << endl
+         << "  Enhances => " << DepMap[pkgCache::Dep::Enhances] << endl
          << "  AddProtected => " << AddProtected << endl
          << "  AddProtected => " << AddProtected << endl
          << "  AddEssential => " << AddEssential << endl;
          << "  AddEssential => " << AddEssential << endl;
 
 
@@ -439,24 +455,23 @@ void pkgProblemResolver::MakeScores()
       */
       */
       if (I->CurrentVer != 0 && Cache[I].CandidateVer != 0 && Cache[I].CandidateVerIter(Cache).Downloadable())
       if (I->CurrentVer != 0 && Cache[I].CandidateVer != 0 && Cache[I].CandidateVerIter(Cache).Downloadable())
 	 Score += PrioInstalledAndNotObsolete;
 	 Score += PrioInstalledAndNotObsolete;
-   }
 
 
-   // Now that we have the base scores we go and propagate dependencies
-   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
-   {
-      if (Cache[I].InstallVer == 0)
-	 continue;
-      
+      // propagate score points along dependencies
       for (pkgCache::DepIterator D = Cache[I].InstVerIter(Cache).DependsList(); D.end() == false; ++D)
       for (pkgCache::DepIterator D = Cache[I].InstVerIter(Cache).DependsList(); D.end() == false; ++D)
       {
       {
-	 if (D->Type == pkgCache::Dep::Depends || 
-	     D->Type == pkgCache::Dep::PreDepends)
-	    Scores[D.TargetPkg()->ID] += PrioDepends;
-	 else if (D->Type == pkgCache::Dep::Recommends)
-	    Scores[D.TargetPkg()->ID] += PrioRecommends;
+	 if (DepMap[D->Type] == 0)
+	    continue;
+	 pkgCache::PkgIterator const T = D.TargetPkg();
+	 if (D->Version != 0)
+	 {
+	    pkgCache::VerIterator const IV = Cache[T].InstVerIter(Cache);
+	    if (IV.end() == true || D.IsSatisfied(IV) != D.IsNegative())
+	       continue;
+	 }
+	 Scores[T->ID] += DepMap[D->Type];
       }
       }
-   }   
-   
+   }
+
    // Copy the scores to advoid additive looping
    // Copy the scores to advoid additive looping
    SPtrArray<int> OldScores = new int[Size];
    SPtrArray<int> OldScores = new int[Size];
    memcpy(OldScores,Scores,sizeof(*Scores)*Size);
    memcpy(OldScores,Scores,sizeof(*Scores)*Size);
@@ -869,8 +884,8 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix)
                }
                }
 
 
 	       if (Debug == true)
 	       if (Debug == true)
-		  clog << "  Considering " << Pkg.FullName(false) << ' ' << (int)Scores[Pkg->ID] <<
-		  " as a solution to " << I.FullName(false) << ' ' << (int)Scores[I->ID] << endl;
+		  clog << "  Considering " << Pkg.FullName(false) << ' ' << Scores[Pkg->ID] <<
+		  " as a solution to " << I.FullName(false) << ' ' << Scores[I->ID] << endl;
 
 
 	       /* Try to fix the package under consideration rather than
 	       /* Try to fix the package under consideration rather than
 	          fiddle with the VList package */
 	          fiddle with the VList package */

+ 5 - 2
apt-pkg/algorithms.h

@@ -33,8 +33,11 @@
 
 
 #include <apt-pkg/packagemanager.h>
 #include <apt-pkg/packagemanager.h>
 #include <apt-pkg/depcache.h>
 #include <apt-pkg/depcache.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
 
 
 #include <iostream>
 #include <iostream>
+#include <string>
 
 
 #include <apt-pkg/macros.h>
 #include <apt-pkg/macros.h>
 
 
@@ -111,7 +114,7 @@ class pkgProblemResolver						/*{{{*/
    
    
    // Sort stuff
    // Sort stuff
    static pkgProblemResolver *This;
    static pkgProblemResolver *This;
-   static int ScoreSort(const void *a,const void *b);
+   static int ScoreSort(const void *a,const void *b) APT_PURE;
 
 
    struct PackageKill
    struct PackageKill
    {
    {
@@ -140,7 +143,7 @@ class pkgProblemResolver						/*{{{*/
    // Try to resolve problems only by using keep
    // Try to resolve problems only by using keep
    bool ResolveByKeep();
    bool ResolveByKeep();
 
 
-   __deprecated void InstallProtect();
+   APT_DEPRECATED void InstallProtect();
 
 
    pkgProblemResolver(pkgDepCache *Cache);
    pkgProblemResolver(pkgDepCache *Cache);
    ~pkgProblemResolver();
    ~pkgProblemResolver();

+ 53 - 66
apt-pkg/aptconfiguration.cc

@@ -17,14 +17,19 @@
 #include <apt-pkg/macros.h>
 #include <apt-pkg/macros.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
 
 
-#include <sys/types.h>
 #include <dirent.h>
 #include <dirent.h>
 #include <stdio.h>
 #include <stdio.h>
 #include <fcntl.h>
 #include <fcntl.h>
-
+#include <ctype.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
 #include <algorithm>
 #include <algorithm>
 #include <string>
 #include <string>
 #include <vector>
 #include <vector>
+
+#include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
 namespace APT {
 namespace APT {
 // getCompressionTypes - Return Vector of usable compressiontypes	/*{{{*/
 // getCompressionTypes - Return Vector of usable compressiontypes	/*{{{*/
@@ -49,11 +54,6 @@ const Configuration::getCompressionTypes(bool const &Cached) {
 	setDefaultConfigurationForCompressors();
 	setDefaultConfigurationForCompressors();
 	std::vector<APT::Configuration::Compressor> const compressors = getCompressors();
 	std::vector<APT::Configuration::Compressor> const compressors = getCompressors();
 
 
-	// accept non-list order as override setting for config settings on commandline
-	std::string const overrideOrder = _config->Find("Acquire::CompressionTypes::Order","");
-	if (overrideOrder.empty() == false)
-		types.push_back(overrideOrder);
-
 	// load the order setting into our vector
 	// load the order setting into our vector
 	std::vector<std::string> const order = _config->FindVector("Acquire::CompressionTypes::Order");
 	std::vector<std::string> const order = _config->FindVector("Acquire::CompressionTypes::Order");
 	for (std::vector<std::string>::const_iterator o = order.begin();
 	for (std::vector<std::string>::const_iterator o = order.begin();
@@ -227,61 +227,11 @@ std::vector<std::string> const Configuration::getLanguages(bool const &All,
 			}
 			}
 		}
 		}
 	} else {
 	} else {
+		// cornercase: LANG=C, so we use only "en" Translation
 		environment.push_back("en");
 		environment.push_back("en");
 	}
 	}
 
 
-	// Support settings like Acquire::Languages=none on the command line to
-	// override the configuration settings vector of languages.
-	string const forceLang = _config->Find("Acquire::Languages","");
-	if (forceLang.empty() == false) {
-		if (forceLang == "none") {
-			codes.clear();
-			allCodes.clear();
-			allCodes.push_back("none");
-		} else {
-			if (forceLang == "environment")
-				codes = environment;
-			else
-				codes.push_back(forceLang);
-			allCodes = codes;
-			for (std::vector<string>::const_iterator b = builtin.begin();
-			     b != builtin.end(); ++b)
-				if (std::find(allCodes.begin(), allCodes.end(), *b) == allCodes.end())
-					allCodes.push_back(*b);
-		}
-		if (All == true)
-			return allCodes;
-		else
-			return codes;
-	}
-
-	// cornercase: LANG=C, so we use only "en" Translation
-	if (envShort == "C") {
-		allCodes = codes = environment;
-		allCodes.insert(allCodes.end(), builtin.begin(), builtin.end());
-		if (All == true)
-			return allCodes;
-		else
-			return codes;
-	}
-
-	std::vector<string> const lang = _config->FindVector("Acquire::Languages");
-	// the default setting -> "environment, en"
-	if (lang.empty() == true) {
-		codes = environment;
-		if (envShort != "en")
-			codes.push_back("en");
-		allCodes = codes;
-		for (std::vector<string>::const_iterator b = builtin.begin();
-		     b != builtin.end(); ++b)
-			if (std::find(allCodes.begin(), allCodes.end(), *b) == allCodes.end())
-				allCodes.push_back(*b);
-		if (All == true)
-			return allCodes;
-		else
-			return codes;
-	}
-
+	std::vector<string> const lang = _config->FindVector("Acquire::Languages", "environment,en");
 	// the configs define the order, so add the environment
 	// the configs define the order, so add the environment
 	// then needed and ensure the codes are not listed twice.
 	// then needed and ensure the codes are not listed twice.
 	bool noneSeen = false;
 	bool noneSeen = false;
@@ -308,10 +258,15 @@ std::vector<std::string> const Configuration::getLanguages(bool const &All,
 		allCodes.push_back(*l);
 		allCodes.push_back(*l);
 	}
 	}
 
 
-	for (std::vector<string>::const_iterator b = builtin.begin();
-	     b != builtin.end(); ++b)
-		if (std::find(allCodes.begin(), allCodes.end(), *b) == allCodes.end())
-			allCodes.push_back(*b);
+	if (allCodes.empty() == false) {
+		for (std::vector<string>::const_iterator b = builtin.begin();
+		     b != builtin.end(); ++b)
+			if (std::find(allCodes.begin(), allCodes.end(), *b) == allCodes.end())
+				allCodes.push_back(*b);
+	} else {
+		// "none" was forced
+		allCodes.push_back("none");
+	}
 
 
 	if (All == true)
 	if (All == true)
 		return allCodes;
 		return allCodes;
@@ -320,7 +275,7 @@ std::vector<std::string> const Configuration::getLanguages(bool const &All,
 }
 }
 									/*}}}*/
 									/*}}}*/
 // checkLanguage - are we interested in the given Language?		/*{{{*/
 // checkLanguage - are we interested in the given Language?		/*{{{*/
-bool const Configuration::checkLanguage(std::string Lang, bool const All) {
+bool Configuration::checkLanguage(std::string Lang, bool const All) {
 	// the empty Language is always interesting as it is the original
 	// the empty Language is always interesting as it is the original
 	if (Lang.empty() == true)
 	if (Lang.empty() == true)
 		return true;
 		return true;
@@ -440,7 +395,7 @@ std::vector<std::string> const Configuration::getArchitectures(bool const &Cache
 }
 }
 									/*}}}*/
 									/*}}}*/
 // checkArchitecture - are we interested in the given Architecture?	/*{{{*/
 // checkArchitecture - are we interested in the given Architecture?	/*{{{*/
-bool const Configuration::checkArchitecture(std::string const &Arch) {
+bool Configuration::checkArchitecture(std::string const &Arch) {
 	if (Arch == "all")
 	if (Arch == "all")
 		return true;
 		return true;
 	std::vector<std::string> const archs = getArchitectures(true);
 	std::vector<std::string> const archs = getArchitectures(true);
@@ -476,7 +431,7 @@ void Configuration::setDefaultConfigurationForCompressors() {
 	}
 	}
 }
 }
 									/*}}}*/
 									/*}}}*/
-// getCompressors - Return Vector of usbale compressors			/*{{{*/
+// getCompressors - Return Vector of usealbe compressors		/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* return a vector of compressors used by apt-ftparchive in the
 /* return a vector of compressors used by apt-ftparchive in the
    multicompress functionality or to detect data.tar files */
    multicompress functionality or to detect data.tar files */
@@ -507,8 +462,16 @@ const Configuration::getCompressors(bool const Cached) {
 #endif
 #endif
 	if (_config->Exists("Dir::Bin::xz") == false || FileExists(_config->FindFile("Dir::Bin::xz")) == true)
 	if (_config->Exists("Dir::Bin::xz") == false || FileExists(_config->FindFile("Dir::Bin::xz")) == true)
 		compressors.push_back(Compressor("xz",".xz","xz","-6","-d",4));
 		compressors.push_back(Compressor("xz",".xz","xz","-6","-d",4));
+#ifdef HAVE_LZMA
+	else
+		compressors.push_back(Compressor("xz",".xz","false", NULL, NULL, 4));
+#endif
 	if (_config->Exists("Dir::Bin::lzma") == false || FileExists(_config->FindFile("Dir::Bin::lzma")) == true)
 	if (_config->Exists("Dir::Bin::lzma") == false || FileExists(_config->FindFile("Dir::Bin::lzma")) == true)
 		compressors.push_back(Compressor("lzma",".lzma","lzma","-9","-d",5));
 		compressors.push_back(Compressor("lzma",".lzma","lzma","-9","-d",5));
+#ifdef HAVE_LZMA
+	else
+		compressors.push_back(Compressor("lzma",".lzma","false", NULL, NULL, 5));
+#endif
 
 
 	std::vector<std::string> const comp = _config->FindVector("APT::Compressor");
 	std::vector<std::string> const comp = _config->FindVector("APT::Compressor");
 	for (std::vector<std::string>::const_iterator c = comp.begin();
 	for (std::vector<std::string>::const_iterator c = comp.begin();
@@ -558,4 +521,28 @@ Configuration::Compressor::Compressor(char const *name, char const *extension,
 		UncompressArgs.push_back(uncompressArg);
 		UncompressArgs.push_back(uncompressArg);
 }
 }
 									/*}}}*/
 									/*}}}*/
+// getBuildProfiles - return a vector of enabled build profiles		/*{{{*/
+std::vector<std::string> const Configuration::getBuildProfiles() {
+	// order is: override value (~= commandline), environment variable, list (~= config file)
+	std::string profiles_env = getenv("DEB_BUILD_PROFILES") == 0 ? "" : getenv("DEB_BUILD_PROFILES");
+	if (profiles_env.empty() == false) {
+		profiles_env = SubstVar(profiles_env, " ", ",");
+		std::string const bp = _config->Find("APT::Build-Profiles");
+		_config->Clear("APT::Build-Profiles");
+		if (bp.empty() == false)
+			_config->Set("APT::Build-Profiles", bp);
+	}
+	return _config->FindVector("APT::Build-Profiles", profiles_env);
+}
+std::string const Configuration::getBuildProfilesString() {
+	std::vector<std::string> profiles = getBuildProfiles();
+	if (profiles.empty() == true)
+		return "";
+	std::vector<std::string>::const_iterator p = profiles.begin();
+	std::string list = *p;
+	for (; p != profiles.end(); ++p)
+	   list.append(",").append(*p);
+	return list;
+}
+									/*}}}*/
 }
 }

+ 7 - 2
apt-pkg/aptconfiguration.h

@@ -73,7 +73,7 @@ public:									/*{{{*/
 	 *  \param All defines if we check against all codes or only against used codes
 	 *  \param All defines if we check against all codes or only against used codes
 	 *  \return true if we are interested, false otherwise
 	 *  \return true if we are interested, false otherwise
 	 */
 	 */
-	bool static const checkLanguage(std::string Lang, bool const All = false);
+	bool static checkLanguage(std::string Lang, bool const All = false);
 
 
 	/** \brief Returns a vector of Architectures we support
 	/** \brief Returns a vector of Architectures we support
 	 *
 	 *
@@ -89,7 +89,7 @@ public:									/*{{{*/
 	 *  \param Arch we want to check
 	 *  \param Arch we want to check
 	 *  \return true if we are interested, false otherwise
 	 *  \return true if we are interested, false otherwise
 	 */
 	 */
-	bool static const checkArchitecture(std::string const &Arch);
+	bool static checkArchitecture(std::string const &Arch);
 
 
 	/** \brief Representation of supported compressors */
 	/** \brief Representation of supported compressors */
 	struct Compressor {
 	struct Compressor {
@@ -117,6 +117,11 @@ public:									/*{{{*/
 
 
 	/** \brief Return a vector of extensions supported for data.tar's */
 	/** \brief Return a vector of extensions supported for data.tar's */
 	std::vector<std::string> static const getCompressorExtensions();
 	std::vector<std::string> static const getCompressorExtensions();
+
+	/** \return Return a vector of enabled build profile specifications */
+	std::vector<std::string> static const getBuildProfiles();
+	/** \return Return a comma-separated list of enabled build profile specifications */
+	std::string static const getBuildProfilesString();
 									/*}}}*/
 									/*}}}*/
 	private:							/*{{{*/
 	private:							/*{{{*/
 	void static setDefaultConfigurationForCompressors();
 	void static setDefaultConfigurationForCompressors();

+ 10 - 3
apt-pkg/cachefile.cc

@@ -21,9 +21,16 @@
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/policy.h>
 #include <apt-pkg/policy.h>
 #include <apt-pkg/pkgsystem.h>
 #include <apt-pkg/pkgsystem.h>
-#include <apt-pkg/acquire-item.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/progress.h>
 #include <apt-pkg/progress.h>
+#include <apt-pkg/depcache.h>
+#include <apt-pkg/mmap.h>
+#include <apt-pkg/pkgcache.h>
+
+#include <string.h>
+#include <unistd.h>
+#include <string>
+#include <vector>
 
 
 #include <apti18n.h>
 #include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
@@ -99,7 +106,7 @@ bool pkgCacheFile::BuildCaches(OpProgress *Progress, bool WithLock)
 // CacheFile::BuildSourceList - Open and build all relevant sources.list/*{{{*/
 // CacheFile::BuildSourceList - Open and build all relevant sources.list/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-bool pkgCacheFile::BuildSourceList(OpProgress *Progress)
+bool pkgCacheFile::BuildSourceList(OpProgress * /*Progress*/)
 {
 {
    if (SrcList != NULL)
    if (SrcList != NULL)
       return true;
       return true;
@@ -113,7 +120,7 @@ bool pkgCacheFile::BuildSourceList(OpProgress *Progress)
 // CacheFile::BuildPolicy - Open and build all relevant preferences	/*{{{*/
 // CacheFile::BuildPolicy - Open and build all relevant preferences	/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-bool pkgCacheFile::BuildPolicy(OpProgress *Progress)
+bool pkgCacheFile::BuildPolicy(OpProgress * /*Progress*/)
 {
 {
    if (Policy != NULL)
    if (Policy != NULL)
       return true;
       return true;

+ 7 - 2
apt-pkg/cachefile.h

@@ -17,8 +17,12 @@
 #ifndef PKGLIB_CACHEFILE_H
 #ifndef PKGLIB_CACHEFILE_H
 #define PKGLIB_CACHEFILE_H
 #define PKGLIB_CACHEFILE_H
 
 
+#include <stddef.h>
+
 #include <apt-pkg/depcache.h>
 #include <apt-pkg/depcache.h>
 #include <apt-pkg/macros.h>
 #include <apt-pkg/macros.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
 
 
 #ifndef APT_8_CLEANER_HEADERS
 #ifndef APT_8_CLEANER_HEADERS
 #include <apt-pkg/acquire.h>
 #include <apt-pkg/acquire.h>
@@ -26,6 +30,7 @@
 #include <apt-pkg/sourcelist.h>
 #include <apt-pkg/sourcelist.h>
 #endif
 #endif
 
 
+class MMap;
 class pkgPolicy;
 class pkgPolicy;
 class pkgSourceList;
 class pkgSourceList;
 class OpProgress;
 class OpProgress;
@@ -60,13 +65,13 @@ class pkgCacheFile
    inline unsigned char &operator [](pkgCache::DepIterator const &I) {return (*DCache)[I];};
    inline unsigned char &operator [](pkgCache::DepIterator const &I) {return (*DCache)[I];};
 
 
    bool BuildCaches(OpProgress *Progress = NULL,bool WithLock = true);
    bool BuildCaches(OpProgress *Progress = NULL,bool WithLock = true);
-   __deprecated bool BuildCaches(OpProgress &Progress,bool const &WithLock = true) { return BuildCaches(&Progress, WithLock); };
+   APT_DEPRECATED bool BuildCaches(OpProgress &Progress,bool const &WithLock = true) { return BuildCaches(&Progress, WithLock); };
    bool BuildSourceList(OpProgress *Progress = NULL);
    bool BuildSourceList(OpProgress *Progress = NULL);
    bool BuildPolicy(OpProgress *Progress = NULL);
    bool BuildPolicy(OpProgress *Progress = NULL);
    bool BuildDepCache(OpProgress *Progress = NULL);
    bool BuildDepCache(OpProgress *Progress = NULL);
    bool Open(OpProgress *Progress = NULL, bool WithLock = true);
    bool Open(OpProgress *Progress = NULL, bool WithLock = true);
    inline bool ReadOnlyOpen(OpProgress *Progress = NULL) { return Open(Progress, false); };
    inline bool ReadOnlyOpen(OpProgress *Progress = NULL) { return Open(Progress, false); };
-   __deprecated bool Open(OpProgress &Progress,bool const &WithLock = true) { return Open(&Progress, WithLock); };
+   APT_DEPRECATED bool Open(OpProgress &Progress,bool const &WithLock = true) { return Open(&Progress, WithLock); };
    static void RemoveCaches();
    static void RemoveCaches();
    void Close();
    void Close();
 
 

+ 3 - 1
apt-pkg/cachefilter.cc

@@ -9,10 +9,12 @@
 #include <apt-pkg/cachefilter.h>
 #include <apt-pkg/cachefilter.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/pkgcache.h>
 #include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
+#include <apt-pkg/macros.h>
 
 
 #include <string>
 #include <string>
-
+#include <string.h>
 #include <regex.h>
 #include <regex.h>
 #include <fnmatch.h>
 #include <fnmatch.h>
 
 

+ 2 - 1
apt-pkg/cachefilter.h

@@ -7,6 +7,7 @@
 #define APT_CACHEFILTER_H
 #define APT_CACHEFILTER_H
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
 #include <apt-pkg/pkgcache.h>
 #include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
 
 
 #include <string>
 #include <string>
 
 
@@ -47,7 +48,7 @@ public:
 /** \class PackageArchitectureMatchesSpecification
 /** \class PackageArchitectureMatchesSpecification
    \brief matching against architecture specification strings
    \brief matching against architecture specification strings
 
 
-   The strings are of the format <kernel>-<cpu> where either component,
+   The strings are of the format \<kernel\>-\<cpu\> where either component,
    or the whole string, can be the wildcard "any" as defined in
    or the whole string, can be the wildcard "any" as defined in
    debian-policy §11.1 "Architecture specification strings".
    debian-policy §11.1 "Architecture specification strings".
 
 

+ 136 - 131
apt-pkg/cacheiterators.h

@@ -29,7 +29,12 @@
 									/*}}}*/
 									/*}}}*/
 #ifndef PKGLIB_CACHEITERATORS_H
 #ifndef PKGLIB_CACHEITERATORS_H
 #define PKGLIB_CACHEITERATORS_H
 #define PKGLIB_CACHEITERATORS_H
+#include<apt-pkg/pkgcache.h>
+#include<apt-pkg/macros.h>
+
 #include<iterator>
 #include<iterator>
+#include <iosfwd>
+#include <string>
 
 
 #include<string.h>
 #include<string.h>
 
 
@@ -55,36 +60,36 @@ template<typename Str, typename Itr> class pkgCache::Iterator :
 	public:
 	public:
 	// Iteration
 	// Iteration
 	virtual void operator ++(int) = 0;
 	virtual void operator ++(int) = 0;
-	virtual void operator ++() = 0; // Should be {operator ++(0);};
-	inline bool end() const {return Owner == 0 || S == OwnerPointer();};
+	virtual void operator ++() = 0; // Should be {operator ++(0);}
+	inline bool end() const {return Owner == 0 || S == OwnerPointer();}
 
 
 	// Comparison
 	// Comparison
-	inline bool operator ==(const Itr &B) const {return S == B.S;};
-	inline bool operator !=(const Itr &B) const {return S != B.S;};
+	inline bool operator ==(const Itr &B) const {return S == B.S;}
+	inline bool operator !=(const Itr &B) const {return S != B.S;}
 
 
 	// Accessors
 	// Accessors
-	inline Str *operator ->() {return S;};
-	inline Str const *operator ->() const {return S;};
-	inline operator Str *() {return S == OwnerPointer() ? 0 : S;};
-	inline operator Str const *() const {return S == OwnerPointer() ? 0 : S;};
-	inline Str &operator *() {return *S;};
-	inline Str const &operator *() const {return *S;};
-	inline pkgCache *Cache() const {return Owner;};
+	inline Str *operator ->() {return S;}
+	inline Str const *operator ->() const {return S;}
+	inline operator Str *() {return S == OwnerPointer() ? 0 : S;}
+	inline operator Str const *() const {return S == OwnerPointer() ? 0 : S;}
+	inline Str &operator *() {return *S;}
+	inline Str const &operator *() const {return *S;}
+	inline pkgCache *Cache() const {return Owner;}
 
 
 	// Mixed stuff
 	// Mixed stuff
-	inline void operator =(const Itr &B) {S = B.S; Owner = B.Owner;};
-	inline bool IsGood() const { return S && Owner && ! end();};
-	inline unsigned long Index() const {return S - OwnerPointer();};
+	inline void operator =(const Itr &B) {S = B.S; Owner = B.Owner;}
+	inline bool IsGood() const { return S && Owner && ! end();}
+	inline unsigned long Index() const {return S - OwnerPointer();}
 
 
 	void ReMap(void const * const oldMap, void const * const newMap) {
 	void ReMap(void const * const oldMap, void const * const newMap) {
 		if (Owner == 0 || S == 0)
 		if (Owner == 0 || S == 0)
 			return;
 			return;
-		S += (Str*)(newMap) - (Str*)(oldMap);
+		S += (Str const * const)(newMap) - (Str const * const)(oldMap);
 	}
 	}
 
 
 	// Constructors - look out for the variable assigning
 	// Constructors - look out for the variable assigning
-	inline Iterator() : S(0), Owner(0) {};
-	inline Iterator(pkgCache &Owner,Str *T = 0) : S(T), Owner(&Owner) {};
+	inline Iterator() : S(0), Owner(0) {}
+	inline Iterator(pkgCache &Owner,Str *T = 0) : S(T), Owner(&Owner) {}
 };
 };
 									/*}}}*/
 									/*}}}*/
 // Group Iterator							/*{{{*/
 // Group Iterator							/*{{{*/
@@ -98,19 +103,19 @@ class pkgCache::GrpIterator: public Iterator<Group, GrpIterator> {
 	protected:
 	protected:
 	inline Group* OwnerPointer() const {
 	inline Group* OwnerPointer() const {
 		return (Owner != 0) ? Owner->GrpP : 0;
 		return (Owner != 0) ? Owner->GrpP : 0;
-	};
+	}
 
 
 	public:
 	public:
 	// This constructor is the 'begin' constructor, never use it.
 	// This constructor is the 'begin' constructor, never use it.
 	inline GrpIterator(pkgCache &Owner) : Iterator<Group, GrpIterator>(Owner), HashIndex(-1) {
 	inline GrpIterator(pkgCache &Owner) : Iterator<Group, GrpIterator>(Owner), HashIndex(-1) {
 		S = OwnerPointer();
 		S = OwnerPointer();
 		operator ++(0);
 		operator ++(0);
-	};
+	}
 
 
 	virtual void operator ++(int);
 	virtual void operator ++(int);
-	virtual void operator ++() {operator ++(0);};
+	virtual void operator ++() {operator ++(0);}
 
 
-	inline const char *Name() const {return S->Name == 0?0:Owner->StrP + S->Name;};
+	inline const char *Name() const {return S->Name == 0?0:Owner->StrP + S->Name;}
 	inline PkgIterator PackageList() const;
 	inline PkgIterator PackageList() const;
 	PkgIterator FindPkg(std::string Arch = "any") const;
 	PkgIterator FindPkg(std::string Arch = "any") const;
 	/** \brief find the package with the "best" architecture
 	/** \brief find the package with the "best" architecture
@@ -127,8 +132,8 @@ class pkgCache::GrpIterator: public Iterator<Group, GrpIterator> {
 	inline GrpIterator(pkgCache &Owner, Group *Trg) : Iterator<Group, GrpIterator>(Owner, Trg), HashIndex(0) {
 	inline GrpIterator(pkgCache &Owner, Group *Trg) : Iterator<Group, GrpIterator>(Owner, Trg), HashIndex(0) {
 		if (S == 0)
 		if (S == 0)
 			S = OwnerPointer();
 			S = OwnerPointer();
-	};
-	inline GrpIterator() : Iterator<Group, GrpIterator>(), HashIndex(0) {};
+	}
+	inline GrpIterator() : Iterator<Group, GrpIterator>(), HashIndex(0) {}
 
 
 };
 };
 									/*}}}*/
 									/*}}}*/
@@ -139,35 +144,35 @@ class pkgCache::PkgIterator: public Iterator<Package, PkgIterator> {
 	protected:
 	protected:
 	inline Package* OwnerPointer() const {
 	inline Package* OwnerPointer() const {
 		return (Owner != 0) ? Owner->PkgP : 0;
 		return (Owner != 0) ? Owner->PkgP : 0;
-	};
+	}
 
 
 	public:
 	public:
 	// This constructor is the 'begin' constructor, never use it.
 	// This constructor is the 'begin' constructor, never use it.
 	inline PkgIterator(pkgCache &Owner) : Iterator<Package, PkgIterator>(Owner), HashIndex(-1) {
 	inline PkgIterator(pkgCache &Owner) : Iterator<Package, PkgIterator>(Owner), HashIndex(-1) {
 		S = OwnerPointer();
 		S = OwnerPointer();
 		operator ++(0);
 		operator ++(0);
-	};
+	}
 
 
 	virtual void operator ++(int);
 	virtual void operator ++(int);
-	virtual void operator ++() {operator ++(0);};
+	virtual void operator ++() {operator ++(0);}
 
 
 	enum OkState {NeedsNothing,NeedsUnpack,NeedsConfigure};
 	enum OkState {NeedsNothing,NeedsUnpack,NeedsConfigure};
 
 
 	// Accessors
 	// Accessors
-	inline const char *Name() const {return S->Name == 0?0:Owner->StrP + S->Name;};
-	inline const char *Section() const {return S->Section == 0?0:Owner->StrP + S->Section;};
+	inline const char *Name() const {return S->Name == 0?0:Owner->StrP + S->Name;}
+	inline const char *Section() const {return S->Section == 0?0:Owner->StrP + S->Section;}
 	inline bool Purge() const {return S->CurrentState == pkgCache::State::Purge ||
 	inline bool Purge() const {return S->CurrentState == pkgCache::State::Purge ||
-		(S->CurrentVer == 0 && S->CurrentState == pkgCache::State::NotInstalled);};
-	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 VerIterator VersionList() const;
-	inline VerIterator CurrentVer() const;
-	inline DepIterator RevDependsList() const;
-	inline PrvIterator ProvidesList() const;
-	OkState State() const;
-	const char *CandVersion() const;
-	const char *CurVersion() const;
+		(S->CurrentVer == 0 && S->CurrentState == pkgCache::State::NotInstalled);}
+	inline const char *Arch() const {return S->Arch == 0?0:Owner->StrP + S->Arch;}
+	inline APT_PURE GrpIterator Group() const { return GrpIterator(*Owner, Owner->GrpP + S->Group);}
+
+	inline VerIterator VersionList() const APT_PURE;
+	inline VerIterator CurrentVer() const APT_PURE;
+	inline DepIterator RevDependsList() const APT_PURE;
+	inline PrvIterator ProvidesList() const APT_PURE;
+	OkState State() const APT_PURE;
+	const char *CandVersion() const APT_PURE;
+	const char *CurVersion() const APT_PURE;
 
 
 	//Nice printable representation
 	//Nice printable representation
 	friend std::ostream& operator <<(std::ostream& out, PkgIterator i);
 	friend std::ostream& operator <<(std::ostream& out, PkgIterator i);
@@ -177,8 +182,8 @@ class pkgCache::PkgIterator: public Iterator<Package, PkgIterator> {
 	inline PkgIterator(pkgCache &Owner,Package *Trg) : Iterator<Package, PkgIterator>(Owner, Trg), HashIndex(0) {
 	inline PkgIterator(pkgCache &Owner,Package *Trg) : Iterator<Package, PkgIterator>(Owner, Trg), HashIndex(0) {
 		if (S == 0)
 		if (S == 0)
 			S = OwnerPointer();
 			S = OwnerPointer();
-	};
-	inline PkgIterator() : Iterator<Package, PkgIterator>(), HashIndex(0) {};
+	}
+	inline PkgIterator() : Iterator<Package, PkgIterator>(), HashIndex(0) {}
 };
 };
 									/*}}}*/
 									/*}}}*/
 // Version Iterator							/*{{{*/
 // Version Iterator							/*{{{*/
@@ -186,12 +191,12 @@ class pkgCache::VerIterator : public Iterator<Version, VerIterator> {
 	protected:
 	protected:
 	inline Version* OwnerPointer() const {
 	inline Version* OwnerPointer() const {
 		return (Owner != 0) ? Owner->VerP : 0;
 		return (Owner != 0) ? Owner->VerP : 0;
-	};
+	}
 
 
 	public:
 	public:
 	// Iteration
 	// Iteration
-	void operator ++(int) {if (S != Owner->VerP) S = Owner->VerP + S->NextVer;};
-	inline void operator ++() {operator ++(0);};
+	void operator ++(int) {if (S != Owner->VerP) S = Owner->VerP + S->NextVer;}
+	inline void operator ++() {operator ++(0);}
 
 
 	// Comparison
 	// Comparison
 	int CompareVer(const VerIterator &B) const;
 	int CompareVer(const VerIterator &B) const;
@@ -201,17 +206,17 @@ class pkgCache::VerIterator : public Iterator<Version, VerIterator> {
 	    referring to the same "real" version */
 	    referring to the same "real" version */
 	inline bool SimilarVer(const VerIterator &B) const {
 	inline bool SimilarVer(const VerIterator &B) const {
 		return (B.end() == false && S->Hash == B->Hash && strcmp(VerStr(), B.VerStr()) == 0);
 		return (B.end() == false && S->Hash == B->Hash && strcmp(VerStr(), B.VerStr()) == 0);
-	};
+	}
 
 
 	// Accessors
 	// Accessors
-	inline const char *VerStr() const {return S->VerStr == 0?0:Owner->StrP + S->VerStr;};
-	inline const char *Section() const {return S->Section == 0?0:Owner->StrP + S->Section;};
+	inline const char *VerStr() const {return S->VerStr == 0?0:Owner->StrP + S->VerStr;}
+	inline const char *Section() const {return S->Section == 0?0:Owner->StrP + S->Section;}
 	inline const char *Arch() const {
 	inline const char *Arch() const {
 		if ((S->MultiArch & pkgCache::Version::All) == pkgCache::Version::All)
 		if ((S->MultiArch & pkgCache::Version::All) == pkgCache::Version::All)
 			return "all";
 			return "all";
 		return S->ParentPkg == 0?0:Owner->StrP + ParentPkg()->Arch;
 		return S->ParentPkg == 0?0:Owner->StrP + ParentPkg()->Arch;
-	};
-	inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + S->ParentPkg);};
+	}
+	inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + S->ParentPkg);}
 
 
 	inline DescIterator DescriptionList() const;
 	inline DescIterator DescriptionList() const;
 	DescIterator TranslatedDescription() const;
 	DescIterator TranslatedDescription() const;
@@ -219,8 +224,8 @@ class pkgCache::VerIterator : public Iterator<Version, VerIterator> {
 	inline PrvIterator ProvidesList() const;
 	inline PrvIterator ProvidesList() const;
 	inline VerFileIterator FileList() const;
 	inline VerFileIterator FileList() const;
 	bool Downloadable() const;
 	bool Downloadable() const;
-	inline const char *PriorityType() const {return Owner->Priority(S->Priority);};
-	const char *MultiArchType() const;
+	inline const char *PriorityType() const {return Owner->Priority(S->Priority);}
+	const char *MultiArchType() const APT_PURE;
 	std::string RelStr() const;
 	std::string RelStr() const;
 
 
 	bool Automatic() const;
 	bool Automatic() const;
@@ -229,8 +234,8 @@ class pkgCache::VerIterator : public Iterator<Version, VerIterator> {
 	inline VerIterator(pkgCache &Owner,Version *Trg = 0) : Iterator<Version, VerIterator>(Owner, Trg) {
 	inline VerIterator(pkgCache &Owner,Version *Trg = 0) : Iterator<Version, VerIterator>(Owner, Trg) {
 		if (S == 0)
 		if (S == 0)
 			S = OwnerPointer();
 			S = OwnerPointer();
-	};
-	inline VerIterator() : Iterator<Version, VerIterator>() {};
+	}
+	inline VerIterator() : Iterator<Version, VerIterator>() {}
 };
 };
 									/*}}}*/
 									/*}}}*/
 // Description Iterator							/*{{{*/
 // Description Iterator							/*{{{*/
@@ -238,26 +243,26 @@ class pkgCache::DescIterator : public Iterator<Description, DescIterator> {
 	protected:
 	protected:
 	inline Description* OwnerPointer() const {
 	inline Description* OwnerPointer() const {
 		return (Owner != 0) ? Owner->DescP : 0;
 		return (Owner != 0) ? Owner->DescP : 0;
-	};
+	}
 
 
 	public:
 	public:
 	// Iteration
 	// Iteration
-	void operator ++(int) {if (S != Owner->DescP) S = Owner->DescP + S->NextDesc;};
-	inline void operator ++() {operator ++(0);};
+	void operator ++(int) {if (S != Owner->DescP) S = Owner->DescP + S->NextDesc;}
+	inline void operator ++() {operator ++(0);}
 
 
 	// Comparison
 	// Comparison
 	int CompareDesc(const DescIterator &B) const;
 	int CompareDesc(const DescIterator &B) const;
 
 
 	// Accessors
 	// Accessors
-	inline const char *LanguageCode() const {return Owner->StrP + S->language_code;};
-	inline const char *md5() const {return Owner->StrP + S->md5sum;};
+	inline const char *LanguageCode() const {return Owner->StrP + S->language_code;}
+	inline const char *md5() const {return Owner->StrP + S->md5sum;}
 	inline DescFileIterator FileList() const;
 	inline DescFileIterator FileList() const;
 
 
-	inline DescIterator() : Iterator<Description, DescIterator>() {};
+	inline DescIterator() : Iterator<Description, DescIterator>() {}
 	inline DescIterator(pkgCache &Owner,Description *Trg = 0) : Iterator<Description, DescIterator>(Owner, Trg) {
 	inline DescIterator(pkgCache &Owner,Description *Trg = 0) : Iterator<Description, DescIterator>(Owner, Trg) {
 		if (S == 0)
 		if (S == 0)
 			S = Owner.DescP;
 			S = Owner.DescP;
-	};
+	}
 };
 };
 									/*}}}*/
 									/*}}}*/
 // Dependency iterator							/*{{{*/
 // Dependency iterator							/*{{{*/
@@ -267,33 +272,33 @@ class pkgCache::DepIterator : public Iterator<Dependency, DepIterator> {
 	protected:
 	protected:
 	inline Dependency* OwnerPointer() const {
 	inline Dependency* OwnerPointer() const {
 		return (Owner != 0) ? Owner->DepP : 0;
 		return (Owner != 0) ? Owner->DepP : 0;
-	};
+	}
 
 
 	public:
 	public:
 	// Iteration
 	// Iteration
 	void operator ++(int) {if (S != Owner->DepP) S = Owner->DepP +
 	void operator ++(int) {if (S != Owner->DepP) S = Owner->DepP +
-		(Type == DepVer ? S->NextDepends : S->NextRevDepends);};
-	inline void operator ++() {operator ++(0);};
+		(Type == DepVer ? S->NextDepends : S->NextRevDepends);}
+	inline void operator ++() {operator ++(0);}
 
 
 	// Accessors
 	// Accessors
-	inline const char *TargetVer() const {return S->Version == 0?0:Owner->StrP + S->Version;};
-	inline PkgIterator TargetPkg() const {return PkgIterator(*Owner,Owner->PkgP + S->Package);};
-	inline PkgIterator SmartTargetPkg() const {PkgIterator R(*Owner,0);SmartTargetPkg(R);return R;};
-	inline VerIterator ParentVer() const {return VerIterator(*Owner,Owner->VerP + S->ParentVer);};
-	inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[S->ParentVer].ParentPkg);};
-	inline bool Reverse() const {return Type == DepRev;};
-	bool IsCritical() const;
-	bool IsNegative() const;
-	bool IsIgnorable(PrvIterator const &Prv) const;
-	bool IsIgnorable(PkgIterator const &Pkg) const;
-	bool IsMultiArchImplicit() const;
-	bool IsSatisfied(VerIterator const &Ver) const;
-	bool IsSatisfied(PrvIterator const &Prv) const;
+	inline const char *TargetVer() const {return S->Version == 0?0:Owner->StrP + S->Version;}
+	inline PkgIterator TargetPkg() const {return PkgIterator(*Owner,Owner->PkgP + S->Package);}
+	inline PkgIterator SmartTargetPkg() const {PkgIterator R(*Owner,0);SmartTargetPkg(R);return R;}
+	inline VerIterator ParentVer() const {return VerIterator(*Owner,Owner->VerP + S->ParentVer);}
+	inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[S->ParentVer].ParentPkg);}
+	inline bool Reverse() const {return Type == DepRev;}
+	bool IsCritical() const APT_PURE;
+	bool IsNegative() const APT_PURE;
+	bool IsIgnorable(PrvIterator const &Prv) const APT_PURE;
+	bool IsIgnorable(PkgIterator const &Pkg) const APT_PURE;
+	bool IsMultiArchImplicit() const APT_PURE;
+	bool IsSatisfied(VerIterator const &Ver) const APT_PURE;
+	bool IsSatisfied(PrvIterator const &Prv) const APT_PURE;
 	void GlobOr(DepIterator &Start,DepIterator &End);
 	void GlobOr(DepIterator &Start,DepIterator &End);
 	Version **AllTargets() const;
 	Version **AllTargets() const;
 	bool SmartTargetPkg(PkgIterator &Result) const;
 	bool SmartTargetPkg(PkgIterator &Result) const;
-	inline const char *CompType() const {return Owner->CompType(S->CompareOp);};
-	inline const char *DepType() const {return Owner->DepType(S->Type);};
+	inline const char *CompType() const {return Owner->CompType(S->CompareOp);}
+	inline const char *DepType() const {return Owner->DepType(S->Type);}
 
 
 	//Nice printable representation
 	//Nice printable representation
 	friend std::ostream& operator <<(std::ostream& out, DepIterator D);
 	friend std::ostream& operator <<(std::ostream& out, DepIterator D);
@@ -302,13 +307,13 @@ class pkgCache::DepIterator : public Iterator<Dependency, DepIterator> {
 		Iterator<Dependency, DepIterator>(Owner, Trg), Type(DepVer) {
 		Iterator<Dependency, DepIterator>(Owner, Trg), Type(DepVer) {
 		if (S == 0)
 		if (S == 0)
 			S = Owner.DepP;
 			S = Owner.DepP;
-	};
+	}
 	inline DepIterator(pkgCache &Owner, Dependency *Trg, Package*) :
 	inline DepIterator(pkgCache &Owner, Dependency *Trg, Package*) :
 		Iterator<Dependency, DepIterator>(Owner, Trg), Type(DepRev) {
 		Iterator<Dependency, DepIterator>(Owner, Trg), Type(DepRev) {
 		if (S == 0)
 		if (S == 0)
 			S = Owner.DepP;
 			S = Owner.DepP;
-	};
-	inline DepIterator() : Iterator<Dependency, DepIterator>(), Type(DepVer) {};
+	}
+	inline DepIterator() : Iterator<Dependency, DepIterator>(), Type(DepVer) {}
 };
 };
 									/*}}}*/
 									/*}}}*/
 // Provides iterator							/*{{{*/
 // Provides iterator							/*{{{*/
@@ -318,34 +323,34 @@ class pkgCache::PrvIterator : public Iterator<Provides, PrvIterator> {
 	protected:
 	protected:
 	inline Provides* OwnerPointer() const {
 	inline Provides* OwnerPointer() const {
 		return (Owner != 0) ? Owner->ProvideP : 0;
 		return (Owner != 0) ? Owner->ProvideP : 0;
-	};
+	}
 
 
 	public:
 	public:
 	// Iteration
 	// Iteration
 	void operator ++(int) {if (S != Owner->ProvideP) S = Owner->ProvideP +
 	void operator ++(int) {if (S != Owner->ProvideP) S = Owner->ProvideP +
-		(Type == PrvVer?S->NextPkgProv:S->NextProvides);};
-	inline void operator ++() {operator ++(0);};
+		(Type == PrvVer?S->NextPkgProv:S->NextProvides);}
+	inline void operator ++() {operator ++(0);}
 
 
 	// Accessors
 	// Accessors
-	inline const char *Name() const {return Owner->StrP + Owner->PkgP[S->ParentPkg].Name;};
-	inline const char *ProvideVersion() const {return S->ProvideVersion == 0?0:Owner->StrP + S->ProvideVersion;};
-	inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->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);};
+	inline const char *Name() const {return Owner->StrP + Owner->PkgP[S->ParentPkg].Name;}
+	inline const char *ProvideVersion() const {return S->ProvideVersion == 0?0:Owner->StrP + S->ProvideVersion;}
+	inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->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);}
 
 
-	bool IsMultiArchImplicit() const;
+	bool IsMultiArchImplicit() const APT_PURE;
 
 
-	inline PrvIterator() : Iterator<Provides, PrvIterator>(), Type(PrvVer) {};
+	inline PrvIterator() : Iterator<Provides, PrvIterator>(), Type(PrvVer) {}
 	inline PrvIterator(pkgCache &Owner, Provides *Trg, Version*) :
 	inline PrvIterator(pkgCache &Owner, Provides *Trg, Version*) :
 		Iterator<Provides, PrvIterator>(Owner, Trg), Type(PrvVer) {
 		Iterator<Provides, PrvIterator>(Owner, Trg), Type(PrvVer) {
 		if (S == 0)
 		if (S == 0)
 			S = Owner.ProvideP;
 			S = Owner.ProvideP;
-	};
+	}
 	inline PrvIterator(pkgCache &Owner, Provides *Trg, Package*) :
 	inline PrvIterator(pkgCache &Owner, Provides *Trg, Package*) :
 		Iterator<Provides, PrvIterator>(Owner, Trg), Type(PrvPkg) {
 		Iterator<Provides, PrvIterator>(Owner, Trg), Type(PrvPkg) {
 		if (S == 0)
 		if (S == 0)
 			S = Owner.ProvideP;
 			S = Owner.ProvideP;
-	};
+	}
 };
 };
 									/*}}}*/
 									/*}}}*/
 // Package file								/*{{{*/
 // Package file								/*{{{*/
@@ -353,32 +358,32 @@ class pkgCache::PkgFileIterator : public Iterator<PackageFile, PkgFileIterator>
 	protected:
 	protected:
 	inline PackageFile* OwnerPointer() const {
 	inline PackageFile* OwnerPointer() const {
 		return (Owner != 0) ? Owner->PkgFileP : 0;
 		return (Owner != 0) ? Owner->PkgFileP : 0;
-	};
+	}
 
 
 	public:
 	public:
 	// Iteration
 	// Iteration
-	void operator ++(int) {if (S != Owner->PkgFileP) S = Owner->PkgFileP + S->NextFile;};
-	inline void operator ++() {operator ++(0);};
+	void operator ++(int) {if (S != Owner->PkgFileP) S = Owner->PkgFileP + S->NextFile;}
+	inline void operator ++() {operator ++(0);}
 
 
 	// Accessors
 	// Accessors
-	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:Owner->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->StrP + 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:Owner->StrP + S->IndexType;};
+	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:Owner->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->StrP + 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:Owner->StrP + S->IndexType;}
 
 
 	bool IsOk();
 	bool IsOk();
 	std::string RelStr();
 	std::string RelStr();
 
 
 	// Constructors
 	// Constructors
-	inline PkgFileIterator() : Iterator<PackageFile, PkgFileIterator>() {};
-	inline PkgFileIterator(pkgCache &Owner) : Iterator<PackageFile, PkgFileIterator>(Owner, Owner.PkgFileP) {};
-	inline PkgFileIterator(pkgCache &Owner,PackageFile *Trg) : Iterator<PackageFile, PkgFileIterator>(Owner, Trg) {};
+	inline PkgFileIterator() : Iterator<PackageFile, PkgFileIterator>() {}
+	inline PkgFileIterator(pkgCache &Owner) : Iterator<PackageFile, PkgFileIterator>(Owner, Owner.PkgFileP) {}
+	inline PkgFileIterator(pkgCache &Owner,PackageFile *Trg) : Iterator<PackageFile, PkgFileIterator>(Owner, Trg) {}
 };
 };
 									/*}}}*/
 									/*}}}*/
 // Version File								/*{{{*/
 // Version File								/*{{{*/
@@ -386,18 +391,18 @@ class pkgCache::VerFileIterator : public pkgCache::Iterator<VerFile, VerFileIter
 	protected:
 	protected:
 	inline VerFile* OwnerPointer() const {
 	inline VerFile* OwnerPointer() const {
 		return (Owner != 0) ? Owner->VerFileP : 0;
 		return (Owner != 0) ? Owner->VerFileP : 0;
-	};
+	}
 
 
 	public:
 	public:
 	// Iteration
 	// Iteration
-	void operator ++(int) {if (S != Owner->VerFileP) S = Owner->VerFileP + S->NextFile;};
-	inline void operator ++() {operator ++(0);};
+	void operator ++(int) {if (S != Owner->VerFileP) S = Owner->VerFileP + S->NextFile;}
+	inline void operator ++() {operator ++(0);}
 
 
 	// Accessors
 	// Accessors
-	inline PkgFileIterator File() const {return PkgFileIterator(*Owner,S->File + Owner->PkgFileP);};
+	inline PkgFileIterator File() const {return PkgFileIterator(*Owner,S->File + Owner->PkgFileP);}
 
 
-	inline VerFileIterator() : Iterator<VerFile, VerFileIterator>() {};
-	inline VerFileIterator(pkgCache &Owner,VerFile *Trg) : Iterator<VerFile, VerFileIterator>(Owner, Trg) {};
+	inline VerFileIterator() : Iterator<VerFile, VerFileIterator>() {}
+	inline VerFileIterator(pkgCache &Owner,VerFile *Trg) : Iterator<VerFile, VerFileIterator>(Owner, Trg) {}
 };
 };
 									/*}}}*/
 									/*}}}*/
 // Description File							/*{{{*/
 // Description File							/*{{{*/
@@ -405,40 +410,40 @@ class pkgCache::DescFileIterator : public Iterator<DescFile, DescFileIterator> {
 	protected:
 	protected:
 	inline DescFile* OwnerPointer() const {
 	inline DescFile* OwnerPointer() const {
 		return (Owner != 0) ? Owner->DescFileP : 0;
 		return (Owner != 0) ? Owner->DescFileP : 0;
-	};
+	}
 
 
 	public:
 	public:
 	// Iteration
 	// Iteration
-	void operator ++(int) {if (S != Owner->DescFileP) S = Owner->DescFileP + S->NextFile;};
-	inline void operator ++() {operator ++(0);};
+	void operator ++(int) {if (S != Owner->DescFileP) S = Owner->DescFileP + S->NextFile;}
+	inline void operator ++() {operator ++(0);}
 
 
 	// Accessors
 	// Accessors
-	inline PkgFileIterator File() const {return PkgFileIterator(*Owner,S->File + Owner->PkgFileP);};
+	inline PkgFileIterator File() const {return PkgFileIterator(*Owner,S->File + Owner->PkgFileP);}
 
 
-	inline DescFileIterator() : Iterator<DescFile, DescFileIterator>() {};
-	inline DescFileIterator(pkgCache &Owner,DescFile *Trg) : Iterator<DescFile, DescFileIterator>(Owner, Trg) {};
+	inline DescFileIterator() : Iterator<DescFile, DescFileIterator>() {}
+	inline DescFileIterator(pkgCache &Owner,DescFile *Trg) : Iterator<DescFile, DescFileIterator>(Owner, Trg) {}
 };
 };
 									/*}}}*/
 									/*}}}*/
 // Inlined Begin functions can't be in the class because of order problems /*{{{*/
 // Inlined Begin functions can't be in the class because of order problems /*{{{*/
 inline pkgCache::PkgIterator pkgCache::GrpIterator::PackageList() const
 inline pkgCache::PkgIterator pkgCache::GrpIterator::PackageList() const
-       {return PkgIterator(*Owner,Owner->PkgP + S->FirstPackage);};
+       {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 + S->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 + S->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 + S->RevDepends,S);};
+       {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 + S->ProvidesList,S);};
+       {return PrvIterator(*Owner,Owner->ProvideP + S->ProvidesList,S);}
 inline pkgCache::DescIterator pkgCache::VerIterator::DescriptionList() const
 inline pkgCache::DescIterator pkgCache::VerIterator::DescriptionList() const
-       {return DescIterator(*Owner,Owner->DescP + S->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 + S->ProvidesList,S);};
+       {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 + S->DependsList,S);};
+       {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 + S->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 + S->FileList);};
+       {return DescFileIterator(*Owner,Owner->DescFileP + S->FileList);}
 									/*}}}*/
 									/*}}}*/
 #endif
 #endif

+ 27 - 19
apt-pkg/cacheset.cc

@@ -16,14 +16,22 @@
 #include <apt-pkg/cachefilter.h>
 #include <apt-pkg/cachefilter.h>
 #include <apt-pkg/cacheset.h>
 #include <apt-pkg/cacheset.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
-#include <apt-pkg/strutl.h>
 #include <apt-pkg/versionmatch.h>
 #include <apt-pkg/versionmatch.h>
 #include <apt-pkg/pkgrecords.h>
 #include <apt-pkg/pkgrecords.h>
 #include <apt-pkg/policy.h>
 #include <apt-pkg/policy.h>
-
-#include <vector>
-
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/depcache.h>
+#include <apt-pkg/macros.h>
+#include <apt-pkg/pkgcache.h>
+
+#include <stddef.h>
+#include <stdio.h>
+#include <string.h>
 #include <regex.h>
 #include <regex.h>
+#include <list>
+#include <string>
+#include <vector>
 
 
 #include <apti18n.h>
 #include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
@@ -588,13 +596,13 @@ pkgCache::PkgIterator CacheSetHelper::canNotFindPkgName(pkgCacheFile &Cache,
 }
 }
 									/*}}}*/
 									/*}}}*/
 // canNotFindTask - handle the case no package is found for a task	/*{{{*/
 // canNotFindTask - handle the case no package is found for a task	/*{{{*/
-void CacheSetHelper::canNotFindTask(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern) {
+void CacheSetHelper::canNotFindTask(PackageContainerInterface * const /*pci*/, pkgCacheFile &/*Cache*/, std::string pattern) {
 	if (ShowError == true)
 	if (ShowError == true)
 		_error->Insert(ErrorType, _("Couldn't find task '%s'"), pattern.c_str());
 		_error->Insert(ErrorType, _("Couldn't find task '%s'"), pattern.c_str());
 }
 }
 									/*}}}*/
 									/*}}}*/
 // canNotFindRegEx - handle the case no package is found by a regex	/*{{{*/
 // canNotFindRegEx - handle the case no package is found by a regex	/*{{{*/
-void CacheSetHelper::canNotFindRegEx(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern) {
+void CacheSetHelper::canNotFindRegEx(PackageContainerInterface * const /*pci*/, pkgCacheFile &/*Cache*/, std::string pattern) {
 	if (ShowError == true)
 	if (ShowError == true)
 		_error->Insert(ErrorType, _("Couldn't find any package by regex '%s'"), pattern.c_str());
 		_error->Insert(ErrorType, _("Couldn't find any package by regex '%s'"), pattern.c_str());
 }
 }
@@ -606,25 +614,25 @@ void CacheSetHelper::canNotFindFnmatch(PackageContainerInterface * const pci, pk
 }
 }
 #endif									/*}}}*/
 #endif									/*}}}*/
 // canNotFindPackage - handle the case no package is found from a string/*{{{*/
 // canNotFindPackage - handle the case no package is found from a string/*{{{*/
-void CacheSetHelper::canNotFindPackage(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string const &str) {
+APT_CONST void CacheSetHelper::canNotFindPackage(PackageContainerInterface * const /*pci*/, pkgCacheFile &/*Cache*/, std::string const &/*str*/) {
 }
 }
 									/*}}}*/
 									/*}}}*/
 // canNotFindAllVer							/*{{{*/
 // canNotFindAllVer							/*{{{*/
-void CacheSetHelper::canNotFindAllVer(VersionContainerInterface * const vci, pkgCacheFile &Cache,
+void CacheSetHelper::canNotFindAllVer(VersionContainerInterface * const /*vci*/, pkgCacheFile &/*Cache*/,
 		pkgCache::PkgIterator const &Pkg) {
 		pkgCache::PkgIterator const &Pkg) {
 	if (ShowError == true)
 	if (ShowError == true)
 		_error->Insert(ErrorType, _("Can't select versions from package '%s' as it is purely virtual"), Pkg.FullName(true).c_str());
 		_error->Insert(ErrorType, _("Can't select versions from package '%s' as it is purely virtual"), Pkg.FullName(true).c_str());
 }
 }
 									/*}}}*/
 									/*}}}*/
 // canNotFindInstCandVer						/*{{{*/
 // canNotFindInstCandVer						/*{{{*/
-void CacheSetHelper::canNotFindInstCandVer(VersionContainerInterface * const vci, pkgCacheFile &Cache,
+void CacheSetHelper::canNotFindInstCandVer(VersionContainerInterface * const /*vci*/, pkgCacheFile &/*Cache*/,
 		pkgCache::PkgIterator const &Pkg) {
 		pkgCache::PkgIterator const &Pkg) {
 	if (ShowError == true)
 	if (ShowError == true)
 		_error->Insert(ErrorType, _("Can't select installed nor candidate version from package '%s' as it has neither of them"), Pkg.FullName(true).c_str());
 		_error->Insert(ErrorType, _("Can't select installed nor candidate version from package '%s' as it has neither of them"), Pkg.FullName(true).c_str());
 }
 }
 									/*}}}*/
 									/*}}}*/
 // canNotFindInstCandVer						/*{{{*/
 // canNotFindInstCandVer						/*{{{*/
-void CacheSetHelper::canNotFindCandInstVer(VersionContainerInterface * const vci, pkgCacheFile &Cache,
+void CacheSetHelper::canNotFindCandInstVer(VersionContainerInterface * const /*vci*/, pkgCacheFile &/*Cache*/,
 		pkgCache::PkgIterator const &Pkg) {
 		pkgCache::PkgIterator const &Pkg) {
 	if (ShowError == true)
 	if (ShowError == true)
 		_error->Insert(ErrorType, _("Can't select installed nor candidate version from package '%s' as it has neither of them"), Pkg.FullName(true).c_str());
 		_error->Insert(ErrorType, _("Can't select installed nor candidate version from package '%s' as it has neither of them"), Pkg.FullName(true).c_str());
@@ -655,27 +663,27 @@ pkgCache::VerIterator CacheSetHelper::canNotFindInstalledVer(pkgCacheFile &Cache
 }
 }
 									/*}}}*/
 									/*}}}*/
 // showTaskSelection							/*{{{*/
 // showTaskSelection							/*{{{*/
-void CacheSetHelper::showTaskSelection(pkgCache::PkgIterator const &pkg,
-				       std::string const &pattern) {
+APT_CONST void CacheSetHelper::showTaskSelection(pkgCache::PkgIterator const &/*pkg*/,
+				       std::string const &/*pattern*/) {
 }
 }
 									/*}}}*/
 									/*}}}*/
 // showRegExSelection							/*{{{*/
 // showRegExSelection							/*{{{*/
-void CacheSetHelper::showRegExSelection(pkgCache::PkgIterator const &pkg,
-					std::string const &pattern) {
+APT_CONST void CacheSetHelper::showRegExSelection(pkgCache::PkgIterator const &/*pkg*/,
+					std::string const &/*pattern*/) {
 }
 }
 									/*}}}*/
 									/*}}}*/
 #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
 #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
 // showFnmatchSelection							/*{{{*/
 // showFnmatchSelection							/*{{{*/
-void CacheSetHelper::showFnmatchSelection(pkgCache::PkgIterator const &pkg,
+APT_CONST void CacheSetHelper::showFnmatchSelection(pkgCache::PkgIterator const &pkg,
                                           std::string const &pattern) {
                                           std::string const &pattern) {
 }
 }
 									/*}}}*/
 									/*}}}*/
 #endif
 #endif
 // showSelectedVersion							/*{{{*/
 // showSelectedVersion							/*{{{*/
-void CacheSetHelper::showSelectedVersion(pkgCache::PkgIterator const &Pkg,
-					 pkgCache::VerIterator const Ver,
-					 std::string const &ver,
-					 bool const verIsRel) {
+APT_CONST void CacheSetHelper::showSelectedVersion(pkgCache::PkgIterator const &/*Pkg*/,
+					 pkgCache::VerIterator const /*Ver*/,
+					 std::string const &/*ver*/,
+					 bool const /*verIsRel*/) {
 }
 }
 									/*}}}*/
 									/*}}}*/
 }
 }

+ 99 - 91
apt-pkg/cacheset.h

@@ -9,7 +9,6 @@
 #ifndef APT_CACHESET_H
 #ifndef APT_CACHESET_H
 #define APT_CACHESET_H
 #define APT_CACHESET_H
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
-#include <iostream>
 #include <fstream>
 #include <fstream>
 #include <map>
 #include <map>
 #include <set>
 #include <set>
@@ -17,11 +16,17 @@
 #include <string>
 #include <string>
 #include <iterator>
 #include <iterator>
 
 
+#include <stddef.h>
+
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/pkgcache.h>
 #include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
 
 
 #ifndef APT_8_CLEANER_HEADERS
 #ifndef APT_8_CLEANER_HEADERS
 #include <apt-pkg/cachefile.h>
 #include <apt-pkg/cachefile.h>
+#endif
+#ifndef APT_10_CLEANER_HEADERS
+#include <iostream>
 #endif
 #endif
 									/*}}}*/
 									/*}}}*/
 
 
@@ -43,8 +48,8 @@ class CacheSetHelper {							/*{{{*/
 public:									/*{{{*/
 public:									/*{{{*/
 	CacheSetHelper(bool const ShowError = true,
 	CacheSetHelper(bool const ShowError = true,
 		GlobalError::MsgType ErrorType = GlobalError::ERROR) :
 		GlobalError::MsgType ErrorType = GlobalError::ERROR) :
-			ShowError(ShowError), ErrorType(ErrorType) {};
-	virtual ~CacheSetHelper() {};
+			ShowError(ShowError), ErrorType(ErrorType) {}
+	virtual ~CacheSetHelper() {}
 
 
 	virtual void showTaskSelection(pkgCache::PkgIterator const &pkg, std::string const &pattern);
 	virtual void showTaskSelection(pkgCache::PkgIterator const &pkg, std::string const &pattern);
 	virtual void showRegExSelection(pkgCache::PkgIterator const &pkg, std::string const &pattern);
 	virtual void showRegExSelection(pkgCache::PkgIterator const &pkg, std::string const &pattern);
@@ -76,9 +81,9 @@ public:									/*{{{*/
 	virtual pkgCache::VerIterator canNotFindInstalledVer(pkgCacheFile &Cache,
 	virtual pkgCache::VerIterator canNotFindInstalledVer(pkgCacheFile &Cache,
 				pkgCache::PkgIterator const &Pkg);
 				pkgCache::PkgIterator const &Pkg);
 
 
-	bool showErrors() const { return ShowError; };
-	bool showErrors(bool const newValue) { if (ShowError == newValue) return ShowError; else return ((ShowError = newValue) == false); };
-	GlobalError::MsgType errorType() const { return ErrorType; };
+	bool showErrors() const { return ShowError; }
+	bool showErrors(bool const newValue) { if (ShowError == newValue) return ShowError; else return ((ShowError = newValue) == false); }
+	GlobalError::MsgType errorType() const { return ErrorType; }
 	GlobalError::MsgType errorType(GlobalError::MsgType const &newValue)
 	GlobalError::MsgType errorType(GlobalError::MsgType const &newValue)
 	{
 	{
 		if (ErrorType == newValue) return ErrorType;
 		if (ErrorType == newValue) return ErrorType;
@@ -87,7 +92,7 @@ public:									/*{{{*/
 			ErrorType = newValue;
 			ErrorType = newValue;
 			return oldValue;
 			return oldValue;
 		}
 		}
-	};
+	}
 
 
 									/*}}}*/
 									/*}}}*/
 protected:
 protected:
@@ -124,12 +129,12 @@ public:
 		inline pkgCache::PkgIterator::OkState State() const { return getPkg().State(); }
 		inline pkgCache::PkgIterator::OkState State() const { return getPkg().State(); }
 		inline const char *CandVersion() const { return getPkg().CandVersion(); }
 		inline const char *CandVersion() const { return getPkg().CandVersion(); }
 		inline const char *CurVersion() const { return getPkg().CurVersion(); }
 		inline const char *CurVersion() const { return getPkg().CurVersion(); }
-		inline pkgCache *Cache() const { return getPkg().Cache(); };
-		inline unsigned long Index() const {return getPkg().Index();};
+		inline pkgCache *Cache() const { return getPkg().Cache(); }
+		inline unsigned long Index() const {return getPkg().Index();}
 		// we have only valid iterators here
 		// we have only valid iterators here
-		inline bool end() const { return false; };
+		inline bool end() const { return false; }
 
 
-		inline pkgCache::Package const * operator->() const {return &*getPkg();};
+		inline pkgCache::Package const * operator->() const {return &*getPkg();}
 	};
 	};
 									/*}}}*/
 									/*}}}*/
 
 
@@ -154,7 +159,7 @@ public:
 		unsigned short ID;
 		unsigned short ID;
 		const char * const Alias;
 		const char * const Alias;
 		Position Pos;
 		Position Pos;
-		Modifier (unsigned short const &id, const char * const alias, Position const &pos) : ID(id), Alias(alias), Pos(pos) {};
+		Modifier (unsigned short const &id, const char * const alias, Position const &pos) : ID(id), Alias(alias), Pos(pos) {}
 	};
 	};
 
 
 	static bool FromModifierCommandLine(unsigned short &modID, PackageContainerInterface * const pci,
 	static bool FromModifierCommandLine(unsigned short &modID, PackageContainerInterface * const pci,
@@ -177,12 +182,12 @@ public:									/*{{{*/
 	public:
 	public:
 		const_iterator(typename Container::const_iterator i) : _iter(i) {}
 		const_iterator(typename Container::const_iterator i) : _iter(i) {}
 		pkgCache::PkgIterator getPkg(void) const { return *_iter; }
 		pkgCache::PkgIterator getPkg(void) const { return *_iter; }
-		inline pkgCache::PkgIterator operator*(void) const { return *_iter; };
+		inline pkgCache::PkgIterator operator*(void) const { return *_iter; }
 		operator typename Container::const_iterator(void) const { return _iter; }
 		operator typename Container::const_iterator(void) const { return _iter; }
 		inline const_iterator& operator++() { ++_iter; return *this; }
 		inline const_iterator& operator++() { ++_iter; return *this; }
 		inline const_iterator operator++(int) { const_iterator tmp(*this); operator++(); return tmp; }
 		inline const_iterator operator++(int) { const_iterator tmp(*this); operator++(); return tmp; }
-		inline bool operator!=(const_iterator const &i) const { return _iter != i._iter; };
-		inline bool operator==(const_iterator const &i) const { return _iter == i._iter; };
+		inline bool operator!=(const_iterator const &i) const { return _iter != i._iter; }
+		inline bool operator==(const_iterator const &i) const { return _iter == i._iter; }
 		friend std::ostream& operator<<(std::ostream& out, const_iterator i) { return operator<<(out, *i); }
 		friend std::ostream& operator<<(std::ostream& out, const_iterator i) { return operator<<(out, *i); }
 	};
 	};
 	class iterator : public PackageContainerInterface::const_iterator,
 	class iterator : public PackageContainerInterface::const_iterator,
@@ -191,43 +196,43 @@ public:									/*{{{*/
 	public:
 	public:
 		iterator(typename Container::iterator i) : _iter(i) {}
 		iterator(typename Container::iterator i) : _iter(i) {}
 		pkgCache::PkgIterator getPkg(void) const { return *_iter; }
 		pkgCache::PkgIterator getPkg(void) const { return *_iter; }
-		inline pkgCache::PkgIterator operator*(void) const { return *_iter; };
+		inline pkgCache::PkgIterator operator*(void) const { return *_iter; }
 		operator typename Container::iterator(void) const { return _iter; }
 		operator typename Container::iterator(void) const { return _iter; }
 		operator typename PackageContainer<Container>::const_iterator() { return typename PackageContainer<Container>::const_iterator(_iter); }
 		operator typename PackageContainer<Container>::const_iterator() { return typename PackageContainer<Container>::const_iterator(_iter); }
 		inline iterator& operator++() { ++_iter; return *this; }
 		inline iterator& operator++() { ++_iter; return *this; }
 		inline iterator operator++(int) { iterator tmp(*this); operator++(); return tmp; }
 		inline iterator operator++(int) { iterator tmp(*this); operator++(); return tmp; }
-		inline bool operator!=(iterator const &i) const { return _iter != i._iter; };
-		inline bool operator==(iterator const &i) const { return _iter == i._iter; };
-		inline iterator& operator=(iterator const &i) { _iter = i._iter; return *this; };
-		inline iterator& operator=(typename Container::iterator const &i) { _iter = i; return *this; };
+		inline bool operator!=(iterator const &i) const { return _iter != i._iter; }
+		inline bool operator==(iterator const &i) const { return _iter == i._iter; }
+		inline iterator& operator=(iterator const &i) { _iter = i._iter; return *this; }
+		inline iterator& operator=(typename Container::iterator const &i) { _iter = i; return *this; }
 		friend std::ostream& operator<<(std::ostream& out, iterator i) { return operator<<(out, *i); }
 		friend std::ostream& operator<<(std::ostream& out, iterator i) { return operator<<(out, *i); }
 	};
 	};
 									/*}}}*/
 									/*}}}*/
 
 
-	bool insert(pkgCache::PkgIterator const &P) { if (P.end() == true) return false; _cont.insert(P); return true; };
-	template<class Cont> void insert(PackageContainer<Cont> const &pkgcont) { _cont.insert((typename Cont::const_iterator)pkgcont.begin(), (typename Cont::const_iterator)pkgcont.end()); };
-	void insert(const_iterator begin, const_iterator end) { _cont.insert(begin, end); };
+	bool insert(pkgCache::PkgIterator const &P) { if (P.end() == true) return false; _cont.insert(P); return true; }
+	template<class Cont> void insert(PackageContainer<Cont> const &pkgcont) { _cont.insert((typename Cont::const_iterator)pkgcont.begin(), (typename Cont::const_iterator)pkgcont.end()); }
+	void insert(const_iterator begin, const_iterator end) { _cont.insert(begin, end); }
 
 
-	bool empty() const { return _cont.empty(); };
-	void clear() { return _cont.clear(); };
+	bool empty() const { return _cont.empty(); }
+	void clear() { return _cont.clear(); }
 	//FIXME: on ABI break, replace the first with the second without bool
 	//FIXME: on ABI break, replace the first with the second without bool
-	void erase(iterator position) { _cont.erase((typename Container::iterator)position); };
-	iterator& erase(iterator &position, bool) { return position = _cont.erase((typename Container::iterator)position); };
-	size_t erase(const pkgCache::PkgIterator x) { return _cont.erase(x); };
-	void erase(iterator first, iterator last) { _cont.erase(first, last); };
-	size_t size() const { return _cont.size(); };
+	void erase(iterator position) { _cont.erase((typename Container::iterator)position); }
+	iterator& erase(iterator &position, bool) { return position = _cont.erase((typename Container::iterator)position); }
+	size_t erase(const pkgCache::PkgIterator x) { return _cont.erase(x); }
+	void erase(iterator first, iterator last) { _cont.erase(first, last); }
+	size_t size() const { return _cont.size(); }
 
 
-	const_iterator begin() const { return const_iterator(_cont.begin()); };
-	const_iterator end() const { return const_iterator(_cont.end()); };
-	iterator begin() { return iterator(_cont.begin()); };
-	iterator end() { return iterator(_cont.end()); };
-	const_iterator find(pkgCache::PkgIterator const &P) const { return const_iterator(_cont.find(P)); };
+	const_iterator begin() const { return const_iterator(_cont.begin()); }
+	const_iterator end() const { return const_iterator(_cont.end()); }
+	iterator begin() { return iterator(_cont.begin()); }
+	iterator end() { return iterator(_cont.end()); }
+	const_iterator find(pkgCache::PkgIterator const &P) const { return const_iterator(_cont.find(P)); }
 
 
-	void setConstructor(Constructor const &by) { ConstructedBy = by; };
-	Constructor getConstructor() const { return ConstructedBy; };
+	void setConstructor(Constructor const &by) { ConstructedBy = by; }
+	Constructor getConstructor() const { return ConstructedBy; }
 
 
-	PackageContainer() : ConstructedBy(UNKNOWN) {};
-	PackageContainer(Constructor const &by) : ConstructedBy(by) {};
+	PackageContainer() : ConstructedBy(UNKNOWN) {}
+	PackageContainer(Constructor const &by) : ConstructedBy(by) {}
 
 
 	/** \brief returns all packages in the cache who belong to the given task
 	/** \brief returns all packages in the cache who belong to the given task
 
 
@@ -365,7 +370,7 @@ private:								/*{{{*/
 template<> template<class Cont> void PackageContainer<std::list<pkgCache::PkgIterator> >::insert(PackageContainer<Cont> const &pkgcont) {
 template<> template<class Cont> void PackageContainer<std::list<pkgCache::PkgIterator> >::insert(PackageContainer<Cont> const &pkgcont) {
 	for (typename PackageContainer<Cont>::const_iterator p = pkgcont.begin(); p != pkgcont.end(); ++p)
 	for (typename PackageContainer<Cont>::const_iterator p = pkgcont.begin(); p != pkgcont.end(); ++p)
 		_cont.push_back(*p);
 		_cont.push_back(*p);
-};
+}
 // these two are 'inline' as otherwise the linker has problems with seeing these untemplated
 // these two are 'inline' as otherwise the linker has problems with seeing these untemplated
 // specializations again and again - but we need to see them, so that library users can use them
 // specializations again and again - but we need to see them, so that library users can use them
 template<> inline bool PackageContainer<std::list<pkgCache::PkgIterator> >::insert(pkgCache::PkgIterator const &P) {
 template<> inline bool PackageContainer<std::list<pkgCache::PkgIterator> >::insert(pkgCache::PkgIterator const &P) {
@@ -373,11 +378,11 @@ template<> inline bool PackageContainer<std::list<pkgCache::PkgIterator> >::inse
 		return false;
 		return false;
 	_cont.push_back(P);
 	_cont.push_back(P);
 	return true;
 	return true;
-};
+}
 template<> inline void PackageContainer<std::list<pkgCache::PkgIterator> >::insert(const_iterator begin, const_iterator end) {
 template<> inline void PackageContainer<std::list<pkgCache::PkgIterator> >::insert(const_iterator begin, const_iterator end) {
 	for (const_iterator p = begin; p != end; ++p)
 	for (const_iterator p = begin; p != end; ++p)
 		_cont.push_back(*p);
 		_cont.push_back(*p);
-};
+}
 typedef PackageContainer<std::set<pkgCache::PkgIterator> > PackageSet;
 typedef PackageContainer<std::set<pkgCache::PkgIterator> > PackageSet;
 typedef PackageContainer<std::list<pkgCache::PkgIterator> > PackageList;
 typedef PackageContainer<std::list<pkgCache::PkgIterator> > PackageList;
 
 
@@ -392,27 +397,27 @@ public:
 		virtual pkgCache::VerIterator getVer() const = 0;
 		virtual pkgCache::VerIterator getVer() const = 0;
 		operator pkgCache::VerIterator(void) { return getVer(); }
 		operator pkgCache::VerIterator(void) { return getVer(); }
 
 
-		inline pkgCache *Cache() const { return getVer().Cache(); };
-		inline unsigned long Index() const {return getVer().Index();};
-		inline int CompareVer(const pkgCache::VerIterator &B) const { return getVer().CompareVer(B); };
-		inline const char *VerStr() const { return getVer().VerStr(); };
-		inline const char *Section() const { return getVer().Section(); };
-		inline const char *Arch() const { return getVer().Arch(); };
-		inline pkgCache::PkgIterator ParentPkg() const { return getVer().ParentPkg(); };
-		inline pkgCache::DescIterator DescriptionList() const { return getVer().DescriptionList(); };
-		inline pkgCache::DescIterator TranslatedDescription() const { return getVer().TranslatedDescription(); };
-		inline pkgCache::DepIterator DependsList() const { return getVer().DependsList(); };
-		inline pkgCache::PrvIterator ProvidesList() const { return getVer().ProvidesList(); };
-		inline pkgCache::VerFileIterator FileList() const { return getVer().FileList(); };
-		inline bool Downloadable() const { return getVer().Downloadable(); };
-		inline const char *PriorityType() const { return getVer().PriorityType(); };
-		inline std::string RelStr() const { return getVer().RelStr(); };
-		inline bool Automatic() const { return getVer().Automatic(); };
-		inline pkgCache::VerFileIterator NewestFile() const { return getVer().NewestFile(); };
+		inline pkgCache *Cache() const { return getVer().Cache(); }
+		inline unsigned long Index() const {return getVer().Index();}
+		inline int CompareVer(const pkgCache::VerIterator &B) const { return getVer().CompareVer(B); }
+		inline const char *VerStr() const { return getVer().VerStr(); }
+		inline const char *Section() const { return getVer().Section(); }
+		inline const char *Arch() const { return getVer().Arch(); }
+		inline pkgCache::PkgIterator ParentPkg() const { return getVer().ParentPkg(); }
+		inline pkgCache::DescIterator DescriptionList() const { return getVer().DescriptionList(); }
+		inline pkgCache::DescIterator TranslatedDescription() const { return getVer().TranslatedDescription(); }
+		inline pkgCache::DepIterator DependsList() const { return getVer().DependsList(); }
+		inline pkgCache::PrvIterator ProvidesList() const { return getVer().ProvidesList(); }
+		inline pkgCache::VerFileIterator FileList() const { return getVer().FileList(); }
+		inline bool Downloadable() const { return getVer().Downloadable(); }
+		inline const char *PriorityType() const { return getVer().PriorityType(); }
+		inline std::string RelStr() const { return getVer().RelStr(); }
+		inline bool Automatic() const { return getVer().Automatic(); }
+		inline pkgCache::VerFileIterator NewestFile() const { return getVer().NewestFile(); }
 		// we have only valid iterators here
 		// we have only valid iterators here
-		inline bool end() const { return false; };
+		inline bool end() const { return false; }
 
 
-		inline pkgCache::Version const * operator->() const { return &*getVer(); };
+		inline pkgCache::Version const * operator->() const { return &*getVer(); }
 	};
 	};
 									/*}}}*/
 									/*}}}*/
 
 
@@ -446,7 +451,7 @@ public:
 		Version SelectVersion;
 		Version SelectVersion;
 		Modifier (unsigned short const &id, const char * const alias, Position const &pos,
 		Modifier (unsigned short const &id, const char * const alias, Position const &pos,
 			  Version const &select) : ID(id), Alias(alias), Pos(pos),
 			  Version const &select) : ID(id), Alias(alias), Pos(pos),
-			 SelectVersion(select) {};
+			 SelectVersion(select) {}
 	};
 	};
 
 
 	static bool FromCommandLine(VersionContainerInterface * const vci, pkgCacheFile &Cache,
 	static bool FromCommandLine(VersionContainerInterface * const vci, pkgCacheFile &Cache,
@@ -479,14 +484,16 @@ protected:								/*{{{*/
 	/** \brief returns the candidate version of the package
 	/** \brief returns the candidate version of the package
 
 
 	    \param Cache to be used to query for information
 	    \param Cache to be used to query for information
-	    \param Pkg we want the candidate version from this package */
+	    \param Pkg we want the candidate version from this package
+	    \param helper used in this container instance */
 	static pkgCache::VerIterator getCandidateVer(pkgCacheFile &Cache,
 	static pkgCache::VerIterator getCandidateVer(pkgCacheFile &Cache,
 		pkgCache::PkgIterator const &Pkg, CacheSetHelper &helper);
 		pkgCache::PkgIterator const &Pkg, CacheSetHelper &helper);
 
 
 	/** \brief returns the installed version of the package
 	/** \brief returns the installed version of the package
 
 
 	    \param Cache to be used to query for information
 	    \param Cache to be used to query for information
-	    \param Pkg we want the installed version from this package */
+	    \param Pkg we want the installed version from this package
+	    \param helper used in this container instance */
 	static pkgCache::VerIterator getInstalledVer(pkgCacheFile &Cache,
 	static pkgCache::VerIterator getInstalledVer(pkgCacheFile &Cache,
 		pkgCache::PkgIterator const &Pkg, CacheSetHelper &helper);
 		pkgCache::PkgIterator const &Pkg, CacheSetHelper &helper);
 									/*}}}*/
 									/*}}}*/
@@ -507,12 +514,12 @@ public:									/*{{{*/
 	public:
 	public:
 		const_iterator(typename Container::const_iterator i) : _iter(i) {}
 		const_iterator(typename Container::const_iterator i) : _iter(i) {}
 		pkgCache::VerIterator getVer(void) const { return *_iter; }
 		pkgCache::VerIterator getVer(void) const { return *_iter; }
-		inline pkgCache::VerIterator operator*(void) const { return *_iter; };
+		inline pkgCache::VerIterator operator*(void) const { return *_iter; }
 		operator typename Container::const_iterator(void) const { return _iter; }
 		operator typename Container::const_iterator(void) const { return _iter; }
 		inline const_iterator& operator++() { ++_iter; return *this; }
 		inline const_iterator& operator++() { ++_iter; return *this; }
 		inline const_iterator operator++(int) { const_iterator tmp(*this); operator++(); return tmp; }
 		inline const_iterator operator++(int) { const_iterator tmp(*this); operator++(); return tmp; }
-		inline bool operator!=(const_iterator const &i) const { return _iter != i._iter; };
-		inline bool operator==(const_iterator const &i) const { return _iter == i._iter; };
+		inline bool operator!=(const_iterator const &i) const { return _iter != i._iter; }
+		inline bool operator==(const_iterator const &i) const { return _iter == i._iter; }
 		friend std::ostream& operator<<(std::ostream& out, const_iterator i) { return operator<<(out, *i); }
 		friend std::ostream& operator<<(std::ostream& out, const_iterator i) { return operator<<(out, *i); }
 	};
 	};
 	class iterator : public VersionContainerInterface::const_iterator,
 	class iterator : public VersionContainerInterface::const_iterator,
@@ -521,36 +528,36 @@ public:									/*{{{*/
 	public:
 	public:
 		iterator(typename Container::iterator i) : _iter(i) {}
 		iterator(typename Container::iterator i) : _iter(i) {}
 		pkgCache::VerIterator getVer(void) const { return *_iter; }
 		pkgCache::VerIterator getVer(void) const { return *_iter; }
-		inline pkgCache::VerIterator operator*(void) const { return *_iter; };
+		inline pkgCache::VerIterator operator*(void) const { return *_iter; }
 		operator typename Container::iterator(void) const { return _iter; }
 		operator typename Container::iterator(void) const { return _iter; }
 		operator typename VersionContainer<Container>::const_iterator() { return typename VersionContainer<Container>::const_iterator(_iter); }
 		operator typename VersionContainer<Container>::const_iterator() { return typename VersionContainer<Container>::const_iterator(_iter); }
 		inline iterator& operator++() { ++_iter; return *this; }
 		inline iterator& operator++() { ++_iter; return *this; }
 		inline iterator operator++(int) { iterator tmp(*this); operator++(); return tmp; }
 		inline iterator operator++(int) { iterator tmp(*this); operator++(); return tmp; }
-		inline bool operator!=(iterator const &i) const { return _iter != i._iter; };
-		inline bool operator==(iterator const &i) const { return _iter == i._iter; };
-		inline iterator& operator=(iterator const &i) { _iter = i._iter; return *this; };
-		inline iterator& operator=(typename Container::iterator const &i) { _iter = i; return *this; };
+		inline bool operator!=(iterator const &i) const { return _iter != i._iter; }
+		inline bool operator==(iterator const &i) const { return _iter == i._iter; }
+		inline iterator& operator=(iterator const &i) { _iter = i._iter; return *this; }
+		inline iterator& operator=(typename Container::iterator const &i) { _iter = i; return *this; }
 		friend std::ostream& operator<<(std::ostream& out, iterator i) { return operator<<(out, *i); }
 		friend std::ostream& operator<<(std::ostream& out, iterator i) { return operator<<(out, *i); }
 	};
 	};
 									/*}}}*/
 									/*}}}*/
 
 
-	bool insert(pkgCache::VerIterator const &V) { if (V.end() == true) return false; _cont.insert(V); return true; };
-	template<class Cont> void insert(VersionContainer<Cont> const &vercont) { _cont.insert((typename Cont::const_iterator)vercont.begin(), (typename Cont::const_iterator)vercont.end()); };
-	void insert(const_iterator begin, const_iterator end) { _cont.insert(begin, end); };
-	bool empty() const { return _cont.empty(); };
-	void clear() { return _cont.clear(); };
+	bool insert(pkgCache::VerIterator const &V) { if (V.end() == true) return false; _cont.insert(V); return true; }
+	template<class Cont> void insert(VersionContainer<Cont> const &vercont) { _cont.insert((typename Cont::const_iterator)vercont.begin(), (typename Cont::const_iterator)vercont.end()); }
+	void insert(const_iterator begin, const_iterator end) { _cont.insert(begin, end); }
+	bool empty() const { return _cont.empty(); }
+	void clear() { return _cont.clear(); }
 	//FIXME: on ABI break, replace the first with the second without bool
 	//FIXME: on ABI break, replace the first with the second without bool
-	void erase(iterator position) { _cont.erase((typename Container::iterator)position); };
-	iterator& erase(iterator &position, bool) { return position = _cont.erase((typename Container::iterator)position); };
-	size_t erase(const pkgCache::VerIterator x) { return _cont.erase(x); };
-	void erase(iterator first, iterator last) { _cont.erase(first, last); };
-	size_t size() const { return _cont.size(); };
-
-	const_iterator begin() const { return const_iterator(_cont.begin()); };
-	const_iterator end() const { return const_iterator(_cont.end()); };
-	iterator begin() { return iterator(_cont.begin()); };
-	iterator end() { return iterator(_cont.end()); };
-	const_iterator find(pkgCache::VerIterator const &V) const { return const_iterator(_cont.find(V)); };
+	void erase(iterator position) { _cont.erase((typename Container::iterator)position); }
+	iterator& erase(iterator &position, bool) { return position = _cont.erase((typename Container::iterator)position); }
+	size_t erase(const pkgCache::VerIterator x) { return _cont.erase(x); }
+	void erase(iterator first, iterator last) { _cont.erase(first, last); }
+	size_t size() const { return _cont.size(); }
+
+	const_iterator begin() const { return const_iterator(_cont.begin()); }
+	const_iterator end() const { return const_iterator(_cont.end()); }
+	iterator begin() { return iterator(_cont.begin()); }
+	iterator end() { return iterator(_cont.end()); }
+	const_iterator find(pkgCache::VerIterator const &V) const { return const_iterator(_cont.find(V)); }
 
 
 	/** \brief returns all versions specified on the commandline
 	/** \brief returns all versions specified on the commandline
 
 
@@ -558,6 +565,7 @@ public:									/*{{{*/
 	    non specifically requested  and executes regex's if needed on names.
 	    non specifically requested  and executes regex's if needed on names.
 	    \param Cache the packages and versions are in
 	    \param Cache the packages and versions are in
 	    \param cmdline Command line the versions should be extracted from
 	    \param cmdline Command line the versions should be extracted from
+	    \param fallback version specification
 	    \param helper responsible for error and message handling */
 	    \param helper responsible for error and message handling */
 	static VersionContainer FromCommandLine(pkgCacheFile &Cache, const char **cmdline,
 	static VersionContainer FromCommandLine(pkgCacheFile &Cache, const char **cmdline,
 			Version const &fallback, CacheSetHelper &helper) {
 			Version const &fallback, CacheSetHelper &helper) {
@@ -656,7 +664,7 @@ public:									/*{{{*/
 template<> template<class Cont> void VersionContainer<std::list<pkgCache::VerIterator> >::insert(VersionContainer<Cont> const &vercont) {
 template<> template<class Cont> void VersionContainer<std::list<pkgCache::VerIterator> >::insert(VersionContainer<Cont> const &vercont) {
 	for (typename VersionContainer<Cont>::const_iterator v = vercont.begin(); v != vercont.end(); ++v)
 	for (typename VersionContainer<Cont>::const_iterator v = vercont.begin(); v != vercont.end(); ++v)
 		_cont.push_back(*v);
 		_cont.push_back(*v);
-};
+}
 // these two are 'inline' as otherwise the linker has problems with seeing these untemplated
 // these two are 'inline' as otherwise the linker has problems with seeing these untemplated
 // specializations again and again - but we need to see them, so that library users can use them
 // specializations again and again - but we need to see them, so that library users can use them
 template<> inline bool VersionContainer<std::list<pkgCache::VerIterator> >::insert(pkgCache::VerIterator const &V) {
 template<> inline bool VersionContainer<std::list<pkgCache::VerIterator> >::insert(pkgCache::VerIterator const &V) {
@@ -664,11 +672,11 @@ template<> inline bool VersionContainer<std::list<pkgCache::VerIterator> >::inse
 		return false;
 		return false;
 	_cont.push_back(V);
 	_cont.push_back(V);
 	return true;
 	return true;
-};
+}
 template<> inline void VersionContainer<std::list<pkgCache::VerIterator> >::insert(const_iterator begin, const_iterator end) {
 template<> inline void VersionContainer<std::list<pkgCache::VerIterator> >::insert(const_iterator begin, const_iterator end) {
 	for (const_iterator v = begin; v != end; ++v)
 	for (const_iterator v = begin; v != end; ++v)
 		_cont.push_back(*v);
 		_cont.push_back(*v);
-};
+}
 typedef VersionContainer<std::set<pkgCache::VerIterator> > VersionSet;
 typedef VersionContainer<std::set<pkgCache::VerIterator> > VersionSet;
 typedef VersionContainer<std::list<pkgCache::VerIterator> > VersionList;
 typedef VersionContainer<std::list<pkgCache::VerIterator> > VersionList;
 }
 }

+ 43 - 38
apt-pkg/cdrom.cc

@@ -1,28 +1,30 @@
 /*
 /*
  */
  */
-#include<config.h>
-
-#include<apt-pkg/init.h>
-#include<apt-pkg/error.h>
-#include<apt-pkg/cdromutl.h>
-#include<apt-pkg/strutl.h>
-#include<apt-pkg/cdrom.h>
-#include<apt-pkg/aptconfiguration.h>
-#include<apt-pkg/configuration.h>
-#include<apt-pkg/fileutl.h>
-
-#include<sstream>
-#include<fstream>
+#include <config.h>
+
+#include <apt-pkg/error.h>
+#include <apt-pkg/cdromutl.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/cdrom.h>
+#include <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/indexcopy.h>
+
+
+#include <string.h>
+#include <iostream>
+#include <string>
+#include <vector>
+#include <sstream>
+#include <fstream>
 #include <sys/stat.h>
 #include <sys/stat.h>
-#include <fcntl.h>
 #include <dirent.h>
 #include <dirent.h>
 #include <unistd.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <stdio.h>
 #include <algorithm>
 #include <algorithm>
 #include <dlfcn.h>
 #include <dlfcn.h>
 
 
-#include "indexcopy.h"
-
 #include<apti18n.h>
 #include<apti18n.h>
 
 
 using namespace std;
 using namespace std;
@@ -369,7 +371,7 @@ bool pkgCdrom::DropRepeats(vector<string> &List,const char *Name)
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* This takes the list of source list expressed entires and collects
 /* This takes the list of source list expressed entires and collects
    similar ones to form a single entry for each dist */
    similar ones to form a single entry for each dist */
-void pkgCdrom::ReduceSourcelist(string CD,vector<string> &List)
+void pkgCdrom::ReduceSourcelist(string /*CD*/,vector<string> &List)
 {
 {
    sort(List.begin(),List.end());
    sort(List.begin(),List.end());
    
    
@@ -440,7 +442,7 @@ bool pkgCdrom::WriteDatabase(Configuration &Cnf)
    Out.close();
    Out.close();
 
 
    if (FileExists(DFile) == true)
    if (FileExists(DFile) == true)
-      rename(DFile.c_str(), string(DFile + '~').c_str());
+      rename(DFile.c_str(), (DFile + '~').c_str());
    if (rename(NewFile.c_str(),DFile.c_str()) != 0)
    if (rename(NewFile.c_str(),DFile.c_str()) != 0)
       return _error->Errno("rename","Failed to rename %s.new to %s",
       return _error->Errno("rename","Failed to rename %s.new to %s",
 			   DFile.c_str(),DFile.c_str());
 			   DFile.c_str(),DFile.c_str());
@@ -553,7 +555,7 @@ bool pkgCdrom::WriteSourceList(string Name,vector<string> &List,bool Source)
    
    
    Out.close();
    Out.close();
 
 
-   rename(File.c_str(),string(File + '~').c_str());
+   rename(File.c_str(), (File + '~').c_str());
    if (rename(NewFile.c_str(),File.c_str()) != 0)
    if (rename(NewFile.c_str(),File.c_str()) != 0)
       return _error->Errno("rename","Failed to rename %s.new to %s",
       return _error->Errno("rename","Failed to rename %s.new to %s",
 			   File.c_str(),File.c_str());
 			   File.c_str(),File.c_str());
@@ -561,7 +563,7 @@ bool pkgCdrom::WriteSourceList(string Name,vector<string> &List,bool Source)
    return true;
    return true;
 }
 }
 									/*}}}*/
 									/*}}}*/
-bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, std::string &ident, pkgCdromStatus * const log)/*{{{*/
+bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, std::string &ident, pkgCdromStatus * const log, bool const interactive)/*{{{*/
 {
 {
    // Startup
    // Startup
    CDROM = _config->FindDir("Acquire::cdrom::mount");
    CDROM = _config->FindDir("Acquire::cdrom::mount");
@@ -579,16 +581,19 @@ bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, s
    // Unmount the CD and get the user to put in the one they want
    // Unmount the CD and get the user to put in the one they want
    if (_config->FindB("APT::CDROM::NoMount", false) == false)
    if (_config->FindB("APT::CDROM::NoMount", false) == false)
    {
    {
-      if(log != NULL)
-	 log->Update(_("Unmounting CD-ROM\n"), STEP_UNMOUNT);
-      UnmountCdrom(CDROM);
-
-      if(log != NULL)
+      if (interactive == true)
       {
       {
-	 log->Update(_("Waiting for disc...\n"), STEP_WAIT);
-	 if(!log->ChangeCdrom()) {
-	    // user aborted
-	    return false;
+	 if(log != NULL)
+	    log->Update(_("Unmounting CD-ROM...\n"), STEP_LAST);
+	 UnmountCdrom(CDROM);
+
+	 if(log != NULL)
+	 {
+	    log->Update(_("Waiting for disc...\n"), STEP_WAIT);
+	    if(!log->ChangeCdrom()) {
+	       // user aborted
+	       return false;
+	    }
 	 }
 	 }
       }
       }
 
 
@@ -602,7 +607,7 @@ bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, s
 
 
    // Hash the CD to get an ID
    // Hash the CD to get an ID
    if (log != NULL)
    if (log != NULL)
-      log->Update(_("Identifying.. "), STEP_IDENT);
+      log->Update(_("Identifying... "), STEP_IDENT);
 
 
    if (IdentCdrom(CDROM,ident) == false)
    if (IdentCdrom(CDROM,ident) == false)
    {
    {
@@ -634,7 +639,7 @@ bool pkgCdrom::Ident(string &ident, pkgCdromStatus *log)		/*{{{*/
 {
 {
    Configuration Database;
    Configuration Database;
    std::string CDROM;
    std::string CDROM;
-   if (MountAndIdentCDROM(Database, CDROM, ident, log) == false)
+   if (MountAndIdentCDROM(Database, CDROM, ident, log, false) == false)
       return false;
       return false;
 
 
    if (log != NULL)
    if (log != NULL)
@@ -660,11 +665,11 @@ bool pkgCdrom::Add(pkgCdromStatus *log)					/*{{{*/
 {
 {
    Configuration Database;
    Configuration Database;
    std::string ID, CDROM;
    std::string ID, CDROM;
-   if (MountAndIdentCDROM(Database, CDROM, ID, log) == false)
+   if (MountAndIdentCDROM(Database, CDROM, ID, log, true) == false)
       return false;
       return false;
 
 
    if(log != NULL)
    if(log != NULL)
-      log->Update(_("Scanning disc for index files..\n"),STEP_SCAN);
+      log->Update(_("Scanning disc for index files...\n"),STEP_SCAN);
 
 
    // Get the CD structure
    // Get the CD structure
    vector<string> List;
    vector<string> List;
@@ -737,7 +742,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log)					/*{{{*/
       if (InfoDir.empty() == false &&
       if (InfoDir.empty() == false &&
 	  FileExists(InfoDir + "/info") == true)
 	  FileExists(InfoDir + "/info") == true)
       {
       {
-	 ifstream F(string(InfoDir + "/info").c_str());
+	 ifstream F((InfoDir + "/info").c_str());
 	 if (!F == 0)
 	 if (!F == 0)
 	    getline(F,Name);
 	    getline(F,Name);
 
 
@@ -933,10 +938,10 @@ pkgUdevCdromDevices::Dlopen()                     		        /*{{{*/
 // convenience interface, this will just call ScanForRemovable
 // convenience interface, this will just call ScanForRemovable
 vector<CdromDevice>
 vector<CdromDevice>
 pkgUdevCdromDevices::Scan()
 pkgUdevCdromDevices::Scan()
-{ 
+{
    bool CdromOnly = _config->FindB("APT::cdrom::CdromOnly", true);
    bool CdromOnly = _config->FindB("APT::cdrom::CdromOnly", true);
-   return ScanForRemovable(CdromOnly); 
-};
+   return ScanForRemovable(CdromOnly);
+}
 									/*}}}*/
 									/*}}}*/
                                                                         /*{{{*/
                                                                         /*{{{*/
 vector<CdromDevice>
 vector<CdromDevice>
@@ -981,7 +986,7 @@ pkgUdevCdromDevices::ScanForRemovable(bool CdromOnly)
       cdrom.DeviceName = string(devnode);
       cdrom.DeviceName = string(devnode);
       if (mountpath != "") {
       if (mountpath != "") {
 	 cdrom.MountPath = mountpath;
 	 cdrom.MountPath = mountpath;
-	 string s = string(mountpath);
+	 string s = mountpath;
 	 cdrom.Mounted = IsMounted(s);
 	 cdrom.Mounted = IsMounted(s);
       } else {
       } else {
 	 cdrom.Mounted = false;
 	 cdrom.Mounted = false;

+ 3 - 1
apt-pkg/cdrom.h

@@ -4,6 +4,8 @@
 #include<string>
 #include<string>
 #include<vector>
 #include<vector>
 
 
+#include <stddef.h>
+
 #ifndef APT_8_CLEANER_HEADERS
 #ifndef APT_8_CLEANER_HEADERS
 #include <apt-pkg/init.h>
 #include <apt-pkg/init.h>
 using namespace std;
 using namespace std;
@@ -72,7 +74,7 @@ class pkgCdrom								/*{{{*/
 
 
  private:
  private:
    bool MountAndIdentCDROM(Configuration &Database, std::string &CDROM,
    bool MountAndIdentCDROM(Configuration &Database, std::string &CDROM,
-	 std::string &ident, pkgCdromStatus * const log);
+	 std::string &ident, pkgCdromStatus * const log, bool const interactive);
 };
 };
 									/*}}}*/
 									/*}}}*/
 
 

+ 4 - 0
apt-pkg/clean.cc

@@ -16,7 +16,11 @@
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/aptconfiguration.h>
 #include <apt-pkg/aptconfiguration.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
 
 
+#include <string>
+#include <string.h>
 #include <dirent.h>
 #include <dirent.h>
 #include <sys/stat.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <unistd.h>

+ 6 - 1
apt-pkg/clean.h

@@ -10,8 +10,13 @@
 #ifndef APTPKG_CLEAN_H
 #ifndef APTPKG_CLEAN_H
 #define APTPKG_CLEAN_H
 #define APTPKG_CLEAN_H
 
 
-
+#ifndef APT_10_CLEANER_HEADERS
 #include <apt-pkg/pkgcache.h>
 #include <apt-pkg/pkgcache.h>
+#endif
+
+#include <string>
+
+class pkgCache;
 
 
 class pkgArchiveCleaner
 class pkgArchiveCleaner
 {
 {

+ 54 - 36
apt-pkg/contrib/cdromutl.cc

@@ -19,7 +19,11 @@
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
 
 
-#include <sys/wait.h>
+#include <stdlib.h>
+#include <string.h>
+#include <iostream>
+#include <string>
+#include <vector>
 #include <sys/statvfs.h>
 #include <sys/statvfs.h>
 #include <dirent.h>
 #include <dirent.h>
 #include <fcntl.h>
 #include <fcntl.h>
@@ -42,11 +46,16 @@ bool IsMounted(string &Path)
 {
 {
    if (Path.empty() == true)
    if (Path.empty() == true)
       return false;
       return false;
-   
+
    // Need that trailing slash for directories
    // Need that trailing slash for directories
    if (Path[Path.length() - 1] != '/')
    if (Path[Path.length() - 1] != '/')
       Path += '/';
       Path += '/';
-   
+
+   // if the path has a ".disk" directory we treat it as mounted
+   // this way even extracted copies of disks are recognized
+   if (DirectoryExists(Path + ".disk/") == true)
+      return true;
+
    /* First we check if the path is actually mounted, we do this by
    /* First we check if the path is actually mounted, we do this by
       stating the path and the previous directory (careful of links!)
       stating the path and the previous directory (careful of links!)
       and comparing their device fields. */
       and comparing their device fields. */
@@ -66,7 +75,13 @@ bool IsMounted(string &Path)
    leave /etc/mtab inconsitant. We drop all messages this produces. */
    leave /etc/mtab inconsitant. We drop all messages this produces. */
 bool UnmountCdrom(string Path)
 bool UnmountCdrom(string Path)
 {
 {
-   if (IsMounted(Path) == false)
+   // do not generate errors, even if the mountpoint does not exist
+   // the mountpoint might be auto-created by the mount command
+   // and a non-existing mountpoint is surely not mounted
+   _error->PushToStack();
+   bool const mounted = IsMounted(Path);
+   _error->RevertToStack();
+   if (mounted == false)
       return true;
       return true;
 
 
    for (int i=0;i<3;i++)
    for (int i=0;i<3;i++)
@@ -78,8 +93,9 @@ bool UnmountCdrom(string Path)
       if (Child == 0)
       if (Child == 0)
       {
       {
 	 // Make all the fds /dev/null
 	 // Make all the fds /dev/null
-	 for (int I = 0; I != 3; I++)
-	    dup2(open("/dev/null",O_RDWR),I);
+	 int const null_fd = open("/dev/null",O_RDWR);
+	 for (int I = 0; I != 3; ++I)
+	    dup2(null_fd, I);
 
 
 	 if (_config->Exists("Acquire::cdrom::"+Path+"::UMount") == true)
 	 if (_config->Exists("Acquire::cdrom::"+Path+"::UMount") == true)
 	 {
 	 {
@@ -113,19 +129,24 @@ bool UnmountCdrom(string Path)
 /* We fork mount and drop all messages */
 /* We fork mount and drop all messages */
 bool MountCdrom(string Path, string DeviceName)
 bool MountCdrom(string Path, string DeviceName)
 {
 {
-   if (IsMounted(Path) == true)
+   // do not generate errors, even if the mountpoint does not exist
+   // the mountpoint might be auto-created by the mount command
+   _error->PushToStack();
+   bool const mounted = IsMounted(Path);
+   _error->RevertToStack();
+   if (mounted == true)
       return true;
       return true;
-   
+
    int Child = ExecFork();
    int Child = ExecFork();
 
 
    // The child
    // The child
    if (Child == 0)
    if (Child == 0)
    {
    {
       // Make all the fds /dev/null
       // Make all the fds /dev/null
-      int null_fd = open("/dev/null",O_RDWR);
-      for (int I = 0; I != 3; I++)
+      int const null_fd = open("/dev/null",O_RDWR);
+      for (int I = 0; I != 3; ++I)
 	 dup2(null_fd, I);
 	 dup2(null_fd, I);
-      
+
       if (_config->Exists("Acquire::cdrom::"+Path+"::Mount") == true)
       if (_config->Exists("Acquire::cdrom::"+Path+"::Mount") == true)
       {
       {
 	 if (system(_config->Find("Acquire::cdrom::"+Path+"::Mount").c_str()) != 0)
 	 if (system(_config->Find("Acquire::cdrom::"+Path+"::Mount").c_str()) != 0)
@@ -242,37 +263,34 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version)
    return true;   
    return true;   
 }
 }
 									/*}}}*/
 									/*}}}*/
-
 // FindMountPointForDevice - Find mountpoint for the given device	/*{{{*/
 // FindMountPointForDevice - Find mountpoint for the given device	/*{{{*/
 string FindMountPointForDevice(const char *devnode)
 string FindMountPointForDevice(const char *devnode)
 {
 {
-   char buf[255];
-   char *out[10];
-   int i=0;
-
    // this is the order that mount uses as well
    // this is the order that mount uses as well
-   const char *mount[] = { "/etc/mtab", 
-                           "/proc/mount", 
-                           NULL };
+   std::vector<std::string> const mounts = _config->FindVector("Dir::state::MountPoints", "/etc/mtab,/proc/mount");
 
 
-   for (i=0; mount[i] != NULL; i++) {
-      if (FileExists(mount[i])) {
-         FILE *f=fopen(mount[i], "r");
-         while ( fgets(buf, sizeof(buf), f) != NULL) {
-            if (strncmp(buf, devnode, strlen(devnode)) == 0) {
-               if(TokSplitString(' ', buf, out, 10))
-               {
-                  fclose(f);
-                  // unescape the \0XXX chars in the path
-                  string mount_point = out[1];
-                  return DeEscapeString(mount_point);
-               }
-            }
-         }
-         fclose(f);
+   for (std::vector<std::string>::const_iterator m = mounts.begin(); m != mounts.end(); ++m)
+      if (FileExists(*m) == true)
+      {
+	 char * line = NULL;
+	 size_t line_len = 0;
+	 FILE * f = fopen(m->c_str(), "r");
+	 while(getline(&line, &line_len, f) != -1)
+	 {
+	    char * out[] = { NULL, NULL, NULL };
+	    TokSplitString(' ', line, out, 3);
+	    if (out[2] != NULL || out[1] == NULL || out[0] == NULL)
+	       continue;
+	    if (strcmp(out[0], devnode) != 0)
+	       continue;
+	    fclose(f);
+	    // unescape the \0XXX chars in the path
+	    string mount_point = out[1];
+	    return DeEscapeString(mount_point);
+	 }
+	 fclose(f);
       }
       }
-   }
-   
+
    return string();
    return string();
 }
 }
 									/*}}}*/
 									/*}}}*/

+ 5 - 0
apt-pkg/contrib/cmndline.cc

@@ -18,6 +18,11 @@
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
 
 
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <string>
+
 #include <apti18n.h>
 #include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
 using namespace std;
 using namespace std;

+ 5 - 3
apt-pkg/contrib/cmndline.h

@@ -44,6 +44,8 @@
 #ifndef PKGLIB_CMNDLINE_H
 #ifndef PKGLIB_CMNDLINE_H
 #define PKGLIB_CMNDLINE_H
 #define PKGLIB_CMNDLINE_H
 
 
+#include <apt-pkg/macros.h>
+
 #ifndef APT_8_CLEANER_HEADERS
 #ifndef APT_8_CLEANER_HEADERS
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
 #endif
 #endif
@@ -80,14 +82,14 @@ class CommandLine
    
    
    bool Parse(int argc,const char **argv);
    bool Parse(int argc,const char **argv);
    void ShowHelp();
    void ShowHelp();
-   unsigned int FileSize() const;
+   unsigned int FileSize() const APT_PURE;
    bool DispatchArg(Dispatch *List,bool NoMatch = true);
    bool DispatchArg(Dispatch *List,bool NoMatch = true);
       
       
    static char const * GetCommand(Dispatch const * const Map,
    static char const * GetCommand(Dispatch const * const Map,
-	 unsigned int const argc, char const * const * const argv);
+	 unsigned int const argc, char const * const * const argv) APT_PURE;
 
 
    static CommandLine::Args MakeArgs(char ShortOpt, char const *LongOpt,
    static CommandLine::Args MakeArgs(char ShortOpt, char const *LongOpt,
-	 char const *ConfName, unsigned long Flags);
+	 char const *ConfName, unsigned long Flags) APT_CONST;
 
 
    CommandLine(Args *AList,Configuration *Conf);
    CommandLine(Args *AList,Configuration *Conf);
    ~CommandLine();
    ~CommandLine();

+ 22 - 6
apt-pkg/contrib/configuration.cc

@@ -21,10 +21,18 @@
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
-
+#include <apt-pkg/macros.h>
+
+#include <ctype.h>
+#include <regex.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <algorithm>
+#include <string>
 #include <vector>
 #include <vector>
 #include <fstream>
 #include <fstream>
-#include <iostream>
 
 
 #include <apti18n.h>
 #include <apti18n.h>
 
 
@@ -42,8 +50,7 @@ Configuration::Configuration() : ToFree(true)
 }
 }
 Configuration::Configuration(const Item *Root) : Root((Item *)Root), ToFree(false)
 Configuration::Configuration(const Item *Root) : Root((Item *)Root), ToFree(false)
 {
 {
-};
-
+}
 									/*}}}*/
 									/*}}}*/
 // Configuration::~Configuration - Destructor				/*{{{*/
 // Configuration::~Configuration - Destructor				/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
@@ -246,12 +253,18 @@ string Configuration::FindDir(const char *Name,const char *Default) const
 // Configuration::FindVector - Find a vector of values			/*{{{*/
 // Configuration::FindVector - Find a vector of values			/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* Returns a vector of config values under the given item */
 /* Returns a vector of config values under the given item */
-vector<string> Configuration::FindVector(const char *Name) const
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR < 13)
+vector<string> Configuration::FindVector(const char *Name) const { return FindVector(Name, ""); }
+#endif
+vector<string> Configuration::FindVector(const char *Name, std::string const &Default) const
 {
 {
    vector<string> Vec;
    vector<string> Vec;
    const Item *Top = Lookup(Name);
    const Item *Top = Lookup(Name);
    if (Top == NULL)
    if (Top == NULL)
-      return Vec;
+      return VectorizeString(Default, ',');
+
+   if (Top->Value.empty() == false)
+      return VectorizeString(Top->Value, ',');
 
 
    Item *I = Top->Child;
    Item *I = Top->Child;
    while(I != NULL)
    while(I != NULL)
@@ -259,6 +272,9 @@ vector<string> Configuration::FindVector(const char *Name) const
       Vec.push_back(I->Value);
       Vec.push_back(I->Value);
       I = I->Next;
       I = I->Next;
    }
    }
+   if (Vec.empty() == true)
+      return VectorizeString(Default, ',');
+
    return Vec;
    return Vec;
 }
 }
 									/*}}}*/
 									/*}}}*/

+ 15 - 1
apt-pkg/contrib/configuration.h

@@ -74,8 +74,22 @@ class Configuration
    std::string Find(std::string const &Name, std::string const &Default) const {return Find(Name.c_str(),Default.c_str());};
    std::string Find(std::string const &Name, std::string const &Default) const {return Find(Name.c_str(),Default.c_str());};
    std::string FindFile(const char *Name,const char *Default = 0) const;
    std::string FindFile(const char *Name,const char *Default = 0) const;
    std::string FindDir(const char *Name,const char *Default = 0) const;
    std::string FindDir(const char *Name,const char *Default = 0) const;
+   /** return a list of child options
+    *
+    * Options like Acquire::Languages are handled as lists which
+    * can be overridden and have a default. For the later two a comma
+    * separated list of values is supported.
+    *
+    * \param Name of the parent node
+    * \param Default list of values separated by commas */
+   std::vector<std::string> FindVector(const char *Name, std::string const &Default) const;
+   std::vector<std::string> FindVector(std::string const &Name, std::string const &Default) const { return FindVector(Name.c_str(), Default); };
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+   std::vector<std::string> FindVector(const char *Name) const { return FindVector(Name, ""); };
+#else
    std::vector<std::string> FindVector(const char *Name) const;
    std::vector<std::string> FindVector(const char *Name) const;
-   std::vector<std::string> FindVector(std::string const &Name) const { return FindVector(Name.c_str()); };
+#endif
+   std::vector<std::string> FindVector(std::string const &Name) const { return FindVector(Name.c_str(), ""); };
    int FindI(const char *Name,int const &Default = 0) const;
    int FindI(const char *Name,int const &Default = 0) const;
    int FindI(std::string const &Name,int const &Default = 0) const {return FindI(Name.c_str(),Default);};
    int FindI(std::string const &Name,int const &Default = 0) const {return FindI(Name.c_str(),Default);};
    bool FindB(const char *Name,bool const &Default = false) const;
    bool FindB(const char *Name,bool const &Default = false) const;

+ 3 - 1
apt-pkg/contrib/crc-16.h

@@ -10,8 +10,10 @@
 #ifndef APTPKG_CRC16_H
 #ifndef APTPKG_CRC16_H
 #define APTPKG_CRC16_H
 #define APTPKG_CRC16_H
 
 
+#include <apt-pkg/macros.h>
+
 #define INIT_FCS  0xffff
 #define INIT_FCS  0xffff
 unsigned short AddCRC16(unsigned short fcs, void const *buf,
 unsigned short AddCRC16(unsigned short fcs, void const *buf,
-			unsigned long long len);
+			unsigned long long len) APT_PURE;
 
 
 #endif
 #endif

+ 4 - 2
apt-pkg/contrib/error.cc

@@ -17,12 +17,14 @@
 
 
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 
 
+#include <stdarg.h>
+#include <stddef.h>
+#include <list>
 #include <iostream>
 #include <iostream>
 #include <errno.h>
 #include <errno.h>
 #include <stdio.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <unistd.h>
-
 #include <string>
 #include <string>
 #include <cstring>
 #include <cstring>
 
 
@@ -223,7 +225,7 @@ void GlobalError::DumpErrors(std::ostream &out, MsgType const &threshold,
 void GlobalError::Discard() {
 void GlobalError::Discard() {
 	Messages.clear();
 	Messages.clear();
 	PendingFlag = false;
 	PendingFlag = false;
-};
+}
 									/*}}}*/
 									/*}}}*/
 // GlobalError::empty - does our error list include anything?		/*{{{*/
 // GlobalError::empty - does our error list include anything?		/*{{{*/
 bool GlobalError::empty(MsgType const &trashhold) const {
 bool GlobalError::empty(MsgType const &trashhold) const {

+ 19 - 18
apt-pkg/contrib/error.h

@@ -46,6 +46,7 @@
 #include <list>
 #include <list>
 #include <string>
 #include <string>
 
 
+#include <stddef.h>
 #include <stdarg.h>
 #include <stdarg.h>
 
 
 class GlobalError							/*{{{*/
 class GlobalError							/*{{{*/
@@ -73,7 +74,7 @@ public:									/*{{{*/
 	 *
 	 *
 	 *  \return \b false
 	 *  \return \b false
 	 */
 	 */
-	bool FatalE(const char *Function,const char *Description,...) __like_printf(3) __cold;
+	bool FatalE(const char *Function,const char *Description,...) APT_PRINTF(3) APT_COLD;
 
 
 	/** \brief add an Error message with errno to the list
 	/** \brief add an Error message with errno to the list
 	 *
 	 *
@@ -82,7 +83,7 @@ public:									/*{{{*/
 	 *
 	 *
 	 *  \return \b false
 	 *  \return \b false
 	 */
 	 */
-	bool Errno(const char *Function,const char *Description,...) __like_printf(3) __cold;
+	bool Errno(const char *Function,const char *Description,...) APT_PRINTF(3) APT_COLD;
 
 
 	/** \brief add a warning message with errno to the list
 	/** \brief add a warning message with errno to the list
 	 *
 	 *
@@ -94,7 +95,7 @@ public:									/*{{{*/
 	 *
 	 *
 	 *  \return \b false
 	 *  \return \b false
 	 */
 	 */
-	bool WarningE(const char *Function,const char *Description,...) __like_printf(3) __cold;
+	bool WarningE(const char *Function,const char *Description,...) APT_PRINTF(3) APT_COLD;
 
 
 	/** \brief add a notice message with errno to the list
 	/** \brief add a notice message with errno to the list
 	 *
 	 *
@@ -103,7 +104,7 @@ public:									/*{{{*/
 	 *
 	 *
 	 *  \return \b false
 	 *  \return \b false
 	 */
 	 */
-	bool NoticeE(const char *Function,const char *Description,...) __like_printf(3) __cold;
+	bool NoticeE(const char *Function,const char *Description,...) APT_PRINTF(3) APT_COLD;
 
 
 	/** \brief add a debug message with errno to the list
 	/** \brief add a debug message with errno to the list
 	 *
 	 *
@@ -112,7 +113,7 @@ public:									/*{{{*/
 	 *
 	 *
 	 *  \return \b false
 	 *  \return \b false
 	 */
 	 */
-	bool DebugE(const char *Function,const char *Description,...) __like_printf(3) __cold;
+	bool DebugE(const char *Function,const char *Description,...) APT_PRINTF(3) APT_COLD;
 
 
 	/** \brief adds an errno message with the given type
 	/** \brief adds an errno message with the given type
 	 *
 	 *
@@ -121,7 +122,7 @@ public:									/*{{{*/
 	 * \param Description of the error
 	 * \param Description of the error
 	 */
 	 */
 	bool InsertErrno(MsgType const &type, const char* Function,
 	bool InsertErrno(MsgType const &type, const char* Function,
-			 const char* Description,...) __like_printf(4) __cold;
+			 const char* Description,...) APT_PRINTF(4) APT_COLD;
 
 
 	/** \brief adds an errno message with the given type
 	/** \brief adds an errno message with the given type
 	 *
 	 *
@@ -140,7 +141,7 @@ public:									/*{{{*/
 	 */
 	 */
 	bool InsertErrno(MsgType type, const char* Function,
 	bool InsertErrno(MsgType type, const char* Function,
 			 const char* Description, va_list &args,
 			 const char* Description, va_list &args,
-			 int const errsv, size_t &msgSize);
+			 int const errsv, size_t &msgSize) APT_COLD;
 
 
 	/** \brief add an fatal error message to the list
 	/** \brief add an fatal error message to the list
 	 *
 	 *
@@ -155,7 +156,7 @@ public:									/*{{{*/
 	 *
 	 *
 	 *  \return \b false
 	 *  \return \b false
 	 */
 	 */
-	bool Fatal(const char *Description,...) __like_printf(2) __cold;
+	bool Fatal(const char *Description,...) APT_PRINTF(2) APT_COLD;
 
 
 	/** \brief add an Error message to the list
 	/** \brief add an Error message to the list
 	 *
 	 *
@@ -163,7 +164,7 @@ public:									/*{{{*/
 	 *
 	 *
 	 *  \return \b false
 	 *  \return \b false
 	 */
 	 */
-	bool Error(const char *Description,...) __like_printf(2) __cold;
+	bool Error(const char *Description,...) APT_PRINTF(2) APT_COLD;
 
 
 	/** \brief add a warning message to the list
 	/** \brief add a warning message to the list
 	 *
 	 *
@@ -174,7 +175,7 @@ public:									/*{{{*/
 	 *
 	 *
 	 *  \return \b false
 	 *  \return \b false
 	 */
 	 */
-	bool Warning(const char *Description,...) __like_printf(2) __cold;
+	bool Warning(const char *Description,...) APT_PRINTF(2) APT_COLD;
 
 
 	/** \brief add a notice message to the list
 	/** \brief add a notice message to the list
 	 *
 	 *
@@ -187,7 +188,7 @@ public:									/*{{{*/
 	 *
 	 *
 	 *  \return \b false
 	 *  \return \b false
 	 */
 	 */
-	bool Notice(const char *Description,...) __like_printf(2) __cold;
+	bool Notice(const char *Description,...) APT_PRINTF(2) APT_COLD;
 
 
 	/** \brief add a debug message to the list
 	/** \brief add a debug message to the list
 	 *
 	 *
@@ -195,14 +196,14 @@ public:									/*{{{*/
 	 *
 	 *
 	 *  \return \b false
 	 *  \return \b false
 	 */
 	 */
-	bool Debug(const char *Description,...) __like_printf(2) __cold;
+	bool Debug(const char *Description,...) APT_PRINTF(2) APT_COLD;
 
 
 	/** \brief adds an error message with the given type
 	/** \brief adds an error message with the given type
 	 *
 	 *
 	 * \param type of the error message
 	 * \param type of the error message
 	 * \param Description of the error
 	 * \param Description of the error
 	 */
 	 */
-	bool Insert(MsgType const &type, const char* Description,...) __like_printf(3) __cold;
+	bool Insert(MsgType const &type, const char* Description,...) APT_PRINTF(3) APT_COLD;
 
 
 	/** \brief adds an error message with the given type
 	/** \brief adds an error message with the given type
 	 *
 	 *
@@ -218,13 +219,13 @@ public:									/*{{{*/
 	 * should call this method again in that case
 	 * should call this method again in that case
 	 */
 	 */
 	bool Insert(MsgType type, const char* Description,
 	bool Insert(MsgType type, const char* Description,
-			 va_list &args, size_t &msgSize) __cold;
+			 va_list &args, size_t &msgSize) APT_COLD;
 
 
 	/** \brief is an error in the list?
 	/** \brief is an error in the list?
 	 *
 	 *
 	 *  \return \b true if an error is included in the list, \b false otherwise
 	 *  \return \b true if an error is included in the list, \b false otherwise
 	 */
 	 */
-	inline bool PendingError() const {return PendingFlag;};
+	inline bool PendingError() const APT_PURE {return PendingFlag;};
 
 
 	/** \brief is the list empty?
 	/** \brief is the list empty?
 	 *
 	 *
@@ -232,11 +233,11 @@ public:									/*{{{*/
 	 *  if you want to check if also no notices happened set the parameter
 	 *  if you want to check if also no notices happened set the parameter
 	 *  flag to \b false.
 	 *  flag to \b false.
 	 *
 	 *
-	 *  \param WithoutNotice does notices count, default is \b true, so no
+	 *  \param threshold minimim level considered
 	 *
 	 *
 	 *  \return \b true if an the list is empty, \b false otherwise
 	 *  \return \b true if an the list is empty, \b false otherwise
 	 */
 	 */
-	bool empty(MsgType const &trashhold = WARNING) const;
+	bool empty(MsgType const &threshold = WARNING) const APT_PURE;
 
 
 	/** \brief returns and removes the first (or last) message in the list
 	/** \brief returns and removes the first (or last) message in the list
 	 *
 	 *
@@ -302,7 +303,7 @@ public:									/*{{{*/
 	void MergeWithStack();
 	void MergeWithStack();
 
 
 	/** \brief return the deep of the stack */
 	/** \brief return the deep of the stack */
-	size_t StackCount() const {
+	size_t StackCount() const APT_PURE {
 		return Stacks.size();
 		return Stacks.size();
 	}
 	}
 
 

+ 326 - 149
apt-pkg/contrib/fileutl.cc

@@ -1,6 +1,5 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: fileutl.cc,v 1.42 2002/09/14 05:29:22 jgg Exp $
 /* ######################################################################
 /* ######################################################################
    
    
    File Utilities
    File Utilities
@@ -26,16 +25,22 @@
 #include <apt-pkg/sptr.h>
 #include <apt-pkg/sptr.h>
 #include <apt-pkg/aptconfiguration.h>
 #include <apt-pkg/aptconfiguration.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
-
+#include <apt-pkg/macros.h>
+
+#include <ctype.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <sys/select.h>
+#include <time.h>
+#include <string>
+#include <vector>
 #include <cstdlib>
 #include <cstdlib>
 #include <cstring>
 #include <cstring>
 #include <cstdio>
 #include <cstdio>
-
 #include <iostream>
 #include <iostream>
 #include <unistd.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <sys/stat.h>
-#include <sys/types.h>
 #include <sys/time.h>
 #include <sys/time.h>
 #include <sys/wait.h>
 #include <sys/wait.h>
 #include <dirent.h>
 #include <dirent.h>
@@ -52,6 +57,10 @@
 #ifdef HAVE_BZ2
 #ifdef HAVE_BZ2
 	#include <bzlib.h>
 	#include <bzlib.h>
 #endif
 #endif
+#ifdef HAVE_LZMA
+	#include <stdint.h>
+	#include <lzma.h>
+#endif
 
 
 #ifdef WORDS_BIGENDIAN
 #ifdef WORDS_BIGENDIAN
 #include <inttypes.h>
 #include <inttypes.h>
@@ -62,54 +71,6 @@
 
 
 using namespace std;
 using namespace std;
 
 
-class FileFdPrivate {
-	public:
-#ifdef HAVE_ZLIB
-	gzFile gz;
-#else
-	void* gz;
-#endif
-#ifdef HAVE_BZ2
-	BZFILE* bz2;
-#else
-	void* bz2;
-#endif
-	int compressed_fd;
-	pid_t compressor_pid;
-	bool pipe;
-	APT::Configuration::Compressor compressor;
-	unsigned int openmode;
-	unsigned long long seekpos;
-	FileFdPrivate() : gz(NULL), bz2(NULL),
-			  compressed_fd(-1), compressor_pid(-1), pipe(false),
-			  openmode(0), seekpos(0) {};
-	bool CloseDown(std::string const &FileName)
-	{
-	   bool Res = true;
-#ifdef HAVE_ZLIB
-	   if (gz != NULL) {
-	      int const e = gzclose(gz);
-	      gz = NULL;
-	      // gzdclose() on empty files always fails with "buffer error" here, ignore that
-	      if (e != 0 && e != Z_BUF_ERROR)
-		 Res &= _error->Errno("close",_("Problem closing the gzip file %s"), FileName.c_str());
-	   }
-#endif
-#ifdef HAVE_BZ2
-	   if (bz2 != NULL) {
-	      BZ2_bzclose(bz2);
-	      bz2 = NULL;
-	   }
-#endif
-	   if (compressor_pid > 0)
-	      ExecWait(compressor_pid, "FileFdCompressor", true);
-	   compressor_pid = -1;
-
-	   return Res;
-	}
-	~FileFdPrivate() { CloseDown(""); }
-};
-
 // RunScripts - Run a set of scripts from a configuration subtree	/*{{{*/
 // RunScripts - Run a set of scripts from a configuration subtree	/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
@@ -874,6 +835,122 @@ bool ExecWait(pid_t Pid,const char *Name,bool Reap)
 }
 }
 									/*}}}*/
 									/*}}}*/
 
 
+class FileFdPrivate {							/*{{{*/
+	public:
+#ifdef HAVE_ZLIB
+	gzFile gz;
+#endif
+#ifdef HAVE_BZ2
+	BZFILE* bz2;
+#endif
+#ifdef HAVE_LZMA
+	struct LZMAFILE {
+	   FILE* file;
+	   uint8_t buffer[4096];
+	   lzma_stream stream;
+	   lzma_ret err;
+	   bool eof;
+	   bool compressing;
+
+	   LZMAFILE() : file(NULL), eof(false), compressing(false) {}
+	   ~LZMAFILE() {
+	      if (compressing == true)
+	      {
+		for (;;) {
+			stream.avail_out = sizeof(buffer)/sizeof(buffer[0]);
+			stream.next_out = buffer;
+			err = lzma_code(&stream, LZMA_FINISH);
+			if (err != LZMA_OK && err != LZMA_STREAM_END)
+			{
+				_error->Error("~LZMAFILE: Compress finalisation failed");
+				break;
+			}
+			size_t const n =  sizeof(buffer)/sizeof(buffer[0]) - stream.avail_out;
+			if (n && fwrite(buffer, 1, n, file) != n)
+			{
+				_error->Errno("~LZMAFILE",_("Write error"));
+				break;
+			}
+			if (err == LZMA_STREAM_END)
+				break;
+		}
+	      }
+	      lzma_end(&stream);
+	      fclose(file);
+	   }
+	};
+	LZMAFILE* lzma;
+#endif
+	int compressed_fd;
+	pid_t compressor_pid;
+	bool pipe;
+	APT::Configuration::Compressor compressor;
+	unsigned int openmode;
+	unsigned long long seekpos;
+	FileFdPrivate() :
+#ifdef HAVE_ZLIB
+			  gz(NULL),
+#endif
+#ifdef HAVE_BZ2
+			  bz2(NULL),
+#endif
+#ifdef HAVE_LZMA
+			  lzma(NULL),
+#endif
+			  compressed_fd(-1), compressor_pid(-1), pipe(false),
+			  openmode(0), seekpos(0) {};
+	bool InternalClose(std::string const &FileName)
+	{
+	   if (false)
+	      /* dummy so that the rest can be 'else if's */;
+#ifdef HAVE_ZLIB
+	   else if (gz != NULL) {
+	      int const e = gzclose(gz);
+	      gz = NULL;
+	      // gzdclose() on empty files always fails with "buffer error" here, ignore that
+	      if (e != 0 && e != Z_BUF_ERROR)
+		 return _error->Errno("close",_("Problem closing the gzip file %s"), FileName.c_str());
+	   }
+#endif
+#ifdef HAVE_BZ2
+	   else if (bz2 != NULL) {
+	      BZ2_bzclose(bz2);
+	      bz2 = NULL;
+	   }
+#endif
+#ifdef HAVE_LZMA
+	   else if (lzma != NULL) {
+	      delete lzma;
+	      lzma = NULL;
+	   }
+#endif
+	   return true;
+	}
+	bool CloseDown(std::string const &FileName)
+	{
+	   bool const Res = InternalClose(FileName);
+
+	   if (compressor_pid > 0)
+	      ExecWait(compressor_pid, "FileFdCompressor", true);
+	   compressor_pid = -1;
+
+	   return Res;
+	}
+	bool InternalStream() const {
+	   return false
+#ifdef HAVE_BZ2
+	      || bz2 != NULL
+#endif
+#ifdef HAVE_LZMA
+	      || lzma != NULL
+#endif
+	      ;
+	}
+
+
+	~FileFdPrivate() { CloseDown(""); }
+};
+									/*}}}*/
 // FileFd::Open - Open a file						/*{{{*/
 // FileFd::Open - Open a file						/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* The most commonly used open mode combinations are given with Mode */
 /* The most commonly used open mode combinations are given with Mode */
@@ -891,7 +968,7 @@ bool FileFd::Open(string FileName,unsigned int const Mode,CompressMode Compress,
    {
    {
       for (; compressor != compressors.end(); ++compressor)
       for (; compressor != compressors.end(); ++compressor)
       {
       {
-	 std::string file = std::string(FileName).append(compressor->Extension);
+	 std::string file = FileName + compressor->Extension;
 	 if (FileExists(file) == false)
 	 if (FileExists(file) == false)
 	    continue;
 	    continue;
 	 FileName = file;
 	 FileName = file;
@@ -1061,30 +1138,12 @@ bool FileFd::OpenDescriptor(int Fd, unsigned int const Mode, APT::Configuration:
 {
 {
    Close();
    Close();
    Flags = (AutoClose) ? FileFd::AutoClose : 0;
    Flags = (AutoClose) ? FileFd::AutoClose : 0;
-   if (AutoClose == false && (
-#ifdef HAVE_ZLIB
-	compressor.Name == "gzip" ||
-#endif
-#ifdef HAVE_BZ2
-	compressor.Name == "bzip2" ||
-#endif
-	false))
-   {
-      // Need to duplicate fd here or gzclose for cleanup will close the fd as well
-      iFd = dup(Fd);
-   }
-   else
-      iFd = Fd;
+   iFd = Fd;
    this->FileName = "";
    this->FileName = "";
-   if (Fd == -1 || OpenInternDescriptor(Mode, compressor) == false)
+   if (OpenInternDescriptor(Mode, compressor) == false)
    {
    {
       if (iFd != -1 && (
       if (iFd != -1 && (
-#ifdef HAVE_ZLIB
-	compressor.Name == "gzip" ||
-#endif
-#ifdef HAVE_BZ2
-	compressor.Name == "bzip2" ||
-#endif
+	(Flags & Compressed) == Compressed ||
 	AutoClose == true))
 	AutoClose == true))
       {
       {
 	 close (iFd);
 	 close (iFd);
@@ -1096,52 +1155,121 @@ bool FileFd::OpenDescriptor(int Fd, unsigned int const Mode, APT::Configuration:
 }
 }
 bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::Compressor const &compressor)
 bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::Compressor const &compressor)
 {
 {
+   if (iFd == -1)
+      return false;
    if (compressor.Name == "." || compressor.Binary.empty() == true)
    if (compressor.Name == "." || compressor.Binary.empty() == true)
       return true;
       return true;
 
 
+#if defined HAVE_ZLIB || defined HAVE_BZ2 || defined HAVE_LZMA
+   // the API to open files is similar, so setup to avoid code duplicates later
+   // and while at it ensure that we close before opening (if its a reopen)
+   void* (*compress_open)(int, const char *) = NULL;
+   if (false)
+      /* dummy so that the rest can be 'else if's */;
+#define APT_COMPRESS_INIT(NAME,OPEN) \
+   else if (compressor.Name == NAME) \
+   { \
+      compress_open = (void*(*)(int, const char *)) OPEN; \
+      if (d != NULL) d->InternalClose(FileName); \
+   }
+#ifdef HAVE_ZLIB
+   APT_COMPRESS_INIT("gzip", gzdopen)
+#endif
+#ifdef HAVE_BZ2
+   APT_COMPRESS_INIT("bzip2", BZ2_bzdopen)
+#endif
+#ifdef HAVE_LZMA
+   APT_COMPRESS_INIT("xz", fdopen)
+   APT_COMPRESS_INIT("lzma", fdopen)
+#endif
+#undef APT_COMPRESS_INIT
+#endif
+
    if (d == NULL)
    if (d == NULL)
    {
    {
       d = new FileFdPrivate();
       d = new FileFdPrivate();
       d->openmode = Mode;
       d->openmode = Mode;
       d->compressor = compressor;
       d->compressor = compressor;
+#if defined HAVE_ZLIB || defined HAVE_BZ2 || defined HAVE_LZMA
+      if (AutoClose == false && compress_open != NULL)
+      {
+	 // Need to duplicate fd here or gz/bz2 close for cleanup will close the fd as well
+	 int const internFd = dup(iFd);
+	 if (internFd == -1)
+	    return FileFdErrno("OpenInternDescriptor", _("Could not open file descriptor %d"), iFd);
+	 iFd = internFd;
+      }
+#endif
    }
    }
 
 
-#ifdef HAVE_ZLIB
-   if (compressor.Name == "gzip")
+#if defined HAVE_ZLIB || defined HAVE_BZ2 || defined HAVE_LZMA
+   if (compress_open != NULL)
    {
    {
-      if (d->gz != NULL)
-      {
-	 gzclose(d->gz);
-	 d->gz = NULL;
-      }
+      void* compress_struct = NULL;
       if ((Mode & ReadWrite) == ReadWrite)
       if ((Mode & ReadWrite) == ReadWrite)
-	 d->gz = gzdopen(iFd, "r+");
+	 compress_struct = compress_open(iFd, "r+");
       else if ((Mode & WriteOnly) == WriteOnly)
       else if ((Mode & WriteOnly) == WriteOnly)
-	 d->gz = gzdopen(iFd, "w");
+	 compress_struct = compress_open(iFd, "w");
       else
       else
-	 d->gz = gzdopen(iFd, "r");
-      if (d->gz == NULL)
+	 compress_struct = compress_open(iFd, "r");
+      if (compress_struct == NULL)
 	 return false;
 	 return false;
-      Flags |= Compressed;
-      return true;
-   }
+
+      if (false)
+	 /* dummy so that the rest can be 'else if's */;
+#ifdef HAVE_ZLIB
+      else if (compressor.Name == "gzip")
+	 d->gz = (gzFile) compress_struct;
 #endif
 #endif
 #ifdef HAVE_BZ2
 #ifdef HAVE_BZ2
-   if (compressor.Name == "bzip2")
-   {
-      if (d->bz2 != NULL)
+      else if (compressor.Name == "bzip2")
+	 d->bz2 = (BZFILE*) compress_struct;
+#endif
+#ifdef HAVE_LZMA
+      else if (compressor.Name == "xz" || compressor.Name == "lzma")
       {
       {
-	 BZ2_bzclose(d->bz2);
-	 d->bz2 = NULL;
+	 uint32_t const xzlevel = 6;
+	 uint64_t const memlimit = UINT64_MAX;
+	 if (d->lzma == NULL)
+	    d->lzma = new FileFdPrivate::LZMAFILE;
+	 d->lzma->file = (FILE*) compress_struct;
+	 d->lzma->stream = LZMA_STREAM_INIT;
+
+	 if ((Mode & ReadWrite) == ReadWrite)
+	    return FileFdError("ReadWrite mode is not supported for file %s", FileName.c_str());
+
+	 if ((Mode & WriteOnly) == WriteOnly)
+	 {
+	    if (compressor.Name == "xz")
+	    {
+	       if (lzma_easy_encoder(&d->lzma->stream, xzlevel, LZMA_CHECK_CRC32) != LZMA_OK)
+		  return false;
+	    }
+	    else
+	    {
+	       lzma_options_lzma options;
+	       lzma_lzma_preset(&options, xzlevel);
+	       if (lzma_alone_encoder(&d->lzma->stream, &options) != LZMA_OK)
+		  return false;
+	    }
+	    d->lzma->compressing = true;
+	 }
+	 else
+	 {
+	    if (compressor.Name == "xz")
+	    {
+	       if (lzma_auto_decoder(&d->lzma->stream, memlimit, 0) != LZMA_OK)
+		  return false;
+	    }
+	    else
+	    {
+	       if (lzma_alone_decoder(&d->lzma->stream, memlimit) != LZMA_OK)
+		  return false;
+	    }
+	    d->lzma->compressing = false;
+	 }
       }
       }
-      if ((Mode & ReadWrite) == ReadWrite)
-	 d->bz2 = BZ2_bzdopen(iFd, "r+");
-      else if ((Mode & WriteOnly) == WriteOnly)
-	 d->bz2 = BZ2_bzdopen(iFd, "w");
-      else
-	 d->bz2 = BZ2_bzdopen(iFd, "r");
-      if (d->bz2 == NULL)
-	 return false;
+#endif
       Flags |= Compressed;
       Flags |= Compressed;
       return true;
       return true;
    }
    }
@@ -1198,7 +1326,7 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C
       }
       }
       else
       else
       {
       {
-	 if (FileName.empty() == true)
+	 if (d->compressed_fd != -1)
 	    dup2(d->compressed_fd,STDIN_FILENO);
 	    dup2(d->compressed_fd,STDIN_FILENO);
 	 dup2(Pipe[1],STDOUT_FILENO);
 	 dup2(Pipe[1],STDOUT_FILENO);
       }
       }
@@ -1267,24 +1395,55 @@ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual)
    *((char *)To) = '\0';
    *((char *)To) = '\0';
    do
    do
    {
    {
+      if (false)
+	 /* dummy so that the rest can be 'else if's */;
 #ifdef HAVE_ZLIB
 #ifdef HAVE_ZLIB
-      if (d != NULL && d->gz != NULL)
+      else if (d != NULL && d->gz != NULL)
 	 Res = gzread(d->gz,To,Size);
 	 Res = gzread(d->gz,To,Size);
-      else
 #endif
 #endif
 #ifdef HAVE_BZ2
 #ifdef HAVE_BZ2
-      if (d != NULL && d->bz2 != NULL)
+      else if (d != NULL && d->bz2 != NULL)
 	 Res = BZ2_bzread(d->bz2,To,Size);
 	 Res = BZ2_bzread(d->bz2,To,Size);
-      else
 #endif
 #endif
+#ifdef HAVE_LZMA
+      else if (d != NULL && d->lzma != NULL)
+      {
+	 if (d->lzma->eof == true)
+	    break;
+
+	 d->lzma->stream.next_out = (uint8_t *) To;
+	 d->lzma->stream.avail_out = Size;
+	 if (d->lzma->stream.avail_in == 0)
+	 {
+	    d->lzma->stream.next_in = d->lzma->buffer;
+	    d->lzma->stream.avail_in = fread(d->lzma->buffer, 1, sizeof(d->lzma->buffer)/sizeof(d->lzma->buffer[0]), d->lzma->file);
+	 }
+	 d->lzma->err = lzma_code(&d->lzma->stream, LZMA_RUN);
+	 if (d->lzma->err == LZMA_STREAM_END)
+	 {
+	    d->lzma->eof = true;
+	    Res = Size - d->lzma->stream.avail_out;
+	 }
+	 else if (d->lzma->err != LZMA_OK)
+	 {
+	    Res = -1;
+	    errno = 0;
+	 }
+	 else
+	    Res = Size - d->lzma->stream.avail_out;
+      }
+#endif
+      else
          Res = read(iFd,To,Size);
          Res = read(iFd,To,Size);
 
 
       if (Res < 0)
       if (Res < 0)
       {
       {
 	 if (errno == EINTR)
 	 if (errno == EINTR)
 	    continue;
 	    continue;
+	 if (false)
+	    /* dummy so that the rest can be 'else if's */;
 #ifdef HAVE_ZLIB
 #ifdef HAVE_ZLIB
-	 if (d != NULL && d->gz != NULL)
+	 else if (d != NULL && d->gz != NULL)
 	 {
 	 {
 	    int err;
 	    int err;
 	    char const * const errmsg = gzerror(d->gz, &err);
 	    char const * const errmsg = gzerror(d->gz, &err);
@@ -1293,13 +1452,17 @@ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual)
 	 }
 	 }
 #endif
 #endif
 #ifdef HAVE_BZ2
 #ifdef HAVE_BZ2
-	 if (d != NULL && d->bz2 != NULL)
+	 else if (d != NULL && d->bz2 != NULL)
 	 {
 	 {
 	    int err;
 	    int err;
 	    char const * const errmsg = BZ2_bzerror(d->bz2, &err);
 	    char const * const errmsg = BZ2_bzerror(d->bz2, &err);
 	    if (err != BZ_IO_ERROR)
 	    if (err != BZ_IO_ERROR)
 	       return FileFdError("BZ2_bzread: %s (%d: %s)", _("Read error"), err, errmsg);
 	       return FileFdError("BZ2_bzread: %s (%d: %s)", _("Read error"), err, errmsg);
 	 }
 	 }
+#endif
+#ifdef HAVE_LZMA
+	 else if (d != NULL && d->lzma != NULL)
+	    return FileFdError("lzma_read: %s (%d)", _("Read error"), d->lzma->err);
 #endif
 #endif
 	 return FileFdErrno("read",_("Read error"));
 	 return FileFdErrno("read",_("Read error"));
       }
       }
@@ -1364,23 +1527,45 @@ bool FileFd::Write(const void *From,unsigned long long Size)
    errno = 0;
    errno = 0;
    do
    do
    {
    {
+      if (false)
+	 /* dummy so that the rest can be 'else if's */;
 #ifdef HAVE_ZLIB
 #ifdef HAVE_ZLIB
-      if (d != NULL && d->gz != NULL)
-         Res = gzwrite(d->gz,From,Size);
-      else
+      else if (d != NULL && d->gz != NULL)
+	 Res = gzwrite(d->gz,From,Size);
 #endif
 #endif
 #ifdef HAVE_BZ2
 #ifdef HAVE_BZ2
-      if (d != NULL && d->bz2 != NULL)
-         Res = BZ2_bzwrite(d->bz2,(void*)From,Size);
-      else
+      else if (d != NULL && d->bz2 != NULL)
+	 Res = BZ2_bzwrite(d->bz2,(void*)From,Size);
+#endif
+#ifdef HAVE_LZMA
+      else if (d != NULL && d->lzma != NULL)
+      {
+	 d->lzma->stream.next_in = (uint8_t *)From;
+	 d->lzma->stream.avail_in = Size;
+	 d->lzma->stream.next_out = d->lzma->buffer;
+	 d->lzma->stream.avail_out = sizeof(d->lzma->buffer)/sizeof(d->lzma->buffer[0]);
+	 d->lzma->err = lzma_code(&d->lzma->stream, LZMA_RUN);
+	 if (d->lzma->err != LZMA_OK)
+	    return false;
+	 size_t const n = sizeof(d->lzma->buffer)/sizeof(d->lzma->buffer[0]) - d->lzma->stream.avail_out;
+	 size_t const m = (n == 0) ? 0 : fwrite(d->lzma->buffer, 1, n, d->lzma->file);
+	 if (m != n)
+	    Res = -1;
+	 else
+	    Res = Size - d->lzma->stream.avail_in;
+      }
 #endif
 #endif
-         Res = write(iFd,From,Size);
+      else
+	 Res = write(iFd,From,Size);
+
       if (Res < 0 && errno == EINTR)
       if (Res < 0 && errno == EINTR)
 	 continue;
 	 continue;
       if (Res < 0)
       if (Res < 0)
       {
       {
+	 if (false)
+	    /* dummy so that the rest can be 'else if's */;
 #ifdef HAVE_ZLIB
 #ifdef HAVE_ZLIB
-	 if (d != NULL && d->gz != NULL)
+	 else if (d != NULL && d->gz != NULL)
 	 {
 	 {
 	    int err;
 	    int err;
 	    char const * const errmsg = gzerror(d->gz, &err);
 	    char const * const errmsg = gzerror(d->gz, &err);
@@ -1389,18 +1574,22 @@ bool FileFd::Write(const void *From,unsigned long long Size)
 	 }
 	 }
 #endif
 #endif
 #ifdef HAVE_BZ2
 #ifdef HAVE_BZ2
-	 if (d != NULL && d->bz2 != NULL)
+	 else if (d != NULL && d->bz2 != NULL)
 	 {
 	 {
 	    int err;
 	    int err;
 	    char const * const errmsg = BZ2_bzerror(d->bz2, &err);
 	    char const * const errmsg = BZ2_bzerror(d->bz2, &err);
 	    if (err != BZ_IO_ERROR)
 	    if (err != BZ_IO_ERROR)
 	       return FileFdError("BZ2_bzwrite: %s (%d: %s)", _("Write error"), err, errmsg);
 	       return FileFdError("BZ2_bzwrite: %s (%d: %s)", _("Write error"), err, errmsg);
 	 }
 	 }
+#endif
+#ifdef HAVE_LZMA
+	 else if (d != NULL && d->lzma != NULL)
+	    return FileFdErrno("lzma_fwrite", _("Write error"));
 #endif
 #endif
 	 return FileFdErrno("write",_("Write error"));
 	 return FileFdErrno("write",_("Write error"));
       }
       }
       
       
-      From = (char *)From + Res;
+      From = (char const *)From + Res;
       Size -= Res;
       Size -= Res;
       if (d != NULL)
       if (d != NULL)
 	 d->seekpos += Res;
 	 d->seekpos += Res;
@@ -1424,7 +1613,7 @@ bool FileFd::Write(int Fd, const void *From, unsigned long long Size)
       if (Res < 0)
       if (Res < 0)
 	 return _error->Errno("write",_("Write error"));
 	 return _error->Errno("write",_("Write error"));
 
 
-      From = (char *)From + Res;
+      From = (char const *)From + Res;
       Size -= Res;
       Size -= Res;
    }
    }
    while (Res > 0 && Size > 0);
    while (Res > 0 && Size > 0);
@@ -1440,11 +1629,7 @@ bool FileFd::Write(int Fd, const void *From, unsigned long long Size)
 /* */
 /* */
 bool FileFd::Seek(unsigned long long To)
 bool FileFd::Seek(unsigned long long To)
 {
 {
-   if (d != NULL && (d->pipe == true
-#ifdef HAVE_BZ2
-			|| d->bz2 != NULL
-#endif
-	))
+   if (d != NULL && (d->pipe == true || d->InternalStream() == true))
    {
    {
       // Our poor man seeking in pipes is costly, so try to avoid it
       // Our poor man seeking in pipes is costly, so try to avoid it
       unsigned long long seekpos = Tell();
       unsigned long long seekpos = Tell();
@@ -1455,13 +1640,7 @@ bool FileFd::Seek(unsigned long long To)
 
 
       if ((d->openmode & ReadOnly) != ReadOnly)
       if ((d->openmode & ReadOnly) != ReadOnly)
 	 return FileFdError("Reopen is only implemented for read-only files!");
 	 return FileFdError("Reopen is only implemented for read-only files!");
-#ifdef HAVE_BZ2
-     if (d->bz2 != NULL) 
-     {
-	BZ2_bzclose(d->bz2);
-	d->bz2 = NULL;
-     }
-#endif
+      d->InternalClose(FileName);
       if (iFd != -1)
       if (iFd != -1)
 	 close(iFd);
 	 close(iFd);
       iFd = -1;
       iFd = -1;
@@ -1507,11 +1686,7 @@ bool FileFd::Seek(unsigned long long To)
 /* */
 /* */
 bool FileFd::Skip(unsigned long long Over)
 bool FileFd::Skip(unsigned long long Over)
 {
 {
-   if (d != NULL && (d->pipe == true
-#ifdef HAVE_BZ2
-			|| d->bz2 != NULL
-#endif
-	))
+   if (d != NULL && (d->pipe == true || d->InternalStream() == true))
    {
    {
       d->seekpos += Over;
       d->seekpos += Over;
       char buffer[1024];
       char buffer[1024];
@@ -1548,8 +1723,12 @@ bool FileFd::Truncate(unsigned long long To)
    // truncating /dev/null is always successful - as we get an error otherwise
    // truncating /dev/null is always successful - as we get an error otherwise
    if (To == 0 && FileName == "/dev/null")
    if (To == 0 && FileName == "/dev/null")
       return true;
       return true;
-#if defined HAVE_ZLIB || defined HAVE_BZ2
-   if (d != NULL && (d->gz != NULL || d->bz2 != NULL))
+#if defined HAVE_ZLIB || defined HAVE_BZ2 || defined HAVE_LZMA
+   if (d != NULL && (d->InternalStream() == true
+#ifdef HAVE_ZLIB
+	    || d->gz != NULL
+#endif
+	    ))
       return FileFdError("Truncating compressed files is not implemented (%s)", FileName.c_str());
       return FileFdError("Truncating compressed files is not implemented (%s)", FileName.c_str());
 #endif
 #endif
    if (ftruncate(iFd,To) != 0)
    if (ftruncate(iFd,To) != 0)
@@ -1567,11 +1746,7 @@ unsigned long long FileFd::Tell()
    // seeking around, but not all users of FileFd use always Seek() and co
    // seeking around, but not all users of FileFd use always Seek() and co
    // so d->seekpos isn't always true and we can just use it as a hint if
    // so d->seekpos isn't always true and we can just use it as a hint if
    // we have nothing else, but not always as an authority…
    // we have nothing else, but not always as an authority…
-   if (d != NULL && (d->pipe == true
-#ifdef HAVE_BZ2
-			|| d->bz2 != NULL
-#endif
-	))
+   if (d != NULL && (d->pipe == true || d->InternalStream() == true))
       return d->seekpos;
       return d->seekpos;
 
 
    off_t Res;
    off_t Res;
@@ -1646,11 +1821,7 @@ unsigned long long FileFd::Size()
 
 
    // for compressor pipes st_size is undefined and at 'best' zero,
    // for compressor pipes st_size is undefined and at 'best' zero,
    // so we 'read' the content and 'seek' back - see there
    // so we 'read' the content and 'seek' back - see there
-   if (d != NULL && (d->pipe == true
-#ifdef HAVE_BZ2
-			|| (d->bz2 && size > 0)
-#endif
-	))
+   if (d != NULL && (d->pipe == true || (d->InternalStream() == true && size > 0)))
    {
    {
       unsigned long long const oldSeek = Tell();
       unsigned long long const oldSeek = Tell();
       char ignore[1000];
       char ignore[1000];
@@ -1793,7 +1964,13 @@ bool FileFd::FileFdError(const char *Description,...) {
 }
 }
 									/*}}}*/
 									/*}}}*/
 
 
-gzFile FileFd::gzFd() { return (gzFile) d->gz; }
+APT_DEPRECATED gzFile FileFd::gzFd() {
+#ifdef HAVE_ZLIB
+   return d->gz;
+#else
+   return NULL;
+#endif
+}
 
 
 
 
 // Glob - wrapper around "glob()"                                      /*{{{*/
 // Glob - wrapper around "glob()"                                      /*{{{*/

+ 6 - 5
apt-pkg/contrib/fileutl.h

@@ -27,6 +27,7 @@
 #include <string>
 #include <string>
 #include <vector>
 #include <vector>
 #include <set>
 #include <set>
+#include <time.h>
 
 
 #include <zlib.h>
 #include <zlib.h>
 
 
@@ -94,7 +95,7 @@ class FileFd
       And as the auto-conversation converts a 'unsigned long *' to a 'bool'
       And as the auto-conversation converts a 'unsigned long *' to a 'bool'
       instead of 'unsigned long long *' we need to provide this explicitely -
       instead of 'unsigned long long *' we need to provide this explicitely -
       otherwise applications magically start to fail… */
       otherwise applications magically start to fail… */
-   __deprecated bool Read(void *To,unsigned long long Size,unsigned long *Actual)
+   bool Read(void *To,unsigned long long Size,unsigned long *Actual) APT_DEPRECATED
    {
    {
 	unsigned long long R;
 	unsigned long long R;
 	bool const T = Read(To, Size, &R);
 	bool const T = Read(To, Size, &R);
@@ -118,7 +119,7 @@ class FileFd
    // Simple manipulators
    // Simple manipulators
    inline int Fd() {return iFd;};
    inline int Fd() {return iFd;};
    inline void Fd(int fd) { OpenDescriptor(fd, ReadWrite);};
    inline void Fd(int fd) { OpenDescriptor(fd, ReadWrite);};
-   __deprecated gzFile gzFd();
+   gzFile gzFd() APT_DEPRECATED APT_PURE;
 
 
    inline bool IsOpen() {return iFd >= 0;};
    inline bool IsOpen() {return iFd >= 0;};
    inline bool Failed() {return (Flags & Fail) == Fail;};
    inline bool Failed() {return (Flags & Fail) == Fail;};
@@ -152,8 +153,8 @@ class FileFd
    bool OpenInternDescriptor(unsigned int const Mode, APT::Configuration::Compressor const &compressor);
    bool OpenInternDescriptor(unsigned int const Mode, APT::Configuration::Compressor const &compressor);
 
 
    // private helpers to set Fail flag and call _error->Error
    // private helpers to set Fail flag and call _error->Error
-   bool FileFdErrno(const char* Function, const char* Description,...) __like_printf(3) __cold;
-   bool FileFdError(const char* Description,...) __like_printf(2) __cold;
+   bool FileFdErrno(const char* Function, const char* Description,...) APT_PRINTF(3) APT_COLD;
+   bool FileFdError(const char* Description,...) APT_PRINTF(2) APT_COLD;
 };
 };
 
 
 bool RunScripts(const char *Cnf);
 bool RunScripts(const char *Cnf);
@@ -161,7 +162,7 @@ bool CopyFile(FileFd &From,FileFd &To);
 int GetLock(std::string File,bool Errors = true);
 int GetLock(std::string File,bool Errors = true);
 bool FileExists(std::string File);
 bool FileExists(std::string File);
 bool RealFileExists(std::string File);
 bool RealFileExists(std::string File);
-bool DirectoryExists(std::string const &Path) __attrib_const;
+bool DirectoryExists(std::string const &Path) APT_CONST;
 bool CreateDirectory(std::string const &Parent, std::string const &Path);
 bool CreateDirectory(std::string const &Parent, std::string const &Path);
 time_t GetModificationTime(std::string const &Path);
 time_t GetModificationTime(std::string const &Path);
 bool Rename(std::string From, std::string To);
 bool Rename(std::string From, std::string To);

+ 10 - 8
apt-pkg/contrib/gpgv.cc

@@ -2,21 +2,23 @@
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
 #include<config.h>
 #include<config.h>
 
 
+#include<apt-pkg/configuration.h>
+#include<apt-pkg/error.h>
+#include<apt-pkg/strutl.h>
+#include<apt-pkg/fileutl.h>
+#include<apt-pkg/gpgv.h>
+
 #include <errno.h>
 #include <errno.h>
 #include <stdio.h>
 #include <stdio.h>
 #include <string.h>
 #include <string.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <fcntl.h>
 #include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
 #include <sys/wait.h>
 #include <sys/wait.h>
 #include <unistd.h>
 #include <unistd.h>
-
-#include<apt-pkg/configuration.h>
-#include<apt-pkg/error.h>
-#include<apt-pkg/strutl.h>
-#include<apt-pkg/fileutl.h>
-#include<apt-pkg/gpgv.h>
+#include <stddef.h>
+#include <iostream>
+#include <string>
+#include <vector>
 
 
 #include <apti18n.h>
 #include <apti18n.h>
 									/*}}}*/
 									/*}}}*/

+ 8 - 10
apt-pkg/contrib/gpgv.h

@@ -9,17 +9,17 @@
 #ifndef CONTRIB_GPGV_H
 #ifndef CONTRIB_GPGV_H
 #define CONTRIB_GPGV_H
 #define CONTRIB_GPGV_H
 
 
+#include <apt-pkg/macros.h>
+
 #include <string>
 #include <string>
 #include <vector>
 #include <vector>
 
 
+#ifndef APT_10_CLEANER_HEADERS
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
-
-#if __GNUC__ >= 4
-	#define APT_noreturn	__attribute__ ((noreturn))
-#else
-	#define APT_noreturn	/* no support */
 #endif
 #endif
 
 
+class FileFd;
+
 /** \brief generates and run the command to verify a file with gpgv
 /** \brief generates and run the command to verify a file with gpgv
  *
  *
  * If File and FileSig specify the same file it is assumed that we
  * If File and FileSig specify the same file it is assumed that we
@@ -40,14 +40,12 @@
  * @param FileSig is the signature (detached or clear-signed)
  * @param FileSig is the signature (detached or clear-signed)
  */
  */
 void ExecGPGV(std::string const &File, std::string const &FileSig,
 void ExecGPGV(std::string const &File, std::string const &FileSig,
-      int const &statusfd, int fd[2]) APT_noreturn;
-inline void ExecGPGV(std::string const &File, std::string const &FileSig,
+      int const &statusfd, int fd[2]) APT_NORETURN;
+inline APT_NORETURN void ExecGPGV(std::string const &File, std::string const &FileSig,
       int const &statusfd = -1) {
       int const &statusfd = -1) {
    int fd[2];
    int fd[2];
    ExecGPGV(File, FileSig, statusfd, fd);
    ExecGPGV(File, FileSig, statusfd, fd);
-};
-
-#undef APT_noreturn
+}
 
 
 /** \brief Split an inline signature into message and signature
 /** \brief Split an inline signature into message and signature
  *
  *

+ 6 - 2
apt-pkg/contrib/hashes.cc

@@ -16,8 +16,12 @@
 #include <apt-pkg/hashes.h>
 #include <apt-pkg/hashes.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
-#include <apt-pkg/macros.h>
+#include <apt-pkg/md5.h>
+#include <apt-pkg/sha1.h>
+#include <apt-pkg/sha2.h>
 
 
+#include <stddef.h>
+#include <algorithm>
 #include <unistd.h>
 #include <unistd.h>
 #include <string>
 #include <string>
 #include <iostream>
 #include <iostream>
@@ -112,7 +116,7 @@ const char** HashString::SupportedHashes()
    return _SupportedHashes;
    return _SupportedHashes;
 }
 }
 
 
-bool HashString::empty() const
+APT_PURE bool HashString::empty() const
 {
 {
    return (Type.empty() || Hash.empty());
    return (Type.empty() || Hash.empty());
 }
 }

+ 11 - 6
apt-pkg/contrib/hashes.h

@@ -17,17 +17,22 @@
 #include <apt-pkg/md5.h>
 #include <apt-pkg/md5.h>
 #include <apt-pkg/sha1.h>
 #include <apt-pkg/sha1.h>
 #include <apt-pkg/sha2.h>
 #include <apt-pkg/sha2.h>
-#include <apt-pkg/fileutl.h>
 
 
-#include <algorithm>
-#include <vector>
 #include <cstring>
 #include <cstring>
-
+#include <string>
 
 
 #ifndef APT_8_CLEANER_HEADERS
 #ifndef APT_8_CLEANER_HEADERS
 using std::min;
 using std::min;
 using std::vector;
 using std::vector;
 #endif
 #endif
+#ifndef APT_10_CLEANER_HEADERS
+#include <apt-pkg/fileutl.h>
+#include <algorithm>
+#include <vector>
+#endif
+
+
+class FileFd;
 
 
 // helper class that contains hash function name
 // helper class that contains hash function name
 // and hash
 // and hash
@@ -61,7 +66,7 @@ class HashString
    bool empty() const;
    bool empty() const;
 
 
    // return the list of hashes we support
    // return the list of hashes we support
-   static const char** SupportedHashes();
+   static APT_CONST const char** SupportedHashes();
 };
 };
 
 
 class Hashes
 class Hashes
@@ -77,7 +82,7 @@ class Hashes
    {
    {
       return MD5.Add(Data,Size) && SHA1.Add(Data,Size) && SHA256.Add(Data,Size) && SHA512.Add(Data,Size);
       return MD5.Add(Data,Size) && SHA1.Add(Data,Size) && SHA256.Add(Data,Size) && SHA512.Add(Data,Size);
    };
    };
-   inline bool Add(const char *Data) {return Add((unsigned char *)Data,strlen(Data));};
+   inline bool Add(const char *Data) {return Add((unsigned char const *)Data,strlen(Data));};
    inline bool AddFD(int const Fd,unsigned long long Size = 0)
    inline bool AddFD(int const Fd,unsigned long long Size = 0)
    { return AddFD(Fd, Size, true, true, true, true); };
    { return AddFD(Fd, Size, true, true, true, true); };
    bool AddFD(int const Fd, unsigned long long Size, bool const addMD5,
    bool AddFD(int const Fd, unsigned long long Size, bool const addMD5,

+ 3 - 0
apt-pkg/contrib/hashsum.cc

@@ -1,6 +1,9 @@
 // Cryptographic API Base
 // Cryptographic API Base
 #include <config.h>
 #include <config.h>
 
 
+#include <apt-pkg/fileutl.h>
+
+#include <algorithm>
 #include <unistd.h>
 #include <unistd.h>
 #include "hashsum_template.h"
 #include "hashsum_template.h"
 
 

+ 28 - 24
apt-pkg/contrib/hashsum_template.h

@@ -10,36 +10,40 @@
 #ifndef APTPKG_HASHSUM_TEMPLATE_H
 #ifndef APTPKG_HASHSUM_TEMPLATE_H
 #define APTPKG_HASHSUM_TEMPLATE_H
 #define APTPKG_HASHSUM_TEMPLATE_H
 
 
-#include <apt-pkg/fileutl.h>
 
 
 #include <string>
 #include <string>
 #include <cstring>
 #include <cstring>
-#include <algorithm>
-#include <stdint.h>
 
 
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
 
 
+#ifndef APT_10_CLEANER_HEADERS
+#include <apt-pkg/fileutl.h>
+#include <algorithm>
+#include <stdint.h>
+#endif
 #ifndef APT_8_CLEANER_HEADERS
 #ifndef APT_8_CLEANER_HEADERS
 using std::string;
 using std::string;
 using std::min;
 using std::min;
 #endif
 #endif
 
 
+class FileFd;
+
 template<int N>
 template<int N>
 class HashSumValue
 class HashSumValue
 {
 {
    unsigned char Sum[N/8];
    unsigned char Sum[N/8];
-   
+
    public:
    public:
 
 
    // Accessors
    // Accessors
    bool operator ==(const HashSumValue &rhs) const
    bool operator ==(const HashSumValue &rhs) const
    {
    {
       return memcmp(Sum,rhs.Sum,sizeof(Sum)) == 0;
       return memcmp(Sum,rhs.Sum,sizeof(Sum)) == 0;
-   };
+   }
    bool operator !=(const HashSumValue &rhs) const
    bool operator !=(const HashSumValue &rhs) const
    {
    {
       return memcmp(Sum,rhs.Sum,sizeof(Sum)) != 0;
       return memcmp(Sum,rhs.Sum,sizeof(Sum)) != 0;
-   };
+   }
 
 
    std::string Value() const
    std::string Value() const
    {
    {
@@ -49,7 +53,7 @@ class HashSumValue
       };
       };
       char Result[((N/8)*2)+1];
       char Result[((N/8)*2)+1];
       Result[(N/8)*2] = 0;
       Result[(N/8)*2] = 0;
-      
+
       // Convert each char into two letters
       // Convert each char into two letters
       int J = 0;
       int J = 0;
       int I = 0;
       int I = 0;
@@ -59,31 +63,31 @@ class HashSumValue
          Result[I + 1] = Conv[Sum[J] & 0xF];
          Result[I + 1] = Conv[Sum[J] & 0xF];
       }
       }
       return std::string(Result);
       return std::string(Result);
-   };
-   
+   }
+
    inline void Value(unsigned char S[N/8])
    inline void Value(unsigned char S[N/8])
    {
    {
-      for (int I = 0; I != sizeof(Sum); I++) 
+      for (int I = 0; I != sizeof(Sum); ++I)
          S[I] = Sum[I];
          S[I] = Sum[I];
-   };
+   }
 
 
-   inline operator std::string() const 
+   inline operator std::string() const
    {
    {
       return Value();
       return Value();
-   };
+   }
 
 
-   bool Set(std::string Str) 
+   bool Set(std::string Str)
    {
    {
       return Hex2Num(Str,Sum,sizeof(Sum));
       return Hex2Num(Str,Sum,sizeof(Sum));
-   };
+   }
 
 
-   inline void Set(unsigned char S[N/8]) 
+   inline void Set(unsigned char S[N/8])
    {
    {
-      for (int I = 0; I != sizeof(Sum); I++) 
+      for (int I = 0; I != sizeof(Sum); ++I)
          Sum[I] = S[I];
          Sum[I] = S[I];
-   };
+   }
 
 
-   HashSumValue(std::string Str) 
+   HashSumValue(std::string Str)
    {
    {
          memset(Sum,0,sizeof(Sum));
          memset(Sum,0,sizeof(Sum));
          Set(Str);
          Set(Str);
@@ -99,17 +103,17 @@ class SummationImplementation
    public:
    public:
    virtual bool Add(const unsigned char *inbuf, unsigned long long inlen) = 0;
    virtual bool Add(const unsigned char *inbuf, unsigned long long inlen) = 0;
    inline bool Add(const char *inbuf, unsigned long long const inlen)
    inline bool Add(const char *inbuf, unsigned long long const inlen)
-   { return Add((unsigned char *)inbuf, inlen); };
+   { return Add((const unsigned char *)inbuf, inlen); }
 
 
    inline bool Add(const unsigned char *Data)
    inline bool Add(const unsigned char *Data)
-   { return Add(Data, strlen((const char *)Data)); };
+   { return Add(Data, strlen((const char *)Data)); }
    inline bool Add(const char *Data)
    inline bool Add(const char *Data)
-   { return Add((const unsigned char *)Data, strlen((const char *)Data)); };
+   { return Add((const unsigned char *)Data, strlen(Data)); }
 
 
    inline bool Add(const unsigned char *Beg, const unsigned char *End)
    inline bool Add(const unsigned char *Beg, const unsigned char *End)
-   { return Add(Beg, End - Beg); };
+   { return Add(Beg, End - Beg); }
    inline bool Add(const char *Beg, const char *End)
    inline bool Add(const char *Beg, const char *End)
-   { return Add((const unsigned char *)Beg, End - Beg); };
+   { return Add((const unsigned char *)Beg, End - Beg); }
 
 
    bool AddFD(int Fd, unsigned long long Size = 0);
    bool AddFD(int Fd, unsigned long long Size = 0);
    bool AddFD(FileFd &Fd, unsigned long long Size = 0);
    bool AddFD(FileFd &Fd, unsigned long long Size = 0);

+ 67 - 17
apt-pkg/contrib/macros.h

@@ -54,37 +54,87 @@
 #define CLRFLAG(v,f)	((v) &=~FLAG(f))
 #define CLRFLAG(v,f)	((v) &=~FLAG(f))
 #define	CHKFLAG(v,f)	((v) &  FLAG(f) ? true : false)
 #define	CHKFLAG(v,f)	((v) &  FLAG(f) ? true : false)
 
 
-// some nice optional GNUC features
-#if __GNUC__ >= 3
-	#define __must_check	__attribute__ ((warn_unused_result))
-	#define __deprecated	__attribute__ ((deprecated))
-	#define __attrib_const	__attribute__ ((__const__))
-	/* likely() and unlikely() can be used to mark boolean expressions
-	   as (not) likely true which will help the compiler to optimise */
+#ifdef __GNUC__
+#define APT_GCC_VERSION (__GNUC__ << 8 | __GNUC_MINOR__)
+#else
+#define APT_GCC_VERSION 0
+#endif
+
+/* likely() and unlikely() can be used to mark boolean expressions
+   as (not) likely true which will help the compiler to optimise */
+#if APT_GCC_VERSION >= 0x0300
 	#define likely(x)	__builtin_expect (!!(x), 1)
 	#define likely(x)	__builtin_expect (!!(x), 1)
 	#define unlikely(x)	__builtin_expect (!!(x), 0)
 	#define unlikely(x)	__builtin_expect (!!(x), 0)
 #else
 #else
-	#define __must_check	/* no warn_unused_result */
-	#define __deprecated	/* no deprecated */
-	#define __attrib_const	/* no const attribute */
 	#define likely(x)	(x)
 	#define likely(x)	(x)
 	#define unlikely(x)	(x)
 	#define unlikely(x)	(x)
 #endif
 #endif
 
 
+#if APT_GCC_VERSION >= 0x0300
+	#define APT_DEPRECATED	__attribute__ ((deprecated))
+	#define APT_CONST	__attribute__((const))
+	#define APT_PURE	__attribute__((pure))
+	#define APT_NORETURN	__attribute__((noreturn))
+	#define APT_PRINTF(n)	__attribute__((format(printf, n, n + 1)))
+#else
+	#define APT_DEPRECATED
+	#define APT_CONST
+	#define APT_PURE
+	#define APT_NORETURN
+	#define APT_PRINTF(n)
+#endif
+
+#if APT_GCC_VERSION > 0x0302
+	#define APT_NONNULL(...)	__attribute__((nonnull(__VA_ARGS__)))
+	#define APT_MUSTCHECK		__attribute__((warn_unused_result))
+#else
+	#define APT_NONNULL(...)
+	#define APT_REQRET
+#endif
+
+#if APT_GCC_VERSION >= 0x0400
+	#define APT_SENTINEL	__attribute__((sentinel))
+#else
+	#define APT_SENTINEL
+#endif
+
 // cold functions are unlikely() to be called
 // cold functions are unlikely() to be called
-#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4
-	#define __cold	__attribute__ ((__cold__))
-	#define __hot	__attribute__ ((__hot__))
+#if APT_GCC_VERSION >= 0x0403
+	#define APT_COLD	__attribute__ ((__cold__))
+	#define APT_HOT		__attribute__ ((__hot__))
 #else
 #else
-	#define __cold	/* no cold marker */
-	#define __hot	/* no hot marker */
+	#define APT_COLD
+	#define APT_HOT
 #endif
 #endif
 
 
-#ifdef __GNUG__
-// Methods have a hidden this parameter that is visible to this attribute
+#ifndef APT_10_CLEANER_HEADERS
+#if APT_GCC_VERSION >= 0x0300
+	#define __must_check	__attribute__ ((warn_unused_result))
+	#define __deprecated	__attribute__ ((deprecated))
+	#define __attrib_const	__attribute__ ((__const__))
 	#define __like_printf(n)	__attribute__((format(printf, n, n + 1)))
 	#define __like_printf(n)	__attribute__((format(printf, n, n + 1)))
 #else
 #else
+	#define __must_check	/* no warn_unused_result */
+	#define __deprecated	/* no deprecated */
+	#define __attrib_const	/* no const attribute */
 	#define __like_printf(n)	/* no like-printf */
 	#define __like_printf(n)	/* no like-printf */
 #endif
 #endif
+#if APT_GCC_VERSION >= 0x0403
+	#define __cold	__attribute__ ((__cold__))
+	#define __hot	__attribute__ ((__hot__))
+#else
+	#define __cold	/* no cold marker */
+	#define __hot	/* no hot marker */
+#endif
+#endif
+
+// These lines are extracted by the makefiles and the buildsystem
+// Increasing MAJOR or MINOR results in the need of recompiling all
+// reverse-dependencies of libapt-pkg against the new SONAME.
+// Non-ABI-Breaks should only increase RELEASE number.
+// See also buildlib/libversion.mak
+#define APT_PKG_MAJOR 4
+#define APT_PKG_MINOR 12
+#define APT_PKG_RELEASE 0
 
 
 #endif
 #endif

+ 1 - 5
apt-pkg/contrib/md5.cc

@@ -38,13 +38,9 @@
 #include <config.h>
 #include <config.h>
 
 
 #include <apt-pkg/md5.h>
 #include <apt-pkg/md5.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/macros.h>
 
 
+#include <stdint.h>
 #include <string.h>
 #include <string.h>
-#include <unistd.h>
-#include <netinet/in.h>                          // For htonl
-#include <inttypes.h>
 									/*}}}*/
 									/*}}}*/
 
 
 // byteSwap - Swap bytes in a buffer					/*{{{*/
 // byteSwap - Swap bytes in a buffer					/*{{{*/

+ 5 - 4
apt-pkg/contrib/md5.h

@@ -23,14 +23,15 @@
 #ifndef APTPKG_MD5_H
 #ifndef APTPKG_MD5_H
 #define APTPKG_MD5_H
 #define APTPKG_MD5_H
 
 
-
-#include <string>
-#include <cstring>
-#include <algorithm>
 #include <stdint.h>
 #include <stdint.h>
 
 
 #include "hashsum_template.h"
 #include "hashsum_template.h"
 
 
+#ifndef APT_10_CLEANER_HEADERS
+#include <string>
+#include <cstring>
+#include <algorithm>
+#endif
 #ifndef APT_8_CLEANER_HEADERS
 #ifndef APT_8_CLEANER_HEADERS
 using std::string;
 using std::string;
 using std::min;
 using std::min;

+ 3 - 3
apt-pkg/contrib/mmap.cc

@@ -22,11 +22,11 @@
 #include <apt-pkg/mmap.h>
 #include <apt-pkg/mmap.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
+#include <apt-pkg/macros.h>
 
 
+#include <string>
 #include <sys/mman.h>
 #include <sys/mman.h>
-#include <sys/stat.h>
 #include <unistd.h>
 #include <unistd.h>
-#include <fcntl.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <errno.h>
 #include <cstring>
 #include <cstring>
@@ -198,7 +198,7 @@ bool MMap::Sync(unsigned long Start,unsigned long Stop)
       {
       {
 #ifdef _POSIX_SYNCHRONIZED_IO
 #ifdef _POSIX_SYNCHRONIZED_IO
 	 unsigned long long const PSize = sysconf(_SC_PAGESIZE);
 	 unsigned long long const PSize = sysconf(_SC_PAGESIZE);
-	 if (msync((char *)Base+(unsigned long long)(Start/PSize)*PSize,Stop - Start,MS_SYNC) < 0)
+	 if (msync((char *)Base+(Start/PSize)*PSize, Stop - Start, MS_SYNC) < 0)
 	    return _error->Errno("msync", _("Unable to synchronize mmap"));
 	    return _error->Errno("msync", _("Unable to synchronize mmap"));
 #endif
 #endif
       }
       }

+ 2 - 3
apt-pkg/contrib/netrc.cc

@@ -15,14 +15,13 @@
 
 
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
-#include <apt-pkg/error.h>
-#include <apt-pkg/fileutl.h>
 
 
 #include <iostream>
 #include <iostream>
 #include <stdio.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>
 #include <unistd.h>
 #include <unistd.h>
+#include <stddef.h>
 #include <pwd.h>
 #include <pwd.h>
 
 
 #include "netrc.h"
 #include "netrc.h"
@@ -198,7 +197,7 @@ void maybe_add_auth (URI &Uri, string NetRCFile)
       // if host did not work, try Host+Path next, this will trigger
       // if host did not work, try Host+Path next, this will trigger
       // a lookup uri.startswith(host) in the netrc file parser (because
       // a lookup uri.startswith(host) in the netrc file parser (because
       // of the "/"
       // of the "/"
-      char *hostpath = strdup(string(Uri.Host+Uri.Path).c_str());
+      char *hostpath = strdup((Uri.Host + Uri.Path).c_str());
       if (hostpath && parsenetrc_string(hostpath, login, password, netrcfile) == 0)
       if (hostpath && parsenetrc_string(hostpath, login, password, netrcfile) == 0)
       {
       {
 	 if (_config->FindB("Debug::Acquire::netrc", false) == true)
 	 if (_config->FindB("Debug::Acquire::netrc", false) == true)

+ 4 - 2
apt-pkg/contrib/netrc.h

@@ -16,6 +16,8 @@
 
 
 #include <string>
 #include <string>
 
 
+#include <apt-pkg/macros.h>
+
 #ifndef APT_8_CLEANER_HEADERS
 #ifndef APT_8_CLEANER_HEADERS
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
 #endif
 #endif
@@ -25,9 +27,9 @@
 
 
 class URI;
 class URI;
 
 
-// kill this export on the next ABI break - strongly doubt its in use anyway
+// FIXME: kill this export on the next ABI break - strongly doubt its in use anyway
 // outside of the apt itself, its really a internal interface
 // outside of the apt itself, its really a internal interface
-__deprecated int parsenetrc (char *host, char *login, char *password, char *filename);
+APT_DEPRECATED int parsenetrc (char *host, char *login, char *password, char *filename);
 
 
 void maybe_add_auth (URI &Uri, std::string NetRCFile);
 void maybe_add_auth (URI &Uri, std::string NetRCFile);
 #endif
 #endif

+ 8 - 6
apt-pkg/contrib/progress.cc

@@ -14,6 +14,8 @@
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
 
 
+#include <sys/time.h>
+#include <string>
 #include <iostream>
 #include <iostream>
 #include <stdio.h>
 #include <stdio.h>
 #include <cstring>
 #include <cstring>
@@ -125,14 +127,14 @@ bool OpProgress::CheckChange(float Interval)
 // OpTextProgress::OpTextProgress - Constructor				/*{{{*/
 // OpTextProgress::OpTextProgress - Constructor				/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-OpTextProgress::OpTextProgress(Configuration &Config) : 
-                               NoUpdate(false), NoDisplay(false), LastLen(0) 
+OpTextProgress::OpTextProgress(Configuration &Config) :
+                               NoUpdate(false), NoDisplay(false), LastLen(0)
 {
 {
    if (Config.FindI("quiet",0) >= 1 || Config.FindB("quiet::NoUpdate", false) == true)
    if (Config.FindI("quiet",0) >= 1 || Config.FindB("quiet::NoUpdate", false) == true)
       NoUpdate = true;
       NoUpdate = true;
    if (Config.FindI("quiet",0) >= 2)
    if (Config.FindI("quiet",0) >= 2)
       NoDisplay = true;
       NoDisplay = true;
-};
+}
 									/*}}}*/
 									/*}}}*/
 // OpTextProgress::Done - Clean up the display				/*{{{*/
 // OpTextProgress::Done - Clean up the display				/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
@@ -150,12 +152,12 @@ void OpTextProgress::Done()
       cout << endl;
       cout << endl;
       OldOp = string();
       OldOp = string();
    }
    }
-   
+
    if (NoUpdate == true && NoDisplay == false && OldOp.empty() == false)
    if (NoUpdate == true && NoDisplay == false && OldOp.empty() == false)
    {
    {
       OldOp = string();
       OldOp = string();
-      cout << endl;   
-   }   
+      cout << endl;
+   }
 }
 }
 									/*}}}*/
 									/*}}}*/
 // OpTextProgress::Update - Simple text spinner				/*{{{*/
 // OpTextProgress::Update - Simple text spinner				/*{{{*/

+ 1 - 4
apt-pkg/contrib/sha1.cc

@@ -32,12 +32,9 @@
 #include <config.h>
 #include <config.h>
 
 
 #include <apt-pkg/sha1.h>
 #include <apt-pkg/sha1.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/macros.h>
 
 
+#include <stdint.h>
 #include <string.h>
 #include <string.h>
-#include <unistd.h>
-#include <inttypes.h>
 									/*}}}*/
 									/*}}}*/
 
 
 // SHA1Transform - Alters an existing SHA-1 hash			/*{{{*/
 // SHA1Transform - Alters an existing SHA-1 hash			/*{{{*/

+ 4 - 3
apt-pkg/contrib/sha1.h

@@ -14,12 +14,13 @@
 #ifndef APTPKG_SHA1_H
 #ifndef APTPKG_SHA1_H
 #define APTPKG_SHA1_H
 #define APTPKG_SHA1_H
 
 
+#include "hashsum_template.h"
+
+#ifndef APT_10_CLEANER_HEADERS
 #include <string>
 #include <string>
 #include <cstring>
 #include <cstring>
 #include <algorithm>
 #include <algorithm>
-
-#include "hashsum_template.h"
-
+#endif
 #ifndef APT_8_CLEANER_HEADERS
 #ifndef APT_8_CLEANER_HEADERS
 using std::string;
 using std::string;
 using std::min;
 using std::min;

+ 7 - 3
apt-pkg/contrib/sha2.h

@@ -14,14 +14,18 @@
 #ifndef APTPKG_SHA2_H
 #ifndef APTPKG_SHA2_H
 #define APTPKG_SHA2_H
 #define APTPKG_SHA2_H
 
 
-#include <string>
 #include <cstring>
 #include <cstring>
-#include <algorithm>
-#include <stdint.h>
 
 
 #include "sha2_internal.h"
 #include "sha2_internal.h"
 #include "hashsum_template.h"
 #include "hashsum_template.h"
 
 
+#ifndef APT_10_CLEANER_HEADERS
+#include <string>
+#include <algorithm>
+#include <stdint.h>
+#endif
+
+
 typedef HashSumValue<512> SHA512SumValue;
 typedef HashSumValue<512> SHA512SumValue;
 typedef HashSumValue<256> SHA256SumValue;
 typedef HashSumValue<256> SHA256SumValue;
 
 

+ 1 - 0
apt-pkg/contrib/sha2_internal.cc

@@ -33,6 +33,7 @@
  */
  */
 #include <config.h>
 #include <config.h>
 
 
+#include <endian.h>
 #include <string.h>	/* memcpy()/memset() or bcopy()/bzero() */
 #include <string.h>	/* memcpy()/memset() or bcopy()/bzero() */
 #include <assert.h>	/* assert() */
 #include <assert.h>	/* assert() */
 #include "sha2_internal.h"
 #include "sha2_internal.h"

+ 1 - 0
apt-pkg/contrib/sha2_internal.h

@@ -44,6 +44,7 @@
 
 
 #ifdef SHA2_USE_INTTYPES_H
 #ifdef SHA2_USE_INTTYPES_H
 
 
+#include <stddef.h>
 #include <inttypes.h>
 #include <inttypes.h>
 
 
 #endif /* SHA2_USE_INTTYPES_H */
 #endif /* SHA2_USE_INTTYPES_H */

+ 12 - 5
apt-pkg/contrib/strutl.cc

@@ -21,6 +21,11 @@
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 
 
+#include <stddef.h>
+#include <stdlib.h>
+#include <time.h>
+#include <string>
+#include <vector>
 #include <ctype.h>
 #include <ctype.h>
 #include <string.h>
 #include <string.h>
 #include <sstream>
 #include <sstream>
@@ -33,9 +38,9 @@
 #include <iconv.h>
 #include <iconv.h>
 
 
 #include <apti18n.h>
 #include <apti18n.h>
-
-using namespace std;
 									/*}}}*/
 									/*}}}*/
+using namespace std;
+
 // Strip - Remove white space from the front and back of a string       /*{{{*/
 // Strip - Remove white space from the front and back of a string       /*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 namespace APT {
 namespace APT {
@@ -153,7 +158,7 @@ char *_strrstrip(char *String)
    End++;
    End++;
    *End = 0;
    *End = 0;
    return String;
    return String;
-};
+}
 									/*}}}*/
 									/*}}}*/
 // strtabexpand - Converts tabs into 8 spaces				/*{{{*/
 // strtabexpand - Converts tabs into 8 spaces				/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
@@ -1130,9 +1135,11 @@ bool TokSplitString(char Tok,char *Input,char **List,
    also, but the advantage is that we have an iteratable vector */
    also, but the advantage is that we have an iteratable vector */
 vector<string> VectorizeString(string const &haystack, char const &split)
 vector<string> VectorizeString(string const &haystack, char const &split)
 {
 {
+   vector<string> exploded;
+   if (haystack.empty() == true)
+      return exploded;
    string::const_iterator start = haystack.begin();
    string::const_iterator start = haystack.begin();
    string::const_iterator end = start;
    string::const_iterator end = start;
-   vector<string> exploded;
    do {
    do {
       for (; end != haystack.end() && *end != split; ++end);
       for (; end != haystack.end() && *end != split; ++end);
       exploded.push_back(string(start, end));
       exploded.push_back(string(start, end));
@@ -1182,7 +1189,7 @@ unsigned long RegexChoice(RxChoiceList *Rxs,const char **ListBegin,
       R->Hit = false;
       R->Hit = false;
 
 
    unsigned long Hits = 0;
    unsigned long Hits = 0;
-   for (; ListBegin != ListEnd; ListBegin++)
+   for (; ListBegin < ListEnd; ++ListBegin)
    {
    {
       // Check if the name is a regex
       // Check if the name is a regex
       const char *I;
       const char *I;

+ 39 - 36
apt-pkg/contrib/strutl.h

@@ -18,15 +18,18 @@
 
 
 
 
 #include <limits>
 #include <limits>
-#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 <stddef.h>
 
 
 #include "macros.h"
 #include "macros.h"
 
 
+#ifndef APT_10_CLEANER_HEADERS
+#include <stdlib.h>
+#endif
 #ifndef APT_8_CLEANER_HEADERS
 #ifndef APT_8_CLEANER_HEADERS
 using std::string;
 using std::string;
 using std::vector;
 using std::vector;
@@ -37,8 +40,8 @@ namespace APT {
    namespace String {
    namespace String {
       std::string Strip(const std::string &s);
       std::string Strip(const std::string &s);
       bool Endswith(const std::string &s, const std::string &ending);
       bool Endswith(const std::string &s, const std::string &ending);
-   };
-};
+   }
+}
 
 
 
 
 bool UTF8ToCodeset(const char *codeset, const std::string &orig, std::string *dest);
 bool UTF8ToCodeset(const char *codeset, const std::string &orig, std::string *dest);
@@ -60,9 +63,9 @@ std::string Base64Encode(const std::string &Str);
 std::string OutputInDepth(const unsigned long Depth, const char* Separator="  ");
 std::string OutputInDepth(const unsigned long Depth, const char* Separator="  ");
 std::string URItoFileName(const std::string &URI);
 std::string URItoFileName(const std::string &URI);
 std::string TimeRFC1123(time_t Date);
 std::string TimeRFC1123(time_t Date);
-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 std::string &Val,time_t &Result);
+bool RFC1123StrToTime(const char* const str,time_t &time) APT_MUSTCHECK;
+bool FTPMDTMStrToTime(const char* const str,time_t &time) APT_MUSTCHECK;
+APT_DEPRECATED bool StrToTime(const std::string &Val,time_t &Result);
 std::string LookupTag(const std::string &Message,const char *Tag,const char *Default = 0);
 std::string LookupTag(const std::string &Message,const char *Tag,const char *Default = 0);
 int StringToBool(const std::string &Text,int Default = -1);
 int StringToBool(const std::string &Text,int Default = -1);
 bool ReadMessages(int Fd, std::vector<std::string> &List);
 bool ReadMessages(int Fd, std::vector<std::string> &List);
@@ -76,7 +79,7 @@ bool TokSplitString(char Tok,char *Input,char **List,
 		    unsigned long ListMax);
 		    unsigned long ListMax);
 
 
 // split a given string by a char
 // split a given string by a char
-std::vector<std::string> VectorizeString(std::string const &haystack, char const &split) __attrib_const;
+std::vector<std::string> VectorizeString(std::string const &haystack, char const &split) APT_CONST;
 
 
 /* \brief Return a vector of strings from string "input" where "sep"
 /* \brief Return a vector of strings from string "input" where "sep"
  * is used as the delimiter string.
  * is used as the delimiter string.
@@ -94,56 +97,56 @@ std::vector<std::string> VectorizeString(std::string const &haystack, char const
  */
  */
 std::vector<std::string> StringSplit(std::string const &input, 
 std::vector<std::string> StringSplit(std::string const &input, 
                                      std::string const &sep, 
                                      std::string const &sep, 
-                                     unsigned int maxsplit=std::numeric_limits<unsigned int>::max()) __attrib_const;
+                                     unsigned int maxsplit=std::numeric_limits<unsigned int>::max()) APT_CONST;
 
 
-void ioprintf(std::ostream &out,const char *format,...) __like_printf(2);
-void strprintf(std::string &out,const char *format,...) __like_printf(2);
-char *safe_snprintf(char *Buffer,char *End,const char *Format,...) __like_printf(3);
+void ioprintf(std::ostream &out,const char *format,...) APT_PRINTF(2);
+void strprintf(std::string &out,const char *format,...) APT_PRINTF(2);
+char *safe_snprintf(char *Buffer,char *End,const char *Format,...) APT_PRINTF(3);
 bool CheckDomainList(const std::string &Host, const std::string &List);
 bool CheckDomainList(const std::string &Host, const std::string &List);
-int tolower_ascii(int const c) __attrib_const __hot;
+int tolower_ascii(int const c) APT_CONST APT_HOT;
 std::string StripEpoch(const std::string &VerStr);
 std::string StripEpoch(const std::string &VerStr);
 
 
 #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 *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));}; \
-inline int name(const std::string& A,const char *B) {return func(A.c_str(),A.c_str()+A.length(),B,B+strlen(B));}; \
-inline int name(const std::string& A,const std::string& B) {return func(A.c_str(),A.c_str()+A.length(),B.c_str(),B.c_str()+B.length());}; \
-inline int name(const std::string& A,const char *B,const char *BEnd) {return func(A.c_str(),A.c_str()+A.length(),B,BEnd);};
+inline APT_PURE int name(const char *A,const char *B) {return func(A,A+strlen(A),B,B+strlen(B));} \
+inline APT_PURE int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));} \
+inline APT_PURE int name(const std::string& A,const char *B) {return func(A.c_str(),A.c_str()+A.length(),B,B+strlen(B));} \
+inline APT_PURE int name(const std::string& A,const std::string& B) {return func(A.c_str(),A.c_str()+A.length(),B.c_str(),B.c_str()+B.length());} \
+inline APT_PURE int name(const std::string& A,const char *B,const char *BEnd) {return func(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 std::string& A,const char *B) {return func(A.begin(),A.end(),B,B+strlen(B));}; \
-inline int name(const std::string& A,const std::string& B) {return func(A.begin(),A.end(),B.begin(),B.end());}; \
-inline int name(const std::string& A,const char *B,const char *BEnd) {return func(A.begin(),A.end(),B,BEnd);};
+inline APT_PURE int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));} \
+inline APT_PURE int name(const std::string& A,const char *B) {return func(A.begin(),A.end(),B,B+strlen(B));} \
+inline APT_PURE int name(const std::string& A,const std::string& B) {return func(A.begin(),A.end(),B.begin(),B.end());} \
+inline APT_PURE int name(const std::string& A,const char *B,const char *BEnd) {return func(A.begin(),A.end(),B,BEnd);}
 
 
-int stringcmp(const char *A,const char *AEnd,const char *B,const char *BEnd);
-int stringcasecmp(const char *A,const char *AEnd,const char *B,const char *BEnd);
+int APT_PURE stringcmp(const char *A,const char *AEnd,const char *B,const char *BEnd);
+int APT_PURE stringcasecmp(const char *A,const char *AEnd,const char *B,const char *BEnd);
 
 
 /* We assume that GCC 3 indicates that libstdc++3 is in use too. In that
 /* We assume that GCC 3 indicates that libstdc++3 is in use too. In that
    case the definition of string::const_iterator is not the same as
    case the definition of string::const_iterator is not the same as
    const char * and we need these extra functions */
    const char * and we need these extra functions */
 #if __GNUC__ >= 3
 #if __GNUC__ >= 3
-int stringcmp(std::string::const_iterator A,std::string::const_iterator AEnd,
+int APT_PURE stringcmp(std::string::const_iterator A,std::string::const_iterator AEnd,
 	      const char *B,const char *BEnd);
 	      const char *B,const char *BEnd);
-int stringcmp(std::string::const_iterator A,std::string::const_iterator AEnd,
+int APT_PURE stringcmp(std::string::const_iterator A,std::string::const_iterator AEnd,
 	      std::string::const_iterator B,std::string::const_iterator BEnd);
 	      std::string::const_iterator B,std::string::const_iterator BEnd);
-int stringcasecmp(std::string::const_iterator A,std::string::const_iterator AEnd,
+int APT_PURE stringcasecmp(std::string::const_iterator A,std::string::const_iterator AEnd,
 		  const char *B,const char *BEnd);
 		  const char *B,const char *BEnd);
-int stringcasecmp(std::string::const_iterator A,std::string::const_iterator AEnd,
+int APT_PURE stringcasecmp(std::string::const_iterator A,std::string::const_iterator AEnd,
                   std::string::const_iterator B,std::string::const_iterator BEnd);
                   std::string::const_iterator B,std::string::const_iterator BEnd);
 
 
-inline int stringcmp(std::string::const_iterator A,std::string::const_iterator Aend,const char *B) {return stringcmp(A,Aend,B,B+strlen(B));};
-inline int stringcasecmp(std::string::const_iterator A,std::string::const_iterator Aend,const char *B) {return stringcasecmp(A,Aend,B,B+strlen(B));};
+inline APT_PURE int stringcmp(std::string::const_iterator A,std::string::const_iterator Aend,const char *B) {return stringcmp(A,Aend,B,B+strlen(B));}
+inline APT_PURE int stringcasecmp(std::string::const_iterator A,std::string::const_iterator Aend,const char *B) {return stringcasecmp(A,Aend,B,B+strlen(B));}
 #endif
 #endif
 
 
-APT_MKSTRCMP2(stringcmp,stringcmp);
-APT_MKSTRCMP2(stringcasecmp,stringcasecmp);
+APT_MKSTRCMP2(stringcmp,stringcmp)
+APT_MKSTRCMP2(stringcasecmp,stringcasecmp)
 
 
 // Return the length of a NULL-terminated string array
 // Return the length of a NULL-terminated string array
-size_t strv_length(const char **str_array);
+size_t APT_PURE strv_length(const char **str_array);
 
 
 
 
-inline const char *DeNull(const char *s) {return (s == 0?"(null)":s);};
+inline const char *DeNull(const char *s) {return (s == 0?"(null)":s);}
 
 
 class URI
 class URI
 {
 {
@@ -159,13 +162,13 @@ class URI
    unsigned int Port;
    unsigned int Port;
    
    
    operator std::string();
    operator std::string();
-   inline void operator =(const std::string &From) {CopyFrom(From);};
+   inline void operator =(const std::string &From) {CopyFrom(From);}
    inline bool empty() {return Access.empty();};
    inline bool empty() {return Access.empty();};
    static std::string SiteOnly(const std::string &URI);
    static std::string SiteOnly(const std::string &URI);
    static std::string NoUserPassword(const std::string &URI);
    static std::string NoUserPassword(const std::string &URI);
    
    
-   URI(std::string Path) {CopyFrom(Path);};
-   URI() : Port(0) {};
+   URI(std::string Path) {CopyFrom(Path);}
+   URI() : Port(0) {}
 };
 };
 
 
 struct SubstVar
 struct SubstVar

+ 13 - 3
apt-pkg/deb/debindexfile.cc

@@ -15,7 +15,6 @@
 #include <apt-pkg/debsrcrecords.h>
 #include <apt-pkg/debsrcrecords.h>
 #include <apt-pkg/deblistparser.h>
 #include <apt-pkg/deblistparser.h>
 #include <apt-pkg/debrecords.h>
 #include <apt-pkg/debrecords.h>
-#include <apt-pkg/sourcelist.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/progress.h>
 #include <apt-pkg/progress.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
@@ -23,7 +22,18 @@
 #include <apt-pkg/acquire-item.h>
 #include <apt-pkg/acquire-item.h>
 #include <apt-pkg/debmetaindex.h>
 #include <apt-pkg/debmetaindex.h>
 #include <apt-pkg/gpgv.h>
 #include <apt-pkg/gpgv.h>
-
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/indexfile.h>
+#include <apt-pkg/mmap.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/pkgcachegen.h>
+#include <apt-pkg/pkgrecords.h>
+#include <apt-pkg/srcrecords.h>
+
+#include <stdio.h>
+#include <iostream>
+#include <string>
 #include <sys/stat.h>
 #include <sys/stat.h>
 									/*}}}*/
 									/*}}}*/
 
 
@@ -650,7 +660,7 @@ pkgCache::PkgFileIterator debStatusIndex::FindInCache(pkgCache &Cache) const
 // StatusIndex::Exists - Check if the index is available		/*{{{*/
 // StatusIndex::Exists - Check if the index is available		/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-bool debStatusIndex::Exists() const
+APT_CONST bool debStatusIndex::Exists() const
 {
 {
    // Abort if the file does not exist.
    // Abort if the file does not exist.
    return true;
    return true;

+ 14 - 6
apt-pkg/deb/debindexfile.h

@@ -16,9 +16,17 @@
 #ifndef PKGLIB_DEBINDEXFILE_H
 #ifndef PKGLIB_DEBINDEXFILE_H
 #define PKGLIB_DEBINDEXFILE_H
 #define PKGLIB_DEBINDEXFILE_H
 
 
+#include <apt-pkg/indexfile.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/srcrecords.h>
 
 
+#include <string>
+
+class OpProgress;
+class pkgAcquire;
+class pkgCacheGenerator;
 
 
-#include <apt-pkg/indexfile.h>
 
 
 class debStatusIndex : public pkgIndexFile
 class debStatusIndex : public pkgIndexFile
 {
 {
@@ -30,10 +38,10 @@ class debStatusIndex : public pkgIndexFile
 
 
    public:
    public:
 
 
-   virtual const Type *GetType() const;
+   virtual const Type *GetType() const APT_CONST;
    
    
    // Interface for acquire
    // Interface for acquire
-   virtual std::string Describe(bool Short) const {return File;};
+   virtual std::string Describe(bool /*Short*/) const {return File;};
    
    
    // Interface for the Cache Generator
    // Interface for the Cache Generator
    virtual bool Exists() const;
    virtual bool Exists() const;
@@ -63,7 +71,7 @@ class debPackagesIndex : public pkgIndexFile
    
    
    public:
    public:
    
    
-   virtual const Type *GetType() const;
+   virtual const Type *GetType() const APT_CONST;
 
 
    // Stuff for accessing files on remote items
    // Stuff for accessing files on remote items
    virtual std::string ArchiveInfo(pkgCache::VerIterator Ver) const;
    virtual std::string ArchiveInfo(pkgCache::VerIterator Ver) const;
@@ -102,7 +110,7 @@ class debTranslationsIndex : public pkgIndexFile
 
 
    public:
    public:
    
    
-   virtual const Type *GetType() const;
+   virtual const Type *GetType() const APT_CONST;
 
 
    // Interface for acquire
    // Interface for acquire
    virtual std::string Describe(bool Short) const;   
    virtual std::string Describe(bool Short) const;   
@@ -134,7 +142,7 @@ class debSourcesIndex : public pkgIndexFile
    
    
    public:
    public:
 
 
-   virtual const Type *GetType() const;
+   virtual const Type *GetType() const APT_CONST;
 
 
    // Stuff for accessing files on remote items
    // Stuff for accessing files on remote items
    virtual std::string SourceInfo(pkgSrcRecords::Parser const &Record,
    virtual std::string SourceInfo(pkgSrcRecords::Parser const &Record,

+ 147 - 29
apt-pkg/deb/deblistparser.cc

@@ -21,8 +21,17 @@
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/crc-16.h>
 #include <apt-pkg/crc-16.h>
 #include <apt-pkg/md5.h>
 #include <apt-pkg/md5.h>
+#include <apt-pkg/mmap.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/tagfile.h>
 #include <apt-pkg/macros.h>
 #include <apt-pkg/macros.h>
 
 
+#include <stddef.h>
+#include <string.h>
+#include <algorithm>
+#include <string>
+#include <vector>
 #include <ctype.h>
 #include <ctype.h>
 									/*}}}*/
 									/*}}}*/
 
 
@@ -34,7 +43,7 @@ static debListParser::WordList PrioList[] = {
    {"standard",pkgCache::State::Standard},
    {"standard",pkgCache::State::Standard},
    {"optional",pkgCache::State::Optional},
    {"optional",pkgCache::State::Optional},
    {"extra",pkgCache::State::Extra},
    {"extra",pkgCache::State::Extra},
-   {}};
+   {NULL, 0}};
 
 
 // ListParser::debListParser - Constructor				/*{{{*/
 // ListParser::debListParser - Constructor				/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
@@ -95,44 +104,49 @@ string debListParser::Version()
    return Section.FindS("Version");
    return Section.FindS("Version");
 }
 }
 									/*}}}*/
 									/*}}}*/
-// ListParser::NewVersion - Fill in the version structure		/*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool debListParser::NewVersion(pkgCache::VerIterator &Ver)
+unsigned char debListParser::ParseMultiArch(bool const showErrors)	/*{{{*/
 {
 {
-   // Parse the section
-   Ver->Section = UniqFindTagWrite("Section");
-
-   // Parse multi-arch
+   unsigned char MA;
    string const MultiArch = Section.FindS("Multi-Arch");
    string const MultiArch = Section.FindS("Multi-Arch");
    if (MultiArch.empty() == true)
    if (MultiArch.empty() == true)
-      Ver->MultiArch = pkgCache::Version::None;
+      MA = pkgCache::Version::None;
    else if (MultiArch == "same") {
    else if (MultiArch == "same") {
-      // Parse multi-arch
       if (ArchitectureAll() == true)
       if (ArchitectureAll() == true)
       {
       {
-	 /* Arch all packages can't be Multi-Arch: same */
-	 _error->Warning("Architecture: all package '%s' can't be Multi-Arch: same",
-			Section.FindS("Package").c_str());
-	 Ver->MultiArch = pkgCache::Version::None;
+	 if (showErrors == true)
+	    _error->Warning("Architecture: all package '%s' can't be Multi-Arch: same",
+		  Section.FindS("Package").c_str());
+	 MA = pkgCache::Version::None;
       }
       }
       else
       else
-	 Ver->MultiArch = pkgCache::Version::Same;
+	 MA = pkgCache::Version::Same;
    }
    }
    else if (MultiArch == "foreign")
    else if (MultiArch == "foreign")
-      Ver->MultiArch = pkgCache::Version::Foreign;
+      MA = pkgCache::Version::Foreign;
    else if (MultiArch == "allowed")
    else if (MultiArch == "allowed")
-      Ver->MultiArch = pkgCache::Version::Allowed;
+      MA = pkgCache::Version::Allowed;
    else
    else
    {
    {
-      _error->Warning("Unknown Multi-Arch type '%s' for package '%s'",
-			MultiArch.c_str(), Section.FindS("Package").c_str());
-      Ver->MultiArch = pkgCache::Version::None;
+      if (showErrors == true)
+	 _error->Warning("Unknown Multi-Arch type '%s' for package '%s'",
+	       MultiArch.c_str(), Section.FindS("Package").c_str());
+      MA = pkgCache::Version::None;
    }
    }
 
 
    if (ArchitectureAll() == true)
    if (ArchitectureAll() == true)
-      Ver->MultiArch |= pkgCache::Version::All;
+      MA |= pkgCache::Version::All;
 
 
+   return MA;
+}
+									/*}}}*/
+// ListParser::NewVersion - Fill in the version structure		/*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool debListParser::NewVersion(pkgCache::VerIterator &Ver)
+{
+   // Parse the section
+   Ver->Section = UniqFindTagWrite("Section");
+   Ver->MultiArch = ParseMultiArch(true);
    // Archive Size
    // Archive Size
    Ver->Size = Section.FindULL("Size");
    Ver->Size = Section.FindULL("Size");
    // Unpacked Size (in K)
    // Unpacked Size (in K)
@@ -354,7 +368,7 @@ bool debListParser::ParseStatus(pkgCache::PkgIterator &Pkg,
                           {"hold",pkgCache::State::Hold},
                           {"hold",pkgCache::State::Hold},
                           {"deinstall",pkgCache::State::DeInstall},
                           {"deinstall",pkgCache::State::DeInstall},
                           {"purge",pkgCache::State::Purge},
                           {"purge",pkgCache::State::Purge},
-                          {}};
+                          {NULL, 0}};
    if (GrabWord(string(Start,I-Start),WantList,Pkg->SelectedState) == false)
    if (GrabWord(string(Start,I-Start),WantList,Pkg->SelectedState) == false)
       return _error->Error("Malformed 1st word in the Status line");
       return _error->Error("Malformed 1st word in the Status line");
 
 
@@ -370,7 +384,7 @@ bool debListParser::ParseStatus(pkgCache::PkgIterator &Pkg,
                           {"reinstreq",pkgCache::State::ReInstReq},
                           {"reinstreq",pkgCache::State::ReInstReq},
                           {"hold",pkgCache::State::HoldInst},
                           {"hold",pkgCache::State::HoldInst},
                           {"hold-reinstreq",pkgCache::State::HoldReInstReq},
                           {"hold-reinstreq",pkgCache::State::HoldReInstReq},
-                          {}};
+                          {NULL, 0}};
    if (GrabWord(string(Start,I-Start),FlagList,Pkg->InstState) == false)
    if (GrabWord(string(Start,I-Start),FlagList,Pkg->InstState) == false)
       return _error->Error("Malformed 2nd word in the Status line");
       return _error->Error("Malformed 2nd word in the Status line");
 
 
@@ -392,7 +406,7 @@ bool debListParser::ParseStatus(pkgCache::PkgIterator &Pkg,
                             {"triggers-pending",pkgCache::State::TriggersPending},
                             {"triggers-pending",pkgCache::State::TriggersPending},
                             {"post-inst-failed",pkgCache::State::HalfConfigured},
                             {"post-inst-failed",pkgCache::State::HalfConfigured},
                             {"removal-failed",pkgCache::State::HalfInstalled},
                             {"removal-failed",pkgCache::State::HalfInstalled},
-                            {}};
+                            {NULL, 0}};
    if (GrabWord(string(Start,I-Start),StatusList,Pkg->CurrentState) == false)
    if (GrabWord(string(Start,I-Start),StatusList,Pkg->CurrentState) == false)
       return _error->Error("Malformed 3rd word in the Status line");
       return _error->Error("Malformed 3rd word in the Status line");
 
 
@@ -474,18 +488,31 @@ const char *debListParser::ConvertRelation(const char *I,unsigned int &Op)
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* This parses the dependency elements out of a standard string in place,
 /* This parses the dependency elements out of a standard string in place,
    bit by bit. */
    bit by bit. */
+const char *debListParser::ParseDepends(const char *Start,const char *Stop,
+               std::string &Package,std::string &Ver,unsigned int &Op)
+   { return ParseDepends(Start, Stop, Package, Ver, Op, false, true, false); }
+const char *debListParser::ParseDepends(const char *Start,const char *Stop,
+               std::string &Package,std::string &Ver,unsigned int &Op,
+               bool const &ParseArchFlags)
+   { return ParseDepends(Start, Stop, Package, Ver, Op, ParseArchFlags, true, false); }
+const char *debListParser::ParseDepends(const char *Start,const char *Stop,
+               std::string &Package,std::string &Ver,unsigned int &Op,
+               bool const &ParseArchFlags, bool const &StripMultiArch)
+   { return ParseDepends(Start, Stop, Package, Ver, Op, ParseArchFlags, StripMultiArch, false); }
 const char *debListParser::ParseDepends(const char *Start,const char *Stop,
 const char *debListParser::ParseDepends(const char *Start,const char *Stop,
 					string &Package,string &Ver,
 					string &Package,string &Ver,
 					unsigned int &Op, bool const &ParseArchFlags,
 					unsigned int &Op, bool const &ParseArchFlags,
-					bool const &StripMultiArch)
+					bool const &StripMultiArch,
+					bool const &ParseRestrictionsList)
 {
 {
    // Strip off leading space
    // Strip off leading space
-   for (;Start != Stop && isspace(*Start) != 0; Start++);
+   for (;Start != Stop && isspace(*Start) != 0; ++Start);
    
    
    // Parse off the package name
    // Parse off the package name
    const char *I = Start;
    const char *I = Start;
    for (;I != Stop && isspace(*I) == 0 && *I != '(' && *I != ')' &&
    for (;I != Stop && isspace(*I) == 0 && *I != '(' && *I != ')' &&
-	*I != ',' && *I != '|' && *I != '[' && *I != ']'; I++);
+	*I != ',' && *I != '|' && *I != '[' && *I != ']' &&
+	*I != '<' && *I != '>'; ++I);
    
    
    // Malformed, no '('
    // Malformed, no '('
    if (I != Stop && *I == ')')
    if (I != Stop && *I == ')')
@@ -602,6 +629,76 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
       for (;I != Stop && isspace(*I) != 0; I++);
       for (;I != Stop && isspace(*I) != 0; I++);
    }
    }
 
 
+   if (ParseRestrictionsList == true)
+   {
+      // Parse a restrictions list
+      if (I != Stop && *I == '<')
+      {
+	 ++I;
+	 // malformed
+	 if (unlikely(I == Stop))
+	    return 0;
+
+	 std::vector<string> const profiles = APT::Configuration::getBuildProfiles();
+
+	 const char *End = I;
+	 bool Found = false;
+	 bool NegRestriction = false;
+	 while (I != Stop)
+	 {
+	    // look for whitespace or ending '>'
+	    for (;End != Stop && !isspace(*End) && *End != '>'; ++End);
+
+	    if (unlikely(End == Stop))
+	       return 0;
+
+	    if (*I == '!')
+	    {
+	       NegRestriction = true;
+	       ++I;
+	    }
+
+	    std::string restriction(I, End);
+
+	    std::string prefix = "profile.";
+	    // only support for "profile" prefix, ignore others
+	    if (restriction.size() > prefix.size() &&
+		  restriction.substr(0, prefix.size()) == prefix)
+	    {
+	       // get the name of the profile
+	       restriction = restriction.substr(prefix.size());
+
+	       if (restriction.empty() == false && profiles.empty() == false &&
+		     std::find(profiles.begin(), profiles.end(), restriction) != profiles.end())
+	       {
+		  Found = true;
+		  if (I[-1] != '!')
+		     NegRestriction = false;
+		  // we found a match, so fast-forward to the end of the wildcards
+		  for (; End != Stop && *End != '>'; ++End);
+	       }
+	    }
+
+	    if (*End++ == '>') {
+	       I = End;
+	       break;
+	    }
+
+	    I = End;
+	    for (;I != Stop && isspace(*I) != 0; I++);
+	 }
+
+	 if (NegRestriction == true)
+	    Found = !Found;
+
+	 if (Found == false)
+	    Package = ""; /* not for this restriction */
+      }
+
+      // Skip whitespace
+      for (;I != Stop && isspace(*I) != 0; I++);
+   }
+
    if (I != Stop && *I == '|')
    if (I != Stop && *I == '|')
       Op |= pkgCache::Dep::Or;
       Op |= pkgCache::Dep::Or;
    
    
@@ -635,7 +732,7 @@ bool debListParser::ParseDepends(pkgCache::VerIterator &Ver,
       string Version;
       string Version;
       unsigned int Op;
       unsigned int Op;
 
 
-      Start = ParseDepends(Start, Stop, Package, Version, Op, false, false);
+      Start = ParseDepends(Start, Stop, Package, Version, Op, false, false, false);
       if (Start == 0)
       if (Start == 0)
 	 return _error->Error("Problem parsing dependency %s",Tag);
 	 return _error->Error("Problem parsing dependency %s",Tag);
       size_t const found = Package.rfind(':');
       size_t const found = Package.rfind(':');
@@ -841,3 +938,24 @@ unsigned char debListParser::GetPrio(string Str)
    return Out;
    return Out;
 }
 }
 									/*}}}*/
 									/*}}}*/
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+bool debListParser::SameVersion(unsigned short const Hash,		/*{{{*/
+      pkgCache::VerIterator const &Ver)
+{
+   if (pkgCacheGenerator::ListParser::SameVersion(Hash, Ver) == false)
+      return false;
+   // status file has no (Download)Size, but all others are fair game
+   // status file is parsed last, so the first version we encounter is
+   // probably also the version we have downloaded
+   unsigned long long const Size = Section.FindULL("Size");
+   if (Size != 0 && Size != Ver->Size)
+      return false;
+   // available everywhere, but easier to check here than to include in VersionHash
+   unsigned char MultiArch = ParseMultiArch(false);
+   if (MultiArch != Ver->MultiArch)
+      return false;
+   // for all practical proposes (we can check): same version
+   return true;
+}
+									/*}}}*/
+#endif

+ 26 - 4
apt-pkg/deb/deblistparser.h

@@ -13,11 +13,18 @@
 
 
 #include <apt-pkg/pkgcachegen.h>
 #include <apt-pkg/pkgcachegen.h>
 #include <apt-pkg/tagfile.h>
 #include <apt-pkg/tagfile.h>
+#include <apt-pkg/md5.h>
+#include <apt-pkg/pkgcache.h>
+
+#include <string>
+#include <vector>
 
 
 #ifndef APT_8_CLEANER_HEADERS
 #ifndef APT_8_CLEANER_HEADERS
 #include <apt-pkg/indexfile.h>
 #include <apt-pkg/indexfile.h>
 #endif
 #endif
 
 
+class FileFd;
+
 class debListParser : public pkgCacheGenerator::ListParser
 class debListParser : public pkgCacheGenerator::ListParser
 {
 {
    public:
    public:
@@ -63,6 +70,9 @@ class debListParser : public pkgCacheGenerator::ListParser
    virtual std::string DescriptionLanguage();
    virtual std::string DescriptionLanguage();
    virtual MD5SumValue Description_md5();
    virtual MD5SumValue Description_md5();
    virtual unsigned short VersionHash();
    virtual unsigned short VersionHash();
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+   virtual bool SameVersion(unsigned short const Hash, pkgCache::VerIterator const &Ver);
+#endif
    virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
    virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
 			   pkgCache::VerIterator &Ver);
 			   pkgCache::VerIterator &Ver);
    virtual unsigned long Offset() {return iOffset;};
    virtual unsigned long Offset() {return iOffset;};
@@ -72,15 +82,27 @@ class debListParser : public pkgCacheGenerator::ListParser
    
    
    bool LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,FileFd &File,
    bool LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,FileFd &File,
 			std::string section);
 			std::string section);
-   
+
+   static const char *ParseDepends(const char *Start,const char *Stop,
+	 std::string &Package,std::string &Ver,unsigned int &Op);
    static const char *ParseDepends(const char *Start,const char *Stop,
    static const char *ParseDepends(const char *Start,const char *Stop,
-			    std::string &Package,std::string &Ver,unsigned int &Op,
-			    bool const &ParseArchFlags = false,
-			    bool const &StripMultiArch = true);
+	 std::string &Package,std::string &Ver,unsigned int &Op,
+	 bool const &ParseArchFlags);
+   static const char *ParseDepends(const char *Start,const char *Stop,
+	 std::string &Package,std::string &Ver,unsigned int &Op,
+	 bool const &ParseArchFlags, bool const &StripMultiArch);
+   static const char *ParseDepends(const char *Start,const char *Stop,
+	 std::string &Package,std::string &Ver,unsigned int &Op,
+	 bool const &ParseArchFlags, bool const &StripMultiArch,
+	 bool const &ParseRestrictionsList);
+
    static const char *ConvertRelation(const char *I,unsigned int &Op);
    static const char *ConvertRelation(const char *I,unsigned int &Op);
 
 
    debListParser(FileFd *File, std::string const &Arch = "");
    debListParser(FileFd *File, std::string const &Arch = "");
    virtual ~debListParser() {};
    virtual ~debListParser() {};
+
+   private:
+   unsigned char ParseMultiArch(bool const showErrors);
 };
 };
 
 
 #endif
 #endif

+ 9 - 2
apt-pkg/deb/debmetaindex.cc

@@ -9,8 +9,15 @@
 #include <apt-pkg/aptconfiguration.h>
 #include <apt-pkg/aptconfiguration.h>
 #include <apt-pkg/indexrecords.h>
 #include <apt-pkg/indexrecords.h>
 #include <apt-pkg/sourcelist.h>
 #include <apt-pkg/sourcelist.h>
-#include <apt-pkg/error.h>
-
+#include <apt-pkg/hashes.h>
+#include <apt-pkg/macros.h>
+#include <apt-pkg/metaindex.h>
+
+#include <string.h>
+#include <map>
+#include <string>
+#include <utility>
+#include <vector>
 #include <set>
 #include <set>
 #include <algorithm>
 #include <algorithm>
 
 

+ 7 - 1
apt-pkg/deb/debmetaindex.h

@@ -3,7 +3,7 @@
 #define PKGLIB_DEBMETAINDEX_H
 #define PKGLIB_DEBMETAINDEX_H
 
 
 #include <apt-pkg/metaindex.h>
 #include <apt-pkg/metaindex.h>
-#include <apt-pkg/init.h>
+#include <apt-pkg/macros.h>
 
 
 #include <map>
 #include <map>
 #include <string>
 #include <string>
@@ -12,6 +12,12 @@
 #ifndef APT_8_CLEANER_HEADERS
 #ifndef APT_8_CLEANER_HEADERS
 #include <apt-pkg/sourcelist.h>
 #include <apt-pkg/sourcelist.h>
 #endif
 #endif
+#ifndef APT_10_CLEANER_HEADERS
+#include <apt-pkg/init.h>
+#endif
+
+class pkgAcquire;
+class pkgIndexFile;
 
 
 class debReleaseIndex : public metaIndex {
 class debReleaseIndex : public metaIndex {
    public:
    public:

+ 7 - 1
apt-pkg/deb/debrecords.cc

@@ -12,10 +12,16 @@
 
 
 #include <apt-pkg/debrecords.h>
 #include <apt-pkg/debrecords.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
-#include <apt-pkg/error.h>
 #include <apt-pkg/aptconfiguration.h>
 #include <apt-pkg/aptconfiguration.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/tagfile.h>
 
 
+#include <string.h>
+#include <algorithm>
+#include <string>
+#include <vector>
 #include <langinfo.h>
 #include <langinfo.h>
 									/*}}}*/
 									/*}}}*/
 
 

+ 3 - 0
apt-pkg/deb/debrecords.h

@@ -17,6 +17,9 @@
 #include <apt-pkg/pkgrecords.h>
 #include <apt-pkg/pkgrecords.h>
 #include <apt-pkg/tagfile.h>
 #include <apt-pkg/tagfile.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
+#include <apt-pkg/pkgcache.h>
+
+#include <string>
 
 
 #ifndef APT_8_CLEANER_HEADERS
 #ifndef APT_8_CLEANER_HEADERS
 #include <apt-pkg/indexfile.h>
 #include <apt-pkg/indexfile.h>

+ 11 - 4
apt-pkg/deb/debsrcrecords.cc

@@ -15,12 +15,19 @@
 #include <apt-pkg/debsrcrecords.h>
 #include <apt-pkg/debsrcrecords.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
-#include <apt-pkg/configuration.h>
 #include <apt-pkg/aptconfiguration.h>
 #include <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/srcrecords.h>
+#include <apt-pkg/tagfile.h>
 
 
-using std::max;
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+#include <algorithm>
+#include <string>
+#include <vector>
 									/*}}}*/
 									/*}}}*/
 
 
+using std::max;
 using std::string;
 using std::string;
 
 
 // SrcRecordParser::Binaries - Return the binaries field		/*{{{*/
 // SrcRecordParser::Binaries - Return the binaries field		/*{{{*/
@@ -57,7 +64,7 @@ const char **debSrcRecordParser::Binaries()
    } while (*bin != '\0');
    } while (*bin != '\0');
    StaticBinList.push_back(NULL);
    StaticBinList.push_back(NULL);
 
 
-   return (const char **) &StaticBinList[0];
+   return &StaticBinList[0];
 }
 }
 									/*}}}*/
 									/*}}}*/
 // SrcRecordParser::BuildDepends - Return the Build-Depends information	/*{{{*/
 // SrcRecordParser::BuildDepends - Return the Build-Depends information	/*{{{*/
@@ -90,7 +97,7 @@ bool debSrcRecordParser::BuildDepends(std::vector<pkgSrcRecords::Parser::BuildDe
       while (1)
       while (1)
       {
       {
          Start = debListParser::ParseDepends(Start, Stop, 
          Start = debListParser::ParseDepends(Start, Stop, 
-		     rec.Package,rec.Version,rec.Op,true, StripMultiArch);
+		     rec.Package,rec.Version,rec.Op,true,StripMultiArch,true);
 	 
 	 
          if (Start == 0) 
          if (Start == 0) 
             return _error->Error("Problem parsing dependency: %s", fields[I]);
             return _error->Error("Problem parsing dependency: %s", fields[I]);

+ 6 - 1
apt-pkg/deb/debsrcrecords.h

@@ -11,11 +11,16 @@
 #ifndef PKGLIB_DEBSRCRECORDS_H
 #ifndef PKGLIB_DEBSRCRECORDS_H
 #define PKGLIB_DEBSRCRECORDS_H
 #define PKGLIB_DEBSRCRECORDS_H
 
 
-
 #include <apt-pkg/srcrecords.h>
 #include <apt-pkg/srcrecords.h>
 #include <apt-pkg/tagfile.h>
 #include <apt-pkg/tagfile.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
 
 
+#include <stddef.h>
+#include <string>
+#include <vector>
+
+class pkgIndexFile;
+
 class debSrcRecordParser : public pkgSrcRecords::Parser
 class debSrcRecordParser : public pkgSrcRecords::Parser
 {
 {
    /** \brief dpointer placeholder (for later in case we need it) */
    /** \brief dpointer placeholder (for later in case we need it) */

+ 9 - 2
apt-pkg/deb/debsystem.cc

@@ -19,7 +19,14 @@
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
-#include <sys/types.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+#include <string>
+#include <vector>
 #include <unistd.h>
 #include <unistd.h>
 #include <dirent.h>
 #include <dirent.h>
 #include <errno.h>
 #include <errno.h>
@@ -195,7 +202,7 @@ bool debSystem::Initialize(Configuration &Cnf)
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* The standard name for a deb is 'deb'.. There are no separate versions
 /* The standard name for a deb is 'deb'.. There are no separate versions
    of .deb to worry about.. */
    of .deb to worry about.. */
-bool debSystem::ArchiveSupported(const char *Type)
+APT_PURE bool debSystem::ArchiveSupported(const char *Type)
 {
 {
    if (strcmp(Type,"deb") == 0)
    if (strcmp(Type,"deb") == 0)
       return true;
       return true;

+ 9 - 1
apt-pkg/deb/debsystem.h

@@ -12,11 +12,19 @@
 
 
 #include <apt-pkg/pkgsystem.h>
 #include <apt-pkg/pkgsystem.h>
 #include <apt-pkg/pkgcache.h>
 #include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
 
 
+#include <vector>
+class Configuration;
+class pkgIndexFile;
+class pkgPackageManager;
 class debSystemPrivate;
 class debSystemPrivate;
-class debStatusIndex;
 class pkgDepCache;
 class pkgDepCache;
 
 
+#ifndef APT_10_CLEANER_HEADERS
+class debStatusIndex;
+#endif
+
 class debSystem : public pkgSystem
 class debSystem : public pkgSystem
 {
 {
    // private d-pointer
    // private d-pointer

+ 2 - 0
apt-pkg/deb/debversion.cc

@@ -15,6 +15,8 @@
 #include <apt-pkg/debversion.h>
 #include <apt-pkg/debversion.h>
 #include <apt-pkg/pkgcache.h>
 #include <apt-pkg/pkgcache.h>
 
 
+#include <string.h>
+#include <string>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <ctype.h>
 #include <ctype.h>
 									/*}}}*/
 									/*}}}*/

+ 10 - 10
apt-pkg/deb/debversion.h

@@ -12,26 +12,26 @@
 #ifndef PKGLIB_DEBVERSION_H
 #ifndef PKGLIB_DEBVERSION_H
 #define PKGLIB_DEBVERSION_H
 #define PKGLIB_DEBVERSION_H
 
 
+#include <apt-pkg/version.h>
 
 
+#include <string>
 
 
-#include <apt-pkg/version.h>
-    
 class debVersioningSystem : public pkgVersioningSystem
 class debVersioningSystem : public pkgVersioningSystem
-{     
+{
    public:
    public:
-   
+
    static int CmpFragment(const char *A, const char *AEnd, const char *B,
    static int CmpFragment(const char *A, const char *AEnd, const char *B,
-			  const char *BEnd);
-   
+			  const char *BEnd) APT_PURE;
+
    // Compare versions..
    // Compare versions..
    virtual int DoCmpVersion(const char *A,const char *Aend,
    virtual int DoCmpVersion(const char *A,const char *Aend,
-			  const char *B,const char *Bend);
-   virtual bool CheckDep(const char *PkgVer,int Op,const char *DepVer);
-   virtual int DoCmpReleaseVer(const char *A,const char *Aend,
+			  const char *B,const char *Bend) APT_PURE;
+   virtual bool CheckDep(const char *PkgVer,int Op,const char *DepVer) APT_PURE;
+   virtual APT_PURE int DoCmpReleaseVer(const char *A,const char *Aend,
 			     const char *B,const char *Bend)
 			     const char *B,const char *Bend)
    {
    {
       return DoCmpVersion(A,Aend,B,Bend);
       return DoCmpVersion(A,Aend,B,Bend);
-   }   
+   }
    virtual std::string UpstreamVersion(const char *A);
    virtual std::string UpstreamVersion(const char *A);
 
 
    debVersioningSystem();
    debVersioningSystem();

+ 29 - 25
apt-pkg/deb/dpkgpm.cc

@@ -10,41 +10,45 @@
 // Includes								/*{{{*/
 // Includes								/*{{{*/
 #include <config.h>
 #include <config.h>
 
 
-#include <apt-pkg/dpkgpm.h>
-#include <apt-pkg/error.h>
+#include <apt-pkg/cachefile.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/depcache.h>
 #include <apt-pkg/depcache.h>
-#include <apt-pkg/pkgrecords.h>
-#include <apt-pkg/strutl.h>
+#include <apt-pkg/dpkgpm.h>
+#include <apt-pkg/error.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
-#include <apt-pkg/cachefile.h>
-#include <apt-pkg/packagemanager.h>
 #include <apt-pkg/install-progress.h>
 #include <apt-pkg/install-progress.h>
+#include <apt-pkg/packagemanager.h>
+#include <apt-pkg/pkgrecords.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/macros.h>
+#include <apt-pkg/pkgcache.h>
 
 
-#include <unistd.h>
-#include <stdlib.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <fcntl.h>
+#include <grp.h>
+#include <pty.h>
+#include <pwd.h>
+#include <signal.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
 #include <sys/select.h>
 #include <sys/select.h>
 #include <sys/stat.h>
 #include <sys/stat.h>
-#include <sys/types.h>
+#include <sys/time.h>
 #include <sys/wait.h>
 #include <sys/wait.h>
-#include <signal.h>
-#include <errno.h>
-#include <string.h>
-#include <stdio.h>
-#include <string.h>
-#include <algorithm>
-#include <sstream>
-#include <map>
-#include <pwd.h>
-#include <grp.h>
-#include <iomanip>
-
 #include <termios.h>
 #include <termios.h>
+#include <time.h>
 #include <unistd.h>
 #include <unistd.h>
-#include <sys/ioctl.h>
-#include <pty.h>
-#include <stdio.h>
+#include <algorithm>
+#include <cstring>
+#include <iostream>
+#include <map>
+#include <set>
+#include <string>
+#include <utility>
+#include <vector>
 
 
 #include <apti18n.h>
 #include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
@@ -1581,7 +1585,7 @@ bool pkgDPkgPM::GoNoABIBreak(APT::Progress::PackageManager *progress)
    return true;
    return true;
 }
 }
 
 
-void SigINT(int sig) {
+void SigINT(int /*sig*/) {
    pkgPackageManager::SigINTStop = true;
    pkgPackageManager::SigINTStop = true;
 }
 }
 									/*}}}*/
 									/*}}}*/

+ 13 - 4
apt-pkg/deb/dpkgpm.h

@@ -11,11 +11,20 @@
 #define PKGLIB_DPKGPM_H
 #define PKGLIB_DPKGPM_H
 
 
 #include <apt-pkg/packagemanager.h>
 #include <apt-pkg/packagemanager.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/macros.h>
+
 #include <vector>
 #include <vector>
 #include <map>
 #include <map>
 #include <stdio.h>
 #include <stdio.h>
-#include <apt-pkg/macros.h>
+#include <string>
+
+#ifndef APT_10_CLEANER_HEADERS
 #include <apt-pkg/init.h>
 #include <apt-pkg/init.h>
+#endif
+
+class pkgDepCache;
+namespace APT { namespace Progress { class PackageManager; } }
 
 
 #ifndef APT_8_CLEANER_HEADERS
 #ifndef APT_8_CLEANER_HEADERS
 using std::vector;
 using std::vector;
@@ -82,7 +91,7 @@ class pkgDPkgPM : public pkgPackageManager
 
 
    // Helpers
    // Helpers
    bool RunScriptsWithPkgs(const char *Cnf);
    bool RunScriptsWithPkgs(const char *Cnf);
-   __deprecated bool SendV2Pkgs(FILE *F);
+   APT_DEPRECATED bool SendV2Pkgs(FILE *F);
    bool SendPkgsInfo(FILE * const F, unsigned int const &Version);
    bool SendPkgsInfo(FILE * const F, unsigned int const &Version);
    void WriteHistoryTag(std::string const &tag, std::string value);
    void WriteHistoryTag(std::string const &tag, std::string value);
    std::string ExpandShortPackageName(pkgDepCache &Cache,
    std::string ExpandShortPackageName(pkgDepCache &Cache,
@@ -109,10 +118,10 @@ class pkgDPkgPM : public pkgPackageManager
    void DoDpkgStatusFd(int statusfd);
    void DoDpkgStatusFd(int statusfd);
    void ProcessDpkgStatusLine(char *line);
    void ProcessDpkgStatusLine(char *line);
 #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR < 13)
 #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR < 13)
-   void DoDpkgStatusFd(int statusfd, int unused) {
+   void DoDpkgStatusFd(int statusfd, int /*unused*/) {
       DoDpkgStatusFd(statusfd);
       DoDpkgStatusFd(statusfd);
    }
    }
-   void ProcessDpkgStatusLine(int unused, char *line) {
+   void ProcessDpkgStatusLine(int /*unused*/, char *line) {
       ProcessDpkgStatusLine(line);
       ProcessDpkgStatusLine(line);
    }
    }
 #endif
 #endif

+ 18 - 12
apt-pkg/depcache.cc

@@ -11,20 +11,26 @@
 #include<config.h>
 #include<config.h>
 
 
 #include <apt-pkg/depcache.h>
 #include <apt-pkg/depcache.h>
-#include <apt-pkg/version.h>
 #include <apt-pkg/versionmatch.h>
 #include <apt-pkg/versionmatch.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/sptr.h>
 #include <apt-pkg/sptr.h>
-#include <apt-pkg/algorithms.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/aptconfiguration.h>
 #include <apt-pkg/aptconfiguration.h>
-#include <apt-pkg/pkgsystem.h>
 #include <apt-pkg/tagfile.h>
 #include <apt-pkg/tagfile.h>
 #include <apt-pkg/progress.h>
 #include <apt-pkg/progress.h>
 #include <apt-pkg/cacheset.h>
 #include <apt-pkg/cacheset.h>
-
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/macros.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <list>
+#include <string>
+#include <utility>
+#include <vector>
 #include <algorithm>
 #include <algorithm>
 #include <iostream>
 #include <iostream>
 #include <sstream>
 #include <sstream>
@@ -222,7 +228,7 @@ bool pkgDepCache::readStateFile(OpProgress *Prog)			/*{{{*/
    return true;
    return true;
 }
 }
 									/*}}}*/
 									/*}}}*/
-bool pkgDepCache::writeStateFile(OpProgress *prog, bool InstalledOnly)	/*{{{*/
+bool pkgDepCache::writeStateFile(OpProgress * /*prog*/, bool InstalledOnly)	/*{{{*/
 {
 {
    bool const debug_autoremove = _config->FindB("Debug::pkgAutoRemove",false);
    bool const debug_autoremove = _config->FindB("Debug::pkgAutoRemove",false);
    
    
@@ -868,7 +874,7 @@ bool pkgDepCache::IsDeleteOk(PkgIterator const &Pkg,bool rPurge,
    return IsDeleteOkProtectInstallRequests(Pkg, rPurge, Depth, FromUser);
    return IsDeleteOkProtectInstallRequests(Pkg, rPurge, Depth, FromUser);
 }
 }
 bool pkgDepCache::IsDeleteOkProtectInstallRequests(PkgIterator const &Pkg,
 bool pkgDepCache::IsDeleteOkProtectInstallRequests(PkgIterator const &Pkg,
-      bool const rPurge, unsigned long const Depth, bool const FromUser)
+      bool const /*rPurge*/, unsigned long const Depth, bool const FromUser)
 {
 {
    if (FromUser == false && Pkg->CurrentVer == 0)
    if (FromUser == false && Pkg->CurrentVer == 0)
    {
    {
@@ -889,7 +895,7 @@ bool pkgDepCache::IsDeleteOkProtectInstallRequests(PkgIterator const &Pkg,
    and prevents mode changes for packages on hold for example.
    and prevents mode changes for packages on hold for example.
    If you want to check Mode specific stuff you can use the virtual public
    If you want to check Mode specific stuff you can use the virtual public
    Is<Mode>Ok methods instead */
    Is<Mode>Ok methods instead */
-char const* PrintMode(char const mode)
+static char const* PrintMode(char const mode)
 {
 {
 	 switch (mode)
 	 switch (mode)
 	 {
 	 {
@@ -1297,7 +1303,7 @@ bool pkgDepCache::IsInstallOk(PkgIterator const &Pkg,bool AutoInst,
    return IsInstallOkMultiArchSameVersionSynced(Pkg,AutoInst, Depth, FromUser);
    return IsInstallOkMultiArchSameVersionSynced(Pkg,AutoInst, Depth, FromUser);
 }
 }
 bool pkgDepCache::IsInstallOkMultiArchSameVersionSynced(PkgIterator const &Pkg,
 bool pkgDepCache::IsInstallOkMultiArchSameVersionSynced(PkgIterator const &Pkg,
-      bool const AutoInst, unsigned long const Depth, bool const FromUser)
+      bool const /*AutoInst*/, unsigned long const Depth, bool const FromUser)
 {
 {
    if (FromUser == true) // as always: user is always right
    if (FromUser == true) // as always: user is always right
       return true;
       return true;
@@ -1685,10 +1691,10 @@ bool pkgDepCache::Policy::IsImportantDep(DepIterator const &Dep)
 }
 }
 									/*}}}*/
 									/*}}}*/
 // Policy::GetPriority - Get the priority of the package pin		/*{{{*/
 // Policy::GetPriority - Get the priority of the package pin		/*{{{*/
-signed short pkgDepCache::Policy::GetPriority(pkgCache::PkgIterator const &Pkg)
-{ return 0; };
-signed short pkgDepCache::Policy::GetPriority(pkgCache::PkgFileIterator const &File)
-{ return 0; };
+APT_CONST signed short pkgDepCache::Policy::GetPriority(pkgCache::PkgIterator const &/*Pkg*/)
+{ return 0; }
+APT_CONST signed short pkgDepCache::Policy::GetPriority(pkgCache::PkgFileIterator const &/*File*/)
+{ return 0; }
 									/*}}}*/
 									/*}}}*/
 pkgDepCache::InRootSetFunc *pkgDepCache::GetRootSetFunc()		/*{{{*/
 pkgDepCache::InRootSetFunc *pkgDepCache::GetRootSetFunc()		/*{{{*/
 {
 {

+ 16 - 7
apt-pkg/depcache.h

@@ -40,18 +40,27 @@
 
 
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/pkgcache.h>
 #include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/macros.h>
+
+#include <stddef.h>
 
 
-#include <vector>
 #include <memory>
 #include <memory>
-#include <set>
 #include <list>
 #include <list>
+#include <string>
+#include <utility>
 
 
 #ifndef APT_8_CLEANER_HEADERS
 #ifndef APT_8_CLEANER_HEADERS
 #include <apt-pkg/progress.h>
 #include <apt-pkg/progress.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #endif
 #endif
+#ifndef APT_10_CLEANER_HEADERS
+#include <set>
+#include <vector>
+#endif
 
 
 class OpProgress;
 class OpProgress;
+class pkgVersioningSystem;
 
 
 class pkgDepCache : protected pkgCache::Namespace
 class pkgDepCache : protected pkgCache::Namespace
 {
 {
@@ -61,7 +70,7 @@ class pkgDepCache : protected pkgCache::Namespace
    class InRootSetFunc
    class InRootSetFunc
    {
    {
    public:
    public:
-     virtual bool InRootSet(const pkgCache::PkgIterator &pkg) {return false;};
+     virtual bool InRootSet(const pkgCache::PkgIterator &/*pkg*/) {return false;};
      virtual ~InRootSetFunc() {};
      virtual ~InRootSetFunc() {};
    };
    };
 
 
@@ -231,7 +240,7 @@ class pkgDepCache : protected pkgCache::Namespace
       unsigned char DepState;          // DepState Flags
       unsigned char DepState;          // DepState Flags
 
 
       // Update of candidate version
       // Update of candidate version
-      const char *StripEpoch(const char *Ver);
+      const char *StripEpoch(const char *Ver) APT_PURE;
       void Update(PkgIterator Pkg,pkgCache &Cache);
       void Update(PkgIterator Pkg,pkgCache &Cache);
       
       
       // Various test members for the current status of the package
       // Various test members for the current status of the package
@@ -381,8 +390,8 @@ class pkgDepCache : protected pkgCache::Namespace
    /** \brief Update the Marked and Garbage fields of all packages.
    /** \brief Update the Marked and Garbage fields of all packages.
     *
     *
     *  This routine is implicitly invoked after all state manipulators
     *  This routine is implicitly invoked after all state manipulators
-    *  and when an ActionGroup is destroyed.  It invokes #MarkRequired
-    *  and #Sweep to do its dirty work.
+    *  and when an ActionGroup is destroyed.  It invokes the private
+    *  MarkRequired() and Sweep() to do its dirty work.
     *
     *
     *  \param rootFunc A predicate that returns \b true for packages
     *  \param rootFunc A predicate that returns \b true for packages
     *  that should be added to the root set.
     *  that should be added to the root set.
@@ -465,7 +474,7 @@ class pkgDepCache : protected pkgCache::Namespace
     *
     *
     *  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 MarkPurge 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?
     */
     */

+ 17 - 10
apt-pkg/edsp.cc

@@ -11,16 +11,25 @@
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/cacheset.h>
 #include <apt-pkg/cacheset.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
-#include <apt-pkg/version.h>
-#include <apt-pkg/policy.h>
 #include <apt-pkg/tagfile.h>
 #include <apt-pkg/tagfile.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/progress.h>
 #include <apt-pkg/progress.h>
+#include <apt-pkg/depcache.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/strutl.h>
 
 
-#include <limits>
+#include <ctype.h>
+#include <stddef.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
 #include <stdio.h>
 #include <stdio.h>
-
+#include <iostream>
+#include <vector>
+#include <limits>
 #include <string>
 #include <string>
+#include <list>
 
 
 #include <apti18n.h>
 #include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
@@ -44,7 +53,7 @@ bool EDSP::WriteScenario(pkgDepCache &Cache, FILE* output, OpProgress *Progress)
       for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() == false; ++Ver, ++p)
       for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() == false; ++Ver, ++p)
       {
       {
 	 WriteScenarioVersion(Cache, output, Pkg, Ver);
 	 WriteScenarioVersion(Cache, output, Pkg, Ver);
-	 WriteScenarioDependency(Cache, output, Pkg, Ver);
+	 WriteScenarioDependency(output, Ver);
 	 fprintf(output, "\n");
 	 fprintf(output, "\n");
 	 if (Progress != NULL && p % 100 == 0)
 	 if (Progress != NULL && p % 100 == 0)
 	    Progress->Progress(p);
 	    Progress->Progress(p);
@@ -64,7 +73,7 @@ bool EDSP::WriteLimitedScenario(pkgDepCache &Cache, FILE* output,
       for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() == false; ++Ver)
       for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() == false; ++Ver)
       {
       {
 	 WriteScenarioVersion(Cache, output, Pkg, Ver);
 	 WriteScenarioVersion(Cache, output, Pkg, Ver);
-	 WriteScenarioLimitedDependency(Cache, output, Pkg, Ver, pkgset);
+	 WriteScenarioLimitedDependency(output, Ver, pkgset);
 	 fprintf(output, "\n");
 	 fprintf(output, "\n");
 	 if (Progress != NULL && p % 100 == 0)
 	 if (Progress != NULL && p % 100 == 0)
 	    Progress->Progress(p);
 	    Progress->Progress(p);
@@ -111,8 +120,7 @@ void EDSP::WriteScenarioVersion(pkgDepCache &Cache, FILE* output, pkgCache::PkgI
 }
 }
 									/*}}}*/
 									/*}}}*/
 // EDSP::WriteScenarioDependency					/*{{{*/
 // EDSP::WriteScenarioDependency					/*{{{*/
-void EDSP::WriteScenarioDependency(pkgDepCache &Cache, FILE* output, pkgCache::PkgIterator const &Pkg,
-				pkgCache::VerIterator const &Ver)
+void EDSP::WriteScenarioDependency( FILE* output, pkgCache::VerIterator const &Ver)
 {
 {
    std::string dependencies[pkgCache::Dep::Enhances + 1];
    std::string dependencies[pkgCache::Dep::Enhances + 1];
    bool orGroup = false;
    bool orGroup = false;
@@ -148,8 +156,7 @@ void EDSP::WriteScenarioDependency(pkgDepCache &Cache, FILE* output, pkgCache::P
 }
 }
 									/*}}}*/
 									/*}}}*/
 // EDSP::WriteScenarioLimitedDependency					/*{{{*/
 // EDSP::WriteScenarioLimitedDependency					/*{{{*/
-void EDSP::WriteScenarioLimitedDependency(pkgDepCache &Cache, FILE* output,
-					  pkgCache::PkgIterator const &Pkg,
+void EDSP::WriteScenarioLimitedDependency(FILE* output,
 					  pkgCache::VerIterator const &Ver,
 					  pkgCache::VerIterator const &Ver,
 					  APT::PackageSet const &pkgset)
 					  APT::PackageSet const &pkgset)
 {
 {

+ 6 - 5
apt-pkg/edsp.h

@@ -9,8 +9,11 @@
 #ifndef PKGLIB_EDSP_H
 #ifndef PKGLIB_EDSP_H
 #define PKGLIB_EDSP_H
 #define PKGLIB_EDSP_H
 
 
-#include <apt-pkg/pkgcache.h>
 #include <apt-pkg/cacheset.h>
 #include <apt-pkg/cacheset.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+
+#include <stdio.h>
 
 
 #include <list>
 #include <list>
 #include <string>
 #include <string>
@@ -35,11 +38,9 @@ class EDSP								/*{{{*/
 	void static WriteScenarioVersion(pkgDepCache &Cache, FILE* output,
 	void static WriteScenarioVersion(pkgDepCache &Cache, FILE* output,
 					 pkgCache::PkgIterator const &Pkg,
 					 pkgCache::PkgIterator const &Pkg,
 					 pkgCache::VerIterator const &Ver);
 					 pkgCache::VerIterator const &Ver);
-	void static WriteScenarioDependency(pkgDepCache &Cache, FILE* output,
-					    pkgCache::PkgIterator const &Pkg,
+	void static WriteScenarioDependency(FILE* output,
 					    pkgCache::VerIterator const &Ver);
 					    pkgCache::VerIterator const &Ver);
-	void static WriteScenarioLimitedDependency(pkgDepCache &Cache, FILE* output,
-						   pkgCache::PkgIterator const &Pkg,
+	void static WriteScenarioLimitedDependency(FILE* output,
 						   pkgCache::VerIterator const &Ver,
 						   pkgCache::VerIterator const &Ver,
 						   APT::PackageSet const &pkgset);
 						   APT::PackageSet const &pkgset);
 public:
 public:

+ 12 - 7
apt-pkg/edsp/edspindexfile.cc

@@ -10,15 +10,20 @@
 
 
 #include <apt-pkg/edspindexfile.h>
 #include <apt-pkg/edspindexfile.h>
 #include <apt-pkg/edsplistparser.h>
 #include <apt-pkg/edsplistparser.h>
-#include <apt-pkg/sourcelist.h>
-#include <apt-pkg/configuration.h>
-#include <apt-pkg/progress.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
-#include <apt-pkg/strutl.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
-#include <apt-pkg/acquire-item.h>
+#include <apt-pkg/progress.h>
+#include <apt-pkg/debindexfile.h>
+#include <apt-pkg/indexfile.h>
+#include <apt-pkg/mmap.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/pkgcachegen.h>
+#include <apt-pkg/pkgrecords.h>
 
 
-#include <sys/stat.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <string>
 									/*}}}*/
 									/*}}}*/
 
 
 // edspIndex::edspIndex - Constructor					/*{{{*/
 // edspIndex::edspIndex - Constructor					/*{{{*/
@@ -63,7 +68,7 @@ bool edspIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
 class edspIFType: public pkgIndexFile::Type
 class edspIFType: public pkgIndexFile::Type
 {
 {
    public:
    public:
-   virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator File) const
+   virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator) const
    {
    {
       // we don't have a record parser for this type as the file is not presistent
       // we don't have a record parser for this type as the file is not presistent
       return NULL;
       return NULL;

+ 5 - 1
apt-pkg/edsp/edspindexfile.h

@@ -9,11 +9,15 @@
 #define PKGLIB_EDSPINDEXFILE_H
 #define PKGLIB_EDSPINDEXFILE_H
 
 
 #include <apt-pkg/debindexfile.h>
 #include <apt-pkg/debindexfile.h>
+#include <string>
 
 
 #ifndef APT_8_CLEANER_HEADERS
 #ifndef APT_8_CLEANER_HEADERS
 #include <apt-pkg/indexfile.h>
 #include <apt-pkg/indexfile.h>
 #endif
 #endif
 
 
+class OpProgress;
+class pkgCacheGenerator;
+
 class edspIndex : public debStatusIndex
 class edspIndex : public debStatusIndex
 {
 {
    /** \brief dpointer placeholder (for later in case we need it) */
    /** \brief dpointer placeholder (for later in case we need it) */
@@ -21,7 +25,7 @@ class edspIndex : public debStatusIndex
 
 
    public:
    public:
 
 
-   virtual const Type *GetType() const;
+   virtual const Type *GetType() const APT_CONST;
 
 
    virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
    virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
 
 

+ 8 - 6
apt-pkg/edsp/edsplistparser.cc

@@ -12,11 +12,13 @@
 #include <config.h>
 #include <config.h>
 
 
 #include <apt-pkg/edsplistparser.h>
 #include <apt-pkg/edsplistparser.h>
-#include <apt-pkg/error.h>
-#include <apt-pkg/configuration.h>
-#include <apt-pkg/strutl.h>
 #include <apt-pkg/md5.h>
 #include <apt-pkg/md5.h>
-#include <apt-pkg/macros.h>
+#include <apt-pkg/deblistparser.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/tagfile.h>
+
+#include <string>
 									/*}}}*/
 									/*}}}*/
 
 
 // ListParser::edspListParser - Constructor				/*{{{*/
 // ListParser::edspListParser - Constructor				/*{{{*/
@@ -84,8 +86,8 @@ bool edspListParser::ParseStatus(pkgCache::PkgIterator &Pkg,
 }
 }
 									/*}}}*/
 									/*}}}*/
 // ListParser::LoadReleaseInfo - Load the release information		/*{{{*/
 // ListParser::LoadReleaseInfo - Load the release information		/*{{{*/
-bool edspListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
-				    FileFd &File, std::string component)
+APT_CONST bool edspListParser::LoadReleaseInfo(pkgCache::PkgFileIterator & /*FileI*/,
+				    FileFd & /*File*/, std::string /*component*/)
 {
 {
    return true;
    return true;
 }
 }

+ 4 - 0
apt-pkg/edsp/edsplistparser.h

@@ -12,6 +12,10 @@
 #define PKGLIB_EDSPLISTPARSER_H
 #define PKGLIB_EDSPLISTPARSER_H
 
 
 #include <apt-pkg/deblistparser.h>
 #include <apt-pkg/deblistparser.h>
+#include <apt-pkg/md5.h>
+#include <apt-pkg/pkgcache.h>
+
+#include <string>
 
 
 #ifndef APT_8_CLEANER_HEADERS
 #ifndef APT_8_CLEANER_HEADERS
 #include <apt-pkg/pkgcachegen.h>
 #include <apt-pkg/pkgcachegen.h>

+ 11 - 10
apt-pkg/edsp/edspsystem.cc

@@ -11,16 +11,17 @@
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
 #include <config.h>
 #include <config.h>
 
 
-#include <apt-pkg/edspsystem.h>
+#include <apt-pkg/configuration.h>
 #include <apt-pkg/debversion.h>
 #include <apt-pkg/debversion.h>
 #include <apt-pkg/edspindexfile.h>
 #include <apt-pkg/edspindexfile.h>
-#include <apt-pkg/configuration.h>
-#include <apt-pkg/error.h>
+#include <apt-pkg/edspsystem.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <dirent.h>
-#include <errno.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+
+#include <stddef.h>
+#include <string>
+#include <vector>
 
 
 #include <apti18n.h>
 #include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
@@ -49,7 +50,7 @@ bool edspSystem::Lock()
 }
 }
 									/*}}}*/
 									/*}}}*/
 // System::UnLock - Drop a lock						/*{{{*/
 // System::UnLock - Drop a lock						/*{{{*/
-bool edspSystem::UnLock(bool NoErrors)
+bool edspSystem::UnLock(bool /*NoErrors*/)
 {
 {
    return true;
    return true;
 }
 }
@@ -58,7 +59,7 @@ bool edspSystem::UnLock(bool NoErrors)
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* we can't use edsp input as input for real installations - just a
 /* we can't use edsp input as input for real installations - just a
    simulation can work, but everything else will fail bigtime */
    simulation can work, but everything else will fail bigtime */
-pkgPackageManager *edspSystem::CreatePM(pkgDepCache *Cache) const
+pkgPackageManager *edspSystem::CreatePM(pkgDepCache * /*Cache*/) const
 {
 {
    return NULL;
    return NULL;
 }
 }
@@ -81,7 +82,7 @@ bool edspSystem::Initialize(Configuration &Cnf)
 }
 }
 									/*}}}*/
 									/*}}}*/
 // System::ArchiveSupported - Is a file format supported		/*{{{*/
 // System::ArchiveSupported - Is a file format supported		/*{{{*/
-bool edspSystem::ArchiveSupported(const char *Type)
+bool edspSystem::ArchiveSupported(const char * /*Type*/)
 {
 {
    return false;
    return false;
 }
 }

+ 13 - 4
apt-pkg/edsp/edspsystem.h

@@ -11,8 +11,17 @@
 #define PKGLIB_EDSPSYSTEM_H
 #define PKGLIB_EDSPSYSTEM_H
 
 
 #include <apt-pkg/pkgsystem.h>
 #include <apt-pkg/pkgsystem.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/pkgcache.h>
 
 
+#include <vector>
+
+class Configuration;
+class pkgDepCache;
+class pkgIndexFile;
+class pkgPackageManager;
 class edspIndex;
 class edspIndex;
+
 class edspSystem : public pkgSystem
 class edspSystem : public pkgSystem
 {
 {
    /** \brief dpointer placeholder (for later in case we need it) */
    /** \brief dpointer placeholder (for later in case we need it) */
@@ -22,11 +31,11 @@ class edspSystem : public pkgSystem
 
 
    public:
    public:
 
 
-   virtual bool Lock();
-   virtual bool UnLock(bool NoErrors = false);
-   virtual pkgPackageManager *CreatePM(pkgDepCache *Cache) const;
+   virtual bool Lock() APT_CONST;
+   virtual bool UnLock(bool NoErrors = false) APT_CONST;
+   virtual pkgPackageManager *CreatePM(pkgDepCache *Cache) const APT_CONST;
    virtual bool Initialize(Configuration &Cnf);
    virtual bool Initialize(Configuration &Cnf);
-   virtual bool ArchiveSupported(const char *Type);
+   virtual bool ArchiveSupported(const char *Type) APT_CONST;
    virtual signed Score(Configuration const &Cnf);
    virtual signed Score(Configuration const &Cnf);
    virtual bool AddStatusFiles(std::vector<pkgIndexFile *> &List);
    virtual bool AddStatusFiles(std::vector<pkgIndexFile *> &List);
    virtual bool FindIndex(pkgCache::PkgFileIterator File,
    virtual bool FindIndex(pkgCache::PkgFileIterator File,

+ 18 - 20
apt-pkg/indexcopy.cc

@@ -20,17 +20,17 @@
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/tagfile.h>
 #include <apt-pkg/tagfile.h>
 #include <apt-pkg/indexrecords.h>
 #include <apt-pkg/indexrecords.h>
-#include <apt-pkg/md5.h>
 #include <apt-pkg/cdrom.h>
 #include <apt-pkg/cdrom.h>
+#include <apt-pkg/gpgv.h>
+#include <apt-pkg/hashes.h>
 
 
 #include <iostream>
 #include <iostream>
 #include <sstream>
 #include <sstream>
 #include <unistd.h>
 #include <unistd.h>
 #include <sys/stat.h>
 #include <sys/stat.h>
-#include <sys/types.h>
-#include <fcntl.h>
 #include <stdio.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdlib.h>
+#include <string.h>
 
 
 #include "indexcopy.h"
 #include "indexcopy.h"
 #include <apti18n.h>
 #include <apti18n.h>
@@ -65,7 +65,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List,
       for (std::vector<APT::Configuration::Compressor>::const_iterator c = compressor.begin();
       for (std::vector<APT::Configuration::Compressor>::const_iterator c = compressor.begin();
 	   c != compressor.end(); ++c)
 	   c != compressor.end(); ++c)
       {
       {
-	 if (stat(std::string(file + c->Extension).c_str(), &Buf) != 0)
+	 if (stat((file + c->Extension).c_str(), &Buf) != 0)
 	    continue;
 	    continue;
 	 found = true;
 	 found = true;
 	 break;
 	 break;
@@ -160,7 +160,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List,
 	    
 	    
 	    // Get the size
 	    // Get the size
 	    struct stat Buf;
 	    struct stat Buf;
-	    if (stat(string(CDROM + Prefix + File).c_str(),&Buf) != 0 || 
+	    if (stat((CDROM + Prefix + File).c_str(),&Buf) != 0 || 
 		Buf.st_size == 0)
 		Buf.st_size == 0)
 	    {
 	    {
 	       bool Mangled = false;
 	       bool Mangled = false;
@@ -175,7 +175,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List,
 	       }
 	       }
 	       
 	       
 	       if (Mangled == false ||
 	       if (Mangled == false ||
-		   stat(string(CDROM + Prefix + File).c_str(),&Buf) != 0)
+		   stat((CDROM + Prefix + File).c_str(),&Buf) != 0)
 	       {
 	       {
 		  if (Debug == true)
 		  if (Debug == true)
 		     clog << "Missed(2): " << OrigFile << endl;
 		     clog << "Missed(2): " << OrigFile << endl;
@@ -286,7 +286,7 @@ bool IndexCopy::ReconstructPrefix(string &Prefix,string OrigPath,string CD,
    while (1)
    while (1)
    {
    {
       struct stat Buf;
       struct stat Buf;
-      if (stat(string(CD + MyPrefix + File).c_str(),&Buf) != 0)
+      if (stat((CD + MyPrefix + File).c_str(),&Buf) != 0)
       {
       {
 	 if (Debug == true)
 	 if (Debug == true)
 	    cout << "Failed, " << CD + MyPrefix + File << endl;
 	    cout << "Failed, " << CD + MyPrefix + File << endl;
@@ -315,7 +315,7 @@ bool IndexCopy::ReconstructChop(unsigned long &Chop,string Dir,string File)
    while (1)
    while (1)
    {
    {
       struct stat Buf;
       struct stat Buf;
-      if (stat(string(Dir + File).c_str(),&Buf) != 0)
+      if (stat((Dir + File).c_str(),&Buf) != 0)
       {
       {
 	 File = ChopDirs(File,1);
 	 File = ChopDirs(File,1);
 	 Depth++;
 	 Depth++;
@@ -436,8 +436,8 @@ bool PackageCopy::GetFile(string &File,unsigned long long &Size)
 /* */
 /* */
 bool PackageCopy::RewriteEntry(FILE *Target,string File)
 bool PackageCopy::RewriteEntry(FILE *Target,string File)
 {
 {
-   TFRewriteData Changes[] = {{"Filename",File.c_str()},
-                              {}};
+   TFRewriteData Changes[] = {{ "Filename", File.c_str(), NULL },
+                              { NULL, NULL, NULL }};
    
    
    if (TFRewrite(Target,*Section,TFRewritePackageOrder,Changes) == false)
    if (TFRewrite(Target,*Section,TFRewritePackageOrder,Changes) == false)
       return false;
       return false;
@@ -482,8 +482,8 @@ bool SourceCopy::GetFile(string &File,unsigned long long &Size)
 bool SourceCopy::RewriteEntry(FILE *Target,string File)
 bool SourceCopy::RewriteEntry(FILE *Target,string File)
 {
 {
    string Dir(File,0,File.rfind('/'));
    string Dir(File,0,File.rfind('/'));
-   TFRewriteData Changes[] = {{"Directory",Dir.c_str()},
-                              {}};
+   TFRewriteData Changes[] = {{ "Directory", Dir.c_str(), NULL },
+                              { NULL, NULL, NULL }};
    
    
    if (TFRewrite(Target,*Section,TFRewriteSourceOrder,Changes) == false)
    if (TFRewrite(Target,*Section,TFRewriteSourceOrder,Changes) == false)
       return false;
       return false;
@@ -551,7 +551,7 @@ bool SigVerify::CopyMetaIndex(string CDROM, string CDName,		/*{{{*/
 }
 }
 									/*}}}*/
 									/*}}}*/
 bool SigVerify::CopyAndVerify(string CDROM,string Name,vector<string> &SigList,	/*{{{*/
 bool SigVerify::CopyAndVerify(string CDROM,string Name,vector<string> &SigList,	/*{{{*/
-			      vector<string> PkgList,vector<string> SrcList)
+			      vector<string> /*PkgList*/,vector<string> /*SrcList*/)
 {
 {
    if (SigList.empty() == true)
    if (SigList.empty() == true)
       return true;
       return true;
@@ -642,16 +642,14 @@ bool SigVerify::CopyAndVerify(string CDROM,string Name,vector<string> &SigList,
 }
 }
 									/*}}}*/
 									/*}}}*/
 // SigVerify::RunGPGV - deprecated wrapper calling ExecGPGV		/*{{{*/
 // SigVerify::RunGPGV - deprecated wrapper calling ExecGPGV		/*{{{*/
-bool SigVerify::RunGPGV(std::string const &File, std::string const &FileOut,
+APT_NORETURN bool SigVerify::RunGPGV(std::string const &File, std::string const &FileOut,
       int const &statusfd, int fd[2]) {
       int const &statusfd, int fd[2]) {
    ExecGPGV(File, FileOut, statusfd, fd);
    ExecGPGV(File, FileOut, statusfd, fd);
-   return false;
-};
-bool SigVerify::RunGPGV(std::string const &File, std::string const &FileOut,
+}
+APT_NORETURN bool SigVerify::RunGPGV(std::string const &File, std::string const &FileOut,
       int const &statusfd) {
       int const &statusfd) {
    ExecGPGV(File, FileOut, statusfd);
    ExecGPGV(File, FileOut, statusfd);
-   return false;
-};
+}
 									/*}}}*/
 									/*}}}*/
 bool TranslationsCopy::CopyTranslations(string CDROM,string Name,	/*{{{*/
 bool TranslationsCopy::CopyTranslations(string CDROM,string Name,	/*{{{*/
 				vector<string> &List, pkgCdromStatus *log)
 				vector<string> &List, pkgCdromStatus *log)
@@ -676,7 +674,7 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name,	/*{{{*/
       for (std::vector<APT::Configuration::Compressor>::const_iterator c = compressor.begin();
       for (std::vector<APT::Configuration::Compressor>::const_iterator c = compressor.begin();
 	   c != compressor.end(); ++c)
 	   c != compressor.end(); ++c)
       {
       {
-	 if (stat(std::string(file + c->Extension).c_str(), &Buf) != 0)
+	 if (stat((file + c->Extension).c_str(), &Buf) != 0)
 	    continue;
 	    continue;
 	 found = true;
 	 found = true;
 	 break;
 	 break;

+ 6 - 4
apt-pkg/indexcopy.h

@@ -14,16 +14,18 @@
 #include <string>
 #include <string>
 #include <stdio.h>
 #include <stdio.h>
 
 
-#include <apt-pkg/gpgv.h>
 #include <apt-pkg/macros.h>
 #include <apt-pkg/macros.h>
 
 
+#ifndef APT_10_CLEANER_HEADERS
+#include <apt-pkg/gpgv.h>
+class FileFd;
+#endif
 #ifndef APT_8_CLEANER_HEADERS
 #ifndef APT_8_CLEANER_HEADERS
 using std::string;
 using std::string;
 using std::vector;
 using std::vector;
 #endif
 #endif
 
 
 class pkgTagSection;
 class pkgTagSection;
-class FileFd;
 class indexRecords;
 class indexRecords;
 class pkgCdromStatus;
 class pkgCdromStatus;
 
 
@@ -99,9 +101,9 @@ class SigVerify								/*{{{*/
    bool CopyAndVerify(std::string CDROM,std::string Name,std::vector<std::string> &SigList,
    bool CopyAndVerify(std::string CDROM,std::string Name,std::vector<std::string> &SigList,
 		      std::vector<std::string> PkgList,std::vector<std::string> SrcList);
 		      std::vector<std::string> PkgList,std::vector<std::string> SrcList);
 
 
-   __deprecated static bool RunGPGV(std::string const &File, std::string const &FileOut,
+   APT_DEPRECATED static bool RunGPGV(std::string const &File, std::string const &FileOut,
 		       int const &statusfd, int fd[2]);
 		       int const &statusfd, int fd[2]);
-   __deprecated static bool RunGPGV(std::string const &File, std::string const &FileOut,
+   APT_DEPRECATED static bool RunGPGV(std::string const &File, std::string const &FileOut,
 			      int const &statusfd = -1);
 			      int const &statusfd = -1);
 };
 };
 									/*}}}*/
 									/*}}}*/

+ 11 - 5
apt-pkg/indexfile.cc

@@ -13,7 +13,13 @@
 #include <apt-pkg/indexfile.h>
 #include <apt-pkg/indexfile.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/aptconfiguration.h>
 #include <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/srcrecords.h>
+#include <apt-pkg/macros.h>
 
 
+#include <string>
+#include <vector>
 #include <clocale>
 #include <clocale>
 #include <cstring>
 #include <cstring>
 									/*}}}*/
 									/*}}}*/
@@ -47,7 +53,7 @@ pkgIndexFile::Type *pkgIndexFile::Type::GetType(const char *Type)
 // IndexFile::ArchiveInfo - Stub					/*{{{*/
 // IndexFile::ArchiveInfo - Stub					/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-std::string pkgIndexFile::ArchiveInfo(pkgCache::VerIterator Ver) const
+std::string pkgIndexFile::ArchiveInfo(pkgCache::VerIterator /*Ver*/) const
 {
 {
    return std::string();
    return std::string();
 }
 }
@@ -63,8 +69,8 @@ pkgCache::PkgFileIterator pkgIndexFile::FindInCache(pkgCache &Cache) const
 // IndexFile::SourceIndex - Stub					/*{{{*/
 // IndexFile::SourceIndex - Stub					/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-std::string pkgIndexFile::SourceInfo(pkgSrcRecords::Parser const &Record,
-				pkgSrcRecords::File const &File) const
+std::string pkgIndexFile::SourceInfo(pkgSrcRecords::Parser const &/*Record*/,
+				pkgSrcRecords::File const &/*File*/) const
 {
 {
    return std::string();
    return std::string();
 }
 }
@@ -82,7 +88,7 @@ bool pkgIndexFile::TranslationsAvailable() {
    is already done in getLanguages(). Note also that this check is
    is already done in getLanguages(). Note also that this check is
    rather bad (doesn't take three character like ast into account).
    rather bad (doesn't take three character like ast into account).
    TODO: Remove method with next API break */
    TODO: Remove method with next API break */
-__attribute__ ((deprecated)) bool pkgIndexFile::CheckLanguageCode(const char *Lang)
+APT_DEPRECATED bool pkgIndexFile::CheckLanguageCode(const char *Lang)
 {
 {
   if (strlen(Lang) == 2 || (strlen(Lang) == 5 && Lang[2] == '_'))
   if (strlen(Lang) == 2 || (strlen(Lang) == 5 && Lang[2] == '_'))
     return true;
     return true;
@@ -98,7 +104,7 @@ __attribute__ ((deprecated)) bool pkgIndexFile::CheckLanguageCode(const char *La
 /* As we have now possibly more than one LanguageCode this method is
 /* As we have now possibly more than one LanguageCode this method is
    supersided by a) private classmembers or b) getLanguages().
    supersided by a) private classmembers or b) getLanguages().
    TODO: Remove method with next API break */
    TODO: Remove method with next API break */
-__attribute__ ((deprecated)) std::string pkgIndexFile::LanguageCode() {
+APT_DEPRECATED std::string pkgIndexFile::LanguageCode() {
 	if (TranslationsAvailable() == false)
 	if (TranslationsAvailable() == false)
 		return "";
 		return "";
 	return APT::Configuration::getLanguages()[0];
 	return APT::Configuration::getLanguages()[0];

+ 12 - 9
apt-pkg/indexfile.h

@@ -22,18 +22,21 @@
 #ifndef PKGLIB_INDEXFILE_H
 #ifndef PKGLIB_INDEXFILE_H
 #define PKGLIB_INDEXFILE_H
 #define PKGLIB_INDEXFILE_H
 
 
-
-#include <string>
-#include <apt-pkg/pkgcache.h>
 #include <apt-pkg/srcrecords.h>
 #include <apt-pkg/srcrecords.h>
 #include <apt-pkg/pkgrecords.h>
 #include <apt-pkg/pkgrecords.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
 #include <apt-pkg/macros.h>
 #include <apt-pkg/macros.h>
 
 
+#include <string>
+
 #ifndef APT_8_CLEANER_HEADERS
 #ifndef APT_8_CLEANER_HEADERS
 using std::string;
 using std::string;
 #endif
 #endif
-
+#ifndef APT_10_CLEANER_HEADERS
 class pkgAcquire;
 class pkgAcquire;
+#endif
+
 class pkgCacheGenerator;
 class pkgCacheGenerator;
 class OpProgress;
 class OpProgress;
 
 
@@ -51,7 +54,7 @@ class pkgIndexFile
       // Global list of Items supported
       // Global list of Items supported
       static Type **GlobalList;
       static Type **GlobalList;
       static unsigned long GlobalListLen;
       static unsigned long GlobalListLen;
-      static Type *GetType(const char *Type);
+      static Type *GetType(const char *Type) APT_PURE;
 
 
       const char *Label;
       const char *Label;
 
 
@@ -78,11 +81,11 @@ class pkgIndexFile
    virtual bool Exists() const = 0;
    virtual bool Exists() const = 0;
    virtual bool HasPackages() const = 0;
    virtual bool HasPackages() const = 0;
    virtual unsigned long Size() const = 0;
    virtual unsigned long Size() const = 0;
-   virtual bool Merge(pkgCacheGenerator &Gen, OpProgress* Prog) const { return false; };
-   __deprecated virtual bool Merge(pkgCacheGenerator &Gen, OpProgress &Prog) const
+   virtual bool Merge(pkgCacheGenerator &/*Gen*/, OpProgress* /*Prog*/) const { return false; };
+   APT_DEPRECATED virtual bool Merge(pkgCacheGenerator &Gen, OpProgress &Prog) const
       { return Merge(Gen, &Prog); };
       { return Merge(Gen, &Prog); };
-   virtual bool MergeFileProvides(pkgCacheGenerator &Gen,OpProgress* Prog) const {return true;};
-   __deprecated virtual bool MergeFileProvides(pkgCacheGenerator &Gen, OpProgress &Prog) const
+   virtual bool MergeFileProvides(pkgCacheGenerator &/*Gen*/,OpProgress* /*Prog*/) const {return true;};
+   APT_DEPRECATED virtual bool MergeFileProvides(pkgCacheGenerator &Gen, OpProgress &Prog) const
       {return MergeFileProvides(Gen, &Prog);};
       {return MergeFileProvides(Gen, &Prog);};
    virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
    virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
 
 

+ 15 - 10
apt-pkg/indexrecords.cc

@@ -14,41 +14,46 @@
 #include <apt-pkg/hashes.h>
 #include <apt-pkg/hashes.h>
 #include <apt-pkg/gpgv.h>
 #include <apt-pkg/gpgv.h>
 
 
-#include <sys/stat.h>
+#include <stdlib.h>
+#include <time.h>
 #include <clocale>
 #include <clocale>
+#include <map>
+#include <string>
+#include <utility>
+#include <vector>
 
 
 #include <apti18n.h>
 #include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
 
 
 using std::string;
 using std::string;
 
 
-string indexRecords::GetDist() const
+APT_PURE string indexRecords::GetDist() const
 {
 {
    return this->Dist;
    return this->Dist;
 }
 }
 
 
-string indexRecords::GetSuite() const
+APT_PURE string indexRecords::GetSuite() const
 {
 {
    return this->Suite;
    return this->Suite;
 }
 }
 
 
-bool indexRecords::CheckDist(const string MaybeDist) const
+APT_PURE bool indexRecords::CheckDist(const string MaybeDist) const
 {
 {
    return (this->Dist == MaybeDist
    return (this->Dist == MaybeDist
 	   || this->Suite == MaybeDist);
 	   || this->Suite == MaybeDist);
 }
 }
 
 
-string indexRecords::GetExpectedDist() const
+APT_PURE string indexRecords::GetExpectedDist() const
 {
 {
    return this->ExpectedDist;
    return this->ExpectedDist;
 }
 }
 
 
-time_t indexRecords::GetValidUntil() const
+APT_PURE time_t indexRecords::GetValidUntil() const
 {
 {
    return this->ValidUntil;
    return this->ValidUntil;
 }
 }
 
 
-const indexRecords::checkSum *indexRecords::Lookup(const string MetaKey)
+APT_PURE const indexRecords::checkSum *indexRecords::Lookup(const string MetaKey)
 {
 {
    std::map<std::string, indexRecords::checkSum* >::const_iterator sum = Entries.find(MetaKey);
    std::map<std::string, indexRecords::checkSum* >::const_iterator sum = Entries.find(MetaKey);
    if (sum == Entries.end())
    if (sum == Entries.end())
@@ -56,7 +61,7 @@ const indexRecords::checkSum *indexRecords::Lookup(const string MetaKey)
    return sum->second;
    return sum->second;
 }
 }
 
 
-bool indexRecords::Exists(string const &MetaKey) const
+APT_PURE bool indexRecords::Exists(string const &MetaKey) const
 {
 {
    return Entries.count(MetaKey) == 1;
    return Entries.count(MetaKey) == 1;
 }
 }
@@ -129,10 +134,10 @@ bool indexRecords::Load(const string Filename)				/*{{{*/
    // get the user settings for this archive and use what expires earlier
    // get the user settings for this archive and use what expires earlier
    int MaxAge = _config->FindI("Acquire::Max-ValidTime", 0);
    int MaxAge = _config->FindI("Acquire::Max-ValidTime", 0);
    if (Label.empty() == false)
    if (Label.empty() == false)
-      MaxAge = _config->FindI(string("Acquire::Max-ValidTime::" + Label).c_str(), MaxAge);
+      MaxAge = _config->FindI(("Acquire::Max-ValidTime::" + Label).c_str(), MaxAge);
    int MinAge = _config->FindI("Acquire::Min-ValidTime", 0);
    int MinAge = _config->FindI("Acquire::Min-ValidTime", 0);
    if (Label.empty() == false)
    if (Label.empty() == false)
-      MinAge = _config->FindI(string("Acquire::Min-ValidTime::" + Label).c_str(), MinAge);
+      MinAge = _config->FindI(("Acquire::Min-ValidTime::" + Label).c_str(), MinAge);
 
 
    if(MaxAge == 0 &&
    if(MaxAge == 0 &&
       (MinAge == 0 || ValidUntil == 0)) // No user settings, use the one from the Release file
       (MinAge == 0 || ValidUntil == 0)) // No user settings, use the one from the Release file

+ 4 - 2
apt-pkg/indexrecords.h

@@ -5,17 +5,19 @@
 #ifndef PKGLIB_INDEXRECORDS_H
 #ifndef PKGLIB_INDEXRECORDS_H
 #define PKGLIB_INDEXRECORDS_H
 #define PKGLIB_INDEXRECORDS_H
 
 
-
-#include <apt-pkg/pkgcache.h>
 #include <apt-pkg/hashes.h>
 #include <apt-pkg/hashes.h>
 
 
 #include <map>
 #include <map>
 #include <vector>
 #include <vector>
 #include <ctime>
 #include <ctime>
+#include <string>
 
 
 #ifndef APT_8_CLEANER_HEADERS
 #ifndef APT_8_CLEANER_HEADERS
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
 #endif
 #endif
+#ifndef APT_10_CLEANER_HEADERS
+#include <apt-pkg/pkgcache.h>
+#endif
 
 
 class indexRecords
 class indexRecords
 {
 {

+ 3 - 1
apt-pkg/init.cc

@@ -15,9 +15,11 @@
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/pkgsystem.h>
 #include <apt-pkg/pkgsystem.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
+#include <apt-pkg/macros.h>
 
 
+#include <string.h>
+#include <string>
 #include <cstdlib>
 #include <cstdlib>
-#include <sys/stat.h>
 
 
 #include <apti18n.h>
 #include <apti18n.h>
 									/*}}}*/
 									/*}}}*/

+ 3 - 10
apt-pkg/init.h

@@ -1,6 +1,5 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: init.h,v 1.9.2.2 2004/01/02 18:51:00 mdz Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Init - Initialize the package library
    Init - Initialize the package library
@@ -17,19 +16,13 @@
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/pkgsystem.h>
 #include <apt-pkg/pkgsystem.h>
 #endif
 #endif
+#ifndef APT_10_CLEANER_HEADERS
+#include <apt-pkg/macros.h>
+#endif
 
 
 class pkgSystem;
 class pkgSystem;
 class Configuration;
 class Configuration;
 
 
-// These lines are extracted by the makefiles and the buildsystem
-// Increasing MAJOR or MINOR results in the need of recompiling all
-// reverse-dependencies of libapt-pkg against the new SONAME.
-// Non-ABI-Breaks should only increase RELEASE number.
-// See also buildlib/libversion.mak
-#define APT_PKG_MAJOR 4
-#define APT_PKG_MINOR 12
-#define APT_PKG_RELEASE 0
-    
 extern const char *pkgVersion;
 extern const char *pkgVersion;
 extern const char *pkgLibVersion;
 extern const char *pkgLibVersion;
 
 

+ 24 - 18
apt-pkg/install-progress.cc

@@ -1,17 +1,23 @@
+#include <config.h>
+
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/install-progress.h>
 #include <apt-pkg/install-progress.h>
 
 
-#include <apti18n.h>
-
-#include <termios.h>
+#include <signal.h>
+#include <unistd.h>
+#include <iostream>
+#include <string>
+#include <vector>
 #include <sys/ioctl.h>
 #include <sys/ioctl.h>
 #include <sstream>
 #include <sstream>
 #include <fcntl.h>
 #include <fcntl.h>
 #include <algorithm>
 #include <algorithm>
 #include <stdio.h>
 #include <stdio.h>
 
 
+#include <apti18n.h>
+
 namespace APT {
 namespace APT {
 namespace Progress {
 namespace Progress {
 
 
@@ -41,10 +47,10 @@ PackageManager* PackageManagerProgressFactory()
    return progress;
    return progress;
 }
 }
 
 
-bool PackageManager::StatusChanged(std::string PackageName, 
+bool PackageManager::StatusChanged(std::string /*PackageName*/,
                                    unsigned int StepsDone,
                                    unsigned int StepsDone,
                                    unsigned int TotalSteps,
                                    unsigned int TotalSteps,
-                                   std::string HumanReadableAction)
+                                   std::string /*HumanReadableAction*/)
 {
 {
    int reporting_steps = _config->FindI("DpkgPM::Reporting-Steps", 1);
    int reporting_steps = _config->FindI("DpkgPM::Reporting-Steps", 1);
    percentage = StepsDone/(float)TotalSteps * 100.0;
    percentage = StepsDone/(float)TotalSteps * 100.0;
@@ -87,7 +93,7 @@ void PackageManagerProgressFd::StartDpkg()
    WriteToStatusFd(status.str());
    WriteToStatusFd(status.str());
 }
 }
 
 
-void PackageManagerProgressFd::Stop()
+APT_CONST void PackageManagerProgressFd::Stop()
 {
 {
 }
 }
 
 
@@ -170,7 +176,7 @@ void PackageManagerProgressDeb822Fd::StartDpkg()
    WriteToStatusFd(status.str());
    WriteToStatusFd(status.str());
 }
 }
 
 
-void PackageManagerProgressDeb822Fd::Stop()
+APT_CONST void PackageManagerProgressDeb822Fd::Stop()
 {
 {
 }
 }
 
 
@@ -329,15 +335,15 @@ bool PackageManagerFancy::StatusChanged(std::string PackageName,
 
 
    int row = GetNumberTerminalRows();
    int row = GetNumberTerminalRows();
 
 
-   static string save_cursor = "\033[s";
-   static string restore_cursor = "\033[u";
-   
-   static string set_bg_color = "\033[42m"; // green
-   static string set_fg_color = "\033[30m"; // black
-   
-   static string restore_bg =  "\033[49m";
-   static string restore_fg = "\033[39m";
-   
+   static std::string save_cursor = "\033[s";
+   static std::string restore_cursor = "\033[u";
+
+   static std::string set_bg_color = "\033[42m"; // green
+   static std::string set_fg_color = "\033[30m"; // black
+
+   static std::string restore_bg =  "\033[49m";
+   static std::string restore_fg = "\033[39m";
+
    std::cout << save_cursor
    std::cout << save_cursor
       // move cursor position to last row
       // move cursor position to last row
              << "\033[" << row << ";0f" 
              << "\033[" << row << ";0f" 
@@ -371,5 +377,5 @@ bool PackageManagerText::StatusChanged(std::string PackageName,
 
 
 
 
 
 
-}; // namespace progress
-}; // namespace apt
+} // namespace progress
+} // namespace apt

+ 0 - 0
apt-pkg/install-progress.h


Неке датотеке нису приказане због велике количине промена