3
Copyright 1989, 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 in
12
all copies or substantial portions of the Software.
14
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
Except as contained in this notice, the name of The Open Group shall not be
22
used in advertising or otherwise to promote the sale, use or other dealings
23
in this Software without prior written authorization from The Open Group.
25
* Author: Keith Packard, MIT X Consortium
31
* manage a collection of proto-displays. These are displays for
32
* which sessionID's have been generated, but no session has been
41
# include <sys/types.h>
43
# define Time_t time_t
45
static struct protoDisplay *protoDisplays;
49
PrintProtoDisplay (struct protoDisplay *pdpy)
51
Debug ("ProtoDisplay 0x%x\n", pdpy);
52
Debug ("\taddress: ");
53
PrintSockAddr (pdpy->address, pdpy->addrlen);
54
Debug ("\tdate %d (%d from now)\n", pdpy->date, time(0) - pdpy->date);
55
Debug ("\tdisplay Number %d\n", pdpy->displayNumber);
56
Debug ("\tsessionID %d\n", pdpy->sessionID);
66
struct protoDisplay *pdpy;
68
Debug ("FindProtoDisplay\n");
69
for (pdpy = protoDisplays; pdpy; pdpy=pdpy->next)
71
if (pdpy->displayNumber == displayNumber &&
72
addressEqual (address, addrlen, pdpy->address, pdpy->addrlen))
77
return (struct protoDisplay *) 0;
81
TimeoutProtoDisplays (Time_t now)
83
struct protoDisplay *pdpy, *next;
85
for (pdpy = protoDisplays; pdpy; pdpy = next)
88
if (pdpy->date < now - PROTO_TIMEOUT)
89
DisposeProtoDisplay (pdpy);
98
CARD16 connectionType,
99
ARRAY8Ptr connectionAddress,
102
struct protoDisplay *pdpy;
105
Debug ("NewProtoDisplay\n");
107
TimeoutProtoDisplays (date);
108
pdpy = malloc (sizeof *pdpy);
111
pdpy->address = malloc (addrlen);
117
pdpy->addrlen = addrlen;
118
memmove( pdpy->address, address, addrlen);
119
pdpy->displayNumber = displayNumber;
120
pdpy->connectionType = connectionType;
122
if (!XdmcpCopyARRAY8 (connectionAddress, &pdpy->connectionAddress))
124
free (pdpy->address);
128
pdpy->sessionID = sessionID;
129
pdpy->fileAuthorization = (Xauth *) NULL;
130
pdpy->xdmcpAuthorization = (Xauth *) NULL;
131
pdpy->next = protoDisplays;
132
protoDisplays = pdpy;
137
DisposeProtoDisplay (struct protoDisplay *pdpy)
139
struct protoDisplay *p, *prev;
142
for (p = protoDisplays; p; p=p->next)
151
prev->next = pdpy->next;
153
protoDisplays = pdpy->next;
154
bzero(&pdpy->key, sizeof(pdpy->key));
155
if (pdpy->fileAuthorization)
156
XauDisposeAuth (pdpy->fileAuthorization);
157
if (pdpy->xdmcpAuthorization)
158
XauDisposeAuth (pdpy->xdmcpAuthorization);
159
XdmcpDisposeARRAY8 (&pdpy->connectionAddress);
160
free (pdpy->address);