aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/gnunet_configuration_lib.h23
-rw-r--r--src/util/configuration_helper.c14
-rw-r--r--src/util/gnunet-config.c57
3 files changed, 64 insertions, 30 deletions
diff --git a/src/include/gnunet_configuration_lib.h b/src/include/gnunet_configuration_lib.h
index 46b745541..234f66e61 100644
--- a/src/include/gnunet_configuration_lib.h
+++ b/src/include/gnunet_configuration_lib.h
@@ -642,6 +642,14 @@ struct GNUNET_CONFIGURATION_ConfigSettings
642{ 642{
643 643
644 /** 644 /**
645 * Must be set to the API version, i.e.
646 * #GNUNET_UTIL_VERSION. Used to detect
647 * which version of the struct the client
648 * is using.
649 */
650 unsigned int api_version;
651
652 /**
645 * Name of the section 653 * Name of the section
646 */ 654 */
647 char *section; 655 char *section;
@@ -657,13 +665,6 @@ struct GNUNET_CONFIGURATION_ConfigSettings
657 char *value; 665 char *value;
658 666
659 /** 667 /**
660 * Backend to check if the respective plugin is
661 * loadable. NULL if no check is to be performed.
662 * The value is the "basename" of the plugin to load.
663 */
664 char *backend_check;
665
666 /**
667 * Treat option as a filename. 668 * Treat option as a filename.
668 */ 669 */
669 int is_filename; 670 int is_filename;
@@ -706,14 +707,6 @@ struct GNUNET_CONFIGURATION_ConfigSettings
706 * @param cs configuration settings to initialize 707 * @param cs configuration settings to initialize
707 */ 708 */
708#define GNUNET_CONFIGURATION_CONFIG_OPTIONS(cs) \ 709#define GNUNET_CONFIGURATION_CONFIG_OPTIONS(cs) \
709 GNUNET_GETOPT_option_exclusive ( \
710 GNUNET_GETOPT_option_string ( \
711 'b', \
712 "supported-backend", \
713 "BACKEND", \
714 gettext_noop ( \
715 "test if the current installation supports the specified BACKEND"), \
716 &(cs)->backend_check)), \
717 GNUNET_GETOPT_option_flag ( \ 710 GNUNET_GETOPT_option_flag ( \
718 'F', \ 711 'F', \
719 "full", \ 712 "full", \
diff --git a/src/util/configuration_helper.c b/src/util/configuration_helper.c
index eb8b543d1..8f995ec03 100644
--- a/src/util/configuration_helper.c
+++ b/src/util/configuration_helper.c
@@ -115,19 +115,6 @@ GNUNET_CONFIGURATION_config_tool_run (
115 struct GNUNET_CONFIGURATION_Handle *ncfg = NULL; 115 struct GNUNET_CONFIGURATION_Handle *ncfg = NULL;
116 116
117 (void) args; 117 (void) args;
118 if (NULL != cs->backend_check)
119 {
120 char *name;
121
122 GNUNET_asprintf (&name,
123 "libgnunet_plugin_%s",
124 cs->backend_check);
125 cs->global_ret = (GNUNET_OK ==
126 GNUNET_PLUGIN_test (name)) ? 0 : 77;
127 GNUNET_free (name);
128 return;
129 }
130
131 if (cs->diagnostics) 118 if (cs->diagnostics)
132 { 119 {
133 /* Re-parse the configuration with diagnostics enabled. */ 120 /* Re-parse the configuration with diagnostics enabled. */
@@ -309,7 +296,6 @@ GNUNET_CONFIGURATION_config_settings_free (
309 GNUNET_free (cs->option); 296 GNUNET_free (cs->option);
310 GNUNET_free (cs->section); 297 GNUNET_free (cs->section);
311 GNUNET_free (cs->value); 298 GNUNET_free (cs->value);
312 GNUNET_free (cs->backend_check);
313} 299}
314 300
315 301
diff --git a/src/util/gnunet-config.c b/src/util/gnunet-config.c
index 202ef7866..797de0b0d 100644
--- a/src/util/gnunet-config.c
+++ b/src/util/gnunet-config.c
@@ -28,6 +28,52 @@
28 28
29 29
30/** 30/**
31 * Backend to check if the respective plugin is
32 * loadable. NULL if no check is to be performed.
33 * The value is the "basename" of the plugin to load.
34 */
35static char *backend_check;
36
37
38/**
39 * Main task to run to perform operations typical for
40 * gnunet-config as per the configuration settings
41 * given in @a cls.
42 *
43 * @param cls closure with the `struct GNUNET_CONFIGURATION_ConfigSettings`
44 * @param args remaining command-line arguments
45 * @param cfgfile name of the configuration file used (for saving,
46 * can be NULL!)
47 * @param cfg configuration
48 */
49static void
50run (void *cls,
51 char *const *args,
52 const char *cfgfile,
53 const struct GNUNET_CONFIGURATION_Handle *cfg)
54{
55 struct GNUNET_CONFIGURATION_ConfigSettings *cs = cls;
56
57 if (NULL != backend_check)
58 {
59 char *name;
60
61 GNUNET_asprintf (&name,
62 "libgnunet_plugin_%s",
63 backend_check);
64 cs->global_ret = (GNUNET_OK ==
65 GNUNET_PLUGIN_test (name)) ? 0 : 77;
66 GNUNET_free (name);
67 return;
68 }
69 GNUNET_CONFIGURATION_config_tool_run (cs,
70 args,
71 cfgfile,
72 cfg);
73}
74
75
76/**
31 * Program to manipulate configuration files. 77 * Program to manipulate configuration files.
32 * 78 *
33 * @param argc number of arguments from the command line 79 * @param argc number of arguments from the command line
@@ -39,9 +85,18 @@ main (int argc,
39 char *const *argv) 85 char *const *argv)
40{ 86{
41 struct GNUNET_CONFIGURATION_ConfigSettings cs = { 87 struct GNUNET_CONFIGURATION_ConfigSettings cs = {
88 .api_version = GNUNET_UTIL_VERSION,
42 .global_ret = EXIT_SUCCESS 89 .global_ret = EXIT_SUCCESS
43 }; 90 };
44 struct GNUNET_GETOPT_CommandLineOption options[] = { 91 struct GNUNET_GETOPT_CommandLineOption options[] = {
92 GNUNET_GETOPT_option_exclusive (
93 GNUNET_GETOPT_option_string (
94 'b',
95 "supported-backend",
96 "BACKEND",
97 gettext_noop (
98 "test if the current installation supports the specified BACKEND"),
99 &backend_check)),
45 GNUNET_CONFIGURATION_CONFIG_OPTIONS (&cs), 100 GNUNET_CONFIGURATION_CONFIG_OPTIONS (&cs),
46 GNUNET_GETOPT_OPTION_END 101 GNUNET_GETOPT_OPTION_END
47 }; 102 };
@@ -57,7 +112,7 @@ main (int argc,
57 "gnunet-config [OPTIONS]", 112 "gnunet-config [OPTIONS]",
58 gettext_noop ("Manipulate GNUnet configuration files"), 113 gettext_noop ("Manipulate GNUnet configuration files"),
59 options, 114 options,
60 &GNUNET_CONFIGURATION_config_tool_run, 115 &run,
61 &cs); 116 &cs);
62 GNUNET_free_nz ((void *) argv); 117 GNUNET_free_nz ((void *) argv);
63 GNUNET_CONFIGURATION_config_settings_free (&cs); 118 GNUNET_CONFIGURATION_config_settings_free (&cs);