From d6d9d77c9fed15f67db85eefd3ba8237640602e8 Mon Sep 17 00:00:00 2001 From: Adam Heath Date: Wed, 20 Dec 2000 08:27:57 +0000 Subject: [PATCH] Make {stream,fd}_null_copy use [lf]seek, and fall back on the buffer code, if stream/fd refer to a pipe. --- ChangeLog | 5 +++++ include/dpkg.h.in | 22 ++++++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7235bee5..785baf66 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Dec 20 02:21:43 CST 2000 Adam Heath + + * include/dpkg.h.in: Make {stream,fd}_null_copy use [lf]seek, and fall + back on the buffer code, if stream/fd refer to a pipe. + Wed Dec 20 02:17:56 CST 2000 Adam Heath * configure.in, Makefile.conf.in: Move -D_GNU_SOURCE from configure.in diff --git a/include/dpkg.h.in b/include/dpkg.h.in index 8c31a213..7c9a0698 100644 --- a/include/dpkg.h.in +++ b/include/dpkg.h.in @@ -225,14 +225,20 @@ struct buffer_data { buffer_copy_setup((void *)fd, BUFFER_READ_FD, NULL, \ buf, BUFFER_WRITE_VBUF, NULL, \ limit, desc) -#define fd_null_copy(fd, limit, desc...)\ - buffer_copy_setup((void *)fd, BUFFER_READ_FD, NULL, \ - NULL, BUFFER_WRITE_NULL, NULL, \ - limit, desc) -#define stream_null_copy(file, limit, desc...)\ - buffer_copy_setup((void *)file, BUFFER_READ_STREAM, NULL, \ - NULL, BUFFER_WRITE_NULL, NULL, \ - limit, desc) +#define fd_null_copy(fd, limit, desc...) \ + if (lseek(fd, limit, SEEK_CUR) == -1) { \ + if(errno != ESPIPE) ohshite(desc); \ + buffer_copy_setup((void *)fd, BUFFER_READ_FD, NULL, \ + 0, BUFFER_WRITE_NULL, NULL, \ + limit, desc);\ + } +#define stream_null_copy(file, limit, desc...) \ + if (fseek(file, limit, SEEK_CUR) == -1) { \ + if(errno != EBADF) ohshite(desc); \ + buffer_copy_setup((void *)file, BUFFER_READ_STREAM, NULL, \ + 0, BUFFER_WRITE_NULL, NULL, \ + limit, desc);\ + } #define stream_fd_copy(file, fd, limit, desc...)\ buffer_copy_setup((void *)file, BUFFER_READ_STREAM, NULL, \ (void *)fd, BUFFER_WRITE_FD, NULL, \ -- 2.39.5