1: #include <X/mit-copyright.h> 2: 3: /* $Header: XFetchBytes.c,v 10.4 86/02/01 15:33:33 tony Rel $ */ 4: /* Copyright Massachusetts Institute of Technology 1985 */ 5: 6: #include "XlibInternal.h" 7: 8: caddr_t XFetchBytes (nbytes) 9: register int *nbytes; 10: { 11: register Display *dpy; 12: register XReq *req; 13: XRep rep; 14: char *data; 15: 16: GetReq(X_FetchBytes, 0); 17: req->func = 0; /* cut buffer 0 */ 18: if (!_XReply(dpy, &rep)) 19: return(NULL); 20: if ((*nbytes = rep.param.s[0]) == 0) 21: return (NULL); /* empty cut buffer */ 22: if ((data = (char *) malloc(*nbytes)) == NULL) { 23: errno = ENOMEM; 24: _XIOError(dpy); 25: } 26: _XReadPad (dpy, data, *nbytes); 27: return(data); 28: }