diff options
author | marha <marha@users.sourceforge.net> | 2010-05-20 15:26:41 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2010-05-20 15:26:41 +0000 |
commit | f5fb2d27f1fd4976f0e77d97461a5e57ba6c9a23 (patch) | |
tree | c76e9cb708483e65b114c08ed008880f478cae15 /xorg-server/hw/xfree86/common/xf86Option.c | |
parent | b16c0295c9f95426980d567e93ae00c52545b3fa (diff) | |
parent | 3319741e6f9fc3232eb40462a261271b9af2dcb2 (diff) | |
download | vcxsrv-f5fb2d27f1fd4976f0e77d97461a5e57ba6c9a23.tar.gz vcxsrv-f5fb2d27f1fd4976f0e77d97461a5e57ba6c9a23.tar.bz2 vcxsrv-f5fb2d27f1fd4976f0e77d97461a5e57ba6c9a23.zip |
svn merge "^/branches/released" .
Diffstat (limited to 'xorg-server/hw/xfree86/common/xf86Option.c')
-rw-r--r-- | xorg-server/hw/xfree86/common/xf86Option.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/xorg-server/hw/xfree86/common/xf86Option.c b/xorg-server/hw/xfree86/common/xf86Option.c index 965ce4c7d..9856a6352 100644 --- a/xorg-server/hw/xfree86/common/xf86Option.c +++ b/xorg-server/hw/xfree86/common/xf86Option.c @@ -223,6 +223,18 @@ LookupBoolOption(pointer optlist, const char *name, int deflt, Bool markUsed) return deflt;
}
+static int
+LookupPercentOption(pointer 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;
+ return deflt;
+}
+
/* These xf86Set* functions are intended for use by non-screen specific code */
int
@@ -252,6 +264,12 @@ xf86SetBoolOption(pointer optlist, const char *name, int deflt) return LookupBoolOption(optlist, name, deflt, TRUE);
}
+double
+xf86SetPercentOption(pointer optlist, const char *name, double deflt)
+{
+ return LookupPercentOption(optlist, name, deflt, TRUE);
+}
+
/*
* These are like the Set*Option functions, but they don't mark the options
* as used.
@@ -283,6 +301,12 @@ xf86CheckBoolOption(pointer optlist, const char *name, int deflt) return LookupBoolOption(optlist, name, deflt, FALSE);
}
+
+double
+xf86CheckPercentOption(pointer optlist, const char *name, double deflt)
+{
+ return LookupPercentOption(optlist, name, deflt, FALSE);
+}
/*
* addNewOption() has the required property of replacing the option value
* if the option is already present.
@@ -310,6 +334,14 @@ xf86ReplaceBoolOption(pointer optlist, const char *name, const Bool val) }
pointer
+xf86ReplacePercentOption(pointer optlist, const char *name, const double val)
+{
+ char tmp[16];
+ sprintf(tmp, "%lf%%", val);
+ return xf86AddNewOption(optlist,name,tmp);
+}
+
+pointer
xf86ReplaceStrOption(pointer optlist, const char *name, const char* val)
{
return xf86AddNewOption(optlist,name,val);
@@ -533,6 +565,21 @@ ParseOptionValue(int scrnIndex, pointer options, OptionInfoPtr p, 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 != '%') {
+ 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') {
xf86DrvMsg(scrnIndex, X_WARNING,
|