#include <sys/types.h>
#include <assert.h>
#include <errno.h>
-#ifndef WINDOWS
-# include <netdb.h> /* for h_errno */
-#endif
#include "wget.h"
#include "utils.h"
#ifndef errno
extern int errno;
#endif
-#ifndef h_errno
-# ifndef __CYGWIN__
-extern int h_errno;
-# endif
-#endif
/* File where the "ls -al" listing will be saved. */
#define LIST_FILENAME ".listing"
FILE *fp;
char *user, *passwd, *respline;
char *tms, *tmrate;
- struct wget_timer *timer;
unsigned char pasv_addr[6];
int cmd = con->cmd;
int passive_mode_open = 0;
abort ();
break;
}
- if (!opt.server_response)
+ if (!opt.server_response && err != FTPSRVERR)
logputs (LOG_VERBOSE, _("done. "));
/* Fourth: Find the initial ftp directory */
switch (err)
{
case FTPRERR:
- case FTPSRVERR :
logputs (LOG_VERBOSE, "\n");
logputs (LOG_NOTQUIET, _("\
Error in server response, closing control connection.\n"));
rbuf_uninitialize (&con->rbuf);
return err;
break;
+ case FTPSRVERR :
+ /* PWD unsupported -- assume "/". */
+ FREE_MAYBE (con->id);
+ con->id = xstrdup ("/");
+ break;
case FTPOK:
/* Everything is OK. */
break;
{
if (opt.ftp_pasv > 0)
{
- char thost[256];
- unsigned short tport;
-
if (!opt.server_response)
logputs (LOG_VERBOSE, "==> PASV ... ");
err = ftp_pasv (&con->rbuf, pasv_addr);
}
if (err==FTPOK)
{
- struct address_list *al;
+ unsigned short tport;
- sprintf (thost, "%d.%d.%d.%d",
- pasv_addr[0], pasv_addr[1], pasv_addr[2], pasv_addr[3]);
tport = (pasv_addr[4] << 8) + pasv_addr[5];
-
- al = lookup_host (thost, 0);
- if (!al)
- {
- CLOSE (csock);
- rbuf_uninitialize (&con->rbuf);
- return HOSTERR;
- }
- dtsock = connect_to_many (al, tport, 0);
- address_list_release (al);
+ dtsock = connect_to_one (pasv_addr, tport, 1);
if (dtsock < 0)
{
int save_errno = errno;
CLOSE (csock);
rbuf_uninitialize (&con->rbuf);
+ logprintf (LOG_VERBOSE, _("couldn't connect to %s:%hu: %s\n"),
+ pretty_print_address (pasv_addr), tport,
+ strerror (save_errno));
return save_errno == ECONNREFUSED ? CONREFUSED : CONERROR;
}
- passive_mode_open= 1; /* Flag to avoid accept port */
+ passive_mode_open = 1; /* Flag to avoid accept port */
if (!opt.server_response)
logputs (LOG_VERBOSE, _("done. "));
} /* err==FTP_OK */
closeport (dtsock);
return err;
break;
- case HOSTERR:
- logputs (LOG_VERBOSE, "\n");
- logprintf (LOG_NOTQUIET, "%s: %s\n", u->host,
- herrmsg (h_errno));
- CLOSE (csock);
- closeport (dtsock);
- rbuf_uninitialize (&con->rbuf);
- return HOSTERR;
- break;
case FTPPORTERR:
logputs (LOG_VERBOSE, "\n");
logputs (LOG_NOTQUIET, _("Invalid PORT.\n"));
legible (expected_bytes - restval));
logputs (LOG_VERBOSE, _(" (unauthoritative)\n"));
}
- timer = wtimer_new ();
+
/* Get the contents of the document. */
- res = get_contents (dtsock, fp, len, restval, expected_bytes, &con->rbuf, 0);
- con->dltime = wtimer_elapsed (timer);
- wtimer_delete (timer);
+ res = get_contents (dtsock, fp, len, restval, expected_bytes, &con->rbuf,
+ 0, &con->dltime);
tms = time_str (NULL);
tmrate = retr_rate (*len - restval, con->dltime, 0);
/* Close data connection socket. */