diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-03-12 10:27:17 +0100 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-03-12 10:27:17 +0100 |
commit | 717ea75196137ff4263bb0c724534588632a8c23 (patch) | |
tree | 23e8d86cafd2dc09d2d71f8f20714a3935bcc1bc /src/util/gnunet-config.c | |
parent | e2a69125afce85c5bdb6e1861212a37abc135300 (diff) | |
download | gnunet-717ea75196137ff4263bb0c724534588632a8c23.tar.gz gnunet-717ea75196137ff4263bb0c724534588632a8c23.zip |
change description of file expansion flag
Diffstat (limited to 'src/util/gnunet-config.c')
-rw-r--r-- | src/util/gnunet-config.c | 129 |
1 files changed, 68 insertions, 61 deletions
diff --git a/src/util/gnunet-config.c b/src/util/gnunet-config.c index 361fa55d6..114efe7db 100644 --- a/src/util/gnunet-config.c +++ b/src/util/gnunet-config.c | |||
@@ -73,9 +73,9 @@ static int rewrite; | |||
73 | */ | 73 | */ |
74 | static void | 74 | static void |
75 | print_option (void *cls, | 75 | print_option (void *cls, |
76 | const char *section, | 76 | const char *section, |
77 | const char *option, | 77 | const char *option, |
78 | const char *value) | 78 | const char *value) |
79 | { | 79 | { |
80 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; | 80 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; |
81 | 81 | ||
@@ -86,27 +86,27 @@ print_option (void *cls, | |||
86 | char *fn; | 86 | char *fn; |
87 | 87 | ||
88 | GNUNET_assert (GNUNET_OK == | 88 | GNUNET_assert (GNUNET_OK == |
89 | GNUNET_CONFIGURATION_get_value_filename (cfg, | 89 | GNUNET_CONFIGURATION_get_value_filename (cfg, |
90 | section, | 90 | section, |
91 | option, | 91 | option, |
92 | &value_fn)); | 92 | &value_fn)); |
93 | fn = GNUNET_STRINGS_filename_expand (value_fn); | 93 | fn = GNUNET_STRINGS_filename_expand (value_fn); |
94 | if (NULL == fn) | 94 | if (NULL == fn) |
95 | fn = value_fn; | 95 | fn = value_fn; |
96 | else | 96 | else |
97 | GNUNET_free (value_fn); | 97 | GNUNET_free (value_fn); |
98 | fprintf (stdout, | 98 | fprintf (stdout, |
99 | "%s = %s\n", | 99 | "%s = %s\n", |
100 | option, | 100 | option, |
101 | fn); | 101 | fn); |
102 | GNUNET_free (fn); | 102 | GNUNET_free (fn); |
103 | } | 103 | } |
104 | else | 104 | else |
105 | { | 105 | { |
106 | fprintf (stdout, | 106 | fprintf (stdout, |
107 | "%s = %s\n", | 107 | "%s = %s\n", |
108 | option, | 108 | option, |
109 | value); | 109 | value); |
110 | } | 110 | } |
111 | } | 111 | } |
112 | 112 | ||
@@ -123,8 +123,8 @@ print_section_name (void *cls, | |||
123 | { | 123 | { |
124 | (void) cls; | 124 | (void) cls; |
125 | fprintf (stdout, | 125 | fprintf (stdout, |
126 | "%s\n", | 126 | "%s\n", |
127 | section); | 127 | section); |
128 | } | 128 | } |
129 | 129 | ||
130 | 130 | ||
@@ -133,7 +133,8 @@ print_section_name (void *cls, | |||
133 | * | 133 | * |
134 | * @param cls closure | 134 | * @param cls closure |
135 | * @param args remaining command-line arguments | 135 | * @param args remaining command-line arguments |
136 | * @param cfgfile name of the configuration file used (for saving, can be NULL!) | 136 | * @param cfgfile name of the configuration file used (for saving, |
137 | * can be NULL!) | ||
137 | * @param cfg configuration | 138 | * @param cfg configuration |
138 | */ | 139 | */ |
139 | static void | 140 | static void |
@@ -192,35 +193,36 @@ run (void *cls, | |||
192 | { | 193 | { |
193 | GNUNET_CONFIGURATION_iterate_section_values (cfg, | 194 | GNUNET_CONFIGURATION_iterate_section_values (cfg, |
194 | section, | 195 | section, |
195 | &print_option, | 196 | &print_option, |
196 | (void *) cfg); | 197 | (void *) cfg); |
197 | } | 198 | } |
198 | else | 199 | else |
199 | { | 200 | { |
200 | if (is_filename) | 201 | if (is_filename) |
201 | { | 202 | { |
202 | if (GNUNET_OK != | 203 | if (GNUNET_OK != |
203 | GNUNET_CONFIGURATION_get_value_filename (cfg, | 204 | GNUNET_CONFIGURATION_get_value_filename (cfg, |
204 | section, | 205 | section, |
205 | option, | 206 | option, |
206 | &value)) | 207 | &value)) |
207 | { | 208 | { |
208 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, | 209 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, |
209 | section, option); | 210 | section, option); |
210 | ret = 3; | 211 | ret = 3; |
211 | goto cleanup; | 212 | goto cleanup; |
212 | } | 213 | } |
213 | } | 214 | } |
214 | else | 215 | else |
215 | { | 216 | { |
216 | if (GNUNET_OK != | 217 | if (GNUNET_OK != |
217 | GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &value)) | 218 | GNUNET_CONFIGURATION_get_value_string (cfg, section, |
218 | { | 219 | option, &value)) |
219 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, | 220 | { |
220 | section, option); | 221 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, |
221 | ret = 3; | 222 | section, option); |
223 | ret = 3; | ||
222 | goto cleanup; | 224 | goto cleanup; |
223 | } | 225 | } |
224 | } | 226 | } |
225 | fprintf (stdout, "%s\n", value); | 227 | fprintf (stdout, "%s\n", value); |
226 | } | 228 | } |
@@ -245,10 +247,10 @@ run (void *cls, | |||
245 | const char *xdg = getenv ("XDG_CONFIG_HOME"); | 247 | const char *xdg = getenv ("XDG_CONFIG_HOME"); |
246 | if (NULL != xdg) | 248 | if (NULL != xdg) |
247 | GNUNET_asprintf (&cfg_fn, | 249 | GNUNET_asprintf (&cfg_fn, |
248 | "%s%s%s", | 250 | "%s%s%s", |
249 | xdg, | 251 | xdg, |
250 | DIR_SEPARATOR_STR, | 252 | DIR_SEPARATOR_STR, |
251 | GNUNET_OS_project_data_get ()->config_file); | 253 | GNUNET_OS_project_data_get ()->config_file); |
252 | else | 254 | else |
253 | cfg_fn = GNUNET_strdup (GNUNET_OS_project_data_get ()->user_config_file); | 255 | cfg_fn = GNUNET_strdup (GNUNET_OS_project_data_get ()->user_config_file); |
254 | cfgfile = cfg_fn; | 256 | cfgfile = cfg_fn; |
@@ -256,14 +258,14 @@ run (void *cls, | |||
256 | if ( (NULL != diff) || (NULL != out) ) | 258 | if ( (NULL != diff) || (NULL != out) ) |
257 | { | 259 | { |
258 | if (GNUNET_OK != | 260 | if (GNUNET_OK != |
259 | GNUNET_CONFIGURATION_write ((NULL == out) ? diff : out, | 261 | GNUNET_CONFIGURATION_write ((NULL == out) ? diff : out, |
260 | cfgfile)) | 262 | cfgfile)) |
261 | ret = 2; | 263 | ret = 2; |
262 | } | 264 | } |
263 | GNUNET_free_non_null (cfg_fn); | 265 | GNUNET_free_non_null (cfg_fn); |
264 | if (NULL != out) | 266 | if (NULL != out) |
265 | GNUNET_CONFIGURATION_destroy (out); | 267 | GNUNET_CONFIGURATION_destroy (out); |
266 | cleanup: | 268 | cleanup: |
267 | if (NULL != diff) | 269 | if (NULL != diff) |
268 | GNUNET_CONFIGURATION_destroy (diff); | 270 | GNUNET_CONFIGURATION_destroy (diff); |
269 | } | 271 | } |
@@ -282,32 +284,36 @@ main (int argc, | |||
282 | { | 284 | { |
283 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 285 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
284 | GNUNET_GETOPT_option_flag ('f', | 286 | GNUNET_GETOPT_option_flag ('f', |
285 | "filename", | 287 | "filename", |
286 | gettext_noop ("obtain option of value as a filename (with $-expansion)"), | 288 | gettext_noop ("interpret option value as |
287 | &is_filename), | 289 | a filename (with $-expansion)"), |
290 | &is_filename), | ||
288 | GNUNET_GETOPT_option_string ('s', | 291 | GNUNET_GETOPT_option_string ('s', |
289 | "section", | 292 | "section", |
290 | "SECTION", | 293 | "SECTION", |
291 | gettext_noop ("name of the section to access"), | 294 | gettext_noop ("name of the section to |
292 | §ion), | 295 | access"), |
296 | §ion), | ||
293 | GNUNET_GETOPT_option_string ('o', | 297 | GNUNET_GETOPT_option_string ('o', |
294 | "option", | 298 | "option", |
295 | "OPTION", | 299 | "OPTION", |
296 | gettext_noop ("name of the option to access"), | 300 | gettext_noop ("name of the option to access"), |
297 | &option), | 301 | &option), |
298 | GNUNET_GETOPT_option_string ('V', | 302 | GNUNET_GETOPT_option_string ('V', |
299 | "value", | 303 | "value", |
300 | "VALUE", | 304 | "VALUE", |
301 | gettext_noop ("value to set"), | 305 | gettext_noop ("value to set"), |
302 | &value), | 306 | &value), |
303 | GNUNET_GETOPT_option_flag ('S', | 307 | GNUNET_GETOPT_option_flag ('S', |
304 | "list-sections", | 308 | "list-sections", |
305 | gettext_noop ("print available configuration sections"), | 309 | gettext_noop ("print available configuration |
306 | &list_sections), | 310 | sections"), |
311 | &list_sections), | ||
307 | GNUNET_GETOPT_option_flag ('w', | 312 | GNUNET_GETOPT_option_flag ('w', |
308 | "rewrite", | 313 | "rewrite", |
309 | gettext_noop ("write configuration file that only contains delta to defaults"), | 314 | gettext_noop ("write configuration file that |
310 | &rewrite), | 315 | only contains delta to defaults"), |
316 | &rewrite), | ||
311 | GNUNET_GETOPT_OPTION_END | 317 | GNUNET_GETOPT_OPTION_END |
312 | }; | 318 | }; |
313 | if (GNUNET_OK != | 319 | if (GNUNET_OK != |
@@ -316,11 +322,12 @@ main (int argc, | |||
316 | return 2; | 322 | return 2; |
317 | 323 | ||
318 | ret = (GNUNET_OK == | 324 | ret = (GNUNET_OK == |
319 | GNUNET_PROGRAM_run (argc, | 325 | GNUNET_PROGRAM_run (argc, |
320 | argv, | 326 | argv, |
321 | "gnunet-config [OPTIONS]", | 327 | "gnunet-config [OPTIONS]", |
322 | gettext_noop ("Manipulate GNUnet configuration files"), | 328 | gettext_noop ("Manipulate GNUnet configuration |
323 | options, | 329 | files"), |
330 | options, | ||
324 | &run, NULL)) ? 0 : ret; | 331 | &run, NULL)) ? 0 : ret; |
325 | GNUNET_free ((void*) argv); | 332 | GNUNET_free ((void*) argv); |
326 | return ret; | 333 | return ret; |