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.c186
1 files changed, 0 insertions, 186 deletions
diff --git a/src/util/gnunet-config.c b/src/util/gnunet-config.c
deleted file mode 100644
index 2ca78577e..000000000
--- a/src/util/gnunet-config.c
+++ /dev/null
@@ -1,186 +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 * If printing the value of CFLAGS has been requested.
40 */
41static int cflags;
42
43
44/**
45 * If printing the value of LIBS has been requested.
46 */
47static int libs;
48
49
50/**
51 * If printing the value of PREFIX has been requested.
52 */
53static int prefix;
54
55
56/**
57 * Print each option in a given section.
58 * Main task to run to perform operations typical for
59 * gnunet-config as per the configuration settings
60 * given in @a cls.
61 *
62 * @param cls closure with the `struct GNUNET_CONFIGURATION_ConfigSettings`
63 * @param args remaining command-line arguments
64 * @param cfgfile name of the configuration file used (for saving,
65 * can be NULL!)
66 * @param cfg configuration
67 */
68static void
69run (void *cls,
70 char *const *args,
71 const char *cfgfile,
72 const struct GNUNET_CONFIGURATION_Handle *cfg)
73{
74 struct GNUNET_CONFIGURATION_ConfigSettings *cs = cls;
75
76 if (1 == cflags || 1 == libs || 1 == prefix)
77 {
78 char *prefixdir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_PREFIX);
79 char *libdir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LIBDIR);
80
81 if (1 == cflags)
82 {
83 fprintf (stdout, "-I%sinclude\n", prefixdir);
84 }
85 if (1 == libs)
86 {
87 fprintf (stdout, "-L%s -lgnunetutil\n", libdir);
88 }
89 if (1 == prefix)
90 {
91 fprintf (stdout, "%s\n", prefixdir);
92 }
93 cs->global_ret = 0;
94 GNUNET_free (prefixdir);
95 GNUNET_free (libdir);
96 return;
97 }
98 if (NULL != backend_check)
99 {
100 char *name;
101
102 GNUNET_asprintf (&name,
103 "libgnunet_plugin_%s",
104 backend_check);
105 cs->global_ret = (GNUNET_OK ==
106 GNUNET_PLUGIN_test (name)) ? 0 : 77;
107 GNUNET_free (name);
108 return;
109 }
110 GNUNET_CONFIGURATION_config_tool_run (cs,
111 args,
112 cfgfile,
113 cfg);
114}
115
116
117/**
118 * Program to manipulate configuration files.
119 *
120 * @param argc number of arguments from the command line
121 * @param argv command line arguments
122 * @return 0 ok, 1 on error
123 */
124int
125main (int argc,
126 char *const *argv)
127{
128 struct GNUNET_CONFIGURATION_ConfigSettings cs = {
129 .api_version = GNUNET_UTIL_VERSION,
130 .global_ret = EXIT_SUCCESS
131 };
132 struct GNUNET_GETOPT_CommandLineOption options[] = {
133 GNUNET_GETOPT_option_exclusive (
134 GNUNET_GETOPT_option_string (
135 'b',
136 "supported-backend",
137 "BACKEND",
138 gettext_noop (
139 "test if the current installation supports the specified BACKEND"),
140 &backend_check)),
141 GNUNET_GETOPT_option_flag (
142 'C',
143 "cflags",
144 gettext_noop (
145 "Provide an appropriate value for CFLAGS to applications building on top of GNUnet"),
146 &cflags),
147 GNUNET_GETOPT_option_flag (
148 'j',
149 "libs",
150 gettext_noop (
151 "Provide an appropriate value for LIBS to applications building on top of GNUnet"),
152 &libs),
153 GNUNET_GETOPT_option_flag (
154 'p',
155 "prefix",
156 gettext_noop (
157 "Provide the path under which GNUnet was installed"),
158 &prefix),
159 GNUNET_CONFIGURATION_CONFIG_OPTIONS (&cs),
160 GNUNET_GETOPT_OPTION_END
161 };
162 enum GNUNET_GenericReturnValue ret;
163
164 if (GNUNET_OK !=
165 GNUNET_STRINGS_get_utf8_args (argc, argv,
166 &argc, &argv))
167 return EXIT_FAILURE;
168 ret =
169 GNUNET_PROGRAM_run (argc,
170 argv,
171 "gnunet-config [OPTIONS]",
172 gettext_noop ("Manipulate GNUnet configuration files"),
173 options,
174 &run,
175 &cs);
176 GNUNET_free_nz ((void *) argv);
177 GNUNET_CONFIGURATION_config_settings_free (&cs);
178 if (GNUNET_NO == ret)
179 return 0;
180 if (GNUNET_SYSERR == ret)
181 return EXIT_INVALIDARGUMENT;
182 return cs.global_ret;
183}
184
185
186/* end of gnunet-config.c */