diff options
Diffstat (limited to 'nx-X11/lib/xtrans/Xtransint.h')
-rw-r--r-- | nx-X11/lib/xtrans/Xtransint.h | 299 |
1 files changed, 124 insertions, 175 deletions
diff --git a/nx-X11/lib/xtrans/Xtransint.h b/nx-X11/lib/xtrans/Xtransint.h index 196eb6fc6..2156bd52f 100644 --- a/nx-X11/lib/xtrans/Xtransint.h +++ b/nx-X11/lib/xtrans/Xtransint.h @@ -24,9 +24,7 @@ not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. -*/ - -/* Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA + * Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA * * All Rights Reserved * @@ -53,10 +51,10 @@ from The Open Group. #define _XTRANSINT_H_ /* - * XTRANSDEBUG will enable the PRMSG() macros used in the X Transport - * Interface code. Each use of the PRMSG macro has a level associated with - * it. XTRANSDEBUG is defined to be a level. If the invocation level is =< - * the value of XTRANSDEBUG, then the message will be printed out to stderr. + * XTRANSDEBUG will enable the PRMSG() macros used in the X Transport + * Interface code. Each use of the PRMSG macro has a level associated with + * it. XTRANSDEBUG is defined to be a level. If the invocation level is =< + * the value of XTRANSDEBUG, then the message will be printed out to stderr. * Recommended levels are: * * XTRANSDEBUG=1 Error messages @@ -70,12 +68,8 @@ from The Open Group. * message. */ -#ifndef XTRANSDEBUG -# ifndef __UNIXOS2__ -# define XTRANSDEBUG 1 -# else +#if !defined(XTRANSDEBUG) && defined(XTRANS_TRANSPORT_C) # define XTRANSDEBUG 1 -# endif #endif #ifdef WIN32 @@ -84,6 +78,10 @@ from The Open Group. #include "Xtrans.h" +#ifndef _X_UNUSED /* Defined in Xfuncproto.h in xproto >= 7.0.22 */ +# define _X_UNUSED /* */ +#endif + #ifdef XTRANSDEBUG # include <stdio.h> #endif /* XTRANSDEBUG */ @@ -91,87 +89,23 @@ from The Open Group. #include <errno.h> #ifndef WIN32 -# ifndef Lynx # include <sys/socket.h> -# else -# include <socket.h> -# endif # include <netinet/in.h> # include <arpa/inet.h> -# ifdef __UNIXOS2__ -# include <sys/ioctl.h> -# endif /* * Moved the setting of NEED_UTSNAME to this header file from Xtrans.c, * to avoid a race condition. JKJ (6/5/97) */ -# if (defined(_POSIX_SOURCE) && !defined(AIXV3) && !defined(__QNX__)) || defined(hpux) || defined(USG) || defined(SVR4) || defined(__SCO__) +# if defined(_POSIX_SOURCE) || defined(USG) || defined(SVR4) || defined(__SVR4) || defined(__SCO__) # ifndef NEED_UTSNAME # define NEED_UTSNAME # endif # include <sys/utsname.h> # endif -/* - * makedepend screws up on #undef OPEN_MAX, so we define a new symbol - */ - -# ifndef TRANS_OPEN_MAX - -# ifndef X_NOT_POSIX -# ifdef _POSIX_SOURCE -# include <limits.h> -# else -# define _POSIX_SOURCE -# include <limits.h> -# undef _POSIX_SOURCE -# endif -# endif -# ifndef OPEN_MAX -# if defined(_SC_OPEN_MAX) && !defined(__UNIXOS2__) -# define OPEN_MAX (sysconf(_SC_OPEN_MAX)) -# else -# ifdef SVR4 -# define OPEN_MAX 256 -# else -# include <sys/param.h> -# ifndef OPEN_MAX -# ifdef __OSF1__ -# define OPEN_MAX 256 -# else -# ifdef NOFILE -# define OPEN_MAX NOFILE -# else -# if !defined(__UNIXOS2__) && !defined(__QNX__) -# define OPEN_MAX NOFILES_MAX -# else -# define OPEN_MAX 256 -# endif -# endif -# endif -# endif -# endif -# endif -# endif -# if defined(_SC_OPEN_MAX) -# define TRANS_OPEN_MAX OPEN_MAX -# else /* !__GNU__ */ -# if OPEN_MAX > 256 -# define TRANS_OPEN_MAX 256 -# else -# define TRANS_OPEN_MAX OPEN_MAX -# endif -# endif /*__GNU__*/ - -# endif /* TRANS_OPEN_MAX */ - -# ifdef __UNIXOS2__ -# define ESET(val) -# else # define ESET(val) errno = val -# endif # define EGET() errno #else /* WIN32 */ @@ -189,6 +123,16 @@ from The Open Group. #define X_TCP_PORT 6000 #endif +#if XTRANS_SEND_FDS + +struct _XtransConnFd { + struct _XtransConnFd *next; + int fd; + int do_close; +}; + +#endif + struct _XtransConnInfo { struct _Xtransport *transptr; int index; @@ -201,75 +145,45 @@ struct _XtransConnInfo { int addrlen; char *peeraddr; int peeraddrlen; + struct _XtransConnFd *recv_fds; + struct _XtransConnFd *send_fds; }; #define XTRANS_OPEN_COTS_CLIENT 1 #define XTRANS_OPEN_COTS_SERVER 2 -#define XTRANS_OPEN_CLTS_CLIENT 3 -#define XTRANS_OPEN_CLTS_SERVER 4 - typedef struct _Xtransport { - char *TransName; + const char *TransName; int flags; #ifdef TRANS_CLIENT XtransConnInfo (*OpenCOTSClient)( struct _Xtransport *, /* transport */ - char *, /* protocol */ - char *, /* host */ - char * /* port */ + const char *, /* protocol */ + const char *, /* host */ + const char * /* port */ ); #endif /* TRANS_CLIENT */ #ifdef TRANS_SERVER - char ** nolisten; + const char ** nolisten; XtransConnInfo (*OpenCOTSServer)( struct _Xtransport *, /* transport */ - char *, /* protocol */ - char *, /* host */ - char * /* port */ - ); - -#endif /* TRANS_SERVER */ - -#ifdef TRANS_CLIENT - - XtransConnInfo (*OpenCLTSClient)( - struct _Xtransport *, /* transport */ - char *, /* protocol */ - char *, /* host */ - char * /* port */ - ); - -#endif /* TRANS_CLIENT */ - -#ifdef TRANS_SERVER - - XtransConnInfo (*OpenCLTSServer)( - struct _Xtransport *, /* transport */ - char *, /* protocol */ - char *, /* host */ - char * /* port */ + const char *, /* protocol */ + const char *, /* host */ + const char * /* port */ ); #endif /* TRANS_SERVER */ - #ifdef TRANS_REOPEN XtransConnInfo (*ReopenCOTSServer)( struct _Xtransport *, /* transport */ int, /* fd */ - char * /* port */ - ); - - XtransConnInfo (*ReopenCLTSServer)( - struct _Xtransport *, /* transport */ - int, /* fd */ - char * /* port */ + const char * /* port */ ); #endif /* TRANS_REOPEN */ @@ -287,7 +201,7 @@ typedef struct _Xtransport { int (*CreateListener)( XtransConnInfo, /* connection */ - char *, /* port */ + const char *, /* port */ unsigned int /* flags */ ); @@ -306,8 +220,8 @@ typedef struct _Xtransport { int (*Connect)( XtransConnInfo, /* connection */ - char *, /* host */ - char * /* port */ + const char *, /* host */ + const char * /* port */ ); #endif /* TRANS_CLIENT */ @@ -341,6 +255,18 @@ typedef struct _Xtransport { int /* size */ ); +#if XTRANS_SEND_FDS + int (*SendFd)( + XtransConnInfo, /* connection */ + int, /* fd */ + int /* do_close */ + ); + + int (*RecvFd)( + XtransConnInfo /* connection */ + ); +#endif + int (*Disconnect)( XtransConnInfo /* connection */ ); @@ -370,18 +296,29 @@ typedef struct _Xtransport_table { #define TRANS_LOCAL (1<<1) /* local transport */ #define TRANS_DISABLED (1<<2) /* Don't open this one */ #define TRANS_NOLISTEN (1<<3) /* Don't listen on this one */ -#define TRANS_NOUNLINK (1<<4) /* Dont unlink transport endpoints */ +#define TRANS_NOUNLINK (1<<4) /* Don't unlink transport endpoints */ #define TRANS_ABSTRACT (1<<5) /* Use abstract sockets if available */ +#define TRANS_NOXAUTH (1<<6) /* Don't verify authentication (because it's secure some other way at the OS layer) */ +#define TRANS_RECEIVED (1<<7) /* The fd for this has already been opened by someone else. */ /* Flags to preserve when setting others */ #define TRANS_KEEPFLAGS (TRANS_NOUNLINK|TRANS_ABSTRACT) +#ifdef XTRANS_TRANSPORT_C /* only provide static function prototypes when + building the transport.c file that has them in */ + +#ifdef __clang__ +/* Not all clients make use of all provided statics */ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-function" +#endif + /* * readv() and writev() don't exist or don't work correctly on some * systems, so they may be emulated. */ -#if (defined(SYSV) && defined(i386) && !defined(__SCO__)) || defined(WIN32) || defined(__sxg__) || defined(__UNIXOS2__) +#ifdef WIN32 #define READV(ciptr, iov, iovcnt) TRANS(ReadV)(ciptr, iov, iovcnt) @@ -395,10 +332,10 @@ static int TRANS(ReadV)( #define READV(ciptr, iov, iovcnt) readv(ciptr->fd, iov, iovcnt) -#endif /* (SYSV && i386) || WIN32 || __sxg__ || */ +#endif /* WIN32 */ -#if (defined(SYSV) && defined(i386) && !defined(__SCO__)) || defined(WIN32) || defined(__sxg__) || defined(__UNIXOS2__) +#ifdef WIN32 #define WRITEV(ciptr, iov, iovcnt) TRANS(WriteV)(ciptr, iov, iovcnt) @@ -412,72 +349,84 @@ static int TRANS(WriteV)( #define WRITEV(ciptr, iov, iovcnt) writev(ciptr->fd, iov, iovcnt) -#endif /* WIN32 || __sxg__ */ +#endif /* WIN32 */ static int is_numeric ( - char * /* str */ + const char * /* str */ ); #ifdef TRANS_SERVER static int trans_mkdir ( - char *, /* path */ + const char *, /* path */ int /* mode */ ); #endif +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + /* * Some XTRANSDEBUG stuff */ -#if defined(XTRANSDEBUG) -/* add hack to the format string to avoid warnings about extra arguments - * to fprintf. +#ifdef XTRANSDEBUG +#include <stdarg.h> + +/* + * The X server provides ErrorF() & VErrorF(), for other software that uses + * xtrans, we provide our own simple versions. */ -#ifdef XTRANSDEBUGTIMESTAMP -#if defined(XSERV_t) && defined(TRANS_SERVER) -/* Use ErrorF() for the X server */ -#define PRMSG(lvl,x,a,b,c) if (lvl <= XTRANSDEBUG){ \ - int hack= 0, saveerrno=errno; \ - struct timeval tp;\ - gettimeofday(&tp,0); \ - ErrorF("%s",__xtransname); \ - ErrorF(x+hack,a,b,c); \ - ErrorF("timestamp (ms): %d\n",tp.tv_sec*1000+tp.tv_usec/1000); \ - errno=saveerrno; \ - } else ((void)0) -#else -#define PRMSG(lvl,x,a,b,c) if (lvl <= XTRANSDEBUG){ \ - int hack= 0, saveerrno=errno; \ - struct timeval tp;\ - gettimeofday(&tp,0); \ - fprintf(stderr, "%s",__xtransname); fflush(stderr); \ - fprintf(stderr, x+hack,a,b,c); fflush(stderr); \ - fprintf(stderr, "timestamp (ms): %d\n",tp.tv_sec*1000+tp.tv_usec/1000); \ - fflush(stderr); \ - errno=saveerrno; \ - } else ((void)0) -#endif /* XSERV_t && TRANS_SERVER */ -#else /* XTRANSDEBUGTIMESTAMP */ -#if defined(XSERV_t) && defined(TRANS_SERVER) -/* Use ErrorF() for the X server */ -#define PRMSG(lvl,x,a,b,c) if (lvl <= XTRANSDEBUG){ \ - int hack= 0, saveerrno=errno; \ - ErrorF("%s",__xtransname); \ - ErrorF(x+hack,a,b,c); \ - errno=saveerrno; \ - } else ((void)0) -#else -#define PRMSG(lvl,x,a,b,c) if (lvl <= XTRANSDEBUG){ \ - int hack= 0, saveerrno=errno; \ - fprintf(stderr, "%s",__xtransname); fflush(stderr); \ - fprintf(stderr, x+hack,a,b,c); fflush(stderr); \ - errno=saveerrno; \ - } else ((void)0) -#endif /* XSERV_t && TRANS_SERVER */ -#endif /* XTRANSDEBUGTIMESTAMP */ -#else -#define PRMSG(lvl,x,a,b,c) ((void)0) +# if defined(XSERV_t) && defined(TRANS_SERVER) +# include "os.h" +# else +static inline void _X_ATTRIBUTE_PRINTF(1, 0) +VErrorF(const char *f, va_list args) +{ + vfprintf(stderr, f, args); + fflush(stderr); +} + +static inline void _X_ATTRIBUTE_PRINTF(1, 2) +ErrorF(const char *f, ...) +{ + va_list args; + + va_start(args, f); + VErrorF(f, args); + va_end(args); +} +# endif /* xserver */ +#endif /* XTRANSDEBUG */ + +static inline void _X_ATTRIBUTE_PRINTF(2, 3) +prmsg(int lvl, const char *f, ...) +{ +#ifdef XTRANSDEBUG + va_list args; + + va_start(args, f); + if (lvl <= XTRANSDEBUG) { + int saveerrno = errno; + + ErrorF("%s", __xtransname); + VErrorF(f, args); + +# ifdef XTRANSDEBUGTIMESTAMP + { + struct timeval tp; + gettimeofday(&tp, 0); + ErrorF("timestamp (ms): %d\n", + tp.tv_sec * 1000 + tp.tv_usec / 1000); + } +# endif + errno = saveerrno; + } + va_end(args); #endif /* XTRANSDEBUG */ +} + +#endif /* XTRANS_TRANSPORT_C */ #endif /* _XTRANSINT_H_ */ |