Browse code

add --mdb option

git-svn: trunk@2715

Tomasz Kojm authored on 2007/02/13 04:30:22
Showing 3 changed files
... ...
@@ -1,3 +1,7 @@
1
+Mon Feb 12 20:27:01 CET 2007 (tk)
2
+---------------------------------
3
+  * sigtool/sigtool.c: add --mdb option, requested by Christoph
4
+
1 5
 Mon Feb 12 20:10:23 CET 2007 (tk)
2 6
 ---------------------------------
3 7
   * shared/options.c: fix bb#254
... ...
@@ -30,6 +30,9 @@ Read data from stdin and write hex string to stdout.
30 30
 \fB\-\-md5 [FILES]\fR
31 31
 Generate MD5 checksum from stdin or MD5 sigs for FILES.
32 32
 .TP 
33
+\fB\-\-mdb [FILES]\fR
34
+Generate .mdb signatures for FILES.
35
+.TP 
33 36
 \fB\-\-html\-normalise=FILE\fR
34 37
 Create normalised HTML files comment.html, nocomment.html, and script.html in current working directory.
35 38
 .TP 
... ...
@@ -84,7 +84,7 @@ static int hexdump(void)
84 84
     return 0;
85 85
 }
86 86
 
87
-static int md5sig(struct optstruct *opt)
87
+static int md5sig(struct optstruct *opt, unsigned int mdb)
88 88
 {
89 89
 	char *md5, *filename;
90 90
 	int i;
... ...
@@ -101,7 +101,10 @@ static int md5sig(struct optstruct *opt)
101 101
 	    } else {
102 102
 		if((sb.st_mode & S_IFMT) == S_IFREG) {
103 103
 		    if((md5 = cli_md5file(filename))) {
104
-			mprintf("%s:%d:%s\n", md5, sb.st_size, filename);
104
+			if(mdb)
105
+			    mprintf("%d:%s:%s\n", sb.st_size, md5, filename);
106
+			else
107
+			    mprintf("%s:%d:%s\n", md5, sb.st_size, filename);
105 108
 			free(md5);
106 109
 		    } else {
107 110
 			mprintf("!md5sig: Can't generate MD5 checksum for %s\n", filename);
... ...
@@ -1694,6 +1697,7 @@ void help(void)
1694 1694
     mprintf("                                           string and print it on stdout\n");
1695 1695
     mprintf("    --md5 [FILES]                          generate MD5 checksum from stdin\n");
1696 1696
     mprintf("                                           or MD5 sigs for FILES\n");
1697
+    mprintf("    --mdb [FILES]                          generate .mdb sigs\n");
1697 1698
     mprintf("    --html-normalise=FILE                  create normalised parts of HTML file\n");
1698 1699
     mprintf("    --utf16-decode=FILE                    decode UTF16 encoded files\n");
1699 1700
     mprintf("    --info=FILE            -i FILE         print database information\n");
... ...
@@ -1728,6 +1732,7 @@ int main(int argc, char **argv)
1728 1728
 	    {"tempdir", 1, 0, 0},
1729 1729
 	    {"hex-dump", 0, 0, 0},
1730 1730
 	    {"md5", 0, 0, 0},
1731
+	    {"mdb", 0, 0, 0},
1731 1732
 	    {"html-normalise", 1, 0, 0},
1732 1733
 	    {"utf16-decode", 1, 0, 0},
1733 1734
 	    {"build", 1, 0, 'b'},
... ...
@@ -1774,7 +1779,9 @@ int main(int argc, char **argv)
1774 1774
     if(opt_check(opt, "hex-dump"))
1775 1775
 	ret = hexdump();
1776 1776
     else if(opt_check(opt, "md5"))
1777
-	ret = md5sig(opt);
1777
+	ret = md5sig(opt, 0);
1778
+    else if(opt_check(opt, "mdb"))
1779
+	ret = md5sig(opt, 1);
1778 1780
     else if(opt_check(opt, "html-normalise"))
1779 1781
 	ret = htmlnorm(opt);
1780 1782
     else if(opt_check(opt, "utf16-decode"))