Mailing List Archive

svn commit: rev 20500 - in incubator/spamassassin/trunk: . spamc
Author: mss
Date: Thu May 27 05:35:47 2004
New Revision: 20500

Added:
incubator/spamassassin/trunk/spamc/version.h.in (contents, props changed)
Modified:
incubator/spamassassin/trunk/Makefile.PL
incubator/spamassassin/trunk/spamc/ (props changed)
incubator/spamassassin/trunk/spamc/configure.pl
incubator/spamassassin/trunk/spamc/spamc.c
Log:
Added often-requested -V switch to spamc. Finally one can check out which version of spamc is installed on his box :)


Modified: incubator/spamassassin/trunk/Makefile.PL
==============================================================================
--- incubator/spamassassin/trunk/Makefile.PL (original)
+++ incubator/spamassassin/trunk/Makefile.PL Thu May 27 05:35:47 2004
@@ -1030,7 +1030,7 @@
LIBSPAMC_SRC = spamc/libspamc.c spamc/utils.c

$(SPAMC_MAKEFILE): $(SPAMC_MAKEFILE).in $(SPAMC_MAKEFILE).win
- $(CONFIGURE) --prefix="$(I_PREFIX)" --sysconfdir="$(I_SYSCONFDIR)" --datadir="$(I_DATADIR)" --enable-ssl="$(ENABLE_SSL)"
+ $(CONFIGURE) VERSION="$(VERSION)" --prefix="$(I_PREFIX)" --sysconfdir="$(I_SYSCONFDIR)" --datadir="$(I_DATADIR)" --enable-ssl="$(ENABLE_SSL)"

spamc_has_moved:
$(NOECHO) echo "***"

Modified: incubator/spamassassin/trunk/spamc/configure.pl
==============================================================================
--- incubator/spamassassin/trunk/spamc/configure.pl (original)
+++ incubator/spamassassin/trunk/spamc/configure.pl Thu May 27 05:35:47 2004
@@ -49,12 +49,42 @@
}


-# Change to the dir s file is in.
+# Change to the dir this file is in.
my $srcdir;
$srcdir = canonpath(catpath((splitpath($0))[0..1])) || curdir();
if ($srcdir ne curdir()) {
print "cd $srcdir\n";
chdir($srcdir) || die "Can't cd to `$srcdir': $!";
+}
+
+
+# Create version.h platform independently.
+print "configure.pl: creating version.h\n";
+if ($ENV{VERSION})
+{
+ $ENV{VERSION} =~ /^(\d+)\.(?:(\d\d\d)(\d\d\d)|(\d+)\.(\d+))/;
+ my %ver = (
+ MAJOR => $1 * 1,
+ MINOR => $2 * 1,
+ REVISION => $3 * 1,
+ );
+
+ open(IN => "<version.h.in") || die "Can't open version.h.in: $!";
+ open(OUT => ">version.h") || die "Can't open version.h: $!";
+
+ print OUT "/* version.h. Generated by configure.pl. */\n";
+ foreach (<IN>) {
+ s/^#undef\s+(VERSION_EXACT)/#define $1/;
+ s/^(#define VERSION_)(MAJOR|MINOR|REVISION)\s+.*$/$1$2 "$ver{$2}"/;
+ print OUT;
+ }
+
+ close(IN);
+ close(OUT);
+}
+else
+{
+ copy(q{version.h.in}, q{version.h}) || die "Can't copy version.h.in to version.h: $!";
}



Modified: incubator/spamassassin/trunk/spamc/spamc.c
==============================================================================
--- incubator/spamassassin/trunk/spamc/spamc.c (original)
+++ incubator/spamassassin/trunk/spamc/spamc.c Thu May 27 05:35:47 2004
@@ -16,6 +16,7 @@
*/

#include "config.h"
+#include "version.h"
#include "libspamc.h"
#include "utils.h"

@@ -92,6 +93,24 @@

static int timeout = 600;

+
+void
+print_version(void)
+{
+ char *maj = VERSION_MAJOR;
+ char *min = VERSION_MINOR;
+ char *rev = VERSION_REVISION;
+
+#ifndef VERSION_EXACT
+ rev = strdup(rev);
+ rev += strlen("LastChangedRevision");
+ strncpy(rev, "x-r", 3);
+ rev[strlen(rev) - 2] = '\0';
+#endif
+
+ fprintf(stderr, "%s version %s.%s.%s\n", "SpamAssassin Client", maj, min, rev);
+}
+
static void
usg(char *str)
{
@@ -101,7 +120,10 @@
void
print_usage(void)
{
+ print_version();
+ usg("\n");
usg("Usage: spamc [options] [-e command [args]] < message\n");
+ usg("\n");
usg("Options:\n");

usg(" -d host Specify host to connect to.\n"
@@ -148,9 +170,9 @@
struct transport *ptrn)
{
#ifndef _WIN32
- const char *opts = "-BcrRd:e:fhyp:t:s:u:xSHU:El";
+ const char *opts = "-BcrRd:e:fyp:t:s:u:xSHU:ElhV";
#else
- const char *opts = "-BcrRd:fhyp:t:s:u:xSHEl";
+ const char *opts = "-BcrRd:fyp:t:s:u:xSHElhV";
#endif
int opt;
int ret = EX_OK;
@@ -278,6 +300,11 @@
print_usage();
exit(ret);
}
+ case 'V':
+ {
+ print_version();
+ exit(ret);
+ }
}
}
return ret;

Added: incubator/spamassassin/trunk/spamc/version.h.in
==============================================================================
--- (empty file)
+++ incubator/spamassassin/trunk/spamc/version.h.in Thu May 27 05:35:47 2004
@@ -0,0 +1,9 @@
+/* version.h.in. template for configure.pl, called from Makefile.PL. */
+/* can be copied to version.h manually if really needed. */
+
+#undef VERSION_EXACT
+
+#define VERSION_MAJOR "3"
+#define VERSION_MINOR "x"
+#define VERSION_REVISION "$LastChangedRevision$"
+