commit-inetutils
[Top][All Lists]
Advanced

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

[SCM] GNU Inetutils branch, master, updated. inetutils-1_9_4-76-g34fd84


From: Mats Erik Andersson
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_9_4-76-g34fd840
Date: Mon, 10 Feb 2020 09:51:40 -0500 (EST)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  34fd840302a885da9ef29c83c9800be651ff075e (commit)
      from  a1d8a1f87d62e5d00c29008f41d350dc2deceaaf (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=34fd840302a885da9ef29c83c9800be651ff075e


commit 34fd840302a885da9ef29c83c9800be651ff075e
Author: Mats Erik Andersson <address@hidden>
Date:   Mon Feb 10 15:48:28 2020 +0100

    Code simplification for program runtime-ipv6.

diff --git a/ChangeLog b/ChangeLog
index 014a250..98e30ed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2020-02-10  Mats Erik Andersson  <address@hidden>
+
+       Simplify coding of test program `runtime-ipv6', by using
+       standard getopt() library function, thus making the code
+       self sufficient.
+
+       * tests/runtime-ipv6.c: Migrate away from argp_parse() to
+       standard getopt().  Let environment variable VERBOSE contribute
+       a short message in case the program tests successfully.
+       Also use AI_NUMERICSERV for completeness.
+
 2020-02-09  Mats Erik Andersson  <address@hidden>
 
        test-snprintf: New test program.
diff --git a/tests/runtime-ipv6.c b/tests/runtime-ipv6.c
index 2f4e128..7f0cbc5 100644
--- a/tests/runtime-ipv6.c
+++ b/tests/runtime-ipv6.c
@@ -28,9 +28,14 @@
  *
  * Return value is 0 (zero) when successful, otherwise -1.
  * On failure a message is printed to stderr: `IPv# disabled in system'.
+ *
+ * By defining the shell environment variable VERBOSE, a short affirmative
+ * message is printed also in case of successful testing.
  */
 
-#include <config.h>
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
 
 #include <stdio.h>
 #include <unistd.h>
@@ -42,11 +47,6 @@
 #include <sys/socket.h>
 #include <netdb.h>
 
-#include <argp.h>
-#include <progname.h>
-#include <unused-parameter.h>
-#include "libinetutils.h"
-
 #define RESOLVE_OK            0
 #define RESOLVE_FAIL         -1
 
@@ -55,60 +55,40 @@ int tested_family = AF_INET6;
 char *tested_family_name = "IPv6";
 char *tested_localhost = "::1";
 
-const char doc[] = "Detect presence of address family";
-
-const char *program_authors[] = { "Mats Erik Andersson", NULL };
-
-static struct argp_option argp_options[] = {
-#define GRP 1
-  {"ipv4", '4', NULL, 0, "test for IPv4", GRP },
-  {"ipv6", '6', NULL, 0, "test for IPv6 (default)", GRP },
-#undef GRP
-  {NULL, 0, NULL, 0, NULL, 0}
-};
-
-static error_t
-parse_opt (int key, char *arg, struct argp_state *state _GL_UNUSED_PARAMETER)
-{
-  switch (key)
-    {
-    case '4':
-      tested_family = AF_INET;
-      tested_family_name = "IPv4";
-      tested_localhost = "127.0.0.1";
-      break;
-
-    case '6':
-      tested_family = AF_INET6;
-      tested_family_name = "IPv6";
-      tested_localhost = "::1";
-      break;
-
-    default:
-      return ARGP_ERR_UNKNOWN;
-    }
-
-  return 0;
-}
-
-static struct argp argp =
-  {argp_options, parse_opt, NULL, doc, NULL, NULL, NULL};
-
 int
 main (int argc, char *argv[])
 {
-  int err;
-  struct sockaddr_storage ss;
+  int err, ch;
   struct addrinfo hints, *aiptr;
 
-  set_program_name (argv[0]);
-  iu_argp_init ("runtime-ipv6", program_authors);
-  argp_parse (&argp, argc, argv, 0, NULL, NULL);
+  while ((ch = getopt (argc, argv, "46")) != -1)
+    {
+      switch (ch)
+       {
+       case '4':
+         tested_family = AF_INET;
+         tested_family_name = "IPv4";
+         tested_localhost = "127.0.0.1";
+         break;
+
+       case '6':
+         tested_family = AF_INET6;
+         tested_family_name = "IPv6";
+         tested_localhost = "::1";
+         break;
+
+       default:
+         fprintf (stderr, "Usage: %s [-4 | -6]\n"
+                  "Determines presence of selected INET address family.\n",
+                  argv[0]);
+         return EXIT_FAILURE;
+       }
+    }
 
   memset (&hints, 0, sizeof (hints));
   hints.ai_family = tested_family;
   hints.ai_socktype = SOCK_DGRAM;
-  hints.ai_flags = AI_NUMERICHOST;
+  hints.ai_flags = AI_NUMERICHOST | AI_NUMERICSERV;
 #ifdef AI_ADDRCONFIG
   hints.ai_flags |= AI_ADDRCONFIG;
 #endif
@@ -135,6 +115,9 @@ main (int argc, char *argv[])
 
       return RESOLVE_FAIL;
     }
+  else if (getenv ("VERBOSE"))
+    printf ("Detection of %s address %s was successful.\n",
+           tested_family_name, tested_localhost);
 
   return RESOLVE_OK;
 }

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog            | 11 +++++++
 tests/runtime-ipv6.c | 85 +++++++++++++++++++++-------------------------------
 2 files changed, 45 insertions(+), 51 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 



reply via email to

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