summaryrefslogtreecommitdiff
path: root/methods
diff options
context:
space:
mode:
Diffstat (limited to 'methods')
-rw-r--r--methods/bzip2.cc9
-rw-r--r--methods/cdrom.cc3
-rw-r--r--methods/connect.cc20
-rw-r--r--methods/connect.h5
-rw-r--r--methods/copy.cc5
-rw-r--r--methods/file.cc9
-rw-r--r--methods/ftp.cc17
-rw-r--r--methods/ftp.h18
-rw-r--r--methods/gpgv.cc10
-rw-r--r--methods/gzip.cc6
-rw-r--r--methods/http.cc44
-rw-r--r--methods/http.h55
-rw-r--r--methods/http_main.cc2
-rw-r--r--methods/https.cc8
-rw-r--r--methods/https.h3
-rw-r--r--methods/mirror.cc7
-rw-r--r--methods/mirror.h25
-rw-r--r--methods/rfc2553emu.cc4
-rw-r--r--methods/rred.cc9
-rw-r--r--methods/rsh.cc42
-rw-r--r--methods/rsh.h24
21 files changed, 195 insertions, 130 deletions
diff --git a/methods/bzip2.cc b/methods/bzip2.cc
index 42932dded..8e7e46557 100644
--- a/methods/bzip2.cc
+++ b/methods/bzip2.cc
@@ -13,11 +13,14 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/fileutl.h>
#include <apt-pkg/error.h>
#include <apt-pkg/acquire-method.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/hashes.h>
+#include <apt-pkg/configuration.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -45,9 +48,9 @@ class Bzip2Method : public pkgAcqMethod
bool Bzip2Method::Fetch(FetchItem *Itm)
{
URI Get = Itm->Uri;
- string Path = Get.Host + Get.Path; // To account for relative paths
+ std::string Path = Get.Host + Get.Path; // To account for relative paths
- string GzPathOption = "Dir::bin::"+string(Prog);
+ std::string GzPathOption = "Dir::bin::" + std::string(Prog);
FetchResult Res;
Res.Filename = Itm->DestFile;
@@ -76,7 +79,7 @@ bool Bzip2Method::Fetch(FetchItem *Itm)
SetCloseExec(STDOUT_FILENO,false);
const char *Args[3];
- string Tmp = _config->Find(GzPathOption,Prog);
+ std::string Tmp = _config->Find(GzPathOption,Prog);
Args[0] = Tmp.c_str();
Args[1] = "-d";
Args[2] = 0;
diff --git a/methods/cdrom.cc b/methods/cdrom.cc
index ae699dfc3..e7114b168 100644
--- a/methods/cdrom.cc
+++ b/methods/cdrom.cc
@@ -8,12 +8,15 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/acquire-method.h>
#include <apt-pkg/cdrom.h>
#include <apt-pkg/cdromutl.h>
#include <apt-pkg/error.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/fileutl.h>
+#include <apt-pkg/strutl.h>
#include <apt-pkg/hashes.h>
#include <sys/stat.h>
diff --git a/methods/connect.cc b/methods/connect.cc
index a5af1f1a6..9a092a43c 100644
--- a/methods/connect.cc
+++ b/methods/connect.cc
@@ -11,9 +11,12 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#include "connect.h"
+#include <config.h>
+
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/acquire-method.h>
#include <stdio.h>
#include <errno.h>
@@ -29,17 +32,18 @@
#include <arpa/inet.h>
#include <netdb.h>
+#include "connect.h"
#include "rfc2553emu.h"
#include <apti18n.h>
/*}}}*/
-static string LastHost;
+static std::string LastHost;
static int LastPort = 0;
static struct addrinfo *LastHostAddr = 0;
static struct addrinfo *LastUsed = 0;
// Set of IP/hostnames that we timed out before or couldn't resolve
-static std::set<string> bad_addr;
+static std::set<std::string> bad_addr;
// RotateDNS - Select a new server from a DNS rotation /*{{{*/
// ---------------------------------------------------------------------
@@ -56,7 +60,7 @@ void RotateDNS()
// DoConnect - Attempt a connect operation /*{{{*/
// ---------------------------------------------------------------------
/* This helper function attempts a connection to a single address. */
-static bool DoConnect(struct addrinfo *Addr,string Host,
+static bool DoConnect(struct addrinfo *Addr,std::string Host,
unsigned long TimeOut,int &Fd,pkgAcqMethod *Owner)
{
// Show a status indicator
@@ -71,7 +75,7 @@ static bool DoConnect(struct addrinfo *Addr,string Host,
Owner->Status(_("Connecting to %s (%s)"),Host.c_str(),Name);
// if that addr did timeout before, we do not try it again
- if(bad_addr.find(string(Name)) != bad_addr.end())
+ if(bad_addr.find(std::string(Name)) != bad_addr.end())
return false;
/* If this is an IP rotation store the IP we are using.. If something goes
@@ -98,7 +102,7 @@ static bool DoConnect(struct addrinfo *Addr,string Host,
/* This implements a timeout for connect by opening the connection
nonblocking */
if (WaitFd(Fd,true,TimeOut) == false) {
- bad_addr.insert(bad_addr.begin(), string(Name));
+ bad_addr.insert(bad_addr.begin(), std::string(Name));
Owner->SetFailReason("Timeout");
return _error->Error(_("Could not connect to %s:%s (%s), "
"connection timed out"),Host.c_str(),Service,Name);
@@ -117,7 +121,7 @@ static bool DoConnect(struct addrinfo *Addr,string Host,
Owner->SetFailReason("ConnectionRefused");
else if (errno == ETIMEDOUT)
Owner->SetFailReason("ConnectionTimedOut");
- bad_addr.insert(bad_addr.begin(), string(Name));
+ bad_addr.insert(bad_addr.begin(), std::string(Name));
return _error->Errno("connect",_("Could not connect to %s:%s (%s)."),Host.c_str(),
Service,Name);
}
@@ -128,7 +132,7 @@ static bool DoConnect(struct addrinfo *Addr,string Host,
// Connect - Connect to a server /*{{{*/
// ---------------------------------------------------------------------
/* Performs a connection to the server */
-bool Connect(string Host,int Port,const char *Service,int DefPort,int &Fd,
+bool Connect(std::string Host,int Port,const char *Service,int DefPort,int &Fd,
unsigned long TimeOut,pkgAcqMethod *Owner)
{
if (_error->PendingError() == true)
diff --git a/methods/connect.h b/methods/connect.h
index 6f208e31d..bbe1bb35d 100644
--- a/methods/connect.h
+++ b/methods/connect.h
@@ -11,9 +11,10 @@
#define CONNECT_H
#include <string>
-#include <apt-pkg/acquire-method.h>
-bool Connect(string To,int Port,const char *Service,int DefPort,
+class pkgAcqMethod;
+
+bool Connect(std::string To,int Port,const char *Service,int DefPort,
int &Fd,unsigned long TimeOut,pkgAcqMethod *Owner);
void RotateDNS();
diff --git a/methods/copy.cc b/methods/copy.cc
index a6bb372a3..f8d58e479 100644
--- a/methods/copy.cc
+++ b/methods/copy.cc
@@ -9,7 +9,10 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/fileutl.h>
+#include <apt-pkg/strutl.h>
#include <apt-pkg/acquire-method.h>
#include <apt-pkg/error.h>
#include <apt-pkg/hashes.h>
@@ -35,7 +38,7 @@ class CopyMethod : public pkgAcqMethod
bool CopyMethod::Fetch(FetchItem *Itm)
{
URI Get = Itm->Uri;
- string File = Get.Path;
+ std::string File = Get.Path;
// Stat the file and send a start message
struct stat Buf;
diff --git a/methods/file.cc b/methods/file.cc
index 9cdd5bc2d..5025c996d 100644
--- a/methods/file.cc
+++ b/methods/file.cc
@@ -13,10 +13,13 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/acquire-method.h>
#include <apt-pkg/error.h>
#include <apt-pkg/hashes.h>
#include <apt-pkg/fileutl.h>
+#include <apt-pkg/strutl.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -38,7 +41,7 @@ class FileMethod : public pkgAcqMethod
bool FileMethod::Fetch(FetchItem *Itm)
{
URI Get = Itm->Uri;
- string File = Get.Path;
+ std::string File = Get.Path;
FetchResult Res;
if (Get.Host.empty() == false)
return _error->Error(_("Invalid URI, local URIS must not start with //"));
@@ -56,10 +59,10 @@ bool FileMethod::Fetch(FetchItem *Itm)
}
// See if we can compute a file without a .gz exentsion
- string::size_type Pos = File.rfind(".gz");
+ std::string::size_type Pos = File.rfind(".gz");
if (Pos + 3 == File.length())
{
- File = string(File,0,Pos);
+ File = std::string(File,0,Pos);
if (stat(File.c_str(),&Buf) == 0)
{
FetchResult AltRes;
diff --git a/methods/ftp.cc b/methods/ftp.cc
index eb7fedd85..2ca0ac6f7 100644
--- a/methods/ftp.cc
+++ b/methods/ftp.cc
@@ -15,11 +15,14 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/fileutl.h>
#include <apt-pkg/acquire-method.h>
#include <apt-pkg/error.h>
#include <apt-pkg/hashes.h>
#include <apt-pkg/netrc.h>
+#include <apt-pkg/configuration.h>
#include <sys/stat.h>
#include <sys/time.h>
@@ -30,7 +33,6 @@
#include <errno.h>
#include <stdarg.h>
#include <iostream>
-#include <apti18n.h>
// Internet stuff
#include <netinet/in.h>
@@ -41,6 +43,7 @@
#include "rfc2553emu.h"
#include "connect.h"
#include "ftp.h"
+#include <apti18n.h>
/*}}}*/
using namespace std;
@@ -628,7 +631,7 @@ bool FTPConn::ExtGoPasv()
// FTPConn::Size - Return the size of a file /*{{{*/
// ---------------------------------------------------------------------
/* Grab the file size from the server, 0 means no size or empty file */
-bool FTPConn::Size(const char *Path,unsigned long &Size)
+bool FTPConn::Size(const char *Path,unsigned long long &Size)
{
// Query the size
unsigned int Tag;
@@ -638,7 +641,7 @@ bool FTPConn::Size(const char *Path,unsigned long &Size)
return false;
char *End;
- Size = strtol(Msg.c_str(),&End,10);
+ Size = strtoull(Msg.c_str(),&End,10);
if (Tag >= 400 || End == Msg.c_str())
Size = 0;
return true;
@@ -840,7 +843,7 @@ bool FTPConn::Finalize()
// ---------------------------------------------------------------------
/* This opens a data connection, sends REST and RETR and then
transfers the file over. */
-bool FTPConn::Get(const char *Path,FileFd &To,unsigned long Resume,
+bool FTPConn::Get(const char *Path,FileFd &To,unsigned long long Resume,
Hashes &Hash,bool &Missing)
{
Missing = false;
@@ -1003,7 +1006,7 @@ bool FtpMethod::Fetch(FetchItem *Itm)
// Get the files information
Status(_("Query"));
- unsigned long Size;
+ unsigned long long Size;
if (Server->Size(File,Size) == false ||
Server->ModTime(File,FailTime) == false)
{
@@ -1025,7 +1028,7 @@ bool FtpMethod::Fetch(FetchItem *Itm)
struct stat Buf;
if (stat(Itm->DestFile.c_str(),&Buf) == 0)
{
- if (Size == (unsigned)Buf.st_size && FailTime == Buf.st_mtime)
+ if (Size == (unsigned long long)Buf.st_size && FailTime == Buf.st_mtime)
{
Res.Size = Buf.st_size;
Res.LastModified = Buf.st_mtime;
@@ -1035,7 +1038,7 @@ bool FtpMethod::Fetch(FetchItem *Itm)
}
// Resume?
- if (FailTime == Buf.st_mtime && Size > (unsigned)Buf.st_size)
+ if (FailTime == Buf.st_mtime && Size > (unsigned long long)Buf.st_size)
Res.ResumePoint = Buf.st_size;
}
diff --git a/methods/ftp.h b/methods/ftp.h
index d7f1f7fbe..2634f0732 100644
--- a/methods/ftp.h
+++ b/methods/ftp.h
@@ -10,6 +10,10 @@
#ifndef APT_FTP_H
#define APT_FTP_H
+#include <apt-pkg/strutl.h>
+
+#include <string>
+
class FTPConn
{
char Buffer[1024*10];
@@ -33,7 +37,7 @@ class FTPConn
socklen_t ServerAddrLen;
// Private helper functions
- bool ReadLine(string &Text);
+ bool ReadLine(std::string &Text);
bool Login();
bool CreateDataFd();
bool Finalize();
@@ -43,8 +47,8 @@ class FTPConn
bool Comp(URI Other) {return Other.Host == ServerName.Host && Other.Port == ServerName.Port && Other.User == ServerName.User && Other.Password == ServerName.Password; };
// Raw connection IO
- bool ReadResp(unsigned int &Ret,string &Text);
- bool WriteMsg(unsigned int &Ret,string &Text,const char *Fmt,...);
+ bool ReadResp(unsigned int &Ret,std::string &Text);
+ bool WriteMsg(unsigned int &Ret,std::string &Text,const char *Fmt,...);
// Connection control
bool Open(pkgAcqMethod *Owner);
@@ -53,9 +57,9 @@ class FTPConn
bool ExtGoPasv();
// Query
- bool Size(const char *Path,unsigned long &Size);
+ bool Size(const char *Path,unsigned long long &Size);
bool ModTime(const char *Path, time_t &Time);
- bool Get(const char *Path,FileFd &To,unsigned long Resume,
+ bool Get(const char *Path,FileFd &To,unsigned long long Resume,
Hashes &MD5,bool &Missing);
FTPConn(URI Srv);
@@ -65,11 +69,11 @@ class FTPConn
class FtpMethod : public pkgAcqMethod
{
virtual bool Fetch(FetchItem *Itm);
- virtual bool Configuration(string Message);
+ virtual bool Configuration(std::string Message);
FTPConn *Server;
- static string FailFile;
+ static std::string FailFile;
static int FailFd;
static time_t FailTime;
static void SigTerm(int);
diff --git a/methods/gpgv.cc b/methods/gpgv.cc
index 3ad3e8d84..2b2aba017 100644
--- a/methods/gpgv.cc
+++ b/methods/gpgv.cc
@@ -1,9 +1,11 @@
+#include <config.h>
+
#include <apt-pkg/error.h>
#include <apt-pkg/acquire-method.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/indexcopy.h>
-#include <apti18n.h>
+#include <apt-pkg/configuration.h>
#include <utime.h>
#include <stdio.h>
@@ -12,9 +14,13 @@
#include <sys/wait.h>
#include <iostream>
#include <sstream>
-
#include <vector>
+#include <apti18n.h>
+
+using std::string;
+using std::vector;
+
#define GNUPGPREFIX "[GNUPG:]"
#define GNUPGBADSIG "[GNUPG:] BADSIG"
#define GNUPGNOPUBKEY "[GNUPG:] NO_PUBKEY"
diff --git a/methods/gzip.cc b/methods/gzip.cc
index fc4e1ecfd..a51497948 100644
--- a/methods/gzip.cc
+++ b/methods/gzip.cc
@@ -9,6 +9,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/fileutl.h>
#include <apt-pkg/error.h>
#include <apt-pkg/acquire-method.h>
@@ -39,7 +41,7 @@ class GzipMethod : public pkgAcqMethod
bool GzipMethod::Fetch(FetchItem *Itm)
{
URI Get = Itm->Uri;
- string Path = Get.Host + Get.Path; // To account for relative paths
+ std::string Path = Get.Host + Get.Path; // To account for relative paths
FetchResult Res;
Res.Filename = Itm->DestFile;
@@ -62,7 +64,7 @@ bool GzipMethod::Fetch(FetchItem *Itm)
while (1)
{
unsigned char Buffer[4*1024];
- unsigned long Count;
+ unsigned long long Count = 0;
if (!From.Read(Buffer,sizeof(Buffer),&Count))
{
diff --git a/methods/http.cc b/methods/http.cc
index 65a0cbbb7..0d81c73ed 100644
--- a/methods/http.cc
+++ b/methods/http.cc
@@ -25,8 +25,11 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/fileutl.h>
#include <apt-pkg/acquire-method.h>
+#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
#include <apt-pkg/hashes.h>
#include <apt-pkg/netrc.h>
@@ -41,8 +44,6 @@
#include <string.h>
#include <iostream>
#include <map>
-#include <apti18n.h>
-
// Internet stuff
#include <netdb.h>
@@ -51,6 +52,8 @@
#include "connect.h"
#include "rfc2553emu.h"
#include "http.h"
+
+#include <apti18n.h>
/*}}}*/
using namespace std;
@@ -63,15 +66,15 @@ bool AllowRedirect = false;
bool Debug = false;
URI Proxy;
-unsigned long CircleBuf::BwReadLimit=0;
-unsigned long CircleBuf::BwTickReadData=0;
+unsigned long long CircleBuf::BwReadLimit=0;
+unsigned long long CircleBuf::BwTickReadData=0;
struct timeval CircleBuf::BwReadTick={0,0};
const unsigned int CircleBuf::BW_HZ=10;
// CircleBuf::CircleBuf - Circular input buffer /*{{{*/
// ---------------------------------------------------------------------
/* */
-CircleBuf::CircleBuf(unsigned long Size) : Size(Size), Hash(0)
+CircleBuf::CircleBuf(unsigned long long Size) : Size(Size), Hash(0)
{
Buf = new unsigned char[Size];
Reset();
@@ -87,7 +90,7 @@ void CircleBuf::Reset()
InP = 0;
OutP = 0;
StrPos = 0;
- MaxGet = (unsigned int)-1;
+ MaxGet = (unsigned long long)-1;
OutQueue = string();
if (Hash != 0)
{
@@ -102,7 +105,7 @@ void CircleBuf::Reset()
is non-blocking.. */
bool CircleBuf::Read(int Fd)
{
- unsigned long BwReadMax;
+ unsigned long long BwReadMax;
while (1)
{
@@ -117,7 +120,7 @@ bool CircleBuf::Read(int Fd)
struct timeval now;
gettimeofday(&now,0);
- unsigned long d = (now.tv_sec-CircleBuf::BwReadTick.tv_sec)*1000000 +
+ unsigned long long d = (now.tv_sec-CircleBuf::BwReadTick.tv_sec)*1000000 +
now.tv_usec-CircleBuf::BwReadTick.tv_usec;
if(d > 1000000/BW_HZ) {
CircleBuf::BwReadTick = now;
@@ -131,7 +134,7 @@ bool CircleBuf::Read(int Fd)
}
// Write the buffer segment
- int Res;
+ ssize_t Res;
if(CircleBuf::BwReadLimit) {
Res = read(Fd,Buf + (InP%Size),
BwReadMax > LeftRead() ? LeftRead() : BwReadMax);
@@ -180,7 +183,7 @@ void CircleBuf::FillOut()
return;
// Write the buffer segment
- unsigned long Sz = LeftRead();
+ unsigned long long Sz = LeftRead();
if (OutQueue.length() - StrPos < Sz)
Sz = OutQueue.length() - StrPos;
memcpy(Buf + (InP%Size),OutQueue.c_str() + StrPos,Sz);
@@ -214,7 +217,7 @@ bool CircleBuf::Write(int Fd)
return true;
// Write the buffer segment
- int Res;
+ ssize_t Res;
Res = write(Fd,Buf + (OutP%Size),LeftWrite());
if (Res == 0)
@@ -240,7 +243,7 @@ bool CircleBuf::Write(int Fd)
bool CircleBuf::WriteTillEl(string &Data,bool Single)
{
// We cheat and assume it is unneeded to have more than one buffer load
- for (unsigned long I = OutP; I < InP; I++)
+ for (unsigned long long I = OutP; I < InP; I++)
{
if (Buf[I%Size] != '\n')
continue;
@@ -258,7 +261,7 @@ bool CircleBuf::WriteTillEl(string &Data,bool Single)
Data = "";
while (OutP < I)
{
- unsigned long Sz = LeftWrite();
+ unsigned long long Sz = LeftWrite();
if (Sz == 0)
return false;
if (I - OutP < Sz)
@@ -286,6 +289,11 @@ void CircleBuf::Stats()
clog << "Got " << InP << " in " << Diff << " at " << InP/Diff << endl;*/
}
/*}}}*/
+CircleBuf::~CircleBuf()
+{
+ delete [] Buf;
+ delete Hash;
+}
// ServerState::ServerState - Constructor /*{{{*/
// ---------------------------------------------------------------------
@@ -453,7 +461,7 @@ bool ServerState::RunData()
return false;
// See if we are done
- unsigned long Len = strtol(Data.c_str(),0,16);
+ unsigned long long Len = strtoull(Data.c_str(),0,16);
if (Len == 0)
{
In.Limit(-1);
@@ -596,7 +604,7 @@ bool ServerState::HeaderLine(string Line)
if (StartPos != 0)
return true;
- if (sscanf(Val.c_str(),"%lu",&Size) != 1)
+ if (sscanf(Val.c_str(),"%llu",&Size) != 1)
return _error->Error(_("The HTTP server sent an invalid Content-Length header"));
return true;
}
@@ -611,9 +619,9 @@ bool ServerState::HeaderLine(string Line)
{
HaveContent = true;
- if (sscanf(Val.c_str(),"bytes %lu-%*u/%lu",&StartPos,&Size) != 2)
+ if (sscanf(Val.c_str(),"bytes %llu-%*u/%llu",&StartPos,&Size) != 2)
return _error->Error(_("The HTTP server sent an invalid Content-Range header"));
- if ((unsigned)StartPos > Size)
+ if ((unsigned long long)StartPos > Size)
return _error->Error(_("This HTTP server has broken range support"));
return true;
}
@@ -716,7 +724,7 @@ void HttpMethod::SendReq(FetchItem *Itm,CircleBuf &Out)
if (stat(Itm->DestFile.c_str(),&SBuf) >= 0 && SBuf.st_size > 0)
{
// In this case we send an if-range query with a range header
- sprintf(Buf,"Range: bytes=%li-\r\nIf-Range: %s\r\n",(long)SBuf.st_size - 1,
+ sprintf(Buf,"Range: bytes=%lli-\r\nIf-Range: %s\r\n",(long long)SBuf.st_size - 1,
TimeRFC1123(SBuf.st_mtime).c_str());
Req += Buf;
}
diff --git a/methods/http.h b/methods/http.h
index 6302807c5..c73d4df5c 100644
--- a/methods/http.h
+++ b/methods/http.h
@@ -13,39 +13,42 @@
#define MAXLEN 360
-#include <apt-pkg/hashes.h>
+#include <apt-pkg/strutl.h>
+
+#include <string>
using std::cout;
using std::endl;
class HttpMethod;
+class Hashes;
class CircleBuf
{
unsigned char *Buf;
- unsigned long Size;
- unsigned long InP;
- unsigned long OutP;
- string OutQueue;
- unsigned long StrPos;
- unsigned long MaxGet;
+ unsigned long long Size;
+ unsigned long long InP;
+ unsigned long long OutP;
+ std::string OutQueue;
+ unsigned long long StrPos;
+ unsigned long long MaxGet;
struct timeval Start;
- static unsigned long BwReadLimit;
- static unsigned long BwTickReadData;
+ static unsigned long long BwReadLimit;
+ static unsigned long long BwTickReadData;
static struct timeval BwReadTick;
static const unsigned int BW_HZ;
- unsigned long LeftRead() const
+ unsigned long long LeftRead() const
{
- unsigned long Sz = Size - (InP - OutP);
+ unsigned long long Sz = Size - (InP - OutP);
if (Sz > Size - (InP%Size))
Sz = Size - (InP%Size);
return Sz;
}
- unsigned long LeftWrite() const
+ unsigned long long LeftWrite() const
{
- unsigned long Sz = InP - OutP;
+ unsigned long long Sz = InP - OutP;
if (InP > MaxGet)
Sz = MaxGet - OutP;
if (Sz > Size - (OutP%Size))
@@ -60,14 +63,14 @@ class CircleBuf
// Read data in
bool Read(int Fd);
- bool Read(string Data);
+ bool Read(std::string Data);
// Write data out
bool Write(int Fd);
- bool WriteTillEl(string &Data,bool Single = false);
+ bool WriteTillEl(std::string &Data,bool Single = false);
// Control the write limit
- void Limit(long Max) {if (Max == -1) MaxGet = 0-1; else MaxGet = OutP + Max;}
+ void Limit(long long Max) {if (Max == -1) MaxGet = 0-1; else MaxGet = OutP + Max;}
bool IsLimit() const {return MaxGet == OutP;};
void Print() const {cout << MaxGet << ',' << OutP << endl;};
@@ -79,8 +82,8 @@ class CircleBuf
void Reset();
void Stats();
- CircleBuf(unsigned long Size);
- ~CircleBuf() {delete [] Buf; delete Hash;};
+ CircleBuf(unsigned long long Size);
+ ~CircleBuf();
};
struct ServerState
@@ -92,14 +95,14 @@ struct ServerState
char Code[MAXLEN];
// These are some statistics from the last parsed header lines
- unsigned long Size;
- signed long StartPos;
+ unsigned long long Size;
+ signed long long StartPos;
time_t Date;
bool HaveContent;
enum {Chunked,Stream,Closes} Encoding;
enum {Header, Data} State;
bool Persistent;
- string Location;
+ std::string Location;
// This is a Persistent attribute of the server itself.
bool Pipeline;
@@ -112,7 +115,7 @@ struct ServerState
int ServerFd;
URI ServerName;
- bool HeaderLine(string Line);
+ bool HeaderLine(std::string Line);
bool Comp(URI Other) const {return Other.Host == ServerName.Host && Other.Port == ServerName.Port;};
void Reset() {Major = 0; Minor = 0; Result = 0; Size = 0; StartPos = 0;
Encoding = Closes; time(&Date); ServerFd = -1;
@@ -167,10 +170,10 @@ class HttpMethod : public pkgAcqMethod
/** \brief Try to AutoDetect the proxy */
bool AutoDetectProxy();
- virtual bool Configuration(string Message);
+ virtual bool Configuration(std::string Message);
// In the event of a fatal signal this file will be closed and timestamped.
- static string FailFile;
+ static std::string FailFile;
static int FailFd;
static time_t FailTime;
static void SigTerm(int);
@@ -178,8 +181,8 @@ class HttpMethod : public pkgAcqMethod
protected:
virtual bool Fetch(FetchItem *);
- string NextURI;
- string AutoDetectProxyCmd;
+ std::string NextURI;
+ std::string AutoDetectProxyCmd;
public:
friend struct ServerState;
diff --git a/methods/http_main.cc b/methods/http_main.cc
index 7815c2fc1..2ca91bfc9 100644
--- a/methods/http_main.cc
+++ b/methods/http_main.cc
@@ -1,3 +1,5 @@
+#include <config.h>
+
#include <apt-pkg/fileutl.h>
#include <apt-pkg/acquire-method.h>
#include <signal.h>
diff --git a/methods/https.cc b/methods/https.cc
index 668a329e6..335699907 100644
--- a/methods/https.cc
+++ b/methods/https.cc
@@ -10,11 +10,14 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/fileutl.h>
#include <apt-pkg/acquire-method.h>
#include <apt-pkg/error.h>
#include <apt-pkg/hashes.h>
#include <apt-pkg/netrc.h>
+#include <apt-pkg/configuration.h>
#include <sys/stat.h>
#include <sys/time.h>
@@ -25,12 +28,11 @@
#include <errno.h>
#include <string.h>
#include <iostream>
-#include <apti18n.h>
#include <sstream>
#include "config.h"
#include "https.h"
-
+#include <apti18n.h>
/*}}}*/
using namespace std;
@@ -51,7 +53,7 @@ HttpsMethod::progress_callback(void *clientp, double dltotal, double dlnow,
{
HttpsMethod *me = (HttpsMethod *)clientp;
if(dltotal > 0 && me->Res.Size == 0) {
- me->Res.Size = (unsigned long)dltotal;
+ me->Res.Size = (unsigned long long)dltotal;
me->URIStart(me->Res);
}
return 0;
diff --git a/methods/https.h b/methods/https.h
index 3f0c416b6..b7adeb880 100644
--- a/methods/https.h
+++ b/methods/https.h
@@ -20,7 +20,7 @@ using std::cout;
using std::endl;
class HttpsMethod;
-
+class FileFd;
class HttpsMethod : public pkgAcqMethod
{
@@ -45,6 +45,7 @@ class HttpsMethod : public pkgAcqMethod
};
};
+#include <apt-pkg/strutl.h>
URI Proxy;
#endif
diff --git a/methods/mirror.cc b/methods/mirror.cc
index a3e60ab15..3d5983efa 100644
--- a/methods/mirror.cc
+++ b/methods/mirror.cc
@@ -8,6 +8,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/acquire-method.h>
@@ -16,7 +18,8 @@
#include <apt-pkg/error.h>
#include <apt-pkg/hashes.h>
#include <apt-pkg/sourcelist.h>
-
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/metaindex.h>
#include <algorithm>
#include <fstream>
@@ -34,7 +37,7 @@ using namespace std;
#include "mirror.h"
#include "http.h"
-#include "apti18n.h"
+#include <apti18n.h>
/*}}}*/
/* Done:
diff --git a/methods/mirror.h b/methods/mirror.h
index 97d18144a..81e531e21 100644
--- a/methods/mirror.h
+++ b/methods/mirror.h
@@ -11,8 +11,9 @@
#ifndef APT_MIRROR_H
#define APT_MIRROR_H
-
#include <iostream>
+#include <string>
+#include <vector>
using std::cout;
using std::cerr;
@@ -24,29 +25,29 @@ class MirrorMethod : public HttpMethod
{
FetchResult Res;
// we simply transform between BaseUri and Mirror
- string BaseUri; // the original mirror://... url
- string Mirror; // the selected mirror uri (http://...)
- vector<string> AllMirrors; // all available mirrors
- string MirrorFile; // the file that contains the list of mirrors
+ std::string BaseUri; // the original mirror://... url
+ std::string Mirror; // the selected mirror uri (http://...)
+ std::vector<std::string> AllMirrors; // all available mirrors
+ std::string MirrorFile; // the file that contains the list of mirrors
bool DownloadedMirrorFile; // already downloaded this session
- string Dist; // the target distrubtion (e.g. sid, oneiric)
+ std::string Dist; // the target distrubtion (e.g. sid, oneiric)
bool Debug;
protected:
- bool DownloadMirrorFile(string uri);
- bool RandomizeMirrorFile(string file);
- string GetMirrorFileName(string uri);
+ bool DownloadMirrorFile(std::string uri);
+ bool RandomizeMirrorFile(std::string file);
+ std::string GetMirrorFileName(std::string uri);
bool InitMirrors();
bool TryNextMirror();
void CurrentQueueUriToMirror();
- bool Clean(string dir);
+ bool Clean(std::string dir);
// we need to overwrite those to transform the url back
- virtual void Fail(string Why, bool Transient = false);
+ virtual void Fail(std::string Why, bool Transient = false);
virtual void URIStart(FetchResult &Res);
virtual void URIDone(FetchResult &Res,FetchResult *Alt = 0);
- virtual bool Configuration(string Message);
+ virtual bool Configuration(std::string Message);
public:
MirrorMethod();
diff --git a/methods/rfc2553emu.cc b/methods/rfc2553emu.cc
index 66bc906e9..f00e85889 100644
--- a/methods/rfc2553emu.cc
+++ b/methods/rfc2553emu.cc
@@ -14,12 +14,14 @@
##################################################################### */
/*}}}*/
-#include "rfc2553emu.h"
+#include <config.h>
+
#include <stdlib.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <string.h>
#include <stdio.h>
+#include "rfc2553emu.h"
#ifndef HAVE_GETADDRINFO
// getaddrinfo - Resolve a hostname /*{{{*/
diff --git a/methods/rred.cc b/methods/rred.cc
index 6c55880ca..ef00fcaa3 100644
--- a/methods/rred.cc
+++ b/methods/rred.cc
@@ -1,10 +1,13 @@
// Includes /*{{{*/
+#include <config.h>
+
#include <apt-pkg/fileutl.h>
#include <apt-pkg/mmap.h>
#include <apt-pkg/error.h>
#include <apt-pkg/acquire-method.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/hashes.h>
+#include <apt-pkg/configuration.h>
#include <sys/stat.h>
#include <sys/uio.h>
@@ -257,7 +260,7 @@ RredMethod::State RredMethod::patchMMap(FileFd &Patch, FileFd &From, /*{{{*/
#ifdef _POSIX_MAPPED_FILES
MMap ed_cmds(MMap::ReadOnly);
if (Patch.gzFd() != NULL) {
- unsigned long mapSize = Patch.Size();
+ unsigned long long mapSize = Patch.Size();
DynamicMMap* dyn = new DynamicMMap(0, mapSize, 0);
if (dyn->validData() == false) {
delete dyn;
@@ -470,7 +473,7 @@ bool RredMethod::Fetch(FetchItem *Itm) /*{{{*/
{
Debug = _config->FindB("Debug::pkgAcquire::RRed", false);
URI Get = Itm->Uri;
- string Path = Get.Host + Get.Path; // To account for relative paths
+ std::string Path = Get.Host + Get.Path; // To account for relative paths
FetchResult Res;
Res.Filename = Itm->DestFile;
@@ -523,7 +526,7 @@ bool RredMethod::Fetch(FetchItem *Itm) /*{{{*/
and use the access time from the "old" file */
struct stat BufBase, BufPatch;
if (stat(Path.c_str(),&BufBase) != 0 ||
- stat(string(Path+".ed").c_str(),&BufPatch) != 0)
+ stat(std::string(Path+".ed").c_str(),&BufPatch) != 0)
return _error->Errno("stat",_("Failed to stat"));
struct utimbuf TimeBuf;
diff --git a/methods/rsh.cc b/methods/rsh.cc
index 21f0d0a22..da9777fc4 100644
--- a/methods/rsh.cc
+++ b/methods/rsh.cc
@@ -11,8 +11,12 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#include "rsh.h"
+#include <config.h>
+
#include <apt-pkg/error.h>
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/hashes.h>
+#include <apt-pkg/configuration.h>
#include <sys/stat.h>
#include <sys/time.h>
@@ -22,6 +26,8 @@
#include <stdio.h>
#include <errno.h>
#include <stdarg.h>
+#include "rsh.h"
+
#include <apti18n.h>
/*}}}*/
@@ -29,7 +35,7 @@ const char *Prog;
unsigned long TimeOut = 120;
Configuration::Item const *RshOptions = 0;
time_t RSHMethod::FailTime = 0;
-string RSHMethod::FailFile;
+std::string RSHMethod::FailFile;
int RSHMethod::FailFd = -1;
// RSHConn::RSHConn - Constructor /*{{{*/
@@ -82,7 +88,7 @@ bool RSHConn::Open()
// RSHConn::Connect - Fire up rsh and connect /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool RSHConn::Connect(string Host, string User)
+bool RSHConn::Connect(std::string Host, std::string User)
{
// Create the pipes
int Pipes[4] = {-1,-1,-1,-1};
@@ -151,7 +157,7 @@ bool RSHConn::Connect(string Host, string User)
// RSHConn::ReadLine - Very simple buffered read with timeout /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool RSHConn::ReadLine(string &Text)
+bool RSHConn::ReadLine(std::string &Text)
{
if (Process == -1 || ReadFd == -1)
return false;
@@ -171,7 +177,7 @@ bool RSHConn::ReadLine(string &Text)
continue;
I++;
- Text = string(Buffer,I);
+ Text = std::string(Buffer,I);
memmove(Buffer,Buffer+I,Len - I);
Len -= I;
return true;
@@ -202,7 +208,7 @@ bool RSHConn::ReadLine(string &Text)
// ---------------------------------------------------------------------
/* The remote sync flag appends a || echo which will insert blank line
once the command completes. */
-bool RSHConn::WriteMsg(string &Text,bool Sync,const char *Fmt,...)
+bool RSHConn::WriteMsg(std::string &Text,bool Sync,const char *Fmt,...)
{
va_list args;
va_start(args,Fmt);
@@ -248,10 +254,10 @@ bool RSHConn::WriteMsg(string &Text,bool Sync,const char *Fmt,...)
// ---------------------------------------------------------------------
/* Right now for successfull transfer the file size must be known in
advance. */
-bool RSHConn::Size(const char *Path,unsigned long &Size)
+bool RSHConn::Size(const char *Path,unsigned long long &Size)
{
// Query the size
- string Msg;
+ std::string Msg;
Size = 0;
if (WriteMsg(Msg,true,"find %s -follow -printf '%%s\\n'",Path) == false)
@@ -260,7 +266,7 @@ bool RSHConn::Size(const char *Path,unsigned long &Size)
// FIXME: Sense if the bad reply is due to a File Not Found.
char *End;
- Size = strtoul(Msg.c_str(),&End,10);
+ Size = strtoull(Msg.c_str(),&End,10);
if (End == Msg.c_str())
return _error->Error(_("File not found"));
return true;
@@ -273,7 +279,7 @@ bool RSHConn::ModTime(const char *Path, time_t &Time)
{
Time = time(&Time);
// Query the mod time
- string Msg;
+ std::string Msg;
if (WriteMsg(Msg,true,"TZ=UTC find %s -follow -printf '%%TY%%Tm%%Td%%TH%%TM%%TS\\n'",Path) == false)
return false;
@@ -285,8 +291,8 @@ bool RSHConn::ModTime(const char *Path, time_t &Time)
// RSHConn::Get - Get a file /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool RSHConn::Get(const char *Path,FileFd &To,unsigned long Resume,
- Hashes &Hash,bool &Missing, unsigned long Size)
+bool RSHConn::Get(const char *Path,FileFd &To,unsigned long long Resume,
+ Hashes &Hash,bool &Missing, unsigned long long Size)
{
Missing = false;
@@ -306,12 +312,12 @@ bool RSHConn::Get(const char *Path,FileFd &To,unsigned long Resume,
}
// FIXME: Detect file-not openable type errors.
- string Jnk;
+ std::string Jnk;
if (WriteMsg(Jnk,false,"dd if=%s bs=2048 skip=%u", Path, Resume / 2048) == false)
return false;
// Copy loop
- unsigned int MyLen = Resume;
+ unsigned long long MyLen = Resume;
unsigned char Buffer[4096];
while (MyLen < Size)
{
@@ -363,7 +369,7 @@ RSHMethod::RSHMethod() : pkgAcqMethod("1.0",SendConfig)
/*}}}*/
// RSHMethod::Configuration - Handle a configuration message /*{{{*/
// ---------------------------------------------------------------------
-bool RSHMethod::Configuration(string Message)
+bool RSHMethod::Configuration(std::string Message)
{
char ProgStr[100];
@@ -425,7 +431,7 @@ bool RSHMethod::Fetch(FetchItem *Itm)
Status(_("Connecting to %s"), Get.Host.c_str());
// Get the files information
- unsigned long Size;
+ unsigned long long Size;
if (Server->Size(File,Size) == false ||
Server->ModTime(File,FailTime) == false)
{
@@ -446,7 +452,7 @@ bool RSHMethod::Fetch(FetchItem *Itm)
// See if the file exists
struct stat Buf;
if (stat(Itm->DestFile.c_str(),&Buf) == 0) {
- if (Size == (unsigned)Buf.st_size && FailTime == Buf.st_mtime) {
+ if (Size == (unsigned long long)Buf.st_size && FailTime == Buf.st_mtime) {
Res.Size = Buf.st_size;
Res.LastModified = Buf.st_mtime;
Res.ResumePoint = Buf.st_size;
@@ -455,7 +461,7 @@ bool RSHMethod::Fetch(FetchItem *Itm)
}
// Resume?
- if (FailTime == Buf.st_mtime && Size > (unsigned)Buf.st_size)
+ if (FailTime == Buf.st_mtime && Size > (unsigned long long)Buf.st_size)
Res.ResumePoint = Buf.st_size;
}
diff --git a/methods/rsh.h b/methods/rsh.h
index 98ca6a88c..d7efa3f06 100644
--- a/methods/rsh.h
+++ b/methods/rsh.h
@@ -12,9 +12,9 @@
#include <string>
#include <apt-pkg/strutl.h>
-#include <apt-pkg/hashes.h>
-#include <apt-pkg/acquire-method.h>
-#include <apt-pkg/fileutl.h>
+
+class Hashes;
+class FileFd;
class RSHConn
{
@@ -25,15 +25,15 @@ class RSHConn
URI ServerName;
// Private helper functions
- bool ReadLine(string &Text);
+ bool ReadLine(std::string &Text);
public:
pid_t Process;
// Raw connection IO
- bool WriteMsg(string &Text,bool Sync,const char *Fmt,...);
- bool Connect(string Host, string User);
+ bool WriteMsg(std::string &Text,bool Sync,const char *Fmt,...);
+ bool Connect(std::string Host, std::string User);
bool Comp(URI Other) const {return Other.Host == ServerName.Host && Other.Port == ServerName.Port;};
// Connection control
@@ -41,23 +41,25 @@ class RSHConn
void Close();
// Query
- bool Size(const char *Path,unsigned long &Size);
+ bool Size(const char *Path,unsigned long long &Size);
bool ModTime(const char *Path, time_t &Time);
- bool Get(const char *Path,FileFd &To,unsigned long Resume,
- Hashes &Hash,bool &Missing, unsigned long Size);
+ bool Get(const char *Path,FileFd &To,unsigned long long Resume,
+ Hashes &Hash,bool &Missing, unsigned long long Size);
RSHConn(URI Srv);
~RSHConn();
};
+#include <apt-pkg/acquire-method.h>
+
class RSHMethod : public pkgAcqMethod
{
virtual bool Fetch(FetchItem *Itm);
- virtual bool Configuration(string Message);
+ virtual bool Configuration(std::string Message);
RSHConn *Server;
- static string FailFile;
+ static std::string FailFile;
static int FailFd;
static time_t FailTime;
static void SigTerm(int);