miinitext.c revision 684baedf
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#endif
59
60#ifdef HAVE_XNEST_CONFIG_H
61#include <xnest-config.h>
62#undef COMPOSITE
63#undef DPMSExtension
64#endif
65
66#ifdef HAVE_KDRIVE_CONFIG_H
67#include <kdrive-config.h>
68/* there must be a better way... */
69#undef XFreeXDGA
70#undef XF86DRI
71#undef XF86VIDMODE
72#endif
73
74#ifdef HAVE_XGL_CONFIG_H
75#include <xgl-config.h>
76#undef XFreeXDGA
77#undef XF86DRI
78#undef XF86VIDMODE
79#endif
80
81#include "misc.h"
82#include "extension.h"
83#include "micmap.h"
84#include "globals.h"
85
86
87extern Bool noTestExtensions;
88
89#ifdef COMPOSITE
90extern Bool noCompositeExtension;
91#endif
92#ifdef DBE
93extern Bool noDbeExtension;
94#endif
95#ifdef DPMSExtension
96extern Bool noDPMSExtension;
97#endif
98#ifdef GLXEXT
99extern Bool noGlxExtension;
100#endif
101#ifdef SCREENSAVER
102extern Bool noScreenSaverExtension;
103#endif
104#ifdef MITSHM
105extern Bool noMITShmExtension;
106#endif
107#ifdef MULTIBUFFER
108extern Bool noMultibufferExtension;
109#endif
110#ifdef RANDR
111extern Bool noRRExtension;
112#endif
113#ifdef RENDER
114extern Bool noRenderExtension;
115#endif
116#ifdef XCSECURITY
117extern Bool noSecurityExtension;
118#endif
119#ifdef RES
120extern Bool noResExtension;
121#endif
122#ifdef XF86BIGFONT
123extern Bool noXFree86BigfontExtension;
124#endif
125#ifdef XFreeXDGA
126extern Bool noXFree86DGAExtension;
127#endif
128#ifdef XF86DRI
129extern Bool noXFree86DRIExtension;
130#endif
131#ifdef XF86VIDMODE
132extern Bool noXFree86VidModeExtension;
133#endif
134#ifdef XFIXES
135extern Bool noXFixesExtension;
136#endif
137#ifdef XKB
138/* |noXkbExtension| is defined in xc/programs/Xserver/xkb/xkbInit.c */
139extern Bool noXkbExtension;
140#endif
141#ifdef PANORAMIX
142extern Bool noPanoramiXExtension;
143#endif
144#ifdef INXQUARTZ
145extern Bool noPseudoramiXExtension;
146#endif
147#ifdef XSELINUX
148extern Bool noSELinuxExtension;
149#endif
150#ifdef XV
151extern Bool noXvExtension;
152#endif
153extern Bool noGEExtension;
154
155#ifndef XFree86LOADER
156#define INITARGS void
157typedef void (*InitExtension)(INITARGS);
158#else /* XFree86Loader */
159#include "loaderProcs.h"
160#endif
161
162#ifdef MITSHM
163#define _XSHM_SERVER_
164#include <X11/extensions/shmstr.h>
165#include <X11/extensions/shmproto.h>
166#endif
167#ifdef XTEST
168#define _XTEST_SERVER_
169#include <X11/extensions/xtestconst.h>
170#endif
171#ifdef XKB
172#include <X11/extensions/XKB.h>
173#endif
174#ifdef XCSECURITY
175#include "securitysrv.h"
176#include <X11/extensions/securproto.h>
177#endif
178#ifdef XSELINUX
179#include "xselinux.h"
180#endif
181#ifdef PANORAMIX
182#include <X11/extensions/panoramiXproto.h>
183#endif
184#ifdef XF86BIGFONT
185#include <X11/extensions/xf86bigfstr.h>
186#endif
187#ifdef RES
188#include <X11/extensions/XResproto.h>
189#endif
190
191/* FIXME: this whole block of externs should be from the appropriate headers */
192#ifdef MITSHM
193extern void ShmExtensionInit(INITARGS);
194#endif
195#ifdef MULTIBUFFER
196extern void MultibufferExtensionInit(INITARGS);
197#endif
198#ifdef PANORAMIX
199extern void PanoramiXExtensionInit(INITARGS);
200#endif
201#ifdef INXQUARTZ
202extern void PseudoramiXExtensionInit(INITARGS);
203#endif
204extern void XInputExtensionInit(INITARGS);
205#ifdef XTEST
206extern void XTestExtensionInit(INITARGS);
207#endif
208extern void BigReqExtensionInit(INITARGS);
209#ifdef SCREENSAVER
210extern void ScreenSaverExtensionInit (INITARGS);
211#endif
212#ifdef XV
213extern void XvExtensionInit(INITARGS);
214extern void XvMCExtensionInit(INITARGS);
215#endif
216extern void SyncExtensionInit(INITARGS);
217#ifdef XKB
218extern void XkbExtensionInit(INITARGS);
219#endif
220extern void XCMiscExtensionInit(INITARGS);
221#ifdef XRECORD
222extern void RecordExtensionInit(INITARGS);
223#endif
224#ifdef DBE
225extern void DbeExtensionInit(INITARGS);
226#endif
227#ifdef XCSECURITY
228extern void SecurityExtensionInit(INITARGS);
229#endif
230#ifdef XSELINUX
231extern void SELinuxExtensionInit(INITARGS);
232#endif
233#ifdef XF86BIGFONT
234extern void XFree86BigfontExtensionInit(INITARGS);
235#endif
236#ifdef XF86VIDMODE
237extern void XFree86VidModeExtensionInit(INITARGS);
238#endif
239#ifdef XFreeXDGA
240extern void XFree86DGAExtensionInit(INITARGS);
241#endif
242#ifdef GLXEXT
243typedef struct __GLXprovider __GLXprovider;
244extern __GLXprovider __glXDRISWRastProvider;
245extern void GlxPushProvider(__GLXprovider *impl);
246extern void GlxExtensionInit(INITARGS);
247#endif
248#ifdef XF86DRI
249extern void XFree86DRIExtensionInit(INITARGS);
250#endif
251#ifdef DPMSExtension
252extern void DPMSExtensionInit(INITARGS);
253#endif
254#ifdef RENDER
255extern void RenderExtensionInit(INITARGS);
256#endif
257#ifdef RANDR
258extern void RRExtensionInit(INITARGS);
259#endif
260#ifdef RES
261extern void ResExtensionInit(INITARGS);
262#endif
263#ifdef DMXEXT
264extern void DMXExtensionInit(INITARGS);
265#endif
266#ifdef XFIXES
267extern void XFixesExtensionInit(INITARGS);
268#endif
269#ifdef DAMAGE
270extern void DamageExtensionInit(INITARGS);
271#endif
272#ifdef COMPOSITE
273extern void CompositeExtensionInit(INITARGS);
274#endif
275extern void GEExtensionInit(INITARGS);
276
277/* The following is only a small first step towards run-time
278 * configurable extensions.
279 */
280typedef struct {
281    char *name;
282    Bool *disablePtr;
283} ExtensionToggle;
284
285static ExtensionToggle ExtensionToggleList[] =
286{
287    /* sort order is extension name string as shown in xdpyinfo */
288    { "Generic Events", &noGEExtension },
289#ifdef COMPOSITE
290    { "Composite", &noCompositeExtension },
291#endif
292#ifdef DAMAGE
293    { "DAMAGE", &noDamageExtension },
294#endif
295#ifdef DBE
296    { "DOUBLE-BUFFER", &noDbeExtension },
297#endif
298#ifdef DPMSExtension
299    { "DPMS", &noDPMSExtension },
300#endif
301#ifdef GLXEXT
302    { "GLX", &noGlxExtension },
303#endif
304#ifdef SCREENSAVER
305    { "MIT-SCREEN-SAVER", &noScreenSaverExtension },
306#endif
307#ifdef MITSHM
308    { SHMNAME, &noMITShmExtension },
309#endif
310#ifdef MULTIBUFFER
311    { "Multi-Buffering", &noMultibufferExtension },
312#endif
313#ifdef RANDR
314    { "RANDR", &noRRExtension },
315#endif
316#ifdef RENDER
317    { "RENDER", &noRenderExtension },
318#endif
319#ifdef XCSECURITY
320    { "SECURITY", &noSecurityExtension },
321#endif
322#ifdef RES
323    { "X-Resource", &noResExtension },
324#endif
325#ifdef XF86BIGFONT
326    { "XFree86-Bigfont", &noXFree86BigfontExtension },
327#endif
328#ifdef XFreeXDGA
329    { "XFree86-DGA", &noXFree86DGAExtension },
330#endif
331#ifdef XF86DRI
332    { "XFree86-DRI", &noXFree86DRIExtension },
333#endif
334#ifdef XF86VIDMODE
335    { "XFree86-VidModeExtension", &noXFree86VidModeExtension },
336#endif
337#ifdef XFIXES
338    { "XFIXES", &noXFixesExtension },
339#endif
340#ifdef PANORAMIX
341    { "XINERAMA", &noPanoramiXExtension },
342#endif
343    { "XInputExtension", NULL },
344#ifdef XKB
345    { "XKEYBOARD", &noXkbExtension },
346#endif
347#ifdef XSELINUX
348    { "SELinux", &noSELinuxExtension },
349#endif
350    { "XTEST", &noTestExtensions },
351#ifdef XV
352    { "XVideo", &noXvExtension },
353#endif
354    { NULL, NULL }
355};
356
357Bool EnableDisableExtension(char *name, Bool enable)
358{
359    ExtensionToggle *ext = &ExtensionToggleList[0];
360
361    for (ext = &ExtensionToggleList[0]; ext->name != NULL; ext++) {
362	if (strcmp(name, ext->name) == 0) {
363	    *ext->disablePtr = !enable;
364	    return TRUE;
365	}
366    }
367
368    return FALSE;
369}
370
371void EnableDisableExtensionError(char *name, Bool enable)
372{
373    ExtensionToggle *ext = &ExtensionToggleList[0];
374
375    ErrorF("[mi] Extension \"%s\" is not recognized\n", name);
376    ErrorF("[mi] Only the following extensions can be run-time %s:\n",
377	   enable ? "enabled" : "disabled");
378    for (ext = &ExtensionToggleList[0]; ext->name != NULL; ext++)
379	ErrorF("[mi]    %s\n", ext->name);
380}
381
382#ifndef XFree86LOADER
383
384/*ARGSUSED*/
385void
386InitExtensions(int argc, char *argv[])
387{
388    if (!noGEExtension) GEExtensionInit();
389
390#ifdef PANORAMIX
391# if !defined(NO_PANORAMIX)
392  if (!noPanoramiXExtension) PanoramiXExtensionInit();
393# endif
394#endif
395#ifdef INXQUARTZ
396    if(!noPseudoramiXExtension) PseudoramiXExtensionInit();
397#endif
398    ShapeExtensionInit();
399#ifdef MITSHM
400    if (!noMITShmExtension) ShmExtensionInit();
401#endif
402#ifdef MULTIBUFFER
403    if (!noMultibufferExtension) MultibufferExtensionInit();
404#endif
405    XInputExtensionInit();
406#ifdef XTEST
407    if (!noTestExtensions) XTestExtensionInit();
408#endif
409    BigReqExtensionInit();
410#if defined(SCREENSAVER)
411    if (!noScreenSaverExtension) ScreenSaverExtensionInit ();
412#endif
413#ifdef XV
414    if (!noXvExtension) {
415      XvExtensionInit();
416      XvMCExtensionInit();
417    }
418#endif
419    SyncExtensionInit();
420#if defined(XKB)
421    if (!noXkbExtension) XkbExtensionInit();
422#endif
423    XCMiscExtensionInit();
424#ifdef XRECORD
425    if (!noTestExtensions) RecordExtensionInit();
426#endif
427#ifdef DBE
428    if (!noDbeExtension) DbeExtensionInit();
429#endif
430#ifdef XCSECURITY
431    if (!noSecurityExtension) SecurityExtensionInit();
432#endif
433#ifdef XSELINUX
434    if (!noSELinuxExtension) SELinuxExtensionInit();
435#endif
436#if defined(DPMSExtension) && !defined(NO_HW_ONLY_EXTS)
437    if (!noDPMSExtension) DPMSExtensionInit();
438#endif
439#ifdef XF86BIGFONT
440    if (!noXFree86BigfontExtension) XFree86BigfontExtensionInit();
441#endif
442#if !defined(NO_HW_ONLY_EXTS)
443#if defined(XF86VIDMODE)
444    if (!noXFree86VidModeExtension) XFree86VidModeExtensionInit();
445#endif
446#if defined(XFreeXDGA)
447    if (!noXFree86DGAExtension) XFree86DGAExtensionInit();
448#endif
449#ifdef XF86DRI
450    if (!noXFree86DRIExtension) XFree86DRIExtensionInit();
451#endif
452#endif
453#ifdef XFIXES
454    /* must be before Render to layer DisplayCursor correctly */
455    if (!noXFixesExtension) XFixesExtensionInit();
456#endif
457#ifdef RENDER
458    if (!noRenderExtension) RenderExtensionInit();
459#endif
460#ifdef RANDR
461    if (!noRRExtension) RRExtensionInit();
462#endif
463#ifdef RES
464    if (!noResExtension) ResExtensionInit();
465#endif
466#ifdef DMXEXT
467    DMXExtensionInit(); /* server-specific extension, cannot be disabled */
468#endif
469#ifdef COMPOSITE
470    if (!noCompositeExtension) CompositeExtensionInit();
471#endif
472#ifdef DAMAGE
473    if (!noDamageExtension) DamageExtensionInit();
474#endif
475
476#ifdef GLXEXT
477    if (serverGeneration == 1)
478	GlxPushProvider(&__glXDRISWRastProvider);
479    if (!noGlxExtension) GlxExtensionInit();
480#endif
481}
482
483#else /* XFree86LOADER */
484/* List of built-in (statically linked) extensions */
485static ExtensionModule staticExtensions[] = {
486    { GEExtensionInit, "Generic Event Extension", &noGEExtension, NULL, NULL},
487    { ShapeExtensionInit, "SHAPE", NULL, NULL, NULL },
488#ifdef MITSHM
489    { ShmExtensionInit, SHMNAME, &noMITShmExtension, NULL, NULL },
490#endif
491    { XInputExtensionInit, "XInputExtension", NULL, NULL, NULL },
492#ifdef XTEST
493    { XTestExtensionInit, XTestExtensionName, &noTestExtensions, NULL, NULL },
494#endif
495    { BigReqExtensionInit, "BIG-REQUESTS", NULL, NULL, NULL },
496    { SyncExtensionInit, "SYNC", NULL, NULL, NULL },
497#ifdef XKB
498    { XkbExtensionInit, XkbName, &noXkbExtension, NULL, NULL },
499#endif
500    { XCMiscExtensionInit, "XC-MISC", NULL, NULL, NULL },
501#ifdef XCSECURITY
502    { SecurityExtensionInit, SECURITY_EXTENSION_NAME, &noSecurityExtension, NULL, NULL },
503#endif
504#ifdef PANORAMIX
505    { PanoramiXExtensionInit, PANORAMIX_PROTOCOL_NAME, &noPanoramiXExtension, NULL, NULL },
506#endif
507#ifdef XFIXES
508    /* must be before Render to layer DisplayCursor correctly */
509    { XFixesExtensionInit, "XFIXES", &noXFixesExtension, NULL, NULL },
510#endif
511#ifdef XF86BIGFONT
512    { XFree86BigfontExtensionInit, XF86BIGFONTNAME, &noXFree86BigfontExtension, NULL, NULL },
513#endif
514#ifdef RENDER
515    { RenderExtensionInit, "RENDER", &noRenderExtension, NULL, NULL },
516#endif
517#ifdef RANDR
518    { RRExtensionInit, "RANDR", &noRRExtension, NULL, NULL },
519#endif
520#ifdef COMPOSITE
521    { CompositeExtensionInit, "COMPOSITE", &noCompositeExtension, NULL },
522#endif
523#ifdef DAMAGE
524    { DamageExtensionInit, "DAMAGE", &noDamageExtension, NULL },
525#endif
526    { NULL, NULL, NULL, NULL, NULL }
527};
528
529/*ARGSUSED*/
530void
531InitExtensions(int argc, char *argv[])
532{
533    int i;
534    ExtensionModule *ext;
535    static Bool listInitialised = FALSE;
536
537    if (!listInitialised) {
538	/* Add built-in extensions to the list. */
539	for (i = 0; staticExtensions[i].name; i++)
540	    LoadExtension(&staticExtensions[i], TRUE);
541
542	/* Sort the extensions according the init dependencies. */
543	LoaderSortExtensions();
544	listInitialised = TRUE;
545    }
546
547    for (i = 0; ExtensionModuleList[i].name != NULL; i++) {
548	ext = &ExtensionModuleList[i];
549	if (ext->initFunc != NULL &&
550	    (ext->disablePtr == NULL ||
551	     (ext->disablePtr != NULL && !*ext->disablePtr))) {
552	    (ext->initFunc)();
553	}
554    }
555}
556
557#endif /* XFree86LOADER */
558