2006-11-26 11:13:41 -07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1998-2003 by The XFree86 Project, Inc.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
* Except as contained in this notice, the name of the copyright holder(s)
|
|
|
|
* and author(s) shall not be used in advertising or otherwise to promote
|
|
|
|
* the sale, use or other dealings in this Software without prior written
|
|
|
|
* authorization from the copyright holder(s) and author(s).
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Author: David Dawes <dawes@xfree86.org>
|
|
|
|
*
|
|
|
|
* This file includes public option handling functions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_XORG_CONFIG_H
|
|
|
|
#include <xorg-config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <X11/X.h>
|
|
|
|
#include "os.h"
|
|
|
|
#include "xf86.h"
|
2012-06-10 07:21:05 -06:00
|
|
|
#include "xf86Opt.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
#include "xf86Xinput.h"
|
|
|
|
#include "xf86Optrec.h"
|
2010-07-27 13:02:24 -06:00
|
|
|
#include "xf86Parser.h"
|
2012-06-10 07:21:05 -06:00
|
|
|
#include "optionstr.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static Bool ParseOptionValue(int scrnIndex, XF86OptionPtr options,
|
|
|
|
OptionInfoPtr p, Bool markUsed);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* xf86CollectOptions collects the options from each of the config file
|
|
|
|
* sections used by the screen and puts the combined list in pScrn->options.
|
|
|
|
* This function requires that the following have been initialised:
|
|
|
|
*
|
|
|
|
* pScrn->confScreen
|
|
|
|
* pScrn->Entities[i]->device
|
|
|
|
* pScrn->display
|
|
|
|
* pScrn->monitor
|
|
|
|
*
|
|
|
|
* The extraOpts parameter may optionally contain a list of additional options
|
|
|
|
* to include.
|
|
|
|
*
|
|
|
|
* The order of precedence for options is:
|
|
|
|
*
|
|
|
|
* extraOpts, display, confScreen, monitor, device
|
|
|
|
*/
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86CollectOptions(ScrnInfoPtr pScrn, XF86OptionPtr extraOpts)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
XF86OptionPtr tmp;
|
2012-06-10 07:21:05 -06:00
|
|
|
XF86OptionPtr extras = (XF86OptionPtr) extraOpts;
|
2006-11-26 11:13:41 -07:00
|
|
|
GDevPtr device;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
int i;
|
|
|
|
|
|
|
|
pScrn->options = NULL;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = pScrn->numEntities - 1; i >= 0; i--) {
|
|
|
|
device = xf86GetDevFromEntity(pScrn->entityList[i],
|
|
|
|
pScrn->entityInstanceList[i]);
|
|
|
|
if (device && device->options) {
|
|
|
|
tmp = xf86optionListDup(device->options);
|
|
|
|
if (pScrn->options)
|
|
|
|
xf86optionListMerge(pScrn->options, tmp);
|
|
|
|
else
|
|
|
|
pScrn->options = tmp;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (pScrn->monitor->options) {
|
2012-06-10 07:21:05 -06:00
|
|
|
tmp = xf86optionListDup(pScrn->monitor->options);
|
|
|
|
if (pScrn->options)
|
|
|
|
pScrn->options = xf86optionListMerge(pScrn->options, tmp);
|
|
|
|
else
|
|
|
|
pScrn->options = tmp;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (pScrn->confScreen->options) {
|
2012-06-10 07:21:05 -06:00
|
|
|
tmp = xf86optionListDup(pScrn->confScreen->options);
|
|
|
|
if (pScrn->options)
|
|
|
|
pScrn->options = xf86optionListMerge(pScrn->options, tmp);
|
|
|
|
else
|
|
|
|
pScrn->options = tmp;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (pScrn->display->options) {
|
2012-06-10 07:21:05 -06:00
|
|
|
tmp = xf86optionListDup(pScrn->display->options);
|
|
|
|
if (pScrn->options)
|
|
|
|
pScrn->options = xf86optionListMerge(pScrn->options, tmp);
|
|
|
|
else
|
|
|
|
pScrn->options = tmp;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (extras) {
|
2012-06-10 07:21:05 -06:00
|
|
|
tmp = xf86optionListDup(extras);
|
|
|
|
if (pScrn->options)
|
|
|
|
pScrn->options = xf86optionListMerge(pScrn->options, tmp);
|
|
|
|
else
|
|
|
|
pScrn->options = tmp;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2011-11-05 07:32:40 -06:00
|
|
|
* xf86CollectInputOptions collects extra options for an InputDevice (other
|
|
|
|
* than those added by the config backend).
|
|
|
|
* The options are merged into the existing ones and thus take precedence
|
|
|
|
* over the others.
|
2006-11-26 11:13:41 -07:00
|
|
|
*/
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2011-11-05 07:32:40 -06:00
|
|
|
xf86CollectInputOptions(InputInfoPtr pInfo, const char **defaultOpts)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
if (defaultOpts) {
|
2012-06-10 07:21:05 -06:00
|
|
|
XF86OptionPtr tmp = xf86optionListCreate(defaultOpts, -1, 0);
|
|
|
|
|
|
|
|
if (pInfo->options)
|
|
|
|
pInfo->options = xf86optionListMerge(tmp, pInfo->options);
|
|
|
|
else
|
|
|
|
pInfo->options = tmp;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2011-11-05 07:32:40 -06:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
/**
|
|
|
|
* Duplicate the option list passed in. The returned pointer will be a newly
|
|
|
|
* allocated option list and must be freed by the caller.
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
XF86OptionPtr
|
|
|
|
xf86OptionListDuplicate(XF86OptionPtr options)
|
2011-11-05 07:32:40 -06:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XF86OptionPtr o = NULL;
|
2011-11-05 07:32:40 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
while (options) {
|
|
|
|
o = xf86AddNewOption(o, xf86OptionName(options),
|
|
|
|
xf86OptionValue(options));
|
2011-11-05 07:32:40 -06:00
|
|
|
options = xf86nextOption(options);
|
2010-12-05 08:36:02 -07:00
|
|
|
}
|
2011-11-05 07:32:40 -06:00
|
|
|
|
|
|
|
return o;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Created for new XInput stuff -- essentially extensions to the parser */
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
LookupIntOption(XF86OptionPtr optlist, const char *name, int deflt,
|
|
|
|
Bool markUsed)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
OptionInfoRec o;
|
|
|
|
|
|
|
|
o.name = name;
|
|
|
|
o.type = OPTV_INTEGER;
|
|
|
|
if (ParseOptionValue(-1, optlist, &o, markUsed))
|
2012-06-10 07:21:05 -06:00
|
|
|
deflt = o.value.num;
|
2006-11-26 11:13:41 -07:00
|
|
|
return deflt;
|
|
|
|
}
|
|
|
|
|
|
|
|
static double
|
2012-06-10 07:21:05 -06:00
|
|
|
LookupRealOption(XF86OptionPtr optlist, const char *name, double deflt,
|
|
|
|
Bool markUsed)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
OptionInfoRec o;
|
|
|
|
|
|
|
|
o.name = name;
|
|
|
|
o.type = OPTV_REAL;
|
|
|
|
if (ParseOptionValue(-1, optlist, &o, markUsed))
|
2012-06-10 07:21:05 -06:00
|
|
|
deflt = o.value.realnum;
|
2006-11-26 11:13:41 -07:00
|
|
|
return deflt;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
2012-06-10 07:21:05 -06:00
|
|
|
LookupStrOption(XF86OptionPtr optlist, const char *name, const char *deflt,
|
|
|
|
Bool markUsed)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
OptionInfoRec o;
|
|
|
|
|
|
|
|
o.name = name;
|
|
|
|
o.type = OPTV_STRING;
|
|
|
|
if (ParseOptionValue(-1, optlist, &o, markUsed))
|
|
|
|
deflt = o.value.str;
|
|
|
|
if (deflt)
|
2012-06-10 07:21:05 -06:00
|
|
|
return strdup(deflt);
|
2006-11-26 11:13:41 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
LookupBoolOption(XF86OptionPtr optlist, const char *name, int deflt,
|
|
|
|
Bool markUsed)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
OptionInfoRec o;
|
|
|
|
|
|
|
|
o.name = name;
|
|
|
|
o.type = OPTV_BOOLEAN;
|
|
|
|
if (ParseOptionValue(-1, optlist, &o, markUsed))
|
2012-06-10 07:21:05 -06:00
|
|
|
deflt = o.value.bool;
|
2006-11-26 11:13:41 -07:00
|
|
|
return deflt;
|
|
|
|
}
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
static double
|
2012-06-10 07:21:05 -06:00
|
|
|
LookupPercentOption(XF86OptionPtr optlist, const char *name, double deflt,
|
|
|
|
Bool markUsed)
|
2010-12-05 08:36:02 -07:00
|
|
|
{
|
|
|
|
OptionInfoRec o;
|
|
|
|
|
|
|
|
o.name = name;
|
|
|
|
o.type = OPTV_PERCENT;
|
|
|
|
if (ParseOptionValue(-1, optlist, &o, markUsed))
|
2012-06-10 07:21:05 -06:00
|
|
|
deflt = o.value.realnum;
|
2010-12-05 08:36:02 -07:00
|
|
|
return deflt;
|
|
|
|
}
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/* These xf86Set* functions are intended for use by non-screen specific code */
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86SetIntOption(XF86OptionPtr optlist, const char *name, int deflt)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
return LookupIntOption(optlist, name, deflt, TRUE);
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
double
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86SetRealOption(XF86OptionPtr optlist, const char *name, double deflt)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
return LookupRealOption(optlist, name, deflt, TRUE);
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
char *
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86SetStrOption(XF86OptionPtr optlist, const char *name, const char *deflt)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
return LookupStrOption(optlist, name, deflt, TRUE);
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86SetBoolOption(XF86OptionPtr optlist, const char *name, int deflt)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
return LookupBoolOption(optlist, name, deflt, TRUE);
|
|
|
|
}
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
double
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86SetPercentOption(XF86OptionPtr optlist, const char *name, double deflt)
|
2010-12-05 08:36:02 -07:00
|
|
|
{
|
|
|
|
return LookupPercentOption(optlist, name, deflt, TRUE);
|
|
|
|
}
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/*
|
|
|
|
* These are like the Set*Option functions, but they don't mark the options
|
|
|
|
* as used.
|
|
|
|
*/
|
2010-07-27 13:02:24 -06:00
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86CheckIntOption(XF86OptionPtr optlist, const char *name, int deflt)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
return LookupIntOption(optlist, name, deflt, FALSE);
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
double
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86CheckRealOption(XF86OptionPtr optlist, const char *name, double deflt)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
return LookupRealOption(optlist, name, deflt, FALSE);
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
char *
|
2013-06-07 11:28:45 -06:00
|
|
|
xf86CheckStrOption(XF86OptionPtr optlist, const char *name, const char *deflt)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
return LookupStrOption(optlist, name, deflt, FALSE);
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86CheckBoolOption(XF86OptionPtr optlist, const char *name, int deflt)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
return LookupBoolOption(optlist, name, deflt, FALSE);
|
|
|
|
}
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
double
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86CheckPercentOption(XF86OptionPtr optlist, const char *name, double deflt)
|
2010-12-05 08:36:02 -07:00
|
|
|
{
|
|
|
|
return LookupPercentOption(optlist, name, deflt, FALSE);
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/*
|
2012-06-10 07:21:05 -06:00
|
|
|
* xf86AddNewOption() has the required property of replacing the option value
|
2006-11-26 11:13:41 -07:00
|
|
|
* if the option is already present.
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
XF86OptionPtr
|
|
|
|
xf86ReplaceIntOption(XF86OptionPtr optlist, const char *name, const int val)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
char tmp[16];
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
snprintf(tmp, sizeof(tmp), "%i", val);
|
|
|
|
return xf86AddNewOption(optlist, name, tmp);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
XF86OptionPtr
|
|
|
|
xf86ReplaceRealOption(XF86OptionPtr optlist, const char *name, const double val)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
char tmp[32];
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
snprintf(tmp, sizeof(tmp), "%f", val);
|
|
|
|
return xf86AddNewOption(optlist, name, tmp);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
XF86OptionPtr
|
|
|
|
xf86ReplaceBoolOption(XF86OptionPtr optlist, const char *name, const Bool val)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
return xf86AddNewOption(optlist, name, val ? "True" : "False");
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
XF86OptionPtr
|
|
|
|
xf86ReplacePercentOption(XF86OptionPtr optlist, const char *name,
|
|
|
|
const double val)
|
2010-12-05 08:36:02 -07:00
|
|
|
{
|
|
|
|
char tmp[16];
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
snprintf(tmp, sizeof(tmp), "%lf%%", val);
|
|
|
|
return xf86AddNewOption(optlist, name, tmp);
|
2010-12-05 08:36:02 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
XF86OptionPtr
|
|
|
|
xf86ReplaceStrOption(XF86OptionPtr optlist, const char *name, const char *val)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
return xf86AddNewOption(optlist, name, val);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
XF86OptionPtr
|
|
|
|
xf86AddNewOption(XF86OptionPtr head, const char *name, const char *val)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
/* XXX These should actually be allocated in the parser library. */
|
2011-11-05 07:32:40 -06:00
|
|
|
char *tmp = val ? strdup(val) : NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
char *tmp_name = strdup(name);
|
|
|
|
|
|
|
|
return xf86addNewOption(head, tmp_name, tmp);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
XF86OptionPtr
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86NewOption(char *name, char *value)
|
|
|
|
{
|
|
|
|
return xf86newOption(name, value);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
XF86OptionPtr
|
|
|
|
xf86NextOption(XF86OptionPtr list)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
return xf86nextOption(list);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
XF86OptionPtr
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86OptionListCreate(const char **options, int count, int used)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
return xf86optionListCreate(options, count, used);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
XF86OptionPtr
|
|
|
|
xf86OptionListMerge(XF86OptionPtr head, XF86OptionPtr tail)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
return xf86optionListMerge(head, tail);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86OptionListFree(XF86OptionPtr opt)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86optionListFree(opt);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
char *
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86OptionName(XF86OptionPtr opt)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
return xf86optionName(opt);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
char *
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86OptionValue(XF86OptionPtr opt)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
return xf86optionValue(opt);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86OptionListReport(XF86OptionPtr parm)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
XF86OptionPtr opts = parm;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
while (opts) {
|
|
|
|
if (xf86optionValue(opts))
|
|
|
|
xf86ErrorFVerb(5, "\tOption \"%s\" \"%s\"\n",
|
|
|
|
xf86optionName(opts), xf86optionValue(opts));
|
|
|
|
else
|
|
|
|
xf86ErrorFVerb(5, "\tOption \"%s\"\n", xf86optionName(opts));
|
|
|
|
opts = xf86nextOption(opts);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* End of XInput-caused section */
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
XF86OptionPtr
|
|
|
|
xf86FindOption(XF86OptionPtr options, const char *name)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
return xf86findOption(options, name);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
const char *
|
|
|
|
xf86FindOptionValue(XF86OptionPtr options, const char *name)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
return xf86findOptionValue(options, name);
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86MarkOptionUsed(XF86OptionPtr option)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
if (option != NULL)
|
2012-06-10 07:21:05 -06:00
|
|
|
option->opt_used = TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86MarkOptionUsedByName(XF86OptionPtr options, const char *name)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
XF86OptionPtr opt;
|
|
|
|
|
|
|
|
opt = xf86findOption(options, name);
|
|
|
|
if (opt != NULL)
|
2012-06-10 07:21:05 -06:00
|
|
|
opt->opt_used = TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86CheckIfOptionUsed(XF86OptionPtr option)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
if (option != NULL)
|
2012-06-10 07:21:05 -06:00
|
|
|
return option->opt_used;
|
2006-11-26 11:13:41 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86CheckIfOptionUsedByName(XF86OptionPtr options, const char *name)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
XF86OptionPtr opt;
|
|
|
|
|
|
|
|
opt = xf86findOption(options, name);
|
|
|
|
if (opt != NULL)
|
2012-06-10 07:21:05 -06:00
|
|
|
return opt->opt_used;
|
2006-11-26 11:13:41 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86ShowUnusedOptions(int scrnIndex, XF86OptionPtr opt)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
while (opt) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (opt->opt_name && !opt->opt_used) {
|
|
|
|
xf86DrvMsg(scrnIndex, X_WARNING, "Option \"%s\" is not used\n",
|
|
|
|
opt->opt_name);
|
|
|
|
}
|
|
|
|
opt = opt->list.next;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
GetBoolValue(OptionInfoPtr p, const char *s)
|
|
|
|
{
|
2010-07-27 13:02:24 -06:00
|
|
|
return xf86getBoolValue(&p->value.bool, s);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
ParseOptionValue(int scrnIndex, XF86OptionPtr options, OptionInfoPtr p,
|
|
|
|
Bool markUsed)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
char *s, *end;
|
|
|
|
Bool wasUsed = FALSE;
|
|
|
|
|
|
|
|
if ((s = xf86findOptionValue(options, p->name)) != NULL) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (markUsed) {
|
|
|
|
wasUsed = xf86CheckIfOptionUsedByName(options, p->name);
|
|
|
|
xf86MarkOptionUsedByName(options, p->name);
|
|
|
|
}
|
|
|
|
switch (p->type) {
|
|
|
|
case OPTV_INTEGER:
|
|
|
|
if (*s == '\0') {
|
|
|
|
if (markUsed) {
|
|
|
|
xf86DrvMsg(scrnIndex, X_WARNING,
|
|
|
|
"Option \"%s\" requires an integer value\n",
|
|
|
|
p->name);
|
|
|
|
}
|
|
|
|
p->found = FALSE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
p->value.num = strtoul(s, &end, 0);
|
|
|
|
if (*end == '\0') {
|
|
|
|
p->found = TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (markUsed) {
|
|
|
|
xf86DrvMsg(scrnIndex, X_WARNING,
|
|
|
|
"Option \"%s\" requires an integer value\n",
|
|
|
|
p->name);
|
|
|
|
}
|
|
|
|
p->found = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case OPTV_STRING:
|
|
|
|
if (*s == '\0') {
|
|
|
|
if (markUsed) {
|
|
|
|
xf86DrvMsg(scrnIndex, X_WARNING,
|
2013-06-07 11:28:45 -06:00
|
|
|
"Option \"%s\" requires a string value\n",
|
2012-06-10 07:21:05 -06:00
|
|
|
p->name);
|
|
|
|
}
|
|
|
|
p->found = FALSE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
p->value.str = s;
|
|
|
|
p->found = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case OPTV_ANYSTR:
|
|
|
|
p->value.str = s;
|
|
|
|
p->found = TRUE;
|
|
|
|
break;
|
|
|
|
case OPTV_REAL:
|
|
|
|
if (*s == '\0') {
|
|
|
|
if (markUsed) {
|
|
|
|
xf86DrvMsg(scrnIndex, X_WARNING,
|
|
|
|
"Option \"%s\" requires a floating point "
|
|
|
|
"value\n", p->name);
|
|
|
|
}
|
|
|
|
p->found = FALSE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
p->value.realnum = strtod(s, &end);
|
|
|
|
if (*end == '\0') {
|
|
|
|
p->found = TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (markUsed) {
|
|
|
|
xf86DrvMsg(scrnIndex, X_WARNING,
|
|
|
|
"Option \"%s\" requires a floating point "
|
|
|
|
"value\n", p->name);
|
|
|
|
}
|
|
|
|
p->found = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case OPTV_BOOLEAN:
|
|
|
|
if (GetBoolValue(p, s)) {
|
|
|
|
p->found = TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (markUsed) {
|
|
|
|
xf86DrvMsg(scrnIndex, X_WARNING,
|
|
|
|
"Option \"%s\" requires a boolean value\n",
|
|
|
|
p->name);
|
|
|
|
}
|
|
|
|
p->found = FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case OPTV_PERCENT:
|
|
|
|
{
|
|
|
|
char tmp = 0;
|
|
|
|
|
|
|
|
/* awkward match, but %% doesn't increase the match counter,
|
|
|
|
* hence 100 looks the same as 100% to the caller of sccanf
|
|
|
|
*/
|
|
|
|
if (sscanf(s, "%lf%c", &p->value.realnum, &tmp) != 2 || tmp != '%') {
|
|
|
|
if (markUsed) {
|
|
|
|
xf86DrvMsg(scrnIndex, X_WARNING,
|
|
|
|
"Option \"%s\" requires a percent value\n",
|
|
|
|
p->name);
|
|
|
|
}
|
|
|
|
p->found = FALSE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
p->found = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case OPTV_FREQ:
|
|
|
|
if (*s == '\0') {
|
|
|
|
if (markUsed) {
|
|
|
|
xf86DrvMsg(scrnIndex, X_WARNING,
|
|
|
|
"Option \"%s\" requires a frequency value\n",
|
|
|
|
p->name);
|
|
|
|
}
|
|
|
|
p->found = FALSE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
double freq = strtod(s, &end);
|
|
|
|
int units = 0;
|
|
|
|
|
|
|
|
if (end != s) {
|
|
|
|
p->found = TRUE;
|
|
|
|
if (!xf86NameCmp(end, "Hz"))
|
|
|
|
units = 1;
|
|
|
|
else if (!xf86NameCmp(end, "kHz") || !xf86NameCmp(end, "k"))
|
|
|
|
units = 1000;
|
|
|
|
else if (!xf86NameCmp(end, "MHz") || !xf86NameCmp(end, "M"))
|
|
|
|
units = 1000000;
|
|
|
|
else {
|
|
|
|
if (markUsed) {
|
|
|
|
xf86DrvMsg(scrnIndex, X_WARNING,
|
|
|
|
"Option \"%s\" requires a frequency value\n",
|
|
|
|
p->name);
|
|
|
|
}
|
|
|
|
p->found = FALSE;
|
|
|
|
}
|
|
|
|
if (p->found)
|
|
|
|
freq *= (double) units;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (markUsed) {
|
|
|
|
xf86DrvMsg(scrnIndex, X_WARNING,
|
|
|
|
"Option \"%s\" requires a frequency value\n",
|
|
|
|
p->name);
|
|
|
|
}
|
|
|
|
p->found = FALSE;
|
|
|
|
}
|
|
|
|
if (p->found) {
|
|
|
|
p->value.freq.freq = freq;
|
|
|
|
p->value.freq.units = units;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case OPTV_NONE:
|
|
|
|
/* Should never get here */
|
|
|
|
p->found = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (p->found && markUsed) {
|
|
|
|
int verb = 2;
|
|
|
|
|
|
|
|
if (wasUsed)
|
|
|
|
verb = 4;
|
|
|
|
xf86DrvMsgVerb(scrnIndex, X_CONFIG, verb, "Option \"%s\"", p->name);
|
|
|
|
if (!(p->type == OPTV_BOOLEAN && *s == 0)) {
|
|
|
|
xf86ErrorFVerb(verb, " \"%s\"", s);
|
|
|
|
}
|
|
|
|
xf86ErrorFVerb(verb, "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (p->type == OPTV_BOOLEAN) {
|
|
|
|
/* Look for matches with options with or without a "No" prefix. */
|
|
|
|
char *n, *newn;
|
|
|
|
OptionInfoRec opt;
|
|
|
|
|
|
|
|
n = xf86NormalizeName(p->name);
|
|
|
|
if (!n) {
|
|
|
|
p->found = FALSE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (strncmp(n, "no", 2) == 0) {
|
|
|
|
newn = n + 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
free(n);
|
|
|
|
if (asprintf(&n, "No%s", p->name) == -1) {
|
|
|
|
p->found = FALSE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
newn = n;
|
|
|
|
}
|
|
|
|
if ((s = xf86findOptionValue(options, newn)) != NULL) {
|
|
|
|
if (markUsed)
|
|
|
|
xf86MarkOptionUsedByName(options, newn);
|
|
|
|
if (GetBoolValue(&opt, s)) {
|
|
|
|
p->value.bool = !opt.value.bool;
|
|
|
|
p->found = TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
xf86DrvMsg(scrnIndex, X_WARNING,
|
|
|
|
"Option \"%s\" requires a boolean value\n", newn);
|
|
|
|
p->found = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
p->found = FALSE;
|
|
|
|
}
|
|
|
|
if (p->found && markUsed) {
|
|
|
|
xf86DrvMsgVerb(scrnIndex, X_CONFIG, 2, "Option \"%s\"", newn);
|
|
|
|
if (*s != 0) {
|
|
|
|
xf86ErrorFVerb(2, " \"%s\"", s);
|
|
|
|
}
|
|
|
|
xf86ErrorFVerb(2, "\n");
|
|
|
|
}
|
|
|
|
free(n);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
p->found = FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return p->found;
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86ProcessOptions(int scrnIndex, XF86OptionPtr options, OptionInfoPtr optinfo)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
OptionInfoPtr p;
|
|
|
|
|
|
|
|
for (p = optinfo; p->name != NULL; p++) {
|
2012-06-10 07:21:05 -06:00
|
|
|
ParseOptionValue(scrnIndex, options, p, TRUE);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
OptionInfoPtr
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86TokenToOptinfo(const OptionInfoRec * table, int token)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
const OptionInfoRec *p, *match = NULL, *set = NULL;
|
|
|
|
|
|
|
|
if (!table) {
|
2012-06-10 07:21:05 -06:00
|
|
|
ErrorF("xf86TokenToOptinfo: table is NULL\n");
|
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
for (p = table; p->token >= 0; p++) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (p->token == token) {
|
|
|
|
match = p;
|
|
|
|
if (p->found)
|
|
|
|
set = p;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (set)
|
2012-06-10 07:21:05 -06:00
|
|
|
return (OptionInfoPtr) set;
|
2006-11-26 11:13:41 -07:00
|
|
|
else if (match)
|
2012-06-10 07:21:05 -06:00
|
|
|
return (OptionInfoPtr) match;
|
2006-11-26 11:13:41 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
const char *
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86TokenToOptName(const OptionInfoRec * table, int token)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
const OptionInfoRec *p;
|
|
|
|
|
|
|
|
p = xf86TokenToOptinfo(table, token);
|
|
|
|
return p->name;
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86IsOptionSet(const OptionInfoRec * table, int token)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
OptionInfoPtr p;
|
|
|
|
|
|
|
|
p = xf86TokenToOptinfo(table, token);
|
2010-12-05 08:36:02 -07:00
|
|
|
return p && p->found;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
char *
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86GetOptValString(const OptionInfoRec * table, int token)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
OptionInfoPtr p;
|
|
|
|
|
|
|
|
p = xf86TokenToOptinfo(table, token);
|
|
|
|
if (p && p->found)
|
2012-06-10 07:21:05 -06:00
|
|
|
return p->value.str;
|
2006-11-26 11:13:41 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86GetOptValInteger(const OptionInfoRec * table, int token, int *value)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
OptionInfoPtr p;
|
|
|
|
|
|
|
|
p = xf86TokenToOptinfo(table, token);
|
|
|
|
if (p && p->found) {
|
2012-06-10 07:21:05 -06:00
|
|
|
*value = p->value.num;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86GetOptValULong(const OptionInfoRec * table, int token, unsigned long *value)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
OptionInfoPtr p;
|
|
|
|
|
|
|
|
p = xf86TokenToOptinfo(table, token);
|
|
|
|
if (p && p->found) {
|
2012-06-10 07:21:05 -06:00
|
|
|
*value = p->value.num;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86GetOptValReal(const OptionInfoRec * table, int token, double *value)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
OptionInfoPtr p;
|
|
|
|
|
|
|
|
p = xf86TokenToOptinfo(table, token);
|
|
|
|
if (p && p->found) {
|
2012-06-10 07:21:05 -06:00
|
|
|
*value = p->value.realnum;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86GetOptValFreq(const OptionInfoRec * table, int token,
|
|
|
|
OptFreqUnits expectedUnits, double *value)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
OptionInfoPtr p;
|
|
|
|
|
|
|
|
p = xf86TokenToOptinfo(table, token);
|
|
|
|
if (p && p->found) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (p->value.freq.units > 0) {
|
|
|
|
/* Units give, so the scaling is known. */
|
|
|
|
switch (expectedUnits) {
|
|
|
|
case OPTUNITS_HZ:
|
|
|
|
*value = p->value.freq.freq;
|
|
|
|
break;
|
|
|
|
case OPTUNITS_KHZ:
|
|
|
|
*value = p->value.freq.freq / 1000.0;
|
|
|
|
break;
|
|
|
|
case OPTUNITS_MHZ:
|
|
|
|
*value = p->value.freq.freq / 1000000.0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* No units given, so try to guess the scaling. */
|
|
|
|
switch (expectedUnits) {
|
|
|
|
case OPTUNITS_HZ:
|
|
|
|
*value = p->value.freq.freq;
|
|
|
|
break;
|
|
|
|
case OPTUNITS_KHZ:
|
|
|
|
if (p->value.freq.freq > 1000.0)
|
|
|
|
*value = p->value.freq.freq / 1000.0;
|
|
|
|
else
|
|
|
|
*value = p->value.freq.freq;
|
|
|
|
break;
|
|
|
|
case OPTUNITS_MHZ:
|
|
|
|
if (p->value.freq.freq > 1000000.0)
|
|
|
|
*value = p->value.freq.freq / 1000000.0;
|
|
|
|
else if (p->value.freq.freq > 1000.0)
|
|
|
|
*value = p->value.freq.freq / 1000.0;
|
|
|
|
else
|
|
|
|
*value = p->value.freq.freq;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86GetOptValBool(const OptionInfoRec * table, int token, Bool *value)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
OptionInfoPtr p;
|
|
|
|
|
|
|
|
p = xf86TokenToOptinfo(table, token);
|
|
|
|
if (p && p->found) {
|
2012-06-10 07:21:05 -06:00
|
|
|
*value = p->value.bool;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86ReturnOptValBool(const OptionInfoRec * table, int token, Bool def)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
OptionInfoPtr p;
|
|
|
|
|
|
|
|
p = xf86TokenToOptinfo(table, token);
|
|
|
|
if (p && p->found) {
|
2012-06-10 07:21:05 -06:00
|
|
|
return p->value.bool;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return def;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
int
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86NameCmp(const char *s1, const char *s2)
|
|
|
|
{
|
|
|
|
return xf86nameCompare(s1, s2);
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
xf86NormalizeName(const char *s)
|
|
|
|
{
|
|
|
|
char *ret, *q;
|
|
|
|
const char *p;
|
|
|
|
|
|
|
|
if (s == NULL)
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
ret = malloc(strlen(s) + 1);
|
2006-11-26 11:13:41 -07:00
|
|
|
for (p = s, q = ret; *p != 0; p++) {
|
2012-06-10 07:21:05 -06:00
|
|
|
switch (*p) {
|
|
|
|
case '_':
|
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
continue;
|
|
|
|
default:
|
|
|
|
if (isupper(*p))
|
|
|
|
*q++ = tolower(*p);
|
|
|
|
else
|
|
|
|
*q++ = *p;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
*q = '\0';
|
|
|
|
return ret;
|
|
|
|
}
|