1 /* $XConsortium: resource.h /main/23 1996/10/30 11:18:23 rws $ */
2 /***********************************************************
4 Copyright (c) 1987, 1989 X Consortium
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 Except as contained in this notice, the name of the X Consortium shall not be
24 used in advertising or otherwise to promote the sale, use or other dealings
25 in this Software without prior written authorization from the X Consortium.
28 Copyright 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
32 Permission to use, copy, modify, and distribute this software and its
33 documentation for any purpose and without fee is hereby granted,
34 provided that the above copyright notice appear in all copies and that
35 both that copyright notice and this permission notice appear in
36 supporting documentation, and that the name of Digital not be
37 used in advertising or publicity pertaining to distribution of the
38 software without specific, written prior permission.
40 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
41 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
42 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
43 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
44 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
48 ******************************************************************/
53 /*****************************************************************
55 *****************************************************************/
57 /* classes for Resource routines */
59 typedef unsigned long RESTYPE;
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!
69 #define RC_NEVERRETAIN ((RESTYPE)1<<29)
70 #define RC_LASTPREDEF RC_NEVERRETAIN
71 #define RC_ANY (~(RESTYPE)0)
73 /* types for Resource routines */
75 #define RT_WINDOW ((RESTYPE)1|RC_CACHED|RC_DRAWABLE)
76 #define RT_PIXMAP ((RESTYPE)2|RC_CACHED|RC_DRAWABLE)
77 #define RT_GC ((RESTYPE)3|RC_CACHED)
78 #define RT_FONT ((RESTYPE)4)
79 #define RT_CURSOR ((RESTYPE)5)
80 #define RT_COLORMAP ((RESTYPE)6)
81 #define RT_CMAPENTRY ((RESTYPE)7)
82 #define RT_OTHERCLIENT ((RESTYPE)8|RC_NEVERRETAIN)
83 #define RT_PASSIVEGRAB ((RESTYPE)9|RC_NEVERRETAIN)
84 #define RT_LASTPREDEF ((RESTYPE)9)
85 #define RT_NONE ((RESTYPE)0)
87 /* bits and fields within a resource id */
88 #define CLIENTOFFSET 22 /* client field */
89 #define RESOURCE_ID_MASK 0x3FFFFF /* low 22 bits */
90 #define CLIENT_BITS(id) ((id) & 0x1fc00000) /* hi 7 bits */
91 #define CLIENT_ID(id) ((int)(CLIENT_BITS(id) >> CLIENTOFFSET))
92 #define SERVER_BIT 0x20000000 /* use illegal bit */
95 #undef INVALID /* needed on HP/UX */
98 /* Invalid resource id */
101 #define BAD_RESOURCE 0xe0000000
103 typedef int (*DeleteType)(
104 #if NeedNestedPrototypes
110 typedef void (*FindResType)(
111 #if NeedNestedPrototypes
118 extern RESTYPE CreateNewResourceType(
119 #if NeedFunctionPrototypes
120 DeleteType /*deleteFunc*/
124 extern RESTYPE CreateNewResourceClass(
125 #if NeedFunctionPrototypes
130 extern Bool InitClientResources(
131 #if NeedFunctionPrototypes
136 extern XID FakeClientID(
137 #if NeedFunctionPrototypes
142 extern Bool AddResource(
143 #if NeedFunctionPrototypes
150 extern void FreeResource(
151 #if NeedFunctionPrototypes
153 RESTYPE /*skipDeleteFuncType*/
157 extern void FreeResourceByType(
158 #if NeedFunctionPrototypes
165 extern Bool ChangeResourceValue(
166 #if NeedFunctionPrototypes
173 extern void FindClientResourcesByType(
174 #if NeedFunctionPrototypes
175 ClientPtr /*client*/,
177 FindResType /*func*/,
182 extern void FreeClientNeverRetainResources(
183 #if NeedFunctionPrototypes
188 extern void FreeClientResources(
189 #if NeedFunctionPrototypes
194 extern void FreeAllResources(
195 #if NeedFunctionPrototypes
200 extern Bool LegalNewID(
201 #if NeedFunctionPrototypes
207 extern pointer LookupIDByType(
208 #if NeedFunctionPrototypes
214 extern pointer LookupIDByClass(
215 #if NeedFunctionPrototypes
221 /* These are the access modes that can be passed in the last parameter
222 * to SecurityLookupIDByType/Class. The Security extension doesn't
223 * currently make much use of these; they're mainly provided as an
224 * example of what you might need for discretionary access control.
225 * You can or these values together to indicate multiple modes
229 #define SecurityUnknownAccess 0 /* don't know intentions */
230 #define SecurityReadAccess (1<<0) /* inspecting the object */
231 #define SecurityWriteAccess (1<<1) /* changing the object */
232 #define SecurityDestroyAccess (1<<2) /* destroying the object */
236 extern pointer SecurityLookupIDByType(
237 #if NeedFunctionPrototypes
238 ClientPtr /*client*/,
245 extern pointer SecurityLookupIDByClass(
246 #if NeedFunctionPrototypes
247 ClientPtr /*client*/,
254 #else /* not XCSECURITY */
256 #define SecurityLookupIDByType(client, id, rtype, access_mode) \
257 LookupIDByType(id, rtype)
259 #define SecurityLookupIDByClass(client, id, classes, access_mode) \
260 LookupIDByClass(id, classes)
262 #endif /* XCSECURITY */
264 extern void GetXIDRange(
265 #if NeedFunctionPrototypes
273 extern unsigned int GetXIDList(
274 #if NeedFunctionPrototypes
275 ClientPtr /*client*/,
276 unsigned int /*count*/,
281 #endif /* RESOURCE_H */