Sometimes i get carried away with the use of function pointers, im sure
it seemed like a good idea at the time.
This commit is contained in:
parent
96099d51b6
commit
15c3512614
@ -27,6 +27,6 @@
|
|||||||
extern void seek_by_char(const archive_handle_t *archive_handle, const unsigned int jump_size)
|
extern void seek_by_char(const archive_handle_t *archive_handle, const unsigned int jump_size)
|
||||||
{
|
{
|
||||||
if (jump_size) {
|
if (jump_size) {
|
||||||
bb_full_fd_action(archive_handle->src_fd, -1, jump_size, NULL);
|
bb_copyfd_size(archive_handle->src_fd, -1, jump_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -483,6 +483,5 @@ extern void xregcomp(regex_t *preg, const char *regex, int cflags);
|
|||||||
#define HASH_SHA1 1
|
#define HASH_SHA1 1
|
||||||
#define HASH_MD5 2
|
#define HASH_MD5 2
|
||||||
extern int hash_fd(int fd, const size_t size, const uint8_t hash_algo, uint8_t *hashval);
|
extern int hash_fd(int fd, const size_t size, const uint8_t hash_algo, uint8_t *hashval);
|
||||||
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));
|
|
||||||
|
|
||||||
#endif /* __LIBCONFIG_H__ */
|
#endif /* __LIBCONFIG_H__ */
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
|
|
||||||
/* If size is 0 copy until EOF */
|
/* 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;
|
size_t read_total = 0;
|
||||||
RESERVE_CONFIG_BUFFER(buffer,BUFSIZ);
|
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);
|
read_actual = safe_read(src_fd, buffer, read_try);
|
||||||
if (read_actual > 0) {
|
if ((read_actual > 0) && (dst_fd >= 0)) {
|
||||||
if (action && (action(dst_fd, buffer, (size_t) read_actual) != read_actual)) {
|
if (bb_full_write(dst_fd, buffer, (size_t) read_actual) != read_actual) {
|
||||||
bb_perror_msg(bb_msg_write_error); /* match Read error below */
|
bb_perror_msg(bb_msg_write_error); /* match Read error below */
|
||||||
break;
|
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)
|
extern int bb_copyfd_size(int fd1, int fd2, const off_t size)
|
||||||
{
|
{
|
||||||
if (size) {
|
if (size) {
|
||||||
return(bb_full_fd_action(fd1, fd2, size, bb_full_write));
|
return(bb_full_fd_action(fd1, fd2, size));
|
||||||
}
|
}
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int bb_copyfd_eof(int fd1, int fd2)
|
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));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user