changeset 895:4ab11f70a7f4

2007-3-15 Brian Masney <masneyb@gftp.org> * lib/sshv2.c lib/gftp.h lib/rfc959.c lib/protocols.c lib/fsp.c lib/local.c lib/rfc2068.c src/uicommon/gftpui.c - removed fd argument to *_get_file(), *_put_file() and gftp_transfer_file().
author masneyb
date Fri, 16 Mar 2007 02:44:07 +0000
parents 14476a8a4d2b
children 5b7b1d5ac06e
files ChangeLog lib/fsp.c lib/gftp.h lib/local.c lib/protocols.c lib/rfc2068.c lib/rfc959.c lib/sshv2.c src/uicommon/gftpui.c
diffstat 9 files changed, 48 insertions(+), 74 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Mar 16 02:33:05 2007 +0000
+++ b/ChangeLog	Fri Mar 16 02:44:07 2007 +0000
@@ -1,4 +1,8 @@
 2007-3-15 Brian Masney <masneyb@gftp.org>
+	* lib/sshv2.c lib/gftp.h lib/rfc959.c lib/protocols.c lib/fsp.c
+	lib/local.c lib/rfc2068.c src/uicommon/gftpui.c - removed fd argument
+	to *_get_file(), *_put_file() and gftp_transfer_file().
+
 	* src/gtk/transfer.c src/gtk/view_dialog.c - combined some duplicate
 	code that was used to view and edit files.
 
--- a/lib/fsp.c	Fri Mar 16 02:33:05 2007 +0000
+++ b/lib/fsp.c	Fri Mar 16 02:44:07 2007 +0000
@@ -94,7 +94,7 @@
 }
 
 static off_t
-fsp_get_file (gftp_request * request, const char *filename, int fd,
+fsp_get_file (gftp_request * request, const char *filename,
                 off_t startsize)
 {
   fsp_protocol_data * lpd;
@@ -164,7 +164,7 @@
 }
 
 static int
-fsp_put_file (gftp_request * request, const char *filename, int fd,
+fsp_put_file (gftp_request * request, const char *filename,
                 off_t startsize, off_t totalsize)
 {
   fsp_protocol_data * lpd;
--- a/lib/gftp.h	Fri Mar 16 02:33:05 2007 +0000
+++ b/lib/gftp.h	Fri Mar 16 02:44:07 2007 +0000
@@ -435,11 +435,9 @@
   void (*disconnect) 			( gftp_request * request );
   off_t (*get_file) 			( gftp_request * request, 
 					  const char *filename, 
-					  int fd,
 					  off_t startsize );
   int (*put_file) 			( gftp_request * request, 
 					  const char *filename, 
-					  int fd,
 					  off_t startsize,
 					  off_t totalsize );
   off_t (*transfer_file) 		( gftp_request * fromreq, 
@@ -891,22 +889,18 @@
 
 off_t gftp_get_file 			( gftp_request * request, 
 					  const char *filename, 
-					  int fd,
 					  off_t startsize );
 
 int gftp_put_file 			( gftp_request * request, 
 					  const char *filename, 
-					  int fd,
 					  off_t startsize,
 					  off_t totalsize );
 
 off_t gftp_transfer_file 		( gftp_request *fromreq, 
 					  const char *fromfile, 
-					  int fromfd,
 					  off_t fromsize, 
 					  gftp_request *toreq, 
 					  const char *tofile, 
-					  int tofd,
 					  off_t tosize );
 
 ssize_t gftp_get_next_file_chunk 	( gftp_request * request, 
--- a/lib/local.c	Fri Mar 16 02:33:05 2007 +0000
+++ b/lib/local.c	Fri Mar 16 02:44:07 2007 +0000
@@ -149,7 +149,7 @@
 
 
 static off_t
-local_get_file (gftp_request * request, const char *filename, int fd,
+local_get_file (gftp_request * request, const char *filename,
                 off_t startsize)
 {
   size_t destlen;
@@ -161,27 +161,22 @@
   g_return_val_if_fail (request->protonum == GFTP_LOCAL_NUM, GFTP_EFATAL);
   g_return_val_if_fail (filename != NULL, GFTP_EFATAL);
 
-  if (fd <= 0)
-    {
-      flags = O_RDONLY;
+  flags = O_RDONLY;
 #if defined (_LARGEFILE_SOURCE) && defined (O_LARGEFILE)
-      flags |= O_LARGEFILE;
+  flags |= O_LARGEFILE;
 #endif
 
-      utf8 = gftp_filename_from_utf8 (request, filename, &destlen);
-      if (utf8 != NULL)
-        {
-          request->datafd = gftp_fd_open (request, utf8, flags, 0);
-          g_free (utf8);
-        }
-      else
-        request->datafd = gftp_fd_open (request, filename, flags, 0);
-
-      if (request->datafd == -1)
-        return (GFTP_ERETRYABLE); 
+  utf8 = gftp_filename_from_utf8 (request, filename, &destlen);
+  if (utf8 != NULL)
+    {
+      request->datafd = gftp_fd_open (request, utf8, flags, 0);
+      g_free (utf8);
     }
   else
-    request->datafd = fd;
+    request->datafd = gftp_fd_open (request, filename, flags, 0);
+
+  if (request->datafd == -1)
+    return (GFTP_ERETRYABLE); 
 
   if ((size = lseek (request->datafd, 0, SEEK_END)) == -1)
     {
@@ -206,7 +201,7 @@
 
 
 static int
-local_put_file (gftp_request * request, const char *filename, int fd,
+local_put_file (gftp_request * request, const char *filename,
                 off_t startsize, off_t totalsize)
 {
   int flags, perms;
@@ -217,30 +212,25 @@
   g_return_val_if_fail (request->protonum == GFTP_LOCAL_NUM, GFTP_EFATAL);
   g_return_val_if_fail (filename != NULL, GFTP_EFATAL);
 
-  if (fd <= 0)
-    {
-      flags = O_WRONLY | O_CREAT;
-      if (startsize > 0)
-         flags |= O_APPEND;
+  flags = O_WRONLY | O_CREAT;
+  if (startsize > 0)
+     flags |= O_APPEND;
 #if defined (_LARGEFILE_SOURCE) && defined (O_LARGEFILE)
-      flags |= O_LARGEFILE;
+  flags |= O_LARGEFILE;
 #endif
 
-      perms = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
-      utf8 = gftp_filename_from_utf8 (request, filename, &destlen);
-      if (utf8 != NULL)
-        {
-          request->datafd = gftp_fd_open (request, utf8, flags, perms);
-          g_free (utf8);
-        }
-      else
-        request->datafd = gftp_fd_open (request, filename, flags, perms);
-
-      if (request->datafd == -1)
-        return (GFTP_ERETRYABLE);
+  perms = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
+  utf8 = gftp_filename_from_utf8 (request, filename, &destlen);
+  if (utf8 != NULL)
+    {
+      request->datafd = gftp_fd_open (request, utf8, flags, perms);
+      g_free (utf8);
     }
   else
-    request->datafd = fd;
+    request->datafd = gftp_fd_open (request, filename, flags, perms);
+
+  if (request->datafd == -1)
+    return (GFTP_ERETRYABLE);
 
   if (ftruncate (request->datafd, startsize) == -1)
     {
--- a/lib/protocols.c	Fri Mar 16 02:33:05 2007 +0000
+++ b/lib/protocols.c	Fri Mar 16 02:44:07 2007 +0000
@@ -174,7 +174,7 @@
 
 
 off_t
-gftp_get_file (gftp_request * request, const char *filename, int fd,
+gftp_get_file (gftp_request * request, const char *filename,
                off_t startsize)
 {
   g_return_val_if_fail (request != NULL, GFTP_EFATAL);
@@ -183,12 +183,12 @@
   if (request->get_file == NULL)
     return (GFTP_EFATAL);
 
-  return (request->get_file (request, filename, fd, startsize));
+  return (request->get_file (request, filename, startsize));
 }
 
 
 int
-gftp_put_file (gftp_request * request, const char *filename, int fd,
+gftp_put_file (gftp_request * request, const char *filename,
                off_t startsize, off_t totalsize)
 {
   g_return_val_if_fail (request != NULL, GFTP_EFATAL);
@@ -197,15 +197,14 @@
   if (request->put_file == NULL)
     return (GFTP_EFATAL);
 
-  return (request->put_file (request, filename, fd, startsize, totalsize));
+  return (request->put_file (request, filename, startsize, totalsize));
 }
 
 
 off_t
 gftp_transfer_file (gftp_request * fromreq, const char *fromfile, 
-                    int fromfd, off_t fromsize, 
-                    gftp_request * toreq, const char *tofile,
-                    int tofd, off_t tosize)
+                    off_t fromsize, gftp_request * toreq, const char *tofile,
+                    off_t tosize)
 {
   /* Needed for systems that size(float) < size(void *) */
   union { intptr_t i; float f; } maxkbs;
@@ -235,7 +234,7 @@
   toreq->cached = 0;
 
 get_file:
-  size = gftp_get_file (fromreq, fromfile, fromfd, tosize);
+  size = gftp_get_file (fromreq, fromfile, tosize);
   if (size < 0)
     {
       if (size == GFTP_ETIMEDOUT)
@@ -251,7 +250,7 @@
     }
 
 put_file:
-  ret = gftp_put_file (toreq, tofile, tofd, tosize, size);
+  ret = gftp_put_file (toreq, tofile, tosize, size);
   if (ret != 0)
     {
       if (size == GFTP_ETIMEDOUT)
--- a/lib/rfc2068.c	Fri Mar 16 02:33:05 2007 +0000
+++ b/lib/rfc2068.c	Fri Mar 16 02:44:07 2007 +0000
@@ -266,7 +266,7 @@
 
 
 static off_t
-rfc2068_get_file (gftp_request * request, const char *filename, int fd,
+rfc2068_get_file (gftp_request * request, const char *filename,
                   off_t startsize)
 {
   char *tempstr, *oldstr, *hf;
@@ -283,9 +283,6 @@
 
   gftp_lookup_request_option (request, "use_http11", &use_http11);
 
-  if (fd > 0)
-    request->datafd = fd;
-
   hf = gftp_build_path (request, request->hostname, filename, NULL);
 
   if (request->username == NULL || *request->username == '\0')
--- a/lib/rfc959.c	Fri Mar 16 02:33:05 2007 +0000
+++ b/lib/rfc959.c	Fri Mar 16 02:44:07 2007 +0000
@@ -1224,10 +1224,9 @@
 
 
 static off_t
-rfc959_get_file (gftp_request * request, const char *filename, int fd,
+rfc959_get_file (gftp_request * request, const char *filename,
                  off_t startsize)
 {
-  rfc959_parms * parms;
   char *tempstr;
   int ret;
 
@@ -1235,10 +1234,6 @@
   g_return_val_if_fail (filename != NULL, GFTP_EFATAL);
   g_return_val_if_fail (request->datafd > 0, GFTP_EFATAL);
 
-  parms = request->protocol_data;
-  if (fd > 0)
-    parms->data_connection = fd;
-
   ret = rfc959_setup_file_transfer (request, filename, startsize, "RETR");
   if (ret < 0)
     return (ret);
@@ -1257,7 +1252,7 @@
 
 
 static int
-rfc959_put_file (gftp_request * request, const char *filename, int fd,
+rfc959_put_file (gftp_request * request, const char *filename,
                  off_t startsize, off_t totalsize)
 {
   rfc959_parms * parms;
@@ -1267,13 +1262,10 @@
   g_return_val_if_fail (filename != NULL, GFTP_EFATAL);
   g_return_val_if_fail (request->datafd > 0, GFTP_EFATAL);
 
-  parms = request->protocol_data;
-  if (fd > 0) /* FIXME */
-    fd = parms->data_connection;
-
   if ((ret = rfc959_set_data_type (request, filename)) < 0)
     return (ret);
 
+  parms = request->protocol_data;
   if (parms->data_connection < 0 && 
       (ret = rfc959_data_connection_new (request, 0)) < 0)
     return (ret);
--- a/lib/sshv2.c	Fri Mar 16 02:33:05 2007 +0000
+++ b/lib/sshv2.c	Fri Mar 16 02:44:07 2007 +0000
@@ -1853,8 +1853,7 @@
 
 
 static off_t
-sshv2_get_file (gftp_request * request, const char *file, int fd,
-                off_t startsize)
+sshv2_get_file (gftp_request * request, const char *file, off_t startsize)
 {
   int ret;
 
@@ -1866,7 +1865,7 @@
 
 
 static int
-sshv2_put_file (gftp_request * request, const char *file, int fd,
+sshv2_put_file (gftp_request * request, const char *file,
                 off_t startsize, off_t totalsize)
 {
   guint32 mode;
--- a/src/uicommon/gftpui.c	Fri Mar 16 02:33:05 2007 +0000
+++ b/src/uicommon/gftpui.c	Fri Mar 16 02:44:07 2007 +0000
@@ -1470,10 +1470,9 @@
         }
 
       tdata->tot_file_trans = gftp_transfer_file (tdata->fromreq, curfle->file,
-                                                  0,
                                                   curfle->transfer_action == GFTP_TRANS_ACTION_RESUME ?
                                                           curfle->startsize : 0,
-                                                  tdata->toreq, curfle->destfile, 0,
+                                                  tdata->toreq, curfle->destfile,
                                                   curfle->transfer_action == GFTP_TRANS_ACTION_RESUME ?
                                                           curfle->startsize : 0);
       if (tdata->tot_file_trans < 0)