Add support for `--version'
authorPhil Blundell <philb@gnu.org>
Sun, 18 Apr 1999 19:41:16 +0000 (19:41 +0000)
committerPhil Blundell <philb@gnu.org>
Sun, 18 Apr 1999 19:41:16 +0000 (19:41 +0000)
ipmaddr.c
iptunnel.c
plipconfig.c
slattach.c

index 7bc72fe..1b64474 100644 (file)
--- a/ipmaddr.c
+++ b/ipmaddr.c
@@ -44,8 +44,8 @@ char *Release = RELEASE,
 
 static void version(void)
 {
-    printf("%s\n%s\n%s\n", Release, Version, Signature);
-    exit(E_VERSION);
+       printf("%s\n%s\n%s\n", Release, Version, Signature);
+       exit(E_VERSION);
 }
 
 static void usage(void) __attribute__((noreturn));
@@ -54,6 +54,7 @@ static void usage(void)
 {
        fprintf(stderr, _("Usage: ipmaddr [ add | del ] MULTIADDR dev STRING\n"));
        fprintf(stderr, _("       ipmaddr show [ dev STRING ] [ ipv4 | ipv6 | link | all ]\n"));
+       fprintf(stderr, _("       ipmaddr -V | -version\n"));
        exit(-1);
 }
 
@@ -408,7 +409,7 @@ int main(int argc, char **argv)
                        ++show_stats;
                } else if (matches(argv[1], "-resolve") == 0) {
                        ++resolve_hosts;
-               } else if (matches(argv[1], "-V") == 0) {
+               } else if ((matches(argv[1], "-V") == 0) || matches(argv[1], "--version") == 0) {
                        version();
                } else
                        usage();
index 5dbb4ea..a41391d 100644 (file)
@@ -31,6 +31,8 @@
 #include <linux/if_tunnel.h>
 
 #include "intl.h"
+#include "net-support.h"
+#include "version.h"
 
 #undef GRE_CSUM
 #define GRE_CSUM       htons(0x8000)
 
 #include "utils.h"
 
+char *Release = RELEASE,
+     *Version = "iptunnel 1.0",
+     *Signature = "Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>";
+
+static void version(void)
+{
+       printf("%s\n%s\n%s\n", Release, Version, Signature);
+       exit(E_VERSION);
+}
+
 static void usage(void) __attribute__((noreturn));
 
 static void usage(void)
@@ -63,7 +75,8 @@ static void usage(void)
        fprintf(stderr, _("Usage: iptunnel { add | change | del | show } [ NAME ]\n"));
        fprintf(stderr, _("          [ mode { ipip | gre | sit } ] [ remote ADDR ] [ local ADDR ]\n"));
        fprintf(stderr, _("          [ [i|o]seq ] [ [i|o]key KEY ] [ [i|o]csum ]\n"));
-       fprintf(stderr, _("          [ ttl TTL ] [ tos TOS ] [ nopmtudisc ] [ dev PHYS_DEV ]\n\n"));
+       fprintf(stderr, _("          [ ttl TTL ] [ tos TOS ] [ nopmtudisc ] [ dev PHYS_DEV ]\n"));
+       fprintf(stderr, _("       iptunnel -V | --version\n\n"));
        fprintf(stderr, _("Where: NAME := STRING\n"));
        fprintf(stderr, _("       ADDR := { IP_ADDRESS | any }\n"));
        fprintf(stderr, _("       TOS  := { NUMBER | inherit }\n"));
@@ -583,6 +596,8 @@ int main(int argc, char **argv)
                        ++show_stats;
                } else if (matches(argv[1], "-resolve") == 0) {
                        ++resolve_hosts;
+               } else if ((matches(argv[1], "-V") == 0) || (matches(argv[1], "--version") == 0)) {
+                       version();
                } else
                        usage();
                argc--; argv++;
index 11b9d1e..e35e4b1 100644 (file)
@@ -65,7 +65,7 @@ void usage(void)
 {
     fprintf(stderr, _("Usage: plipconfig [-a] [-i] [-v] interface\n"));
     fprintf(stderr, _("                  [nibble NN] [trigger NN]\n"));
-    fprintf(stderr, _("       plipconfig -V\n"));
+    fprintf(stderr, _("       plipconfig -V | --version\n"));
     exit(-1);
 }
 
@@ -91,7 +91,7 @@ int main(int argc, char **argv)
            opt_a = 1;
        if (!strcmp(*argv, "-v"))
            opt_v = 1;
-       if (!strcmp(*argv, "-V"))
+       if (!strcmp(*argv, "-V") || !strcmp(*argv, "--version"))
            version();
        argv++;
        argc--;
index 4f79a00..5167092 100644 (file)
@@ -39,6 +39,7 @@
 #include <stdlib.h>          
 #include <string.h>
 #include <unistd.h>
+#include <getopt.h>
 #include <linux/if_slip.h>
 
 #if defined(__GLIBC__)
@@ -543,7 +544,7 @@ usage(void)
          "[-o outfill] "
 #endif
          "[-c cmd] [-s speed] [-p protocol] tty | -\n"
-         "       slattach -V\n";
+         "       slattach -V | --version\n";
 
   fprintf(stderr, usage_msg);
   exit(1);
@@ -569,19 +570,16 @@ main(int argc, char *argv[])
   struct hwtype *ht;
   char *sp;
   int s;
+  static struct option longopts[] = {
+    { "version", 0, NULL, 'V' },
+    { NULL, 0, NULL, 0 }
+  };
 
   strcpy(path, "");
 
   /* Scan command line for any arguments. */
   opterr = 0;
-  while ((s = getopt(argc, argv, "c:ehlLmnp:qs:vdV"
-#ifdef SIOCSKEEPALIVE
-                    "k:"
-#endif
-#ifdef SIOCSOUTFILL
-                    "o:"
-#endif
-                    )) != EOF) switch(s) {
+  while ((s = getopt_long(argc, argv, "c:ehlLmnp:qs:vdVk:o:", longopts, NULL)) != EOF) switch(s) {
        case 'c':
                extcmd = optarg;
                break;