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

merged from http://bzr.debian.org/bzr/apt/apt/debian-experimental2

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

+ 3 - 2
Makefile

@@ -9,8 +9,8 @@ endif
 .PHONY: default
 .PHONY: default
 default: startup all
 default: startup all
 
 
-.PHONY: headers library clean veryclean all binary program doc
-all headers library clean veryclean binary program doc dirs:
+.PHONY: headers library clean veryclean all binary program doc test
+all headers library clean veryclean binary program doc dirs test:
 	$(MAKE) -C apt-pkg $@
 	$(MAKE) -C apt-pkg $@
 	$(MAKE) -C apt-inst $@
 	$(MAKE) -C apt-inst $@
 	$(MAKE) -C methods $@
 	$(MAKE) -C methods $@
@@ -19,6 +19,7 @@ all headers library clean veryclean binary program doc dirs:
 	$(MAKE) -C dselect $@
 	$(MAKE) -C dselect $@
 	$(MAKE) -C doc $@
 	$(MAKE) -C doc $@
 	$(MAKE) -C po $@
 	$(MAKE) -C po $@
+	$(MAKE) -C test $@
 
 
 # Some very common aliases
 # Some very common aliases
 .PHONY: maintainer-clean dist-clean distclean pristine sanity 
 .PHONY: maintainer-clean dist-clean distclean pristine sanity 

+ 6 - 2
apt-inst/contrib/arfile.cc

@@ -14,13 +14,17 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include<config.h>
+
 #include <apt-pkg/arfile.h>
 #include <apt-pkg/arfile.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
+#include <apt-pkg/fileutl.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 
 
 #include <stdlib.h>
 #include <stdlib.h>
-									/*}}}*/
+
 #include <apti18n.h>
 #include <apti18n.h>
+									/*}}}*/
 
 
 struct ARArchive::MemberHeader
 struct ARArchive::MemberHeader
 {
 {
@@ -112,7 +116,7 @@ bool ARArchive::LoadHeaders()
       {
       {
 	 unsigned int I = sizeof(Head.Name) - 1;
 	 unsigned int I = sizeof(Head.Name) - 1;
 	 for (; Head.Name[I] == ' ' || Head.Name[I] == '/'; I--);
 	 for (; Head.Name[I] == ' ' || Head.Name[I] == '/'; I--);
-	 Memb->Name = string(Head.Name,I+1);
+	 Memb->Name = std::string(Head.Name,I+1);
       }
       }
 
 
       // Account for the AR header alignment 
       // Account for the AR header alignment 

+ 4 - 3
apt-inst/contrib/arfile.h

@@ -17,7 +17,8 @@
 
 
 
 
 #include <string>
 #include <string>
-#include <apt-pkg/fileutl.h>
+
+class FileFd;
 
 
 class ARArchive
 class ARArchive
 {
 {
@@ -49,12 +50,12 @@ class ARArchive
 struct ARArchive::Member
 struct ARArchive::Member
 {
 {
    // Fields from the header
    // Fields from the header
-   string Name;
+   std::string Name;
    unsigned long MTime;
    unsigned long MTime;
    unsigned long UID;
    unsigned long UID;
    unsigned long GID;
    unsigned long GID;
    unsigned long Mode;
    unsigned long Mode;
-   unsigned long Size;
+   unsigned long long Size;
    
    
    // Location of the data.
    // Location of the data.
    unsigned long Start;
    unsigned long Start;

+ 4 - 1
apt-inst/contrib/extracttar.cc

@@ -16,8 +16,10 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
-#include <apt-pkg/extracttar.h>
+#include<config.h>
 
 
+#include <apt-pkg/dirstream.h>
+#include <apt-pkg/extracttar.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/configuration.h>
@@ -28,6 +30,7 @@
 #include <signal.h>
 #include <signal.h>
 #include <fcntl.h>
 #include <fcntl.h>
 #include <iostream>
 #include <iostream>
+
 #include <apti18n.h>
 #include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
 
 

+ 4 - 5
apt-inst/contrib/extracttar.h

@@ -15,11 +15,10 @@
 #define PKGLIB_EXTRACTTAR_H
 #define PKGLIB_EXTRACTTAR_H
 
 
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
-#include <apt-pkg/dirstream.h>
 
 
-#include <algorithm>
+#include <string>
 
 
-using std::min;
+class pkgDirStream;
 
 
 class ExtractTar
 class ExtractTar
 {
 {
@@ -38,7 +37,7 @@ class ExtractTar
    int GZPid;
    int GZPid;
    FileFd InFd;
    FileFd InFd;
    bool Eof;
    bool Eof;
-   string DecompressProg;
+   std::string DecompressProg;
    
    
    // Fork and reap gzip
    // Fork and reap gzip
    bool StartGzip();
    bool StartGzip();
@@ -48,7 +47,7 @@ class ExtractTar
 
 
    bool Go(pkgDirStream &Stream);
    bool Go(pkgDirStream &Stream);
    
    
-   ExtractTar(FileFd &Fd,unsigned long Max,string DecompressionProgram);
+   ExtractTar(FileFd &Fd,unsigned long Max,std::string DecompressionProgram);
    virtual ~ExtractTar();
    virtual ~ExtractTar();
 };
 };
 
 

+ 10 - 1
apt-inst/database.cc

@@ -8,14 +8,18 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include<config.h>
+
 #include <apt-pkg/database.h>
 #include <apt-pkg/database.h>
+#include <apt-pkg/filelist.h>
+#include <apt-pkg/pkgcachegen.h>
 									/*}}}*/
 									/*}}}*/
 
 
 // DataBase::GetMetaTmp - Get the temp dir				/*{{{*/
 // DataBase::GetMetaTmp - Get the temp dir				/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* This re-initializes the meta temporary directory if it hasn't yet 
 /* This re-initializes the meta temporary directory if it hasn't yet 
    been inited for this cycle. The flag is the emptyness of MetaDir */
    been inited for this cycle. The flag is the emptyness of MetaDir */
-bool pkgDataBase::GetMetaTmp(string &Dir)
+bool pkgDataBase::GetMetaTmp(std::string &Dir)
 {
 {
    if (MetaDir.empty() == true)
    if (MetaDir.empty() == true)
       if (InitMetaTmp(MetaDir) == false)
       if (InitMetaTmp(MetaDir) == false)
@@ -24,3 +28,8 @@ bool pkgDataBase::GetMetaTmp(string &Dir)
    return true;
    return true;
 }
 }
 									/*}}}*/
 									/*}}}*/
+pkgDataBase::~pkgDataBase()
+{
+   delete Cache;
+   delete FList;
+}

+ 9 - 5
apt-inst/database.h

@@ -21,17 +21,21 @@
 #ifndef PKGLIB_DATABASE_H
 #ifndef PKGLIB_DATABASE_H
 #define PKGLIB_DATABASE_H
 #define PKGLIB_DATABASE_H
 
 
-#include <apt-pkg/filelist.h>
 #include <apt-pkg/pkgcachegen.h>
 #include <apt-pkg/pkgcachegen.h>
 
 
+#include <string>
+
+class pkgFLCache;
+class OpProgress;
+
 class pkgDataBase
 class pkgDataBase
 {
 {
    protected:
    protected:
    
    
    pkgCacheGenerator *Cache;
    pkgCacheGenerator *Cache;
    pkgFLCache *FList;
    pkgFLCache *FList;
-   string MetaDir;
-   virtual bool InitMetaTmp(string &Dir) = 0;
+   std::string MetaDir;
+   virtual bool InitMetaTmp(std::string &Dir) = 0;
    
    
    public:
    public:
 
 
@@ -40,13 +44,13 @@ class pkgDataBase
    inline pkgFLCache &GetFLCache() {return *FList;};
    inline pkgFLCache &GetFLCache() {return *FList;};
    inline pkgCacheGenerator &GetGenerator() {return *Cache;};
    inline pkgCacheGenerator &GetGenerator() {return *Cache;};
    
    
-   bool GetMetaTmp(string &Dir);
+   bool GetMetaTmp(std::string &Dir);
    virtual bool ReadyFileList(OpProgress &Progress) = 0;
    virtual bool ReadyFileList(OpProgress &Progress) = 0;
    virtual bool ReadyPkgCache(OpProgress &Progress) = 0;
    virtual bool ReadyPkgCache(OpProgress &Progress) = 0;
    virtual bool LoadChanges() = 0;
    virtual bool LoadChanges() = 0;
 
 
    pkgDataBase() : Cache(0), FList(0) {};
    pkgDataBase() : Cache(0), FList(0) {};
-   virtual ~pkgDataBase() {delete Cache; delete FList;};
+   virtual ~pkgDataBase();
 };
 };
 
 
 #endif
 #endif

+ 6 - 3
apt-inst/deb/debfile.cc

@@ -16,6 +16,9 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include<config.h>
+
+#include <apt-pkg/database.h>
 #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>
@@ -105,8 +108,8 @@ bool debDebFile::ExtractControl(pkgDataBase &DB)
       return false;
       return false;
    
    
    // Get into the temporary directory
    // Get into the temporary directory
-   string Cwd = SafeGetCWD();
-   string Tmp;
+   std::string Cwd = SafeGetCWD();
+   std::string Tmp;
    if (DB.GetMetaTmp(Tmp) == false)
    if (DB.GetMetaTmp(Tmp) == false)
       return false;
       return false;
    if (chdir(Tmp.c_str()) != 0)
    if (chdir(Tmp.c_str()) != 0)
@@ -172,7 +175,7 @@ bool debDebFile::ExtractArchive(pkgDirStream &Stream)
 pkgCache::VerIterator debDebFile::MergeControl(pkgDataBase &DB)
 pkgCache::VerIterator debDebFile::MergeControl(pkgDataBase &DB)
 {
 {
    // Open the control file
    // Open the control file
-   string Tmp;
+   std::string Tmp;
    if (DB.GetMetaTmp(Tmp) == false)
    if (DB.GetMetaTmp(Tmp) == false)
       return pkgCache::VerIterator(DB.GetCache());
       return pkgCache::VerIterator(DB.GetCache());
    FileFd Fd(Tmp + "control",FileFd::ReadOnly);
    FileFd Fd(Tmp + "control",FileFd::ReadOnly);

+ 6 - 3
apt-inst/deb/debfile.h

@@ -25,9 +25,12 @@
 
 
 
 
 #include <apt-pkg/arfile.h>
 #include <apt-pkg/arfile.h>
-#include <apt-pkg/database.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>
+
+class FileFd;
+class pkgDataBase;
 
 
 class debDebFile
 class debDebFile
 {
 {
@@ -68,7 +71,7 @@ class debDebFile::MemControlExtract : public pkgDirStream
    char *Control;
    char *Control;
    pkgTagSection Section;
    pkgTagSection Section;
    unsigned long Length;
    unsigned long Length;
-   string Member;
+   std::string Member;
    
    
    // Members from DirStream
    // Members from DirStream
    virtual bool DoItem(Item &Itm,int &Fd);
    virtual bool DoItem(Item &Itm,int &Fd);
@@ -81,7 +84,7 @@ class debDebFile::MemControlExtract : public pkgDirStream
    bool TakeControl(const void *Data,unsigned long Size);
    bool TakeControl(const void *Data,unsigned long Size);
       
       
    MemControlExtract() : IsControl(false), Control(0), Length(0), Member("control") {};
    MemControlExtract() : IsControl(false), Control(0), Length(0), Member("control") {};
-   MemControlExtract(string Member) : IsControl(false), Control(0), Length(0), Member(Member) {};
+   MemControlExtract(std::string Member) : IsControl(false), Control(0), Length(0), Member(Member) {};
    ~MemControlExtract() {delete [] Control;};   
    ~MemControlExtract() {delete [] Control;};   
 };
 };
 									/*}}}*/
 									/*}}}*/

+ 4 - 0
apt-inst/deb/dpkgdb.cc

@@ -13,12 +13,16 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include<config.h>
+
 #include <apt-pkg/dpkgdb.h>
 #include <apt-pkg/dpkgdb.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/progress.h>
 #include <apt-pkg/progress.h>
 #include <apt-pkg/tagfile.h>
 #include <apt-pkg/tagfile.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/filelist.h>
 
 
 #include <stdio.h>
 #include <stdio.h>
 #include <errno.h>
 #include <errno.h>

+ 9 - 4
apt-inst/deb/dpkgdb.h

@@ -22,17 +22,22 @@
 
 
 #include <apt-pkg/database.h>
 #include <apt-pkg/database.h>
 
 
+#include <string>
+
+class DynamicMMap;
+class OpProgress;
+
 class debDpkgDB : public pkgDataBase
 class debDpkgDB : public pkgDataBase
 {
 {
    protected:
    protected:
-   
-   string AdminDir;
+
+   std::string AdminDir;
    DynamicMMap *CacheMap;
    DynamicMMap *CacheMap;
    DynamicMMap *FileMap;
    DynamicMMap *FileMap;
    unsigned long DiverInode;
    unsigned long DiverInode;
    signed long DiverTime;
    signed long DiverTime;
-   
-   virtual bool InitMetaTmp(string &Dir);
+
+   virtual bool InitMetaTmp(std::string &Dir);
    bool ReadFList(OpProgress &Progress);
    bool ReadFList(OpProgress &Progress);
    bool ReadDiversions();
    bool ReadDiversions();
    bool ReadConfFiles();
    bool ReadConfFiles();

+ 2 - 0
apt-inst/dirstream.cc

@@ -11,6 +11,8 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include<config.h>
+
 #include <apt-pkg/dirstream.h>
 #include <apt-pkg/dirstream.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 
 

+ 3 - 0
apt-inst/extract.cc

@@ -44,9 +44,12 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include<config.h>
+
 #include <apt-pkg/extract.h>
 #include <apt-pkg/extract.h>
 #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 <sys/stat.h>
 #include <sys/stat.h>
 #include <stdio.h>
 #include <stdio.h>

+ 1 - 1
apt-inst/extract.h

@@ -33,7 +33,7 @@ class pkgExtract : public pkgDirStream
    
    
    bool HandleOverwrites(pkgFLCache::NodeIterator Nde,
    bool HandleOverwrites(pkgFLCache::NodeIterator Nde,
 			 bool DiverCheck = false);
 			 bool DiverCheck = false);
-   bool CheckDirReplace(string Dir,unsigned int Depth = 0);
+   bool CheckDirReplace(std::string Dir,unsigned int Depth = 0);
    
    
    public:
    public:
    
    

+ 2 - 0
apt-inst/filelist.cc

@@ -32,6 +32,8 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include<config.h>
+
 #include <apt-pkg/filelist.h>
 #include <apt-pkg/filelist.h>
 #include <apt-pkg/mmap.h>
 #include <apt-pkg/mmap.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>

+ 3 - 2
apt-inst/filelist.h

@@ -28,9 +28,10 @@
 #ifndef PKGLIB_FILELIST_H
 #ifndef PKGLIB_FILELIST_H
 #define PKGLIB_FILELIST_H
 #define PKGLIB_FILELIST_H
 
 
+#include <apt-pkg/mmap.h>
 
 
 #include <cstring>
 #include <cstring>
-#include <apt-pkg/mmap.h>
+#include <string>
 
 
 class pkgFLCache
 class pkgFLCache
 {
 {
@@ -48,7 +49,7 @@ class pkgFLCache
    class DiverIterator;
    class DiverIterator;
    
    
    protected:
    protected:
-   string CacheFile;
+   std::string CacheFile;
    DynamicMMap &Map;
    DynamicMMap &Map;
    map_ptrloc LastTreeLookup;
    map_ptrloc LastTreeLookup;
    unsigned long LastLookupSize;
    unsigned long LastLookupSize;

+ 1 - 1
apt-inst/makefile

@@ -14,7 +14,7 @@ include ../buildlib/libversion.mak
 
 
 # The library name
 # The library name
 LIBRARY=apt-inst
 LIBRARY=apt-inst
-MAJOR=1.3
+MAJOR=1.4
 MINOR=0
 MINOR=0
 SLIBS=$(PTHREADLIB) -lapt-pkg
 SLIBS=$(PTHREADLIB) -lapt-pkg
 APT_DOMAIN:=libapt-inst$(MAJOR)
 APT_DOMAIN:=libapt-inst$(MAJOR)

+ 39 - 38
apt-pkg/acquire-item.cc

@@ -13,6 +13,8 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include <config.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/aptconfiguration.h>
 #include <apt-pkg/aptconfiguration.h>
@@ -23,9 +25,9 @@
 #include <apt-pkg/md5.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/metaindex.h>
 
 
-#include <apti18n.h>
-    
 #include <sys/stat.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <unistd.h>
 #include <errno.h>
 #include <errno.h>
@@ -33,6 +35,8 @@
 #include <sstream>
 #include <sstream>
 #include <stdio.h>
 #include <stdio.h>
 #include <ctime>
 #include <ctime>
+
+#include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
 
 
 using namespace std;
 using namespace std;
@@ -681,17 +685,17 @@ bool pkgAcqIndexDiffs::QueueNextDiff()					/*{{{*/
    // remove all patches until the next matching patch is found
    // remove all patches until the next matching patch is found
    // this requires the Index file to be ordered
    // this requires the Index file to be ordered
    for(vector<DiffInfo>::iterator I=available_patches.begin();
    for(vector<DiffInfo>::iterator I=available_patches.begin();
-       available_patches.size() > 0 && 
+       available_patches.empty() == false &&
 	  I != available_patches.end() &&
 	  I != available_patches.end() &&
-	  (*I).sha1 != local_sha1; 
-       I++) 
+	  I->sha1 != local_sha1;
+       ++I)
    {
    {
       available_patches.erase(I);
       available_patches.erase(I);
    }
    }
 
 
    // error checking and falling back if no patch was found
    // error checking and falling back if no patch was found
-   if(available_patches.size() == 0) 
-   { 
+   if(available_patches.empty() == true)
+   {
       Failed("", NULL);
       Failed("", NULL);
       return false;
       return false;
    }
    }
@@ -756,7 +760,7 @@ void pkgAcqIndexDiffs::Done(string Message,unsigned long long Size,string Md5Has
       chmod(FinalFile.c_str(),0644);
       chmod(FinalFile.c_str(),0644);
 
 
       // see if there is more to download
       // see if there is more to download
-      if(available_patches.size() > 0) {
+      if(available_patches.empty() == false) {
 	 new pkgAcqIndexDiffs(Owner, RealURI, Description, Desc.ShortDesc,
 	 new pkgAcqIndexDiffs(Owner, RealURI, Description, Desc.ShortDesc,
 			      ExpectedHash, ServerSha1, available_patches);
 			      ExpectedHash, ServerSha1, available_patches);
 	 return Finish();
 	 return Finish();
@@ -1266,9 +1270,9 @@ void pkgAcqMetaIndex::Done(string Message,unsigned long long Size,string Hash,	/
       if (SigFile == "")
       if (SigFile == "")
       {
       {
          // There was no signature file, so we are finished.  Download
          // There was no signature file, so we are finished.  Download
-         // the indexes and do only hashsum verification
+         // the indexes and do only hashsum verification if possible
          MetaIndexParser->Load(DestFile);
          MetaIndexParser->Load(DestFile);
-         QueueIndexes(true);
+         QueueIndexes(false);
       }
       }
       else
       else
       {
       {
@@ -1383,36 +1387,33 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify)				/*{{{*/
 #endif
 #endif
    for (vector <struct IndexTarget*>::const_iterator Target = IndexTargets->begin();
    for (vector <struct IndexTarget*>::const_iterator Target = IndexTargets->begin();
         Target != IndexTargets->end();
         Target != IndexTargets->end();
-        Target++)
+        ++Target)
    {
    {
       HashString ExpectedIndexHash;
       HashString ExpectedIndexHash;
-      if (verify)
+      const indexRecords::checkSum *Record = MetaIndexParser->Lookup((*Target)->MetaKey);
+      if (Record == NULL)
       {
       {
-	 const indexRecords::checkSum *Record = MetaIndexParser->Lookup((*Target)->MetaKey);
-	 if (Record == NULL)
+	 if (verify == true && (*Target)->IsOptional() == false)
 	 {
 	 {
-	    if ((*Target)->IsOptional() == false)
-	    {
-	       Status = StatAuthError;
-	       strprintf(ErrorText, _("Unable to find expected entry '%s' in Release file (Wrong sources.list entry or malformed file)"), (*Target)->MetaKey.c_str());
-	       return;
-	    }
+	    Status = StatAuthError;
+	    strprintf(ErrorText, _("Unable to find expected entry '%s' in Release file (Wrong sources.list entry or malformed file)"), (*Target)->MetaKey.c_str());
+	    return;
 	 }
 	 }
-	 else
+      }
+      else
+      {
+	 ExpectedIndexHash = Record->Hash;
+	 if (_config->FindB("Debug::pkgAcquire::Auth", false))
 	 {
 	 {
-	    ExpectedIndexHash = Record->Hash;
-	    if (_config->FindB("Debug::pkgAcquire::Auth", false))
-	    {
-	       std::cerr << "Queueing: " << (*Target)->URI << std::endl;
-	       std::cerr << "Expected Hash: " << ExpectedIndexHash.toStr() << std::endl;
-	       std::cerr << "For: " << Record->MetaKeyFilename << std::endl;
-	    }
-	    if (ExpectedIndexHash.empty() == true && (*Target)->IsOptional() == false)
-	    {
-	       Status = StatAuthError;
-	       strprintf(ErrorText, _("Unable to find hash sum for '%s' in Release file"), (*Target)->MetaKey.c_str());
-	       return;
-	    }
+	    std::cerr << "Queueing: " << (*Target)->URI << std::endl;
+	    std::cerr << "Expected Hash: " << ExpectedIndexHash.toStr() << std::endl;
+	    std::cerr << "For: " << Record->MetaKeyFilename << std::endl;
+	 }
+	 if (verify == true && ExpectedIndexHash.empty() == true && (*Target)->IsOptional() == false)
+	 {
+	    Status = StatAuthError;
+	    strprintf(ErrorText, _("Unable to find hash sum for '%s' in Release file"), (*Target)->MetaKey.c_str());
+	    return;
 	 }
 	 }
       }
       }
 
 
@@ -1681,7 +1682,7 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
 
 
    // check if we have one trusted source for the package. if so, switch
    // check if we have one trusted source for the package. if so, switch
    // to "TrustedOnly" mode
    // to "TrustedOnly" mode
-   for (pkgCache::VerFileIterator i = Version.FileList(); i.end() == false; i++)
+   for (pkgCache::VerFileIterator i = Version.FileList(); i.end() == false; ++i)
    {
    {
       pkgIndexFile *Index;
       pkgIndexFile *Index;
       if (Sources->FindIndex(i.File(),Index) == false)
       if (Sources->FindIndex(i.File(),Index) == false)
@@ -1718,7 +1719,7 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
 bool pkgAcqArchive::QueueNext()
 bool pkgAcqArchive::QueueNext()
 {
 {
    string const ForceHash = _config->Find("Acquire::ForceHash");
    string const ForceHash = _config->Find("Acquire::ForceHash");
-   for (; Vf.end() == false; Vf++)
+   for (; Vf.end() == false; ++Vf)
    {
    {
       // Ignore not source sources
       // Ignore not source sources
       if ((Vf.File()->Flags & pkgCache::Flag::NotSource) != 0)
       if ((Vf.File()->Flags & pkgCache::Flag::NotSource) != 0)
@@ -1833,7 +1834,7 @@ bool pkgAcqArchive::QueueNext()
       Desc.ShortDesc = Version.ParentPkg().Name();
       Desc.ShortDesc = Version.ParentPkg().Name();
       QueueURI(Desc);
       QueueURI(Desc);
 
 
-      Vf++;
+      ++Vf;
       return true;
       return true;
    }
    }
    return false;
    return false;
@@ -1907,7 +1908,7 @@ void pkgAcqArchive::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
        StringToBool(LookupTag(Message,"Transient-Failure"),false) == true)
        StringToBool(LookupTag(Message,"Transient-Failure"),false) == true)
    {
    {
       // Vf = Version.FileList();
       // Vf = Version.FileList();
-      while (Vf.end() == false) Vf++;
+      while (Vf.end() == false) ++Vf;
       StoreFilename = string();
       StoreFilename = string();
       Item::Failed(Message,Cnf);
       Item::Failed(Message,Cnf);
       return;
       return;

+ 119 - 119
apt-pkg/acquire-item.h

@@ -21,13 +21,9 @@
 #define PKGLIB_ACQUIRE_ITEM_H
 #define PKGLIB_ACQUIRE_ITEM_H
 
 
 #include <apt-pkg/acquire.h>
 #include <apt-pkg/acquire.h>
-#include <apt-pkg/indexfile.h>
-#include <apt-pkg/vendor.h>
-#include <apt-pkg/sourcelist.h>
-#include <apt-pkg/pkgrecords.h>
-#include <apt-pkg/indexrecords.h>
 #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>
 
 
 /** \addtogroup acquire
 /** \addtogroup acquire
  *  @{
  *  @{
@@ -35,6 +31,10 @@
  *  \file acquire-item.h
  *  \file acquire-item.h
  */
  */
 
 
+class indexRecords;
+class pkgRecords;
+class pkgSourceList;
+
 /** \brief Represents the process by which a pkgAcquire object should	{{{
 /** \brief Represents the process by which a pkgAcquire object should	{{{
  *  retrieve a file or a collection of files.
  *  retrieve a file or a collection of files.
  *
  *
@@ -74,7 +74,7 @@ class pkgAcquire::Item : public WeakPointable
     *  \param To The new name of #From.  If #To exists it will be
     *  \param To The new name of #From.  If #To exists it will be
     *  overwritten.
     *  overwritten.
     */
     */
-   void Rename(string From,string To);
+   void Rename(std::string From,std::string To);
    
    
    public:
    public:
 
 
@@ -109,7 +109,7 @@ class pkgAcquire::Item : public WeakPointable
    /** \brief Contains a textual description of the error encountered
    /** \brief Contains a textual description of the error encountered
     *  if #Status is #StatError or #StatAuthError.
     *  if #Status is #StatError or #StatAuthError.
     */
     */
-   string ErrorText;
+   std::string ErrorText;
 
 
    /** \brief The size of the object to fetch. */
    /** \brief The size of the object to fetch. */
    unsigned long long FileSize;
    unsigned long long FileSize;
@@ -143,7 +143,7 @@ class pkgAcquire::Item : public WeakPointable
     *  download progress indicator's overall statistics.
     *  download progress indicator's overall statistics.
     */
     */
    bool Local;
    bool Local;
-   string UsedMirror;
+   std::string UsedMirror;
 
 
    /** \brief The number of fetch queues into which this item has been
    /** \brief The number of fetch queues into which this item has been
     *  inserted.
     *  inserted.
@@ -158,7 +158,7 @@ class pkgAcquire::Item : public WeakPointable
    /** \brief The name of the file into which the retrieved object
    /** \brief The name of the file into which the retrieved object
     *  will be written.
     *  will be written.
     */
     */
-   string DestFile;
+   std::string DestFile;
 
 
    /** \brief Invoked by the acquire worker when the object couldn't
    /** \brief Invoked by the acquire worker when the object couldn't
     *  be fetched.
     *  be fetched.
@@ -173,7 +173,7 @@ class pkgAcquire::Item : public WeakPointable
     *
     *
     *  \sa pkgAcqMethod
     *  \sa pkgAcqMethod
     */
     */
-   virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
+   virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
 
 
    /** \brief Invoked by the acquire worker when the object was
    /** \brief Invoked by the acquire worker when the object was
     *  fetched successfully.
     *  fetched successfully.
@@ -194,7 +194,7 @@ class pkgAcquire::Item : public WeakPointable
     *
     *
     *  \sa pkgAcqMethod
     *  \sa pkgAcqMethod
     */
     */
-   virtual void Done(string Message,unsigned long long Size,string Hash,
+   virtual void Done(std::string Message,unsigned long long Size,std::string Hash,
 		     pkgAcquire::MethodConfig *Cnf);
 		     pkgAcquire::MethodConfig *Cnf);
 
 
    /** \brief Invoked when the worker starts to fetch this object.
    /** \brief Invoked when the worker starts to fetch this object.
@@ -206,7 +206,7 @@ class pkgAcquire::Item : public WeakPointable
     *
     *
     *  \sa pkgAcqMethod
     *  \sa pkgAcqMethod
     */
     */
-   virtual void Start(string Message,unsigned long long Size);
+   virtual void Start(std::string Message,unsigned long long Size);
 
 
    /** \brief Custom headers to be sent to the fetch process.
    /** \brief Custom headers to be sent to the fetch process.
     *
     *
@@ -216,18 +216,18 @@ class pkgAcquire::Item : public WeakPointable
     *  line, so they should (if nonempty) have a leading newline and
     *  line, so they should (if nonempty) have a leading newline and
     *  no trailing newline.
     *  no trailing newline.
     */
     */
-   virtual string Custom600Headers() {return string();};
+   virtual std::string Custom600Headers() {return std::string();};
 
 
    /** \brief A "descriptive" URI-like string.
    /** \brief A "descriptive" URI-like string.
     *
     *
     *  \return a URI that should be used to describe what is being fetched.
     *  \return a URI that should be used to describe what is being fetched.
     */
     */
-   virtual string DescURI() = 0;
+   virtual std::string DescURI() = 0;
    /** \brief Short item description.
    /** \brief Short item description.
     *
     *
     *  \return a brief description of the object being fetched.
     *  \return a brief description of the object being fetched.
     */
     */
-   virtual string ShortDesc() {return DescURI();}
+   virtual std::string ShortDesc() {return DescURI();}
 
 
    /** \brief Invoked by the worker when the download is completely done. */
    /** \brief Invoked by the worker when the download is completely done. */
    virtual void Finished() {};
    virtual void Finished() {};
@@ -237,7 +237,7 @@ class pkgAcquire::Item : public WeakPointable
     *  \return the HashSum of this object, if applicable; otherwise, an
     *  \return the HashSum of this object, if applicable; otherwise, an
     *  empty string.
     *  empty string.
     */
     */
-   virtual string HashSum() {return string();};
+   virtual std::string HashSum() {return std::string();};
 
 
    /** \return the acquire process with which this item is associated. */
    /** \return the acquire process with which this item is associated. */
    pkgAcquire *GetOwner() {return Owner;};
    pkgAcquire *GetOwner() {return Owner;};
@@ -253,7 +253,7 @@ class pkgAcquire::Item : public WeakPointable
     * 
     * 
     *  \param FailCode A short failure string that is send
     *  \param FailCode A short failure string that is send
     */
     */
-   void ReportMirrorFailure(string FailCode);
+   void ReportMirrorFailure(std::string FailCode);
 
 
 
 
    /** \brief Initialize an item.
    /** \brief Initialize an item.
@@ -278,10 +278,10 @@ class pkgAcquire::Item : public WeakPointable
 /** \brief Information about an index patch (aka diff). */		/*{{{*/
 /** \brief Information about an index patch (aka diff). */		/*{{{*/
 struct DiffInfo {
 struct DiffInfo {
    /** The filename of the diff. */
    /** The filename of the diff. */
-   string file;
+   std::string file;
 
 
    /** The sha1 hash of the diff. */
    /** The sha1 hash of the diff. */
-   string sha1;
+   std::string sha1;
 
 
    /** The size of the diff. */
    /** The size of the diff. */
    unsigned long size;
    unsigned long size;
@@ -308,12 +308,12 @@ class pkgAcqSubIndex : public pkgAcquire::Item
 
 
  public:
  public:
    // Specialized action members
    // Specialized action members
-   virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
-   virtual void Done(string Message,unsigned long long Size,string Md5Hash,
+   virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
+   virtual void Done(std::string Message,unsigned long long Size,std::string Md5Hash,
 		     pkgAcquire::MethodConfig *Cnf);
 		     pkgAcquire::MethodConfig *Cnf);
-   virtual string DescURI() {return Desc.URI;};
-   virtual string Custom600Headers();
-   virtual bool ParseIndex(string const &IndexFile);
+   virtual std::string DescURI() {return Desc.URI;};
+   virtual std::string Custom600Headers();
+   virtual bool ParseIndex(std::string const &IndexFile);
 
 
    /** \brief Create a new pkgAcqSubIndex.
    /** \brief Create a new pkgAcqSubIndex.
     *
     *
@@ -327,8 +327,8 @@ class pkgAcqSubIndex : public pkgAcquire::Item
     *
     *
     *  \param ExpectedHash The list file's MD5 signature.
     *  \param ExpectedHash The list file's MD5 signature.
     */
     */
-   pkgAcqSubIndex(pkgAcquire *Owner, string const &URI,string const &URIDesc,
-		   string const &ShortDesc, HashString const &ExpectedHash);
+   pkgAcqSubIndex(pkgAcquire *Owner, std::string const &URI,std::string const &URIDesc,
+		   std::string const &ShortDesc, HashString const &ExpectedHash);
 };
 };
 									/*}}}*/
 									/*}}}*/
 /** \brief An item that is responsible for fetching an index file of	{{{
 /** \brief An item that is responsible for fetching an index file of	{{{
@@ -352,7 +352,7 @@ class pkgAcqDiffIndex : public pkgAcquire::Item
    /** \brief The URI of the index file to recreate at our end (either
    /** \brief The URI of the index file to recreate at our end (either
     *  by downloading it or by applying partial patches).
     *  by downloading it or by applying partial patches).
     */
     */
-   string RealURI;
+   std::string RealURI;
 
 
    /** \brief The Hash that the real index file should have after
    /** \brief The Hash that the real index file should have after
     *  all patches have been applied.
     *  all patches have been applied.
@@ -362,20 +362,20 @@ class pkgAcqDiffIndex : public pkgAcquire::Item
    /** \brief The index file which will be patched to generate the new
    /** \brief The index file which will be patched to generate the new
     *  file.
     *  file.
     */
     */
-   string CurrentPackagesFile;
+   std::string CurrentPackagesFile;
 
 
    /** \brief A description of the Packages file (stored in
    /** \brief A description of the Packages file (stored in
     *  pkgAcquire::ItemDesc::Description).
     *  pkgAcquire::ItemDesc::Description).
     */
     */
-   string Description;
+   std::string Description;
 
 
  public:
  public:
    // Specialized action members
    // Specialized action members
-   virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
-   virtual void Done(string Message,unsigned long long Size,string Md5Hash,
+   virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
+   virtual void Done(std::string Message,unsigned long long Size,std::string Md5Hash,
 		     pkgAcquire::MethodConfig *Cnf);
 		     pkgAcquire::MethodConfig *Cnf);
-   virtual string DescURI() {return RealURI + "Index";};
-   virtual string Custom600Headers();
+   virtual std::string DescURI() {return RealURI + "Index";};
+   virtual std::string Custom600Headers();
 
 
    /** \brief Parse the Index file for a set of Packages diffs.
    /** \brief Parse the Index file for a set of Packages diffs.
     *
     *
@@ -387,7 +387,7 @@ class pkgAcqDiffIndex : public pkgAcquire::Item
     *  \return \b true if the Index file was successfully parsed, \b
     *  \return \b true if the Index file was successfully parsed, \b
     *  false otherwise.
     *  false otherwise.
     */
     */
-   bool ParseDiffIndex(string IndexDiffFile);
+   bool ParseDiffIndex(std::string IndexDiffFile);
    
    
 
 
    /** \brief Create a new pkgAcqDiffIndex.
    /** \brief Create a new pkgAcqDiffIndex.
@@ -402,8 +402,8 @@ class pkgAcqDiffIndex : public pkgAcquire::Item
     *
     *
     *  \param ExpectedHash The list file's MD5 signature.
     *  \param ExpectedHash The list file's MD5 signature.
     */
     */
-   pkgAcqDiffIndex(pkgAcquire *Owner,string URI,string URIDesc,
-		   string ShortDesc, HashString ExpectedHash);
+   pkgAcqDiffIndex(pkgAcquire *Owner,std::string URI,std::string URIDesc,
+		   std::string ShortDesc, HashString ExpectedHash);
 };
 };
 									/*}}}*/
 									/*}}}*/
 /** \brief An item that is responsible for fetching all the patches	{{{
 /** \brief An item that is responsible for fetching all the patches	{{{
@@ -460,7 +460,7 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item
    /** \brief The URI of the package index file that is being
    /** \brief The URI of the package index file that is being
     *  reconstructed.
     *  reconstructed.
     */
     */
-   string RealURI;
+   std::string RealURI;
 
 
    /** \brief The HashSum of the package index file that is being
    /** \brief The HashSum of the package index file that is being
     *  reconstructed.
     *  reconstructed.
@@ -468,7 +468,7 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item
    HashString ExpectedHash;
    HashString ExpectedHash;
 
 
    /** A description of the file being downloaded. */
    /** A description of the file being downloaded. */
-   string Description;
+   std::string Description;
 
 
    /** The patches that remain to be downloaded, including the patch
    /** The patches that remain to be downloaded, including the patch
     *  being downloaded right now.  This list should be ordered so
     *  being downloaded right now.  This list should be ordered so
@@ -478,10 +478,10 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item
     *  dictionary instead of relying on ordering and stripping them
     *  dictionary instead of relying on ordering and stripping them
     *  off the front?
     *  off the front?
     */
     */
-   vector<DiffInfo> available_patches;
+   std::vector<DiffInfo> available_patches;
 
 
    /** Stop applying patches when reaching that sha1 */
    /** Stop applying patches when reaching that sha1 */
-   string ServerSha1;
+   std::string ServerSha1;
 
 
    /** The current status of this patch. */
    /** The current status of this patch. */
    enum DiffState
    enum DiffState
@@ -506,11 +506,11 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item
     *  This method will fall back to downloading the whole index file
     *  This method will fall back to downloading the whole index file
     *  outright; its arguments are ignored.
     *  outright; its arguments are ignored.
     */
     */
-   virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
+   virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
 
 
-   virtual void Done(string Message,unsigned long long Size,string Md5Hash,
+   virtual void Done(std::string Message,unsigned long long Size,std::string Md5Hash,
 		     pkgAcquire::MethodConfig *Cnf);
 		     pkgAcquire::MethodConfig *Cnf);
-   virtual string DescURI() {return RealURI + "Index";};
+   virtual std::string DescURI() {return RealURI + "Index";};
 
 
    /** \brief Create an index diff item.
    /** \brief Create an index diff item.
     *
     *
@@ -534,10 +534,10 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item
     *  should be ordered so that each diff appears before any diff
     *  should be ordered so that each diff appears before any diff
     *  that depends on it.
     *  that depends on it.
     */
     */
-   pkgAcqIndexDiffs(pkgAcquire *Owner,string URI,string URIDesc,
-		    string ShortDesc, HashString ExpectedHash,
-		    string ServerSha1,
-		    vector<DiffInfo> diffs=vector<DiffInfo>());
+   pkgAcqIndexDiffs(pkgAcquire *Owner,std::string URI,std::string URIDesc,
+		    std::string ShortDesc, HashString ExpectedHash,
+		    std::string ServerSha1,
+		    std::vector<DiffInfo> diffs=std::vector<DiffInfo>());
 };
 };
 									/*}}}*/
 									/*}}}*/
 /** \brief An acquire item that is responsible for fetching an index	{{{
 /** \brief An acquire item that is responsible for fetching an index	{{{
@@ -577,7 +577,7 @@ class pkgAcqIndex : public pkgAcquire::Item
    /** \brief The object that is actually being fetched (minus any
    /** \brief The object that is actually being fetched (minus any
     *  compression-related extensions).
     *  compression-related extensions).
     */
     */
-   string RealURI;
+   std::string RealURI;
 
 
    /** \brief The expected hashsum of the decompressed index file. */
    /** \brief The expected hashsum of the decompressed index file. */
    HashString ExpectedHash;
    HashString ExpectedHash;
@@ -585,17 +585,17 @@ class pkgAcqIndex : public pkgAcquire::Item
    /** \brief The compression-related file extensions that are being
    /** \brief The compression-related file extensions that are being
     *  added to the downloaded file one by one if first fails (e.g., "gz bz2").
     *  added to the downloaded file one by one if first fails (e.g., "gz bz2").
     */
     */
-   string CompressionExtension;
+   std::string CompressionExtension;
 
 
    public:
    public:
    
    
    // Specialized action members
    // Specialized action members
-   virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
-   virtual void Done(string Message,unsigned long long Size,string Md5Hash,
+   virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
+   virtual void Done(std::string Message,unsigned long long Size,std::string Md5Hash,
 		     pkgAcquire::MethodConfig *Cnf);
 		     pkgAcquire::MethodConfig *Cnf);
-   virtual string Custom600Headers();
-   virtual string DescURI() {return Desc.URI;};
-   virtual string HashSum() {return ExpectedHash.toStr(); };
+   virtual std::string Custom600Headers();
+   virtual std::string DescURI() {return Desc.URI;};
+   virtual std::string HashSum() {return ExpectedHash.toStr(); };
 
 
    /** \brief Create a pkgAcqIndex.
    /** \brief Create a pkgAcqIndex.
     *
     *
@@ -616,12 +616,12 @@ class pkgAcqIndex : public pkgAcquire::Item
     *  default is ".lzma" or ".bz2" (if the needed binaries are present)
     *  default is ".lzma" or ".bz2" (if the needed binaries are present)
     *  fallback is ".gz" or none.
     *  fallback is ".gz" or none.
     */
     */
-   pkgAcqIndex(pkgAcquire *Owner,string URI,string URIDesc,
-	       string ShortDesc, HashString ExpectedHash, 
-	       string compressExt="");
+   pkgAcqIndex(pkgAcquire *Owner,std::string URI,std::string URIDesc,
+	       std::string ShortDesc, HashString ExpectedHash, 
+	       std::string compressExt="");
    pkgAcqIndex(pkgAcquire *Owner, struct IndexTarget const * const Target,
    pkgAcqIndex(pkgAcquire *Owner, struct IndexTarget const * const Target,
 			 HashString const &ExpectedHash, indexRecords const *MetaIndexParser);
 			 HashString const &ExpectedHash, indexRecords const *MetaIndexParser);
-   void Init(string const &URI, string const &URIDesc, string const &ShortDesc);
+   void Init(std::string const &URI, std::string const &URIDesc, std::string const &ShortDesc);
 };
 };
 									/*}}}*/
 									/*}}}*/
 /** \brief An acquire item that is responsible for fetching a		{{{
 /** \brief An acquire item that is responsible for fetching a		{{{
@@ -635,8 +635,8 @@ class pkgAcqIndexTrans : public pkgAcqIndex
 {
 {
    public:
    public:
   
   
-   virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
-   virtual string Custom600Headers();
+   virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
+   virtual std::string Custom600Headers();
 
 
    /** \brief Create a pkgAcqIndexTrans.
    /** \brief Create a pkgAcqIndexTrans.
     *
     *
@@ -649,8 +649,8 @@ class pkgAcqIndexTrans : public pkgAcqIndex
     *
     *
     *  \param ShortDesc A brief description of this index file.
     *  \param ShortDesc A brief description of this index file.
     */
     */
-   pkgAcqIndexTrans(pkgAcquire *Owner,string URI,string URIDesc,
-		    string ShortDesc);
+   pkgAcqIndexTrans(pkgAcquire *Owner,std::string URI,std::string URIDesc,
+		    std::string ShortDesc);
    pkgAcqIndexTrans(pkgAcquire *Owner, struct IndexTarget const * const Target,
    pkgAcqIndexTrans(pkgAcquire *Owner, struct IndexTarget const * const Target,
 		    HashString const &ExpectedHash, indexRecords const *MetaIndexParser);
 		    HashString const &ExpectedHash, indexRecords const *MetaIndexParser);
 };
 };
@@ -660,18 +660,18 @@ class IndexTarget
 {
 {
  public:
  public:
    /** \brief A URI from which the index file can be downloaded. */
    /** \brief A URI from which the index file can be downloaded. */
-   string URI;
+   std::string URI;
 
 
    /** \brief A description of the index file. */
    /** \brief A description of the index file. */
-   string Description;
+   std::string Description;
 
 
    /** \brief A shorter description of the index file. */
    /** \brief A shorter description of the index file. */
-   string ShortDesc;
+   std::string ShortDesc;
 
 
    /** \brief The key by which this index file should be
    /** \brief The key by which this index file should be
     *  looked up within the meta signature file.
     *  looked up within the meta signature file.
     */
     */
-   string MetaKey;
+   std::string MetaKey;
 
 
    virtual bool IsOptional() const {
    virtual bool IsOptional() const {
       return false;
       return false;
@@ -718,7 +718,7 @@ class pkgAcqMetaSig : public pkgAcquire::Item
 {
 {
    protected:
    protected:
    /** \brief The last good signature file */
    /** \brief The last good signature file */
-   string LastGoodSig;
+   std::string LastGoodSig;
 
 
    /** \brief The fetch request that is currently being processed. */
    /** \brief The fetch request that is currently being processed. */
    pkgAcquire::ItemDesc Desc;
    pkgAcquire::ItemDesc Desc;
@@ -727,20 +727,20 @@ class pkgAcqMetaSig : public pkgAcquire::Item
     *  never modified; it is used to determine the file that is being
     *  never modified; it is used to determine the file that is being
     *  downloaded.
     *  downloaded.
     */
     */
-   string RealURI;
+   std::string RealURI;
 
 
    /** \brief The URI of the meta-index file to be fetched after the signature. */
    /** \brief The URI of the meta-index file to be fetched after the signature. */
-   string MetaIndexURI;
+   std::string MetaIndexURI;
 
 
    /** \brief A "URI-style" description of the meta-index file to be
    /** \brief A "URI-style" description of the meta-index file to be
     *  fetched after the signature.
     *  fetched after the signature.
     */
     */
-   string MetaIndexURIDesc;
+   std::string MetaIndexURIDesc;
 
 
    /** \brief A brief description of the meta-index file to be fetched
    /** \brief A brief description of the meta-index file to be fetched
     *  after the signature.
     *  after the signature.
     */
     */
-   string MetaIndexShortDesc;
+   std::string MetaIndexShortDesc;
 
 
    /** \brief A package-system-specific parser for the meta-index file. */
    /** \brief A package-system-specific parser for the meta-index file. */
    indexRecords* MetaIndexParser;
    indexRecords* MetaIndexParser;
@@ -750,21 +750,21 @@ class pkgAcqMetaSig : public pkgAcquire::Item
     *
     *
     *  \todo Why a list of pointers instead of a list of structs?
     *  \todo Why a list of pointers instead of a list of structs?
     */
     */
-   const vector<struct IndexTarget*>* IndexTargets;
+   const std::vector<struct IndexTarget*>* IndexTargets;
 
 
    public:
    public:
    
    
    // Specialized action members
    // Specialized action members
-   virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
-   virtual void Done(string Message,unsigned long long Size,string Md5Hash,
+   virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
+   virtual void Done(std::string Message,unsigned long long Size,std::string Md5Hash,
 		     pkgAcquire::MethodConfig *Cnf);
 		     pkgAcquire::MethodConfig *Cnf);
-   virtual string Custom600Headers();
-   virtual string DescURI() {return RealURI; };
+   virtual std::string Custom600Headers();
+   virtual std::string DescURI() {return RealURI; };
 
 
    /** \brief Create a new pkgAcqMetaSig. */
    /** \brief Create a new pkgAcqMetaSig. */
-   pkgAcqMetaSig(pkgAcquire *Owner,string URI,string URIDesc, string ShortDesc,
-		 string MetaIndexURI, string MetaIndexURIDesc, string MetaIndexShortDesc,
-		 const vector<struct IndexTarget*>* IndexTargets,
+   pkgAcqMetaSig(pkgAcquire *Owner,std::string URI,std::string URIDesc, std::string ShortDesc,
+		 std::string MetaIndexURI, std::string MetaIndexURIDesc, std::string MetaIndexShortDesc,
+		 const std::vector<struct IndexTarget*>* IndexTargets,
 		 indexRecords* MetaIndexParser);
 		 indexRecords* MetaIndexParser);
 };
 };
 									/*}}}*/
 									/*}}}*/
@@ -787,17 +787,17 @@ class pkgAcqMetaIndex : public pkgAcquire::Item
    /** \brief The URI that is actually being downloaded; never
    /** \brief The URI that is actually being downloaded; never
     *  modified by pkgAcqMetaIndex.
     *  modified by pkgAcqMetaIndex.
     */
     */
-   string RealURI;
+   std::string RealURI;
 
 
    /** \brief The file in which the signature for this index was stored.
    /** \brief The file in which the signature for this index was stored.
     *
     *
     *  If empty, the signature and the md5sums of the individual
     *  If empty, the signature and the md5sums of the individual
     *  indices will not be checked.
     *  indices will not be checked.
     */
     */
-   string SigFile;
+   std::string SigFile;
 
 
    /** \brief The index files to download. */
    /** \brief The index files to download. */
-   const vector<struct IndexTarget*>* IndexTargets;
+   const std::vector<struct IndexTarget*>* IndexTargets;
 
 
    /** \brief The parser for the meta-index file. */
    /** \brief The parser for the meta-index file. */
    indexRecords* MetaIndexParser;
    indexRecords* MetaIndexParser;
@@ -813,7 +813,7 @@ class pkgAcqMetaIndex : public pkgAcquire::Item
     *
     *
     *  \return \b true if no fatal errors were encountered.
     *  \return \b true if no fatal errors were encountered.
     */
     */
-   bool VerifyVendor(string Message);
+   bool VerifyVendor(std::string Message);
 
 
    /** \brief Called when a file is finished being retrieved.
    /** \brief Called when a file is finished being retrieved.
     *
     *
@@ -824,7 +824,7 @@ class pkgAcqMetaIndex : public pkgAcquire::Item
     *  \param Message The message block received from the fetch
     *  \param Message The message block received from the fetch
     *  subprocess.
     *  subprocess.
     */
     */
-   void RetrievalDone(string Message);
+   void RetrievalDone(std::string Message);
 
 
    /** \brief Called when authentication succeeded.
    /** \brief Called when authentication succeeded.
     *
     *
@@ -835,7 +835,7 @@ class pkgAcqMetaIndex : public pkgAcquire::Item
     *  \param Message The message block received from the fetch
     *  \param Message The message block received from the fetch
     *  subprocess.
     *  subprocess.
     */
     */
-   void AuthDone(string Message);
+   void AuthDone(std::string Message);
 
 
    /** \brief Starts downloading the individual index files.
    /** \brief Starts downloading the individual index files.
     *
     *
@@ -850,17 +850,17 @@ class pkgAcqMetaIndex : public pkgAcquire::Item
    public:
    public:
    
    
    // Specialized action members
    // Specialized action members
-   virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
-   virtual void Done(string Message,unsigned long long Size, string Hash,
+   virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
+   virtual void Done(std::string Message,unsigned long long Size, std::string Hash,
 		     pkgAcquire::MethodConfig *Cnf);
 		     pkgAcquire::MethodConfig *Cnf);
-   virtual string Custom600Headers();
-   virtual string DescURI() {return RealURI; };
+   virtual std::string Custom600Headers();
+   virtual std::string DescURI() {return RealURI; };
 
 
    /** \brief Create a new pkgAcqMetaIndex. */
    /** \brief Create a new pkgAcqMetaIndex. */
    pkgAcqMetaIndex(pkgAcquire *Owner,
    pkgAcqMetaIndex(pkgAcquire *Owner,
-		   string URI,string URIDesc, string ShortDesc,
-		   string SigFile,
-		   const vector<struct IndexTarget*>* IndexTargets,
+		   std::string URI,std::string URIDesc, std::string ShortDesc,
+		   std::string SigFile,
+		   const std::vector<struct IndexTarget*>* IndexTargets,
 		   indexRecords* MetaIndexParser);
 		   indexRecords* MetaIndexParser);
 };
 };
 									/*}}}*/
 									/*}}}*/
@@ -868,33 +868,33 @@ class pkgAcqMetaIndex : public pkgAcquire::Item
 class pkgAcqMetaClearSig : public pkgAcqMetaIndex
 class pkgAcqMetaClearSig : public pkgAcqMetaIndex
 {
 {
    /** \brief The URI of the meta-index file for the detached signature */
    /** \brief The URI of the meta-index file for the detached signature */
-   string MetaIndexURI;
+   std::string MetaIndexURI;
 
 
    /** \brief A "URI-style" description of the meta-index file */
    /** \brief A "URI-style" description of the meta-index file */
-   string MetaIndexURIDesc;
+   std::string MetaIndexURIDesc;
 
 
    /** \brief A brief description of the meta-index file */
    /** \brief A brief description of the meta-index file */
-   string MetaIndexShortDesc;
+   std::string MetaIndexShortDesc;
 
 
    /** \brief The URI of the detached meta-signature file if the clearsigned one failed. */
    /** \brief The URI of the detached meta-signature file if the clearsigned one failed. */
-   string MetaSigURI;
+   std::string MetaSigURI;
 
 
    /** \brief A "URI-style" description of the meta-signature file */
    /** \brief A "URI-style" description of the meta-signature file */
-   string MetaSigURIDesc;
+   std::string MetaSigURIDesc;
 
 
    /** \brief A brief description of the meta-signature file */
    /** \brief A brief description of the meta-signature file */
-   string MetaSigShortDesc;
+   std::string MetaSigShortDesc;
 
 
 public:
 public:
-   void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
-   virtual string Custom600Headers();
+   void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
+   virtual std::string Custom600Headers();
 
 
    /** \brief Create a new pkgAcqMetaClearSig. */
    /** \brief Create a new pkgAcqMetaClearSig. */
    pkgAcqMetaClearSig(pkgAcquire *Owner,
    pkgAcqMetaClearSig(pkgAcquire *Owner,
-		string const &URI, string const &URIDesc, string const &ShortDesc,
-		string const &MetaIndexURI, string const &MetaIndexURIDesc, string const &MetaIndexShortDesc,
-		string const &MetaSigURI, string const &MetaSigURIDesc, string const &MetaSigShortDesc,
-		const vector<struct IndexTarget*>* IndexTargets,
+		std::string const &URI, std::string const &URIDesc, std::string const &ShortDesc,
+		std::string const &MetaIndexURI, std::string const &MetaIndexURIDesc, std::string const &MetaIndexShortDesc,
+		std::string const &MetaSigURI, std::string const &MetaSigURIDesc, std::string const &MetaSigShortDesc,
+		const std::vector<struct IndexTarget*>* IndexTargets,
 		indexRecords* MetaIndexParser);
 		indexRecords* MetaIndexParser);
 };
 };
 									/*}}}*/
 									/*}}}*/
@@ -928,7 +928,7 @@ class pkgAcqArchive : public pkgAcquire::Item
    /** \brief A location in which the actual filename of the package
    /** \brief A location in which the actual filename of the package
     *  should be stored.
     *  should be stored.
     */
     */
-   string &StoreFilename;
+   std::string &StoreFilename;
 
 
    /** \brief The next file for this version to try to download. */
    /** \brief The next file for this version to try to download. */
    pkgCache::VerFileIterator Vf;
    pkgCache::VerFileIterator Vf;
@@ -950,13 +950,13 @@ class pkgAcqArchive : public pkgAcquire::Item
    
    
    public:
    public:
    
    
-   virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
-   virtual void Done(string Message,unsigned long long Size,string Hash,
+   virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
+   virtual void Done(std::string Message,unsigned long long Size,std::string Hash,
 		     pkgAcquire::MethodConfig *Cnf);
 		     pkgAcquire::MethodConfig *Cnf);
-   virtual string DescURI() {return Desc.URI;};
-   virtual string ShortDesc() {return Desc.ShortDesc;};
+   virtual std::string DescURI() {return Desc.URI;};
+   virtual std::string ShortDesc() {return Desc.ShortDesc;};
    virtual void Finished();
    virtual void Finished();
-   virtual string HashSum() {return ExpectedHash.toStr(); };
+   virtual std::string HashSum() {return ExpectedHash.toStr(); };
    virtual bool IsTrusted();
    virtual bool IsTrusted();
    
    
    /** \brief Create a new pkgAcqArchive.
    /** \brief Create a new pkgAcqArchive.
@@ -979,7 +979,7 @@ class pkgAcqArchive : public pkgAcquire::Item
     */
     */
    pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
    pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
 		 pkgRecords *Recs,pkgCache::VerIterator const &Version,
 		 pkgRecords *Recs,pkgCache::VerIterator const &Version,
-		 string &StoreFilename);
+		 std::string &StoreFilename);
 };
 };
 									/*}}}*/
 									/*}}}*/
 /** \brief Retrieve an arbitrary file to the current directory.		{{{
 /** \brief Retrieve an arbitrary file to the current directory.		{{{
@@ -1007,12 +1007,12 @@ class pkgAcqFile : public pkgAcquire::Item
    public:
    public:
    
    
    // Specialized action members
    // Specialized action members
-   virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
-   virtual void Done(string Message,unsigned long long Size,string CalcHash,
+   virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
+   virtual void Done(std::string Message,unsigned long long Size,std::string CalcHash,
 		     pkgAcquire::MethodConfig *Cnf);
 		     pkgAcquire::MethodConfig *Cnf);
-   virtual string DescURI() {return Desc.URI;};
-   virtual string HashSum() {return ExpectedHash.toStr(); };
-   virtual string Custom600Headers();
+   virtual std::string DescURI() {return Desc.URI;};
+   virtual std::string HashSum() {return ExpectedHash.toStr(); };
+   virtual std::string Custom600Headers();
 
 
    /** \brief Create a new pkgAcqFile object.
    /** \brief Create a new pkgAcqFile object.
     *
     *
@@ -1045,9 +1045,9 @@ class pkgAcqFile : public pkgAcquire::Item
     * is the absolute name to which the file should be downloaded.
     * is the absolute name to which the file should be downloaded.
     */
     */
 
 
-   pkgAcqFile(pkgAcquire *Owner, string URI, string Hash, unsigned long long Size,
-	      string Desc, string ShortDesc,
-	      const string &DestDir="", const string &DestFilename="",
+   pkgAcqFile(pkgAcquire *Owner, std::string URI, std::string Hash, unsigned long long Size,
+	      std::string Desc, std::string ShortDesc,
+	      const std::string &DestDir="", const std::string &DestFilename="",
 	      bool IsIndexFile=false);
 	      bool IsIndexFile=false);
 };
 };
 									/*}}}*/
 									/*}}}*/

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

@@ -15,6 +15,8 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include <config.h>
+
 #include <apt-pkg/acquire-method.h>
 #include <apt-pkg/acquire-method.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
@@ -81,7 +83,7 @@ void pkgAcqMethod::Fail(bool Transient)
 void pkgAcqMethod::Fail(string Err,bool Transient)
 void pkgAcqMethod::Fail(string Err,bool Transient)
 {
 {
    // Strip out junk from the error messages
    // Strip out junk from the error messages
-   for (string::iterator I = Err.begin(); I != Err.end(); I++)
+   for (string::iterator I = Err.begin(); I != Err.end(); ++I)
    {
    {
       if (*I == '\r') 
       if (*I == '\r') 
 	 *I = ' ';
 	 *I = ' ';
@@ -289,12 +291,12 @@ bool pkgAcqMethod::Configuration(string Message)
       I += Length + 1;
       I += Length + 1;
       
       
       for (; I < MsgEnd && *I == ' '; I++);
       for (; I < MsgEnd && *I == ' '; I++);
-      const char *Equals = I;
-      for (; Equals < MsgEnd && *Equals != '='; Equals++);
-      const char *End = Equals;
-      for (; End < MsgEnd && *End != '\n'; End++);
-      if (End == Equals)
+      const char *Equals = (const char*) memchr(I, '=', MsgEnd - I);
+      if (Equals == NULL)
 	 return false;
 	 return false;
+      const char *End = (const char*) memchr(Equals, '\n', MsgEnd - Equals);
+      if (End == NULL)
+	 End = MsgEnd;
       
       
       Cnf.Set(DeQuoteString(string(I,Equals-I)),
       Cnf.Set(DeQuoteString(string(I,Equals-I)),
 	      DeQuoteString(string(Equals+1,End-Equals-1)));
 	      DeQuoteString(string(Equals+1,End-Equals-1)));
@@ -425,12 +427,8 @@ void pkgAcqMethod::Status(const char *Format,...)
    to keep the pipeline synchronized. */
    to keep the pipeline synchronized. */
 void pkgAcqMethod::Redirect(const string &NewURI)
 void pkgAcqMethod::Redirect(const string &NewURI)
 {
 {
-   std::cout << "103 Redirect\nURI: ";
-   if (Queue != 0)
-      std::cout << Queue->Uri << "\n";
-   else
-      std::cout << "<UNKNOWN>\n";
-   std::cout << "New-URI: " << NewURI << "\n"
+   std::cout << "103 Redirect\nURI: " << Queue->Uri << "\n"
+	     << "New-URI: " << NewURI << "\n"
 	     << "\n" << std::flush;
 	     << "\n" << std::flush;
 
 
    // Change the URI for the request.
    // Change the URI for the request.

+ 22 - 22
apt-pkg/acquire-method.h

@@ -20,11 +20,11 @@
 #ifndef PKGLIB_ACQUIRE_METHOD_H
 #ifndef PKGLIB_ACQUIRE_METHOD_H
 #define PKGLIB_ACQUIRE_METHOD_H
 #define PKGLIB_ACQUIRE_METHOD_H
 
 
-#include <apt-pkg/configuration.h>
-#include <apt-pkg/strutl.h>
-
 #include <stdarg.h>
 #include <stdarg.h>
 
 
+#include <string>
+#include <vector>
+
 class Hashes;
 class Hashes;
 class pkgAcqMethod
 class pkgAcqMethod
 {
 {
@@ -34,8 +34,8 @@ class pkgAcqMethod
    {
    {
       FetchItem *Next;
       FetchItem *Next;
 
 
-      string Uri;
-      string DestFile;
+      std::string Uri;
+      std::string DestFile;
       time_t LastModified;
       time_t LastModified;
       bool IndexFile;
       bool IndexFile;
       bool FailIgnore;
       bool FailIgnore;
@@ -43,14 +43,14 @@ class pkgAcqMethod
    
    
    struct FetchResult
    struct FetchResult
    {
    {
-      string MD5Sum;
-      string SHA1Sum;
-      string SHA256Sum;
-      string SHA512Sum;
-      vector<string> GPGVOutput;
+      std::string MD5Sum;
+      std::string SHA1Sum;
+      std::string SHA256Sum;
+      std::string SHA512Sum;
+      std::vector<std::string> GPGVOutput;
       time_t LastModified;
       time_t LastModified;
       bool IMSHit;
       bool IMSHit;
-      string Filename;
+      std::string Filename;
       unsigned long long Size;
       unsigned long long Size;
       unsigned long long ResumePoint;
       unsigned long long ResumePoint;
       
       
@@ -59,25 +59,25 @@ class pkgAcqMethod
    };
    };
 
 
    // State
    // State
-   vector<string> Messages;
+   std::vector<std::string> Messages;
    FetchItem *Queue;
    FetchItem *Queue;
    FetchItem *QueueBack;
    FetchItem *QueueBack;
-   string FailReason;
-   string UsedMirror;
-   string IP;
+   std::string FailReason;
+   std::string UsedMirror;
+   std::string IP;
    
    
    // Handlers for messages
    // Handlers for messages
-   virtual bool Configuration(string Message);
+   virtual bool Configuration(std::string Message);
    virtual bool Fetch(FetchItem * /*Item*/) {return true;};
    virtual bool Fetch(FetchItem * /*Item*/) {return true;};
    
    
    // Outgoing messages
    // Outgoing messages
    void Fail(bool Transient = false);
    void Fail(bool Transient = false);
-   inline void Fail(const char *Why, bool Transient = false) {Fail(string(Why),Transient);};
-   virtual void Fail(string Why, bool Transient = false);
+   inline void Fail(const char *Why, bool Transient = false) {Fail(std::string(Why),Transient);};
+   virtual void Fail(std::string Why, bool Transient = false);
    virtual void URIStart(FetchResult &Res);
    virtual void URIStart(FetchResult &Res);
    virtual void URIDone(FetchResult &Res,FetchResult *Alt = 0);
    virtual void URIDone(FetchResult &Res,FetchResult *Alt = 0);
 
 
-   bool MediaFail(string Required,string Drive);
+   bool MediaFail(std::string Required,std::string Drive);
    virtual void Exit() {};
    virtual void Exit() {};
 
 
    void PrintStatus(char const * const header, const char* Format, va_list &args) const;
    void PrintStatus(char const * const header, const char* Format, va_list &args) const;
@@ -91,11 +91,11 @@ class pkgAcqMethod
    void Log(const char *Format,...);
    void Log(const char *Format,...);
    void Status(const char *Format,...);
    void Status(const char *Format,...);
    
    
-   void Redirect(const string &NewURI);
+   void Redirect(const std::string &NewURI);
  
  
    int Run(bool Single = false);
    int Run(bool Single = false);
-   inline void SetFailReason(string Msg) {FailReason = Msg;};
-   inline void SetIP(string aIP) {IP = aIP;};
+   inline void SetFailReason(std::string Msg) {FailReason = Msg;};
+   inline void SetIP(std::string aIP) {IP = aIP;};
    
    
    pkgAcqMethod(const char *Ver,unsigned long Flags = 0);
    pkgAcqMethod(const char *Ver,unsigned long Flags = 0);
    virtual ~pkgAcqMethod() {};
    virtual ~pkgAcqMethod() {};

+ 9 - 7
apt-pkg/acquire-worker.cc

@@ -12,6 +12,8 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include <config.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>
@@ -19,18 +21,18 @@
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
 
 
-#include <apti18n.h>
-
 #include <iostream>
 #include <iostream>
 #include <sstream>
 #include <sstream>
 #include <fstream>
 #include <fstream>
-    
+
 #include <sys/stat.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <fcntl.h>
 #include <signal.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdio.h>
 #include <errno.h>
 #include <errno.h>
+
+#include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
 
 
 using namespace std;
 using namespace std;
@@ -256,9 +258,9 @@ bool pkgAcquire::Worker::RunMessages()
 	    
 	    
 	    CurrentItem = Itm;
 	    CurrentItem = Itm;
 	    CurrentSize = 0;
 	    CurrentSize = 0;
-	    TotalSize = atoi(LookupTag(Message,"Size","0").c_str());
-	    ResumePoint = atoi(LookupTag(Message,"Resume-Point","0").c_str());
-	    Itm->Owner->Start(Message,atoi(LookupTag(Message,"Size","0").c_str()));
+	    TotalSize = strtoull(LookupTag(Message,"Size","0").c_str(), NULL, 10);
+	    ResumePoint = strtoull(LookupTag(Message,"Resume-Point","0").c_str(), NULL, 10);
+	    Itm->Owner->Start(Message,strtoull(LookupTag(Message,"Size","0").c_str(), NULL, 10));
 
 
 	    // Display update before completion
 	    // Display update before completion
 	    if (Log != 0 && Log->MorePulses == true)
 	    if (Log != 0 && Log->MorePulses == true)
@@ -287,7 +289,7 @@ bool pkgAcquire::Worker::RunMessages()
 	       Log->Pulse(Owner->GetOwner());
 	       Log->Pulse(Owner->GetOwner());
 	    
 	    
 	    OwnerQ->ItemDone(Itm);
 	    OwnerQ->ItemDone(Itm);
-	    unsigned long long const ServerSize = atoll(LookupTag(Message,"Size","0").c_str());
+	    unsigned long long const ServerSize = strtoull(LookupTag(Message,"Size","0").c_str(), NULL, 10);
 	    if (TotalSize != 0 && ServerSize != TotalSize)
 	    if (TotalSize != 0 && ServerSize != TotalSize)
 	       _error->Warning("Size of file %s is not what the server reported %s %llu",
 	       _error->Warning("Size of file %s is not what the server reported %s %llu",
 			       Owner->DestFile.c_str(), LookupTag(Message,"Size","0").c_str(),TotalSize);
 			       Owner->DestFile.c_str(), LookupTag(Message,"Size","0").c_str(),TotalSize);

+ 6 - 6
apt-pkg/acquire-worker.h

@@ -79,7 +79,7 @@ class pkgAcquire::Worker : public WeakPointable
     *
     *
     *  \todo Doesn't this duplicate Config->Access?
     *  \todo Doesn't this duplicate Config->Access?
     */
     */
-   string Access;
+   std::string Access;
 
 
    /** \brief The PID of the subprocess. */
    /** \brief The PID of the subprocess. */
    pid_t Process;
    pid_t Process;
@@ -118,13 +118,13 @@ class pkgAcquire::Worker : public WeakPointable
    /** \brief The raw text values of messages received from the
    /** \brief The raw text values of messages received from the
     *  worker, in sequence.
     *  worker, in sequence.
     */
     */
-   vector<string> MessageQueue;
+   std::vector<std::string> MessageQueue;
 
 
    /** \brief Buffers pending writes to the subprocess.
    /** \brief Buffers pending writes to the subprocess.
     *
     *
     *  \todo Wouldn't a std::dequeue be more appropriate?
     *  \todo Wouldn't a std::dequeue be more appropriate?
     */
     */
-   string OutQueue;
+   std::string OutQueue;
    
    
    /** \brief Common code for the constructor.
    /** \brief Common code for the constructor.
     *
     *
@@ -183,7 +183,7 @@ class pkgAcquire::Worker : public WeakPointable
     *
     *
     *  \return \b true.
     *  \return \b true.
     */
     */
-   bool Capabilities(string Message);
+   bool Capabilities(std::string Message);
 
 
    /** \brief Send a 601 Configuration message (containing the APT
    /** \brief Send a 601 Configuration message (containing the APT
     *  configuration) to the subprocess.
     *  configuration) to the subprocess.
@@ -214,7 +214,7 @@ class pkgAcquire::Worker : public WeakPointable
     *  603 Media Changed, with the Failed field set to \b true if the
     *  603 Media Changed, with the Failed field set to \b true if the
     *  user cancelled the media change).
     *  user cancelled the media change).
     */
     */
-   bool MediaChange(string Message);
+   bool MediaChange(std::string Message);
    
    
    /** \brief Invoked when the worked process dies unexpectedly.
    /** \brief Invoked when the worked process dies unexpectedly.
     *
     *
@@ -242,7 +242,7 @@ class pkgAcquire::Worker : public WeakPointable
    /** \brief The most recent status string received from the
    /** \brief The most recent status string received from the
     *  subprocess.
     *  subprocess.
     */
     */
-   string Status;
+   std::string Status;
 
 
    /** \brief How many bytes of the file have been downloaded.  Zero
    /** \brief How many bytes of the file have been downloaded.  Zero
     *  if the current progress of the file cannot be determined.
     *  if the current progress of the file cannot be determined.

+ 18 - 12
apt-pkg/acquire.cc

@@ -13,6 +13,8 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include <config.h>
+
 #include <apt-pkg/acquire.h>
 #include <apt-pkg/acquire.h>
 #include <apt-pkg/acquire-item.h>
 #include <apt-pkg/acquire-item.h>
 #include <apt-pkg/acquire-worker.h>
 #include <apt-pkg/acquire-worker.h>
@@ -21,8 +23,6 @@
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
 
 
-#include <apti18n.h>
-
 #include <iostream>
 #include <iostream>
 #include <sstream>
 #include <sstream>
 #include <stdio.h>
 #include <stdio.h>
@@ -30,6 +30,8 @@
 #include <dirent.h>
 #include <dirent.h>
 #include <sys/time.h>
 #include <sys/time.h>
 #include <errno.h>
 #include <errno.h>
+
+#include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
 
 
 using namespace std;
 using namespace std;
@@ -116,7 +118,7 @@ pkgAcquire::~pkgAcquire()
 /* */
 /* */
 void pkgAcquire::Shutdown()
 void pkgAcquire::Shutdown()
 {
 {
-   while (Items.size() != 0)
+   while (Items.empty() == false)
    {
    {
       if (Items[0]->Status == Item::StatFetching)
       if (Items[0]->Status == Item::StatFetching)
          Items[0]->Status = Item::StatError;
          Items[0]->Status = Item::StatError;
@@ -155,7 +157,7 @@ void pkgAcquire::Remove(Item *Itm)
 	 I = Items.begin();
 	 I = Items.begin();
       }      
       }      
       else 
       else 
-	 I++;
+	 ++I;
    }
    }
 }
 }
 									/*}}}*/
 									/*}}}*/
@@ -411,7 +413,7 @@ pkgAcquire::RunResult pkgAcquire::Run(int PulseIntervall)
       I->Shutdown(false);
       I->Shutdown(false);
 
 
    // Shut down the items
    // Shut down the items
-   for (ItemIterator I = Items.begin(); I != Items.end(); I++)
+   for (ItemIterator I = Items.begin(); I != Items.end(); ++I)
       (*I)->Finished(); 
       (*I)->Finished(); 
    
    
    if (_error->PendingError())
    if (_error->PendingError())
@@ -445,6 +447,10 @@ pkgAcquire::Worker *pkgAcquire::WorkerStep(Worker *I)
    if it is part of the download set. */
    if it is part of the download set. */
 bool pkgAcquire::Clean(string Dir)
 bool pkgAcquire::Clean(string Dir)
 {
 {
+   // non-existing directories are by definition clean…
+   if (DirectoryExists(Dir) == false)
+      return true;
+
    DIR *D = opendir(Dir.c_str());   
    DIR *D = opendir(Dir.c_str());   
    if (D == 0)
    if (D == 0)
       return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str());
       return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str());
@@ -467,7 +473,7 @@ bool pkgAcquire::Clean(string Dir)
       
       
       // Look in the get list
       // Look in the get list
       ItemCIterator I = Items.begin();
       ItemCIterator I = Items.begin();
-      for (; I != Items.end(); I++)
+      for (; I != Items.end(); ++I)
 	 if (flNotDir((*I)->DestFile) == Dir->d_name)
 	 if (flNotDir((*I)->DestFile) == Dir->d_name)
 	    break;
 	    break;
       
       
@@ -488,7 +494,7 @@ bool pkgAcquire::Clean(string Dir)
 unsigned long long pkgAcquire::TotalNeeded()
 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)
       Total += (*I)->FileSize;
       Total += (*I)->FileSize;
    return Total;
    return Total;
 }
 }
@@ -499,7 +505,7 @@ unsigned long long pkgAcquire::TotalNeeded()
 unsigned long long pkgAcquire::FetchNeeded()
 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)
       if ((*I)->Local == false)
       if ((*I)->Local == false)
 	 Total += (*I)->FileSize;
 	 Total += (*I)->FileSize;
    return Total;
    return Total;
@@ -511,7 +517,7 @@ unsigned long long pkgAcquire::FetchNeeded()
 unsigned long long pkgAcquire::PartialPresent()
 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)
       if ((*I)->Local == false)
       if ((*I)->Local == false)
 	 Total += (*I)->PartialSize;
 	 Total += (*I)->PartialSize;
    return Total;
    return Total;
@@ -781,11 +787,11 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner)
    unsigned int Unknown = 0;
    unsigned int Unknown = 0;
    unsigned int Count = 0;
    unsigned int Count = 0;
    for (pkgAcquire::ItemCIterator I = Owner->ItemsBegin(); I != Owner->ItemsEnd();
    for (pkgAcquire::ItemCIterator I = Owner->ItemsBegin(); I != Owner->ItemsEnd();
-	I++, Count++)
+	++I, ++Count)
    {
    {
       TotalItems++;
       TotalItems++;
       if ((*I)->Status == pkgAcquire::Item::StatDone)
       if ((*I)->Status == pkgAcquire::Item::StatDone)
-	 CurrentItems++;
+	 ++CurrentItems;
       
       
       // Totally ignore local items
       // Totally ignore local items
       if ((*I)->Local == true)
       if ((*I)->Local == true)
@@ -795,7 +801,7 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner)
       if ((*I)->Complete == true)
       if ((*I)->Complete == true)
 	 CurrentBytes += (*I)->FileSize;
 	 CurrentBytes += (*I)->FileSize;
       if ((*I)->FileSize == 0 && (*I)->Complete == false)
       if ((*I)->FileSize == 0 && (*I)->Complete == false)
-	 Unknown++;
+	 ++Unknown;
    }
    }
    
    
    // Compute the current completion
    // Compute the current completion

+ 16 - 20
apt-pkg/acquire.h

@@ -72,10 +72,6 @@
 #include <vector>
 #include <vector>
 #include <string>
 #include <string>
 
 
-using std::vector;
-using std::string;
-
-
 #include <sys/time.h>
 #include <sys/time.h>
 #include <unistd.h>
 #include <unistd.h>
 
 
@@ -107,8 +103,8 @@ class pkgAcquire
    friend class Item;
    friend class Item;
    friend class Queue;
    friend class Queue;
 
 
-   typedef vector<Item *>::iterator ItemIterator;
-   typedef vector<Item *>::const_iterator ItemCIterator;
+   typedef std::vector<Item *>::iterator ItemIterator;
+   typedef std::vector<Item *>::const_iterator ItemCIterator;
 
 
    protected:
    protected:
    
    
@@ -117,7 +113,7 @@ class pkgAcquire
     *  This is built monotonically as items are created and only
     *  This is built monotonically as items are created and only
     *  emptied when the download shuts down.
     *  emptied when the download shuts down.
     */
     */
-   vector<Item *> Items;
+   std::vector<Item *> Items;
    
    
    /** \brief The head of the list of active queues.
    /** \brief The head of the list of active queues.
     *
     *
@@ -202,7 +198,7 @@ class pkgAcquire
     *  \return the string-name of the queue in which a fetch request
     *  \return the string-name of the queue in which a fetch request
     *  for the given URI should be placed.
     *  for the given URI should be placed.
     */
     */
-   string QueueName(string URI,MethodConfig const *&Config);
+   std::string QueueName(std::string URI,MethodConfig const *&Config);
 
 
    /** \brief Build up the set of file descriptors upon which select() should
    /** \brief Build up the set of file descriptors upon which select() should
     *  block.
     *  block.
@@ -248,7 +244,7 @@ class pkgAcquire
     *
     *
     *  \return the method whose name is Access, or \b NULL if no such method exists.
     *  \return the method whose name is Access, or \b NULL if no such method exists.
     */
     */
-   MethodConfig *GetConfig(string Access);
+   MethodConfig *GetConfig(std::string Access);
 
 
    /** \brief Provides information on how a download terminated. */
    /** \brief Provides information on how a download terminated. */
    enum RunResult {
    enum RunResult {
@@ -319,7 +315,7 @@ class pkgAcquire
     *
     *
     *  \return \b true if the directory exists and is readable.
     *  \return \b true if the directory exists and is readable.
     */
     */
-   bool Clean(string Dir);
+   bool Clean(std::string Dir);
 
 
    /** \return the total size in bytes of all the items included in
    /** \return the total size in bytes of all the items included in
     *  this download.
     *  this download.
@@ -347,7 +343,7 @@ class pkgAcquire
     *  only one Acquire class is in action at the time or an empty string
     *  only one Acquire class is in action at the time or an empty string
     *  if no lock file should be used.
     *  if no lock file should be used.
     */
     */
-   bool Setup(pkgAcquireStatus *Progress = NULL, string const &Lock = "");
+   bool Setup(pkgAcquireStatus *Progress = NULL, std::string const &Lock = "");
 
 
    void SetLog(pkgAcquireStatus *Progress) { Log = Progress; }
    void SetLog(pkgAcquireStatus *Progress) { Log = Progress; }
 
 
@@ -372,11 +368,11 @@ class pkgAcquire
 struct pkgAcquire::ItemDesc : public WeakPointable
 struct pkgAcquire::ItemDesc : public WeakPointable
 {
 {
    /** \brief The URI from which to download this item. */
    /** \brief The URI from which to download this item. */
-   string URI;
+   std::string URI;
    /** brief A description of this item. */
    /** brief A description of this item. */
-   string Description;
+   std::string Description;
    /** brief A shorter description of this item. */
    /** brief A shorter description of this item. */
-   string ShortDesc;
+   std::string ShortDesc;
    /** brief The underlying item which is to be downloaded. */
    /** brief The underlying item which is to be downloaded. */
    Item *Owner;
    Item *Owner;
 };
 };
@@ -420,7 +416,7 @@ class pkgAcquire::Queue
    };
    };
    
    
    /** \brief The name of this queue. */
    /** \brief The name of this queue. */
-   string Name;
+   std::string Name;
 
 
    /** \brief The head of the list of items contained in this queue.
    /** \brief The head of the list of items contained in this queue.
     *
     *
@@ -475,7 +471,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(string URI,pkgAcquire::Worker *Owner);
+   QItem *FindItem(std::string URI,pkgAcquire::Worker *Owner);
 
 
    /** Presumably this should start downloading an item?
    /** Presumably this should start downloading an item?
     *
     *
@@ -538,7 +534,7 @@ class pkgAcquire::Queue
     *  \param Name The name of the new queue.
     *  \param Name The name of the new queue.
     *  \param Owner The download process that owns the new queue.
     *  \param Owner The download process that owns the new queue.
     */
     */
-   Queue(string Name,pkgAcquire *Owner);
+   Queue(std::string Name,pkgAcquire *Owner);
 
 
    /** Shut down all the worker processes associated with this queue
    /** Shut down all the worker processes associated with this queue
     *  and empty the queue.
     *  and empty the queue.
@@ -603,10 +599,10 @@ struct pkgAcquire::MethodConfig
    MethodConfig *Next;
    MethodConfig *Next;
    
    
    /** \brief The name of this acquire method (e.g., http). */
    /** \brief The name of this acquire method (e.g., http). */
-   string Access;
+   std::string Access;
 
 
    /** \brief The implementation version of this acquire method. */
    /** \brief The implementation version of this acquire method. */
-   string Version;
+   std::string Version;
 
 
    /** \brief If \b true, only one download queue should be created for this
    /** \brief If \b true, only one download queue should be created for this
     *  method.
     *  method.
@@ -748,7 +744,7 @@ class pkgAcquireStatus
     *  \todo This is a horrible blocking monster; it should be CPSed
     *  \todo This is a horrible blocking monster; it should be CPSed
     *  with prejudice.
     *  with prejudice.
     */
     */
-   virtual bool MediaChange(string Media,string Drive) = 0;
+   virtual bool MediaChange(std::string Media,std::string Drive) = 0;
    
    
    /** \brief Invoked when an item is confirmed to be up-to-date.
    /** \brief Invoked when an item is confirmed to be up-to-date.
 
 

+ 50 - 39
apt-pkg/algorithms.cc

@@ -14,6 +14,8 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include <config.h>
+
 #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>
@@ -21,14 +23,17 @@
 #include <apt-pkg/sptr.h>
 #include <apt-pkg/sptr.h>
 #include <apt-pkg/acquire-item.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 <apti18n.h>
 #include <sys/types.h>
 #include <sys/types.h>
 #include <cstdlib>
 #include <cstdlib>
 #include <algorithm>
 #include <algorithm>
 #include <iostream>
 #include <iostream>
-
 #include <stdio.h>
 #include <stdio.h>
+
+#include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
 using namespace std;
 using namespace std;
 
 
@@ -94,7 +99,7 @@ bool pkgSimulate::Install(PkgIterator iPkg,string /*File*/)
    Sim.MarkInstall(Pkg,false);
    Sim.MarkInstall(Pkg,false);
 
 
    // Look for broken conflicts+predepends.
    // Look for broken conflicts+predepends.
-   for (PkgIterator I = Sim.PkgBegin(); I.end() == false; I++)
+   for (PkgIterator I = Sim.PkgBegin(); I.end() == false; ++I)
    {
    {
       if (Sim[I].InstallVer == 0)
       if (Sim[I].InstallVer == 0)
 	 continue;
 	 continue;
@@ -143,7 +148,7 @@ bool pkgSimulate::Configure(PkgIterator iPkg)
       Sim.Update();
       Sim.Update();
       
       
       // Print out each package and the failed dependencies
       // Print out each package and the failed dependencies
-      for (pkgCache::DepIterator D = Sim[Pkg].InstVerIter(Sim).DependsList(); D.end() == false; D++)
+      for (pkgCache::DepIterator D = Sim[Pkg].InstVerIter(Sim).DependsList(); D.end() == false; ++D)
       {
       {
 	 if (Sim.IsImportantDep(D) == false || 
 	 if (Sim.IsImportantDep(D) == false || 
 	     (Sim[D] & pkgDepCache::DepInstall) != 0)
 	     (Sim[D] & pkgDepCache::DepInstall) != 0)
@@ -207,7 +212,7 @@ bool pkgSimulate::Remove(PkgIterator iPkg,bool Purge)
 void pkgSimulate::ShortBreaks()
 void pkgSimulate::ShortBreaks()
 {
 {
    cout << " [";
    cout << " [";
-   for (PkgIterator I = Sim.PkgBegin(); I.end() == false; I++)
+   for (PkgIterator I = Sim.PkgBegin(); I.end() == false; ++I)
    {
    {
       if (Sim[I].InstBroken() == true)
       if (Sim[I].InstBroken() == true)
       {
       {
@@ -229,7 +234,7 @@ bool pkgApplyStatus(pkgDepCache &Cache)
 {
 {
    pkgDepCache::ActionGroup group(Cache);
    pkgDepCache::ActionGroup group(Cache);
 
 
-   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
+   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
    {
    {
       if (I->VersionList == 0)
       if (I->VersionList == 0)
 	 continue;
 	 continue;
@@ -298,13 +303,13 @@ bool pkgFixBroken(pkgDepCache &Cache)
    pkgDepCache::ActionGroup group(Cache);
    pkgDepCache::ActionGroup group(Cache);
 
 
    // Auto upgrade all broken packages
    // Auto upgrade all broken packages
-   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
+   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
       if (Cache[I].NowBroken() == true)
       if (Cache[I].NowBroken() == true)
 	 Cache.MarkInstall(I, true, 0, false);
 	 Cache.MarkInstall(I, true, 0, false);
    
    
    /* Fix packages that are in a NeedArchive state but don't have a
    /* Fix packages that are in a NeedArchive state but don't have a
       downloadable install version */
       downloadable install version */
-   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
+   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
    {
    {
       if (I.State() != pkgCache::PkgIterator::NeedsUnpack ||
       if (I.State() != pkgCache::PkgIterator::NeedsUnpack ||
 	  Cache[I].Delete() == true)
 	  Cache[I].Delete() == true)
@@ -347,19 +352,19 @@ bool pkgDistUpgrade(pkgDepCache &Cache)
 
 
    /* Auto upgrade all installed packages, this provides the basis 
    /* Auto upgrade all installed packages, this provides the basis 
       for the installation */
       for the installation */
-   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
+   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
       if (I->CurrentVer != 0)
       if (I->CurrentVer != 0)
 	 Cache.MarkInstall(I, true, 0, false);
 	 Cache.MarkInstall(I, true, 0, false);
 
 
    /* Now, auto upgrade all essential packages - this ensures that
    /* Now, auto upgrade all essential packages - this ensures that
       the essential packages are present and working */
       the essential packages are present and working */
-   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
+   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
       if ((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential)
       if ((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential)
 	 Cache.MarkInstall(I, true, 0, false);
 	 Cache.MarkInstall(I, true, 0, false);
    
    
    /* We do it again over all previously installed packages to force 
    /* We do it again over all previously installed packages to force 
       conflict resolution on them all. */
       conflict resolution on them all. */
-   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
+   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
       if (I->CurrentVer != 0)
       if (I->CurrentVer != 0)
 	 Cache.MarkInstall(I, false, 0, false);
 	 Cache.MarkInstall(I, false, 0, false);
 
 
@@ -368,7 +373,7 @@ bool pkgDistUpgrade(pkgDepCache &Cache)
    // Hold back held packages.
    // Hold back held packages.
    if (_config->FindB("APT::Ignore-Hold",false) == false)
    if (_config->FindB("APT::Ignore-Hold",false) == false)
    {
    {
-      for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
+      for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
       {
       {
 	 if (I->SelectedState == pkgCache::State::Hold)
 	 if (I->SelectedState == pkgCache::State::Hold)
 	 {
 	 {
@@ -402,7 +407,7 @@ bool pkgAllUpgrade(pkgDepCache &Cache)
       return false;
       return false;
    
    
    // Upgrade all installed packages
    // Upgrade all installed packages
-   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
+   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
    {
    {
       if (Cache[I].Install() == true)
       if (Cache[I].Install() == true)
 	 Fix.Protect(I);
 	 Fix.Protect(I);
@@ -436,7 +441,7 @@ bool pkgMinimizeUpgrade(pkgDepCache &Cache)
    do
    do
    {
    {
       Change = false;
       Change = false;
-      for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
+      for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
       {
       {
 	 // Not interesting
 	 // Not interesting
 	 if (Cache[I].Upgrade() == false || Cache[I].NewInstall() == true)
 	 if (Cache[I].Upgrade() == false || Cache[I].NewInstall() == true)
@@ -453,7 +458,7 @@ bool pkgMinimizeUpgrade(pkgDepCache &Cache)
 	       Change = true;
 	       Change = true;
 	 }	 
 	 }	 
       }      
       }      
-      Count++;
+      ++Count;
    }
    }
    while (Change == true && Count < 10);
    while (Change == true && Count < 10);
 
 
@@ -540,7 +545,7 @@ void pkgProblemResolver::MakeScores()
          << "  AddEssential => " << AddEssential << endl;
          << "  AddEssential => " << AddEssential << endl;
 
 
    // Generate the base scores for a package based on its properties
    // Generate the base scores for a package based on its properties
-   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
+   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
    {
    {
       if (Cache[I].InstallVer == 0)
       if (Cache[I].InstallVer == 0)
 	 continue;
 	 continue;
@@ -567,12 +572,12 @@ void pkgProblemResolver::MakeScores()
    }
    }
 
 
    // Now that we have the base scores we go and propogate dependencies
    // Now that we have the base scores we go and propogate dependencies
-   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
+   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
    {
    {
       if (Cache[I].InstallVer == 0)
       if (Cache[I].InstallVer == 0)
 	 continue;
 	 continue;
       
       
-      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 || 
 	 if (D->Type == pkgCache::Dep::Depends || 
 	     D->Type == pkgCache::Dep::PreDepends)
 	     D->Type == pkgCache::Dep::PreDepends)
@@ -589,12 +594,12 @@ void pkgProblemResolver::MakeScores()
    /* Now we cause 1 level of dependency inheritance, that is we add the 
    /* Now we cause 1 level of dependency inheritance, that is we add the 
       score of the packages that depend on the target Package. This 
       score of the packages that depend on the target Package. This 
       fortifies high scoring packages */
       fortifies high scoring packages */
-   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
+   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
    {
    {
       if (Cache[I].InstallVer == 0)
       if (Cache[I].InstallVer == 0)
 	 continue;
 	 continue;
       
       
-      for (pkgCache::DepIterator D = I.RevDependsList(); D.end() == false; D++)
+      for (pkgCache::DepIterator D = I.RevDependsList(); D.end() == false; ++D)
       {
       {
 	 // Only do it for the install version
 	 // Only do it for the install version
 	 if ((pkgCache::Version *)D.ParentVer() != Cache[D.ParentPkg()].InstallVer ||
 	 if ((pkgCache::Version *)D.ParentVer() != Cache[D.ParentPkg()].InstallVer ||
@@ -609,9 +614,9 @@ void pkgProblemResolver::MakeScores()
 
 
    /* Now we propogate along provides. This makes the packages that 
    /* Now we propogate along provides. This makes the packages that 
       provide important packages extremely important */
       provide important packages extremely important */
-   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
+   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
    {
    {
-      for (pkgCache::PrvIterator P = I.ProvidesList(); P.end() == false; P++)
+      for (pkgCache::PrvIterator P = I.ProvidesList(); P.end() == false; ++P)
       {
       {
 	 // Only do it once per package
 	 // Only do it once per package
 	 if ((pkgCache::Version *)P.OwnerVer() != Cache[P.OwnerPkg()].InstallVer)
 	 if ((pkgCache::Version *)P.OwnerVer() != Cache[P.OwnerPkg()].InstallVer)
@@ -622,7 +627,7 @@ void pkgProblemResolver::MakeScores()
 
 
    /* Protected things are pushed really high up. This number should put them
    /* Protected things are pushed really high up. This number should put them
       ahead of everything */
       ahead of everything */
-   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
+   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
    {
    {
       if ((Flags[I->ID] & Protected) != 0)
       if ((Flags[I->ID] & Protected) != 0)
 	 Scores[I->ID] += AddProtected;
 	 Scores[I->ID] += AddProtected;
@@ -719,7 +724,7 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg)
 	 
 	 
 	 if (Start == End)
 	 if (Start == End)
 	    break;
 	    break;
-	 Start++;
+	 ++Start;
       }
       }
       if (Fail == true)
       if (Fail == true)
 	 break;
 	 break;
@@ -776,7 +781,7 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix)
    do
    do
    {
    {
       Again = false;
       Again = false;
-      for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
+      for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
       {
       {
 	 if (Cache[I].Install() == true)
 	 if (Cache[I].Install() == true)
 	    Flags[I->ID] |= PreInstalled;
 	    Flags[I->ID] |= PreInstalled;
@@ -809,7 +814,7 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix)
       would cause the removal of even lower score packages. */
       would cause the removal of even lower score packages. */
    SPtrArray<pkgCache::Package *> PList = new pkgCache::Package *[Size];
    SPtrArray<pkgCache::Package *> PList = new pkgCache::Package *[Size];
    pkgCache::Package **PEnd = PList;
    pkgCache::Package **PEnd = PList;
-   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
+   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
       *PEnd++ = I;
       *PEnd++ = I;
    This = this;
    This = this;
    qsort(PList,PEnd - PList,sizeof(*PList),&ScoreSort);
    qsort(PList,PEnd - PList,sizeof(*PList),&ScoreSort);
@@ -929,7 +934,7 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix)
 	    }
 	    }
 	    else
 	    else
             {
             {
-	       Start++;
+	       ++Start;
 	       // We only worry about critical deps.
 	       // We only worry about critical deps.
 	       if (Start.IsCritical() != true)
 	       if (Start.IsCritical() != true)
                   continue;
                   continue;
@@ -1030,7 +1035,7 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix)
 		     if (BrokenFix == false || DoUpgrade(I) == false)
 		     if (BrokenFix == false || DoUpgrade(I) == false)
 		     {
 		     {
 			// Consider other options
 			// Consider other options
-			if (InOr == false)
+			if (InOr == false || Cache[I].Garbage == true)
 			{
 			{
 			   if (Debug == true)
 			   if (Debug == true)
 			      clog << "  Removing " << I.FullName(false) << " rather than change " << Start.TargetPkg().FullName(false) << endl;
 			      clog << "  Removing " << I.FullName(false) << " rather than change " << Start.TargetPkg().FullName(false) << endl;
@@ -1178,7 +1183,7 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix)
    {
    {
       // See if this is the result of a hold
       // See if this is the result of a hold
       pkgCache::PkgIterator I = Cache.PkgBegin();
       pkgCache::PkgIterator I = Cache.PkgBegin();
-      for (;I.end() != true; I++)
+      for (;I.end() != true; ++I)
       {
       {
 	 if (Cache[I].InstBroken() == false)
 	 if (Cache[I].InstBroken() == false)
 	    continue;
 	    continue;
@@ -1190,7 +1195,7 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix)
    
    
    // set the auto-flags (mvo: I'm not sure if we _really_ need this)
    // set the auto-flags (mvo: I'm not sure if we _really_ need this)
    pkgCache::PkgIterator I = Cache.PkgBegin();
    pkgCache::PkgIterator I = Cache.PkgBegin();
-   for (;I.end() != true; I++) {
+   for (;I.end() != true; ++I) {
       if (Cache[I].NewInstall() && !(Flags[I->ID] & PreInstalled)) {
       if (Cache[I].NewInstall() && !(Flags[I->ID] & PreInstalled)) {
 	 if(_config->FindI("Debug::pkgAutoRemove",false)) {
 	 if(_config->FindI("Debug::pkgAutoRemove",false)) {
 	    std::clog << "Resolve installed new pkg: " << I.FullName(false) 
 	    std::clog << "Resolve installed new pkg: " << I.FullName(false) 
@@ -1204,7 +1209,6 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix)
    return true;
    return true;
 }
 }
 									/*}}}*/
 									/*}}}*/
-
 // ProblemResolver::BreaksInstOrPolicy - Check if the given pkg is broken/*{{{*/
 // ProblemResolver::BreaksInstOrPolicy - Check if the given pkg is broken/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* This checks if the given package is broken either by a hard dependency
 /* This checks if the given package is broken either by a hard dependency
@@ -1216,19 +1220,26 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix)
 */
 */
 bool pkgProblemResolver::InstOrNewPolicyBroken(pkgCache::PkgIterator I)
 bool pkgProblemResolver::InstOrNewPolicyBroken(pkgCache::PkgIterator I)
 {
 {
-   
    // a broken install is always a problem
    // a broken install is always a problem
    if (Cache[I].InstBroken() == true)
    if (Cache[I].InstBroken() == true)
+   {
+      if (Debug == true)
+	 std::clog << "  Dependencies are not satisfied for " << I << std::endl;
       return true;
       return true;
+   }
 
 
    // a newly broken policy (recommends/suggests) is a problem
    // a newly broken policy (recommends/suggests) is a problem
    if (Cache[I].NowPolicyBroken() == false &&
    if (Cache[I].NowPolicyBroken() == false &&
        Cache[I].InstPolicyBroken() == true)
        Cache[I].InstPolicyBroken() == true)
+   {
+      if (Debug == true)
+	 std::clog << "  Policy breaks with upgrade of " << I << std::endl;
       return true;
       return true;
-       
+   }
+
    return false;
    return false;
 }
 }
-
+									/*}}}*/
 // ProblemResolver::ResolveByKeep - Resolve problems using keep		/*{{{*/
 // ProblemResolver::ResolveByKeep - Resolve problems using keep		/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* This is the work horse of the soft upgrade routine. It is very gental 
 /* This is the work horse of the soft upgrade routine. It is very gental 
@@ -1263,7 +1274,7 @@ bool pkgProblemResolver::ResolveByKeepInternal()
       would cause the removal of even lower score packages. */
       would cause the removal of even lower score packages. */
    pkgCache::Package **PList = new pkgCache::Package *[Size];
    pkgCache::Package **PList = new pkgCache::Package *[Size];
    pkgCache::Package **PEnd = PList;
    pkgCache::Package **PEnd = PList;
-   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
+   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
       *PEnd++ = I;
       *PEnd++ = I;
    This = this;
    This = this;
    qsort(PList,PEnd - PList,sizeof(*PList),&ScoreSort);
    qsort(PList,PEnd - PList,sizeof(*PList),&ScoreSort);
@@ -1360,7 +1371,7 @@ bool pkgProblemResolver::ResolveByKeepInternal()
 
 
 	    if (Start == End)
 	    if (Start == End)
 	       break;
 	       break;
-	    Start++;
+	    ++Start;
 	 }
 	 }
 	      
 	      
 	 if (InstOrNewPolicyBroken(I) == false)
 	 if (InstOrNewPolicyBroken(I) == false)
@@ -1387,7 +1398,7 @@ void pkgProblemResolver::InstallProtect()
 {
 {
    pkgDepCache::ActionGroup group(Cache);
    pkgDepCache::ActionGroup group(Cache);
 
 
-   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
+   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
    {
    {
       if ((Flags[I->ID] & Protected) == Protected)
       if ((Flags[I->ID] & Protected) == Protected)
       {
       {
@@ -1434,7 +1445,7 @@ void pkgPrioSortList(pkgCache &Cache,pkgCache::Version **List)
    qsort(List,Count,sizeof(*List),PrioComp);
    qsort(List,Count,sizeof(*List),PrioComp);
 }
 }
 									/*}}}*/
 									/*}}}*/
-// CacheFile::ListUpdate - update the cache files                    	/*{{{*/
+// ListUpdate - update the cache files					/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* This is a simple wrapper to update the cache. it will fetch stuff
 /* This is a simple wrapper to update the cache. it will fetch stuff
  * from the network (or any other sources defined in sources.list)
  * from the network (or any other sources defined in sources.list)
@@ -1467,7 +1478,7 @@ bool ListUpdate(pkgAcquireStatus &Stat,
    bool Failed = false;
    bool Failed = false;
    bool TransientNetworkFailure = false;
    bool TransientNetworkFailure = false;
    for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); 
    for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); 
-	I != Fetcher.ItemsEnd(); I++)
+	I != Fetcher.ItemsEnd(); ++I)
    {
    {
       if ((*I)->Status == pkgAcquire::Item::StatDone)
       if ((*I)->Status == pkgAcquire::Item::StatDone)
 	 continue;
 	 continue;

+ 3 - 4
apt-pkg/algorithms.h

@@ -33,11 +33,10 @@
 
 
 #include <apt-pkg/packagemanager.h>
 #include <apt-pkg/packagemanager.h>
 #include <apt-pkg/depcache.h>
 #include <apt-pkg/depcache.h>
-#include <apt-pkg/acquire.h>
 
 
 #include <iostream>
 #include <iostream>
 
 
-using std::ostream;
+class pkgAcquireStatus;
 
 
 class pkgSimulate : public pkgPackageManager				/*{{{*/
 class pkgSimulate : public pkgPackageManager				/*{{{*/
 {
 {
@@ -63,13 +62,13 @@ class pkgSimulate : public pkgPackageManager				/*{{{*/
    pkgDepCache::ActionGroup group;
    pkgDepCache::ActionGroup group;
    
    
    // The Actuall installation implementation
    // The Actuall installation implementation
-   virtual bool Install(PkgIterator Pkg,string File);
+   virtual bool Install(PkgIterator Pkg,std::string File);
    virtual bool Configure(PkgIterator Pkg);
    virtual bool Configure(PkgIterator Pkg);
    virtual bool Remove(PkgIterator Pkg,bool Purge);
    virtual bool Remove(PkgIterator Pkg,bool Purge);
 
 
 private:
 private:
    void ShortBreaks();
    void ShortBreaks();
-   void Describe(PkgIterator iPkg,ostream &out,bool Current,bool Candidate);
+   void Describe(PkgIterator iPkg,std::ostream &out,bool Current,bool Candidate);
    
    
    public:
    public:
 
 

+ 13 - 9
apt-pkg/aptconfiguration.cc

@@ -8,6 +8,8 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include <config.h>
+
 #include <apt-pkg/aptconfiguration.h>
 #include <apt-pkg/aptconfiguration.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
@@ -53,14 +55,14 @@ const Configuration::getCompressionTypes(bool const &Cached) {
 	// 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();
-	     o != order.end(); o++) {
+	     o != order.end(); ++o) {
 		if ((*o).empty() == true)
 		if ((*o).empty() == true)
 			continue;
 			continue;
 		// ignore types we have no method ready to use
 		// ignore types we have no method ready to use
-		if (_config->Exists(string("Acquire::CompressionTypes::").append(*o)) == false)
+		if (_config->Exists(std::string("Acquire::CompressionTypes::").append(*o)) == false)
 			continue;
 			continue;
 		// ignore types we have no app ready to use
 		// ignore types we have no app ready to use
-		string const appsetting = string("Dir::Bin::").append(*o);
+		std::string const appsetting = std::string("Dir::Bin::").append(*o);
 		if (_config->Exists(appsetting) == true) {
 		if (_config->Exists(appsetting) == true) {
 			std::string const app = _config->FindFile(appsetting.c_str(), "");
 			std::string const app = _config->FindFile(appsetting.c_str(), "");
 			if (app.empty() == false && FileExists(app) == false)
 			if (app.empty() == false && FileExists(app) == false)
@@ -81,7 +83,7 @@ const Configuration::getCompressionTypes(bool const &Cached) {
 		if (std::find(types.begin(),types.end(),Types->Tag) != types.end())
 		if (std::find(types.begin(),types.end(),Types->Tag) != types.end())
 			continue;
 			continue;
 		// ignore types we have no app ready to use
 		// ignore types we have no app ready to use
-		string const appsetting = string("Dir::Bin::").append(Types->Value);
+		std::string const appsetting = std::string("Dir::Bin::").append(Types->Value);
 		if (appsetting.empty() == false && _config->Exists(appsetting) == true) {
 		if (appsetting.empty() == false && _config->Exists(appsetting) == true) {
 			std::string const app = _config->FindFile(appsetting.c_str(), "");
 			std::string const app = _config->FindFile(appsetting.c_str(), "");
 			if (app.empty() == false && FileExists(app) == false)
 			if (app.empty() == false && FileExists(app) == false)
@@ -93,7 +95,7 @@ const Configuration::getCompressionTypes(bool const &Cached) {
 	// add the special "uncompressed" type
 	// add the special "uncompressed" type
 	if (std::find(types.begin(), types.end(), "uncompressed") == types.end())
 	if (std::find(types.begin(), types.end(), "uncompressed") == types.end())
 	{
 	{
-		string const uncompr = _config->FindFile("Dir::Bin::uncompressed", "");
+		std::string const uncompr = _config->FindFile("Dir::Bin::uncompressed", "");
 		if (uncompr.empty() == true || FileExists(uncompr) == true)
 		if (uncompr.empty() == true || FileExists(uncompr) == true)
 			types.push_back("uncompressed");
 			types.push_back("uncompressed");
 	}
 	}
@@ -140,7 +142,7 @@ std::vector<std::string> const Configuration::getLanguages(bool const &All,
 		for (struct dirent *Ent = readdir(D); Ent != 0; Ent = readdir(D)) {
 		for (struct dirent *Ent = readdir(D); Ent != 0; Ent = readdir(D)) {
 			string const name = Ent->d_name;
 			string const name = Ent->d_name;
 			size_t const foundDash = name.rfind("-");
 			size_t const foundDash = name.rfind("-");
-			size_t const foundUnderscore = name.rfind("_");
+			size_t const foundUnderscore = name.rfind("_", foundDash);
 			if (foundDash == string::npos || foundUnderscore == string::npos ||
 			if (foundDash == string::npos || foundUnderscore == string::npos ||
 			    foundDash <= foundUnderscore ||
 			    foundDash <= foundUnderscore ||
 			    name.substr(foundUnderscore+1, foundDash-(foundUnderscore+1)) != "Translation")
 			    name.substr(foundUnderscore+1, foundDash-(foundUnderscore+1)) != "Translation")
@@ -151,7 +153,7 @@ std::vector<std::string> const Configuration::getLanguages(bool const &All,
 			// Skip unusual files, like backups or that alike
 			// Skip unusual files, like backups or that alike
 			string::const_iterator s = c.begin();
 			string::const_iterator s = c.begin();
 			for (;s != c.end(); ++s) {
 			for (;s != c.end(); ++s) {
-				if (isalpha(*s) == 0)
+				if (isalpha(*s) == 0 && *s != '_')
 					break;
 					break;
 			}
 			}
 			if (s != c.end())
 			if (s != c.end())
@@ -232,6 +234,8 @@ std::vector<std::string> const Configuration::getLanguages(bool const &All,
 			codes = environment;
 			codes = environment;
 		} else if (forceLang != "none")
 		} else if (forceLang != "none")
 			codes.push_back(forceLang);
 			codes.push_back(forceLang);
+		else //if (forceLang == "none")
+			builtin.clear();
 		allCodes = codes;
 		allCodes = codes;
 		for (std::vector<string>::const_iterator b = builtin.begin();
 		for (std::vector<string>::const_iterator b = builtin.begin();
 		     b != builtin.end(); ++b)
 		     b != builtin.end(); ++b)
@@ -274,7 +278,7 @@ std::vector<std::string> const Configuration::getLanguages(bool const &All,
 	// 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;
 	for (std::vector<string>::const_iterator l = lang.begin();
 	for (std::vector<string>::const_iterator l = lang.begin();
-	     l != lang.end(); l++) {
+	     l != lang.end(); ++l) {
 		if (*l == "environment") {
 		if (*l == "environment") {
 			for (std::vector<string>::const_iterator e = environment.begin();
 			for (std::vector<string>::const_iterator e = environment.begin();
 			     e != environment.end(); ++e) {
 			     e != environment.end(); ++e) {
@@ -439,7 +443,7 @@ Configuration::Compressor::Compressor(char const *name, char const *extension,
 				      char const *binary,
 				      char const *binary,
 				      char const *compressArg, char const *uncompressArg,
 				      char const *compressArg, char const *uncompressArg,
 				      unsigned short const cost) {
 				      unsigned short const cost) {
-	std::string const config = string("APT:Compressor::").append(name).append("::");
+	std::string const config = std::string("APT:Compressor::").append(name).append("::");
 	Name = _config->Find(std::string(config).append("Name"), name);
 	Name = _config->Find(std::string(config).append("Name"), name);
 	Extension = _config->Find(std::string(config).append("Extension"), extension);
 	Extension = _config->Find(std::string(config).append("Extension"), extension);
 	Binary = _config->Find(std::string(config).append("Binary"), binary);
 	Binary = _config->Find(std::string(config).append("Binary"), binary);

+ 2 - 1
apt-pkg/aptconfiguration.h

@@ -13,6 +13,7 @@
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
 #include <string>
 #include <string>
 #include <vector>
 #include <vector>
+#include <limits>
 									/*}}}*/
 									/*}}}*/
 namespace APT {
 namespace APT {
 class Configuration {							/*{{{*/
 class Configuration {							/*{{{*/
@@ -94,7 +95,7 @@ public:									/*{{{*/
 		Compressor(char const *name, char const *extension, char const *binary,
 		Compressor(char const *name, char const *extension, char const *binary,
 			   char const *compressArg, char const *uncompressArg,
 			   char const *compressArg, char const *uncompressArg,
 			   unsigned short const cost);
 			   unsigned short const cost);
-		Compressor() {};
+		Compressor() : Cost(std::numeric_limits<unsigned short>::max()) {};
 	};
 	};
 
 
 	/** \brief Return a vector of Compressors supported for data.tar's
 	/** \brief Return a vector of Compressors supported for data.tar's

+ 18 - 1
apt-pkg/cachefile.cc

@@ -12,6 +12,8 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include <config.h>
+
 #include <apt-pkg/cachefile.h>
 #include <apt-pkg/cachefile.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/sourcelist.h>
 #include <apt-pkg/sourcelist.h>
@@ -21,7 +23,8 @@
 #include <apt-pkg/pkgsystem.h>
 #include <apt-pkg/pkgsystem.h>
 #include <apt-pkg/acquire-item.h>
 #include <apt-pkg/acquire-item.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
-    
+#include <apt-pkg/progress.h>
+
 #include <apti18n.h>
 #include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
 // CacheFile::CacheFile - Constructor					/*{{{*/
 // CacheFile::CacheFile - Constructor					/*{{{*/
@@ -163,6 +166,20 @@ bool pkgCacheFile::Open(OpProgress *Progress, bool WithLock)
    return true;
    return true;
 }
 }
 									/*}}}*/
 									/*}}}*/
+// CacheFile::RemoveCaches - remove all cache files from disk		/*{{{*/
+// ---------------------------------------------------------------------
+/* */
+void pkgCacheFile::RemoveCaches()
+{
+   std::string const pkgcache = _config->FindFile("Dir::cache::pkgcache");
+   std::string const srcpkgcache = _config->FindFile("Dir::cache::srcpkgcache");
+
+   if (pkgcache.empty() == false && RealFileExists(pkgcache) == true)
+      unlink(pkgcache.c_str());
+   if (srcpkgcache.empty() == false && RealFileExists(srcpkgcache) == true)
+      unlink(srcpkgcache.c_str());
+}
+									/*}}}*/
 // CacheFile::Close - close the cache files				/*{{{*/
 // CacheFile::Close - close the cache files				/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */

+ 6 - 4
apt-pkg/cachefile.h

@@ -17,11 +17,12 @@
 #ifndef PKGLIB_CACHEFILE_H
 #ifndef PKGLIB_CACHEFILE_H
 #define PKGLIB_CACHEFILE_H
 #define PKGLIB_CACHEFILE_H
 
 
-
 #include <apt-pkg/depcache.h>
 #include <apt-pkg/depcache.h>
-#include <apt-pkg/acquire.h>
-#include <apt-pkg/policy.h>
-#include <apt-pkg/sourcelist.h>
+#include <apt-pkg/macros.h>
+
+class pkgPolicy;
+class pkgSourceList;
+class OpProgress;
 
 
 class pkgCacheFile
 class pkgCacheFile
 {
 {
@@ -60,6 +61,7 @@ class pkgCacheFile
    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); };
    __deprecated bool Open(OpProgress &Progress,bool const &WithLock = true) { return Open(&Progress, WithLock); };
+   static void RemoveCaches();
    void Close();
    void Close();
 
 
    inline pkgCache* GetPkgCache() { BuildCaches(NULL, false); return Cache; };
    inline pkgCache* GetPkgCache() { BuildCaches(NULL, false); return Cache; };

+ 2 - 0
apt-pkg/cachefilter.cc

@@ -4,6 +4,8 @@
     Collection of functor classes */
     Collection of functor classes */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include <config.h>
+
 #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>

+ 4 - 3
apt-pkg/cacheiterators.h

@@ -32,6 +32,7 @@
 #include<iterator>
 #include<iterator>
 
 
 #include<string.h>
 #include<string.h>
+
 // abstract Iterator template						/*{{{*/
 // abstract Iterator template						/*{{{*/
 /* This template provides the very basic iterator methods we
 /* This template provides the very basic iterator methods we
    need to have for doing some walk-over-the-cache magic */
    need to have for doing some walk-over-the-cache magic */
@@ -111,7 +112,7 @@ class pkgCache::GrpIterator: public Iterator<Group, GrpIterator> {
 
 
 	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(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
 
 
 	    The best architecture is either the "native" or the first
 	    The best architecture is either the "native" or the first
@@ -219,7 +220,7 @@ class pkgCache::VerIterator : public Iterator<Version, VerIterator> {
 	inline VerFileIterator FileList() const;
 	inline VerFileIterator FileList() const;
 	bool Downloadable() const;
 	bool Downloadable() const;
 	inline const char *PriorityType() const {return Owner->Priority(S->Priority);};
 	inline const char *PriorityType() const {return Owner->Priority(S->Priority);};
-	string RelStr() const;
+	std::string RelStr() const;
 
 
 	bool Automatic() const;
 	bool Automatic() const;
 	VerFileIterator NewestFile() const;
 	VerFileIterator NewestFile() const;
@@ -365,7 +366,7 @@ class pkgCache::PkgFileIterator : public Iterator<PackageFile, PkgFileIterator>
 	inline const char *IndexType() const {return S->IndexType == 0?0:Owner->StrP + S->IndexType;};
 	inline const char *IndexType() const {return S->IndexType == 0?0:Owner->StrP + S->IndexType;};
 
 
 	bool IsOk();
 	bool IsOk();
-	string RelStr();
+	std::string RelStr();
 
 
 	// Constructors
 	// Constructors
 	inline PkgFileIterator() : Iterator<PackageFile, PkgFileIterator>() {};
 	inline PkgFileIterator() : Iterator<PackageFile, PkgFileIterator>() {};

+ 9 - 4
apt-pkg/cacheset.cc

@@ -9,18 +9,23 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include <config.h>
+
 #include <apt-pkg/aptconfiguration.h>
 #include <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/cachefile.h>
 #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/strutl.h>
 #include <apt-pkg/versionmatch.h>
 #include <apt-pkg/versionmatch.h>
-
-#include <apti18n.h>
+#include <apt-pkg/pkgrecords.h>
+#include <apt-pkg/policy.h>
 
 
 #include <vector>
 #include <vector>
 
 
 #include <regex.h>
 #include <regex.h>
+
+#include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
 namespace APT {
 namespace APT {
 // FromTask - Return all packages in the cache from a specific task	/*{{{*/
 // FromTask - Return all packages in the cache from a specific task	/*{{{*/
@@ -296,7 +301,7 @@ APT::VersionSet VersionSet::FromString(pkgCacheFile &Cache, std::string pkg,
 	std::string ver;
 	std::string ver;
 	bool verIsRel = false;
 	bool verIsRel = false;
 	size_t const vertag = pkg.find_last_of("/=");
 	size_t const vertag = pkg.find_last_of("/=");
-	if (vertag != string::npos) {
+	if (vertag != std::string::npos) {
 		ver = pkg.substr(vertag+1);
 		ver = pkg.substr(vertag+1);
 		verIsRel = (pkg[vertag] == '/');
 		verIsRel = (pkg[vertag] == '/');
 		pkg.erase(vertag);
 		pkg.erase(vertag);
@@ -314,7 +319,7 @@ APT::VersionSet VersionSet::FromString(pkgCacheFile &Cache, std::string pkg,
 		errors = helper.showErrors(false);
 		errors = helper.showErrors(false);
 	for (PackageSet::const_iterator P = pkgset.begin();
 	for (PackageSet::const_iterator P = pkgset.begin();
 	     P != pkgset.end(); ++P) {
 	     P != pkgset.end(); ++P) {
-		if (vertag == string::npos) {
+		if (vertag == std::string::npos) {
 			verset.insert(VersionSet::FromPackage(Cache, P, fallback, helper));
 			verset.insert(VersionSet::FromPackage(Cache, P, fallback, helper));
 			continue;
 			continue;
 		}
 		}

+ 8 - 5
apt-pkg/cacheset.h

@@ -16,9 +16,12 @@
 #include <set>
 #include <set>
 #include <string>
 #include <string>
 
 
-#include <apt-pkg/cachefile.h>
+#include <apt-pkg/error.h>
 #include <apt-pkg/pkgcache.h>
 #include <apt-pkg/pkgcache.h>
 									/*}}}*/
 									/*}}}*/
+
+class pkgCacheFile;
+
 namespace APT {
 namespace APT {
 class PackageSet;
 class PackageSet;
 class VersionSet;
 class VersionSet;
@@ -37,10 +40,10 @@ public:									/*{{{*/
 			ShowError(ShowError), ErrorType(ErrorType) {};
 			ShowError(ShowError), ErrorType(ErrorType) {};
 	virtual ~CacheSetHelper() {};
 	virtual ~CacheSetHelper() {};
 
 
-	virtual void showTaskSelection(PackageSet const &pkgset, string const &pattern) {};
-	virtual void showRegExSelection(PackageSet const &pkgset, string const &pattern) {};
+	virtual void showTaskSelection(PackageSet const &pkgset, std::string const &pattern) {};
+	virtual void showRegExSelection(PackageSet const &pkgset, std::string const &pattern) {};
 	virtual void showSelectedVersion(pkgCache::PkgIterator const &Pkg, pkgCache::VerIterator const Ver,
 	virtual void showSelectedVersion(pkgCache::PkgIterator const &Pkg, pkgCache::VerIterator const Ver,
-				 string const &ver, bool const &verIsRel) {};
+				 std::string const &ver, bool const &verIsRel) {};
 
 
 	virtual pkgCache::PkgIterator canNotFindPkgName(pkgCacheFile &Cache, std::string const &str);
 	virtual pkgCache::PkgIterator canNotFindPkgName(pkgCacheFile &Cache, std::string const &str);
 	virtual PackageSet canNotFindTask(pkgCacheFile &Cache, std::string pattern);
 	virtual PackageSet canNotFindTask(pkgCacheFile &Cache, std::string pattern);
@@ -265,7 +268,7 @@ public:									/*{{{*/
 		inline pkgCache::VerFileIterator FileList() const { return (**this).FileList(); };
 		inline pkgCache::VerFileIterator FileList() const { return (**this).FileList(); };
 		inline bool Downloadable() const { return (**this).Downloadable(); };
 		inline bool Downloadable() const { return (**this).Downloadable(); };
 		inline const char *PriorityType() const { return (**this).PriorityType(); };
 		inline const char *PriorityType() const { return (**this).PriorityType(); };
-		inline string RelStr() const { return (**this).RelStr(); };
+		inline std::string RelStr() const { return (**this).RelStr(); };
 		inline bool Automatic() const { return (**this).Automatic(); };
 		inline bool Automatic() const { return (**this).Automatic(); };
 		inline pkgCache::VerFileIterator NewestFile() const { return (**this).NewestFile(); };
 		inline pkgCache::VerFileIterator NewestFile() const { return (**this).NewestFile(); };
 	};
 	};

+ 18 - 15
apt-pkg/cdrom.cc

@@ -1,5 +1,6 @@
 /*
 /*
  */
  */
+#include<config.h>
 
 
 #include<apt-pkg/init.h>
 #include<apt-pkg/init.h>
 #include<apt-pkg/error.h>
 #include<apt-pkg/error.h>
@@ -7,11 +8,11 @@
 #include<apt-pkg/strutl.h>
 #include<apt-pkg/strutl.h>
 #include<apt-pkg/cdrom.h>
 #include<apt-pkg/cdrom.h>
 #include<apt-pkg/aptconfiguration.h>
 #include<apt-pkg/aptconfiguration.h>
+#include<apt-pkg/configuration.h>
+#include<apt-pkg/fileutl.h>
 
 
 #include<sstream>
 #include<sstream>
 #include<fstream>
 #include<fstream>
-#include<config.h>
-#include<apti18n.h>
 #include <sys/stat.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <fcntl.h>
 #include <dirent.h>
 #include <dirent.h>
@@ -22,6 +23,8 @@
 
 
 #include "indexcopy.h"
 #include "indexcopy.h"
 
 
+#include<apti18n.h>
+
 using namespace std;
 using namespace std;
 
 
 // FindPackages - Find the package files on the CDROM			/*{{{*/
 // FindPackages - Find the package files on the CDROM			/*{{{*/
@@ -310,7 +313,7 @@ void pkgCdrom::ReduceSourcelist(string CD,vector<string> &List)
    sort(List.begin(),List.end());
    sort(List.begin(),List.end());
    
    
    // Collect similar entries
    // Collect similar entries
-   for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+   for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
    {
    {
       // Find a space..
       // Find a space..
       string::size_type Space = (*I).find(' ');
       string::size_type Space = (*I).find(' ');
@@ -322,7 +325,7 @@ void pkgCdrom::ReduceSourcelist(string CD,vector<string> &List)
 
 
       string Word1 = string(*I,Space,SSpace-Space);
       string Word1 = string(*I,Space,SSpace-Space);
       string Prefix = string(*I,0,Space);
       string Prefix = string(*I,0,Space);
-      for (vector<string>::iterator J = List.begin(); J != I; J++)
+      for (vector<string>::iterator J = List.begin(); J != I; ++J)
       {
       {
 	 // Find a space..
 	 // Find a space..
 	 string::size_type Space2 = (*J).find(' ');
 	 string::size_type Space2 = (*J).find(' ');
@@ -405,7 +408,7 @@ bool pkgCdrom::WriteDatabase(Configuration &Cnf)
    that were the same. */
    that were the same. */
 bool pkgCdrom::WriteSourceList(string Name,vector<string> &List,bool Source)
 bool pkgCdrom::WriteSourceList(string Name,vector<string> &List,bool Source)
 {
 {
-   if (List.size() == 0)
+   if (List.empty() == true)
       return true;
       return true;
 
 
    string File = _config->FindFile("Dir::Etc::sourcelist");
    string File = _config->FindFile("Dir::Etc::sourcelist");
@@ -455,7 +458,7 @@ bool pkgCdrom::WriteSourceList(string Name,vector<string> &List,bool Source)
 
 
       if (First == true)
       if (First == true)
       {
       {
-	 for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+	 for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
 	 {
 	 {
 	    string::size_type Space = (*I).find(' ');
 	    string::size_type Space = (*I).find(' ');
 	    if (Space == string::npos)
 	    if (Space == string::npos)
@@ -489,7 +492,7 @@ bool pkgCdrom::WriteSourceList(string Name,vector<string> &List,bool Source)
    // Just in case the file was empty
    // Just in case the file was empty
    if (First == true)
    if (First == true)
    {
    {
-      for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+      for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
       {
       {
 	 string::size_type Space = (*I).find(' ');
 	 string::size_type Space = (*I).find(' ');
 	 if (Space == string::npos)
 	 if (Space == string::npos)
@@ -661,13 +664,13 @@ bool pkgCdrom::Add(pkgCdromStatus *log)					/*{{{*/
    if (_config->FindB("Debug::aptcdrom",false) == true)
    if (_config->FindB("Debug::aptcdrom",false) == true)
    {
    {
       cout << "I found (binary):" << endl;
       cout << "I found (binary):" << endl;
-      for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+      for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
 	 cout << *I << endl;
 	 cout << *I << endl;
       cout << "I found (source):" << endl;
       cout << "I found (source):" << endl;
-      for (vector<string>::iterator I = SourceList.begin(); I != SourceList.end(); I++)
+      for (vector<string>::iterator I = SourceList.begin(); I != SourceList.end(); ++I)
 	 cout << *I << endl;
 	 cout << *I << endl;
       cout << "I found (Signatures):" << endl;
       cout << "I found (Signatures):" << endl;
-      for (vector<string>::iterator I = SigList.begin(); I != SigList.end(); I++)
+      for (vector<string>::iterator I = SigList.begin(); I != SigList.end(); ++I)
 	 cout << *I << endl;
 	 cout << *I << endl;
    }   
    }   
 
 
@@ -688,7 +691,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log)					/*{{{*/
       log->Update(msg.str(), STEP_SCAN);
       log->Update(msg.str(), STEP_SCAN);
    }
    }
 
 
-   if (List.size() == 0 && SourceList.size() == 0) 
+   if (List.empty() == true && SourceList.empty() == true) 
    {
    {
       if (_config->FindB("APT::CDROM::NoMount",false) == false) 
       if (_config->FindB("APT::CDROM::NoMount",false) == false) 
 	 UnmountCdrom(CDROM);
 	 UnmountCdrom(CDROM);
@@ -712,7 +715,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log)					/*{{{*/
 	 {
 	 {
 	    // Escape special characters
 	    // Escape special characters
 	    string::iterator J = Name.begin();
 	    string::iterator J = Name.begin();
-	    for (; J != Name.end(); J++)
+	    for (; J != Name.end(); ++J)
 	       if (*J == '"' || *J == ']' || *J == '[')
 	       if (*J == '"' || *J == ']' || *J == '[')
 		  *J = '_';
 		  *J = '_';
 	    
 	    
@@ -757,7 +760,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log)					/*{{{*/
 
 
    // Escape special characters
    // Escape special characters
    string::iterator J = Name.begin();
    string::iterator J = Name.begin();
-   for (; J != Name.end(); J++)
+   for (; J != Name.end(); ++J)
       if (*J == '"' || *J == ']' || *J == '[')
       if (*J == '"' || *J == ']' || *J == '[')
 	 *J = '_';
 	 *J = '_';
    
    
@@ -804,7 +807,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log)					/*{{{*/
    if(log != NULL)
    if(log != NULL)
       log->Update(_("Source list entries for this disc are:\n"));
       log->Update(_("Source list entries for this disc are:\n"));
 
 
-   for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+   for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
    {
    {
       string::size_type Space = (*I).find(' ');
       string::size_type Space = (*I).find(' ');
       if (Space == string::npos)
       if (Space == string::npos)
@@ -823,7 +826,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log)					/*{{{*/
       }
       }
    }
    }
 
 
-   for (vector<string>::iterator I = SourceList.begin(); I != SourceList.end(); I++)
+   for (vector<string>::iterator I = SourceList.begin(); I != SourceList.end(); ++I)
    {
    {
       string::size_type Space = (*I).find(' ');
       string::size_type Space = (*I).find(' ');
       if (Space == string::npos)
       if (Space == string::npos)

+ 20 - 21
apt-pkg/cdrom.h

@@ -1,12 +1,11 @@
 #ifndef PKGLIB_CDROM_H
 #ifndef PKGLIB_CDROM_H
 #define PKGLIB_CDROM_H
 #define PKGLIB_CDROM_H
 
 
-#include<apt-pkg/init.h>
 #include<string>
 #include<string>
 #include<vector>
 #include<vector>
 
 
-
-using namespace std;
+class Configuration;
+class OpProgress;
 
 
 class pkgCdromStatus							/*{{{*/
 class pkgCdromStatus							/*{{{*/
 {
 {
@@ -20,12 +19,12 @@ class pkgCdromStatus							/*{{{*/
    // total steps
    // total steps
    virtual void SetTotal(int total) { totalSteps = total; };
    virtual void SetTotal(int total) { totalSteps = total; };
    // update steps, will be called regularly as a "pulse"
    // update steps, will be called regularly as a "pulse"
-   virtual void Update(string text="", int current=0) = 0;
+   virtual void Update(std::string text="", int current=0) = 0;
    
    
    // ask for cdrom insert
    // ask for cdrom insert
    virtual bool ChangeCdrom() = 0;
    virtual bool ChangeCdrom() = 0;
    // ask for cdrom name
    // ask for cdrom name
-   virtual bool AskCdromName(string &Name) = 0;
+   virtual bool AskCdromName(std::string &Name) = 0;
    // Progress indicator for the Index rewriter
    // Progress indicator for the Index rewriter
    virtual OpProgress* GetOpProgress() {return NULL; };
    virtual OpProgress* GetOpProgress() {return NULL; };
 };
 };
@@ -47,22 +46,22 @@ class pkgCdrom								/*{{{*/
    };
    };
 
 
 
 
-   bool FindPackages(string CD,
-		     vector<string> &List,
-		     vector<string> &SList, 
-		     vector<string> &SigList,
-		     vector<string> &TransList,
-		     string &InfoDir, pkgCdromStatus *log,
+   bool FindPackages(std::string CD,
+		     std::vector<std::string> &List,
+		     std::vector<std::string> &SList, 
+		     std::vector<std::string> &SigList,
+		     std::vector<std::string> &TransList,
+		     std::string &InfoDir, pkgCdromStatus *log,
 		     unsigned int Depth = 0);
 		     unsigned int Depth = 0);
-   bool DropBinaryArch(vector<string> &List);
-   bool DropRepeats(vector<string> &List,const char *Name);
-   void ReduceSourcelist(string CD,vector<string> &List);
+   bool DropBinaryArch(std::vector<std::string> &List);
+   bool DropRepeats(std::vector<std::string> &List,const char *Name);
+   void ReduceSourcelist(std::string CD,std::vector<std::string> &List);
    bool WriteDatabase(Configuration &Cnf);
    bool WriteDatabase(Configuration &Cnf);
-   bool WriteSourceList(string Name,vector<string> &List,bool Source);
-   int Score(string Path);
+   bool WriteSourceList(std::string Name,std::vector<std::string> &List,bool Source);
+   int Score(std::string Path);
 
 
  public:
  public:
-   bool Ident(string &ident, pkgCdromStatus *log);
+   bool Ident(std::string &ident, pkgCdromStatus *log);
    bool Add(pkgCdromStatus *log);
    bool Add(pkgCdromStatus *log);
 };
 };
 									/*}}}*/
 									/*}}}*/
@@ -71,9 +70,9 @@ class pkgCdrom								/*{{{*/
 // class that uses libudev to find cdrom/removable devices dynamically
 // class that uses libudev to find cdrom/removable devices dynamically
 struct CdromDevice							/*{{{*/
 struct CdromDevice							/*{{{*/
 {
 {
-   string DeviceName;
+   std::string DeviceName;
    bool Mounted;
    bool Mounted;
-   string MountPath;
+   std::string MountPath;
 };
 };
 									/*}}}*/
 									/*}}}*/
 class pkgUdevCdromDevices						/*{{{*/
 class pkgUdevCdromDevices						/*{{{*/
@@ -104,9 +103,9 @@ class pkgUdevCdromDevices						/*{{{*/
 
 
    // convenience interface, this will just call ScanForRemovable
    // convenience interface, this will just call ScanForRemovable
    // with "APT::cdrom::CdromOnly"
    // with "APT::cdrom::CdromOnly"
-   vector<CdromDevice> Scan();
+   std::vector<CdromDevice> Scan();
 
 
-   vector<CdromDevice> ScanForRemovable(bool CdromOnly);
+   std::vector<CdromDevice> ScanForRemovable(bool CdromOnly);
 };
 };
 									/*}}}*/
 									/*}}}*/
 
 

+ 12 - 9
apt-pkg/clean.cc

@@ -8,23 +8,26 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Includes								/*{{{*/
 // Includes								/*{{{*/
+#include<config.h>
+
 #include <apt-pkg/clean.h>
 #include <apt-pkg/clean.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/aptconfiguration.h>
 #include <apt-pkg/aptconfiguration.h>
-
-#include <apti18n.h>    
+#include <apt-pkg/fileutl.h>
 
 
 #include <dirent.h>
 #include <dirent.h>
 #include <sys/stat.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <unistd.h>
+
+#include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
 // ArchiveCleaner::Go - Perform smart cleanup of the archive		/*{{{*/
 // ArchiveCleaner::Go - Perform smart cleanup of the archive		/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* Scan the directory for files to erase, we check the version information
 /* Scan the directory for files to erase, we check the version information
    against our database to see if it is interesting */
    against our database to see if it is interesting */
-bool pkgArchiveCleaner::Go(string Dir,pkgCache &Cache)
+bool pkgArchiveCleaner::Go(std::string Dir,pkgCache &Cache)
 {
 {
    bool CleanInstalled = _config->FindB("APT::Clean-Installed",true);
    bool CleanInstalled = _config->FindB("APT::Clean-Installed",true);
       
       
@@ -32,7 +35,7 @@ bool pkgArchiveCleaner::Go(string Dir,pkgCache &Cache)
    if (D == 0)
    if (D == 0)
       return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str());
       return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str());
 
 
-   string StartDir = SafeGetCWD();
+   std::string StartDir = SafeGetCWD();
    if (chdir(Dir.c_str()) != 0)
    if (chdir(Dir.c_str()) != 0)
    {
    {
       closedir(D);
       closedir(D);
@@ -61,21 +64,21 @@ bool pkgArchiveCleaner::Go(string Dir,pkgCache &Cache)
       for (; *I != 0 && *I != '_';I++);
       for (; *I != 0 && *I != '_';I++);
       if (*I != '_')
       if (*I != '_')
 	 continue;
 	 continue;
-      string Pkg = DeQuoteString(string(Dir->d_name,I-Dir->d_name));
+      std::string Pkg = DeQuoteString(std::string(Dir->d_name,I-Dir->d_name));
 
 
       // Grab the version
       // Grab the version
       const char *Start = I + 1;
       const char *Start = I + 1;
       for (I = Start; *I != 0 && *I != '_';I++);
       for (I = Start; *I != 0 && *I != '_';I++);
       if (*I != '_')
       if (*I != '_')
 	 continue;
 	 continue;
-      string Ver = DeQuoteString(string(Start,I-Start));
+      std::string Ver = DeQuoteString(std::string(Start,I-Start));
   
   
       // Grab the arch
       // Grab the arch
       Start = I + 1;
       Start = I + 1;
       for (I = Start; *I != 0 && *I != '.' ;I++);
       for (I = Start; *I != 0 && *I != '.' ;I++);
       if (*I != '.')
       if (*I != '.')
 	 continue;
 	 continue;
-      string const Arch = DeQuoteString(string(Start,I-Start));
+      std::string const Arch = DeQuoteString(std::string(Start,I-Start));
       
       
       if (APT::Configuration::checkArchitecture(Arch) == false)
       if (APT::Configuration::checkArchitecture(Arch) == false)
 	 continue;
 	 continue;
@@ -85,12 +88,12 @@ bool pkgArchiveCleaner::Go(string Dir,pkgCache &Cache)
       if (P.end() != true)
       if (P.end() != true)
       {
       {
 	 pkgCache::VerIterator V = P.VersionList();
 	 pkgCache::VerIterator V = P.VersionList();
-	 for (; V.end() == false; V++)
+	 for (; V.end() == false; ++V)
 	 {
 	 {
 	    // See if we can fetch this version at all
 	    // See if we can fetch this version at all
 	    bool IsFetchable = false;
 	    bool IsFetchable = false;
 	    for (pkgCache::VerFileIterator J = V.FileList(); 
 	    for (pkgCache::VerFileIterator J = V.FileList(); 
-		 J.end() == false; J++)
+		 J.end() == false; ++J)
 	    {
 	    {
 	       if (CleanInstalled == true &&
 	       if (CleanInstalled == true &&
 		   (J.File()->Flags & pkgCache::Flag::NotSource) != 0)
 		   (J.File()->Flags & pkgCache::Flag::NotSource) != 0)

+ 2 - 2
apt-pkg/clean.h

@@ -20,11 +20,11 @@ class pkgArchiveCleaner
 
 
    protected:
    protected:
    
    
-   virtual void Erase(const char * /*File*/,string /*Pkg*/,string /*Ver*/,struct stat & /*St*/) {};
+   virtual void Erase(const char * /*File*/,std::string /*Pkg*/,std::string /*Ver*/,struct stat & /*St*/) {};
 
 
    public:   
    public:   
    
    
-   bool Go(string Dir,pkgCache &Cache);
+   bool Go(std::string Dir,pkgCache &Cache);
    virtual ~pkgArchiveCleaner() {};
    virtual ~pkgArchiveCleaner() {};
 };
 };
 
 

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

@@ -10,6 +10,8 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include<config.h>
+
 #include <apt-pkg/cdromutl.h>
 #include <apt-pkg/cdromutl.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/md5.h>
 #include <apt-pkg/md5.h>
@@ -17,8 +19,6 @@
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
 
 
-#include <apti18n.h>
-    
 #include <sys/wait.h>
 #include <sys/wait.h>
 #include <sys/statvfs.h>
 #include <sys/statvfs.h>
 #include <dirent.h>
 #include <dirent.h>
@@ -26,8 +26,12 @@
 #include <sys/stat.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <stdio.h>
+
+#include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
 
 
+using std::string;
+
 // IsMounted - Returns true if the mount point is mounted		/*{{{*/
 // IsMounted - Returns true if the mount point is mounted		/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* This is a simple algorithm that should always work, we stat the mount point
 /* This is a simple algorithm that should always work, we stat the mount point

+ 5 - 7
apt-pkg/contrib/cdromutl.h

@@ -12,13 +12,11 @@
 
 
 #include <string>
 #include <string>
 
 
-using std::string;
-
 // mount cdrom, DeviceName (e.g. /dev/sr0) is optional
 // mount cdrom, DeviceName (e.g. /dev/sr0) is optional
-bool MountCdrom(string Path, string DeviceName="");
-bool UnmountCdrom(string Path);
-bool IdentCdrom(string CD,string &Res,unsigned int Version = 2);
-bool IsMounted(string &Path);
-string FindMountPointForDevice(const char *device);
+bool MountCdrom(std::string Path, std::string DeviceName="");
+bool UnmountCdrom(std::string Path);
+bool IdentCdrom(std::string CD,std::string &Res,unsigned int Version = 2);
+bool IsMounted(std::string &Path);
+std::string FindMountPointForDevice(const char *device);
 
 
 #endif
 #endif

+ 15 - 18
apt-pkg/contrib/cmndline.cc

@@ -11,11 +11,14 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include files							/*{{{*/
 // Include files							/*{{{*/
+#include<config.h>
+
+#include <apt-pkg/configuration.h>
 #include <apt-pkg/cmndline.h>
 #include <apt-pkg/cmndline.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
 
 
-#include <apti18n.h>    
+#include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
 using namespace std;
 using namespace std;
 
 
@@ -87,9 +90,8 @@ bool CommandLine::Parse(int argc,const char **argv)
       Opt++;
       Opt++;
 
 
       // Match up to a = against the list
       // Match up to a = against the list
-      const char *OptEnd = Opt;
       Args *A;
       Args *A;
-      for (; *OptEnd != 0 && *OptEnd != '='; OptEnd++);
+      const char *OptEnd = strchrnul(Opt, '=');
       for (A = ArgList; A->end() == false && 
       for (A = ArgList; A->end() == false && 
 	   stringcasecmp(Opt,OptEnd,A->LongOpt) != 0; A++);
 	   stringcasecmp(Opt,OptEnd,A->LongOpt) != 0; A++);
       
       
@@ -97,9 +99,8 @@ bool CommandLine::Parse(int argc,const char **argv)
       bool PreceedMatch = false;
       bool PreceedMatch = false;
       if (A->end() == true)
       if (A->end() == true)
       {
       {
-	 for (; Opt != OptEnd && *Opt != '-'; Opt++);
-
-	 if (Opt == OptEnd)
+         Opt = (const char*) memchr(Opt, '-', OptEnd - Opt);
+	 if (Opt == NULL)
 	    return _error->Error(_("Command line option %s is not understood"),argv[I]);
 	    return _error->Error(_("Command line option %s is not understood"),argv[I]);
 	 Opt++;
 	 Opt++;
 	 
 	 
@@ -194,9 +195,8 @@ bool CommandLine::HandleOpt(int &I,int argc,const char *argv[],
       // Arbitrary item specification
       // Arbitrary item specification
       if ((A->Flags & ArbItem) == ArbItem)
       if ((A->Flags & ArbItem) == ArbItem)
       {
       {
-	 const char *J;
-	 for (J = Argument; *J != 0 && *J != '='; J++);
-	 if (*J == 0)
+	 const char *J = strchr(Argument, '=');
+	 if (J == NULL)
 	    return _error->Error(_("Option %s: Configuration item specification must have an =<val>."),argv[I]);
 	    return _error->Error(_("Option %s: Configuration item specification must have an =<val>."),argv[I]);
 
 
 	 // = is trailing
 	 // = is trailing
@@ -212,8 +212,7 @@ bool CommandLine::HandleOpt(int &I,int argc,const char *argv[],
 	 return true;
 	 return true;
       }
       }
       
       
-      const char *I = A->ConfName;
-      for (; *I != 0 && *I != ' '; I++);
+      const char *I = strchrnul(A->ConfName, ' ');
       if (*I == ' ')
       if (*I == ' ')
 	 Conf->Set(string(A->ConfName,0,I-A->ConfName),string(I+1) + Argument);
 	 Conf->Set(string(A->ConfName,0,I-A->ConfName),string(I+1) + Argument);
       else
       else
@@ -269,10 +268,9 @@ bool CommandLine::HandleOpt(int &I,int argc,const char *argv[],
 	 // Skip the leading dash
 	 // Skip the leading dash
 	 const char *J = argv[I];
 	 const char *J = argv[I];
 	 for (; *J != 0 && *J == '-'; J++);
 	 for (; *J != 0 && *J == '-'; J++);
-	 
-	 const char *JEnd = J;
-	 for (; *JEnd != 0 && *JEnd != '-'; JEnd++);
-	 if (*JEnd != 0)
+
+	 const char *JEnd = strchr(J, '-');
+	 if (JEnd != NULL)
 	 {
 	 {
 	    strncpy(Buffer,J,JEnd - J);
 	    strncpy(Buffer,J,JEnd - J);
 	    Buffer[JEnd - J] = 0;
 	    Buffer[JEnd - J] = 0;
@@ -373,9 +371,8 @@ void CommandLine::SaveInConfig(unsigned int const &argc, char const * const * co
 	 {
 	 {
 	    // That is possibly an option: Quote it if it includes spaces,
 	    // That is possibly an option: Quote it if it includes spaces,
 	    // the benefit is that this will eliminate also most false positives
 	    // the benefit is that this will eliminate also most false positives
-	    const char* c = &argv[i][j+1];
-	    for (; *c != '\0' && *c != ' '; ++c);
-	    if (*c == '\0') continue;
+	    const char* c = strchr(&argv[i][j+1], ' ');
+	    if (c == NULL) continue;
 	    cmdline[++length] = '"';
 	    cmdline[++length] = '"';
 	    closeQuote = true;
 	    closeQuote = true;
 	 }
 	 }

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

@@ -44,9 +44,7 @@
 #ifndef PKGLIB_CMNDLINE_H
 #ifndef PKGLIB_CMNDLINE_H
 #define PKGLIB_CMNDLINE_H
 #define PKGLIB_CMNDLINE_H
 
 
-
-
-#include <apt-pkg/configuration.h>
+class Configuration;
 
 
 class CommandLine
 class CommandLine
 {
 {

+ 7 - 4
apt-pkg/contrib/configuration.cc

@@ -15,16 +15,19 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include files							/*{{{*/
 // Include files							/*{{{*/
+#include <config.h>
+
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
 #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 <apti18n.h>
 
 
 #include <vector>
 #include <vector>
 #include <fstream>
 #include <fstream>
 #include <iostream>
 #include <iostream>
 
 
+#include <apti18n.h>
+
 using namespace std;
 using namespace std;
 									/*}}}*/
 									/*}}}*/
 
 
@@ -672,9 +675,9 @@ bool ReadConfigFile(Configuration &Conf,const string &FName,bool const &AsSectio
 	    // Put the last fragment into the buffer
 	    // Put the last fragment into the buffer
 	    std::string::const_iterator NonWhitespaceStart = Start;
 	    std::string::const_iterator NonWhitespaceStart = Start;
 	    std::string::const_iterator NonWhitespaceStop = I;
 	    std::string::const_iterator NonWhitespaceStop = I;
-	    for (; NonWhitespaceStart != I && isspace(*NonWhitespaceStart) != 0; NonWhitespaceStart++)
+	    for (; NonWhitespaceStart != I && isspace(*NonWhitespaceStart) != 0; ++NonWhitespaceStart)
 	      ;
 	      ;
-	    for (; NonWhitespaceStop != NonWhitespaceStart && isspace(NonWhitespaceStop[-1]) != 0; NonWhitespaceStop--)
+	    for (; NonWhitespaceStop != NonWhitespaceStart && isspace(NonWhitespaceStop[-1]) != 0; --NonWhitespaceStop)
 	      ;
 	      ;
 	    if (LineBuffer.empty() == false && NonWhitespaceStop - NonWhitespaceStart != 0)
 	    if (LineBuffer.empty() == false && NonWhitespaceStop - NonWhitespaceStart != 0)
 	       LineBuffer += ' ';
 	       LineBuffer += ' ';
@@ -850,7 +853,7 @@ bool ReadConfigDir(Configuration &Conf,const string &Dir,
    vector<string> const List = GetListOfFilesInDir(Dir, "conf", true, true);
    vector<string> const List = GetListOfFilesInDir(Dir, "conf", true, true);
 
 
    // Read the files
    // Read the files
-   for (vector<string>::const_iterator I = List.begin(); I != List.end(); I++)
+   for (vector<string>::const_iterator I = List.begin(); I != List.end(); ++I)
       if (ReadConfigFile(Conf,*I,AsSectional,Depth) == false)
       if (ReadConfigFile(Conf,*I,AsSectional,Depth) == false)
 	 return false;
 	 return false;
    return true;
    return true;

+ 22 - 24
apt-pkg/contrib/configuration.h

@@ -34,21 +34,19 @@
 #include <vector>
 #include <vector>
 #include <iostream>
 #include <iostream>
 
 
-using std::string;
-
 class Configuration
 class Configuration
 {
 {
    public:
    public:
    
    
    struct Item
    struct Item
    {
    {
-      string Value;
-      string Tag;
+      std::string Value;
+      std::string Tag;
       Item *Parent;
       Item *Parent;
       Item *Child;
       Item *Child;
       Item *Next;
       Item *Next;
       
       
-      string FullTag(const Item *Stop = 0) const;
+      std::string FullTag(const Item *Stop = 0) const;
       
       
       Item() : Parent(0), Child(0), Next(0) {};
       Item() : Parent(0), Child(0), Next(0) {};
    };
    };
@@ -67,35 +65,35 @@ class Configuration
    
    
    public:
    public:
 
 
-   string Find(const char *Name,const char *Default = 0) const;
-   string Find(string const &Name,const char *Default = 0) const {return Find(Name.c_str(),Default);};
-   string Find(string const &Name, string const &Default) const {return Find(Name.c_str(),Default.c_str());};
-   string FindFile(const char *Name,const char *Default = 0) const;
-   string FindDir(const char *Name,const char *Default = 0) const;
-   std::vector<string> FindVector(const char *Name) const;
-   std::vector<string> FindVector(string const &Name) const { return FindVector(Name.c_str()); };
+   std::string Find(const char *Name,const char *Default = 0) const;
+   std::string Find(std::string const &Name,const char *Default = 0) const {return Find(Name.c_str(),Default);};
+   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 FindDir(const char *Name,const char *Default = 0) 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()); };
    int FindI(const char *Name,int const &Default = 0) const;
    int FindI(const char *Name,int const &Default = 0) const;
-   int FindI(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;
-   bool FindB(string const &Name,bool const &Default = false) const {return FindB(Name.c_str(),Default);};
-   string FindAny(const char *Name,const char *Default = 0) const;
+   bool FindB(std::string const &Name,bool const &Default = false) const {return FindB(Name.c_str(),Default);};
+   std::string FindAny(const char *Name,const char *Default = 0) const;
 	      
 	      
-   inline void Set(const string &Name,const string &Value) {Set(Name.c_str(),Value);};
-   void CndSet(const char *Name,const string &Value);
+   inline void Set(const std::string &Name,const std::string &Value) {Set(Name.c_str(),Value);};
+   void CndSet(const char *Name,const std::string &Value);
    void CndSet(const char *Name,const int Value);
    void CndSet(const char *Name,const int Value);
-   void Set(const char *Name,const string &Value);
+   void Set(const char *Name,const std::string &Value);
    void Set(const char *Name,const int &Value);
    void Set(const char *Name,const int &Value);
    
    
-   inline bool Exists(const string &Name) const {return Exists(Name.c_str());};
+   inline bool Exists(const std::string &Name) const {return Exists(Name.c_str());};
    bool Exists(const char *Name) const;
    bool Exists(const char *Name) const;
    bool ExistsAny(const char *Name) const;
    bool ExistsAny(const char *Name) const;
 
 
    // clear a whole tree
    // clear a whole tree
-   void Clear(const string &Name);
+   void Clear(const std::string &Name);
 
 
    // remove a certain value from a list (e.g. the list of "APT::Keep-Fds")
    // remove a certain value from a list (e.g. the list of "APT::Keep-Fds")
-   void Clear(string const &List, string const &Value);
-   void Clear(string const &List, int const &Value);
+   void Clear(std::string const &List, std::string const &Value);
+   void Clear(std::string const &List, int const &Value);
 
 
    inline const Item *Tree(const char *Name) const {return Lookup(Name);};
    inline const Item *Tree(const char *Name) const {return Lookup(Name);};
 
 
@@ -127,11 +125,11 @@ class Configuration
 
 
 extern Configuration *_config;
 extern Configuration *_config;
 
 
-bool ReadConfigFile(Configuration &Conf,const string &FName,
+bool ReadConfigFile(Configuration &Conf,const std::string &FName,
 		    bool const &AsSectional = false,
 		    bool const &AsSectional = false,
 		    unsigned const &Depth = 0);
 		    unsigned const &Depth = 0);
 
 
-bool ReadConfigDir(Configuration &Conf,const string &Dir,
+bool ReadConfigDir(Configuration &Conf,const std::string &Dir,
 		   bool const &AsSectional = false,
 		   bool const &AsSectional = false,
 		   unsigned const &Depth = 0);
 		   unsigned const &Depth = 0);
 
 

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

@@ -15,6 +15,8 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include <config.h>
+
 #include <apt-pkg/crc-16.h>
 #include <apt-pkg/crc-16.h>
 									/*}}}*/
 									/*}}}*/
 
 
@@ -63,7 +65,7 @@ static unsigned short const crc16_table[256] =
 /* Recompute the FCS with one more character appended. */
 /* Recompute the FCS with one more character appended. */
 #define CalcFCS(fcs, c) (((fcs) >> 8) ^ crc16_table[((fcs) ^ (c)) & 0xff])
 #define CalcFCS(fcs, c) (((fcs) >> 8) ^ crc16_table[((fcs) ^ (c)) & 0xff])
 unsigned short AddCRC16(unsigned short fcs, void const *Buf,
 unsigned short AddCRC16(unsigned short fcs, void const *Buf,
-			unsigned long len) 
+			unsigned long long len)
 {
 {
    unsigned char const *buf = (unsigned char const *)Buf;
    unsigned char const *buf = (unsigned char const *)Buf;
    while (len--)
    while (len--)

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

@@ -12,6 +12,6 @@
 
 
 #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 len);
+			unsigned long long len);
 
 
 #endif
 #endif

+ 6 - 5
apt-pkg/contrib/error.cc

@@ -13,6 +13,8 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include <config.h>
+
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 
 
 #include <iostream>
 #include <iostream>
@@ -24,8 +26,7 @@
 #include <string>
 #include <string>
 #include <cstring>
 #include <cstring>
 
 
-#include "config.h"
-   									/*}}}*/
+									/*}}}*/
 
 
 // Global Error Object							/*{{{*/
 // Global Error Object							/*{{{*/
 /* If the implementation supports posix threads then the accessor function
 /* If the implementation supports posix threads then the accessor function
@@ -193,7 +194,7 @@ bool GlobalError::PopMessage(std::string &Text) {
 
 
 	// check if another error message is pending
 	// check if another error message is pending
 	for (std::list<Item>::const_iterator m = Messages.begin();
 	for (std::list<Item>::const_iterator m = Messages.begin();
-	     m != Messages.end(); m++)
+	     m != Messages.end(); ++m)
 		if (m->Type == ERROR || m->Type == FATAL)
 		if (m->Type == ERROR || m->Type == FATAL)
 			return Ret;
 			return Ret;
 
 
@@ -210,7 +211,7 @@ void GlobalError::DumpErrors(std::ostream &out, MsgType const &threshold,
 			Messages.insert(Messages.begin(), s->Messages.begin(), s->Messages.end());
 			Messages.insert(Messages.begin(), s->Messages.begin(), s->Messages.end());
 
 
 	for (std::list<Item>::const_iterator m = Messages.begin();
 	for (std::list<Item>::const_iterator m = Messages.begin();
-	     m != Messages.end(); m++)
+	     m != Messages.end(); ++m)
 		if (m->Type >= threshold)
 		if (m->Type >= threshold)
 			out << (*m) << std::endl;
 			out << (*m) << std::endl;
 	Discard();
 	Discard();
@@ -231,7 +232,7 @@ bool GlobalError::empty(MsgType const &trashhold) const {
 		return true;
 		return true;
 
 
 	for (std::list<Item>::const_iterator m = Messages.begin();
 	for (std::list<Item>::const_iterator m = Messages.begin();
-	     m != Messages.end(); m++)
+	     m != Messages.end(); ++m)
 		if (m->Type >= trashhold)
 		if (m->Type >= trashhold)
 			return false;
 			return false;
 
 

+ 21 - 19
apt-pkg/contrib/fileutl.cc

@@ -18,14 +18,14 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include <config.h>
+
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/sptr.h>
 #include <apt-pkg/sptr.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
 
 
-#include <apti18n.h>
-
 #include <cstdlib>
 #include <cstdlib>
 #include <cstring>
 #include <cstring>
 #include <cstdio>
 #include <cstdio>
@@ -43,10 +43,11 @@
 #include <set>
 #include <set>
 #include <algorithm>
 #include <algorithm>
 
 
-#include <config.h>
 #ifdef WORDS_BIGENDIAN
 #ifdef WORDS_BIGENDIAN
 #include <inttypes.h>
 #include <inttypes.h>
 #endif
 #endif
+
+#include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
 
 
 using namespace std;
 using namespace std;
@@ -132,10 +133,10 @@ bool CopyFile(FileFd &From,FileFd &To)
    
    
    // Buffered copy between fds
    // Buffered copy between fds
    SPtrArray<unsigned char> Buf = new unsigned char[64000];
    SPtrArray<unsigned char> Buf = new unsigned char[64000];
-   unsigned long Size = From.Size();
+   unsigned long long Size = From.Size();
    while (Size != 0)
    while (Size != 0)
    {
    {
-      unsigned long ToRead = Size;
+      unsigned long long ToRead = Size;
       if (Size > 64000)
       if (Size > 64000)
 	 ToRead = 64000;
 	 ToRead = 64000;
       
       
@@ -810,7 +811,7 @@ FileFd::~FileFd()
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* We are carefull to handle interruption by a signal while reading 
 /* We are carefull to handle interruption by a signal while reading 
    gracefully. */
    gracefully. */
-bool FileFd::Read(void *To,unsigned long Size,unsigned long *Actual)
+bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual)
 {
 {
    int Res;
    int Res;
    errno = 0;
    errno = 0;
@@ -849,13 +850,13 @@ bool FileFd::Read(void *To,unsigned long Size,unsigned long *Actual)
    }
    }
    
    
    Flags |= Fail;
    Flags |= Fail;
-   return _error->Error(_("read, still have %lu to read but none left"),Size);
+   return _error->Error(_("read, still have %llu to read but none left"), Size);
 }
 }
 									/*}}}*/
 									/*}}}*/
 // FileFd::Write - Write to the file					/*{{{*/
 // FileFd::Write - Write to the file					/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-bool FileFd::Write(const void *From,unsigned long Size)
+bool FileFd::Write(const void *From,unsigned long long Size)
 {
 {
    int Res;
    int Res;
    errno = 0;
    errno = 0;
@@ -882,13 +883,13 @@ bool FileFd::Write(const void *From,unsigned long Size)
       return true;
       return true;
    
    
    Flags |= Fail;
    Flags |= Fail;
-   return _error->Error(_("write, still have %lu to write but couldn't"),Size);
+   return _error->Error(_("write, still have %llu to write but couldn't"), Size);
 }
 }
 									/*}}}*/
 									/*}}}*/
 // FileFd::Seek - Seek in the file					/*{{{*/
 // FileFd::Seek - Seek in the file					/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-bool FileFd::Seek(unsigned long To)
+bool FileFd::Seek(unsigned long long To)
 {
 {
    int res;
    int res;
    if (gz)
    if (gz)
@@ -898,7 +899,7 @@ bool FileFd::Seek(unsigned long To)
    if (res != (signed)To)
    if (res != (signed)To)
    {
    {
       Flags |= Fail;
       Flags |= Fail;
-      return _error->Error("Unable to seek to %lu",To);
+      return _error->Error("Unable to seek to %llu", To);
    }
    }
    
    
    return true;
    return true;
@@ -907,7 +908,7 @@ bool FileFd::Seek(unsigned long To)
 // FileFd::Skip - Seek in the file					/*{{{*/
 // FileFd::Skip - Seek in the file					/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-bool FileFd::Skip(unsigned long Over)
+bool FileFd::Skip(unsigned long long Over)
 {
 {
    int res;
    int res;
    if (gz)
    if (gz)
@@ -917,7 +918,7 @@ bool FileFd::Skip(unsigned long Over)
    if (res < 0)
    if (res < 0)
    {
    {
       Flags |= Fail;
       Flags |= Fail;
-      return _error->Error("Unable to seek ahead %lu",Over);
+      return _error->Error("Unable to seek ahead %llu",Over);
    }
    }
    
    
    return true;
    return true;
@@ -926,7 +927,7 @@ bool FileFd::Skip(unsigned long Over)
 // FileFd::Truncate - Truncate the file 				/*{{{*/
 // FileFd::Truncate - Truncate the file 				/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-bool FileFd::Truncate(unsigned long To)
+bool FileFd::Truncate(unsigned long long To)
 {
 {
    if (gz)
    if (gz)
    {
    {
@@ -936,7 +937,7 @@ bool FileFd::Truncate(unsigned long To)
    if (ftruncate(iFd,To) != 0)
    if (ftruncate(iFd,To) != 0)
    {
    {
       Flags |= Fail;
       Flags |= Fail;
-      return _error->Error("Unable to truncate to %lu",To);
+      return _error->Error("Unable to truncate to %llu",To);
    }
    }
    
    
    return true;
    return true;
@@ -945,7 +946,7 @@ bool FileFd::Truncate(unsigned long To)
 // FileFd::Tell - Current seek position					/*{{{*/
 // FileFd::Tell - Current seek position					/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-unsigned long FileFd::Tell()
+unsigned long long FileFd::Tell()
 {
 {
    off_t Res;
    off_t Res;
    if (gz)
    if (gz)
@@ -960,7 +961,7 @@ unsigned long FileFd::Tell()
 // FileFd::FileSize - Return the size of the file			/*{{{*/
 // FileFd::FileSize - Return the size of the file			/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-unsigned long FileFd::FileSize()
+unsigned long long FileFd::FileSize()
 {
 {
    struct stat Buf;
    struct stat Buf;
 
 
@@ -972,9 +973,9 @@ unsigned long FileFd::FileSize()
 // FileFd::Size - Return the size of the content in the file		/*{{{*/
 // FileFd::Size - Return the size of the content in the file		/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-unsigned long FileFd::Size()
+unsigned long long FileFd::Size()
 {
 {
-   unsigned long size = FileSize();
+   unsigned long long size = FileSize();
 
 
    // only check gzsize if we are actually a gzip file, just checking for
    // only check gzsize if we are actually a gzip file, just checking for
    // "gz" is not sufficient as uncompressed files will be opened with
    // "gz" is not sufficient as uncompressed files will be opened with
@@ -984,6 +985,7 @@ unsigned long FileFd::Size()
        /* unfortunately zlib.h doesn't provide a gzsize(), so we have to do
        /* unfortunately zlib.h doesn't provide a gzsize(), so we have to do
 	* this ourselves; the original (uncompressed) file size is the last 32
 	* this ourselves; the original (uncompressed) file size is the last 32
 	* bits of the file */
 	* bits of the file */
+       // FIXME: Size for gz-files is limited by 32bit… no largefile support
        off_t orig_pos = lseek(iFd, 0, SEEK_CUR);
        off_t orig_pos = lseek(iFd, 0, SEEK_CUR);
        if (lseek(iFd, -4, SEEK_END) < 0)
        if (lseek(iFd, -4, SEEK_END) < 0)
 	   return _error->Errno("lseek","Unable to seek to end of gzipped file");
 	   return _error->Errno("lseek","Unable to seek to end of gzipped file");

+ 45 - 32
apt-pkg/contrib/fileutl.h

@@ -31,8 +31,6 @@
 /* Define this for python-apt */
 /* Define this for python-apt */
 #define APT_HAS_GZIP 1
 #define APT_HAS_GZIP 1
 
 
-using std::string;
-
 class FileFd
 class FileFd
 {
 {
    protected:
    protected:
@@ -41,30 +39,45 @@ class FileFd
    enum LocalFlags {AutoClose = (1<<0),Fail = (1<<1),DelOnFail = (1<<2),
    enum LocalFlags {AutoClose = (1<<0),Fail = (1<<1),DelOnFail = (1<<2),
                     HitEof = (1<<3), Replace = (1<<4) };
                     HitEof = (1<<3), Replace = (1<<4) };
    unsigned long Flags;
    unsigned long Flags;
-   string FileName;
-   string TemporaryFileName;
+   std::string FileName;
+   std::string TemporaryFileName;
    gzFile gz;
    gzFile gz;
 
 
    public:
    public:
    enum OpenMode {ReadOnly,WriteEmpty,WriteExists,WriteAny,WriteTemp,ReadOnlyGzip,
    enum OpenMode {ReadOnly,WriteEmpty,WriteExists,WriteAny,WriteTemp,ReadOnlyGzip,
                   WriteAtomic};
                   WriteAtomic};
    
    
-   inline bool Read(void *To,unsigned long Size,bool AllowEof)
+   inline bool Read(void *To,unsigned long long Size,bool AllowEof)
    {
    {
-      unsigned long Jnk;
+      unsigned long long Jnk;
       if (AllowEof)
       if (AllowEof)
 	 return Read(To,Size,&Jnk);
 	 return Read(To,Size,&Jnk);
       return Read(To,Size);
       return Read(To,Size);
    }   
    }   
-   bool Read(void *To,unsigned long Size,unsigned long *Actual = 0);
-   bool Write(const void *From,unsigned long Size);
-   bool Seek(unsigned long To);
-   bool Skip(unsigned long To);
-   bool Truncate(unsigned long To);
-   unsigned long Tell();
-   unsigned long Size();
-   unsigned long FileSize();
-   bool Open(string FileName,OpenMode Mode,unsigned long Perms = 0666);
+   bool Read(void *To,unsigned long long Size,unsigned long long *Actual = 0);
+   bool Write(const void *From,unsigned long long Size);
+   bool Seek(unsigned long long To);
+   bool Skip(unsigned long long To);
+   bool Truncate(unsigned long long To);
+   unsigned long long Tell();
+   unsigned long long Size();
+   unsigned long long FileSize();
+
+   /* You want to use 'unsigned long long' if you are talking about a file
+      to be able to support large files (>2 or >4 GB) properly.
+      This shouldn't happen all to often for the indexes, but deb's might be…
+      And as the auto-conversation converts a 'unsigned long *' to a 'bool'
+      instead of 'unsigned long long *' we need to provide this explicitely -
+      otherwise applications magically start to fail… */
+   __deprecated bool Read(void *To,unsigned long long Size,unsigned long *Actual)
+   {
+	unsigned long long R;
+	bool const T = Read(To, Size, &R);
+	*Actual = R;
+	return T;
+   }
+
+   bool Open(std::string FileName,OpenMode Mode,unsigned long Perms = 0666);
    bool OpenDescriptor(int Fd, OpenMode Mode, bool AutoClose=false);
    bool OpenDescriptor(int Fd, OpenMode Mode, bool AutoClose=false);
    bool Close();
    bool Close();
    bool Sync();
    bool Sync();
@@ -78,9 +91,9 @@ class FileFd
    inline void EraseOnFailure() {Flags |= DelOnFail;};
    inline void EraseOnFailure() {Flags |= DelOnFail;};
    inline void OpFail() {Flags |= Fail;};
    inline void OpFail() {Flags |= Fail;};
    inline bool Eof() {return (Flags & HitEof) == HitEof;};
    inline bool Eof() {return (Flags & HitEof) == HitEof;};
-   inline string &Name() {return FileName;};
+   inline std::string &Name() {return FileName;};
    
    
-   FileFd(string FileName,OpenMode Mode,unsigned long Perms = 0666) : iFd(-1), 
+   FileFd(std::string FileName,OpenMode Mode,unsigned long Perms = 0666) : iFd(-1), 
             Flags(0), gz(NULL)
             Flags(0), gz(NULL)
    {
    {
       Open(FileName,Mode,Perms);
       Open(FileName,Mode,Perms);
@@ -92,12 +105,12 @@ class FileFd
 
 
 bool RunScripts(const char *Cnf);
 bool RunScripts(const char *Cnf);
 bool CopyFile(FileFd &From,FileFd &To);
 bool CopyFile(FileFd &From,FileFd &To);
-int GetLock(string File,bool Errors = true);
-bool FileExists(string File);
-bool RealFileExists(string File);
-bool DirectoryExists(string const &Path) __attrib_const;
-bool CreateDirectory(string const &Parent, string const &Path);
-time_t GetModificationTime(string const &Path);
+int GetLock(std::string File,bool Errors = true);
+bool FileExists(std::string File);
+bool RealFileExists(std::string File);
+bool DirectoryExists(std::string const &Path) __attrib_const;
+bool CreateDirectory(std::string const &Parent, std::string const &Path);
+time_t GetModificationTime(std::string const &Path);
 
 
 /** \brief Ensure the existence of the given Path
 /** \brief Ensure the existence of the given Path
  *
  *
@@ -105,13 +118,13 @@ time_t GetModificationTime(string const &Path);
  *  /apt/ will be removed before CreateDirectory call.
  *  /apt/ will be removed before CreateDirectory call.
  *  \param Path which should exist after (successful) call
  *  \param Path which should exist after (successful) call
  */
  */
-bool CreateAPTDirectoryIfNeeded(string const &Parent, string const &Path);
+bool CreateAPTDirectoryIfNeeded(std::string const &Parent, std::string const &Path);
 
 
-std::vector<string> GetListOfFilesInDir(string const &Dir, string const &Ext,
+std::vector<std::string> GetListOfFilesInDir(std::string const &Dir, std::string const &Ext,
 					bool const &SortList, bool const &AllowNoExt=false);
 					bool const &SortList, bool const &AllowNoExt=false);
-std::vector<string> GetListOfFilesInDir(string const &Dir, std::vector<string> const &Ext,
+std::vector<std::string> GetListOfFilesInDir(std::string const &Dir, std::vector<std::string> const &Ext,
 					bool const &SortList);
 					bool const &SortList);
-string SafeGetCWD();
+std::string SafeGetCWD();
 void SetCloseExec(int Fd,bool Close);
 void SetCloseExec(int Fd,bool Close);
 void SetNonBlock(int Fd,bool Block);
 void SetNonBlock(int Fd,bool Block);
 bool WaitFd(int Fd,bool write = false,unsigned long timeout = 0);
 bool WaitFd(int Fd,bool write = false,unsigned long timeout = 0);
@@ -119,10 +132,10 @@ pid_t ExecFork();
 bool ExecWait(pid_t Pid,const char *Name,bool Reap = false);
 bool ExecWait(pid_t Pid,const char *Name,bool Reap = false);
 
 
 // File string manipulators
 // File string manipulators
-string flNotDir(string File);
-string flNotFile(string File);
-string flNoLink(string File);
-string flExtension(string File);
-string flCombine(string Dir,string File);
+std::string flNotDir(std::string File);
+std::string flNotFile(std::string File);
+std::string flNoLink(std::string File);
+std::string flExtension(std::string File);
+std::string flCombine(std::string Dir,std::string File);
 
 
 #endif
 #endif

+ 20 - 18
apt-pkg/contrib/hashes.cc

@@ -11,12 +11,14 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include <config.h>
+
 #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/macros.h>
 
 
-#include <unistd.h>    
+#include <unistd.h>
 #include <string>
 #include <string>
 #include <iostream>
 #include <iostream>
 									/*}}}*/
 									/*}}}*/
@@ -30,20 +32,20 @@ HashString::HashString()
 {
 {
 }
 }
 
 
-HashString::HashString(string Type, string Hash) : Type(Type), Hash(Hash)
+HashString::HashString(std::string Type, std::string Hash) : Type(Type), Hash(Hash)
 {
 {
 }
 }
 
 
-HashString::HashString(string StringedHash)				/*{{{*/
+HashString::HashString(std::string StringedHash)			/*{{{*/
 {
 {
    // legacy: md5sum without "MD5Sum:" prefix
    // legacy: md5sum without "MD5Sum:" prefix
-   if (StringedHash.find(":") == string::npos && StringedHash.size() == 32)
+   if (StringedHash.find(":") == std::string::npos && StringedHash.size() == 32)
    {
    {
       Type = "MD5Sum";
       Type = "MD5Sum";
       Hash = StringedHash;
       Hash = StringedHash;
       return;
       return;
    }
    }
-   string::size_type pos = StringedHash.find(":");
+   std::string::size_type pos = StringedHash.find(":");
    Type = StringedHash.substr(0,pos);
    Type = StringedHash.substr(0,pos);
    Hash = StringedHash.substr(pos+1, StringedHash.size() - pos);
    Hash = StringedHash.substr(pos+1, StringedHash.size() - pos);
 
 
@@ -51,34 +53,34 @@ HashString::HashString(string StringedHash)				/*{{{*/
       std::clog << "HashString(string): " << Type << " : " << Hash << std::endl;
       std::clog << "HashString(string): " << Type << " : " << Hash << std::endl;
 }
 }
 									/*}}}*/
 									/*}}}*/
-bool HashString::VerifyFile(string filename) const			/*{{{*/
+bool HashString::VerifyFile(std::string filename) const			/*{{{*/
 {
 {
-   string fileHash;
+   std::string fileHash;
 
 
    FileFd Fd(filename, FileFd::ReadOnly);
    FileFd Fd(filename, FileFd::ReadOnly);
    if(Type == "MD5Sum")
    if(Type == "MD5Sum")
    {
    {
       MD5Summation MD5;
       MD5Summation MD5;
       MD5.AddFD(Fd.Fd(), Fd.Size());
       MD5.AddFD(Fd.Fd(), Fd.Size());
-      fileHash = (string)MD5.Result();
+      fileHash = (std::string)MD5.Result();
    }
    }
    else if (Type == "SHA1")
    else if (Type == "SHA1")
    {
    {
       SHA1Summation SHA1;
       SHA1Summation SHA1;
       SHA1.AddFD(Fd.Fd(), Fd.Size());
       SHA1.AddFD(Fd.Fd(), Fd.Size());
-      fileHash = (string)SHA1.Result();
+      fileHash = (std::string)SHA1.Result();
    }
    }
    else if (Type == "SHA256")
    else if (Type == "SHA256")
    {
    {
       SHA256Summation SHA256;
       SHA256Summation SHA256;
       SHA256.AddFD(Fd.Fd(), Fd.Size());
       SHA256.AddFD(Fd.Fd(), Fd.Size());
-      fileHash = (string)SHA256.Result();
+      fileHash = (std::string)SHA256.Result();
    }
    }
    else if (Type == "SHA512")
    else if (Type == "SHA512")
    {
    {
       SHA512Summation SHA512;
       SHA512Summation SHA512;
       SHA512.AddFD(Fd.Fd(), Fd.Size());
       SHA512.AddFD(Fd.Fd(), Fd.Size());
-      fileHash = (string)SHA512.Result();
+      fileHash = (std::string)SHA512.Result();
    }
    }
    Fd.Close();
    Fd.Close();
 
 
@@ -98,26 +100,26 @@ bool HashString::empty() const
    return (Type.empty() || Hash.empty());
    return (Type.empty() || Hash.empty());
 }
 }
 
 
-string HashString::toStr() const
+std::string HashString::toStr() const
 {
 {
-   return Type+string(":")+Hash;
+   return Type + std::string(":") + Hash;
 }
 }
 
 
 // Hashes::AddFD - Add the contents of the FD				/*{{{*/
 // Hashes::AddFD - Add the contents of the FD				/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-bool Hashes::AddFD(int const Fd,unsigned long Size, bool const addMD5,
+bool Hashes::AddFD(int const Fd,unsigned long long Size, bool const addMD5,
 		   bool const addSHA1, bool const addSHA256, bool const addSHA512)
 		   bool const addSHA1, bool const addSHA256, bool const addSHA512)
 {
 {
    unsigned char Buf[64*64];
    unsigned char Buf[64*64];
-   int Res = 0;
+   ssize_t Res = 0;
    int ToEOF = (Size == 0);
    int ToEOF = (Size == 0);
    while (Size != 0 || ToEOF)
    while (Size != 0 || ToEOF)
    {
    {
-      unsigned n = sizeof(Buf);
-      if (!ToEOF) n = min(Size,(unsigned long)n);
+      unsigned long long n = sizeof(Buf);
+      if (!ToEOF) n = std::min(Size, n);
       Res = read(Fd,Buf,n);
       Res = read(Fd,Buf,n);
-      if (Res < 0 || (!ToEOF && (unsigned) Res != n)) // error, or short read
+      if (Res < 0 || (!ToEOF && Res != (ssize_t) n)) // error, or short read
 	 return false;
 	 return false;
       if (ToEOF && Res == 0) // EOF
       if (ToEOF && Res == 0) // EOF
 	 break;
 	 break;

+ 10 - 13
apt-pkg/contrib/hashes.h

@@ -22,31 +22,28 @@
 #include <vector>
 #include <vector>
 #include <cstring>
 #include <cstring>
 
 
-using std::min;
-using std::vector;
-
 // helper class that contains hash function name
 // helper class that contains hash function name
 // and hash
 // and hash
 class HashString
 class HashString
 {
 {
  protected:
  protected:
-   string Type;
-   string Hash;
+   std::string Type;
+   std::string Hash;
    static const char * _SupportedHashes[10];
    static const char * _SupportedHashes[10];
 
 
  public:
  public:
-   HashString(string Type, string Hash);
-   HashString(string StringedHashString);  // init from str as "type:hash"
+   HashString(std::string Type, std::string Hash);
+   HashString(std::string StringedHashString);  // init from str as "type:hash"
    HashString();
    HashString();
 
 
    // get hash type used
    // get hash type used
-   string HashType() { return Type; };
+   std::string HashType() { return Type; };
 
 
    // verify the given filename against the currently loaded hash
    // verify the given filename against the currently loaded hash
-   bool VerifyFile(string filename) const;
+   bool VerifyFile(std::string filename) const;
 
 
    // helper
    // helper
-   string toStr() const;                    // convert to str as "type:hash"
+   std::string toStr() const;                    // convert to str as "type:hash"
    bool empty() const;
    bool empty() const;
 
 
    // return the list of hashes we support
    // return the list of hashes we support
@@ -62,14 +59,14 @@ class Hashes
    SHA256Summation SHA256;
    SHA256Summation SHA256;
    SHA512Summation SHA512;
    SHA512Summation SHA512;
    
    
-   inline bool Add(const unsigned char *Data,unsigned long Size)
+   inline bool Add(const unsigned char *Data,unsigned long long Size)
    {
    {
       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 *)Data,strlen(Data));};
-   inline bool AddFD(int const Fd,unsigned 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 Size, bool const addMD5,
+   bool AddFD(int const Fd, unsigned long long Size, bool const addMD5,
 	      bool const addSHA1, bool const addSHA256, bool const addSHA512);
 	      bool const addSHA1, bool const addSHA256, bool const addSHA512);
    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);};

+ 6 - 5
apt-pkg/contrib/hashsum.cc

@@ -1,4 +1,5 @@
 // Cryptographic API Base
 // Cryptographic API Base
+#include <config.h>
 
 
 #include <unistd.h>
 #include <unistd.h>
 #include "hashsum_template.h"
 #include "hashsum_template.h"
@@ -6,16 +7,16 @@
 // Summation::AddFD - Add content of file into the checksum		/*{{{*/
 // Summation::AddFD - Add content of file into the checksum		/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-bool SummationImplementation::AddFD(int const Fd, unsigned long Size) {
+bool SummationImplementation::AddFD(int const Fd, unsigned long long Size) {
    unsigned char Buf[64 * 64];
    unsigned char Buf[64 * 64];
-   int Res = 0;
+   ssize_t Res = 0;
    int ToEOF = (Size == 0);
    int ToEOF = (Size == 0);
    while (Size != 0 || ToEOF)
    while (Size != 0 || ToEOF)
    {
    {
-      unsigned n = sizeof(Buf);
-      if (!ToEOF) n = min(Size,(unsigned long)n);
+      unsigned long long n = sizeof(Buf);
+      if (!ToEOF) n = std::min(Size, n);
       Res = read(Fd, Buf, n);
       Res = read(Fd, Buf, n);
-      if (Res < 0 || (!ToEOF && (unsigned) Res != n)) // error, or short read
+      if (Res < 0 || (!ToEOF && Res != (ssize_t) n)) // error, or short read
 	 return false;
 	 return false;
       if (ToEOF && Res == 0) // EOF
       if (ToEOF && Res == 0) // EOF
 	 break;
 	 break;

+ 13 - 12
apt-pkg/contrib/hashsum_template.h

@@ -15,9 +15,6 @@
 #include <algorithm>
 #include <algorithm>
 #include <stdint.h>
 #include <stdint.h>
 
 
-using std::string;
-using std::min;
-
 template<int N>
 template<int N>
 class HashSumValue
 class HashSumValue
 {
 {
@@ -29,9 +26,13 @@ class HashSumValue
    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
+   {
+      return memcmp(Sum,rhs.Sum,sizeof(Sum)) != 0;
+   };
 
 
-   string Value() const
+   std::string Value() const
    {
    {
       char Conv[16] =
       char Conv[16] =
       { '0','1','2','3','4','5','6','7','8','9','a','b',
       { '0','1','2','3','4','5','6','7','8','9','a','b',
@@ -48,7 +49,7 @@ class HashSumValue
          Result[I] = Conv[Sum[J] >> 4];
          Result[I] = Conv[Sum[J] >> 4];
          Result[I + 1] = Conv[Sum[J] & 0xF];
          Result[I + 1] = Conv[Sum[J] & 0xF];
       }
       }
-      return string(Result);
+      return std::string(Result);
    };
    };
    
    
    inline void Value(unsigned char S[N/8])
    inline void Value(unsigned char S[N/8])
@@ -57,12 +58,12 @@ class HashSumValue
          S[I] = Sum[I];
          S[I] = Sum[I];
    };
    };
 
 
-   inline operator string() const 
+   inline operator std::string() const 
    {
    {
       return Value();
       return Value();
    };
    };
 
 
-   bool Set(string Str) 
+   bool Set(std::string Str) 
    {
    {
       return Hex2Num(Str,Sum,sizeof(Sum));
       return Hex2Num(Str,Sum,sizeof(Sum));
    };
    };
@@ -73,7 +74,7 @@ class HashSumValue
          Sum[I] = S[I];
          Sum[I] = S[I];
    };
    };
 
 
-   HashSumValue(string Str) 
+   HashSumValue(std::string Str) 
    {
    {
          memset(Sum,0,sizeof(Sum));
          memset(Sum,0,sizeof(Sum));
          Set(Str);
          Set(Str);
@@ -87,8 +88,8 @@ class HashSumValue
 class SummationImplementation
 class SummationImplementation
 {
 {
    public:
    public:
-   virtual bool Add(const unsigned char *inbuf, unsigned long inlen) = 0;
-   inline bool Add(const char *inbuf, unsigned long const inlen)
+   virtual bool Add(const unsigned char *inbuf, unsigned long long inlen) = 0;
+   inline bool Add(const char *inbuf, unsigned long long const inlen)
    { return Add((unsigned char *)inbuf, inlen); };
    { return Add((unsigned char *)inbuf, inlen); };
 
 
    inline bool Add(const unsigned char *Data)
    inline bool Add(const unsigned char *Data)
@@ -101,7 +102,7 @@ class SummationImplementation
    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 Size = 0);
+   bool AddFD(int Fd, unsigned long long Size = 0);
 };
 };
 
 
 #endif
 #endif

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

@@ -35,6 +35,8 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include <config.h>
+
 #include <apt-pkg/md5.h>
 #include <apt-pkg/md5.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/macros.h>
 #include <apt-pkg/macros.h>
@@ -43,7 +45,6 @@
 #include <unistd.h>
 #include <unistd.h>
 #include <netinet/in.h>                          // For htonl
 #include <netinet/in.h>                          // For htonl
 #include <inttypes.h>
 #include <inttypes.h>
-#include <config.h>
 									/*}}}*/
 									/*}}}*/
 
 
 // byteSwap - Swap bytes in a buffer					/*{{{*/
 // byteSwap - Swap bytes in a buffer					/*{{{*/
@@ -186,7 +187,7 @@ MD5Summation::MD5Summation()
 // MD5Summation::Add - 'Add' a data set to the hash			/*{{{*/
 // MD5Summation::Add - 'Add' a data set to the hash			/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-bool MD5Summation::Add(const unsigned char *data,unsigned long len)
+bool MD5Summation::Add(const unsigned char *data,unsigned long long len)
 {
 {
    if (Done == true)
    if (Done == true)
       return false;
       return false;

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

@@ -29,9 +29,6 @@
 #include <algorithm>
 #include <algorithm>
 #include <stdint.h>
 #include <stdint.h>
 
 
-using std::string;
-using std::min;
-
 #include "hashsum_template.h"
 #include "hashsum_template.h"
 
 
 typedef HashSumValue<128> MD5SumValue;
 typedef HashSumValue<128> MD5SumValue;
@@ -45,7 +42,7 @@ class MD5Summation : public SummationImplementation
 
 
    public:
    public:
 
 
-   bool Add(const unsigned char *inbuf, unsigned long inlen);
+   bool Add(const unsigned char *inbuf, unsigned long long inlen);
    using SummationImplementation::Add;
    using SummationImplementation::Add;
 
 
    MD5SumValue Result();
    MD5SumValue Result();

+ 14 - 12
apt-pkg/contrib/mmap.cc

@@ -17,10 +17,11 @@
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
 #define _BSD_SOURCE
 #define _BSD_SOURCE
+#include <config.h>
+
 #include <apt-pkg/mmap.h>
 #include <apt-pkg/mmap.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
-
-#include <apti18n.h>
+#include <apt-pkg/fileutl.h>
 
 
 #include <sys/mman.h>
 #include <sys/mman.h>
 #include <sys/stat.h>
 #include <sys/stat.h>
@@ -28,9 +29,10 @@
 #include <fcntl.h>
 #include <fcntl.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <errno.h>
-
 #include <cstring>
 #include <cstring>
-   									/*}}}*/
+
+#include <apti18n.h>
+									/*}}}*/
 
 
 // MMap::MMap - Constructor						/*{{{*/
 // MMap::MMap - Constructor						/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
@@ -94,7 +96,7 @@ bool MMap::Map(FileFd &Fd)
 	    return false;
 	    return false;
       }
       }
       else
       else
-	 return _error->Errno("mmap",_("Couldn't make mmap of %lu bytes"),
+	 return _error->Errno("mmap",_("Couldn't make mmap of %llu bytes"),
 	                      iSize);
 	                      iSize);
      }
      }
 
 
@@ -165,7 +167,7 @@ bool MMap::Sync(unsigned long Start,unsigned long Stop)
       return true;
       return true;
    
    
 #ifdef _POSIX_SYNCHRONIZED_IO
 #ifdef _POSIX_SYNCHRONIZED_IO
-   unsigned long PSize = sysconf(_SC_PAGESIZE);
+   unsigned long long PSize = sysconf(_SC_PAGESIZE);
    if ((Flags & ReadOnly) != ReadOnly)
    if ((Flags & ReadOnly) != ReadOnly)
    {
    {
       if (SyncToFd != 0)
       if (SyncToFd != 0)
@@ -176,7 +178,7 @@ bool MMap::Sync(unsigned long Start,unsigned long Stop)
       }
       }
       else
       else
       {
       {
-	 if (msync((char *)Base+(int)(Start/PSize)*PSize,Stop - Start,MS_SYNC) < 0)
+	 if (msync((char *)Base+(unsigned long long)(Start/PSize)*PSize,Stop - Start,MS_SYNC) < 0)
 	    return _error->Errno("msync", _("Unable to synchronize mmap"));
 	    return _error->Errno("msync", _("Unable to synchronize mmap"));
       }
       }
    }
    }
@@ -196,7 +198,7 @@ DynamicMMap::DynamicMMap(FileFd &F,unsigned long Flags,unsigned long const &Work
    if (_error->PendingError() == true)
    if (_error->PendingError() == true)
       return;
       return;
    
    
-   unsigned long EndOfFile = Fd->Size();
+   unsigned long long EndOfFile = Fd->Size();
    if (EndOfFile > WorkSpace)
    if (EndOfFile > WorkSpace)
       WorkSpace = EndOfFile;
       WorkSpace = EndOfFile;
    else if(WorkSpace > 0)
    else if(WorkSpace > 0)
@@ -284,7 +286,7 @@ DynamicMMap::~DynamicMMap()
       return;
       return;
    }
    }
    
    
-   unsigned long EndOfFile = iSize;
+   unsigned long long EndOfFile = iSize;
    iSize = WorkSpace;
    iSize = WorkSpace;
    Close(false);
    Close(false);
    if(ftruncate(Fd->Fd(),EndOfFile) < 0)
    if(ftruncate(Fd->Fd(),EndOfFile) < 0)
@@ -294,9 +296,9 @@ DynamicMMap::~DynamicMMap()
 // DynamicMMap::RawAllocate - Allocate a raw chunk of unaligned space	/*{{{*/
 // DynamicMMap::RawAllocate - Allocate a raw chunk of unaligned space	/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* This allocates a block of memory aligned to the given size */
 /* This allocates a block of memory aligned to the given size */
-unsigned long DynamicMMap::RawAllocate(unsigned long Size,unsigned long Aln)
+unsigned long DynamicMMap::RawAllocate(unsigned long long Size,unsigned long Aln)
 {
 {
-   unsigned long Result = iSize;
+   unsigned long long Result = iSize;
    if (Aln != 0)
    if (Aln != 0)
       Result += Aln - (iSize%Aln);
       Result += Aln - (iSize%Aln);
 
 
@@ -411,7 +413,7 @@ bool DynamicMMap::Grow() {
 	if (GrowFactor <= 0)
 	if (GrowFactor <= 0)
 		return _error->Error(_("Unable to increase size of the MMap as automatic growing is disabled by user."));
 		return _error->Error(_("Unable to increase size of the MMap as automatic growing is disabled by user."));
 
 
-	unsigned long const newSize = WorkSpace + GrowFactor;
+	unsigned long long const newSize = WorkSpace + GrowFactor;
 
 
 	if(Fd != 0) {
 	if(Fd != 0) {
 		Fd->Seek(newSize - 1);
 		Fd->Seek(newSize - 1);

+ 6 - 7
apt-pkg/contrib/mmap.h

@@ -27,9 +27,8 @@
 
 
 
 
 #include <string>
 #include <string>
-#include <apt-pkg/fileutl.h>
 
 
-using std::string;
+class FileFd;
 
 
 /* This should be a 32 bit type, larger tyes use too much ram and smaller
 /* This should be a 32 bit type, larger tyes use too much ram and smaller
    types are too small. Where ever possible 'unsigned long' should be used
    types are too small. Where ever possible 'unsigned long' should be used
@@ -41,7 +40,7 @@ class MMap
    protected:
    protected:
    
    
    unsigned long Flags;
    unsigned long Flags;
-   unsigned long iSize;
+   unsigned long long iSize;
    void *Base;
    void *Base;
 
 
    // In case mmap can not be used, we keep a dup of the file
    // In case mmap can not be used, we keep a dup of the file
@@ -60,8 +59,8 @@ class MMap
    // Simple accessors
    // Simple accessors
    inline operator void *() {return Base;};
    inline operator void *() {return Base;};
    inline void *Data() {return Base;}; 
    inline void *Data() {return Base;}; 
-   inline unsigned long Size() {return iSize;};
-   inline void AddSize(unsigned long const size) {iSize += size;};
+   inline unsigned long long Size() {return iSize;};
+   inline void AddSize(unsigned long long const size) {iSize += size;};
    inline bool validData() const { return Base != (void *)-1 && Base != 0; };
    inline bool validData() const { return Base != (void *)-1 && Base != 0; };
    
    
    // File manipulators
    // File manipulators
@@ -99,10 +98,10 @@ class DynamicMMap : public MMap
    public:
    public:
 
 
    // Allocation
    // Allocation
-   unsigned long RawAllocate(unsigned long Size,unsigned long Aln = 0);
+   unsigned long RawAllocate(unsigned long long Size,unsigned long Aln = 0);
    unsigned long Allocate(unsigned long ItemSize);
    unsigned long Allocate(unsigned long ItemSize);
    unsigned long WriteString(const char *String,unsigned long Len = (unsigned long)-1);
    unsigned long WriteString(const char *String,unsigned long Len = (unsigned long)-1);
-   inline unsigned long WriteString(const string &S) {return WriteString(S.c_str(),S.length());};
+   inline unsigned long WriteString(const std::string &S) {return WriteString(S.c_str(),S.length());};
    void UsePools(Pool &P,unsigned int Count) {Pools = &P; PoolCount = Count;};
    void UsePools(Pool &P,unsigned int Count) {Pools = &P; PoolCount = Count;};
    
    
    DynamicMMap(FileFd &F,unsigned long Flags,unsigned long const &WorkSpace = 2*1024*1024,
    DynamicMMap(FileFd &F,unsigned long Flags,unsigned long const &WorkSpace = 2*1024*1024,

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

@@ -11,9 +11,12 @@
 
 
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
+#include <config.h>
 
 
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
+#include <apt-pkg/strutl.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
+
 #include <iostream>
 #include <iostream>
 #include <stdio.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdlib.h>
@@ -23,6 +26,7 @@
 
 
 #include "netrc.h"
 #include "netrc.h"
 
 
+using std::string;
 
 
 /* Get user and password from .netrc when given a machine name */
 /* Get user and password from .netrc when given a machine name */
 
 
@@ -47,10 +51,7 @@ int parsenetrc (char *host, char *login, char *password, char *netrcfile = NULL)
   int specific_login = (login[0] != 0);
   int specific_login = (login[0] != 0);
   char *home = NULL;
   char *home = NULL;
   bool netrc_alloc = false;
   bool netrc_alloc = false;
-  int state = NOTHING;
 
 
-  char state_login = 0;        /* Found a login keyword */
-  char state_password = 0;     /* Found a password keyword */
   int state_our_login = false;  /* With specific_login,
   int state_our_login = false;  /* With specific_login,
                                    found *our* login name */
                                    found *our* login name */
 
 
@@ -81,6 +82,10 @@ int parsenetrc (char *host, char *login, char *password, char *netrcfile = NULL)
     bool done = false;
     bool done = false;
     char netrcbuffer[256];
     char netrcbuffer[256];
 
 
+    int state = NOTHING;
+    char state_login = 0;        /* Found a login keyword */
+    char state_password = 0;     /* Found a password keyword */
+
     while (!done && fgets(netrcbuffer, sizeof (netrcbuffer), file)) {
     while (!done && fgets(netrcbuffer, sizeof (netrcbuffer), file)) {
       tok = strtok_r (netrcbuffer, " \t\n", &tok_buf);
       tok = strtok_r (netrcbuffer, " \t\n", &tok_buf);
       while (!done && tok) {
       while (!done && tok) {

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

@@ -14,16 +14,18 @@
 #ifndef NETRC_H
 #ifndef NETRC_H
 #define NETRC_H
 #define NETRC_H
 
 
-#include <apt-pkg/strutl.h>
+#include <string>
 
 
 #define DOT_CHAR "."
 #define DOT_CHAR "."
 #define DIR_CHAR "/"
 #define DIR_CHAR "/"
 
 
+class URI;
+
 // Assume: password[0]=0, host[0] != 0.
 // Assume: password[0]=0, host[0] != 0.
 // If login[0] = 0, search for login and password within a machine section
 // If login[0] = 0, search for login and password within a machine section
 // in the netrc.
 // in the netrc.
 // If login[0] != 0, search for password within machine and login.
 // If login[0] != 0, search for password within machine and login.
 int parsenetrc (char *host, char *login, char *password, char *filename);
 int parsenetrc (char *host, char *login, char *password, char *filename);
 
 
-void maybe_add_auth (URI &Uri, string NetRCFile);
+void maybe_add_auth (URI &Uri, std::string NetRCFile);
 #endif
 #endif

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

@@ -8,15 +8,17 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include <config.h>
+
 #include <apt-pkg/progress.h>
 #include <apt-pkg/progress.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
 
 
-#include <apti18n.h>
-
 #include <iostream>
 #include <iostream>
 #include <stdio.h>
 #include <stdio.h>
 #include <cstring>
 #include <cstring>
+
+#include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
 
 
 using namespace std;
 using namespace std;
@@ -35,7 +37,7 @@ OpProgress::OpProgress() : Current(0), Total(0), Size(0), SubTotal(1),
 /* Current is the Base Overall progress in units of Total. Cur is the sub
 /* Current is the Base Overall progress in units of Total. Cur is the sub
    progress in units of SubTotal. Size is a scaling factor that says what
    progress in units of SubTotal. Size is a scaling factor that says what
    percent of Total SubTotal is. */
    percent of Total SubTotal is. */
-void OpProgress::Progress(unsigned long Cur)
+void OpProgress::Progress(unsigned long long Cur)
 {
 {
    if (Total == 0 || Size == 0 || SubTotal == 0)
    if (Total == 0 || Size == 0 || SubTotal == 0)
       Percent = 0;
       Percent = 0;
@@ -47,8 +49,8 @@ void OpProgress::Progress(unsigned long Cur)
 // OpProgress::OverallProgress - Set the overall progress		/*{{{*/
 // OpProgress::OverallProgress - Set the overall progress		/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-void OpProgress::OverallProgress(unsigned long Current, unsigned long Total,
-	  			 unsigned long Size,const string &Op)
+void OpProgress::OverallProgress(unsigned long long Current, unsigned long long Total,
+	  			 unsigned long long Size,const string &Op)
 {
 {
    this->Current = Current;
    this->Current = Current;
    this->Total = Total;
    this->Total = Total;
@@ -65,7 +67,7 @@ void OpProgress::OverallProgress(unsigned long Current, unsigned long Total,
 // OpProgress::SubProgress - Set the sub progress state			/*{{{*/
 // OpProgress::SubProgress - Set the sub progress state			/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-void OpProgress::SubProgress(unsigned long SubTotal,const string &Op,
+void OpProgress::SubProgress(unsigned long long SubTotal,const string &Op,
 			     float const Percent)
 			     float const Percent)
 {
 {
    this->SubTotal = SubTotal;
    this->SubTotal = SubTotal;

+ 14 - 16
apt-pkg/contrib/progress.h

@@ -25,26 +25,24 @@
 #include <string>
 #include <string>
 #include <sys/time.h>
 #include <sys/time.h>
 
 
-using std::string;
-
 class Configuration;
 class Configuration;
 class OpProgress
 class OpProgress
 {
 {
-   unsigned long Current;
-   unsigned long Total;
-   unsigned long Size;
-   unsigned long SubTotal;
+   unsigned long long Current;
+   unsigned long long Total;
+   unsigned long long Size;
+   unsigned long long SubTotal;
    float LastPercent;
    float LastPercent;
    
    
    // Change reduction code
    // Change reduction code
    struct timeval LastTime;
    struct timeval LastTime;
-   string LastOp;
-   string LastSubOp;
+   std::string LastOp;
+   std::string LastSubOp;
    
    
    protected:
    protected:
    
    
-   string Op;
-   string SubOp;
+   std::string Op;
+   std::string SubOp;
    float Percent;
    float Percent;
    
    
    bool MajorChange;
    bool MajorChange;
@@ -54,10 +52,10 @@ class OpProgress
    
    
    public:
    public:
    
    
-   void Progress(unsigned long Current);
-   void SubProgress(unsigned long SubTotal, const string &Op = "", float const Percent = -1);
-   void OverallProgress(unsigned long Current,unsigned long Total,
-			unsigned long Size,const string &Op);
+   void Progress(unsigned long long Current);
+   void SubProgress(unsigned long long SubTotal, const std::string &Op = "", float const Percent = -1);
+   void OverallProgress(unsigned long long Current,unsigned long long Total,
+			unsigned long long Size,const std::string &Op);
    virtual void Done() {};
    virtual void Done() {};
    
    
    OpProgress();
    OpProgress();
@@ -67,8 +65,8 @@ class OpProgress
 class OpTextProgress : public OpProgress
 class OpTextProgress : public OpProgress
 {
 {
    protected:
    protected:
-   
-   string OldOp;
+
+   std::string OldOp;
    bool NoUpdate;
    bool NoUpdate;
    bool NoDisplay;
    bool NoDisplay;
    unsigned long LastLen;
    unsigned long LastLen;

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

@@ -29,6 +29,8 @@
  */
  */
 									/*}}} */
 									/*}}} */
 // Include Files                                                        /*{{{*/
 // Include Files                                                        /*{{{*/
+#include <config.h>
+
 #include <apt-pkg/sha1.h>
 #include <apt-pkg/sha1.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/macros.h>
 #include <apt-pkg/macros.h>
@@ -36,7 +38,6 @@
 #include <string.h>
 #include <string.h>
 #include <unistd.h>
 #include <unistd.h>
 #include <inttypes.h>
 #include <inttypes.h>
-#include <config.h>
 									/*}}}*/
 									/*}}}*/
 
 
 // SHA1Transform - Alters an existing SHA-1 hash			/*{{{*/
 // SHA1Transform - Alters an existing SHA-1 hash			/*{{{*/
@@ -241,7 +242,7 @@ SHA1SumValue SHA1Summation::Result()
 // SHA1Summation::Add - Adds content of buffer into the checksum        /*{{{*/
 // SHA1Summation::Add - Adds content of buffer into the checksum        /*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* May not be called after Result() is called */
 /* May not be called after Result() is called */
-bool SHA1Summation::Add(const unsigned char *data,unsigned long len)
+bool SHA1Summation::Add(const unsigned char *data,unsigned long long len)
 {
 {
    if (Done)
    if (Done)
       return false;
       return false;

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

@@ -18,9 +18,6 @@
 #include <cstring>
 #include <cstring>
 #include <algorithm>
 #include <algorithm>
 
 
-using std::string;
-using std::min;
-
 #include "hashsum_template.h"
 #include "hashsum_template.h"
 
 
 typedef  HashSumValue<160> SHA1SumValue;
 typedef  HashSumValue<160> SHA1SumValue;
@@ -34,7 +31,7 @@ class SHA1Summation : public SummationImplementation
    bool Done;
    bool Done;
    
    
    public:
    public:
-   bool Add(const unsigned char *inbuf, unsigned long inlen);
+   bool Add(const unsigned char *inbuf, unsigned long long inlen);
    using SummationImplementation::Add;
    using SummationImplementation::Add;
 
 
    SHA1SumValue Result();
    SHA1SumValue Result();

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

@@ -30,7 +30,7 @@ class SHA2SummationBase : public SummationImplementation
  protected:
  protected:
    bool Done;
    bool Done;
  public:
  public:
-   bool Add(const unsigned char *inbuf, unsigned long len) = 0;
+   bool Add(const unsigned char *inbuf, unsigned long long len) = 0;
 
 
    void Result();
    void Result();
 };
 };
@@ -41,7 +41,7 @@ class SHA256Summation : public SHA2SummationBase
    unsigned char Sum[32];
    unsigned char Sum[32];
 
 
    public:
    public:
-   bool Add(const unsigned char *inbuf, unsigned long len)
+   bool Add(const unsigned char *inbuf, unsigned long long len)
    {
    {
       if (Done) 
       if (Done) 
          return false;
          return false;
@@ -73,7 +73,7 @@ class SHA512Summation : public SHA2SummationBase
    unsigned char Sum[64];
    unsigned char Sum[64];
 
 
    public:
    public:
-   bool Add(const unsigned char *inbuf, unsigned long len)
+   bool Add(const unsigned char *inbuf, unsigned long long len)
    {
    {
       if (Done) 
       if (Done) 
          return false;
          return false;

+ 14 - 3
apt-pkg/contrib/sha2_internal.cc

@@ -31,6 +31,7 @@
  *
  *
  * $Id: sha2.c,v 1.1 2001/11/08 00:01:51 adg Exp adg $
  * $Id: sha2.c,v 1.1 2001/11/08 00:01:51 adg Exp adg $
  */
  */
+#include <config.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() */
@@ -604,7 +605,12 @@ void SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
 			*context->buffer = 0x80;
 			*context->buffer = 0x80;
 		}
 		}
 		/* Set the bit count: */
 		/* Set the bit count: */
-		*(sha2_word64*)&context->buffer[SHA256_SHORT_BLOCK_LENGTH] = context->bitcount;
+		union {
+			sha2_byte* c;
+			sha2_word64* l;
+		} bitcount;
+		bitcount.c = &context->buffer[SHA256_SHORT_BLOCK_LENGTH];
+		*(bitcount.l) = context->bitcount;
 
 
 		/* Final transform: */
 		/* Final transform: */
 		SHA256_Transform(context, (sha2_word32*)context->buffer);
 		SHA256_Transform(context, (sha2_word32*)context->buffer);
@@ -921,8 +927,13 @@ static void SHA512_Last(SHA512_CTX* context) {
 		*context->buffer = 0x80;
 		*context->buffer = 0x80;
 	}
 	}
 	/* Store the length of input data (in bits): */
 	/* Store the length of input data (in bits): */
-	*(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH] = context->bitcount[1];
-	*(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH+8] = context->bitcount[0];
+	union {
+		sha2_byte* c;
+		sha2_word64* l;
+	} bitcount;
+	bitcount.c = &context->buffer[SHA512_SHORT_BLOCK_LENGTH];
+	bitcount.l[0] = context->bitcount[1];
+	bitcount.l[1] = context->bitcount[0];
 
 
 	/* Final transform: */
 	/* Final transform: */
 	SHA512_Transform(context, (sha2_word64*)context->buffer);
 	SHA512_Transform(context, (sha2_word64*)context->buffer);

+ 53 - 26
apt-pkg/contrib/strutl.cc

@@ -15,12 +15,12 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Includes								/*{{{*/
 // Includes								/*{{{*/
+#include <config.h>
+
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 
 
-#include <apti18n.h>
-    
 #include <ctype.h>
 #include <ctype.h>
 #include <string.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdio.h>
@@ -31,7 +31,7 @@
 #include <stdarg.h>
 #include <stdarg.h>
 #include <iconv.h>
 #include <iconv.h>
 
 
-#include "config.h"
+#include <apti18n.h>
 
 
 using namespace std;
 using namespace std;
 									/*}}}*/
 									/*}}}*/
@@ -179,14 +179,14 @@ bool ParseQuoteWord(const char *&String,string &Res)
    {
    {
       if (*C == '"')
       if (*C == '"')
       {
       {
-	 for (C++; *C != 0 && *C != '"'; C++);
-	 if (*C == 0)
+	 C = strchr(C + 1, '"');
+	 if (C == NULL)
 	    return false;
 	    return false;
       }
       }
       if (*C == '[')
       if (*C == '[')
       {
       {
-	 for (C++; *C != 0 && *C != ']'; C++);
-	 if (*C == 0)
+	 C = strchr(C + 1, ']');
+	 if (C == NULL)
 	    return false;
 	    return false;
       }
       }
    }
    }
@@ -271,7 +271,7 @@ bool ParseCWord(const char *&String,string &Res)
 string QuoteString(const string &Str, const char *Bad)
 string QuoteString(const string &Str, const char *Bad)
 {
 {
    string Res;
    string Res;
-   for (string::const_iterator I = Str.begin(); I != Str.end(); I++)
+   for (string::const_iterator I = Str.begin(); I != Str.end(); ++I)
    {
    {
       if (strchr(Bad,*I) != 0 || isprint(*I) == 0 || 
       if (strchr(Bad,*I) != 0 || isprint(*I) == 0 || 
 	  *I == 0x25 || // percent '%' char
 	  *I == 0x25 || // percent '%' char
@@ -298,7 +298,7 @@ string DeQuoteString(string::const_iterator const &begin,
 			string::const_iterator const &end)
 			string::const_iterator const &end)
 {
 {
    string Res;
    string Res;
-   for (string::const_iterator I = begin; I != end; I++)
+   for (string::const_iterator I = begin; I != end; ++I)
    {
    {
       if (*I == '%' && I + 2 < end &&
       if (*I == '%' && I + 2 < end &&
 	  isxdigit(I[1]) && isxdigit(I[2]))
 	  isxdigit(I[1]) && isxdigit(I[2]))
@@ -632,7 +632,7 @@ string LookupTag(const string &Message,const char *Tag,const char *Default)
 {
 {
    // Look for a matching tag.
    // Look for a matching tag.
    int Length = strlen(Tag);
    int Length = strlen(Tag);
-   for (string::const_iterator I = Message.begin(); I + Length < Message.end(); I++)
+   for (string::const_iterator I = Message.begin(); I + Length < Message.end(); ++I)
    {
    {
       // Found the tag
       // Found the tag
       if (I[Length] == ':' && stringcasecmp(I,I+Length,Tag) == 0)
       if (I[Length] == ':' && stringcasecmp(I,I+Length,Tag) == 0)
@@ -640,14 +640,14 @@ string LookupTag(const string &Message,const char *Tag,const char *Default)
 	 // Find the end of line and strip the leading/trailing spaces
 	 // Find the end of line and strip the leading/trailing spaces
 	 string::const_iterator J;
 	 string::const_iterator J;
 	 I += Length + 1;
 	 I += Length + 1;
-	 for (; isspace(*I) != 0 && I < Message.end(); I++);
-	 for (J = I; *J != '\n' && J < Message.end(); J++);
-	 for (; J > I && isspace(J[-1]) != 0; J--);
+	 for (; isspace(*I) != 0 && I < Message.end(); ++I);
+	 for (J = I; *J != '\n' && J < Message.end(); ++J);
+	 for (; J > I && isspace(J[-1]) != 0; --J);
 	 
 	 
 	 return string(I,J);
 	 return string(I,J);
       }
       }
       
       
-      for (; *I != '\n' && I < Message.end(); I++);
+      for (; *I != '\n' && I < Message.end(); ++I);
    }   
    }   
    
    
    // Failed to find a match
    // Failed to find a match
@@ -904,11 +904,10 @@ bool StrToTime(const string &Val,time_t &Result)
 {
 {
    struct tm Tm;
    struct tm Tm;
    char Month[10];
    char Month[10];
-   const char *I = Val.c_str();
-   
+
    // Skip the day of the week
    // Skip the day of the week
-   for (;*I != 0  && *I != ' '; I++);
-   
+   const char *I = strchr(Val.c_str(), ' ');
+
    // Handle RFC 1123 time
    // Handle RFC 1123 time
    Month[0] = 0;
    Month[0] = 0;
    if (sscanf(I," %d %3s %d %d:%d:%d GMT",&Tm.tm_mday,Month,&Tm.tm_year,
    if (sscanf(I," %d %3s %d %d:%d:%d GMT",&Tm.tm_mday,Month,&Tm.tm_year,
@@ -970,6 +969,34 @@ bool StrToNum(const char *Str,unsigned long &Res,unsigned Len,unsigned Base)
    return true;
    return true;
 }
 }
 									/*}}}*/
 									/*}}}*/
+// StrToNum - Convert a fixed length string to a number			/*{{{*/
+// ---------------------------------------------------------------------
+/* This is used in decoding the crazy fixed length string headers in 
+   tar and ar files. */
+bool StrToNum(const char *Str,unsigned long long &Res,unsigned Len,unsigned Base)
+{
+   char S[30];
+   if (Len >= sizeof(S))
+      return false;
+   memcpy(S,Str,Len);
+   S[Len] = 0;
+   
+   // All spaces is a zero
+   Res = 0;
+   unsigned I;
+   for (I = 0; S[I] == ' '; I++);
+   if (S[I] == 0)
+      return true;
+   
+   char *End;
+   Res = strtoull(S,&End,Base);
+   if (End == S)
+      return false;
+   
+   return true;
+}
+									/*}}}*/
+
 // Base256ToNum - Convert a fixed length binary to a number             /*{{{*/
 // Base256ToNum - Convert a fixed length binary to a number             /*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* This is used in decoding the 256bit encoded fixed length fields in
 /* This is used in decoding the 256bit encoded fixed length fields in
@@ -1224,7 +1251,7 @@ int tolower_ascii(int const c)
 bool CheckDomainList(const string &Host,const string &List)
 bool CheckDomainList(const string &Host,const string &List)
 {
 {
    string::const_iterator Start = List.begin();
    string::const_iterator Start = List.begin();
-   for (string::const_iterator Cur = List.begin(); Cur <= List.end(); Cur++)
+   for (string::const_iterator Cur = List.begin(); Cur <= List.end(); ++Cur)
    {
    {
       if (Cur < List.end() && *Cur != ',')
       if (Cur < List.end() && *Cur != ',')
 	 continue;
 	 continue;
@@ -1248,7 +1275,7 @@ string DeEscapeString(const string &input)
    char tmp[3];
    char tmp[3];
    string::const_iterator it, escape_start;
    string::const_iterator it, escape_start;
    string output, octal, hex;
    string output, octal, hex;
-   for (it = input.begin(); it != input.end(); it++) 
+   for (it = input.begin(); it != input.end(); ++it)
    {
    {
       // just copy non-escape chars
       // just copy non-escape chars
       if (*it != '\\')
       if (*it != '\\')
@@ -1264,7 +1291,7 @@ string DeEscapeString(const string &input)
          // copy
          // copy
          output += *it;
          output += *it;
          // advance iterator one step further
          // advance iterator one step further
-         it += 1;
+         ++it;
          continue;
          continue;
       }
       }
         
         
@@ -1273,7 +1300,7 @@ string DeEscapeString(const string &input)
          continue;
          continue;
 
 
       // read it
       // read it
-      it++;
+      ++it;
       switch (*it)
       switch (*it)
       {
       {
          case '0':
          case '0':
@@ -1310,7 +1337,7 @@ void URI::CopyFrom(const string &U)
    string::const_iterator I = U.begin();
    string::const_iterator I = U.begin();
 
 
    // Locate the first colon, this separates the scheme
    // Locate the first colon, this separates the scheme
-   for (; I < U.end() && *I != ':' ; I++);
+   for (; I < U.end() && *I != ':' ; ++I);
    string::const_iterator FirstColon = I;
    string::const_iterator FirstColon = I;
 
 
    /* Determine if this is a host type URI with a leading double //
    /* Determine if this is a host type URI with a leading double //
@@ -1322,7 +1349,7 @@ void URI::CopyFrom(const string &U)
    /* Find the / indicating the end of the hostname, ignoring /'s in the
    /* Find the / indicating the end of the hostname, ignoring /'s in the
       square brackets */
       square brackets */
    bool InBracket = false;
    bool InBracket = false;
-   for (; SingleSlash < U.end() && (*SingleSlash != '/' || InBracket == true); SingleSlash++)
+   for (; SingleSlash < U.end() && (*SingleSlash != '/' || InBracket == true); ++SingleSlash)
    {
    {
       if (*SingleSlash == '[')
       if (*SingleSlash == '[')
 	 InBracket = true;
 	 InBracket = true;
@@ -1355,11 +1382,11 @@ void URI::CopyFrom(const string &U)
    I = FirstColon + 1;
    I = FirstColon + 1;
    if (I > SingleSlash)
    if (I > SingleSlash)
       I = SingleSlash;
       I = SingleSlash;
-   for (; I < SingleSlash && *I != ':'; I++);
+   for (; I < SingleSlash && *I != ':'; ++I);
    string::const_iterator SecondColon = I;
    string::const_iterator SecondColon = I;
    
    
    // Search for the @ after the colon
    // Search for the @ after the colon
-   for (; I < SingleSlash && *I != '@'; I++);
+   for (; I < SingleSlash && *I != '@'; ++I);
    string::const_iterator At = I;
    string::const_iterator At = I;
    
    
    // Now write the host and user/pass
    // Now write the host and user/pass

+ 53 - 56
apt-pkg/contrib/strutl.h

@@ -27,59 +27,56 @@
 
 
 #include "macros.h"
 #include "macros.h"
 
 
-using std::string;
-using std::vector;
-using std::ostream;
-
-bool UTF8ToCodeset(const char *codeset, const string &orig, string *dest);
+bool UTF8ToCodeset(const char *codeset, const std::string &orig, std::string *dest);
 char *_strstrip(char *String);
 char *_strstrip(char *String);
 char *_strtabexpand(char *String,size_t Len);
 char *_strtabexpand(char *String,size_t Len);
-bool ParseQuoteWord(const char *&String,string &Res);
-bool ParseCWord(const char *&String,string &Res);
-string QuoteString(const string &Str,const char *Bad);
-string DeQuoteString(const string &Str);
-string DeQuoteString(string::const_iterator const &begin, string::const_iterator const &end);
+bool ParseQuoteWord(const char *&String,std::string &Res);
+bool ParseCWord(const char *&String,std::string &Res);
+std::string QuoteString(const std::string &Str,const char *Bad);
+std::string DeQuoteString(const std::string &Str);
+std::string DeQuoteString(std::string::const_iterator const &begin, std::string::const_iterator const &end);
 
 
 // unescape (\0XX and \xXX) from a string
 // unescape (\0XX and \xXX) from a string
-string DeEscapeString(const string &input);
-
-string SizeToStr(double Bytes);
-string TimeToStr(unsigned long Sec);
-string Base64Encode(const string &Str);
-string OutputInDepth(const unsigned long Depth, const char* Separator="  ");
-string URItoFileName(const string &URI);
-string TimeRFC1123(time_t Date);
+std::string DeEscapeString(const std::string &input);
+
+std::string SizeToStr(double Bytes);
+std::string TimeToStr(unsigned long Sec);
+std::string Base64Encode(const std::string &Str);
+std::string OutputInDepth(const unsigned long Depth, const char* Separator="  ");
+std::string URItoFileName(const std::string &URI);
+std::string TimeRFC1123(time_t Date);
 bool RFC1123StrToTime(const char* const str,time_t &time) __must_check;
 bool RFC1123StrToTime(const char* const str,time_t &time) __must_check;
 bool FTPMDTMStrToTime(const char* const str,time_t &time) __must_check;
 bool FTPMDTMStrToTime(const char* const str,time_t &time) __must_check;
-__deprecated bool StrToTime(const string &Val,time_t &Result);
-string LookupTag(const string &Message,const char *Tag,const char *Default = 0);
-int StringToBool(const string &Text,int Default = -1);
-bool ReadMessages(int Fd, vector<string> &List);
+__deprecated bool StrToTime(const std::string &Val,time_t &Result);
+std::string LookupTag(const std::string &Message,const char *Tag,const char *Default = 0);
+int StringToBool(const std::string &Text,int Default = -1);
+bool ReadMessages(int Fd, std::vector<std::string> &List);
 bool StrToNum(const char *Str,unsigned long &Res,unsigned Len,unsigned Base = 0);
 bool StrToNum(const char *Str,unsigned long &Res,unsigned Len,unsigned Base = 0);
+bool StrToNum(const char *Str,unsigned long long &Res,unsigned Len,unsigned Base = 0);
 bool Base256ToNum(const char *Str,unsigned long &Res,unsigned int Len);
 bool Base256ToNum(const char *Str,unsigned long &Res,unsigned int Len);
-bool Hex2Num(const string &Str,unsigned char *Num,unsigned int Length);
+bool Hex2Num(const std::string &Str,unsigned char *Num,unsigned int Length);
 bool TokSplitString(char Tok,char *Input,char **List,
 bool TokSplitString(char Tok,char *Input,char **List,
 		    unsigned long ListMax);
 		    unsigned long ListMax);
-vector<string> VectorizeString(string const &haystack, char const &split) __attrib_const;
-void ioprintf(ostream &out,const char *format,...) __like_printf(2);
-void strprintf(string &out,const char *format,...) __like_printf(2);
+std::vector<std::string> VectorizeString(std::string const &haystack, char const &split) __attrib_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);
 char *safe_snprintf(char *Buffer,char *End,const char *Format,...) __like_printf(3);
-bool CheckDomainList(const string &Host, const 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) __attrib_const __hot;
-string StripEpoch(const 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 *B) {return func(A,A+strlen(A),B,B+strlen(B));}; \
 inline int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));}; \
 inline int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));}; \
-inline int name(const string& A,const char *B) {return func(A.c_str(),A.c_str()+A.length(),B,B+strlen(B));}; \
-inline int name(const string& A,const string& B) {return func(A.c_str(),A.c_str()+A.length(),B.c_str(),B.c_str()+B.length());}; \
-inline int name(const string& A,const char *B,const char *BEnd) {return func(A.c_str(),A.c_str()+A.length(),B,BEnd);};
+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);};
 
 
 #define APT_MKSTRCMP2(name,func) \
 #define APT_MKSTRCMP2(name,func) \
 inline int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));}; \
 inline int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));}; \
-inline int name(const string& A,const char *B) {return func(A.begin(),A.end(),B,B+strlen(B));}; \
-inline int name(const string& A,const string& B) {return func(A.begin(),A.end(),B.begin(),B.end());}; \
-inline int name(const string& A,const char *B,const char *BEnd) {return func(A.begin(),A.end(),B,BEnd);};
+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);};
 
 
 int stringcmp(const char *A,const char *AEnd,const char *B,const char *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 stringcasecmp(const char *A,const char *AEnd,const char *B,const char *BEnd);
@@ -88,17 +85,17 @@ int stringcasecmp(const char *A,const char *AEnd,const char *B,const char *BEnd)
    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(string::const_iterator A,string::const_iterator AEnd,
+int 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(string::const_iterator A,string::const_iterator AEnd,
-	      string::const_iterator B,string::const_iterator BEnd);
-int stringcasecmp(string::const_iterator A,string::const_iterator AEnd,
+int stringcmp(std::string::const_iterator A,std::string::const_iterator AEnd,
+	      std::string::const_iterator B,std::string::const_iterator BEnd);
+int 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(string::const_iterator A,string::const_iterator AEnd,
-                  string::const_iterator B,string::const_iterator BEnd);
+int stringcasecmp(std::string::const_iterator A,std::string::const_iterator AEnd,
+                  std::string::const_iterator B,std::string::const_iterator BEnd);
 
 
-inline int stringcmp(string::const_iterator A,string::const_iterator Aend,const char *B) {return stringcmp(A,Aend,B,B+strlen(B));};
-inline int stringcasecmp(string::const_iterator A,string::const_iterator Aend,const char *B) {return stringcasecmp(A,Aend,B,B+strlen(B));};
+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));};
 #endif
 #endif
 
 
 APT_MKSTRCMP2(stringcmp,stringcmp);
 APT_MKSTRCMP2(stringcmp,stringcmp);
@@ -108,34 +105,34 @@ inline const char *DeNull(const char *s) {return (s == 0?"(null)":s);};
 
 
 class URI
 class URI
 {
 {
-   void CopyFrom(const string &From);
+   void CopyFrom(const std::string &From);
 		 
 		 
    public:
    public:
    
    
-   string Access;
-   string User;
-   string Password;
-   string Host;
-   string Path;
+   std::string Access;
+   std::string User;
+   std::string Password;
+   std::string Host;
+   std::string Path;
    unsigned int Port;
    unsigned int Port;
    
    
-   operator string();
-   inline void operator =(const string &From) {CopyFrom(From);};
+   operator std::string();
+   inline void operator =(const std::string &From) {CopyFrom(From);};
    inline bool empty() {return Access.empty();};
    inline bool empty() {return Access.empty();};
-   static string SiteOnly(const string &URI);
-   static string NoUserPassword(const string &URI);
+   static std::string SiteOnly(const std::string &URI);
+   static std::string NoUserPassword(const std::string &URI);
    
    
-   URI(string Path) {CopyFrom(Path);};
+   URI(std::string Path) {CopyFrom(Path);};
    URI() : Port(0) {};
    URI() : Port(0) {};
 };
 };
 
 
 struct SubstVar
 struct SubstVar
 {
 {
    const char *Subst;
    const char *Subst;
-   const string *Contents;
+   const std::string *Contents;
 };
 };
-string SubstVar(string Str,const struct SubstVar *Vars);
-string SubstVar(const string &Str,const string &Subst,const string &Contents);
+std::string SubstVar(std::string Str,const struct SubstVar *Vars);
+std::string SubstVar(const std::string &Str,const std::string &Subst,const std::string &Contents);
 
 
 struct RxChoiceList
 struct RxChoiceList
 {
 {

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

@@ -9,6 +9,8 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include <config.h>
+
 #include <apt-pkg/debindexfile.h>
 #include <apt-pkg/debindexfile.h>
 #include <apt-pkg/debsrcrecords.h>
 #include <apt-pkg/debsrcrecords.h>
 #include <apt-pkg/deblistparser.h>
 #include <apt-pkg/deblistparser.h>
@@ -352,7 +354,7 @@ pkgCache::PkgFileIterator debPackagesIndex::FindInCache(pkgCache &Cache) const
 {
 {
    string FileName = IndexFile("Packages");
    string FileName = IndexFile("Packages");
    pkgCache::PkgFileIterator File = Cache.FileBegin();
    pkgCache::PkgFileIterator File = Cache.FileBegin();
-   for (; File.end() == false; File++)
+   for (; File.end() == false; ++File)
    {
    {
        if (File.FileName() == NULL || FileName != File.FileName())
        if (File.FileName() == NULL || FileName != File.FileName())
 	 continue;
 	 continue;
@@ -540,7 +542,7 @@ pkgCache::PkgFileIterator debTranslationsIndex::FindInCache(pkgCache &Cache) con
    string FileName = IndexFile(Language);
    string FileName = IndexFile(Language);
    
    
    pkgCache::PkgFileIterator File = Cache.FileBegin();
    pkgCache::PkgFileIterator File = Cache.FileBegin();
-   for (; File.end() == false; File++)
+   for (; File.end() == false; ++File)
    {
    {
       if (FileName != File.FileName())
       if (FileName != File.FileName())
 	 continue;
 	 continue;
@@ -620,7 +622,7 @@ bool debStatusIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
 pkgCache::PkgFileIterator debStatusIndex::FindInCache(pkgCache &Cache) const
 pkgCache::PkgFileIterator debStatusIndex::FindInCache(pkgCache &Cache) const
 {
 {
    pkgCache::PkgFileIterator File = Cache.FileBegin();
    pkgCache::PkgFileIterator File = Cache.FileBegin();
-   for (; File.end() == false; File++)
+   for (; File.end() == false; ++File)
    {
    {
       if (this->File != File.FileName())
       if (this->File != File.FileName())
 	 continue;
 	 continue;

+ 34 - 34
apt-pkg/deb/debindexfile.h

@@ -26,14 +26,14 @@ class debStatusIndex : public pkgIndexFile
    void *d;
    void *d;
 
 
    protected:
    protected:
-   string File;
+   std::string File;
 
 
    public:
    public:
 
 
    virtual const Type *GetType() const;
    virtual const Type *GetType() const;
    
    
    // Interface for acquire
    // Interface for acquire
-   virtual 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;
@@ -43,7 +43,7 @@ class debStatusIndex : public pkgIndexFile
    bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog, unsigned long const Flag) const;
    bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog, unsigned long const Flag) const;
    virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
    virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
 
 
-   debStatusIndex(string File);
+   debStatusIndex(std::string File);
    virtual ~debStatusIndex() {};
    virtual ~debStatusIndex() {};
 };
 };
     
     
@@ -52,25 +52,25 @@ class debPackagesIndex : public pkgIndexFile
    /** \brief dpointer placeholder (for later in case we need it) */
    /** \brief dpointer placeholder (for later in case we need it) */
    void *d;
    void *d;
 
 
-   string URI;
-   string Dist;
-   string Section;
-   string Architecture;
+   std::string URI;
+   std::string Dist;
+   std::string Section;
+   std::string Architecture;
 
 
-   string Info(const char *Type) const;
-   string IndexFile(const char *Type) const;
-   string IndexURI(const char *Type) const;
+   std::string Info(const char *Type) const;
+   std::string IndexFile(const char *Type) const;
+   std::string IndexURI(const char *Type) const;
    
    
    public:
    public:
    
    
    virtual const Type *GetType() const;
    virtual const Type *GetType() const;
 
 
    // Stuff for accessing files on remote items
    // Stuff for accessing files on remote items
-   virtual string ArchiveInfo(pkgCache::VerIterator Ver) const;
-   virtual string ArchiveURI(string File) const {return URI + File;};
+   virtual std::string ArchiveInfo(pkgCache::VerIterator Ver) const;
+   virtual std::string ArchiveURI(std::string File) const {return URI + File;};
    
    
    // Interface for acquire
    // Interface for acquire
-   virtual string Describe(bool Short) const;   
+   virtual std::string Describe(bool Short) const;   
    
    
    // Interface for the Cache Generator
    // Interface for the Cache Generator
    virtual bool Exists() const;
    virtual bool Exists() const;
@@ -79,8 +79,8 @@ class debPackagesIndex : public pkgIndexFile
    virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
    virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
    virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
    virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
 
 
-   debPackagesIndex(string const &URI, string const &Dist, string const &Section,
-			bool const &Trusted, string const &Arch = "native");
+   debPackagesIndex(std::string const &URI, std::string const &Dist, std::string const &Section,
+			bool const &Trusted, std::string const &Arch = "native");
    virtual ~debPackagesIndex() {};
    virtual ~debPackagesIndex() {};
 };
 };
 
 
@@ -89,23 +89,23 @@ class debTranslationsIndex : public pkgIndexFile
    /** \brief dpointer placeholder (for later in case we need it) */
    /** \brief dpointer placeholder (for later in case we need it) */
    void *d;
    void *d;
 
 
-   string URI;
-   string Dist;
-   string Section;
+   std::string URI;
+   std::string Dist;
+   std::string Section;
    const char * const Language;
    const char * const Language;
    
    
-   string Info(const char *Type) const;
-   string IndexFile(const char *Type) const;
-   string IndexURI(const char *Type) const;
+   std::string Info(const char *Type) const;
+   std::string IndexFile(const char *Type) const;
+   std::string IndexURI(const char *Type) const;
 
 
-   inline string TranslationFile() const {return string("Translation-").append(Language);};
+   inline std::string TranslationFile() const {return std::string("Translation-").append(Language);};
 
 
    public:
    public:
    
    
    virtual const Type *GetType() const;
    virtual const Type *GetType() const;
 
 
    // Interface for acquire
    // Interface for acquire
-   virtual string Describe(bool Short) const;   
+   virtual std::string Describe(bool Short) const;   
    virtual bool GetIndexes(pkgAcquire *Owner) const;
    virtual bool GetIndexes(pkgAcquire *Owner) const;
    
    
    // Interface for the Cache Generator
    // Interface for the Cache Generator
@@ -115,7 +115,7 @@ class debTranslationsIndex : public pkgIndexFile
    virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
    virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
    virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
    virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
 
 
-   debTranslationsIndex(string URI,string Dist,string Section, char const * const Language);
+   debTranslationsIndex(std::string URI,std::string Dist,std::string Section, char const * const Language);
    virtual ~debTranslationsIndex() {};
    virtual ~debTranslationsIndex() {};
 };
 };
 
 
@@ -124,25 +124,25 @@ class debSourcesIndex : public pkgIndexFile
    /** \brief dpointer placeholder (for later in case we need it) */
    /** \brief dpointer placeholder (for later in case we need it) */
    void *d;
    void *d;
 
 
-   string URI;
-   string Dist;
-   string Section;
+   std::string URI;
+   std::string Dist;
+   std::string Section;
 
 
-   string Info(const char *Type) const;
-   string IndexFile(const char *Type) const;
-   string IndexURI(const char *Type) const;
+   std::string Info(const char *Type) const;
+   std::string IndexFile(const char *Type) const;
+   std::string IndexURI(const char *Type) const;
    
    
    public:
    public:
 
 
    virtual const Type *GetType() const;
    virtual const Type *GetType() const;
 
 
    // Stuff for accessing files on remote items
    // Stuff for accessing files on remote items
-   virtual string SourceInfo(pkgSrcRecords::Parser const &Record,
+   virtual std::string SourceInfo(pkgSrcRecords::Parser const &Record,
 			     pkgSrcRecords::File const &File) const;
 			     pkgSrcRecords::File const &File) const;
-   virtual string ArchiveURI(string File) const {return URI + File;};
+   virtual std::string ArchiveURI(std::string File) const {return URI + File;};
    
    
    // Interface for acquire
    // Interface for acquire
-   virtual string Describe(bool Short) const;   
+   virtual std::string Describe(bool Short) const;   
 
 
    // Interface for the record parsers
    // Interface for the record parsers
    virtual pkgSrcRecords::Parser *CreateSrcParser() const;
    virtual pkgSrcRecords::Parser *CreateSrcParser() const;
@@ -152,7 +152,7 @@ class debSourcesIndex : public pkgIndexFile
    virtual bool HasPackages() const {return false;};
    virtual bool HasPackages() const {return false;};
    virtual unsigned long Size() const;
    virtual unsigned long Size() const;
    
    
-   debSourcesIndex(string URI,string Dist,string Section,bool Trusted);
+   debSourcesIndex(std::string URI,std::string Dist,std::string Section,bool Trusted);
    virtual ~debSourcesIndex() {};
    virtual ~debSourcesIndex() {};
 };
 };
 
 

+ 18 - 18
apt-pkg/deb/deblistparser.cc

@@ -10,11 +10,14 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include <config.h>
+
 #include <apt-pkg/deblistparser.h>
 #include <apt-pkg/deblistparser.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/aptconfiguration.h>
 #include <apt-pkg/aptconfiguration.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.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/macros.h>
 #include <apt-pkg/macros.h>
@@ -23,6 +26,8 @@
 #include <ctype.h>
 #include <ctype.h>
 									/*}}}*/
 									/*}}}*/
 
 
+using std::string;
+
 static debListParser::WordList PrioList[] = {{"important",pkgCache::State::Important},
 static debListParser::WordList PrioList[] = {{"important",pkgCache::State::Important},
                        {"required",pkgCache::State::Required},
                        {"required",pkgCache::State::Required},
                        {"standard",pkgCache::State::Standard},
                        {"standard",pkgCache::State::Standard},
@@ -69,10 +74,7 @@ string debListParser::Package() {
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* This will return the Architecture of the package this section describes */
 /* This will return the Architecture of the package this section describes */
 string debListParser::Architecture() {
 string debListParser::Architecture() {
-   std::string const Arch = Section.FindS("Architecture");
-   if (Arch.empty() == true)
-      return _config->Find("APT::Architecture");
-   return Arch;
+   return Section.FindS("Architecture");
 }
 }
 									/*}}}*/
 									/*}}}*/
 // ListParser::ArchitectureAll						/*{{{*/
 // ListParser::ArchitectureAll						/*{{{*/
@@ -198,7 +200,7 @@ string debListParser::DescriptionLanguage()
 
 
    std::vector<string> const lang = APT::Configuration::getLanguages(true);
    std::vector<string> const lang = APT::Configuration::getLanguages(true);
    for (std::vector<string>::const_iterator l = lang.begin();
    for (std::vector<string>::const_iterator l = lang.begin();
-	l != lang.end(); l++)
+	l != lang.end(); ++l)
       if (Section.FindS(string("Description-").append(*l).c_str()).empty() == false)
       if (Section.FindS(string("Description-").append(*l).c_str()).empty() == false)
 	 return *l;
 	 return *l;
 
 
@@ -520,9 +522,9 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
       // Skip whitespace
       // Skip whitespace
       for (;I != Stop && isspace(*I) != 0; I++);
       for (;I != Stop && isspace(*I) != 0; I++);
       Start = I;
       Start = I;
-      for (;I != Stop && *I != ')'; I++);
-      if (I == Stop || Start == I)
-	 return 0;     
+      I = (const char*) memchr(I, ')', Stop - I);
+      if (I == NULL || Start == I)
+	 return 0;
       
       
       // Skip trailing whitespace
       // Skip trailing whitespace
       const char *End = I;
       const char *End = I;
@@ -673,6 +675,9 @@ bool debListParser::ParseProvides(pkgCache::VerIterator &Ver)
 	    return _error->Error("Problem parsing Provides line");
 	    return _error->Error("Problem parsing Provides line");
 	 if (Op != pkgCache::Dep::NoOp) {
 	 if (Op != pkgCache::Dep::NoOp) {
 	    _error->Warning("Ignoring Provides line with DepCompareOp for package %s", Package.c_str());
 	    _error->Warning("Ignoring Provides line with DepCompareOp for package %s", Package.c_str());
+	 } else if ((Ver->MultiArch & pkgCache::Version::Foreign) == pkgCache::Version::Foreign) {
+	    if (NewProvidesAllArch(Ver, Package, Version) == false)
+	       return false;
 	 } else {
 	 } else {
 	    if (NewProvides(Ver, Package, Arch, Version) == false)
 	    if (NewProvides(Ver, Package, Arch, Version) == false)
 	       return false;
 	       return false;
@@ -795,21 +800,16 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
       }
       }
 
 
       // seperate the tag from the data
       // seperate the tag from the data
-      for (; buffer[len] != ':' && buffer[len] != '\0'; ++len)
-         /* nothing */
-         ;
-      if (buffer[len] == '\0')
+      const char* dataStart = strchr(buffer + len, ':');
+      if (dataStart == NULL)
 	 continue;
 	 continue;
-      char* dataStart = buffer + len;
+      len = dataStart - buffer;
       for (++dataStart; *dataStart == ' '; ++dataStart)
       for (++dataStart; *dataStart == ' '; ++dataStart)
          /* nothing */
          /* nothing */
          ;
          ;
-      char* dataEnd = dataStart;
-      for (++dataEnd; *dataEnd != '\0'; ++dataEnd)
-         /* nothing */
-         ;
+      const char* dataEnd = (const char*)rawmemchr(dataStart, '\0');
       // The last char should be a newline, but we can never be sure: #633350
       // The last char should be a newline, but we can never be sure: #633350
-      char* lineEnd = dataEnd;
+      const char* lineEnd = dataEnd;
       for (--lineEnd; *lineEnd == '\r' || *lineEnd == '\n'; --lineEnd)
       for (--lineEnd; *lineEnd == '\r' || *lineEnd == '\n'; --lineEnd)
          /* nothing */
          /* nothing */
          ;
          ;

+ 12 - 13
apt-pkg/deb/deblistparser.h

@@ -12,7 +12,6 @@
 #define PKGLIB_DEBLISTPARSER_H
 #define PKGLIB_DEBLISTPARSER_H
 
 
 #include <apt-pkg/pkgcachegen.h>
 #include <apt-pkg/pkgcachegen.h>
-#include <apt-pkg/indexfile.h>
 #include <apt-pkg/tagfile.h>
 #include <apt-pkg/tagfile.h>
 
 
 class debListParser : public pkgCacheGenerator::ListParser
 class debListParser : public pkgCacheGenerator::ListParser
@@ -34,7 +33,7 @@ class debListParser : public pkgCacheGenerator::ListParser
    pkgTagFile Tags;
    pkgTagFile Tags;
    pkgTagSection Section;
    pkgTagSection Section;
    unsigned long iOffset;
    unsigned long iOffset;
-   string Arch;
+   std::string Arch;
    std::vector<std::string> Architectures;
    std::vector<std::string> Architectures;
    bool MultiArchEnabled;
    bool MultiArchEnabled;
 
 
@@ -43,21 +42,21 @@ class debListParser : public pkgCacheGenerator::ListParser
    bool ParseDepends(pkgCache::VerIterator &Ver,const char *Tag,
    bool ParseDepends(pkgCache::VerIterator &Ver,const char *Tag,
 		     unsigned int Type);
 		     unsigned int Type);
    bool ParseProvides(pkgCache::VerIterator &Ver);
    bool ParseProvides(pkgCache::VerIterator &Ver);
-   bool NewProvidesAllArch(pkgCache::VerIterator &Ver, string const &Package, string const &Version);
-   static bool GrabWord(string Word,WordList *List,unsigned char &Out);
+   bool NewProvidesAllArch(pkgCache::VerIterator &Ver, std::string const &Package, std::string const &Version);
+   static bool GrabWord(std::string Word,WordList *List,unsigned char &Out);
    
    
    public:
    public:
 
 
-   static unsigned char GetPrio(string Str);
+   static unsigned char GetPrio(std::string Str);
       
       
    // These all operate against the current section
    // These all operate against the current section
-   virtual string Package();
-   virtual string Architecture();
+   virtual std::string Package();
+   virtual std::string Architecture();
    virtual bool ArchitectureAll();
    virtual bool ArchitectureAll();
-   virtual string Version();
+   virtual std::string Version();
    virtual bool NewVersion(pkgCache::VerIterator &Ver);
    virtual bool NewVersion(pkgCache::VerIterator &Ver);
-   virtual string Description();
-   virtual string DescriptionLanguage();
+   virtual std::string Description();
+   virtual std::string DescriptionLanguage();
    virtual MD5SumValue Description_md5();
    virtual MD5SumValue Description_md5();
    virtual unsigned short VersionHash();
    virtual unsigned short VersionHash();
    virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
    virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
@@ -68,15 +67,15 @@ class debListParser : public pkgCacheGenerator::ListParser
    virtual bool Step();
    virtual bool Step();
    
    
    bool LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,FileFd &File,
    bool LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,FileFd &File,
-			string section);
+			std::string section);
    
    
    static const char *ParseDepends(const char *Start,const char *Stop,
    static const char *ParseDepends(const char *Start,const char *Stop,
-			    string &Package,string &Ver,unsigned int &Op,
+			    std::string &Package,std::string &Ver,unsigned int &Op,
 			    bool const &ParseArchFlags = false,
 			    bool const &ParseArchFlags = false,
 			    bool const &StripMultiArch = true);
 			    bool const &StripMultiArch = true);
    static const char *ConvertRelation(const char *I,unsigned int &Op);
    static const char *ConvertRelation(const char *I,unsigned int &Op);
 
 
-   debListParser(FileFd *File, string const &Arch = "");
+   debListParser(FileFd *File, std::string const &Arch = "");
    virtual ~debListParser() {};
    virtual ~debListParser() {};
 };
 };
 
 

+ 16 - 8
apt-pkg/deb/debmetaindex.cc

@@ -1,14 +1,19 @@
 // ijones, walters
 // ijones, walters
+#include <config.h>
 
 
 #include <apt-pkg/debmetaindex.h>
 #include <apt-pkg/debmetaindex.h>
 #include <apt-pkg/debindexfile.h>
 #include <apt-pkg/debindexfile.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
+#include <apt-pkg/fileutl.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/aptconfiguration.h>
 #include <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/indexrecords.h>
+#include <apt-pkg/sourcelist.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 
 
 #include <set>
 #include <set>
+#include <algorithm>
 
 
 using namespace std;
 using namespace std;
 
 
@@ -197,7 +202,11 @@ vector <struct IndexTarget *>* debReleaseIndex::ComputeIndexTargets() const {
 		}
 		}
 	}
 	}
 
 
-	std::vector<std::string> const lang = APT::Configuration::getLanguages(true);
+	std::vector<std::string> lang = APT::Configuration::getLanguages(true);
+	std::vector<std::string>::iterator lend = std::remove(lang.begin(), lang.end(), "none");
+	if (lend != lang.end())
+		lang.erase(lend);
+
 	if (lang.empty() == true)
 	if (lang.empty() == true)
 		return IndexTargets;
 		return IndexTargets;
 
 
@@ -208,8 +217,7 @@ vector <struct IndexTarget *>* debReleaseIndex::ComputeIndexTargets() const {
 		for (std::set<std::string>::const_iterator s = sections.begin();
 		for (std::set<std::string>::const_iterator s = sections.begin();
 		     s != sections.end(); ++s) {
 		     s != sections.end(); ++s) {
 			for (std::vector<std::string>::const_iterator l = lang.begin();
 			for (std::vector<std::string>::const_iterator l = lang.begin();
-			     l != lang.end(); l++) {
-				if (*l == "none") continue;
+			     l != lang.end(); ++l) {
 				IndexTarget * Target = new OptionalIndexTarget();
 				IndexTarget * Target = new OptionalIndexTarget();
 				Target->ShortDesc = "Translation-" + *l;
 				Target->ShortDesc = "Translation-" + *l;
 				Target->MetaKey = TranslationIndexURISuffix(l->c_str(), *s);
 				Target->MetaKey = TranslationIndexURISuffix(l->c_str(), *s);
@@ -238,7 +246,7 @@ bool debReleaseIndex::GetIndexes(pkgAcquire *Owner, bool const &GetAll) const
    // special case for --print-uris
    // special case for --print-uris
    if (GetAll) {
    if (GetAll) {
       vector <struct IndexTarget *> *targets = ComputeIndexTargets();
       vector <struct IndexTarget *> *targets = ComputeIndexTargets();
-      for (vector <struct IndexTarget*>::const_iterator Target = targets->begin(); Target != targets->end(); Target++) {
+      for (vector <struct IndexTarget*>::const_iterator Target = targets->begin(); Target != targets->end(); ++Target) {
 	 new pkgAcqIndex(Owner, (*Target)->URI, (*Target)->Description,
 	 new pkgAcqIndex(Owner, (*Target)->URI, (*Target)->Description,
 			 (*Target)->ShortDesc, HashString());
 			 (*Target)->ShortDesc, HashString());
       }
       }
@@ -295,7 +303,7 @@ vector <pkgIndexFile *> *debReleaseIndex::GetIndexFiles() {
 	if (src != ArchEntries.end()) {
 	if (src != ArchEntries.end()) {
 		vector<debSectionEntry const*> const SectionEntries = src->second;
 		vector<debSectionEntry const*> const SectionEntries = src->second;
 		for (vector<debSectionEntry const*>::const_iterator I = SectionEntries.begin();
 		for (vector<debSectionEntry const*>::const_iterator I = SectionEntries.begin();
-		     I != SectionEntries.end(); I++)
+		     I != SectionEntries.end(); ++I)
 			Indexes->push_back(new debSourcesIndex (URI, Dist, (*I)->Section, IsTrusted()));
 			Indexes->push_back(new debSourcesIndex (URI, Dist, (*I)->Section, IsTrusted()));
 	}
 	}
 
 
@@ -310,7 +318,7 @@ vector <pkgIndexFile *> *debReleaseIndex::GetIndexFiles() {
 		if (a->first == "source")
 		if (a->first == "source")
 			continue;
 			continue;
 		for (vector<debSectionEntry const*>::const_iterator I = a->second.begin();
 		for (vector<debSectionEntry const*>::const_iterator I = a->second.begin();
-		     I != a->second.end(); I++) {
+		     I != a->second.end(); ++I) {
 			Indexes->push_back(new debPackagesIndex (URI, Dist, (*I)->Section, IsTrusted(), a->first));
 			Indexes->push_back(new debPackagesIndex (URI, Dist, (*I)->Section, IsTrusted(), a->first));
 			sections[(*I)->Section].insert(lang.begin(), lang.end());
 			sections[(*I)->Section].insert(lang.begin(), lang.end());
 		}
 		}
@@ -319,7 +327,7 @@ vector <pkgIndexFile *> *debReleaseIndex::GetIndexFiles() {
 	for (map<string, set<string> >::const_iterator s = sections.begin();
 	for (map<string, set<string> >::const_iterator s = sections.begin();
 	     s != sections.end(); ++s)
 	     s != sections.end(); ++s)
 		for (set<string>::const_iterator l = s->second.begin();
 		for (set<string>::const_iterator l = s->second.begin();
-		     l != s->second.end(); l++) {
+		     l != s->second.end(); ++l) {
 			if (*l == "none") continue;
 			if (*l == "none") continue;
 			Indexes->push_back(new debTranslationsIndex(URI,Dist,s->first,(*l).c_str()));
 			Indexes->push_back(new debTranslationsIndex(URI,Dist,s->first,(*l).c_str()));
 		}
 		}
@@ -368,7 +376,7 @@ class debSLTypeDebian : public pkgSourceList::Type
       map<string, string>::const_iterator const trusted = Options.find("trusted");
       map<string, string>::const_iterator const trusted = Options.find("trusted");
 
 
       for (vector<metaIndex *>::const_iterator I = List.begin();
       for (vector<metaIndex *>::const_iterator I = List.begin();
-	   I != List.end(); I++)
+	   I != List.end(); ++I)
       {
       {
 	 // We only worry about debian entries here
 	 // We only worry about debian entries here
 	 if (strcmp((*I)->GetType(), "deb") != 0)
 	 if (strcmp((*I)->GetType(), "deb") != 0)

+ 22 - 21
apt-pkg/deb/debmetaindex.h

@@ -3,9 +3,10 @@
 #define PKGLIB_DEBMETAINDEX_H
 #define PKGLIB_DEBMETAINDEX_H
 
 
 #include <apt-pkg/metaindex.h>
 #include <apt-pkg/metaindex.h>
-#include <apt-pkg/sourcelist.h>
 
 
 #include <map>
 #include <map>
+#include <string>
+#include <vector>
 
 
 class debReleaseIndex : public metaIndex {
 class debReleaseIndex : public metaIndex {
    public:
    public:
@@ -13,43 +14,43 @@ class debReleaseIndex : public metaIndex {
    class debSectionEntry
    class debSectionEntry
    {
    {
       public:
       public:
-      debSectionEntry (string const &Section, bool const &IsSrc);
-      string const Section;
+      debSectionEntry (std::string const &Section, bool const &IsSrc);
+      std::string const Section;
       bool const IsSrc;
       bool const IsSrc;
    };
    };
 
 
    private:
    private:
    /** \brief dpointer placeholder (for later in case we need it) */
    /** \brief dpointer placeholder (for later in case we need it) */
    void *d;
    void *d;
-   std::map<string, vector<debSectionEntry const*> > ArchEntries;
+   std::map<std::string, std::vector<debSectionEntry const*> > ArchEntries;
    enum { ALWAYS_TRUSTED, NEVER_TRUSTED, CHECK_TRUST } Trusted;
    enum { ALWAYS_TRUSTED, NEVER_TRUSTED, CHECK_TRUST } Trusted;
 
 
    public:
    public:
 
 
-   debReleaseIndex(string const &URI, string const &Dist);
-   debReleaseIndex(string const &URI, string const &Dist, bool const Trusted);
+   debReleaseIndex(std::string const &URI, std::string const &Dist);
+   debReleaseIndex(std::string const &URI, std::string const &Dist, bool const Trusted);
    virtual ~debReleaseIndex();
    virtual ~debReleaseIndex();
 
 
-   virtual string ArchiveURI(string const &File) const {return URI + File;};
+   virtual std::string ArchiveURI(std::string const &File) const {return URI + File;};
    virtual bool GetIndexes(pkgAcquire *Owner, bool const &GetAll=false) const;
    virtual bool GetIndexes(pkgAcquire *Owner, bool const &GetAll=false) const;
-   vector <struct IndexTarget *>* ComputeIndexTargets() const;
-   string Info(const char *Type, string const &Section, string const &Arch="") const;
-   string MetaIndexInfo(const char *Type) const;
-   string MetaIndexFile(const char *Types) const;
-   string MetaIndexURI(const char *Type) const;
-   string IndexURI(const char *Type, string const &Section, string const &Arch="native") const;
-   string IndexURISuffix(const char *Type, string const &Section, string const &Arch="native") const;
-   string SourceIndexURI(const char *Type, const string &Section) const;
-   string SourceIndexURISuffix(const char *Type, const string &Section) const;
-   string TranslationIndexURI(const char *Type, const string &Section) const;
-   string TranslationIndexURISuffix(const char *Type, const string &Section) const;
-   virtual vector <pkgIndexFile *> *GetIndexFiles();
+   std::vector <struct IndexTarget *>* ComputeIndexTargets() const;
+   std::string Info(const char *Type, std::string const &Section, std::string const &Arch="") const;
+   std::string MetaIndexInfo(const char *Type) const;
+   std::string MetaIndexFile(const char *Types) const;
+   std::string MetaIndexURI(const char *Type) const;
+   std::string IndexURI(const char *Type, std::string const &Section, std::string const &Arch="native") const;
+   std::string IndexURISuffix(const char *Type, std::string const &Section, std::string const &Arch="native") const;
+   std::string SourceIndexURI(const char *Type, const std::string &Section) const;
+   std::string SourceIndexURISuffix(const char *Type, const std::string &Section) const;
+   std::string TranslationIndexURI(const char *Type, const std::string &Section) const;
+   std::string TranslationIndexURISuffix(const char *Type, const std::string &Section) const;
+   virtual std::vector <pkgIndexFile *> *GetIndexFiles();
 
 
    void SetTrusted(bool const Trusted);
    void SetTrusted(bool const Trusted);
    virtual bool IsTrusted() const;
    virtual bool IsTrusted() const;
 
 
-   void PushSectionEntry(vector<string> const &Archs, const debSectionEntry *Entry);
-   void PushSectionEntry(string const &Arch, const debSectionEntry *Entry);
+   void PushSectionEntry(std::vector<std::string> const &Archs, const debSectionEntry *Entry);
+   void PushSectionEntry(std::string const &Arch, const debSectionEntry *Entry);
    void PushSectionEntry(const debSectionEntry *Entry);
    void PushSectionEntry(const debSectionEntry *Entry);
 };
 };
 
 

+ 9 - 3
apt-pkg/deb/debrecords.cc

@@ -8,13 +8,19 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include <config.h>
+
 #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/error.h>
 #include <apt-pkg/aptconfiguration.h>
 #include <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/fileutl.h>
+
 #include <langinfo.h>
 #include <langinfo.h>
 									/*}}}*/
 									/*}}}*/
 
 
+using std::string;
+
 // RecordParser::debRecordParser - Constructor				/*{{{*/
 // RecordParser::debRecordParser - Constructor				/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
@@ -133,9 +139,9 @@ string debRecordParser::LongDesc()
      orig = Section.FindS("Description").c_str();
      orig = Section.FindS("Description").c_str();
   else
   else
   {
   {
-     vector<string> const lang = APT::Configuration::getLanguages();
-     for (vector<string>::const_iterator l = lang.begin();
-	  orig.empty() && l != lang.end(); l++)
+     std::vector<string> const lang = APT::Configuration::getLanguages();
+     for (std::vector<string>::const_iterator l = lang.begin();
+	  orig.empty() && l != lang.end(); ++l)
 	orig = Section.FindS(string("Description-").append(*l).c_str());
 	orig = Section.FindS(string("Description-").append(*l).c_str());
   }
   }
 
 

+ 15 - 15
apt-pkg/deb/debrecords.h

@@ -15,8 +15,8 @@
 #define PKGLIB_DEBRECORDS_H
 #define PKGLIB_DEBRECORDS_H
 
 
 #include <apt-pkg/pkgrecords.h>
 #include <apt-pkg/pkgrecords.h>
-#include <apt-pkg/indexfile.h>
 #include <apt-pkg/tagfile.h>
 #include <apt-pkg/tagfile.h>
+#include <apt-pkg/fileutl.h>
 
 
 class debRecordParser : public pkgRecords::Parser
 class debRecordParser : public pkgRecords::Parser
 {
 {
@@ -35,27 +35,27 @@ class debRecordParser : public pkgRecords::Parser
    public:
    public:
 
 
    // These refer to the archive file for the Version
    // These refer to the archive file for the Version
-   virtual string FileName();
-   virtual string MD5Hash();
-   virtual string SHA1Hash();
-   virtual string SHA256Hash();
-   virtual string SHA512Hash();
-   virtual string SourcePkg();
-   virtual string SourceVer();
+   virtual std::string FileName();
+   virtual std::string MD5Hash();
+   virtual std::string SHA1Hash();
+   virtual std::string SHA256Hash();
+   virtual std::string SHA512Hash();
+   virtual std::string SourcePkg();
+   virtual std::string SourceVer();
    
    
    // These are some general stats about the package
    // These are some general stats about the package
-   virtual string Maintainer();
-   virtual string ShortDesc();
-   virtual string LongDesc();
-   virtual string Name();
-   virtual string Homepage();
+   virtual std::string Maintainer();
+   virtual std::string ShortDesc();
+   virtual std::string LongDesc();
+   virtual std::string Name();
+   virtual std::string Homepage();
 
 
    // An arbitrary custom field
    // An arbitrary custom field
-   virtual string RecordField(const char *fieldName);
+   virtual std::string RecordField(const char *fieldName);
 
 
    virtual void GetRec(const char *&Start,const char *&Stop);
    virtual void GetRec(const char *&Start,const char *&Stop);
    
    
-   debRecordParser(string FileName,pkgCache &Cache);
+   debRecordParser(std::string FileName,pkgCache &Cache);
    virtual ~debRecordParser() {};
    virtual ~debRecordParser() {};
 };
 };
 
 

+ 30 - 19
apt-pkg/deb/debsrcrecords.cc

@@ -9,6 +9,8 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include <config.h>
+
 #include <apt-pkg/deblistparser.h>
 #include <apt-pkg/deblistparser.h>
 #include <apt-pkg/debsrcrecords.h>
 #include <apt-pkg/debsrcrecords.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
@@ -19,6 +21,8 @@
 using std::max;
 using std::max;
 									/*}}}*/
 									/*}}}*/
 
 
+using std::string;
+
 // SrcRecordParser::Binaries - Return the binaries field		/*{{{*/
 // SrcRecordParser::Binaries - Return the binaries field		/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* This member parses the binaries field into a pair of class arrays and
 /* This member parses the binaries field into a pair of class arrays and
@@ -28,25 +32,32 @@ using std::max;
    used during scanning to find the right package */
    used during scanning to find the right package */
 const char **debSrcRecordParser::Binaries()
 const char **debSrcRecordParser::Binaries()
 {
 {
-   // This should use Start/Stop too, it is supposed to be efficient after all.
-   string Bins = Sect.FindS("Binary");
-   if (Bins.empty() == true || Bins.length() >= 102400)
-      return 0;
-   
-   if (Bins.length() >= BufSize)
-   {
-      delete [] Buffer;
-      // allocate new size based on buffer (but never smaller than 4000)
-      BufSize = max((unsigned int)4000, max((unsigned int)Bins.length()+1,2*BufSize));
-      Buffer = new char[BufSize];
-   }
+   const char *Start, *End;
+   if (Sect.Find("Binary", Start, End) == false)
+      return NULL;
+   for (; isspace(*Start) != 0; ++Start);
+   if (Start >= End)
+      return NULL;
+
+   StaticBinList.clear();
+   free(Buffer);
+   Buffer = strndup(Start, End - Start);
 
 
-   strcpy(Buffer,Bins.c_str());
-   if (TokSplitString(',',Buffer,StaticBinList,
-		      sizeof(StaticBinList)/sizeof(StaticBinList[0])) == false)
-      return 0;
+   char* bin = Buffer;
+   do {
+      char* binStartNext = strchrnul(bin, ',');
+      char* binEnd = binStartNext - 1;
+      for (; isspace(*binEnd) != 0; --binEnd)
+	 binEnd = '\0';
+      StaticBinList.push_back(bin);
+      if (*binStartNext != ',')
+	 break;
+      *binStartNext = '\0';
+      for (bin = binStartNext + 1; isspace(*bin) != 0; ++bin);
+   } while (*bin != '\0');
+   StaticBinList.push_back(NULL);
 
 
-   return (const char **)StaticBinList;
+   return (const char **) &StaticBinList[0];
 }
 }
 									/*}}}*/
 									/*}}}*/
 // SrcRecordParser::BuildDepends - Return the Build-Depends information	/*{{{*/
 // SrcRecordParser::BuildDepends - Return the Build-Depends information	/*{{{*/
@@ -55,7 +66,7 @@ const char **debSrcRecordParser::Binaries()
    package/version records representing the build dependency. The returned 
    package/version records representing the build dependency. The returned 
    array need not be freed and will be reused by the next call to this 
    array need not be freed and will be reused by the next call to this 
    function */
    function */
-bool debSrcRecordParser::BuildDepends(vector<pkgSrcRecords::Parser::BuildDepRec> &BuildDeps,
+bool debSrcRecordParser::BuildDepends(std::vector<pkgSrcRecords::Parser::BuildDepRec> &BuildDeps,
 					bool const &ArchOnly, bool const &StripMultiArch)
 					bool const &ArchOnly, bool const &StripMultiArch)
 {
 {
    unsigned int I;
    unsigned int I;
@@ -100,7 +111,7 @@ bool debSrcRecordParser::BuildDepends(vector<pkgSrcRecords::Parser::BuildDepRec>
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* This parses the list of files and returns it, each file is required to have
 /* This parses the list of files and returns it, each file is required to have
    a complete source package */
    a complete source package */
-bool debSrcRecordParser::Files(vector<pkgSrcRecords::File> &List)
+bool debSrcRecordParser::Files(std::vector<pkgSrcRecords::File> &List)
 {
 {
    List.erase(List.begin(),List.end());
    List.erase(List.begin(),List.end());
    
    

+ 11 - 12
apt-pkg/deb/debsrcrecords.h

@@ -24,10 +24,9 @@ class debSrcRecordParser : public pkgSrcRecords::Parser
    FileFd Fd;
    FileFd Fd;
    pkgTagFile Tags;
    pkgTagFile Tags;
    pkgTagSection Sect;
    pkgTagSection Sect;
-   char *StaticBinList[400];
+   std::vector<const char*> StaticBinList;
    unsigned long iOffset;
    unsigned long iOffset;
    char *Buffer;
    char *Buffer;
-   unsigned int BufSize;
    
    
    public:
    public:
 
 
@@ -35,24 +34,24 @@ class debSrcRecordParser : public pkgSrcRecords::Parser
    virtual bool Step() {iOffset = Tags.Offset(); return Tags.Step(Sect);};
    virtual bool Step() {iOffset = Tags.Offset(); return Tags.Step(Sect);};
    virtual bool Jump(unsigned long const &Off) {iOffset = Off; return Tags.Jump(Sect,Off);};
    virtual bool Jump(unsigned long const &Off) {iOffset = Off; return Tags.Jump(Sect,Off);};
 
 
-   virtual string Package() const {return Sect.FindS("Package");};
-   virtual string Version() const {return Sect.FindS("Version");};
-   virtual string Maintainer() const {return Sect.FindS("Maintainer");};
-   virtual string Section() const {return Sect.FindS("Section");};
+   virtual std::string Package() const {return Sect.FindS("Package");};
+   virtual std::string Version() const {return Sect.FindS("Version");};
+   virtual std::string Maintainer() const {return Sect.FindS("Maintainer");};
+   virtual std::string Section() const {return Sect.FindS("Section");};
    virtual const char **Binaries();
    virtual const char **Binaries();
-   virtual bool BuildDepends(vector<BuildDepRec> &BuildDeps, bool const &ArchOnly, bool const &StripMultiArch = true);
+   virtual bool BuildDepends(std::vector<BuildDepRec> &BuildDeps, bool const &ArchOnly, bool const &StripMultiArch = true);
    virtual unsigned long Offset() {return iOffset;};
    virtual unsigned long Offset() {return iOffset;};
-   virtual string AsStr() 
+   virtual std::string AsStr() 
    {
    {
       const char *Start=0,*Stop=0;
       const char *Start=0,*Stop=0;
       Sect.GetSection(Start,Stop);
       Sect.GetSection(Start,Stop);
-      return string(Start,Stop);
+      return std::string(Start,Stop);
    };
    };
-   virtual bool Files(vector<pkgSrcRecords::File> &F);
+   virtual bool Files(std::vector<pkgSrcRecords::File> &F);
 
 
-   debSrcRecordParser(string const &File,pkgIndexFile const *Index) 
+   debSrcRecordParser(std::string const &File,pkgIndexFile const *Index) 
       : Parser(Index), Fd(File,FileFd::ReadOnlyGzip), Tags(&Fd,102400), 
       : Parser(Index), Fd(File,FileFd::ReadOnlyGzip), Tags(&Fd,102400), 
-        Buffer(0), BufSize(0) {}
+        Buffer(NULL) {}
    virtual ~debSrcRecordParser();
    virtual ~debSrcRecordParser();
 };
 };
 
 

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

@@ -10,6 +10,8 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include <config.h>
+
 #include <apt-pkg/debsystem.h>
 #include <apt-pkg/debsystem.h>
 #include <apt-pkg/debversion.h>
 #include <apt-pkg/debversion.h>
 #include <apt-pkg/debindexfile.h>
 #include <apt-pkg/debindexfile.h>
@@ -17,13 +19,16 @@
 #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 <apti18n.h>
 #include <sys/types.h>
 #include <sys/types.h>
 #include <unistd.h>
 #include <unistd.h>
 #include <dirent.h>
 #include <dirent.h>
 #include <errno.h>
 #include <errno.h>
+
+#include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
 
 
+using std::string;
+
 debSystem debSys;
 debSystem debSys;
 
 
 class debSystemPrivate {
 class debSystemPrivate {
@@ -216,7 +221,7 @@ signed debSystem::Score(Configuration const &Cnf)
 // System::AddStatusFiles - Register the status files			/*{{{*/
 // System::AddStatusFiles - Register the status files			/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-bool debSystem::AddStatusFiles(vector<pkgIndexFile *> &List)
+bool debSystem::AddStatusFiles(std::vector<pkgIndexFile *> &List)
 {
 {
    if (d->StatusFile == 0)
    if (d->StatusFile == 0)
       d->StatusFile = new debStatusIndex(_config->FindFile("Dir::State::status"));
       d->StatusFile = new debStatusIndex(_config->FindFile("Dir::State::status"));

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

@@ -11,10 +11,12 @@
 #define PKGLIB_DEBSYSTEM_H
 #define PKGLIB_DEBSYSTEM_H
 
 
 #include <apt-pkg/pkgsystem.h>
 #include <apt-pkg/pkgsystem.h>
+#include <apt-pkg/pkgcache.h>
 
 
 class debSystemPrivate;
 class debSystemPrivate;
-
 class debStatusIndex;
 class debStatusIndex;
+class pkgDepCache;
+
 class debSystem : public pkgSystem
 class debSystem : public pkgSystem
 {
 {
    // private d-pointer
    // private d-pointer

+ 13 - 18
apt-pkg/deb/debversion.cc

@@ -10,7 +10,7 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
-#define APT_COMPATIBILITY 986
+#include <config.h>
 
 
 #include <apt-pkg/debversion.h>
 #include <apt-pkg/debversion.h>
 #include <apt-pkg/pkgcache.h>
 #include <apt-pkg/pkgcache.h>
@@ -127,14 +127,12 @@ int debVersioningSystem::CmpFragment(const char *A,const char *AEnd,
 int debVersioningSystem::DoCmpVersion(const char *A,const char *AEnd,
 int debVersioningSystem::DoCmpVersion(const char *A,const char *AEnd,
 				      const char *B,const char *BEnd)
 				      const char *B,const char *BEnd)
 {
 {
-   // Strip off the epoch and compare it 
-   const char *lhs = A;
-   const char *rhs = B;
-   for (;lhs != AEnd && *lhs != ':'; lhs++);
-   for (;rhs != BEnd && *rhs != ':'; rhs++);
-   if (lhs == AEnd)
+   // Strip off the epoch and compare it
+   const char *lhs = (const char*) memchr(A, ':', AEnd - A);
+   const char *rhs = (const char*) memchr(B, ':', BEnd - B);
+   if (lhs == NULL)
       lhs = A;
       lhs = A;
-   if (rhs == BEnd)
+   if (rhs == NULL)
       rhs = B;
       rhs = B;
    
    
    // Special case: a zero epoch is the same as no epoch,
    // Special case: a zero epoch is the same as no epoch,
@@ -169,15 +167,12 @@ int debVersioningSystem::DoCmpVersion(const char *A,const char *AEnd,
    if (rhs != B)
    if (rhs != B)
       rhs++;
       rhs++;
    
    
-   // Find the last - 
-   const char *dlhs = AEnd-1;
-   const char *drhs = BEnd-1;
-   for (;dlhs > lhs && *dlhs != '-'; dlhs--);
-   for (;drhs > rhs && *drhs != '-'; drhs--);
-
-   if (dlhs == lhs)
+   // Find the last -
+   const char *dlhs = (const char*) memrchr(lhs, '-', AEnd - lhs);
+   const char *drhs = (const char*) memrchr(rhs, '-', BEnd - rhs);
+   if (dlhs == NULL)
       dlhs = AEnd;
       dlhs = AEnd;
-   if (drhs == rhs)
+   if (drhs == NULL)
       drhs = BEnd;
       drhs = BEnd;
    
    
    // Compare the main version
    // Compare the main version
@@ -262,7 +257,7 @@ bool debVersioningSystem::CheckDep(const char *PkgVer,
 // debVS::UpstreamVersion - Return the upstream version string		/*{{{*/
 // debVS::UpstreamVersion - Return the upstream version string		/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* This strips all the debian specific information from the version number */
 /* This strips all the debian specific information from the version number */
-string debVersioningSystem::UpstreamVersion(const char *Ver)
+std::string debVersioningSystem::UpstreamVersion(const char *Ver)
 {
 {
    // Strip off the bit before the first colon
    // Strip off the bit before the first colon
    const char *I = Ver;
    const char *I = Ver;
@@ -277,6 +272,6 @@ string debVersioningSystem::UpstreamVersion(const char *Ver)
       if (*I == '-')
       if (*I == '-')
 	 Last = I - Ver;
 	 Last = I - Ver;
    
    
-   return string(Ver,Last);
+   return std::string(Ver,Last);
 }
 }
 									/*}}}*/
 									/*}}}*/

+ 1 - 29
apt-pkg/deb/debversion.h

@@ -32,39 +32,11 @@ class debVersioningSystem : public pkgVersioningSystem
    {
    {
       return DoCmpVersion(A,Aend,B,Bend);
       return DoCmpVersion(A,Aend,B,Bend);
    }   
    }   
-   virtual string UpstreamVersion(const char *A);
+   virtual std::string UpstreamVersion(const char *A);
 
 
    debVersioningSystem();
    debVersioningSystem();
 };
 };
 
 
 extern debVersioningSystem debVS;
 extern debVersioningSystem debVS;
 
 
-#ifdef APT_COMPATIBILITY
-#if APT_COMPATIBILITY != 986
-#warning "Using APT_COMPATIBILITY"
-#endif
-
-inline int pkgVersionCompare(const char *A, const char *B)
-{
-   return debVS.CmpVersion(A,B);
-}
-inline int pkgVersionCompare(const char *A, const char *AEnd, 
-			     const char *B, const char *BEnd)
-{
-   return debVS.DoCmpVersion(A,AEnd,B,BEnd);
-}
-inline int pkgVersionCompare(string A,string B)
-{
-   return debVS.CmpVersion(A,B);
-}
-inline bool pkgCheckDep(const char *DepVer,const char *PkgVer,int Op)
-{
-   return debVS.CheckDep(PkgVer,Op,DepVer);
-}
-inline string pkgBaseVersion(const char *Ver)
-{
-   return debVS.UpstreamVersion(Ver);
-}
-#endif
-
 #endif
 #endif

+ 110 - 87
apt-pkg/deb/dpkgpm.cc

@@ -8,6 +8,8 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Includes								/*{{{*/
 // Includes								/*{{{*/
+#include <config.h>
+
 #include <apt-pkg/dpkgpm.h>
 #include <apt-pkg/dpkgpm.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
@@ -16,6 +18,7 @@
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/cachefile.h>
 #include <apt-pkg/cachefile.h>
+#include <apt-pkg/packagemanager.h>
 
 
 #include <unistd.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdlib.h>
@@ -40,7 +43,6 @@
 #include <sys/ioctl.h>
 #include <sys/ioctl.h>
 #include <pty.h>
 #include <pty.h>
 
 
-#include <config.h>
 #include <apti18n.h>
 #include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
 
 
@@ -229,7 +231,7 @@ bool pkgDPkgPM::SendV2Pkgs(FILE *F)
    fprintf(F,"\n");
    fprintf(F,"\n");
  
  
    // Write out the package actions in order.
    // Write out the package actions in order.
-   for (vector<Item>::iterator I = List.begin(); I != List.end(); I++)
+   for (vector<Item>::iterator I = List.begin(); I != List.end(); ++I)
    {
    {
       if(I->Pkg.end() == true)
       if(I->Pkg.end() == true)
 	 continue;
 	 continue;
@@ -351,7 +353,7 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
       // Feed it the filenames.
       // Feed it the filenames.
       if (Version <= 1)
       if (Version <= 1)
       {
       {
-	 for (vector<Item>::iterator I = List.begin(); I != List.end(); I++)
+	 for (vector<Item>::iterator I = List.begin(); I != List.end(); ++I)
 	 {
 	 {
 	    // Only deal with packages to be installed from .deb
 	    // Only deal with packages to be installed from .deb
 	    if (I->Op != Item::Install)
 	    if (I->Op != Item::Install)
@@ -706,7 +708,7 @@ bool pkgDPkgPM::OpenLog()
       chmod(history_name.c_str(), 0644);
       chmod(history_name.c_str(), 0644);
       fprintf(d->history_out, "\nStart-Date: %s\n", timestr);
       fprintf(d->history_out, "\nStart-Date: %s\n", timestr);
       string remove, purge, install, reinstall, upgrade, downgrade;
       string remove, purge, install, reinstall, upgrade, downgrade;
-      for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
+      for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
       {
       {
 	 enum { CANDIDATE, CANDIDATE_AUTO, CURRENT_CANDIDATE, CURRENT } infostring;
 	 enum { CANDIDATE, CANDIDATE_AUTO, CURRENT_CANDIDATE, CURRENT } infostring;
 	 string *line = NULL;
 	 string *line = NULL;
@@ -884,14 +886,14 @@ bool pkgDPkgPM::Go(int OutStatusFd)
    // that will be [installed|configured|removed|purged] and add
    // that will be [installed|configured|removed|purged] and add
    // them to the PackageOps map (the dpkg states it goes through)
    // them to the PackageOps map (the dpkg states it goes through)
    // and the PackageOpsTranslations (human readable strings)
    // and the PackageOpsTranslations (human readable strings)
-   for (vector<Item>::const_iterator I = List.begin(); I != List.end();I++)
+   for (vector<Item>::const_iterator I = List.begin(); I != List.end(); ++I)
    {
    {
       if((*I).Pkg.end() == true)
       if((*I).Pkg.end() == true)
 	 continue;
 	 continue;
 
 
       string const name = (*I).Pkg.Name();
       string const name = (*I).Pkg.Name();
       PackageOpsDone[name] = 0;
       PackageOpsDone[name] = 0;
-      for(int i=0; (DpkgStatesOpMap[(*I).Op][i]).state != NULL;  i++) 
+      for(int i=0; (DpkgStatesOpMap[(*I).Op][i]).state != NULL; ++i)
       {
       {
 	 PackageOps[name].push_back(DpkgStatesOpMap[(*I).Op][i]);
 	 PackageOps[name].push_back(DpkgStatesOpMap[(*I).Op][i]);
 	 PackagesTotal++;
 	 PackagesTotal++;
@@ -903,13 +905,35 @@ bool pkgDPkgPM::Go(int OutStatusFd)
    // create log
    // create log
    OpenLog();
    OpenLog();
 
 
+   // Generate the base argument list for dpkg
+   std::vector<const char *> Args;
+   unsigned long StartSize = 0;
+   string const Tmp = _config->Find("Dir::Bin::dpkg","dpkg");
+   Args.push_back(Tmp.c_str());
+   StartSize += Tmp.length();
+
+   // Stick in any custom dpkg options
+   Configuration::Item const *Opts = _config->Tree("DPkg::Options");
+   if (Opts != 0)
+   {
+      Opts = Opts->Child;
+      for (; Opts != 0; Opts = Opts->Next)
+      {
+	 if (Opts->Value.empty() == true)
+	    continue;
+	 Args.push_back(Opts->Value.c_str());
+	 StartSize += Opts->Value.length();
+      }
+   }
+   size_t const BaseArgs = Args.size();
+
    // this loop is runs once per operation
    // this loop is runs once per operation
    for (vector<Item>::const_iterator I = List.begin(); I != List.end();)
    for (vector<Item>::const_iterator I = List.begin(); I != List.end();)
    {
    {
       // Do all actions with the same Op in one run
       // Do all actions with the same Op in one run
       vector<Item>::const_iterator J = I;
       vector<Item>::const_iterator J = I;
       if (TriggersPending == true)
       if (TriggersPending == true)
-	 for (; J != List.end(); J++)
+	 for (; J != List.end(); ++J)
 	 {
 	 {
 	    if (J->Op == I->Op)
 	    if (J->Op == I->Op)
 	       continue;
 	       continue;
@@ -921,14 +945,15 @@ bool pkgDPkgPM::Go(int OutStatusFd)
 	    break;
 	    break;
 	 }
 	 }
       else
       else
-	 for (; J != List.end() && J->Op == I->Op; J++)
+	 for (; J != List.end() && J->Op == I->Op; ++J)
 	    /* nothing */;
 	    /* nothing */;
 
 
-      // Generate the argument list
-      const char *Args[MaxArgs + 50];
       // keep track of allocated strings for multiarch package names
       // keep track of allocated strings for multiarch package names
-      char *Packages[MaxArgs + 50];
-      unsigned int pkgcount = 0;
+      std::vector<char *> Packages;
+
+      // start with the baseset of arguments
+      unsigned long Size = StartSize;
+      Args.erase(Args.begin() + BaseArgs, Args.end());
 
 
       // Now check if we are within the MaxArgs limit
       // Now check if we are within the MaxArgs limit
       //
       //
@@ -936,139 +961,122 @@ bool pkgDPkgPM::Go(int OutStatusFd)
       // the argument list is split in a way that A depends on B
       // the argument list is split in a way that A depends on B
       // and they are in the same "--configure A B" run
       // and they are in the same "--configure A B" run
       // - with the split they may now be configured in different
       // - with the split they may now be configured in different
-      //   runs 
+      //   runs, using Immediate-Configure-All can help prevent this.
       if (J - I > (signed)MaxArgs)
       if (J - I > (signed)MaxArgs)
+      {
 	 J = I + MaxArgs;
 	 J = I + MaxArgs;
-      
-      unsigned int n = 0;
-      unsigned long Size = 0;
-      string const Tmp = _config->Find("Dir::Bin::dpkg","dpkg");
-      Args[n++] = Tmp.c_str();
-      Size += strlen(Args[n-1]);
-      
-      // Stick in any custom dpkg options
-      Configuration::Item const *Opts = _config->Tree("DPkg::Options");
-      if (Opts != 0)
+	 Args.reserve(MaxArgs + 10);
+      }
+      else
       {
       {
-	 Opts = Opts->Child;
-	 for (; Opts != 0; Opts = Opts->Next)
-	 {
-	    if (Opts->Value.empty() == true)
-	       continue;
-	    Args[n++] = Opts->Value.c_str();
-	    Size += Opts->Value.length();
-	 }	 
+	 Args.reserve((J - I) + 10);
       }
       }
+
       
       
-      char status_fd_buf[20];
       int fd[2];
       int fd[2];
       pipe(fd);
       pipe(fd);
-      
-      Args[n++] = "--status-fd";
-      Size += strlen(Args[n-1]);
+
+#define ADDARG(X) Args.push_back(X); Size += strlen(X)
+#define ADDARGC(X) Args.push_back(X); Size += sizeof(X) - 1
+
+      ADDARGC("--status-fd");
+      char status_fd_buf[20];
       snprintf(status_fd_buf,sizeof(status_fd_buf),"%i", fd[1]);
       snprintf(status_fd_buf,sizeof(status_fd_buf),"%i", fd[1]);
-      Args[n++] = status_fd_buf;
-      Size += strlen(Args[n-1]);
+      ADDARG(status_fd_buf);
+      unsigned long const Op = I->Op;
 
 
       switch (I->Op)
       switch (I->Op)
       {
       {
 	 case Item::Remove:
 	 case Item::Remove:
-	 Args[n++] = "--force-depends";
-	 Size += strlen(Args[n-1]);
-	 Args[n++] = "--force-remove-essential";
-	 Size += strlen(Args[n-1]);
-	 Args[n++] = "--remove";
-	 Size += strlen(Args[n-1]);
+	 ADDARGC("--force-depends");
+	 ADDARGC("--force-remove-essential");
+	 ADDARGC("--remove");
 	 break;
 	 break;
 	 
 	 
 	 case Item::Purge:
 	 case Item::Purge:
-	 Args[n++] = "--force-depends";
-	 Size += strlen(Args[n-1]);
-	 Args[n++] = "--force-remove-essential";
-	 Size += strlen(Args[n-1]);
-	 Args[n++] = "--purge";
-	 Size += strlen(Args[n-1]);
+	 ADDARGC("--force-depends");
+	 ADDARGC("--force-remove-essential");
+	 ADDARGC("--purge");
 	 break;
 	 break;
 	 
 	 
 	 case Item::Configure:
 	 case Item::Configure:
-	 Args[n++] = "--configure";
-	 Size += strlen(Args[n-1]);
+	 ADDARGC("--configure");
 	 break;
 	 break;
 
 
 	 case Item::ConfigurePending:
 	 case Item::ConfigurePending:
-	 Args[n++] = "--configure";
-	 Size += strlen(Args[n-1]);
-	 Args[n++] = "--pending";
-	 Size += strlen(Args[n-1]);
+	 ADDARGC("--configure");
+	 ADDARGC("--pending");
 	 break;
 	 break;
 
 
 	 case Item::TriggersPending:
 	 case Item::TriggersPending:
-	 Args[n++] = "--triggers-only";
-	 Size += strlen(Args[n-1]);
-	 Args[n++] = "--pending";
-	 Size += strlen(Args[n-1]);
+	 ADDARGC("--triggers-only");
+	 ADDARGC("--pending");
 	 break;
 	 break;
 
 
 	 case Item::Install:
 	 case Item::Install:
-	 Args[n++] = "--unpack";
-	 Size += strlen(Args[n-1]);
-	 Args[n++] = "--auto-deconfigure";
-	 Size += strlen(Args[n-1]);
+	 ADDARGC("--unpack");
+	 ADDARGC("--auto-deconfigure");
 	 break;
 	 break;
       }
       }
 
 
       if (NoTriggers == true && I->Op != Item::TriggersPending &&
       if (NoTriggers == true && I->Op != Item::TriggersPending &&
 	  I->Op != Item::ConfigurePending)
 	  I->Op != Item::ConfigurePending)
       {
       {
-	 Args[n++] = "--no-triggers";
-	 Size += strlen(Args[n-1]);
+	 ADDARGC("--no-triggers");
       }
       }
+#undef ADDARGC
 
 
       // Write in the file or package names
       // Write in the file or package names
       if (I->Op == Item::Install)
       if (I->Op == Item::Install)
       {
       {
-	 for (;I != J && Size < MaxArgBytes; I++)
+	 for (;I != J && Size < MaxArgBytes; ++I)
 	 {
 	 {
 	    if (I->File[0] != '/')
 	    if (I->File[0] != '/')
 	       return _error->Error("Internal Error, Pathname to install is not absolute '%s'",I->File.c_str());
 	       return _error->Error("Internal Error, Pathname to install is not absolute '%s'",I->File.c_str());
-	    Args[n++] = I->File.c_str();
-	    Size += strlen(Args[n-1]);
+	    Args.push_back(I->File.c_str());
+	    Size += I->File.length();
 	 }
 	 }
-      }      
+      }
       else
       else
       {
       {
 	 string const nativeArch = _config->Find("APT::Architecture");
 	 string const nativeArch = _config->Find("APT::Architecture");
 	 unsigned long const oldSize = I->Op == Item::Configure ? Size : 0;
 	 unsigned long const oldSize = I->Op == Item::Configure ? Size : 0;
-	 for (;I != J && Size < MaxArgBytes; I++)
+	 for (;I != J && Size < MaxArgBytes; ++I)
 	 {
 	 {
 	    if((*I).Pkg.end() == true)
 	    if((*I).Pkg.end() == true)
 	       continue;
 	       continue;
 	    if (I->Op == Item::Configure && disappearedPkgs.find(I->Pkg.Name()) != disappearedPkgs.end())
 	    if (I->Op == Item::Configure && disappearedPkgs.find(I->Pkg.Name()) != disappearedPkgs.end())
 	       continue;
 	       continue;
 	    if (I->Pkg.Arch() == nativeArch || !strcmp(I->Pkg.Arch(), "all"))
 	    if (I->Pkg.Arch() == nativeArch || !strcmp(I->Pkg.Arch(), "all"))
-	       Args[n++] = I->Pkg.Name();
+	    {
+	       char const * const name = I->Pkg.Name();
+	       ADDARG(name);
+	    }
 	    else
 	    else
 	    {
 	    {
-	       Packages[pkgcount] = strdup(I->Pkg.FullName(false).c_str());
-	       Args[n++] = Packages[pkgcount++];
+	       char * const fullname = strdup(I->Pkg.FullName(false).c_str());
+	       Packages.push_back(fullname);
+	       ADDARG(fullname);
 	    }
 	    }
-	    Size += strlen(Args[n-1]);
 	 }
 	 }
 	 // skip configure action if all sheduled packages disappeared
 	 // skip configure action if all sheduled packages disappeared
 	 if (oldSize == Size)
 	 if (oldSize == Size)
 	    continue;
 	    continue;
       }
       }
-      Args[n] = 0;
+#undef ADDARG
+
       J = I;
       J = I;
       
       
       if (_config->FindB("Debug::pkgDPkgPM",false) == true)
       if (_config->FindB("Debug::pkgDPkgPM",false) == true)
       {
       {
-	 for (unsigned int k = 0; k != n; k++)
-	    clog << Args[k] << ' ';
+	 for (std::vector<const char *>::const_iterator a = Args.begin();
+	      a != Args.end(); ++a)
+	    clog << *a << ' ';
 	 clog << endl;
 	 clog << endl;
 	 continue;
 	 continue;
       }
       }
-      
+      Args.push_back(NULL);
+
       cout << flush;
       cout << flush;
       clog << flush;
       clog << flush;
       cerr << flush;
       cerr << flush;
@@ -1078,8 +1086,13 @@ bool pkgDPkgPM::Go(int OutStatusFd)
 	 it to all processes in the group. Since dpkg ignores the signal 
 	 it to all processes in the group. Since dpkg ignores the signal 
 	 it doesn't die but we do! So we must also ignore it */
 	 it doesn't die but we do! So we must also ignore it */
       sighandler_t old_SIGQUIT = signal(SIGQUIT,SIG_IGN);
       sighandler_t old_SIGQUIT = signal(SIGQUIT,SIG_IGN);
-      sighandler_t old_SIGINT = signal(SIGINT,SIG_IGN);
-
+      sighandler_t old_SIGINT = signal(SIGINT,SigINT);
+      
+      // Check here for any SIGINT
+      if (pkgPackageManager::SigINTStop && (Op == Item::Remove || Op == Item::Purge || Op == Item::Install)) 
+         break;
+      
+      
       // ignore SIGHUP as well (debian #463030)
       // ignore SIGHUP as well (debian #463030)
       sighandler_t old_SIGHUP = signal(SIGHUP,SIG_IGN);
       sighandler_t old_SIGHUP = signal(SIGHUP,SIG_IGN);
 
 
@@ -1117,7 +1130,6 @@ bool pkgDPkgPM::Go(int OutStatusFd)
 	    sigprocmask(SIG_SETMASK, &original_sigmask, 0);
 	    sigprocmask(SIG_SETMASK, &original_sigmask, 0);
 	 }
 	 }
       }
       }
-
        // Fork dpkg
        // Fork dpkg
       pid_t Child;
       pid_t Child;
       _config->Set("APT::Keep-Fds::",fd[1]);
       _config->Set("APT::Keep-Fds::",fd[1]);
@@ -1178,7 +1190,7 @@ bool pkgDPkgPM::Go(int OutStatusFd)
 	 /* No Job Control Stop Env is a magic dpkg var that prevents it
 	 /* No Job Control Stop Env is a magic dpkg var that prevents it
 	    from using sigstop */
 	    from using sigstop */
 	 putenv((char *)"DPKG_NO_TSTP=yes");
 	 putenv((char *)"DPKG_NO_TSTP=yes");
-	 execvp(Args[0],(char **)Args);
+	 execvp(Args[0], (char**) &Args[0]);
 	 cerr << "Could not exec dpkg!" << endl;
 	 cerr << "Could not exec dpkg!" << endl;
 	 _exit(100);
 	 _exit(100);
       }      
       }      
@@ -1204,10 +1216,11 @@ bool pkgDPkgPM::Go(int OutStatusFd)
       sigemptyset(&sigmask);
       sigemptyset(&sigmask);
       sigprocmask(SIG_BLOCK,&sigmask,&original_sigmask);
       sigprocmask(SIG_BLOCK,&sigmask,&original_sigmask);
 
 
-      /* clean up the temporary allocation for multiarch package names in
-         the parent, so we don't leak memory when we return. */
-      for (unsigned int i = 0; i < pkgcount; i++)
-	 free(Packages[i]);
+      /* free vectors (and therefore memory) as we don't need the included data anymore */
+      for (std::vector<char *>::const_iterator p = Packages.begin();
+	   p != Packages.end(); ++p)
+	 free(*p);
+      Packages.clear();
 
 
       // the result of the waitpid call
       // the result of the waitpid call
       int res;
       int res;
@@ -1223,6 +1236,7 @@ bool pkgDPkgPM::Go(int OutStatusFd)
 	    // Restore sig int/quit
 	    // Restore sig int/quit
 	    signal(SIGQUIT,old_SIGQUIT);
 	    signal(SIGQUIT,old_SIGQUIT);
 	    signal(SIGINT,old_SIGINT);
 	    signal(SIGINT,old_SIGINT);
+
 	    signal(SIGHUP,old_SIGHUP);
 	    signal(SIGHUP,old_SIGHUP);
 	    return _error->Errno("waitpid","Couldn't wait for subprocess");
 	    return _error->Errno("waitpid","Couldn't wait for subprocess");
 	 }
 	 }
@@ -1263,6 +1277,7 @@ bool pkgDPkgPM::Go(int OutStatusFd)
       // Restore sig int/quit
       // Restore sig int/quit
       signal(SIGQUIT,old_SIGQUIT);
       signal(SIGQUIT,old_SIGQUIT);
       signal(SIGINT,old_SIGINT);
       signal(SIGINT,old_SIGINT);
+      
       signal(SIGHUP,old_SIGHUP);
       signal(SIGHUP,old_SIGHUP);
 
 
       if(master >= 0) 
       if(master >= 0) 
@@ -1300,6 +1315,9 @@ bool pkgDPkgPM::Go(int OutStatusFd)
       }      
       }      
    }
    }
    CloseLog();
    CloseLog();
+   
+   if (pkgPackageManager::SigINTStop)
+       _error->Warning(_("Operation was interrupted before it could finish"));
 
 
    if (RunScripts("DPkg::Post-Invoke") == false)
    if (RunScripts("DPkg::Post-Invoke") == false)
       return false;
       return false;
@@ -1324,6 +1342,11 @@ bool pkgDPkgPM::Go(int OutStatusFd)
    Cache.writeStateFile(NULL);
    Cache.writeStateFile(NULL);
    return true;
    return true;
 }
 }
+
+void SigINT(int sig) {
+   if (_config->FindB("APT::Immediate-Configure-All",false)) 
+      pkgPackageManager::SigINTStop = true;
+} 
 									/*}}}*/
 									/*}}}*/
 // pkgDpkgPM::Reset - Dump the contents of the command list		/*{{{*/
 // pkgDpkgPM::Reset - Dump the contents of the command list		/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
@@ -1477,7 +1500,7 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
    // log the ordering 
    // log the ordering 
    const char *ops_str[] = {"Install", "Configure","Remove","Purge"};
    const char *ops_str[] = {"Install", "Configure","Remove","Purge"};
    fprintf(report, "AptOrdering:\n");
    fprintf(report, "AptOrdering:\n");
-   for (vector<Item>::iterator I = List.begin(); I != List.end(); I++)
+   for (vector<Item>::iterator I = List.begin(); I != List.end(); ++I)
       fprintf(report, " %s: %s\n", (*I).Pkg.Name(), ops_str[(*I).Op]);
       fprintf(report, " %s: %s\n", (*I).Pkg.Name(), ops_str[(*I).Op]);
 
 
    // attach dmesg log (to learn about segfaults)
    // attach dmesg log (to learn about segfaults)

+ 10 - 11
apt-pkg/deb/dpkgpm.h

@@ -15,9 +15,6 @@
 #include <map>
 #include <map>
 #include <stdio.h>
 #include <stdio.h>
 
 
-using std::vector;
-using std::map;
-
 class pkgDPkgPMPrivate;
 class pkgDPkgPMPrivate;
 
 
 class pkgDPkgPM : public pkgPackageManager
 class pkgDPkgPM : public pkgPackageManager
@@ -38,7 +35,7 @@ class pkgDPkgPM : public pkgPackageManager
       needs to declare a Replaces on the disappeared package.
       needs to declare a Replaces on the disappeared package.
       \param pkgname Name of the package that disappeared
       \param pkgname Name of the package that disappeared
    */
    */
-   void handleDisappearAction(string const &pkgname);
+   void handleDisappearAction(std::string const &pkgname);
 
 
    protected:
    protected:
    int pkgFailures;
    int pkgFailures;
@@ -53,11 +50,11 @@ class pkgDPkgPM : public pkgPackageManager
    // the dpkg states that the pkg will run through, the string is 
    // the dpkg states that the pkg will run through, the string is 
    // the package, the vector contains the dpkg states that the package
    // the package, the vector contains the dpkg states that the package
    // will go through
    // will go through
-   map<string,vector<struct DpkgState> > PackageOps;
+   std::map<std::string,std::vector<struct DpkgState> > PackageOps;
    // the dpkg states that are already done; the string is the package
    // the dpkg states that are already done; the string is the package
    // the int is the state that is already done (e.g. a package that is
    // the int is the state that is already done (e.g. a package that is
    // going to be install is already in state "half-installed")
    // going to be install is already in state "half-installed")
-   map<string,unsigned int> PackageOpsDone;
+   std::map<std::string,unsigned int> PackageOpsDone;
 
 
    // progress reporting
    // progress reporting
    unsigned int PackagesDone;
    unsigned int PackagesDone;
@@ -66,19 +63,19 @@ class pkgDPkgPM : public pkgPackageManager
    struct Item
    struct Item
    {
    {
       enum Ops {Install, Configure, Remove, Purge, ConfigurePending, TriggersPending} Op;
       enum Ops {Install, Configure, Remove, Purge, ConfigurePending, TriggersPending} Op;
-      string File;
+      std::string File;
       PkgIterator Pkg;
       PkgIterator Pkg;
-      Item(Ops Op,PkgIterator Pkg,string File = "") : Op(Op),
+      Item(Ops Op,PkgIterator Pkg,std::string File = "") : Op(Op),
             File(File), Pkg(Pkg) {};
             File(File), Pkg(Pkg) {};
       Item() {};
       Item() {};
       
       
    };
    };
-   vector<Item> List;
+   std::vector<Item> List;
 
 
    // Helpers
    // Helpers
    bool RunScriptsWithPkgs(const char *Cnf);
    bool RunScriptsWithPkgs(const char *Cnf);
    bool SendV2Pkgs(FILE *F);
    bool SendV2Pkgs(FILE *F);
-   void WriteHistoryTag(string const &tag, string value);
+   void WriteHistoryTag(std::string const &tag, std::string value);
 
 
    // apport integration
    // apport integration
    void WriteApportReport(const char *pkgpath, const char *errormsg);
    void WriteApportReport(const char *pkgpath, const char *errormsg);
@@ -94,7 +91,7 @@ class pkgDPkgPM : public pkgPackageManager
    void ProcessDpkgStatusLine(int OutStatusFd, char *line);
    void ProcessDpkgStatusLine(int OutStatusFd, char *line);
 
 
    // The Actuall installation implementation
    // The Actuall installation implementation
-   virtual bool Install(PkgIterator Pkg,string File);
+   virtual bool Install(PkgIterator Pkg,std::string File);
    virtual bool Configure(PkgIterator Pkg);
    virtual bool Configure(PkgIterator Pkg);
    virtual bool Remove(PkgIterator Pkg,bool Purge = false);
    virtual bool Remove(PkgIterator Pkg,bool Purge = false);
    virtual bool Go(int StatusFd=-1);
    virtual bool Go(int StatusFd=-1);
@@ -106,4 +103,6 @@ class pkgDPkgPM : public pkgPackageManager
    virtual ~pkgDPkgPM();
    virtual ~pkgDPkgPM();
 };
 };
 
 
+void SigINT(int sig);
+
 #endif
 #endif

+ 24 - 19
apt-pkg/depcache.cc

@@ -8,28 +8,33 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include<config.h>
+
 #include <apt-pkg/depcache.h>
 #include <apt-pkg/depcache.h>
 #include <apt-pkg/version.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/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/pkgsystem.h>
 #include <apt-pkg/tagfile.h>
 #include <apt-pkg/tagfile.h>
+#include <apt-pkg/progress.h>
 
 
 #include <iostream>
 #include <iostream>
-#include <sstream>    
+#include <sstream>
 #include <set>
 #include <set>
 
 
 #include <sys/stat.h>
 #include <sys/stat.h>
 
 
-#include <apti18n.h>    
+#include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
+
+using std::string;
+
 // helper for Install-Recommends-Sections and Never-MarkAuto-Sections	/*{{{*/
 // helper for Install-Recommends-Sections and Never-MarkAuto-Sections	/*{{{*/
 static bool 
 static bool 
 ConfigValueInSubTree(const char* SubTree, const char *needle)
 ConfigValueInSubTree(const char* SubTree, const char *needle)
@@ -129,7 +134,7 @@ bool pkgDepCache::Init(OpProgress *Prog)
    /* Set the current state of everything. In this state all of the
    /* Set the current state of everything. In this state all of the
       packages are kept exactly as is. See AllUpgrade */
       packages are kept exactly as is. See AllUpgrade */
    int Done = 0;
    int Done = 0;
-   for (PkgIterator I = PkgBegin(); I.end() != true; I++,Done++)
+   for (PkgIterator I = PkgBegin(); I.end() != true; ++I, ++Done)
    {
    {
       if (Prog != 0 && Done%20 == 0)
       if (Prog != 0 && Done%20 == 0)
 	 Prog->Progress(Done);
 	 Prog->Progress(Done);
@@ -169,14 +174,14 @@ bool pkgDepCache::readStateFile(OpProgress *Prog)			/*{{{*/
    string const state = _config->FindFile("Dir::State::extended_states");
    string const state = _config->FindFile("Dir::State::extended_states");
    if(RealFileExists(state)) {
    if(RealFileExists(state)) {
       state_file.Open(state, FileFd::ReadOnly);
       state_file.Open(state, FileFd::ReadOnly);
-      int const file_size = state_file.Size();
+      off_t const file_size = state_file.Size();
       if(Prog != NULL)
       if(Prog != NULL)
 	 Prog->OverallProgress(0, file_size, 1, 
 	 Prog->OverallProgress(0, file_size, 1, 
 			       _("Reading state information"));
 			       _("Reading state information"));
 
 
       pkgTagFile tagfile(&state_file);
       pkgTagFile tagfile(&state_file);
       pkgTagSection section;
       pkgTagSection section;
-      int amt = 0;
+      off_t amt = 0;
       bool const debug_autoremove = _config->FindB("Debug::pkgAutoRemove",false);
       bool const debug_autoremove = _config->FindB("Debug::pkgAutoRemove",false);
       while(tagfile.Step(section)) {
       while(tagfile.Step(section)) {
 	 string const pkgname = section.FindS("Package");
 	 string const pkgname = section.FindS("Package");
@@ -292,7 +297,7 @@ bool pkgDepCache::writeStateFile(OpProgress *prog, bool InstalledOnly)	/*{{{*/
    
    
    // then write the ones we have not seen yet
    // then write the ones we have not seen yet
    std::ostringstream ostr;
    std::ostringstream ostr;
-   for(pkgCache::PkgIterator pkg=Cache->PkgBegin(); !pkg.end(); pkg++) {
+   for(pkgCache::PkgIterator pkg=Cache->PkgBegin(); !pkg.end(); ++pkg) {
       StateCache const &P = PkgState[pkg->ID];
       StateCache const &P = PkgState[pkg->ID];
       if(P.Flags & Flag::Auto) {
       if(P.Flags & Flag::Auto) {
 	 if (pkgs_seen.find(pkg.FullName()) != pkgs_seen.end()) {
 	 if (pkgs_seen.find(pkg.FullName()) != pkgs_seen.end()) {
@@ -365,7 +370,7 @@ bool pkgDepCache::CheckDep(DepIterator Dep,int Type,PkgIterator &Res)
    // Check the providing packages
    // Check the providing packages
    PrvIterator P = Dep.TargetPkg().ProvidesList();
    PrvIterator P = Dep.TargetPkg().ProvidesList();
    PkgIterator Pkg = Dep.ParentPkg();
    PkgIterator Pkg = Dep.ParentPkg();
-   for (; P.end() != true; P++)
+   for (; P.end() != true; ++P)
    {
    {
       /* Provides may never be applied against the same package (or group)
       /* Provides may never be applied against the same package (or group)
          if it is a conflicts. See the comment above. */
          if it is a conflicts. See the comment above. */
@@ -534,7 +539,7 @@ void pkgDepCache::BuildGroupOrs(VerIterator const &V)
 {
 {
    unsigned char Group = 0;
    unsigned char Group = 0;
    
    
-   for (DepIterator D = V.DependsList(); D.end() != true; D++)
+   for (DepIterator D = V.DependsList(); D.end() != true; ++D)
    {
    {
       // Build the dependency state.
       // Build the dependency state.
       unsigned char &State = DepState[D->ID];
       unsigned char &State = DepState[D->ID];
@@ -574,7 +579,7 @@ unsigned char pkgDepCache::VersionState(DepIterator D,unsigned char Check,
       // Compute a single dependency element (glob or)
       // Compute a single dependency element (glob or)
       DepIterator Start = D;
       DepIterator Start = D;
       unsigned char State = 0;
       unsigned char State = 0;
-      for (bool LastOR = true; D.end() == false && LastOR == true; D++)
+      for (bool LastOR = true; D.end() == false && LastOR == true; ++D)
       {
       {
 	 State |= DepState[D->ID];
 	 State |= DepState[D->ID];
 	 LastOR = (D->CompareOp & Dep::Or) == Dep::Or;
 	 LastOR = (D->CompareOp & Dep::Or) == Dep::Or;
@@ -664,15 +669,15 @@ void pkgDepCache::Update(OpProgress *Prog)
 
 
    // Perform the depends pass
    // Perform the depends pass
    int Done = 0;
    int Done = 0;
-   for (PkgIterator I = PkgBegin(); I.end() != true; I++,Done++)
+   for (PkgIterator I = PkgBegin(); I.end() != true; ++I, ++Done)
    {
    {
       if (Prog != 0 && Done%20 == 0)
       if (Prog != 0 && Done%20 == 0)
 	 Prog->Progress(Done);
 	 Prog->Progress(Done);
-      for (VerIterator V = I.VersionList(); V.end() != true; V++)
+      for (VerIterator V = I.VersionList(); V.end() != true; ++V)
       {
       {
 	 unsigned char Group = 0;
 	 unsigned char Group = 0;
 
 
-	 for (DepIterator D = V.DependsList(); D.end() != true; D++)
+	 for (DepIterator D = V.DependsList(); D.end() != true; ++D)
 	 {
 	 {
 	    // Build the dependency state.
 	    // Build the dependency state.
 	    unsigned char &State = DepState[D->ID];
 	    unsigned char &State = DepState[D->ID];
@@ -709,7 +714,7 @@ void pkgDepCache::Update(OpProgress *Prog)
 void pkgDepCache::Update(DepIterator D)
 void pkgDepCache::Update(DepIterator D)
 {
 {
    // Update the reverse deps
    // Update the reverse deps
-   for (;D.end() != true; D++)
+   for (;D.end() != true; ++D)
    {      
    {      
       unsigned char &State = DepState[D->ID];
       unsigned char &State = DepState[D->ID];
       State = DependencyState(D);
       State = DependencyState(D);
@@ -742,13 +747,13 @@ void pkgDepCache::Update(PkgIterator const &Pkg)
    // Update the provides map for the current ver
    // Update the provides map for the current ver
    if (Pkg->CurrentVer != 0)
    if (Pkg->CurrentVer != 0)
       for (PrvIterator P = Pkg.CurrentVer().ProvidesList(); 
       for (PrvIterator P = Pkg.CurrentVer().ProvidesList(); 
-	   P.end() != true; P++)
+	   P.end() != true; ++P)
 	 Update(P.ParentPkg().RevDependsList());
 	 Update(P.ParentPkg().RevDependsList());
 
 
    // Update the provides map for the candidate ver
    // Update the provides map for the candidate ver
    if (PkgState[Pkg->ID].CandidateVer != 0)
    if (PkgState[Pkg->ID].CandidateVer != 0)
       for (PrvIterator P = PkgState[Pkg->ID].CandidateVerIter(*this).ProvidesList();
       for (PrvIterator P = PkgState[Pkg->ID].CandidateVerIter(*this).ProvidesList();
-	   P.end() != true; P++)
+	   P.end() != true; ++P)
 	 Update(P.ParentPkg().RevDependsList());
 	 Update(P.ParentPkg().RevDependsList());
 }
 }
 									/*}}}*/
 									/*}}}*/
@@ -1009,7 +1014,7 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
       DepIterator Start = Dep;
       DepIterator Start = Dep;
       bool Result = true;
       bool Result = true;
       unsigned Ors = 0;
       unsigned Ors = 0;
-      for (bool LastOR = true; Dep.end() == false && LastOR == true; Dep++,Ors++)
+      for (bool LastOR = true; Dep.end() == false && LastOR == true; ++Dep, ++Ors)
       {
       {
 	 LastOR = (Dep->CompareOp & Dep::Or) == Dep::Or;
 	 LastOR = (Dep->CompareOp & Dep::Or) == Dep::Or;
 
 
@@ -1475,12 +1480,12 @@ pkgCache::VerIterator pkgDepCache::Policy::GetCandidateVer(PkgIterator const &Pk
       unless they are already installed */
       unless they are already installed */
    VerIterator Last(*(pkgCache *)this,0);
    VerIterator Last(*(pkgCache *)this,0);
    
    
-   for (VerIterator I = Pkg.VersionList(); I.end() == false; I++)
+   for (VerIterator I = Pkg.VersionList(); I.end() == false; ++I)
    {
    {
       if (Pkg.CurrentVer() == I)
       if (Pkg.CurrentVer() == I)
 	 return I;
 	 return I;
       
       
-      for (VerFileIterator J = I.FileList(); J.end() == false; J++)
+      for (VerFileIterator J = I.FileList(); J.end() == false; ++J)
       {
       {
 	 if ((J.File()->Flags & Flag::NotSource) != 0)
 	 if ((J.File()->Flags & Flag::NotSource) != 0)
 	    continue;
 	    continue;

+ 8 - 7
apt-pkg/depcache.h

@@ -40,12 +40,13 @@
 
 
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/pkgcache.h>
 #include <apt-pkg/pkgcache.h>
-#include <apt-pkg/progress.h>
-#include <apt-pkg/error.h>
 
 
 #include <vector>
 #include <vector>
 #include <memory>
 #include <memory>
 #include <set>
 #include <set>
+#include <list>
+
+class OpProgress;
 
 
 class pkgDepCache : protected pkgCache::Namespace
 class pkgDepCache : protected pkgCache::Namespace
 {
 {
@@ -338,9 +339,9 @@ class pkgDepCache : protected pkgCache::Namespace
    inline Header &Head() {return *Cache->HeaderP;};
    inline Header &Head() {return *Cache->HeaderP;};
    inline GrpIterator GrpBegin() {return Cache->GrpBegin();};
    inline GrpIterator GrpBegin() {return Cache->GrpBegin();};
    inline PkgIterator PkgBegin() {return Cache->PkgBegin();};
    inline PkgIterator PkgBegin() {return Cache->PkgBegin();};
-   inline GrpIterator FindGrp(string const &Name) {return Cache->FindGrp(Name);};
-   inline PkgIterator FindPkg(string const &Name) {return Cache->FindPkg(Name);};
-   inline PkgIterator FindPkg(string const &Name, string const &Arch) {return Cache->FindPkg(Name, Arch);};
+   inline GrpIterator FindGrp(std::string const &Name) {return Cache->FindGrp(Name);};
+   inline PkgIterator FindPkg(std::string const &Name) {return Cache->FindPkg(Name);};
+   inline PkgIterator FindPkg(std::string const &Name, std::string const &Arch) {return Cache->FindPkg(Name, Arch);};
 
 
    inline pkgCache &GetCache() {return *Cache;};
    inline pkgCache &GetCache() {return *Cache;};
    inline pkgVersioningSystem &VS() {return *Cache->VS;};
    inline pkgVersioningSystem &VS() {return *Cache->VS;};
@@ -400,7 +401,7 @@ class pkgDepCache : protected pkgCache::Namespace
    // @{
    // @{
    bool MarkKeep(PkgIterator const &Pkg, bool Soft = false,
    bool MarkKeep(PkgIterator const &Pkg, bool Soft = false,
 		 bool FromUser = true, unsigned long Depth = 0);
 		 bool FromUser = true, unsigned long Depth = 0);
-   bool MarkDelete(PkgIterator const &Pkg, bool Purge = false,
+   bool MarkDelete(PkgIterator const &Pkg, bool MarkPurge = false,
                    unsigned long Depth = 0, bool FromUser = true);
                    unsigned long Depth = 0, bool FromUser = true);
    bool MarkInstall(PkgIterator const &Pkg,bool AutoInst = true,
    bool MarkInstall(PkgIterator const &Pkg,bool AutoInst = true,
 		    unsigned long Depth = 0, bool FromUser = true,
 		    unsigned long Depth = 0, bool FromUser = true,
@@ -468,7 +469,7 @@ class pkgDepCache : protected pkgCache::Namespace
     *  \param Depth     recursive deep of this Marker call
     *  \param Depth     recursive deep of this Marker call
     *  \param FromUser  was the remove requested by the user?
     *  \param FromUser  was the remove requested by the user?
     */
     */
-   virtual bool IsDeleteOk(const PkgIterator &Pkg,bool Purge = false,
+   virtual bool IsDeleteOk(const PkgIterator &Pkg,bool MarkPurge = false,
 			    unsigned long Depth = 0, bool FromUser = true);
 			    unsigned long Depth = 0, bool FromUser = true);
 
 
    // read persistent states
    // read persistent states

+ 12 - 3
apt-pkg/edsp.cc

@@ -5,19 +5,28 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include <config.h>
+
 #include <apt-pkg/edsp.h>
 #include <apt-pkg/edsp.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
+#include <apt-pkg/cacheset.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/version.h>
 #include <apt-pkg/version.h>
 #include <apt-pkg/policy.h>
 #include <apt-pkg/policy.h>
 #include <apt-pkg/tagfile.h>
 #include <apt-pkg/tagfile.h>
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/progress.h>
 
 
-#include <apti18n.h>
 #include <limits>
 #include <limits>
-
 #include <stdio.h>
 #include <stdio.h>
+
+#include <string>
+
+#include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
 
 
+using std::string;
+
 // we could use pkgCache::DepType and ::Priority, but these would be localized strings…
 // we could use pkgCache::DepType and ::Priority, but these would be localized strings…
 const char * const EDSP::PrioMap[] = {0, "important", "required", "standard",
 const char * const EDSP::PrioMap[] = {0, "important", "required", "standard",
 				      "optional", "extra"};
 				      "optional", "extra"};
@@ -277,7 +286,7 @@ bool EDSP::ReadResponse(int const input, pkgDepCache &Cache, OpProgress *Progres
 			std::string msg = SubstVar(SubstVar(section.FindS("Message"), "\n .\n", "\n\n"), "\n ", "\n");
 			std::string msg = SubstVar(SubstVar(section.FindS("Message"), "\n .\n", "\n\n"), "\n ", "\n");
 			if (msg.empty() == true) {
 			if (msg.empty() == true) {
 				msg = _("External solver failed without a proper error message");
 				msg = _("External solver failed without a proper error message");
-				_error->Error(msg.c_str());
+				_error->Error("%s", msg.c_str());
 			} else
 			} else
 				_error->Error("External solver failed with: %s", msg.substr(0,msg.find('\n')).c_str());
 				_error->Error("External solver failed with: %s", msg.substr(0,msg.find('\n')).c_str());
 			if (Progress != NULL)
 			if (Progress != NULL)

+ 8 - 3
apt-pkg/edsp.h

@@ -9,12 +9,17 @@
 #ifndef PKGLIB_EDSP_H
 #ifndef PKGLIB_EDSP_H
 #define PKGLIB_EDSP_H
 #define PKGLIB_EDSP_H
 
 
-#include <apt-pkg/depcache.h>
-#include <apt-pkg/cacheset.h>
-#include <apt-pkg/progress.h>
+#include <apt-pkg/pkgcache.h>
 
 
+#include <list>
 #include <string>
 #include <string>
 
 
+namespace APT {
+	class PackageSet;
+};
+class pkgDepCache;
+class OpProgress;
+
 class EDSP								/*{{{*/
 class EDSP								/*{{{*/
 {
 {
 	// we could use pkgCache::DepType and ::Priority, but these would be localized strings…
 	// we could use pkgCache::DepType and ::Priority, but these would be localized strings…

+ 3 - 0
apt-pkg/edsp/edspindexfile.cc

@@ -6,6 +6,8 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include <config.h>
+
 #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/sourcelist.h>
@@ -13,6 +15,7 @@
 #include <apt-pkg/progress.h>
 #include <apt-pkg/progress.h>
 #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/acquire-item.h>
 #include <apt-pkg/acquire-item.h>
 
 
 #include <sys/stat.h>
 #include <sys/stat.h>

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

@@ -8,7 +8,6 @@
 #ifndef PKGLIB_EDSPINDEXFILE_H
 #ifndef PKGLIB_EDSPINDEXFILE_H
 #define PKGLIB_EDSPINDEXFILE_H
 #define PKGLIB_EDSPINDEXFILE_H
 
 
-#include <apt-pkg/indexfile.h>
 #include <apt-pkg/debindexfile.h>
 #include <apt-pkg/debindexfile.h>
 
 
 class edspIndex : public debStatusIndex
 class edspIndex : public debStatusIndex
@@ -22,7 +21,7 @@ class edspIndex : public debStatusIndex
 
 
    virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
    virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
 
 
-   edspIndex(string File);
+   edspIndex(std::string File);
 };
 };
 
 
 #endif
 #endif

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

@@ -9,6 +9,8 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include <config.h>
+
 #include <apt-pkg/edsplistparser.h>
 #include <apt-pkg/edsplistparser.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
@@ -18,7 +20,7 @@
 									/*}}}*/
 									/*}}}*/
 
 
 // ListParser::edspListParser - Constructor				/*{{{*/
 // ListParser::edspListParser - Constructor				/*{{{*/
-edspListParser::edspListParser(FileFd *File, string const &Arch) : debListParser(File, Arch)
+edspListParser::edspListParser(FileFd *File, std::string const &Arch) : debListParser(File, Arch)
 {}
 {}
 									/*}}}*/
 									/*}}}*/
 // ListParser::NewVersion - Fill in the version structure		/*{{{*/
 // ListParser::NewVersion - Fill in the version structure		/*{{{*/
@@ -31,11 +33,11 @@ bool edspListParser::NewVersion(pkgCache::VerIterator &Ver)
 // ListParser::Description - Return the description string		/*{{{*/
 // ListParser::Description - Return the description string		/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* Sorry, no description for the resolvers… */
 /* Sorry, no description for the resolvers… */
-string edspListParser::Description()
+std::string edspListParser::Description()
 {
 {
    return "";
    return "";
 }
 }
-string edspListParser::DescriptionLanguage()
+std::string edspListParser::DescriptionLanguage()
 {
 {
    return "";
    return "";
 }
 }
@@ -83,7 +85,7 @@ bool edspListParser::ParseStatus(pkgCache::PkgIterator &Pkg,
 									/*}}}*/
 									/*}}}*/
 // ListParser::LoadReleaseInfo - Load the release information		/*{{{*/
 // ListParser::LoadReleaseInfo - Load the release information		/*{{{*/
 bool edspListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
 bool edspListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
-				    FileFd &File, string component)
+				    FileFd &File, std::string component)
 {
 {
    return true;
    return true;
 }
 }

+ 6 - 7
apt-pkg/edsp/edsplistparser.h

@@ -12,23 +12,22 @@
 #define PKGLIB_EDSPLISTPARSER_H
 #define PKGLIB_EDSPLISTPARSER_H
 
 
 #include <apt-pkg/deblistparser.h>
 #include <apt-pkg/deblistparser.h>
-#include <apt-pkg/pkgcachegen.h>
-#include <apt-pkg/indexfile.h>
-#include <apt-pkg/tagfile.h>
+
+class FileFd;
 
 
 class edspListParser : public debListParser
 class edspListParser : public debListParser
 {
 {
    public:
    public:
    virtual bool NewVersion(pkgCache::VerIterator &Ver);
    virtual bool NewVersion(pkgCache::VerIterator &Ver);
-   virtual string Description();
-   virtual string DescriptionLanguage();
+   virtual std::string Description();
+   virtual std::string DescriptionLanguage();
    virtual MD5SumValue Description_md5();
    virtual MD5SumValue Description_md5();
    virtual unsigned short VersionHash();
    virtual unsigned short VersionHash();
 
 
    bool LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,FileFd &File,
    bool LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,FileFd &File,
-			string section);
+			std::string section);
 
 
-   edspListParser(FileFd *File, string const &Arch = "");
+   edspListParser(FileFd *File, std::string const &Arch = "");
 
 
    protected:
    protected:
    virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver);
    virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver);

+ 5 - 2
apt-pkg/edsp/edspsystem.cc

@@ -9,17 +9,20 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include <config.h>
+
 #include <apt-pkg/edspsystem.h>
 #include <apt-pkg/edspsystem.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/configuration.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
-#include <apti18n.h>
 #include <sys/types.h>
 #include <sys/types.h>
 #include <unistd.h>
 #include <unistd.h>
 #include <dirent.h>
 #include <dirent.h>
 #include <errno.h>
 #include <errno.h>
+
+#include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
 
 
 edspSystem edspSys;
 edspSystem edspSys;
@@ -94,7 +97,7 @@ signed edspSystem::Score(Configuration const &Cnf)
 }
 }
 									/*}}}*/
 									/*}}}*/
 // System::AddStatusFiles - Register the status files			/*{{{*/
 // System::AddStatusFiles - Register the status files			/*{{{*/
-bool edspSystem::AddStatusFiles(vector<pkgIndexFile *> &List)
+bool edspSystem::AddStatusFiles(std::vector<pkgIndexFile *> &List)
 {
 {
    if (StatusFile == 0)
    if (StatusFile == 0)
    {
    {

+ 26 - 24
apt-pkg/indexcopy.cc

@@ -10,7 +10,7 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
-#include "indexcopy.h"
+#include<config.h>
 
 
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/progress.h>
 #include <apt-pkg/progress.h>
@@ -21,7 +21,6 @@
 #include <apt-pkg/indexrecords.h>
 #include <apt-pkg/indexrecords.h>
 #include <apt-pkg/md5.h>
 #include <apt-pkg/md5.h>
 #include <apt-pkg/cdrom.h>
 #include <apt-pkg/cdrom.h>
-#include <apti18n.h>
 
 
 #include <iostream>
 #include <iostream>
 #include <sstream>
 #include <sstream>
@@ -30,6 +29,10 @@
 #include <sys/types.h>
 #include <sys/types.h>
 #include <fcntl.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdio.h>
+#include <stdlib.h>
+
+#include "indexcopy.h"
+#include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
 
 
 using namespace std;
 using namespace std;
@@ -43,7 +46,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List,
 			     pkgCdromStatus *log)
 			     pkgCdromStatus *log)
 {
 {
    OpProgress *Progress = NULL;
    OpProgress *Progress = NULL;
-   if (List.size() == 0)
+   if (List.empty() == true)
       return true;
       return true;
    
    
    if(log) 
    if(log) 
@@ -53,8 +56,8 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List,
    bool Debug = _config->FindB("Debug::aptcdrom",false);
    bool Debug = _config->FindB("Debug::aptcdrom",false);
    
    
    // Prepare the progress indicator
    // Prepare the progress indicator
-   unsigned long TotalSize = 0;
-   for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+   off_t TotalSize = 0;
+   for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
    {
    {
       struct stat Buf;
       struct stat Buf;
       if (stat(string(*I + GetFileName()).c_str(),&Buf) != 0 &&
       if (stat(string(*I + GetFileName()).c_str(),&Buf) != 0 &&
@@ -64,14 +67,14 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List,
       TotalSize += Buf.st_size;
       TotalSize += Buf.st_size;
    }	
    }	
 
 
-   unsigned long CurrentSize = 0;
+   off_t CurrentSize = 0;
    unsigned int NotFound = 0;
    unsigned int NotFound = 0;
    unsigned int WrongSize = 0;
    unsigned int WrongSize = 0;
    unsigned int Packages = 0;
    unsigned int Packages = 0;
-   for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+   for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
    {      
    {      
       string OrigPath = string(*I,CDROM.length());
       string OrigPath = string(*I,CDROM.length());
-      unsigned long FileSize = 0;
+      off_t FileSize = 0;
       
       
       // Open the package file
       // Open the package file
       FileFd Pkg;
       FileFd Pkg;
@@ -164,7 +167,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List,
 	 if(Progress)
 	 if(Progress)
 	    Progress->Progress(Parser.Offset());
 	    Progress->Progress(Parser.Offset());
 	 string File;
 	 string File;
-	 unsigned long Size;
+	 unsigned long long Size;
 	 if (GetFile(File,Size) == false)
 	 if (GetFile(File,Size) == false)
 	 {
 	 {
 	    fclose(TargetFl);
 	    fclose(TargetFl);
@@ -219,7 +222,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List,
 	    }	    
 	    }	    
 	    			    	    
 	    			    	    
 	    // Size match
 	    // Size match
-	    if ((unsigned)Buf.st_size != Size)
+	    if ((unsigned long long)Buf.st_size != Size)
 	    {
 	    {
 	       if (Debug == true)
 	       if (Debug == true)
 		  clog << "Wrong Size: " << File << endl;
 		  clog << "Wrong Size: " << File << endl;
@@ -453,7 +456,7 @@ bool IndexCopy::GrabFirst(string Path,string &To,unsigned int Depth)
 // PackageCopy::GetFile - Get the file information from the section	/*{{{*/
 // PackageCopy::GetFile - Get the file information from the section	/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-bool PackageCopy::GetFile(string &File,unsigned long &Size)
+bool PackageCopy::GetFile(string &File,unsigned long long &Size)
 {
 {
    File = Section->FindS("Filename");
    File = Section->FindS("Filename");
    Size = Section->FindI("Size");
    Size = Section->FindI("Size");
@@ -479,7 +482,7 @@ bool PackageCopy::RewriteEntry(FILE *Target,string File)
 // SourceCopy::GetFile - Get the file information from the section	/*{{{*/
 // SourceCopy::GetFile - Get the file information from the section	/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-bool SourceCopy::GetFile(string &File,unsigned long &Size)
+bool SourceCopy::GetFile(string &File,unsigned long long &Size)
 {
 {
    string Files = Section->FindS("Files");
    string Files = Section->FindS("Files");
    if (Files.empty() == true)
    if (Files.empty() == true)
@@ -502,7 +505,7 @@ bool SourceCopy::GetFile(string &File,unsigned long &Size)
       return _error->Error("Error parsing file record");
       return _error->Error("Error parsing file record");
    
    
    // Parse the size and append the directory
    // Parse the size and append the directory
-   Size = atoi(sSize.c_str());
+   Size = strtoull(sSize.c_str(), NULL, 10);
    File = Base + File;
    File = Base + File;
    return true;
    return true;
 }
 }
@@ -583,13 +586,13 @@ 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.size() == 0)
+   if (SigList.empty() == true)
       return true;
       return true;
 
 
    bool Debug = _config->FindB("Debug::aptcdrom",false);
    bool Debug = _config->FindB("Debug::aptcdrom",false);
 
 
    // Read all Release files
    // Read all Release files
-   for (vector<string>::iterator I = SigList.begin(); I != SigList.end(); I++)
+   for (vector<string>::iterator I = SigList.begin(); I != SigList.end(); ++I)
    { 
    { 
       if(Debug)
       if(Debug)
 	 cout << "Signature verify for: " << *I << endl;
 	 cout << "Signature verify for: " << *I << endl;
@@ -633,7 +636,7 @@ bool SigVerify::CopyAndVerify(string CDROM,string Name,vector<string> &SigList,
       // go over the Indexfiles and see if they verify
       // go over the Indexfiles and see if they verify
       // if so, remove them from our copy of the lists
       // if so, remove them from our copy of the lists
       vector<string> keys = MetaIndex->MetaKeys();
       vector<string> keys = MetaIndex->MetaKeys();
-      for (vector<string>::iterator I = keys.begin(); I != keys.end(); I++)
+      for (vector<string>::iterator I = keys.begin(); I != keys.end(); ++I)
       { 
       { 
 	 if(!Verify(prefix,*I, MetaIndex)) {
 	 if(!Verify(prefix,*I, MetaIndex)) {
 	    // something went wrong, don't copy the Release.gpg
 	    // something went wrong, don't copy the Release.gpg
@@ -776,7 +779,7 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name,	/*{{{*/
 				vector<string> &List, pkgCdromStatus *log)
 				vector<string> &List, pkgCdromStatus *log)
 {
 {
    OpProgress *Progress = NULL;
    OpProgress *Progress = NULL;
-   if (List.size() == 0)
+   if (List.empty() == true)
       return true;
       return true;
    
    
    if(log) 
    if(log) 
@@ -785,8 +788,8 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name,	/*{{{*/
    bool Debug = _config->FindB("Debug::aptcdrom",false);
    bool Debug = _config->FindB("Debug::aptcdrom",false);
    
    
    // Prepare the progress indicator
    // Prepare the progress indicator
-   unsigned long TotalSize = 0;
-   for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+   off_t TotalSize = 0;
+   for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
    {
    {
       struct stat Buf;
       struct stat Buf;
       if (stat(string(*I).c_str(),&Buf) != 0 &&
       if (stat(string(*I).c_str(),&Buf) != 0 &&
@@ -796,14 +799,14 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name,	/*{{{*/
       TotalSize += Buf.st_size;
       TotalSize += Buf.st_size;
    }	
    }	
 
 
-   unsigned long CurrentSize = 0;
+   off_t CurrentSize = 0;
    unsigned int NotFound = 0;
    unsigned int NotFound = 0;
    unsigned int WrongSize = 0;
    unsigned int WrongSize = 0;
    unsigned int Packages = 0;
    unsigned int Packages = 0;
-   for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+   for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
    {      
    {      
       string OrigPath = string(*I,CDROM.length());
       string OrigPath = string(*I,CDROM.length());
-      unsigned long FileSize = 0;
+      off_t FileSize = 0;
       
       
       // Open the package file
       // Open the package file
       FileFd Pkg;
       FileFd Pkg;
@@ -885,7 +888,6 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name,	/*{{{*/
       this->Section = &Section;
       this->Section = &Section;
       string Prefix;
       string Prefix;
       unsigned long Hits = 0;
       unsigned long Hits = 0;
-      unsigned long Chop = 0;
       while (Parser.Step(Section) == true)
       while (Parser.Step(Section) == true)
       {
       {
 	 if(Progress)
 	 if(Progress)
@@ -903,7 +905,7 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name,	/*{{{*/
       fclose(TargetFl);
       fclose(TargetFl);
 
 
       if (Debug == true)
       if (Debug == true)
-	 cout << " Processed by using Prefix '" << Prefix << "' and chop " << Chop << endl;
+	 cout << " Processed by using Prefix '" << Prefix << "' and chop " << endl;
 	 
 	 
       if (_config->FindB("APT::CDROM::NoAct",false) == false)
       if (_config->FindB("APT::CDROM::NoAct",false) == false)
       {
       {

+ 19 - 22
apt-pkg/indexcopy.h

@@ -14,9 +14,6 @@
 #include <string>
 #include <string>
 #include <stdio.h>
 #include <stdio.h>
 
 
-using std::string;
-using std::vector;
-
 class pkgTagSection;
 class pkgTagSection;
 class FileFd;
 class FileFd;
 class indexRecords;
 class indexRecords;
@@ -31,20 +28,20 @@ class IndexCopy								/*{{{*/
    
    
    pkgTagSection *Section;
    pkgTagSection *Section;
    
    
-   string ChopDirs(string Path,unsigned int Depth);
-   bool ReconstructPrefix(string &Prefix,string OrigPath,string CD,
-			  string File);
-   bool ReconstructChop(unsigned long &Chop,string Dir,string File);
-   void ConvertToSourceList(string CD,string &Path);
-   bool GrabFirst(string Path,string &To,unsigned int Depth);
-   virtual bool GetFile(string &Filename,unsigned long &Size) = 0;
-   virtual bool RewriteEntry(FILE *Target,string File) = 0;
+   std::string ChopDirs(std::string Path,unsigned int Depth);
+   bool ReconstructPrefix(std::string &Prefix,std::string OrigPath,std::string CD,
+			  std::string File);
+   bool ReconstructChop(unsigned long &Chop,std::string Dir,std::string File);
+   void ConvertToSourceList(std::string CD,std::string &Path);
+   bool GrabFirst(std::string Path,std::string &To,unsigned int Depth);
+   virtual bool GetFile(std::string &Filename,unsigned long long &Size) = 0;
+   virtual bool RewriteEntry(FILE *Target,std::string File) = 0;
    virtual const char *GetFileName() = 0;
    virtual const char *GetFileName() = 0;
    virtual const char *Type() = 0;
    virtual const char *Type() = 0;
    
    
    public:
    public:
 
 
-   bool CopyPackages(string CDROM,string Name,vector<string> &List,
+   bool CopyPackages(std::string CDROM,std::string Name,std::vector<std::string> &List,
 		     pkgCdromStatus *log);
 		     pkgCdromStatus *log);
    virtual ~IndexCopy() {};
    virtual ~IndexCopy() {};
 };
 };
@@ -53,8 +50,8 @@ class PackageCopy : public IndexCopy					/*{{{*/
 {
 {
    protected:
    protected:
    
    
-   virtual bool GetFile(string &Filename,unsigned long &Size);
-   virtual bool RewriteEntry(FILE *Target,string File);
+   virtual bool GetFile(std::string &Filename,unsigned long long &Size);
+   virtual bool RewriteEntry(FILE *Target,std::string File);
    virtual const char *GetFileName() {return "Packages";};
    virtual const char *GetFileName() {return "Packages";};
    virtual const char *Type() {return "Package";};
    virtual const char *Type() {return "Package";};
    
    
@@ -64,8 +61,8 @@ class SourceCopy : public IndexCopy					/*{{{*/
 {
 {
    protected:
    protected:
    
    
-   virtual bool GetFile(string &Filename,unsigned long &Size);
-   virtual bool RewriteEntry(FILE *Target,string File);
+   virtual bool GetFile(std::string &Filename,unsigned long long &Size);
+   virtual bool RewriteEntry(FILE *Target,std::string File);
    virtual const char *GetFileName() {return "Sources";};
    virtual const char *GetFileName() {return "Sources";};
    virtual const char *Type() {return "Source";};
    virtual const char *Type() {return "Source";};
    
    
@@ -77,7 +74,7 @@ class TranslationsCopy							/*{{{*/
    pkgTagSection *Section;
    pkgTagSection *Section;
 
 
    public:
    public:
-   bool CopyTranslations(string CDROM,string Name,vector<string> &List,
+   bool CopyTranslations(std::string CDROM,std::string Name,std::vector<std::string> &List,
 			 pkgCdromStatus *log);
 			 pkgCdromStatus *log);
 };
 };
 									/*}}}*/
 									/*}}}*/
@@ -86,13 +83,13 @@ class SigVerify								/*{{{*/
    /** \brief dpointer placeholder (for later in case we need it) */
    /** \brief dpointer placeholder (for later in case we need it) */
    void *d;
    void *d;
 
 
-   bool Verify(string prefix,string file, indexRecords *records);
-   bool CopyMetaIndex(string CDROM, string CDName, 
-		      string prefix, string file);
+   bool Verify(std::string prefix,std::string file, indexRecords *records);
+   bool CopyMetaIndex(std::string CDROM, std::string CDName, 
+		      std::string prefix, std::string file);
 
 
  public:
  public:
-   bool CopyAndVerify(string CDROM,string Name,vector<string> &SigList,
-		      vector<string> PkgList,vector<string> SrcList);
+   bool CopyAndVerify(std::string CDROM,std::string Name,std::vector<std::string> &SigList,
+		      std::vector<std::string> PkgList,std::vector<std::string> SrcList);
 
 
    /** \brief generates and run the command to verify a file with gpgv */
    /** \brief generates and run the command to verify a file with gpgv */
    static bool RunGPGV(std::string const &File, std::string const &FileOut,
    static bool RunGPGV(std::string const &File, std::string const &FileOut,

+ 9 - 6
apt-pkg/indexfile.cc

@@ -8,6 +8,8 @@
    ##################################################################### */
    ##################################################################### */
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include<config.h>
+
 #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>
@@ -27,7 +29,8 @@ unsigned long pkgIndexFile::Type::GlobalListLen = 0;
 pkgIndexFile::Type::Type()
 pkgIndexFile::Type::Type()
 {
 {
    ItmList[GlobalListLen] = this;
    ItmList[GlobalListLen] = this;
-   GlobalListLen++;   
+   GlobalListLen++;
+   Label = NULL;
 }
 }
 									/*}}}*/
 									/*}}}*/
 // Type::GetType - Locate the type by name				/*{{{*/
 // Type::GetType - Locate the type by name				/*{{{*/
@@ -44,9 +47,9 @@ pkgIndexFile::Type *pkgIndexFile::Type::GetType(const char *Type)
 // IndexFile::ArchiveInfo - Stub					/*{{{*/
 // IndexFile::ArchiveInfo - Stub					/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-string pkgIndexFile::ArchiveInfo(pkgCache::VerIterator Ver) const
+std::string pkgIndexFile::ArchiveInfo(pkgCache::VerIterator Ver) const
 {
 {
-   return string();
+   return std::string();
 }
 }
 									/*}}}*/
 									/*}}}*/
 // IndexFile::FindInCache - Stub					/*{{{*/
 // IndexFile::FindInCache - Stub					/*{{{*/
@@ -60,10 +63,10 @@ pkgCache::PkgFileIterator pkgIndexFile::FindInCache(pkgCache &Cache) const
 // IndexFile::SourceIndex - Stub					/*{{{*/
 // IndexFile::SourceIndex - Stub					/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-string pkgIndexFile::SourceInfo(pkgSrcRecords::Parser const &Record,
+std::string pkgIndexFile::SourceInfo(pkgSrcRecords::Parser const &Record,
 				pkgSrcRecords::File const &File) const
 				pkgSrcRecords::File const &File) const
 {
 {
-   return string();
+   return std::string();
 }
 }
 									/*}}}*/
 									/*}}}*/
 // IndexFile::TranslationsAvailable - Check if will use Translation	/*{{{*/
 // IndexFile::TranslationsAvailable - Check if will use Translation	/*{{{*/
@@ -95,7 +98,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)) string pkgIndexFile::LanguageCode() {
+__attribute__ ((deprecated)) std::string pkgIndexFile::LanguageCode() {
 	if (TranslationsAvailable() == false)
 	if (TranslationsAvailable() == false)
 		return "";
 		return "";
 	return APT::Configuration::getLanguages()[0];
 	return APT::Configuration::getLanguages()[0];

+ 7 - 7
apt-pkg/indexfile.h

@@ -27,12 +27,12 @@
 #include <apt-pkg/pkgcache.h>
 #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>
-    
-using std::string;
+#include <apt-pkg/macros.h>
 
 
 class pkgAcquire;
 class pkgAcquire;
 class pkgCacheGenerator;
 class pkgCacheGenerator;
 class OpProgress;
 class OpProgress;
+
 class pkgIndexFile
 class pkgIndexFile
 {
 {
    protected:
    protected:
@@ -59,13 +59,13 @@ class pkgIndexFile
    virtual const Type *GetType() const = 0;
    virtual const Type *GetType() const = 0;
    
    
    // Return descriptive strings of various sorts
    // Return descriptive strings of various sorts
-   virtual string ArchiveInfo(pkgCache::VerIterator Ver) const;
-   virtual string SourceInfo(pkgSrcRecords::Parser const &Record,
+   virtual std::string ArchiveInfo(pkgCache::VerIterator Ver) const;
+   virtual std::string SourceInfo(pkgSrcRecords::Parser const &Record,
 			     pkgSrcRecords::File const &File) const;
 			     pkgSrcRecords::File const &File) const;
-   virtual string Describe(bool Short = false) const = 0;   
+   virtual std::string Describe(bool Short = false) const = 0;   
 
 
    // Interface for acquire
    // Interface for acquire
-   virtual string ArchiveURI(string /*File*/) const {return string();};
+   virtual std::string ArchiveURI(std::string /*File*/) const {return std::string();};
 
 
    // Interface for the record parsers
    // Interface for the record parsers
    virtual pkgSrcRecords::Parser *CreateSrcParser() const {return 0;};
    virtual pkgSrcRecords::Parser *CreateSrcParser() const {return 0;};
@@ -84,7 +84,7 @@ class pkgIndexFile
 
 
    static bool TranslationsAvailable();
    static bool TranslationsAvailable();
    static bool CheckLanguageCode(const char *Lang);
    static bool CheckLanguageCode(const char *Lang);
-   static string LanguageCode();
+   static std::string LanguageCode();
 
 
    bool IsTrusted() const { return Trusted; };
    bool IsTrusted() const { return Trusted; };
    
    

+ 29 - 10
apt-pkg/indexrecords.cc

@@ -3,16 +3,24 @@
 // $Id: indexrecords.cc,v 1.1.2.4 2003/12/30 02:11:43 mdz Exp $
 // $Id: indexrecords.cc,v 1.1.2.4 2003/12/30 02:11:43 mdz Exp $
 									/*}}}*/
 									/*}}}*/
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
+#include<config.h>
+
 #include <apt-pkg/indexrecords.h>
 #include <apt-pkg/indexrecords.h>
 #include <apt-pkg/tagfile.h>
 #include <apt-pkg/tagfile.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/configuration.h>
-#include <apti18n.h>
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/hashes.h>
+
 #include <sys/stat.h>
 #include <sys/stat.h>
 #include <clocale>
 #include <clocale>
 
 
+#include <apti18n.h>
 									/*}}}*/
 									/*}}}*/
+
+using std::string;
+
 string indexRecords::GetDist() const
 string indexRecords::GetDist() const
 {
 {
    return this->Dist;
    return this->Dist;
@@ -78,7 +86,7 @@ bool indexRecords::Load(const string Filename)				/*{{{*/
 
 
       string Name;
       string Name;
       string Hash;
       string Hash;
-      size_t Size;
+      unsigned long long Size;
       while (Start < End)
       while (Start < End)
       {
       {
 	 if (!parseSumData(Start, End, Name, Hash, Size))
 	 if (!parseSumData(Start, End, Name, Hash, Size))
@@ -113,10 +121,14 @@ 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() == true)
+   if (Label.empty() == false)
       MaxAge = _config->FindI(string("Acquire::Max-ValidTime::" + Label).c_str(), MaxAge);
       MaxAge = _config->FindI(string("Acquire::Max-ValidTime::" + Label).c_str(), MaxAge);
+   int MinAge = _config->FindI("Acquire::Min-ValidTime", 0);
+   if (Label.empty() == false)
+      MinAge = _config->FindI(string("Acquire::Min-ValidTime::" + Label).c_str(), MinAge);
 
 
-   if(MaxAge == 0) // No user settings, use the one from the Release file
+   if(MaxAge == 0 &&
+      (MinAge == 0 || ValidUntil == 0)) // No user settings, use the one from the Release file
       return true;
       return true;
 
 
    time_t date;
    time_t date;
@@ -125,15 +137,22 @@ bool indexRecords::Load(const string Filename)				/*{{{*/
       strprintf(ErrorText, _("Invalid 'Date' entry in Release file %s"), Filename.c_str());
       strprintf(ErrorText, _("Invalid 'Date' entry in Release file %s"), Filename.c_str());
       return false;
       return false;
    }
    }
-   date += 24*60*60*MaxAge;
 
 
-   if (ValidUntil == 0 || ValidUntil > date)
-      ValidUntil = date;
+   if (MinAge != 0 && ValidUntil != 0) {
+      time_t const min_date = date + MinAge;
+      if (ValidUntil < min_date)
+	 ValidUntil = min_date;
+   }
+   if (MaxAge != 0) {
+      time_t const max_date = date + MaxAge;
+      if (ValidUntil == 0 || ValidUntil > max_date)
+	 ValidUntil = max_date;
+   }
 
 
    return true;
    return true;
 }
 }
 									/*}}}*/
 									/*}}}*/
-vector<string> indexRecords::MetaKeys()					/*{{{*/
+std::vector<string> indexRecords::MetaKeys()				/*{{{*/
 {
 {
    std::vector<std::string> keys;
    std::vector<std::string> keys;
    std::map<string,checkSum *>::iterator I = Entries.begin();
    std::map<string,checkSum *>::iterator I = Entries.begin();
@@ -145,7 +164,7 @@ vector<string> indexRecords::MetaKeys()					/*{{{*/
 }
 }
 									/*}}}*/
 									/*}}}*/
 bool indexRecords::parseSumData(const char *&Start, const char *End,	/*{{{*/
 bool indexRecords::parseSumData(const char *&Start, const char *End,	/*{{{*/
-				   string &Name, string &Hash, size_t &Size)
+				   string &Name, string &Hash, unsigned long long &Size)
 {
 {
    Name = "";
    Name = "";
    Hash = "";
    Hash = "";
@@ -182,7 +201,7 @@ bool indexRecords::parseSumData(const char *&Start, const char *End,	/*{{{*/
    if (EntryEnd == End)
    if (EntryEnd == End)
       return false;
       return false;
    
    
-   Size = strtol (Start, NULL, 10);
+   Size = strtoull (Start, NULL, 10);
       
       
    /* Skip over intermediate blanks */
    /* Skip over intermediate blanks */
    Start = EntryEnd;
    Start = EntryEnd;

+ 16 - 17
apt-pkg/indexrecords.h

@@ -7,7 +7,6 @@
 
 
 
 
 #include <apt-pkg/pkgcache.h>
 #include <apt-pkg/pkgcache.h>
-#include <apt-pkg/fileutl.h>
 #include <apt-pkg/hashes.h>
 #include <apt-pkg/hashes.h>
 
 
 #include <map>
 #include <map>
@@ -16,44 +15,44 @@
 
 
 class indexRecords
 class indexRecords
 {
 {
-   bool parseSumData(const char *&Start, const char *End, string &Name,
-		     string &Hash, size_t &Size);
+   bool parseSumData(const char *&Start, const char *End, std::string &Name,
+		     std::string &Hash, unsigned long long &Size);
    public:
    public:
    struct checkSum;
    struct checkSum;
-   string ErrorText;
+   std::string ErrorText;
    
    
    protected:
    protected:
-   string Dist;
-   string Suite;
-   string ExpectedDist;
+   std::string Dist;
+   std::string Suite;
+   std::string ExpectedDist;
    time_t ValidUntil;
    time_t ValidUntil;
 
 
-   std::map<string,checkSum *> Entries;
+   std::map<std::string,checkSum *> Entries;
 
 
    public:
    public:
 
 
    indexRecords();
    indexRecords();
-   indexRecords(const string ExpectedDist);
+   indexRecords(const std::string ExpectedDist);
 
 
    // Lookup function
    // Lookup function
-   virtual const checkSum *Lookup(const string MetaKey);
+   virtual const checkSum *Lookup(const std::string MetaKey);
    /** \brief tests if a checksum for this file is available */
    /** \brief tests if a checksum for this file is available */
-   bool Exists(string const &MetaKey) const;
+   bool Exists(std::string const &MetaKey) const;
    std::vector<std::string> MetaKeys();
    std::vector<std::string> MetaKeys();
 
 
-   virtual bool Load(string Filename);
-   string GetDist() const;
+   virtual bool Load(std::string Filename);
+   std::string GetDist() const;
    time_t GetValidUntil() const;
    time_t GetValidUntil() const;
-   virtual bool CheckDist(const string MaybeDist) const;
-   string GetExpectedDist() const;
+   virtual bool CheckDist(const std::string MaybeDist) const;
+   std::string GetExpectedDist() const;
    virtual ~indexRecords(){};
    virtual ~indexRecords(){};
 };
 };
 
 
 struct indexRecords::checkSum
 struct indexRecords::checkSum
 {
 {
-   string MetaKeyFilename;
+   std::string MetaKeyFilename;
    HashString Hash;
    HashString Hash;
-   size_t Size;      
+   unsigned long long Size;
 };
 };
 
 
 #endif
 #endif

+ 0 - 0
apt-pkg/init.cc


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