+2010-03-01 Steven Schubiger <stsc@member.fsf.org>
+
+ * retr.c (retrieve_url): Retrieve the local filename from ftp_loop.
+ (retrieve_from_file): Return if there's no input file.
+
+ * ftp.c (ftp_loop_internal): Duplicate the local filename into
+ retrieve_url's scope when a valid reference is being passed.
+ (ftp_loop): Call ftp_loop_internal here with passing a
+ reference to the local filename, elsewhere with NULL.
+
+ * ftp.h: Adjust declaration of ftp_loop.
+
2010-01-27 Paul Townsend <aab@purdue.edu> (tiny change)
* retr.c (fd_read_body): Be sure to measure timer when time has
This loop either gets commands from con, or (if ON_YOUR_OWN is
set), makes them up to retrieve the file given by the URL. */
static uerr_t
-ftp_loop_internal (struct url *u, struct fileinfo *f, ccon *con)
+ftp_loop_internal (struct url *u, struct fileinfo *f, ccon *con, char **local_file)
{
int count, orig_lp;
wgint restval, len = 0, qtyread = 0;
con->cmd |= LEAVE_PENDING;
else
con->cmd &= ~LEAVE_PENDING;
+
+ if (local_file)
+ *local_file = xstrdup (locf);
+
return RETROK;
} while (!opt.ntry || (count < opt.ntry));
con->target = xstrdup (lf);
xfree (lf);
- err = ftp_loop_internal (u, NULL, con);
+ err = ftp_loop_internal (u, NULL, con, NULL);
lf = xstrdup (con->target);
xfree (con->target);
con->target = old_target;
else /* opt.retr_symlinks */
{
if (dlthis)
- err = ftp_loop_internal (u, f, con);
+ err = ftp_loop_internal (u, f, con, NULL);
} /* opt.retr_symlinks */
break;
case FT_DIRECTORY:
case FT_PLAINFILE:
/* Call the retrieve loop. */
if (dlthis)
- err = ftp_loop_internal (u, f, con);
+ err = ftp_loop_internal (u, f, con, NULL);
break;
case FT_UNKNOWN:
logprintf (LOG_NOTQUIET, _("%s: unknown/unsupported file type.\n"),
{
/* Let's try retrieving it anyway. */
con->st |= ON_YOUR_OWN;
- res = ftp_loop_internal (u, NULL, con);
+ res = ftp_loop_internal (u, NULL, con, NULL);
return res;
}
of URL. Inherently, its capabilities are limited on what can be
encoded into a URL. */
uerr_t
-ftp_loop (struct url *u, int *dt, struct url *proxy, bool recursive, bool glob)
+ftp_loop (struct url *u, char **local_file, int *dt, struct url *proxy,
+ bool recursive, bool glob)
{
ccon con; /* FTP connection */
uerr_t res;
ispattern ? GLOB_GLOBALL : GLOB_GETONE);
}
else
- res = ftp_loop_internal (u, NULL, &con);
+ res = ftp_loop_internal (u, NULL, &con, local_file);
}
if (res == FTPOK)
res = RETROK;
};
struct fileinfo *ftp_parse_ls (const char *, const enum stype);
-uerr_t ftp_loop (struct url *, int *, struct url *, bool, bool);
+uerr_t ftp_loop (struct url *, char **, int *, struct url *, bool, bool);
uerr_t ftp_index (const char *, struct url *, struct fileinfo *);
if (redirection_count)
oldrec = glob = false;
- result = ftp_loop (u, dt, proxy_url, recursive, glob);
+ result = ftp_loop (u, &local_file, dt, proxy_url, recursive, glob);
recursive = oldrec;
/* There is a possibility of having HTTP being redirected to
status = retrieve_url (url_parsed, url, &input_file, NULL, NULL, &dt,
false, iri, true);
- if (status != RETROK)
+ url_free (url_parsed);
+
+ if (!input_file || (status != RETROK))
return status;
if (dt & TEXTHTML)
+2010-03-01 Steven Schubiger <stsc@member.fsf.org>
+
+ * Test-i-ftp.px: Test --input-file in conjunction with FTP.
+ * run-px, Makefile.am (EXTRA_DIST): Added Test-i-ftp.px.
+
2010-02-26 Steven Schubiger <stsc@member.fsf.org>
* Test-i-http.px: Test --input-file in conjunction with HTTP.
Test-HTTP-Content-Disposition-1.px \
Test-HTTP-Content-Disposition-2.px \
Test-HTTP-Content-Disposition.px \
+ Test-i-ftp.px \
Test-i-http.px \
Test-idn-headers.px \
Test-idn-meta.px \
--- /dev/null
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use FTPTest;
+
+
+###############################################################################
+
+my $urls = <<EOF;
+ftp://localhost:{{port}}/site1.html
+ftp://localhost:{{port}}/site2.html
+EOF
+
+my $site1 = <<EOF;
+<html>
+ <head>
+ <title>Site 1</title>
+ </head>
+ <body>
+ <p>Nunc eu ligula sed mauris sollicitudin scelerisque. Suspendisse viverra, dolor.</p>
+ </body>
+</html>
+EOF
+
+my $site2 = <<EOF;
+<html>
+ <head>
+ <title>Site 2</title>
+ </head>
+ <body>
+ <p>Suspendisse potenti. Phasellus et magna est, quis consectetur ligula. Integer.</p>
+ </body>
+</html>
+EOF
+
+foreach ($urls, $site1, $site2) {
+ s/\n/\r\n/g;
+}
+
+my %urls = (
+ '/urls.txt' => {
+ content => $urls,
+ },
+ '/site1.html' => {
+ content => $site1,
+ },
+ '/site2.html' => {
+ content => $site2,
+ },
+);
+
+my $cmdline = $WgetTest::WGETPATH . " -i ftp://localhost:{{port}}/urls.txt";
+
+my $expected_error_code = 0;
+
+my %expected_downloaded_files = (
+ 'urls.txt' => {
+ content => $urls,
+ },
+ 'site1.html' => {
+ content => $site1,
+ },
+ 'site2.html' => {
+ content => $site2,
+ },
+);
+
+###############################################################################
+
+my $the_test = FTPTest->new (name => "Test-i-ftp",
+ input => \%urls,
+ cmdline => $cmdline,
+ errcode => $expected_error_code,
+ output => \%expected_downloaded_files);
+exit $the_test->run();
+
+# vim: et ts=4 sw=4
+
'Test-HTTP-Content-Disposition-1.px',
'Test-HTTP-Content-Disposition-2.px',
'Test-HTTP-Content-Disposition.px',
+ 'Test-i-ftp.px',
'Test-i-http.px',
'Test-idn-headers.px',
'Test-idn-meta.px',