1
/* $Xorg: resource.h,v 1.5 2001/02/09 02:05:15 xorgcvs Exp $ */
2
/***********************************************************
4
Copyright 1987, 1989, 1998 The Open Group
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
12
The above copyright notice and this permission notice shall be included in
13
all copies or substantial portions of the Software.
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.
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.
27
Copyright 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
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.
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
47
******************************************************************/
48
/* $XFree86: xc/programs/Xserver/include/resource.h,v 1.11 2002/03/06 21:14:04 mvojkovi Exp $ */
54
/*****************************************************************
56
*****************************************************************/
58
/* classes for Resource routines */
60
typedef unsigned long RESTYPE;
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!
70
#define RC_NEVERRETAIN ((RESTYPE)1<<29)
71
#define RC_LASTPREDEF RC_NEVERRETAIN
72
#define RC_ANY (~(RESTYPE)0)
74
/* types for Resource routines */
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)
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)
90
/* bits and fields within a resource id */
91
#define RESOURCE_AND_CLIENT_COUNT 29 /* 29 bits for XIDs */
93
#define RESOURCE_CLIENT_BITS 6
96
#define RESOURCE_CLIENT_BITS 7
99
#define RESOURCE_CLIENT_BITS 8
101
#if MAXCLIENTS == 512
102
#define RESOURCE_CLIENT_BITS 9
104
/* client field offset */
105
#define CLIENTOFFSET (RESOURCE_AND_CLIENT_COUNT - RESOURCE_CLIENT_BITS)
107
#define RESOURCE_ID_MASK ((1 << CLIENTOFFSET) - 1)
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 */
117
#undef INVALID /* needed on HP/UX */
120
/* Invalid resource id */
123
#define BAD_RESOURCE 0xe0000000
125
typedef int (*DeleteType)(
126
#if NeedNestedPrototypes
132
typedef void (*FindResType)(
133
#if NeedNestedPrototypes
140
typedef void (*FindAllRes)(
141
#if NeedNestedPrototypes
149
typedef Bool (*FindComplexResType)(
150
#if NeedNestedPrototypes
157
extern RESTYPE CreateNewResourceType(
158
#if NeedFunctionPrototypes
159
DeleteType /*deleteFunc*/
163
extern RESTYPE CreateNewResourceClass(
164
#if NeedFunctionPrototypes
169
extern Bool InitClientResources(
170
#if NeedFunctionPrototypes
175
extern XID FakeClientID(
176
#if NeedFunctionPrototypes
181
/* Quartz support on Mac OS X uses the CarbonCore
182
framework whose AddResource function conflicts here. */
184
#define AddResource Darwin_X_AddResource
186
extern Bool AddResource(
187
#if NeedFunctionPrototypes
194
extern void FreeResource(
195
#if NeedFunctionPrototypes
197
RESTYPE /*skipDeleteFuncType*/
201
extern void FreeResourceByType(
202
#if NeedFunctionPrototypes
209
extern Bool ChangeResourceValue(
210
#if NeedFunctionPrototypes
217
extern void FindClientResourcesByType(
218
#if NeedFunctionPrototypes
219
ClientPtr /*client*/,
221
FindResType /*func*/,
226
extern void FindAllClientResources(
227
#if NeedFunctionPrototypes
228
ClientPtr /*client*/,
234
extern void FreeClientNeverRetainResources(
235
#if NeedFunctionPrototypes
240
extern void FreeClientResources(
241
#if NeedFunctionPrototypes
246
extern void FreeAllResources(
247
#if NeedFunctionPrototypes
252
extern Bool LegalNewID(
253
#if NeedFunctionPrototypes
259
extern pointer LookupIDByType(
260
#if NeedFunctionPrototypes
266
extern pointer LookupIDByClass(
267
#if NeedFunctionPrototypes
273
extern pointer LookupClientResourceComplex(
274
#if NeedFunctionPrototypes
277
FindComplexResType func,
282
/* These are the access modes that can be passed in the last parameter
283
* to SecurityLookupIDByType/Class. The Security extension doesn't
284
* currently make much use of these; they're mainly provided as an
285
* example of what you might need for discretionary access control.
286
* You can or these values together to indicate multiple modes
290
#define SecurityUnknownAccess 0 /* don't know intentions */
291
#define SecurityReadAccess (1<<0) /* inspecting the object */
292
#define SecurityWriteAccess (1<<1) /* changing the object */
293
#define SecurityDestroyAccess (1<<2) /* destroying the object */
297
extern pointer SecurityLookupIDByType(
298
#if NeedFunctionPrototypes
299
ClientPtr /*client*/,
306
extern pointer SecurityLookupIDByClass(
307
#if NeedFunctionPrototypes
308
ClientPtr /*client*/,
315
#else /* not XCSECURITY */
317
#define SecurityLookupIDByType(client, id, rtype, access_mode) \
318
LookupIDByType(id, rtype)
320
#define SecurityLookupIDByClass(client, id, classes, access_mode) \
321
LookupIDByClass(id, classes)
323
#endif /* XCSECURITY */
325
extern void GetXIDRange(
326
#if NeedFunctionPrototypes
334
extern unsigned int GetXIDList(
335
#if NeedFunctionPrototypes
336
ClientPtr /*client*/,
337
unsigned int /*count*/,
342
extern RESTYPE lastResourceType;
343
extern RESTYPE TypeMask;
346
extern Atom *ResourceNames;
347
void RegisterResourceName(RESTYPE type, char* name);
350
#endif /* RESOURCE_H */