diff lib/rfc959.c @ 442:9d03253b00d0

2004-3-20 Brian Masney <masneyb@gftp.org> * Officially release 2.0.17pre0 * lib/gftp.h src/uicommon/gftpui.c lib/rfc959.c - if the connection timed out to the server, return GFTP_ETIMEDOUT. In the UI, if this error code is returned, immediately reconnect to the server and retry the operation * lib/rfc959.c - if the return value from rfc959_send_command() is < 0, then make sure the exact value is returned instead of GFTP_ERETRYABLE
author masneyb
date Sat, 20 Mar 2004 19:36:05 +0000
parents d7ff8d2d43aa
children 6b1e4bd20ae4
line wrap: on
line diff
--- a/lib/rfc959.c	Sat Mar 20 19:17:48 2004 +0000
+++ b/lib/rfc959.c	Sat Mar 20 19:36:05 2004 +0000
@@ -130,7 +130,10 @@
   if (request->last_ftp_response[0] == '4' &&
       request->last_ftp_response[1] == '2' &&
       disconnect_on_42x)
-    gftp_disconnect (request);
+    {
+      gftp_disconnect (request);
+      return (GFTP_ETIMEDOUT);
+    }
 
   return (*request->last_ftp_response);
 }
@@ -365,7 +368,9 @@
       g_free (tempstr);
     }
 
-  if (ret != '2')
+  if (ret < 0)
+    return (ret);
+  else if (ret != '2')
     return (GFTP_ERETRYABLE);
 
   if (directory != request->directory)
@@ -1074,7 +1079,9 @@
       resp = rfc959_send_command (request, command, 1);
       g_free (command);
 
-      if (resp != '3')
+      if (resp < 0)
+        return (resp);
+      else if (resp != '3')
         {
           close (parms->data_connection);
           parms->data_connection = -1;
@@ -1086,7 +1093,9 @@
   ret = rfc959_send_command (request, tempstr, 1);
   g_free (tempstr);
 
-  if (ret != '1')
+  if (ret < 0)
+    return (ret);
+  else if (ret != '1')
     {
       close (parms->data_connection);
       parms->data_connection = -1;
@@ -1147,7 +1156,9 @@
 #endif
       resp = rfc959_send_command (request, command, 1);
       g_free (command);
-      if (resp != '3')
+      if (resp < 0)
+        return (resp);
+      else if (resp != '3')
         {
           close (parms->data_connection);
           parms->data_connection = -1;
@@ -1158,7 +1169,9 @@
   tempstr = g_strconcat ("STOR ", filename, "\r\n", NULL);
   ret = rfc959_send_command (request, tempstr, 1);
   g_free (tempstr);
-  if (ret != '1')
+  if (ret < 0)
+    return (ret);
+  else if (ret != '1')
     {
       close (parms->data_connection);
       parms->data_connection = -1;
@@ -1190,8 +1203,10 @@
   g_return_val_if_fail (fromreq->datafd > 0, GFTP_EFATAL);
   g_return_val_if_fail (toreq->datafd > 0, GFTP_EFATAL);
 
-  if ((ret = rfc959_send_command (fromreq, "PASV\r\n", 1)) != '2')
+  if ((ret = rfc959_send_command (fromreq, "PASV\r\n", 1)) < 0)
     return (ret);
+  else if (ret != '2')
+    return (GFTP_ERETRYABLE);
 
   pos = fromreq->last_ftp_response + 4;
   while (!isdigit ((int) *pos) && *pos != '\0') 
@@ -1206,13 +1221,14 @@
     *endpos = '\0';
 
   tempstr = g_strconcat ("PORT ", pos, "\r\n", NULL);
-  if ((ret = rfc959_send_command (toreq, tempstr, 1)) != '2')
-     {
-       g_free (tempstr);
-       return (ret);
-     }
+  ret = rfc959_send_command (toreq, tempstr, 1);
   g_free (tempstr);
 
+  if (ret < 0)
+    return (ret);
+  else if (ret != '2')
+    return (GFTP_ERETRYABLE);
+
   tempstr = g_strconcat ("RETR ", fromfile, "\r\n", NULL);
   if ((ret = rfc959_send_command (fromreq, tempstr, 0)) < 0)
     {
@@ -1330,7 +1346,9 @@
   ret = rfc959_send_command (request, tempstr, 1);
   g_free (tempstr);
 
-  if (ret != '1')
+  if (ret < 0)
+    return (ret);
+  else if (ret != '1')
     {
       request->logging_function (gftp_logging_error, request,
                                  _("Invalid response '%c' received from server.\n"),