summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-09-05 18:27:53 +0200
committerChristian Grothoff <christian@grothoff.org>2021-09-05 18:27:53 +0200
commitf9f3cbe9fcedfb8ca95275d5e406b1270062d7ea (patch)
tree27b0edf698cb8044dcd9b51833271454e6c29aa5
parentb4e034d9aa471c6244718914e08be3ee414b18e6 (diff)
make backend-check a gnunet-only gnunet-config option
-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
{
/**
+ * Must be set to the API version, i.e.
+ * #GNUNET_UTIL_VERSION. Used to detect
+ * which version of the struct the client
+ * is using.
+ */
+ unsigned int api_version;
+
+ /**
* Name of the section
*/
char *section;
@@ -657,13 +665,6 @@ struct GNUNET_CONFIGURATION_ConfigSettings
char *value;
/**
- * Backend to check if the respective plugin is
- * loadable. NULL if no check is to be performed.
- * The value is the "basename" of the plugin to load.
- */
- char *backend_check;
-
- /**
* Treat option as a filename.
*/
int is_filename;
@@ -706,14 +707,6 @@ struct GNUNET_CONFIGURATION_ConfigSettings
* @param cs configuration settings to initialize
*/
#define GNUNET_CONFIGURATION_CONFIG_OPTIONS(cs) \
- GNUNET_GETOPT_option_exclusive ( \
- GNUNET_GETOPT_option_string ( \
- 'b', \
- "supported-backend", \
- "BACKEND", \
- gettext_noop ( \
- "test if the current installation supports the specified BACKEND"), \
- &(cs)->backend_check)), \
GNUNET_GETOPT_option_flag ( \
'F', \
"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 (
struct GNUNET_CONFIGURATION_Handle *ncfg = NULL;
(void) args;
- if (NULL != cs->backend_check)
- {
- char *name;
-
- GNUNET_asprintf (&name,
- "libgnunet_plugin_%s",
- cs->backend_check);
- cs->global_ret = (GNUNET_OK ==
- GNUNET_PLUGIN_test (name)) ? 0 : 77;
- GNUNET_free (name);
- return;
- }
-
if (cs->diagnostics)
{
/* Re-parse the configuration with diagnostics enabled. */
@@ -309,7 +296,6 @@ GNUNET_CONFIGURATION_config_settings_free (
GNUNET_free (cs->option);
GNUNET_free (cs->section);
GNUNET_free (cs->value);
- GNUNET_free (cs->backend_check);
}
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 @@
/**
+ * Backend to check if the respective plugin is
+ * loadable. NULL if no check is to be performed.
+ * The value is the "basename" of the plugin to load.
+ */
+static char *backend_check;
+
+
+/**
+ * Main task to run to perform operations typical for
+ * gnunet-config as per the configuration settings
+ * given in @a cls.
+ *
+ * @param cls closure with the `struct GNUNET_CONFIGURATION_ConfigSettings`
+ * @param args remaining command-line arguments
+ * @param cfgfile name of the configuration file used (for saving,
+ * can be NULL!)
+ * @param cfg configuration
+ */
+static void
+run (void *cls,
+ char *const *args,
+ const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+ struct GNUNET_CONFIGURATION_ConfigSettings *cs = cls;
+
+ if (NULL != backend_check)
+ {
+ char *name;
+
+ GNUNET_asprintf (&name,
+ "libgnunet_plugin_%s",
+ backend_check);
+ cs->global_ret = (GNUNET_OK ==
+ GNUNET_PLUGIN_test (name)) ? 0 : 77;
+ GNUNET_free (name);
+ return;
+ }
+ GNUNET_CONFIGURATION_config_tool_run (cs,
+ args,
+ cfgfile,
+ cfg);
+}
+
+
+/**
* Program to manipulate configuration files.
*
* @param argc number of arguments from the command line
@@ -39,9 +85,18 @@ main (int argc,
char *const *argv)
{
struct GNUNET_CONFIGURATION_ConfigSettings cs = {
+ .api_version = GNUNET_UTIL_VERSION,
.global_ret = EXIT_SUCCESS
};
struct GNUNET_GETOPT_CommandLineOption options[] = {
+ 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_CONFIGURATION_CONFIG_OPTIONS (&cs),
GNUNET_GETOPT_OPTION_END
};
@@ -57,7 +112,7 @@ main (int argc,
"gnunet-config [OPTIONS]",
gettext_noop ("Manipulate GNUnet configuration files"),
options,
- &GNUNET_CONFIGURATION_config_tool_run,
+ &run,
&cs);
GNUNET_free_nz ((void *) argv);
GNUNET_CONFIGURATION_config_settings_free (&cs);