[BusyBox-cvs] busybox/libbb copyfd.c,1.9,1.10
Glenn McGrath
bug1 at busybox.net
Sat Feb 21 09:20:58 UTC 2004
Update of /var/cvs/busybox/libbb
In directory nail:/tmp/cvs-serv22717/libbb
Modified Files:
copyfd.c
Log Message:
Sometimes i get carried away with the use of function pointers, im sure
it seemed like a good idea at the time.
Index: copyfd.c
===================================================================
RCS file: /var/cvs/busybox/libbb/copyfd.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- a/copyfd.c 24 Nov 2003 23:50:07 -0000 1.9
+++ b/copyfd.c 21 Feb 2004 09:20:55 -0000 1.10
@@ -34,7 +34,7 @@
/* If size is 0 copy until EOF */
-extern size_t bb_full_fd_action(int src_fd, int dst_fd, const size_t size, ssize_t (*action)(int fd, const void *, size_t))
+static size_t bb_full_fd_action(int src_fd, int dst_fd, const size_t size)
{
size_t read_total = 0;
RESERVE_CONFIG_BUFFER(buffer,BUFSIZ);
@@ -50,8 +50,8 @@
}
read_actual = safe_read(src_fd, buffer, read_try);
- if (read_actual > 0) {
- if (action && (action(dst_fd, buffer, (size_t) read_actual) != read_actual)) {
+ if ((read_actual > 0) && (dst_fd >= 0)) {
+ if (bb_full_write(dst_fd, buffer, (size_t) read_actual) != read_actual) {
bb_perror_msg(bb_msg_write_error); /* match Read error below */
break;
}
@@ -79,12 +79,12 @@
extern int bb_copyfd_size(int fd1, int fd2, const off_t size)
{
if (size) {
- return(bb_full_fd_action(fd1, fd2, size, bb_full_write));
+ return(bb_full_fd_action(fd1, fd2, size));
}
return(0);
}
extern int bb_copyfd_eof(int fd1, int fd2)
{
- return(bb_full_fd_action(fd1, fd2, 0, bb_full_write));
+ return(bb_full_fd_action(fd1, fd2, 0));
}
More information about the busybox-cvs
mailing list