NetworkManager r3288 - in trunk: . system-settings/src
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: NetworkManager r3288 - in trunk: . system-settings/src
- Date: Mon, 4 Feb 2008 20:03:28 +0000 (GMT)
Author: dcbw
Date: Mon Feb 4 20:03:28 2008
New Revision: 3288
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3288&view=rev
Log:
2008-02-04 Dan Williams <dcbw redhat com>
* system-settings/src/main.c
- (parse_config_file): parse a config file
- (main): accept --config option and read plugins from config file
Modified:
trunk/ChangeLog
trunk/system-settings/src/main.c
Modified: trunk/system-settings/src/main.c
==============================================================================
--- trunk/system-settings/src/main.c (original)
+++ trunk/system-settings/src/main.c Mon Feb 4 20:03:28 2008
@@ -375,6 +375,30 @@
return FALSE;
}
+static gboolean
+parse_config_file (const char *filename, char **plugins, GError **error)
+{
+ GKeyFile *config;
+
+ config = g_key_file_new ();
+ if (!config) {
+ g_set_error (error, plugins_error_quark (), 0,
+ "Not enough memory to load config file.");
+ return FALSE;
+ }
+
+ g_key_file_set_list_separator (config, ',');
+ if (!g_key_file_load_from_file (config, filename, G_KEY_FILE_NONE, error))
+ return FALSE;
+
+ *plugins = g_key_file_get_value (config, "main", "plugins", error);
+ if (*error)
+ return FALSE;
+
+ g_key_file_free (config);
+ return TRUE;
+}
+
int
main (int argc, char **argv)
{
@@ -382,8 +406,10 @@
GOptionContext *opt_ctx;
GError *error = NULL;
char *plugins = NULL;
+ char *config = NULL;
GOptionEntry entries[] = {
+ { "config", 0, 0, G_OPTION_ARG_FILENAME, &config, "Config file location", "/path/to/config.file" },
{ "plugins", 0, 0, G_OPTION_ARG_STRING, &plugins, "List of plugins separated by ,", "plugin1,plugin2" },
{ NULL }
};
@@ -400,8 +426,15 @@
g_option_context_free (opt_ctx);
+ if (config) {
+ if (!parse_config_file (config, &plugins, &error)) {
+ g_warning ("Invalid config file: %s.", error->message);
+ return 1;
+ }
+ }
+
if (!plugins) {
- g_warning ("'plugins' argument is required.");
+ g_warning ("No plugins were specified.");
return 1;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]