aboutsummaryrefslogtreecommitdiff
path: root/libbb/copyfd.c
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2004-02-21 09:20:56 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2004-02-21 09:20:56 +0000
commit15c3512614d699efe17f1942f1ef414f9ec29b79 (patch)
tree918c56f64eb92670bf2809ddf346824c91d3a8ab /libbb/copyfd.c
parent96099d51b6a872fbd33cdaef123bf93fbc4e9871 (diff)
downloadbusybox-15c3512614d699efe17f1942f1ef414f9ec29b79.tar.gz
Sometimes i get carried away with the use of function pointers, im sure
it seemed like a good idea at the time.
Diffstat (limited to 'libbb/copyfd.c')
-rw-r--r--libbb/copyfd.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/libbb/copyfd.c b/libbb/copyfd.c
index 1ef994c98..9ab83728c 100644
--- a/libbb/copyfd.c
+++ b/libbb/copyfd.c
@@ -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 @@ extern size_t bb_full_fd_action(int src_fd, int dst_fd, const size_t size, ssize
}
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 size_t bb_full_fd_action(int src_fd, int dst_fd, const size_t size, ssize
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));
}