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 | #include "dixaccess.h"
|
---|
52 |
|
---|
53 | /*****************************************************************
|
---|
54 | * STUFF FOR RESOURCES
|
---|
55 | *****************************************************************/
|
---|
56 |
|
---|
57 | /* classes for Resource routines */
|
---|
58 |
|
---|
59 | typedef unsigned long RESTYPE;
|
---|
60 |
|
---|
61 | #define RC_VANILLA ((RESTYPE)0)
|
---|
62 | #define RC_CACHED ((RESTYPE)1<<31)
|
---|
63 | #define RC_DRAWABLE ((RESTYPE)1<<30)
|
---|
64 | /* Use class RC_NEVERRETAIN for resources that should not be retained
|
---|
65 | * regardless of the close down mode when the client dies. (A client's
|
---|
66 | * event selections on objects that it doesn't own are good candidates.)
|
---|
67 | * Extensions can use this too!
|
---|
68 | */
|
---|
69 | #define RC_NEVERRETAIN ((RESTYPE)1<<29)
|
---|
70 | #define RC_LASTPREDEF RC_NEVERRETAIN
|
---|
71 | #define RC_ANY (~(RESTYPE)0)
|
---|
72 |
|
---|
73 | /* types for Resource routines */
|
---|
74 |
|
---|
75 | #define RT_WINDOW ((RESTYPE)1|RC_DRAWABLE)
|
---|
76 | #define RT_PIXMAP ((RESTYPE)2|RC_DRAWABLE)
|
---|
77 | #define RT_GC ((RESTYPE)3)
|
---|
78 | #undef RT_FONT
|
---|
79 | #undef RT_CURSOR
|
---|
80 | #define RT_FONT ((RESTYPE)4)
|
---|
81 | #define RT_CURSOR ((RESTYPE)5)
|
---|
82 | #define RT_COLORMAP ((RESTYPE)6)
|
---|
83 | #define RT_CMAPENTRY ((RESTYPE)7)
|
---|
84 | #define RT_OTHERCLIENT ((RESTYPE)8|RC_NEVERRETAIN)
|
---|
85 | #define RT_PASSIVEGRAB ((RESTYPE)9|RC_NEVERRETAIN)
|
---|
86 | #define RT_LASTPREDEF ((RESTYPE)9)
|
---|
87 | #define RT_NONE ((RESTYPE)0)
|
---|
88 |
|
---|
89 | /* bits and fields within a resource id */
|
---|
90 | #define RESOURCE_AND_CLIENT_COUNT 29 /* 29 bits for XIDs */
|
---|
91 | #if MAXCLIENTS == 64
|
---|
92 | #define RESOURCE_CLIENT_BITS 6
|
---|
93 | #endif
|
---|
94 | #if MAXCLIENTS == 128
|
---|
95 | #define RESOURCE_CLIENT_BITS 7
|
---|
96 | #endif
|
---|
97 | #if MAXCLIENTS == 256
|
---|
98 | #define RESOURCE_CLIENT_BITS 8
|
---|
99 | #endif
|
---|
100 | #if MAXCLIENTS == 512
|
---|
101 | #define RESOURCE_CLIENT_BITS 9
|
---|
102 | #endif
|
---|
103 | /* client field offset */
|
---|
104 | #define CLIENTOFFSET (RESOURCE_AND_CLIENT_COUNT - RESOURCE_CLIENT_BITS)
|
---|
105 | /* resource field */
|
---|
106 | #define RESOURCE_ID_MASK ((1 << CLIENTOFFSET) - 1)
|
---|
107 | /* client field */
|
---|
108 | #define RESOURCE_CLIENT_MASK (((1 << RESOURCE_CLIENT_BITS) - 1) << CLIENTOFFSET)
|
---|
109 | /* extract the client mask from an XID */
|
---|
110 | #define CLIENT_BITS(id) ((id) & RESOURCE_CLIENT_MASK)
|
---|
111 | /* extract the client id from an XID */
|
---|
112 | #define CLIENT_ID(id) ((int)(CLIENT_BITS(id) >> CLIENTOFFSET))
|
---|
113 | #define SERVER_BIT (Mask)0x40000000 /* use illegal bit */
|
---|
114 |
|
---|
115 | #ifdef INVALID
|
---|
116 | #undef INVALID /* needed on HP/UX */
|
---|
117 | #endif
|
---|
118 |
|
---|
119 | /* Invalid resource id */
|
---|
120 | #define INVALID (0)
|
---|
121 |
|
---|
122 | #define BAD_RESOURCE 0xe0000000
|
---|
123 |
|
---|
124 | /* Resource state callback */
|
---|
125 | extern _X_EXPORT CallbackListPtr ResourceStateCallback;
|
---|
126 |
|
---|
127 | typedef enum {ResourceStateAdding,
|
---|
128 | ResourceStateFreeing} ResourceState;
|
---|
129 |
|
---|
130 | typedef struct {
|
---|
131 | ResourceState state;
|
---|
132 | XID id;
|
---|
133 | RESTYPE type;
|
---|
134 | pointer value;
|
---|
135 | } ResourceStateInfoRec;
|
---|
136 |
|
---|
137 | typedef int (*DeleteType)(
|
---|
138 | pointer /*value*/,
|
---|
139 | XID /*id*/);
|
---|
140 |
|
---|
141 | typedef void (*FindResType)(
|
---|
142 | pointer /*value*/,
|
---|
143 | XID /*id*/,
|
---|
144 | pointer /*cdata*/);
|
---|
145 |
|
---|
146 | typedef void (*FindAllRes)(
|
---|
147 | pointer /*value*/,
|
---|
148 | XID /*id*/,
|
---|
149 | RESTYPE /*type*/,
|
---|
150 | pointer /*cdata*/);
|
---|
151 |
|
---|
152 | typedef Bool (*FindComplexResType)(
|
---|
153 | pointer /*value*/,
|
---|
154 | XID /*id*/,
|
---|
155 | pointer /*cdata*/);
|
---|
156 |
|
---|
157 | extern _X_EXPORT RESTYPE CreateNewResourceType(
|
---|
158 | DeleteType /*deleteFunc*/, char * /*name*/);
|
---|
159 |
|
---|
160 | extern _X_EXPORT void SetResourceTypeErrorValue(
|
---|
161 | RESTYPE /*type*/, int /*errorValue*/);
|
---|
162 |
|
---|
163 | extern _X_EXPORT RESTYPE CreateNewResourceClass(void);
|
---|
164 |
|
---|
165 | extern _X_EXPORT Bool InitClientResources(
|
---|
166 | ClientPtr /*client*/);
|
---|
167 |
|
---|
168 | extern _X_EXPORT XID FakeClientID(
|
---|
169 | int /*client*/);
|
---|
170 |
|
---|
171 | /* Quartz support on Mac OS X uses the CarbonCore
|
---|
172 | framework whose AddResource function conflicts here. */
|
---|
173 | #ifdef __APPLE__
|
---|
174 | #define AddResource Darwin_X_AddResource
|
---|
175 | #endif
|
---|
176 | extern _X_EXPORT Bool AddResource(
|
---|
177 | XID /*id*/,
|
---|
178 | RESTYPE /*type*/,
|
---|
179 | pointer /*value*/);
|
---|
180 |
|
---|
181 | extern _X_EXPORT void FreeResource(
|
---|
182 | XID /*id*/,
|
---|
183 | RESTYPE /*skipDeleteFuncType*/);
|
---|
184 |
|
---|
185 | extern _X_EXPORT void FreeResourceByType(
|
---|
186 | XID /*id*/,
|
---|
187 | RESTYPE /*type*/,
|
---|
188 | Bool /*skipFree*/);
|
---|
189 |
|
---|
190 | extern _X_EXPORT Bool ChangeResourceValue(
|
---|
191 | XID /*id*/,
|
---|
192 | RESTYPE /*rtype*/,
|
---|
193 | pointer /*value*/);
|
---|
194 |
|
---|
195 | extern _X_EXPORT void FindClientResourcesByType(
|
---|
196 | ClientPtr /*client*/,
|
---|
197 | RESTYPE /*type*/,
|
---|
198 | FindResType /*func*/,
|
---|
199 | pointer /*cdata*/);
|
---|
200 |
|
---|
201 | extern _X_EXPORT void FindAllClientResources(
|
---|
202 | ClientPtr /*client*/,
|
---|
203 | FindAllRes /*func*/,
|
---|
204 | pointer /*cdata*/);
|
---|
205 |
|
---|
206 | extern _X_EXPORT void FreeClientNeverRetainResources(
|
---|
207 | ClientPtr /*client*/);
|
---|
208 |
|
---|
209 | extern _X_EXPORT void FreeClientResources(
|
---|
210 | ClientPtr /*client*/);
|
---|
211 |
|
---|
212 | extern _X_EXPORT void FreeAllResources(void);
|
---|
213 |
|
---|
214 | extern _X_EXPORT Bool LegalNewID(
|
---|
215 | XID /*id*/,
|
---|
216 | ClientPtr /*client*/);
|
---|
217 |
|
---|
218 | extern _X_EXPORT pointer LookupClientResourceComplex(
|
---|
219 | ClientPtr client,
|
---|
220 | RESTYPE type,
|
---|
221 | FindComplexResType func,
|
---|
222 | pointer cdata);
|
---|
223 |
|
---|
224 | extern _X_EXPORT int dixLookupResourceByType(
|
---|
225 | pointer *result,
|
---|
226 | XID id,
|
---|
227 | RESTYPE rtype,
|
---|
228 | ClientPtr client,
|
---|
229 | Mask access_mode);
|
---|
230 |
|
---|
231 | extern _X_EXPORT int dixLookupResourceByClass(
|
---|
232 | pointer *result,
|
---|
233 | XID id,
|
---|
234 | RESTYPE rclass,
|
---|
235 | ClientPtr client,
|
---|
236 | Mask access_mode);
|
---|
237 |
|
---|
238 | extern _X_EXPORT void GetXIDRange(
|
---|
239 | int /*client*/,
|
---|
240 | Bool /*server*/,
|
---|
241 | XID * /*minp*/,
|
---|
242 | XID * /*maxp*/);
|
---|
243 |
|
---|
244 | extern _X_EXPORT unsigned int GetXIDList(
|
---|
245 | ClientPtr /*client*/,
|
---|
246 | unsigned int /*count*/,
|
---|
247 | XID * /*pids*/);
|
---|
248 |
|
---|
249 | extern _X_EXPORT RESTYPE lastResourceType;
|
---|
250 | extern _X_EXPORT RESTYPE TypeMask;
|
---|
251 |
|
---|
252 | /*
|
---|
253 | * These are deprecated compatibility functions and will be removed soon!
|
---|
254 | * Please use the noted replacements instead.
|
---|
255 | */
|
---|
256 |
|
---|
257 | /* replaced by dixLookupResourceByType */
|
---|
258 | extern _X_EXPORT pointer SecurityLookupIDByType(
|
---|
259 | ClientPtr client,
|
---|
260 | XID id,
|
---|
261 | RESTYPE rtype,
|
---|
262 | Mask access_mode) _X_DEPRECATED;
|
---|
263 |
|
---|
264 | /* replaced by dixLookupResourceByClass */
|
---|
265 | extern _X_EXPORT pointer SecurityLookupIDByClass(
|
---|
266 | ClientPtr client,
|
---|
267 | XID id,
|
---|
268 | RESTYPE classes,
|
---|
269 | Mask access_mode) _X_DEPRECATED;
|
---|
270 |
|
---|
271 | /* replaced by dixLookupResourceByType */
|
---|
272 | extern _X_EXPORT pointer LookupIDByType(
|
---|
273 | XID id,
|
---|
274 | RESTYPE rtype) _X_DEPRECATED;
|
---|
275 |
|
---|
276 | /* replaced by dixLookupResourceByClass */
|
---|
277 | extern _X_EXPORT pointer LookupIDByClass(
|
---|
278 | XID id,
|
---|
279 | RESTYPE classes) _X_DEPRECATED;
|
---|
280 |
|
---|
281 | #endif /* RESOURCE_H */
|
---|
282 |
|
---|