2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* (c) Copyright 1997 The Open Group */
25 * (c) Copyright 1993, 1994 Hewlett-Packard Company *
26 * (c) Copyright 1993, 1994 International Business Machines Corp. *
27 * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
28 * (c) Copyright 1993, 1994 Novell, Inc. *
31 * xdm - display manager daemon
33 * $TOG: dpylist.c /main/5 1997/03/14 13:44:46 barstow $
35 * Copyright 1988 Massachusetts Institute of Technology
37 * Permission to use, copy, modify, and distribute this software and its
38 * documentation for any purpose and without fee is hereby granted, provided
39 * that the above copyright notice appear in all copies and that both that
40 * copyright notice and this permission notice appear in supporting
41 * documentation, and that the name of M.I.T. not be used in advertising or
42 * publicity pertaining to distribution of the software without specific,
43 * written prior permission. M.I.T. makes no representations about the
44 * suitability of this software for any purpose. It is provided "as is"
45 * without express or implied warranty.
47 * Author: Keith Packard, MIT X Consortium
51 * a simple linked list of known displays
57 struct display *displays;
61 AnyDisplaysLeft( void )
63 return displays != (struct display *) 0;
67 ForEachDisplay( void (*f)() )
69 struct display *d, *next;
71 for (d = displays; d; d = next) {
78 FindDisplayByName( char *name )
82 for (d = displays; d; d = d->next)
83 if (!strcmp (name, d->name))
89 FindDisplayByPid( int pid )
93 for (d = displays; d; d = d->next)
100 FindDisplayByServerPid( int serverPid )
104 for (d = displays; d; d = d->next)
105 if (serverPid == d->serverPid)
111 FindDisplayBySessionID( CARD32 sessionID )
115 for (d = displays; d; d = d->next)
116 if (sessionID == d->sessionID)
122 FindDisplayByAddress(struct sockaddr *addr, int addrlen,
123 #if NeedWidePrototypes
126 CARD16 displayNumber )
127 #endif /* NeedWidePrototypes */
131 for (d = displays; d; d = d->next)
132 if (d->displayType.origin == FromXDMCP &&
133 d->displayNumber == displayNumber &&
134 addressEqual ((char *)d->from, d->fromlen, (char *)addr, addrlen))
141 #define IfFree(x) if (x) free ((char *) x)
144 RemoveDisplay( struct display *old )
146 struct display *d, *p;
150 extern int wakeupTime;
152 Debug("Removing display %s from display list.\n", old->name);
155 for (d = displays; d; d = d->next) {
163 for (x = d->argv; x && *x; x++)
166 IfFree (d->resources);
173 IfFree (d->userPath);
174 IfFree (d->systemPath);
175 IfFree (d->systemShell);
176 IfFree (d->failsafeClient);
178 if (d->authorizations)
180 for (i = 0; i < d->authNum; i++)
181 XauDisposeAuth (d->authorizations[i]);
182 free ((char *) d->authorizations);
184 IfFree (d->clientAuthFile);
186 (void) unlink (d->authFile);
187 IfFree (d->authFile);
188 IfFree (d->userAuthDir);
189 IfFree (d->authNames);
192 XdmcpDisposeARRAY8(&d->clientAddr);
193 IfFree (d->language);
194 IfFree (d->langList);
196 IfFree (d->gettyLine);
197 IfFree (d->gettySpeed);
198 IfFree (d->environStr);
199 IfFree (d->verifyName);
202 * turn off polling if we are removing a suspended display...
205 if ( d->status == suspended )
217 NewDisplay( char *name, char *class )
221 d = (struct display *) malloc (sizeof (struct display));
223 LogOutOfMem (ReadCatalog(MC_LOG_SET,MC_LOG_NEW_DPY,MC_DEF_LOG_NEW_DPY));
227 d->name = malloc ((unsigned) (strlen (name) + 1));
229 LogOutOfMem (ReadCatalog(MC_LOG_SET,MC_LOG_NEW_DPY,MC_DEF_LOG_NEW_DPY));
233 strcpy (d->name, name);
236 d->class = malloc ((unsigned) (strlen (class) + 1));
239 ReadCatalog(MC_LOG_SET,MC_LOG_NEW_DPY,MC_DEF_LOG_NEW_DPY));
244 strcpy (d->class, class);
248 d->class = (char *) 0;
250 /* initialize every field to avoid possible problems */
252 d->status = notRunning;
264 d->systemPath = NULL;
265 d->systemShell = NULL;
266 d->failsafeClient = NULL;
268 d->authorize = FALSE;
269 d->authorizations = NULL;
272 d->clientAuthFile = NULL;
274 d->userAuthDir = NULL;
276 d->authNameLens = NULL;
280 d->startAttempts = 0;
282 d->terminateServer = 0;
289 d->displayNumber = 0;
291 d->clientAddr.data = NULL;
292 d->clientAddr.length = 0;
297 d->gettySpeed = NULL;
298 d->environStr = NULL;
300 d->verifyName = NULL;
301 d->pmSearchPath = NULL;
302 d->bmSearchPath = NULL;