diff options
author | marha <marha@users.sourceforge.net> | 2010-05-20 07:07:37 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2010-05-20 07:07:37 +0000 |
commit | 3319741e6f9fc3232eb40462a261271b9af2dcb2 (patch) | |
tree | ffe7fbae59390aafa850dcdbd3ea48d2cb59bda0 /xorg-server/hw/xfree86/common/xf86Option.c | |
parent | 153f5cafa19da4e4c0cf21e9c909958359ed8ebd (diff) | |
download | vcxsrv-3319741e6f9fc3232eb40462a261271b9af2dcb2.tar.gz vcxsrv-3319741e6f9fc3232eb40462a261271b9af2dcb2.tar.bz2 vcxsrv-3319741e6f9fc3232eb40462a261271b9af2dcb2.zip |
xserver git update 20/5/2010
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,
|