Browse code

Add sigtool --compare.

This can be used how big cdiffs between different files are,
without actually creating CVDs or signed cdiffs.

Török Edvin authored on 2011/12/07 19:50:20
Showing 2 changed files
... ...
@@ -118,6 +118,7 @@ const struct clam_option __clam_options[] = {
118 118
     { NULL, "vba", 0, TYPE_STRING, NULL, -1, NULL, 0, OPT_SIGTOOL, "", "" },
119 119
     { NULL, "vba-hex", 0, TYPE_STRING, NULL, -1, NULL, 0, OPT_SIGTOOL, "", "" },
120 120
     { NULL, "diff", 'd', TYPE_STRING, NULL, -1, NULL, 0, OPT_SIGTOOL, "", "" },
121
+    { NULL, "compare", 0, TYPE_STRING, NULL, -1, NULL, 0, OPT_SIGTOOL, "", "" },
121 122
     { NULL, "run-cdiff", 'r', TYPE_STRING, NULL, -1, NULL, 0, OPT_SIGTOOL, "", "" },
122 123
     { NULL, "verify-cdiff", 0, TYPE_STRING, NULL, -1, NULL, 0, OPT_SIGTOOL, "", "" },
123 124
     { NULL, "defaultcolors", 'd', TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMDTOP, "", "" },
... ...
@@ -1781,6 +1781,15 @@ static int compare(const char *oldpath, const char *newpath, FILE *diff)
1781 1781
     return 0;
1782 1782
 }
1783 1783
 
1784
+static int compareone(const struct optstruct *opts)
1785
+{
1786
+    if(!opts->filename) {
1787
+	mprintf("!makediff: --compare requires two arguments\n");
1788
+	return -1;
1789
+    }
1790
+    return compare(optget(opts,"compare")->strarg, opts->filename[0], stdout);
1791
+}
1792
+
1784 1793
 static int dircopy(const char *src, const char *dest)
1785 1794
 {
1786 1795
 	DIR *dd;
... ...
@@ -2754,6 +2763,7 @@ static void help(void)
2754 2754
     mprintf("    --vba=FILE                             Extract VBA/Word6 macro code\n");
2755 2755
     mprintf("    --vba-hex=FILE                         Extract Word6 macro code with hex values\n");
2756 2756
     mprintf("    --diff=OLD NEW         -d OLD NEW      Create diff for OLD and NEW CVDs\n");
2757
+    mprintf("    --compare=OLD NEW			Show diff between OLD and NEW files in cdiff format\n");
2757 2758
     mprintf("    --run-cdiff=FILE       -r FILE         Execute update script FILE in cwd\n");
2758 2759
     mprintf("    --verify-cdiff=DIFF CVD/CLD            Verify DIFF against CVD/CLD\n");
2759 2760
     mprintf("\n");
... ...
@@ -2837,6 +2847,8 @@ int main(int argc, char **argv)
2837 2837
 	ret = vbadump(opts);
2838 2838
     else if(optget(opts, "diff")->enabled)
2839 2839
 	ret = makediff(opts);
2840
+    else if(optget(opts, "compare")->enabled)
2841
+	ret = compareone(opts);
2840 2842
     else if(optget(opts, "run-cdiff")->enabled)
2841 2843
 	ret = rundiff(opts);
2842 2844
     else if(optget(opts, "verify-cdiff")->enabled) {