diff options
author | Jamey Sharp <jamey@minilop.net> | 2006-02-24 00:48:18 -0800 |
---|---|---|
committer | Jamey Sharp <jamey@minilop.net> | 2006-02-24 00:48:18 -0800 |
commit | 3f8d0bd5322749132626e8f203017b6da6448fd0 (patch) | |
tree | 74412ab653240da848c1072618430a23825feb12 | |
parent | cdf362f33a7bc4d412231de32e37ffb65a06d3f1 (diff) |
Move _xcb_readn to xcb_in.c and make it static. Minor change to _xcb_read_block to not depend on _xcb_readn.
-rw-r--r-- | src/xcb_in.c | 11 | ||||
-rw-r--r-- | src/xcb_util.c | 12 | ||||
-rw-r--r-- | src/xcbint.h | 1 |
3 files changed, 13 insertions, 11 deletions
diff --git a/src/xcb_in.c b/src/xcb_in.c index 967beac..4a62a48 100644 --- a/src/xcb_in.c +++ b/src/xcb_in.c @@ -28,6 +28,7 @@ #include <assert.h> #include <string.h> #include <stdlib.h> +#include <unistd.h> #include <stdio.h> #include <errno.h> @@ -68,6 +69,14 @@ static void wake_up_next_reader(XCBConnection *c) assert(pthreadret == 0); } +static int readn(const int fd, void *buf, const int buflen, int *count) +{ + int n = read(fd, ((char *) buf) + *count, buflen - *count); + if(n > 0) + *count += n; + return n; +} + static int read_packet(XCBConnection *c) { XCBGenericRep genrep; @@ -327,7 +336,7 @@ int _xcb_in_expect_reply(XCBConnection *c, unsigned int request, enum workaround int _xcb_in_read(XCBConnection *c) { - int n = _xcb_readn(c->fd, c->in.queue, sizeof(c->in.queue), &c->in.queue_len); + int n = readn(c->fd, c->in.queue, sizeof(c->in.queue), &c->in.queue_len); while(read_packet(c)) /* empty */; return (n > 0) || (n < 0 && errno == EAGAIN); diff --git a/src/xcb_util.c b/src/xcb_util.c index db3bffb..c9c7f92 100644 --- a/src/xcb_util.c +++ b/src/xcb_util.c @@ -217,20 +217,14 @@ int _xcb_set_fd_flags(const int fd) return 1; } -int _xcb_readn(const int fd, void *buf, const int buflen, int *count) -{ - int n = read(fd, ((char *) buf) + *count, buflen - *count); - if(n > 0) - *count += n; - return n; -} - int _xcb_read_block(const int fd, void *buf, const size_t len) { int done = 0; while(done < len) { - int ret = _xcb_readn(fd, buf, len, &done); + int ret = read(fd, ((char *) buf) + done, len - done); + if(ret > 0) + done += ret; if(ret < 0 && errno == EAGAIN) { fd_set fds; diff --git a/src/xcbint.h b/src/xcbint.h index e7e6688..ebbb2fe 100644 --- a/src/xcbint.h +++ b/src/xcbint.h @@ -72,7 +72,6 @@ void *_xcb_map_remove(_xcb_map *q, unsigned int key); #define XCB_PAD(i) ((4 - (i & 3)) & 3) int _xcb_set_fd_flags(const int fd); -int _xcb_readn(const int fd, void *buf, const int buflen, int *count); int _xcb_read_block(const int fd, void *buf, const size_t len); |