summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2011-11-10 16:32:52 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2011-11-10 16:32:52 +0100
commit71ecaad29d8066a494f516efc5efd80860653fe2 (patch)
treeb0769df88e2b6496f23e3d899aeb1c240a3488d9 /apt-pkg/contrib
parenta865ed25fa54514224cf4d6f83dd9cf48b7ed02b (diff)
parent37adedc9d0b66eeae7efb88aebd08dfbc6e06f77 (diff)
merged from http://bzr.debian.org/bzr/apt/apt/debian-experimental2
Diffstat (limited to 'apt-pkg/contrib')
-rw-r--r--apt-pkg/contrib/cdromutl.cc8
-rw-r--r--apt-pkg/contrib/cdromutl.h12
-rw-r--r--apt-pkg/contrib/cmndline.cc33
-rw-r--r--apt-pkg/contrib/cmndline.h4
-rw-r--r--apt-pkg/contrib/configuration.cc11
-rw-r--r--apt-pkg/contrib/configuration.h46
-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.h77
-rw-r--r--apt-pkg/contrib/hashes.cc38
-rw-r--r--apt-pkg/contrib/hashes.h23
-rw-r--r--apt-pkg/contrib/hashsum.cc11
-rw-r--r--apt-pkg/contrib/hashsum_template.h25
-rw-r--r--apt-pkg/contrib/md5.cc5
-rw-r--r--apt-pkg/contrib/md5.h5
-rw-r--r--apt-pkg/contrib/mmap.cc26
-rw-r--r--apt-pkg/contrib/mmap.h13
-rw-r--r--apt-pkg/contrib/netrc.cc11
-rw-r--r--apt-pkg/contrib/netrc.h6
-rw-r--r--apt-pkg/contrib/progress.cc14
-rw-r--r--apt-pkg/contrib/progress.h30
-rw-r--r--apt-pkg/contrib/sha1.cc5
-rw-r--r--apt-pkg/contrib/sha1.h5
-rw-r--r--apt-pkg/contrib/sha2.h6
-rw-r--r--apt-pkg/contrib/sha2_internal.cc17
-rw-r--r--apt-pkg/contrib/strutl.cc79
-rw-r--r--apt-pkg/contrib/strutl.h109
29 files changed, 366 insertions, 310 deletions
diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc
index e25caf1a5..187f6bd59 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,8 +26,12 @@
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
+
+#include <apti18n.h>
/*}}}*/
+using std::string;
+
// IsMounted - Returns true if the mount point is mounted /*{{{*/
// ---------------------------------------------------------------------
/* This is a simple algorithm that should always work, we stat the mount point
diff --git a/apt-pkg/contrib/cdromutl.h b/apt-pkg/contrib/cdromutl.h
index 38ed2996e..2c6afac0f 100644
--- a/apt-pkg/contrib/cdromutl.h
+++ b/apt-pkg/contrib/cdromutl.h
@@ -12,13 +12,11 @@
#include <string>
-using std::string;
-
// 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
diff --git a/apt-pkg/contrib/cmndline.cc b/apt-pkg/contrib/cmndline.cc
index 5a9944096..159f330a1 100644
--- a/apt-pkg/contrib/cmndline.cc
+++ b/apt-pkg/contrib/cmndline.cc
@@ -11,11 +11,14 @@
##################################################################### */
/*}}}*/
// Include files /*{{{*/
+#include<config.h>
+
+#include <apt-pkg/configuration.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;
@@ -87,9 +90,8 @@ bool CommandLine::Parse(int argc,const char **argv)
Opt++;
// Match up to a = against the list
- const char *OptEnd = Opt;
Args *A;
- for (; *OptEnd != 0 && *OptEnd != '='; OptEnd++);
+ const char *OptEnd = strchrnul(Opt, '=');
for (A = ArgList; A->end() == false &&
stringcasecmp(Opt,OptEnd,A->LongOpt) != 0; A++);
@@ -97,9 +99,8 @@ bool CommandLine::Parse(int argc,const char **argv)
bool PreceedMatch = false;
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]);
Opt++;
@@ -194,9 +195,8 @@ bool CommandLine::HandleOpt(int &I,int argc,const char *argv[],
// Arbitrary item specification
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]);
// = is trailing
@@ -212,8 +212,7 @@ bool CommandLine::HandleOpt(int &I,int argc,const char *argv[],
return true;
}
- const char *I = A->ConfName;
- for (; *I != 0 && *I != ' '; I++);
+ const char *I = strchrnul(A->ConfName, ' ');
if (*I == ' ')
Conf->Set(string(A->ConfName,0,I-A->ConfName),string(I+1) + Argument);
else
@@ -269,10 +268,9 @@ bool CommandLine::HandleOpt(int &I,int argc,const char *argv[],
// Skip the leading dash
const char *J = argv[I];
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);
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,
// 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] = '"';
closeQuote = true;
}
diff --git a/apt-pkg/contrib/cmndline.h b/apt-pkg/contrib/cmndline.h
index 7c0c71aa7..b201d9855 100644
--- a/apt-pkg/contrib/cmndline.h
+++ b/apt-pkg/contrib/cmndline.h
@@ -44,9 +44,7 @@
#ifndef PKGLIB_CMNDLINE_H
#define PKGLIB_CMNDLINE_H
-
-
-#include <apt-pkg/configuration.h>
+class Configuration;
class CommandLine
{
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/configuration.h b/apt-pkg/contrib/configuration.h
index 2844ec097..f6f2a3c1d 100644
--- a/apt-pkg/contrib/configuration.h
+++ b/apt-pkg/contrib/configuration.h
@@ -34,21 +34,19 @@
#include <vector>
#include <iostream>
-using std::string;
-
class Configuration
{
public:
struct Item
{
- string Value;
- string Tag;
+ std::string Value;
+ std::string Tag;
Item *Parent;
Item *Child;
Item *Next;
- string FullTag(const Item *Stop = 0) const;
+ std::string FullTag(const Item *Stop = 0) const;
Item() : Parent(0), Child(0), Next(0) {};
};
@@ -67,35 +65,35 @@ class Configuration
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(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(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 Set(const char *Name,const string &Value);
+ void Set(const char *Name,const std::string &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 ExistsAny(const char *Name) const;
// 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")
- 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);};
@@ -127,11 +125,11 @@ class Configuration
extern Configuration *_config;
-bool ReadConfigFile(Configuration &Conf,const string &FName,
+bool ReadConfigFile(Configuration &Conf,const std::string &FName,
bool const &AsSectional = false,
unsigned const &Depth = 0);
-bool ReadConfigDir(Configuration &Conf,const string &Dir,
+bool ReadConfigDir(Configuration &Conf,const std::string &Dir,
bool const &AsSectional = false,
unsigned const &Depth = 0);
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..0d0451a46 100644
--- a/apt-pkg/contrib/fileutl.h
+++ b/apt-pkg/contrib/fileutl.h
@@ -31,8 +31,6 @@
/* Define this for python-apt */
#define APT_HAS_GZIP 1
-using std::string;
-
class FileFd
{
protected:
@@ -41,30 +39,45 @@ class FileFd
enum LocalFlags {AutoClose = (1<<0),Fail = (1<<1),DelOnFail = (1<<2),
HitEof = (1<<3), Replace = (1<<4) };
unsigned long Flags;
- string FileName;
- string TemporaryFileName;
+ std::string FileName;
+ std::string TemporaryFileName;
gzFile gz;
public:
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 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 Close();
bool Sync();
@@ -78,9 +91,9 @@ class FileFd
inline void EraseOnFailure() {Flags |= DelOnFail;};
inline void OpFail() {Flags |= Fail;};
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)
{
Open(FileName,Mode,Perms);
@@ -92,12 +105,12 @@ class FileFd
bool RunScripts(const char *Cnf);
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
*
@@ -105,13 +118,13 @@ time_t GetModificationTime(string const &Path);
* /apt/ will be removed before CreateDirectory 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);
-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);
-string SafeGetCWD();
+std::string SafeGetCWD();
void SetCloseExec(int Fd,bool Close);
void SetNonBlock(int Fd,bool Block);
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);
// 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
diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc
index 4407574fa..05001f042 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>
/*}}}*/
@@ -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
- if (StringedHash.find(":") == string::npos && StringedHash.size() == 32)
+ if (StringedHash.find(":") == std::string::npos && StringedHash.size() == 32)
{
Type = "MD5Sum";
Hash = StringedHash;
return;
}
- string::size_type pos = StringedHash.find(":");
+ std::string::size_type pos = StringedHash.find(":");
Type = StringedHash.substr(0,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;
}
/*}}}*/
-bool HashString::VerifyFile(string filename) const /*{{{*/
+bool HashString::VerifyFile(std::string filename) const /*{{{*/
{
- string fileHash;
+ std::string fileHash;
FileFd Fd(filename, FileFd::ReadOnly);
if(Type == "MD5Sum")
{
MD5Summation MD5;
MD5.AddFD(Fd.Fd(), Fd.Size());
- fileHash = (string)MD5.Result();
+ fileHash = (std::string)MD5.Result();
}
else if (Type == "SHA1")
{
SHA1Summation SHA1;
SHA1.AddFD(Fd.Fd(), Fd.Size());
- fileHash = (string)SHA1.Result();
+ fileHash = (std::string)SHA1.Result();
}
else if (Type == "SHA256")
{
SHA256Summation SHA256;
SHA256.AddFD(Fd.Fd(), Fd.Size());
- fileHash = (string)SHA256.Result();
+ fileHash = (std::string)SHA256.Result();
}
else if (Type == "SHA512")
{
SHA512Summation SHA512;
SHA512.AddFD(Fd.Fd(), Fd.Size());
- fileHash = (string)SHA512.Result();
+ fileHash = (std::string)SHA512.Result();
}
Fd.Close();
@@ -98,26 +100,26 @@ bool HashString::empty() const
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 /*{{{*/
// ---------------------------------------------------------------------
/* */
-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 = std::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..81851dede 100644
--- a/apt-pkg/contrib/hashes.h
+++ b/apt-pkg/contrib/hashes.h
@@ -22,31 +22,28 @@
#include <vector>
#include <cstring>
-using std::min;
-using std::vector;
-
// helper class that contains hash function name
// and hash
class HashString
{
protected:
- string Type;
- string Hash;
+ std::string Type;
+ std::string Hash;
static const char * _SupportedHashes[10];
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();
// get hash type used
- string HashType() { return Type; };
+ std::string HashType() { return Type; };
// verify the given filename against the currently loaded hash
- bool VerifyFile(string filename) const;
+ bool VerifyFile(std::string filename) const;
// helper
- string toStr() const; // convert to str as "type:hash"
+ std::string toStr() const; // convert to str as "type:hash"
bool empty() const;
// return the list of hashes we support
@@ -62,14 +59,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..ff3b112bb 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 = std::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..27d192b82 100644
--- a/apt-pkg/contrib/hashsum_template.h
+++ b/apt-pkg/contrib/hashsum_template.h
@@ -15,9 +15,6 @@
#include <algorithm>
#include <stdint.h>
-using std::string;
-using std::min;
-
template<int N>
class HashSumValue
{
@@ -29,9 +26,13 @@ class HashSumValue
bool operator ==(const HashSumValue &rhs) const
{
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] =
{ '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 + 1] = Conv[Sum[J] & 0xF];
}
- return string(Result);
+ return std::string(Result);
};
inline void Value(unsigned char S[N/8])
@@ -57,12 +58,12 @@ class HashSumValue
S[I] = Sum[I];
};
- inline operator string() const
+ inline operator std::string() const
{
return Value();
};
- bool Set(string Str)
+ bool Set(std::string Str)
{
return Hex2Num(Str,Sum,sizeof(Sum));
};
@@ -73,7 +74,7 @@ class HashSumValue
Sum[I] = S[I];
};
- HashSumValue(string Str)
+ HashSumValue(std::string Str)
{
memset(Sum,0,sizeof(Sum));
Set(Str);
@@ -87,8 +88,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 +102,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..a207da4e4 100644
--- a/apt-pkg/contrib/md5.h
+++ b/apt-pkg/contrib/md5.h
@@ -29,9 +29,6 @@
#include <algorithm>
#include <stdint.h>
-using std::string;
-using std::min;
-
#include "hashsum_template.h"
typedef HashSumValue<128> MD5SumValue;
@@ -45,7 +42,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..f76169a92 100644
--- a/apt-pkg/contrib/mmap.cc
+++ b/apt-pkg/contrib/mmap.cc
@@ -17,10 +17,11 @@
/*}}}*/
// Include Files /*{{{*/
#define _BSD_SOURCE
+#include <config.h>
+
#include <apt-pkg/mmap.h>
#include <apt-pkg/error.h>
-
-#include <apti18n.h>
+#include <apt-pkg/fileutl.h>
#include <sys/mman.h>
#include <sys/stat.h>
@@ -28,9 +29,10 @@
#include <fcntl.h>
#include <stdlib.h>
#include <errno.h>
-
#include <cstring>
- /*}}}*/
+
+#include <apti18n.h>
+ /*}}}*/
// MMap::MMap - Constructor /*{{{*/
// ---------------------------------------------------------------------
@@ -94,7 +96,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 +167,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 +178,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 +198,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 +286,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 +296,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 +413,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..2ed4a95f8 100644
--- a/apt-pkg/contrib/mmap.h
+++ b/apt-pkg/contrib/mmap.h
@@ -27,9 +27,8 @@
#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
types are too small. Where ever possible 'unsigned long' should be used
@@ -41,7 +40,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 +59,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,10 +98,10 @@ 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());};
+ 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;};
DynamicMMap(FileFd &F,unsigned long Flags,unsigned long const &WorkSpace = 2*1024*1024,
diff --git a/apt-pkg/contrib/netrc.cc b/apt-pkg/contrib/netrc.cc
index 34f472ee1..cb7d36088 100644
--- a/apt-pkg/contrib/netrc.cc
+++ b/apt-pkg/contrib/netrc.cc
@@ -11,9 +11,12 @@
##################################################################### */
/*}}}*/
+#include <config.h>
#include <apt-pkg/configuration.h>
+#include <apt-pkg/strutl.h>
#include <apt-pkg/fileutl.h>
+
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
@@ -23,6 +26,7 @@
#include "netrc.h"
+using std::string;
/* 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);
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 +82,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/netrc.h b/apt-pkg/contrib/netrc.h
index 02a5eb09f..7b94eba88 100644
--- a/apt-pkg/contrib/netrc.h
+++ b/apt-pkg/contrib/netrc.h
@@ -14,16 +14,18 @@
#ifndef NETRC_H
#define NETRC_H
-#include <apt-pkg/strutl.h>
+#include <string>
#define DOT_CHAR "."
#define DIR_CHAR "/"
+class URI;
+
// Assume: password[0]=0, host[0] != 0.
// If login[0] = 0, search for login and password within a machine section
// in the netrc.
// If login[0] != 0, search for password within machine and login.
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
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..7635719bc 100644
--- a/apt-pkg/contrib/progress.h
+++ b/apt-pkg/contrib/progress.h
@@ -25,26 +25,24 @@
#include <string>
#include <sys/time.h>
-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
struct timeval LastTime;
- string LastOp;
- string LastSubOp;
+ std::string LastOp;
+ std::string LastSubOp;
protected:
- string Op;
- string SubOp;
+ std::string Op;
+ std::string SubOp;
float Percent;
bool MajorChange;
@@ -54,10 +52,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 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() {};
OpProgress();
@@ -67,8 +65,8 @@ class OpProgress
class OpTextProgress : public OpProgress
{
protected:
-
- string OldOp;
+
+ std::string OldOp;
bool NoUpdate;
bool NoDisplay;
unsigned long LastLen;
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..b4b139a22 100644
--- a/apt-pkg/contrib/sha1.h
+++ b/apt-pkg/contrib/sha1.h
@@ -18,9 +18,6 @@
#include <cstring>
#include <algorithm>
-using std::string;
-using std::min;
-
#include "hashsum_template.h"
typedef HashSumValue<160> SHA1SumValue;
@@ -34,7 +31,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..6d27e8f2b 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() */
@@ -604,7 +605,12 @@ void SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
*context->buffer = 0x80;
}
/* 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: */
SHA256_Transform(context, (sha2_word32*)context->buffer);
@@ -921,8 +927,13 @@ static void SHA512_Last(SHA512_CTX* context) {
*context->buffer = 0x80;
}
/* 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: */
SHA512_Transform(context, (sha2_word64*)context->buffer);
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index ab2da2d9a..861cdcbeb 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;
/*}}}*/
@@ -179,14 +179,14 @@ bool ParseQuoteWord(const char *&String,string &Res)
{
if (*C == '"')
{
- for (C++; *C != 0 && *C != '"'; C++);
- if (*C == 0)
+ C = strchr(C + 1, '"');
+ if (C == NULL)
return false;
}
if (*C == '[')
{
- for (C++; *C != 0 && *C != ']'; C++);
- if (*C == 0)
+ C = strchr(C + 1, ']');
+ if (C == NULL)
return false;
}
}
@@ -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
@@ -904,11 +904,10 @@ bool StrToTime(const string &Val,time_t &Result)
{
struct tm Tm;
char Month[10];
- const char *I = Val.c_str();
-
+
// Skip the day of the week
- for (;*I != 0 && *I != ' '; I++);
-
+ const char *I = strchr(Val.c_str(), ' ');
+
// Handle RFC 1123 time
Month[0] = 0;
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;
}
/*}}}*/
+// 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 +1251,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 +1275,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 +1291,7 @@ string DeEscapeString(const string &input)
// copy
output += *it;
// advance iterator one step further
- it += 1;
+ ++it;
continue;
}
@@ -1273,7 +1300,7 @@ string DeEscapeString(const string &input)
continue;
// read it
- it++;
+ ++it;
switch (*it)
{
case '0':
@@ -1310,7 +1337,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 +1349,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 +1382,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..93f4bef4f 100644
--- a/apt-pkg/contrib/strutl.h
+++ b/apt-pkg/contrib/strutl.h
@@ -27,59 +27,56 @@
#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 *_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
-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 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 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 Hex2Num(const std::string &Str,unsigned char *Num,unsigned int Length);
bool TokSplitString(char Tok,char *Input,char **List,
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);
-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;
-string StripEpoch(const string &VerStr);
+std::string StripEpoch(const std::string &VerStr);
#define APT_MKSTRCMP(name,func) \
inline int name(const char *A,const char *B) {return func(A,A+strlen(A),B,B+strlen(B));}; \
inline int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));}; \
-inline int name(const 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) \
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 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
const char * and we need these extra functions */
#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);
-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);
-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
APT_MKSTRCMP2(stringcmp,stringcmp);
@@ -108,34 +105,34 @@ inline const char *DeNull(const char *s) {return (s == 0?"(null)":s);};
class URI
{
- void CopyFrom(const string &From);
+ void CopyFrom(const std::string &From);
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;
- 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();};
- 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) {};
};
struct SubstVar
{
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
{