3 Copyright 1993, 1994, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
11 The above copyright notice and this permission notice shall be included
12 in all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 OTHER DEALINGS IN THE SOFTWARE.
22 Except as contained in this notice, the name of The Open Group shall
23 not be used in advertising or otherwise to promote the sale, use or
24 other dealings in this Software without prior written authorization
27 * Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
31 * Permission to use, copy, modify, and distribute this software and its
32 * documentation for any purpose and without fee is hereby granted, provided
33 * that the above copyright notice appear in all copies and that both that
34 * copyright notice and this permission notice appear in supporting
35 * documentation, and that the name NCR not be used in advertising
36 * or publicity pertaining to distribution of the software without specific,
37 * written prior permission. NCR makes no representations about the
38 * suitability of this software for any purpose. It is provided "as is"
39 * without express or implied warranty.
41 * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
42 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
43 * NO EVENT SHALL NCR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
44 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
45 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
46 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
47 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
54 * XTRANSDEBUG will enable the PRMSG() macros used in the X Transport
55 * Interface code. Each use of the PRMSG macro has a level associated with
56 * it. XTRANSDEBUG is defined to be a level. If the invocation level is =<
57 * the value of XTRANSDEBUG, then the message will be printed out to stderr.
58 * Recommended levels are:
60 * XTRANSDEBUG=1 Error messages
61 * XTRANSDEBUG=2 API Function Tracing
62 * XTRANSDEBUG=3 All Function Tracing
63 * XTRANSDEBUG=4 printing of intermediate values
64 * XTRANSDEBUG=5 really detailed stuff
67 * Defining XTRANSDEBUGTIMESTAMP will cause printing timestamps with each
72 # define XTRANSDEBUG 1
76 # define _WILLWINSOCK_
83 #endif /* XTRANSDEBUG */
88 # include <sys/socket.h>
89 # include <netinet/in.h>
90 # include <arpa/inet.h>
93 * Moved the setting of NEED_UTSNAME to this header file from Xtrans.c,
94 * to avoid a race condition. JKJ (6/5/97)
97 # if defined(_POSIX_SOURCE) || defined(USG) || defined(SVR4) || defined(__SVR4) || defined(__SCO__)
101 # include <sys/utsname.h>
104 # define ESET(val) errno = val
105 # define EGET() errno
109 # include <limits.h> /* for USHRT_MAX */
111 # define ESET(val) WSASetLastError(val)
112 # define EGET() WSAGetLastError()
119 #define X_TCP_PORT 6000
122 struct _XtransConnInfo {
123 struct _Xtransport *transptr;
136 #define XTRANS_OPEN_COTS_CLIENT 1
137 #define XTRANS_OPEN_COTS_SERVER 2
138 #define XTRANS_OPEN_CLTS_CLIENT 3
139 #define XTRANS_OPEN_CLTS_SERVER 4
142 typedef struct _Xtransport {
148 XtransConnInfo (*OpenCOTSClient)(
149 struct _Xtransport *, /* transport */
150 char *, /* protocol */
155 #endif /* TRANS_CLIENT */
159 XtransConnInfo (*OpenCOTSServer)(
160 struct _Xtransport *, /* transport */
161 char *, /* protocol */
166 #endif /* TRANS_SERVER */
170 XtransConnInfo (*OpenCLTSClient)(
171 struct _Xtransport *, /* transport */
172 char *, /* protocol */
177 #endif /* TRANS_CLIENT */
181 XtransConnInfo (*OpenCLTSServer)(
182 struct _Xtransport *, /* transport */
183 char *, /* protocol */
188 #endif /* TRANS_SERVER */
193 XtransConnInfo (*ReopenCOTSServer)(
194 struct _Xtransport *, /* transport */
199 XtransConnInfo (*ReopenCLTSServer)(
200 struct _Xtransport *, /* transport */
205 #endif /* TRANS_REOPEN */
209 XtransConnInfo, /* connection */
216 # define ADDR_IN_USE_ALLOWED 1
218 int (*CreateListener)(
219 XtransConnInfo, /* connection */
221 unsigned int /* flags */
224 int (*ResetListener)(
225 XtransConnInfo /* connection */
228 XtransConnInfo (*Accept)(
229 XtransConnInfo, /* connection */
233 #endif /* TRANS_SERVER */
238 XtransConnInfo, /* connection */
243 #endif /* TRANS_CLIENT */
245 int (*BytesReadable)(
246 XtransConnInfo, /* connection */
247 BytesReadable_t * /* pend */
251 XtransConnInfo, /* connection */
257 XtransConnInfo, /* connection */
263 XtransConnInfo, /* connection */
264 struct iovec *, /* buf */
269 XtransConnInfo, /* connection */
270 struct iovec *, /* buf */
275 XtransConnInfo /* connection */
279 XtransConnInfo /* connection */
282 int (*CloseForCloning)(
283 XtransConnInfo /* connection */
289 typedef struct _Xtransport_table {
290 Xtransport *transport;
296 * Flags for the flags member of Xtransport.
299 #define TRANS_ALIAS (1<<0) /* record is an alias, don't create server */
300 #define TRANS_LOCAL (1<<1) /* local transport */
301 #define TRANS_DISABLED (1<<2) /* Don't open this one */
302 #define TRANS_NOLISTEN (1<<3) /* Don't listen on this one */
303 #define TRANS_NOUNLINK (1<<4) /* Don't unlink transport endpoints */
304 #define TRANS_ABSTRACT (1<<5) /* Use abstract sockets if available */
305 #define TRANS_NOXAUTH (1<<6) /* Don't verify authentication (because it's secure some other way at the OS layer) */
307 /* Flags to preserve when setting others */
308 #define TRANS_KEEPFLAGS (TRANS_NOUNLINK|TRANS_ABSTRACT)
311 * readv() and writev() don't exist or don't work correctly on some
312 * systems, so they may be emulated.
315 #if defined(SYSV) && defined(__i386__) && !defined(__SCO__) && !defined(sun) || defined(WIN32)
317 #define READV(ciptr, iov, iovcnt) TRANS(ReadV)(ciptr, iov, iovcnt)
319 static int TRANS(ReadV)(
320 XtransConnInfo, /* ciptr */
321 struct iovec *, /* iov */
327 #define READV(ciptr, iov, iovcnt) readv(ciptr->fd, iov, iovcnt)
329 #endif /* CRAY || (SYSV && __i386__) || WIN32 || __sxg__ || */
332 #if defined(SYSV) && defined(__i386__) && !defined(__SCO__) && !defined(sun) || defined(WIN32)
334 #define WRITEV(ciptr, iov, iovcnt) TRANS(WriteV)(ciptr, iov, iovcnt)
336 static int TRANS(WriteV)(
337 XtransConnInfo, /* ciptr */
338 struct iovec *, /* iov */
344 #define WRITEV(ciptr, iov, iovcnt) writev(ciptr->fd, iov, iovcnt)
346 #endif /* CRAY || WIN32 || __sxg__ */
349 static int is_numeric (
350 const char * /* str */
354 static int trans_mkdir (
355 const char *, /* path */
361 * Some XTRANSDEBUG stuff
364 #if defined(XTRANSDEBUG)
365 /* add hack to the format string to avoid warnings about extra arguments
368 #ifdef XTRANSDEBUGTIMESTAMP
369 #if defined(XSERV_t) && defined(TRANS_SERVER)
370 /* Use ErrorF() for the X server */
371 #define PRMSG(lvl,x,a,b,c) if (lvl <= XTRANSDEBUG){ \
372 int hack= 0, saveerrno=errno; \
374 gettimeofday(&tp,0); \
375 ErrorF("%s",__xtransname); \
376 ErrorF(x+hack,a,b,c); \
377 ErrorF("timestamp (ms): %d\n",tp.tv_sec*1000+tp.tv_usec/1000); \
381 #define PRMSG(lvl,x,a,b,c) if (lvl <= XTRANSDEBUG){ \
382 int hack= 0, saveerrno=errno; \
384 gettimeofday(&tp,0); \
385 fprintf(stderr, "%s", __xtransname); fflush(stderr); \
386 fprintf(stderr, x+hack,a,b,c); fflush(stderr); \
387 fprintf(stderr, "timestamp (ms): %d\n",tp.tv_sec*1000+tp.tv_usec/1000); \
391 #endif /* XSERV_t && TRANS_SERVER */
392 #else /* XTRANSDEBUGTIMESTAMP */
393 #if defined(XSERV_t) && defined(TRANS_SERVER)
394 /* Use ErrorF() for the X server */
395 #define PRMSG(lvl,x,a,b,c) if (lvl <= XTRANSDEBUG){ \
396 int hack= 0, saveerrno=errno; \
397 ErrorF("%s",__xtransname); \
398 ErrorF(x+hack,a,b,c); \
402 #define PRMSG(lvl,x,a,b,c) if (lvl <= XTRANSDEBUG){ \
403 int hack= 0, saveerrno=errno; \
404 fprintf(stderr, "%s", __xtransname); fflush(stderr); \
405 fprintf(stderr, x+hack,a,b,c); fflush(stderr); \
408 #endif /* XSERV_t && TRANS_SERVER */
409 #endif /* XTRANSDEBUGTIMESTAMP */
411 #define PRMSG(lvl,x,a,b,c) ((void)0)
412 #endif /* XTRANSDEBUG */
414 #endif /* _XTRANSINT_H_ */