Annotation of researchv9/X11/src/X.V11R1/lib/X/Xlibint.h, revision 1.1.1.2

1.1       root        1: #include "copyright.h"
                      2: 
                      3: /* $Header: Xlibint.h,v 11.40 87/06/24 11:32:42 swick Exp $ */
                      4: /* Copyright 1984, 1985, 1987  Massachusetts Institute of Technology */
                      5: 
                      6: /*
                      7:  *     XlibInternal.h - Header definition and support file for the internal
                      8:  *     support routines (XlibInternal) used by the C subroutine interface
                      9:  *     library (Xlib) to the X Window System.
                     10:  *
                     11:  */
                     12: #ifndef NEED_EVENTS
                     13: #define _XEVENT_
                     14: #endif
                     15: #include <sys/types.h>
                     16: #include <X11/Xlib.h>
                     17: #include <X11/Xproto.h>
                     18: #include "Xlibos.h"
                     19: #include <errno.h>
                     20: 
                     21: #ifndef NULL
                     22: #define NULL 0
                     23: #endif
                     24: #define LOCKED 1
                     25: #define UNLOCKED 0
                     26: 
                     27: extern int errno;                      /* Internal system error number. */
                     28: extern void bcopy();
                     29: 
                     30: extern (*_XIOErrorFunction)();         /* X system error reporting routine. */
                     31: extern (*_XErrorFunction)();           /* X_Error event reporting routine. */
                     32: extern char *_XAllocScratch();         /* fast memory allocator */
                     33: extern Visual *_XVIDtoVisual();                /* given visual id, find structure */
                     34: 
1.1.1.2 ! root       35: #undef BUFSIZE
1.1       root       36: #define BUFSIZE 2048                   /* X output buffer size. */
                     37: #define EPERBATCH 8                    /* when batching, how many elements */
                     38: #define CURSORFONT "cursor"            /* standard cursor fonts */
                     39: 
                     40: /*
                     41:  * X Protocol packetizing macros.
                     42:  */
                     43: 
                     44: 
                     45: /*
                     46:  * GetReq - Get the next avilable X request packet in the buffer and
                     47:  * return it. 
                     48:  *
                     49:  * "name" is the name of the request, e.g. CreatePixmap, OpenFont, etc.
                     50:  * "req" is the name of the request pointer.
                     51:  *
                     52:  */
                     53: 
                     54: #define GetReq(name, req) \
                     55:        if ((dpy->bufptr + sizeof(x/**/name/**/Req)) > dpy->bufmax)\
                     56:                _XFlush(dpy);\
                     57:        req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
                     58:        req->reqType = X_/**/name;\
                     59:        req->length = (sizeof(x/**/name/**/Req))>>2;\
                     60:        dpy->bufptr += sizeof(x/**/name/**/Req);\
                     61:        dpy->request++
                     62: 
                     63: /* GetReqExtra is the same as GetReq, but allocates "n" additional
                     64:    bytes after the request. "n" must be a multiple of 4!  */
                     65: 
                     66: 
                     67: #define GetReqExtra(name, n, req) \
                     68:        if ((dpy->bufptr + sizeof(x/**/name/**/Req) + n) > dpy->bufmax)\
                     69:                _XFlush(dpy);\
                     70:        req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
                     71:        req->reqType = X_/**/name;\
                     72:        req->length = (sizeof(x/**/name/**/Req) + n)>>2;\
                     73:        dpy->bufptr += sizeof(x/**/name/**/Req) + n;\
                     74:        dpy->request++
                     75: 
                     76: /*
                     77:  * GetResReq is for those requests that have a resource ID 
                     78:  * (Window, Pixmap, GContext, etc.) as their single argument.
                     79:  * "rid" is the name of the resource. 
                     80:  */
                     81: 
                     82: #define GetResReq(name, rid, req) \
                     83:        if ((dpy->bufptr + sizeof(xResourceReq)) > dpy->bufmax)\
                     84:            _XFlush(dpy);\
                     85:        req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\
                     86:        req->reqType = X_/**/name;\
                     87:        req->length = 2;\
                     88:        req->id = (rid);\
                     89:        dpy->bufptr += sizeof(xResourceReq);\
                     90:        dpy->request++
                     91: 
                     92: /*
                     93:  * GetEmptyReq is for those requests that have no arguments
                     94:  * at all. 
                     95:  */
                     96: 
                     97: #define GetEmptyReq(name, req) \
                     98:        if ((dpy->bufptr + sizeof(xReq)) > dpy->bufmax)\
                     99:            _XFlush(dpy);\
                    100:        req = (xReq *) (dpy->last_req = dpy->bufptr);\
                    101:        req->reqType = X_/**/name;\
                    102:        req->length = 1;\
                    103:        dpy->bufptr += sizeof(xReq);\
                    104:        dpy->request++
                    105: 
                    106: #define SyncHandle() \
                    107:        if (dpy->synchandler) (*dpy->synchandler)(dpy)
                    108: 
                    109: #define FlushGC(dpy, gc) \
                    110:        if ((gc)->dirty) _XFlushGCCache((dpy), (gc))
                    111: /*
                    112:  * Data - Place data in the buffer and pad the end to provide
                    113:  * 32 bit word alignment.  Transmit if the buffer fills.
                    114:  *
                    115:  * "dpy" is a pointer to a Display.
                    116:  * "data" is a pinter to a data buffer.
                    117:  * "len" is the length of the data buffer.
                    118:  * we can presume buffer less than 2^16 bytes, so bcopy can be used safely.
                    119:  */
                    120: #define Data(dpy, data, len) \
                    121:        if (dpy->bufptr + (len) <= dpy->bufmax) {\
                    122:                bcopy(data, dpy->bufptr, (int)len);\
                    123:                dpy->bufptr += ((len) + 3) & ~3;\
                    124:        } else\
                    125:                _XSend(dpy, data, len)
                    126: 
                    127: 
                    128: /* Allocate bytes from the buffer.  No padding is done, so if
                    129:  * the length is not a multiple of 4, the caller must be
                    130:  * careful to leave the buffer aligned after sending the
                    131:  * current request.
                    132:  *
                    133:  * "type" is the type of the pointer being assigned to.
                    134:  * "ptr" is the pointer being assigned to.
                    135:  * "n" is the number of bytes to allocate.
                    136:  *
                    137:  * Example: 
                    138:  *    xTextElt *elt;
                    139:  *    BufAlloc (xTextElt *, elt, nbytes)
                    140:  */
                    141: 
                    142: #define BufAlloc(type, ptr, n) \
                    143:     if (dpy->bufptr + (n) > dpy->bufmax) \
                    144:         _XFlush (dpy); \
                    145:     ptr = (type) dpy->bufptr; \
                    146:     dpy->bufptr += (n);
                    147: 
                    148: #ifndef BIGSHORTS
                    149: #define PackData(dpy, data, len) Data(dpy, data, len)
                    150: #define PackShorts(f, t, n)  bcopy(f, t, n)
                    151: #endif
                    152: 
                    153: #define min(a,b) (((a) < (b)) ? (a) : (b))
                    154: #define max(a,b) (((a) > (b)) ? (a) : (b))
                    155: 
                    156: #define        CI_NONEXISTCHAR 0x4000  /* required because QueryFont represents
                    157:                                   a non-existant character with zero-value
                    158:                                   metrics, but requires drivers to output
                    159:                                   the default char in their place. */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.