1/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86ShopwOpts.c,v 3.80 2003/10/08 14:58:27 dawes Exp $ */ 2/* 3 * Copyright 2000-2002 by Alan Hourihane, Flint Mountain, North Wales. 4 * 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 9 * documentation, and that the name of Alan Hourihane not be used in 10 * advertising or publicity pertaining to distribution of the software without 11 * specific, written prior permission. Alan Hourihane makes no representations 12 * about the suitability of this software for any purpose. It is provided 13 * "as is" without express or implied warranty. 14 * 15 * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 17 * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR 18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 19 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 20 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 21 * PERFORMANCE OF THIS SOFTWARE. 22 * 23 * Author: Marcus Schaefer, ms@suse.de 24 * 25 */ 26 27#include <ctype.h> 28#include <stdlib.h> 29#include <unistd.h> 30#include <sys/types.h> 31#include <sys/stat.h> 32#include <fcntl.h> 33#include <X11/X.h> 34#include <X11/Xmd.h> 35#include "os.h" 36#ifdef XFree86LOADER 37#include "loaderProcs.h" 38#endif 39#include "xf86.h" 40#include "xf86Config.h" 41#include "xf86_OSlib.h" 42#include "xf86Priv.h" 43/* #include "xf86PciData.h" */ 44#define IN_XSERVER 45#include "xf86Parser.h" 46#include "xf86tokens.h" 47#include "Configint.h" 48#include "xf86DDC.h" 49#if defined(__sparc__) && !defined(__OpenBSD__) 50#include "xf86Bus.h" 51#include "xf86Sbus.h" 52#endif 53#include "globals.h" 54 55static const char* 56optionTypeToSting(OptionValueType type) 57{ 58 switch (type) { 59 case OPTV_NONE: 60 return ""; 61 case OPTV_INTEGER: 62 return "<int>"; 63 case OPTV_STRING: 64 return "<str>"; 65 case OPTV_ANYSTR: 66 return "<str>"; 67 case OPTV_REAL: 68 return "<real>"; 69 case OPTV_BOOLEAN: 70 return "<bool>"; 71 case OPTV_FREQ: 72 return "<freq>"; 73 case OPTV_PERCENT: 74 return "<percent>"; 75 default: 76 return "<undef>"; 77 } 78} 79 80void DoShowOptions (void) { 81 int i = 0; 82 char **vlist = 0; 83 char *pSymbol = 0; 84 XF86ModuleData *initData = 0; 85 if (! (vlist = xf86DriverlistFromCompile())) { 86 ErrorF("Missing output drivers\n"); 87 goto bail; 88 } 89 xf86LoadModules (vlist,0); 90 free(vlist); 91 for (i = 0; i < xf86NumDrivers; i++) { 92 if (xf86DriverList[i]->AvailableOptions) { 93 OptionInfoPtr pOption = (OptionInfoPtr)(*xf86DriverList[i]->AvailableOptions)(0,0); 94 if (! pOption) { 95 ErrorF ("(EE) Couldn't read option table for %s driver\n", 96 xf86DriverList[i]->driverName 97 ); 98 continue; 99 } 100 XNFasprintf(&pSymbol, "%sModuleData", 101 xf86DriverList[i]->driverName); 102 initData = LoaderSymbol (pSymbol); 103 if (initData) { 104 XF86ModuleVersionInfo *vers = initData->vers; 105 OptionInfoPtr p; 106 ErrorF ("Driver[%d]:%s[%s] {\n", 107 i,xf86DriverList[i]->driverName,vers->vendor 108 ); 109 for (p = pOption; p->name != NULL; p++) { 110 const char *opttype = optionTypeToSting(p->type); 111 /* XXX: Why overallocate by 2 bytes? 112 * Otherwise, this would be strdup() 113 */ 114 char *optname = malloc(strlen(p->name) + 2 + 1); 115 if (!optname) { 116 continue; 117 } 118 sprintf(optname, "%s", p->name); 119 ErrorF ("\t%s:%s\n", optname,opttype); 120 } 121 ErrorF ("}\n"); 122 } 123 } 124 } 125 bail: 126 OsCleanup (TRUE); 127 AbortDDX (); 128 fflush (stderr); 129 exit (0); 130} 131