manipulate GNUnet configuration files
.Sh SYNOPSIS
.Nm
+.Op Fl b Ar BACKEND | Fl \-supported-backend= Ns Ar BACKEND
.Op Fl c Ar FILENAME | Fl \-config= Ns Ar FILENAME
.Op Fl f | \-filename
.Op Fl h | \-help
.Nm
can be used to read or modify GNUnet configuration files.
.Bl -tag -width indent
+.It Fl b Ar BACKEND | Fl \-supported-backend= Ns Ar BACKEND
+Tests whether the specified BACKEND is supported by the current installation. The backend must match the name of a plugin, i.e. "namestore_postgres" for the Postgres database backend of the "NAMESTORE" service. If the BACKEND is supported, gnunet-config will return a status code of 0 (success), otherwise 77 (unsupported). When this option is specified, no other options may be specified. Specifying this option together with other options will cause gnunet-config to return a status code of 1 (error).
.It Fl c Ar FILENAME | Fl \-config= Ns Ar FILENAME
Use the configuration file FILENAME.
.It Fl f | \-filename
*/
static 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.
+ */
+static char *backend_check;
+
/**
* Treat option as a filename.
*/
/**
* Return value from 'main'.
*/
-static int ret;
+static int global_ret;
/**
* Should we generate a configuration file that is clean and
*/
static int rewrite;
+
/**
* Print each option in a given section.
*
(void) cls;
(void) args;
+ if (NULL != backend_check)
+ {
+ char *name;
+
+ GNUNET_asprintf (&name,
+ "libgnunet_plugin_%s",
+ backend_check);
+ global_ret = (GNUNET_OK == GNUNET_PLUGIN_test (name)) ? 0 : 77;
+ GNUNET_free (name);
+ return;
+ }
if (rewrite)
{
struct GNUNET_CONFIGURATION_Handle *def;
{
fprintf (stderr,
_("failed to load configuration defaults"));
- ret = 1;
+ global_ret = 1;
return;
}
diff = GNUNET_CONFIGURATION_get_diff (def,
_("%s or %s argument is required\n"),
"--section",
"--list-sections");
- ret = 1;
+ global_ret = 1;
}
else
{
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
section, option);
- ret = 3;
+ global_ret = 3;
goto cleanup;
}
}
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
section, option);
- ret = 3;
+ global_ret = 3;
goto cleanup;
}
}
if (NULL == option)
{
fprintf (stderr, _("--option argument required to set value\n"));
- ret = 1;
+ global_ret = 1;
goto cleanup;
}
out = GNUNET_CONFIGURATION_dup (cfg);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_write ((NULL == out) ? diff : out,
cfgfile))
- ret = 2;
+ global_ret = 2;
}
GNUNET_free_non_null (cfg_fn);
if (NULL != out)
"filename",
gettext_noop ("interpret option value as a filename (with $-expansion)"),
&is_filename),
+ //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_GETOPT_option_string ('s',
"section",
"SECTION",
&rewrite),
GNUNET_GETOPT_OPTION_END
};
+ int ret;
+
if (GNUNET_OK !=
GNUNET_STRINGS_get_utf8_args (argc, argv,
&argc, &argv))
return 2;
- ret = (GNUNET_OK ==
- GNUNET_PROGRAM_run (argc,
- argv,
- "gnunet-config [OPTIONS]",
- gettext_noop ("Manipulate GNUnet configuration files"),
- options,
- &run, NULL)) ? 0 : ret;
+ ret = GNUNET_PROGRAM_run (argc,
+ argv,
+ "gnunet-config [OPTIONS]",
+ gettext_noop ("Manipulate GNUnet configuration files"),
+ options,
+ &run, NULL);
GNUNET_free ((void*) argv);
- return ret;
+ if (GNUNET_OK == ret)
+ return global_ret;
+ return 1;
}
/* end of gnunet-config.c */