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 librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 * (c) Copyright 1993, 1994 Hewlett-Packard Company *
25 * (c) Copyright 1993, 1994 International Business Machines Corp. *
26 * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
27 * (c) Copyright 1993, 1994 Novell, Inc. *
30 * $XConsortium: protodpy.c /main/4 1995/10/27 16:14:24 rswiston $
32 * Copyright 1989 Massachusetts Institute of Technology
34 * Permission to use, copy, modify, distribute, and sell this software and its
35 * documentation for any purpose is hereby granted without fee, provided that
36 * the above copyright notice appear in all copies and that both that
37 * copyright notice and this permission notice appear in supporting
38 * documentation, and that the name of M.I.T. not be used in advertising or
39 * publicity pertaining to distribution of the software without specific,
40 * written prior permission. M.I.T. makes no representations about the
41 * suitability of this software for any purpose. It is provided "as is"
42 * without express or implied warranty.
44 * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
46 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
47 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
48 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
49 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
51 * Author: Keith Packard, MIT X Consortium
57 * manage a collection of proto-displays. These are displays for
58 * which sessionID's have been generated, but no session has been
64 struct protoDisplay *protoDisplays;
67 FindProtoDisplay( struct sockaddr *address, int addrlen,
68 #if NeedWidePrototypes
71 CARD16 displayNumber )
72 #endif /* NeedWidePrototypes */
74 struct protoDisplay *pdpy;
76 for (pdpy = protoDisplays; pdpy; pdpy=pdpy->next)
77 if (pdpy->displayNumber == displayNumber &&
78 addressEqual ((char *)address, addrlen, (char *)pdpy->address, pdpy->addrlen))
82 return (struct protoDisplay *) 0;
86 TimeoutProtoDisplays( long now )
88 struct protoDisplay *pdpy, *next;
90 for (pdpy = protoDisplays; pdpy; pdpy = next)
93 if (pdpy->date < now - PROTO_TIMEOUT)
94 DisposeProtoDisplay (pdpy);
99 NewProtoDisplay( struct sockaddr *address, int addrlen,
100 #if NeedWidePrototypes
104 CARD16 displayNumber,
105 CARD16 connectionType,
106 #endif /* NeedWidePrototypes */
107 ARRAY8Ptr connectionAddress, CARD32 sessionID )
109 struct protoDisplay *pdpy;
113 TimeoutProtoDisplays (date);
114 pdpy = (struct protoDisplay *) malloc (sizeof *pdpy);
117 pdpy->address = (struct sockaddr *) malloc (addrlen);
120 free ((char *) pdpy);
123 pdpy->addrlen = addrlen;
124 bcopy ((char *)address, (char *)pdpy->address, addrlen);
125 pdpy->displayNumber = displayNumber;
126 pdpy->connectionType = connectionType;
128 if (!XdmcpCopyARRAY8 (connectionAddress, &pdpy->connectionAddress))
130 free ((char *) pdpy->address);
131 free ((char *) pdpy);
134 pdpy->sessionID = sessionID;
135 pdpy->fileAuthorization = (Xauth *) NULL;
136 pdpy->xdmcpAuthorization = (Xauth *) NULL;
137 pdpy->next = protoDisplays;
138 protoDisplays = pdpy;
143 DisposeProtoDisplay( struct protoDisplay *pdpy )
145 struct protoDisplay *p, *prev;
148 for (p = protoDisplays; p; p=p->next)
157 prev->next = pdpy->next;
159 protoDisplays = pdpy->next;
160 XdmcpDisposeARRAY8 (&pdpy->connectionAddress);
161 if (pdpy->fileAuthorization)
162 XauDisposeAuth (pdpy->fileAuthorization);
163 if (pdpy->xdmcpAuthorization)
164 XauDisposeAuth (pdpy->xdmcpAuthorization);
165 free ((char *) pdpy->address);
166 free ((char *) pdpy);