resource.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. /***********************************************************
  2. Copyright 1987, 1989, 1998 The Open Group
  3. Permission to use, copy, modify, distribute, and sell this software and its
  4. documentation for any purpose is hereby granted without fee, provided that
  5. the above copyright notice appear in all copies and that both that
  6. copyright notice and this permission notice appear in supporting
  7. documentation.
  8. The above copyright notice and this permission notice shall be included in
  9. all copies or substantial portions of the Software.
  10. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  11. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  12. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  13. OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  14. AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  15. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  16. Except as contained in this notice, the name of The Open Group shall not be
  17. used in advertising or otherwise to promote the sale, use or other dealings
  18. in this Software without prior written authorization from The Open Group.
  19. Copyright 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
  20. All Rights Reserved
  21. Permission to use, copy, modify, and distribute this software and its
  22. documentation for any purpose and without fee is hereby granted,
  23. provided that the above copyright notice appear in all copies and that
  24. both that copyright notice and this permission notice appear in
  25. supporting documentation, and that the name of Digital not be
  26. used in advertising or publicity pertaining to distribution of the
  27. software without specific, written prior permission.
  28. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  29. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  30. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  31. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  32. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  33. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  34. SOFTWARE.
  35. ******************************************************************/
  36. #ifndef RESOURCE_H
  37. #define RESOURCE_H 1
  38. #include "misc.h"
  39. /*****************************************************************
  40. * STUFF FOR RESOURCES
  41. *****************************************************************/
  42. /* classes for Resource routines */
  43. typedef unsigned long RESTYPE;
  44. #define RC_VANILLA ((RESTYPE)0)
  45. #define RC_CACHED ((RESTYPE)1<<31)
  46. #define RC_DRAWABLE ((RESTYPE)1<<30)
  47. /* Use class RC_NEVERRETAIN for resources that should not be retained
  48. * regardless of the close down mode when the client dies. (A client's
  49. * event selections on objects that it doesn't own are good candidates.)
  50. * Extensions can use this too!
  51. */
  52. #define RC_NEVERRETAIN ((RESTYPE)1<<29)
  53. #define RC_LASTPREDEF RC_NEVERRETAIN
  54. #define RC_ANY (~(RESTYPE)0)
  55. /* types for Resource routines */
  56. #define RT_WINDOW ((RESTYPE)1|RC_CACHED|RC_DRAWABLE)
  57. #define RT_PIXMAP ((RESTYPE)2|RC_CACHED|RC_DRAWABLE)
  58. #define RT_GC ((RESTYPE)3|RC_CACHED)
  59. #undef RT_FONT
  60. #undef RT_CURSOR
  61. #define RT_FONT ((RESTYPE)4)
  62. #define RT_CURSOR ((RESTYPE)5)
  63. #define RT_COLORMAP ((RESTYPE)6)
  64. #define RT_CMAPENTRY ((RESTYPE)7)
  65. #define RT_OTHERCLIENT ((RESTYPE)8|RC_NEVERRETAIN)
  66. #define RT_PASSIVEGRAB ((RESTYPE)9|RC_NEVERRETAIN)
  67. #define RT_LASTPREDEF ((RESTYPE)9)
  68. #define RT_NONE ((RESTYPE)0)
  69. /* bits and fields within a resource id */
  70. #define RESOURCE_AND_CLIENT_COUNT 29 /* 29 bits for XIDs */
  71. #if MAXCLIENTS == 64
  72. #define RESOURCE_CLIENT_BITS 6
  73. #endif
  74. #if MAXCLIENTS == 128
  75. #define RESOURCE_CLIENT_BITS 7
  76. #endif
  77. #if MAXCLIENTS == 256
  78. #define RESOURCE_CLIENT_BITS 8
  79. #endif
  80. #if MAXCLIENTS == 512
  81. #define RESOURCE_CLIENT_BITS 9
  82. #endif
  83. /* client field offset */
  84. #define CLIENTOFFSET (RESOURCE_AND_CLIENT_COUNT - RESOURCE_CLIENT_BITS)
  85. /* resource field */
  86. #define RESOURCE_ID_MASK ((1 << CLIENTOFFSET) - 1)
  87. /* client field */
  88. #define RESOURCE_CLIENT_MASK (((1 << RESOURCE_CLIENT_BITS) - 1) << CLIENTOFFSET)
  89. /* extract the client mask from an XID */
  90. #define CLIENT_BITS(id) ((id) & RESOURCE_CLIENT_MASK)
  91. /* extract the client id from an XID */
  92. #define CLIENT_ID(id) ((int)(CLIENT_BITS(id) >> CLIENTOFFSET))
  93. #define SERVER_BIT (Mask)0x40000000 /* use illegal bit */
  94. #ifdef INVALID
  95. #undef INVALID /* needed on HP/UX */
  96. #endif
  97. /* Invalid resource id */
  98. #define INVALID (0)
  99. #define BAD_RESOURCE 0xe0000000
  100. typedef int (*DeleteType)(
  101. pointer /*value*/,
  102. XID /*id*/);
  103. typedef void (*FindResType)(
  104. pointer /*value*/,
  105. XID /*id*/,
  106. pointer /*cdata*/);
  107. typedef void (*FindAllRes)(
  108. pointer /*value*/,
  109. XID /*id*/,
  110. RESTYPE /*type*/,
  111. pointer /*cdata*/);
  112. typedef Bool (*FindComplexResType)(
  113. pointer /*value*/,
  114. XID /*id*/,
  115. pointer /*cdata*/);
  116. RESTYPE CreateNewResourceType(
  117. DeleteType /*deleteFunc*/);
  118. Bool InitClientResources(
  119. ClientPtr /*client*/);
  120. XID FakeClientID(
  121. int /*client*/);
  122. /* Quartz support on Mac OS X uses the CarbonCore
  123. framework whose AddResource function conflicts here. */
  124. Bool AddResource(
  125. XID /*id*/,
  126. RESTYPE /*type*/,
  127. pointer /*value*/);
  128. void FreeResource(
  129. XID /*id*/,
  130. RESTYPE /*skipDeleteFuncType*/);
  131. void FreeResourceByType(
  132. XID /*id*/,
  133. RESTYPE /*type*/,
  134. Bool /*skipFree*/);
  135. Bool ChangeResourceValue(
  136. XID /*id*/,
  137. RESTYPE /*rtype*/,
  138. pointer /*value*/);
  139. void FindClientResourcesByType(
  140. ClientPtr /*client*/,
  141. RESTYPE /*type*/,
  142. FindResType /*func*/,
  143. pointer /*cdata*/);
  144. void FindAllClientResources(
  145. ClientPtr /*client*/,
  146. FindAllRes /*func*/,
  147. pointer /*cdata*/);
  148. void FreeClientNeverRetainResources(
  149. ClientPtr /*client*/);
  150. void FreeClientResources(
  151. ClientPtr /*client*/);
  152. void FreeAllResources(void);
  153. Bool LegalNewID(
  154. XID /*id*/,
  155. ClientPtr /*client*/);
  156. pointer LookupIDByType(
  157. XID /*id*/,
  158. RESTYPE /*rtype*/);
  159. pointer LookupIDByClass(
  160. XID /*id*/,
  161. RESTYPE /*classes*/);
  162. pointer LookupClientResourceComplex(
  163. ClientPtr client,
  164. RESTYPE type,
  165. FindComplexResType func,
  166. pointer cdata);
  167. /* These are the access modes that can be passed in the last parameter
  168. * to SecurityLookupIDByType/Class. The Security extension doesn't
  169. * currently make much use of these; they're mainly provided as an
  170. * example of what you might need for discretionary access control.
  171. * You can or these values together to indicate multiple modes
  172. * simultaneously.
  173. */
  174. #define SecurityUnknownAccess 0 /* don't know intentions */
  175. #define SecurityReadAccess (1<<0) /* inspecting the object */
  176. #define SecurityWriteAccess (1<<1) /* changing the object */
  177. #define SecurityDestroyAccess (1<<2) /* destroying the object */
  178. pointer SecurityLookupIDByType(
  179. ClientPtr /*client*/,
  180. XID /*id*/,
  181. RESTYPE /*rtype*/,
  182. Mask /*access_mode*/);
  183. pointer SecurityLookupIDByClass(
  184. ClientPtr /*client*/,
  185. XID /*id*/,
  186. RESTYPE /*classes*/,
  187. Mask /*access_mode*/);
  188. void GetXIDRange(
  189. int /*client*/,
  190. Bool /*server*/,
  191. XID * /*minp*/,
  192. XID * /*maxp*/);
  193. unsigned int GetXIDList(
  194. ClientPtr /*client*/,
  195. unsigned int /*count*/,
  196. XID * /*pids*/);
  197. extern RESTYPE lastResourceType;
  198. extern RESTYPE TypeMask;
  199. #ifdef XResExtension
  200. extern Atom *ResourceNames;
  201. void RegisterResourceName(RESTYPE type, char* name);
  202. #endif
  203. #endif /* RESOURCE_H */