summaryrefslogtreecommitdiff
path: root/src/xcb_out.c
diff options
context:
space:
mode:
authorJamey Sharp <jamey@minilop.net>2006-02-23 12:48:27 -0800
committerJamey Sharp <jamey@minilop.net>2006-02-23 12:48:27 -0800
commit55c1842686d2e668708cd106b5e08847df0184c3 (patch)
tree4cb6023b11611a740ae4c927c48437ee1f4b13bd /src/xcb_out.c
parent213b5725928ccf8aedc807cc40a261b2d5431247 (diff)
Move _xcb_write and _xcb_writev to xcb_out.c and make them static, since only _xcb_out_write calls them.
Diffstat (limited to 'src/xcb_out.c')
-rw-r--r--src/xcb_out.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/xcb_out.c b/src/xcb_out.c
index 62d7053..a3cb2e4 100644
--- a/src/xcb_out.c
+++ b/src/xcb_out.c
@@ -27,6 +27,7 @@
#include <assert.h>
#include <stdlib.h>
+#include <unistd.h>
#include <string.h>
#include <errno.h>
@@ -47,6 +48,40 @@ static int force_sequence_wrap(XCBConnection *c)
return ret;
}
+static int _xcb_write(const int fd, char (*buf)[], int *count)
+{
+ int n = write(fd, *buf, *count);
+ if(n > 0)
+ {
+ *count -= n;
+ if(*count)
+ memmove(*buf, *buf + n, *count);
+ }
+ return n;
+}
+
+static int _xcb_writev(const int fd, struct iovec *vec, int count)
+{
+ int n = writev(fd, vec, count);
+ if(n > 0)
+ {
+ int rem = n;
+ for(; count; --count, ++vec)
+ {
+ int cur = vec->iov_len;
+ if(cur > rem)
+ cur = rem;
+ vec->iov_len -= cur;
+ vec->iov_base = (char *) vec->iov_base + cur;
+ rem -= cur;
+ if(vec->iov_len)
+ break;
+ }
+ assert(rem == 0);
+ }
+ return n;
+}
+
/* Public interface */
CARD32 XCBGetMaximumRequestLength(XCBConnection *c)