1 /***********************************************************
3 Copyright 1987, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
25 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
29 Permission to use, copy, modify, and distribute this software and its
30 documentation for any purpose and without fee is hereby granted,
31 provided that the above copyright notice appear in all copies and that
32 both that copyright notice and this permission notice appear in
33 supporting documentation, and that the name of Digital not be
34 used in advertising or publicity pertaining to distribution of the
35 software without specific, written prior permission.
37 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
38 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
39 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
40 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
41 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
42 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
45 ******************************************************************/
48 * Copyright (c) 2000 by The XFree86 Project, Inc.
50 * Permission is hereby granted, free of charge, to any person obtaining a
51 * copy of this software and associated documentation files (the "Software"),
52 * to deal in the Software without restriction, including without limitation
53 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
54 * and/or sell copies of the Software, and to permit persons to whom the
55 * Software is furnished to do so, subject to the following conditions:
57 * The above copyright notice and this permission notice shall be included in
58 * all copies or substantial portions of the Software.
60 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
61 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
62 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
63 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
64 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
65 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
66 * OTHER DEALINGS IN THE SOFTWARE.
68 * Except as contained in this notice, the name of the copyright holder(s)
69 * and author(s) shall not be used in advertising or otherwise to promote
70 * the sale, use or other dealings in this Software without prior written
71 * authorization from the copyright holder(s) and author(s).
74 #ifdef HAVE_DIX_CONFIG_H
75 #include <dix-config.h>
78 #ifdef HAVE_XORG_CONFIG_H
79 #include <xorg-config.h>
80 #include "xf86Extensions.h"
83 #ifdef HAVE_DMX_CONFIG_H
84 #include <dmx-config.h>
94 #ifdef HAVE_XNEST_CONFIG_H
95 #include <xnest-config.h>
100 #ifdef HAVE_KDRIVE_CONFIG_H
101 #include <kdrive-config.h>
104 #ifdef HAVE_XGL_CONFIG_H
105 #include <xgl-config.h>
109 #include "extension.h"
114 /* The following is only a small first step towards run-time
115 * configurable extensions.
122 static ExtensionToggle ExtensionToggleList
[] = {
123 /* sort order is extension name string as shown in xdpyinfo */
124 {"Generic Events", &noGEExtension
},
126 {"Composite", &noCompositeExtension
},
129 {"DAMAGE", &noDamageExtension
},
132 {"DOUBLE-BUFFER", &noDbeExtension
},
135 {"DPMS", &noDPMSExtension
},
138 {"GLX", &noGlxExtension
},
141 {"MIT-SCREEN-SAVER", &noScreenSaverExtension
},
144 {SHMNAME
, &noMITShmExtension
},
147 {"RANDR", &noRRExtension
},
149 {"RENDER", &noRenderExtension
},
151 {"SECURITY", &noSecurityExtension
},
154 {"X-Resource", &noResExtension
},
157 {"XFree86-Bigfont", &noXFree86BigfontExtension
},
161 {"XFree86-DGA", &noXFree86DGAExtension
},
164 {"XFree86-DRI", &noXFree86DRIExtension
},
167 {"XFree86-VidModeExtension", &noXFree86VidModeExtension
},
170 {"XFIXES", &noXFixesExtension
},
172 {"XINERAMA", &noPanoramiXExtension
},
174 {"XInputExtension", NULL
},
177 {"SELinux", &noSELinuxExtension
},
179 {"XTEST", &noTestExtensions
},
181 {"XVideo", &noXvExtension
},
186 EnableDisableExtension(const char *name
, Bool enable
)
188 ExtensionToggle
*ext
;
191 for (i
= 0; i
< ARRAY_SIZE(ExtensionToggleList
); i
++) {
192 ext
= &ExtensionToggleList
[i
];
193 if (strcmp(name
, ext
->name
) == 0) {
194 if (ext
->disablePtr
!= NULL
) {
195 *ext
->disablePtr
= !enable
;
199 /* Extension is always on, impossible to disable */
200 return enable
; /* okay if they wanted to enable,
201 fail if they tried to disable */
210 EnableDisableExtensionError(const char *name
, Bool enable
)
212 ExtensionToggle
*ext
;
216 for (i
= 0; i
< ARRAY_SIZE(ExtensionToggleList
); i
++) {
217 ext
= &ExtensionToggleList
[i
];
218 if ((strcmp(name
, ext
->name
) == 0) && (ext
->disablePtr
== NULL
)) {
219 ErrorF("[mi] Extension \"%s\" can not be disabled\n", name
);
225 ErrorF("[mi] Extension \"%s\" is not recognized\n", name
);
226 ErrorF("[mi] Only the following extensions can be run-time %s:\n",
227 enable
? "enabled" : "disabled");
228 for (i
= 0; i
< ARRAY_SIZE(ExtensionToggleList
); i
++) {
229 ext
= &ExtensionToggleList
[i
];
230 if (ext
->disablePtr
!= NULL
) {
231 ErrorF("[mi] %s\n", ext
->name
);
236 /* List of built-in (statically linked) extensions */
237 static ExtensionModule staticExtensions
[] = {
238 {GEExtensionInit
, "Generic Event Extension", &noGEExtension
},
239 {ShapeExtensionInit
, "SHAPE", NULL
},
241 {ShmExtensionInit
, SHMNAME
, &noMITShmExtension
},
243 {XInputExtensionInit
, "XInputExtension", NULL
},
245 {XTestExtensionInit
, XTestExtensionName
, &noTestExtensions
},
247 {BigReqExtensionInit
, "BIG-REQUESTS", NULL
},
248 {SyncExtensionInit
, "SYNC", NULL
},
249 {XkbExtensionInit
, XkbName
, NULL
},
250 {XCMiscExtensionInit
, "XC-MISC", NULL
},
252 {SecurityExtensionInit
, SECURITY_EXTENSION_NAME
, &noSecurityExtension
},
255 {PanoramiXExtensionInit
, PANORAMIX_PROTOCOL_NAME
, &noPanoramiXExtension
},
258 /* PseudoramiXExtensionInit must be done before RRExtensionInit, or
259 * XQuartz will render windows offscreen.
261 {PseudoramiXExtensionInit
, "PseudoramiX", &noPseudoramiXExtension
},
263 /* must be before Render to layer DisplayCursor correctly */
264 {XFixesExtensionInit
, "XFIXES", &noXFixesExtension
},
266 {XFree86BigfontExtensionInit
, XF86BIGFONTNAME
, &noXFree86BigfontExtension
},
268 {RenderExtensionInit
, "RENDER", &noRenderExtension
},
270 {RRExtensionInit
, "RANDR", &noRRExtension
},
273 {CompositeExtensionInit
, "COMPOSITE", &noCompositeExtension
},
276 {DamageExtensionInit
, "DAMAGE", &noDamageExtension
},
279 {ScreenSaverExtensionInit
, ScreenSaverName
, &noScreenSaverExtension
},
282 {DbeExtensionInit
, "DOUBLE-BUFFER", &noDbeExtension
},
285 {RecordExtensionInit
, "RECORD", &noTestExtensions
},
288 {DPMSExtensionInit
, DPMSExtensionName
, &noDPMSExtension
},
291 {present_extension_init
, PRESENT_NAME
, NULL
},
294 {dri3_extension_init
, DRI3_NAME
, NULL
},
297 {ResExtensionInit
, XRES_NAME
, &noResExtension
},
300 {XvExtensionInit
, XvName
, &noXvExtension
},
301 {XvMCExtensionInit
, XvMCName
, &noXvExtension
},
304 {SELinuxExtensionInit
, SELINUX_EXTENSION_NAME
, &noSELinuxExtension
},
308 static ExtensionModule
*ExtensionModuleList
= NULL
;
309 static int numExtensionModules
= 0;
312 AddStaticExtensions(void)
314 static Bool listInitialised
= FALSE
;
319 listInitialised
= TRUE
;
321 /* Add built-in extensions to the list. */
322 for (i
= 0; i
< ARRAY_SIZE(staticExtensions
); i
++)
323 LoadExtension(&staticExtensions
[i
], TRUE
);
327 InitExtensions(int argc
, char *argv
[])
330 ExtensionModule
*ext
;
332 AddStaticExtensions();
334 for (i
= 0; ExtensionModuleList
[i
].name
!= NULL
; i
++) {
335 ext
= &ExtensionModuleList
[i
];
336 if (ext
->initFunc
!= NULL
&&
337 (ext
->disablePtr
== NULL
|| !*ext
->disablePtr
)) {
343 static ExtensionModule
*
344 NewExtensionModule(void)
346 ExtensionModule
*save
= ExtensionModuleList
;
349 /* Make sure built-in extensions get added to the list before those
351 AddStaticExtensions();
354 if (!ExtensionModuleList
)
355 numExtensionModules
= 0;
357 n
= numExtensionModules
+ 1;
358 ExtensionModuleList
= realloc(ExtensionModuleList
,
359 (n
+ 1) * sizeof(ExtensionModule
));
360 if (ExtensionModuleList
== NULL
) {
361 ExtensionModuleList
= save
;
365 numExtensionModules
++;
366 ExtensionModuleList
[numExtensionModules
].name
= NULL
;
367 return ExtensionModuleList
+ (numExtensionModules
- 1);
372 LoadExtension(const ExtensionModule
* e
, Bool builtin
)
374 ExtensionModule
*newext
;
376 if (e
== NULL
|| e
->name
== NULL
)
379 if (!(newext
= NewExtensionModule()))
383 ErrorF("Initializing built-in extension %s\n", e
->name
);
385 ErrorF("Loading extension %s\n", e
->name
);
387 newext
->name
= e
->name
;
388 newext
->initFunc
= e
->initFunc
;
389 newext
->disablePtr
= e
->disablePtr
;