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)(
129
typedef void (*FindResType)(
134
typedef void (*FindAllRes)(
140
typedef Bool (*FindComplexResType)(
145
extern RESTYPE CreateNewResourceType(
146
DeleteType /*deleteFunc*/);
148
extern RESTYPE CreateNewResourceClass(void);
150
extern Bool InitClientResources(
151
ClientPtr /*client*/);
153
extern XID FakeClientID(
156
/* Quartz support on Mac OS X uses the CarbonCore
157
framework whose AddResource function conflicts here. */
159
#define AddResource Darwin_X_AddResource
161
extern Bool AddResource(
166
extern void FreeResource(
168
RESTYPE /*skipDeleteFuncType*/);
170
extern void FreeResourceByType(
175
extern Bool ChangeResourceValue(
180
extern void FindClientResourcesByType(
181
ClientPtr /*client*/,
183
FindResType /*func*/,
186
extern void FindAllClientResources(
187
ClientPtr /*client*/,
191
extern void FreeClientNeverRetainResources(
192
ClientPtr /*client*/);
194
extern void FreeClientResources(
195
ClientPtr /*client*/);
197
extern void FreeAllResources(void);
199
extern Bool LegalNewID(
201
ClientPtr /*client*/);
203
extern pointer LookupIDByType(
207
extern pointer LookupIDByClass(
209
RESTYPE /*classes*/);
211
extern pointer LookupClientResourceComplex(
214
FindComplexResType func,
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
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 */
232
extern pointer SecurityLookupIDByType(
233
ClientPtr /*client*/,
236
Mask /*access_mode*/);
238
extern pointer SecurityLookupIDByClass(
239
ClientPtr /*client*/,
242
Mask /*access_mode*/);
244
#else /* not XCSECURITY */
246
#define SecurityLookupIDByType(client, id, rtype, access_mode) \
247
LookupIDByType(id, rtype)
249
#define SecurityLookupIDByClass(client, id, classes, access_mode) \
250
LookupIDByClass(id, classes)
252
#endif /* XCSECURITY */
254
extern void GetXIDRange(
260
extern unsigned int GetXIDList(
261
ClientPtr /*client*/,
262
unsigned int /*count*/,
265
extern RESTYPE lastResourceType;
266
extern RESTYPE TypeMask;
269
extern Atom *ResourceNames;
270
void RegisterResourceName(RESTYPE type, char* name);
273
#endif /* RESOURCE_H */