From d409b566bdaf7d40f1697095e62b7811c793fd30 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 7 Nov 2018 22:19:17 +0100 Subject: os: unifdef WIN32 --- nx-X11/programs/Xserver/os/WaitFor.c | 48 ----------- nx-X11/programs/Xserver/os/access.c | 19 ----- nx-X11/programs/Xserver/os/auth.c | 3 - nx-X11/programs/Xserver/os/connection.c | 144 -------------------------------- nx-X11/programs/Xserver/os/io.c | 35 -------- nx-X11/programs/Xserver/os/log.c | 8 -- nx-X11/programs/Xserver/os/osdep.h | 18 ---- nx-X11/programs/Xserver/os/osinit.c | 6 +- nx-X11/programs/Xserver/os/utils.c | 19 +---- nx-X11/programs/Xserver/os/xdmcp.c | 12 --- 10 files changed, 6 insertions(+), 306 deletions(-) diff --git a/nx-X11/programs/Xserver/os/WaitFor.c b/nx-X11/programs/Xserver/os/WaitFor.c index 9db3faef1..3d53335b3 100644 --- a/nx-X11/programs/Xserver/os/WaitFor.c +++ b/nx-X11/programs/Xserver/os/WaitFor.c @@ -82,9 +82,6 @@ SOFTWARE. #include #endif -#ifdef WIN32 -#include -#endif #include /* for strings, fcntl, time */ #include #include @@ -105,22 +102,9 @@ static unsigned long startTimeInMillis; #endif -#ifdef WIN32 -/* Error codes from windows sockets differ from fileio error codes */ -#undef EINTR -#define EINTR WSAEINTR -#undef EINVAL -#define EINVAL WSAEINVAL -#undef EBADF -#define EBADF WSAENOTSOCK -/* Windows select does not set errno. Use GetErrno as wrapper for - WSAGetLastError */ -#define GetErrno WSAGetLastError -#else /* This is just a fallback to errno to hide the differences between unix and Windows in the code */ #define GetErrno() errno -#endif /* modifications by raphael */ int @@ -484,30 +468,12 @@ WaitForSomething(int *pClientsReady) if (XFD_ANYSET (&clientsReadable)) break; -#ifdef WIN32 - /* Windows keyboard and mouse events are added to the input queue - in Block- and WakupHandlers. There is no device to check if - data is ready. So check here if new input is available */ -#if defined(NX_TRANS_SOCKET) - if (*checkForInput[0] != *checkForInput[1]) - { -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "WaitForSomething: Returning 0 because of (*checkForInput[0] != *checkForInput[1]).\n"); -#endif - return 0; - } -#else - if (*checkForInput[0] != *checkForInput[1]) - return 0; -#endif -#endif } } nready = 0; if (XFD_ANYSET (&clientsReadable)) { -#ifndef WIN32 for (i=0; i #endif -#ifdef WIN32 -#include -#endif #include #include @@ -75,7 +72,6 @@ SOFTWARE. #include "site.h" #include #include -#ifndef WIN32 #include #include #include @@ -141,7 +137,6 @@ SOFTWARE. /* #endif */ #endif -#endif /* WIN32 */ #ifndef PATH_MAX #include @@ -474,13 +469,7 @@ DefineSelf (int fd) int family; register HOST *host; -#ifndef WIN32 struct utsname name; -#else - struct { - char nodename[512]; - } name; -#endif register struct hostent *hp; @@ -504,11 +493,7 @@ DefineSelf (int fd) * uname() lets me access to the whole string (it smashes release, you * see), whereas gethostname() kindly truncates it for me. */ -#ifndef WIN32 uname(&name); -#else - gethostname(name.nodename, sizeof(name.nodename)); -#endif hp = _XGethostbyname(name.nodename, hparams); if (hp != NULL) @@ -1692,10 +1677,6 @@ ConvertAddr ( return FamilyLocal; #if defined(TCPCONN) case AF_INET: -#ifdef WIN32 - if (16777343 == *(long*)&((struct sockaddr_in *) saddr)->sin_addr) - return FamilyLocal; -#endif *len = sizeof (struct in_addr); *addr = (void *) &(((struct sockaddr_in *) saddr)->sin_addr); return FamilyInternet; diff --git a/nx-X11/programs/Xserver/os/auth.c b/nx-X11/programs/Xserver/os/auth.c index 84bc5c3c6..491b8c427 100644 --- a/nx-X11/programs/Xserver/os/auth.c +++ b/nx-X11/programs/Xserver/os/auth.c @@ -71,9 +71,6 @@ from The Open Group. #define _SECURITY_SERVER # include #endif -#ifdef WIN32 -#include -#endif struct protocol { unsigned short name_length; diff --git a/nx-X11/programs/Xserver/os/connection.c b/nx-X11/programs/Xserver/os/connection.c index c5ebeea1e..7deeec428 100644 --- a/nx-X11/programs/Xserver/os/connection.c +++ b/nx-X11/programs/Xserver/os/connection.c @@ -65,9 +65,6 @@ SOFTWARE. #include #endif -#ifdef WIN32 -#include -#endif #include #include #define XSERV_t @@ -81,7 +78,6 @@ SOFTWARE. #include #include -#ifndef WIN32 #include #if defined(TCPCONN) @@ -104,7 +100,6 @@ SOFTWARE. #endif #include -#endif /* WIN32 */ #include "misc.h" #include "osdep.h" #include @@ -155,98 +150,7 @@ int GrabInProgress = 0; static void QueueNewConnections(int curconn, int ready, void *data); -#if !defined(WIN32) int *ConnectionTranslation = NULL; -#else -/* - * On NT fds are not between 0 and MAXSOCKS, they are unrelated, and there is - * not even a known maximum value, so use something quite arbitrary for now. - * Do storage is a hash table of size 256. Collisions are handled in a linked - * list. - */ - -#undef MAXSOCKS -#define MAXSOCKS 500 -#undef MAXSELECT -#define MAXSELECT 500 -#define MAXFD 500 - -struct _ct_node { - struct _ct_node *next; - int key; - int value; -}; - -struct _ct_node *ct_head[256]; - -void InitConnectionTranslation(void) -{ - bzero(ct_head, sizeof(ct_head)); -} - -int GetConnectionTranslation(int conn) -{ - struct _ct_node *node = ct_head[conn & 0xff]; - while (node != NULL) - { - if (node->key == conn) - return node->value; - node = node->next; - } - return 0; -} - -void SetConnectionTranslation(int conn, int client) -{ - struct _ct_node **node = ct_head + (conn & 0xff); - if (client == 0) /* remove entry */ - { - while (*node != NULL) - { - if ((*node)->key == conn) - { - struct _ct_node *temp = *node; - *node = (*node)->next; - free(temp); - return; - } - node = &((*node)->next); - } - return; - } else - { - while (*node != NULL) - { - if ((*node)->key == conn) - { - (*node)->value = client; - return; - } - node = &((*node)->next); - } - *node = (struct _ct_node*)malloc(sizeof(struct _ct_node)); - (*node)->next = NULL; - (*node)->key = conn; - (*node)->value = client; - return; - } -} - -void ClearConnectionTranslation(void) -{ - unsigned i; - for (i = 0; i < 256; i++) - { - struct _ct_node *node = ct_head[i]; - while (node != NULL) - { - struct _ct_node *temp = node; - node = node->next; - free(temp); - } - } -} -#endif XtransConnInfo *ListenTransConns = NULL; int *ListenTransFds = NULL; @@ -318,11 +222,7 @@ InitConnectionLimits(void) ErrorF("InitConnectionLimits: MaxClients = %d\n", MaxClients); #endif -#if !defined(WIN32) ConnectionTranslation = (int *)xnfalloc(sizeof(int)*(lastfdesc + 1)); -#else - InitConnectionTranslation(); -#endif } /* @@ -341,7 +241,6 @@ InitConnectionLimits(void) static void InitParentProcess(void) { -#if !defined(WIN32) OsSigHandlerPtr handler; handler = OsSignal (SIGUSR1, SIG_IGN); if ( handler == SIG_IGN) @@ -357,13 +256,11 @@ InitParentProcess(void) */ ParentProcess = GetPPID (ParentProcess); #endif /* __UNIXOS2__ */ -#endif } void NotifyParentProcess(void) { -#if !defined(WIN32) if (displayfd >= 0) { #ifdef NXAGENT_SERVER if (displayfd == STDERR_FILENO) @@ -385,7 +282,6 @@ NotifyParentProcess(void) kill (ParentProcess, SIGUSR1); } } -#endif } static Bool @@ -416,11 +312,7 @@ CreateWellKnownSockets(void) FD_ZERO(&LastSelectMask); FD_ZERO(&ClientsWithInput); -#if !defined(WIN32) for (i=0; i= lastfdesc -#else - XFD_SETCOUNT(&AllClients) >= MaxClients -#endif ) return NullClient; oc = (OsCommPtr)malloc(sizeof(OsCommRec)); @@ -825,11 +711,7 @@ AllocNewConnection (XtransConnInfo trans_conn, int fd, CARD32 conn_time) } client->local = ComputeLocalClient(client); { -#if !defined(WIN32) ConnectionTranslation[fd] = client->index; -#else - SetConnectionTranslation(fd, client->index); -#endif if (GrabInProgress) { FD_SET(fd, &SavedAllClients); @@ -893,11 +775,7 @@ EstablishNewConnections(ClientPtr clientUnused, void * closure) if (newconn < lastfdesc) { int clientid; -#if !defined(WIN32) clientid = ConnectionTranslation[newconn]; -#else - clientid = GetConnectionTranslation(newconn); -#endif if (clientid && (client = clients[clientid])) CloseDownClient(client); } @@ -990,11 +868,7 @@ CloseDownFileDescriptor(OsCommPtr oc) } FreeOsBuffers(oc); free(oc); -#ifndef WIN32 ConnectionTranslation[connection] = 0; -#else - SetConnectionTranslation(connection, 0); -#endif FD_CLR(connection, &AllSockets); FD_CLR(connection, &AllClients); FD_CLR(connection, &ClientsWithInput); @@ -1023,22 +897,16 @@ CloseDownFileDescriptor(OsCommPtr oc) void CheckConnections(void) { -#ifndef WIN32 fd_mask mask; -#endif fd_set tmask; int curclient, curoff; int i; struct timeval notime; int r; -#ifdef WIN32 - fd_set savedAllClients; -#endif notime.tv_sec = 0; notime.tv_usec = 0; -#ifndef WIN32 for (i=0; i -#endif #include #define XSERV_t #define TRANS_SERVER @@ -70,9 +67,7 @@ SOFTWARE. #include #include #include -#if !defined(WIN32) #include -#endif #include #include #include "os.h" @@ -88,7 +83,6 @@ CallbackListPtr FlushCallback; /* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX * systems are broken and return EWOULDBLOCK when they should return EAGAIN */ -#ifndef WIN32 #if defined(EAGAIN) && defined(EWOULDBLOCK) #define ETEST(err) (err == EAGAIN || err == EWOULDBLOCK) #else @@ -98,9 +92,6 @@ CallbackListPtr FlushCallback; #define ETEST(err) (err == EWOULDBLOCK) #endif #endif -#else /* WIN32 The socket errorcodes differ from the normal errors*/ -#define ETEST(err) (err == EAGAIN || err == WSAEWOULDBLOCK) -#endif Bool CriticalOutputPending; int timesThisConnection = 0; @@ -777,9 +768,6 @@ FlushAllOutput(void) OsCommPtr oc; register ClientPtr client; Bool newoutput = NewOutputPending; -#if defined(WIN32) - fd_set newOutputPending; -#endif if (!newoutput) return; @@ -792,7 +780,6 @@ FlushAllOutput(void) CriticalOutputPending = FALSE; NewOutputPending = FALSE; -#ifndef WIN32 for (base = 0; base < howmany(XFD_SETSIZE, NFDBITS); base++) { mask = OutputPending.fds_bits[ base ]; @@ -817,28 +804,6 @@ FlushAllOutput(void) (void)FlushClient(client, oc, (char *)NULL, 0); } } -#else /* WIN32 */ - FD_ZERO(&newOutputPending); - for (base = 0; base < XFD_SETCOUNT(&OutputPending); base++) - { - index = XFD_FD(&OutputPending, base); - if ((index = GetConnectionTranslation(index)) == 0) - continue; - client = clients[index]; - if (client->clientGone) - continue; - oc = (OsCommPtr)client->osPrivate; - if ( - FD_ISSET(oc->fd, &ClientsWithInput)) - { - FD_SET(oc->fd, &newOutputPending); /* set the bit again */ - NewOutputPending = TRUE; - } - else - (void)FlushClient(client, oc, (char *)NULL, 0); - } - XFD_COPYSET(&newOutputPending, &OutputPending); -#endif /* WIN32 */ } void diff --git a/nx-X11/programs/Xserver/os/log.c b/nx-X11/programs/Xserver/os/log.c index 2dc5627e4..3ec3a2779 100644 --- a/nx-X11/programs/Xserver/os/log.c +++ b/nx-X11/programs/Xserver/os/log.c @@ -117,10 +117,6 @@ OR PERFORMANCE OF THIS SOFTWARE. #include "site.h" #include "opaque.h" -#ifdef WIN32 -#include -#define getpid(x) _getpid(x) -#endif #ifdef NX_TRANS_SOCKET @@ -268,9 +264,7 @@ LogInit(const char *fname, const char *backup) if (saveBuffer && bufferSize > 0) { fwrite(saveBuffer, bufferPos, 1, logFile); fflush(logFile); -#ifndef WIN32 fsync(fileno(logFile)); -#endif } } @@ -398,10 +392,8 @@ LogVWrite(int verb, const char *f, va_list args) fwrite(tmpBuffer, len, 1, logFile); if (logFlush) { fflush(logFile); -#ifndef WIN32 if (logSync) fsync(fileno(logFile)); -#endif } } else if (needBuffer) { /* diff --git a/nx-X11/programs/Xserver/os/osdep.h b/nx-X11/programs/Xserver/os/osdep.h index 01ae7c3fb..5985cfef2 100644 --- a/nx-X11/programs/Xserver/os/osdep.h +++ b/nx-X11/programs/Xserver/os/osdep.h @@ -69,11 +69,6 @@ SOFTWARE. #undef _POSIX_SOURCE #endif #else /* X_NOT_POSIX */ -#ifdef WIN32 -#define _POSIX_ -#include -#undef _POSIX_ -#endif #endif /* X_NOT_POSIX */ #ifndef OPEN_MAX @@ -85,11 +80,7 @@ SOFTWARE. #if defined(NOFILE) && !defined(NOFILES_MAX) #define OPEN_MAX NOFILE #else -#if !defined(WIN32) #define OPEN_MAX NOFILES_MAX -#else -#define OPEN_MAX 256 -#endif #endif #endif #endif @@ -213,13 +204,7 @@ extern fd_set ClientsWriteBlocked; extern fd_set OutputPending; extern fd_set IgnoredClientsWithInput; -#ifndef WIN32 extern int *ConnectionTranslation; -#else -extern int GetConnectionTranslation(int conn); -extern void SetConnectionTranslation(int conn, int client); -extern void ClearConnectionTranslation(); -#endif extern Bool NewOutputPending; extern Bool AnyWritesPending; @@ -234,9 +219,6 @@ extern OsCommPtr AvailableInput; extern WorkQueuePtr workQueue; /* added by raphael */ -#ifdef WIN32 -typedef long int fd_mask; -#endif #define ffs mffs extern int mffs(fd_mask); diff --git a/nx-X11/programs/Xserver/os/osinit.c b/nx-X11/programs/Xserver/os/osinit.c index 4edbb73b0..823656316 100644 --- a/nx-X11/programs/Xserver/os/osinit.c +++ b/nx-X11/programs/Xserver/os/osinit.c @@ -66,7 +66,7 @@ SOFTWARE. #endif -#if !defined(SYSV) && !defined(WIN32) +#if !defined(SYSV) #include #endif @@ -131,7 +131,7 @@ OsInit(void) dup2 (fileno (err), 2); fclose (err); } -#if defined(SYSV) || defined(SVR4) || defined(WIN32) || defined(__CYGWIN__) +#if defined(SYSV) || defined(SVR4) || defined(__CYGWIN__) { static char buf[BUFSIZ]; setvbuf (stderr, buf, _IOLBF, BUFSIZ); @@ -145,7 +145,7 @@ OsInit(void) if (getpgrp () == 0) setpgid (0, 0); #else -#if !defined(SYSV) && !defined(WIN32) +#if !defined(SYSV) if (getpgrp (0) == 0) setpgrp (0, getpid ()); #endif diff --git a/nx-X11/programs/Xserver/os/utils.c b/nx-X11/programs/Xserver/os/utils.c index f7bce64ae..eed8cbf13 100644 --- a/nx-X11/programs/Xserver/os/utils.c +++ b/nx-X11/programs/Xserver/os/utils.c @@ -83,9 +83,6 @@ OR PERFORMANCE OF THIS SOFTWARE. #include #endif -#if defined(WIN32) && !defined(__CYGWIN__) -#include -#endif #include #include #include "misc.h" @@ -115,10 +112,8 @@ OR PERFORMANCE OF THIS SOFTWARE. #undef _POSIX_SOURCE #endif #endif -#ifndef WIN32 #include -#endif -#if !defined(SYSV) && !defined(WIN32) +#if !defined(SYSV) #include #endif #include @@ -132,9 +127,7 @@ OR PERFORMANCE OF THIS SOFTWARE. #include /* for malloc() */ #if defined(TCPCONN) -# ifndef WIN32 # include -# endif #endif #include "opaque.h" @@ -910,7 +903,7 @@ ProcessCommandLine(int argc, char *argv[]) #ifdef SERVER_LOCK else if ( strcmp ( argv[i], "-nolock") == 0) { -#if !defined(WIN32) && !defined(__CYGWIN__) +#if !defined(__CYGWIN__) if (getuid() != 0) ErrorF("Warning: the -nolock option can only be used by root\n"); else @@ -1230,7 +1223,7 @@ ExpandCommandLine(int *pargc, char ***pargv) { int i; -#if !defined(WIN32) && !defined(__CYGWIN__) +#if !defined(__CYGWIN__) if (getuid() != geteuid()) return; #endif @@ -1566,7 +1559,6 @@ OsReleaseSignals (void) #endif } -#if !defined(WIN32) /* * "safer" versions of system(3), popen(3) and pclose(3) which give up * all privs before running a command. @@ -1948,7 +1940,6 @@ Fclose(void * iop) #endif } -#endif /* !WIN32 */ /* @@ -1981,11 +1972,7 @@ Fclose(void * iop) /* Check args and env only if running setuid (euid == 0 && euid != uid) ? */ #ifndef CHECK_EUID -#ifndef WIN32 #define CHECK_EUID 1 -#else -#define CHECK_EUID 0 -#endif #endif /* diff --git a/nx-X11/programs/Xserver/os/xdmcp.c b/nx-X11/programs/Xserver/os/xdmcp.c index 3a077d8f4..8da1131ed 100644 --- a/nx-X11/programs/Xserver/os/xdmcp.c +++ b/nx-X11/programs/Xserver/os/xdmcp.c @@ -17,22 +17,13 @@ #include #endif -#ifdef WIN32 -#include -#define XSERV_t -#define TRANS_SERVER -#define TRANS_REOPEN -#include -#endif #include -#if !defined(WIN32) #include #include #include #include -#endif #include #include @@ -1506,9 +1497,6 @@ get_addr_by_name( struct hostent *hep; #ifdef XTHREADS_NEEDS_BYNAMEPARAMS _Xgethostbynameparams hparams; -#endif -#if defined(WIN32) && defined(TCPCONN) - _XSERVTransWSAStartup(); #endif if (!(hep = _XGethostbyname(namestr, hparams))) { -- cgit v1.2.3