gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnunet] branch master updated: implement #5771


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated: implement #5771
Date: Sat, 22 Jun 2019 11:49:46 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 4b3469ce5 implement #5771
4b3469ce5 is described below

commit 4b3469ce52759581bf8833a3093cfe7ddad8aa9d
Author: Christian Grothoff <address@hidden>
AuthorDate: Sat Jun 22 11:48:40 2019 +0200

    implement #5771
---
 doc/man/gnunet-config.1  |  3 +++
 src/util/gnunet-config.c | 58 +++++++++++++++++++++++++++++++++++-------------
 2 files changed, 46 insertions(+), 15 deletions(-)

diff --git a/doc/man/gnunet-config.1 b/doc/man/gnunet-config.1
index 0e612fe29..95dc98811 100644
--- a/doc/man/gnunet-config.1
+++ b/doc/man/gnunet-config.1
@@ -30,6 +30,7 @@
 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
@@ -44,6 +45,8 @@ manipulate GNUnet configuration files
 .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  [...]
 .It Fl c Ar FILENAME | Fl \-config= Ns Ar FILENAME
 Use the configuration file FILENAME.
 .It Fl f | \-filename
diff --git a/src/util/gnunet-config.c b/src/util/gnunet-config.c
index f700428a2..9c292205a 100644
--- a/src/util/gnunet-config.c
+++ b/src/util/gnunet-config.c
@@ -42,6 +42,13 @@ static char *option;
  */
 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.
  */
@@ -55,7 +62,7 @@ static int list_sections;
 /**
  * Return value from 'main'.
  */
-static int ret;
+static int global_ret;
 
 /**
  * Should we generate a configuration file that is clean and
@@ -63,6 +70,7 @@ static int ret;
  */
 static int rewrite;
 
+
 /**
  * Print each option in a given section.
  *
@@ -149,6 +157,17 @@ run (void *cls,
 
   (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;
@@ -159,7 +178,7 @@ run (void *cls,
     {
       fprintf (stderr,
                _("failed to load configuration defaults"));
-      ret = 1;
+      global_ret = 1;
       return;
     }
     diff = GNUNET_CONFIGURATION_get_diff (def,
@@ -174,7 +193,7 @@ run (void *cls,
                _("%s or %s argument is required\n"),
                "--section",
                "--list-sections");
-      ret = 1;
+      global_ret = 1;
     }
     else
     {
@@ -208,7 +227,7 @@ run (void *cls,
         {
           GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
                                      section, option);
-          ret = 3;
+          global_ret = 3;
           goto cleanup;
         }
       }
@@ -220,7 +239,7 @@ run (void *cls,
         {
           GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
                                      section, option);
-          ret = 3;
+          global_ret = 3;
           goto cleanup;
         }
       }
@@ -232,7 +251,7 @@ run (void *cls,
     if (NULL == option)
     {
       fprintf (stderr, _("--option argument required to set value\n"));
-      ret = 1;
+      global_ret = 1;
       goto cleanup;
     }
     out = GNUNET_CONFIGURATION_dup (cfg);
@@ -260,7 +279,7 @@ run (void *cls,
     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)
@@ -287,6 +306,12 @@ main (int argc,
       "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",
@@ -312,20 +337,23 @@ main (int argc,
                                &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 */

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]