resource.h revision 05b261ec
105b261ecSmrg/*********************************************************** 205b261ecSmrg 305b261ecSmrgCopyright 1987, 1989, 1998 The Open Group 405b261ecSmrg 505b261ecSmrgPermission to use, copy, modify, distribute, and sell this software and its 605b261ecSmrgdocumentation for any purpose is hereby granted without fee, provided that 705b261ecSmrgthe above copyright notice appear in all copies and that both that 805b261ecSmrgcopyright notice and this permission notice appear in supporting 905b261ecSmrgdocumentation. 1005b261ecSmrg 1105b261ecSmrgThe above copyright notice and this permission notice shall be included in 1205b261ecSmrgall copies or substantial portions of the Software. 1305b261ecSmrg 1405b261ecSmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1505b261ecSmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1605b261ecSmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 1705b261ecSmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 1805b261ecSmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 1905b261ecSmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2005b261ecSmrg 2105b261ecSmrgExcept as contained in this notice, the name of The Open Group shall not be 2205b261ecSmrgused in advertising or otherwise to promote the sale, use or other dealings 2305b261ecSmrgin this Software without prior written authorization from The Open Group. 2405b261ecSmrg 2505b261ecSmrg 2605b261ecSmrgCopyright 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts. 2705b261ecSmrg 2805b261ecSmrg All Rights Reserved 2905b261ecSmrg 3005b261ecSmrgPermission to use, copy, modify, and distribute this software and its 3105b261ecSmrgdocumentation for any purpose and without fee is hereby granted, 3205b261ecSmrgprovided that the above copyright notice appear in all copies and that 3305b261ecSmrgboth that copyright notice and this permission notice appear in 3405b261ecSmrgsupporting documentation, and that the name of Digital not be 3505b261ecSmrgused in advertising or publicity pertaining to distribution of the 3605b261ecSmrgsoftware without specific, written prior permission. 3705b261ecSmrg 3805b261ecSmrgDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 3905b261ecSmrgALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 4005b261ecSmrgDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 4105b261ecSmrgANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 4205b261ecSmrgWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 4305b261ecSmrgARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 4405b261ecSmrgSOFTWARE. 4505b261ecSmrg 4605b261ecSmrg******************************************************************/ 4705b261ecSmrg 4805b261ecSmrg#ifndef RESOURCE_H 4905b261ecSmrg#define RESOURCE_H 1 5005b261ecSmrg#include "misc.h" 5105b261ecSmrg 5205b261ecSmrg/***************************************************************** 5305b261ecSmrg * STUFF FOR RESOURCES 5405b261ecSmrg *****************************************************************/ 5505b261ecSmrg 5605b261ecSmrg/* classes for Resource routines */ 5705b261ecSmrg 5805b261ecSmrgtypedef unsigned long RESTYPE; 5905b261ecSmrg 6005b261ecSmrg#define RC_VANILLA ((RESTYPE)0) 6105b261ecSmrg#define RC_CACHED ((RESTYPE)1<<31) 6205b261ecSmrg#define RC_DRAWABLE ((RESTYPE)1<<30) 6305b261ecSmrg/* Use class RC_NEVERRETAIN for resources that should not be retained 6405b261ecSmrg * regardless of the close down mode when the client dies. (A client's 6505b261ecSmrg * event selections on objects that it doesn't own are good candidates.) 6605b261ecSmrg * Extensions can use this too! 6705b261ecSmrg */ 6805b261ecSmrg#define RC_NEVERRETAIN ((RESTYPE)1<<29) 6905b261ecSmrg#define RC_LASTPREDEF RC_NEVERRETAIN 7005b261ecSmrg#define RC_ANY (~(RESTYPE)0) 7105b261ecSmrg 7205b261ecSmrg/* types for Resource routines */ 7305b261ecSmrg 7405b261ecSmrg#define RT_WINDOW ((RESTYPE)1|RC_CACHED|RC_DRAWABLE) 7505b261ecSmrg#define RT_PIXMAP ((RESTYPE)2|RC_CACHED|RC_DRAWABLE) 7605b261ecSmrg#define RT_GC ((RESTYPE)3|RC_CACHED) 7705b261ecSmrg#undef RT_FONT 7805b261ecSmrg#undef RT_CURSOR 7905b261ecSmrg#define RT_FONT ((RESTYPE)4) 8005b261ecSmrg#define RT_CURSOR ((RESTYPE)5) 8105b261ecSmrg#define RT_COLORMAP ((RESTYPE)6) 8205b261ecSmrg#define RT_CMAPENTRY ((RESTYPE)7) 8305b261ecSmrg#define RT_OTHERCLIENT ((RESTYPE)8|RC_NEVERRETAIN) 8405b261ecSmrg#define RT_PASSIVEGRAB ((RESTYPE)9|RC_NEVERRETAIN) 8505b261ecSmrg#define RT_LASTPREDEF ((RESTYPE)9) 8605b261ecSmrg#define RT_NONE ((RESTYPE)0) 8705b261ecSmrg 8805b261ecSmrg/* bits and fields within a resource id */ 8905b261ecSmrg#define RESOURCE_AND_CLIENT_COUNT 29 /* 29 bits for XIDs */ 9005b261ecSmrg#if MAXCLIENTS == 64 9105b261ecSmrg#define RESOURCE_CLIENT_BITS 6 9205b261ecSmrg#endif 9305b261ecSmrg#if MAXCLIENTS == 128 9405b261ecSmrg#define RESOURCE_CLIENT_BITS 7 9505b261ecSmrg#endif 9605b261ecSmrg#if MAXCLIENTS == 256 9705b261ecSmrg#define RESOURCE_CLIENT_BITS 8 9805b261ecSmrg#endif 9905b261ecSmrg#if MAXCLIENTS == 512 10005b261ecSmrg#define RESOURCE_CLIENT_BITS 9 10105b261ecSmrg#endif 10205b261ecSmrg/* client field offset */ 10305b261ecSmrg#define CLIENTOFFSET (RESOURCE_AND_CLIENT_COUNT - RESOURCE_CLIENT_BITS) 10405b261ecSmrg/* resource field */ 10505b261ecSmrg#define RESOURCE_ID_MASK ((1 << CLIENTOFFSET) - 1) 10605b261ecSmrg/* client field */ 10705b261ecSmrg#define RESOURCE_CLIENT_MASK (((1 << RESOURCE_CLIENT_BITS) - 1) << CLIENTOFFSET) 10805b261ecSmrg/* extract the client mask from an XID */ 10905b261ecSmrg#define CLIENT_BITS(id) ((id) & RESOURCE_CLIENT_MASK) 11005b261ecSmrg/* extract the client id from an XID */ 11105b261ecSmrg#define CLIENT_ID(id) ((int)(CLIENT_BITS(id) >> CLIENTOFFSET)) 11205b261ecSmrg#define SERVER_BIT (Mask)0x40000000 /* use illegal bit */ 11305b261ecSmrg 11405b261ecSmrg#ifdef INVALID 11505b261ecSmrg#undef INVALID /* needed on HP/UX */ 11605b261ecSmrg#endif 11705b261ecSmrg 11805b261ecSmrg/* Invalid resource id */ 11905b261ecSmrg#define INVALID (0) 12005b261ecSmrg 12105b261ecSmrg#define BAD_RESOURCE 0xe0000000 12205b261ecSmrg 12305b261ecSmrgtypedef int (*DeleteType)( 12405b261ecSmrg pointer /*value*/, 12505b261ecSmrg XID /*id*/); 12605b261ecSmrg 12705b261ecSmrgtypedef void (*FindResType)( 12805b261ecSmrg pointer /*value*/, 12905b261ecSmrg XID /*id*/, 13005b261ecSmrg pointer /*cdata*/); 13105b261ecSmrg 13205b261ecSmrgtypedef void (*FindAllRes)( 13305b261ecSmrg pointer /*value*/, 13405b261ecSmrg XID /*id*/, 13505b261ecSmrg RESTYPE /*type*/, 13605b261ecSmrg pointer /*cdata*/); 13705b261ecSmrg 13805b261ecSmrgtypedef Bool (*FindComplexResType)( 13905b261ecSmrg pointer /*value*/, 14005b261ecSmrg XID /*id*/, 14105b261ecSmrg pointer /*cdata*/); 14205b261ecSmrg 14305b261ecSmrgextern RESTYPE CreateNewResourceType( 14405b261ecSmrg DeleteType /*deleteFunc*/); 14505b261ecSmrg 14605b261ecSmrgextern RESTYPE CreateNewResourceClass(void); 14705b261ecSmrg 14805b261ecSmrgextern Bool InitClientResources( 14905b261ecSmrg ClientPtr /*client*/); 15005b261ecSmrg 15105b261ecSmrgextern XID FakeClientID( 15205b261ecSmrg int /*client*/); 15305b261ecSmrg 15405b261ecSmrg/* Quartz support on Mac OS X uses the CarbonCore 15505b261ecSmrg framework whose AddResource function conflicts here. */ 15605b261ecSmrg#ifdef __DARWIN__ 15705b261ecSmrg#define AddResource Darwin_X_AddResource 15805b261ecSmrg#endif 15905b261ecSmrgextern Bool AddResource( 16005b261ecSmrg XID /*id*/, 16105b261ecSmrg RESTYPE /*type*/, 16205b261ecSmrg pointer /*value*/); 16305b261ecSmrg 16405b261ecSmrgextern void FreeResource( 16505b261ecSmrg XID /*id*/, 16605b261ecSmrg RESTYPE /*skipDeleteFuncType*/); 16705b261ecSmrg 16805b261ecSmrgextern void FreeResourceByType( 16905b261ecSmrg XID /*id*/, 17005b261ecSmrg RESTYPE /*type*/, 17105b261ecSmrg Bool /*skipFree*/); 17205b261ecSmrg 17305b261ecSmrgextern Bool ChangeResourceValue( 17405b261ecSmrg XID /*id*/, 17505b261ecSmrg RESTYPE /*rtype*/, 17605b261ecSmrg pointer /*value*/); 17705b261ecSmrg 17805b261ecSmrgextern void FindClientResourcesByType( 17905b261ecSmrg ClientPtr /*client*/, 18005b261ecSmrg RESTYPE /*type*/, 18105b261ecSmrg FindResType /*func*/, 18205b261ecSmrg pointer /*cdata*/); 18305b261ecSmrg 18405b261ecSmrgextern void FindAllClientResources( 18505b261ecSmrg ClientPtr /*client*/, 18605b261ecSmrg FindAllRes /*func*/, 18705b261ecSmrg pointer /*cdata*/); 18805b261ecSmrg 18905b261ecSmrgextern void FreeClientNeverRetainResources( 19005b261ecSmrg ClientPtr /*client*/); 19105b261ecSmrg 19205b261ecSmrgextern void FreeClientResources( 19305b261ecSmrg ClientPtr /*client*/); 19405b261ecSmrg 19505b261ecSmrgextern void FreeAllResources(void); 19605b261ecSmrg 19705b261ecSmrgextern Bool LegalNewID( 19805b261ecSmrg XID /*id*/, 19905b261ecSmrg ClientPtr /*client*/); 20005b261ecSmrg 20105b261ecSmrgextern pointer LookupIDByType( 20205b261ecSmrg XID /*id*/, 20305b261ecSmrg RESTYPE /*rtype*/); 20405b261ecSmrg 20505b261ecSmrgextern pointer LookupIDByClass( 20605b261ecSmrg XID /*id*/, 20705b261ecSmrg RESTYPE /*classes*/); 20805b261ecSmrg 20905b261ecSmrgextern pointer LookupClientResourceComplex( 21005b261ecSmrg ClientPtr client, 21105b261ecSmrg RESTYPE type, 21205b261ecSmrg FindComplexResType func, 21305b261ecSmrg pointer cdata); 21405b261ecSmrg 21505b261ecSmrg/* These are the access modes that can be passed in the last parameter 21605b261ecSmrg * to SecurityLookupIDByType/Class. The Security extension doesn't 21705b261ecSmrg * currently make much use of these; they're mainly provided as an 21805b261ecSmrg * example of what you might need for discretionary access control. 21905b261ecSmrg * You can or these values together to indicate multiple modes 22005b261ecSmrg * simultaneously. 22105b261ecSmrg */ 22205b261ecSmrg 22305b261ecSmrg#define DixUnknownAccess 0 /* don't know intentions */ 22405b261ecSmrg#define DixReadAccess (1<<0) /* inspecting the object */ 22505b261ecSmrg#define DixWriteAccess (1<<1) /* changing the object */ 22605b261ecSmrg#define DixReadWriteAccess (DixReadAccess|DixWriteAccess) 22705b261ecSmrg#define DixDestroyAccess (1<<2) /* destroying the object */ 22805b261ecSmrg 22905b261ecSmrgextern pointer SecurityLookupIDByType( 23005b261ecSmrg ClientPtr /*client*/, 23105b261ecSmrg XID /*id*/, 23205b261ecSmrg RESTYPE /*rtype*/, 23305b261ecSmrg Mask /*access_mode*/); 23405b261ecSmrg 23505b261ecSmrgextern pointer SecurityLookupIDByClass( 23605b261ecSmrg ClientPtr /*client*/, 23705b261ecSmrg XID /*id*/, 23805b261ecSmrg RESTYPE /*classes*/, 23905b261ecSmrg Mask /*access_mode*/); 24005b261ecSmrg 24105b261ecSmrg 24205b261ecSmrgextern void GetXIDRange( 24305b261ecSmrg int /*client*/, 24405b261ecSmrg Bool /*server*/, 24505b261ecSmrg XID * /*minp*/, 24605b261ecSmrg XID * /*maxp*/); 24705b261ecSmrg 24805b261ecSmrgextern unsigned int GetXIDList( 24905b261ecSmrg ClientPtr /*client*/, 25005b261ecSmrg unsigned int /*count*/, 25105b261ecSmrg XID * /*pids*/); 25205b261ecSmrg 25305b261ecSmrgextern RESTYPE lastResourceType; 25405b261ecSmrgextern RESTYPE TypeMask; 25505b261ecSmrg 25605b261ecSmrg#ifdef XResExtension 25705b261ecSmrgextern Atom *ResourceNames; 25805b261ecSmrgvoid RegisterResourceName(RESTYPE type, char* name); 25905b261ecSmrg#endif 26005b261ecSmrg 26105b261ecSmrg#endif /* RESOURCE_H */ 26205b261ecSmrg 263