aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/os
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-03-23 10:05:55 +0100
committermarha <marha@users.sourceforge.net>2012-03-23 10:05:55 +0100
commit0f834b91a4768673833ab4917e87d86c237bb1a6 (patch)
tree363489504ed4b2d360259b8de4c9e392918e5d02 /xorg-server/os
parentfc72edebf875378459368c5383d9023730cbca54 (diff)
downloadvcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.gz
vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.bz2
vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.zip
libX11 xserver fontconfig mesa pixman xkbcomp xkeyboard-config git update
23 Mar 2012
Diffstat (limited to 'xorg-server/os')
-rw-r--r--xorg-server/os/WaitFor.c607
-rw-r--r--xorg-server/os/access.c2000
-rw-r--r--xorg-server/os/auth.c323
-rw-r--r--xorg-server/os/backtrace.c235
-rw-r--r--xorg-server/os/client.c120
-rw-r--r--xorg-server/os/connection.c1045
-rw-r--r--xorg-server/os/io.c1201
-rw-r--r--xorg-server/os/log.c311
-rw-r--r--xorg-server/os/mitauth.c151
-rw-r--r--xorg-server/os/oscolor.c3058
-rw-r--r--xorg-server/os/osdep.h116
-rw-r--r--xorg-server/os/osinit.c285
-rw-r--r--xorg-server/os/rpcauth.c113
-rw-r--r--xorg-server/os/strlcpy.c35
-rw-r--r--xorg-server/os/utils.c1666
-rw-r--r--xorg-server/os/xdmauth.c516
-rw-r--r--xorg-server/os/xdmcp.c1644
-rw-r--r--xorg-server/os/xprintf.c41
-rw-r--r--xorg-server/os/xsha1.c363
-rw-r--r--xorg-server/os/xstrans.c4
20 files changed, 6777 insertions, 7057 deletions
diff --git a/xorg-server/os/WaitFor.c b/xorg-server/os/WaitFor.c
index 867cb04b8..95e64ba45 100644
--- a/xorg-server/os/WaitFor.c
+++ b/xorg-server/os/WaitFor.c
@@ -22,7 +22,6 @@ Except as contained in this notice, the name of The Open Group shall 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 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
@@ -45,7 +44,6 @@ SOFTWARE.
******************************************************************/
-
/*****************************************************************
* OS Dependent input routines:
*
@@ -61,7 +59,7 @@ SOFTWARE.
#ifdef WIN32
#include <X11/Xwinsock.h>
#endif
-#include <X11/Xos.h> /* for strings, fcntl, time */
+#include <X11/Xos.h> /* for strings, fcntl, time */
#include <errno.h>
#include <stdio.h>
#include <X11/X.h>
@@ -100,12 +98,12 @@ mffs(fd_mask mask)
{
int i;
- if (!mask) return 0;
+ if (!mask)
+ return 0;
i = 1;
- while (!(mask & 1))
- {
- i++;
- mask >>= 1;
+ while (!(mask & 1)) {
+ i++;
+ mask >>= 1;
}
return i;
}
@@ -115,11 +113,11 @@ mffs(fd_mask mask)
#endif
struct _OsTimerRec {
- OsTimerPtr next;
- CARD32 expires;
- CARD32 delta;
- OsTimerCallback callback;
- pointer arg;
+ OsTimerPtr next;
+ CARD32 expires;
+ CARD32 delta;
+ OsTimerCallback callback;
+ pointer arg;
};
static void DoTimer(OsTimerPtr timer, CARD32 now, OsTimerPtr *prev);
@@ -156,7 +154,7 @@ WaitForSomething(int *pClientsReady)
static int nready;
fd_set devicesReadable;
CARD32 now = 0;
- Bool someReady = FALSE;
+ Bool someReady = FALSE;
FD_ZERO(&clientsReadable);
@@ -166,229 +164,208 @@ WaitForSomething(int *pClientsReady)
/* We need a while loop here to handle
crashed connections and the screen saver timeout */
- while (1)
- {
- /* deal with any blocked jobs */
- if (workQueue)
- ProcessWorkQueue();
- if (XFD_ANYSET (&ClientsWithInput))
- {
- if (!SmartScheduleDisable)
- {
- someReady = TRUE;
- waittime.tv_sec = 0;
- waittime.tv_usec = 0;
- wt = &waittime;
- }
- else
- {
- XFD_COPYSET (&ClientsWithInput, &clientsReadable);
- break;
- }
- }
- if (someReady)
- {
- XFD_COPYSET(&AllSockets, &LastSelectMask);
- XFD_UNSET(&LastSelectMask, &ClientsWithInput);
- }
- else
- {
- wt = NULL;
- if (timers)
- {
- now = GetTimeInMillis();
- timeout = timers->expires - now;
- if (timeout > 0 && timeout > timers->delta + 250) {
- /* time has rewound. reset the timers. */
- CheckAllTimers();
+ while (1) {
+ /* deal with any blocked jobs */
+ if (workQueue)
+ ProcessWorkQueue();
+ if (XFD_ANYSET(&ClientsWithInput)) {
+ if (!SmartScheduleDisable) {
+ someReady = TRUE;
+ waittime.tv_sec = 0;
+ waittime.tv_usec = 0;
+ wt = &waittime;
+ }
+ else {
+ XFD_COPYSET(&ClientsWithInput, &clientsReadable);
+ break;
}
+ }
+ if (someReady) {
+ XFD_COPYSET(&AllSockets, &LastSelectMask);
+ XFD_UNSET(&LastSelectMask, &ClientsWithInput);
+ }
+ else {
+ wt = NULL;
+ if (timers) {
+ now = GetTimeInMillis();
+ timeout = timers->expires - now;
+ if (timeout > 0 && timeout > timers->delta + 250) {
+ /* time has rewound. reset the timers. */
+ CheckAllTimers();
+ }
+
+ if (timers) {
+ timeout = timers->expires - now;
+ if (timeout < 0)
+ timeout = 0;
+ waittime.tv_sec = timeout / MILLI_PER_SECOND;
+ waittime.tv_usec = (timeout % MILLI_PER_SECOND) *
+ (1000000 / MILLI_PER_SECOND);
+ wt = &waittime;
+ }
+ }
+ XFD_COPYSET(&AllSockets, &LastSelectMask);
+ }
- if (timers) {
- timeout = timers->expires - now;
- if (timeout < 0)
- timeout = 0;
- waittime.tv_sec = timeout / MILLI_PER_SECOND;
- waittime.tv_usec = (timeout % MILLI_PER_SECOND) *
- (1000000 / MILLI_PER_SECOND);
- wt = &waittime;
- }
- }
- XFD_COPYSET(&AllSockets, &LastSelectMask);
- }
-
- BlockHandler((pointer)&wt, (pointer)&LastSelectMask);
- if (NewOutputPending)
- FlushAllOutput();
- /* keep this check close to select() call to minimize race */
- if (dispatchException)
- i = -1;
- else if (AnyClientsWriteBlocked)
- {
- XFD_COPYSET(&ClientsWriteBlocked, &clientsWritable);
- i = Select (MaxClients, &LastSelectMask, &clientsWritable, NULL, wt);
- }
- else
- {
- i = Select (MaxClients, &LastSelectMask, NULL, NULL, wt);
- }
- selecterr = GetErrno();
- WakeupHandler(i, (pointer)&LastSelectMask);
- if (i <= 0) /* An error or timeout occurred */
- {
- if (dispatchException)
- return 0;
- if (i < 0)
- {
- if (selecterr == EBADF) /* Some client disconnected */
- {
- CheckConnections ();
- if (! XFD_ANYSET (&AllClients))
- return 0;
- }
- else if (selecterr == EINVAL)
- {
- FatalError("WaitForSomething(): select: %s\n",
- strerror(selecterr));
+ BlockHandler((pointer) &wt, (pointer) &LastSelectMask);
+ if (NewOutputPending)
+ FlushAllOutput();
+ /* keep this check close to select() call to minimize race */
+ if (dispatchException)
+ i = -1;
+ else if (AnyClientsWriteBlocked) {
+ XFD_COPYSET(&ClientsWriteBlocked, &clientsWritable);
+ i = Select(MaxClients, &LastSelectMask, &clientsWritable, NULL, wt);
+ }
+ else {
+ i = Select(MaxClients, &LastSelectMask, NULL, NULL, wt);
+ }
+ selecterr = GetErrno();
+ WakeupHandler(i, (pointer) &LastSelectMask);
+ if (i <= 0) { /* An error or timeout occurred */
+ if (dispatchException)
+ return 0;
+ if (i < 0) {
+ if (selecterr == EBADF) { /* Some client disconnected */
+ CheckConnections();
+ if (!XFD_ANYSET(&AllClients))
+ return 0;
+ }
+ else if (selecterr == EINVAL) {
+ FatalError("WaitForSomething(): select: %s\n",
+ strerror(selecterr));
+ }
+ else if (selecterr != EINTR && selecterr != EAGAIN) {
+ ErrorF("WaitForSomething(): select: %s\n",
+ strerror(selecterr));
+ }
+ }
+ else if (someReady) {
+ /*
+ * If no-one else is home, bail quickly
+ */
+ XFD_COPYSET(&ClientsWithInput, &LastSelectMask);
+ XFD_COPYSET(&ClientsWithInput, &clientsReadable);
+ break;
}
- else if (selecterr != EINTR && selecterr != EAGAIN)
- {
- ErrorF("WaitForSomething(): select: %s\n",
- strerror(selecterr));
- }
- }
- else if (someReady)
- {
- /*
- * If no-one else is home, bail quickly
- */
- XFD_COPYSET(&ClientsWithInput, &LastSelectMask);
- XFD_COPYSET(&ClientsWithInput, &clientsReadable);
- break;
- }
- if (*checkForInput[0] != *checkForInput[1])
- return 0;
-
- if (timers)
- {
+ if (*checkForInput[0] != *checkForInput[1])
+ return 0;
+
+ if (timers) {
int expired = 0;
- now = GetTimeInMillis();
- if ((int) (timers->expires - now) <= 0)
- expired = 1;
- while (timers && (int) (timers->expires - now) <= 0)
- DoTimer(timers, now, &timers);
+ now = GetTimeInMillis();
+ if ((int) (timers->expires - now) <= 0)
+ expired = 1;
+
+ while (timers && (int) (timers->expires - now) <= 0)
+ DoTimer(timers, now, &timers);
if (expired)
return 0;
- }
- }
- else
- {
- fd_set tmp_set;
-
- if (*checkForInput[0] == *checkForInput[1]) {
- if (timers)
- {
+ }
+ }
+ else {
+ fd_set tmp_set;
+
+ if (*checkForInput[0] == *checkForInput[1]) {
+ if (timers) {
int expired = 0;
- now = GetTimeInMillis();
- if ((int) (timers->expires - now) <= 0)
- expired = 1;
- while (timers && (int) (timers->expires - now) <= 0)
- DoTimer(timers, now, &timers);
+ now = GetTimeInMillis();
+ if ((int) (timers->expires - now) <= 0)
+ expired = 1;
+
+ while (timers && (int) (timers->expires - now) <= 0)
+ DoTimer(timers, now, &timers);
if (expired)
return 0;
- }
- }
- if (someReady)
- XFD_ORSET(&LastSelectMask, &ClientsWithInput, &LastSelectMask);
- if (AnyClientsWriteBlocked && XFD_ANYSET (&clientsWritable))
- {
- NewOutputPending = TRUE;
- XFD_ORSET(&OutputPending, &clientsWritable, &OutputPending);
- XFD_UNSET(&ClientsWriteBlocked, &clientsWritable);
- if (! XFD_ANYSET(&ClientsWriteBlocked))
- AnyClientsWriteBlocked = FALSE;
- }
-
- XFD_ANDSET(&devicesReadable, &LastSelectMask, &EnabledDevices);
- XFD_ANDSET(&clientsReadable, &LastSelectMask, &AllClients);
- XFD_ANDSET(&tmp_set, &LastSelectMask, &WellKnownConnections);
- if (XFD_ANYSET(&tmp_set))
- QueueWorkProc(EstablishNewConnections, NULL,
- (pointer)&LastSelectMask);
-
- if (XFD_ANYSET (&devicesReadable) || XFD_ANYSET (&clientsReadable))
- break;
- /* check here for DDXes that queue events during Block/Wakeup */
- if (*checkForInput[0] != *checkForInput[1])
- return 0;
- }
+ }
+ }
+ if (someReady)
+ XFD_ORSET(&LastSelectMask, &ClientsWithInput, &LastSelectMask);
+ if (AnyClientsWriteBlocked && XFD_ANYSET(&clientsWritable)) {
+ NewOutputPending = TRUE;
+ XFD_ORSET(&OutputPending, &clientsWritable, &OutputPending);
+ XFD_UNSET(&ClientsWriteBlocked, &clientsWritable);
+ if (!XFD_ANYSET(&ClientsWriteBlocked))
+ AnyClientsWriteBlocked = FALSE;
+ }
+
+ XFD_ANDSET(&devicesReadable, &LastSelectMask, &EnabledDevices);
+ XFD_ANDSET(&clientsReadable, &LastSelectMask, &AllClients);
+ XFD_ANDSET(&tmp_set, &LastSelectMask, &WellKnownConnections);
+ if (XFD_ANYSET(&tmp_set))
+ QueueWorkProc(EstablishNewConnections, NULL,
+ (pointer) &LastSelectMask);
+
+ if (XFD_ANYSET(&devicesReadable) || XFD_ANYSET(&clientsReadable))
+ break;
+ /* check here for DDXes that queue events during Block/Wakeup */
+ if (*checkForInput[0] != *checkForInput[1])
+ return 0;
+ }
}
nready = 0;
- if (XFD_ANYSET (&clientsReadable))
- {
+ if (XFD_ANYSET(&clientsReadable)) {
#ifndef WIN32
- for (i=0; i<howmany(XFD_SETSIZE, NFDBITS); i++)
- {
- int highest_priority = 0;
+ for (i = 0; i < howmany(XFD_SETSIZE, NFDBITS); i++) {
+ int highest_priority = 0;
- while (clientsReadable.fds_bits[i])
- {
- int client_priority, client_index;
+ while (clientsReadable.fds_bits[i]) {
+ int client_priority, client_index;
- curclient = mffs (clientsReadable.fds_bits[i]) - 1;
- client_index = /* raphael: modified */
- ConnectionTranslation[curclient + (i * (sizeof(fd_mask) * 8))];
+ curclient = mffs(clientsReadable.fds_bits[i]) - 1;
+ client_index = /* raphael: modified */
+ ConnectionTranslation[curclient +
+ (i * (sizeof(fd_mask) * 8))];
#else
- int highest_priority = 0;
- fd_set savedClientsReadable;
- XFD_COPYSET(&clientsReadable, &savedClientsReadable);
- for (i = 0; i < XFD_SETCOUNT(&savedClientsReadable); i++)
- {
- int client_priority, client_index;
-
- curclient = XFD_FD(&savedClientsReadable, i);
- client_index = GetConnectionTranslation(curclient);
+ int highest_priority = 0;
+ fd_set savedClientsReadable;
+
+ XFD_COPYSET(&clientsReadable, &savedClientsReadable);
+ for (i = 0; i < XFD_SETCOUNT(&savedClientsReadable); i++) {
+ int client_priority, client_index;
+
+ curclient = XFD_FD(&savedClientsReadable, i);
+ client_index = GetConnectionTranslation(curclient);
#endif
- /* We implement "strict" priorities.
- * Only the highest priority client is returned to
- * dix. If multiple clients at the same priority are
- * ready, they are all returned. This means that an
- * aggressive client could take over the server.
- * This was not considered a big problem because
- * aggressive clients can hose the server in so many
- * other ways :)
- */
- client_priority = clients[client_index]->priority;
- if (nready == 0 || client_priority > highest_priority)
- {
- /* Either we found the first client, or we found
- * a client whose priority is greater than all others
- * that have been found so far. Either way, we want
- * to initialize the list of clients to contain just
- * this client.
- */
- pClientsReady[0] = client_index;
- highest_priority = client_priority;
- nready = 1;
- }
- /* the following if makes sure that multiple same-priority
- * clients get batched together
- */
- else if (client_priority == highest_priority)
- {
- pClientsReady[nready++] = client_index;
- }
+ /* We implement "strict" priorities.
+ * Only the highest priority client is returned to
+ * dix. If multiple clients at the same priority are
+ * ready, they are all returned. This means that an
+ * aggressive client could take over the server.
+ * This was not considered a big problem because
+ * aggressive clients can hose the server in so many
+ * other ways :)
+ */
+ client_priority = clients[client_index]->priority;
+ if (nready == 0 || client_priority > highest_priority) {
+ /* Either we found the first client, or we found
+ * a client whose priority is greater than all others
+ * that have been found so far. Either way, we want
+ * to initialize the list of clients to contain just
+ * this client.
+ */
+ pClientsReady[0] = client_index;
+ highest_priority = client_priority;
+ nready = 1;
+ }
+ /* the following if makes sure that multiple same-priority
+ * clients get batched together
+ */
+ else if (client_priority == highest_priority) {
+ pClientsReady[nready++] = client_index;
+ }
#ifndef WIN32
- clientsReadable.fds_bits[i] &= ~(((fd_mask)1L) << curclient);
- }
+ clientsReadable.fds_bits[i] &= ~(((fd_mask) 1L) << curclient);
+ }
#else
- FD_CLR(curclient, &clientsReadable);
+ FD_CLR(curclient, &clientsReadable);
#endif
- }
+ }
}
if (nready)
@@ -405,7 +382,7 @@ CheckAllTimers(void)
OsTimerPtr timer;
CARD32 now;
-start:
+ start:
now = GetTimeInMillis();
for (timer = timers; timer; timer = timer->next) {
@@ -423,60 +400,54 @@ DoTimer(OsTimerPtr timer, CARD32 now, OsTimerPtr *prev)
*prev = timer->next;
timer->next = NULL;
- newTime = (*timer->callback)(timer, now, timer->arg);
+ newTime = (*timer->callback) (timer, now, timer->arg);
if (newTime)
- TimerSet(timer, 0, newTime, timer->callback, timer->arg);
+ TimerSet(timer, 0, newTime, timer->callback, timer->arg);
}
OsTimerPtr
-TimerSet(OsTimerPtr timer, int flags, CARD32 millis,
- OsTimerCallback func, pointer arg)
+TimerSet(OsTimerPtr timer, int flags, CARD32 millis,
+ OsTimerCallback func, pointer arg)
{
register OsTimerPtr *prev;
CARD32 now = GetTimeInMillis();
- if (!timer)
- {
- timer = malloc(sizeof(struct _OsTimerRec));
- if (!timer)
- return NULL;
+ if (!timer) {
+ timer = malloc(sizeof(struct _OsTimerRec));
+ if (!timer)
+ return NULL;
}
- else
- {
- for (prev = &timers; *prev; prev = &(*prev)->next)
- {
- if (*prev == timer)
- {
- *prev = timer->next;
- if (flags & TimerForceOld)
- (void)(*timer->callback)(timer, now, timer->arg);
- break;
- }
- }
+ else {
+ for (prev = &timers; *prev; prev = &(*prev)->next) {
+ if (*prev == timer) {
+ *prev = timer->next;
+ if (flags & TimerForceOld)
+ (void) (*timer->callback) (timer, now, timer->arg);
+ break;
+ }
+ }
}
if (!millis)
- return timer;
+ return timer;
if (flags & TimerAbsolute) {
timer->delta = millis - now;
}
else {
timer->delta = millis;
- millis += now;
+ millis += now;
}
timer->expires = millis;
timer->callback = func;
timer->arg = arg;
- if ((int) (millis - now) <= 0)
- {
- timer->next = NULL;
- millis = (*timer->callback)(timer, now, timer->arg);
- if (!millis)
- return timer;
+ if ((int) (millis - now) <= 0) {
+ timer->next = NULL;
+ millis = (*timer->callback) (timer, now, timer->arg);
+ if (!millis)
+ return timer;
}
for (prev = &timers;
- *prev && (int) ((*prev)->expires - millis) <= 0;
- prev = &(*prev)->next)
- ;
+ *prev && (int) ((*prev)->expires - millis) <= 0;
+ prev = &(*prev)->next);
timer->next = *prev;
*prev = timer;
return timer;
@@ -487,32 +458,27 @@ TimerForce(OsTimerPtr timer)
{
OsTimerPtr *prev;
- for (prev = &timers; *prev; prev = &(*prev)->next)
- {
- if (*prev == timer)
- {
- DoTimer(timer, GetTimeInMillis(), prev);
- return TRUE;
- }
+ for (prev = &timers; *prev; prev = &(*prev)->next) {
+ if (*prev == timer) {
+ DoTimer(timer, GetTimeInMillis(), prev);
+ return TRUE;
+ }
}
return FALSE;
}
-
void
TimerCancel(OsTimerPtr timer)
{
OsTimerPtr *prev;
if (!timer)
- return;
- for (prev = &timers; *prev; prev = &(*prev)->next)
- {
- if (*prev == timer)
- {
- *prev = timer->next;
- break;
- }
+ return;
+ for (prev = &timers; *prev; prev = &(*prev)->next) {
+ if (*prev == timer) {
+ *prev = timer->next;
+ break;
+ }
}
}
@@ -520,7 +486,7 @@ void
TimerFree(OsTimerPtr timer)
{
if (!timer)
- return;
+ return;
TimerCancel(timer);
free(timer);
}
@@ -531,7 +497,7 @@ TimerCheck(void)
CARD32 now = GetTimeInMillis();
while (timers && (int) (timers->expires - now) <= 0)
- DoTimer(timers, now, &timers);
+ DoTimer(timers, now, &timers);
}
void
@@ -539,10 +505,9 @@ TimerInit(void)
{
OsTimerPtr timer;
- while ((timer = timers))
- {
- timers = timer->next;
- free(timer);
+ while ((timer = timers)) {
+ timers = timer->next;
+ free(timer);
}
}
@@ -563,27 +528,26 @@ NextDPMSTimeout(INT32 timeout)
* Return the amount of time remaining until we should set
* the next power level. Fallthroughs are intentional.
*/
- switch (DPMSPowerLevel)
- {
- case DPMSModeOn:
- DPMS_CHECK_TIMEOUT(DPMSStandbyTime)
+ switch (DPMSPowerLevel) {
+ case DPMSModeOn:
+ DPMS_CHECK_TIMEOUT(DPMSStandbyTime)
- case DPMSModeStandby:
- DPMS_CHECK_TIMEOUT(DPMSSuspendTime)
+ case DPMSModeStandby:
+ DPMS_CHECK_TIMEOUT(DPMSSuspendTime)
- case DPMSModeSuspend:
- DPMS_CHECK_TIMEOUT(DPMSOffTime)
+ case DPMSModeSuspend:
+ DPMS_CHECK_TIMEOUT(DPMSOffTime)
- default: /* DPMSModeOff */
- return 0;
+ default: /* DPMSModeOff */
+ return 0;
}
}
-#endif /* DPMSExtension */
+#endif /* DPMSExtension */
static CARD32
-ScreenSaverTimeoutExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+ScreenSaverTimeoutExpire(OsTimerPtr timer, CARD32 now, pointer arg)
{
- INT32 timeout = now - lastDeviceEventTime.milliseconds;
+ INT32 timeout = now - lastDeviceEventTime[XIAllDevices].milliseconds;
CARD32 nextTimeout = 0;
#ifdef DPMSExtension
@@ -591,13 +555,12 @@ ScreenSaverTimeoutExpire(OsTimerPtr timer,CARD32 now,pointer arg)
* Check each mode lowest to highest, since a lower mode can
* have the same timeout as a higher one.
*/
- if (DPMSEnabled)
- {
- DPMS_CHECK_MODE(DPMSModeOff, DPMSOffTime)
- DPMS_CHECK_MODE(DPMSModeSuspend, DPMSSuspendTime)
- DPMS_CHECK_MODE(DPMSModeStandby, DPMSStandbyTime)
+ if (DPMSEnabled) {
+ DPMS_CHECK_MODE(DPMSModeOff, DPMSOffTime)
+ DPMS_CHECK_MODE(DPMSModeSuspend, DPMSSuspendTime)
+ DPMS_CHECK_MODE(DPMSModeStandby, DPMSStandbyTime)
- nextTimeout = NextDPMSTimeout(timeout);
+ nextTimeout = NextDPMSTimeout(timeout);
}
/*
@@ -605,27 +568,24 @@ ScreenSaverTimeoutExpire(OsTimerPtr timer,CARD32 now,pointer arg)
* power saving mode
*/
if (DPMSPowerLevel != DPMSModeOn)
- return nextTimeout;
-#endif /* DPMSExtension */
+ return nextTimeout;
+#endif /* DPMSExtension */
if (!ScreenSaverTime)
- return nextTimeout;
+ return nextTimeout;
- if (timeout < ScreenSaverTime)
- {
- return nextTimeout > 0 ?
- min(ScreenSaverTime - timeout, nextTimeout) :
- ScreenSaverTime - timeout;
+ if (timeout < ScreenSaverTime) {
+ return nextTimeout > 0 ?
+ min(ScreenSaverTime - timeout, nextTimeout) :
+ ScreenSaverTime - timeout;
}
- ResetOsBuffers(); /* not ideal, but better than nothing */
+ ResetOsBuffers(); /* not ideal, but better than nothing */
dixSaveScreens(serverClient, SCREEN_SAVER_ON, ScreenSaverActive);
- if (ScreenSaverInterval > 0)
- {
- nextTimeout = nextTimeout > 0 ?
- min(ScreenSaverInterval, nextTimeout) :
- ScreenSaverInterval;
+ if (ScreenSaverInterval > 0) {
+ nextTimeout = nextTimeout > 0 ?
+ min(ScreenSaverInterval, nextTimeout) : ScreenSaverInterval;
}
return nextTimeout;
@@ -637,8 +597,8 @@ void
FreeScreenSaverTimer(void)
{
if (ScreenSaverTimer) {
- TimerFree(ScreenSaverTimer);
- ScreenSaverTimer = NULL;
+ TimerFree(ScreenSaverTimer);
+ ScreenSaverTimer = NULL;
}
}
@@ -648,28 +608,24 @@ SetScreenSaverTimer(void)
CARD32 timeout = 0;
#ifdef DPMSExtension
- if (DPMSEnabled)
- {
- /*
- * A higher DPMS level has a timeout that's either less
- * than or equal to that of a lower DPMS level.
- */
- if (DPMSStandbyTime > 0)
- timeout = DPMSStandbyTime;
-
- else if (DPMSSuspendTime > 0)
- timeout = DPMSSuspendTime;
-
- else if (DPMSOffTime > 0)
- timeout = DPMSOffTime;
+ if (DPMSEnabled) {
+ /*
+ * A higher DPMS level has a timeout that's either less
+ * than or equal to that of a lower DPMS level.
+ */
+ if (DPMSStandbyTime > 0)
+ timeout = DPMSStandbyTime;
+
+ else if (DPMSSuspendTime > 0)
+ timeout = DPMSSuspendTime;
+
+ else if (DPMSOffTime > 0)
+ timeout = DPMSOffTime;
}
#endif
- if (ScreenSaverTime > 0)
- {
- timeout = timeout > 0 ?
- min(ScreenSaverTime, timeout) :
- ScreenSaverTime;
+ if (ScreenSaverTime > 0) {
+ timeout = timeout > 0 ? min(ScreenSaverTime, timeout) : ScreenSaverTime;
}
#ifdef SCREENSAVER
@@ -677,11 +633,10 @@ SetScreenSaverTimer(void)
#else
if (timeout) {
#endif
- ScreenSaverTimer = TimerSet(ScreenSaverTimer, 0, timeout,
- ScreenSaverTimeoutExpire, NULL);
+ ScreenSaverTimer = TimerSet(ScreenSaverTimer, 0, timeout,
+ ScreenSaverTimeoutExpire, NULL);
}
else if (ScreenSaverTimer) {
- FreeScreenSaverTimer();
+ FreeScreenSaverTimer();
}
}
-
diff --git a/xorg-server/os/access.c b/xorg-server/os/access.c
index b609442de..550f2ed8c 100644
--- a/xorg-server/os/access.c
+++ b/xorg-server/os/access.c
@@ -102,28 +102,28 @@ SOFTWARE.
#include <sys/ioctl.h>
#include <ctype.h>
-#if defined(TCPCONN) || defined(STREAMSCONN)
+#if defined(TCPCONN) || defined(STREAMSCONN)
#include <netinet/in.h>
-#endif /* TCPCONN || STREAMSCONN */
+#endif /* TCPCONN || STREAMSCONN */
#ifdef HAVE_GETPEERUCRED
-# include <ucred.h>
-# ifdef sun
-# include <zone.h>
-# endif
+#include <ucred.h>
+#ifdef sun
+#include <zone.h>
+#endif
#endif
#if defined(SVR4) || (defined(SYSV) && defined(__i386__)) || defined(__GNU__)
-# include <sys/utsname.h>
+#include <sys/utsname.h>
#endif
#if defined(SYSV) && defined(__i386__)
-# include <sys/stream.h>
+#include <sys/stream.h>
#endif
#ifdef __GNU__
#undef SIOCGIFCONF
#include <netdb.h>
-#else /*!__GNU__*/
-# include <net/if.h>
+#else /*!__GNU__ */
+#include <net/if.h>
#endif /*__GNU__ */
#ifdef SVR4
@@ -163,8 +163,7 @@ SOFTWARE.
/* #endif */
#endif
-#endif /* WIN32 */
-
+#endif /* WIN32 */
#define X_INCLUDE_NETDB_H
#include <X11/Xos_r.h>
@@ -181,18 +180,18 @@ Bool defeatAccessControl = FALSE;
(length) == (host)->len &&\
!memcmp (address, (host)->addr, length))
-static int ConvertAddr(struct sockaddr * /*saddr*/,
- int * /*len*/,
- pointer * /*addr*/);
+static int ConvertAddr(struct sockaddr * /*saddr */ ,
+ int * /*len */ ,
+ pointer * /*addr */ );
-static int CheckAddr(int /*family*/,
- const void * /*pAddr*/,
- unsigned /*length*/);
+static int CheckAddr(int /*family */ ,
+ const void * /*pAddr */ ,
+ unsigned /*length */ );
-static Bool NewHost(int /*family*/,
- const void * /*addr*/,
- int /*len*/,
- int /* addingLocalHosts */);
+static Bool NewHost(int /*family */ ,
+ const void * /*addr */ ,
+ int /*len */ ,
+ int /* addingLocalHosts */ );
/* XFree86 bug #156: To keep track of which hosts were explicitly requested in
/etc/X<display>.hosts, we've added a requested field to the HOST struct,
@@ -202,11 +201,11 @@ static Bool NewHost(int /*family*/,
local host entries when stronger authentication is turned on. */
typedef struct _host {
- short family;
- short len;
- unsigned char *addr;
- struct _host *next;
- int requested;
+ short family;
+ short len;
+ unsigned char *addr;
+ struct _host *next;
+ int requested;
} HOST;
#define MakeHost(h,l) (h)=malloc(sizeof *(h)+(l));\
@@ -223,9 +222,9 @@ static int LocalHostRequested = FALSE;
static int UsingXdmcp = FALSE;
/* FamilyServerInterpreted implementation */
-static Bool siAddrMatch(int family, pointer addr, int len, HOST *host,
- ClientPtr client);
-static int siCheckAddr(const char *addrString, int length);
+static Bool siAddrMatch(int family, pointer addr, int len, HOST * host,
+ ClientPtr client);
+static int siCheckAddr(const char *addrString, int length);
static void siTypesInitialize(void);
/*
@@ -234,12 +233,11 @@ static void siTypesInitialize(void);
*/
void
-EnableLocalHost (void)
+EnableLocalHost(void)
{
- if (!UsingXdmcp)
- {
- LocalHostEnabled = TRUE;
- AddLocalHosts ();
+ if (!UsingXdmcp) {
+ LocalHostEnabled = TRUE;
+ AddLocalHosts();
}
}
@@ -247,15 +245,16 @@ EnableLocalHost (void)
* called when authorization is enabled to keep us secure
*/
void
-DisableLocalHost (void)
+DisableLocalHost(void)
{
HOST *self;
- if (!LocalHostRequested) /* Fix for XFree86 bug #156 */
- LocalHostEnabled = FALSE;
+ if (!LocalHostRequested) /* Fix for XFree86 bug #156 */
+ LocalHostEnabled = FALSE;
for (self = selfhosts; self; self = self->next) {
- if (!self->requested) /* Fix for XFree86 bug #156 */
- (void) RemoveHost ((ClientPtr)NULL, self->family, self->len, (pointer)self->addr);
+ if (!self->requested) /* Fix for XFree86 bug #156 */
+ (void) RemoveHost((ClientPtr) NULL, self->family, self->len,
+ (pointer) self->addr);
}
}
@@ -265,19 +264,18 @@ DisableLocalHost (void)
*/
void
-AccessUsingXdmcp (void)
+AccessUsingXdmcp(void)
{
UsingXdmcp = TRUE;
LocalHostEnabled = FALSE;
}
-
#if defined(SVR4) && !defined(sun) && defined(SIOCGIFCONF) && !defined(USE_SIOCGLIFCONF)
/* Deal with different SIOCGIFCONF ioctl semantics on these OSs */
static int
-ifioctl (int fd, int cmd, char *arg)
+ifioctl(int fd, int cmd, char *arg)
{
struct strioctl ioc;
int ret;
@@ -285,20 +283,18 @@ ifioctl (int fd, int cmd, char *arg)
memset((char *) &ioc, 0, sizeof(ioc));
ioc.ic_cmd = cmd;
ioc.ic_timout = 0;
- if (cmd == SIOCGIFCONF)
- {
- ioc.ic_len = ((struct ifconf *) arg)->ifc_len;
- ioc.ic_dp = ((struct ifconf *) arg)->ifc_buf;
+ if (cmd == SIOCGIFCONF) {
+ ioc.ic_len = ((struct ifconf *) arg)->ifc_len;
+ ioc.ic_dp = ((struct ifconf *) arg)->ifc_buf;
}
- else
- {
- ioc.ic_len = sizeof(struct ifreq);
- ioc.ic_dp = arg;
+ else {
+ ioc.ic_len = sizeof(struct ifreq);
+ ioc.ic_dp = arg;
}
ret = ioctl(fd, I_STR, (char *) &ioc);
if (ret >= 0 && cmd == SIOCGIFCONF)
#ifdef SVR4
- ((struct ifconf *) arg)->ifc_len = ioc.ic_len;
+ ((struct ifconf *) arg)->ifc_len = ioc.ic_len;
#endif
return ret;
}
@@ -313,40 +309,41 @@ ifioctl (int fd, int cmd, char *arg)
* for this fd and add them to the selfhosts list.
*/
-#if !defined(SIOCGIFCONF)
+#if !defined(SIOCGIFCONF)
void
-DefineSelf (int fd)
+DefineSelf(int fd)
{
#if !defined(TCPCONN) && !defined(STREAMSCONN) && !defined(UNIXCONN)
return;
#else
register int n;
- int len;
- caddr_t addr;
- int family;
- register HOST *host;
+ int len;
+ caddr_t addr;
+ int family;
+ register HOST *host;
#ifndef WIN32
struct utsname name;
#else
struct {
- char nodename[512];
+ char nodename[512];
} name;
#endif
- register struct hostent *hp;
+ register struct hostent *hp;
union {
- struct sockaddr sa;
- struct sockaddr_in in;
+ struct sockaddr sa;
+ struct sockaddr_in in;
#if defined(IPv6) && defined(AF_INET6)
- struct sockaddr_in6 in6;
+ struct sockaddr_in6 in6;
#endif
} saddr;
-
- struct sockaddr_in *inetaddr;
- struct sockaddr_in6 *inet6addr;
+
+ struct sockaddr_in *inetaddr;
+ struct sockaddr_in6 *inet6addr;
struct sockaddr_in broad_addr;
+
#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
_Xgethostbynameparams hparams;
#endif
@@ -363,95 +360,86 @@ DefineSelf (int fd)
#endif
hp = _XGethostbyname(name.nodename, hparams);
- if (hp != NULL)
- {
- saddr.sa.sa_family = hp->h_addrtype;
- switch (hp->h_addrtype) {
- case AF_INET:
- inetaddr = (struct sockaddr_in *) (&(saddr.sa));
- memcpy ( &(inetaddr->sin_addr), hp->h_addr, hp->h_length);
- len = sizeof(saddr.sa);
- break;
+ if (hp != NULL) {
+ saddr.sa.sa_family = hp->h_addrtype;
+ switch (hp->h_addrtype) {
+ case AF_INET:
+ inetaddr = (struct sockaddr_in *) (&(saddr.sa));
+ memcpy(&(inetaddr->sin_addr), hp->h_addr, hp->h_length);
+ len = sizeof(saddr.sa);
+ break;
#if defined(IPv6) && defined(AF_INET6)
- case AF_INET6:
- inet6addr = (struct sockaddr_in6 *) (&(saddr.sa));
- memcpy ( &(inet6addr->sin6_addr), hp->h_addr, hp->h_length);
- len = sizeof(saddr.in6);
- break;
-#endif
- default:
- goto DefineLocalHost;
- }
- family = ConvertAddr ( &(saddr.sa), &len, (pointer *)&addr);
- if ( family != -1 && family != FamilyLocal )
- {
- for (host = selfhosts;
- host && !addrEqual (family, addr, len, host);
- host = host->next) ;
- if (!host)
- {
- /* add this host to the host list. */
- MakeHost(host,len)
- if (host)
- {
- host->family = family;
- host->len = len;
- memcpy ( host->addr, addr, len);
- host->next = selfhosts;
- selfhosts = host;
- }
+ case AF_INET6:
+ inet6addr = (struct sockaddr_in6 *) (&(saddr.sa));
+ memcpy(&(inet6addr->sin6_addr), hp->h_addr, hp->h_length);
+ len = sizeof(saddr.in6);
+ break;
+#endif
+ default:
+ goto DefineLocalHost;
+ }
+ family = ConvertAddr(&(saddr.sa), &len, (pointer *) &addr);
+ if (family != -1 && family != FamilyLocal) {
+ for (host = selfhosts;
+ host && !addrEqual(family, addr, len, host);
+ host = host->next);
+ if (!host) {
+ /* add this host to the host list. */
+ MakeHost(host, len)
+ if (host) {
+ host->family = family;
+ host->len = len;
+ memcpy(host->addr, addr, len);
+ host->next = selfhosts;
+ selfhosts = host;
+ }
#ifdef XDMCP
- /*
- * If this is an Internet Address, but not the localhost
- * address (127.0.0.1), nor the bogus address (0.0.0.0),
- * register it.
- */
- if (family == FamilyInternet &&
- !(len == 4 &&
- ((addr[0] == 127) ||
- (addr[0] == 0 && addr[1] == 0 &&
- addr[2] == 0 && addr[3] == 0)))
- )
- {
- XdmcpRegisterConnection (family, (char *)addr, len);
- broad_addr = *inetaddr;
- ((struct sockaddr_in *) &broad_addr)->sin_addr.s_addr =
- htonl (INADDR_BROADCAST);
- XdmcpRegisterBroadcastAddress ((struct sockaddr_in *)
- &broad_addr);
- }
+ /*
+ * If this is an Internet Address, but not the localhost
+ * address (127.0.0.1), nor the bogus address (0.0.0.0),
+ * register it.
+ */
+ if (family == FamilyInternet &&
+ !(len == 4 &&
+ ((addr[0] == 127) ||
+ (addr[0] == 0 && addr[1] == 0 &&
+ addr[2] == 0 && addr[3] == 0)))
+ ) {
+ XdmcpRegisterConnection(family, (char *) addr, len);
+ broad_addr = *inetaddr;
+ ((struct sockaddr_in *) &broad_addr)->sin_addr.s_addr =
+ htonl(INADDR_BROADCAST);
+ XdmcpRegisterBroadcastAddress((struct sockaddr_in *)
+ &broad_addr);
+ }
#if defined(IPv6) && defined(AF_INET6)
- else if (family == FamilyInternet6 &&
- !(IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr)))
- {
- XdmcpRegisterConnection (family, (char *)addr, len);
- }
+ else if (family == FamilyInternet6 &&
+ !(IN6_IS_ADDR_LOOPBACK((struct in6_addr *) addr))) {
+ XdmcpRegisterConnection(family, (char *) addr, len);
+ }
#endif
-#endif /* XDMCP */
- }
- }
+#endif /* XDMCP */
+ }
+ }
}
/*
* now add a host of family FamilyLocalHost...
*/
-DefineLocalHost:
+ DefineLocalHost:
for (host = selfhosts;
- host && !addrEqual(FamilyLocalHost, "", 0, host);
- host = host->next);
- if (!host)
- {
- MakeHost(host, 0);
- if (host)
- {
- host->family = FamilyLocalHost;
- host->len = 0;
- /* Nothing to store in host->addr */
- host->next = selfhosts;
- selfhosts = host;
- }
+ host && !addrEqual(FamilyLocalHost, "", 0, host); host = host->next);
+ if (!host) {
+ MakeHost(host, 0);
+ if (host) {
+ host->family = FamilyLocalHost;
+ host->len = 0;
+ /* Nothing to store in host->addr */
+ host->next = selfhosts;
+ selfhosts = host;
+ }
}
-#endif /* !TCPCONN && !STREAMSCONN && !UNIXCONN */
+#endif /* !TCPCONN && !STREAMSCONN && !UNIXCONN */
}
#else
@@ -481,58 +469,60 @@ static void
in6_fillscopeid(struct sockaddr_in6 *sin6)
{
#if defined(__KAME__)
- if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
- sin6->sin6_scope_id =
- ntohs(*(u_int16_t *)&sin6->sin6_addr.s6_addr[2]);
- sin6->sin6_addr.s6_addr[2] = sin6->sin6_addr.s6_addr[3] = 0;
- }
+ if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
+ sin6->sin6_scope_id =
+ ntohs(*(u_int16_t *) & sin6->sin6_addr.s6_addr[2]);
+ sin6->sin6_addr.s6_addr[2] = sin6->sin6_addr.s6_addr[3] = 0;
+ }
#endif
}
#endif
void
-DefineSelf (int fd)
+DefineSelf(int fd)
{
#ifndef HAVE_GETIFADDRS
- char *cp, *cplim;
-# ifdef USE_SIOCGLIFCONF
+ char *cp, *cplim;
+
+#ifdef USE_SIOCGLIFCONF
struct sockaddr_storage buf[16];
- struct lifconf ifc;
+ struct lifconf ifc;
register struct lifreq *ifr;
-# ifdef SIOCGLIFNUM
- struct lifnum ifn;
-# endif
-# else /* !USE_SIOCGLIFCONF */
- char buf[2048];
- struct ifconf ifc;
+
+#ifdef SIOCGLIFNUM
+ struct lifnum ifn;
+#endif
+#else /* !USE_SIOCGLIFCONF */
+ char buf[2048];
+ struct ifconf ifc;
register struct ifreq *ifr;
-# endif
- void * bufptr = buf;
-#else /* HAVE_GETIFADDRS */
- struct ifaddrs * ifap, *ifr;
-#endif
- int len;
- unsigned char * addr;
- int family;
- register HOST *host;
-
+#endif
+ void *bufptr = buf;
+#else /* HAVE_GETIFADDRS */
+ struct ifaddrs *ifap, *ifr;
+#endif
+ int len;
+ unsigned char *addr;
+ int family;
+ register HOST *host;
+
#ifndef HAVE_GETIFADDRS
len = sizeof(buf);
#ifdef USE_SIOCGLIFCONF
-
+
#ifdef SIOCGLIFNUM
ifn.lifn_family = AF_UNSPEC;
ifn.lifn_flags = 0;
- if (ioctl (fd, SIOCGLIFNUM, (char *) &ifn) < 0)
- ErrorF ("Getting interface count: %s\n", strerror(errno));
+ if (ioctl(fd, SIOCGLIFNUM, (char *) &ifn) < 0)
+ ErrorF("Getting interface count: %s\n", strerror(errno));
if (len < (ifn.lifn_count * sizeof(struct lifreq))) {
- len = ifn.lifn_count * sizeof(struct lifreq);
- bufptr = malloc(len);
+ len = ifn.lifn_count * sizeof(struct lifreq);
+ bufptr = malloc(len);
}
#endif
-
+
ifc.lifc_family = AF_UNSPEC;
ifc.lifc_flags = 0;
ifc.lifc_len = len;
@@ -544,7 +534,7 @@ DefineSelf (int fd)
#define IFR_IFR_ADDR ifr->lifr_addr
#define IFR_IFR_NAME ifr->lifr_name
-#else /* Use SIOCGIFCONF */
+#else /* Use SIOCGIFCONF */
ifc.ifc_len = len;
ifc.ifc_buf = bufptr;
@@ -555,248 +545,233 @@ DefineSelf (int fd)
#define IFR_IFR_NAME ifr->ifr_name
#endif
- if (ifioctl (fd, IFC_IOCTL_REQ, (pointer) &ifc) < 0)
- ErrorF ("Getting interface configuration (4): %s\n", strerror(errno));
+ if (ifioctl(fd, IFC_IOCTL_REQ, (pointer) &ifc) < 0)
+ ErrorF("Getting interface configuration (4): %s\n", strerror(errno));
cplim = (char *) IFC_IFC_REQ + IFC_IFC_LEN;
-
- for (cp = (char *) IFC_IFC_REQ; cp < cplim; cp += ifr_size (ifr))
- {
- ifr = (ifr_type *) cp;
- len = ifraddr_size (IFR_IFR_ADDR);
- family = ConvertAddr ((struct sockaddr *) &IFR_IFR_ADDR,
- &len, (pointer *)&addr);
+
+ for (cp = (char *) IFC_IFC_REQ; cp < cplim; cp += ifr_size(ifr)) {
+ ifr = (ifr_type *) cp;
+ len = ifraddr_size(IFR_IFR_ADDR);
+ family = ConvertAddr((struct sockaddr *) &IFR_IFR_ADDR,
+ &len, (pointer *) &addr);
if (family == -1 || family == FamilyLocal)
- continue;
+ continue;
#if defined(IPv6) && defined(AF_INET6)
- if (family == FamilyInternet6)
- in6_fillscopeid((struct sockaddr_in6 *)&IFR_IFR_ADDR);
+ if (family == FamilyInternet6)
+ in6_fillscopeid((struct sockaddr_in6 *) &IFR_IFR_ADDR);
#endif
for (host = selfhosts;
- host && !addrEqual (family, addr, len, host);
- host = host->next)
- ;
+ host && !addrEqual(family, addr, len, host); host = host->next);
if (host)
- continue;
- MakeHost(host,len)
- if (host)
- {
- host->family = family;
- host->len = len;
- memcpy(host->addr, addr, len);
- host->next = selfhosts;
- selfhosts = host;
- }
+ continue;
+ MakeHost(host, len)
+ if (host) {
+ host->family = family;
+ host->len = len;
+ memcpy(host->addr, addr, len);
+ host->next = selfhosts;
+ selfhosts = host;
+ }
#ifdef XDMCP
- {
+ {
#ifdef USE_SIOCGLIFCONF
- struct sockaddr_storage broad_addr;
+ struct sockaddr_storage broad_addr;
#else
- struct sockaddr broad_addr;
+ struct sockaddr broad_addr;
#endif
- /*
- * If this isn't an Internet Address, don't register it.
- */
- if (family != FamilyInternet
+ /*
+ * If this isn't an Internet Address, don't register it.
+ */
+ if (family != FamilyInternet
#if defined(IPv6) && defined(AF_INET6)
- && family != FamilyInternet6
-#endif
- )
- continue;
-
- /*
- * ignore 'localhost' entries as they're not useful
- * on the other end of the wire
- */
- if (family == FamilyInternet &&
- addr[0] == 127 && addr[1] == 0 &&
- addr[2] == 0 && addr[3] == 1)
- continue;
+ && family != FamilyInternet6
+#endif
+ )
+ continue;
+
+ /*
+ * ignore 'localhost' entries as they're not useful
+ * on the other end of the wire
+ */
+ if (family == FamilyInternet &&
+ addr[0] == 127 && addr[1] == 0 && addr[2] == 0 && addr[3] == 1)
+ continue;
#if defined(IPv6) && defined(AF_INET6)
- else if (family == FamilyInternet6 &&
- IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr))
- continue;
+ else if (family == FamilyInternet6 &&
+ IN6_IS_ADDR_LOOPBACK((struct in6_addr *) addr))
+ continue;
#endif
- /*
- * Ignore '0.0.0.0' entries as they are
- * returned by some OSes for unconfigured NICs but they are
- * not useful on the other end of the wire.
- */
- if (len == 4 &&
- addr[0] == 0 && addr[1] == 0 &&
- addr[2] == 0 && addr[3] == 0)
- continue;
+ /*
+ * Ignore '0.0.0.0' entries as they are
+ * returned by some OSes for unconfigured NICs but they are
+ * not useful on the other end of the wire.
+ */
+ if (len == 4 &&
+ addr[0] == 0 && addr[1] == 0 && addr[2] == 0 && addr[3] == 0)
+ continue;
- XdmcpRegisterConnection (family, (char *)addr, len);
+ XdmcpRegisterConnection(family, (char *) addr, len);
#if defined(IPv6) && defined(AF_INET6)
- /* IPv6 doesn't support broadcasting, so we drop out here */
- if (family == FamilyInternet6)
- continue;
+ /* IPv6 doesn't support broadcasting, so we drop out here */
+ if (family == FamilyInternet6)
+ continue;
#endif
- broad_addr = IFR_IFR_ADDR;
+ broad_addr = IFR_IFR_ADDR;
- ((struct sockaddr_in *) &broad_addr)->sin_addr.s_addr =
- htonl (INADDR_BROADCAST);
+ ((struct sockaddr_in *) &broad_addr)->sin_addr.s_addr =
+ htonl(INADDR_BROADCAST);
#if defined(USE_SIOCGLIFCONF) && defined(SIOCGLIFBRDADDR)
- {
- struct lifreq broad_req;
-
- broad_req = *ifr;
- if (ioctl (fd, SIOCGLIFFLAGS, (char *) &broad_req) != -1 &&
- (broad_req.lifr_flags & IFF_BROADCAST) &&
- (broad_req.lifr_flags & IFF_UP)
- )
- {
- broad_req = *ifr;
- if (ioctl (fd, SIOCGLIFBRDADDR, &broad_req) != -1)
- broad_addr = broad_req.lifr_broadaddr;
- else
- continue;
- }
- else
- continue;
- }
+ {
+ struct lifreq broad_req;
+
+ broad_req = *ifr;
+ if (ioctl(fd, SIOCGLIFFLAGS, (char *) &broad_req) != -1 &&
+ (broad_req.lifr_flags & IFF_BROADCAST) &&
+ (broad_req.lifr_flags & IFF_UP)
+ ) {
+ broad_req = *ifr;
+ if (ioctl(fd, SIOCGLIFBRDADDR, &broad_req) != -1)
+ broad_addr = broad_req.lifr_broadaddr;
+ else
+ continue;
+ }
+ else
+ continue;
+ }
#elif defined(SIOCGIFBRDADDR)
- {
- struct ifreq broad_req;
-
- broad_req = *ifr;
- if (ifioctl (fd, SIOCGIFFLAGS, (pointer) &broad_req) != -1 &&
- (broad_req.ifr_flags & IFF_BROADCAST) &&
- (broad_req.ifr_flags & IFF_UP)
- )
- {
- broad_req = *ifr;
- if (ifioctl (fd, SIOCGIFBRDADDR, (pointer) &broad_req) != -1)
- broad_addr = broad_req.ifr_addr;
- else
- continue;
- }
- else
- continue;
- }
-#endif /* SIOCGIFBRDADDR */
- XdmcpRegisterBroadcastAddress ((struct sockaddr_in *) &broad_addr);
- }
-#endif /* XDMCP */
+ {
+ struct ifreq broad_req;
+
+ broad_req = *ifr;
+ if (ifioctl(fd, SIOCGIFFLAGS, (pointer) &broad_req) != -1 &&
+ (broad_req.ifr_flags & IFF_BROADCAST) &&
+ (broad_req.ifr_flags & IFF_UP)
+ ) {
+ broad_req = *ifr;
+ if (ifioctl(fd, SIOCGIFBRDADDR, (pointer) &broad_req) != -1)
+ broad_addr = broad_req.ifr_addr;
+ else
+ continue;
+ }
+ else
+ continue;
+ }
+#endif /* SIOCGIFBRDADDR */
+ XdmcpRegisterBroadcastAddress((struct sockaddr_in *) &broad_addr);
+ }
+#endif /* XDMCP */
}
if (bufptr != buf)
- free(bufptr);
-#else /* HAVE_GETIFADDRS */
+ free(bufptr);
+#else /* HAVE_GETIFADDRS */
if (getifaddrs(&ifap) < 0) {
- ErrorF("Warning: getifaddrs returns %s\n", strerror(errno));
- return;
+ ErrorF("Warning: getifaddrs returns %s\n", strerror(errno));
+ return;
}
for (ifr = ifap; ifr != NULL; ifr = ifr->ifa_next) {
if (!ifr->ifa_addr)
continue;
- len = sizeof(*(ifr->ifa_addr));
- family = ConvertAddr((struct sockaddr *) ifr->ifa_addr, &len,
- (pointer *)&addr);
- if (family == -1 || family == FamilyLocal)
- continue;
+ len = sizeof(*(ifr->ifa_addr));
+ family = ConvertAddr((struct sockaddr *) ifr->ifa_addr, &len,
+ (pointer *) &addr);
+ if (family == -1 || family == FamilyLocal)
+ continue;
#if defined(IPv6) && defined(AF_INET6)
- if (family == FamilyInternet6)
- in6_fillscopeid((struct sockaddr_in6 *)ifr->ifa_addr);
-#endif
-
- for (host = selfhosts;
- host != NULL && !addrEqual(family, addr, len, host);
- host = host->next)
- ;
- if (host != NULL)
- continue;
- MakeHost(host, len);
- if (host != NULL) {
- host->family = family;
- host->len = len;
- memcpy(host->addr, addr, len);
- host->next = selfhosts;
- selfhosts = host;
- }
+ if (family == FamilyInternet6)
+ in6_fillscopeid((struct sockaddr_in6 *) ifr->ifa_addr);
+#endif
+
+ for (host = selfhosts;
+ host != NULL && !addrEqual(family, addr, len, host);
+ host = host->next);
+ if (host != NULL)
+ continue;
+ MakeHost(host, len);
+ if (host != NULL) {
+ host->family = family;
+ host->len = len;
+ memcpy(host->addr, addr, len);
+ host->next = selfhosts;
+ selfhosts = host;
+ }
#ifdef XDMCP
- {
- /*
- * If this isn't an Internet Address, don't register it.
- */
- if (family != FamilyInternet
+ {
+ /*
+ * If this isn't an Internet Address, don't register it.
+ */
+ if (family != FamilyInternet
#if defined(IPv6) && defined(AF_INET6)
- && family != FamilyInternet6
-#endif
- )
- continue;
-
- /*
- * ignore 'localhost' entries as they're not useful
- * on the other end of the wire
- */
- if (ifr->ifa_flags & IFF_LOOPBACK)
- continue;
-
- if (family == FamilyInternet &&
- addr[0] == 127 && addr[1] == 0 &&
- addr[2] == 0 && addr[3] == 1)
- continue;
-
- /*
- * Ignore '0.0.0.0' entries as they are
- * returned by some OSes for unconfigured NICs but they are
- * not useful on the other end of the wire.
- */
- if (len == 4 &&
- addr[0] == 0 && addr[1] == 0 &&
- addr[2] == 0 && addr[3] == 0)
- continue;
+ && family != FamilyInternet6
+#endif
+ )
+ continue;
+
+ /*
+ * ignore 'localhost' entries as they're not useful
+ * on the other end of the wire
+ */
+ if (ifr->ifa_flags & IFF_LOOPBACK)
+ continue;
+
+ if (family == FamilyInternet &&
+ addr[0] == 127 && addr[1] == 0 && addr[2] == 0 && addr[3] == 1)
+ continue;
+
+ /*
+ * Ignore '0.0.0.0' entries as they are
+ * returned by some OSes for unconfigured NICs but they are
+ * not useful on the other end of the wire.
+ */
+ if (len == 4 &&
+ addr[0] == 0 && addr[1] == 0 && addr[2] == 0 && addr[3] == 0)
+ continue;
#if defined(IPv6) && defined(AF_INET6)
- else if (family == FamilyInternet6 &&
- IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr))
- continue;
+ else if (family == FamilyInternet6 &&
+ IN6_IS_ADDR_LOOPBACK((struct in6_addr *) addr))
+ continue;
#endif
- XdmcpRegisterConnection(family, (char *)addr, len);
+ XdmcpRegisterConnection(family, (char *) addr, len);
#if defined(IPv6) && defined(AF_INET6)
- if (family == FamilyInternet6)
- /* IPv6 doesn't support broadcasting, so we drop out here */
- continue;
-#endif
- if ((ifr->ifa_flags & IFF_BROADCAST) &&
- (ifr->ifa_flags & IFF_UP) &&
- ifr->ifa_broadaddr)
- XdmcpRegisterBroadcastAddress(
- (struct sockaddr_in *) ifr->ifa_broadaddr);
- else
- continue;
- }
-#endif /* XDMCP */
-
- } /* for */
+ if (family == FamilyInternet6)
+ /* IPv6 doesn't support broadcasting, so we drop out here */
+ continue;
+#endif
+ if ((ifr->ifa_flags & IFF_BROADCAST) &&
+ (ifr->ifa_flags & IFF_UP) && ifr->ifa_broadaddr)
+ XdmcpRegisterBroadcastAddress((struct sockaddr_in *) ifr->
+ ifa_broadaddr);
+ else
+ continue;
+ }
+#endif /* XDMCP */
+
+ } /* for */
freeifaddrs(ifap);
-#endif /* HAVE_GETIFADDRS */
+#endif /* HAVE_GETIFADDRS */
/*
* add something of FamilyLocalHost
*/
for (host = selfhosts;
- host && !addrEqual(FamilyLocalHost, "", 0, host);
- host = host->next);
- if (!host)
- {
- MakeHost(host, 0);
- if (host)
- {
- host->family = FamilyLocalHost;
- host->len = 0;
- /* Nothing to store in host->addr */
- host->next = selfhosts;
- selfhosts = host;
- }
+ host && !addrEqual(FamilyLocalHost, "", 0, host); host = host->next);
+ if (!host) {
+ MakeHost(host, 0);
+ if (host) {
+ host->family = FamilyLocalHost;
+ host->len = 0;
+ /* Nothing to store in host->addr */
+ host->next = selfhosts;
+ selfhosts = host;
+ }
}
}
-#endif /* hpux && !HAVE_IFREQ */
+#endif /* hpux && !HAVE_IFREQ */
#ifdef XDMCP
void
@@ -806,17 +781,16 @@ AugmentSelf(pointer from, int len)
pointer addr;
register HOST *host;
- family = ConvertAddr(from, &len, (pointer *)&addr);
+ family = ConvertAddr(from, &len, (pointer *) &addr);
if (family == -1 || family == FamilyLocal)
- return;
- for (host = selfhosts; host; host = host->next)
- {
- if (addrEqual(family, addr, len, host))
- return;
+ return;
+ for (host = selfhosts; host; host = host->next) {
+ if (addrEqual(family, addr, len, host))
+ return;
}
- MakeHost(host,len)
- if (!host)
- return;
+ MakeHost(host, len)
+ if (!host)
+ return;
host->family = family;
host->len = len;
memcpy(host->addr, addr, len);
@@ -826,50 +800,50 @@ AugmentSelf(pointer from, int len)
#endif
void
-AddLocalHosts (void)
+AddLocalHosts(void)
{
- HOST *self;
+ HOST *self;
for (self = selfhosts; self; self = self->next)
- /* Fix for XFree86 bug #156: pass addingLocal = TRUE to
- * NewHost to tell that we are adding the default local
- * host entries and not to flag the entries as being
- * explicitely requested */
- (void) NewHost (self->family, self->addr, self->len, TRUE);
+ /* Fix for XFree86 bug #156: pass addingLocal = TRUE to
+ * NewHost to tell that we are adding the default local
+ * host entries and not to flag the entries as being
+ * explicitely requested */
+ (void) NewHost(self->family, self->addr, self->len, TRUE);
}
/* Reset access control list to initial hosts */
void
-ResetHosts (char *display)
+ResetHosts(char *display)
{
- register HOST *host;
- char lhostname[120], ohostname[120];
- char *hostname = ohostname;
- char fname[PATH_MAX + 1];
- int fnamelen;
- FILE *fd;
- char *ptr;
- int i, hostlen;
+ register HOST *host;
+ char lhostname[120], ohostname[120];
+ char *hostname = ohostname;
+ char fname[PATH_MAX + 1];
+ int fnamelen;
+ FILE *fd;
+ char *ptr;
+ int i, hostlen;
+
#if (defined(TCPCONN) || defined(STREAMSCONN) ) && \
(!defined(IPv6) || !defined(AF_INET6))
union {
- struct sockaddr sa;
+ struct sockaddr sa;
#if defined(TCPCONN) || defined(STREAMSCONN)
- struct sockaddr_in in;
-#endif /* TCPCONN || STREAMSCONN */
- } saddr;
+ struct sockaddr_in in;
+#endif /* TCPCONN || STREAMSCONN */
+ } saddr;
#endif
- int family = 0;
- pointer addr;
- int len;
+ int family = 0;
+ pointer addr;
+ int len;
siTypesInitialize();
AccessEnabled = defeatAccessControl ? FALSE : DEFAULT_ACCESS_CONTROL;
LocalHostEnabled = FALSE;
- while ((host = validhosts) != 0)
- {
+ while ((host = validhosts) != 0) {
validhosts = host->next;
- FreeHost (host);
+ FreeHost(host);
}
#if defined WIN32 && defined __MINGW32__
@@ -879,130 +853,122 @@ ResetHosts (char *display)
#endif
#define ETC_HOST_SUFFIX ".hosts"
fnamelen = strlen(ETC_HOST_PREFIX) + strlen(ETC_HOST_SUFFIX) +
- strlen(display) + 1;
+ strlen(display) + 1;
if (fnamelen > sizeof(fname))
- FatalError("Display name `%s' is too long\n", display);
- snprintf(fname, sizeof(fname), ETC_HOST_PREFIX "%s" ETC_HOST_SUFFIX,
- display);
-
- if ((fd = fopen (fname, "r")) != 0)
- {
- while (fgets (ohostname, sizeof (ohostname), fd))
- {
- family = FamilyWild;
- if (*ohostname == '#')
- continue;
- if ((ptr = strchr(ohostname, '\n')) != 0)
- *ptr = 0;
- hostlen = strlen(ohostname) + 1;
- for (i = 0; i < hostlen; i++)
- lhostname[i] = tolower(ohostname[i]);
- hostname = ohostname;
- if (!strncmp("local:", lhostname, 6))
- {
- family = FamilyLocalHost;
- NewHost(family, "", 0, FALSE);
- LocalHostRequested = TRUE; /* Fix for XFree86 bug #156 */
- }
+ FatalError("Display name `%s' is too long\n", display);
+ snprintf(fname, sizeof(fname), ETC_HOST_PREFIX "%s" ETC_HOST_SUFFIX,
+ display);
+
+ if ((fd = fopen(fname, "r")) != 0) {
+ while (fgets(ohostname, sizeof(ohostname), fd)) {
+ family = FamilyWild;
+ if (*ohostname == '#')
+ continue;
+ if ((ptr = strchr(ohostname, '\n')) != 0)
+ *ptr = 0;
+ hostlen = strlen(ohostname) + 1;
+ for (i = 0; i < hostlen; i++)
+ lhostname[i] = tolower(ohostname[i]);
+ hostname = ohostname;
+ if (!strncmp("local:", lhostname, 6)) {
+ family = FamilyLocalHost;
+ NewHost(family, "", 0, FALSE);
+ LocalHostRequested = TRUE; /* Fix for XFree86 bug #156 */
+ }
#if defined(TCPCONN) || defined(STREAMSCONN)
- else if (!strncmp("inet:", lhostname, 5))
- {
- family = FamilyInternet;
- hostname = ohostname + 5;
- }
+ else if (!strncmp("inet:", lhostname, 5)) {
+ family = FamilyInternet;
+ hostname = ohostname + 5;
+ }
#if defined(IPv6) && defined(AF_INET6)
- else if (!strncmp("inet6:", lhostname, 6))
- {
- family = FamilyInternet6;
- hostname = ohostname + 6;
- }
+ else if (!strncmp("inet6:", lhostname, 6)) {
+ family = FamilyInternet6;
+ hostname = ohostname + 6;
+ }
#endif
#endif
#ifdef SECURE_RPC
- else if (!strncmp("nis:", lhostname, 4))
- {
- family = FamilyNetname;
- hostname = ohostname + 4;
- }
-#endif
- else if (!strncmp("si:", lhostname, 3))
- {
- family = FamilyServerInterpreted;
- hostname = ohostname + 3;
- hostlen -= 3;
- }
-
-
- if (family == FamilyServerInterpreted)
- {
- len = siCheckAddr(hostname, hostlen);
- if (len >= 0) {
- NewHost(family, hostname, len, FALSE);
- }
- }
- else
+ else if (!strncmp("nis:", lhostname, 4)) {
+ family = FamilyNetname;
+ hostname = ohostname + 4;
+ }
+#endif
+ else if (!strncmp("si:", lhostname, 3)) {
+ family = FamilyServerInterpreted;
+ hostname = ohostname + 3;
+ hostlen -= 3;
+ }
+
+ if (family == FamilyServerInterpreted) {
+ len = siCheckAddr(hostname, hostlen);
+ if (len >= 0) {
+ NewHost(family, hostname, len, FALSE);
+ }
+ }
+ else
#ifdef SECURE_RPC
- if ((family == FamilyNetname) || (strchr(hostname, '@')))
- {
- SecureRPCInit ();
- (void) NewHost (FamilyNetname, hostname, strlen (hostname), FALSE);
- }
- else
-#endif /* SECURE_RPC */
+ if ((family == FamilyNetname) || (strchr(hostname, '@'))) {
+ SecureRPCInit();
+ (void) NewHost(FamilyNetname, hostname, strlen(hostname),
+ FALSE);
+ }
+ else
+#endif /* SECURE_RPC */
#if defined(TCPCONN) || defined(STREAMSCONN)
- {
-#if defined(IPv6) && defined(AF_INET6)
- if ( (family == FamilyInternet) || (family == FamilyInternet6) ||
- (family == FamilyWild) )
{
- struct addrinfo *addresses;
- struct addrinfo *a;
- int f;
-
- if (getaddrinfo(hostname, NULL, NULL, &addresses) == 0) {
- for (a = addresses ; a != NULL ; a = a->ai_next) {
- len = a->ai_addrlen;
- f = ConvertAddr(a->ai_addr,&len,(pointer *)&addr);
- if ( (family == f) ||
- ((family == FamilyWild) && (f != -1)) ) {
- NewHost(f, addr, len, FALSE);
- }
- }
- freeaddrinfo(addresses);
- }
- }
+#if defined(IPv6) && defined(AF_INET6)
+ if ((family == FamilyInternet) || (family == FamilyInternet6) ||
+ (family == FamilyWild)) {
+ struct addrinfo *addresses;
+ struct addrinfo *a;
+ int f;
+
+ if (getaddrinfo(hostname, NULL, NULL, &addresses) == 0) {
+ for (a = addresses; a != NULL; a = a->ai_next) {
+ len = a->ai_addrlen;
+ f = ConvertAddr(a->ai_addr, &len,
+ (pointer *) &addr);
+ if ((family == f) ||
+ ((family == FamilyWild) && (f != -1))) {
+ NewHost(f, addr, len, FALSE);
+ }
+ }
+ freeaddrinfo(addresses);
+ }
+ }
#else
#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
- _Xgethostbynameparams hparams;
-#endif
- register struct hostent *hp;
-
- /* host name */
- if ((family == FamilyInternet &&
- ((hp = _XGethostbyname(hostname, hparams)) != 0)) ||
- ((hp = _XGethostbyname(hostname, hparams)) != 0))
- {
- saddr.sa.sa_family = hp->h_addrtype;
- len = sizeof(saddr.sa);
- if ((family = ConvertAddr (&saddr.sa, &len, (pointer *)&addr)) != -1)
- {
-#ifdef h_addr /* new 4.3bsd version of gethostent */
- char **list;
-
- /* iterate over the addresses */
- for (list = hp->h_addr_list; *list; list++)
- (void) NewHost (family, (pointer)*list, len, FALSE);
+ _Xgethostbynameparams hparams;
+#endif
+ register struct hostent *hp;
+
+ /* host name */
+ if ((family == FamilyInternet &&
+ ((hp = _XGethostbyname(hostname, hparams)) != 0)) ||
+ ((hp = _XGethostbyname(hostname, hparams)) != 0)) {
+ saddr.sa.sa_family = hp->h_addrtype;
+ len = sizeof(saddr.sa);
+ if ((family =
+ ConvertAddr(&saddr.sa, &len,
+ (pointer *) &addr)) != -1) {
+#ifdef h_addr /* new 4.3bsd version of gethostent */
+ char **list;
+
+ /* iterate over the addresses */
+ for (list = hp->h_addr_list; *list; list++)
+ (void) NewHost(family, (pointer) *list, len, FALSE);
#else
- (void) NewHost (family, (pointer)hp->h_addr, len, FALSE);
-#endif
- }
- }
-#endif /* IPv6 */
+ (void) NewHost(family, (pointer) hp->h_addr, len,
+ FALSE);
+#endif
+ }
+ }
+#endif /* IPv6 */
+ }
+#endif /* TCPCONN || STREAMSCONN */
+ family = FamilyWild;
}
-#endif /* TCPCONN || STREAMSCONN */
- family = FamilyWild;
- }
- fclose (fd);
+ fclose(fd);
}
}
@@ -1010,46 +976,43 @@ ResetHosts (char *display)
Bool
ComputeLocalClient(ClientPtr client)
{
- int alen, family, notused;
- Xtransaddr *from = NULL;
- pointer addr;
- register HOST *host;
- OsCommPtr oc = (OsCommPtr) client->osPrivate;
+ int alen, family, notused;
+ Xtransaddr *from = NULL;
+ pointer addr;
+ register HOST *host;
+ OsCommPtr oc = (OsCommPtr) client->osPrivate;
if (!oc->trans_conn)
return FALSE;
- if (!_XSERVTransGetPeerAddr (oc->trans_conn, &notused, &alen, &from))
- {
- family = ConvertAddr ((struct sockaddr *) from,
- &alen, (pointer *)&addr);
- if (family == -1)
- {
- free(from);
- return FALSE;
- }
- if (family == FamilyLocal)
- {
- free(from);
- return TRUE;
- }
- for (host = selfhosts; host; host = host->next)
- {
- if (addrEqual (family, addr, alen, host)) {
- free(from);
- return TRUE;
- }
- }
- free(from);
+ if (!_XSERVTransGetPeerAddr(oc->trans_conn, &notused, &alen, &from)) {
+ family = ConvertAddr((struct sockaddr *) from,
+ &alen, (pointer *) &addr);
+ if (family == -1) {
+ free(from);
+ return FALSE;
+ }
+ if (family == FamilyLocal) {
+ free(from);
+ return TRUE;
+ }
+ for (host = selfhosts; host; host = host->next) {
+ if (addrEqual(family, addr, alen, host)) {
+ free(from);
+ return TRUE;
+ }
+ }
+ free(from);
}
return FALSE;
}
-Bool LocalClient(ClientPtr client)
+Bool
+LocalClient(ClientPtr client)
{
if (!client->osPrivate)
return FALSE;
- return ((OsCommPtr)client->osPrivate)->local_client;
+ return ((OsCommPtr) client->osPrivate)->local_client;
}
/*
@@ -1064,17 +1027,17 @@ LocalClientCred(ClientPtr client, int *pUid, int *pGid)
int ret = GetLocalClientCreds(client, &lcc);
if (ret == 0) {
-#ifdef HAVE_GETZONEID /* only local if in the same zone */
- if ((lcc->fieldsSet & LCC_ZID_SET) && (lcc->zoneid != getzoneid())) {
- FreeLocalClientCreds(lcc);
- return -1;
- }
-#endif
- if ((lcc->fieldsSet & LCC_UID_SET) && (pUid != NULL))
- *pUid = lcc->euid;
- if ((lcc->fieldsSet & LCC_GID_SET) && (pGid != NULL))
- *pGid = lcc->egid;
- FreeLocalClientCreds(lcc);
+#ifdef HAVE_GETZONEID /* only local if in the same zone */
+ if ((lcc->fieldsSet & LCC_ZID_SET) && (lcc->zoneid != getzoneid())) {
+ FreeLocalClientCreds(lcc);
+ return -1;
+ }
+#endif
+ if ((lcc->fieldsSet & LCC_UID_SET) && (pUid != NULL))
+ *pUid = lcc->euid;
+ if ((lcc->fieldsSet & LCC_GID_SET) && (pGid != NULL))
+ *pGid = lcc->egid;
+ FreeLocalClientCreds(lcc);
}
return ret;
}
@@ -1087,12 +1050,13 @@ LocalClientCred(ClientPtr client, int *pUid, int *pGid)
* Used by AuthAudit to log who local connections came from
*/
int
-GetLocalClientCreds(ClientPtr client, LocalClientCredRec **lccp)
+GetLocalClientCreds(ClientPtr client, LocalClientCredRec ** lccp)
{
#if defined(HAVE_GETPEEREID) || defined(HAVE_GETPEERUCRED) || defined(SO_PEERCRED)
int fd;
XtransConnInfo ci;
LocalClientCredRec *lcc;
+
#ifdef HAVE_GETPEEREID
uid_t uid;
gid_t gid;
@@ -1105,28 +1069,28 @@ GetLocalClientCreds(ClientPtr client, LocalClientCredRec **lccp)
#endif
if (client == NULL)
- return -1;
- ci = ((OsCommPtr)client->osPrivate)->trans_conn;
+ return -1;
+ ci = ((OsCommPtr) client->osPrivate)->trans_conn;
#if !(defined(sun) && defined(HAVE_GETPEERUCRED))
/* Most implementations can only determine peer credentials for Unix
* domain sockets - Solaris getpeerucred can work with a bit more, so
* we just let it tell us if the connection type is supported or not
*/
if (!_XSERVTransIsLocal(ci)) {
- return -1;
+ return -1;
}
#endif
*lccp = calloc(1, sizeof(LocalClientCredRec));
if (*lccp == NULL)
- return -1;
+ return -1;
lcc = *lccp;
-
+
fd = _XSERVTransGetConnectionNumber(ci);
#ifdef HAVE_GETPEEREID
if (getpeereid(fd, &uid, &gid) == -1) {
- FreeLocalClientCreds(lcc);
- return -1;
+ FreeLocalClientCreds(lcc);
+ return -1;
}
lcc->euid = uid;
lcc->egid = gid;
@@ -1134,43 +1098,46 @@ GetLocalClientCreds(ClientPtr client, LocalClientCredRec **lccp)
return 0;
#elif defined(HAVE_GETPEERUCRED)
if (getpeerucred(fd, &peercred) < 0) {
- FreeLocalClientCreds(lcc);
- return -1;
+ FreeLocalClientCreds(lcc);
+ return -1;
}
lcc->euid = ucred_geteuid(peercred);
if (lcc->euid != -1)
- lcc->fieldsSet |= LCC_UID_SET;
+ lcc->fieldsSet |= LCC_UID_SET;
lcc->egid = ucred_getegid(peercred);
if (lcc->egid != -1)
- lcc->fieldsSet |= LCC_GID_SET;
+ lcc->fieldsSet |= LCC_GID_SET;
lcc->pid = ucred_getpid(peercred);
if (lcc->pid != -1)
- lcc->fieldsSet |= LCC_PID_SET;
+ lcc->fieldsSet |= LCC_PID_SET;
#ifdef HAVE_GETZONEID
lcc->zoneid = ucred_getzoneid(peercred);
if (lcc->zoneid != -1)
- lcc->fieldsSet |= LCC_ZID_SET;
+ lcc->fieldsSet |= LCC_ZID_SET;
#endif
lcc->nSuppGids = ucred_getgroups(peercred, &gids);
if (lcc->nSuppGids > 0) {
- lcc->pSuppGids = calloc(lcc->nSuppGids, sizeof(int));
- if (lcc->pSuppGids == NULL) {
- lcc->nSuppGids = 0;
- } else {
- int i;
- for (i = 0 ; i < lcc->nSuppGids; i++) {
- (lcc->pSuppGids)[i] = (int) gids[i];
- }
- }
- } else {
- lcc->nSuppGids = 0;
+ lcc->pSuppGids = calloc(lcc->nSuppGids, sizeof(int));
+ if (lcc->pSuppGids == NULL) {
+ lcc->nSuppGids = 0;
+ }
+ else {
+ int i;
+
+ for (i = 0; i < lcc->nSuppGids; i++) {
+ (lcc->pSuppGids)[i] = (int) gids[i];
+ }
+ }
+ }
+ else {
+ lcc->nSuppGids = 0;
}
ucred_free(peercred);
return 0;
#elif defined(SO_PEERCRED)
if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &peercred, &so_len) == -1) {
- FreeLocalClientCreds(lcc);
- return -1;
+ FreeLocalClientCreds(lcc);
+ return -1;
}
lcc->euid = peercred.uid;
lcc->egid = peercred.gid;
@@ -1186,13 +1153,13 @@ GetLocalClientCreds(ClientPtr client, LocalClientCredRec **lccp)
}
void
-FreeLocalClientCreds(LocalClientCredRec *lcc)
+FreeLocalClientCreds(LocalClientCredRec * lcc)
{
if (lcc != NULL) {
- if (lcc->nSuppGids > 0) {
- free(lcc->pSuppGids);
- }
- free(lcc);
+ if (lcc->nSuppGids > 0) {
+ free(lcc->pSuppGids);
+ }
+ free(lcc);
}
}
@@ -1202,12 +1169,12 @@ AuthorizedClient(ClientPtr client)
int rc;
if (!client || defeatAccessControl)
- return Success;
+ return Success;
/* untrusted clients can't change host access */
rc = XaceHook(XACE_SERVER_ACCESS, client, DixManageAccess);
if (rc != Success)
- return rc;
+ return rc;
return LocalClient(client) ? Success : BadAccess;
}
@@ -1216,26 +1183,24 @@ AuthorizedClient(ClientPtr client)
* called from the dispatcher */
int
-AddHost (ClientPtr client,
- int family,
- unsigned length, /* of bytes in pAddr */
- const void * pAddr)
+AddHost(ClientPtr client, int family, unsigned length, /* of bytes in pAddr */
+ const void *pAddr)
{
int rc, len;
rc = AuthorizedClient(client);
if (rc != Success)
- return rc;
+ return rc;
switch (family) {
case FamilyLocalHost:
- len = length;
- LocalHostEnabled = TRUE;
- break;
+ len = length;
+ LocalHostEnabled = TRUE;
+ break;
#ifdef SECURE_RPC
case FamilyNetname:
- len = length;
- SecureRPCInit ();
- break;
+ len = length;
+ SecureRPCInit();
+ break;
#endif
case FamilyInternet:
#if defined(IPv6) && defined(AF_INET6)
@@ -1244,64 +1209,57 @@ AddHost (ClientPtr client,
case FamilyDECnet:
case FamilyChaos:
case FamilyServerInterpreted:
- if ((len = CheckAddr (family, pAddr, length)) < 0)
- {
- client->errorValue = length;
- return BadValue;
- }
- break;
+ if ((len = CheckAddr(family, pAddr, length)) < 0) {
+ client->errorValue = length;
+ return BadValue;
+ }
+ break;
case FamilyLocal:
default:
- client->errorValue = family;
- return BadValue;
+ client->errorValue = family;
+ return BadValue;
}
- if (NewHost (family, pAddr, len, FALSE))
- return Success;
+ if (NewHost(family, pAddr, len, FALSE))
+ return Success;
return BadAlloc;
}
Bool
-ForEachHostInFamily (int family,
- Bool (*func)(
- unsigned char * /* addr */,
- short /* len */,
- pointer /* closure */),
- pointer closure)
+ForEachHostInFamily(int family, Bool (*func) (unsigned char * /* addr */ ,
+ short /* len */ ,
+ pointer /* closure */ ),
+ pointer closure)
{
- HOST *host;
+ HOST *host;
for (host = validhosts; host; host = host->next)
- if (family == host->family && func (host->addr, host->len, closure))
- return TRUE;
+ if (family == host->family && func(host->addr, host->len, closure))
+ return TRUE;
return FALSE;
}
/* Add a host to the access control list. This is the internal interface
* called when starting or resetting the server */
static Bool
-NewHost (int family,
- const void * addr,
- int len,
- int addingLocalHosts)
+NewHost(int family, const void *addr, int len, int addingLocalHosts)
{
register HOST *host;
- for (host = validhosts; host; host = host->next)
- {
- if (addrEqual (family, addr, len, host))
- return TRUE;
+ for (host = validhosts; host; host = host->next) {
+ if (addrEqual(family, addr, len, host))
+ return TRUE;
}
- if (!addingLocalHosts) { /* Fix for XFree86 bug #156 */
- for (host = selfhosts; host; host = host->next) {
- if (addrEqual (family, addr, len, host)) {
- host->requested = TRUE;
- break;
- }
- }
+ if (!addingLocalHosts) { /* Fix for XFree86 bug #156 */
+ for (host = selfhosts; host; host = host->next) {
+ if (addrEqual(family, addr, len, host)) {
+ host->requested = TRUE;
+ break;
+ }
+ }
}
- MakeHost(host,len)
- if (!host)
- return FALSE;
+ MakeHost(host, len)
+ if (!host)
+ return FALSE;
host->family = family;
host->len = len;
memcpy(host->addr, addr, len);
@@ -1313,27 +1271,24 @@ NewHost (int family,
/* Remove a host from the access control list */
int
-RemoveHost (
- ClientPtr client,
- int family,
- unsigned length, /* of bytes in pAddr */
- pointer pAddr)
+RemoveHost(ClientPtr client, int family, unsigned length, /* of bytes in pAddr */
+ pointer pAddr)
{
int rc, len;
- register HOST *host, **prev;
+ register HOST *host, **prev;
rc = AuthorizedClient(client);
if (rc != Success)
- return rc;
+ return rc;
switch (family) {
case FamilyLocalHost:
- len = length;
- LocalHostEnabled = FALSE;
- break;
+ len = length;
+ LocalHostEnabled = FALSE;
+ break;
#ifdef SECURE_RPC
case FamilyNetname:
- len = length;
- break;
+ len = length;
+ break;
#endif
case FamilyInternet:
#if defined(IPv6) && defined(AF_INET6)
@@ -1342,67 +1297,57 @@ RemoveHost (
case FamilyDECnet:
case FamilyChaos:
case FamilyServerInterpreted:
- if ((len = CheckAddr (family, pAddr, length)) < 0)
- {
- client->errorValue = length;
+ if ((len = CheckAddr(family, pAddr, length)) < 0) {
+ client->errorValue = length;
return BadValue;
- }
- break;
+ }
+ break;
case FamilyLocal:
default:
- client->errorValue = family;
+ client->errorValue = family;
return BadValue;
}
for (prev = &validhosts;
- (host = *prev) && (!addrEqual (family, pAddr, len, host));
- prev = &host->next)
- ;
- if (host)
- {
+ (host = *prev) && (!addrEqual(family, pAddr, len, host));
+ prev = &host->next);
+ if (host) {
*prev = host->next;
- FreeHost (host);
+ FreeHost(host);
}
return Success;
}
/* Get all hosts in the access control list */
int
-GetHosts (
- pointer *data,
- int *pnHosts,
- int *pLen,
- BOOL *pEnabled)
+GetHosts(pointer *data, int *pnHosts, int *pLen, BOOL * pEnabled)
{
- int len;
- register int n = 0;
+ int len;
+ register int n = 0;
register unsigned char *ptr;
- register HOST *host;
- int nHosts = 0;
+ register HOST *host;
+ int nHosts = 0;
*pEnabled = AccessEnabled ? EnableAccess : DisableAccess;
- for (host = validhosts; host; host = host->next)
- {
- nHosts++;
- n += pad_to_int32(host->len) + sizeof(xHostEntry);
+ for (host = validhosts; host; host = host->next) {
+ nHosts++;
+ n += pad_to_int32(host->len) + sizeof(xHostEntry);
}
- if (n)
- {
+ if (n) {
*data = ptr = malloc(n);
- if (!ptr)
- {
- return BadAlloc;
- }
- for (host = validhosts; host; host = host->next)
- {
- len = host->len;
- ((xHostEntry *)ptr)->family = host->family;
- ((xHostEntry *)ptr)->length = len;
- ptr += sizeof(xHostEntry);
- memcpy (ptr, host->addr, len);
- ptr += pad_to_int32(len);
+ if (!ptr) {
+ return BadAlloc;
+ }
+ for (host = validhosts; host; host = host->next) {
+ len = host->len;
+ ((xHostEntry *) ptr)->family = host->family;
+ ((xHostEntry *) ptr)->length = len;
+ ptr += sizeof(xHostEntry);
+ memcpy(ptr, host->addr, len);
+ ptr += pad_to_int32(len);
}
- } else {
- *data = NULL;
+ }
+ else {
+ *data = NULL;
}
*pnHosts = nHosts;
*pLen = n;
@@ -1411,37 +1356,32 @@ GetHosts (
/* Check for valid address family and length, and return address length. */
-/*ARGSUSED*/
-static int
-CheckAddr (
- int family,
- const void * pAddr,
- unsigned length)
+ /*ARGSUSED*/ static int
+CheckAddr(int family, const void *pAddr, unsigned length)
{
- int len;
+ int len;
- switch (family)
- {
+ switch (family) {
#if defined(TCPCONN) || defined(STREAMSCONN)
- case FamilyInternet:
- if (length == sizeof (struct in_addr))
- len = length;
- else
- len = -1;
+ case FamilyInternet:
+ if (length == sizeof(struct in_addr))
+ len = length;
+ else
+ len = -1;
break;
#if defined(IPv6) && defined(AF_INET6)
- case FamilyInternet6:
- if (length == sizeof (struct in6_addr))
- len = length;
- else
- len = -1;
+ case FamilyInternet6:
+ if (length == sizeof(struct in6_addr))
+ len = length;
+ else
+ len = -1;
break;
#endif
-#endif
- case FamilyServerInterpreted:
- len = siCheckAddr(pAddr, length);
- break;
- default:
+#endif
+ case FamilyServerInterpreted:
+ len = siCheckAddr(pAddr, length);
+ break;
+ default:
len = -1;
}
return len;
@@ -1451,65 +1391,55 @@ CheckAddr (
* Returns 1 if host is invalid, 0 if we've found it. */
int
-InvalidHost (
- register struct sockaddr *saddr,
- int len,
- ClientPtr client)
+InvalidHost(register struct sockaddr *saddr, int len, ClientPtr client)
{
- int family;
- pointer addr;
- register HOST *selfhost, *host;
+ int family;
+ pointer addr;
+ register HOST *selfhost, *host;
- if (!AccessEnabled) /* just let them in */
+ if (!AccessEnabled) /* just let them in */
return 0;
- family = ConvertAddr (saddr, &len, (pointer *)&addr);
+ family = ConvertAddr(saddr, &len, (pointer *) &addr);
if (family == -1)
return 1;
- if (family == FamilyLocal)
- {
- if (!LocalHostEnabled)
- {
- /*
- * check to see if any local address is enabled. This
- * implicitly enables local connections.
- */
- for (selfhost = selfhosts; selfhost; selfhost=selfhost->next)
- {
- for (host = validhosts; host; host=host->next)
- {
- if (addrEqual (selfhost->family, selfhost->addr,
- selfhost->len, host))
- return 0;
- }
- }
- } else
- return 0;
+ if (family == FamilyLocal) {
+ if (!LocalHostEnabled) {
+ /*
+ * check to see if any local address is enabled. This
+ * implicitly enables local connections.
+ */
+ for (selfhost = selfhosts; selfhost; selfhost = selfhost->next) {
+ for (host = validhosts; host; host = host->next) {
+ if (addrEqual(selfhost->family, selfhost->addr,
+ selfhost->len, host))
+ return 0;
+ }
+ }
+ }
+ else
+ return 0;
}
- for (host = validhosts; host; host = host->next)
- {
- if (host->family == FamilyServerInterpreted) {
- if (siAddrMatch (family, addr, len, host, client)) {
- return 0;
- }
- } else {
- if (addrEqual (family, addr, len, host))
- return 0;
- }
+ for (host = validhosts; host; host = host->next) {
+ if (host->family == FamilyServerInterpreted) {
+ if (siAddrMatch(family, addr, len, host, client)) {
+ return 0;
+ }
+ }
+ else {
+ if (addrEqual(family, addr, len, host))
+ return 0;
+ }
}
return 1;
}
static int
-ConvertAddr (
- register struct sockaddr *saddr,
- int *len,
- pointer *addr)
+ConvertAddr(register struct sockaddr *saddr, int *len, pointer *addr)
{
if (*len == 0)
return FamilyLocal;
- switch (saddr->sa_family)
- {
+ switch (saddr->sa_family) {
case AF_UNSPEC:
#if defined(UNIXCONN) || defined(LOCALCONN)
case AF_UNIX:
@@ -1518,25 +1448,27 @@ ConvertAddr (
#if defined(TCPCONN) || defined(STREAMSCONN)
case AF_INET:
#ifdef WIN32
- if (16777343 == *(long*)&((struct sockaddr_in *) saddr)->sin_addr)
+ if (16777343 == *(long *) &((struct sockaddr_in *) saddr)->sin_addr)
return FamilyLocal;
#endif
- *len = sizeof (struct in_addr);
+ *len = sizeof(struct in_addr);
*addr = (pointer) &(((struct sockaddr_in *) saddr)->sin_addr);
return FamilyInternet;
#if defined(IPv6) && defined(AF_INET6)
- case AF_INET6:
+ case AF_INET6:
{
- struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *) saddr;
- if (IN6_IS_ADDR_V4MAPPED(&(saddr6->sin6_addr))) {
- *len = sizeof (struct in_addr);
- *addr = (pointer) &(saddr6->sin6_addr.s6_addr[12]);
- return FamilyInternet;
- } else {
- *len = sizeof (struct in6_addr);
- *addr = (pointer) &(saddr6->sin6_addr);
- return FamilyInternet6;
- }
+ struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *) saddr;
+
+ if (IN6_IS_ADDR_V4MAPPED(&(saddr6->sin6_addr))) {
+ *len = sizeof(struct in_addr);
+ *addr = (pointer) &(saddr6->sin6_addr.s6_addr[12]);
+ return FamilyInternet;
+ }
+ else {
+ *len = sizeof(struct in6_addr);
+ *addr = (pointer) &(saddr6->sin6_addr);
+ return FamilyInternet6;
+ }
}
#endif
#endif
@@ -1546,13 +1478,12 @@ ConvertAddr (
}
int
-ChangeAccessControl(
- ClientPtr client,
- int fEnabled)
+ChangeAccessControl(ClientPtr client, int fEnabled)
{
int rc = AuthorizedClient(client);
+
if (rc != Success)
- return rc;
+ return rc;
AccessEnabled = fEnabled;
return Success;
}
@@ -1582,47 +1513,48 @@ GetAccessControl(void)
* future to enable loading additional host types, but that was not done for
* the initial implementation.
*/
-typedef Bool (*siAddrMatchFunc)(int family, pointer addr, int len,
- const char *siAddr, int siAddrlen, ClientPtr client, void *siTypePriv);
-typedef int (*siCheckAddrFunc)(const char *addrString, int length,
- void *siTypePriv);
+typedef Bool (*siAddrMatchFunc) (int family, pointer addr, int len,
+ const char *siAddr, int siAddrlen,
+ ClientPtr client, void *siTypePriv);
+typedef int (*siCheckAddrFunc) (const char *addrString, int length,
+ void *siTypePriv);
struct siType {
- struct siType * next;
- const char * typeName;
- siAddrMatchFunc addrMatch;
- siCheckAddrFunc checkAddr;
- void * typePriv; /* Private data for type routines */
+ struct siType *next;
+ const char *typeName;
+ siAddrMatchFunc addrMatch;
+ siCheckAddrFunc checkAddr;
+ void *typePriv; /* Private data for type routines */
};
static struct siType *siTypeList;
static int
siTypeAdd(const char *typeName, siAddrMatchFunc addrMatch,
- siCheckAddrFunc checkAddr, void *typePriv)
+ siCheckAddrFunc checkAddr, void *typePriv)
{
struct siType *s, *p;
if ((typeName == NULL) || (addrMatch == NULL) || (checkAddr == NULL))
- return BadValue;
-
- for (s = siTypeList, p = NULL; s != NULL ; p = s, s = s->next) {
- if (strcmp(typeName, s->typeName) == 0) {
- s->addrMatch = addrMatch;
- s->checkAddr = checkAddr;
- s->typePriv = typePriv;
- return Success;
- }
+ return BadValue;
+
+ for (s = siTypeList, p = NULL; s != NULL; p = s, s = s->next) {
+ if (strcmp(typeName, s->typeName) == 0) {
+ s->addrMatch = addrMatch;
+ s->checkAddr = checkAddr;
+ s->typePriv = typePriv;
+ return Success;
+ }
}
s = malloc(sizeof(struct siType));
if (s == NULL)
- return BadAlloc;
+ return BadAlloc;
if (p == NULL)
- siTypeList = s;
+ siTypeList = s;
else
- p->next = s;
+ p->next = s;
s->next = NULL;
s->typeName = typeName;
@@ -1633,8 +1565,8 @@ siTypeAdd(const char *typeName, siAddrMatchFunc addrMatch,
}
/* Checks to see if a host matches a server-interpreted host entry */
-static Bool
-siAddrMatch(int family, pointer addr, int len, HOST *host, ClientPtr client)
+static Bool
+siAddrMatch(int family, pointer addr, int len, HOST * host, ClientPtr client)
{
Bool matches = FALSE;
struct siType *s;
@@ -1643,19 +1575,19 @@ siAddrMatch(int family, pointer addr, int len, HOST *host, ClientPtr client)
valueString = (const char *) memchr(host->addr, '\0', host->len);
if (valueString != NULL) {
- for (s = siTypeList; s != NULL ; s = s->next) {
- if (strcmp((char *) host->addr, s->typeName) == 0) {
- addrlen = host->len - (strlen((char *)host->addr) + 1);
- matches = s->addrMatch(family, addr, len,
- valueString + 1, addrlen, client, s->typePriv);
- break;
- }
- }
+ for (s = siTypeList; s != NULL; s = s->next) {
+ if (strcmp((char *) host->addr, s->typeName) == 0) {
+ addrlen = host->len - (strlen((char *) host->addr) + 1);
+ matches = s->addrMatch(family, addr, len,
+ valueString + 1, addrlen, client,
+ s->typePriv);
+ break;
+ }
+ }
#ifdef FAMILY_SI_DEBUG
- ErrorF(
- "Xserver: siAddrMatch(): type = %s, value = %*.*s -- %s\n",
- host->addr, addrlen, addrlen, valueString + 1,
- (matches) ? "accepted" : "rejected");
+ ErrorF("Xserver: siAddrMatch(): type = %s, value = %*.*s -- %s\n",
+ host->addr, addrlen, addrlen, valueString + 1,
+ (matches) ? "accepted" : "rejected");
#endif
}
return matches;
@@ -1673,43 +1605,44 @@ siCheckAddr(const char *addrString, int length)
to separate the address type from the address value. */
valueString = (const char *) memchr(addrString, '\0', length);
if (valueString != NULL) {
- /* Make sure the first string is a recognized address type,
- * and the second string is a valid address of that type.
- */
- typelen = strlen(addrString) + 1;
- addrlen = length - typelen;
-
- for (s = siTypeList; s != NULL ; s = s->next) {
- if (strcmp(addrString, s->typeName) == 0) {
- len = s->checkAddr(valueString + 1, addrlen, s->typePriv);
- if (len >= 0) {
- len += typelen;
- }
- break;
- }
- }
+ /* Make sure the first string is a recognized address type,
+ * and the second string is a valid address of that type.
+ */
+ typelen = strlen(addrString) + 1;
+ addrlen = length - typelen;
+
+ for (s = siTypeList; s != NULL; s = s->next) {
+ if (strcmp(addrString, s->typeName) == 0) {
+ len = s->checkAddr(valueString + 1, addrlen, s->typePriv);
+ if (len >= 0) {
+ len += typelen;
+ }
+ break;
+ }
+ }
#ifdef FAMILY_SI_DEBUG
- {
- const char *resultMsg;
-
- if (s == NULL) {
- resultMsg = "type not registered";
- } else {
- if (len == -1)
- resultMsg = "rejected";
- else
- resultMsg = "accepted";
- }
-
- ErrorF("Xserver: siCheckAddr(): type = %s, value = %*.*s, len = %d -- %s\n",
- addrString, addrlen, addrlen, valueString + 1, len, resultMsg);
- }
+ {
+ const char *resultMsg;
+
+ if (s == NULL) {
+ resultMsg = "type not registered";
+ }
+ else {
+ if (len == -1)
+ resultMsg = "rejected";
+ else
+ resultMsg = "accepted";
+ }
+
+ ErrorF
+ ("Xserver: siCheckAddr(): type = %s, value = %*.*s, len = %d -- %s\n",
+ addrString, addrlen, addrlen, valueString + 1, len, resultMsg);
+ }
#endif
}
return len;
}
-
/***
* Hostname server-interpreted host type
*
@@ -1724,18 +1657,19 @@ siCheckAddr(const char *addrString, int length)
*/
#ifdef NI_MAXHOST
-# define SI_HOSTNAME_MAXLEN NI_MAXHOST
+#define SI_HOSTNAME_MAXLEN NI_MAXHOST
+#else
+#ifdef MAXHOSTNAMELEN
+#define SI_HOSTNAME_MAXLEN MAXHOSTNAMELEN
#else
-# ifdef MAXHOSTNAMELEN
-# define SI_HOSTNAME_MAXLEN MAXHOSTNAMELEN
-# else
-# define SI_HOSTNAME_MAXLEN 256
-# endif
+#define SI_HOSTNAME_MAXLEN 256
+#endif
#endif
-static Bool
+static Bool
siHostnameAddrMatch(int family, pointer addr, int len,
- const char *siAddr, int siAddrLen, ClientPtr client, void *typePriv)
+ const char *siAddr, int siAddrLen, ClientPtr client,
+ void *typePriv)
{
Bool res = FALSE;
@@ -1745,74 +1679,74 @@ siHostnameAddrMatch(int family, pointer addr, int len,
*/
#if defined(IPv6) && defined(AF_INET6)
if ((family == FamilyInternet) || (family == FamilyInternet6)) {
- char hostname[SI_HOSTNAME_MAXLEN];
- struct addrinfo *addresses;
- struct addrinfo *a;
- int f, hostaddrlen;
- pointer hostaddr;
-
- if (siAddrLen >= sizeof(hostname))
- return FALSE;
-
- strlcpy(hostname, siAddr, siAddrLen + 1);
-
- if (getaddrinfo(hostname, NULL, NULL, &addresses) == 0) {
- for (a = addresses ; a != NULL ; a = a->ai_next) {
- hostaddrlen = a->ai_addrlen;
- f = ConvertAddr(a->ai_addr,&hostaddrlen,&hostaddr);
- if ((f == family) && (len == hostaddrlen) &&
- (memcmp (addr, hostaddr, len) == 0) ) {
- res = TRUE;
- break;
- }
- }
- freeaddrinfo(addresses);
- }
+ char hostname[SI_HOSTNAME_MAXLEN];
+ struct addrinfo *addresses;
+ struct addrinfo *a;
+ int f, hostaddrlen;
+ pointer hostaddr;
+
+ if (siAddrLen >= sizeof(hostname))
+ return FALSE;
+
+ strlcpy(hostname, siAddr, siAddrLen + 1);
+
+ if (getaddrinfo(hostname, NULL, NULL, &addresses) == 0) {
+ for (a = addresses; a != NULL; a = a->ai_next) {
+ hostaddrlen = a->ai_addrlen;
+ f = ConvertAddr(a->ai_addr, &hostaddrlen, &hostaddr);
+ if ((f == family) && (len == hostaddrlen) &&
+ (memcmp(addr, hostaddr, len) == 0)) {
+ res = TRUE;
+ break;
+ }
+ }
+ freeaddrinfo(addresses);
+ }
}
-#else /* IPv6 not supported, use gethostbyname instead for IPv4 */
+#else /* IPv6 not supported, use gethostbyname instead for IPv4 */
if (family == FamilyInternet) {
- register struct hostent *hp;
+ register struct hostent *hp;
+
#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
- _Xgethostbynameparams hparams;
+ _Xgethostbynameparams hparams;
#endif
- char hostname[SI_HOSTNAME_MAXLEN];
- int f, hostaddrlen;
- pointer hostaddr;
- const char **addrlist;
+ char hostname[SI_HOSTNAME_MAXLEN];
+ int f, hostaddrlen;
+ pointer hostaddr;
+ const char **addrlist;
- if (siAddrLen >= sizeof(hostname))
- return FALSE;
+ if (siAddrLen >= sizeof(hostname))
+ return FALSE;
- strlcpy(hostname, siAddr, siAddrLen + 1);
+ strlcpy(hostname, siAddr, siAddrLen + 1);
- if ((hp = _XGethostbyname(hostname, hparams)) != NULL) {
-#ifdef h_addr /* new 4.3bsd version of gethostent */
- /* iterate over the addresses */
- for (addrlist = hp->h_addr_list; *addrlist; addrlist++)
+ if ((hp = _XGethostbyname(hostname, hparams)) != NULL) {
+#ifdef h_addr /* new 4.3bsd version of gethostent */
+ /* iterate over the addresses */
+ for (addrlist = hp->h_addr_list; *addrlist; addrlist++)
#else
- addrlist = &hp->h_addr;
-#endif
- {
- struct sockaddr_in sin;
-
- sin.sin_family = hp->h_addrtype;
- memcpy ( &(sin.sin_addr), *addrlist, hp->h_length);
- hostaddrlen = sizeof(sin);
- f = ConvertAddr ((struct sockaddr *)&sin,
- &hostaddrlen, &hostaddr);
- if ((f == family) && (len == hostaddrlen) &&
- (memcmp (addr, hostaddr, len) == 0) ) {
- res = TRUE;
- break;
- }
- }
+ addrlist = &hp->h_addr;
+#endif
+ {
+ struct sockaddr_in sin;
+
+ sin.sin_family = hp->h_addrtype;
+ memcpy(&(sin.sin_addr), *addrlist, hp->h_length);
+ hostaddrlen = sizeof(sin);
+ f = ConvertAddr((struct sockaddr *) &sin,
+ &hostaddrlen, &hostaddr);
+ if ((f == family) && (len == hostaddrlen) &&
+ (memcmp(addr, hostaddr, len) == 0)) {
+ res = TRUE;
+ break;
+ }
+ }
}
}
#endif
return res;
}
-
static int
siHostnameCheckAddr(const char *valueString, int length, void *typePriv)
{
@@ -1824,38 +1758,44 @@ siHostnameCheckAddr(const char *valueString, int length, void *typePriv)
int i;
Bool dotAllowed = FALSE;
Bool dashAllowed = FALSE;
-
+
if ((length <= 0) || (length >= SI_HOSTNAME_MAXLEN)) {
- len = -1;
- } else {
- for (i = 0; i < length; i++) {
- char c = valueString[i];
-
- if (c == 0x2E) { /* '.' */
- if (dotAllowed == FALSE) {
- len = -1;
- break;
- } else {
- dotAllowed = FALSE;
- dashAllowed = FALSE;
- }
- } else if (c == 0x2D) { /* '-' */
- if (dashAllowed == FALSE) {
- len = -1;
- break;
- } else {
- dotAllowed = FALSE;
- }
- } else if (((c >= 0x30) && (c <= 0x3A)) /* 0-9 */ ||
- ((c >= 0x61) && (c <= 0x7A)) /* a-z */ ||
- ((c >= 0x41) && (c <= 0x5A)) /* A-Z */) {
- dotAllowed = TRUE;
- dashAllowed = TRUE;
- } else { /* Invalid character */
- len = -1;
- break;
- }
- }
+ len = -1;
+ }
+ else {
+ for (i = 0; i < length; i++) {
+ char c = valueString[i];
+
+ if (c == 0x2E) { /* '.' */
+ if (dotAllowed == FALSE) {
+ len = -1;
+ break;
+ }
+ else {
+ dotAllowed = FALSE;
+ dashAllowed = FALSE;
+ }
+ }
+ else if (c == 0x2D) { /* '-' */
+ if (dashAllowed == FALSE) {
+ len = -1;
+ break;
+ }
+ else {
+ dotAllowed = FALSE;
+ }
+ }
+ else if (((c >= 0x30) && (c <= 0x3A)) /* 0-9 */ ||
+ ((c >= 0x61) && (c <= 0x7A)) /* a-z */ ||
+ ((c >= 0x41) && (c <= 0x5A)) /* A-Z */ ) {
+ dotAllowed = TRUE;
+ dashAllowed = TRUE;
+ }
+ else { /* Invalid character */
+ len = -1;
+ break;
+ }
+ }
}
return len;
}
@@ -1875,28 +1815,30 @@ siHostnameCheckAddr(const char *valueString, int length, void *typePriv)
*/
#define SI_IPv6_MAXLEN INET6_ADDRSTRLEN
-static Bool
+static Bool
siIPv6AddrMatch(int family, pointer addr, int len,
- const char *siAddr, int siAddrlen, ClientPtr client, void *typePriv)
+ const char *siAddr, int siAddrlen, ClientPtr client,
+ void *typePriv)
{
struct in6_addr addr6;
char addrbuf[SI_IPv6_MAXLEN];
if ((family != FamilyInternet6) || (len != sizeof(addr6)))
- return FALSE;
+ return FALSE;
memcpy(addrbuf, siAddr, siAddrlen);
addrbuf[siAddrlen] = '\0';
if (inet_pton(AF_INET6, addrbuf, &addr6) != 1) {
- perror("inet_pton");
- return FALSE;
+ perror("inet_pton");
+ return FALSE;
}
if (memcmp(addr, &addr6, len) == 0) {
- return TRUE;
- } else {
- return FALSE;
+ return TRUE;
+ }
+ else {
+ return FALSE;
}
}
@@ -1907,29 +1849,32 @@ siIPv6CheckAddr(const char *addrString, int length, void *typePriv)
/* Minimum length is 3 (smallest legal address is "::1") */
if (length < 3) {
- /* Address is too short! */
- len = -1;
- } else if (length >= SI_IPv6_MAXLEN) {
- /* Address is too long! */
- len = -1;
- } else {
- /* Assume inet_pton is sufficient validation */
- struct in6_addr addr6;
- char addrbuf[SI_IPv6_MAXLEN];
-
- memcpy(addrbuf, addrString, length);
- addrbuf[length] = '\0';
-
- if (inet_pton(AF_INET6, addrbuf, &addr6) != 1) {
- perror("inet_pton");
- len = -1;
- } else {
- len = length;
- }
+ /* Address is too short! */
+ len = -1;
+ }
+ else if (length >= SI_IPv6_MAXLEN) {
+ /* Address is too long! */
+ len = -1;
+ }
+ else {
+ /* Assume inet_pton is sufficient validation */
+ struct in6_addr addr6;
+ char addrbuf[SI_IPv6_MAXLEN];
+
+ memcpy(addrbuf, addrString, length);
+ addrbuf[length] = '\0';
+
+ if (inet_pton(AF_INET6, addrbuf, &addr6) != 1) {
+ perror("inet_pton");
+ len = -1;
+ }
+ else {
+ len = length;
+ }
}
return len;
}
-#endif /* IPv6 */
+#endif /* IPv6 */
#if !defined(NO_LOCAL_CLIENT_CRED)
/***
@@ -1958,85 +1903,90 @@ siLocalCredGetId(const char *addr, int len, siLocalCredPrivPtr lcPriv, int *id)
char *addrbuf = malloc(len + 1);
if (addrbuf == NULL) {
- return FALSE;
+ return FALSE;
}
memcpy(addrbuf, addr, len);
addrbuf[len] = '\0';
- if (addr[0] == '#') { /* numeric id */
- char *cp;
- errno = 0;
- *id = strtol(addrbuf + 1, &cp, 0);
- if ((errno == 0) && (cp != (addrbuf+1))) {
- parsedOK = TRUE;
- }
- } else { /* non-numeric name */
- if (lcPriv->credType == LOCAL_USER) {
- struct passwd *pw = getpwnam(addrbuf);
-
- if (pw != NULL) {
- *id = (int) pw->pw_uid;
- parsedOK = TRUE;
- }
- } else { /* group */
- struct group *gr = getgrnam(addrbuf);
-
- if (gr != NULL) {
- *id = (int) gr->gr_gid;
- parsedOK = TRUE;
- }
- }
+ if (addr[0] == '#') { /* numeric id */
+ char *cp;
+
+ errno = 0;
+ *id = strtol(addrbuf + 1, &cp, 0);
+ if ((errno == 0) && (cp != (addrbuf + 1))) {
+ parsedOK = TRUE;
+ }
+ }
+ else { /* non-numeric name */
+ if (lcPriv->credType == LOCAL_USER) {
+ struct passwd *pw = getpwnam(addrbuf);
+
+ if (pw != NULL) {
+ *id = (int) pw->pw_uid;
+ parsedOK = TRUE;
+ }
+ }
+ else { /* group */
+ struct group *gr = getgrnam(addrbuf);
+
+ if (gr != NULL) {
+ *id = (int) gr->gr_gid;
+ parsedOK = TRUE;
+ }
+ }
}
free(addrbuf);
return parsedOK;
}
-static Bool
+static Bool
siLocalCredAddrMatch(int family, pointer addr, int len,
- const char *siAddr, int siAddrlen, ClientPtr client, void *typePriv)
+ const char *siAddr, int siAddrlen, ClientPtr client,
+ void *typePriv)
{
int siAddrId;
LocalClientCredRec *lcc;
siLocalCredPrivPtr lcPriv = (siLocalCredPrivPtr) typePriv;
if (GetLocalClientCreds(client, &lcc) == -1) {
- return FALSE;
+ return FALSE;
}
-#ifdef HAVE_GETZONEID /* Ensure process is in the same zone */
+#ifdef HAVE_GETZONEID /* Ensure process is in the same zone */
if ((lcc->fieldsSet & LCC_ZID_SET) && (lcc->zoneid != getzoneid())) {
- FreeLocalClientCreds(lcc);
- return FALSE;
+ FreeLocalClientCreds(lcc);
+ return FALSE;
}
#endif
if (siLocalCredGetId(siAddr, siAddrlen, lcPriv, &siAddrId) == FALSE) {
- FreeLocalClientCreds(lcc);
- return FALSE;
+ FreeLocalClientCreds(lcc);
+ return FALSE;
}
if (lcPriv->credType == LOCAL_USER) {
- if ((lcc->fieldsSet & LCC_UID_SET) && (lcc->euid == siAddrId)) {
- FreeLocalClientCreds(lcc);
- return TRUE;
- }
- } else {
- if ((lcc->fieldsSet & LCC_GID_SET) && (lcc->egid == siAddrId)) {
- FreeLocalClientCreds(lcc);
- return TRUE;
- }
- if (lcc->pSuppGids != NULL) {
- int i;
-
- for (i = 0 ; i < lcc->nSuppGids; i++) {
- if (lcc->pSuppGids[i] == siAddrId) {
- FreeLocalClientCreds(lcc);
- return TRUE;
- }
- }
- }
+ if ((lcc->fieldsSet & LCC_UID_SET) && (lcc->euid == siAddrId)) {
+ FreeLocalClientCreds(lcc);
+ return TRUE;
+ }
+ }
+ else {
+ if ((lcc->fieldsSet & LCC_GID_SET) && (lcc->egid == siAddrId)) {
+ FreeLocalClientCreds(lcc);
+ return TRUE;
+ }
+ if (lcc->pSuppGids != NULL) {
+ int i;
+
+ for (i = 0; i < lcc->nSuppGids; i++) {
+ if (lcc->pSuppGids[i] == siAddrId) {
+ FreeLocalClientCreds(lcc);
+ return TRUE;
+ }
+ }
+ }
}
FreeLocalClientCreds(lcc);
return FALSE;
@@ -2048,13 +1998,13 @@ siLocalCredCheckAddr(const char *addrString, int length, void *typePriv)
int len = length;
int id;
- if (siLocalCredGetId(addrString, length,
- (siLocalCredPrivPtr)typePriv, &id) == FALSE) {
- len = -1;
+ if (siLocalCredGetId(addrString, length,
+ (siLocalCredPrivPtr) typePriv, &id) == FALSE) {
+ len = -1;
}
return len;
}
-#endif /* localuser */
+#endif /* localuser */
static void
siTypesInitialize(void)
@@ -2064,9 +2014,9 @@ siTypesInitialize(void)
siTypeAdd("ipv6", siIPv6AddrMatch, siIPv6CheckAddr, NULL);
#endif
#if !defined(NO_LOCAL_CLIENT_CRED)
- siTypeAdd("localuser", siLocalCredAddrMatch, siLocalCredCheckAddr,
- &siLocalUserPriv);
- siTypeAdd("localgroup", siLocalCredAddrMatch, siLocalCredCheckAddr,
- &siLocalGroupPriv);
+ siTypeAdd("localuser", siLocalCredAddrMatch, siLocalCredCheckAddr,
+ &siLocalUserPriv);
+ siTypeAdd("localgroup", siLocalCredAddrMatch, siLocalCredCheckAddr,
+ &siLocalGroupPriv);
#endif
}
diff --git a/xorg-server/os/auth.c b/xorg-server/os/auth.c
index 6669c148e..ac20de47d 100644
--- a/xorg-server/os/auth.c
+++ b/xorg-server/os/auth.c
@@ -35,60 +35,60 @@ from The Open Group.
#include <dix-config.h>
#endif
-# include <X11/X.h>
-# include <X11/Xauth.h>
-# include "misc.h"
-# include "osdep.h"
-# include "dixstruct.h"
-# include <sys/types.h>
-# include <sys/stat.h>
+#include <X11/X.h>
+#include <X11/Xauth.h>
+#include "misc.h"
+#include "osdep.h"
+#include "dixstruct.h"
+#include <sys/types.h>
+#include <sys/stat.h>
#ifdef WIN32
#include <X11/Xw32defs.h>
#endif
struct protocol {
- unsigned short name_length;
- const char *name;
- AuthAddCFunc Add; /* new authorization data */
- AuthCheckFunc Check; /* verify client authorization data */
- AuthRstCFunc Reset; /* delete all authorization data entries */
- AuthToIDFunc ToID; /* convert cookie to ID */
- AuthFromIDFunc FromID; /* convert ID to cookie */
- AuthRemCFunc Remove; /* remove a specific cookie */
+ unsigned short name_length;
+ const char *name;
+ AuthAddCFunc Add; /* new authorization data */
+ AuthCheckFunc Check; /* verify client authorization data */
+ AuthRstCFunc Reset; /* delete all authorization data entries */
+ AuthToIDFunc ToID; /* convert cookie to ID */
+ AuthFromIDFunc FromID; /* convert ID to cookie */
+ AuthRemCFunc Remove; /* remove a specific cookie */
#ifdef XCSECURITY
- AuthGenCFunc Generate;
+ AuthGenCFunc Generate;
#endif
};
-static struct protocol protocols[] = {
-{ (unsigned short) 18, "MIT-MAGIC-COOKIE-1",
- MitAddCookie, MitCheckCookie, MitResetCookie,
- MitToID, MitFromID, MitRemoveCookie,
+static struct protocol protocols[] = {
+ {(unsigned short) 18, "MIT-MAGIC-COOKIE-1",
+ MitAddCookie, MitCheckCookie, MitResetCookie,
+ MitToID, MitFromID, MitRemoveCookie,
#ifdef XCSECURITY
- MitGenerateCookie
+ MitGenerateCookie
#endif
-},
+ },
#ifdef HASXDMAUTH
-{ (unsigned short) 19, "XDM-AUTHORIZATION-1",
- XdmAddCookie, XdmCheckCookie, XdmResetCookie,
- XdmToID, XdmFromID, XdmRemoveCookie,
+ {(unsigned short) 19, "XDM-AUTHORIZATION-1",
+ XdmAddCookie, XdmCheckCookie, XdmResetCookie,
+ XdmToID, XdmFromID, XdmRemoveCookie,
#ifdef XCSECURITY
- NULL
+ NULL
#endif
-},
+ },
#endif
#ifdef SECURE_RPC
-{ (unsigned short) 9, "SUN-DES-1",
- SecureRPCAdd, SecureRPCCheck, SecureRPCReset,
- SecureRPCToID, SecureRPCFromID,SecureRPCRemove,
+ {(unsigned short) 9, "SUN-DES-1",
+ SecureRPCAdd, SecureRPCCheck, SecureRPCReset,
+ SecureRPCToID, SecureRPCFromID, SecureRPCRemove,
#ifdef XCSECURITY
- NULL
+ NULL
#endif
-},
+ },
#endif
};
-# define NUM_AUTHORIZATION (sizeof (protocols) /\
+#define NUM_AUTHORIZATION (sizeof (protocols) /\
sizeof (struct protocol))
/*
@@ -96,47 +96,46 @@ static struct protocol protocols[] = {
* specified authorization file
*/
-static char *authorization_file = (char *)NULL;
+static char *authorization_file = (char *) NULL;
static Bool ShouldLoadAuth = TRUE;
void
-InitAuthorization (char *file_name)
+InitAuthorization(char *file_name)
{
authorization_file = file_name;
}
static int
-LoadAuthorization (void)
+LoadAuthorization(void)
{
- FILE *f;
- Xauth *auth;
- int i;
- int count = 0;
+ FILE *f;
+ Xauth *auth;
+ int i;
+ int count = 0;
ShouldLoadAuth = FALSE;
if (!authorization_file)
- return 0;
+ return 0;
- f = Fopen (authorization_file, "r");
+ f = Fopen(authorization_file, "r");
if (!f)
- return -1;
-
- while ((auth = XauReadAuth (f)) != 0) {
- for (i = 0; i < NUM_AUTHORIZATION; i++) {
- if (protocols[i].name_length == auth->name_length &&
- memcmp (protocols[i].name, auth->name, (int) auth->name_length) == 0 &&
- protocols[i].Add)
- {
- ++count;
- (*protocols[i].Add) (auth->data_length, auth->data,
- FakeClientID(0));
- }
- }
- XauDisposeAuth (auth);
+ return -1;
+
+ while ((auth = XauReadAuth(f)) != 0) {
+ for (i = 0; i < NUM_AUTHORIZATION; i++) {
+ if (protocols[i].name_length == auth->name_length &&
+ memcmp(protocols[i].name, auth->name,
+ (int) auth->name_length) == 0 && protocols[i].Add) {
+ ++count;
+ (*protocols[i].Add) (auth->data_length, auth->data,
+ FakeClientID(0));
+ }
+ }
+ XauDisposeAuth(auth);
}
- Fclose (f);
+ Fclose(f);
return count;
}
@@ -146,146 +145,134 @@ LoadAuthorization (void)
* schemes supported by the display
*/
void
-RegisterAuthorizations (void)
+RegisterAuthorizations(void)
{
- int i;
+ int i;
for (i = 0; i < NUM_AUTHORIZATION; i++)
- XdmcpRegisterAuthorization (protocols[i].name,
- (int)protocols[i].name_length);
+ XdmcpRegisterAuthorization(protocols[i].name,
+ (int) protocols[i].name_length);
}
#endif
XID
-CheckAuthorization (
- unsigned int name_length,
- const char *name,
- unsigned int data_length,
- const char *data,
- ClientPtr client,
- const char **reason) /* failure message. NULL for default msg */
-{
- int i;
+CheckAuthorization(unsigned int name_length,
+ const char *name,
+ unsigned int data_length,
+ const char *data, ClientPtr client, const char **reason)
+{ /* failure message. NULL for default msg */
+ int i;
struct stat buf;
static time_t lastmod = 0;
static Bool loaded = FALSE;
- if (!authorization_file || stat(authorization_file, &buf))
- {
- if (lastmod != 0) {
- lastmod = 0;
- ShouldLoadAuth = TRUE; /* stat lost, so force reload */
- }
+ if (!authorization_file || stat(authorization_file, &buf)) {
+ if (lastmod != 0) {
+ lastmod = 0;
+ ShouldLoadAuth = TRUE; /* stat lost, so force reload */
+ }
}
- else if (buf.st_mtime > lastmod)
- {
- lastmod = buf.st_mtime;
- ShouldLoadAuth = TRUE;
+ else if (buf.st_mtime > lastmod) {
+ lastmod = buf.st_mtime;
+ ShouldLoadAuth = TRUE;
}
- if (ShouldLoadAuth)
- {
- int loadauth = LoadAuthorization();
-
- /*
- * If the authorization file has at least one entry for this server,
- * disable local host access. (loadauth > 0)
- *
- * If there are zero entries (either initially or when the
- * authorization file is later reloaded), or if a valid
- * authorization file was never loaded, enable local host access.
- * (loadauth == 0 || !loaded)
- *
- * If the authorization file was loaded initially (with valid
- * entries for this server), and reloading it later fails, don't
- * change anything. (loadauth == -1 && loaded)
- */
-
- if (loadauth > 0)
- {
- DisableLocalHost(); /* got at least one */
- loaded = TRUE;
- }
- else if (loadauth == 0 || !loaded)
- EnableLocalHost ();
+ if (ShouldLoadAuth) {
+ int loadauth = LoadAuthorization();
+
+ /*
+ * If the authorization file has at least one entry for this server,
+ * disable local host access. (loadauth > 0)
+ *
+ * If there are zero entries (either initially or when the
+ * authorization file is later reloaded), or if a valid
+ * authorization file was never loaded, enable local host access.
+ * (loadauth == 0 || !loaded)
+ *
+ * If the authorization file was loaded initially (with valid
+ * entries for this server), and reloading it later fails, don't
+ * change anything. (loadauth == -1 && loaded)
+ */
+
+ if (loadauth > 0) {
+ DisableLocalHost(); /* got at least one */
+ loaded = TRUE;
+ }
+ else if (loadauth == 0 || !loaded)
+ EnableLocalHost();
}
if (name_length) {
- for (i = 0; i < NUM_AUTHORIZATION; i++) {
- if (protocols[i].name_length == name_length &&
- memcmp (protocols[i].name, name, (int) name_length) == 0)
- {
- return (*protocols[i].Check) (data_length, data, client, reason);
- }
- *reason = "Protocol not supported by server\n";
- }
- } else *reason = "No protocol specified\n";
+ for (i = 0; i < NUM_AUTHORIZATION; i++) {
+ if (protocols[i].name_length == name_length &&
+ memcmp(protocols[i].name, name, (int) name_length) == 0) {
+ return (*protocols[i].Check) (data_length, data, client,
+ reason);
+ }
+ *reason = "Protocol not supported by server\n";
+ }
+ }
+ else
+ *reason = "No protocol specified\n";
return (XID) ~0L;
}
void
-ResetAuthorization (void)
+ResetAuthorization(void)
{
- int i;
+ int i;
for (i = 0; i < NUM_AUTHORIZATION; i++)
- if (protocols[i].Reset)
- (*protocols[i].Reset)();
+ if (protocols[i].Reset)
+ (*protocols[i].Reset) ();
ShouldLoadAuth = TRUE;
}
int
-AuthorizationFromID (
- XID id,
- unsigned short *name_lenp,
- const char **namep,
- unsigned short *data_lenp,
- char **datap)
+AuthorizationFromID(XID id,
+ unsigned short *name_lenp,
+ const char **namep, unsigned short *data_lenp, char **datap)
{
- int i;
+ int i;
for (i = 0; i < NUM_AUTHORIZATION; i++) {
- if (protocols[i].FromID &&
- (*protocols[i].FromID) (id, data_lenp, datap)) {
- *name_lenp = protocols[i].name_length;
- *namep = protocols[i].name;
- return 1;
- }
+ if (protocols[i].FromID &&
+ (*protocols[i].FromID) (id, data_lenp, datap)) {
+ *name_lenp = protocols[i].name_length;
+ *namep = protocols[i].name;
+ return 1;
+ }
}
return 0;
}
int
-RemoveAuthorization (
- unsigned short name_length,
- const char *name,
- unsigned short data_length,
- const char *data)
+RemoveAuthorization(unsigned short name_length,
+ const char *name,
+ unsigned short data_length, const char *data)
{
- int i;
+ int i;
for (i = 0; i < NUM_AUTHORIZATION; i++) {
- if (protocols[i].name_length == name_length &&
- memcmp (protocols[i].name, name, (int) name_length) == 0 &&
- protocols[i].Remove)
- {
- return (*protocols[i].Remove) (data_length, data);
- }
+ if (protocols[i].name_length == name_length &&
+ memcmp(protocols[i].name, name, (int) name_length) == 0 &&
+ protocols[i].Remove) {
+ return (*protocols[i].Remove) (data_length, data);
+ }
}
return 0;
}
int
-AddAuthorization (unsigned name_length, const char *name,
- unsigned data_length, char *data)
+AddAuthorization(unsigned name_length, const char *name,
+ unsigned data_length, char *data)
{
- int i;
+ int i;
for (i = 0; i < NUM_AUTHORIZATION; i++) {
- if (protocols[i].name_length == name_length &&
- memcmp (protocols[i].name, name, (int) name_length) == 0 &&
- protocols[i].Add)
- {
- return (*protocols[i].Add) (data_length, data, FakeClientID(0));
- }
+ if (protocols[i].name_length == name_length &&
+ memcmp(protocols[i].name, name, (int) name_length) == 0 &&
+ protocols[i].Add) {
+ return (*protocols[i].Add) (data_length, data, FakeClientID(0));
+ }
}
return 0;
}
@@ -293,30 +280,28 @@ AddAuthorization (unsigned name_length, const char *name,
#ifdef XCSECURITY
XID
-GenerateAuthorization(
- unsigned name_length,
- const char *name,
- unsigned data_length,
- const char *data,
- unsigned *data_length_return,
- char **data_return)
+GenerateAuthorization(unsigned name_length,
+ const char *name,
+ unsigned data_length,
+ const char *data,
+ unsigned *data_length_return, char **data_return)
{
- int i;
+ int i;
for (i = 0; i < NUM_AUTHORIZATION; i++) {
- if (protocols[i].name_length == name_length &&
- memcmp (protocols[i].name, name, (int) name_length) == 0 &&
- protocols[i].Generate)
- {
- return (*protocols[i].Generate) (data_length, data,
- FakeClientID(0), data_length_return, data_return);
- }
+ if (protocols[i].name_length == name_length &&
+ memcmp(protocols[i].name, name, (int) name_length) == 0 &&
+ protocols[i].Generate) {
+ return (*protocols[i].Generate) (data_length, data,
+ FakeClientID(0),
+ data_length_return, data_return);
+ }
}
return -1;
}
void
-GenerateRandomData (int len, char *buf)
+GenerateRandomData(int len, char *buf)
{
int fd;
@@ -325,4 +310,4 @@ GenerateRandomData (int len, char *buf)
close(fd);
}
-#endif /* XCSECURITY */
+#endif /* XCSECURITY */
diff --git a/xorg-server/os/backtrace.c b/xorg-server/os/backtrace.c
index edaeb17c7..81348f417 100644
--- a/xorg-server/os/backtrace.c
+++ b/xorg-server/os/backtrace.c
@@ -37,53 +37,61 @@
#include <dlfcn.h>
#include <execinfo.h>
-void xorg_backtrace(void)
+void
+xorg_backtrace(void)
{
void *array[64];
const char *mod;
int size, i;
Dl_info info;
+
ErrorF("\n");
ErrorF("Backtrace:\n");
size = backtrace(array, 64);
for (i = 0; i < size; i++) {
- int rc = dladdr(array[i], &info);
- if (rc == 0) {
- ErrorF("%d: ?? [%p]\n", i, array[i]);
- continue;
- }
- mod = (info.dli_fname && *info.dli_fname) ? info.dli_fname : "(vdso)";
- if (info.dli_saddr)
- ErrorF("%d: %s (%s+0x%lx) [%p]\n", i, mod,
- info.dli_sname, (long unsigned int)((char *) array[i] - (char *) info.dli_saddr), array[i]);
- else
- ErrorF("%d: %s (%p+0x%lx) [%p]\n", i, mod,
- info.dli_fbase, (long unsigned int)((char *) array[i] - (char *) info.dli_fbase), array[i]);
+ int rc = dladdr(array[i], &info);
+
+ if (rc == 0) {
+ ErrorF("%d: ?? [%p]\n", i, array[i]);
+ continue;
+ }
+ mod = (info.dli_fname && *info.dli_fname) ? info.dli_fname : "(vdso)";
+ if (info.dli_saddr)
+ ErrorF("%d: %s (%s+0x%lx) [%p]\n", i, mod,
+ info.dli_sname,
+ (long unsigned int) ((char *) array[i] -
+ (char *) info.dli_saddr), array[i]);
+ else
+ ErrorF("%d: %s (%p+0x%lx) [%p]\n", i, mod,
+ info.dli_fbase,
+ (long unsigned int) ((char *) array[i] -
+ (char *) info.dli_fbase), array[i]);
}
ErrorF("\n");
}
-#else /* not glibc or glibc < 2.1 */
+#else /* not glibc or glibc < 2.1 */
-# if defined(sun) && defined(__SVR4)
-# define HAVE_PSTACK
-# endif
+#if defined(sun) && defined(__SVR4)
+#define HAVE_PSTACK
+#endif
-# if defined(HAVE_WALKCONTEXT) /* Solaris 9 & later */
+#if defined(HAVE_WALKCONTEXT) /* Solaris 9 & later */
-# include <ucontext.h>
-# include <signal.h>
-# include <dlfcn.h>
-# include <sys/elf.h>
+#include <ucontext.h>
+#include <signal.h>
+#include <dlfcn.h>
+#include <sys/elf.h>
#ifdef _LP64
-# define ElfSym Elf64_Sym
+#define ElfSym Elf64_Sym
#else
-# define ElfSym Elf32_Sym
+#define ElfSym Elf32_Sym
#endif
/* Called for each frame on the stack to print it's contents */
-static int xorg_backtrace_frame(uintptr_t pc, int signo, void *arg)
+static int
+xorg_backtrace_frame(uintptr_t pc, int signo, void *arg)
{
Dl_info dlinfo;
ElfSym *dlsym;
@@ -91,13 +99,13 @@ static int xorg_backtrace_frame(uintptr_t pc, int signo, void *arg)
int depth = *((int *) arg);
if (signo) {
- char signame[SIG2STR_MAX];
+ char signame[SIG2STR_MAX];
- if (sig2str(signo, signame) != 0) {
- strcpy(signame, "unknown");
- }
+ if (sig2str(signo, signame) != 0) {
+ strcpy(signame, "unknown");
+ }
- ErrorF("** Signal %d (%s)\n", signo, signame);
+ ErrorF("** Signal %d (%s)\n", signo, signame);
}
snprintf(header, sizeof(header), "%d: 0x%lx", depth, pc);
@@ -105,118 +113,127 @@ static int xorg_backtrace_frame(uintptr_t pc, int signo, void *arg)
/* Ask system dynamic loader for info on the address */
if (dladdr1((void *) pc, &dlinfo, (void **) &dlsym, RTLD_DL_SYMENT)) {
- unsigned long offset = pc - (uintptr_t) dlinfo.dli_saddr;
- const char *symname;
-
- if (offset < dlsym->st_size) { /* inside a function */
- symname = dlinfo.dli_sname;
- } else { /* found which file it was in, but not which function */
- symname = "<section start>";
- offset = pc - (uintptr_t)dlinfo.dli_fbase;
- }
- ErrorF("%s: %s:%s+0x%lx\n", header, dlinfo.dli_fname,
- symname, offset);
-
- } else {
- /* Couldn't find symbol info from system dynamic loader, should
- * probably poke elfloader here, but haven't written that code yet,
- * so we just print the pc.
- */
- ErrorF("%s\n", header);
+ unsigned long offset = pc - (uintptr_t) dlinfo.dli_saddr;
+ const char *symname;
+
+ if (offset < dlsym->st_size) { /* inside a function */
+ symname = dlinfo.dli_sname;
+ }
+ else { /* found which file it was in, but not which function */
+ symname = "<section start>";
+ offset = pc - (uintptr_t) dlinfo.dli_fbase;
+ }
+ ErrorF("%s: %s:%s+0x%lx\n", header, dlinfo.dli_fname, symname, offset);
+
+ }
+ else {
+ /* Couldn't find symbol info from system dynamic loader, should
+ * probably poke elfloader here, but haven't written that code yet,
+ * so we just print the pc.
+ */
+ ErrorF("%s\n", header);
}
return 0;
}
-# endif /* HAVE_WALKCONTEXT */
+#endif /* HAVE_WALKCONTEXT */
-# ifdef HAVE_PSTACK
-static int xorg_backtrace_pstack(void) {
+#ifdef HAVE_PSTACK
+static int
+xorg_backtrace_pstack(void)
+{
pid_t kidpid;
int pipefd[2];
if (pipe(pipefd) != 0) {
- return -1;
+ return -1;
}
kidpid = fork1();
if (kidpid == -1) {
- /* ERROR */
- return -1;
- } else if (kidpid == 0) {
- /* CHILD */
- char parent[16];
-
- seteuid(0);
- close(STDIN_FILENO);
- close(STDOUT_FILENO);
- dup2(pipefd[1],STDOUT_FILENO);
- closefrom(STDERR_FILENO);
-
- snprintf(parent, sizeof(parent), "%d", getppid());
- execle("/usr/bin/pstack", "pstack", parent, NULL);
- exit(1);
- } else {
- /* PARENT */
- char btline[256];
- int kidstat;
- int bytesread;
- int done = 0;
-
- close(pipefd[1]);
-
- while (!done) {
- bytesread = read(pipefd[0], btline, sizeof(btline) - 1);
-
- if (bytesread > 0) {
- btline[bytesread] = 0;
- ErrorF("%s", btline);
- }
- else if ((bytesread < 0) ||
- ((errno != EINTR) && (errno != EAGAIN)))
- done = 1;
- }
- close(pipefd[0]);
- waitpid(kidpid, &kidstat, 0);
- if (kidstat != 0)
- return -1;
+ /* ERROR */
+ return -1;
+ }
+ else if (kidpid == 0) {
+ /* CHILD */
+ char parent[16];
+
+ seteuid(0);
+ close(STDIN_FILENO);
+ close(STDOUT_FILENO);
+ dup2(pipefd[1], STDOUT_FILENO);
+ closefrom(STDERR_FILENO);
+
+ snprintf(parent, sizeof(parent), "%d", getppid());
+ execle("/usr/bin/pstack", "pstack", parent, NULL);
+ exit(1);
+ }
+ else {
+ /* PARENT */
+ char btline[256];
+ int kidstat;
+ int bytesread;
+ int done = 0;
+
+ close(pipefd[1]);
+
+ while (!done) {
+ bytesread = read(pipefd[0], btline, sizeof(btline) - 1);
+
+ if (bytesread > 0) {
+ btline[bytesread] = 0;
+ ErrorF("%s", btline);
+ }
+ else if ((bytesread < 0) || ((errno != EINTR) && (errno != EAGAIN)))
+ done = 1;
+ }
+ close(pipefd[0]);
+ waitpid(kidpid, &kidstat, 0);
+ if (kidstat != 0)
+ return -1;
}
return 0;
}
-# endif /* HAVE_PSTACK */
-
+#endif /* HAVE_PSTACK */
-# if defined(HAVE_PSTACK) || defined(HAVE_WALKCONTEXT)
+#if defined(HAVE_PSTACK) || defined(HAVE_WALKCONTEXT)
-void xorg_backtrace(void) {
+void
+xorg_backtrace(void)
+{
ErrorF("\n");
ErrorF("Backtrace:\n");
-# ifdef HAVE_PSTACK
+#ifdef HAVE_PSTACK
/* First try fork/exec of pstack - otherwise fall back to walkcontext
pstack is preferred since it can print names of non-exported functions */
if (xorg_backtrace_pstack() < 0)
-# endif
+#endif
{
-# ifdef HAVE_WALKCONTEXT
- ucontext_t u;
- int depth = 1;
-
- if (getcontext(&u) == 0)
- walkcontext(&u, xorg_backtrace_frame, &depth);
- else
-# endif
- ErrorF("Failed to get backtrace info: %s\n", strerror(errno));
+#ifdef HAVE_WALKCONTEXT
+ ucontext_t u;
+ int depth = 1;
+
+ if (getcontext(&u) == 0)
+ walkcontext(&u, xorg_backtrace_frame, &depth);
+ else
+#endif
+ ErrorF("Failed to get backtrace info: %s\n", strerror(errno));
}
ErrorF("\n");
}
-# else
+#else
/* Default fallback if we can't find any way to get a backtrace */
-void xorg_backtrace(void) { return; }
+void
+xorg_backtrace(void)
+{
+ return;
+}
-# endif
+#endif
#endif
diff --git a/xorg-server/os/client.c b/xorg-server/os/client.c
index fbccf22ed..ef5e3935d 100644
--- a/xorg-server/os/client.c
+++ b/xorg-server/os/client.c
@@ -85,7 +85,8 @@
*
* @see GetClientPid
*/
-pid_t DetermineClientPid(struct _Client *client)
+pid_t
+DetermineClientPid(struct _Client * client)
{
LocalClientCredRec *lcc = NULL;
pid_t pid = -1;
@@ -96,8 +97,7 @@ pid_t DetermineClientPid(struct _Client *client)
if (client == serverClient)
return getpid();
- if (GetLocalClientCreds(client, &lcc) != -1)
- {
+ if (GetLocalClientCreds(client, &lcc) != -1) {
if (lcc->fieldsSet & LCC_PID_SET)
pid = lcc->pid;
FreeLocalClientCreds(lcc);
@@ -127,7 +127,8 @@ pid_t DetermineClientPid(struct _Client *client)
*
* @see GetClientCmdName/Args
*/
-void DetermineClientCmd(pid_t pid, const char **cmdname, const char **cmdargs)
+void
+DetermineClientCmd(pid_t pid, const char **cmdname, const char **cmdargs)
{
char path[PATH_MAX + 1];
int totsize = 0;
@@ -141,20 +142,18 @@ void DetermineClientCmd(pid_t pid, const char **cmdname, const char **cmdargs)
if (pid == -1)
return;
-#ifdef __sun /* Solaris */
+#ifdef __sun /* Solaris */
/* Solaris does not support /proc/pid/cmdline, but makes information
* similar to what ps shows available in a binary structure in the
* /proc/pid/psinfo file. */
if (snprintf(path, sizeof(path), "/proc/%d/psinfo", pid) < 0)
return;
fd = open(path, O_RDONLY);
- if (fd < 0)
- {
- ErrorF ("Failed to open %s: %s\n", path, strerror(errno));
+ if (fd < 0) {
+ ErrorF("Failed to open %s: %s\n", path, strerror(errno));
return;
}
- else
- {
+ else {
psinfo_t psinfo = { 0 };
char *sp;
@@ -170,7 +169,7 @@ void DetermineClientCmd(pid_t pid, const char **cmdname, const char **cmdargs)
* the file that was exec'ed, thus cutting off many long gnome
* command names, or returning "isapython2.6" for all python scripts.
*/
- psinfo.pr_psargs[PRARGSZ-1] = '\0';
+ psinfo.pr_psargs[PRARGSZ - 1] = '\0';
sp = strchr(psinfo.pr_psargs, ' ');
if (sp)
*sp++ = '\0';
@@ -184,36 +183,37 @@ void DetermineClientCmd(pid_t pid, const char **cmdname, const char **cmdargs)
#elif defined(__OpenBSD__)
/* on OpenBSD use kvm_getargv() */
{
- kvm_t *kd;
- char errbuf[_POSIX2_LINE_MAX];
- char **argv;
- struct kinfo_proc *kp;
- size_t len = 0;
- int i, n;
-
- kd = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, errbuf);
- if (kd == NULL)
- return;
- kp = kvm_getprocs(kd, KERN_PROC_PID, pid, sizeof(struct kinfo_proc), &n);
- if (n != 1)
- return;
- argv = kvm_getargv(kd, kp, 0);
- *cmdname = strdup(argv[0]);
- i = 1;
- while (argv[i] != NULL) {
- len += strlen(argv[i]) + 1;
- i++;
- }
- *cmdargs = calloc(1, len);
- i = 1;
- while (argv[i] != NULL) {
- strlcat(*cmdargs, argv[i], len);
- strlcat(*cmdargs, " ", len);
- i++;
- }
- kvm_close(kd);
+ kvm_t *kd;
+ char errbuf[_POSIX2_LINE_MAX];
+ char **argv;
+ struct kinfo_proc *kp;
+ size_t len = 0;
+ int i, n;
+
+ kd = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, errbuf);
+ if (kd == NULL)
+ return;
+ kp = kvm_getprocs(kd, KERN_PROC_PID, pid, sizeof(struct kinfo_proc),
+ &n);
+ if (n != 1)
+ return;
+ argv = kvm_getargv(kd, kp, 0);
+ *cmdname = strdup(argv[0]);
+ i = 1;
+ while (argv[i] != NULL) {
+ len += strlen(argv[i]) + 1;
+ i++;
+ }
+ *cmdargs = calloc(1, len);
+ i = 1;
+ while (argv[i] != NULL) {
+ strlcat(*cmdargs, argv[i], len);
+ strlcat(*cmdargs, " ", len);
+ i++;
+ }
+ kvm_close(kd);
}
-#else /* Linux using /proc/pid/cmdline */
+#else /* Linux using /proc/pid/cmdline */
/* Check if /proc/pid/cmdline exists. It's not supported on all
* operating systems. */
@@ -232,26 +232,24 @@ void DetermineClientCmd(pid_t pid, const char **cmdname, const char **cmdargs)
path[totsize - 1] = '\0';
/* Contruct the process name without arguments. */
- if (cmdname)
- {
+ if (cmdname) {
*cmdname = strdup(path);
}
/* Construct the arguments for client process. */
- if (cmdargs)
- {
+ if (cmdargs) {
int cmdsize = strlen(path) + 1;
int argsize = totsize - cmdsize;
char *args = NULL;
if (argsize > 0)
args = malloc(argsize);
- if (args)
- {
+ if (args) {
int i = 0;
- for (i = 0; i < (argsize - 1); ++i)
- {
+
+ for (i = 0; i < (argsize - 1); ++i) {
const char c = path[cmdsize + i];
+
args[i] = (c == '\0') ? ' ' : c;
}
args[argsize - 1] = '\0';
@@ -266,7 +264,8 @@ void DetermineClientCmd(pid_t pid, const char **cmdname, const char **cmdargs)
*
* @param[in] client Recently connected client.
*/
-void ReserveClientIds(struct _Client *client)
+void
+ReserveClientIds(struct _Client *client)
{
#ifdef CLIENTIDS
if (client == NullClient)
@@ -279,7 +278,8 @@ void ReserveClientIds(struct _Client *client)
client->clientIds->pid = DetermineClientPid(client);
if (client->clientIds->pid != -1)
- DetermineClientCmd(client->clientIds->pid, &client->clientIds->cmdname, &client->clientIds->cmdargs);
+ DetermineClientCmd(client->clientIds->pid, &client->clientIds->cmdname,
+ &client->clientIds->cmdargs);
DebugF("client(%lx): Reserved pid(%d).\n",
(unsigned long) client->clientAsMask, client->clientIds->pid);
@@ -287,7 +287,7 @@ void ReserveClientIds(struct _Client *client)
(unsigned long) client->clientAsMask,
client->clientIds->cmdname ? client->clientIds->cmdname : "NULL",
client->clientIds->cmdargs ? client->clientIds->cmdargs : "NULL");
-#endif /* CLIENTIDS */
+#endif /* CLIENTIDS */
}
/**
@@ -296,7 +296,8 @@ void ReserveClientIds(struct _Client *client)
*
* @param[in] client Recently disconnected client.
*/
-void ReleaseClientIds(struct _Client *client)
+void
+ReleaseClientIds(struct _Client *client)
{
#ifdef CLIENTIDS
if (client == NullClient)
@@ -312,11 +313,11 @@ void ReleaseClientIds(struct _Client *client)
client->clientIds->cmdname ? client->clientIds->cmdname : "NULL",
client->clientIds->cmdargs ? client->clientIds->cmdargs : "NULL");
- free((void *) client->clientIds->cmdname); /* const char * */
- free((void *) client->clientIds->cmdargs); /* const char * */
+ free((void *) client->clientIds->cmdname); /* const char * */
+ free((void *) client->clientIds->cmdargs); /* const char * */
free(client->clientIds);
client->clientIds = NULL;
-#endif /* CLIENTIDS */
+#endif /* CLIENTIDS */
}
/**
@@ -331,7 +332,8 @@ void ReleaseClientIds(struct _Client *client)
*
* @see DetermineClientPid
*/
-pid_t GetClientPid(struct _Client *client)
+pid_t
+GetClientPid(struct _Client *client)
{
if (client == NullClient)
return -1;
@@ -356,7 +358,8 @@ pid_t GetClientPid(struct _Client *client)
*
* @see DetermineClientCmd
*/
-const char *GetClientCmdName(struct _Client *client)
+const char *
+GetClientCmdName(struct _Client *client)
{
if (client == NullClient)
return NULL;
@@ -381,7 +384,8 @@ const char *GetClientCmdName(struct _Client *client)
*
* @see DetermineClientCmd
*/
-const char *GetClientCmdArgs(struct _Client *client)
+const char *
+GetClientCmdArgs(struct _Client *client)
{
if (client == NullClient)
return NULL;
diff --git a/xorg-server/os/connection.c b/xorg-server/os/connection.c
index 0e557a544..1099752e4 100644
--- a/xorg-server/os/connection.c
+++ b/xorg-server/os/connection.c
@@ -22,7 +22,6 @@ Except as contained in this notice, the name of The Open Group shall 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 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
@@ -83,28 +82,26 @@ SOFTWARE.
#ifndef WIN32
#include <sys/socket.h>
-
-
#if defined(TCPCONN) || defined(STREAMSCONN)
-# include <netinet/in.h>
-# include <arpa/inet.h>
-# ifdef apollo
-# ifndef NO_TCP_H
-# include <netinet/tcp.h>
-# endif
-# else
-# ifdef CSRG_BASED
-# include <sys/param.h>
-# endif
-# include <netinet/tcp.h>
-# endif
-# include <arpa/inet.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#ifdef apollo
+#ifndef NO_TCP_H
+#include <netinet/tcp.h>
+#endif
+#else
+#ifdef CSRG_BASED
+#include <sys/param.h>
+#endif
+#include <netinet/tcp.h>
+#endif
+#include <arpa/inet.h>
#endif
#include <sys/uio.h>
-#endif /* WIN32 */
-#include "misc.h" /* for typedef of pointer */
+#endif /* WIN32 */
+#include "misc.h" /* for typedef of pointer */
#include "osdep.h"
#include <X11/Xpoll.h>
#include "opaque.h"
@@ -113,39 +110,39 @@ SOFTWARE.
#define Pid_t pid_t
-
#ifdef HAVE_GETPEERUCRED
-# include <ucred.h>
-# include <zone.h>
+#include <ucred.h>
+#include <zone.h>
#endif
#ifdef XSERVER_DTRACE
-# include <sys/types.h>
+#include <sys/types.h>
typedef const char *string;
-# ifndef HAVE_GETPEERUCRED
-# define zoneid_t int
-# endif
-# include "../dix/Xserver-dtrace.h"
+
+#ifndef HAVE_GETPEERUCRED
+#define zoneid_t int
+#endif
+#include "../dix/Xserver-dtrace.h"
#endif
-static int lastfdesc; /* maximum file descriptor */
+static int lastfdesc; /* maximum file descriptor */
-fd_set WellKnownConnections; /* Listener mask */
-fd_set EnabledDevices; /* mask for input devices that are on */
-fd_set AllSockets; /* select on this */
-fd_set AllClients; /* available clients */
-fd_set LastSelectMask; /* mask returned from last select call */
-fd_set ClientsWithInput; /* clients with FULL requests in buffer */
-fd_set ClientsWriteBlocked; /* clients who cannot receive output */
-fd_set OutputPending; /* clients with reply/event data ready to go */
+fd_set WellKnownConnections; /* Listener mask */
+fd_set EnabledDevices; /* mask for input devices that are on */
+fd_set AllSockets; /* select on this */
+fd_set AllClients; /* available clients */
+fd_set LastSelectMask; /* mask returned from last select call */
+fd_set ClientsWithInput; /* clients with FULL requests in buffer */
+fd_set ClientsWriteBlocked; /* clients who cannot receive output */
+fd_set OutputPending; /* clients with reply/event data ready to go */
int MaxClients = 0;
-Bool NewOutputPending; /* not yet attempted to write some new output */
-Bool AnyClientsWriteBlocked; /* true if some client blocked on write */
+Bool NewOutputPending; /* not yet attempted to write some new output */
+Bool AnyClientsWriteBlocked; /* true if some client blocked on write */
-static Bool RunFromSmartParent; /* send SIGUSR1 to parent process */
-Bool RunFromSigStopParent; /* send SIGSTOP to our own process; Upstart (or
- equivalent) will send SIGCONT back. */
-Bool PartialNetwork; /* continue even if unable to bind all addrs */
+static Bool RunFromSmartParent; /* send SIGUSR1 to parent process */
+Bool RunFromSigStopParent; /* send SIGSTOP to our own process; Upstart (or
+ equivalent) will send SIGCONT back. */
+Bool PartialNetwork; /* continue even if unable to bind all addrs */
static Pid_t ParentProcess;
static Bool debug_conns = FALSE;
@@ -180,16 +177,18 @@ struct _ct_node {
struct _ct_node *ct_head[256];
-void InitConnectionTranslation(void)
+void
+InitConnectionTranslation(void)
{
memset(ct_head, 0, sizeof(ct_head));
}
-int GetConnectionTranslation(int conn)
+int
+GetConnectionTranslation(int conn)
{
struct _ct_node *node = ct_head[conn & 0xff];
- while (node != NULL)
- {
+
+ while (node != NULL) {
if (node->key == conn)
return node->value;
node = node->next;
@@ -197,16 +196,16 @@ int GetConnectionTranslation(int conn)
return 0;
}
-void SetConnectionTranslation(int conn, int client)
+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)
- {
+
+ if (client == 0) { /* remove entry */
+ while (*node != NULL) {
+ if ((*node)->key == conn) {
struct _ct_node *temp = *node;
+
*node = (*node)->next;
free(temp);
return;
@@ -214,12 +213,10 @@ void SetConnectionTranslation(int conn, int client)
node = &((*node)->next);
}
return;
- } else
- {
- while (*node != NULL)
- {
- if ((*node)->key == conn)
- {
+ }
+ else {
+ while (*node != NULL) {
+ if ((*node)->key == conn) {
(*node)->value = client;
return;
}
@@ -233,15 +230,17 @@ void SetConnectionTranslation(int conn, int client)
}
}
-void ClearConnectionTranslation(void)
+void
+ClearConnectionTranslation(void)
{
unsigned i;
- for (i = 0; i < 256; i++)
- {
+
+ for (i = 0; i < 256; i++) {
struct _ct_node *node = ct_head[i];
- while (node != NULL)
- {
+
+ while (node != NULL) {
struct _ct_node *temp = node;
+
node = node->next;
free(temp);
}
@@ -249,21 +248,21 @@ void ClearConnectionTranslation(void)
}
#endif
-static XtransConnInfo *ListenTransConns = NULL;
-static int *ListenTransFds = NULL;
-static int ListenTransCount;
+static XtransConnInfo *ListenTransConns = NULL;
+static int *ListenTransFds = NULL;
+static int ListenTransCount;
-static void ErrorConnMax(XtransConnInfo /* trans_conn */);
+static void ErrorConnMax(XtransConnInfo /* trans_conn */ );
static XtransConnInfo
-lookup_trans_conn (int fd)
+lookup_trans_conn(int fd)
{
- if (ListenTransFds)
- {
- int i;
- for (i = 0; i < ListenTransCount; i++)
- if (ListenTransFds[i] == fd)
- return ListenTransConns[i];
+ if (ListenTransFds) {
+ int i;
+
+ for (i = 0; i < ListenTransCount; i++)
+ if (ListenTransFds[i] == fd)
+ return ListenTransConns[i];
}
return NULL;
@@ -284,28 +283,27 @@ InitConnectionLimits(void)
#ifdef HAVE_GETDTABLESIZE
if (lastfdesc < 0)
- lastfdesc = getdtablesize() - 1;
+ lastfdesc = getdtablesize() - 1;
#endif
#ifdef _NFILE
if (lastfdesc < 0)
- lastfdesc = _NFILE - 1;
+ lastfdesc = _NFILE - 1;
#endif
-#endif /* __CYGWIN__ */
+#endif /* __CYGWIN__ */
/* This is the fallback */
if (lastfdesc < 0)
- lastfdesc = MAXSOCKS;
+ lastfdesc = MAXSOCKS;
if (lastfdesc > MAXSELECT)
- lastfdesc = MAXSELECT;
+ lastfdesc = MAXSELECT;
- if (lastfdesc > MAXCLIENTS)
- {
- lastfdesc = MAXCLIENTS;
- if (debug_conns)
- ErrorF( "REACHED MAXIMUM CLIENTS LIMIT %d\n", MAXCLIENTS);
+ if (lastfdesc > MAXCLIENTS) {
+ lastfdesc = MAXCLIENTS;
+ if (debug_conns)
+ ErrorF("REACHED MAXIMUM CLIENTS LIMIT %d\n", MAXCLIENTS);
}
MaxClients = lastfdesc;
@@ -315,7 +313,7 @@ InitConnectionLimits(void)
#if !defined(WIN32)
if (!ConnectionTranslation)
- ConnectionTranslation = (int *)xnfalloc(sizeof(int)*(lastfdesc + 1));
+ ConnectionTranslation = (int *) xnfalloc(sizeof(int) * (lastfdesc + 1));
#else
InitConnectionTranslation();
#endif
@@ -339,11 +337,12 @@ InitParentProcess(void)
{
#if !defined(WIN32)
OsSigHandlerPtr handler;
- handler = OsSignal (SIGUSR1, SIG_IGN);
- if ( handler == SIG_IGN)
- RunFromSmartParent = TRUE;
+
+ handler = OsSignal(SIGUSR1, SIG_IGN);
+ if (handler == SIG_IGN)
+ RunFromSmartParent = TRUE;
OsSignal(SIGUSR1, handler);
- ParentProcess = getppid ();
+ ParentProcess = getppid();
#endif
}
@@ -352,12 +351,12 @@ NotifyParentProcess(void)
{
#if !defined(WIN32)
if (RunFromSmartParent) {
- if (ParentProcess > 1) {
- kill (ParentProcess, SIGUSR1);
- }
+ if (ParentProcess > 1) {
+ kill(ParentProcess, SIGUSR1);
+ }
}
if (RunFromSigStopParent)
- raise (SIGSTOP);
+ raise(SIGSTOP);
#endif
}
@@ -369,9 +368,9 @@ NotifyParentProcess(void)
void
CreateWellKnownSockets(void)
{
- int i;
- int partial;
- char port[20];
+ int i;
+ int partial;
+ char port[20];
FD_ZERO(&AllSockets);
FD_ZERO(&AllClients);
@@ -379,108 +378,102 @@ CreateWellKnownSockets(void)
FD_ZERO(&ClientsWithInput);
#if !defined(WIN32)
- for (i=0; i<MaxClients; i++) ConnectionTranslation[i] = 0;
+ for (i = 0; i < MaxClients; i++)
+ ConnectionTranslation[i] = 0;
#else
ClearConnectionTranslation();
#endif
- FD_ZERO (&WellKnownConnections);
+ FD_ZERO(&WellKnownConnections);
- snprintf (port, sizeof(port), "%d", atoi (display));
+ snprintf(port, sizeof(port), "%d", atoi(display));
- if ((_XSERVTransMakeAllCOTSServerListeners (port, &partial,
- &ListenTransCount, &ListenTransConns) >= 0) &&
- (ListenTransCount >= 1))
- {
- if (!PartialNetwork && partial)
- {
- FatalError ("Failed to establish all listening sockets");
- }
- else
- {
- ListenTransFds = malloc(ListenTransCount * sizeof (int));
-
- for (i = 0; i < ListenTransCount; i++)
- {
- int fd = _XSERVTransGetConnectionNumber (ListenTransConns[i]);
-
- ListenTransFds[i] = fd;
- FD_SET (fd, &WellKnownConnections);
-
- if (!_XSERVTransIsLocal (ListenTransConns[i]))
- {
- DefineSelf (fd);
- }
- }
- }
+ if ((_XSERVTransMakeAllCOTSServerListeners(port, &partial,
+ &ListenTransCount,
+ &ListenTransConns) >= 0) &&
+ (ListenTransCount >= 1)) {
+ if (!PartialNetwork && partial) {
+ FatalError("Failed to establish all listening sockets");
+ }
+ else {
+ ListenTransFds = malloc(ListenTransCount * sizeof(int));
+
+ for (i = 0; i < ListenTransCount; i++) {
+ int fd = _XSERVTransGetConnectionNumber(ListenTransConns[i]);
+
+ ListenTransFds[i] = fd;
+ FD_SET(fd, &WellKnownConnections);
+
+ if (!_XSERVTransIsLocal(ListenTransConns[i])) {
+ DefineSelf(fd);
+ }
+ }
+ }
}
- if (!XFD_ANYSET (&WellKnownConnections))
- FatalError ("Cannot establish any listening sockets - Make sure an X server isn't already running");
+ if (!XFD_ANYSET(&WellKnownConnections))
+ FatalError
+ ("Cannot establish any listening sockets - Make sure an X server isn't already running");
#if !defined(WIN32)
- OsSignal (SIGPIPE, SIG_IGN);
- OsSignal (SIGHUP, AutoResetServer);
+ OsSignal(SIGPIPE, SIG_IGN);
+ OsSignal(SIGHUP, AutoResetServer);
#endif
- OsSignal (SIGINT, GiveUp);
- OsSignal (SIGTERM, GiveUp);
- XFD_COPYSET (&WellKnownConnections, &AllSockets);
+ OsSignal(SIGINT, GiveUp);
+ OsSignal(SIGTERM, GiveUp);
+ XFD_COPYSET(&WellKnownConnections, &AllSockets);
ResetHosts(display);
InitParentProcess();
#ifdef XDMCP
- XdmcpInit ();
+ XdmcpInit();
#endif
}
void
-ResetWellKnownSockets (void)
+ResetWellKnownSockets(void)
{
int i;
ResetOsBuffers();
- for (i = 0; i < ListenTransCount; i++)
- {
- int status = _XSERVTransResetListener (ListenTransConns[i]);
-
- if (status != TRANS_RESET_NOOP)
- {
- if (status == TRANS_RESET_FAILURE)
- {
- /*
- * ListenTransConns[i] freed by xtrans.
- * Remove it from out list.
- */
-
- FD_CLR (ListenTransFds[i], &WellKnownConnections);
- ListenTransFds[i] = ListenTransFds[ListenTransCount - 1];
- ListenTransConns[i] = ListenTransConns[ListenTransCount - 1];
- ListenTransCount -= 1;
- i -= 1;
- }
- else if (status == TRANS_RESET_NEW_FD)
- {
- /*
- * A new file descriptor was allocated (the old one was closed)
- */
-
- int newfd = _XSERVTransGetConnectionNumber (ListenTransConns[i]);
-
- FD_CLR (ListenTransFds[i], &WellKnownConnections);
- ListenTransFds[i] = newfd;
- FD_SET(newfd, &WellKnownConnections);
- }
- }
+ for (i = 0; i < ListenTransCount; i++) {
+ int status = _XSERVTransResetListener(ListenTransConns[i]);
+
+ if (status != TRANS_RESET_NOOP) {
+ if (status == TRANS_RESET_FAILURE) {
+ /*
+ * ListenTransConns[i] freed by xtrans.
+ * Remove it from out list.
+ */
+
+ FD_CLR(ListenTransFds[i], &WellKnownConnections);
+ ListenTransFds[i] = ListenTransFds[ListenTransCount - 1];
+ ListenTransConns[i] = ListenTransConns[ListenTransCount - 1];
+ ListenTransCount -= 1;
+ i -= 1;
+ }
+ else if (status == TRANS_RESET_NEW_FD) {
+ /*
+ * A new file descriptor was allocated (the old one was closed)
+ */
+
+ int newfd = _XSERVTransGetConnectionNumber(ListenTransConns[i]);
+
+ FD_CLR(ListenTransFds[i], &WellKnownConnections);
+ ListenTransFds[i] = newfd;
+ FD_SET(newfd, &WellKnownConnections);
+ }
+ }
}
- ResetAuthorization ();
+ ResetAuthorization();
ResetHosts(display);
/*
* restart XDMCP
*/
#ifdef XDMCP
- XdmcpReset ();
+ XdmcpReset();
#endif
}
@@ -490,17 +483,18 @@ CloseWellKnownConnections(void)
int i;
for (i = 0; i < ListenTransCount; i++)
- _XSERVTransClose (ListenTransConns[i]);
+ _XSERVTransClose(ListenTransConns[i]);
}
static void
-AuthAudit (ClientPtr client, Bool letin,
- struct sockaddr *saddr, int len,
- unsigned int proto_n, char *auth_proto, int auth_id)
+AuthAudit(ClientPtr client, Bool letin,
+ struct sockaddr *saddr, int len,
+ unsigned int proto_n, char *auth_proto, int auth_id)
{
char addr[128];
char client_uid_string[64];
LocalClientCredRec *lcc;
+
#ifdef XSERVER_DTRACE
pid_t client_pid = -1;
zoneid_t client_zid = -1;
@@ -509,93 +503,93 @@ AuthAudit (ClientPtr client, Bool letin,
if (!len)
strlcpy(addr, "local host", sizeof(addr));
else
- switch (saddr->sa_family)
- {
- case AF_UNSPEC:
+ switch (saddr->sa_family) {
+ case AF_UNSPEC:
#if defined(UNIXCONN) || defined(LOCALCONN)
- case AF_UNIX:
+ case AF_UNIX:
#endif
- strlcpy(addr, "local host", sizeof(addr));
- break;
+ strlcpy(addr, "local host", sizeof(addr));
+ break;
#if defined(TCPCONN) || defined(STREAMSCONN)
- case AF_INET:
- snprintf(addr, sizeof(addr), "IP %s",
- inet_ntoa(((struct sockaddr_in *) saddr)->sin_addr));
- break;
+ case AF_INET:
+ snprintf(addr, sizeof(addr), "IP %s",
+ inet_ntoa(((struct sockaddr_in *) saddr)->sin_addr));
+ break;
#if defined(IPv6) && defined(AF_INET6)
- case AF_INET6: {
- char ipaddr[INET6_ADDRSTRLEN];
- inet_ntop(AF_INET6, &((struct sockaddr_in6 *) saddr)->sin6_addr,
- ipaddr, sizeof(ipaddr));
- snprintf(addr, sizeof(addr), "IP %s", ipaddr);
- }
- break;
+ case AF_INET6:{
+ char ipaddr[INET6_ADDRSTRLEN];
+
+ inet_ntop(AF_INET6, &((struct sockaddr_in6 *) saddr)->sin6_addr,
+ ipaddr, sizeof(ipaddr));
+ snprintf(addr, sizeof(addr), "IP %s", ipaddr);
+ }
+ break;
#endif
#endif
- default:
- strlcpy(addr, "unknown address", sizeof(addr));
- }
+ default:
+ strlcpy(addr, "unknown address", sizeof(addr));
+ }
if (GetLocalClientCreds(client, &lcc) != -1) {
- int slen; /* length written to client_uid_string */
-
- strcpy(client_uid_string, " ( ");
- slen = 3;
-
- if (lcc->fieldsSet & LCC_UID_SET) {
- snprintf(client_uid_string + slen,
- sizeof(client_uid_string) - slen,
- "uid=%ld ", (long) lcc->euid);
- slen = strlen(client_uid_string);
- }
-
- if (lcc->fieldsSet & LCC_GID_SET) {
- snprintf(client_uid_string + slen,
- sizeof(client_uid_string) - slen,
- "gid=%ld ", (long) lcc->egid);
- slen = strlen(client_uid_string);
- }
-
- if (lcc->fieldsSet & LCC_PID_SET) {
-#ifdef XSERVER_DTRACE
- client_pid = lcc->pid;
+ int slen; /* length written to client_uid_string */
+
+ strcpy(client_uid_string, " ( ");
+ slen = 3;
+
+ if (lcc->fieldsSet & LCC_UID_SET) {
+ snprintf(client_uid_string + slen,
+ sizeof(client_uid_string) - slen,
+ "uid=%ld ", (long) lcc->euid);
+ slen = strlen(client_uid_string);
+ }
+
+ if (lcc->fieldsSet & LCC_GID_SET) {
+ snprintf(client_uid_string + slen,
+ sizeof(client_uid_string) - slen,
+ "gid=%ld ", (long) lcc->egid);
+ slen = strlen(client_uid_string);
+ }
+
+ if (lcc->fieldsSet & LCC_PID_SET) {
+#ifdef XSERVER_DTRACE
+ client_pid = lcc->pid;
#endif
- snprintf(client_uid_string + slen,
- sizeof(client_uid_string) - slen,
- "pid=%ld ", (long) lcc->pid);
- slen = strlen(client_uid_string);
- }
-
- if (lcc->fieldsSet & LCC_ZID_SET) {
+ snprintf(client_uid_string + slen,
+ sizeof(client_uid_string) - slen,
+ "pid=%ld ", (long) lcc->pid);
+ slen = strlen(client_uid_string);
+ }
+
+ if (lcc->fieldsSet & LCC_ZID_SET) {
#ifdef XSERVER_DTRACE
- client_zid = lcc->zoneid;
-#endif
- snprintf(client_uid_string + slen,
- sizeof(client_uid_string) - slen,
- "zoneid=%ld ", (long) lcc->zoneid);
- slen = strlen(client_uid_string);
- }
-
- snprintf(client_uid_string + slen, sizeof(client_uid_string) - slen,
- ")");
- FreeLocalClientCreds(lcc);
+ client_zid = lcc->zoneid;
+#endif
+ snprintf(client_uid_string + slen,
+ sizeof(client_uid_string) - slen,
+ "zoneid=%ld ", (long) lcc->zoneid);
+ slen = strlen(client_uid_string);
+ }
+
+ snprintf(client_uid_string + slen, sizeof(client_uid_string) - slen,
+ ")");
+ FreeLocalClientCreds(lcc);
}
else {
- client_uid_string[0] = '\0';
+ client_uid_string[0] = '\0';
}
-
+
#ifdef XSERVER_DTRACE
XSERVER_CLIENT_AUTH(client->index, addr, client_pid, client_zid);
#endif
if (auditTrailLevel > 1) {
- if (proto_n)
- AuditF("client %d %s from %s%s\n Auth name: %.*s ID: %d\n",
- client->index, letin ? "connected" : "rejected", addr,
- client_uid_string, (int)proto_n, auth_proto, auth_id);
- else
- AuditF("client %d %s from %s%s\n",
- client->index, letin ? "connected" : "rejected", addr,
- client_uid_string);
+ if (proto_n)
+ AuditF("client %d %s from %s%s\n Auth name: %.*s ID: %d\n",
+ client->index, letin ? "connected" : "rejected", addr,
+ client_uid_string, (int) proto_n, auth_proto, auth_id);
+ else
+ AuditF("client %d %s from %s%s\n",
+ client->index, letin ? "connected" : "rejected", addr,
+ client_uid_string);
}
}
@@ -604,12 +598,11 @@ XID
AuthorizationIDOfClient(ClientPtr client)
{
if (client->osPrivate)
- return ((OsCommPtr)client->osPrivate)->auth_id;
+ return ((OsCommPtr) client->osPrivate)->auth_id;
else
- return None;
+ return None;
}
-
/*****************************************************************
* ClientAuthorized
*
@@ -630,58 +623,58 @@ AuthorizationIDOfClient(ClientPtr client)
*****************************************************************/
const char *
-ClientAuthorized(ClientPtr client,
- unsigned int proto_n, char *auth_proto,
- unsigned int string_n, char *auth_string)
+ClientAuthorized(ClientPtr client,
+ unsigned int proto_n, char *auth_proto,
+ unsigned int string_n, char *auth_string)
{
- OsCommPtr priv;
- Xtransaddr *from = NULL;
- int family;
- int fromlen;
- XID auth_id;
- const char *reason = NULL;
- XtransConnInfo trans_conn;
-
- priv = (OsCommPtr)client->osPrivate;
+ OsCommPtr priv;
+ Xtransaddr *from = NULL;
+ int family;
+ int fromlen;
+ XID auth_id;
+ const char *reason = NULL;
+ XtransConnInfo trans_conn;
+
+ priv = (OsCommPtr) client->osPrivate;
trans_conn = priv->trans_conn;
/* Allow any client to connect without authorization on a launchd socket,
because it is securely created -- this prevents a race condition on launch */
- if(trans_conn->flags & TRANS_NOXAUTH) {
+ if (trans_conn->flags & TRANS_NOXAUTH) {
auth_id = (XID) 0L;
- } else {
- auth_id = CheckAuthorization (proto_n, auth_proto, string_n, auth_string, client, &reason);
+ }
+ else {
+ auth_id =
+ CheckAuthorization(proto_n, auth_proto, string_n, auth_string,
+ client, &reason);
}
- if (auth_id == (XID) ~0L)
- {
- if (_XSERVTransGetPeerAddr(trans_conn, &family, &fromlen, &from) != -1)
- {
- if (InvalidHost ((struct sockaddr *) from, fromlen, client))
- AuthAudit(client, FALSE, (struct sockaddr *) from,
- fromlen, proto_n, auth_proto, auth_id);
- else
- {
- auth_id = (XID) 0;
+ if (auth_id == (XID) ~0L) {
+ if (_XSERVTransGetPeerAddr(trans_conn, &family, &fromlen, &from) != -1) {
+ if (InvalidHost((struct sockaddr *) from, fromlen, client))
+ AuthAudit(client, FALSE, (struct sockaddr *) from,
+ fromlen, proto_n, auth_proto, auth_id);
+ else {
+ auth_id = (XID) 0;
#ifdef XSERVER_DTRACE
- if ((auditTrailLevel > 1) || XSERVER_CLIENT_AUTH_ENABLED())
+ if ((auditTrailLevel > 1) || XSERVER_CLIENT_AUTH_ENABLED())
#else
- if (auditTrailLevel > 1)
+ if (auditTrailLevel > 1)
#endif
- AuthAudit(client, TRUE,
- (struct sockaddr *) from, fromlen,
- proto_n, auth_proto, auth_id);
- }
-
- free(from);
- }
-
- if (auth_id == (XID) ~0L) {
- if (reason)
- return reason;
- else
- return "Client is not authorized to connect to Server";
- }
+ AuthAudit(client, TRUE,
+ (struct sockaddr *) from, fromlen,
+ proto_n, auth_proto, auth_id);
+ }
+
+ free(from);
+ }
+
+ if (auth_id == (XID) ~0L) {
+ if (reason)
+ return reason;
+ else
+ return "Client is not authorized to connect to Server";
+ }
}
#ifdef XSERVER_DTRACE
else if ((auditTrailLevel > 1) || XSERVER_CLIENT_AUTH_ENABLED())
@@ -689,14 +682,12 @@ ClientAuthorized(ClientPtr client,
else if (auditTrailLevel > 1)
#endif
{
- if (_XSERVTransGetPeerAddr (trans_conn,
- &family, &fromlen, &from) != -1)
- {
- AuthAudit(client, TRUE, (struct sockaddr *) from, fromlen,
- proto_n, auth_proto, auth_id);
-
- free(from);
- }
+ if (_XSERVTransGetPeerAddr(trans_conn, &family, &fromlen, &from) != -1) {
+ AuthAudit(client, TRUE, (struct sockaddr *) from, fromlen,
+ proto_n, auth_proto, auth_id);
+
+ free(from);
+ }
}
priv->auth_id = auth_id;
priv->conn_time = 0;
@@ -704,7 +695,7 @@ ClientAuthorized(ClientPtr client,
#ifdef XDMCP
/* indicate to Xdmcp protocol that we've opened new client */
XdmcpOpenDisplay(priv->fd);
-#endif /* XDMCP */
+#endif /* XDMCP */
XaceHook(XACE_AUTH_AVAIL, client, auth_id);
@@ -714,36 +705,35 @@ ClientAuthorized(ClientPtr client,
* true purpose of the selfhosts list is to see who may change the
* access control list.
*/
- return((char *)NULL);
+ return ((char *) NULL);
}
static ClientPtr
-AllocNewConnection (XtransConnInfo trans_conn, int fd, CARD32 conn_time)
+AllocNewConnection(XtransConnInfo trans_conn, int fd, CARD32 conn_time)
{
- OsCommPtr oc;
- ClientPtr client;
-
+ OsCommPtr oc;
+ ClientPtr client;
+
if (
#ifndef WIN32
- fd >= lastfdesc
+ fd >= lastfdesc
#else
- XFD_SETCOUNT(&AllClients) >= MaxClients
+ XFD_SETCOUNT(&AllClients) >= MaxClients
#endif
- )
- return NullClient;
+ )
+ return NullClient;
oc = malloc(sizeof(OsCommRec));
if (!oc)
- return NullClient;
+ return NullClient;
oc->trans_conn = trans_conn;
oc->fd = fd;
- oc->input = (ConnectionInputPtr)NULL;
- oc->output = (ConnectionOutputPtr)NULL;
+ oc->input = (ConnectionInputPtr) NULL;
+ oc->output = (ConnectionOutputPtr) NULL;
oc->auth_id = None;
oc->conn_time = conn_time;
- if (!(client = NextAvailableClient((pointer)oc)))
- {
- free(oc);
- return NullClient;
+ if (!(client = NextAvailableClient((pointer) oc))) {
+ free(oc);
+ return NullClient;
}
oc->local_client = ComputeLocalClient(client);
#if !defined(WIN32)
@@ -751,24 +741,22 @@ AllocNewConnection (XtransConnInfo trans_conn, int fd, CARD32 conn_time)
#else
SetConnectionTranslation(fd, client->index);
#endif
- if (GrabInProgress)
- {
+ if (GrabInProgress) {
FD_SET(fd, &SavedAllClients);
FD_SET(fd, &SavedAllSockets);
}
- else
- {
+ else {
FD_SET(fd, &AllClients);
FD_SET(fd, &AllSockets);
}
#ifdef DEBUG
ErrorF("AllocNewConnection: client index = %d, socket fd = %d\n",
- client->index, fd);
+ client->index, fd);
#endif
#ifdef XSERVER_DTRACE
XSERVER_CLIENT_CONNECT(client->index, fd);
-#endif
+#endif
return client;
}
@@ -780,90 +768,85 @@ AllocNewConnection (XtransConnInfo trans_conn, int fd, CARD32 conn_time)
* and AllSockets.
*****************/
-/*ARGSUSED*/
-Bool
+ /*ARGSUSED*/ Bool
EstablishNewConnections(ClientPtr clientUnused, pointer closure)
{
- fd_set readyconnections; /* set of listeners that are ready */
- int curconn; /* fd of listener that's ready */
- register int newconn; /* fd of new client */
+ fd_set readyconnections; /* set of listeners that are ready */
+ int curconn; /* fd of listener that's ready */
+ register int newconn; /* fd of new client */
CARD32 connect_time;
register int i;
register ClientPtr client;
register OsCommPtr oc;
fd_set tmask;
- XFD_ANDSET (&tmask, (fd_set*)closure, &WellKnownConnections);
+ XFD_ANDSET(&tmask, (fd_set *) closure, &WellKnownConnections);
XFD_COPYSET(&tmask, &readyconnections);
if (!XFD_ANYSET(&readyconnections))
- return TRUE;
+ return TRUE;
connect_time = GetTimeInMillis();
/* kill off stragglers */
- for (i=1; i<currentMaxClients; i++)
- {
- if ((client = clients[i]))
- {
- oc = (OsCommPtr)(client->osPrivate);
- if ((oc && (oc->conn_time != 0) &&
- (connect_time - oc->conn_time) >= TimeOutValue) ||
- (client->noClientException != Success && !client->clientGone))
- CloseDownClient(client);
- }
+ for (i = 1; i < currentMaxClients; i++) {
+ if ((client = clients[i])) {
+ oc = (OsCommPtr) (client->osPrivate);
+ if ((oc && (oc->conn_time != 0) &&
+ (connect_time - oc->conn_time) >= TimeOutValue) ||
+ (client->noClientException != Success && !client->clientGone))
+ CloseDownClient(client);
+ }
}
#ifndef WIN32
- for (i = 0; i < howmany(XFD_SETSIZE, NFDBITS); i++)
- {
- while (readyconnections.fds_bits[i])
+ for (i = 0; i < howmany(XFD_SETSIZE, NFDBITS); i++) {
+ while (readyconnections.fds_bits[i])
#else
- for (i = 0; i < XFD_SETCOUNT(&readyconnections); i++)
+ for (i = 0; i < XFD_SETCOUNT(&readyconnections); i++)
#endif
- {
- XtransConnInfo trans_conn, new_trans_conn;
- int status;
+ {
+ XtransConnInfo trans_conn, new_trans_conn;
+ int status;
#ifndef WIN32
- curconn = mffs (readyconnections.fds_bits[i]) - 1;
- readyconnections.fds_bits[i] &= ~((fd_mask)1 << curconn);
- curconn += (i * (sizeof(fd_mask)*8));
+ curconn = mffs(readyconnections.fds_bits[i]) - 1;
+ readyconnections.fds_bits[i] &= ~((fd_mask) 1 << curconn);
+ curconn += (i * (sizeof(fd_mask) * 8));
#else
- curconn = XFD_FD(&readyconnections, i);
+ curconn = XFD_FD(&readyconnections, i);
#endif
- if ((trans_conn = lookup_trans_conn (curconn)) == NULL)
- continue;
+ if ((trans_conn = lookup_trans_conn(curconn)) == NULL)
+ continue;
+
+ if ((new_trans_conn = _XSERVTransAccept(trans_conn, &status)) == NULL)
+ continue;
- if ((new_trans_conn = _XSERVTransAccept (trans_conn, &status)) == NULL)
- continue;
+ newconn = _XSERVTransGetConnectionNumber(new_trans_conn);
- newconn = _XSERVTransGetConnectionNumber (new_trans_conn);
+ if (newconn < lastfdesc) {
+ int clientid;
- if (newconn < lastfdesc)
- {
- int clientid;
#if !defined(WIN32)
- clientid = ConnectionTranslation[newconn];
+ clientid = ConnectionTranslation[newconn];
#else
- clientid = GetConnectionTranslation(newconn);
+ clientid = GetConnectionTranslation(newconn);
#endif
- if(clientid && (client = clients[clientid]))
- CloseDownClient(client);
- }
+ if (clientid && (client = clients[clientid]))
+ CloseDownClient(client);
+ }
- _XSERVTransSetOption(new_trans_conn, TRANS_NONBLOCKING, 1);
+ _XSERVTransSetOption(new_trans_conn, TRANS_NONBLOCKING, 1);
- if(trans_conn->flags & TRANS_NOXAUTH)
- new_trans_conn->flags = new_trans_conn->flags | TRANS_NOXAUTH;
+ if (trans_conn->flags & TRANS_NOXAUTH)
+ new_trans_conn->flags = new_trans_conn->flags | TRANS_NOXAUTH;
- if (!AllocNewConnection (new_trans_conn, newconn, connect_time))
- {
- ErrorConnMax(new_trans_conn);
- _XSERVTransClose(new_trans_conn);
- }
- }
-#ifndef WIN32
+ if (!AllocNewConnection(new_trans_conn, newconn, connect_time)) {
+ ErrorConnMax(new_trans_conn);
+ _XSERVTransClose(new_trans_conn);
+ }
}
+#ifndef WIN32
+}
#endif
- return TRUE;
+return TRUE;
}
#define NOROOM "Maximum number of clients reached"
@@ -873,12 +856,12 @@ EstablishNewConnections(ClientPtr clientUnused, pointer closure)
* Fail a connection due to lack of client or file descriptor space
************/
-#define BOTIMEOUT 200 /* in milliseconds */
+#define BOTIMEOUT 200 /* in milliseconds */
static void
ErrorConnMax(XtransConnInfo trans_conn)
{
- int fd = _XSERVTransGetConnectionNumber (trans_conn);
+ int fd = _XSERVTransGetConnectionNumber(trans_conn);
xConnSetupPrefix csp;
char pad[3];
struct iovec iov[3];
@@ -890,33 +873,31 @@ ErrorConnMax(XtransConnInfo trans_conn)
/* if these seems like a lot of trouble to go to, it probably is */
waittime.tv_sec = BOTIMEOUT / MILLI_PER_SECOND;
waittime.tv_usec = (BOTIMEOUT % MILLI_PER_SECOND) *
- (1000000 / MILLI_PER_SECOND);
+ (1000000 / MILLI_PER_SECOND);
FD_ZERO(&mask);
FD_SET(fd, &mask);
- (void)Select(fd + 1, &mask, NULL, NULL, &waittime);
+ (void) Select(fd + 1, &mask, NULL, NULL, &waittime);
/* try to read the byte-order of the connection */
- (void)_XSERVTransRead(trans_conn, &byteOrder, 1);
- if ((byteOrder == 'l') || (byteOrder == 'B'))
- {
- csp.success = xFalse;
- csp.lengthReason = sizeof(NOROOM) - 1;
- csp.length = (sizeof(NOROOM) + 2) >> 2;
- csp.majorVersion = X_PROTOCOL;
- csp.minorVersion = X_PROTOCOL_REVISION;
- if (((*(char *) &whichbyte) && (byteOrder == 'B')) ||
- (!(*(char *) &whichbyte) && (byteOrder == 'l')))
- {
- swaps(&csp.majorVersion);
- swaps(&csp.minorVersion);
- swaps(&csp.length);
- }
- iov[0].iov_len = sz_xConnSetupPrefix;
- iov[0].iov_base = (char *) &csp;
- iov[1].iov_len = csp.lengthReason;
- iov[1].iov_base = NOROOM;
- iov[2].iov_len = (4 - (csp.lengthReason & 3)) & 3;
- iov[2].iov_base = pad;
- (void)_XSERVTransWritev(trans_conn, iov, 3);
+ (void) _XSERVTransRead(trans_conn, &byteOrder, 1);
+ if ((byteOrder == 'l') || (byteOrder == 'B')) {
+ csp.success = xFalse;
+ csp.lengthReason = sizeof(NOROOM) - 1;
+ csp.length = (sizeof(NOROOM) + 2) >> 2;
+ csp.majorVersion = X_PROTOCOL;
+ csp.minorVersion = X_PROTOCOL_REVISION;
+ if (((*(char *) &whichbyte) && (byteOrder == 'B')) ||
+ (!(*(char *) &whichbyte) && (byteOrder == 'l'))) {
+ swaps(&csp.majorVersion);
+ swaps(&csp.minorVersion);
+ swaps(&csp.length);
+ }
+ iov[0].iov_len = sz_xConnSetupPrefix;
+ iov[0].iov_base = (char *) &csp;
+ iov[1].iov_len = csp.lengthReason;
+ iov[1].iov_base = NOROOM;
+ iov[2].iov_len = (4 - (csp.lengthReason & 3)) & 3;
+ iov[2].iov_base = pad;
+ (void) _XSERVTransWritev(trans_conn, iov, 3);
}
}
@@ -931,27 +912,26 @@ CloseDownFileDescriptor(OsCommPtr oc)
int connection = oc->fd;
if (oc->trans_conn) {
- _XSERVTransDisconnect(oc->trans_conn);
- _XSERVTransClose(oc->trans_conn);
+ _XSERVTransDisconnect(oc->trans_conn);
+ _XSERVTransClose(oc->trans_conn);
}
#ifndef WIN32
ConnectionTranslation[connection] = 0;
#else
SetConnectionTranslation(connection, 0);
-#endif
+#endif
FD_CLR(connection, &AllSockets);
FD_CLR(connection, &AllClients);
FD_CLR(connection, &ClientsWithInput);
FD_CLR(connection, &GrabImperviousClients);
- if (GrabInProgress)
- {
- FD_CLR(connection, &SavedAllSockets);
- FD_CLR(connection, &SavedAllClients);
- FD_CLR(connection, &SavedClientsWithInput);
+ if (GrabInProgress) {
+ FD_CLR(connection, &SavedAllSockets);
+ FD_CLR(connection, &SavedAllClients);
+ FD_CLR(connection, &SavedClientsWithInput);
}
FD_CLR(connection, &ClientsWriteBlocked);
if (!XFD_ANYSET(&ClientsWriteBlocked))
- AnyClientsWriteBlocked = FALSE;
+ AnyClientsWriteBlocked = FALSE;
FD_CLR(connection, &OutputPending);
}
@@ -968,13 +948,14 @@ void
CheckConnections(void)
{
#ifndef WIN32
- fd_mask mask;
+ fd_mask mask;
#endif
- fd_set tmask;
- int curclient, curoff;
- int i;
- struct timeval notime;
+ fd_set tmask;
+ int curclient, curoff;
+ int i;
+ struct timeval notime;
int r;
+
#ifdef WIN32
fd_set savedAllClients;
#endif
@@ -983,42 +964,38 @@ CheckConnections(void)
notime.tv_usec = 0;
#ifndef WIN32
- for (i=0; i<howmany(XFD_SETSIZE, NFDBITS); i++)
- {
- mask = AllClients.fds_bits[i];
- while (mask)
- {
- curoff = mffs (mask) - 1;
- curclient = curoff + (i * (sizeof(fd_mask)*8));
+ for (i = 0; i < howmany(XFD_SETSIZE, NFDBITS); i++) {
+ mask = AllClients.fds_bits[i];
+ while (mask) {
+ curoff = mffs(mask) - 1;
+ curclient = curoff + (i * (sizeof(fd_mask) * 8));
FD_ZERO(&tmask);
FD_SET(curclient, &tmask);
do {
- r = Select (curclient + 1, &tmask, NULL, NULL, &notime);
+ r = Select(curclient + 1, &tmask, NULL, NULL, &notime);
} while (r < 0 && (errno == EINTR || errno == EAGAIN));
if (r < 0)
if (ConnectionTranslation[curclient] > 0)
CloseDownClient(clients[ConnectionTranslation[curclient]]);
- mask &= ~((fd_mask)1 << curoff);
- }
- }
+ mask &= ~((fd_mask) 1 << curoff);
+ }
+ }
#else
XFD_COPYSET(&AllClients, &savedAllClients);
- for (i = 0; i < XFD_SETCOUNT(&savedAllClients); i++)
- {
- curclient = XFD_FD(&savedAllClients, i);
- FD_ZERO(&tmask);
- FD_SET(curclient, &tmask);
+ for (i = 0; i < XFD_SETCOUNT(&savedAllClients); i++) {
+ curclient = XFD_FD(&savedAllClients, i);
+ FD_ZERO(&tmask);
+ FD_SET(curclient, &tmask);
do {
- r = Select (curclient + 1, &tmask, NULL, NULL, &notime);
+ r = Select(curclient + 1, &tmask, NULL, NULL, &notime);
} while (r < 0 && (errno == EINTR || errno == EAGAIN));
- if (r < 0)
+ if (r < 0)
if (GetConnectionTranslation(curclient) > 0)
CloseDownClient(clients[GetConnectionTranslation(curclient)]);
- }
+ }
#endif
}
-
/*****************
* CloseDownConnection
* Delete client from AllClients and free resources
@@ -1027,22 +1004,22 @@ CheckConnections(void)
void
CloseDownConnection(ClientPtr client)
{
- OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ OsCommPtr oc = (OsCommPtr) client->osPrivate;
if (FlushCallback)
- CallCallbacks(&FlushCallback, NULL);
+ CallCallbacks(&FlushCallback, NULL);
if (oc->output && oc->output->count)
- FlushClient(client, oc, (char *)NULL, 0);
+ FlushClient(client, oc, (char *) NULL, 0);
#ifdef XDMCP
XdmcpCloseDisplay(oc->fd);
#endif
CloseDownFileDescriptor(oc);
FreeOsBuffers(oc);
free(client->osPrivate);
- client->osPrivate = (pointer)NULL;
+ client->osPrivate = (pointer) NULL;
if (auditTrailLevel > 1)
- AuditF("client %d disconnected\n", client->index);
+ AuditF("client %d disconnected\n", client->index);
}
void
@@ -1050,7 +1027,7 @@ AddGeneralSocket(int fd)
{
FD_SET(fd, &AllSockets);
if (GrabInProgress)
- FD_SET(fd, &SavedAllSockets);
+ FD_SET(fd, &SavedAllSockets);
}
void
@@ -1065,7 +1042,7 @@ RemoveGeneralSocket(int fd)
{
FD_CLR(fd, &AllSockets);
if (GrabInProgress)
- FD_CLR(fd, &SavedAllSockets);
+ FD_CLR(fd, &SavedAllSockets);
}
void
@@ -1088,31 +1065,29 @@ RemoveEnabledDevice(int fd)
int
OnlyListenToOneClient(ClientPtr client)
{
- OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ OsCommPtr oc = (OsCommPtr) client->osPrivate;
int rc, connection = oc->fd;
rc = XaceHook(XACE_SERVER_ACCESS, client, DixGrabAccess);
if (rc != Success)
- return rc;
-
- if (! GrabInProgress)
- {
- XFD_COPYSET(&ClientsWithInput, &SavedClientsWithInput);
- XFD_ANDSET(&ClientsWithInput,
- &ClientsWithInput, &GrabImperviousClients);
- if (FD_ISSET(connection, &SavedClientsWithInput))
- {
- FD_CLR(connection, &SavedClientsWithInput);
- FD_SET(connection, &ClientsWithInput);
- }
- XFD_UNSET(&SavedClientsWithInput, &GrabImperviousClients);
- XFD_COPYSET(&AllSockets, &SavedAllSockets);
- XFD_COPYSET(&AllClients, &SavedAllClients);
- XFD_UNSET(&AllSockets, &AllClients);
- XFD_ANDSET(&AllClients, &AllClients, &GrabImperviousClients);
- FD_SET(connection, &AllClients);
- XFD_ORSET(&AllSockets, &AllSockets, &AllClients);
- GrabInProgress = client->index;
+ return rc;
+
+ if (!GrabInProgress) {
+ XFD_COPYSET(&ClientsWithInput, &SavedClientsWithInput);
+ XFD_ANDSET(&ClientsWithInput,
+ &ClientsWithInput, &GrabImperviousClients);
+ if (FD_ISSET(connection, &SavedClientsWithInput)) {
+ FD_CLR(connection, &SavedClientsWithInput);
+ FD_SET(connection, &ClientsWithInput);
+ }
+ XFD_UNSET(&SavedClientsWithInput, &GrabImperviousClients);
+ XFD_COPYSET(&AllSockets, &SavedAllSockets);
+ XFD_COPYSET(&AllClients, &SavedAllClients);
+ XFD_UNSET(&AllSockets, &AllClients);
+ XFD_ANDSET(&AllClients, &AllClients, &GrabImperviousClients);
+ FD_SET(connection, &AllClients);
+ XFD_ORSET(&AllSockets, &AllSockets, &AllClients);
+ GrabInProgress = client->index;
}
return rc;
}
@@ -1125,13 +1100,12 @@ OnlyListenToOneClient(ClientPtr client)
void
ListenToAllClients(void)
{
- if (GrabInProgress)
- {
- XFD_ORSET(&AllSockets, &AllSockets, &SavedAllSockets);
- XFD_ORSET(&AllClients, &AllClients, &SavedAllClients);
- XFD_ORSET(&ClientsWithInput, &ClientsWithInput, &SavedClientsWithInput);
- GrabInProgress = 0;
- }
+ if (GrabInProgress) {
+ XFD_ORSET(&AllSockets, &AllSockets, &SavedAllSockets);
+ XFD_ORSET(&AllClients, &AllClients, &SavedAllClients);
+ XFD_ORSET(&ClientsWithInput, &ClientsWithInput, &SavedClientsWithInput);
+ GrabInProgress = 0;
+ }
}
/****************
@@ -1141,36 +1115,34 @@ ListenToAllClients(void)
****************/
void
-IgnoreClient (ClientPtr client)
+IgnoreClient(ClientPtr client)
{
- OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ OsCommPtr oc = (OsCommPtr) client->osPrivate;
int connection = oc->fd;
client->ignoreCount++;
if (client->ignoreCount > 1)
- return;
+ return;
isItTimeToYield = TRUE;
- if (!GrabInProgress || FD_ISSET(connection, &AllClients))
- {
- if (FD_ISSET (connection, &ClientsWithInput))
- FD_SET(connection, &IgnoredClientsWithInput);
- else
- FD_CLR(connection, &IgnoredClientsWithInput);
- FD_CLR(connection, &ClientsWithInput);
- FD_CLR(connection, &AllSockets);
- FD_CLR(connection, &AllClients);
- FD_CLR(connection, &LastSelectMask);
+ if (!GrabInProgress || FD_ISSET(connection, &AllClients)) {
+ if (FD_ISSET(connection, &ClientsWithInput))
+ FD_SET(connection, &IgnoredClientsWithInput);
+ else
+ FD_CLR(connection, &IgnoredClientsWithInput);
+ FD_CLR(connection, &ClientsWithInput);
+ FD_CLR(connection, &AllSockets);
+ FD_CLR(connection, &AllClients);
+ FD_CLR(connection, &LastSelectMask);
}
- else
- {
- if (FD_ISSET (connection, &SavedClientsWithInput))
- FD_SET(connection, &IgnoredClientsWithInput);
- else
- FD_CLR(connection, &IgnoredClientsWithInput);
- FD_CLR(connection, &SavedClientsWithInput);
- FD_CLR(connection, &SavedAllSockets);
- FD_CLR(connection, &SavedAllClients);
+ else {
+ if (FD_ISSET(connection, &SavedClientsWithInput))
+ FD_SET(connection, &IgnoredClientsWithInput);
+ else
+ FD_CLR(connection, &IgnoredClientsWithInput);
+ FD_CLR(connection, &SavedClientsWithInput);
+ FD_CLR(connection, &SavedAllSockets);
+ FD_CLR(connection, &SavedAllClients);
}
}
@@ -1180,30 +1152,28 @@ IgnoreClient (ClientPtr client)
****************/
void
-AttendClient (ClientPtr client)
+AttendClient(ClientPtr client)
{
- OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ OsCommPtr oc = (OsCommPtr) client->osPrivate;
int connection = oc->fd;
client->ignoreCount--;
if (client->ignoreCount)
- return;
+ return;
if (!GrabInProgress || GrabInProgress == client->index ||
- FD_ISSET(connection, &GrabImperviousClients))
- {
- FD_SET(connection, &AllClients);
- FD_SET(connection, &AllSockets);
- FD_SET(connection, &LastSelectMask);
- if (FD_ISSET (connection, &IgnoredClientsWithInput))
- FD_SET(connection, &ClientsWithInput);
+ FD_ISSET(connection, &GrabImperviousClients)) {
+ FD_SET(connection, &AllClients);
+ FD_SET(connection, &AllSockets);
+ FD_SET(connection, &LastSelectMask);
+ if (FD_ISSET(connection, &IgnoredClientsWithInput))
+ FD_SET(connection, &ClientsWithInput);
}
- else
- {
- FD_SET(connection, &SavedAllClients);
- FD_SET(connection, &SavedAllSockets);
- if (FD_ISSET(connection, &IgnoredClientsWithInput))
- FD_SET(connection, &SavedClientsWithInput);
+ else {
+ FD_SET(connection, &SavedAllClients);
+ FD_SET(connection, &SavedAllSockets);
+ if (FD_ISSET(connection, &IgnoredClientsWithInput))
+ FD_SET(connection, &SavedClientsWithInput);
}
}
@@ -1212,17 +1182,17 @@ AttendClient (ClientPtr client)
void
MakeClientGrabImpervious(ClientPtr client)
{
- OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ OsCommPtr oc = (OsCommPtr) client->osPrivate;
int connection = oc->fd;
FD_SET(connection, &GrabImperviousClients);
- if (ServerGrabCallback)
- {
- ServerGrabInfoRec grabinfo;
- grabinfo.client = client;
- grabinfo.grabstate = CLIENT_IMPERVIOUS;
- CallCallbacks(&ServerGrabCallback, &grabinfo);
+ if (ServerGrabCallback) {
+ ServerGrabInfoRec grabinfo;
+
+ grabinfo.client = client;
+ grabinfo.grabstate = CLIENT_IMPERVIOUS;
+ CallCallbacks(&ServerGrabCallback, &grabinfo);
}
}
@@ -1231,42 +1201,43 @@ MakeClientGrabImpervious(ClientPtr client)
void
MakeClientGrabPervious(ClientPtr client)
{
- OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ OsCommPtr oc = (OsCommPtr) client->osPrivate;
int connection = oc->fd;
FD_CLR(connection, &GrabImperviousClients);
- if (GrabInProgress && (GrabInProgress != client->index))
- {
- if (FD_ISSET(connection, &ClientsWithInput))
- {
- FD_SET(connection, &SavedClientsWithInput);
- FD_CLR(connection, &ClientsWithInput);
- }
- FD_CLR(connection, &AllSockets);
- FD_CLR(connection, &AllClients);
- isItTimeToYield = TRUE;
+ if (GrabInProgress && (GrabInProgress != client->index)) {
+ if (FD_ISSET(connection, &ClientsWithInput)) {
+ FD_SET(connection, &SavedClientsWithInput);
+ FD_CLR(connection, &ClientsWithInput);
+ }
+ FD_CLR(connection, &AllSockets);
+ FD_CLR(connection, &AllClients);
+ isItTimeToYield = TRUE;
}
- if (ServerGrabCallback)
- {
- ServerGrabInfoRec grabinfo;
- grabinfo.client = client;
- grabinfo.grabstate = CLIENT_PERVIOUS;
- CallCallbacks(&ServerGrabCallback, &grabinfo);
+ if (ServerGrabCallback) {
+ ServerGrabInfoRec grabinfo;
+
+ grabinfo.client = client;
+ grabinfo.grabstate = CLIENT_PERVIOUS;
+ CallCallbacks(&ServerGrabCallback, &grabinfo);
}
}
#ifdef XQUARTZ
/* Add a fd (from launchd) to our listeners */
-void ListenOnOpenFD(int fd, int noxauth) {
+void
+ListenOnOpenFD(int fd, int noxauth)
+{
char port[256];
XtransConnInfo ciptr;
const char *display_env = getenv("DISPLAY");
- if(display_env && (strncmp(display_env, "/tmp/launch", 11) == 0)) {
+ if (display_env && (strncmp(display_env, "/tmp/launch", 11) == 0)) {
/* Make the path the launchd socket if our DISPLAY is set right */
strcpy(port, display_env);
- } else {
+ }
+ else {
/* Just some default so things don't break and die. */
snprintf(port, sizeof(port), ":%d", atoi(display));
}
@@ -1275,25 +1246,29 @@ void ListenOnOpenFD(int fd, int noxauth) {
* TRANS_SOCKET_LOCAL_INDEX = 5 from Xtrans.c
*/
ciptr = _XSERVTransReopenCOTSServer(5, fd, port);
- if(ciptr == NULL) {
+ if (ciptr == NULL) {
ErrorF("Got NULL while trying to Reopen launchd port.\n");
return;
}
-
- if(noxauth)
+
+ if (noxauth)
ciptr->flags = ciptr->flags | TRANS_NOXAUTH;
/* Allocate space to store it */
- ListenTransFds = (int *) realloc(ListenTransFds, (ListenTransCount + 1) * sizeof (int));
- ListenTransConns = (XtransConnInfo *) realloc(ListenTransConns, (ListenTransCount + 1) * sizeof (XtransConnInfo));
-
+ ListenTransFds =
+ (int *) realloc(ListenTransFds, (ListenTransCount + 1) * sizeof(int));
+ ListenTransConns =
+ (XtransConnInfo *) realloc(ListenTransConns,
+ (ListenTransCount +
+ 1) * sizeof(XtransConnInfo));
+
/* Store it */
ListenTransConns[ListenTransCount] = ciptr;
ListenTransFds[ListenTransCount] = fd;
FD_SET(fd, &WellKnownConnections);
FD_SET(fd, &AllSockets);
-
+
/* Increment the count */
ListenTransCount++;
diff --git a/xorg-server/os/io.c b/xorg-server/os/io.c
index f5013d774..b67a5f324 100644
--- a/xorg-server/os/io.c
+++ b/xorg-server/os/io.c
@@ -22,7 +22,6 @@ Except as contained in this notice, the name of The Open Group shall 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 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
@@ -43,7 +42,6 @@ WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
-
******************************************************************/
/*****************************************************************
* i/o functions
@@ -81,8 +79,8 @@ SOFTWARE.
#include "dixstruct.h"
#include "misc.h"
-CallbackListPtr ReplyCallback;
-CallbackListPtr FlushCallback;
+CallbackListPtr ReplyCallback;
+CallbackListPtr FlushCallback;
static ConnectionInputPtr AllocateInputBuffer(void);
static ConnectionOutputPtr AllocateOutputBuffer(void);
@@ -92,15 +90,15 @@ static ConnectionOutputPtr AllocateOutputBuffer(void);
*/
#ifndef WIN32
#define ETEST(err) (err == EAGAIN || err == EWOULDBLOCK)
-#else /* WIN32 The socket errorcodes differ from the normal errors*/
+#else /* WIN32 The socket errorcodes differ from the normal errors */
#define ETEST(err) (err == EAGAIN || err == WSAEWOULDBLOCK)
#endif
static Bool CriticalOutputPending;
static int timesThisConnection = 0;
-static ConnectionInputPtr FreeInputs = (ConnectionInputPtr)NULL;
-static ConnectionOutputPtr FreeOutputs = (ConnectionOutputPtr)NULL;
-static OsCommPtr AvailableInput = (OsCommPtr)NULL;
+static ConnectionInputPtr FreeInputs = (ConnectionInputPtr) NULL;
+static ConnectionOutputPtr FreeOutputs = (ConnectionOutputPtr) NULL;
+static OsCommPtr AvailableInput = (OsCommPtr) NULL;
#define get_req_len(req,cli) ((cli)->swapped ? \
lswaps((req)->length) : (req)->length)
@@ -145,7 +143,6 @@ static OsCommPtr AvailableInput = (OsCommPtr)NULL;
* counts CARD32's.
*/
-
/*****************************************************************
* ReadRequestFromClient
* Returns one request in client->requestBuffer. The request
@@ -195,7 +192,7 @@ YieldControlDeath(void)
int
ReadRequestFromClient(ClientPtr client)
{
- OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ OsCommPtr oc = (OsCommPtr) client->osPrivate;
ConnectionInputPtr oci = oc->input;
int fd = oc->fd;
unsigned int gotnow, needed;
@@ -210,40 +207,34 @@ ReadRequestFromClient(ClientPtr client)
* times). This was done to save memory.
*/
- if (AvailableInput)
- {
- if (AvailableInput != oc)
- {
- register ConnectionInputPtr aci = AvailableInput->input;
- if (aci->size > BUFWATERMARK)
- {
- free(aci->buffer);
- free(aci);
- }
- else
- {
- aci->next = FreeInputs;
- FreeInputs = aci;
- }
- AvailableInput->input = (ConnectionInputPtr)NULL;
- }
- AvailableInput = (OsCommPtr)NULL;
+ if (AvailableInput) {
+ if (AvailableInput != oc) {
+ register ConnectionInputPtr aci = AvailableInput->input;
+
+ if (aci->size > BUFWATERMARK) {
+ free(aci->buffer);
+ free(aci);
+ }
+ else {
+ aci->next = FreeInputs;
+ FreeInputs = aci;
+ }
+ AvailableInput->input = (ConnectionInputPtr) NULL;
+ }
+ AvailableInput = (OsCommPtr) NULL;
}
/* make sure we have an input buffer */
- if (!oci)
- {
- if ((oci = FreeInputs))
- {
- FreeInputs = oci->next;
- }
- else if (!(oci = AllocateInputBuffer()))
- {
- YieldControlDeath();
- return -1;
- }
- oc->input = oci;
+ if (!oci) {
+ if ((oci = FreeInputs)) {
+ FreeInputs = oci->next;
+ }
+ else if (!(oci = AllocateInputBuffer())) {
+ YieldControlDeath();
+ return -1;
+ }
+ oc->input = oci;
}
/* advance to start of next request */
@@ -255,182 +246,164 @@ ReadRequestFromClient(ClientPtr client)
gotnow = oci->bufcnt + oci->buffer - oci->bufptr;
if (oci->ignoreBytes > 0) {
- if (oci->ignoreBytes > oci->size)
- needed = oci->size;
- else
- needed = oci->ignoreBytes;
+ if (oci->ignoreBytes > oci->size)
+ needed = oci->size;
+ else
+ needed = oci->ignoreBytes;
}
- else if (gotnow < sizeof(xReq))
- {
- /* We don't have an entire xReq yet. Can't tell how big
- * the request will be until we get the whole xReq.
- */
- needed = sizeof(xReq);
- need_header = TRUE;
+ else if (gotnow < sizeof(xReq)) {
+ /* We don't have an entire xReq yet. Can't tell how big
+ * the request will be until we get the whole xReq.
+ */
+ needed = sizeof(xReq);
+ need_header = TRUE;
}
- else
- {
- /* We have a whole xReq. We can tell how big the whole
- * request will be unless it is a Big Request.
- */
- request = (xReq *)oci->bufptr;
- needed = get_req_len(request, client);
- if (!needed && client->big_requests)
- {
- /* It's a Big Request. */
- move_header = TRUE;
- if (gotnow < sizeof(xBigReq))
- {
- /* Still need more data to tell just how big. */
- needed = bytes_to_int32(sizeof(xBigReq)); /* needed is in CARD32s now */
- need_header = TRUE;
- }
- else
- needed = get_big_req_len(request, client);
- }
- client->req_len = needed;
- needed <<= 2; /* needed is in bytes now */
+ else {
+ /* We have a whole xReq. We can tell how big the whole
+ * request will be unless it is a Big Request.
+ */
+ request = (xReq *) oci->bufptr;
+ needed = get_req_len(request, client);
+ if (!needed && client->big_requests) {
+ /* It's a Big Request. */
+ move_header = TRUE;
+ if (gotnow < sizeof(xBigReq)) {
+ /* Still need more data to tell just how big. */
+ needed = bytes_to_int32(sizeof(xBigReq)); /* needed is in CARD32s now */
+ need_header = TRUE;
+ }
+ else
+ needed = get_big_req_len(request, client);
+ }
+ client->req_len = needed;
+ needed <<= 2; /* needed is in bytes now */
}
- if (gotnow < needed)
- {
- /* Need to read more data, either so that we can get a
- * complete xReq (if need_header is TRUE), a complete
- * xBigReq (if move_header is TRUE), or the rest of the
- * request (if need_header and move_header are both FALSE).
- */
-
- oci->lenLastReq = 0;
- if (needed > maxBigRequestSize << 2)
- {
- /* request is too big for us to handle */
- /*
- * Mark the rest of it as needing to be ignored, and then return
- * the full size. Dispatch() will turn it into a BadLength error.
- */
- oci->ignoreBytes = needed - gotnow;
- oci->lenLastReq = gotnow;
- return needed;
- }
- if ((gotnow == 0) ||
- ((oci->bufptr - oci->buffer + needed) > oci->size))
- {
- /* no data, or the request is too big to fit in the buffer */
-
- if ((gotnow > 0) && (oci->bufptr != oci->buffer))
- /* save the data we've already read */
- memmove(oci->buffer, oci->bufptr, gotnow);
- if (needed > oci->size)
- {
- /* make buffer bigger to accomodate request */
- char *ibuf;
-
- ibuf = (char *)realloc(oci->buffer, needed);
- if (!ibuf)
- {
- YieldControlDeath();
- return -1;
- }
- oci->size = needed;
- oci->buffer = ibuf;
- }
- oci->bufptr = oci->buffer;
- oci->bufcnt = gotnow;
- }
- /* XXX this is a workaround. This function is sometimes called
- * after the trans_conn has been freed. In this case trans_conn
- * will be null. Really ought to restructure things so that we
- * never get here in those circumstances.
- */
- if (!oc->trans_conn)
- {
- /* treat as if an error occured on the read, which is what
- * used to happen
- */
- YieldControlDeath();
- return -1;
- }
- result = _XSERVTransRead(oc->trans_conn, oci->buffer + oci->bufcnt,
- oci->size - oci->bufcnt);
- if (result <= 0)
- {
- if ((result < 0) && ETEST(errno))
- {
+ if (gotnow < needed) {
+ /* Need to read more data, either so that we can get a
+ * complete xReq (if need_header is TRUE), a complete
+ * xBigReq (if move_header is TRUE), or the rest of the
+ * request (if need_header and move_header are both FALSE).
+ */
+
+ oci->lenLastReq = 0;
+ if (needed > maxBigRequestSize << 2) {
+ /* request is too big for us to handle */
+ /*
+ * Mark the rest of it as needing to be ignored, and then return
+ * the full size. Dispatch() will turn it into a BadLength error.
+ */
+ oci->ignoreBytes = needed - gotnow;
+ oci->lenLastReq = gotnow;
+ return needed;
+ }
+ if ((gotnow == 0) || ((oci->bufptr - oci->buffer + needed) > oci->size)) {
+ /* no data, or the request is too big to fit in the buffer */
+
+ if ((gotnow > 0) && (oci->bufptr != oci->buffer))
+ /* save the data we've already read */
+ memmove(oci->buffer, oci->bufptr, gotnow);
+ if (needed > oci->size) {
+ /* make buffer bigger to accomodate request */
+ char *ibuf;
+
+ ibuf = (char *) realloc(oci->buffer, needed);
+ if (!ibuf) {
+ YieldControlDeath();
+ return -1;
+ }
+ oci->size = needed;
+ oci->buffer = ibuf;
+ }
+ oci->bufptr = oci->buffer;
+ oci->bufcnt = gotnow;
+ }
+ /* XXX this is a workaround. This function is sometimes called
+ * after the trans_conn has been freed. In this case trans_conn
+ * will be null. Really ought to restructure things so that we
+ * never get here in those circumstances.
+ */
+ if (!oc->trans_conn) {
+ /* treat as if an error occured on the read, which is what
+ * used to happen
+ */
+ YieldControlDeath();
+ return -1;
+ }
+ result = _XSERVTransRead(oc->trans_conn, oci->buffer + oci->bufcnt,
+ oci->size - oci->bufcnt);
+ if (result <= 0) {
+ if ((result < 0) && ETEST(errno)) {
#if defined(SVR4) && defined(__i386__) && !defined(sun)
- if (0)
+ if (0)
#endif
- {
- YieldControlNoInput(fd);
- return 0;
- }
- }
- YieldControlDeath();
- return -1;
- }
- oci->bufcnt += result;
- gotnow += result;
- /* free up some space after huge requests */
- if ((oci->size > BUFWATERMARK) &&
- (oci->bufcnt < BUFSIZE) && (needed < BUFSIZE))
- {
- char *ibuf;
-
- ibuf = (char *)realloc(oci->buffer, BUFSIZE);
- if (ibuf)
- {
- oci->size = BUFSIZE;
- oci->buffer = ibuf;
- oci->bufptr = ibuf + oci->bufcnt - gotnow;
- }
- }
- if (need_header && gotnow >= needed)
- {
- /* We wanted an xReq, now we've gotten it. */
- request = (xReq *)oci->bufptr;
- needed = get_req_len(request, client);
- if (!needed && client->big_requests)
- {
- move_header = TRUE;
- if (gotnow < sizeof(xBigReq))
- needed = bytes_to_int32(sizeof(xBigReq));
- else
- needed = get_big_req_len(request, client);
- }
- client->req_len = needed;
- needed <<= 2;
- }
- if (gotnow < needed)
- {
- /* Still don't have enough; punt. */
- YieldControlNoInput(fd);
- return 0;
- }
+ {
+ YieldControlNoInput(fd);
+ return 0;
+ }
+ }
+ YieldControlDeath();
+ return -1;
+ }
+ oci->bufcnt += result;
+ gotnow += result;
+ /* free up some space after huge requests */
+ if ((oci->size > BUFWATERMARK) &&
+ (oci->bufcnt < BUFSIZE) && (needed < BUFSIZE)) {
+ char *ibuf;
+
+ ibuf = (char *) realloc(oci->buffer, BUFSIZE);
+ if (ibuf) {
+ oci->size = BUFSIZE;
+ oci->buffer = ibuf;
+ oci->bufptr = ibuf + oci->bufcnt - gotnow;
+ }
+ }
+ if (need_header && gotnow >= needed) {
+ /* We wanted an xReq, now we've gotten it. */
+ request = (xReq *) oci->bufptr;
+ needed = get_req_len(request, client);
+ if (!needed && client->big_requests) {
+ move_header = TRUE;
+ if (gotnow < sizeof(xBigReq))
+ needed = bytes_to_int32(sizeof(xBigReq));
+ else
+ needed = get_big_req_len(request, client);
+ }
+ client->req_len = needed;
+ needed <<= 2;
+ }
+ if (gotnow < needed) {
+ /* Still don't have enough; punt. */
+ YieldControlNoInput(fd);
+ return 0;
+ }
}
- if (needed == 0)
- {
- if (client->big_requests)
- needed = sizeof(xBigReq);
- else
- needed = sizeof(xReq);
+ if (needed == 0) {
+ if (client->big_requests)
+ needed = sizeof(xBigReq);
+ else
+ needed = sizeof(xReq);
}
/* If there are bytes to ignore, ignore them now. */
if (oci->ignoreBytes > 0) {
- assert(needed == oci->ignoreBytes || needed == oci->size);
- /*
- * The _XSERVTransRead call above may return more or fewer bytes than we
- * want to ignore. Ignore the smaller of the two sizes.
- */
- if (gotnow < needed) {
- oci->ignoreBytes -= gotnow;
- oci->bufptr += gotnow;
- gotnow = 0;
- } else {
- oci->ignoreBytes -= needed;
- oci->bufptr += needed;
- gotnow -= needed;
- }
- needed = 0;
+ assert(needed == oci->ignoreBytes || needed == oci->size);
+ /*
+ * The _XSERVTransRead call above may return more or fewer bytes than we
+ * want to ignore. Ignore the smaller of the two sizes.
+ */
+ if (gotnow < needed) {
+ oci->ignoreBytes -= gotnow;
+ oci->bufptr += gotnow;
+ gotnow = 0;
+ }
+ else {
+ oci->ignoreBytes -= needed;
+ oci->bufptr += needed;
+ gotnow -= needed;
+ }
+ needed = 0;
}
oci->lenLastReq = needed;
@@ -444,50 +417,47 @@ ReadRequestFromClient(ClientPtr client)
*/
gotnow -= needed;
- if (gotnow >= sizeof(xReq))
- {
- request = (xReq *)(oci->bufptr + needed);
- if (gotnow >= (result = (get_req_len(request, client) << 2))
- && (result ||
- (client->big_requests &&
- (gotnow >= sizeof(xBigReq) &&
- gotnow >= (get_big_req_len(request, client) << 2))))
- )
- FD_SET(fd, &ClientsWithInput);
- else
- {
- if (!SmartScheduleDisable)
- FD_CLR(fd, &ClientsWithInput);
- else
- YieldControlNoInput(fd);
- }
+ if (gotnow >= sizeof(xReq)) {
+ request = (xReq *) (oci->bufptr + needed);
+ if (gotnow >= (result = (get_req_len(request, client) << 2))
+ && (result ||
+ (client->big_requests &&
+ (gotnow >= sizeof(xBigReq) &&
+ gotnow >= (get_big_req_len(request, client) << 2))))
+ )
+ FD_SET(fd, &ClientsWithInput);
+ else {
+ if (!SmartScheduleDisable)
+ FD_CLR(fd, &ClientsWithInput);
+ else
+ YieldControlNoInput(fd);
+ }
}
- else
- {
- if (!gotnow)
- AvailableInput = oc;
- if (!SmartScheduleDisable)
- FD_CLR(fd, &ClientsWithInput);
- else
- YieldControlNoInput(fd);
+ else {
+ if (!gotnow)
+ AvailableInput = oc;
+ if (!SmartScheduleDisable)
+ FD_CLR(fd, &ClientsWithInput);
+ else
+ YieldControlNoInput(fd);
}
if (SmartScheduleDisable)
- if (++timesThisConnection >= MAX_TIMES_PER)
- YieldControl();
- if (move_header)
- {
- request = (xReq *)oci->bufptr;
- oci->bufptr += (sizeof(xBigReq) - sizeof(xReq));
- *(xReq *)oci->bufptr = *request;
- oci->lenLastReq -= (sizeof(xBigReq) - sizeof(xReq));
- client->req_len -= bytes_to_int32(sizeof(xBigReq) - sizeof(xReq));
+ if (++timesThisConnection >= MAX_TIMES_PER)
+ YieldControl();
+ if (move_header) {
+ request = (xReq *) oci->bufptr;
+ oci->bufptr += (sizeof(xBigReq) - sizeof(xReq));
+ *(xReq *) oci->bufptr = *request;
+ oci->lenLastReq -= (sizeof(xBigReq) - sizeof(xReq));
+ client->req_len -= bytes_to_int32(sizeof(xBigReq) - sizeof(xReq));
}
- client->requestBuffer = (pointer)oci->bufptr;
+ client->requestBuffer = (pointer) oci->bufptr;
#ifdef DEBUG_COMMUNICATION
{
- xReq *req = client->requestBuffer;
- ErrorF("REQUEST: ClientIDX: %i, type: 0x%x data: 0x%x len: %i\n",
- client->index,req->reqType,req->data,req->length);
+ xReq *req = client->requestBuffer;
+
+ ErrorF("REQUEST: ClientIDX: %i, type: 0x%x data: 0x%x len: %i\n",
+ client->index, req->reqType, req->data, req->length);
}
#endif
return needed;
@@ -502,68 +472,62 @@ ReadRequestFromClient(ClientPtr client)
Bool
InsertFakeRequest(ClientPtr client, char *data, int count)
{
- OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ OsCommPtr oc = (OsCommPtr) client->osPrivate;
ConnectionInputPtr oci = oc->input;
int fd = oc->fd;
int gotnow, moveup;
- if (AvailableInput)
- {
- if (AvailableInput != oc)
- {
- ConnectionInputPtr aci = AvailableInput->input;
- if (aci->size > BUFWATERMARK)
- {
- free(aci->buffer);
- free(aci);
- }
- else
- {
- aci->next = FreeInputs;
- FreeInputs = aci;
- }
- AvailableInput->input = (ConnectionInputPtr)NULL;
- }
- AvailableInput = (OsCommPtr)NULL;
+ if (AvailableInput) {
+ if (AvailableInput != oc) {
+ ConnectionInputPtr aci = AvailableInput->input;
+
+ if (aci->size > BUFWATERMARK) {
+ free(aci->buffer);
+ free(aci);
+ }
+ else {
+ aci->next = FreeInputs;
+ FreeInputs = aci;
+ }
+ AvailableInput->input = (ConnectionInputPtr) NULL;
+ }
+ AvailableInput = (OsCommPtr) NULL;
}
- if (!oci)
- {
- if ((oci = FreeInputs))
- FreeInputs = oci->next;
- else if (!(oci = AllocateInputBuffer()))
- return FALSE;
- oc->input = oci;
+ if (!oci) {
+ if ((oci = FreeInputs))
+ FreeInputs = oci->next;
+ else if (!(oci = AllocateInputBuffer()))
+ return FALSE;
+ oc->input = oci;
}
oci->bufptr += oci->lenLastReq;
oci->lenLastReq = 0;
gotnow = oci->bufcnt + oci->buffer - oci->bufptr;
- if ((gotnow + count) > oci->size)
- {
- char *ibuf;
-
- ibuf = (char *)realloc(oci->buffer, gotnow + count);
- if (!ibuf)
- return FALSE;
- oci->size = gotnow + count;
- oci->buffer = ibuf;
- oci->bufptr = ibuf + oci->bufcnt - gotnow;
+ if ((gotnow + count) > oci->size) {
+ char *ibuf;
+
+ ibuf = (char *) realloc(oci->buffer, gotnow + count);
+ if (!ibuf)
+ return FALSE;
+ oci->size = gotnow + count;
+ oci->buffer = ibuf;
+ oci->bufptr = ibuf + oci->bufcnt - gotnow;
}
moveup = count - (oci->bufptr - oci->buffer);
- if (moveup > 0)
- {
- if (gotnow > 0)
- memmove(oci->bufptr + moveup, oci->bufptr, gotnow);
- oci->bufptr += moveup;
- oci->bufcnt += moveup;
+ if (moveup > 0) {
+ if (gotnow > 0)
+ memmove(oci->bufptr + moveup, oci->bufptr, gotnow);
+ oci->bufptr += moveup;
+ oci->bufcnt += moveup;
}
memmove(oci->bufptr - count, data, count);
oci->bufptr -= count;
gotnow += count;
if ((gotnow >= sizeof(xReq)) &&
- (gotnow >= (int)(get_req_len((xReq *)oci->bufptr, client) << 2)))
- FD_SET(fd, &ClientsWithInput);
+ (gotnow >= (int) (get_req_len((xReq *) oci->bufptr, client) << 2)))
+ FD_SET(fd, &ClientsWithInput);
else
- YieldControlNoInput(fd);
+ YieldControlNoInput(fd);
return TRUE;
}
@@ -576,51 +540,45 @@ InsertFakeRequest(ClientPtr client, char *data, int count)
void
ResetCurrentRequest(ClientPtr client)
{
- OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ OsCommPtr oc = (OsCommPtr) client->osPrivate;
register ConnectionInputPtr oci = oc->input;
int fd = oc->fd;
register xReq *request;
int gotnow, needed;
+
if (AvailableInput == oc)
- AvailableInput = (OsCommPtr)NULL;
+ AvailableInput = (OsCommPtr) NULL;
oci->lenLastReq = 0;
gotnow = oci->bufcnt + oci->buffer - oci->bufptr;
- if (gotnow < sizeof(xReq))
- {
- YieldControlNoInput(fd);
+ if (gotnow < sizeof(xReq)) {
+ YieldControlNoInput(fd);
}
- else
- {
- request = (xReq *)oci->bufptr;
- needed = get_req_len(request, client);
- if (!needed && client->big_requests)
- {
- oci->bufptr -= sizeof(xBigReq) - sizeof(xReq);
- *(xReq *)oci->bufptr = *request;
- ((xBigReq *)oci->bufptr)->length = client->req_len;
- if (client->swapped)
- {
- swapl(&((xBigReq *)oci->bufptr)->length);
- }
- }
- if (gotnow >= (needed << 2))
- {
- if (FD_ISSET(fd, &AllClients))
- {
- FD_SET(fd, &ClientsWithInput);
- }
- else
- {
- FD_SET(fd, &IgnoredClientsWithInput);
- }
- YieldControl();
- }
- else
- YieldControlNoInput(fd);
+ else {
+ request = (xReq *) oci->bufptr;
+ needed = get_req_len(request, client);
+ if (!needed && client->big_requests) {
+ oci->bufptr -= sizeof(xBigReq) - sizeof(xReq);
+ *(xReq *) oci->bufptr = *request;
+ ((xBigReq *) oci->bufptr)->length = client->req_len;
+ if (client->swapped) {
+ swapl(&((xBigReq *) oci->bufptr)->length);
+ }
+ }
+ if (gotnow >= (needed << 2)) {
+ if (FD_ISSET(fd, &AllClients)) {
+ FD_SET(fd, &ClientsWithInput);
+ }
+ else {
+ FD_SET(fd, &IgnoredClientsWithInput);
+ }
+ YieldControl();
+ }
+ else
+ YieldControlNoInput(fd);
}
}
-static const int padlength[4] = {0, 3, 2, 1};
+static const int padlength[4] = { 0, 3, 2, 1 };
/********************
* FlushAllOutput()
@@ -636,19 +594,20 @@ void
FlushAllOutput(void)
{
register int index, base;
- register fd_mask mask; /* raphael */
+ register fd_mask mask; /* raphael */
OsCommPtr oc;
register ClientPtr client;
Bool newoutput = NewOutputPending;
+
#if defined(WIN32)
fd_set newOutputPending;
#endif
if (FlushCallback)
- CallCallbacks(&FlushCallback, NULL);
+ CallCallbacks(&FlushCallback, NULL);
if (!newoutput)
- return;
+ return;
/*
* It may be that some client still has critical output pending,
@@ -659,57 +618,54 @@ FlushAllOutput(void)
NewOutputPending = FALSE;
#ifndef WIN32
- for (base = 0; base < howmany(XFD_SETSIZE, NFDBITS); base++)
- {
- mask = OutputPending.fds_bits[ base ];
- OutputPending.fds_bits[ base ] = 0;
- while (mask)
- {
- index = ffs(mask) - 1;
- mask &= ~lowbit(mask);
- if ((index = ConnectionTranslation[(base * (sizeof(fd_mask)*8)) + index]) == 0)
- continue;
- client = clients[index];
- if (client->clientGone)
- continue;
- oc = (OsCommPtr)client->osPrivate;
- if (FD_ISSET(oc->fd, &ClientsWithInput))
- {
- FD_SET(oc->fd, &OutputPending); /* set the bit again */
- NewOutputPending = TRUE;
- }
- else
- (void)FlushClient(client, oc, (char *)NULL, 0);
- }
+ for (base = 0; base < howmany(XFD_SETSIZE, NFDBITS); base++) {
+ mask = OutputPending.fds_bits[base];
+ OutputPending.fds_bits[base] = 0;
+ while (mask) {
+ index = ffs(mask) - 1;
+ mask &= ~lowbit(mask);
+ if ((index =
+ ConnectionTranslation[(base * (sizeof(fd_mask) * 8)) +
+ index]) == 0)
+ continue;
+ client = clients[index];
+ if (client->clientGone)
+ continue;
+ oc = (OsCommPtr) client->osPrivate;
+ if (FD_ISSET(oc->fd, &ClientsWithInput)) {
+ FD_SET(oc->fd, &OutputPending); /* set the bit again */
+ NewOutputPending = TRUE;
+ }
+ else
+ (void) FlushClient(client, oc, (char *) NULL, 0);
+ }
}
-#else /* WIN32 */
+#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);
+ 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 */
+#endif /* WIN32 */
}
void
FlushIfCriticalOutputPending(void)
{
if (CriticalOutputPending)
- FlushAllOutput();
+ FlushAllOutput();
}
void
@@ -730,139 +686,135 @@ SetCriticalOutputPending(void)
*****************/
int
-WriteToClient (ClientPtr who, int count, const void *__buf)
+WriteToClient(ClientPtr who, int count, const void *__buf)
{
OsCommPtr oc;
ConnectionOutputPtr oco;
int padBytes;
const char *buf = __buf;
+
#ifdef DEBUG_COMMUNICATION
Bool multicount = FALSE;
#endif
if (!count || !who || who == serverClient || who->clientGone)
- return 0;
+ return 0;
oc = who->osPrivate;
oco = oc->output;
#ifdef DEBUG_COMMUNICATION
{
- char info[128];
- xError *err;
- xGenericReply *rep;
- xEvent *ev;
-
- if (!who->replyBytesRemaining) {
- switch(buf[0]) {
- case X_Reply:
- rep = (xGenericReply*)buf;
- if (rep->sequenceNumber == who->sequence) {
- snprintf(info,127,"Xreply: type: 0x%x data: 0x%x "
- "len: %i seq#: 0x%x", rep->type, rep->data1,
- rep->length, rep->sequenceNumber);
- multicount = TRUE;
- }
- break;
- case X_Error:
- err = (xError*)buf;
- snprintf(info,127,"Xerror: Code: 0x%x resID: 0x%x maj: 0x%x "
- "min: %x", err->errorCode,err->resourceID,
- err->minorCode,err->majorCode);
- break;
- default:
- if ((buf[0] & 0x7f) == KeymapNotify)
- snprintf(info,127,"KeymapNotifyEvent: %i",buf[0]);
- else {
- ev = (xEvent*)buf;
- snprintf(info,127,"XEvent: type: 0x%x detail: 0x%x "
- "seq#: 0x%x", ev->u.u.type, ev->u.u.detail,
- ev->u.u.sequenceNumber);
- }
- }
- ErrorF("REPLY: ClientIDX: %i %s\n",who->index, info);
- } else
- multicount = TRUE;
+ char info[128];
+ xError *err;
+ xGenericReply *rep;
+ xEvent *ev;
+
+ if (!who->replyBytesRemaining) {
+ switch (buf[0]) {
+ case X_Reply:
+ rep = (xGenericReply *) buf;
+ if (rep->sequenceNumber == who->sequence) {
+ snprintf(info, 127, "Xreply: type: 0x%x data: 0x%x "
+ "len: %i seq#: 0x%x", rep->type, rep->data1,
+ rep->length, rep->sequenceNumber);
+ multicount = TRUE;
+ }
+ break;
+ case X_Error:
+ err = (xError *) buf;
+ snprintf(info, 127, "Xerror: Code: 0x%x resID: 0x%x maj: 0x%x "
+ "min: %x", err->errorCode, err->resourceID,
+ err->minorCode, err->majorCode);
+ break;
+ default:
+ if ((buf[0] & 0x7f) == KeymapNotify)
+ snprintf(info, 127, "KeymapNotifyEvent: %i", buf[0]);
+ else {
+ ev = (xEvent *) buf;
+ snprintf(info, 127, "XEvent: type: 0x%x detail: 0x%x "
+ "seq#: 0x%x", ev->u.u.type, ev->u.u.detail,
+ ev->u.u.sequenceNumber);
+ }
+ }
+ ErrorF("REPLY: ClientIDX: %i %s\n", who->index, info);
+ }
+ else
+ multicount = TRUE;
}
#endif
- if (!oco)
- {
- if ((oco = FreeOutputs))
- {
- FreeOutputs = oco->next;
- }
- else if (!(oco = AllocateOutputBuffer()))
- {
- if (oc->trans_conn) {
- _XSERVTransDisconnect(oc->trans_conn);
- _XSERVTransClose(oc->trans_conn);
- oc->trans_conn = NULL;
- }
- MarkClientException(who);
- return -1;
- }
- oc->output = oco;
+ if (!oco) {
+ if ((oco = FreeOutputs)) {
+ FreeOutputs = oco->next;
+ }
+ else if (!(oco = AllocateOutputBuffer())) {
+ if (oc->trans_conn) {
+ _XSERVTransDisconnect(oc->trans_conn);
+ _XSERVTransClose(oc->trans_conn);
+ oc->trans_conn = NULL;
+ }
+ MarkClientException(who);
+ return -1;
+ }
+ oc->output = oco;
}
padBytes = padlength[count & 3];
- if(ReplyCallback)
- {
+ if (ReplyCallback) {
ReplyInfoRec replyinfo;
- replyinfo.client = who;
- replyinfo.replyData = buf;
- replyinfo.dataLenBytes = count + padBytes;
- replyinfo.padBytes = padBytes;
- if (who->replyBytesRemaining)
- { /* still sending data of an earlier reply */
- who->replyBytesRemaining -= count + padBytes;
- replyinfo.startOfReply = FALSE;
- replyinfo.bytesRemaining = who->replyBytesRemaining;
- CallCallbacks((&ReplyCallback), (pointer)&replyinfo);
- }
- else if (who->clientState == ClientStateRunning
- && buf[0] == X_Reply)
- { /* start of new reply */
- CARD32 replylen;
- unsigned long bytesleft;
-
- replylen = ((const xGenericReply *)buf)->length;
- if (who->swapped)
- swapl(&replylen);
- bytesleft = (replylen * 4) + SIZEOF(xReply) - count - padBytes;
- replyinfo.startOfReply = TRUE;
- replyinfo.bytesRemaining = who->replyBytesRemaining = bytesleft;
- CallCallbacks((&ReplyCallback), (pointer)&replyinfo);
- }
+ replyinfo.client = who;
+ replyinfo.replyData = buf;
+ replyinfo.dataLenBytes = count + padBytes;
+ replyinfo.padBytes = padBytes;
+ if (who->replyBytesRemaining) { /* still sending data of an earlier reply */
+ who->replyBytesRemaining -= count + padBytes;
+ replyinfo.startOfReply = FALSE;
+ replyinfo.bytesRemaining = who->replyBytesRemaining;
+ CallCallbacks((&ReplyCallback), (pointer) &replyinfo);
+ }
+ else if (who->clientState == ClientStateRunning && buf[0] == X_Reply) { /* start of new reply */
+ CARD32 replylen;
+ unsigned long bytesleft;
+
+ replylen = ((const xGenericReply *) buf)->length;
+ if (who->swapped)
+ swapl(&replylen);
+ bytesleft = (replylen * 4) + SIZEOF(xReply) - count - padBytes;
+ replyinfo.startOfReply = TRUE;
+ replyinfo.bytesRemaining = who->replyBytesRemaining = bytesleft;
+ CallCallbacks((&ReplyCallback), (pointer) &replyinfo);
+ }
}
#ifdef DEBUG_COMMUNICATION
else if (multicount) {
- if (who->replyBytesRemaining) {
- who->replyBytesRemaining -= (count + padBytes);
- } else {
- CARD32 replylen;
- replylen = ((xGenericReply *)buf)->length;
- who->replyBytesRemaining =
- (replylen * 4) + SIZEOF(xReply) - count - padBytes;
- }
+ if (who->replyBytesRemaining) {
+ who->replyBytesRemaining -= (count + padBytes);
+ }
+ else {
+ CARD32 replylen;
+
+ replylen = ((xGenericReply *) buf)->length;
+ who->replyBytesRemaining =
+ (replylen * 4) + SIZEOF(xReply) - count - padBytes;
+ }
}
#endif
- if (oco->count + count + padBytes > oco->size)
- {
- FD_CLR(oc->fd, &OutputPending);
- if(!XFD_ANYSET(&OutputPending)) {
- CriticalOutputPending = FALSE;
- NewOutputPending = FALSE;
- }
+ if (oco->count + count + padBytes > oco->size) {
+ FD_CLR(oc->fd, &OutputPending);
+ if (!XFD_ANYSET(&OutputPending)) {
+ CriticalOutputPending = FALSE;
+ NewOutputPending = FALSE;
+ }
- if (FlushCallback)
- CallCallbacks(&FlushCallback, NULL);
+ if (FlushCallback)
+ CallCallbacks(&FlushCallback, NULL);
- return FlushClient(who, oc, buf, count);
+ return FlushClient(who, oc, buf, count);
}
NewOutputPending = TRUE;
FD_SET(oc->fd, &OutputPending);
- memmove((char *)oco->buf + oco->count, buf, count);
+ memmove((char *) oco->buf + oco->count, buf, count);
oco->count += count + padBytes;
return count;
}
@@ -892,30 +844,30 @@ FlushClient(ClientPtr who, OsCommPtr oc, const void *__extraBuf, int extraCount)
long todo;
if (!oco)
- return 0;
+ return 0;
written = 0;
padsize = padlength[extraCount & 3];
notWritten = oco->count + extraCount + padsize;
todo = notWritten;
while (notWritten) {
- long before = written; /* amount of whole thing written */
- long remain = todo; /* amount to try this time, <= notWritten */
- int i = 0;
- long len;
-
- /* You could be very general here and have "in" and "out" iovecs
- * and write a loop without using a macro, but what the heck. This
- * translates to:
- *
- * how much of this piece is new?
- * if more new then we are trying this time, clamp
- * if nothing new
- * then bump down amount already written, for next piece
- * else put new stuff in iovec, will need all of next piece
- *
- * Note that todo had better be at least 1 or else we'll end up
- * writing 0 iovecs.
- */
+ long before = written; /* amount of whole thing written */
+ long remain = todo; /* amount to try this time, <= notWritten */
+ int i = 0;
+ long len;
+
+ /* You could be very general here and have "in" and "out" iovecs
+ * and write a loop without using a macro, but what the heck. This
+ * translates to:
+ *
+ * how much of this piece is new?
+ * if more new then we are trying this time, clamp
+ * if nothing new
+ * then bump down amount already written, for next piece
+ * else put new stuff in iovec, will need all of next piece
+ *
+ * Note that todo had better be at least 1 or else we'll end up
+ * writing 0 iovecs.
+ */
#define InsertIOV(pointer, length) \
len = (length) - before; \
if (len > remain) \
@@ -930,120 +882,105 @@ FlushClient(ClientPtr who, OsCommPtr oc, const void *__extraBuf, int extraCount)
before = 0; \
}
- InsertIOV ((char *)oco->buf, oco->count)
- InsertIOV ((char *)extraBuf, extraCount)
- InsertIOV (padBuffer, padsize)
-
- errno = 0;
- if (trans_conn && (len = _XSERVTransWritev(trans_conn, iov, i)) >= 0)
- {
- written += len;
- notWritten -= len;
- todo = notWritten;
- }
- else if (ETEST(errno)
-#ifdef SUNSYSV /* check for another brain-damaged OS bug */
- || (errno == 0)
+ InsertIOV((char *) oco->buf, oco->count)
+ InsertIOV((char *) extraBuf, extraCount)
+ InsertIOV(padBuffer, padsize)
+
+ errno = 0;
+ if (trans_conn && (len = _XSERVTransWritev(trans_conn, iov, i)) >= 0) {
+ written += len;
+ notWritten -= len;
+ todo = notWritten;
+ }
+ else if (ETEST(errno)
+#ifdef SUNSYSV /* check for another brain-damaged OS bug */
+ || (errno == 0)
#endif
-#ifdef EMSGSIZE /* check for another brain-damaged OS bug */
- || ((errno == EMSGSIZE) && (todo == 1))
+#ifdef EMSGSIZE /* check for another brain-damaged OS bug */
+ || ((errno == EMSGSIZE) && (todo == 1))
#endif
- )
- {
- /* If we've arrived here, then the client is stuffed to the gills
- and not ready to accept more. Make a note of it and buffer
- the rest. */
- FD_SET(connection, &ClientsWriteBlocked);
- AnyClientsWriteBlocked = TRUE;
-
- if (written < oco->count)
- {
- if (written > 0)
- {
- oco->count -= written;
- memmove((char *)oco->buf,
- (char *)oco->buf + written,
- oco->count);
- written = 0;
- }
- }
- else
- {
- written -= oco->count;
- oco->count = 0;
- }
-
- if (notWritten > oco->size)
- {
- unsigned char *obuf;
-
- obuf = (unsigned char *)realloc(oco->buf,
- notWritten + BUFSIZE);
- if (!obuf)
- {
- _XSERVTransDisconnect(oc->trans_conn);
- _XSERVTransClose(oc->trans_conn);
- oc->trans_conn = NULL;
- MarkClientException(who);
- oco->count = 0;
- return -1;
- }
- oco->size = notWritten + BUFSIZE;
- oco->buf = obuf;
- }
-
- /* If the amount written extended into the padBuffer, then the
- difference "extraCount - written" may be less than 0 */
- if ((len = extraCount - written) > 0)
- memmove ((char *)oco->buf + oco->count,
- extraBuf + written,
- len);
-
- oco->count = notWritten; /* this will include the pad */
- /* return only the amount explicitly requested */
- return extraCount;
- }
-#ifdef EMSGSIZE /* check for another brain-damaged OS bug */
- else if (errno == EMSGSIZE)
- {
- todo >>= 1;
- }
+ ) {
+ /* If we've arrived here, then the client is stuffed to the gills
+ and not ready to accept more. Make a note of it and buffer
+ the rest. */
+ FD_SET(connection, &ClientsWriteBlocked);
+ AnyClientsWriteBlocked = TRUE;
+
+ if (written < oco->count) {
+ if (written > 0) {
+ oco->count -= written;
+ memmove((char *) oco->buf,
+ (char *) oco->buf + written, oco->count);
+ written = 0;
+ }
+ }
+ else {
+ written -= oco->count;
+ oco->count = 0;
+ }
+
+ if (notWritten > oco->size) {
+ unsigned char *obuf;
+
+ obuf = (unsigned char *) realloc(oco->buf,
+ notWritten + BUFSIZE);
+ if (!obuf) {
+ _XSERVTransDisconnect(oc->trans_conn);
+ _XSERVTransClose(oc->trans_conn);
+ oc->trans_conn = NULL;
+ MarkClientException(who);
+ oco->count = 0;
+ return -1;
+ }
+ oco->size = notWritten + BUFSIZE;
+ oco->buf = obuf;
+ }
+
+ /* If the amount written extended into the padBuffer, then the
+ difference "extraCount - written" may be less than 0 */
+ if ((len = extraCount - written) > 0)
+ memmove((char *) oco->buf + oco->count,
+ extraBuf + written, len);
+
+ oco->count = notWritten; /* this will include the pad */
+ /* return only the amount explicitly requested */
+ return extraCount;
+ }
+#ifdef EMSGSIZE /* check for another brain-damaged OS bug */
+ else if (errno == EMSGSIZE) {
+ todo >>= 1;
+ }
#endif
- else
- {
- if (oc->trans_conn)
- {
- _XSERVTransDisconnect(oc->trans_conn);
- _XSERVTransClose(oc->trans_conn);
- oc->trans_conn = NULL;
- }
- MarkClientException(who);
- oco->count = 0;
- return -1;
- }
+ else {
+ if (oc->trans_conn) {
+ _XSERVTransDisconnect(oc->trans_conn);
+ _XSERVTransClose(oc->trans_conn);
+ oc->trans_conn = NULL;
+ }
+ MarkClientException(who);
+ oco->count = 0;
+ return -1;
+ }
}
/* everything was flushed out */
oco->count = 0;
/* check to see if this client was write blocked */
- if (AnyClientsWriteBlocked)
- {
- FD_CLR(oc->fd, &ClientsWriteBlocked);
- if (! XFD_ANYSET(&ClientsWriteBlocked))
- AnyClientsWriteBlocked = FALSE;
+ if (AnyClientsWriteBlocked) {
+ FD_CLR(oc->fd, &ClientsWriteBlocked);
+ if (!XFD_ANYSET(&ClientsWriteBlocked))
+ AnyClientsWriteBlocked = FALSE;
}
- if (oco->size > BUFWATERMARK)
- {
- free(oco->buf);
- free(oco);
+ if (oco->size > BUFWATERMARK) {
+ free(oco->buf);
+ free(oco);
}
- else
- {
- oco->next = FreeOutputs;
- FreeOutputs = oco;
+ else {
+ oco->next = FreeOutputs;
+ FreeOutputs = oco;
}
- oc->output = (ConnectionOutputPtr)NULL;
- return extraCount; /* return only the amount explicitly requested */
+ oc->output = (ConnectionOutputPtr) NULL;
+ return extraCount; /* return only the amount explicitly requested */
}
static ConnectionInputPtr
@@ -1053,12 +990,11 @@ AllocateInputBuffer(void)
oci = malloc(sizeof(ConnectionInput));
if (!oci)
- return NULL;
+ return NULL;
oci->buffer = malloc(BUFSIZE);
- if (!oci->buffer)
- {
- free(oci);
- return NULL;
+ if (!oci->buffer) {
+ free(oci);
+ return NULL;
}
oci->size = BUFSIZE;
oci->bufptr = oci->buffer;
@@ -1075,12 +1011,11 @@ AllocateOutputBuffer(void)
oco = malloc(sizeof(ConnectionOutput));
if (!oco)
- return NULL;
+ return NULL;
oco->buf = calloc(1, BUFSIZE);
- if (!oco->buf)
- {
- free(oco);
- return NULL;
+ if (!oco->buf) {
+ free(oco);
+ return NULL;
}
oco->size = BUFSIZE;
oco->count = 0;
@@ -1094,36 +1029,30 @@ FreeOsBuffers(OsCommPtr oc)
ConnectionOutputPtr oco;
if (AvailableInput == oc)
- AvailableInput = (OsCommPtr)NULL;
- if ((oci = oc->input))
- {
- if (FreeInputs)
- {
- free(oci->buffer);
- free(oci);
- }
- else
- {
- FreeInputs = oci;
- oci->next = (ConnectionInputPtr)NULL;
- oci->bufptr = oci->buffer;
- oci->bufcnt = 0;
- oci->lenLastReq = 0;
- }
+ AvailableInput = (OsCommPtr) NULL;
+ if ((oci = oc->input)) {
+ if (FreeInputs) {
+ free(oci->buffer);
+ free(oci);
+ }
+ else {
+ FreeInputs = oci;
+ oci->next = (ConnectionInputPtr) NULL;
+ oci->bufptr = oci->buffer;
+ oci->bufcnt = 0;
+ oci->lenLastReq = 0;
+ }
}
- if ((oco = oc->output))
- {
- if (FreeOutputs)
- {
- free(oco->buf);
- free(oco);
- }
- else
- {
- FreeOutputs = oco;
- oco->next = (ConnectionOutputPtr)NULL;
- oco->count = 0;
- }
+ if ((oco = oc->output)) {
+ if (FreeOutputs) {
+ free(oco->buf);
+ free(oco);
+ }
+ else {
+ FreeOutputs = oco;
+ oco->next = (ConnectionOutputPtr) NULL;
+ oco->count = 0;
+ }
}
}
@@ -1133,16 +1062,14 @@ ResetOsBuffers(void)
ConnectionInputPtr oci;
ConnectionOutputPtr oco;
- while ((oci = FreeInputs))
- {
- FreeInputs = oci->next;
- free(oci->buffer);
- free(oci);
+ while ((oci = FreeInputs)) {
+ FreeInputs = oci->next;
+ free(oci->buffer);
+ free(oci);
}
- while ((oco = FreeOutputs))
- {
- FreeOutputs = oco->next;
- free(oco->buf);
- free(oco);
+ while ((oco = FreeOutputs)) {
+ FreeOutputs = oco->next;
+ free(oco->buf);
+ free(oco);
}
}
diff --git a/xorg-server/os/log.c b/xorg-server/os/log.c
index 671a01bb6..1b1b28519 100644
--- a/xorg-server/os/log.c
+++ b/xorg-server/os/log.c
@@ -24,7 +24,6 @@ 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 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
Copyright 1994 Quarterdeck Office Systems.
@@ -76,7 +75,6 @@ OR PERFORMANCE OF THIS SOFTWARE.
* authorization from the copyright holder(s) and author(s).
*/
-
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
@@ -86,7 +84,7 @@ OR PERFORMANCE OF THIS SOFTWARE.
#include <time.h>
#include <sys/stat.h>
#include <stdarg.h>
-#include <stdlib.h> /* for malloc() */
+#include <stdlib.h> /* for malloc() */
#include "input.h"
#include "site.h"
@@ -106,7 +104,7 @@ OR PERFORMANCE OF THIS SOFTWARE.
#endif
#ifdef DDXOSVERRORF
-void (*OsVendorVErrorFProc)(const char *, va_list args) = NULL;
+void (*OsVendorVErrorFProc) (const char *, va_list args) = NULL;
#endif
static FILE *logFile = NULL;
@@ -123,13 +121,15 @@ static Bool needBuffer = TRUE;
#ifdef __APPLE__
#include <AvailabilityMacros.h>
-static char __crashreporter_info_buff__[4096] = {0};
-static const char *__crashreporter_info__ __attribute__((__used__)) = &__crashreporter_info_buff__[0];
+static char __crashreporter_info_buff__[4096] = { 0 };
+
+static const char *__crashreporter_info__ __attribute__ ((__used__)) =
+ &__crashreporter_info_buff__[0];
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
// This is actually a toolchain requirement, but I'm not sure the correct check,
// but it should be fine to just only include it for Leopard and later. This line
// just tells the linker to never strip this symbol (such as for space optimization)
-asm (".desc ___crashreporter_info__, 0x10");
+asm(".desc ___crashreporter_info__, 0x10");
#endif
#endif
@@ -164,6 +164,9 @@ asm (".desc ___crashreporter_info__, 0x10");
#ifndef X_NOT_IMPLEMENTED_STRING
#define X_NOT_IMPLEMENTED_STRING "(NI)"
#endif
+#ifndef X_DEBUG_STRING
+#define X_DEBUG_STRING "(DB)"
+#endif
#ifndef X_NONE_STRING
#define X_NONE_STRING ""
#endif
@@ -183,39 +186,39 @@ LogInit(const char *fname, const char *backup)
char *logFileName = NULL;
if (fname && *fname) {
- if (asprintf(&logFileName, fname, display) == -1)
- FatalError("Cannot allocate space for the log file name\n");
-
- if (backup && *backup) {
- struct stat buf;
-
- if (!stat(logFileName, &buf) && S_ISREG(buf.st_mode)) {
- char *suffix;
- char *oldLog;
-
- if ((asprintf(&suffix, backup, display) == -1) ||
- (asprintf(&oldLog, "%s%s", logFileName, suffix) == -1))
- FatalError("Cannot allocate space for the log file name\n");
- free(suffix);
- if (rename(logFileName, oldLog) == -1) {
- FatalError("Cannot move old log file \"%s\" to \"%s\"\n",
- logFileName, oldLog);
- }
- free(oldLog);
- }
- }
- if ((logFile = fopen(logFileName, "w")) == NULL)
- FatalError("Cannot open log file \"%s\"\n", logFileName);
- setvbuf(logFile, NULL, _IONBF, 0);
-
- /* Flush saved log information. */
- if (saveBuffer && bufferSize > 0) {
- fwrite(saveBuffer, bufferPos, 1, logFile);
- fflush(logFile);
+ if (asprintf(&logFileName, fname, display) == -1)
+ FatalError("Cannot allocate space for the log file name\n");
+
+ if (backup && *backup) {
+ struct stat buf;
+
+ if (!stat(logFileName, &buf) && S_ISREG(buf.st_mode)) {
+ char *suffix;
+ char *oldLog;
+
+ if ((asprintf(&suffix, backup, display) == -1) ||
+ (asprintf(&oldLog, "%s%s", logFileName, suffix) == -1))
+ FatalError("Cannot allocate space for the log file name\n");
+ free(suffix);
+ if (rename(logFileName, oldLog) == -1) {
+ FatalError("Cannot move old log file \"%s\" to \"%s\"\n",
+ logFileName, oldLog);
+ }
+ free(oldLog);
+ }
+ }
+ if ((logFile = fopen(logFileName, "w")) == NULL)
+ FatalError("Cannot open log file \"%s\"\n", logFileName);
+ setvbuf(logFile, NULL, _IONBF, 0);
+
+ /* Flush saved log information. */
+ if (saveBuffer && bufferSize > 0) {
+ fwrite(saveBuffer, bufferPos, 1, logFile);
+ fflush(logFile);
#ifndef WIN32
- fsync(fileno(logFile));
+ fsync(fileno(logFile));
#endif
- }
+ }
}
/*
@@ -223,9 +226,9 @@ LogInit(const char *fname, const char *backup)
* needed.
*/
if (saveBuffer && bufferSize > 0) {
- free(saveBuffer); /* Must be free(), not free() */
- saveBuffer = NULL;
- bufferSize = 0;
+ free(saveBuffer); /* Must be free(), not free() */
+ saveBuffer = NULL;
+ bufferSize = 0;
}
needBuffer = FALSE;
@@ -236,10 +239,10 @@ void
LogClose(enum ExitCode error)
{
if (logFile) {
- ErrorF("Server terminated %s (%d). Closing log file.\n",
- (error == EXIT_NO_ERROR) ? "successfully" : "with error", error);
- fclose(logFile);
- logFile = NULL;
+ ErrorF("Server terminated %s (%d). Closing log file.\n",
+ (error == EXIT_NO_ERROR) ? "successfully" : "with error", error);
+ fclose(logFile);
+ logFile = NULL;
}
}
@@ -248,19 +251,19 @@ LogSetParameter(LogParameter param, int value)
{
switch (param) {
case XLOG_FLUSH:
- logFlush = value ? TRUE : FALSE;
- return TRUE;
+ logFlush = value ? TRUE : FALSE;
+ return TRUE;
case XLOG_SYNC:
- logSync = value ? TRUE : FALSE;
- return TRUE;
+ logSync = value ? TRUE : FALSE;
+ return TRUE;
case XLOG_VERBOSITY:
- logVerbosity = value;
- return TRUE;
+ logVerbosity = value;
+ return TRUE;
case XLOG_FILE_VERBOSITY:
- logFileVerbosity = value;
- return TRUE;
+ logFileVerbosity = value;
+ return TRUE;
default:
- return FALSE;
+ return FALSE;
}
}
@@ -274,10 +277,10 @@ LogVWrite(int verb, const char *f, va_list args)
static Bool newline = TRUE;
if (newline) {
- sprintf(tmpBuffer, "[%10.3f] ", GetTimeInMillis() / 1000.0);
- len = strlen(tmpBuffer);
- if (logFile)
- fwrite(tmpBuffer, len, 1, logFile);
+ sprintf(tmpBuffer, "[%10.3f] ", GetTimeInMillis() / 1000.0);
+ len = strlen(tmpBuffer);
+ if (logFile)
+ fwrite(tmpBuffer, len, 1, logFile);
}
/*
@@ -286,34 +289,35 @@ LogVWrite(int verb, const char *f, va_list args)
* stream(s).
*/
if (verb < 0 || logFileVerbosity >= verb || logVerbosity >= verb) {
- vsnprintf(tmpBuffer, sizeof(tmpBuffer), f, args);
- len = strlen(tmpBuffer);
+ vsnprintf(tmpBuffer, sizeof(tmpBuffer), f, args);
+ len = strlen(tmpBuffer);
}
- newline = (tmpBuffer[len-1] == '\n');
+ newline = (tmpBuffer[len - 1] == '\n');
if ((verb < 0 || logVerbosity >= verb) && len > 0)
- fwrite(tmpBuffer, len, 1, stderr);
+ fwrite(tmpBuffer, len, 1, stderr);
if ((verb < 0 || logFileVerbosity >= verb) && len > 0) {
- if (logFile) {
- fwrite(tmpBuffer, len, 1, logFile);
- if (logFlush) {
- fflush(logFile);
+ if (logFile) {
+ fwrite(tmpBuffer, len, 1, logFile);
+ if (logFlush) {
+ fflush(logFile);
#ifndef WIN32
- if (logSync)
- fsync(fileno(logFile));
+ if (logSync)
+ fsync(fileno(logFile));
#endif
- }
- } else if (needBuffer) {
- if (len > bufferUnused) {
- bufferSize += 1024;
- bufferUnused += 1024;
- saveBuffer = realloc(saveBuffer, bufferSize);
- if (!saveBuffer)
- FatalError("realloc() failed while saving log messages\n");
- }
- bufferUnused -= len;
- memcpy(saveBuffer + bufferPos, tmpBuffer, len);
- bufferPos += len;
- }
+ }
+ }
+ else if (needBuffer) {
+ if (len > bufferUnused) {
+ bufferSize += 1024;
+ bufferUnused += 1024;
+ saveBuffer = realloc(saveBuffer, bufferSize);
+ if (!saveBuffer)
+ FatalError("realloc() failed while saving log messages\n");
+ }
+ bufferUnused -= len;
+ memcpy(saveBuffer + bufferPos, tmpBuffer, len);
+ bufferPos += len;
+ }
}
}
@@ -333,36 +337,38 @@ static const char *
LogMessageTypeVerbString(MessageType type, int verb)
{
if (type == X_ERROR)
- verb = 0;
+ verb = 0;
if (logVerbosity < verb && logFileVerbosity < verb)
- return NULL;
+ return NULL;
switch (type) {
case X_PROBED:
- return X_PROBE_STRING;
+ return X_PROBE_STRING;
case X_CONFIG:
- return X_CONFIG_STRING;
+ return X_CONFIG_STRING;
case X_DEFAULT:
- return X_DEFAULT_STRING;
+ return X_DEFAULT_STRING;
case X_CMDLINE:
- return X_CMDLINE_STRING;
+ return X_CMDLINE_STRING;
case X_NOTICE:
- return X_NOTICE_STRING;
+ return X_NOTICE_STRING;
case X_ERROR:
- return X_ERROR_STRING;
+ return X_ERROR_STRING;
case X_WARNING:
- return X_WARNING_STRING;
+ return X_WARNING_STRING;
case X_INFO:
- return X_INFO_STRING;
+ return X_INFO_STRING;
case X_NOT_IMPLEMENTED:
- return X_NOT_IMPLEMENTED_STRING;
+ return X_NOT_IMPLEMENTED_STRING;
case X_UNKNOWN:
- return X_UNKNOWN_STRING;
+ return X_UNKNOWN_STRING;
case X_NONE:
- return X_NONE_STRING;
+ return X_NONE_STRING;
+ case X_DEBUG:
+ return X_DEBUG_STRING;
default:
- return X_UNKNOWN_STRING;
+ return X_UNKNOWN_STRING;
}
}
@@ -375,7 +381,7 @@ LogVMessageVerb(MessageType type, int verb, const char *format, va_list args)
type_str = LogMessageTypeVerbString(type, verb);
if (!type_str)
- return;
+ return;
/* if type_str is not "", prepend it and ' ', to format */
if (type_str[0] == '\0')
@@ -410,10 +416,9 @@ LogMessage(MessageType type, const char *format, ...)
va_end(ap);
}
-
void
LogVHdrMessageVerb(MessageType type, int verb, const char *msg_format,
- va_list msg_args, const char *hdr_format, va_list hdr_args)
+ va_list msg_args, const char *hdr_format, va_list hdr_args)
{
const char *type_str;
char tmpFormat[1024];
@@ -423,29 +428,29 @@ LogVHdrMessageVerb(MessageType type, int verb, const char *msg_format,
type_str = LogMessageTypeVerbString(type, verb);
if (!type_str)
- return;
+ return;
/* if type_str != "", copy it and ' ' to tmpFormat; set p after ' ' */
p = tmpFormat;
if (type_str[0] != '\0')
- p += snprintf(tmpFormat, sizeof(tmpFormat), "%s ", type_str);
+ p += snprintf(tmpFormat, sizeof(tmpFormat), "%s ", type_str);
/* append as much of hdr as fits after type_str (if there was one) */
left = tmpFormat_end - p;
if (left > 1)
- p += vsnprintf(p, left, hdr_format, hdr_args);
+ p += vsnprintf(p, left, hdr_format, hdr_args);
/* append as much of msg_format as will fit after hdr */
left = tmpFormat_end - p;
if (left > 1)
- snprintf(p, left, "%s", msg_format);
+ snprintf(p, left, "%s", msg_format);
LogVWrite(verb, tmpFormat, msg_args);
}
void
LogHdrMessageVerb(MessageType type, int verb, const char *msg_format,
- va_list msg_args, const char *hdr_format, ...)
+ va_list msg_args, const char *hdr_format, ...)
{
va_list hdr_args;
@@ -456,7 +461,7 @@ LogHdrMessageVerb(MessageType type, int verb, const char *msg_format,
void
LogHdrMessage(MessageType type, const char *msg_format, va_list msg_args,
- const char *hdr_format, ...)
+ const char *hdr_format, ...)
{
va_list hdr_args;
@@ -466,7 +471,8 @@ LogHdrMessage(MessageType type, const char *msg_format, va_list msg_args,
}
void
-AbortServer(void) _X_NORETURN;
+AbortServer(void)
+ _X_NORETURN;
void
AbortServer(void)
@@ -480,13 +486,13 @@ AbortServer(void)
AbortDDX(EXIT_ERR_ABORT);
fflush(stderr);
if (CoreDump)
- OsAbort();
- exit (1);
+ OsAbort();
+ exit(1);
}
#define AUDIT_PREFIX "AUDIT: %s: %ld: "
#ifndef AUDIT_TIMEOUT
-#define AUDIT_TIMEOUT ((CARD32)(120 * 1000)) /* 2 mn */
+#define AUDIT_TIMEOUT ((CARD32)(120 * 1000)) /* 2 mn */
#endif
static int nrepeat = 0;
@@ -497,10 +503,10 @@ void
FreeAuditTimer(void)
{
if (auditTimer != NULL) {
- /* Force output of pending messages */
- TimerForce(auditTimer);
- TimerFree(auditTimer);
- auditTimer = NULL;
+ /* Force output of pending messages */
+ TimerForce(auditTimer);
+ TimerFree(auditTimer);
+ auditTimer = NULL;
}
}
@@ -515,17 +521,17 @@ AuditPrefix(void)
time(&tm);
autime = ctime(&tm);
if ((s = strchr(autime, '\n')))
- *s = '\0';
+ *s = '\0';
len = strlen(AUDIT_PREFIX) + strlen(autime) + 10 + 1;
tmpBuf = malloc(len);
if (!tmpBuf)
- return NULL;
- snprintf(tmpBuf, len, AUDIT_PREFIX, autime, (unsigned long)getpid());
+ return NULL;
+ snprintf(tmpBuf, len, AUDIT_PREFIX, autime, (unsigned long) getpid());
return tmpBuf;
}
void
-AuditF(const char * f, ...)
+AuditF(const char *f, ...)
{
va_list args;
@@ -541,16 +547,17 @@ AuditFlush(OsTimerPtr timer, CARD32 now, pointer arg)
char *prefix;
if (nrepeat > 0) {
- prefix = AuditPrefix();
- ErrorF("%slast message repeated %d times\n",
- prefix != NULL ? prefix : "", nrepeat);
- nrepeat = 0;
- free(prefix);
- return AUDIT_TIMEOUT;
- } else {
- /* if the timer expires without anything to print, flush the message */
- oldlen = -1;
- return 0;
+ prefix = AuditPrefix();
+ ErrorF("%slast message repeated %d times\n",
+ prefix != NULL ? prefix : "", nrepeat);
+ nrepeat = 0;
+ free(prefix);
+ return AUDIT_TIMEOUT;
+ }
+ else {
+ /* if the timer expires without anything to print, flush the message */
+ oldlen = -1;
+ return 0;
}
}
@@ -566,17 +573,18 @@ VAuditF(const char *f, va_list args)
len = vsnprintf(buf, sizeof(buf), f, args);
if (len == oldlen && strcmp(buf, oldbuf) == 0) {
- /* Message already seen */
- nrepeat++;
- } else {
- /* new message */
- if (auditTimer != NULL)
- TimerForce(auditTimer);
- ErrorF("%s%s", prefix != NULL ? prefix : "", buf);
- strlcpy(oldbuf, buf, sizeof(oldbuf));
- oldlen = len;
- nrepeat = 0;
- auditTimer = TimerSet(auditTimer, 0, AUDIT_TIMEOUT, AuditFlush, NULL);
+ /* Message already seen */
+ nrepeat++;
+ }
+ else {
+ /* new message */
+ if (auditTimer != NULL)
+ TimerForce(auditTimer);
+ ErrorF("%s%s", prefix != NULL ? prefix : "", buf);
+ strlcpy(oldbuf, buf, sizeof(oldbuf));
+ oldlen = len;
+ nrepeat = 0;
+ auditTimer = TimerSet(auditTimer, 0, AUDIT_TIMEOUT, AuditFlush, NULL);
}
free(prefix);
}
@@ -588,16 +596,18 @@ FatalError(const char *f, ...)
static Bool beenhere = FALSE;
if (beenhere)
- ErrorF("\nFatalError re-entered, aborting\n");
+ ErrorF("\nFatalError re-entered, aborting\n");
else
- ErrorF("\nFatal server error:\n");
+ ErrorF("\nFatal server error:\n");
va_start(args, f);
#ifdef __APPLE__
{
va_list args2;
+
va_copy(args2, args);
- (void)vsnprintf(__crashreporter_info_buff__, sizeof(__crashreporter_info_buff__), f, args2);
+ (void) vsnprintf(__crashreporter_info_buff__,
+ sizeof(__crashreporter_info_buff__), f, args2);
va_end(args2);
}
#endif
@@ -605,30 +615,30 @@ FatalError(const char *f, ...)
va_end(args);
ErrorF("\n");
if (!beenhere)
- OsVendorFatalError();
+ OsVendorFatalError();
if (!beenhere) {
- beenhere = TRUE;
- AbortServer();
- } else
- OsAbort();
- /*NOTREACHED*/
-}
+ beenhere = TRUE;
+ AbortServer();
+ }
+ else
+ OsAbort();
+ /*NOTREACHED*/}
void
VErrorF(const char *f, va_list args)
{
#ifdef DDXOSVERRORF
if (OsVendorVErrorFProc)
- OsVendorVErrorFProc(f, args);
+ OsVendorVErrorFProc(f, args);
else
- LogVWrite(-1, f, args);
+ LogVWrite(-1, f, args);
#else
LogVWrite(-1, f, args);
#endif
}
void
-ErrorF(const char * f, ...)
+ErrorF(const char *f, ...)
{
va_list args;
@@ -653,4 +663,3 @@ LogPrintMarkers(void)
LogMessageVerb(X_NOT_IMPLEMENTED, 0, "not implemented, ");
LogMessageVerb(X_UNKNOWN, 0, "unknown.\n");
}
-
diff --git a/xorg-server/os/mitauth.c b/xorg-server/os/mitauth.c
index 477736ee8..768a52a22 100644
--- a/xorg-server/os/mitauth.c
+++ b/xorg-server/os/mitauth.c
@@ -41,27 +41,24 @@ from The Open Group.
#include "dixstruct.h"
static struct auth {
- struct auth *next;
- unsigned short len;
- char *data;
- XID id;
+ struct auth *next;
+ unsigned short len;
+ char *data;
+ XID id;
} *mit_auth;
int
-MitAddCookie (
- unsigned short data_length,
- const char *data,
- XID id)
+MitAddCookie(unsigned short data_length, const char *data, XID id)
{
- struct auth *new;
+ struct auth *new;
- new = malloc(sizeof (struct auth));
+ new = malloc(sizeof(struct auth));
if (!new)
- return 0;
+ return 0;
new->data = malloc((unsigned) data_length);
if (!new->data) {
- free(new);
- return 0;
+ free(new);
+ return 0;
}
new->next = mit_auth;
mit_auth = new;
@@ -72,126 +69,110 @@ MitAddCookie (
}
XID
-MitCheckCookie (
- unsigned short data_length,
- const char *data,
- ClientPtr client,
- const char **reason)
+MitCheckCookie(unsigned short data_length,
+ const char *data, ClientPtr client, const char **reason)
{
- struct auth *auth;
+ struct auth *auth;
- for (auth = mit_auth; auth; auth=auth->next) {
+ for (auth = mit_auth; auth; auth = auth->next) {
if (data_length == auth->len &&
- memcmp (data, auth->data, (int) data_length) == 0)
- return auth->id;
+ memcmp(data, auth->data, (int) data_length) == 0)
+ return auth->id;
}
*reason = "Invalid MIT-MAGIC-COOKIE-1 key";
return (XID) -1;
}
int
-MitResetCookie (void)
+MitResetCookie(void)
{
- struct auth *auth, *next;
+ struct auth *auth, *next;
- for (auth = mit_auth; auth; auth=next) {
- next = auth->next;
- free(auth->data);
- free(auth);
+ for (auth = mit_auth; auth; auth = next) {
+ next = auth->next;
+ free(auth->data);
+ free(auth);
}
mit_auth = 0;
return 0;
}
XID
-MitToID (
- unsigned short data_length,
- char *data)
+MitToID(unsigned short data_length, char *data)
{
- struct auth *auth;
+ struct auth *auth;
- for (auth = mit_auth; auth; auth=auth->next) {
- if (data_length == auth->len &&
- memcmp (data, auth->data, data_length) == 0)
- return auth->id;
+ for (auth = mit_auth; auth; auth = auth->next) {
+ if (data_length == auth->len &&
+ memcmp(data, auth->data, data_length) == 0)
+ return auth->id;
}
return (XID) -1;
}
int
-MitFromID (
- XID id,
- unsigned short *data_lenp,
- char **datap)
+MitFromID(XID id, unsigned short *data_lenp, char **datap)
{
- struct auth *auth;
-
- for (auth = mit_auth; auth; auth=auth->next) {
- if (id == auth->id) {
- *data_lenp = auth->len;
- *datap = auth->data;
- return 1;
- }
+ struct auth *auth;
+
+ for (auth = mit_auth; auth; auth = auth->next) {
+ if (id == auth->id) {
+ *data_lenp = auth->len;
+ *datap = auth->data;
+ return 1;
+ }
}
return 0;
}
int
-MitRemoveCookie (
- unsigned short data_length,
- const char *data)
+MitRemoveCookie(unsigned short data_length, const char *data)
{
- struct auth *auth, *prev;
+ struct auth *auth, *prev;
prev = 0;
- for (auth = mit_auth; auth; prev = auth, auth=auth->next) {
- if (data_length == auth->len &&
- memcmp (data, auth->data, data_length) == 0)
- {
- if (prev)
- prev->next = auth->next;
- else
- mit_auth = auth->next;
- free(auth->data);
- free(auth);
- return 1;
- }
+ for (auth = mit_auth; auth; prev = auth, auth = auth->next) {
+ if (data_length == auth->len &&
+ memcmp(data, auth->data, data_length) == 0) {
+ if (prev)
+ prev->next = auth->next;
+ else
+ mit_auth = auth->next;
+ free(auth->data);
+ free(auth);
+ return 1;
+ }
}
return 0;
}
#ifdef XCSECURITY
-static char cookie[16]; /* 128 bits */
+static char cookie[16]; /* 128 bits */
XID
-MitGenerateCookie (
- unsigned data_length,
- const char *data,
- XID id,
- unsigned *data_length_return,
- char **data_return)
+MitGenerateCookie(unsigned data_length,
+ const char *data,
+ XID id, unsigned *data_length_return, char **data_return)
{
int i = 0;
int status;
- while (data_length--)
- {
- cookie[i++] += *data++;
- if (i >= sizeof (cookie)) i = 0;
+ while (data_length--) {
+ cookie[i++] += *data++;
+ if (i >= sizeof(cookie))
+ i = 0;
}
- GenerateRandomData(sizeof (cookie), cookie);
- status = MitAddCookie(sizeof (cookie), cookie, id);
- if (!status)
- {
- id = -1;
+ GenerateRandomData(sizeof(cookie), cookie);
+ status = MitAddCookie(sizeof(cookie), cookie, id);
+ if (!status) {
+ id = -1;
}
- else
- {
- *data_return = cookie;
- *data_length_return = sizeof (cookie);
+ else {
+ *data_return = cookie;
+ *data_length_return = sizeof(cookie);
}
return id;
}
-#endif /* XCSECURITY */
+#endif /* XCSECURITY */
diff --git a/xorg-server/os/oscolor.c b/xorg-server/os/oscolor.c
index 7f6b93880..a7573d28b 100644
--- a/xorg-server/os/oscolor.c
+++ b/xorg-server/os/oscolor.c
@@ -22,7 +22,6 @@ Except as contained in this notice, the name of The Open Group shall 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 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
@@ -53,1554 +52,1547 @@ SOFTWARE.
#include "os.h"
typedef struct _builtinColor {
- unsigned char red;
- unsigned char green;
- unsigned char blue;
- unsigned short name;
+ unsigned char red;
+ unsigned char green;
+ unsigned char blue;
+ unsigned short name;
} BuiltinColor;
static const char BuiltinColorNames[] = {
"alice blue\0"
- "AliceBlue\0"
- "antique white\0"
- "AntiqueWhite\0"
- "AntiqueWhite1\0"
- "AntiqueWhite2\0"
- "AntiqueWhite3\0"
- "AntiqueWhite4\0"
- "aquamarine\0"
- "aquamarine1\0"
- "aquamarine2\0"
- "aquamarine3\0"
- "aquamarine4\0"
- "azure\0"
- "azure1\0"
- "azure2\0"
- "azure3\0"
- "azure4\0"
- "beige\0"
- "bisque\0"
- "bisque1\0"
- "bisque2\0"
- "bisque3\0"
- "bisque4\0"
- "black\0"
- "blanched almond\0"
- "BlanchedAlmond\0"
- "blue\0"
- "blue violet\0"
- "blue1\0"
- "blue2\0"
- "blue3\0"
- "blue4\0"
- "BlueViolet\0"
- "brown\0"
- "brown1\0"
- "brown2\0"
- "brown3\0"
- "brown4\0"
- "burlywood\0"
- "burlywood1\0"
- "burlywood2\0"
- "burlywood3\0"
- "burlywood4\0"
- "cadet blue\0"
- "CadetBlue\0"
- "CadetBlue1\0"
- "CadetBlue2\0"
- "CadetBlue3\0"
- "CadetBlue4\0"
- "chartreuse\0"
- "chartreuse1\0"
- "chartreuse2\0"
- "chartreuse3\0"
- "chartreuse4\0"
- "chocolate\0"
- "chocolate1\0"
- "chocolate2\0"
- "chocolate3\0"
- "chocolate4\0"
- "coral\0"
- "coral1\0"
- "coral2\0"
- "coral3\0"
- "coral4\0"
- "cornflower blue\0"
- "CornflowerBlue\0"
- "cornsilk\0"
- "cornsilk1\0"
- "cornsilk2\0"
- "cornsilk3\0"
- "cornsilk4\0"
- "cyan\0"
- "cyan1\0"
- "cyan2\0"
- "cyan3\0"
- "cyan4\0"
- "dark blue\0"
- "dark cyan\0"
- "dark goldenrod\0"
- "dark gray\0"
- "dark green\0"
- "dark grey\0"
- "dark khaki\0"
- "dark magenta\0"
- "dark olive green\0"
- "dark orange\0"
- "dark orchid\0"
- "dark red\0"
- "dark salmon\0"
- "dark sea green\0"
- "dark slate blue\0"
- "dark slate gray\0"
- "dark slate grey\0"
- "dark turquoise\0"
- "dark violet\0"
- "DarkBlue\0"
- "DarkCyan\0"
- "DarkGoldenrod\0"
- "DarkGoldenrod1\0"
- "DarkGoldenrod2\0"
- "DarkGoldenrod3\0"
- "DarkGoldenrod4\0"
- "DarkGray\0"
- "DarkGreen\0"
- "DarkGrey\0"
- "DarkKhaki\0"
- "DarkMagenta\0"
- "DarkOliveGreen\0"
- "DarkOliveGreen1\0"
- "DarkOliveGreen2\0"
- "DarkOliveGreen3\0"
- "DarkOliveGreen4\0"
- "DarkOrange\0"
- "DarkOrange1\0"
- "DarkOrange2\0"
- "DarkOrange3\0"
- "DarkOrange4\0"
- "DarkOrchid\0"
- "DarkOrchid1\0"
- "DarkOrchid2\0"
- "DarkOrchid3\0"
- "DarkOrchid4\0"
- "DarkRed\0"
- "DarkSalmon\0"
- "DarkSeaGreen\0"
- "DarkSeaGreen1\0"
- "DarkSeaGreen2\0"
- "DarkSeaGreen3\0"
- "DarkSeaGreen4\0"
- "DarkSlateBlue\0"
- "DarkSlateGray\0"
- "DarkSlateGray1\0"
- "DarkSlateGray2\0"
- "DarkSlateGray3\0"
- "DarkSlateGray4\0"
- "DarkSlateGrey\0"
- "DarkTurquoise\0"
- "DarkViolet\0"
- "deep pink\0"
- "deep sky blue\0"
- "DeepPink\0"
- "DeepPink1\0"
- "DeepPink2\0"
- "DeepPink3\0"
- "DeepPink4\0"
- "DeepSkyBlue\0"
- "DeepSkyBlue1\0"
- "DeepSkyBlue2\0"
- "DeepSkyBlue3\0"
- "DeepSkyBlue4\0"
- "dim gray\0"
- "dim grey\0"
- "DimGray\0"
- "DimGrey\0"
- "dodger blue\0"
- "DodgerBlue\0"
- "DodgerBlue1\0"
- "DodgerBlue2\0"
- "DodgerBlue3\0"
- "DodgerBlue4\0"
- "firebrick\0"
- "firebrick1\0"
- "firebrick2\0"
- "firebrick3\0"
- "firebrick4\0"
- "floral white\0"
- "FloralWhite\0"
- "forest green\0"
- "ForestGreen\0"
- "gainsboro\0"
- "ghost white\0"
- "GhostWhite\0"
- "gold\0"
- "gold1\0"
- "gold2\0"
- "gold3\0"
- "gold4\0"
- "goldenrod\0"
- "goldenrod1\0"
- "goldenrod2\0"
- "goldenrod3\0"
- "goldenrod4\0"
- "gray\0"
- "gray0\0"
- "gray1\0"
- "gray10\0"
- "gray100\0"
- "gray11\0"
- "gray12\0"
- "gray13\0"
- "gray14\0"
- "gray15\0"
- "gray16\0"
- "gray17\0"
- "gray18\0"
- "gray19\0"
- "gray2\0"
- "gray20\0"
- "gray21\0"
- "gray22\0"
- "gray23\0"
- "gray24\0"
- "gray25\0"
- "gray26\0"
- "gray27\0"
- "gray28\0"
- "gray29\0"
- "gray3\0"
- "gray30\0"
- "gray31\0"
- "gray32\0"
- "gray33\0"
- "gray34\0"
- "gray35\0"
- "gray36\0"
- "gray37\0"
- "gray38\0"
- "gray39\0"
- "gray4\0"
- "gray40\0"
- "gray41\0"
- "gray42\0"
- "gray43\0"
- "gray44\0"
- "gray45\0"
- "gray46\0"
- "gray47\0"
- "gray48\0"
- "gray49\0"
- "gray5\0"
- "gray50\0"
- "gray51\0"
- "gray52\0"
- "gray53\0"
- "gray54\0"
- "gray55\0"
- "gray56\0"
- "gray57\0"
- "gray58\0"
- "gray59\0"
- "gray6\0"
- "gray60\0"
- "gray61\0"
- "gray62\0"
- "gray63\0"
- "gray64\0"
- "gray65\0"
- "gray66\0"
- "gray67\0"
- "gray68\0"
- "gray69\0"
- "gray7\0"
- "gray70\0"
- "gray71\0"
- "gray72\0"
- "gray73\0"
- "gray74\0"
- "gray75\0"
- "gray76\0"
- "gray77\0"
- "gray78\0"
- "gray79\0"
- "gray8\0"
- "gray80\0"
- "gray81\0"
- "gray82\0"
- "gray83\0"
- "gray84\0"
- "gray85\0"
- "gray86\0"
- "gray87\0"
- "gray88\0"
- "gray89\0"
- "gray9\0"
- "gray90\0"
- "gray91\0"
- "gray92\0"
- "gray93\0"
- "gray94\0"
- "gray95\0"
- "gray96\0"
- "gray97\0"
- "gray98\0"
- "gray99\0"
- "green\0"
- "green yellow\0"
- "green1\0"
- "green2\0"
- "green3\0"
- "green4\0"
- "GreenYellow\0"
- "grey\0"
- "grey0\0"
- "grey1\0"
- "grey10\0"
- "grey100\0"
- "grey11\0"
- "grey12\0"
- "grey13\0"
- "grey14\0"
- "grey15\0"
- "grey16\0"
- "grey17\0"
- "grey18\0"
- "grey19\0"
- "grey2\0"
- "grey20\0"
- "grey21\0"
- "grey22\0"
- "grey23\0"
- "grey24\0"
- "grey25\0"
- "grey26\0"
- "grey27\0"
- "grey28\0"
- "grey29\0"
- "grey3\0"
- "grey30\0"
- "grey31\0"
- "grey32\0"
- "grey33\0"
- "grey34\0"
- "grey35\0"
- "grey36\0"
- "grey37\0"
- "grey38\0"
- "grey39\0"
- "grey4\0"
- "grey40\0"
- "grey41\0"
- "grey42\0"
- "grey43\0"
- "grey44\0"
- "grey45\0"
- "grey46\0"
- "grey47\0"
- "grey48\0"
- "grey49\0"
- "grey5\0"
- "grey50\0"
- "grey51\0"
- "grey52\0"
- "grey53\0"
- "grey54\0"
- "grey55\0"
- "grey56\0"
- "grey57\0"
- "grey58\0"
- "grey59\0"
- "grey6\0"
- "grey60\0"
- "grey61\0"
- "grey62\0"
- "grey63\0"
- "grey64\0"
- "grey65\0"
- "grey66\0"
- "grey67\0"
- "grey68\0"
- "grey69\0"
- "grey7\0"
- "grey70\0"
- "grey71\0"
- "grey72\0"
- "grey73\0"
- "grey74\0"
- "grey75\0"
- "grey76\0"
- "grey77\0"
- "grey78\0"
- "grey79\0"
- "grey8\0"
- "grey80\0"
- "grey81\0"
- "grey82\0"
- "grey83\0"
- "grey84\0"
- "grey85\0"
- "grey86\0"
- "grey87\0"
- "grey88\0"
- "grey89\0"
- "grey9\0"
- "grey90\0"
- "grey91\0"
- "grey92\0"
- "grey93\0"
- "grey94\0"
- "grey95\0"
- "grey96\0"
- "grey97\0"
- "grey98\0"
- "grey99\0"
- "honeydew\0"
- "honeydew1\0"
- "honeydew2\0"
- "honeydew3\0"
- "honeydew4\0"
- "hot pink\0"
- "HotPink\0"
- "HotPink1\0"
- "HotPink2\0"
- "HotPink3\0"
- "HotPink4\0"
- "indian red\0"
- "IndianRed\0"
- "IndianRed1\0"
- "IndianRed2\0"
- "IndianRed3\0"
- "IndianRed4\0"
- "ivory\0"
- "ivory1\0"
- "ivory2\0"
- "ivory3\0"
- "ivory4\0"
- "khaki\0"
- "khaki1\0"
- "khaki2\0"
- "khaki3\0"
- "khaki4\0"
- "lavender\0"
- "lavender blush\0"
- "LavenderBlush\0"
- "LavenderBlush1\0"
- "LavenderBlush2\0"
- "LavenderBlush3\0"
- "LavenderBlush4\0"
- "lawn green\0"
- "LawnGreen\0"
- "lemon chiffon\0"
- "LemonChiffon\0"
- "LemonChiffon1\0"
- "LemonChiffon2\0"
- "LemonChiffon3\0"
- "LemonChiffon4\0"
- "light blue\0"
- "light coral\0"
- "light cyan\0"
- "light goldenrod\0"
- "light goldenrod yellow\0"
- "light gray\0"
- "light green\0"
- "light grey\0"
- "light pink\0"
- "light salmon\0"
- "light sea green\0"
- "light sky blue\0"
- "light slate blue\0"
- "light slate gray\0"
- "light slate grey\0"
- "light steel blue\0"
- "light yellow\0"
- "LightBlue\0"
- "LightBlue1\0"
- "LightBlue2\0"
- "LightBlue3\0"
- "LightBlue4\0"
- "LightCoral\0"
- "LightCyan\0"
- "LightCyan1\0"
- "LightCyan2\0"
- "LightCyan3\0"
- "LightCyan4\0"
- "LightGoldenrod\0"
- "LightGoldenrod1\0"
- "LightGoldenrod2\0"
- "LightGoldenrod3\0"
- "LightGoldenrod4\0"
- "LightGoldenrodYellow\0"
- "LightGray\0"
- "LightGreen\0"
- "LightGrey\0"
- "LightPink\0"
- "LightPink1\0"
- "LightPink2\0"
- "LightPink3\0"
- "LightPink4\0"
- "LightSalmon\0"
- "LightSalmon1\0"
- "LightSalmon2\0"
- "LightSalmon3\0"
- "LightSalmon4\0"
- "LightSeaGreen\0"
- "LightSkyBlue\0"
- "LightSkyBlue1\0"
- "LightSkyBlue2\0"
- "LightSkyBlue3\0"
- "LightSkyBlue4\0"
- "LightSlateBlue\0"
- "LightSlateGray\0"
- "LightSlateGrey\0"
- "LightSteelBlue\0"
- "LightSteelBlue1\0"
- "LightSteelBlue2\0"
- "LightSteelBlue3\0"
- "LightSteelBlue4\0"
- "LightYellow\0"
- "LightYellow1\0"
- "LightYellow2\0"
- "LightYellow3\0"
- "LightYellow4\0"
- "lime green\0"
- "LimeGreen\0"
- "linen\0"
- "magenta\0"
- "magenta1\0"
- "magenta2\0"
- "magenta3\0"
- "magenta4\0"
- "maroon\0"
- "maroon1\0"
- "maroon2\0"
- "maroon3\0"
- "maroon4\0"
- "medium aquamarine\0"
- "medium blue\0"
- "medium orchid\0"
- "medium purple\0"
- "medium sea green\0"
- "medium slate blue\0"
- "medium spring green\0"
- "medium turquoise\0"
- "medium violet red\0"
- "MediumAquamarine\0"
- "MediumBlue\0"
- "MediumOrchid\0"
- "MediumOrchid1\0"
- "MediumOrchid2\0"
- "MediumOrchid3\0"
- "MediumOrchid4\0"
- "MediumPurple\0"
- "MediumPurple1\0"
- "MediumPurple2\0"
- "MediumPurple3\0"
- "MediumPurple4\0"
- "MediumSeaGreen\0"
- "MediumSlateBlue\0"
- "MediumSpringGreen\0"
- "MediumTurquoise\0"
- "MediumVioletRed\0"
- "midnight blue\0"
- "MidnightBlue\0"
- "mint cream\0"
- "MintCream\0"
- "misty rose\0"
- "MistyRose\0"
- "MistyRose1\0"
- "MistyRose2\0"
- "MistyRose3\0"
- "MistyRose4\0"
- "moccasin\0"
- "navajo white\0"
- "NavajoWhite\0"
- "NavajoWhite1\0"
- "NavajoWhite2\0"
- "NavajoWhite3\0"
- "NavajoWhite4\0"
- "navy\0"
- "navy blue\0"
- "NavyBlue\0"
- "old lace\0"
- "OldLace\0"
- "olive drab\0"
- "OliveDrab\0"
- "OliveDrab1\0"
- "OliveDrab2\0"
- "OliveDrab3\0"
- "OliveDrab4\0"
- "orange\0"
- "orange red\0"
- "orange1\0"
- "orange2\0"
- "orange3\0"
- "orange4\0"
- "OrangeRed\0"
- "OrangeRed1\0"
- "OrangeRed2\0"
- "OrangeRed3\0"
- "OrangeRed4\0"
- "orchid\0"
- "orchid1\0"
- "orchid2\0"
- "orchid3\0"
- "orchid4\0"
- "pale goldenrod\0"
- "pale green\0"
- "pale turquoise\0"
- "pale violet red\0"
- "PaleGoldenrod\0"
- "PaleGreen\0"
- "PaleGreen1\0"
- "PaleGreen2\0"
- "PaleGreen3\0"
- "PaleGreen4\0"
- "PaleTurquoise\0"
- "PaleTurquoise1\0"
- "PaleTurquoise2\0"
- "PaleTurquoise3\0"
- "PaleTurquoise4\0"
- "PaleVioletRed\0"
- "PaleVioletRed1\0"
- "PaleVioletRed2\0"
- "PaleVioletRed3\0"
- "PaleVioletRed4\0"
- "papaya whip\0"
- "PapayaWhip\0"
- "peach puff\0"
- "PeachPuff\0"
- "PeachPuff1\0"
- "PeachPuff2\0"
- "PeachPuff3\0"
- "PeachPuff4\0"
- "peru\0"
- "pink\0"
- "pink1\0"
- "pink2\0"
- "pink3\0"
- "pink4\0"
- "plum\0"
- "plum1\0"
- "plum2\0"
- "plum3\0"
- "plum4\0"
- "powder blue\0"
- "PowderBlue\0"
- "purple\0"
- "purple1\0"
- "purple2\0"
- "purple3\0"
- "purple4\0"
- "red\0"
- "red1\0"
- "red2\0"
- "red3\0"
- "red4\0"
- "rosy brown\0"
- "RosyBrown\0"
- "RosyBrown1\0"
- "RosyBrown2\0"
- "RosyBrown3\0"
- "RosyBrown4\0"
- "royal blue\0"
- "RoyalBlue\0"
- "RoyalBlue1\0"
- "RoyalBlue2\0"
- "RoyalBlue3\0"
- "RoyalBlue4\0"
- "saddle brown\0"
- "SaddleBrown\0"
- "salmon\0"
- "salmon1\0"
- "salmon2\0"
- "salmon3\0"
- "salmon4\0"
- "sandy brown\0"
- "SandyBrown\0"
- "sea green\0"
- "SeaGreen\0"
- "SeaGreen1\0"
- "SeaGreen2\0"
- "SeaGreen3\0"
- "SeaGreen4\0"
- "seashell\0"
- "seashell1\0"
- "seashell2\0"
- "seashell3\0"
- "seashell4\0"
- "sienna\0"
- "sienna1\0"
- "sienna2\0"
- "sienna3\0"
- "sienna4\0"
- "sky blue\0"
- "SkyBlue\0"
- "SkyBlue1\0"
- "SkyBlue2\0"
- "SkyBlue3\0"
- "SkyBlue4\0"
- "slate blue\0"
- "slate gray\0"
- "slate grey\0"
- "SlateBlue\0"
- "SlateBlue1\0"
- "SlateBlue2\0"
- "SlateBlue3\0"
- "SlateBlue4\0"
- "SlateGray\0"
- "SlateGray1\0"
- "SlateGray2\0"
- "SlateGray3\0"
- "SlateGray4\0"
- "SlateGrey\0"
- "snow\0"
- "snow1\0"
- "snow2\0"
- "snow3\0"
- "snow4\0"
- "spring green\0"
- "SpringGreen\0"
- "SpringGreen1\0"
- "SpringGreen2\0"
- "SpringGreen3\0"
- "SpringGreen4\0"
- "steel blue\0"
- "SteelBlue\0"
- "SteelBlue1\0"
- "SteelBlue2\0"
- "SteelBlue3\0"
- "SteelBlue4\0"
- "tan\0"
- "tan1\0"
- "tan2\0"
- "tan3\0"
- "tan4\0"
- "thistle\0"
- "thistle1\0"
- "thistle2\0"
- "thistle3\0"
- "thistle4\0"
- "tomato\0"
- "tomato1\0"
- "tomato2\0"
- "tomato3\0"
- "tomato4\0"
- "turquoise\0"
- "turquoise1\0"
- "turquoise2\0"
- "turquoise3\0"
- "turquoise4\0"
- "violet\0"
- "violet red\0"
- "VioletRed\0"
- "VioletRed1\0"
- "VioletRed2\0"
- "VioletRed3\0"
- "VioletRed4\0"
- "wheat\0"
- "wheat1\0"
- "wheat2\0"
- "wheat3\0"
- "wheat4\0"
- "white\0"
- "white smoke\0"
- "WhiteSmoke\0"
- "yellow\0"
- "yellow green\0"
- "yellow1\0"
- "yellow2\0"
- "yellow3\0"
- "yellow4\0"
- "YellowGreen\0"
+ "AliceBlue\0"
+ "antique white\0"
+ "AntiqueWhite\0"
+ "AntiqueWhite1\0"
+ "AntiqueWhite2\0"
+ "AntiqueWhite3\0"
+ "AntiqueWhite4\0"
+ "aquamarine\0"
+ "aquamarine1\0"
+ "aquamarine2\0"
+ "aquamarine3\0"
+ "aquamarine4\0"
+ "azure\0"
+ "azure1\0"
+ "azure2\0"
+ "azure3\0"
+ "azure4\0"
+ "beige\0"
+ "bisque\0"
+ "bisque1\0"
+ "bisque2\0"
+ "bisque3\0"
+ "bisque4\0"
+ "black\0"
+ "blanched almond\0"
+ "BlanchedAlmond\0"
+ "blue\0"
+ "blue violet\0"
+ "blue1\0"
+ "blue2\0"
+ "blue3\0"
+ "blue4\0"
+ "BlueViolet\0"
+ "brown\0"
+ "brown1\0"
+ "brown2\0"
+ "brown3\0"
+ "brown4\0"
+ "burlywood\0"
+ "burlywood1\0"
+ "burlywood2\0"
+ "burlywood3\0"
+ "burlywood4\0"
+ "cadet blue\0"
+ "CadetBlue\0"
+ "CadetBlue1\0"
+ "CadetBlue2\0"
+ "CadetBlue3\0"
+ "CadetBlue4\0"
+ "chartreuse\0"
+ "chartreuse1\0"
+ "chartreuse2\0"
+ "chartreuse3\0"
+ "chartreuse4\0"
+ "chocolate\0"
+ "chocolate1\0"
+ "chocolate2\0"
+ "chocolate3\0"
+ "chocolate4\0"
+ "coral\0"
+ "coral1\0"
+ "coral2\0"
+ "coral3\0"
+ "coral4\0"
+ "cornflower blue\0"
+ "CornflowerBlue\0"
+ "cornsilk\0"
+ "cornsilk1\0"
+ "cornsilk2\0"
+ "cornsilk3\0"
+ "cornsilk4\0"
+ "cyan\0"
+ "cyan1\0"
+ "cyan2\0"
+ "cyan3\0"
+ "cyan4\0"
+ "dark blue\0"
+ "dark cyan\0"
+ "dark goldenrod\0"
+ "dark gray\0"
+ "dark green\0"
+ "dark grey\0"
+ "dark khaki\0"
+ "dark magenta\0"
+ "dark olive green\0"
+ "dark orange\0"
+ "dark orchid\0"
+ "dark red\0"
+ "dark salmon\0"
+ "dark sea green\0"
+ "dark slate blue\0"
+ "dark slate gray\0"
+ "dark slate grey\0"
+ "dark turquoise\0"
+ "dark violet\0"
+ "DarkBlue\0"
+ "DarkCyan\0"
+ "DarkGoldenrod\0"
+ "DarkGoldenrod1\0"
+ "DarkGoldenrod2\0"
+ "DarkGoldenrod3\0"
+ "DarkGoldenrod4\0"
+ "DarkGray\0"
+ "DarkGreen\0"
+ "DarkGrey\0"
+ "DarkKhaki\0"
+ "DarkMagenta\0"
+ "DarkOliveGreen\0"
+ "DarkOliveGreen1\0"
+ "DarkOliveGreen2\0"
+ "DarkOliveGreen3\0"
+ "DarkOliveGreen4\0"
+ "DarkOrange\0"
+ "DarkOrange1\0"
+ "DarkOrange2\0"
+ "DarkOrange3\0"
+ "DarkOrange4\0"
+ "DarkOrchid\0"
+ "DarkOrchid1\0"
+ "DarkOrchid2\0"
+ "DarkOrchid3\0"
+ "DarkOrchid4\0"
+ "DarkRed\0"
+ "DarkSalmon\0"
+ "DarkSeaGreen\0"
+ "DarkSeaGreen1\0"
+ "DarkSeaGreen2\0"
+ "DarkSeaGreen3\0"
+ "DarkSeaGreen4\0"
+ "DarkSlateBlue\0"
+ "DarkSlateGray\0"
+ "DarkSlateGray1\0"
+ "DarkSlateGray2\0"
+ "DarkSlateGray3\0"
+ "DarkSlateGray4\0"
+ "DarkSlateGrey\0"
+ "DarkTurquoise\0"
+ "DarkViolet\0"
+ "deep pink\0"
+ "deep sky blue\0"
+ "DeepPink\0"
+ "DeepPink1\0"
+ "DeepPink2\0"
+ "DeepPink3\0"
+ "DeepPink4\0"
+ "DeepSkyBlue\0"
+ "DeepSkyBlue1\0"
+ "DeepSkyBlue2\0"
+ "DeepSkyBlue3\0"
+ "DeepSkyBlue4\0"
+ "dim gray\0"
+ "dim grey\0"
+ "DimGray\0"
+ "DimGrey\0"
+ "dodger blue\0"
+ "DodgerBlue\0"
+ "DodgerBlue1\0"
+ "DodgerBlue2\0"
+ "DodgerBlue3\0"
+ "DodgerBlue4\0"
+ "firebrick\0"
+ "firebrick1\0"
+ "firebrick2\0"
+ "firebrick3\0"
+ "firebrick4\0"
+ "floral white\0"
+ "FloralWhite\0"
+ "forest green\0"
+ "ForestGreen\0"
+ "gainsboro\0"
+ "ghost white\0"
+ "GhostWhite\0"
+ "gold\0"
+ "gold1\0"
+ "gold2\0"
+ "gold3\0"
+ "gold4\0"
+ "goldenrod\0"
+ "goldenrod1\0"
+ "goldenrod2\0"
+ "goldenrod3\0"
+ "goldenrod4\0"
+ "gray\0"
+ "gray0\0"
+ "gray1\0"
+ "gray10\0"
+ "gray100\0"
+ "gray11\0"
+ "gray12\0"
+ "gray13\0"
+ "gray14\0"
+ "gray15\0"
+ "gray16\0"
+ "gray17\0"
+ "gray18\0"
+ "gray19\0"
+ "gray2\0"
+ "gray20\0"
+ "gray21\0"
+ "gray22\0"
+ "gray23\0"
+ "gray24\0"
+ "gray25\0"
+ "gray26\0"
+ "gray27\0"
+ "gray28\0"
+ "gray29\0"
+ "gray3\0"
+ "gray30\0"
+ "gray31\0"
+ "gray32\0"
+ "gray33\0"
+ "gray34\0"
+ "gray35\0"
+ "gray36\0"
+ "gray37\0"
+ "gray38\0"
+ "gray39\0"
+ "gray4\0"
+ "gray40\0"
+ "gray41\0"
+ "gray42\0"
+ "gray43\0"
+ "gray44\0"
+ "gray45\0"
+ "gray46\0"
+ "gray47\0"
+ "gray48\0"
+ "gray49\0"
+ "gray5\0"
+ "gray50\0"
+ "gray51\0"
+ "gray52\0"
+ "gray53\0"
+ "gray54\0"
+ "gray55\0"
+ "gray56\0"
+ "gray57\0"
+ "gray58\0"
+ "gray59\0"
+ "gray6\0"
+ "gray60\0"
+ "gray61\0"
+ "gray62\0"
+ "gray63\0"
+ "gray64\0"
+ "gray65\0"
+ "gray66\0"
+ "gray67\0"
+ "gray68\0"
+ "gray69\0"
+ "gray7\0"
+ "gray70\0"
+ "gray71\0"
+ "gray72\0"
+ "gray73\0"
+ "gray74\0"
+ "gray75\0"
+ "gray76\0"
+ "gray77\0"
+ "gray78\0"
+ "gray79\0"
+ "gray8\0"
+ "gray80\0"
+ "gray81\0"
+ "gray82\0"
+ "gray83\0"
+ "gray84\0"
+ "gray85\0"
+ "gray86\0"
+ "gray87\0"
+ "gray88\0"
+ "gray89\0"
+ "gray9\0"
+ "gray90\0"
+ "gray91\0"
+ "gray92\0"
+ "gray93\0"
+ "gray94\0"
+ "gray95\0"
+ "gray96\0"
+ "gray97\0"
+ "gray98\0"
+ "gray99\0"
+ "green\0"
+ "green yellow\0"
+ "green1\0"
+ "green2\0"
+ "green3\0"
+ "green4\0"
+ "GreenYellow\0"
+ "grey\0"
+ "grey0\0"
+ "grey1\0"
+ "grey10\0"
+ "grey100\0"
+ "grey11\0"
+ "grey12\0"
+ "grey13\0"
+ "grey14\0"
+ "grey15\0"
+ "grey16\0"
+ "grey17\0"
+ "grey18\0"
+ "grey19\0"
+ "grey2\0"
+ "grey20\0"
+ "grey21\0"
+ "grey22\0"
+ "grey23\0"
+ "grey24\0"
+ "grey25\0"
+ "grey26\0"
+ "grey27\0"
+ "grey28\0"
+ "grey29\0"
+ "grey3\0"
+ "grey30\0"
+ "grey31\0"
+ "grey32\0"
+ "grey33\0"
+ "grey34\0"
+ "grey35\0"
+ "grey36\0"
+ "grey37\0"
+ "grey38\0"
+ "grey39\0"
+ "grey4\0"
+ "grey40\0"
+ "grey41\0"
+ "grey42\0"
+ "grey43\0"
+ "grey44\0"
+ "grey45\0"
+ "grey46\0"
+ "grey47\0"
+ "grey48\0"
+ "grey49\0"
+ "grey5\0"
+ "grey50\0"
+ "grey51\0"
+ "grey52\0"
+ "grey53\0"
+ "grey54\0"
+ "grey55\0"
+ "grey56\0"
+ "grey57\0"
+ "grey58\0"
+ "grey59\0"
+ "grey6\0"
+ "grey60\0"
+ "grey61\0"
+ "grey62\0"
+ "grey63\0"
+ "grey64\0"
+ "grey65\0"
+ "grey66\0"
+ "grey67\0"
+ "grey68\0"
+ "grey69\0"
+ "grey7\0"
+ "grey70\0"
+ "grey71\0"
+ "grey72\0"
+ "grey73\0"
+ "grey74\0"
+ "grey75\0"
+ "grey76\0"
+ "grey77\0"
+ "grey78\0"
+ "grey79\0"
+ "grey8\0"
+ "grey80\0"
+ "grey81\0"
+ "grey82\0"
+ "grey83\0"
+ "grey84\0"
+ "grey85\0"
+ "grey86\0"
+ "grey87\0"
+ "grey88\0"
+ "grey89\0"
+ "grey9\0"
+ "grey90\0"
+ "grey91\0"
+ "grey92\0"
+ "grey93\0"
+ "grey94\0"
+ "grey95\0"
+ "grey96\0"
+ "grey97\0"
+ "grey98\0"
+ "grey99\0"
+ "honeydew\0"
+ "honeydew1\0"
+ "honeydew2\0"
+ "honeydew3\0"
+ "honeydew4\0"
+ "hot pink\0"
+ "HotPink\0"
+ "HotPink1\0"
+ "HotPink2\0"
+ "HotPink3\0"
+ "HotPink4\0"
+ "indian red\0"
+ "IndianRed\0"
+ "IndianRed1\0"
+ "IndianRed2\0"
+ "IndianRed3\0"
+ "IndianRed4\0"
+ "ivory\0"
+ "ivory1\0"
+ "ivory2\0"
+ "ivory3\0"
+ "ivory4\0"
+ "khaki\0"
+ "khaki1\0"
+ "khaki2\0"
+ "khaki3\0"
+ "khaki4\0"
+ "lavender\0"
+ "lavender blush\0"
+ "LavenderBlush\0"
+ "LavenderBlush1\0"
+ "LavenderBlush2\0"
+ "LavenderBlush3\0"
+ "LavenderBlush4\0"
+ "lawn green\0"
+ "LawnGreen\0"
+ "lemon chiffon\0"
+ "LemonChiffon\0"
+ "LemonChiffon1\0"
+ "LemonChiffon2\0"
+ "LemonChiffon3\0"
+ "LemonChiffon4\0"
+ "light blue\0"
+ "light coral\0"
+ "light cyan\0"
+ "light goldenrod\0"
+ "light goldenrod yellow\0"
+ "light gray\0"
+ "light green\0"
+ "light grey\0"
+ "light pink\0"
+ "light salmon\0"
+ "light sea green\0"
+ "light sky blue\0"
+ "light slate blue\0"
+ "light slate gray\0"
+ "light slate grey\0"
+ "light steel blue\0"
+ "light yellow\0"
+ "LightBlue\0"
+ "LightBlue1\0"
+ "LightBlue2\0"
+ "LightBlue3\0"
+ "LightBlue4\0"
+ "LightCoral\0"
+ "LightCyan\0"
+ "LightCyan1\0"
+ "LightCyan2\0"
+ "LightCyan3\0"
+ "LightCyan4\0"
+ "LightGoldenrod\0"
+ "LightGoldenrod1\0"
+ "LightGoldenrod2\0"
+ "LightGoldenrod3\0"
+ "LightGoldenrod4\0"
+ "LightGoldenrodYellow\0"
+ "LightGray\0"
+ "LightGreen\0"
+ "LightGrey\0"
+ "LightPink\0"
+ "LightPink1\0"
+ "LightPink2\0"
+ "LightPink3\0"
+ "LightPink4\0"
+ "LightSalmon\0"
+ "LightSalmon1\0"
+ "LightSalmon2\0"
+ "LightSalmon3\0"
+ "LightSalmon4\0"
+ "LightSeaGreen\0"
+ "LightSkyBlue\0"
+ "LightSkyBlue1\0"
+ "LightSkyBlue2\0"
+ "LightSkyBlue3\0"
+ "LightSkyBlue4\0"
+ "LightSlateBlue\0"
+ "LightSlateGray\0"
+ "LightSlateGrey\0"
+ "LightSteelBlue\0"
+ "LightSteelBlue1\0"
+ "LightSteelBlue2\0"
+ "LightSteelBlue3\0"
+ "LightSteelBlue4\0"
+ "LightYellow\0"
+ "LightYellow1\0"
+ "LightYellow2\0"
+ "LightYellow3\0"
+ "LightYellow4\0"
+ "lime green\0"
+ "LimeGreen\0"
+ "linen\0"
+ "magenta\0"
+ "magenta1\0"
+ "magenta2\0"
+ "magenta3\0"
+ "magenta4\0"
+ "maroon\0"
+ "maroon1\0"
+ "maroon2\0"
+ "maroon3\0"
+ "maroon4\0"
+ "medium aquamarine\0"
+ "medium blue\0"
+ "medium orchid\0"
+ "medium purple\0"
+ "medium sea green\0"
+ "medium slate blue\0"
+ "medium spring green\0"
+ "medium turquoise\0"
+ "medium violet red\0"
+ "MediumAquamarine\0"
+ "MediumBlue\0"
+ "MediumOrchid\0"
+ "MediumOrchid1\0"
+ "MediumOrchid2\0"
+ "MediumOrchid3\0"
+ "MediumOrchid4\0"
+ "MediumPurple\0"
+ "MediumPurple1\0"
+ "MediumPurple2\0"
+ "MediumPurple3\0"
+ "MediumPurple4\0"
+ "MediumSeaGreen\0"
+ "MediumSlateBlue\0"
+ "MediumSpringGreen\0"
+ "MediumTurquoise\0"
+ "MediumVioletRed\0"
+ "midnight blue\0"
+ "MidnightBlue\0"
+ "mint cream\0"
+ "MintCream\0"
+ "misty rose\0"
+ "MistyRose\0"
+ "MistyRose1\0"
+ "MistyRose2\0"
+ "MistyRose3\0"
+ "MistyRose4\0"
+ "moccasin\0"
+ "navajo white\0"
+ "NavajoWhite\0"
+ "NavajoWhite1\0"
+ "NavajoWhite2\0"
+ "NavajoWhite3\0"
+ "NavajoWhite4\0"
+ "navy\0"
+ "navy blue\0"
+ "NavyBlue\0"
+ "old lace\0"
+ "OldLace\0"
+ "olive drab\0"
+ "OliveDrab\0"
+ "OliveDrab1\0"
+ "OliveDrab2\0"
+ "OliveDrab3\0"
+ "OliveDrab4\0"
+ "orange\0"
+ "orange red\0"
+ "orange1\0"
+ "orange2\0"
+ "orange3\0"
+ "orange4\0"
+ "OrangeRed\0"
+ "OrangeRed1\0"
+ "OrangeRed2\0"
+ "OrangeRed3\0"
+ "OrangeRed4\0"
+ "orchid\0"
+ "orchid1\0"
+ "orchid2\0"
+ "orchid3\0"
+ "orchid4\0"
+ "pale goldenrod\0"
+ "pale green\0"
+ "pale turquoise\0"
+ "pale violet red\0"
+ "PaleGoldenrod\0"
+ "PaleGreen\0"
+ "PaleGreen1\0"
+ "PaleGreen2\0"
+ "PaleGreen3\0"
+ "PaleGreen4\0"
+ "PaleTurquoise\0"
+ "PaleTurquoise1\0"
+ "PaleTurquoise2\0"
+ "PaleTurquoise3\0"
+ "PaleTurquoise4\0"
+ "PaleVioletRed\0"
+ "PaleVioletRed1\0"
+ "PaleVioletRed2\0"
+ "PaleVioletRed3\0"
+ "PaleVioletRed4\0"
+ "papaya whip\0"
+ "PapayaWhip\0"
+ "peach puff\0"
+ "PeachPuff\0"
+ "PeachPuff1\0"
+ "PeachPuff2\0"
+ "PeachPuff3\0"
+ "PeachPuff4\0"
+ "peru\0"
+ "pink\0"
+ "pink1\0"
+ "pink2\0"
+ "pink3\0"
+ "pink4\0"
+ "plum\0"
+ "plum1\0"
+ "plum2\0"
+ "plum3\0"
+ "plum4\0"
+ "powder blue\0"
+ "PowderBlue\0"
+ "purple\0"
+ "purple1\0"
+ "purple2\0"
+ "purple3\0"
+ "purple4\0"
+ "red\0"
+ "red1\0"
+ "red2\0"
+ "red3\0"
+ "red4\0"
+ "rosy brown\0"
+ "RosyBrown\0"
+ "RosyBrown1\0"
+ "RosyBrown2\0"
+ "RosyBrown3\0"
+ "RosyBrown4\0"
+ "royal blue\0"
+ "RoyalBlue\0"
+ "RoyalBlue1\0"
+ "RoyalBlue2\0"
+ "RoyalBlue3\0"
+ "RoyalBlue4\0"
+ "saddle brown\0"
+ "SaddleBrown\0"
+ "salmon\0"
+ "salmon1\0"
+ "salmon2\0"
+ "salmon3\0"
+ "salmon4\0"
+ "sandy brown\0"
+ "SandyBrown\0"
+ "sea green\0"
+ "SeaGreen\0"
+ "SeaGreen1\0"
+ "SeaGreen2\0"
+ "SeaGreen3\0"
+ "SeaGreen4\0"
+ "seashell\0"
+ "seashell1\0"
+ "seashell2\0"
+ "seashell3\0"
+ "seashell4\0"
+ "sienna\0"
+ "sienna1\0"
+ "sienna2\0"
+ "sienna3\0"
+ "sienna4\0"
+ "sky blue\0"
+ "SkyBlue\0"
+ "SkyBlue1\0"
+ "SkyBlue2\0"
+ "SkyBlue3\0"
+ "SkyBlue4\0"
+ "slate blue\0"
+ "slate gray\0"
+ "slate grey\0"
+ "SlateBlue\0"
+ "SlateBlue1\0"
+ "SlateBlue2\0"
+ "SlateBlue3\0"
+ "SlateBlue4\0"
+ "SlateGray\0"
+ "SlateGray1\0"
+ "SlateGray2\0"
+ "SlateGray3\0"
+ "SlateGray4\0"
+ "SlateGrey\0"
+ "snow\0"
+ "snow1\0"
+ "snow2\0"
+ "snow3\0"
+ "snow4\0"
+ "spring green\0"
+ "SpringGreen\0"
+ "SpringGreen1\0"
+ "SpringGreen2\0"
+ "SpringGreen3\0"
+ "SpringGreen4\0"
+ "steel blue\0"
+ "SteelBlue\0"
+ "SteelBlue1\0"
+ "SteelBlue2\0"
+ "SteelBlue3\0"
+ "SteelBlue4\0"
+ "tan\0"
+ "tan1\0"
+ "tan2\0"
+ "tan3\0"
+ "tan4\0"
+ "thistle\0"
+ "thistle1\0"
+ "thistle2\0"
+ "thistle3\0"
+ "thistle4\0"
+ "tomato\0"
+ "tomato1\0"
+ "tomato2\0"
+ "tomato3\0"
+ "tomato4\0"
+ "turquoise\0"
+ "turquoise1\0"
+ "turquoise2\0"
+ "turquoise3\0"
+ "turquoise4\0"
+ "violet\0"
+ "violet red\0"
+ "VioletRed\0"
+ "VioletRed1\0"
+ "VioletRed2\0"
+ "VioletRed3\0"
+ "VioletRed4\0"
+ "wheat\0"
+ "wheat1\0"
+ "wheat2\0"
+ "wheat3\0"
+ "wheat4\0"
+ "white\0"
+ "white smoke\0"
+ "WhiteSmoke\0"
+ "yellow\0"
+ "yellow green\0"
+ "yellow1\0" "yellow2\0" "yellow3\0" "yellow4\0" "YellowGreen\0"
};
static const BuiltinColor BuiltinColors[] = {
- { 240, 248, 255, 0 }, /* alice blue */
- { 240, 248, 255, 11 }, /* AliceBlue */
- { 250, 235, 215, 21 }, /* antique white */
- { 250, 235, 215, 35 }, /* AntiqueWhite */
- { 255, 239, 219, 48 }, /* AntiqueWhite1 */
- { 238, 223, 204, 62 }, /* AntiqueWhite2 */
- { 205, 192, 176, 76 }, /* AntiqueWhite3 */
- { 139, 131, 120, 90 }, /* AntiqueWhite4 */
- { 127, 255, 212, 104 }, /* aquamarine */
- { 127, 255, 212, 115 }, /* aquamarine1 */
- { 118, 238, 198, 127 }, /* aquamarine2 */
- { 102, 205, 170, 139 }, /* aquamarine3 */
- { 69, 139, 116, 151 }, /* aquamarine4 */
- { 240, 255, 255, 163 }, /* azure */
- { 240, 255, 255, 169 }, /* azure1 */
- { 224, 238, 238, 176 }, /* azure2 */
- { 193, 205, 205, 183 }, /* azure3 */
- { 131, 139, 139, 190 }, /* azure4 */
- { 245, 245, 220, 197 }, /* beige */
- { 255, 228, 196, 203 }, /* bisque */
- { 255, 228, 196, 210 }, /* bisque1 */
- { 238, 213, 183, 218 }, /* bisque2 */
- { 205, 183, 158, 226 }, /* bisque3 */
- { 139, 125, 107, 234 }, /* bisque4 */
- { 0, 0, 0, 242 }, /* black */
- { 255, 235, 205, 248 }, /* blanched almond */
- { 255, 235, 205, 264 }, /* BlanchedAlmond */
- { 0, 0, 255, 279 }, /* blue */
- { 138, 43, 226, 284 }, /* blue violet */
- { 0, 0, 255, 296 }, /* blue1 */
- { 0, 0, 238, 302 }, /* blue2 */
- { 0, 0, 205, 308 }, /* blue3 */
- { 0, 0, 139, 314 }, /* blue4 */
- { 138, 43, 226, 320 }, /* BlueViolet */
- { 165, 42, 42, 331 }, /* brown */
- { 255, 64, 64, 337 }, /* brown1 */
- { 238, 59, 59, 344 }, /* brown2 */
- { 205, 51, 51, 351 }, /* brown3 */
- { 139, 35, 35, 358 }, /* brown4 */
- { 222, 184, 135, 365 }, /* burlywood */
- { 255, 211, 155, 375 }, /* burlywood1 */
- { 238, 197, 145, 386 }, /* burlywood2 */
- { 205, 170, 125, 397 }, /* burlywood3 */
- { 139, 115, 85, 408 }, /* burlywood4 */
- { 95, 158, 160, 419 }, /* cadet blue */
- { 95, 158, 160, 430 }, /* CadetBlue */
- { 152, 245, 255, 440 }, /* CadetBlue1 */
- { 142, 229, 238, 451 }, /* CadetBlue2 */
- { 122, 197, 205, 462 }, /* CadetBlue3 */
- { 83, 134, 139, 473 }, /* CadetBlue4 */
- { 127, 255, 0, 484 }, /* chartreuse */
- { 127, 255, 0, 495 }, /* chartreuse1 */
- { 118, 238, 0, 507 }, /* chartreuse2 */
- { 102, 205, 0, 519 }, /* chartreuse3 */
- { 69, 139, 0, 531 }, /* chartreuse4 */
- { 210, 105, 30, 543 }, /* chocolate */
- { 255, 127, 36, 553 }, /* chocolate1 */
- { 238, 118, 33, 564 }, /* chocolate2 */
- { 205, 102, 29, 575 }, /* chocolate3 */
- { 139, 69, 19, 586 }, /* chocolate4 */
- { 255, 127, 80, 597 }, /* coral */
- { 255, 114, 86, 603 }, /* coral1 */
- { 238, 106, 80, 610 }, /* coral2 */
- { 205, 91, 69, 617 }, /* coral3 */
- { 139, 62, 47, 624 }, /* coral4 */
- { 100, 149, 237, 631 }, /* cornflower blue */
- { 100, 149, 237, 647 }, /* CornflowerBlue */
- { 255, 248, 220, 662 }, /* cornsilk */
- { 255, 248, 220, 671 }, /* cornsilk1 */
- { 238, 232, 205, 681 }, /* cornsilk2 */
- { 205, 200, 177, 691 }, /* cornsilk3 */
- { 139, 136, 120, 701 }, /* cornsilk4 */
- { 0, 255, 255, 711 }, /* cyan */
- { 0, 255, 255, 716 }, /* cyan1 */
- { 0, 238, 238, 722 }, /* cyan2 */
- { 0, 205, 205, 728 }, /* cyan3 */
- { 0, 139, 139, 734 }, /* cyan4 */
- { 0, 0, 139, 740 }, /* dark blue */
- { 0, 139, 139, 750 }, /* dark cyan */
- { 184, 134, 11, 760 }, /* dark goldenrod */
- { 169, 169, 169, 775 }, /* dark gray */
- { 0, 100, 0, 785 }, /* dark green */
- { 169, 169, 169, 796 }, /* dark grey */
- { 189, 183, 107, 806 }, /* dark khaki */
- { 139, 0, 139, 817 }, /* dark magenta */
- { 85, 107, 47, 830 }, /* dark olive green */
- { 255, 140, 0, 847 }, /* dark orange */
- { 153, 50, 204, 859 }, /* dark orchid */
- { 139, 0, 0, 871 }, /* dark red */
- { 233, 150, 122, 880 }, /* dark salmon */
- { 143, 188, 143, 892 }, /* dark sea green */
- { 72, 61, 139, 907 }, /* dark slate blue */
- { 47, 79, 79, 923 }, /* dark slate gray */
- { 47, 79, 79, 939 }, /* dark slate grey */
- { 0, 206, 209, 955 }, /* dark turquoise */
- { 148, 0, 211, 970 }, /* dark violet */
- { 0, 0, 139, 982 }, /* DarkBlue */
- { 0, 139, 139, 991 }, /* DarkCyan */
- { 184, 134, 11, 1000 }, /* DarkGoldenrod */
- { 255, 185, 15, 1014 }, /* DarkGoldenrod1 */
- { 238, 173, 14, 1029 }, /* DarkGoldenrod2 */
- { 205, 149, 12, 1044 }, /* DarkGoldenrod3 */
- { 139, 101, 8, 1059 }, /* DarkGoldenrod4 */
- { 169, 169, 169, 1074 }, /* DarkGray */
- { 0, 100, 0, 1083 }, /* DarkGreen */
- { 169, 169, 169, 1093 }, /* DarkGrey */
- { 189, 183, 107, 1102 }, /* DarkKhaki */
- { 139, 0, 139, 1112 }, /* DarkMagenta */
- { 85, 107, 47, 1124 }, /* DarkOliveGreen */
- { 202, 255, 112, 1139 }, /* DarkOliveGreen1 */
- { 188, 238, 104, 1155 }, /* DarkOliveGreen2 */
- { 162, 205, 90, 1171 }, /* DarkOliveGreen3 */
- { 110, 139, 61, 1187 }, /* DarkOliveGreen4 */
- { 255, 140, 0, 1203 }, /* DarkOrange */
- { 255, 127, 0, 1214 }, /* DarkOrange1 */
- { 238, 118, 0, 1226 }, /* DarkOrange2 */
- { 205, 102, 0, 1238 }, /* DarkOrange3 */
- { 139, 69, 0, 1250 }, /* DarkOrange4 */
- { 153, 50, 204, 1262 }, /* DarkOrchid */
- { 191, 62, 255, 1273 }, /* DarkOrchid1 */
- { 178, 58, 238, 1285 }, /* DarkOrchid2 */
- { 154, 50, 205, 1297 }, /* DarkOrchid3 */
- { 104, 34, 139, 1309 }, /* DarkOrchid4 */
- { 139, 0, 0, 1321 }, /* DarkRed */
- { 233, 150, 122, 1329 }, /* DarkSalmon */
- { 143, 188, 143, 1340 }, /* DarkSeaGreen */
- { 193, 255, 193, 1353 }, /* DarkSeaGreen1 */
- { 180, 238, 180, 1367 }, /* DarkSeaGreen2 */
- { 155, 205, 155, 1381 }, /* DarkSeaGreen3 */
- { 105, 139, 105, 1395 }, /* DarkSeaGreen4 */
- { 72, 61, 139, 1409 }, /* DarkSlateBlue */
- { 47, 79, 79, 1423 }, /* DarkSlateGray */
- { 151, 255, 255, 1437 }, /* DarkSlateGray1 */
- { 141, 238, 238, 1452 }, /* DarkSlateGray2 */
- { 121, 205, 205, 1467 }, /* DarkSlateGray3 */
- { 82, 139, 139, 1482 }, /* DarkSlateGray4 */
- { 47, 79, 79, 1497 }, /* DarkSlateGrey */
- { 0, 206, 209, 1511 }, /* DarkTurquoise */
- { 148, 0, 211, 1525 }, /* DarkViolet */
- { 255, 20, 147, 1536 }, /* deep pink */
- { 0, 191, 255, 1546 }, /* deep sky blue */
- { 255, 20, 147, 1560 }, /* DeepPink */
- { 255, 20, 147, 1569 }, /* DeepPink1 */
- { 238, 18, 137, 1579 }, /* DeepPink2 */
- { 205, 16, 118, 1589 }, /* DeepPink3 */
- { 139, 10, 80, 1599 }, /* DeepPink4 */
- { 0, 191, 255, 1609 }, /* DeepSkyBlue */
- { 0, 191, 255, 1621 }, /* DeepSkyBlue1 */
- { 0, 178, 238, 1634 }, /* DeepSkyBlue2 */
- { 0, 154, 205, 1647 }, /* DeepSkyBlue3 */
- { 0, 104, 139, 1660 }, /* DeepSkyBlue4 */
- { 105, 105, 105, 1673 }, /* dim gray */
- { 105, 105, 105, 1682 }, /* dim grey */
- { 105, 105, 105, 1691 }, /* DimGray */
- { 105, 105, 105, 1699 }, /* DimGrey */
- { 30, 144, 255, 1707 }, /* dodger blue */
- { 30, 144, 255, 1719 }, /* DodgerBlue */
- { 30, 144, 255, 1730 }, /* DodgerBlue1 */
- { 28, 134, 238, 1742 }, /* DodgerBlue2 */
- { 24, 116, 205, 1754 }, /* DodgerBlue3 */
- { 16, 78, 139, 1766 }, /* DodgerBlue4 */
- { 178, 34, 34, 1778 }, /* firebrick */
- { 255, 48, 48, 1788 }, /* firebrick1 */
- { 238, 44, 44, 1799 }, /* firebrick2 */
- { 205, 38, 38, 1810 }, /* firebrick3 */
- { 139, 26, 26, 1821 }, /* firebrick4 */
- { 255, 250, 240, 1832 }, /* floral white */
- { 255, 250, 240, 1845 }, /* FloralWhite */
- { 34, 139, 34, 1857 }, /* forest green */
- { 34, 139, 34, 1870 }, /* ForestGreen */
- { 220, 220, 220, 1882 }, /* gainsboro */
- { 248, 248, 255, 1892 }, /* ghost white */
- { 248, 248, 255, 1904 }, /* GhostWhite */
- { 255, 215, 0, 1915 }, /* gold */
- { 255, 215, 0, 1920 }, /* gold1 */
- { 238, 201, 0, 1926 }, /* gold2 */
- { 205, 173, 0, 1932 }, /* gold3 */
- { 139, 117, 0, 1938 }, /* gold4 */
- { 218, 165, 32, 1944 }, /* goldenrod */
- { 255, 193, 37, 1954 }, /* goldenrod1 */
- { 238, 180, 34, 1965 }, /* goldenrod2 */
- { 205, 155, 29, 1976 }, /* goldenrod3 */
- { 139, 105, 20, 1987 }, /* goldenrod4 */
- { 190, 190, 190, 1998 }, /* gray */
- { 0, 0, 0, 2003 }, /* gray0 */
- { 3, 3, 3, 2009 }, /* gray1 */
- { 26, 26, 26, 2015 }, /* gray10 */
- { 255, 255, 255, 2022 }, /* gray100 */
- { 28, 28, 28, 2030 }, /* gray11 */
- { 31, 31, 31, 2037 }, /* gray12 */
- { 33, 33, 33, 2044 }, /* gray13 */
- { 36, 36, 36, 2051 }, /* gray14 */
- { 38, 38, 38, 2058 }, /* gray15 */
- { 41, 41, 41, 2065 }, /* gray16 */
- { 43, 43, 43, 2072 }, /* gray17 */
- { 46, 46, 46, 2079 }, /* gray18 */
- { 48, 48, 48, 2086 }, /* gray19 */
- { 5, 5, 5, 2093 }, /* gray2 */
- { 51, 51, 51, 2099 }, /* gray20 */
- { 54, 54, 54, 2106 }, /* gray21 */
- { 56, 56, 56, 2113 }, /* gray22 */
- { 59, 59, 59, 2120 }, /* gray23 */
- { 61, 61, 61, 2127 }, /* gray24 */
- { 64, 64, 64, 2134 }, /* gray25 */
- { 66, 66, 66, 2141 }, /* gray26 */
- { 69, 69, 69, 2148 }, /* gray27 */
- { 71, 71, 71, 2155 }, /* gray28 */
- { 74, 74, 74, 2162 }, /* gray29 */
- { 8, 8, 8, 2169 }, /* gray3 */
- { 77, 77, 77, 2175 }, /* gray30 */
- { 79, 79, 79, 2182 }, /* gray31 */
- { 82, 82, 82, 2189 }, /* gray32 */
- { 84, 84, 84, 2196 }, /* gray33 */
- { 87, 87, 87, 2203 }, /* gray34 */
- { 89, 89, 89, 2210 }, /* gray35 */
- { 92, 92, 92, 2217 }, /* gray36 */
- { 94, 94, 94, 2224 }, /* gray37 */
- { 97, 97, 97, 2231 }, /* gray38 */
- { 99, 99, 99, 2238 }, /* gray39 */
- { 10, 10, 10, 2245 }, /* gray4 */
- { 102, 102, 102, 2251 }, /* gray40 */
- { 105, 105, 105, 2258 }, /* gray41 */
- { 107, 107, 107, 2265 }, /* gray42 */
- { 110, 110, 110, 2272 }, /* gray43 */
- { 112, 112, 112, 2279 }, /* gray44 */
- { 115, 115, 115, 2286 }, /* gray45 */
- { 117, 117, 117, 2293 }, /* gray46 */
- { 120, 120, 120, 2300 }, /* gray47 */
- { 122, 122, 122, 2307 }, /* gray48 */
- { 125, 125, 125, 2314 }, /* gray49 */
- { 13, 13, 13, 2321 }, /* gray5 */
- { 127, 127, 127, 2327 }, /* gray50 */
- { 130, 130, 130, 2334 }, /* gray51 */
- { 133, 133, 133, 2341 }, /* gray52 */
- { 135, 135, 135, 2348 }, /* gray53 */
- { 138, 138, 138, 2355 }, /* gray54 */
- { 140, 140, 140, 2362 }, /* gray55 */
- { 143, 143, 143, 2369 }, /* gray56 */
- { 145, 145, 145, 2376 }, /* gray57 */
- { 148, 148, 148, 2383 }, /* gray58 */
- { 150, 150, 150, 2390 }, /* gray59 */
- { 15, 15, 15, 2397 }, /* gray6 */
- { 153, 153, 153, 2403 }, /* gray60 */
- { 156, 156, 156, 2410 }, /* gray61 */
- { 158, 158, 158, 2417 }, /* gray62 */
- { 161, 161, 161, 2424 }, /* gray63 */
- { 163, 163, 163, 2431 }, /* gray64 */
- { 166, 166, 166, 2438 }, /* gray65 */
- { 168, 168, 168, 2445 }, /* gray66 */
- { 171, 171, 171, 2452 }, /* gray67 */
- { 173, 173, 173, 2459 }, /* gray68 */
- { 176, 176, 176, 2466 }, /* gray69 */
- { 18, 18, 18, 2473 }, /* gray7 */
- { 179, 179, 179, 2479 }, /* gray70 */
- { 181, 181, 181, 2486 }, /* gray71 */
- { 184, 184, 184, 2493 }, /* gray72 */
- { 186, 186, 186, 2500 }, /* gray73 */
- { 189, 189, 189, 2507 }, /* gray74 */
- { 191, 191, 191, 2514 }, /* gray75 */
- { 194, 194, 194, 2521 }, /* gray76 */
- { 196, 196, 196, 2528 }, /* gray77 */
- { 199, 199, 199, 2535 }, /* gray78 */
- { 201, 201, 201, 2542 }, /* gray79 */
- { 20, 20, 20, 2549 }, /* gray8 */
- { 204, 204, 204, 2555 }, /* gray80 */
- { 207, 207, 207, 2562 }, /* gray81 */
- { 209, 209, 209, 2569 }, /* gray82 */
- { 212, 212, 212, 2576 }, /* gray83 */
- { 214, 214, 214, 2583 }, /* gray84 */
- { 217, 217, 217, 2590 }, /* gray85 */
- { 219, 219, 219, 2597 }, /* gray86 */
- { 222, 222, 222, 2604 }, /* gray87 */
- { 224, 224, 224, 2611 }, /* gray88 */
- { 227, 227, 227, 2618 }, /* gray89 */
- { 23, 23, 23, 2625 }, /* gray9 */
- { 229, 229, 229, 2631 }, /* gray90 */
- { 232, 232, 232, 2638 }, /* gray91 */
- { 235, 235, 235, 2645 }, /* gray92 */
- { 237, 237, 237, 2652 }, /* gray93 */
- { 240, 240, 240, 2659 }, /* gray94 */
- { 242, 242, 242, 2666 }, /* gray95 */
- { 245, 245, 245, 2673 }, /* gray96 */
- { 247, 247, 247, 2680 }, /* gray97 */
- { 250, 250, 250, 2687 }, /* gray98 */
- { 252, 252, 252, 2694 }, /* gray99 */
- { 0, 255, 0, 2701 }, /* green */
- { 173, 255, 47, 2707 }, /* green yellow */
- { 0, 255, 0, 2720 }, /* green1 */
- { 0, 238, 0, 2727 }, /* green2 */
- { 0, 205, 0, 2734 }, /* green3 */
- { 0, 139, 0, 2741 }, /* green4 */
- { 173, 255, 47, 2748 }, /* GreenYellow */
- { 190, 190, 190, 2760 }, /* grey */
- { 0, 0, 0, 2765 }, /* grey0 */
- { 3, 3, 3, 2771 }, /* grey1 */
- { 26, 26, 26, 2777 }, /* grey10 */
- { 255, 255, 255, 2784 }, /* grey100 */
- { 28, 28, 28, 2792 }, /* grey11 */
- { 31, 31, 31, 2799 }, /* grey12 */
- { 33, 33, 33, 2806 }, /* grey13 */
- { 36, 36, 36, 2813 }, /* grey14 */
- { 38, 38, 38, 2820 }, /* grey15 */
- { 41, 41, 41, 2827 }, /* grey16 */
- { 43, 43, 43, 2834 }, /* grey17 */
- { 46, 46, 46, 2841 }, /* grey18 */
- { 48, 48, 48, 2848 }, /* grey19 */
- { 5, 5, 5, 2855 }, /* grey2 */
- { 51, 51, 51, 2861 }, /* grey20 */
- { 54, 54, 54, 2868 }, /* grey21 */
- { 56, 56, 56, 2875 }, /* grey22 */
- { 59, 59, 59, 2882 }, /* grey23 */
- { 61, 61, 61, 2889 }, /* grey24 */
- { 64, 64, 64, 2896 }, /* grey25 */
- { 66, 66, 66, 2903 }, /* grey26 */
- { 69, 69, 69, 2910 }, /* grey27 */
- { 71, 71, 71, 2917 }, /* grey28 */
- { 74, 74, 74, 2924 }, /* grey29 */
- { 8, 8, 8, 2931 }, /* grey3 */
- { 77, 77, 77, 2937 }, /* grey30 */
- { 79, 79, 79, 2944 }, /* grey31 */
- { 82, 82, 82, 2951 }, /* grey32 */
- { 84, 84, 84, 2958 }, /* grey33 */
- { 87, 87, 87, 2965 }, /* grey34 */
- { 89, 89, 89, 2972 }, /* grey35 */
- { 92, 92, 92, 2979 }, /* grey36 */
- { 94, 94, 94, 2986 }, /* grey37 */
- { 97, 97, 97, 2993 }, /* grey38 */
- { 99, 99, 99, 3000 }, /* grey39 */
- { 10, 10, 10, 3007 }, /* grey4 */
- { 102, 102, 102, 3013 }, /* grey40 */
- { 105, 105, 105, 3020 }, /* grey41 */
- { 107, 107, 107, 3027 }, /* grey42 */
- { 110, 110, 110, 3034 }, /* grey43 */
- { 112, 112, 112, 3041 }, /* grey44 */
- { 115, 115, 115, 3048 }, /* grey45 */
- { 117, 117, 117, 3055 }, /* grey46 */
- { 120, 120, 120, 3062 }, /* grey47 */
- { 122, 122, 122, 3069 }, /* grey48 */
- { 125, 125, 125, 3076 }, /* grey49 */
- { 13, 13, 13, 3083 }, /* grey5 */
- { 127, 127, 127, 3089 }, /* grey50 */
- { 130, 130, 130, 3096 }, /* grey51 */
- { 133, 133, 133, 3103 }, /* grey52 */
- { 135, 135, 135, 3110 }, /* grey53 */
- { 138, 138, 138, 3117 }, /* grey54 */
- { 140, 140, 140, 3124 }, /* grey55 */
- { 143, 143, 143, 3131 }, /* grey56 */
- { 145, 145, 145, 3138 }, /* grey57 */
- { 148, 148, 148, 3145 }, /* grey58 */
- { 150, 150, 150, 3152 }, /* grey59 */
- { 15, 15, 15, 3159 }, /* grey6 */
- { 153, 153, 153, 3165 }, /* grey60 */
- { 156, 156, 156, 3172 }, /* grey61 */
- { 158, 158, 158, 3179 }, /* grey62 */
- { 161, 161, 161, 3186 }, /* grey63 */
- { 163, 163, 163, 3193 }, /* grey64 */
- { 166, 166, 166, 3200 }, /* grey65 */
- { 168, 168, 168, 3207 }, /* grey66 */
- { 171, 171, 171, 3214 }, /* grey67 */
- { 173, 173, 173, 3221 }, /* grey68 */
- { 176, 176, 176, 3228 }, /* grey69 */
- { 18, 18, 18, 3235 }, /* grey7 */
- { 179, 179, 179, 3241 }, /* grey70 */
- { 181, 181, 181, 3248 }, /* grey71 */
- { 184, 184, 184, 3255 }, /* grey72 */
- { 186, 186, 186, 3262 }, /* grey73 */
- { 189, 189, 189, 3269 }, /* grey74 */
- { 191, 191, 191, 3276 }, /* grey75 */
- { 194, 194, 194, 3283 }, /* grey76 */
- { 196, 196, 196, 3290 }, /* grey77 */
- { 199, 199, 199, 3297 }, /* grey78 */
- { 201, 201, 201, 3304 }, /* grey79 */
- { 20, 20, 20, 3311 }, /* grey8 */
- { 204, 204, 204, 3317 }, /* grey80 */
- { 207, 207, 207, 3324 }, /* grey81 */
- { 209, 209, 209, 3331 }, /* grey82 */
- { 212, 212, 212, 3338 }, /* grey83 */
- { 214, 214, 214, 3345 }, /* grey84 */
- { 217, 217, 217, 3352 }, /* grey85 */
- { 219, 219, 219, 3359 }, /* grey86 */
- { 222, 222, 222, 3366 }, /* grey87 */
- { 224, 224, 224, 3373 }, /* grey88 */
- { 227, 227, 227, 3380 }, /* grey89 */
- { 23, 23, 23, 3387 }, /* grey9 */
- { 229, 229, 229, 3393 }, /* grey90 */
- { 232, 232, 232, 3400 }, /* grey91 */
- { 235, 235, 235, 3407 }, /* grey92 */
- { 237, 237, 237, 3414 }, /* grey93 */
- { 240, 240, 240, 3421 }, /* grey94 */
- { 242, 242, 242, 3428 }, /* grey95 */
- { 245, 245, 245, 3435 }, /* grey96 */
- { 247, 247, 247, 3442 }, /* grey97 */
- { 250, 250, 250, 3449 }, /* grey98 */
- { 252, 252, 252, 3456 }, /* grey99 */
- { 240, 255, 240, 3463 }, /* honeydew */
- { 240, 255, 240, 3472 }, /* honeydew1 */
- { 224, 238, 224, 3482 }, /* honeydew2 */
- { 193, 205, 193, 3492 }, /* honeydew3 */
- { 131, 139, 131, 3502 }, /* honeydew4 */
- { 255, 105, 180, 3512 }, /* hot pink */
- { 255, 105, 180, 3521 }, /* HotPink */
- { 255, 110, 180, 3529 }, /* HotPink1 */
- { 238, 106, 167, 3538 }, /* HotPink2 */
- { 205, 96, 144, 3547 }, /* HotPink3 */
- { 139, 58, 98, 3556 }, /* HotPink4 */
- { 205, 92, 92, 3565 }, /* indian red */
- { 205, 92, 92, 3576 }, /* IndianRed */
- { 255, 106, 106, 3586 }, /* IndianRed1 */
- { 238, 99, 99, 3597 }, /* IndianRed2 */
- { 205, 85, 85, 3608 }, /* IndianRed3 */
- { 139, 58, 58, 3619 }, /* IndianRed4 */
- { 255, 255, 240, 3630 }, /* ivory */
- { 255, 255, 240, 3636 }, /* ivory1 */
- { 238, 238, 224, 3643 }, /* ivory2 */
- { 205, 205, 193, 3650 }, /* ivory3 */
- { 139, 139, 131, 3657 }, /* ivory4 */
- { 240, 230, 140, 3664 }, /* khaki */
- { 255, 246, 143, 3670 }, /* khaki1 */
- { 238, 230, 133, 3677 }, /* khaki2 */
- { 205, 198, 115, 3684 }, /* khaki3 */
- { 139, 134, 78, 3691 }, /* khaki4 */
- { 230, 230, 250, 3698 }, /* lavender */
- { 255, 240, 245, 3707 }, /* lavender blush */
- { 255, 240, 245, 3722 }, /* LavenderBlush */
- { 255, 240, 245, 3736 }, /* LavenderBlush1 */
- { 238, 224, 229, 3751 }, /* LavenderBlush2 */
- { 205, 193, 197, 3766 }, /* LavenderBlush3 */
- { 139, 131, 134, 3781 }, /* LavenderBlush4 */
- { 124, 252, 0, 3796 }, /* lawn green */
- { 124, 252, 0, 3807 }, /* LawnGreen */
- { 255, 250, 205, 3817 }, /* lemon chiffon */
- { 255, 250, 205, 3831 }, /* LemonChiffon */
- { 255, 250, 205, 3844 }, /* LemonChiffon1 */
- { 238, 233, 191, 3858 }, /* LemonChiffon2 */
- { 205, 201, 165, 3872 }, /* LemonChiffon3 */
- { 139, 137, 112, 3886 }, /* LemonChiffon4 */
- { 173, 216, 230, 3900 }, /* light blue */
- { 240, 128, 128, 3911 }, /* light coral */
- { 224, 255, 255, 3923 }, /* light cyan */
- { 238, 221, 130, 3934 }, /* light goldenrod */
- { 250, 250, 210, 3950 }, /* light goldenrod yellow */
- { 211, 211, 211, 3973 }, /* light gray */
- { 144, 238, 144, 3984 }, /* light green */
- { 211, 211, 211, 3996 }, /* light grey */
- { 255, 182, 193, 4007 }, /* light pink */
- { 255, 160, 122, 4018 }, /* light salmon */
- { 32, 178, 170, 4031 }, /* light sea green */
- { 135, 206, 250, 4047 }, /* light sky blue */
- { 132, 112, 255, 4062 }, /* light slate blue */
- { 119, 136, 153, 4079 }, /* light slate gray */
- { 119, 136, 153, 4096 }, /* light slate grey */
- { 176, 196, 222, 4113 }, /* light steel blue */
- { 255, 255, 224, 4130 }, /* light yellow */
- { 173, 216, 230, 4143 }, /* LightBlue */
- { 191, 239, 255, 4153 }, /* LightBlue1 */
- { 178, 223, 238, 4164 }, /* LightBlue2 */
- { 154, 192, 205, 4175 }, /* LightBlue3 */
- { 104, 131, 139, 4186 }, /* LightBlue4 */
- { 240, 128, 128, 4197 }, /* LightCoral */
- { 224, 255, 255, 4208 }, /* LightCyan */
- { 224, 255, 255, 4218 }, /* LightCyan1 */
- { 209, 238, 238, 4229 }, /* LightCyan2 */
- { 180, 205, 205, 4240 }, /* LightCyan3 */
- { 122, 139, 139, 4251 }, /* LightCyan4 */
- { 238, 221, 130, 4262 }, /* LightGoldenrod */
- { 255, 236, 139, 4277 }, /* LightGoldenrod1 */
- { 238, 220, 130, 4293 }, /* LightGoldenrod2 */
- { 205, 190, 112, 4309 }, /* LightGoldenrod3 */
- { 139, 129, 76, 4325 }, /* LightGoldenrod4 */
- { 250, 250, 210, 4341 }, /* LightGoldenrodYellow */
- { 211, 211, 211, 4362 }, /* LightGray */
- { 144, 238, 144, 4372 }, /* LightGreen */
- { 211, 211, 211, 4383 }, /* LightGrey */
- { 255, 182, 193, 4393 }, /* LightPink */
- { 255, 174, 185, 4403 }, /* LightPink1 */
- { 238, 162, 173, 4414 }, /* LightPink2 */
- { 205, 140, 149, 4425 }, /* LightPink3 */
- { 139, 95, 101, 4436 }, /* LightPink4 */
- { 255, 160, 122, 4447 }, /* LightSalmon */
- { 255, 160, 122, 4459 }, /* LightSalmon1 */
- { 238, 149, 114, 4472 }, /* LightSalmon2 */
- { 205, 129, 98, 4485 }, /* LightSalmon3 */
- { 139, 87, 66, 4498 }, /* LightSalmon4 */
- { 32, 178, 170, 4511 }, /* LightSeaGreen */
- { 135, 206, 250, 4525 }, /* LightSkyBlue */
- { 176, 226, 255, 4538 }, /* LightSkyBlue1 */
- { 164, 211, 238, 4552 }, /* LightSkyBlue2 */
- { 141, 182, 205, 4566 }, /* LightSkyBlue3 */
- { 96, 123, 139, 4580 }, /* LightSkyBlue4 */
- { 132, 112, 255, 4594 }, /* LightSlateBlue */
- { 119, 136, 153, 4609 }, /* LightSlateGray */
- { 119, 136, 153, 4624 }, /* LightSlateGrey */
- { 176, 196, 222, 4639 }, /* LightSteelBlue */
- { 202, 225, 255, 4654 }, /* LightSteelBlue1 */
- { 188, 210, 238, 4670 }, /* LightSteelBlue2 */
- { 162, 181, 205, 4686 }, /* LightSteelBlue3 */
- { 110, 123, 139, 4702 }, /* LightSteelBlue4 */
- { 255, 255, 224, 4718 }, /* LightYellow */
- { 255, 255, 224, 4730 }, /* LightYellow1 */
- { 238, 238, 209, 4743 }, /* LightYellow2 */
- { 205, 205, 180, 4756 }, /* LightYellow3 */
- { 139, 139, 122, 4769 }, /* LightYellow4 */
- { 50, 205, 50, 4782 }, /* lime green */
- { 50, 205, 50, 4793 }, /* LimeGreen */
- { 250, 240, 230, 4803 }, /* linen */
- { 255, 0, 255, 4809 }, /* magenta */
- { 255, 0, 255, 4817 }, /* magenta1 */
- { 238, 0, 238, 4826 }, /* magenta2 */
- { 205, 0, 205, 4835 }, /* magenta3 */
- { 139, 0, 139, 4844 }, /* magenta4 */
- { 176, 48, 96, 4853 }, /* maroon */
- { 255, 52, 179, 4860 }, /* maroon1 */
- { 238, 48, 167, 4868 }, /* maroon2 */
- { 205, 41, 144, 4876 }, /* maroon3 */
- { 139, 28, 98, 4884 }, /* maroon4 */
- { 102, 205, 170, 4892 }, /* medium aquamarine */
- { 0, 0, 205, 4910 }, /* medium blue */
- { 186, 85, 211, 4922 }, /* medium orchid */
- { 147, 112, 219, 4936 }, /* medium purple */
- { 60, 179, 113, 4950 }, /* medium sea green */
- { 123, 104, 238, 4967 }, /* medium slate blue */
- { 0, 250, 154, 4985 }, /* medium spring green */
- { 72, 209, 204, 5005 }, /* medium turquoise */
- { 199, 21, 133, 5022 }, /* medium violet red */
- { 102, 205, 170, 5040 }, /* MediumAquamarine */
- { 0, 0, 205, 5057 }, /* MediumBlue */
- { 186, 85, 211, 5068 }, /* MediumOrchid */
- { 224, 102, 255, 5081 }, /* MediumOrchid1 */
- { 209, 95, 238, 5095 }, /* MediumOrchid2 */
- { 180, 82, 205, 5109 }, /* MediumOrchid3 */
- { 122, 55, 139, 5123 }, /* MediumOrchid4 */
- { 147, 112, 219, 5137 }, /* MediumPurple */
- { 171, 130, 255, 5150 }, /* MediumPurple1 */
- { 159, 121, 238, 5164 }, /* MediumPurple2 */
- { 137, 104, 205, 5178 }, /* MediumPurple3 */
- { 93, 71, 139, 5192 }, /* MediumPurple4 */
- { 60, 179, 113, 5206 }, /* MediumSeaGreen */
- { 123, 104, 238, 5221 }, /* MediumSlateBlue */
- { 0, 250, 154, 5237 }, /* MediumSpringGreen */
- { 72, 209, 204, 5255 }, /* MediumTurquoise */
- { 199, 21, 133, 5271 }, /* MediumVioletRed */
- { 25, 25, 112, 5287 }, /* midnight blue */
- { 25, 25, 112, 5301 }, /* MidnightBlue */
- { 245, 255, 250, 5314 }, /* mint cream */
- { 245, 255, 250, 5325 }, /* MintCream */
- { 255, 228, 225, 5335 }, /* misty rose */
- { 255, 228, 225, 5346 }, /* MistyRose */
- { 255, 228, 225, 5356 }, /* MistyRose1 */
- { 238, 213, 210, 5367 }, /* MistyRose2 */
- { 205, 183, 181, 5378 }, /* MistyRose3 */
- { 139, 125, 123, 5389 }, /* MistyRose4 */
- { 255, 228, 181, 5400 }, /* moccasin */
- { 255, 222, 173, 5409 }, /* navajo white */
- { 255, 222, 173, 5422 }, /* NavajoWhite */
- { 255, 222, 173, 5434 }, /* NavajoWhite1 */
- { 238, 207, 161, 5447 }, /* NavajoWhite2 */
- { 205, 179, 139, 5460 }, /* NavajoWhite3 */
- { 139, 121, 94, 5473 }, /* NavajoWhite4 */
- { 0, 0, 128, 5486 }, /* navy */
- { 0, 0, 128, 5491 }, /* navy blue */
- { 0, 0, 128, 5501 }, /* NavyBlue */
- { 253, 245, 230, 5510 }, /* old lace */
- { 253, 245, 230, 5519 }, /* OldLace */
- { 107, 142, 35, 5527 }, /* olive drab */
- { 107, 142, 35, 5538 }, /* OliveDrab */
- { 192, 255, 62, 5548 }, /* OliveDrab1 */
- { 179, 238, 58, 5559 }, /* OliveDrab2 */
- { 154, 205, 50, 5570 }, /* OliveDrab3 */
- { 105, 139, 34, 5581 }, /* OliveDrab4 */
- { 255, 165, 0, 5592 }, /* orange */
- { 255, 69, 0, 5599 }, /* orange red */
- { 255, 165, 0, 5610 }, /* orange1 */
- { 238, 154, 0, 5618 }, /* orange2 */
- { 205, 133, 0, 5626 }, /* orange3 */
- { 139, 90, 0, 5634 }, /* orange4 */
- { 255, 69, 0, 5642 }, /* OrangeRed */
- { 255, 69, 0, 5652 }, /* OrangeRed1 */
- { 238, 64, 0, 5663 }, /* OrangeRed2 */
- { 205, 55, 0, 5674 }, /* OrangeRed3 */
- { 139, 37, 0, 5685 }, /* OrangeRed4 */
- { 218, 112, 214, 5696 }, /* orchid */
- { 255, 131, 250, 5703 }, /* orchid1 */
- { 238, 122, 233, 5711 }, /* orchid2 */
- { 205, 105, 201, 5719 }, /* orchid3 */
- { 139, 71, 137, 5727 }, /* orchid4 */
- { 238, 232, 170, 5735 }, /* pale goldenrod */
- { 152, 251, 152, 5750 }, /* pale green */
- { 175, 238, 238, 5761 }, /* pale turquoise */
- { 219, 112, 147, 5776 }, /* pale violet red */
- { 238, 232, 170, 5792 }, /* PaleGoldenrod */
- { 152, 251, 152, 5806 }, /* PaleGreen */
- { 154, 255, 154, 5816 }, /* PaleGreen1 */
- { 144, 238, 144, 5827 }, /* PaleGreen2 */
- { 124, 205, 124, 5838 }, /* PaleGreen3 */
- { 84, 139, 84, 5849 }, /* PaleGreen4 */
- { 175, 238, 238, 5860 }, /* PaleTurquoise */
- { 187, 255, 255, 5874 }, /* PaleTurquoise1 */
- { 174, 238, 238, 5889 }, /* PaleTurquoise2 */
- { 150, 205, 205, 5904 }, /* PaleTurquoise3 */
- { 102, 139, 139, 5919 }, /* PaleTurquoise4 */
- { 219, 112, 147, 5934 }, /* PaleVioletRed */
- { 255, 130, 171, 5948 }, /* PaleVioletRed1 */
- { 238, 121, 159, 5963 }, /* PaleVioletRed2 */
- { 205, 104, 137, 5978 }, /* PaleVioletRed3 */
- { 139, 71, 93, 5993 }, /* PaleVioletRed4 */
- { 255, 239, 213, 6008 }, /* papaya whip */
- { 255, 239, 213, 6020 }, /* PapayaWhip */
- { 255, 218, 185, 6031 }, /* peach puff */
- { 255, 218, 185, 6042 }, /* PeachPuff */
- { 255, 218, 185, 6052 }, /* PeachPuff1 */
- { 238, 203, 173, 6063 }, /* PeachPuff2 */
- { 205, 175, 149, 6074 }, /* PeachPuff3 */
- { 139, 119, 101, 6085 }, /* PeachPuff4 */
- { 205, 133, 63, 6096 }, /* peru */
- { 255, 192, 203, 6101 }, /* pink */
- { 255, 181, 197, 6106 }, /* pink1 */
- { 238, 169, 184, 6112 }, /* pink2 */
- { 205, 145, 158, 6118 }, /* pink3 */
- { 139, 99, 108, 6124 }, /* pink4 */
- { 221, 160, 221, 6130 }, /* plum */
- { 255, 187, 255, 6135 }, /* plum1 */
- { 238, 174, 238, 6141 }, /* plum2 */
- { 205, 150, 205, 6147 }, /* plum3 */
- { 139, 102, 139, 6153 }, /* plum4 */
- { 176, 224, 230, 6159 }, /* powder blue */
- { 176, 224, 230, 6171 }, /* PowderBlue */
- { 160, 32, 240, 6182 }, /* purple */
- { 155, 48, 255, 6189 }, /* purple1 */
- { 145, 44, 238, 6197 }, /* purple2 */
- { 125, 38, 205, 6205 }, /* purple3 */
- { 85, 26, 139, 6213 }, /* purple4 */
- { 255, 0, 0, 6221 }, /* red */
- { 255, 0, 0, 6225 }, /* red1 */
- { 238, 0, 0, 6230 }, /* red2 */
- { 205, 0, 0, 6235 }, /* red3 */
- { 139, 0, 0, 6240 }, /* red4 */
- { 188, 143, 143, 6245 }, /* rosy brown */
- { 188, 143, 143, 6256 }, /* RosyBrown */
- { 255, 193, 193, 6266 }, /* RosyBrown1 */
- { 238, 180, 180, 6277 }, /* RosyBrown2 */
- { 205, 155, 155, 6288 }, /* RosyBrown3 */
- { 139, 105, 105, 6299 }, /* RosyBrown4 */
- { 65, 105, 225, 6310 }, /* royal blue */
- { 65, 105, 225, 6321 }, /* RoyalBlue */
- { 72, 118, 255, 6331 }, /* RoyalBlue1 */
- { 67, 110, 238, 6342 }, /* RoyalBlue2 */
- { 58, 95, 205, 6353 }, /* RoyalBlue3 */
- { 39, 64, 139, 6364 }, /* RoyalBlue4 */
- { 139, 69, 19, 6375 }, /* saddle brown */
- { 139, 69, 19, 6388 }, /* SaddleBrown */
- { 250, 128, 114, 6400 }, /* salmon */
- { 255, 140, 105, 6407 }, /* salmon1 */
- { 238, 130, 98, 6415 }, /* salmon2 */
- { 205, 112, 84, 6423 }, /* salmon3 */
- { 139, 76, 57, 6431 }, /* salmon4 */
- { 244, 164, 96, 6439 }, /* sandy brown */
- { 244, 164, 96, 6451 }, /* SandyBrown */
- { 46, 139, 87, 6462 }, /* sea green */
- { 46, 139, 87, 6472 }, /* SeaGreen */
- { 84, 255, 159, 6481 }, /* SeaGreen1 */
- { 78, 238, 148, 6491 }, /* SeaGreen2 */
- { 67, 205, 128, 6501 }, /* SeaGreen3 */
- { 46, 139, 87, 6511 }, /* SeaGreen4 */
- { 255, 245, 238, 6521 }, /* seashell */
- { 255, 245, 238, 6530 }, /* seashell1 */
- { 238, 229, 222, 6540 }, /* seashell2 */
- { 205, 197, 191, 6550 }, /* seashell3 */
- { 139, 134, 130, 6560 }, /* seashell4 */
- { 160, 82, 45, 6570 }, /* sienna */
- { 255, 130, 71, 6577 }, /* sienna1 */
- { 238, 121, 66, 6585 }, /* sienna2 */
- { 205, 104, 57, 6593 }, /* sienna3 */
- { 139, 71, 38, 6601 }, /* sienna4 */
- { 135, 206, 235, 6609 }, /* sky blue */
- { 135, 206, 235, 6618 }, /* SkyBlue */
- { 135, 206, 255, 6626 }, /* SkyBlue1 */
- { 126, 192, 238, 6635 }, /* SkyBlue2 */
- { 108, 166, 205, 6644 }, /* SkyBlue3 */
- { 74, 112, 139, 6653 }, /* SkyBlue4 */
- { 106, 90, 205, 6662 }, /* slate blue */
- { 112, 128, 144, 6673 }, /* slate gray */
- { 112, 128, 144, 6684 }, /* slate grey */
- { 106, 90, 205, 6695 }, /* SlateBlue */
- { 131, 111, 255, 6705 }, /* SlateBlue1 */
- { 122, 103, 238, 6716 }, /* SlateBlue2 */
- { 105, 89, 205, 6727 }, /* SlateBlue3 */
- { 71, 60, 139, 6738 }, /* SlateBlue4 */
- { 112, 128, 144, 6749 }, /* SlateGray */
- { 198, 226, 255, 6759 }, /* SlateGray1 */
- { 185, 211, 238, 6770 }, /* SlateGray2 */
- { 159, 182, 205, 6781 }, /* SlateGray3 */
- { 108, 123, 139, 6792 }, /* SlateGray4 */
- { 112, 128, 144, 6803 }, /* SlateGrey */
- { 255, 250, 250, 6813 }, /* snow */
- { 255, 250, 250, 6818 }, /* snow1 */
- { 238, 233, 233, 6824 }, /* snow2 */
- { 205, 201, 201, 6830 }, /* snow3 */
- { 139, 137, 137, 6836 }, /* snow4 */
- { 0, 255, 127, 6842 }, /* spring green */
- { 0, 255, 127, 6855 }, /* SpringGreen */
- { 0, 255, 127, 6867 }, /* SpringGreen1 */
- { 0, 238, 118, 6880 }, /* SpringGreen2 */
- { 0, 205, 102, 6893 }, /* SpringGreen3 */
- { 0, 139, 69, 6906 }, /* SpringGreen4 */
- { 70, 130, 180, 6919 }, /* steel blue */
- { 70, 130, 180, 6930 }, /* SteelBlue */
- { 99, 184, 255, 6940 }, /* SteelBlue1 */
- { 92, 172, 238, 6951 }, /* SteelBlue2 */
- { 79, 148, 205, 6962 }, /* SteelBlue3 */
- { 54, 100, 139, 6973 }, /* SteelBlue4 */
- { 210, 180, 140, 6984 }, /* tan */
- { 255, 165, 79, 6988 }, /* tan1 */
- { 238, 154, 73, 6993 }, /* tan2 */
- { 205, 133, 63, 6998 }, /* tan3 */
- { 139, 90, 43, 7003 }, /* tan4 */
- { 216, 191, 216, 7008 }, /* thistle */
- { 255, 225, 255, 7016 }, /* thistle1 */
- { 238, 210, 238, 7025 }, /* thistle2 */
- { 205, 181, 205, 7034 }, /* thistle3 */
- { 139, 123, 139, 7043 }, /* thistle4 */
- { 255, 99, 71, 7052 }, /* tomato */
- { 255, 99, 71, 7059 }, /* tomato1 */
- { 238, 92, 66, 7067 }, /* tomato2 */
- { 205, 79, 57, 7075 }, /* tomato3 */
- { 139, 54, 38, 7083 }, /* tomato4 */
- { 64, 224, 208, 7091 }, /* turquoise */
- { 0, 245, 255, 7101 }, /* turquoise1 */
- { 0, 229, 238, 7112 }, /* turquoise2 */
- { 0, 197, 205, 7123 }, /* turquoise3 */
- { 0, 134, 139, 7134 }, /* turquoise4 */
- { 238, 130, 238, 7145 }, /* violet */
- { 208, 32, 144, 7152 }, /* violet red */
- { 208, 32, 144, 7163 }, /* VioletRed */
- { 255, 62, 150, 7173 }, /* VioletRed1 */
- { 238, 58, 140, 7184 }, /* VioletRed2 */
- { 205, 50, 120, 7195 }, /* VioletRed3 */
- { 139, 34, 82, 7206 }, /* VioletRed4 */
- { 245, 222, 179, 7217 }, /* wheat */
- { 255, 231, 186, 7223 }, /* wheat1 */
- { 238, 216, 174, 7230 }, /* wheat2 */
- { 205, 186, 150, 7237 }, /* wheat3 */
- { 139, 126, 102, 7244 }, /* wheat4 */
- { 255, 255, 255, 7251 }, /* white */
- { 245, 245, 245, 7257 }, /* white smoke */
- { 245, 245, 245, 7269 }, /* WhiteSmoke */
- { 255, 255, 0, 7280 }, /* yellow */
- { 154, 205, 50, 7287 }, /* yellow green */
- { 255, 255, 0, 7300 }, /* yellow1 */
- { 238, 238, 0, 7308 }, /* yellow2 */
- { 205, 205, 0, 7316 }, /* yellow3 */
- { 139, 139, 0, 7324 }, /* yellow4 */
- { 154, 205, 50, 7332 }, /* YellowGreen */
+ {240, 248, 255, 0}, /* alice blue */
+ {240, 248, 255, 11}, /* AliceBlue */
+ {250, 235, 215, 21}, /* antique white */
+ {250, 235, 215, 35}, /* AntiqueWhite */
+ {255, 239, 219, 48}, /* AntiqueWhite1 */
+ {238, 223, 204, 62}, /* AntiqueWhite2 */
+ {205, 192, 176, 76}, /* AntiqueWhite3 */
+ {139, 131, 120, 90}, /* AntiqueWhite4 */
+ {127, 255, 212, 104}, /* aquamarine */
+ {127, 255, 212, 115}, /* aquamarine1 */
+ {118, 238, 198, 127}, /* aquamarine2 */
+ {102, 205, 170, 139}, /* aquamarine3 */
+ {69, 139, 116, 151}, /* aquamarine4 */
+ {240, 255, 255, 163}, /* azure */
+ {240, 255, 255, 169}, /* azure1 */
+ {224, 238, 238, 176}, /* azure2 */
+ {193, 205, 205, 183}, /* azure3 */
+ {131, 139, 139, 190}, /* azure4 */
+ {245, 245, 220, 197}, /* beige */
+ {255, 228, 196, 203}, /* bisque */
+ {255, 228, 196, 210}, /* bisque1 */
+ {238, 213, 183, 218}, /* bisque2 */
+ {205, 183, 158, 226}, /* bisque3 */
+ {139, 125, 107, 234}, /* bisque4 */
+ {0, 0, 0, 242}, /* black */
+ {255, 235, 205, 248}, /* blanched almond */
+ {255, 235, 205, 264}, /* BlanchedAlmond */
+ {0, 0, 255, 279}, /* blue */
+ {138, 43, 226, 284}, /* blue violet */
+ {0, 0, 255, 296}, /* blue1 */
+ {0, 0, 238, 302}, /* blue2 */
+ {0, 0, 205, 308}, /* blue3 */
+ {0, 0, 139, 314}, /* blue4 */
+ {138, 43, 226, 320}, /* BlueViolet */
+ {165, 42, 42, 331}, /* brown */
+ {255, 64, 64, 337}, /* brown1 */
+ {238, 59, 59, 344}, /* brown2 */
+ {205, 51, 51, 351}, /* brown3 */
+ {139, 35, 35, 358}, /* brown4 */
+ {222, 184, 135, 365}, /* burlywood */
+ {255, 211, 155, 375}, /* burlywood1 */
+ {238, 197, 145, 386}, /* burlywood2 */
+ {205, 170, 125, 397}, /* burlywood3 */
+ {139, 115, 85, 408}, /* burlywood4 */
+ {95, 158, 160, 419}, /* cadet blue */
+ {95, 158, 160, 430}, /* CadetBlue */
+ {152, 245, 255, 440}, /* CadetBlue1 */
+ {142, 229, 238, 451}, /* CadetBlue2 */
+ {122, 197, 205, 462}, /* CadetBlue3 */
+ {83, 134, 139, 473}, /* CadetBlue4 */
+ {127, 255, 0, 484}, /* chartreuse */
+ {127, 255, 0, 495}, /* chartreuse1 */
+ {118, 238, 0, 507}, /* chartreuse2 */
+ {102, 205, 0, 519}, /* chartreuse3 */
+ {69, 139, 0, 531}, /* chartreuse4 */
+ {210, 105, 30, 543}, /* chocolate */
+ {255, 127, 36, 553}, /* chocolate1 */
+ {238, 118, 33, 564}, /* chocolate2 */
+ {205, 102, 29, 575}, /* chocolate3 */
+ {139, 69, 19, 586}, /* chocolate4 */
+ {255, 127, 80, 597}, /* coral */
+ {255, 114, 86, 603}, /* coral1 */
+ {238, 106, 80, 610}, /* coral2 */
+ {205, 91, 69, 617}, /* coral3 */
+ {139, 62, 47, 624}, /* coral4 */
+ {100, 149, 237, 631}, /* cornflower blue */
+ {100, 149, 237, 647}, /* CornflowerBlue */
+ {255, 248, 220, 662}, /* cornsilk */
+ {255, 248, 220, 671}, /* cornsilk1 */
+ {238, 232, 205, 681}, /* cornsilk2 */
+ {205, 200, 177, 691}, /* cornsilk3 */
+ {139, 136, 120, 701}, /* cornsilk4 */
+ {0, 255, 255, 711}, /* cyan */
+ {0, 255, 255, 716}, /* cyan1 */
+ {0, 238, 238, 722}, /* cyan2 */
+ {0, 205, 205, 728}, /* cyan3 */
+ {0, 139, 139, 734}, /* cyan4 */
+ {0, 0, 139, 740}, /* dark blue */
+ {0, 139, 139, 750}, /* dark cyan */
+ {184, 134, 11, 760}, /* dark goldenrod */
+ {169, 169, 169, 775}, /* dark gray */
+ {0, 100, 0, 785}, /* dark green */
+ {169, 169, 169, 796}, /* dark grey */
+ {189, 183, 107, 806}, /* dark khaki */
+ {139, 0, 139, 817}, /* dark magenta */
+ {85, 107, 47, 830}, /* dark olive green */
+ {255, 140, 0, 847}, /* dark orange */
+ {153, 50, 204, 859}, /* dark orchid */
+ {139, 0, 0, 871}, /* dark red */
+ {233, 150, 122, 880}, /* dark salmon */
+ {143, 188, 143, 892}, /* dark sea green */
+ {72, 61, 139, 907}, /* dark slate blue */
+ {47, 79, 79, 923}, /* dark slate gray */
+ {47, 79, 79, 939}, /* dark slate grey */
+ {0, 206, 209, 955}, /* dark turquoise */
+ {148, 0, 211, 970}, /* dark violet */
+ {0, 0, 139, 982}, /* DarkBlue */
+ {0, 139, 139, 991}, /* DarkCyan */
+ {184, 134, 11, 1000}, /* DarkGoldenrod */
+ {255, 185, 15, 1014}, /* DarkGoldenrod1 */
+ {238, 173, 14, 1029}, /* DarkGoldenrod2 */
+ {205, 149, 12, 1044}, /* DarkGoldenrod3 */
+ {139, 101, 8, 1059}, /* DarkGoldenrod4 */
+ {169, 169, 169, 1074}, /* DarkGray */
+ {0, 100, 0, 1083}, /* DarkGreen */
+ {169, 169, 169, 1093}, /* DarkGrey */
+ {189, 183, 107, 1102}, /* DarkKhaki */
+ {139, 0, 139, 1112}, /* DarkMagenta */
+ {85, 107, 47, 1124}, /* DarkOliveGreen */
+ {202, 255, 112, 1139}, /* DarkOliveGreen1 */
+ {188, 238, 104, 1155}, /* DarkOliveGreen2 */
+ {162, 205, 90, 1171}, /* DarkOliveGreen3 */
+ {110, 139, 61, 1187}, /* DarkOliveGreen4 */
+ {255, 140, 0, 1203}, /* DarkOrange */
+ {255, 127, 0, 1214}, /* DarkOrange1 */
+ {238, 118, 0, 1226}, /* DarkOrange2 */
+ {205, 102, 0, 1238}, /* DarkOrange3 */
+ {139, 69, 0, 1250}, /* DarkOrange4 */
+ {153, 50, 204, 1262}, /* DarkOrchid */
+ {191, 62, 255, 1273}, /* DarkOrchid1 */
+ {178, 58, 238, 1285}, /* DarkOrchid2 */
+ {154, 50, 205, 1297}, /* DarkOrchid3 */
+ {104, 34, 139, 1309}, /* DarkOrchid4 */
+ {139, 0, 0, 1321}, /* DarkRed */
+ {233, 150, 122, 1329}, /* DarkSalmon */
+ {143, 188, 143, 1340}, /* DarkSeaGreen */
+ {193, 255, 193, 1353}, /* DarkSeaGreen1 */
+ {180, 238, 180, 1367}, /* DarkSeaGreen2 */
+ {155, 205, 155, 1381}, /* DarkSeaGreen3 */
+ {105, 139, 105, 1395}, /* DarkSeaGreen4 */
+ {72, 61, 139, 1409}, /* DarkSlateBlue */
+ {47, 79, 79, 1423}, /* DarkSlateGray */
+ {151, 255, 255, 1437}, /* DarkSlateGray1 */
+ {141, 238, 238, 1452}, /* DarkSlateGray2 */
+ {121, 205, 205, 1467}, /* DarkSlateGray3 */
+ {82, 139, 139, 1482}, /* DarkSlateGray4 */
+ {47, 79, 79, 1497}, /* DarkSlateGrey */
+ {0, 206, 209, 1511}, /* DarkTurquoise */
+ {148, 0, 211, 1525}, /* DarkViolet */
+ {255, 20, 147, 1536}, /* deep pink */
+ {0, 191, 255, 1546}, /* deep sky blue */
+ {255, 20, 147, 1560}, /* DeepPink */
+ {255, 20, 147, 1569}, /* DeepPink1 */
+ {238, 18, 137, 1579}, /* DeepPink2 */
+ {205, 16, 118, 1589}, /* DeepPink3 */
+ {139, 10, 80, 1599}, /* DeepPink4 */
+ {0, 191, 255, 1609}, /* DeepSkyBlue */
+ {0, 191, 255, 1621}, /* DeepSkyBlue1 */
+ {0, 178, 238, 1634}, /* DeepSkyBlue2 */
+ {0, 154, 205, 1647}, /* DeepSkyBlue3 */
+ {0, 104, 139, 1660}, /* DeepSkyBlue4 */
+ {105, 105, 105, 1673}, /* dim gray */
+ {105, 105, 105, 1682}, /* dim grey */
+ {105, 105, 105, 1691}, /* DimGray */
+ {105, 105, 105, 1699}, /* DimGrey */
+ {30, 144, 255, 1707}, /* dodger blue */
+ {30, 144, 255, 1719}, /* DodgerBlue */
+ {30, 144, 255, 1730}, /* DodgerBlue1 */
+ {28, 134, 238, 1742}, /* DodgerBlue2 */
+ {24, 116, 205, 1754}, /* DodgerBlue3 */
+ {16, 78, 139, 1766}, /* DodgerBlue4 */
+ {178, 34, 34, 1778}, /* firebrick */
+ {255, 48, 48, 1788}, /* firebrick1 */
+ {238, 44, 44, 1799}, /* firebrick2 */
+ {205, 38, 38, 1810}, /* firebrick3 */
+ {139, 26, 26, 1821}, /* firebrick4 */
+ {255, 250, 240, 1832}, /* floral white */
+ {255, 250, 240, 1845}, /* FloralWhite */
+ {34, 139, 34, 1857}, /* forest green */
+ {34, 139, 34, 1870}, /* ForestGreen */
+ {220, 220, 220, 1882}, /* gainsboro */
+ {248, 248, 255, 1892}, /* ghost white */
+ {248, 248, 255, 1904}, /* GhostWhite */
+ {255, 215, 0, 1915}, /* gold */
+ {255, 215, 0, 1920}, /* gold1 */
+ {238, 201, 0, 1926}, /* gold2 */
+ {205, 173, 0, 1932}, /* gold3 */
+ {139, 117, 0, 1938}, /* gold4 */
+ {218, 165, 32, 1944}, /* goldenrod */
+ {255, 193, 37, 1954}, /* goldenrod1 */
+ {238, 180, 34, 1965}, /* goldenrod2 */
+ {205, 155, 29, 1976}, /* goldenrod3 */
+ {139, 105, 20, 1987}, /* goldenrod4 */
+ {190, 190, 190, 1998}, /* gray */
+ {0, 0, 0, 2003}, /* gray0 */
+ {3, 3, 3, 2009}, /* gray1 */
+ {26, 26, 26, 2015}, /* gray10 */
+ {255, 255, 255, 2022}, /* gray100 */
+ {28, 28, 28, 2030}, /* gray11 */
+ {31, 31, 31, 2037}, /* gray12 */
+ {33, 33, 33, 2044}, /* gray13 */
+ {36, 36, 36, 2051}, /* gray14 */
+ {38, 38, 38, 2058}, /* gray15 */
+ {41, 41, 41, 2065}, /* gray16 */
+ {43, 43, 43, 2072}, /* gray17 */
+ {46, 46, 46, 2079}, /* gray18 */
+ {48, 48, 48, 2086}, /* gray19 */
+ {5, 5, 5, 2093}, /* gray2 */
+ {51, 51, 51, 2099}, /* gray20 */
+ {54, 54, 54, 2106}, /* gray21 */
+ {56, 56, 56, 2113}, /* gray22 */
+ {59, 59, 59, 2120}, /* gray23 */
+ {61, 61, 61, 2127}, /* gray24 */
+ {64, 64, 64, 2134}, /* gray25 */
+ {66, 66, 66, 2141}, /* gray26 */
+ {69, 69, 69, 2148}, /* gray27 */
+ {71, 71, 71, 2155}, /* gray28 */
+ {74, 74, 74, 2162}, /* gray29 */
+ {8, 8, 8, 2169}, /* gray3 */
+ {77, 77, 77, 2175}, /* gray30 */
+ {79, 79, 79, 2182}, /* gray31 */
+ {82, 82, 82, 2189}, /* gray32 */
+ {84, 84, 84, 2196}, /* gray33 */
+ {87, 87, 87, 2203}, /* gray34 */
+ {89, 89, 89, 2210}, /* gray35 */
+ {92, 92, 92, 2217}, /* gray36 */
+ {94, 94, 94, 2224}, /* gray37 */
+ {97, 97, 97, 2231}, /* gray38 */
+ {99, 99, 99, 2238}, /* gray39 */
+ {10, 10, 10, 2245}, /* gray4 */
+ {102, 102, 102, 2251}, /* gray40 */
+ {105, 105, 105, 2258}, /* gray41 */
+ {107, 107, 107, 2265}, /* gray42 */
+ {110, 110, 110, 2272}, /* gray43 */
+ {112, 112, 112, 2279}, /* gray44 */
+ {115, 115, 115, 2286}, /* gray45 */
+ {117, 117, 117, 2293}, /* gray46 */
+ {120, 120, 120, 2300}, /* gray47 */
+ {122, 122, 122, 2307}, /* gray48 */
+ {125, 125, 125, 2314}, /* gray49 */
+ {13, 13, 13, 2321}, /* gray5 */
+ {127, 127, 127, 2327}, /* gray50 */
+ {130, 130, 130, 2334}, /* gray51 */
+ {133, 133, 133, 2341}, /* gray52 */
+ {135, 135, 135, 2348}, /* gray53 */
+ {138, 138, 138, 2355}, /* gray54 */
+ {140, 140, 140, 2362}, /* gray55 */
+ {143, 143, 143, 2369}, /* gray56 */
+ {145, 145, 145, 2376}, /* gray57 */
+ {148, 148, 148, 2383}, /* gray58 */
+ {150, 150, 150, 2390}, /* gray59 */
+ {15, 15, 15, 2397}, /* gray6 */
+ {153, 153, 153, 2403}, /* gray60 */
+ {156, 156, 156, 2410}, /* gray61 */
+ {158, 158, 158, 2417}, /* gray62 */
+ {161, 161, 161, 2424}, /* gray63 */
+ {163, 163, 163, 2431}, /* gray64 */
+ {166, 166, 166, 2438}, /* gray65 */
+ {168, 168, 168, 2445}, /* gray66 */
+ {171, 171, 171, 2452}, /* gray67 */
+ {173, 173, 173, 2459}, /* gray68 */
+ {176, 176, 176, 2466}, /* gray69 */
+ {18, 18, 18, 2473}, /* gray7 */
+ {179, 179, 179, 2479}, /* gray70 */
+ {181, 181, 181, 2486}, /* gray71 */
+ {184, 184, 184, 2493}, /* gray72 */
+ {186, 186, 186, 2500}, /* gray73 */
+ {189, 189, 189, 2507}, /* gray74 */
+ {191, 191, 191, 2514}, /* gray75 */
+ {194, 194, 194, 2521}, /* gray76 */
+ {196, 196, 196, 2528}, /* gray77 */
+ {199, 199, 199, 2535}, /* gray78 */
+ {201, 201, 201, 2542}, /* gray79 */
+ {20, 20, 20, 2549}, /* gray8 */
+ {204, 204, 204, 2555}, /* gray80 */
+ {207, 207, 207, 2562}, /* gray81 */
+ {209, 209, 209, 2569}, /* gray82 */
+ {212, 212, 212, 2576}, /* gray83 */
+ {214, 214, 214, 2583}, /* gray84 */
+ {217, 217, 217, 2590}, /* gray85 */
+ {219, 219, 219, 2597}, /* gray86 */
+ {222, 222, 222, 2604}, /* gray87 */
+ {224, 224, 224, 2611}, /* gray88 */
+ {227, 227, 227, 2618}, /* gray89 */
+ {23, 23, 23, 2625}, /* gray9 */
+ {229, 229, 229, 2631}, /* gray90 */
+ {232, 232, 232, 2638}, /* gray91 */
+ {235, 235, 235, 2645}, /* gray92 */
+ {237, 237, 237, 2652}, /* gray93 */
+ {240, 240, 240, 2659}, /* gray94 */
+ {242, 242, 242, 2666}, /* gray95 */
+ {245, 245, 245, 2673}, /* gray96 */
+ {247, 247, 247, 2680}, /* gray97 */
+ {250, 250, 250, 2687}, /* gray98 */
+ {252, 252, 252, 2694}, /* gray99 */
+ {0, 255, 0, 2701}, /* green */
+ {173, 255, 47, 2707}, /* green yellow */
+ {0, 255, 0, 2720}, /* green1 */
+ {0, 238, 0, 2727}, /* green2 */
+ {0, 205, 0, 2734}, /* green3 */
+ {0, 139, 0, 2741}, /* green4 */
+ {173, 255, 47, 2748}, /* GreenYellow */
+ {190, 190, 190, 2760}, /* grey */
+ {0, 0, 0, 2765}, /* grey0 */
+ {3, 3, 3, 2771}, /* grey1 */
+ {26, 26, 26, 2777}, /* grey10 */
+ {255, 255, 255, 2784}, /* grey100 */
+ {28, 28, 28, 2792}, /* grey11 */
+ {31, 31, 31, 2799}, /* grey12 */
+ {33, 33, 33, 2806}, /* grey13 */
+ {36, 36, 36, 2813}, /* grey14 */
+ {38, 38, 38, 2820}, /* grey15 */
+ {41, 41, 41, 2827}, /* grey16 */
+ {43, 43, 43, 2834}, /* grey17 */
+ {46, 46, 46, 2841}, /* grey18 */
+ {48, 48, 48, 2848}, /* grey19 */
+ {5, 5, 5, 2855}, /* grey2 */
+ {51, 51, 51, 2861}, /* grey20 */
+ {54, 54, 54, 2868}, /* grey21 */
+ {56, 56, 56, 2875}, /* grey22 */
+ {59, 59, 59, 2882}, /* grey23 */
+ {61, 61, 61, 2889}, /* grey24 */
+ {64, 64, 64, 2896}, /* grey25 */
+ {66, 66, 66, 2903}, /* grey26 */
+ {69, 69, 69, 2910}, /* grey27 */
+ {71, 71, 71, 2917}, /* grey28 */
+ {74, 74, 74, 2924}, /* grey29 */
+ {8, 8, 8, 2931}, /* grey3 */
+ {77, 77, 77, 2937}, /* grey30 */
+ {79, 79, 79, 2944}, /* grey31 */
+ {82, 82, 82, 2951}, /* grey32 */
+ {84, 84, 84, 2958}, /* grey33 */
+ {87, 87, 87, 2965}, /* grey34 */
+ {89, 89, 89, 2972}, /* grey35 */
+ {92, 92, 92, 2979}, /* grey36 */
+ {94, 94, 94, 2986}, /* grey37 */
+ {97, 97, 97, 2993}, /* grey38 */
+ {99, 99, 99, 3000}, /* grey39 */
+ {10, 10, 10, 3007}, /* grey4 */
+ {102, 102, 102, 3013}, /* grey40 */
+ {105, 105, 105, 3020}, /* grey41 */
+ {107, 107, 107, 3027}, /* grey42 */
+ {110, 110, 110, 3034}, /* grey43 */
+ {112, 112, 112, 3041}, /* grey44 */
+ {115, 115, 115, 3048}, /* grey45 */
+ {117, 117, 117, 3055}, /* grey46 */
+ {120, 120, 120, 3062}, /* grey47 */
+ {122, 122, 122, 3069}, /* grey48 */
+ {125, 125, 125, 3076}, /* grey49 */
+ {13, 13, 13, 3083}, /* grey5 */
+ {127, 127, 127, 3089}, /* grey50 */
+ {130, 130, 130, 3096}, /* grey51 */
+ {133, 133, 133, 3103}, /* grey52 */
+ {135, 135, 135, 3110}, /* grey53 */
+ {138, 138, 138, 3117}, /* grey54 */
+ {140, 140, 140, 3124}, /* grey55 */
+ {143, 143, 143, 3131}, /* grey56 */
+ {145, 145, 145, 3138}, /* grey57 */
+ {148, 148, 148, 3145}, /* grey58 */
+ {150, 150, 150, 3152}, /* grey59 */
+ {15, 15, 15, 3159}, /* grey6 */
+ {153, 153, 153, 3165}, /* grey60 */
+ {156, 156, 156, 3172}, /* grey61 */
+ {158, 158, 158, 3179}, /* grey62 */
+ {161, 161, 161, 3186}, /* grey63 */
+ {163, 163, 163, 3193}, /* grey64 */
+ {166, 166, 166, 3200}, /* grey65 */
+ {168, 168, 168, 3207}, /* grey66 */
+ {171, 171, 171, 3214}, /* grey67 */
+ {173, 173, 173, 3221}, /* grey68 */
+ {176, 176, 176, 3228}, /* grey69 */
+ {18, 18, 18, 3235}, /* grey7 */
+ {179, 179, 179, 3241}, /* grey70 */
+ {181, 181, 181, 3248}, /* grey71 */
+ {184, 184, 184, 3255}, /* grey72 */
+ {186, 186, 186, 3262}, /* grey73 */
+ {189, 189, 189, 3269}, /* grey74 */
+ {191, 191, 191, 3276}, /* grey75 */
+ {194, 194, 194, 3283}, /* grey76 */
+ {196, 196, 196, 3290}, /* grey77 */
+ {199, 199, 199, 3297}, /* grey78 */
+ {201, 201, 201, 3304}, /* grey79 */
+ {20, 20, 20, 3311}, /* grey8 */
+ {204, 204, 204, 3317}, /* grey80 */
+ {207, 207, 207, 3324}, /* grey81 */
+ {209, 209, 209, 3331}, /* grey82 */
+ {212, 212, 212, 3338}, /* grey83 */
+ {214, 214, 214, 3345}, /* grey84 */
+ {217, 217, 217, 3352}, /* grey85 */
+ {219, 219, 219, 3359}, /* grey86 */
+ {222, 222, 222, 3366}, /* grey87 */
+ {224, 224, 224, 3373}, /* grey88 */
+ {227, 227, 227, 3380}, /* grey89 */
+ {23, 23, 23, 3387}, /* grey9 */
+ {229, 229, 229, 3393}, /* grey90 */
+ {232, 232, 232, 3400}, /* grey91 */
+ {235, 235, 235, 3407}, /* grey92 */
+ {237, 237, 237, 3414}, /* grey93 */
+ {240, 240, 240, 3421}, /* grey94 */
+ {242, 242, 242, 3428}, /* grey95 */
+ {245, 245, 245, 3435}, /* grey96 */
+ {247, 247, 247, 3442}, /* grey97 */
+ {250, 250, 250, 3449}, /* grey98 */
+ {252, 252, 252, 3456}, /* grey99 */
+ {240, 255, 240, 3463}, /* honeydew */
+ {240, 255, 240, 3472}, /* honeydew1 */
+ {224, 238, 224, 3482}, /* honeydew2 */
+ {193, 205, 193, 3492}, /* honeydew3 */
+ {131, 139, 131, 3502}, /* honeydew4 */
+ {255, 105, 180, 3512}, /* hot pink */
+ {255, 105, 180, 3521}, /* HotPink */
+ {255, 110, 180, 3529}, /* HotPink1 */
+ {238, 106, 167, 3538}, /* HotPink2 */
+ {205, 96, 144, 3547}, /* HotPink3 */
+ {139, 58, 98, 3556}, /* HotPink4 */
+ {205, 92, 92, 3565}, /* indian red */
+ {205, 92, 92, 3576}, /* IndianRed */
+ {255, 106, 106, 3586}, /* IndianRed1 */
+ {238, 99, 99, 3597}, /* IndianRed2 */
+ {205, 85, 85, 3608}, /* IndianRed3 */
+ {139, 58, 58, 3619}, /* IndianRed4 */
+ {255, 255, 240, 3630}, /* ivory */
+ {255, 255, 240, 3636}, /* ivory1 */
+ {238, 238, 224, 3643}, /* ivory2 */
+ {205, 205, 193, 3650}, /* ivory3 */
+ {139, 139, 131, 3657}, /* ivory4 */
+ {240, 230, 140, 3664}, /* khaki */
+ {255, 246, 143, 3670}, /* khaki1 */
+ {238, 230, 133, 3677}, /* khaki2 */
+ {205, 198, 115, 3684}, /* khaki3 */
+ {139, 134, 78, 3691}, /* khaki4 */
+ {230, 230, 250, 3698}, /* lavender */
+ {255, 240, 245, 3707}, /* lavender blush */
+ {255, 240, 245, 3722}, /* LavenderBlush */
+ {255, 240, 245, 3736}, /* LavenderBlush1 */
+ {238, 224, 229, 3751}, /* LavenderBlush2 */
+ {205, 193, 197, 3766}, /* LavenderBlush3 */
+ {139, 131, 134, 3781}, /* LavenderBlush4 */
+ {124, 252, 0, 3796}, /* lawn green */
+ {124, 252, 0, 3807}, /* LawnGreen */
+ {255, 250, 205, 3817}, /* lemon chiffon */
+ {255, 250, 205, 3831}, /* LemonChiffon */
+ {255, 250, 205, 3844}, /* LemonChiffon1 */
+ {238, 233, 191, 3858}, /* LemonChiffon2 */
+ {205, 201, 165, 3872}, /* LemonChiffon3 */
+ {139, 137, 112, 3886}, /* LemonChiffon4 */
+ {173, 216, 230, 3900}, /* light blue */
+ {240, 128, 128, 3911}, /* light coral */
+ {224, 255, 255, 3923}, /* light cyan */
+ {238, 221, 130, 3934}, /* light goldenrod */
+ {250, 250, 210, 3950}, /* light goldenrod yellow */
+ {211, 211, 211, 3973}, /* light gray */
+ {144, 238, 144, 3984}, /* light green */
+ {211, 211, 211, 3996}, /* light grey */
+ {255, 182, 193, 4007}, /* light pink */
+ {255, 160, 122, 4018}, /* light salmon */
+ {32, 178, 170, 4031}, /* light sea green */
+ {135, 206, 250, 4047}, /* light sky blue */
+ {132, 112, 255, 4062}, /* light slate blue */
+ {119, 136, 153, 4079}, /* light slate gray */
+ {119, 136, 153, 4096}, /* light slate grey */
+ {176, 196, 222, 4113}, /* light steel blue */
+ {255, 255, 224, 4130}, /* light yellow */
+ {173, 216, 230, 4143}, /* LightBlue */
+ {191, 239, 255, 4153}, /* LightBlue1 */
+ {178, 223, 238, 4164}, /* LightBlue2 */
+ {154, 192, 205, 4175}, /* LightBlue3 */
+ {104, 131, 139, 4186}, /* LightBlue4 */
+ {240, 128, 128, 4197}, /* LightCoral */
+ {224, 255, 255, 4208}, /* LightCyan */
+ {224, 255, 255, 4218}, /* LightCyan1 */
+ {209, 238, 238, 4229}, /* LightCyan2 */
+ {180, 205, 205, 4240}, /* LightCyan3 */
+ {122, 139, 139, 4251}, /* LightCyan4 */
+ {238, 221, 130, 4262}, /* LightGoldenrod */
+ {255, 236, 139, 4277}, /* LightGoldenrod1 */
+ {238, 220, 130, 4293}, /* LightGoldenrod2 */
+ {205, 190, 112, 4309}, /* LightGoldenrod3 */
+ {139, 129, 76, 4325}, /* LightGoldenrod4 */
+ {250, 250, 210, 4341}, /* LightGoldenrodYellow */
+ {211, 211, 211, 4362}, /* LightGray */
+ {144, 238, 144, 4372}, /* LightGreen */
+ {211, 211, 211, 4383}, /* LightGrey */
+ {255, 182, 193, 4393}, /* LightPink */
+ {255, 174, 185, 4403}, /* LightPink1 */
+ {238, 162, 173, 4414}, /* LightPink2 */
+ {205, 140, 149, 4425}, /* LightPink3 */
+ {139, 95, 101, 4436}, /* LightPink4 */
+ {255, 160, 122, 4447}, /* LightSalmon */
+ {255, 160, 122, 4459}, /* LightSalmon1 */
+ {238, 149, 114, 4472}, /* LightSalmon2 */
+ {205, 129, 98, 4485}, /* LightSalmon3 */
+ {139, 87, 66, 4498}, /* LightSalmon4 */
+ {32, 178, 170, 4511}, /* LightSeaGreen */
+ {135, 206, 250, 4525}, /* LightSkyBlue */
+ {176, 226, 255, 4538}, /* LightSkyBlue1 */
+ {164, 211, 238, 4552}, /* LightSkyBlue2 */
+ {141, 182, 205, 4566}, /* LightSkyBlue3 */
+ {96, 123, 139, 4580}, /* LightSkyBlue4 */
+ {132, 112, 255, 4594}, /* LightSlateBlue */
+ {119, 136, 153, 4609}, /* LightSlateGray */
+ {119, 136, 153, 4624}, /* LightSlateGrey */
+ {176, 196, 222, 4639}, /* LightSteelBlue */
+ {202, 225, 255, 4654}, /* LightSteelBlue1 */
+ {188, 210, 238, 4670}, /* LightSteelBlue2 */
+ {162, 181, 205, 4686}, /* LightSteelBlue3 */
+ {110, 123, 139, 4702}, /* LightSteelBlue4 */
+ {255, 255, 224, 4718}, /* LightYellow */
+ {255, 255, 224, 4730}, /* LightYellow1 */
+ {238, 238, 209, 4743}, /* LightYellow2 */
+ {205, 205, 180, 4756}, /* LightYellow3 */
+ {139, 139, 122, 4769}, /* LightYellow4 */
+ {50, 205, 50, 4782}, /* lime green */
+ {50, 205, 50, 4793}, /* LimeGreen */
+ {250, 240, 230, 4803}, /* linen */
+ {255, 0, 255, 4809}, /* magenta */
+ {255, 0, 255, 4817}, /* magenta1 */
+ {238, 0, 238, 4826}, /* magenta2 */
+ {205, 0, 205, 4835}, /* magenta3 */
+ {139, 0, 139, 4844}, /* magenta4 */
+ {176, 48, 96, 4853}, /* maroon */
+ {255, 52, 179, 4860}, /* maroon1 */
+ {238, 48, 167, 4868}, /* maroon2 */
+ {205, 41, 144, 4876}, /* maroon3 */
+ {139, 28, 98, 4884}, /* maroon4 */
+ {102, 205, 170, 4892}, /* medium aquamarine */
+ {0, 0, 205, 4910}, /* medium blue */
+ {186, 85, 211, 4922}, /* medium orchid */
+ {147, 112, 219, 4936}, /* medium purple */
+ {60, 179, 113, 4950}, /* medium sea green */
+ {123, 104, 238, 4967}, /* medium slate blue */
+ {0, 250, 154, 4985}, /* medium spring green */
+ {72, 209, 204, 5005}, /* medium turquoise */
+ {199, 21, 133, 5022}, /* medium violet red */
+ {102, 205, 170, 5040}, /* MediumAquamarine */
+ {0, 0, 205, 5057}, /* MediumBlue */
+ {186, 85, 211, 5068}, /* MediumOrchid */
+ {224, 102, 255, 5081}, /* MediumOrchid1 */
+ {209, 95, 238, 5095}, /* MediumOrchid2 */
+ {180, 82, 205, 5109}, /* MediumOrchid3 */
+ {122, 55, 139, 5123}, /* MediumOrchid4 */
+ {147, 112, 219, 5137}, /* MediumPurple */
+ {171, 130, 255, 5150}, /* MediumPurple1 */
+ {159, 121, 238, 5164}, /* MediumPurple2 */
+ {137, 104, 205, 5178}, /* MediumPurple3 */
+ {93, 71, 139, 5192}, /* MediumPurple4 */
+ {60, 179, 113, 5206}, /* MediumSeaGreen */
+ {123, 104, 238, 5221}, /* MediumSlateBlue */
+ {0, 250, 154, 5237}, /* MediumSpringGreen */
+ {72, 209, 204, 5255}, /* MediumTurquoise */
+ {199, 21, 133, 5271}, /* MediumVioletRed */
+ {25, 25, 112, 5287}, /* midnight blue */
+ {25, 25, 112, 5301}, /* MidnightBlue */
+ {245, 255, 250, 5314}, /* mint cream */
+ {245, 255, 250, 5325}, /* MintCream */
+ {255, 228, 225, 5335}, /* misty rose */
+ {255, 228, 225, 5346}, /* MistyRose */
+ {255, 228, 225, 5356}, /* MistyRose1 */
+ {238, 213, 210, 5367}, /* MistyRose2 */
+ {205, 183, 181, 5378}, /* MistyRose3 */
+ {139, 125, 123, 5389}, /* MistyRose4 */
+ {255, 228, 181, 5400}, /* moccasin */
+ {255, 222, 173, 5409}, /* navajo white */
+ {255, 222, 173, 5422}, /* NavajoWhite */
+ {255, 222, 173, 5434}, /* NavajoWhite1 */
+ {238, 207, 161, 5447}, /* NavajoWhite2 */
+ {205, 179, 139, 5460}, /* NavajoWhite3 */
+ {139, 121, 94, 5473}, /* NavajoWhite4 */
+ {0, 0, 128, 5486}, /* navy */
+ {0, 0, 128, 5491}, /* navy blue */
+ {0, 0, 128, 5501}, /* NavyBlue */
+ {253, 245, 230, 5510}, /* old lace */
+ {253, 245, 230, 5519}, /* OldLace */
+ {107, 142, 35, 5527}, /* olive drab */
+ {107, 142, 35, 5538}, /* OliveDrab */
+ {192, 255, 62, 5548}, /* OliveDrab1 */
+ {179, 238, 58, 5559}, /* OliveDrab2 */
+ {154, 205, 50, 5570}, /* OliveDrab3 */
+ {105, 139, 34, 5581}, /* OliveDrab4 */
+ {255, 165, 0, 5592}, /* orange */
+ {255, 69, 0, 5599}, /* orange red */
+ {255, 165, 0, 5610}, /* orange1 */
+ {238, 154, 0, 5618}, /* orange2 */
+ {205, 133, 0, 5626}, /* orange3 */
+ {139, 90, 0, 5634}, /* orange4 */
+ {255, 69, 0, 5642}, /* OrangeRed */
+ {255, 69, 0, 5652}, /* OrangeRed1 */
+ {238, 64, 0, 5663}, /* OrangeRed2 */
+ {205, 55, 0, 5674}, /* OrangeRed3 */
+ {139, 37, 0, 5685}, /* OrangeRed4 */
+ {218, 112, 214, 5696}, /* orchid */
+ {255, 131, 250, 5703}, /* orchid1 */
+ {238, 122, 233, 5711}, /* orchid2 */
+ {205, 105, 201, 5719}, /* orchid3 */
+ {139, 71, 137, 5727}, /* orchid4 */
+ {238, 232, 170, 5735}, /* pale goldenrod */
+ {152, 251, 152, 5750}, /* pale green */
+ {175, 238, 238, 5761}, /* pale turquoise */
+ {219, 112, 147, 5776}, /* pale violet red */
+ {238, 232, 170, 5792}, /* PaleGoldenrod */
+ {152, 251, 152, 5806}, /* PaleGreen */
+ {154, 255, 154, 5816}, /* PaleGreen1 */
+ {144, 238, 144, 5827}, /* PaleGreen2 */
+ {124, 205, 124, 5838}, /* PaleGreen3 */
+ {84, 139, 84, 5849}, /* PaleGreen4 */
+ {175, 238, 238, 5860}, /* PaleTurquoise */
+ {187, 255, 255, 5874}, /* PaleTurquoise1 */
+ {174, 238, 238, 5889}, /* PaleTurquoise2 */
+ {150, 205, 205, 5904}, /* PaleTurquoise3 */
+ {102, 139, 139, 5919}, /* PaleTurquoise4 */
+ {219, 112, 147, 5934}, /* PaleVioletRed */
+ {255, 130, 171, 5948}, /* PaleVioletRed1 */
+ {238, 121, 159, 5963}, /* PaleVioletRed2 */
+ {205, 104, 137, 5978}, /* PaleVioletRed3 */
+ {139, 71, 93, 5993}, /* PaleVioletRed4 */
+ {255, 239, 213, 6008}, /* papaya whip */
+ {255, 239, 213, 6020}, /* PapayaWhip */
+ {255, 218, 185, 6031}, /* peach puff */
+ {255, 218, 185, 6042}, /* PeachPuff */
+ {255, 218, 185, 6052}, /* PeachPuff1 */
+ {238, 203, 173, 6063}, /* PeachPuff2 */
+ {205, 175, 149, 6074}, /* PeachPuff3 */
+ {139, 119, 101, 6085}, /* PeachPuff4 */
+ {205, 133, 63, 6096}, /* peru */
+ {255, 192, 203, 6101}, /* pink */
+ {255, 181, 197, 6106}, /* pink1 */
+ {238, 169, 184, 6112}, /* pink2 */
+ {205, 145, 158, 6118}, /* pink3 */
+ {139, 99, 108, 6124}, /* pink4 */
+ {221, 160, 221, 6130}, /* plum */
+ {255, 187, 255, 6135}, /* plum1 */
+ {238, 174, 238, 6141}, /* plum2 */
+ {205, 150, 205, 6147}, /* plum3 */
+ {139, 102, 139, 6153}, /* plum4 */
+ {176, 224, 230, 6159}, /* powder blue */
+ {176, 224, 230, 6171}, /* PowderBlue */
+ {160, 32, 240, 6182}, /* purple */
+ {155, 48, 255, 6189}, /* purple1 */
+ {145, 44, 238, 6197}, /* purple2 */
+ {125, 38, 205, 6205}, /* purple3 */
+ {85, 26, 139, 6213}, /* purple4 */
+ {255, 0, 0, 6221}, /* red */
+ {255, 0, 0, 6225}, /* red1 */
+ {238, 0, 0, 6230}, /* red2 */
+ {205, 0, 0, 6235}, /* red3 */
+ {139, 0, 0, 6240}, /* red4 */
+ {188, 143, 143, 6245}, /* rosy brown */
+ {188, 143, 143, 6256}, /* RosyBrown */
+ {255, 193, 193, 6266}, /* RosyBrown1 */
+ {238, 180, 180, 6277}, /* RosyBrown2 */
+ {205, 155, 155, 6288}, /* RosyBrown3 */
+ {139, 105, 105, 6299}, /* RosyBrown4 */
+ {65, 105, 225, 6310}, /* royal blue */
+ {65, 105, 225, 6321}, /* RoyalBlue */
+ {72, 118, 255, 6331}, /* RoyalBlue1 */
+ {67, 110, 238, 6342}, /* RoyalBlue2 */
+ {58, 95, 205, 6353}, /* RoyalBlue3 */
+ {39, 64, 139, 6364}, /* RoyalBlue4 */
+ {139, 69, 19, 6375}, /* saddle brown */
+ {139, 69, 19, 6388}, /* SaddleBrown */
+ {250, 128, 114, 6400}, /* salmon */
+ {255, 140, 105, 6407}, /* salmon1 */
+ {238, 130, 98, 6415}, /* salmon2 */
+ {205, 112, 84, 6423}, /* salmon3 */
+ {139, 76, 57, 6431}, /* salmon4 */
+ {244, 164, 96, 6439}, /* sandy brown */
+ {244, 164, 96, 6451}, /* SandyBrown */
+ {46, 139, 87, 6462}, /* sea green */
+ {46, 139, 87, 6472}, /* SeaGreen */
+ {84, 255, 159, 6481}, /* SeaGreen1 */
+ {78, 238, 148, 6491}, /* SeaGreen2 */
+ {67, 205, 128, 6501}, /* SeaGreen3 */
+ {46, 139, 87, 6511}, /* SeaGreen4 */
+ {255, 245, 238, 6521}, /* seashell */
+ {255, 245, 238, 6530}, /* seashell1 */
+ {238, 229, 222, 6540}, /* seashell2 */
+ {205, 197, 191, 6550}, /* seashell3 */
+ {139, 134, 130, 6560}, /* seashell4 */
+ {160, 82, 45, 6570}, /* sienna */
+ {255, 130, 71, 6577}, /* sienna1 */
+ {238, 121, 66, 6585}, /* sienna2 */
+ {205, 104, 57, 6593}, /* sienna3 */
+ {139, 71, 38, 6601}, /* sienna4 */
+ {135, 206, 235, 6609}, /* sky blue */
+ {135, 206, 235, 6618}, /* SkyBlue */
+ {135, 206, 255, 6626}, /* SkyBlue1 */
+ {126, 192, 238, 6635}, /* SkyBlue2 */
+ {108, 166, 205, 6644}, /* SkyBlue3 */
+ {74, 112, 139, 6653}, /* SkyBlue4 */
+ {106, 90, 205, 6662}, /* slate blue */
+ {112, 128, 144, 6673}, /* slate gray */
+ {112, 128, 144, 6684}, /* slate grey */
+ {106, 90, 205, 6695}, /* SlateBlue */
+ {131, 111, 255, 6705}, /* SlateBlue1 */
+ {122, 103, 238, 6716}, /* SlateBlue2 */
+ {105, 89, 205, 6727}, /* SlateBlue3 */
+ {71, 60, 139, 6738}, /* SlateBlue4 */
+ {112, 128, 144, 6749}, /* SlateGray */
+ {198, 226, 255, 6759}, /* SlateGray1 */
+ {185, 211, 238, 6770}, /* SlateGray2 */
+ {159, 182, 205, 6781}, /* SlateGray3 */
+ {108, 123, 139, 6792}, /* SlateGray4 */
+ {112, 128, 144, 6803}, /* SlateGrey */
+ {255, 250, 250, 6813}, /* snow */
+ {255, 250, 250, 6818}, /* snow1 */
+ {238, 233, 233, 6824}, /* snow2 */
+ {205, 201, 201, 6830}, /* snow3 */
+ {139, 137, 137, 6836}, /* snow4 */
+ {0, 255, 127, 6842}, /* spring green */
+ {0, 255, 127, 6855}, /* SpringGreen */
+ {0, 255, 127, 6867}, /* SpringGreen1 */
+ {0, 238, 118, 6880}, /* SpringGreen2 */
+ {0, 205, 102, 6893}, /* SpringGreen3 */
+ {0, 139, 69, 6906}, /* SpringGreen4 */
+ {70, 130, 180, 6919}, /* steel blue */
+ {70, 130, 180, 6930}, /* SteelBlue */
+ {99, 184, 255, 6940}, /* SteelBlue1 */
+ {92, 172, 238, 6951}, /* SteelBlue2 */
+ {79, 148, 205, 6962}, /* SteelBlue3 */
+ {54, 100, 139, 6973}, /* SteelBlue4 */
+ {210, 180, 140, 6984}, /* tan */
+ {255, 165, 79, 6988}, /* tan1 */
+ {238, 154, 73, 6993}, /* tan2 */
+ {205, 133, 63, 6998}, /* tan3 */
+ {139, 90, 43, 7003}, /* tan4 */
+ {216, 191, 216, 7008}, /* thistle */
+ {255, 225, 255, 7016}, /* thistle1 */
+ {238, 210, 238, 7025}, /* thistle2 */
+ {205, 181, 205, 7034}, /* thistle3 */
+ {139, 123, 139, 7043}, /* thistle4 */
+ {255, 99, 71, 7052}, /* tomato */
+ {255, 99, 71, 7059}, /* tomato1 */
+ {238, 92, 66, 7067}, /* tomato2 */
+ {205, 79, 57, 7075}, /* tomato3 */
+ {139, 54, 38, 7083}, /* tomato4 */
+ {64, 224, 208, 7091}, /* turquoise */
+ {0, 245, 255, 7101}, /* turquoise1 */
+ {0, 229, 238, 7112}, /* turquoise2 */
+ {0, 197, 205, 7123}, /* turquoise3 */
+ {0, 134, 139, 7134}, /* turquoise4 */
+ {238, 130, 238, 7145}, /* violet */
+ {208, 32, 144, 7152}, /* violet red */
+ {208, 32, 144, 7163}, /* VioletRed */
+ {255, 62, 150, 7173}, /* VioletRed1 */
+ {238, 58, 140, 7184}, /* VioletRed2 */
+ {205, 50, 120, 7195}, /* VioletRed3 */
+ {139, 34, 82, 7206}, /* VioletRed4 */
+ {245, 222, 179, 7217}, /* wheat */
+ {255, 231, 186, 7223}, /* wheat1 */
+ {238, 216, 174, 7230}, /* wheat2 */
+ {205, 186, 150, 7237}, /* wheat3 */
+ {139, 126, 102, 7244}, /* wheat4 */
+ {255, 255, 255, 7251}, /* white */
+ {245, 245, 245, 7257}, /* white smoke */
+ {245, 245, 245, 7269}, /* WhiteSmoke */
+ {255, 255, 0, 7280}, /* yellow */
+ {154, 205, 50, 7287}, /* yellow green */
+ {255, 255, 0, 7300}, /* yellow1 */
+ {238, 238, 0, 7308}, /* yellow2 */
+ {205, 205, 0, 7316}, /* yellow3 */
+ {139, 139, 0, 7324}, /* yellow4 */
+ {154, 205, 50, 7332}, /* YellowGreen */
};
#define NUM_BUILTIN_COLORS (sizeof (BuiltinColors) / sizeof (BuiltinColors[0]))
Bool
-OsLookupColor(int screen,
- char *name,
- unsigned int len,
- unsigned short *pred,
- unsigned short *pgreen,
- unsigned short *pblue)
+OsLookupColor(int screen,
+ char *name,
+ unsigned int len,
+ unsigned short *pred,
+ unsigned short *pgreen, unsigned short *pblue)
{
- const BuiltinColor *c;
- int low, mid, high;
- int r;
+ const BuiltinColor *c;
+ int low, mid, high;
+ int r;
low = 0;
high = NUM_BUILTIN_COLORS - 1;
- while (high >= low)
- {
- mid = (low + high) / 2;
- c = &BuiltinColors[mid];
- r = strncasecmp (&BuiltinColorNames[c->name], name, len);
- if (r == 0 && len == strlen (&BuiltinColorNames[c->name]))
- {
- *pred = c->red * 0x101;
- *pgreen = c->green * 0x101;
- *pblue = c->blue * 0x101;
- return TRUE;
- }
- if (r < 0)
- low = mid + 1;
- else
- high = mid - 1;
+ while (high >= low) {
+ mid = (low + high) / 2;
+ c = &BuiltinColors[mid];
+ r = strncasecmp(&BuiltinColorNames[c->name], name, len);
+ if (r == 0 && len == strlen(&BuiltinColorNames[c->name])) {
+ *pred = c->red * 0x101;
+ *pgreen = c->green * 0x101;
+ *pblue = c->blue * 0x101;
+ return TRUE;
+ }
+ if (r < 0)
+ low = mid + 1;
+ else
+ high = mid - 1;
}
return FALSE;
}
diff --git a/xorg-server/os/osdep.h b/xorg-server/os/osdep.h
index 70e2a0726..fff088701 100644
--- a/xorg-server/os/osdep.h
+++ b/xorg-server/os/osdep.h
@@ -22,7 +22,6 @@ Except as contained in this notice, the name of The Open Group shall 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 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
@@ -102,17 +101,17 @@ SOFTWARE.
#include <stddef.h>
#if defined(XDMCP) || defined(HASXDMAUTH)
-typedef Bool (*ValidatorFunc)(ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type);
-typedef Bool (*GeneratorFunc)(ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type);
-typedef Bool (*AddAuthorFunc)(unsigned name_length, const char *name,
- unsigned data_length, char *data);
+typedef Bool (*ValidatorFunc) (ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type);
+typedef Bool (*GeneratorFunc) (ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type);
+typedef Bool (*AddAuthorFunc) (unsigned name_length, const char *name,
+ unsigned data_length, char *data);
#endif
typedef struct _connectionInput {
struct _connectionInput *next;
char *buffer; /* contains current client input */
char *bufptr; /* pointer to current start of data */
- int bufcnt; /* count of bytes in buffer */
+ int bufcnt; /* count of bytes in buffer */
int lenLastReq;
int size;
unsigned int ignoreBytes; /* bytes to ignore before the next request */
@@ -151,30 +150,29 @@ typedef int (*AuthRstCFunc) (AuthRstCArgs);
#define AuthToIDArgs unsigned short data_length, char *data
typedef XID (*AuthToIDFunc) (AuthToIDArgs);
-typedef void (*OsCloseFunc)(ClientPtr);
+typedef void (*OsCloseFunc) (ClientPtr);
-typedef int (*OsFlushFunc)(ClientPtr who, struct _osComm * oc, char* extraBuf, int extraCount);
+typedef int (*OsFlushFunc) (ClientPtr who, struct _osComm * oc, char *extraBuf,
+ int extraCount);
typedef struct _osComm {
int fd;
ConnectionInputPtr input;
ConnectionOutputPtr output;
- XID auth_id; /* authorization id */
- CARD32 conn_time; /* timestamp if not established, else 0 */
+ XID auth_id; /* authorization id */
+ CARD32 conn_time; /* timestamp if not established, else 0 */
struct _XtransConnInfo *trans_conn; /* transport connection object */
Bool local_client;
} OsCommRec, *OsCommPtr;
-extern int FlushClient(
- ClientPtr /*who*/,
- OsCommPtr /*oc*/,
- const void * /*extraBuf*/,
- int /*extraCount*/
-);
+extern int FlushClient(ClientPtr /*who */ ,
+ OsCommPtr /*oc */ ,
+ const void * /*extraBuf */ ,
+ int /*extraCount */
+ );
-extern void FreeOsBuffers(
- OsCommPtr /*oc*/
-);
+extern void FreeOsBuffers(OsCommPtr /*oc */
+ );
#include "dix.h"
@@ -195,7 +193,7 @@ extern int GetConnectionTranslation(int conn);
extern void SetConnectionTranslation(int conn, int client);
extern void ClearConnectionTranslation(void);
#endif
-
+
extern Bool NewOutputPending;
extern Bool AnyClientsWriteBlocked;
@@ -212,67 +210,63 @@ extern int mffs(fd_mask);
extern Bool ComputeLocalClient(ClientPtr client);
/* in auth.c */
-extern void GenerateRandomData (int len, char *buf);
+extern void GenerateRandomData(int len, char *buf);
/* in mitauth.c */
-extern XID MitCheckCookie (AuthCheckArgs);
-extern XID MitGenerateCookie (AuthGenCArgs);
-extern XID MitToID (AuthToIDArgs);
-extern int MitAddCookie (AuthAddCArgs);
-extern int MitFromID (AuthFromIDArgs);
-extern int MitRemoveCookie (AuthRemCArgs);
-extern int MitResetCookie (AuthRstCArgs);
+extern XID MitCheckCookie(AuthCheckArgs);
+extern XID MitGenerateCookie(AuthGenCArgs);
+extern XID MitToID(AuthToIDArgs);
+extern int MitAddCookie(AuthAddCArgs);
+extern int MitFromID(AuthFromIDArgs);
+extern int MitRemoveCookie(AuthRemCArgs);
+extern int MitResetCookie(AuthRstCArgs);
/* in xdmauth.c */
#ifdef HASXDMAUTH
-extern XID XdmCheckCookie (AuthCheckArgs);
-extern XID XdmToID (AuthToIDArgs);
-extern int XdmAddCookie (AuthAddCArgs);
-extern int XdmFromID (AuthFromIDArgs);
-extern int XdmRemoveCookie (AuthRemCArgs);
-extern int XdmResetCookie (AuthRstCArgs);
+extern XID XdmCheckCookie(AuthCheckArgs);
+extern XID XdmToID(AuthToIDArgs);
+extern int XdmAddCookie(AuthAddCArgs);
+extern int XdmFromID(AuthFromIDArgs);
+extern int XdmRemoveCookie(AuthRemCArgs);
+extern int XdmResetCookie(AuthRstCArgs);
#endif
/* in rpcauth.c */
#ifdef SECURE_RPC
-extern void SecureRPCInit (AuthInitArgs);
-extern XID SecureRPCCheck (AuthCheckArgs);
-extern XID SecureRPCToID (AuthToIDArgs);
-extern int SecureRPCAdd (AuthAddCArgs);
-extern int SecureRPCFromID (AuthFromIDArgs);
-extern int SecureRPCRemove (AuthRemCArgs);
-extern int SecureRPCReset (AuthRstCArgs);
+extern void SecureRPCInit(AuthInitArgs);
+extern XID SecureRPCCheck(AuthCheckArgs);
+extern XID SecureRPCToID(AuthToIDArgs);
+extern int SecureRPCAdd(AuthAddCArgs);
+extern int SecureRPCFromID(AuthFromIDArgs);
+extern int SecureRPCRemove(AuthRemCArgs);
+extern int SecureRPCReset(AuthRstCArgs);
#endif
#ifdef XDMCP
/* in xdmcp.c */
-extern void XdmcpUseMsg (void);
+extern void XdmcpUseMsg(void);
extern int XdmcpOptions(int argc, char **argv, int i);
-extern void XdmcpRegisterConnection (
- int type,
- const char *address,
- int addrlen);
-extern void XdmcpRegisterAuthorizations (void);
-extern void XdmcpRegisterAuthorization (const char *name, int namelen);
-extern void XdmcpInit (void);
-extern void XdmcpReset (void);
+extern void XdmcpRegisterConnection(int type, const char *address, int addrlen);
+extern void XdmcpRegisterAuthorizations(void);
+extern void XdmcpRegisterAuthorization(const char *name, int namelen);
+extern void XdmcpInit(void);
+extern void XdmcpReset(void);
extern void XdmcpOpenDisplay(int sock);
extern void XdmcpCloseDisplay(int sock);
-extern void XdmcpRegisterAuthentication (
- const char *name,
- int namelen,
- const char *data,
- int datalen,
- ValidatorFunc Validator,
- GeneratorFunc Generator,
- AddAuthorFunc AddAuth);
+extern void XdmcpRegisterAuthentication(const char *name,
+ int namelen,
+ const char *data,
+ int datalen,
+ ValidatorFunc Validator,
+ GeneratorFunc Generator,
+ AddAuthorFunc AddAuth);
struct sockaddr_in;
-extern void XdmcpRegisterBroadcastAddress (const struct sockaddr_in *addr);
+extern void XdmcpRegisterBroadcastAddress(const struct sockaddr_in *addr);
#endif
#ifdef HASXDMAUTH
-extern void XdmAuthenticationInit (const char *cookie, int cookie_length);
+extern void XdmAuthenticationInit(const char *cookie, int cookie_length);
#endif
-#endif /* _OSDEP_H_ */
+#endif /* _OSDEP_H_ */
diff --git a/xorg-server/os/osinit.c b/xorg-server/os/osinit.c
index ff3c45de0..e2a220886 100644
--- a/xorg-server/os/osinit.c
+++ b/xorg-server/os/osinit.c
@@ -22,7 +22,6 @@ Except as contained in this notice, the name of The Open Group shall 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 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
@@ -57,7 +56,7 @@ SOFTWARE.
#include <signal.h>
#include <errno.h>
#ifdef HAVE_DLFCN_H
-# include <dlfcn.h>
+#include <dlfcn.h>
#endif
#ifdef HAVE_BACKTRACE
#include <execinfo.h>
@@ -67,8 +66,7 @@ SOFTWARE.
#include "dixstruct.h"
-
-#if !defined(SYSV) && !defined(WIN32)
+#if !defined(SYSV) && !defined(WIN32)
#include <sys/resource.h>
#endif
@@ -77,6 +75,7 @@ SOFTWARE.
#endif
extern char *display;
+
#ifdef RLIMIT_DATA
int limitDataSpace = -1;
#endif
@@ -105,188 +104,187 @@ OsRegisterSigWrapper(OsSigWrapperPtr newSigWrapper)
*/
static void
#ifdef SA_SIGINFO
-OsSigHandler(int signo, siginfo_t *sip, void *unused)
+OsSigHandler(int signo, siginfo_t * sip, void *unused)
#else
OsSigHandler(int signo)
#endif
{
#ifdef RTLD_DI_SETSIGNAL
- const char *dlerr = dlerror();
+ const char *dlerr = dlerror();
- if (dlerr) {
- LogMessage(X_ERROR, "Dynamic loader error: %s\n", dlerr);
- }
-#endif /* RTLD_DI_SETSIGNAL */
+ if (dlerr) {
+ LogMessage(X_ERROR, "Dynamic loader error: %s\n", dlerr);
+ }
+#endif /* RTLD_DI_SETSIGNAL */
- if (OsSigWrapper != NULL) {
- if (OsSigWrapper(signo) == 0) {
- /* ddx handled signal and wants us to continue */
- return;
- }
- }
+ if (OsSigWrapper != NULL) {
+ if (OsSigWrapper(signo) == 0) {
+ /* ddx handled signal and wants us to continue */
+ return;
+ }
+ }
- /* log, cleanup, and abort */
- xorg_backtrace();
+ /* log, cleanup, and abort */
+ xorg_backtrace();
#ifdef SA_SIGINFO
- if (sip->si_code == SI_USER) {
- ErrorF("Recieved signal %d sent by process %ld, uid %ld\n",
- signo, (long) sip->si_pid, (long) sip->si_uid);
- } else {
- switch (signo) {
- case SIGSEGV:
- case SIGBUS:
- case SIGILL:
- case SIGFPE:
- ErrorF("%s at address %p\n", strsignal(signo), sip->si_addr);
- }
- }
+ if (sip->si_code == SI_USER) {
+ ErrorF("Recieved signal %d sent by process %ld, uid %ld\n",
+ signo, (long) sip->si_pid, (long) sip->si_uid);
+ }
+ else {
+ switch (signo) {
+ case SIGSEGV:
+ case SIGBUS:
+ case SIGILL:
+ case SIGFPE:
+ ErrorF("%s at address %p\n", strsignal(signo), sip->si_addr);
+ }
+ }
#endif
- FatalError("Caught signal %d (%s). Server aborting\n",
- signo, strsignal(signo));
+ FatalError("Caught signal %d (%s). Server aborting\n",
+ signo, strsignal(signo));
}
void
OsInit(void)
{
static Bool been_here = FALSE;
- static const char* devnull = "/dev/null";
+ static const char *devnull = "/dev/null";
char fname[PATH_MAX];
if (!been_here) {
- struct sigaction act, oact;
- int i;
- int siglist[] = { SIGSEGV, SIGQUIT, SIGILL, SIGFPE, SIGBUS,
- SIGSYS,
- SIGXCPU,
- SIGXFSZ,
+ struct sigaction act, oact;
+ int i;
+
+ int siglist[] = { SIGSEGV, SIGQUIT, SIGILL, SIGFPE, SIGBUS,
+ SIGSYS,
+ SIGXCPU,
+ SIGXFSZ,
#ifdef SIGEMT
- SIGEMT,
+ SIGEMT,
#endif
- 0 /* must be last */ };
- sigemptyset(&act.sa_mask);
+ 0 /* must be last */
+ };
+ sigemptyset(&act.sa_mask);
#ifdef SA_SIGINFO
- act.sa_sigaction = OsSigHandler;
- act.sa_flags = SA_SIGINFO;
+ act.sa_sigaction = OsSigHandler;
+ act.sa_flags = SA_SIGINFO;
#else
act.sa_handler = OsSigHandler;
act.sa_flags = 0;
#endif
- for (i = 0; siglist[i] != 0; i++) {
- if (sigaction(siglist[i], &act, &oact)) {
- ErrorF("failed to install signal handler for signal %d: %s\n",
- siglist[i], strerror(errno));
- }
- }
+ for (i = 0; siglist[i] != 0; i++) {
+ if (sigaction(siglist[i], &act, &oact)) {
+ ErrorF("failed to install signal handler for signal %d: %s\n",
+ siglist[i], strerror(errno));
+ }
+ }
#ifdef HAVE_BACKTRACE
- /*
- * initialize the backtracer, since the ctor calls dlopen(), which
- * calls malloc(), which isn't signal-safe.
- */
- do {
- void *array;
- backtrace(&array, 1);
- } while (0);
+ /*
+ * initialize the backtracer, since the ctor calls dlopen(), which
+ * calls malloc(), which isn't signal-safe.
+ */
+ do {
+ void *array;
+
+ backtrace(&array, 1);
+ } while (0);
#endif
#ifdef RTLD_DI_SETSIGNAL
- /* Tell runtime linker to send a signal we can catch instead of SIGKILL
- * for failures to load libraries/modules at runtime so we can clean up
- * after ourselves.
- */
- int failure_signal = SIGQUIT;
- dlinfo(RTLD_SELF, RTLD_DI_SETSIGNAL, &failure_signal);
+ /* Tell runtime linker to send a signal we can catch instead of SIGKILL
+ * for failures to load libraries/modules at runtime so we can clean up
+ * after ourselves.
+ */
+ int failure_signal = SIGQUIT;
+
+ dlinfo(RTLD_SELF, RTLD_DI_SETSIGNAL, &failure_signal);
#endif
-#if !defined(__CYGWIN__)
- fclose(stdin);
- fclose(stdout);
+#if !defined(__CYGWIN__)
+ fclose(stdin);
+ fclose(stdout);
#endif
- /*
- * If a write of zero bytes to stderr returns non-zero, i.e. -1,
- * then writing to stderr failed, and we'll write somewhere else
- * instead. (Apparently this never happens in the Real World.)
- */
- if (write (2, fname, 0) == -1)
- {
- FILE *err;
-
- if (strlen (display) + strlen (ADMPATH) + 1 < sizeof fname)
- snprintf (fname, sizeof(fname), ADMPATH, display);
- else
- strcpy (fname, devnull);
- /*
- * uses stdio to avoid os dependencies here,
- * a real os would use
- * open (fname, O_WRONLY|O_APPEND|O_CREAT, 0666)
- */
- if (!(err = fopen (fname, "a+")))
- err = fopen (devnull, "w");
- if (err && (fileno(err) != 2)) {
- dup2 (fileno (err), 2);
- fclose (err);
- }
+ /*
+ * If a write of zero bytes to stderr returns non-zero, i.e. -1,
+ * then writing to stderr failed, and we'll write somewhere else
+ * instead. (Apparently this never happens in the Real World.)
+ */
+ if (write(2, fname, 0) == -1) {
+ FILE *err;
+
+ if (strlen(display) + strlen(ADMPATH) + 1 < sizeof fname)
+ snprintf(fname, sizeof(fname), ADMPATH, display);
+ else
+ strcpy(fname, devnull);
+ /*
+ * uses stdio to avoid os dependencies here,
+ * a real os would use
+ * open (fname, O_WRONLY|O_APPEND|O_CREAT, 0666)
+ */
+ if (!(err = fopen(fname, "a+")))
+ err = fopen(devnull, "w");
+ if (err && (fileno(err) != 2)) {
+ dup2(fileno(err), 2);
+ fclose(err);
+ }
#if defined(SYSV) || defined(SVR4) || defined(WIN32) || defined(__CYGWIN__)
- {
- static char buf[BUFSIZ];
- setvbuf (stderr, buf, _IOLBF, BUFSIZ);
- }
+ {
+ static char buf[BUFSIZ];
+
+ setvbuf(stderr, buf, _IOLBF, BUFSIZ);
+ }
#else
- setlinebuf(stderr);
+ setlinebuf(stderr);
#endif
- }
+ }
- if (getpgrp () == 0)
- setpgid (0, 0);
+ if (getpgrp() == 0)
+ setpgid(0, 0);
#ifdef RLIMIT_DATA
- if (limitDataSpace >= 0)
- {
- struct rlimit rlim;
-
- if (!getrlimit(RLIMIT_DATA, &rlim))
- {
- if ((limitDataSpace > 0) && (limitDataSpace < rlim.rlim_max))
- rlim.rlim_cur = limitDataSpace;
- else
- rlim.rlim_cur = rlim.rlim_max;
- (void)setrlimit(RLIMIT_DATA, &rlim);
- }
- }
+ if (limitDataSpace >= 0) {
+ struct rlimit rlim;
+
+ if (!getrlimit(RLIMIT_DATA, &rlim)) {
+ if ((limitDataSpace > 0) && (limitDataSpace < rlim.rlim_max))
+ rlim.rlim_cur = limitDataSpace;
+ else
+ rlim.rlim_cur = rlim.rlim_max;
+ (void) setrlimit(RLIMIT_DATA, &rlim);
+ }
+ }
#endif
#ifdef RLIMIT_STACK
- if (limitStackSpace >= 0)
- {
- struct rlimit rlim;
-
- if (!getrlimit(RLIMIT_STACK, &rlim))
- {
- if ((limitStackSpace > 0) && (limitStackSpace < rlim.rlim_max))
- rlim.rlim_cur = limitStackSpace;
- else
- rlim.rlim_cur = rlim.rlim_max;
- (void)setrlimit(RLIMIT_STACK, &rlim);
- }
- }
+ if (limitStackSpace >= 0) {
+ struct rlimit rlim;
+
+ if (!getrlimit(RLIMIT_STACK, &rlim)) {
+ if ((limitStackSpace > 0) && (limitStackSpace < rlim.rlim_max))
+ rlim.rlim_cur = limitStackSpace;
+ else
+ rlim.rlim_cur = rlim.rlim_max;
+ (void) setrlimit(RLIMIT_STACK, &rlim);
+ }
+ }
#endif
#ifdef RLIMIT_NOFILE
- if (limitNoFile >= 0)
- {
- struct rlimit rlim;
-
- if (!getrlimit(RLIMIT_NOFILE, &rlim))
- {
- if ((limitNoFile > 0) && (limitNoFile < rlim.rlim_max))
- rlim.rlim_cur = limitNoFile;
- else
- rlim.rlim_cur = rlim.rlim_max;
- (void)setrlimit(RLIMIT_NOFILE, &rlim);
- }
- }
+ if (limitNoFile >= 0) {
+ struct rlimit rlim;
+
+ if (!getrlimit(RLIMIT_NOFILE, &rlim)) {
+ if ((limitNoFile > 0) && (limitNoFile < rlim.rlim_max))
+ rlim.rlim_cur = limitNoFile;
+ else
+ rlim.rlim_cur = rlim.rlim_max;
+ (void) setrlimit(RLIMIT_NOFILE, &rlim);
+ }
+ }
#endif
- LockServer();
- been_here = TRUE;
+ LockServer();
+ been_here = TRUE;
}
TimerInit();
OsVendorInit();
@@ -295,14 +293,13 @@ OsInit(void)
* log file name if logging to a file is desired.
*/
LogInit(NULL, NULL);
- SmartScheduleInit ();
+ SmartScheduleInit();
}
void
OsCleanup(Bool terminating)
{
- if (terminating)
- {
- UnlockServer();
+ if (terminating) {
+ UnlockServer();
}
}
diff --git a/xorg-server/os/rpcauth.c b/xorg-server/os/rpcauth.c
index 63b97b675..bd219acfa 100644
--- a/xorg-server/os/rpcauth.c
+++ b/xorg-server/os/rpcauth.c
@@ -31,7 +31,6 @@ from The Open Group.
* Author: Mayank Choudhary, Sun Microsystems
*/
-
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
@@ -54,29 +53,29 @@ extern bool_t xdr_opaque_auth(XDR *, struct opaque_auth *);
static enum auth_stat why;
-static char *
+static char *
authdes_ezdecode(const char *inmsg, int len)
{
- struct rpc_msg msg;
- char cred_area[MAX_AUTH_BYTES];
- char verf_area[MAX_AUTH_BYTES];
- char *temp_inmsg;
- struct svc_req r;
- bool_t res0, res1;
- XDR xdr;
- SVCXPRT xprt;
+ struct rpc_msg msg;
+ char cred_area[MAX_AUTH_BYTES];
+ char verf_area[MAX_AUTH_BYTES];
+ char *temp_inmsg;
+ struct svc_req r;
+ bool_t res0, res1;
+ XDR xdr;
+ SVCXPRT xprt;
temp_inmsg = malloc(len);
memmove(temp_inmsg, inmsg, len);
- memset((char *)&msg, 0, sizeof(msg));
- memset((char *)&r, 0, sizeof(r));
+ memset((char *) &msg, 0, sizeof(msg));
+ memset((char *) &r, 0, sizeof(r));
memset(cred_area, 0, sizeof(cred_area));
memset(verf_area, 0, sizeof(verf_area));
msg.rm_call.cb_cred.oa_base = cred_area;
msg.rm_call.cb_verf.oa_base = verf_area;
- why = AUTH_FAILED;
+ why = AUTH_FAILED;
xdrmem_create(&xdr, temp_inmsg, len, XDR_DECODE);
if ((r.rq_clntcred = malloc(MAX_AUTH_BYTES)) == NULL)
@@ -84,14 +83,14 @@ authdes_ezdecode(const char *inmsg, int len)
r.rq_xprt = &xprt;
/* decode into msg */
- res0 = xdr_opaque_auth(&xdr, &(msg.rm_call.cb_cred));
+ res0 = xdr_opaque_auth(&xdr, &(msg.rm_call.cb_cred));
res1 = xdr_opaque_auth(&xdr, &(msg.rm_call.cb_verf));
- if ( ! (res0 && res1) )
- goto bad2;
+ if (!(res0 && res1))
+ goto bad2;
/* do the authentication */
- r.rq_cred = msg.rm_call.cb_cred; /* read by opaque stuff */
+ r.rq_cred = msg.rm_call.cb_cred; /* read by opaque stuff */
if (r.rq_cred.oa_flavor != AUTH_DES) {
why = AUTH_TOOWEAK;
goto bad2;
@@ -101,94 +100,92 @@ authdes_ezdecode(const char *inmsg, int len)
#else
if ((why = _authenticate(&r, &msg)) != AUTH_OK) {
#endif
- goto bad2;
+ goto bad2;
}
- return (((struct authdes_cred *) r.rq_clntcred)->adc_fullname.name);
+ return (((struct authdes_cred *) r.rq_clntcred)->adc_fullname.name);
-bad2:
+ bad2:
free(r.rq_clntcred);
-bad1:
- return ((char *)0); /* ((struct authdes_cred *) NULL); */
+ bad1:
+ return ((char *) 0); /* ((struct authdes_cred *) NULL); */
}
-static XID rpc_id = (XID) ~0L;
+static XID rpc_id = (XID) ~0L;
static Bool
-CheckNetName (
- unsigned char *addr,
- short len,
- pointer closure
-)
+CheckNetName(unsigned char *addr, short len, pointer closure)
{
- return (len == strlen ((char *) closure) &&
- strncmp ((char *) addr, (char *) closure, len) == 0);
+ return (len == strlen((char *) closure) &&
+ strncmp((char *) addr, (char *) closure, len) == 0);
}
-static char rpc_error[MAXNETNAMELEN+50];
+static char rpc_error[MAXNETNAMELEN + 50];
_X_HIDDEN XID
-SecureRPCCheck (unsigned short data_length, const char *data,
- ClientPtr client, const char **reason)
+SecureRPCCheck(unsigned short data_length, const char *data,
+ ClientPtr client, const char **reason)
{
char *fullname;
-
+
if (rpc_id == (XID) ~0L) {
- *reason = "Secure RPC authorization not initialized";
- } else {
- fullname = authdes_ezdecode(data, data_length);
- if (fullname == (char *)0) {
- snprintf(rpc_error, sizeof(rpc_error),
- "Unable to authenticate secure RPC client (why=%d)", why);
- *reason = rpc_error;
- } else {
- if (ForEachHostInFamily (FamilyNetname, CheckNetName, fullname))
- return rpc_id;
- snprintf(rpc_error, sizeof(rpc_error),
- "Principal \"%s\" is not authorized to connect", fullname);
- *reason = rpc_error;
- }
+ *reason = "Secure RPC authorization not initialized";
+ }
+ else {
+ fullname = authdes_ezdecode(data, data_length);
+ if (fullname == (char *) 0) {
+ snprintf(rpc_error, sizeof(rpc_error),
+ "Unable to authenticate secure RPC client (why=%d)", why);
+ *reason = rpc_error;
+ }
+ else {
+ if (ForEachHostInFamily(FamilyNetname, CheckNetName, fullname))
+ return rpc_id;
+ snprintf(rpc_error, sizeof(rpc_error),
+ "Principal \"%s\" is not authorized to connect", fullname);
+ *reason = rpc_error;
+ }
}
return (XID) ~0L;
}
-
+
_X_HIDDEN void
-SecureRPCInit (void)
+SecureRPCInit(void)
{
if (rpc_id == ~0L)
- AddAuthorization (9, "SUN-DES-1", 0, (char *) 0);
+ AddAuthorization(9, "SUN-DES-1", 0, (char *) 0);
}
_X_HIDDEN int
-SecureRPCAdd (unsigned short data_length, const char *data, XID id)
+SecureRPCAdd(unsigned short data_length, const char *data, XID id)
{
if (data_length)
- AddHost ((pointer) 0, FamilyNetname, data_length, data);
+ AddHost((pointer) 0, FamilyNetname, data_length, data);
rpc_id = id;
return 1;
}
_X_HIDDEN int
-SecureRPCReset (void)
+SecureRPCReset(void)
{
rpc_id = (XID) ~0L;
return 1;
}
_X_HIDDEN XID
-SecureRPCToID (unsigned short data_length, char *data)
+SecureRPCToID(unsigned short data_length, char *data)
{
return rpc_id;
}
_X_HIDDEN int
-SecureRPCFromID (XID id, unsigned short *data_lenp, char **datap)
+SecureRPCFromID(XID id, unsigned short *data_lenp, char **datap)
{
return 0;
}
_X_HIDDEN int
-SecureRPCRemove (unsigned short data_length, const char *data)
+SecureRPCRemove(unsigned short data_length, const char *data)
{
return 0;
}
-#endif /* SECURE_RPC */
+#endif /* SECURE_RPC */
diff --git a/xorg-server/os/strlcpy.c b/xorg-server/os/strlcpy.c
index 7ffb64cd6..52e7203b2 100644
--- a/xorg-server/os/strlcpy.c
+++ b/xorg-server/os/strlcpy.c
@@ -31,26 +31,25 @@
size_t
strlcpy(char *dst, const char *src, size_t siz)
{
- register char *d = dst;
- register const char *s = src;
- register size_t n = siz;
+ register char *d = dst;
+ register const char *s = src;
+ register size_t n = siz;
- /* Copy as many bytes as will fit */
- if (n != 0 && --n != 0) {
- do {
- if ((*d++ = *s++) == 0)
- break;
- } while (--n != 0);
- }
+ /* Copy as many bytes as will fit */
+ if (n != 0 && --n != 0) {
+ do {
+ if ((*d++ = *s++) == 0)
+ break;
+ } while (--n != 0);
+ }
- /* Not enough room in dst, add NUL and traverse rest of src */
- if (n == 0) {
- if (siz != 0)
- *d = '\0'; /* NUL-terminate dst */
- while (*s++)
- ;
- }
+ /* Not enough room in dst, add NUL and traverse rest of src */
+ if (n == 0) {
+ if (siz != 0)
+ *d = '\0'; /* NUL-terminate dst */
+ while (*s++);
+ }
- return s - src - 1; /* count does not include NUL */
+ return s - src - 1; /* count does not include NUL */
}
#endif
diff --git a/xorg-server/os/utils.c b/xorg-server/os/utils.c
index 6461ed591..30592d2cc 100644
--- a/xorg-server/os/utils.c
+++ b/xorg-server/os/utils.c
@@ -24,7 +24,6 @@ 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 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
Copyright 1994 Quarterdeck Office Systems.
@@ -99,19 +98,19 @@ __stdcall unsigned long GetTickCount(void);
#ifndef WIN32
#include <sys/wait.h>
#endif
-#if !defined(SYSV) && !defined(WIN32)
+#if !defined(SYSV) && !defined(WIN32)
#include <sys/resource.h>
#endif
#include <sys/stat.h>
-#include <ctype.h> /* for isspace */
+#include <ctype.h> /* for isspace */
#include <stdarg.h>
-#include <stdlib.h> /* for malloc() */
+#include <stdlib.h> /* for malloc() */
#if defined(TCPCONN) || defined(STREAMSCONN)
-# ifndef WIN32
-# include <netdb.h>
-# endif
+#ifndef WIN32
+#include <netdb.h>
+#endif
#endif
#include "opaque.h"
@@ -123,6 +122,7 @@ __stdcall unsigned long GetTickCount(void);
#include "picture.h"
Bool noTestExtensions;
+
#ifdef COMPOSITE
Bool noCompositeExtension = FALSE;
#endif
@@ -150,6 +150,7 @@ Bool noMITShmExtension = FALSE;
Bool noRRExtension = FALSE;
#endif
Bool noRenderExtension = FALSE;
+
#ifdef XCSECURITY
Bool noSecurityExtension = FALSE;
#endif
@@ -214,11 +215,11 @@ OsSignal(int sig, OsSigHandlerPtr handler)
sigemptyset(&act.sa_mask);
if (handler != SIG_IGN)
- sigaddset(&act.sa_mask, sig);
+ sigaddset(&act.sa_mask, sig);
act.sa_flags = 0;
act.sa_handler = handler;
if (sigaction(sig, &act, &oact))
- perror("sigaction");
+ perror("sigaction");
return oact.sa_handler;
}
@@ -246,121 +247,123 @@ static Bool nolock = FALSE;
void
LockServer(void)
{
- char tmp[PATH_MAX], pid_str[12];
- int lfd, i, haslock, l_pid, t;
- const char *tmppath = LOCK_DIR;
- int len;
- char port[20];
-
- if (nolock) return;
- /*
- * Path names
- */
- snprintf(port, sizeof(port), "%d", atoi(display));
- len = strlen(LOCK_PREFIX) > strlen(LOCK_TMP_PREFIX) ? strlen(LOCK_PREFIX) :
- strlen(LOCK_TMP_PREFIX);
- len += strlen(tmppath) + strlen(port) + strlen(LOCK_SUFFIX) + 1;
- if (len > sizeof(LockFile))
- FatalError("Display name `%s' is too long\n", port);
- (void)sprintf(tmp, "%s" LOCK_TMP_PREFIX "%s" LOCK_SUFFIX, tmppath, port);
- (void)sprintf(LockFile, "%s" LOCK_PREFIX "%s" LOCK_SUFFIX, tmppath, port);
-
- /*
- * Create a temporary file containing our PID. Attempt three times
- * to create the file.
- */
- StillLocking = TRUE;
- i = 0;
- do {
- i++;
- lfd = open(tmp, O_CREAT | O_EXCL | O_WRONLY, 0644);
- if (lfd < 0)
- sleep(2);
- else
- break;
- } while (i < 3);
- if (lfd < 0) {
- unlink(tmp);
+ char tmp[PATH_MAX], pid_str[12];
+ int lfd, i, haslock, l_pid, t;
+ const char *tmppath = LOCK_DIR;
+ int len;
+ char port[20];
+
+ if (nolock)
+ return;
+ /*
+ * Path names
+ */
+ snprintf(port, sizeof(port), "%d", atoi(display));
+ len = strlen(LOCK_PREFIX) > strlen(LOCK_TMP_PREFIX) ? strlen(LOCK_PREFIX) :
+ strlen(LOCK_TMP_PREFIX);
+ len += strlen(tmppath) + strlen(port) + strlen(LOCK_SUFFIX) + 1;
+ if (len > sizeof(LockFile))
+ FatalError("Display name `%s' is too long\n", port);
+ (void) sprintf(tmp, "%s" LOCK_TMP_PREFIX "%s" LOCK_SUFFIX, tmppath, port);
+ (void) sprintf(LockFile, "%s" LOCK_PREFIX "%s" LOCK_SUFFIX, tmppath, port);
+
+ /*
+ * Create a temporary file containing our PID. Attempt three times
+ * to create the file.
+ */
+ StillLocking = TRUE;
i = 0;
do {
- i++;
- lfd = open(tmp, O_CREAT | O_EXCL | O_WRONLY, 0644);
- if (lfd < 0)
- sleep(2);
- else
- break;
+ i++;
+ lfd = open(tmp, O_CREAT | O_EXCL | O_WRONLY, 0644);
+ if (lfd < 0)
+ sleep(2);
+ else
+ break;
} while (i < 3);
- }
- if (lfd < 0)
- FatalError("Could not create lock file in %s\n", tmp);
- snprintf(pid_str, sizeof(pid_str), "%10ld\n", (long)getpid());
- (void) write(lfd, pid_str, 11);
- (void) fchmod(lfd, 0444);
- (void) close(lfd);
-
- /*
- * OK. Now the tmp file exists. Try three times to move it in place
- * for the lock.
- */
- i = 0;
- haslock = 0;
- while ((!haslock) && (i++ < 3)) {
- haslock = (link(tmp,LockFile) == 0);
- if (haslock) {
- /*
- * We're done.
- */
- break;
- }
- else {
- /*
- * Read the pid from the existing file
- */
- lfd = open(LockFile, O_RDONLY|O_NOFOLLOW);
- if (lfd < 0) {
- unlink(tmp);
- FatalError("Can't read lock file %s\n", LockFile);
- }
- pid_str[0] = '\0';
- if (read(lfd, pid_str, 11) != 11) {
- /*
- * Bogus lock file.
- */
- unlink(LockFile);
- close(lfd);
- continue;
- }
- pid_str[11] = '\0';
- sscanf(pid_str, "%d", &l_pid);
- close(lfd);
-
- /*
- * Now try to kill the PID to see if it exists.
- */
- errno = 0;
- t = kill(l_pid, 0);
- if ((t< 0) && (errno == ESRCH)) {
- /*
- * Stale lock file.
- */
- unlink(LockFile);
- continue;
- }
- else if (((t < 0) && (errno == EPERM)) || (t == 0)) {
- /*
- * Process is still active.
- */
+ if (lfd < 0) {
unlink(tmp);
- FatalError("Server is already active for display %s\n%s %s\n%s\n",
- port, "\tIf this server is no longer running, remove",
- LockFile, "\tand start again.");
- }
+ i = 0;
+ do {
+ i++;
+ lfd = open(tmp, O_CREAT | O_EXCL | O_WRONLY, 0644);
+ if (lfd < 0)
+ sleep(2);
+ else
+ break;
+ } while (i < 3);
+ }
+ if (lfd < 0)
+ FatalError("Could not create lock file in %s\n", tmp);
+ snprintf(pid_str, sizeof(pid_str), "%10ld\n", (long) getpid());
+ (void) write(lfd, pid_str, 11);
+ (void) fchmod(lfd, 0444);
+ (void) close(lfd);
+
+ /*
+ * OK. Now the tmp file exists. Try three times to move it in place
+ * for the lock.
+ */
+ i = 0;
+ haslock = 0;
+ while ((!haslock) && (i++ < 3)) {
+ haslock = (link(tmp, LockFile) == 0);
+ if (haslock) {
+ /*
+ * We're done.
+ */
+ break;
+ }
+ else {
+ /*
+ * Read the pid from the existing file
+ */
+ lfd = open(LockFile, O_RDONLY | O_NOFOLLOW);
+ if (lfd < 0) {
+ unlink(tmp);
+ FatalError("Can't read lock file %s\n", LockFile);
+ }
+ pid_str[0] = '\0';
+ if (read(lfd, pid_str, 11) != 11) {
+ /*
+ * Bogus lock file.
+ */
+ unlink(LockFile);
+ close(lfd);
+ continue;
+ }
+ pid_str[11] = '\0';
+ sscanf(pid_str, "%d", &l_pid);
+ close(lfd);
+
+ /*
+ * Now try to kill the PID to see if it exists.
+ */
+ errno = 0;
+ t = kill(l_pid, 0);
+ if ((t < 0) && (errno == ESRCH)) {
+ /*
+ * Stale lock file.
+ */
+ unlink(LockFile);
+ continue;
+ }
+ else if (((t < 0) && (errno == EPERM)) || (t == 0)) {
+ /*
+ * Process is still active.
+ */
+ unlink(tmp);
+ FatalError
+ ("Server is already active for display %s\n%s %s\n%s\n",
+ port, "\tIf this server is no longer running, remove",
+ LockFile, "\tand start again.");
+ }
+ }
}
- }
- unlink(tmp);
- if (!haslock)
- FatalError("Could not create server lock file: %s\n", LockFile);
- StillLocking = FALSE;
+ unlink(tmp);
+ if (!haslock)
+ FatalError("Could not create server lock file: %s\n", LockFile);
+ StillLocking = FALSE;
}
/*
@@ -370,18 +373,19 @@ LockServer(void)
void
UnlockServer(void)
{
- if (nolock) return;
+ if (nolock)
+ return;
- if (!StillLocking){
+ if (!StillLocking) {
- (void) unlink(LockFile);
- }
+ (void) unlink(LockFile);
+ }
}
/* Force connections to close on SIGHUP from init */
void
-AutoResetServer (int sig)
+AutoResetServer(int sig)
{
int olderrno = errno;
@@ -404,9 +408,9 @@ GiveUp(int sig)
#if (defined WIN32 && defined __MINGW32__) || defined(__CYGWIN__)
CARD32
-GetTimeInMillis (void)
+GetTimeInMillis(void)
{
- return GetTickCount ();
+ return GetTickCount();
}
#else
CARD32
@@ -417,6 +421,7 @@ GetTimeInMillis(void)
#ifdef MONOTONIC_CLOCK
struct timespec tp;
static clockid_t clockid;
+
if (!clockid) {
#ifdef CLOCK_MONOTONIC_COARSE
if (clock_getres(CLOCK_MONOTONIC_COARSE, &tp) == 0 &&
@@ -435,41 +440,39 @@ GetTimeInMillis(void)
#endif
X_GETTIMEOFDAY(&tv);
- return(tv.tv_sec * 1000) + (tv.tv_usec / 1000);
+ return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
}
#endif
void
-AdjustWaitForDelay (pointer waitTime, unsigned long newdelay)
+AdjustWaitForDelay(pointer waitTime, unsigned long newdelay)
{
- static struct timeval delay_val;
- struct timeval **wt = (struct timeval **) waitTime;
- unsigned long olddelay;
-
- if (*wt == NULL)
- {
- delay_val.tv_sec = newdelay / 1000;
- delay_val.tv_usec = 1000 * (newdelay % 1000);
- *wt = &delay_val;
+ static struct timeval delay_val;
+ struct timeval **wt = (struct timeval **) waitTime;
+ unsigned long olddelay;
+
+ if (*wt == NULL) {
+ delay_val.tv_sec = newdelay / 1000;
+ delay_val.tv_usec = 1000 * (newdelay % 1000);
+ *wt = &delay_val;
}
- else
- {
- olddelay = (*wt)->tv_sec * 1000 + (*wt)->tv_usec / 1000;
- if (newdelay < olddelay)
- {
- (*wt)->tv_sec = newdelay / 1000;
- (*wt)->tv_usec = 1000 * (newdelay % 1000);
- }
+ else {
+ olddelay = (*wt)->tv_sec * 1000 + (*wt)->tv_usec / 1000;
+ if (newdelay < olddelay) {
+ (*wt)->tv_sec = newdelay / 1000;
+ (*wt)->tv_usec = 1000 * (newdelay % 1000);
+ }
}
}
-void UseMsg(void)
+void
+UseMsg(void)
{
ErrorF("use: X [:<display>] [option]\n");
ErrorF("-a # default pointer acceleration (factor)\n");
ErrorF("-ac disable access control restrictions\n");
- ErrorF("-audit int set audit trail level\n");
- ErrorF("-auth file select authorization file\n");
+ ErrorF("-audit int set audit trail level\n");
+ ErrorF("-auth file select authorization file\n");
ErrorF("-br create root window with black background\n");
ErrorF("+bs enable any backing store support\n");
ErrorF("-bs disable any backing store support\n");
@@ -482,7 +485,8 @@ void UseMsg(void)
#ifdef DPMSExtension
ErrorF("-dpms disables VESA DPMS monitor control\n");
#endif
- ErrorF("-deferglyphs [none|all|16] defer loading of [no|all|16-bit] glyphs\n");
+ ErrorF
+ ("-deferglyphs [none|all|16] defer loading of [no|all|16-bit] glyphs\n");
ErrorF("-f # bell base (0-100)\n");
ErrorF("-fc string cursor font\n");
ErrorF("-fn string default font name\n");
@@ -526,7 +530,8 @@ void UseMsg(void)
ErrorF("+xinerama Enable XINERAMA extension\n");
ErrorF("-xinerama Disable XINERAMA extension\n");
#endif
- ErrorF("-dumbSched Disable smart scheduling, enable old behavior\n");
+ ErrorF
+ ("-dumbSched Disable smart scheduling, enable old behavior\n");
ErrorF("-schedInterval int Set scheduler interval in msec\n");
ErrorF("-sigstop Enable SIGSTOP based startup\n");
ErrorF("+extension name Enable extension\n");
@@ -545,14 +550,19 @@ void UseMsg(void)
* not contain a "/" and not start with a "-".
* --kvajk
*/
-static int
+static int
VerifyDisplayName(const char *d)
{
- if ( d == (char *)0 ) return 0; /* null */
- if ( *d == '\0' ) return 0; /* empty */
- if ( *d == '-' ) return 0; /* could be confused for an option */
- if ( *d == '.' ) return 0; /* must not equal "." or ".." */
- if ( strchr(d, '/') != (char *)0 ) return 0; /* very important!!! */
+ if (d == (char *) 0)
+ return 0; /* null */
+ if (*d == '\0')
+ return 0; /* empty */
+ if (*d == '-')
+ return 0; /* could be confused for an option */
+ if (*d == '.')
+ return 0; /* must not equal "." or ".." */
+ if (strchr(d, '/') != (char *) 0)
+ return 0; /* very important!!! */
return 1;
}
@@ -574,390 +584,339 @@ ProcessCommandLine(int argc, char *argv[])
PartialNetwork = TRUE;
#endif
- for ( i = 1; i < argc; i++ )
- {
- /* call ddx first, so it can peek/override if it wants */
- if((skip = ddxProcessArgument(argc, argv, i)))
- {
- i += (skip - 1);
- }
- else if(argv[i][0] == ':')
- {
- /* initialize display */
- display = argv[i];
- display++;
- if( ! VerifyDisplayName( display ) ) {
+ for (i = 1; i < argc; i++) {
+ /* call ddx first, so it can peek/override if it wants */
+ if ((skip = ddxProcessArgument(argc, argv, i))) {
+ i += (skip - 1);
+ }
+ else if (argv[i][0] == ':') {
+ /* initialize display */
+ display = argv[i];
+ display++;
+ if (!VerifyDisplayName(display)) {
ErrorF("Bad display name: %s\n", display);
UseMsg();
- FatalError("Bad display name, exiting: %s\n", display);
+ FatalError("Bad display name, exiting: %s\n", display);
}
- }
- else if ( strcmp( argv[i], "-a") == 0)
- {
- if(++i < argc)
- defaultPointerControl.num = atoi(argv[i]);
- else
- UseMsg();
- }
- else if ( strcmp( argv[i], "-ac") == 0)
- {
- defeatAccessControl = TRUE;
- }
- else if ( strcmp( argv[i], "-audit") == 0)
- {
- if(++i < argc)
- auditTrailLevel = atoi(argv[i]);
- else
- UseMsg();
- }
- else if ( strcmp( argv[i], "-auth") == 0)
- {
- if(++i < argc)
- InitAuthorization (argv[i]);
- else
- UseMsg();
- }
- else if ( strcmp( argv[i], "-br") == 0) ; /* default */
- else if ( strcmp( argv[i], "+bs") == 0)
- enableBackingStore = TRUE;
- else if ( strcmp( argv[i], "-bs") == 0)
- disableBackingStore = TRUE;
- else if ( strcmp( argv[i], "c") == 0)
- {
- if(++i < argc)
- defaultKeyboardControl.click = atoi(argv[i]);
- else
- UseMsg();
- }
- else if ( strcmp( argv[i], "-c") == 0)
- {
- defaultKeyboardControl.click = 0;
- }
- else if ( strcmp( argv[i], "-cc") == 0)
- {
- if(++i < argc)
- defaultColorVisualClass = atoi(argv[i]);
- else
- UseMsg();
- }
- else if ( strcmp( argv[i], "-core") == 0)
- {
+ }
+ else if (strcmp(argv[i], "-a") == 0) {
+ if (++i < argc)
+ defaultPointerControl.num = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+ else if (strcmp(argv[i], "-ac") == 0) {
+ defeatAccessControl = TRUE;
+ }
+ else if (strcmp(argv[i], "-audit") == 0) {
+ if (++i < argc)
+ auditTrailLevel = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+ else if (strcmp(argv[i], "-auth") == 0) {
+ if (++i < argc)
+ InitAuthorization(argv[i]);
+ else
+ UseMsg();
+ }
+ else if (strcmp(argv[i], "-br") == 0); /* default */
+ else if (strcmp(argv[i], "+bs") == 0)
+ enableBackingStore = TRUE;
+ else if (strcmp(argv[i], "-bs") == 0)
+ disableBackingStore = TRUE;
+ else if (strcmp(argv[i], "c") == 0) {
+ if (++i < argc)
+ defaultKeyboardControl.click = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+ else if (strcmp(argv[i], "-c") == 0) {
+ defaultKeyboardControl.click = 0;
+ }
+ else if (strcmp(argv[i], "-cc") == 0) {
+ if (++i < argc)
+ defaultColorVisualClass = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+ else if (strcmp(argv[i], "-core") == 0) {
#if !defined(WIN32) || !defined(__MINGW32__)
- struct rlimit core_limit;
- getrlimit (RLIMIT_CORE, &core_limit);
- core_limit.rlim_cur = core_limit.rlim_max;
- setrlimit (RLIMIT_CORE, &core_limit);
-#endif
- CoreDump = TRUE;
- }
- else if ( strcmp( argv[i], "-nocursor") == 0)
- {
+ struct rlimit core_limit;
+
+ getrlimit(RLIMIT_CORE, &core_limit);
+ core_limit.rlim_cur = core_limit.rlim_max;
+ setrlimit(RLIMIT_CORE, &core_limit);
+#endif
+ CoreDump = TRUE;
+ }
+ else if (strcmp(argv[i], "-nocursor") == 0) {
EnableCursor = FALSE;
}
- else if ( strcmp( argv[i], "-dpi") == 0)
- {
- if(++i < argc)
- monitorResolution = atoi(argv[i]);
- else
- UseMsg();
- }
+ else if (strcmp(argv[i], "-dpi") == 0) {
+ if (++i < argc)
+ monitorResolution = atoi(argv[i]);
+ else
+ UseMsg();
+ }
#ifdef DPMSExtension
- else if ( strcmp( argv[i], "dpms") == 0)
- /* ignored for compatibility */ ;
- else if ( strcmp( argv[i], "-dpms") == 0)
- DPMSDisabledSwitch = TRUE;
-#endif
- else if ( strcmp( argv[i], "-deferglyphs") == 0)
- {
- if(++i >= argc || !ParseGlyphCachingMode(argv[i]))
- UseMsg();
- }
- else if ( strcmp( argv[i], "-f") == 0)
- {
- if(++i < argc)
- defaultKeyboardControl.bell = atoi(argv[i]);
- else
- UseMsg();
- }
- else if ( strcmp( argv[i], "-fc") == 0)
- {
- if(++i < argc)
- defaultCursorFont = argv[i];
- else
- UseMsg();
- }
- else if ( strcmp( argv[i], "-fn") == 0)
- {
- if(++i < argc)
- defaultTextFont = argv[i];
- else
- UseMsg();
- }
- else if ( strcmp( argv[i], "-fp") == 0)
- {
- if(++i < argc)
- {
- defaultFontPath = argv[i];
- }
- else
- UseMsg();
- }
- else if ( strcmp( argv[i], "-help") == 0)
- {
- UseMsg();
- exit(0);
- }
- else if ( (skip=XkbProcessArguments(argc,argv,i))!=0 ) {
- if (skip>0)
- i+= skip-1;
- else UseMsg();
- }
+ else if (strcmp(argv[i], "dpms") == 0)
+ /* ignored for compatibility */ ;
+ else if (strcmp(argv[i], "-dpms") == 0)
+ DPMSDisabledSwitch = TRUE;
+#endif
+ else if (strcmp(argv[i], "-deferglyphs") == 0) {
+ if (++i >= argc || !ParseGlyphCachingMode(argv[i]))
+ UseMsg();
+ }
+ else if (strcmp(argv[i], "-f") == 0) {
+ if (++i < argc)
+ defaultKeyboardControl.bell = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+ else if (strcmp(argv[i], "-fc") == 0) {
+ if (++i < argc)
+ defaultCursorFont = argv[i];
+ else
+ UseMsg();
+ }
+ else if (strcmp(argv[i], "-fn") == 0) {
+ if (++i < argc)
+ defaultTextFont = argv[i];
+ else
+ UseMsg();
+ }
+ else if (strcmp(argv[i], "-fp") == 0) {
+ if (++i < argc) {
+ defaultFontPath = argv[i];
+ }
+ else
+ UseMsg();
+ }
+ else if (strcmp(argv[i], "-help") == 0) {
+ UseMsg();
+ exit(0);
+ }
+ else if ((skip = XkbProcessArguments(argc, argv, i)) != 0) {
+ if (skip > 0)
+ i += skip - 1;
+ else
+ UseMsg();
+ }
#ifdef RLIMIT_DATA
- else if ( strcmp( argv[i], "-ld") == 0)
- {
- if(++i < argc)
- {
- limitDataSpace = atoi(argv[i]);
- if (limitDataSpace > 0)
- limitDataSpace *= 1024;
- }
- else
- UseMsg();
- }
+ else if (strcmp(argv[i], "-ld") == 0) {
+ if (++i < argc) {
+ limitDataSpace = atoi(argv[i]);
+ if (limitDataSpace > 0)
+ limitDataSpace *= 1024;
+ }
+ else
+ UseMsg();
+ }
#endif
#ifdef RLIMIT_NOFILE
- else if ( strcmp( argv[i], "-lf") == 0)
- {
- if(++i < argc)
- limitNoFile = atoi(argv[i]);
- else
- UseMsg();
- }
+ else if (strcmp(argv[i], "-lf") == 0) {
+ if (++i < argc)
+ limitNoFile = atoi(argv[i]);
+ else
+ UseMsg();
+ }
#endif
#ifdef RLIMIT_STACK
- else if ( strcmp( argv[i], "-ls") == 0)
- {
- if(++i < argc)
- {
- limitStackSpace = atoi(argv[i]);
- if (limitStackSpace > 0)
- limitStackSpace *= 1024;
- }
- else
- UseMsg();
- }
-#endif
- else if ( strcmp ( argv[i], "-nolock") == 0)
- {
+ else if (strcmp(argv[i], "-ls") == 0) {
+ if (++i < argc) {
+ limitStackSpace = atoi(argv[i]);
+ if (limitStackSpace > 0)
+ limitStackSpace *= 1024;
+ }
+ else
+ UseMsg();
+ }
+#endif
+ else if (strcmp(argv[i], "-nolock") == 0) {
#if !defined(WIN32) && !defined(__CYGWIN__)
- if (getuid() != 0)
- ErrorF("Warning: the -nolock option can only be used by root\n");
- else
-#endif
- nolock = TRUE;
- }
- else if ( strcmp( argv[i], "-nolisten") == 0)
- {
- if(++i < argc) {
- if (_XSERVTransNoListen(argv[i]))
- FatalError ("Failed to disable listen for %s transport",
- argv[i]);
- } else
- UseMsg();
- }
- else if ( strcmp( argv[i], "-noreset") == 0)
- {
- dispatchExceptionAtReset = 0;
- }
- else if ( strcmp( argv[i], "-reset") == 0)
- {
- dispatchExceptionAtReset = DE_RESET;
- }
- else if ( strcmp( argv[i], "-p") == 0)
- {
- if(++i < argc)
- defaultScreenSaverInterval = ((CARD32)atoi(argv[i])) *
- MILLI_PER_MIN;
- else
- UseMsg();
- }
- else if (strcmp(argv[i], "-pogo") == 0)
- {
- dispatchException = DE_TERMINATE;
- }
- else if ( strcmp( argv[i], "-pn") == 0)
- PartialNetwork = TRUE;
- else if ( strcmp( argv[i], "-nopn") == 0)
- PartialNetwork = FALSE;
- else if ( strcmp( argv[i], "r") == 0)
- defaultKeyboardControl.autoRepeat = TRUE;
- else if ( strcmp( argv[i], "-r") == 0)
- defaultKeyboardControl.autoRepeat = FALSE;
- else if ( strcmp( argv[i], "-retro") == 0)
- party_like_its_1989 = TRUE;
- else if ( strcmp( argv[i], "-s") == 0)
- {
- if(++i < argc)
- defaultScreenSaverTime = ((CARD32)atoi(argv[i])) *
- MILLI_PER_MIN;
- else
- UseMsg();
- }
- else if ( strcmp( argv[i], "-seat") == 0)
- {
- if(++i < argc)
- SeatId = argv[i];
- else
- UseMsg();
- }
- else if ( strcmp( argv[i], "-t") == 0)
- {
- if(++i < argc)
- defaultPointerControl.threshold = atoi(argv[i]);
- else
- UseMsg();
- }
- else if ( strcmp( argv[i], "-terminate") == 0)
- {
- dispatchExceptionAtReset = DE_TERMINATE;
- }
- else if ( strcmp( argv[i], "-to") == 0)
- {
- if(++i < argc)
- TimeOutValue = ((CARD32)atoi(argv[i])) * MILLI_PER_SECOND;
- else
- UseMsg();
- }
- else if ( strcmp( argv[i], "-tst") == 0)
- {
- noTestExtensions = TRUE;
- }
- else if ( strcmp( argv[i], "v") == 0)
- defaultScreenSaverBlanking = PreferBlanking;
- else if ( strcmp( argv[i], "-v") == 0)
- defaultScreenSaverBlanking = DontPreferBlanking;
- else if ( strcmp( argv[i], "-wm") == 0)
- defaultBackingStore = WhenMapped;
- else if ( strcmp( argv[i], "-wr") == 0)
+ if (getuid() != 0)
+ ErrorF
+ ("Warning: the -nolock option can only be used by root\n");
+ else
+#endif
+ nolock = TRUE;
+ }
+ else if (strcmp(argv[i], "-nolisten") == 0) {
+ if (++i < argc) {
+ if (_XSERVTransNoListen(argv[i]))
+ FatalError("Failed to disable listen for %s transport",
+ argv[i]);
+ }
+ else
+ UseMsg();
+ }
+ else if (strcmp(argv[i], "-noreset") == 0) {
+ dispatchExceptionAtReset = 0;
+ }
+ else if (strcmp(argv[i], "-reset") == 0) {
+ dispatchExceptionAtReset = DE_RESET;
+ }
+ else if (strcmp(argv[i], "-p") == 0) {
+ if (++i < argc)
+ defaultScreenSaverInterval = ((CARD32) atoi(argv[i])) *
+ MILLI_PER_MIN;
+ else
+ UseMsg();
+ }
+ else if (strcmp(argv[i], "-pogo") == 0) {
+ dispatchException = DE_TERMINATE;
+ }
+ else if (strcmp(argv[i], "-pn") == 0)
+ PartialNetwork = TRUE;
+ else if (strcmp(argv[i], "-nopn") == 0)
+ PartialNetwork = FALSE;
+ else if (strcmp(argv[i], "r") == 0)
+ defaultKeyboardControl.autoRepeat = TRUE;
+ else if (strcmp(argv[i], "-r") == 0)
+ defaultKeyboardControl.autoRepeat = FALSE;
+ else if (strcmp(argv[i], "-retro") == 0)
+ party_like_its_1989 = TRUE;
+ else if (strcmp(argv[i], "-s") == 0) {
+ if (++i < argc)
+ defaultScreenSaverTime = ((CARD32) atoi(argv[i])) *
+ MILLI_PER_MIN;
+ else
+ UseMsg();
+ }
+ else if (strcmp(argv[i], "-seat") == 0) {
+ if (++i < argc)
+ SeatId = argv[i];
+ else
+ UseMsg();
+ }
+ else if (strcmp(argv[i], "-t") == 0) {
+ if (++i < argc)
+ defaultPointerControl.threshold = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+ else if (strcmp(argv[i], "-terminate") == 0) {
+ dispatchExceptionAtReset = DE_TERMINATE;
+ }
+ else if (strcmp(argv[i], "-to") == 0) {
+ if (++i < argc)
+ TimeOutValue = ((CARD32) atoi(argv[i])) * MILLI_PER_SECOND;
+ else
+ UseMsg();
+ }
+ else if (strcmp(argv[i], "-tst") == 0) {
+ noTestExtensions = TRUE;
+ }
+ else if (strcmp(argv[i], "v") == 0)
+ defaultScreenSaverBlanking = PreferBlanking;
+ else if (strcmp(argv[i], "-v") == 0)
+ defaultScreenSaverBlanking = DontPreferBlanking;
+ else if (strcmp(argv[i], "-wm") == 0)
+ defaultBackingStore = WhenMapped;
+ else if (strcmp(argv[i], "-wr") == 0)
whiteRoot = TRUE;
- else if ( strcmp( argv[i], "-background") == 0) {
- if(++i < argc) {
- if (!strcmp ( argv[i], "none"))
+ else if (strcmp(argv[i], "-background") == 0) {
+ if (++i < argc) {
+ if (!strcmp(argv[i], "none"))
bgNoneRoot = TRUE;
else
UseMsg();
}
}
- else if ( strcmp( argv[i], "-maxbigreqsize") == 0) {
- if(++i < argc) {
- long reqSizeArg = atol(argv[i]);
-
- /* Request size > 128MB does not make much sense... */
- if( reqSizeArg > 0L && reqSizeArg < 128L ) {
- maxBigRequestSize = (reqSizeArg * 1048576L) - 1L;
- }
- else
- {
- UseMsg();
- }
- }
- else
- {
- UseMsg();
- }
- }
+ else if (strcmp(argv[i], "-maxbigreqsize") == 0) {
+ if (++i < argc) {
+ long reqSizeArg = atol(argv[i]);
+
+ /* Request size > 128MB does not make much sense... */
+ if (reqSizeArg > 0L && reqSizeArg < 128L) {
+ maxBigRequestSize = (reqSizeArg * 1048576L) - 1L;
+ }
+ else {
+ UseMsg();
+ }
+ }
+ else {
+ UseMsg();
+ }
+ }
#ifdef PANORAMIX
- else if ( strcmp( argv[i], "+xinerama") == 0){
- noPanoramiXExtension = FALSE;
- }
- else if ( strcmp( argv[i], "-xinerama") == 0){
- noPanoramiXExtension = TRUE;
- }
- else if ( strcmp( argv[i], "-disablexineramaextension") == 0){
- PanoramiXExtensionDisabledHack = TRUE;
- }
-#endif
- else if ( strcmp( argv[i], "-I") == 0)
- {
- /* ignore all remaining arguments */
- break;
- }
- else if (strncmp (argv[i], "tty", 3) == 0)
- {
+ else if (strcmp(argv[i], "+xinerama") == 0) {
+ noPanoramiXExtension = FALSE;
+ }
+ else if (strcmp(argv[i], "-xinerama") == 0) {
+ noPanoramiXExtension = TRUE;
+ }
+ else if (strcmp(argv[i], "-disablexineramaextension") == 0) {
+ PanoramiXExtensionDisabledHack = TRUE;
+ }
+#endif
+ else if (strcmp(argv[i], "-I") == 0) {
+ /* ignore all remaining arguments */
+ break;
+ }
+ else if (strncmp(argv[i], "tty", 3) == 0) {
/* init supplies us with this useless information */
- }
+ }
#ifdef XDMCP
- else if ((skip = XdmcpOptions(argc, argv, i)) != i)
- {
- i = skip - 1;
- }
-#endif
- else if ( strcmp( argv[i], "-dumbSched") == 0)
- {
- SmartScheduleDisable = TRUE;
- }
- else if ( strcmp( argv[i], "-schedInterval") == 0)
- {
- if (++i < argc)
- {
- SmartScheduleInterval = atoi(argv[i]);
- SmartScheduleSlice = SmartScheduleInterval;
- }
- else
- UseMsg();
- }
- else if ( strcmp( argv[i], "-schedMax") == 0)
- {
- if (++i < argc)
- {
- SmartScheduleMaxSlice = atoi(argv[i]);
- }
- else
- UseMsg();
- }
- else if ( strcmp( argv[i], "-render" ) == 0)
- {
- if (++i < argc)
- {
- int policy = PictureParseCmapPolicy (argv[i]);
-
- if (policy != PictureCmapPolicyInvalid)
- PictureCmapPolicy = policy;
- else
- UseMsg ();
- }
- else
- UseMsg ();
- }
- else if ( strcmp( argv[i], "-sigstop") == 0)
- {
- RunFromSigStopParent = TRUE;
- }
- else if ( strcmp( argv[i], "+extension") == 0)
- {
- if (++i < argc)
- {
- if (!EnableDisableExtension(argv[i], TRUE))
- EnableDisableExtensionError(argv[i], TRUE);
- }
- else
- UseMsg();
- }
- else if ( strcmp( argv[i], "-extension") == 0)
- {
- if (++i < argc)
- {
- if (!EnableDisableExtension(argv[i], FALSE))
- EnableDisableExtensionError(argv[i], FALSE);
- }
- else
- UseMsg();
- }
- else
- {
- ErrorF("Unrecognized option: %s\n", argv[i]);
- UseMsg();
- FatalError("Unrecognized option: %s\n", argv[i]);
+ else if ((skip = XdmcpOptions(argc, argv, i)) != i) {
+ i = skip - 1;
+ }
+#endif
+ else if (strcmp(argv[i], "-dumbSched") == 0) {
+ SmartScheduleDisable = TRUE;
+ }
+ else if (strcmp(argv[i], "-schedInterval") == 0) {
+ if (++i < argc) {
+ SmartScheduleInterval = atoi(argv[i]);
+ SmartScheduleSlice = SmartScheduleInterval;
+ }
+ else
+ UseMsg();
+ }
+ else if (strcmp(argv[i], "-schedMax") == 0) {
+ if (++i < argc) {
+ SmartScheduleMaxSlice = atoi(argv[i]);
+ }
+ else
+ UseMsg();
+ }
+ else if (strcmp(argv[i], "-render") == 0) {
+ if (++i < argc) {
+ int policy = PictureParseCmapPolicy(argv[i]);
+
+ if (policy != PictureCmapPolicyInvalid)
+ PictureCmapPolicy = policy;
+ else
+ UseMsg();
+ }
+ else
+ UseMsg();
+ }
+ else if (strcmp(argv[i], "-sigstop") == 0) {
+ RunFromSigStopParent = TRUE;
+ }
+ else if (strcmp(argv[i], "+extension") == 0) {
+ if (++i < argc) {
+ if (!EnableDisableExtension(argv[i], TRUE))
+ EnableDisableExtensionError(argv[i], TRUE);
+ }
+ else
+ UseMsg();
+ }
+ else if (strcmp(argv[i], "-extension") == 0) {
+ if (++i < argc) {
+ if (!EnableDisableExtension(argv[i], FALSE))
+ EnableDisableExtensionError(argv[i], FALSE);
+ }
+ else
+ UseMsg();
+ }
+ else {
+ ErrorF("Unrecognized option: %s\n", argv[i]);
+ UseMsg();
+ FatalError("Unrecognized option: %s\n", argv[i]);
}
}
}
@@ -972,61 +931,63 @@ set_font_authorizations(char **authorizations, int *authlen, pointer client)
static char *result = NULL;
static char *p = NULL;
- if (p == NULL)
- {
- char hname[1024], *hnameptr;
- unsigned int len;
+ if (p == NULL) {
+ char hname[1024], *hnameptr;
+ unsigned int len;
+
#if defined(IPv6) && defined(AF_INET6)
- struct addrinfo hints, *ai = NULL;
+ struct addrinfo hints, *ai = NULL;
#else
- struct hostent *host;
+ struct hostent *host;
+
#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
- _Xgethostbynameparams hparams;
+ _Xgethostbynameparams hparams;
#endif
#endif
- gethostname(hname, 1024);
+ gethostname(hname, 1024);
#if defined(IPv6) && defined(AF_INET6)
- memset(&hints, 0, sizeof(hints));
- hints.ai_flags = AI_CANONNAME;
- if (getaddrinfo(hname, NULL, &hints, &ai) == 0) {
- hnameptr = ai->ai_canonname;
- } else {
- hnameptr = hname;
- }
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_flags = AI_CANONNAME;
+ if (getaddrinfo(hname, NULL, &hints, &ai) == 0) {
+ hnameptr = ai->ai_canonname;
+ }
+ else {
+ hnameptr = hname;
+ }
#else
- host = _XGethostbyname(hname, hparams);
- if (host == NULL)
- hnameptr = hname;
- else
- hnameptr = host->h_name;
+ host = _XGethostbyname(hname, hparams);
+ if (host == NULL)
+ hnameptr = hname;
+ else
+ hnameptr = host->h_name;
#endif
- len = strlen(hnameptr) + 1;
- result = malloc(len + sizeof(AUTHORIZATION_NAME) + 4);
+ len = strlen(hnameptr) + 1;
+ result = malloc(len + sizeof(AUTHORIZATION_NAME) + 4);
- p = result;
+ p = result;
*p++ = sizeof(AUTHORIZATION_NAME) >> 8;
*p++ = sizeof(AUTHORIZATION_NAME) & 0xff;
*p++ = (len) >> 8;
*p++ = (len & 0xff);
- memmove(p, AUTHORIZATION_NAME, sizeof(AUTHORIZATION_NAME));
- p += sizeof(AUTHORIZATION_NAME);
- memmove(p, hnameptr, len);
- p += len;
+ memmove(p, AUTHORIZATION_NAME, sizeof(AUTHORIZATION_NAME));
+ p += sizeof(AUTHORIZATION_NAME);
+ memmove(p, hnameptr, len);
+ p += len;
#if defined(IPv6) && defined(AF_INET6)
- if (ai) {
- freeaddrinfo(ai);
- }
+ if (ai) {
+ freeaddrinfo(ai);
+ }
#endif
}
*authlen = p - result;
*authorizations = result;
return 1;
-#else /* TCPCONN */
+#else /* TCPCONN */
return 0;
-#endif /* TCPCONN */
+#endif /* TCPCONN */
}
void *
@@ -1039,9 +1000,9 @@ Xalloc(unsigned long amount)
*
* -- Mikhail Gusarov
*/
- if ((long)amount <= 0)
- ErrorF("Warning: Xalloc: "
- "requesting unpleasantly large amount of memory: %lu bytes.\n",
+ if ((long) amount <= 0)
+ ErrorF("Warning: Xalloc: "
+ "requesting unpleasantly large amount of memory: %lu bytes.\n",
amount);
return malloc(amount);
@@ -1051,6 +1012,7 @@ void *
XNFalloc(unsigned long amount)
{
void *ptr = malloc(amount);
+
if (!ptr)
FatalError("Out of memory");
return ptr;
@@ -1066,6 +1028,7 @@ void *
XNFcalloc(unsigned long amount)
{
void *ret = calloc(1, amount);
+
if (!ret)
FatalError("XNFcalloc: Out of memory");
return ret;
@@ -1081,9 +1044,9 @@ Xrealloc(void *ptr, unsigned long amount)
*
* -- Mikhail Gusarov
*/
- if ((long)amount <= 0)
- ErrorF("Warning: Xrealloc: "
- "requesting unpleasantly large amount of memory: %lu bytes.\n",
+ if ((long) amount <= 0)
+ ErrorF("Warning: Xrealloc: "
+ "requesting unpleasantly large amount of memory: %lu bytes.\n",
amount);
return realloc(ptr, amount);
@@ -1093,8 +1056,9 @@ void *
XNFrealloc(void *ptr, unsigned long amount)
{
void *ret = realloc(ptr, amount);
+
if (!ret)
- FatalError("XNFrealloc: Out of memory");
+ FatalError("XNFrealloc: Out of memory");
return ret;
}
@@ -1104,12 +1068,11 @@ Xfree(void *ptr)
free(ptr);
}
-
char *
Xstrdup(const char *s)
{
if (s == NULL)
- return NULL;
+ return NULL;
return strdup(s);
}
@@ -1119,107 +1082,104 @@ XNFstrdup(const char *s)
char *ret;
if (s == NULL)
- return NULL;
+ return NULL;
ret = strdup(s);
if (!ret)
- FatalError("XNFstrdup: Out of memory");
+ FatalError("XNFstrdup: Out of memory");
return ret;
}
void
-SmartScheduleStopTimer (void)
+SmartScheduleStopTimer(void)
{
- struct itimerval timer;
-
+ struct itimerval timer;
+
if (SmartScheduleDisable)
- return;
+ return;
timer.it_interval.tv_sec = 0;
timer.it_interval.tv_usec = 0;
timer.it_value.tv_sec = 0;
timer.it_value.tv_usec = 0;
- (void) setitimer (ITIMER_REAL, &timer, 0);
+ (void) setitimer(ITIMER_REAL, &timer, 0);
}
void
-SmartScheduleStartTimer (void)
+SmartScheduleStartTimer(void)
{
- struct itimerval timer;
-
+ struct itimerval timer;
+
if (SmartScheduleDisable)
- return;
+ return;
timer.it_interval.tv_sec = 0;
timer.it_interval.tv_usec = SmartScheduleInterval * 1000;
timer.it_value.tv_sec = 0;
timer.it_value.tv_usec = SmartScheduleInterval * 1000;
- setitimer (ITIMER_REAL, &timer, 0);
+ setitimer(ITIMER_REAL, &timer, 0);
}
static void
-SmartScheduleTimer (int sig)
+SmartScheduleTimer(int sig)
{
SmartScheduleTime += SmartScheduleInterval;
}
void
-SmartScheduleInit (void)
+SmartScheduleInit(void)
{
- struct sigaction act;
+ struct sigaction act;
if (SmartScheduleDisable)
- return;
+ return;
memset((char *) &act, 0, sizeof(struct sigaction));
/* Set up the timer signal function */
act.sa_handler = SmartScheduleTimer;
- sigemptyset (&act.sa_mask);
- sigaddset (&act.sa_mask, SIGALRM);
- if (sigaction (SIGALRM, &act, 0) < 0)
- {
- perror ("sigaction for smart scheduler");
- SmartScheduleDisable = TRUE;
+ sigemptyset(&act.sa_mask);
+ sigaddset(&act.sa_mask, SIGALRM);
+ if (sigaction(SIGALRM, &act, 0) < 0) {
+ perror("sigaction for smart scheduler");
+ SmartScheduleDisable = TRUE;
}
}
#ifdef SIG_BLOCK
-static sigset_t PreviousSignalMask;
-static int BlockedSignalCount;
+static sigset_t PreviousSignalMask;
+static int BlockedSignalCount;
#endif
void
-OsBlockSignals (void)
+OsBlockSignals(void)
{
#ifdef SIG_BLOCK
- if (BlockedSignalCount++ == 0)
- {
- sigset_t set;
-
- sigemptyset (&set);
- sigaddset (&set, SIGALRM);
- sigaddset (&set, SIGVTALRM);
+ if (BlockedSignalCount++ == 0) {
+ sigset_t set;
+
+ sigemptyset(&set);
+ sigaddset(&set, SIGALRM);
+ sigaddset(&set, SIGVTALRM);
#ifdef SIGWINCH
- sigaddset (&set, SIGWINCH);
+ sigaddset(&set, SIGWINCH);
#endif
#ifdef SIGIO
- sigaddset (&set, SIGIO);
+ sigaddset(&set, SIGIO);
#endif
- sigaddset (&set, SIGTSTP);
- sigaddset (&set, SIGTTIN);
- sigaddset (&set, SIGTTOU);
- sigaddset (&set, SIGCHLD);
- sigprocmask (SIG_BLOCK, &set, &PreviousSignalMask);
+ sigaddset(&set, SIGTSTP);
+ sigaddset(&set, SIGTTIN);
+ sigaddset(&set, SIGTTOU);
+ sigaddset(&set, SIGCHLD);
+ sigprocmask(SIG_BLOCK, &set, &PreviousSignalMask);
}
#endif
}
void
-OsReleaseSignals (void)
+OsReleaseSignals(void)
{
#ifdef SIG_BLOCK
- if (--BlockedSignalCount == 0)
- {
- sigprocmask (SIG_SETMASK, &PreviousSignalMask, 0);
+ if (--BlockedSignalCount == 0) {
+ sigprocmask(SIG_SETMASK, &PreviousSignalMask, 0);
}
#endif
}
@@ -1230,7 +1190,7 @@ OsReleaseSignals (void)
*/
void
-OsAbort (void)
+OsAbort(void)
{
#ifndef __APPLE__
OsBlockSignals();
@@ -1253,39 +1213,39 @@ int
System(const char *command)
{
int pid, p;
- void (*csig)(int);
+ void (*csig) (int);
int status;
if (!command)
- return 1;
+ return 1;
csig = signal(SIGCHLD, SIG_DFL);
if (csig == SIG_ERR) {
- perror("signal");
- return -1;
+ perror("signal");
+ return -1;
}
DebugF("System: `%s'\n", command);
switch (pid = fork()) {
- case -1: /* error */
- p = -1;
- case 0: /* child */
- if (setgid(getgid()) == -1)
- _exit(127);
- if (setuid(getuid()) == -1)
- _exit(127);
- execl("/bin/sh", "sh", "-c", command, (char *)NULL);
- _exit(127);
- default: /* parent */
- do {
- p = waitpid(pid, &status, 0);
- } while (p == -1 && errno == EINTR);
-
+ case -1: /* error */
+ p = -1;
+ case 0: /* child */
+ if (setgid(getgid()) == -1)
+ _exit(127);
+ if (setuid(getuid()) == -1)
+ _exit(127);
+ execl("/bin/sh", "sh", "-c", command, (char *) NULL);
+ _exit(127);
+ default: /* parent */
+ do {
+ p = waitpid(pid, &status, 0);
+ } while (p == -1 && errno == EINTR);
+
}
if (signal(SIGCHLD, csig) == SIG_ERR) {
- perror("signal");
- return -1;
+ perror("signal");
+ return -1;
}
return p == -1 ? -1 : status;
@@ -1297,7 +1257,7 @@ static struct pid {
int pid;
} *pidlist;
-OsSigHandlerPtr old_alarm = NULL; /* XXX horrible awful hack */
+OsSigHandlerPtr old_alarm = NULL; /* XXX horrible awful hack */
pointer
Popen(const char *command, const char *type)
@@ -1307,71 +1267,73 @@ Popen(const char *command, const char *type)
int pdes[2], pid;
if (command == NULL || type == NULL)
- return NULL;
+ return NULL;
if ((*type != 'r' && *type != 'w') || type[1])
- return NULL;
+ return NULL;
if ((cur = malloc(sizeof(struct pid))) == NULL)
- return NULL;
+ return NULL;
if (pipe(pdes) < 0) {
- free(cur);
- return NULL;
+ free(cur);
+ return NULL;
}
/* Ignore the smart scheduler while this is going on */
old_alarm = OsSignal(SIGALRM, SIG_IGN);
if (old_alarm == SIG_ERR) {
- close(pdes[0]);
- close(pdes[1]);
- free(cur);
- perror("signal");
- return NULL;
+ close(pdes[0]);
+ close(pdes[1]);
+ free(cur);
+ perror("signal");
+ return NULL;
}
switch (pid = fork()) {
- case -1: /* error */
- close(pdes[0]);
- close(pdes[1]);
- free(cur);
- if (OsSignal(SIGALRM, old_alarm) == SIG_ERR)
- perror("signal");
- return NULL;
- case 0: /* child */
- if (setgid(getgid()) == -1)
- _exit(127);
- if (setuid(getuid()) == -1)
- _exit(127);
- if (*type == 'r') {
- if (pdes[1] != 1) {
- /* stdout */
- dup2(pdes[1], 1);
- close(pdes[1]);
- }
- close(pdes[0]);
- } else {
- if (pdes[0] != 0) {
- /* stdin */
- dup2(pdes[0], 0);
- close(pdes[0]);
- }
- close(pdes[1]);
- }
- execl("/bin/sh", "sh", "-c", command, (char *)NULL);
- _exit(127);
+ case -1: /* error */
+ close(pdes[0]);
+ close(pdes[1]);
+ free(cur);
+ if (OsSignal(SIGALRM, old_alarm) == SIG_ERR)
+ perror("signal");
+ return NULL;
+ case 0: /* child */
+ if (setgid(getgid()) == -1)
+ _exit(127);
+ if (setuid(getuid()) == -1)
+ _exit(127);
+ if (*type == 'r') {
+ if (pdes[1] != 1) {
+ /* stdout */
+ dup2(pdes[1], 1);
+ close(pdes[1]);
+ }
+ close(pdes[0]);
+ }
+ else {
+ if (pdes[0] != 0) {
+ /* stdin */
+ dup2(pdes[0], 0);
+ close(pdes[0]);
+ }
+ close(pdes[1]);
+ }
+ execl("/bin/sh", "sh", "-c", command, (char *) NULL);
+ _exit(127);
}
/* Avoid EINTR during stdio calls */
- OsBlockSignals ();
-
+ OsBlockSignals();
+
/* parent */
if (*type == 'r') {
- iop = fdopen(pdes[0], type);
- close(pdes[1]);
- } else {
- iop = fdopen(pdes[1], type);
- close(pdes[0]);
+ iop = fdopen(pdes[0], type);
+ close(pdes[1]);
+ }
+ else {
+ iop = fdopen(pdes[1], type);
+ close(pdes[0]);
}
cur->fp = iop;
@@ -1389,64 +1351,67 @@ pointer
Fopen(const char *file, const char *type)
{
FILE *iop;
+
#ifndef HAS_SAVED_IDS_AND_SETEUID
struct pid *cur;
int pdes[2], pid;
if (file == NULL || type == NULL)
- return NULL;
+ return NULL;
if ((*type != 'r' && *type != 'w') || type[1])
- return NULL;
+ return NULL;
if ((cur = malloc(sizeof(struct pid))) == NULL)
- return NULL;
+ return NULL;
if (pipe(pdes) < 0) {
- free(cur);
- return NULL;
+ free(cur);
+ return NULL;
}
switch (pid = fork()) {
- case -1: /* error */
- close(pdes[0]);
- close(pdes[1]);
- free(cur);
- return NULL;
- case 0: /* child */
- if (setgid(getgid()) == -1)
- _exit(127);
- if (setuid(getuid()) == -1)
- _exit(127);
- if (*type == 'r') {
- if (pdes[1] != 1) {
- /* stdout */
- dup2(pdes[1], 1);
- close(pdes[1]);
- }
- close(pdes[0]);
- } else {
- if (pdes[0] != 0) {
- /* stdin */
- dup2(pdes[0], 0);
- close(pdes[0]);
- }
- close(pdes[1]);
- }
- execl("/bin/cat", "cat", file, (char *)NULL);
- _exit(127);
+ case -1: /* error */
+ close(pdes[0]);
+ close(pdes[1]);
+ free(cur);
+ return NULL;
+ case 0: /* child */
+ if (setgid(getgid()) == -1)
+ _exit(127);
+ if (setuid(getuid()) == -1)
+ _exit(127);
+ if (*type == 'r') {
+ if (pdes[1] != 1) {
+ /* stdout */
+ dup2(pdes[1], 1);
+ close(pdes[1]);
+ }
+ close(pdes[0]);
+ }
+ else {
+ if (pdes[0] != 0) {
+ /* stdin */
+ dup2(pdes[0], 0);
+ close(pdes[0]);
+ }
+ close(pdes[1]);
+ }
+ execl("/bin/cat", "cat", file, (char *) NULL);
+ _exit(127);
}
/* Avoid EINTR during stdio calls */
- OsBlockSignals ();
-
+ OsBlockSignals();
+
/* parent */
if (*type == 'r') {
- iop = fdopen(pdes[0], type);
- close(pdes[1]);
- } else {
- iop = fdopen(pdes[1], type);
- close(pdes[0]);
+ iop = fdopen(pdes[0], type);
+ close(pdes[1]);
+ }
+ else {
+ iop = fdopen(pdes[1], type);
+ close(pdes[0]);
}
cur->fp = iop;
@@ -1462,18 +1427,18 @@ Fopen(const char *file, const char *type)
ruid = getuid();
euid = geteuid();
-
+
if (seteuid(ruid) == -1) {
- return NULL;
+ return NULL;
}
iop = fopen(file, type);
if (seteuid(euid) == -1) {
- fclose(iop);
- return NULL;
+ fclose(iop);
+ return NULL;
}
return iop;
-#endif /* HAS_SAVED_IDS_AND_SETEUID */
+#endif /* HAS_SAVED_IDS_AND_SETEUID */
}
int
@@ -1487,27 +1452,27 @@ Pclose(pointer iop)
fclose(iop);
for (last = NULL, cur = pidlist; cur; last = cur, cur = cur->next)
- if (cur->fp == iop)
- break;
+ if (cur->fp == iop)
+ break;
if (cur == NULL)
- return -1;
+ return -1;
do {
- pid = waitpid(cur->pid, &pstat, 0);
+ pid = waitpid(cur->pid, &pstat, 0);
} while (pid == -1 && errno == EINTR);
if (last == NULL)
- pidlist = cur->next;
+ pidlist = cur->next;
else
- last->next = cur->next;
+ last->next = cur->next;
free(cur);
/* allow EINTR again */
- OsReleaseSignals ();
-
+ OsReleaseSignals();
+
if (old_alarm && OsSignal(SIGALRM, old_alarm) == SIG_ERR) {
- perror("signal");
- return -1;
+ perror("signal");
+ return -1;
}
return pid == -1 ? -1 : pstat;
@@ -1523,8 +1488,7 @@ Fclose(pointer iop)
#endif
}
-#endif /* !WIN32 */
-
+#endif /* !WIN32 */
/*
* CheckUserParameters: check for long command line arguments and long
@@ -1553,7 +1517,6 @@ Fclose(pointer iop)
#define NO_OUTPUT_PIPES 0
#endif
-
/* Check args and env only if running setuid (euid == 0 && euid != uid) ? */
#ifndef CHECK_EUID
#ifndef WIN32
@@ -1573,7 +1536,7 @@ Fclose(pointer iop)
#define MAX_ARG_LENGTH 128
#define MAX_ENV_LENGTH 256
-#define MAX_ENV_PATH_LENGTH 2048 /* Limit for *PATH and TERMCAP */
+#define MAX_ENV_PATH_LENGTH 2048 /* Limit for *PATH and TERMCAP */
#if USE_ISPRINT
#include <ctype.h>
@@ -1611,115 +1574,116 @@ CheckUserParameters(int argc, char **argv, char **envp)
if (geteuid() == 0 && getuid() != geteuid())
#endif
{
- /* Check each argv[] */
- for (i = 1; i < argc; i++) {
- if (strcmp(argv[i], "-fp") == 0)
- {
- i++; /* continue with next argument. skip the length check */
- if (i >= argc)
- break;
- } else
- {
- if (strlen(argv[i]) > MAX_ARG_LENGTH) {
- bad = ArgTooLong;
- break;
- }
- }
- a = argv[i];
- while (*a) {
- if (checkPrintable(*a) == 0) {
- bad = UnprintableArg;
- break;
- }
- a++;
- }
- if (bad)
- break;
- }
- if (!bad) {
- /* Check each envp[] */
- for (i = 0; envp[i]; i++) {
-
- /* Check for bad environment variables and values */
+ /* Check each argv[] */
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-fp") == 0) {
+ i++; /* continue with next argument. skip the length check */
+ if (i >= argc)
+ break;
+ }
+ else {
+ if (strlen(argv[i]) > MAX_ARG_LENGTH) {
+ bad = ArgTooLong;
+ break;
+ }
+ }
+ a = argv[i];
+ while (*a) {
+ if (checkPrintable(*a) == 0) {
+ bad = UnprintableArg;
+ break;
+ }
+ a++;
+ }
+ if (bad)
+ break;
+ }
+ if (!bad) {
+ /* Check each envp[] */
+ for (i = 0; envp[i]; i++) {
+
+ /* Check for bad environment variables and values */
#if REMOVE_ENV_LD
- while (envp[i] && (strncmp(envp[i], "LD", 2) == 0)) {
- for (j = i; envp[j]; j++) {
- envp[j] = envp[j+1];
- }
- }
-#endif
- if (envp[i] && (strlen(envp[i]) > MAX_ENV_LENGTH)) {
+ while (envp[i] && (strncmp(envp[i], "LD", 2) == 0)) {
+ for (j = i; envp[j]; j++) {
+ envp[j] = envp[j + 1];
+ }
+ }
+#endif
+ if (envp[i] && (strlen(envp[i]) > MAX_ENV_LENGTH)) {
#if REMOVE_LONG_ENV
- for (j = i; envp[j]; j++) {
- envp[j] = envp[j+1];
- }
- i--;
+ for (j = i; envp[j]; j++) {
+ envp[j] = envp[j + 1];
+ }
+ i--;
#else
- char *eq;
- int len;
-
- eq = strchr(envp[i], '=');
- if (!eq)
- continue;
- len = eq - envp[i];
- e = strndup(envp[i], len);
- if (!e) {
- bad = InternalError;
- break;
- }
- if (len >= 4 &&
- (strcmp(e + len - 4, "PATH") == 0 ||
- strcmp(e, "TERMCAP") == 0)) {
- if (strlen(envp[i]) > MAX_ENV_PATH_LENGTH) {
- bad = EnvTooLong;
- break;
- } else {
- free(e);
- }
- } else {
- bad = EnvTooLong;
- break;
- }
-#endif
- }
- }
- }
+ char *eq;
+ int len;
+
+ eq = strchr(envp[i], '=');
+ if (!eq)
+ continue;
+ len = eq - envp[i];
+ e = strndup(envp[i], len);
+ if (!e) {
+ bad = InternalError;
+ break;
+ }
+ if (len >= 4 &&
+ (strcmp(e + len - 4, "PATH") == 0 ||
+ strcmp(e, "TERMCAP") == 0)) {
+ if (strlen(envp[i]) > MAX_ENV_PATH_LENGTH) {
+ bad = EnvTooLong;
+ break;
+ }
+ else {
+ free(e);
+ }
+ }
+ else {
+ bad = EnvTooLong;
+ break;
+ }
+#endif
+ }
+ }
+ }
#if NO_OUTPUT_PIPES
- if (!bad) {
- struct stat buf;
+ if (!bad) {
+ struct stat buf;
- if (fstat(fileno(stdout), &buf) == 0 && S_ISFIFO(buf.st_mode))
- bad = OutputIsPipe;
- if (fstat(fileno(stderr), &buf) == 0 && S_ISFIFO(buf.st_mode))
- bad = OutputIsPipe;
- }
+ if (fstat(fileno(stdout), &buf) == 0 && S_ISFIFO(buf.st_mode))
+ bad = OutputIsPipe;
+ if (fstat(fileno(stderr), &buf) == 0 && S_ISFIFO(buf.st_mode))
+ bad = OutputIsPipe;
+ }
#endif
}
switch (bad) {
case NotBad:
- return;
+ return;
case UnsafeArg:
- ErrorF("Command line argument number %d is unsafe\n", i);
- break;
+ ErrorF("Command line argument number %d is unsafe\n", i);
+ break;
case ArgTooLong:
- ErrorF("Command line argument number %d is too long\n", i);
- break;
+ ErrorF("Command line argument number %d is too long\n", i);
+ break;
case UnprintableArg:
- ErrorF("Command line argument number %d contains unprintable"
- " characters\n", i);
- break;
+ ErrorF("Command line argument number %d contains unprintable"
+ " characters\n", i);
+ break;
case EnvTooLong:
- ErrorF("Environment variable `%s' is too long\n", e);
- break;
+ ErrorF("Environment variable `%s' is too long\n", e);
+ break;
case OutputIsPipe:
- ErrorF("Stdout and/or stderr is a pipe\n");
- break;
+ ErrorF("Stdout and/or stderr is a pipe\n");
+ break;
case InternalError:
- ErrorF("Internal Error\n");
- break;
+ ErrorF("Internal Error\n");
+ break;
default:
- ErrorF("Unknown error\n");
- break;
+ ErrorF("Unknown error\n");
+ break;
}
FatalError("X server aborted because of unsafe environment\n");
}
@@ -1734,15 +1698,15 @@ CheckUserParameters(int argc, char **argv, char **envp)
#include <security/pam_appl.h>
#include <security/pam_misc.h>
#include <pwd.h>
-#endif /* USE_PAM */
+#endif /* USE_PAM */
void
CheckUserAuthorization(void)
{
#ifdef USE_PAM
static struct pam_conv conv = {
- misc_conv,
- NULL
+ misc_conv,
+ NULL
};
pam_handle_t *pamh = NULL;
@@ -1750,31 +1714,31 @@ CheckUserAuthorization(void)
int retval;
if (getuid() != geteuid()) {
- pw = getpwuid(getuid());
- if (pw == NULL)
- FatalError("getpwuid() failed for uid %d\n", getuid());
-
- retval = pam_start("xserver", pw->pw_name, &conv, &pamh);
- if (retval != PAM_SUCCESS)
- FatalError("pam_start() failed.\n"
- "\tMissing or mangled PAM config file or module?\n");
-
- retval = pam_authenticate(pamh, 0);
- if (retval != PAM_SUCCESS) {
- pam_end(pamh, retval);
- FatalError("PAM authentication failed, cannot start X server.\n"
- "\tPerhaps you do not have console ownership?\n");
- }
-
- retval = pam_acct_mgmt(pamh, 0);
- if (retval != PAM_SUCCESS) {
- pam_end(pamh, retval);
- FatalError("PAM authentication failed, cannot start X server.\n"
- "\tPerhaps you do not have console ownership?\n");
- }
-
- /* this is not a session, so do not do session management */
- pam_end(pamh, PAM_SUCCESS);
+ pw = getpwuid(getuid());
+ if (pw == NULL)
+ FatalError("getpwuid() failed for uid %d\n", getuid());
+
+ retval = pam_start("xserver", pw->pw_name, &conv, &pamh);
+ if (retval != PAM_SUCCESS)
+ FatalError("pam_start() failed.\n"
+ "\tMissing or mangled PAM config file or module?\n");
+
+ retval = pam_authenticate(pamh, 0);
+ if (retval != PAM_SUCCESS) {
+ pam_end(pamh, retval);
+ FatalError("PAM authentication failed, cannot start X server.\n"
+ "\tPerhaps you do not have console ownership?\n");
+ }
+
+ retval = pam_acct_mgmt(pamh, 0);
+ if (retval != PAM_SUCCESS) {
+ pam_end(pamh, retval);
+ FatalError("PAM authentication failed, cannot start X server.\n"
+ "\tPerhaps you do not have console ownership?\n");
+ }
+
+ /* this is not a session, so do not do session management */
+ pam_end(pamh, PAM_SUCCESS);
}
#endif
}
@@ -1783,7 +1747,7 @@ CheckUserAuthorization(void)
* Tokenize a string into a NULL terminated array of strings. Always returns
* an allocated array unless an error occurs.
*/
-char**
+char **
xstrtokenize(const char *str, const char *separators)
{
char **list, **nlist;
@@ -1811,7 +1775,7 @@ xstrtokenize(const char *str, const char *separators)
free(tmp);
return list;
-error:
+ error:
free(tmp);
for (n = 0; n < num; n++)
free(list[n]);
diff --git a/xorg-server/os/xdmauth.c b/xorg-server/os/xdmauth.c
index 733fda504..28584d2e8 100644
--- a/xorg-server/os/xdmauth.c
+++ b/xorg-server/os/xdmauth.c
@@ -58,390 +58,380 @@ static Bool authFromXDMCP;
/* XDM-AUTHENTICATION-1 */
-static XdmAuthKeyRec privateKey;
+static XdmAuthKeyRec privateKey;
static char XdmAuthenticationName[] = "XDM-AUTHENTICATION-1";
+
#define XdmAuthenticationNameLen (sizeof XdmAuthenticationName - 1)
-static XdmAuthKeyRec rho;
+static XdmAuthKeyRec rho;
-static Bool
-XdmAuthenticationValidator (ARRAY8Ptr privateData, ARRAY8Ptr incomingData,
- xdmOpCode packet_type)
+static Bool
+XdmAuthenticationValidator(ARRAY8Ptr privateData, ARRAY8Ptr incomingData,
+ xdmOpCode packet_type)
{
- XdmAuthKeyPtr incoming;
+ XdmAuthKeyPtr incoming;
- XdmcpUnwrap (incomingData->data, (unsigned char *)&privateKey,
- incomingData->data,incomingData->length);
+ XdmcpUnwrap(incomingData->data, (unsigned char *) &privateKey,
+ incomingData->data, incomingData->length);
if (packet_type == ACCEPT) {
- if (incomingData->length != 8)
- return FALSE;
- incoming = (XdmAuthKeyPtr) incomingData->data;
- XdmcpDecrementKey (incoming);
- return XdmcpCompareKeys (incoming, &rho);
+ if (incomingData->length != 8)
+ return FALSE;
+ incoming = (XdmAuthKeyPtr) incomingData->data;
+ XdmcpDecrementKey(incoming);
+ return XdmcpCompareKeys(incoming, &rho);
}
return FALSE;
}
static Bool
-XdmAuthenticationGenerator (ARRAY8Ptr privateData, ARRAY8Ptr outgoingData,
- xdmOpCode packet_type)
+XdmAuthenticationGenerator(ARRAY8Ptr privateData, ARRAY8Ptr outgoingData,
+ xdmOpCode packet_type)
{
outgoingData->length = 0;
outgoingData->data = 0;
if (packet_type == REQUEST) {
- if (XdmcpAllocARRAY8 (outgoingData, 8))
- XdmcpWrap ((unsigned char *)&rho, (unsigned char *)&privateKey,
- outgoingData->data, 8);
+ if (XdmcpAllocARRAY8(outgoingData, 8))
+ XdmcpWrap((unsigned char *) &rho, (unsigned char *) &privateKey,
+ outgoingData->data, 8);
}
return TRUE;
}
static Bool
-XdmAuthenticationAddAuth (int name_len, const char *name,
- int data_len, char *data)
+XdmAuthenticationAddAuth(int name_len, const char *name,
+ int data_len, char *data)
{
- Bool ret;
- XdmcpUnwrap ((unsigned char *)data, (unsigned char *)&privateKey,
- (unsigned char *)data, data_len);
+ Bool ret;
+
+ XdmcpUnwrap((unsigned char *) data, (unsigned char *) &privateKey,
+ (unsigned char *) data, data_len);
authFromXDMCP = TRUE;
- ret = AddAuthorization (name_len, name, data_len, data);
+ ret = AddAuthorization(name_len, name, data_len, data);
authFromXDMCP = FALSE;
return ret;
}
-
#define atox(c) ('0' <= c && c <= '9' ? c - '0' : \
'a' <= c && c <= 'f' ? c - 'a' + 10 : \
'A' <= c && c <= 'F' ? c - 'A' + 10 : -1)
static int
-HexToBinary (const char *in, char *out, int len)
+HexToBinary(const char *in, char *out, int len)
{
- int top, bottom;
-
- while (len > 0)
- {
- top = atox(in[0]);
- if (top == -1)
- return 0;
- bottom = atox(in[1]);
- if (bottom == -1)
- return 0;
- *out++ = (top << 4) | bottom;
- in += 2;
- len -= 2;
+ int top, bottom;
+
+ while (len > 0) {
+ top = atox(in[0]);
+ if (top == -1)
+ return 0;
+ bottom = atox(in[1]);
+ if (bottom == -1)
+ return 0;
+ *out++ = (top << 4) | bottom;
+ in += 2;
+ len -= 2;
}
if (len)
- return 0;
+ return 0;
*out++ = '\0';
return 1;
}
void
-XdmAuthenticationInit (const char *cookie, int cookie_len)
+XdmAuthenticationInit(const char *cookie, int cookie_len)
{
memset(privateKey.data, 0, 8);
- if (!strncmp (cookie, "0x", 2) || !strncmp (cookie, "0X", 2))
- {
- if (cookie_len > 2 + 2 * 8)
- cookie_len = 2 + 2 * 8;
- HexToBinary (cookie + 2, (char *)privateKey.data, cookie_len - 2);
+ if (!strncmp(cookie, "0x", 2) || !strncmp(cookie, "0X", 2)) {
+ if (cookie_len > 2 + 2 * 8)
+ cookie_len = 2 + 2 * 8;
+ HexToBinary(cookie + 2, (char *) privateKey.data, cookie_len - 2);
}
- else
- {
- if (cookie_len > 7)
- cookie_len = 7;
- memmove (privateKey.data + 1, cookie, cookie_len);
+ else {
+ if (cookie_len > 7)
+ cookie_len = 7;
+ memmove(privateKey.data + 1, cookie, cookie_len);
}
- XdmcpGenerateKey (&rho);
- XdmcpRegisterAuthentication (XdmAuthenticationName, XdmAuthenticationNameLen,
- (char *)&rho,
- sizeof (rho),
- (ValidatorFunc)XdmAuthenticationValidator,
- (GeneratorFunc)XdmAuthenticationGenerator,
- (AddAuthorFunc)XdmAuthenticationAddAuth);
+ XdmcpGenerateKey(&rho);
+ XdmcpRegisterAuthentication(XdmAuthenticationName, XdmAuthenticationNameLen,
+ (char *) &rho,
+ sizeof(rho),
+ (ValidatorFunc) XdmAuthenticationValidator,
+ (GeneratorFunc) XdmAuthenticationGenerator,
+ (AddAuthorFunc) XdmAuthenticationAddAuth);
}
-#endif /* XDMCP */
+#endif /* XDMCP */
/* XDM-AUTHORIZATION-1 */
typedef struct _XdmAuthorization {
- struct _XdmAuthorization *next;
- XdmAuthKeyRec rho;
- XdmAuthKeyRec key;
- XID id;
+ struct _XdmAuthorization *next;
+ XdmAuthKeyRec rho;
+ XdmAuthKeyRec key;
+ XID id;
} XdmAuthorizationRec, *XdmAuthorizationPtr;
static XdmAuthorizationPtr xdmAuth;
typedef struct _XdmClientAuth {
- struct _XdmClientAuth *next;
- XdmAuthKeyRec rho;
- char client[6];
- long time;
+ struct _XdmClientAuth *next;
+ XdmAuthKeyRec rho;
+ char client[6];
+ long time;
} XdmClientAuthRec, *XdmClientAuthPtr;
-static XdmClientAuthPtr xdmClients;
-static long clockOffset;
-static Bool gotClock;
+static XdmClientAuthPtr xdmClients;
+static long clockOffset;
+static Bool gotClock;
#define TwentyMinutes (20 * 60)
#define TwentyFiveMinutes (25 * 60)
static Bool
-XdmClientAuthCompare (const XdmClientAuthPtr a, const XdmClientAuthPtr b)
+XdmClientAuthCompare(const XdmClientAuthPtr a, const XdmClientAuthPtr b)
{
- int i;
+ int i;
- if (!XdmcpCompareKeys (&a->rho, &b->rho))
- return FALSE;
+ if (!XdmcpCompareKeys(&a->rho, &b->rho))
+ return FALSE;
for (i = 0; i < 6; i++)
- if (a->client[i] != b->client[i])
- return FALSE;
+ if (a->client[i] != b->client[i])
+ return FALSE;
return a->time == b->time;
}
static void
-XdmClientAuthDecode (const unsigned char *plain, XdmClientAuthPtr auth)
+XdmClientAuthDecode(const unsigned char *plain, XdmClientAuthPtr auth)
{
- int i, j;
+ int i, j;
j = 0;
- for (i = 0; i < 8; i++)
- {
- auth->rho.data[i] = plain[j];
- ++j;
+ for (i = 0; i < 8; i++) {
+ auth->rho.data[i] = plain[j];
+ ++j;
}
- for (i = 0; i < 6; i++)
- {
- auth->client[i] = plain[j];
- ++j;
+ for (i = 0; i < 6; i++) {
+ auth->client[i] = plain[j];
+ ++j;
}
auth->time = 0;
- for (i = 0; i < 4; i++)
- {
- auth->time |= plain[j] << ((3 - i) << 3);
- j++;
+ for (i = 0; i < 4; i++) {
+ auth->time |= plain[j] << ((3 - i) << 3);
+ j++;
}
}
static void
-XdmClientAuthTimeout (long now)
+XdmClientAuthTimeout(long now)
{
- XdmClientAuthPtr client, next, prev;
+ XdmClientAuthPtr client, next, prev;
prev = 0;
- for (client = xdmClients; client; client=next)
- {
- next = client->next;
- if (abs (now - client->time) > TwentyFiveMinutes)
- {
- if (prev)
- prev->next = next;
- else
- xdmClients = next;
- free(client);
- }
- else
- prev = client;
+ for (client = xdmClients; client; client = next) {
+ next = client->next;
+ if (abs(now - client->time) > TwentyFiveMinutes) {
+ if (prev)
+ prev->next = next;
+ else
+ xdmClients = next;
+ free(client);
+ }
+ else
+ prev = client;
}
}
static XdmClientAuthPtr
-XdmAuthorizationValidate (unsigned char *plain, int length,
- XdmAuthKeyPtr rho, ClientPtr xclient, const char **reason)
+XdmAuthorizationValidate(unsigned char *plain, int length,
+ XdmAuthKeyPtr rho, ClientPtr xclient,
+ const char **reason)
{
- XdmClientAuthPtr client, existing;
- long now;
- int i;
+ XdmClientAuthPtr client, existing;
+ long now;
+ int i;
if (length != (192 / 8)) {
- if (reason)
- *reason = "Bad XDM authorization key length";
- return NULL;
+ if (reason)
+ *reason = "Bad XDM authorization key length";
+ return NULL;
}
- client = malloc(sizeof (XdmClientAuthRec));
+ client = malloc(sizeof(XdmClientAuthRec));
if (!client)
- return NULL;
- XdmClientAuthDecode (plain, client);
- if (!XdmcpCompareKeys (&client->rho, rho))
- {
- free(client);
- if (reason)
- *reason = "Invalid XDM-AUTHORIZATION-1 key (failed key comparison)";
- return NULL;
+ return NULL;
+ XdmClientAuthDecode(plain, client);
+ if (!XdmcpCompareKeys(&client->rho, rho)) {
+ free(client);
+ if (reason)
+ *reason = "Invalid XDM-AUTHORIZATION-1 key (failed key comparison)";
+ return NULL;
}
for (i = 18; i < 24; i++)
- if (plain[i] != 0) {
- free(client);
- if (reason)
- *reason = "Invalid XDM-AUTHORIZATION-1 key (failed NULL check)";
- return NULL;
- }
+ if (plain[i] != 0) {
+ free(client);
+ if (reason)
+ *reason = "Invalid XDM-AUTHORIZATION-1 key (failed NULL check)";
+ return NULL;
+ }
if (xclient) {
- int family, addr_len;
- Xtransaddr *addr;
+ int family, addr_len;
+ Xtransaddr *addr;
- if (_XSERVTransGetPeerAddr(((OsCommPtr)xclient->osPrivate)->trans_conn,
- &family, &addr_len, &addr) == 0
- && _XSERVTransConvertAddress(&family, &addr_len, &addr) == 0) {
+ if (_XSERVTransGetPeerAddr(((OsCommPtr) xclient->osPrivate)->trans_conn,
+ &family, &addr_len, &addr) == 0
+ && _XSERVTransConvertAddress(&family, &addr_len, &addr) == 0) {
#if defined(TCPCONN) || defined(STREAMSCONN)
- if (family == FamilyInternet &&
- memcmp((char *)addr, client->client, 4) != 0) {
- free(client);
- free(addr);
- if (reason)
- *reason = "Invalid XDM-AUTHORIZATION-1 key (failed address comparison)";
- return NULL;
-
- }
+ if (family == FamilyInternet &&
+ memcmp((char *) addr, client->client, 4) != 0) {
+ free(client);
+ free(addr);
+ if (reason)
+ *reason =
+ "Invalid XDM-AUTHORIZATION-1 key (failed address comparison)";
+ return NULL;
+
+ }
#endif
- free(addr);
- }
+ free(addr);
+ }
}
now = time(0);
- if (!gotClock)
- {
- clockOffset = client->time - now;
- gotClock = TRUE;
+ if (!gotClock) {
+ clockOffset = client->time - now;
+ gotClock = TRUE;
}
now += clockOffset;
- XdmClientAuthTimeout (now);
- if (abs (client->time - now) > TwentyMinutes)
- {
- free(client);
- if (reason)
- *reason = "Excessive XDM-AUTHORIZATION-1 time offset";
- return NULL;
+ XdmClientAuthTimeout(now);
+ if (abs(client->time - now) > TwentyMinutes) {
+ free(client);
+ if (reason)
+ *reason = "Excessive XDM-AUTHORIZATION-1 time offset";
+ return NULL;
}
- for (existing = xdmClients; existing; existing=existing->next)
- {
- if (XdmClientAuthCompare (existing, client))
- {
- free(client);
- if (reason)
- *reason = "XDM authorization key matches an existing client!";
- return NULL;
- }
+ for (existing = xdmClients; existing; existing = existing->next) {
+ if (XdmClientAuthCompare(existing, client)) {
+ free(client);
+ if (reason)
+ *reason = "XDM authorization key matches an existing client!";
+ return NULL;
+ }
}
return client;
}
int
-XdmAddCookie (unsigned short data_length, const char *data, XID id)
+XdmAddCookie(unsigned short data_length, const char *data, XID id)
{
- XdmAuthorizationPtr new;
- unsigned char *rho_bits, *key_bits;
+ XdmAuthorizationPtr new;
+ unsigned char *rho_bits, *key_bits;
- switch (data_length)
- {
- case 16: /* auth from files is 16 bytes long */
+ switch (data_length) {
+ case 16: /* auth from files is 16 bytes long */
#ifdef XDMCP
- if (authFromXDMCP)
- {
- /* R5 xdm sent bogus authorization data in the accept packet,
- * but we can recover */
- rho_bits = rho.data;
- key_bits = (unsigned char *) data;
- key_bits[0] = '\0';
- }
- else
+ if (authFromXDMCP) {
+ /* R5 xdm sent bogus authorization data in the accept packet,
+ * but we can recover */
+ rho_bits = rho.data;
+ key_bits = (unsigned char *) data;
+ key_bits[0] = '\0';
+ }
+ else
#endif
- {
- rho_bits = (unsigned char *) data;
- key_bits = (unsigned char *) (data + 8);
- }
- break;
+ {
+ rho_bits = (unsigned char *) data;
+ key_bits = (unsigned char *) (data + 8);
+ }
+ break;
#ifdef XDMCP
- case 8: /* auth from XDMCP is 8 bytes long */
- rho_bits = rho.data;
- key_bits = (unsigned char *) data;
- break;
+ case 8: /* auth from XDMCP is 8 bytes long */
+ rho_bits = rho.data;
+ key_bits = (unsigned char *) data;
+ break;
#endif
default:
- return 0;
+ return 0;
}
/* the first octet of the key must be zero */
if (key_bits[0] != '\0')
- return 0;
- new = malloc(sizeof (XdmAuthorizationRec));
+ return 0;
+ new = malloc(sizeof(XdmAuthorizationRec));
if (!new)
- return 0;
+ return 0;
new->next = xdmAuth;
xdmAuth = new;
- memmove (new->key.data, key_bits, (int) 8);
- memmove (new->rho.data, rho_bits, (int) 8);
+ memmove(new->key.data, key_bits, (int) 8);
+ memmove(new->rho.data, rho_bits, (int) 8);
new->id = id;
return 1;
}
XID
-XdmCheckCookie (unsigned short cookie_length, const char *cookie,
- ClientPtr xclient, const char **reason)
+XdmCheckCookie(unsigned short cookie_length, const char *cookie,
+ ClientPtr xclient, const char **reason)
{
- XdmAuthorizationPtr auth;
- XdmClientAuthPtr client;
- unsigned char *plain;
+ XdmAuthorizationPtr auth;
+ XdmClientAuthPtr client;
+ unsigned char *plain;
/* Auth packets must be a multiple of 8 bytes long */
if (cookie_length & 7)
- return (XID) -1;
+ return (XID) -1;
plain = malloc(cookie_length);
if (!plain)
- return (XID) -1;
- for (auth = xdmAuth; auth; auth=auth->next) {
- XdmcpUnwrap ((unsigned char *)cookie, (unsigned char *)&auth->key, plain, cookie_length);
- if ((client = XdmAuthorizationValidate (plain, cookie_length, &auth->rho, xclient, reason)) != NULL)
- {
- client->next = xdmClients;
- xdmClients = client;
- free(plain);
- return auth->id;
- }
+ return (XID) -1;
+ for (auth = xdmAuth; auth; auth = auth->next) {
+ XdmcpUnwrap((unsigned char *) cookie, (unsigned char *) &auth->key,
+ plain, cookie_length);
+ if ((client =
+ XdmAuthorizationValidate(plain, cookie_length, &auth->rho, xclient,
+ reason)) != NULL) {
+ client->next = xdmClients;
+ xdmClients = client;
+ free(plain);
+ return auth->id;
+ }
}
free(plain);
return (XID) -1;
}
int
-XdmResetCookie (void)
+XdmResetCookie(void)
{
- XdmAuthorizationPtr auth, next_auth;
- XdmClientAuthPtr client, next_client;
+ XdmAuthorizationPtr auth, next_auth;
+ XdmClientAuthPtr client, next_client;
- for (auth = xdmAuth; auth; auth=next_auth)
- {
- next_auth = auth->next;
- free(auth);
+ for (auth = xdmAuth; auth; auth = next_auth) {
+ next_auth = auth->next;
+ free(auth);
}
xdmAuth = 0;
- for (client = xdmClients; client; client=next_client)
- {
- next_client = client->next;
- free(client);
+ for (client = xdmClients; client; client = next_client) {
+ next_client = client->next;
+ free(client);
}
xdmClients = (XdmClientAuthPtr) 0;
return 1;
}
XID
-XdmToID (unsigned short cookie_length, char *cookie)
+XdmToID(unsigned short cookie_length, char *cookie)
{
- XdmAuthorizationPtr auth;
- XdmClientAuthPtr client;
- unsigned char *plain;
+ XdmAuthorizationPtr auth;
+ XdmClientAuthPtr client;
+ unsigned char *plain;
plain = malloc(cookie_length);
if (!plain)
- return (XID) -1;
- for (auth = xdmAuth; auth; auth=auth->next) {
- XdmcpUnwrap ((unsigned char *)cookie, (unsigned char *)&auth->key, plain, cookie_length);
- if ((client = XdmAuthorizationValidate (plain, cookie_length, &auth->rho, NULL, NULL)) != NULL)
- {
- free(client);
- free(cookie);
- free(plain);
- return auth->id;
- }
+ return (XID) -1;
+ for (auth = xdmAuth; auth; auth = auth->next) {
+ XdmcpUnwrap((unsigned char *) cookie, (unsigned char *) &auth->key,
+ plain, cookie_length);
+ if ((client =
+ XdmAuthorizationValidate(plain, cookie_length, &auth->rho, NULL,
+ NULL)) != NULL) {
+ free(client);
+ free(cookie);
+ free(plain);
+ return auth->id;
+ }
}
free(cookie);
free(plain);
@@ -449,49 +439,47 @@ XdmToID (unsigned short cookie_length, char *cookie)
}
int
-XdmFromID (XID id, unsigned short *data_lenp, char **datap)
+XdmFromID(XID id, unsigned short *data_lenp, char **datap)
{
- XdmAuthorizationPtr auth;
-
- for (auth = xdmAuth; auth; auth=auth->next) {
- if (id == auth->id) {
- *data_lenp = 16;
- *datap = (char *) &auth->rho;
- return 1;
- }
+ XdmAuthorizationPtr auth;
+
+ for (auth = xdmAuth; auth; auth = auth->next) {
+ if (id == auth->id) {
+ *data_lenp = 16;
+ *datap = (char *) &auth->rho;
+ return 1;
+ }
}
return 0;
}
int
-XdmRemoveCookie (unsigned short data_length, const char *data)
+XdmRemoveCookie(unsigned short data_length, const char *data)
{
- XdmAuthorizationPtr auth;
- XdmAuthKeyPtr key_bits, rho_bits;
+ XdmAuthorizationPtr auth;
+ XdmAuthKeyPtr key_bits, rho_bits;
- switch (data_length)
- {
+ switch (data_length) {
case 16:
- rho_bits = (XdmAuthKeyPtr) data;
- key_bits = (XdmAuthKeyPtr) (data + 8);
- break;
+ rho_bits = (XdmAuthKeyPtr) data;
+ key_bits = (XdmAuthKeyPtr) (data + 8);
+ break;
#ifdef XDMCP
case 8:
- rho_bits = &rho;
- key_bits = (XdmAuthKeyPtr) data;
- break;
+ rho_bits = &rho;
+ key_bits = (XdmAuthKeyPtr) data;
+ break;
#endif
default:
- return 0;
+ return 0;
}
- for (auth = xdmAuth; auth; auth=auth->next) {
- if (XdmcpCompareKeys (rho_bits, &auth->rho) &&
- XdmcpCompareKeys (key_bits, &auth->key))
- {
- xdmAuth = auth->next;
- free(auth);
- return 1;
- }
+ for (auth = xdmAuth; auth; auth = auth->next) {
+ if (XdmcpCompareKeys(rho_bits, &auth->rho) &&
+ XdmcpCompareKeys(key_bits, &auth->key)) {
+ xdmAuth = auth->next;
+ free(auth);
+ return 1;
+ }
}
return 0;
}
diff --git a/xorg-server/os/xdmcp.c b/xorg-server/os/xdmcp.c
index 77f02da91..87f04b455 100644
--- a/xorg-server/os/xdmcp.c
+++ b/xorg-server/os/xdmcp.c
@@ -62,27 +62,29 @@
static const char *defaultDisplayClass = COMPILEDDISPLAYCLASS;
-static int xdmcpSocket, sessionSocket;
-static xdmcp_states state;
+static int xdmcpSocket, sessionSocket;
+static xdmcp_states state;
+
#if defined(IPv6) && defined(AF_INET6)
-static int xdmcpSocket6;
+static int xdmcpSocket6;
static struct sockaddr_storage req_sockaddr;
#else
-static struct sockaddr_in req_sockaddr;
+static struct sockaddr_in req_sockaddr;
#endif
-static int req_socklen;
-static CARD32 SessionID;
-static CARD32 timeOutTime;
-static int timeOutRtx;
-static CARD32 defaultKeepaliveDormancy = XDM_DEF_DORMANCY;
-static CARD32 keepaliveDormancy = XDM_DEF_DORMANCY;
-static CARD16 DisplayNumber;
-static xdmcp_states XDM_INIT_STATE = XDM_OFF;
+static int req_socklen;
+static CARD32 SessionID;
+static CARD32 timeOutTime;
+static int timeOutRtx;
+static CARD32 defaultKeepaliveDormancy = XDM_DEF_DORMANCY;
+static CARD32 keepaliveDormancy = XDM_DEF_DORMANCY;
+static CARD16 DisplayNumber;
+static xdmcp_states XDM_INIT_STATE = XDM_OFF;
+
#ifdef HASXDMAUTH
-static char *xdmAuthCookie;
+static char *xdmAuthCookie;
#endif
-static XdmcpBuffer buffer;
+static XdmcpBuffer buffer;
#if defined(IPv6) && defined(AF_INET6)
@@ -113,8 +115,8 @@ static struct addrinfo *mgrAddrFirst;
#endif
-static SOCKADDR_TYPE ManagerAddress;
-static SOCKADDR_TYPE FromAddress;
+static SOCKADDR_TYPE ManagerAddress;
+static SOCKADDR_TYPE FromAddress;
#ifdef SOCKLEN_FIELD
#define ManagerAddressLen SOCKLEN_FIELD(ManagerAddress)
@@ -125,67 +127,61 @@ static SOCKLEN_TYPE ManagerAddressLen, FromAddressLen;
#if defined(IPv6) && defined(AF_INET6)
static struct multicastinfo {
- struct multicastinfo *next;
- struct addrinfo *ai;
- int hops;
+ struct multicastinfo *next;
+ struct addrinfo *ai;
+ int hops;
} *mcastlist;
#endif
-static void XdmcpAddHost(
- const struct sockaddr *from,
- int fromlen,
- ARRAY8Ptr AuthenticationName,
- ARRAY8Ptr hostname,
- ARRAY8Ptr status);
+static void XdmcpAddHost(const struct sockaddr *from,
+ int fromlen,
+ ARRAY8Ptr AuthenticationName,
+ ARRAY8Ptr hostname, ARRAY8Ptr status);
-static void XdmcpSelectHost(
- const struct sockaddr *host_sockaddr,
- int host_len,
- ARRAY8Ptr AuthenticationName);
+static void XdmcpSelectHost(const struct sockaddr *host_sockaddr,
+ int host_len, ARRAY8Ptr AuthenticationName);
static void get_xdmcp_sock(void);
static void send_query_msg(void);
-static void recv_willing_msg(
- struct sockaddr * /*from*/,
- int /*fromlen*/,
- unsigned /*length*/);
+static void recv_willing_msg(struct sockaddr * /*from */ ,
+ int /*fromlen */ ,
+ unsigned /*length */ );
static void send_request_msg(void);
-static void recv_accept_msg(unsigned /*length*/);
+static void recv_accept_msg(unsigned /*length */ );
-static void recv_decline_msg(unsigned /*length*/);
+static void recv_decline_msg(unsigned /*length */ );
static void send_manage_msg(void);
-static void recv_refuse_msg(unsigned /*length*/);
+static void recv_refuse_msg(unsigned /*length */ );
-static void recv_failed_msg(unsigned /*length*/);
+static void recv_failed_msg(unsigned /*length */ );
static void send_keepalive_msg(void);
-static void recv_alive_msg(unsigned /*length*/);
+static void recv_alive_msg(unsigned /*length */ );
-static void XdmcpFatal(
- const char * /*type*/,
- ARRAY8Ptr /*status*/);
-
-static void XdmcpWarning(const char * /*str*/);
+static void XdmcpFatal(const char * /*type */ ,
+ ARRAY8Ptr /*status */ );
-static void get_manager_by_name(
- int /*argc*/,
- char ** /*argv*/,
- int /*i*/);
+static void XdmcpWarning(const char * /*str */ );
-static void get_fromaddr_by_name(int /*argc*/, char ** /*argv*/, int /*i*/);
+static void get_manager_by_name(int /*argc */ ,
+ char ** /*argv */ ,
+ int /*i */ );
+
+static void get_fromaddr_by_name(int /*argc */ , char ** /*argv */ ,
+ int /*i */ );
#if defined(IPv6) && defined(AF_INET6)
-static int get_mcast_options(int /*argc*/, char ** /*argv*/, int /*i*/);
+static int get_mcast_options(int /*argc */ , char ** /*argv */ , int /*i */ );
#endif
-static void receive_packet(int /*socketfd*/);
+static void receive_packet(int /*socketfd */ );
static void send_packet(void);
@@ -193,15 +189,13 @@ static void timeout(void);
static void restart(void);
-static void XdmcpBlockHandler(
- pointer /*data*/,
- struct timeval ** /*wt*/,
- pointer /*LastSelectMask*/);
+static void XdmcpBlockHandler(pointer /*data */ ,
+ struct timeval ** /*wt */ ,
+ pointer /*LastSelectMask */ );
-static void XdmcpWakeupHandler(
- pointer /*data*/,
- int /*i*/,
- pointer /*LastSelectMask*/);
+static void XdmcpWakeupHandler(pointer /*data */ ,
+ int /*i */ ,
+ pointer /*LastSelectMask */ );
/*
* Register the Manufacturer display ID
@@ -210,23 +204,23 @@ static void XdmcpWakeupHandler(
static ARRAY8 ManufacturerDisplayID;
static void
-XdmcpRegisterManufacturerDisplayID (const char *name, int length)
+XdmcpRegisterManufacturerDisplayID(const char *name, int length)
{
- int i;
+ int i;
- XdmcpDisposeARRAY8 (&ManufacturerDisplayID);
- if (!XdmcpAllocARRAY8 (&ManufacturerDisplayID, length))
- return;
+ XdmcpDisposeARRAY8(&ManufacturerDisplayID);
+ if (!XdmcpAllocARRAY8(&ManufacturerDisplayID, length))
+ return;
for (i = 0; i < length; i++)
- ManufacturerDisplayID.data[i] = (CARD8) name[i];
+ ManufacturerDisplayID.data[i] = (CARD8) name[i];
}
-static unsigned short xdm_udp_port = XDM_UDP_PORT;
-static Bool OneSession = FALSE;
-static const char *xdm_from = NULL;
+static unsigned short xdm_udp_port = XDM_UDP_PORT;
+static Bool OneSession = FALSE;
+static const char *xdm_from = NULL;
void
-XdmcpUseMsg (void)
+XdmcpUseMsg(void)
{
ErrorF("-query host-name contact named host for XDMCP\n");
ErrorF("-broadcast broadcast for XDMCP\n");
@@ -235,7 +229,8 @@ XdmcpUseMsg (void)
#endif
ErrorF("-indirect host-name contact named host for indirect XDMCP\n");
ErrorF("-port port-num UDP port number to send messages to\n");
- ErrorF("-from local-address specify the local address to connect from\n");
+ ErrorF
+ ("-from local-address specify the local address to connect from\n");
ErrorF("-once Terminate server after one session\n");
ErrorF("-class display-class specify display class to send in manage\n");
#ifdef HASXDMAUTH
@@ -244,71 +239,71 @@ XdmcpUseMsg (void)
ErrorF("-displayID display-id manufacturer display ID for request\n");
}
-int
+int
XdmcpOptions(int argc, char **argv, int i)
{
if (strcmp(argv[i], "-query") == 0) {
- get_manager_by_name(argc, argv, i++);
- XDM_INIT_STATE = XDM_QUERY;
- AccessUsingXdmcp ();
- return i + 1;
+ get_manager_by_name(argc, argv, i++);
+ XDM_INIT_STATE = XDM_QUERY;
+ AccessUsingXdmcp();
+ return i + 1;
}
if (strcmp(argv[i], "-broadcast") == 0) {
- XDM_INIT_STATE = XDM_BROADCAST;
- AccessUsingXdmcp ();
- return i + 1;
+ XDM_INIT_STATE = XDM_BROADCAST;
+ AccessUsingXdmcp();
+ return i + 1;
}
#if defined(IPv6) && defined(AF_INET6)
if (strcmp(argv[i], "-multicast") == 0) {
- i = get_mcast_options(argc, argv, ++i);
- XDM_INIT_STATE = XDM_MULTICAST;
- AccessUsingXdmcp ();
- return i + 1;
+ i = get_mcast_options(argc, argv, ++i);
+ XDM_INIT_STATE = XDM_MULTICAST;
+ AccessUsingXdmcp();
+ return i + 1;
}
#endif
if (strcmp(argv[i], "-indirect") == 0) {
- get_manager_by_name(argc, argv, i++);
- XDM_INIT_STATE = XDM_INDIRECT;
- AccessUsingXdmcp ();
- return i + 1;
+ get_manager_by_name(argc, argv, i++);
+ XDM_INIT_STATE = XDM_INDIRECT;
+ AccessUsingXdmcp();
+ return i + 1;
}
if (strcmp(argv[i], "-port") == 0) {
- if (++i == argc) {
- FatalError("Xserver: missing port number in command line\n");
- }
- xdm_udp_port = (unsigned short) atoi(argv[i]);
- return i + 1;
+ if (++i == argc) {
+ FatalError("Xserver: missing port number in command line\n");
+ }
+ xdm_udp_port = (unsigned short) atoi(argv[i]);
+ return i + 1;
}
if (strcmp(argv[i], "-from") == 0) {
- get_fromaddr_by_name(argc, argv, ++i);
- return i + 1;
+ get_fromaddr_by_name(argc, argv, ++i);
+ return i + 1;
}
if (strcmp(argv[i], "-once") == 0) {
- OneSession = TRUE;
- return i + 1;
+ OneSession = TRUE;
+ return i + 1;
}
if (strcmp(argv[i], "-class") == 0) {
- if (++i == argc) {
- FatalError("Xserver: missing class name in command line\n");
- }
- defaultDisplayClass = argv[i];
- return i + 1;
+ if (++i == argc) {
+ FatalError("Xserver: missing class name in command line\n");
+ }
+ defaultDisplayClass = argv[i];
+ return i + 1;
}
#ifdef HASXDMAUTH
if (strcmp(argv[i], "-cookie") == 0) {
- if (++i == argc) {
- FatalError("Xserver: missing cookie data in command line\n");
- }
- xdmAuthCookie = argv[i];
- return i + 1;
+ if (++i == argc) {
+ FatalError("Xserver: missing cookie data in command line\n");
+ }
+ xdmAuthCookie = argv[i];
+ return i + 1;
}
#endif
if (strcmp(argv[i], "-displayID") == 0) {
- if (++i == argc) {
- FatalError("Xserver: missing displayID in command line\n");
- }
- XdmcpRegisterManufacturerDisplayID (argv[i], strlen (argv[i]));
- return i + 1;
+ if (++i == argc) {
+ FatalError("Xserver: missing displayID in command line\n");
+ }
+ XdmcpRegisterManufacturerDisplayID(argv[i], strlen(argv[i]));
+ return i + 1;
}
return i;
}
@@ -319,7 +314,6 @@ XdmcpOptions(int argc, char **argv, int i)
* state machine.
*/
-
/*
* Save all broadcast addresses away so BroadcastQuery
* packets get sent everywhere
@@ -328,22 +322,23 @@ XdmcpOptions(int argc, char **argv, int i)
#define MAX_BROADCAST 10
/* This stays sockaddr_in since IPv6 doesn't support broadcast */
-static struct sockaddr_in BroadcastAddresses[MAX_BROADCAST];
-static int NumBroadcastAddresses;
+static struct sockaddr_in BroadcastAddresses[MAX_BROADCAST];
+static int NumBroadcastAddresses;
void
-XdmcpRegisterBroadcastAddress (const struct sockaddr_in *addr)
+XdmcpRegisterBroadcastAddress(const struct sockaddr_in *addr)
{
- struct sockaddr_in *bcast;
+ struct sockaddr_in *bcast;
+
if (NumBroadcastAddresses >= MAX_BROADCAST)
- return;
+ return;
bcast = &BroadcastAddresses[NumBroadcastAddresses++];
- memset(bcast, 0, sizeof (struct sockaddr_in));
+ memset(bcast, 0, sizeof(struct sockaddr_in));
#ifdef BSD44SOCKETS
bcast->sin_len = addr->sin_len;
#endif
bcast->sin_family = addr->sin_family;
- bcast->sin_port = htons (xdm_udp_port);
+ bcast->sin_port = htons(xdm_udp_port);
bcast->sin_addr = addr->sin_addr;
}
@@ -353,59 +348,59 @@ XdmcpRegisterBroadcastAddress (const struct sockaddr_in *addr)
* the specified authentication type
*/
-static ARRAYofARRAY8 AuthenticationNames, AuthenticationDatas;
+static ARRAYofARRAY8 AuthenticationNames, AuthenticationDatas;
typedef struct _AuthenticationFuncs {
- ValidatorFunc Validator;
- GeneratorFunc Generator;
- AddAuthorFunc AddAuth;
+ ValidatorFunc Validator;
+ GeneratorFunc Generator;
+ AddAuthorFunc AddAuth;
} AuthenticationFuncsRec, *AuthenticationFuncsPtr;
-static AuthenticationFuncsPtr AuthenticationFuncsList;
+static AuthenticationFuncsPtr AuthenticationFuncsList;
void
-XdmcpRegisterAuthentication (
- const char *name,
- int namelen,
- const char *data,
- int datalen,
- ValidatorFunc Validator,
- GeneratorFunc Generator,
- AddAuthorFunc AddAuth)
+XdmcpRegisterAuthentication(const char *name,
+ int namelen,
+ const char *data,
+ int datalen,
+ ValidatorFunc Validator,
+ GeneratorFunc Generator, AddAuthorFunc AddAuth)
{
- int i;
- ARRAY8 AuthenticationName, AuthenticationData;
- static AuthenticationFuncsPtr newFuncs;
-
- if (!XdmcpAllocARRAY8 (&AuthenticationName, namelen))
- return;
- if (!XdmcpAllocARRAY8 (&AuthenticationData, datalen))
- {
- XdmcpDisposeARRAY8 (&AuthenticationName);
- return;
+ int i;
+ ARRAY8 AuthenticationName, AuthenticationData;
+ static AuthenticationFuncsPtr newFuncs;
+
+ if (!XdmcpAllocARRAY8(&AuthenticationName, namelen))
+ return;
+ if (!XdmcpAllocARRAY8(&AuthenticationData, datalen)) {
+ XdmcpDisposeARRAY8(&AuthenticationName);
+ return;
}
for (i = 0; i < namelen; i++)
- AuthenticationName.data[i] = name[i];
+ AuthenticationName.data[i] = name[i];
for (i = 0; i < datalen; i++)
- AuthenticationData.data[i] = data[i];
- if (!(XdmcpReallocARRAYofARRAY8 (&AuthenticationNames,
- AuthenticationNames.length + 1) &&
- XdmcpReallocARRAYofARRAY8 (&AuthenticationDatas,
- AuthenticationDatas.length + 1) &&
- (newFuncs = malloc((AuthenticationNames.length + 1) * sizeof (AuthenticationFuncsRec)))))
- {
- XdmcpDisposeARRAY8 (&AuthenticationName);
- XdmcpDisposeARRAY8 (&AuthenticationData);
- return;
+ AuthenticationData.data[i] = data[i];
+ if (!(XdmcpReallocARRAYofARRAY8(&AuthenticationNames,
+ AuthenticationNames.length + 1) &&
+ XdmcpReallocARRAYofARRAY8(&AuthenticationDatas,
+ AuthenticationDatas.length + 1) &&
+ (newFuncs =
+ malloc((AuthenticationNames.length +
+ 1) * sizeof(AuthenticationFuncsRec))))) {
+ XdmcpDisposeARRAY8(&AuthenticationName);
+ XdmcpDisposeARRAY8(&AuthenticationData);
+ return;
}
for (i = 0; i < AuthenticationNames.length - 1; i++)
- newFuncs[i] = AuthenticationFuncsList[i];
- newFuncs[AuthenticationNames.length-1].Validator = Validator;
- newFuncs[AuthenticationNames.length-1].Generator = Generator;
- newFuncs[AuthenticationNames.length-1].AddAuth = AddAuth;
+ newFuncs[i] = AuthenticationFuncsList[i];
+ newFuncs[AuthenticationNames.length - 1].Validator = Validator;
+ newFuncs[AuthenticationNames.length - 1].Generator = Generator;
+ newFuncs[AuthenticationNames.length - 1].AddAuth = AddAuth;
free(AuthenticationFuncsList);
AuthenticationFuncsList = newFuncs;
- AuthenticationNames.data[AuthenticationNames.length-1] = AuthenticationName;
- AuthenticationDatas.data[AuthenticationDatas.length-1] = AuthenticationData;
+ AuthenticationNames.data[AuthenticationNames.length - 1] =
+ AuthenticationName;
+ AuthenticationDatas.data[AuthenticationDatas.length - 1] =
+ AuthenticationData;
}
/*
@@ -413,104 +408,103 @@ XdmcpRegisterAuthentication (
* set by the manager of the host to be connected to.
*/
-static ARRAY8 noAuthenticationName = {(CARD16) 0, (CARD8Ptr) 0};
-static ARRAY8 noAuthenticationData = {(CARD16) 0, (CARD8Ptr) 0};
-static ARRAY8Ptr AuthenticationName = &noAuthenticationName;
-static ARRAY8Ptr AuthenticationData = &noAuthenticationData;
-static AuthenticationFuncsPtr AuthenticationFuncs;
+static ARRAY8 noAuthenticationName = { (CARD16) 0, (CARD8Ptr) 0 };
+static ARRAY8 noAuthenticationData = { (CARD16) 0, (CARD8Ptr) 0 };
+
+static ARRAY8Ptr AuthenticationName = &noAuthenticationName;
+static ARRAY8Ptr AuthenticationData = &noAuthenticationData;
+static AuthenticationFuncsPtr AuthenticationFuncs;
static void
-XdmcpSetAuthentication (const ARRAY8Ptr name)
+XdmcpSetAuthentication(const ARRAY8Ptr name)
{
- int i;
+ int i;
for (i = 0; i < AuthenticationNames.length; i++)
- if (XdmcpARRAY8Equal (&AuthenticationNames.data[i], name))
- {
- AuthenticationName = &AuthenticationNames.data[i];
- AuthenticationData = &AuthenticationDatas.data[i];
- AuthenticationFuncs = &AuthenticationFuncsList[i];
- break;
- }
+ if (XdmcpARRAY8Equal(&AuthenticationNames.data[i], name)) {
+ AuthenticationName = &AuthenticationNames.data[i];
+ AuthenticationData = &AuthenticationDatas.data[i];
+ AuthenticationFuncs = &AuthenticationFuncsList[i];
+ break;
+ }
}
/*
* Register the host address for the display
*/
-static ARRAY16 ConnectionTypes;
-static ARRAYofARRAY8 ConnectionAddresses;
-static long xdmcpGeneration;
+static ARRAY16 ConnectionTypes;
+static ARRAYofARRAY8 ConnectionAddresses;
+static long xdmcpGeneration;
void
-XdmcpRegisterConnection (
- int type,
- const char *address,
- int addrlen)
+XdmcpRegisterConnection(int type, const char *address, int addrlen)
{
- int i;
- CARD8 *newAddress;
-
- if (xdmcpGeneration != serverGeneration)
- {
- XdmcpDisposeARRAY16 (&ConnectionTypes);
- XdmcpDisposeARRAYofARRAY8 (&ConnectionAddresses);
- xdmcpGeneration = serverGeneration;
+ int i;
+ CARD8 *newAddress;
+
+ if (xdmcpGeneration != serverGeneration) {
+ XdmcpDisposeARRAY16(&ConnectionTypes);
+ XdmcpDisposeARRAYofARRAY8(&ConnectionAddresses);
+ xdmcpGeneration = serverGeneration;
}
- if (xdm_from != NULL) { /* Only register the requested address */
- const void *regAddr = address;
- const void *fromAddr = NULL;
- int regAddrlen = addrlen;
-
- if (addrlen == sizeof(struct in_addr)) {
- if (SOCKADDR_FAMILY(FromAddress) == AF_INET) {
- fromAddr = &((struct sockaddr_in *)&FromAddress)->sin_addr;
- }
+ if (xdm_from != NULL) { /* Only register the requested address */
+ const void *regAddr = address;
+ const void *fromAddr = NULL;
+ int regAddrlen = addrlen;
+
+ if (addrlen == sizeof(struct in_addr)) {
+ if (SOCKADDR_FAMILY(FromAddress) == AF_INET) {
+ fromAddr = &((struct sockaddr_in *) &FromAddress)->sin_addr;
+ }
#if defined(IPv6) && defined(AF_INET6)
- else if ((SOCKADDR_FAMILY(FromAddress) == AF_INET6) &&
- IN6_IS_ADDR_V4MAPPED(
- &((struct sockaddr_in6 *)&FromAddress)->sin6_addr)) {
- fromAddr = &((struct sockaddr_in6 *)&FromAddress)->sin6_addr.s6_addr[12];
- }
+ else if ((SOCKADDR_FAMILY(FromAddress) == AF_INET6) &&
+ IN6_IS_ADDR_V4MAPPED(&
+ ((struct sockaddr_in6 *)
+ &FromAddress)->sin6_addr)) {
+ fromAddr =
+ &((struct sockaddr_in6 *) &FromAddress)->sin6_addr.
+ s6_addr[12];
+ }
#endif
- }
+ }
#if defined(IPv6) && defined(AF_INET6)
- else if (addrlen == sizeof(struct in6_addr)) {
- if (SOCKADDR_FAMILY(FromAddress) == AF_INET6) {
- fromAddr = &((struct sockaddr_in6 *)&FromAddress)->sin6_addr;
- } else if ((SOCKADDR_FAMILY(FromAddress) == AF_INET) &&
- IN6_IS_ADDR_V4MAPPED((const struct in6_addr *) address)) {
- fromAddr = &((struct sockaddr_in *)&FromAddress)->sin_addr;
- regAddr = &((struct sockaddr_in6 *)&address)->sin6_addr.s6_addr[12];
- regAddrlen = sizeof(struct in_addr);
- }
- }
+ else if (addrlen == sizeof(struct in6_addr)) {
+ if (SOCKADDR_FAMILY(FromAddress) == AF_INET6) {
+ fromAddr = &((struct sockaddr_in6 *) &FromAddress)->sin6_addr;
+ }
+ else if ((SOCKADDR_FAMILY(FromAddress) == AF_INET) &&
+ IN6_IS_ADDR_V4MAPPED((const struct in6_addr *) address)) {
+ fromAddr = &((struct sockaddr_in *) &FromAddress)->sin_addr;
+ regAddr =
+ &((struct sockaddr_in6 *) &address)->sin6_addr.s6_addr[12];
+ regAddrlen = sizeof(struct in_addr);
+ }
+ }
#endif
- if (!fromAddr || memcmp(regAddr, fromAddr, regAddrlen) != 0) {
- return;
- }
+ if (!fromAddr || memcmp(regAddr, fromAddr, regAddrlen) != 0) {
+ return;
+ }
}
if (ConnectionAddresses.length + 1 == 256)
- return;
- newAddress = malloc(addrlen * sizeof (CARD8));
+ return;
+ newAddress = malloc(addrlen * sizeof(CARD8));
if (!newAddress)
- return;
- if (!XdmcpReallocARRAY16 (&ConnectionTypes, ConnectionTypes.length + 1))
- {
- free(newAddress);
- return;
+ return;
+ if (!XdmcpReallocARRAY16(&ConnectionTypes, ConnectionTypes.length + 1)) {
+ free(newAddress);
+ return;
}
- if (!XdmcpReallocARRAYofARRAY8 (&ConnectionAddresses,
- ConnectionAddresses.length + 1))
- {
- free(newAddress);
- return;
+ if (!XdmcpReallocARRAYofARRAY8(&ConnectionAddresses,
+ ConnectionAddresses.length + 1)) {
+ free(newAddress);
+ return;
}
ConnectionTypes.data[ConnectionTypes.length - 1] = (CARD16) type;
for (i = 0; i < addrlen; i++)
- newAddress[i] = address[i];
- ConnectionAddresses.data[ConnectionAddresses.length-1].data = newAddress;
- ConnectionAddresses.data[ConnectionAddresses.length-1].length = addrlen;
+ newAddress[i] = address[i];
+ ConnectionAddresses.data[ConnectionAddresses.length - 1].data = newAddress;
+ ConnectionAddresses.data[ConnectionAddresses.length - 1].length = addrlen;
}
/*
@@ -518,51 +512,51 @@ XdmcpRegisterConnection (
* to the manager.
*/
-static ARRAYofARRAY8 AuthorizationNames;
+static ARRAYofARRAY8 AuthorizationNames;
void
-XdmcpRegisterAuthorizations (void)
+XdmcpRegisterAuthorizations(void)
{
- XdmcpDisposeARRAYofARRAY8 (&AuthorizationNames);
- RegisterAuthorizations ();
+ XdmcpDisposeARRAYofARRAY8(&AuthorizationNames);
+ RegisterAuthorizations();
}
void
-XdmcpRegisterAuthorization (const char *name, int namelen)
+XdmcpRegisterAuthorization(const char *name, int namelen)
{
- ARRAY8 authName;
- int i;
+ ARRAY8 authName;
+ int i;
- authName.data = malloc(namelen * sizeof (CARD8));
+ authName.data = malloc(namelen * sizeof(CARD8));
if (!authName.data)
- return;
- if (!XdmcpReallocARRAYofARRAY8 (&AuthorizationNames, AuthorizationNames.length +1))
- {
- free(authName.data);
- return;
+ return;
+ if (!XdmcpReallocARRAYofARRAY8
+ (&AuthorizationNames, AuthorizationNames.length + 1)) {
+ free(authName.data);
+ return;
}
for (i = 0; i < namelen; i++)
- authName.data[i] = (CARD8) name[i];
+ authName.data[i] = (CARD8) name[i];
authName.length = namelen;
- AuthorizationNames.data[AuthorizationNames.length-1] = authName;
+ AuthorizationNames.data[AuthorizationNames.length - 1] = authName;
}
/*
* Register the DisplayClass string
*/
-static ARRAY8 DisplayClass;
+static ARRAY8 DisplayClass;
static void
-XdmcpRegisterDisplayClass (const char *name, int length)
+XdmcpRegisterDisplayClass(const char *name, int length)
{
- int i;
+ int i;
- XdmcpDisposeARRAY8 (&DisplayClass);
- if (!XdmcpAllocARRAY8 (&DisplayClass, length))
- return;
+ XdmcpDisposeARRAY8(&DisplayClass);
+ if (!XdmcpAllocARRAY8(&DisplayClass, length))
+ return;
for (i = 0; i < length; i++)
- DisplayClass.data[i] = (CARD8) name[i];
+ DisplayClass.data[i] = (CARD8) name[i];
}
/*
@@ -570,38 +564,37 @@ XdmcpRegisterDisplayClass (const char *name, int length)
* number, set up the state machine
*/
-void
+void
XdmcpInit(void)
{
state = XDM_INIT_STATE;
#ifdef HASXDMAUTH
if (xdmAuthCookie)
- XdmAuthenticationInit (xdmAuthCookie, strlen (xdmAuthCookie));
+ XdmAuthenticationInit(xdmAuthCookie, strlen(xdmAuthCookie));
#endif
- if (state != XDM_OFF)
- {
- XdmcpRegisterAuthorizations();
- XdmcpRegisterDisplayClass (defaultDisplayClass, strlen (defaultDisplayClass));
- AccessUsingXdmcp();
- RegisterBlockAndWakeupHandlers (XdmcpBlockHandler, XdmcpWakeupHandler,
- (pointer) 0);
- timeOutRtx = 0;
- DisplayNumber = (CARD16) atoi(display);
- get_xdmcp_sock();
- send_packet();
+ if (state != XDM_OFF) {
+ XdmcpRegisterAuthorizations();
+ XdmcpRegisterDisplayClass(defaultDisplayClass,
+ strlen(defaultDisplayClass));
+ AccessUsingXdmcp();
+ RegisterBlockAndWakeupHandlers(XdmcpBlockHandler, XdmcpWakeupHandler,
+ (pointer) 0);
+ timeOutRtx = 0;
+ DisplayNumber = (CARD16) atoi(display);
+ get_xdmcp_sock();
+ send_packet();
}
}
void
-XdmcpReset (void)
+XdmcpReset(void)
{
state = XDM_INIT_STATE;
- if (state != XDM_OFF)
- {
- RegisterBlockAndWakeupHandlers (XdmcpBlockHandler, XdmcpWakeupHandler,
- (pointer) 0);
- timeOutRtx = 0;
- send_packet();
+ if (state != XDM_OFF) {
+ RegisterBlockAndWakeupHandlers(XdmcpBlockHandler, XdmcpWakeupHandler,
+ (pointer) 0);
+ timeOutRtx = 0;
+ send_packet();
}
}
@@ -615,22 +608,22 @@ void
XdmcpOpenDisplay(int sock)
{
if (state != XDM_AWAIT_MANAGE_RESPONSE)
- return;
+ return;
state = XDM_RUN_SESSION;
sessionSocket = sock;
}
-void
+void
XdmcpCloseDisplay(int sock)
{
if ((state != XDM_RUN_SESSION && state != XDM_AWAIT_ALIVE_RESPONSE)
- || sessionSocket != sock)
- return;
+ || sessionSocket != sock)
+ return;
state = XDM_INIT_STATE;
if (OneSession)
- dispatchException |= DE_TERMINATE;
+ dispatchException |= DE_TERMINATE;
else
- dispatchException |= DE_RESET;
+ dispatchException |= DE_RESET;
isItTimeToYield = TRUE;
}
@@ -641,29 +634,26 @@ XdmcpCloseDisplay(int sock)
* dynamically while starting up
*/
-/*ARGSUSED*/
-static void
-XdmcpBlockHandler(
- pointer data, /* unused */
- struct timeval **wt,
- pointer pReadmask)
+ /*ARGSUSED*/ static void
+XdmcpBlockHandler(pointer data, /* unused */
+ struct timeval **wt, pointer pReadmask)
{
- fd_set *LastSelectMask = (fd_set*)pReadmask;
+ fd_set *LastSelectMask = (fd_set *) pReadmask;
CARD32 millisToGo;
if (state == XDM_OFF)
- return;
+ return;
FD_SET(xdmcpSocket, LastSelectMask);
#if defined(IPv6) && defined(AF_INET6)
if (xdmcpSocket6 >= 0)
- FD_SET(xdmcpSocket6, LastSelectMask);
+ FD_SET(xdmcpSocket6, LastSelectMask);
#endif
if (timeOutTime == 0)
- return;
+ return;
millisToGo = timeOutTime - GetTimeInMillis();
if ((int) millisToGo < 0)
- millisToGo = 0;
- AdjustWaitForDelay (wt, millisToGo);
+ millisToGo = 0;
+ AdjustWaitForDelay(wt, millisToGo);
}
/*
@@ -672,52 +662,43 @@ XdmcpBlockHandler(
* process them appropriately
*/
-/*ARGSUSED*/
-static void
-XdmcpWakeupHandler(
- pointer data, /* unused */
- int i,
- pointer pReadmask)
+ /*ARGSUSED*/ static void
+XdmcpWakeupHandler(pointer data, /* unused */
+ int i, pointer pReadmask)
{
- fd_set* LastSelectMask = (fd_set*)pReadmask;
- fd_set devicesReadable;
+ fd_set *LastSelectMask = (fd_set *) pReadmask;
+ fd_set devicesReadable;
if (state == XDM_OFF)
- return;
- if (i > 0)
- {
- if (FD_ISSET(xdmcpSocket, LastSelectMask))
- {
- receive_packet(xdmcpSocket);
- FD_CLR(xdmcpSocket, LastSelectMask);
- }
+ return;
+ if (i > 0) {
+ if (FD_ISSET(xdmcpSocket, LastSelectMask)) {
+ receive_packet(xdmcpSocket);
+ FD_CLR(xdmcpSocket, LastSelectMask);
+ }
#if defined(IPv6) && defined(AF_INET6)
- if (xdmcpSocket6 >= 0 && FD_ISSET(xdmcpSocket6, LastSelectMask))
- {
- receive_packet(xdmcpSocket6);
- FD_CLR(xdmcpSocket6, LastSelectMask);
- }
+ if (xdmcpSocket6 >= 0 && FD_ISSET(xdmcpSocket6, LastSelectMask)) {
+ receive_packet(xdmcpSocket6);
+ FD_CLR(xdmcpSocket6, LastSelectMask);
+ }
#endif
- XFD_ANDSET(&devicesReadable, LastSelectMask, &EnabledDevices);
- if (XFD_ANYSET(&devicesReadable))
- {
- if (state == XDM_AWAIT_USER_INPUT)
- restart();
- else if (state == XDM_RUN_SESSION)
- keepaliveDormancy = defaultKeepaliveDormancy;
- }
- if (XFD_ANYSET(&AllClients) && state == XDM_RUN_SESSION)
- timeOutTime = GetTimeInMillis() + keepaliveDormancy * 1000;
+ XFD_ANDSET(&devicesReadable, LastSelectMask, &EnabledDevices);
+ if (XFD_ANYSET(&devicesReadable)) {
+ if (state == XDM_AWAIT_USER_INPUT)
+ restart();
+ else if (state == XDM_RUN_SESSION)
+ keepaliveDormancy = defaultKeepaliveDormancy;
+ }
+ if (XFD_ANYSET(&AllClients) && state == XDM_RUN_SESSION)
+ timeOutTime = GetTimeInMillis() + keepaliveDormancy * 1000;
}
- else if (timeOutTime && (int) (GetTimeInMillis() - timeOutTime) >= 0)
- {
- if (state == XDM_RUN_SESSION)
- {
- state = XDM_KEEPALIVE;
- send_packet();
- }
- else
- timeout();
+ else if (timeOutTime && (int) (GetTimeInMillis() - timeOutTime) >= 0) {
+ if (state == XDM_RUN_SESSION) {
+ state = XDM_KEEPALIVE;
+ send_packet();
+ }
+ else
+ timeout();
}
}
@@ -727,15 +708,13 @@ XdmcpWakeupHandler(
*/
static void
-XdmcpSelectHost(
- const struct sockaddr *host_sockaddr,
- int host_len,
- ARRAY8Ptr AuthenticationName)
+XdmcpSelectHost(const struct sockaddr *host_sockaddr,
+ int host_len, ARRAY8Ptr AuthenticationName)
{
state = XDM_START_CONNECTION;
memmove(&req_sockaddr, host_sockaddr, host_len);
req_socklen = host_len;
- XdmcpSetAuthentication (AuthenticationName);
+ XdmcpSetAuthentication(AuthenticationName);
send_packet();
}
@@ -745,14 +724,10 @@ XdmcpSelectHost(
* selects the first host to respond with willing message.
*/
-/*ARGSUSED*/
-static void
-XdmcpAddHost(
- const struct sockaddr *from,
- int fromlen,
- ARRAY8Ptr AuthenticationName,
- ARRAY8Ptr hostname,
- ARRAY8Ptr status)
+ /*ARGSUSED*/ static void
+XdmcpAddHost(const struct sockaddr *from,
+ int fromlen,
+ ARRAY8Ptr AuthenticationName, ARRAY8Ptr hostname, ARRAY8Ptr status)
{
XdmcpSelectHost(from, fromlen, AuthenticationName);
}
@@ -762,7 +737,7 @@ XdmcpAddHost(
* do the appropriate thing
*/
-static ARRAY8 UnwillingMessage = { (CARD8) 14, (CARD8 *) "Host unwilling" };
+static ARRAY8 UnwillingMessage = { (CARD8) 14, (CARD8 *) "Host unwilling" };
static void
receive_packet(int socketfd)
@@ -773,43 +748,43 @@ receive_packet(int socketfd)
struct sockaddr_in from;
#endif
int fromlen = sizeof(from);
- XdmcpHeader header;
+ XdmcpHeader header;
/* read message off socket */
- if (!XdmcpFill (socketfd, &buffer, (XdmcpNetaddr) &from, &fromlen))
- return;
+ if (!XdmcpFill(socketfd, &buffer, (XdmcpNetaddr) & from, &fromlen))
+ return;
/* reset retransmission backoff */
timeOutRtx = 0;
- if (!XdmcpReadHeader (&buffer, &header))
- return;
+ if (!XdmcpReadHeader(&buffer, &header))
+ return;
if (header.version != XDM_PROTOCOL_VERSION)
- return;
+ return;
switch (header.opcode) {
case WILLING:
- recv_willing_msg((struct sockaddr *) &from, fromlen, header.length);
- break;
+ recv_willing_msg((struct sockaddr *) &from, fromlen, header.length);
+ break;
case UNWILLING:
- XdmcpFatal("Manager unwilling", &UnwillingMessage);
- break;
+ XdmcpFatal("Manager unwilling", &UnwillingMessage);
+ break;
case ACCEPT:
- recv_accept_msg(header.length);
- break;
+ recv_accept_msg(header.length);
+ break;
case DECLINE:
- recv_decline_msg(header.length);
- break;
+ recv_decline_msg(header.length);
+ break;
case REFUSE:
- recv_refuse_msg(header.length);
- break;
+ recv_refuse_msg(header.length);
+ break;
case FAILED:
- recv_failed_msg(header.length);
- break;
+ recv_failed_msg(header.length);
+ break;
case ALIVE:
- recv_alive_msg(header.length);
- break;
+ recv_alive_msg(header.length);
+ break;
}
}
@@ -821,6 +796,7 @@ static void
send_packet(void)
{
int rtx;
+
switch (state) {
case XDM_QUERY:
case XDM_BROADCAST:
@@ -828,23 +804,23 @@ send_packet(void)
#if defined(IPv6) && defined(AF_INET6)
case XDM_MULTICAST:
#endif
- send_query_msg();
- break;
+ send_query_msg();
+ break;
case XDM_START_CONNECTION:
- send_request_msg();
- break;
+ send_request_msg();
+ break;
case XDM_MANAGE:
- send_manage_msg();
- break;
+ send_manage_msg();
+ break;
case XDM_KEEPALIVE:
- send_keepalive_msg();
- break;
+ send_keepalive_msg();
+ break;
default:
- break;
+ break;
}
rtx = (XDM_MIN_RTX << timeOutRtx);
if (rtx > XDM_MAX_RTX)
- rtx = XDM_MAX_RTX;
+ rtx = XDM_MAX_RTX;
timeOutTime = GetTimeInMillis() + rtx * 1000;
}
@@ -854,9 +830,9 @@ send_packet(void)
*/
static void
-XdmcpDeadSession (const char *reason)
+XdmcpDeadSession(const char *reason)
{
- ErrorF ("XDM: %s, declaring session dead\n", reason);
+ ErrorF("XDM: %s, declaring session dead\n", reason);
state = XDM_INIT_STATE;
isItTimeToYield = TRUE;
dispatchException |= DE_RESET;
@@ -873,67 +849,65 @@ static void
timeout(void)
{
timeOutRtx++;
- if (state == XDM_AWAIT_ALIVE_RESPONSE && timeOutRtx >= XDM_KA_RTX_LIMIT )
- {
- XdmcpDeadSession ("too many keepalive retransmissions");
- return;
+ if (state == XDM_AWAIT_ALIVE_RESPONSE && timeOutRtx >= XDM_KA_RTX_LIMIT) {
+ XdmcpDeadSession("too many keepalive retransmissions");
+ return;
}
- else if (timeOutRtx >= XDM_RTX_LIMIT)
- {
- /* Quit if "-once" specified, otherwise reset and try again. */
+ else if (timeOutRtx >= XDM_RTX_LIMIT) {
+ /* Quit if "-once" specified, otherwise reset and try again. */
if (OneSession) {
- dispatchException |= DE_TERMINATE;
- ErrorF("XDM: too many retransmissions\n");
- } else {
- XdmcpDeadSession("too many retransmissions");
- }
- return;
+ dispatchException |= DE_TERMINATE;
+ ErrorF("XDM: too many retransmissions\n");
+ }
+ else {
+ XdmcpDeadSession("too many retransmissions");
+ }
+ return;
}
#if defined(IPv6) && defined(AF_INET6)
if (state == XDM_COLLECT_QUERY || state == XDM_COLLECT_INDIRECT_QUERY) {
- /* Try next address */
- for (mgrAddr = mgrAddr->ai_next; ; mgrAddr = mgrAddr->ai_next) {
- if (mgrAddr == NULL) {
- mgrAddr = mgrAddrFirst;
- }
- if (mgrAddr->ai_family == AF_INET
- || mgrAddr->ai_family == AF_INET6)
- break;
- }
+ /* Try next address */
+ for (mgrAddr = mgrAddr->ai_next;; mgrAddr = mgrAddr->ai_next) {
+ if (mgrAddr == NULL) {
+ mgrAddr = mgrAddrFirst;
+ }
+ if (mgrAddr->ai_family == AF_INET || mgrAddr->ai_family == AF_INET6)
+ break;
+ }
#ifndef SIN6_LEN
- ManagerAddressLen = mgrAddr->ai_addrlen;
+ ManagerAddressLen = mgrAddr->ai_addrlen;
#endif
- memcpy(&ManagerAddress, mgrAddr->ai_addr, mgrAddr->ai_addrlen);
+ memcpy(&ManagerAddress, mgrAddr->ai_addr, mgrAddr->ai_addrlen);
}
#endif
switch (state) {
case XDM_COLLECT_QUERY:
- state = XDM_QUERY;
- break;
+ state = XDM_QUERY;
+ break;
case XDM_COLLECT_BROADCAST_QUERY:
- state = XDM_BROADCAST;
- break;
+ state = XDM_BROADCAST;
+ break;
#if defined(IPv6) && defined(AF_INET6)
case XDM_COLLECT_MULTICAST_QUERY:
- state = XDM_MULTICAST;
- break;
+ state = XDM_MULTICAST;
+ break;
#endif
case XDM_COLLECT_INDIRECT_QUERY:
- state = XDM_INDIRECT;
- break;
+ state = XDM_INDIRECT;
+ break;
case XDM_AWAIT_REQUEST_RESPONSE:
- state = XDM_START_CONNECTION;
- break;
+ state = XDM_START_CONNECTION;
+ break;
case XDM_AWAIT_MANAGE_RESPONSE:
- state = XDM_MANAGE;
- break;
+ state = XDM_MANAGE;
+ break;
case XDM_AWAIT_ALIVE_RESPONSE:
- state = XDM_KEEPALIVE;
- break;
+ state = XDM_KEEPALIVE;
+ break;
default:
- break;
+ break;
}
send_packet();
}
@@ -947,26 +921,26 @@ restart(void)
}
static int
-XdmcpCheckAuthentication (ARRAY8Ptr Name, ARRAY8Ptr Data, int packet_type)
+XdmcpCheckAuthentication(ARRAY8Ptr Name, ARRAY8Ptr Data, int packet_type)
{
- return (XdmcpARRAY8Equal (Name, AuthenticationName) &&
- (AuthenticationName->length == 0 ||
- (*AuthenticationFuncs->Validator) (AuthenticationData, Data, packet_type)));
+ return (XdmcpARRAY8Equal(Name, AuthenticationName) &&
+ (AuthenticationName->length == 0 ||
+ (*AuthenticationFuncs->Validator) (AuthenticationData, Data,
+ packet_type)));
}
static int
-XdmcpAddAuthorization (ARRAY8Ptr name, ARRAY8Ptr data)
+XdmcpAddAuthorization(ARRAY8Ptr name, ARRAY8Ptr data)
{
AddAuthorFunc AddAuth;
if (AuthenticationFuncs && AuthenticationFuncs->AddAuth)
- AddAuth = AuthenticationFuncs->AddAuth;
+ AddAuth = AuthenticationFuncs->AddAuth;
else
- AddAuth = AddAuthorization;
- return (*AddAuth) ((unsigned short)name->length,
- (char *)name->data,
- (unsigned short)data->length,
- (char *)data->data);
+ AddAuth = AddAuthorization;
+ return (*AddAuth) ((unsigned short) name->length,
+ (char *) name->data,
+ (unsigned short) data->length, (char *) data->data);
}
/*
@@ -981,498 +955,476 @@ get_xdmcp_sock(void)
struct netconfig *nconf;
if ((xdmcpSocket = t_open("/dev/udp", O_RDWR, 0)) < 0) {
- XdmcpWarning("t_open() of /dev/udp failed");
- return;
+ XdmcpWarning("t_open() of /dev/udp failed");
+ return;
}
- if( t_bind(xdmcpSocket,NULL,NULL) < 0 ) {
- XdmcpWarning("UDP socket creation failed");
- t_error("t_bind(xdmcpSocket) failed" );
- t_close(xdmcpSocket);
- return;
+ if (t_bind(xdmcpSocket, NULL, NULL) < 0) {
+ XdmcpWarning("UDP socket creation failed");
+ t_error("t_bind(xdmcpSocket) failed");
+ t_close(xdmcpSocket);
+ return;
}
/*
* This part of the code looks contrived. It will actually fit in nicely
* when the CLTS part of Xtrans is implemented.
*/
-
- if( (nconf=getnetconfigent("udp")) == NULL ) {
- XdmcpWarning("UDP socket creation failed: getnetconfigent()");
- t_unbind(xdmcpSocket);
- t_close(xdmcpSocket);
- return;
+
+ if ((nconf = getnetconfigent("udp")) == NULL) {
+ XdmcpWarning("UDP socket creation failed: getnetconfigent()");
+ t_unbind(xdmcpSocket);
+ t_close(xdmcpSocket);
+ return;
}
-
- if( netdir_options(nconf, ND_SET_BROADCAST, xdmcpSocket, NULL) ) {
- XdmcpWarning("UDP set broadcast option failed: netdir_options()");
- freenetconfigent(nconf);
- t_unbind(xdmcpSocket);
- t_close(xdmcpSocket);
- return;
+
+ if (netdir_options(nconf, ND_SET_BROADCAST, xdmcpSocket, NULL)) {
+ XdmcpWarning("UDP set broadcast option failed: netdir_options()");
+ freenetconfigent(nconf);
+ t_unbind(xdmcpSocket);
+ t_close(xdmcpSocket);
+ return;
}
-
+
freenetconfigent(nconf);
#else
int soopts = 1;
#if defined(IPv6) && defined(AF_INET6)
if ((xdmcpSocket6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
- XdmcpWarning("INET6 UDP socket creation failed");
+ XdmcpWarning("INET6 UDP socket creation failed");
#endif
if ((xdmcpSocket = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
- XdmcpWarning("UDP socket creation failed");
+ XdmcpWarning("UDP socket creation failed");
#ifdef SO_BROADCAST
- else if (setsockopt(xdmcpSocket, SOL_SOCKET, SO_BROADCAST, (char *)&soopts,
- sizeof(soopts)) < 0)
- XdmcpWarning("UDP set broadcast socket-option failed");
-#endif /* SO_BROADCAST */
+ else if (setsockopt(xdmcpSocket, SOL_SOCKET, SO_BROADCAST, (char *) &soopts,
+ sizeof(soopts)) < 0)
+ XdmcpWarning("UDP set broadcast socket-option failed");
+#endif /* SO_BROADCAST */
if (xdmcpSocket >= 0 && xdm_from != NULL) {
- if (bind(xdmcpSocket, (struct sockaddr *)&FromAddress,
- FromAddressLen) < 0) {
- FatalError("Xserver: failed to bind to -from address: %s\n", xdm_from);
- }
+ if (bind(xdmcpSocket, (struct sockaddr *) &FromAddress,
+ FromAddressLen) < 0) {
+ FatalError("Xserver: failed to bind to -from address: %s\n",
+ xdm_from);
+ }
}
-#endif /* STREAMSCONN */
+#endif /* STREAMSCONN */
}
static void
send_query_msg(void)
{
- XdmcpHeader header;
- Bool broadcast = FALSE;
+ XdmcpHeader header;
+ Bool broadcast = FALSE;
+
#if defined(IPv6) && defined(AF_INET6)
- Bool multicast = FALSE;
+ Bool multicast = FALSE;
#endif
- int i;
- int socketfd = xdmcpSocket;
+ int i;
+ int socketfd = xdmcpSocket;
header.version = XDM_PROTOCOL_VERSION;
- switch(state){
+ switch (state) {
case XDM_QUERY:
- header.opcode = (CARD16) QUERY;
- state = XDM_COLLECT_QUERY;
- break;
+ header.opcode = (CARD16) QUERY;
+ state = XDM_COLLECT_QUERY;
+ break;
case XDM_BROADCAST:
- header.opcode = (CARD16) BROADCAST_QUERY;
- state = XDM_COLLECT_BROADCAST_QUERY;
- broadcast = TRUE;
- break;
+ header.opcode = (CARD16) BROADCAST_QUERY;
+ state = XDM_COLLECT_BROADCAST_QUERY;
+ broadcast = TRUE;
+ break;
#if defined(IPv6) && defined(AF_INET6)
case XDM_MULTICAST:
- header.opcode = (CARD16) BROADCAST_QUERY;
- state = XDM_COLLECT_MULTICAST_QUERY;
- multicast = TRUE;
- break;
+ header.opcode = (CARD16) BROADCAST_QUERY;
+ state = XDM_COLLECT_MULTICAST_QUERY;
+ multicast = TRUE;
+ break;
#endif
case XDM_INDIRECT:
- header.opcode = (CARD16) INDIRECT_QUERY;
- state = XDM_COLLECT_INDIRECT_QUERY;
- break;
+ header.opcode = (CARD16) INDIRECT_QUERY;
+ state = XDM_COLLECT_INDIRECT_QUERY;
+ break;
default:
- break;
+ break;
}
header.length = 1;
for (i = 0; i < AuthenticationNames.length; i++)
- header.length += 2 + AuthenticationNames.data[i].length;
+ header.length += 2 + AuthenticationNames.data[i].length;
- XdmcpWriteHeader (&buffer, &header);
- XdmcpWriteARRAYofARRAY8 (&buffer, &AuthenticationNames);
- if (broadcast)
- {
- int i;
+ XdmcpWriteHeader(&buffer, &header);
+ XdmcpWriteARRAYofARRAY8(&buffer, &AuthenticationNames);
+ if (broadcast) {
+ int i;
- for (i = 0; i < NumBroadcastAddresses; i++)
- XdmcpFlush (xdmcpSocket, &buffer, (XdmcpNetaddr) &BroadcastAddresses[i],
- sizeof (struct sockaddr_in));
+ for (i = 0; i < NumBroadcastAddresses; i++)
+ XdmcpFlush(xdmcpSocket, &buffer,
+ (XdmcpNetaddr) & BroadcastAddresses[i],
+ sizeof(struct sockaddr_in));
}
#if defined(IPv6) && defined(AF_INET6)
- else if (multicast)
- {
- struct multicastinfo *mcl;
- struct addrinfo *ai;
-
- for (mcl = mcastlist; mcl != NULL; mcl = mcl->next) {
- for (ai = mcl->ai ; ai != NULL; ai = ai->ai_next) {
- if (ai->ai_family == AF_INET) {
- unsigned char hopflag = (unsigned char) mcl->hops;
- socketfd = xdmcpSocket;
- setsockopt(socketfd, IPPROTO_IP, IP_MULTICAST_TTL,
- &hopflag, sizeof(hopflag));
- } else if (ai->ai_family == AF_INET6) {
- int hopflag6 = mcl->hops;
- socketfd = xdmcpSocket6;
- setsockopt(socketfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
- &hopflag6, sizeof(hopflag6));
- } else {
- continue;
- }
- XdmcpFlush (socketfd, &buffer,
- (XdmcpNetaddr) ai->ai_addr, ai->ai_addrlen);
- break;
- }
- }
+ else if (multicast) {
+ struct multicastinfo *mcl;
+ struct addrinfo *ai;
+
+ for (mcl = mcastlist; mcl != NULL; mcl = mcl->next) {
+ for (ai = mcl->ai; ai != NULL; ai = ai->ai_next) {
+ if (ai->ai_family == AF_INET) {
+ unsigned char hopflag = (unsigned char) mcl->hops;
+
+ socketfd = xdmcpSocket;
+ setsockopt(socketfd, IPPROTO_IP, IP_MULTICAST_TTL,
+ &hopflag, sizeof(hopflag));
+ }
+ else if (ai->ai_family == AF_INET6) {
+ int hopflag6 = mcl->hops;
+
+ socketfd = xdmcpSocket6;
+ setsockopt(socketfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
+ &hopflag6, sizeof(hopflag6));
+ }
+ else {
+ continue;
+ }
+ XdmcpFlush(socketfd, &buffer,
+ (XdmcpNetaddr) ai->ai_addr, ai->ai_addrlen);
+ break;
+ }
+ }
}
#endif
- else
- {
+ else {
#if defined(IPv6) && defined(AF_INET6)
- if (SOCKADDR_FAMILY(ManagerAddress) == AF_INET6)
- socketfd = xdmcpSocket6;
-#endif
- XdmcpFlush (socketfd, &buffer, (XdmcpNetaddr) &ManagerAddress,
- ManagerAddressLen);
+ if (SOCKADDR_FAMILY(ManagerAddress) == AF_INET6)
+ socketfd = xdmcpSocket6;
+#endif
+ XdmcpFlush(socketfd, &buffer, (XdmcpNetaddr) & ManagerAddress,
+ ManagerAddressLen);
}
}
static void
-recv_willing_msg(
- struct sockaddr *from,
- int fromlen,
- unsigned length)
+recv_willing_msg(struct sockaddr *from, int fromlen, unsigned length)
{
- ARRAY8 authenticationName;
- ARRAY8 hostname;
- ARRAY8 status;
+ ARRAY8 authenticationName;
+ ARRAY8 hostname;
+ ARRAY8 status;
authenticationName.data = 0;
hostname.data = 0;
status.data = 0;
- if (XdmcpReadARRAY8 (&buffer, &authenticationName) &&
- XdmcpReadARRAY8 (&buffer, &hostname) &&
- XdmcpReadARRAY8 (&buffer, &status))
- {
- if (length == 6 + authenticationName.length +
- hostname.length + status.length)
- {
- switch (state)
- {
- case XDM_COLLECT_QUERY:
- XdmcpSelectHost(from, fromlen, &authenticationName);
- break;
- case XDM_COLLECT_BROADCAST_QUERY:
+ if (XdmcpReadARRAY8(&buffer, &authenticationName) &&
+ XdmcpReadARRAY8(&buffer, &hostname) &&
+ XdmcpReadARRAY8(&buffer, &status)) {
+ if (length == 6 + authenticationName.length +
+ hostname.length + status.length) {
+ switch (state) {
+ case XDM_COLLECT_QUERY:
+ XdmcpSelectHost(from, fromlen, &authenticationName);
+ break;
+ case XDM_COLLECT_BROADCAST_QUERY:
#if defined(IPv6) && defined(AF_INET6)
- case XDM_COLLECT_MULTICAST_QUERY:
+ case XDM_COLLECT_MULTICAST_QUERY:
#endif
- case XDM_COLLECT_INDIRECT_QUERY:
- XdmcpAddHost(from, fromlen, &authenticationName, &hostname, &status);
- break;
- default:
- break;
- }
- }
+ case XDM_COLLECT_INDIRECT_QUERY:
+ XdmcpAddHost(from, fromlen, &authenticationName, &hostname,
+ &status);
+ break;
+ default:
+ break;
+ }
+ }
}
- XdmcpDisposeARRAY8 (&authenticationName);
- XdmcpDisposeARRAY8 (&hostname);
- XdmcpDisposeARRAY8 (&status);
+ XdmcpDisposeARRAY8(&authenticationName);
+ XdmcpDisposeARRAY8(&hostname);
+ XdmcpDisposeARRAY8(&status);
}
static void
send_request_msg(void)
{
- XdmcpHeader header;
- int length;
- int i;
- CARD16 XdmcpConnectionType;
- ARRAY8 authenticationData;
- int socketfd = xdmcpSocket;
-
- switch (SOCKADDR_FAMILY(ManagerAddress))
- {
- case AF_INET: XdmcpConnectionType=FamilyInternet; break;
+ XdmcpHeader header;
+ int length;
+ int i;
+ CARD16 XdmcpConnectionType;
+ ARRAY8 authenticationData;
+ int socketfd = xdmcpSocket;
+
+ switch (SOCKADDR_FAMILY(ManagerAddress)) {
+ case AF_INET:
+ XdmcpConnectionType = FamilyInternet;
+ break;
#if defined(IPv6) && defined(AF_INET6)
- case AF_INET6: XdmcpConnectionType=FamilyInternet6; break;
+ case AF_INET6:
+ XdmcpConnectionType = FamilyInternet6;
+ break;
#endif
- default: XdmcpConnectionType=0xffff; break;
+ default:
+ XdmcpConnectionType = 0xffff;
+ break;
}
header.version = XDM_PROTOCOL_VERSION;
header.opcode = (CARD16) REQUEST;
- length = 2; /* display number */
- length += 1 + 2 * ConnectionTypes.length; /* connection types */
- length += 1; /* connection addresses */
+ length = 2; /* display number */
+ length += 1 + 2 * ConnectionTypes.length; /* connection types */
+ length += 1; /* connection addresses */
for (i = 0; i < ConnectionAddresses.length; i++)
- length += 2 + ConnectionAddresses.data[i].length;
+ length += 2 + ConnectionAddresses.data[i].length;
authenticationData.length = 0;
authenticationData.data = 0;
- if (AuthenticationFuncs)
- {
- (*AuthenticationFuncs->Generator) (AuthenticationData,
- &authenticationData,
- REQUEST);
+ if (AuthenticationFuncs) {
+ (*AuthenticationFuncs->Generator) (AuthenticationData,
+ &authenticationData, REQUEST);
}
- length += 2 + AuthenticationName->length; /* authentication name */
- length += 2 + authenticationData.length; /* authentication data */
- length += 1; /* authorization names */
+ length += 2 + AuthenticationName->length; /* authentication name */
+ length += 2 + authenticationData.length; /* authentication data */
+ length += 1; /* authorization names */
for (i = 0; i < AuthorizationNames.length; i++)
- length += 2 + AuthorizationNames.data[i].length;
- length += 2 + ManufacturerDisplayID.length; /* display ID */
+ length += 2 + AuthorizationNames.data[i].length;
+ length += 2 + ManufacturerDisplayID.length; /* display ID */
header.length = length;
- if (!XdmcpWriteHeader (&buffer, &header))
- {
- XdmcpDisposeARRAY8 (&authenticationData);
- return;
+ if (!XdmcpWriteHeader(&buffer, &header)) {
+ XdmcpDisposeARRAY8(&authenticationData);
+ return;
}
- XdmcpWriteCARD16 (&buffer, DisplayNumber);
- XdmcpWriteCARD8 (&buffer, ConnectionTypes.length);
-
- /* The connection array is send reordered, so that connections of */
- /* the same address type as the XDMCP manager connection are send */
- /* first. This works around a bug in xdm. mario@klebsch.de */
- for (i = 0; i < (int)ConnectionTypes.length; i++)
- if (ConnectionTypes.data[i]==XdmcpConnectionType)
- XdmcpWriteCARD16 (&buffer, ConnectionTypes.data[i]);
- for (i = 0; i < (int)ConnectionTypes.length; i++)
- if (ConnectionTypes.data[i]!=XdmcpConnectionType)
- XdmcpWriteCARD16 (&buffer, ConnectionTypes.data[i]);
-
- XdmcpWriteCARD8 (&buffer, ConnectionAddresses.length);
- for (i = 0; i < (int)ConnectionAddresses.length; i++)
- if ( (i<ConnectionTypes.length) &&
- (ConnectionTypes.data[i]==XdmcpConnectionType) )
- XdmcpWriteARRAY8 (&buffer, &ConnectionAddresses.data[i]);
- for (i = 0; i < (int)ConnectionAddresses.length; i++)
- if ( (i>=ConnectionTypes.length) ||
- (ConnectionTypes.data[i]!=XdmcpConnectionType) )
- XdmcpWriteARRAY8 (&buffer, &ConnectionAddresses.data[i]);
-
- XdmcpWriteARRAY8 (&buffer, AuthenticationName);
- XdmcpWriteARRAY8 (&buffer, &authenticationData);
- XdmcpDisposeARRAY8 (&authenticationData);
- XdmcpWriteARRAYofARRAY8 (&buffer, &AuthorizationNames);
- XdmcpWriteARRAY8 (&buffer, &ManufacturerDisplayID);
+ XdmcpWriteCARD16(&buffer, DisplayNumber);
+ XdmcpWriteCARD8(&buffer, ConnectionTypes.length);
+
+ /* The connection array is send reordered, so that connections of */
+ /* the same address type as the XDMCP manager connection are send */
+ /* first. This works around a bug in xdm. mario@klebsch.de */
+ for (i = 0; i < (int) ConnectionTypes.length; i++)
+ if (ConnectionTypes.data[i] == XdmcpConnectionType)
+ XdmcpWriteCARD16(&buffer, ConnectionTypes.data[i]);
+ for (i = 0; i < (int) ConnectionTypes.length; i++)
+ if (ConnectionTypes.data[i] != XdmcpConnectionType)
+ XdmcpWriteCARD16(&buffer, ConnectionTypes.data[i]);
+
+ XdmcpWriteCARD8(&buffer, ConnectionAddresses.length);
+ for (i = 0; i < (int) ConnectionAddresses.length; i++)
+ if ((i < ConnectionTypes.length) &&
+ (ConnectionTypes.data[i] == XdmcpConnectionType))
+ XdmcpWriteARRAY8(&buffer, &ConnectionAddresses.data[i]);
+ for (i = 0; i < (int) ConnectionAddresses.length; i++)
+ if ((i >= ConnectionTypes.length) ||
+ (ConnectionTypes.data[i] != XdmcpConnectionType))
+ XdmcpWriteARRAY8(&buffer, &ConnectionAddresses.data[i]);
+
+ XdmcpWriteARRAY8(&buffer, AuthenticationName);
+ XdmcpWriteARRAY8(&buffer, &authenticationData);
+ XdmcpDisposeARRAY8(&authenticationData);
+ XdmcpWriteARRAYofARRAY8(&buffer, &AuthorizationNames);
+ XdmcpWriteARRAY8(&buffer, &ManufacturerDisplayID);
#if defined(IPv6) && defined(AF_INET6)
if (SOCKADDR_FAMILY(req_sockaddr) == AF_INET6)
- socketfd = xdmcpSocket6;
+ socketfd = xdmcpSocket6;
#endif
- if (XdmcpFlush (socketfd, &buffer,
- (XdmcpNetaddr) &req_sockaddr, req_socklen))
- state = XDM_AWAIT_REQUEST_RESPONSE;
+ if (XdmcpFlush(socketfd, &buffer,
+ (XdmcpNetaddr) & req_sockaddr, req_socklen))
+ state = XDM_AWAIT_REQUEST_RESPONSE;
}
static void
recv_accept_msg(unsigned length)
{
- CARD32 AcceptSessionID;
- ARRAY8 AcceptAuthenticationName, AcceptAuthenticationData;
- ARRAY8 AcceptAuthorizationName, AcceptAuthorizationData;
+ CARD32 AcceptSessionID;
+ ARRAY8 AcceptAuthenticationName, AcceptAuthenticationData;
+ ARRAY8 AcceptAuthorizationName, AcceptAuthorizationData;
if (state != XDM_AWAIT_REQUEST_RESPONSE)
- return;
+ return;
AcceptAuthenticationName.data = 0;
AcceptAuthenticationData.data = 0;
AcceptAuthorizationName.data = 0;
AcceptAuthorizationData.data = 0;
- if (XdmcpReadCARD32 (&buffer, &AcceptSessionID) &&
- XdmcpReadARRAY8 (&buffer, &AcceptAuthenticationName) &&
- XdmcpReadARRAY8 (&buffer, &AcceptAuthenticationData) &&
- XdmcpReadARRAY8 (&buffer, &AcceptAuthorizationName) &&
- XdmcpReadARRAY8 (&buffer, &AcceptAuthorizationData))
- {
- if (length == 12 + AcceptAuthenticationName.length +
- AcceptAuthenticationData.length +
- AcceptAuthorizationName.length +
- AcceptAuthorizationData.length)
- {
- if (!XdmcpCheckAuthentication (&AcceptAuthenticationName,
- &AcceptAuthenticationData, ACCEPT))
- {
- XdmcpFatal ("Authentication Failure", &AcceptAuthenticationName);
- }
- /* permit access control manipulations from this host */
- AugmentSelf (&req_sockaddr, req_socklen);
- /* if the authorization specified in the packet fails
- * to be acceptable, enable the local addresses
- */
- if (!XdmcpAddAuthorization (&AcceptAuthorizationName,
- &AcceptAuthorizationData))
- {
- AddLocalHosts ();
- }
- SessionID = AcceptSessionID;
- state = XDM_MANAGE;
- send_packet();
- }
+ if (XdmcpReadCARD32(&buffer, &AcceptSessionID) &&
+ XdmcpReadARRAY8(&buffer, &AcceptAuthenticationName) &&
+ XdmcpReadARRAY8(&buffer, &AcceptAuthenticationData) &&
+ XdmcpReadARRAY8(&buffer, &AcceptAuthorizationName) &&
+ XdmcpReadARRAY8(&buffer, &AcceptAuthorizationData)) {
+ if (length == 12 + AcceptAuthenticationName.length +
+ AcceptAuthenticationData.length +
+ AcceptAuthorizationName.length + AcceptAuthorizationData.length) {
+ if (!XdmcpCheckAuthentication(&AcceptAuthenticationName,
+ &AcceptAuthenticationData, ACCEPT)) {
+ XdmcpFatal("Authentication Failure", &AcceptAuthenticationName);
+ }
+ /* permit access control manipulations from this host */
+ AugmentSelf(&req_sockaddr, req_socklen);
+ /* if the authorization specified in the packet fails
+ * to be acceptable, enable the local addresses
+ */
+ if (!XdmcpAddAuthorization(&AcceptAuthorizationName,
+ &AcceptAuthorizationData)) {
+ AddLocalHosts();
+ }
+ SessionID = AcceptSessionID;
+ state = XDM_MANAGE;
+ send_packet();
+ }
}
- XdmcpDisposeARRAY8 (&AcceptAuthenticationName);
- XdmcpDisposeARRAY8 (&AcceptAuthenticationData);
- XdmcpDisposeARRAY8 (&AcceptAuthorizationName);
- XdmcpDisposeARRAY8 (&AcceptAuthorizationData);
+ XdmcpDisposeARRAY8(&AcceptAuthenticationName);
+ XdmcpDisposeARRAY8(&AcceptAuthenticationData);
+ XdmcpDisposeARRAY8(&AcceptAuthorizationName);
+ XdmcpDisposeARRAY8(&AcceptAuthorizationData);
}
static void
recv_decline_msg(unsigned length)
{
- ARRAY8 status, DeclineAuthenticationName, DeclineAuthenticationData;
+ ARRAY8 status, DeclineAuthenticationName, DeclineAuthenticationData;
status.data = 0;
DeclineAuthenticationName.data = 0;
DeclineAuthenticationData.data = 0;
- if (XdmcpReadARRAY8 (&buffer, &status) &&
- XdmcpReadARRAY8 (&buffer, &DeclineAuthenticationName) &&
- XdmcpReadARRAY8 (&buffer, &DeclineAuthenticationData))
- {
- if (length == 6 + status.length +
- DeclineAuthenticationName.length +
- DeclineAuthenticationData.length &&
- XdmcpCheckAuthentication (&DeclineAuthenticationName,
- &DeclineAuthenticationData, DECLINE))
- {
- XdmcpFatal ("Session declined", &status);
- }
+ if (XdmcpReadARRAY8(&buffer, &status) &&
+ XdmcpReadARRAY8(&buffer, &DeclineAuthenticationName) &&
+ XdmcpReadARRAY8(&buffer, &DeclineAuthenticationData)) {
+ if (length == 6 + status.length +
+ DeclineAuthenticationName.length +
+ DeclineAuthenticationData.length &&
+ XdmcpCheckAuthentication(&DeclineAuthenticationName,
+ &DeclineAuthenticationData, DECLINE)) {
+ XdmcpFatal("Session declined", &status);
+ }
}
- XdmcpDisposeARRAY8 (&status);
- XdmcpDisposeARRAY8 (&DeclineAuthenticationName);
- XdmcpDisposeARRAY8 (&DeclineAuthenticationData);
+ XdmcpDisposeARRAY8(&status);
+ XdmcpDisposeARRAY8(&DeclineAuthenticationName);
+ XdmcpDisposeARRAY8(&DeclineAuthenticationData);
}
static void
send_manage_msg(void)
{
- XdmcpHeader header;
+ XdmcpHeader header;
int socketfd = xdmcpSocket;
header.version = XDM_PROTOCOL_VERSION;
header.opcode = (CARD16) MANAGE;
header.length = 8 + DisplayClass.length;
- if (!XdmcpWriteHeader (&buffer, &header))
- return;
- XdmcpWriteCARD32 (&buffer, SessionID);
- XdmcpWriteCARD16 (&buffer, DisplayNumber);
- XdmcpWriteARRAY8 (&buffer, &DisplayClass);
+ if (!XdmcpWriteHeader(&buffer, &header))
+ return;
+ XdmcpWriteCARD32(&buffer, SessionID);
+ XdmcpWriteCARD16(&buffer, DisplayNumber);
+ XdmcpWriteARRAY8(&buffer, &DisplayClass);
state = XDM_AWAIT_MANAGE_RESPONSE;
#if defined(IPv6) && defined(AF_INET6)
if (SOCKADDR_FAMILY(req_sockaddr) == AF_INET6)
- socketfd = xdmcpSocket6;
+ socketfd = xdmcpSocket6;
#endif
- XdmcpFlush (socketfd, &buffer, (XdmcpNetaddr) &req_sockaddr, req_socklen);
+ XdmcpFlush(socketfd, &buffer, (XdmcpNetaddr) & req_sockaddr, req_socklen);
}
static void
recv_refuse_msg(unsigned length)
{
- CARD32 RefusedSessionID;
+ CARD32 RefusedSessionID;
if (state != XDM_AWAIT_MANAGE_RESPONSE)
- return;
+ return;
if (length != 4)
- return;
- if (XdmcpReadCARD32 (&buffer, &RefusedSessionID))
- {
- if (RefusedSessionID == SessionID)
- {
- state = XDM_START_CONNECTION;
- send_packet();
- }
+ return;
+ if (XdmcpReadCARD32(&buffer, &RefusedSessionID)) {
+ if (RefusedSessionID == SessionID) {
+ state = XDM_START_CONNECTION;
+ send_packet();
+ }
}
}
static void
recv_failed_msg(unsigned length)
{
- CARD32 FailedSessionID;
- ARRAY8 status;
+ CARD32 FailedSessionID;
+ ARRAY8 status;
if (state != XDM_AWAIT_MANAGE_RESPONSE)
- return;
+ return;
status.data = 0;
- if (XdmcpReadCARD32 (&buffer, &FailedSessionID) &&
- XdmcpReadARRAY8 (&buffer, &status))
- {
- if (length == 6 + status.length &&
- SessionID == FailedSessionID)
- {
- XdmcpFatal ("Session failed", &status);
- }
+ if (XdmcpReadCARD32(&buffer, &FailedSessionID) &&
+ XdmcpReadARRAY8(&buffer, &status)) {
+ if (length == 6 + status.length && SessionID == FailedSessionID) {
+ XdmcpFatal("Session failed", &status);
+ }
}
- XdmcpDisposeARRAY8 (&status);
+ XdmcpDisposeARRAY8(&status);
}
static void
send_keepalive_msg(void)
{
- XdmcpHeader header;
+ XdmcpHeader header;
int socketfd = xdmcpSocket;
header.version = XDM_PROTOCOL_VERSION;
header.opcode = (CARD16) KEEPALIVE;
header.length = 6;
- XdmcpWriteHeader (&buffer, &header);
- XdmcpWriteCARD16 (&buffer, DisplayNumber);
- XdmcpWriteCARD32 (&buffer, SessionID);
+ XdmcpWriteHeader(&buffer, &header);
+ XdmcpWriteCARD16(&buffer, DisplayNumber);
+ XdmcpWriteCARD32(&buffer, SessionID);
state = XDM_AWAIT_ALIVE_RESPONSE;
#if defined(IPv6) && defined(AF_INET6)
if (SOCKADDR_FAMILY(req_sockaddr) == AF_INET6)
- socketfd = xdmcpSocket6;
+ socketfd = xdmcpSocket6;
#endif
- XdmcpFlush (socketfd, &buffer, (XdmcpNetaddr) &req_sockaddr, req_socklen);
+ XdmcpFlush(socketfd, &buffer, (XdmcpNetaddr) & req_sockaddr, req_socklen);
}
static void
-recv_alive_msg (unsigned length)
+recv_alive_msg(unsigned length)
{
- CARD8 SessionRunning;
- CARD32 AliveSessionID;
+ CARD8 SessionRunning;
+ CARD32 AliveSessionID;
if (state != XDM_AWAIT_ALIVE_RESPONSE)
- return;
+ return;
if (length != 5)
- return;
- if (XdmcpReadCARD8 (&buffer, &SessionRunning) &&
- XdmcpReadCARD32 (&buffer, &AliveSessionID))
- {
- if (SessionRunning && AliveSessionID == SessionID)
- {
- /* backoff dormancy period */
- state = XDM_RUN_SESSION;
- if ((GetTimeInMillis() - lastDeviceEventTime.milliseconds) >
- keepaliveDormancy * 1000)
- {
- keepaliveDormancy <<= 1;
- if (keepaliveDormancy > XDM_MAX_DORMANCY)
- keepaliveDormancy = XDM_MAX_DORMANCY;
- }
- timeOutTime = GetTimeInMillis() + keepaliveDormancy * 1000;
- }
- else
- {
- XdmcpDeadSession ("Alive response indicates session dead");
- }
+ return;
+ if (XdmcpReadCARD8(&buffer, &SessionRunning) &&
+ XdmcpReadCARD32(&buffer, &AliveSessionID)) {
+ if (SessionRunning && AliveSessionID == SessionID) {
+ /* backoff dormancy period */
+ state = XDM_RUN_SESSION;
+ if ((GetTimeInMillis() - lastDeviceEventTime[XIAllDevices].milliseconds) >
+ keepaliveDormancy * 1000) {
+ keepaliveDormancy <<= 1;
+ if (keepaliveDormancy > XDM_MAX_DORMANCY)
+ keepaliveDormancy = XDM_MAX_DORMANCY;
+ }
+ timeOutTime = GetTimeInMillis() + keepaliveDormancy * 1000;
+ }
+ else {
+ XdmcpDeadSession("Alive response indicates session dead");
+ }
}
}
-static void
-XdmcpFatal (
- const char *type,
- ARRAY8Ptr status)
+static void
+XdmcpFatal(const char *type, ARRAY8Ptr status)
{
- FatalError ("XDMCP fatal error: %s %*.*s\n", type,
- status->length, status->length, status->data);
+ FatalError("XDMCP fatal error: %s %*.*s\n", type,
+ status->length, status->length, status->data);
}
-static void
+static void
XdmcpWarning(const char *str)
{
ErrorF("XDMCP warning: %s\n", str);
}
static void
-get_addr_by_name(
- const char *argtype,
- const char *namestr,
- int port,
- int socktype,
- SOCKADDR_TYPE *addr,
- SOCKLEN_TYPE *addrlen
+get_addr_by_name(const char *argtype,
+ const char *namestr,
+ int port,
+ int socktype, SOCKADDR_TYPE * addr, SOCKLEN_TYPE * addrlen
#if defined(IPv6) && defined(AF_INET6)
- ,
- struct addrinfo **aip,
- struct addrinfo **aifirstp
+ , struct addrinfo **aip, struct addrinfo **aifirstp
#endif
)
{
@@ -1487,108 +1439,102 @@ get_addr_by_name(
hints.ai_socktype = socktype;
if (port == 0) {
- pport = NULL;
- } else if (port > 0 && port < 65535) {
- snprintf(portstr, sizeof(portstr), "%d", port);
- } else {
- FatalError("Xserver: port out of range: %d\n", port);
+ pport = NULL;
+ }
+ else if (port > 0 && port < 65535) {
+ snprintf(portstr, sizeof(portstr), "%d", port);
+ }
+ else {
+ FatalError("Xserver: port out of range: %d\n", port);
}
if (*aifirstp != NULL) {
- freeaddrinfo(*aifirstp);
- *aifirstp = NULL;
+ freeaddrinfo(*aifirstp);
+ *aifirstp = NULL;
}
if ((gaierr = getaddrinfo(namestr, pport, &hints, aifirstp)) == 0) {
- for (ai = *aifirstp; ai != NULL; ai = ai->ai_next) {
- if (ai->ai_family == AF_INET || ai->ai_family == AF_INET6)
- break;
- }
- if ((ai == NULL) || (ai->ai_addrlen > sizeof(SOCKADDR_TYPE))) {
- FatalError ("Xserver: %s host %s not on supported network type\n",
- argtype, namestr);
- } else {
- *aip = ai;
- *addrlen = ai->ai_addrlen;
- memcpy(addr, ai->ai_addr, ai->ai_addrlen);
- }
- } else {
- FatalError("Xserver: %s: %s %s\n", gai_strerror(gaierr), argtype, namestr);
- }
+ for (ai = *aifirstp; ai != NULL; ai = ai->ai_next) {
+ if (ai->ai_family == AF_INET || ai->ai_family == AF_INET6)
+ break;
+ }
+ if ((ai == NULL) || (ai->ai_addrlen > sizeof(SOCKADDR_TYPE))) {
+ FatalError("Xserver: %s host %s not on supported network type\n",
+ argtype, namestr);
+ }
+ else {
+ *aip = ai;
+ *addrlen = ai->ai_addrlen;
+ memcpy(addr, ai->ai_addr, ai->ai_addrlen);
+ }
+ }
+ else {
+ FatalError("Xserver: %s: %s %s\n", gai_strerror(gaierr), argtype,
+ namestr);
+ }
#else
struct hostent *hep;
+
#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
_Xgethostbynameparams hparams;
#endif
#if defined(WIN32) && defined(TCPCONN)
- _XSERVTransWSAStartup();
+ _XSERVTransWSAStartup();
#endif
- if (!(hep = _XGethostbyname(namestr, hparams)))
- {
- FatalError("Xserver: %s unknown host: %s\n", argtype, namestr);
+ if (!(hep = _XGethostbyname(namestr, hparams))) {
+ FatalError("Xserver: %s unknown host: %s\n", argtype, namestr);
}
- if (hep->h_length == sizeof (struct in_addr))
- {
- memmove(&addr->sin_addr, hep->h_addr, hep->h_length);
- *addrlen = sizeof(struct sockaddr_in);
- addr->sin_family = AF_INET;
- addr->sin_port = htons (port);
+ if (hep->h_length == sizeof(struct in_addr)) {
+ memmove(&addr->sin_addr, hep->h_addr, hep->h_length);
+ *addrlen = sizeof(struct sockaddr_in);
+ addr->sin_family = AF_INET;
+ addr->sin_port = htons(port);
}
- else
- {
- FatalError("Xserver: %s host on strange network %s\n", argtype, namestr);
+ else {
+ FatalError("Xserver: %s host on strange network %s\n", argtype,
+ namestr);
}
#endif
}
static void
-get_manager_by_name(
- int argc,
- char **argv,
- int i)
+get_manager_by_name(int argc, char **argv, int i)
{
- if ((i + 1) == argc)
- {
- FatalError("Xserver: missing %s host name in command line\n", argv[i]);
+ if ((i + 1) == argc) {
+ FatalError("Xserver: missing %s host name in command line\n", argv[i]);
}
- get_addr_by_name(argv[i], argv[i+1], xdm_udp_port, SOCK_DGRAM,
- &ManagerAddress, &ManagerAddressLen
+ get_addr_by_name(argv[i], argv[i + 1], xdm_udp_port, SOCK_DGRAM,
+ &ManagerAddress, &ManagerAddressLen
#if defined(IPv6) && defined(AF_INET6)
- , &mgrAddr, &mgrAddrFirst
+ , &mgrAddr, &mgrAddrFirst
#endif
- );
+ );
}
-
static void
-get_fromaddr_by_name(
- int argc,
- char **argv,
- int i)
+get_fromaddr_by_name(int argc, char **argv, int i)
{
#if defined(IPv6) && defined(AF_INET6)
struct addrinfo *ai = NULL;
struct addrinfo *aifirst = NULL;
#endif
- if (i == argc)
- {
- FatalError("Xserver: missing -from host name in command line\n");
+ if (i == argc) {
+ FatalError("Xserver: missing -from host name in command line\n");
}
get_addr_by_name("-from", argv[i], 0, 0, &FromAddress, &FromAddressLen
#if defined(IPv6) && defined(AF_INET6)
- , &ai, &aifirst
+ , &ai, &aifirst
#endif
- );
+ );
#if defined(IPv6) && defined(AF_INET6)
if (aifirst != NULL)
- freeaddrinfo(aifirst);
+ freeaddrinfo(aifirst);
#endif
xdm_from = argv[i];
}
-
#if defined(IPv6) && defined(AF_INET6)
static int
get_mcast_options(int argc, char **argv, int i)
@@ -1601,61 +1547,65 @@ get_mcast_options(int argc, char **argv, int i)
struct addrinfo *ai, *firstai;
if ((i < argc) && (argv[i][0] != '-') && (argv[i][0] != '+')) {
- address = argv[i++];
- if ((i < argc) && (argv[i][0] != '-') && (argv[i][0] != '+')) {
- hopcount = strtol(argv[i++], NULL, 10);
- if ((hopcount < 1) || (hopcount > 255)) {
- FatalError("Xserver: multicast hop count out of range: %d\n",
- hopcount);
- }
- }
+ address = argv[i++];
+ if ((i < argc) && (argv[i][0] != '-') && (argv[i][0] != '+')) {
+ hopcount = strtol(argv[i++], NULL, 10);
+ if ((hopcount < 1) || (hopcount > 255)) {
+ FatalError("Xserver: multicast hop count out of range: %d\n",
+ hopcount);
+ }
+ }
}
if (xdm_udp_port > 0 && xdm_udp_port < 65535) {
- snprintf(portstr, sizeof(portstr), "%d", xdm_udp_port);
- } else {
- FatalError("Xserver: port out of range: %d\n", xdm_udp_port);
+ snprintf(portstr, sizeof(portstr), "%d", xdm_udp_port);
+ }
+ else {
+ FatalError("Xserver: port out of range: %d\n", xdm_udp_port);
}
memset(&hints, 0, sizeof(hints));
hints.ai_socktype = SOCK_DGRAM;
if ((gaierr = getaddrinfo(address, portstr, &hints, &firstai)) == 0) {
- for (ai = firstai; ai != NULL; ai = ai->ai_next) {
- if (((ai->ai_family == AF_INET) &&
- IN_MULTICAST(((struct sockaddr_in *) ai->ai_addr)
- ->sin_addr.s_addr))
- || ((ai->ai_family == AF_INET6) &&
- IN6_IS_ADDR_MULTICAST(&((struct sockaddr_in6 *) ai->ai_addr)
- ->sin6_addr)))
- break;
- }
- if (ai == NULL) {
- FatalError ("Xserver: address not supported multicast type %s\n",
- address);
- } else {
- struct multicastinfo *mcastinfo, *mcl;
-
- mcastinfo = malloc(sizeof(struct multicastinfo));
- mcastinfo->next = NULL;
- mcastinfo->ai = firstai;
- mcastinfo->hops = hopcount;
-
- if (mcastlist == NULL) {
- mcastlist = mcastinfo;
- } else {
- for (mcl = mcastlist; mcl->next != NULL; mcl = mcl->next) {
- /* Do nothing - just find end of list */
- }
- mcl->next = mcastinfo;
- }
- }
- } else {
- FatalError("Xserver: %s: %s\n", gai_strerror(gaierr), address);
- }
+ for (ai = firstai; ai != NULL; ai = ai->ai_next) {
+ if (((ai->ai_family == AF_INET) &&
+ IN_MULTICAST(((struct sockaddr_in *) ai->ai_addr)
+ ->sin_addr.s_addr))
+ || ((ai->ai_family == AF_INET6) &&
+ IN6_IS_ADDR_MULTICAST(&((struct sockaddr_in6 *) ai->ai_addr)
+ ->sin6_addr)))
+ break;
+ }
+ if (ai == NULL) {
+ FatalError("Xserver: address not supported multicast type %s\n",
+ address);
+ }
+ else {
+ struct multicastinfo *mcastinfo, *mcl;
+
+ mcastinfo = malloc(sizeof(struct multicastinfo));
+ mcastinfo->next = NULL;
+ mcastinfo->ai = firstai;
+ mcastinfo->hops = hopcount;
+
+ if (mcastlist == NULL) {
+ mcastlist = mcastinfo;
+ }
+ else {
+ for (mcl = mcastlist; mcl->next != NULL; mcl = mcl->next) {
+ /* Do nothing - just find end of list */
+ }
+ mcl->next = mcastinfo;
+ }
+ }
+ }
+ else {
+ FatalError("Xserver: %s: %s\n", gai_strerror(gaierr), address);
+ }
return i;
}
#endif
#else
-static int xdmcp_non_empty; /* avoid complaint by ranlib */
-#endif /* XDMCP */
+static int xdmcp_non_empty; /* avoid complaint by ranlib */
+#endif /* XDMCP */
diff --git a/xorg-server/os/xprintf.c b/xorg-server/os/xprintf.c
index 3b4bb4117..17fea2ec7 100644
--- a/xorg-server/os/xprintf.c
+++ b/xorg-server/os/xprintf.c
@@ -68,18 +68,18 @@
#include <string.h>
#ifdef asprintf
-# undef asprintf
+#undef asprintf
#endif
#ifdef vasprintf
-# undef vasprintf
+#undef vasprintf
#endif
#ifndef va_copy
-# ifdef __va_copy
-# define va_copy __va_copy
-# else
-# error "no working va_copy was found"
-# endif
+#ifdef __va_copy
+#define va_copy __va_copy
+#else
+#error "no working va_copy was found"
+#endif
#endif
/**
@@ -93,7 +93,7 @@
* @return size of allocated buffer, or -1 on error.
*/
int
-Xvasprintf(char **ret, const char * _X_RESTRICT_KYWD format, va_list va)
+Xvasprintf(char **ret, const char *_X_RESTRICT_KYWD format, va_list va)
{
#ifdef HAVE_VASPRINTF
return vasprintf(ret, format, va);
@@ -116,7 +116,7 @@ Xvasprintf(char **ret, const char * _X_RESTRICT_KYWD format, va_list va)
}
#ifndef HAVE_VASPRINTF
-# define vasprintf Xvasprintf
+#define vasprintf Xvasprintf
#endif
/**
@@ -130,10 +130,11 @@ Xvasprintf(char **ret, const char * _X_RESTRICT_KYWD format, va_list va)
* @return size of allocated buffer, or -1 on error.
*/
int
-Xasprintf(char ** ret, const char * _X_RESTRICT_KYWD format, ...)
+Xasprintf(char **ret, const char *_X_RESTRICT_KYWD format, ...)
{
int size;
va_list va;
+
va_start(va, format);
size = vasprintf(ret, format, va);
va_end(va);
@@ -152,11 +153,12 @@ Xasprintf(char ** ret, const char * _X_RESTRICT_KYWD format, ...)
* @return size of allocated buffer
*/
int
-XNFvasprintf(char **ret, const char * _X_RESTRICT_KYWD format, va_list va)
+XNFvasprintf(char **ret, const char *_X_RESTRICT_KYWD format, va_list va)
{
int size = vasprintf(ret, format, va);
+
if ((size == -1) || (*ret == NULL)) {
- FatalError("XNFvasprintf failed: %s", strerror(errno));
+ FatalError("XNFvasprintf failed: %s", strerror(errno));
}
return size;
}
@@ -173,10 +175,11 @@ XNFvasprintf(char **ret, const char * _X_RESTRICT_KYWD format, va_list va)
* @return size of allocated buffer
*/
int
-XNFasprintf(char ** ret, const char * _X_RESTRICT_KYWD format, ...)
+XNFasprintf(char **ret, const char *_X_RESTRICT_KYWD format, ...)
{
int size;
va_list va;
+
va_start(va, format);
size = XNFvasprintf(ret, format, va);
va_end(va);
@@ -190,18 +193,20 @@ Xvprintf(const char *format, va_list va)
char *ret;
if (vasprintf(&ret, format, va) == -1)
- ret = NULL;
+ ret = NULL;
return ret;
}
-char *Xprintf(const char *format, ...)
+char *
+Xprintf(const char *format, ...)
{
char *ret;
va_list va;
+
va_start(va, format);
if (vasprintf(&ret, format, va) == -1)
- ret = NULL;
+ ret = NULL;
va_end(va);
return ret;
}
@@ -216,10 +221,12 @@ XNFvprintf(const char *format, va_list va)
return ret;
}
-char *XNFprintf(const char *format, ...)
+char *
+XNFprintf(const char *format, ...)
{
char *ret;
va_list va;
+
va_start(va, format);
XNFvasprintf(&ret, format, va);
va_end(va);
diff --git a/xorg-server/os/xsha1.c b/xorg-server/os/xsha1.c
index 518745b4c..dccce74b6 100644
--- a/xorg-server/os/xsha1.c
+++ b/xorg-server/os/xsha1.c
@@ -1,168 +1,195 @@
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "os.h"
-#include "xsha1.h"
-
-#if defined(HAVE_SHA1_IN_LIBMD) /* Use libmd for SHA1 */ \
- || defined(HAVE_SHA1_IN_LIBC) /* Use libc for SHA1 */
-
-# include <sha1.h>
-
-void *x_sha1_init(void)
-{
- SHA1_CTX *ctx = malloc(sizeof(*ctx));
- if (!ctx)
- return NULL;
- SHA1Init(ctx);
- return ctx;
-}
-
-int x_sha1_update(void *ctx, void *data, int size)
-{
- SHA1_CTX *sha1_ctx = ctx;
- SHA1Update(sha1_ctx, data, size);
- return 1;
-}
-
-int x_sha1_final(void *ctx, unsigned char result[20])
-{
- SHA1_CTX *sha1_ctx = ctx;
- SHA1Final(result, sha1_ctx);
- free(sha1_ctx);
- return 1;
-}
-
-#elif defined(HAVE_SHA1_IN_COMMONCRYPTO) /* Use CommonCrypto for SHA1 */
-
-#include <CommonCrypto/CommonDigest.h>
-
-void *x_sha1_init(void)
-{
- CC_SHA1_CTX *ctx = malloc(sizeof(*ctx));
- if (!ctx)
- return NULL;
- CC_SHA1_Init(ctx);
- return ctx;
-}
-
-int x_sha1_update(void *ctx, void *data, int size)
-{
- CC_SHA1_CTX *sha1_ctx = ctx;
- CC_SHA1_Update(sha1_ctx, data, size);
- return 1;
-}
-
-int x_sha1_final(void *ctx, unsigned char result[20])
-{
- CC_SHA1_CTX *sha1_ctx = ctx;
- CC_SHA1_Final(result, sha1_ctx);
- free(sha1_ctx);
- return 1;
-}
-
-#elif defined(HAVE_SHA1_IN_LIBGCRYPT) /* Use libgcrypt for SHA1 */
-
-# include <gcrypt.h>
-
-void *x_sha1_init(void)
-{
- static int init;
- gcry_md_hd_t h;
- gcry_error_t err;
-
- if (!init) {
- if (!gcry_check_version(NULL))
- return NULL;
- gcry_control(GCRYCTL_DISABLE_SECMEM, 0);
- gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
- init = 1;
- }
-
- err = gcry_md_open(&h, GCRY_MD_SHA1, 0);
- if (err)
- return NULL;
- return h;
-}
-
-int x_sha1_update(void *ctx, void *data, int size)
-{
- gcry_md_hd_t h = ctx;
- gcry_md_write(h, data, size);
- return 1;
-}
-
-int x_sha1_final(void *ctx, unsigned char result[20])
-{
- gcry_md_hd_t h = ctx;
- memcpy(result, gcry_md_read(h, GCRY_MD_SHA1), 20);
- gcry_md_close(h);
- return 1;
-}
-
-#elif defined(HAVE_SHA1_IN_LIBSHA1) /* Use libsha1 */
-
-# include <libsha1.h>
-
-void *x_sha1_init(void)
-{
- sha1_ctx *ctx = malloc(sizeof(*ctx));
- if(!ctx)
- return NULL;
- sha1_begin(ctx);
- return ctx;
-}
-
-int x_sha1_update(void *ctx, void *data, int size)
-{
- sha1_hash(data, size, ctx);
- return 1;
-}
-
-int x_sha1_final(void *ctx, unsigned char result[20])
-{
- sha1_end(result, ctx);
- free(ctx);
- return 1;
-}
-
-#else /* Use OpenSSL's libcrypto */
-
-# include <stddef.h> /* buggy openssl/sha.h wants size_t */
-# include <openssl/sha.h>
-
-void *x_sha1_init(void)
-{
- int ret;
- SHA_CTX *ctx = malloc(sizeof(*ctx));
- if (!ctx)
- return NULL;
- ret = SHA1_Init(ctx);
- if (!ret) {
- free(ctx);
- return NULL;
- }
- return ctx;
-}
-
-int x_sha1_update(void *ctx, void *data, int size)
-{
- int ret;
- SHA_CTX *sha_ctx = ctx;
- ret = SHA1_Update(sha_ctx, data, size);
- if (!ret)
- free(sha_ctx);
- return ret;
-}
-
-int x_sha1_final(void *ctx, unsigned char result[20])
-{
- int ret;
- SHA_CTX *sha_ctx = ctx;
- ret = SHA1_Final(result, sha_ctx);
- free(sha_ctx);
- return ret;
-}
-
-#endif
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "os.h"
+#include "xsha1.h"
+
+#if defined(HAVE_SHA1_IN_LIBMD) /* Use libmd for SHA1 */ \
+ || defined(HAVE_SHA1_IN_LIBC) /* Use libc for SHA1 */
+
+#include <sha1.h>
+
+void *
+x_sha1_init(void)
+{
+ SHA1_CTX *ctx = malloc(sizeof(*ctx));
+
+ if (!ctx)
+ return NULL;
+ SHA1Init(ctx);
+ return ctx;
+}
+
+int
+x_sha1_update(void *ctx, void *data, int size)
+{
+ SHA1_CTX *sha1_ctx = ctx;
+
+ SHA1Update(sha1_ctx, data, size);
+ return 1;
+}
+
+int
+x_sha1_final(void *ctx, unsigned char result[20])
+{
+ SHA1_CTX *sha1_ctx = ctx;
+
+ SHA1Final(result, sha1_ctx);
+ free(sha1_ctx);
+ return 1;
+}
+
+#elif defined(HAVE_SHA1_IN_COMMONCRYPTO) /* Use CommonCrypto for SHA1 */
+
+#include <CommonCrypto/CommonDigest.h>
+
+void *
+x_sha1_init(void)
+{
+ CC_SHA1_CTX *ctx = malloc(sizeof(*ctx));
+
+ if (!ctx)
+ return NULL;
+ CC_SHA1_Init(ctx);
+ return ctx;
+}
+
+int
+x_sha1_update(void *ctx, void *data, int size)
+{
+ CC_SHA1_CTX *sha1_ctx = ctx;
+
+ CC_SHA1_Update(sha1_ctx, data, size);
+ return 1;
+}
+
+int
+x_sha1_final(void *ctx, unsigned char result[20])
+{
+ CC_SHA1_CTX *sha1_ctx = ctx;
+
+ CC_SHA1_Final(result, sha1_ctx);
+ free(sha1_ctx);
+ return 1;
+}
+
+#elif defined(HAVE_SHA1_IN_LIBGCRYPT) /* Use libgcrypt for SHA1 */
+
+#include <gcrypt.h>
+
+void *
+x_sha1_init(void)
+{
+ static int init;
+ gcry_md_hd_t h;
+ gcry_error_t err;
+
+ if (!init) {
+ if (!gcry_check_version(NULL))
+ return NULL;
+ gcry_control(GCRYCTL_DISABLE_SECMEM, 0);
+ gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
+ init = 1;
+ }
+
+ err = gcry_md_open(&h, GCRY_MD_SHA1, 0);
+ if (err)
+ return NULL;
+ return h;
+}
+
+int
+x_sha1_update(void *ctx, void *data, int size)
+{
+ gcry_md_hd_t h = ctx;
+
+ gcry_md_write(h, data, size);
+ return 1;
+}
+
+int
+x_sha1_final(void *ctx, unsigned char result[20])
+{
+ gcry_md_hd_t h = ctx;
+
+ memcpy(result, gcry_md_read(h, GCRY_MD_SHA1), 20);
+ gcry_md_close(h);
+ return 1;
+}
+
+#elif defined(HAVE_SHA1_IN_LIBSHA1) /* Use libsha1 */
+
+#include <libsha1.h>
+
+void *
+x_sha1_init(void)
+{
+ sha1_ctx *ctx = malloc(sizeof(*ctx));
+
+ if (!ctx)
+ return NULL;
+ sha1_begin(ctx);
+ return ctx;
+}
+
+int
+x_sha1_update(void *ctx, void *data, int size)
+{
+ sha1_hash(data, size, ctx);
+ return 1;
+}
+
+int
+x_sha1_final(void *ctx, unsigned char result[20])
+{
+ sha1_end(result, ctx);
+ free(ctx);
+ return 1;
+}
+
+#else /* Use OpenSSL's libcrypto */
+
+#include <stddef.h> /* buggy openssl/sha.h wants size_t */
+#include <openssl/sha.h>
+
+void *
+x_sha1_init(void)
+{
+ int ret;
+ SHA_CTX *ctx = malloc(sizeof(*ctx));
+
+ if (!ctx)
+ return NULL;
+ ret = SHA1_Init(ctx);
+ if (!ret) {
+ free(ctx);
+ return NULL;
+ }
+ return ctx;
+}
+
+int
+x_sha1_update(void *ctx, void *data, int size)
+{
+ int ret;
+ SHA_CTX *sha_ctx = ctx;
+
+ ret = SHA1_Update(sha_ctx, data, size);
+ if (!ret)
+ free(sha_ctx);
+ return ret;
+}
+
+int
+x_sha1_final(void *ctx, unsigned char result[20])
+{
+ int ret;
+ SHA_CTX *sha_ctx = ctx;
+
+ ret = SHA1_Final(result, sha_ctx);
+ free(sha_ctx);
+ return ret;
+}
+
+#endif
diff --git a/xorg-server/os/xstrans.c b/xorg-server/os/xstrans.c
index 44ff976a9..6348a6511 100644
--- a/xorg-server/os/xstrans.c
+++ b/xorg-server/os/xstrans.c
@@ -5,7 +5,9 @@
#include <X11/Xfuncproto.h>
/* ErrorF is used by xtrans */
-extern _X_EXPORT void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2);
+extern _X_EXPORT void
+ErrorF(const char *f, ...)
+_X_ATTRIBUTE_PRINTF(1, 2);
#define TRANS_REOPEN
#define TRANS_SERVER