summaryrefslogtreecommitdiff
path: root/src/qxl_option_helpers.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/qxl_option_helpers.c')
-rw-r--r--src/qxl_option_helpers.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/qxl_option_helpers.c b/src/qxl_option_helpers.c
new file mode 100644
index 0000000..47603ce
--- /dev/null
+++ b/src/qxl_option_helpers.c
@@ -0,0 +1,37 @@
+#include <stdlib.h>
+
+#include <xf86.h>
+#include <xf86Opt.h>
+
+#include "qxl_option_helpers.h"
+
+int get_int_option(OptionInfoPtr options, int option_index,
+ const char *env_name)
+{
+ if (env_name && getenv(env_name)) {
+ return atoi(getenv(env_name));
+ }
+ return options[option_index].value.num;
+}
+
+const char *get_str_option(OptionInfoPtr options, int option_index,
+ const char *env_name)
+{
+ if (getenv(env_name)) {
+ return getenv(env_name);
+ }
+ return options[option_index].value.str;
+}
+
+int get_bool_option(OptionInfoPtr options, int option_index,
+ const char *env_name)
+{
+ if (getenv(env_name)) {
+ /* we don't support the whole range of boolean true and
+ * false values documented in man xorg.conf, just the c
+ * convention - 0 is false, anything else is true, so
+ * just like a number. */
+ return !!atoi(getenv(env_name));
+ }
+ return options[option_index].value.bool;
+}