changeset 811:789ff8cb3170

2006-9-14 Brian Masney <masneyb@gftp.org> * src/uicommon/gftpui.c - added _do_transfer_file(). This will take care of the actual file transfer. It will also make sure that the entire buffer has been transmitted properly. * lib/protocols.c lib/rfc959.c (*_put_next_file_chunk) - removed unneeded code that checks for a block size of 0 * lib/rfc959.c (rfc959_syst) - disable show_hidden_files and resolve_remote_symlinks if the remote system type is OS/400.
author masneyb
date Thu, 14 Sep 2006 09:07:29 +0000
parents 6cdba64ec675
children 3f1d3d35620b
files ChangeLog lib/protocols.c lib/rfc959.c src/uicommon/gftpui.c
diffstat 4 files changed, 80 insertions(+), 47 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Sep 13 20:50:45 2006 +0000
+++ b/ChangeLog	Thu Sep 14 09:07:29 2006 +0000
@@ -1,3 +1,14 @@
+2006-9-14 Brian Masney <masneyb@gftp.org>
+	* src/uicommon/gftpui.c - added _do_transfer_file(). This will take
+	care of the actual file transfer. It will also make sure that the
+	entire buffer has been transmitted properly.
+
+	* lib/protocols.c lib/rfc959.c (*_put_next_file_chunk) - removed
+	unneeded code that checks for a block size of 0
+
+	* lib/rfc959.c (rfc959_syst) - disable show_hidden_files and
+	resolve_remote_symlinks if the remote system type is OS/400.
+
 2006-8-10 Brian Masney <masneyb@gftp.org>
 	* lib/options.h src/gtk/gftp-gtk.c (_gftp_exit) - added new option:
 	remember_last_directory. This will control whether or not the last
@@ -3564,7 +3575,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.471 2006/09/10 16:18:15 masneyb Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.472 2006/09/14 09:07:24 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- a/lib/protocols.c	Wed Sep 13 20:50:45 2006 +0000
+++ b/lib/protocols.c	Thu Sep 14 09:07:29 2006 +0000
@@ -295,9 +295,6 @@
   if (request->put_next_file_chunk != NULL)
     return (request->put_next_file_chunk (request, buf, size));
 
-  if (size == 0)
-    return (0);
-
   return (request->write_function (request, buf, size, request->datafd));
 }
 
--- a/lib/rfc959.c	Wed Sep 13 20:50:45 2006 +0000
+++ b/lib/rfc959.c	Thu Sep 14 09:07:29 2006 +0000
@@ -388,9 +388,9 @@
 static int
 rfc959_syst (gftp_request * request)
 {
+  int ret, disable_ls_options;
   rfc959_parms * parms;
   char *stpos, *endpos;
-  int ret;
 
   g_return_val_if_fail (request != NULL, GFTP_EFATAL);
   g_return_val_if_fail (request->datafd > 0, GFTP_EFATAL);
@@ -412,14 +412,13 @@
     return (GFTP_ERETRYABLE);
 
   *endpos = '\0';
+  disable_ls_options = 0;
 
   if (strcmp (stpos, "UNIX") == 0)
     request->server_type = GFTP_DIRTYPE_UNIX;
   else if (strcmp (stpos, "VMS") == 0)
     {
-      gftp_set_request_option (request, "show_hidden_files",
-                               GINT_TO_POINTER(0));
-      gftp_set_request_option (request, "resolve_symlinks", GINT_TO_POINTER(0));
+      disable_ls_options = 1;
       request->server_type = GFTP_DIRTYPE_VMS;
     }
   else if (strcmp (stpos, "MVS") == 0 ||
@@ -432,6 +431,16 @@
   else
     request->server_type = GFTP_DIRTYPE_OTHER;
 
+  if (strcmp (stpos, "OS/400") == 0)
+    disable_ls_options = 1;
+
+  if (disable_ls_options)
+    {
+      gftp_set_request_option (request, "show_hidden_files",
+                               GINT_TO_POINTER(0));
+      gftp_set_request_option (request, "resolve_symlinks", GINT_TO_POINTER(0));
+    }
+
   return (0);
 }
 
@@ -1440,9 +1449,6 @@
   ssize_t num_wrote;
   char *tempstr;
 
-  if (size == 0)
-    return (0);
-
   parms = request->protocol_data;
 
   if (parms->is_fxp_transfer)
--- a/src/uicommon/gftpui.c	Wed Sep 13 20:50:45 2006 +0000
+++ b/src/uicommon/gftpui.c	Thu Sep 14 09:07:29 2006 +0000
@@ -1291,18 +1291,64 @@
 
 
 int
-gftpui_common_transfer_files (gftp_transfer * tdata)
+_do_transfer_file (gftp_transfer * tdata)
 {
-  intptr_t preserve_permissions, preserve_time, trans_blksize;
   struct timeval updatetime;
+  intptr_t trans_blksize;
   ssize_t num_read, ret;
-  gftp_file * curfle; 
-  int tofd, fromfd;
-  char *buf;
+  char *buf, *bufpos;
 
   gftp_lookup_request_option (tdata->fromreq, "trans_blksize", &trans_blksize);
   buf = g_malloc (trans_blksize);
 
+  memset (&updatetime, 0, sizeof (updatetime));
+  gftpui_start_current_file_in_transfer (tdata);
+
+  while (!tdata->cancel &&
+         (num_read = gftp_get_next_file_chunk (tdata->fromreq, buf,
+                                               trans_blksize)) > 0)
+    {
+      gftp_calc_kbs (tdata, num_read);
+      if (tdata->lasttime.tv_sec - updatetime.tv_sec >= 1 ||
+          tdata->curtrans >= tdata->tot_file_trans)
+        {
+          gftpui_update_current_file_in_transfer (tdata);
+          memcpy (&updatetime, &tdata->lasttime, sizeof (updatetime));
+        }
+
+      bufpos = buf;
+      while (num_read > 0)
+        {
+          if ((ret = gftp_put_next_file_chunk (tdata->toreq, bufpos,
+                                               num_read)) <= 0)
+            {
+              num_read = ret;
+              break;
+            }
+
+          num_read -= ret;
+          bufpos += ret;
+        }
+    }
+
+  if (num_read == GFTP_ENOTRANS)
+    num_read = 0;
+
+  g_free (buf);
+  gftpui_finish_current_file_in_transfer (tdata);
+
+  return ((int) num_read);
+}
+
+
+int
+gftpui_common_transfer_files (gftp_transfer * tdata)
+{
+  intptr_t preserve_permissions, preserve_time;
+  gftp_file * curfle; 
+  int tofd, fromfd;
+  int ret;
+
   tdata->curfle = tdata->files;
   gettimeofday (&tdata->starttime, NULL);
   memcpy (&tdata->lasttime, &tdata->starttime, sizeof (tdata->lasttime));
@@ -1314,7 +1360,7 @@
 
   while (tdata->curfle != NULL)
     {
-      num_read = -1;
+      ret = -1;
 
       if (g_thread_supported ())
         g_static_mutex_lock (&tdata->structmutex);
@@ -1424,33 +1470,7 @@
           if (g_thread_supported ())
             g_static_mutex_unlock (&tdata->structmutex);
 
-          memset (&updatetime, 0, sizeof (updatetime));
-          gftpui_start_current_file_in_transfer (tdata);
-
-          while (!tdata->cancel &&
-                 (num_read = gftp_get_next_file_chunk (tdata->fromreq,
-                                                       buf, trans_blksize)) > 0)
-            {
-              gftp_calc_kbs (tdata, num_read);
-              if (tdata->lasttime.tv_sec - updatetime.tv_sec >= 1 ||
-                  tdata->curtrans >= tdata->tot_file_trans)
-                {
-                  gftpui_update_current_file_in_transfer (tdata);
-                  memcpy (&updatetime, &tdata->lasttime, sizeof (updatetime));
-                }
-
-              if ((ret = gftp_put_next_file_chunk (tdata->toreq, buf,
-                                                   num_read)) < 0)
-                {
-                  num_read = (int) ret;
-                  break;
-                }
-            }
-
-          if (num_read == GFTP_ENOTRANS)
-            num_read = 0;
-
-          gftpui_finish_current_file_in_transfer (tdata);
+          ret = _do_transfer_file (tdata);
         }
 
       if (tdata->cancel)
@@ -1461,7 +1481,7 @@
           if (gftp_abort_transfer (tdata->toreq) != 0)
             gftp_disconnect (tdata->toreq);
         }
-      else if (num_read < 0)
+      else if (ret < 0)
         {
           tdata->fromreq->logging_function (gftp_logging_error,
                                         tdata->fromreq,
@@ -1469,7 +1489,7 @@
                                         curfle->file,
                                         tdata->fromreq->hostname);
 
-          if (gftp_get_transfer_status (tdata, num_read) == GFTP_ERETRYABLE)
+          if (gftp_get_transfer_status (tdata, ret) == GFTP_ERETRYABLE)
             continue;
 
           break;
@@ -1531,7 +1551,6 @@
     }
 
   tdata->done = 1;
-  g_free (buf);
 
   return (1);
 }