1
/* $XConsortium: Xlibnet.h,v 1.18 91/07/23 19:01:27 rws Exp $ */
4
Copyright 1991 Massachusetts Institute of Technology
6
Permission to use, copy, modify, distribute, and sell this software and its
7
documentation for any purpose is hereby granted without fee, provided that
8
the above copyright notice appear in all copies and that both that
9
copyright notice and this permission notice appear in supporting
10
documentation, and that the name of M.I.T. not be used in advertising or
11
publicity pertaining to distribution of the software without specific,
12
written prior permission. M.I.T. makes no representations about the
13
suitability of this software for any purpose. It is provided "as is"
14
without express or implied warranty.
16
/* $XFree86: xc/lib/dps/Xlibnet.h,v 1.7 2002/05/31 18:45:48 dawes Exp $ */
18
* Xlibnet.h - Xlib networking include files for UNIX Systems.
23
#define X_UNIX_PATH "/usr/spool/sockets/X11/"
24
#define OLD_UNIX_PATH "/tmp/.X11-unix/X"
26
#define X_UNIX_PATH "/tmp/.X11-unix/X"
28
#endif /* X_UNIX_PATH */
33
* UNIX System V Release 3.2
35
#define BytesReadable(fd,ptr) (_XBytesReadable ((fd), (ptr)))
36
#define MALLOC_0_RETURNS_NULL
37
#include <sys/ioctl.h>
42
* TLI (Streams-based) networking
44
#define BytesReadable(fd,ptr) (_XBytesReadable ((fd), (ptr)))
45
#include <sys/uio.h> /* define struct iovec */
48
#else /* not STREAMSCONN */
50
* socket-based systems
52
#include <netinet/in.h>
53
#include <sys/ioctl.h>
55
#include <sys/uio.h> /* needed for XlibInt.c */
57
#include <sys/filio.h>
60
#if defined(i386) && defined(SYSV)
61
#if !defined(SCO) && !defined(SCO325)
62
#include <net/errno.h>
64
#include <sys/stropts.h>
65
#define BytesReadable(fd,ptr) ioctl((fd), I_NREAD, (ptr))
67
#define BytesReadable(fd, ptr) ioctl ((fd), FIONREAD, (ptr))
70
#endif /* STREAMSCONN else */
73
* If your BytesReadable correctly detects broken connections, then
74
* you should NOT define XCONN_CHECK_FREQ.
76
#define XCONN_CHECK_FREQ 256
91
#include <sys/param.h>
94
#define OPEN_MAX NOFILE
96
#if !defined(__UNIXOS2__) && !defined(__QNX__)
97
#define OPEN_MAX NOFILES_MAX
111
/* Adobe additions */
122
#define MSKCNT ((OPEN_MAX + 31) / 32)
125
#define BITMASK(i) (1 << (i))
129
#define BITMASK(i) (1 << ((i) & 31))
130
#define MASKIDX(i) ((i) >> 5)
133
#define MASKWORD(buf, i) buf[MASKIDX(i)]
134
#define BITSET(buf, i) MASKWORD(buf, i) |= BITMASK(i)
135
#define BITCLEAR(buf, i) MASKWORD(buf, i) &= ~BITMASK(i)
136
#define GETBIT(buf, i) (MASKWORD(buf, i) & BITMASK(i))
138
/* Adobe additions */
142
#undef MASKANDSETBITS
148
#define COPYBITS(src, dst) dst[0] = src[0]
149
#define CLEARBITS(buf) buf[0] = 0
150
#define MASKANDSETBITS(dst, b1, b2) dst[0] = (b1[0] & b2[0])
151
#define ORBITS(dst, b1, b2) dst[0] = (b1[0] | b2[0])
152
#define UNSETBITS(dst, b1) (dst[0] &= ~b1[0])
153
#define _XANYSET(src) (src[0])
156
#define COPYBITS(src, dst) { dst[0] = src[0]; dst[1] = src[1]; }
157
#define CLEARBITS(buf) { buf[0] = 0; buf[1] = 0; }
158
#define MASKANDSETBITS(dst, b1, b2) {\
159
dst[0] = (b1[0] & b2[0]);\
160
dst[1] = (b1[1] & b2[1]); }
161
#define ORBITS(dst, b1, b2) {\
162
dst[0] = (b1[0] | b2[0]);\
163
dst[1] = (b1[1] | b2[1]); }
164
#define UNSETBITS(dst, b1) {\
167
#define _XANYSET(src) (src[0] || src[1])
170
#define COPYBITS(src, dst) { dst[0] = src[0]; dst[1] = src[1]; \
172
#define CLEARBITS(buf) { buf[0] = 0; buf[1] = 0; buf[2] = 0; }
173
#define MASKANDSETBITS(dst, b1, b2) {\
174
dst[0] = (b1[0] & b2[0]);\
175
dst[1] = (b1[1] & b2[1]);\
176
dst[2] = (b1[2] & b2[2]); }
177
#define ORBITS(dst, b1, b2) {\
178
dst[0] = (b1[0] | b2[0]);\
179
dst[1] = (b1[1] | b2[1]);\
180
dst[2] = (b1[2] | b2[2]); }
181
#define UNSETBITS(dst, b1) {\
185
#define _XANYSET(src) (src[0] || src[1] || src[2])
188
#define COPYBITS(src, dst) dst[0] = src[0]; dst[1] = src[1]; \
189
dst[2] = src[2]; dst[3] = src[3]
190
#define CLEARBITS(buf) buf[0] = 0; buf[1] = 0; buf[2] = 0; buf[3] = 0
191
#define MASKANDSETBITS(dst, b1, b2) \
192
dst[0] = (b1[0] & b2[0]);\
193
dst[1] = (b1[1] & b2[1]);\
194
dst[2] = (b1[2] & b2[2]);\
195
dst[3] = (b1[3] & b2[3])
196
#define ORBITS(dst, b1, b2) \
197
dst[0] = (b1[0] | b2[0]);\
198
dst[1] = (b1[1] | b2[1]);\
199
dst[2] = (b1[2] | b2[2]);\
200
dst[3] = (b1[3] | b2[3])
201
#define UNSETBITS(dst, b1) \
206
#define _XANYSET(src) (src[0] || src[1] || src[2] || src[3])
210
#define COPYBITS(src, dst) bcopy((char *) src, (char *) dst,\
212
#define CLEARBITS(buf) bzero((char *) buf, MSKCNT*sizeof(long))
213
#define MASKANDSETBITS(dst, b1, b2) \
215
for (cri=MSKCNT; --cri>=0; ) \
216
dst[cri] = (b1[cri] & b2[cri]); }
217
#define ORBITS(dst, b1, b2) \
219
for (cri=MSKCNT; --cri>=0; ) \
220
dst[cri] = (b1[cri] | b2[cri]); }
221
#define UNSETBITS(dst, b1) \
223
for (cri=MSKCNT; --cri>=0; ) \
224
dst[cri] &= ~b1[cri]; }
226
* If MSKCNT>4, then _XANYSET is a routine defined in XlibInt.c.
228
* #define _XANYSET(src) (src[0] || src[1] || src[2] || src[3] || src[4] ...)
230
extern int N_XANYSET(unsigned long *);
234
* ReadvFromServer and WritevToSever use struct iovec, normally found
235
* in Berkeley systems in <sys/uio.h>. See the readv(2) and writev(2)
236
* manual pages for details.
243
#if defined(USG) && !defined(CRAY) && !defined(umips) && !defined(MOTOROLA)
252
#include "Xstreams.h"
254
extern char _XsTypeOfStream[];
255
extern Xstream _XsStream[];
257
#define ReadFromServer(dpy, data, size) \
258
(*_XsStream[_XsTypeOfStream[dpy]].ReadFromStream)((dpy), (data), (size), \
260
#define WriteToServer(dpy, bufind, size) \
261
(*_XsStream[_XsTypeOfStream[dpy]].WriteToStream)((dpy), (bufind), (size))
263
#else /* else not STREAMSCONN */
266
* bsd can read from sockets directly
268
#define ReadFromServer(dpy, data, size) read((dpy), (data), (size))
269
#define WriteToServer(dpy, bufind, size) write((dpy), (bufind), (size))
271
#endif /* STREAMSCONN */
275
#if !defined(USG) || defined(MOTOROLA)
276
#if (defined(SCO) || defined(SCO325)) || (!(defined(SYSV) && defined(i386)))
277
#define _XReadV readv
279
#define _XWriteV writev
281
#endif /* !USL_COMPAT */
283
#define ReadvFromServer(dpy, iov, iovcnt) _XReadV((dpy), (iov), (iovcnt))
284
#define WritevToServer(dpy, iov, iovcnt) _XWriteV((dpy), (iov), (iovcnt))