diff options
author | Manuel Novoa III <mjn3@codepoet.org> | 2003-03-19 09:13:01 +0000 |
---|---|---|
committer | Manuel Novoa III <mjn3@codepoet.org> | 2003-03-19 09:13:01 +0000 |
commit | cad5364599eb5062d59e0c397ed638ddd61a8d5d (patch) | |
tree | a318d0f03aa076c74b576ea45dc543a5669e8e91 /networking/ftpgetput.c | |
parent | e01f9662a5bd5d91be4f6b3941b57fff73cd5af1 (diff) | |
download | busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.tar.gz busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.tar.bz2 busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.zip |
Major coreutils update.
Diffstat (limited to 'networking/ftpgetput.c')
-rw-r--r-- | networking/ftpgetput.c | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c index 44e91c37a..394389043 100644 --- a/networking/ftpgetput.c +++ b/networking/ftpgetput.c | |||
@@ -77,7 +77,7 @@ static ftp_host_info_t *ftp_init(void) | |||
77 | static int ftpcmd(const char *s1, const char *s2, FILE *stream, char *buf) | 77 | static int ftpcmd(const char *s1, const char *s2, FILE *stream, char *buf) |
78 | { | 78 | { |
79 | if (verbose_flag) { | 79 | if (verbose_flag) { |
80 | error_msg("cmd %s%s", s1, s2); | 80 | bb_error_msg("cmd %s%s", s1, s2); |
81 | } | 81 | } |
82 | 82 | ||
83 | if (s1) { | 83 | if (s1) { |
@@ -90,7 +90,7 @@ static int ftpcmd(const char *s1, const char *s2, FILE *stream, char *buf) | |||
90 | 90 | ||
91 | do { | 91 | do { |
92 | if (fgets(buf, 510, stream) == NULL) { | 92 | if (fgets(buf, 510, stream) == NULL) { |
93 | perror_msg_and_die("fgets()"); | 93 | bb_perror_msg_and_die("fgets()"); |
94 | } | 94 | } |
95 | } while (! isdigit(buf[0]) || buf[3] != ' '); | 95 | } while (! isdigit(buf[0]) || buf[3] != ' '); |
96 | 96 | ||
@@ -125,11 +125,11 @@ static FILE *ftp_login(ftp_host_info_t *server) | |||
125 | control_fd = xconnect(server->host, server->port); | 125 | control_fd = xconnect(server->host, server->port); |
126 | control_stream = fdopen(control_fd, "r+"); | 126 | control_stream = fdopen(control_fd, "r+"); |
127 | if (control_stream == NULL) { | 127 | if (control_stream == NULL) { |
128 | perror_msg_and_die("Couldnt open control stream"); | 128 | bb_perror_msg_and_die("Couldnt open control stream"); |
129 | } | 129 | } |
130 | 130 | ||
131 | if (ftpcmd(NULL, NULL, control_stream, buf) != 220) { | 131 | if (ftpcmd(NULL, NULL, control_stream, buf) != 220) { |
132 | error_msg_and_die("%s", buf + 4); | 132 | bb_error_msg_and_die("%s", buf + 4); |
133 | } | 133 | } |
134 | 134 | ||
135 | /* Login to the server */ | 135 | /* Login to the server */ |
@@ -138,11 +138,11 @@ static FILE *ftp_login(ftp_host_info_t *server) | |||
138 | break; | 138 | break; |
139 | case 331: | 139 | case 331: |
140 | if (ftpcmd("PASS ", server->password, control_stream, buf) != 230) { | 140 | if (ftpcmd("PASS ", server->password, control_stream, buf) != 230) { |
141 | error_msg_and_die("PASS error: %s", buf + 4); | 141 | bb_error_msg_and_die("PASS error: %s", buf + 4); |
142 | } | 142 | } |
143 | break; | 143 | break; |
144 | default: | 144 | default: |
145 | error_msg_and_die("USER error: %s", buf + 4); | 145 | bb_error_msg_and_die("USER error: %s", buf + 4); |
146 | } | 146 | } |
147 | 147 | ||
148 | ftpcmd("TYPE I", NULL, control_stream, buf); | 148 | ftpcmd("TYPE I", NULL, control_stream, buf); |
@@ -161,12 +161,12 @@ static int ftp_recieve(FILE *control_stream, const char *host, const char *local | |||
161 | int fd_local; | 161 | int fd_local; |
162 | off_t beg_range = 0; | 162 | off_t beg_range = 0; |
163 | 163 | ||
164 | filename = get_last_path_component(server_path); | 164 | filename = bb_get_last_path_component(server_path); |
165 | local_file = concat_path_file(local_path, filename); | 165 | local_file = concat_path_file(local_path, filename); |
166 | 166 | ||
167 | /* Connect to the data socket */ | 167 | /* Connect to the data socket */ |
168 | if (ftpcmd("PASV", NULL, control_stream, buf) != 227) { | 168 | if (ftpcmd("PASV", NULL, control_stream, buf) != 227) { |
169 | error_msg_and_die("PASV error: %s", buf + 4); | 169 | bb_error_msg_and_die("PASV error: %s", buf + 4); |
170 | } | 170 | } |
171 | fd_data = xconnect_ftpdata(host, buf); | 171 | fd_data = xconnect_ftpdata(host, buf); |
172 | 172 | ||
@@ -177,7 +177,7 @@ static int ftp_recieve(FILE *control_stream, const char *host, const char *local | |||
177 | if (do_continue) { | 177 | if (do_continue) { |
178 | struct stat sbuf; | 178 | struct stat sbuf; |
179 | if (lstat(local_file, &sbuf) < 0) { | 179 | if (lstat(local_file, &sbuf) < 0) { |
180 | perror_msg_and_die("fstat()"); | 180 | bb_perror_msg_and_die("fstat()"); |
181 | } | 181 | } |
182 | if (sbuf.st_size > 0) { | 182 | if (sbuf.st_size > 0) { |
183 | beg_range = sbuf.st_size; | 183 | beg_range = sbuf.st_size; |
@@ -196,25 +196,25 @@ static int ftp_recieve(FILE *control_stream, const char *host, const char *local | |||
196 | } | 196 | } |
197 | 197 | ||
198 | if (ftpcmd("RETR ", server_path, control_stream, buf) > 150) { | 198 | if (ftpcmd("RETR ", server_path, control_stream, buf) > 150) { |
199 | error_msg_and_die("RETR error: %s", buf + 4); | 199 | bb_error_msg_and_die("RETR error: %s", buf + 4); |
200 | } | 200 | } |
201 | 201 | ||
202 | /* only make a local file if we know that one exists on the remote server */ | 202 | /* only make a local file if we know that one exists on the remote server */ |
203 | if (do_continue) { | 203 | if (do_continue) { |
204 | fd_local = xopen(local_file, O_APPEND | O_WRONLY); | 204 | fd_local = bb_xopen(local_file, O_APPEND | O_WRONLY); |
205 | } else { | 205 | } else { |
206 | fd_local = xopen(local_file, O_CREAT | O_TRUNC | O_WRONLY); | 206 | fd_local = bb_xopen(local_file, O_CREAT | O_TRUNC | O_WRONLY); |
207 | } | 207 | } |
208 | 208 | ||
209 | /* Copy the file */ | 209 | /* Copy the file */ |
210 | if (copyfd(fd_data, fd_local, filesize) == -1) { | 210 | if (bb_copyfd(fd_data, fd_local, filesize) == -1) { |
211 | exit(EXIT_FAILURE); | 211 | exit(EXIT_FAILURE); |
212 | } | 212 | } |
213 | 213 | ||
214 | /* close it all down */ | 214 | /* close it all down */ |
215 | close(fd_data); | 215 | close(fd_data); |
216 | if (ftpcmd(NULL, NULL, control_stream, buf) != 226) { | 216 | if (ftpcmd(NULL, NULL, control_stream, buf) != 226) { |
217 | error_msg_and_die("ftp error: %s", buf + 4); | 217 | bb_error_msg_and_die("ftp error: %s", buf + 4); |
218 | } | 218 | } |
219 | ftpcmd("QUIT", NULL, control_stream, buf); | 219 | ftpcmd("QUIT", NULL, control_stream, buf); |
220 | 220 | ||
@@ -233,16 +233,16 @@ static int ftp_send(FILE *control_stream, const char *host, const char *server_p | |||
233 | 233 | ||
234 | /* Connect to the data socket */ | 234 | /* Connect to the data socket */ |
235 | if (ftpcmd("PASV", NULL, control_stream, buf) != 227) { | 235 | if (ftpcmd("PASV", NULL, control_stream, buf) != 227) { |
236 | error_msg_and_die("PASV error: %s", buf + 4); | 236 | bb_error_msg_and_die("PASV error: %s", buf + 4); |
237 | } | 237 | } |
238 | fd_data = xconnect_ftpdata(host, buf); | 238 | fd_data = xconnect_ftpdata(host, buf); |
239 | 239 | ||
240 | if (ftpcmd("CWD ", server_path, control_stream, buf) != 250) { | 240 | if (ftpcmd("CWD ", server_path, control_stream, buf) != 250) { |
241 | error_msg_and_die("CWD error: %s", buf + 4); | 241 | bb_error_msg_and_die("CWD error: %s", buf + 4); |
242 | } | 242 | } |
243 | 243 | ||
244 | /* get the local file */ | 244 | /* get the local file */ |
245 | fd_local = xopen(local_path, O_RDONLY); | 245 | fd_local = bb_xopen(local_path, O_RDONLY); |
246 | fstat(fd_local, &sbuf); | 246 | fstat(fd_local, &sbuf); |
247 | 247 | ||
248 | sprintf(buf, "ALLO %lu", sbuf.st_size); | 248 | sprintf(buf, "ALLO %lu", sbuf.st_size); |
@@ -253,7 +253,7 @@ static int ftp_send(FILE *control_stream, const char *host, const char *server_p | |||
253 | break; | 253 | break; |
254 | default: | 254 | default: |
255 | close(fd_local); | 255 | close(fd_local); |
256 | error_msg_and_die("ALLO error: %s", buf + 4); | 256 | bb_error_msg_and_die("ALLO error: %s", buf + 4); |
257 | break; | 257 | break; |
258 | } | 258 | } |
259 | 259 | ||
@@ -264,18 +264,18 @@ static int ftp_send(FILE *control_stream, const char *host, const char *server_p | |||
264 | break; | 264 | break; |
265 | default: | 265 | default: |
266 | close(fd_local); | 266 | close(fd_local); |
267 | error_msg_and_die("STOR error: %s", buf + 4); | 267 | bb_error_msg_and_die("STOR error: %s", buf + 4); |
268 | } | 268 | } |
269 | 269 | ||
270 | /* transfer the file */ | 270 | /* transfer the file */ |
271 | if (copyfd(fd_local, fd_data, 0) == -1) { | 271 | if (bb_copyfd(fd_local, fd_data, 0) == -1) { |
272 | exit(EXIT_FAILURE); | 272 | exit(EXIT_FAILURE); |
273 | } | 273 | } |
274 | 274 | ||
275 | /* close it all down */ | 275 | /* close it all down */ |
276 | close(fd_data); | 276 | close(fd_data); |
277 | if (ftpcmd(NULL, NULL, control_stream, buf) != 226) { | 277 | if (ftpcmd(NULL, NULL, control_stream, buf) != 226) { |
278 | error_msg_and_die("error: %s", buf + 4); | 278 | bb_error_msg_and_die("error: %s", buf + 4); |
279 | } | 279 | } |
280 | ftpcmd("QUIT", NULL, control_stream, buf); | 280 | ftpcmd("QUIT", NULL, control_stream, buf); |
281 | 281 | ||
@@ -307,12 +307,12 @@ int ftpgetput_main(int argc, char **argv) | |||
307 | }; | 307 | }; |
308 | 308 | ||
309 | #ifdef CONFIG_FTPPUT | 309 | #ifdef CONFIG_FTPPUT |
310 | if (applet_name[3] == 'p') { | 310 | if (bb_applet_name[3] == 'p') { |
311 | ftp_action = ftp_send; | 311 | ftp_action = ftp_send; |
312 | } | 312 | } |
313 | #endif | 313 | #endif |
314 | #ifdef CONFIG_FTPGET | 314 | #ifdef CONFIG_FTPGET |
315 | if (applet_name[3] == 'g') { | 315 | if (bb_applet_name[3] == 'g') { |
316 | ftp_action = ftp_recieve; | 316 | ftp_action = ftp_recieve; |
317 | } | 317 | } |
318 | #endif | 318 | #endif |
@@ -342,7 +342,7 @@ int ftpgetput_main(int argc, char **argv) | |||
342 | verbose_flag = 1; | 342 | verbose_flag = 1; |
343 | break; | 343 | break; |
344 | default: | 344 | default: |
345 | show_usage(); | 345 | bb_show_usage(); |
346 | } | 346 | } |
347 | } | 347 | } |
348 | 348 | ||
@@ -350,7 +350,7 @@ int ftpgetput_main(int argc, char **argv) | |||
350 | * Process the non-option command line arguments | 350 | * Process the non-option command line arguments |
351 | */ | 351 | */ |
352 | if (argc - optind != 3) { | 352 | if (argc - optind != 3) { |
353 | show_usage(); | 353 | bb_show_usage(); |
354 | } | 354 | } |
355 | 355 | ||
356 | /* Connect/Setup/Configure the FTP session */ | 356 | /* Connect/Setup/Configure the FTP session */ |