X-Git-Url: http://sjero.net/git/?a=blobdiff_plain;f=src%2Fftp.c;h=9e4f3d76bcbc231f4c74402fd00a81c2eed100f9;hb=3a62674582c4163010aa44babce47a8b8e8b6537;hp=e90db9a82dbcb76c2eb49881a6d8e47356fadba9;hpb=af928aaaaaf8d5a9d55700a4c33d63b304d35c86;p=wget diff --git a/src/ftp.c b/src/ftp.c index e90db9a8..9e4f3d76 100644 --- a/src/ftp.c +++ b/src/ftp.c @@ -1,6 +1,7 @@ /* File Transfer Protocol support. Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, + Inc. This file is part of GNU Wget. @@ -34,9 +35,7 @@ as that of the covered work. */ #include #include #include -#ifdef HAVE_UNISTD_H -# include -#endif +#include #include #include #include @@ -241,7 +240,7 @@ static uerr_t ftp_get_listing (struct url *, ccon *, struct fileinfo **); and closes the control connection in case of error. */ static uerr_t getftp (struct url *u, wgint passed_expected_bytes, wgint *qtyread, - wgint restval, ccon *con) + wgint restval, ccon *con, int count) { int csock, dtsock, local_sock, res; uerr_t err = RETROK; /* appease the compiler */ @@ -302,10 +301,20 @@ getftp (struct url *u, wgint passed_expected_bytes, wgint *qtyread, csock = connect_to_host (host, port); if (csock == E_HOST) - return HOSTERR; + { + if (con->proxy) + xfree (logname); + + return HOSTERR; + } else if (csock < 0) - return (retryable_socket_connect_error (errno) - ? CONERROR : CONIMPOSSIBLE); + { + if (con->proxy) + xfree (logname); + + return (retryable_socket_connect_error (errno) + ? CONERROR : CONIMPOSSIBLE); + } if (cmd & LEAVE_PENDING) con->csock = csock; @@ -504,9 +513,9 @@ Error in server response, closing control connection.\n")); else { char *targ = NULL; - int cwd_count; - int cwd_end; - int cwd_start; + int cwd_count; + int cwd_end; + int cwd_start; char *target = u->dir; @@ -1172,7 +1181,7 @@ Error in server response, closing control connection.\n")); #endif /* def __VMS [else] */ } else if (opt.noclobber || opt.always_rest || opt.timestamping || opt.dirstruct - || opt.output_document) + || opt.output_document || count > 0) { if (opt.unlink && file_exists_p (con->target)) { @@ -1488,7 +1497,7 @@ ftp_loop_internal (struct url *u, struct fileinfo *f, ccon *con, char **local_fi len = f->size; else len = 0; - err = getftp (u, len, &qtyread, restval, con); + err = getftp (u, len, &qtyread, restval, con, count); if (con->csock == -1) con->st &= ~DONE_CWD;