if (len < SIZEOF(xReply)) { _XIOError (dpy); buf += *lenp; *lenp = 0; return buf; }
_XAsyncReply(dpy, rep, buf, lenp, discard)    Display *dpy;    register xReply *rep;    char *buf;    register int *lenp;    Bool discard;{    register _XAsyncHandler *async, *next;    register int len;    register Bool consumed = False;    char *nbuf;    (void) _XSetLastRequestRead(dpy, &rep->generic);    len = SIZEOF(xReply) + (rep->generic.length << 2);    for (async = dpy->async_handlers; async; async = next) {	next = async->next;	if (consumed = (*async->handler)(dpy, rep, buf, *lenp, async->data))	    break;    }    if (!consumed) {	if (!discard)	    return buf;	(void) fprintf(stderr, 		       "Xlib: unexpected async reply (sequence 0x%lx)!\n",		       dpy->last_request_read);#ifdef XTHREADS#ifdef XTHREADS_DEBUG	printf("thread %x, unexpected async reply\n", XThread_Self());#endif#endif	if (len > *lenp)	    _XEatData(dpy, len - *lenp);    }    if (len >= *lenp) {	buf += *lenp;	*lenp = 0;	return buf;    }    *lenp -= len;    buf += len;    len = *lenp;    nbuf = buf;    while (len > SIZEOF(xReply)) {	if (*buf == X_Reply)	    return nbuf;	buf += SIZEOF(xReply);	len -= SIZEOF(xReply);    }    if (len > 0 && len < SIZEOF(xReply)) {	buf = nbuf;	len = SIZEOF(xReply) - len;	nbuf -= len;	memmove(nbuf, buf, *lenp);	(void) _XRead(dpy, nbuf + *lenp, (long)len);	*lenp += len;    }    return nbuf;}