3
Copyright 1988, 1998 The Open Group
5
Permission to use, copy, modify, distribute, and sell this software and its
6
documentation for any purpose is hereby granted without fee, provided that
7
the above copyright notice appear in all copies and that both that
8
copyright notice and this permission notice appear in supporting
11
The above copyright notice and this permission notice shall be included
12
in all copies or substantial portions of the Software.
14
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
18
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20
OTHER DEALINGS IN THE SOFTWARE.
22
Except as contained in this notice, the name of The Open Group shall
23
not be used in advertising or otherwise to promote the sale, use or
24
other dealings in this Software without prior written authorization
30
* xdm - display manager daemon
31
* Author: Keith Packard, MIT X Consortium
33
* a simple linked list of known displays
39
static struct display *displays;
42
AnyDisplaysLeft (void)
44
return displays != (struct display *) 0;
48
ForEachDisplay (void (*f)(struct display *))
50
struct display *d, *next;
52
for (d = displays; d; d = next) {
59
FindDisplayByName (char *name)
63
for (d = displays; d; d = d->next)
64
if (!strcmp (name, d->name))
70
FindDisplayByPid (pid_t pid)
74
for (d = displays; d; d = d->next)
81
FindDisplayByServerPid (pid_t serverPid)
85
for (d = displays; d; d = d->next)
86
if (serverPid == d->serverPid)
94
FindDisplayBySessionID (CARD32 sessionID)
98
for (d = displays; d; d = d->next)
99
if (sessionID == d->sessionID)
105
FindDisplayByAddress (XdmcpNetaddr addr, int addrlen, CARD16 displayNumber)
109
for (d = displays; d; d = d->next)
110
if (d->displayType.origin == FromXDMCP &&
111
d->displayNumber == displayNumber &&
112
addressEqual (d->from, d->fromlen, addr, addrlen))
121
#define IfFree(x) if (x) free ((char *) x)
124
RemoveDisplay (struct display *old)
126
struct display *d, *p;
131
for (d = displays; d; d = d->next) {
139
for (x = d->argv; x && *x; x++)
142
IfFree (d->resources);
148
IfFree (d->userPath);
149
IfFree (d->systemPath);
150
IfFree (d->systemShell);
151
IfFree (d->failsafeClient);
153
if (d->authorizations)
155
for (i = 0; i < d->authNum; i++)
156
XauDisposeAuth (d->authorizations[i]);
157
free ((char *) d->authorizations);
159
IfFree (d->clientAuthFile);
161
(void) unlink (d->authFile);
162
IfFree (d->authFile);
163
IfFree (d->userAuthDir);
164
for (x = d->authNames; x && *x; x++)
166
IfFree (d->authNames);
167
IfFree (d->authNameLens);
171
XdmcpDisposeARRAY8 (&d->clientAddr);
173
IfFree (d->windowPath);
182
NewDisplay (char *name, char *class)
186
d = (struct display *) calloc (1, sizeof (struct display));
188
LogOutOfMem ("NewDisplay");
192
d->name = strdup (name);
194
LogOutOfMem ("NewDisplay");
200
d->class = strdup (class);
202
LogOutOfMem ("NewDisplay");
212
/* initialize every field to avoid possible problems */
214
d->status = notRunning;
225
d->systemPath = NULL;
226
d->systemShell = NULL;
227
d->failsafeClient = NULL;
229
d->authorize = FALSE;
230
d->authorizations = NULL;
233
d->clientAuthFile = NULL;
235
d->userAuthDir = NULL;
237
d->authNameLens = NULL;
242
d->startAttempts = 0;
245
d->terminateServer = 0;
253
d->displayNumber = 0;
255
d->clientAddr.data = NULL;
256
d->clientAddr.length = 0;
257
d->connectionType = 0;
260
d->version = 1; /* registered with The Open Group */
263
d->windowPath = NULL;