Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:14:34

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) {\
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 }
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) \
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 
0678 #define Data16(dpy, data, len) Data((dpy), (_Xconst char *)(data), (len))
0679 #define _XRead16Pad(dpy, data, len) _XReadPad((dpy), (char *)(data), (len))
0680 #define _XRead16(dpy, data, len) _XRead((dpy), (char *)(data), (len))
0681 #ifdef LONG64
0682 #define Data32(dpy, data, len) _XData32(dpy, (_Xconst long *)(data), (unsigned)(len))
0683 extern int _XData32(
0684          Display *dpy,
0685          _Xconst long *data,
0686          unsigned len
0687 );
0688 extern void _XRead32(
0689          Display *dpy,
0690          long *data,
0691          long len
0692 );
0693 #else
0694 #define Data32(dpy, data, len) Data((dpy), (_Xconst char *)(data), (long)(len))
0695 #define _XRead32(dpy, data, len) _XRead((dpy), (char *)(data), (len))
0696 #endif
0697 
0698 #define PackData16(dpy,data,len) Data16 (dpy, data, len)
0699 #define PackData32(dpy,data,len) Data32 (dpy, data, len)
0700 
0701 /* Xlib manual is bogus */
0702 #define PackData(dpy,data,len) PackData16 (dpy, data, len)
0703 
0704 #define min(a,b) (((a) < (b)) ? (a) : (b))
0705 #define max(a,b) (((a) > (b)) ? (a) : (b))
0706 
0707 #define CI_NONEXISTCHAR(cs) (((cs)->width == 0) && \
0708                  (((cs)->rbearing|(cs)->lbearing| \
0709                    (cs)->ascent|(cs)->descent) == 0))
0710 
0711 /*
0712  * CI_GET_CHAR_INFO_1D - return the charinfo struct for the indicated 8bit
0713  * character.  If the character is in the column and exists, then return the
0714  * appropriate metrics (note that fonts with common per-character metrics will
0715  * return min_bounds).  If none of these hold true, try again with the default
0716  * char.
0717  */
0718 #define CI_GET_CHAR_INFO_1D(fs,col,def,cs) \
0719 { \
0720     cs = def; \
0721     if (col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \
0722     if (fs->per_char == NULL) { \
0723         cs = &fs->min_bounds; \
0724     } else { \
0725         cs = &fs->per_char[(col - fs->min_char_or_byte2)]; \
0726         if (CI_NONEXISTCHAR(cs)) cs = def; \
0727     } \
0728     } \
0729 }
0730 
0731 #define CI_GET_DEFAULT_INFO_1D(fs,cs) \
0732   CI_GET_CHAR_INFO_1D (fs, fs->default_char, NULL, cs)
0733 
0734 
0735 
0736 /*
0737  * CI_GET_CHAR_INFO_2D - return the charinfo struct for the indicated row and
0738  * column.  This is used for fonts that have more than row zero.
0739  */
0740 #define CI_GET_CHAR_INFO_2D(fs,row,col,def,cs) \
0741 { \
0742     cs = def; \
0743     if (row >= fs->min_byte1 && row <= fs->max_byte1 && \
0744     col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \
0745     if (fs->per_char == NULL) { \
0746         cs = &fs->min_bounds; \
0747     } else { \
0748         cs = &fs->per_char[((row - fs->min_byte1) * \
0749                     (fs->max_char_or_byte2 - \
0750                  fs->min_char_or_byte2 + 1)) + \
0751                    (col - fs->min_char_or_byte2)]; \
0752         if (CI_NONEXISTCHAR(cs)) cs = def; \
0753         } \
0754     } \
0755 }
0756 
0757 #define CI_GET_DEFAULT_INFO_2D(fs,cs) \
0758 { \
0759     unsigned int r = (fs->default_char >> 8); \
0760     unsigned int c = (fs->default_char & 0xff); \
0761     CI_GET_CHAR_INFO_2D (fs, r, c, NULL, cs); \
0762 }
0763 
0764 
0765 /* srcvar must be a variable for large architecture version */
0766 #define OneDataCard32(dpy,dstaddr,srcvar) \
0767   { *(CARD32 *)(dstaddr) = (srcvar); }
0768 
0769 
0770 typedef struct _XInternalAsync {
0771     struct _XInternalAsync *next;
0772     /*
0773      * handler arguments:
0774      * rep is the generic reply that caused this handler
0775      * to be invoked.  It must also be passed to _XGetAsyncReply.
0776      * buf and len are opaque values that must be passed to
0777      * _XGetAsyncReply or _XGetAsyncData.
0778      * data is the closure stored in this struct.
0779      * The handler returns True iff it handled this reply.
0780      */
0781     Bool (*handler)(
0782             Display*    /* dpy */,
0783             xReply* /* rep */,
0784             char*   /* buf */,
0785             int     /* len */,
0786             XPointer    /* data */
0787             );
0788     XPointer data;
0789 } _XAsyncHandler;
0790 
0791 /*
0792  * This struct is part of the ABI and is defined by value
0793  * in user-code. This means that we cannot make
0794  * the sequence-numbers 64bit.
0795  */
0796 typedef struct _XAsyncEState {
0797     unsigned long min_sequence_number;
0798     unsigned long max_sequence_number;
0799     unsigned char error_code;
0800     unsigned char major_opcode;
0801     unsigned short minor_opcode;
0802     unsigned char last_error_received;
0803     int error_count;
0804 } _XAsyncErrorState;
0805 
0806 extern void _XDeqAsyncHandler(Display *dpy, _XAsyncHandler *handler);
0807 #define DeqAsyncHandler(dpy,handler) { \
0808     if (dpy->async_handlers == (handler)) \
0809     dpy->async_handlers = (handler)->next; \
0810     else \
0811     _XDeqAsyncHandler(dpy, handler); \
0812     }
0813 
0814 typedef void (*FreeFuncType) (
0815     Display*    /* display */
0816 );
0817 
0818 typedef int (*FreeModmapType) (
0819     XModifierKeymap*    /* modmap */
0820 );
0821 
0822 /*
0823  * This structure is private to the library.
0824  */
0825 typedef struct _XFreeFuncs {
0826     FreeFuncType atoms;     /* _XFreeAtomTable */
0827     FreeModmapType modifiermap; /* XFreeModifiermap */
0828     FreeFuncType key_bindings;  /* _XFreeKeyBindings */
0829     FreeFuncType context_db;    /* _XFreeContextDB */
0830     FreeFuncType defaultCCCs;   /* _XcmsFreeDefaultCCCs */
0831     FreeFuncType clientCmaps;   /* _XcmsFreeClientCmaps */
0832     FreeFuncType intensityMaps; /* _XcmsFreeIntensityMaps */
0833     FreeFuncType im_filters;    /* _XFreeIMFilters */
0834     FreeFuncType xkb;       /* _XkbFreeInfo */
0835 } _XFreeFuncRec;
0836 
0837 /* types for InitExt.c */
0838 typedef int (*CreateGCType) (
0839     Display*    /* display */,
0840     GC      /* gc */,
0841     XExtCodes*  /* codes */
0842 );
0843 
0844 typedef int (*CopyGCType)(
0845     Display*    /* display */,
0846     GC      /* gc */,
0847     XExtCodes*  /* codes */
0848 );
0849 
0850 typedef int (*FlushGCType) (
0851     Display*    /* display */,
0852     GC      /* gc */,
0853     XExtCodes*  /* codes */
0854 );
0855 
0856 typedef int (*FreeGCType) (
0857     Display*    /* display */,
0858     GC      /* gc */,
0859     XExtCodes*  /* codes */
0860 );
0861 
0862 typedef int (*CreateFontType) (
0863     Display*    /* display */,
0864     XFontStruct* /* fs */,
0865     XExtCodes*  /* codes */
0866 );
0867 
0868 typedef int (*FreeFontType) (
0869     Display*    /* display */,
0870     XFontStruct* /* fs */,
0871     XExtCodes*  /* codes */
0872 );
0873 
0874 typedef int (*CloseDisplayType) (
0875     Display*    /* display */,
0876     XExtCodes*  /* codes */
0877 );
0878 
0879 typedef int (*ErrorType) (
0880     Display*    /* display */,
0881     xError* /* err */,
0882     XExtCodes*  /* codes */,
0883     int*    /* ret_code */
0884 );
0885 
0886 typedef char* (*ErrorStringType) (
0887     Display*    /* display */,
0888     int     /* code */,
0889     XExtCodes*  /* codes */,
0890     char*   /* buffer */,
0891     int     /* nbytes */
0892 );
0893 
0894 typedef void (*PrintErrorType)(
0895     Display*    /* display */,
0896     XErrorEvent* /* ev */,
0897     void*   /* fp */
0898 );
0899 
0900 typedef void (*BeforeFlushType)(
0901     Display*    /* display */,
0902     XExtCodes*  /* codes */,
0903     _Xconst char* /* data */,
0904     long    /* len */
0905 );
0906 
0907 /*
0908  * This structure is private to the library.
0909  */
0910 typedef struct _XExten {        /* private to extension mechanism */
0911     struct _XExten *next;       /* next in list */
0912     XExtCodes codes;        /* public information, all extension told */
0913     CreateGCType create_GC;     /* routine to call when GC created */
0914     CopyGCType copy_GC;     /* routine to call when GC copied */
0915     FlushGCType flush_GC;       /* routine to call when GC flushed */
0916     FreeGCType free_GC;     /* routine to call when GC freed */
0917     CreateFontType create_Font; /* routine to call when Font created */
0918     FreeFontType free_Font;     /* routine to call when Font freed */
0919     CloseDisplayType close_display; /* routine to call when connection closed */
0920     ErrorType error;        /* who to call when an error occurs */
0921     ErrorStringType error_string;   /* routine to supply error string */
0922     char *name;         /* name of this extension */
0923     PrintErrorType error_values;    /* routine to supply error values */
0924     BeforeFlushType before_flush;   /* routine to call when sending data */
0925     struct _XExten *next_flush; /* next in list of those with flushes */
0926 } _XExtension;
0927 
0928 /* extension hooks */
0929 
0930 #ifdef DataRoutineIsProcedure
0931 extern void Data(Display *dpy, char *data, long len);
0932 #endif
0933 extern int _XError(
0934     Display*    /* dpy */,
0935     xError* /* rep */
0936 );
0937 extern int _XIOError(
0938     Display*    /* dpy */
0939 );
0940 extern int (*_XIOErrorFunction)(
0941     Display*    /* dpy */
0942 );
0943 extern int (*_XErrorFunction)(
0944     Display*        /* dpy */,
0945     XErrorEvent*    /* error_event */
0946 );
0947 extern void _XEatData(
0948     Display*        /* dpy */,
0949     unsigned long   /* n */
0950 ) _X_COLD;
0951 extern void _XEatDataWords(
0952     Display*        /* dpy */,
0953     unsigned long   /* n */
0954 ) _X_COLD;
0955 #if defined(__SUNPRO_C) /* Studio compiler alternative to "cold" attribute */
0956 # pragma rarely_called(_XEatData, _XEatDataWords)
0957 #endif
0958 extern char *_XAllocScratch(
0959     Display*        /* dpy */,
0960     unsigned long   /* nbytes */
0961 );
0962 extern char *_XAllocTemp(
0963     Display*        /* dpy */,
0964     unsigned long   /* nbytes */
0965 );
0966 extern void _XFreeTemp(
0967     Display*        /* dpy */,
0968     char*       /* buf */,
0969     unsigned long   /* nbytes */
0970 );
0971 extern Visual *_XVIDtoVisual(
0972     Display*    /* dpy */,
0973     VisualID    /* id */
0974 );
0975 extern unsigned long _XSetLastRequestRead(
0976     Display*        /* dpy */,
0977     xGenericReply*  /* rep */
0978 );
0979 extern int _XGetHostname(
0980     char*   /* buf */,
0981     int     /* maxlen */
0982 );
0983 extern Screen *_XScreenOfWindow(
0984     Display*    /* dpy */,
0985     Window  /* w */
0986 );
0987 extern Bool _XAsyncErrorHandler(
0988     Display*    /* dpy */,
0989     xReply* /* rep */,
0990     char*   /* buf */,
0991     int     /* len */,
0992     XPointer    /* data */
0993 );
0994 extern char *_XGetAsyncReply(
0995     Display*    /* dpy */,
0996     char*   /* replbuf */,
0997     xReply* /* rep */,
0998     char*   /* buf */,
0999     int     /* len */,
1000     int     /* extra */,
1001     Bool    /* discard */
1002 );
1003 extern void _XGetAsyncData(
1004     Display*    /* dpy */,
1005     char *  /* data */,
1006     char *  /* buf */,
1007     int     /* len */,
1008     int     /* skip */,
1009     int     /* datalen */,
1010     int     /* discardtotal */
1011 );
1012 extern void _XFlush(
1013     Display*    /* dpy */
1014 );
1015 extern int _XEventsQueued(
1016     Display*    /* dpy */,
1017     int     /* mode */
1018 );
1019 extern void _XReadEvents(
1020     Display*    /* dpy */
1021 );
1022 extern int _XRead(
1023     Display*    /* dpy */,
1024     char*   /* data */,
1025     long    /* size */
1026 );
1027 extern void _XReadPad(
1028     Display*    /* dpy */,
1029     char*   /* data */,
1030     long    /* size */
1031 );
1032 extern void _XSend(
1033     Display*        /* dpy */,
1034     _Xconst char*   /* data */,
1035     long        /* size */
1036 );
1037 extern Status _XReply(
1038     Display*    /* dpy */,
1039     xReply* /* rep */,
1040     int     /* extra */,
1041     Bool    /* discard */
1042 );
1043 extern void _XEnq(
1044     Display*    /* dpy */,
1045     xEvent* /* event */
1046 );
1047 extern void _XDeq(
1048     Display*    /* dpy */,
1049     _XQEvent*   /* prev */,
1050     _XQEvent*   /* qelt */
1051 );
1052 
1053 extern Bool _XUnknownWireEvent(
1054     Display*    /* dpy */,
1055     XEvent* /* re */,
1056     xEvent* /* event */
1057 );
1058 
1059 extern Bool _XUnknownWireEventCookie(
1060     Display*    /* dpy */,
1061     XGenericEventCookie*    /* re */,
1062     xEvent* /* event */
1063 );
1064 
1065 extern Bool _XUnknownCopyEventCookie(
1066     Display*    /* dpy */,
1067     XGenericEventCookie*    /* in */,
1068     XGenericEventCookie*    /* out */
1069 );
1070 
1071 extern Status _XUnknownNativeEvent(
1072     Display*    /* dpy */,
1073     XEvent* /* re */,
1074     xEvent* /* event */
1075 );
1076 
1077 extern Bool _XWireToEvent(Display *dpy, XEvent *re, xEvent *event);
1078 extern Bool _XDefaultWireError(Display *display, XErrorEvent *he, xError *we);
1079 extern Bool _XPollfdCacheInit(Display *dpy);
1080 extern void _XPollfdCacheAdd(Display *dpy, int fd);
1081 extern void _XPollfdCacheDel(Display *dpy, int fd);
1082 extern XID _XAllocID(Display *dpy);
1083 extern void _XAllocIDs(Display *dpy, XID *ids, int count);
1084 
1085 extern int _XFreeExtData(
1086     XExtData*   /* extension */
1087 );
1088 
1089 extern int (*XESetCreateGC(
1090     Display*        /* display */,
1091     int         /* extension */,
1092     int (*) (
1093           Display*          /* display */,
1094           GC            /* gc */,
1095           XExtCodes*        /* codes */
1096         )       /* proc */
1097 ))(
1098     Display*, GC, XExtCodes*
1099 );
1100 
1101 extern int (*XESetCopyGC(
1102     Display*        /* display */,
1103     int         /* extension */,
1104     int (*) (
1105           Display*          /* display */,
1106               GC            /* gc */,
1107               XExtCodes*        /* codes */
1108             )       /* proc */
1109 ))(
1110     Display*, GC, XExtCodes*
1111 );
1112 
1113 extern int (*XESetFlushGC(
1114     Display*        /* display */,
1115     int         /* extension */,
1116     int (*) (
1117           Display*          /* display */,
1118               GC            /* gc */,
1119               XExtCodes*        /* codes */
1120             )       /* proc */
1121 ))(
1122     Display*, GC, XExtCodes*
1123 );
1124 
1125 extern int (*XESetFreeGC(
1126     Display*        /* display */,
1127     int         /* extension */,
1128     int (*) (
1129           Display*          /* display */,
1130               GC            /* gc */,
1131               XExtCodes*        /* codes */
1132             )       /* proc */
1133 ))(
1134     Display*, GC, XExtCodes*
1135 );
1136 
1137 extern int (*XESetCreateFont(
1138     Display*        /* display */,
1139     int         /* extension */,
1140     int (*) (
1141           Display*          /* display */,
1142               XFontStruct*      /* fs */,
1143               XExtCodes*        /* codes */
1144             )       /* proc */
1145 ))(
1146     Display*, XFontStruct*, XExtCodes*
1147 );
1148 
1149 extern int (*XESetFreeFont(
1150     Display*        /* display */,
1151     int         /* extension */,
1152     int (*) (
1153           Display*          /* display */,
1154               XFontStruct*      /* fs */,
1155               XExtCodes*        /* codes */
1156             )       /* proc */
1157 ))(
1158     Display*, XFontStruct*, XExtCodes*
1159 );
1160 
1161 extern int (*XESetCloseDisplay(
1162     Display*        /* display */,
1163     int         /* extension */,
1164     int (*) (
1165           Display*          /* display */,
1166               XExtCodes*        /* codes */
1167             )       /* proc */
1168 ))(
1169     Display*, XExtCodes*
1170 );
1171 
1172 extern int (*XESetError(
1173     Display*        /* display */,
1174     int         /* extension */,
1175     int (*) (
1176           Display*          /* display */,
1177               xError*           /* err */,
1178               XExtCodes*        /* codes */,
1179               int*          /* ret_code */
1180             )       /* proc */
1181 ))(
1182     Display*, xError*, XExtCodes*, int*
1183 );
1184 
1185 extern char* (*XESetErrorString(
1186     Display*        /* display */,
1187     int         /* extension */,
1188     char* (*) (
1189             Display*        /* display */,
1190                 int         /* code */,
1191                 XExtCodes*      /* codes */,
1192                 char*           /* buffer */,
1193                 int         /* nbytes */
1194               )     /* proc */
1195 ))(
1196     Display*, int, XExtCodes*, char*, int
1197 );
1198 
1199 extern void (*XESetPrintErrorValues (
1200     Display*        /* display */,
1201     int         /* extension */,
1202     void (*)(
1203           Display*          /* display */,
1204           XErrorEvent*      /* ev */,
1205           void*         /* fp */
1206          )      /* proc */
1207 ))(
1208     Display*, XErrorEvent*, void*
1209 );
1210 
1211 extern Bool (*XESetWireToEvent(
1212     Display*        /* display */,
1213     int         /* event_number */,
1214     Bool (*) (
1215            Display*         /* display */,
1216                XEvent*          /* re */,
1217                xEvent*          /* event */
1218              )      /* proc */
1219 ))(
1220     Display*, XEvent*, xEvent*
1221 );
1222 
1223 extern Bool (*XESetWireToEventCookie(
1224     Display*        /* display */,
1225     int         /* extension */,
1226     Bool (*) (
1227            Display*         /* display */,
1228                XGenericEventCookie* /* re */,
1229                xEvent*          /* event */
1230              )      /* proc */
1231 ))(
1232     Display*, XGenericEventCookie*, xEvent*
1233 );
1234 
1235 extern Bool (*XESetCopyEventCookie(
1236     Display*        /* display */,
1237     int         /* extension */,
1238     Bool (*) (
1239            Display*         /* display */,
1240                XGenericEventCookie* /* in */,
1241                XGenericEventCookie* /* out */
1242              )      /* proc */
1243 ))(
1244     Display*, XGenericEventCookie*, XGenericEventCookie*
1245 );
1246 
1247 
1248 extern Status (*XESetEventToWire(
1249     Display*        /* display */,
1250     int         /* event_number */,
1251     Status (*) (
1252           Display*          /* display */,
1253               XEvent*           /* re */,
1254               xEvent*           /* event */
1255             )       /* proc */
1256 ))(
1257     Display*, XEvent*, xEvent*
1258 );
1259 
1260 extern Bool (*XESetWireToError(
1261     Display*        /* display */,
1262     int         /* error_number */,
1263     Bool (*) (
1264            Display*         /* display */,
1265            XErrorEvent*     /* he */,
1266            xError*          /* we */
1267             )       /* proc */
1268 ))(
1269     Display*, XErrorEvent*, xError*
1270 );
1271 
1272 extern void (*XESetBeforeFlush(
1273     Display*        /* display */,
1274     int         /* error_number */,
1275     void (*) (
1276            Display*         /* display */,
1277            XExtCodes*       /* codes */,
1278            _Xconst char*        /* data */,
1279            long         /* len */
1280             )       /* proc */
1281 ))(
1282     Display*, XExtCodes*, _Xconst char*, long
1283 );
1284 
1285 /* internal connections for IMs */
1286 
1287 typedef void (*_XInternalConnectionProc)(
1288     Display*            /* dpy */,
1289     int             /* fd */,
1290     XPointer            /* call_data */
1291 );
1292 
1293 
1294 extern Status _XRegisterInternalConnection(
1295     Display*            /* dpy */,
1296     int             /* fd */,
1297     _XInternalConnectionProc    /* callback */,
1298     XPointer            /* call_data */
1299 );
1300 
1301 extern void _XUnregisterInternalConnection(
1302     Display*            /* dpy */,
1303     int             /* fd */
1304 );
1305 
1306 extern void _XProcessInternalConnection(
1307     Display*            /* dpy */,
1308     struct _XConnectionInfo*    /* conn_info */
1309 );
1310 
1311 /* Display structure has pointers to these */
1312 
1313 struct _XConnectionInfo {   /* info from _XRegisterInternalConnection */
1314     int fd;
1315     _XInternalConnectionProc read_callback;
1316     XPointer call_data;
1317     XPointer *watch_data;   /* set/used by XConnectionWatchProc */
1318     struct _XConnectionInfo *next;
1319 };
1320 
1321 struct _XConnWatchInfo {    /* info from XAddConnectionWatch */
1322     XConnectionWatchProc fn;
1323     XPointer client_data;
1324     struct _XConnWatchInfo *next;
1325 };
1326 
1327 extern int _XTextHeight(
1328     XFontStruct*    /* font_struct */,
1329     _Xconst char*   /* string */,
1330     int         /* count */
1331 );
1332 
1333 extern int _XTextHeight16(
1334     XFontStruct*    /* font_struct */,
1335     _Xconst XChar2b*    /* string */,
1336     int         /* count */
1337 );
1338 
1339 #if defined(WIN32)
1340 
1341 extern int _XOpenFile(
1342     _Xconst char*   /* path */,
1343     int         /* flags */
1344 );
1345 
1346 extern int _XOpenFileMode(
1347     _Xconst char*   /* path */,
1348     int         /* flags */,
1349     mode_t              /* mode */
1350 );
1351 
1352 extern void* _XFopenFile(
1353     _Xconst char*   /* path */,
1354     _Xconst char*   /* mode */
1355 );
1356 
1357 extern int _XAccessFile(
1358     _Xconst char*   /* path */
1359 );
1360 #else
1361 #define _XOpenFile(path,flags) open(path,flags)
1362 #define _XOpenFileMode(path,flags,mode) open(path,flags,mode)
1363 #define _XFopenFile(path,mode) fopen(path,mode)
1364 #endif
1365 
1366 /* EvToWire.c */
1367 extern Status _XEventToWire(Display *dpy, XEvent *re, xEvent *event);
1368 
1369 extern int _XF86LoadQueryLocaleFont(
1370     Display*        /* dpy */,
1371     _Xconst char*   /* name*/,
1372     XFontStruct**   /* xfp*/,
1373     Font*       /* fidp */
1374 );
1375 
1376 extern void _XProcessWindowAttributes (
1377     Display *dpy,
1378     xChangeWindowAttributesReq *req,
1379     unsigned long valuemask,
1380     XSetWindowAttributes *attributes);
1381 
1382 extern int _XDefaultError(
1383         Display *dpy,
1384         XErrorEvent *event);
1385 
1386 extern int _XDefaultIOError(
1387         Display *dpy);
1388 
1389 extern void _XDefaultIOErrorExit(
1390     Display *dpy,
1391     void *user_data);
1392 
1393 extern void _XSetClipRectangles (
1394     Display *dpy,
1395     GC gc,
1396     int clip_x_origin, int clip_y_origin,
1397     XRectangle *rectangles,
1398     int n,
1399     int ordering);
1400 
1401 Status _XGetWindowAttributes(
1402     Display *dpy,
1403     Window w,
1404     XWindowAttributes *attr);
1405 
1406 int _XPutBackEvent (
1407     Display *dpy,
1408     XEvent *event);
1409 
1410 extern Bool _XIsEventCookie(
1411         Display *dpy,
1412         XEvent *ev);
1413 
1414 extern void _XFreeEventCookies(
1415         Display *dpy);
1416 
1417 extern void _XStoreEventCookie(
1418         Display *dpy,
1419         XEvent *ev);
1420 
1421 extern Bool _XFetchEventCookie(
1422         Display *dpy,
1423         XGenericEventCookie *ev);
1424 
1425 extern Bool _XCopyEventCookie(
1426         Display *dpy,
1427         XGenericEventCookie *in,
1428         XGenericEventCookie *out);
1429 
1430 /* lcFile.c */
1431 
1432 extern void xlocaledir(
1433     char *buf,
1434     int buf_len
1435 );
1436 
1437 #ifdef __clang__
1438 #pragma clang diagnostic pop
1439 #endif
1440 
1441 _XFUNCPROTOEND
1442 
1443 #endif /* _X11_XLIBINT_H_ */