diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-01-26 19:03:03 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-01-26 19:03:03 +0000 |
commit | 47be1a48f383fc4b84a1b9369a62468dabb4bfba (patch) | |
tree | ac6981a3f5ca1c4491d7f4c13165633367c8bcfc /src/util/gnunet-config.c | |
parent | bc09b304a1a9795520141585cceb02916733c3a1 (diff) | |
download | gnunet-47be1a48f383fc4b84a1b9369a62468dabb4bfba.tar.gz gnunet-47be1a48f383fc4b84a1b9369a62468dabb4bfba.zip |
patches from Hellekin to fix #3577
Diffstat (limited to 'src/util/gnunet-config.c')
-rw-r--r-- | src/util/gnunet-config.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/util/gnunet-config.c b/src/util/gnunet-config.c index 1d204dd07..f0acf11e4 100644 --- a/src/util/gnunet-config.c +++ b/src/util/gnunet-config.c | |||
@@ -48,6 +48,11 @@ static char *value; | |||
48 | static int is_filename; | 48 | static int is_filename; |
49 | 49 | ||
50 | /** | 50 | /** |
51 | * Whether to show the sections. | ||
52 | */ | ||
53 | static int list_sections; | ||
54 | |||
55 | /** | ||
51 | * Return value from 'main'. | 56 | * Return value from 'main'. |
52 | */ | 57 | */ |
53 | static int ret; | 58 | static int ret; |
@@ -72,6 +77,20 @@ print_option (void *cls, const char *section, | |||
72 | 77 | ||
73 | 78 | ||
74 | /** | 79 | /** |
80 | * Print out given section name. | ||
81 | * | ||
82 | * @param cls unused | ||
83 | * @param section a section in the configuration file | ||
84 | */ | ||
85 | static void | ||
86 | print_section_name (void *cls, | ||
87 | const char *section) | ||
88 | { | ||
89 | fprintf (stdout, "%s\n", section); | ||
90 | } | ||
91 | |||
92 | |||
93 | /** | ||
75 | * Main function that will be run by the scheduler. | 94 | * Main function that will be run by the scheduler. |
76 | * | 95 | * |
77 | * @param cls closure | 96 | * @param cls closure |
@@ -85,9 +104,14 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
85 | { | 104 | { |
86 | struct GNUNET_CONFIGURATION_Handle *out; | 105 | struct GNUNET_CONFIGURATION_Handle *out; |
87 | 106 | ||
88 | if (NULL == section) | 107 | if (NULL == section || list_sections) |
89 | { | 108 | { |
90 | fprintf (stderr, _("--section argument is required\n")); | 109 | if (! list_sections) |
110 | { | ||
111 | fprintf (stderr, _("--section argument is required\n")); | ||
112 | } | ||
113 | fprintf (stderr, _("The following sections are available:\n")); | ||
114 | GNUNET_CONFIGURATION_iterate_sections (cfg, &print_section_name, NULL); | ||
91 | ret = 1; | 115 | ret = 1; |
92 | return; | 116 | return; |
93 | } | 117 | } |
@@ -168,6 +192,9 @@ main (int argc, char *const *argv) | |||
168 | { 'V', "value", "VALUE", | 192 | { 'V', "value", "VALUE", |
169 | gettext_noop ("value to set"), | 193 | gettext_noop ("value to set"), |
170 | 1, &GNUNET_GETOPT_set_string, &value }, | 194 | 1, &GNUNET_GETOPT_set_string, &value }, |
195 | { 'S', "list-sections", NULL, | ||
196 | gettext_noop ("print available configuration sections"), | ||
197 | 0, &GNUNET_GETOPT_set_one, &list_sections }, | ||
171 | GNUNET_GETOPT_OPTION_END | 198 | GNUNET_GETOPT_OPTION_END |
172 | }; | 199 | }; |
173 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 200 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |