Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2002-12-13 11:20:44 +0300
committerGlenn L McGrath <bug1@ihug.co.nz>2002-12-13 11:20:44 +0300
commit25fe94fd32f39a76294456a7bc7b8dd0595afb0d (patch)
tree5f41636eb6f772de78a17e90189da6aeee3f32a7 /networking/ftpgetput.c
parenta67dffe186eefb6cf75c08422dbfa0e4a752c692 (diff)
Merge copyfd and copy_file_chunk
Diffstat (limited to 'networking/ftpgetput.c')
-rw-r--r--networking/ftpgetput.c53
1 files changed, 6 insertions, 47 deletions
diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c
index 909f3b117..a23c64af1 100644
--- a/networking/ftpgetput.c
+++ b/networking/ftpgetput.c
@@ -56,51 +56,6 @@ typedef struct ftp_host_info_s {
static char verbose_flag;
static char do_continue = 0;
-static int copyfd_chunk(int fd1, int fd2, const off_t chunksize)
-{
- size_t nread;
- size_t nwritten;
- size_t size;
- size_t remaining;
- char buffer[BUFSIZ];
-
- if (chunksize) {
- remaining = chunksize;
- } else {
- remaining = -1;
- }
-
- do {
- if ((chunksize > BUFSIZ) || (chunksize == 0)) {
- size = BUFSIZ;
- } else {
- size = chunksize;
- }
-
- nread = safe_read(fd1, buffer, size);
-
- if (nread <= 0) {
- if (chunksize) {
- perror_msg_and_die("read error");
- } else {
- return(0);
- }
- }
-
- nwritten = full_write(fd2, buffer, nread);
-
- if (nwritten != nread) {
- error_msg_and_die("Unable to write all data");
- }
-
- if (chunksize) {
- remaining -= nwritten;
- }
- } while (remaining != 0);
-
- return 0;
-}
-
static ftp_host_info_t *ftp_init(void)
{
ftp_host_info_t *host;
@@ -252,7 +207,9 @@ static int ftp_recieve(FILE *control_stream, const char *host, const char *local
}
/* Copy the file */
- copyfd_chunk(fd_data, fd_local, filesize);
+ if (copyfd(fd_data, fd_local, filesize) == -1) {
+ exit(EXIT_FAILURE);
+ }
/* close it all down */
close(fd_data);
@@ -311,7 +268,9 @@ static int ftp_send(FILE *control_stream, const char *host, const char *server_p
}
/* transfer the file */
- copyfd_chunk(fd_local, fd_data, 0);
+ if (copyfd(fd_local, fd_data, 0) == -1) {
+ exit(EXIT_FAILURE);
+ }
/* close it all down */
close(fd_data);