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