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.c127
1 files changed, 0 insertions, 127 deletions
diff --git a/src/util/gnunet-config.c b/src/util/gnunet-config.c
deleted file mode 100644
index 797de0b0d..000000000
--- a/src/util/gnunet-config.c
+++ /dev/null
@@ -1,127 +0,0 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2012-2021 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @file util/gnunet-config.c
23 * @brief tool to access and manipulate GNUnet configuration files
24 * @author Christian Grothoff
25 */
26#include "platform.h"
27#include "gnunet_util_lib.h"
28
29
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/**
77 * Program to manipulate configuration files.
78 *
79 * @param argc number of arguments from the command line
80 * @param argv command line arguments
81 * @return 0 ok, 1 on error
82 */
83int
84main (int argc,
85 char *const *argv)
86{
87 struct GNUNET_CONFIGURATION_ConfigSettings cs = {
88 .api_version = GNUNET_UTIL_VERSION,
89 .global_ret = EXIT_SUCCESS
90 };
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)),
100 GNUNET_CONFIGURATION_CONFIG_OPTIONS (&cs),
101 GNUNET_GETOPT_OPTION_END
102 };
103 enum GNUNET_GenericReturnValue ret;
104
105 if (GNUNET_OK !=
106 GNUNET_STRINGS_get_utf8_args (argc, argv,
107 &argc, &argv))
108 return EXIT_FAILURE;
109 ret =
110 GNUNET_PROGRAM_run (argc,
111 argv,
112 "gnunet-config [OPTIONS]",
113 gettext_noop ("Manipulate GNUnet configuration files"),
114 options,
115 &run,
116 &cs);
117 GNUNET_free_nz ((void *) argv);
118 GNUNET_CONFIGURATION_config_settings_free (&cs);
119 if (GNUNET_NO == ret)
120 return 0;
121 if (GNUNET_SYSERR == ret)
122 return EXIT_INVALIDARGUMENT;
123 return cs.global_ret;
124}
125
126
127/* end of gnunet-config.c */