[netfilter-cvslog] r3320 - in trunk/nfsim: . core tools
rusty at netfilter.org
rusty at netfilter.org
Sat Dec 11 00:51:48 CET 2004
Author: rusty at netfilter.org
Date: 2004-12-11 00:51:47 +0100 (Sat, 11 Dec 2004)
New Revision: 3320
Added:
trunk/nfsim/tools/version.c
Modified:
trunk/nfsim/configure
trunk/nfsim/core/core.c
Log:
Print license information in interactive mode (GPL compliance)
Add version command and -V
Modified: trunk/nfsim/configure
===================================================================
--- trunk/nfsim/configure 2004-12-10 10:25:38 UTC (rev 3319)
+++ trunk/nfsim/configure 2004-12-10 23:51:47 UTC (rev 3320)
@@ -4,6 +4,7 @@
KERNELDIR=/lib/modules/$(uname -r)/build
TYPE=ipv4
+VERSION=0.2
barf()
{
@@ -21,7 +22,7 @@
esac
done
-SUB="$SUB"'s/%TYPE%/'$TYPE'/;'
+SUB="$SUB"'s/%TYPE%/'$TYPE'/;s/%VERSION%/'$VERSION'/'
[ -d $KERNELDIR/net/$TYPE/netfilter ] ||
barf No netfilter directory found in $KERNELDIR
Modified: trunk/nfsim/core/core.c
===================================================================
--- trunk/nfsim/core/core.c 2004-12-10 10:25:38 UTC (rev 3319)
+++ trunk/nfsim/core/core.c 2004-12-10 23:51:47 UTC (rev 3320)
@@ -141,12 +141,21 @@
(*p)();
}
+static void print_license(void)
+{
+ printf("nfsim %s, Copyright (C) 2004 Jeremy Kerr, Rusty Russell\n"
+ "Nfsim comes with ABSOLUTELY NO WARRANTY; see COPYING.\n"
+ "This is free software, and you are welcome to redistribute\n"
+ "it under certain conditions; see COPYING for details.\n",
+ VERSION);
+}
static const struct option options[] = {
{"echo", 0, 0, 'x'},
{"quiet", 0, 0, 'q'},
{"exit", 0, 0, 'e'},
{"load-all", 0, 0, 'a'},
+ {"version", 0, 0, 'V'},
{0, 0, 0, 0 }
};
@@ -155,7 +164,7 @@
int termfd, load_all = 0;
char c;
- while ((c = getopt_long(argc, argv, "xqea", options, NULL)) != EOF) {
+ while ((c = getopt_long(argc, argv, "xqeaV", options, NULL)) != EOF) {
switch (c) {
case 'x':
tui_echo_commands = 1;
@@ -169,6 +178,12 @@
case 'a':
load_all = 1;
break;
+ case 'V':
+ printf("nfsim version %s\nkernel version %s\n",
+ VERSION, UTS_RELEASE);
+ print_license();
+ exit(0);
+ break;
default:
fprintf(stderr, "Unknown argument %c\n", c);
return EXIT_FAILURE;
@@ -178,6 +193,8 @@
kernelenv_init();
run_inits();
+ if (!tui_quiet)
+ print_license();
if (load_all && !load_all_modules())
barf("Module loading failed\n");
Added: trunk/nfsim/tools/version.c
===================================================================
--- trunk/nfsim/tools/version.c 2004-12-10 10:25:38 UTC (rev 3319)
+++ trunk/nfsim/tools/version.c 2004-12-10 23:51:47 UTC (rev 3320)
@@ -0,0 +1,70 @@
+/*
+
+Copyright (c) 2004 Rusty Russell
+
+This file is part of nfsim.
+
+nfsim is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+nfsim is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with nfsim; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include <linux/version.h>
+#include <log.h>
+#include <tui.h>
+#include <kernelenv.h>
+#include <utils.h>
+
+static void version_help(int argc, char **argv)
+{
+#include "version-help:version"
+/*** XML Help:
+ <section id="c:version">
+ <title><command>version</command></title>
+ <para>Displays version information about the kernel simulator.</para>
+ <cmdsynopsis>
+ <command>version</command>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>version kernel</command>
+ </cmdsynopsis>
+ <para>The <command>version</command> displays information about
+ the nfsim version and the version of the kernel it's simulating.
+ With the <arg>kernel</arg> argument, it only displays the version
+ of the kernel (useful for testsuites).
+ </para>
+ </section>
+*/
+}
+
+static bool version(int argc, char **argv)
+{
+ if (argc == 2 && streq(argv[1], "kernel")) {
+ nfsim_log(LOG_ALWAYS, "%s", UTS_RELEASE);
+ return true;
+ } else if (argc != 1) {
+ version_help(argc, argv);
+ return false;
+ }
+ nfsim_log(LOG_UI, "nfsim version %s", VERSION);
+ nfsim_log(LOG_UI, "kernel version %s", UTS_RELEASE);
+ return true;
+}
+
+static void init(void)
+{
+ tui_register_command("version", version, NULL);
+}
+
+init_call(init);
+
More information about the netfilter-cvslog
mailing list