diff options
author | Alon Levy <alevy@redhat.com> | 2012-02-01 08:45:10 +0200 |
---|---|---|
committer | Alon Levy <alevy@redhat.com> | 2012-02-16 12:33:40 +0200 |
commit | 8b3c5a5fac297226a467ea15c16cea8e5da51b8f (patch) | |
tree | 1578c586bae94251314e91c1be2236626a5a51cf | |
parent | 96349ebb43e7de49b6b561b79d6fff5ada7aa4c7 (diff) |
introduce qxl_option_helpers.[ch]
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/qxl_driver.c | 1 | ||||
-rw-r--r-- | src/qxl_option_helpers.c | 37 | ||||
-rw-r--r-- | src/spiceqxl_spice_server.c | 35 |
4 files changed, 40 insertions, 34 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 2695614..9e249dc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -61,6 +61,7 @@ spiceqxl_drv_la_LIBADD = uxa/libuxa.la spiceqxl_drv_la_SOURCES = \ qxl.h \ + qxl_option_helpers.c \ spiceqxl_spice_server.c \ spiceqxl_spice_server.h \ spiceqxl_io_port.c \ diff --git a/src/qxl_driver.c b/src/qxl_driver.c index 191fa07..ed4bb13 100644 --- a/src/qxl_driver.c +++ b/src/qxl_driver.c @@ -36,6 +36,7 @@ #include <stdlib.h> #include "qxl.h" #include "assert.h" +#include "qxl_option_helpers.h" #ifdef XSPICE #include "spiceqxl_driver.h" 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; +} diff --git a/src/spiceqxl_spice_server.c b/src/spiceqxl_spice_server.c index 61f20d1..b7206cc 100644 --- a/src/spiceqxl_spice_server.c +++ b/src/spiceqxl_spice_server.c @@ -27,6 +27,7 @@ */ #include "qxl.h" +#include "qxl_option_helpers.h" #include "spiceqxl_spice_server.h" /* Single instance of spice server per Xorg executable. @@ -40,40 +41,6 @@ SpiceServer *xspice_get_spice_server(void) return spice_server; } -static -int get_int_option(OptionInfoPtr options, int option_index, - const char *env_name) -{ - if (getenv(env_name)) { - return atoi(getenv(env_name)); - } - return options[option_index].value.num; -} - -static -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; -} - -static -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; -} - #define X509_CA_CERT_FILE "ca-cert.pem" #define X509_SERVER_KEY_FILE "server-key.pem" #define X509_SERVER_CERT_FILE "server-cert.pem" |