Index: Imakefile =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/common/Imakefile,v retrieving revision 1.16 diff -u -r1.16 Imakefile --- Imakefile 10 Oct 2005 07:08:44 -0000 1.16 +++ Imakefile 9 Jan 2006 10:28:28 -0000 @@ -79,6 +79,7 @@ SRCS = \ xf86Configure.c \ + xf86ShowOpts.c \ xf86Bus.c \ xf86isaBus.c \ xf86pciBus.c \ @@ -120,6 +121,7 @@ OBJS = \ xf86Configure.o \ + xf86ShowOpts.o \ xf86Bus.o \ xf86isaBus.o \ xf86pciBus.o \ Index: xf86.h =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/common/xf86.h,v retrieving revision 1.10 diff -u -r1.10 xf86.h --- xf86.h 29 Oct 2005 21:31:23 -0000 1.10 +++ xf86.h 9 Jan 2006 10:28:28 -0000 @@ -53,6 +53,7 @@ /* General parameters */ extern int xf86DoConfigure; +extern int xf86DoShowOptions; extern Bool xf86DoConfigurePass1; extern int xf86ScreenIndex; /* Index into pScreen.devPrivates */ extern int xf86CreateRootWindowIndex; /* Index into pScreen.devPrivates */ Index: xf86Globals.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/common/xf86Globals.c,v retrieving revision 1.9 diff -u -r1.9 xf86Globals.c --- xf86Globals.c 14 Dec 2005 20:12:00 -0000 1.9 +++ xf86Globals.c 9 Jan 2006 10:28:28 -0000 @@ -189,6 +189,7 @@ Bool xf86ProbeFailed = FALSE; Bool xf86DoProbe = FALSE; Bool xf86DoConfigure = FALSE; +Bool xf86DoShowOptions = FALSE; #ifdef XFree86LOADER DriverPtr *xf86DriverList = NULL; int xf86NumDrivers = 0; Index: xf86Init.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/common/xf86Init.c,v retrieving revision 1.29 diff -u -r1.29 xf86Init.c --- xf86Init.c 14 Dec 2005 20:12:00 -0000 1.29 +++ xf86Init.c 9 Jan 2006 10:28:28 -0000 @@ -323,7 +323,7 @@ } /* Read and parse the config file */ - if (!xf86DoProbe && !xf86DoConfigure) { + if (!xf86DoProbe && !xf86DoConfigure && !xf86DoShowOptions) { switch (xf86HandleConfigFile(FALSE)) { case CONFIG_OK: break; @@ -385,6 +385,9 @@ #endif + if (xf86DoShowOptions) + DoShowOptions(); + xf86OpenConsole(); /* Do a general bus probe. This will be a PCI probe for x86 platforms */ @@ -1687,6 +1690,15 @@ xf86AllowMouseOpenFail = TRUE; return 1; } + if (!strcmp(argv[i], "-showopts")) + { + if (getuid() != 0 && geteuid == 0) { + ErrorF("The '-showopts' option can only be used by root.\n"); + exit(1); + } + xf86DoShowOptions = TRUE; + return 1; + } if (!strcmp(argv[i], "-isolateDevice")) { int bus, device, func; @@ -1729,6 +1741,7 @@ ErrorF("-modulepath paths specify the module search path\n"); ErrorF("-logfile file specify a log file name\n"); ErrorF("-configure probe for devices and write an "__XCONFIGFILE__"\n"); + ErrorF("-showopts print available options for all installed drivers\n"); } ErrorF("-config file specify a configuration file, relative to the\n"); ErrorF(" "__XCONFIGFILE__" search path, only root can use absolute\n"); Index: xf86Priv.h =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/common/xf86Priv.h,v retrieving revision 1.7 diff -u -r1.7 xf86Priv.h --- xf86Priv.h 14 Dec 2005 20:12:00 -0000 1.7 +++ xf86Priv.h 9 Jan 2006 10:28:28 -0000 @@ -174,6 +174,7 @@ void DoProbeArgs(int argc, char **argv, int i); void DoProbe(void); void DoConfigure(void); +void DoShowOptions(void); /* xf86Events.c */ Index: xf86ShowOpts.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/common/xf86ShowOpts.c,v retrieving revision diff -u /dev/null xf86ShowOpts.c --- /dev/null 2006-01-03 13:55:53.000000000 +0100 +++ xf86ShowOpts.c 2006-01-09 11:21:10.000000000 +0100 @@ -0,0 +1,129 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86ShopwOpts.c,v 3.80 2003/10/08 14:58:27 dawes Exp $ */ +/* + * Copyright 2000-2002 by Alan Hourihane, Flint Mountain, North Wales. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Alan Hourihane not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Alan Hourihane makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + * Author: Marcus Schaefer, ms@suse.de + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "os.h" +#ifdef XFree86LOADER +#include "loaderProcs.h" +#endif +#include "xf86.h" +#include "xf86Config.h" +#include "xf86_OSlib.h" +#include "xf86Priv.h" +#include "xf86PciData.h" +#define IN_XSERVER +#include "xf86Parser.h" +#include "xf86tokens.h" +#include "Configint.h" +#include "vbe.h" +#include "xf86DDC.h" +#if defined(__sparc__) && !defined(__OpenBSD__) +#include "xf86Bus.h" +#include "xf86Sbus.h" +#endif +#include "globals.h" + +static const char* +optionTypeToSting(OptionValueType type) +{ + switch (type) { + case OPTV_NONE: + return ""; + case OPTV_INTEGER: + return ""; + case OPTV_STRING: + return ""; + case OPTV_ANYSTR: + return ""; + case OPTV_REAL: + return ""; + case OPTV_BOOLEAN: + return ""; + case OPTV_FREQ: + return ""; + default: + return ""; + } +} + +void DoShowOptions (void) { + int i = 0; + char **vlist = 0; + char *pSymbol = 0; + XF86ModuleData *initData = 0; + if (! (vlist = xf86DriverlistFromCompile())) { + ErrorF("Missing output drivers\n"); + goto bail; + } + xf86LoadModules (vlist,0); + xfree (vlist); + for (i = 0; i < xf86NumDrivers; i++) { + if (xf86DriverList[i]->AvailableOptions) { + OptionInfoPtr pOption = (OptionInfoPtr)(*xf86DriverList[i]->AvailableOptions)(0,0); + if (! pOption) { + ErrorF ("(EE) Couldn't read option table for %s driver\n", + xf86DriverList[i]->driverName + ); + continue; + } + pSymbol = xalloc ( + strlen(xf86DriverList[i]->driverName) + strlen("ModuleData") + 1 + ); + strcpy (pSymbol, xf86DriverList[i]->driverName); + strcat (pSymbol, "ModuleData"); + initData = LoaderSymbol (pSymbol); + if (initData) { + XF86ModuleVersionInfo *vers = initData->vers; + ErrorF ("Driver[%d]:%s[%s] {\n", + i,xf86DriverList[i]->driverName,vers->vendor + ); + OptionInfoPtr p; + for (p = pOption; p->name != NULL; p++) { + const char *opttype = optionTypeToSting(p->type); + char *optname = xalloc(strlen(p->name) + 2 + 1); + if (!optname) { + continue; + } + sprintf(optname, "%s", p->name); + ErrorF ("\t%s:%s\n", optname,opttype); + } + ErrorF ("}\n"); + } + } + } + bail: + OsCleanup (TRUE); + AbortDDX (); + fflush (stderr); + exit (0); +}