1 | /***********************************************************
|
---|
2 |
|
---|
3 | Copyright 1987, 1989, 1998 The Open Group
|
---|
4 |
|
---|
5 | Permission to use, copy, modify, distribute, and sell this software and its
|
---|
6 | documentation for any purpose is hereby granted without fee, provided that
|
---|
7 | the above copyright notice appear in all copies and that both that
|
---|
8 | copyright notice and this permission notice appear in supporting
|
---|
9 | documentation.
|
---|
10 |
|
---|
11 | The above copyright notice and this permission notice shall be included in
|
---|
12 | all copies or substantial portions of the Software.
|
---|
13 |
|
---|
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
---|
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
---|
17 | OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
---|
18 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
---|
19 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
---|
20 |
|
---|
21 | Except as contained in this notice, the name of The Open Group shall not be
|
---|
22 | used in advertising or otherwise to promote the sale, use or other dealings
|
---|
23 | in this Software without prior written authorization from The Open Group.
|
---|
24 |
|
---|
25 |
|
---|
26 | Copyright 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
|
---|
27 |
|
---|
28 | All Rights Reserved
|
---|
29 |
|
---|
30 | Permission to use, copy, modify, and distribute this software and its
|
---|
31 | documentation for any purpose and without fee is hereby granted,
|
---|
32 | provided that the above copyright notice appear in all copies and that
|
---|
33 | both that copyright notice and this permission notice appear in
|
---|
34 | supporting documentation, and that the name of Digital not be
|
---|
35 | used in advertising or publicity pertaining to distribution of the
|
---|
36 | software without specific, written prior permission.
|
---|
37 |
|
---|
38 | DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
---|
39 | ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
---|
40 | DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
---|
41 | ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
---|
42 | WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
---|
43 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
---|
44 | SOFTWARE.
|
---|
45 |
|
---|
46 | ******************************************************************/
|
---|
47 |
|
---|
48 | #ifndef RESOURCE_H
|
---|
49 | #define RESOURCE_H 1
|
---|
50 | #include "misc.h"
|
---|
51 |
|
---|
52 | /*****************************************************************
|
---|
53 | * STUFF FOR RESOURCES
|
---|
54 | *****************************************************************/
|
---|
55 |
|
---|
56 | /* classes for Resource routines */
|
---|
57 |
|
---|
58 | typedef unsigned long RESTYPE;
|
---|
59 |
|
---|
60 | #define RC_VANILLA ((RESTYPE)0)
|
---|
61 | #define RC_CACHED ((RESTYPE)1<<31)
|
---|
62 | #define RC_DRAWABLE ((RESTYPE)1<<30)
|
---|
63 | /* Use class RC_NEVERRETAIN for resources that should not be retained
|
---|
64 | * regardless of the close down mode when the client dies. (A client's
|
---|
65 | * event selections on objects that it doesn't own are good candidates.)
|
---|
66 | * Extensions can use this too!
|
---|
67 | */
|
---|
68 | #define RC_NEVERRETAIN ((RESTYPE)1<<29)
|
---|
69 | #define RC_LASTPREDEF RC_NEVERRETAIN
|
---|
70 | #define RC_ANY (~(RESTYPE)0)
|
---|
71 |
|
---|
72 | /* types for Resource routines */
|
---|
73 |
|
---|
74 | #define RT_WINDOW ((RESTYPE)1|RC_CACHED|RC_DRAWABLE)
|
---|
75 | #define RT_PIXMAP ((RESTYPE)2|RC_CACHED|RC_DRAWABLE)
|
---|
76 | #define RT_GC ((RESTYPE)3|RC_CACHED)
|
---|
77 | #undef RT_FONT
|
---|
78 | #undef RT_CURSOR
|
---|
79 | #define RT_FONT ((RESTYPE)4)
|
---|
80 | #define RT_CURSOR ((RESTYPE)5)
|
---|
81 | #define RT_COLORMAP ((RESTYPE)6)
|
---|
82 | #define RT_CMAPENTRY ((RESTYPE)7)
|
---|
83 | #define RT_OTHERCLIENT ((RESTYPE)8|RC_NEVERRETAIN)
|
---|
84 | #define RT_PASSIVEGRAB ((RESTYPE)9|RC_NEVERRETAIN)
|
---|
85 | #define RT_LASTPREDEF ((RESTYPE)9)
|
---|
86 | #define RT_NONE ((RESTYPE)0)
|
---|
87 |
|
---|
88 | /* bits and fields within a resource id */
|
---|
89 | #define RESOURCE_AND_CLIENT_COUNT 29 /* 29 bits for XIDs */
|
---|
90 | #if MAXCLIENTS == 64
|
---|
91 | #define RESOURCE_CLIENT_BITS 6
|
---|
92 | #endif
|
---|
93 | #if MAXCLIENTS == 128
|
---|
94 | #define RESOURCE_CLIENT_BITS 7
|
---|
95 | #endif
|
---|
96 | #if MAXCLIENTS == 256
|
---|
97 | #define RESOURCE_CLIENT_BITS 8
|
---|
98 | #endif
|
---|
99 | #if MAXCLIENTS == 512
|
---|
100 | #define RESOURCE_CLIENT_BITS 9
|
---|
101 | #endif
|
---|
102 | /* client field offset */
|
---|
103 | #define CLIENTOFFSET (RESOURCE_AND_CLIENT_COUNT - RESOURCE_CLIENT_BITS)
|
---|
104 | /* resource field */
|
---|
105 | #define RESOURCE_ID_MASK ((1 << CLIENTOFFSET) - 1)
|
---|
106 | /* client field */
|
---|
107 | #define RESOURCE_CLIENT_MASK (((1 << RESOURCE_CLIENT_BITS) - 1) << CLIENTOFFSET)
|
---|
108 | /* extract the client mask from an XID */
|
---|
109 | #define CLIENT_BITS(id) ((id) & RESOURCE_CLIENT_MASK)
|
---|
110 | /* extract the client id from an XID */
|
---|
111 | #define CLIENT_ID(id) ((int)(CLIENT_BITS(id) >> CLIENTOFFSET))
|
---|
112 | #define SERVER_BIT (Mask)0x40000000 /* use illegal bit */
|
---|
113 |
|
---|
114 | #ifdef INVALID
|
---|
115 | #undef INVALID /* needed on HP/UX */
|
---|
116 | #endif
|
---|
117 |
|
---|
118 | /* Invalid resource id */
|
---|
119 | #define INVALID (0)
|
---|
120 |
|
---|
121 | #define BAD_RESOURCE 0xe0000000
|
---|
122 |
|
---|
123 | typedef int (*DeleteType)(
|
---|
124 | pointer /*value*/,
|
---|
125 | XID /*id*/);
|
---|
126 |
|
---|
127 | typedef void (*FindResType)(
|
---|
128 | pointer /*value*/,
|
---|
129 | XID /*id*/,
|
---|
130 | pointer /*cdata*/);
|
---|
131 |
|
---|
132 | typedef void (*FindAllRes)(
|
---|
133 | pointer /*value*/,
|
---|
134 | XID /*id*/,
|
---|
135 | RESTYPE /*type*/,
|
---|
136 | pointer /*cdata*/);
|
---|
137 |
|
---|
138 | typedef Bool (*FindComplexResType)(
|
---|
139 | pointer /*value*/,
|
---|
140 | XID /*id*/,
|
---|
141 | pointer /*cdata*/);
|
---|
142 |
|
---|
143 | extern RESTYPE CreateNewResourceType(
|
---|
144 | DeleteType /*deleteFunc*/);
|
---|
145 |
|
---|
146 | extern RESTYPE CreateNewResourceClass(void);
|
---|
147 |
|
---|
148 | extern Bool InitClientResources(
|
---|
149 | ClientPtr /*client*/);
|
---|
150 |
|
---|
151 | extern XID FakeClientID(
|
---|
152 | int /*client*/);
|
---|
153 |
|
---|
154 | /* Quartz support on Mac OS X uses the CarbonCore
|
---|
155 | framework whose AddResource function conflicts here. */
|
---|
156 | #ifdef __DARWIN__
|
---|
157 | #define AddResource Darwin_X_AddResource
|
---|
158 | #endif
|
---|
159 | extern Bool AddResource(
|
---|
160 | XID /*id*/,
|
---|
161 | RESTYPE /*type*/,
|
---|
162 | pointer /*value*/);
|
---|
163 |
|
---|
164 | extern void FreeResource(
|
---|
165 | XID /*id*/,
|
---|
166 | RESTYPE /*skipDeleteFuncType*/);
|
---|
167 |
|
---|
168 | extern void FreeResourceByType(
|
---|
169 | XID /*id*/,
|
---|
170 | RESTYPE /*type*/,
|
---|
171 | Bool /*skipFree*/);
|
---|
172 |
|
---|
173 | extern Bool ChangeResourceValue(
|
---|
174 | XID /*id*/,
|
---|
175 | RESTYPE /*rtype*/,
|
---|
176 | pointer /*value*/);
|
---|
177 |
|
---|
178 | extern void FindClientResourcesByType(
|
---|
179 | ClientPtr /*client*/,
|
---|
180 | RESTYPE /*type*/,
|
---|
181 | FindResType /*func*/,
|
---|
182 | pointer /*cdata*/);
|
---|
183 |
|
---|
184 | extern void FindAllClientResources(
|
---|
185 | ClientPtr /*client*/,
|
---|
186 | FindAllRes /*func*/,
|
---|
187 | pointer /*cdata*/);
|
---|
188 |
|
---|
189 | extern void FreeClientNeverRetainResources(
|
---|
190 | ClientPtr /*client*/);
|
---|
191 |
|
---|
192 | extern void FreeClientResources(
|
---|
193 | ClientPtr /*client*/);
|
---|
194 |
|
---|
195 | extern void FreeAllResources(void);
|
---|
196 |
|
---|
197 | extern Bool LegalNewID(
|
---|
198 | XID /*id*/,
|
---|
199 | ClientPtr /*client*/);
|
---|
200 |
|
---|
201 | extern pointer LookupIDByType(
|
---|
202 | XID /*id*/,
|
---|
203 | RESTYPE /*rtype*/);
|
---|
204 |
|
---|
205 | extern pointer LookupIDByClass(
|
---|
206 | XID /*id*/,
|
---|
207 | RESTYPE /*classes*/);
|
---|
208 |
|
---|
209 | extern pointer LookupClientResourceComplex(
|
---|
210 | ClientPtr client,
|
---|
211 | RESTYPE type,
|
---|
212 | FindComplexResType func,
|
---|
213 | pointer cdata);
|
---|
214 |
|
---|
215 | /* These are the access modes that can be passed in the last parameter
|
---|
216 | * to SecurityLookupIDByType/Class. The Security extension doesn't
|
---|
217 | * currently make much use of these; they're mainly provided as an
|
---|
218 | * example of what you might need for discretionary access control.
|
---|
219 | * You can or these values together to indicate multiple modes
|
---|
220 | * simultaneously.
|
---|
221 | */
|
---|
222 |
|
---|
223 | #define DixUnknownAccess 0 /* don't know intentions */
|
---|
224 | #define DixReadAccess (1<<0) /* inspecting the object */
|
---|
225 | #define DixWriteAccess (1<<1) /* changing the object */
|
---|
226 | #define DixReadWriteAccess (DixReadAccess|DixWriteAccess)
|
---|
227 | #define DixDestroyAccess (1<<2) /* destroying the object */
|
---|
228 |
|
---|
229 | extern pointer SecurityLookupIDByType(
|
---|
230 | ClientPtr /*client*/,
|
---|
231 | XID /*id*/,
|
---|
232 | RESTYPE /*rtype*/,
|
---|
233 | Mask /*access_mode*/);
|
---|
234 |
|
---|
235 | extern pointer SecurityLookupIDByClass(
|
---|
236 | ClientPtr /*client*/,
|
---|
237 | XID /*id*/,
|
---|
238 | RESTYPE /*classes*/,
|
---|
239 | Mask /*access_mode*/);
|
---|
240 |
|
---|
241 |
|
---|
242 | extern void GetXIDRange(
|
---|
243 | int /*client*/,
|
---|
244 | Bool /*server*/,
|
---|
245 | XID * /*minp*/,
|
---|
246 | XID * /*maxp*/);
|
---|
247 |
|
---|
248 | extern unsigned int GetXIDList(
|
---|
249 | ClientPtr /*client*/,
|
---|
250 | unsigned int /*count*/,
|
---|
251 | XID * /*pids*/);
|
---|
252 |
|
---|
253 | extern RESTYPE lastResourceType;
|
---|
254 | extern RESTYPE TypeMask;
|
---|
255 |
|
---|
256 | #ifdef XResExtension
|
---|
257 | extern Atom *ResourceNames;
|
---|
258 | void RegisterResourceName(RESTYPE type, char* name);
|
---|
259 | #endif
|
---|
260 |
|
---|
261 | #endif /* RESOURCE_H */
|
---|
262 |
|
---|