Browse code

make update messages more precise

git-svn: trunk@2474

Tomasz Kojm authored on 2006/11/02 08:22:05
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Thu Nov  2 00:20:36 CET 2006 (tk)
2
+---------------------------------
3
+  * freshclam/manager.c: make update messages more precise
4
+
1 5
 Wed Nov  1 19:15:57 CET 2006 (tk)
2 6
 ---------------------------------
3 7
   * libclamav/others.c: add cli_strdup(), thanks to NJH
... ...
@@ -746,20 +746,21 @@ static int getpatch(const char *dbname, int version, const char *hostname, char
746 746
     return 0;
747 747
 }
748 748
 
749
-static struct cl_cvd *currentdb(const char *dbname)
749
+static struct cl_cvd *currentdb(const char *dbname, unsigned int *inc)
750 750
 {
751 751
 	struct stat sb;
752 752
 	char path[512];
753 753
 	struct cl_cvd *cvd;
754
-	short inc = 0;
755 754
 
756 755
 
757 756
     snprintf(path, sizeof(path), "%s.inc", dbname);
758 757
     if(stat(path, &sb) != -1) {
759 758
 	snprintf(path, sizeof(path), "%s.inc/%s.info", dbname, dbname);
760
-	inc = 1;
761
-    } else
759
+	*inc = 1;
760
+    } else {
762 761
 	snprintf(path, sizeof(path), "%s.cvd", dbname);
762
+	*inc = 0;
763
+    }
763 764
 
764 765
     cvd = cl_cvdhead(path);
765 766
 
... ...
@@ -773,7 +774,7 @@ int updatedb(const char *dbname, const char *hostname, char *ip, int *signo, con
773 773
 	int nodb = 0, currver = 0, newver = -1, ret, port = 0, ims = -1, i;
774 774
 	char *pt, dbfile[32], dbinc[32];
775 775
 	const char *proxy = NULL, *user = NULL, *pass = NULL, *uas = NULL;
776
-	int flevel = cl_retflevel();
776
+	unsigned int flevel = cl_retflevel(), inc;
777 777
 	struct stat sb;
778 778
 	int ctimeout, rtimeout;
779 779
 
... ...
@@ -781,8 +782,9 @@ int updatedb(const char *dbname, const char *hostname, char *ip, int *signo, con
781 781
     snprintf(dbfile, sizeof(dbfile), "%s.cvd", dbname);
782 782
     snprintf(dbinc, sizeof(dbinc), "%s.inc", dbname);
783 783
 
784
-    if(!(current = currentdb(dbname))) {
784
+    if(!(current = currentdb(dbname, &inc))) {
785 785
 	nodb = 1;
786
+	inc = 0;
786 787
 	if(stat(dbinc, &sb) != -1) {
787 788
 	    logg("^Removing corrupted incremental directory %s\n", dbinc);
788 789
 	    if(rmdirs(dbinc)) {
... ...
@@ -861,7 +863,7 @@ int updatedb(const char *dbname, const char *hostname, char *ip, int *signo, con
861 861
 	remote = remote_cvdhead(dbfile, hostname, ip, localip, proxy, port, user, pass, uas, &ims, ctimeout, rtimeout);
862 862
 
863 863
 	if(!nodb && !ims) {
864
-	    logg("%s is up to date (version: %d, sigs: %d, f-level: %d, builder: %s)\n", dbfile, current->version, current->sigs, current->fl, current->builder);
864
+	    logg("%s is up to date (version: %d, sigs: %d, f-level: %d, builder: %s)\n", inc ? dbinc : dbfile, current->version, current->sigs, current->fl, current->builder);
865 865
 	    *signo += current->sigs;
866 866
 	    cl_cvdfree(current);
867 867
 	    return 1;
... ...
@@ -878,7 +880,7 @@ int updatedb(const char *dbname, const char *hostname, char *ip, int *signo, con
878 878
     }
879 879
 
880 880
     if(!nodb && (current->version >= newver)) {
881
-	logg("%s is up to date (version: %d, sigs: %d, f-level: %d, builder: %s)\n", dbfile, current->version, current->sigs, current->fl, current->builder);
881
+	logg("%s is up to date (version: %d, sigs: %d, f-level: %d, builder: %s)\n", inc ? dbinc : dbfile, current->version, current->sigs, current->fl, current->builder);
882 882
 
883 883
 	if(!outdated && flevel < current->fl) {
884 884
 	    /* display warning even for already installed database */
... ...
@@ -948,13 +950,13 @@ int updatedb(const char *dbname, const char *hostname, char *ip, int *signo, con
948 948
 	}
949 949
     }
950 950
 
951
-    if(!(current = currentdb(dbname))) {
951
+    if(!(current = currentdb(dbname, &inc))) {
952 952
 	/* should never be reached */
953 953
 	logg("!Can't parse new database\n");
954 954
 	return 55; /* FIXME */
955 955
     }
956 956
 
957
-    logg("%s updated (version: %d, sigs: %d, f-level: %d, builder: %s)\n", dbfile, current->version, current->sigs, current->fl, current->builder);
957
+    logg("%s updated (version: %d, sigs: %d, f-level: %d, builder: %s)\n", inc ? dbinc : dbfile, current->version, current->sigs, current->fl, current->builder);
958 958
 
959 959
     if(flevel < current->fl) {
960 960
 	logg("^Your ClamAV installation is OUTDATED!\n");