Module Name:    othersrc
Committed By:   agc
Date:           Sat Aug 17 20:13:48 UTC 2013

Modified Files:
        othersrc/external/bsd/multigest/dist: main.c multigest.c multigest.h

Log Message:
adapt the signature of the multigest_file() and multigests_data()
functions to return the output digest (albeit in raw format), and to
take the algorithm list as the first argument.  this makes it mirror
the normal digest *Data() and *File() functions signatures.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 othersrc/external/bsd/multigest/dist/main.c \
    othersrc/external/bsd/multigest/dist/multigest.c \
    othersrc/external/bsd/multigest/dist/multigest.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/bsd/multigest/dist/main.c
diff -u othersrc/external/bsd/multigest/dist/main.c:1.2 othersrc/external/bsd/multigest/dist/main.c:1.3
--- othersrc/external/bsd/multigest/dist/main.c:1.2	Sat Aug 17 18:29:35 2013
+++ othersrc/external/bsd/multigest/dist/main.c	Sat Aug 17 20:13:48 2013
@@ -51,7 +51,7 @@ do_input(const char *alg, uint8_t *raw, 
 				break;
 			}
 		}
-		multigest_data(data, cc, alg, raw, pat, repl);
+		multigest_data(alg, data, cc, raw, pat, repl);
 		free(data);
 		return 1;
 	}
@@ -127,7 +127,7 @@ read_check(const char *check)
 	provided = &in[match[4].rm_so];
 	in[match[1].rm_eo] = in[match[2].rm_eo] = in[match[3].rm_eo] = in[match[4].rm_eo] = 0x0;
 	getsubst(subs, from, sizeof(from), to, sizeof(to));
-	multigest_file(file, alg, raw, from, to);
+	multigest_file(alg, file, raw, from, to);
 	multigest_format_hex(raw, alg, calc, sizeof(calc));
 	if ((ret = memcmp(calc, provided, match[4].rm_eo - match[4].rm_so)) != 0) {
 		fprintf(stderr, "multigest: provided digest:   '%s', calculated digest: '%s'\n", provided, calc);
@@ -187,10 +187,10 @@ main(int argc, char **argv)
 		}
 	} else {
 		for (i = optind ; i < argc ; i++) {
-			if (multigest_file(argv[i], alg, raw, from, to)) {
-				multigest_print_hex(raw, alg, outname, argv[i], sub);
-			} else {
+			if (multigest_file(alg, argv[i], raw, from, to) == NULL) {
 				ok = 0;
+			} else {
+				multigest_print_hex(raw, alg, outname, argv[i], sub);
 			}
 		}
 	}
Index: othersrc/external/bsd/multigest/dist/multigest.c
diff -u othersrc/external/bsd/multigest/dist/multigest.c:1.2 othersrc/external/bsd/multigest/dist/multigest.c:1.3
--- othersrc/external/bsd/multigest/dist/multigest.c:1.2	Sat Aug 17 18:29:35 2013
+++ othersrc/external/bsd/multigest/dist/multigest.c	Sat Aug 17 20:13:48 2013
@@ -512,8 +512,8 @@ multigest_final(multigest_t *multigest, 
 }
 
 /* run sed on data and then digest it */
-int
-multigest_data(const char *data, size_t size, const char *alg, uint8_t *raw, const char *pat, const char *repl)
+uint8_t *
+multigest_data(const char *alg, const char *data, size_t size, uint8_t *raw, const char *pat, const char *repl)
 {
 	multigest_t	s;
 
@@ -524,14 +524,14 @@ multigest_data(const char *data, size_t 
 		multigest_update(&s, data, size);
 		multigest_final(&s, raw);
 		multigest_free(&s);
-		return 1;
+		return raw;
 	}
-	return 0;
+	return NULL;
 }
 
 /* run sed, then digest on a file */
-int
-multigest_file(const char *f, const char *alg, uint8_t *raw, const char *pat, const char *repl)
+uint8_t *
+multigest_file(const char *alg, const char *f, uint8_t *raw, const char *pat, const char *repl)
 {
 	struct stat	 st;
 	ssize_t		 rc;
@@ -554,17 +554,17 @@ multigest_file(const char *f, const char
 				if ((rc = read(fileno(fp), mapped, MB(1))) <= 0) {
 					break;
 				}
-				multigest_data(mapped, (size_t)rc, alg, raw, pat, repl);
+				multigest_data(alg, mapped, (size_t)rc, raw, pat, repl);
 			}
 			free(mapped);
 		} else {
-			multigest_data(mapped, size, alg, raw, pat, repl);
+			multigest_data(alg, mapped, size, raw, pat, repl);
 			munmap(mapped, size);
 		}
 		fclose(fp);
-		return 1;
+		return raw;
 	}
-	return 0;
+	return NULL;
 }
 
 /* free resources used in a sedded digest */
Index: othersrc/external/bsd/multigest/dist/multigest.h
diff -u othersrc/external/bsd/multigest/dist/multigest.h:1.2 othersrc/external/bsd/multigest/dist/multigest.h:1.3
--- othersrc/external/bsd/multigest/dist/multigest.h:1.2	Sat Aug 17 18:29:35 2013
+++ othersrc/external/bsd/multigest/dist/multigest.h	Sat Aug 17 20:13:48 2013
@@ -82,8 +82,8 @@ void multigest_update(multigest_t */*mul
 void multigest_final(multigest_t */*multigest*/, uint8_t */*raw*/);
 
 /* high-level interface */
-int multigest_data(const char */*data*/, size_t /*size*/, const char */*alg*/, uint8_t */*raw*/, const char */*pat*/, const char */*repl*/);
-int multigest_file(const char */*f*/, const char */*alg*/, uint8_t */*raw*/, const char */*pat*/, const char */*repl*/);
+uint8_t *multigest_data(const char */*alg*/, const char */*data*/, size_t /*size*/, uint8_t */*raw*/, const char */*pat*/, const char */*repl*/);
+uint8_t *multigest_file(const char */*alg*/, const char */*f*/, uint8_t */*raw*/, const char */*pat*/, const char */*repl*/);
 
 /* output */
 void multigest_unpcstring(const char */*in*/, size_t /*isize*/, char */*out*/, size_t /*osize*/);

Reply via email to