Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* |
| 3 | * ftpget |
| 4 | * |
| 5 | * Mini implementation of FTP to retrieve a remote file. |
| 6 | * |
| 7 | * Copyright (C) 2002 Jeff Angielski, The PTR Group <jeff@theptrgroup.com> |
| 8 | * Copyright (C) 2002 Glenn McGrath <bug1@optushome.com.au> |
| 9 | * |
| 10 | * Based on wget.c by Chip Rosenthal Covad Communications |
| 11 | * <chip@laserlink.net> |
| 12 | * |
| 13 | * This program is free software; you can redistribute it and/or modify |
| 14 | * it under the terms of the GNU General Public License as published by |
| 15 | * the Free Software Foundation; either version 2 of the License, or |
| 16 | * (at your option) any later version. |
| 17 | * |
| 18 | * This program is distributed in the hope that it will be useful, |
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 21 | * General Public License for more details. |
| 22 | * |
| 23 | * You should have received a copy of the GNU General Public License |
| 24 | * along with this program; if not, write to the Free Software |
| 25 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 26 | * |
| 27 | */ |
| 28 | |
| 29 | #include <sys/types.h> |
| 30 | #include <sys/ioctl.h> |
| 31 | #include <sys/time.h> |
| 32 | #include <sys/stat.h> |
| 33 | |
| 34 | #include <ctype.h> |
| 35 | #include <errno.h> |
| 36 | #include <fcntl.h> |
| 37 | #include <getopt.h> |
| 38 | #include <stdio.h> |
| 39 | #include <stdlib.h> |
| 40 | #include <signal.h> |
| 41 | #include <string.h> |
| 42 | #include <unistd.h> |
| 43 | |
| 44 | #include <netinet/in.h> |
| 45 | #include <netdb.h> |
Eric Andersen | 04d055f | 2003-11-03 21:20:18 +0000 | [diff] [blame] | 46 | #include <sys/socket.h> |
| 47 | #include <arpa/inet.h> |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 48 | |
| 49 | #include "busybox.h" |
| 50 | |
| 51 | typedef struct ftp_host_info_s { |
| 52 | char *host; |
| 53 | char *port; |
| 54 | char *user; |
| 55 | char *password; |
Eric Andersen | 04d055f | 2003-11-03 21:20:18 +0000 | [diff] [blame] | 56 | struct sockaddr_in *s_in; |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 57 | } ftp_host_info_t; |
| 58 | |
| 59 | static char verbose_flag; |
| 60 | static char do_continue = 0; |
| 61 | |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 62 | static ftp_host_info_t *ftp_init(void) |
| 63 | { |
| 64 | ftp_host_info_t *host; |
| 65 | |
| 66 | host = xcalloc(1, sizeof(ftp_host_info_t)); |
| 67 | |
| 68 | /* Set the default port */ |
| 69 | if (getservbyname("ftp", "tcp")) { |
| 70 | host->port = "ftp"; |
| 71 | } else { |
| 72 | host->port = "21"; |
| 73 | } |
| 74 | host->user = "anonymous"; |
| 75 | host->password = "busybox@"; |
| 76 | |
| 77 | return(host); |
| 78 | } |
| 79 | |
| 80 | static int ftpcmd(const char *s1, const char *s2, FILE *stream, char *buf) |
| 81 | { |
| 82 | if (verbose_flag) { |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 83 | bb_error_msg("cmd %s%s", s1, s2); |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | if (s1) { |
| 87 | if (s2) { |
| 88 | fprintf(stream, "%s%s\n", s1, s2); |
| 89 | } else { |
| 90 | fprintf(stream, "%s\n", s1); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | do { |
| 95 | if (fgets(buf, 510, stream) == NULL) { |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 96 | bb_perror_msg_and_die("fgets()"); |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 97 | } |
| 98 | } while (! isdigit(buf[0]) || buf[3] != ' '); |
| 99 | |
| 100 | return atoi(buf); |
| 101 | } |
| 102 | |
Eric Andersen | 04d055f | 2003-11-03 21:20:18 +0000 | [diff] [blame] | 103 | static int xconnect_ftpdata(ftp_host_info_t *server, const char *buf) |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 104 | { |
| 105 | char *buf_ptr; |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 106 | unsigned short port_num; |
| 107 | |
| 108 | buf_ptr = strrchr(buf, ','); |
| 109 | *buf_ptr = '\0'; |
| 110 | port_num = atoi(buf_ptr + 1); |
| 111 | |
| 112 | buf_ptr = strrchr(buf, ','); |
| 113 | *buf_ptr = '\0'; |
| 114 | port_num += atoi(buf_ptr + 1) * 256; |
| 115 | |
Eric Andersen | 04d055f | 2003-11-03 21:20:18 +0000 | [diff] [blame] | 116 | server->s_in->sin_port=htons(port_num); |
| 117 | return(xconnect(server->s_in)); |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | static FILE *ftp_login(ftp_host_info_t *server) |
| 121 | { |
| 122 | FILE *control_stream; |
| 123 | char buf[512]; |
| 124 | int control_fd; |
| 125 | |
| 126 | /* Connect to the command socket */ |
Eric Andersen | 04d055f | 2003-11-03 21:20:18 +0000 | [diff] [blame] | 127 | control_fd = xconnect(server->s_in); |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 128 | control_stream = fdopen(control_fd, "r+"); |
| 129 | if (control_stream == NULL) { |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 130 | bb_perror_msg_and_die("Couldnt open control stream"); |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | if (ftpcmd(NULL, NULL, control_stream, buf) != 220) { |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 134 | bb_error_msg_and_die("%s", buf + 4); |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | /* Login to the server */ |
| 138 | switch (ftpcmd("USER ", server->user, control_stream, buf)) { |
| 139 | case 230: |
| 140 | break; |
| 141 | case 331: |
| 142 | if (ftpcmd("PASS ", server->password, control_stream, buf) != 230) { |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 143 | bb_error_msg_and_die("PASS error: %s", buf + 4); |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 144 | } |
| 145 | break; |
| 146 | default: |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 147 | bb_error_msg_and_die("USER error: %s", buf + 4); |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | ftpcmd("TYPE I", NULL, control_stream, buf); |
| 151 | |
| 152 | return(control_stream); |
| 153 | } |
| 154 | |
| 155 | #ifdef CONFIG_FTPGET |
Eric Andersen | 04d055f | 2003-11-03 21:20:18 +0000 | [diff] [blame] | 156 | static int ftp_recieve(ftp_host_info_t *server, FILE *control_stream, |
| 157 | const char *local_path, char *server_path) |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 158 | { |
| 159 | char *filename; |
| 160 | char *local_file; |
| 161 | char buf[512]; |
| 162 | off_t filesize = 0; |
| 163 | int fd_data; |
| 164 | int fd_local; |
| 165 | off_t beg_range = 0; |
| 166 | |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 167 | filename = bb_get_last_path_component(server_path); |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 168 | local_file = concat_path_file(local_path, filename); |
| 169 | |
| 170 | /* Connect to the data socket */ |
| 171 | if (ftpcmd("PASV", NULL, control_stream, buf) != 227) { |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 172 | bb_error_msg_and_die("PASV error: %s", buf + 4); |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 173 | } |
Eric Andersen | 04d055f | 2003-11-03 21:20:18 +0000 | [diff] [blame] | 174 | fd_data = xconnect_ftpdata(server, buf); |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 175 | |
| 176 | if (ftpcmd("SIZE ", server_path, control_stream, buf) == 213) { |
| 177 | filesize = atol(buf + 4); |
| 178 | } |
| 179 | |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 180 | if (do_continue) { |
| 181 | struct stat sbuf; |
Glenn L McGrath | 1643f41 | 2002-12-18 02:47:40 +0000 | [diff] [blame] | 182 | if (lstat(local_file, &sbuf) < 0) { |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 183 | bb_perror_msg_and_die("fstat()"); |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 184 | } |
| 185 | if (sbuf.st_size > 0) { |
| 186 | beg_range = sbuf.st_size; |
| 187 | } else { |
| 188 | do_continue = 0; |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | if (do_continue) { |
Eric Andersen | 2a41ec6 | 2003-06-20 09:22:12 +0000 | [diff] [blame] | 193 | sprintf(buf, "REST %ld", (long)beg_range); |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 194 | if (ftpcmd(buf, NULL, control_stream, buf) != 350) { |
| 195 | do_continue = 0; |
| 196 | } else { |
| 197 | filesize -= beg_range; |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | if (ftpcmd("RETR ", server_path, control_stream, buf) > 150) { |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 202 | bb_error_msg_and_die("RETR error: %s", buf + 4); |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 203 | } |
| 204 | |
Glenn L McGrath | 1643f41 | 2002-12-18 02:47:40 +0000 | [diff] [blame] | 205 | /* only make a local file if we know that one exists on the remote server */ |
| 206 | if (do_continue) { |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 207 | fd_local = bb_xopen(local_file, O_APPEND | O_WRONLY); |
Glenn L McGrath | 1643f41 | 2002-12-18 02:47:40 +0000 | [diff] [blame] | 208 | } else { |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 209 | fd_local = bb_xopen(local_file, O_CREAT | O_TRUNC | O_WRONLY); |
Glenn L McGrath | 1643f41 | 2002-12-18 02:47:40 +0000 | [diff] [blame] | 210 | } |
| 211 | |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 212 | /* Copy the file */ |
Glenn L McGrath | 7ffe133 | 2003-11-21 22:24:57 +0000 | [diff] [blame] | 213 | if (bb_copyfd_size(fd_data, fd_local, filesize) == -1) { |
Glenn L McGrath | 25fe94f | 2002-12-13 08:20:44 +0000 | [diff] [blame] | 214 | exit(EXIT_FAILURE); |
| 215 | } |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 216 | |
| 217 | /* close it all down */ |
| 218 | close(fd_data); |
| 219 | if (ftpcmd(NULL, NULL, control_stream, buf) != 226) { |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 220 | bb_error_msg_and_die("ftp error: %s", buf + 4); |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 221 | } |
| 222 | ftpcmd("QUIT", NULL, control_stream, buf); |
| 223 | |
| 224 | return(EXIT_SUCCESS); |
| 225 | } |
| 226 | #endif |
| 227 | |
| 228 | #ifdef CONFIG_FTPPUT |
Eric Andersen | 04d055f | 2003-11-03 21:20:18 +0000 | [diff] [blame] | 229 | static int ftp_send(ftp_host_info_t *server, FILE *control_stream, |
| 230 | const char *server_path, char *local_path) |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 231 | { |
| 232 | struct stat sbuf; |
| 233 | char buf[512]; |
| 234 | int fd_data; |
| 235 | int fd_local; |
| 236 | int response; |
| 237 | |
| 238 | /* Connect to the data socket */ |
| 239 | if (ftpcmd("PASV", NULL, control_stream, buf) != 227) { |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 240 | bb_error_msg_and_die("PASV error: %s", buf + 4); |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 241 | } |
Eric Andersen | 04d055f | 2003-11-03 21:20:18 +0000 | [diff] [blame] | 242 | fd_data = xconnect_ftpdata(server, buf); |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 243 | |
| 244 | if (ftpcmd("CWD ", server_path, control_stream, buf) != 250) { |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 245 | bb_error_msg_and_die("CWD error: %s", buf + 4); |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 246 | } |
| 247 | |
| 248 | /* get the local file */ |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 249 | fd_local = bb_xopen(local_path, O_RDONLY); |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 250 | fstat(fd_local, &sbuf); |
| 251 | |
Eric Andersen | 2a41ec6 | 2003-06-20 09:22:12 +0000 | [diff] [blame] | 252 | sprintf(buf, "ALLO %lu", (unsigned long)sbuf.st_size); |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 253 | response = ftpcmd(buf, NULL, control_stream, buf); |
| 254 | switch (response) { |
| 255 | case 200: |
| 256 | case 202: |
| 257 | break; |
| 258 | default: |
| 259 | close(fd_local); |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 260 | bb_error_msg_and_die("ALLO error: %s", buf + 4); |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 261 | break; |
| 262 | } |
| 263 | |
| 264 | response = ftpcmd("STOR ", local_path, control_stream, buf); |
| 265 | switch (response) { |
| 266 | case 125: |
| 267 | case 150: |
| 268 | break; |
| 269 | default: |
| 270 | close(fd_local); |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 271 | bb_error_msg_and_die("STOR error: %s", buf + 4); |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | /* transfer the file */ |
Glenn L McGrath | 7ffe133 | 2003-11-21 22:24:57 +0000 | [diff] [blame] | 275 | if (bb_copyfd_eof(fd_local, fd_data) == -1) { |
Glenn L McGrath | 25fe94f | 2002-12-13 08:20:44 +0000 | [diff] [blame] | 276 | exit(EXIT_FAILURE); |
| 277 | } |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 278 | |
| 279 | /* close it all down */ |
| 280 | close(fd_data); |
| 281 | if (ftpcmd(NULL, NULL, control_stream, buf) != 226) { |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 282 | bb_error_msg_and_die("error: %s", buf + 4); |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 283 | } |
| 284 | ftpcmd("QUIT", NULL, control_stream, buf); |
| 285 | |
| 286 | return(EXIT_SUCCESS); |
| 287 | } |
| 288 | #endif |
| 289 | |
| 290 | int ftpgetput_main(int argc, char **argv) |
| 291 | { |
| 292 | /* content-length of the file */ |
| 293 | int option_index = -1; |
| 294 | int opt; |
| 295 | |
| 296 | /* socket to ftp server */ |
| 297 | FILE *control_stream; |
Eric Andersen | 04d055f | 2003-11-03 21:20:18 +0000 | [diff] [blame] | 298 | struct sockaddr_in s_in; |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 299 | |
| 300 | /* continue a prev transfer (-c) */ |
| 301 | ftp_host_info_t *server; |
| 302 | |
Eric Andersen | 04d055f | 2003-11-03 21:20:18 +0000 | [diff] [blame] | 303 | int (*ftp_action)(ftp_host_info_t *, FILE *, const char *, char *) = NULL; |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 304 | |
| 305 | struct option long_options[] = { |
| 306 | {"username", 1, NULL, 'u'}, |
| 307 | {"password", 1, NULL, 'p'}, |
| 308 | {"port", 1, NULL, 'P'}, |
| 309 | {"continue", 1, NULL, 'c'}, |
| 310 | {"verbose", 0, NULL, 'v'}, |
| 311 | {0, 0, 0, 0} |
| 312 | }; |
| 313 | |
| 314 | #ifdef CONFIG_FTPPUT |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 315 | if (bb_applet_name[3] == 'p') { |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 316 | ftp_action = ftp_send; |
| 317 | } |
| 318 | #endif |
| 319 | #ifdef CONFIG_FTPGET |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 320 | if (bb_applet_name[3] == 'g') { |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 321 | ftp_action = ftp_recieve; |
| 322 | } |
| 323 | #endif |
| 324 | |
| 325 | /* Set default values */ |
| 326 | server = ftp_init(); |
| 327 | verbose_flag = 0; |
| 328 | |
| 329 | /* |
| 330 | * Decipher the command line |
| 331 | */ |
Eric Andersen | 04d055f | 2003-11-03 21:20:18 +0000 | [diff] [blame] | 332 | server->port = "21"; |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 333 | while ((opt = getopt_long(argc, argv, "u:p:P:cv", long_options, &option_index)) != EOF) { |
| 334 | switch(opt) { |
| 335 | case 'c': |
| 336 | do_continue = 1; |
| 337 | break; |
| 338 | case 'u': |
| 339 | server->user = optarg; |
| 340 | break; |
| 341 | case 'p': |
| 342 | server->password = optarg; |
| 343 | break; |
| 344 | case 'P': |
| 345 | server->port = optarg; |
| 346 | break; |
| 347 | case 'v': |
| 348 | verbose_flag = 1; |
| 349 | break; |
| 350 | default: |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 351 | bb_show_usage(); |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 352 | } |
| 353 | } |
| 354 | |
| 355 | /* |
| 356 | * Process the non-option command line arguments |
| 357 | */ |
| 358 | if (argc - optind != 3) { |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 359 | bb_show_usage(); |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 360 | } |
| 361 | |
Eric Andersen | 04d055f | 2003-11-03 21:20:18 +0000 | [diff] [blame] | 362 | /* We want to do exactly _one_ DNS lookup, since some |
| 363 | * sites (i.e. ftp.us.debian.org) use round-robin DNS |
| 364 | * and we want to connect to only one IP... */ |
| 365 | server->s_in = &s_in; |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 366 | server->host = argv[optind]; |
Eric Andersen | 04d055f | 2003-11-03 21:20:18 +0000 | [diff] [blame] | 367 | bb_lookup_host(&s_in, server->host, NULL); |
| 368 | if (verbose_flag) { |
| 369 | fprintf(stdout, "Connecting to %s[%s]:%s\n", |
| 370 | server->host, inet_ntoa(s_in.sin_addr), server->port); |
| 371 | } |
| 372 | |
| 373 | /* Connect/Setup/Configure the FTP session */ |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 374 | control_stream = ftp_login(server); |
| 375 | |
Eric Andersen | 04d055f | 2003-11-03 21:20:18 +0000 | [diff] [blame] | 376 | return(ftp_action(server, control_stream, argv[optind + 1], argv[optind + 2])); |
Glenn L McGrath | 02d7cbf | 2002-12-13 02:43:50 +0000 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | /* |
| 380 | Local Variables: |
| 381 | c-file-style: "linux" |
| 382 | c-basic-offset: 4 |
| 383 | tab-width: 4 |
| 384 | End: |
| 385 | */ |