[BusyBox-cvs] busybox/networking ftpgetput.c,1.3,1.4
Glenn McGrath
bug1 at busybox.net
Fri Dec 13 08:20:48 UTC 2002
Update of /var/cvs/busybox/networking
In directory winder:/tmp/cvs-serv23731/networking
Modified Files:
ftpgetput.c
Log Message:
Merge copyfd and copy_file_chunk
Index: ftpgetput.c
===================================================================
RCS file: /var/cvs/busybox/networking/ftpgetput.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ftpgetput.c 13 Dec 2002 05:57:46 -0000 1.3
+++ ftpgetput.c 13 Dec 2002 08:20:44 -0000 1.4
@@ -56,51 +56,6 @@
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 @@
}
/* 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 @@
}
/* 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);
More information about the busybox-cvs
mailing list