1: #include <X/mit-copyright.h> 2: 3: /* $Header: XFetchName.c,v 10.4 86/02/01 15:33:38 tony Rel $ */ 4: /* Copyright Massachusetts Institute of Technology 1985 */ 5: 6: #include "XlibInternal.h" 7: 8: Status XFetchName (w, name) 9: Window w; 10: char **name; 11: { 12: register Display *dpy; 13: register XReq *req; 14: XRep rep; 15: register int nbytes; 16: 17: GetReq(X_FetchName, w); 18: if (!_XReply(dpy, &rep)) { 19: /* error */ 20: *name = NULL; 21: return(0); 22: } 23: if ((nbytes = rep.param.s[0]) == 0) { 24: /* no name set */ 25: *name = NULL; 26: return(1); 27: } 28: if ((*name = (char *) malloc(nbytes + 1)) == NULL) { 29: errno = ENOMEM; 30: _XIOError(dpy); 31: } 32: _XReadPad (dpy, *name, nbytes); 33: (*name)[nbytes] = '\0'; 34: return (1); 35: }