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