]> sjero.net Git - wget/blobdiff - src/ftp-basic.c
[svn] Rename long_to_string to number_to_string, and make it return a useful
[wget] / src / ftp-basic.c
index ee17669058f0f9a6249ded23125e892dccc814bd..69e94f022380292cbb4a1181c75c6abd55ac9b58 100644 (file)
@@ -255,7 +255,7 @@ ftp_port (struct rbuf *rbuf)
     return err;
   /* Get the address of this side of the connection.  */
   if (!(in_addr = conaddr (RBUF_FD (rbuf))))
-    return HOSTERR;
+    return BINDERR;
   /* Construct the argument of PORT (of the form a,b,c,d,e,f).  */
   bytes = (char *)alloca (6 * 4 + 1);
   sprintf (bytes, "%d,%d,%d,%d,%d,%d", in_addr[0], in_addr[1],
@@ -426,9 +426,9 @@ ftp_rest (struct rbuf *rbuf, long offset)
   char *request, *respline;
   int nwritten;
   uerr_t err;
-  static char numbuf[20]; /* Buffer for the number */
+  static char numbuf[24]; /* Buffer for the number */
 
-  long_to_string (numbuf, offset);
+  number_to_string (numbuf, offset);
   request = ftp_request ("REST", numbuf);
   nwritten = iwrite (RBUF_FD (rbuf), request, strlen (request));
   if (nwritten < 0)
@@ -550,6 +550,7 @@ ftp_syst (struct rbuf *rbuf, enum stype *server_type)
       return WRITEFAILED;
     }
   xfree (request);
+
   /* Get appropriate response.  */
   err = ftp_response (rbuf, &respline);
   if (err != FTPOK)
@@ -572,17 +573,14 @@ ftp_syst (struct rbuf *rbuf, enum stype *server_type)
 
   if (!strcasecmp (request, "VMS"))
     *server_type = ST_VMS;
+  else if (!strcasecmp (request, "UNIX"))
+    *server_type = ST_UNIX;
+  else if (!strcasecmp (request, "WINDOWS_NT"))
+    *server_type = ST_WINNT;
+  else if (!strcasecmp (request, "MACOS"))
+    *server_type = ST_MACOS;
   else
-    if (!strcasecmp (request, "UNIX"))
-      *server_type = ST_UNIX;
-    else
-      if (!strcasecmp (request, "WINDOWS_NT"))
-        *server_type = ST_WINNT;
-      else
-        if (!strcasecmp (request, "MACOS"))
-          *server_type = ST_MACOS;
-        else
-          *server_type = ST_OTHER;
+    *server_type = ST_OTHER;
 
   xfree (respline);
   /* All OK.  */
@@ -633,6 +631,7 @@ ftp_pwd (struct rbuf *rbuf, char **pwd)
   /* All OK.  */
   return FTPOK;
 }
+
 /* Sends the SIZE command to the server, and returns the value in 'size'.
  * If an error occurs, size is set to zero. */
 uerr_t
@@ -690,3 +689,16 @@ ftp_size (struct rbuf *rbuf, const char *file, long int *size)
   /* All OK.  */
   return FTPOK;
 }
+
+/* If URL's params are of the form "type=X", return character X.
+   Otherwise, return 'I' (the default type).  */
+char
+ftp_process_type (const char *params)
+{
+  if (params
+      && 0 == strncasecmp (params, "type=", 5)
+      && params[5] != '\0')
+    return TOUPPER (params[5]);
+  else
+    return 'I';
+}