diff options
author | Grant Erickson <marathon96@gmail.com> | 2012-08-07 08:12:35 -0700 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2012-08-08 12:29:33 +0300 |
commit | 0691d0ad4ed0cd9f3c9799bf257be80ea0539c7c (patch) | |
tree | 9155e8aaac8601e3fa6b8bc6b295f3c1cf2101cf /src/main.c | |
parent | 0cad4dafb8f9ebd89fe56a8d35824349817c8229 (diff) | |
download | connman-0691d0ad4ed0cd9f3c9799bf257be80ea0539c7c.tar.gz connman-0691d0ad4ed0cd9f3c9799bf257be80ea0539c7c.tar.bz2 connman-0691d0ad4ed0cd9f3c9799bf257be80ea0539c7c.zip |
main: Add support for specifying a non-default configuration file.
This patch adds support for specifying a main configuration file
different from the default value of /etc/connman/main.conf. This
is valuable during debug to specify alternate debug-only
configurations.
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 28 |
1 files changed, 23 insertions, 5 deletions
@@ -42,6 +42,8 @@ #define DEFAULT_INPUT_REQUEST_TIMEOUT 120 * 1000 #define DEFAULT_BROWSER_LAUNCH_TIMEOUT 300 * 1000 +#define CONFIGMAINFILE CONFIGDIR "/main.conf" + static char *default_auto_connect[] = { "wifi", "ethernet", @@ -243,6 +245,18 @@ static void parse_config(GKeyFile *config) g_clear_error(&error); } +static int config_init(const char *file) +{ + GKeyFile *config; + + config = load_config(file); + parse_config(config); + if (config != NULL) + g_key_file_free(config); + + return 0; +} + static GMainLoop *main_loop = NULL; static unsigned int __terminated = 0; @@ -322,6 +336,7 @@ static void disconnect_callback(DBusConnection *conn, void *user_data) g_main_loop_quit(main_loop); } +static gchar *option_config = NULL; static gchar *option_debug = NULL; static gchar *option_device = NULL; static gchar *option_plugin = NULL; @@ -344,6 +359,9 @@ static gboolean parse_debug(const char *key, const char *value, } static GOptionEntry options[] = { + { "config", 'c', 0, G_OPTION_ARG_STRING, &option_config, + "Load the specified configuration file " + "instead of " CONFIGMAINFILE, "FILE" }, { "debug", 'd', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK, parse_debug, "Specify debug options to enable", "DEBUG" }, @@ -427,7 +445,6 @@ int main(int argc, char *argv[]) GError *error = NULL; DBusConnection *conn; DBusError err; - GKeyFile *config; guint signal; #ifdef NEED_THREADS @@ -504,10 +521,10 @@ int main(int argc, char *argv[]) __connman_dbus_init(conn); - config = load_config(CONFIGDIR "/main.conf"); - parse_config(config); - if (config != NULL) - g_key_file_free(config); + if (option_config == NULL) + config_init(CONFIGMAINFILE); + else + config_init(option_config); __connman_storage_migrate(); __connman_technology_init(); @@ -547,6 +564,7 @@ int main(int argc, char *argv[]) __connman_wispr_init(); __connman_rfkill_init(); + g_free(option_config); g_free(option_device); g_free(option_plugin); g_free(option_nodevice); |