Move _xcb_read_block to xcb_in.c and make it static. Change calls in xcb_conn.c to _xcb_in_read_block instead.

This commit is contained in:
Jamey Sharp 2006-02-24 01:40:45 -08:00
parent 838317f4d3
commit 67b2649dc4
4 changed files with 24 additions and 25 deletions

View File

@ -88,7 +88,7 @@ static int read_setup(XCBConnection *c)
if(!c->setup)
return 0;
if(_xcb_read_block(c->fd, c->setup, sizeof(XCBConnSetupGenericRep)) != sizeof(XCBConnSetupGenericRep))
if(_xcb_in_read_block(c, c->setup, sizeof(XCBConnSetupGenericRep)) != sizeof(XCBConnSetupGenericRep))
return 0;
{
@ -98,7 +98,7 @@ static int read_setup(XCBConnection *c)
c->setup = tmp;
}
if(_xcb_read_block(c->fd, (char *) c->setup + sizeof(XCBConnSetupGenericRep), c->setup->length * 4) <= 0)
if(_xcb_in_read_block(c, (char *) c->setup + sizeof(XCBConnSetupGenericRep), c->setup->length * 4) <= 0)
return 0;
/* 0 = failed, 2 = authenticate, 1 = success */

View File

@ -153,6 +153,27 @@ static int read_packet(XCBConnection *c)
return 1; /* I have something for you... */
}
static int read_block(const int fd, void *buf, const size_t len)
{
int done = 0;
while(done < len)
{
int ret = read(fd, ((char *) buf) + done, len - done);
if(ret > 0)
done += ret;
if(ret < 0 && errno == EAGAIN)
{
fd_set fds;
FD_ZERO(&fds);
FD_SET(fd, &fds);
ret = select(fd + 1, &fds, 0, 0, 0);
}
if(ret <= 0)
return ret;
}
return len;
}
/* Public interface */
void *XCBWaitForReply(XCBConnection *c, unsigned int request, XCBGenericError **e)
@ -348,7 +369,7 @@ int _xcb_in_read_block(XCBConnection *c, void *buf, int len)
if(len > done)
{
int ret = _xcb_read_block(c->fd, (char *) buf + done, len - done);
int ret = read_block(c->fd, (char *) buf + done, len - done);
if(ret <= 0)
return ret;
}

View File

@ -216,24 +216,3 @@ int _xcb_set_fd_flags(const int fd)
return 0;
return 1;
}
int _xcb_read_block(const int fd, void *buf, const size_t len)
{
int done = 0;
while(done < len)
{
int ret = read(fd, ((char *) buf) + done, len - done);
if(ret > 0)
done += ret;
if(ret < 0 && errno == EAGAIN)
{
fd_set fds;
FD_ZERO(&fds);
FD_SET(fd, &fds);
ret = select(fd + 1, &fds, 0, 0, 0);
}
if(ret <= 0)
return ret;
}
return len;
}

View File

@ -73,7 +73,6 @@ void *_xcb_map_remove(_xcb_map *q, unsigned int key);
#define XCB_PAD(i) (-(i) & 3)
int _xcb_set_fd_flags(const int fd);
int _xcb_read_block(const int fd, void *buf, const size_t len);
/* xcb_out.c */