diff options
Diffstat (limited to 'methods')
-rw-r--r-- | methods/bzip2.cc | 2 | ||||
-rw-r--r-- | methods/cdrom.cc | 2 | ||||
-rw-r--r-- | methods/connect.cc | 4 | ||||
-rw-r--r-- | methods/copy.cc | 2 | ||||
-rw-r--r-- | methods/file.cc | 2 | ||||
-rw-r--r-- | methods/ftp.cc | 16 | ||||
-rw-r--r-- | methods/ftp.h | 4 | ||||
-rw-r--r-- | methods/gpgv.cc | 6 | ||||
-rw-r--r-- | methods/gzip.cc | 4 | ||||
-rw-r--r-- | methods/http.cc | 38 | ||||
-rw-r--r-- | methods/http.h | 30 | ||||
-rw-r--r-- | methods/http_main.cc | 2 | ||||
-rw-r--r-- | methods/https.cc | 7 | ||||
-rw-r--r-- | methods/mirror.cc | 4 | ||||
-rw-r--r-- | methods/rfc2553emu.cc | 4 | ||||
-rw-r--r-- | methods/rred.cc | 4 | ||||
-rw-r--r-- | methods/rsh.cc | 21 | ||||
-rw-r--r-- | methods/rsh.h | 6 |
18 files changed, 94 insertions, 64 deletions
diff --git a/methods/bzip2.cc b/methods/bzip2.cc index 42932dded..eff83bda7 100644 --- a/methods/bzip2.cc +++ b/methods/bzip2.cc @@ -13,6 +13,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include <config.h> + #include <apt-pkg/fileutl.h> #include <apt-pkg/error.h> #include <apt-pkg/acquire-method.h> diff --git a/methods/cdrom.cc b/methods/cdrom.cc index ae699dfc3..bc115d259 100644 --- a/methods/cdrom.cc +++ b/methods/cdrom.cc @@ -8,6 +8,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include <config.h> + #include <apt-pkg/acquire-method.h> #include <apt-pkg/cdrom.h> #include <apt-pkg/cdromutl.h> diff --git a/methods/connect.cc b/methods/connect.cc index a5af1f1a6..16fb6e793 100644 --- a/methods/connect.cc +++ b/methods/connect.cc @@ -11,7 +11,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ -#include "connect.h" +#include <config.h> + #include <apt-pkg/error.h> #include <apt-pkg/fileutl.h> @@ -29,6 +30,7 @@ #include <arpa/inet.h> #include <netdb.h> +#include "connect.h" #include "rfc2553emu.h" #include <apti18n.h> /*}}}*/ diff --git a/methods/copy.cc b/methods/copy.cc index a6bb372a3..94467e054 100644 --- a/methods/copy.cc +++ b/methods/copy.cc @@ -9,6 +9,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include <config.h> + #include <apt-pkg/fileutl.h> #include <apt-pkg/acquire-method.h> #include <apt-pkg/error.h> diff --git a/methods/file.cc b/methods/file.cc index 9cdd5bc2d..9fc4cd76c 100644 --- a/methods/file.cc +++ b/methods/file.cc @@ -13,6 +13,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include <config.h> + #include <apt-pkg/acquire-method.h> #include <apt-pkg/error.h> #include <apt-pkg/hashes.h> diff --git a/methods/ftp.cc b/methods/ftp.cc index eb7fedd85..861647aea 100644 --- a/methods/ftp.cc +++ b/methods/ftp.cc @@ -15,6 +15,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include <config.h> + #include <apt-pkg/fileutl.h> #include <apt-pkg/acquire-method.h> #include <apt-pkg/error.h> @@ -30,7 +32,6 @@ #include <errno.h> #include <stdarg.h> #include <iostream> -#include <apti18n.h> // Internet stuff #include <netinet/in.h> @@ -41,6 +42,7 @@ #include "rfc2553emu.h" #include "connect.h" #include "ftp.h" +#include <apti18n.h> /*}}}*/ using namespace std; @@ -628,7 +630,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 +640,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 +842,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 +1005,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 +1027,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 +1037,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..b4913ca57 100644 --- a/methods/ftp.h +++ b/methods/ftp.h @@ -53,9 +53,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); diff --git a/methods/gpgv.cc b/methods/gpgv.cc index 3ad3e8d84..251bcbc90 100644 --- a/methods/gpgv.cc +++ b/methods/gpgv.cc @@ -1,9 +1,10 @@ +#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 <utime.h> #include <stdio.h> @@ -12,9 +13,10 @@ #include <sys/wait.h> #include <iostream> #include <sstream> - #include <vector> +#include <apti18n.h> + #define GNUPGPREFIX "[GNUPG:]" #define GNUPGBADSIG "[GNUPG:] BADSIG" #define GNUPGNOPUBKEY "[GNUPG:] NO_PUBKEY" diff --git a/methods/gzip.cc b/methods/gzip.cc index fc4e1ecfd..f4bb052e2 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> @@ -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..b60cfeb9e 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -25,6 +25,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include <config.h> + #include <apt-pkg/fileutl.h> #include <apt-pkg/acquire-method.h> #include <apt-pkg/error.h> @@ -41,8 +43,6 @@ #include <string.h> #include <iostream> #include <map> -#include <apti18n.h> - // Internet stuff #include <netdb.h> @@ -51,6 +51,8 @@ #include "connect.h" #include "rfc2553emu.h" #include "http.h" + +#include <apti18n.h> /*}}}*/ using namespace std; @@ -63,15 +65,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 +89,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 +104,7 @@ void CircleBuf::Reset() is non-blocking.. */ bool CircleBuf::Read(int Fd) { - unsigned long BwReadMax; + unsigned long long BwReadMax; while (1) { @@ -117,7 +119,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 +133,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 +182,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 +216,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 +242,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 +260,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) @@ -453,7 +455,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 +598,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 +613,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 +718,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..c47d7184a 100644 --- a/methods/http.h +++ b/methods/http.h @@ -23,29 +23,29 @@ class HttpMethod; class CircleBuf { unsigned char *Buf; - unsigned long Size; - unsigned long InP; - unsigned long OutP; + unsigned long long Size; + unsigned long long InP; + unsigned long long OutP; string OutQueue; - unsigned long StrPos; - unsigned long MaxGet; + 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)) @@ -67,7 +67,7 @@ class CircleBuf bool WriteTillEl(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,7 +79,7 @@ class CircleBuf void Reset(); void Stats(); - CircleBuf(unsigned long Size); + CircleBuf(unsigned long long Size); ~CircleBuf() {delete [] Buf; delete Hash;}; }; @@ -92,8 +92,8 @@ 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; 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 fc649d6c2..06a0e285a 100644 --- a/methods/https.cc +++ b/methods/https.cc @@ -10,6 +10,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include <config.h> + #include <apt-pkg/fileutl.h> #include <apt-pkg/acquire-method.h> #include <apt-pkg/error.h> @@ -25,12 +27,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 +52,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/mirror.cc b/methods/mirror.cc index a3e60ab15..61a7f12fd 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> @@ -34,7 +36,7 @@ using namespace std; #include "mirror.h" #include "http.h" -#include "apti18n.h" +#include <apti18n.h> /*}}}*/ /* Done: 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..bc941ed04 100644 --- a/methods/rred.cc +++ b/methods/rred.cc @@ -1,4 +1,6 @@ // Includes /*{{{*/ +#include <config.h> + #include <apt-pkg/fileutl.h> #include <apt-pkg/mmap.h> #include <apt-pkg/error.h> @@ -257,7 +259,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; diff --git a/methods/rsh.cc b/methods/rsh.cc index 21f0d0a22..c95a4d3eb 100644 --- a/methods/rsh.cc +++ b/methods/rsh.cc @@ -11,7 +11,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ -#include "rsh.h" +#include <config.h> + #include <apt-pkg/error.h> #include <sys/stat.h> @@ -22,6 +23,8 @@ #include <stdio.h> #include <errno.h> #include <stdarg.h> +#include "rsh.h" + #include <apti18n.h> /*}}}*/ @@ -248,7 +251,7 @@ 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; @@ -260,7 +263,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; @@ -285,8 +288,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; @@ -311,7 +314,7 @@ bool RSHConn::Get(const char *Path,FileFd &To,unsigned long Resume, return false; // Copy loop - unsigned int MyLen = Resume; + unsigned long long MyLen = Resume; unsigned char Buffer[4096]; while (MyLen < Size) { @@ -425,7 +428,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 +449,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 +458,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..c81396b5f 100644 --- a/methods/rsh.h +++ b/methods/rsh.h @@ -41,10 +41,10 @@ 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(); |