Xlibint.h revision 9c019ec5
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	/* avoid recursion on requests sequence number synchronization */
207	Bool req_seq_syncing; /* requests syncing is in-progress */
208};
209
210#define XAllocIDs(dpy,ids,n) (*(dpy)->idlist_alloc)(dpy,ids,n)
211
212/*
213 * access "last_request_read" and "request" with 64bit
214 * warning: the value argument of the SET-macros must not
215 * have any side-effects because it may get called twice.
216 */
217#ifndef LONG64
218/* accessors for 32-bit unsigned long */
219
220#define X_DPY_GET_REQUEST(dpy) \
221    ( \
222        ((uint64_t)(((struct _XDisplay*)dpy)->request)) \
223	+ (((uint64_t)(((struct _XDisplay*)dpy)->request_upper32bit)) << 32) \
224    )
225
226#define X_DPY_SET_REQUEST(dpy, value) \
227    ( \
228        (((struct _XDisplay*)dpy)->request = \
229            (value) & 0xFFFFFFFFUL), \
230        (((struct _XDisplay*)dpy)->request_upper32bit = \
231            ((uint64_t)(value)) >> 32), \
232	(void)0 /* don't use the result */ \
233    )
234
235#define X_DPY_GET_LAST_REQUEST_READ(dpy) \
236    ( \
237        ((uint64_t)(((struct _XDisplay*)dpy)->last_request_read)) \
238        + ( \
239            ((uint64_t)( \
240                ((struct _XDisplay*)dpy)->last_request_read_upper32bit \
241            )) << 32 \
242        ) \
243    )
244
245#define X_DPY_SET_LAST_REQUEST_READ(dpy, value) \
246    ( \
247        (((struct _XDisplay*)dpy)->last_request_read = \
248            (value) & 0xFFFFFFFFUL), \
249        (((struct _XDisplay*)dpy)->last_request_read_upper32bit = \
250            ((uint64_t)(value)) >> 32), \
251	(void)0 /* don't use the result */ \
252    )
253
254/*
255 * widen a 32-bit sequence number to a 64 sequence number.
256 * This macro makes the following assumptions:
257 * - ulseq refers to a sequence that has already been sent
258 * - ulseq means the most recent possible sequence number
259 *   with these lower 32 bits.
260 *
261 * The following optimization is used:
262 * The comparison result is taken a 0 or 1 to avoid a branch.
263 */
264#define X_DPY_WIDEN_UNSIGNED_LONG_SEQ(dpy, ulseq) \
265    ( \
266        ((uint64_t)ulseq) \
267        + \
268        (( \
269            ((uint64_t)(((struct _XDisplay*)dpy)->request_upper32bit)) \
270            - (uint64_t)( \
271                (ulseq) > (((struct _XDisplay*)dpy)->request) \
272	    ) \
273        ) << 32) \
274    )
275
276#define X_DPY_REQUEST_INCREMENT(dpy) \
277    ( \
278        ((struct _XDisplay*)dpy)->request++, \
279        ( \
280            (((struct _XDisplay*)dpy)->request == 0) ? ( \
281                ((struct _XDisplay*)dpy)->request_upper32bit++ \
282	    ) : 0 \
283        ), \
284	(void)0 /* don't use the result */ \
285    )
286
287
288#define X_DPY_REQUEST_DECREMENT(dpy) \
289    ( \
290	( \
291            (((struct _XDisplay*)dpy)->request == 0) ? (\
292                ((struct _XDisplay*)dpy)->request--, /* wrap */ \
293                ((struct _XDisplay*)dpy)->request_upper32bit-- \
294            ) : ( \
295                ((struct _XDisplay*)dpy)->request-- \
296            ) \
297	), \
298	(void)0 /* don't use the result */ \
299    )
300
301#else
302/* accessors for 64-bit unsigned long */
303#define X_DPY_GET_REQUEST(dpy) \
304    (((struct _XDisplay*)dpy)->request)
305#define X_DPY_SET_REQUEST(dpy, value) \
306    ((struct _XDisplay*)dpy)->request = (value)
307
308#define X_DPY_GET_LAST_REQUEST_READ(dpy) \
309    (((struct _XDisplay*)dpy)->last_request_read)
310#define X_DPY_SET_LAST_REQUEST_READ(dpy, value) \
311    ((struct _XDisplay*)dpy)->last_request_read = (value)
312
313#define X_DPY_WIDEN_UNSIGNED_LONG_SEQ(dpy, ulseq) ulseq
314
315#define X_DPY_REQUEST_INCREMENT(dpy) ((struct _XDisplay*)dpy)->request++
316#define X_DPY_REQUEST_DECREMENT(dpy) ((struct _XDisplay*)dpy)->request--
317#endif
318
319
320#ifndef _XEVENT_
321/*
322 * _QEvent datatype for use in input queueing.
323 */
324typedef struct _XSQEvent
325{
326    struct _XSQEvent *next;
327    XEvent event;
328    unsigned long qserial_num;	/* so multi-threaded code can find new ones */
329} _XQEvent;
330#endif
331
332#include <X11/Xproto.h>
333#ifdef __sgi
334#define _SGI_MP_SOURCE  /* turn this on to get MP safe errno */
335#endif
336#include <errno.h>
337#define _XBCOPYFUNC _Xbcopy
338#include <X11/Xfuncs.h>
339#include <X11/Xosdefs.h>
340
341/* Utek leaves kernel macros around in include files (bleah) */
342#ifdef dirty
343#undef dirty
344#endif
345
346#include <stdlib.h>
347#include <string.h>
348
349#include <X11/Xfuncproto.h>
350
351_XFUNCPROTOBEGIN
352
353/*
354 * The following definitions can be used for locking requests in multi-threaded
355 * address spaces.
356 */
357#ifdef XTHREADS
358/* Author: Stephen Gildea, MIT X Consortium
359 *
360 * declarations for C Threads locking
361 */
362
363typedef struct _LockInfoRec *LockInfoPtr;
364
365/* interfaces for locking.c */
366struct _XLockPtrs {
367    /* used by all, including extensions; do not move */
368    void (*lock_display)(
369		Display *dpy
370#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
371		, char *file
372		, int line
373#endif
374	);
375    void (*unlock_display)(
376		Display *dpy
377#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
378		, char *file
379		, int line
380#endif
381	);
382};
383
384#if defined(WIN32) && !defined(_XLIBINT_)
385#define _XCreateMutex_fn (*_XCreateMutex_fn_p)
386#define _XFreeMutex_fn (*_XFreeMutex_fn_p)
387#define _XLockMutex_fn (*_XLockMutex_fn_p)
388#define _XUnlockMutex_fn (*_XUnlockMutex_fn_p)
389#define _Xglobal_lock (*_Xglobal_lock_p)
390#endif
391
392/* in XlibInt.c */
393extern void (*_XCreateMutex_fn)(
394    LockInfoPtr /* lock */
395);
396extern void (*_XFreeMutex_fn)(
397    LockInfoPtr /* lock */
398);
399extern void (*_XLockMutex_fn)(
400    LockInfoPtr	/* lock */
401#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
402    , char * /* file */
403    , int /* line */
404#endif
405);
406extern void (*_XUnlockMutex_fn)(
407    LockInfoPtr	/* lock */
408#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
409    , char * /* file */
410    , int /* line */
411#endif
412);
413
414extern LockInfoPtr _Xglobal_lock;
415
416#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
417#define LockDisplay(d)	     if ((d)->lock_fns) (*(d)->lock_fns->lock_display)((d),__FILE__,__LINE__)
418#define UnlockDisplay(d)     if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)((d),__FILE__,__LINE__)
419#define _XLockMutex(lock)		if (_XLockMutex_fn) (*_XLockMutex_fn)(lock,__FILE__,__LINE__)
420#define _XUnlockMutex(lock)	if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock,__FILE__,__LINE__)
421#else
422/* used everywhere, so must be fast if not using threads */
423#define LockDisplay(d)	     if ((d)->lock_fns) (*(d)->lock_fns->lock_display)(d)
424#define UnlockDisplay(d)     if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)(d)
425#define _XLockMutex(lock)		if (_XLockMutex_fn) (*_XLockMutex_fn)(lock)
426#define _XUnlockMutex(lock)	if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock)
427#endif
428#define _XCreateMutex(lock)	if (_XCreateMutex_fn) (*_XCreateMutex_fn)(lock);
429#define _XFreeMutex(lock)	if (_XFreeMutex_fn) (*_XFreeMutex_fn)(lock);
430
431#else /* XTHREADS */
432#define LockDisplay(dis)
433#define _XLockMutex(lock)
434#define _XUnlockMutex(lock)
435#define UnlockDisplay(dis)
436#define _XCreateMutex(lock)
437#define _XFreeMutex(lock)
438#endif
439
440#define Xfree(ptr) free((ptr))
441
442/*
443 * Note that some machines do not return a valid pointer for malloc(0), in
444 * which case we provide an alternate under the control of the
445 * define MALLOC_0_RETURNS_NULL.  This is necessary because some
446 * Xlib code expects malloc(0) to return a valid pointer to storage.
447 */
448#if defined(MALLOC_0_RETURNS_NULL) || defined(__clang_analyzer__)
449
450# define Xmalloc(size) malloc((size_t)((size) == 0 ? 1 : (size)))
451# define Xrealloc(ptr, size) realloc((ptr), (size_t)((size) == 0 ? 1 : (size)))
452# define Xcalloc(nelem, elsize) calloc((size_t)((nelem) == 0 ? 1 : (nelem)), (size_t)(elsize))
453
454#else
455
456# define Xmalloc(size) malloc((size_t)(size))
457# define Xrealloc(ptr, size) realloc((ptr), (size_t)(size))
458# define Xcalloc(nelem, elsize) calloc((size_t)(nelem), (size_t)(elsize))
459
460#endif
461
462#include <stddef.h>
463
464#define LOCKED 1
465#define UNLOCKED 0
466
467#ifndef BUFSIZE
468#define BUFSIZE 2048			/* X output buffer size. */
469#endif
470#ifndef PTSPERBATCH
471#define PTSPERBATCH 1024		/* point batching */
472#endif
473#ifndef WLNSPERBATCH
474#define WLNSPERBATCH 50			/* wide line batching */
475#endif
476#ifndef ZLNSPERBATCH
477#define ZLNSPERBATCH 1024		/* thin line batching */
478#endif
479#ifndef WRCTSPERBATCH
480#define WRCTSPERBATCH 10		/* wide line rectangle batching */
481#endif
482#ifndef ZRCTSPERBATCH
483#define ZRCTSPERBATCH 256		/* thin line rectangle batching */
484#endif
485#ifndef FRCTSPERBATCH
486#define FRCTSPERBATCH 256		/* filled rectangle batching */
487#endif
488#ifndef FARCSPERBATCH
489#define FARCSPERBATCH 256		/* filled arc batching */
490#endif
491#ifndef CURSORFONT
492#define CURSORFONT "cursor"		/* standard cursor fonts */
493#endif
494
495/*
496 * Display flags
497 */
498#define XlibDisplayIOError	(1L << 0)
499#define XlibDisplayClosing	(1L << 1)
500#define XlibDisplayNoXkb	(1L << 2)
501#define XlibDisplayPrivSync	(1L << 3)
502#define XlibDisplayProcConni	(1L << 4) /* in _XProcessInternalConnection */
503#define XlibDisplayReadEvents	(1L << 5) /* in _XReadEvents */
504#define XlibDisplayReply	(1L << 5) /* in _XReply */
505#define XlibDisplayWriting	(1L << 6) /* in _XFlushInt, _XSend */
506#define XlibDisplayDfltRMDB     (1L << 7) /* mark if RM db from XGetDefault */
507
508/*
509 * X Protocol packetizing macros.
510 */
511
512/* Leftover from CRAY support - was defined empty on all non-Cray systems */
513#define WORD64ALIGN
514
515/**
516 * Return a len-sized request buffer for the request type. This function may
517 * flush the output queue.
518 *
519 * @param dpy The display connection
520 * @param type The request type
521 * @param len Length of the request in bytes
522 *
523 * @returns A pointer to the request buffer with a few default values
524 * initialized.
525 */
526extern void *_XGetRequest(Display *dpy, CARD8 type, size_t len);
527
528/* GetReqSized is the same as GetReq but allows the caller to specify the
529 * size in bytes. 'sz' must be a multiple of 4! */
530
531#define GetReqSized(name, sz, req) \
532	req = (x##name##Req *) _XGetRequest(dpy, X_##name, sz)
533
534/*
535 * GetReq - Get the next available X request packet in the buffer and
536 * return it.
537 *
538 * "name" is the name of the request, e.g. CreatePixmap, OpenFont, etc.
539 * "req" is the name of the request pointer.
540 *
541 */
542
543#define GetReq(name, req) \
544	GetReqSized(name, SIZEOF(x##name##Req), req)
545
546/* GetReqExtra is the same as GetReq, but allocates "n" additional
547   bytes after the request. "n" must be a multiple of 4!  */
548
549#define GetReqExtra(name, n, req) \
550        GetReqSized(name, SIZEOF(x##name##Req) + n, req)
551
552/*
553 * GetResReq is for those requests that have a resource ID
554 * (Window, Pixmap, GContext, etc.) as their single argument.
555 * "rid" is the name of the resource.
556 */
557
558#define GetResReq(name, rid, req) \
559	req = (xResourceReq *) _XGetRequest(dpy, X_##name, SIZEOF(xResourceReq)); \
560	req->id = (rid)
561
562/*
563 * GetEmptyReq is for those requests that have no arguments
564 * at all.
565 */
566
567#define GetEmptyReq(name, req) \
568	req = (xReq *) _XGetRequest(dpy, X_##name, SIZEOF(xReq))
569
570/*
571 * MakeBigReq sets the CARD16 "req->length" to 0 and inserts a new CARD32
572 * length, after req->length, before the data in the request.  The new length
573 * includes the "n" extra 32-bit words.
574 *
575 * Do not use MakeBigReq if there is no data already in the request.
576 * req->length must already be >= 2.
577 */
578#ifdef LONG64
579#define MakeBigReq(req,n) \
580    { \
581    CARD64 _BRdat; \
582    CARD32 _BRlen = req->length - 1; \
583    req->length = 0; \
584    _BRdat = ((CARD32 *)req)[_BRlen]; \
585    memmove(((char *)req) + 8, ((char *)req) + 4, (_BRlen - 1) << 2); \
586    ((CARD32 *)req)[1] = _BRlen + n + 2; \
587    Data32(dpy, &_BRdat, 4); \
588    }
589#else
590#define MakeBigReq(req,n) \
591    { \
592    CARD32 _BRdat; \
593    CARD32 _BRlen = req->length - 1; \
594    req->length = 0; \
595    _BRdat = ((CARD32 *)req)[_BRlen]; \
596    memmove(((char *)req) + 8, ((char *)req) + 4, (_BRlen - 1) << 2); \
597    ((CARD32 *)req)[1] = _BRlen + n + 2; \
598    Data32(dpy, &_BRdat, 4); \
599    }
600#endif
601
602/*
603 * SetReqLen increases the count of 32-bit words in the request by "n",
604 * or by "badlen" if "n" is too large.
605 *
606 * Do not use SetReqLen if "req" does not already have data after the
607 * xReq header.  req->length must already be >= 2.
608 */
609#ifndef __clang_analyzer__
610#define SetReqLen(req,n,badlen) \
611    if ((req->length + n) > (unsigned)65535) { \
612	if (dpy->bigreq_size) { \
613	    MakeBigReq(req,n) \
614	} else { \
615	    n = badlen; \
616	    req->length += n; \
617	} \
618    } else \
619	req->length += n
620#else
621#define SetReqLen(req,n,badlen) \
622    req->length += n
623#endif
624
625#define SyncHandle() \
626	if (dpy->synchandler) (*dpy->synchandler)(dpy)
627
628extern void _XFlushGCCache(Display *dpy, GC gc);
629#define FlushGC(dpy, gc) \
630	if ((gc)->dirty) _XFlushGCCache((dpy), (gc))
631/*
632 * Data - Place data in the buffer and pad the end to provide
633 * 32 bit word alignment.  Transmit if the buffer fills.
634 *
635 * "dpy" is a pointer to a Display.
636 * "data" is a pointer to a data buffer.
637 * "len" is the length of the data buffer.
638 */
639#ifndef DataRoutineIsProcedure
640#define Data(dpy, data, len) {\
641	if (dpy->bufptr + (len) <= dpy->bufmax) {\
642		memcpy(dpy->bufptr, data, (int)(len));\
643		dpy->bufptr += ((len) + 3) & ~3;\
644	} else\
645		_XSend(dpy, data, len);\
646}
647#endif /* DataRoutineIsProcedure */
648
649
650/* Allocate bytes from the buffer.  No padding is done, so if
651 * the length is not a multiple of 4, the caller must be
652 * careful to leave the buffer aligned after sending the
653 * current request.
654 *
655 * "type" is the type of the pointer being assigned to.
656 * "ptr" is the pointer being assigned to.
657 * "n" is the number of bytes to allocate.
658 *
659 * Example:
660 *    xTextElt *elt;
661 *    BufAlloc (xTextElt *, elt, nbytes)
662 */
663
664#define BufAlloc(type, ptr, n) \
665    if (dpy->bufptr + (n) > dpy->bufmax) \
666        _XFlush (dpy); \
667    ptr = (type) dpy->bufptr; \
668    memset(ptr, '\0', n); \
669    dpy->bufptr += (n);
670
671#define Data16(dpy, data, len) Data((dpy), (_Xconst char *)(data), (len))
672#define _XRead16Pad(dpy, data, len) _XReadPad((dpy), (char *)(data), (len))
673#define _XRead16(dpy, data, len) _XRead((dpy), (char *)(data), (len))
674#ifdef LONG64
675#define Data32(dpy, data, len) _XData32(dpy, (_Xconst long *)data, len)
676extern int _XData32(
677	     Display *dpy,
678	     register _Xconst long *data,
679	     unsigned len
680);
681extern void _XRead32(
682	     Display *dpy,
683	     register long *data,
684	     long len
685);
686#else
687#define Data32(dpy, data, len) Data((dpy), (_Xconst char *)(data), (len))
688#define _XRead32(dpy, data, len) _XRead((dpy), (char *)(data), (len))
689#endif
690
691#define PackData16(dpy,data,len) Data16 (dpy, data, len)
692#define PackData32(dpy,data,len) Data32 (dpy, data, len)
693
694/* Xlib manual is bogus */
695#define PackData(dpy,data,len) PackData16 (dpy, data, len)
696
697#define min(a,b) (((a) < (b)) ? (a) : (b))
698#define max(a,b) (((a) > (b)) ? (a) : (b))
699
700#define CI_NONEXISTCHAR(cs) (((cs)->width == 0) && \
701			     (((cs)->rbearing|(cs)->lbearing| \
702			       (cs)->ascent|(cs)->descent) == 0))
703
704/*
705 * CI_GET_CHAR_INFO_1D - return the charinfo struct for the indicated 8bit
706 * character.  If the character is in the column and exists, then return the
707 * appropriate metrics (note that fonts with common per-character metrics will
708 * return min_bounds).  If none of these hold true, try again with the default
709 * char.
710 */
711#define CI_GET_CHAR_INFO_1D(fs,col,def,cs) \
712{ \
713    cs = def; \
714    if (col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \
715	if (fs->per_char == NULL) { \
716	    cs = &fs->min_bounds; \
717	} else { \
718	    cs = &fs->per_char[(col - fs->min_char_or_byte2)]; \
719	    if (CI_NONEXISTCHAR(cs)) cs = def; \
720	} \
721    } \
722}
723
724#define CI_GET_DEFAULT_INFO_1D(fs,cs) \
725  CI_GET_CHAR_INFO_1D (fs, fs->default_char, NULL, cs)
726
727
728
729/*
730 * CI_GET_CHAR_INFO_2D - return the charinfo struct for the indicated row and
731 * column.  This is used for fonts that have more than row zero.
732 */
733#define CI_GET_CHAR_INFO_2D(fs,row,col,def,cs) \
734{ \
735    cs = def; \
736    if (row >= fs->min_byte1 && row <= fs->max_byte1 && \
737	col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \
738	if (fs->per_char == NULL) { \
739	    cs = &fs->min_bounds; \
740	} else { \
741	    cs = &fs->per_char[((row - fs->min_byte1) * \
742			        (fs->max_char_or_byte2 - \
743				 fs->min_char_or_byte2 + 1)) + \
744			       (col - fs->min_char_or_byte2)]; \
745	    if (CI_NONEXISTCHAR(cs)) cs = def; \
746        } \
747    } \
748}
749
750#define CI_GET_DEFAULT_INFO_2D(fs,cs) \
751{ \
752    unsigned int r = (fs->default_char >> 8); \
753    unsigned int c = (fs->default_char & 0xff); \
754    CI_GET_CHAR_INFO_2D (fs, r, c, NULL, cs); \
755}
756
757
758/* srcvar must be a variable for large architecture version */
759#define OneDataCard32(dpy,dstaddr,srcvar) \
760  { *(CARD32 *)(dstaddr) = (srcvar); }
761
762
763typedef struct _XInternalAsync {
764    struct _XInternalAsync *next;
765    /*
766     * handler arguments:
767     * rep is the generic reply that caused this handler
768     * to be invoked.  It must also be passed to _XGetAsyncReply.
769     * buf and len are opaque values that must be passed to
770     * _XGetAsyncReply or _XGetAsyncData.
771     * data is the closure stored in this struct.
772     * The handler returns True iff it handled this reply.
773     */
774    Bool (*handler)(
775		    Display*	/* dpy */,
776		    xReply*	/* rep */,
777		    char*	/* buf */,
778		    int		/* len */,
779		    XPointer	/* data */
780		    );
781    XPointer data;
782} _XAsyncHandler;
783
784/*
785 * This struct is part of the ABI and is defined by value
786 * in user-code. This means that we cannot make
787 * the sequence-numbers 64bit.
788 */
789typedef struct _XAsyncEState {
790    unsigned long min_sequence_number;
791    unsigned long max_sequence_number;
792    unsigned char error_code;
793    unsigned char major_opcode;
794    unsigned short minor_opcode;
795    unsigned char last_error_received;
796    int error_count;
797} _XAsyncErrorState;
798
799extern void _XDeqAsyncHandler(Display *dpy, _XAsyncHandler *handler);
800#define DeqAsyncHandler(dpy,handler) { \
801    if (dpy->async_handlers == (handler)) \
802	dpy->async_handlers = (handler)->next; \
803    else \
804	_XDeqAsyncHandler(dpy, handler); \
805    }
806
807typedef void (*FreeFuncType) (
808    Display*	/* display */
809);
810
811typedef int (*FreeModmapType) (
812    XModifierKeymap*	/* modmap */
813);
814
815/*
816 * This structure is private to the library.
817 */
818typedef struct _XFreeFuncs {
819    FreeFuncType atoms;		/* _XFreeAtomTable */
820    FreeModmapType modifiermap;	/* XFreeModifiermap */
821    FreeFuncType key_bindings;	/* _XFreeKeyBindings */
822    FreeFuncType context_db;	/* _XFreeContextDB */
823    FreeFuncType defaultCCCs;	/* _XcmsFreeDefaultCCCs */
824    FreeFuncType clientCmaps;	/* _XcmsFreeClientCmaps */
825    FreeFuncType intensityMaps;	/* _XcmsFreeIntensityMaps */
826    FreeFuncType im_filters;	/* _XFreeIMFilters */
827    FreeFuncType xkb;		/* _XkbFreeInfo */
828} _XFreeFuncRec;
829
830/* types for InitExt.c */
831typedef int (*CreateGCType) (
832    Display*	/* display */,
833    GC		/* gc */,
834    XExtCodes*	/* codes */
835);
836
837typedef int (*CopyGCType)(
838    Display*	/* display */,
839    GC		/* gc */,
840    XExtCodes*	/* codes */
841);
842
843typedef int (*FlushGCType) (
844    Display*	/* display */,
845    GC		/* gc */,
846    XExtCodes*	/* codes */
847);
848
849typedef int (*FreeGCType) (
850    Display*	/* display */,
851    GC		/* gc */,
852    XExtCodes*	/* codes */
853);
854
855typedef int (*CreateFontType) (
856    Display*	/* display */,
857    XFontStruct* /* fs */,
858    XExtCodes*	/* codes */
859);
860
861typedef int (*FreeFontType) (
862    Display*	/* display */,
863    XFontStruct* /* fs */,
864    XExtCodes*	/* codes */
865);
866
867typedef int (*CloseDisplayType) (
868    Display*	/* display */,
869    XExtCodes*	/* codes */
870);
871
872typedef int (*ErrorType) (
873    Display*	/* display */,
874    xError*	/* err */,
875    XExtCodes*	/* codes */,
876    int*	/* ret_code */
877);
878
879typedef char* (*ErrorStringType) (
880    Display*	/* display */,
881    int		/* code */,
882    XExtCodes*	/* codes */,
883    char*	/* buffer */,
884    int		/* nbytes */
885);
886
887typedef void (*PrintErrorType)(
888    Display*	/* display */,
889    XErrorEvent* /* ev */,
890    void*	/* fp */
891);
892
893typedef void (*BeforeFlushType)(
894    Display*	/* display */,
895    XExtCodes*	/* codes */,
896    _Xconst char* /* data */,
897    long	/* len */
898);
899
900/*
901 * This structure is private to the library.
902 */
903typedef struct _XExten {		/* private to extension mechanism */
904	struct _XExten *next;		/* next in list */
905	XExtCodes codes;		/* public information, all extension told */
906	CreateGCType create_GC;		/* routine to call when GC created */
907	CopyGCType copy_GC;		/* routine to call when GC copied */
908	FlushGCType flush_GC;		/* routine to call when GC flushed */
909	FreeGCType free_GC;		/* routine to call when GC freed */
910	CreateFontType create_Font;	/* routine to call when Font created */
911	FreeFontType free_Font;		/* routine to call when Font freed */
912	CloseDisplayType close_display;	/* routine to call when connection closed */
913	ErrorType error;		/* who to call when an error occurs */
914	ErrorStringType error_string;	/* routine to supply error string */
915	char *name;			/* name of this extension */
916	PrintErrorType error_values;	/* routine to supply error values */
917	BeforeFlushType before_flush;	/* routine to call when sending data */
918	struct _XExten *next_flush;	/* next in list of those with flushes */
919} _XExtension;
920
921/* Temporary definition until we can depend on an xproto release with it */
922#ifdef _X_COLD
923# define _XLIB_COLD _X_COLD
924#elif defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 403) /* 4.3+ */
925# define _XLIB_COLD __attribute__((__cold__))
926#else
927# define _XLIB_COLD /* nothing */
928#endif
929
930/* extension hooks */
931
932#ifdef DataRoutineIsProcedure
933extern void Data(Display *dpy, char *data, long len);
934#endif
935extern int _XError(
936    Display*	/* dpy */,
937    xError*	/* rep */
938);
939extern int _XIOError(
940    Display*	/* dpy */
941) _X_NORETURN;
942extern int (*_XIOErrorFunction)(
943    Display*	/* dpy */
944);
945extern int (*_XErrorFunction)(
946    Display*		/* dpy */,
947    XErrorEvent*	/* error_event */
948);
949extern void _XEatData(
950    Display*		/* dpy */,
951    unsigned long	/* n */
952) _XLIB_COLD;
953extern void _XEatDataWords(
954    Display*		/* dpy */,
955    unsigned long	/* n */
956) _XLIB_COLD;
957#if defined(__SUNPRO_C) /* Studio compiler alternative to "cold" attribute */
958# pragma rarely_called(_XEatData, _XEatDataWords)
959#endif
960extern char *_XAllocScratch(
961    Display*		/* dpy */,
962    unsigned long	/* nbytes */
963);
964extern char *_XAllocTemp(
965    Display*		/* dpy */,
966    unsigned long	/* nbytes */
967);
968extern void _XFreeTemp(
969    Display*		/* dpy */,
970    char*		/* buf */,
971    unsigned long	/* nbytes */
972);
973extern Visual *_XVIDtoVisual(
974    Display*	/* dpy */,
975    VisualID	/* id */
976);
977extern unsigned long _XSetLastRequestRead(
978    Display*		/* dpy */,
979    xGenericReply*	/* rep */
980);
981extern int _XGetHostname(
982    char*	/* buf */,
983    int		/* maxlen */
984);
985extern Screen *_XScreenOfWindow(
986    Display*	/* dpy */,
987    Window	/* w */
988);
989extern Bool _XAsyncErrorHandler(
990    Display*	/* dpy */,
991    xReply*	/* rep */,
992    char*	/* buf */,
993    int		/* len */,
994    XPointer	/* data */
995);
996extern char *_XGetAsyncReply(
997    Display*	/* dpy */,
998    char*	/* replbuf */,
999    xReply*	/* rep */,
1000    char*	/* buf */,
1001    int		/* len */,
1002    int		/* extra */,
1003    Bool	/* discard */
1004);
1005extern void _XGetAsyncData(
1006    Display*	/* dpy */,
1007    char *	/* data */,
1008    char *	/* buf */,
1009    int		/* len */,
1010    int		/* skip */,
1011    int		/* datalen */,
1012    int		/* discardtotal */
1013);
1014extern void _XFlush(
1015    Display*	/* dpy */
1016);
1017extern int _XEventsQueued(
1018    Display*	/* dpy */,
1019    int 	/* mode */
1020);
1021extern void _XReadEvents(
1022    Display*	/* dpy */
1023);
1024extern int _XRead(
1025    Display*	/* dpy */,
1026    char*	/* data */,
1027    long	/* size */
1028);
1029extern void _XReadPad(
1030    Display*	/* dpy */,
1031    char*	/* data */,
1032    long	/* size */
1033);
1034extern void _XSend(
1035    Display*		/* dpy */,
1036    _Xconst char*	/* data */,
1037    long		/* size */
1038);
1039extern Status _XReply(
1040    Display*	/* dpy */,
1041    xReply*	/* rep */,
1042    int		/* extra */,
1043    Bool	/* discard */
1044);
1045extern void _XEnq(
1046    Display*	/* dpy */,
1047    xEvent*	/* event */
1048);
1049extern void _XDeq(
1050    Display*	/* dpy */,
1051    _XQEvent*	/* prev */,
1052    _XQEvent*	/* qelt */
1053);
1054
1055extern Bool _XUnknownWireEvent(
1056    Display*	/* dpy */,
1057    XEvent*	/* re */,
1058    xEvent*	/* event */
1059);
1060
1061extern Bool _XUnknownWireEventCookie(
1062    Display*	/* dpy */,
1063    XGenericEventCookie*	/* re */,
1064    xEvent*	/* event */
1065);
1066
1067extern Bool _XUnknownCopyEventCookie(
1068    Display*	/* dpy */,
1069    XGenericEventCookie*	/* in */,
1070    XGenericEventCookie*	/* out */
1071);
1072
1073extern Status _XUnknownNativeEvent(
1074    Display*	/* dpy */,
1075    XEvent*	/* re */,
1076    xEvent*	/* event */
1077);
1078
1079extern Bool _XWireToEvent(Display *dpy, XEvent *re, xEvent *event);
1080extern Bool _XDefaultWireError(Display *display, XErrorEvent *he, xError *we);
1081extern Bool _XPollfdCacheInit(Display *dpy);
1082extern void _XPollfdCacheAdd(Display *dpy, int fd);
1083extern void _XPollfdCacheDel(Display *dpy, int fd);
1084extern XID _XAllocID(Display *dpy);
1085extern void _XAllocIDs(Display *dpy, XID *ids, int count);
1086
1087extern int _XFreeExtData(
1088    XExtData*	/* extension */
1089);
1090
1091extern int (*XESetCreateGC(
1092    Display*		/* display */,
1093    int			/* extension */,
1094    int (*) (
1095	      Display*			/* display */,
1096	      GC			/* gc */,
1097	      XExtCodes*		/* codes */
1098	    )		/* proc */
1099))(
1100    Display*, GC, XExtCodes*
1101);
1102
1103extern int (*XESetCopyGC(
1104    Display*		/* display */,
1105    int			/* extension */,
1106    int (*) (
1107	      Display*			/* display */,
1108              GC			/* gc */,
1109              XExtCodes*		/* codes */
1110            )		/* proc */
1111))(
1112    Display*, GC, XExtCodes*
1113);
1114
1115extern int (*XESetFlushGC(
1116    Display*		/* display */,
1117    int			/* extension */,
1118    int (*) (
1119	      Display*			/* display */,
1120              GC			/* gc */,
1121              XExtCodes*		/* codes */
1122            )		/* proc */
1123))(
1124    Display*, GC, XExtCodes*
1125);
1126
1127extern int (*XESetFreeGC(
1128    Display*		/* display */,
1129    int			/* extension */,
1130    int (*) (
1131	      Display*			/* display */,
1132              GC			/* gc */,
1133              XExtCodes*		/* codes */
1134            )		/* proc */
1135))(
1136    Display*, GC, XExtCodes*
1137);
1138
1139extern int (*XESetCreateFont(
1140    Display*		/* display */,
1141    int			/* extension */,
1142    int (*) (
1143	      Display*			/* display */,
1144              XFontStruct*		/* fs */,
1145              XExtCodes*		/* codes */
1146            )		/* proc */
1147))(
1148    Display*, XFontStruct*, XExtCodes*
1149);
1150
1151extern int (*XESetFreeFont(
1152    Display*		/* display */,
1153    int			/* extension */,
1154    int (*) (
1155	      Display*			/* display */,
1156              XFontStruct*		/* fs */,
1157              XExtCodes*		/* codes */
1158            )		/* proc */
1159))(
1160    Display*, XFontStruct*, XExtCodes*
1161);
1162
1163extern int (*XESetCloseDisplay(
1164    Display*		/* display */,
1165    int			/* extension */,
1166    int (*) (
1167	      Display*			/* display */,
1168              XExtCodes*		/* codes */
1169            )		/* proc */
1170))(
1171    Display*, XExtCodes*
1172);
1173
1174extern int (*XESetError(
1175    Display*		/* display */,
1176    int			/* extension */,
1177    int (*) (
1178	      Display*			/* display */,
1179              xError*			/* err */,
1180              XExtCodes*		/* codes */,
1181              int*			/* ret_code */
1182            )		/* proc */
1183))(
1184    Display*, xError*, XExtCodes*, int*
1185);
1186
1187extern char* (*XESetErrorString(
1188    Display*		/* display */,
1189    int			/* extension */,
1190    char* (*) (
1191	        Display*		/* display */,
1192                int			/* code */,
1193                XExtCodes*		/* codes */,
1194                char*			/* buffer */,
1195                int			/* nbytes */
1196              )		/* proc */
1197))(
1198    Display*, int, XExtCodes*, char*, int
1199);
1200
1201extern void (*XESetPrintErrorValues (
1202    Display*		/* display */,
1203    int			/* extension */,
1204    void (*)(
1205	      Display*			/* display */,
1206	      XErrorEvent*		/* ev */,
1207	      void*			/* fp */
1208	     )		/* proc */
1209))(
1210    Display*, XErrorEvent*, void*
1211);
1212
1213extern Bool (*XESetWireToEvent(
1214    Display*		/* display */,
1215    int			/* event_number */,
1216    Bool (*) (
1217	       Display*			/* display */,
1218               XEvent*			/* re */,
1219               xEvent*			/* event */
1220             )		/* proc */
1221))(
1222    Display*, XEvent*, xEvent*
1223);
1224
1225extern Bool (*XESetWireToEventCookie(
1226    Display*		/* display */,
1227    int			/* extension */,
1228    Bool (*) (
1229	       Display*			/* display */,
1230               XGenericEventCookie*	/* re */,
1231               xEvent*			/* event */
1232             )		/* proc */
1233))(
1234    Display*, XGenericEventCookie*, xEvent*
1235);
1236
1237extern Bool (*XESetCopyEventCookie(
1238    Display*		/* display */,
1239    int			/* extension */,
1240    Bool (*) (
1241	       Display*			/* display */,
1242               XGenericEventCookie*	/* in */,
1243               XGenericEventCookie*	/* out */
1244             )		/* proc */
1245))(
1246    Display*, XGenericEventCookie*, XGenericEventCookie*
1247);
1248
1249
1250extern Status (*XESetEventToWire(
1251    Display*		/* display */,
1252    int			/* event_number */,
1253    Status (*) (
1254	      Display*			/* display */,
1255              XEvent*			/* re */,
1256              xEvent*			/* event */
1257            )		/* proc */
1258))(
1259    Display*, XEvent*, xEvent*
1260);
1261
1262extern Bool (*XESetWireToError(
1263    Display*		/* display */,
1264    int			/* error_number */,
1265    Bool (*) (
1266	       Display*			/* display */,
1267	       XErrorEvent*		/* he */,
1268	       xError*			/* we */
1269            )		/* proc */
1270))(
1271    Display*, XErrorEvent*, xError*
1272);
1273
1274extern void (*XESetBeforeFlush(
1275    Display*		/* display */,
1276    int			/* error_number */,
1277    void (*) (
1278	       Display*			/* display */,
1279	       XExtCodes*		/* codes */,
1280	       _Xconst char*		/* data */,
1281	       long			/* len */
1282            )		/* proc */
1283))(
1284    Display*, XExtCodes*, _Xconst char*, long
1285);
1286
1287/* internal connections for IMs */
1288
1289typedef void (*_XInternalConnectionProc)(
1290    Display*			/* dpy */,
1291    int				/* fd */,
1292    XPointer			/* call_data */
1293);
1294
1295
1296extern Status _XRegisterInternalConnection(
1297    Display*			/* dpy */,
1298    int				/* fd */,
1299    _XInternalConnectionProc	/* callback */,
1300    XPointer			/* call_data */
1301);
1302
1303extern void _XUnregisterInternalConnection(
1304    Display*			/* dpy */,
1305    int				/* fd */
1306);
1307
1308extern void _XProcessInternalConnection(
1309    Display*			/* dpy */,
1310    struct _XConnectionInfo*	/* conn_info */
1311);
1312
1313/* Display structure has pointers to these */
1314
1315struct _XConnectionInfo {	/* info from _XRegisterInternalConnection */
1316    int fd;
1317    _XInternalConnectionProc read_callback;
1318    XPointer call_data;
1319    XPointer *watch_data;	/* set/used by XConnectionWatchProc */
1320    struct _XConnectionInfo *next;
1321};
1322
1323struct _XConnWatchInfo {	/* info from XAddConnectionWatch */
1324    XConnectionWatchProc fn;
1325    XPointer client_data;
1326    struct _XConnWatchInfo *next;
1327};
1328
1329#ifdef __UNIXOS2__
1330extern char* __XOS2RedirRoot(
1331    char*
1332);
1333#endif
1334
1335extern int _XTextHeight(
1336    XFontStruct*	/* font_struct */,
1337    _Xconst char*	/* string */,
1338    int			/* count */
1339);
1340
1341extern int _XTextHeight16(
1342    XFontStruct*	/* font_struct */,
1343    _Xconst XChar2b*	/* string */,
1344    int			/* count */
1345);
1346
1347#if defined(WIN32)
1348
1349extern int _XOpenFile(
1350    _Xconst char*	/* path */,
1351    int			/* flags */
1352);
1353
1354extern int _XOpenFileMode(
1355    _Xconst char*	/* path */,
1356    int			/* flags */,
1357    mode_t              /* mode */
1358);
1359
1360extern void* _XFopenFile(
1361    _Xconst char*	/* path */,
1362    _Xconst char*	/* mode */
1363);
1364
1365extern int _XAccessFile(
1366    _Xconst char*	/* path */
1367);
1368#else
1369#define _XOpenFile(path,flags) open(path,flags)
1370#define _XOpenFileMode(path,flags,mode) open(path,flags,mode)
1371#define _XFopenFile(path,mode) fopen(path,mode)
1372#endif
1373
1374/* EvToWire.c */
1375extern Status _XEventToWire(Display *dpy, XEvent *re, xEvent *event);
1376
1377extern int _XF86LoadQueryLocaleFont(
1378    Display*		/* dpy */,
1379    _Xconst char*	/* name*/,
1380    XFontStruct**	/* xfp*/,
1381    Font*		/* fidp */
1382);
1383
1384extern void _XProcessWindowAttributes (
1385    register Display *dpy,
1386    xChangeWindowAttributesReq *req,
1387    register unsigned long valuemask,
1388    register XSetWindowAttributes *attributes);
1389
1390extern int _XDefaultError(
1391        Display *dpy,
1392        XErrorEvent *event);
1393
1394extern int _XDefaultIOError(
1395        Display *dpy);
1396
1397extern void _XSetClipRectangles (
1398    register Display *dpy,
1399    GC gc,
1400    int clip_x_origin, int clip_y_origin,
1401    XRectangle *rectangles,
1402    int n,
1403    int ordering);
1404
1405Status _XGetWindowAttributes(
1406    register Display *dpy,
1407    Window w,
1408    XWindowAttributes *attr);
1409
1410int _XPutBackEvent (
1411    register Display *dpy,
1412    register XEvent *event);
1413
1414extern Bool _XIsEventCookie(
1415        Display *dpy,
1416        XEvent *ev);
1417
1418extern void _XFreeEventCookies(
1419        Display *dpy);
1420
1421extern void _XStoreEventCookie(
1422        Display *dpy,
1423        XEvent *ev);
1424
1425extern Bool _XFetchEventCookie(
1426        Display *dpy,
1427        XGenericEventCookie *ev);
1428
1429extern Bool _XCopyEventCookie(
1430        Display *dpy,
1431        XGenericEventCookie *in,
1432        XGenericEventCookie *out);
1433
1434/* lcFile.c */
1435
1436extern void xlocaledir(
1437    char *buf,
1438    int buf_len
1439);
1440
1441#ifdef __clang__
1442#pragma clang diagnostic pop
1443#endif
1444
1445_XFUNCPROTOEND
1446
1447#endif /* _X11_XLIBINT_H_ */
1448