From 901637760b4206e968e73dd5ff7430c107c27b57 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 18 Jan 2007 21:54:08 -0500 Subject: Add fdprintf(). Remove reread() and rewrite() which handle -EINTR, which shouldn't be a problem if we register signal handlers with sigaction(SA_RESTART) Straighten out count and len (I generally consistently use "count" for the current progress and "len" for the total, but this time I got them backwards for some reason and don't want to confuse myself in future.) --- lib/functions.c | 57 ++++++++++++++++++++----------------------------------- lib/lib.h | 12 +++++------- lib/portability.h | 6 ++++++ 3 files changed, 32 insertions(+), 43 deletions(-) (limited to 'lib') diff --git a/lib/functions.c b/lib/functions.c index 98a344a2..ce3edccc 100644 --- a/lib/functions.c +++ b/lib/functions.c @@ -174,30 +174,12 @@ FILE *xfopen(char *path, char *mode) return f; } -// Read from file handle, retrying if interrupted. -ssize_t reread(int fd, void *buf, size_t count) -{ - for (;;) { - ssize_t len = read(fd, buf, count); - if (len >= 0 || errno != EINTR) return len; - } -} - -// Write to file handle, retrying if interrupted. -ssize_t rewrite(int fd, void *buf, size_t count) -{ - for (;;) { - ssize_t len = write(fd, buf, count); - if (len >= 0 || errno != EINTR) return len; - } -} - // Keep reading until full or EOF -ssize_t readall(int fd, void *buf, size_t count) +ssize_t readall(int fd, void *buf, size_t len) { - size_t len = 0; - while (len +#define fdprintf(...) dprintf(__VA_ARGS__) + #include #if __BYTE_ORDER == __BIG_ENDIAN -- cgit v1.2.3