summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile1
-rw-r--r--src/anytun-config.cpp6
-rw-r--r--src/anytun-controld.cpp6
-rw-r--r--src/anytun.cpp6
-rwxr-xr-xsrc/configure29
-rw-r--r--src/options.cpp24
-rw-r--r--src/options.h1
7 files changed, 60 insertions, 13 deletions
diff --git a/src/Makefile b/src/Makefile
index cf5822c..0e91563 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -179,6 +179,7 @@ distclean: cleanall
find . -name *.o -exec rm -f {} \;
rm -f config.sub config.guess
rm -f signalHandler.hpp
+ rm -f version.h
rm -f tunDevice.cpp
rm -f include.mk
diff --git a/src/anytun-config.cpp b/src/anytun-config.cpp
index 0e60710..d09f1e8 100644
--- a/src/anytun-config.cpp
+++ b/src/anytun-config.cpp
@@ -104,11 +104,9 @@ int main(int argc, char* argv[])
{
try
{
- bool result = gOpt.parse(argc, argv);
- if(!result) {
- gOpt.printUsage();
+ if(!gOpt.parse(argc, argv))
exit(0);
- }
+
StringList targets = gOpt.getLogTargets();
for(StringList::const_iterator it = targets.begin();it != targets.end(); ++it)
cLog.addTarget(*it);
diff --git a/src/anytun-controld.cpp b/src/anytun-controld.cpp
index dd9be12..724296d 100644
--- a/src/anytun-controld.cpp
+++ b/src/anytun-controld.cpp
@@ -82,11 +82,9 @@ int main(int argc, char* argv[])
{
try
{
- bool result = gOpt.parse(argc, argv);
- if(!result) {
- gOpt.printUsage();
+ if(!gOpt.parse(argc, argv))
exit(0);
- }
+
StringList targets = gOpt.getLogTargets();
for(StringList::const_iterator it = targets.begin();it != targets.end(); ++it)
cLog.addTarget(*it);
diff --git a/src/anytun.cpp b/src/anytun.cpp
index e9f2452..e70087d 100644
--- a/src/anytun.cpp
+++ b/src/anytun.cpp
@@ -366,11 +366,9 @@ int main(int argc, char* argv[])
{
try
{
- bool result = gOpt.parse(argc, argv);
- if(!result) {
- gOpt.printUsage();
+ if(!gOpt.parse(argc, argv))
exit(0);
- }
+
StringList targets = gOpt.getLogTargets();
for(StringList::const_iterator it = targets.begin();it != targets.end(); ++it)
cLog.addTarget(*it);
diff --git a/src/configure b/src/configure
index 1f5f024..2c6d8ea 100755
--- a/src/configure
+++ b/src/configure
@@ -245,4 +245,33 @@ else
echo "not installing example files"
fi
+VERSION=`cat ../version`
+if which svn >/dev/null; then
+ SVN_REV=`svn info | grep "^Revision: " | awk '{print($2)}'`
+ if [ -n "$SVN_REV" ]; then
+ VERSION="$VERSION (svn$SVN_REV)"
+ fi
+fi
+HOSTNAME=`hostname`
+DATE=`date +"%d.%m.%Y %H:%M:%S %Z"`
+
+cat >> version.h <<EOF
+/*
+ * anytun version info
+ *
+ * this file was created automatically
+ * do not edit this file directly
+ * use ./configure instead
+ */
+
+#ifndef ANYTUN_version_h_INCLUDED
+#define ANYTUN_version_h_INCLUDED
+
+#define VERSION_STRING_0 " version $VERSION"
+#define VERSION_STRING_1 "built on $HOSTNAME, $DATE"
+
+#endif
+
+EOF
+
exit 0
diff --git a/src/options.cpp b/src/options.cpp
index 6230483..c393c9f 100644
--- a/src/options.cpp
+++ b/src/options.cpp
@@ -37,6 +37,8 @@
#include <sstream>
#include "datatypes.h"
+#include "version.h"
+
#include "options.h"
#include "log.h"
#include "authAlgoFactory.h"
@@ -371,8 +373,14 @@ bool Options::parse(int argc, char* argv[])
std::string str(argv[i]);
argc--;
- if(str == "-h" || str == "--help")
+ if(str == "-h" || str == "--help") {
+ printUsage();
+ return false;
+ }
+ else if(str == "-v" || str == "--version") {
+ printVersion();
return false;
+ }
#if defined(ANYTUN_OPTIONS) || defined(ANYCTR_OPTIONS)
@@ -520,6 +528,19 @@ void Options::parse_post()
dev_type_ = "tun";
}
+void Options::printVersion()
+{
+#if defined(ANYCTR_OPTIONS)
+ std::cout << "anytun-controld";
+#elif defined(ANYCONF_OPTIONS)
+ std::cout << "anytun-config";
+#else
+ std::cout << "anytun";
+#endif
+ std::cout << VERSION_STRING_0 << std::endl;
+ std::cout << VERSION_STRING_1 << std::endl;
+}
+
void Options::printUsage()
{
std::cout << "USAGE:" << std::endl;
@@ -533,6 +554,7 @@ void Options::printUsage()
#endif
std::cout << " [-h|--help] prints this..." << std::endl;
+ std::cout << " [-v|--version] print version info and exit" << std::endl;
#if defined(ANYTUN_OPTIONS) || defined(ANYCTR_OPTIONS)
diff --git a/src/options.h b/src/options.h
index 8ed9c4c..7a58c58 100644
--- a/src/options.h
+++ b/src/options.h
@@ -88,6 +88,7 @@ public:
bool parse(int argc, char* argv[]);
void parse_post();
+ void printVersion();
void printUsage();
void printOptions();