Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 09:15:20

0001 
0002 /*
0003 
0004 Copyright 1984, 1985, 1987, 1989, 1998  The Open Group
0005 
0006 Permission to use, copy, modify, distribute, and sell this software and its
0007 documentation for any purpose is hereby granted without fee, provided that
0008 the above copyright notice appear in all copies and that both that
0009 copyright notice and this permission notice appear in supporting
0010 documentation.
0011 
0012 The above copyright notice and this permission notice shall be included
0013 in all copies or substantial portions of the Software.
0014 
0015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
0016 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0017 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
0018 IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
0019 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0020 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0021 OTHER DEALINGS IN THE SOFTWARE.
0022 
0023 Except as contained in this notice, the name of The Open Group shall
0024 not be used in advertising or otherwise to promote the sale, use or
0025 other dealings in this Software without prior written authorization
0026 from The Open Group.
0027 
0028 */
0029 
0030 #ifndef _X11_XLIBINT_H_
0031 #define _X11_XLIBINT_H_ 1
0032 
0033 /*
0034  *  Xlibint.h - Header definition and support file for the internal
0035  *  support routines used by the C subroutine interface
0036  *  library (Xlib) to the X Window System.
0037  *
0038  *  Warning, there be dragons here....
0039  */
0040 
0041 #include <stdint.h>
0042 #include <X11/Xlib.h>
0043 #include <X11/Xproto.h>     /* to declare xEvent */
0044 #include <X11/XlibConf.h>   /* for configured options like XTHREADS */
0045 
0046 #ifdef XTHREADS
0047 #include <X11/Xthreads.h>
0048 #endif
0049 
0050 /* The Xlib structs are full of implicit padding to properly align members.
0051    We can't clean that up without breaking ABI, so tell clang not to bother
0052    complaining about it. */
0053 #ifdef __clang__
0054 #pragma clang diagnostic push
0055 #pragma clang diagnostic ignored "-Wpadded"
0056 #endif
0057 
0058 #ifdef WIN32
0059 #define _XFlush _XFlushIt
0060 #endif
0061 
0062 struct _XGC
0063 {
0064     XExtData *ext_data; /* hook for extension to hang data */
0065     GContext gid;   /* protocol ID for graphics context */
0066     Bool rects;     /* boolean: TRUE if clipmask is list of rectangles */
0067     Bool dashes;    /* boolean: TRUE if dash-list is really a list */
0068     unsigned long dirty;/* cache dirty bits */
0069     XGCValues values;   /* shadow structure of values */
0070 };
0071 
0072 struct _XDisplay
0073 {
0074     XExtData *ext_data; /* hook for extension to hang data */
0075     struct _XFreeFuncs *free_funcs; /* internal free functions */
0076     int fd;         /* Network socket. */
0077     int conn_checker;         /* ugly thing used by _XEventsQueued */
0078     int proto_major_version;/* maj. version of server's X protocol */
0079     int proto_minor_version;/* minor version of server's X protocol */
0080     char *vendor;       /* vendor of the server hardware */
0081         XID resource_base;  /* resource ID base */
0082     XID resource_mask;  /* resource ID mask bits */
0083     XID resource_id;    /* allocator current ID */
0084     int resource_shift; /* allocator shift to correct bits */
0085     XID (*resource_alloc)(  /* allocator function */
0086         struct _XDisplay*
0087         );
0088     int byte_order;     /* screen byte order, LSBFirst, MSBFirst */
0089     int bitmap_unit;    /* padding and data requirements */
0090     int bitmap_pad;     /* padding requirements on bitmaps */
0091     int bitmap_bit_order;   /* LeastSignificant or MostSignificant */
0092     int nformats;       /* number of pixmap formats in list */
0093     ScreenFormat *pixmap_format;    /* pixmap format list */
0094     int vnumber;        /* Xlib's X protocol version number. */
0095     int release;        /* release of the server */
0096     struct _XSQEvent *head, *tail;  /* Input event queue. */
0097     int qlen;       /* Length of input event queue */
0098     unsigned long last_request_read; /* seq number of last event read */
0099     unsigned long request;  /* sequence number of last request. */
0100     char *last_req;     /* beginning of last request, or dummy */
0101     char *buffer;       /* Output buffer starting address. */
0102     char *bufptr;       /* Output buffer index pointer. */
0103     char *bufmax;       /* Output buffer maximum+1 address. */
0104     unsigned max_request_size; /* maximum number 32 bit words in request*/
0105     struct _XrmHashBucketRec *db;
0106     int (*synchandler)( /* Synchronization handler */
0107         struct _XDisplay*
0108         );
0109     char *display_name; /* "host:display" string used on this connect*/
0110     int default_screen; /* default screen for operations */
0111     int nscreens;       /* number of screens on this server*/
0112     Screen *screens;    /* pointer to list of screens */
0113     unsigned long motion_buffer;    /* size of motion buffer */
0114     volatile unsigned long flags;      /* internal connection flags */
0115     int min_keycode;    /* minimum defined keycode */
0116     int max_keycode;    /* maximum defined keycode */
0117     KeySym *keysyms;    /* This server's keysyms */
0118     XModifierKeymap *modifiermap;   /* This server's modifier keymap */
0119     int keysyms_per_keycode;/* number of rows */
0120     char *xdefaults;    /* contents of defaults from server */
0121     char *scratch_buffer;   /* place to hang scratch buffer */
0122     unsigned long scratch_length;   /* length of scratch buffer */
0123     int ext_number;     /* extension number on this display */
0124     struct _XExten *ext_procs; /* extensions initialized on this display */
0125     /*
0126      * the following can be fixed size, as the protocol defines how
0127      * much address space is available.
0128      * While this could be done using the extension vector, there
0129      * may be MANY events processed, so a search through the extension
0130      * list to find the right procedure for each event might be
0131      * expensive if many extensions are being used.
0132      */
0133     Bool (*event_vec[128])( /* vector for wire to event */
0134         Display *   /* dpy */,
0135         XEvent *    /* re */,
0136         xEvent *    /* event */
0137         );
0138     Status (*wire_vec[128])( /* vector for event to wire */
0139         Display *   /* dpy */,
0140         XEvent *    /* re */,
0141         xEvent *    /* event */
0142         );
0143     KeySym lock_meaning;       /* for XLookupString */
0144     struct _XLockInfo *lock;   /* multi-thread state, display lock */
0145     struct _XInternalAsync *async_handlers; /* for internal async */
0146     unsigned long bigreq_size; /* max size of big requests */
0147     struct _XLockPtrs *lock_fns; /* pointers to threads functions */
0148     void (*idlist_alloc)(      /* XID list allocator function */
0149         Display *   /* dpy */,
0150         XID *       /* ids */,
0151         int     /* count */
0152         );
0153     /* things above this line should not move, for binary compatibility */
0154     struct _XKeytrans *key_bindings; /* for XLookupString */
0155     Font cursor_font;      /* for XCreateFontCursor */
0156     struct _XDisplayAtoms *atoms; /* for XInternAtom */
0157     unsigned int mode_switch;  /* keyboard group modifiers */
0158     unsigned int num_lock;  /* keyboard numlock modifiers */
0159     struct _XContextDB *context_db; /* context database */
0160     Bool (**error_vec)( /* vector for wire to error */
0161         Display     *   /* display */,
0162         XErrorEvent *   /* he */,
0163         xError      *   /* we */
0164         );
0165     /*
0166      * Xcms information
0167      */
0168     struct {
0169        XPointer defaultCCCs;  /* pointer to an array of default XcmsCCC */
0170        XPointer clientCmaps;  /* pointer to linked list of XcmsCmapRec */
0171        XPointer perVisualIntensityMaps;
0172                   /* linked list of XcmsIntensityMap */
0173     } cms;
0174     struct _XIMFilter *im_filters;
0175     struct _XSQEvent *qfree; /* unallocated event queue elements */
0176     unsigned long next_event_serial_num; /* inserted into next queue elt */
0177     struct _XExten *flushes; /* Flush hooks */
0178     struct _XConnectionInfo *im_fd_info; /* _XRegisterInternalConnection */
0179     int im_fd_length;   /* number of im_fd_info */
0180     struct _XConnWatchInfo *conn_watchers; /* XAddConnectionWatch */
0181     int watcher_count;  /* number of conn_watchers */
0182     XPointer filedes;   /* struct pollfd cache for _XWaitForReadable */
0183     int (*savedsynchandler)( /* user synchandler when Xlib usurps */
0184         Display *   /* dpy */
0185         );
0186     XID resource_max;   /* allocator max ID */
0187     int xcmisc_opcode;  /* major opcode for XC-MISC */
0188     struct _XkbInfoRec *xkb_info; /* XKB info */
0189     struct _XtransConnInfo *trans_conn; /* transport connection object */
0190     struct _X11XCBPrivate *xcb; /* XCB glue private data */
0191 
0192     /* Generic event cookie handling */
0193     unsigned int next_cookie; /* next event cookie */
0194     /* vector for wire to generic event, index is (extension - 128) */
0195     Bool (*generic_event_vec[128])(
0196         Display *   /* dpy */,
0197         XGenericEventCookie *   /* Xlib event */,
0198         xEvent *    /* wire event */);
0199     /* vector for event copy, index is (extension - 128) */
0200     Bool (*generic_event_copy_vec[128])(
0201         Display *   /* dpy */,
0202         XGenericEventCookie *   /* in */,
0203         XGenericEventCookie *   /* out*/);
0204     void *cookiejar;  /* cookie events returned but not claimed */
0205 #ifndef LONG64
0206     unsigned long last_request_read_upper32bit;
0207     unsigned long request_upper32bit;
0208 #endif
0209 
0210     struct _XErrorThreadInfo *error_threads;
0211 
0212     XIOErrorExitHandler exit_handler;
0213     void *exit_handler_data;
0214     CARD32 in_ifevent;
0215 #ifdef XTHREADS
0216     xthread_t ifevent_thread;
0217 #endif
0218 };
0219 
0220 #define XAllocIDs(dpy,ids,n) (*(dpy)->idlist_alloc)(dpy,ids,n)
0221 
0222 /*
0223  * access "last_request_read" and "request" with 64bit
0224  * warning: the value argument of the SET-macros must not
0225  * have any side-effects because it may get called twice.
0226  */
0227 #ifndef LONG64
0228 /* accessors for 32-bit unsigned long */
0229 
0230 #define X_DPY_GET_REQUEST(dpy) \
0231     ( \
0232         ((uint64_t)(((struct _XDisplay*)dpy)->request)) \
0233     + (((uint64_t)(((struct _XDisplay*)dpy)->request_upper32bit)) << 32) \
0234     )
0235 
0236 #define X_DPY_SET_REQUEST(dpy, value) \
0237     ( \
0238         (((struct _XDisplay*)dpy)->request = \
0239             (value) & 0xFFFFFFFFUL), \
0240         (((struct _XDisplay*)dpy)->request_upper32bit = \
0241             ((uint64_t)(value)) >> 32), \
0242     (void)0 /* don't use the result */ \
0243     )
0244 
0245 #define X_DPY_GET_LAST_REQUEST_READ(dpy) \
0246     ( \
0247         ((uint64_t)(((struct _XDisplay*)dpy)->last_request_read)) \
0248         + ( \
0249             ((uint64_t)( \
0250                 ((struct _XDisplay*)dpy)->last_request_read_upper32bit \
0251             )) << 32 \
0252         ) \
0253     )
0254 
0255 #define X_DPY_SET_LAST_REQUEST_READ(dpy, value) \
0256     ( \
0257         (((struct _XDisplay*)dpy)->last_request_read = \
0258             (value) & 0xFFFFFFFFUL), \
0259         (((struct _XDisplay*)dpy)->last_request_read_upper32bit = \
0260             ((uint64_t)(value)) >> 32), \
0261     (void)0 /* don't use the result */ \
0262     )
0263 
0264 /*
0265  * widen a 32-bit sequence number to a 64 sequence number.
0266  * This macro makes the following assumptions:
0267  * - ulseq refers to a sequence that has already been sent
0268  * - ulseq means the most recent possible sequence number
0269  *   with these lower 32 bits.
0270  *
0271  * The following optimization is used:
0272  * The comparison result is taken a 0 or 1 to avoid a branch.
0273  */
0274 #define X_DPY_WIDEN_UNSIGNED_LONG_SEQ(dpy, ulseq) \
0275     ( \
0276         ((uint64_t)ulseq) \
0277         + \
0278         (( \
0279             ((uint64_t)(((struct _XDisplay*)dpy)->request_upper32bit)) \
0280             - (uint64_t)( \
0281                 (ulseq) > (((struct _XDisplay*)dpy)->request) \
0282         ) \
0283         ) << 32) \
0284     )
0285 
0286 #define X_DPY_REQUEST_INCREMENT(dpy) \
0287     ( \
0288         ((struct _XDisplay*)dpy)->request++, \
0289         ( \
0290             (((struct _XDisplay*)dpy)->request == 0) ? ( \
0291                 ((struct _XDisplay*)dpy)->request_upper32bit++ \
0292         ) : 0 \
0293         ), \
0294     (void)0 /* don't use the result */ \
0295     )
0296 
0297 
0298 #define X_DPY_REQUEST_DECREMENT(dpy) \
0299     ( \
0300     ( \
0301             (((struct _XDisplay*)dpy)->request == 0) ? (\
0302                 ((struct _XDisplay*)dpy)->request--, /* wrap */ \
0303                 ((struct _XDisplay*)dpy)->request_upper32bit-- \
0304             ) : ( \
0305                 ((struct _XDisplay*)dpy)->request-- \
0306             ) \
0307     ), \
0308     (void)0 /* don't use the result */ \
0309     )
0310 
0311 #else
0312 /* accessors for 64-bit unsigned long */
0313 #define X_DPY_GET_REQUEST(dpy) \
0314     (((struct _XDisplay*)dpy)->request)
0315 #define X_DPY_SET_REQUEST(dpy, value) \
0316     ((struct _XDisplay*)dpy)->request = (value)
0317 
0318 #define X_DPY_GET_LAST_REQUEST_READ(dpy) \
0319     (((struct _XDisplay*)dpy)->last_request_read)
0320 #define X_DPY_SET_LAST_REQUEST_READ(dpy, value) \
0321     ((struct _XDisplay*)dpy)->last_request_read = (value)
0322 
0323 #define X_DPY_WIDEN_UNSIGNED_LONG_SEQ(dpy, ulseq) ulseq
0324 
0325 #define X_DPY_REQUEST_INCREMENT(dpy) ((struct _XDisplay*)dpy)->request++
0326 #define X_DPY_REQUEST_DECREMENT(dpy) ((struct _XDisplay*)dpy)->request--
0327 #endif
0328 
0329 
0330 #ifndef _XEVENT_
0331 /*
0332  * _QEvent datatype for use in input queueing.
0333  */
0334 typedef struct _XSQEvent
0335 {
0336     struct _XSQEvent *next;
0337     XEvent event;
0338     unsigned long qserial_num;  /* so multi-threaded code can find new ones */
0339 } _XQEvent;
0340 #endif
0341 
0342 #include <X11/Xproto.h>
0343 #include <errno.h>
0344 #define _XBCOPYFUNC _Xbcopy
0345 #include <X11/Xfuncs.h>
0346 #include <X11/Xosdefs.h>
0347 
0348 /* Utek leaves kernel macros around in include files (bleah) */
0349 #ifdef dirty
0350 #undef dirty
0351 #endif
0352 
0353 #include <stdlib.h>
0354 #include <string.h>
0355 
0356 #include <X11/Xfuncproto.h>
0357 
0358 _XFUNCPROTOBEGIN
0359 
0360 /*
0361  * The following definitions can be used for locking requests in multi-threaded
0362  * address spaces.
0363  */
0364 #ifdef XTHREADS
0365 /* Author: Stephen Gildea, MIT X Consortium
0366  *
0367  * declarations for C Threads locking
0368  */
0369 
0370 typedef struct _LockInfoRec *LockInfoPtr;
0371 
0372 /* interfaces for locking.c */
0373 struct _XLockPtrs {
0374     /* used by all, including extensions; do not move */
0375     void (*lock_display)(
0376         Display *dpy
0377 #if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
0378         , char *file
0379         , int line
0380 #endif
0381     );
0382     void (*unlock_display)(
0383         Display *dpy
0384 #if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
0385         , char *file
0386         , int line
0387 #endif
0388     );
0389 };
0390 
0391 #if defined(WIN32) && !defined(_XLIBINT_)
0392 #define _XCreateMutex_fn (*_XCreateMutex_fn_p)
0393 #define _XFreeMutex_fn (*_XFreeMutex_fn_p)
0394 #define _XLockMutex_fn (*_XLockMutex_fn_p)
0395 #define _XUnlockMutex_fn (*_XUnlockMutex_fn_p)
0396 #define _Xglobal_lock (*_Xglobal_lock_p)
0397 #endif
0398 
0399 /* in XlibInt.c */
0400 extern void (*_XCreateMutex_fn)(
0401     LockInfoPtr /* lock */
0402 );
0403 extern void (*_XFreeMutex_fn)(
0404     LockInfoPtr /* lock */
0405 );
0406 extern void (*_XLockMutex_fn)(
0407     LockInfoPtr /* lock */
0408 #if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
0409     , char * /* file */
0410     , int /* line */
0411 #endif
0412 );
0413 extern void (*_XUnlockMutex_fn)(
0414     LockInfoPtr /* lock */
0415 #if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
0416     , char * /* file */
0417     , int /* line */
0418 #endif
0419 );
0420 
0421 extern LockInfoPtr _Xglobal_lock;
0422 
0423 #if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
0424 #define LockDisplay(d)       if ((d)->lock_fns) (*(d)->lock_fns->lock_display)((d),__FILE__,__LINE__)
0425 #define UnlockDisplay(d)     if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)((d),__FILE__,__LINE__)
0426 #define _XLockMutex(lock)       if (_XLockMutex_fn) (*_XLockMutex_fn)(lock,__FILE__,__LINE__)
0427 #define _XUnlockMutex(lock) if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock,__FILE__,__LINE__)
0428 #else
0429 /* used everywhere, so must be fast if not using threads */
0430 #define LockDisplay(d)       if ((d)->lock_fns) (*(d)->lock_fns->lock_display)(d)
0431 #define UnlockDisplay(d)     if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)(d)
0432 #define _XLockMutex(lock)       if (_XLockMutex_fn) (*_XLockMutex_fn)(lock)
0433 #define _XUnlockMutex(lock) if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock)
0434 #endif
0435 #define _XCreateMutex(lock) if (_XCreateMutex_fn) (*_XCreateMutex_fn)(lock)
0436 #define _XFreeMutex(lock)   if (_XFreeMutex_fn) (*_XFreeMutex_fn)(lock)
0437 
0438 #else /* XTHREADS */
0439 #define LockDisplay(dis)
0440 #define _XLockMutex(lock)
0441 #define _XUnlockMutex(lock)
0442 #define UnlockDisplay(dis)
0443 #define _XCreateMutex(lock)
0444 #define _XFreeMutex(lock)
0445 #endif
0446 
0447 #define Xfree(ptr) free((ptr))
0448 
0449 /*
0450  * Note that some machines do not return a valid pointer for malloc(0), in
0451  * which case we provide an alternate under the control of the
0452  * define MALLOC_0_RETURNS_NULL.  This is necessary because some
0453  * Xlib code expects malloc(0) to return a valid pointer to storage.
0454  */
0455 #if defined(MALLOC_0_RETURNS_NULL) || defined(__clang_analyzer__)
0456 
0457 # define Xmalloc(size) malloc((size_t)((size) == 0 ? 1 : (size)))
0458 # define Xrealloc(ptr, size) realloc((ptr), (size_t)((size) == 0 ? 1 : (size)))
0459 # define Xcalloc(nelem, elsize) calloc((size_t)((nelem) == 0 ? 1 : (nelem)), (size_t)(elsize))
0460 
0461 #else
0462 
0463 # define Xmalloc(size) malloc((size_t)(size))
0464 # define Xrealloc(ptr, size) realloc((ptr), (size_t)(size))
0465 # define Xcalloc(nelem, elsize) calloc((size_t)(nelem), (size_t)(elsize))
0466 
0467 #endif
0468 
0469 #include <stddef.h>
0470 
0471 #define LOCKED 1
0472 #define UNLOCKED 0
0473 
0474 #ifndef BUFSIZE
0475 #define BUFSIZE 2048            /* X output buffer size. */
0476 #endif
0477 #ifndef PTSPERBATCH
0478 #define PTSPERBATCH 1024        /* point batching */
0479 #endif
0480 #ifndef WLNSPERBATCH
0481 #define WLNSPERBATCH 50         /* wide line batching */
0482 #endif
0483 #ifndef ZLNSPERBATCH
0484 #define ZLNSPERBATCH 1024       /* thin line batching */
0485 #endif
0486 #ifndef WRCTSPERBATCH
0487 #define WRCTSPERBATCH 10        /* wide line rectangle batching */
0488 #endif
0489 #ifndef ZRCTSPERBATCH
0490 #define ZRCTSPERBATCH 256       /* thin line rectangle batching */
0491 #endif
0492 #ifndef FRCTSPERBATCH
0493 #define FRCTSPERBATCH 256       /* filled rectangle batching */
0494 #endif
0495 #ifndef FARCSPERBATCH
0496 #define FARCSPERBATCH 256       /* filled arc batching */
0497 #endif
0498 #ifndef CURSORFONT
0499 #define CURSORFONT "cursor"     /* standard cursor fonts */
0500 #endif
0501 
0502 /*
0503  * Display flags
0504  */
0505 #define XlibDisplayIOError  (1L << 0)
0506 #define XlibDisplayClosing  (1L << 1)
0507 #define XlibDisplayNoXkb    (1L << 2)
0508 #define XlibDisplayPrivSync (1L << 3)
0509 #define XlibDisplayProcConni    (1L << 4) /* in _XProcessInternalConnection */
0510 #define XlibDisplayReadEvents   (1L << 5) /* in _XReadEvents */
0511 #define XlibDisplayReply    (1L << 5) /* in _XReply */
0512 #define XlibDisplayWriting  (1L << 6) /* in _XFlushInt, _XSend */
0513 #define XlibDisplayDfltRMDB     (1L << 7) /* mark if RM db from XGetDefault */
0514 
0515 /*
0516  * X Protocol packetizing macros.
0517  */
0518 
0519 /* Leftover from CRAY support - was defined empty on all non-Cray systems */
0520 #define WORD64ALIGN
0521 
0522 /**
0523  * Return a len-sized request buffer for the request type. This function may
0524  * flush the output queue.
0525  *
0526  * @param dpy The display connection
0527  * @param type The request type
0528  * @param len Length of the request in bytes
0529  *
0530  * @returns A pointer to the request buffer with a few default values
0531  * initialized.
0532  */
0533 extern void *_XGetRequest(Display *dpy, CARD8 type, size_t len);
0534 
0535 /* GetReqSized is the same as GetReq but allows the caller to specify the
0536  * size in bytes. 'sz' must be a multiple of 4! */
0537 
0538 #define GetReqSized(name, sz, req) \
0539     req = (x##name##Req *) _XGetRequest(dpy, X_##name, sz)
0540 
0541 /*
0542  * GetReq - Get the next available X request packet in the buffer and
0543  * return it.
0544  *
0545  * "name" is the name of the request, e.g. CreatePixmap, OpenFont, etc.
0546  * "req" is the name of the request pointer.
0547  *
0548  */
0549 
0550 #define GetReq(name, req) \
0551     GetReqSized(name, SIZEOF(x##name##Req), req)
0552 
0553 /* GetReqExtra is the same as GetReq, but allocates "n" additional
0554    bytes after the request. "n" must be a multiple of 4!  */
0555 
0556 #define GetReqExtra(name, n, req) \
0557         GetReqSized(name, SIZEOF(x##name##Req) + n, req)
0558 
0559 /*
0560  * GetResReq is for those requests that have a resource ID
0561  * (Window, Pixmap, GContext, etc.) as their single argument.
0562  * "rid" is the name of the resource.
0563  */
0564 
0565 #define GetResReq(name, rid, req) \
0566     req = (xResourceReq *) _XGetRequest(dpy, X_##name, SIZEOF(xResourceReq)); \
0567     if (req) req->id = (rid)
0568 
0569 /*
0570  * GetEmptyReq is for those requests that have no arguments
0571  * at all.
0572  */
0573 
0574 #define GetEmptyReq(name, req) \
0575     req = (xReq *) _XGetRequest(dpy, X_##name, SIZEOF(xReq))
0576 
0577 /*
0578  * MakeBigReq sets the CARD16 "req->length" to 0 and inserts a new CARD32
0579  * length, after req->length, before the data in the request.  The new length
0580  * includes the "n" extra 32-bit words.
0581  *
0582  * Do not use MakeBigReq if there is no data already in the request.
0583  * req->length must already be >= 2.
0584  */
0585 #ifdef LONG64
0586 #define MakeBigReq(req,n) \
0587     { \
0588     CARD64 _BRdat; \
0589     CARD32 _BRlen = (CARD32) (req->length - 1); \
0590     req->length = 0; \
0591     _BRdat = ((CARD32 *)req)[_BRlen]; \
0592     memmove(((char *)req) + 8, ((char *)req) + 4, (_BRlen - 1) << 2); \
0593     ((CARD32 *)req)[1] = _BRlen + (CARD32) (n) + 2; \
0594     Data32(dpy, &_BRdat, 4); \
0595     }
0596 #else
0597 #define MakeBigReq(req,n) \
0598     { \
0599     CARD32 _BRdat; \
0600     CARD32 _BRlen = req->length - 1; \
0601     req->length = 0; \
0602     _BRdat = ((CARD32 *)req)[_BRlen]; \
0603     memmove(((char *)req) + 8, ((char *)req) + 4, (_BRlen - 1) << 2); \
0604     ((CARD32 *)req)[1] = _BRlen + (CARD32) (n) + 2; \
0605     Data32(dpy, &_BRdat, 4); \
0606     }
0607 #endif
0608 
0609 /*
0610  * SetReqLen increases the count of 32-bit words in the request by "n",
0611  * or by "badlen" if "n" is too large.
0612  *
0613  * Do not use SetReqLen if "req" does not already have data after the
0614  * xReq header.  req->length must already be >= 2.
0615  */
0616 #ifndef __clang_analyzer__
0617 #define SetReqLen(req,n,badlen) \
0618     if ((req->length + n) > (unsigned)65535) { \
0619     if (dpy->bigreq_size) { \
0620         MakeBigReq(req,n) \
0621     } else { \
0622         n = badlen; \
0623         req->length = (CARD16) (req->length + n); \
0624     } \
0625     } else \
0626     req->length = (CARD16) (req->length + n)
0627 #else
0628 #define SetReqLen(req,n,badlen) \
0629     req->length += n
0630 #endif
0631 
0632 #define SyncHandle() \
0633     if (dpy->synchandler) (*dpy->synchandler)(dpy)
0634 
0635 extern void _XFlushGCCache(Display *dpy, GC gc);
0636 #define FlushGC(dpy, gc) \
0637     if ((gc)->dirty) _XFlushGCCache((dpy), (gc))
0638 /*
0639  * Data - Place data in the buffer and pad the end to provide
0640  * 32 bit word alignment.  Transmit if the buffer fills.
0641  *
0642  * "dpy" is a pointer to a Display.
0643  * "data" is a pointer to a data buffer.
0644  * "len" is the length of the data buffer.
0645  */
0646 #ifndef DataRoutineIsProcedure
0647 #define Data(dpy, data, len) do {\
0648     if (dpy->bufptr + (len) <= dpy->bufmax) {\
0649         memcpy(dpy->bufptr, data, (size_t)(len));\
0650         dpy->bufptr += ((size_t)((len) + 3) & (size_t)~3);\
0651     } else\
0652         _XSend(dpy, (_Xconst char*)(data), (long)(len));\
0653 } while (0)
0654 #endif /* DataRoutineIsProcedure */
0655 
0656 
0657 /* Allocate bytes from the buffer.  No padding is done, so if
0658  * the length is not a multiple of 4, the caller must be
0659  * careful to leave the buffer aligned after sending the
0660  * current request.
0661  *
0662  * "type" is the type of the pointer being assigned to.
0663  * "ptr" is the pointer being assigned to.
0664  * "n" is the number of bytes to allocate.
0665  *
0666  * Example:
0667  *    xTextElt *elt;
0668  *    BufAlloc (xTextElt *, elt, nbytes)
0669  */
0670 
0671 #define BufAlloc(type, ptr, n) do {      \
0672     if (dpy->bufptr + (n) > dpy->bufmax) \
0673         _XFlush (dpy); \
0674     ptr = (type) dpy->bufptr; \
0675     memset(ptr, '\0', (size_t)(n)); \
0676     dpy->bufptr += (n); \
0677 } while (0)
0678 
0679 #define Data16(dpy, data, len) Data((dpy), (_Xconst char *)(data), (len))
0680 #define _XRead16Pad(dpy, data, len) _XReadPad((dpy), (char *)(data), (len))
0681 #define _XRead16(dpy, data, len) _XRead((dpy), (char *)(data), (len))
0682 #ifdef LONG64
0683 #define Data32(dpy, data, len) _XData32(dpy, (_Xconst long *)(data), (unsigned)(len))
0684 extern int _XData32(
0685          Display *dpy,
0686          _Xconst long *data,
0687          unsigned len
0688 );
0689 extern void _XRead32(
0690          Display *dpy,
0691          long *data,
0692          long len
0693 );
0694 #else
0695 #define Data32(dpy, data, len) Data((dpy), (_Xconst char *)(data), (long)(len))
0696 #define _XRead32(dpy, data, len) _XRead((dpy), (char *)(data), (len))
0697 #endif
0698 
0699 #define PackData16(dpy,data,len) Data16 (dpy, data, len)
0700 #define PackData32(dpy,data,len) Data32 (dpy, data, len)
0701 
0702 /* Xlib manual is bogus */
0703 #define PackData(dpy,data,len) PackData16 (dpy, data, len)
0704 
0705 #define min(a,b) (((a) < (b)) ? (a) : (b))
0706 #define max(a,b) (((a) > (b)) ? (a) : (b))
0707 
0708 #define CI_NONEXISTCHAR(cs) (((cs)->width == 0) && \
0709                  (((cs)->rbearing|(cs)->lbearing| \
0710                    (cs)->ascent|(cs)->descent) == 0))
0711 
0712 /*
0713  * CI_GET_CHAR_INFO_1D - return the charinfo struct for the indicated 8bit
0714  * character.  If the character is in the column and exists, then return the
0715  * appropriate metrics (note that fonts with common per-character metrics will
0716  * return min_bounds).  If none of these hold true, try again with the default
0717  * char.
0718  */
0719 #define CI_GET_CHAR_INFO_1D(fs,col,def,cs) \
0720 do { \
0721     cs = def; \
0722     if (col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \
0723     if (fs->per_char == NULL) { \
0724         cs = &fs->min_bounds; \
0725     } else { \
0726         cs = &fs->per_char[(col - fs->min_char_or_byte2)]; \
0727         if (CI_NONEXISTCHAR(cs)) cs = def; \
0728     } \
0729     } \
0730 } while (0)
0731 
0732 #define CI_GET_DEFAULT_INFO_1D(fs,cs) \
0733   CI_GET_CHAR_INFO_1D (fs, fs->default_char, NULL, cs)
0734 
0735 
0736 
0737 /*
0738  * CI_GET_CHAR_INFO_2D - return the charinfo struct for the indicated row and
0739  * column.  This is used for fonts that have more than row zero.
0740  */
0741 #define CI_GET_CHAR_INFO_2D(fs,row,col,def,cs) \
0742 do { \
0743     cs = def; \
0744     if (row >= fs->min_byte1 && row <= fs->max_byte1 && \
0745     col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \
0746     if (fs->per_char == NULL) { \
0747         cs = &fs->min_bounds; \
0748     } else { \
0749         cs = &fs->per_char[((row - fs->min_byte1) * \
0750                     (fs->max_char_or_byte2 - \
0751                  fs->min_char_or_byte2 + 1)) + \
0752                    (col - fs->min_char_or_byte2)]; \
0753         if (CI_NONEXISTCHAR(cs)) cs = def; \
0754         } \
0755     } \
0756 } while (0)
0757 
0758 #define CI_GET_DEFAULT_INFO_2D(fs,cs) \
0759 do { \
0760     unsigned int r = (fs->default_char >> 8); \
0761     unsigned int c = (fs->default_char & 0xff); \
0762     CI_GET_CHAR_INFO_2D (fs, r, c, NULL, cs); \
0763 } while (0)
0764 
0765 
0766 /* srcvar must be a variable for large architecture version */
0767 #define OneDataCard32(dpy,dstaddr,srcvar) \
0768     do { *(CARD32 *)(dstaddr) = (srcvar); } while (0)
0769 
0770 
0771 typedef struct _XInternalAsync {
0772     struct _XInternalAsync *next;
0773     /*
0774      * handler arguments:
0775      * rep is the generic reply that caused this handler
0776      * to be invoked.  It must also be passed to _XGetAsyncReply.
0777      * buf and len are opaque values that must be passed to
0778      * _XGetAsyncReply or _XGetAsyncData.
0779      * data is the closure stored in this struct.
0780      * The handler returns True iff it handled this reply.
0781      */
0782     Bool (*handler)(
0783             Display*    /* dpy */,
0784             xReply* /* rep */,
0785             char*   /* buf */,
0786             int     /* len */,
0787             XPointer    /* data */
0788             );
0789     XPointer data;
0790 } _XAsyncHandler;
0791 
0792 /*
0793  * This struct is part of the ABI and is defined by value
0794  * in user-code. This means that we cannot make
0795  * the sequence-numbers 64bit.
0796  */
0797 typedef struct _XAsyncEState {
0798     unsigned long min_sequence_number;
0799     unsigned long max_sequence_number;
0800     unsigned char error_code;
0801     unsigned char major_opcode;
0802     unsigned short minor_opcode;
0803     unsigned char last_error_received;
0804     int error_count;
0805 } _XAsyncErrorState;
0806 
0807 extern void _XDeqAsyncHandler(Display *dpy, _XAsyncHandler *handler);
0808 #define DeqAsyncHandler(dpy,handler) do { \
0809     if (dpy->async_handlers == (handler)) \
0810     dpy->async_handlers = (handler)->next; \
0811     else \
0812     _XDeqAsyncHandler(dpy, handler); \
0813     } while (0)
0814 
0815 typedef void (*FreeFuncType) (
0816     Display*    /* display */
0817 );
0818 
0819 typedef int (*FreeModmapType) (
0820     XModifierKeymap*    /* modmap */
0821 );
0822 
0823 /*
0824  * This structure is private to the library.
0825  */
0826 typedef struct _XFreeFuncs {
0827     FreeFuncType atoms;     /* _XFreeAtomTable */
0828     FreeModmapType modifiermap; /* XFreeModifiermap */
0829     FreeFuncType key_bindings;  /* _XFreeKeyBindings */
0830     FreeFuncType context_db;    /* _XFreeContextDB */
0831     FreeFuncType defaultCCCs;   /* _XcmsFreeDefaultCCCs */
0832     FreeFuncType clientCmaps;   /* _XcmsFreeClientCmaps */
0833     FreeFuncType intensityMaps; /* _XcmsFreeIntensityMaps */
0834     FreeFuncType im_filters;    /* _XFreeIMFilters */
0835     FreeFuncType xkb;       /* _XkbFreeInfo */
0836 } _XFreeFuncRec;
0837 
0838 /* types for InitExt.c */
0839 typedef int (*CreateGCType) (
0840     Display*    /* display */,
0841     GC      /* gc */,
0842     XExtCodes*  /* codes */
0843 );
0844 
0845 typedef int (*CopyGCType)(
0846     Display*    /* display */,
0847     GC      /* gc */,
0848     XExtCodes*  /* codes */
0849 );
0850 
0851 typedef int (*FlushGCType) (
0852     Display*    /* display */,
0853     GC      /* gc */,
0854     XExtCodes*  /* codes */
0855 );
0856 
0857 typedef int (*FreeGCType) (
0858     Display*    /* display */,
0859     GC      /* gc */,
0860     XExtCodes*  /* codes */
0861 );
0862 
0863 typedef int (*CreateFontType) (
0864     Display*    /* display */,
0865     XFontStruct* /* fs */,
0866     XExtCodes*  /* codes */
0867 );
0868 
0869 typedef int (*FreeFontType) (
0870     Display*    /* display */,
0871     XFontStruct* /* fs */,
0872     XExtCodes*  /* codes */
0873 );
0874 
0875 typedef int (*CloseDisplayType) (
0876     Display*    /* display */,
0877     XExtCodes*  /* codes */
0878 );
0879 
0880 typedef int (*ErrorType) (
0881     Display*    /* display */,
0882     xError* /* err */,
0883     XExtCodes*  /* codes */,
0884     int*    /* ret_code */
0885 );
0886 
0887 typedef char* (*ErrorStringType) (
0888     Display*    /* display */,
0889     int     /* code */,
0890     XExtCodes*  /* codes */,
0891     char*   /* buffer */,
0892     int     /* nbytes */
0893 );
0894 
0895 typedef void (*PrintErrorType)(
0896     Display*    /* display */,
0897     XErrorEvent* /* ev */,
0898     void*   /* fp */
0899 );
0900 
0901 typedef void (*BeforeFlushType)(
0902     Display*    /* display */,
0903     XExtCodes*  /* codes */,
0904     _Xconst char* /* data */,
0905     long    /* len */
0906 );
0907 
0908 /*
0909  * This structure is private to the library.
0910  */
0911 typedef struct _XExten {        /* private to extension mechanism */
0912     struct _XExten *next;       /* next in list */
0913     XExtCodes codes;        /* public information, all extension told */
0914     CreateGCType create_GC;     /* routine to call when GC created */
0915     CopyGCType copy_GC;     /* routine to call when GC copied */
0916     FlushGCType flush_GC;       /* routine to call when GC flushed */
0917     FreeGCType free_GC;     /* routine to call when GC freed */
0918     CreateFontType create_Font; /* routine to call when Font created */
0919     FreeFontType free_Font;     /* routine to call when Font freed */
0920     CloseDisplayType close_display; /* routine to call when connection closed */
0921     ErrorType error;        /* who to call when an error occurs */
0922     ErrorStringType error_string;   /* routine to supply error string */
0923     char *name;         /* name of this extension */
0924     PrintErrorType error_values;    /* routine to supply error values */
0925     BeforeFlushType before_flush;   /* routine to call when sending data */
0926     struct _XExten *next_flush; /* next in list of those with flushes */
0927 } _XExtension;
0928 
0929 /* extension hooks */
0930 
0931 #ifdef DataRoutineIsProcedure
0932 extern void Data(Display *dpy, char *data, long len);
0933 #endif
0934 extern int _XError(
0935     Display*    /* dpy */,
0936     xError* /* rep */
0937 );
0938 extern int _XIOError(
0939     Display*    /* dpy */
0940 );
0941 extern int (*_XIOErrorFunction)(
0942     Display*    /* dpy */
0943 );
0944 extern int (*_XErrorFunction)(
0945     Display*        /* dpy */,
0946     XErrorEvent*    /* error_event */
0947 );
0948 extern void _XEatData(
0949     Display*        /* dpy */,
0950     unsigned long   /* n */
0951 ) _X_COLD;
0952 extern void _XEatDataWords(
0953     Display*        /* dpy */,
0954     unsigned long   /* n */
0955 ) _X_COLD;
0956 #if defined(__SUNPRO_C) /* Studio compiler alternative to "cold" attribute */
0957 # pragma rarely_called(_XEatData, _XEatDataWords)
0958 #endif
0959 extern char *_XAllocScratch(
0960     Display*        /* dpy */,
0961     unsigned long   /* nbytes */
0962 );
0963 extern char *_XAllocTemp(
0964     Display*        /* dpy */,
0965     unsigned long   /* nbytes */
0966 );
0967 extern void _XFreeTemp(
0968     Display*        /* dpy */,
0969     char*       /* buf */,
0970     unsigned long   /* nbytes */
0971 );
0972 extern Visual *_XVIDtoVisual(
0973     Display*    /* dpy */,
0974     VisualID    /* id */
0975 );
0976 extern unsigned long _XSetLastRequestRead(
0977     Display*        /* dpy */,
0978     xGenericReply*  /* rep */
0979 );
0980 extern int _XGetHostname(
0981     char*   /* buf */,
0982     int     /* maxlen */
0983 );
0984 extern Screen *_XScreenOfWindow(
0985     Display*    /* dpy */,
0986     Window  /* w */
0987 );
0988 extern Bool _XAsyncErrorHandler(
0989     Display*    /* dpy */,
0990     xReply* /* rep */,
0991     char*   /* buf */,
0992     int     /* len */,
0993     XPointer    /* data */
0994 );
0995 extern char *_XGetAsyncReply(
0996     Display*    /* dpy */,
0997     char*   /* replbuf */,
0998     xReply* /* rep */,
0999     char*   /* buf */,
1000     int     /* len */,
1001     int     /* extra */,
1002     Bool    /* discard */
1003 );
1004 extern void _XGetAsyncData(
1005     Display*    /* dpy */,
1006     char *  /* data */,
1007     char *  /* buf */,
1008     int     /* len */,
1009     int     /* skip */,
1010     int     /* datalen */,
1011     int     /* discardtotal */
1012 );
1013 extern void _XFlush(
1014     Display*    /* dpy */
1015 );
1016 extern int _XEventsQueued(
1017     Display*    /* dpy */,
1018     int     /* mode */
1019 );
1020 extern void _XReadEvents(
1021     Display*    /* dpy */
1022 );
1023 extern int _XRead(
1024     Display*    /* dpy */,
1025     char*   /* data */,
1026     long    /* size */
1027 );
1028 extern void _XReadPad(
1029     Display*    /* dpy */,
1030     char*   /* data */,
1031     long    /* size */
1032 );
1033 extern void _XSend(
1034     Display*        /* dpy */,
1035     _Xconst char*   /* data */,
1036     long        /* size */
1037 );
1038 extern Status _XReply(
1039     Display*    /* dpy */,
1040     xReply* /* rep */,
1041     int     /* extra */,
1042     Bool    /* discard */
1043 );
1044 extern void _XEnq(
1045     Display*    /* dpy */,
1046     xEvent* /* event */
1047 );
1048 extern void _XDeq(
1049     Display*    /* dpy */,
1050     _XQEvent*   /* prev */,
1051     _XQEvent*   /* qelt */
1052 );
1053 
1054 extern Bool _XUnknownWireEvent(
1055     Display*    /* dpy */,
1056     XEvent* /* re */,
1057     xEvent* /* event */
1058 );
1059 
1060 extern Bool _XUnknownWireEventCookie(
1061     Display*    /* dpy */,
1062     XGenericEventCookie*    /* re */,
1063     xEvent* /* event */
1064 );
1065 
1066 extern Bool _XUnknownCopyEventCookie(
1067     Display*    /* dpy */,
1068     XGenericEventCookie*    /* in */,
1069     XGenericEventCookie*    /* out */
1070 );
1071 
1072 extern Status _XUnknownNativeEvent(
1073     Display*    /* dpy */,
1074     XEvent* /* re */,
1075     xEvent* /* event */
1076 );
1077 
1078 extern Bool _XWireToEvent(Display *dpy, XEvent *re, xEvent *event);
1079 extern Bool _XDefaultWireError(Display *display, XErrorEvent *he, xError *we);
1080 extern Bool _XPollfdCacheInit(Display *dpy);
1081 extern void _XPollfdCacheAdd(Display *dpy, int fd);
1082 extern void _XPollfdCacheDel(Display *dpy, int fd);
1083 extern XID _XAllocID(Display *dpy);
1084 extern void _XAllocIDs(Display *dpy, XID *ids, int count);
1085 
1086 extern int _XFreeExtData(
1087     XExtData*   /* extension */
1088 );
1089 
1090 extern int (*XESetCreateGC(
1091     Display*        /* display */,
1092     int         /* extension */,
1093     int (*) (
1094           Display*          /* display */,
1095           GC            /* gc */,
1096           XExtCodes*        /* codes */
1097         )       /* proc */
1098 ))(
1099     Display*, GC, XExtCodes*
1100 );
1101 
1102 extern int (*XESetCopyGC(
1103     Display*        /* display */,
1104     int         /* extension */,
1105     int (*) (
1106           Display*          /* display */,
1107               GC            /* gc */,
1108               XExtCodes*        /* codes */
1109             )       /* proc */
1110 ))(
1111     Display*, GC, XExtCodes*
1112 );
1113 
1114 extern int (*XESetFlushGC(
1115     Display*        /* display */,
1116     int         /* extension */,
1117     int (*) (
1118           Display*          /* display */,
1119               GC            /* gc */,
1120               XExtCodes*        /* codes */
1121             )       /* proc */
1122 ))(
1123     Display*, GC, XExtCodes*
1124 );
1125 
1126 extern int (*XESetFreeGC(
1127     Display*        /* display */,
1128     int         /* extension */,
1129     int (*) (
1130           Display*          /* display */,
1131               GC            /* gc */,
1132               XExtCodes*        /* codes */
1133             )       /* proc */
1134 ))(
1135     Display*, GC, XExtCodes*
1136 );
1137 
1138 extern int (*XESetCreateFont(
1139     Display*        /* display */,
1140     int         /* extension */,
1141     int (*) (
1142           Display*          /* display */,
1143               XFontStruct*      /* fs */,
1144               XExtCodes*        /* codes */
1145             )       /* proc */
1146 ))(
1147     Display*, XFontStruct*, XExtCodes*
1148 );
1149 
1150 extern int (*XESetFreeFont(
1151     Display*        /* display */,
1152     int         /* extension */,
1153     int (*) (
1154           Display*          /* display */,
1155               XFontStruct*      /* fs */,
1156               XExtCodes*        /* codes */
1157             )       /* proc */
1158 ))(
1159     Display*, XFontStruct*, XExtCodes*
1160 );
1161 
1162 extern int (*XESetCloseDisplay(
1163     Display*        /* display */,
1164     int         /* extension */,
1165     int (*) (
1166           Display*          /* display */,
1167               XExtCodes*        /* codes */
1168             )       /* proc */
1169 ))(
1170     Display*, XExtCodes*
1171 );
1172 
1173 extern int (*XESetError(
1174     Display*        /* display */,
1175     int         /* extension */,
1176     int (*) (
1177           Display*          /* display */,
1178               xError*           /* err */,
1179               XExtCodes*        /* codes */,
1180               int*          /* ret_code */
1181             )       /* proc */
1182 ))(
1183     Display*, xError*, XExtCodes*, int*
1184 );
1185 
1186 extern char* (*XESetErrorString(
1187     Display*        /* display */,
1188     int         /* extension */,
1189     char* (*) (
1190             Display*        /* display */,
1191                 int         /* code */,
1192                 XExtCodes*      /* codes */,
1193                 char*           /* buffer */,
1194                 int         /* nbytes */
1195               )     /* proc */
1196 ))(
1197     Display*, int, XExtCodes*, char*, int
1198 );
1199 
1200 extern void (*XESetPrintErrorValues (
1201     Display*        /* display */,
1202     int         /* extension */,
1203     void (*)(
1204           Display*          /* display */,
1205           XErrorEvent*      /* ev */,
1206           void*         /* fp */
1207          )      /* proc */
1208 ))(
1209     Display*, XErrorEvent*, void*
1210 );
1211 
1212 extern Bool (*XESetWireToEvent(
1213     Display*        /* display */,
1214     int         /* event_number */,
1215     Bool (*) (
1216            Display*         /* display */,
1217                XEvent*          /* re */,
1218                xEvent*          /* event */
1219              )      /* proc */
1220 ))(
1221     Display*, XEvent*, xEvent*
1222 );
1223 
1224 extern Bool (*XESetWireToEventCookie(
1225     Display*        /* display */,
1226     int         /* extension */,
1227     Bool (*) (
1228            Display*         /* display */,
1229                XGenericEventCookie* /* re */,
1230                xEvent*          /* event */
1231              )      /* proc */
1232 ))(
1233     Display*, XGenericEventCookie*, xEvent*
1234 );
1235 
1236 extern Bool (*XESetCopyEventCookie(
1237     Display*        /* display */,
1238     int         /* extension */,
1239     Bool (*) (
1240            Display*         /* display */,
1241                XGenericEventCookie* /* in */,
1242                XGenericEventCookie* /* out */
1243              )      /* proc */
1244 ))(
1245     Display*, XGenericEventCookie*, XGenericEventCookie*
1246 );
1247 
1248 
1249 extern Status (*XESetEventToWire(
1250     Display*        /* display */,
1251     int         /* event_number */,
1252     Status (*) (
1253           Display*          /* display */,
1254               XEvent*           /* re */,
1255               xEvent*           /* event */
1256             )       /* proc */
1257 ))(
1258     Display*, XEvent*, xEvent*
1259 );
1260 
1261 extern Bool (*XESetWireToError(
1262     Display*        /* display */,
1263     int         /* error_number */,
1264     Bool (*) (
1265            Display*         /* display */,
1266            XErrorEvent*     /* he */,
1267            xError*          /* we */
1268             )       /* proc */
1269 ))(
1270     Display*, XErrorEvent*, xError*
1271 );
1272 
1273 extern void (*XESetBeforeFlush(
1274     Display*        /* display */,
1275     int         /* error_number */,
1276     void (*) (
1277            Display*         /* display */,
1278            XExtCodes*       /* codes */,
1279            _Xconst char*        /* data */,
1280            long         /* len */
1281             )       /* proc */
1282 ))(
1283     Display*, XExtCodes*, _Xconst char*, long
1284 );
1285 
1286 /* internal connections for IMs */
1287 
1288 typedef void (*_XInternalConnectionProc)(
1289     Display*            /* dpy */,
1290     int             /* fd */,
1291     XPointer            /* call_data */
1292 );
1293 
1294 
1295 extern Status _XRegisterInternalConnection(
1296     Display*            /* dpy */,
1297     int             /* fd */,
1298     _XInternalConnectionProc    /* callback */,
1299     XPointer            /* call_data */
1300 );
1301 
1302 extern void _XUnregisterInternalConnection(
1303     Display*            /* dpy */,
1304     int             /* fd */
1305 );
1306 
1307 extern void _XProcessInternalConnection(
1308     Display*            /* dpy */,
1309     struct _XConnectionInfo*    /* conn_info */
1310 );
1311 
1312 /* Display structure has pointers to these */
1313 
1314 struct _XConnectionInfo {   /* info from _XRegisterInternalConnection */
1315     int fd;
1316     _XInternalConnectionProc read_callback;
1317     XPointer call_data;
1318     XPointer *watch_data;   /* set/used by XConnectionWatchProc */
1319     struct _XConnectionInfo *next;
1320 };
1321 
1322 struct _XConnWatchInfo {    /* info from XAddConnectionWatch */
1323     XConnectionWatchProc fn;
1324     XPointer client_data;
1325     struct _XConnWatchInfo *next;
1326 };
1327 
1328 extern int _XTextHeight(
1329     XFontStruct*    /* font_struct */,
1330     _Xconst char*   /* string */,
1331     int         /* count */
1332 );
1333 
1334 extern int _XTextHeight16(
1335     XFontStruct*    /* font_struct */,
1336     _Xconst XChar2b*    /* string */,
1337     int         /* count */
1338 );
1339 
1340 #if defined(WIN32)
1341 
1342 extern int _XOpenFile(
1343     _Xconst char*   /* path */,
1344     int         /* flags */
1345 );
1346 
1347 extern int _XOpenFileMode(
1348     _Xconst char*   /* path */,
1349     int         /* flags */,
1350     mode_t              /* mode */
1351 );
1352 
1353 extern void* _XFopenFile(
1354     _Xconst char*   /* path */,
1355     _Xconst char*   /* mode */
1356 );
1357 
1358 extern int _XAccessFile(
1359     _Xconst char*   /* path */
1360 );
1361 #else
1362 #define _XOpenFile(path,flags) open(path,flags)
1363 #define _XOpenFileMode(path,flags,mode) open(path,flags,mode)
1364 #define _XFopenFile(path,mode) fopen(path,mode)
1365 #endif
1366 
1367 /* EvToWire.c */
1368 extern Status _XEventToWire(Display *dpy, XEvent *re, xEvent *event);
1369 
1370 extern int _XF86LoadQueryLocaleFont(
1371     Display*        /* dpy */,
1372     _Xconst char*   /* name*/,
1373     XFontStruct**   /* xfp*/,
1374     Font*       /* fidp */
1375 );
1376 
1377 extern void _XProcessWindowAttributes (
1378     Display *dpy,
1379     xChangeWindowAttributesReq *req,
1380     unsigned long valuemask,
1381     XSetWindowAttributes *attributes);
1382 
1383 extern int _XDefaultError(
1384         Display *dpy,
1385         XErrorEvent *event);
1386 
1387 extern int _XDefaultIOError(
1388         Display *dpy);
1389 
1390 extern void _XDefaultIOErrorExit(
1391     Display *dpy,
1392     void *user_data);
1393 
1394 extern void _XSetClipRectangles (
1395     Display *dpy,
1396     GC gc,
1397     int clip_x_origin, int clip_y_origin,
1398     XRectangle *rectangles,
1399     int n,
1400     int ordering);
1401 
1402 Status _XGetWindowAttributes(
1403     Display *dpy,
1404     Window w,
1405     XWindowAttributes *attr);
1406 
1407 int _XPutBackEvent (
1408     Display *dpy,
1409     XEvent *event);
1410 
1411 extern Bool _XIsEventCookie(
1412         Display *dpy,
1413         XEvent *ev);
1414 
1415 extern void _XFreeEventCookies(
1416         Display *dpy);
1417 
1418 extern void _XStoreEventCookie(
1419         Display *dpy,
1420         XEvent *ev);
1421 
1422 extern Bool _XFetchEventCookie(
1423         Display *dpy,
1424         XGenericEventCookie *ev);
1425 
1426 extern Bool _XCopyEventCookie(
1427         Display *dpy,
1428         XGenericEventCookie *in,
1429         XGenericEventCookie *out);
1430 
1431 /* lcFile.c */
1432 
1433 extern void xlocaledir(
1434     char *buf,
1435     int buf_len
1436 );
1437 
1438 #ifdef __clang__
1439 #pragma clang diagnostic pop
1440 #endif
1441 
1442 _XFUNCPROTOEND
1443 
1444 #endif /* _X11_XLIBINT_H_ */