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