~ubuntu-branches/ubuntu/trusty/xdm/trusty

« back to all changes in this revision

Viewing changes to dpylist.c

  • Committer: Package Import Robot
  • Author(s): Micah Gersten
  • Date: 2011-12-09 03:00:26 UTC
  • mfrom: (9.1.5 sid)
  • Revision ID: package-import@ubuntu.com-20111209030026-baa9vul2hhtujjxh
Tags: 1:1.1.11-1ubuntu1
* Merge from Debian testing.  Remaining changes:
  - debian/{rules, xdm.install, local/ubuntu*}:
    + Add Ubuntu graphics and configure xdm to use them by default.
  - debian/patches/ubuntu_no_whiteglass.diff: Don't hardcode
    the default Xcursor theme to whiteglass. Use the Ubuntu
    default x-cursor-theme instead.

* Drop debian/patches/ftbfs_binutils-gold.diff: Fixed upstream
* Change Vcs-* to XS-Debian-Vcs-*
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 
3
 
Copyright 1988, 1998  The Open Group
4
 
 
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
9
 
documentation.
10
 
 
11
 
The above copyright notice and this permission notice shall be included
12
 
in all copies or substantial portions of the Software.
13
 
 
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 OPEN GROUP 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.
21
 
 
22
 
Except as contained in this notice, the name of The Open Group 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 Open Group.
26
 
 
27
 
*/
28
 
 
29
 
/*
30
 
 * xdm - display manager daemon
31
 
 * Author:  Keith Packard, MIT X Consortium
32
 
 *
33
 
 * a simple linked list of known displays
34
 
 */
35
 
 
36
 
#include "dm.h"
37
 
#include "dm_error.h"
38
 
 
39
 
static struct display   *displays;
40
 
 
41
 
int
42
 
AnyDisplaysLeft (void)
43
 
{
44
 
        return displays != (struct display *) 0;
45
 
}
46
 
 
47
 
void
48
 
ForEachDisplay (void (*f)(struct display *))
49
 
{
50
 
        struct display  *d, *next;
51
 
 
52
 
        for (d = displays; d; d = next) {
53
 
                next = d->next;
54
 
                (*f) (d);
55
 
        }
56
 
}
57
 
 
58
 
struct display *
59
 
FindDisplayByName (char *name)
60
 
{
61
 
        struct display  *d;
62
 
 
63
 
        for (d = displays; d; d = d->next)
64
 
                if (!strcmp (name, d->name))
65
 
                        return d;
66
 
        return NULL;
67
 
}
68
 
 
69
 
struct display *
70
 
FindDisplayByPid (pid_t pid)
71
 
{
72
 
        struct display  *d;
73
 
 
74
 
        for (d = displays; d; d = d->next)
75
 
                if (pid == d->pid)
76
 
                        return d;
77
 
        return NULL;
78
 
}
79
 
 
80
 
struct display *
81
 
FindDisplayByServerPid (pid_t serverPid)
82
 
{
83
 
        struct display  *d;
84
 
 
85
 
        for (d = displays; d; d = d->next)
86
 
                if (serverPid == d->serverPid)
87
 
                        return d;
88
 
        return NULL;
89
 
}
90
 
 
91
 
#ifdef XDMCP
92
 
 
93
 
struct display *
94
 
FindDisplayBySessionID (CARD32 sessionID)
95
 
{
96
 
    struct display      *d;
97
 
 
98
 
    for (d = displays; d; d = d->next)
99
 
        if (sessionID == d->sessionID)
100
 
            return d;
101
 
    return NULL;
102
 
}
103
 
 
104
 
struct display *
105
 
FindDisplayByAddress (XdmcpNetaddr addr, int addrlen, CARD16 displayNumber)
106
 
{
107
 
    struct display  *d;
108
 
 
109
 
    for (d = displays; d; d = d->next)
110
 
        if (d->displayType.origin == FromXDMCP &&
111
 
            d->displayNumber == displayNumber &&
112
 
            addressEqual (d->from, d->fromlen, addr, addrlen))
113
 
        {
114
 
            return d;
115
 
        }
116
 
    return NULL;
117
 
}
118
 
 
119
 
#endif /* XDMCP */
120
 
 
121
 
#define IfFree(x)  if (x) free ((char *) x)
122
 
 
123
 
void
124
 
RemoveDisplay (struct display *old)
125
 
{
126
 
    struct display      *d, *p;
127
 
    char                **x;
128
 
    int                 i;
129
 
 
130
 
    p = NULL;
131
 
    for (d = displays; d; d = d->next) {
132
 
        if (d == old) {
133
 
            if (p)
134
 
                p->next = d->next;
135
 
            else
136
 
                displays = d->next;
137
 
            IfFree (d->name);
138
 
            IfFree (d->class);
139
 
            for (x = d->argv; x && *x; x++)
140
 
                IfFree (*x);
141
 
            IfFree (d->argv);
142
 
            IfFree (d->resources);
143
 
            IfFree (d->xrdb);
144
 
            IfFree (d->setup);
145
 
            IfFree (d->startup);
146
 
            IfFree (d->reset);
147
 
            IfFree (d->session);
148
 
            IfFree (d->userPath);
149
 
            IfFree (d->systemPath);
150
 
            IfFree (d->systemShell);
151
 
            IfFree (d->failsafeClient);
152
 
            IfFree (d->chooser);
153
 
            if (d->authorizations)
154
 
            {
155
 
                for (i = 0; i < d->authNum; i++)
156
 
                    XauDisposeAuth (d->authorizations[i]);
157
 
                free ((char *) d->authorizations);
158
 
            }
159
 
            IfFree (d->clientAuthFile);
160
 
            if (d->authFile)
161
 
                (void) unlink (d->authFile);
162
 
            IfFree (d->authFile);
163
 
            IfFree (d->userAuthDir);
164
 
            for (x = d->authNames; x && *x; x++)
165
 
                IfFree (*x);
166
 
            IfFree (d->authNames);
167
 
            IfFree (d->authNameLens);
168
 
#ifdef XDMCP
169
 
            IfFree (d->peer);
170
 
            IfFree (d->from);
171
 
            XdmcpDisposeARRAY8 (&d->clientAddr);
172
 
#endif
173
 
            IfFree (d->windowPath);
174
 
            free ((char *) d);
175
 
            break;
176
 
        }
177
 
        p = d;
178
 
    }
179
 
}
180
 
 
181
 
struct display *
182
 
NewDisplay (char *name, char *class)
183
 
{
184
 
    struct display      *d;
185
 
 
186
 
    d = (struct display *) calloc (1, sizeof (struct display));
187
 
    if (!d) {
188
 
        LogOutOfMem ("NewDisplay");
189
 
        return NULL;
190
 
    }
191
 
    d->next = displays;
192
 
    d->name = strdup (name);
193
 
    if (!d->name) {
194
 
        LogOutOfMem ("NewDisplay");
195
 
        free ((char *) d);
196
 
        return NULL;
197
 
    }
198
 
    if (class)
199
 
    {
200
 
        d->class = strdup (class);
201
 
        if (!d->class) {
202
 
            LogOutOfMem ("NewDisplay");
203
 
            free (d->name);
204
 
            free ((char *) d);
205
 
            return NULL;
206
 
        }
207
 
    }
208
 
    else
209
 
    {
210
 
        d->class = NULL;
211
 
    }
212
 
    /* initialize every field to avoid possible problems */
213
 
    d->argv = NULL;
214
 
    d->status = notRunning;
215
 
    d->pid = -1;
216
 
    d->serverPid = -1;
217
 
    d->state = NewEntry;
218
 
    d->resources = NULL;
219
 
    d->xrdb = NULL;
220
 
    d->setup = NULL;
221
 
    d->startup = NULL;
222
 
    d->reset = NULL;
223
 
    d->session = NULL;
224
 
    d->userPath = NULL;
225
 
    d->systemPath = NULL;
226
 
    d->systemShell = NULL;
227
 
    d->failsafeClient = NULL;
228
 
    d->chooser = NULL;
229
 
    d->authorize = FALSE;
230
 
    d->authorizations = NULL;
231
 
    d->authNum = 0;
232
 
    d->authNameNum = 0;
233
 
    d->clientAuthFile = NULL;
234
 
    d->authFile = NULL;
235
 
    d->userAuthDir = NULL;
236
 
    d->authNames = NULL;
237
 
    d->authNameLens = NULL;
238
 
    d->authComplain = 1;
239
 
    d->openDelay = 0;
240
 
    d->openRepeat = 0;
241
 
    d->openTimeout = 0;
242
 
    d->startAttempts = 0;
243
 
    d->startTries = 0;
244
 
    d->lastCrash = 0;
245
 
    d->terminateServer = 0;
246
 
    d->grabTimeout = 0;
247
 
#ifdef XDMCP
248
 
    d->sessionID = 0;
249
 
    d->peer = NULL;
250
 
    d->peerlen = 0;
251
 
    d->from = NULL;
252
 
    d->fromlen = 0;
253
 
    d->displayNumber = 0;
254
 
    d->useChooser = 0;
255
 
    d->clientAddr.data = NULL;
256
 
    d->clientAddr.length = 0;
257
 
    d->connectionType = 0;
258
 
    d->xdmcpFd = -1;
259
 
#endif
260
 
    d->version = 1;             /* registered with The Open Group */
261
 
    d->willing = NULL;
262
 
    d->dpy = NULL;
263
 
    d->windowPath = NULL;
264
 
    displays = d;
265
 
    return d;
266
 
}