1/* 2 * Copyright (c) 1997 Matthieu Herrb 3 * 4 * Permission to use, copy, modify, distribute, and sell this software and its 5 * documentation for any purpose is hereby granted without fee, provided that 6 * the above copyright notice appear in all copies and that both that 7 * copyright notice and this permission notice appear in supporting 8 * documentation, and that the name of Matthieu Herrb not be used in 9 * advertising or publicity pertaining to distribution of the software without 10 * specific, written prior permission. Matthieu Herrb makes no 11 * representations about the suitability of this software for any purpose. 12 * It is provided "as is" without express or implied warranty. 13 * 14 * MATTHIEU HERRB DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 16 * EVENT SHALL MATTHIEU HERRB BE LIABLE FOR ANY SPECIAL, INDIRECT OR 17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 20 * PERFORMANCE OF THIS SOFTWARE. 21 */ 22 23#ifdef HAVE_XORG_CONFIG_H 24#include <xorg-config.h> 25#endif 26 27#include "xf86Module.h" 28#include "xf86Opt.h" 29 30#include <X11/Xproto.h> 31 32#include "modinit.h" 33#include "globals.h" 34 35static MODULESETUPPROTO(extmodSetup); 36 37/* 38 * Array describing extensions to be initialized 39 */ 40static ExtensionModule extensionModules[] = { 41#ifdef XSELINUX 42 { 43 SELinuxExtensionInit, 44 SELINUX_EXTENSION_NAME, 45 &noSELinuxExtension, 46 NULL, 47 NULL 48 }, 49#endif 50#ifdef SCREENSAVER 51 { 52 ScreenSaverExtensionInit, 53 ScreenSaverName, 54 &noScreenSaverExtension, 55 NULL, 56 NULL 57 }, 58#endif 59#ifdef XF86VIDMODE 60 { 61 XFree86VidModeExtensionInit, 62 XF86VIDMODENAME, 63 &noXFree86VidModeExtension, 64 NULL, 65 NULL 66 }, 67#endif 68#ifdef XFreeXDGA 69 { 70 XFree86DGAExtensionInit, 71 XF86DGANAME, 72 &noXFree86DGAExtension, 73 XFree86DGARegister, 74 NULL 75 }, 76#endif 77#ifdef DPMSExtension 78 { 79 DPMSExtensionInit, 80 DPMSExtensionName, 81 &noDPMSExtension, 82 NULL, 83 NULL 84 }, 85#endif 86#ifdef XV 87 { 88 XvExtensionInit, 89 XvName, 90 &noXvExtension, 91 XvRegister, 92 NULL 93 }, 94 { 95 XvMCExtensionInit, 96 XvMCName, 97 &noXvExtension, 98 NULL, 99 NULL 100 }, 101#endif 102#ifdef RES 103 { 104 ResExtensionInit, 105 XRES_NAME, 106 &noResExtension, 107 NULL, 108 NULL 109 }, 110#endif 111 { /* DON'T delete this entry ! */ 112 NULL, 113 NULL, 114 NULL, 115 NULL, 116 NULL 117 } 118}; 119 120static XF86ModuleVersionInfo VersRec = 121{ 122 "extmod", 123 MODULEVENDORSTRING, 124 MODINFOSTRING1, 125 MODINFOSTRING2, 126 XORG_VERSION_CURRENT, 127 1, 0, 0, 128 ABI_CLASS_EXTENSION, 129 ABI_EXTENSION_VERSION, 130 MOD_CLASS_EXTENSION, 131 {0,0,0,0} 132}; 133 134/* 135 * Data for the loader 136 */ 137_X_EXPORT XF86ModuleData extmodModuleData = { &VersRec, extmodSetup, NULL }; 138 139static pointer 140extmodSetup(pointer module, pointer opts, int *errmaj, int *errmin) 141{ 142 int i; 143 144 /* XXX the option stuff here is largely a sample/test case */ 145 146 for (i = 0; extensionModules[i].name != NULL; i++) { 147 if (opts) { 148 char *s; 149 if (asprintf(&s, "omit%s", extensionModules[i].name) != -1) { 150 pointer o; 151 o = xf86FindOption(opts, s); 152 free(s); 153 if (o) { 154 xf86MarkOptionUsed(o); 155 continue; 156 } 157 } 158 } 159 160#ifdef XSELINUX 161 if (! strcmp(SELINUX_EXTENSION_NAME, extensionModules[i].name)) { 162 pointer o; 163 selinuxEnforcingState = SELINUX_MODE_DEFAULT; 164 165 if ((o = xf86FindOption(opts, "SELinux mode disabled"))) { 166 xf86MarkOptionUsed(o); 167 selinuxEnforcingState = SELINUX_MODE_DISABLED; 168 } 169 if ((o = xf86FindOption(opts, "SELinux mode permissive"))) { 170 xf86MarkOptionUsed(o); 171 selinuxEnforcingState = SELINUX_MODE_PERMISSIVE; 172 } 173 if ((o = xf86FindOption(opts, "SELinux mode enforcing"))) { 174 xf86MarkOptionUsed(o); 175 selinuxEnforcingState = SELINUX_MODE_ENFORCING; 176 } 177 } 178#endif 179 180 LoadExtension(&extensionModules[i], FALSE); 181 } 182 /* Need a non-NULL return */ 183 return (pointer)1; 184} 185