summaryrefslogtreecommitdiff
path: root/src/util/gnunet-config.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/gnunet-config.c')
-rw-r--r--src/util/gnunet-config.c181
1 files changed, 81 insertions, 100 deletions
diff --git a/src/util/gnunet-config.c b/src/util/gnunet-config.c
index 9c292205a..3b9b64d4e 100644
--- a/src/util/gnunet-config.c
+++ b/src/util/gnunet-config.c
@@ -103,18 +103,12 @@ print_option (void *cls,
fn = value_fn;
else
GNUNET_free (value_fn);
- fprintf (stdout,
- "%s = %s\n",
- option,
- fn);
+ fprintf (stdout, "%s = %s\n", option, fn);
GNUNET_free (fn);
}
else
{
- fprintf (stdout,
- "%s = %s\n",
- option,
- value);
+ fprintf (stdout, "%s = %s\n", option, value);
}
}
@@ -126,13 +120,10 @@ print_option (void *cls,
* @param section a section in the configuration file
*/
static void
-print_section_name (void *cls,
- const char *section)
+print_section_name (void *cls, const char *section)
{
(void) cls;
- fprintf (stdout,
- "%s\n",
- section);
+ fprintf (stdout, "%s\n", section);
}
@@ -161,9 +152,7 @@ run (void *cls,
{
char *name;
- GNUNET_asprintf (&name,
- "libgnunet_plugin_%s",
- backend_check);
+ GNUNET_asprintf (&name, "libgnunet_plugin_%s", backend_check);
global_ret = (GNUNET_OK == GNUNET_PLUGIN_test (name)) ? 0 : 77;
GNUNET_free (name);
return;
@@ -173,40 +162,34 @@ run (void *cls,
struct GNUNET_CONFIGURATION_Handle *def;
def = GNUNET_CONFIGURATION_create ();
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_load (def, NULL))
+ if (GNUNET_OK != GNUNET_CONFIGURATION_load (def, NULL))
{
- fprintf (stderr,
- _("failed to load configuration defaults"));
+ fprintf (stderr, _ ("failed to load configuration defaults"));
global_ret = 1;
return;
}
- diff = GNUNET_CONFIGURATION_get_diff (def,
- cfg);
+ diff = GNUNET_CONFIGURATION_get_diff (def, cfg);
cfg = diff;
}
- if ( ((! rewrite) && (NULL == section)) || list_sections)
+ if (((! rewrite) && (NULL == section)) || list_sections)
{
if (! list_sections)
{
fprintf (stderr,
- _("%s or %s argument is required\n"),
+ _ ("%s or %s argument is required\n"),
"--section",
"--list-sections");
global_ret = 1;
}
else
{
- fprintf (stderr,
- _("The following sections are available:\n"));
- GNUNET_CONFIGURATION_iterate_sections (cfg,
- &print_section_name,
- NULL);
+ fprintf (stderr, _ ("The following sections are available:\n"));
+ GNUNET_CONFIGURATION_iterate_sections (cfg, &print_section_name, NULL);
}
goto cleanup;
}
- if ( (NULL != section) && (NULL == value) )
+ if ((NULL != section) && (NULL == value))
{
if (NULL == option)
{
@@ -219,26 +202,24 @@ run (void *cls,
{
if (is_filename)
{
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_filename (cfg,
- section,
- option,
- &value))
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg,
+ section,
+ option,
+ &value))
{
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
- section, option);
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, section, option);
global_ret = 3;
goto cleanup;
}
}
else
{
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg, section,
- option, &value))
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg,
+ section,
+ option,
+ &value))
{
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
- section, option);
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, section, option);
global_ret = 3;
goto cleanup;
}
@@ -250,15 +231,12 @@ run (void *cls,
{
if (NULL == option)
{
- fprintf (stderr, _("--option argument required to set value\n"));
+ fprintf (stderr, _ ("--option argument required to set value\n"));
global_ret = 1;
goto cleanup;
}
out = GNUNET_CONFIGURATION_dup (cfg);
- GNUNET_CONFIGURATION_set_value_string (out,
- section,
- option,
- value);
+ GNUNET_CONFIGURATION_set_value_string (out, section, option, value);
}
cfg_fn = NULL;
if (NULL == cfgfile)
@@ -274,11 +252,10 @@ run (void *cls,
cfg_fn = GNUNET_strdup (GNUNET_OS_project_data_get ()->user_config_file);
cfgfile = cfg_fn;
}
- if ( (NULL != diff) || (NULL != out) )
+ if ((NULL != diff) || (NULL != out))
{
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_write ((NULL == out) ? diff : out,
- cfgfile))
+ GNUNET_CONFIGURATION_write ((NULL == out) ? diff : out, cfgfile))
global_ret = 2;
}
GNUNET_free_non_null (cfg_fn);
@@ -298,62 +275,66 @@ cleanup:
* @return 0 ok, 1 on error
*/
int
-main (int argc,
- char *const *argv)
+main (int argc, char *const *argv)
{
- struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_option_flag ('f',
- "filename",
- gettext_noop ("interpret option value as a filename (with $-expansion)"),
- &is_filename),
- //GNUNET_GETOPT_option_exclusive
- (GNUNET_GETOPT_option_string ('b',
- "supported-backend",
- "BACKEND",
- gettext_noop ("test if the current installation supports the specified BACKEND"),
- &backend_check)),
- GNUNET_GETOPT_option_string ('s',
- "section",
- "SECTION",
- gettext_noop ("name of the section to access"),
- &section),
- GNUNET_GETOPT_option_string ('o',
- "option",
- "OPTION",
- gettext_noop ("name of the option to access"),
- &option),
- GNUNET_GETOPT_option_string ('V',
- "value",
- "VALUE",
- gettext_noop ("value to set"),
- &value),
- GNUNET_GETOPT_option_flag ('S',
- "list-sections",
- gettext_noop ("print available configuration sections"),
- &list_sections),
- GNUNET_GETOPT_option_flag ('w',
- "rewrite",
- gettext_noop ("write configuration file that only contains delta to defaults"),
- &rewrite),
- GNUNET_GETOPT_OPTION_END
- };
+ struct GNUNET_GETOPT_CommandLineOption options[] =
+ {GNUNET_GETOPT_option_flag (
+ 'f',
+ "filename",
+ gettext_noop ("interpret option value as a filename (with $-expansion)"),
+ &is_filename),
+ GNUNET_GETOPT_option_exclusive (GNUNET_GETOPT_option_string (
+ 'b',
+ "supported-backend",
+ "BACKEND",
+ gettext_noop (
+ "test if the current installation supports the specified BACKEND"),
+ &backend_check)),
+ GNUNET_GETOPT_option_string ('s',
+ "section",
+ "SECTION",
+ gettext_noop (
+ "name of the section to access"),
+ &section),
+ GNUNET_GETOPT_option_string ('o',
+ "option",
+ "OPTION",
+ gettext_noop ("name of the option to access"),
+ &option),
+ GNUNET_GETOPT_option_string ('V',
+ "value",
+ "VALUE",
+ gettext_noop ("value to set"),
+ &value),
+ GNUNET_GETOPT_option_flag ('S',
+ "list-sections",
+ gettext_noop (
+ "print available configuration sections"),
+ &list_sections),
+ GNUNET_GETOPT_option_flag (
+ 'w',
+ "rewrite",
+ gettext_noop (
+ "write configuration file that only contains delta to defaults"),
+ &rewrite),
+ GNUNET_GETOPT_OPTION_END};
int ret;
-
- if (GNUNET_OK !=
- GNUNET_STRINGS_get_utf8_args (argc, argv,
- &argc, &argv))
+
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
return 2;
- ret = GNUNET_PROGRAM_run (argc,
- argv,
- "gnunet-config [OPTIONS]",
- gettext_noop ("Manipulate GNUnet configuration files"),
- options,
- &run, NULL);
- GNUNET_free ((void*) argv);
+ ret =
+ GNUNET_PROGRAM_run (argc,
+ argv,
+ "gnunet-config [OPTIONS]",
+ gettext_noop ("Manipulate GNUnet configuration files"),
+ options,
+ &run,
+ NULL);
+ GNUNET_free ((void *) argv);
if (GNUNET_OK == ret)
return global_ret;
- return 1;
+ return ret;
}
/* end of gnunet-config.c */