|
|
1.1 ! root 1: #include "copyright.h" ! 2: ! 3: /* $Header: XFetchName.c,v 11.18 87/09/01 14:47:27 toddb Exp $ */ ! 4: /* Copyright Massachusetts Institute of Technology 1986 */ ! 5: ! 6: #include <stdio.h> ! 7: #include "Xlibint.h" ! 8: #include "Xatom.h" ! 9: #include <strings.h> ! 10: ! 11: ! 12: Status XFetchName (dpy, w, name) ! 13: register Display *dpy; ! 14: Window w; ! 15: char **name; ! 16: { ! 17: Atom actual_type; ! 18: int actual_format; ! 19: unsigned long nitems; ! 20: long leftover; ! 21: unsigned char *data = NULL; ! 22: if (XGetWindowProperty(dpy, w, XA_WM_NAME, 0L, (long)BUFSIZ, False, XA_STRING, ! 23: &actual_type, ! 24: &actual_format, &nitems, &leftover, &data) != Success) { ! 25: *name = NULL; ! 26: return (0); ! 27: } ! 28: if ( (actual_type == XA_STRING) && (actual_format == 8) ) { ! 29: ! 30: /* The data returned by XGetWindowProperty is guarranteed to ! 31: contain one extra byte that is null terminated to make retrieveing ! 32: string properties easy. */ ! 33: ! 34: *name = (char *)data; ! 35: return(1); ! 36: } ! 37: if (data) Xfree ((char *)data); ! 38: *name = NULL; ! 39: return(0); ! 40: } ! 41: ! 42: Status XGetIconName (dpy, w, icon_name) ! 43: register Display *dpy; ! 44: Window w; ! 45: char **icon_name; ! 46: { ! 47: Atom actual_type; ! 48: int actual_format; ! 49: unsigned long nitems; ! 50: long leftover; ! 51: unsigned char *data = NULL; ! 52: if (XGetWindowProperty(dpy, w, XA_WM_ICON_NAME, 0L, (long)BUFSIZ, False, ! 53: XA_STRING, ! 54: &actual_type, ! 55: &actual_format, &nitems, &leftover, &data) != Success) { ! 56: *icon_name = NULL; ! 57: return (0); ! 58: } ! 59: if ( (actual_type == XA_STRING) && (actual_format == 8) ) { ! 60: ! 61: /* The data returned by XGetWindowProperty is guarranteed to ! 62: contain one extra byte that is null terminated to make retrieveing ! 63: string properties easy. */ ! 64: ! 65: *icon_name = (char*)data; ! 66: return(1); ! 67: } ! 68: if (data) Xfree ((char *)data); ! 69: *icon_name = NULL; ! 70: return(0); ! 71: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.