}  if (rep->generic.length > GENERIC_LENGTH_LIMIT) { rep->generic.length = GENERIC_LENGTH_LIMIT; (void) fprintf(stderr, "Xlib: suspiciously long reply length %d set to %d", rep->generic.length, GENERIC_LENGTH_LIMIT);
_XReply (dpy, rep, extra, discard)    register Display *dpy;    register xReply *rep;    int extra;		/* number of 32-bit words expected after the reply */    Bool discard;	/* should I discard data following "extra" words? */{    /* Pull out the serial number now, so that (currently illegal) requests     * generated by an error handler don't confuse us.     */    unsigned long cur_request = dpy->request;#ifdef XTHREADS    struct _XCVList *cvl;#endif    if (dpy->flags & XlibDisplayIOError)	return 0;#ifdef XTHREADS    /* create our condition variable and append to list */    cvl = QueueReplyReaderLock(dpy);    if (cvl) {	cvl->buf = rep;	if (dpy->lock->reply_awaiters == cvl && !dpy->lock->event_awaiters)	    dpy->lock->reply_first = True;    }#ifdef XTHREADS_DEBUG    printf("_XReply called in thread %x, adding %x to cvl\n",	   XThread_Self(), cvl);#endif    _XFlushInt(dpy, cvl ? cvl->cv : NULL);    /* if it is not our turn to read a reply off the wire,     * wait til we're at head of list.  if there is an event waiter,     * and our reply hasn't been read, they'll be in select and will     * hand control back to us next.     */    if(dpy->lock &&       (dpy->lock->reply_awaiters != cvl || !dpy->lock->reply_first)) {	ConditionWait(dpy, cvl->cv);    }    dpy->flags |= XlibDisplayReply;#else /* XTHREADS else */    _XFlush(dpy);#endif    for (;;) {#ifdef XTHREADS	/* Did another thread's _XReadEvents get our reply by accident? */	if (!dpy->lock || !dpy->lock->reply_was_read)#endif	    (void) _XRead(dpy, (char *)rep, (long)SIZEOF(xReply));#ifdef XTHREADS	if (dpy->lock)	    dpy->lock->reply_was_read = False;#endif	switch ((int)rep->generic.type) {	    case X_Reply:	        /* Reply received.  Fast update for synchronous replies,		 * but deal with multiple outstanding replies.		 */	        if (rep->generic.sequenceNumber == (cur_request & 0xffff))		    dpy->last_request_read = cur_request;		else {		    int pend = SIZEOF(xReply);		    if (_XAsyncReply(dpy, rep, (char *)rep, &pend, False)			!= (char *)rep)			continue;		}		if (extra <= rep->generic.length) {		    if (extra > 0)			/* 			 * Read the extra data into storage immediately			 * following the GenericReply structure. 			 */			(void) _XRead (dpy, (char *) (NEXTPTR(rep,xReply)),				((long)extra) << 2);		    if (discard) {			if (extra < rep->generic.length)			    _XEatData(dpy, (rep->generic.length - extra) << 2);		    }#ifdef XTHREADS		    if (dpy->lock) {			if (discard) {			    dpy->lock->reply_bytes_left = 0;			} else {			    dpy->lock->reply_bytes_left =				(rep->generic.length - extra) << 2;			}			if (dpy->lock->reply_bytes_left == 0) {			    dpy->flags &= ~XlibDisplayReply;			    UnlockNextReplyReader(dpy);			}		    } else			dpy->flags &= ~XlibDisplayReply;#endif		    return 1;		}		/* 		 *if we get here, then extra > rep->generic.length--meaning we		 * read a reply that's shorter than we expected.  This is an 		 * error,  but we still need to figure out how to handle it...		 */		(void) _XRead (dpy, (char *) (NEXTPTR(rep,xReply)),			((long) rep->generic.length) << 2);		dpy->flags &= ~XlibDisplayReply;		UnlockNextReplyReader(dpy);		_XIOError (dpy);		return (0);    	    case X_Error:	    	{	        register _XExtension *ext;		register Bool ret = False;		int ret_code;		xError *err = (xError *) rep;		unsigned long serial;		dpy->flags &= ~XlibDisplayReply;		serial = _XSetLastRequestRead(dpy, (xGenericReply *)rep);		if (serial == cur_request)			/* do not die on "no such font", "can't allocate",			   "can't grab" failures */			switch ((int)err->errorCode) {			case BadName:			    switch (err->majorCode) {				case X_LookupColor:				case X_AllocNamedColor:				    UnlockNextReplyReader(dpy);				    return(0);			    }			    break;			case BadFont:			    if (err->majorCode == X_QueryFont) {				UnlockNextReplyReader(dpy);				return (0);			    }			    break;			case BadAlloc:			case BadAccess:			    UnlockNextReplyReader(dpy);			    return (0);			}		/* 		 * we better see if there is an extension who may		 * want to suppress the error.		 */		for (ext = dpy->ext_procs; !ret && ext; ext = ext->next) {		    if (ext->error) 		       ret = (*ext->error)(dpy, err, &ext->codes, &ret_code);		}		if (!ret) {		    _XError(dpy, err);		    ret_code = 0;		}		if (serial == cur_request) {		    UnlockNextReplyReader(dpy);		    return(ret_code);		}		} /* case X_Error */		break;	    default:		_XEnq(dpy, (xEvent *) rep);#ifdef XTHREADS		if (dpy->lock && dpy->lock->event_awaiters)		    ConditionSignal(dpy, dpy->lock->event_awaiters->cv);#endif		break;	    }	}}   