From ea54214002c09eeb4dd498d97a564471ec9993c5 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 13 Sep 2011 10:09:00 +0200 Subject: reorder includes: add if needed and include it at first --- methods/rsh.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'methods/rsh.cc') diff --git a/methods/rsh.cc b/methods/rsh.cc index 21f0d0a22..10fe76dc3 100644 --- a/methods/rsh.cc +++ b/methods/rsh.cc @@ -11,7 +11,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ -#include "rsh.h" +#include + #include #include @@ -22,6 +23,8 @@ #include #include #include +#include "rsh.h" + #include /*}}}*/ -- cgit v1.2.3 From 650faab01603caac04494d54cf6b10a65c00ea13 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 13 Sep 2011 17:46:48 +0200 Subject: Support large files in the complete toolset. Indexes of this size are pretty unlikely for now, but we need it for deb packages which could become bigger than 4GB now (LP: #815895) --- methods/rsh.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'methods/rsh.cc') diff --git a/methods/rsh.cc b/methods/rsh.cc index 10fe76dc3..c95a4d3eb 100644 --- a/methods/rsh.cc +++ b/methods/rsh.cc @@ -251,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; @@ -263,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; @@ -288,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; @@ -314,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) { @@ -428,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) { @@ -449,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; @@ -458,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; } -- cgit v1.2.3 From 8f3ba4e8708cb72be19dacc2af4f601ee5fea292 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 19 Sep 2011 13:31:29 +0200 Subject: do not pollute namespace in the headers with using (Closes: #500198) --- methods/rsh.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'methods/rsh.cc') diff --git a/methods/rsh.cc b/methods/rsh.cc index c95a4d3eb..add128c49 100644 --- a/methods/rsh.cc +++ b/methods/rsh.cc @@ -32,7 +32,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 /*{{{*/ @@ -85,7 +85,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}; @@ -154,7 +154,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; @@ -174,7 +174,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; @@ -205,7 +205,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); @@ -254,7 +254,7 @@ bool RSHConn::WriteMsg(string &Text,bool Sync,const char *Fmt,...) 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) @@ -276,7 +276,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; @@ -309,7 +309,7 @@ bool RSHConn::Get(const char *Path,FileFd &To,unsigned long 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; @@ -366,7 +366,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]; -- cgit v1.2.3 From 472ff00ef2e48383805d281c6364ec27839e3f4d Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 19 Sep 2011 19:14:19 +0200 Subject: use forward declaration in headers if possible instead of includes --- methods/rsh.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'methods/rsh.cc') diff --git a/methods/rsh.cc b/methods/rsh.cc index add128c49..da9777fc4 100644 --- a/methods/rsh.cc +++ b/methods/rsh.cc @@ -14,6 +14,9 @@ #include #include +#include +#include +#include #include #include -- cgit v1.2.3 From 109eb1511d0cdfa4af3196105cada30bcbb77bc8 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 17 Dec 2011 23:53:31 +0100 Subject: try to avoid direct usage of .Fd() if possible and do read()s and co on the FileFd instead --- methods/rsh.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'methods/rsh.cc') diff --git a/methods/rsh.cc b/methods/rsh.cc index da9777fc4..d249ae961 100644 --- a/methods/rsh.cc +++ b/methods/rsh.cc @@ -305,7 +305,7 @@ bool RSHConn::Get(const char *Path,FileFd &To,unsigned long long Resume, return false; if (Resume != 0) { - if (Hash.AddFD(To.Fd(),Resume) == false) { + if (Hash.AddFD(To,Resume) == false) { _error->Errno("read",_("Problem hashing file")); return false; } -- cgit v1.2.3 From dcaa1185506986142bccd990a5dca4c6ec1228cf Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 4 Mar 2012 23:47:05 +0100 Subject: fix a bunch of cppcheck "(warning) Member variable '<#>' is not initialized in the constructor." messages (no functional change) --- methods/rsh.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'methods/rsh.cc') diff --git a/methods/rsh.cc b/methods/rsh.cc index d249ae961..fb3782314 100644 --- a/methods/rsh.cc +++ b/methods/rsh.cc @@ -42,7 +42,9 @@ int RSHMethod::FailFd = -1; // --------------------------------------------------------------------- /* */ RSHConn::RSHConn(URI Srv) : Len(0), WriteFd(-1), ReadFd(-1), - ServerName(Srv), Process(-1) {} + ServerName(Srv), Process(-1) { + Buffer[0] = '\0'; +} /*}}}*/ // RSHConn::RSHConn - Destructor /*{{{*/ // --------------------------------------------------------------------- -- cgit v1.2.3