3
Copyright 1988, 1998 The Open Group
4
Copyright 2000-2005 Oswald Buddenhagen <ossi@kde.org>
6
Permission to use, copy, modify, distribute, and sell this software and its
7
documentation for any purpose is hereby granted without fee, provided that
8
the above copyright notice appear in all copies and that both that
9
copyright notice and this permission notice appear in supporting
12
The above copyright notice and this permission notice shall be included
13
in all copies or substantial portions of the Software.
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21
OTHER DEALINGS IN THE SOFTWARE.
23
Except as contained in this notice, the name of a copyright holder shall
24
not be used in advertising or otherwise to promote the sale, use or
25
other dealings in this Software without prior written authorization
26
from the copyright holder.
31
* xdm - display manager daemon
32
* Author: Keith Packard, MIT X Consortium
34
* a simple linked list of known displays
40
struct display *displays;
41
static struct disphist *disphist;
50
anyRunningDisplays(void)
54
for (d = displays; d; d = d->next)
67
anyReserveDisplays(void)
71
for (d = displays; d; d = d->next)
72
if ((d->displayType & d_lifetime) == dReserve)
78
idleReserveDisplays(void)
83
for (d = displays; d; d = d->next)
84
if (d->status == reserve)
90
startReserveDisplay(void)
92
struct display *d, *rd;
94
for (rd = 0, d = displays; d; d = d->next)
95
if (d->status == reserve)
98
rd->status = notRunning;
105
forEachDisplay(void (*f)(struct display *))
107
struct display *d, *next;
109
for (d = displays; d; d = next) {
117
_forEachDisplayRev(struct display *d, void (*f)(struct display *))
121
_forEachDisplayRev(d->next, f);
127
forEachDisplayRev(void (*f)(struct display *))
129
_forEachDisplayRev(displays, f);
134
findDisplayByName(const char *name)
138
for (d = displays; d; d = d->next)
139
if (!strcmp(name, d->name))
145
findDisplayByPid(int pid)
149
for (d = displays; d; d = d->next)
156
findDisplayByServerPid(int serverPid)
160
for (d = displays; d; d = d->next)
161
if (serverPid == d->serverPid)
169
findDisplayBySessionID(CARD32 sessionID)
173
for (d = displays; d; d = d->next)
174
if (sessionID == d->sessionID)
180
findDisplayByAddress(XdmcpNetaddr addr, int addrlen, CARD16 displayNumber)
184
for (d = displays; d; d = d->next)
185
if ((d->displayType & d_origin) == dFromXDMCP &&
186
d->displayNumber == displayNumber &&
187
addressEqual((XdmcpNetaddr)d->from.data, d->from.length,
196
removeDisplay(struct display *old)
198
struct display *d, **dp;
201
for (dp = &displays; (d = *dp); dp = &(*dp)->next) {
203
debug("Removing display %s\n", d->name);
207
delStr(d->cfg.dep.name);
211
if (d->authorizations) {
212
for (i = 0; i < d->authNum; i++)
213
XauDisposeAuth(d->authorizations[i]);
214
free(d->authorizations);
217
(void)unlink(d->authFile);
220
if (d->greeterAuthFile) {
221
(void)unlink(d->greeterAuthFile);
222
free(d->greeterAuthFile);
225
XdmcpDisposeARRAY8(&d->peer);
226
XdmcpDisposeARRAY8(&d->from);
227
XdmcpDisposeARRAY8(&d->clientAddr);
235
static struct disphist *
236
findHist(const char *name)
238
struct disphist *hstent;
240
for (hstent = disphist; hstent; hstent = hstent->next)
241
if (!strcmp(hstent->name, name))
247
newDisplay(const char *name)
250
struct disphist *hstent;
252
if (!(hstent = findHist(name))) {
253
if (!(hstent = Calloc(1, sizeof(*hstent))))
255
if (!strDup(&hstent->name, name)) {
259
hstent->next = disphist;
263
if (!(d = Calloc(1, sizeof(*d))))
267
d->name = hstent->name;
268
/* initialize fields (others are 0) */
283
debug("created new display %s\n", d->name);
288
displayName(struct display *d)
290
return memcmp(d->name, "localhost:", 10) ? d->name : d->name + 9;