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