~ubuntu-branches/ubuntu/gutsy/vnc4/gutsy

« back to all changes in this revision

Viewing changes to unix/xc/lib/X11/Xlibint.h

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2006-05-15 20:35:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060515203517-l4lre1ku942mn26k
Tags: 4.1.1+X4.3.0-10
* Correction of critical security issue. Thanks to Martin Kogler
  <e9925248@student.tuwien.ac.at> that informed me about the issue,
  and provided the patch.
  This flaw was originally found by Steve Wiseman of intelliadmin.com.
* Applied patch from Javier Kohen <jkohen@users.sourceforge.net> that
  inform the user that only 8 first characters of the password will
  actually be used when typing more than 8 characters, closes:
  #355619.

Show diffs side-by-side

added added

removed removed

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