[PATCH x11spice 1/2] Bug fix: --config=<filename> did not work.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Jeremy White <jwhite@xxxxxxxxxxxxxxx>
---
 src/options.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/options.c b/src/options.c
index b7f487c5..0d3138d0 100644
--- a/src/options.c
+++ b/src/options.c
@@ -213,14 +213,34 @@ void options_handle_ssl_file_options(options_t *options,
     options->ssl.ciphersuite = string_option(userkey, systemkey, "ssl", "ciphersuite");
 }
 
+/* In general, we want to parse the config file options before the command line
+**  arguments.  However, the command line argument to specify a config file is
+**  the exception.  We manually parse this out now, so we can simplify the
+**  flow of control later. */
 void options_handle_user_config(int argc, char *argv[], options_t *options)
 {
     int i;
-    for (i = 1; i < argc - 1; i++)
-        if (strcmp(argv[i], "--config") == 0 || strcmp(argv[i], "-config") == 0) {
+    char *p, *q;
+
+    /* getopt long is complex; it supports [-]-config[=]filename */
+    for (i = 1; i < argc; i++) {
+        p = strstr(argv[i], "--config");
+        if (p != argv[i]) {
+            p = strstr(argv[i], "-config");
+        }
+        if (p != argv[i]) {
+            continue;
+        }
+        q = strstr(p, "=");
+        if (q) {
+            options->user_config_file = strdup(q + 1);
+            continue;
+        }
+        if (i < argc - 1) {
             options->user_config_file = strdup(argv[i + 1]);
             i++;
         }
+    }
 }
 
 int options_parse_arguments(int argc, char *argv[], options_t *options)
-- 
2.11.0

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]