git-svn: trunk@4076
Török Edvin authored on 2008/08/04 19:38:24... | ... |
@@ -33,8 +33,6 @@ |
33 | 33 |
*/ |
34 | 34 |
static char const rcsid[] = "$Id: clamav-milter.c,v 1.312 2007/02/12 22:24:21 njh Exp $"; |
35 | 35 |
|
36 |
-#define CM_VERSION "devel-20080219" |
|
37 |
- |
|
38 | 36 |
#if HAVE_CONFIG_H |
39 | 37 |
#include "clamav-config.h" |
40 | 38 |
#endif |
... | ... |
@@ -628,7 +626,7 @@ int safe_res_query(const char *d, int c, int t, u_char *a, int l) { |
628 | 628 |
static void |
629 | 629 |
help(void) |
630 | 630 |
{ |
631 |
- printf("\n\tclamav-milter version %s\n", CM_VERSION); |
|
631 |
+ printf("\n\tclamav-milter version %s\n", get_version()); |
|
632 | 632 |
puts("\tCopyright (C) 2007 Nigel Horne <njh@clamav.net>\n"); |
633 | 633 |
|
634 | 634 |
puts(_("\t--advisory\t\t-A\tFlag viruses rather than deleting them.")); |
... | ... |
@@ -743,7 +741,7 @@ main(int argc, char **argv) |
743 | 743 |
*/ |
744 | 744 |
snprintf(version, sizeof(version) - 1, |
745 | 745 |
"ClamAV version %s, clamav-milter version %s", |
746 |
- VERSION, CM_VERSION); |
|
746 |
+ cl_retver(), get_version()); |
|
747 | 747 |
|
748 | 748 |
progname = strrchr(argv[0], '/'); |
749 | 749 |
if(progname) |
... | ... |
@@ -2366,7 +2364,7 @@ pingServer(int serverNumber) |
2366 | 2366 |
*/ |
2367 | 2367 |
snprintf(clamav_version, sizeof(clamav_version) - 1, |
2368 | 2368 |
"%s\n\tclamav-milter version %s", |
2369 |
- buf, CM_VERSION); |
|
2369 |
+ buf, get_version()); |
|
2370 | 2370 |
|
2371 | 2371 |
return 1; |
2372 | 2372 |
} |
... | ... |
@@ -5844,7 +5842,7 @@ loadDatabase(void) |
5844 | 5844 |
char buf[26]; |
5845 | 5845 |
|
5846 | 5846 |
snprintf(clamav_version, VERSION_LENGTH, |
5847 |
- "ClamAV %s/%u/%s", VERSION, d->version, |
|
5847 |
+ "ClamAV %s/%u/%s", get_version(), d->version, |
|
5848 | 5848 |
cli_ctime(&t, buf, sizeof(buf))); |
5849 | 5849 |
|
5850 | 5850 |
/* Remove ctime's trailing \n */ |
... | ... |
@@ -5855,7 +5853,7 @@ loadDatabase(void) |
5855 | 5855 |
} else |
5856 | 5856 |
snprintf(clamav_version, VERSION_LENGTH, |
5857 | 5857 |
"ClamAV version %s, clamav-milter version %s", |
5858 |
- VERSION, CM_VERSION); |
|
5858 |
+ cl_retver(), get_version()); |
|
5859 | 5859 |
|
5860 | 5860 |
free(daily); |
5861 | 5861 |
|
... | ... |
@@ -34,6 +34,7 @@ |
34 | 34 |
|
35 | 35 |
#include "shared/misc.h" |
36 | 36 |
#include "libclamav/clamav.h" |
37 |
+#include "libclamav/version.h" |
|
37 | 38 |
|
38 | 39 |
#include "cfgparser.h" |
39 | 40 |
#define _GNU_SOURCE |
... | ... |
@@ -199,26 +200,38 @@ static void printdb(const char *dir, const char *db) |
199 | 199 |
} |
200 | 200 |
} |
201 | 201 |
|
202 |
+static void version(void) |
|
203 |
+{ |
|
204 |
+ printf("Clam AntiVirus Configuration Tool %s\n", get_version()); |
|
205 |
+} |
|
206 |
+ |
|
202 | 207 |
static void help(void) |
203 | 208 |
{ |
204 | 209 |
printf("\n"); |
205 |
- printf(" Clam AntiVirus: Configuration Tool "VERSION"\n"); |
|
210 |
+ printf(" Clam AntiVirus: Configuration Tool %s\n", get_version()); |
|
206 | 211 |
printf(" (C) 2006 - 2007 ClamAV Team - http://www.clamav.net/team\n\n"); |
207 | 212 |
|
208 | 213 |
printf(" --help -h show help\n"); |
214 |
+ printf(" --version -v show version\n"); |
|
209 | 215 |
printf(" --config-dir DIR -c DIR search for config files in DIR\n"); |
210 | 216 |
printf(" --non-default -n only print non-default settings\n"); |
211 | 217 |
printf("\n"); |
212 | 218 |
} |
213 | 219 |
|
220 |
+ |
|
221 |
+#ifndef REPO_VERSION |
|
222 |
+#define REPO_VERSION VERSION |
|
223 |
+#endif |
|
224 |
+ |
|
214 | 225 |
int main(int argc, char **argv) |
215 | 226 |
{ |
216 | 227 |
char path[1024]; |
217 | 228 |
struct stat sb; |
218 | 229 |
int ret, opt_index, nondef = 0; |
219 |
- const char *getopt_parameters = "hc:n"; |
|
230 |
+ const char *getopt_parameters = "hVc:n"; |
|
220 | 231 |
static struct option long_options[] = { |
221 | 232 |
{"help", 0, 0, 'h'}, |
233 |
+ {"version", 0, 0, 'V'}, |
|
222 | 234 |
{"config-dir", 1, 0, 'c'}, |
223 | 235 |
{"non-default", 0, 0, 'n'}, |
224 | 236 |
{0, 0, 0, 0} |
... | ... |
@@ -252,6 +265,11 @@ int main(int argc, char **argv) |
252 | 252 |
nondef = 1; |
253 | 253 |
break; |
254 | 254 |
|
255 |
+ case 'V': |
|
256 |
+ version(); |
|
257 |
+ free(confdir); |
|
258 |
+ exit(0); |
|
259 |
+ |
|
255 | 260 |
default: |
256 | 261 |
printf("ERROR: Unknown option passed\n"); |
257 | 262 |
free(confdir); |
... | ... |
@@ -283,13 +301,13 @@ int main(int argc, char **argv) |
283 | 283 |
printf("------------------------------\n"); |
284 | 284 |
|
285 | 285 |
#ifdef CL_EXPERIMENTAL |
286 |
- printf("Engine version: "VERSION" (with experimental code)\n"); |
|
286 |
+ printf("Engine version: %s (with experimental code)\n", get_version()); |
|
287 | 287 |
#else |
288 |
- printf("Engine version: "VERSION"\n"); |
|
288 |
+ printf("Engine version: %s\n", get_version()); |
|
289 | 289 |
#endif |
290 | 290 |
|
291 |
- if(strcmp(VERSION, cl_retver())) |
|
292 |
- printf("WARNING: Version mismatch: clamconf: "VERSION", libclamav: %s\n", cl_retver()); |
|
291 |
+ if(strcmp(REPO_VERSION, cl_retver())) |
|
292 |
+ printf("WARNING: Version mismatch: clamconf: "REPO_VERSION", libclamav: %s\n", cl_retver()); |
|
293 | 293 |
|
294 | 294 |
printf("Database directory: "); |
295 | 295 |
dbdir = freshdbdir(); |
... | ... |
@@ -78,7 +78,7 @@ short foreground = 0; |
78 | 78 |
static void help(void) |
79 | 79 |
{ |
80 | 80 |
printf("\n"); |
81 |
- printf(" Clam AntiVirus Daemon %s\n", cl_retver()); |
|
81 |
+ printf(" Clam AntiVirus Daemon %s\n", get_version()); |
|
82 | 82 |
printf(" (C) 2002 - 2007 ClamAV Team - http://www.clamav.net/team\n\n"); |
83 | 83 |
|
84 | 84 |
printf(" --help -h Show this help.\n"); |
... | ... |
@@ -288,7 +288,7 @@ int main(int argc, char **argv) |
288 | 288 |
if(cfgopt(copt, "LeaveTemporaryFiles")->enabled) |
289 | 289 |
cl_settempdir(NULL, 1); |
290 | 290 |
|
291 |
- logg("#clamd daemon %s (OS: "TARGET_OS_TYPE", ARCH: "TARGET_ARCH_TYPE", CPU: "TARGET_CPU_TYPE")\n", cl_retver()); |
|
291 |
+ logg("#clamd daemon %s (OS: "TARGET_OS_TYPE", ARCH: "TARGET_ARCH_TYPE", CPU: "TARGET_CPU_TYPE")\n", get_version()); |
|
292 | 292 |
|
293 | 293 |
#ifndef C_WINDOWS |
294 | 294 |
if(user) |
... | ... |
@@ -171,10 +171,10 @@ int command(int desc, const struct cl_engine *engine, const struct cl_limits *li |
171 | 171 |
char timestr[32]; |
172 | 172 |
time_t t = (time_t) daily->stime; |
173 | 173 |
|
174 |
- mdprintf(desc, "ClamAV %s/%d/%s", cl_retver(), daily->version, cli_ctime(&t, timestr, sizeof(timestr))); |
|
174 |
+ mdprintf(desc, "ClamAV %s/%d/%s", get_version(), daily->version, cli_ctime(&t, timestr, sizeof(timestr))); |
|
175 | 175 |
cl_cvdfree(daily); |
176 | 176 |
} else { |
177 |
- mdprintf(desc, "ClamAV %s\n", cl_retver()); |
|
177 |
+ mdprintf(desc, "ClamAV %s\n", get_version()); |
|
178 | 178 |
} |
179 | 179 |
|
180 | 180 |
free(path); |
... | ... |
@@ -43,17 +43,11 @@ short printinfected = 0; |
43 | 43 |
|
44 | 44 |
extern int notremoved, notmoved; |
45 | 45 |
|
46 |
-#ifdef CL_EXPERIMENTAL |
|
47 |
-#define VERSION_EXP VERSION"-exp" |
|
48 |
-#else |
|
49 |
-#define VERSION_EXP VERSION |
|
50 |
-#endif |
|
51 |
- |
|
52 | 46 |
static void print_server_version(const struct optstruct *opt) |
53 | 47 |
{ |
54 | 48 |
if(get_clamd_version(opt)) { |
55 | 49 |
/* can't get version from server, fallback */ |
56 |
- printf("ClamAV "VERSION_EXP"\n"); |
|
50 |
+ printf("ClamAV %s\n", get_version()); |
|
57 | 51 |
} |
58 | 52 |
} |
59 | 53 |
|
... | ... |
@@ -149,7 +143,7 @@ void help(void) |
149 | 149 |
mprintf_stdout = 1; |
150 | 150 |
|
151 | 151 |
mprintf("\n"); |
152 |
- mprintf(" ClamAV Daemon Client "VERSION"\n"); |
|
152 |
+ mprintf(" ClamAV Daemon Client %s\n", get_version()); |
|
153 | 153 |
mprintf(" (C) 2002 - 2007 ClamAV Team - http://www.clamav.net/team\n\n"); |
154 | 154 |
|
155 | 155 |
mprintf(" --help -h Show help\n"); |
... | ... |
@@ -246,7 +246,7 @@ int main(int argc, char **argv) |
246 | 246 |
dms += (dms < 0) ? (1000000):(0); |
247 | 247 |
logg("\n----------- SCAN SUMMARY -----------\n"); |
248 | 248 |
logg("Known viruses: %u\n", info.sigs); |
249 |
- logg("Engine version: %s\n", cl_retver()); |
|
249 |
+ logg("Engine version: %s\n", get_version()); |
|
250 | 250 |
logg("Scanned directories: %u\n", info.dirs); |
251 | 251 |
logg("Scanned files: %u\n", info.files); |
252 | 252 |
logg("Infected files: %u\n", info.ifiles); |
... | ... |
@@ -279,7 +279,7 @@ void help(void) |
279 | 279 |
mprintf_stdout = 1; |
280 | 280 |
|
281 | 281 |
mprintf("\n"); |
282 |
- mprintf(" Clam AntiVirus Scanner "VERSION"\n"); |
|
282 |
+ mprintf(" Clam AntiVirus Scanner %s\n", get_version()); |
|
283 | 283 |
mprintf(" (C) 2002 - 2007 ClamAV Team - http://www.clamav.net/team\n\n"); |
284 | 284 |
|
285 | 285 |
mprintf(" --help -h Print this help screen\n"); |
... | ... |
@@ -117,7 +117,7 @@ static void help(void) |
117 | 117 |
mprintf_stdout = 1; |
118 | 118 |
|
119 | 119 |
mprintf("\n"); |
120 |
- mprintf(" Clam AntiVirus: freshclam "VERSION"\n"); |
|
120 |
+ mprintf(" Clam AntiVirus: freshclam %s\n", get_version()); |
|
121 | 121 |
mprintf(" (C) 2002 - 2007 ClamAV Team - http://www.clamav.net/team\n\n"); |
122 | 122 |
|
123 | 123 |
mprintf(" --help -h show help\n"); |
... | ... |
@@ -511,7 +511,7 @@ int main(int argc, char **argv) |
511 | 511 |
|
512 | 512 |
active_children = 0; |
513 | 513 |
|
514 |
- logg("#freshclam daemon "VERSION" (OS: "TARGET_OS_TYPE", ARCH: "TARGET_ARCH_TYPE", CPU: "TARGET_CPU_TYPE")\n"); |
|
514 |
+ logg("#freshclam daemon %s (OS: "TARGET_OS_TYPE", ARCH: "TARGET_ARCH_TYPE", CPU: "TARGET_CPU_TYPE")\n", get_version()); |
|
515 | 515 |
|
516 | 516 |
#ifdef C_WINDOWS |
517 | 517 |
signal(SIGINT, daemon_sighandler); |
... | ... |
@@ -473,7 +473,6 @@ static struct cl_cvd *remote_cvdhead(const char *file, const char *hostname, cha |
473 | 473 |
int bread, cnt, sd; |
474 | 474 |
unsigned int i, j; |
475 | 475 |
char *remotename = NULL, *authorization = NULL; |
476 |
- const char *agent; |
|
477 | 476 |
struct cl_cvd *cvd; |
478 | 477 |
char last_modified[36]; |
479 | 478 |
struct stat sb; |
... | ... |
@@ -507,23 +506,15 @@ static struct cl_cvd *remote_cvdhead(const char *file, const char *hostname, cha |
507 | 507 |
|
508 | 508 |
logg("Reading CVD header (%s): ", file); |
509 | 509 |
|
510 |
- if(uas) |
|
511 |
- agent = uas; |
|
512 |
- else |
|
513 |
-#ifdef CL_EXPERIMENTAL |
|
514 |
- agent = PACKAGE"/"VERSION"-exp"; |
|
515 |
-#else |
|
516 |
- agent = PACKAGE"/"VERSION; |
|
517 |
-#endif |
|
518 |
- |
|
519 | 510 |
snprintf(cmd, sizeof(cmd), |
520 | 511 |
"GET %s/%s HTTP/1.0\r\n" |
521 | 512 |
"Host: %s\r\n%s" |
522 |
- "User-Agent: %s\r\n" |
|
513 |
+ "User-Agent: %s%s\r\n" |
|
523 | 514 |
"Connection: close\r\n" |
524 | 515 |
"Range: bytes=0-511\r\n" |
525 | 516 |
"If-Modified-Since: %s\r\n" |
526 |
- "\r\n", (remotename != NULL) ? remotename : "", file, hostname, (authorization != NULL) ? authorization : "", agent, last_modified); |
|
517 |
+ "\r\n", (remotename != NULL) ? remotename : "", file, hostname, (authorization != NULL) ? authorization : "", |
|
518 |
+ uas ? uas : PACKAGE"/",uas ? "" : get_version(), last_modified); |
|
527 | 519 |
|
528 | 520 |
free(remotename); |
529 | 521 |
free(authorization); |
... | ... |
@@ -641,7 +632,7 @@ static int getfile(const char *srcfile, const char *destfile, const char *hostna |
641 | 641 |
percentage = 0, sd; |
642 | 642 |
unsigned int i; |
643 | 643 |
char *remotename = NULL, *authorization = NULL, *headerline, ipaddr[16]; |
644 |
- const char *rotation = "|/-\\", *agent; |
|
644 |
+ const char *rotation = "|/-\\"; |
|
645 | 645 |
|
646 | 646 |
|
647 | 647 |
if(proxy) { |
... | ... |
@@ -659,24 +650,16 @@ static int getfile(const char *srcfile, const char *destfile, const char *hostna |
659 | 659 |
} |
660 | 660 |
} |
661 | 661 |
|
662 |
- if(uas) |
|
663 |
- agent = uas; |
|
664 |
- else |
|
665 |
-#ifdef CL_EXPERIMENTAL |
|
666 |
- agent = PACKAGE"/"VERSION"-exp"; |
|
667 |
-#else |
|
668 |
- agent = PACKAGE"/"VERSION; |
|
669 |
-#endif |
|
670 |
- |
|
671 | 662 |
snprintf(cmd, sizeof(cmd), |
672 | 663 |
"GET %s/%s HTTP/1.0\r\n" |
673 | 664 |
"Host: %s\r\n%s" |
674 |
- "User-Agent: %s\r\n" |
|
665 |
+ "User-Agent: %s%s\r\n" |
|
675 | 666 |
#ifdef FRESHCLAM_NO_CACHE |
676 | 667 |
"Cache-Control: no-cache\r\n" |
677 | 668 |
#endif |
678 | 669 |
"Connection: close\r\n" |
679 |
- "\r\n", (remotename != NULL) ? remotename : "", srcfile, hostname, (authorization != NULL) ? authorization : "", agent); |
|
670 |
+ "\r\n", (remotename != NULL) ? remotename : "", srcfile, hostname, (authorization != NULL) ? authorization : "", |
|
671 |
+ uas ? uas : PACKAGE"/", uas ? "" : get_version()); |
|
680 | 672 |
|
681 | 673 |
memset(ipaddr, 0, sizeof(ipaddr)); |
682 | 674 |
|
... | ... |
@@ -1412,10 +1395,10 @@ int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, c |
1412 | 1412 |
|
1413 | 1413 |
logg("*Software version from DNS: %s\n", newver); |
1414 | 1414 |
|
1415 |
- if(vwarning && !strstr(cl_retver(), "devel") && !strstr(cl_retver(), "rc")) { |
|
1416 |
- if(strcmp(cl_retver(), newver)) { |
|
1415 |
+ if(vwarning && !strstr(get_version(), "devel") && !strstr(get_version(), "rc")) { |
|
1416 |
+ if(strcmp(get_version(), newver)) { |
|
1417 | 1417 |
logg("^Your ClamAV installation is OUTDATED!\n"); |
1418 |
- logg("^Local version: %s Recommended version: %s\n", cl_retver(), newver); |
|
1418 |
+ logg("^Local version: %s Recommended version: %s\n", get_version(), newver); |
|
1419 | 1419 |
logg("DON'T PANIC! Read http://www.clamav.net/support/faq\n"); |
1420 | 1420 |
outdated = 1; |
1421 | 1421 |
} |
... | ... |
@@ -207,8 +207,10 @@ libclamav_la_SOURCES = \ |
207 | 207 |
.PHONY: version.h.tmp |
208 | 208 |
version.lo: version.h |
209 | 209 |
version.h: version.h.tmp |
210 |
- @if ! diff $@ $< >/dev/null 2>/dev/null; then\ |
|
211 |
- cp $< $@;\ |
|
210 |
+ @if test -f version.h.static; then\ |
|
211 |
+ cp version.h.static version.h;\ |
|
212 |
+ elif ! diff $@ version.h.tmp >/dev/null 2>/dev/null; then\ |
|
213 |
+ cp version.h.tmp $@;\ |
|
212 | 214 |
fi |
213 | 215 |
|
214 | 216 |
version.h.tmp: |
... | ... |
@@ -216,12 +218,16 @@ version.h.tmp: |
216 | 216 |
rm -f $@;\ |
217 | 217 |
REVISION="$$(LANG=C svnversion "$(top_srcdir)" 2>/dev/null || echo exported)";\ |
218 | 218 |
if test $$REVISION = "exported"; then\ |
219 |
- REVISION="$$(LANG=C cd "$(top_srcdir)"; git-svn info configure | awk '/Revision:/ { print $$2 }' || echo exported)";\ |
|
220 |
- if test ! $$REVISION = "exported"; then\ |
|
221 |
- REVISION="$$REVISION-$$(LANG=C cd "$(top_srcdir)"; git-describe --always)";\ |
|
219 |
+ REVISION="$$(LANG=C cd "$(top_srcdir)"; git-svn info configure 2>/dev/null| awk '/Revision:/ { print $$2 }' || echo)";\ |
|
220 |
+ if test -n "$$REVISION"; then\ |
|
221 |
+ REVISION="$$REVISION-$$(LANG=C cd "$(top_srcdir)"; git-describe --always 2>/dev/null)";\ |
|
222 | 222 |
fi;\ |
223 | 223 |
fi;\ |
224 |
- echo "#define REPO_VERSION \"devel-r$$REVISION\"" >> $@ |
|
224 |
+ if test -n "$$REVISION"; then\ |
|
225 |
+ echo "#define REPO_VERSION \"devel-r$$REVISION\"" >> $@;\ |
|
226 |
+ else\ |
|
227 |
+ touch version.h.tmp;\ |
|
228 |
+ fi |
|
225 | 229 |
|
226 | 230 |
libclamav_internal_utils_la_SOURCES=str.c \ |
227 | 231 |
str.h \ |
... | ... |
@@ -1036,8 +1036,10 @@ uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES |
1036 | 1036 |
.PHONY: version.h.tmp |
1037 | 1037 |
version.lo: version.h |
1038 | 1038 |
version.h: version.h.tmp |
1039 |
- @if ! diff $@ $< >/dev/null 2>/dev/null; then\ |
|
1040 |
- cp $< $@;\ |
|
1039 |
+ @if test -f version.h.static; then\ |
|
1040 |
+ cp version.h.static version.h;\ |
|
1041 |
+ elif ! diff $@ version.h.tmp >/dev/null 2>/dev/null; then\ |
|
1042 |
+ cp version.h.tmp $@;\ |
|
1041 | 1043 |
fi |
1042 | 1044 |
|
1043 | 1045 |
version.h.tmp: |
... | ... |
@@ -1045,12 +1047,16 @@ version.h.tmp: |
1045 | 1045 |
rm -f $@;\ |
1046 | 1046 |
REVISION="$$(LANG=C svnversion "$(top_srcdir)" 2>/dev/null || echo exported)";\ |
1047 | 1047 |
if test $$REVISION = "exported"; then\ |
1048 |
- REVISION="$$(LANG=C cd "$(top_srcdir)"; git-svn info configure | awk '/Revision:/ { print $$2 }' || echo exported)";\ |
|
1049 |
- if test ! $$REVISION = "exported"; then\ |
|
1050 |
- REVISION="$$REVISION-$$(LANG=C cd "$(top_srcdir)"; git-describe --always)";\ |
|
1048 |
+ REVISION="$$(LANG=C cd "$(top_srcdir)"; git-svn info configure 2>/dev/null| awk '/Revision:/ { print $$2 }' || echo)";\ |
|
1049 |
+ if test -n "$$REVISION"; then\ |
|
1050 |
+ REVISION="$$REVISION-$$(LANG=C cd "$(top_srcdir)"; git-describe --always 2>/dev/null)";\ |
|
1051 | 1051 |
fi;\ |
1052 | 1052 |
fi;\ |
1053 |
- echo "#define REPO_VERSION \"devel-r$$REVISION\"" >> $@ |
|
1053 |
+ if test -n "$$REVISION"; then\ |
|
1054 |
+ echo "#define REPO_VERSION \"devel-r$$REVISION\"" >> $@;\ |
|
1055 |
+ else\ |
|
1056 |
+ touch version.h.tmp;\ |
|
1057 |
+ fi |
|
1054 | 1058 |
|
1055 | 1059 |
@MAINTAINER_MODE_TRUE@jsparse-keywords.gperf: jsparse/keywords.list jsparse/future_reserved_words.list jsparse/special_keywords.list |
1056 | 1060 |
@MAINTAINER_MODE_TRUE@ echo -e "struct keyword { const char *name; int val; };\n%%" >keywords-g-tmp |
... | ... |
@@ -2,12 +2,14 @@ |
2 | 2 |
#include "clamav-config.h" |
3 | 3 |
#endif |
4 | 4 |
#include "version.h" |
5 |
+#include <string.h> |
|
5 | 6 |
|
7 |
+#ifndef REPO_VERSION |
|
8 |
+#define REPO_VERSION VERSION |
|
9 |
+#endif |
|
10 |
+ |
|
11 |
+/* libclamav's version is always the SVN revision (if available) */ |
|
6 | 12 |
const char *cl_retver(void) |
7 | 13 |
{ |
8 |
- if(!strncmp("devel-",VERSION,6) && strcmp("exported",REPO_VERSION)) { |
|
9 |
- return REPO_VERSION; |
|
10 |
- } |
|
11 |
- /* it is a release, or we have nothing better */ |
|
12 |
- return VERSION; |
|
14 |
+ return REPO_VERSION; |
|
13 | 15 |
} |
... | ... |
@@ -43,6 +43,7 @@ |
43 | 43 |
#include "libclamav/cvd.h" |
44 | 44 |
#include "libclamav/others.h" /* for cli_rmdirs() */ |
45 | 45 |
#include "libclamav/regex/regex.h" |
46 |
+#include "libclamav/version.h" |
|
46 | 47 |
#include "shared/misc.h" |
47 | 48 |
|
48 | 49 |
#ifndef O_BINARY |
... | ... |
@@ -55,6 +56,24 @@ |
55 | 55 |
#define EXP "" |
56 | 56 |
#endif |
57 | 57 |
|
58 |
+#ifndef REPO_VERSION |
|
59 |
+#define REPO_VERSION "exported" |
|
60 |
+#endif |
|
61 |
+ |
|
62 |
+#ifdef CL_EXPERIMENTAL |
|
63 |
+#define EXP_VER "-exp" |
|
64 |
+#else |
|
65 |
+#define EXP_VER |
|
66 |
+#endif |
|
67 |
+ |
|
68 |
+const char *get_version(void) |
|
69 |
+{ |
|
70 |
+ if(!strncmp("devel-",VERSION,6) && strcmp("exported",REPO_VERSION)) { |
|
71 |
+ return REPO_VERSION""EXP_VER; |
|
72 |
+ } |
|
73 |
+ /* it is a release, or we have nothing better */ |
|
74 |
+ return VERSION""EXP_VER; |
|
75 |
+} |
|
58 | 76 |
/* CL_NOLIBCLAMAV means to omit functions that depends on libclamav */ |
59 | 77 |
#ifndef CL_NOLIBCLAMAV |
60 | 78 |
char *freshdbdir(void) |
... | ... |
@@ -106,6 +125,7 @@ char *freshdbdir(void) |
106 | 106 |
return retdir; |
107 | 107 |
} |
108 | 108 |
|
109 |
+ |
|
109 | 110 |
void print_version(const char *dbdir) |
110 | 111 |
{ |
111 | 112 |
char *fdbdir, *path; |
... | ... |
@@ -119,7 +139,7 @@ void print_version(const char *dbdir) |
119 | 119 |
pt = fdbdir = freshdbdir(); |
120 | 120 |
|
121 | 121 |
if(!pt) { |
122 |
- printf("ClamAV %s"EXP"\n",cl_retver()); |
|
122 |
+ printf("ClamAV %s"EXP"\n",get_version()); |
|
123 | 123 |
return; |
124 | 124 |
} |
125 | 125 |
|
... | ... |
@@ -139,10 +159,10 @@ void print_version(const char *dbdir) |
139 | 139 |
if(!access(path, R_OK) && (daily = cl_cvdhead(path))) { |
140 | 140 |
time_t t = (time_t) daily->stime; |
141 | 141 |
|
142 |
- printf("ClamAV %s"EXP"/%d/%s", cl_retver(), daily->version, ctime(&t)); |
|
142 |
+ printf("ClamAV %s"EXP"/%d/%s", get_version(), daily->version, ctime(&t)); |
|
143 | 143 |
cl_cvdfree(daily); |
144 | 144 |
} else { |
145 |
- printf("ClamAV %s"EXP"\n",cl_retver()); |
|
145 |
+ printf("ClamAV %s"EXP"\n",get_version()); |
|
146 | 146 |
} |
147 | 147 |
|
148 | 148 |
free(path); |
... | ... |
@@ -1696,7 +1696,7 @@ static int makediff(struct optstruct *opt) |
1696 | 1696 |
static void help(void) |
1697 | 1697 |
{ |
1698 | 1698 |
mprintf("\n"); |
1699 |
- mprintf(" Clam AntiVirus: Signature Tool (sigtool) "VERSION"\n"); |
|
1699 |
+ mprintf(" Clam AntiVirus: Signature Tool (sigtool) %s\n", get_version()); |
|
1700 | 1700 |
mprintf(" (C) 2002 - 2007 ClamAV Team - http://www.clamav.net/team\n\n"); |
1701 | 1701 |
|
1702 | 1702 |
mprintf(" --help -h show help\n"); |
... | ... |
@@ -70,13 +70,16 @@ START_TEST (test_cl_retdbdir) |
70 | 70 |
fail_unless(!strcmp(DATADIR, cl_retdbdir()), "cl_retdbdir"); |
71 | 71 |
END_TEST |
72 | 72 |
|
73 |
+#ifndef REPO_VERSION |
|
74 |
+#define REPO_VERSION VERSION |
|
75 |
+#endif |
|
76 |
+ |
|
73 | 77 |
/* extern const char *cl_retver(void); */ |
74 | 78 |
START_TEST (test_cl_retver) |
75 | 79 |
const char *ver = cl_retver(); |
76 |
- if(strstr(VERSION,"devel")) |
|
77 |
- fail_unless(!strcmp(REPO_VERSION, ver),"cl_retver"); |
|
78 |
- else |
|
79 |
- fail_unless(!strcmp(VERSION, ver),"cl_retver"); |
|
80 |
+ fail_unless(!strcmp(REPO_VERSION, ver),"cl_retver"); |
|
81 |
+ fail_unless(strcspn(ver,"012345789") < strlen(ver), |
|
82 |
+ "cl_retver must have a number"); |
|
80 | 83 |
END_TEST |
81 | 84 |
|
82 | 85 |
/* extern void cl_cvdfree(struct cl_cvd *cvd); */ |