1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302
|
/*
* cslibint.h -- low level I/O
*
* (c) Copyright 1993-1994 Adobe Systems Incorporated.
* All rights reserved.
*
* Permission to use, copy, modify, distribute, and sublicense this software
* and its documentation for any purpose and without fee is hereby granted,
* provided that the above copyright notices appear in all copies and that
* both those copyright notices and this permission notice appear in
* supporting documentation and that the name of Adobe Systems Incorporated
* not be used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission. No trademark license
* to use the Adobe trademarks is hereby granted. If the Adobe trademark
* "Display PostScript"(tm) is used to describe this software, its
* functionality or for any other purpose, such use shall be limited to a
* statement that this software works in conjunction with the Display
* PostScript system. Proper trademark attribution to reflect Adobe's
* ownership of the trademark shall be given whenever any such reference to
* the Display PostScript system is made.
*
* ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
* ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
* ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
* TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
* PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
*
* Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
* Incorporated which may be registered in certain jurisdictions
*
* Portions Copyright 1984, 1985, 1987, 1989 Massachusetts Institute of
* Technology
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. M.I.T. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* Author: Adobe Systems Incorporated and MIT X Consortium
*/
/* $XFree86: xc/lib/dps/cslibint.h,v 1.4 2001/07/25 15:04:54 dawes Exp $ */
/*
* XlibInternal.h - Header definition and support file for the internal
* support routines (XlibInternal) used by the C subroutine interface
* library (Xlib) to the X Window System.
*
* Warning, there be dragons here....
*/
#ifndef _CSLIBINT_H
#define _CSLIBINT_H
#include <X11/Xlibint.h>
#include <X11/Xutil.h>
/* For SYSV, no gethostname, so fake it */
#include <sys/param.h>
#if defined(SCO) || defined(SCO325)
/* SCO systems define MAXHOSTNAMELEN here */
#include <sys/socket.h>
#endif
#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 64
#endif
/* === MACROS === */
/*
* GetReq - Get the next avilable X request packet in the buffer and
* return it.
*
* "name" is the name of the request, e.g. CreatePixmap, OpenFont, etc.
* "req" is the name of the request pointer.
*
*/
#if !defined(UNIXCPP)
#define NXMacroGetReq(name, req) \
WORD64ALIGN\
if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\
{if (dpy != xdpy) N_XFlush(dpy); else _XFlush(dpy);}\
req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
req->reqType = X_##name;\
req->length = (SIZEOF(x##name##Req))>>2;\
dpy->bufptr += SIZEOF(x##name##Req);\
dpy->request++
#else /* non-ANSI C uses empty comment instead of "##" for token concatenation */
#define NXMacroGetReq(name, req) \
WORD64ALIGN\
if ((dpy->bufptr + SIZEOF(x/**/name/**/Req)) > dpy->bufmax)\
{if (dpy != xdpy) N_XFlush(dpy); else _XFlush(dpy);}\
req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
req->reqType = X_/**/name;\
req->length = (SIZEOF(x/**/name/**/Req))>>2;\
dpy->bufptr += SIZEOF(x/**/name/**/Req);\
dpy->request++
#endif
#ifdef NEEDFORNX
/* GetReqExtra is the same as GetReq, but allocates "n" additional
bytes after the request. "n" must be a multiple of 4! */
#if !defined(UNIXCPP)
#define GetReqExtra(name, n, req) \
WORD64ALIGN\
if ((dpy->bufptr + SIZEOF(x##name##Req) + n) > dpy->bufmax)\
_XFlush(dpy);\
req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
req->reqType = X_##name;\
req->length = (SIZEOF(x##name##Req) + n)>>2;\
dpy->bufptr += SIZEOF(x##name##Req) + n;\
dpy->request++
#else
#define GetReqExtra(name, n, req) \
WORD64ALIGN\
if ((dpy->bufptr + SIZEOF(x/**/name/**/Req) + n) > dpy->bufmax)\
_XFlush(dpy);\
req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
req->reqType = X_/**/name;\
req->length = (SIZEOF(x/**/name/**/Req) + n)>>2;\
dpy->bufptr += SIZEOF(x/**/name/**/Req) + n;\
dpy->request++
#endif
/*
* GetResReq is for those requests that have a resource ID
* (Window, Pixmap, GContext, etc.) as their single argument.
* "rid" is the name of the resource.
*/
#if !defined(UNIXCPP)
#define GetResReq(name, rid, req) \
WORD64ALIGN\
if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\
_XFlush(dpy);\
req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\
req->reqType = X_##name;\
req->length = 2;\
req->id = (rid);\
dpy->bufptr += SIZEOF(xResourceReq);\
dpy->request++
#else
#define GetResReq(name, rid, req) \
WORD64ALIGN\
if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\
_XFlush(dpy);\
req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\
req->reqType = X_/**/name;\
req->length = 2;\
req->id = (rid);\
dpy->bufptr += SIZEOF(xResourceReq);\
dpy->request++
#endif
/*
* GetEmptyReq is for those requests that have no arguments
* at all.
*/
#if !defined(UNIXCPP)
#define GetEmptyReq(name, req) \
WORD64ALIGN\
if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\
_XFlush(dpy);\
req = (xReq *) (dpy->last_req = dpy->bufptr);\
req->reqType = X_##name;\
req->length = 1;\
dpy->bufptr += SIZEOF(xReq);\
dpy->request++
#else
#define GetEmptyReq(name, req) \
WORD64ALIGN\
if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\
_XFlush(dpy);\
req = (xReq *) (dpy->last_req = dpy->bufptr);\
req->reqType = X_/**/name;\
req->length = 1;\
dpy->bufptr += SIZEOF(xReq);\
dpy->request++
#endif
#define SyncHandle() \
if (dpy->synchandler) (*dpy->synchandler)(dpy)
#define FlushGC(dpy, gc) \
if ((gc)->dirty) _XFlushGCCache((dpy), (gc))
/*
* Data - Place data in the buffer and pad the end to provide
* 32 bit word alignment. Transmit if the buffer fills.
*
* "dpy" is a pointer to a Display.
* "data" is a pinter to a data buffer.
* "len" is the length of the data buffer.
* we can presume buffer less than 2^16 bytes, so bcopy can be used safely.
*/
#ifndef DataRoutineIsProcedure
#define Data(dpy, data, len) \
if (dpy->bufptr + (len) <= dpy->bufmax) {\
bcopy(data, dpy->bufptr, (int)len);\
dpy->bufptr += ((len) + 3) & ~3;\
} else\
_XSend(dpy, data, len)
#endif /* DataRoutineIsProcedure */
/* Allocate bytes from the buffer. No padding is done, so if
* the length is not a multiple of 4, the caller must be
* careful to leave the buffer aligned after sending the
* current request.
*
* "type" is the type of the pointer being assigned to.
* "ptr" is the pointer being assigned to.
* "n" is the number of bytes to allocate.
*
* Example:
* xTextElt *elt;
* BufAlloc (xTextElt *, elt, nbytes)
*/
#define BufAlloc(type, ptr, n) \
if (dpy->bufptr + (n) > dpy->bufmax) \
_XFlush (dpy); \
ptr = (type) dpy->bufptr; \
dpy->bufptr += (n);
/*
* provide emulation routines for smaller architectures
*/
#ifndef WORD64
#define Data16(dpy, data, len) Data((dpy), (char *)(data), (len))
#define Data32(dpy, data, len) Data((dpy), (char *)(data), (len))
#define _XRead16Pad(dpy, data, len) _XReadPad((dpy), (char *)(data), (len))
#define _XRead16(dpy, data, len) _XRead((dpy), (char *)(data), (len))
#define _XRead32(dpy, data, len) _XRead((dpy), (char *)(data), (len))
#endif /* not WORD64 */
#define PackData16(dpy,data,len) Data16 (dpy, data, len)
#define PackData32(dpy,data,len) Data32 (dpy, data, len)
/* Xlib manual is bogus */
#define PackData(dpy,data,len) PackData16 (dpy, data, len)
#endif /* NEEDFORNX */
#if !defined(STARTITERATE) && !defined(WORD64)
#define STARTITERATE(tpvar,type,start,endcond,decr) \
for (tpvar = (type *) start; endcond; tpvar++, decr) {
#define ENDITERATE }
#endif /* STARTITERATE */
#ifndef WORD64
#undef Data32
#define Data32(dpy, data, len) NXProcData((dpy), (char *)(data), (len))
#endif /* not WORD64 */
extern int gNXSyncGCMode;
/* extension hooks */
extern Bool N_XUnknownWireEvent(Display *, XEvent *, xEvent *);
extern Status N_XReply(Display *, xReply *, int, Bool);
extern Status N_XUnknownNativeEvent(Display *, XEvent *, xEvent *);
extern int DPSCAPConnect( char *, char **, int *, int *, int *, char **);
extern int N_XDisconnectDisplay(int);
extern int N_XGetHostname (char *, int);
extern int N_XRead(Display*, char *, long);
extern void NXProcData (Display *, char *, long);
extern void N_XFlush(Display *);
extern void N_XReadPad(Display*, char *, long);
extern void N_XSend(Display *, _Xconst char *, long);
extern void N_XWaitForReadable(Display *);
extern void N_XWaitForWritable(Display *);
extern void XDPSGetDefaultColorMaps(
Display *dpy,
Screen *screen,
Drawable drawable,
XStandardColormap *colorCube,
XStandardColormap *grayRamp);
#endif /* _CSLIBINT_H */
|