Hello everyone.

This is a sort of follow-up to the previous discussion about 3rd party
applications built on top of GNUnet[1].  In the end it turned out that
for the most part it was caused by a misunderstanding on my part and
incomplete documentation.

After talking with Christian, I decided to patch gnunet-ext with some
suggested changes.  As such, the previous proposal for a
"gnunet_application_lib" component[2] can be scrapped.  The patches are
attached: the one removing platform.h is for gnunet-ext, the other is
for GNUnet itself.  Please review them and tell me if there's anything
wrong or strange.

It still isn't complete as '--help' still prints a line talking about
GNU even when the application isn't part of the GNU project, but I'm not
sure what would be the best approach here.

Thanks,
A.V.

[1] https://lists.gnu.org/archive/html/gnunet-developers/2019-08/msg00005.html
[2] https://gitlab.com/gnunet/gnunet/merge_requests/1

>From 39c08b8b1c3d4a7402c0174cc6e3b077f5316a02 Mon Sep 17 00:00:00 2001
From: Alessio Vanni <[email protected]>
Date: Tue, 6 Aug 2019 19:36:01 +0200
Subject: [PATCH] Add version string to GNUNET_OS_ProjectData

---
 src/include/gnunet_os_lib.h | 4 ++++
 src/util/Makefile.am        | 2 +-
 src/util/os_installation.c  | 1 +
 src/util/program.c          | 7 ++++---
 4 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/include/gnunet_os_lib.h b/src/include/gnunet_os_lib.h
index 6eb4ce5eb..41c75e513 100644
--- a/src/include/gnunet_os_lib.h
+++ b/src/include/gnunet_os_lib.h
@@ -267,6 +267,10 @@ struct GNUNET_OS_ProjectData
    */
   const char *user_config_file;
 
+  /**
+   * String identifying the current project version.
+   */
+  const char *version;
 };
 
 
diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index fe5cc6e72..647f09224 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -161,7 +161,7 @@ libgnunetutil_la_LIBADD = \
 
 libgnunetutil_la_LDFLAGS = \
   $(GN_LIB_LDFLAGS) \
-  -version-info 13:1:0
+  -version-info 13:2:0
 
 libgnunetutil_taler_wallet_la_SOURCES = \
   common_allocation.c \
diff --git a/src/util/os_installation.c b/src/util/os_installation.c
index d2ce7fd9b..9dcfa5ef1 100644
--- a/src/util/os_installation.c
+++ b/src/util/os_installation.c
@@ -57,6 +57,7 @@ static const struct GNUNET_OS_ProjectData default_pd = {
   .libname = "libgnunetutil",
   .project_dirname = "gnunet",
   .binary_name = "gnunet-arm",
+  .version = PACKAGE_VERSION " " VCS_VERSION,
   .env_varname = "GNUNET_PREFIX",
   .base_config_varname = "GNUNET_BASE_CONFIG",
   .bug_email = "[email protected]",
diff --git a/src/util/program.c b/src/util/program.c
index 8a5b1c414..1462a03a8 100644
--- a/src/util/program.c
+++ b/src/util/program.c
@@ -161,12 +161,13 @@ GNUNET_PROGRAM_run2 (int argc,
   unsigned long long skew_variance;
   long long clock_offset;
   struct GNUNET_CONFIGURATION_Handle *cfg;
+  const struct GNUNET_OS_ProjectData *pd = GNUNET_OS_project_data_get ();
   struct GNUNET_GETOPT_CommandLineOption defoptions[] =
     {GNUNET_GETOPT_option_cfgfile (&cc.cfgfile),
      GNUNET_GETOPT_option_help (binaryHelp),
      GNUNET_GETOPT_option_loglevel (&loglev),
      GNUNET_GETOPT_option_logfile (&logfile),
-     GNUNET_GETOPT_option_version (PACKAGE_VERSION " " VCS_VERSION)};
+     GNUNET_GETOPT_option_version (pd->version)};
   struct GNUNET_GETOPT_CommandLineOption *allopts;
   const char *gargs;
   char *lpfx;
@@ -231,9 +232,9 @@ GNUNET_PROGRAM_run2 (int argc,
                      "%s%s%s",
                      xdg,
                      DIR_SEPARATOR_STR,
-                     GNUNET_OS_project_data_get ()->config_file);
+                     pd->config_file);
   else
-    cfg_fn = GNUNET_strdup (GNUNET_OS_project_data_get ()->user_config_file);
+    cfg_fn = GNUNET_strdup (pd->user_config_file);
   lpfx = GNUNET_strdup (binaryName);
   if (NULL != (spc = strstr (lpfx, " ")))
     *spc = '\0';
-- 
2.21.0

>From 43510f76ddfb2d8b3faf8f2b85baf6cfb22f203e Mon Sep 17 00:00:00 2001
From: Alessio Vanni <[email protected]>
Date: Tue, 6 Aug 2019 19:28:31 +0200
Subject: [PATCH] Remove platform.h and set project data

---
 src/ext/ext_api.c      | 12 +++++++++++-
 src/ext/gnunet-ext.c   | 32 +++++++++++++++++++++++++++++++-
 src/ext/test_ext_api.c | 12 +++++++++++-
 3 files changed, 53 insertions(+), 3 deletions(-)

diff --git a/src/ext/ext_api.c b/src/ext/ext_api.c
index 65637d5..365dd89 100644
--- a/src/ext/ext_api.c
+++ b/src/ext/ext_api.c
@@ -23,7 +23,17 @@
  * @brief API for ext
  * @author
  */
-#include <gnunet/platform.h>
+#include "gnunet_ext_config.h"
+#include <stddef.h>
+
+#if WINDOWS
+#define FDTYPE HANDLE
+#define SOCKTYPE SOCKET
+#else
+#define FDTYPE int
+#define SOCKTYPE int
+#endif
+
 #include <gnunet/gnunet_util_lib.h>
 #include "gnunet_ext_service.h"
 
diff --git a/src/ext/gnunet-ext.c b/src/ext/gnunet-ext.c
index 36fc02b..0df3fe7 100644
--- a/src/ext/gnunet-ext.c
+++ b/src/ext/gnunet-ext.c
@@ -23,12 +23,39 @@
  * @brief ext tool
  * @author
  */
-#include <gnunet/platform.h>
+#include "gnunet_ext_config.h"
+#include <stddef.h>
+
+#if WINDOWS
+#define FDTYPE HANDLE
+#define SOCKTYPE SOCKET
+#else
+#define FDTYPE int
+#define SOCKTYPE int
+#endif
+
+#include <gnunet/gettext.h>
 #include <gnunet/gnunet_util_lib.h>
 #include "gnunet_ext_service.h"
 
 static int ret;
 
+/**
+ * This structure holds informations about the project.
+ */
+static const struct GNUNET_OS_ProjectData gnunetext_pd = {
+     .libname = "libgnunetext",
+     .project_dirname = "gnunet-ext",
+     .binary_name = "gnunet-ext",
+     .env_varname = "GNUNET_EXT_PREFIX",
+     .base_config_varname = "GNUNET_EXT_BASE_CONFIG",
+     .bug_email = "[email protected]",
+     .homepage = "http://www.gnu.org/s/gnunet/";,
+     .config_file = "gnunet-ext.conf",
+     .user_config_file = "~/.config/gnunet-ext.conf",
+     .version = "1.0",
+};
+
 /**
  * Main function that will be run by the scheduler.
  *
@@ -60,6 +87,9 @@ main (int argc, char *const *argv)
   static const struct GNUNET_GETOPT_CommandLineOption options[] = {
     GNUNET_GETOPT_OPTION_END
   };
+
+  GNUNET_OS_init(&gnunetext_pd);
+  
   return (GNUNET_OK ==
           GNUNET_PROGRAM_run (argc,
                               argv,
diff --git a/src/ext/test_ext_api.c b/src/ext/test_ext_api.c
index 75a7cc4..e69dca0 100644
--- a/src/ext/test_ext_api.c
+++ b/src/ext/test_ext_api.c
@@ -21,7 +21,17 @@
  * @file ext/test_ext_api.c
  * @brief testcase for ext_api.c
  */
-#include <gnunet/platform.h>
+#include "gnunet_ext_config.h"
+#include <stddef.h>
+
+#if WINDOWS
+#define FDTYPE HANDLE
+#define SOCKTYPE SOCKET
+#else
+#define FDTYPE int
+#define SOCKTYPE int
+#endif
+
 #include <gnunet/gnunet_util_lib.h>
 #include "gnunet_ext_service.h"
 
-- 
2.21.0

_______________________________________________
GNUnet-developers mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/gnunet-developers

Reply via email to