merged from lp:~donkult/apt/experimental
[ntk/apt.git] / methods / rsh.cc
index f0ccfc4..c95a4d3 100644 (file)
@@ -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>
                                                                        /*}}}*/
 
@@ -110,6 +113,8 @@ bool RSHConn::Connect(string Host, string User)
       // Probably should do
       // dup2(open("/dev/null",O_RDONLY),STDERR_FILENO);
 
+      Args[i++] = Prog;
+
       // Insert user-supplied command line options
       Configuration::Item const *Opts = RshOptions;
       if (Opts != 0)
@@ -123,7 +128,6 @@ bool RSHConn::Connect(string Host, string User)
          }
       }
 
-      Args[i++] = Prog;
       if (User.empty() == false) {
          Args[i++] = "-l";
         Args[i++] = User.c_str();
@@ -247,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;
@@ -259,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;
@@ -278,15 +282,14 @@ bool RSHConn::ModTime(const char *Path, time_t &Time)
       return false;
 
    // Parse it
-   StrToTime(Msg,Time);
-   return true;
+   return FTPMDTMStrToTime(Msg.c_str(), 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;
    }