diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-09-05 18:27:53 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-09-05 18:27:53 +0200 |
commit | f9f3cbe9fcedfb8ca95275d5e406b1270062d7ea (patch) | |
tree | 27b0edf698cb8044dcd9b51833271454e6c29aa5 /src/util | |
parent | b4e034d9aa471c6244718914e08be3ee414b18e6 (diff) | |
download | gnunet-f9f3cbe9fcedfb8ca95275d5e406b1270062d7ea.tar.gz gnunet-f9f3cbe9fcedfb8ca95275d5e406b1270062d7ea.zip |
make backend-check a gnunet-only gnunet-config option
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/configuration_helper.c | 14 | ||||
-rw-r--r-- | src/util/gnunet-config.c | 57 |
2 files changed, 56 insertions, 15 deletions
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 | */ | ||
35 | static 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 | */ | ||
49 | static void | ||
50 | run (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); |