1/*********************************************************** 2 3Copyright 1987, 1998 The Open Group 4 5Permission to use, copy, modify, distribute, and sell this software and its 6documentation for any purpose is hereby granted without fee, provided that 7the above copyright notice appear in all copies and that both that 8copyright notice and this permission notice appear in supporting 9documentation. 10 11The above copyright notice and this permission notice shall be included in 12all copies or substantial portions of the Software. 13 14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 18AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 21Except as contained in this notice, the name of The Open Group shall not be 22used in advertising or otherwise to promote the sale, use or other dealings 23in this Software without prior written authorization from The Open Group. 24 25 26Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. 27 28 All Rights Reserved 29 30Permission to use, copy, modify, and distribute this software and its 31documentation for any purpose and without fee is hereby granted, 32provided that the above copyright notice appear in all copies and that 33both that copyright notice and this permission notice appear in 34supporting documentation, and that the name of Digital not be 35used in advertising or publicity pertaining to distribution of the 36software without specific, written prior permission. 37 38DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 39ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 40DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 41ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 42WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 43ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 44SOFTWARE. 45 46******************************************************************/ 47 48#ifdef HAVE_DIX_CONFIG_H 49#include <dix-config.h> 50#endif 51 52#ifdef HAVE_XORG_CONFIG_H 53#include <xorg-config.h> 54#endif 55 56#ifdef HAVE_DMX_CONFIG_H 57#include <dmx-config.h> 58#undef XV 59#undef DBE 60#undef XF86VIDMODE 61#undef XFreeXDGA 62#undef XF86DRI 63#undef SCREENSAVER 64#undef RANDR 65#undef XFIXES 66#undef DAMAGE 67#undef COMPOSITE 68#undef MITSHM 69#endif 70 71#ifdef HAVE_XNEST_CONFIG_H 72#include <xnest-config.h> 73#undef COMPOSITE 74#undef DPMSExtension 75#endif 76 77#ifdef HAVE_KDRIVE_CONFIG_H 78#include <kdrive-config.h> 79/* there must be a better way... */ 80#undef XFreeXDGA 81#undef XF86DRI 82#undef XF86VIDMODE 83#endif 84 85#ifdef HAVE_XGL_CONFIG_H 86#include <xgl-config.h> 87#undef XFreeXDGA 88#undef XF86DRI 89#undef XF86VIDMODE 90#endif 91 92#include "misc.h" 93#include "extension.h" 94#include "micmap.h" 95#include "globals.h" 96 97 98extern Bool noTestExtensions; 99 100#ifdef COMPOSITE 101extern Bool noCompositeExtension; 102#endif 103#ifdef DBE 104extern Bool noDbeExtension; 105#endif 106#ifdef DPMSExtension 107extern Bool noDPMSExtension; 108#endif 109#ifdef GLXEXT 110extern Bool noGlxExtension; 111#endif 112#ifdef SCREENSAVER 113extern Bool noScreenSaverExtension; 114#endif 115#ifdef MITSHM 116extern Bool noMITShmExtension; 117#endif 118#ifdef RANDR 119extern Bool noRRExtension; 120#endif 121extern Bool noRenderExtension; 122#ifdef XCSECURITY 123extern Bool noSecurityExtension; 124#endif 125#ifdef RES 126extern Bool noResExtension; 127#endif 128#ifdef XF86BIGFONT 129extern Bool noXFree86BigfontExtension; 130#endif 131#ifdef XFreeXDGA 132extern Bool noXFree86DGAExtension; 133#endif 134#ifdef XF86DRI 135extern Bool noXFree86DRIExtension; 136#endif 137#ifdef XF86VIDMODE 138extern Bool noXFree86VidModeExtension; 139#endif 140#ifdef XFIXES 141extern Bool noXFixesExtension; 142#endif 143#ifdef PANORAMIX 144extern Bool noPanoramiXExtension; 145#endif 146#ifdef INXQUARTZ 147extern Bool noPseudoramiXExtension; 148#endif 149#ifdef XSELINUX 150extern Bool noSELinuxExtension; 151#endif 152#ifdef XV 153extern Bool noXvExtension; 154#endif 155extern Bool noGEExtension; 156 157#ifndef XFree86LOADER 158#define INITARGS void 159typedef void (*InitExtension)(INITARGS); 160#else /* XFree86Loader */ 161#include "loaderProcs.h" 162#endif 163 164#ifdef MITSHM 165#include <X11/extensions/shm.h> 166#endif 167#ifdef XTEST 168#include <X11/extensions/xtestconst.h> 169#endif 170#include <X11/extensions/XKB.h> 171#ifdef XCSECURITY 172#include "securitysrv.h" 173#include <X11/extensions/secur.h> 174#endif 175#ifdef XSELINUX 176#include "xselinux.h" 177#endif 178#ifdef PANORAMIX 179#include <X11/extensions/panoramiXproto.h> 180#endif 181#ifdef XF86BIGFONT 182#include <X11/extensions/xf86bigfproto.h> 183#endif 184#ifdef RES 185#include <X11/extensions/XResproto.h> 186#endif 187 188/* FIXME: this whole block of externs should be from the appropriate headers */ 189#ifdef MITSHM 190extern void ShmExtensionInit(INITARGS); 191#endif 192#ifdef PANORAMIX 193extern void PanoramiXExtensionInit(INITARGS); 194#endif 195#ifdef INXQUARTZ 196extern void PseudoramiXExtensionInit(INITARGS); 197#endif 198extern void XInputExtensionInit(INITARGS); 199#ifdef XTEST 200extern void XTestExtensionInit(INITARGS); 201#endif 202extern void BigReqExtensionInit(INITARGS); 203#ifdef SCREENSAVER 204extern void ScreenSaverExtensionInit (INITARGS); 205#endif 206#ifdef XV 207extern void XvExtensionInit(INITARGS); 208extern void XvMCExtensionInit(INITARGS); 209#endif 210extern void SyncExtensionInit(INITARGS); 211extern void XkbExtensionInit(INITARGS); 212extern void XCMiscExtensionInit(INITARGS); 213#ifdef XRECORD 214extern void RecordExtensionInit(INITARGS); 215#endif 216#ifdef DBE 217extern void DbeExtensionInit(INITARGS); 218#endif 219#ifdef XCSECURITY 220extern void SecurityExtensionInit(INITARGS); 221#endif 222#ifdef XSELINUX 223extern void SELinuxExtensionInit(INITARGS); 224#endif 225#ifdef XF86BIGFONT 226extern void XFree86BigfontExtensionInit(INITARGS); 227#endif 228#ifdef XF86VIDMODE 229extern void XFree86VidModeExtensionInit(INITARGS); 230#endif 231#ifdef XFreeXDGA 232extern void XFree86DGAExtensionInit(INITARGS); 233#endif 234#ifdef GLXEXT 235typedef struct __GLXprovider __GLXprovider; 236extern __GLXprovider __glXDRISWRastProvider; 237extern void GlxPushProvider(__GLXprovider *impl); 238extern void GlxExtensionInit(INITARGS); 239#endif 240#ifdef XF86DRI 241extern void XFree86DRIExtensionInit(INITARGS); 242#endif 243#ifdef DPMSExtension 244extern void DPMSExtensionInit(INITARGS); 245#endif 246extern void RenderExtensionInit(INITARGS); 247#ifdef RANDR 248extern void RRExtensionInit(INITARGS); 249#endif 250#ifdef RES 251extern void ResExtensionInit(INITARGS); 252#endif 253#ifdef DMXEXT 254extern void DMXExtensionInit(INITARGS); 255#endif 256#ifdef XFIXES 257extern void XFixesExtensionInit(INITARGS); 258#endif 259#ifdef DAMAGE 260extern void DamageExtensionInit(INITARGS); 261#endif 262#ifdef COMPOSITE 263extern void CompositeExtensionInit(INITARGS); 264#endif 265extern void GEExtensionInit(INITARGS); 266 267/* The following is only a small first step towards run-time 268 * configurable extensions. 269 */ 270typedef struct { 271 char *name; 272 Bool *disablePtr; 273} ExtensionToggle; 274 275static ExtensionToggle ExtensionToggleList[] = 276{ 277 /* sort order is extension name string as shown in xdpyinfo */ 278 { "Generic Events", &noGEExtension }, 279#ifdef COMPOSITE 280 { "Composite", &noCompositeExtension }, 281#endif 282#ifdef DAMAGE 283 { "DAMAGE", &noDamageExtension }, 284#endif 285#ifdef DBE 286 { "DOUBLE-BUFFER", &noDbeExtension }, 287#endif 288#ifdef DPMSExtension 289 { "DPMS", &noDPMSExtension }, 290#endif 291#ifdef GLXEXT 292 { "GLX", &noGlxExtension }, 293#endif 294#ifdef SCREENSAVER 295 { "MIT-SCREEN-SAVER", &noScreenSaverExtension }, 296#endif 297#ifdef MITSHM 298 { SHMNAME, &noMITShmExtension }, 299#endif 300#ifdef RANDR 301 { "RANDR", &noRRExtension }, 302#endif 303 { "RENDER", &noRenderExtension }, 304#ifdef XCSECURITY 305 { "SECURITY", &noSecurityExtension }, 306#endif 307#ifdef RES 308 { "X-Resource", &noResExtension }, 309#endif 310#ifdef XF86BIGFONT 311 { "XFree86-Bigfont", &noXFree86BigfontExtension }, 312#endif 313#ifdef XFreeXDGA 314 { "XFree86-DGA", &noXFree86DGAExtension }, 315#endif 316#ifdef XF86DRI 317 { "XFree86-DRI", &noXFree86DRIExtension }, 318#endif 319#ifdef XF86VIDMODE 320 { "XFree86-VidModeExtension", &noXFree86VidModeExtension }, 321#endif 322#ifdef XFIXES 323 { "XFIXES", &noXFixesExtension }, 324#endif 325#ifdef PANORAMIX 326 { "XINERAMA", &noPanoramiXExtension }, 327#endif 328 { "XInputExtension", NULL }, 329 { "XKEYBOARD", NULL }, 330#ifdef XSELINUX 331 { "SELinux", &noSELinuxExtension }, 332#endif 333 { "XTEST", &noTestExtensions }, 334#ifdef XV 335 { "XVideo", &noXvExtension }, 336#endif 337 { NULL, NULL } 338}; 339 340Bool EnableDisableExtension(char *name, Bool enable) 341{ 342 ExtensionToggle *ext = &ExtensionToggleList[0]; 343 344 for (ext = &ExtensionToggleList[0]; ext->name != NULL; ext++) { 345 if (strcmp(name, ext->name) == 0) { 346 if (ext->disablePtr != NULL) { 347 *ext->disablePtr = !enable; 348 return TRUE; 349 } else { 350 /* Extension is always on, impossible to disable */ 351 return enable; /* okay if they wanted to enable, 352 fail if they tried to disable */ 353 } 354 } 355 } 356 357 return FALSE; 358} 359 360void EnableDisableExtensionError(char *name, Bool enable) 361{ 362 ExtensionToggle *ext = &ExtensionToggleList[0]; 363 Bool found = FALSE; 364 365 for (ext = &ExtensionToggleList[0]; ext->name != NULL; ext++) { 366 if ((strcmp(name, ext->name) == 0) && (ext->disablePtr == NULL)) { 367 ErrorF("[mi] Extension \"%s\" can not be disabled\n", name); 368 found = TRUE; 369 break; 370 } 371 } 372 if (found == FALSE) 373 ErrorF("[mi] Extension \"%s\" is not recognized\n", name); 374 ErrorF("[mi] Only the following extensions can be run-time %s:\n", 375 enable ? "enabled" : "disabled"); 376 for (ext = &ExtensionToggleList[0]; ext->name != NULL; ext++) { 377 if (ext->disablePtr != NULL) { 378 ErrorF("[mi] %s\n", ext->name); 379 } 380 } 381} 382 383#ifndef XFree86LOADER 384 385/*ARGSUSED*/ 386void 387InitExtensions(int argc, char *argv[]) 388{ 389 if (!noGEExtension) GEExtensionInit(); 390 391#ifdef PANORAMIX 392 if (!noPanoramiXExtension) PanoramiXExtensionInit(); 393#endif 394#ifdef INXQUARTZ 395 if(!noPseudoramiXExtension) PseudoramiXExtensionInit(); 396#endif 397 ShapeExtensionInit(); 398#ifdef MITSHM 399 if (!noMITShmExtension) ShmExtensionInit(); 400#endif 401 XInputExtensionInit(); 402#ifdef XTEST 403 if (!noTestExtensions) XTestExtensionInit(); 404#endif 405 BigReqExtensionInit(); 406#if defined(SCREENSAVER) 407 if (!noScreenSaverExtension) ScreenSaverExtensionInit (); 408#endif 409#ifdef XV 410 if (!noXvExtension) { 411 XvExtensionInit(); 412 XvMCExtensionInit(); 413 } 414#endif 415 SyncExtensionInit(); 416 XkbExtensionInit(); 417 XCMiscExtensionInit(); 418#ifdef XRECORD 419 if (!noTestExtensions) RecordExtensionInit(); 420#endif 421#ifdef DBE 422 if (!noDbeExtension) DbeExtensionInit(); 423#endif 424#ifdef XCSECURITY 425 if (!noSecurityExtension) SecurityExtensionInit(); 426#endif 427#ifdef XSELINUX 428 if (!noSELinuxExtension) SELinuxExtensionInit(); 429#endif 430#if defined(DPMSExtension) && !defined(NO_HW_ONLY_EXTS) 431 if (!noDPMSExtension) DPMSExtensionInit(); 432#endif 433#ifdef XF86BIGFONT 434 if (!noXFree86BigfontExtension) XFree86BigfontExtensionInit(); 435#endif 436#if !defined(NO_HW_ONLY_EXTS) 437#if defined(XF86VIDMODE) 438 if (!noXFree86VidModeExtension) XFree86VidModeExtensionInit(); 439#endif 440#if defined(XFreeXDGA) 441 if (!noXFree86DGAExtension) XFree86DGAExtensionInit(); 442#endif 443#ifdef XF86DRI 444 if (!noXFree86DRIExtension) XFree86DRIExtensionInit(); 445#endif 446#endif 447#ifdef XFIXES 448 /* must be before Render to layer DisplayCursor correctly */ 449 if (!noXFixesExtension) XFixesExtensionInit(); 450#endif 451 if (!noRenderExtension) RenderExtensionInit(); 452#ifdef RANDR 453 if (!noRRExtension) RRExtensionInit(); 454#endif 455#ifdef RES 456 if (!noResExtension) ResExtensionInit(); 457#endif 458#ifdef DMXEXT 459 DMXExtensionInit(); /* server-specific extension, cannot be disabled */ 460#endif 461#ifdef COMPOSITE 462 if (!noCompositeExtension) CompositeExtensionInit(); 463#endif 464#ifdef DAMAGE 465 if (!noDamageExtension) DamageExtensionInit(); 466#endif 467 468#ifdef GLXEXT 469 if (serverGeneration == 1) 470 GlxPushProvider(&__glXDRISWRastProvider); 471 if (!noGlxExtension) GlxExtensionInit(); 472#endif 473} 474 475#else /* XFree86LOADER */ 476/* List of built-in (statically linked) extensions */ 477static ExtensionModule staticExtensions[] = { 478 { GEExtensionInit, "Generic Event Extension", &noGEExtension, NULL, NULL}, 479 { ShapeExtensionInit, "SHAPE", NULL, NULL, NULL }, 480#ifdef MITSHM 481 { ShmExtensionInit, SHMNAME, &noMITShmExtension, NULL, NULL }, 482#endif 483 { XInputExtensionInit, "XInputExtension", NULL, NULL, NULL }, 484#ifdef XTEST 485 { XTestExtensionInit, XTestExtensionName, &noTestExtensions, NULL, NULL }, 486#endif 487 { BigReqExtensionInit, "BIG-REQUESTS", NULL, NULL, NULL }, 488 { SyncExtensionInit, "SYNC", NULL, NULL, NULL }, 489 { XkbExtensionInit, XkbName, NULL, NULL, NULL }, 490 { XCMiscExtensionInit, "XC-MISC", NULL, NULL, NULL }, 491#ifdef XCSECURITY 492 { SecurityExtensionInit, SECURITY_EXTENSION_NAME, &noSecurityExtension, NULL, NULL }, 493#endif 494#ifdef PANORAMIX 495 { PanoramiXExtensionInit, PANORAMIX_PROTOCOL_NAME, &noPanoramiXExtension, NULL, NULL }, 496#endif 497#ifdef XFIXES 498 /* must be before Render to layer DisplayCursor correctly */ 499 { XFixesExtensionInit, "XFIXES", &noXFixesExtension, NULL, NULL }, 500#endif 501#ifdef XF86BIGFONT 502 { XFree86BigfontExtensionInit, XF86BIGFONTNAME, &noXFree86BigfontExtension, NULL, NULL }, 503#endif 504 { RenderExtensionInit, "RENDER", &noRenderExtension, NULL, NULL }, 505#ifdef RANDR 506 { RRExtensionInit, "RANDR", &noRRExtension, NULL, NULL }, 507#endif 508#ifdef COMPOSITE 509 { CompositeExtensionInit, "COMPOSITE", &noCompositeExtension, NULL }, 510#endif 511#ifdef DAMAGE 512 { DamageExtensionInit, "DAMAGE", &noDamageExtension, NULL }, 513#endif 514 { NULL, NULL, NULL, NULL, NULL } 515}; 516 517/*ARGSUSED*/ 518void 519InitExtensions(int argc, char *argv[]) 520{ 521 int i; 522 ExtensionModule *ext; 523 static Bool listInitialised = FALSE; 524 525 if (!listInitialised) { 526 /* Add built-in extensions to the list. */ 527 for (i = 0; staticExtensions[i].name; i++) 528 LoadExtension(&staticExtensions[i], TRUE); 529 530 /* Sort the extensions according the init dependencies. */ 531 LoaderSortExtensions(); 532 listInitialised = TRUE; 533 } 534 535 for (i = 0; ExtensionModuleList[i].name != NULL; i++) { 536 ext = &ExtensionModuleList[i]; 537 if (ext->initFunc != NULL && 538 (ext->disablePtr == NULL || !*ext->disablePtr)) { 539 (ext->initFunc)(); 540 } 541 } 542} 543 544#endif /* XFree86LOADER */ 545