home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / extensions / server / PEX / include / dipex.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-21  |  5.4 KB  |  202 lines

  1. /* $XConsortium: dipex.h,v 5.5 92/11/24 13:00:28 mor Exp $ */
  2.  
  3. /***********************************************************
  4. Copyright 1989, 1990, 1991 by Sun Microsystems, Inc. and the X Consortium.
  5.  
  6.                         All Rights Reserved
  7.  
  8. Permission to use, copy, modify, and distribute this software and its 
  9. documentation for any purpose and without fee is hereby granted, 
  10. provided that the above copyright notice appear in all copies and that
  11. both that copyright notice and this permission notice appear in 
  12. supporting documentation, and that the names of Sun Microsystems,
  13. the X Consortium, and MIT not be used in advertising or publicity 
  14. pertaining to distribution of the software without specific, written 
  15. prior permission.  
  16.  
  17. SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
  18. INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT 
  19. SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
  20. DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  21. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  22. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  23. SOFTWARE.
  24.  
  25. ******************************************************************/
  26.  
  27.  
  28. /*    Pex server-private include file
  29.  */
  30.  
  31. #ifndef DIPEX_H
  32. #define DIPEX_H 1
  33.  
  34. #ifndef TRUE
  35. #define TRUE 1
  36. #endif
  37.  
  38. #ifndef FALSE
  39. #define FALSE 0
  40. #endif
  41.  
  42. #include "PEX.h"
  43. #include "PEXproto.h"
  44. #include "PEXprotost.h"
  45. #include "pexSwap.h"
  46. #include "gcstruct.h"
  47. #include "dixstruct.h"
  48. #include "ddpex.h"
  49. #include "misc.h"
  50. #include "pixmap.h"
  51.  
  52.  
  53. #define PEXCONTEXTTABLE 1
  54. #define PEXID(client, type)    ((((client)->index)<<CLIENTOFFSET) + \
  55.                             (SERVER_BIT) + (type))
  56.  
  57. #ifndef LOCAL_FLAG
  58. #define LOCAL_FLAG extern
  59. #endif
  60.  
  61. LOCAL_FLAG ErrorCode PexReqCode;
  62. LOCAL_FLAG ErrorCode PexErrorBase;
  63. LOCAL_FLAG ErrorCode PexEventBase;
  64.  
  65. /* resources */
  66. extern Bool AddResource();
  67.  
  68. #define ADDRESOURCE(id,what,stuff) \
  69.     if (!(AddResource((id),(what),(pointer)(stuff)))) { \
  70.     PEX_ERR_EXIT(BadAlloc,0,cntxtPtr); \
  71.     }
  72.  
  73. /* resource class */
  74. LOCAL_FLAG unsigned long PEXClass;
  75.  
  76. /* resource types */
  77. LOCAL_FLAG unsigned long PEXContextType;
  78. LOCAL_FLAG unsigned long PEXLutType;
  79. LOCAL_FLAG unsigned long PEXPipeType;
  80. LOCAL_FLAG unsigned long PEXRendType;
  81. LOCAL_FLAG unsigned long PEXStructType;
  82. LOCAL_FLAG unsigned long PEXNameType;
  83. LOCAL_FLAG unsigned long PEXSearchType;
  84. LOCAL_FLAG unsigned long PEXWksType;
  85. LOCAL_FLAG unsigned long PEXPickType;
  86. LOCAL_FLAG unsigned long PEXFontType;
  87.  
  88. /* additional type so that we get Drawable-destroy notification */
  89. LOCAL_FLAG unsigned long PEXWksDrawableType;
  90.  
  91. /* default font */
  92. LOCAL_FLAG diFontHandle defaultPEXFont;
  93.  
  94.  
  95. typedef ErrorCode (*RequestFunction)();
  96. typedef void (*ReplyFunction)();
  97.  
  98. /* OCFunction is typedef'd in pexSwap.h */
  99.  
  100. /* This structure holds all client dependent information.  */
  101. typedef struct {
  102.     ClientPtr        client;
  103.     pexReq        *current_req;
  104.     RequestFunction *pexRequest;
  105.     ReplyFunction   *pexSwapReply;    /* only non-0 if conversion needed */
  106.     OCFunction        *pexSwapRequestOC;    /* only non-0 if conversion needed */
  107.     OCFunction        *pexSwapReplyOC;    /* only non-0 if conversion needed */
  108.     pexSwap        *swap;
  109. } pexContext;
  110.  
  111.  
  112. #define VALID_OC(n) \
  113.     if ((PEXOCAll >= (n) ) || ((n) > PEXMaxOC)) { \
  114.     err = BadValue; \
  115.     PEX_ERR_EXIT(err, (n), cntxtPtr); }
  116.  
  117.  
  118. #define OC_RANGE(ELTYPE) ((PEXOCAll < (ELTYPE) ) && ( PEXMaxOC >=(ELTYPE)))
  119.  
  120. /* these arrays are in dipexExt.c */
  121.  
  122. #ifndef _DIPEXEXT_
  123. LOCAL_FLAG unsigned long add_pad_of[];
  124.  
  125. LOCAL_FLAG unsigned int ColourSpecSizes[];
  126. #endif
  127.  
  128.  
  129. #define PADDED(PB) (PB + add_pad_of[(PB & 3)]);
  130. #define LWORDS(PB) (((PB) + add_pad_of[((*((int *)&(PB))) & 3)])/4);
  131.  
  132. #define WritePEXReplyToClient(CONTEXT, PEXREQUEST, DATA_SIZE, DATA)  { \
  133.     int num_bytes = (int)(DATA_SIZE); \
  134.     (DATA)->type = X_Reply; \
  135.     (DATA)->sequenceNumber = (CONTEXT)->client->sequence; \
  136.     if ((CONTEXT)->pexSwapReply) \
  137.     (CONTEXT)->pexSwapReply[(CONTEXT)->current_req->opcode]\
  138.         ((CONTEXT), (PEXREQUEST), (DATA)); \
  139.     (void) WriteToClient ((CONTEXT)->client, num_bytes, (char *)(DATA)); }
  140.  
  141.  
  142. #define WritePEXBufferReply(TYPE)  \
  143.     WritePEXReplyToClient(  cntxtPtr, strmPtr, \
  144.                 sizeof(TYPE) + *((int *)&(pPEXBuffer->dataSize)), \
  145.                 reply)
  146.  
  147.  
  148. #define SETUP_INQ(TYPE) \
  149.     pPEXBuffer->pBuf = (unsigned char *)(pPEXBuffer->pHead+sizeof(TYPE)); \
  150.     pPEXBuffer->dataSize = 0
  151.  
  152.  
  153. #define SETUP_VAR_REPLY(TYPE) \
  154.     TYPE *reply = (TYPE *)(pPEXBuffer->pHead); \
  155.     reply->length = LWORDS(pPEXBuffer->dataSize)
  156.  
  157.  
  158.  
  159. /* some dipex types */
  160.  
  161. typedef struct {
  162.     ddWKSResource   dd_data;
  163.     Drawable        did;
  164. } dipexPhigsWks;
  165.  
  166.  
  167. /*
  168.  * NOTE: The following structure has it's fields layed out in an
  169.  *       order dependent way.  It is created in the DI as a dipexFont,
  170.  *       and is sometime referenced in the DD as a ddFontResource.
  171.  */
  172.  
  173. typedef struct {
  174.     ddFontResource  ddFont;
  175.     long        refcnt;
  176. } dipexFont;
  177.  
  178.  
  179. /*
  180.     Some data structures so that we can keep track of Drawables,
  181.     in case they get destroyed (about which destruction we want
  182.     notification).
  183.  */
  184. typedef struct _dipexWksDrawableLink {
  185.     pexPhigsWks                wksid;
  186.     dipexPhigsWks            *wks;
  187.     struct _dipexWksDrawableLink    *next;
  188. } dipexWksDrawableLink;
  189.  
  190. typedef struct {
  191.     Drawable            id;
  192.     DrawablePtr            x_drawable;
  193.     dipexWksDrawableLink    *wks_list;
  194. } dipexWksDrawable;
  195.  
  196.  
  197. #define GetId(PTR) (((PTR)) ? (PTR)->id : 0)
  198.  
  199.  
  200. #undef LOCAL_FLAG
  201. #endif /* SERVER_PEX_H */
  202.