aboutsummaryrefslogtreecommitdiff
path: root/src/util/gnunet-config.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/gnunet-config.c')
-rw-r--r--src/util/gnunet-config.c57
1 files changed, 56 insertions, 1 deletions
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);