a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/***********************************************************
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncCopyright 1987, 1989, 1998 The Open Group
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncPermission to use, copy, modify, distribute, and sell this software and its
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncdocumentation for any purpose is hereby granted without fee, provided that
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncthe above copyright notice appear in all copies and that both that
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsynccopyright notice and this permission notice appear in supporting
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncdocumentation.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncThe above copyright notice and this permission notice shall be included in
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncall copies or substantial portions of the Software.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncExcept as contained in this notice, the name of The Open Group shall not be
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncused in advertising or otherwise to promote the sale, use or other dealings
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncin this Software without prior written authorization from The Open Group.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncCopyright 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync All Rights Reserved
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncPermission to use, copy, modify, and distribute this software and its
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncdocumentation for any purpose and without fee is hereby granted,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncprovided that the above copyright notice appear in all copies and that
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncboth that copyright notice and this permission notice appear in
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncsupporting documentation, and that the name of Digital not be
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncused in advertising or publicity pertaining to distribution of the
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncsoftware without specific, written prior permission.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync******************************************************************/
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/*****************************************************************
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * STUFF FOR RESOURCES
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync *****************************************************************/
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* classes for Resource routines */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* Use class RC_NEVERRETAIN for resources that should not be retained
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * regardless of the close down mode when the client dies. (A client's
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * event selections on objects that it doesn't own are good candidates.)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * Extensions can use this too!
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* types for Resource routines */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* bits and fields within a resource id */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define RESOURCE_AND_CLIENT_COUNT 29 /* 29 bits for XIDs */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* client field offset */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define CLIENTOFFSET (RESOURCE_AND_CLIENT_COUNT - RESOURCE_CLIENT_BITS)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* resource field */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* client field */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define RESOURCE_CLIENT_MASK (((1 << RESOURCE_CLIENT_BITS) - 1) << CLIENTOFFSET)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* extract the client mask from an XID */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define CLIENT_BITS(id) ((id) & RESOURCE_CLIENT_MASK)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* extract the client id from an XID */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define CLIENT_ID(id) ((int)(CLIENT_BITS(id) >> CLIENTOFFSET))
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define SERVER_BIT (Mask)0x40000000 /* use illegal bit */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* Invalid resource id */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* Resource state callback */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncextern _X_EXPORT CallbackListPtr ResourceStateCallback;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsynctypedef struct {
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* Structure for estimating resource memory usage. Memory usage
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * consists of space allocated for the resource itself and of
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * references to other resources. Currently the most important use for
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * this structure is to estimate pixmap usage of different resources
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * more accurately. */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsynctypedef struct {
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync /* Size of resource itself. Zero if not implemented. */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync /* Size attributed to pixmap references from the resource. */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync /* Number of references to this resource; typically 1 */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncextern _X_EXPORT RESTYPE CreateNewResourceType(DeleteType deleteFunc,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync const char *name);
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncextern _X_EXPORT void SetResourceTypeFindSubResFunc(
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync RESTYPE /*type*/, FindTypeSubResources /*findFunc*/);
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncextern _X_EXPORT RESTYPE CreateNewResourceClass(void);
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncextern _X_EXPORT Bool InitClientResources(ClientPtr /*client */ );
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncextern _X_EXPORT XID FakeClientID(int /*client */ );
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* Quartz support on Mac OS X uses the CarbonCore
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync framework whose AddResource function conflicts here. */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncextern _X_EXPORT void FreeResourceByType(XID /*id */ ,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncextern _X_EXPORT void FindClientResourcesByType(ClientPtr client,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncextern _X_EXPORT void FindAllClientResources(ClientPtr client,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/** @brief Iterate through all subresources of a resource.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync @note The XID argument provided to the FindAllRes function
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync may be 0 for subresources that don't have an XID */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncextern _X_EXPORT void FindSubResources(void *resource,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncextern _X_EXPORT void FreeClientNeverRetainResources(ClientPtr /*client */ );
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncextern _X_EXPORT void FreeClientResources(ClientPtr /*client */ );
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncextern _X_EXPORT void *LookupClientResourceComplex(ClientPtr client,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncextern _X_EXPORT int dixLookupResourceByType(void **result,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncextern _X_EXPORT int dixLookupResourceByClass(void **result,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncextern _X_EXPORT unsigned int GetXIDList(ClientPtr /*client */ ,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync unsigned int /*count */ ,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/** @brief A hashing function to be used for hashing resource IDs
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync @param id The resource ID to hash
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync @param numBits The number of bits in the resulting hash. Must be >=0.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync @note This function is really only for handling
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync INITHASHSIZE..MAXHASHSIZE bit hashes, but will handle any number
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync of bits by either masking numBits lower bits of the ID or by
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync providing at most MAXHASHSIZE hashes.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#endif /* RESOURCE_H */