3 Copyright 1988, 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
12 in all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 OTHER DEALINGS IN THE SOFTWARE.
22 Except as contained in this notice, the name of a copyright holder shall
23 not be used in advertising or otherwise to promote the sale, use or
24 other dealings in this Software without prior written authorization
25 from the copyright holder.
30 * xdm - display manager daemon
31 * Author: Keith Packard, MIT X Consortium
33 * manage a collection of proto-displays. These are displays for
34 * which sessionID's have been generated, but no session has been
41 static struct protoDisplay
*protoDisplays
;
44 findProtoDisplay( XdmcpNetaddr address
,
46 CARD16 displayNumber
)
48 struct protoDisplay
*pdpy
;
50 debug( "findProtoDisplay\n" );
51 for (pdpy
= protoDisplays
; pdpy
; pdpy
=pdpy
->next
) {
52 if (pdpy
->displayNumber
== displayNumber
&&
53 addressEqual( address
, addrlen
, pdpy
->address
, pdpy
->addrlen
))
58 return (struct protoDisplay
*)False
;
62 timeoutProtoDisplays( void )
64 struct protoDisplay
*pdpy
, *next
;
66 for (pdpy
= protoDisplays
; pdpy
; pdpy
= next
) {
68 if (pdpy
->date
< (unsigned long)(now
- PROTO_TIMEOUT
))
69 disposeProtoDisplay( pdpy
);
74 newProtoDisplay( XdmcpNetaddr address
, int addrlen
, CARD16 displayNumber
,
75 CARD16 connectionType
, ARRAY8Ptr connectionAddress
,
78 struct protoDisplay
*pdpy
;
80 debug( "newProtoDisplay\n" );
81 timeoutProtoDisplays();
82 pdpy
= (struct protoDisplay
*)Malloc( sizeof(*pdpy
) );
85 pdpy
->address
= (XdmcpNetaddr
)Malloc( addrlen
);
90 pdpy
->addrlen
= addrlen
;
91 memmove( pdpy
->address
, address
, addrlen
);
92 pdpy
->displayNumber
= displayNumber
;
93 pdpy
->connectionType
= connectionType
;
95 if (!XdmcpCopyARRAY8( connectionAddress
, &pdpy
->connectionAddress
)) {
96 free( (char *)pdpy
->address
);
100 pdpy
->sessionID
= sessionID
;
101 pdpy
->fileAuthorization
= (Xauth
*)NULL
;
102 pdpy
->xdmcpAuthorization
= (Xauth
*)NULL
;
103 pdpy
->next
= protoDisplays
;
104 protoDisplays
= pdpy
;
109 disposeProtoDisplay( struct protoDisplay
*pdpy
)
111 struct protoDisplay
*p
, *prev
;
114 for (p
= protoDisplays
; p
; p
=p
->next
) {
122 prev
->next
= pdpy
->next
;
124 protoDisplays
= pdpy
->next
;
125 bzero( &pdpy
->key
, sizeof(pdpy
->key
) );
126 if (pdpy
->fileAuthorization
)
127 XauDisposeAuth( pdpy
->fileAuthorization
);
128 if (pdpy
->xdmcpAuthorization
)
129 XauDisposeAuth( pdpy
->xdmcpAuthorization
);
130 XdmcpDisposeARRAY8( &pdpy
->connectionAddress
);
131 free( (char *)pdpy
->address
);
132 free( (char *)pdpy
);