From: Alexandru DAMIAN <alexandru.dam...@intel.com>

Added an option to specify the weston.ini config file
to be used. Defaults to ${PWD}/weston.ini

Adding a check in weston_config_full_path so that
we don't crash if we started without a config file.

Fixing a typo in help message.

Signed-off-by: Alexandru DAMIAN <alexandru.dam...@intel.com>
---
 shared/config-parser.c |  2 +-
 src/compositor.c       | 15 +++++++++++----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/shared/config-parser.c b/shared/config-parser.c
index e1bf212..8defbbb 100644
--- a/shared/config-parser.c
+++ b/shared/config-parser.c
@@ -385,7 +385,7 @@ weston_config_parse(const char *name)
 const char *
 weston_config_get_full_path(struct weston_config *config)
 {
-       return config->path;
+       return config == NULL ? NULL : config->path;
 }
 
 int
diff --git a/src/compositor.c b/src/compositor.c
index f619f82..c073410 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -3338,7 +3338,8 @@ usage(int error_code)
                "  -S, --socket=NAME\tName of socket to listen on\n"
                "  -i, --idle-time=SECS\tIdle time in seconds\n"
                "  --modules\t\tLoad the comma-separated list of modules\n"
-               "  --log==FILE\t\tLog to the given file\n"
+               "  --log=FILE\t\tLog to the given file\n"
+               "  --config=FILE\t\tUse specified config file. Defaults to 
./weston.ini\n"
                "  -h, --help\t\tThis help message\n\n");
 
        fprintf(stderr,
@@ -3429,6 +3430,7 @@ int main(int argc, char *argv[])
        int32_t help = 0;
        char *socket_name = "wayland-0";
        int32_t version = 0;
+       char *config_file = "weston.ini";
        struct weston_config *config;
        struct weston_config_section *section;
 
@@ -3441,6 +3443,7 @@ int main(int argc, char *argv[])
                { WESTON_OPTION_STRING, "log", 0, &log },
                { WESTON_OPTION_BOOLEAN, "help", 'h', &help },
                { WESTON_OPTION_BOOLEAN, "version", 0, &version },
+               { WESTON_OPTION_STRING, "config", 'c', &config_file },
        };
 
        parse_options(core_options, ARRAY_LENGTH(core_options), &argc, argv);
@@ -3488,9 +3491,13 @@ int main(int argc, char *argv[])
                        backend = WESTON_NATIVE_BACKEND;
        }
 
-       config = weston_config_parse("weston.ini");
-       weston_log("Using config file '%s'\n",
-                  weston_config_get_full_path(config));
+       config = weston_config_parse(config_file);
+
+       if (config != NULL) {
+               weston_log("Using config file '%s'\n", 
weston_config_get_full_path(config));
+       } else {
+               weston_log("Starting with no config file.");
+       }
        section = weston_config_get_section(config, "core", NULL, NULL);
        weston_config_section_get_string(section, "modules", &modules, "");
 
-- 
1.8.1.2

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to