home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-bin / x11r6.1 / include / x11 / xlibint.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-17  |  33.4 KB  |  1,224 lines

  1. /* $XConsortium: Xlibint.h /main/111 1996/02/02 14:10:09 kaleb $ */
  2.  
  3. /*
  4.  
  5. Copyright (c) 1984, 1985, 1987, 1989  X Consortium
  6.  
  7. Permission is hereby granted, free of charge, to any person obtaining
  8. a copy of this software and associated documentation files (the
  9. "Software"), to deal in the Software without restriction, including
  10. without limitation the rights to use, copy, modify, merge, publish,
  11. distribute, sublicense, and/or sell copies of the Software, and to
  12. permit persons to whom the Software is furnished to do so, subject to
  13. the following conditions:
  14.  
  15. The above copyright notice and this permission notice shall be included
  16. in all copies or substantial portions of the Software.
  17.  
  18. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  19. OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  21. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
  22. OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  23. ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  24. OTHER DEALINGS IN THE SOFTWARE.
  25.  
  26. Except as contained in this notice, the name of the X Consortium shall
  27. not be used in advertising or otherwise to promote the sale, use or
  28. other dealings in this Software without prior written authorization
  29. from the X Consortium.
  30.  
  31. */
  32.  
  33. /*
  34.  *    Xlibint.h - Header definition and support file for the internal
  35.  *    support routines used by the C subroutine interface
  36.  *    library (Xlib) to the X Window System.
  37.  *
  38.  *    Warning, there be dragons here....
  39.  */
  40.  
  41. #if !defined(NEED_EVENTS) && !NeedFunctionPrototypes
  42. #define _XEVENT_
  43. #endif
  44.  
  45. #include <X11/Xlib.h>
  46.  
  47. #ifdef WIN32
  48. #define _XFlush _XFlushIt
  49. #endif
  50.  
  51. /*
  52.  * If your BytesReadable correctly detects broken connections, then
  53.  * you should NOT define XCONN_CHECK_FREQ.
  54.  */
  55. #ifndef XCONN_CHECK_FREQ
  56. #define XCONN_CHECK_FREQ 256
  57. #endif
  58.  
  59. struct _XGC
  60. {
  61.     XExtData *ext_data;    /* hook for extension to hang data */
  62.     GContext gid;    /* protocol ID for graphics context */
  63.     Bool rects;        /* boolean: TRUE if clipmask is list of rectangles */
  64.     Bool dashes;    /* boolean: TRUE if dash-list is really a list */
  65.     unsigned long dirty;/* cache dirty bits */
  66.     XGCValues values;    /* shadow structure of values */
  67. };
  68.  
  69. struct _XDisplay
  70. {
  71.     XExtData *ext_data;    /* hook for extension to hang data */
  72.     struct _XFreeFuncs *free_funcs; /* internal free functions */
  73.     int fd;            /* Network socket. */
  74.     int conn_checker;         /* ugly thing used by _XEventsQueued */
  75.     int proto_major_version;/* maj. version of server's X protocol */
  76.     int proto_minor_version;/* minor version of server's X protocol */
  77.     char *vendor;        /* vendor of the server hardware */
  78.         XID resource_base;    /* resource ID base */
  79.     XID resource_mask;    /* resource ID mask bits */
  80.     XID resource_id;    /* allocator current ID */
  81.     int resource_shift;    /* allocator shift to correct bits */
  82.     XID (*resource_alloc)(); /* allocator function */
  83.     int byte_order;        /* screen byte order, LSBFirst, MSBFirst */
  84.     int bitmap_unit;    /* padding and data requirements */
  85.     int bitmap_pad;        /* padding requirements on bitmaps */
  86.     int bitmap_bit_order;    /* LeastSignificant or MostSignificant */
  87.     int nformats;        /* number of pixmap formats in list */
  88.     ScreenFormat *pixmap_format;    /* pixmap format list */
  89.     int vnumber;        /* Xlib's X protocol version number. */
  90.     int release;        /* release of the server */
  91.     struct _XSQEvent *head, *tail;    /* Input event queue. */
  92.     int qlen;        /* Length of input event queue */
  93.     unsigned long last_request_read; /* seq number of last event read */
  94.     unsigned long request;    /* sequence number of last request. */
  95.     char *last_req;        /* beginning of last request, or dummy */
  96.     char *buffer;        /* Output buffer starting address. */
  97.     char *bufptr;        /* Output buffer index pointer. */
  98.     char *bufmax;        /* Output buffer maximum+1 address. */
  99.     unsigned max_request_size; /* maximum number 32 bit words in request*/
  100.     struct _XrmHashBucketRec *db;
  101.     int (*synchandler)();    /* Synchronization handler */
  102.     char *display_name;    /* "host:display" string used on this connect*/
  103.     int default_screen;    /* default screen for operations */
  104.     int nscreens;        /* number of screens on this server*/
  105.     Screen *screens;    /* pointer to list of screens */
  106.     unsigned long motion_buffer;    /* size of motion buffer */
  107.     unsigned long flags;       /* internal connection flags */
  108.     int min_keycode;    /* minimum defined keycode */
  109.     int max_keycode;    /* maximum defined keycode */
  110.     KeySym *keysyms;    /* This server's keysyms */
  111.     XModifierKeymap *modifiermap;    /* This server's modifier keymap */
  112.     int keysyms_per_keycode;/* number of rows */
  113.     char *xdefaults;    /* contents of defaults from server */
  114.     char *scratch_buffer;    /* place to hang scratch buffer */
  115.     unsigned long scratch_length;    /* length of scratch buffer */
  116.     int ext_number;        /* extension number on this display */
  117.     struct _XExten *ext_procs; /* extensions initialized on this display */
  118.     /*
  119.      * the following can be fixed size, as the protocol defines how
  120.      * much address space is available. 
  121.      * While this could be done using the extension vector, there
  122.      * may be MANY events processed, so a search through the extension
  123.      * list to find the right procedure for each event might be
  124.      * expensive if many extensions are being used.
  125.      */
  126.     Bool (*event_vec[128])();  /* vector for wire to event */
  127.     Status (*wire_vec[128])(); /* vector for event to wire */
  128.     KeySym lock_meaning;       /* for XLookupString */
  129.     struct _XLockInfo *lock;   /* multi-thread state, display lock */
  130.     struct _XInternalAsync *async_handlers; /* for internal async */
  131.     unsigned long bigreq_size; /* max size of big requests */
  132.     struct _XLockPtrs *lock_fns; /* pointers to threads functions */
  133.     void (*idlist_alloc)();       /* XID list allocator function */
  134.     /* things above this line should not move, for binary compatibility */
  135.     struct _XKeytrans *key_bindings; /* for XLookupString */
  136.     Font cursor_font;       /* for XCreateFontCursor */
  137.     struct _XDisplayAtoms *atoms; /* for XInternAtom */
  138.     unsigned int mode_switch;  /* keyboard group modifiers */
  139.     unsigned int num_lock;  /* keyboard numlock modifiers */
  140.     struct _XContextDB *context_db; /* context database */
  141.     Bool (**error_vec)();      /* vector for wire to error */
  142.     /*
  143.      * Xcms information
  144.      */
  145.     struct {
  146.        XPointer defaultCCCs;  /* pointer to an array of default XcmsCCC */
  147.        XPointer clientCmaps;  /* pointer to linked list of XcmsCmapRec */
  148.        XPointer perVisualIntensityMaps;
  149.                   /* linked list of XcmsIntensityMap */
  150.     } cms;
  151.     struct _XIMFilter *im_filters;
  152.     struct _XSQEvent *qfree; /* unallocated event queue elements */
  153.     unsigned long next_event_serial_num; /* inserted into next queue elt */
  154.     struct _XExten *flushes; /* Flush hooks */
  155.     struct _XConnectionInfo *im_fd_info; /* _XRegisterInternalConnection */
  156.     int im_fd_length;    /* number of im_fd_info */
  157.     struct _XConnWatchInfo *conn_watchers; /* XAddConnectionWatch */
  158.     int watcher_count;    /* number of conn_watchers */
  159.     XPointer filedes;    /* struct pollfd cache for _XWaitForReadable */
  160.     int (*savedsynchandler)(); /* user synchandler when Xlib usurps */
  161.     XID resource_max;    /* allocator max ID */
  162.     int xcmisc_opcode;    /* major opcode for XC-MISC */
  163.     struct _XkbInfoRec *xkb_info; /* XKB info */
  164.     struct _XtransConnInfo *trans_conn; /* transport connection object */
  165. };
  166.  
  167. #define XAllocIDs(dpy,ids,n) (*(dpy)->idlist_alloc)(dpy,ids,n)
  168.  
  169. /*
  170.  * define the following if you want the Data macro to be a procedure instead
  171.  */
  172. #ifdef CRAY
  173. #define DataRoutineIsProcedure
  174. #endif /* CRAY */
  175.  
  176. #ifndef _XEVENT_
  177. /*
  178.  * _QEvent datatype for use in input queueing.
  179.  */
  180. typedef struct _XSQEvent
  181. {
  182.     struct _XSQEvent *next;
  183.     XEvent event;
  184.     unsigned long qserial_num;    /* so multi-threaded code can find new ones */
  185. } _XQEvent;
  186. #endif
  187.  
  188. #ifdef XTHREADS            /* for xReply */
  189. #define NEED_REPLIES
  190. #endif
  191.  
  192. #if NeedFunctionPrototypes    /* prototypes require event type definitions */
  193. #define NEED_EVENTS
  194. #define NEED_REPLIES
  195. #endif
  196. #include <X11/Xproto.h>
  197. #ifdef __sgi
  198. #define _SGI_MP_SOURCE  /* turn this on to get MP safe errno */
  199. #endif
  200. #include <errno.h>
  201. #define _XBCOPYFUNC _Xbcopy
  202. #include <X11/Xfuncs.h>
  203. #include <X11/Xosdefs.h>
  204.  
  205. /* Utek leaves kernel macros around in include files (bleah) */
  206. #ifdef dirty
  207. #undef dirty
  208. #endif
  209.  
  210. #ifndef X_NOT_STDC_ENV
  211. #include <stdlib.h>
  212. #include <string.h>
  213. #else
  214. char *malloc(), *realloc(), *calloc();
  215. void exit();
  216. #ifdef SYSV
  217. #include <string.h>
  218. #else
  219. #include <strings.h>
  220. #endif
  221. #endif
  222.  
  223. /*
  224.  * The following definitions can be used for locking requests in multi-threaded
  225.  * address spaces.
  226.  */
  227. #ifdef XTHREADS
  228. /* Author: Stephen Gildea, MIT X Consortium
  229.  *
  230.  * declarations for C Threads locking
  231.  */
  232.  
  233. #include <X11/Xfuncproto.h>
  234.  
  235. struct _XLockPtrs {
  236.     /* used by all, including extensions; do not move */
  237.     void (*lock_display)();
  238.     void (*unlock_display)();
  239. };
  240.  
  241. typedef struct _LockInfoRec *LockInfoPtr;
  242.  
  243. #if defined(WIN32) && !defined(_XLIBINT_)
  244. #define _XCreateMutex_fn (*_XCreateMutex_fn_p)
  245. #define _XFreeMutex_fn (*_XFreeMutex_fn_p)
  246. #define _XLockMutex_fn (*_XLockMutex_fn_p)
  247. #define _XUnlockMutex_fn (*_XUnlockMutex_fn_p)
  248. #define _Xglobal_lock (*_Xglobal_lock_p)
  249. #endif
  250.  
  251. /* in XlibInt.c */
  252. extern void (*_XCreateMutex_fn)(
  253. #if NeedFunctionPrototypes
  254.     LockInfoPtr /* lock */
  255. #endif
  256. );
  257. extern void (*_XFreeMutex_fn)(
  258. #if NeedFunctionPrototypes
  259.     LockInfoPtr /* lock */
  260. #endif
  261. );
  262. extern void (*_XLockMutex_fn)(
  263. #if NeedFunctionPrototypes
  264.     LockInfoPtr    /* lock */
  265. #if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
  266.     , char * /* file */
  267.     , int /* line */
  268. #endif
  269. #endif
  270. );
  271. extern void (*_XUnlockMutex_fn)(
  272. #if NeedFunctionPrototypes
  273.     LockInfoPtr    /* lock */
  274. #if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
  275.     , char * /* file */
  276.     , int /* line */
  277. #endif
  278. #endif
  279. );
  280.  
  281. extern LockInfoPtr _Xglobal_lock;
  282.  
  283. #if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
  284. #define LockDisplay(d)         if ((d)->lock_fns) (*(d)->lock_fns->lock_display)((d),__FILE__,__LINE__)
  285. #define UnlockDisplay(d)     if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)((d),__FILE__,__LINE__)
  286. #define _XLockMutex(lock)        if (_XLockMutex_fn) (*_XLockMutex_fn)(lock,__FILE__,__LINE__)
  287. #define _XUnlockMutex(lock)    if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock,__FILE__,__LINE__)
  288. #else
  289. /* used everywhere, so must be fast if not using threads */
  290. #define LockDisplay(d)         if ((d)->lock_fns) (*(d)->lock_fns->lock_display)(d)
  291. #define UnlockDisplay(d)     if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)(d)
  292. #define _XLockMutex(lock)        if (_XLockMutex_fn) (*_XLockMutex_fn)(lock)
  293. #define _XUnlockMutex(lock)    if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock)
  294. #endif
  295. #define _XCreateMutex(lock)    if (_XCreateMutex_fn) (*_XCreateMutex_fn)(lock);
  296. #define _XFreeMutex(lock)    if (_XFreeMutex_fn) (*_XFreeMutex_fn)(lock);
  297.  
  298. #else /* XTHREADS */
  299. #define LockDisplay(dis)
  300. #define _XLockMutex(lock)
  301. #define _XUnlockMutex(lock)
  302. #define UnlockDisplay(dis)
  303. #define _XCreateMutex(lock)
  304. #define _XFreeMutex(lock)
  305. #endif
  306.  
  307. #define Xfree(ptr) free((ptr))
  308.  
  309. /*
  310.  * Note that some machines do not return a valid pointer for malloc(0), in
  311.  * which case we provide an alternate under the control of the
  312.  * define MALLOC_0_RETURNS_NULL.  This is necessary because some
  313.  * Xlib code expects malloc(0) to return a valid pointer to storage.
  314.  */
  315. #ifdef MALLOC_0_RETURNS_NULL
  316.  
  317. # define Xmalloc(size) malloc(((size) == 0 ? 1 : (size)))
  318. # define Xrealloc(ptr, size) realloc((ptr), ((size) == 0 ? 1 : (size)))
  319. # define Xcalloc(nelem, elsize) calloc(((nelem) == 0 ? 1 : (nelem)), (elsize))
  320.  
  321. #else
  322.  
  323. # define Xmalloc(size) malloc((size))
  324. # define Xrealloc(ptr, size) realloc((ptr), (size))
  325. # define Xcalloc(nelem, elsize) calloc((nelem), (elsize))
  326.  
  327. #endif
  328.  
  329. #ifndef NULL
  330. #define NULL 0
  331. #endif
  332. #define LOCKED 1
  333. #define UNLOCKED 0
  334.  
  335. #ifdef X_NOT_STDC_ENV
  336. extern int errno;            /* Internal system error number. */
  337. #endif
  338.  
  339. #ifndef BUFSIZE
  340. #define BUFSIZE 2048            /* X output buffer size. */
  341. #endif
  342. #ifndef PTSPERBATCH
  343. #define PTSPERBATCH 1024        /* point batching */
  344. #endif
  345. #ifndef WLNSPERBATCH
  346. #define WLNSPERBATCH 50            /* wide line batching */
  347. #endif
  348. #ifndef ZLNSPERBATCH
  349. #define ZLNSPERBATCH 1024        /* thin line batching */
  350. #endif
  351. #ifndef WRCTSPERBATCH
  352. #define WRCTSPERBATCH 10        /* wide line rectangle batching */
  353. #endif
  354. #ifndef ZRCTSPERBATCH
  355. #define ZRCTSPERBATCH 256        /* thin line rectangle batching */
  356. #endif
  357. #ifndef FRCTSPERBATCH
  358. #define FRCTSPERBATCH 256        /* filled rectangle batching */
  359. #endif
  360. #ifndef FARCSPERBATCH
  361. #define FARCSPERBATCH 256        /* filled arc batching */
  362. #endif
  363. #ifndef CURSORFONT
  364. #define CURSORFONT "cursor"        /* standard cursor fonts */
  365. #endif
  366.  
  367. /*
  368.  * Display flags
  369.  */
  370. #define XlibDisplayIOError    (1L << 0)
  371. #define XlibDisplayClosing    (1L << 1)
  372. #define XlibDisplayNoXkb    (1L << 2)
  373. #define XlibDisplayPrivSync    (1L << 3)
  374. #define XlibDisplayProcConni    (1L << 4) /* in _XProcessInternalConnection */
  375. #define XlibDisplayReadEvents    (1L << 5) /* in _XReadEvents */
  376. #define XlibDisplayReply    (1L << 5) /* in _XReply */
  377. #define XlibDisplayWriting    (1L << 6) /* in _XFlushInt, _XSend */
  378.  
  379. /*
  380.  * X Protocol packetizing macros.
  381.  */
  382.  
  383. /*   Need to start requests on 64 bit word boundaries
  384.  *   on a CRAY computer so add a NoOp (127) if needed.
  385.  *   A character pointer on a CRAY computer will be non-zero
  386.  *   after shifting right 61 bits of it is not pointing to
  387.  *   a word boundary.
  388.  */
  389. #ifdef WORD64
  390. #define WORD64ALIGN if ((long)dpy->bufptr >> 61) {\
  391.            dpy->last_req = dpy->bufptr;\
  392.            *(dpy->bufptr)   = X_NoOperation;\
  393.            *(dpy->bufptr+1) =  0;\
  394.            *(dpy->bufptr+2) =  0;\
  395.            *(dpy->bufptr+3) =  1;\
  396.              dpy->request++;\
  397.              dpy->bufptr += 4;\
  398.          }
  399. #else /* else does not require alignment on 64-bit boundaries */
  400. #define WORD64ALIGN
  401. #endif /* WORD64 */
  402.  
  403.  
  404. /*
  405.  * GetReq - Get the next available X request packet in the buffer and
  406.  * return it. 
  407.  *
  408.  * "name" is the name of the request, e.g. CreatePixmap, OpenFont, etc.
  409.  * "req" is the name of the request pointer.
  410.  *
  411.  */
  412.  
  413. #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
  414. #define GetReq(name, req) \
  415.         WORD64ALIGN\
  416.     if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\
  417.         _XFlush(dpy);\
  418.     req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
  419.     req->reqType = X_##name;\
  420.     req->length = (SIZEOF(x##name##Req))>>2;\
  421.     dpy->bufptr += SIZEOF(x##name##Req);\
  422.     dpy->request++
  423.  
  424. #else  /* non-ANSI C uses empty comment instead of "##" for token concatenation */
  425. #define GetReq(name, req) \
  426.         WORD64ALIGN\
  427.     if ((dpy->bufptr + SIZEOF(x/**/name/**/Req)) > dpy->bufmax)\
  428.         _XFlush(dpy);\
  429.     req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
  430.     req->reqType = X_/**/name;\
  431.     req->length = (SIZEOF(x/**/name/**/Req))>>2;\
  432.     dpy->bufptr += SIZEOF(x/**/name/**/Req);\
  433.     dpy->request++
  434. #endif
  435.  
  436. /* GetReqExtra is the same as GetReq, but allocates "n" additional
  437.    bytes after the request. "n" must be a multiple of 4!  */
  438.  
  439. #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
  440. #define GetReqExtra(name, n, req) \
  441.         WORD64ALIGN\
  442.     if ((dpy->bufptr + SIZEOF(x##name##Req) + n) > dpy->bufmax)\
  443.         _XFlush(dpy);\
  444.     req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
  445.     req->reqType = X_##name;\
  446.     req->length = (SIZEOF(x##name##Req) + n)>>2;\
  447.     dpy->bufptr += SIZEOF(x##name##Req) + n;\
  448.     dpy->request++
  449. #else
  450. #define GetReqExtra(name, n, req) \
  451.         WORD64ALIGN\
  452.     if ((dpy->bufptr + SIZEOF(x/**/name/**/Req) + n) > dpy->bufmax)\
  453.         _XFlush(dpy);\
  454.     req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
  455.     req->reqType = X_/**/name;\
  456.     req->length = (SIZEOF(x/**/name/**/Req) + n)>>2;\
  457.     dpy->bufptr += SIZEOF(x/**/name/**/Req) + n;\
  458.     dpy->request++
  459. #endif
  460.  
  461.  
  462. /*
  463.  * GetResReq is for those requests that have a resource ID 
  464.  * (Window, Pixmap, GContext, etc.) as their single argument.
  465.  * "rid" is the name of the resource. 
  466.  */
  467.  
  468. #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
  469. #define GetResReq(name, rid, req) \
  470.         WORD64ALIGN\
  471.     if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\
  472.         _XFlush(dpy);\
  473.     req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\
  474.     req->reqType = X_##name;\
  475.     req->length = 2;\
  476.     req->id = (rid);\
  477.     dpy->bufptr += SIZEOF(xResourceReq);\
  478.     dpy->request++
  479. #else
  480. #define GetResReq(name, rid, req) \
  481.         WORD64ALIGN\
  482.     if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\
  483.         _XFlush(dpy);\
  484.     req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\
  485.     req->reqType = X_/**/name;\
  486.     req->length = 2;\
  487.     req->id = (rid);\
  488.     dpy->bufptr += SIZEOF(xResourceReq);\
  489.     dpy->request++
  490. #endif
  491.  
  492. /*
  493.  * GetEmptyReq is for those requests that have no arguments
  494.  * at all. 
  495.  */
  496. #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
  497. #define GetEmptyReq(name, req) \
  498.         WORD64ALIGN\
  499.     if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\
  500.         _XFlush(dpy);\
  501.     req = (xReq *) (dpy->last_req = dpy->bufptr);\
  502.     req->reqType = X_##name;\
  503.     req->length = 1;\
  504.     dpy->bufptr += SIZEOF(xReq);\
  505.     dpy->request++
  506. #else
  507. #define GetEmptyReq(name, req) \
  508.         WORD64ALIGN\
  509.     if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\
  510.         _XFlush(dpy);\
  511.     req = (xReq *) (dpy->last_req = dpy->bufptr);\
  512.     req->reqType = X_/**/name;\
  513.     req->length = 1;\
  514.     dpy->bufptr += SIZEOF(xReq);\
  515.     dpy->request++
  516. #endif
  517.  
  518. #ifdef WORD64
  519. #define MakeBigReq(req,n) \
  520.     { \
  521.     char _BRdat[4]; \
  522.     unsigned long _BRlen = req->length - 1; \
  523.     req->length = 0; \
  524.     memcpy(_BRdat, ((char *)req) + (_BRlen << 2), 4); \
  525.     memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \
  526.     memcpy(((char *)req) + 4, _BRdat, 4); \
  527.     Data32(dpy, (long *)&_BRdat, 4); \
  528.     }
  529. #else
  530. #define MakeBigReq(req,n) \
  531.     { \
  532.     CARD32 _BRdat; \
  533.     CARD32 _BRlen = req->length - 1; \
  534.     req->length = 0; \
  535.     _BRdat = ((CARD32 *)req)[_BRlen]; \
  536.     memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \
  537.     ((CARD32 *)req)[1] = _BRlen + n + 2; \
  538.     Data32(dpy, &_BRdat, 4); \
  539.     }
  540. #endif
  541.  
  542. #define SetReqLen(req,n,badlen) \
  543.     if ((req->length + n) > (unsigned)65535) { \
  544.     if (dpy->bigreq_size) { \
  545.         MakeBigReq(req,n) \
  546.     } else { \
  547.         n = badlen; \
  548.         req->length += n; \
  549.     } \
  550.     } else \
  551.     req->length += n
  552.  
  553. #define SyncHandle() \
  554.     if (dpy->synchandler) (*dpy->synchandler)(dpy)
  555.  
  556. #define FlushGC(dpy, gc) \
  557.     if ((gc)->dirty) _XFlushGCCache((dpy), (gc))
  558. /*
  559.  * Data - Place data in the buffer and pad the end to provide
  560.  * 32 bit word alignment.  Transmit if the buffer fills.
  561.  *
  562.  * "dpy" is a pointer to a Display.
  563.  * "data" is a pinter to a data buffer.
  564.  * "len" is the length of the data buffer.
  565.  */
  566. #ifndef DataRoutineIsProcedure
  567. #define Data(dpy, data, len) \
  568.     if (dpy->bufptr + (len) <= dpy->bufmax) {\
  569.         memcpy(dpy->bufptr, data, (int)len);\
  570.         dpy->bufptr += ((len) + 3) & ~3;\
  571.     } else\
  572.         _XSend(dpy, data, len)
  573. #endif /* DataRoutineIsProcedure */
  574.  
  575.  
  576. /* Allocate bytes from the buffer.  No padding is done, so if
  577.  * the length is not a multiple of 4, the caller must be
  578.  * careful to leave the buffer aligned after sending the
  579.  * current request.
  580.  *
  581.  * "type" is the type of the pointer being assigned to.
  582.  * "ptr" is the pointer being assigned to.
  583.  * "n" is the number of bytes to allocate.
  584.  *
  585.  * Example: 
  586.  *    xTextElt *elt;
  587.  *    BufAlloc (xTextElt *, elt, nbytes)
  588.  */
  589.  
  590. #define BufAlloc(type, ptr, n) \
  591.     if (dpy->bufptr + (n) > dpy->bufmax) \
  592.         _XFlush (dpy); \
  593.     ptr = (type) dpy->bufptr; \
  594.     dpy->bufptr += (n);
  595.  
  596. #ifdef WORD64
  597. #define Data16(dpy, data, len) _XData16(dpy, (short *)data, len)
  598. #define Data32(dpy, data, len) _XData32(dpy, (long *)data, len)
  599. #else
  600. #define Data16(dpy, data, len) Data((dpy), (char *)(data), (len))
  601. #define _XRead16Pad(dpy, data, len) _XReadPad((dpy), (char *)(data), (len))
  602. #define _XRead16(dpy, data, len) _XRead((dpy), (char *)(data), (len))
  603. #ifdef LONG64
  604. #define Data32(dpy, data, len) _XData32(dpy, (long *)data, len)
  605. #else
  606. #define Data32(dpy, data, len) Data((dpy), (char *)(data), (len))
  607. #define _XRead32(dpy, data, len) _XRead((dpy), (char *)(data), (len))
  608. #endif
  609. #endif /* not WORD64 */
  610.  
  611. #define PackData16(dpy,data,len) Data16 (dpy, data, len)
  612. #define PackData32(dpy,data,len) Data32 (dpy, data, len)
  613.  
  614. /* Xlib manual is bogus */
  615. #define PackData(dpy,data,len) PackData16 (dpy, data, len)
  616.  
  617. #define min(a,b) (((a) < (b)) ? (a) : (b))
  618. #define max(a,b) (((a) > (b)) ? (a) : (b))
  619.  
  620. #define CI_NONEXISTCHAR(cs) (((cs)->width == 0) && \
  621.                  (((cs)->rbearing|(cs)->lbearing| \
  622.                    (cs)->ascent|(cs)->descent) == 0))
  623.  
  624. /* 
  625.  * CI_GET_CHAR_INFO_1D - return the charinfo struct for the indicated 8bit
  626.  * character.  If the character is in the column and exists, then return the
  627.  * appropriate metrics (note that fonts with common per-character metrics will
  628.  * return min_bounds).  If none of these hold true, try again with the default
  629.  * char.
  630.  */
  631. #define CI_GET_CHAR_INFO_1D(fs,col,def,cs) \
  632. { \
  633.     cs = def; \
  634.     if (col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \
  635.     if (fs->per_char == NULL) { \
  636.         cs = &fs->min_bounds; \
  637.     } else { \
  638.         cs = &fs->per_char[(col - fs->min_char_or_byte2)]; \
  639.         if (CI_NONEXISTCHAR(cs)) cs = def; \
  640.     } \
  641.     } \
  642. }
  643.  
  644. #define CI_GET_DEFAULT_INFO_1D(fs,cs) \
  645.   CI_GET_CHAR_INFO_1D (fs, fs->default_char, NULL, cs)
  646.  
  647.  
  648.  
  649. /*
  650.  * CI_GET_CHAR_INFO_2D - return the charinfo struct for the indicated row and 
  651.  * column.  This is used for fonts that have more than row zero.
  652.  */
  653. #define CI_GET_CHAR_INFO_2D(fs,row,col,def,cs) \
  654. { \
  655.     cs = def; \
  656.     if (row >= fs->min_byte1 && row <= fs->max_byte1 && \
  657.     col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \
  658.     if (fs->per_char == NULL) { \
  659.         cs = &fs->min_bounds; \
  660.     } else { \
  661.         cs = &fs->per_char[((row - fs->min_byte1) * \
  662.                     (fs->max_char_or_byte2 - \
  663.                  fs->min_char_or_byte2 + 1)) + \
  664.                    (col - fs->min_char_or_byte2)]; \
  665.         if (CI_NONEXISTCHAR(cs)) cs = def; \
  666.         } \
  667.     } \
  668. }
  669.  
  670. #define CI_GET_DEFAULT_INFO_2D(fs,cs) \
  671. { \
  672.     unsigned int r = (fs->default_char >> 8); \
  673.     unsigned int c = (fs->default_char & 0xff); \
  674.     CI_GET_CHAR_INFO_2D (fs, r, c, NULL, cs); \
  675. }
  676.  
  677.  
  678. #ifdef MUSTCOPY
  679.  
  680. /* for when 32-bit alignment is not good enough */
  681. #define OneDataCard32(dpy,dstaddr,srcvar) \
  682.   { dpy->bufptr -= 4; Data32 (dpy, (char *) &(srcvar), 4); }
  683.  
  684. #else
  685.  
  686. /* srcvar must be a variable for large architecture version */
  687. #define OneDataCard32(dpy,dstaddr,srcvar) \
  688.   { *(CARD32 *)(dstaddr) = (srcvar); }
  689.  
  690. #endif /* MUSTCOPY */
  691.  
  692. typedef struct _XInternalAsync {
  693.     struct _XInternalAsync *next;
  694.     /*
  695.      * handler arguments:
  696.      * rep is the generic reply that caused this handler
  697.      * to be invoked.  It must also be passed to _XGetAsyncReply.
  698.      * buf and len are opaque values that must be passed to
  699.      * _XGetAsyncReply or _XGetAsyncData.
  700.      * data is the closure stored in this struct.
  701.      * The handler returns True iff it handled this reply.
  702.      */
  703.     Bool (*handler)(
  704. #if NeedNestedPrototypes
  705.             Display*    /* dpy */,
  706.             xReply*    /* rep */,
  707.             char*    /* buf */,
  708.             int        /* len */,
  709.             XPointer    /* data */
  710. #endif
  711.             );
  712.     XPointer data;
  713. } _XAsyncHandler;
  714.  
  715. typedef struct _XAsyncEState {
  716.     unsigned long min_sequence_number;
  717.     unsigned long max_sequence_number;
  718.     unsigned char error_code;
  719.     unsigned char major_opcode;
  720.     unsigned short minor_opcode;
  721.     unsigned char last_error_received;
  722.     int error_count;
  723. } _XAsyncErrorState;
  724.  
  725. #define DeqAsyncHandler(dpy,handler) { \
  726.     if (dpy->async_handlers == (handler)) \
  727.     dpy->async_handlers = (handler)->next; \
  728.     else \
  729.     _XDeqAsyncHandler(dpy, handler); \
  730.     }
  731.  
  732. /*
  733.  * This structure is private to the library.
  734.  */
  735. typedef struct _XFreeFuncs {
  736.     void (*atoms)();        /* _XFreeAtomTable */
  737.     int (*modifiermap)();    /* XFreeModifierMap */
  738.     void (*key_bindings)();    /* _XFreeKeyBindings */
  739.     void (*context_db)();    /* _XFreeContextDB */
  740.     void (*defaultCCCs)();    /* _XcmsFreeDefaultCCCs */
  741.     void (*clientCmaps)();    /* _XcmsFreeClientCmaps */
  742.     void (*intensityMaps)();    /* _XcmsFreeIntensityMaps */
  743.     void (*im_filters)();    /* _XFreeIMFilters */
  744.     void (*xkb)();        /* _XkbFreeInfo */
  745. } _XFreeFuncRec;
  746.  
  747. /*
  748.  * This structure is private to the library.
  749.  */
  750. typedef struct _XExten {    /* private to extension mechanism */
  751.     struct _XExten *next;    /* next in list */
  752.     XExtCodes codes;    /* public information, all extension told */
  753.     int (*create_GC)();    /* routine to call when GC created */
  754.     int (*copy_GC)();    /* routine to call when GC copied */
  755.     int (*flush_GC)();    /* routine to call when GC flushed */
  756.     int (*free_GC)();    /* routine to call when GC freed */
  757.     int (*create_Font)();    /* routine to call when Font created */
  758.     int (*free_Font)();    /* routine to call when Font freed */
  759.     int (*close_display)();    /* routine to call when connection closed */
  760.     int (*error)();        /* who to call when an error occurs */
  761.         char *(*error_string)();  /* routine to supply error string */
  762.     char *name;        /* name of this extension */
  763.     void (*error_values)(); /* routine to supply error values */
  764.     void (*before_flush)();    /* routine to call when sending data */
  765.     struct _XExten *next_flush; /* next in list of those with flushes */
  766. } _XExtension;
  767.  
  768. /* extension hooks */
  769.  
  770. _XFUNCPROTOBEGIN
  771.  
  772. #ifdef DataRoutineIsProcedure
  773. extern void Data();
  774. #endif
  775. extern int _XError(
  776. #if NeedFunctionPrototypes
  777.     Display*    /* dpy */,
  778.     xError*    /* rep */
  779. #endif
  780. );
  781. extern int _XIOError(
  782. #if NeedFunctionPrototypes
  783.     Display*    /* dpy */
  784. #endif
  785. );
  786. extern int (*_XIOErrorFunction)(
  787. #if NeedNestedPrototypes
  788.     Display*    /* dpy */
  789. #endif
  790. );
  791. extern int (*_XErrorFunction)(
  792. #if NeedNestedPrototypes
  793.     Display*        /* dpy */,
  794.     XErrorEvent*    /* error_event */
  795. #endif
  796. );
  797. extern void _XEatData(
  798. #if NeedFunctionPrototypes
  799.     Display*        /* dpy */,
  800.     unsigned long    /* n */
  801. #endif
  802. );
  803. extern char *_XAllocScratch(
  804. #if NeedFunctionPrototypes
  805.     Display*        /* dpy */,
  806.     unsigned long    /* nbytes */
  807. #endif
  808. );
  809. extern char *_XAllocTemp(
  810. #if NeedFunctionPrototypes
  811.     Display*        /* dpy */,
  812.     unsigned long    /* nbytes */
  813. #endif
  814. );
  815. extern void _XFreeTemp(
  816. #if NeedFunctionPrototypes
  817.     Display*        /* dpy */,
  818.     char*        /* buf */,
  819.     unsigned long    /* nbytes */
  820. #endif
  821. );
  822. extern Visual *_XVIDtoVisual(
  823. #if NeedFunctionPrototypes
  824.     Display*    /* dpy */,
  825.     VisualID    /* id */
  826. #endif
  827. );
  828. extern unsigned long _XSetLastRequestRead(
  829. #if NeedFunctionPrototypes
  830.     Display*        /* dpy */,
  831.     xGenericReply*    /* rep */
  832. #endif
  833. );
  834. extern int _XGetHostname(
  835. #if NeedFunctionPrototypes
  836.     char*    /* buf */,
  837.     int        /* maxlen */
  838. #endif
  839. );
  840. extern Screen *_XScreenOfWindow(
  841. #if NeedFunctionPrototypes
  842.     Display*    /* dpy */,
  843.     Window    /* w */
  844. #endif
  845. );
  846. extern Bool _XAsyncErrorHandler(
  847. #if NeedFunctionPrototypes
  848.     Display*    /* dpy */,
  849.     xReply*    /* rep */,
  850.     char*    /* buf */,
  851.     int        /* len */,
  852.     XPointer    /* data */
  853. #endif
  854. );
  855. extern char *_XGetAsyncReply(
  856. #if NeedFunctionPrototypes
  857.     Display*    /* dpy */,
  858.     char*    /* replbuf */,
  859.     xReply*    /* rep */,
  860.     char*    /* buf */,
  861.     int        /* len */,
  862.     int        /* extra */,
  863.     Bool    /* discard */
  864. #endif
  865. );
  866. extern _XFlush(
  867. #if NeedFunctionPrototypes
  868.     Display*    /* dpy */
  869. #endif
  870. );
  871. extern int _XEventsQueued(
  872. #if NeedFunctionPrototypes
  873.     Display*    /* dpy */,
  874.     int     /* mode */
  875. #endif
  876. );
  877. extern _XReadEvents(
  878. #if NeedFunctionPrototypes
  879.     Display*    /* dpy */
  880. #endif
  881. );
  882. extern _XRead(
  883. #if NeedFunctionPrototypes
  884.     Display*    /* dpy */,
  885.     char*    /* data */,
  886.     long    /* size */
  887. #endif
  888. );
  889. extern _XReadPad(
  890. #if NeedFunctionPrototypes
  891.     Display*    /* dpy */,
  892.     char*    /* data */,
  893.     long    /* size */
  894. #endif
  895. );
  896. extern _XSend(
  897. #if NeedFunctionPrototypes
  898.     Display*        /* dpy */,
  899.     _Xconst char*    /* data */,
  900.     long        /* size */
  901. #endif
  902. );
  903. extern Status _XReply(
  904. #if NeedFunctionPrototypes
  905.     Display*    /* dpy */,
  906.     xReply*    /* rep */,
  907.     int        /* extra */,
  908.     Bool    /* discard */
  909. #endif
  910. );
  911. extern _XEnq(
  912. #if NeedFunctionPrototypes
  913.     Display*    /* dpy */,
  914.     xEvent*    /* event */
  915. #endif
  916. );
  917. extern _XDeq(
  918. #if NeedFunctionPrototypes
  919.     Display*    /* dpy */,
  920.     _XQEvent*    /* prev */,
  921.     _XQEvent*    /* qelt */
  922. #endif
  923. );
  924.  
  925. extern int (*XESetCreateGC(
  926. #if NeedFunctionPrototypes
  927.     Display*        /* display */,
  928.     int            /* extension */,
  929.     int (*) (
  930. #if NeedNestedPrototypes
  931.           Display*            /* display */,
  932.           GC            /* gc */,
  933.           XExtCodes*        /* codes */
  934. #endif
  935.         )        /* proc */
  936. #endif
  937. ))(
  938. #if NeedNestedPrototypes
  939.     Display*, GC, XExtCodes*
  940. #endif
  941. );
  942.  
  943. extern int (*XESetCopyGC(
  944. #if NeedFunctionPrototypes
  945.     Display*        /* display */,
  946.     int            /* extension */,
  947.     int (*) (
  948. #if NeedNestedPrototypes
  949.           Display*            /* display */,
  950.               GC            /* gc */,
  951.               XExtCodes*        /* codes */
  952. #endif
  953.             )        /* proc */          
  954. #endif
  955. ))(
  956. #if NeedNestedPrototypes
  957.     Display*, GC, XExtCodes*
  958. #endif
  959. );
  960.  
  961. extern int (*XESetFlushGC(
  962. #if NeedFunctionPrototypes
  963.     Display*        /* display */,
  964.     int            /* extension */,
  965.     int (*) (
  966. #if NeedNestedPrototypes
  967.           Display*            /* display */,
  968.               GC            /* gc */,
  969.               XExtCodes*        /* codes */
  970. #endif
  971.             )        /* proc */         
  972. #endif
  973. ))(
  974. #if NeedNestedPrototypes
  975.     Display*, GC, XExtCodes*
  976. #endif
  977. );
  978.  
  979. extern int (*XESetFreeGC(
  980. #if NeedFunctionPrototypes
  981.     Display*        /* display */,
  982.     int            /* extension */,
  983.     int (*) (
  984. #if NeedNestedPrototypes
  985.           Display*            /* display */,
  986.               GC            /* gc */,
  987.               XExtCodes*        /* codes */
  988. #endif
  989.             )        /* proc */         
  990. #endif
  991. ))(
  992. #if NeedNestedPrototypes
  993.     Display*, GC, XExtCodes*
  994. #endif
  995. );
  996.  
  997. extern int (*XESetCreateFont(
  998. #if NeedFunctionPrototypes
  999.     Display*        /* display */,
  1000.     int            /* extension */,
  1001.     int (*) (
  1002. #if NeedNestedPrototypes
  1003.           Display*            /* display */,
  1004.               XFontStruct*        /* fs */,
  1005.               XExtCodes*        /* codes */
  1006. #endif
  1007.             )        /* proc */    
  1008. #endif
  1009. ))(
  1010. #if NeedNestedPrototypes
  1011.     Display*, XFontStruct*, XExtCodes*
  1012. #endif
  1013. );
  1014.  
  1015. extern int (*XESetFreeFont(
  1016. #if NeedFunctionPrototypes
  1017.     Display*        /* display */,
  1018.     int            /* extension */,
  1019.     int (*) (
  1020. #if NeedNestedPrototypes
  1021.           Display*            /* display */,
  1022.               XFontStruct*        /* fs */,
  1023.               XExtCodes*        /* codes */
  1024. #endif
  1025.             )        /* proc */    
  1026. #endif
  1027. ))(
  1028. #if NeedNestedPrototypes
  1029.     Display*, XFontStruct*, XExtCodes*
  1030. #endif
  1031. ); 
  1032.  
  1033. extern int (*XESetCloseDisplay(
  1034. #if NeedFunctionPrototypes
  1035.     Display*        /* display */,
  1036.     int            /* extension */,
  1037.     int (*) (
  1038. #if NeedNestedPrototypes
  1039.           Display*            /* display */,
  1040.               XExtCodes*        /* codes */
  1041. #endif
  1042.             )        /* proc */    
  1043. #endif
  1044. ))(
  1045. #if NeedNestedPrototypes
  1046.     Display*, XExtCodes*
  1047. #endif
  1048. );
  1049.  
  1050. extern int (*XESetError(
  1051. #if NeedFunctionPrototypes
  1052.     Display*        /* display */,
  1053.     int            /* extension */,
  1054.     int (*) (
  1055. #if NeedNestedPrototypes
  1056.           Display*            /* display */,
  1057.               xError*            /* err */,
  1058.               XExtCodes*        /* codes */,
  1059.               int*            /* ret_code */
  1060. #endif
  1061.             )        /* proc */    
  1062. #endif
  1063. ))(
  1064. #if NeedNestedPrototypes
  1065.     Display*, xError*, XExtCodes*, int*
  1066. #endif
  1067. );
  1068.  
  1069. extern char* (*XESetErrorString(
  1070. #if NeedFunctionPrototypes
  1071.     Display*        /* display */,
  1072.     int            /* extension */,
  1073.     char* (*) (
  1074. #if NeedNestedPrototypes
  1075.             Display*        /* display */,
  1076.                 int            /* code */,
  1077.                 XExtCodes*        /* codes */,
  1078.                 char*            /* buffer */,
  1079.                 int            /* nbytes */
  1080. #endif
  1081.               )        /* proc */           
  1082. #endif
  1083. ))(
  1084. #if NeedNestedPrototypes
  1085.     Display*, int, XExtCodes*, char*, int
  1086. #endif
  1087. );
  1088.  
  1089. extern void (*XESetPrintErrorValues (
  1090. #if NeedFunctionPrototypes
  1091.     Display*        /* display */,
  1092.     int            /* extension */,
  1093.     void (*)(
  1094. #if NeedNestedPrototypes
  1095.           Display*            /* display */,
  1096.           XErrorEvent*        /* ev */,
  1097.           void*            /* fp */
  1098. #endif
  1099.          )        /* proc */
  1100. #endif
  1101. ))(
  1102. #if NeedNestedPrototypes
  1103.     Display*, XErrorEvent*, void*
  1104. #endif
  1105. );
  1106.  
  1107. extern Bool (*XESetWireToEvent(
  1108. #if NeedFunctionPrototypes
  1109.     Display*        /* display */,
  1110.     int            /* event_number */,
  1111.     Bool (*) (
  1112. #if NeedNestedPrototypes
  1113.            Display*            /* display */,
  1114.                XEvent*            /* re */,
  1115.                xEvent*            /* event */
  1116. #endif
  1117.              )        /* proc */    
  1118. #endif
  1119. ))(
  1120. #if NeedNestedPrototypes
  1121.     Display*, XEvent*, xEvent*
  1122. #endif
  1123. );
  1124.  
  1125. extern Status (*XESetEventToWire(
  1126. #if NeedFunctionPrototypes
  1127.     Display*        /* display */,
  1128.     int            /* event_number */,
  1129.     Status (*) (
  1130. #if NeedNestedPrototypes
  1131.           Display*            /* display */,
  1132.               XEvent*            /* re */,
  1133.               xEvent*            /* event */
  1134. #endif
  1135.             )        /* proc */   
  1136. #endif
  1137. ))(
  1138. #if NeedNestedPrototypes
  1139.     Display*, XEvent*, xEvent*
  1140. #endif
  1141. );
  1142.  
  1143. extern Bool (*XESetWireToError(
  1144. #if NeedFunctionPrototypes
  1145.     Display*        /* display */,
  1146.     int            /* error_number */,
  1147.     Bool (*) (
  1148. #if NeedNestedPrototypes
  1149.            Display*            /* display */,
  1150.            XErrorEvent*        /* he */,
  1151.            xError*            /* we */
  1152. #endif
  1153.             )        /* proc */   
  1154. #endif
  1155. ))(
  1156. #if NeedNestedPrototypes
  1157.     Display*, XErrorEvent*, xError*
  1158. #endif
  1159. );
  1160.  
  1161. extern void (*XESetBeforeFlush(
  1162. #if NeedFunctionPrototypes
  1163.     Display*        /* display */,
  1164.     int            /* error_number */,
  1165.     void (*) (
  1166. #if NeedNestedPrototypes
  1167.            Display*            /* display */,
  1168.            XExtCodes*        /* codes */,
  1169.            char*            /* data */,
  1170.            long            /* len */
  1171. #endif
  1172.             )        /* proc */   
  1173. #endif
  1174. ))(
  1175. #if NeedNestedPrototypes
  1176.     Display*, XExtCodes*, char*, long
  1177. #endif
  1178. );
  1179.  
  1180. /* internal connections for IMs */
  1181.  
  1182. typedef void (*_XInternalConnectionProc)(
  1183. #if NeedFunctionPrototypes
  1184.     Display*            /* dpy */,
  1185.     int                /* fd */,
  1186.     XPointer            /* call_data */
  1187. #endif
  1188. );
  1189.  
  1190.  
  1191. extern Status _XRegisterInternalConnection(
  1192. #if NeedFunctionPrototypes
  1193.     Display*            /* dpy */,
  1194.     int                /* fd */,
  1195.     _XInternalConnectionProc    /* callback */,
  1196.     XPointer            /* call_data */
  1197. #endif
  1198. );
  1199.  
  1200. extern void _XUnregisterInternalConnection(
  1201. #if NeedFunctionPrototypes
  1202.     Display*            /* dpy */,
  1203.     int                /* fd */
  1204. #endif
  1205. );
  1206.  
  1207. /* Display structure has pointers to these */
  1208.  
  1209. struct _XConnectionInfo {    /* info from _XRegisterInternalConnection */
  1210.     int fd;
  1211.     _XInternalConnectionProc read_callback;
  1212.     XPointer call_data;
  1213.     XPointer *watch_data;    /* set/used by XConnectionWatchProc */
  1214.     struct _XConnectionInfo *next;
  1215. };
  1216.  
  1217. struct _XConnWatchInfo {    /* info from XAddConnectionWatch */
  1218.     XConnectionWatchProc fn;
  1219.     XPointer client_data;
  1220.     struct _XConnWatchInfo *next;
  1221. };
  1222.  
  1223. _XFUNCPROTOEND
  1224.