summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/contrib')
-rw-r--r--apt-pkg/contrib/cdromutl.cc6
-rw-r--r--apt-pkg/contrib/cmndline.cc4
-rw-r--r--apt-pkg/contrib/configuration.cc11
-rw-r--r--apt-pkg/contrib/crc-16.cc4
-rw-r--r--apt-pkg/contrib/crc-16.h2
-rw-r--r--apt-pkg/contrib/error.cc11
-rw-r--r--apt-pkg/contrib/fileutl.cc40
-rw-r--r--apt-pkg/contrib/fileutl.h35
-rw-r--r--apt-pkg/contrib/hashes.cc14
-rw-r--r--apt-pkg/contrib/hashes.h6
-rw-r--r--apt-pkg/contrib/hashsum.cc11
-rw-r--r--apt-pkg/contrib/hashsum_template.h6
-rw-r--r--apt-pkg/contrib/md5.cc5
-rw-r--r--apt-pkg/contrib/md5.h2
-rw-r--r--apt-pkg/contrib/mmap.cc25
-rw-r--r--apt-pkg/contrib/mmap.h8
-rw-r--r--apt-pkg/contrib/netrc.cc8
-rw-r--r--apt-pkg/contrib/progress.cc14
-rw-r--r--apt-pkg/contrib/progress.h16
-rw-r--r--apt-pkg/contrib/sha1.cc5
-rw-r--r--apt-pkg/contrib/sha1.h2
-rw-r--r--apt-pkg/contrib/sha2.h6
-rw-r--r--apt-pkg/contrib/sha2_internal.cc1
-rw-r--r--apt-pkg/contrib/strutl.cc64
-rw-r--r--apt-pkg/contrib/strutl.h1
25 files changed, 187 insertions, 120 deletions
diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc
index e25caf1a5..9de795b60 100644
--- a/apt-pkg/contrib/cdromutl.cc
+++ b/apt-pkg/contrib/cdromutl.cc
@@ -10,6 +10,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include<config.h>
+
#include <apt-pkg/cdromutl.h>
#include <apt-pkg/error.h>
#include <apt-pkg/md5.h>
@@ -17,8 +19,6 @@
#include <apt-pkg/configuration.h>
#include <apt-pkg/strutl.h>
-#include <apti18n.h>
-
#include <sys/wait.h>
#include <sys/statvfs.h>
#include <dirent.h>
@@ -26,6 +26,8 @@
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
+
+#include <apti18n.h>
/*}}}*/
// IsMounted - Returns true if the mount point is mounted /*{{{*/
diff --git a/apt-pkg/contrib/cmndline.cc b/apt-pkg/contrib/cmndline.cc
index 5a9944096..34e90da20 100644
--- a/apt-pkg/contrib/cmndline.cc
+++ b/apt-pkg/contrib/cmndline.cc
@@ -11,11 +11,13 @@
##################################################################### */
/*}}}*/
// Include files /*{{{*/
+#include<config.h>
+
#include <apt-pkg/cmndline.h>
#include <apt-pkg/error.h>
#include <apt-pkg/strutl.h>
-#include <apti18n.h>
+#include <apti18n.h>
/*}}}*/
using namespace std;
diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc
index 2d1dee22d..0949ec223 100644
--- a/apt-pkg/contrib/configuration.cc
+++ b/apt-pkg/contrib/configuration.cc
@@ -15,16 +15,19 @@
##################################################################### */
/*}}}*/
// Include files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/fileutl.h>
-#include <apti18n.h>
#include <vector>
#include <fstream>
#include <iostream>
+#include <apti18n.h>
+
using namespace std;
/*}}}*/
@@ -672,9 +675,9 @@ bool ReadConfigFile(Configuration &Conf,const string &FName,bool const &AsSectio
// Put the last fragment into the buffer
std::string::const_iterator NonWhitespaceStart = Start;
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)
LineBuffer += ' ';
@@ -850,7 +853,7 @@ bool ReadConfigDir(Configuration &Conf,const string &Dir,
vector<string> const List = GetListOfFilesInDir(Dir, "conf", true, true);
// 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)
return false;
return true;
diff --git a/apt-pkg/contrib/crc-16.cc b/apt-pkg/contrib/crc-16.cc
index b300ed67e..4058821f9 100644
--- a/apt-pkg/contrib/crc-16.cc
+++ b/apt-pkg/contrib/crc-16.cc
@@ -15,6 +15,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.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. */
#define CalcFCS(fcs, c) (((fcs) >> 8) ^ crc16_table[((fcs) ^ (c)) & 0xff])
unsigned short AddCRC16(unsigned short fcs, void const *Buf,
- unsigned long len)
+ unsigned long long len)
{
unsigned char const *buf = (unsigned char const *)Buf;
while (len--)
diff --git a/apt-pkg/contrib/crc-16.h b/apt-pkg/contrib/crc-16.h
index f30678bac..702de40b2 100644
--- a/apt-pkg/contrib/crc-16.h
+++ b/apt-pkg/contrib/crc-16.h
@@ -12,6 +12,6 @@
#define INIT_FCS 0xffff
unsigned short AddCRC16(unsigned short fcs, void const *buf,
- unsigned long len);
+ unsigned long long len);
#endif
diff --git a/apt-pkg/contrib/error.cc b/apt-pkg/contrib/error.cc
index 18810d2a4..122e2c809 100644
--- a/apt-pkg/contrib/error.cc
+++ b/apt-pkg/contrib/error.cc
@@ -13,6 +13,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/error.h>
#include <iostream>
@@ -24,8 +26,7 @@
#include <string>
#include <cstring>
-#include "config.h"
- /*}}}*/
+ /*}}}*/
// Global Error Object /*{{{*/
/* 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
for (std::list<Item>::const_iterator m = Messages.begin();
- m != Messages.end(); m++)
+ m != Messages.end(); ++m)
if (m->Type == ERROR || m->Type == FATAL)
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());
for (std::list<Item>::const_iterator m = Messages.begin();
- m != Messages.end(); m++)
+ m != Messages.end(); ++m)
if (m->Type >= threshold)
out << (*m) << std::endl;
Discard();
@@ -231,7 +232,7 @@ bool GlobalError::empty(MsgType const &trashhold) const {
return true;
for (std::list<Item>::const_iterator m = Messages.begin();
- m != Messages.end(); m++)
+ m != Messages.end(); ++m)
if (m->Type >= trashhold)
return false;
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 85dc6f600..95058cbde 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -18,14 +18,14 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/fileutl.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/error.h>
#include <apt-pkg/sptr.h>
#include <apt-pkg/configuration.h>
-#include <apti18n.h>
-
#include <cstdlib>
#include <cstring>
#include <cstdio>
@@ -43,10 +43,11 @@
#include <set>
#include <algorithm>
-#include <config.h>
#ifdef WORDS_BIGENDIAN
#include <inttypes.h>
#endif
+
+#include <apti18n.h>
/*}}}*/
using namespace std;
@@ -132,10 +133,10 @@ bool CopyFile(FileFd &From,FileFd &To)
// Buffered copy between fds
SPtrArray<unsigned char> Buf = new unsigned char[64000];
- unsigned long Size = From.Size();
+ unsigned long long Size = From.Size();
while (Size != 0)
{
- unsigned long ToRead = Size;
+ unsigned long long ToRead = Size;
if (Size > 64000)
ToRead = 64000;
@@ -810,7 +811,7 @@ FileFd::~FileFd()
// ---------------------------------------------------------------------
/* We are carefull to handle interruption by a signal while reading
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;
errno = 0;
@@ -849,13 +850,13 @@ bool FileFd::Read(void *To,unsigned long Size,unsigned long *Actual)
}
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 /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool FileFd::Write(const void *From,unsigned long Size)
+bool FileFd::Write(const void *From,unsigned long long Size)
{
int Res;
errno = 0;
@@ -882,13 +883,13 @@ bool FileFd::Write(const void *From,unsigned long Size)
return true;
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 /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool FileFd::Seek(unsigned long To)
+bool FileFd::Seek(unsigned long long To)
{
int res;
if (gz)
@@ -898,7 +899,7 @@ bool FileFd::Seek(unsigned long To)
if (res != (signed)To)
{
Flags |= Fail;
- return _error->Error("Unable to seek to %lu",To);
+ return _error->Error("Unable to seek to %llu", To);
}
return true;
@@ -907,7 +908,7 @@ bool FileFd::Seek(unsigned long To)
// FileFd::Skip - Seek in the file /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool FileFd::Skip(unsigned long Over)
+bool FileFd::Skip(unsigned long long Over)
{
int res;
if (gz)
@@ -917,7 +918,7 @@ bool FileFd::Skip(unsigned long Over)
if (res < 0)
{
Flags |= Fail;
- return _error->Error("Unable to seek ahead %lu",Over);
+ return _error->Error("Unable to seek ahead %llu",Over);
}
return true;
@@ -926,7 +927,7 @@ bool FileFd::Skip(unsigned long Over)
// FileFd::Truncate - Truncate the file /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool FileFd::Truncate(unsigned long To)
+bool FileFd::Truncate(unsigned long long To)
{
if (gz)
{
@@ -936,7 +937,7 @@ bool FileFd::Truncate(unsigned long To)
if (ftruncate(iFd,To) != 0)
{
Flags |= Fail;
- return _error->Error("Unable to truncate to %lu",To);
+ return _error->Error("Unable to truncate to %llu",To);
}
return true;
@@ -945,7 +946,7 @@ bool FileFd::Truncate(unsigned long To)
// FileFd::Tell - Current seek position /*{{{*/
// ---------------------------------------------------------------------
/* */
-unsigned long FileFd::Tell()
+unsigned long long FileFd::Tell()
{
off_t Res;
if (gz)
@@ -960,7 +961,7 @@ unsigned long FileFd::Tell()
// FileFd::FileSize - Return the size of the file /*{{{*/
// ---------------------------------------------------------------------
/* */
-unsigned long FileFd::FileSize()
+unsigned long long FileFd::FileSize()
{
struct stat Buf;
@@ -972,9 +973,9 @@ unsigned long FileFd::FileSize()
// 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
// "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
* this ourselves; the original (uncompressed) file size is the last 32
* 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);
if (lseek(iFd, -4, SEEK_END) < 0)
return _error->Errno("lseek","Unable to seek to end of gzipped file");
diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h
index a1b177f38..973a38cff 100644
--- a/apt-pkg/contrib/fileutl.h
+++ b/apt-pkg/contrib/fileutl.h
@@ -49,21 +49,36 @@ class FileFd
enum OpenMode {ReadOnly,WriteEmpty,WriteExists,WriteAny,WriteTemp,ReadOnlyGzip,
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)
return Read(To,Size,&Jnk);
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 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(string FileName,OpenMode Mode,unsigned long Perms = 0666);
bool OpenDescriptor(int Fd, OpenMode Mode, bool AutoClose=false);
bool Close();
diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc
index 4407574fa..fd76bf229 100644
--- a/apt-pkg/contrib/hashes.cc
+++ b/apt-pkg/contrib/hashes.cc
@@ -11,12 +11,14 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/hashes.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/macros.h>
-#include <unistd.h>
+#include <unistd.h>
#include <string>
#include <iostream>
/*}}}*/
@@ -106,18 +108,18 @@ string HashString::toStr() const
// 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)
{
unsigned char Buf[64*64];
- int Res = 0;
+ ssize_t Res = 0;
int ToEOF = (Size == 0);
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 = min(Size, 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;
if (ToEOF && Res == 0) // EOF
break;
diff --git a/apt-pkg/contrib/hashes.h b/apt-pkg/contrib/hashes.h
index e702fcca2..40c2ad064 100644
--- a/apt-pkg/contrib/hashes.h
+++ b/apt-pkg/contrib/hashes.h
@@ -62,14 +62,14 @@ class Hashes
SHA256Summation SHA256;
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);
};
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); };
- 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);
inline bool Add(const unsigned char *Beg,const unsigned char *End)
{return Add(Beg,End-Beg);};
diff --git a/apt-pkg/contrib/hashsum.cc b/apt-pkg/contrib/hashsum.cc
index 728747d7a..0edcbb364 100644
--- a/apt-pkg/contrib/hashsum.cc
+++ b/apt-pkg/contrib/hashsum.cc
@@ -1,4 +1,5 @@
// Cryptographic API Base
+#include <config.h>
#include <unistd.h>
#include "hashsum_template.h"
@@ -6,16 +7,16 @@
// 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];
- int Res = 0;
+ ssize_t Res = 0;
int ToEOF = (Size == 0);
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 = min(Size, 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;
if (ToEOF && Res == 0) // EOF
break;
diff --git a/apt-pkg/contrib/hashsum_template.h b/apt-pkg/contrib/hashsum_template.h
index 85d94c2af..9157754e3 100644
--- a/apt-pkg/contrib/hashsum_template.h
+++ b/apt-pkg/contrib/hashsum_template.h
@@ -87,8 +87,8 @@ class HashSumValue
class SummationImplementation
{
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); };
inline bool Add(const unsigned char *Data)
@@ -101,7 +101,7 @@ class SummationImplementation
inline bool Add(const char *Beg, const char *End)
{ 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
diff --git a/apt-pkg/contrib/md5.cc b/apt-pkg/contrib/md5.cc
index 65e20e9bb..4351aeb22 100644
--- a/apt-pkg/contrib/md5.cc
+++ b/apt-pkg/contrib/md5.cc
@@ -35,6 +35,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/md5.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/macros.h>
@@ -43,7 +45,6 @@
#include <unistd.h>
#include <netinet/in.h> // For htonl
#include <inttypes.h>
-#include <config.h>
/*}}}*/
// byteSwap - Swap bytes in a buffer /*{{{*/
@@ -186,7 +187,7 @@ MD5Summation::MD5Summation()
// 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)
return false;
diff --git a/apt-pkg/contrib/md5.h b/apt-pkg/contrib/md5.h
index e76428325..305cdb20d 100644
--- a/apt-pkg/contrib/md5.h
+++ b/apt-pkg/contrib/md5.h
@@ -45,7 +45,7 @@ class MD5Summation : public SummationImplementation
public:
- bool Add(const unsigned char *inbuf, unsigned long inlen);
+ bool Add(const unsigned char *inbuf, unsigned long long inlen);
using SummationImplementation::Add;
MD5SumValue Result();
diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc
index 19381ae47..a110a7019 100644
--- a/apt-pkg/contrib/mmap.cc
+++ b/apt-pkg/contrib/mmap.cc
@@ -17,20 +17,21 @@
/*}}}*/
// Include Files /*{{{*/
#define _BSD_SOURCE
+#include <config.h>
+
#include <apt-pkg/mmap.h>
#include <apt-pkg/error.h>
-#include <apti18n.h>
-
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <errno.h>
-
#include <cstring>
- /*}}}*/
+
+#include <apti18n.h>
+ /*}}}*/
// MMap::MMap - Constructor /*{{{*/
// ---------------------------------------------------------------------
@@ -94,7 +95,7 @@ bool MMap::Map(FileFd &Fd)
return false;
}
else
- return _error->Errno("mmap",_("Couldn't make mmap of %lu bytes"),
+ return _error->Errno("mmap",_("Couldn't make mmap of %llu bytes"),
iSize);
}
@@ -165,7 +166,7 @@ bool MMap::Sync(unsigned long Start,unsigned long Stop)
return true;
#ifdef _POSIX_SYNCHRONIZED_IO
- unsigned long PSize = sysconf(_SC_PAGESIZE);
+ unsigned long long PSize = sysconf(_SC_PAGESIZE);
if ((Flags & ReadOnly) != ReadOnly)
{
if (SyncToFd != 0)
@@ -176,7 +177,7 @@ bool MMap::Sync(unsigned long Start,unsigned long Stop)
}
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"));
}
}
@@ -196,7 +197,7 @@ DynamicMMap::DynamicMMap(FileFd &F,unsigned long Flags,unsigned long const &Work
if (_error->PendingError() == true)
return;
- unsigned long EndOfFile = Fd->Size();
+ unsigned long long EndOfFile = Fd->Size();
if (EndOfFile > WorkSpace)
WorkSpace = EndOfFile;
else if(WorkSpace > 0)
@@ -284,7 +285,7 @@ DynamicMMap::~DynamicMMap()
return;
}
- unsigned long EndOfFile = iSize;
+ unsigned long long EndOfFile = iSize;
iSize = WorkSpace;
Close(false);
if(ftruncate(Fd->Fd(),EndOfFile) < 0)
@@ -294,9 +295,9 @@ DynamicMMap::~DynamicMMap()
// DynamicMMap::RawAllocate - Allocate a raw chunk of unaligned space /*{{{*/
// ---------------------------------------------------------------------
/* 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)
Result += Aln - (iSize%Aln);
@@ -411,7 +412,7 @@ bool DynamicMMap::Grow() {
if (GrowFactor <= 0)
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) {
Fd->Seek(newSize - 1);
diff --git a/apt-pkg/contrib/mmap.h b/apt-pkg/contrib/mmap.h
index 2bf2c1540..e0ff8db95 100644
--- a/apt-pkg/contrib/mmap.h
+++ b/apt-pkg/contrib/mmap.h
@@ -41,7 +41,7 @@ class MMap
protected:
unsigned long Flags;
- unsigned long iSize;
+ unsigned long long iSize;
void *Base;
// In case mmap can not be used, we keep a dup of the file
@@ -60,8 +60,8 @@ class MMap
// Simple accessors
inline operator void *() {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; };
// File manipulators
@@ -99,7 +99,7 @@ class DynamicMMap : public MMap
public:
// 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 WriteString(const char *String,unsigned long Len = (unsigned long)-1);
inline unsigned long WriteString(const string &S) {return WriteString(S.c_str(),S.length());};
diff --git a/apt-pkg/contrib/netrc.cc b/apt-pkg/contrib/netrc.cc
index 34f472ee1..b9d0749e2 100644
--- a/apt-pkg/contrib/netrc.cc
+++ b/apt-pkg/contrib/netrc.cc
@@ -11,6 +11,7 @@
##################################################################### */
/*}}}*/
+#include <config.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/fileutl.h>
@@ -47,10 +48,7 @@ int parsenetrc (char *host, char *login, char *password, char *netrcfile = NULL)
int specific_login = (login[0] != 0);
char *home = NULL;
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,
found *our* login name */
@@ -81,6 +79,10 @@ int parsenetrc (char *host, char *login, char *password, char *netrcfile = NULL)
bool done = false;
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)) {
tok = strtok_r (netrcbuffer, " \t\n", &tok_buf);
while (!done && tok) {
diff --git a/apt-pkg/contrib/progress.cc b/apt-pkg/contrib/progress.cc
index 84ee4c124..317048845 100644
--- a/apt-pkg/contrib/progress.cc
+++ b/apt-pkg/contrib/progress.cc
@@ -8,15 +8,17 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/progress.h>
#include <apt-pkg/error.h>
#include <apt-pkg/configuration.h>
-#include <apti18n.h>
-
#include <iostream>
#include <stdio.h>
#include <cstring>
+
+#include <apti18n.h>
/*}}}*/
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
progress in units of SubTotal. Size is a scaling factor that says what
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)
Percent = 0;
@@ -47,8 +49,8 @@ void OpProgress::Progress(unsigned long Cur)
// 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->Total = Total;
@@ -65,7 +67,7 @@ void OpProgress::OverallProgress(unsigned long Current, unsigned long Total,
// 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)
{
this->SubTotal = SubTotal;
diff --git a/apt-pkg/contrib/progress.h b/apt-pkg/contrib/progress.h
index 3a914d17f..5344323f6 100644
--- a/apt-pkg/contrib/progress.h
+++ b/apt-pkg/contrib/progress.h
@@ -30,10 +30,10 @@ using std::string;
class Configuration;
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;
// Change reduction code
@@ -54,10 +54,10 @@ class OpProgress
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 string &Op = "", float const Percent = -1);
+ void OverallProgress(unsigned long long Current,unsigned long long Total,
+ unsigned long long Size,const string &Op);
virtual void Done() {};
OpProgress();
diff --git a/apt-pkg/contrib/sha1.cc b/apt-pkg/contrib/sha1.cc
index 5b9db202d..b5a6a2440 100644
--- a/apt-pkg/contrib/sha1.cc
+++ b/apt-pkg/contrib/sha1.cc
@@ -29,6 +29,8 @@
*/
/*}}} */
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/sha1.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/macros.h>
@@ -36,7 +38,6 @@
#include <string.h>
#include <unistd.h>
#include <inttypes.h>
-#include <config.h>
/*}}}*/
// SHA1Transform - Alters an existing SHA-1 hash /*{{{*/
@@ -241,7 +242,7 @@ SHA1SumValue SHA1Summation::Result()
// SHA1Summation::Add - Adds content of buffer into the checksum /*{{{*/
// ---------------------------------------------------------------------
/* 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)
return false;
diff --git a/apt-pkg/contrib/sha1.h b/apt-pkg/contrib/sha1.h
index 2701fc67e..916faec1b 100644
--- a/apt-pkg/contrib/sha1.h
+++ b/apt-pkg/contrib/sha1.h
@@ -34,7 +34,7 @@ class SHA1Summation : public SummationImplementation
bool Done;
public:
- bool Add(const unsigned char *inbuf, unsigned long inlen);
+ bool Add(const unsigned char *inbuf, unsigned long long inlen);
using SummationImplementation::Add;
SHA1SumValue Result();
diff --git a/apt-pkg/contrib/sha2.h b/apt-pkg/contrib/sha2.h
index 386225889..51c921dbd 100644
--- a/apt-pkg/contrib/sha2.h
+++ b/apt-pkg/contrib/sha2.h
@@ -30,7 +30,7 @@ class SHA2SummationBase : public SummationImplementation
protected:
bool Done;
public:
- bool Add(const unsigned char *inbuf, unsigned long len) = 0;
+ bool Add(const unsigned char *inbuf, unsigned long long len) = 0;
void Result();
};
@@ -41,7 +41,7 @@ class SHA256Summation : public SHA2SummationBase
unsigned char Sum[32];
public:
- bool Add(const unsigned char *inbuf, unsigned long len)
+ bool Add(const unsigned char *inbuf, unsigned long long len)
{
if (Done)
return false;
@@ -73,7 +73,7 @@ class SHA512Summation : public SHA2SummationBase
unsigned char Sum[64];
public:
- bool Add(const unsigned char *inbuf, unsigned long len)
+ bool Add(const unsigned char *inbuf, unsigned long long len)
{
if (Done)
return false;
diff --git a/apt-pkg/contrib/sha2_internal.cc b/apt-pkg/contrib/sha2_internal.cc
index 565db2f91..ff995cdf2 100644
--- a/apt-pkg/contrib/sha2_internal.cc
+++ b/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 $
*/
+#include <config.h>
#include <string.h> /* memcpy()/memset() or bcopy()/bzero() */
#include <assert.h> /* assert() */
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index ab2da2d9a..aaf44b7ff 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -15,12 +15,12 @@
##################################################################### */
/*}}}*/
// Includes /*{{{*/
+#include <config.h>
+
#include <apt-pkg/strutl.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/error.h>
-#include <apti18n.h>
-
#include <ctype.h>
#include <string.h>
#include <stdio.h>
@@ -31,7 +31,7 @@
#include <stdarg.h>
#include <iconv.h>
-#include "config.h"
+#include <apti18n.h>
using namespace std;
/*}}}*/
@@ -271,7 +271,7 @@ bool ParseCWord(const char *&String,string &Res)
string QuoteString(const string &Str, const char *Bad)
{
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 ||
*I == 0x25 || // percent '%' char
@@ -298,7 +298,7 @@ string DeQuoteString(string::const_iterator const &begin,
string::const_iterator const &end)
{
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 &&
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.
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
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
string::const_iterator J;
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);
}
- for (; *I != '\n' && I < Message.end(); I++);
+ for (; *I != '\n' && I < Message.end(); ++I);
}
// Failed to find a match
@@ -970,6 +970,34 @@ bool StrToNum(const char *Str,unsigned long &Res,unsigned Len,unsigned Base)
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 /*{{{*/
// ---------------------------------------------------------------------
/* This is used in decoding the 256bit encoded fixed length fields in
@@ -1224,7 +1252,7 @@ int tolower_ascii(int const c)
bool CheckDomainList(const string &Host,const string &List)
{
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 != ',')
continue;
@@ -1248,7 +1276,7 @@ string DeEscapeString(const string &input)
char tmp[3];
string::const_iterator it, escape_start;
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
if (*it != '\\')
@@ -1264,7 +1292,7 @@ string DeEscapeString(const string &input)
// copy
output += *it;
// advance iterator one step further
- it += 1;
+ ++it;
continue;
}
@@ -1273,7 +1301,7 @@ string DeEscapeString(const string &input)
continue;
// read it
- it++;
+ ++it;
switch (*it)
{
case '0':
@@ -1310,7 +1338,7 @@ void URI::CopyFrom(const string &U)
string::const_iterator I = U.begin();
// 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;
/* Determine if this is a host type URI with a leading double //
@@ -1322,7 +1350,7 @@ void URI::CopyFrom(const string &U)
/* Find the / indicating the end of the hostname, ignoring /'s in the
square brackets */
bool InBracket = false;
- for (; SingleSlash < U.end() && (*SingleSlash != '/' || InBracket == true); SingleSlash++)
+ for (; SingleSlash < U.end() && (*SingleSlash != '/' || InBracket == true); ++SingleSlash)
{
if (*SingleSlash == '[')
InBracket = true;
@@ -1355,11 +1383,11 @@ void URI::CopyFrom(const string &U)
I = FirstColon + 1;
if (I > SingleSlash)
I = SingleSlash;
- for (; I < SingleSlash && *I != ':'; I++);
+ for (; I < SingleSlash && *I != ':'; ++I);
string::const_iterator SecondColon = I;
// Search for the @ after the colon
- for (; I < SingleSlash && *I != '@'; I++);
+ for (; I < SingleSlash && *I != '@'; ++I);
string::const_iterator At = I;
// Now write the host and user/pass
diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h
index fba85cf94..ab4b54722 100644
--- a/apt-pkg/contrib/strutl.h
+++ b/apt-pkg/contrib/strutl.h
@@ -56,6 +56,7 @@ 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);
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 Hex2Num(const string &Str,unsigned char *Num,unsigned int Length);
bool TokSplitString(char Tok,char *Input,char **List,