Bug Summary

File:hw/xfree86/common/xf86Config.c
Location:line 1325, column 50
Description:Access to field 'options' results in a dereference of a null pointer (loaded from variable 'Keyboard')

Annotated Source Code

1/*
2 * Loosely based on code bearing the following copyright:
3 *
4 * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
5 */
6
7/*
8 * Copyright 1992-2003 by The XFree86 Project, Inc.
9 * Copyright 1997 by Metro Link, Inc.
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 * and/or sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
25 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * OTHER DEALINGS IN THE SOFTWARE.
28 *
29 * Except as contained in this notice, the name of the copyright holder(s)
30 * and author(s) shall not be used in advertising or otherwise to promote
31 * the sale, use or other dealings in this Software without prior written
32 * authorization from the copyright holder(s) and author(s).
33 */
34
35/*
36 *
37 * Authors:
38 * Dirk Hohndel <hohndel@XFree86.Org>
39 * David Dawes <dawes@XFree86.Org>
40 * Marc La France <tsi@XFree86.Org>
41 * Egbert Eich <eich@XFree86.Org>
42 * ... and others
43 */
44
45#ifdef HAVE_XORG_CONFIG_H1
46#include <xorg-config.h>
47#endif
48
49#ifdef XF86DRI
50#include <sys/types.h>
51#include <grp.h>
52#endif
53
54#include "xf86.h"
55#include "xf86Modes.h"
56#include "xf86Parser.h"
57#include "xf86tokens.h"
58#include "xf86Config.h"
59#include "xf86Priv.h"
60#include "xf86_OSlib.h"
61#include "configProcs.h"
62#include "globals.h"
63#include "extension.h"
64#include "xf86pciBus.h"
65
66#include "xf86Xinput.h"
67
68#include "xkbsrv.h"
69
70#include "picture.h"
71
72/*
73 * These paths define the way the config file search is done. The escape
74 * sequences are documented in parser/scan.c.
75 */
76#ifndef ALL_CONFIGPATH"%A," "%R," "/etc/X11/%R," "%P/etc/X11/%R," "%E," "%F," "/etc/X11/%F,"
"%P/etc/X11/%F," "/etc/X11/%X," "/etc/%X," "%P/etc/X11/%X.%H,"
"%P/etc/X11/%X," "%P/lib/X11/%X.%H," "%P/lib/X11/%X"
77#define ALL_CONFIGPATH"%A," "%R," "/etc/X11/%R," "%P/etc/X11/%R," "%E," "%F," "/etc/X11/%F,"
"%P/etc/X11/%F," "/etc/X11/%X," "/etc/%X," "%P/etc/X11/%X.%H,"
"%P/etc/X11/%X," "%P/lib/X11/%X.%H," "%P/lib/X11/%X"
"%A," "%R," \
78 "/etc/X11/%R," "%P/etc/X11/%R," \
79 "%E," "%F," \
80 "/etc/X11/%F," "%P/etc/X11/%F," \
81 "/etc/X11/%X," "/etc/%X," \
82 "%P/etc/X11/%X.%H," \
83 "%P/etc/X11/%X," \
84 "%P/lib/X11/%X.%H," \
85 "%P/lib/X11/%X"
86#endif
87#ifndef RESTRICTED_CONFIGPATH"/etc/X11/%S," "%P/etc/X11/%S," "/etc/X11/%G," "%P/etc/X11/%G,"
"/etc/X11/%X," "/etc/%X," "%P/etc/X11/%X.%H," "%P/etc/X11/%X,"
"%P/lib/X11/%X.%H," "%P/lib/X11/%X"
88#define RESTRICTED_CONFIGPATH"/etc/X11/%S," "%P/etc/X11/%S," "/etc/X11/%G," "%P/etc/X11/%G,"
"/etc/X11/%X," "/etc/%X," "%P/etc/X11/%X.%H," "%P/etc/X11/%X,"
"%P/lib/X11/%X.%H," "%P/lib/X11/%X"
"/etc/X11/%S," "%P/etc/X11/%S," \
89 "/etc/X11/%G," "%P/etc/X11/%G," \
90 "/etc/X11/%X," "/etc/%X," \
91 "%P/etc/X11/%X.%H," \
92 "%P/etc/X11/%X," \
93 "%P/lib/X11/%X.%H," \
94 "%P/lib/X11/%X"
95#endif
96#ifndef ALL_CONFIGDIRPATH"%A," "%R," "/etc/X11/%R," "%C/X11/%R," "/etc/X11/%X," "%C/X11/%X"
97#define ALL_CONFIGDIRPATH"%A," "%R," "/etc/X11/%R," "%C/X11/%R," "/etc/X11/%X," "%C/X11/%X" "%A," "%R," \
98 "/etc/X11/%R," "%C/X11/%R," \
99 "/etc/X11/%X," "%C/X11/%X"
100#endif
101#ifndef RESTRICTED_CONFIGDIRPATH"/etc/X11/%R," "%C/X11/%R," "/etc/X11/%X," "%C/X11/%X"
102#define RESTRICTED_CONFIGDIRPATH"/etc/X11/%R," "%C/X11/%R," "/etc/X11/%X," "%C/X11/%X" "/etc/X11/%R," "%C/X11/%R," \
103 "/etc/X11/%X," "%C/X11/%X"
104#endif
105#ifndef SYS_CONFIGDIRPATH"%D/X11/%X"
106#define SYS_CONFIGDIRPATH"%D/X11/%X" "%D/X11/%X"
107#endif
108#ifndef PROJECTROOT"/Users/jeremy/src/freedesktop/jhbuild/build"
109#define PROJECTROOT"/Users/jeremy/src/freedesktop/jhbuild/build" "/usr/X11R6"
110#endif
111
112static ModuleDefault ModuleDefaults[] = {
113#ifdef GLXEXT1
114 {.name = "glx",.toLoad = TRUE1,.load_opt = NULL((void*)0)},
115#endif
116#ifdef __CYGWIN__
117 /* load DIX modules used by drivers first */
118 {.name = "fb",.toLoad = TRUE1,.load_opt = NULL((void*)0)},
119 {.name = "shadow",.toLoad = TRUE1,.load_opt = NULL((void*)0)},
120#endif
121 {.name = NULL((void*)0),.toLoad = FALSE0,.load_opt = NULL((void*)0)}
122};
123
124/* Forward declarations */
125static Bool configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen,
126 int scrnum, MessageType from);
127static Bool configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor);
128static Bool configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device,
129 Bool active);
130static Bool configInput(InputInfoPtr pInfo, XF86ConfInputPtr conf_input,
131 MessageType from);
132static Bool configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display);
133static Bool addDefaultModes(MonPtr monitorp);
134
135#ifdef XF86DRI
136static void configDRI(XF86ConfDRIPtr drip);
137#endif
138static void configExtensions(XF86ConfExtensionsPtr conf_ext);
139
140/*
141 * xf86GetPathElem --
142 * Extract a single element from the font path string starting at
143 * pnt. The font path element will be returned, and pnt will be
144 * updated to point to the start of the next element, or set to
145 * NULL if there are no more.
146 */
147static char *
148xf86GetPathElem(char **pnt)
149{
150 char *p1;
151
152 p1 = *pnt;
153 *pnt = index(*pnt, ',');
154 if (*pnt != NULL((void*)0)) {
155 **pnt = '\0';
156 *pnt += 1;
157 }
158 return p1;
159}
160
161/*
162 * xf86ValidateFontPath --
163 * Validates the user-specified font path. Each element that
164 * begins with a '/' is checked to make sure the directory exists.
165 * If the directory exists, the existence of a file named 'fonts.dir'
166 * is checked. If either check fails, an error is printed and the
167 * element is removed from the font path.
168 */
169
170#define DIR_FILE"/fonts.dir" "/fonts.dir"
171static char *
172xf86ValidateFontPath(char *path)
173{
174 char *next, *tmp_path, *out_pnt, *path_elem, *p1, *dir_elem;
175 struct stat stat_buf;
176 int flag;
177 int dirlen;
178
179 tmp_path = calloc(1, strlen(path) + 1);
180 out_pnt = tmp_path;
181 path_elem = NULL((void*)0);
182 next = path;
183 while (next != NULL((void*)0)) {
184 path_elem = xf86GetPathElem(&next);
185 if (*path_elem == '/') {
186 dir_elem = xnfcalloc(1, strlen(path_elem) + 1)XNFcalloc((unsigned long)(1)*(unsigned long)(strlen(path_elem
) + 1))
;
187 if ((p1 = strchr(path_elem, ':')) != 0)
188 dirlen = p1 - path_elem;
189 else
190 dirlen = strlen(path_elem);
191 strlcpy(dir_elem, path_elem, dirlen + 1)__builtin___strlcpy_chk (dir_elem, path_elem, dirlen + 1, __builtin_object_size
(dir_elem, 2 > 1 ? 1 : 0))
;
192 flag = stat(dir_elem, &stat_buf);
193 if (flag == 0)
194 if (!S_ISDIR(stat_buf.st_mode)(((stat_buf.st_mode) & 0170000) == 0040000))
195 flag = -1;
196 if (flag != 0) {
197 xf86Msg(X_WARNING, "The directory \"%s\" does not exist.\n",
198 dir_elem);
199 xf86ErrorF("\tEntry deleted from font path.\n");
200 free(dir_elem);
201 continue;
202 }
203 else {
204 XNFasprintf(&p1, "%s%s", dir_elem, DIR_FILE"/fonts.dir");
205 flag = stat(p1, &stat_buf);
206 if (flag == 0)
207 if (!S_ISREG(stat_buf.st_mode)(((stat_buf.st_mode) & 0170000) == 0100000))
208 flag = -1;
209 free(p1);
210 if (flag != 0) {
211 xf86Msg(X_WARNING,
212 "`fonts.dir' not found (or not valid) in \"%s\".\n",
213 dir_elem);
214 xf86ErrorF("\tEntry deleted from font path.\n");
215 xf86ErrorF("\t(Run 'mkfontdir' on \"%s\").\n", dir_elem);
216 free(dir_elem);
217 continue;
218 }
219 }
220 free(dir_elem);
221 }
222
223 /*
224 * Either an OK directory, or a font server name. So add it to
225 * the path.
226 */
227 if (out_pnt != tmp_path)
228 *out_pnt++ = ',';
229 strcat(out_pnt, path_elem)__builtin___strcat_chk (out_pnt, path_elem, __builtin_object_size
(out_pnt, 2 > 1 ? 1 : 0))
;
230 out_pnt += strlen(path_elem);
231 }
232 return tmp_path;
233}
234
235#define FIND_SUITABLE(pointertype, listhead, ptr)do { pointertype _l, _p; for (_l = (listhead), _p = ((void*)0
); !_p && _l; _l = (pointertype)_l->list.next) { if
(!_l->match_seat || (SeatId && xf86nameCompare(_l
->match_seat, SeatId) == 0)) _p = _l; } (ptr) = _p; } while
(0)
\
236 do { \
237 pointertype _l, _p; \
238 \
239 for (_l = (listhead), _p = NULL((void*)0); !_p && _l; _l = (pointertype)_l->list.next) { \
240 if (!_l->match_seat || (SeatId && xf86nameCompare(_l->match_seat, SeatId) == 0)) \
241 _p = _l; \
242 } \
243 \
244 (ptr) = _p; \
245 } while(0)
246
247/*
248 * use the datastructure that the parser provides and pick out the parts
249 * that we need at this point
250 */
251const char **
252xf86ModulelistFromConfig(void ***optlist)
253{
254 int count = 0, i = 0;
255 const char **modulearray;
256
257 const char *ignore[] = { "GLcore", "speedo", "bitmap", "drm",
258 "freetype", "type1",
259 NULL((void*)0)
260 };
261 void **optarray;
262 XF86LoadPtr modp;
263 Bool found;
264
265 /*
266 * make sure the config file has been parsed and that we have a
267 * ModulePath set; if no ModulePath was given, use the default
268 * ModulePath
269 */
270 if (xf86configptr == NULL((void*)0)) {
271 xf86Msg(X_ERROR, "Cannot access global config data structure\n");
272 return NULL((void*)0);
273 }
274
275 if (xf86configptr->conf_modules) {
276 /* Walk the disable list and let people know what we've parsed to
277 * not be loaded
278 */
279 modp = xf86configptr->conf_modules->mod_disable_lst;
280 while (modp) {
281 xf86Msg(X_WARNING,
282 "\"%s\" will not be loaded unless you've specified it to be loaded elsewhere.\n",
283 modp->load_name);
284 modp = (XF86LoadPtr) modp->list.next;
285 }
286 /*
287 * Walk the default settings table. For each module listed to be
288 * loaded, make sure it's in the mod_load_lst. If it's not, make
289 * sure it's not in the mod_no_load_lst. If it's not disabled,
290 * append it to mod_load_lst
291 */
292 for (i = 0; ModuleDefaults[i].name != NULL((void*)0); i++) {
293 if (ModuleDefaults[i].toLoad == FALSE0) {
294 xf86Msg(X_WARNING,
295 "\"%s\" is not to be loaded by default. Skipping.\n",
296 ModuleDefaults[i].name);
297 continue;
298 }
299 found = FALSE0;
300 modp = xf86configptr->conf_modules->mod_load_lst;
301 while (modp) {
302 if (strcmp(modp->load_name, ModuleDefaults[i].name) == 0) {
303 xf86Msg(X_INFO,
304 "\"%s\" will be loaded. This was enabled by default and also specified in the config file.\n",
305 ModuleDefaults[i].name);
306 found = TRUE1;
307 break;
308 }
309 modp = (XF86LoadPtr) modp->list.next;
310 }
311 if (found == FALSE0) {
312 modp = xf86configptr->conf_modules->mod_disable_lst;
313 while (modp) {
314 if (strcmp(modp->load_name, ModuleDefaults[i].name) == 0) {
315 xf86Msg(X_INFO,
316 "\"%s\" will be loaded even though the default is to disable it.\n",
317 ModuleDefaults[i].name);
318 found = TRUE1;
319 break;
320 }
321 modp = (XF86LoadPtr) modp->list.next;
322 }
323 }
324 if (found == FALSE0) {
325 XF86LoadPtr ptr = (XF86LoadPtr) xf86configptr->conf_modules;
326
327 xf86addNewLoadDirective(ptr, ModuleDefaults[i].name,
328 XF86_LOAD_MODULE0,
329 ModuleDefaults[i].load_opt);
330 xf86Msg(X_INFO, "\"%s\" will be loaded by default.\n",
331 ModuleDefaults[i].name);
332 }
333 }
334 }
335 else {
336 xf86configptr->conf_modules = xnfcalloc(1, sizeof(XF86ConfModuleRec))XNFcalloc((unsigned long)(1)*(unsigned long)(sizeof(XF86ConfModuleRec
)))
;
337 for (i = 0; ModuleDefaults[i].name != NULL((void*)0); i++) {
338 if (ModuleDefaults[i].toLoad == TRUE1) {
339 XF86LoadPtr ptr = (XF86LoadPtr) xf86configptr->conf_modules;
340
341 xf86addNewLoadDirective(ptr, ModuleDefaults[i].name,
342 XF86_LOAD_MODULE0,
343 ModuleDefaults[i].load_opt);
344 }
345 }
346 }
347
348 /*
349 * Walk the list of modules in the "Module" section to determine how
350 * many we have.
351 */
352 modp = xf86configptr->conf_modules->mod_load_lst;
353 while (modp) {
354 for (i = 0; ignore[i]; i++) {
355 if (strcmp(modp->load_name, ignore[i]) == 0)
356 modp->ignore = 1;
357 }
358 if (!modp->ignore)
359 count++;
360 modp = (XF86LoadPtr) modp->list.next;
361 }
362
363 /*
364 * allocate the memory and walk the list again to fill in the pointers
365 */
366 modulearray = xnfalloc((count + 1) * sizeof(char *))XNFalloc((unsigned long)((count + 1) * sizeof(char *)));
367 optarray = xnfalloc((count + 1) * sizeof(void *))XNFalloc((unsigned long)((count + 1) * sizeof(void *)));
368 count = 0;
369 if (xf86configptr->conf_modules) {
370 modp = xf86configptr->conf_modules->mod_load_lst;
371 while (modp) {
372 if (!modp->ignore) {
373 modulearray[count] = modp->load_name;
374 optarray[count] = modp->load_opt;
375 count++;
376 }
377 modp = (XF86LoadPtr) modp->list.next;
378 }
379 }
380 modulearray[count] = NULL((void*)0);
381 optarray[count] = NULL((void*)0);
382 if (optlist)
383 *optlist = optarray;
384 else
385 free(optarray);
386 return modulearray;
387}
388
389const char **
390xf86DriverlistFromConfig(void)
391{
392 int count = 0;
393 int j;
394 const char **modulearray;
395 screenLayoutPtr slp;
396
397 /*
398 * make sure the config file has been parsed and that we have a
399 * ModulePath set; if no ModulePath was given, use the default
400 * ModulePath
401 */
402 if (xf86configptr == NULL((void*)0)) {
403 xf86Msg(X_ERROR, "Cannot access global config data structure\n");
404 return NULL((void*)0);
405 }
406
407 /*
408 * Walk the list of driver lines in active "Device" sections to
409 * determine now many implicitly loaded modules there are.
410 *
411 */
412 if (xf86ConfigLayout.screens) {
413 slp = xf86ConfigLayout.screens;
414 while ((slp++)->screen) {
415 count++;
416 }
417 }
418
419 /*
420 * Handle the set of inactive "Device" sections.
421 */
422 j = 0;
423 while (xf86ConfigLayout.inactives[j++].identifier)
424 count++;
425
426 if (count == 0)
427 return NULL((void*)0);
428
429 /*
430 * allocate the memory and walk the list again to fill in the pointers
431 */
432 modulearray = xnfalloc((count + 1) * sizeof(char *))XNFalloc((unsigned long)((count + 1) * sizeof(char *)));
433 count = 0;
434 slp = xf86ConfigLayout.screens;
435 while (slp->screen) {
436 modulearray[count] = slp->screen->device->driver;
437 count++;
438 slp++;
439 }
440
441 j = 0;
442
443 while (xf86ConfigLayout.inactives[j].identifier)
444 modulearray[count++] = xf86ConfigLayout.inactives[j++].driver;
445
446 modulearray[count] = NULL((void*)0);
447
448 /* Remove duplicates */
449 for (count = 0; modulearray[count] != NULL((void*)0); count++) {
450 int i;
451
452 for (i = 0; i < count; i++)
453 if (xf86NameCmp(modulearray[i], modulearray[count]) == 0) {
454 modulearray[count] = "";
455 break;
456 }
457 }
458 return modulearray;
459}
460
461const char **
462xf86InputDriverlistFromConfig(void)
463{
464 int count = 0;
465 const char **modulearray;
466 InputInfoPtr *idp;
467
468 /*
469 * make sure the config file has been parsed and that we have a
470 * ModulePath set; if no ModulePath was given, use the default
471 * ModulePath
472 */
473 if (xf86configptr == NULL((void*)0)) {
474 xf86Msg(X_ERROR, "Cannot access global config data structure\n");
475 return NULL((void*)0);
476 }
477
478 /*
479 * Walk the list of driver lines in active "InputDevice" sections to
480 * determine now many implicitly loaded modules there are.
481 */
482 if (xf86ConfigLayout.inputs) {
483 idp = xf86ConfigLayout.inputs;
484 while (*idp) {
485 count++;
486 idp++;
487 }
488 }
489
490 if (count == 0)
491 return NULL((void*)0);
492
493 /*
494 * allocate the memory and walk the list again to fill in the pointers
495 */
496 modulearray = xnfalloc((count + 1) * sizeof(char *))XNFalloc((unsigned long)((count + 1) * sizeof(char *)));
497 count = 0;
498 idp = xf86ConfigLayout.inputs;
499 while (idp && *idp) {
500 modulearray[count] = (*idp)->driver;
501 count++;
502 idp++;
503 }
504 modulearray[count] = NULL((void*)0);
505
506 /* Remove duplicates */
507 for (count = 0; modulearray[count] != NULL((void*)0); count++) {
508 int i;
509
510 for (i = 0; i < count; i++)
511 if (xf86NameCmp(modulearray[i], modulearray[count]) == 0) {
512 modulearray[count] = "";
513 break;
514 }
515 }
516 return modulearray;
517}
518
519static void
520fixup_video_driver_list(const char **drivers)
521{
522 static const char *fallback[5] = { "modesetting", "fbdev", "vesa", "wsfb", NULL((void*)0) };
523 const char **end, **drv;
524 const char *x;
525 int i;
526
527 /* walk to the end of the list */
528 for (end = drivers; *end && **end; end++);
529 end--;
530
531 /*
532 * for each of the fallback drivers, if we find it in the list,
533 * swap it with the last available non-fallback driver.
534 */
535 for (i = 0; fallback[i]; i++) {
536 for (drv = drivers; drv != end; drv++) {
537 if (strstr(*drv, fallback[i])) {
538 x = *drv;
539 *drv = *end;
540 *end = x;
541 end--;
542 break;
543 }
544 }
545 }
546}
547
548static const char **
549GenerateDriverlist(const char *dirname)
550{
551 const char **ret;
552 const char *subdirs[] = { dirname, NULL((void*)0) };
553 static const char *patlist[] = { "(.*)_drv\\.so", NULL((void*)0) };
554 ret = LoaderListDirs(subdirs, patlist);
555
556 /* fix up the probe order for video drivers */
557 if (strstr(dirname, "drivers") && ret != NULL((void*)0))
558 fixup_video_driver_list(ret);
559
560 return ret;
561}
562
563const char **
564xf86DriverlistFromCompile(void)
565{
566 static const char **driverlist = NULL((void*)0);
567
568 if (!driverlist)
569 driverlist = GenerateDriverlist("drivers");
570
571 return driverlist;
572}
573
574static void
575configFiles(XF86ConfFilesPtr fileconf)
576{
577 MessageType pathFrom;
578 Bool must_copy;
579 int size, countDirs;
580 char *temp_path, *log_buf, *start, *end;
581
582 /* FontPath */
583 must_copy = TRUE1;
584
585 temp_path = defaultFontPath ? (char *) defaultFontPath : (char *) "";
586 if (xf86fpFlag)
587 pathFrom = X_CMDLINE;
588 else if (fileconf && fileconf->file_fontpath) {
589 pathFrom = X_CONFIG;
590 if (xf86Info.useDefaultFontPath) {
591 char *new_font_path;
592 if (asprintf(&new_font_path, "%s%s%s", fileconf->file_fontpath,
593 *temp_path ? "," : "", temp_path) == -1)
594 new_font_path = NULL((void*)0);
595 else
596 must_copy = FALSE0;
597 defaultFontPath = new_font_path;
598 }
599 else
600 defaultFontPath = fileconf->file_fontpath;
601 }
602 else
603 pathFrom = X_DEFAULT;
604 temp_path = defaultFontPath ? (char *) defaultFontPath : (char *) "";
605
606 /* xf86ValidateFontPath modifies its argument, but returns a copy of it. */
607 temp_path = must_copy ? xnfstrdup(defaultFontPath)XNFstrdup(defaultFontPath) : (char *) defaultFontPath;
608 defaultFontPath = xf86ValidateFontPath(temp_path);
609 free(temp_path);
610
611 /* make fontpath more readable in the logfiles */
612 countDirs = 1;
613 temp_path = (char *) defaultFontPath;
614 while ((temp_path = index(temp_path, ',')) != NULL((void*)0)) {
615 countDirs++;
616 temp_path++;
617 }
618
619 log_buf = xnfalloc(strlen(defaultFontPath) + (2 * countDirs) + 1)XNFalloc((unsigned long)(strlen(defaultFontPath) + (2 * countDirs
) + 1))
;
620 temp_path = log_buf;
621 start = (char *) defaultFontPath;
622 while ((end = index(start, ',')) != NULL((void*)0)) {
623 size = (end - start) + 1;
624 *(temp_path++) = '\t';
625 strncpy(temp_path, start, size)__builtin___strncpy_chk (temp_path, start, size, __builtin_object_size
(temp_path, 2 > 1 ? 1 : 0))
;
626 temp_path += size;
627 *(temp_path++) = '\n';
628 start += size;
629 }
630 /* copy last entry */
631 *(temp_path++) = '\t';
632 strcpy(temp_path, start)__builtin___strcpy_chk (temp_path, start, __builtin_object_size
(temp_path, 2 > 1 ? 1 : 0))
;
633 xf86Msg(pathFrom, "FontPath set to:\n%s\n", log_buf);
634 free(log_buf);
635
636 /* ModulePath */
637
638 if (fileconf) {
639 if (xf86ModPathFrom != X_CMDLINE && fileconf->file_modulepath) {
640 xf86ModulePath = fileconf->file_modulepath;
641 xf86ModPathFrom = X_CONFIG;
642 }
643 }
644
645 xf86Msg(xf86ModPathFrom, "ModulePath set to \"%s\"\n", xf86ModulePath);
646
647 if (!xf86xkbdirFlag && fileconf && fileconf->file_xkbdir) {
648 XkbBaseDirectory = fileconf->file_xkbdir;
649 xf86Msg(X_CONFIG, "XKB base directory set to \"%s\"\n",
650 XkbBaseDirectory);
651 }
652#if 0
653 /* LogFile */
654 /*
655 * XXX The problem with this is that the log file is already open.
656 * One option might be to copy the exiting contents to the new location.
657 * and re-open it. The down side is that the default location would
658 * already have been overwritten. Another option would be to start with
659 * unique temporary location, then copy it once the correct name is known.
660 * A problem with this is what happens if the server exits before that
661 * happens.
662 */
663 if (xf86LogFileFrom == X_DEFAULT && fileconf->file_logfile) {
664 xf86LogFile = fileconf->file_logfile;
665 xf86LogFileFrom = X_CONFIG;
666 }
667#endif
668
669 return;
670}
671
672typedef enum {
673 FLAG_NOTRAPSIGNALS,
674 FLAG_DONTVTSWITCH,
675 FLAG_DONTZAP,
676 FLAG_DONTZOOM,
677 FLAG_DISABLEVIDMODE,
678 FLAG_ALLOWNONLOCAL,
679 FLAG_ALLOWMOUSEOPENFAIL,
680 FLAG_SAVER_BLANKTIME,
681 FLAG_DPMS_STANDBYTIME,
682 FLAG_DPMS_SUSPENDTIME,
683 FLAG_DPMS_OFFTIME,
684 FLAG_PIXMAP,
685 FLAG_NOPM,
686 FLAG_XINERAMA,
687 FLAG_LOG,
688 FLAG_RENDER_COLORMAP_MODE,
689 FLAG_RANDR,
690 FLAG_AIGLX,
691 FLAG_IGNORE_ABI,
692 FLAG_ALLOW_EMPTY_INPUT,
693 FLAG_USE_DEFAULT_FONT_PATH,
694 FLAG_AUTO_ADD_DEVICES,
695 FLAG_AUTO_ENABLE_DEVICES,
696 FLAG_GLX_VISUALS,
697 FLAG_DRI2,
698 FLAG_USE_SIGIO,
699 FLAG_AUTO_ADD_GPU,
700} FlagValues;
701
702/**
703 * NOTE: the last value for each entry is NOT the default. It is set to TRUE
704 * if the parser found the option in the config file.
705 */
706static OptionInfoRec FlagOptions[] = {
707 {FLAG_NOTRAPSIGNALS, "NoTrapSignals", OPTV_BOOLEAN,
708 {0}, FALSE0},
709 {FLAG_DONTVTSWITCH, "DontVTSwitch", OPTV_BOOLEAN,
710 {0}, FALSE0},
711 {FLAG_DONTZAP, "DontZap", OPTV_BOOLEAN,
712 {0}, FALSE0},
713 {FLAG_DONTZOOM, "DontZoom", OPTV_BOOLEAN,
714 {0}, FALSE0},
715 {FLAG_DISABLEVIDMODE, "DisableVidModeExtension", OPTV_BOOLEAN,
716 {0}, FALSE0},
717 {FLAG_ALLOWNONLOCAL, "AllowNonLocalXvidtune", OPTV_BOOLEAN,
718 {0}, FALSE0},
719 {FLAG_ALLOWMOUSEOPENFAIL, "AllowMouseOpenFail", OPTV_BOOLEAN,
720 {0}, FALSE0},
721 {FLAG_SAVER_BLANKTIME, "BlankTime", OPTV_INTEGER,
722 {0}, FALSE0},
723 {FLAG_DPMS_STANDBYTIME, "StandbyTime", OPTV_INTEGER,
724 {0}, FALSE0},
725 {FLAG_DPMS_SUSPENDTIME, "SuspendTime", OPTV_INTEGER,
726 {0}, FALSE0},
727 {FLAG_DPMS_OFFTIME, "OffTime", OPTV_INTEGER,
728 {0}, FALSE0},
729 {FLAG_PIXMAP, "Pixmap", OPTV_INTEGER,
730 {0}, FALSE0},
731 {FLAG_NOPM, "NoPM", OPTV_BOOLEAN,
732 {0}, FALSE0},
733 {FLAG_XINERAMA, "Xinerama", OPTV_BOOLEAN,
734 {0}, FALSE0},
735 {FLAG_LOG, "Log", OPTV_STRING,
736 {0}, FALSE0},
737 {FLAG_RENDER_COLORMAP_MODE, "RenderColormapMode", OPTV_STRING,
738 {0}, FALSE0},
739 {FLAG_RANDR, "RandR", OPTV_BOOLEAN,
740 {0}, FALSE0},
741 {FLAG_AIGLX, "AIGLX", OPTV_BOOLEAN,
742 {0}, FALSE0},
743 {FLAG_IGNORE_ABI, "IgnoreABI", OPTV_BOOLEAN,
744 {0}, FALSE0},
745 {FLAG_USE_DEFAULT_FONT_PATH, "UseDefaultFontPath", OPTV_BOOLEAN,
746 {0}, FALSE0},
747 {FLAG_AUTO_ADD_DEVICES, "AutoAddDevices", OPTV_BOOLEAN,
748 {0}, FALSE0},
749 {FLAG_AUTO_ENABLE_DEVICES, "AutoEnableDevices", OPTV_BOOLEAN,
750 {0}, FALSE0},
751 {FLAG_GLX_VISUALS, "GlxVisuals", OPTV_STRING,
752 {0}, FALSE0},
753 {FLAG_DRI2, "DRI2", OPTV_BOOLEAN,
754 {0}, FALSE0},
755 {FLAG_USE_SIGIO, "UseSIGIO", OPTV_BOOLEAN,
756 {0}, FALSE0},
757 {FLAG_AUTO_ADD_GPU, "AutoAddGPU", OPTV_BOOLEAN,
758 {0}, FALSE0},
759 {-1, NULL((void*)0), OPTV_NONE,
760 {0}, FALSE0},
761};
762
763static void
764configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
765{
766 XF86OptionPtr optp, tmp;
767 int i;
768 Pix24Flags pix24 = Pix24DontCare;
769 Bool value;
770 MessageType from;
771 const char *s;
772 XkbRMLVOSet set;
773 const char *rules;
774
775 /*
776 * Merge the ServerLayout and ServerFlags options. The former have
777 * precedence over the latter.
778 */
779 optp = NULL((void*)0);
780 if (flagsconf && flagsconf->flg_option_lst)
781 optp = xf86optionListDup(flagsconf->flg_option_lst);
782 if (layoutopts) {
783 tmp = xf86optionListDup(layoutopts);
784 if (optp)
785 optp = xf86optionListMerge(optp, tmp);
786 else
787 optp = tmp;
788 }
789
790 xf86ProcessOptions(-1, optp, FlagOptions);
791
792 xf86GetOptValBool(FlagOptions, FLAG_NOTRAPSIGNALS, &xf86Info.notrapSignals);
793 xf86GetOptValBool(FlagOptions, FLAG_DONTVTSWITCH, &xf86Info.dontVTSwitch);
794 xf86GetOptValBool(FlagOptions, FLAG_DONTZAP, &xf86Info.dontZap);
795 xf86GetOptValBool(FlagOptions, FLAG_DONTZOOM, &xf86Info.dontZoom);
796
797 xf86GetOptValBool(FlagOptions, FLAG_IGNORE_ABI, &xf86Info.ignoreABI);
798 if (xf86Info.ignoreABI) {
799 xf86Msg(X_CONFIG, "Ignoring ABI Version\n");
800 }
801
802 if (xf86SIGIOSupported()) {
803 xf86Info.useSIGIO =
804 xf86ReturnOptValBool(FlagOptions, FLAG_USE_SIGIO,
805 USE_SIGIO_BY_DEFAULT1);
806 if (xf86IsOptionSet(FlagOptions, FLAG_USE_SIGIO)) {
807 from = X_CONFIG;
808 }
809 else {
810 from = X_DEFAULT;
811 }
812 if (!xf86Info.useSIGIO) {
813 xf86Msg(from, "Disabling SIGIO handlers for input devices\n");
814 }
815 else if (from == X_CONFIG) {
816 xf86Msg(from, "Enabling SIGIO handlers for input devices\n");
817 }
818 }
819 else {
820 xf86Info.useSIGIO = FALSE0;
821 }
822
823 if (xf86IsOptionSet(FlagOptions, FLAG_AUTO_ADD_DEVICES)) {
824 xf86GetOptValBool(FlagOptions, FLAG_AUTO_ADD_DEVICES,
825 &xf86Info.autoAddDevices);
826 from = X_CONFIG;
827 }
828 else {
829 from = X_DEFAULT;
830 }
831 xf86Msg(from, "%sutomatically adding devices\n",
832 xf86Info.autoAddDevices ? "A" : "Not a");
833
834 if (xf86IsOptionSet(FlagOptions, FLAG_AUTO_ENABLE_DEVICES)) {
835 xf86GetOptValBool(FlagOptions, FLAG_AUTO_ENABLE_DEVICES,
836 &xf86Info.autoEnableDevices);
837 from = X_CONFIG;
838 }
839 else {
840 from = X_DEFAULT;
841 }
842 xf86Msg(from, "%sutomatically enabling devices\n",
843 xf86Info.autoEnableDevices ? "A" : "Not a");
844
845 if (xf86IsOptionSet(FlagOptions, FLAG_AUTO_ADD_GPU)) {
846 xf86GetOptValBool(FlagOptions, FLAG_AUTO_ADD_GPU,
847 &xf86Info.autoAddGPU);
848 from = X_CONFIG;
849 }
850 else {
851 from = X_DEFAULT;
852 }
853 xf86Msg(from, "%sutomatically adding GPU devices\n",
854 xf86Info.autoAddGPU ? "A" : "Not a");
855 /*
856 * Set things up based on the config file information. Some of these
857 * settings may be overridden later when the command line options are
858 * checked.
859 */
860#ifdef XF86VIDMODE1
861 if (xf86GetOptValBool(FlagOptions, FLAG_DISABLEVIDMODE, &value))
862 xf86Info.vidModeEnabled = !value;
863 if (xf86GetOptValBool(FlagOptions, FLAG_ALLOWNONLOCAL, &value))
864 xf86Info.vidModeAllowNonLocal = value;
865#endif
866
867 if (xf86GetOptValBool(FlagOptions, FLAG_ALLOWMOUSEOPENFAIL, &value))
868 xf86Info.allowMouseOpenFail = value;
869
870 xf86Info.pmFlag = TRUE1;
871 if (xf86GetOptValBool(FlagOptions, FLAG_NOPM, &value))
872 xf86Info.pmFlag = !value;
873 {
874 if ((s = xf86GetOptValString(FlagOptions, FLAG_LOG))) {
875 if (!xf86NameCmp(s, "flush")) {
876 xf86Msg(X_CONFIG, "Flushing logfile enabled\n");
877 LogSetParameter(XLOG_FLUSH, TRUE1);
878 }
879 else if (!xf86NameCmp(s, "sync")) {
880 xf86Msg(X_CONFIG, "Syncing logfile enabled\n");
881 LogSetParameter(XLOG_FLUSH, TRUE1);
882 LogSetParameter(XLOG_SYNC, TRUE1);
883 }
884 else {
885 xf86Msg(X_WARNING, "Unknown Log option\n");
886 }
887 }
888 }
889
890 {
891 if ((s = xf86GetOptValString(FlagOptions, FLAG_RENDER_COLORMAP_MODE))) {
892 int policy = PictureParseCmapPolicy(s);
893
894 if (policy == PictureCmapPolicyInvalid-1)
895 xf86Msg(X_WARNING, "Unknown colormap policy \"%s\"\n", s);
896 else {
897 xf86Msg(X_CONFIG, "Render colormap policy set to %s\n", s);
898 PictureCmapPolicy = policy;
899 }
900 }
901 }
902
903#ifdef RANDR1
904 xf86Info.disableRandR = FALSE0;
905 xf86Info.randRFrom = X_DEFAULT;
906 if (xf86GetOptValBool(FlagOptions, FLAG_RANDR, &value)) {
907 xf86Info.disableRandR = !value;
908 xf86Info.randRFrom = X_CONFIG;
909 }
910#endif
911
912 xf86Info.aiglx = TRUE1;
913 xf86Info.aiglxFrom = X_DEFAULT;
914 if (xf86GetOptValBool(FlagOptions, FLAG_AIGLX, &value)) {
915 xf86Info.aiglx = value;
916 xf86Info.aiglxFrom = X_CONFIG;
917 }
918
919#ifdef GLXEXT1
920 xf86Info.glxVisuals = XF86_GlxVisualsTypical;
921 xf86Info.glxVisualsFrom = X_DEFAULT;
922 if ((s = xf86GetOptValString(FlagOptions, FLAG_GLX_VISUALS))) {
923 if (!xf86NameCmp(s, "minimal")) {
924 xf86Info.glxVisuals = XF86_GlxVisualsMinimal;
925 }
926 else if (!xf86NameCmp(s, "typical")) {
927 xf86Info.glxVisuals = XF86_GlxVisualsTypical;
928 }
929 else if (!xf86NameCmp(s, "all")) {
930 xf86Info.glxVisuals = XF86_GlxVisualsAll;
931 }
932 else {
933 xf86Msg(X_WARNING, "Unknown GlxVisuals option\n");
934 }
935 }
936
937 if (xf86GetOptValBool(FlagOptions, FLAG_AIGLX, &value)) {
938 xf86Info.aiglx = value;
939 xf86Info.aiglxFrom = X_CONFIG;
940 }
941#endif
942
943 /* if we're not hotplugging, force some input devices to exist */
944 xf86Info.forceInputDevices = !(xf86Info.autoAddDevices &&
945 xf86Info.autoEnableDevices);
946
947 /* when forcing input devices, we use kbd. otherwise evdev, so use the
948 * evdev rules set. */
949#if defined(linux)
950 if (!xf86Info.forceInputDevices)
951 rules = "evdev";
952 else
953#endif
954 rules = "base";
955
956 /* Xkb default options. */
957 XkbInitRules(&set, rules, "pc105", "us", NULL((void*)0), NULL((void*)0));
958 XkbSetRulesDflts(&set);
959 XkbFreeRMLVOSet(&set, FALSE0);
960
961 xf86Info.useDefaultFontPath = TRUE1;
962 if (xf86GetOptValBool(FlagOptions, FLAG_USE_DEFAULT_FONT_PATH, &value)) {
963 xf86Info.useDefaultFontPath = value;
964 }
965
966/* Make sure that timers don't overflow CARD32's after multiplying */
967#define MAX_TIME_IN_MIN(0x7fffffff / (1000 * 60)) (0x7fffffff / MILLI_PER_MIN(1000 * 60))
968
969 i = -1;
970 xf86GetOptValInteger(FlagOptions, FLAG_SAVER_BLANKTIME, &i);
971 if ((i >= 0) && (i < MAX_TIME_IN_MIN(0x7fffffff / (1000 * 60))))
972 ScreenSaverTime = defaultScreenSaverTime = i * MILLI_PER_MIN(1000 * 60);
973 else if (i != -1)
974 ErrorF("BlankTime value %d outside legal range of 0 - %d minutes\n",
975 i, MAX_TIME_IN_MIN(0x7fffffff / (1000 * 60)));
976
977#ifdef DPMSExtension1
978 i = -1;
979 xf86GetOptValInteger(FlagOptions, FLAG_DPMS_STANDBYTIME, &i);
980 if ((i >= 0) && (i < MAX_TIME_IN_MIN(0x7fffffff / (1000 * 60))))
981 DPMSStandbyTime = i * MILLI_PER_MIN(1000 * 60);
982 else if (i != -1)
983 ErrorF("StandbyTime value %d outside legal range of 0 - %d minutes\n",
984 i, MAX_TIME_IN_MIN(0x7fffffff / (1000 * 60)));
985 i = -1;
986 xf86GetOptValInteger(FlagOptions, FLAG_DPMS_SUSPENDTIME, &i);
987 if ((i >= 0) && (i < MAX_TIME_IN_MIN(0x7fffffff / (1000 * 60))))
988 DPMSSuspendTime = i * MILLI_PER_MIN(1000 * 60);
989 else if (i != -1)
990 ErrorF("SuspendTime value %d outside legal range of 0 - %d minutes\n",
991 i, MAX_TIME_IN_MIN(0x7fffffff / (1000 * 60)));
992 i = -1;
993 xf86GetOptValInteger(FlagOptions, FLAG_DPMS_OFFTIME, &i);
994 if ((i >= 0) && (i < MAX_TIME_IN_MIN(0x7fffffff / (1000 * 60))))
995 DPMSOffTime = i * MILLI_PER_MIN(1000 * 60);
996 else if (i != -1)
997 ErrorF("OffTime value %d outside legal range of 0 - %d minutes\n",
998 i, MAX_TIME_IN_MIN(0x7fffffff / (1000 * 60)));
999#endif
1000
1001 i = -1;
1002 xf86GetOptValInteger(FlagOptions, FLAG_PIXMAP, &i);
1003 switch (i) {
1004 case 24:
1005 pix24 = Pix24Use24;
1006 break;
1007 case 32:
1008 pix24 = Pix24Use32;
1009 break;
1010 case -1:
1011 break;
1012 default:
1013 ErrorF("Pixmap option's value (%d) must be 24 or 32\n", i);
1014 break;
1015 }
1016 if (xf86Pix24 != Pix24DontCare) {
1017 xf86Info.pixmap24 = xf86Pix24;
1018 xf86Info.pix24From = X_CMDLINE;
1019 }
1020 else if (pix24 != Pix24DontCare) {
1021 xf86Info.pixmap24 = pix24;
1022 xf86Info.pix24From = X_CONFIG;
1023 }
1024 else {
1025 xf86Info.pixmap24 = Pix24DontCare;
1026 xf86Info.pix24From = X_DEFAULT;
1027 }
1028
1029#ifdef PANORAMIX1
1030 from = X_DEFAULT;
1031 if (!noPanoramiXExtension)
1032 from = X_CMDLINE;
1033 else if (xf86GetOptValBool(FlagOptions, FLAG_XINERAMA, &value)) {
1034 noPanoramiXExtension = !value;
1035 from = X_CONFIG;
1036 }
1037 if (!noPanoramiXExtension)
1038 xf86Msg(from, "Xinerama: enabled\n");
1039#endif
1040
1041#ifdef DRI2
1042 xf86Info.dri2 = FALSE0;
1043 xf86Info.dri2From = X_DEFAULT;
1044 if (xf86GetOptValBool(FlagOptions, FLAG_DRI2, &value)) {
1045 xf86Info.dri2 = value;
1046 xf86Info.dri2From = X_CONFIG;
1047 }
1048#endif
1049}
1050
1051Bool
1052xf86DRI2Enabled(void)
1053{
1054 return xf86Info.dri2;
1055}
1056
1057/**
1058 * Search for the pInfo in the null-terminated list given and remove (and
1059 * free) it if present. All other devices are moved forward.
1060 */
1061static void
1062freeDevice(InputInfoPtr * list, InputInfoPtr pInfo)
1063{
1064 InputInfoPtr *devs;
1065
1066 for (devs = list; devs && *devs; devs++) {
1067 if (*devs == pInfo) {
1068 free(*devs);
1069 for (; devs && *devs; devs++)
1070 devs[0] = devs[1];
1071 break;
1072 }
1073 }
1074}
1075
1076/**
1077 * Append pInfo to the null-terminated list, allocating space as necessary.
1078 * pInfo is used as the last element.
1079 */
1080static InputInfoPtr *
1081addDevice(InputInfoPtr * list, InputInfoPtr pInfo)
1082{
1083 InputInfoPtr *devs;
1084 int count = 1;
1085
1086 for (devs = list; devs && *devs; devs++)
1087 count++;
1088
1089 list = xnfrealloc(list, (count + 1) * sizeof(InputInfoPtr))XNFrealloc((void *)(list), (unsigned long)((count + 1) * sizeof
(InputInfoPtr)))
;
1090 list[count] = NULL((void*)0);
1091
1092 list[count - 1] = pInfo;
1093 return list;
1094}
1095
1096/*
1097 * Locate the core input devices. These can be specified/located in
1098 * the following ways, in order of priority:
1099 *
1100 * 1. The InputDevices named by the -pointer and -keyboard command line
1101 * options.
1102 * 2. The "CorePointer" and "CoreKeyboard" InputDevices referred to by
1103 * the active ServerLayout.
1104 * 3. The first InputDevices marked as "CorePointer" and "CoreKeyboard".
1105 * 4. The first InputDevices that use 'keyboard' or 'kbd' and a valid mouse
1106 * driver (mouse, synaptics, evdev, vmmouse, void)
1107 * 5. Default devices with an empty (default) configuration. These defaults
1108 * will reference the 'mouse' and 'keyboard' drivers.
1109 */
1110
1111static Bool
1112checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
1113{
1114 InputInfoPtr corePointer = NULL((void*)0), coreKeyboard = NULL((void*)0);
1115 Bool foundPointer = FALSE0, foundKeyboard = FALSE0;
1116 const char *pointerMsg = NULL((void*)0), *keyboardMsg = NULL((void*)0);
1117 InputInfoPtr *devs, /* iterator */
1118 indp;
1119 InputInfoPtr Pointer, Keyboard;
1120 XF86ConfInputPtr confInput;
1121 XF86ConfInputRec defPtr, defKbd;
1122 MessageType from = X_DEFAULT;
1123
1124 const char *mousedrivers[] = { "mouse", "synaptics", "evdev", "vmmouse",
1125 "void", NULL((void*)0)
1126 };
1127
1128 /*
1129 * First check if a core pointer or core keyboard have been specified
1130 * in the active ServerLayout. If more than one is specified for either,
1131 * remove the core attribute from the later ones.
1132 */
1133 for (devs = servlayoutp->inputs; devs && *devs; devs++) {
1134 indp = *devs;
1135 if (indp->options &&
1136 xf86CheckBoolOption(indp->options, "CorePointer", FALSE0)) {
1137 if (!corePointer) {
1138 corePointer = indp;
1139 }
1140 }
1141 if (indp->options &&
1142 xf86CheckBoolOption(indp->options, "CoreKeyboard", FALSE0)) {
1143 if (!coreKeyboard) {
1144 coreKeyboard = indp;
1145 }
1146 }
1147 }
1148
1149 confInput = NULL((void*)0);
1150
1151 /* 1. Check for the -pointer command line option. */
1152 if (xf86PointerName) {
1
Assuming 'xf86PointerName' is null
2
Taking false branch
1153 confInput = xf86findInput(xf86PointerName,
1154 xf86configptr->conf_input_lst);
1155 if (!confInput) {
1156 xf86Msg(X_ERROR, "No InputDevice section called \"%s\"\n",
1157 xf86PointerName);
1158 return FALSE0;
1159 }
1160 from = X_CMDLINE;
1161 /*
1162 * If one was already specified in the ServerLayout, it needs to be
1163 * removed.
1164 */
1165 if (corePointer) {
1166 freeDevice(servlayoutp->inputs, corePointer);
1167 corePointer = NULL((void*)0);
1168 }
1169 foundPointer = TRUE1;
1170 }
1171
1172 /* 2. ServerLayout-specified core pointer. */
1173 if (corePointer) {
3
Taking false branch
1174 foundPointer = TRUE1;
1175 from = X_CONFIG;
1176 }
1177
1178 /* 3. First core pointer device. */
1179 if (!foundPointer && (xf86Info.forceInputDevices || implicitLayout)) {
4
Taking false branch
1180 XF86ConfInputPtr p;
1181
1182 for (p = xf86configptr->conf_input_lst; p; p = p->list.next) {
1183 if (p->inp_option_lst &&
1184 xf86CheckBoolOption(p->inp_option_lst, "CorePointer", FALSE0)) {
1185 confInput = p;
1186 foundPointer = TRUE1;
1187 from = X_DEFAULT;
1188 pointerMsg = "first core pointer device";
1189 break;
1190 }
1191 }
1192 }
1193
1194 /* 4. First pointer with an allowed mouse driver. */
1195 if (!foundPointer && xf86Info.forceInputDevices) {
5
Taking false branch
1196 const char **driver = mousedrivers;
1197
1198 confInput = xf86findInput(CONF_IMPLICIT_POINTER"Implicit Core Pointer",
1199 xf86configptr->conf_input_lst);
1200 while (*driver && !confInput) {
1201 confInput = xf86findInputByDriver(*driver,
1202 xf86configptr->conf_input_lst);
1203 driver++;
1204 }
1205 if (confInput) {
1206 foundPointer = TRUE1;
1207 from = X_DEFAULT;
1208 pointerMsg = "first mouse device";
1209 }
1210 }
1211
1212 /* 5. Built-in default. */
1213 if (!foundPointer && xf86Info.forceInputDevices) {
6
Taking false branch
1214 memset(&defPtr, 0, sizeof(defPtr))__builtin___memset_chk (&defPtr, 0, sizeof(defPtr), __builtin_object_size
(&defPtr, 0))
;
1215 defPtr.inp_identifier = strdup("<default pointer>");
1216 defPtr.inp_driver = strdup("mouse");
1217 confInput = &defPtr;
1218 foundPointer = TRUE1;
1219 from = X_DEFAULT;
1220 pointerMsg = "default mouse configuration";
1221 }
1222
1223 /* Add the core pointer device to the layout, and set it to Core. */
1224 if (foundPointer && confInput) {
1225 Pointer = xf86AllocateInput();
1226 if (Pointer)
1227 foundPointer = configInput(Pointer, confInput, from);
1228 if (foundPointer) {
1229 Pointer->options = xf86AddNewOption(Pointer->options,
1230 "CorePointer", "on");
1231 Pointer->options = xf86AddNewOption(Pointer->options,
1232 "driver",
1233 confInput->inp_driver);
1234 Pointer->options =
1235 xf86AddNewOption(Pointer->options, "identifier",
1236 confInput->inp_identifier);
1237 servlayoutp->inputs = addDevice(servlayoutp->inputs, Pointer);
1238 }
1239 }
1240
1241 if (!foundPointer && xf86Info.forceInputDevices) {
7
Taking false branch
1242 /* This shouldn't happen. */
1243 xf86Msg(X_ERROR, "Cannot locate a core pointer device.\n");
1244 xf86DeleteInput(Pointer, 0);
1245 return FALSE0;
1246 }
1247
1248 confInput = NULL((void*)0);
1249
1250 /* 1. Check for the -keyboard command line option. */
1251 if (xf86KeyboardName) {
8
Assuming 'xf86KeyboardName' is non-null
9
Taking true branch
1252 confInput = xf86findInput(xf86KeyboardName,
1253 xf86configptr->conf_input_lst);
1254 if (!confInput) {
10
Assuming 'confInput' is non-null
11
Taking false branch
1255 xf86Msg(X_ERROR, "No InputDevice section called \"%s\"\n",
1256 xf86KeyboardName);
1257 return FALSE0;
1258 }
1259 from = X_CMDLINE;
1260 /*
1261 * If one was already specified in the ServerLayout, it needs to be
1262 * removed.
1263 */
1264 if (coreKeyboard) {
12
Taking false branch
1265 freeDevice(servlayoutp->inputs, coreKeyboard);
1266 coreKeyboard = NULL((void*)0);
1267 }
1268 foundKeyboard = TRUE1;
1269 }
1270
1271 /* 2. ServerLayout-specified core keyboard. */
1272 if (coreKeyboard) {
13
Taking false branch
1273 foundKeyboard = TRUE1;
1274 from = X_CONFIG;
1275 }
1276
1277 /* 3. First core keyboard device. */
1278 if (!foundKeyboard && (xf86Info.forceInputDevices || implicitLayout)) {
1279 XF86ConfInputPtr p;
1280
1281 for (p = xf86configptr->conf_input_lst; p; p = p->list.next) {
1282 if (p->inp_option_lst &&
1283 xf86CheckBoolOption(p->inp_option_lst, "CoreKeyboard", FALSE0)) {
1284 confInput = p;
1285 foundKeyboard = TRUE1;
1286 from = X_DEFAULT;
1287 keyboardMsg = "first core keyboard device";
1288 break;
1289 }
1290 }
1291 }
1292
1293 /* 4. First keyboard with 'keyboard' or 'kbd' as the driver. */
1294 if (!foundKeyboard && xf86Info.forceInputDevices) {
1295 confInput = xf86findInput(CONF_IMPLICIT_KEYBOARD"Implicit Core Keyboard",
1296 xf86configptr->conf_input_lst);
1297 if (!confInput) {
1298 confInput = xf86findInputByDriver("kbd",
1299 xf86configptr->conf_input_lst);
1300 }
1301 if (confInput) {
1302 foundKeyboard = TRUE1;
1303 from = X_DEFAULT;
1304 keyboardMsg = "first keyboard device";
1305 }
1306 }
1307
1308 /* 5. Built-in default. */
1309 if (!foundKeyboard && xf86Info.forceInputDevices) {
1310 memset(&defKbd, 0, sizeof(defKbd))__builtin___memset_chk (&defKbd, 0, sizeof(defKbd), __builtin_object_size
(&defKbd, 0))
;
1311 defKbd.inp_identifier = strdup("<default keyboard>");
1312 defKbd.inp_driver = strdup("kbd");
1313 confInput = &defKbd;
1314 foundKeyboard = TRUE1;
1315 keyboardMsg = "default keyboard configuration";
1316 from = X_DEFAULT;
1317 }
1318
1319 /* Add the core keyboard device to the layout, and set it to Core. */
1320 if (foundKeyboard && confInput) {
14
Taking true branch
1321 Keyboard = xf86AllocateInput();
15
Value assigned to 'Keyboard'
1322 if (Keyboard)
16
Assuming 'Keyboard' is null
17
Taking false branch
1323 foundKeyboard = configInput(Keyboard, confInput, from);
1324 if (foundKeyboard) {
18
Taking true branch
1325 Keyboard->options = xf86AddNewOption(Keyboard->options,
19
Access to field 'options' results in a dereference of a null pointer (loaded from variable 'Keyboard')
1326 "CoreKeyboard", "on");
1327 Keyboard->options = xf86AddNewOption(Keyboard->options,
1328 "driver",
1329 confInput->inp_driver);
1330 Keyboard->options =
1331 xf86AddNewOption(Keyboard->options, "identifier",
1332 confInput->inp_identifier);
1333 servlayoutp->inputs = addDevice(servlayoutp->inputs, Keyboard);
1334 }
1335 }
1336
1337 if (!foundKeyboard && xf86Info.forceInputDevices) {
1338 /* This shouldn't happen. */
1339 xf86Msg(X_ERROR, "Cannot locate a core keyboard device.\n");
1340 xf86DeleteInput(Keyboard, 0);
1341 return FALSE0;
1342 }
1343
1344 if (pointerMsg) {
1345 if (implicitLayout)
1346 xf86Msg(X_DEFAULT, "No Layout section. Using the %s.\n",
1347 pointerMsg);
1348 else
1349 xf86Msg(X_DEFAULT, "The core pointer device wasn't specified "
1350 "explicitly in the layout.\n"
1351 "\tUsing the %s.\n", pointerMsg);
1352 }
1353
1354 if (keyboardMsg) {
1355 if (implicitLayout)
1356 xf86Msg(X_DEFAULT, "No Layout section. Using the %s.\n",
1357 keyboardMsg);
1358 else
1359 xf86Msg(X_DEFAULT, "The core keyboard device wasn't specified "
1360 "explicitly in the layout.\n"
1361 "\tUsing the %s.\n", keyboardMsg);
1362 }
1363
1364 if (!xf86Info.forceInputDevices && !(foundPointer && foundKeyboard)) {
1365#if defined(CONFIG_HAL) || defined(CONFIG_UDEV) || defined(CONFIG_WSCONS)
1366 const char *config_backend;
1367
1368#if defined(CONFIG_HAL)
1369 config_backend = "HAL";
1370#elif defined(CONFIG_UDEV)
1371 config_backend = "udev";
1372#else
1373 config_backend = "wscons";
1374#endif
1375 xf86Msg(X_INFO, "The server relies on %s to provide the list of "
1376 "input devices.\n\tIf no devices become available, "
1377 "reconfigure %s or disable AutoAddDevices.\n",
1378 config_backend, config_backend);
1379#else
1380 xf86Msg(X_WARNING, "Hotplugging requested but the server was "
1381 "compiled without a config backend. "
1382 "No input devices were configured, the server "
1383 "will start without any input devices.\n");
1384#endif
1385 }
1386
1387 return TRUE1;
1388}
1389
1390typedef enum {
1391 LAYOUT_ISOLATEDEVICE,
1392 LAYOUT_SINGLECARD
1393} LayoutValues;
1394
1395static OptionInfoRec LayoutOptions[] = {
1396 {LAYOUT_ISOLATEDEVICE, "IsolateDevice", OPTV_STRING,
1397 {0}, FALSE0},
1398 {LAYOUT_SINGLECARD, "SingleCard", OPTV_BOOLEAN,
1399 {0}, FALSE0},
1400 {-1, NULL((void*)0), OPTV_NONE,
1401 {0}, FALSE0},
1402};
1403
1404static Bool
1405configInputDevices(XF86ConfLayoutPtr layout, serverLayoutPtr servlayoutp)
1406{
1407 XF86ConfInputrefPtr irp;
1408 InputInfoPtr *indp;
1409 int count = 0;
1410
1411 /*
1412 * Count the number of input devices.
1413 */
1414 irp = layout->lay_input_lst;
1415 while (irp) {
1416 count++;
1417 irp = (XF86ConfInputrefPtr) irp->list.next;
1418 }
1419 DebugF("Found %d input devices in the layout section %s\n",
1420 count, layout->lay_identifier);
1421 indp = xnfcalloc((count + 1), sizeof(InputInfoPtr))XNFcalloc((unsigned long)((count + 1))*(unsigned long)(sizeof
(InputInfoPtr)))
;
1422 indp[count] = NULL((void*)0);
1423 irp = layout->lay_input_lst;
1424 count = 0;
1425 while (irp) {
1426 indp[count] = xf86AllocateInput();
1427 if (!configInput(indp[count], irp->iref_inputdev, X_CONFIG)) {
1428 do {
1429 free(indp[count]);
1430 } while (count--);
1431 free(indp);
1432 return FALSE0;
1433 }
1434 indp[count]->options = xf86OptionListMerge(indp[count]->options,
1435 irp->iref_option_lst);
1436 count++;
1437 irp = (XF86ConfInputrefPtr) irp->list.next;
1438 }
1439 servlayoutp->inputs = indp;
1440
1441 return TRUE1;
1442}
1443
1444/*
1445 * figure out which layout is active, which screens are used in that layout,
1446 * which drivers and monitors are used in these screens
1447 */
1448static Bool
1449configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
1450 char *default_layout)
1451{
1452 XF86ConfAdjacencyPtr adjp;
1453 XF86ConfInactivePtr idp;
1454 int saved_count, count = 0;
1455 int scrnum;
1456 XF86ConfLayoutPtr l;
1457 MessageType from;
1458 screenLayoutPtr slp;
1459 GDevPtr gdp;
1460 int i = 0, j;
1461
1462 if (!servlayoutp)
1463 return FALSE0;
1464
1465 /*
1466 * which layout section is the active one?
1467 *
1468 * If there is a -layout command line option, use that one, otherwise
1469 * pick the first one.
1470 */
1471 from = X_DEFAULT;
1472 if (xf86LayoutName != NULL((void*)0))
1473 from = X_CMDLINE;
1474 else if (default_layout) {
1475 xf86LayoutName = default_layout;
1476 from = X_CONFIG;
1477 }
1478 if (xf86LayoutName != NULL((void*)0)) {
1479 if ((l = xf86findLayout(xf86LayoutName, conf_layout)) == NULL((void*)0)) {
1480 xf86Msg(X_ERROR, "No ServerLayout section called \"%s\"\n",
1481 xf86LayoutName);
1482 return FALSE0;
1483 }
1484 conf_layout = l;
1485 }
1486 xf86Msg(from, "ServerLayout \"%s\"\n", conf_layout->lay_identifier);
1487 adjp = conf_layout->lay_adjacency_lst;
1488
1489 /*
1490 * we know that each screen is referenced exactly once on the left side
1491 * of a layout statement in the Layout section. So to allocate the right
1492 * size for the array we do a quick walk of the list to figure out how
1493 * many sections we have
1494 */
1495 while (adjp) {
1496 count++;
1497 adjp = (XF86ConfAdjacencyPtr) adjp->list.next;
1498 }
1499
1500 DebugF("Found %d screens in the layout section %s",
1501 count, conf_layout->lay_identifier);
1502 if (!count) /* alloc enough storage even if no screen is specified */
1503 count = 1;
1504
1505 slp = xnfcalloc(1, (count + 1) * sizeof(screenLayoutRec))XNFcalloc((unsigned long)(1)*(unsigned long)((count + 1) * sizeof
(screenLayoutRec)))
;
1506 slp[count].screen = NULL((void*)0);
1507 /*
1508 * now that we have storage, loop over the list again and fill in our
1509 * data structure; at this point we do not fill in the adjacency
1510 * information as it is not clear if we need it at all
1511 */
1512 adjp = conf_layout->lay_adjacency_lst;
1513 count = 0;
1514 while (adjp) {
1515 slp[count].screen = xnfcalloc(1, sizeof(confScreenRec))XNFcalloc((unsigned long)(1)*(unsigned long)(sizeof(confScreenRec
)))
;
1516 if (adjp->adj_scrnum < 0)
1517 scrnum = count;
1518 else
1519 scrnum = adjp->adj_scrnum;
1520 if (!configScreen(slp[count].screen, adjp->adj_screen, scrnum,
1521 X_CONFIG)) {
1522 do {
1523 free(slp[count].screen);
1524 } while (count--);
1525 free(slp);
1526 return FALSE0;
1527 }
1528 slp[count].x = adjp->adj_x;
1529 slp[count].y = adjp->adj_y;
1530 slp[count].refname = adjp->adj_refscreen;
1531 switch (adjp->adj_where) {
1532 case CONF_ADJ_OBSOLETE-1:
1533 slp[count].where = PosObsolete;
1534 slp[count].topname = adjp->adj_top_str;
1535 slp[count].bottomname = adjp->adj_bottom_str;
1536 slp[count].leftname = adjp->adj_left_str;
1537 slp[count].rightname = adjp->adj_right_str;
1538 break;
1539 case CONF_ADJ_ABSOLUTE0:
1540 slp[count].where = PosAbsolute;
1541 break;
1542 case CONF_ADJ_RIGHTOF1:
1543 slp[count].where = PosRightOf;
1544 break;
1545 case CONF_ADJ_LEFTOF2:
1546 slp[count].where = PosLeftOf;
1547 break;
1548 case CONF_ADJ_ABOVE3:
1549 slp[count].where = PosAbove;
1550 break;
1551 case CONF_ADJ_BELOW4:
1552 slp[count].where = PosBelow;
1553 break;
1554 case CONF_ADJ_RELATIVE5:
1555 slp[count].where = PosRelative;
1556 break;
1557 }
1558 count++;
1559 adjp = (XF86ConfAdjacencyPtr) adjp->list.next;
1560 }
1561
1562 /* No screen was specified in the layout. take the first one from the
1563 * config file, or - if it is NULL - configScreen autogenerates one for
1564 * us */
1565 if (!count) {
1566 XF86ConfScreenPtr screen;
1567
1568 FIND_SUITABLE (XF86ConfScreenPtr, xf86configptr->conf_screen_lst, screen)do { XF86ConfScreenPtr _l, _p; for (_l = (xf86configptr->conf_screen_lst
), _p = ((void*)0); !_p && _l; _l = (XF86ConfScreenPtr
)_l->list.next) { if (!_l->match_seat || (SeatId &&
xf86nameCompare(_l->match_seat, SeatId) == 0)) _p = _l; }
(screen) = _p; } while(0)
;
1569 slp[0].screen = xnfcalloc(1, sizeof(confScreenRec))XNFcalloc((unsigned long)(1)*(unsigned long)(sizeof(confScreenRec
)))
;
1570 if (!configScreen(slp[0].screen, screen,
1571 0, X_CONFIG)) {
1572 free(slp[0].screen);
1573 free(slp);
1574 return FALSE0;
1575 }
1576 }
1577
1578 /* XXX Need to tie down the upper left screen. */
1579
1580 /* Fill in the refscreen and top/bottom/left/right values */
1581 for (i = 0; i < count; i++) {
1582 for (j = 0; j < count; j++) {
1583 if (slp[i].refname &&
1584 strcmp(slp[i].refname, slp[j].screen->id) == 0) {
1585 slp[i].refscreen = slp[j].screen;
1586 }
1587 if (slp[i].topname &&
1588 strcmp(slp[i].topname, slp[j].screen->id) == 0) {
1589 slp[i].top = slp[j].screen;
1590 }
1591 if (slp[i].bottomname &&
1592 strcmp(slp[i].bottomname, slp[j].screen->id) == 0) {
1593 slp[i].bottom = slp[j].screen;
1594 }
1595 if (slp[i].leftname &&
1596 strcmp(slp[i].leftname, slp[j].screen->id) == 0) {
1597 slp[i].left = slp[j].screen;
1598 }
1599 if (slp[i].rightname &&
1600 strcmp(slp[i].rightname, slp[j].screen->id) == 0) {
1601 slp[i].right = slp[j].screen;
1602 }
1603 }
1604 if (slp[i].where != PosObsolete
1605 && slp[i].where != PosAbsolute && !slp[i].refscreen) {
1606 xf86Msg(X_ERROR, "Screen %s doesn't exist: deleting placement\n",
1607 slp[i].refname);
1608 slp[i].where = PosAbsolute;
1609 slp[i].x = 0;
1610 slp[i].y = 0;
1611 }
1612 }
1613
1614 if (!count)
1615 saved_count = 1;
1616 else
1617 saved_count = count;
1618 /*
1619 * Count the number of inactive devices.
1620 */
1621 count = 0;
1622 idp = conf_layout->lay_inactive_lst;
1623 while (idp) {
1624 count++;
1625 idp = (XF86ConfInactivePtr) idp->list.next;
1626 }
1627 DebugF("Found %d inactive devices in the layout section %s\n",
1628 count, conf_layout->lay_identifier);
1629 gdp = xnfalloc((count + 1) * sizeof(GDevRec))XNFalloc((unsigned long)((count + 1) * sizeof(GDevRec)));
1630 gdp[count].identifier = NULL((void*)0);
1631 idp = conf_layout->lay_inactive_lst;
1632 count = 0;
1633 while (idp) {
1634 if (!configDevice(&gdp[count], idp->inactive_device, FALSE0))
1635 goto bail;
1636 count++;
1637 idp = (XF86ConfInactivePtr) idp->list.next;
1638 }
1639
1640 if (!configInputDevices(conf_layout, servlayoutp))
1641 goto bail;
1642
1643 servlayoutp->id = conf_layout->lay_identifier;
1644 servlayoutp->screens = slp;
1645 servlayoutp->inactives = gdp;
1646 servlayoutp->options = conf_layout->lay_option_lst;
1647 from = X_DEFAULT;
1648
1649 return TRUE1;
1650
1651 bail:
1652 do {
1653 free(slp[saved_count].screen);
1654 } while (saved_count--);
1655 free(slp);
1656 free(gdp);
1657 return FALSE0;
1658}
1659
1660/*
1661 * No layout section, so find the first Screen section and set that up as
1662 * the only active screen.
1663 */
1664static Bool
1665configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen,
1666 XF86ConfigPtr conf_ptr)
1667{
1668 MessageType from;
1669 XF86ConfScreenPtr s;
1670 screenLayoutPtr slp;
1671 InputInfoPtr *indp;
1672 XF86ConfLayoutRec layout;
1673
1674 if (!servlayoutp)
1675 return FALSE0;
1676
1677 /*
1678 * which screen section is the active one?
1679 *
1680 * If there is a -screen option, use that one, otherwise use the first
1681 * one.
1682 */
1683
1684 from = X_CONFIG;
1685 if (xf86ScreenName != NULL((void*)0)) {
1686 if ((s = xf86findScreen(xf86ScreenName, conf_screen)) == NULL((void*)0)) {
1687 xf86Msg(X_ERROR, "No Screen section called \"%s\"\n",
1688 xf86ScreenName);
1689 return FALSE0;
1690 }
1691 conf_screen = s;
1692 from = X_CMDLINE;
1693 }
1694
1695 /* We have exactly one screen */
1696
1697 slp = xnfcalloc(1, 2 * sizeof(screenLayoutRec))XNFcalloc((unsigned long)(1)*(unsigned long)(2 * sizeof(screenLayoutRec
)))
;
1698 slp[0].screen = xnfcalloc(1, sizeof(confScreenRec))XNFcalloc((unsigned long)(1)*(unsigned long)(sizeof(confScreenRec
)))
;
1699 slp[1].screen = NULL((void*)0);
1700 if (!configScreen(slp[0].screen, conf_screen, 0, from)) {
1701 free(slp);
1702 return FALSE0;
1703 }
1704 servlayoutp->id = "(implicit)";
1705 servlayoutp->screens = slp;
1706 servlayoutp->inactives = xnfcalloc(1, sizeof(GDevRec))XNFcalloc((unsigned long)(1)*(unsigned long)(sizeof(GDevRec))
)
;
1707 servlayoutp->options = NULL((void*)0);
1708
1709 memset(&layout, 0, sizeof(layout))__builtin___memset_chk (&layout, 0, sizeof(layout), __builtin_object_size
(&layout, 0))
;
1710 layout.lay_identifier = servlayoutp->id;
1711 if (xf86layoutAddInputDevices(conf_ptr, &layout) > 0) {
1712 if (!configInputDevices(&layout, servlayoutp))
1713 return FALSE0;
1714 from = X_DEFAULT;
1715 }
1716 else {
1717 /* Set up an empty input device list, then look for some core devices. */
1718 indp = xnfalloc(sizeof(InputInfoPtr))XNFalloc((unsigned long)(sizeof(InputInfoPtr)));
1719 *indp = NULL((void*)0);
1720 servlayoutp->inputs = indp;
1721 }
1722
1723 return TRUE1;
1724}
1725
1726static Bool
1727configXvAdaptor(confXvAdaptorPtr adaptor, XF86ConfVideoAdaptorPtr conf_adaptor)
1728{
1729 int count = 0;
1730 XF86ConfVideoPortPtr conf_port;
1731
1732 xf86Msg(X_CONFIG, "| |-->VideoAdaptor \"%s\"\n",
1733 conf_adaptor->va_identifier);
1734 adaptor->identifier = conf_adaptor->va_identifier;
1735 adaptor->options = conf_adaptor->va_option_lst;
1736 if (conf_adaptor->va_busid || conf_adaptor->va_driver) {
1737 xf86Msg(X_CONFIG, "| | Unsupported device type, skipping entry\n");
1738 return FALSE0;
1739 }
1740
1741 /*
1742 * figure out how many videoport subsections there are and fill them in
1743 */
1744 conf_port = conf_adaptor->va_port_lst;
1745 while (conf_port) {
1746 count++;
1747 conf_port = (XF86ConfVideoPortPtr) conf_port->list.next;
1748 }
1749 adaptor->ports = xnfalloc((count) * sizeof(confXvPortRec))XNFalloc((unsigned long)((count) * sizeof(confXvPortRec)));
1750 adaptor->numports = count;
1751 count = 0;
1752 conf_port = conf_adaptor->va_port_lst;
1753 while (conf_port) {
1754 adaptor->ports[count].identifier = conf_port->vp_identifier;
1755 adaptor->ports[count].options = conf_port->vp_option_lst;
1756 count++;
1757 conf_port = (XF86ConfVideoPortPtr) conf_port->list.next;
1758 }
1759
1760 return TRUE1;
1761}
1762
1763static Bool
1764configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum,
1765 MessageType from)
1766{
1767 int count = 0;
1768 XF86ConfDisplayPtr dispptr;
1769 XF86ConfAdaptorLinkPtr conf_adaptor;
1770 Bool defaultMonitor = FALSE0;
1771 XF86ConfScreenRec local_conf_screen;
1772
1773 if (!conf_screen) {
1774 memset(&local_conf_screen, 0, sizeof(local_conf_screen))__builtin___memset_chk (&local_conf_screen, 0, sizeof(local_conf_screen
), __builtin_object_size (&local_conf_screen, 0))
;
1775 conf_screen = &local_conf_screen;
1776 conf_screen->scrn_identifier = "Default Screen Section";
1777 xf86Msg(X_DEFAULT, "No screen section available. Using defaults.\n");
1778 }
1779
1780 xf86Msg(from, "|-->Screen \"%s\" (%d)\n", conf_screen->scrn_identifier,
1781 scrnum);
1782 /*
1783 * now we fill in the elements of the screen
1784 */
1785 screenp->id = conf_screen->scrn_identifier;
1786 screenp->screennum = scrnum;
1787 screenp->defaultdepth = conf_screen->scrn_defaultdepth;
1788 screenp->defaultbpp = conf_screen->scrn_defaultbpp;
1789 screenp->defaultfbbpp = conf_screen->scrn_defaultfbbpp;
1790 screenp->monitor = xnfcalloc(1, sizeof(MonRec))XNFcalloc((unsigned long)(1)*(unsigned long)(sizeof(MonRec)));
1791 /* If no monitor is specified, create a default one. */
1792 if (!conf_screen->scrn_monitor) {
1793 XF86ConfMonitorRec defMon;
1794
1795 memset(&defMon, 0, sizeof(defMon))__builtin___memset_chk (&defMon, 0, sizeof(defMon), __builtin_object_size
(&defMon, 0))
;
1796 defMon.mon_identifier = "<default monitor>";
1797 if (!configMonitor(screenp->monitor, &defMon))
1798 return FALSE0;
1799 defaultMonitor = TRUE1;
1800 }
1801 else {
1802 if (!configMonitor(screenp->monitor, conf_screen->scrn_monitor))
1803 return FALSE0;
1804 }
1805 /* Configure the device. If there isn't one configured, attach to the
1806 * first inactive one that we can configure. If there's none that work,
1807 * set it to NULL so that the section can be autoconfigured later */
1808 screenp->device = xnfcalloc(1, sizeof(GDevRec))XNFcalloc((unsigned long)(1)*(unsigned long)(sizeof(GDevRec))
)
;
1809 if ((!conf_screen->scrn_device) && (xf86configptr->conf_device_lst)) {
1810 FIND_SUITABLE (XF86ConfDevicePtr, xf86configptr->conf_device_lst, conf_screen->scrn_device)do { XF86ConfDevicePtr _l, _p; for (_l = (xf86configptr->conf_device_lst
), _p = ((void*)0); !_p && _l; _l = (XF86ConfDevicePtr
)_l->list.next) { if (!_l->match_seat || (SeatId &&
xf86nameCompare(_l->match_seat, SeatId) == 0)) _p = _l; }
(conf_screen->scrn_device) = _p; } while(0)
;
1811 xf86Msg(X_DEFAULT, "No device specified for screen \"%s\".\n"
1812 "\tUsing the first device section listed.\n", screenp->id);
1813 }
1814 if (configDevice(screenp->device, conf_screen->scrn_device, TRUE1)) {
1815 screenp->device->myScreenSection = screenp;
1816 }
1817 else {
1818 screenp->device = NULL((void*)0);
1819 }
1820 screenp->options = conf_screen->scrn_option_lst;
1821
1822 /*
1823 * figure out how many display subsections there are and fill them in
1824 */
1825 dispptr = conf_screen->scrn_display_lst;
1826 while (dispptr) {
1827 count++;
1828 dispptr = (XF86ConfDisplayPtr) dispptr->list.next;
1829 }
1830 screenp->displays = xnfalloc((count) * sizeof(DispRec))XNFalloc((unsigned long)((count) * sizeof(DispRec)));
1831 screenp->numdisplays = count;
1832
1833 /* Fill in the default Virtual size, if any */
1834 if (conf_screen->scrn_virtualX && conf_screen->scrn_virtualY) {
1835 for (count = 0, dispptr = conf_screen->scrn_display_lst;
1836 dispptr;
1837 dispptr = (XF86ConfDisplayPtr) dispptr->list.next, count++) {
1838 screenp->displays[count].virtualX = conf_screen->scrn_virtualX;
1839 screenp->displays[count].virtualY = conf_screen->scrn_virtualY;
1840 }
1841 }
1842
1843 /* Now do the per-Display Virtual sizes */
1844 count = 0;
1845 dispptr = conf_screen->scrn_display_lst;
1846 while (dispptr) {
1847 configDisplay(&(screenp->displays[count]), dispptr);
1848 count++;
1849 dispptr = (XF86ConfDisplayPtr) dispptr->list.next;
1850 }
1851
1852 /*
1853 * figure out how many videoadaptor references there are and fill them in
1854 */
1855 conf_adaptor = conf_screen->scrn_adaptor_lst;
1856 while (conf_adaptor) {
1857 count++;
1858 conf_adaptor = (XF86ConfAdaptorLinkPtr) conf_adaptor->list.next;
1859 }
1860 screenp->xvadaptors = xnfalloc((count) * sizeof(confXvAdaptorRec))XNFalloc((unsigned long)((count) * sizeof(confXvAdaptorRec)));
1861 screenp->numxvadaptors = 0;
1862 conf_adaptor = conf_screen->scrn_adaptor_lst;
1863 while (conf_adaptor) {
1864 if (configXvAdaptor(&(screenp->xvadaptors[screenp->numxvadaptors]),
1865 conf_adaptor->al_adaptor))
1866 screenp->numxvadaptors++;
1867 conf_adaptor = (XF86ConfAdaptorLinkPtr) conf_adaptor->list.next;
1868 }
1869
1870 if (defaultMonitor) {
1871 xf86Msg(X_DEFAULT, "No monitor specified for screen \"%s\".\n"
1872 "\tUsing a default monitor configuration.\n", screenp->id);
1873 }
1874 return TRUE1;
1875}
1876
1877typedef enum {
1878 MON_REDUCEDBLANKING,
1879 MON_MAX_PIX_CLOCK,
1880} MonitorValues;
1881
1882static OptionInfoRec MonitorOptions[] = {
1883 {MON_REDUCEDBLANKING, "ReducedBlanking", OPTV_BOOLEAN,
1884 {0}, FALSE0},
1885 {MON_MAX_PIX_CLOCK, "MaxPixClock", OPTV_FREQ,
1886 {0}, FALSE0},
1887 {-1, NULL((void*)0), OPTV_NONE,
1888 {0}, FALSE0},
1889};
1890
1891static Bool
1892configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor)
1893{
1894 int count;
1895 DisplayModePtr mode, last = NULL((void*)0);
1896 XF86ConfModeLinePtr cmodep;
1897 XF86ConfModesPtr modes;
1898 XF86ConfModesLinkPtr modeslnk = conf_monitor->mon_modes_sect_lst;
1899 Gamma zeros = { 0.0, 0.0, 0.0 };
1900 float badgamma = 0.0;
1901 double maxPixClock;
1902
1903 xf86Msg(X_CONFIG, "| |-->Monitor \"%s\"\n", conf_monitor->mon_identifier);
1904 monitorp->id = conf_monitor->mon_identifier;
1905 monitorp->vendor = conf_monitor->mon_vendor;
1906 monitorp->model = conf_monitor->mon_modelname;
1907 monitorp->Modes = NULL((void*)0);
1908 monitorp->Last = NULL((void*)0);
1909 monitorp->gamma = zeros;
1910 monitorp->widthmm = conf_monitor->mon_width;
1911 monitorp->heightmm = conf_monitor->mon_height;
1912 monitorp->reducedblanking = FALSE0;
1913 monitorp->maxPixClock = 0;
1914 monitorp->options = conf_monitor->mon_option_lst;
1915
1916 /*
1917 * fill in the monitor structure
1918 */
1919 for (count = 0;
1920 count < conf_monitor->mon_n_hsync && count < MAX_HSYNC8; count++) {
1921 monitorp->hsync[count].hi = conf_monitor->mon_hsync[count].hi;
1922 monitorp->hsync[count].lo = conf_monitor->mon_hsync[count].lo;
1923 }
1924 monitorp->nHsync = count;
1925 for (count = 0;
1926 count < conf_monitor->mon_n_vrefresh && count < MAX_VREFRESH8;
1927 count++) {
1928 monitorp->vrefresh[count].hi = conf_monitor->mon_vrefresh[count].hi;
1929 monitorp->vrefresh[count].lo = conf_monitor->mon_vrefresh[count].lo;
1930 }
1931 monitorp->nVrefresh = count;
1932
1933 /*
1934 * first we collect the mode lines from the UseModes directive
1935 */
1936 while (modeslnk) {
1937 modes = xf86findModes(modeslnk->ml_modes_str,
1938 xf86configptr->conf_modes_lst);
1939 modeslnk->ml_modes = modes;
1940
1941 /* now add the modes found in the modes
1942 section to the list of modes for this
1943 monitor unless it has been added before
1944 because we are reusing the same section
1945 for another screen */
1946 if (xf86itemNotSublist((GenericListPtr) conf_monitor->mon_modeline_lst,
1947 (GenericListPtr) modes->mon_modeline_lst)) {
1948 conf_monitor->mon_modeline_lst = (XF86ConfModeLinePtr)
1949 xf86addListItem((GenericListPtr) conf_monitor->mon_modeline_lst,
1950 (GenericListPtr) modes->mon_modeline_lst);
1951 }
1952 modeslnk = modeslnk->list.next;
1953 }
1954
1955 /*
1956 * we need to hook in the mode lines now
1957 * here both data structures use lists, only our internal one
1958 * is double linked
1959 */
1960 cmodep = conf_monitor->mon_modeline_lst;
1961 while (cmodep) {
1962 mode = xnfcalloc(1, sizeof(DisplayModeRec))XNFcalloc((unsigned long)(1)*(unsigned long)(sizeof(DisplayModeRec
)))
;
1963 mode->type = 0;
1964 mode->Clock = cmodep->ml_clock;
1965 mode->HDisplay = cmodep->ml_hdisplay;
1966 mode->HSyncStart = cmodep->ml_hsyncstart;
1967 mode->HSyncEnd = cmodep->ml_hsyncend;
1968 mode->HTotal = cmodep->ml_htotal;
1969 mode->VDisplay = cmodep->ml_vdisplay;
1970 mode->VSyncStart = cmodep->ml_vsyncstart;
1971 mode->VSyncEnd = cmodep->ml_vsyncend;
1972 mode->VTotal = cmodep->ml_vtotal;
1973 mode->Flags = cmodep->ml_flags;
1974 mode->HSkew = cmodep->ml_hskew;
1975 mode->VScan = cmodep->ml_vscan;
1976 mode->name = xnfstrdup(cmodep->ml_identifier)XNFstrdup(cmodep->ml_identifier);
1977 if (last) {
1978 mode->prev = last;
1979 last->next = mode;
1980 }
1981 else {
1982 /*
1983 * this is the first mode
1984 */
1985 monitorp->Modes = mode;
1986 mode->prev = NULL((void*)0);
1987 }
1988 last = mode;
1989 cmodep = (XF86ConfModeLinePtr) cmodep->list.next;
1990 }
1991 if (last) {
1992 last->next = NULL((void*)0);
1993 }
1994 monitorp->Last = last;
1995
1996 /* add the (VESA) default modes */
1997 if (!addDefaultModes(monitorp))
1998 return FALSE0;
1999
2000 if (conf_monitor->mon_gamma_red > GAMMA_ZERO((1.0 / 10.0) / 100.0))
2001 monitorp->gamma.red = conf_monitor->mon_gamma_red;
2002 if (conf_monitor->mon_gamma_green > GAMMA_ZERO((1.0 / 10.0) / 100.0))
2003 monitorp->gamma.green = conf_monitor->mon_gamma_green;
2004 if (conf_monitor->mon_gamma_blue > GAMMA_ZERO((1.0 / 10.0) / 100.0))
2005 monitorp->gamma.blue = conf_monitor->mon_gamma_blue;
2006
2007 /* Check that the gamma values are within range */
2008 if (monitorp->gamma.red > GAMMA_ZERO((1.0 / 10.0) / 100.0) &&
2009 (monitorp->gamma.red < GAMMA_MIN(1.0 / 10.0) || monitorp->gamma.red > GAMMA_MAX10.0)) {
2010 badgamma = monitorp->gamma.red;
2011 }
2012 else if (monitorp->gamma.green > GAMMA_ZERO((1.0 / 10.0) / 100.0) &&
2013 (monitorp->gamma.green < GAMMA_MIN(1.0 / 10.0) ||
2014 monitorp->gamma.green > GAMMA_MAX10.0)) {
2015 badgamma = monitorp->gamma.green;
2016 }
2017 else if (monitorp->gamma.blue > GAMMA_ZERO((1.0 / 10.0) / 100.0) &&
2018 (monitorp->gamma.blue < GAMMA_MIN(1.0 / 10.0) ||
2019 monitorp->gamma.blue > GAMMA_MAX10.0)) {
2020 badgamma = monitorp->gamma.blue;
2021 }
2022 if (badgamma > GAMMA_ZERO((1.0 / 10.0) / 100.0)) {
2023 ErrorF("Gamma value %.f is out of range (%.2f - %.1f)\n", badgamma,
2024 GAMMA_MIN(1.0 / 10.0), GAMMA_MAX10.0);
2025 return FALSE0;
2026 }
2027
2028 xf86ProcessOptions(-1, monitorp->options, MonitorOptions);
2029 xf86GetOptValBool(MonitorOptions, MON_REDUCEDBLANKING,
2030 &monitorp->reducedblanking);
2031 if (xf86GetOptValFreq(MonitorOptions, MON_MAX_PIX_CLOCK, OPTUNITS_KHZ,
2032 &maxPixClock) == TRUE1) {
2033 monitorp->maxPixClock = (int) maxPixClock;
2034 }
2035
2036 return TRUE1;
2037}
2038
2039static int
2040lookupVisual(const char *visname)
2041{
2042 int i;
2043
2044 if (!visname || !*visname)
2045 return -1;
2046
2047 for (i = 0; i <= DirectColor5; i++) {
2048 if (!xf86nameCompare(visname, xf86VisualNames[i]))
2049 break;
2050 }
2051
2052 if (i <= DirectColor5)
2053 return i;
2054
2055 return -1;
2056}
2057
2058static Bool
2059configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display)
2060{
2061 int count = 0;
2062 XF86ModePtr modep;
2063
2064 displayp->frameX0 = conf_display->disp_frameX0;
2065 displayp->frameY0 = conf_display->disp_frameY0;
2066 displayp->virtualX = conf_display->disp_virtualX;
2067 displayp->virtualY = conf_display->disp_virtualY;
2068 displayp->depth = conf_display->disp_depth;
2069 displayp->fbbpp = conf_display->disp_bpp;
2070 displayp->weight.red = conf_display->disp_weight.red;
2071 displayp->weight.green = conf_display->disp_weight.green;
2072 displayp->weight.blue = conf_display->disp_weight.blue;
2073 displayp->blackColour.red = conf_display->disp_black.red;
2074 displayp->blackColour.green = conf_display->disp_black.green;
2075 displayp->blackColour.blue = conf_display->disp_black.blue;
2076 displayp->whiteColour.red = conf_display->disp_white.red;
2077 displayp->whiteColour.green = conf_display->disp_white.green;
2078 displayp->whiteColour.blue = conf_display->disp_white.blue;
2079 displayp->options = conf_display->disp_option_lst;
2080 if (conf_display->disp_visual) {
2081 displayp->defaultVisual = lookupVisual(conf_display->disp_visual);
2082 if (displayp->defaultVisual == -1) {
2083 ErrorF("Invalid visual name: \"%s\"\n", conf_display->disp_visual);
2084 return FALSE0;
2085 }
2086 }
2087 else {
2088 displayp->defaultVisual = -1;
2089 }
2090
2091 /*
2092 * now hook in the modes
2093 */
2094 modep = conf_display->disp_mode_lst;
2095 while (modep) {
2096 count++;
2097 modep = (XF86ModePtr) modep->list.next;
2098 }
2099 displayp->modes = xnfalloc((count + 1) * sizeof(char *))XNFalloc((unsigned long)((count + 1) * sizeof(char *)));
2100 modep = conf_display->disp_mode_lst;
2101 count = 0;
2102 while (modep) {
2103 displayp->modes[count] = modep->mode_name;
2104 count++;
2105 modep = (XF86ModePtr) modep->list.next;
2106 }
2107 displayp->modes[count] = NULL((void*)0);
2108
2109 return TRUE1;
2110}
2111
2112static Bool
2113configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device, Bool active)
2114{
2115 int i;
2116
2117 if (!conf_device) {
2118 return FALSE0;
2119 }
2120
2121 if (active)
2122 xf86Msg(X_CONFIG, "| |-->Device \"%s\"\n",
2123 conf_device->dev_identifier);
2124 else
2125 xf86Msg(X_CONFIG, "|-->Inactive Device \"%s\"\n",
2126 conf_device->dev_identifier);
2127
2128 devicep->identifier = conf_device->dev_identifier;
2129 devicep->vendor = conf_device->dev_vendor;
2130 devicep->board = conf_device->dev_board;
2131 devicep->chipset = conf_device->dev_chipset;
2132 devicep->ramdac = conf_device->dev_ramdac;
2133 devicep->driver = conf_device->dev_driver;
2134 devicep->active = active;
2135 devicep->videoRam = conf_device->dev_videoram;
2136 devicep->BiosBase = conf_device->dev_bios_base;
2137 devicep->MemBase = conf_device->dev_mem_base;
2138 devicep->IOBase = conf_device->dev_io_base;
2139 devicep->clockchip = conf_device->dev_clockchip;
2140 devicep->busID = conf_device->dev_busid;
2141 devicep->chipID = conf_device->dev_chipid;
2142 devicep->chipRev = conf_device->dev_chiprev;
2143 devicep->options = conf_device->dev_option_lst;
2144 devicep->irq = conf_device->dev_irq;
2145 devicep->screen = conf_device->dev_screen;
2146
2147 for (i = 0; i < MAXDACSPEEDS; i++) {
2148 if (i < CONF_MAXDACSPEEDS4)
2149 devicep->dacSpeeds[i] = conf_device->dev_dacSpeeds[i];
2150 else
2151 devicep->dacSpeeds[i] = 0;
2152 }
2153 devicep->numclocks = conf_device->dev_clocks;
2154 if (devicep->numclocks > MAXCLOCKS128)
2155 devicep->numclocks = MAXCLOCKS128;
2156 for (i = 0; i < devicep->numclocks; i++) {
2157 devicep->clock[i] = conf_device->dev_clock[i];
2158 }
2159 devicep->claimed = FALSE0;
2160
2161 return TRUE1;
2162}
2163
2164#ifdef XF86DRI
2165static void
2166configDRI(XF86ConfDRIPtr drip)
2167{
2168 struct group *grp;
2169
2170 xf86ConfigDRI.group = -1;
2171 xf86ConfigDRI.mode = 0;
2172
2173 if (drip) {
2174 if (drip->dri_group_name) {
2175 if ((grp = getgrnam(drip->dri_group_name)))
2176 xf86ConfigDRI.group = grp->gr_gid;
2177 }
2178 else {
2179 if (drip->dri_group >= 0)
2180 xf86ConfigDRI.group = drip->dri_group;
2181 }
2182 xf86ConfigDRI.mode = drip->dri_mode;
2183 }
2184}
2185#endif
2186
2187static void
2188configExtensions(XF86ConfExtensionsPtr conf_ext)
2189{
2190 XF86OptionPtr o;
2191
2192 if (conf_ext && conf_ext->ext_option_lst) {
2193 for (o = conf_ext->ext_option_lst; o; o = xf86NextOption(o)) {
2194 char *name = xf86OptionName(o);
2195 char *val = xf86OptionValue(o);
2196 char *n;
2197 Bool enable = TRUE1;
2198
2199 /* Handle "No<ExtensionName>" */
2200 n = xf86NormalizeName(name);
2201 if (strncmp(n, "no", 2) == 0) {
2202 name += 2;
2203 enable = FALSE0;
2204 }
2205
2206 if (!val ||
2207 xf86NameCmp(val, "enable") == 0 ||
2208 xf86NameCmp(val, "enabled") == 0 ||
2209 xf86NameCmp(val, "on") == 0 ||
2210 xf86NameCmp(val, "1") == 0 ||
2211 xf86NameCmp(val, "yes") == 0 || xf86NameCmp(val, "true") == 0) {
2212 /* NOTHING NEEDED -- enabling is handled below */
2213 }
2214 else if (xf86NameCmp(val, "disable") == 0 ||
2215 xf86NameCmp(val, "disabled") == 0 ||
2216 xf86NameCmp(val, "off") == 0 ||
2217 xf86NameCmp(val, "0") == 0 ||
2218 xf86NameCmp(val, "no") == 0 ||
2219 xf86NameCmp(val, "false") == 0) {
2220 enable = !enable;
2221 }
2222 else {
2223 xf86Msg(X_WARNING, "Ignoring unrecognized value \"%s\"\n", val);
2224 free(n);
2225 continue;
2226 }
2227
2228 if (EnableDisableExtension(name, enable)) {
2229 xf86Msg(X_CONFIG, "Extension \"%s\" is %s\n",
2230 name, enable ? "enabled" : "disabled");
2231 }
2232 else {
2233 xf86Msg(X_WARNING, "Ignoring unrecognized extension \"%s\"\n",
2234 name);
2235 }
2236 free(n);
2237 }
2238 }
2239}
2240
2241static Bool
2242configInput(InputInfoPtr inputp, XF86ConfInputPtr conf_input, MessageType from)
2243{
2244 xf86Msg(from, "|-->Input Device \"%s\"\n", conf_input->inp_identifier);
2245 inputp->name = conf_input->inp_identifier;
2246 inputp->driver = conf_input->inp_driver;
2247 inputp->options = conf_input->inp_option_lst;
2248 inputp->attrs = NULL((void*)0);
2249
2250 return TRUE1;
2251}
2252
2253static Bool
2254modeIsPresent(DisplayModePtr mode, MonPtr monitorp)
2255{
2256 DisplayModePtr knownmodes = monitorp->Modes;
2257
2258 /* all I can think of is a linear search... */
2259 while (knownmodes != NULL((void*)0)) {
2260 if (!strcmp(mode->name, knownmodes->name) &&
2261 !(knownmodes->type & M_T_DEFAULT0x10))
2262 return TRUE1;
2263 knownmodes = knownmodes->next;
2264 }
2265 return FALSE0;
2266}
2267
2268static Bool
2269addDefaultModes(MonPtr monitorp)
2270{
2271 DisplayModePtr mode;
2272 DisplayModePtr last = monitorp->Last;
2273 int i = 0;
2274
2275 for (i = 0; i < xf86NumDefaultModes; i++) {
2276 mode = xf86DuplicateMode(&xf86DefaultModes[i]);
2277 if (!modeIsPresent(mode, monitorp)) {
2278 monitorp->Modes = xf86ModesAdd(monitorp->Modes, mode);
2279 last = mode;
2280 }
2281 else {
2282 free(mode);
2283 }
2284 }
2285 monitorp->Last = last;
2286
2287 return TRUE1;
2288}
2289
2290static void
2291checkInput(serverLayoutPtr layout, Bool implicit_layout)
2292{
2293 checkCoreInputDevices(layout, implicit_layout);
2294
2295 /* Unless we're forcing input devices, disable mouse/kbd devices in the
2296 * config. Otherwise the same physical device is added multiple times,
2297 * leading to duplicate events.
2298 */
2299 if (!xf86Info.forceInputDevices && layout->inputs) {
2300 InputInfoPtr *dev = layout->inputs;
2301 BOOL warned = FALSE0;
2302
2303 while (*dev) {
2304 if (strcmp((*dev)->driver, "kbd") == 0 ||
2305 strcmp((*dev)->driver, "mouse") == 0 ||
2306 strcmp((*dev)->driver, "vmmouse") == 0) {
2307 InputInfoPtr *current;
2308
2309 if (!warned) {
2310 xf86Msg(X_WARNING, "Hotplugging is on, devices using "
2311 "drivers 'kbd', 'mouse' or 'vmmouse' will be disabled.\n");
2312 warned = TRUE1;
2313 }
2314
2315 xf86Msg(X_WARNING, "Disabling %s\n", (*dev)->name);
2316
2317 current = dev;
2318 free(*dev);
2319 *dev = NULL((void*)0);
2320
2321 do {
2322 *current = *(current + 1);
2323 current++;
2324 } while (*current);
2325 }
2326 else
2327 dev++;
2328 }
2329 }
2330}
2331
2332/*
2333 * load the config file and fill the global data structure
2334 */
2335ConfigStatus
2336xf86HandleConfigFile(Bool autoconfig)
2337{
2338 const char *scanptr;
2339 Bool singlecard = 0;
2340 Bool implicit_layout = FALSE0;
2341 XF86ConfLayoutPtr layout;
2342
2343 if (!autoconfig) {
2344 char *filename, *dirname, *sysdirname;
2345 const char *filesearch, *dirsearch;
2346 MessageType filefrom = X_DEFAULT;
2347 MessageType dirfrom = X_DEFAULT;
2348
2349 if (!xf86PrivsElevated()) {
2350 filesearch = ALL_CONFIGPATH"%A," "%R," "/etc/X11/%R," "%P/etc/X11/%R," "%E," "%F," "/etc/X11/%F,"
"%P/etc/X11/%F," "/etc/X11/%X," "/etc/%X," "%P/etc/X11/%X.%H,"
"%P/etc/X11/%X," "%P/lib/X11/%X.%H," "%P/lib/X11/%X"
;
2351 dirsearch = ALL_CONFIGDIRPATH"%A," "%R," "/etc/X11/%R," "%C/X11/%R," "/etc/X11/%X," "%C/X11/%X";
2352 }
2353 else {
2354 filesearch = RESTRICTED_CONFIGPATH"/etc/X11/%S," "%P/etc/X11/%S," "/etc/X11/%G," "%P/etc/X11/%G,"
"/etc/X11/%X," "/etc/%X," "%P/etc/X11/%X.%H," "%P/etc/X11/%X,"
"%P/lib/X11/%X.%H," "%P/lib/X11/%X"
;
2355 dirsearch = RESTRICTED_CONFIGDIRPATH"/etc/X11/%R," "%C/X11/%R," "/etc/X11/%X," "%C/X11/%X";
2356 }
2357
2358 if (xf86ConfigFile)
2359 filefrom = X_CMDLINE;
2360 if (xf86ConfigDir)
2361 dirfrom = X_CMDLINE;
2362
2363 xf86initConfigFiles();
2364 sysdirname = xf86openConfigDirFiles(SYS_CONFIGDIRPATH"%D/X11/%X", NULL((void*)0),
2365 PROJECTROOT"/Users/jeremy/src/freedesktop/jhbuild/build");
2366 dirname = xf86openConfigDirFiles(dirsearch, xf86ConfigDir, PROJECTROOT"/Users/jeremy/src/freedesktop/jhbuild/build");
2367 filename = xf86openConfigFile(filesearch, xf86ConfigFile, PROJECTROOT"/Users/jeremy/src/freedesktop/jhbuild/build");
2368 if (filename) {
2369 xf86MsgVerb(filefrom, 0, "Using config file: \"%s\"\n", filename);
2370 xf86ConfigFile = xnfstrdup(filename)XNFstrdup(filename);
2371 }
2372 else {
2373 if (xf86ConfigFile)
2374 xf86Msg(X_ERROR, "Unable to locate/open config file: \"%s\"\n",
2375 xf86ConfigFile);
2376 }
2377 if (dirname) {
2378 xf86MsgVerb(dirfrom, 0, "Using config directory: \"%s\"\n",
2379 dirname);
2380 xf86ConfigDir = xnfstrdup(dirname)XNFstrdup(dirname);
2381 }
2382 else {
2383 if (xf86ConfigDir)
2384 xf86Msg(X_ERROR,
2385 "Unable to locate/open config directory: \"%s\"\n",
2386 xf86ConfigDir);
2387 }
2388 if (sysdirname)
2389 xf86MsgVerb(X_DEFAULT, 0, "Using system config directory \"%s\"\n",
2390 sysdirname);
2391 if (!filename && !dirname && !sysdirname)
2392 return CONFIG_NOFILE;
2393
2394 free(filename);
2395 free(dirname);
2396 free(sysdirname);
2397 }
2398
2399 if ((xf86configptr = xf86readConfigFile()) == NULL((void*)0)) {
2400 xf86Msg(X_ERROR, "Problem parsing the config file\n");
2401 return CONFIG_PARSE_ERROR;
2402 }
2403 xf86closeConfigFile();
2404
2405 /* Initialise a few things. */
2406
2407 /*
2408 * now we convert part of the information contained in the parser
2409 * structures into our own structures.
2410 * The important part here is to figure out which Screen Sections
2411 * in the XF86Config file are active so that we can piece together
2412 * the modes that we need later down the road.
2413 * And while we are at it, we'll decode the rest of the stuff as well
2414 */
2415
2416 /* First check if a layout section is present, and if it is valid. */
2417 FIND_SUITABLE(XF86ConfLayoutPtr, xf86configptr->conf_layout_lst, layout)do { XF86ConfLayoutPtr _l, _p; for (_l = (xf86configptr->conf_layout_lst
), _p = ((void*)0); !_p && _l; _l = (XF86ConfLayoutPtr
)_l->list.next) { if (!_l->match_seat || (SeatId &&
xf86nameCompare(_l->match_seat, SeatId) == 0)) _p = _l; }
(layout) = _p; } while(0)
;
2418 if (layout == NULL((void*)0) || xf86ScreenName != NULL((void*)0)) {
2419 XF86ConfScreenPtr screen;
2420
2421 if (xf86ScreenName == NULL((void*)0)) {
2422 xf86Msg(X_DEFAULT,
2423 "No Layout section. Using the first Screen section.\n");
2424 }
2425 FIND_SUITABLE (XF86ConfScreenPtr, xf86configptr->conf_screen_lst, screen)do { XF86ConfScreenPtr _l, _p; for (_l = (xf86configptr->conf_screen_lst
), _p = ((void*)0); !_p && _l; _l = (XF86ConfScreenPtr
)_l->list.next) { if (!_l->match_seat || (SeatId &&
xf86nameCompare(_l->match_seat, SeatId) == 0)) _p = _l; }
(screen) = _p; } while(0)
;
2426 if (!configImpliedLayout(&xf86ConfigLayout,
2427 screen,
2428 xf86configptr)) {
2429 xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
2430 return CONFIG_PARSE_ERROR;
2431 }
2432 implicit_layout = TRUE1;
2433 }
2434 else {
2435 if (xf86configptr->conf_flags != NULL((void*)0)) {
2436 char *dfltlayout = NULL((void*)0);
2437 void *optlist = xf86configptr->conf_flags->flg_option_lst;
2438
2439 if (optlist && xf86FindOption(optlist, "defaultserverlayout"))
2440 dfltlayout =
2441 xf86SetStrOption(optlist, "defaultserverlayout", NULL((void*)0));
2442 if (!configLayout(&xf86ConfigLayout, layout, dfltlayout)) {
2443 xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
2444 return CONFIG_PARSE_ERROR;
2445 }
2446 }
2447 else {
2448 if (!configLayout(&xf86ConfigLayout, layout, NULL((void*)0))) {
2449 xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
2450 return CONFIG_PARSE_ERROR;
2451 }
2452 }
2453 }
2454
2455 xf86ProcessOptions(-1, xf86ConfigLayout.options, LayoutOptions);
2456#ifdef XSERVER_LIBPCIACCESS
2457 if ((scanptr = xf86GetOptValString(LayoutOptions, LAYOUT_ISOLATEDEVICE))) {
2458 ; /* IsolateDevice specified; overrides SingleCard */
2459 }
2460 else {
2461 xf86GetOptValBool(LayoutOptions, LAYOUT_SINGLECARD, &singlecard);
2462 if (singlecard)
2463 scanptr = xf86ConfigLayout.screens->screen->device->busID;
2464 }
2465 if (scanptr) {
2466 if (strncmp(scanptr, "PCI:", 4) != 0) {
2467 xf86Msg(X_WARNING, "Bus types other than PCI not yet isolable.\n"
2468 "\tIgnoring IsolateDevice option.\n");
2469 }
2470 else
2471 xf86PciIsolateDevice(scanptr);
2472 }
2473#endif
2474 /* Now process everything else */
2475 configServerFlags(xf86configptr->conf_flags, xf86ConfigLayout.options);
2476 configFiles(xf86configptr->conf_files);
2477 configExtensions(xf86configptr->conf_extensions);
2478#ifdef XF86DRI
2479 configDRI(xf86configptr->conf_dri);
2480#endif
2481
2482 checkInput(&xf86ConfigLayout, implicit_layout);
2483
2484 /*
2485 * Handle some command line options that can override some of the
2486 * ServerFlags settings.
2487 */
2488#ifdef XF86VIDMODE1
2489 if (xf86VidModeDisabled)
2490 xf86Info.vidModeEnabled = FALSE0;
2491 if (xf86VidModeAllowNonLocal)
2492 xf86Info.vidModeAllowNonLocal = TRUE1;
2493#endif
2494
2495 if (xf86AllowMouseOpenFail)
2496 xf86Info.allowMouseOpenFail = TRUE1;
2497
2498 return CONFIG_OK;
2499}
2500
2501Bool
2502xf86PathIsSafe(const char *path)
2503{
2504 return (xf86pathIsSafe(path) != 0);
2505}