1 /* (c) Copyright 1997 The Open Group */
3 * (c) Copyright 1993, 1994 Hewlett-Packard Company *
4 * (c) Copyright 1993, 1994 International Business Machines Corp. *
5 * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
6 * (c) Copyright 1993, 1994 Novell, Inc. *
9 * xdm - display manager daemon
11 * $TOG: dpylist.c /main/5 1997/03/14 13:44:46 barstow $
13 * Copyright 1988 Massachusetts Institute of Technology
15 * Permission to use, copy, modify, and distribute this software and its
16 * documentation for any purpose and without fee is hereby granted, provided
17 * that the above copyright notice appear in all copies and that both that
18 * copyright notice and this permission notice appear in supporting
19 * documentation, and that the name of M.I.T. not be used in advertising or
20 * publicity pertaining to distribution of the software without specific,
21 * written prior permission. M.I.T. makes no representations about the
22 * suitability of this software for any purpose. It is provided "as is"
23 * without express or implied warranty.
25 * Author: Keith Packard, MIT X Consortium
29 * a simple linked list of known displays
35 struct display *displays;
39 AnyDisplaysLeft( void )
41 return displays != (struct display *) 0;
45 ForEachDisplay( void (*f)() )
47 struct display *d, *next;
49 for (d = displays; d; d = next) {
56 FindDisplayByName( char *name )
60 for (d = displays; d; d = d->next)
61 if (!strcmp (name, d->name))
67 FindDisplayByPid( int pid )
71 for (d = displays; d; d = d->next)
78 FindDisplayByServerPid( int serverPid )
82 for (d = displays; d; d = d->next)
83 if (serverPid == d->serverPid)
89 FindDisplayBySessionID( CARD32 sessionID )
93 for (d = displays; d; d = d->next)
94 if (sessionID == d->sessionID)
100 FindDisplayByAddress(struct sockaddr *addr, int addrlen,
101 #if NeedWidePrototypes
104 CARD16 displayNumber )
105 #endif /* NeedWidePrototypes */
109 for (d = displays; d; d = d->next)
110 if (d->displayType.origin == FromXDMCP &&
111 d->displayNumber == displayNumber &&
112 addressEqual ((char *)d->from, d->fromlen, (char *)addr, addrlen))
119 #define IfFree(x) if (x) free ((char *) x)
122 RemoveDisplay( struct display *old )
124 struct display *d, *p;
128 extern int wakeupTime;
130 Debug("Removing display %s from display list.\n", old->name);
133 for (d = displays; d; d = d->next) {
141 for (x = d->argv; x && *x; x++)
144 IfFree (d->resources);
151 IfFree (d->userPath);
152 IfFree (d->systemPath);
153 IfFree (d->systemShell);
154 IfFree (d->failsafeClient);
156 if (d->authorizations)
158 for (i = 0; i < d->authNum; i++)
159 XauDisposeAuth (d->authorizations[i]);
160 free ((char *) d->authorizations);
162 IfFree (d->clientAuthFile);
164 (void) unlink (d->authFile);
165 IfFree (d->authFile);
166 IfFree (d->userAuthDir);
167 IfFree (d->authNames);
170 XdmcpDisposeARRAY8(&d->clientAddr);
171 IfFree (d->language);
172 IfFree (d->langList);
174 IfFree (d->gettyLine);
175 IfFree (d->gettySpeed);
176 IfFree (d->environStr);
177 IfFree (d->verifyName);
180 * turn off polling if we are removing a suspended display...
183 if ( d->status == suspended )
195 NewDisplay( char *name, char *class )
199 d = (struct display *) malloc (sizeof (struct display));
201 LogOutOfMem (ReadCatalog(MC_LOG_SET,MC_LOG_NEW_DPY,MC_DEF_LOG_NEW_DPY));
205 d->name = malloc ((unsigned) (strlen (name) + 1));
207 LogOutOfMem (ReadCatalog(MC_LOG_SET,MC_LOG_NEW_DPY,MC_DEF_LOG_NEW_DPY));
211 strcpy (d->name, name);
214 d->class = malloc ((unsigned) (strlen (class) + 1));
217 ReadCatalog(MC_LOG_SET,MC_LOG_NEW_DPY,MC_DEF_LOG_NEW_DPY));
222 strcpy (d->class, class);
226 d->class = (char *) 0;
228 /* initialize every field to avoid possible problems */
230 d->status = notRunning;
242 d->systemPath = NULL;
243 d->systemShell = NULL;
244 d->failsafeClient = NULL;
246 d->authorize = FALSE;
247 d->authorizations = NULL;
250 d->clientAuthFile = NULL;
252 d->userAuthDir = NULL;
254 d->authNameLens = NULL;
258 d->startAttempts = 0;
260 d->terminateServer = 0;
267 d->displayNumber = 0;
269 d->clientAddr.data = NULL;
270 d->clientAddr.length = 0;
275 d->gettySpeed = NULL;
276 d->environStr = NULL;
278 d->verifyName = NULL;
279 d->pmSearchPath = NULL;
280 d->bmSearchPath = NULL;