diff options
author | Glenn L McGrath <bug1@ihug.co.nz> | 2004-02-21 09:20:56 +0000 |
---|---|---|
committer | Glenn L McGrath <bug1@ihug.co.nz> | 2004-02-21 09:20:56 +0000 |
commit | 15c3512614d699efe17f1942f1ef414f9ec29b79 (patch) | |
tree | 918c56f64eb92670bf2809ddf346824c91d3a8ab | |
parent | 96099d51b6a872fbd33cdaef123bf93fbc4e9871 (diff) | |
download | busybox-w32-15c3512614d699efe17f1942f1ef414f9ec29b79.tar.gz busybox-w32-15c3512614d699efe17f1942f1ef414f9ec29b79.tar.bz2 busybox-w32-15c3512614d699efe17f1942f1ef414f9ec29b79.zip |
Sometimes i get carried away with the use of function pointers, im sure
it seemed like a good idea at the time.
-rw-r--r-- | archival/libunarchive/seek_by_char.c | 2 | ||||
-rw-r--r-- | include/libbb.h | 1 | ||||
-rw-r--r-- | libbb/copyfd.c | 10 |
3 files changed, 6 insertions, 7 deletions
diff --git a/archival/libunarchive/seek_by_char.c b/archival/libunarchive/seek_by_char.c index c0315616e..a50d566f5 100644 --- a/archival/libunarchive/seek_by_char.c +++ b/archival/libunarchive/seek_by_char.c | |||
@@ -27,6 +27,6 @@ | |||
27 | extern void seek_by_char(const archive_handle_t *archive_handle, const unsigned int jump_size) | 27 | extern void seek_by_char(const archive_handle_t *archive_handle, const unsigned int jump_size) |
28 | { | 28 | { |
29 | if (jump_size) { | 29 | if (jump_size) { |
30 | bb_full_fd_action(archive_handle->src_fd, -1, jump_size, NULL); | 30 | bb_copyfd_size(archive_handle->src_fd, -1, jump_size); |
31 | } | 31 | } |
32 | } | 32 | } |
diff --git a/include/libbb.h b/include/libbb.h index 15e3e49cf..61888042d 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -483,6 +483,5 @@ extern void xregcomp(regex_t *preg, const char *regex, int cflags); | |||
483 | #define HASH_SHA1 1 | 483 | #define HASH_SHA1 1 |
484 | #define HASH_MD5 2 | 484 | #define HASH_MD5 2 |
485 | extern int hash_fd(int fd, const size_t size, const uint8_t hash_algo, uint8_t *hashval); | 485 | extern int hash_fd(int fd, const size_t size, const uint8_t hash_algo, uint8_t *hashval); |
486 | 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)); | ||
487 | 486 | ||
488 | #endif /* __LIBCONFIG_H__ */ | 487 | #endif /* __LIBCONFIG_H__ */ |
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 @@ | |||
34 | 34 | ||
35 | 35 | ||
36 | /* If size is 0 copy until EOF */ | 36 | /* If size is 0 copy until EOF */ |
37 | 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)) | 37 | static size_t bb_full_fd_action(int src_fd, int dst_fd, const size_t size) |
38 | { | 38 | { |
39 | size_t read_total = 0; | 39 | size_t read_total = 0; |
40 | RESERVE_CONFIG_BUFFER(buffer,BUFSIZ); | 40 | 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 | |||
50 | } | 50 | } |
51 | 51 | ||
52 | read_actual = safe_read(src_fd, buffer, read_try); | 52 | read_actual = safe_read(src_fd, buffer, read_try); |
53 | if (read_actual > 0) { | 53 | if ((read_actual > 0) && (dst_fd >= 0)) { |
54 | if (action && (action(dst_fd, buffer, (size_t) read_actual) != read_actual)) { | 54 | if (bb_full_write(dst_fd, buffer, (size_t) read_actual) != read_actual) { |
55 | bb_perror_msg(bb_msg_write_error); /* match Read error below */ | 55 | bb_perror_msg(bb_msg_write_error); /* match Read error below */ |
56 | break; | 56 | break; |
57 | } | 57 | } |
@@ -79,12 +79,12 @@ extern size_t bb_full_fd_action(int src_fd, int dst_fd, const size_t size, ssize | |||
79 | extern int bb_copyfd_size(int fd1, int fd2, const off_t size) | 79 | extern int bb_copyfd_size(int fd1, int fd2, const off_t size) |
80 | { | 80 | { |
81 | if (size) { | 81 | if (size) { |
82 | return(bb_full_fd_action(fd1, fd2, size, bb_full_write)); | 82 | return(bb_full_fd_action(fd1, fd2, size)); |
83 | } | 83 | } |
84 | return(0); | 84 | return(0); |
85 | } | 85 | } |
86 | 86 | ||
87 | extern int bb_copyfd_eof(int fd1, int fd2) | 87 | extern int bb_copyfd_eof(int fd1, int fd2) |
88 | { | 88 | { |
89 | return(bb_full_fd_action(fd1, fd2, 0, bb_full_write)); | 89 | return(bb_full_fd_action(fd1, fd2, 0)); |
90 | } | 90 | } |