aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xfree86/common/xf86Option.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-03-23 10:05:55 +0100
committermarha <marha@users.sourceforge.net>2012-03-23 10:05:55 +0100
commit0f834b91a4768673833ab4917e87d86c237bb1a6 (patch)
tree363489504ed4b2d360259b8de4c9e392918e5d02 /xorg-server/hw/xfree86/common/xf86Option.c
parentfc72edebf875378459368c5383d9023730cbca54 (diff)
downloadvcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.gz
vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.bz2
vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.zip
libX11 xserver fontconfig mesa pixman xkbcomp xkeyboard-config git update
23 Mar 2012
Diffstat (limited to 'xorg-server/hw/xfree86/common/xf86Option.c')
-rw-r--r--xorg-server/hw/xfree86/common/xf86Option.c817
1 files changed, 410 insertions, 407 deletions
diff --git a/xorg-server/hw/xfree86/common/xf86Option.c b/xorg-server/hw/xfree86/common/xf86Option.c
index dc0a01899..7cc744029 100644
--- a/xorg-server/hw/xfree86/common/xf86Option.c
+++ b/xorg-server/hw/xfree86/common/xf86Option.c
@@ -46,8 +46,8 @@
#include "xf86Parser.h"
#include "optionstr.h"
-static Bool ParseOptionValue(int scrnIndex, XF86OptionPtr options, OptionInfoPtr p,
- Bool markUsed);
+static Bool ParseOptionValue(int scrnIndex, XF86OptionPtr options,
+ OptionInfoPtr p, Bool markUsed);
/*
* xf86CollectOptions collects the options from each of the config file
@@ -71,51 +71,51 @@ void
xf86CollectOptions(ScrnInfoPtr pScrn, XF86OptionPtr extraOpts)
{
XF86OptionPtr tmp;
- XF86OptionPtr extras = (XF86OptionPtr)extraOpts;
+ XF86OptionPtr extras = (XF86OptionPtr) extraOpts;
GDevPtr device;
-
+
int i;
pScrn->options = NULL;
- 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;
- }
+ 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;
+ }
}
if (pScrn->monitor->options) {
- tmp = xf86optionListDup(pScrn->monitor->options);
- if (pScrn->options)
- pScrn->options = xf86optionListMerge(pScrn->options, tmp);
- else
- pScrn->options = tmp;
+ tmp = xf86optionListDup(pScrn->monitor->options);
+ if (pScrn->options)
+ pScrn->options = xf86optionListMerge(pScrn->options, tmp);
+ else
+ pScrn->options = tmp;
}
if (pScrn->confScreen->options) {
- tmp = xf86optionListDup(pScrn->confScreen->options);
- if (pScrn->options)
- pScrn->options = xf86optionListMerge(pScrn->options, tmp);
- else
- pScrn->options = tmp;
+ tmp = xf86optionListDup(pScrn->confScreen->options);
+ if (pScrn->options)
+ pScrn->options = xf86optionListMerge(pScrn->options, tmp);
+ else
+ pScrn->options = tmp;
}
if (pScrn->display->options) {
- tmp = xf86optionListDup(pScrn->display->options);
- if (pScrn->options)
- pScrn->options = xf86optionListMerge(pScrn->options, tmp);
- else
- pScrn->options = tmp;
+ tmp = xf86optionListDup(pScrn->display->options);
+ if (pScrn->options)
+ pScrn->options = xf86optionListMerge(pScrn->options, tmp);
+ else
+ pScrn->options = tmp;
}
if (extras) {
- tmp = xf86optionListDup(extras);
- if (pScrn->options)
- pScrn->options = xf86optionListMerge(pScrn->options, tmp);
- else
- pScrn->options = tmp;
+ tmp = xf86optionListDup(extras);
+ if (pScrn->options)
+ pScrn->options = xf86optionListMerge(pScrn->options, tmp);
+ else
+ pScrn->options = tmp;
}
}
@@ -130,11 +130,12 @@ void
xf86CollectInputOptions(InputInfoPtr pInfo, const char **defaultOpts)
{
if (defaultOpts) {
- XF86OptionPtr tmp =xf86optionListCreate(defaultOpts, -1, 0);
- if (pInfo->options)
- pInfo->options = xf86optionListMerge(tmp, pInfo->options);
- else
- pInfo->options = tmp;
+ XF86OptionPtr tmp = xf86optionListCreate(defaultOpts, -1, 0);
+
+ if (pInfo->options)
+ pInfo->options = xf86optionListMerge(tmp, pInfo->options);
+ else
+ pInfo->options = tmp;
}
}
@@ -147,47 +148,46 @@ xf86OptionListDuplicate(XF86OptionPtr options)
{
XF86OptionPtr o = NULL;
- while (options)
- {
- o = xf86AddNewOption(o, xf86OptionName(options), xf86OptionValue(options));
+ while (options) {
+ o = xf86AddNewOption(o, xf86OptionName(options),
+ xf86OptionValue(options));
options = xf86nextOption(options);
}
return o;
}
-
/* Created for new XInput stuff -- essentially extensions to the parser */
static int
-LookupIntOption(XF86OptionPtr optlist, const char *name, int deflt, Bool markUsed)
+LookupIntOption(XF86OptionPtr optlist, const char *name, int deflt,
+ Bool markUsed)
{
OptionInfoRec o;
o.name = name;
o.type = OPTV_INTEGER;
if (ParseOptionValue(-1, optlist, &o, markUsed))
- deflt = o.value.num;
+ deflt = o.value.num;
return deflt;
}
-
static double
LookupRealOption(XF86OptionPtr optlist, const char *name, double deflt,
- Bool markUsed)
+ Bool markUsed)
{
OptionInfoRec o;
o.name = name;
o.type = OPTV_REAL;
if (ParseOptionValue(-1, optlist, &o, markUsed))
- deflt = o.value.realnum;
+ deflt = o.value.realnum;
return deflt;
}
-
static char *
-LookupStrOption(XF86OptionPtr optlist, const char *name, const char *deflt, Bool markUsed)
+LookupStrOption(XF86OptionPtr optlist, const char *name, const char *deflt,
+ Bool markUsed)
{
OptionInfoRec o;
@@ -196,33 +196,34 @@ LookupStrOption(XF86OptionPtr optlist, const char *name, const char *deflt, Bool
if (ParseOptionValue(-1, optlist, &o, markUsed))
deflt = o.value.str;
if (deflt)
- return strdup(deflt);
+ return strdup(deflt);
else
- return NULL;
+ return NULL;
}
-
static int
-LookupBoolOption(XF86OptionPtr optlist, const char *name, int deflt, Bool markUsed)
+LookupBoolOption(XF86OptionPtr optlist, const char *name, int deflt,
+ Bool markUsed)
{
OptionInfoRec o;
o.name = name;
o.type = OPTV_BOOLEAN;
if (ParseOptionValue(-1, optlist, &o, markUsed))
- deflt = o.value.bool;
+ deflt = o.value.bool;
return deflt;
}
static double
-LookupPercentOption(XF86OptionPtr optlist, const char *name, double deflt, Bool markUsed)
+LookupPercentOption(XF86OptionPtr optlist, const char *name, double deflt,
+ Bool markUsed)
{
OptionInfoRec o;
o.name = name;
o.type = OPTV_PERCENT;
if (ParseOptionValue(-1, optlist, &o, markUsed))
- deflt = o.value.realnum;
+ deflt = o.value.realnum;
return deflt;
}
@@ -234,21 +235,18 @@ xf86SetIntOption(XF86OptionPtr optlist, const char *name, int deflt)
return LookupIntOption(optlist, name, deflt, TRUE);
}
-
double
xf86SetRealOption(XF86OptionPtr optlist, const char *name, double deflt)
{
return LookupRealOption(optlist, name, deflt, TRUE);
}
-
char *
xf86SetStrOption(XF86OptionPtr optlist, const char *name, const char *deflt)
{
return LookupStrOption(optlist, name, deflt, TRUE);
}
-
int
xf86SetBoolOption(XF86OptionPtr optlist, const char *name, int deflt)
{
@@ -271,33 +269,30 @@ xf86CheckIntOption(XF86OptionPtr optlist, const char *name, int deflt)
return LookupIntOption(optlist, name, deflt, FALSE);
}
-
double
xf86CheckRealOption(XF86OptionPtr optlist, const char *name, double deflt)
{
return LookupRealOption(optlist, name, deflt, FALSE);
}
-
char *
xf86CheckStrOption(XF86OptionPtr optlist, const char *name, char *deflt)
{
return LookupStrOption(optlist, name, deflt, FALSE);
}
-
int
xf86CheckBoolOption(XF86OptionPtr optlist, const char *name, int deflt)
{
return LookupBoolOption(optlist, name, deflt, FALSE);
}
-
double
xf86CheckPercentOption(XF86OptionPtr optlist, const char *name, double deflt)
{
return LookupPercentOption(optlist, name, deflt, FALSE);
}
+
/*
* xf86AddNewOption() has the required property of replacing the option value
* if the option is already present.
@@ -306,36 +301,40 @@ XF86OptionPtr
xf86ReplaceIntOption(XF86OptionPtr optlist, const char *name, const int val)
{
char tmp[16];
- snprintf(tmp,sizeof(tmp),"%i",val);
- return xf86AddNewOption(optlist,name,tmp);
+
+ snprintf(tmp, sizeof(tmp), "%i", val);
+ return xf86AddNewOption(optlist, name, tmp);
}
XF86OptionPtr
xf86ReplaceRealOption(XF86OptionPtr optlist, const char *name, const double val)
{
char tmp[32];
- snprintf(tmp,sizeof(tmp),"%f",val);
- return xf86AddNewOption(optlist,name,tmp);
+
+ snprintf(tmp, sizeof(tmp), "%f", val);
+ return xf86AddNewOption(optlist, name, tmp);
}
XF86OptionPtr
xf86ReplaceBoolOption(XF86OptionPtr optlist, const char *name, const Bool val)
{
- return xf86AddNewOption(optlist,name,val?"True":"False");
+ return xf86AddNewOption(optlist, name, val ? "True" : "False");
}
XF86OptionPtr
-xf86ReplacePercentOption(XF86OptionPtr optlist, const char *name, const double val)
+xf86ReplacePercentOption(XF86OptionPtr optlist, const char *name,
+ const double val)
{
char tmp[16];
+
snprintf(tmp, sizeof(tmp), "%lf%%", val);
- return xf86AddNewOption(optlist,name,tmp);
+ return xf86AddNewOption(optlist, name, tmp);
}
XF86OptionPtr
-xf86ReplaceStrOption(XF86OptionPtr optlist, const char *name, const char* val)
+xf86ReplaceStrOption(XF86OptionPtr optlist, const char *name, const char *val)
{
- return xf86AddNewOption(optlist,name,val);
+ return xf86AddNewOption(optlist, name, val);
}
XF86OptionPtr
@@ -348,14 +347,12 @@ xf86AddNewOption(XF86OptionPtr head, const char *name, const char *val)
return xf86addNewOption(head, tmp_name, tmp);
}
-
XF86OptionPtr
xf86NewOption(char *name, char *value)
{
return xf86newOption(name, value);
}
-
XF86OptionPtr
xf86NextOption(XF86OptionPtr list)
{
@@ -365,31 +362,31 @@ xf86NextOption(XF86OptionPtr list)
XF86OptionPtr
xf86OptionListCreate(const char **options, int count, int used)
{
- return xf86optionListCreate(options, count, used);
+ return xf86optionListCreate(options, count, used);
}
XF86OptionPtr
xf86OptionListMerge(XF86OptionPtr head, XF86OptionPtr tail)
{
- return xf86optionListMerge(head, tail);
+ return xf86optionListMerge(head, tail);
}
void
xf86OptionListFree(XF86OptionPtr opt)
{
- xf86optionListFree(opt);
+ xf86optionListFree(opt);
}
char *
xf86OptionName(XF86OptionPtr opt)
{
- return xf86optionName(opt);
+ return xf86optionName(opt);
}
char *
xf86OptionValue(XF86OptionPtr opt)
{
- return xf86optionValue(opt);
+ return xf86optionValue(opt);
}
void
@@ -397,13 +394,13 @@ xf86OptionListReport(XF86OptionPtr parm)
{
XF86OptionPtr opts = parm;
- 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);
+ 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);
}
}
@@ -415,22 +412,19 @@ xf86FindOption(XF86OptionPtr options, const char *name)
return xf86findOption(options, name);
}
-
const char *
xf86FindOptionValue(XF86OptionPtr options, const char *name)
{
return xf86findOptionValue(options, name);
}
-
void
xf86MarkOptionUsed(XF86OptionPtr option)
{
if (option != NULL)
- option->opt_used = TRUE;
+ option->opt_used = TRUE;
}
-
void
xf86MarkOptionUsedByName(XF86OptionPtr options, const char *name)
{
@@ -438,16 +432,16 @@ xf86MarkOptionUsedByName(XF86OptionPtr options, const char *name)
opt = xf86findOption(options, name);
if (opt != NULL)
- opt->opt_used = TRUE;
+ opt->opt_used = TRUE;
}
Bool
xf86CheckIfOptionUsed(XF86OptionPtr option)
{
if (option != NULL)
- return option->opt_used;
+ return option->opt_used;
else
- return FALSE;
+ return FALSE;
}
Bool
@@ -457,24 +451,23 @@ xf86CheckIfOptionUsedByName(XF86OptionPtr options, const char *name)
opt = xf86findOption(options, name);
if (opt != NULL)
- return opt->opt_used;
+ return opt->opt_used;
else
- return FALSE;
+ return FALSE;
}
void
xf86ShowUnusedOptions(int scrnIndex, XF86OptionPtr opt)
{
while (opt) {
- if (opt->opt_name && !opt->opt_used) {
- xf86DrvMsg(scrnIndex, X_WARNING, "Option \"%s\" is not used\n",
- opt->opt_name);
- }
- opt = opt->list.next;
+ if (opt->opt_name && !opt->opt_used) {
+ xf86DrvMsg(scrnIndex, X_WARNING, "Option \"%s\" is not used\n",
+ opt->opt_name);
+ }
+ opt = opt->list.next;
}
}
-
static Bool
GetBoolValue(OptionInfoPtr p, const char *s)
{
@@ -483,257 +476,269 @@ GetBoolValue(OptionInfoPtr p, const char *s)
static Bool
ParseOptionValue(int scrnIndex, XF86OptionPtr options, OptionInfoPtr p,
- Bool markUsed)
+ Bool markUsed)
{
char *s, *end;
Bool wasUsed = FALSE;
if ((s = xf86findOptionValue(options, p->name)) != NULL) {
- 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,
- "Option \"%s\" requires an string value\n",
- 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;
+ 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,
+ "Option \"%s\" requires an string value\n",
+ 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;
}
return p->found;
}
-
void
xf86ProcessOptions(int scrnIndex, XF86OptionPtr options, OptionInfoPtr optinfo)
{
OptionInfoPtr p;
for (p = optinfo; p->name != NULL; p++) {
- ParseOptionValue(scrnIndex, options, p, TRUE);
+ ParseOptionValue(scrnIndex, options, p, TRUE);
}
}
-
OptionInfoPtr
-xf86TokenToOptinfo(const OptionInfoRec *table, int token)
+xf86TokenToOptinfo(const OptionInfoRec * table, int token)
{
const OptionInfoRec *p, *match = NULL, *set = NULL;
if (!table) {
- ErrorF("xf86TokenToOptinfo: table is NULL\n");
- return NULL;
+ ErrorF("xf86TokenToOptinfo: table is NULL\n");
+ return NULL;
}
for (p = table; p->token >= 0; p++) {
- if (p->token == token) {
- match = p;
- if (p->found)
- set = p;
- }
+ if (p->token == token) {
+ match = p;
+ if (p->found)
+ set = p;
+ }
}
if (set)
- return (OptionInfoPtr)set;
+ return (OptionInfoPtr) set;
else if (match)
- return (OptionInfoPtr)match;
+ return (OptionInfoPtr) match;
else
- return NULL;
+ return NULL;
}
-
const char *
-xf86TokenToOptName(const OptionInfoRec *table, int token)
+xf86TokenToOptName(const OptionInfoRec * table, int token)
{
const OptionInfoRec *p;
@@ -741,9 +746,8 @@ xf86TokenToOptName(const OptionInfoRec *table, int token)
return p->name;
}
-
Bool
-xf86IsOptionSet(const OptionInfoRec *table, int token)
+xf86IsOptionSet(const OptionInfoRec * table, int token)
{
OptionInfoPtr p;
@@ -751,137 +755,136 @@ xf86IsOptionSet(const OptionInfoRec *table, int token)
return p && p->found;
}
-
char *
-xf86GetOptValString(const OptionInfoRec *table, int token)
+xf86GetOptValString(const OptionInfoRec * table, int token)
{
OptionInfoPtr p;
p = xf86TokenToOptinfo(table, token);
if (p && p->found)
- return p->value.str;
+ return p->value.str;
else
- return NULL;
+ return NULL;
}
-
Bool
-xf86GetOptValInteger(const OptionInfoRec *table, int token, int *value)
+xf86GetOptValInteger(const OptionInfoRec * table, int token, int *value)
{
OptionInfoPtr p;
p = xf86TokenToOptinfo(table, token);
if (p && p->found) {
- *value = p->value.num;
- return TRUE;
- } else
- return FALSE;
+ *value = p->value.num;
+ return TRUE;
+ }
+ else
+ return FALSE;
}
-
Bool
-xf86GetOptValULong(const OptionInfoRec *table, int token, unsigned long *value)
+xf86GetOptValULong(const OptionInfoRec * table, int token, unsigned long *value)
{
OptionInfoPtr p;
p = xf86TokenToOptinfo(table, token);
if (p && p->found) {
- *value = p->value.num;
- return TRUE;
- } else
- return FALSE;
+ *value = p->value.num;
+ return TRUE;
+ }
+ else
+ return FALSE;
}
-
Bool
-xf86GetOptValReal(const OptionInfoRec *table, int token, double *value)
+xf86GetOptValReal(const OptionInfoRec * table, int token, double *value)
{
OptionInfoPtr p;
p = xf86TokenToOptinfo(table, token);
if (p && p->found) {
- *value = p->value.realnum;
- return TRUE;
- } else
- return FALSE;
+ *value = p->value.realnum;
+ return TRUE;
+ }
+ else
+ return FALSE;
}
-
Bool
-xf86GetOptValFreq(const OptionInfoRec *table, int token,
- OptFreqUnits expectedUnits, double *value)
+xf86GetOptValFreq(const OptionInfoRec * table, int token,
+ OptFreqUnits expectedUnits, double *value)
{
OptionInfoPtr p;
p = xf86TokenToOptinfo(table, token);
if (p && p->found) {
- 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;
+ 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;
}
-
Bool
-xf86GetOptValBool(const OptionInfoRec *table, int token, Bool *value)
+xf86GetOptValBool(const OptionInfoRec * table, int token, Bool *value)
{
OptionInfoPtr p;
p = xf86TokenToOptinfo(table, token);
if (p && p->found) {
- *value = p->value.bool;
- return TRUE;
- } else
- return FALSE;
+ *value = p->value.bool;
+ return TRUE;
+ }
+ else
+ return FALSE;
}
-
Bool
-xf86ReturnOptValBool(const OptionInfoRec *table, int token, Bool def)
+xf86ReturnOptValBool(const OptionInfoRec * table, int token, Bool def)
{
OptionInfoPtr p;
p = xf86TokenToOptinfo(table, token);
if (p && p->found) {
- return p->value.bool;
- } else
- return def;
+ return p->value.bool;
+ }
+ else
+ return def;
}
-
int
xf86NameCmp(const char *s1, const char *s2)
{
@@ -895,21 +898,21 @@ xf86NormalizeName(const char *s)
const char *p;
if (s == NULL)
- return NULL;
+ return NULL;
ret = malloc(strlen(s) + 1);
for (p = s, q = ret; *p != 0; p++) {
- switch (*p) {
- case '_':
- case ' ':
- case '\t':
- continue;
- default:
- if (isupper(*p))
- *q++ = tolower(*p);
- else
- *q++ = *p;
- }
+ switch (*p) {
+ case '_':
+ case ' ':
+ case '\t':
+ continue;
+ default:
+ if (isupper(*p))
+ *q++ = tolower(*p);
+ else
+ *q++ = *p;
+ }
}
*q = '\0';
return ret;