[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: [BusyBox] Adding listing capabilities to ftpget
From: "Owens, Steve" <Steve.Owens () usa ! xerox ! com>
Date: 2003-03-17 12:02:03
[Download RAW message or body]
Not having done this before, I hope this works....
I've attached the context diff of the changes I made to ftpget to add
listing capabilities. I haven't attached the changes to usage.h for the help
lines, however.
Let me know what you think.
<<ftpgetput.diff>>
A man who carries a cat by the tail learns something he can learn in no
other way.
-- Mark Twain
["ftpgetput.diff" (application/octet-stream)]
*** ftpgetput.orig Fri Mar 14 09:39:09 2003
--- ftpgetput.c Fri Mar 14 10:58:59 2003
***************
*** 54,59 ****
--- 54,60 ----
} ftp_host_info_t;
static char verbose_flag;
+ static char *listing_file = (char *)NULL;
static char do_continue = 0;
static ftp_host_info_t *ftp_init(void)
***************
*** 145,151 ****
error_msg_and_die("USER error: %s", buf + 4);
}
! ftpcmd("TYPE I", NULL, control_stream, buf);
return(control_stream);
}
--- 146,155 ----
error_msg_and_die("USER error: %s", buf + 4);
}
! if (!listing_file)
! ftpcmd("TYPE I", NULL, control_stream, buf);
! else
! ftpcmd("TYPE A", NULL, control_stream, buf);
return(control_stream);
}
***************
*** 161,167 ****
int fd_local;
off_t beg_range = 0;
! filename = get_last_path_component(server_path);
local_file = concat_path_file(local_path, filename);
/* Connect to the data socket */
--- 165,175 ----
int fd_local;
off_t beg_range = 0;
! if (!listing_file)
! filename = get_last_path_component(server_path);
! else
! filename = listing_file;
!
local_file = concat_path_file(local_path, filename);
/* Connect to the data socket */
***************
*** 170,177 ****
}
fd_data = xconnect_ftpdata(host, buf);
! if (ftpcmd("SIZE ", server_path, control_stream, buf) == 213) {
! filesize = atol(buf + 4);
}
if (do_continue) {
--- 178,187 ----
}
fd_data = xconnect_ftpdata(host, buf);
! if (!listing_file) {
! if (ftpcmd("SIZE ", server_path, control_stream, buf) == 213) {
! filesize = atol(buf + 4);
! }
}
if (do_continue) {
***************
*** 195,202 ****
}
}
! if (ftpcmd("RETR ", server_path, control_stream, buf) > 150) {
! error_msg_and_die("RETR error: %s", buf + 4);
}
/* only make a local file if we know that one exists on the remote server */
--- 205,219 ----
}
}
! if (!listing_file) {
! if (ftpcmd("RETR ", server_path, control_stream, buf) > 150) {
! error_msg_and_die("RETR error: %s", buf + 4);
! }
! }
! else {
! if (ftpcmd("NLST ", server_path, control_stream, buf) > 150) {
! error_msg_and_die("NLST error: %s", buf + 4);
! }
}
/* only make a local file if we know that one exists on the remote server */
***************
*** 303,308 ****
--- 320,326 ----
{"port", 1, NULL, 'P'},
{"continue", 1, NULL, 'c'},
{"verbose", 0, NULL, 'v'},
+ {"list", 1, NULL, 'l'},
{0, 0, 0, 0}
};
***************
*** 324,330 ****
/*
* Decipher the command line
*/
! while ((opt = getopt_long(argc, argv, "u:p:P:cv", long_options, &option_index)) != EOF) {
switch(opt) {
case 'c':
do_continue = 1;
--- 342,348 ----
/*
* Decipher the command line
*/
! while ((opt = getopt_long(argc, argv, "u:p:P:l:cv", long_options, &option_index)) != EOF) {
switch(opt) {
case 'c':
do_continue = 1;
***************
*** 341,346 ****
--- 359,367 ----
case 'v':
verbose_flag = 1;
break;
+ case 'l':
+ listing_file = optarg;
+ break;
default:
show_usage();
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic