Commit 4ed3f006 authored by Phil Blundell's avatar Phil Blundell

Add support for `--version'

parent 9ad2aa12
...@@ -44,8 +44,8 @@ char *Release = RELEASE, ...@@ -44,8 +44,8 @@ char *Release = RELEASE,
static void version(void) static void version(void)
{ {
printf("%s\n%s\n%s\n", Release, Version, Signature); printf("%s\n%s\n%s\n", Release, Version, Signature);
exit(E_VERSION); exit(E_VERSION);
} }
static void usage(void) __attribute__((noreturn)); static void usage(void) __attribute__((noreturn));
...@@ -54,6 +54,7 @@ static void usage(void) ...@@ -54,6 +54,7 @@ static void usage(void)
{ {
fprintf(stderr, _("Usage: ipmaddr [ add | del ] MULTIADDR dev STRING\n")); fprintf(stderr, _("Usage: ipmaddr [ add | del ] MULTIADDR dev STRING\n"));
fprintf(stderr, _(" ipmaddr show [ dev STRING ] [ ipv4 | ipv6 | link | all ]\n")); fprintf(stderr, _(" ipmaddr show [ dev STRING ] [ ipv4 | ipv6 | link | all ]\n"));
fprintf(stderr, _(" ipmaddr -V | -version\n"));
exit(-1); exit(-1);
} }
...@@ -408,7 +409,7 @@ int main(int argc, char **argv) ...@@ -408,7 +409,7 @@ int main(int argc, char **argv)
++show_stats; ++show_stats;
} else if (matches(argv[1], "-resolve") == 0) { } else if (matches(argv[1], "-resolve") == 0) {
++resolve_hosts; ++resolve_hosts;
} else if (matches(argv[1], "-V") == 0) { } else if ((matches(argv[1], "-V") == 0) || matches(argv[1], "--version") == 0) {
version(); version();
} else } else
usage(); usage();
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#include <linux/if_tunnel.h> #include <linux/if_tunnel.h>
#include "intl.h" #include "intl.h"
#include "net-support.h"
#include "version.h"
#undef GRE_CSUM #undef GRE_CSUM
#define GRE_CSUM htons(0x8000) #define GRE_CSUM htons(0x8000)
...@@ -56,6 +58,16 @@ ...@@ -56,6 +58,16 @@
#include "utils.h" #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) __attribute__((noreturn));
static void usage(void) static void usage(void)
...@@ -63,7 +75,8 @@ static void usage(void) ...@@ -63,7 +75,8 @@ static void usage(void)
fprintf(stderr, _("Usage: iptunnel { add | change | del | show } [ NAME ]\n")); fprintf(stderr, _("Usage: iptunnel { add | change | del | show } [ NAME ]\n"));
fprintf(stderr, _(" [ mode { ipip | gre | sit } ] [ remote ADDR ] [ local ADDR ]\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, _(" [ [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, _("Where: NAME := STRING\n"));
fprintf(stderr, _(" ADDR := { IP_ADDRESS | any }\n")); fprintf(stderr, _(" ADDR := { IP_ADDRESS | any }\n"));
fprintf(stderr, _(" TOS := { NUMBER | inherit }\n")); fprintf(stderr, _(" TOS := { NUMBER | inherit }\n"));
...@@ -583,6 +596,8 @@ int main(int argc, char **argv) ...@@ -583,6 +596,8 @@ int main(int argc, char **argv)
++show_stats; ++show_stats;
} else if (matches(argv[1], "-resolve") == 0) { } else if (matches(argv[1], "-resolve") == 0) {
++resolve_hosts; ++resolve_hosts;
} else if ((matches(argv[1], "-V") == 0) || (matches(argv[1], "--version") == 0)) {
version();
} else } else
usage(); usage();
argc--; argv++; argc--; argv++;
......
...@@ -65,7 +65,7 @@ void usage(void) ...@@ -65,7 +65,7 @@ void usage(void)
{ {
fprintf(stderr, _("Usage: plipconfig [-a] [-i] [-v] interface\n")); fprintf(stderr, _("Usage: plipconfig [-a] [-i] [-v] interface\n"));
fprintf(stderr, _(" [nibble NN] [trigger NN]\n")); fprintf(stderr, _(" [nibble NN] [trigger NN]\n"));
fprintf(stderr, _(" plipconfig -V\n")); fprintf(stderr, _(" plipconfig -V | --version\n"));
exit(-1); exit(-1);
} }
...@@ -91,7 +91,7 @@ int main(int argc, char **argv) ...@@ -91,7 +91,7 @@ int main(int argc, char **argv)
opt_a = 1; opt_a = 1;
if (!strcmp(*argv, "-v")) if (!strcmp(*argv, "-v"))
opt_v = 1; opt_v = 1;
if (!strcmp(*argv, "-V")) if (!strcmp(*argv, "-V") || !strcmp(*argv, "--version"))
version(); version();
argv++; argv++;
argc--; argc--;
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <getopt.h>
#include <linux/if_slip.h> #include <linux/if_slip.h>
#if defined(__GLIBC__) #if defined(__GLIBC__)
...@@ -543,7 +544,7 @@ usage(void) ...@@ -543,7 +544,7 @@ usage(void)
"[-o outfill] " "[-o outfill] "
#endif #endif
"[-c cmd] [-s speed] [-p protocol] tty | -\n" "[-c cmd] [-s speed] [-p protocol] tty | -\n"
" slattach -V\n"; " slattach -V | --version\n";
fprintf(stderr, usage_msg); fprintf(stderr, usage_msg);
exit(1); exit(1);
...@@ -569,19 +570,16 @@ main(int argc, char *argv[]) ...@@ -569,19 +570,16 @@ main(int argc, char *argv[])
struct hwtype *ht; struct hwtype *ht;
char *sp; char *sp;
int s; int s;
static struct option longopts[] = {
{ "version", 0, NULL, 'V' },
{ NULL, 0, NULL, 0 }
};
strcpy(path, ""); strcpy(path, "");
/* Scan command line for any arguments. */ /* Scan command line for any arguments. */
opterr = 0; opterr = 0;
while ((s = getopt(argc, argv, "c:ehlLmnp:qs:vdV" while ((s = getopt_long(argc, argv, "c:ehlLmnp:qs:vdVk:o:", longopts, NULL)) != EOF) switch(s) {
#ifdef SIOCSKEEPALIVE
"k:"
#endif
#ifdef SIOCSOUTFILL
"o:"
#endif
)) != EOF) switch(s) {
case 'c': case 'c':
extcmd = optarg; extcmd = optarg;
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment