1/***********************************************************
2Copyright 1988 by Wyse Technology, Inc., San Jose, Ca.,
3
4                        All Rights Reserved
5
6Permission to use, copy, modify, and distribute this software and its
7documentation for any purpose and without fee is hereby granted,
8provided that the above copyright notice appear in all copies and that
9both that copyright notice and this permission notice appear in
10supporting documentation, and that the name Wyse not be
11used in advertising or publicity pertaining to distribution of the
12software without specific, written prior permission.
13
14WYSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
15ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
16DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
17ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
18WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
19ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
20SOFTWARE.
21
22******************************************************************/
23/*
24
25Copyright 1988, 1998  The Open Group
26
27Permission to use, copy, modify, distribute, and sell this software and its
28documentation for any purpose is hereby granted without fee, provided that
29the above copyright notice appear in all copies and that both that
30copyright notice and this permission notice appear in supporting
31documentation.
32
33The above copyright notice and this permission notice shall be included
34in all copies or substantial portions of the Software.
35
36THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
37OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
38MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
39IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
40OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
41ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
42OTHER DEALINGS IN THE SOFTWARE.
43
44Except as contained in this notice, the name of The Open Group shall
45not be used in advertising or otherwise to promote the sale, use or
46other dealings in this Software without prior written authorization
47from The Open Group.
48
49*/
50
51#ifdef HAVE_CONFIG_H
52#include <config.h>
53#endif
54#include <X11/Xlibint.h>
55#include <X11/Xatom.h>
56#include <X11/Xutil.h>
57#include <X11/Xos.h>
58#include <stdio.h>
59
60Status XGetTextProperty (
61    Display *display,
62    Window window,
63    XTextProperty *tp,
64    Atom property)
65{
66    Atom actual_type;
67    int actual_format = 0;
68    unsigned long nitems = 0L, leftover = 0L;
69    unsigned char *prop = NULL;
70
71    if (XGetWindowProperty (display, window, property, 0L, 1000000L, False,
72			    AnyPropertyType, &actual_type, &actual_format,
73			    &nitems, &leftover, &prop) == Success &&
74	actual_type != None) {
75	/* okay, fill it in */
76	tp->value = prop;
77	tp->encoding = actual_type;
78	tp->format = actual_format;
79	tp->nitems = nitems;
80	return True;
81    }
82
83    tp->value = NULL;
84    tp->encoding = None;
85    tp->format = 0;
86    tp->nitems = 0;
87    return False;
88}
89
90Status XGetWMName (
91    Display *dpy,
92    Window w,
93    XTextProperty *tp)
94{
95    return (XGetTextProperty (dpy, w, tp, XA_WM_NAME));
96}
97
98Status XGetWMIconName (
99    Display *dpy,
100    Window w,
101    XTextProperty *tp)
102{
103    return (XGetTextProperty (dpy, w, tp, XA_WM_ICON_NAME));
104}
105
106Status XGetWMClientMachine (
107    Display *dpy,
108    Window w,
109    XTextProperty *tp)
110{
111    return (XGetTextProperty (dpy, w, tp, XA_WM_CLIENT_MACHINE));
112}
113
114