11ab64890Smrg/***********************************************************
21ab64890SmrgCopyright 1988 by Wyse Technology, Inc., San Jose, Ca.,
31ab64890Smrg
41ab64890Smrg                        All Rights Reserved
51ab64890Smrg
661b2299dSmrgPermission to use, copy, modify, and distribute this software and its
761b2299dSmrgdocumentation for any purpose and without fee is hereby granted,
81ab64890Smrgprovided that the above copyright notice appear in all copies and that
961b2299dSmrgboth that copyright notice and this permission notice appear in
101ab64890Smrgsupporting documentation, and that the name Wyse not be
111ab64890Smrgused in advertising or publicity pertaining to distribution of the
1261b2299dSmrgsoftware without specific, written prior permission.
131ab64890Smrg
141ab64890SmrgWYSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
151ab64890SmrgALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
161ab64890SmrgDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
171ab64890SmrgANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
181ab64890SmrgWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
191ab64890SmrgARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
201ab64890SmrgSOFTWARE.
211ab64890Smrg
221ab64890Smrg******************************************************************/
231ab64890Smrg/*
241ab64890Smrg
251ab64890SmrgCopyright 1988, 1998  The Open Group
261ab64890Smrg
271ab64890SmrgPermission to use, copy, modify, distribute, and sell this software and its
281ab64890Smrgdocumentation for any purpose is hereby granted without fee, provided that
291ab64890Smrgthe above copyright notice appear in all copies and that both that
301ab64890Smrgcopyright notice and this permission notice appear in supporting
311ab64890Smrgdocumentation.
321ab64890Smrg
331ab64890SmrgThe above copyright notice and this permission notice shall be included
341ab64890Smrgin all copies or substantial portions of the Software.
351ab64890Smrg
361ab64890SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
371ab64890SmrgOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
381ab64890SmrgMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
391ab64890SmrgIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
401ab64890SmrgOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
411ab64890SmrgARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
421ab64890SmrgOTHER DEALINGS IN THE SOFTWARE.
431ab64890Smrg
441ab64890SmrgExcept as contained in this notice, the name of The Open Group shall
451ab64890Smrgnot be used in advertising or otherwise to promote the sale, use or
461ab64890Smrgother dealings in this Software without prior written authorization
471ab64890Smrgfrom The Open Group.
481ab64890Smrg
491ab64890Smrg*/
501ab64890Smrg
511ab64890Smrg#ifdef HAVE_CONFIG_H
521ab64890Smrg#include <config.h>
531ab64890Smrg#endif
541ab64890Smrg#include <X11/Xlibint.h>
551ab64890Smrg#include <X11/Xatom.h>
561ab64890Smrg#include <X11/Xutil.h>
571ab64890Smrg#include <X11/Xos.h>
581ab64890Smrg#include <stdio.h>
591ab64890Smrg
601ab64890SmrgStatus XGetTextProperty (
611ab64890Smrg    Display *display,
621ab64890Smrg    Window window,
631ab64890Smrg    XTextProperty *tp,
641ab64890Smrg    Atom property)
651ab64890Smrg{
661ab64890Smrg    Atom actual_type;
671ab64890Smrg    int actual_format = 0;
681ab64890Smrg    unsigned long nitems = 0L, leftover = 0L;
691ab64890Smrg    unsigned char *prop = NULL;
701ab64890Smrg
711ab64890Smrg    if (XGetWindowProperty (display, window, property, 0L, 1000000L, False,
721ab64890Smrg			    AnyPropertyType, &actual_type, &actual_format,
731ab64890Smrg			    &nitems, &leftover, &prop) == Success &&
741ab64890Smrg	actual_type != None) {
751ab64890Smrg	/* okay, fill it in */
761ab64890Smrg	tp->value = prop;
771ab64890Smrg	tp->encoding = actual_type;
781ab64890Smrg	tp->format = actual_format;
791ab64890Smrg	tp->nitems = nitems;
801ab64890Smrg	return True;
811ab64890Smrg    }
821ab64890Smrg
831ab64890Smrg    tp->value = NULL;
841ab64890Smrg    tp->encoding = None;
851ab64890Smrg    tp->format = 0;
861ab64890Smrg    tp->nitems = 0;
871ab64890Smrg    return False;
881ab64890Smrg}
891ab64890Smrg
901ab64890SmrgStatus XGetWMName (
911ab64890Smrg    Display *dpy,
921ab64890Smrg    Window w,
931ab64890Smrg    XTextProperty *tp)
941ab64890Smrg{
951ab64890Smrg    return (XGetTextProperty (dpy, w, tp, XA_WM_NAME));
961ab64890Smrg}
971ab64890Smrg
981ab64890SmrgStatus XGetWMIconName (
991ab64890Smrg    Display *dpy,
1001ab64890Smrg    Window w,
1011ab64890Smrg    XTextProperty *tp)
1021ab64890Smrg{
1031ab64890Smrg    return (XGetTextProperty (dpy, w, tp, XA_WM_ICON_NAME));
1041ab64890Smrg}
1051ab64890Smrg
1061ab64890SmrgStatus XGetWMClientMachine (
1071ab64890Smrg    Display *dpy,
1081ab64890Smrg    Window w,
1091ab64890Smrg    XTextProperty *tp)
1101ab64890Smrg{
1111ab64890Smrg    return (XGetTextProperty (dpy, w, tp, XA_WM_CLIENT_MACHINE));
1121ab64890Smrg}
1131ab64890Smrg
114