From 528213cc8c44ad62e59631ba816e7b82ef7a6e02 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Tue, 22 Dec 2009 21:52:59 +0000 Subject: added version info into binary --- src/Makefile | 1 + src/configure | 31 ++++++++++++++++++++++++++++++- src/options.c | 10 ++++++++++ src/uanytun.c | 8 +++++++- 4 files changed, 48 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Makefile b/src/Makefile index 4124575..7ad7921 100644 --- a/src/Makefile +++ b/src/Makefile @@ -89,6 +89,7 @@ distclean: cleanall find . -name *.o -exec rm -f {} \; find . -name "*.\~*" -exec rm -rf {} \; rm -f include.mk + rm -f version.h rm -f tun.c clean: diff --git a/src/configure b/src/configure index ac2dc03..a791738 100755 --- a/src/configure +++ b/src/configure @@ -139,7 +139,7 @@ if [ -n "$ERRORS" ] && [ $EBUILD_COMPAT -ne 1 ]; then exit 1 fi - +rm -f version.h rm -f include.mk case $TARGET in Linux) @@ -238,4 +238,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 <daemonize_) PARSE_STRING_PARAM("-u","--username", opt->username_) PARSE_STRING_PARAM("-g","--groupname", opt->groupname_) @@ -420,6 +423,7 @@ void options_print_usage() { printf("USAGE:\n"); printf("uanytun [-h|--help] prints this...\n"); + printf(" [-v|--version] print version info and exit\n"); printf(" [-D|--nodaemonize] don't run in background\n"); printf(" [-u|--username] change to this user\n"); printf(" [-g|--groupname] change to this group\n"); @@ -456,6 +460,12 @@ void options_print_usage() #endif } +void options_print_version() +{ + printf("%s\n", VERSION_STRING_0); + printf("%s\n", VERSION_STRING_1); +} + void options_print(options_t* opt) { if(!opt) diff --git a/src/uanytun.c b/src/uanytun.c index 0e36781..ba64bc7 100644 --- a/src/uanytun.c +++ b/src/uanytun.c @@ -336,10 +336,16 @@ int main(int argc, char* argv[]) if(ret == -4) { fprintf(stderr, "syntax error: unknown role name\n\n"); } + if(ret == -5) { + options_print_version(); + } - if(ret != -2) + if(ret != -2 && ret != -5) options_print_usage(); + if(ret == -1 || ret == -5) + ret = 0; + options_clear(&opt); log_close(); exit(ret); -- cgit v1.2.3